RequireJS和THREE.js轨道控件 [英] RequireJS and THREE.js Orbit Controls

查看:535
本文介绍了RequireJS和THREE.js轨道控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在requirejs构建中使用THREEjs r83.无论我做什么,OrbitControl都会加载&在THREEjs启动之前运行,所以我得到了持久性错误:

I am using THREEjs r83 in a requirejs build. No matter what I do, the OrbitControl is loading & running before THREEjs initiates so I get the persistant error:

未捕获的ReferenceError:未定义三个

Uncaught ReferenceError: THREE is not defined

这是文件的初始部分,您可以在其中看到3个作为OrbitControl的垫片.我已经遍历了代码&无法制定解决方案.有人可以帮我吗?

Here is the initial part of my file where you can see THREE is required as a shim for the 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.

这篇关于RequireJS和THREE.js轨道控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆