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

297
Vistas
ThreeJS unable to get the click event from CSS2DObject

I'm working with ThreeJs in order to provide a ruler for the 3d model.

I have created a div in this way and than I have put it inside CSS2DObject as in the below code

        const measurementDiv = document.createElement('div');
        const labelDiv = document.createElement('div');
        const close_button = document.createElement('button');
        close_button.type = "button";
        close_button.innerHTML ='x';
        close_button.id = lineId;
        close_button.className='measurementButton';
        measurementDiv.className = 'measurement';
        labelDiv.className = 'measurementLabel';
        labelDiv.innerText = "0.0 mm";
        measurementDiv.appendChild(labelDiv);
        measurementDiv.appendChild(close_button);
        close_button.addEventListener('click', function(){
            console.log( event ) ;
            // scene.remove(measurementLabels[close_button.id]);
        });
        const measurementLabel = new CSS2DObject(measurementDiv);

what I would like to do is, when I click on the button I delete the CSS2DObject.

the problem is that if I click on the button the click event is not fired. it seems that the main render view is getting the event and it does not transfer it to the underline dom element

enter image description here

at this link you can try a simple example https://codepen.io/mboscolo/pen/XWapaEK

thanks

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