Three.js - GLTF 模型位置不从原点开始

Var*_*yan 2 javascript three.js

当我尝试加载带有0,0,0位置的 glTF 模型时,它距离原点很远。

当我尝试旋转 glTF 模型时,它围绕原点(用蓝点标记)旋转,而不是从中心旋转。

我认为这是某种关键问题?

我该如何解决?

var tree;
function loadGLTFCharacter(path, position){
    // Load a glTF resource
    loader.load(
        // resource URL
        path,
        // called when the resource is loaded
        function ( gltf ) {
            gltf.scene.traverse( function( node ) {

                if ( node.isMesh ) {
                    node.castShadow = true;
                    node.receiveShadow = true;
                }

            } );
            gltf.scene.position.set(position.x, position.y, position.z);
            tree = gltf.scene;
            scene.add( tree );
            
            gltf.animations; // Array<THREE.AnimationClip>
            gltf.scene; // THREE.Group
            gltf.scenes; // Array<THREE.Group>
            gltf.cameras; // Array<THREE.Camera>
            gltf.asset; // Object

        },
        // called while loading is progressing
        function ( xhr ) {

            console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );

        },
        // called when loading has errors
        function ( error ) {

            console.log( 'An error happened' );

        }
    );
}

loadGLTFCharacter('models/characters/tree_detailed.gltf', {x:0,y:0.2,z:0});
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

Var*_*yan 5

.gltf在文本编辑器中打开该文件,结果发现有一部分:

"nodes": [
{
  "mesh": 0,
  "scale": [
    0.25,
    0.25,
    0.25
  ],
  "translation": [
    6.49107456,
    1.60296546E-31,
    -1.89133477
  ],
  "name": "tree_detailed"
}
],
Run Code Online (Sandbox Code Playgroud)

我将该部分中的数字替换translation为 0, 0, 0,现在工作正常。

我无法理解为什么有人会创建一个具有随机翻译的对象