endset_three_editor 0.8.7 → 0.8.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -135,7 +135,7 @@
135
135
  `,o.setAttribute("data-item-code",s.code||""),o.innerHTML=`
136
136
  <span class="item-label" style="flex-shrink:0;letter-spacing:0.02em;color:#8cc8ff;">${this.escapeHtml(s.label)}</span>
137
137
  <span class="item-value" style="font-weight:700;color:#ffffff;text-shadow:0 0 0.62em rgba(0, 200, 255, 0.40);text-align:right;word-break:break-all;">${this.escapeHtml(s.value)}${s.unit?`<span style="font-size:0.85em;margin-left:0.15em;color:#8cc8ff;">${this.escapeHtml(s.unit)}</span>`:""}</span>
138
- `,e.appendChild(o)})}escapeHtml(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}attachTo(e){this.attachedObject&&this.attachedObject!==e&&this.detach();const t=new P.Vector3;e.getWorldPosition(t);const o=new P.Box3().setFromObject(e).max.y-t.y+this.options.offsetY;this.css2dObject||(this.css2dObject=new Es(this.container),this.css2dObject.name=`DataPanel_${e.name||e.uuid}`,this.css2dObject.center.set(.5,1)),this.css2dObject.position.set(this.options.offsetX,o,0),e.add(this.css2dObject),this.attachedObject=e}detach(){this.css2dObject&&this.attachedObject&&this.attachedObject.remove(this.css2dObject),this.attachedObject=null}show(){this._visible=!0,this.css2dObject&&(this.css2dObject.visible=!0)}hide(){this._visible=!1,this.css2dObject&&(this.css2dObject.visible=!1)}get visible(){return this._visible}set visible(e){e?this.show():this.hide()}setTitle(e){var s;this.options.title=e;const t=(s=this.container)==null?void 0:s.querySelector("[data-panel-title]");e?t?t.textContent=e:this.rebuildPanel():t&&t.remove()}getTitle(){return this.options.title||""}setItems(e){var s;this.options.items=[...e];const t=(s=this.container)==null?void 0:s.querySelector("[data-panel-list]");t&&this.renderItems(t,this.options.items)}getItems(){return[...this.options.items||[]]}addItem(e){var s;this.options.items.push(e);const t=(s=this.container)==null?void 0:s.querySelector("[data-panel-list]");t&&this.renderItems(t,this.options.items)}removeItem(e){var s;this.options.items=this.options.items.filter(n=>n.label!==e);const t=(s=this.container)==null?void 0:s.querySelector("[data-panel-list]");t&&this.renderItems(t,this.options.items)}updateItem(e,t,s){var o;const n=this.options.items.find(i=>i.label===e);if(n){n.value=t,s!==void 0&&(n.unit=s);const i=(o=this.container)==null?void 0:o.querySelector("[data-panel-list]");i&&this.renderItems(i,this.options.items)}}updateItemByCode(e,t){var n;const s=this.options.items.find(o=>o.code===e);if(s){s.value=t;const o=(n=this.container)==null?void 0:n.querySelector("[data-panel-list]");o&&this.renderItems(o,this.options.items)}}clearItems(){var t;this.options.items=[];const e=(t=this.container)==null?void 0:t.querySelector("[data-panel-list]");e&&this.renderItems(e,[])}rebuildPanel(){const e=this._visible,t=this.attachedObject;this.css2dObject&&this.attachedObject&&this.attachedObject.remove(this.css2dObject),this.buildPanel(),t&&(this.attachedObject=t,t.add(this.css2dObject),e||this.hide())}updateOptions(e){this.options={...this.options,...e},this.rebuildPanel()}getOffsetY(){return this.options.offsetY??.1}setOffsetY(e){if(this.options.offsetY=e,this.css2dObject&&this.attachedObject){const t=new P.Vector3;this.attachedObject.getWorldPosition(t);const n=new P.Box3().setFromObject(this.attachedObject).max.y-t.y;this.css2dObject.position.set(this.options.offsetX??0,n+e,0)}}getOffsetX(){return this.options.offsetX??0}setOffsetX(e){this.options.offsetX=e,this.css2dObject&&this.attachedObject&&(this.css2dObject.position.x=e)}getWidth(){return this.options.width||"20em"}getFontSize(){return this.options.fontSize||"0.85em"}setWidth(e){this.options.width=e,this.container&&(this.container.style.width=e)}setFontSize(e){if(this.options.fontSize=e,this.container){this.container.style.fontSize=e;const t=this.container.querySelector("[data-panel-title]");t&&(t.style.fontSize=`calc(${e} + 0.15em)`)}}getElement(){return this.container}dispose(){var e;this.detach(),(e=this.container)!=null&&e.parentNode&&this.container.parentNode.removeChild(this.container),this.css2dObject=null,this.container=null,this.attachedObject=null}};ye(Te,"_breathInjected",!1);let Be=Te;const tt=new WeakMap;function rn(l,e){const t=r.toRaw(l);tt.set(t,e),t.userData._hasDataPanel=!0}function Oe(l){return tt.get(r.toRaw(l))||null}function yt(l){const e=r.toRaw(l),t=tt.get(e);t&&(t.dispose(),tt.delete(e)),e.userData._hasDataPanel=void 0}let q=null;function an(l){return q?(q.domElement.parentNode!==l&&l.appendChild(q.domElement),q):(q=new Ds,q.setSize(l.clientWidth,l.clientHeight),q.domElement.style.position="absolute",q.domElement.style.top="0",q.domElement.style.left="0",q.domElement.style.pointerEvents="none",l.appendChild(q.domElement),q)}function Vs(){return q}function ln(l,e){q&&q.render(l,e)}function cn(l,e){q&&q.setSize(l,e)}function un(){q&&(q.domElement.parentNode&&q.domElement.parentNode.removeChild(q.domElement),q=null)}function Hs(){const l=new P.Scene;l.position.y=-3.5;const e=new P.BoxGeometry;e.deleteAttribute("uv");const t=new P.MeshStandardMaterial({side:P.BackSide}),s=new P.PointLight(16777215,1300,28,2);s.position.set(.418,16.199,.3),l.add(s);const n=new P.Mesh(e,t);n.position.set(-.757,13.219,.717),n.scale.set(31.713,28.305,28.591),l.add(n);const o=new P.MeshStandardMaterial,i=new P.InstancedMesh(e,o,6),c=new P.Object3D;c.position.set(-10.906,2.009,1.846),c.rotation.set(0,-.195,0),c.scale.set(2.328,7.905,4.651),c.updateMatrix(),i.setMatrixAt(0,c.matrix),c.position.set(-5.607,-.754,-.758),c.rotation.set(0,.994,0),c.scale.set(1.97,1.534,3.955),c.updateMatrix(),i.setMatrixAt(1,c.matrix),c.position.set(6.167,.857,7.803),c.rotation.set(0,.561,0),c.scale.set(3.927,6.285,3.687),c.updateMatrix(),i.setMatrixAt(2,c.matrix),c.position.set(-2.017,.018,6.124),c.rotation.set(0,.333,0),c.scale.set(2.002,4.566,2.064),c.updateMatrix(),i.setMatrixAt(3,c.matrix),c.position.set(2.291,-.756,-2.621),c.rotation.set(0,-.286,0),c.scale.set(1.546,1.552,1.496),c.updateMatrix(),i.setMatrixAt(4,c.matrix),c.position.set(-2.193,-.369,-5.547),c.rotation.set(0,.516,0),c.scale.set(3.875,3.487,2.986),c.updateMatrix(),i.setMatrixAt(5,c.matrix),i.instanceMatrix.needsUpdate=!0,l.add(i);function u(A){return new P.MeshLambertMaterial({color:0,emissive:16777215,emissiveIntensity:A})}const d=new P.Mesh(e,u(75));d.position.set(-16.116,14.37,8.208),d.scale.set(.1,2.428,2.739),l.add(d);const p=new P.Mesh(e,u(75));p.position.set(-16.109,18.021,-8.207),p.scale.set(.1,2.425,2.751),l.add(p);const f=new P.Mesh(e,u(26));f.position.set(14.904,12.198,-1.832),f.scale.set(.15,4.265,6.331),l.add(f);const g=new P.Mesh(e,u(65));g.position.set(-.462,8.89,14.52),g.scale.set(4.38,5.441,.088),l.add(g);const C=new P.Mesh(e,u(30));C.position.set(3.235,11.486,-12.541),C.scale.set(2.5,2,.1),l.add(C);const I=new P.Mesh(e,u(150));return I.position.set(0,20,0),I.scale.set(1,.1,1),l.add(I),l}function dn(l){try{const e=new P.PMREMGenerator(l),t=Hs(),s=e.fromScene(t).texture;return t.traverse(n=>{if(n.isMesh){const o=n,i=Array.isArray(o.material)?o.material:[o.material];for(const c of i)c&&c.dispose()}}),e.dispose(),s}catch(e){return console.error("环境贴图生成失败:",e),null}}const x={mode:"",transformControlsMode:"translate",scene:null,camera:null,defaultMainCamera:null,renderer:null,orbitControls:null,transformControls:null,container:null,gridHelper:null,selectedObject:null};let Je=!1,Me=!1,Ae=null;const js=16755200;let pt=[],Ke=[],We=!0,ve=null,At=null,_e=null,me=[];const we=new Map;let nt,$e=null,Ve=null,He=null;function hn(l,e="edit",t){x.container=l,x.mode=e,Ws(),Gs(),Us(),t&&(Pn(t.scene,e,t.dataPanels,t.waters,t.textures),t!=null&&t.camera&&(x.defaultMainCamera=t.camera,Ct(!0))),qs(),Xs(),nt&&x.orbitControls&&(x.orbitControls.target.fromArray(nt),x.orbitControls.update()),Fs(),In(),fn(),Ve=s=>Zs(s),He=()=>Ks(),e==="edit"&&l.addEventListener("click",Ve),window.addEventListener("resize",He),t||Ys(),e==="edit"&&zs()}function Bs(){return window.devicePixelRatio}function Ws(){const l=Bs(),e=new P.WebGLRenderer({antialias:!0,alpha:!0});e.setSize(x.container.clientWidth,x.container.clientHeight),e.setPixelRatio(l),e.toneMapping=P.NoToneMapping,e.toneMappingExposure=1,console.log(`[Renderer] css=${x.container.clientWidth}×${x.container.clientHeight}, dpr=${window.devicePixelRatio}, targetRatio=${l}, antialias=true`),x.container.appendChild(e.domElement),x.renderer=e}function Fs(){if(!x.renderer||!x.scene||!x.camera)return;const l=x.renderer.getPixelRatio(),e=x.container.clientWidth*l,t=x.container.clientHeight*l,s=new P.WebGLRenderTarget(e,t,{type:P.HalfFloatType,samples:4});s.texture.name="EffectComposer.rt1";const n=new vs(x.renderer,s);n.addPass(new Ms(x.scene,x.camera)),n.addPass(new ws),Ae=n}function Gs(){if(x.scene=new P.Scene,x.scene.name="sl_scene",x.renderer){const l=dn(x.renderer);l&&(x.scene.environment=l,x.scene.environmentIntensity=.4)}}function zs(){const l=new P.GridHelper(30,30,8956671,3364232);l.name="地板",l.userData.type="initFloor",x.scene.add(l),x.gridHelper=l}function Us(){const l=x.container,e=l.clientWidth/l.clientHeight,t=new P.PerspectiveCamera(45,e,.1,1e3);t.position.set(0,6,15),t.lookAt(0,0,0),x.camera=t}function Ct(l=!1){if(!x.defaultMainCamera)return;const e=x.defaultMainCamera;if(l){x.camera.position.set(e.position[0],e.position[1],e.position[2]),x.camera.rotation.set(e.rotation[0],e.rotation[1],e.rotation[2]),x.camera.updateProjectionMatrix(),nt=e.target;return}else xt(""),st();if(!x.camera||!x.orbitControls)return;const t=x.camera.position.clone(),s=x.orbitControls.target.clone(),n=new P.Vector3(e.position[0],e.position[1],e.position[2]),o=e.target?new P.Vector3(e.target[0],e.target[1],e.target[2]):new P.Vector3(0,0,0);x.orbitControls.enabled=!1,new je.Tween({x:t.x,y:t.y,z:t.z,tx:s.x,ty:s.y,tz:s.z}).to({x:n.x,y:n.y,z:n.z,tx:o.x,ty:o.y,tz:o.z},1e3).easing(je.Easing.Quadratic.InOut).onUpdate(i=>{x.camera.position.set(i.x,i.y,i.z),x.orbitControls.target.set(i.tx,i.ty,i.tz),x.orbitControls.update()}).onComplete(()=>{nt=e.target,x.orbitControls.enabled=!0}).start()}function Xs(){const l=new Zn(x.camera,x.renderer.domElement);l.minDistance=0,l.maxDistance=1/0,l.addEventListener("start",()=>{Je=!1}),l.addEventListener("change",()=>{Je=!0}),l.addEventListener("end",()=>{Je&&(Me=!0,setTimeout(()=>{Me=!1},200))}),x.orbitControls=l}function qs(){const l=new ls(x.camera,x.renderer.domElement);l.addEventListener("dragging-changed",e=>{x.orbitControls.enabled=!e.value,e.value||(Me=!0,setTimeout(()=>{Me=!1},200))}),l.addEventListener("objectChange",()=>{const e=x.selectedObject;if(At&&e&&At(e),e&&e.type==="DirectionalLight"){const t=e.userData.helper;t&&t.update&&t.update()}}),x.scene.add(l.getHelper()),x.transformControls=l}function Ys(){const l=new P.AmbientLight(16777215,1);x.scene.add(l)}function fn(){var e,t;$e=requestAnimationFrame(fn),je.update(),(e=x.orbitControls)==null||e.update(),x.mode==="run"&&Ae&&x.scene&&x.camera?Ae.render():(t=x.renderer)==null||t.render(x.scene,x.camera),x.scene&&x.camera&&ln(x.scene,x.camera),We&&x.scene&&(Ke=[],x.scene.traverse(s=>{s.userData.isWater&&s.type==="Mesh"&&Ke.push(s)}),We=!1);for(let s=0;s<Ke.length;s++){const n=Ke[s],o=n.material;if(o.uniforms&&o.uniforms.time){const i=n.userData.waterTimeScale??1;o.uniforms.time.value+=1/60*i,x.camera&&o.uniforms.eye&&o.uniforms.eye.value.copy(x.camera.position);continue}if(o.normalMap){const i=n.userData.waterSpeed||{x:.005,y:.003};o.normalMap.offset.x+=i.x,o.normalMap.offset.y+=i.y}}}function Ks(){if(!x.container||!x.camera||!x.renderer)return;const l=x.container.clientWidth,e=x.container.clientHeight;l===0||e===0||(x.camera.aspect=l/e,x.camera.updateProjectionMatrix(),x.renderer.setSize(l,e),Ae&&Ae.setSize(l,e),cn(l,e))}function ot(l){x.selectedObject!==l&&(x.selectedObject&&x.transformControls.detach(),x.selectedObject=l,x.transformControls.attach(l),x.transformControls.setMode(x.transformControlsMode),x.transformControls.showX=!0,x.transformControls.showY=!0,x.transformControls.showZ=!0,mn(l),ve==null||ve(l))}let se=null;function pn(l){se=l}function et(l){se==null||se(l)}function An(l){x.transformControlsMode=l,x.transformControls&&x.transformControls.setMode(x.transformControlsMode)}function mn(l){if(x.mode!=="edit"){st();return}st(),l.traverse(e=>{if(e.isMesh){const t=e,s=new P.EdgesGeometry(t.geometry),n=new P.LineBasicMaterial({color:js,depthTest:!0}),o=new P.LineSegments(s,n);e.add(o),pt.push(o)}})}function st(){for(const l of pt)l.parent&&l.parent.remove(l),l.geometry.dispose(),l.material.dispose();pt=[]}function It(){x.selectedObject&&(st(),x.transformControls.detach(),x.selectedObject=null,ve==null||ve(null))}function xt(l){let e=null;we.forEach(t=>{t.userData.id==l&&(e=t),t.children&&t.children.forEach(s=>{s.name&&s.name.startsWith("DataPanel_")&&(s.visible=!1)})}),e&&(e.children.forEach(t=>{t.name&&t.name.startsWith("DataPanel_")&&(t.visible=!0)}),mn(e),x.selectedObject=e,setTimeout(()=>{gn(e)},500))}function Zs(l){if(Me){Me=!1;return}const e=x.renderer.domElement.getBoundingClientRect(),t=new P.Vector2((l.clientX-e.left)/e.width*2-1,-((l.clientY-e.top)/e.height)*2+1),s=new P.Raycaster;s.setFromCamera(t,x.camera);const n=[];x.scene.traverse(i=>{(i.userData.isMovable||i.userData.type==="lightHelper")&&n.push(i)});const o=s.intersectObjects(n);if(o.length>0){let i=Qs(o[0].object);ot(i)}else It()}function Qs(l){if(l.type==="Line"||l.type==="LineSegments"){const e=l.parent;if(e)switch(e.type){case"DirectionalLightHelper":return e.light;default:return e.isMesh?e:l}return l}return l}function gn(l,e=500){if(!x.camera||!x.orbitControls){console.warn("[focusOnObject] 编辑器尚未初始化或已销毁,无法执行聚焦操作。请确保已调用 initEditor()");return}if(!l){console.warn("[focusOnObject] 传入的物体为空,无法执行聚焦操作。");return}let t=null;l.userData.closeUpView&&typeof l.userData.closeUpView.x=="number"&&typeof l.userData.closeUpView.y=="number"&&typeof l.userData.closeUpView.z=="number"&&(t=l.userData.closeUpView);const s=new P.Vector3;l.getWorldPosition(s);const o=new P.Box3().setFromObject(l).getSize(new P.Vector3),i=Math.max(o.x,o.y,o.z)*.5,c=Math.max(i*3.5,5),u=new P.Vector3().copy(x.camera.position).sub(s).normalize();u.lengthSq()<.001&&u.set(0,0,1);const d=s.clone().add(u.multiplyScalar(c)),p=x.camera.position.clone(),f=x.orbitControls.target.clone();try{new je.Tween({x:p.x,y:p.y,z:p.z,tx:f.x,ty:f.y,tz:f.z}).to({x:t?t.x:d.x,y:t?t.y:d.y,z:t?t.z:d.z,tx:s.x,ty:s.y,tz:s.z},e).easing(je.Easing.Quadratic.InOut).onUpdate(g=>{x.camera.position.set(g.x,g.y,g.z),x.orbitControls.target.set(g.tx,g.ty,g.tz),x.orbitControls.update()}).start()}catch(g){console.error("[focusOnObject] TWEEN 动画创建失败,请检查 @tweenjs/tween.js 是否已正确安装且版本兼容(^23.1.3):",g)}}function Js(l){l.userData.id&&we.set(String(l.userData.id),l)}function _s(l){l.userData.id&&we.delete(String(l.userData.id))}function bn(l,e){const t=e||l.userData.id;if(t)we.set(String(t),l);else{const s=P.MathUtils.generateUUID();l.userData.id=s,we.set(s,l)}}function $s(l){l.traverse(e=>{if(e.name&&e.name.startsWith("DataPanel_")){const t=e;t.element&&t.element.parentNode&&t.element.parentNode.removeChild(t.element)}})}function ge(l,e=!1){x.scene.add(l),We=!0,l.userData.isMovable&&(eo(l),it()),e&&x.mode==="edit"&&ot(l)}function yn(l){x.selectedObject===l&&It(),We=!0,$s(l),_s(l),l.userData.helper&&x.scene.remove(l.userData.helper),l.parent?l.parent.remove(l):x.scene.remove(l),to(l),it()}function Cn(l){const e=x.scene.getObjectByProperty("uuid",l);e&&yn(e)}function eo(l){l.userData.isMovable&&l.parent===x.scene&&(me.includes(l)||me.push(l))}function to(l){const e=me.indexOf(l);e!==-1&&me.splice(e,1)}function In(){const l=[];x.scene.children.forEach(e=>{e.userData.isMovable&&l.push(e)}),me=l,it()}function it(){_e==null||_e([...me])}function xn(l){ve=l}function vn(l){At=l}function Mn(l){_e=l}function wn(){return me}function En(){return x.selectedObject}function no(l,e,t){if(!x.scene)return;const s=we.get(l);if(s){const n=Oe(s);n&&n.updateItemByCode(e,t)}}function so(){return x.scene}function Dn(){return x.camera}function oo(){return x.renderer}async function Tn(){var C,I,A;se==null||se(!0),await new Promise(h=>setTimeout(h,50)),It();const l=x.scene;if(!l)return se==null||se(!1),"{}";const e=[],t=new Map,s=new Map,n={},o=[],i=[];l.traverse(h=>{var m,M;if(h.userData.type==="lightHelper"&&e.push(h),h.type==="DirectionalLight"&&h.userData.helper&&(t.set(h,h.userData.helper),h.userData.helper=void 0),h.userData.isWater&&h.type==="Mesh"&&h.parent){const y=h,v=y.material;let D="#4fc3f7";v.uniforms&&v.uniforms.waterColor&&(D="#"+v.uniforms.waterColor.value.getHexString());const E=y.geometry,N={uuid:h.uuid,name:h.name,position:h.position.toArray(),rotation:[h.rotation.x,h.rotation.y,h.rotation.z],scale:h.scale.toArray(),color:D,timeScale:h.userData.waterTimeScale??.05,geometryType:"box",boxWidth:void 0,boxDepth:void 0,cylinderRadiusTop:void 0,cylinderRadiusBottom:void 0,cylinderRadialSegments:void 0};E.parameters&&E.parameters.radiusTop!==void 0?(N.geometryType="cylinder",N.cylinderRadiusTop=E.parameters.radiusTop,N.cylinderRadiusBottom=E.parameters.radiusBottom,N.cylinderRadialSegments=E.parameters.radialSegments):(N.geometryType="box",N.boxWidth=E.parameters.width,N.boxDepth=E.parameters.depth),o.push(N),i.push(h)}if(h.name&&h.name.startsWith("DataPanel_")){const y=h;if(y.element){const v=y.element.querySelector("[data-panel-title]"),D=[];if(y.element.querySelectorAll(".sl-css2d-data-panel-item").forEach(N=>{var z,$,K;const H=N.querySelector(".item-label"),G=N.querySelector(".item-value");if(H&&G){const le=(H.textContent||"").trim(),Q=(($=(z=G.childNodes[0])==null?void 0:z.textContent)==null?void 0:$.trim())||"",j=G.querySelector("span"),X=j?(j.textContent||"").trim():void 0,J=((K=N.getAttribute("data-item-code"))==null?void 0:K.trim())||void 0;D.push({label:le,value:Q,unit:X,code:J})}}),h.parent){const N=y.element.style.width||"",H=y.element.style.fontSize||"",G=Oe(h.parent),z=G?G.getOffsetY():.1;s.set(h.parent.userData.id?h.parent.userData.id:h.parent.uuid,{title:((m=v==null?void 0:v.textContent)==null?void 0:m.trim())||"",items:D,width:N,fontSize:H,offsetY:z,offsetX:G?G.getOffsetX():0})}}}if(h.type==="Mesh"){const y=h,v=Array.isArray(y.material)?y.material:[y.material];for(const D of v)if(D&&D.userData){const E=D.userData;if(E._mapDataUrl||E._normalMapDataUrl||E._aoMapDataUrl){const N=D.uuid,H=n[N]||{};E._mapDataUrl&&(H.mapDataUrl=E._mapDataUrl,H.mapFileName=E._mapFileName),E._normalMapDataUrl&&(H.normalMapDataUrl=E._normalMapDataUrl,H.normalMapFileName=E._normalMapFileName,H.normalScale=((M=D.normalScale)==null?void 0:M.x)??1),E._aoMapDataUrl&&(H.aoMapDataUrl=E._aoMapDataUrl,H.aoMapFileName=E._aoMapFileName,H.aoMapIntensity=D.aoMapIntensity??1),n[N]=H}}}}),e.forEach(h=>l.remove(h));const c=new Map;for(const h of i)c.set(h,h.parent),h.parent&&h.parent.remove(h);const u=l.clone();u.children=u.children.filter(h=>h.userData.type!=="initFloor"),u.traverse(h=>{h.name&&h.name.startsWith("DataPanel_")&&h.parent&&h.parent.remove(h)});const d=u.toJSON();e.forEach(h=>l.add(h));for(const h of i){const m=c.get(h);m?m.add(h):l.add(h)}t.forEach((h,m)=>{m.userData.helper=h});const p={position:(C=x.camera)==null?void 0:C.position.toArray(),rotation:(I=x.camera)==null?void 0:I.rotation.toArray(),target:((A=x.orbitControls)==null?void 0:A.target.toArray())||[0,0,0]},f={};s.forEach((h,m)=>{f[m]=h});const g=JSON.stringify({scene:d,camera:p,dataPanels:f,waters:o,textures:n});return se==null||se(!1),g}function Pn(l,e="edit",t,s,n){var u,d,p,f,g;const o=typeof l=="string"?JSON.parse(l):l,c=new P.ObjectLoader().parse(o);if(c.type==="Scene"){const C=(u=x.scene)==null?void 0:u.environment;if(x.scene=c,C)x.scene.environment=C;else if(x.renderer){const I=dn(x.renderer);I&&(x.scene.environment=I,x.scene.environmentIntensity=.4)}}else(d=x.scene)==null||d.add(c);if(t&&((p=x.scene)==null||p.traverse(C=>{const I=C.userData.id||C.uuid,A=t[I];if(A&&C.userData.isMovable){Js(C);const h=new Be({title:A.title,items:A.items});h.attachTo(C),h.visible=!1,A.width&&h.setWidth(A.width),A.fontSize&&h.setFontSize(A.fontSize),A.offsetY!==void 0&&h.setOffsetY(A.offsetY),A.offsetX!==void 0&&h.setOffsetX(A.offsetX),rn(C,h)}})),s&&s.length>0&&Promise.resolve().then(()=>Qo).then(({addWater:C,addWaterCylinder:I})=>{for(const A of s){const h=A.geometryType||"box";let m;h==="cylinder"?m=I({radiusTop:A.cylinderRadiusTop??5,radiusBottom:A.cylinderRadiusBottom??5,radialSegments:A.cylinderRadialSegments??32,height:.8,color:A.color,scale:4}):m=C({width:A.boxWidth??10,height:A.boxDepth??10,color:A.color,scale:4}),m.position.fromArray(A.position),m.rotation.set(A.rotation[0],A.rotation[1],A.rotation[2]),m.scale.fromArray(A.scale),m.name=A.name,m.userData.waterTimeScale=A.timeScale??.05,m.userData.isWater=!0,m.userData.isMovable=!0,We=!0}In()}),n){const C=new P.TextureLoader;(f=x.scene)==null||f.traverse(I=>{if(I.type==="Mesh"){const A=I,h=Array.isArray(A.material)?A.material:[A.material];for(const m of h)if(m&&m.uuid&&n[m.uuid]){const M=n[m.uuid];if(M.mapDataUrl){const y=C.load(M.mapDataUrl);y.wrapS=y.wrapT=P.RepeatWrapping,y.repeat.set(1,1),m.map=y,m.userData=m.userData||{},m.userData._mapDataUrl=M.mapDataUrl,m.userData._mapFileName=M.mapFileName}if(M.normalMapDataUrl){const y=C.load(M.normalMapDataUrl);y.wrapS=y.wrapT=P.RepeatWrapping,y.repeat.set(1,1),m.normalMap=y,m.normalScale=new P.Vector2(M.normalScale??1,M.normalScale??1),m.userData=m.userData||{},m.userData._normalMapDataUrl=M.normalMapDataUrl,m.userData._normalMapFileName=M.normalMapFileName}if(M.aoMapDataUrl){const y=C.load(M.aoMapDataUrl);y.wrapS=y.wrapT=P.RepeatWrapping,y.repeat.set(1,1),m.aoMap=y,m.aoMapIntensity=M.aoMapIntensity??1,m.userData=m.userData||{},m.userData._aoMapDataUrl=M.aoMapDataUrl,m.userData._aoMapFileName=M.aoMapFileName}m.needsUpdate=!0}}})}e==="edit"&&((g=x.scene)==null||g.traverse(C=>{var I;if(C.type==="DirectionalLight"){const A=C;if(!A.userData.helper){const h=new P.DirectionalLightHelper(A,1);h.userData.type="lightHelper",A.userData.helper=h,(I=x.scene)==null||I.add(h)}}}))}function On(l){if(!l)return;if(l.type==="Mesh"){const t=l;t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material:[t.material]).forEach(n=>{n.map&&(n.map=null),n.lightMap&&(n.lightMap=null),n.aoMap&&(n.aoMap=null),n.emissiveMap&&(n.emissiveMap=null),n.bumpMap&&(n.bumpMap=null),n.normalMap&&(n.normalMap=null),n.displacementMap&&(n.displacementMap=null),n.roughnessMap&&(n.roughnessMap=null),n.metalnessMap&&(n.metalnessMap=null),n.alphaMap&&(n.alphaMap=null),n.envMap&&(n.envMap=null),n.dispose()})}const e=l.children.slice();for(const t of e)On(t)}function Nn(){$e!==null&&(cancelAnimationFrame($e),$e=null),Ve&&x.container&&(x.container.removeEventListener("click",Ve),Ve=null),He&&(window.removeEventListener("resize",He),He=null),x.orbitControls&&(x.orbitControls.dispose(),x.orbitControls=null),x.transformControls&&(x.transformControls.dispose(),x.transformControls=null),Ae&&(Ae.dispose(),Ae=null),x.scene&&(On(x.scene),x.scene=null),x.renderer&&(x.renderer.dispose(),x.renderer.domElement&&x.container&&x.container.removeChild(x.renderer.domElement),x.renderer=null),un(),x.camera=null,x.gridHelper=null,x.selectedObject=null,x.container=null,x.mode="",me=[],we.clear(),it(),Je=!1,Me=!1}const io=/^[og]\s*(.+)?/,ro=/^mtllib /,ao=/^usemtl /,lo=/^usemap /,Yt=/\s+/,Kt=new a.Vector3,ct=new a.Vector3,Zt=new a.Vector3,Qt=new a.Vector3,oe=new a.Vector3,Ze=new a.Color;function co(){const l={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materials:{},materialLibraries:[],startObject:function(e,t){if(this.object&&this.object.fromDeclaration===!1){this.object.name=e,this.object.fromDeclaration=t!==!1;return}const s=this.object&&typeof this.object.currentMaterial=="function"?this.object.currentMaterial():void 0;if(this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0),this.object={name:e||"",fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(n,o){const i=this._finalize(!1);i&&(i.inherited||i.groupCount<=0)&&this.materials.splice(i.index,1);const c={index:this.materials.length,name:n||"",mtllib:Array.isArray(o)&&o.length>0?o[o.length-1]:"",smooth:i!==void 0?i.smooth:this.smooth,groupStart:i!==void 0?i.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(u){const d={index:typeof u=="number"?u:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return d.clone=this.clone.bind(d),d}};return this.materials.push(c),c},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(n){const o=this.currentMaterial();if(o&&o.groupEnd===-1&&(o.groupEnd=this.geometry.vertices.length/3,o.groupCount=o.groupEnd-o.groupStart,o.inherited=!1),n&&this.materials.length>1)for(let i=this.materials.length-1;i>=0;i--)this.materials[i].groupCount<=0&&this.materials.splice(i,1);return n&&this.materials.length===0&&this.materials.push({name:"",smooth:this.smooth}),o}},s&&s.name&&typeof s.clone=="function"){const n=s.clone(0);n.inherited=!0,this.object.materials.push(n)}this.objects.push(this.object)},finalize:function(){this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0)},parseVertexIndex:function(e,t){const s=parseInt(e,10);return(s>=0?s-1:s+t/3)*3},parseNormalIndex:function(e,t){const s=parseInt(e,10);return(s>=0?s-1:s+t/3)*3},parseUVIndex:function(e,t){const s=parseInt(e,10);return(s>=0?s-1:s+t/2)*2},addVertex:function(e,t,s){const n=this.vertices,o=this.object.geometry.vertices;o.push(n[e+0],n[e+1],n[e+2]),o.push(n[t+0],n[t+1],n[t+2]),o.push(n[s+0],n[s+1],n[s+2])},addVertexPoint:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,s){const n=this.normals,o=this.object.geometry.normals;o.push(n[e+0],n[e+1],n[e+2]),o.push(n[t+0],n[t+1],n[t+2]),o.push(n[s+0],n[s+1],n[s+2])},addFaceNormal:function(e,t,s){const n=this.vertices,o=this.object.geometry.normals;Kt.fromArray(n,e),ct.fromArray(n,t),Zt.fromArray(n,s),oe.subVectors(Zt,ct),Qt.subVectors(Kt,ct),oe.cross(Qt),oe.normalize(),o.push(oe.x,oe.y,oe.z),o.push(oe.x,oe.y,oe.z),o.push(oe.x,oe.y,oe.z)},addColor:function(e,t,s){const n=this.colors,o=this.object.geometry.colors;n[e]!==void 0&&o.push(n[e+0],n[e+1],n[e+2]),n[t]!==void 0&&o.push(n[t+0],n[t+1],n[t+2]),n[s]!==void 0&&o.push(n[s+0],n[s+1],n[s+2])},addUV:function(e,t,s){const n=this.uvs,o=this.object.geometry.uvs;o.push(n[e+0],n[e+1]),o.push(n[t+0],n[t+1]),o.push(n[s+0],n[s+1])},addDefaultUV:function(){const e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){const t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,s,n,o,i,c,u,d){const p=this.vertices.length;let f=this.parseVertexIndex(e,p),g=this.parseVertexIndex(t,p),C=this.parseVertexIndex(s,p);if(this.addVertex(f,g,C),this.addColor(f,g,C),c!==void 0&&c!==""){const I=this.normals.length;f=this.parseNormalIndex(c,I),g=this.parseNormalIndex(u,I),C=this.parseNormalIndex(d,I),this.addNormal(f,g,C)}else this.addFaceNormal(f,g,C);if(n!==void 0&&n!==""){const I=this.uvs.length;f=this.parseUVIndex(n,I),g=this.parseUVIndex(o,I),C=this.parseUVIndex(i,I),this.addUV(f,g,C),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type="Points";const t=this.vertices.length;for(let s=0,n=e.length;s<n;s++){const o=this.parseVertexIndex(e[s],t);this.addVertexPoint(o),this.addColor(o)}},addLineGeometry:function(e,t){this.object.geometry.type="Line";const s=this.vertices.length,n=this.uvs.length;for(let o=0,i=e.length;o<i;o++)this.addVertexLine(this.parseVertexIndex(e[o],s));for(let o=0,i=t.length;o<i;o++)this.addUVLine(this.parseUVIndex(t[o],n))}};return l.startObject("",!1),l}class uo extends a.Loader{constructor(e){super(e),this.materials=null}load(e,t,s,n){const o=this,i=new a.FileLoader(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,function(c){try{t(o.parse(c))}catch(u){n?n(u):console.error(u),o.manager.itemError(e)}},s,n)}setMaterials(e){return this.materials=e,this}parse(e){const t=new co;e.indexOf(`\r
138
+ `,e.appendChild(o)})}escapeHtml(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}attachTo(e){this.attachedObject&&this.attachedObject!==e&&this.detach();const t=new P.Vector3;e.getWorldPosition(t);const o=new P.Box3().setFromObject(e).max.y-t.y+this.options.offsetY;this.css2dObject||(this.css2dObject=new Es(this.container),this.css2dObject.name=`DataPanel_${e.name||e.uuid}`,this.css2dObject.center.set(.5,1)),this.css2dObject.position.set(this.options.offsetX,o,0),e.add(this.css2dObject),this.attachedObject=e}detach(){this.css2dObject&&this.attachedObject&&this.attachedObject.remove(this.css2dObject),this.attachedObject=null}show(){this._visible=!0,this.css2dObject&&(this.css2dObject.visible=!0)}hide(){this._visible=!1,this.css2dObject&&(this.css2dObject.visible=!1)}get visible(){return this._visible}set visible(e){e?this.show():this.hide()}setTitle(e){var s;this.options.title=e;const t=(s=this.container)==null?void 0:s.querySelector("[data-panel-title]");e?t?t.textContent=e:this.rebuildPanel():t&&t.remove()}getTitle(){return this.options.title||""}setItems(e){var s;this.options.items=[...e];const t=(s=this.container)==null?void 0:s.querySelector("[data-panel-list]");t&&this.renderItems(t,this.options.items)}getItems(){return[...this.options.items||[]]}addItem(e){var s;this.options.items.push(e);const t=(s=this.container)==null?void 0:s.querySelector("[data-panel-list]");t&&this.renderItems(t,this.options.items)}removeItem(e){var s;this.options.items=this.options.items.filter(n=>n.label!==e);const t=(s=this.container)==null?void 0:s.querySelector("[data-panel-list]");t&&this.renderItems(t,this.options.items)}updateItem(e,t,s){var o;const n=this.options.items.find(i=>i.label===e);if(n){n.value=t,s!==void 0&&(n.unit=s);const i=(o=this.container)==null?void 0:o.querySelector("[data-panel-list]");i&&this.renderItems(i,this.options.items)}}updateItemByCode(e,t){var n;const s=this.options.items.find(o=>o.code===e);if(s){s.value=t;const o=(n=this.container)==null?void 0:n.querySelector("[data-panel-list]");o&&this.renderItems(o,this.options.items)}}clearItems(){var t;this.options.items=[];const e=(t=this.container)==null?void 0:t.querySelector("[data-panel-list]");e&&this.renderItems(e,[])}rebuildPanel(){const e=this._visible,t=this.attachedObject;this.css2dObject&&this.attachedObject&&this.attachedObject.remove(this.css2dObject),this.buildPanel(),t&&(this.attachedObject=t,t.add(this.css2dObject),e||this.hide())}updateOptions(e){this.options={...this.options,...e},this.rebuildPanel()}getOffsetY(){return this.options.offsetY??.1}setOffsetY(e){if(this.options.offsetY=e,this.css2dObject&&this.attachedObject){const t=new P.Vector3;this.attachedObject.getWorldPosition(t);const n=new P.Box3().setFromObject(this.attachedObject).max.y-t.y;this.css2dObject.position.set(this.options.offsetX??0,n+e,0)}}getOffsetX(){return this.options.offsetX??0}setOffsetX(e){this.options.offsetX=e,this.css2dObject&&this.attachedObject&&(this.css2dObject.position.x=e)}getWidth(){return this.options.width||"20em"}getFontSize(){return this.options.fontSize||"0.85em"}setWidth(e){this.options.width=e,this.container&&(this.container.style.width=e)}setFontSize(e){if(this.options.fontSize=e,this.container){this.container.style.fontSize=e;const t=this.container.querySelector("[data-panel-title]");t&&(t.style.fontSize=`calc(${e} + 0.15em)`)}}getElement(){return this.container}dispose(){var e;this.detach(),(e=this.container)!=null&&e.parentNode&&this.container.parentNode.removeChild(this.container),this.css2dObject=null,this.container=null,this.attachedObject=null}};ye(Te,"_breathInjected",!1);let Be=Te;const tt=new WeakMap;function rn(l,e){const t=r.toRaw(l);tt.set(t,e),t.userData._hasDataPanel=!0}function Oe(l){return tt.get(r.toRaw(l))||null}function yt(l){const e=r.toRaw(l),t=tt.get(e);t&&(t.dispose(),tt.delete(e)),e.userData._hasDataPanel=void 0}let q=null;function an(l){return q?(q.domElement.parentNode!==l&&l.appendChild(q.domElement),q):(q=new Ds,q.setSize(l.clientWidth,l.clientHeight),q.domElement.style.position="absolute",q.domElement.style.top="0",q.domElement.style.left="0",q.domElement.style.pointerEvents="none",l.appendChild(q.domElement),q)}function Vs(){return q}function ln(l,e){q&&q.render(l,e)}function cn(l,e){q&&q.setSize(l,e)}function un(){q&&(q.domElement.parentNode&&q.domElement.parentNode.removeChild(q.domElement),q=null)}function Hs(){const l=new P.Scene;l.position.y=-3.5;const e=new P.BoxGeometry;e.deleteAttribute("uv");const t=new P.MeshStandardMaterial({side:P.BackSide}),s=new P.PointLight(16777215,900,28,2);s.position.set(.418,16.199,.3),l.add(s);const n=new P.Mesh(e,t);n.position.set(-.757,13.219,.717),n.scale.set(31.713,28.305,28.591),l.add(n);const o=new P.MeshStandardMaterial,i=new P.InstancedMesh(e,o,6),c=new P.Object3D;c.position.set(-10.906,2.009,1.846),c.rotation.set(0,-.195,0),c.scale.set(2.328,7.905,4.651),c.updateMatrix(),i.setMatrixAt(0,c.matrix),c.position.set(-5.607,-.754,-.758),c.rotation.set(0,.994,0),c.scale.set(1.97,1.534,3.955),c.updateMatrix(),i.setMatrixAt(1,c.matrix),c.position.set(6.167,.857,7.803),c.rotation.set(0,.561,0),c.scale.set(3.927,6.285,3.687),c.updateMatrix(),i.setMatrixAt(2,c.matrix),c.position.set(-2.017,.018,6.124),c.rotation.set(0,.333,0),c.scale.set(2.002,4.566,2.064),c.updateMatrix(),i.setMatrixAt(3,c.matrix),c.position.set(2.291,-.756,-2.621),c.rotation.set(0,-.286,0),c.scale.set(1.546,1.552,1.496),c.updateMatrix(),i.setMatrixAt(4,c.matrix),c.position.set(-2.193,-.369,-5.547),c.rotation.set(0,.516,0),c.scale.set(3.875,3.487,2.986),c.updateMatrix(),i.setMatrixAt(5,c.matrix),i.instanceMatrix.needsUpdate=!0,l.add(i);function u(A){return new P.MeshLambertMaterial({color:0,emissive:16777215,emissiveIntensity:A})}const d=new P.Mesh(e,u(50));d.position.set(-16.116,14.37,8.208),d.scale.set(.1,2.428,2.739),l.add(d);const p=new P.Mesh(e,u(50));p.position.set(-16.109,18.021,-8.207),p.scale.set(.1,2.425,2.751),l.add(p);const f=new P.Mesh(e,u(17));f.position.set(14.904,12.198,-1.832),f.scale.set(.15,4.265,6.331),l.add(f);const g=new P.Mesh(e,u(43));g.position.set(-.462,8.89,14.52),g.scale.set(4.38,5.441,.088),l.add(g);const C=new P.Mesh(e,u(20));C.position.set(3.235,11.486,-12.541),C.scale.set(2.5,2,.1),l.add(C);const I=new P.Mesh(e,u(100));return I.position.set(0,20,0),I.scale.set(1,.1,1),l.add(I),l}function dn(l){try{const e=new P.PMREMGenerator(l),t=Hs(),s=e.fromScene(t).texture;return t.traverse(n=>{if(n.isMesh){const o=n,i=Array.isArray(o.material)?o.material:[o.material];for(const c of i)c&&c.dispose()}}),e.dispose(),s}catch(e){return console.error("环境贴图生成失败:",e),null}}const x={mode:"",transformControlsMode:"translate",scene:null,camera:null,defaultMainCamera:null,renderer:null,orbitControls:null,transformControls:null,container:null,gridHelper:null,selectedObject:null};let Je=!1,Me=!1,Ae=null;const js=16755200;let pt=[],Ke=[],We=!0,ve=null,At=null,_e=null,me=[];const we=new Map;let nt,$e=null,Ve=null,He=null;function hn(l,e="edit",t){x.container=l,x.mode=e,Ws(),Gs(),Us(),t&&(Pn(t.scene,e,t.dataPanels,t.waters,t.textures),t!=null&&t.camera&&(x.defaultMainCamera=t.camera,Ct(!0))),qs(),Xs(),nt&&x.orbitControls&&(x.orbitControls.target.fromArray(nt),x.orbitControls.update()),Fs(),In(),fn(),Ve=s=>Zs(s),He=()=>Ks(),e==="edit"&&l.addEventListener("click",Ve),window.addEventListener("resize",He),t||Ys(),e==="edit"&&zs()}function Bs(){return window.devicePixelRatio}function Ws(){const l=Bs(),e=new P.WebGLRenderer({antialias:!0,alpha:!0});e.setSize(x.container.clientWidth,x.container.clientHeight),e.setPixelRatio(l),e.toneMapping=P.NeutralToneMapping,e.toneMappingExposure=1,console.log(`[Renderer] css=${x.container.clientWidth}×${x.container.clientHeight}, dpr=${window.devicePixelRatio}, targetRatio=${l}, antialias=true`),x.container.appendChild(e.domElement),x.renderer=e}function Fs(){if(!x.renderer||!x.scene||!x.camera)return;const l=x.renderer.getPixelRatio(),e=x.container.clientWidth*l,t=x.container.clientHeight*l,s=new P.WebGLRenderTarget(e,t,{type:P.HalfFloatType,samples:4});s.texture.name="EffectComposer.rt1";const n=new vs(x.renderer,s);n.addPass(new Ms(x.scene,x.camera)),n.addPass(new ws),Ae=n}function Gs(){if(x.scene=new P.Scene,x.scene.name="sl_scene",x.renderer){const l=dn(x.renderer);l&&(x.scene.environment=l,x.scene.environmentIntensity=1)}}function zs(){const l=new P.GridHelper(30,30,8956671,3364232);l.name="地板",l.userData.type="initFloor",x.scene.add(l),x.gridHelper=l}function Us(){const l=x.container,e=l.clientWidth/l.clientHeight,t=new P.PerspectiveCamera(45,e,.1,1e3);t.position.set(0,6,15),t.lookAt(0,0,0),x.camera=t}function Ct(l=!1){if(!x.defaultMainCamera)return;const e=x.defaultMainCamera;if(l){x.camera.position.set(e.position[0],e.position[1],e.position[2]),x.camera.rotation.set(e.rotation[0],e.rotation[1],e.rotation[2]),x.camera.updateProjectionMatrix(),nt=e.target;return}else xt(""),st();if(!x.camera||!x.orbitControls)return;const t=x.camera.position.clone(),s=x.orbitControls.target.clone(),n=new P.Vector3(e.position[0],e.position[1],e.position[2]),o=e.target?new P.Vector3(e.target[0],e.target[1],e.target[2]):new P.Vector3(0,0,0);x.orbitControls.enabled=!1,new je.Tween({x:t.x,y:t.y,z:t.z,tx:s.x,ty:s.y,tz:s.z}).to({x:n.x,y:n.y,z:n.z,tx:o.x,ty:o.y,tz:o.z},1e3).easing(je.Easing.Quadratic.InOut).onUpdate(i=>{x.camera.position.set(i.x,i.y,i.z),x.orbitControls.target.set(i.tx,i.ty,i.tz),x.orbitControls.update()}).onComplete(()=>{nt=e.target,x.orbitControls.enabled=!0}).start()}function Xs(){const l=new Zn(x.camera,x.renderer.domElement);l.minDistance=0,l.maxDistance=1/0,l.addEventListener("start",()=>{Je=!1}),l.addEventListener("change",()=>{Je=!0}),l.addEventListener("end",()=>{Je&&(Me=!0,setTimeout(()=>{Me=!1},200))}),x.orbitControls=l}function qs(){const l=new ls(x.camera,x.renderer.domElement);l.addEventListener("dragging-changed",e=>{x.orbitControls.enabled=!e.value,e.value||(Me=!0,setTimeout(()=>{Me=!1},200))}),l.addEventListener("objectChange",()=>{const e=x.selectedObject;if(At&&e&&At(e),e&&e.type==="DirectionalLight"){const t=e.userData.helper;t&&t.update&&t.update()}}),x.scene.add(l.getHelper()),x.transformControls=l}function Ys(){const l=new P.AmbientLight(16777215,1);x.scene.add(l)}function fn(){var e,t;$e=requestAnimationFrame(fn),je.update(),(e=x.orbitControls)==null||e.update(),x.mode==="run"&&Ae&&x.scene&&x.camera?Ae.render():(t=x.renderer)==null||t.render(x.scene,x.camera),x.scene&&x.camera&&ln(x.scene,x.camera),We&&x.scene&&(Ke=[],x.scene.traverse(s=>{s.userData.isWater&&s.type==="Mesh"&&Ke.push(s)}),We=!1);for(let s=0;s<Ke.length;s++){const n=Ke[s],o=n.material;if(o.uniforms&&o.uniforms.time){const i=n.userData.waterTimeScale??1;o.uniforms.time.value+=1/60*i,x.camera&&o.uniforms.eye&&o.uniforms.eye.value.copy(x.camera.position);continue}if(o.normalMap){const i=n.userData.waterSpeed||{x:.005,y:.003};o.normalMap.offset.x+=i.x,o.normalMap.offset.y+=i.y}}}function Ks(){if(!x.container||!x.camera||!x.renderer)return;const l=x.container.clientWidth,e=x.container.clientHeight;l===0||e===0||(x.camera.aspect=l/e,x.camera.updateProjectionMatrix(),x.renderer.setSize(l,e),Ae&&Ae.setSize(l,e),cn(l,e))}function ot(l){x.selectedObject!==l&&(x.selectedObject&&x.transformControls.detach(),x.selectedObject=l,x.transformControls.attach(l),x.transformControls.setMode(x.transformControlsMode),x.transformControls.showX=!0,x.transformControls.showY=!0,x.transformControls.showZ=!0,mn(l),ve==null||ve(l))}let se=null;function pn(l){se=l}function et(l){se==null||se(l)}function An(l){x.transformControlsMode=l,x.transformControls&&x.transformControls.setMode(x.transformControlsMode)}function mn(l){if(x.mode!=="edit"){st();return}st(),l.traverse(e=>{if(e.isMesh){const t=e,s=new P.EdgesGeometry(t.geometry),n=new P.LineBasicMaterial({color:js,depthTest:!0}),o=new P.LineSegments(s,n);e.add(o),pt.push(o)}})}function st(){for(const l of pt)l.parent&&l.parent.remove(l),l.geometry.dispose(),l.material.dispose();pt=[]}function It(){x.selectedObject&&(st(),x.transformControls.detach(),x.selectedObject=null,ve==null||ve(null))}function xt(l){let e=null;we.forEach(t=>{t.userData.id==l&&(e=t),t.children&&t.children.forEach(s=>{s.name&&s.name.startsWith("DataPanel_")&&(s.visible=!1)})}),e&&(e.children.forEach(t=>{t.name&&t.name.startsWith("DataPanel_")&&(t.visible=!0)}),mn(e),x.selectedObject=e,setTimeout(()=>{gn(e)},500))}function Zs(l){if(Me){Me=!1;return}const e=x.renderer.domElement.getBoundingClientRect(),t=new P.Vector2((l.clientX-e.left)/e.width*2-1,-((l.clientY-e.top)/e.height)*2+1),s=new P.Raycaster;s.setFromCamera(t,x.camera);const n=[];x.scene.traverse(i=>{(i.userData.isMovable||i.userData.type==="lightHelper")&&n.push(i)});const o=s.intersectObjects(n);if(o.length>0){let i=Qs(o[0].object);ot(i)}else It()}function Qs(l){if(l.type==="Line"||l.type==="LineSegments"){const e=l.parent;if(e)switch(e.type){case"DirectionalLightHelper":return e.light;default:return e.isMesh?e:l}return l}return l}function gn(l,e=500){if(!x.camera||!x.orbitControls){console.warn("[focusOnObject] 编辑器尚未初始化或已销毁,无法执行聚焦操作。请确保已调用 initEditor()");return}if(!l){console.warn("[focusOnObject] 传入的物体为空,无法执行聚焦操作。");return}let t=null;l.userData.closeUpView&&typeof l.userData.closeUpView.x=="number"&&typeof l.userData.closeUpView.y=="number"&&typeof l.userData.closeUpView.z=="number"&&(t=l.userData.closeUpView);const s=new P.Vector3;l.getWorldPosition(s);const o=new P.Box3().setFromObject(l).getSize(new P.Vector3),i=Math.max(o.x,o.y,o.z)*.5,c=Math.max(i*3.5,5),u=new P.Vector3().copy(x.camera.position).sub(s).normalize();u.lengthSq()<.001&&u.set(0,0,1);const d=s.clone().add(u.multiplyScalar(c)),p=x.camera.position.clone(),f=x.orbitControls.target.clone();try{new je.Tween({x:p.x,y:p.y,z:p.z,tx:f.x,ty:f.y,tz:f.z}).to({x:t?t.x:d.x,y:t?t.y:d.y,z:t?t.z:d.z,tx:s.x,ty:s.y,tz:s.z},e).easing(je.Easing.Quadratic.InOut).onUpdate(g=>{x.camera.position.set(g.x,g.y,g.z),x.orbitControls.target.set(g.tx,g.ty,g.tz),x.orbitControls.update()}).start()}catch(g){console.error("[focusOnObject] TWEEN 动画创建失败,请检查 @tweenjs/tween.js 是否已正确安装且版本兼容(^23.1.3):",g)}}function Js(l){l.userData.id&&we.set(String(l.userData.id),l)}function _s(l){l.userData.id&&we.delete(String(l.userData.id))}function bn(l,e){const t=e||l.userData.id;if(t)we.set(String(t),l);else{const s=P.MathUtils.generateUUID();l.userData.id=s,we.set(s,l)}}function $s(l){l.traverse(e=>{if(e.name&&e.name.startsWith("DataPanel_")){const t=e;t.element&&t.element.parentNode&&t.element.parentNode.removeChild(t.element)}})}function ge(l,e=!1){x.scene.add(l),We=!0,l.userData.isMovable&&(eo(l),it()),e&&x.mode==="edit"&&ot(l)}function yn(l){x.selectedObject===l&&It(),We=!0,$s(l),_s(l),l.userData.helper&&x.scene.remove(l.userData.helper),l.parent?l.parent.remove(l):x.scene.remove(l),to(l),it()}function Cn(l){const e=x.scene.getObjectByProperty("uuid",l);e&&yn(e)}function eo(l){l.userData.isMovable&&l.parent===x.scene&&(me.includes(l)||me.push(l))}function to(l){const e=me.indexOf(l);e!==-1&&me.splice(e,1)}function In(){const l=[];x.scene.children.forEach(e=>{e.userData.isMovable&&l.push(e)}),me=l,it()}function it(){_e==null||_e([...me])}function xn(l){ve=l}function vn(l){At=l}function Mn(l){_e=l}function wn(){return me}function En(){return x.selectedObject}function no(l,e,t){if(!x.scene)return;const s=we.get(l);if(s){const n=Oe(s);n&&n.updateItemByCode(e,t)}}function so(){return x.scene}function Dn(){return x.camera}function oo(){return x.renderer}async function Tn(){var C,I,A;se==null||se(!0),await new Promise(h=>setTimeout(h,50)),It();const l=x.scene;if(!l)return se==null||se(!1),"{}";const e=[],t=new Map,s=new Map,n={},o=[],i=[];l.traverse(h=>{var m,M;if(h.userData.type==="lightHelper"&&e.push(h),h.type==="DirectionalLight"&&h.userData.helper&&(t.set(h,h.userData.helper),h.userData.helper=void 0),h.userData.isWater&&h.type==="Mesh"&&h.parent){const y=h,v=y.material;let D="#4fc3f7";v.uniforms&&v.uniforms.waterColor&&(D="#"+v.uniforms.waterColor.value.getHexString());const E=y.geometry,N={uuid:h.uuid,name:h.name,position:h.position.toArray(),rotation:[h.rotation.x,h.rotation.y,h.rotation.z],scale:h.scale.toArray(),color:D,timeScale:h.userData.waterTimeScale??.05,geometryType:"box",boxWidth:void 0,boxDepth:void 0,cylinderRadiusTop:void 0,cylinderRadiusBottom:void 0,cylinderRadialSegments:void 0};E.parameters&&E.parameters.radiusTop!==void 0?(N.geometryType="cylinder",N.cylinderRadiusTop=E.parameters.radiusTop,N.cylinderRadiusBottom=E.parameters.radiusBottom,N.cylinderRadialSegments=E.parameters.radialSegments):(N.geometryType="box",N.boxWidth=E.parameters.width,N.boxDepth=E.parameters.depth),o.push(N),i.push(h)}if(h.name&&h.name.startsWith("DataPanel_")){const y=h;if(y.element){const v=y.element.querySelector("[data-panel-title]"),D=[];if(y.element.querySelectorAll(".sl-css2d-data-panel-item").forEach(N=>{var z,$,K;const H=N.querySelector(".item-label"),G=N.querySelector(".item-value");if(H&&G){const le=(H.textContent||"").trim(),Q=(($=(z=G.childNodes[0])==null?void 0:z.textContent)==null?void 0:$.trim())||"",j=G.querySelector("span"),X=j?(j.textContent||"").trim():void 0,J=((K=N.getAttribute("data-item-code"))==null?void 0:K.trim())||void 0;D.push({label:le,value:Q,unit:X,code:J})}}),h.parent){const N=y.element.style.width||"",H=y.element.style.fontSize||"",G=Oe(h.parent),z=G?G.getOffsetY():.1;s.set(h.parent.userData.id?h.parent.userData.id:h.parent.uuid,{title:((m=v==null?void 0:v.textContent)==null?void 0:m.trim())||"",items:D,width:N,fontSize:H,offsetY:z,offsetX:G?G.getOffsetX():0})}}}if(h.type==="Mesh"){const y=h,v=Array.isArray(y.material)?y.material:[y.material];for(const D of v)if(D&&D.userData){const E=D.userData;if(E._mapDataUrl||E._normalMapDataUrl||E._aoMapDataUrl){const N=D.uuid,H=n[N]||{};E._mapDataUrl&&(H.mapDataUrl=E._mapDataUrl,H.mapFileName=E._mapFileName),E._normalMapDataUrl&&(H.normalMapDataUrl=E._normalMapDataUrl,H.normalMapFileName=E._normalMapFileName,H.normalScale=((M=D.normalScale)==null?void 0:M.x)??1),E._aoMapDataUrl&&(H.aoMapDataUrl=E._aoMapDataUrl,H.aoMapFileName=E._aoMapFileName,H.aoMapIntensity=D.aoMapIntensity??1),n[N]=H}}}}),e.forEach(h=>l.remove(h));const c=new Map;for(const h of i)c.set(h,h.parent),h.parent&&h.parent.remove(h);const u=l.clone();u.children=u.children.filter(h=>h.userData.type!=="initFloor"),u.traverse(h=>{h.name&&h.name.startsWith("DataPanel_")&&h.parent&&h.parent.remove(h)});const d=u.toJSON();e.forEach(h=>l.add(h));for(const h of i){const m=c.get(h);m?m.add(h):l.add(h)}t.forEach((h,m)=>{m.userData.helper=h});const p={position:(C=x.camera)==null?void 0:C.position.toArray(),rotation:(I=x.camera)==null?void 0:I.rotation.toArray(),target:((A=x.orbitControls)==null?void 0:A.target.toArray())||[0,0,0]},f={};s.forEach((h,m)=>{f[m]=h});const g=JSON.stringify({scene:d,camera:p,dataPanels:f,waters:o,textures:n});return se==null||se(!1),g}function Pn(l,e="edit",t,s,n){var u,d,p,f,g;const o=typeof l=="string"?JSON.parse(l):l,c=new P.ObjectLoader().parse(o);if(c.type==="Scene"){const C=(u=x.scene)==null?void 0:u.environment;if(x.scene=c,C)x.scene.environment=C;else if(x.renderer){const I=dn(x.renderer);I&&(x.scene.environment=I,x.scene.environmentIntensity=1)}}else(d=x.scene)==null||d.add(c);if(t&&((p=x.scene)==null||p.traverse(C=>{const I=C.userData.id||C.uuid,A=t[I];if(A&&C.userData.isMovable){Js(C);const h=new Be({title:A.title,items:A.items});h.attachTo(C),h.visible=!1,A.width&&h.setWidth(A.width),A.fontSize&&h.setFontSize(A.fontSize),A.offsetY!==void 0&&h.setOffsetY(A.offsetY),A.offsetX!==void 0&&h.setOffsetX(A.offsetX),rn(C,h)}})),s&&s.length>0&&Promise.resolve().then(()=>Qo).then(({addWater:C,addWaterCylinder:I})=>{for(const A of s){const h=A.geometryType||"box";let m;h==="cylinder"?m=I({radiusTop:A.cylinderRadiusTop??5,radiusBottom:A.cylinderRadiusBottom??5,radialSegments:A.cylinderRadialSegments??32,height:.8,color:A.color,scale:4}):m=C({width:A.boxWidth??10,height:A.boxDepth??10,color:A.color,scale:4}),m.position.fromArray(A.position),m.rotation.set(A.rotation[0],A.rotation[1],A.rotation[2]),m.scale.fromArray(A.scale),m.name=A.name,m.userData.waterTimeScale=A.timeScale??.05,m.userData.isWater=!0,m.userData.isMovable=!0,We=!0}In()}),n){const C=new P.TextureLoader;(f=x.scene)==null||f.traverse(I=>{if(I.type==="Mesh"){const A=I,h=Array.isArray(A.material)?A.material:[A.material];for(const m of h)if(m&&m.uuid&&n[m.uuid]){const M=n[m.uuid];if(M.mapDataUrl){const y=C.load(M.mapDataUrl);y.wrapS=y.wrapT=P.RepeatWrapping,y.repeat.set(1,1),m.map=y,m.userData=m.userData||{},m.userData._mapDataUrl=M.mapDataUrl,m.userData._mapFileName=M.mapFileName}if(M.normalMapDataUrl){const y=C.load(M.normalMapDataUrl);y.wrapS=y.wrapT=P.RepeatWrapping,y.repeat.set(1,1),m.normalMap=y,m.normalScale=new P.Vector2(M.normalScale??1,M.normalScale??1),m.userData=m.userData||{},m.userData._normalMapDataUrl=M.normalMapDataUrl,m.userData._normalMapFileName=M.normalMapFileName}if(M.aoMapDataUrl){const y=C.load(M.aoMapDataUrl);y.wrapS=y.wrapT=P.RepeatWrapping,y.repeat.set(1,1),m.aoMap=y,m.aoMapIntensity=M.aoMapIntensity??1,m.userData=m.userData||{},m.userData._aoMapDataUrl=M.aoMapDataUrl,m.userData._aoMapFileName=M.aoMapFileName}m.needsUpdate=!0}}})}e==="edit"&&((g=x.scene)==null||g.traverse(C=>{var I;if(C.type==="DirectionalLight"){const A=C;if(!A.userData.helper){const h=new P.DirectionalLightHelper(A,1);h.userData.type="lightHelper",A.userData.helper=h,(I=x.scene)==null||I.add(h)}}}))}function On(l){if(!l)return;if(l.type==="Mesh"){const t=l;t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material:[t.material]).forEach(n=>{n.map&&(n.map=null),n.lightMap&&(n.lightMap=null),n.aoMap&&(n.aoMap=null),n.emissiveMap&&(n.emissiveMap=null),n.bumpMap&&(n.bumpMap=null),n.normalMap&&(n.normalMap=null),n.displacementMap&&(n.displacementMap=null),n.roughnessMap&&(n.roughnessMap=null),n.metalnessMap&&(n.metalnessMap=null),n.alphaMap&&(n.alphaMap=null),n.envMap&&(n.envMap=null),n.dispose()})}const e=l.children.slice();for(const t of e)On(t)}function Nn(){$e!==null&&(cancelAnimationFrame($e),$e=null),Ve&&x.container&&(x.container.removeEventListener("click",Ve),Ve=null),He&&(window.removeEventListener("resize",He),He=null),x.orbitControls&&(x.orbitControls.dispose(),x.orbitControls=null),x.transformControls&&(x.transformControls.dispose(),x.transformControls=null),Ae&&(Ae.dispose(),Ae=null),x.scene&&(On(x.scene),x.scene=null),x.renderer&&(x.renderer.dispose(),x.renderer.domElement&&x.container&&x.container.removeChild(x.renderer.domElement),x.renderer=null),un(),x.camera=null,x.gridHelper=null,x.selectedObject=null,x.container=null,x.mode="",me=[],we.clear(),it(),Je=!1,Me=!1}const io=/^[og]\s*(.+)?/,ro=/^mtllib /,ao=/^usemtl /,lo=/^usemap /,Yt=/\s+/,Kt=new a.Vector3,ct=new a.Vector3,Zt=new a.Vector3,Qt=new a.Vector3,oe=new a.Vector3,Ze=new a.Color;function co(){const l={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materials:{},materialLibraries:[],startObject:function(e,t){if(this.object&&this.object.fromDeclaration===!1){this.object.name=e,this.object.fromDeclaration=t!==!1;return}const s=this.object&&typeof this.object.currentMaterial=="function"?this.object.currentMaterial():void 0;if(this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0),this.object={name:e||"",fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(n,o){const i=this._finalize(!1);i&&(i.inherited||i.groupCount<=0)&&this.materials.splice(i.index,1);const c={index:this.materials.length,name:n||"",mtllib:Array.isArray(o)&&o.length>0?o[o.length-1]:"",smooth:i!==void 0?i.smooth:this.smooth,groupStart:i!==void 0?i.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(u){const d={index:typeof u=="number"?u:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return d.clone=this.clone.bind(d),d}};return this.materials.push(c),c},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(n){const o=this.currentMaterial();if(o&&o.groupEnd===-1&&(o.groupEnd=this.geometry.vertices.length/3,o.groupCount=o.groupEnd-o.groupStart,o.inherited=!1),n&&this.materials.length>1)for(let i=this.materials.length-1;i>=0;i--)this.materials[i].groupCount<=0&&this.materials.splice(i,1);return n&&this.materials.length===0&&this.materials.push({name:"",smooth:this.smooth}),o}},s&&s.name&&typeof s.clone=="function"){const n=s.clone(0);n.inherited=!0,this.object.materials.push(n)}this.objects.push(this.object)},finalize:function(){this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0)},parseVertexIndex:function(e,t){const s=parseInt(e,10);return(s>=0?s-1:s+t/3)*3},parseNormalIndex:function(e,t){const s=parseInt(e,10);return(s>=0?s-1:s+t/3)*3},parseUVIndex:function(e,t){const s=parseInt(e,10);return(s>=0?s-1:s+t/2)*2},addVertex:function(e,t,s){const n=this.vertices,o=this.object.geometry.vertices;o.push(n[e+0],n[e+1],n[e+2]),o.push(n[t+0],n[t+1],n[t+2]),o.push(n[s+0],n[s+1],n[s+2])},addVertexPoint:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,s){const n=this.normals,o=this.object.geometry.normals;o.push(n[e+0],n[e+1],n[e+2]),o.push(n[t+0],n[t+1],n[t+2]),o.push(n[s+0],n[s+1],n[s+2])},addFaceNormal:function(e,t,s){const n=this.vertices,o=this.object.geometry.normals;Kt.fromArray(n,e),ct.fromArray(n,t),Zt.fromArray(n,s),oe.subVectors(Zt,ct),Qt.subVectors(Kt,ct),oe.cross(Qt),oe.normalize(),o.push(oe.x,oe.y,oe.z),o.push(oe.x,oe.y,oe.z),o.push(oe.x,oe.y,oe.z)},addColor:function(e,t,s){const n=this.colors,o=this.object.geometry.colors;n[e]!==void 0&&o.push(n[e+0],n[e+1],n[e+2]),n[t]!==void 0&&o.push(n[t+0],n[t+1],n[t+2]),n[s]!==void 0&&o.push(n[s+0],n[s+1],n[s+2])},addUV:function(e,t,s){const n=this.uvs,o=this.object.geometry.uvs;o.push(n[e+0],n[e+1]),o.push(n[t+0],n[t+1]),o.push(n[s+0],n[s+1])},addDefaultUV:function(){const e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){const t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,s,n,o,i,c,u,d){const p=this.vertices.length;let f=this.parseVertexIndex(e,p),g=this.parseVertexIndex(t,p),C=this.parseVertexIndex(s,p);if(this.addVertex(f,g,C),this.addColor(f,g,C),c!==void 0&&c!==""){const I=this.normals.length;f=this.parseNormalIndex(c,I),g=this.parseNormalIndex(u,I),C=this.parseNormalIndex(d,I),this.addNormal(f,g,C)}else this.addFaceNormal(f,g,C);if(n!==void 0&&n!==""){const I=this.uvs.length;f=this.parseUVIndex(n,I),g=this.parseUVIndex(o,I),C=this.parseUVIndex(i,I),this.addUV(f,g,C),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type="Points";const t=this.vertices.length;for(let s=0,n=e.length;s<n;s++){const o=this.parseVertexIndex(e[s],t);this.addVertexPoint(o),this.addColor(o)}},addLineGeometry:function(e,t){this.object.geometry.type="Line";const s=this.vertices.length,n=this.uvs.length;for(let o=0,i=e.length;o<i;o++)this.addVertexLine(this.parseVertexIndex(e[o],s));for(let o=0,i=t.length;o<i;o++)this.addUVLine(this.parseUVIndex(t[o],n))}};return l.startObject("",!1),l}class uo extends a.Loader{constructor(e){super(e),this.materials=null}load(e,t,s,n){const o=this,i=new a.FileLoader(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,function(c){try{t(o.parse(c))}catch(u){n?n(u):console.error(u),o.manager.itemError(e)}},s,n)}setMaterials(e){return this.materials=e,this}parse(e){const t=new co;e.indexOf(`\r
139
139
  `)!==-1&&(e=e.replace(/\r\n/g,`
140
140
  `)),e.indexOf(`\\
141
141
  `)!==-1&&(e=e.replace(/\\\n/g,""));const s=e.split(`