我的用例是:
我已经建立了自己的节点,该节点正在使用ObjectAnimator
,类似于太阳系示例。我唯一的问题是我不知道如何确定评估者的起点和终点。我的第一个想法是从起始和结束锚位
Vector3 start = new Vector3(startAnchor.getPose().tx(), startAnchor.getPose().ty(), startAnchor.getPose().tz());
Vector3 end = new Vector3(endAnchor.getPose().tx(), endAnchor.getPose().ty(), endAnchor.getPose().tz());
...
movingAnimation.setObjectValues(startingPoint, endPoint);
movingAnimation.setPropertyName("localPosition");
movingAnimation.setEvaluator(new Vector3Evaluator());
但是当我这样做时,动画是在完全不同的地方完成的。
我没有t found any reference to inbuild tools for such operation.
I
使用场景形式
问题是。如何制作从锚点A到锚点B的流畅动画(一张简单的幻灯片就足够了)
答案 0 :(得分:9)
我在HelloSceneform示例中做到了。我创建了第一个AnchorNode并将“ andy”节点添加为子节点。下一步,我创建了endPosition AnchorNode并开始将动画移到该位置。
要记住的事情是,如果您要使用具有不同父对象的对象的位置,则要使用 worldPosition 与localPosition。
private void onPlaneTap(HitResult hitResult, Plane plane, MotionEvent motionEvent) {
if (andyRenderable == null) {
return;
}
// Create the Anchor.
Anchor anchor = hitResult.createAnchor();
// Create the starting position.
if (startNode == null) {
startNode = new AnchorNode(anchor);
startNode.setParent(arFragment.getArSceneView().getScene());
// Create the transformable andy and add it to the anchor.
andy = new Node();
andy.setParent(startNode);
andy.setRenderable(andyRenderable);
} else {
// Create the end position and start the animation.
endNode = new AnchorNode(anchor);
endNode.setParent(arFragment.getArSceneView().getScene());
startWalking();
}
}
private void startWalking() {
objectAnimation = new ObjectAnimator();
objectAnimation.setAutoCancel(true);
objectAnimation.setTarget(andy);
// All the positions should be world positions
// The first position is the start, and the second is the end.
objectAnimation.setObjectValues(andy.getWorldPosition(), endNode.getWorldPosition());
// Use setWorldPosition to position andy.
objectAnimation.setPropertyName("worldPosition");
// The Vector3Evaluator is used to evaluator 2 vector3 and return the next
// vector3. The default is to use lerp.
objectAnimation.setEvaluator(new Vector3Evaluator());
// This makes the animation linear (smooth and uniform).
objectAnimation.setInterpolator(new LinearInterpolator());
// Duration in ms of the animation.
objectAnimation.setDuration(500);
objectAnimation.start();
}
答案 1 :(得分:0)
<p:panel header="This is my header text"
toggleable="true"
toggleableHeader="true">
The content of the panel.
</p:panel>