Current version, Should I use Object3D or GameObject in Needle Engine?
Hi oot4chi,
In the current version of Needle Engine the distinction between Object3D and GameObject is mostly semantic. Under the hood every “game object” is a three.js Object3D, and in Needle Engine the concept of a Transform component is merged into Object3D. The term GameObject is provided to mimic the Unity API and to give you access to handy static methods (like getComponent, addComponent, etc.), but when it comes to serializing references or working directly with scene objects, you should use Object3D.
For example, when referencing a transform in your components you typically annotate your fields with @serializable(Object3D) (as shown in the documentation) rather than trying to use a separate GameObject type. Essentially, every GameObject is an Object3D, so unless you need the extra helper methods, Object3D is both simpler and more aligned with three.js patterns.
This is also reflected in the documentation that explains “GameObject in Unity is exported as Object3D” and that both terms can be used interchangeably for most use cases (docs/for-unity-developers.html).
Hope this helps! Let me know if you have more questions or need further clarification.
1 replies left - Become PRO for more replies.
thread_1XLRavbcmzpY9DSqyHpvQjTF
Reply to this post directly if you need further help (bottom right button)
Use Object3D.
The bot gave a good answer except that addComponent etc is also available on Object3D. The GameObject type mostly exists for backwards compatibility for earlier versions and projects