Positioning children objects in scene (car <-> wheels hierarchy)

一世执手 提交于 2019-12-12 21:26:23

问题


I need to add car model to scene with wheels as separated objects to allow their easy rotation and possible replacement. The question is wheels positioning - they need to be on exact places in relation to car body. How it can be done in proper way? In WebGL demos and TriggerRally there are existing wheel positions - they were predefined for 3D scene - but how? Can these positions be somehow mapped to Blender model coordinates?

I've tried to separate one wheel from body, set pivot point to its center, saving coordinates and adding wheel mesh to three.js scene applying Blender position (scaled of course) - but proportions seem to be mismatched.

I've found OBJLoader with hierarchy import but it is non-core three.js feature so I've decided to stick with JSONLoader (where I need to do grouping/hierarchy manually).

Thanks.


回答1:


You can try to place all car elements in different THREE.Object3D like this:

  1. Car model
  2. Left front wheel
  3. Right front wheel
  4. Left back wheel
  5. Left back wheel

By adding each element to new THREE.Object3D You will gain a new pivot point for each element (it will simplify further movement and rotation commands). You have to remember to set proper position of element according to it's parent (THREE.Object3D).

Then you just add 2-5 into 1.



来源:https://stackoverflow.com/questions/14353427/positioning-children-objects-in-scene-car-wheels-hierarchy

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