Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the position of the Markers? #32

Open
Zaniyar opened this issue Apr 6, 2023 · 2 comments
Open

How to get the position of the Markers? #32

Zaniyar opened this issue Apr 6, 2023 · 2 comments

Comments

@Zaniyar
Copy link

Zaniyar commented Apr 6, 2023


	const markerRef= useRef<THREE.Group>(null);
	const modelRef= useRef<THREE.Group>(null);                   
             <ARMarker
		  ref={markerRef}
		  params={{ smooth: true }}
		  type={"pattern"}
		  patternUrl={"data/patt.kanji"}
		  onMarkerFound={(x) => {
			console.log(x); // undefined
		  }}
	      >
		  <Model
			  ref={modelRef}
			  scale={[1, 1, 1]}
			  url="/model.glb"
		  />
	  </ARMarker>

later I try to get the position like this:

   modelRef.current.getWorldPosition(new THREE.Vector3()),

it is always 0

Vector3 {x: 0, y: 0, z: 0}
Vector3 {x: 0, y: 0, z: 0}
@mwmwmw
Copy link

mwmwmw commented Jul 19, 2023

If I'm not mistaken, the position of the marker is always the center of the world.

@j-era
Copy link
Contributor

j-era commented Jul 24, 2023

Yes, the marker position root will be updated. So you need to get the position of the marker root (the parent of your Model)

console.log(modelRef.current.parent.getWorldPosition(new Vector3()))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants