Giter VIP home page Giter VIP logo

Comments (5)

SGTjeong avatar SGTjeong commented on July 26, 2024 1

You need to update the node position relatively to the camera position in onUpdate method.
Or you can set the camera as the node's parent, and adjust node's local position.

from sceneform-android-sdk.

danyjoy avatar danyjoy commented on July 26, 2024

You need to update the node position relatively to the camera position in onUpdate method.
Or you can set the camera as the node's parent, and adjust node's local position.

i don't really know how to do that. I'm taking frames from the scene and passing it to the classifier inside onUpdate method.

How can i update the node position relatively to the camera position ?

And also it says in the docs that Pose.makeTranslation(0, 0, -3f) creates a translation-only pose. Does this has something to do with the problem??

from sceneform-android-sdk.

SGTjeong avatar SGTjeong commented on July 26, 2024

(1) inside onUpdate method

val cameraPos = arSceneView.scene.camera.worldPosition
val cameraForward = arSceneView.scene.camera.forward
val position = Vector3.add(cameraPos, cameraForward.scaled(distance))
node.worldPosition = position

(2) Or when you place Node

ModelRenderable.builder().setSource(context, Uri.parse("model.sfb"))
.build()
.thenAccept{
var node = Node()
node.localPosition = Vector3(0f, -0.2f, -0.5f)
node.renderable = it
node.setParent(arSceneView.scene.camera)
}
.exceptionally {
null
}
}

from sceneform-android-sdk.

danyjoy avatar danyjoy commented on July 26, 2024

@SGTjeong Thanks for the reply.

I tried using the 2nd step that you gave me. But the object is just sticking to the camera. I also tried another method where i use random coordinates to put the renderable when i detect object.

ModelRenderable
                    .builder()
                    .setSource(this, Uri.parse("andy.sfb"))
                    .build()
                    .thenAccept(renderable -> {


                            Node node = new Node();
                            node.setRenderable(renderable);
                            scene.addChild(node);


                            Random random = new Random();
                            int x = random.nextInt(10);
                            int z = random.nextInt(10);
                            int y = random.nextInt(20);

                            z = -z;

                            node.setWorldPosition(new Vector3(
                                    (float) x,
                                    y / 10f,
                                    (float) z
                            ));



                    });

But still, its drifting from the position when i move it to left or right.

Is there any way that i can link all the anchorNodes to a trackable plane on the scene??

from sceneform-android-sdk.

danyjoy avatar danyjoy commented on July 26, 2024

So, i got a SOLUTION for this problem.

I created a ray from the center of the screen and then placed the renderable 3 meters along the ray and now its not drifting drastically.

Ray ray = camera.screenPointToRay(point.x / 2f, point.y / 2f);
Vector3 vector3 = ray.getPoint(3f);
AnchorNode addedAnchorNode = new AnchorNode();
addedAnchorNode.setWorldPosition(vector3);

from sceneform-android-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.