在three.js中将网格添加到场景之前如何设置网格的位置 [英] How can I set the position of a mesh before I add it to the scene in three.js

查看:26
本文介绍了在three.js中将网格添加到场景之前如何设置网格的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在three.js中,我想在场景中的某个位置添加一个网格

In three.js, I want to add a mesh to a position in the scene

我试过了:

// mesh is a THREE.Mesh
scene is a THREE.Scene
scene.add(mesh)
scene.updateMatrixWorld(true)
mesh.matrixWorld.setPosition(new THREE.Vector3(100, 100, 100))
scene.updateMatrix()

但它没有影响任何东西.

BUT it didn't affect anything.

我该怎么办?

推荐答案

我建议您查看此处的文档:http://threejs.org/docs/#Reference/Objects/Mesh正如您在文档页面顶部看到的,Mesh 继承自Object3D".这意味着您可以使用 Object3D 提供的所有方法或属性.因此,单击文档页面上的Object3D"链接并检查属性列表.您将找到属性.position".单击.position"以查看它是什么数据类型.Paha..它的Vector3.

i would recommend you to check the documenation over here: http://threejs.org/docs/#Reference/Objects/Mesh As you can see on the top of the docu-page, Mesh inherits from "Object3D". That means that you can use all methods or properties that are provided by Object3D. So click on the "Object3D" link on the docu-page and check the properties list. You will find propertie ".position". Click on ".position" to see what data-type it is. Paha..its Vector3.

请尝试执行以下操作:

//scene is a THREE.Scene
scene.add(mesh);
mesh.position.set(100, 100, 100);

这篇关于在three.js中将网格添加到场景之前如何设置网格的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆