简体   繁体   English

RequireJS和THREE.js轨道控件

[英]RequireJS and THREE.js Orbit Controls

I am using THREEjs r83 in a requirejs build. 我在requirejs构建中使用THREEjs r83。 No matter what I do, the OrbitControl is loading & running before THREEjs initiates so I get the persistant error: 无论我做什么,OrbitControl都会在THREEjs启动之前加载并运行,因此我得到了持久性错误:

Uncaught ReferenceError: THREE is not defined 未捕获的ReferenceError:未定义三

Here is the initial part of my file where you can see THREE is required as a shim for the OrbitControl. 这是我文件的初始部分,您可以在其中看到3个作为OrbitControl的垫片。 I've gone over the code repeatedly & cannot work out a solution. 我反复检查了代码,无法解决。 Can anyone help me out? 谁能帮我吗?

requirejs.config({
    paths: {
        three: 'lib/three'
    },
    shim: {
        'three': ["lib/FloatFix"],
        'lib/OrbitControls': ["three"]
    }
});
require(
    [
        'jquery',
        'three',
        'lib/OrbitControls'
    ],
    ...

I had this issue ( was using trackball instead of orbit) a while back. 我有这个问题(使用轨迹球而不是轨道)。 Try this: 尝试这个:

paths: {
    three: 'lib/three'
    orbit: 'lib/OrbitControls'
},
shim: {
    'three': {
        exports: 'THREE'
    },
    'orbit': {
        deps: ['three']
    }
}

Let me know if this works for you. 让我知道这是否适合您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM