Reputation: 31
I got the package file three.js-dev
from threejs.org 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.
I thought, is there issues about 'javascript import'?
So I searched it, and found this at the MDN and I replaced './Loader'
by "./Loader"
but the error remains.
Is anyone who have wonder wisdom about this issue? Help!
Upvotes: 1
Views: 3000
Reputation: 2543
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: http://threejs.org/docs/index.html?q=json#Reference/Loaders/JSONLoader
Upvotes: 1