Hello! I’m new to Three.js and would like to create a Dual N’Back style game in 3D. One aspect of the game is pressing a button when the object appears in the same location it did x number of rounds ago and I was just wondering how you could compare the value of two vectors(?) in Three.js. Here is some code I have written so far to state the location of the cube8 object (it’s pretty basic):
function AnotherFunction() {
gsap.to(cube8.position,3, { y: Math.floor(Math.random()*5)});
gsap.to(cube8.position,3, { z: Math.floor(Math.random()*5)});
gsap.to(cube7.position,3, { x: Math.floor(Math.random()*5)});
gsap.to(cube7.position,3, { y: Math.floor(Math.random()*5)});
gsap.to(cube7.position,3, { z: Math.floor(Math.random()*5)});
gsap.to(cube6.position,3, { x: Math.floor(Math.random()*5)});
gsap.to(cube6.position,3, { y: Math.floor(Math.random()*5)});
gsap.to(cube6.position,3, { z: Math.floor(Math.random()*5)});
gsap.to(cube6.position,3, { z: Math.floor(Math.random()*5)});
let Vectorforcube = THREE.Vector3();
const printlocation = cube8.getWorldPosition(Vectorforcube);
console.log(printlocation);
const r3 = (Math.random()*150);
const g3 = (Math.floor(Math.random()*10));
const b3 = (Math.random());
materialf.color.setHSL(r3,g3,b3);
renderer.render(scene, camera);
}
Thank you for your help!