cybaj cybaj - 9 months ago 122
Javascript Question

Three.js Loaders

I got the package file

from which I', trying to use like so:

<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>

But in I got an error in the console:

JSONLoader.js:1 Uncaught SyntaxError: Unexpected token import

other error at source tab.

Uncaught SyntaxError: Unexpected token import

I thought, is there issues about 'javascript import'?

So I searched it, and found this at the MDN and I replaced
but the error remains.

Is anyone who have wonder wisdom about this issue? Help!


You are referencing the source of the JSONLoader. This is written in ES6 using a modules pattern (which is what the import token is for), that is bundled into the build/three.js that you are referencing already. The problem arises as it's not possible to use modules in the browser (..yet).

Simply put, you do not need to reference /src/loaders/JSONLoader.js, the JSONLoader is included by default.

See here: