Wrong model position with parent node

Hi all, in one of my previous questions i managed to get the model rotating, now however it wont display it self in the right position on the first try.

what is the right position? and what do you mean “on the first try”? is it working after a while? or after tying again?

Hi, the right position is where the marker is, when i tap on scene, the sphere spawns either right or left of the marker and when i tap again it’s in the right position, so every second time it’s in the right position

The example doesn’t work at all. there are a few exceptions when running it. I assume i know how to fix it, but i will be happy to know how you test it

Sorry, I forgot to check the playground if it’s working,
Here is the working example:

I was testing on my machine before, but the issue is in the playground as well

ok. As I am not 100% sure what your use case is, I will answer a more general answer here :slight_smile:

You have a single anchor node that you are using as a parent for your model. You are cloning the mesh itself every time you are adding an anchor, but keeping the parent s is. On pointer down you are removing the previou s anchor, and then (async) adding a new anchor and attaching it to the parent (which was set to be the last anchor’s position). So when you are setting the parent of the newly created model, the transformation of the anchor is still the old one.

This will fix this behavior. However, I would recommend you not to blindly copy this but to understand the workflow and organizye your code in a way that will help you develop it further - webxr test positioning 1 | Babylon.js Playground (babylonjs.com)

1 Like

Thank you for such a fast response, I will check the code later as I’m busy right now
My use case is the following: i want to tap anywhere on the scene and the sphere should spawn there, also when i tap again the sphere should also spawn in the location of the marker

Thank you for explaining it so clearly

Thank you for the advice, I won’t copy it blindly, I’m trying to learn Babylon and xr/3d in general because I find great interest in that field, also I’m relatively new to the whole thing.

1 Like