想实现一个在选中物体,弹出菜单,结果发现,点击会失效
<ul id="menu" class="list-group list-group-full">
<li class="list-group-item" onclick="test()">24小时曲线</li>
<li class="list-group-item" onclick="test()">72小时曲线</li>
</ul>
const tag = new CSS3DObject(dom);
tag.scale.set(0.05, 0.05, 0.05); //缩放标签尺寸
let position = this.getWorldPosition(this.hightLightObject);
let size = this.getSize(this.hightLightObject);
let offsetY = size.y / 2;
tag.position.x = position.x + offset.x;
tag.position.y = position.y + offsetY + offsetY / 4 + offset.y;
tag.position.z = position.z + offset.z;
this.scene.add(tag);
之前绑定在dom中click事件不会触发。
Google了一下,找到解决方法
https://discourse.threejs.org/t/onclick-is-not-working-on-css3dobject/31108
dom.addEventListener('pointerdown', () => { alert(2) })