ARCore – What is the difference between WorldScale and LocalScale?

Issue

I’m trying to resize my AR models, I’m working with models the size of buildings.

I managed to resize my model using worldscale and localscale but what exactly is the difference and when should I use worldscale to enlarge my model and when to use localscale?

Solution

Scaling locally a single object

In local space, all operations on the model (translation, rotation and scaling) are performed relative to the Pivot Point of the model.

Official Google ARCore developer documentation says:

public void setLocalScale (Vector3 scale) 

Sets the scale of this node relative to its parent (local-space). If isTopLevel() is true, then this is the same as setWorldScale(Vector3).

Here’s how it looks like in a real code:

Anchor anchor = hitResult.createAnchor();
AnchorNode anchorNode = new AnchorNode(anchor);
anchorNode.setParent(arFragment.getArSceneView().getScene());

TransformableNode n = new TransformableNode(arFragment.getTransformationSystem());
n.setRenderable(modelRenderable);

n.getScaleController().setMinScale(1.74f);
n.getScaleController().setMaxScale(1.75f);

// Set Node's local scale before setting its Parent
n.setLocalScale(new Vector3(1.23f, 1.23f, 1.23f));

n.setParent(anchorNode);

Scaling locally multiple objects

When multiple selected objects are simultaneously scaled locally (using setLocalScale), then each of them will be scaled relative to the position of its own pivot point.

However, if you simultaneously scale all these selected objects globally (using setWorldScale), they will be scaled relative to one resulting pivot point of The World.

Here’s a visual representation of local and world scale:

enter image description here

World Scale:

enter image description here

Local Scale:

enter image description here

Answered By – Andy Jazz

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published