sceneform-android-sdk icon indicating copy to clipboard operation
sceneform-android-sdk copied to clipboard

Model is rendering big then device size

Open RavindraVirat opened this issue 8 years ago • 5 comments

The model I am rendering is big in size and appearing bigger then device screen when rendering, if I set value for max scale then we can handle the height of the model but it is creating problem for other small models, not allowing them to scale "zooming" properly means restricting. Can you please guide some common solution that will handle all size models.

RavindraVirat avatar Jul 11 '18 07:07 RavindraVirat

It's probably best for your models to be adjusted to a world scale. That way if someone wants to modify them, the changes can be done to the model file and hopefully none of the code or UX needs to be changed.

But if you want to do something like auto-scaling a model, you could try something like this:

    Box boundingBox = (Box) renderable.getCollisionShape();    
    if (boundingBox != null) {
      Vector3 boundingBoxSize = boundingBox.getSize();
      float maxExtent = Math.max(boundingBoxSize.x, Math.max(boundingBoxSize.y, boundingBoxSize.z));
      float targetSize = 0.2f; // Whatever size you want.
      float scale = targetSize / maxExtent;
      node.setLocalScale(Vector3.one().scaled(scale));
    }

This will scale the renderable such that the largest extent on the bounding box will be equal to targetSize.

gstanlo avatar Jul 11 '18 17:07 gstanlo

See also: https://github.com/google-ar/sceneform-android-sdk/issues/108 and let us know if this helps

Additionally, a scale value is present in the .sfa file of your model. https://developers.google.com/ar/develop/java/sceneform/sfa

gstanlo avatar Jul 11 '18 18:07 gstanlo

Thank you, I will try this and update.

RavindraVirat avatar Jul 13 '18 05:07 RavindraVirat

Any luck with this?

gstanlo avatar Jul 25 '18 17:07 gstanlo

Closing due to inactivity.

dsternfeld7 avatar Aug 01 '18 22:08 dsternfeld7