Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

182
Views
transformcontrols attach and detach... in threejs

hi i have problem ㅠㅠ

I am using transformconstrols in threejs. The current situation is shown in the figure below

enter image description here

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.

enter image description here

plz help me

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!