Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSM / GLTFLoader: Webpack error using jsm #15939

Closed
hevali opened this Issue Mar 9, 2019 · 3 comments

Comments

Projects
None yet
3 participants
@hevali
Copy link

hevali commented Mar 9, 2019

Description of the problem

I´m using three.js in an Angular project with webpack as bundler.
When trying to load a GLTF file a ReferenceError is thrown:

ERROR Error: Uncaught (in promise): ReferenceError: THREE is not defined ReferenceError: THREE is not defined at GLTFLoader.js:2715

Referring to this line of code:

} else if ( geometries.length > 1 && THREE.BufferGeometryUtils !== undefined ) {

In my TypeScript code, I import the loader this way:

import { GLTFLoader} from 'three/examples/jsm/loaders/GLTFLoader';

I guess to fix this, either BufferGeometryUtils hast to be exported in three.module.js or the code block has to be removed from the jsm version of GLTFLoader, as the global THREE object is not defined.

I also found that BufferGeometryUtils is an exception in the modularize script:

{ path: 'loaders/GLTFLoader.js', ignoreList: [ 'NoSide', 'Matrix2', 'DDSLoader', 'DRACOLoader', 'BufferGeometryUtils' ] },

Three.js version
  • Dev
  • [x ] r102
  • ...
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS
Hardware Requirements (graphics card, VR Device, ...)

@donmccurdy donmccurdy changed the title GLTFLoader: Webpack error using jsm JSM / GLTFLoader: Webpack error using jsm Mar 9, 2019

@donmccurdy

This comment has been minimized.

Copy link
Collaborator

donmccurdy commented Mar 9, 2019

Unfortunately the examples/jsm modules aren't fully functional yet sorry. Still working on this.

@Mugen87 Mugen87 added the Bug label Mar 10, 2019

@Mugen87

This comment has been minimized.

Copy link
Collaborator

Mugen87 commented Mar 10, 2019

An other user reported the same problem here:

https://discourse.threejs.org/t/importing-three-r102-examples-jsm-gltfloader-into-angular-7-project/6484

Merging #15582 should solve this issue, right?

@hevali

This comment has been minimized.

Copy link
Author

hevali commented Mar 15, 2019

I´ve tryed the updated GLTFLoader in dev branch and it´s working fine, waiting for the release.
Thanks for the fix!

For anyone that needs an urgent fix, use the 'three-gltf-loader' npm package:

import GLTFLoader from 'three-gltf-loader';

@hevali hevali closed this Mar 15, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.