Skip to content

Instantly share code, notes, and snippets.

@Dmuasya

Dmuasya/MainActivity.java Secret

Created May 2, 2021
Embed
What would you like to do?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
arFragment = (ArFragment)getSupportFragmentManager()
.findFragmentById(R.id.sceneform_fragment);
//Tap on plane event
arFragment.setOnTapArPlaneListener(new BaseArFragment.OnTapArPlaneListener() {
@Override
public void onTapPlane(HitResult hitResult, Plane plane, MotionEvent motionEvent) {
if(animationCrab ==null)
return;
//Create the Anchor
Anchor anchor = hitResult.createAnchor();
if(anchorNode == null) //If crab is not place on plane
{
anchorNode = new AnchorNode(anchor);
anchorNode.setParent(arFragment.getArSceneView().getScene());
transformableNode = new TransformableNode(arFragment.getTransformationSystem());
//Scale model
transformableNode.getScaleController().setMinScale(0.09f);
transformableNode.getScaleController().setMaxScale(0.1f);
transformableNode.setParent(anchorNode);
transformableNode.setRenderable(animationCrab);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment