I like to copy a 3dObject in place but all matrixs are getting reset and the copied object is somewhere else in the scene. What do i wrong?
Originalobject:
1. oa {uuid: "900269EB-3D05-4A79-87FC-7596EEC94918", name: "", type: "Mesh", parent: Mr, children: Array(0), …}
1. castShadow: true
2. children: []
3. frustumCulled: true
4. geometry: ki {uuid: "E495D41C-F204-4D41-A53F-32AFC59FEE0C", name: "", type: "BufferGeometry", index: Li, attributes: {…}, …}
5. layers: lr {mask: 1}
6. material: il {uuid: "504CB1D7-717E-42E4-AE85-7584E355F292", name: "gem", type: "MeshPhysicalMaterial", fog: true, blending: 1, …}
7. matrix: ar
1. elements: (16) [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]
2. __proto__: Object
8. matrixAutoUpdate: true
9. matrixWorld: ar
1. elements: (16) [1, 0, 0, 0, 0, 2.220446049250313e-16, -1, 0, 0, 1, 2.220446049250313e-16, 0, -12.898780822753906, 10.827563285827638, -0.07714200019836186, 1]
2. __proto__: Object
10. matrixWorldNeedsUpdate: false
11. name: ""
12. parent: Mr {uuid: "CF28A87B-ADA3-4C46-B52D-46865554F6EB", name: "", type: "Object3D", parent: Ao, children: Array(1), …}
13. position: Qn {x: 0, y: 0, z: 0}
14. quaternion: Yn {_x: 0, _y: 0, _z: 0, _w: 1, _onChangeCallback: ƒ}
15. receiveShadow: false
16. renderOrder: 0
17. rotation: cr {_x: 0, _y: 0, _z: 0, _order: "XYZ", _onChangeCallback: ƒ}
18. scale: Qn {x: 1, y: 1, z: 1}
19. type: "Mesh"
20. up: Qn {x: 0, y: 1, z: 0}
21. userData: {}
22. uuid: "900269EB-3D05-4A79-87FC-7596EEC94918"
23. visible: true
24. drawMode: (...)
25. eulerOrder: (...)
26. id: 7
27. modelViewMatrix: ar
1. elements: (16) [0.7071067811865477, 0.3545308169249882, -0.6118070773131842, 0, -0.7071067811865475, 0.3545308169249884, -0.6118070773131842, 0, 1.570092458683775e-16, 0.8652258662921498, 0.5013822895745312, 0, -9.175363020262832, -4.547232208794878, -481.92182505610884, 1]
2. __proto__: Object
28. normalMatrix: Gn
1. elements: (9) [0.7071067811865474, 0.35453081692498795, -0.6118070773131841, -0.7071067811865474, 0.3545308169249883, -0.611807077313184, 1.110223024625156e-16, 0.8652258662921495, 0.5013822895745311]
2. __proto__: Object
29. useQuaternion: (...)
30. __proto__: Mr
Copied Object:
1. oa {uuid: "7E7757B9-3B1B-46FD-88D6-4720F13B7125", name: "", type: "Mesh", parent: null, children: Array(0), …}
1. castShadow: true
2. children: []
3. frustumCulled: true
4. geometry: ki {uuid: "E495D41C-F204-4D41-A53F-32AFC59FEE0C", name: "", type: "BufferGeometry", index: Li, attributes: {…}, …}
5. layers: lr {mask: 1}
6. material: Rr {uuid: "74992A47-B0AA-4218-8575-37DC3C62E0DA", name: "", type: "MeshBasicMaterial", fog: true, blending: 1, …}
7. matrix: ar {elements: Array(16)}
8. matrixAutoUpdate: true
9. matrixWorld: ar {elements: Array(16)}
10. matrixWorldNeedsUpdate: false
11. name: ""
12. parent: On
1. autoUpdate: true
2. background: wr {r: 1, g: 1, b: 1}
3. castShadow: false
4. children: (4) [vh, Ao, Mr, oa]
5. environment: Yi {uuid: "6CC4BA54-AE89-40D9-9FE8-119DC6E528A7", name: "", image: Array(6), mipmaps: Array(0), mapping: 301, …}
6. fog: null
7. frustumCulled: true
8. layers: vn {mask: 1}
9. matrix: dn
1. elements: (16) [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]
2. __proto__: Object
10. matrixAutoUpdate: true
11. matrixWorld: dn
1. elements: (16) [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]
2. __proto__: Object
12. matrixWorldNeedsUpdate: false
13. name: ""
14. overrideMaterial: null
15. parent: null
16. position: an {x: 0, y: 0, z: 0}
17. quaternion: tn {_x: 0, _y: 0, _z: 0, _w: 1, _onChangeCallback: ƒ}
18. receiveShadow: false
19. renderOrder: 0
20. rotation: gn {_x: 0, _y: 0, _z: 0, _order: "XYZ", _onChangeCallback: ƒ}
21. scale: an {x: 1, y: 1, z: 1}
22. type: "Scene"
23. up: an {x: 0, y: 1, z: 0}
24. userData: {}
25. uuid: "9CFDFDF4-01A6-4653-ACBB-9231190581EF"
26. visible: true
27. _listeners: {dispose: Array(2)}
28. eulerOrder: (...)
29. id: 6
30. modelViewMatrix: dn
1. elements: (16) [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]
2. __proto__: Object
31. normalMatrix: Yt
1. elements: (9) [1, 0, 0, 0, 1, 0, 0, 0, 1]
2. __proto__: Object
32. useQuaternion: (...)
33. __proto__: Cn
13. position: Qn {x: 0, y: 0, z: 0}
14. quaternion: Yn {_x: 0, _y: 0, _z: 0, _w: 1, _onChangeCallback: ƒ}
15. receiveShadow: false
16. renderOrder: 0
17. rotation: cr {_x: -0, _y: 0, _z: -0, _order: "XYZ", _onChangeCallback: ƒ}
18. scale: Qn {x: 1.05, y: 1.05, z: 1.05}
19. type: "Mesh"
20. up: Qn {x: 0, y: 1, z: 0}
21. userData: {}
22. uuid: "7E7757B9-3B1B-46FD-88D6-4720F13B7125"
23. visible: true
24. drawMode: (...)
25. eulerOrder: (...)
26. id: 28
27. modelViewMatrix: ar {elements: Array(16)}
28. normalMatrix: Gn {elements: Array(9)}
29. useQuaternion: (...)
30. __proto__: Mr
Code:
let nMesh = oldMesh.clone();
nMesh.material = outlineMaterial;
nMesh.material.needsUpdate = true;
nMesh.matrix.set(oldMesh.matrix);
nMesh.matrixWorld.set(oldMesh.matrixWorld);
nMesh.matrixWorldNeedsUpdate = true;