Awais Munawar
Awais Munawar

Reputation: 15

How do i load gltf files using three js

  var manager = new THREE.LoadingManager();
  const loader = new THREE.GLTFLoader(manager);

  // A reusable function to set up the models. We're passing in a position parameter
  // Load a glTF resource
**line90**      loader.load(
    // resource URL
    'static/ElmTree.gltf',
    // called when the resource is loaded
    function ( gltf ) {

    enter code here

        scene.add( gltf.scene );

    });

Hi I'm learning three.js and getting errors loading files external gltf files by following discoverthree.js file. I downloaded a file from google poly but not sure what i'm doing wrong. I'm getting error below and have tried loadingmanager as stated in documentation as well.

i'm using flask to run the application, please let me know if i need to add more information to understand the problem. thank you in advance :)

three.js:49037 THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.
get @ three.js:49037
(anonymous) @ GLTFLoader.js:2161
Promise.then (async)
THREE.GLTFLoader.GLTFParser.loadTexture @ GLTFLoader.js:2157
THREE.GLTFLoader.GLTFParser.getDependency @ GLTFLoader.js:1829
THREE.GLTFLoader.GLTFParser.assignTexture @ GLTFLoader.js:2223
THREE.GLTFLoader.GLTFParser.loadMaterial @ GLTFLoader.js:2308
THREE.GLTFLoader.GLTFParser.getDependency @ GLTFLoader.js:1825
THREE.GLTFLoader.GLTFParser.loadMesh @ GLTFLoader.js:2675
THREE.GLTFLoader.GLTFParser.getDependency @ GLTFLoader.js:1809
(anonymous) @ GLTFLoader.js:3146
THREE.GLTFLoader.GLTFParser.loadNode @ GLTFLoader.js:3210
THREE.GLTFLoader.GLTFParser.getDependency @ GLTFLoader.js:1805
buildNodeHierachy @ GLTFLoader.js:3269
(anonymous) @ GLTFLoader.js:3351
Promise.then (async)
buildNodeHierachy @ GLTFLoader.js:3336
(anonymous) @ GLTFLoader.js:3351
Promise.then (async)
buildNodeHierachy @ GLTFLoader.js:3336
(anonymous) @ GLTFLoader.js:3351
Promise.then (async)
buildNodeHierachy @ GLTFLoader.js:3336
loadScene @ GLTFLoader.js:3383
THREE.GLTFLoader.GLTFParser.getDependency @ GLTFLoader.js:1801
(anonymous) @ GLTFLoader.js:1877
THREE.GLTFLoader.GLTFParser.getDependencies @ GLTFLoader.js:1875
THREE.GLTFLoader.GLTFParser.getMultiDependencies @ GLTFLoader.js:1902
THREE.GLTFLoader.GLTFParser.parse @ GLTFLoader.js:1703
parse @ GLTFLoader.js:221
(anonymous) @ GLTFLoader.js:75
(anonymous) @ three.js:36378
load (async)
load @ three.js:36356
load @ GLTFLoader.js:71
loadModels @ index.js:90
init @ index.js:21
(anonymous) @ index.js:142

Upvotes: 1

Views: 2014

Answers (1)

Mugen87
Mugen87

Reputation: 31086

It seems that GLTFLoader and three.js in your code are from different releases. You always have to ensure that the version of the library core and example files (like GLTFLoader or OrbitControls) match.

Upvotes: 1

Related Questions