我想创建一个与magicplan 相同的应用程序,并想绘制与magicplan 相同的连续绿色垂直管道,该管道会随着相机的移动而远近。
我已经尝试过下面的代码,但它将节点保持在屏幕的中心。请帮助我如何实现这一目标。
Ray ray = arFragment.getArSceneView().getScene().getCamera().screenPointToRay(arFragment.getArSceneView().getWidth() / 2, arFragment.getArSceneView().getHeight() / 2);
Vector3 localpos = ray.getPoint(1f);
Quaternion localRotation = arFragment.getArSceneView().getScene().getCamera().getLocalRotation();
Vector3 localScale = new Vector3(0.3f,0.3f,0.3f);
Frame frame = arFragment.getArSceneView().getArFrame();
Vector3 pos;
pos = Vector3.add(ray.getOrigin(), ray.getDirection());
Pose pose = Pose.makeTranslation(pos.x, pos.y, pos.z);
anchor = arFragment.getArSceneView().getSession().createAnchor(pose);
anchorNode = new AnchorNode(anchor);
anchorNode.setParent(arFragment.getArSceneView().getScene());
TransformationSystem transformationSystem = arFragment.getTransformationSystem();
node = new TransformableNode(transformationSystem);
node.setRenderable(cylinderRenderable2);
node.setParent(anchorNode);
node.setLocalPosition(localpos);
node.setLocalRotation(localRotation);
node.setLocalScale(localScale);
node.select();