-
-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect dimensions/size of 3D model and scale accordingly? #36
Comments
Here is what you are looking for: sceneview-android/sceneview/src/main/kotlin/io/github/sceneview/node/ModelNode.kt Lines 332 to 342 in 9f7a01d
It will scale your model to your desired units cube. You can also call it at the loading time with the sceneview-android/sceneview/src/main/kotlin/io/github/sceneview/node/ModelNode.kt Lines 217 to 241 in 9f7a01d
You can also use the |
You could encounter some issues if your model is animated due to an actual wrong bounding box calculation returned by Filament. |
BTW, that's the kind of things that makes me love the kotlin-math integration within SceneView: val halfExtent = asset.boundingBox.halfExtent.let { v -> Float3(v[0], v[1], v[2]) }
modelScale = Scale(units / max(halfExtent)) |
Really appreciate your help @ThomasGorisse Thank you! I'll give these a try. |
@ThomasGorisse Would it be possible for you to explain how I can use this to have the model fit the max screen width? |
Sorry. I won't be able to answer you on the deprecated/archived version of Google Sceneform within those repositories issues context. |
No worries, I will be migrating over to SceneView. |
Is there a way to detect the size (dimensions) of a loaded GLB file and calculate a scale factor so that the 3D model fits on the Android screen? Filament has a method called
transformToUnitCube()
which "tells the model viewer to transform the root node of the scene such that it fits into a 1x1x1 cube centered at the origin".Could we build something like that for
SceneView
?Source: https://medium.com/@philiprideout/getting-started-with-filament-on-android-d10b16f0ec67
The text was updated successfully, but these errors were encountered: