0

How to add 2d view rather than 3d view without detection of plane, i know how to add 3d view by using viewRenderable.

I wish to create something like screenshot below.

https://i.stack.imgur.com/Wm9M6.jpg

Thanks in advance!

I have use ViewRenderable to create android 2d view in the 3d space. However, i want the 2d view stay as 2d view on the screen (something like location based AR)

https://developers.google.com/ar/develop/java/sceneform/create-renderables

Below is the code that allow me to add 2d view rather than 3d view.

    arFragment = (ArFragment) getSupportFragmentManager().findFragmentById(R.id.scene_view);
    arFragment.getPlaneDiscoveryController().hide(); arFragment.getPlaneDiscoveryController().setInstructionView(null);
    arFragment.getArSceneView().getPlaneRenderer().setEnabled(false);

    Node node = new Node();
    node.setParent(arFragment.getArSceneView().getScene());
    node.setEnabled(false);
    node.setLocalPosition(new Vector3(0.0f, 100 * 5, 0.0f));

    ViewRenderable.builder()
            .setView(this, R.layout.card)
            .build()
            .thenAccept(
                    (renderable) -> {
                        node.setRenderable(renderable);
                        TextView textView = (TextView) renderable.getView();
                        textView.setText("planetName");
                    })
            .exceptionally(
                    (throwable) -> {
                        throw new AssertionError("Could not load plane card view.", throwable);
                    });
Novice
  • 19
  • 1
  • 8
  • Do you mean you want a flat text box on the screen, but that it should be anchored to the scene so when you move the phone it moves out of view? – Mick May 27 '19 at 15:11
  • @Mick Yes correct, do you know how to make it? Thanks in advance! – Novice May 27 '19 at 15:30
  • The ViewRenderable (https://developers.google.com/ar/reference/java/com/google/ar/sceneform/rendering/ViewRenderable) in your link above should do exactly that. You can style the layout so ti matches the example in your screenshot. – Mick May 27 '19 at 15:47
  • @Mick ya i know this method but it required a plane to place the object, what i want is render the object that follow the geolocation... – Novice May 27 '19 at 16:33
  • Ah, ok - I think you probably want to edit the question to out this in the title and the description to help steer people to give an answer. – Mick May 27 '19 at 20:14

0 Answers0