Three.js 装载机

Three.js Loaders

我从 threejs.org 得到了包文件 three.js-dev,我尝试这样使用它:

<script type="text/javascript" src="./build/three.js"></script>

<script type="text/javascript" src="./src/loaders/JSONLoader.js"></script>

<script src="./examples/js/controls/TrackballControls.js"></script>
<script src="./examples/js/Detector.js"></script>

但是我在控制台中得到一个错误:

JSONLoader.js:1 Uncaught SyntaxError: Unexpected token import

源选项卡中的其他错误。

Uncaught SyntaxError: Unexpected token import

我想,'javascript import'有问题吗?

所以我搜索了一下,然后 found this at the MDN 我用 "./Loader" 替换了 './Loader' 但错误仍然存​​在。

有没有哪位大神知道这个问题?求助!

您引用的是 JSONLoader 的来源。这是使用模块模式(这是 import 标记的用途)在 ES6 中编写的,它被捆绑到您已经引用的 build/three.js 中。问题出现是因为无法在浏览器中使用模块(..yet)。

简单的说,不需要引用/src/loaders/JSONLoader.js,默认包含JSONLoader

看这里: http://threejs.org/docs/index.html?q=json#Reference/Loaders/JSONLoader