endset_three_editor 0.6.5 → 0.6.6
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.
package/dist/three/index.d.ts
CHANGED
package/dist/three-editor.cjs.js
CHANGED
|
@@ -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 cn(this.container),this.css2dObject.name=`DataPanel_${e.name||e.uuid}`,this.css2dObject.center.set(.5,1)),this.css2dObject.position.set(this.options.offsetX,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(this.options.offsetX??0,s+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||"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 Bt(a,e){const t=l.toRaw(a);Ge.set(t,e),t.userData._hasDataPanel=!0}function Se(a){return Ge.get(l.toRaw(a))||null}function Ut(a){const e=l.toRaw(a),t=Ge.get(e);t&&(t.dispose(),Ge.delete(e)),e.userData._hasDataPanel=void 0}let P=null;function Gt(a){return P?(P.domElement.parentNode!==a&&a.appendChild(P.domElement),P):(P=new un,P.setSize(a.clientWidth,a.clientHeight),P.domElement.style.position="absolute",P.domElement.style.top="0",P.domElement.style.left="0",P.domElement.style.pointerEvents="none",a.appendChild(P.domElement),P)}function yn(){return P}function Ht(a,e){P&&P.render(a,e)}function zt(a,e){P&&P.setSize(a,e)}function Kt(){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 In=16755200,wt=16733440;let st=[],Oe=[],He=!0,re=null,nt=null,Fe=null,ee=[];const le=new Map;let ze,Be=null,xe=null,ve=null;function Zt(a,e="edit",t){y.container=a,y.mode=e,vn(),Sn(),wn(),t&&(ls(t.scene,e,t.dataPanels),t!=null&&t.camera&&(y.defaultMainCamera=t.camera,lt(!0))),Rn(),En(),ze&&y.orbitControls&&(y.orbitControls.target.fromArray(ze),y.orbitControls.update()),Mn(),Fn(),Xt(),xe=n=>Pn(n),ve=()=>kn(),e==="edit"&&a.addEventListener("click",xe),window.addEventListener("resize",ve),t||Nn(),e==="edit"&&Tn()}function xn(){var i,o;const a=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*a*t*a;let s;return n<=5e6?s=Math.min(a,2):n<=12e6?s=Math.min(a,1.5):n<=2e7?s=Math.min(a,1.3):s=Math.min(a,1),s}function vn(){const a=xn(),e=new T.WebGLRenderer({antialias:!0,alpha:!0});e.setSize(y.container.clientWidth,y.container.clientHeight),e.setPixelRatio(a),console.log(`[Renderer] css=${y.container.clientWidth}×${y.container.clientHeight}, dpr=${window.devicePixelRatio}, targetRatio=${a}, antialias=true`),e.shadowMap.enabled=!0,e.shadowMap.type=T.PCFSoftShadowMap,y.container.appendChild(e.domElement),y.renderer=e}function Mn(){if(!y.renderer||!y.scene||!y.camera)return;const a=new rn(y.renderer);a.addPass(new an(y.scene,y.camera)),a.addPass(new ln);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(wt),c.hiddenEdgeColor.set(wt),c.downSampleRatio=A,c.pulsePeriod=2,a.addPass(c),_=a,$=c}function Sn(){y.scene=new T.Scene,y.scene.name="sl_scene",new T.TextureLoader().load(An,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 Tn(){const a=new T.GridHelper(30,30,8956671,3364232);a.name="地板",a.userData.type="initFloor",y.scene.add(a),y.gridHelper=a;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 wn(){const a=y.container,e=a.clientWidth/a.clientHeight,t=new T.PerspectiveCamera(45,e,.1,1e3);t.position.set(0,6,15),t.lookAt(0,0,0),y.camera=t}function lt(a=!1){if(!y.defaultMainCamera)return;const e=y.defaultMainCamera;if(a){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(),ze=e.target;return}else ut(""),At();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(()=>{ze=e.target,y.orbitControls.enabled=!0}).start()}function En(){const a=new Ps(y.camera,y.renderer.domElement);a.minDistance=0,a.maxDistance=1/0,a.addEventListener("start",()=>{Ve=!1}),a.addEventListener("change",()=>{Ve=!0}),a.addEventListener("end",()=>{Ve&&(ae=!0,setTimeout(()=>{ae=!1},200))}),y.orbitControls=a}function Rn(){const a=new Ks(y.camera,y.renderer.domElement);a.addEventListener("dragging-changed",e=>{y.orbitControls.enabled=!e.value,e.value||(ae=!0,setTimeout(()=>{ae=!1},200))}),a.addEventListener("objectChange",()=>{const e=y.selectedObject;if(nt&&e&&nt(e),e&&e.type==="DirectionalLight"){const t=e.userData.helper;t&&t.update&&t.update()}}),y.scene.add(a.getHelper()),y.transformControls=a}function Nn(){const a=new T.AmbientLight(16777215,1);y.scene.add(a)}function Xt(){var e,t;Be=requestAnimationFrame(Xt),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&&Ht(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 kn(){if(!y.container||!y.camera||!y.renderer)return;const a=y.container.clientWidth,e=y.container.clientHeight;a===0||e===0||(y.camera.aspect=a/e,y.camera.updateProjectionMatrix(),y.renderer.setSize(a,e),_&&_.setSize(a,e),$&&$.resolution.set(a,e),zt(a,e))}function Ke(a){y.selectedObject!==a&&(y.selectedObject&&y.transformControls.detach(),y.selectedObject=a,y.transformControls.attach(a),y.transformControls.setMode(y.transformControlsMode),y.transformControls.showX=!0,y.transformControls.showY=!0,y.transformControls.showZ=!0,Qt(a),re==null||re(a))}let B=null;function qt(a){B=a}function Ue(a){B==null||B(a)}function Jt(a){y.transformControlsMode=a,y.transformControls&&y.transformControls.setMode(y.transformControlsMode)}function Qt(a){if(y.mode==="edit")At(),a.traverse(t=>{if(t.isMesh){const n=t,s=new T.EdgesGeometry(n.geometry),i=new T.LineBasicMaterial({color:In,depthTest:!0}),o=new T.LineSegments(s,i);t.add(o),st.push(o)}});else{if(!$)return;const t=[];a.traverse(n=>{n.isMesh&&t.push(n)}),$.selectedObjects=t}}function At(){if(y.mode==="edit"){for(const a of st)a.parent&&a.parent.remove(a),a.geometry.dispose(),a.material.dispose();st=[]}else $&&($.selectedObjects=[])}function ct(){y.selectedObject&&(At(),y.transformControls.detach(),y.selectedObject=null,re==null||re(null))}function ut(a){let e=null;le.forEach(t=>{t.userData.id==a&&(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)}),Qt(e),setTimeout(()=>{Yt(e)},500))}function Pn(a){if(ae){ae=!1;return}const e=y.renderer.domElement.getBoundingClientRect(),t=new T.Vector2((a.clientX-e.left)/e.width*2-1,-((a.clientY-e.top)/e.height)*2+1),n=new T.Raycaster;n.setFromCamera(t,y.camera);const s=[];y.scene.traverse(o=>{(o.userData.isMovable||o.userData.type==="lightHelper")&&s.push(o)});const i=n.intersectObjects(s);if(i.length>0){let o=Ln(i[0].object);Ke(o)}else ct()}function Ln(a){if(a.type==="Line"||a.type==="LineSegments"){const e=a.parent;if(e)switch(e.type){case"DirectionalLightHelper":return e.light;default:return e.isMesh?e:a}return a}return a}function Yt(a,e=500){if(!y.camera||!y.orbitControls){console.warn("[focusOnObject] 编辑器尚未初始化或已销毁,无法执行聚焦操作。请确保已调用 initEditor()");return}if(!a){console.warn("[focusOnObject] 传入的物体为空,无法执行聚焦操作。");return}let t=null;a.userData.closeUpView&&typeof a.userData.closeUpView.x=="number"&&typeof a.userData.closeUpView.y=="number"&&typeof a.userData.closeUpView.z=="number"&&(t=a.userData.closeUpView);const n=new T.Vector3;a.getWorldPosition(n);const i=new T.Box3().setFromObject(a).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)),f=y.camera.position.clone(),h=y.orbitControls.target.clone();try{new Me.Tween({x:f.x,y:f.y,z:f.z,tx:h.x,ty:h.y,tz:h.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(d=>{y.camera.position.set(d.x,d.y,d.z),y.orbitControls.target.set(d.tx,d.ty,d.tz),y.orbitControls.update()}).start()}catch(d){console.error("[focusOnObject] TWEEN 动画创建失败,请检查 @tweenjs/tween.js 是否已正确安装且版本兼容(^23.1.3):",d)}}function Dn(a){a.userData.id&&le.set(String(a.userData.id),a)}function On(a){a.userData.id&&le.delete(String(a.userData.id))}function _t(a,e){const t=e||a.userData.id;if(t)le.set(String(t),a);else{const n=T.MathUtils.generateUUID();a.userData.id=n,le.set(n,a)}}function Wn(a){a.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(a,e=!1){y.scene.add(a),He=!0,a.userData.isMovable&&(jn(a),Ze()),e&&y.mode==="edit"&&Ke(a)}function $t(a){y.selectedObject===a&&ct(),He=!0,Wn(a),On(a),a.userData.helper&&y.scene.remove(a.userData.helper),a.parent?a.parent.remove(a):y.scene.remove(a),Vn(a),Ze()}function es(a){const e=y.scene.getObjectByProperty("uuid",a);e&&$t(e)}function jn(a){a.userData.isMovable&&a.parent===y.scene&&(ee.includes(a)||ee.push(a))}function Vn(a){const e=ee.indexOf(a);e!==-1&&ee.splice(e,1)}function Fn(){const a=[];y.scene.children.forEach(e=>{e.userData.isMovable&&a.push(e)}),ee=a,Ze()}function Ze(){Fe==null||Fe([...ee])}function ts(a){re=a}function ss(a){nt=a}function ns(a){Fe=a}function is(){return ee}function os(){return y.selectedObject}function Bn(a,e,t){if(!y.scene)return;const n=le.get(a);if(n){const s=Se(n);s&&s.updateItemByCode(e,t)}}function Un(){return y.scene}function rs(){return y.camera}function Gn(){return y.renderer}async function as(){var u,f,h;B==null||B(!0),await new Promise(d=>setTimeout(d,50)),ct();const a=y.scene;if(!a)return B==null||B(!1),"{}";const e=[],t=new Map,n=new Map;a.traverse(d=>{var p;if(d.userData.type==="lightHelper"&&e.push(d),d.type==="DirectionalLight"&&d.userData.helper&&(t.set(d,d.userData.helper),d.userData.helper=void 0),d.name&&d.name.startsWith("DataPanel_")){const g=d;if(g.element){const m=g.element.querySelector("[data-panel-title]"),b=[];if(g.element.querySelectorAll(".sl-css2d-data-panel-item").forEach(v=>{var M,S,E;const I=v.querySelector(".item-label"),x=v.querySelector(".item-value");if(I&&x){const V=(I.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,Xe=((E=v.getAttribute("data-item-code"))==null?void 0:E.trim())||void 0;b.push({label:V,value:U,unit:se,code:Xe})}}),d.parent){const v=g.element.style.width||"",I=g.element.style.fontSize||"",x=Se(d.parent),M=x?x.getOffsetY():.1;n.set(d.parent.userData.id?d.parent.userData.id:d.parent.uuid,{title:((p=m==null?void 0:m.textContent)==null?void 0:p.trim())||"",items:b,width:v,fontSize:I,offsetY:M})}}}}),e.forEach(d=>a.remove(d));const s=a.clone();s.children=s.children.filter(d=>d.userData.type!=="initFloor"),s.traverse(d=>{d.name&&d.name.startsWith("DataPanel_")&&d.parent&&d.parent.remove(d)});const i=s.toJSON();e.forEach(d=>a.add(d)),t.forEach((d,p)=>{p.userData.helper=d});const o={position:(u=y.camera)==null?void 0:u.position.toArray(),rotation:(f=y.camera)==null?void 0:f.rotation.toArray(),target:((h=y.orbitControls)==null?void 0:h.target.toArray())||[0,0,0]},A={};n.forEach((d,p)=>{A[p]=d});const c=JSON.stringify({scene:i,camera:o,dataPanels:A});return B==null||B(!1),c}function ls(a,e="edit",t){var o,A,c;const n=typeof a=="string"?JSON.parse(a):a,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 f=u.userData.id||u.uuid,h=t[f];if(h&&u.userData.isMovable){Dn(u);const d=new fe({title:h.title,items:h.items});d.attachTo(u),d.visible=!1,h.width&&d.setWidth(h.width),h.fontSize&&d.setFontSize(h.fontSize),h.offsetY!==void 0&&d.setOffsetY(h.offsetY),Bt(u,d)}})),e==="edit"&&((c=y.scene)==null||c.traverse(u=>{var f;if(u.type==="DirectionalLight"){const h=u;if(!h.userData.helper){const d=new T.DirectionalLightHelper(h,1);d.userData.type="lightHelper",h.userData.helper=d,(f=y.scene)==null||f.add(d)}}}))}function As(a){if(!a)return;if(a.type==="Mesh"){const t=a;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=a.children.slice();for(const t of e)As(t)}function cs(){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&&(As(y.scene),y.scene=null),y.renderer&&(y.renderer.dispose(),y.renderer.domElement&&y.container&&y.container.removeChild(y.renderer.domElement),y.renderer=null),Kt(),y.camera=null,y.gridHelper=null,y.selectedObject=null,y.container=null,y.mode="",ee=[],le.clear(),Ze(),Ve=!1,ae=!1}const Hn=/^[og]\s*(.+)?/,zn=/^mtllib /,Kn=/^usemtl /,Zn=/^usemap /,Et=/\s+/,Rt=new r.Vector3,Ye=new r.Vector3,Nt=new r.Vector3,kt=new r.Vector3,H=new r.Vector3,We=new r.Color;function Xn(){const a={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;Rt.fromArray(s,e),Ye.fromArray(s,t),Nt.fromArray(s,n),H.subVectors(Nt,Ye),kt.subVectors(Rt,Ye),H.cross(kt),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 f=this.vertices.length;let h=this.parseVertexIndex(e,f),d=this.parseVertexIndex(t,f),p=this.parseVertexIndex(n,f);if(this.addVertex(h,d,p),this.addColor(h,d,p),A!==void 0&&A!==""){const g=this.normals.length;h=this.parseNormalIndex(A,g),d=this.parseNormalIndex(c,g),p=this.parseNormalIndex(u,g),this.addNormal(h,d,p)}else this.addFaceNormal(h,d,p);if(s!==void 0&&s!==""){const g=this.uvs.length;h=this.parseUVIndex(s,g),d=this.parseUVIndex(i,g),p=this.parseUVIndex(o,g),this.addUV(h,d,p),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 a.startObject("",!1),a}class qn extends r.Loader{constructor(e){super(e),this.materials=null}load(e,t,n,s){const i=this,o=new r.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 Xn;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 cn(this.container),this.css2dObject.name=`DataPanel_${e.name||e.uuid}`,this.css2dObject.center.set(.5,1)),this.css2dObject.position.set(this.options.offsetX,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(this.options.offsetX??0,s+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||"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 Bt(a,e){const t=l.toRaw(a);Ge.set(t,e),t.userData._hasDataPanel=!0}function Se(a){return Ge.get(l.toRaw(a))||null}function Ut(a){const e=l.toRaw(a),t=Ge.get(e);t&&(t.dispose(),Ge.delete(e)),e.userData._hasDataPanel=void 0}let P=null;function Gt(a){return P?(P.domElement.parentNode!==a&&a.appendChild(P.domElement),P):(P=new un,P.setSize(a.clientWidth,a.clientHeight),P.domElement.style.position="absolute",P.domElement.style.top="0",P.domElement.style.left="0",P.domElement.style.pointerEvents="none",a.appendChild(P.domElement),P)}function yn(){return P}function Ht(a,e){P&&P.render(a,e)}function zt(a,e){P&&P.setSize(a,e)}function Kt(){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 In=16755200,wt=16733440;let st=[],Oe=[],He=!0,re=null,nt=null,Fe=null,ee=[];const le=new Map;let ze,Be=null,xe=null,ve=null;function Zt(a,e="edit",t){y.container=a,y.mode=e,vn(),Sn(),wn(),t&&(ls(t.scene,e,t.dataPanels),t!=null&&t.camera&&(y.defaultMainCamera=t.camera,lt(!0))),Rn(),En(),ze&&y.orbitControls&&(y.orbitControls.target.fromArray(ze),y.orbitControls.update()),Mn(),Fn(),Xt(),xe=n=>Pn(n),ve=()=>kn(),e==="edit"&&a.addEventListener("click",xe),window.addEventListener("resize",ve),t||Nn(),e==="edit"&&Tn()}function xn(){var i,o;const a=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*a*t*a;let s;return n<=5e6?s=Math.min(a,2):n<=12e6?s=Math.min(a,1.5):n<=2e7?s=Math.min(a,1.3):s=Math.min(a,1),s}function vn(){const a=xn(),e=new T.WebGLRenderer({antialias:!0,alpha:!0});e.setSize(y.container.clientWidth,y.container.clientHeight),e.setPixelRatio(a),console.log(`[Renderer] css=${y.container.clientWidth}×${y.container.clientHeight}, dpr=${window.devicePixelRatio}, targetRatio=${a}, antialias=true`),e.shadowMap.enabled=!0,e.shadowMap.type=T.PCFSoftShadowMap,y.container.appendChild(e.domElement),y.renderer=e}function Mn(){if(!y.renderer||!y.scene||!y.camera)return;const a=new rn(y.renderer);a.addPass(new an(y.scene,y.camera)),a.addPass(new ln);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(wt),c.hiddenEdgeColor.set(wt),c.downSampleRatio=A,c.pulsePeriod=2,a.addPass(c),_=a,$=c}function Sn(){y.scene=new T.Scene,y.scene.name="sl_scene",new T.TextureLoader().load(An,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 Tn(){const a=new T.GridHelper(30,30,8956671,3364232);a.name="地板",a.userData.type="initFloor",y.scene.add(a),y.gridHelper=a;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 wn(){const a=y.container,e=a.clientWidth/a.clientHeight,t=new T.PerspectiveCamera(45,e,.1,1e3);t.position.set(0,6,15),t.lookAt(0,0,0),y.camera=t}function lt(a=!1){if(!y.defaultMainCamera)return;const e=y.defaultMainCamera;if(a){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(),ze=e.target;return}else ut(""),At();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(()=>{ze=e.target,y.orbitControls.enabled=!0}).start()}function En(){const a=new Ps(y.camera,y.renderer.domElement);a.minDistance=0,a.maxDistance=1/0,a.addEventListener("start",()=>{Ve=!1}),a.addEventListener("change",()=>{Ve=!0}),a.addEventListener("end",()=>{Ve&&(ae=!0,setTimeout(()=>{ae=!1},200))}),y.orbitControls=a}function Rn(){const a=new Ks(y.camera,y.renderer.domElement);a.addEventListener("dragging-changed",e=>{y.orbitControls.enabled=!e.value,e.value||(ae=!0,setTimeout(()=>{ae=!1},200))}),a.addEventListener("objectChange",()=>{const e=y.selectedObject;if(nt&&e&&nt(e),e&&e.type==="DirectionalLight"){const t=e.userData.helper;t&&t.update&&t.update()}}),y.scene.add(a.getHelper()),y.transformControls=a}function Nn(){const a=new T.AmbientLight(16777215,1);y.scene.add(a)}function Xt(){var e,t;Be=requestAnimationFrame(Xt),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&&Ht(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 kn(){if(!y.container||!y.camera||!y.renderer)return;const a=y.container.clientWidth,e=y.container.clientHeight;a===0||e===0||(y.camera.aspect=a/e,y.camera.updateProjectionMatrix(),y.renderer.setSize(a,e),_&&_.setSize(a,e),$&&$.resolution.set(a,e),zt(a,e))}function Ke(a){y.selectedObject!==a&&(y.selectedObject&&y.transformControls.detach(),y.selectedObject=a,y.transformControls.attach(a),y.transformControls.setMode(y.transformControlsMode),y.transformControls.showX=!0,y.transformControls.showY=!0,y.transformControls.showZ=!0,Qt(a),re==null||re(a))}let B=null;function qt(a){B=a}function Ue(a){B==null||B(a)}function Jt(a){y.transformControlsMode=a,y.transformControls&&y.transformControls.setMode(y.transformControlsMode)}function Qt(a){if(y.mode==="edit")At(),a.traverse(t=>{if(t.isMesh){const n=t,s=new T.EdgesGeometry(n.geometry),i=new T.LineBasicMaterial({color:In,depthTest:!0}),o=new T.LineSegments(s,i);t.add(o),st.push(o)}});else{if(!$)return;const t=[];a.traverse(n=>{n.isMesh&&t.push(n)}),$.selectedObjects=t}}function At(){if(y.mode==="edit"){for(const a of st)a.parent&&a.parent.remove(a),a.geometry.dispose(),a.material.dispose();st=[]}else $&&($.selectedObjects=[])}function ct(){y.selectedObject&&(At(),y.transformControls.detach(),y.selectedObject=null,re==null||re(null))}function ut(a){let e=null;le.forEach(t=>{t.userData.id==a&&(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)}),Qt(e),setTimeout(()=>{Yt(e)},500))}function Pn(a){if(ae){ae=!1;return}const e=y.renderer.domElement.getBoundingClientRect(),t=new T.Vector2((a.clientX-e.left)/e.width*2-1,-((a.clientY-e.top)/e.height)*2+1),n=new T.Raycaster;n.setFromCamera(t,y.camera);const s=[];y.scene.traverse(o=>{(o.userData.isMovable||o.userData.type==="lightHelper")&&s.push(o)});const i=n.intersectObjects(s);if(i.length>0){let o=Ln(i[0].object);Ke(o)}else ct()}function Ln(a){if(a.type==="Line"||a.type==="LineSegments"){const e=a.parent;if(e)switch(e.type){case"DirectionalLightHelper":return e.light;default:return e.isMesh?e:a}return a}return a}function Yt(a,e=500){if(!y.camera||!y.orbitControls){console.warn("[focusOnObject] 编辑器尚未初始化或已销毁,无法执行聚焦操作。请确保已调用 initEditor()");return}if(!a){console.warn("[focusOnObject] 传入的物体为空,无法执行聚焦操作。");return}let t=null;a.userData.closeUpView&&typeof a.userData.closeUpView.x=="number"&&typeof a.userData.closeUpView.y=="number"&&typeof a.userData.closeUpView.z=="number"&&(t=a.userData.closeUpView);const n=new T.Vector3;a.getWorldPosition(n);const i=new T.Box3().setFromObject(a).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)),f=y.camera.position.clone(),h=y.orbitControls.target.clone();try{new Me.Tween({x:f.x,y:f.y,z:f.z,tx:h.x,ty:h.y,tz:h.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(d=>{y.camera.position.set(d.x,d.y,d.z),y.orbitControls.target.set(d.tx,d.ty,d.tz),y.orbitControls.update()}).start()}catch(d){console.error("[focusOnObject] TWEEN 动画创建失败,请检查 @tweenjs/tween.js 是否已正确安装且版本兼容(^23.1.3):",d)}}function Dn(a){a.userData.id&&le.set(String(a.userData.id),a)}function On(a){a.userData.id&&le.delete(String(a.userData.id))}function _t(a,e){const t=e||a.userData.id;if(t)le.set(String(t),a);else{const n=T.MathUtils.generateUUID();a.userData.id=n,le.set(n,a)}}function Wn(a){a.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(a,e=!1){y.scene.add(a),He=!0,a.userData.isMovable&&(jn(a),Ze()),e&&y.mode==="edit"&&Ke(a)}function $t(a){y.selectedObject===a&&ct(),He=!0,Wn(a),On(a),a.userData.helper&&y.scene.remove(a.userData.helper),a.parent?a.parent.remove(a):y.scene.remove(a),Vn(a),Ze()}function es(a){const e=y.scene.getObjectByProperty("uuid",a);e&&$t(e)}function jn(a){a.userData.isMovable&&a.parent===y.scene&&(ee.includes(a)||ee.push(a))}function Vn(a){const e=ee.indexOf(a);e!==-1&&ee.splice(e,1)}function Fn(){const a=[];y.scene.children.forEach(e=>{e.userData.isMovable&&a.push(e)}),ee=a,Ze()}function Ze(){Fe==null||Fe([...ee])}function ts(a){re=a}function ss(a){nt=a}function ns(a){Fe=a}function is(){return ee}function os(){return y.selectedObject}function Bn(a,e,t){if(!y.scene)return;const n=le.get(a);if(n){const s=Se(n);s&&s.updateItemByCode(e,t)}}function Un(){return y.scene}function rs(){return y.camera}function Gn(){return y.renderer}async function as(){var u,f,h;B==null||B(!0),await new Promise(d=>setTimeout(d,50)),ct();const a=y.scene;if(!a)return B==null||B(!1),"{}";const e=[],t=new Map,n=new Map;a.traverse(d=>{var p;if(d.userData.type==="lightHelper"&&e.push(d),d.type==="DirectionalLight"&&d.userData.helper&&(t.set(d,d.userData.helper),d.userData.helper=void 0),d.name&&d.name.startsWith("DataPanel_")){const g=d;if(g.element){const m=g.element.querySelector("[data-panel-title]"),b=[];if(g.element.querySelectorAll(".sl-css2d-data-panel-item").forEach(v=>{var M,S,E;const I=v.querySelector(".item-label"),x=v.querySelector(".item-value");if(I&&x){const V=(I.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,Xe=((E=v.getAttribute("data-item-code"))==null?void 0:E.trim())||void 0;b.push({label:V,value:U,unit:se,code:Xe})}}),d.parent){const v=g.element.style.width||"",I=g.element.style.fontSize||"",x=Se(d.parent),M=x?x.getOffsetY():.1;n.set(d.parent.userData.id?d.parent.userData.id:d.parent.uuid,{title:((p=m==null?void 0:m.textContent)==null?void 0:p.trim())||"",items:b,width:v,fontSize:I,offsetY:M,offsetX:x?x.getOffsetX():0})}}}}),e.forEach(d=>a.remove(d));const s=a.clone();s.children=s.children.filter(d=>d.userData.type!=="initFloor"),s.traverse(d=>{d.name&&d.name.startsWith("DataPanel_")&&d.parent&&d.parent.remove(d)});const i=s.toJSON();e.forEach(d=>a.add(d)),t.forEach((d,p)=>{p.userData.helper=d});const o={position:(u=y.camera)==null?void 0:u.position.toArray(),rotation:(f=y.camera)==null?void 0:f.rotation.toArray(),target:((h=y.orbitControls)==null?void 0:h.target.toArray())||[0,0,0]},A={};n.forEach((d,p)=>{A[p]=d});const c=JSON.stringify({scene:i,camera:o,dataPanels:A});return B==null||B(!1),c}function ls(a,e="edit",t){var o,A,c;const n=typeof a=="string"?JSON.parse(a):a,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 f=u.userData.id||u.uuid,h=t[f];if(h&&u.userData.isMovable){Dn(u);const d=new fe({title:h.title,items:h.items});d.attachTo(u),d.visible=!1,h.width&&d.setWidth(h.width),h.fontSize&&d.setFontSize(h.fontSize),h.offsetY!==void 0&&d.setOffsetY(h.offsetY),h.offsetX!==void 0&&d.setOffsetX(h.offsetX),Bt(u,d)}})),e==="edit"&&((c=y.scene)==null||c.traverse(u=>{var f;if(u.type==="DirectionalLight"){const h=u;if(!h.userData.helper){const d=new T.DirectionalLightHelper(h,1);d.userData.type="lightHelper",h.userData.helper=d,(f=y.scene)==null||f.add(d)}}}))}function As(a){if(!a)return;if(a.type==="Mesh"){const t=a;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=a.children.slice();for(const t of e)As(t)}function cs(){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&&(As(y.scene),y.scene=null),y.renderer&&(y.renderer.dispose(),y.renderer.domElement&&y.container&&y.container.removeChild(y.renderer.domElement),y.renderer=null),Kt(),y.camera=null,y.gridHelper=null,y.selectedObject=null,y.container=null,y.mode="",ee=[],le.clear(),Ze(),Ve=!1,ae=!1}const Hn=/^[og]\s*(.+)?/,zn=/^mtllib /,Kn=/^usemtl /,Zn=/^usemap /,Et=/\s+/,Rt=new r.Vector3,Ye=new r.Vector3,Nt=new r.Vector3,kt=new r.Vector3,H=new r.Vector3,We=new r.Color;function Xn(){const a={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;Rt.fromArray(s,e),Ye.fromArray(s,t),Nt.fromArray(s,n),H.subVectors(Nt,Ye),kt.subVectors(Rt,Ye),H.cross(kt),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 f=this.vertices.length;let h=this.parseVertexIndex(e,f),d=this.parseVertexIndex(t,f),p=this.parseVertexIndex(n,f);if(this.addVertex(h,d,p),this.addColor(h,d,p),A!==void 0&&A!==""){const g=this.normals.length;h=this.parseNormalIndex(A,g),d=this.parseNormalIndex(c,g),p=this.parseNormalIndex(u,g),this.addNormal(h,d,p)}else this.addFaceNormal(h,d,p);if(s!==void 0&&s!==""){const g=this.uvs.length;h=this.parseUVIndex(s,g),d=this.parseUVIndex(i,g),p=this.parseUVIndex(o,g),this.addUV(h,d,p),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 a.startObject("",!1),a}class qn extends r.Loader{constructor(e){super(e),this.materials=null}load(e,t,n,s){const i=this,o=new r.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 Xn;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(`
|