javascript - 如何平移、旋转、缩放 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:
解决方案
推荐阅读
- android-studio - 任何人都可以帮助我尝试调用虚拟方法“void android.widget.TextView.setText(java.lang.CharSequence)”空对象
- c# - 使用 C# 通过 Web 套接字的桌面应用程序的 WebRTC 客户端代码
- python - Python RotatingFileHandler 不旋转
- c - 在 C 编程中创建指向文件的指针数组
- kubernetes - 如何在 k8s 中的两个不同部署之间定义共享持久卷?
- javascript - 获得嵌套承诺的最终价值
- asp.net-mvc - 通过 aspnet_regiis.exe 在 ASP.NET MVC 中加密的 Web.config 抛出错误
- c# - 遍历 DataGridView
- visual-studio-code - 如何使用 mrcrowl 插件在 VS Code 中创建新的 Mercurial 分支?
- python - 正则表达式删除整个外部父模式,但仍保留子模式内的数据。嵌套模式