【发布时间】:2017-01-29 18:36:45
【问题描述】:
由于https://github.com/antonkulaga/threejs-facade 已经严重过时,我尝试了类似https://github.com/Katrix-/threejs-facade 的方法,并希望为新的three.js 库创建一个外观。
我绝不是JS 专家,也不是Scala.js 专家,所以我很可能在做一些非常愚蠢的事情。
在另一个问题之后,我正在使用这个sbt-scalajs-bundler 和sbt-web-scalajs-bundler
我的build.sbt 看起来像这样:
lazy val client = (project in file("modules/client"))
.enablePlugins(ScalaJSBundlerPlugin, ScalaJSWeb) // ScalaJSBundlerPlugin automatically enables ScalaJSPlugin
.settings(generalSettings: _*)
.settings(
name := "client"
//, scalaJSModuleKind := ModuleKind.CommonJSModule // ScalaJSBundlerPlugin implicitly sets moduleKind to CommonJSModule enables ScalaJSPlugin
,jsDependencies += ProvidedJS / "three.min.js"
)
lazy val server = (project in file("modules/server"))
.enablePlugins(PlayScala, WebScalaJSBundlerPlugin)
.settings(generalSettings: _*)
.settings(
name := "server"
,scalaJSProjects := Seq(client)
,pipelineStages in Assets := Seq(scalaJSPipeline)
//,pipelineStages := Seq(digest, gzip)
,compile in Compile := ((compile in Compile) dependsOn scalaJSPipeline).value
)
three.min.js 在我的client 项目的资源文件夹中。
Facade 的一部分是例如
@js.native
@JSImport("THREE", "Scene")
class Scene extends Object3D {
我想像这样使用它:val scene = new Scene。在scala.js 方面,这实际上编译得很好,但是当我运行它时,我得到:
错误:找不到模块“三”
在浏览器中,我想知道为什么。毕竟在three.min.js中是这样称呼的。
现在我也尝试从服务器端提供和提供three.min.js 文件,因为我认为它可能只是在运行时丢失了,但不,这似乎不是原因。
所以现在我想知道我在这里做错了什么?
只是为了澄清:如果我不导出 Facade 的任何使用,其余转译的 js 工作得很好!
【问题讨论】:
-
也许这就是你要找的东西:scalacenter.github.io/scalajs-bundler/…
标签: three.js scala.js facade transpiler scalajs-bundler