ARCore – WorldScale 和 LocalScale 有什么区别?

Ste*_*n.B 2 java android augmented-reality kotlin arcore

我正在尝试调整 AR 模型的大小,我正在使用建筑物大小的模型。

我设法使用 worldscale 和 localscale 调整模型大小,但到底有什么区别?何时应该使用 worldscale 来放大模型以及何时使用 localscale?

ARG*_*Geo 6

局部缩放单个对象

在局部空间中,模型上的所有操作(平移、旋转和缩放)都是相对于模型的枢轴点执行的。


官方 Google ARCore 开发者文档说道

public void setLocalScale (Vector3 scale) 
Run Code Online (Sandbox Code Playgroud)

设置此节点相对于其父节点(本地空间)的比例。如果isTopLevel()为真,则与 相同setWorldScale(Vector3)

这是它在真实代码中的样子:

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);
Run Code Online (Sandbox Code Playgroud)


局部缩放多个对象

当多个选定对象同时进行局部缩放(使用setLocalScale)时,每个对象都将相对于其自身枢轴点的位置进行缩放。

然而,如果您同时全局缩放所有这些选定的对象(使用setWorldScale),它们将相对于“世界”的一个结果枢轴点进行缩放。


这是本地和世界规模的视觉表示:

在此输入图像描述

世界规模:

在此输入图像描述

当地规模:

在此输入图像描述