Three.js import with ES6 tells 'global' is

2019-08-23 04:50发布

Apart from missing something in this thread and topic-related threads, I tried this:

import * as THREE from './libraries/three.js';

This fails. Browsers (Firefox-Chrome) tell me that 'global' is 'undefined'. Looking at three.js header code, 'global' is set to 'this' which is itself undefined.

What I don't understand is that old-fashion loading of three.js works fine ('global' is set to 'window' because 'this === window'). With ES6 import, I checked that 'this === undefined' in the header code.

To sum up, I perfectly understand why ES6 import fails, but I strongly wonder how one may use 'import * as THREE from './libraries/three.js'; ' without facing problems??? Highlights welcomed!!!

0条回答
登录 后发表回答