想实现一个在选中物体,弹出菜单,结果发现,点击会失效
<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事件不会触发。文章来源:https://www.toymoban.com/news/detail-534887.html
Google了一下,找到解决方法
https://discourse.threejs.org/t/onclick-is-not-working-on-css3dobject/31108文章来源地址https://www.toymoban.com/news/detail-534887.html
dom.addEventListener('pointerdown', () => { alert(2) })
到了这里,关于ThreeJs CSS3DObject 点击失效问题的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!