Way to handle multple object as a single one in thee.js

不问归期 提交于 2019-12-12 05:39:52

问题


I'm new to three.js. I need to handle multiple objects as a single one. In simple terms I need to render a kind of bas-relief:

  • a box geometry (the base)
  • an extruded image on top of it
  • and some text.

Each object has to have a different material but they has to act as a single one: location and rotation the same etc.

I'm still new to three.js so I don't know how to make a kind of composite pattern: with group? Joining geometry? Join mesh? What is the best way?

Right now I'm using everything in a group but.. it seems a bit slow.


回答1:


You could nest your objects in an Object3D instance.

group = new THREE.Object3D(); //create a container
group.add( mesh1 ); //add a mesh with geometry to it
group.add( mesh2 );
scene.add( group ); //add the group to the scene

EDIT:
Release 69 added THREE.Group class and the release note say to use this instead of Object3D where possible, but I can not find any other documentation.
https://github.com/mrdoob/three.js/releases

group = new THREE.Group(); //create a container
group.add( mesh1 ); //add a mesh with geometry to it
group.add( mesh2 );
scene.add( group ); //add the group to the scene


来源:https://stackoverflow.com/questions/28397857/way-to-handle-multple-object-as-a-single-one-in-thee-js

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