首页 > 解决方案 > 如何平移、旋转、缩放 GLTF 3D 模型(Three.js)

问题描述

想知道在模型加载到场景后是否可以平移、旋转、缩放模型。我也在寻找一种更好的方式来使用加载,因为我有多个模型要添加到我的程序中,但我不想调用 `loaded.load(...); 每次。

这是我使用的:

var loader = new THREE.GLTFLoader();

loader.load( 'models/model_environment/scene.gltf', 
    function ( gltf ) {

        cube_Geometry = new THREE.BoxGeometry(10,10,10);
        cube_Material = new THREE.MeshNormalMaterial();
        cube_Mesh = new THREE.Mesh(cube_Geometry, cube_Material);
        cube_Mesh.position.set(0,5,0);
        canvas_Scene.add(cube_Mesh);
        canvas_Scene.add(gltf.scene);
        modelsLoaded = true;
    }, 
    undefined, 
    function ( error ) {
        console.error( error );
    } 
);

请注意,已加载的模型在 Y 轴(地面)上低于 0:

在此处输入图像描述

标签: javascriptthree.jstranslate3d-modelgltf

解决方案


推荐阅读