domEvent.addeventlistener callback function doesn't work

Hello, everybody.
I am working with Threex.domEvents library now.
So at first time, everything works well. but now it has gone wrong so I am not sure why it is not working.
Here is my code.

gltfLoader.load('/assets/model/house/front_door.gltf', function (object) {
        testva = object.scene;
        testva.scale.set(50,50,50);
        domEvent.addEventListener(testva, 'click', function () {
            console.log('here')
        });
        transformControl.attach( testva );
        scene.add( transformControl );
        scene.add(testva);
    });

and here is my screen record video.


so what I want to do is when I click the object, it should have a focus of transformControl.
It performed perfectly at first and I made some changes in my project.
After this, it is not working.
As I think, there is no wrong in logic.
What is wrong in my code?
I attached my whole project here.

Two points:

  • format your code
  • consider asking developers of threex instead of three.js
2 Likes

Iā€™m not sure threex is still maintained. The last commit is three years ago.

2 Likes

Thank you for your reply.
but the problem is that worked well for the first time.
After that I have made some changes but what is make it wrong.
I made another project and it works well.
Kindly check this one.


And I noticed that there is some problem with crosspoint between raycast and object.
so when I click certain area(not the object), that event triggered.
sorry, I changed the url because origin screen record include noise.

I found the problem.
The problem was in CSS.
I had set css for canvas like following.

canvas {
display:block;
position :relative;
transform: translate(-50%, 0);
left:50%;
}

so the problem was transform:translate();
I removed it then It works well.
Thank you everybody.

3 Likes