import{definePlugin}from"../../core/extension";import{ModelMouseEvent}from"../../common/constant";import{CSS2DRenderer}from"three/examples/jsm/renderers/CSS2DRenderer";export default definePlugin("css2d",{setup(a,b){const c=b.container,d=new CSS2DRenderer;d.setSize(c.offsetWidth,c.offsetHeight),d.domElement.style.position="absolute",d.domElement.style.top="0",d.domElement.style.left="0px",d.domElement.style.pointerEvents="none";let e=a=>{d.domElement.addEventListener(a,a=>{a.stopPropagation(),a.preventDefault()})};[ModelMouseEvent.Blur,ModelMouseEvent.Hover,ModelMouseEvent.Mousemove,ModelMouseEvent.ContextMenu].forEach(a=>e(a)),c.append(d.domElement);const f=b.renderer.onResize((a,b)=>{d.setSize(a,b)});return{css2DRenderer:d,dispose:()=>{f(),d.domElement.remove()},update:()=>{d.render(b.scene,b.camera)},add:a=>{b.scene.add(a)}}},render(){this.update()},destroyed(){this.dispose()}});