Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

178
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda