Svelte ❤️ Three
## My code: I'm trying to create an `Object3D` manually, and then attach children to it via the svelte component hierarchy: ```svelte <script> import { Object3D } from 'three'; const myObject = new Object3D(); myObject.name = 'expectedParent'; <script> <Primitive object={myObject}> <Mesh /> </Primitive> ``` ## Expected scene graph The mesh should be a child of the object that we created, named, and passed in: - Scene - expectedParent - Mesh ## Actual scene graph Instead, `<Primitive>` creates a new `Object3D` of its own, and attaches both our named object and the child mesh to it. So our object ends up as a sibling of the mesh instead of as its parent. - Scene - Object3D - expectedParent - Mesh ## Why is this a problem? Firstly, it's just plain useful to be able to take a primitive object and make something else a child of it. And it's surprising that `<Primitive>` does not allow this. I did not expect it to create its own `Object3D`as a middle-layer parent. What I'm really trying to do though, is work around the fact that svelte-cubed does not expose bindings for the three.js objects that it creates. I'm trying to use the three.js Raycaster and it needs an `Object3D` to test against. Luckily it can do so recursively, so I thought "I'll just stick my own primitive object into the root of the scene and search downwards from there". With the current behaviour though it doesn't work. My workaround to the workaround was to do the above, and then when I call the raycaster instead of passing in `myObject`, I pass in `myObject.parent`. That works but it's pretty gross.
This issue appears to be discussing a feature request or bug report related to the repository. Based on the content, it seems to be resolved. The issue was opened by camjackson and has received 4 comments.