endset_three_editor 0.5.9 → 0.6.0

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.
@@ -266,7 +266,7 @@
266
266
  `,i.setAttribute("data-item-code",s.code||""),i.innerHTML=`
267
267
  <span class="item-label" style="opacity: 0.9; flex-shrink: 0; letter-spacing: ${n(.3)}em;">${this.escapeHtml(s.label)}</span>
268
268
  <span class="item-value" style="font-weight: 700; color: #9ae4ff; text-shadow: 0 0 ${n(6)}em rgba(154, 228, 255, 0.25); text-align: right; word-break: break-all;">${this.escapeHtml(s.value)}${s.unit?`<span style="font-size:0.85em;opacity:0.8;margin-left:${n(2)}em;">${this.escapeHtml(s.unit)}</span>`:""}</span>
269
- `,e.appendChild(i)})}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 T.Vector3;e.getWorldPosition(t);const n=new T.Box3().setFromObject(e),s=new T.Vector3,i=new T.Vector3;n.getCenter(s),n.getSize(i);const A=n.max.y-t.y+this.options.offsetY;this.css2dObject||(this.css2dObject=new dn(this.container),this.css2dObject.name=`DataPanel_${e.name||e.uuid}`,this.css2dObject.center.set(.5,1)),this.css2dObject.position.set(0,A,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 n;this.options.title=e;const t=(n=this.container)==null?void 0:n.querySelector("[data-panel-title]");e?t?t.textContent=e:this.rebuildPanel():t&&t.remove()}getTitle(){return this.options.title||""}setItems(e){var n;this.options.items=[...e];const t=(n=this.container)==null?void 0:n.querySelector("[data-panel-list]");t&&this.renderItems(t,this.options.items)}getItems(){return[...this.options.items||[]]}addItem(e){var n;this.options.items.push(e);const t=(n=this.container)==null?void 0:n.querySelector("[data-panel-list]");t&&this.renderItems(t,this.options.items)}removeItem(e){var n;this.options.items=this.options.items.filter(s=>s.label!==e);const t=(n=this.container)==null?void 0:n.querySelector("[data-panel-list]");t&&this.renderItems(t,this.options.items)}updateItem(e,t,n){var i;const s=this.options.items.find(o=>o.label===e);if(s){s.value=t,n!==void 0&&(s.unit=n);const o=(i=this.container)==null?void 0:i.querySelector("[data-panel-list]");o&&this.renderItems(o,this.options.items)}}updateItemByCode(e,t){var s;const n=this.options.items.find(i=>i.code===e);if(n){n.value=t;const i=(s=this.container)==null?void 0:s.querySelector("[data-panel-list]");i&&this.renderItems(i,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 T.Vector3;this.attachedObject.getWorldPosition(t);const s=new T.Box3().setFromObject(this.attachedObject).max.y-t.y;this.css2dObject.position.set(0,s+e,0)}}getWidth(){return this.options.width||"200px"}getFontSize(){return this.options.fontSize||"13px"}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} + 2px)`)}}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}}const Ge=new WeakMap;function Gt(r,e){const t=l.toRaw(r);Ge.set(t,e),t.userData._hasDataPanel=!0}function Se(r){return Ge.get(l.toRaw(r))||null}function Ht(r){const e=l.toRaw(r),t=Ge.get(e);t&&(t.dispose(),Ge.delete(e)),e.userData._hasDataPanel=void 0}let P=null;function zt(r){return P?(P.domElement.parentNode!==r&&r.appendChild(P.domElement),P):(P=new hn,P.setSize(r.clientWidth,r.clientHeight),P.domElement.style.position="absolute",P.domElement.style.top="0",P.domElement.style.left="0",P.domElement.style.pointerEvents="none",r.appendChild(P.domElement),P)}function xn(){return P}function Kt(r,e){P&&P.render(r,e)}function Zt(r,e){P&&P.setSize(r,e)}function Xt(){P&&(P.domElement.parentNode&&P.domElement.parentNode.removeChild(P.domElement),P=null)}const y={mode:"",transformControlsMode:"translate",scene:null,camera:null,defaultMainCamera:null,renderer:null,orbitControls:null,transformControls:null,container:null,gridHelper:null,selectedObject:null};let Ve=!1,ae=!1,_=null,$=null;const vn=16755200,Rt=16755200;let it=[],Oe=[],He=!0,_e=[],ze=!0,re=null,ot=null,Fe=null,ee=[];const le=new Map;let Ke,Be=null,xe=null,ve=null;function qt(r,e="edit",t){y.container=r,y.mode=e,Sn(),wn(),Rn(),t&&(cs(t.scene,e,t.dataPanels),t!=null&&t.camera&&(y.defaultMainCamera=t.camera,ct(!0))),Nn(),kn(),Ke&&y.orbitControls&&(y.orbitControls.target.fromArray(Ke),y.orbitControls.update()),Tn(),Un(),Jt(),xe=n=>Dn(n),ve=()=>Ln(),e==="edit"&&r.addEventListener("click",xe),window.addEventListener("resize",ve),t||Pn(),e==="edit"&&En()}function Mn(){var i,o;const r=window.devicePixelRatio,e=((i=y.container)==null?void 0:i.clientWidth)||window.innerWidth,t=((o=y.container)==null?void 0:o.clientHeight)||window.innerHeight,n=e*r*t*r;let s;return n<=5e6?s=Math.min(r,2):n<=12e6?s=Math.min(r,1.5):n<=2e7?s=Math.min(r,1.3):s=Math.min(r,1),s}function Sn(){const r=Mn(),e=r>=1.5,t=new T.WebGLRenderer({antialias:e,alpha:!0});t.setSize(y.container.clientWidth,y.container.clientHeight),t.setPixelRatio(r),console.log(`[Renderer] css=${y.container.clientWidth}×${y.container.clientHeight}, dpr=${window.devicePixelRatio}, targetRatio=${r}, MSAA=${e}`),y.container.appendChild(t.domElement),y.renderer=t}function Tn(){if(!y.renderer||!y.scene||!y.camera)return;const r=new ln(y.renderer);r.addPass(new An(y.scene,y.camera)),r.addPass(new cn);const e=window.innerWidth*window.devicePixelRatio,t=window.innerWidth*window.devicePixelRatio*window.innerHeight*window.devicePixelRatio,s=e/1920,o=Math.round(4*Math.min(Math.max(s,.6),8)),A=t>25e6?1:t>12e6?1.5:2;console.log(`[OutlinePass] totalPx=${t}, downSample=${A}, dpr=${window.devicePixelRatio}, thickness=${o}`);const c=new Y(new T.Vector2(y.container.clientWidth,y.container.clientHeight),y.scene,y.camera);c.edgeStrength=8,c.edgeGlow=1.5,c.edgeThickness=o,c.visibleEdgeColor.set(Rt),c.hiddenEdgeColor.set(Rt),c.downSampleRatio=A,c.pulsePeriod=2,r.addPass(c),_=r,$=c}function wn(){y.scene=new T.Scene,y.scene.name="sl_scene",new T.TextureLoader().load(un,e=>{const t=new T.PMREMGenerator(y.renderer),n=t.fromEquirectangular(e).texture;y.scene.environment=n,t.dispose()},void 0,e=>console.error("背景图加载失败:",e))}function En(){const r=new T.GridHelper(30,30,8956671,3364232);r.name="地板",r.userData.type="initFloor",y.scene.add(r),y.gridHelper=r;const e=new T.PlaneGeometry(30,30),t=new T.ShadowMaterial({opacity:.3,color:0}),n=new T.Mesh(e,t);n.rotation.x=-Math.PI/2,n.position.y=-.01,n.name="阴影接收平面",n.userData.type="initFloor",n.receiveShadow=!0,y.scene.add(n)}function Rn(){const r=y.container,e=r.clientWidth/r.clientHeight,t=new T.PerspectiveCamera(45,e,.1,1e3);t.position.set(0,6,15),t.lookAt(0,0,0),y.camera=t}function ct(r=!1){if(!y.defaultMainCamera)return;const e=y.defaultMainCamera;if(r){y.camera.position.set(e.position[0],e.position[1],e.position[2]),y.camera.rotation.set(e.rotation[0],e.rotation[1],e.rotation[2]),y.camera.updateProjectionMatrix(),Ke=e.target;return}else ht(""),ut();if(!y.camera||!y.orbitControls)return;const t=y.camera.position.clone(),n=y.orbitControls.target.clone(),s=new T.Vector3(e.position[0],e.position[1],e.position[2]),i=e.target?new T.Vector3(e.target[0],e.target[1],e.target[2]):new T.Vector3(0,0,0);y.orbitControls.enabled=!1,new Me.Tween({x:t.x,y:t.y,z:t.z,tx:n.x,ty:n.y,tz:n.z}).to({x:s.x,y:s.y,z:s.z,tx:i.x,ty:i.y,tz:i.z},1e3).easing(Me.Easing.Quadratic.InOut).onUpdate(o=>{y.camera.position.set(o.x,o.y,o.z),y.orbitControls.target.set(o.tx,o.ty,o.tz),y.orbitControls.update()}).onComplete(()=>{Ke=e.target,y.orbitControls.enabled=!0}).start()}function kn(){const r=new Ds(y.camera,y.renderer.domElement);r.minDistance=0,r.maxDistance=1/0,r.addEventListener("start",()=>{Ve=!1}),r.addEventListener("change",()=>{Ve=!0}),r.addEventListener("end",()=>{Ve&&(ae=!0,setTimeout(()=>{ae=!1},200))}),y.orbitControls=r}function Nn(){const r=new Xs(y.camera,y.renderer.domElement);r.addEventListener("dragging-changed",e=>{y.orbitControls.enabled=!e.value,e.value||(ae=!0,setTimeout(()=>{ae=!1},200))}),r.addEventListener("objectChange",()=>{const e=y.selectedObject;if(ot&&e&&ot(e),e&&e.type==="DirectionalLight"){const t=e.userData.helper;t&&t.update&&t.update()}}),y.scene.add(r.getHelper()),y.transformControls=r}function Pn(){const r=new T.AmbientLight(16777215,1);y.scene.add(r)}function Jt(){var e,t;Be=requestAnimationFrame(Jt),Me.update(),(e=y.orbitControls)==null||e.update(),y.mode==="run"&&_&&y.scene&&y.camera?_.render():(t=y.renderer)==null||t.render(y.scene,y.camera),y.scene&&y.camera&&Kt(y.scene,y.camera),He&&y.scene&&(Oe=[],y.scene.traverse(n=>{n.userData.isWater&&n.type==="Mesh"&&Oe.push(n)}),He=!1);for(let n=0;n<Oe.length;n++){const s=Oe[n],i=s.material;if(i.normalMap){const o=s.userData.waterSpeed||{x:.005,y:.003};i.normalMap.offset.x+=o.x,i.normalMap.offset.y+=o.y}}}function Ln(){if(!y.container||!y.camera||!y.renderer)return;const r=y.container.clientWidth,e=y.container.clientHeight;r===0||e===0||(y.camera.aspect=r/e,y.camera.updateProjectionMatrix(),y.renderer.setSize(r,e),_&&_.setSize(r,e),$&&$.resolution.set(r,e),Zt(r,e))}function Ze(r){y.selectedObject!==r&&(y.selectedObject&&y.transformControls.detach(),y.selectedObject=r,y.transformControls.attach(r),y.transformControls.setMode(y.transformControlsMode),y.transformControls.showX=!0,y.transformControls.showY=!0,y.transformControls.showZ=!0,_t(r),console.log("选中",y.selectedObject),re==null||re(r))}let B=null;function Qt(r){B=r}function Ue(r){B==null||B(r)}function Yt(r){y.transformControlsMode=r,y.transformControls&&y.transformControls.setMode(y.transformControlsMode)}function _t(r){if(y.mode==="edit")ut(),r.traverse(t=>{if(t.isMesh){const n=t,s=new T.EdgesGeometry(n.geometry),i=new T.LineBasicMaterial({color:vn,depthTest:!0}),o=new T.LineSegments(s,i);t.add(o),it.push(o)}});else{if(!$)return;const t=[];r.traverse(n=>{n.isMesh&&t.push(n)}),$.selectedObjects=t}}function ut(){if(y.mode==="edit"){for(const r of it)r.parent&&r.parent.remove(r),r.geometry.dispose(),r.material.dispose();it=[]}else $&&($.selectedObjects=[])}function dt(){y.selectedObject&&(ut(),y.transformControls.detach(),y.selectedObject=null,re==null||re(null))}function ht(r){let e=null;le.forEach(t=>{t.userData.id==r&&(e=t),t.children&&t.children.forEach(n=>{n.name&&n.name.startsWith("DataPanel_")&&(n.visible=!1)})}),e&&(e.children.forEach(t=>{t.name&&t.name.startsWith("DataPanel_")&&(t.visible=!0)}),_t(e),$t(e))}function Dn(r){if(ae){ae=!1;return}const e=y.renderer.domElement.getBoundingClientRect(),t=new T.Vector2((r.clientX-e.left)/e.width*2-1,-((r.clientY-e.top)/e.height)*2+1),n=new T.Raycaster;n.setFromCamera(t,y.camera),ze&&y.scene&&(_e=[],y.scene.traverse(i=>{(i.userData.isMovable||i.userData.type==="lightHelper")&&_e.push(i)}),ze=!1);const s=n.intersectObjects(_e);if(s.length>0){let i=On(s[0].object);Ze(i)}else dt()}function On(r){if(r.type==="Line"||r.type==="LineSegments"){const e=r.parent;if(e)switch(e.type){case"DirectionalLightHelper":return e.light;default:return e.isMesh?e:r}return r}return r}function $t(r,e=500){if(!y.camera||!y.orbitControls){console.warn("[focusOnObject] 编辑器尚未初始化或已销毁,无法执行聚焦操作。请确保已调用 initEditor()");return}if(!r){console.warn("[focusOnObject] 传入的物体为空,无法执行聚焦操作。");return}let t=null;r.userData.closeUpView&&typeof r.userData.closeUpView.x=="number"&&typeof r.userData.closeUpView.y=="number"&&typeof r.userData.closeUpView.z=="number"&&(t=r.userData.closeUpView);const n=new T.Vector3;r.getWorldPosition(n);const i=new T.Box3().setFromObject(r).getSize(new T.Vector3),o=Math.max(i.x,i.y,i.z)*.5,A=Math.max(o*3.5,5),c=new T.Vector3().copy(y.camera.position).sub(n).normalize();c.lengthSq()<.001&&c.set(0,0,1);const u=n.clone().add(c.multiplyScalar(A)),h=y.camera.position.clone(),d=y.orbitControls.target.clone();try{new Me.Tween({x:h.x,y:h.y,z:h.z,tx:d.x,ty:d.y,tz:d.z}).to({x:t?t.x:u.x,y:t?t.y:u.y,z:t?t.z:u.z,tx:n.x,ty:n.y,tz:n.z},e).easing(Me.Easing.Quadratic.InOut).onUpdate(p=>{y.camera.position.set(p.x,p.y,p.z),y.orbitControls.target.set(p.tx,p.ty,p.tz),y.orbitControls.update()}).start()}catch(p){console.error("[focusOnObject] TWEEN 动画创建失败,请检查 @tweenjs/tween.js 是否已正确安装且版本兼容(^23.1.3):",p)}}function Wn(r){r.userData.id&&le.set(String(r.userData.id),r)}function jn(r){r.userData.id&&le.delete(String(r.userData.id))}function es(r,e){const t=e||r.userData.id;if(t)le.set(String(t),r);else{const n=T.MathUtils.generateUUID();r.userData.id=n,le.set(n,r)}}function Vn(r){r.traverse(e=>{if(e.name&&e.name.startsWith("DataPanel_")){const t=e;t.element&&t.element.parentNode&&t.element.parentNode.removeChild(t.element)}})}function Ae(r,e=!1){y.scene.add(r),He=!0,ze=!0,r.userData.isMovable&&(Fn(r),Xe()),e&&y.mode==="edit"&&Ze(r)}function ts(r){y.selectedObject===r&&dt(),He=!0,ze=!0,Vn(r),jn(r),r.userData.helper&&y.scene.remove(r.userData.helper),r.parent?r.parent.remove(r):y.scene.remove(r),Bn(r),Xe()}function ss(r){const e=y.scene.getObjectByProperty("uuid",r);e&&ts(e)}function Fn(r){r.userData.isMovable&&r.parent===y.scene&&(ee.includes(r)||ee.push(r))}function Bn(r){const e=ee.indexOf(r);e!==-1&&ee.splice(e,1)}function Un(){const r=[];y.scene.children.forEach(e=>{e.userData.isMovable&&r.push(e)}),ee=r,Xe()}function Xe(){Fe==null||Fe([...ee])}function ns(r){re=r}function is(r){ot=r}function os(r){Fe=r}function rs(){return ee}function as(){return y.selectedObject}function Gn(r,e,t){if(!y.scene)return;const n=le.get(r);if(n){const s=Se(n);s&&s.updateItemByCode(e,t)}}function Hn(){return y.scene}function ls(){return y.camera}function zn(){return y.renderer}async function As(){var u,h,d;B==null||B(!0),await new Promise(p=>setTimeout(p,50)),dt();const r=y.scene;if(!r)return B==null||B(!1),"{}";const e=[],t=new Map,n=new Map;r.traverse(p=>{var f;if(p.userData.type==="lightHelper"&&e.push(p),p.type==="DirectionalLight"&&p.userData.helper&&(t.set(p,p.userData.helper),p.userData.helper=void 0),p.name&&p.name.startsWith("DataPanel_")){const C=p;if(C.element){const m=C.element.querySelector("[data-panel-title]"),b=[];if(C.element.querySelectorAll(".sl-css2d-data-panel-item").forEach(I=>{var M,S,E;const v=I.querySelector(".item-label"),x=I.querySelector(".item-value");if(v&&x){const V=(v.textContent||"").trim(),U=((S=(M=x.childNodes[0])==null?void 0:M.textContent)==null?void 0:S.trim())||"",F=x.querySelector("span"),se=F?(F.textContent||"").trim():void 0,qe=((E=I.getAttribute("data-item-code"))==null?void 0:E.trim())||void 0;b.push({label:V,value:U,unit:se,code:qe})}}),p.parent){const I=C.element.style.width||"",v=C.element.style.fontSize||"",x=Se(p.parent),M=x?x.getOffsetY():.1;n.set(p.parent.userData.id?p.parent.userData.id:p.parent.uuid,{title:((f=m==null?void 0:m.textContent)==null?void 0:f.trim())||"",items:b,width:I,fontSize:v,offsetY:M})}}}}),e.forEach(p=>r.remove(p));const s=r.clone();s.children=s.children.filter(p=>p.userData.type!=="initFloor"),s.traverse(p=>{p.name&&p.name.startsWith("DataPanel_")&&p.parent&&p.parent.remove(p)});const i=s.toJSON();e.forEach(p=>r.add(p)),t.forEach((p,f)=>{f.userData.helper=p});const o={position:(u=y.camera)==null?void 0:u.position.toArray(),rotation:(h=y.camera)==null?void 0:h.rotation.toArray(),target:((d=y.orbitControls)==null?void 0:d.target.toArray())||[0,0,0]},A={};n.forEach((p,f)=>{A[f]=p});const c=JSON.stringify({scene:i,camera:o,dataPanels:A});return B==null||B(!1),c}function cs(r,e="edit",t){var o,A,c;const n=typeof r=="string"?JSON.parse(r):r,i=new T.ObjectLoader().parse(n);i.type==="Scene"?y.scene=i:(o=y.scene)==null||o.add(i),t&&((A=y.scene)==null||A.traverse(u=>{const h=u.userData.id||u.uuid,d=t[h];if(d&&u.userData.isMovable){Wn(u);const p=new fe({title:d.title,items:d.items});p.attachTo(u),p.visible=!1,d.width&&p.setWidth(d.width),d.fontSize&&p.setFontSize(d.fontSize),d.offsetY!==void 0&&p.setOffsetY(d.offsetY),Gt(u,p)}})),e==="edit"&&((c=y.scene)==null||c.traverse(u=>{var h;if(u.type==="DirectionalLight"){const d=u;if(!d.userData.helper){const p=new T.DirectionalLightHelper(d,1);p.userData.type="lightHelper",d.userData.helper=p,(h=y.scene)==null||h.add(p)}}}))}function us(r){if(!r)return;if(r.type==="Mesh"){const t=r;t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material:[t.material]).forEach(s=>{s.map&&(s.map=null),s.lightMap&&(s.lightMap=null),s.aoMap&&(s.aoMap=null),s.emissiveMap&&(s.emissiveMap=null),s.bumpMap&&(s.bumpMap=null),s.normalMap&&(s.normalMap=null),s.displacementMap&&(s.displacementMap=null),s.roughnessMap&&(s.roughnessMap=null),s.metalnessMap&&(s.metalnessMap=null),s.alphaMap&&(s.alphaMap=null),s.envMap&&(s.envMap=null),s.dispose()})}const e=r.children.slice();for(const t of e)us(t)}function ds(){Be!==null&&(cancelAnimationFrame(Be),Be=null),xe&&y.container&&(y.container.removeEventListener("click",xe),xe=null),ve&&(window.removeEventListener("resize",ve),ve=null),y.orbitControls&&(y.orbitControls.dispose(),y.orbitControls=null),y.transformControls&&(y.transformControls.dispose(),y.transformControls=null),_&&(_.dispose(),_=null,$=null),y.scene&&(us(y.scene),y.scene=null),y.renderer&&(y.renderer.dispose(),y.renderer.domElement&&y.container&&y.container.removeChild(y.renderer.domElement),y.renderer=null),Xt(),y.camera=null,y.gridHelper=null,y.selectedObject=null,y.container=null,y.mode="",ee=[],le.clear(),Xe(),Ve=!1,ae=!1}const Kn=/^[og]\s*(.+)?/,Zn=/^mtllib /,Xn=/^usemtl /,qn=/^usemap /,kt=/\s+/,Nt=new a.Vector3,$e=new a.Vector3,Pt=new a.Vector3,Lt=new a.Vector3,H=new a.Vector3,We=new a.Color;function Jn(){const r={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 n=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(s,i){const o=this._finalize(!1);o&&(o.inherited||o.groupCount<=0)&&this.materials.splice(o.index,1);const A={index:this.materials.length,name:s||"",mtllib:Array.isArray(i)&&i.length>0?i[i.length-1]:"",smooth:o!==void 0?o.smooth:this.smooth,groupStart:o!==void 0?o.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(c){const u={index:typeof c=="number"?c:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return u.clone=this.clone.bind(u),u}};return this.materials.push(A),A},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(s){const i=this.currentMaterial();if(i&&i.groupEnd===-1&&(i.groupEnd=this.geometry.vertices.length/3,i.groupCount=i.groupEnd-i.groupStart,i.inherited=!1),s&&this.materials.length>1)for(let o=this.materials.length-1;o>=0;o--)this.materials[o].groupCount<=0&&this.materials.splice(o,1);return s&&this.materials.length===0&&this.materials.push({name:"",smooth:this.smooth}),i}},n&&n.name&&typeof n.clone=="function"){const s=n.clone(0);s.inherited=!0,this.object.materials.push(s)}this.objects.push(this.object)},finalize:function(){this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0)},parseVertexIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseNormalIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseUVIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/2)*2},addVertex:function(e,t,n){const s=this.vertices,i=this.object.geometry.vertices;i.push(s[e+0],s[e+1],s[e+2]),i.push(s[t+0],s[t+1],s[t+2]),i.push(s[n+0],s[n+1],s[n+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,n){const s=this.normals,i=this.object.geometry.normals;i.push(s[e+0],s[e+1],s[e+2]),i.push(s[t+0],s[t+1],s[t+2]),i.push(s[n+0],s[n+1],s[n+2])},addFaceNormal:function(e,t,n){const s=this.vertices,i=this.object.geometry.normals;Nt.fromArray(s,e),$e.fromArray(s,t),Pt.fromArray(s,n),H.subVectors(Pt,$e),Lt.subVectors(Nt,$e),H.cross(Lt),H.normalize(),i.push(H.x,H.y,H.z),i.push(H.x,H.y,H.z),i.push(H.x,H.y,H.z)},addColor:function(e,t,n){const s=this.colors,i=this.object.geometry.colors;s[e]!==void 0&&i.push(s[e+0],s[e+1],s[e+2]),s[t]!==void 0&&i.push(s[t+0],s[t+1],s[t+2]),s[n]!==void 0&&i.push(s[n+0],s[n+1],s[n+2])},addUV:function(e,t,n){const s=this.uvs,i=this.object.geometry.uvs;i.push(s[e+0],s[e+1]),i.push(s[t+0],s[t+1]),i.push(s[n+0],s[n+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,n,s,i,o,A,c,u){const h=this.vertices.length;let d=this.parseVertexIndex(e,h),p=this.parseVertexIndex(t,h),f=this.parseVertexIndex(n,h);if(this.addVertex(d,p,f),this.addColor(d,p,f),A!==void 0&&A!==""){const C=this.normals.length;d=this.parseNormalIndex(A,C),p=this.parseNormalIndex(c,C),f=this.parseNormalIndex(u,C),this.addNormal(d,p,f)}else this.addFaceNormal(d,p,f);if(s!==void 0&&s!==""){const C=this.uvs.length;d=this.parseUVIndex(s,C),p=this.parseUVIndex(i,C),f=this.parseUVIndex(o,C),this.addUV(d,p,f),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type="Points";const t=this.vertices.length;for(let n=0,s=e.length;n<s;n++){const i=this.parseVertexIndex(e[n],t);this.addVertexPoint(i),this.addColor(i)}},addLineGeometry:function(e,t){this.object.geometry.type="Line";const n=this.vertices.length,s=this.uvs.length;for(let i=0,o=e.length;i<o;i++)this.addVertexLine(this.parseVertexIndex(e[i],n));for(let i=0,o=t.length;i<o;i++)this.addUVLine(this.parseUVIndex(t[i],s))}};return r.startObject("",!1),r}class Qn extends a.Loader{constructor(e){super(e),this.materials=null}load(e,t,n,s){const i=this,o=new a.FileLoader(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(A){try{t(i.parse(A))}catch(c){s?s(c):console.error(c),i.manager.itemError(e)}},n,s)}setMaterials(e){return this.materials=e,this}parse(e){const t=new Jn;e.indexOf(`\r
269
+ `,e.appendChild(i)})}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 T.Vector3;e.getWorldPosition(t);const n=new T.Box3().setFromObject(e),s=new T.Vector3,i=new T.Vector3;n.getCenter(s),n.getSize(i);const A=n.max.y-t.y+this.options.offsetY;this.css2dObject||(this.css2dObject=new dn(this.container),this.css2dObject.name=`DataPanel_${e.name||e.uuid}`,this.css2dObject.center.set(.5,1)),this.css2dObject.position.set(0,A,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 n;this.options.title=e;const t=(n=this.container)==null?void 0:n.querySelector("[data-panel-title]");e?t?t.textContent=e:this.rebuildPanel():t&&t.remove()}getTitle(){return this.options.title||""}setItems(e){var n;this.options.items=[...e];const t=(n=this.container)==null?void 0:n.querySelector("[data-panel-list]");t&&this.renderItems(t,this.options.items)}getItems(){return[...this.options.items||[]]}addItem(e){var n;this.options.items.push(e);const t=(n=this.container)==null?void 0:n.querySelector("[data-panel-list]");t&&this.renderItems(t,this.options.items)}removeItem(e){var n;this.options.items=this.options.items.filter(s=>s.label!==e);const t=(n=this.container)==null?void 0:n.querySelector("[data-panel-list]");t&&this.renderItems(t,this.options.items)}updateItem(e,t,n){var i;const s=this.options.items.find(o=>o.label===e);if(s){s.value=t,n!==void 0&&(s.unit=n);const o=(i=this.container)==null?void 0:i.querySelector("[data-panel-list]");o&&this.renderItems(o,this.options.items)}}updateItemByCode(e,t){var s;const n=this.options.items.find(i=>i.code===e);if(n){n.value=t;const i=(s=this.container)==null?void 0:s.querySelector("[data-panel-list]");i&&this.renderItems(i,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 T.Vector3;this.attachedObject.getWorldPosition(t);const s=new T.Box3().setFromObject(this.attachedObject).max.y-t.y;this.css2dObject.position.set(0,s+e,0)}}getWidth(){return this.options.width||"200px"}getFontSize(){return this.options.fontSize||"13px"}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} + 2px)`)}}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}}const Ge=new WeakMap;function Gt(r,e){const t=l.toRaw(r);Ge.set(t,e),t.userData._hasDataPanel=!0}function Se(r){return Ge.get(l.toRaw(r))||null}function Ht(r){const e=l.toRaw(r),t=Ge.get(e);t&&(t.dispose(),Ge.delete(e)),e.userData._hasDataPanel=void 0}let P=null;function zt(r){return P?(P.domElement.parentNode!==r&&r.appendChild(P.domElement),P):(P=new hn,P.setSize(r.clientWidth,r.clientHeight),P.domElement.style.position="absolute",P.domElement.style.top="0",P.domElement.style.left="0",P.domElement.style.pointerEvents="none",r.appendChild(P.domElement),P)}function xn(){return P}function Kt(r,e){P&&P.render(r,e)}function Zt(r,e){P&&P.setSize(r,e)}function Xt(){P&&(P.domElement.parentNode&&P.domElement.parentNode.removeChild(P.domElement),P=null)}const y={mode:"",transformControlsMode:"translate",scene:null,camera:null,defaultMainCamera:null,renderer:null,orbitControls:null,transformControls:null,container:null,gridHelper:null,selectedObject:null};let Ve=!1,ae=!1,_=null,$=null;const vn=16755200,Rt=16755200;let it=[],Oe=[],He=!0,_e=[],ze=!0,re=null,ot=null,Fe=null,ee=[];const le=new Map;let Ke,Be=null,xe=null,ve=null;function qt(r,e="edit",t){y.container=r,y.mode=e,Sn(),wn(),Rn(),t&&(cs(t.scene,e,t.dataPanels),t!=null&&t.camera&&(y.defaultMainCamera=t.camera,ct(!0))),Nn(),kn(),Ke&&y.orbitControls&&(y.orbitControls.target.fromArray(Ke),y.orbitControls.update()),Tn(),Un(),Jt(),xe=n=>Dn(n),ve=()=>Ln(),e==="edit"&&r.addEventListener("click",xe),window.addEventListener("resize",ve),t||Pn(),e==="edit"&&En()}function Mn(){var i,o;const r=window.devicePixelRatio,e=((i=y.container)==null?void 0:i.clientWidth)||window.innerWidth,t=((o=y.container)==null?void 0:o.clientHeight)||window.innerHeight,n=e*r*t*r;let s;return n<=5e6?s=Math.min(r,2):n<=12e6?s=Math.min(r,1.5):n<=2e7?s=Math.min(r,1.3):s=Math.min(r,1),s}function Sn(){const r=Mn(),e=new T.WebGLRenderer({antialias:!0,alpha:!0});e.setSize(y.container.clientWidth,y.container.clientHeight),e.setPixelRatio(r),console.log(`[Renderer] css=${y.container.clientWidth}×${y.container.clientHeight}, dpr=${window.devicePixelRatio}, targetRatio=${r}, antialias=true`),y.container.appendChild(e.domElement),y.renderer=e}function Tn(){if(!y.renderer||!y.scene||!y.camera)return;const r=new ln(y.renderer);r.addPass(new An(y.scene,y.camera)),r.addPass(new cn);const e=window.innerWidth*window.devicePixelRatio,t=window.innerWidth*window.devicePixelRatio*window.innerHeight*window.devicePixelRatio,s=e/1920,o=Math.round(4*Math.min(Math.max(s,.6),8)),A=t>25e6?1:t>12e6?1.5:2;console.log(`[OutlinePass] totalPx=${t}, downSample=${A}, dpr=${window.devicePixelRatio}, thickness=${o}`);const c=new Y(new T.Vector2(y.container.clientWidth,y.container.clientHeight),y.scene,y.camera);c.edgeStrength=8,c.edgeGlow=1.5,c.edgeThickness=o,c.visibleEdgeColor.set(Rt),c.hiddenEdgeColor.set(Rt),c.downSampleRatio=A,c.pulsePeriod=2,r.addPass(c),_=r,$=c}function wn(){y.scene=new T.Scene,y.scene.name="sl_scene",new T.TextureLoader().load(un,e=>{const t=new T.PMREMGenerator(y.renderer),n=t.fromEquirectangular(e).texture;y.scene.environment=n,t.dispose()},void 0,e=>console.error("背景图加载失败:",e))}function En(){const r=new T.GridHelper(30,30,8956671,3364232);r.name="地板",r.userData.type="initFloor",y.scene.add(r),y.gridHelper=r;const e=new T.PlaneGeometry(30,30),t=new T.ShadowMaterial({opacity:.3,color:0}),n=new T.Mesh(e,t);n.rotation.x=-Math.PI/2,n.position.y=-.01,n.name="阴影接收平面",n.userData.type="initFloor",n.receiveShadow=!0,y.scene.add(n)}function Rn(){const r=y.container,e=r.clientWidth/r.clientHeight,t=new T.PerspectiveCamera(45,e,.1,1e3);t.position.set(0,6,15),t.lookAt(0,0,0),y.camera=t}function ct(r=!1){if(!y.defaultMainCamera)return;const e=y.defaultMainCamera;if(r){y.camera.position.set(e.position[0],e.position[1],e.position[2]),y.camera.rotation.set(e.rotation[0],e.rotation[1],e.rotation[2]),y.camera.updateProjectionMatrix(),Ke=e.target;return}else ht(""),ut();if(!y.camera||!y.orbitControls)return;const t=y.camera.position.clone(),n=y.orbitControls.target.clone(),s=new T.Vector3(e.position[0],e.position[1],e.position[2]),i=e.target?new T.Vector3(e.target[0],e.target[1],e.target[2]):new T.Vector3(0,0,0);y.orbitControls.enabled=!1,new Me.Tween({x:t.x,y:t.y,z:t.z,tx:n.x,ty:n.y,tz:n.z}).to({x:s.x,y:s.y,z:s.z,tx:i.x,ty:i.y,tz:i.z},1e3).easing(Me.Easing.Quadratic.InOut).onUpdate(o=>{y.camera.position.set(o.x,o.y,o.z),y.orbitControls.target.set(o.tx,o.ty,o.tz),y.orbitControls.update()}).onComplete(()=>{Ke=e.target,y.orbitControls.enabled=!0}).start()}function kn(){const r=new Ds(y.camera,y.renderer.domElement);r.minDistance=0,r.maxDistance=1/0,r.addEventListener("start",()=>{Ve=!1}),r.addEventListener("change",()=>{Ve=!0}),r.addEventListener("end",()=>{Ve&&(ae=!0,setTimeout(()=>{ae=!1},200))}),y.orbitControls=r}function Nn(){const r=new Xs(y.camera,y.renderer.domElement);r.addEventListener("dragging-changed",e=>{y.orbitControls.enabled=!e.value,e.value||(ae=!0,setTimeout(()=>{ae=!1},200))}),r.addEventListener("objectChange",()=>{const e=y.selectedObject;if(ot&&e&&ot(e),e&&e.type==="DirectionalLight"){const t=e.userData.helper;t&&t.update&&t.update()}}),y.scene.add(r.getHelper()),y.transformControls=r}function Pn(){const r=new T.AmbientLight(16777215,1);y.scene.add(r)}function Jt(){var e,t;Be=requestAnimationFrame(Jt),Me.update(),(e=y.orbitControls)==null||e.update(),y.mode==="run"&&_&&y.scene&&y.camera?_.render():(t=y.renderer)==null||t.render(y.scene,y.camera),y.scene&&y.camera&&Kt(y.scene,y.camera),He&&y.scene&&(Oe=[],y.scene.traverse(n=>{n.userData.isWater&&n.type==="Mesh"&&Oe.push(n)}),He=!1);for(let n=0;n<Oe.length;n++){const s=Oe[n],i=s.material;if(i.normalMap){const o=s.userData.waterSpeed||{x:.005,y:.003};i.normalMap.offset.x+=o.x,i.normalMap.offset.y+=o.y}}}function Ln(){if(!y.container||!y.camera||!y.renderer)return;const r=y.container.clientWidth,e=y.container.clientHeight;r===0||e===0||(y.camera.aspect=r/e,y.camera.updateProjectionMatrix(),y.renderer.setSize(r,e),_&&_.setSize(r,e),$&&$.resolution.set(r,e),Zt(r,e))}function Ze(r){y.selectedObject!==r&&(y.selectedObject&&y.transformControls.detach(),y.selectedObject=r,y.transformControls.attach(r),y.transformControls.setMode(y.transformControlsMode),y.transformControls.showX=!0,y.transformControls.showY=!0,y.transformControls.showZ=!0,_t(r),console.log("选中",y.selectedObject),re==null||re(r))}let B=null;function Qt(r){B=r}function Ue(r){B==null||B(r)}function Yt(r){y.transformControlsMode=r,y.transformControls&&y.transformControls.setMode(y.transformControlsMode)}function _t(r){if(y.mode==="edit")ut(),r.traverse(t=>{if(t.isMesh){const n=t,s=new T.EdgesGeometry(n.geometry),i=new T.LineBasicMaterial({color:vn,depthTest:!0}),o=new T.LineSegments(s,i);t.add(o),it.push(o)}});else{if(!$)return;const t=[];r.traverse(n=>{n.isMesh&&t.push(n)}),$.selectedObjects=t}}function ut(){if(y.mode==="edit"){for(const r of it)r.parent&&r.parent.remove(r),r.geometry.dispose(),r.material.dispose();it=[]}else $&&($.selectedObjects=[])}function dt(){y.selectedObject&&(ut(),y.transformControls.detach(),y.selectedObject=null,re==null||re(null))}function ht(r){let e=null;le.forEach(t=>{t.userData.id==r&&(e=t),t.children&&t.children.forEach(n=>{n.name&&n.name.startsWith("DataPanel_")&&(n.visible=!1)})}),e&&(e.children.forEach(t=>{t.name&&t.name.startsWith("DataPanel_")&&(t.visible=!0)}),_t(e),$t(e))}function Dn(r){if(ae){ae=!1;return}const e=y.renderer.domElement.getBoundingClientRect(),t=new T.Vector2((r.clientX-e.left)/e.width*2-1,-((r.clientY-e.top)/e.height)*2+1),n=new T.Raycaster;n.setFromCamera(t,y.camera),ze&&y.scene&&(_e=[],y.scene.traverse(i=>{(i.userData.isMovable||i.userData.type==="lightHelper")&&_e.push(i)}),ze=!1);const s=n.intersectObjects(_e);if(s.length>0){let i=On(s[0].object);Ze(i)}else dt()}function On(r){if(r.type==="Line"||r.type==="LineSegments"){const e=r.parent;if(e)switch(e.type){case"DirectionalLightHelper":return e.light;default:return e.isMesh?e:r}return r}return r}function $t(r,e=500){if(!y.camera||!y.orbitControls){console.warn("[focusOnObject] 编辑器尚未初始化或已销毁,无法执行聚焦操作。请确保已调用 initEditor()");return}if(!r){console.warn("[focusOnObject] 传入的物体为空,无法执行聚焦操作。");return}let t=null;r.userData.closeUpView&&typeof r.userData.closeUpView.x=="number"&&typeof r.userData.closeUpView.y=="number"&&typeof r.userData.closeUpView.z=="number"&&(t=r.userData.closeUpView);const n=new T.Vector3;r.getWorldPosition(n);const i=new T.Box3().setFromObject(r).getSize(new T.Vector3),o=Math.max(i.x,i.y,i.z)*.5,A=Math.max(o*3.5,5),c=new T.Vector3().copy(y.camera.position).sub(n).normalize();c.lengthSq()<.001&&c.set(0,0,1);const u=n.clone().add(c.multiplyScalar(A)),h=y.camera.position.clone(),d=y.orbitControls.target.clone();try{new Me.Tween({x:h.x,y:h.y,z:h.z,tx:d.x,ty:d.y,tz:d.z}).to({x:t?t.x:u.x,y:t?t.y:u.y,z:t?t.z:u.z,tx:n.x,ty:n.y,tz:n.z},e).easing(Me.Easing.Quadratic.InOut).onUpdate(p=>{y.camera.position.set(p.x,p.y,p.z),y.orbitControls.target.set(p.tx,p.ty,p.tz),y.orbitControls.update()}).start()}catch(p){console.error("[focusOnObject] TWEEN 动画创建失败,请检查 @tweenjs/tween.js 是否已正确安装且版本兼容(^23.1.3):",p)}}function Wn(r){r.userData.id&&le.set(String(r.userData.id),r)}function jn(r){r.userData.id&&le.delete(String(r.userData.id))}function es(r,e){const t=e||r.userData.id;if(t)le.set(String(t),r);else{const n=T.MathUtils.generateUUID();r.userData.id=n,le.set(n,r)}}function Vn(r){r.traverse(e=>{if(e.name&&e.name.startsWith("DataPanel_")){const t=e;t.element&&t.element.parentNode&&t.element.parentNode.removeChild(t.element)}})}function Ae(r,e=!1){y.scene.add(r),He=!0,ze=!0,r.userData.isMovable&&(Fn(r),Xe()),e&&y.mode==="edit"&&Ze(r)}function ts(r){y.selectedObject===r&&dt(),He=!0,ze=!0,Vn(r),jn(r),r.userData.helper&&y.scene.remove(r.userData.helper),r.parent?r.parent.remove(r):y.scene.remove(r),Bn(r),Xe()}function ss(r){const e=y.scene.getObjectByProperty("uuid",r);e&&ts(e)}function Fn(r){r.userData.isMovable&&r.parent===y.scene&&(ee.includes(r)||ee.push(r))}function Bn(r){const e=ee.indexOf(r);e!==-1&&ee.splice(e,1)}function Un(){const r=[];y.scene.children.forEach(e=>{e.userData.isMovable&&r.push(e)}),ee=r,Xe()}function Xe(){Fe==null||Fe([...ee])}function ns(r){re=r}function is(r){ot=r}function os(r){Fe=r}function rs(){return ee}function as(){return y.selectedObject}function Gn(r,e,t){if(!y.scene)return;const n=le.get(r);if(n){const s=Se(n);s&&s.updateItemByCode(e,t)}}function Hn(){return y.scene}function ls(){return y.camera}function zn(){return y.renderer}async function As(){var u,h,d;B==null||B(!0),await new Promise(p=>setTimeout(p,50)),dt();const r=y.scene;if(!r)return B==null||B(!1),"{}";const e=[],t=new Map,n=new Map;r.traverse(p=>{var f;if(p.userData.type==="lightHelper"&&e.push(p),p.type==="DirectionalLight"&&p.userData.helper&&(t.set(p,p.userData.helper),p.userData.helper=void 0),p.name&&p.name.startsWith("DataPanel_")){const C=p;if(C.element){const m=C.element.querySelector("[data-panel-title]"),b=[];if(C.element.querySelectorAll(".sl-css2d-data-panel-item").forEach(I=>{var M,S,E;const v=I.querySelector(".item-label"),x=I.querySelector(".item-value");if(v&&x){const V=(v.textContent||"").trim(),U=((S=(M=x.childNodes[0])==null?void 0:M.textContent)==null?void 0:S.trim())||"",F=x.querySelector("span"),se=F?(F.textContent||"").trim():void 0,qe=((E=I.getAttribute("data-item-code"))==null?void 0:E.trim())||void 0;b.push({label:V,value:U,unit:se,code:qe})}}),p.parent){const I=C.element.style.width||"",v=C.element.style.fontSize||"",x=Se(p.parent),M=x?x.getOffsetY():.1;n.set(p.parent.userData.id?p.parent.userData.id:p.parent.uuid,{title:((f=m==null?void 0:m.textContent)==null?void 0:f.trim())||"",items:b,width:I,fontSize:v,offsetY:M})}}}}),e.forEach(p=>r.remove(p));const s=r.clone();s.children=s.children.filter(p=>p.userData.type!=="initFloor"),s.traverse(p=>{p.name&&p.name.startsWith("DataPanel_")&&p.parent&&p.parent.remove(p)});const i=s.toJSON();e.forEach(p=>r.add(p)),t.forEach((p,f)=>{f.userData.helper=p});const o={position:(u=y.camera)==null?void 0:u.position.toArray(),rotation:(h=y.camera)==null?void 0:h.rotation.toArray(),target:((d=y.orbitControls)==null?void 0:d.target.toArray())||[0,0,0]},A={};n.forEach((p,f)=>{A[f]=p});const c=JSON.stringify({scene:i,camera:o,dataPanels:A});return B==null||B(!1),c}function cs(r,e="edit",t){var o,A,c;const n=typeof r=="string"?JSON.parse(r):r,i=new T.ObjectLoader().parse(n);i.type==="Scene"?y.scene=i:(o=y.scene)==null||o.add(i),t&&((A=y.scene)==null||A.traverse(u=>{const h=u.userData.id||u.uuid,d=t[h];if(d&&u.userData.isMovable){Wn(u);const p=new fe({title:d.title,items:d.items});p.attachTo(u),p.visible=!1,d.width&&p.setWidth(d.width),d.fontSize&&p.setFontSize(d.fontSize),d.offsetY!==void 0&&p.setOffsetY(d.offsetY),Gt(u,p)}})),e==="edit"&&((c=y.scene)==null||c.traverse(u=>{var h;if(u.type==="DirectionalLight"){const d=u;if(!d.userData.helper){const p=new T.DirectionalLightHelper(d,1);p.userData.type="lightHelper",d.userData.helper=p,(h=y.scene)==null||h.add(p)}}}))}function us(r){if(!r)return;if(r.type==="Mesh"){const t=r;t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material:[t.material]).forEach(s=>{s.map&&(s.map=null),s.lightMap&&(s.lightMap=null),s.aoMap&&(s.aoMap=null),s.emissiveMap&&(s.emissiveMap=null),s.bumpMap&&(s.bumpMap=null),s.normalMap&&(s.normalMap=null),s.displacementMap&&(s.displacementMap=null),s.roughnessMap&&(s.roughnessMap=null),s.metalnessMap&&(s.metalnessMap=null),s.alphaMap&&(s.alphaMap=null),s.envMap&&(s.envMap=null),s.dispose()})}const e=r.children.slice();for(const t of e)us(t)}function ds(){Be!==null&&(cancelAnimationFrame(Be),Be=null),xe&&y.container&&(y.container.removeEventListener("click",xe),xe=null),ve&&(window.removeEventListener("resize",ve),ve=null),y.orbitControls&&(y.orbitControls.dispose(),y.orbitControls=null),y.transformControls&&(y.transformControls.dispose(),y.transformControls=null),_&&(_.dispose(),_=null,$=null),y.scene&&(us(y.scene),y.scene=null),y.renderer&&(y.renderer.dispose(),y.renderer.domElement&&y.container&&y.container.removeChild(y.renderer.domElement),y.renderer=null),Xt(),y.camera=null,y.gridHelper=null,y.selectedObject=null,y.container=null,y.mode="",ee=[],le.clear(),Xe(),Ve=!1,ae=!1}const Kn=/^[og]\s*(.+)?/,Zn=/^mtllib /,Xn=/^usemtl /,qn=/^usemap /,kt=/\s+/,Nt=new a.Vector3,$e=new a.Vector3,Pt=new a.Vector3,Lt=new a.Vector3,H=new a.Vector3,We=new a.Color;function Jn(){const r={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 n=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(s,i){const o=this._finalize(!1);o&&(o.inherited||o.groupCount<=0)&&this.materials.splice(o.index,1);const A={index:this.materials.length,name:s||"",mtllib:Array.isArray(i)&&i.length>0?i[i.length-1]:"",smooth:o!==void 0?o.smooth:this.smooth,groupStart:o!==void 0?o.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(c){const u={index:typeof c=="number"?c:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return u.clone=this.clone.bind(u),u}};return this.materials.push(A),A},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(s){const i=this.currentMaterial();if(i&&i.groupEnd===-1&&(i.groupEnd=this.geometry.vertices.length/3,i.groupCount=i.groupEnd-i.groupStart,i.inherited=!1),s&&this.materials.length>1)for(let o=this.materials.length-1;o>=0;o--)this.materials[o].groupCount<=0&&this.materials.splice(o,1);return s&&this.materials.length===0&&this.materials.push({name:"",smooth:this.smooth}),i}},n&&n.name&&typeof n.clone=="function"){const s=n.clone(0);s.inherited=!0,this.object.materials.push(s)}this.objects.push(this.object)},finalize:function(){this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0)},parseVertexIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseNormalIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseUVIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/2)*2},addVertex:function(e,t,n){const s=this.vertices,i=this.object.geometry.vertices;i.push(s[e+0],s[e+1],s[e+2]),i.push(s[t+0],s[t+1],s[t+2]),i.push(s[n+0],s[n+1],s[n+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,n){const s=this.normals,i=this.object.geometry.normals;i.push(s[e+0],s[e+1],s[e+2]),i.push(s[t+0],s[t+1],s[t+2]),i.push(s[n+0],s[n+1],s[n+2])},addFaceNormal:function(e,t,n){const s=this.vertices,i=this.object.geometry.normals;Nt.fromArray(s,e),$e.fromArray(s,t),Pt.fromArray(s,n),H.subVectors(Pt,$e),Lt.subVectors(Nt,$e),H.cross(Lt),H.normalize(),i.push(H.x,H.y,H.z),i.push(H.x,H.y,H.z),i.push(H.x,H.y,H.z)},addColor:function(e,t,n){const s=this.colors,i=this.object.geometry.colors;s[e]!==void 0&&i.push(s[e+0],s[e+1],s[e+2]),s[t]!==void 0&&i.push(s[t+0],s[t+1],s[t+2]),s[n]!==void 0&&i.push(s[n+0],s[n+1],s[n+2])},addUV:function(e,t,n){const s=this.uvs,i=this.object.geometry.uvs;i.push(s[e+0],s[e+1]),i.push(s[t+0],s[t+1]),i.push(s[n+0],s[n+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,n,s,i,o,A,c,u){const h=this.vertices.length;let d=this.parseVertexIndex(e,h),p=this.parseVertexIndex(t,h),f=this.parseVertexIndex(n,h);if(this.addVertex(d,p,f),this.addColor(d,p,f),A!==void 0&&A!==""){const C=this.normals.length;d=this.parseNormalIndex(A,C),p=this.parseNormalIndex(c,C),f=this.parseNormalIndex(u,C),this.addNormal(d,p,f)}else this.addFaceNormal(d,p,f);if(s!==void 0&&s!==""){const C=this.uvs.length;d=this.parseUVIndex(s,C),p=this.parseUVIndex(i,C),f=this.parseUVIndex(o,C),this.addUV(d,p,f),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type="Points";const t=this.vertices.length;for(let n=0,s=e.length;n<s;n++){const i=this.parseVertexIndex(e[n],t);this.addVertexPoint(i),this.addColor(i)}},addLineGeometry:function(e,t){this.object.geometry.type="Line";const n=this.vertices.length,s=this.uvs.length;for(let i=0,o=e.length;i<o;i++)this.addVertexLine(this.parseVertexIndex(e[i],n));for(let i=0,o=t.length;i<o;i++)this.addUVLine(this.parseUVIndex(t[i],s))}};return r.startObject("",!1),r}class Qn extends a.Loader{constructor(e){super(e),this.materials=null}load(e,t,n,s){const i=this,o=new a.FileLoader(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(A){try{t(i.parse(A))}catch(c){s?s(c):console.error(c),i.manager.itemError(e)}},n,s)}setMaterials(e){return this.materials=e,this}parse(e){const t=new Jn;e.indexOf(`\r
270
270
  `)!==-1&&(e=e.replace(/\r\n/g,`
271
271
  `)),e.indexOf(`\\
272
272
  `)!==-1&&(e=e.replace(/\\\n/g,""));const n=e.split(`