I’ve integrated Babylon.js into a Vue 3 application. I want to get the current camera position and rotation whenever saving the current state. However, my watcher functions don’t work. If i try to get the position and rotation value before and after interacting with my 3D space, the values do not change. I there a way to watch position and rotation changes after initializing my camera?
let camera = new ArcRotateCamera(
null,
Math.PI / 2,
Math.PI / 2,
3,
new Vector3(0, 0, 0),
scene
);
camera.attachControl()
//watchers don't work
watch(() => camera.position, (pos, prevpos) => {
console.log(pos, prevpos);
})
watch(() => camera.absoluteRotation, (rotation) => {
console.log(rotation);
})
Solution clarification: It was pointed out that I need a reactive wrapper for my camera object. The code above is a simplification of what I’m actually working with, and reactive wrappers could not be used in my case. I did however end up creating a reactive object in my store to transfer camera data across components.