将THREE.js与aurelia-cli一起使用,导出为全局

时间:2018-10-04 14:08:41

标签: three.js aurelia aurelia-cli

安装THREE.js:npm install three

配置aurelia.json

"dependencies": [
      {
        "name": "three",
        "path": "../node_modules/three/build",
        "main": "three.min"
      }

导入视图:import * as THREE from 'three';

好的,这样可以正常工作,并且我可以使用three.js,但是,我也想使用一些插件。具体是GPUParticleSystem。现在,此插件依赖于全局THREE对象。首次尝试将其添加到aurelia.json

"dependencies": [
          {
            "name": "three",
            "path": "../node_modules/three/build",
            "main": "three.min",
             "exports": "THREE" //this should make the library a global object?
          }

但是它似乎不起作用?我看不到devTools的全局变量。

1 个答案:

答案 0 :(得分:1)

解决此问题的一种可能方法是在prepend中使用aurelia.json

...
"prepend": [
    "node_modules/three/build/three.min.js",
    "node_modules/three/examples/js/GPUParticleSystem.js"
 ]
...