How to get the dimensions of the box around a GLTF/GLB model ? #243
-
Hi, I load 3D GLTF/GLB models with a CompletableFuture like here. I would like to get the size of the box around the GLTF/GLB model. How can I do that ? Thanks. |
Beta Was this translation helpful? Give feedback.
Answered by
grassydragon
Dec 17, 2021
Replies: 1 comment 2 replies
-
Hi! // Create a model node and fit it inside a unit cube
val modelNode = Node()
modelNode.parent = transformableNode
val instance = modelNode.setRenderable(state.model)
val boundingBox = instance.filamentAsset?.boundingBox
if (boundingBox != null) {
val maxHalfExtent = boundingBox.halfExtent.maxOrNull()!!
val scale = 0.5f / maxHalfExtent
modelNode.localScale = Vector3(scale, scale, scale)
} |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
ThomasGorisse
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi!
You can access bounding box if you save a reference to
RendereableInstance
when settingRenderable
. For example: