How do I create resizable objects in THREE.JS

偶尔善良 提交于 2019-12-06 10:48:02

I think easiest would be to create your cube with 1 unit dimensions (1x1x1). Then set the dimensions by scaling it:

mesh.scale.x = width;
mesh.scale.y = height;
mesh.scale.z = depth;

Not actually sure if mesh supports scale, if not, you can wrap it in Object3D

var obj = new THREE.Object3D();
    obj.add(mesh);
obj.scale.x = width;
obj.scale.y = height;
obj.scale.z = depth;

Nothing stops you from modifying the vertices directly. I think you need to specify geometry.dynamic=true; and then geometry.verticesNeedUpdate=true; in that case.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!