endset_three_editor 0.4.0 → 0.4.1
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
|
@@ -43,7 +43,7 @@ export declare function selectModelHandle(objectId: string): void;
|
|
|
43
43
|
* @param objectId - 目标物体 id
|
|
44
44
|
* @param duration - 动画持续时间(毫秒),默认 500ms
|
|
45
45
|
*/
|
|
46
|
-
export declare function focusOnObject(
|
|
46
|
+
export declare function focusOnObject(objectId: string, duration?: number): void;
|
|
47
47
|
/**
|
|
48
48
|
* 添加模型
|
|
49
49
|
* @param model
|
package/dist/three-editor.cjs.js
CHANGED
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
`,n.setAttribute("data-item-code",s.code||""),n.innerHTML=`
|
|
38
38
|
<span class="item-label" style="opacity: 0.75; flex-shrink: 0;">${this.escapeHtml(s.label)}</span>
|
|
39
39
|
<span class="item-value" style="font-weight: 600; color: #5dade2; text-align: right; word-break: break-all;">${this.escapeHtml(s.value)}${s.unit?`<span style="font-size:0.85em;opacity:0.7;margin-left:2px;">${this.escapeHtml(s.unit)}</span>`:""}</span>
|
|
40
|
-
`,e.appendChild(n)})}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 E.Box3().setFromObject(e),s=new E.Vector3;t.getSize(s);const n=s.y/2+this.options.offsetY;this.css2dObject||(this.css2dObject=new zn(this.container),this.css2dObject.name=`DataPanel_${e.name||e.uuid}`,this.css2dObject.center.set(.5,1)),this.css2dObject.position.set(0,n,0),e.add(this.css2dObject),this.attachedObject=e}detach(){this.css2dObject&&this.attachedObject&&this.attachedObject.remove(this.css2dObject),this.attachedObject=null}show(){this._visible=!0,this.css2dObject&&(this.css2dObject.visible=!0)}hide(){this._visible=!1,this.css2dObject&&(this.css2dObject.visible=!1)}get visible(){return this._visible}set visible(e){e?this.show():this.hide()}setTitle(e){var s;this.options.title=e;const t=(s=this.container)==null?void 0:s.querySelector("[data-panel-title]");e?t?t.textContent=e:this.rebuildPanel():t&&t.remove()}getTitle(){return this.options.title||""}setItems(e){var s;this.options.items=[...e];const t=(s=this.container)==null?void 0:s.querySelector("[data-panel-list]");t&&this.renderItems(t,this.options.items)}getItems(){return[...this.options.items||[]]}addItem(e){var s;this.options.items.push(e);const t=(s=this.container)==null?void 0:s.querySelector("[data-panel-list]");t&&this.renderItems(t,this.options.items)}removeItem(e){var s;this.options.items=this.options.items.filter(n=>n.label!==e);const t=(s=this.container)==null?void 0:s.querySelector("[data-panel-list]");t&&this.renderItems(t,this.options.items)}updateItem(e,t,s){var o;const n=this.options.items.find(i=>i.label===e);if(n){n.value=t,s!==void 0&&(n.unit=s);const i=(o=this.container)==null?void 0:o.querySelector("[data-panel-list]");i&&this.renderItems(i,this.options.items)}}updateItemByCode(e,t){var n;const s=this.options.items.find(o=>o.code===e);if(s){s.value=t;const o=(n=this.container)==null?void 0:n.querySelector("[data-panel-list]");o&&this.renderItems(o,this.options.items)}}clearItems(){var t;this.options.items=[];const e=(t=this.container)==null?void 0:t.querySelector("[data-panel-list]");e&&this.renderItems(e,[])}rebuildPanel(){const e=this._visible,t=this.attachedObject;this.css2dObject&&this.attachedObject&&this.attachedObject.remove(this.css2dObject),this.buildPanel(),t&&(this.attachedObject=t,t.add(this.css2dObject),e||this.hide())}updateOptions(e){this.options={...this.options,...e},this.rebuildPanel()}setOffsetY(e){if(this.options.offsetY=e,this.css2dObject&&this.attachedObject){const t=new E.Box3().setFromObject(this.attachedObject),s=new E.Vector3;t.getSize(s),this.css2dObject.position.set(0,s.y/2+e,0)}}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 Se=new WeakMap;function Dt(r,e){const t=a.toRaw(r);Se.set(t,e),t.userData._hasDataPanel=!0}function ke(r){return Se.get(a.toRaw(r))||null}function Tt(r){const e=a.toRaw(r),t=Se.get(e);t&&(t.dispose(),Se.delete(e)),e.userData._hasDataPanel=void 0}let N=null;function Pt(r){return N?(N.domElement.parentNode!==r&&r.appendChild(N.domElement),N):(N=new Fn,N.setSize(r.clientWidth,r.clientHeight),N.domElement.style.position="absolute",N.domElement.style.top="0",N.domElement.style.left="0",N.domElement.style.pointerEvents="none",r.appendChild(N.domElement),N)}function qn(){return N}function Ot(r,e){N&&N.render(r,e)}function Rt(r,e){N&&N.setSize(r,e)}function Nt(){N&&(N.domElement.parentNode&&N.domElement.parentNode.removeChild(N.domElement),N=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 Pe=!1,oe=!1,Ke=[];const Xn=16755200;let se=null,Ye=null,Oe=null,J=[];const be=new Map;let Le,Re=null,pe=null,me=null;function St(r,e="edit",t){y.container=r,y.mode=e,Un(),Kn(),Zn(),t&&(Zt(t.scene,e,t.dataPanels),t!=null&&t.camera&&(y.defaultMainCamera=t.camera,$e(!0))),Jn(),Qn(),Le&&y.orbitControls&&(y.orbitControls.target.fromArray(Le),y.orbitControls.update()),as(),Lt(),pe=s=>es(s),me=()=>$n(),e==="edit"&&r.addEventListener("click",pe),window.addEventListener("resize",me),t||_n(),e==="edit"&&Yn()}function Un(){const r=new E.WebGLRenderer({antialias:!0,alpha:!0});r.setSize(y.container.clientWidth,y.container.clientHeight),r.setPixelRatio(Math.min(window.devicePixelRatio,2)),r.shadowMap.enabled=!0,r.shadowMap.type=E.PCFSoftShadowMap,y.container.appendChild(r.domElement),y.renderer=r}function Kn(){y.scene=new E.Scene,y.scene.name="sl_scene"}function Yn(){const r=new E.GridHelper(30,30,8956671,3364232);r.name="地板",r.userData.type="initFloor",y.scene.add(r),y.gridHelper=r;const e=new E.PlaneGeometry(30,30),t=new E.ShadowMaterial({opacity:.3,color:0}),s=new E.Mesh(e,t);s.rotation.x=-Math.PI/2,s.position.y=-.01,s.name="阴影接收平面",s.userData.type="initFloor",s.receiveShadow=!0,y.scene.add(s)}function Zn(){const r=y.container,e=r.clientWidth/r.clientHeight,t=new E.PerspectiveCamera(45,e,.1,1e3);t.position.set(0,6,15),t.lookAt(0,0,0),y.camera=t}function $e(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(),Le=e.target;return}if(!y.camera||!y.orbitControls)return;const t=y.camera.position.clone(),s=y.orbitControls.target.clone(),n=new E.Vector3(e.position[0],e.position[1],e.position[2]),o=e.target?new E.Vector3(e.target[0],e.target[1],e.target[2]):new E.Vector3(0,0,0);y.orbitControls.enabled=!1,new ge.Tween({x:t.x,y:t.y,z:t.z,tx:s.x,ty:s.y,tz:s.z}).to({x:n.x,y:n.y,z:n.z,tx:o.x,ty:o.y,tz:o.z},1e3).easing(ge.Easing.Quadratic.InOut).onUpdate(i=>{y.camera.position.set(i.x,i.y,i.z),y.orbitControls.target.set(i.tx,i.ty,i.tz),y.orbitControls.update()}).onComplete(()=>{Le=e.target,y.orbitControls.enabled=!0}).start()}function Qn(){const r=new yn(y.camera,y.renderer.domElement);r.minDistance=0,r.maxDistance=1/0,r.addEventListener("start",()=>{Pe=!1}),r.addEventListener("change",()=>{Pe=!0}),r.addEventListener("end",()=>{Pe&&(oe=!0,setTimeout(()=>{oe=!1},200))}),y.orbitControls=r}function Jn(){const r=new Sn(y.camera,y.renderer.domElement);r.addEventListener("dragging-changed",e=>{y.orbitControls.enabled=!e.value,e.value||(oe=!0,setTimeout(()=>{oe=!1},200))}),r.addEventListener("objectChange",()=>{const e=y.selectedObject;if(Ye&&e&&Ye(e),e&&e.type==="DirectionalLight"){const t=e.userData.helper;t&&t.update&&t.update()}}),y.scene.add(r.getHelper()),y.transformControls=r}function _n(){const r=new E.AmbientLight(16777215,1);y.scene.add(r)}function Lt(){var r,e;Re=requestAnimationFrame(Lt),ge.update(),(r=y.orbitControls)==null||r.update(),(e=y.renderer)==null||e.render(y.scene,y.camera),y.scene&&y.camera&&Ot(y.scene,y.camera),y.scene&&y.scene.traverse(t=>{if(t.userData.isWater&&t.type==="Mesh"){const s=t,n=s.material;if(n.normalMap){const o=s.userData.waterSpeed||{x:.005,y:.003};n.normalMap.offset.x+=o.x,n.normalMap.offset.y+=o.y}}})}function $n(){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),Rt(r,e))}function He(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,jt(r),console.log("选中",y.selectedObject),se==null||se(r))}let G=null;function kt(r){G=r}function Ne(r){G==null||G(r)}function Ht(r){y.transformControlsMode=r,y.transformControls&&y.transformControls.setMode(y.transformControlsMode)}function jt(r){et(),r.traverse(e=>{if(e.isMesh){const t=e,s=new E.EdgesGeometry(t.geometry),n=new E.LineBasicMaterial({color:Xn,depthTest:!0}),o=new E.LineSegments(s,n);e.add(o),Ke.push(o)}})}function et(){for(const r of Ke)r.parent&&r.parent.remove(r),r.geometry.dispose(),r.material.dispose();Ke=[]}function tt(){y.selectedObject&&(et(),y.transformControls.detach(),y.selectedObject=null,se==null||se(null))}function Vt(r){let e;if(be.forEach(t=>{t.userData.id==r&&(e=t),t.children&&t.children.forEach(s=>{s.name&&s.name.startsWith("DataPanel_")&&(s.visible=!1)})}),!e)return et();e.children.forEach(t=>{t.name&&t.name.startsWith("DataPanel_")&&(t.visible=!0)}),jt(e),Bt(e)}function es(r){if(oe){oe=!1;return}const e=y.renderer.domElement.getBoundingClientRect(),t=new E.Vector2((r.clientX-e.left)/e.width*2-1,-((r.clientY-e.top)/e.height)*2+1),s=new E.Raycaster;s.setFromCamera(t,y.camera);const n=[];y.scene.traverse(i=>{(i.userData.isMovable||i.userData.type==="lightHelper")&&n.push(i)});const o=s.intersectObjects(n);if(o.length>0){let i=ts(o[0].object);He(i)}else tt()}function ts(r){if(r.type==="Line"){const e=r.parent;switch(e.type){case"DirectionalLightHelper":return e.light;default:return r}}return r}function Bt(r,e=500){if(!y.camera||!y.orbitControls)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 s=new E.Vector3;r.getWorldPosition(s);const o=new E.Box3().setFromObject(r).getSize(new E.Vector3),i=Math.max(o.x,o.y,o.z)*.5,c=Math.max(i*3.5,5),d=new E.Vector3().copy(y.camera.position).sub(s).normalize();d.lengthSq()<.001&&d.set(0,0,1);const u=s.clone().add(d.multiplyScalar(c)),A=y.camera.position.clone(),h=y.orbitControls.target.clone();new ge.Tween({x:A.x,y:A.y,z:A.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:s.x,ty:s.y,tz:s.z},e).easing(ge.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()}function ns(r){r.userData.id&&be.set(String(r.userData.id),r)}function ss(r){r.userData.id&&be.delete(String(r.userData.id))}function os(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 ie(r,e=!1){y.scene.add(r),r.userData.isMovable&&(is(r),je()),e&&y.mode==="edit"&&He(r)}function Gt(r){y.selectedObject===r&&tt(),os(r),ss(r),r.userData.helper&&y.scene.remove(r.userData.helper),r.parent?r.parent.remove(r):y.scene.remove(r),rs(r),je()}function Wt(r){const e=y.scene.getObjectByProperty("uuid",r);e&&Gt(e)}function is(r){r.userData.isMovable&&r.parent===y.scene&&(J.includes(r)||J.push(r))}function rs(r){const e=J.indexOf(r);e!==-1&&J.splice(e,1)}function as(){const r=[];y.scene.children.forEach(e=>{e.userData.isMovable&&r.push(e)}),J=r,je()}function je(){Oe==null||Oe([...J])}function zt(r){se=r}function Ft(r){Ye=r}function qt(r){Oe=r}function Xt(){return J}function Ut(){return y.selectedObject}function ls(r,e,t){if(!y.scene)return;const s=be.get(r);if(s){const n=ke(s);n&&n.updateItemByCode(e,t)}}function cs(){return y.scene}function Kt(){return y.camera}function ds(){return y.renderer}async function Yt(){var u,A,h;G==null||G(!0),await new Promise(p=>setTimeout(p,50)),tt();const r=y.scene;if(!r)return G==null||G(!1),"{}";const e=[],t=new Map,s=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 b=p;if(b.element){const g=b.element.querySelector("[data-panel-title]"),m=[];b.element.querySelectorAll(".css2d-data-panel-item").forEach(w=>{var M,v,T;const x=w.querySelector(".item-label"),C=w.querySelector(".item-value");if(x&&C){const V=(x.textContent||"").trim(),W=((v=(M=C.childNodes[0])==null?void 0:M.textContent)==null?void 0:v.trim())||"",B=C.querySelector("span"),$=B?(B.textContent||"").trim():void 0,Ve=((T=w.getAttribute("data-item-code"))==null?void 0:T.trim())||void 0;m.push({label:V,value:W,unit:$,code:Ve})}}),p.parent&&s.set(p.parent.userData.id?p.parent.userData.id:p.parent.uuid,{title:((f=g==null?void 0:g.textContent)==null?void 0:f.trim())||"",items:m})}}}),e.forEach(p=>r.remove(p));const n=r.clone();n.children=n.children.filter(p=>p.userData.type!=="initFloor"),n.traverse(p=>{p.name&&p.name.startsWith("DataPanel_")&&p.parent&&p.parent.remove(p)});const o=n.toJSON();e.forEach(p=>r.add(p)),t.forEach((p,f)=>{f.userData.helper=p});const i={position:(u=y.camera)==null?void 0:u.position.toArray(),rotation:(A=y.camera)==null?void 0:A.rotation.toArray(),target:((h=y.orbitControls)==null?void 0:h.target.toArray())||[0,0,0]},c={};s.forEach((p,f)=>{c[f]=p});const d=JSON.stringify({scene:o,camera:i,dataPanels:c});return G==null||G(!1),d}function Zt(r,e="edit",t){var i,c,d;const s=typeof r=="string"?JSON.parse(r):r,o=new E.ObjectLoader().parse(s);o.type==="Scene"?y.scene=o:(i=y.scene)==null||i.add(o),t&&((c=y.scene)==null||c.traverse(u=>{const A=u.userData.id||u.uuid,h=t[A];if(h&&u.userData.isMovable){ns(u);const p=new _e({title:h.title,items:h.items});p.attachTo(u),p.visible=!1,console.log("panel",p),Dt(u,p)}})),e==="edit"&&((d=y.scene)==null||d.traverse(u=>{var A;if(u.type==="DirectionalLight"){const h=u;if(!h.userData.helper){const p=new E.DirectionalLightHelper(h,1);p.userData.type="lightHelper",h.userData.helper=p,(A=y.scene)==null||A.add(p)}}}))}function Qt(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(n=>{n.map&&(n.map=null),n.lightMap&&(n.lightMap=null),n.aoMap&&(n.aoMap=null),n.emissiveMap&&(n.emissiveMap=null),n.bumpMap&&(n.bumpMap=null),n.normalMap&&(n.normalMap=null),n.displacementMap&&(n.displacementMap=null),n.roughnessMap&&(n.roughnessMap=null),n.metalnessMap&&(n.metalnessMap=null),n.alphaMap&&(n.alphaMap=null),n.envMap&&(n.envMap=null),n.dispose()})}const e=r.children.slice();for(const t of e)Qt(t)}function Jt(){Re!==null&&(cancelAnimationFrame(Re),Re=null),pe&&y.container&&(y.container.removeEventListener("click",pe),pe=null),me&&(window.removeEventListener("resize",me),me=null),y.orbitControls&&(y.orbitControls.dispose(),y.orbitControls=null),y.transformControls&&(y.transformControls.dispose(),y.transformControls=null),y.scene&&(Qt(y.scene),y.scene=null),y.renderer&&(y.renderer.dispose(),y.renderer.domElement&&y.container&&y.container.removeChild(y.renderer.domElement),y.renderer=null),Nt(),y.camera=null,y.gridHelper=null,y.selectedObject=null,y.container=null,y.mode="",J=[],be.clear(),je(),Pe=!1,oe=!1}const us=/^[og]\s*(.+)?/,hs=/^mtllib /,As=/^usemtl /,fs=/^usemap /,mt=/\s+/,gt=new l.Vector3,ze=new l.Vector3,bt=new l.Vector3,It=new l.Vector3,F=new l.Vector3,De=new l.Color;function ps(){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 s=this.object&&typeof this.object.currentMaterial=="function"?this.object.currentMaterial():void 0;if(this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0),this.object={name:e||"",fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(n,o){const i=this._finalize(!1);i&&(i.inherited||i.groupCount<=0)&&this.materials.splice(i.index,1);const c={index:this.materials.length,name:n||"",mtllib:Array.isArray(o)&&o.length>0?o[o.length-1]:"",smooth:i!==void 0?i.smooth:this.smooth,groupStart:i!==void 0?i.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(d){const u={index:typeof d=="number"?d: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(c),c},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(n){const o=this.currentMaterial();if(o&&o.groupEnd===-1&&(o.groupEnd=this.geometry.vertices.length/3,o.groupCount=o.groupEnd-o.groupStart,o.inherited=!1),n&&this.materials.length>1)for(let i=this.materials.length-1;i>=0;i--)this.materials[i].groupCount<=0&&this.materials.splice(i,1);return n&&this.materials.length===0&&this.materials.push({name:"",smooth:this.smooth}),o}},s&&s.name&&typeof s.clone=="function"){const n=s.clone(0);n.inherited=!0,this.object.materials.push(n)}this.objects.push(this.object)},finalize:function(){this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0)},parseVertexIndex:function(e,t){const s=parseInt(e,10);return(s>=0?s-1:s+t/3)*3},parseNormalIndex:function(e,t){const s=parseInt(e,10);return(s>=0?s-1:s+t/3)*3},parseUVIndex:function(e,t){const s=parseInt(e,10);return(s>=0?s-1:s+t/2)*2},addVertex:function(e,t,s){const n=this.vertices,o=this.object.geometry.vertices;o.push(n[e+0],n[e+1],n[e+2]),o.push(n[t+0],n[t+1],n[t+2]),o.push(n[s+0],n[s+1],n[s+2])},addVertexPoint:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,s){const n=this.normals,o=this.object.geometry.normals;o.push(n[e+0],n[e+1],n[e+2]),o.push(n[t+0],n[t+1],n[t+2]),o.push(n[s+0],n[s+1],n[s+2])},addFaceNormal:function(e,t,s){const n=this.vertices,o=this.object.geometry.normals;gt.fromArray(n,e),ze.fromArray(n,t),bt.fromArray(n,s),F.subVectors(bt,ze),It.subVectors(gt,ze),F.cross(It),F.normalize(),o.push(F.x,F.y,F.z),o.push(F.x,F.y,F.z),o.push(F.x,F.y,F.z)},addColor:function(e,t,s){const n=this.colors,o=this.object.geometry.colors;n[e]!==void 0&&o.push(n[e+0],n[e+1],n[e+2]),n[t]!==void 0&&o.push(n[t+0],n[t+1],n[t+2]),n[s]!==void 0&&o.push(n[s+0],n[s+1],n[s+2])},addUV:function(e,t,s){const n=this.uvs,o=this.object.geometry.uvs;o.push(n[e+0],n[e+1]),o.push(n[t+0],n[t+1]),o.push(n[s+0],n[s+1])},addDefaultUV:function(){const e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){const t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,s,n,o,i,c,d,u){const A=this.vertices.length;let h=this.parseVertexIndex(e,A),p=this.parseVertexIndex(t,A),f=this.parseVertexIndex(s,A);if(this.addVertex(h,p,f),this.addColor(h,p,f),c!==void 0&&c!==""){const b=this.normals.length;h=this.parseNormalIndex(c,b),p=this.parseNormalIndex(d,b),f=this.parseNormalIndex(u,b),this.addNormal(h,p,f)}else this.addFaceNormal(h,p,f);if(n!==void 0&&n!==""){const b=this.uvs.length;h=this.parseUVIndex(n,b),p=this.parseUVIndex(o,b),f=this.parseUVIndex(i,b),this.addUV(h,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 s=0,n=e.length;s<n;s++){const o=this.parseVertexIndex(e[s],t);this.addVertexPoint(o),this.addColor(o)}},addLineGeometry:function(e,t){this.object.geometry.type="Line";const s=this.vertices.length,n=this.uvs.length;for(let o=0,i=e.length;o<i;o++)this.addVertexLine(this.parseVertexIndex(e[o],s));for(let o=0,i=t.length;o<i;o++)this.addUVLine(this.parseUVIndex(t[o],n))}};return r.startObject("",!1),r}class ms extends l.Loader{constructor(e){super(e),this.materials=null}load(e,t,s,n){const o=this,i=new l.FileLoader(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,function(c){try{t(o.parse(c))}catch(d){n?n(d):console.error(d),o.manager.itemError(e)}},s,n)}setMaterials(e){return this.materials=e,this}parse(e){const t=new ps;e.indexOf(`\r
|
|
40
|
+
`,e.appendChild(n)})}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 E.Box3().setFromObject(e),s=new E.Vector3;t.getSize(s);const n=s.y/2+this.options.offsetY;this.css2dObject||(this.css2dObject=new zn(this.container),this.css2dObject.name=`DataPanel_${e.name||e.uuid}`,this.css2dObject.center.set(.5,1)),this.css2dObject.position.set(0,n,0),e.add(this.css2dObject),this.attachedObject=e}detach(){this.css2dObject&&this.attachedObject&&this.attachedObject.remove(this.css2dObject),this.attachedObject=null}show(){this._visible=!0,this.css2dObject&&(this.css2dObject.visible=!0)}hide(){this._visible=!1,this.css2dObject&&(this.css2dObject.visible=!1)}get visible(){return this._visible}set visible(e){e?this.show():this.hide()}setTitle(e){var s;this.options.title=e;const t=(s=this.container)==null?void 0:s.querySelector("[data-panel-title]");e?t?t.textContent=e:this.rebuildPanel():t&&t.remove()}getTitle(){return this.options.title||""}setItems(e){var s;this.options.items=[...e];const t=(s=this.container)==null?void 0:s.querySelector("[data-panel-list]");t&&this.renderItems(t,this.options.items)}getItems(){return[...this.options.items||[]]}addItem(e){var s;this.options.items.push(e);const t=(s=this.container)==null?void 0:s.querySelector("[data-panel-list]");t&&this.renderItems(t,this.options.items)}removeItem(e){var s;this.options.items=this.options.items.filter(n=>n.label!==e);const t=(s=this.container)==null?void 0:s.querySelector("[data-panel-list]");t&&this.renderItems(t,this.options.items)}updateItem(e,t,s){var o;const n=this.options.items.find(i=>i.label===e);if(n){n.value=t,s!==void 0&&(n.unit=s);const i=(o=this.container)==null?void 0:o.querySelector("[data-panel-list]");i&&this.renderItems(i,this.options.items)}}updateItemByCode(e,t){var n;const s=this.options.items.find(o=>o.code===e);if(s){s.value=t;const o=(n=this.container)==null?void 0:n.querySelector("[data-panel-list]");o&&this.renderItems(o,this.options.items)}}clearItems(){var t;this.options.items=[];const e=(t=this.container)==null?void 0:t.querySelector("[data-panel-list]");e&&this.renderItems(e,[])}rebuildPanel(){const e=this._visible,t=this.attachedObject;this.css2dObject&&this.attachedObject&&this.attachedObject.remove(this.css2dObject),this.buildPanel(),t&&(this.attachedObject=t,t.add(this.css2dObject),e||this.hide())}updateOptions(e){this.options={...this.options,...e},this.rebuildPanel()}setOffsetY(e){if(this.options.offsetY=e,this.css2dObject&&this.attachedObject){const t=new E.Box3().setFromObject(this.attachedObject),s=new E.Vector3;t.getSize(s),this.css2dObject.position.set(0,s.y/2+e,0)}}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 Se=new WeakMap;function Dt(r,e){const t=a.toRaw(r);Se.set(t,e),t.userData._hasDataPanel=!0}function ke(r){return Se.get(a.toRaw(r))||null}function Tt(r){const e=a.toRaw(r),t=Se.get(e);t&&(t.dispose(),Se.delete(e)),e.userData._hasDataPanel=void 0}let N=null;function Pt(r){return N?(N.domElement.parentNode!==r&&r.appendChild(N.domElement),N):(N=new Fn,N.setSize(r.clientWidth,r.clientHeight),N.domElement.style.position="absolute",N.domElement.style.top="0",N.domElement.style.left="0",N.domElement.style.pointerEvents="none",r.appendChild(N.domElement),N)}function qn(){return N}function Ot(r,e){N&&N.render(r,e)}function Rt(r,e){N&&N.setSize(r,e)}function Nt(){N&&(N.domElement.parentNode&&N.domElement.parentNode.removeChild(N.domElement),N=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 Pe=!1,oe=!1,Ke=[];const Xn=16755200;let se=null,Ye=null,Oe=null,J=[];const be=new Map;let Le,Re=null,pe=null,me=null;function St(r,e="edit",t){y.container=r,y.mode=e,Un(),Kn(),Zn(),t&&(Zt(t.scene,e,t.dataPanels),t!=null&&t.camera&&(y.defaultMainCamera=t.camera,$e(!0))),Jn(),Qn(),Le&&y.orbitControls&&(y.orbitControls.target.fromArray(Le),y.orbitControls.update()),as(),Lt(),pe=s=>es(s),me=()=>$n(),e==="edit"&&r.addEventListener("click",pe),window.addEventListener("resize",me),t||_n(),e==="edit"&&Yn()}function Un(){const r=new E.WebGLRenderer({antialias:!0,alpha:!0});r.setSize(y.container.clientWidth,y.container.clientHeight),r.setPixelRatio(Math.min(window.devicePixelRatio,2)),r.shadowMap.enabled=!0,r.shadowMap.type=E.PCFSoftShadowMap,y.container.appendChild(r.domElement),y.renderer=r}function Kn(){y.scene=new E.Scene,y.scene.name="sl_scene"}function Yn(){const r=new E.GridHelper(30,30,8956671,3364232);r.name="地板",r.userData.type="initFloor",y.scene.add(r),y.gridHelper=r;const e=new E.PlaneGeometry(30,30),t=new E.ShadowMaterial({opacity:.3,color:0}),s=new E.Mesh(e,t);s.rotation.x=-Math.PI/2,s.position.y=-.01,s.name="阴影接收平面",s.userData.type="initFloor",s.receiveShadow=!0,y.scene.add(s)}function Zn(){const r=y.container,e=r.clientWidth/r.clientHeight,t=new E.PerspectiveCamera(45,e,.1,1e3);t.position.set(0,6,15),t.lookAt(0,0,0),y.camera=t}function $e(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(),Le=e.target;return}if(!y.camera||!y.orbitControls)return;const t=y.camera.position.clone(),s=y.orbitControls.target.clone(),n=new E.Vector3(e.position[0],e.position[1],e.position[2]),o=e.target?new E.Vector3(e.target[0],e.target[1],e.target[2]):new E.Vector3(0,0,0);y.orbitControls.enabled=!1,new ge.Tween({x:t.x,y:t.y,z:t.z,tx:s.x,ty:s.y,tz:s.z}).to({x:n.x,y:n.y,z:n.z,tx:o.x,ty:o.y,tz:o.z},1e3).easing(ge.Easing.Quadratic.InOut).onUpdate(i=>{y.camera.position.set(i.x,i.y,i.z),y.orbitControls.target.set(i.tx,i.ty,i.tz),y.orbitControls.update()}).onComplete(()=>{Le=e.target,y.orbitControls.enabled=!0}).start()}function Qn(){const r=new yn(y.camera,y.renderer.domElement);r.minDistance=0,r.maxDistance=1/0,r.addEventListener("start",()=>{Pe=!1}),r.addEventListener("change",()=>{Pe=!0}),r.addEventListener("end",()=>{Pe&&(oe=!0,setTimeout(()=>{oe=!1},200))}),y.orbitControls=r}function Jn(){const r=new Sn(y.camera,y.renderer.domElement);r.addEventListener("dragging-changed",e=>{y.orbitControls.enabled=!e.value,e.value||(oe=!0,setTimeout(()=>{oe=!1},200))}),r.addEventListener("objectChange",()=>{const e=y.selectedObject;if(Ye&&e&&Ye(e),e&&e.type==="DirectionalLight"){const t=e.userData.helper;t&&t.update&&t.update()}}),y.scene.add(r.getHelper()),y.transformControls=r}function _n(){const r=new E.AmbientLight(16777215,1);y.scene.add(r)}function Lt(){var r,e;Re=requestAnimationFrame(Lt),ge.update(),(r=y.orbitControls)==null||r.update(),(e=y.renderer)==null||e.render(y.scene,y.camera),y.scene&&y.camera&&Ot(y.scene,y.camera),y.scene&&y.scene.traverse(t=>{if(t.userData.isWater&&t.type==="Mesh"){const s=t,n=s.material;if(n.normalMap){const o=s.userData.waterSpeed||{x:.005,y:.003};n.normalMap.offset.x+=o.x,n.normalMap.offset.y+=o.y}}})}function $n(){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),Rt(r,e))}function He(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,jt(r),console.log("选中",y.selectedObject),se==null||se(r))}let G=null;function kt(r){G=r}function Ne(r){G==null||G(r)}function Ht(r){y.transformControlsMode=r,y.transformControls&&y.transformControls.setMode(y.transformControlsMode)}function jt(r){et(),r.traverse(e=>{if(e.isMesh){const t=e,s=new E.EdgesGeometry(t.geometry),n=new E.LineBasicMaterial({color:Xn,depthTest:!0}),o=new E.LineSegments(s,n);e.add(o),Ke.push(o)}})}function et(){for(const r of Ke)r.parent&&r.parent.remove(r),r.geometry.dispose(),r.material.dispose();Ke=[]}function tt(){y.selectedObject&&(et(),y.transformControls.detach(),y.selectedObject=null,se==null||se(null))}function Vt(r){Bt(r);let e;if(be.forEach(t=>{t.userData.id==r&&(e=t),t.children&&t.children.forEach(s=>{s.name&&s.name.startsWith("DataPanel_")&&(s.visible=!1)})}),!e)return et();e.children.forEach(t=>{t.name&&t.name.startsWith("DataPanel_")&&(t.visible=!0)}),jt(e)}function es(r){if(oe){oe=!1;return}const e=y.renderer.domElement.getBoundingClientRect(),t=new E.Vector2((r.clientX-e.left)/e.width*2-1,-((r.clientY-e.top)/e.height)*2+1),s=new E.Raycaster;s.setFromCamera(t,y.camera);const n=[];y.scene.traverse(i=>{(i.userData.isMovable||i.userData.type==="lightHelper")&&n.push(i)});const o=s.intersectObjects(n);if(o.length>0){let i=ts(o[0].object);He(i)}else tt()}function ts(r){if(r.type==="Line"){const e=r.parent;switch(e.type){case"DirectionalLightHelper":return e.light;default:return r}}return r}function Bt(r,e=500){var f;if(!y.camera||!y.orbitControls)return;let t;(f=y.scene)==null||f.traverse(b=>{b.userData.id==r&&(t=b)});let s=null;t.userData.closeUpView&&typeof t.userData.closeUpView.x=="number"&&typeof t.userData.closeUpView.y=="number"&&typeof t.userData.closeUpView.z=="number"&&(s=t.userData.closeUpView);const n=new E.Vector3;t.getWorldPosition(n);const i=new E.Box3().setFromObject(t).getSize(new E.Vector3),c=Math.max(i.x,i.y,i.z)*.5,d=Math.max(c*3.5,5),u=new E.Vector3().copy(y.camera.position).sub(n).normalize();u.lengthSq()<.001&&u.set(0,0,1);const A=n.clone().add(u.multiplyScalar(d)),h=y.camera.position.clone(),p=y.orbitControls.target.clone();new ge.Tween({x:h.x,y:h.y,z:h.z,tx:p.x,ty:p.y,tz:p.z}).to({x:s?s.x:A.x,y:s?s.y:A.y,z:s?s.z:A.z,tx:n.x,ty:n.y,tz:n.z},e).easing(ge.Easing.Quadratic.InOut).onUpdate(b=>{y.camera.position.set(b.x,b.y,b.z),y.orbitControls.target.set(b.tx,b.ty,b.tz),y.orbitControls.update()}).start()}function ns(r){r.userData.id&&be.set(String(r.userData.id),r)}function ss(r){r.userData.id&&be.delete(String(r.userData.id))}function os(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 ie(r,e=!1){y.scene.add(r),r.userData.isMovable&&(is(r),je()),e&&y.mode==="edit"&&He(r)}function Gt(r){y.selectedObject===r&&tt(),os(r),ss(r),r.userData.helper&&y.scene.remove(r.userData.helper),r.parent?r.parent.remove(r):y.scene.remove(r),rs(r),je()}function Wt(r){const e=y.scene.getObjectByProperty("uuid",r);e&&Gt(e)}function is(r){r.userData.isMovable&&r.parent===y.scene&&(J.includes(r)||J.push(r))}function rs(r){const e=J.indexOf(r);e!==-1&&J.splice(e,1)}function as(){const r=[];y.scene.children.forEach(e=>{e.userData.isMovable&&r.push(e)}),J=r,je()}function je(){Oe==null||Oe([...J])}function zt(r){se=r}function Ft(r){Ye=r}function qt(r){Oe=r}function Xt(){return J}function Ut(){return y.selectedObject}function ls(r,e,t){if(!y.scene)return;const s=be.get(r);if(s){const n=ke(s);n&&n.updateItemByCode(e,t)}}function cs(){return y.scene}function Kt(){return y.camera}function ds(){return y.renderer}async function Yt(){var u,A,h;G==null||G(!0),await new Promise(p=>setTimeout(p,50)),tt();const r=y.scene;if(!r)return G==null||G(!1),"{}";const e=[],t=new Map,s=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 b=p;if(b.element){const g=b.element.querySelector("[data-panel-title]"),m=[];b.element.querySelectorAll(".css2d-data-panel-item").forEach(w=>{var M,v,T;const x=w.querySelector(".item-label"),C=w.querySelector(".item-value");if(x&&C){const V=(x.textContent||"").trim(),W=((v=(M=C.childNodes[0])==null?void 0:M.textContent)==null?void 0:v.trim())||"",B=C.querySelector("span"),$=B?(B.textContent||"").trim():void 0,Ve=((T=w.getAttribute("data-item-code"))==null?void 0:T.trim())||void 0;m.push({label:V,value:W,unit:$,code:Ve})}}),p.parent&&s.set(p.parent.userData.id?p.parent.userData.id:p.parent.uuid,{title:((f=g==null?void 0:g.textContent)==null?void 0:f.trim())||"",items:m})}}}),e.forEach(p=>r.remove(p));const n=r.clone();n.children=n.children.filter(p=>p.userData.type!=="initFloor"),n.traverse(p=>{p.name&&p.name.startsWith("DataPanel_")&&p.parent&&p.parent.remove(p)});const o=n.toJSON();e.forEach(p=>r.add(p)),t.forEach((p,f)=>{f.userData.helper=p});const i={position:(u=y.camera)==null?void 0:u.position.toArray(),rotation:(A=y.camera)==null?void 0:A.rotation.toArray(),target:((h=y.orbitControls)==null?void 0:h.target.toArray())||[0,0,0]},c={};s.forEach((p,f)=>{c[f]=p});const d=JSON.stringify({scene:o,camera:i,dataPanels:c});return G==null||G(!1),d}function Zt(r,e="edit",t){var i,c,d;const s=typeof r=="string"?JSON.parse(r):r,o=new E.ObjectLoader().parse(s);o.type==="Scene"?y.scene=o:(i=y.scene)==null||i.add(o),t&&((c=y.scene)==null||c.traverse(u=>{const A=u.userData.id||u.uuid,h=t[A];if(h&&u.userData.isMovable){ns(u);const p=new _e({title:h.title,items:h.items});p.attachTo(u),p.visible=!1,console.log("panel",p),Dt(u,p)}})),e==="edit"&&((d=y.scene)==null||d.traverse(u=>{var A;if(u.type==="DirectionalLight"){const h=u;if(!h.userData.helper){const p=new E.DirectionalLightHelper(h,1);p.userData.type="lightHelper",h.userData.helper=p,(A=y.scene)==null||A.add(p)}}}))}function Qt(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(n=>{n.map&&(n.map=null),n.lightMap&&(n.lightMap=null),n.aoMap&&(n.aoMap=null),n.emissiveMap&&(n.emissiveMap=null),n.bumpMap&&(n.bumpMap=null),n.normalMap&&(n.normalMap=null),n.displacementMap&&(n.displacementMap=null),n.roughnessMap&&(n.roughnessMap=null),n.metalnessMap&&(n.metalnessMap=null),n.alphaMap&&(n.alphaMap=null),n.envMap&&(n.envMap=null),n.dispose()})}const e=r.children.slice();for(const t of e)Qt(t)}function Jt(){Re!==null&&(cancelAnimationFrame(Re),Re=null),pe&&y.container&&(y.container.removeEventListener("click",pe),pe=null),me&&(window.removeEventListener("resize",me),me=null),y.orbitControls&&(y.orbitControls.dispose(),y.orbitControls=null),y.transformControls&&(y.transformControls.dispose(),y.transformControls=null),y.scene&&(Qt(y.scene),y.scene=null),y.renderer&&(y.renderer.dispose(),y.renderer.domElement&&y.container&&y.container.removeChild(y.renderer.domElement),y.renderer=null),Nt(),y.camera=null,y.gridHelper=null,y.selectedObject=null,y.container=null,y.mode="",J=[],be.clear(),je(),Pe=!1,oe=!1}const us=/^[og]\s*(.+)?/,hs=/^mtllib /,As=/^usemtl /,fs=/^usemap /,mt=/\s+/,gt=new l.Vector3,ze=new l.Vector3,bt=new l.Vector3,It=new l.Vector3,F=new l.Vector3,De=new l.Color;function ps(){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 s=this.object&&typeof this.object.currentMaterial=="function"?this.object.currentMaterial():void 0;if(this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0),this.object={name:e||"",fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(n,o){const i=this._finalize(!1);i&&(i.inherited||i.groupCount<=0)&&this.materials.splice(i.index,1);const c={index:this.materials.length,name:n||"",mtllib:Array.isArray(o)&&o.length>0?o[o.length-1]:"",smooth:i!==void 0?i.smooth:this.smooth,groupStart:i!==void 0?i.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(d){const u={index:typeof d=="number"?d: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(c),c},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(n){const o=this.currentMaterial();if(o&&o.groupEnd===-1&&(o.groupEnd=this.geometry.vertices.length/3,o.groupCount=o.groupEnd-o.groupStart,o.inherited=!1),n&&this.materials.length>1)for(let i=this.materials.length-1;i>=0;i--)this.materials[i].groupCount<=0&&this.materials.splice(i,1);return n&&this.materials.length===0&&this.materials.push({name:"",smooth:this.smooth}),o}},s&&s.name&&typeof s.clone=="function"){const n=s.clone(0);n.inherited=!0,this.object.materials.push(n)}this.objects.push(this.object)},finalize:function(){this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0)},parseVertexIndex:function(e,t){const s=parseInt(e,10);return(s>=0?s-1:s+t/3)*3},parseNormalIndex:function(e,t){const s=parseInt(e,10);return(s>=0?s-1:s+t/3)*3},parseUVIndex:function(e,t){const s=parseInt(e,10);return(s>=0?s-1:s+t/2)*2},addVertex:function(e,t,s){const n=this.vertices,o=this.object.geometry.vertices;o.push(n[e+0],n[e+1],n[e+2]),o.push(n[t+0],n[t+1],n[t+2]),o.push(n[s+0],n[s+1],n[s+2])},addVertexPoint:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,s){const n=this.normals,o=this.object.geometry.normals;o.push(n[e+0],n[e+1],n[e+2]),o.push(n[t+0],n[t+1],n[t+2]),o.push(n[s+0],n[s+1],n[s+2])},addFaceNormal:function(e,t,s){const n=this.vertices,o=this.object.geometry.normals;gt.fromArray(n,e),ze.fromArray(n,t),bt.fromArray(n,s),F.subVectors(bt,ze),It.subVectors(gt,ze),F.cross(It),F.normalize(),o.push(F.x,F.y,F.z),o.push(F.x,F.y,F.z),o.push(F.x,F.y,F.z)},addColor:function(e,t,s){const n=this.colors,o=this.object.geometry.colors;n[e]!==void 0&&o.push(n[e+0],n[e+1],n[e+2]),n[t]!==void 0&&o.push(n[t+0],n[t+1],n[t+2]),n[s]!==void 0&&o.push(n[s+0],n[s+1],n[s+2])},addUV:function(e,t,s){const n=this.uvs,o=this.object.geometry.uvs;o.push(n[e+0],n[e+1]),o.push(n[t+0],n[t+1]),o.push(n[s+0],n[s+1])},addDefaultUV:function(){const e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){const t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,s,n,o,i,c,d,u){const A=this.vertices.length;let h=this.parseVertexIndex(e,A),p=this.parseVertexIndex(t,A),f=this.parseVertexIndex(s,A);if(this.addVertex(h,p,f),this.addColor(h,p,f),c!==void 0&&c!==""){const b=this.normals.length;h=this.parseNormalIndex(c,b),p=this.parseNormalIndex(d,b),f=this.parseNormalIndex(u,b),this.addNormal(h,p,f)}else this.addFaceNormal(h,p,f);if(n!==void 0&&n!==""){const b=this.uvs.length;h=this.parseUVIndex(n,b),p=this.parseUVIndex(o,b),f=this.parseUVIndex(i,b),this.addUV(h,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 s=0,n=e.length;s<n;s++){const o=this.parseVertexIndex(e[s],t);this.addVertexPoint(o),this.addColor(o)}},addLineGeometry:function(e,t){this.object.geometry.type="Line";const s=this.vertices.length,n=this.uvs.length;for(let o=0,i=e.length;o<i;o++)this.addVertexLine(this.parseVertexIndex(e[o],s));for(let o=0,i=t.length;o<i;o++)this.addUVLine(this.parseUVIndex(t[o],n))}};return r.startObject("",!1),r}class ms extends l.Loader{constructor(e){super(e),this.materials=null}load(e,t,s,n){const o=this,i=new l.FileLoader(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,function(c){try{t(o.parse(c))}catch(d){n?n(d):console.error(d),o.manager.itemError(e)}},s,n)}setMaterials(e){return this.materials=e,this}parse(e){const t=new ps;e.indexOf(`\r
|
|
41
41
|
`)!==-1&&(e=e.replace(/\r\n/g,`
|
|
42
42
|
`)),e.indexOf(`\\
|
|
43
43
|
`)!==-1&&(e=e.replace(/\\\n/g,""));const s=e.split(`
|