Reputation: 39
I'm searching for the method to move my 3D object (.gltf format) to an alternate position when the box is checked as well as moving back to the initial position when the box is unchecked. However, I'm not sure what is the proper way of doing this. I created an object transition function but the object doesn't seem to move according to the checkbox.
here's my function code
function zoom() {
var move = document.getElementById('controllr');
if (move.checked) {
model2.position.set(0, 50, 0);
} else {
model2.position.set(0, 25, 0);
}
}
Thank you in advance for any solution.
I still can not figure out how to achieve my intention so I created a new post with full code here.
Moving object on checkbox event
Upvotes: 0
Views: 153
Reputation: 368
When are you actually calling the zoom function? If you put this code inside an event listener, it should work.
var move = document.getElementById('controllr');
move.addEventListener('change', (e) => {
if (e.currentTarget.checked) {
model2.position.set(0, 50, 0);
} else {
model2.position.set(0, 25, 0);
}
}
Upvotes: 2