我如何使用三个js加载gltf文件

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 );

    });

您好,我正在学习 three.js 并在按照发现three.js 文件加载外部 gltf 文件时遇到错误。我从 google poly 下载了一个文件,但不确定我做错了什么。我在下面遇到错误,并尝试了文档中所述的 loadingmanager。

我正在使用 Flask 运行 应用程序,如果我需要添加更多信息以了解问题,请告诉我。提前谢谢你:)

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

您代码中的 GLTFLoaderthree.js 似乎来自不同的版本。您始终必须确保库核心和示例文件的版本(如 GLTFLoaderOrbitControls)匹配。