So with my project my object seems to be moving around to much. Rotation seems to be updating somewhat fine when i move around but it doesn’t stay put in world space when i move forward or back. My image target component is setup very similar to what’s been posted in previous projects, my only addition is adding a persistence tag so when the image target is lost it stays at its last location.
const imageTargetComponent = () => ({
schema: {
name: {type: 'string'},
persistPosition: {type: 'boolean', default: true}, // Add option to control persistence
},
init() {
const {object3D} = this.el
const {name} = this.data
object3D.visible = false
let targetFound = false
let lastPosition = null
let lastRotation = null
let lastScale = null
const showImage = ({detail}) => {
if (name !== detail.name) {
return
}
// Store the position, rotation and scale
lastPosition = detail.position
lastRotation = detail.rotation
lastScale = detail.scale
// Update object transform
object3D.position.copy(detail.position)
object3D.quaternion.copy(detail.rotation)
object3D.scale.set(detail.scale, detail.scale, detail.scale)
object3D.visible = true
}
const imageFound = (e) => {
showImage(e)
targetFound = true
console.log('found img')
}
const imageLost = (e) => {
// Only hide the object if persistence is disabled or target was never found
if (!this.data.persistPosition || !targetFound) {
object3D.visible = false
} else if (lastPosition && lastRotation && lastScale) {
// Keep the last known position when target is lost
object3D.position.copy(lastPosition)
object3D.quaternion.copy(lastRotation)
object3D.scale.set(lastScale, lastScale, lastScale)
object3D.visible = true
}
}
this.el.sceneEl.addEventListener('xrimagefound', imageFound)
this.el.sceneEl.addEventListener('xrimageupdated', showImage)
this.el.sceneEl.addEventListener('xrimagelost', imageLost)
},
})
To note i tested this without my persist tag to see if that was the issue which it is not.
I have attached a video to show you my issue, you can see that rotating seems to working fine but once i move forward the model also moves forward.
I’ve tried keeping disableWorldTracking: true and false.
Current camera
<a-camera position="0 4 10" raycaster="objects: .cantap" cursor="fuse: false; rayOrigin: mouse;"></a-camera>
My image target
Video