@tomorrowevening/hermes 0.1.30 → 0.1.31
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/hermes.cjs.js
CHANGED
|
@@ -140,4 +140,4 @@ void main() {
|
|
|
140
140
|
#include <clipping_planes_fragment>
|
|
141
141
|
if (opacity < 0.015) discard;
|
|
142
142
|
gl_FragColor = vec4(vec3(vUv, 0.0), opacity);
|
|
143
|
-
}`;class vi extends m.ShaderMaterial{constructor(){super({defines:{USE_UV:""},uniforms:{opacity:{value:1}},vertexShader:vn,fragmentShader:_n,transparent:!0})}}class _i extends Zt{constructor(){super(),this.colorNode=ze.vec4(ze.uv(),0,1)}}class W extends m.EventDispatcher{static DRAG_START="Transform::dragStart";static DRAG_END="Transform::dragEnd";static _instance;three;activeCamera;controls=new Map;visibility=new Map;setApp(e){this.three=e,this.three.addEventListener(U.SET_SCENE,this.setScene)}clear(){for(const e of this.controls.values()){e.detach(),e.disconnect();const t=e.getHelper();re(t)}this.controls=new Map,this.visibility=new Map}add(e){let t=this.controls.get(e);if(t===void 0){const s=document.querySelector(".clickable");t=new Fi.TransformControls(this.activeCamera,s),t.getHelper().name=e,t.setSize(.5),t.setSpace("local"),this.controls.set(e,t),this.visibility.set(e,!0),t.addEventListener("mouseDown",()=>{this.dispatchEvent({type:W.DRAG_START})}),t.addEventListener("mouseUp",()=>{this.dispatchEvent({type:W.DRAG_END})}),t.addEventListener("dragging-changed",n=>{G.instance?.toggleOrbitControls(n.value)})}return t}get(e){return this.controls.get(e)}remove(e){const t=this.get(e);return t===void 0?!1:(t.detach(),t.disconnect(),re(t.getHelper()),this.controls.delete(e),!0)}enabled(e){this.controls.forEach(t=>{t.enabled=e})}updateCamera(e,t){this.activeCamera=e,this.controls.forEach(s=>{s.camera!==e&&(s.camera=e,e.getWorldPosition(s.cameraPosition),e.getWorldQuaternion(s.cameraQuaternion)),s.domElement!==t&&(s.disconnect(),s.domElement=t,s.connect(t))})}show(){this.controls.forEach(e=>{const t=e.getHelper(),s=this.visibility.get(t.name);s!==void 0&&(t.visible=s)})}hide(){this.controls.forEach(e=>{const t=e.getHelper();this.visibility.set(t.name,t.visible),t.visible=!1})}setScene=()=>{this.clear()};static get instance(){return W._instance||(W._instance=new W),W._instance}}const Cn=new w.BoxGeometry,ft=new w.Vector2;class Ke extends w.Object3D{curve=new w.CatmullRomCurve3;line;draggable;curvePos;tension=.5;closed=!1;subdivide=50;curveType;offset=1;lineMaterial;_camera;_curvePercentage=0;_draggableScale=10;_transform;raycaster;draggedMat=new w.MeshBasicMaterial;parentGroup;group;constructor(e,t){const s=new w.Color($.lerp(.5,1,Math.random()),$.lerp(.5,1,Math.random()),$.lerp(.5,1,Math.random()));super(),this.name=e,this.lineMaterial=new w.LineBasicMaterial({color:s}),this.line=new w.Line(new w.BufferGeometry,this.lineMaterial),this.line.name="line",this.line.visible=!1,this.add(this.line),this._camera=t,this.curveType="catmullrom",this.draggedMat.color=s,this.draggable=new w.Object3D,this.draggable.name="draggablePoints",this.add(this.draggable),this.curvePos=new w.Mesh(new w.SphereGeometry(1.5),new w.MeshBasicMaterial({color:s})),this.curvePos.name="curvePos",this.curvePos.scale.setScalar(this._draggableScale),this.curvePos.visible=!1,this.add(this.curvePos),this.raycaster=new w.Raycaster,this.raycaster.params.Line.threshold=3,this.enable()}enable(){document.addEventListener("pointerdown",this.onMouseClick)}disable(){document.removeEventListener("pointerdown",this.onMouseClick)}dispose=()=>{this._transform&&(this._transform.removeEventListener("objectChange",this.updateSpline),W.instance.remove(this.name)),this.disable(),this.parentGroup.removeGroup(this.name)};hideTransform=()=>{this._transform?.detach()};exportSpline=()=>{const e=[];this.draggable.children.forEach(t=>{e.push([X(t.position.x,3),X(t.position.y,3),X(t.position.z,3)])}),$t({name:this.name,points:e,tension:this.tension,closed:this.closed,subdivide:this.subdivide,type:this.curveType}),console.log("Spline copied!")};showPoints=(e=!0)=>{this.draggable.visible=e};addPoints=(e=[])=>{if(e.length>0){const t=e.length-1;for(let s=0;s<t;s++)this.addPoint(e[s],!1);this.addPoint(e[t])}};addPoint=(e,t=!0)=>{const s=this.draggable.children.length,n=new w.Mesh(Cn,this.draggedMat);n.name=`point_${s}`,n.position.copy(e),n.scale.setScalar(this._draggableScale),this.draggable.add(n),this._transform?.attach(n);const a=this.points.length>1;return a&&t&&this.updateSpline(),this.line.visible=a,this.updateCurrentPoint(),n};addNextPt=()=>{const e=this.draggable.children.length,t=e>1?this.draggable.children[e-1].position.clone():new w.Vector3,s=this.addPoint(t);this.updateField(s.position)};removePoint=e=>{if(this._transform?.object===e){this._transform?.detach();const t=this.draggable.children[this.draggable.children.length-1];this._transform?.attach(t),this.updateField(t.position)}re(e),this.updateSpline()};removePointAt=e=>{const t=this.draggable.children[e];this.removePoint(t)};removeSelectedPt=()=>{this._transform?.object!==void 0&&this.removePoint(this._transform?.object)};updateLastPoint(e){const t=this.draggable.children.length;t>0&&(this.draggable.children[t-1].position.copy(e),this.updateSpline())}updateSpline=()=>{this.points.length<2||(this.curve=new w.CatmullRomCurve3(this.points,this.closed,this.curveType,this.tension),this.line.geometry.dispose(),this.line.geometry=new w.BufferGeometry().setFromPoints(this.curve.getPoints(this.subdivide)),this.curvePos.position.copy(this.getPointAt(this._curvePercentage)))};updateField(e){this.group.current?.setField("Current Point",e)}onMouseClick=e=>{if(!G.instance||!G.instance.currentWindow||this._transform&&!this._transform.getHelper().visible)return;const s=G.instance.currentWindow.current.getBoundingClientRect();ft.x=(e.clientX-s.x)/s.width*2-1,ft.y=-((e.clientY-s.y)/s.height)*2+1,this.raycaster.setFromCamera(ft,this.camera);const n=this.raycaster.intersectObjects(this.draggable.children,!1);if(n.length>0){const a=n[0].object;a!==this._transform?.object&&(this._transform?.attach(a),this.updateField(a.position))}};getPointAt(e){return this.curve.points.length>1?this.curve.getPointAt(e):this.curve.points.length===1?this.curve.points[0]:new w.Vector3}getTangentAt(e){return this.curve.getTangentAt(e)}get points(){const e=[];return this.draggable.children.forEach(t=>{e.push(t.position)}),e}get total(){return this.draggable.children.length}get draggableScale(){return this._draggableScale}set draggableScale(e){this._draggableScale=e,this.draggable.children.forEach(t=>t.scale.setScalar(e)),this.curvePos.scale.setScalar(e)}get camera(){return this._camera}set camera(e){this._camera=e,this._transform!==void 0&&(this._transform.camera=e)}get curvePercentage(){return this._curvePercentage}set curvePercentage(e){this._curvePercentage=e,this.curvePos.position.copy(this.getPointAt(e))}updateCurrentPoint(){if(this._transform?.object&&this.group){const e=this._transform?.object;e.name.search("point")>-1&&this.updateField(e.position)}}onUpdateTransform=()=>{this.updateCurrentPoint(),this.updateSpline()};initDebug(e,t){const s=this.draggable.children;this.visible=t,this.parentGroup=e,this._transform=W.instance.add(this.name),this._transform.camera=this._camera,this._transform.addEventListener("objectChange",this.onUpdateTransform),s.length>0&&this._transform.attach(s[s.length-1]),G.instance?.helpersContainer.add(this._transform.getHelper());const n=s.length>0?s[s.length-1].position:{x:0,y:0,z:0};this.group=e.addGroup({title:this.name,expanded:t,items:[{prop:"Closed",type:"boolean",value:this.closed},{prop:"Visible",type:"boolean",value:this.visible},{prop:"Show Position",type:"boolean",value:this.curvePos.visible},{prop:"Show Points",type:"boolean",value:this.draggable.visible},{prop:"Color",type:"color",value:`#${this.draggedMat.color.getHexString()}`},{prop:"Curve",type:"option",options:[{title:"Catmullrom",value:"catmullrom"},{title:"Centripetal",value:"centripetal"},{title:"Chordal",value:"chordal"}]},{prop:"Draggable Scale",type:"range",min:.01,max:100,step:.01,value:this._draggableScale},{prop:"Subdivide",type:"range",min:1,max:1e3,step:1,value:this.subdivide},{prop:"Tension",type:"range",min:0,max:1,step:.01,value:this.tension},{prop:"New Pt Offset",type:"range",min:0,max:10,value:this.offset},{prop:"Curve At",type:"range",min:0,max:1,step:.01,value:0},{prop:"Toggle Transform",type:"button"},{prop:"Add Point",type:"button"},{prop:"Remove Point",type:"button"},{prop:"Export",type:"button"},{prop:"Delete",type:"button"},{prop:"Current Point",type:"grid3",value:n}],onUpdate:(a,r)=>{switch(a){case"Closed":this.closed=r,this.updateSpline();break;case"Visible":this.visible=r;break;case"Color":this.lineMaterial.color.setStyle(r),this.draggedMat.color.setStyle(r);break;case"Curve":this.curveType=r,this.updateSpline();break;case"Draggable Scale":this.draggableScale=r;break;case"Subdivide":this.subdivide=r,this.updateSpline();break;case"Tension":this.tension=r,this.updateSpline();break;case"New Pt Offset":this.offset=r;break;case"Curve At":this.curvePos.position.copy(this.getPointAt(r));break;case"Show Position":this.curvePos.visible=r;break;case"Show Points":this.draggable.visible=r;break;case"Toggle Transform":this._transform&&(this._transform.getHelper().visible=!this._transform.getHelper().visible);break;case"Add Point":this.addNextPt();break;case"Remove Point":this.removeSelectedPt();break;case"Export":this.exportSpline();break;case"Delete":this.parent.currentSpline=null,re(this);break;case"Current Point":if(this.group.current&&this._transform?.object){const o=this._transform?.object;o.name.search("point")>-1&&(o.position.copy(r),this.updateSpline())}break}}}),this.draggable.children.forEach(a=>{this.debugPoint(a)})}debugPoint=e=>{e.name,e.visible=this.draggable.visible}}let Ze=0;class Ci extends m.Object3D{defaultScale=10;currentSpline=null;_camera;group=null;three;splineDataText="";constructor(e,t){super(),this.name="Spline Editor",this._camera=e,this.three=t,this.three.addEventListener(U.ADD_SPLINE,this.onAddSpline)}initDebug(){this.group=N.addEditorGroup({title:this.name,items:[{type:"field",prop:"Spline Data",value:"",disabled:!1},{type:"button",prop:"Import Spline"},{type:"button",prop:"New Spline"},{type:"boolean",prop:"Show Points",value:!0},{type:"boolean",prop:"Draw Mode",value:!1},{type:"boolean",prop:"Visible",value:this.visible},{type:"range",prop:"Default Scale",min:0,max:50,step:.01,value:this.defaultScale}],onUpdate:(e,t)=>{switch(e){case"New Spline":this.createSpline();break;case"Spline Data":this.splineDataText=t;break;case"Import Spline":this.createSplineFromJSON(JSON.parse(this.splineDataText));break;case"Show Points":this.showPoints(t);break;case"Visible":this.visible=t;break;case"Default Scale":this.defaultScale=t;break;case"Draw Mode":t?this.enableClickToDraw():this.disableClickToDraw();break}}})}dispose(){this.three.removeEventListener(U.ADD_SPLINE,this.onAddSpline),N.removeEditorGroup(this.name)}addSpline(e,t){e.draggableScale=this.defaultScale,e.hideTransform(),this.group?.current!==null&&e.initDebug(this.group.current,t),this.add(e),this.currentSpline=e}createSpline=(e=[])=>{const t=`Spline ${Ze+1}`,s=new Ke(t,this._camera);return s.addPoints(e),this.addSpline(s,!0),Ze++,s};createSplineFromArray=e=>{const t=[];return e.forEach(s=>{t.push(new m.Vector3(s[0],s[1],s[2]))}),this.createSpline(t)};createSplineFromCatmullRom=e=>this.createSpline(e.points);createSplineFromJSON=e=>{const t=[];e.points.forEach(n=>{t.push(new m.Vector3(n[0],n[1],n[2]))});const s=new Ke(e.name,this._camera);return s.closed=e.closed,s.subdivide=e.subdivide,s.tension=e.tension,s.type=e.type,s.addPoints(t),s.updateSpline(),this.addSpline(s,!1),s};showPoints=(e=!0)=>{this.children.forEach(t=>{t.showPoints(e)})};onAddSpline=e=>{const t=JSON.parse(e.value),s=t.name!==void 0?t.name:`Spline ${Ze+1}`,n=new Ke(s,this.camera);t.tension!==void 0&&(n.tension=t.tension),t.closed!==void 0&&(n.closed=t.closed),t.subdivide!==void 0&&(n.subdivide=t.subdivide),t.type!==void 0&&(n.curveType=t.type);const a=[];t.points.forEach(r=>{a.push(new m.Vector3(r[0],r[1],r[2]))}),n.addPoints(a),this.addSpline(n,!1),Ze++};isMouseDown=!1;enableClickToDraw(){document.querySelectorAll(".clickable").forEach(e=>{e.addEventListener("mousedown",this.onClickCanvas),e.addEventListener("mousemove",this.onMouseMove),e.addEventListener("mouseup",this.onMouseUp)})}disableClickToDraw(){document.querySelectorAll(".clickable").forEach(e=>{e.removeEventListener("mousedown",this.onClickCanvas),e.removeEventListener("mousemove",this.onMouseMove),e.removeEventListener("mouseup",this.onMouseUp)})}onClickCanvas=e=>{if(e.button!==0)return;if(this._camera.type!=="OrthographicCamera"){console.warn("Spline Editor - 3D Camera not supported in Draw Mode");return}const s=e.target.getBoundingClientRect(),n=(e.clientX-s.left)/s.width*2-1,a=-((e.clientY-s.top)/s.height)*2+1;if(G.instance){const o=new m.Raycaster;o.setFromCamera(new m.Vector2(n,a),this._camera);const c=o.intersectObjects(G.instance.helpersContainer.children,!0);for(let l=0;l<c.length;l++){const h=c[l];if(!(h.object.isLine||h.object.isTransformControlsPlane)&&h.object.isObject3D)return}}this.currentSpline===null&&(this.currentSpline=this.createSpline());const r=this.mouseToSplinePos(n,a,s.width,s.height);this.currentSpline?.addPoint(r),this.isMouseDown=!0};onMouseMove=e=>{if(!this.isMouseDown)return;const s=e.target.getBoundingClientRect(),n=(e.clientX-s.left)/s.width*2-1,a=-((e.clientY-s.top)/s.height)*2+1,r=this.mouseToSplinePos(n,a,s.width,s.height);this.currentSpline?.updateLastPoint(r),this.currentSpline?.updateField(r)};onMouseUp=()=>{this.isMouseDown=!1};mouseToSplinePos(e,t,s,n){const a=new m.Vector3,r=Math.PI/2,o=this._camera,c=o.zoom,l=o.rotation.x===-6123233995736766e-32&&o.rotation.y===0&&o.rotation.z===0,h=o.rotation.x===-Math.PI&&o.rotation.y===12246467991473532e-32&&o.rotation.z===Math.PI,u=o.rotation.x===-6162975822039155e-48&&o.rotation.y===-r&&o.rotation.z===0,p=o.rotation.x===-6162975822039155e-48&&o.rotation.y===r&&o.rotation.z===0,g=o.rotation.x===-1.5707953264174506&&o.rotation.y===0&&o.rotation.z===0,y=o.rotation.x===1.5707953264174506&&o.rotation.y===0&&o.rotation.z===0;let _=e,E=t;h||p?_*=-1:g&&(E*=-1);const v=s/2/c,C=n/2/c;if(this.currentSpline===null&&(this.currentSpline=this.createSpline()),l||h){const x=_*v+o.position.x,O=E*C+o.position.y;a.set(x,O,0)}else if(u||p){const x=_*v+o.position.z,O=E*C+o.position.y;a.set(0,O,x)}else if(g||y){const x=_*v+o.position.x,O=E*C+o.position.z;a.set(x,0,O)}return a}get camera(){return this._camera}set camera(e){this._camera=e,this.children.forEach(t=>{const s=t;s.camera=e})}}const Wt=["Single","Side by Side","Stacked","Quad"],yn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAC60lEQVRYhe2YT4hNcRTHP48xpmYaNAvRyEQxEhnKQljYsRm9/EmSyJiMFAsMZWNhJYoNIUVJ2VGiyb9ZzIpMpkQSahbGv9GMYWrM+1rc2zjvzvvdd+99rzdvMd+6de75nd+5387vnN/v/G5KEuWMKRNNIB8mCRaKiiL5qQb2ApuBuUAV0Ad0AJeB3sSeJRX6LJbULTf6JTUn9Z+KWMUpPyp/Avoa4CNQZ3Sj/lNpdL/xottR7AjOkHRUUpekN5I6JbVLavDH75lIfZN0UFKTpCWS0pJem/HeJBEMG6yV1ONYtgFJbZJ+GF1jDh+zJb03NuliEuwMkMo4yErS2RA/LcbuYVyCrm1mA7Dal/8Cu4FG4JD/HsTTkCy6a+SVMTPQuc1sBKb78nHghi+/A+YBxwL2lbhRY+ThuARdEVxu5JdGFvACr0otdoZ8Y4+Rn0Sn5sFFsMvI6YB9MzA1YJ8mN8k1wAHzfj4uQVdyrpI0aJL7oqTtkq4FiqPLyCOSbktqlbRL0jlJQ2b8QdwCUZ4qvhRStZL0XFK1pMd57CRvq5mfhKBriRfiFUMY6oD7eOdwPlQAN4G10dfWg+uouwXsiOssAj4AC+JMcEWwvnAuOTEr7gTXPmg34zagOwkbIIOXAo9CbDYBrcBXYN+4UUdy2sRflyS5zVNlfPX7ugpJW5V9nI7mmh+lYU0lCZ2B3TOnAVuAk0BTwC5nuhWro46KauBOQJch5OpRaoIW34GreGf+YZdRqS9NAj4Bp4ClQDvwOWxCqSM4ADQEdKE5XvbXzlITrAVe4TW+M6NMKDXBFLAMuAD0ACfIc7pMZBXXA2cY3/xmodQRHAL2A2+NLtj8ZiEKwUL/z2WMPAJcAVYALWSf8dZuDFGWeBHwKxm3sWYhiGG8Tfo6sA2vSfiSy4GrH3wGrDcfKSSKKf6v1E9yF0XK9Q1XBPuMXMw8HXTonQFwETwNzMFr64v1jzgFHIk9ybHEZYPJo65QlD3Bf2/Q/eaHPiSWAAAAAElFTkSuQmCC",bn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAETklEQVRYhe2YXYhVVRTHf3d0/JhyUrMpFbImM+whSa3Mynww+4AeIgiKoozooQ+KyMyXIAujF6OXqHyI6iEKKYgIP/owsjSFqCkprdDUTEcjbWZ0HHV+Pex1ucfb9Z57Z9REXHA4Z++99l7/s/ZZ/7X2KaiczNLwfwPIk9MA+yunNMAG4DHgV+BvoB3YFff2TPstYEyfrajVroI6Sr1GvahsbJC63HzZq04pmztSvU5tVRuqYRiYg78JeBR4HPg5ntdmxovz9wJfA3uAxuibDLQCA+IqynnAQuBuYCnwMLC1rx48U12U8cZqdWqMDcx4cI16qTpYbVKHqa+ovWUeHKsujn7VL9ULq2HI+wY7gVeBJdGeFu3J4ZUiy/cAXeHRRuAQsC/GC0B3eG4BcH/0tUV7czUAeVsMsBF4Kha9HZgCvAncAuwPnXHA0wFuGLANuDrGuoGDwFxgTqzzQ7RX5FrP2eLsdb76vnogtme6+nE8H1YPlQXHwbi3q9eqn0e7Tb25VrsF68vFY0lb1AGcDTwItGQ8tQM4AIwGmqP/EPAu8A0wElgJfFGzxTo8mKWXu9Rd4ZF96jvqjSbauEC9Sn1O3R463epLaku99voCsFXdkAH3kNpcQW+IiT/bQne3eufxBtioPqP2mKhioXpWzpxb1T8C5Ifh4ZptVoriRmAIKdrI3Lujf3bobAPeJpF0NVkKrAFuI9HTOBIxnxFrF4OgQKKr/dnJlQA+AcwABgOHA4zAamA5cE7orQL+zAEHiWI+A2bFC7aSguheYCgpqAphZz3wSB7AecCICv2TgH8oFRib4gVqka0k0h8CXAxMBW6ooDejFoCvA9OBQUAvKWM0kDz4XUZvNKXtyZMWUl7vBbaQXq457PeEziDgx/KJlQAuIPFdMcEXv5OdYWBP9M8k8VpnDQCvB4aTSrCNJB5cSdrW3tBpIJVnR0qdUTxAfdGUOVTnmwqEanNmqltC/9OgqePKg5eom8PgdvW+oJ9Kupera0O3U50TL3lcAaI+oHaF4R3qa6Z822wq0Saq89T1lmSxOrxeW/Xm4uGkiqQDmECKuKHxHW0HdpMiewSpvGqKeR8Ay0iBsYIjg6261PE2o9Q3Yqv+MqWxO9R1Hl12qs+q49Vlppy82pSr+5xJKsko4AXgHlJ0t5NIeg3wLXAlqZhtIUV8J6nmWwX8QiLjdhL5TwMWkY4R6/rrwYKlMr1Y321QZ/vfwBijPqm+rF4Wc7PjE9QllurGVeoV5gRNHsAm9fnMom3qrKPoTjKdMXaYyrFygEWQ72XWW24qhPu8xcUc2UU6O8wFPjmK7jhgPHAuMJGUGQ6U6WwE5sfzTXGvei7KA9hFOiR9D/wOfFVFt4dS2tpfRe83Ur7/CPiJakfOGgBCypubatArl2r8VfOax/LfzABKtePAzHO/5FgC7KBEzB2kOrDfUm8mOeFySv9+OyFyGmB/5aQH+C9BVKmVCNuMZgAAAABJRU5ErkJggg==",En="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAQ0lEQVQ4jWP8////fwYqAxYozUhFM/8zkaKYWIWkGEq0b0ZdSjQY5i79TyWagRGaTUdzFEEw6lLqGzqwLoVVJ1StpwA9sBwbUqAh5gAAAABJRU5ErkJggg==";class G extends b.Component{static instance=null;scene;renderer;currentScene;scenes=new Map;cameras=new Map;controls=new Map;currentCamera;currentWindow;helpersContainer=new w.Group;grid;cameraHelpers=new Map;lightHelpers=new Map;interactionHelper=new w.AxesHelper(25);currentTransform;splineEditor;depthMaterial;normalsMaterial;uvMaterial;wireframeMaterial=new w.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0});playing=!1;rafID=-1;cameraControlsRafID=-1;width=0;height=0;tlCam=null;trCam=null;blCam=null;brCam=null;tlRender="Renderer";trRender="Renderer";blRender="Renderer";brRender="Renderer";cameraVisibility=!0;lightVisibility=!0;gridVisibility=!0;rendererReady=!1;selectedItem=void 0;debugCamera;raycaster=new w.Raycaster;pointer=new w.Vector2;cameraControls=void 0;canvasRef;containerRef;tlWindow;trWindow;blWindow;brWindow;editorCameras=["Top","Bottom","Left","Right","Front","Back","Orthographic","UI","Debug"];constructor(e){super(e),this.props.three.addEventListener(U.ADD_RENDERER,this.setupRenderer),this.scene=new w.Scene,this.scene.name=this.scene.uuid="",this.canvasRef=b.createRef(),this.containerRef=b.createRef(),this.tlWindow=b.createRef(),this.trWindow=b.createRef(),this.blWindow=b.createRef(),this.brWindow=b.createRef();const t=e.three.name,s=localStorage,n=s.getItem(`${t}_mode`);this.state={mode:n!==null?n:"Single",modeOpen:!1,renderModeOpen:!1,interactionMode:"Orbit",interactionModeOpen:!1,lastUpdate:Date.now()},s.setItem(`${t}_mode`,this.state.mode),s.setItem(`${t}_tlCam`,s.getItem(`${t}_tlCam`)!==null?s.getItem(`${t}_tlCam`):"Debug"),s.setItem(`${t}_trCam`,s.getItem(`${t}_trCam`)!==null?s.getItem(`${t}_trCam`):"Orthographic"),s.setItem(`${t}_blCam`,s.getItem(`${t}_blCam`)!==null?s.getItem(`${t}_blCam`):"Front"),s.setItem(`${t}_brCam`,s.getItem(`${t}_brCam`)!==null?s.getItem(`${t}_brCam`):"Top"),s.setItem(`${t}_tlRender`,s.getItem(`${t}_tlRender`)!==null?s.getItem(`${t}_tlRender`):"Renderer"),s.setItem(`${t}_trRender`,s.getItem(`${t}_trRender`)!==null?s.getItem(`${t}_trRender`):"Renderer"),s.setItem(`${t}_blRender`,s.getItem(`${t}_blRender`)!==null?s.getItem(`${t}_blRender`):"Renderer"),s.setItem(`${t}_brRender`,s.getItem(`${t}_brRender`)!==null?s.getItem(`${t}_brRender`):"Renderer");const a={Vector2:w.Vector2,Vector3:w.Vector3,Vector4:w.Vector4,Quaternion:w.Quaternion,Matrix4:w.Matrix4,Spherical:w.Spherical,Box3:w.Box3,Sphere:w.Sphere,Raycaster:w.Raycaster};ne.install({THREE:a}),this.setupScene(),this.setupTools();const r=localStorage.getItem(this.expandedCameraVisibility);r!==null&&(this.cameraVisibility=r==="open"),this.saveExpandedCameraVisibility();const o=localStorage.getItem(this.expandedLightVisibility);o!==null&&(this.lightVisibility=o==="open"),this.saveExpandedLightVisibility();const c=localStorage.getItem(this.expandedGridVisibility);c!==null&&(this.gridVisibility=c==="open"),this.grid&&(this.grid.visible=this.gridVisibility),this.saveExpandedGridVisibility(),G.instance=this}componentDidMount(){this.enable(),this.assignControls(),this.resize(),this.play(),W.instance.setApp(this.props.three),W.instance.activeCamera=this.debugCamera,this.props.three.requestRenderer()}componentDidUpdate(e,t,s){t.mode!==this.state.mode&&(this.assignControls(),this.resize())}componentWillUnmount(){this.disable(),this.clear(),N.removeEditorGroup("View Settings")}render(){const e=[];return this.cameras.forEach((t,s)=>{e.push(s)}),d.jsxs("div",{className:"multiview",children:[d.jsx("canvas",{ref:this.canvasRef}),d.jsxs("div",{className:`cameras ${this.state.mode==="Single"||this.state.mode==="Stacked"?"single":""}`,ref:this.containerRef,children:[this.state.mode==="Single"&&d.jsx(d.Fragment,{children:d.jsx(ge,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}})}),(this.state.mode==="Side by Side"||this.state.mode==="Stacked")&&d.jsxs(d.Fragment,{children:[d.jsx(ge,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),d.jsx(ge,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.trCam),this.trCam=s,localStorage.setItem(`${this.appID}_trCam`,s.name),this.createControls(s,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}})]}),this.state.mode==="Quad"&&d.jsxs(d.Fragment,{children:[d.jsx(ge,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),d.jsx(ge,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.trCam),this.trCam=s,localStorage.setItem(`${this.appID}_trCam`,s.name),this.createControls(s,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}}),d.jsx(ge,{name:"bl",camera:this.blCam,options:e,ref:this.blWindow,onSelectCamera:t=>{this.controls.get(this.blCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.blCam),this.blCam=s,localStorage.setItem(`${this.appID}_blCam`,s.name),this.createControls(s,this.blWindow.current))},onSelectRenderMode:t=>{this.blRender=t,localStorage.setItem(`${this.appID}_blRender`,t)}}),d.jsx(ge,{name:"br",camera:this.brCam,options:e,ref:this.brWindow,onSelectCamera:t=>{this.controls.get(this.brCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.brCam),this.brCam=s,localStorage.setItem(`${this.appID}_brCam`,s.name),this.createControls(s,this.brWindow.current))},onSelectRenderMode:t=>{this.brRender=t,localStorage.setItem(`${this.appID}_brRender`,t)}})]})]}),d.jsxs("div",{className:"settings",children:[d.jsx(Qe,{title:"View",index:Wt.indexOf(this.state.mode),options:Wt,onSelect:t=>{t!==this.state.mode&&(this.killControls(),this.setState({mode:t}),localStorage.setItem(`${this.appID}_mode`,t))},open:this.state.modeOpen,onToggle:t=>{this.setState({modeOpen:t,renderModeOpen:!1,interactionModeOpen:!1})}}),d.jsx(Qe,{title:"Interact",index:this.state.interactionMode==="Orbit"?0:1,options:["Orbit Mode","Selection Mode"],onSelect:t=>{this.interactionHelper.visible=t==="Selection Mode",this.setState({interactionMode:this.interactionHelper.visible?"Selection":"Orbit"})},open:this.state.interactionModeOpen,onToggle:t=>{this.setState({modeOpen:!1,renderModeOpen:!1,interactionModeOpen:t})}}),d.jsx(mt,{name:"cameraHelper",icon:yn,selected:this.cameraVisibility,height:24,top:2,onClick:t=>{if(this.cameraVisibility=t,this.saveExpandedCameraVisibility(),this.cameraHelpers.forEach(s=>{s.visible=t}),this.selectedItem!==void 0&&!t){const s=this.cameraHelpers.get(this.selectedItem.name);s!==void 0&&(s.visible=!0)}}}),d.jsx(mt,{name:"lightHelper",icon:bn,selected:this.lightVisibility,height:24,top:4,onClick:t=>{if(this.lightVisibility=t,this.saveExpandedLightVisibility(),this.lightHelpers.forEach(s=>{s.visible=t}),this.selectedItem!==void 0&&!t&&this.selectedItem.isLight===!0){const s=this.lightHelpers.get(this.selectedItem.name);s!==void 0&&(s.visible=!0)}}}),d.jsx(mt,{name:"gridHelper",icon:En,selected:this.gridVisibility,height:21,width:21,onClick:t=>{this.setGridVisibility(t)}})]},this.state.lastUpdate)]})}setupRenderer=e=>{const t=e.value;if(this.renderer){if(this.renderer instanceof m.WebGLRenderer&&t.type==="WebGLRenderer"||this.renderer instanceof w.WebGPURenderer&&t.type==="WebGPURenderer")return;this.renderer.dispose()}this.rendererReady=!1;const s=this.canvasRef.current;this.props.three.canvas=s,t.type==="WebGLRenderer"?(this.renderer=new m.WebGLRenderer({canvas:s,stencil:!1}),this.depthMaterial=new w.MeshDepthMaterial,this.normalsMaterial=new w.MeshNormalMaterial,this.uvMaterial=new vi,this.grid=new pi,this.scene.add(this.grid),this.rendererReady=!0):t.type==="WebGPURenderer"&&(this.renderer=new w.WebGPURenderer({canvas:s,stencil:!1}),this.grid=new fi,this.scene.add(this.grid)),this.renderer&&(this.renderer.autoClear=!1,this.renderer.shadowMap.enabled=!0,this.renderer.setClearColor(0),this.renderer.setPixelRatio(devicePixelRatio),this.renderer.setScissorTest(!0),this.resize(),this.props.three.renderer=this.renderer,this.depthMaterial=new gi,this.normalsMaterial=new w.MeshNormalNodeMaterial,this.uvMaterial=new _i,t.type==="WebGPURenderer"?this.renderer.init().then(()=>{this.rendererReady=!0,this.props.three.requestScene()}):this.props.three.requestScene())};setupScene(){this.helpersContainer.name="helpers",this.scene.add(this.helpersContainer),this.interactionHelper.name="interactionHelper",this.interactionHelper.visible=!1,this.helpersContainer.add(this.interactionHelper);const e=(a,r)=>{const o=new w.OrthographicCamera(-100,100,100,-100,0,3e3);return o.name=a,o.position.copy(r),o.lookAt(0,0,0),this.cameras.set(a,o),o},t=1e3;e("Top",new w.Vector3(0,t,0)),e("Bottom",new w.Vector3(0,-t,0)),e("Left",new w.Vector3(-t,0,0)),e("Right",new w.Vector3(t,0,0)),e("Front",new w.Vector3(0,0,t)),e("Back",new w.Vector3(0,0,-t)),e("Orthographic",new w.Vector3(t,t,t)),e("UI",new w.Vector3),this.debugCamera=new w.PerspectiveCamera(60,1,.01,3e3),this.debugCamera.name="Debug",this.debugCamera.position.set(300,300,300),this.debugCamera.lookAt(0,0,0),this.cameras.set("Debug",this.debugCamera),this.currentCamera=this.debugCamera;const s=localStorage,n=this.props.three.name;this.tlCam=this.cameras.get(s.getItem(`${n}_tlCam`)),this.trCam=this.cameras.get(s.getItem(`${n}_trCam`)),this.blCam=this.cameras.get(s.getItem(`${n}_blCam`)),this.brCam=this.cameras.get(s.getItem(`${n}_brCam`)),this.tlCam===void 0&&(this.tlCam=this.cameras.get("Debug")),this.trCam===void 0&&(this.trCam=this.cameras.get("Orthographic")),this.blCam===void 0&&(this.blCam=this.cameras.get("Front")),this.brCam===void 0&&(this.brCam=this.cameras.get("Top")),N.addEditorGroup({title:"Editor",items:[{type:"button",prop:"Hide All Transforms"},{type:"button",prop:"Resize"}],onUpdate:(a,r)=>{switch(a){case"Hide All Transforms":W.instance.hide();break;case"Resize":this.resize();break}},subgroups:[{title:"Debug Camera",items:[{type:"range",prop:"Near",step:1e-4,min:.001,max:1e3,value:this.debugCamera.near},{type:"range",prop:"Far",step:.001,min:.001,max:1e4,value:this.debugCamera.far}],onUpdate:(a,r)=>{switch(a){case"Near":this.debugCamera.near=r,this.debugCamera.updateProjectionMatrix();break;case"Far":this.debugCamera.far=r,this.debugCamera.updateProjectionMatrix();break}}},{title:"Grid",items:[{type:"number",prop:"Position",value:0},{type:"color",prop:"Color",value:"#FFFFFF"},{type:"range",prop:"Grid Opacity",value:.25,min:0,max:1,step:.01},{type:"range",prop:"Subgrid Opacity",value:.15,min:0,max:1,step:.01}],onUpdate:(a,r)=>{switch(a){case"Position":this.grid&&(this.grid.position.y=r);break;case"Color":this.grid&&this.grid.color.setStyle(r);break;case"Grid Opacity":this.grid&&(this.grid.gridOpacity=r);break;case"Subgrid Opacity":this.grid&&(this.grid.subgridOpacity=r);break}}}]})}setupTools(){this.splineEditor=new Ci(this.currentCamera,this.three),this.splineEditor.initDebug(),this.helpersContainer.add(this.splineEditor)}play(){this.playing=!0,this.onUpdate()}pause(){this.playing=!1,cancelAnimationFrame(this.rafID),this.rafID=-1}toggleOrbitControls(e){this.controls.forEach(t=>{t.enabled=!e})}clear(){this.three.dispatchEvent({type:U.CLEAR_OBJECT}),N.removeAllGroups(),this.clearLightHelpers(),this.clearControls(),this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),W.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=void 0,W.instance.clear(),this.cameras.forEach(e=>{this.editorCameras.indexOf(e.name)<0&&this.three.dispatchEvent({type:U.REMOVE_CAMERA,value:e})}),this.currentCamera=this.debugCamera,this.currentScene=void 0,this.scenes.forEach(e=>{this.three.dispatchEvent({type:U.REMOVE_SCENE,value:e})}),this.scenes.clear()}setGridVisibility(e){this.gridVisibility=e,this.saveExpandedGridVisibility(),this.grid&&(this.grid.visible=e)}update(){this.renderer&&this.rendererReady&&this.renderer?.clear(),this.controls.forEach(e=>e.update()),this.cameraHelpers.forEach(e=>e.update()),this.lightHelpers.forEach(e=>{e.update!==void 0&&e.update()}),this.props.onSceneUpdate!==void 0&&this.currentScene!==void 0&&this.props.onSceneUpdate(this.currentScene)}draw(){if(this.rendererReady)switch(this.renderer&&this.renderer?.clear(),this.state.mode){case"Single":this.drawSingle();break;case"Side by Side":case"Stacked":this.drawDouble();break;case"Quad":this.drawQuad();break}}onUpdate=()=>{this.playing&&(this.update(),this.draw(),this.rafID=requestAnimationFrame(this.onUpdate))};enable(){const e=this.containerRef.current;e.addEventListener("mousemove",this.onMouseMove),e.addEventListener("click",this.onClick),window.addEventListener("keydown",this.onKey),window.addEventListener("resize",this.resize),this.three.addEventListener(U.ADD_SCENE,this.addScene),this.three.addEventListener(U.SET_SCENE,this.sceneUpdate),this.three.addEventListener(U.REMOVE_SCENE,this.removeScene),this.three.addEventListener(U.ADD_CAMERA,this.addCamera),this.three.addEventListener(U.REMOVE_CAMERA,this.removeCamera),this.three.addEventListener(U.SET_OBJECT,this.onSetSelectedItem)}disable(){const e=this.containerRef.current;e.removeEventListener("mousemove",this.onMouseMove),e.removeEventListener("click",this.onClick),window.removeEventListener("keydown",this.onKey),window.removeEventListener("resize",this.resize),this.three.removeEventListener(U.ADD_SCENE,this.addScene),this.three.removeEventListener(U.SET_SCENE,this.sceneUpdate),this.three.removeEventListener(U.ADD_CAMERA,this.addCamera),this.three.removeEventListener(U.REMOVE_CAMERA,this.removeCamera),this.three.removeEventListener(U.SET_OBJECT,this.onSetSelectedItem)}resize=()=>{this.width=window.innerWidth-300,this.height=window.innerHeight,this.renderer?.setSize(this.width,this.height);const e=Math.floor(this.width/2),t=Math.floor(this.height/2);this.props.three.resize(this.width,this.height),this.props.onSceneResize!==void 0&&this.currentScene!==void 0&&this.props.onSceneResize(this.currentScene,this.width,this.height);let s=this.width,n=this.height;switch(this.state.mode){case"Side by Side":s=e,n=this.height;break;case"Stacked":s=this.width,n=t;break;case"Quad":s=e,n=t;break}const a=s/n;this.cameras.forEach(r=>{r instanceof w.OrthographicCamera?(r.left=s/-2,r.right=s/2,r.top=n/2,r.bottom=n/-2,r.name==="UI"&&(r.position.x=this.width/2,r.position.y=this.height/-2,r.position.z=100),r.updateProjectionMatrix()):r instanceof w.PerspectiveCamera&&(r.aspect=a,r.updateProjectionMatrix()),this.cameraHelpers.get(r.name)?.update()})};addScene=e=>{const t=this.props.scenes.get(e.value.name);if(t!==void 0){const s=new t;s.visible=!1,this.props.onSceneAdd!==void 0&&this.props.onSceneAdd(s),this.props.three.scene=s,this.scenes.set(e.value.name,s),this.scene.add(s)}else console.log("Hermes - Scene not found:",e.value.name,this.props.scenes)};sceneUpdate=e=>{this.currentScene!==void 0&&(this.currentScene.visible=!1,this.clearLightHelpers());const t=this.scene.getObjectByName(e.value.name);t!==void 0&&(this.currentScene=t,this.currentScene.visible=!0,this.addLightHelpers(this.currentScene))};removeScene=e=>{const t=e.value.name;this.scenes.delete(t);const s=this.scene.getObjectByName(t);s&&setTimeout(()=>{re(s)},100),this.clearLightHelpers()};addCamera=e=>{const t=e.value,s=t.uuid,n=this.props.three.scene?.getObjectByProperty("uuid",t.uuid);if(n!==void 0){const a=n;this.cameras.set(s,a);const r=new w.CameraHelper(a);r.visible=this.cameraVisibility,this.cameraHelpers.set(s,r),this.helpersContainer.add(r),this.setState({lastUpdate:Date.now()})}};removeCamera=e=>{const s=e.value.uuid,n=this.cameraHelpers.get(s);n!==void 0&&(this.helpersContainer.remove(n),n.dispose()),this.cameras.delete(s),this.setState({lastUpdate:Date.now()})};onMouseMove=e=>{const t=new w.Vector2;this.renderer?.getSize(t);const s=Math.min(e.clientX,t.x),n=Math.min(e.clientY,t.y);this.pointer.x=$.mapLinear(s,0,t.x,-1,1),this.pointer.y=$.mapLinear(n,0,t.y,1,-1);const a=t.x/2,r=t.y/2,o=()=>{s<a?this.pointer.x=$.mapLinear(s,0,a,-1,1):this.pointer.x=$.mapLinear(s,a,t.x,-1,1)},c=()=>{n<r?this.pointer.y=$.mapLinear(n,0,r,1,-1):this.pointer.y=$.mapLinear(n,r,t.y,1,-1)};switch(this.state.mode){case"Quad":o(),c();break;case"Side by Side":o();break;case"Stacked":c(),c();break}if(this.updateCamera(s,n,a,r),this.state.interactionMode==="Orbit"||this.currentScene===void 0)return;const l=this.raycaster.intersectObjects(this.currentScene.children);l.length>0&&this.interactionHelper.position.copy(l[0].point)};onClick=e=>{if(this.state.interactionMode==="Orbit"||this.currentScene===void 0)return;const t=new w.Vector2;if(this.renderer.getSize(t),e.clientX>=t.x)return;this.onMouseMove(e);const s=this.raycaster.intersectObjects(this.currentScene.children);s.length>0&&(this.props.three.getObject(s[0].object.uuid),this.interactionHelper.visible=!1,this.setState({interactionMode:"Orbit",lastUpdate:Date.now()}))};onKey=e=>{if(this.selectedItem!==void 0){if(e.ctrlKey){if(this.currentCamera.name==="UI")return;const t=this.controls.get(this.currentCamera.name);e.key==="0"?(e.preventDefault(),this.clearControls(),this.cameraControls=new ne(this.currentCamera,this.currentWindow.current),this.selectedItem instanceof w.Mesh||this.selectedItem instanceof w.SkinnedMesh?(this.selectedItem.geometry.computeBoundingBox(),this.cameraControls.fitToBox(this.selectedItem.geometry.boundingBox,!0)):this.cameraControls.fitToSphere(this.selectedItem,!0),this.updateCameraControls(t,!0)):e.key==="1"?(e.preventDefault(),this.clearControls(),this.cameraControls=new ne(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,Math.PI*.5,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(t)):e.key==="2"?(e.preventDefault(),this.clearControls(),this.cameraControls=new ne(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,0,!0),this.cameraControls.moveTo(this.selectedItem.position.x,0,this.selectedItem.position.z,!0),this.updateCameraControls(t)):e.key==="3"?(e.preventDefault(),this.clearControls(),this.cameraControls=new ne(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI/2,Math.PI/2,!0),this.cameraControls.moveTo(0,this.selectedItem.position.y,this.selectedItem.position.z,!0),this.updateCameraControls(t)):e.key==="4"?(e.preventDefault(),this.clearControls(),this.cameraControls=new ne(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI,Math.PI/2,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(t)):e.key==="5"&&(e.preventDefault(),this.clearControls(),this.cameraControls=new ne(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo($.degToRad(45),$.degToRad(45),!0),this.updateCameraControls(t))}else if(this.currentTransform!==void 0)switch(e.key){case"r":this.currentTransform.setMode("rotate");break;case"s":this.currentTransform.setMode("scale");break;case"t":this.currentTransform.setMode("translate");break;case"q":this.currentTransform.setSpace(this.currentTransform.space==="local"?"world":"local");break}}};onSetSelectedItem=e=>{this.selectedItem!==void 0&&this.updateSelectedItemHelper(!1),this.selectedItem=void 0;const t=e.value.uuid;if(this.scenes.forEach(s=>{t.search(s.uuid)>-1&&(this.selectedItem=s.getObjectByProperty("uuid",t))}),this.selectedItem===void 0){console.log(`Hermes - Can't find selected item: ${e.value.uuid}, ${e.value.name}`);return}this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),W.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=W.instance.add(e.value.name),this.currentTransform&&(this.currentTransform.attach(this.selectedItem),this.helpersContainer.add(this.currentTransform.getHelper()),this.currentTransform.addEventListener("objectChange",this.onUpdateTransform)),this.updateSelectedItemHelper(!0)};updateSelectedItemHelper(e){if(this.selectedItem!==void 0)if(this.cameraVisibility){if(this.selectedItem.isLight===!0&&!this.lightVisibility){const t=this.lightHelpers.get(this.selectedItem.name);t!==void 0&&(t.visible=e)}}else{const t=this.cameraHelpers.get(this.selectedItem.name);t!==void 0&&(t.visible=e)}}onUpdateTransform=()=>{this.selectedItem!==void 0&&(this.props.three.updateObject(this.selectedItem.uuid,"position",this.selectedItem.position),this.props.three.updateObject(this.selectedItem.uuid,"rotation",{x:this.selectedItem.rotation.x,y:this.selectedItem.rotation.y,z:this.selectedItem.rotation.z}),this.props.three.updateObject(this.selectedItem.uuid,"scale",this.selectedItem.scale),tt.instance.update())};clearLightHelpers=()=>{this.lightHelpers.forEach(e=>{this.helpersContainer.remove(e),e.dispose()}),this.lightHelpers.clear()};addLightHelpers=e=>{e.traverse(t=>{if(t.type.search("Light")>-1){let s;switch(t.type){case"DirectionalLight":s=new w.DirectionalLightHelper(t,100),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"HemisphereLight":s=new w.HemisphereLightHelper(t,250),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"RectAreaLight":s=new Ni.RectAreaLightHelper(t),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"PointLight":s=new w.PointLightHelper(t,100),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"SpotLight":s=new w.SpotLightHelper(t),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break}}})};createControls(e,t){const s=this.controls.get(e.name);if(s!==void 0&&s.dispose(),this.controls.delete(e.name),e.name==="UI")return;const n=new ki.OrbitControls(e,t);switch(n.enableDamping=!0,n.dampingFactor=.1,e.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":n.enableRotate=!1;break}this.controls.set(e.name,n)}clearCamera(e){const t=this.cameraHelpers.get(e.name);t!==void 0&&(this.helpersContainer.remove(t),t.dispose(),this.cameraHelpers.delete(e.name));const s=this.controls.get(e.name);s!==void 0&&(s.dispose(),this.controls.delete(e.name))}killControls(){this.controls.forEach((e,t)=>{e.dispose();const s=this.cameraHelpers.get(t);s!==void 0&&(this.helpersContainer.remove(s),s.dispose()),this.cameraHelpers.delete(t),this.controls.delete(t)}),this.controls.clear(),this.cameraHelpers.clear()}assignControls(){switch(this.state.mode){case"Single":this.createControls(this.tlCam,this.tlWindow.current);break;case"Side by Side":case"Stacked":this.createControls(this.tlCam,this.tlWindow.current),this.createControls(this.trCam,this.trWindow.current);break;case"Quad":this.createControls(this.tlCam,this.tlWindow.current),this.createControls(this.trCam,this.trWindow.current),this.createControls(this.blCam,this.blWindow.current),this.createControls(this.brCam,this.brWindow.current);break}}updateCamera=(e,t,s,n)=>{switch(this.state.mode){case"Quad":t<n?e<s?this.currentCamera=this.tlCam:this.currentCamera=this.trCam:e<s?this.currentCamera=this.blCam:this.currentCamera=this.brCam;break;case"Side by Side":e<s?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break;case"Single":this.currentCamera=this.tlCam;break;case"Stacked":t<n?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break}this.splineEditor.camera=this.currentCamera,this.raycaster.setFromCamera(this.pointer,this.currentCamera),this.currentCamera===this.tlCam?this.currentWindow=this.tlWindow:this.currentCamera===this.trCam?this.currentWindow=this.trWindow:this.currentCamera===this.blCam?this.currentWindow=this.blWindow:this.currentCamera===this.brCam&&(this.currentWindow=this.brWindow),W.instance.updateCamera(this.currentCamera,this.currentWindow.current)};updateCameraControls=(e,t=!1)=>{if(this.selectedItem===void 0)return;cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.cameraControls&&(this.cameraControls.smoothTime=.1);const s=.15,n=new w.Clock;n.start(),this.selectedItem.getWorldPosition(e.target0);const a=()=>{const r=n.getDelta();this.cameraControls&&this.cameraControls.update(r),t&&(e.target.lerp(e.target0,s),e.object.position.lerp(e.position0,s),e.object.zoom=Ae(e.object.zoom,e.zoom0,s),e.object.updateProjectionMatrix(),e.dispatchEvent({type:"change"})),n.getElapsedTime()>=.5?(cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.clearControls()):this.cameraControlsRafID=requestAnimationFrame(a)};a()};clearControls=()=>{this.cameraControls!==void 0&&(this.cameraControls.disconnect(),this.cameraControls.dispose(),this.cameraControls=void 0)};saveExpandedCameraVisibility(){localStorage.setItem(this.expandedCameraVisibility,this.cameraVisibility?"open":"closed")}saveExpandedLightVisibility(){localStorage.setItem(this.expandedLightVisibility,this.lightVisibility?"open":"closed")}saveExpandedGridVisibility(){localStorage.setItem(this.expandedGridVisibility,this.gridVisibility?"open":"closed")}getSceneOverride(e){switch(e){case"Depth":return this.depthMaterial;case"Normals":return this.normalsMaterial;case"Renderer":return null;case"UVs":return this.uvMaterial;case"Wireframe":return this.wireframeMaterial}return null}drawTo(e,t,s,n,a,r){switch(a.name){case"Left":case"Right":this.grid&&(this.grid.rotation.z=Math.PI/2);break;case"Front":case"Back":this.grid&&(this.grid.rotation.x=Math.PI/2);break}this.scene.overrideMaterial=r,this.renderer&&(this.renderer?.setScissor(e,t,s,n),this.renderer?.setViewport(e,t,s,n),this.renderer?.render(this.scene,a)),this.grid&&this.grid.rotation.set(0,0,0)}drawSingle(){const e=this.getSceneOverride(this.tlRender);this.drawTo(0,0,this.width,this.height,this.tlCam,e)}drawDouble=()=>{const e=this.getSceneOverride(this.tlRender),t=this.getSceneOverride(this.trRender),s=Math.floor(this.width/2),n=Math.floor(this.height/2),a=this.renderer instanceof w.WebGPURenderer;if(this.state.mode==="Side by Side")this.drawTo(0,0,s,this.height,this.tlCam,e),this.drawTo(s,0,s,this.height,this.trCam,t);else{const r=this.height-n;a?(this.drawTo(0,0,this.width,n,this.tlCam,e),this.drawTo(0,r,this.width,n,this.trCam,t)):(this.drawTo(0,r,this.width,n,this.tlCam,e),this.drawTo(0,0,this.width,n,this.trCam,t))}};drawQuad=()=>{const e=this.renderer instanceof w.WebGPURenderer,t=this.getSceneOverride(this.tlRender),s=this.getSceneOverride(this.trRender),n=this.getSceneOverride(this.blRender),a=this.getSceneOverride(this.brRender),r=Math.floor(this.width/2),o=Math.floor(this.height/2),c=this.height-o;let l=0,h=e?0:this.height-o;l=0,this.drawTo(l,h,r,o,this.tlCam,t),l=r,this.drawTo(l,h,r,o,this.trCam,s),h=e?c:0,l=0,this.scene.overrideMaterial=n,this.drawTo(l,h,r,o,this.blCam,n),l=r,this.drawTo(l,h,r,o,this.brCam,a)};get appID(){return this.props.three.name}get mode(){return this.state.mode}get three(){return this.props.three}get expandedCameraVisibility(){return`${this.appID}_multiviewCameraVisibility`}get expandedLightVisibility(){return`${this.appID}_multiviewLightVisibility`}get expandedGridVisibility(){return`${this.appID}_multiviewGridVisibility`}}class tt extends b.Component{static instance;matrix=new m.Matrix4;position=new m.Vector3;rotation=new m.Euler;scale=new m.Vector3;open=!1;constructor(e){super(e);const t=localStorage.getItem(this.expandedName),s=t!==null?t==="open":!1;this.open=s,this.saveExpanded(),this.state={lastUpdated:0,expanded:s},this.matrix.elements=e.object.matrix,e.object.uuid.length>0&&(this.position.setFromMatrixPosition(this.matrix),this.rotation.setFromRotationMatrix(this.matrix),this.scale.setFromMatrixScale(this.matrix)),tt.instance=this}update(){if(G.instance){const e=G.instance.selectedItem;if(e===void 0)return;this.position.x=X(e.position.x,3),this.position.y=X(e.position.y,3),this.position.z=X(e.position.z,3),this.rotation.copy(e.rotation),this.scale.x=X(e.scale.x,3),this.scale.y=X(e.scale.y,3),this.scale.z=X(e.scale.z,3),this.setState({lastUpdated:Date.now()})}}render(){return d.jsx(Q,{three:this.props.three,title:"Transform",expanded:this.open,items:[{title:"Position",prop:"position",type:"grid3",step:.1,value:this.position,onChange:this.updateTransform},{title:"Rotation",prop:"rotation",type:"euler",value:this.rotation,onChange:this.updateTransform},{title:"Scale",prop:"scale",type:"grid3",value:this.scale,onChange:this.updateTransform},{title:"Visible",prop:"visible",type:"boolean",value:this.props.object.visible,onChange:this.updateTransform}],onToggle:e=>{this.open=e,this.saveExpanded()}},this.state.lastUpdated)}updateTransform=(e,t)=>{const s=e==="rotation"?{x:t._x,y:t._y,z:t._z}:t;this.props.three.updateObject(this.props.object.uuid,e,s);const n=this.props.three.getScene(this.props.object.uuid);if(n){const a=n.getObjectByProperty("uuid",this.props.object.uuid);V(a,e,s)}};saveExpanded(){localStorage.setItem(this.expandedName,this.open?"open":"closed")}get expandedName(){return`${this.props.three.name}_transform`}}function Yt(i){switch(i){case"color":return"Color";case"intensity":return"Intensity";case"decay":return"Decay";case"distance":return"Distance";case"angle":return"Angle";case"penumbra":return"Penumbra";case"groundColor":return"Ground Color";case"width":return"Width";case"height":return"Height"}return i}function Sn(i,e){function t(){return`${e.name}_light`}const s=localStorage.getItem(t()),n=s!==null?s==="open":!1;function a(o){localStorage.setItem(t(),o?"open":"closed")}const r=[];if(i.lightInfo!==void 0)for(const o in i.lightInfo){const c=i.lightInfo[o];c!==void 0&&(c.isColor!==void 0?r.push({title:Yt(o),prop:o,type:"color",value:c,onChange:(l,h)=>{const u=new m.Color(h);e.updateObject(i.uuid,l,u);const p=e.getScene(i.uuid);if(p!==null){const g=p.getObjectByProperty("uuid",i.uuid);V(g,l,u)}}}):r.push({title:Yt(o),prop:o,type:typeof c,value:c,step:typeof c=="number"?.01:void 0,onChange:(l,h)=>{e.updateObject(i.uuid,l,h);const u=e.getScene(i.uuid);if(u!==null){const p=u.getObjectByProperty("uuid",i.uuid);V(p,l,h)}}}))}return d.jsx(Q,{three:e,title:"Light",items:r,expanded:n,onToggle:o=>{a(o)}})}function xn(i){const e=i.object,t=i.three;function s(){return`${t.name}_animation`}const n=localStorage.getItem(s()),a=n!==null?n==="open":!1;function r(p){localStorage.setItem(s(),p?"open":"closed")}const o=[],c=[];let l=0;e.animations.forEach(p=>{l=Math.max(l,p.duration),p.duration>0&&c.push({title:p.name,items:[{title:"Duration",type:"number",value:p.duration,disabled:!0},{title:"Blend Mode",type:"option",disabled:!0,options:[{title:"Normal",value:2500},{title:"Additive",value:2501}]}]})}),o.push({title:"Animations",items:c});let h;const u=t.getScene(e.uuid);if(u!==null){const p=u.getObjectByProperty("uuid",e.uuid);if(p!==void 0){const g=p.mixer;if(g!==void 0){const _=[{title:"Time Scale",type:"range",value:g.timeScale,step:.01,min:-1,max:2,onChange:(E,v)=>{g.timeScale=v,t.updateObject(e.uuid,"mixer.timeScale",v)}}];_.push({title:"Stop All",type:"button",onChange:()=>{g.stopAllAction(),t.requestMethod(e.uuid,"stopAllAction",void 0,"mixer")}}),o.push({title:"Mixer",items:_}),h=new m.SkeletonHelper(p),G.instance?.scene.add(h)}}}return b.useEffect(()=>()=>{h!==void 0&&re(h)},[]),d.jsx(Q,{three:i.three,title:"Animation",items:o,expanded:a,onToggle:p=>{r(p)}})}const gt={name:"",uuid:"",type:"",visible:!1,matrix:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0,children:[]};function yi(i){const[e,t]=b.useState(gt);b.useEffect(()=>{function r(c){t(c.value)}function o(){t(gt)}return i.three.addEventListener(U.CLEAR_OBJECT,o),i.three.addEventListener(U.SET_SCENE,o),i.three.addEventListener(U.SET_OBJECT,r),()=>{i.three.removeEventListener(U.CLEAR_OBJECT,o),i.three.removeEventListener(U.SET_SCENE,o),i.three.removeEventListener(U.SET_OBJECT,r)}},[]);const s=e.type.toLowerCase(),n=e.animations.length>0||e.mixer!==void 0,a=s.search("mesh")>-1||s.search("line")>-1||s.search("points")>-1;return d.jsx(Me,{three:i.three,label:"Inspector",button:e.uuid.length>0?d.jsx("button",{className:"remove",onClick:()=>{W.instance.remove(e.name),t(gt)}}):void 0,children:d.jsx("div",{id:"Inspector",className:i.class,children:e.uuid.length>0&&d.jsxs(d.Fragment,{children:[d.jsxs(d.Fragment,{children:[d.jsx(qe,{type:"string",title:"Name",prop:"name",value:e.name,disabled:!0}),d.jsx(qe,{type:"string",title:"Type",prop:"type",value:e.type,disabled:!0}),d.jsx(qe,{type:"string",title:"UUID",prop:"uuid",value:e.uuid,disabled:!0})]}),d.jsxs(d.Fragment,{children:[d.jsx(tt,{object:e,three:i.three}),n?d.jsx(xn,{object:e,three:i.three}):null,s.search("camera")>-1?dn(e,i.three):null,s.search("light")>-1?Sn(e,i.three):null,a?ln(e,i.three):null]})]})})},"Inspector")}class On extends b.Component{autoClear=!0;autoClearColor=!0;autoClearDepth=!0;autoClearStencil=!0;outputColorSpace=m.SRGBColorSpace;localClippingEnabled=!1;clearColor=new m.Color(0);clearAlpha=1;toneMapping=m.NoToneMapping;toneMappingExposure=1;type="";constructor(e){super(e);const t=localStorage.getItem(this.expandedName),s=t!==null?t==="open":!1;if(this.state={expanded:s,lastUpdated:Date.now()},this.saveExpanded(s),G.instance){const n=G.instance.renderer;n&&(this.autoClear=n.autoClear,this.autoClearColor=n.autoClearColor,this.autoClearDepth=n.autoClearDepth,this.autoClearStencil=n.autoClearStencil,this.clearAlpha=n.getClearAlpha(),this.toneMapping=n.toneMapping,this.toneMappingExposure=n.toneMappingExposure,n instanceof m.WebGLRenderer&&(this.localClippingEnabled=n.localClippingEnabled,n.getClearColor(this.clearColor)))}this.props.three.addEventListener(U.ADD_RENDERER,this.onAddRenderer)}componentwillunmount(){this.props.three.removeEventListener(U.ADD_RENDERER,this.onAddRenderer)}onAddRenderer=e=>{const t=e.value;if(this.autoClear=t.autoClear,this.autoClearColor=t.autoClearColor,this.autoClearDepth=t.autoClearDepth,this.autoClearStencil=t.autoClearStencil,this.outputColorSpace=t.outputColorSpace,this.localClippingEnabled=t.localClippingEnabled,this.clearAlpha=t.clearAlpha,this.type=t.type,this.toneMapping=t.toneMapping,this.toneMappingExposure=t.toneMappingExposure,this.clearColor.setStyle(t.clearColor,m.LinearSRGBColorSpace),m.ColorManagement.enabled=t.colorManagement,G.instance){const s=G.instance.renderer;s&&(s.autoClearColor=this.autoClearColor,s.outputColorSpace=this.outputColorSpace,s instanceof m.WebGLRenderer&&(s.localClippingEnabled=this.localClippingEnabled),s.toneMapping=this.toneMapping,s.toneMappingExposure=this.toneMappingExposure,s.setClearColor(t.clearColor,this.clearAlpha))}this.setState({lastUpdated:Date.now()})};render(){const e=()=>{if(G.instance){const t=G.instance.renderer;t&&(t.autoClearColor=this.autoClearColor,t.outputColorSpace=this.outputColorSpace,t instanceof m.WebGLRenderer&&(t.localClippingEnabled=this.localClippingEnabled),t.toneMapping=this.toneMapping,t.toneMappingExposure=this.toneMappingExposure,t.setClearColor(this.clearColor.getStyle(),this.clearAlpha),this.props.three.updateRenderer({autoClear:this.autoClear,autoClearColor:this.autoClearColor,autoClearDepth:this.autoClearDepth,autoClearStencil:this.autoClearStencil,outputColorSpace:this.outputColorSpace,localClippingEnabled:this.localClippingEnabled,clearAlpha:this.clearAlpha,clearColor:this.clearColor.getStyle(),colorManagement:m.ColorManagement.enabled,toneMapping:this.toneMapping,toneMappingExposure:this.toneMappingExposure}))}};return d.jsx(Q,{three:this.props.three,title:"Renderer",expanded:this.state.expanded,items:[{type:"boolean",title:"Auto Clear",value:this.autoClear,onChange:(t,s)=>{this.autoClear=s}},{type:"boolean",title:"Auto Clear Color",value:this.autoClearColor,onChange:(t,s)=>{this.autoClearColor=s,e()}},{type:"boolean",title:"Auto Clear Depth",value:this.autoClearDepth,onChange:(t,s)=>{this.autoClearDepth=s,e()}},{type:"boolean",title:"Auto Clear Stencil",value:this.autoClearStencil,onChange:(t,s)=>{this.autoClearStencil=s,e()}},{type:"boolean",title:"Local Clipping",value:this.localClippingEnabled,onChange:(t,s)=>{this.localClippingEnabled=s,e()}},{type:"color",title:"Clear Color",value:`#${this.clearColor.getHexString()}`,onChange:(t,s)=>{this.clearColor.setStyle(s),e()}},{type:"range",title:"Clear Alpha",min:0,max:1,step:.01,value:this.clearAlpha,onChange:(t,s)=>{this.clearAlpha=s,e()}},{type:"boolean",title:"Color Management",value:m.ColorManagement.enabled,onChange:(t,s)=>{m.ColorManagement.enabled=s,e()}},{type:"option",title:"Color Space",value:this.outputColorSpace,options:[{title:"No Color Space",value:m.NoColorSpace},{title:"SRB Color Space",value:m.SRGBColorSpace},{title:"Linear SRB Color Space",value:m.LinearSRGBColorSpace}],onChange:(t,s)=>{this.outputColorSpace=s,e()}},{type:"option",title:"Tone Mapping",value:this.toneMapping,options:[{title:"None ",value:m.NoToneMapping},{title:"Linear ",value:m.LinearToneMapping},{title:"Reinhard",value:m.ReinhardToneMapping},{title:"Cineon ",value:m.CineonToneMapping},{title:"ACES Filmic",value:m.ACESFilmicToneMapping},{title:"AgX",value:m.AgXToneMapping},{title:"Neutral",value:m.NeutralToneMapping},{title:"Custom",value:m.CustomToneMapping}],onChange:(t,s)=>{this.toneMapping=s,e()}},{type:"range",title:"Tone Mapping Exposure",value:this.toneMappingExposure,min:0,max:2,step:.01,onChange:(t,s)=>{this.toneMappingExposure=s,e()}},{type:"string",title:"Type",value:this.type,disabled:!0},{type:"button",title:"Resize Scenes from Source",onChange:()=>{this.props.three.requestSize()}}],onToggle:t=>{this.setState({expanded:t}),this.saveExpanded(t)}},Math.random())}saveExpanded(e){localStorage.setItem(this.expandedName,e?"open":"closed")}get expandedName(){return`${this.props.three.name}_renderer`}}function bi(i){const[e]=b.useState([]),[t]=b.useState([]),[s,n]=b.useState(0),a=l=>{const h=l.value;e.push(h),t.push(d.jsx(Me,{three:i.three,label:`Scene: ${h.name}`,scene:h,open:!1,visible:!1,onRefresh:()=>{i.three.refreshScene(h.name)},children:d.jsx($e,{child:h,scene:h,three:i.three})},h.name)),n(Date.now())},r=l=>{const h=l.value;for(let u=0;u<e.length;u++)if(h.uuid===e[u].uuid){e[u]=h,t[u]=d.jsx(Me,{three:i.three,label:`Scene: ${h.name}`,scene:h,open:t[u].props.open,visible:t[u].props.visible,onRefresh:()=>{i.three.refreshScene(h.name)},children:d.jsx($e,{child:h,scene:h,three:i.three})},h.name),n(Date.now());return}},o=l=>{const h=l.value;for(let u=0;u<e.length;u++)if(h.uuid===e[u].uuid){e.splice(u,1),t.splice(u,1),n(Date.now());return}},c=l=>{const h=l.value.name;for(let u=0;u<e.length;u++){const p=e[u],g=p.name===h;t[u]=d.jsx(Me,{three:i.three,label:`Scene: ${p.name}`,scene:p,open:g,visible:g,onRefresh:()=>{i.three.refreshScene(p.name)},children:d.jsx($e,{child:p,scene:p,three:i.three})},p.name)}n(Date.now())};return b.useEffect(()=>(i.three.addEventListener(U.ADD_SCENE,a),i.three.addEventListener(U.SET_SCENE,c),i.three.addEventListener(U.REFRESH_SCENE,r),i.three.addEventListener(U.REMOVE_SCENE,o),()=>{i.three.removeEventListener(U.ADD_SCENE,a),i.three.removeEventListener(U.SET_SCENE,c),i.three.removeEventListener(U.REFRESH_SCENE,r),i.three.removeEventListener(U.REMOVE_SCENE,o)}),[]),d.jsxs("div",{id:"SidePanel",children:[d.jsx("div",{className:"scenes",children:t},s),d.jsx(yi,{three:i.three}),d.jsx(On,{three:i.three}),d.jsx(N,{three:i.three})]})}function Ei(i){return d.jsxs("div",{className:"editor",ref:i.ref,style:i.style,children:[d.jsx("div",{className:"header",children:i.header}),i.children,d.jsx("div",{className:"footer",children:i.footer})]})}function wn(i){return d.jsx(Ei,{children:d.jsxs(d.Fragment,{children:[d.jsx(G,{three:i.three,scenes:i.scenes,onSceneAdd:i.onSceneAdd,onSceneResize:i.onSceneResize,onSceneUpdate:i.onSceneUpdate}),d.jsx(bi,{three:i.three})]})})}exports.Accordion=Me;exports.Application=Is;exports.BaseRemote=St;exports.ChildObject=Ot;exports.ContainerObject=$e;exports.DepthNodeMaterial=gi;exports.Draggable=oi;exports.DraggableItem=ai;exports.Dropdown=li;exports.DropdownItem=ci;exports.Editor=Ei;exports.ElementProxy=Ps;exports.ElementProxyReceiver=ni;exports.ExportTexture=le;exports.InfiniteGridHelper=pi;exports.InfiniteGridHelperGPU=fi;exports.InfiniteGridMaterial=ui;exports.InfiniteGridNodeMaterial=mi;exports.Inspector=yi;exports.MultiView=G;exports.NavButton=xt;exports.ProxyManager=Ds;exports.RemoteTheatre=Ns;exports.RemoteThree=Bs;exports.SidePanel=bi;exports.Spline=Ke;exports.SplineEditor=Ci;exports.ThreeEditor=wn;exports.Transform=W;exports.UVMaterial=vi;exports.UVNodeMaterial=_i;exports.WebworkerEventHandlers=As;exports.anchorGeometry=ii;exports.anchorGeometryTL=cs;exports.animateObjectMaterial=rs;exports.animateObjectTransform=ss;exports.applyObjectMaterial=ti;exports.capitalize=je;exports.clamp=de;exports.clearComposerGroups=ys;exports.colorToHex=vt;exports.copyToClipboard=$t;exports.createMask=ps;exports.cubicBezier=Ji;exports.customizeTheatreElements=is;exports.damp=Zi;exports.defaultTheatreCallback=zi;exports.detectMaxFrameRate=Xt;exports.detectSettings=Qt;exports.dispose=re;exports.disposeMaterial=bt;exports.disposeTexture=_t;exports.distance=Yi;exports.generateCubemap=bs;exports.getAngle=$i;exports.getObjectMaterialObject=ei;exports.getObjectMaterialProps=Jt;exports.hierarchyUUID=Te;exports.inspectComposer=Cs;exports.inspectComposerPass=si;exports.isColor=qt;exports.map=Wi;exports.mix=Ae;exports.noop=He;exports.normalize=Xe;exports.orthoCamera=as;exports.parseModelLite=os;exports.randomID=Y;exports.renderToTexture=ls;exports.resetThreeObjects=Ne;exports.rgbaToHex=es;exports.roundTo=X;exports.setMaterialBlendAdd=gs;exports.setMaterialBlendMultiply=vs;exports.setMaterialBlendNormal=fs;exports.setMaterialBlendScreen=_s;exports.supportsOffscreenCanvas=us;exports.triangle=Je;exports.updateCameraOrtho=hs;exports.updateCameraOrtho16x9=ds;exports.useMask=ms;exports.useStudio=ts;
|
|
143
|
+
}`;class vi extends m.ShaderMaterial{constructor(){super({defines:{USE_UV:""},uniforms:{opacity:{value:1}},vertexShader:vn,fragmentShader:_n,transparent:!0})}}class _i extends Zt{constructor(){super(),this.colorNode=ze.vec4(ze.uv(),0,1)}}class W extends m.EventDispatcher{static DRAG_START="Transform::dragStart";static DRAG_END="Transform::dragEnd";static _instance;three;activeCamera;controls=new Map;visibility=new Map;setApp(e){this.three=e,this.three.addEventListener(U.SET_SCENE,this.setScene)}clear(){for(const e of this.controls.values()){e.detach(),e.disconnect();const t=e.getHelper();re(t)}this.controls=new Map,this.visibility=new Map}add(e){let t=this.controls.get(e);if(t===void 0){const s=document.querySelector(".clickable");t=new Fi.TransformControls(this.activeCamera,s),t.getHelper().name=e,t.setSize(.5),t.setSpace("local"),this.controls.set(e,t),this.visibility.set(e,!0),t.addEventListener("mouseDown",()=>{this.dispatchEvent({type:W.DRAG_START})}),t.addEventListener("mouseUp",()=>{this.dispatchEvent({type:W.DRAG_END})}),t.addEventListener("dragging-changed",n=>{G.instance?.toggleOrbitControls(n.value)})}return t}get(e){return this.controls.get(e)}remove(e){const t=this.get(e);return t===void 0?!1:(t.detach(),t.disconnect(),re(t.getHelper()),this.controls.delete(e),!0)}enabled(e){this.controls.forEach(t=>{t.enabled=e})}updateCamera(e,t){this.activeCamera=e,this.controls.forEach(s=>{s.camera!==e&&(s.camera=e,e.getWorldPosition(s.cameraPosition),e.getWorldQuaternion(s.cameraQuaternion)),s.domElement!==t&&(s.disconnect(),s.domElement=t,s.connect(t))})}show(){this.controls.forEach(e=>{const t=e.getHelper(),s=this.visibility.get(t.name);s!==void 0&&(t.visible=s)})}hide(){this.controls.forEach(e=>{const t=e.getHelper();this.visibility.set(t.name,t.visible),t.visible=!1})}setScene=()=>{this.clear()};static get instance(){return W._instance||(W._instance=new W),W._instance}}const Cn=new w.BoxGeometry,ft=new w.Vector2;class Ke extends w.Object3D{curve=new w.CatmullRomCurve3;line;draggable;curvePos;tension=.5;closed=!1;subdivide=50;curveType;offset=1;lineMaterial;_camera;_curvePercentage=0;_draggableScale=10;_transform;raycaster;draggedMat=new w.MeshBasicMaterial;parentGroup;group;constructor(e,t){const s=new w.Color($.lerp(.5,1,Math.random()),$.lerp(.5,1,Math.random()),$.lerp(.5,1,Math.random()));super(),this.name=e,this.lineMaterial=new w.LineBasicMaterial({color:s}),this.line=new w.Line(new w.BufferGeometry,this.lineMaterial),this.line.name="line",this.line.visible=!1,this.add(this.line),this._camera=t,this.curveType="catmullrom",this.draggedMat.color=s,this.draggable=new w.Object3D,this.draggable.name="draggablePoints",this.add(this.draggable),this.curvePos=new w.Mesh(new w.SphereGeometry(1.5),new w.MeshBasicMaterial({color:s})),this.curvePos.name="curvePos",this.curvePos.scale.setScalar(this._draggableScale),this.curvePos.visible=!1,this.add(this.curvePos),this.raycaster=new w.Raycaster,this.raycaster.params.Line.threshold=3,this.enable()}enable(){document.addEventListener("pointerdown",this.onMouseClick)}disable(){document.removeEventListener("pointerdown",this.onMouseClick)}dispose=()=>{this._transform&&(this._transform.removeEventListener("objectChange",this.updateSpline),W.instance.remove(this.name)),this.disable(),this.parentGroup.removeGroup(this.name)};hideTransform=()=>{this._transform?.detach()};exportSpline=()=>{const e=[];this.draggable.children.forEach(t=>{e.push([X(t.position.x,3),X(t.position.y,3),X(t.position.z,3)])}),$t({name:this.name,points:e,tension:this.tension,closed:this.closed,subdivide:this.subdivide,type:this.curveType}),console.log("Spline copied!")};showPoints=(e=!0)=>{this.draggable.visible=e};addPoints=(e=[])=>{if(e.length>0){const t=e.length-1;for(let s=0;s<t;s++)this.addPoint(e[s],!1);this.addPoint(e[t])}};addPoint=(e,t=!0)=>{const s=this.draggable.children.length,n=new w.Mesh(Cn,this.draggedMat);n.name=`point_${s}`,n.position.copy(e),n.scale.setScalar(this._draggableScale),this.draggable.add(n),this._transform?.attach(n);const a=this.points.length>1;return a&&t&&this.updateSpline(),this.line.visible=a,this.updateCurrentPoint(),n};addNextPt=()=>{const e=this.draggable.children.length,t=e>1?this.draggable.children[e-1].position.clone():new w.Vector3,s=this.addPoint(t);this.updateField(s.position)};removePoint=e=>{if(this._transform?.object===e){this._transform?.detach();const t=this.draggable.children[this.draggable.children.length-1];this._transform?.attach(t),this.updateField(t.position)}re(e),this.updateSpline()};removePointAt=e=>{const t=this.draggable.children[e];this.removePoint(t)};removeSelectedPt=()=>{this._transform?.object!==void 0&&this.removePoint(this._transform?.object)};updateLastPoint(e){const t=this.draggable.children.length;t>0&&(this.draggable.children[t-1].position.copy(e),this.updateSpline())}updateSpline=()=>{this.points.length<2||(this.curve=new w.CatmullRomCurve3(this.points,this.closed,this.curveType,this.tension),this.line.geometry.dispose(),this.line.geometry=new w.BufferGeometry().setFromPoints(this.curve.getPoints(this.subdivide)),this.curvePos.position.copy(this.getPointAt(this._curvePercentage)))};updateField(e){this.group.current?.setField("Current Point",e)}onMouseClick=e=>{if(!G.instance||!G.instance.currentWindow||this._transform&&!this._transform.getHelper().visible)return;const s=G.instance.currentWindow.current.getBoundingClientRect();ft.x=(e.clientX-s.x)/s.width*2-1,ft.y=-((e.clientY-s.y)/s.height)*2+1,this.raycaster.setFromCamera(ft,this.camera);const n=this.raycaster.intersectObjects(this.draggable.children,!1);if(n.length>0){const a=n[0].object;a!==this._transform?.object&&(this._transform?.attach(a),this.updateField(a.position))}};getPointAt(e){return this.curve.points.length>1?this.curve.getPointAt(e):this.curve.points.length===1?this.curve.points[0]:new w.Vector3}getTangentAt(e){return this.curve.getTangentAt(e)}get points(){const e=[];return this.draggable.children.forEach(t=>{e.push(t.position)}),e}get total(){return this.draggable.children.length}get draggableScale(){return this._draggableScale}set draggableScale(e){this._draggableScale=e,this.draggable.children.forEach(t=>t.scale.setScalar(e)),this.curvePos.scale.setScalar(e)}get camera(){return this._camera}set camera(e){this._camera=e,this._transform!==void 0&&(this._transform.camera=e)}get curvePercentage(){return this._curvePercentage}set curvePercentage(e){this._curvePercentage=e,this.curvePos.position.copy(this.getPointAt(e))}updateCurrentPoint(){if(this._transform?.object&&this.group){const e=this._transform?.object;e.name.search("point")>-1&&this.updateField(e.position)}}onUpdateTransform=()=>{this.updateCurrentPoint(),this.updateSpline()};initDebug(e,t){const s=this.draggable.children;this.visible=t,this.parentGroup=e,this._transform=W.instance.add(this.name),this._transform.camera=this._camera,this._transform.addEventListener("objectChange",this.onUpdateTransform),s.length>0&&this._transform.attach(s[s.length-1]),G.instance?.helpersContainer.add(this._transform.getHelper());const n=s.length>0?s[s.length-1].position:{x:0,y:0,z:0};this.group=e.addGroup({title:this.name,expanded:t,items:[{prop:"Closed",type:"boolean",value:this.closed},{prop:"Visible",type:"boolean",value:this.visible},{prop:"Show Position",type:"boolean",value:this.curvePos.visible},{prop:"Show Points",type:"boolean",value:this.draggable.visible},{prop:"Color",type:"color",value:`#${this.draggedMat.color.getHexString()}`},{prop:"Curve",type:"option",options:[{title:"Catmullrom",value:"catmullrom"},{title:"Centripetal",value:"centripetal"},{title:"Chordal",value:"chordal"}]},{prop:"Draggable Scale",type:"range",min:.01,max:100,step:.01,value:this._draggableScale},{prop:"Subdivide",type:"range",min:1,max:1e3,step:1,value:this.subdivide},{prop:"Tension",type:"range",min:0,max:1,step:.01,value:this.tension},{prop:"New Pt Offset",type:"range",min:0,max:10,value:this.offset},{prop:"Curve At",type:"range",min:0,max:1,step:.01,value:0},{prop:"Toggle Transform",type:"button"},{prop:"Add Point",type:"button"},{prop:"Remove Point",type:"button"},{prop:"Export",type:"button"},{prop:"Delete",type:"button"},{prop:"Current Point",type:"grid3",value:n}],onUpdate:(a,r)=>{switch(a){case"Closed":this.closed=r,this.updateSpline();break;case"Visible":this.visible=r;break;case"Color":this.lineMaterial.color.setStyle(r),this.draggedMat.color.setStyle(r);break;case"Curve":this.curveType=r,this.updateSpline();break;case"Draggable Scale":this.draggableScale=r;break;case"Subdivide":this.subdivide=r,this.updateSpline();break;case"Tension":this.tension=r,this.updateSpline();break;case"New Pt Offset":this.offset=r;break;case"Curve At":this.curvePos.position.copy(this.getPointAt(r));break;case"Show Position":this.curvePos.visible=r;break;case"Show Points":this.draggable.visible=r;break;case"Toggle Transform":this._transform&&(this._transform.getHelper().visible=!this._transform.getHelper().visible);break;case"Add Point":this.addNextPt();break;case"Remove Point":this.removeSelectedPt();break;case"Export":this.exportSpline();break;case"Delete":this.parent.currentSpline=null,re(this);break;case"Current Point":if(this.group.current&&this._transform?.object){const o=this._transform?.object;o.name.search("point")>-1&&(o.position.copy(r),this.updateSpline())}break}}}),this.draggable.children.forEach(a=>{this.debugPoint(a)})}debugPoint=e=>{e.name,e.visible=this.draggable.visible}}let Ze=0;class Ci extends m.Object3D{defaultScale=10;currentSpline=null;_camera;group=null;three;splineDataText="";constructor(e,t){super(),this.name="Spline Editor",this._camera=e,this.three=t,this.three.addEventListener(U.ADD_SPLINE,this.onAddSpline)}initDebug(){this.group=N.addEditorGroup({title:this.name,items:[{type:"field",prop:"Spline Data",value:"",disabled:!1},{type:"button",prop:"Import Spline"},{type:"button",prop:"New Spline"},{type:"boolean",prop:"Show Points",value:!0},{type:"boolean",prop:"Draw Mode",value:!1},{type:"boolean",prop:"Visible",value:this.visible},{type:"range",prop:"Default Scale",min:0,max:50,step:.01,value:this.defaultScale}],onUpdate:(e,t)=>{switch(e){case"New Spline":this.createSpline();break;case"Spline Data":this.splineDataText=t;break;case"Import Spline":this.createSplineFromJSON(JSON.parse(this.splineDataText));break;case"Show Points":this.showPoints(t);break;case"Visible":this.visible=t;break;case"Default Scale":this.defaultScale=t;break;case"Draw Mode":t?this.enableClickToDraw():this.disableClickToDraw();break}}})}dispose(){this.three.removeEventListener(U.ADD_SPLINE,this.onAddSpline),N.removeEditorGroup(this.name)}addSpline(e,t){e.draggableScale=this.defaultScale,e.hideTransform(),this.group?.current!==null&&e.initDebug(this.group.current,t),this.add(e),this.currentSpline=e}createSpline=(e=[])=>{const t=`Spline ${Ze+1}`,s=new Ke(t,this._camera);return s.addPoints(e),this.addSpline(s,!0),Ze++,s};createSplineFromArray=e=>{const t=[];return e.forEach(s=>{t.push(new m.Vector3(s[0],s[1],s[2]))}),this.createSpline(t)};createSplineFromCatmullRom=e=>this.createSpline(e.points);createSplineFromJSON=e=>{const t=[];e.points.forEach(n=>{t.push(new m.Vector3(n[0],n[1],n[2]))});const s=new Ke(e.name,this._camera);return s.closed=e.closed,s.subdivide=e.subdivide,s.tension=e.tension,s.type=e.type,s.addPoints(t),s.updateSpline(),this.addSpline(s,!1),s};showPoints=(e=!0)=>{this.children.forEach(t=>{t.showPoints(e)})};onAddSpline=e=>{const t=JSON.parse(e.value),s=t.name!==void 0?t.name:`Spline ${Ze+1}`,n=new Ke(s,this.camera);t.tension!==void 0&&(n.tension=t.tension),t.closed!==void 0&&(n.closed=t.closed),t.subdivide!==void 0&&(n.subdivide=t.subdivide),t.type!==void 0&&(n.curveType=t.type);const a=[];t.points.forEach(r=>{a.push(new m.Vector3(r[0],r[1],r[2]))}),n.addPoints(a),this.addSpline(n,!1),Ze++};isMouseDown=!1;enableClickToDraw(){document.querySelectorAll(".clickable").forEach(e=>{e.addEventListener("mousedown",this.onClickCanvas),e.addEventListener("mousemove",this.onMouseMove),e.addEventListener("mouseup",this.onMouseUp)})}disableClickToDraw(){document.querySelectorAll(".clickable").forEach(e=>{e.removeEventListener("mousedown",this.onClickCanvas),e.removeEventListener("mousemove",this.onMouseMove),e.removeEventListener("mouseup",this.onMouseUp)})}onClickCanvas=e=>{if(e.button!==0)return;if(this._camera.type!=="OrthographicCamera"){console.warn("Spline Editor - 3D Camera not supported in Draw Mode");return}const s=e.target.getBoundingClientRect(),n=(e.clientX-s.left)/s.width*2-1,a=-((e.clientY-s.top)/s.height)*2+1;if(G.instance){const o=new m.Raycaster;o.setFromCamera(new m.Vector2(n,a),this._camera);const c=o.intersectObjects(G.instance.helpersContainer.children,!0);for(let l=0;l<c.length;l++){const h=c[l];if(!(h.object.isLine||h.object.isTransformControlsPlane)&&h.object.isObject3D)return}}this.currentSpline===null&&(this.currentSpline=this.createSpline());const r=this.mouseToSplinePos(n,a,s.width,s.height);this.currentSpline?.addPoint(r),this.isMouseDown=!0};onMouseMove=e=>{if(!this.isMouseDown)return;const s=e.target.getBoundingClientRect(),n=(e.clientX-s.left)/s.width*2-1,a=-((e.clientY-s.top)/s.height)*2+1,r=this.mouseToSplinePos(n,a,s.width,s.height);this.currentSpline?.updateLastPoint(r),this.currentSpline?.updateField(r)};onMouseUp=()=>{this.isMouseDown=!1};mouseToSplinePos(e,t,s,n){const a=new m.Vector3,r=Math.PI/2,o=this._camera,c=o.zoom,l=o.rotation.x===-6123233995736766e-32&&o.rotation.y===0&&o.rotation.z===0,h=o.rotation.x===-Math.PI&&o.rotation.y===12246467991473532e-32&&o.rotation.z===Math.PI,u=o.rotation.x===-6162975822039155e-48&&o.rotation.y===-r&&o.rotation.z===0,p=o.rotation.x===-6162975822039155e-48&&o.rotation.y===r&&o.rotation.z===0,g=o.rotation.x===-1.5707953264174506&&o.rotation.y===0&&o.rotation.z===0,y=o.rotation.x===1.5707953264174506&&o.rotation.y===0&&o.rotation.z===0;let _=e,E=t;h||p?_*=-1:g&&(E*=-1);const v=s/2/c,C=n/2/c;if(this.currentSpline===null&&(this.currentSpline=this.createSpline()),l||h){const x=_*v+o.position.x,O=E*C+o.position.y;a.set(x,O,0)}else if(u||p){const x=_*v+o.position.z,O=E*C+o.position.y;a.set(0,O,x)}else if(g||y){const x=_*v+o.position.x,O=E*C+o.position.z;a.set(x,0,O)}return a}get camera(){return this._camera}set camera(e){this._camera=e,this.children.forEach(t=>{const s=t;s.camera=e})}}const Wt=["Single","Side by Side","Stacked","Quad"],yn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAC60lEQVRYhe2YT4hNcRTHP48xpmYaNAvRyEQxEhnKQljYsRm9/EmSyJiMFAsMZWNhJYoNIUVJ2VGiyb9ZzIpMpkQSahbGv9GMYWrM+1rc2zjvzvvdd+99rzdvMd+6de75nd+5387vnN/v/G5KEuWMKRNNIB8mCRaKiiL5qQb2ApuBuUAV0Ad0AJeB3sSeJRX6LJbULTf6JTUn9Z+KWMUpPyp/Avoa4CNQZ3Sj/lNpdL/xottR7AjOkHRUUpekN5I6JbVLavDH75lIfZN0UFKTpCWS0pJem/HeJBEMG6yV1ONYtgFJbZJ+GF1jDh+zJb03NuliEuwMkMo4yErS2RA/LcbuYVyCrm1mA7Dal/8Cu4FG4JD/HsTTkCy6a+SVMTPQuc1sBKb78nHghi+/A+YBxwL2lbhRY+ThuARdEVxu5JdGFvACr0otdoZ8Y4+Rn0Sn5sFFsMvI6YB9MzA1YJ8mN8k1wAHzfj4uQVdyrpI0aJL7oqTtkq4FiqPLyCOSbktqlbRL0jlJQ2b8QdwCUZ4qvhRStZL0XFK1pMd57CRvq5mfhKBriRfiFUMY6oD7eOdwPlQAN4G10dfWg+uouwXsiOssAj4AC+JMcEWwvnAuOTEr7gTXPmg34zagOwkbIIOXAo9CbDYBrcBXYN+4UUdy2sRflyS5zVNlfPX7ugpJW5V9nI7mmh+lYU0lCZ2B3TOnAVuAk0BTwC5nuhWro46KauBOQJch5OpRaoIW34GreGf+YZdRqS9NAj4Bp4ClQDvwOWxCqSM4ADQEdKE5XvbXzlITrAVe4TW+M6NMKDXBFLAMuAD0ACfIc7pMZBXXA2cY3/xmodQRHAL2A2+NLtj8ZiEKwUL/z2WMPAJcAVYALWSf8dZuDFGWeBHwKxm3sWYhiGG8Tfo6sA2vSfiSy4GrH3wGrDcfKSSKKf6v1E9yF0XK9Q1XBPuMXMw8HXTonQFwETwNzMFr64v1jzgFHIk9ybHEZYPJo65QlD3Bf2/Q/eaHPiSWAAAAAElFTkSuQmCC",bn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAETklEQVRYhe2YXYhVVRTHf3d0/JhyUrMpFbImM+whSa3Mynww+4AeIgiKoozooQ+KyMyXIAujF6OXqHyI6iEKKYgIP/owsjSFqCkprdDUTEcjbWZ0HHV+Pex1ucfb9Z57Z9REXHA4Z++99l7/s/ZZ/7X2KaiczNLwfwPIk9MA+yunNMAG4DHgV+BvoB3YFff2TPstYEyfrajVroI6Sr1GvahsbJC63HzZq04pmztSvU5tVRuqYRiYg78JeBR4HPg5ntdmxovz9wJfA3uAxuibDLQCA+IqynnAQuBuYCnwMLC1rx48U12U8cZqdWqMDcx4cI16qTpYbVKHqa+ovWUeHKsujn7VL9ULq2HI+wY7gVeBJdGeFu3J4ZUiy/cAXeHRRuAQsC/GC0B3eG4BcH/0tUV7czUAeVsMsBF4Kha9HZgCvAncAuwPnXHA0wFuGLANuDrGuoGDwFxgTqzzQ7RX5FrP2eLsdb76vnogtme6+nE8H1YPlQXHwbi3q9eqn0e7Tb25VrsF68vFY0lb1AGcDTwItGQ8tQM4AIwGmqP/EPAu8A0wElgJfFGzxTo8mKWXu9Rd4ZF96jvqjSbauEC9Sn1O3R463epLaku99voCsFXdkAH3kNpcQW+IiT/bQne3eufxBtioPqP2mKhioXpWzpxb1T8C5Ifh4ZptVoriRmAIKdrI3Lujf3bobAPeJpF0NVkKrAFuI9HTOBIxnxFrF4OgQKKr/dnJlQA+AcwABgOHA4zAamA5cE7orQL+zAEHiWI+A2bFC7aSguheYCgpqAphZz3wSB7AecCICv2TgH8oFRib4gVqka0k0h8CXAxMBW6ooDejFoCvA9OBQUAvKWM0kDz4XUZvNKXtyZMWUl7vBbaQXq457PeEziDgx/KJlQAuIPFdMcEXv5OdYWBP9M8k8VpnDQCvB4aTSrCNJB5cSdrW3tBpIJVnR0qdUTxAfdGUOVTnmwqEanNmqltC/9OgqePKg5eom8PgdvW+oJ9Kupera0O3U50TL3lcAaI+oHaF4R3qa6Z822wq0Saq89T1lmSxOrxeW/Xm4uGkiqQDmECKuKHxHW0HdpMiewSpvGqKeR8Ay0iBsYIjg6261PE2o9Q3Yqv+MqWxO9R1Hl12qs+q49Vlppy82pSr+5xJKsko4AXgHlJ0t5NIeg3wLXAlqZhtIUV8J6nmWwX8QiLjdhL5TwMWkY4R6/rrwYKlMr1Y321QZ/vfwBijPqm+rF4Wc7PjE9QllurGVeoV5gRNHsAm9fnMom3qrKPoTjKdMXaYyrFygEWQ72XWW24qhPu8xcUc2UU6O8wFPjmK7jhgPHAuMJGUGQ6U6WwE5sfzTXGvei7KA9hFOiR9D/wOfFVFt4dS2tpfRe83Ur7/CPiJakfOGgBCypubatArl2r8VfOax/LfzABKtePAzHO/5FgC7KBEzB2kOrDfUm8mOeFySv9+OyFyGmB/5aQH+C9BVKmVCNuMZgAAAABJRU5ErkJggg==",En="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAQ0lEQVQ4jWP8////fwYqAxYozUhFM/8zkaKYWIWkGEq0b0ZdSjQY5i79TyWagRGaTUdzFEEw6lLqGzqwLoVVJ1StpwA9sBwbUqAh5gAAAABJRU5ErkJggg==";class G extends b.Component{static instance=null;scene;renderer;currentScene;scenes=new Map;cameras=new Map;controls=new Map;currentCamera;currentWindow;helpersContainer=new w.Group;grid;cameraHelpers=new Map;lightHelpers=new Map;interactionHelper=new w.AxesHelper(25);currentTransform;splineEditor;depthMaterial;normalsMaterial;uvMaterial;wireframeMaterial=new w.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0});playing=!1;rafID=-1;cameraControlsRafID=-1;width=0;height=0;tlCam=null;trCam=null;blCam=null;brCam=null;tlRender="Renderer";trRender="Renderer";blRender="Renderer";brRender="Renderer";cameraVisibility=!0;lightVisibility=!0;gridVisibility=!0;rendererReady=!1;selectedItem=void 0;debugCamera;raycaster=new w.Raycaster;pointer=new w.Vector2;cameraControls=void 0;canvasRef;containerRef;tlWindow;trWindow;blWindow;brWindow;editorCameras=["Top","Bottom","Left","Right","Front","Back","Orthographic","UI","Debug"];constructor(e){super(e),this.props.three.addEventListener(U.ADD_RENDERER,this.setupRenderer),this.scene=new w.Scene,this.scene.name=this.scene.uuid="",this.canvasRef=b.createRef(),this.containerRef=b.createRef(),this.tlWindow=b.createRef(),this.trWindow=b.createRef(),this.blWindow=b.createRef(),this.brWindow=b.createRef();const t=e.three.name,s=localStorage,n=s.getItem(`${t}_mode`);this.state={mode:n!==null?n:"Single",modeOpen:!1,renderModeOpen:!1,interactionMode:"Orbit",interactionModeOpen:!1,lastUpdate:Date.now()},s.setItem(`${t}_mode`,this.state.mode),s.setItem(`${t}_tlCam`,s.getItem(`${t}_tlCam`)!==null?s.getItem(`${t}_tlCam`):"Debug"),s.setItem(`${t}_trCam`,s.getItem(`${t}_trCam`)!==null?s.getItem(`${t}_trCam`):"Orthographic"),s.setItem(`${t}_blCam`,s.getItem(`${t}_blCam`)!==null?s.getItem(`${t}_blCam`):"Front"),s.setItem(`${t}_brCam`,s.getItem(`${t}_brCam`)!==null?s.getItem(`${t}_brCam`):"Top"),s.setItem(`${t}_tlRender`,s.getItem(`${t}_tlRender`)!==null?s.getItem(`${t}_tlRender`):"Renderer"),s.setItem(`${t}_trRender`,s.getItem(`${t}_trRender`)!==null?s.getItem(`${t}_trRender`):"Renderer"),s.setItem(`${t}_blRender`,s.getItem(`${t}_blRender`)!==null?s.getItem(`${t}_blRender`):"Renderer"),s.setItem(`${t}_brRender`,s.getItem(`${t}_brRender`)!==null?s.getItem(`${t}_brRender`):"Renderer");const a={Vector2:w.Vector2,Vector3:w.Vector3,Vector4:w.Vector4,Quaternion:w.Quaternion,Matrix4:w.Matrix4,Spherical:w.Spherical,Box3:w.Box3,Sphere:w.Sphere,Raycaster:w.Raycaster};ne.install({THREE:a}),this.setupScene(),this.setupTools();const r=localStorage.getItem(this.expandedCameraVisibility);r!==null&&(this.cameraVisibility=r==="open"),this.saveExpandedCameraVisibility();const o=localStorage.getItem(this.expandedLightVisibility);o!==null&&(this.lightVisibility=o==="open"),this.saveExpandedLightVisibility();const c=localStorage.getItem(this.expandedGridVisibility);c!==null&&(this.gridVisibility=c==="open"),this.grid&&(this.grid.visible=this.gridVisibility),this.saveExpandedGridVisibility(),G.instance=this}componentDidMount(){this.enable(),this.assignControls(),this.resize(),this.play(),W.instance.setApp(this.props.three),W.instance.activeCamera=this.debugCamera,this.props.three.requestRenderer()}componentDidUpdate(e,t,s){t.mode!==this.state.mode&&(this.assignControls(),this.resize())}componentWillUnmount(){this.disable(),this.clear(),N.removeEditorGroup("View Settings")}render(){const e=[];return this.cameras.forEach((t,s)=>{e.push(s)}),d.jsxs("div",{className:"multiview",children:[d.jsx("canvas",{ref:this.canvasRef}),d.jsxs("div",{className:`cameras ${this.state.mode==="Single"||this.state.mode==="Stacked"?"single":""}`,ref:this.containerRef,children:[this.state.mode==="Single"&&d.jsx(d.Fragment,{children:d.jsx(ge,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}})}),(this.state.mode==="Side by Side"||this.state.mode==="Stacked")&&d.jsxs(d.Fragment,{children:[d.jsx(ge,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),d.jsx(ge,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.trCam),this.trCam=s,localStorage.setItem(`${this.appID}_trCam`,s.name),this.createControls(s,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}})]}),this.state.mode==="Quad"&&d.jsxs(d.Fragment,{children:[d.jsx(ge,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),d.jsx(ge,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.trCam),this.trCam=s,localStorage.setItem(`${this.appID}_trCam`,s.name),this.createControls(s,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}}),d.jsx(ge,{name:"bl",camera:this.blCam,options:e,ref:this.blWindow,onSelectCamera:t=>{this.controls.get(this.blCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.blCam),this.blCam=s,localStorage.setItem(`${this.appID}_blCam`,s.name),this.createControls(s,this.blWindow.current))},onSelectRenderMode:t=>{this.blRender=t,localStorage.setItem(`${this.appID}_blRender`,t)}}),d.jsx(ge,{name:"br",camera:this.brCam,options:e,ref:this.brWindow,onSelectCamera:t=>{this.controls.get(this.brCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.brCam),this.brCam=s,localStorage.setItem(`${this.appID}_brCam`,s.name),this.createControls(s,this.brWindow.current))},onSelectRenderMode:t=>{this.brRender=t,localStorage.setItem(`${this.appID}_brRender`,t)}})]})]}),d.jsxs("div",{className:"settings",children:[d.jsx(Qe,{title:"View",index:Wt.indexOf(this.state.mode),options:Wt,onSelect:t=>{t!==this.state.mode&&(this.killControls(),this.setState({mode:t}),localStorage.setItem(`${this.appID}_mode`,t))},open:this.state.modeOpen,onToggle:t=>{this.setState({modeOpen:t,renderModeOpen:!1,interactionModeOpen:!1})}}),d.jsx(Qe,{title:"Interact",index:this.state.interactionMode==="Orbit"?0:1,options:["Orbit Mode","Selection Mode"],onSelect:t=>{this.interactionHelper.visible=t==="Selection Mode",this.setState({interactionMode:this.interactionHelper.visible?"Selection":"Orbit"})},open:this.state.interactionModeOpen,onToggle:t=>{this.setState({modeOpen:!1,renderModeOpen:!1,interactionModeOpen:t})}}),d.jsx(mt,{name:"cameraHelper",icon:yn,selected:this.cameraVisibility,height:24,top:2,onClick:t=>{if(this.cameraVisibility=t,this.saveExpandedCameraVisibility(),this.cameraHelpers.forEach(s=>{s.visible=t}),this.selectedItem!==void 0&&!t){const s=this.cameraHelpers.get(this.selectedItem.name);s!==void 0&&(s.visible=!0)}}}),d.jsx(mt,{name:"lightHelper",icon:bn,selected:this.lightVisibility,height:24,top:4,onClick:t=>{if(this.lightVisibility=t,this.saveExpandedLightVisibility(),this.lightHelpers.forEach(s=>{s.visible=t}),this.selectedItem!==void 0&&!t&&this.selectedItem.isLight===!0){const s=this.lightHelpers.get(this.selectedItem.name);s!==void 0&&(s.visible=!0)}}}),d.jsx(mt,{name:"gridHelper",icon:En,selected:this.gridVisibility,height:21,width:21,onClick:t=>{this.setGridVisibility(t)}})]},this.state.lastUpdate)]})}setupRenderer=e=>{const t=e.value;if(this.renderer){if(this.renderer instanceof m.WebGLRenderer&&t.type==="WebGLRenderer"||this.renderer instanceof w.WebGPURenderer&&t.type==="WebGPURenderer")return;this.renderer.dispose()}this.rendererReady=!1;const s=this.canvasRef.current;this.props.three.canvas=s,t.type==="WebGLRenderer"?(this.renderer=new m.WebGLRenderer({canvas:s,stencil:!1}),this.depthMaterial=new w.MeshDepthMaterial,this.normalsMaterial=new w.MeshNormalMaterial,this.uvMaterial=new vi,this.grid=new pi,this.scene.add(this.grid),this.rendererReady=!0):t.type==="WebGPURenderer"&&(this.renderer=new w.WebGPURenderer({canvas:s,stencil:!1}),this.grid=new fi,this.scene.add(this.grid)),this.renderer&&(this.renderer.autoClear=!1,this.renderer.shadowMap.enabled=!0,this.renderer.setClearColor(0),this.renderer.setPixelRatio(devicePixelRatio),this.renderer.setScissorTest(!0),this.resize(),this.props.three.renderer=this.renderer,this.depthMaterial=new gi,this.normalsMaterial=new w.MeshNormalNodeMaterial,this.uvMaterial=new _i,t.type==="WebGPURenderer"?this.renderer.init().then(()=>{this.rendererReady=!0,this.props.three.requestScene()}):this.props.three.requestScene())};setupScene(){this.helpersContainer.name="helpers",this.scene.add(this.helpersContainer),this.interactionHelper.name="interactionHelper",this.interactionHelper.visible=!1,this.helpersContainer.add(this.interactionHelper);const e=(a,r)=>{const o=new w.OrthographicCamera(-100,100,100,-100,0,3e3);return o.name=a,o.position.copy(r),o.lookAt(0,0,0),this.cameras.set(a,o),o},t=1e3;e("Top",new w.Vector3(0,t,0)),e("Bottom",new w.Vector3(0,-t,0)),e("Left",new w.Vector3(-t,0,0)),e("Right",new w.Vector3(t,0,0)),e("Front",new w.Vector3(0,0,t)),e("Back",new w.Vector3(0,0,-t)),e("Orthographic",new w.Vector3(t,t,t)),e("UI",new w.Vector3),this.debugCamera=new w.PerspectiveCamera(60,1,.01,3e3),this.debugCamera.name="Debug",this.debugCamera.position.set(300,300,300),this.debugCamera.lookAt(0,0,0),this.cameras.set("Debug",this.debugCamera),this.currentCamera=this.debugCamera;const s=localStorage,n=this.props.three.name;this.tlCam=this.cameras.get(s.getItem(`${n}_tlCam`)),this.trCam=this.cameras.get(s.getItem(`${n}_trCam`)),this.blCam=this.cameras.get(s.getItem(`${n}_blCam`)),this.brCam=this.cameras.get(s.getItem(`${n}_brCam`)),this.tlCam===void 0&&(this.tlCam=this.cameras.get("Debug")),this.trCam===void 0&&(this.trCam=this.cameras.get("Orthographic")),this.blCam===void 0&&(this.blCam=this.cameras.get("Front")),this.brCam===void 0&&(this.brCam=this.cameras.get("Top")),N.addEditorGroup({title:"Editor",items:[{type:"button",prop:"Hide All Transforms"},{type:"button",prop:"Resize"}],onUpdate:(a,r)=>{switch(a){case"Hide All Transforms":W.instance.hide();break;case"Resize":this.resize();break}},subgroups:[{title:"Debug Camera",items:[{type:"range",prop:"Near",step:1e-4,min:.001,max:1e3,value:this.debugCamera.near},{type:"range",prop:"Far",step:.001,min:.001,max:1e4,value:this.debugCamera.far}],onUpdate:(a,r)=>{switch(a){case"Near":this.debugCamera.near=r,this.debugCamera.updateProjectionMatrix();break;case"Far":this.debugCamera.far=r,this.debugCamera.updateProjectionMatrix();break}}},{title:"Grid",items:[{type:"number",prop:"Position",value:0},{type:"color",prop:"Color",value:"#FFFFFF"},{type:"range",prop:"Grid Opacity",value:.25,min:0,max:1,step:.01},{type:"range",prop:"Subgrid Opacity",value:.15,min:0,max:1,step:.01}],onUpdate:(a,r)=>{switch(a){case"Position":this.grid&&(this.grid.position.y=r);break;case"Color":this.grid&&this.grid.color.setStyle(r);break;case"Grid Opacity":this.grid&&(this.grid.gridOpacity=r);break;case"Subgrid Opacity":this.grid&&(this.grid.subgridOpacity=r);break}}}]})}setupTools(){this.splineEditor=new Ci(this.currentCamera,this.three),this.splineEditor.initDebug(),this.helpersContainer.add(this.splineEditor)}play(){this.playing=!0,this.onUpdate()}pause(){this.playing=!1,cancelAnimationFrame(this.rafID),this.rafID=-1}toggleOrbitControls(e){this.controls.forEach(t=>{t.enabled=!e})}clear(){this.three.dispatchEvent({type:U.CLEAR_OBJECT}),N.removeAllGroups(),this.clearLightHelpers(),this.clearControls(),this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),W.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=void 0,W.instance.clear(),this.cameras.forEach(e=>{this.editorCameras.indexOf(e.name)<0&&this.three.dispatchEvent({type:U.REMOVE_CAMERA,value:e})}),this.currentCamera=this.debugCamera,this.currentScene=void 0,this.scenes.forEach(e=>{this.three.dispatchEvent({type:U.REMOVE_SCENE,value:e})}),this.scenes.clear()}setGridVisibility(e){this.gridVisibility=e,this.saveExpandedGridVisibility(),this.grid&&(this.grid.visible=e)}update(){this.renderer&&this.rendererReady&&this.renderer?.clear(),this.controls.forEach(e=>e.update()),this.cameraHelpers.forEach(e=>e.update()),this.lightHelpers.forEach(e=>{e.update!==void 0&&e.update()}),this.props.onSceneUpdate!==void 0&&this.currentScene!==void 0&&this.props.onSceneUpdate(this.currentScene)}draw(){if(this.rendererReady)switch(this.renderer&&this.renderer?.clear(),this.state.mode){case"Single":this.drawSingle();break;case"Side by Side":case"Stacked":this.drawDouble();break;case"Quad":this.drawQuad();break}}onUpdate=()=>{this.playing&&(this.update(),this.draw(),this.rafID=requestAnimationFrame(this.onUpdate))};enable(){const e=this.containerRef.current;e.addEventListener("mousemove",this.onMouseMove),e.addEventListener("click",this.onClick),window.addEventListener("keydown",this.onKey),window.addEventListener("resize",this.resize),this.three.addEventListener(U.ADD_SCENE,this.addScene),this.three.addEventListener(U.SET_SCENE,this.sceneUpdate),this.three.addEventListener(U.REMOVE_SCENE,this.removeScene),this.three.addEventListener(U.ADD_CAMERA,this.addCamera),this.three.addEventListener(U.REMOVE_CAMERA,this.removeCamera),this.three.addEventListener(U.SET_OBJECT,this.onSetSelectedItem)}disable(){const e=this.containerRef.current;e.removeEventListener("mousemove",this.onMouseMove),e.removeEventListener("click",this.onClick),window.removeEventListener("keydown",this.onKey),window.removeEventListener("resize",this.resize),this.three.removeEventListener(U.ADD_SCENE,this.addScene),this.three.removeEventListener(U.SET_SCENE,this.sceneUpdate),this.three.removeEventListener(U.ADD_CAMERA,this.addCamera),this.three.removeEventListener(U.REMOVE_CAMERA,this.removeCamera),this.three.removeEventListener(U.SET_OBJECT,this.onSetSelectedItem)}resize=()=>{this.width=window.innerWidth-300,this.height=window.innerHeight,this.renderer?.setSize(this.width,this.height);const e=Math.floor(this.width/2),t=Math.floor(this.height/2);this.props.three.resize(this.width,this.height),this.props.onSceneResize!==void 0&&this.currentScene!==void 0&&this.props.onSceneResize(this.currentScene,this.width,this.height);let s=this.width,n=this.height;switch(this.state.mode){case"Side by Side":s=e,n=this.height;break;case"Stacked":s=this.width,n=t;break;case"Quad":s=e,n=t;break}const a=s/n;this.cameras.forEach(r=>{r instanceof w.OrthographicCamera?(r.left=s/-2,r.right=s/2,r.top=n/2,r.bottom=n/-2,r.name==="UI"&&(r.position.x=this.width/2,r.position.y=this.height/-2,r.position.z=100),r.updateProjectionMatrix()):r instanceof w.PerspectiveCamera&&(r.aspect=a,r.updateProjectionMatrix()),this.cameraHelpers.get(r.name)?.update()})};addScene=e=>{const t=this.props.scenes.get(e.value.name);if(t!==void 0){const s=this.scenes.get(e.value.name);if(s!==void 0){this.props.onSceneAdd!==void 0&&this.props.onSceneAdd(s),this.props.three.scene=s;return}const n=new t;n.visible=!1,this.props.onSceneAdd!==void 0&&this.props.onSceneAdd(n),this.props.three.scene=n,this.scenes.set(e.value.name,n),this.scene.add(n)}else console.log("Hermes - Scene not found:",e.value.name,this.props.scenes)};sceneUpdate=e=>{this.currentScene!==void 0&&(this.currentScene.visible=!1,this.clearLightHelpers());const t=this.scene.getObjectByName(e.value.name);t!==void 0&&(this.currentScene=t,this.currentScene.visible=!0,this.addLightHelpers(this.currentScene))};removeScene=e=>{const t=e.value.name;this.scenes.delete(t);const s=this.scene.getObjectByName(t);s&&setTimeout(()=>{re(s)},100),this.clearLightHelpers()};addCamera=e=>{const t=e.value,s=t.uuid,n=this.props.three.scene?.getObjectByProperty("uuid",t.uuid);if(n!==void 0){const a=n;this.cameras.set(s,a);const r=new w.CameraHelper(a);r.visible=this.cameraVisibility,this.cameraHelpers.set(s,r),this.helpersContainer.add(r),this.setState({lastUpdate:Date.now()})}};removeCamera=e=>{const s=e.value.uuid,n=this.cameraHelpers.get(s);n!==void 0&&(this.helpersContainer.remove(n),n.dispose()),this.cameras.delete(s),this.setState({lastUpdate:Date.now()})};onMouseMove=e=>{const t=new w.Vector2;this.renderer?.getSize(t);const s=Math.min(e.clientX,t.x),n=Math.min(e.clientY,t.y);this.pointer.x=$.mapLinear(s,0,t.x,-1,1),this.pointer.y=$.mapLinear(n,0,t.y,1,-1);const a=t.x/2,r=t.y/2,o=()=>{s<a?this.pointer.x=$.mapLinear(s,0,a,-1,1):this.pointer.x=$.mapLinear(s,a,t.x,-1,1)},c=()=>{n<r?this.pointer.y=$.mapLinear(n,0,r,1,-1):this.pointer.y=$.mapLinear(n,r,t.y,1,-1)};switch(this.state.mode){case"Quad":o(),c();break;case"Side by Side":o();break;case"Stacked":c(),c();break}if(this.updateCamera(s,n,a,r),this.state.interactionMode==="Orbit"||this.currentScene===void 0)return;const l=this.raycaster.intersectObjects(this.currentScene.children);l.length>0&&this.interactionHelper.position.copy(l[0].point)};onClick=e=>{if(this.state.interactionMode==="Orbit"||this.currentScene===void 0)return;const t=new w.Vector2;if(this.renderer.getSize(t),e.clientX>=t.x)return;this.onMouseMove(e);const s=this.raycaster.intersectObjects(this.currentScene.children);s.length>0&&(this.props.three.getObject(s[0].object.uuid),this.interactionHelper.visible=!1,this.setState({interactionMode:"Orbit",lastUpdate:Date.now()}))};onKey=e=>{if(this.selectedItem!==void 0){if(e.ctrlKey){if(this.currentCamera.name==="UI")return;const t=this.controls.get(this.currentCamera.name);e.key==="0"?(e.preventDefault(),this.clearControls(),this.cameraControls=new ne(this.currentCamera,this.currentWindow.current),this.selectedItem instanceof w.Mesh||this.selectedItem instanceof w.SkinnedMesh?(this.selectedItem.geometry.computeBoundingBox(),this.cameraControls.fitToBox(this.selectedItem.geometry.boundingBox,!0)):this.cameraControls.fitToSphere(this.selectedItem,!0),this.updateCameraControls(t,!0)):e.key==="1"?(e.preventDefault(),this.clearControls(),this.cameraControls=new ne(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,Math.PI*.5,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(t)):e.key==="2"?(e.preventDefault(),this.clearControls(),this.cameraControls=new ne(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,0,!0),this.cameraControls.moveTo(this.selectedItem.position.x,0,this.selectedItem.position.z,!0),this.updateCameraControls(t)):e.key==="3"?(e.preventDefault(),this.clearControls(),this.cameraControls=new ne(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI/2,Math.PI/2,!0),this.cameraControls.moveTo(0,this.selectedItem.position.y,this.selectedItem.position.z,!0),this.updateCameraControls(t)):e.key==="4"?(e.preventDefault(),this.clearControls(),this.cameraControls=new ne(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI,Math.PI/2,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(t)):e.key==="5"&&(e.preventDefault(),this.clearControls(),this.cameraControls=new ne(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo($.degToRad(45),$.degToRad(45),!0),this.updateCameraControls(t))}else if(this.currentTransform!==void 0)switch(e.key){case"r":this.currentTransform.setMode("rotate");break;case"s":this.currentTransform.setMode("scale");break;case"t":this.currentTransform.setMode("translate");break;case"q":this.currentTransform.setSpace(this.currentTransform.space==="local"?"world":"local");break}}};onSetSelectedItem=e=>{this.selectedItem!==void 0&&this.updateSelectedItemHelper(!1),this.selectedItem=void 0;const t=e.value.uuid;if(this.scenes.forEach(s=>{t.search(s.uuid)>-1&&(this.selectedItem=s.getObjectByProperty("uuid",t))}),this.selectedItem===void 0){console.log(`Hermes - Can't find selected item: ${e.value.uuid}, ${e.value.name}`);return}this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),W.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=W.instance.add(e.value.name),this.currentTransform&&(this.currentTransform.attach(this.selectedItem),this.helpersContainer.add(this.currentTransform.getHelper()),this.currentTransform.addEventListener("objectChange",this.onUpdateTransform)),this.updateSelectedItemHelper(!0)};updateSelectedItemHelper(e){if(this.selectedItem!==void 0)if(this.cameraVisibility){if(this.selectedItem.isLight===!0&&!this.lightVisibility){const t=this.lightHelpers.get(this.selectedItem.name);t!==void 0&&(t.visible=e)}}else{const t=this.cameraHelpers.get(this.selectedItem.name);t!==void 0&&(t.visible=e)}}onUpdateTransform=()=>{this.selectedItem!==void 0&&(this.props.three.updateObject(this.selectedItem.uuid,"position",this.selectedItem.position),this.props.three.updateObject(this.selectedItem.uuid,"rotation",{x:this.selectedItem.rotation.x,y:this.selectedItem.rotation.y,z:this.selectedItem.rotation.z}),this.props.three.updateObject(this.selectedItem.uuid,"scale",this.selectedItem.scale),tt.instance.update())};clearLightHelpers=()=>{this.lightHelpers.forEach(e=>{this.helpersContainer.remove(e),e.dispose()}),this.lightHelpers.clear()};addLightHelpers=e=>{e.traverse(t=>{if(t.type.search("Light")>-1){let s;switch(t.type){case"DirectionalLight":s=new w.DirectionalLightHelper(t,100),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"HemisphereLight":s=new w.HemisphereLightHelper(t,250),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"RectAreaLight":s=new Ni.RectAreaLightHelper(t),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"PointLight":s=new w.PointLightHelper(t,100),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"SpotLight":s=new w.SpotLightHelper(t),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break}}})};createControls(e,t){const s=this.controls.get(e.name);if(s!==void 0&&s.dispose(),this.controls.delete(e.name),e.name==="UI")return;const n=new ki.OrbitControls(e,t);switch(n.enableDamping=!0,n.dampingFactor=.1,e.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":n.enableRotate=!1;break}this.controls.set(e.name,n)}clearCamera(e){const t=this.cameraHelpers.get(e.name);t!==void 0&&(this.helpersContainer.remove(t),t.dispose(),this.cameraHelpers.delete(e.name));const s=this.controls.get(e.name);s!==void 0&&(s.dispose(),this.controls.delete(e.name))}killControls(){this.controls.forEach((e,t)=>{e.dispose();const s=this.cameraHelpers.get(t);s!==void 0&&(this.helpersContainer.remove(s),s.dispose()),this.cameraHelpers.delete(t),this.controls.delete(t)}),this.controls.clear(),this.cameraHelpers.clear()}assignControls(){switch(this.state.mode){case"Single":this.createControls(this.tlCam,this.tlWindow.current);break;case"Side by Side":case"Stacked":this.createControls(this.tlCam,this.tlWindow.current),this.createControls(this.trCam,this.trWindow.current);break;case"Quad":this.createControls(this.tlCam,this.tlWindow.current),this.createControls(this.trCam,this.trWindow.current),this.createControls(this.blCam,this.blWindow.current),this.createControls(this.brCam,this.brWindow.current);break}}updateCamera=(e,t,s,n)=>{switch(this.state.mode){case"Quad":t<n?e<s?this.currentCamera=this.tlCam:this.currentCamera=this.trCam:e<s?this.currentCamera=this.blCam:this.currentCamera=this.brCam;break;case"Side by Side":e<s?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break;case"Single":this.currentCamera=this.tlCam;break;case"Stacked":t<n?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break}this.splineEditor.camera=this.currentCamera,this.raycaster.setFromCamera(this.pointer,this.currentCamera),this.currentCamera===this.tlCam?this.currentWindow=this.tlWindow:this.currentCamera===this.trCam?this.currentWindow=this.trWindow:this.currentCamera===this.blCam?this.currentWindow=this.blWindow:this.currentCamera===this.brCam&&(this.currentWindow=this.brWindow),W.instance.updateCamera(this.currentCamera,this.currentWindow.current)};updateCameraControls=(e,t=!1)=>{if(this.selectedItem===void 0)return;cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.cameraControls&&(this.cameraControls.smoothTime=.1);const s=.15,n=new w.Clock;n.start(),this.selectedItem.getWorldPosition(e.target0);const a=()=>{const r=n.getDelta();this.cameraControls&&this.cameraControls.update(r),t&&(e.target.lerp(e.target0,s),e.object.position.lerp(e.position0,s),e.object.zoom=Ae(e.object.zoom,e.zoom0,s),e.object.updateProjectionMatrix(),e.dispatchEvent({type:"change"})),n.getElapsedTime()>=.5?(cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.clearControls()):this.cameraControlsRafID=requestAnimationFrame(a)};a()};clearControls=()=>{this.cameraControls!==void 0&&(this.cameraControls.disconnect(),this.cameraControls.dispose(),this.cameraControls=void 0)};saveExpandedCameraVisibility(){localStorage.setItem(this.expandedCameraVisibility,this.cameraVisibility?"open":"closed")}saveExpandedLightVisibility(){localStorage.setItem(this.expandedLightVisibility,this.lightVisibility?"open":"closed")}saveExpandedGridVisibility(){localStorage.setItem(this.expandedGridVisibility,this.gridVisibility?"open":"closed")}getSceneOverride(e){switch(e){case"Depth":return this.depthMaterial;case"Normals":return this.normalsMaterial;case"Renderer":return null;case"UVs":return this.uvMaterial;case"Wireframe":return this.wireframeMaterial}return null}drawTo(e,t,s,n,a,r){switch(a.name){case"Left":case"Right":this.grid&&(this.grid.rotation.z=Math.PI/2);break;case"Front":case"Back":this.grid&&(this.grid.rotation.x=Math.PI/2);break}this.scene.overrideMaterial=r,this.renderer&&(this.renderer?.setScissor(e,t,s,n),this.renderer?.setViewport(e,t,s,n),this.renderer?.render(this.scene,a)),this.grid&&this.grid.rotation.set(0,0,0)}drawSingle(){const e=this.getSceneOverride(this.tlRender);this.drawTo(0,0,this.width,this.height,this.tlCam,e)}drawDouble=()=>{const e=this.getSceneOverride(this.tlRender),t=this.getSceneOverride(this.trRender),s=Math.floor(this.width/2),n=Math.floor(this.height/2),a=this.renderer instanceof w.WebGPURenderer;if(this.state.mode==="Side by Side")this.drawTo(0,0,s,this.height,this.tlCam,e),this.drawTo(s,0,s,this.height,this.trCam,t);else{const r=this.height-n;a?(this.drawTo(0,0,this.width,n,this.tlCam,e),this.drawTo(0,r,this.width,n,this.trCam,t)):(this.drawTo(0,r,this.width,n,this.tlCam,e),this.drawTo(0,0,this.width,n,this.trCam,t))}};drawQuad=()=>{const e=this.renderer instanceof w.WebGPURenderer,t=this.getSceneOverride(this.tlRender),s=this.getSceneOverride(this.trRender),n=this.getSceneOverride(this.blRender),a=this.getSceneOverride(this.brRender),r=Math.floor(this.width/2),o=Math.floor(this.height/2),c=this.height-o;let l=0,h=e?0:this.height-o;l=0,this.drawTo(l,h,r,o,this.tlCam,t),l=r,this.drawTo(l,h,r,o,this.trCam,s),h=e?c:0,l=0,this.scene.overrideMaterial=n,this.drawTo(l,h,r,o,this.blCam,n),l=r,this.drawTo(l,h,r,o,this.brCam,a)};get appID(){return this.props.three.name}get mode(){return this.state.mode}get three(){return this.props.three}get expandedCameraVisibility(){return`${this.appID}_multiviewCameraVisibility`}get expandedLightVisibility(){return`${this.appID}_multiviewLightVisibility`}get expandedGridVisibility(){return`${this.appID}_multiviewGridVisibility`}}class tt extends b.Component{static instance;matrix=new m.Matrix4;position=new m.Vector3;rotation=new m.Euler;scale=new m.Vector3;open=!1;constructor(e){super(e);const t=localStorage.getItem(this.expandedName),s=t!==null?t==="open":!1;this.open=s,this.saveExpanded(),this.state={lastUpdated:0,expanded:s},this.matrix.elements=e.object.matrix,e.object.uuid.length>0&&(this.position.setFromMatrixPosition(this.matrix),this.rotation.setFromRotationMatrix(this.matrix),this.scale.setFromMatrixScale(this.matrix)),tt.instance=this}update(){if(G.instance){const e=G.instance.selectedItem;if(e===void 0)return;this.position.x=X(e.position.x,3),this.position.y=X(e.position.y,3),this.position.z=X(e.position.z,3),this.rotation.copy(e.rotation),this.scale.x=X(e.scale.x,3),this.scale.y=X(e.scale.y,3),this.scale.z=X(e.scale.z,3),this.setState({lastUpdated:Date.now()})}}render(){return d.jsx(Q,{three:this.props.three,title:"Transform",expanded:this.open,items:[{title:"Position",prop:"position",type:"grid3",step:.1,value:this.position,onChange:this.updateTransform},{title:"Rotation",prop:"rotation",type:"euler",value:this.rotation,onChange:this.updateTransform},{title:"Scale",prop:"scale",type:"grid3",value:this.scale,onChange:this.updateTransform},{title:"Visible",prop:"visible",type:"boolean",value:this.props.object.visible,onChange:this.updateTransform}],onToggle:e=>{this.open=e,this.saveExpanded()}},this.state.lastUpdated)}updateTransform=(e,t)=>{const s=e==="rotation"?{x:t._x,y:t._y,z:t._z}:t;this.props.three.updateObject(this.props.object.uuid,e,s);const n=this.props.three.getScene(this.props.object.uuid);if(n){const a=n.getObjectByProperty("uuid",this.props.object.uuid);V(a,e,s)}};saveExpanded(){localStorage.setItem(this.expandedName,this.open?"open":"closed")}get expandedName(){return`${this.props.three.name}_transform`}}function Yt(i){switch(i){case"color":return"Color";case"intensity":return"Intensity";case"decay":return"Decay";case"distance":return"Distance";case"angle":return"Angle";case"penumbra":return"Penumbra";case"groundColor":return"Ground Color";case"width":return"Width";case"height":return"Height"}return i}function Sn(i,e){function t(){return`${e.name}_light`}const s=localStorage.getItem(t()),n=s!==null?s==="open":!1;function a(o){localStorage.setItem(t(),o?"open":"closed")}const r=[];if(i.lightInfo!==void 0)for(const o in i.lightInfo){const c=i.lightInfo[o];c!==void 0&&(c.isColor!==void 0?r.push({title:Yt(o),prop:o,type:"color",value:c,onChange:(l,h)=>{const u=new m.Color(h);e.updateObject(i.uuid,l,u);const p=e.getScene(i.uuid);if(p!==null){const g=p.getObjectByProperty("uuid",i.uuid);V(g,l,u)}}}):r.push({title:Yt(o),prop:o,type:typeof c,value:c,step:typeof c=="number"?.01:void 0,onChange:(l,h)=>{e.updateObject(i.uuid,l,h);const u=e.getScene(i.uuid);if(u!==null){const p=u.getObjectByProperty("uuid",i.uuid);V(p,l,h)}}}))}return d.jsx(Q,{three:e,title:"Light",items:r,expanded:n,onToggle:o=>{a(o)}})}function xn(i){const e=i.object,t=i.three;function s(){return`${t.name}_animation`}const n=localStorage.getItem(s()),a=n!==null?n==="open":!1;function r(p){localStorage.setItem(s(),p?"open":"closed")}const o=[],c=[];let l=0;e.animations.forEach(p=>{l=Math.max(l,p.duration),p.duration>0&&c.push({title:p.name,items:[{title:"Duration",type:"number",value:p.duration,disabled:!0},{title:"Blend Mode",type:"option",disabled:!0,options:[{title:"Normal",value:2500},{title:"Additive",value:2501}]}]})}),o.push({title:"Animations",items:c});let h;const u=t.getScene(e.uuid);if(u!==null){const p=u.getObjectByProperty("uuid",e.uuid);if(p!==void 0){const g=p.mixer;if(g!==void 0){const _=[{title:"Time Scale",type:"range",value:g.timeScale,step:.01,min:-1,max:2,onChange:(E,v)=>{g.timeScale=v,t.updateObject(e.uuid,"mixer.timeScale",v)}}];_.push({title:"Stop All",type:"button",onChange:()=>{g.stopAllAction(),t.requestMethod(e.uuid,"stopAllAction",void 0,"mixer")}}),o.push({title:"Mixer",items:_}),h=new m.SkeletonHelper(p),G.instance?.scene.add(h)}}}return b.useEffect(()=>()=>{h!==void 0&&re(h)},[]),d.jsx(Q,{three:i.three,title:"Animation",items:o,expanded:a,onToggle:p=>{r(p)}})}const gt={name:"",uuid:"",type:"",visible:!1,matrix:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0,children:[]};function yi(i){const[e,t]=b.useState(gt);b.useEffect(()=>{function r(c){t(c.value)}function o(){t(gt)}return i.three.addEventListener(U.CLEAR_OBJECT,o),i.three.addEventListener(U.SET_SCENE,o),i.three.addEventListener(U.SET_OBJECT,r),()=>{i.three.removeEventListener(U.CLEAR_OBJECT,o),i.three.removeEventListener(U.SET_SCENE,o),i.three.removeEventListener(U.SET_OBJECT,r)}},[]);const s=e.type.toLowerCase(),n=e.animations.length>0||e.mixer!==void 0,a=s.search("mesh")>-1||s.search("line")>-1||s.search("points")>-1;return d.jsx(Me,{three:i.three,label:"Inspector",button:e.uuid.length>0?d.jsx("button",{className:"remove",onClick:()=>{W.instance.remove(e.name),t(gt)}}):void 0,children:d.jsx("div",{id:"Inspector",className:i.class,children:e.uuid.length>0&&d.jsxs(d.Fragment,{children:[d.jsxs(d.Fragment,{children:[d.jsx(qe,{type:"string",title:"Name",prop:"name",value:e.name,disabled:!0}),d.jsx(qe,{type:"string",title:"Type",prop:"type",value:e.type,disabled:!0}),d.jsx(qe,{type:"string",title:"UUID",prop:"uuid",value:e.uuid,disabled:!0})]}),d.jsxs(d.Fragment,{children:[d.jsx(tt,{object:e,three:i.three}),n?d.jsx(xn,{object:e,three:i.three}):null,s.search("camera")>-1?dn(e,i.three):null,s.search("light")>-1?Sn(e,i.three):null,a?ln(e,i.three):null]})]})})},"Inspector")}class On extends b.Component{autoClear=!0;autoClearColor=!0;autoClearDepth=!0;autoClearStencil=!0;outputColorSpace=m.SRGBColorSpace;localClippingEnabled=!1;clearColor=new m.Color(0);clearAlpha=1;toneMapping=m.NoToneMapping;toneMappingExposure=1;type="";constructor(e){super(e);const t=localStorage.getItem(this.expandedName),s=t!==null?t==="open":!1;if(this.state={expanded:s,lastUpdated:Date.now()},this.saveExpanded(s),G.instance){const n=G.instance.renderer;n&&(this.autoClear=n.autoClear,this.autoClearColor=n.autoClearColor,this.autoClearDepth=n.autoClearDepth,this.autoClearStencil=n.autoClearStencil,this.clearAlpha=n.getClearAlpha(),this.toneMapping=n.toneMapping,this.toneMappingExposure=n.toneMappingExposure,n instanceof m.WebGLRenderer&&(this.localClippingEnabled=n.localClippingEnabled,n.getClearColor(this.clearColor)))}this.props.three.addEventListener(U.ADD_RENDERER,this.onAddRenderer)}componentwillunmount(){this.props.three.removeEventListener(U.ADD_RENDERER,this.onAddRenderer)}onAddRenderer=e=>{const t=e.value;if(this.autoClear=t.autoClear,this.autoClearColor=t.autoClearColor,this.autoClearDepth=t.autoClearDepth,this.autoClearStencil=t.autoClearStencil,this.outputColorSpace=t.outputColorSpace,this.localClippingEnabled=t.localClippingEnabled,this.clearAlpha=t.clearAlpha,this.type=t.type,this.toneMapping=t.toneMapping,this.toneMappingExposure=t.toneMappingExposure,this.clearColor.setStyle(t.clearColor,m.LinearSRGBColorSpace),m.ColorManagement.enabled=t.colorManagement,G.instance){const s=G.instance.renderer;s&&(s.autoClearColor=this.autoClearColor,s.outputColorSpace=this.outputColorSpace,s instanceof m.WebGLRenderer&&(s.localClippingEnabled=this.localClippingEnabled),s.toneMapping=this.toneMapping,s.toneMappingExposure=this.toneMappingExposure,s.setClearColor(t.clearColor,this.clearAlpha))}this.setState({lastUpdated:Date.now()})};render(){const e=()=>{if(G.instance){const t=G.instance.renderer;t&&(t.autoClearColor=this.autoClearColor,t.outputColorSpace=this.outputColorSpace,t instanceof m.WebGLRenderer&&(t.localClippingEnabled=this.localClippingEnabled),t.toneMapping=this.toneMapping,t.toneMappingExposure=this.toneMappingExposure,t.setClearColor(this.clearColor.getStyle(),this.clearAlpha),this.props.three.updateRenderer({autoClear:this.autoClear,autoClearColor:this.autoClearColor,autoClearDepth:this.autoClearDepth,autoClearStencil:this.autoClearStencil,outputColorSpace:this.outputColorSpace,localClippingEnabled:this.localClippingEnabled,clearAlpha:this.clearAlpha,clearColor:this.clearColor.getStyle(),colorManagement:m.ColorManagement.enabled,toneMapping:this.toneMapping,toneMappingExposure:this.toneMappingExposure}))}};return d.jsx(Q,{three:this.props.three,title:"Renderer",expanded:this.state.expanded,items:[{type:"boolean",title:"Auto Clear",value:this.autoClear,onChange:(t,s)=>{this.autoClear=s}},{type:"boolean",title:"Auto Clear Color",value:this.autoClearColor,onChange:(t,s)=>{this.autoClearColor=s,e()}},{type:"boolean",title:"Auto Clear Depth",value:this.autoClearDepth,onChange:(t,s)=>{this.autoClearDepth=s,e()}},{type:"boolean",title:"Auto Clear Stencil",value:this.autoClearStencil,onChange:(t,s)=>{this.autoClearStencil=s,e()}},{type:"boolean",title:"Local Clipping",value:this.localClippingEnabled,onChange:(t,s)=>{this.localClippingEnabled=s,e()}},{type:"color",title:"Clear Color",value:`#${this.clearColor.getHexString()}`,onChange:(t,s)=>{this.clearColor.setStyle(s),e()}},{type:"range",title:"Clear Alpha",min:0,max:1,step:.01,value:this.clearAlpha,onChange:(t,s)=>{this.clearAlpha=s,e()}},{type:"boolean",title:"Color Management",value:m.ColorManagement.enabled,onChange:(t,s)=>{m.ColorManagement.enabled=s,e()}},{type:"option",title:"Color Space",value:this.outputColorSpace,options:[{title:"No Color Space",value:m.NoColorSpace},{title:"SRB Color Space",value:m.SRGBColorSpace},{title:"Linear SRB Color Space",value:m.LinearSRGBColorSpace}],onChange:(t,s)=>{this.outputColorSpace=s,e()}},{type:"option",title:"Tone Mapping",value:this.toneMapping,options:[{title:"None ",value:m.NoToneMapping},{title:"Linear ",value:m.LinearToneMapping},{title:"Reinhard",value:m.ReinhardToneMapping},{title:"Cineon ",value:m.CineonToneMapping},{title:"ACES Filmic",value:m.ACESFilmicToneMapping},{title:"AgX",value:m.AgXToneMapping},{title:"Neutral",value:m.NeutralToneMapping},{title:"Custom",value:m.CustomToneMapping}],onChange:(t,s)=>{this.toneMapping=s,e()}},{type:"range",title:"Tone Mapping Exposure",value:this.toneMappingExposure,min:0,max:2,step:.01,onChange:(t,s)=>{this.toneMappingExposure=s,e()}},{type:"string",title:"Type",value:this.type,disabled:!0},{type:"button",title:"Resize Scenes from Source",onChange:()=>{this.props.three.requestSize()}}],onToggle:t=>{this.setState({expanded:t}),this.saveExpanded(t)}},Math.random())}saveExpanded(e){localStorage.setItem(this.expandedName,e?"open":"closed")}get expandedName(){return`${this.props.three.name}_renderer`}}function bi(i){const[e]=b.useState([]),[t]=b.useState([]),[s,n]=b.useState(0),a=l=>{const h=l.value;for(let u=0;u<e.length;u++)if(h.uuid===e[u].uuid)return;e.push(h),t.push(d.jsx(Me,{three:i.three,label:`Scene: ${h.name}`,scene:h,open:!1,visible:!1,onRefresh:()=>{i.three.refreshScene(h.name)},children:d.jsx($e,{child:h,scene:h,three:i.three})},h.name)),n(Date.now())},r=l=>{const h=l.value;for(let u=0;u<e.length;u++)if(h.uuid===e[u].uuid){e[u]=h,t[u]=d.jsx(Me,{three:i.three,label:`Scene: ${h.name}`,scene:h,open:t[u].props.open,visible:t[u].props.visible,onRefresh:()=>{i.three.refreshScene(h.name)},children:d.jsx($e,{child:h,scene:h,three:i.three})},h.name),n(Date.now());return}},o=l=>{const h=l.value;for(let u=0;u<e.length;u++)if(h.uuid===e[u].uuid){e.splice(u,1),t.splice(u,1),n(Date.now());return}},c=l=>{const h=l.value.name;for(let u=0;u<e.length;u++){const p=e[u],g=p.name===h;t[u]=d.jsx(Me,{three:i.three,label:`Scene: ${p.name}`,scene:p,open:g,visible:g,onRefresh:()=>{i.three.refreshScene(p.name)},children:d.jsx($e,{child:p,scene:p,three:i.three})},p.name)}n(Date.now())};return b.useEffect(()=>(i.three.addEventListener(U.ADD_SCENE,a),i.three.addEventListener(U.SET_SCENE,c),i.three.addEventListener(U.REFRESH_SCENE,r),i.three.addEventListener(U.REMOVE_SCENE,o),()=>{i.three.removeEventListener(U.ADD_SCENE,a),i.three.removeEventListener(U.SET_SCENE,c),i.three.removeEventListener(U.REFRESH_SCENE,r),i.three.removeEventListener(U.REMOVE_SCENE,o)}),[]),d.jsxs("div",{id:"SidePanel",children:[d.jsx("div",{className:"scenes",children:t},s),d.jsx(yi,{three:i.three}),d.jsx(On,{three:i.three}),d.jsx(N,{three:i.three})]})}function Ei(i){return d.jsxs("div",{className:"editor",ref:i.ref,style:i.style,children:[d.jsx("div",{className:"header",children:i.header}),i.children,d.jsx("div",{className:"footer",children:i.footer})]})}function wn(i){return d.jsx(Ei,{children:d.jsxs(d.Fragment,{children:[d.jsx(G,{three:i.three,scenes:i.scenes,onSceneAdd:i.onSceneAdd,onSceneResize:i.onSceneResize,onSceneUpdate:i.onSceneUpdate}),d.jsx(bi,{three:i.three})]})})}exports.Accordion=Me;exports.Application=Is;exports.BaseRemote=St;exports.ChildObject=Ot;exports.ContainerObject=$e;exports.DepthNodeMaterial=gi;exports.Draggable=oi;exports.DraggableItem=ai;exports.Dropdown=li;exports.DropdownItem=ci;exports.Editor=Ei;exports.ElementProxy=Ps;exports.ElementProxyReceiver=ni;exports.ExportTexture=le;exports.InfiniteGridHelper=pi;exports.InfiniteGridHelperGPU=fi;exports.InfiniteGridMaterial=ui;exports.InfiniteGridNodeMaterial=mi;exports.Inspector=yi;exports.MultiView=G;exports.NavButton=xt;exports.ProxyManager=Ds;exports.RemoteTheatre=Ns;exports.RemoteThree=Bs;exports.SidePanel=bi;exports.Spline=Ke;exports.SplineEditor=Ci;exports.ThreeEditor=wn;exports.Transform=W;exports.UVMaterial=vi;exports.UVNodeMaterial=_i;exports.WebworkerEventHandlers=As;exports.anchorGeometry=ii;exports.anchorGeometryTL=cs;exports.animateObjectMaterial=rs;exports.animateObjectTransform=ss;exports.applyObjectMaterial=ti;exports.capitalize=je;exports.clamp=de;exports.clearComposerGroups=ys;exports.colorToHex=vt;exports.copyToClipboard=$t;exports.createMask=ps;exports.cubicBezier=Ji;exports.customizeTheatreElements=is;exports.damp=Zi;exports.defaultTheatreCallback=zi;exports.detectMaxFrameRate=Xt;exports.detectSettings=Qt;exports.dispose=re;exports.disposeMaterial=bt;exports.disposeTexture=_t;exports.distance=Yi;exports.generateCubemap=bs;exports.getAngle=$i;exports.getObjectMaterialObject=ei;exports.getObjectMaterialProps=Jt;exports.hierarchyUUID=Te;exports.inspectComposer=Cs;exports.inspectComposerPass=si;exports.isColor=qt;exports.map=Wi;exports.mix=Ae;exports.noop=He;exports.normalize=Xe;exports.orthoCamera=as;exports.parseModelLite=os;exports.randomID=Y;exports.renderToTexture=ls;exports.resetThreeObjects=Ne;exports.rgbaToHex=es;exports.roundTo=X;exports.setMaterialBlendAdd=gs;exports.setMaterialBlendMultiply=vs;exports.setMaterialBlendNormal=fs;exports.setMaterialBlendScreen=_s;exports.supportsOffscreenCanvas=us;exports.triangle=Je;exports.updateCameraOrtho=hs;exports.updateCameraOrtho16x9=ds;exports.useMask=ms;exports.useStudio=ts;
|
package/dist/hermes.es.js
CHANGED
|
@@ -7070,8 +7070,13 @@ class G extends Qe {
|
|
|
7070
7070
|
addScene = (e) => {
|
|
7071
7071
|
const t = this.props.scenes.get(e.value.name);
|
|
7072
7072
|
if (t !== void 0) {
|
|
7073
|
-
const s =
|
|
7074
|
-
s
|
|
7073
|
+
const s = this.scenes.get(e.value.name);
|
|
7074
|
+
if (s !== void 0) {
|
|
7075
|
+
this.props.onSceneAdd !== void 0 && this.props.onSceneAdd(s), this.props.three.scene = s;
|
|
7076
|
+
return;
|
|
7077
|
+
}
|
|
7078
|
+
const n = new t();
|
|
7079
|
+
n.visible = !1, this.props.onSceneAdd !== void 0 && this.props.onSceneAdd(n), this.props.three.scene = n, this.scenes.set(e.value.name, n), this.scene.add(n);
|
|
7075
7080
|
} else
|
|
7076
7081
|
console.log("Hermes - Scene not found:", e.value.name, this.props.scenes);
|
|
7077
7082
|
};
|
|
@@ -7933,6 +7938,8 @@ class ba extends Qe {
|
|
|
7933
7938
|
function Ea(i) {
|
|
7934
7939
|
const [e] = L([]), [t] = L([]), [s, n] = L(0), a = (l) => {
|
|
7935
7940
|
const h = l.value;
|
|
7941
|
+
for (let d = 0; d < e.length; d++)
|
|
7942
|
+
if (h.uuid === e[d].uuid) return;
|
|
7936
7943
|
e.push(h), t.push(
|
|
7937
7944
|
/* @__PURE__ */ f(
|
|
7938
7945
|
Ke,
|
|
@@ -8754,7 +8754,7 @@ void main() {
|
|
|
8754
8754
|
#include <clipping_planes_fragment>
|
|
8755
8755
|
if (opacity < 0.015) discard;
|
|
8756
8756
|
gl_FragColor = vec4(vec3(vUv, 0.0), opacity);
|
|
8757
|
-
}`;class Kdt extends bh{constructor(){super({defines:{USE_UV:""},uniforms:{opacity:{value:1}},vertexShader:Xdt,fragmentShader:Ydt,transparent:!0})}}class Zdt extends sNe{constructor(){super(),this.colorNode=Tl(fN(),0,1)}}const P6=new AA,_c=new be,Uy=new be,Uo=new vs,h_e={X:new be(1,0,0),Y:new be(0,1,0),Z:new be(0,0,1)},uY={type:"change"},p_e={type:"mouseDown",mode:null},f_e={type:"mouseUp",mode:null},m_e={type:"objectChange"};class Qdt extends _Se{constructor(e,t=null){super(void 0,t);const n=new iht(this);this._root=n;const r=new sht;this._gizmo=r,n.add(r);const i=new oht;this._plane=i,n.add(i);const o=this;function l(j,C){let Z=C;Object.defineProperty(o,j,{get:function(){return Z!==void 0?Z:C},set:function(ie){Z!==ie&&(Z=ie,i[j]=ie,r[j]=ie,o.dispatchEvent({type:j+"-changed",value:ie}),o.dispatchEvent(uY))}}),o[j]=C,i[j]=C,r[j]=C}l("camera",e),l("object",void 0),l("enabled",!0),l("axis",null),l("mode","translate"),l("translationSnap",null),l("rotationSnap",null),l("scaleSnap",null),l("space","world"),l("size",1),l("dragging",!1),l("showX",!0),l("showY",!0),l("showZ",!0),l("minX",-1/0),l("maxX",1/0),l("minY",-1/0),l("maxY",1/0),l("minZ",-1/0),l("maxZ",1/0);const c=new be,h=new be,m=new vs,y=new vs,b=new be,w=new vs,A=new be,I=new be,D=new be,P=0,U=new be;l("worldPosition",c),l("worldPositionStart",h),l("worldQuaternion",m),l("worldQuaternionStart",y),l("cameraPosition",b),l("cameraQuaternion",w),l("pointStart",A),l("pointEnd",I),l("rotationAxis",D),l("rotationAngle",P),l("eye",U),this._offset=new be,this._startNorm=new be,this._endNorm=new be,this._cameraScale=new be,this._parentPosition=new be,this._parentQuaternion=new vs,this._parentQuaternionInv=new vs,this._parentScale=new be,this._worldScaleStart=new be,this._worldQuaternionInv=new vs,this._worldScale=new be,this._positionStart=new be,this._quaternionStart=new vs,this._scaleStart=new be,this._getPointer=Jdt.bind(this),this._onPointerDown=tht.bind(this),this._onPointerHover=eht.bind(this),this._onPointerMove=nht.bind(this),this._onPointerUp=rht.bind(this),t!==null&&this.connect(t)}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&P6.setFromCamera(e,this.camera);const t=dY(this._gizmo.picker[this.mode],P6);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&P6.setFromCamera(e,this.camera);const t=dY(this._plane,P6,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,p_e.mode=this.mode,this.dispatchEvent(p_e)}}pointerMove(e){const t=this.axis,n=this.mode,r=this.object;let i=this.space;if(n==="scale"?i="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(i="world"),r===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&P6.setFromCamera(e,this.camera);const o=dY(this._plane,P6,!0);if(o){if(this.pointEnd.copy(o.point).sub(this.worldPositionStart),n==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),i==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),i==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),r.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(i==="local"&&(r.position.applyQuaternion(Uo.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.position.applyQuaternion(this._quaternionStart)),i==="world"&&(r.parent&&r.position.add(_c.setFromMatrixPosition(r.parent.matrixWorld)),t.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.parent&&r.position.sub(_c.setFromMatrixPosition(r.parent.matrixWorld)))),r.position.x=Math.max(this.minX,Math.min(this.maxX,r.position.x)),r.position.y=Math.max(this.minY,Math.min(this.maxY,r.position.y)),r.position.z=Math.max(this.minZ,Math.min(this.maxZ,r.position.z));else if(n==="scale"){if(t.search("XYZ")!==-1){let l=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(l*=-1),Uy.set(l,l,l)}else _c.copy(this.pointStart),Uy.copy(this.pointEnd),_c.applyQuaternion(this._worldQuaternionInv),Uy.applyQuaternion(this._worldQuaternionInv),Uy.divide(_c),t.search("X")===-1&&(Uy.x=1),t.search("Y")===-1&&(Uy.y=1),t.search("Z")===-1&&(Uy.z=1);r.scale.copy(this._scaleStart).multiply(Uy),this.scaleSnap&&(t.search("X")!==-1&&(r.scale.x=Math.round(r.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(r.scale.y=Math.round(r.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(r.scale.z=Math.round(r.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(n==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const l=20/this.worldPosition.distanceTo(_c.setFromMatrixPosition(this.camera.matrixWorld));let c=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(_c.copy(this.rotationAxis).cross(this.eye))*l):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(h_e[t]),_c.copy(h_e[t]),i==="local"&&_c.applyQuaternion(this.worldQuaternion),_c.cross(this.eye),_c.length()===0?c=!0:this.rotationAngle=this._offset.dot(_c.normalize())*l),(t==="E"||c)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),i==="local"&&t!=="E"&&t!=="XYZE"?(r.quaternion.copy(this._quaternionStart),r.quaternion.multiply(Uo.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),r.quaternion.copy(Uo.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),r.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(uY),this.dispatchEvent(m_e)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(f_e.mode=this.mode,this.dispatchEvent(f_e)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(uY),this.dispatchEvent(m_e),this.pointStart.copy(this.pointEnd))}getRaycaster(){return P6}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}setColors(e,t,n,r){const i=this._gizmo.materialLib;i.xAxis.color.set(e),i.yAxis.color.set(t),i.zAxis.color.set(n),i.active.color.set(r),i.xAxisTransparent.color.set(e),i.yAxisTransparent.color.set(t),i.zAxisTransparent.color.set(n),i.activeTransparent.color.set(r),i.xAxis._color&&i.xAxis._color.set(e),i.yAxis._color&&i.yAxis._color.set(t),i.zAxis._color&&i.zAxis._color.set(n),i.active._color&&i.active._color.set(r),i.xAxisTransparent._color&&i.xAxisTransparent._color.set(e),i.yAxisTransparent._color&&i.yAxisTransparent._color.set(t),i.zAxisTransparent._color&&i.zAxisTransparent._color.set(n),i.activeTransparent._color&&i.activeTransparent._color.set(r)}}function Jdt(s){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:s.button};{const e=this.domElement.getBoundingClientRect();return{x:(s.clientX-e.left)/e.width*2-1,y:-(s.clientY-e.top)/e.height*2+1,button:s.button}}}function eht(s){if(this.enabled)switch(s.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(s));break}}function tht(s){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(s.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(s)),this.pointerDown(this._getPointer(s)))}function nht(s){this.enabled&&this.pointerMove(this._getPointer(s))}function rht(s){this.enabled&&(this.domElement.releasePointerCapture(s.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(s)))}function dY(s,e,t){const n=e.intersectObject(s,!0);for(let r=0;r<n.length;r++)if(n[r].object.visible||t)return n[r];return!1}const FL=new Sa,no=new be(0,1,0),g_e=new be(0,0,0),y_e=new Pn,BL=new vs,sF=new vs,ag=new be,v_e=new Pn,LC=new be(1,0,0),O6=new be(0,1,0),FC=new be(0,0,1),UL=new be,bC=new be,_C=new be;class iht extends Bi{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){const t=this.controls;t.object!==void 0&&(t.object.updateMatrixWorld(),t.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):t.object.parent.matrixWorld.decompose(t._parentPosition,t._parentQuaternion,t._parentScale),t.object.matrixWorld.decompose(t.worldPosition,t.worldQuaternion,t._worldScale),t._parentQuaternionInv.copy(t._parentQuaternion).invert(),t._worldQuaternionInv.copy(t.worldQuaternion).invert()),t.camera.updateMatrixWorld(),t.camera.matrixWorld.decompose(t.cameraPosition,t.cameraQuaternion,t._cameraScale),t.camera.isOrthographicCamera?t.camera.getWorldDirection(t.eye).negate():t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(),super.updateMatrixWorld(e)}dispose(){this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}}class sht extends Bi{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new rl({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new Sh({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),n=e.clone();n.opacity=.15;const r=t.clone();r.opacity=.5;const i=e.clone();i.color.setHex(16711680);const o=e.clone();o.color.setHex(65280);const l=e.clone();l.color.setHex(255);const c=e.clone();c.color.setHex(16711680),c.opacity=.5;const h=e.clone();h.color.setHex(65280),h.opacity=.5;const m=e.clone();m.color.setHex(255),m.opacity=.5;const y=e.clone();y.opacity=.25;const b=e.clone();b.color.setHex(16776960),b.opacity=.25;const w=e.clone();w.color.setHex(16776960);const A=e.clone();A.color.setHex(7895160),this.materialLib={xAxis:i,yAxis:o,zAxis:l,active:w,xAxisTransparent:c,yAxisTransparent:h,zAxisTransparent:m,activeTransparent:b};const I=new k0(0,.04,.1,12);I.translate(0,.05,0);const D=new _a(.08,.08,.08);D.translate(0,.04,0);const P=new Ki;P.setAttribute("position",new Fr([0,0,0,1,0,0],3));const U=new k0(.0075,.0075,.5,3);U.translate(0,.25,0);function j(Ie,ce){const Ve=new L6(Ie,.0075,3,64,ce*Math.PI*2);return Ve.rotateY(Math.PI/2),Ve.rotateX(Math.PI/2),Ve}function C(){const Ie=new Ki;return Ie.setAttribute("position",new Fr([0,0,0,1,1,1],3)),Ie}const Z={X:[[new gn(I,i),[.5,0,0],[0,0,-Math.PI/2]],[new gn(I,i),[-.5,0,0],[0,0,Math.PI/2]],[new gn(U,i),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new gn(I,o),[0,.5,0]],[new gn(I,o),[0,-.5,0],[Math.PI,0,0]],[new gn(U,o)]],Z:[[new gn(I,l),[0,0,.5],[Math.PI/2,0,0]],[new gn(I,l),[0,0,-.5],[-Math.PI/2,0,0]],[new gn(U,l),null,[Math.PI/2,0,0]]],XYZ:[[new gn(new H6(.1,0),y),[0,0,0]]],XY:[[new gn(new _a(.15,.15,.01),m),[.15,.15,0]]],YZ:[[new gn(new _a(.15,.15,.01),c),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new gn(new _a(.15,.15,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]]},ie={X:[[new gn(new k0(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new gn(new k0(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new gn(new k0(.2,0,.6,4),n),[0,.3,0]],[new gn(new k0(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new gn(new k0(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new gn(new k0(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new gn(new H6(.2,0),n)]],XY:[[new gn(new _a(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new gn(new _a(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new gn(new _a(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]]},se={START:[[new gn(new H6(.01,2),r),null,null,null,"helper"]],END:[[new gn(new H6(.01,2),r),null,null,null,"helper"]],DELTA:[[new dd(C(),r),null,null,null,"helper"]],X:[[new dd(P,r),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new dd(P,r),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new dd(P,r),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},z={XYZE:[[new gn(j(.5,1),A),null,[0,Math.PI/2,0]]],X:[[new gn(j(.5,.5),i)]],Y:[[new gn(j(.5,.5),o),null,[0,0,-Math.PI/2]]],Z:[[new gn(j(.5,.5),l),null,[0,Math.PI/2,0]]],E:[[new gn(j(.75,1),b),null,[0,Math.PI/2,0]]]},re={AXIS:[[new dd(P,r),[-1e3,0,0],null,[1e6,1,1],"helper"]]},ye={XYZE:[[new gn(new Mg(.25,10,8),n)]],X:[[new gn(new L6(.5,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new gn(new L6(.5,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new gn(new L6(.5,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new gn(new L6(.75,.1,2,24),n)]]},H={X:[[new gn(D,i),[.5,0,0],[0,0,-Math.PI/2]],[new gn(U,i),[0,0,0],[0,0,-Math.PI/2]],[new gn(D,i),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new gn(D,o),[0,.5,0]],[new gn(U,o)],[new gn(D,o),[0,-.5,0],[0,0,Math.PI]]],Z:[[new gn(D,l),[0,0,.5],[Math.PI/2,0,0]],[new gn(U,l),[0,0,0],[Math.PI/2,0,0]],[new gn(D,l),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new gn(new _a(.15,.15,.01),m),[.15,.15,0]]],YZ:[[new gn(new _a(.15,.15,.01),c),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new gn(new _a(.15,.15,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new gn(new _a(.1,.1,.1),y)]]},Me={X:[[new gn(new k0(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new gn(new k0(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new gn(new k0(.2,0,.6,4),n),[0,.3,0]],[new gn(new k0(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new gn(new k0(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new gn(new k0(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new gn(new _a(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new gn(new _a(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new gn(new _a(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new gn(new _a(.2,.2,.2),n),[0,0,0]]]},Oe={X:[[new dd(P,r),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new dd(P,r),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new dd(P,r),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function Ue(Ie){const ce=new Bi;for(const Ve in Ie)for(let Pe=Ie[Ve].length;Pe--;){const We=Ie[Ve][Pe][0].clone(),pt=Ie[Ve][Pe][1],Ne=Ie[Ve][Pe][2],st=Ie[Ve][Pe][3],Pt=Ie[Ve][Pe][4];We.name=Ve,We.tag=Pt,pt&&We.position.set(pt[0],pt[1],pt[2]),Ne&&We.rotation.set(Ne[0],Ne[1],Ne[2]),st&&We.scale.set(st[0],st[1],st[2]),We.updateMatrix();const yn=We.geometry.clone();yn.applyMatrix4(We.matrix),We.geometry=yn,We.renderOrder=1/0,We.position.set(0,0,0),We.rotation.set(0,0,0),We.scale.set(1,1,1),ce.add(We)}return ce}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=Ue(Z)),this.add(this.gizmo.rotate=Ue(z)),this.add(this.gizmo.scale=Ue(H)),this.add(this.picker.translate=Ue(ie)),this.add(this.picker.rotate=Ue(ye)),this.add(this.picker.scale=Ue(Me)),this.add(this.helper.translate=Ue(se)),this.add(this.helper.rotate=Ue(re)),this.add(this.helper.scale=Ue(Oe)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const n=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:sF;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let r=[];r=r.concat(this.picker[this.mode].children),r=r.concat(this.gizmo[this.mode].children),r=r.concat(this.helper[this.mode].children);for(let i=0;i<r.length;i++){const o=r[i];o.visible=!0,o.rotation.set(0,0,0),o.position.copy(this.worldPosition);let l;if(this.camera.isOrthographicCamera?l=(this.camera.top-this.camera.bottom)/this.camera.zoom:l=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),o.scale.set(1,1,1).multiplyScalar(l*this.size/4),o.tag==="helper"){o.visible=!1,o.name==="AXIS"?(o.visible=!!this.axis,this.axis==="X"&&(Uo.setFromEuler(FL.set(0,0,0)),o.quaternion.copy(n).multiply(Uo),Math.abs(no.copy(LC).applyQuaternion(n).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Y"&&(Uo.setFromEuler(FL.set(0,0,Math.PI/2)),o.quaternion.copy(n).multiply(Uo),Math.abs(no.copy(O6).applyQuaternion(n).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Z"&&(Uo.setFromEuler(FL.set(0,Math.PI/2,0)),o.quaternion.copy(n).multiply(Uo),Math.abs(no.copy(FC).applyQuaternion(n).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="XYZE"&&(Uo.setFromEuler(FL.set(0,Math.PI/2,0)),no.copy(this.rotationAxis),o.quaternion.setFromRotationMatrix(y_e.lookAt(g_e,no,O6)),o.quaternion.multiply(Uo),o.visible=this.dragging),this.axis==="E"&&(o.visible=!1)):o.name==="START"?(o.position.copy(this.worldPositionStart),o.visible=this.dragging):o.name==="END"?(o.position.copy(this.worldPosition),o.visible=this.dragging):o.name==="DELTA"?(o.position.copy(this.worldPositionStart),o.quaternion.copy(this.worldQuaternionStart),_c.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),_c.applyQuaternion(this.worldQuaternionStart.clone().invert()),o.scale.copy(_c),o.visible=this.dragging):(o.quaternion.copy(n),this.dragging?o.position.copy(this.worldPositionStart):o.position.copy(this.worldPosition),this.axis&&(o.visible=this.axis.search(o.name)!==-1));continue}o.quaternion.copy(n),this.mode==="translate"||this.mode==="scale"?(o.name==="X"&&Math.abs(no.copy(LC).applyQuaternion(n).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Y"&&Math.abs(no.copy(O6).applyQuaternion(n).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Z"&&Math.abs(no.copy(FC).applyQuaternion(n).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XY"&&Math.abs(no.copy(FC).applyQuaternion(n).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="YZ"&&Math.abs(no.copy(LC).applyQuaternion(n).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XZ"&&Math.abs(no.copy(O6).applyQuaternion(n).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1)):this.mode==="rotate"&&(BL.copy(n),no.copy(this.eye).applyQuaternion(Uo.copy(n).invert()),o.name.search("E")!==-1&&o.quaternion.setFromRotationMatrix(y_e.lookAt(this.eye,g_e,O6)),o.name==="X"&&(Uo.setFromAxisAngle(LC,Math.atan2(-no.y,no.z)),Uo.multiplyQuaternions(BL,Uo),o.quaternion.copy(Uo)),o.name==="Y"&&(Uo.setFromAxisAngle(O6,Math.atan2(no.x,no.z)),Uo.multiplyQuaternions(BL,Uo),o.quaternion.copy(Uo)),o.name==="Z"&&(Uo.setFromAxisAngle(FC,Math.atan2(no.y,no.x)),Uo.multiplyQuaternions(BL,Uo),o.quaternion.copy(Uo))),o.visible=o.visible&&(o.name.indexOf("X")===-1||this.showX),o.visible=o.visible&&(o.name.indexOf("Y")===-1||this.showY),o.visible=o.visible&&(o.name.indexOf("Z")===-1||this.showZ),o.visible=o.visible&&(o.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),o.material._color=o.material._color||o.material.color.clone(),o.material._opacity=o.material._opacity||o.material.opacity,o.material.color.copy(o.material._color),o.material.opacity=o.material._opacity,this.enabled&&this.axis&&(o.name===this.axis?(o.material.color.copy(this.materialLib.active.color),o.material.opacity=1):this.axis.split("").some(function(c){return o.name===c})&&(o.material.color.copy(this.materialLib.active.color),o.material.opacity=1))}super.updateMatrixWorld(e)}}class oht extends gn{constructor(){super(new Ng(1e5,1e5,2,2),new rl({visible:!1,wireframe:!0,side:oa,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),UL.copy(LC).applyQuaternion(t==="local"?this.worldQuaternion:sF),bC.copy(O6).applyQuaternion(t==="local"?this.worldQuaternion:sF),_C.copy(FC).applyQuaternion(t==="local"?this.worldQuaternion:sF),no.copy(bC),this.mode){case"translate":case"scale":switch(this.axis){case"X":no.copy(this.eye).cross(UL),ag.copy(UL).cross(no);break;case"Y":no.copy(this.eye).cross(bC),ag.copy(bC).cross(no);break;case"Z":no.copy(this.eye).cross(_C),ag.copy(_C).cross(no);break;case"XY":ag.copy(_C);break;case"YZ":ag.copy(UL);break;case"XZ":no.copy(_C),ag.copy(bC);break;case"XYZ":case"E":ag.set(0,0,0);break}break;case"rotate":default:ag.set(0,0,0)}ag.length()===0?this.quaternion.copy(this.cameraQuaternion):(v_e.lookAt(_c.set(0,0,0),ag,no),this.quaternion.setFromRotationMatrix(v_e)),super.updateMatrixWorld(e)}}const tm=class tm extends _d{constructor(){super(...arguments);qe(this,"three");qe(this,"activeCamera");qe(this,"controls",new Map);qe(this,"visibility",new Map);qe(this,"setScene",()=>{this.clear()})}setApp(t){this.three=t,this.three.addEventListener(Ci.SET_SCENE,this.setScene)}clear(){for(const t of this.controls.values()){t.detach(),t.disconnect();const n=t.getHelper();Rp(n)}this.controls=new Map,this.visibility=new Map}add(t){let n=this.controls.get(t);if(n===void 0){const r=document.querySelector(".clickable");n=new Qdt(this.activeCamera,r),n.getHelper().name=t,n.setSize(.5),n.setSpace("local"),this.controls.set(t,n),this.visibility.set(t,!0),n.addEventListener("mouseDown",()=>{this.dispatchEvent({type:tm.DRAG_START})}),n.addEventListener("mouseUp",()=>{this.dispatchEvent({type:tm.DRAG_END})}),n.addEventListener("dragging-changed",i=>{var o;(o=nl.instance)==null||o.toggleOrbitControls(i.value)})}return n}get(t){return this.controls.get(t)}remove(t){const n=this.get(t);return n===void 0?!1:(n.detach(),n.disconnect(),Rp(n.getHelper()),this.controls.delete(t),!0)}enabled(t){this.controls.forEach(n=>{n.enabled=t})}updateCamera(t,n){this.activeCamera=t,this.controls.forEach(r=>{r.camera!==t&&(r.camera=t,t.getWorldPosition(r.cameraPosition),t.getWorldQuaternion(r.cameraQuaternion)),r.domElement!==n&&(r.disconnect(),r.domElement=n,r.connect(n))})}show(){this.controls.forEach(t=>{const n=t.getHelper(),r=this.visibility.get(n.name);r!==void 0&&(n.visible=r)})}hide(){this.controls.forEach(t=>{const n=t.getHelper();this.visibility.set(n.name,n.visible),n.visible=!1})}static get instance(){return tm._instance||(tm._instance=new tm),tm._instance}};qe(tm,"DRAG_START","Transform::dragStart"),qe(tm,"DRAG_END","Transform::dragEnd"),qe(tm,"_instance");let fh=tm;const aht=new _a,hY=new Ln;class pY extends Bi{constructor(t,n){const r=new Tn(c5(.5,1,Math.random()),c5(.5,1,Math.random()),c5(.5,1,Math.random()));super();qe(this,"curve",new w6e);qe(this,"line");qe(this,"draggable");qe(this,"curvePos");qe(this,"tension",.5);qe(this,"closed",!1);qe(this,"subdivide",50);qe(this,"curveType");qe(this,"offset",1);qe(this,"lineMaterial");qe(this,"_camera");qe(this,"_curvePercentage",0);qe(this,"_draggableScale",10);qe(this,"_transform");qe(this,"raycaster");qe(this,"draggedMat",new rl);qe(this,"parentGroup");qe(this,"group");qe(this,"dispose",()=>{this._transform&&(this._transform.removeEventListener("objectChange",this.updateSpline),fh.instance.remove(this.name)),this.disable(),this.parentGroup.removeGroup(this.name)});qe(this,"hideTransform",()=>{var t;(t=this._transform)==null||t.detach()});qe(this,"exportSpline",()=>{const t=[];this.draggable.children.forEach(n=>{t.push([om(n.position.x,3),om(n.position.y,3),om(n.position.z,3)])}),kXe({name:this.name,points:t,tension:this.tension,closed:this.closed,subdivide:this.subdivide,type:this.curveType}),console.log("Spline copied!")});qe(this,"showPoints",(t=!0)=>{this.draggable.visible=t});qe(this,"addPoints",(t=[])=>{if(t.length>0){const n=t.length-1;for(let r=0;r<n;r++)this.addPoint(t[r],!1);this.addPoint(t[n])}});qe(this,"addPoint",(t,n=!0)=>{var l;const r=this.draggable.children.length,i=new gn(aht,this.draggedMat);i.name=`point_${r}`,i.position.copy(t),i.scale.setScalar(this._draggableScale),this.draggable.add(i),(l=this._transform)==null||l.attach(i);const o=this.points.length>1;return o&&n&&this.updateSpline(),this.line.visible=o,this.updateCurrentPoint(),i});qe(this,"addNextPt",()=>{const t=this.draggable.children.length,n=t>1?this.draggable.children[t-1].position.clone():new be,r=this.addPoint(n);this.updateField(r.position)});qe(this,"removePoint",t=>{var n,r,i;if(((n=this._transform)==null?void 0:n.object)===t){(r=this._transform)==null||r.detach();const o=this.draggable.children[this.draggable.children.length-1];(i=this._transform)==null||i.attach(o),this.updateField(o.position)}Rp(t),this.updateSpline()});qe(this,"removePointAt",t=>{const n=this.draggable.children[t];this.removePoint(n)});qe(this,"removeSelectedPt",()=>{var t,n;((t=this._transform)==null?void 0:t.object)!==void 0&&this.removePoint((n=this._transform)==null?void 0:n.object)});qe(this,"updateSpline",()=>{this.points.length<2||(this.curve=new w6e(this.points,this.closed,this.curveType,this.tension),this.line.geometry.dispose(),this.line.geometry=new Ki().setFromPoints(this.curve.getPoints(this.subdivide)),this.curvePos.position.copy(this.getPointAt(this._curvePercentage)))});qe(this,"onMouseClick",t=>{var o,l;if(!nl.instance||!nl.instance.currentWindow||this._transform&&!this._transform.getHelper().visible)return;const r=nl.instance.currentWindow.current.getBoundingClientRect();hY.x=(t.clientX-r.x)/r.width*2-1,hY.y=-((t.clientY-r.y)/r.height)*2+1,this.raycaster.setFromCamera(hY,this.camera);const i=this.raycaster.intersectObjects(this.draggable.children,!1);if(i.length>0){const c=i[0].object;c!==((o=this._transform)==null?void 0:o.object)&&((l=this._transform)==null||l.attach(c),this.updateField(c.position))}});qe(this,"onUpdateTransform",()=>{this.updateCurrentPoint(),this.updateSpline()});qe(this,"debugPoint",t=>{t.name,t.visible=this.draggable.visible});this.name=t,this.lineMaterial=new Sh({color:r}),this.line=new dd(new Ki,this.lineMaterial),this.line.name="line",this.line.visible=!1,this.add(this.line),this._camera=n,this.curveType="catmullrom",this.draggedMat.color=r,this.draggable=new Bi,this.draggable.name="draggablePoints",this.add(this.draggable),this.curvePos=new gn(new Mg(1.5),new rl({color:r})),this.curvePos.name="curvePos",this.curvePos.scale.setScalar(this._draggableScale),this.curvePos.visible=!1,this.add(this.curvePos),this.raycaster=new AA,this.raycaster.params.Line.threshold=3,this.enable()}enable(){document.addEventListener("pointerdown",this.onMouseClick)}disable(){document.removeEventListener("pointerdown",this.onMouseClick)}updateLastPoint(t){const n=this.draggable.children.length;n>0&&(this.draggable.children[n-1].position.copy(t),this.updateSpline())}updateField(t){var n;(n=this.group.current)==null||n.setField("Current Point",t)}getPointAt(t){return this.curve.points.length>1?this.curve.getPointAt(t):this.curve.points.length===1?this.curve.points[0]:new be}getTangentAt(t){return this.curve.getTangentAt(t)}get points(){const t=[];return this.draggable.children.forEach(n=>{t.push(n.position)}),t}get total(){return this.draggable.children.length}get draggableScale(){return this._draggableScale}set draggableScale(t){this._draggableScale=t,this.draggable.children.forEach(n=>n.scale.setScalar(t)),this.curvePos.scale.setScalar(t)}get camera(){return this._camera}set camera(t){this._camera=t,this._transform!==void 0&&(this._transform.camera=t)}get curvePercentage(){return this._curvePercentage}set curvePercentage(t){this._curvePercentage=t,this.curvePos.position.copy(this.getPointAt(t))}updateCurrentPoint(){var t,n;if((t=this._transform)!=null&&t.object&&this.group){const r=(n=this._transform)==null?void 0:n.object;r.name.search("point")>-1&&this.updateField(r.position)}}initDebug(t,n){var o;const r=this.draggable.children;this.visible=n,this.parentGroup=t,this._transform=fh.instance.add(this.name),this._transform.camera=this._camera,this._transform.addEventListener("objectChange",this.onUpdateTransform),r.length>0&&this._transform.attach(r[r.length-1]),(o=nl.instance)==null||o.helpersContainer.add(this._transform.getHelper());const i=r.length>0?r[r.length-1].position:{x:0,y:0,z:0};this.group=t.addGroup({title:this.name,expanded:n,items:[{prop:"Closed",type:"boolean",value:this.closed},{prop:"Visible",type:"boolean",value:this.visible},{prop:"Show Position",type:"boolean",value:this.curvePos.visible},{prop:"Show Points",type:"boolean",value:this.draggable.visible},{prop:"Color",type:"color",value:`#${this.draggedMat.color.getHexString()}`},{prop:"Curve",type:"option",options:[{title:"Catmullrom",value:"catmullrom"},{title:"Centripetal",value:"centripetal"},{title:"Chordal",value:"chordal"}]},{prop:"Draggable Scale",type:"range",min:.01,max:100,step:.01,value:this._draggableScale},{prop:"Subdivide",type:"range",min:1,max:1e3,step:1,value:this.subdivide},{prop:"Tension",type:"range",min:0,max:1,step:.01,value:this.tension},{prop:"New Pt Offset",type:"range",min:0,max:10,value:this.offset},{prop:"Curve At",type:"range",min:0,max:1,step:.01,value:0},{prop:"Toggle Transform",type:"button"},{prop:"Add Point",type:"button"},{prop:"Remove Point",type:"button"},{prop:"Export",type:"button"},{prop:"Delete",type:"button"},{prop:"Current Point",type:"grid3",value:i}],onUpdate:(l,c)=>{var h,m;switch(l){case"Closed":this.closed=c,this.updateSpline();break;case"Visible":this.visible=c;break;case"Color":this.lineMaterial.color.setStyle(c),this.draggedMat.color.setStyle(c);break;case"Curve":this.curveType=c,this.updateSpline();break;case"Draggable Scale":this.draggableScale=c;break;case"Subdivide":this.subdivide=c,this.updateSpline();break;case"Tension":this.tension=c,this.updateSpline();break;case"New Pt Offset":this.offset=c;break;case"Curve At":this.curvePos.position.copy(this.getPointAt(c));break;case"Show Position":this.curvePos.visible=c;break;case"Show Points":this.draggable.visible=c;break;case"Toggle Transform":this._transform&&(this._transform.getHelper().visible=!this._transform.getHelper().visible);break;case"Add Point":this.addNextPt();break;case"Remove Point":this.removeSelectedPt();break;case"Export":this.exportSpline();break;case"Delete":this.parent.currentSpline=null,Rp(this);break;case"Current Point":if(this.group.current&&((h=this._transform)!=null&&h.object)){const y=(m=this._transform)==null?void 0:m.object;y.name.search("point")>-1&&(y.position.copy(c),this.updateSpline())}break}}}),this.draggable.children.forEach(l=>{this.debugPoint(l)})}}let zL=0;class lht extends Bi{constructor(t,n){super();qe(this,"defaultScale",10);qe(this,"currentSpline",null);qe(this,"_camera");qe(this,"group",null);qe(this,"three");qe(this,"splineDataText","");qe(this,"createSpline",(t=[])=>{const n=`Spline ${zL+1}`,r=new pY(n,this._camera);return r.addPoints(t),this.addSpline(r,!0),zL++,r});qe(this,"createSplineFromArray",t=>{const n=[];return t.forEach(r=>{n.push(new be(r[0],r[1],r[2]))}),this.createSpline(n)});qe(this,"createSplineFromCatmullRom",t=>this.createSpline(t.points));qe(this,"createSplineFromJSON",t=>{const n=[];t.points.forEach(i=>{n.push(new be(i[0],i[1],i[2]))});const r=new pY(t.name,this._camera);return r.closed=t.closed,r.subdivide=t.subdivide,r.tension=t.tension,r.type=t.type,r.addPoints(n),r.updateSpline(),this.addSpline(r,!1),r});qe(this,"showPoints",(t=!0)=>{this.children.forEach(n=>{n.showPoints(t)})});qe(this,"onAddSpline",t=>{const n=JSON.parse(t.value),r=n.name!==void 0?n.name:`Spline ${zL+1}`,i=new pY(r,this.camera);n.tension!==void 0&&(i.tension=n.tension),n.closed!==void 0&&(i.closed=n.closed),n.subdivide!==void 0&&(i.subdivide=n.subdivide),n.type!==void 0&&(i.curveType=n.type);const o=[];n.points.forEach(l=>{o.push(new be(l[0],l[1],l[2]))}),i.addPoints(o),this.addSpline(i,!1),zL++});qe(this,"isMouseDown",!1);qe(this,"onClickCanvas",t=>{var c;if(t.button!==0)return;if(this._camera.type!=="OrthographicCamera"){console.warn("Spline Editor - 3D Camera not supported in Draw Mode");return}const r=t.target.getBoundingClientRect(),i=(t.clientX-r.left)/r.width*2-1,o=-((t.clientY-r.top)/r.height)*2+1;if(nl.instance){const h=new AA;h.setFromCamera(new Ln(i,o),this._camera);const m=h.intersectObjects(nl.instance.helpersContainer.children,!0);for(let y=0;y<m.length;y++){const b=m[y];if(!(b.object.isLine||b.object.isTransformControlsPlane)&&b.object.isObject3D)return}}this.currentSpline===null&&(this.currentSpline=this.createSpline());const l=this.mouseToSplinePos(i,o,r.width,r.height);(c=this.currentSpline)==null||c.addPoint(l),this.isMouseDown=!0});qe(this,"onMouseMove",t=>{var c,h;if(!this.isMouseDown)return;const r=t.target.getBoundingClientRect(),i=(t.clientX-r.left)/r.width*2-1,o=-((t.clientY-r.top)/r.height)*2+1,l=this.mouseToSplinePos(i,o,r.width,r.height);(c=this.currentSpline)==null||c.updateLastPoint(l),(h=this.currentSpline)==null||h.updateField(l)});qe(this,"onMouseUp",()=>{this.isMouseDown=!1});this.name="Spline Editor",this._camera=t,this.three=n,this.three.addEventListener(Ci.ADD_SPLINE,this.onAddSpline)}initDebug(){this.group=u5.addEditorGroup({title:this.name,items:[{type:"field",prop:"Spline Data",value:"",disabled:!1},{type:"button",prop:"Import Spline"},{type:"button",prop:"New Spline"},{type:"boolean",prop:"Show Points",value:!0},{type:"boolean",prop:"Draw Mode",value:!1},{type:"boolean",prop:"Visible",value:this.visible},{type:"range",prop:"Default Scale",min:0,max:50,step:.01,value:this.defaultScale}],onUpdate:(t,n)=>{switch(t){case"New Spline":this.createSpline();break;case"Spline Data":this.splineDataText=n;break;case"Import Spline":this.createSplineFromJSON(JSON.parse(this.splineDataText));break;case"Show Points":this.showPoints(n);break;case"Visible":this.visible=n;break;case"Default Scale":this.defaultScale=n;break;case"Draw Mode":n?this.enableClickToDraw():this.disableClickToDraw();break}}})}dispose(){this.three.removeEventListener(Ci.ADD_SPLINE,this.onAddSpline),u5.removeEditorGroup(this.name)}addSpline(t,n){var r;t.draggableScale=this.defaultScale,t.hideTransform(),((r=this.group)==null?void 0:r.current)!==null&&t.initDebug(this.group.current,n),this.add(t),this.currentSpline=t}enableClickToDraw(){document.querySelectorAll(".clickable").forEach(t=>{t.addEventListener("mousedown",this.onClickCanvas),t.addEventListener("mousemove",this.onMouseMove),t.addEventListener("mouseup",this.onMouseUp)})}disableClickToDraw(){document.querySelectorAll(".clickable").forEach(t=>{t.removeEventListener("mousedown",this.onClickCanvas),t.removeEventListener("mousemove",this.onMouseMove),t.removeEventListener("mouseup",this.onMouseUp)})}mouseToSplinePos(t,n,r,i){const o=new be,l=Math.PI/2,c=this._camera,h=c.zoom,m=c.rotation.x===-6123233995736766e-32&&c.rotation.y===0&&c.rotation.z===0,y=c.rotation.x===-Math.PI&&c.rotation.y===12246467991473532e-32&&c.rotation.z===Math.PI,b=c.rotation.x===-6162975822039155e-48&&c.rotation.y===-l&&c.rotation.z===0,w=c.rotation.x===-6162975822039155e-48&&c.rotation.y===l&&c.rotation.z===0,A=c.rotation.x===-1.5707953264174506&&c.rotation.y===0&&c.rotation.z===0,I=c.rotation.x===1.5707953264174506&&c.rotation.y===0&&c.rotation.z===0;let D=t,P=n;y||w?D*=-1:A&&(P*=-1);const U=r/2/h,j=i/2/h;if(this.currentSpline===null&&(this.currentSpline=this.createSpline()),m||y){const C=D*U+c.position.x,Z=P*j+c.position.y;o.set(C,Z,0)}else if(b||w){const C=D*U+c.position.z,Z=P*j+c.position.y;o.set(0,Z,C)}else if(A||I){const C=D*U+c.position.x,Z=P*j+c.position.z;o.set(C,0,Z)}return o}get camera(){return this._camera}set camera(t){this._camera=t,this.children.forEach(n=>{const r=n;r.camera=t})}}const x_e=["Single","Side by Side","Stacked","Quad"],cht="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAC60lEQVRYhe2YT4hNcRTHP48xpmYaNAvRyEQxEhnKQljYsRm9/EmSyJiMFAsMZWNhJYoNIUVJ2VGiyb9ZzIpMpkQSahbGv9GMYWrM+1rc2zjvzvvdd+99rzdvMd+6de75nd+5387vnN/v/G5KEuWMKRNNIB8mCRaKiiL5qQb2ApuBuUAV0Ad0AJeB3sSeJRX6LJbULTf6JTUn9Z+KWMUpPyp/Avoa4CNQZ3Sj/lNpdL/xottR7AjOkHRUUpekN5I6JbVLavDH75lIfZN0UFKTpCWS0pJem/HeJBEMG6yV1ONYtgFJbZJ+GF1jDh+zJb03NuliEuwMkMo4yErS2RA/LcbuYVyCrm1mA7Dal/8Cu4FG4JD/HsTTkCy6a+SVMTPQuc1sBKb78nHghi+/A+YBxwL2lbhRY+ThuARdEVxu5JdGFvACr0otdoZ8Y4+Rn0Sn5sFFsMvI6YB9MzA1YJ8mN8k1wAHzfj4uQVdyrpI0aJL7oqTtkq4FiqPLyCOSbktqlbRL0jlJQ2b8QdwCUZ4qvhRStZL0XFK1pMd57CRvq5mfhKBriRfiFUMY6oD7eOdwPlQAN4G10dfWg+uouwXsiOssAj4AC+JMcEWwvnAuOTEr7gTXPmg34zagOwkbIIOXAo9CbDYBrcBXYN+4UUdy2sRflyS5zVNlfPX7ugpJW5V9nI7mmh+lYU0lCZ2B3TOnAVuAk0BTwC5nuhWro46KauBOQJch5OpRaoIW34GreGf+YZdRqS9NAj4Bp4ClQDvwOWxCqSM4ADQEdKE5XvbXzlITrAVe4TW+M6NMKDXBFLAMuAD0ACfIc7pMZBXXA2cY3/xmodQRHAL2A2+NLtj8ZiEKwUL/z2WMPAJcAVYALWSf8dZuDFGWeBHwKxm3sWYhiGG8Tfo6sA2vSfiSy4GrH3wGrDcfKSSKKf6v1E9yF0XK9Q1XBPuMXMw8HXTonQFwETwNzMFr64v1jzgFHIk9ybHEZYPJo65QlD3Bf2/Q/eaHPiSWAAAAAElFTkSuQmCC",uht="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAETklEQVRYhe2YXYhVVRTHf3d0/JhyUrMpFbImM+whSa3Mynww+4AeIgiKoozooQ+KyMyXIAujF6OXqHyI6iEKKYgIP/owsjSFqCkprdDUTEcjbWZ0HHV+Pex1ucfb9Z57Z9REXHA4Z++99l7/s/ZZ/7X2KaiczNLwfwPIk9MA+yunNMAG4DHgV+BvoB3YFff2TPstYEyfrajVroI6Sr1GvahsbJC63HzZq04pmztSvU5tVRuqYRiYg78JeBR4HPg5ntdmxovz9wJfA3uAxuibDLQCA+IqynnAQuBuYCnwMLC1rx48U12U8cZqdWqMDcx4cI16qTpYbVKHqa+ovWUeHKsujn7VL9ULq2HI+wY7gVeBJdGeFu3J4ZUiy/cAXeHRRuAQsC/GC0B3eG4BcH/0tUV7czUAeVsMsBF4Kha9HZgCvAncAuwPnXHA0wFuGLANuDrGuoGDwFxgTqzzQ7RX5FrP2eLsdb76vnogtme6+nE8H1YPlQXHwbi3q9eqn0e7Tb25VrsF68vFY0lb1AGcDTwItGQ8tQM4AIwGmqP/EPAu8A0wElgJfFGzxTo8mKWXu9Rd4ZF96jvqjSbauEC9Sn1O3R463epLaku99voCsFXdkAH3kNpcQW+IiT/bQne3eufxBtioPqP2mKhioXpWzpxb1T8C5Ifh4ZptVoriRmAIKdrI3Lujf3bobAPeJpF0NVkKrAFuI9HTOBIxnxFrF4OgQKKr/dnJlQA+AcwABgOHA4zAamA5cE7orQL+zAEHiWI+A2bFC7aSguheYCgpqAphZz3wSB7AecCICv2TgH8oFRib4gVqka0k0h8CXAxMBW6ooDejFoCvA9OBQUAvKWM0kDz4XUZvNKXtyZMWUl7vBbaQXq457PeEziDgx/KJlQAuIPFdMcEXv5OdYWBP9M8k8VpnDQCvB4aTSrCNJB5cSdrW3tBpIJVnR0qdUTxAfdGUOVTnmwqEanNmqltC/9OgqePKg5eom8PgdvW+oJ9Kupera0O3U50TL3lcAaI+oHaF4R3qa6Z822wq0Saq89T1lmSxOrxeW/Xm4uGkiqQDmECKuKHxHW0HdpMiewSpvGqKeR8Ay0iBsYIjg6261PE2o9Q3Yqv+MqWxO9R1Hl12qs+q49Vlppy82pSr+5xJKsko4AXgHlJ0t5NIeg3wLXAlqZhtIUV8J6nmWwX8QiLjdhL5TwMWkY4R6/rrwYKlMr1Y321QZ/vfwBijPqm+rF4Wc7PjE9QllurGVeoV5gRNHsAm9fnMom3qrKPoTjKdMXaYyrFygEWQ72XWW24qhPu8xcUc2UU6O8wFPjmK7jhgPHAuMJGUGQ6U6WwE5sfzTXGvei7KA9hFOiR9D/wOfFVFt4dS2tpfRe83Ur7/CPiJakfOGgBCypubatArl2r8VfOax/LfzABKtePAzHO/5FgC7KBEzB2kOrDfUm8mOeFySv9+OyFyGmB/5aQH+C9BVKmVCNuMZgAAAABJRU5ErkJggg==",dht="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAQ0lEQVQ4jWP8////fwYqAxYozUhFM/8zkaKYWIWkGEq0b0ZdSjQY5i79TyWagRGaTUdzFEEw6lLqGzqwLoVVJ1StpwA9sBwbUqAh5gAAAABJRU5ErkJggg==",jF=class jF extends On.Component{constructor(t){super(t);qe(this,"scene");qe(this,"renderer");qe(this,"currentScene");qe(this,"scenes",new Map);qe(this,"cameras",new Map);qe(this,"controls",new Map);qe(this,"currentCamera");qe(this,"currentWindow");qe(this,"helpersContainer",new j6);qe(this,"grid");qe(this,"cameraHelpers",new Map);qe(this,"lightHelpers",new Map);qe(this,"interactionHelper",new Pje(25));qe(this,"currentTransform");qe(this,"splineEditor");qe(this,"depthMaterial");qe(this,"normalsMaterial");qe(this,"uvMaterial");qe(this,"wireframeMaterial",new rl({opacity:.33,transparent:!0,wireframe:!0}));qe(this,"playing",!1);qe(this,"rafID",-1);qe(this,"cameraControlsRafID",-1);qe(this,"width",0);qe(this,"height",0);qe(this,"tlCam",null);qe(this,"trCam",null);qe(this,"blCam",null);qe(this,"brCam",null);qe(this,"tlRender","Renderer");qe(this,"trRender","Renderer");qe(this,"blRender","Renderer");qe(this,"brRender","Renderer");qe(this,"cameraVisibility",!0);qe(this,"lightVisibility",!0);qe(this,"gridVisibility",!0);qe(this,"rendererReady",!1);qe(this,"selectedItem");qe(this,"debugCamera");qe(this,"raycaster",new AA);qe(this,"pointer",new Ln);qe(this,"cameraControls");qe(this,"canvasRef");qe(this,"containerRef");qe(this,"tlWindow");qe(this,"trWindow");qe(this,"blWindow");qe(this,"brWindow");qe(this,"editorCameras",["Top","Bottom","Left","Right","Front","Back","Orthographic","UI","Debug"]);qe(this,"setupRenderer",t=>{const n=t.value;if(this.renderer){if(this.renderer instanceof VC&&n.type==="WebGLRenderer"||this.renderer instanceof hS&&n.type==="WebGPURenderer")return;this.renderer.dispose()}this.rendererReady=!1;const r=this.canvasRef.current;this.props.three.canvas=r,n.type==="WebGLRenderer"?(this.renderer=new VC({canvas:r,stencil:!1}),this.depthMaterial=new oSe,this.normalsMaterial=new lZ,this.uvMaterial=new Kdt,this.grid=new sat,this.scene.add(this.grid),this.rendererReady=!0):n.type==="WebGPURenderer"&&(this.renderer=new hS({canvas:r,stencil:!1}),this.grid=new Eat,this.scene.add(this.grid)),this.renderer&&(this.renderer.autoClear=!1,this.renderer.shadowMap.enabled=!0,this.renderer.setClearColor(0),this.renderer.setPixelRatio(devicePixelRatio),this.renderer.setScissorTest(!0),this.resize(),this.props.three.renderer=this.renderer,this.depthMaterial=new qdt,this.normalsMaterial=new OEe,this.uvMaterial=new Zdt,n.type==="WebGPURenderer"?this.renderer.init().then(()=>{this.rendererReady=!0,this.props.three.requestScene()}):this.props.three.requestScene())});qe(this,"onUpdate",()=>{this.playing&&(this.update(),this.draw(),this.rafID=requestAnimationFrame(this.onUpdate))});qe(this,"resize",()=>{var l;this.width=window.innerWidth-300,this.height=window.innerHeight,(l=this.renderer)==null||l.setSize(this.width,this.height);const t=Math.floor(this.width/2),n=Math.floor(this.height/2);this.props.three.resize(this.width,this.height),this.props.onSceneResize!==void 0&&this.currentScene!==void 0&&this.props.onSceneResize(this.currentScene,this.width,this.height);let r=this.width,i=this.height;switch(this.state.mode){case"Side by Side":r=t,i=this.height;break;case"Stacked":r=this.width,i=n;break;case"Quad":r=t,i=n;break}const o=r/i;this.cameras.forEach(c=>{var h;c instanceof J3?(c.left=r/-2,c.right=r/2,c.top=i/2,c.bottom=i/-2,c.name==="UI"&&(c.position.x=this.width/2,c.position.y=this.height/-2,c.position.z=100),c.updateProjectionMatrix()):c instanceof Va&&(c.aspect=o,c.updateProjectionMatrix()),(h=this.cameraHelpers.get(c.name))==null||h.update()})});qe(this,"addScene",t=>{const n=this.props.scenes.get(t.value.name);if(n!==void 0){const r=new n;r.visible=!1,this.props.onSceneAdd!==void 0&&this.props.onSceneAdd(r),this.props.three.scene=r,this.scenes.set(t.value.name,r),this.scene.add(r)}else console.log("Hermes - Scene not found:",t.value.name,this.props.scenes)});qe(this,"sceneUpdate",t=>{this.currentScene!==void 0&&(this.currentScene.visible=!1,this.clearLightHelpers());const n=this.scene.getObjectByName(t.value.name);n!==void 0&&(this.currentScene=n,this.currentScene.visible=!0,this.addLightHelpers(this.currentScene))});qe(this,"removeScene",t=>{const n=t.value.name;this.scenes.delete(n);const r=this.scene.getObjectByName(n);r&&setTimeout(()=>{Rp(r)},100),this.clearLightHelpers()});qe(this,"addCamera",t=>{var o;const n=t.value,r=n.uuid,i=(o=this.props.three.scene)==null?void 0:o.getObjectByProperty("uuid",n.uuid);if(i!==void 0){const l=i;this.cameras.set(r,l);const c=new Nje(l);c.visible=this.cameraVisibility,this.cameraHelpers.set(r,c),this.helpersContainer.add(c),this.setState({lastUpdate:Date.now()})}});qe(this,"removeCamera",t=>{const r=t.value.uuid,i=this.cameraHelpers.get(r);i!==void 0&&(this.helpersContainer.remove(i),i.dispose()),this.cameras.delete(r),this.setState({lastUpdate:Date.now()})});qe(this,"onMouseMove",t=>{var y;const n=new Ln;(y=this.renderer)==null||y.getSize(n);const r=Math.min(t.clientX,n.x),i=Math.min(t.clientY,n.y);this.pointer.x=D6(r,0,n.x,-1,1),this.pointer.y=D6(i,0,n.y,1,-1);const o=n.x/2,l=n.y/2,c=()=>{r<o?this.pointer.x=D6(r,0,o,-1,1):this.pointer.x=D6(r,o,n.x,-1,1)},h=()=>{i<l?this.pointer.y=D6(i,0,l,1,-1):this.pointer.y=D6(i,l,n.y,1,-1)};switch(this.state.mode){case"Quad":c(),h();break;case"Side by Side":c();break;case"Stacked":h(),h();break}if(this.updateCamera(r,i,o,l),this.state.interactionMode==="Orbit"||this.currentScene===void 0)return;const m=this.raycaster.intersectObjects(this.currentScene.children);m.length>0&&this.interactionHelper.position.copy(m[0].point)});qe(this,"onClick",t=>{if(this.state.interactionMode==="Orbit"||this.currentScene===void 0)return;const n=new Ln;if(this.renderer.getSize(n),t.clientX>=n.x)return;this.onMouseMove(t);const r=this.raycaster.intersectObjects(this.currentScene.children);r.length>0&&(this.props.three.getObject(r[0].object.uuid),this.interactionHelper.visible=!1,this.setState({interactionMode:"Orbit",lastUpdate:Date.now()}))});qe(this,"onKey",t=>{if(this.selectedItem!==void 0){if(t.ctrlKey){if(this.currentCamera.name==="UI")return;const n=this.controls.get(this.currentCamera.name);t.key==="0"?(t.preventDefault(),this.clearControls(),this.cameraControls=new ug(this.currentCamera,this.currentWindow.current),this.selectedItem instanceof gn||this.selectedItem instanceof QK?(this.selectedItem.geometry.computeBoundingBox(),this.cameraControls.fitToBox(this.selectedItem.geometry.boundingBox,!0)):this.cameraControls.fitToSphere(this.selectedItem,!0),this.updateCameraControls(n,!0)):t.key==="1"?(t.preventDefault(),this.clearControls(),this.cameraControls=new ug(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,Math.PI*.5,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(n)):t.key==="2"?(t.preventDefault(),this.clearControls(),this.cameraControls=new ug(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,0,!0),this.cameraControls.moveTo(this.selectedItem.position.x,0,this.selectedItem.position.z,!0),this.updateCameraControls(n)):t.key==="3"?(t.preventDefault(),this.clearControls(),this.cameraControls=new ug(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI/2,Math.PI/2,!0),this.cameraControls.moveTo(0,this.selectedItem.position.y,this.selectedItem.position.z,!0),this.updateCameraControls(n)):t.key==="4"?(t.preventDefault(),this.clearControls(),this.cameraControls=new ug(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI,Math.PI/2,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(n)):t.key==="5"&&(t.preventDefault(),this.clearControls(),this.cameraControls=new ug(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(DF(45),DF(45),!0),this.updateCameraControls(n))}else if(this.currentTransform!==void 0)switch(t.key){case"r":this.currentTransform.setMode("rotate");break;case"s":this.currentTransform.setMode("scale");break;case"t":this.currentTransform.setMode("translate");break;case"q":this.currentTransform.setSpace(this.currentTransform.space==="local"?"world":"local");break}}});qe(this,"onSetSelectedItem",t=>{this.selectedItem!==void 0&&this.updateSelectedItemHelper(!1),this.selectedItem=void 0;const n=t.value.uuid;if(this.scenes.forEach(r=>{n.search(r.uuid)>-1&&(this.selectedItem=r.getObjectByProperty("uuid",n))}),this.selectedItem===void 0){console.log(`Hermes - Can't find selected item: ${t.value.uuid}, ${t.value.name}`);return}this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),fh.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=fh.instance.add(t.value.name),this.currentTransform&&(this.currentTransform.attach(this.selectedItem),this.helpersContainer.add(this.currentTransform.getHelper()),this.currentTransform.addEventListener("objectChange",this.onUpdateTransform)),this.updateSelectedItemHelper(!0)});qe(this,"onUpdateTransform",()=>{this.selectedItem!==void 0&&(this.props.three.updateObject(this.selectedItem.uuid,"position",this.selectedItem.position),this.props.three.updateObject(this.selectedItem.uuid,"rotation",{x:this.selectedItem.rotation.x,y:this.selectedItem.rotation.y,z:this.selectedItem.rotation.z}),this.props.three.updateObject(this.selectedItem.uuid,"scale",this.selectedItem.scale),FF.instance.update())});qe(this,"clearLightHelpers",()=>{this.lightHelpers.forEach(t=>{this.helpersContainer.remove(t),t.dispose()}),this.lightHelpers.clear()});qe(this,"addLightHelpers",t=>{t.traverse(n=>{if(n.type.search("Light")>-1){let r;switch(n.type){case"DirectionalLight":r=new Aje(n,100),r.name=`${n.name}Helper`,r.visible=this.lightVisibility,this.lightHelpers.set(n.name,r),this.helpersContainer.add(r);break;case"HemisphereLight":r=new Cje(n,250),r.name=`${n.name}Helper`,r.visible=this.lightVisibility,this.lightHelpers.set(n.name,r),this.helpersContainer.add(r);break;case"RectAreaLight":r=new lot(n),r.name=`${n.name}Helper`,r.visible=this.lightVisibility,this.lightHelpers.set(n.name,r),this.helpersContainer.add(r);break;case"PointLight":r=new bSe(n,100),r.name=`${n.name}Helper`,r.visible=this.lightVisibility,this.lightHelpers.set(n.name,r),this.helpersContainer.add(r);break;case"SpotLight":r=new Tje(n),r.name=`${n.name}Helper`,r.visible=this.lightVisibility,this.lightHelpers.set(n.name,r),this.helpersContainer.add(r);break}}})});qe(this,"updateCamera",(t,n,r,i)=>{switch(this.state.mode){case"Quad":n<i?t<r?this.currentCamera=this.tlCam:this.currentCamera=this.trCam:t<r?this.currentCamera=this.blCam:this.currentCamera=this.brCam;break;case"Side by Side":t<r?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break;case"Single":this.currentCamera=this.tlCam;break;case"Stacked":n<i?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break}this.splineEditor.camera=this.currentCamera,this.raycaster.setFromCamera(this.pointer,this.currentCamera),this.currentCamera===this.tlCam?this.currentWindow=this.tlWindow:this.currentCamera===this.trCam?this.currentWindow=this.trWindow:this.currentCamera===this.blCam?this.currentWindow=this.blWindow:this.currentCamera===this.brCam&&(this.currentWindow=this.brWindow),fh.instance.updateCamera(this.currentCamera,this.currentWindow.current)});qe(this,"updateCameraControls",(t,n=!1)=>{if(this.selectedItem===void 0)return;cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.cameraControls&&(this.cameraControls.smoothTime=.1);const r=.15,i=new wje;i.start(),this.selectedItem.getWorldPosition(t.target0);const o=()=>{const l=i.getDelta();this.cameraControls&&this.cameraControls.update(l),n&&(t.target.lerp(t.target0,r),t.object.position.lerp(t.position0,r),t.object.zoom=mK(t.object.zoom,t.zoom0,r),t.object.updateProjectionMatrix(),t.dispatchEvent({type:"change"})),i.getElapsedTime()>=.5?(cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.clearControls()):this.cameraControlsRafID=requestAnimationFrame(o)};o()});qe(this,"clearControls",()=>{this.cameraControls!==void 0&&(this.cameraControls.disconnect(),this.cameraControls.dispose(),this.cameraControls=void 0)});qe(this,"drawDouble",()=>{const t=this.getSceneOverride(this.tlRender),n=this.getSceneOverride(this.trRender),r=Math.floor(this.width/2),i=Math.floor(this.height/2),o=this.renderer instanceof hS;if(this.state.mode==="Side by Side")this.drawTo(0,0,r,this.height,this.tlCam,t),this.drawTo(r,0,r,this.height,this.trCam,n);else{const l=this.height-i;o?(this.drawTo(0,0,this.width,i,this.tlCam,t),this.drawTo(0,l,this.width,i,this.trCam,n)):(this.drawTo(0,l,this.width,i,this.tlCam,t),this.drawTo(0,0,this.width,i,this.trCam,n))}});qe(this,"drawQuad",()=>{const t=this.renderer instanceof hS,n=this.getSceneOverride(this.tlRender),r=this.getSceneOverride(this.trRender),i=this.getSceneOverride(this.blRender),o=this.getSceneOverride(this.brRender),l=Math.floor(this.width/2),c=Math.floor(this.height/2),h=this.height-c;let m=0,y=t?0:this.height-c;m=0,this.drawTo(m,y,l,c,this.tlCam,n),m=l,this.drawTo(m,y,l,c,this.trCam,r),y=t?h:0,m=0,this.scene.overrideMaterial=i,this.drawTo(m,y,l,c,this.blCam,i),m=l,this.drawTo(m,y,l,c,this.brCam,o)});this.props.three.addEventListener(Ci.ADD_RENDERER,this.setupRenderer),this.scene=new XA,this.scene.name=this.scene.uuid="",this.canvasRef=On.createRef(),this.containerRef=On.createRef(),this.tlWindow=On.createRef(),this.trWindow=On.createRef(),this.blWindow=On.createRef(),this.brWindow=On.createRef();const n=t.three.name,r=localStorage,i=r.getItem(`${n}_mode`);this.state={mode:i!==null?i:"Single",modeOpen:!1,renderModeOpen:!1,interactionMode:"Orbit",interactionModeOpen:!1,lastUpdate:Date.now()},r.setItem(`${n}_mode`,this.state.mode),r.setItem(`${n}_tlCam`,r.getItem(`${n}_tlCam`)!==null?r.getItem(`${n}_tlCam`):"Debug"),r.setItem(`${n}_trCam`,r.getItem(`${n}_trCam`)!==null?r.getItem(`${n}_trCam`):"Orthographic"),r.setItem(`${n}_blCam`,r.getItem(`${n}_blCam`)!==null?r.getItem(`${n}_blCam`):"Front"),r.setItem(`${n}_brCam`,r.getItem(`${n}_brCam`)!==null?r.getItem(`${n}_brCam`):"Top"),r.setItem(`${n}_tlRender`,r.getItem(`${n}_tlRender`)!==null?r.getItem(`${n}_tlRender`):"Renderer"),r.setItem(`${n}_trRender`,r.getItem(`${n}_trRender`)!==null?r.getItem(`${n}_trRender`):"Renderer"),r.setItem(`${n}_blRender`,r.getItem(`${n}_blRender`)!==null?r.getItem(`${n}_blRender`):"Renderer"),r.setItem(`${n}_brRender`,r.getItem(`${n}_brRender`)!==null?r.getItem(`${n}_brRender`):"Renderer");const o={Vector2:Ln,Vector3:be,Vector4:zr,Quaternion:vs,Matrix4:Pn,Spherical:LY,Box3:i9,Sphere:xm,Raycaster:AA};ug.install({THREE:o}),this.setupScene(),this.setupTools();const l=localStorage.getItem(this.expandedCameraVisibility);l!==null&&(this.cameraVisibility=l==="open"),this.saveExpandedCameraVisibility();const c=localStorage.getItem(this.expandedLightVisibility);c!==null&&(this.lightVisibility=c==="open"),this.saveExpandedLightVisibility();const h=localStorage.getItem(this.expandedGridVisibility);h!==null&&(this.gridVisibility=h==="open"),this.grid&&(this.grid.visible=this.gridVisibility),this.saveExpandedGridVisibility(),jF.instance=this}componentDidMount(){this.enable(),this.assignControls(),this.resize(),this.play(),fh.instance.setApp(this.props.three),fh.instance.activeCamera=this.debugCamera,this.props.three.requestRenderer()}componentDidUpdate(t,n,r){n.mode!==this.state.mode&&(this.assignControls(),this.resize())}componentWillUnmount(){this.disable(),this.clear(),u5.removeEditorGroup("View Settings")}render(){const t=[];return this.cameras.forEach((n,r)=>{t.push(r)}),ot.jsxs("div",{className:"multiview",children:[ot.jsx("canvas",{ref:this.canvasRef}),ot.jsxs("div",{className:`cameras ${this.state.mode==="Single"||this.state.mode==="Stacked"?"single":""}`,ref:this.containerRef,children:[this.state.mode==="Single"&&ot.jsx(ot.Fragment,{children:ot.jsx(E6,{name:"tl",camera:this.tlCam,options:t,ref:this.tlWindow,onSelectCamera:n=>{var i;(i=this.controls.get(this.tlCam.name))==null||i.dispose();const r=this.cameras.get(n);r!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=r,localStorage.setItem(`${this.appID}_tlCam`,r.name),this.createControls(r,this.tlWindow.current))},onSelectRenderMode:n=>{this.tlRender=n,localStorage.setItem(`${this.appID}_tlRender`,n)}})}),(this.state.mode==="Side by Side"||this.state.mode==="Stacked")&&ot.jsxs(ot.Fragment,{children:[ot.jsx(E6,{name:"tl",camera:this.tlCam,options:t,ref:this.tlWindow,onSelectCamera:n=>{var i;(i=this.controls.get(this.tlCam.name))==null||i.dispose();const r=this.cameras.get(n);r!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=r,localStorage.setItem(`${this.appID}_tlCam`,r.name),this.createControls(r,this.tlWindow.current))},onSelectRenderMode:n=>{this.tlRender=n,localStorage.setItem(`${this.appID}_tlRender`,n)}}),ot.jsx(E6,{name:"tr",camera:this.trCam,options:t,ref:this.trWindow,onSelectCamera:n=>{var i;(i=this.controls.get(this.trCam.name))==null||i.dispose();const r=this.cameras.get(n);r!==void 0&&(this.clearCamera(this.trCam),this.trCam=r,localStorage.setItem(`${this.appID}_trCam`,r.name),this.createControls(r,this.trWindow.current))},onSelectRenderMode:n=>{this.trRender=n,localStorage.setItem(`${this.appID}_trRender`,n)}})]}),this.state.mode==="Quad"&&ot.jsxs(ot.Fragment,{children:[ot.jsx(E6,{name:"tl",camera:this.tlCam,options:t,ref:this.tlWindow,onSelectCamera:n=>{var i;(i=this.controls.get(this.tlCam.name))==null||i.dispose();const r=this.cameras.get(n);r!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=r,localStorage.setItem(`${this.appID}_tlCam`,r.name),this.createControls(r,this.tlWindow.current))},onSelectRenderMode:n=>{this.tlRender=n,localStorage.setItem(`${this.appID}_tlRender`,n)}}),ot.jsx(E6,{name:"tr",camera:this.trCam,options:t,ref:this.trWindow,onSelectCamera:n=>{var i;(i=this.controls.get(this.trCam.name))==null||i.dispose();const r=this.cameras.get(n);r!==void 0&&(this.clearCamera(this.trCam),this.trCam=r,localStorage.setItem(`${this.appID}_trCam`,r.name),this.createControls(r,this.trWindow.current))},onSelectRenderMode:n=>{this.trRender=n,localStorage.setItem(`${this.appID}_trRender`,n)}}),ot.jsx(E6,{name:"bl",camera:this.blCam,options:t,ref:this.blWindow,onSelectCamera:n=>{var i;(i=this.controls.get(this.blCam.name))==null||i.dispose();const r=this.cameras.get(n);r!==void 0&&(this.clearCamera(this.blCam),this.blCam=r,localStorage.setItem(`${this.appID}_blCam`,r.name),this.createControls(r,this.blWindow.current))},onSelectRenderMode:n=>{this.blRender=n,localStorage.setItem(`${this.appID}_blRender`,n)}}),ot.jsx(E6,{name:"br",camera:this.brCam,options:t,ref:this.brWindow,onSelectCamera:n=>{var i;(i=this.controls.get(this.brCam.name))==null||i.dispose();const r=this.cameras.get(n);r!==void 0&&(this.clearCamera(this.brCam),this.brCam=r,localStorage.setItem(`${this.appID}_brCam`,r.name),this.createControls(r,this.brWindow.current))},onSelectRenderMode:n=>{this.brRender=n,localStorage.setItem(`${this.appID}_brRender`,n)}})]})]}),ot.jsxs("div",{className:"settings",children:[ot.jsx(OF,{title:"View",index:x_e.indexOf(this.state.mode),options:x_e,onSelect:n=>{n!==this.state.mode&&(this.killControls(),this.setState({mode:n}),localStorage.setItem(`${this.appID}_mode`,n))},open:this.state.modeOpen,onToggle:n=>{this.setState({modeOpen:n,renderModeOpen:!1,interactionModeOpen:!1})}}),ot.jsx(OF,{title:"Interact",index:this.state.interactionMode==="Orbit"?0:1,options:["Orbit Mode","Selection Mode"],onSelect:n=>{this.interactionHelper.visible=n==="Selection Mode",this.setState({interactionMode:this.interactionHelper.visible?"Selection":"Orbit"})},open:this.state.interactionModeOpen,onToggle:n=>{this.setState({modeOpen:!1,renderModeOpen:!1,interactionModeOpen:n})}}),ot.jsx(DX,{name:"cameraHelper",icon:cht,selected:this.cameraVisibility,height:24,top:2,onClick:n=>{if(this.cameraVisibility=n,this.saveExpandedCameraVisibility(),this.cameraHelpers.forEach(r=>{r.visible=n}),this.selectedItem!==void 0&&!n){const r=this.cameraHelpers.get(this.selectedItem.name);r!==void 0&&(r.visible=!0)}}}),ot.jsx(DX,{name:"lightHelper",icon:uht,selected:this.lightVisibility,height:24,top:4,onClick:n=>{if(this.lightVisibility=n,this.saveExpandedLightVisibility(),this.lightHelpers.forEach(r=>{r.visible=n}),this.selectedItem!==void 0&&!n&&this.selectedItem.isLight===!0){const r=this.lightHelpers.get(this.selectedItem.name);r!==void 0&&(r.visible=!0)}}}),ot.jsx(DX,{name:"gridHelper",icon:dht,selected:this.gridVisibility,height:21,width:21,onClick:n=>{this.setGridVisibility(n)}})]},this.state.lastUpdate)]})}setupScene(){this.helpersContainer.name="helpers",this.scene.add(this.helpersContainer),this.interactionHelper.name="interactionHelper",this.interactionHelper.visible=!1,this.helpersContainer.add(this.interactionHelper);const t=(o,l)=>{const c=new J3(-100,100,100,-100,0,3e3);return c.name=o,c.position.copy(l),c.lookAt(0,0,0),this.cameras.set(o,c),c},n=1e3;t("Top",new be(0,n,0)),t("Bottom",new be(0,-n,0)),t("Left",new be(-n,0,0)),t("Right",new be(n,0,0)),t("Front",new be(0,0,n)),t("Back",new be(0,0,-n)),t("Orthographic",new be(n,n,n)),t("UI",new be),this.debugCamera=new Va(60,1,.01,3e3),this.debugCamera.name="Debug",this.debugCamera.position.set(300,300,300),this.debugCamera.lookAt(0,0,0),this.cameras.set("Debug",this.debugCamera),this.currentCamera=this.debugCamera;const r=localStorage,i=this.props.three.name;this.tlCam=this.cameras.get(r.getItem(`${i}_tlCam`)),this.trCam=this.cameras.get(r.getItem(`${i}_trCam`)),this.blCam=this.cameras.get(r.getItem(`${i}_blCam`)),this.brCam=this.cameras.get(r.getItem(`${i}_brCam`)),this.tlCam===void 0&&(this.tlCam=this.cameras.get("Debug")),this.trCam===void 0&&(this.trCam=this.cameras.get("Orthographic")),this.blCam===void 0&&(this.blCam=this.cameras.get("Front")),this.brCam===void 0&&(this.brCam=this.cameras.get("Top")),u5.addEditorGroup({title:"Editor",items:[{type:"button",prop:"Hide All Transforms"},{type:"button",prop:"Resize"}],onUpdate:(o,l)=>{switch(o){case"Hide All Transforms":fh.instance.hide();break;case"Resize":this.resize();break}},subgroups:[{title:"Debug Camera",items:[{type:"range",prop:"Near",step:1e-4,min:.001,max:1e3,value:this.debugCamera.near},{type:"range",prop:"Far",step:.001,min:.001,max:1e4,value:this.debugCamera.far}],onUpdate:(o,l)=>{switch(o){case"Near":this.debugCamera.near=l,this.debugCamera.updateProjectionMatrix();break;case"Far":this.debugCamera.far=l,this.debugCamera.updateProjectionMatrix();break}}},{title:"Grid",items:[{type:"number",prop:"Position",value:0},{type:"color",prop:"Color",value:"#FFFFFF"},{type:"range",prop:"Grid Opacity",value:.25,min:0,max:1,step:.01},{type:"range",prop:"Subgrid Opacity",value:.15,min:0,max:1,step:.01}],onUpdate:(o,l)=>{switch(o){case"Position":this.grid&&(this.grid.position.y=l);break;case"Color":this.grid&&this.grid.color.setStyle(l);break;case"Grid Opacity":this.grid&&(this.grid.gridOpacity=l);break;case"Subgrid Opacity":this.grid&&(this.grid.subgridOpacity=l);break}}}]})}setupTools(){this.splineEditor=new lht(this.currentCamera,this.three),this.splineEditor.initDebug(),this.helpersContainer.add(this.splineEditor)}play(){this.playing=!0,this.onUpdate()}pause(){this.playing=!1,cancelAnimationFrame(this.rafID),this.rafID=-1}toggleOrbitControls(t){this.controls.forEach(n=>{n.enabled=!t})}clear(){this.three.dispatchEvent({type:Ci.CLEAR_OBJECT}),u5.removeAllGroups(),this.clearLightHelpers(),this.clearControls(),this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),fh.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=void 0,fh.instance.clear(),this.cameras.forEach(t=>{this.editorCameras.indexOf(t.name)<0&&this.three.dispatchEvent({type:Ci.REMOVE_CAMERA,value:t})}),this.currentCamera=this.debugCamera,this.currentScene=void 0,this.scenes.forEach(t=>{this.three.dispatchEvent({type:Ci.REMOVE_SCENE,value:t})}),this.scenes.clear()}setGridVisibility(t){this.gridVisibility=t,this.saveExpandedGridVisibility(),this.grid&&(this.grid.visible=t)}update(){var t;this.renderer&&this.rendererReady&&((t=this.renderer)==null||t.clear()),this.controls.forEach(n=>n.update()),this.cameraHelpers.forEach(n=>n.update()),this.lightHelpers.forEach(n=>{n.update!==void 0&&n.update()}),this.props.onSceneUpdate!==void 0&&this.currentScene!==void 0&&this.props.onSceneUpdate(this.currentScene)}draw(){var t;if(this.rendererReady)switch(this.renderer&&((t=this.renderer)==null||t.clear()),this.state.mode){case"Single":this.drawSingle();break;case"Side by Side":case"Stacked":this.drawDouble();break;case"Quad":this.drawQuad();break}}enable(){const t=this.containerRef.current;t.addEventListener("mousemove",this.onMouseMove),t.addEventListener("click",this.onClick),window.addEventListener("keydown",this.onKey),window.addEventListener("resize",this.resize),this.three.addEventListener(Ci.ADD_SCENE,this.addScene),this.three.addEventListener(Ci.SET_SCENE,this.sceneUpdate),this.three.addEventListener(Ci.REMOVE_SCENE,this.removeScene),this.three.addEventListener(Ci.ADD_CAMERA,this.addCamera),this.three.addEventListener(Ci.REMOVE_CAMERA,this.removeCamera),this.three.addEventListener(Ci.SET_OBJECT,this.onSetSelectedItem)}disable(){const t=this.containerRef.current;t.removeEventListener("mousemove",this.onMouseMove),t.removeEventListener("click",this.onClick),window.removeEventListener("keydown",this.onKey),window.removeEventListener("resize",this.resize),this.three.removeEventListener(Ci.ADD_SCENE,this.addScene),this.three.removeEventListener(Ci.SET_SCENE,this.sceneUpdate),this.three.removeEventListener(Ci.ADD_CAMERA,this.addCamera),this.three.removeEventListener(Ci.REMOVE_CAMERA,this.removeCamera),this.three.removeEventListener(Ci.SET_OBJECT,this.onSetSelectedItem)}updateSelectedItemHelper(t){if(this.selectedItem!==void 0)if(this.cameraVisibility){if(this.selectedItem.isLight===!0&&!this.lightVisibility){const n=this.lightHelpers.get(this.selectedItem.name);n!==void 0&&(n.visible=t)}}else{const n=this.cameraHelpers.get(this.selectedItem.name);n!==void 0&&(n.visible=t)}}createControls(t,n){const r=this.controls.get(t.name);if(r!==void 0&&r.dispose(),this.controls.delete(t.name),t.name==="UI")return;const i=new ECe(t,n);switch(i.enableDamping=!0,i.dampingFactor=.1,t.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":i.enableRotate=!1;break}this.controls.set(t.name,i)}clearCamera(t){const n=this.cameraHelpers.get(t.name);n!==void 0&&(this.helpersContainer.remove(n),n.dispose(),this.cameraHelpers.delete(t.name));const r=this.controls.get(t.name);r!==void 0&&(r.dispose(),this.controls.delete(t.name))}killControls(){this.controls.forEach((t,n)=>{t.dispose();const r=this.cameraHelpers.get(n);r!==void 0&&(this.helpersContainer.remove(r),r.dispose()),this.cameraHelpers.delete(n),this.controls.delete(n)}),this.controls.clear(),this.cameraHelpers.clear()}assignControls(){switch(this.state.mode){case"Single":this.createControls(this.tlCam,this.tlWindow.current);break;case"Side by Side":case"Stacked":this.createControls(this.tlCam,this.tlWindow.current),this.createControls(this.trCam,this.trWindow.current);break;case"Quad":this.createControls(this.tlCam,this.tlWindow.current),this.createControls(this.trCam,this.trWindow.current),this.createControls(this.blCam,this.blWindow.current),this.createControls(this.brCam,this.brWindow.current);break}}saveExpandedCameraVisibility(){localStorage.setItem(this.expandedCameraVisibility,this.cameraVisibility?"open":"closed")}saveExpandedLightVisibility(){localStorage.setItem(this.expandedLightVisibility,this.lightVisibility?"open":"closed")}saveExpandedGridVisibility(){localStorage.setItem(this.expandedGridVisibility,this.gridVisibility?"open":"closed")}getSceneOverride(t){switch(t){case"Depth":return this.depthMaterial;case"Normals":return this.normalsMaterial;case"Renderer":return null;case"UVs":return this.uvMaterial;case"Wireframe":return this.wireframeMaterial}return null}drawTo(t,n,r,i,o,l){var c,h,m;switch(o.name){case"Left":case"Right":this.grid&&(this.grid.rotation.z=Math.PI/2);break;case"Front":case"Back":this.grid&&(this.grid.rotation.x=Math.PI/2);break}this.scene.overrideMaterial=l,this.renderer&&((c=this.renderer)==null||c.setScissor(t,n,r,i),(h=this.renderer)==null||h.setViewport(t,n,r,i),(m=this.renderer)==null||m.render(this.scene,o)),this.grid&&this.grid.rotation.set(0,0,0)}drawSingle(){const t=this.getSceneOverride(this.tlRender);this.drawTo(0,0,this.width,this.height,this.tlCam,t)}get appID(){return this.props.three.name}get mode(){return this.state.mode}get three(){return this.props.three}get expandedCameraVisibility(){return`${this.appID}_multiviewCameraVisibility`}get expandedLightVisibility(){return`${this.appID}_multiviewLightVisibility`}get expandedGridVisibility(){return`${this.appID}_multiviewGridVisibility`}};qe(jF,"instance",null);let nl=jF;function aNe(s){if(s.child===void 0)return console.log("Hermes - No child attached"),null;const e=On.useRef(null),[t,n]=On.useState(!1),r=s.child.children.length>0,i=[];return s.child.children.length>0&&s.child.children.map((o,l)=>{i.push(ot.jsx(aNe,{child:o,three:s.three},l))}),On.useEffect(()=>{if(s.child){const o=s.child.uuid.split(".")[0],l=s.three.getScene(o);if(l!==null)try{const c=l.getObjectByProperty("uuid",s.child.uuid);c!==void 0?e.current.style.opacity=c.visible?"1":"0.25":console.log(`Hermes - Can't find child: ${s.child.uuid}`)}catch(c){console.log("Error looking for child:",c),console.log(s.child),console.log(s.three.scenes),console.log(l)}else console.log(`Hermes (ChildObject) - Can't find Scene: ${o} with child UUID: ${s.child.uuid}`,s.three.scenes,s.three.scene,l)}},[t]),ot.jsxs("div",{className:"childObject",children:[ot.jsxs("div",{className:"child",children:[r?ot.jsx("button",{className:"status",style:{backgroundPositionX:t?"-14px":"2px"},onClick:()=>{n(!t)}}):null,ot.jsx("button",{className:"name",style:{left:r?"20px":"5px"},onClick:()=>{s.child!==void 0?(s.three.getObject(s.child.uuid),!t&&r&&n(!0)):console.log("Hermes - No child attached...")},children:s.child.name.length>0?`${s.child.name} (${s.child.type})`:`${s.child.type}::${s.child.uuid}`}),ot.jsx("button",{className:"visibility",ref:e,onClick:()=>{if(s.child){const o=s.three.getScene(s.child.uuid);if(o!==null){const l=o.getObjectByProperty("uuid",s.child.uuid);if(l!==void 0){const c="visible",h=!l.visible;e.current.style.opacity=h?"1":"0.25",s.three.updateObject(s.child.uuid,c,h),za(l,c,h)}else console.log(`Hermes - Couldn't find object: ${s.child.uuid}`,o)}else console.log(`Hermes - Couldn't find object in scene: ${s.child.uuid}, ${s.child.name}`)}}}),ot.jsx("div",{className:`icon ${eot(s.child)}`})]}),ot.jsx("div",{className:t?"open":"",children:ot.jsx("div",{className:"container",children:i})})]},Math.random())}function fY(s){var t;const e=[];return(t=s.child)==null||t.children.map((n,r)=>{e.push(ot.jsx(aNe,{child:n,scene:s.scene,three:s.three},r))}),ot.jsx("div",{className:`scene ${s.class!==void 0?s.class:""}`,children:e})}function b_e(s){switch(s){case"fov":return"FOV";case"zoom":return"Zoom";case"near":return"Near";case"far":return"Far";case"focus":return"Focus";case"aspect":return"Aspect";case"filmGauge":return"Film Gauge";case"filmOffset":return"Film Offset";case"left":return"Left";case"right":return"Right";case"top":return"Top";case"bottom":return"Bottom"}return s}function hht(s,e){function t(){return`${e.name}_camera`}const n=localStorage.getItem(t()),r=n!==null?n==="open":!1;function i(l){localStorage.setItem(t(),l?"open":"closed")}const o=[];if(s.perspectiveCameraInfo!==void 0)for(const l in s.perspectiveCameraInfo)o.push({title:b_e(l),prop:l,type:"number",step:.01,value:s.perspectiveCameraInfo[l],onChange:(c,h)=>{e.updateObject(s.uuid,c,h),e.requestMethod(s.uuid,"updateProjectionMatrix");const m=e.getScene(s.uuid);if(m!==null){const y=m.getObjectByProperty("uuid",s.uuid);y!==void 0&&(za(y,c,h),y.updateProjectionMatrix())}}});else if(s.orthographicCameraInfo!==void 0)for(const l in s.orthographicCameraInfo)o.push({title:b_e(l),prop:l,type:"number",step:.01,value:s.orthographicCameraInfo[l],onChange:(c,h)=>{e.updateObject(s.uuid,c,h),e.requestMethod(s.uuid,"updateProjectionMatrix");const m=e.getScene(s.uuid);if(m!==null){const y=m.getObjectByProperty("uuid",s.uuid);y!==void 0&&(za(y,c,h),y.updateProjectionMatrix())}}});return ot.jsx(Ip,{three:e,title:"Camera",items:o,expanded:r,onToggle:l=>{i(l)}})}function __e(s){switch(s){case"color":return"Color";case"intensity":return"Intensity";case"decay":return"Decay";case"distance":return"Distance";case"angle":return"Angle";case"penumbra":return"Penumbra";case"groundColor":return"Ground Color";case"width":return"Width";case"height":return"Height"}return s}function pht(s,e){function t(){return`${e.name}_light`}const n=localStorage.getItem(t()),r=n!==null?n==="open":!1;function i(l){localStorage.setItem(t(),l?"open":"closed")}const o=[];if(s.lightInfo!==void 0)for(const l in s.lightInfo){const c=s.lightInfo[l];c!==void 0&&(c.isColor!==void 0?o.push({title:__e(l),prop:l,type:"color",value:c,onChange:(h,m)=>{const y=new Tn(m);e.updateObject(s.uuid,h,y);const b=e.getScene(s.uuid);if(b!==null){const w=b.getObjectByProperty("uuid",s.uuid);za(w,h,y)}}}):o.push({title:__e(l),prop:l,type:typeof c,value:c,step:typeof c=="number"?.01:void 0,onChange:(h,m)=>{e.updateObject(s.uuid,h,m);const y=e.getScene(s.uuid);if(y!==null){const b=y.getObjectByProperty("uuid",s.uuid);za(b,h,m)}}}))}return ot.jsx(Ip,{three:e,title:"Light",items:o,expanded:r,onToggle:l=>{i(l)}})}function fht(s){var b;const e=s.object,t=s.three;function n(){return`${t.name}_animation`}const r=localStorage.getItem(n()),i=r!==null?r==="open":!1;function o(w){localStorage.setItem(n(),w?"open":"closed")}const l=[],c=[];let h=0;e.animations.forEach(w=>{h=Math.max(h,w.duration),w.duration>0&&c.push({title:w.name,items:[{title:"Duration",type:"number",value:w.duration,disabled:!0},{title:"Blend Mode",type:"option",disabled:!0,options:[{title:"Normal",value:2500},{title:"Additive",value:2501}]}]})}),l.push({title:"Animations",items:c});let m;const y=t.getScene(e.uuid);if(y!==null){const w=y.getObjectByProperty("uuid",e.uuid);if(w!==void 0){const A=w.mixer;if(A!==void 0){const D=[{title:"Time Scale",type:"range",value:A.timeScale,step:.01,min:-1,max:2,onChange:(P,U)=>{A.timeScale=U,t.updateObject(e.uuid,"mixer.timeScale",U)}}];D.push({title:"Stop All",type:"button",onChange:()=>{A.stopAllAction(),t.requestMethod(e.uuid,"stopAllAction",void 0,"mixer")}}),l.push({title:"Mixer",items:D}),m=new Eje(w),(b=nl.instance)==null||b.scene.add(m)}}}return On.useEffect(()=>()=>{m!==void 0&&Rp(m)},[]),ot.jsx(Ip,{three:s.three,title:"Animation",items:l,expanded:i,onToggle:w=>{o(w)}})}const mY={name:"",uuid:"",type:"",visible:!1,matrix:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0,children:[]};function mht(s){const[e,t]=On.useState(mY);On.useEffect(()=>{function o(c){t(c.value)}function l(){t(mY)}return s.three.addEventListener(Ci.CLEAR_OBJECT,l),s.three.addEventListener(Ci.SET_SCENE,l),s.three.addEventListener(Ci.SET_OBJECT,o),()=>{s.three.removeEventListener(Ci.CLEAR_OBJECT,l),s.three.removeEventListener(Ci.SET_SCENE,l),s.three.removeEventListener(Ci.SET_OBJECT,o)}},[]);const n=e.type.toLowerCase(),r=e.animations.length>0||e.mixer!==void 0,i=n.search("mesh")>-1||n.search("line")>-1||n.search("points")>-1;return ot.jsx(QC,{three:s.three,label:"Inspector",button:e.uuid.length>0?ot.jsx("button",{className:"remove",onClick:()=>{fh.instance.remove(e.name),t(mY)}}):void 0,children:ot.jsx("div",{id:"Inspector",className:s.class,children:e.uuid.length>0&&ot.jsxs(ot.Fragment,{children:[ot.jsxs(ot.Fragment,{children:[ot.jsx(nF,{type:"string",title:"Name",prop:"name",value:e.name,disabled:!0}),ot.jsx(nF,{type:"string",title:"Type",prop:"type",value:e.type,disabled:!0}),ot.jsx(nF,{type:"string",title:"UUID",prop:"uuid",value:e.uuid,disabled:!0})]}),ot.jsxs(ot.Fragment,{children:[ot.jsx(FF,{object:e,three:s.three}),r?ot.jsx(fht,{object:e,three:s.three}):null,n.search("camera")>-1?hht(e,s.three):null,n.search("light")>-1?pht(e,s.three):null,i?Gat(e,s.three):null]})]})})},"Inspector")}class ght extends On.Component{constructor(t){super(t);qe(this,"autoClear",!0);qe(this,"autoClearColor",!0);qe(this,"autoClearDepth",!0);qe(this,"autoClearStencil",!0);qe(this,"outputColorSpace",Is);qe(this,"localClippingEnabled",!1);qe(this,"clearColor",new Tn(0));qe(this,"clearAlpha",1);qe(this,"toneMapping",Ta);qe(this,"toneMappingExposure",1);qe(this,"type","");qe(this,"onAddRenderer",t=>{const n=t.value;if(this.autoClear=n.autoClear,this.autoClearColor=n.autoClearColor,this.autoClearDepth=n.autoClearDepth,this.autoClearStencil=n.autoClearStencil,this.outputColorSpace=n.outputColorSpace,this.localClippingEnabled=n.localClippingEnabled,this.clearAlpha=n.clearAlpha,this.type=n.type,this.toneMapping=n.toneMapping,this.toneMappingExposure=n.toneMappingExposure,this.clearColor.setStyle(n.clearColor,vd),Zn.enabled=n.colorManagement,nl.instance){const r=nl.instance.renderer;r&&(r.autoClearColor=this.autoClearColor,r.outputColorSpace=this.outputColorSpace,r instanceof VC&&(r.localClippingEnabled=this.localClippingEnabled),r.toneMapping=this.toneMapping,r.toneMappingExposure=this.toneMappingExposure,r.setClearColor(n.clearColor,this.clearAlpha))}this.setState({lastUpdated:Date.now()})});const n=localStorage.getItem(this.expandedName),r=n!==null?n==="open":!1;if(this.state={expanded:r,lastUpdated:Date.now()},this.saveExpanded(r),nl.instance){const i=nl.instance.renderer;i&&(this.autoClear=i.autoClear,this.autoClearColor=i.autoClearColor,this.autoClearDepth=i.autoClearDepth,this.autoClearStencil=i.autoClearStencil,this.clearAlpha=i.getClearAlpha(),this.toneMapping=i.toneMapping,this.toneMappingExposure=i.toneMappingExposure,i instanceof VC&&(this.localClippingEnabled=i.localClippingEnabled,i.getClearColor(this.clearColor)))}this.props.three.addEventListener(Ci.ADD_RENDERER,this.onAddRenderer)}componentwillunmount(){this.props.three.removeEventListener(Ci.ADD_RENDERER,this.onAddRenderer)}render(){const t=()=>{if(nl.instance){const n=nl.instance.renderer;n&&(n.autoClearColor=this.autoClearColor,n.outputColorSpace=this.outputColorSpace,n instanceof VC&&(n.localClippingEnabled=this.localClippingEnabled),n.toneMapping=this.toneMapping,n.toneMappingExposure=this.toneMappingExposure,n.setClearColor(this.clearColor.getStyle(),this.clearAlpha),this.props.three.updateRenderer({autoClear:this.autoClear,autoClearColor:this.autoClearColor,autoClearDepth:this.autoClearDepth,autoClearStencil:this.autoClearStencil,outputColorSpace:this.outputColorSpace,localClippingEnabled:this.localClippingEnabled,clearAlpha:this.clearAlpha,clearColor:this.clearColor.getStyle(),colorManagement:Zn.enabled,toneMapping:this.toneMapping,toneMappingExposure:this.toneMappingExposure}))}};return ot.jsx(Ip,{three:this.props.three,title:"Renderer",expanded:this.state.expanded,items:[{type:"boolean",title:"Auto Clear",value:this.autoClear,onChange:(n,r)=>{this.autoClear=r}},{type:"boolean",title:"Auto Clear Color",value:this.autoClearColor,onChange:(n,r)=>{this.autoClearColor=r,t()}},{type:"boolean",title:"Auto Clear Depth",value:this.autoClearDepth,onChange:(n,r)=>{this.autoClearDepth=r,t()}},{type:"boolean",title:"Auto Clear Stencil",value:this.autoClearStencil,onChange:(n,r)=>{this.autoClearStencil=r,t()}},{type:"boolean",title:"Local Clipping",value:this.localClippingEnabled,onChange:(n,r)=>{this.localClippingEnabled=r,t()}},{type:"color",title:"Clear Color",value:`#${this.clearColor.getHexString()}`,onChange:(n,r)=>{this.clearColor.setStyle(r),t()}},{type:"range",title:"Clear Alpha",min:0,max:1,step:.01,value:this.clearAlpha,onChange:(n,r)=>{this.clearAlpha=r,t()}},{type:"boolean",title:"Color Management",value:Zn.enabled,onChange:(n,r)=>{Zn.enabled=r,t()}},{type:"option",title:"Color Space",value:this.outputColorSpace,options:[{title:"No Color Space",value:gu},{title:"SRB Color Space",value:Is},{title:"Linear SRB Color Space",value:vd}],onChange:(n,r)=>{this.outputColorSpace=r,t()}},{type:"option",title:"Tone Mapping",value:this.toneMapping,options:[{title:"None ",value:Ta},{title:"Linear ",value:qF},{title:"Reinhard",value:XF},{title:"Cineon ",value:YF},{title:"ACES Filmic",value:KF},{title:"AgX",value:ZF},{title:"Neutral",value:QF},{title:"Custom",value:FK}],onChange:(n,r)=>{this.toneMapping=r,t()}},{type:"range",title:"Tone Mapping Exposure",value:this.toneMappingExposure,min:0,max:2,step:.01,onChange:(n,r)=>{this.toneMappingExposure=r,t()}},{type:"string",title:"Type",value:this.type,disabled:!0},{type:"button",title:"Resize Scenes from Source",onChange:()=>{this.props.three.requestSize()}}],onToggle:n=>{this.setState({expanded:n}),this.saveExpanded(n)}},Math.random())}saveExpanded(t){localStorage.setItem(this.expandedName,t?"open":"closed")}get expandedName(){return`${this.props.three.name}_renderer`}}function yht(s){const[e]=On.useState([]),[t]=On.useState([]),[n,r]=On.useState(0),i=h=>{const m=h.value;e.push(m),t.push(ot.jsx(QC,{three:s.three,label:`Scene: ${m.name}`,scene:m,open:!1,visible:!1,onRefresh:()=>{s.three.refreshScene(m.name)},children:ot.jsx(fY,{child:m,scene:m,three:s.three})},m.name)),r(Date.now())},o=h=>{const m=h.value;for(let y=0;y<e.length;y++)if(m.uuid===e[y].uuid){e[y]=m,t[y]=ot.jsx(QC,{three:s.three,label:`Scene: ${m.name}`,scene:m,open:t[y].props.open,visible:t[y].props.visible,onRefresh:()=>{s.three.refreshScene(m.name)},children:ot.jsx(fY,{child:m,scene:m,three:s.three})},m.name),r(Date.now());return}},l=h=>{const m=h.value;for(let y=0;y<e.length;y++)if(m.uuid===e[y].uuid){e.splice(y,1),t.splice(y,1),r(Date.now());return}},c=h=>{const m=h.value.name;for(let y=0;y<e.length;y++){const b=e[y],w=b.name===m;t[y]=ot.jsx(QC,{three:s.three,label:`Scene: ${b.name}`,scene:b,open:w,visible:w,onRefresh:()=>{s.three.refreshScene(b.name)},children:ot.jsx(fY,{child:b,scene:b,three:s.three})},b.name)}r(Date.now())};return On.useEffect(()=>(s.three.addEventListener(Ci.ADD_SCENE,i),s.three.addEventListener(Ci.SET_SCENE,c),s.three.addEventListener(Ci.REFRESH_SCENE,o),s.three.addEventListener(Ci.REMOVE_SCENE,l),()=>{s.three.removeEventListener(Ci.ADD_SCENE,i),s.three.removeEventListener(Ci.SET_SCENE,c),s.three.removeEventListener(Ci.REFRESH_SCENE,o),s.three.removeEventListener(Ci.REMOVE_SCENE,l)}),[]),ot.jsxs("div",{id:"SidePanel",children:[ot.jsx("div",{className:"scenes",children:t},n),ot.jsx(mht,{three:s.three}),ot.jsx(ght,{three:s.three}),ot.jsx(u5,{three:s.three})]})}function vht(s){return ot.jsx(aot,{children:ot.jsxs(ot.Fragment,{children:[ot.jsx(nl,{three:s.three,scenes:s.scenes,onSceneAdd:s.onSceneAdd,onSceneResize:s.onSceneResize,onSceneUpdate:s.onSceneUpdate}),ot.jsx(yht,{three:s.three})]})})}async function xht(){var n;for(;!document.getElementById("theatrejs-studio-root");)await new Promise(r=>setTimeout(r,100));const s=document.getElementById("theatrejs-studio-root");if(s===null||s.shadowRoot===null)return;const e=s.shadowRoot.getElementById("pointer-root");if(e===null)return;const t=e.children[0];if(t!==null){try{const i=t.children[1].children[1];(n=i.parentElement)==null||n.removeChild(i)}catch{}try{const r=t.children[3];r.style.top="0",r.style.right="300px"}catch{}}}const bht=`varying vec2 vUv;
|
|
8757
|
+
}`;class Kdt extends bh{constructor(){super({defines:{USE_UV:""},uniforms:{opacity:{value:1}},vertexShader:Xdt,fragmentShader:Ydt,transparent:!0})}}class Zdt extends sNe{constructor(){super(),this.colorNode=Tl(fN(),0,1)}}const P6=new AA,_c=new be,Uy=new be,Uo=new vs,h_e={X:new be(1,0,0),Y:new be(0,1,0),Z:new be(0,0,1)},uY={type:"change"},p_e={type:"mouseDown",mode:null},f_e={type:"mouseUp",mode:null},m_e={type:"objectChange"};class Qdt extends _Se{constructor(e,t=null){super(void 0,t);const n=new iht(this);this._root=n;const r=new sht;this._gizmo=r,n.add(r);const i=new oht;this._plane=i,n.add(i);const o=this;function l(j,C){let Z=C;Object.defineProperty(o,j,{get:function(){return Z!==void 0?Z:C},set:function(ie){Z!==ie&&(Z=ie,i[j]=ie,r[j]=ie,o.dispatchEvent({type:j+"-changed",value:ie}),o.dispatchEvent(uY))}}),o[j]=C,i[j]=C,r[j]=C}l("camera",e),l("object",void 0),l("enabled",!0),l("axis",null),l("mode","translate"),l("translationSnap",null),l("rotationSnap",null),l("scaleSnap",null),l("space","world"),l("size",1),l("dragging",!1),l("showX",!0),l("showY",!0),l("showZ",!0),l("minX",-1/0),l("maxX",1/0),l("minY",-1/0),l("maxY",1/0),l("minZ",-1/0),l("maxZ",1/0);const c=new be,h=new be,m=new vs,y=new vs,b=new be,w=new vs,A=new be,I=new be,D=new be,P=0,U=new be;l("worldPosition",c),l("worldPositionStart",h),l("worldQuaternion",m),l("worldQuaternionStart",y),l("cameraPosition",b),l("cameraQuaternion",w),l("pointStart",A),l("pointEnd",I),l("rotationAxis",D),l("rotationAngle",P),l("eye",U),this._offset=new be,this._startNorm=new be,this._endNorm=new be,this._cameraScale=new be,this._parentPosition=new be,this._parentQuaternion=new vs,this._parentQuaternionInv=new vs,this._parentScale=new be,this._worldScaleStart=new be,this._worldQuaternionInv=new vs,this._worldScale=new be,this._positionStart=new be,this._quaternionStart=new vs,this._scaleStart=new be,this._getPointer=Jdt.bind(this),this._onPointerDown=tht.bind(this),this._onPointerHover=eht.bind(this),this._onPointerMove=nht.bind(this),this._onPointerUp=rht.bind(this),t!==null&&this.connect(t)}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&P6.setFromCamera(e,this.camera);const t=dY(this._gizmo.picker[this.mode],P6);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&P6.setFromCamera(e,this.camera);const t=dY(this._plane,P6,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,p_e.mode=this.mode,this.dispatchEvent(p_e)}}pointerMove(e){const t=this.axis,n=this.mode,r=this.object;let i=this.space;if(n==="scale"?i="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(i="world"),r===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&P6.setFromCamera(e,this.camera);const o=dY(this._plane,P6,!0);if(o){if(this.pointEnd.copy(o.point).sub(this.worldPositionStart),n==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),i==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),i==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),r.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(i==="local"&&(r.position.applyQuaternion(Uo.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.position.applyQuaternion(this._quaternionStart)),i==="world"&&(r.parent&&r.position.add(_c.setFromMatrixPosition(r.parent.matrixWorld)),t.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.parent&&r.position.sub(_c.setFromMatrixPosition(r.parent.matrixWorld)))),r.position.x=Math.max(this.minX,Math.min(this.maxX,r.position.x)),r.position.y=Math.max(this.minY,Math.min(this.maxY,r.position.y)),r.position.z=Math.max(this.minZ,Math.min(this.maxZ,r.position.z));else if(n==="scale"){if(t.search("XYZ")!==-1){let l=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(l*=-1),Uy.set(l,l,l)}else _c.copy(this.pointStart),Uy.copy(this.pointEnd),_c.applyQuaternion(this._worldQuaternionInv),Uy.applyQuaternion(this._worldQuaternionInv),Uy.divide(_c),t.search("X")===-1&&(Uy.x=1),t.search("Y")===-1&&(Uy.y=1),t.search("Z")===-1&&(Uy.z=1);r.scale.copy(this._scaleStart).multiply(Uy),this.scaleSnap&&(t.search("X")!==-1&&(r.scale.x=Math.round(r.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(r.scale.y=Math.round(r.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(r.scale.z=Math.round(r.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(n==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const l=20/this.worldPosition.distanceTo(_c.setFromMatrixPosition(this.camera.matrixWorld));let c=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(_c.copy(this.rotationAxis).cross(this.eye))*l):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(h_e[t]),_c.copy(h_e[t]),i==="local"&&_c.applyQuaternion(this.worldQuaternion),_c.cross(this.eye),_c.length()===0?c=!0:this.rotationAngle=this._offset.dot(_c.normalize())*l),(t==="E"||c)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),i==="local"&&t!=="E"&&t!=="XYZE"?(r.quaternion.copy(this._quaternionStart),r.quaternion.multiply(Uo.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),r.quaternion.copy(Uo.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),r.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(uY),this.dispatchEvent(m_e)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(f_e.mode=this.mode,this.dispatchEvent(f_e)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(uY),this.dispatchEvent(m_e),this.pointStart.copy(this.pointEnd))}getRaycaster(){return P6}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}setColors(e,t,n,r){const i=this._gizmo.materialLib;i.xAxis.color.set(e),i.yAxis.color.set(t),i.zAxis.color.set(n),i.active.color.set(r),i.xAxisTransparent.color.set(e),i.yAxisTransparent.color.set(t),i.zAxisTransparent.color.set(n),i.activeTransparent.color.set(r),i.xAxis._color&&i.xAxis._color.set(e),i.yAxis._color&&i.yAxis._color.set(t),i.zAxis._color&&i.zAxis._color.set(n),i.active._color&&i.active._color.set(r),i.xAxisTransparent._color&&i.xAxisTransparent._color.set(e),i.yAxisTransparent._color&&i.yAxisTransparent._color.set(t),i.zAxisTransparent._color&&i.zAxisTransparent._color.set(n),i.activeTransparent._color&&i.activeTransparent._color.set(r)}}function Jdt(s){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:s.button};{const e=this.domElement.getBoundingClientRect();return{x:(s.clientX-e.left)/e.width*2-1,y:-(s.clientY-e.top)/e.height*2+1,button:s.button}}}function eht(s){if(this.enabled)switch(s.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(s));break}}function tht(s){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(s.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(s)),this.pointerDown(this._getPointer(s)))}function nht(s){this.enabled&&this.pointerMove(this._getPointer(s))}function rht(s){this.enabled&&(this.domElement.releasePointerCapture(s.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(s)))}function dY(s,e,t){const n=e.intersectObject(s,!0);for(let r=0;r<n.length;r++)if(n[r].object.visible||t)return n[r];return!1}const FL=new Sa,no=new be(0,1,0),g_e=new be(0,0,0),y_e=new Pn,BL=new vs,sF=new vs,ag=new be,v_e=new Pn,LC=new be(1,0,0),O6=new be(0,1,0),FC=new be(0,0,1),UL=new be,bC=new be,_C=new be;class iht extends Bi{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){const t=this.controls;t.object!==void 0&&(t.object.updateMatrixWorld(),t.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):t.object.parent.matrixWorld.decompose(t._parentPosition,t._parentQuaternion,t._parentScale),t.object.matrixWorld.decompose(t.worldPosition,t.worldQuaternion,t._worldScale),t._parentQuaternionInv.copy(t._parentQuaternion).invert(),t._worldQuaternionInv.copy(t.worldQuaternion).invert()),t.camera.updateMatrixWorld(),t.camera.matrixWorld.decompose(t.cameraPosition,t.cameraQuaternion,t._cameraScale),t.camera.isOrthographicCamera?t.camera.getWorldDirection(t.eye).negate():t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(),super.updateMatrixWorld(e)}dispose(){this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}}class sht extends Bi{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new rl({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new Sh({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),n=e.clone();n.opacity=.15;const r=t.clone();r.opacity=.5;const i=e.clone();i.color.setHex(16711680);const o=e.clone();o.color.setHex(65280);const l=e.clone();l.color.setHex(255);const c=e.clone();c.color.setHex(16711680),c.opacity=.5;const h=e.clone();h.color.setHex(65280),h.opacity=.5;const m=e.clone();m.color.setHex(255),m.opacity=.5;const y=e.clone();y.opacity=.25;const b=e.clone();b.color.setHex(16776960),b.opacity=.25;const w=e.clone();w.color.setHex(16776960);const A=e.clone();A.color.setHex(7895160),this.materialLib={xAxis:i,yAxis:o,zAxis:l,active:w,xAxisTransparent:c,yAxisTransparent:h,zAxisTransparent:m,activeTransparent:b};const I=new k0(0,.04,.1,12);I.translate(0,.05,0);const D=new _a(.08,.08,.08);D.translate(0,.04,0);const P=new Ki;P.setAttribute("position",new Fr([0,0,0,1,0,0],3));const U=new k0(.0075,.0075,.5,3);U.translate(0,.25,0);function j(Ie,ce){const Ve=new L6(Ie,.0075,3,64,ce*Math.PI*2);return Ve.rotateY(Math.PI/2),Ve.rotateX(Math.PI/2),Ve}function C(){const Ie=new Ki;return Ie.setAttribute("position",new Fr([0,0,0,1,1,1],3)),Ie}const Z={X:[[new gn(I,i),[.5,0,0],[0,0,-Math.PI/2]],[new gn(I,i),[-.5,0,0],[0,0,Math.PI/2]],[new gn(U,i),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new gn(I,o),[0,.5,0]],[new gn(I,o),[0,-.5,0],[Math.PI,0,0]],[new gn(U,o)]],Z:[[new gn(I,l),[0,0,.5],[Math.PI/2,0,0]],[new gn(I,l),[0,0,-.5],[-Math.PI/2,0,0]],[new gn(U,l),null,[Math.PI/2,0,0]]],XYZ:[[new gn(new H6(.1,0),y),[0,0,0]]],XY:[[new gn(new _a(.15,.15,.01),m),[.15,.15,0]]],YZ:[[new gn(new _a(.15,.15,.01),c),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new gn(new _a(.15,.15,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]]},ie={X:[[new gn(new k0(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new gn(new k0(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new gn(new k0(.2,0,.6,4),n),[0,.3,0]],[new gn(new k0(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new gn(new k0(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new gn(new k0(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new gn(new H6(.2,0),n)]],XY:[[new gn(new _a(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new gn(new _a(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new gn(new _a(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]]},se={START:[[new gn(new H6(.01,2),r),null,null,null,"helper"]],END:[[new gn(new H6(.01,2),r),null,null,null,"helper"]],DELTA:[[new dd(C(),r),null,null,null,"helper"]],X:[[new dd(P,r),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new dd(P,r),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new dd(P,r),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},z={XYZE:[[new gn(j(.5,1),A),null,[0,Math.PI/2,0]]],X:[[new gn(j(.5,.5),i)]],Y:[[new gn(j(.5,.5),o),null,[0,0,-Math.PI/2]]],Z:[[new gn(j(.5,.5),l),null,[0,Math.PI/2,0]]],E:[[new gn(j(.75,1),b),null,[0,Math.PI/2,0]]]},re={AXIS:[[new dd(P,r),[-1e3,0,0],null,[1e6,1,1],"helper"]]},ye={XYZE:[[new gn(new Mg(.25,10,8),n)]],X:[[new gn(new L6(.5,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new gn(new L6(.5,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new gn(new L6(.5,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new gn(new L6(.75,.1,2,24),n)]]},H={X:[[new gn(D,i),[.5,0,0],[0,0,-Math.PI/2]],[new gn(U,i),[0,0,0],[0,0,-Math.PI/2]],[new gn(D,i),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new gn(D,o),[0,.5,0]],[new gn(U,o)],[new gn(D,o),[0,-.5,0],[0,0,Math.PI]]],Z:[[new gn(D,l),[0,0,.5],[Math.PI/2,0,0]],[new gn(U,l),[0,0,0],[Math.PI/2,0,0]],[new gn(D,l),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new gn(new _a(.15,.15,.01),m),[.15,.15,0]]],YZ:[[new gn(new _a(.15,.15,.01),c),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new gn(new _a(.15,.15,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new gn(new _a(.1,.1,.1),y)]]},Me={X:[[new gn(new k0(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new gn(new k0(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new gn(new k0(.2,0,.6,4),n),[0,.3,0]],[new gn(new k0(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new gn(new k0(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new gn(new k0(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new gn(new _a(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new gn(new _a(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new gn(new _a(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new gn(new _a(.2,.2,.2),n),[0,0,0]]]},Oe={X:[[new dd(P,r),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new dd(P,r),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new dd(P,r),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function Ue(Ie){const ce=new Bi;for(const Ve in Ie)for(let Pe=Ie[Ve].length;Pe--;){const We=Ie[Ve][Pe][0].clone(),pt=Ie[Ve][Pe][1],Ne=Ie[Ve][Pe][2],st=Ie[Ve][Pe][3],Pt=Ie[Ve][Pe][4];We.name=Ve,We.tag=Pt,pt&&We.position.set(pt[0],pt[1],pt[2]),Ne&&We.rotation.set(Ne[0],Ne[1],Ne[2]),st&&We.scale.set(st[0],st[1],st[2]),We.updateMatrix();const yn=We.geometry.clone();yn.applyMatrix4(We.matrix),We.geometry=yn,We.renderOrder=1/0,We.position.set(0,0,0),We.rotation.set(0,0,0),We.scale.set(1,1,1),ce.add(We)}return ce}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=Ue(Z)),this.add(this.gizmo.rotate=Ue(z)),this.add(this.gizmo.scale=Ue(H)),this.add(this.picker.translate=Ue(ie)),this.add(this.picker.rotate=Ue(ye)),this.add(this.picker.scale=Ue(Me)),this.add(this.helper.translate=Ue(se)),this.add(this.helper.rotate=Ue(re)),this.add(this.helper.scale=Ue(Oe)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const n=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:sF;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let r=[];r=r.concat(this.picker[this.mode].children),r=r.concat(this.gizmo[this.mode].children),r=r.concat(this.helper[this.mode].children);for(let i=0;i<r.length;i++){const o=r[i];o.visible=!0,o.rotation.set(0,0,0),o.position.copy(this.worldPosition);let l;if(this.camera.isOrthographicCamera?l=(this.camera.top-this.camera.bottom)/this.camera.zoom:l=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),o.scale.set(1,1,1).multiplyScalar(l*this.size/4),o.tag==="helper"){o.visible=!1,o.name==="AXIS"?(o.visible=!!this.axis,this.axis==="X"&&(Uo.setFromEuler(FL.set(0,0,0)),o.quaternion.copy(n).multiply(Uo),Math.abs(no.copy(LC).applyQuaternion(n).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Y"&&(Uo.setFromEuler(FL.set(0,0,Math.PI/2)),o.quaternion.copy(n).multiply(Uo),Math.abs(no.copy(O6).applyQuaternion(n).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Z"&&(Uo.setFromEuler(FL.set(0,Math.PI/2,0)),o.quaternion.copy(n).multiply(Uo),Math.abs(no.copy(FC).applyQuaternion(n).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="XYZE"&&(Uo.setFromEuler(FL.set(0,Math.PI/2,0)),no.copy(this.rotationAxis),o.quaternion.setFromRotationMatrix(y_e.lookAt(g_e,no,O6)),o.quaternion.multiply(Uo),o.visible=this.dragging),this.axis==="E"&&(o.visible=!1)):o.name==="START"?(o.position.copy(this.worldPositionStart),o.visible=this.dragging):o.name==="END"?(o.position.copy(this.worldPosition),o.visible=this.dragging):o.name==="DELTA"?(o.position.copy(this.worldPositionStart),o.quaternion.copy(this.worldQuaternionStart),_c.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),_c.applyQuaternion(this.worldQuaternionStart.clone().invert()),o.scale.copy(_c),o.visible=this.dragging):(o.quaternion.copy(n),this.dragging?o.position.copy(this.worldPositionStart):o.position.copy(this.worldPosition),this.axis&&(o.visible=this.axis.search(o.name)!==-1));continue}o.quaternion.copy(n),this.mode==="translate"||this.mode==="scale"?(o.name==="X"&&Math.abs(no.copy(LC).applyQuaternion(n).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Y"&&Math.abs(no.copy(O6).applyQuaternion(n).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Z"&&Math.abs(no.copy(FC).applyQuaternion(n).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XY"&&Math.abs(no.copy(FC).applyQuaternion(n).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="YZ"&&Math.abs(no.copy(LC).applyQuaternion(n).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XZ"&&Math.abs(no.copy(O6).applyQuaternion(n).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1)):this.mode==="rotate"&&(BL.copy(n),no.copy(this.eye).applyQuaternion(Uo.copy(n).invert()),o.name.search("E")!==-1&&o.quaternion.setFromRotationMatrix(y_e.lookAt(this.eye,g_e,O6)),o.name==="X"&&(Uo.setFromAxisAngle(LC,Math.atan2(-no.y,no.z)),Uo.multiplyQuaternions(BL,Uo),o.quaternion.copy(Uo)),o.name==="Y"&&(Uo.setFromAxisAngle(O6,Math.atan2(no.x,no.z)),Uo.multiplyQuaternions(BL,Uo),o.quaternion.copy(Uo)),o.name==="Z"&&(Uo.setFromAxisAngle(FC,Math.atan2(no.y,no.x)),Uo.multiplyQuaternions(BL,Uo),o.quaternion.copy(Uo))),o.visible=o.visible&&(o.name.indexOf("X")===-1||this.showX),o.visible=o.visible&&(o.name.indexOf("Y")===-1||this.showY),o.visible=o.visible&&(o.name.indexOf("Z")===-1||this.showZ),o.visible=o.visible&&(o.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),o.material._color=o.material._color||o.material.color.clone(),o.material._opacity=o.material._opacity||o.material.opacity,o.material.color.copy(o.material._color),o.material.opacity=o.material._opacity,this.enabled&&this.axis&&(o.name===this.axis?(o.material.color.copy(this.materialLib.active.color),o.material.opacity=1):this.axis.split("").some(function(c){return o.name===c})&&(o.material.color.copy(this.materialLib.active.color),o.material.opacity=1))}super.updateMatrixWorld(e)}}class oht extends gn{constructor(){super(new Ng(1e5,1e5,2,2),new rl({visible:!1,wireframe:!0,side:oa,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),UL.copy(LC).applyQuaternion(t==="local"?this.worldQuaternion:sF),bC.copy(O6).applyQuaternion(t==="local"?this.worldQuaternion:sF),_C.copy(FC).applyQuaternion(t==="local"?this.worldQuaternion:sF),no.copy(bC),this.mode){case"translate":case"scale":switch(this.axis){case"X":no.copy(this.eye).cross(UL),ag.copy(UL).cross(no);break;case"Y":no.copy(this.eye).cross(bC),ag.copy(bC).cross(no);break;case"Z":no.copy(this.eye).cross(_C),ag.copy(_C).cross(no);break;case"XY":ag.copy(_C);break;case"YZ":ag.copy(UL);break;case"XZ":no.copy(_C),ag.copy(bC);break;case"XYZ":case"E":ag.set(0,0,0);break}break;case"rotate":default:ag.set(0,0,0)}ag.length()===0?this.quaternion.copy(this.cameraQuaternion):(v_e.lookAt(_c.set(0,0,0),ag,no),this.quaternion.setFromRotationMatrix(v_e)),super.updateMatrixWorld(e)}}const tm=class tm extends _d{constructor(){super(...arguments);qe(this,"three");qe(this,"activeCamera");qe(this,"controls",new Map);qe(this,"visibility",new Map);qe(this,"setScene",()=>{this.clear()})}setApp(t){this.three=t,this.three.addEventListener(Ci.SET_SCENE,this.setScene)}clear(){for(const t of this.controls.values()){t.detach(),t.disconnect();const n=t.getHelper();Rp(n)}this.controls=new Map,this.visibility=new Map}add(t){let n=this.controls.get(t);if(n===void 0){const r=document.querySelector(".clickable");n=new Qdt(this.activeCamera,r),n.getHelper().name=t,n.setSize(.5),n.setSpace("local"),this.controls.set(t,n),this.visibility.set(t,!0),n.addEventListener("mouseDown",()=>{this.dispatchEvent({type:tm.DRAG_START})}),n.addEventListener("mouseUp",()=>{this.dispatchEvent({type:tm.DRAG_END})}),n.addEventListener("dragging-changed",i=>{var o;(o=nl.instance)==null||o.toggleOrbitControls(i.value)})}return n}get(t){return this.controls.get(t)}remove(t){const n=this.get(t);return n===void 0?!1:(n.detach(),n.disconnect(),Rp(n.getHelper()),this.controls.delete(t),!0)}enabled(t){this.controls.forEach(n=>{n.enabled=t})}updateCamera(t,n){this.activeCamera=t,this.controls.forEach(r=>{r.camera!==t&&(r.camera=t,t.getWorldPosition(r.cameraPosition),t.getWorldQuaternion(r.cameraQuaternion)),r.domElement!==n&&(r.disconnect(),r.domElement=n,r.connect(n))})}show(){this.controls.forEach(t=>{const n=t.getHelper(),r=this.visibility.get(n.name);r!==void 0&&(n.visible=r)})}hide(){this.controls.forEach(t=>{const n=t.getHelper();this.visibility.set(n.name,n.visible),n.visible=!1})}static get instance(){return tm._instance||(tm._instance=new tm),tm._instance}};qe(tm,"DRAG_START","Transform::dragStart"),qe(tm,"DRAG_END","Transform::dragEnd"),qe(tm,"_instance");let fh=tm;const aht=new _a,hY=new Ln;class pY extends Bi{constructor(t,n){const r=new Tn(c5(.5,1,Math.random()),c5(.5,1,Math.random()),c5(.5,1,Math.random()));super();qe(this,"curve",new w6e);qe(this,"line");qe(this,"draggable");qe(this,"curvePos");qe(this,"tension",.5);qe(this,"closed",!1);qe(this,"subdivide",50);qe(this,"curveType");qe(this,"offset",1);qe(this,"lineMaterial");qe(this,"_camera");qe(this,"_curvePercentage",0);qe(this,"_draggableScale",10);qe(this,"_transform");qe(this,"raycaster");qe(this,"draggedMat",new rl);qe(this,"parentGroup");qe(this,"group");qe(this,"dispose",()=>{this._transform&&(this._transform.removeEventListener("objectChange",this.updateSpline),fh.instance.remove(this.name)),this.disable(),this.parentGroup.removeGroup(this.name)});qe(this,"hideTransform",()=>{var t;(t=this._transform)==null||t.detach()});qe(this,"exportSpline",()=>{const t=[];this.draggable.children.forEach(n=>{t.push([om(n.position.x,3),om(n.position.y,3),om(n.position.z,3)])}),kXe({name:this.name,points:t,tension:this.tension,closed:this.closed,subdivide:this.subdivide,type:this.curveType}),console.log("Spline copied!")});qe(this,"showPoints",(t=!0)=>{this.draggable.visible=t});qe(this,"addPoints",(t=[])=>{if(t.length>0){const n=t.length-1;for(let r=0;r<n;r++)this.addPoint(t[r],!1);this.addPoint(t[n])}});qe(this,"addPoint",(t,n=!0)=>{var l;const r=this.draggable.children.length,i=new gn(aht,this.draggedMat);i.name=`point_${r}`,i.position.copy(t),i.scale.setScalar(this._draggableScale),this.draggable.add(i),(l=this._transform)==null||l.attach(i);const o=this.points.length>1;return o&&n&&this.updateSpline(),this.line.visible=o,this.updateCurrentPoint(),i});qe(this,"addNextPt",()=>{const t=this.draggable.children.length,n=t>1?this.draggable.children[t-1].position.clone():new be,r=this.addPoint(n);this.updateField(r.position)});qe(this,"removePoint",t=>{var n,r,i;if(((n=this._transform)==null?void 0:n.object)===t){(r=this._transform)==null||r.detach();const o=this.draggable.children[this.draggable.children.length-1];(i=this._transform)==null||i.attach(o),this.updateField(o.position)}Rp(t),this.updateSpline()});qe(this,"removePointAt",t=>{const n=this.draggable.children[t];this.removePoint(n)});qe(this,"removeSelectedPt",()=>{var t,n;((t=this._transform)==null?void 0:t.object)!==void 0&&this.removePoint((n=this._transform)==null?void 0:n.object)});qe(this,"updateSpline",()=>{this.points.length<2||(this.curve=new w6e(this.points,this.closed,this.curveType,this.tension),this.line.geometry.dispose(),this.line.geometry=new Ki().setFromPoints(this.curve.getPoints(this.subdivide)),this.curvePos.position.copy(this.getPointAt(this._curvePercentage)))});qe(this,"onMouseClick",t=>{var o,l;if(!nl.instance||!nl.instance.currentWindow||this._transform&&!this._transform.getHelper().visible)return;const r=nl.instance.currentWindow.current.getBoundingClientRect();hY.x=(t.clientX-r.x)/r.width*2-1,hY.y=-((t.clientY-r.y)/r.height)*2+1,this.raycaster.setFromCamera(hY,this.camera);const i=this.raycaster.intersectObjects(this.draggable.children,!1);if(i.length>0){const c=i[0].object;c!==((o=this._transform)==null?void 0:o.object)&&((l=this._transform)==null||l.attach(c),this.updateField(c.position))}});qe(this,"onUpdateTransform",()=>{this.updateCurrentPoint(),this.updateSpline()});qe(this,"debugPoint",t=>{t.name,t.visible=this.draggable.visible});this.name=t,this.lineMaterial=new Sh({color:r}),this.line=new dd(new Ki,this.lineMaterial),this.line.name="line",this.line.visible=!1,this.add(this.line),this._camera=n,this.curveType="catmullrom",this.draggedMat.color=r,this.draggable=new Bi,this.draggable.name="draggablePoints",this.add(this.draggable),this.curvePos=new gn(new Mg(1.5),new rl({color:r})),this.curvePos.name="curvePos",this.curvePos.scale.setScalar(this._draggableScale),this.curvePos.visible=!1,this.add(this.curvePos),this.raycaster=new AA,this.raycaster.params.Line.threshold=3,this.enable()}enable(){document.addEventListener("pointerdown",this.onMouseClick)}disable(){document.removeEventListener("pointerdown",this.onMouseClick)}updateLastPoint(t){const n=this.draggable.children.length;n>0&&(this.draggable.children[n-1].position.copy(t),this.updateSpline())}updateField(t){var n;(n=this.group.current)==null||n.setField("Current Point",t)}getPointAt(t){return this.curve.points.length>1?this.curve.getPointAt(t):this.curve.points.length===1?this.curve.points[0]:new be}getTangentAt(t){return this.curve.getTangentAt(t)}get points(){const t=[];return this.draggable.children.forEach(n=>{t.push(n.position)}),t}get total(){return this.draggable.children.length}get draggableScale(){return this._draggableScale}set draggableScale(t){this._draggableScale=t,this.draggable.children.forEach(n=>n.scale.setScalar(t)),this.curvePos.scale.setScalar(t)}get camera(){return this._camera}set camera(t){this._camera=t,this._transform!==void 0&&(this._transform.camera=t)}get curvePercentage(){return this._curvePercentage}set curvePercentage(t){this._curvePercentage=t,this.curvePos.position.copy(this.getPointAt(t))}updateCurrentPoint(){var t,n;if((t=this._transform)!=null&&t.object&&this.group){const r=(n=this._transform)==null?void 0:n.object;r.name.search("point")>-1&&this.updateField(r.position)}}initDebug(t,n){var o;const r=this.draggable.children;this.visible=n,this.parentGroup=t,this._transform=fh.instance.add(this.name),this._transform.camera=this._camera,this._transform.addEventListener("objectChange",this.onUpdateTransform),r.length>0&&this._transform.attach(r[r.length-1]),(o=nl.instance)==null||o.helpersContainer.add(this._transform.getHelper());const i=r.length>0?r[r.length-1].position:{x:0,y:0,z:0};this.group=t.addGroup({title:this.name,expanded:n,items:[{prop:"Closed",type:"boolean",value:this.closed},{prop:"Visible",type:"boolean",value:this.visible},{prop:"Show Position",type:"boolean",value:this.curvePos.visible},{prop:"Show Points",type:"boolean",value:this.draggable.visible},{prop:"Color",type:"color",value:`#${this.draggedMat.color.getHexString()}`},{prop:"Curve",type:"option",options:[{title:"Catmullrom",value:"catmullrom"},{title:"Centripetal",value:"centripetal"},{title:"Chordal",value:"chordal"}]},{prop:"Draggable Scale",type:"range",min:.01,max:100,step:.01,value:this._draggableScale},{prop:"Subdivide",type:"range",min:1,max:1e3,step:1,value:this.subdivide},{prop:"Tension",type:"range",min:0,max:1,step:.01,value:this.tension},{prop:"New Pt Offset",type:"range",min:0,max:10,value:this.offset},{prop:"Curve At",type:"range",min:0,max:1,step:.01,value:0},{prop:"Toggle Transform",type:"button"},{prop:"Add Point",type:"button"},{prop:"Remove Point",type:"button"},{prop:"Export",type:"button"},{prop:"Delete",type:"button"},{prop:"Current Point",type:"grid3",value:i}],onUpdate:(l,c)=>{var h,m;switch(l){case"Closed":this.closed=c,this.updateSpline();break;case"Visible":this.visible=c;break;case"Color":this.lineMaterial.color.setStyle(c),this.draggedMat.color.setStyle(c);break;case"Curve":this.curveType=c,this.updateSpline();break;case"Draggable Scale":this.draggableScale=c;break;case"Subdivide":this.subdivide=c,this.updateSpline();break;case"Tension":this.tension=c,this.updateSpline();break;case"New Pt Offset":this.offset=c;break;case"Curve At":this.curvePos.position.copy(this.getPointAt(c));break;case"Show Position":this.curvePos.visible=c;break;case"Show Points":this.draggable.visible=c;break;case"Toggle Transform":this._transform&&(this._transform.getHelper().visible=!this._transform.getHelper().visible);break;case"Add Point":this.addNextPt();break;case"Remove Point":this.removeSelectedPt();break;case"Export":this.exportSpline();break;case"Delete":this.parent.currentSpline=null,Rp(this);break;case"Current Point":if(this.group.current&&((h=this._transform)!=null&&h.object)){const y=(m=this._transform)==null?void 0:m.object;y.name.search("point")>-1&&(y.position.copy(c),this.updateSpline())}break}}}),this.draggable.children.forEach(l=>{this.debugPoint(l)})}}let zL=0;class lht extends Bi{constructor(t,n){super();qe(this,"defaultScale",10);qe(this,"currentSpline",null);qe(this,"_camera");qe(this,"group",null);qe(this,"three");qe(this,"splineDataText","");qe(this,"createSpline",(t=[])=>{const n=`Spline ${zL+1}`,r=new pY(n,this._camera);return r.addPoints(t),this.addSpline(r,!0),zL++,r});qe(this,"createSplineFromArray",t=>{const n=[];return t.forEach(r=>{n.push(new be(r[0],r[1],r[2]))}),this.createSpline(n)});qe(this,"createSplineFromCatmullRom",t=>this.createSpline(t.points));qe(this,"createSplineFromJSON",t=>{const n=[];t.points.forEach(i=>{n.push(new be(i[0],i[1],i[2]))});const r=new pY(t.name,this._camera);return r.closed=t.closed,r.subdivide=t.subdivide,r.tension=t.tension,r.type=t.type,r.addPoints(n),r.updateSpline(),this.addSpline(r,!1),r});qe(this,"showPoints",(t=!0)=>{this.children.forEach(n=>{n.showPoints(t)})});qe(this,"onAddSpline",t=>{const n=JSON.parse(t.value),r=n.name!==void 0?n.name:`Spline ${zL+1}`,i=new pY(r,this.camera);n.tension!==void 0&&(i.tension=n.tension),n.closed!==void 0&&(i.closed=n.closed),n.subdivide!==void 0&&(i.subdivide=n.subdivide),n.type!==void 0&&(i.curveType=n.type);const o=[];n.points.forEach(l=>{o.push(new be(l[0],l[1],l[2]))}),i.addPoints(o),this.addSpline(i,!1),zL++});qe(this,"isMouseDown",!1);qe(this,"onClickCanvas",t=>{var c;if(t.button!==0)return;if(this._camera.type!=="OrthographicCamera"){console.warn("Spline Editor - 3D Camera not supported in Draw Mode");return}const r=t.target.getBoundingClientRect(),i=(t.clientX-r.left)/r.width*2-1,o=-((t.clientY-r.top)/r.height)*2+1;if(nl.instance){const h=new AA;h.setFromCamera(new Ln(i,o),this._camera);const m=h.intersectObjects(nl.instance.helpersContainer.children,!0);for(let y=0;y<m.length;y++){const b=m[y];if(!(b.object.isLine||b.object.isTransformControlsPlane)&&b.object.isObject3D)return}}this.currentSpline===null&&(this.currentSpline=this.createSpline());const l=this.mouseToSplinePos(i,o,r.width,r.height);(c=this.currentSpline)==null||c.addPoint(l),this.isMouseDown=!0});qe(this,"onMouseMove",t=>{var c,h;if(!this.isMouseDown)return;const r=t.target.getBoundingClientRect(),i=(t.clientX-r.left)/r.width*2-1,o=-((t.clientY-r.top)/r.height)*2+1,l=this.mouseToSplinePos(i,o,r.width,r.height);(c=this.currentSpline)==null||c.updateLastPoint(l),(h=this.currentSpline)==null||h.updateField(l)});qe(this,"onMouseUp",()=>{this.isMouseDown=!1});this.name="Spline Editor",this._camera=t,this.three=n,this.three.addEventListener(Ci.ADD_SPLINE,this.onAddSpline)}initDebug(){this.group=u5.addEditorGroup({title:this.name,items:[{type:"field",prop:"Spline Data",value:"",disabled:!1},{type:"button",prop:"Import Spline"},{type:"button",prop:"New Spline"},{type:"boolean",prop:"Show Points",value:!0},{type:"boolean",prop:"Draw Mode",value:!1},{type:"boolean",prop:"Visible",value:this.visible},{type:"range",prop:"Default Scale",min:0,max:50,step:.01,value:this.defaultScale}],onUpdate:(t,n)=>{switch(t){case"New Spline":this.createSpline();break;case"Spline Data":this.splineDataText=n;break;case"Import Spline":this.createSplineFromJSON(JSON.parse(this.splineDataText));break;case"Show Points":this.showPoints(n);break;case"Visible":this.visible=n;break;case"Default Scale":this.defaultScale=n;break;case"Draw Mode":n?this.enableClickToDraw():this.disableClickToDraw();break}}})}dispose(){this.three.removeEventListener(Ci.ADD_SPLINE,this.onAddSpline),u5.removeEditorGroup(this.name)}addSpline(t,n){var r;t.draggableScale=this.defaultScale,t.hideTransform(),((r=this.group)==null?void 0:r.current)!==null&&t.initDebug(this.group.current,n),this.add(t),this.currentSpline=t}enableClickToDraw(){document.querySelectorAll(".clickable").forEach(t=>{t.addEventListener("mousedown",this.onClickCanvas),t.addEventListener("mousemove",this.onMouseMove),t.addEventListener("mouseup",this.onMouseUp)})}disableClickToDraw(){document.querySelectorAll(".clickable").forEach(t=>{t.removeEventListener("mousedown",this.onClickCanvas),t.removeEventListener("mousemove",this.onMouseMove),t.removeEventListener("mouseup",this.onMouseUp)})}mouseToSplinePos(t,n,r,i){const o=new be,l=Math.PI/2,c=this._camera,h=c.zoom,m=c.rotation.x===-6123233995736766e-32&&c.rotation.y===0&&c.rotation.z===0,y=c.rotation.x===-Math.PI&&c.rotation.y===12246467991473532e-32&&c.rotation.z===Math.PI,b=c.rotation.x===-6162975822039155e-48&&c.rotation.y===-l&&c.rotation.z===0,w=c.rotation.x===-6162975822039155e-48&&c.rotation.y===l&&c.rotation.z===0,A=c.rotation.x===-1.5707953264174506&&c.rotation.y===0&&c.rotation.z===0,I=c.rotation.x===1.5707953264174506&&c.rotation.y===0&&c.rotation.z===0;let D=t,P=n;y||w?D*=-1:A&&(P*=-1);const U=r/2/h,j=i/2/h;if(this.currentSpline===null&&(this.currentSpline=this.createSpline()),m||y){const C=D*U+c.position.x,Z=P*j+c.position.y;o.set(C,Z,0)}else if(b||w){const C=D*U+c.position.z,Z=P*j+c.position.y;o.set(0,Z,C)}else if(A||I){const C=D*U+c.position.x,Z=P*j+c.position.z;o.set(C,0,Z)}return o}get camera(){return this._camera}set camera(t){this._camera=t,this.children.forEach(n=>{const r=n;r.camera=t})}}const x_e=["Single","Side by Side","Stacked","Quad"],cht="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAC60lEQVRYhe2YT4hNcRTHP48xpmYaNAvRyEQxEhnKQljYsRm9/EmSyJiMFAsMZWNhJYoNIUVJ2VGiyb9ZzIpMpkQSahbGv9GMYWrM+1rc2zjvzvvdd+99rzdvMd+6de75nd+5387vnN/v/G5KEuWMKRNNIB8mCRaKiiL5qQb2ApuBuUAV0Ad0AJeB3sSeJRX6LJbULTf6JTUn9Z+KWMUpPyp/Avoa4CNQZ3Sj/lNpdL/xottR7AjOkHRUUpekN5I6JbVLavDH75lIfZN0UFKTpCWS0pJem/HeJBEMG6yV1ONYtgFJbZJ+GF1jDh+zJb03NuliEuwMkMo4yErS2RA/LcbuYVyCrm1mA7Dal/8Cu4FG4JD/HsTTkCy6a+SVMTPQuc1sBKb78nHghi+/A+YBxwL2lbhRY+ThuARdEVxu5JdGFvACr0otdoZ8Y4+Rn0Sn5sFFsMvI6YB9MzA1YJ8mN8k1wAHzfj4uQVdyrpI0aJL7oqTtkq4FiqPLyCOSbktqlbRL0jlJQ2b8QdwCUZ4qvhRStZL0XFK1pMd57CRvq5mfhKBriRfiFUMY6oD7eOdwPlQAN4G10dfWg+uouwXsiOssAj4AC+JMcEWwvnAuOTEr7gTXPmg34zagOwkbIIOXAo9CbDYBrcBXYN+4UUdy2sRflyS5zVNlfPX7ugpJW5V9nI7mmh+lYU0lCZ2B3TOnAVuAk0BTwC5nuhWro46KauBOQJch5OpRaoIW34GreGf+YZdRqS9NAj4Bp4ClQDvwOWxCqSM4ADQEdKE5XvbXzlITrAVe4TW+M6NMKDXBFLAMuAD0ACfIc7pMZBXXA2cY3/xmodQRHAL2A2+NLtj8ZiEKwUL/z2WMPAJcAVYALWSf8dZuDFGWeBHwKxm3sWYhiGG8Tfo6sA2vSfiSy4GrH3wGrDcfKSSKKf6v1E9yF0XK9Q1XBPuMXMw8HXTonQFwETwNzMFr64v1jzgFHIk9ybHEZYPJo65QlD3Bf2/Q/eaHPiSWAAAAAElFTkSuQmCC",uht="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAETklEQVRYhe2YXYhVVRTHf3d0/JhyUrMpFbImM+whSa3Mynww+4AeIgiKoozooQ+KyMyXIAujF6OXqHyI6iEKKYgIP/owsjSFqCkprdDUTEcjbWZ0HHV+Pex1ucfb9Z57Z9REXHA4Z++99l7/s/ZZ/7X2KaiczNLwfwPIk9MA+yunNMAG4DHgV+BvoB3YFff2TPstYEyfrajVroI6Sr1GvahsbJC63HzZq04pmztSvU5tVRuqYRiYg78JeBR4HPg5ntdmxovz9wJfA3uAxuibDLQCA+IqynnAQuBuYCnwMLC1rx48U12U8cZqdWqMDcx4cI16qTpYbVKHqa+ovWUeHKsujn7VL9ULq2HI+wY7gVeBJdGeFu3J4ZUiy/cAXeHRRuAQsC/GC0B3eG4BcH/0tUV7czUAeVsMsBF4Kha9HZgCvAncAuwPnXHA0wFuGLANuDrGuoGDwFxgTqzzQ7RX5FrP2eLsdb76vnogtme6+nE8H1YPlQXHwbi3q9eqn0e7Tb25VrsF68vFY0lb1AGcDTwItGQ8tQM4AIwGmqP/EPAu8A0wElgJfFGzxTo8mKWXu9Rd4ZF96jvqjSbauEC9Sn1O3R463epLaku99voCsFXdkAH3kNpcQW+IiT/bQne3eufxBtioPqP2mKhioXpWzpxb1T8C5Ifh4ZptVoriRmAIKdrI3Lujf3bobAPeJpF0NVkKrAFuI9HTOBIxnxFrF4OgQKKr/dnJlQA+AcwABgOHA4zAamA5cE7orQL+zAEHiWI+A2bFC7aSguheYCgpqAphZz3wSB7AecCICv2TgH8oFRib4gVqka0k0h8CXAxMBW6ooDejFoCvA9OBQUAvKWM0kDz4XUZvNKXtyZMWUl7vBbaQXq457PeEziDgx/KJlQAuIPFdMcEXv5OdYWBP9M8k8VpnDQCvB4aTSrCNJB5cSdrW3tBpIJVnR0qdUTxAfdGUOVTnmwqEanNmqltC/9OgqePKg5eom8PgdvW+oJ9Kupera0O3U50TL3lcAaI+oHaF4R3qa6Z822wq0Saq89T1lmSxOrxeW/Xm4uGkiqQDmECKuKHxHW0HdpMiewSpvGqKeR8Ay0iBsYIjg6261PE2o9Q3Yqv+MqWxO9R1Hl12qs+q49Vlppy82pSr+5xJKsko4AXgHlJ0t5NIeg3wLXAlqZhtIUV8J6nmWwX8QiLjdhL5TwMWkY4R6/rrwYKlMr1Y321QZ/vfwBijPqm+rF4Wc7PjE9QllurGVeoV5gRNHsAm9fnMom3qrKPoTjKdMXaYyrFygEWQ72XWW24qhPu8xcUc2UU6O8wFPjmK7jhgPHAuMJGUGQ6U6WwE5sfzTXGvei7KA9hFOiR9D/wOfFVFt4dS2tpfRe83Ur7/CPiJakfOGgBCypubatArl2r8VfOax/LfzABKtePAzHO/5FgC7KBEzB2kOrDfUm8mOeFySv9+OyFyGmB/5aQH+C9BVKmVCNuMZgAAAABJRU5ErkJggg==",dht="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAQ0lEQVQ4jWP8////fwYqAxYozUhFM/8zkaKYWIWkGEq0b0ZdSjQY5i79TyWagRGaTUdzFEEw6lLqGzqwLoVVJ1StpwA9sBwbUqAh5gAAAABJRU5ErkJggg==",jF=class jF extends On.Component{constructor(t){super(t);qe(this,"scene");qe(this,"renderer");qe(this,"currentScene");qe(this,"scenes",new Map);qe(this,"cameras",new Map);qe(this,"controls",new Map);qe(this,"currentCamera");qe(this,"currentWindow");qe(this,"helpersContainer",new j6);qe(this,"grid");qe(this,"cameraHelpers",new Map);qe(this,"lightHelpers",new Map);qe(this,"interactionHelper",new Pje(25));qe(this,"currentTransform");qe(this,"splineEditor");qe(this,"depthMaterial");qe(this,"normalsMaterial");qe(this,"uvMaterial");qe(this,"wireframeMaterial",new rl({opacity:.33,transparent:!0,wireframe:!0}));qe(this,"playing",!1);qe(this,"rafID",-1);qe(this,"cameraControlsRafID",-1);qe(this,"width",0);qe(this,"height",0);qe(this,"tlCam",null);qe(this,"trCam",null);qe(this,"blCam",null);qe(this,"brCam",null);qe(this,"tlRender","Renderer");qe(this,"trRender","Renderer");qe(this,"blRender","Renderer");qe(this,"brRender","Renderer");qe(this,"cameraVisibility",!0);qe(this,"lightVisibility",!0);qe(this,"gridVisibility",!0);qe(this,"rendererReady",!1);qe(this,"selectedItem");qe(this,"debugCamera");qe(this,"raycaster",new AA);qe(this,"pointer",new Ln);qe(this,"cameraControls");qe(this,"canvasRef");qe(this,"containerRef");qe(this,"tlWindow");qe(this,"trWindow");qe(this,"blWindow");qe(this,"brWindow");qe(this,"editorCameras",["Top","Bottom","Left","Right","Front","Back","Orthographic","UI","Debug"]);qe(this,"setupRenderer",t=>{const n=t.value;if(this.renderer){if(this.renderer instanceof VC&&n.type==="WebGLRenderer"||this.renderer instanceof hS&&n.type==="WebGPURenderer")return;this.renderer.dispose()}this.rendererReady=!1;const r=this.canvasRef.current;this.props.three.canvas=r,n.type==="WebGLRenderer"?(this.renderer=new VC({canvas:r,stencil:!1}),this.depthMaterial=new oSe,this.normalsMaterial=new lZ,this.uvMaterial=new Kdt,this.grid=new sat,this.scene.add(this.grid),this.rendererReady=!0):n.type==="WebGPURenderer"&&(this.renderer=new hS({canvas:r,stencil:!1}),this.grid=new Eat,this.scene.add(this.grid)),this.renderer&&(this.renderer.autoClear=!1,this.renderer.shadowMap.enabled=!0,this.renderer.setClearColor(0),this.renderer.setPixelRatio(devicePixelRatio),this.renderer.setScissorTest(!0),this.resize(),this.props.three.renderer=this.renderer,this.depthMaterial=new qdt,this.normalsMaterial=new OEe,this.uvMaterial=new Zdt,n.type==="WebGPURenderer"?this.renderer.init().then(()=>{this.rendererReady=!0,this.props.three.requestScene()}):this.props.three.requestScene())});qe(this,"onUpdate",()=>{this.playing&&(this.update(),this.draw(),this.rafID=requestAnimationFrame(this.onUpdate))});qe(this,"resize",()=>{var l;this.width=window.innerWidth-300,this.height=window.innerHeight,(l=this.renderer)==null||l.setSize(this.width,this.height);const t=Math.floor(this.width/2),n=Math.floor(this.height/2);this.props.three.resize(this.width,this.height),this.props.onSceneResize!==void 0&&this.currentScene!==void 0&&this.props.onSceneResize(this.currentScene,this.width,this.height);let r=this.width,i=this.height;switch(this.state.mode){case"Side by Side":r=t,i=this.height;break;case"Stacked":r=this.width,i=n;break;case"Quad":r=t,i=n;break}const o=r/i;this.cameras.forEach(c=>{var h;c instanceof J3?(c.left=r/-2,c.right=r/2,c.top=i/2,c.bottom=i/-2,c.name==="UI"&&(c.position.x=this.width/2,c.position.y=this.height/-2,c.position.z=100),c.updateProjectionMatrix()):c instanceof Va&&(c.aspect=o,c.updateProjectionMatrix()),(h=this.cameraHelpers.get(c.name))==null||h.update()})});qe(this,"addScene",t=>{const n=this.props.scenes.get(t.value.name);if(n!==void 0){const r=this.scenes.get(t.value.name);if(r!==void 0){this.props.onSceneAdd!==void 0&&this.props.onSceneAdd(r),this.props.three.scene=r;return}const i=new n;i.visible=!1,this.props.onSceneAdd!==void 0&&this.props.onSceneAdd(i),this.props.three.scene=i,this.scenes.set(t.value.name,i),this.scene.add(i)}else console.log("Hermes - Scene not found:",t.value.name,this.props.scenes)});qe(this,"sceneUpdate",t=>{this.currentScene!==void 0&&(this.currentScene.visible=!1,this.clearLightHelpers());const n=this.scene.getObjectByName(t.value.name);n!==void 0&&(this.currentScene=n,this.currentScene.visible=!0,this.addLightHelpers(this.currentScene))});qe(this,"removeScene",t=>{const n=t.value.name;this.scenes.delete(n);const r=this.scene.getObjectByName(n);r&&setTimeout(()=>{Rp(r)},100),this.clearLightHelpers()});qe(this,"addCamera",t=>{var o;const n=t.value,r=n.uuid,i=(o=this.props.three.scene)==null?void 0:o.getObjectByProperty("uuid",n.uuid);if(i!==void 0){const l=i;this.cameras.set(r,l);const c=new Nje(l);c.visible=this.cameraVisibility,this.cameraHelpers.set(r,c),this.helpersContainer.add(c),this.setState({lastUpdate:Date.now()})}});qe(this,"removeCamera",t=>{const r=t.value.uuid,i=this.cameraHelpers.get(r);i!==void 0&&(this.helpersContainer.remove(i),i.dispose()),this.cameras.delete(r),this.setState({lastUpdate:Date.now()})});qe(this,"onMouseMove",t=>{var y;const n=new Ln;(y=this.renderer)==null||y.getSize(n);const r=Math.min(t.clientX,n.x),i=Math.min(t.clientY,n.y);this.pointer.x=D6(r,0,n.x,-1,1),this.pointer.y=D6(i,0,n.y,1,-1);const o=n.x/2,l=n.y/2,c=()=>{r<o?this.pointer.x=D6(r,0,o,-1,1):this.pointer.x=D6(r,o,n.x,-1,1)},h=()=>{i<l?this.pointer.y=D6(i,0,l,1,-1):this.pointer.y=D6(i,l,n.y,1,-1)};switch(this.state.mode){case"Quad":c(),h();break;case"Side by Side":c();break;case"Stacked":h(),h();break}if(this.updateCamera(r,i,o,l),this.state.interactionMode==="Orbit"||this.currentScene===void 0)return;const m=this.raycaster.intersectObjects(this.currentScene.children);m.length>0&&this.interactionHelper.position.copy(m[0].point)});qe(this,"onClick",t=>{if(this.state.interactionMode==="Orbit"||this.currentScene===void 0)return;const n=new Ln;if(this.renderer.getSize(n),t.clientX>=n.x)return;this.onMouseMove(t);const r=this.raycaster.intersectObjects(this.currentScene.children);r.length>0&&(this.props.three.getObject(r[0].object.uuid),this.interactionHelper.visible=!1,this.setState({interactionMode:"Orbit",lastUpdate:Date.now()}))});qe(this,"onKey",t=>{if(this.selectedItem!==void 0){if(t.ctrlKey){if(this.currentCamera.name==="UI")return;const n=this.controls.get(this.currentCamera.name);t.key==="0"?(t.preventDefault(),this.clearControls(),this.cameraControls=new ug(this.currentCamera,this.currentWindow.current),this.selectedItem instanceof gn||this.selectedItem instanceof QK?(this.selectedItem.geometry.computeBoundingBox(),this.cameraControls.fitToBox(this.selectedItem.geometry.boundingBox,!0)):this.cameraControls.fitToSphere(this.selectedItem,!0),this.updateCameraControls(n,!0)):t.key==="1"?(t.preventDefault(),this.clearControls(),this.cameraControls=new ug(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,Math.PI*.5,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(n)):t.key==="2"?(t.preventDefault(),this.clearControls(),this.cameraControls=new ug(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,0,!0),this.cameraControls.moveTo(this.selectedItem.position.x,0,this.selectedItem.position.z,!0),this.updateCameraControls(n)):t.key==="3"?(t.preventDefault(),this.clearControls(),this.cameraControls=new ug(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI/2,Math.PI/2,!0),this.cameraControls.moveTo(0,this.selectedItem.position.y,this.selectedItem.position.z,!0),this.updateCameraControls(n)):t.key==="4"?(t.preventDefault(),this.clearControls(),this.cameraControls=new ug(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI,Math.PI/2,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(n)):t.key==="5"&&(t.preventDefault(),this.clearControls(),this.cameraControls=new ug(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(DF(45),DF(45),!0),this.updateCameraControls(n))}else if(this.currentTransform!==void 0)switch(t.key){case"r":this.currentTransform.setMode("rotate");break;case"s":this.currentTransform.setMode("scale");break;case"t":this.currentTransform.setMode("translate");break;case"q":this.currentTransform.setSpace(this.currentTransform.space==="local"?"world":"local");break}}});qe(this,"onSetSelectedItem",t=>{this.selectedItem!==void 0&&this.updateSelectedItemHelper(!1),this.selectedItem=void 0;const n=t.value.uuid;if(this.scenes.forEach(r=>{n.search(r.uuid)>-1&&(this.selectedItem=r.getObjectByProperty("uuid",n))}),this.selectedItem===void 0){console.log(`Hermes - Can't find selected item: ${t.value.uuid}, ${t.value.name}`);return}this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),fh.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=fh.instance.add(t.value.name),this.currentTransform&&(this.currentTransform.attach(this.selectedItem),this.helpersContainer.add(this.currentTransform.getHelper()),this.currentTransform.addEventListener("objectChange",this.onUpdateTransform)),this.updateSelectedItemHelper(!0)});qe(this,"onUpdateTransform",()=>{this.selectedItem!==void 0&&(this.props.three.updateObject(this.selectedItem.uuid,"position",this.selectedItem.position),this.props.three.updateObject(this.selectedItem.uuid,"rotation",{x:this.selectedItem.rotation.x,y:this.selectedItem.rotation.y,z:this.selectedItem.rotation.z}),this.props.three.updateObject(this.selectedItem.uuid,"scale",this.selectedItem.scale),FF.instance.update())});qe(this,"clearLightHelpers",()=>{this.lightHelpers.forEach(t=>{this.helpersContainer.remove(t),t.dispose()}),this.lightHelpers.clear()});qe(this,"addLightHelpers",t=>{t.traverse(n=>{if(n.type.search("Light")>-1){let r;switch(n.type){case"DirectionalLight":r=new Aje(n,100),r.name=`${n.name}Helper`,r.visible=this.lightVisibility,this.lightHelpers.set(n.name,r),this.helpersContainer.add(r);break;case"HemisphereLight":r=new Cje(n,250),r.name=`${n.name}Helper`,r.visible=this.lightVisibility,this.lightHelpers.set(n.name,r),this.helpersContainer.add(r);break;case"RectAreaLight":r=new lot(n),r.name=`${n.name}Helper`,r.visible=this.lightVisibility,this.lightHelpers.set(n.name,r),this.helpersContainer.add(r);break;case"PointLight":r=new bSe(n,100),r.name=`${n.name}Helper`,r.visible=this.lightVisibility,this.lightHelpers.set(n.name,r),this.helpersContainer.add(r);break;case"SpotLight":r=new Tje(n),r.name=`${n.name}Helper`,r.visible=this.lightVisibility,this.lightHelpers.set(n.name,r),this.helpersContainer.add(r);break}}})});qe(this,"updateCamera",(t,n,r,i)=>{switch(this.state.mode){case"Quad":n<i?t<r?this.currentCamera=this.tlCam:this.currentCamera=this.trCam:t<r?this.currentCamera=this.blCam:this.currentCamera=this.brCam;break;case"Side by Side":t<r?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break;case"Single":this.currentCamera=this.tlCam;break;case"Stacked":n<i?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break}this.splineEditor.camera=this.currentCamera,this.raycaster.setFromCamera(this.pointer,this.currentCamera),this.currentCamera===this.tlCam?this.currentWindow=this.tlWindow:this.currentCamera===this.trCam?this.currentWindow=this.trWindow:this.currentCamera===this.blCam?this.currentWindow=this.blWindow:this.currentCamera===this.brCam&&(this.currentWindow=this.brWindow),fh.instance.updateCamera(this.currentCamera,this.currentWindow.current)});qe(this,"updateCameraControls",(t,n=!1)=>{if(this.selectedItem===void 0)return;cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.cameraControls&&(this.cameraControls.smoothTime=.1);const r=.15,i=new wje;i.start(),this.selectedItem.getWorldPosition(t.target0);const o=()=>{const l=i.getDelta();this.cameraControls&&this.cameraControls.update(l),n&&(t.target.lerp(t.target0,r),t.object.position.lerp(t.position0,r),t.object.zoom=mK(t.object.zoom,t.zoom0,r),t.object.updateProjectionMatrix(),t.dispatchEvent({type:"change"})),i.getElapsedTime()>=.5?(cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.clearControls()):this.cameraControlsRafID=requestAnimationFrame(o)};o()});qe(this,"clearControls",()=>{this.cameraControls!==void 0&&(this.cameraControls.disconnect(),this.cameraControls.dispose(),this.cameraControls=void 0)});qe(this,"drawDouble",()=>{const t=this.getSceneOverride(this.tlRender),n=this.getSceneOverride(this.trRender),r=Math.floor(this.width/2),i=Math.floor(this.height/2),o=this.renderer instanceof hS;if(this.state.mode==="Side by Side")this.drawTo(0,0,r,this.height,this.tlCam,t),this.drawTo(r,0,r,this.height,this.trCam,n);else{const l=this.height-i;o?(this.drawTo(0,0,this.width,i,this.tlCam,t),this.drawTo(0,l,this.width,i,this.trCam,n)):(this.drawTo(0,l,this.width,i,this.tlCam,t),this.drawTo(0,0,this.width,i,this.trCam,n))}});qe(this,"drawQuad",()=>{const t=this.renderer instanceof hS,n=this.getSceneOverride(this.tlRender),r=this.getSceneOverride(this.trRender),i=this.getSceneOverride(this.blRender),o=this.getSceneOverride(this.brRender),l=Math.floor(this.width/2),c=Math.floor(this.height/2),h=this.height-c;let m=0,y=t?0:this.height-c;m=0,this.drawTo(m,y,l,c,this.tlCam,n),m=l,this.drawTo(m,y,l,c,this.trCam,r),y=t?h:0,m=0,this.scene.overrideMaterial=i,this.drawTo(m,y,l,c,this.blCam,i),m=l,this.drawTo(m,y,l,c,this.brCam,o)});this.props.three.addEventListener(Ci.ADD_RENDERER,this.setupRenderer),this.scene=new XA,this.scene.name=this.scene.uuid="",this.canvasRef=On.createRef(),this.containerRef=On.createRef(),this.tlWindow=On.createRef(),this.trWindow=On.createRef(),this.blWindow=On.createRef(),this.brWindow=On.createRef();const n=t.three.name,r=localStorage,i=r.getItem(`${n}_mode`);this.state={mode:i!==null?i:"Single",modeOpen:!1,renderModeOpen:!1,interactionMode:"Orbit",interactionModeOpen:!1,lastUpdate:Date.now()},r.setItem(`${n}_mode`,this.state.mode),r.setItem(`${n}_tlCam`,r.getItem(`${n}_tlCam`)!==null?r.getItem(`${n}_tlCam`):"Debug"),r.setItem(`${n}_trCam`,r.getItem(`${n}_trCam`)!==null?r.getItem(`${n}_trCam`):"Orthographic"),r.setItem(`${n}_blCam`,r.getItem(`${n}_blCam`)!==null?r.getItem(`${n}_blCam`):"Front"),r.setItem(`${n}_brCam`,r.getItem(`${n}_brCam`)!==null?r.getItem(`${n}_brCam`):"Top"),r.setItem(`${n}_tlRender`,r.getItem(`${n}_tlRender`)!==null?r.getItem(`${n}_tlRender`):"Renderer"),r.setItem(`${n}_trRender`,r.getItem(`${n}_trRender`)!==null?r.getItem(`${n}_trRender`):"Renderer"),r.setItem(`${n}_blRender`,r.getItem(`${n}_blRender`)!==null?r.getItem(`${n}_blRender`):"Renderer"),r.setItem(`${n}_brRender`,r.getItem(`${n}_brRender`)!==null?r.getItem(`${n}_brRender`):"Renderer");const o={Vector2:Ln,Vector3:be,Vector4:zr,Quaternion:vs,Matrix4:Pn,Spherical:LY,Box3:i9,Sphere:xm,Raycaster:AA};ug.install({THREE:o}),this.setupScene(),this.setupTools();const l=localStorage.getItem(this.expandedCameraVisibility);l!==null&&(this.cameraVisibility=l==="open"),this.saveExpandedCameraVisibility();const c=localStorage.getItem(this.expandedLightVisibility);c!==null&&(this.lightVisibility=c==="open"),this.saveExpandedLightVisibility();const h=localStorage.getItem(this.expandedGridVisibility);h!==null&&(this.gridVisibility=h==="open"),this.grid&&(this.grid.visible=this.gridVisibility),this.saveExpandedGridVisibility(),jF.instance=this}componentDidMount(){this.enable(),this.assignControls(),this.resize(),this.play(),fh.instance.setApp(this.props.three),fh.instance.activeCamera=this.debugCamera,this.props.three.requestRenderer()}componentDidUpdate(t,n,r){n.mode!==this.state.mode&&(this.assignControls(),this.resize())}componentWillUnmount(){this.disable(),this.clear(),u5.removeEditorGroup("View Settings")}render(){const t=[];return this.cameras.forEach((n,r)=>{t.push(r)}),ot.jsxs("div",{className:"multiview",children:[ot.jsx("canvas",{ref:this.canvasRef}),ot.jsxs("div",{className:`cameras ${this.state.mode==="Single"||this.state.mode==="Stacked"?"single":""}`,ref:this.containerRef,children:[this.state.mode==="Single"&&ot.jsx(ot.Fragment,{children:ot.jsx(E6,{name:"tl",camera:this.tlCam,options:t,ref:this.tlWindow,onSelectCamera:n=>{var i;(i=this.controls.get(this.tlCam.name))==null||i.dispose();const r=this.cameras.get(n);r!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=r,localStorage.setItem(`${this.appID}_tlCam`,r.name),this.createControls(r,this.tlWindow.current))},onSelectRenderMode:n=>{this.tlRender=n,localStorage.setItem(`${this.appID}_tlRender`,n)}})}),(this.state.mode==="Side by Side"||this.state.mode==="Stacked")&&ot.jsxs(ot.Fragment,{children:[ot.jsx(E6,{name:"tl",camera:this.tlCam,options:t,ref:this.tlWindow,onSelectCamera:n=>{var i;(i=this.controls.get(this.tlCam.name))==null||i.dispose();const r=this.cameras.get(n);r!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=r,localStorage.setItem(`${this.appID}_tlCam`,r.name),this.createControls(r,this.tlWindow.current))},onSelectRenderMode:n=>{this.tlRender=n,localStorage.setItem(`${this.appID}_tlRender`,n)}}),ot.jsx(E6,{name:"tr",camera:this.trCam,options:t,ref:this.trWindow,onSelectCamera:n=>{var i;(i=this.controls.get(this.trCam.name))==null||i.dispose();const r=this.cameras.get(n);r!==void 0&&(this.clearCamera(this.trCam),this.trCam=r,localStorage.setItem(`${this.appID}_trCam`,r.name),this.createControls(r,this.trWindow.current))},onSelectRenderMode:n=>{this.trRender=n,localStorage.setItem(`${this.appID}_trRender`,n)}})]}),this.state.mode==="Quad"&&ot.jsxs(ot.Fragment,{children:[ot.jsx(E6,{name:"tl",camera:this.tlCam,options:t,ref:this.tlWindow,onSelectCamera:n=>{var i;(i=this.controls.get(this.tlCam.name))==null||i.dispose();const r=this.cameras.get(n);r!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=r,localStorage.setItem(`${this.appID}_tlCam`,r.name),this.createControls(r,this.tlWindow.current))},onSelectRenderMode:n=>{this.tlRender=n,localStorage.setItem(`${this.appID}_tlRender`,n)}}),ot.jsx(E6,{name:"tr",camera:this.trCam,options:t,ref:this.trWindow,onSelectCamera:n=>{var i;(i=this.controls.get(this.trCam.name))==null||i.dispose();const r=this.cameras.get(n);r!==void 0&&(this.clearCamera(this.trCam),this.trCam=r,localStorage.setItem(`${this.appID}_trCam`,r.name),this.createControls(r,this.trWindow.current))},onSelectRenderMode:n=>{this.trRender=n,localStorage.setItem(`${this.appID}_trRender`,n)}}),ot.jsx(E6,{name:"bl",camera:this.blCam,options:t,ref:this.blWindow,onSelectCamera:n=>{var i;(i=this.controls.get(this.blCam.name))==null||i.dispose();const r=this.cameras.get(n);r!==void 0&&(this.clearCamera(this.blCam),this.blCam=r,localStorage.setItem(`${this.appID}_blCam`,r.name),this.createControls(r,this.blWindow.current))},onSelectRenderMode:n=>{this.blRender=n,localStorage.setItem(`${this.appID}_blRender`,n)}}),ot.jsx(E6,{name:"br",camera:this.brCam,options:t,ref:this.brWindow,onSelectCamera:n=>{var i;(i=this.controls.get(this.brCam.name))==null||i.dispose();const r=this.cameras.get(n);r!==void 0&&(this.clearCamera(this.brCam),this.brCam=r,localStorage.setItem(`${this.appID}_brCam`,r.name),this.createControls(r,this.brWindow.current))},onSelectRenderMode:n=>{this.brRender=n,localStorage.setItem(`${this.appID}_brRender`,n)}})]})]}),ot.jsxs("div",{className:"settings",children:[ot.jsx(OF,{title:"View",index:x_e.indexOf(this.state.mode),options:x_e,onSelect:n=>{n!==this.state.mode&&(this.killControls(),this.setState({mode:n}),localStorage.setItem(`${this.appID}_mode`,n))},open:this.state.modeOpen,onToggle:n=>{this.setState({modeOpen:n,renderModeOpen:!1,interactionModeOpen:!1})}}),ot.jsx(OF,{title:"Interact",index:this.state.interactionMode==="Orbit"?0:1,options:["Orbit Mode","Selection Mode"],onSelect:n=>{this.interactionHelper.visible=n==="Selection Mode",this.setState({interactionMode:this.interactionHelper.visible?"Selection":"Orbit"})},open:this.state.interactionModeOpen,onToggle:n=>{this.setState({modeOpen:!1,renderModeOpen:!1,interactionModeOpen:n})}}),ot.jsx(DX,{name:"cameraHelper",icon:cht,selected:this.cameraVisibility,height:24,top:2,onClick:n=>{if(this.cameraVisibility=n,this.saveExpandedCameraVisibility(),this.cameraHelpers.forEach(r=>{r.visible=n}),this.selectedItem!==void 0&&!n){const r=this.cameraHelpers.get(this.selectedItem.name);r!==void 0&&(r.visible=!0)}}}),ot.jsx(DX,{name:"lightHelper",icon:uht,selected:this.lightVisibility,height:24,top:4,onClick:n=>{if(this.lightVisibility=n,this.saveExpandedLightVisibility(),this.lightHelpers.forEach(r=>{r.visible=n}),this.selectedItem!==void 0&&!n&&this.selectedItem.isLight===!0){const r=this.lightHelpers.get(this.selectedItem.name);r!==void 0&&(r.visible=!0)}}}),ot.jsx(DX,{name:"gridHelper",icon:dht,selected:this.gridVisibility,height:21,width:21,onClick:n=>{this.setGridVisibility(n)}})]},this.state.lastUpdate)]})}setupScene(){this.helpersContainer.name="helpers",this.scene.add(this.helpersContainer),this.interactionHelper.name="interactionHelper",this.interactionHelper.visible=!1,this.helpersContainer.add(this.interactionHelper);const t=(o,l)=>{const c=new J3(-100,100,100,-100,0,3e3);return c.name=o,c.position.copy(l),c.lookAt(0,0,0),this.cameras.set(o,c),c},n=1e3;t("Top",new be(0,n,0)),t("Bottom",new be(0,-n,0)),t("Left",new be(-n,0,0)),t("Right",new be(n,0,0)),t("Front",new be(0,0,n)),t("Back",new be(0,0,-n)),t("Orthographic",new be(n,n,n)),t("UI",new be),this.debugCamera=new Va(60,1,.01,3e3),this.debugCamera.name="Debug",this.debugCamera.position.set(300,300,300),this.debugCamera.lookAt(0,0,0),this.cameras.set("Debug",this.debugCamera),this.currentCamera=this.debugCamera;const r=localStorage,i=this.props.three.name;this.tlCam=this.cameras.get(r.getItem(`${i}_tlCam`)),this.trCam=this.cameras.get(r.getItem(`${i}_trCam`)),this.blCam=this.cameras.get(r.getItem(`${i}_blCam`)),this.brCam=this.cameras.get(r.getItem(`${i}_brCam`)),this.tlCam===void 0&&(this.tlCam=this.cameras.get("Debug")),this.trCam===void 0&&(this.trCam=this.cameras.get("Orthographic")),this.blCam===void 0&&(this.blCam=this.cameras.get("Front")),this.brCam===void 0&&(this.brCam=this.cameras.get("Top")),u5.addEditorGroup({title:"Editor",items:[{type:"button",prop:"Hide All Transforms"},{type:"button",prop:"Resize"}],onUpdate:(o,l)=>{switch(o){case"Hide All Transforms":fh.instance.hide();break;case"Resize":this.resize();break}},subgroups:[{title:"Debug Camera",items:[{type:"range",prop:"Near",step:1e-4,min:.001,max:1e3,value:this.debugCamera.near},{type:"range",prop:"Far",step:.001,min:.001,max:1e4,value:this.debugCamera.far}],onUpdate:(o,l)=>{switch(o){case"Near":this.debugCamera.near=l,this.debugCamera.updateProjectionMatrix();break;case"Far":this.debugCamera.far=l,this.debugCamera.updateProjectionMatrix();break}}},{title:"Grid",items:[{type:"number",prop:"Position",value:0},{type:"color",prop:"Color",value:"#FFFFFF"},{type:"range",prop:"Grid Opacity",value:.25,min:0,max:1,step:.01},{type:"range",prop:"Subgrid Opacity",value:.15,min:0,max:1,step:.01}],onUpdate:(o,l)=>{switch(o){case"Position":this.grid&&(this.grid.position.y=l);break;case"Color":this.grid&&this.grid.color.setStyle(l);break;case"Grid Opacity":this.grid&&(this.grid.gridOpacity=l);break;case"Subgrid Opacity":this.grid&&(this.grid.subgridOpacity=l);break}}}]})}setupTools(){this.splineEditor=new lht(this.currentCamera,this.three),this.splineEditor.initDebug(),this.helpersContainer.add(this.splineEditor)}play(){this.playing=!0,this.onUpdate()}pause(){this.playing=!1,cancelAnimationFrame(this.rafID),this.rafID=-1}toggleOrbitControls(t){this.controls.forEach(n=>{n.enabled=!t})}clear(){this.three.dispatchEvent({type:Ci.CLEAR_OBJECT}),u5.removeAllGroups(),this.clearLightHelpers(),this.clearControls(),this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),fh.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=void 0,fh.instance.clear(),this.cameras.forEach(t=>{this.editorCameras.indexOf(t.name)<0&&this.three.dispatchEvent({type:Ci.REMOVE_CAMERA,value:t})}),this.currentCamera=this.debugCamera,this.currentScene=void 0,this.scenes.forEach(t=>{this.three.dispatchEvent({type:Ci.REMOVE_SCENE,value:t})}),this.scenes.clear()}setGridVisibility(t){this.gridVisibility=t,this.saveExpandedGridVisibility(),this.grid&&(this.grid.visible=t)}update(){var t;this.renderer&&this.rendererReady&&((t=this.renderer)==null||t.clear()),this.controls.forEach(n=>n.update()),this.cameraHelpers.forEach(n=>n.update()),this.lightHelpers.forEach(n=>{n.update!==void 0&&n.update()}),this.props.onSceneUpdate!==void 0&&this.currentScene!==void 0&&this.props.onSceneUpdate(this.currentScene)}draw(){var t;if(this.rendererReady)switch(this.renderer&&((t=this.renderer)==null||t.clear()),this.state.mode){case"Single":this.drawSingle();break;case"Side by Side":case"Stacked":this.drawDouble();break;case"Quad":this.drawQuad();break}}enable(){const t=this.containerRef.current;t.addEventListener("mousemove",this.onMouseMove),t.addEventListener("click",this.onClick),window.addEventListener("keydown",this.onKey),window.addEventListener("resize",this.resize),this.three.addEventListener(Ci.ADD_SCENE,this.addScene),this.three.addEventListener(Ci.SET_SCENE,this.sceneUpdate),this.three.addEventListener(Ci.REMOVE_SCENE,this.removeScene),this.three.addEventListener(Ci.ADD_CAMERA,this.addCamera),this.three.addEventListener(Ci.REMOVE_CAMERA,this.removeCamera),this.three.addEventListener(Ci.SET_OBJECT,this.onSetSelectedItem)}disable(){const t=this.containerRef.current;t.removeEventListener("mousemove",this.onMouseMove),t.removeEventListener("click",this.onClick),window.removeEventListener("keydown",this.onKey),window.removeEventListener("resize",this.resize),this.three.removeEventListener(Ci.ADD_SCENE,this.addScene),this.three.removeEventListener(Ci.SET_SCENE,this.sceneUpdate),this.three.removeEventListener(Ci.ADD_CAMERA,this.addCamera),this.three.removeEventListener(Ci.REMOVE_CAMERA,this.removeCamera),this.three.removeEventListener(Ci.SET_OBJECT,this.onSetSelectedItem)}updateSelectedItemHelper(t){if(this.selectedItem!==void 0)if(this.cameraVisibility){if(this.selectedItem.isLight===!0&&!this.lightVisibility){const n=this.lightHelpers.get(this.selectedItem.name);n!==void 0&&(n.visible=t)}}else{const n=this.cameraHelpers.get(this.selectedItem.name);n!==void 0&&(n.visible=t)}}createControls(t,n){const r=this.controls.get(t.name);if(r!==void 0&&r.dispose(),this.controls.delete(t.name),t.name==="UI")return;const i=new ECe(t,n);switch(i.enableDamping=!0,i.dampingFactor=.1,t.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":i.enableRotate=!1;break}this.controls.set(t.name,i)}clearCamera(t){const n=this.cameraHelpers.get(t.name);n!==void 0&&(this.helpersContainer.remove(n),n.dispose(),this.cameraHelpers.delete(t.name));const r=this.controls.get(t.name);r!==void 0&&(r.dispose(),this.controls.delete(t.name))}killControls(){this.controls.forEach((t,n)=>{t.dispose();const r=this.cameraHelpers.get(n);r!==void 0&&(this.helpersContainer.remove(r),r.dispose()),this.cameraHelpers.delete(n),this.controls.delete(n)}),this.controls.clear(),this.cameraHelpers.clear()}assignControls(){switch(this.state.mode){case"Single":this.createControls(this.tlCam,this.tlWindow.current);break;case"Side by Side":case"Stacked":this.createControls(this.tlCam,this.tlWindow.current),this.createControls(this.trCam,this.trWindow.current);break;case"Quad":this.createControls(this.tlCam,this.tlWindow.current),this.createControls(this.trCam,this.trWindow.current),this.createControls(this.blCam,this.blWindow.current),this.createControls(this.brCam,this.brWindow.current);break}}saveExpandedCameraVisibility(){localStorage.setItem(this.expandedCameraVisibility,this.cameraVisibility?"open":"closed")}saveExpandedLightVisibility(){localStorage.setItem(this.expandedLightVisibility,this.lightVisibility?"open":"closed")}saveExpandedGridVisibility(){localStorage.setItem(this.expandedGridVisibility,this.gridVisibility?"open":"closed")}getSceneOverride(t){switch(t){case"Depth":return this.depthMaterial;case"Normals":return this.normalsMaterial;case"Renderer":return null;case"UVs":return this.uvMaterial;case"Wireframe":return this.wireframeMaterial}return null}drawTo(t,n,r,i,o,l){var c,h,m;switch(o.name){case"Left":case"Right":this.grid&&(this.grid.rotation.z=Math.PI/2);break;case"Front":case"Back":this.grid&&(this.grid.rotation.x=Math.PI/2);break}this.scene.overrideMaterial=l,this.renderer&&((c=this.renderer)==null||c.setScissor(t,n,r,i),(h=this.renderer)==null||h.setViewport(t,n,r,i),(m=this.renderer)==null||m.render(this.scene,o)),this.grid&&this.grid.rotation.set(0,0,0)}drawSingle(){const t=this.getSceneOverride(this.tlRender);this.drawTo(0,0,this.width,this.height,this.tlCam,t)}get appID(){return this.props.three.name}get mode(){return this.state.mode}get three(){return this.props.three}get expandedCameraVisibility(){return`${this.appID}_multiviewCameraVisibility`}get expandedLightVisibility(){return`${this.appID}_multiviewLightVisibility`}get expandedGridVisibility(){return`${this.appID}_multiviewGridVisibility`}};qe(jF,"instance",null);let nl=jF;function aNe(s){if(s.child===void 0)return console.log("Hermes - No child attached"),null;const e=On.useRef(null),[t,n]=On.useState(!1),r=s.child.children.length>0,i=[];return s.child.children.length>0&&s.child.children.map((o,l)=>{i.push(ot.jsx(aNe,{child:o,three:s.three},l))}),On.useEffect(()=>{if(s.child){const o=s.child.uuid.split(".")[0],l=s.three.getScene(o);if(l!==null)try{const c=l.getObjectByProperty("uuid",s.child.uuid);c!==void 0?e.current.style.opacity=c.visible?"1":"0.25":console.log(`Hermes - Can't find child: ${s.child.uuid}`)}catch(c){console.log("Error looking for child:",c),console.log(s.child),console.log(s.three.scenes),console.log(l)}else console.log(`Hermes (ChildObject) - Can't find Scene: ${o} with child UUID: ${s.child.uuid}`,s.three.scenes,s.three.scene,l)}},[t]),ot.jsxs("div",{className:"childObject",children:[ot.jsxs("div",{className:"child",children:[r?ot.jsx("button",{className:"status",style:{backgroundPositionX:t?"-14px":"2px"},onClick:()=>{n(!t)}}):null,ot.jsx("button",{className:"name",style:{left:r?"20px":"5px"},onClick:()=>{s.child!==void 0?(s.three.getObject(s.child.uuid),!t&&r&&n(!0)):console.log("Hermes - No child attached...")},children:s.child.name.length>0?`${s.child.name} (${s.child.type})`:`${s.child.type}::${s.child.uuid}`}),ot.jsx("button",{className:"visibility",ref:e,onClick:()=>{if(s.child){const o=s.three.getScene(s.child.uuid);if(o!==null){const l=o.getObjectByProperty("uuid",s.child.uuid);if(l!==void 0){const c="visible",h=!l.visible;e.current.style.opacity=h?"1":"0.25",s.three.updateObject(s.child.uuid,c,h),za(l,c,h)}else console.log(`Hermes - Couldn't find object: ${s.child.uuid}`,o)}else console.log(`Hermes - Couldn't find object in scene: ${s.child.uuid}, ${s.child.name}`)}}}),ot.jsx("div",{className:`icon ${eot(s.child)}`})]}),ot.jsx("div",{className:t?"open":"",children:ot.jsx("div",{className:"container",children:i})})]},Math.random())}function fY(s){var t;const e=[];return(t=s.child)==null||t.children.map((n,r)=>{e.push(ot.jsx(aNe,{child:n,scene:s.scene,three:s.three},r))}),ot.jsx("div",{className:`scene ${s.class!==void 0?s.class:""}`,children:e})}function b_e(s){switch(s){case"fov":return"FOV";case"zoom":return"Zoom";case"near":return"Near";case"far":return"Far";case"focus":return"Focus";case"aspect":return"Aspect";case"filmGauge":return"Film Gauge";case"filmOffset":return"Film Offset";case"left":return"Left";case"right":return"Right";case"top":return"Top";case"bottom":return"Bottom"}return s}function hht(s,e){function t(){return`${e.name}_camera`}const n=localStorage.getItem(t()),r=n!==null?n==="open":!1;function i(l){localStorage.setItem(t(),l?"open":"closed")}const o=[];if(s.perspectiveCameraInfo!==void 0)for(const l in s.perspectiveCameraInfo)o.push({title:b_e(l),prop:l,type:"number",step:.01,value:s.perspectiveCameraInfo[l],onChange:(c,h)=>{e.updateObject(s.uuid,c,h),e.requestMethod(s.uuid,"updateProjectionMatrix");const m=e.getScene(s.uuid);if(m!==null){const y=m.getObjectByProperty("uuid",s.uuid);y!==void 0&&(za(y,c,h),y.updateProjectionMatrix())}}});else if(s.orthographicCameraInfo!==void 0)for(const l in s.orthographicCameraInfo)o.push({title:b_e(l),prop:l,type:"number",step:.01,value:s.orthographicCameraInfo[l],onChange:(c,h)=>{e.updateObject(s.uuid,c,h),e.requestMethod(s.uuid,"updateProjectionMatrix");const m=e.getScene(s.uuid);if(m!==null){const y=m.getObjectByProperty("uuid",s.uuid);y!==void 0&&(za(y,c,h),y.updateProjectionMatrix())}}});return ot.jsx(Ip,{three:e,title:"Camera",items:o,expanded:r,onToggle:l=>{i(l)}})}function __e(s){switch(s){case"color":return"Color";case"intensity":return"Intensity";case"decay":return"Decay";case"distance":return"Distance";case"angle":return"Angle";case"penumbra":return"Penumbra";case"groundColor":return"Ground Color";case"width":return"Width";case"height":return"Height"}return s}function pht(s,e){function t(){return`${e.name}_light`}const n=localStorage.getItem(t()),r=n!==null?n==="open":!1;function i(l){localStorage.setItem(t(),l?"open":"closed")}const o=[];if(s.lightInfo!==void 0)for(const l in s.lightInfo){const c=s.lightInfo[l];c!==void 0&&(c.isColor!==void 0?o.push({title:__e(l),prop:l,type:"color",value:c,onChange:(h,m)=>{const y=new Tn(m);e.updateObject(s.uuid,h,y);const b=e.getScene(s.uuid);if(b!==null){const w=b.getObjectByProperty("uuid",s.uuid);za(w,h,y)}}}):o.push({title:__e(l),prop:l,type:typeof c,value:c,step:typeof c=="number"?.01:void 0,onChange:(h,m)=>{e.updateObject(s.uuid,h,m);const y=e.getScene(s.uuid);if(y!==null){const b=y.getObjectByProperty("uuid",s.uuid);za(b,h,m)}}}))}return ot.jsx(Ip,{three:e,title:"Light",items:o,expanded:r,onToggle:l=>{i(l)}})}function fht(s){var b;const e=s.object,t=s.three;function n(){return`${t.name}_animation`}const r=localStorage.getItem(n()),i=r!==null?r==="open":!1;function o(w){localStorage.setItem(n(),w?"open":"closed")}const l=[],c=[];let h=0;e.animations.forEach(w=>{h=Math.max(h,w.duration),w.duration>0&&c.push({title:w.name,items:[{title:"Duration",type:"number",value:w.duration,disabled:!0},{title:"Blend Mode",type:"option",disabled:!0,options:[{title:"Normal",value:2500},{title:"Additive",value:2501}]}]})}),l.push({title:"Animations",items:c});let m;const y=t.getScene(e.uuid);if(y!==null){const w=y.getObjectByProperty("uuid",e.uuid);if(w!==void 0){const A=w.mixer;if(A!==void 0){const D=[{title:"Time Scale",type:"range",value:A.timeScale,step:.01,min:-1,max:2,onChange:(P,U)=>{A.timeScale=U,t.updateObject(e.uuid,"mixer.timeScale",U)}}];D.push({title:"Stop All",type:"button",onChange:()=>{A.stopAllAction(),t.requestMethod(e.uuid,"stopAllAction",void 0,"mixer")}}),l.push({title:"Mixer",items:D}),m=new Eje(w),(b=nl.instance)==null||b.scene.add(m)}}}return On.useEffect(()=>()=>{m!==void 0&&Rp(m)},[]),ot.jsx(Ip,{three:s.three,title:"Animation",items:l,expanded:i,onToggle:w=>{o(w)}})}const mY={name:"",uuid:"",type:"",visible:!1,matrix:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0,children:[]};function mht(s){const[e,t]=On.useState(mY);On.useEffect(()=>{function o(c){t(c.value)}function l(){t(mY)}return s.three.addEventListener(Ci.CLEAR_OBJECT,l),s.three.addEventListener(Ci.SET_SCENE,l),s.three.addEventListener(Ci.SET_OBJECT,o),()=>{s.three.removeEventListener(Ci.CLEAR_OBJECT,l),s.three.removeEventListener(Ci.SET_SCENE,l),s.three.removeEventListener(Ci.SET_OBJECT,o)}},[]);const n=e.type.toLowerCase(),r=e.animations.length>0||e.mixer!==void 0,i=n.search("mesh")>-1||n.search("line")>-1||n.search("points")>-1;return ot.jsx(QC,{three:s.three,label:"Inspector",button:e.uuid.length>0?ot.jsx("button",{className:"remove",onClick:()=>{fh.instance.remove(e.name),t(mY)}}):void 0,children:ot.jsx("div",{id:"Inspector",className:s.class,children:e.uuid.length>0&&ot.jsxs(ot.Fragment,{children:[ot.jsxs(ot.Fragment,{children:[ot.jsx(nF,{type:"string",title:"Name",prop:"name",value:e.name,disabled:!0}),ot.jsx(nF,{type:"string",title:"Type",prop:"type",value:e.type,disabled:!0}),ot.jsx(nF,{type:"string",title:"UUID",prop:"uuid",value:e.uuid,disabled:!0})]}),ot.jsxs(ot.Fragment,{children:[ot.jsx(FF,{object:e,three:s.three}),r?ot.jsx(fht,{object:e,three:s.three}):null,n.search("camera")>-1?hht(e,s.three):null,n.search("light")>-1?pht(e,s.three):null,i?Gat(e,s.three):null]})]})})},"Inspector")}class ght extends On.Component{constructor(t){super(t);qe(this,"autoClear",!0);qe(this,"autoClearColor",!0);qe(this,"autoClearDepth",!0);qe(this,"autoClearStencil",!0);qe(this,"outputColorSpace",Is);qe(this,"localClippingEnabled",!1);qe(this,"clearColor",new Tn(0));qe(this,"clearAlpha",1);qe(this,"toneMapping",Ta);qe(this,"toneMappingExposure",1);qe(this,"type","");qe(this,"onAddRenderer",t=>{const n=t.value;if(this.autoClear=n.autoClear,this.autoClearColor=n.autoClearColor,this.autoClearDepth=n.autoClearDepth,this.autoClearStencil=n.autoClearStencil,this.outputColorSpace=n.outputColorSpace,this.localClippingEnabled=n.localClippingEnabled,this.clearAlpha=n.clearAlpha,this.type=n.type,this.toneMapping=n.toneMapping,this.toneMappingExposure=n.toneMappingExposure,this.clearColor.setStyle(n.clearColor,vd),Zn.enabled=n.colorManagement,nl.instance){const r=nl.instance.renderer;r&&(r.autoClearColor=this.autoClearColor,r.outputColorSpace=this.outputColorSpace,r instanceof VC&&(r.localClippingEnabled=this.localClippingEnabled),r.toneMapping=this.toneMapping,r.toneMappingExposure=this.toneMappingExposure,r.setClearColor(n.clearColor,this.clearAlpha))}this.setState({lastUpdated:Date.now()})});const n=localStorage.getItem(this.expandedName),r=n!==null?n==="open":!1;if(this.state={expanded:r,lastUpdated:Date.now()},this.saveExpanded(r),nl.instance){const i=nl.instance.renderer;i&&(this.autoClear=i.autoClear,this.autoClearColor=i.autoClearColor,this.autoClearDepth=i.autoClearDepth,this.autoClearStencil=i.autoClearStencil,this.clearAlpha=i.getClearAlpha(),this.toneMapping=i.toneMapping,this.toneMappingExposure=i.toneMappingExposure,i instanceof VC&&(this.localClippingEnabled=i.localClippingEnabled,i.getClearColor(this.clearColor)))}this.props.three.addEventListener(Ci.ADD_RENDERER,this.onAddRenderer)}componentwillunmount(){this.props.three.removeEventListener(Ci.ADD_RENDERER,this.onAddRenderer)}render(){const t=()=>{if(nl.instance){const n=nl.instance.renderer;n&&(n.autoClearColor=this.autoClearColor,n.outputColorSpace=this.outputColorSpace,n instanceof VC&&(n.localClippingEnabled=this.localClippingEnabled),n.toneMapping=this.toneMapping,n.toneMappingExposure=this.toneMappingExposure,n.setClearColor(this.clearColor.getStyle(),this.clearAlpha),this.props.three.updateRenderer({autoClear:this.autoClear,autoClearColor:this.autoClearColor,autoClearDepth:this.autoClearDepth,autoClearStencil:this.autoClearStencil,outputColorSpace:this.outputColorSpace,localClippingEnabled:this.localClippingEnabled,clearAlpha:this.clearAlpha,clearColor:this.clearColor.getStyle(),colorManagement:Zn.enabled,toneMapping:this.toneMapping,toneMappingExposure:this.toneMappingExposure}))}};return ot.jsx(Ip,{three:this.props.three,title:"Renderer",expanded:this.state.expanded,items:[{type:"boolean",title:"Auto Clear",value:this.autoClear,onChange:(n,r)=>{this.autoClear=r}},{type:"boolean",title:"Auto Clear Color",value:this.autoClearColor,onChange:(n,r)=>{this.autoClearColor=r,t()}},{type:"boolean",title:"Auto Clear Depth",value:this.autoClearDepth,onChange:(n,r)=>{this.autoClearDepth=r,t()}},{type:"boolean",title:"Auto Clear Stencil",value:this.autoClearStencil,onChange:(n,r)=>{this.autoClearStencil=r,t()}},{type:"boolean",title:"Local Clipping",value:this.localClippingEnabled,onChange:(n,r)=>{this.localClippingEnabled=r,t()}},{type:"color",title:"Clear Color",value:`#${this.clearColor.getHexString()}`,onChange:(n,r)=>{this.clearColor.setStyle(r),t()}},{type:"range",title:"Clear Alpha",min:0,max:1,step:.01,value:this.clearAlpha,onChange:(n,r)=>{this.clearAlpha=r,t()}},{type:"boolean",title:"Color Management",value:Zn.enabled,onChange:(n,r)=>{Zn.enabled=r,t()}},{type:"option",title:"Color Space",value:this.outputColorSpace,options:[{title:"No Color Space",value:gu},{title:"SRB Color Space",value:Is},{title:"Linear SRB Color Space",value:vd}],onChange:(n,r)=>{this.outputColorSpace=r,t()}},{type:"option",title:"Tone Mapping",value:this.toneMapping,options:[{title:"None ",value:Ta},{title:"Linear ",value:qF},{title:"Reinhard",value:XF},{title:"Cineon ",value:YF},{title:"ACES Filmic",value:KF},{title:"AgX",value:ZF},{title:"Neutral",value:QF},{title:"Custom",value:FK}],onChange:(n,r)=>{this.toneMapping=r,t()}},{type:"range",title:"Tone Mapping Exposure",value:this.toneMappingExposure,min:0,max:2,step:.01,onChange:(n,r)=>{this.toneMappingExposure=r,t()}},{type:"string",title:"Type",value:this.type,disabled:!0},{type:"button",title:"Resize Scenes from Source",onChange:()=>{this.props.three.requestSize()}}],onToggle:n=>{this.setState({expanded:n}),this.saveExpanded(n)}},Math.random())}saveExpanded(t){localStorage.setItem(this.expandedName,t?"open":"closed")}get expandedName(){return`${this.props.three.name}_renderer`}}function yht(s){const[e]=On.useState([]),[t]=On.useState([]),[n,r]=On.useState(0),i=h=>{const m=h.value;for(let y=0;y<e.length;y++)if(m.uuid===e[y].uuid)return;e.push(m),t.push(ot.jsx(QC,{three:s.three,label:`Scene: ${m.name}`,scene:m,open:!1,visible:!1,onRefresh:()=>{s.three.refreshScene(m.name)},children:ot.jsx(fY,{child:m,scene:m,three:s.three})},m.name)),r(Date.now())},o=h=>{const m=h.value;for(let y=0;y<e.length;y++)if(m.uuid===e[y].uuid){e[y]=m,t[y]=ot.jsx(QC,{three:s.three,label:`Scene: ${m.name}`,scene:m,open:t[y].props.open,visible:t[y].props.visible,onRefresh:()=>{s.three.refreshScene(m.name)},children:ot.jsx(fY,{child:m,scene:m,three:s.three})},m.name),r(Date.now());return}},l=h=>{const m=h.value;for(let y=0;y<e.length;y++)if(m.uuid===e[y].uuid){e.splice(y,1),t.splice(y,1),r(Date.now());return}},c=h=>{const m=h.value.name;for(let y=0;y<e.length;y++){const b=e[y],w=b.name===m;t[y]=ot.jsx(QC,{three:s.three,label:`Scene: ${b.name}`,scene:b,open:w,visible:w,onRefresh:()=>{s.three.refreshScene(b.name)},children:ot.jsx(fY,{child:b,scene:b,three:s.three})},b.name)}r(Date.now())};return On.useEffect(()=>(s.three.addEventListener(Ci.ADD_SCENE,i),s.three.addEventListener(Ci.SET_SCENE,c),s.three.addEventListener(Ci.REFRESH_SCENE,o),s.three.addEventListener(Ci.REMOVE_SCENE,l),()=>{s.three.removeEventListener(Ci.ADD_SCENE,i),s.three.removeEventListener(Ci.SET_SCENE,c),s.three.removeEventListener(Ci.REFRESH_SCENE,o),s.three.removeEventListener(Ci.REMOVE_SCENE,l)}),[]),ot.jsxs("div",{id:"SidePanel",children:[ot.jsx("div",{className:"scenes",children:t},n),ot.jsx(mht,{three:s.three}),ot.jsx(ght,{three:s.three}),ot.jsx(u5,{three:s.three})]})}function vht(s){return ot.jsx(aot,{children:ot.jsxs(ot.Fragment,{children:[ot.jsx(nl,{three:s.three,scenes:s.scenes,onSceneAdd:s.onSceneAdd,onSceneResize:s.onSceneResize,onSceneUpdate:s.onSceneUpdate}),ot.jsx(yht,{three:s.three})]})})}async function xht(){var n;for(;!document.getElementById("theatrejs-studio-root");)await new Promise(r=>setTimeout(r,100));const s=document.getElementById("theatrejs-studio-root");if(s===null||s.shadowRoot===null)return;const e=s.shadowRoot.getElementById("pointer-root");if(e===null)return;const t=e.children[0];if(t!==null){try{const i=t.children[1].children[1];(n=i.parentElement)==null||n.removeChild(i)}catch{}try{const r=t.children[3];r.style.top="0",r.style.right="300px"}catch{}}}const bht=`varying vec2 vUv;
|
|
8758
8758
|
|
|
8759
8759
|
void main() {
|
|
8760
8760
|
vUv = uv;
|
package/dist/index.html
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.png">
|
|
9
9
|
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.png">
|
|
10
10
|
<link rel="manifest" href="/images/site.webmanifest">
|
|
11
|
-
<script type="module" crossorigin src="/index-
|
|
11
|
+
<script type="module" crossorigin src="/index-hdXsyID5.js"></script>
|
|
12
12
|
<link rel="stylesheet" crossorigin href="/index-D82t4hmO.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"module": "./dist/hermes.esm.js",
|
|
8
8
|
"types": "./types/index.d.ts",
|
|
9
9
|
"type": "module",
|
|
10
|
-
"version": "0.1.
|
|
10
|
+
"version": "0.1.31",
|
|
11
11
|
"homepage": "https://github.com/tomorrowevening/hermes#readme",
|
|
12
12
|
"bugs": {
|
|
13
13
|
"url": "https://github.com/tomorrowevening/hermes/issues"
|