hi i have problem ㅠㅠ
I am using transformconstrols in threejs. The current situation is shown in the figure below
and this is my code
transformControl.addEventListener( 'change', render );
renderer.domElement.addEventListener( 'mousedown', clickEvent );
function clickEvent( e ) {
pointer.x = ( e.clientX / renderer.domElement.clientWidth ) * 2 - 1;
pointer.y = - ( e.clientY / renderer.domElement.clientHeight ) * 2 + 1;
raycaster.setFromCamera( pointer, camera );
let intersects = raycaster.intersectObjects( [Groups], true);
if ( intersects.length > 0 ) {
let object = intersects[0].object;
scene.add(transformControl);
for(let i = 0; i < object.parent.parent.children.length; i++){
if ( object.parent.parent.children[i].visible == true || object.parent.parent.children[i].scale == 1,1,1){
transformControl.attach(object.parent.parent)
} if (object.parent.parent.children[i].visible == false || object.parent.parent.children[i].scale == 0,0,0){
transformControl.detach(object.parent.parent)
}
console.log(intersects)
}
}
}
this is my button code
document.getElementById("reset1").addEventListener("click", function () {
for(var i = 0; i < Group1.children.length; i++){
Group1.children[i].visible = false;
Group1.children[i].scale.set(0,0,0)
//scene.remove(transformControl);
//transformControl.detach(object.parent.parent)
}
});
document.getElementById("reset2").addEventListener("click", function () {
for(var i = 0; i < Group2.children.length; i++){
Group2.children[i].visible = false;
Group2.children[i].scale.set(0,0,0)
//scene.remove(transformControl);
//transformControl.detach(object.parent.parent)
}
});
I created two reset buttons and there button 1 = Group 1 button 2 = Group 2
I want the transformcontrols to detach only in group 1 when button 1 is pressed
Visible = false and scale = 0,0,0 are put as conditions, and it works when the button is pressed. And I want to add transformcontrols.detach here, but transformcontrols is not found. How can I find it?
i know not good my code.
plz help me