2

I tried to load scene data into aframe, then below error was showed up

3dio.js:13140 Uncaught (in promise) ReferenceError: io3d is not defined
    at NewComponent.update (3dio.js:13140)
    at NewComponent.updateProperties (aframe-master.js:73663)
    at HTMLElement.value (aframe-master.js:72467)
    at doUpdateComponent (aframe-master.js:72441)
    at Array.forEach (<anonymous>)
    at HTMLElement.value (aframe-master.js:72423)
    at entityLoadCallback (aframe-master.js:72234)
    at emitLoaded (aframe-master.js:73071)
    at <anonymous>

"dependencies": {
    "3dio": "^1.1.1",
    "aframe": "^0.6.0",
    "aframe-animation-component": "^3.2.5",
 }

IO3D is working at global variable, io3d is not defined.

Felix Chang
  • 209
  • 1
  • 5
  • Thanks. I created a pull request which might fix this issue: https://github.com/archilogic-com/3dio-js/pull/116 – tomas polach Dec 20 '17 at 09:31
  • generally it's a bad idea to rely on global variables. Do you use something like webpack (i assume yes, because you are pulling 3dio from npm dependencies)? Then you should import 3dio from npm explicitly. – macrozone Dec 21 '17 at 15:33
  • @macrozone fully agree on global variables being a bad idea. the IO3D (upper case) is being exposed in browser environments only for legacy reasons as window.IO3D. (We should remove it in next major version). io3d (lower case) global is only being exposed if the environment does not support CommonJS or AMD modules (i.e. script has been loaded via script tag in the browser). – tomas polach Dec 29 '17 at 08:42

1 Answers1

1

To use 3dio-js in an ES6 module you can import it like

import io3d from '3dio'
Benjamin
  • 455
  • 4
  • 7