Hi, I’ve found the geometry namespaces in the Cocos Creator v3 docs, but there is no example on how to get AABB of an instantiated node.
What I want was getting the size in cocos metrics ( width/ height/ depth ) of the node so that I could placing them next to each other ( based on their width for example )
Is there such function/property that I missed somewhere ?
Wow, I missed such critical part, was looking at getComponent(UITransform) but didn’t go forward and type in getBoundingBox, there is also computeAABB which I really need, thanks so much
I’ve just checked the API, it was defined inside 2d rendering so I guess it would work if working with UI element. But since I’m creating some object in 3d so the getComponent(UITransfrom) is null, hence the getBoundingBox, and computeAABB is unavailable, I’m currently looking at the Mesh and MeshRenderer, but to no avail since no public function to get the boundingBox/AABB yet.
Hi, I found out the way to calculate it now although I need to check the output values to be sure it corrects
Since the node only has MeshRenderer ( as we all have seen in Cocos Inspector ), we should get the MeshRenderer component from node and via the model property, get the worldBounds and it’s the AABB of the mesh.