Positioning children objects in scene (car <->

2019-07-18 11:55发布

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条回答
戒情不戒烟
2楼-- · 2019-07-18 12:24

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.

查看更多
登录 后发表回答