0

For example: I added child rectangle(2,3) to main rectangle(1).

Looks like 3 rectangles one by one.

parent.add(obj);

But if I change parent rectangle rotation(1) this causes that childs change position and rotation(!) with the ancestor.

img.example

How to change position and save rotation?

WestLangley
  • 102,557
  • 10
  • 276
  • 276
Vlad
  • 93
  • 1
  • 6
  • Change the axis position of each plane to the start of the mesh, then to achieve what you want you have to rotate plane 2. Plane 1 will rotate all it's children. – Stubbies Jun 21 '16 at 15:14
  • @Vlad See http://stackoverflow.com/questions/29586422/three-js-ignore-parents-rotation. Also see http://stackoverflow.com/questions/15734049/invert-rotation-of-parent-in-the-child-so-the-child-appears-unrotated-in-the-wo/15735090#15735090. – WestLangley Jun 21 '16 at 15:31

1 Answers1

0

If you add object to parent as a child, and change parent's rotation or position, it will affect only parent.

Child element have values untouched, but position and rotation is calculated towards parent. Relations between child and parent of parent are never saved anywhere. That is a reason why you can't save child rotation towards parent of parent. It just not exist.

If you want to move only with parent element, you can calculate children position or rotation towards parent-of-parent and store it somewhere. In each animation frame you must set this position and rotation to each children. This will be not practicable.

To calculate child position towards parent scene see how to: get the global/world position of a child object

but much better approach

is to place other elements into the scene separately, not as a child od object. If you need to make some operations with a group of object, save object identifiers outside and get object by identifier as reference.

scene.getObjectById( 4, true );
Community
  • 1
  • 1
Martin
  • 2,575
  • 6
  • 32
  • 53