@tomorrowevening/hermes 0.1.14 → 0.1.15
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 +1 -1
- package/dist/hermes.es.js +1 -1
- package/package.json +1 -1
package/dist/hermes.cjs.js
CHANGED
|
@@ -597,4 +597,4 @@ void main() {
|
|
|
597
597
|
void main() {
|
|
598
598
|
#include <clipping_planes_fragment>
|
|
599
599
|
gl_FragColor = vec4(vec3(vUv, 0.0), 1.0);
|
|
600
|
-
}`;class Zy extends y.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:ON,fragmentShader:BN})}}const Qi=new y.Raycaster,_t=new y.Vector3,bi=new y.Vector3,He=new y.Quaternion,qf={X:new y.Vector3(1,0,0),Y:new y.Vector3(0,1,0),Z:new y.Vector3(0,0,1)},ah={type:"change"},Yf={type:"mouseDown",mode:null},Xf={type:"mouseUp",mode:null},Zf={type:"objectChange"};class IN extends y.Controls{constructor(e,t=null){super(void 0,t);const s=new VN(this);this._root=s;const i=new HN;this._gizmo=i,s.add(i);const n=new WN;this._plane=n,s.add(n);const r=this;function a(b,T){let S=T;Object.defineProperty(r,b,{get:function(){return S!==void 0?S:T},set:function(C){S!==C&&(S=C,n[b]=C,i[b]=C,r.dispatchEvent({type:b+"-changed",value:C}),r.dispatchEvent(ah))}}),r[b]=T,n[b]=T,i[b]=T}a("camera",e),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0),a("minX",-1/0),a("maxX",1/0),a("minY",-1/0),a("maxY",1/0),a("minZ",-1/0),a("maxZ",1/0);const l=new y.Vector3,c=new y.Vector3,h=new y.Quaternion,u=new y.Quaternion,d=new y.Vector3,p=new y.Quaternion,f=new y.Vector3,m=new y.Vector3,x=new y.Vector3,g=0,_=new y.Vector3;a("worldPosition",l),a("worldPositionStart",c),a("worldQuaternion",h),a("worldQuaternionStart",u),a("cameraPosition",d),a("cameraQuaternion",p),a("pointStart",f),a("pointEnd",m),a("rotationAxis",x),a("rotationAngle",g),a("eye",_),this._offset=new y.Vector3,this._startNorm=new y.Vector3,this._endNorm=new y.Vector3,this._cameraScale=new y.Vector3,this._parentPosition=new y.Vector3,this._parentQuaternion=new y.Quaternion,this._parentQuaternionInv=new y.Quaternion,this._parentScale=new y.Vector3,this._worldScaleStart=new y.Vector3,this._worldQuaternionInv=new y.Quaternion,this._worldScale=new y.Vector3,this._positionStart=new y.Vector3,this._quaternionStart=new y.Quaternion,this._scaleStart=new y.Vector3,this._getPointer=LN.bind(this),this._onPointerDown=kN.bind(this),this._onPointerHover=UN.bind(this),this._onPointerMove=zN.bind(this),this._onPointerUp=GN.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&&Qi.setFromCamera(e,this.camera);const t=lh(this._gizmo.picker[this.mode],Qi);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&&Qi.setFromCamera(e,this.camera);const t=lh(this._plane,Qi,!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,Yf.mode=this.mode,this.dispatchEvent(Yf)}}pointerMove(e){const t=this.axis,s=this.mode,i=this.object;let n=this.space;if(s==="scale"?n="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(n="world"),i===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&Qi.setFromCamera(e,this.camera);const r=lh(this._plane,Qi,!0);if(r){if(this.pointEnd.copy(r.point).sub(this.worldPositionStart),s==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),n==="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),n==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),i.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(n==="local"&&(i.position.applyQuaternion(He.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this._quaternionStart)),n==="world"&&(i.parent&&i.position.add(_t.setFromMatrixPosition(i.parent.matrixWorld)),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(_t.setFromMatrixPosition(i.parent.matrixWorld)))),i.position.x=Math.max(this.minX,Math.min(this.maxX,i.position.x)),i.position.y=Math.max(this.minY,Math.min(this.maxY,i.position.y)),i.position.z=Math.max(this.minZ,Math.min(this.maxZ,i.position.z));else if(s==="scale"){if(t.search("XYZ")!==-1){let a=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(a*=-1),bi.set(a,a,a)}else _t.copy(this.pointStart),bi.copy(this.pointEnd),_t.applyQuaternion(this._worldQuaternionInv),bi.applyQuaternion(this._worldQuaternionInv),bi.divide(_t),t.search("X")===-1&&(bi.x=1),t.search("Y")===-1&&(bi.y=1),t.search("Z")===-1&&(bi.z=1);i.scale.copy(this._scaleStart).multiply(bi),this.scaleSnap&&(t.search("X")!==-1&&(i.scale.x=Math.round(i.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(i.scale.y=Math.round(i.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(i.scale.z=Math.round(i.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(s==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const a=20/this.worldPosition.distanceTo(_t.setFromMatrixPosition(this.camera.matrixWorld));let l=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(_t.copy(this.rotationAxis).cross(this.eye))*a):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(qf[t]),_t.copy(qf[t]),n==="local"&&_t.applyQuaternion(this.worldQuaternion),_t.cross(this.eye),_t.length()===0?l=!0:this.rotationAngle=this._offset.dot(_t.normalize())*a),(t==="E"||l)&&(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),n==="local"&&t!=="E"&&t!=="XYZE"?(i.quaternion.copy(this._quaternionStart),i.quaternion.multiply(He.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),i.quaternion.copy(He.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(ah),this.dispatchEvent(Zf)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(Xf.mode=this.mode,this.dispatchEvent(Xf)),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(ah),this.dispatchEvent(Zf),this.pointStart.copy(this.pointEnd))}getRaycaster(){return Qi}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}}function LN(o){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:o.button};{const e=this.domElement.getBoundingClientRect();return{x:(o.clientX-e.left)/e.width*2-1,y:-(o.clientY-e.top)/e.height*2+1,button:o.button}}}function UN(o){if(this.enabled)switch(o.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(o));break}}function kN(o){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(o.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(o)),this.pointerDown(this._getPointer(o)))}function zN(o){this.enabled&&this.pointerMove(this._getPointer(o))}function GN(o){this.enabled&&(this.domElement.releasePointerCapture(o.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(o)))}function lh(o,e,t){const s=e.intersectObject(o,!0);for(let i=0;i<s.length;i++)if(s[i].object.visible||t)return s[i];return!1}const wa=new y.Euler,Oe=new y.Vector3(0,1,0),Kf=new y.Vector3(0,0,0),Qf=new y.Matrix4,Ma=new y.Quaternion,za=new y.Quaternion,Ns=new y.Vector3,Jf=new y.Matrix4,ro=new y.Vector3(1,0,0),nn=new y.Vector3(0,1,0),oo=new y.Vector3(0,0,1),Ca=new y.Vector3,Zr=new y.Vector3,Kr=new y.Vector3;class VN extends y.Object3D{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 HN extends y.Object3D{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new y.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new y.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),s=e.clone();s.opacity=.15;const i=t.clone();i.opacity=.5;const n=e.clone();n.color.setHex(16711680);const r=e.clone();r.color.setHex(65280);const a=e.clone();a.color.setHex(255);const l=e.clone();l.color.setHex(16711680),l.opacity=.5;const c=e.clone();c.color.setHex(65280),c.opacity=.5;const h=e.clone();h.color.setHex(255),h.opacity=.5;const u=e.clone();u.opacity=.25;const d=e.clone();d.color.setHex(16776960),d.opacity=.25,e.clone().color.setHex(16776960);const f=e.clone();f.color.setHex(7895160);const m=new y.CylinderGeometry(0,.04,.1,12);m.translate(0,.05,0);const x=new y.BoxGeometry(.08,.08,.08);x.translate(0,.04,0);const g=new y.BufferGeometry;g.setAttribute("position",new y.Float32BufferAttribute([0,0,0,1,0,0],3));const _=new y.CylinderGeometry(.0075,.0075,.5,3);_.translate(0,.25,0);function b(Z,Me){const de=new y.TorusGeometry(Z,.0075,3,64,Me*Math.PI*2);return de.rotateY(Math.PI/2),de.rotateX(Math.PI/2),de}function T(){const Z=new y.BufferGeometry;return Z.setAttribute("position",new y.Float32BufferAttribute([0,0,0,1,1,1],3)),Z}const S={X:[[new y.Mesh(m,n),[.5,0,0],[0,0,-Math.PI/2]],[new y.Mesh(m,n),[-.5,0,0],[0,0,Math.PI/2]],[new y.Mesh(_,n),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new y.Mesh(m,r),[0,.5,0]],[new y.Mesh(m,r),[0,-.5,0],[Math.PI,0,0]],[new y.Mesh(_,r)]],Z:[[new y.Mesh(m,a),[0,0,.5],[Math.PI/2,0,0]],[new y.Mesh(m,a),[0,0,-.5],[-Math.PI/2,0,0]],[new y.Mesh(_,a),null,[Math.PI/2,0,0]]],XYZ:[[new y.Mesh(new y.OctahedronGeometry(.1,0),u.clone()),[0,0,0]]],XY:[[new y.Mesh(new y.BoxGeometry(.15,.15,.01),h.clone()),[.15,.15,0]]],YZ:[[new y.Mesh(new y.BoxGeometry(.15,.15,.01),l.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new y.Mesh(new y.BoxGeometry(.15,.15,.01),c.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},C={X:[[new y.Mesh(new y.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new y.Mesh(new y.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new y.Mesh(new y.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new y.Mesh(new y.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new y.Mesh(new y.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new y.Mesh(new y.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new y.Mesh(new y.OctahedronGeometry(.2,0),s)]],XY:[[new y.Mesh(new y.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new y.Mesh(new y.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new y.Mesh(new y.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]]},w={START:[[new y.Mesh(new y.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],END:[[new y.Mesh(new y.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],DELTA:[[new y.Line(T(),i),null,null,null,"helper"]],X:[[new y.Line(g,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new y.Line(g,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new y.Line(g,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},R={XYZE:[[new y.Mesh(b(.5,1),f),null,[0,Math.PI/2,0]]],X:[[new y.Mesh(b(.5,.5),n)]],Y:[[new y.Mesh(b(.5,.5),r),null,[0,0,-Math.PI/2]]],Z:[[new y.Mesh(b(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new y.Mesh(b(.75,1),d),null,[0,Math.PI/2,0]]]},P={AXIS:[[new y.Line(g,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},z={XYZE:[[new y.Mesh(new y.SphereGeometry(.25,10,8),s)]],X:[[new y.Mesh(new y.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new y.Mesh(new y.TorusGeometry(.5,.1,4,24),s),[0,0,0],[Math.PI/2,0,0]]],Z:[[new y.Mesh(new y.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,0,-Math.PI/2]]],E:[[new y.Mesh(new y.TorusGeometry(.75,.1,2,24),s)]]},$={X:[[new y.Mesh(x,n),[.5,0,0],[0,0,-Math.PI/2]],[new y.Mesh(_,n),[0,0,0],[0,0,-Math.PI/2]],[new y.Mesh(x,n),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new y.Mesh(x,r),[0,.5,0]],[new y.Mesh(_,r)],[new y.Mesh(x,r),[0,-.5,0],[0,0,Math.PI]]],Z:[[new y.Mesh(x,a),[0,0,.5],[Math.PI/2,0,0]],[new y.Mesh(_,a),[0,0,0],[Math.PI/2,0,0]],[new y.Mesh(x,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new y.Mesh(new y.BoxGeometry(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new y.Mesh(new y.BoxGeometry(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new y.Mesh(new y.BoxGeometry(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new y.Mesh(new y.BoxGeometry(.1,.1,.1),u.clone())]]},q={X:[[new y.Mesh(new y.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new y.Mesh(new y.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new y.Mesh(new y.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new y.Mesh(new y.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new y.Mesh(new y.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new y.Mesh(new y.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new y.Mesh(new y.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new y.Mesh(new y.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new y.Mesh(new y.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new y.Mesh(new y.BoxGeometry(.2,.2,.2),s),[0,0,0]]]},j={X:[[new y.Line(g,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new y.Line(g,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new y.Line(g,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function X(Z){const Me=new y.Object3D;for(const de in Z)for(let ye=Z[de].length;ye--;){const se=Z[de][ye][0].clone(),Ce=Z[de][ye][1],ze=Z[de][ye][2],ot=Z[de][ye][3],Te=Z[de][ye][4];se.name=de,se.tag=Te,Ce&&se.position.set(Ce[0],Ce[1],Ce[2]),ze&&se.rotation.set(ze[0],ze[1],ze[2]),ot&&se.scale.set(ot[0],ot[1],ot[2]),se.updateMatrix();const at=se.geometry.clone();at.applyMatrix4(se.matrix),se.geometry=at,se.renderOrder=1/0,se.position.set(0,0,0),se.rotation.set(0,0,0),se.scale.set(1,1,1),Me.add(se)}return Me}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=X(S)),this.add(this.gizmo.rotate=X(R)),this.add(this.gizmo.scale=X($)),this.add(this.picker.translate=X(C)),this.add(this.picker.rotate=X(z)),this.add(this.picker.scale=X(q)),this.add(this.helper.translate=X(w)),this.add(this.helper.rotate=X(P)),this.add(this.helper.scale=X(j)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const s=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:za;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 i=[];i=i.concat(this.picker[this.mode].children),i=i.concat(this.gizmo[this.mode].children),i=i.concat(this.helper[this.mode].children);for(let n=0;n<i.length;n++){const r=i[n];r.visible=!0,r.rotation.set(0,0,0),r.position.copy(this.worldPosition);let a;if(this.camera.isOrthographicCamera?a=(this.camera.top-this.camera.bottom)/this.camera.zoom:a=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),r.scale.set(1,1,1).multiplyScalar(a*this.size/4),r.tag==="helper"){r.visible=!1,r.name==="AXIS"?(r.visible=!!this.axis,this.axis==="X"&&(He.setFromEuler(wa.set(0,0,0)),r.quaternion.copy(s).multiply(He),Math.abs(Oe.copy(ro).applyQuaternion(s).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Y"&&(He.setFromEuler(wa.set(0,0,Math.PI/2)),r.quaternion.copy(s).multiply(He),Math.abs(Oe.copy(nn).applyQuaternion(s).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Z"&&(He.setFromEuler(wa.set(0,Math.PI/2,0)),r.quaternion.copy(s).multiply(He),Math.abs(Oe.copy(oo).applyQuaternion(s).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="XYZE"&&(He.setFromEuler(wa.set(0,Math.PI/2,0)),Oe.copy(this.rotationAxis),r.quaternion.setFromRotationMatrix(Qf.lookAt(Kf,Oe,nn)),r.quaternion.multiply(He),r.visible=this.dragging),this.axis==="E"&&(r.visible=!1)):r.name==="START"?(r.position.copy(this.worldPositionStart),r.visible=this.dragging):r.name==="END"?(r.position.copy(this.worldPosition),r.visible=this.dragging):r.name==="DELTA"?(r.position.copy(this.worldPositionStart),r.quaternion.copy(this.worldQuaternionStart),_t.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),_t.applyQuaternion(this.worldQuaternionStart.clone().invert()),r.scale.copy(_t),r.visible=this.dragging):(r.quaternion.copy(s),this.dragging?r.position.copy(this.worldPositionStart):r.position.copy(this.worldPosition),this.axis&&(r.visible=this.axis.search(r.name)!==-1));continue}r.quaternion.copy(s),this.mode==="translate"||this.mode==="scale"?(r.name==="X"&&Math.abs(Oe.copy(ro).applyQuaternion(s).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Y"&&Math.abs(Oe.copy(nn).applyQuaternion(s).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Z"&&Math.abs(Oe.copy(oo).applyQuaternion(s).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XY"&&Math.abs(Oe.copy(oo).applyQuaternion(s).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="YZ"&&Math.abs(Oe.copy(ro).applyQuaternion(s).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XZ"&&Math.abs(Oe.copy(nn).applyQuaternion(s).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1)):this.mode==="rotate"&&(Ma.copy(s),Oe.copy(this.eye).applyQuaternion(He.copy(s).invert()),r.name.search("E")!==-1&&r.quaternion.setFromRotationMatrix(Qf.lookAt(this.eye,Kf,nn)),r.name==="X"&&(He.setFromAxisAngle(ro,Math.atan2(-Oe.y,Oe.z)),He.multiplyQuaternions(Ma,He),r.quaternion.copy(He)),r.name==="Y"&&(He.setFromAxisAngle(nn,Math.atan2(Oe.x,Oe.z)),He.multiplyQuaternions(Ma,He),r.quaternion.copy(He)),r.name==="Z"&&(He.setFromAxisAngle(oo,Math.atan2(Oe.y,Oe.x)),He.multiplyQuaternions(Ma,He),r.quaternion.copy(He))),r.visible=r.visible&&(r.name.indexOf("X")===-1||this.showX),r.visible=r.visible&&(r.name.indexOf("Y")===-1||this.showY),r.visible=r.visible&&(r.name.indexOf("Z")===-1||this.showZ),r.visible=r.visible&&(r.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),r.material._color=r.material._color||r.material.color.clone(),r.material._opacity=r.material._opacity||r.material.opacity,r.material.color.copy(r.material._color),r.material.opacity=r.material._opacity,this.enabled&&this.axis&&(r.name===this.axis||this.axis.split("").some(function(l){return r.name===l}))&&(r.material.color.setHex(16776960),r.material.opacity=1)}super.updateMatrixWorld(e)}}class WN extends y.Mesh{constructor(){super(new y.PlaneGeometry(1e5,1e5,2,2),new y.MeshBasicMaterial({visible:!1,wireframe:!0,side:y.DoubleSide,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"),Ca.copy(ro).applyQuaternion(t==="local"?this.worldQuaternion:za),Zr.copy(nn).applyQuaternion(t==="local"?this.worldQuaternion:za),Kr.copy(oo).applyQuaternion(t==="local"?this.worldQuaternion:za),Oe.copy(Zr),this.mode){case"translate":case"scale":switch(this.axis){case"X":Oe.copy(this.eye).cross(Ca),Ns.copy(Ca).cross(Oe);break;case"Y":Oe.copy(this.eye).cross(Zr),Ns.copy(Zr).cross(Oe);break;case"Z":Oe.copy(this.eye).cross(Kr),Ns.copy(Kr).cross(Oe);break;case"XY":Ns.copy(Kr);break;case"YZ":Ns.copy(Ca);break;case"XZ":Oe.copy(Kr),Ns.copy(Zr);break;case"XYZ":case"E":Ns.set(0,0,0);break}break;case"rotate":default:Ns.set(0,0,0)}Ns.length()===0?this.quaternion.copy(this.cameraQuaternion):(Jf.lookAt(_t.set(0,0,0),Ns,Oe),this.quaternion.setFromRotationMatrix(Jf)),super.updateMatrixWorld(e)}}class mt extends y.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(ce.SET_SCENE,this.setScene)}clear(){for(const e of this.controls.values()){e.detach(),e.disconnect();const t=e.getHelper();Ls(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 IN(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:mt.DRAG_START})}),t.addEventListener("mouseUp",()=>{this.dispatchEvent({type:mt.DRAG_END})}),t.addEventListener("dragging-changed",i=>{tt.instance?.toggleOrbitControls(i.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(),Ls(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 mt._instance||(mt._instance=new mt),mt._instance}}const $N=new y.BoxGeometry,ch=new y.Vector2;class Ga extends y.Object3D{curve=new y.CatmullRomCurve3;line;draggable;curvePos;tension=.5;closed=!1;subdivide=50;curveType;offset=1;lineMaterial;_camera;_curvePercentage=0;_draggableScale=10;_transform;raycaster;draggedMat=new y.MeshBasicMaterial;parentGroup;group;constructor(e,t){const s=new y.Color(Pi(.5,1,Math.random()),Pi(.5,1,Math.random()),Pi(.5,1,Math.random()));super(),this.name=e,this.lineMaterial=new y.LineBasicMaterial({color:s}),this.line=new y.Line(new y.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 y.Object3D,this.draggable.name="draggablePoints",this.add(this.draggable),this.curvePos=new y.Mesh(new y.SphereGeometry(1.5),new y.MeshBasicMaterial({color:s})),this.curvePos.name="curvePos",this.curvePos.scale.setScalar(this._draggableScale),this.curvePos.visible=!1,this.add(this.curvePos),this.raycaster=new y.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),mt.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([is(t.position.x,3),is(t.position.y,3),is(t.position.z,3)])}),sm({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,i=new y.Mesh($N,this.draggedMat);i.name=`point_${s}`,i.position.copy(e),i.scale.setScalar(this._draggableScale),this.draggable.add(i),this._transform?.attach(i);const n=this.points.length>1;return n&&t&&this.updateSpline(),this.line.visible=n,this.updateCurrentPoint(),i};addNextPt=()=>{const e=this.draggable.children.length,t=e>1?this.draggable.children[e-1].position.clone():new y.Vector3,s=this.addPoint(t);this.group.current?.setField("Current Point",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.group.current?.setField("Current Point",t.position)}Ls(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 y.CatmullRomCurve3(this.points,this.closed,this.curveType,this.tension),this.line.geometry.dispose(),this.line.geometry=new y.BufferGeometry().setFromPoints(this.curve.getPoints(this.subdivide)),this.curvePos.position.copy(this.getPointAt(this._curvePercentage)))};onMouseClick=e=>{if(!tt.instance||!tt.instance.currentWindow||this._transform&&!this._transform.getHelper().visible)return;const s=tt.instance.currentWindow.current.getBoundingClientRect();ch.x=(e.clientX-s.x)/s.width*2-1,ch.y=-((e.clientY-s.y)/s.height)*2+1,this.raycaster.setFromCamera(ch,this.camera);const i=this.raycaster.intersectObjects(this.draggable.children,!1);if(i.length>0){const n=i[0].object;n!==this._transform?.object&&(this._transform?.attach(n),this.group.current?.setField("Current Point",n.position))}};getPointAt(e){return this.curve.points.length>1?this.curve.getPointAt(e):this.curve.points.length===1?this.curve.points[0]:new y.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.group.current?.setField("Current Point",e.position)}}onUpdateTransform=()=>{this.updateCurrentPoint(),this.updateSpline()};initDebug(e){const t=this.draggable.children;this.parentGroup=e,this._transform=mt.instance.add(this.name),this._transform.camera=this._camera,this._transform.addEventListener("objectChange",this.onUpdateTransform),t.length>0&&this._transform.attach(t[t.length-1]),tt.instance?.helpersContainer.add(this._transform.getHelper());const s=t.length>0?t[t.length-1].position:{x:0,y:0,z:0};this.group=e.addGroup({title:this.name,expanded:!0,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:s}],onUpdate:(i,n)=>{switch(i){case"Closed":this.closed=n,this.updateSpline();break;case"Visible":this.visible=n;break;case"Color":this.lineMaterial.color.setStyle(n),this.draggedMat.color.setStyle(n);break;case"Curve":this.curveType=n,this.updateSpline();break;case"Draggable Scale":this.draggableScale=n;break;case"Subdivide":this.subdivide=n,this.updateSpline();break;case"Tension":this.tension=n,this.updateSpline();break;case"New Pt Offset":this.offset=n;break;case"Curve At":this.curvePos.position.copy(this.getPointAt(n));break;case"Show Position":this.curvePos.visible=n;break;case"Show Points":this.draggable.visible=n;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,Ls(this);break;case"Current Point":if(this.group.current&&this._transform?.object){const r=this._transform?.object;r.name.search("point")>-1&&(r.position.copy(n),this.updateSpline())}break}}}),this.draggable.children.forEach(i=>{this.debugPoint(i)})}debugPoint=e=>{e.name,e.visible=this.draggable.visible}}let Ea=0;class Ky extends y.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(ce.ADD_SPLINE,this.onAddSpline)}initDebug(){this.group=_e.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(ce.ADD_SPLINE,this.onAddSpline),_e.removeEditorGroup(this.name)}addSpline(e){e.draggableScale=this.defaultScale,e.hideTransform(),this.group?.current!==null&&e.initDebug(this.group.current),this.add(e),this.currentSpline=e}createSpline=(e=[])=>{const t=`Spline ${Ea+1}`,s=new Ga(t,this._camera);return s.addPoints(e),this.addSpline(s),Ea++,s};createSplineFromArray=e=>{const t=[];return e.forEach(s=>{t.push(new y.Vector3(s[0],s[1],s[2]))}),this.createSpline(t)};createSplineFromCatmullRom=e=>this.createSpline(e.points);createSplineFromJSON=e=>{const t=[];e.points.forEach(i=>{t.push(new y.Vector3(i[0],i[1],i[2]))});const s=new Ga(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),s};showPoints=(e=!0)=>{this.children.forEach(t=>{t.showPoints(e)})};onAddSpline=e=>{const t=JSON.parse(e.value),s=`Spline ${Ea+1}`,i=[];t.points.forEach(r=>{i.push(new y.Vector3(r[0],r[1],r[2]))});const n=new Ga(s,this.camera);n.addPoints(i),this.addSpline(n),Ea++};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(),i=(e.clientX-s.left)/s.width*2-1,n=-((e.clientY-s.top)/s.height)*2+1;if(tt.instance){const a=new y.Raycaster;a.setFromCamera(new y.Vector2(i,n),this._camera);const l=a.intersectObjects(tt.instance.helpersContainer.children,!0);for(let c=0;c<l.length;c++){const h=l[c];if(!(h.object.isLine||h.object.isTransformControlsPlane)&&h.object.isObject3D)return}}this.currentSpline===null&&(this.currentSpline=this.createSpline());const r=this.mouseToSplinePos(i,n,s.width,s.height);this.currentSpline?.addPoint(r),this.isMouseDown=!0};onMouseMove=e=>{if(!this.isMouseDown)return;const s=e.target.getBoundingClientRect(),i=(e.clientX-s.left)/s.width*2-1,n=-((e.clientY-s.top)/s.height)*2+1,r=this.mouseToSplinePos(i,n,s.width,s.height);this.currentSpline?.updateLastPoint(r)};onMouseUp=()=>{this.isMouseDown=!1};mouseToSplinePos(e,t,s,i){const n=new y.Vector3,r=Math.PI/2,a=this._camera,l=a.zoom,c=a.rotation.x===-6123233995736766e-32&&a.rotation.y===0&&a.rotation.z===0,h=a.rotation.x===-Math.PI&&a.rotation.y===12246467991473532e-32&&a.rotation.z===Math.PI,u=a.rotation.x===-6162975822039155e-48&&a.rotation.y===-r&&a.rotation.z===0,d=a.rotation.x===-6162975822039155e-48&&a.rotation.y===r&&a.rotation.z===0,p=a.rotation.x===-1.5707953264174506&&a.rotation.y===0&&a.rotation.z===0,f=a.rotation.x===1.5707953264174506&&a.rotation.y===0&&a.rotation.z===0;let m=e,x=t;h||d?m*=-1:p&&(x*=-1);const g=s/2/l,_=i/2/l;if(this.currentSpline===null&&(this.currentSpline=this.createSpline()),c||h){const b=m*g+a.position.x,T=x*_+a.position.y;n.set(b,T,0)}else if(u||d){const b=m*g+a.position.z,T=x*_+a.position.y;n.set(0,T,b)}else if(p||f){const b=m*g+a.position.x,T=x*_+a.position.z;n.set(b,0,T)}return n}get camera(){return this._camera}set camera(e){this._camera=e,this.children.forEach(t=>{const s=t;s.camera=e})}}const em=["Single","Side by Side","Stacked","Quad"],jN="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",qN="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==",YN="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAQ0lEQVQ4jWP8////fwYqAxYozUhFM/8zkaKYWIWkGEq0b0ZdSjQY5i79TyWagRGaTUdzFEEw6lLqGzqwLoVVJ1StpwA9sBwbUqAh5gAAAABJRU5ErkJggg==";class tt extends W.Component{static instance=null;scene;renderer;currentScene;scenes=new Map;cameras=new Map;controls=new Map;currentCamera;currentWindow;helpersContainer=new y.Group;grid=new Xy;cameraHelpers=new Map;lightHelpers=new Map;interactionHelper=new y.AxesHelper(25);currentTransform;splineEditor;depthMaterial=new y.MeshDepthMaterial;normalsMaterial=new y.MeshNormalMaterial;uvMaterial=new Zy;wireframeMaterial=new y.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;selectedItem=void 0;debugCamera;raycaster=new y.Raycaster;pointer=new y.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(ce.ADD_RENDERER,this.setupRenderer),this.scene=new y.Scene,this.scene.name=this.scene.uuid="",this.canvasRef=W.createRef(),this.containerRef=W.createRef(),this.tlWindow=W.createRef(),this.trWindow=W.createRef(),this.blWindow=W.createRef(),this.brWindow=W.createRef();const t=e.three.name,s=localStorage,i=s.getItem(`${t}_mode`);this.state={mode:i!==null?i:"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 n={Vector2:y.Vector2,Vector3:y.Vector3,Vector4:y.Vector4,Quaternion:y.Quaternion,Matrix4:y.Matrix4,Spherical:y.Spherical,Box3:y.Box3,Sphere:y.Sphere,Raycaster:y.Raycaster};Ds.install({THREE:n}),this.setupScene(),this.setupTools();const r=localStorage.getItem(this.expandedCameraVisibility);r!==null&&(this.cameraVisibility=r==="open"),this.saveExpandedCameraVisibility();const a=localStorage.getItem(this.expandedLightVisibility);a!==null&&(this.lightVisibility=a==="open"),this.saveExpandedLightVisibility();const l=localStorage.getItem(this.expandedGridVisibility);l!==null&&(this.gridVisibility=l==="open"),this.grid.visible=this.gridVisibility,this.saveExpandedGridVisibility(),tt.instance=this}componentDidMount(){this.enable(),this.assignControls(),this.resize(),this.play(),mt.instance.setApp(this.props.three),mt.instance.activeCamera=this.debugCamera}componentDidUpdate(e,t,s){t.mode!==this.state.mode&&(this.assignControls(),this.resize())}componentWillUnmount(){this.disable(),this.clear(),_e.removeEditorGroup("View Settings")}render(){const e=[];return this.cameras.forEach((t,s)=>{e.push(s)}),E.jsxs("div",{className:"multiview",children:[E.jsx("canvas",{ref:this.canvasRef}),E.jsxs("div",{className:`cameras ${this.state.mode==="Single"||this.state.mode==="Stacked"?"single":""}`,ref:this.containerRef,children:[this.state.mode==="Single"&&E.jsx(E.Fragment,{children:E.jsx(Ki,{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")&&E.jsxs(E.Fragment,{children:[E.jsx(Ki,{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)}}),E.jsx(Ki,{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"&&E.jsxs(E.Fragment,{children:[E.jsx(Ki,{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)}}),E.jsx(Ki,{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)}}),E.jsx(Ki,{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)}}),E.jsx(Ki,{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)}})]})]}),E.jsxs("div",{className:"settings",children:[E.jsx(hl,{title:"View",index:em.indexOf(this.state.mode),options:em,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})}}),E.jsx(hl,{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})}}),E.jsx(oh,{name:"cameraHelper",icon:jN,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)}}}),E.jsx(oh,{name:"lightHelper",icon:qN,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)}}}),E.jsx(oh,{name:"gridHelper",icon:YN,selected:this.gridVisibility,height:21,width:21,onClick:t=>{this.setGridVisibility(t)}})]},this.state.lastUpdate)]})}setupRenderer=e=>{this.renderer&&this.renderer.dispose();const t=this.canvasRef.current;this.props.three.canvas=t;const s=e.value;s.type==="WebGLRenderer"?(this.renderer=new y.WebGLRenderer({canvas:t,stencil:!1}),this.grid.visible=!0):s.type==="WebGPURenderer"&&(this.renderer=new xa({canvas:t,stencil:!1}),this.grid.visible=!1),this.renderer&&(this.renderer.autoClear=!1,this.renderer.shadowMap.enabled=!0,this.renderer.setPixelRatio(devicePixelRatio),this.renderer.setClearColor(0),this.resize(),this.props.three.renderer=this.renderer)};setupScene(){this.helpersContainer.name="helpers",this.scene.add(this.helpersContainer),this.scene.add(this.grid),this.interactionHelper.name="interactionHelper",this.interactionHelper.visible=!1,this.helpersContainer.add(this.interactionHelper);const e=(n,r)=>{const a=new y.OrthographicCamera(-100,100,100,-100,0,3e3);return a.name=n,a.position.copy(r),a.lookAt(0,0,0),this.cameras.set(n,a),a},t=3e3;e("Top",new y.Vector3(0,t,0)),e("Bottom",new y.Vector3(0,-t,0)),e("Left",new y.Vector3(-t,0,0)),e("Right",new y.Vector3(t,0,0)),e("Front",new y.Vector3(0,0,t)),e("Back",new y.Vector3(0,0,-t)),e("Orthographic",new y.Vector3(t,t,t)),e("UI",new y.Vector3),this.debugCamera=new y.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,i=this.props.three.name;this.tlCam=this.cameras.get(s.getItem(`${i}_tlCam`)),this.trCam=this.cameras.get(s.getItem(`${i}_trCam`)),this.blCam=this.cameras.get(s.getItem(`${i}_blCam`)),this.brCam=this.cameras.get(s.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")),_e.addEditorGroup({title:"Editor",items:[{type:"number",prop:"Grid Position",value:this.grid.position.y}],onUpdate:(n,r)=>{switch(n){case"Grid Position":this.grid.position.y=r;break}}})}setupTools(){this.splineEditor=new Ky(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:ce.CLEAR_OBJECT}),_e.removeAllGroups(),this.clearLightHelpers(),this.clearControls(),this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),mt.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=void 0,mt.instance.clear(),this.cameras.forEach(e=>{this.editorCameras.indexOf(e.name)<0&&this.three.dispatchEvent({type:ce.REMOVE_CAMERA,value:e})}),this.currentCamera=this.debugCamera,this.currentScene=void 0,this.scenes.forEach(e=>{this.three.dispatchEvent({type:ce.REMOVE_SCENE,value:e})}),this.scenes.clear()}setGridVisibility(e){this.gridVisibility=e,this.saveExpandedGridVisibility(),this.grid.visible=e}update(){this.renderer&&(this.renderer instanceof y.WebGLRenderer?this.renderer?.clear():this.renderer instanceof xa&&this.renderer?.clearAsync()),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(){switch(this.renderer&&(this.renderer instanceof y.WebGLRenderer?this.renderer?.clear():this.renderer instanceof xa&&this.renderer?.clearAsync()),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(ce.ADD_SCENE,this.addScene),this.three.addEventListener(ce.SET_SCENE,this.sceneUpdate),this.three.addEventListener(ce.REMOVE_SCENE,this.removeScene),this.three.addEventListener(ce.ADD_CAMERA,this.addCamera),this.three.addEventListener(ce.REMOVE_CAMERA,this.removeCamera),this.three.addEventListener(ce.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(ce.ADD_SCENE,this.addScene),this.three.removeEventListener(ce.SET_SCENE,this.sceneUpdate),this.three.removeEventListener(ce.ADD_CAMERA,this.addCamera),this.three.removeEventListener(ce.REMOVE_CAMERA,this.removeCamera),this.three.removeEventListener(ce.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,i=this.height;switch(this.state.mode){case"Side by Side":s=e,i=this.height;break;case"Stacked":s=this.width,i=t;break;case"Quad":s=e,i=t;break}const n=s/i;this.cameras.forEach(r=>{r instanceof y.OrthographicCamera?(r.left=s/-2,r.right=s/2,r.top=i/2,r.bottom=i/-2,r.name==="UI"&&(r.position.x=this.width/2,r.position.y=this.height/-2,r.position.z=100),r.updateProjectionMatrix()):r instanceof y.PerspectiveCamera&&(r.aspect=n,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(()=>{Ls(s)},100),this.clearLightHelpers()};addCamera=e=>{const t=e.value,s=t.uuid,i=this.props.three.scene?.getObjectByProperty("uuid",t.uuid);if(i!==void 0){const n=i;this.cameras.set(s,n);const r=new y.CameraHelper(n);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,i=this.cameraHelpers.get(s);i!==void 0&&(this.helpersContainer.remove(i),i.dispose()),this.cameras.delete(s),this.setState({lastUpdate:Date.now()})};onMouseMove=e=>{const t=new y.Vector2;this.renderer?.getSize(t);const s=Math.min(e.clientX,t.x),i=Math.min(e.clientY,t.y);this.pointer.x=Ji(s,0,t.x,-1,1),this.pointer.y=Ji(i,0,t.y,1,-1);const n=t.x/2,r=t.y/2,a=()=>{s<n?this.pointer.x=Ji(s,0,n,-1,1):this.pointer.x=Ji(s,n,t.x,-1,1)},l=()=>{i<r?this.pointer.y=Ji(i,0,r,1,-1):this.pointer.y=Ji(i,r,t.y,1,-1)};switch(this.state.mode){case"Quad":a(),l();break;case"Side by Side":a();break;case"Stacked":l(),l();break}if(this.updateCamera(s,i,n,r),this.state.interactionMode==="Orbit"||this.currentScene===void 0)return;const c=this.raycaster.intersectObjects(this.currentScene.children);c.length>0&&this.interactionHelper.position.copy(c[0].point)};onClick=e=>{if(this.state.interactionMode==="Orbit"||this.currentScene===void 0)return;const t=new y.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 Ds(this.currentCamera,this.currentWindow.current),this.selectedItem instanceof y.Mesh||this.selectedItem instanceof y.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 Ds(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 Ds(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 Ds(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 Ds(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 Ds(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Wa(45),Wa(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),mt.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=mt.instance.add(e.value.name),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),Fl.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 y.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 y.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 fN(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 y.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 y.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 i=new gN(e,t);switch(i.enableDamping=!0,i.dampingFactor=.1,e.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":i.enableRotate=!1;break}this.controls.set(e.name,i)}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,i)=>{switch(this.state.mode){case"Quad":t<i?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<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),mt.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,i=new y.Clock;i.start(),this.selectedItem.getWorldPosition(e.target0);const n=()=>{const r=i.getDelta();this.cameraControls&&this.cameraControls.update(r),t&&(e.target.lerp(e.target0,s),e.object.position.lerp(e.position0,s),e.object.zoom=lr(e.object.zoom,e.zoom0,s),e.object.updateProjectionMatrix(),e.dispatchEvent({type:"change"})),i.getElapsedTime()>=.5?(cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.clearControls()):this.cameraControlsRafID=requestAnimationFrame(n)};n()};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,i,n,r){switch(n.name){case"Left":case"Right":this.grid.rotation.z=Math.PI/2;break;case"Front":case"Back":this.grid.rotation.x=Math.PI/2;break}this.scene.overrideMaterial=r,this.renderer&&(this.renderer?.setViewport(e,t,s,i),this.renderer?.setScissor(e,t,s,i),this.renderer instanceof y.WebGLRenderer?this.renderer?.render(this.scene,n):this.renderer instanceof xa&&this.renderer?.renderAsync(this.scene,n)),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),i=Math.floor(this.height/2);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 n=this.height-i;this.drawTo(0,n,this.width,i,this.tlCam,e),this.drawTo(0,0,this.width,i,this.trCam,t)}};drawQuad=()=>{const e=this.getSceneOverride(this.tlRender),t=this.getSceneOverride(this.trRender),s=this.getSceneOverride(this.blRender),i=this.getSceneOverride(this.brRender),n=Math.floor(this.width/2),r=Math.floor(this.height/2);let a=0,l=0;l=this.height-r,a=0,this.drawTo(a,l,n,r,this.tlCam,e),a=n,this.drawTo(a,l,n,r,this.trCam,t),l=0,a=0,this.scene.overrideMaterial=s,this.drawTo(a,l,n,r,this.blCam,s),a=n,this.drawTo(a,l,n,r,this.brCam,i)};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 Fl extends W.Component{static instance;matrix=new y.Matrix4;position=new y.Vector3;rotation=new y.Euler;scale=new y.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)),Fl.instance=this}update(){if(tt.instance){const e=tt.instance.selectedItem;if(e===void 0)return;this.position.x=is(e.position.x,3),this.position.y=is(e.position.y,3),this.position.z=is(e.position.z,3),this.rotation.copy(e.rotation),this.scale.x=is(e.scale.x,3),this.scale.y=is(e.scale.y,3),this.scale.z=is(e.scale.z,3),this.setState({lastUpdated:Date.now()})}}render(){return E.jsx(hs,{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 i=this.props.three.getScene(this.props.object.uuid);if(i){const n=i.getObjectByProperty("uuid",this.props.object.uuid);Ye(n,e,s)}};saveExpanded(){localStorage.setItem(this.expandedName,this.open?"open":"closed")}get expandedName(){return`${this.props.three.name}_transform`}}function tm(o){switch(o){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 o}function XN(o,e){function t(){return`${e.name}_light`}const s=localStorage.getItem(t()),i=s!==null?s==="open":!1;function n(a){localStorage.setItem(t(),a?"open":"closed")}const r=[];if(o.lightInfo!==void 0)for(const a in o.lightInfo){const l=o.lightInfo[a];l!==void 0&&(l.isColor!==void 0?r.push({title:tm(a),prop:a,type:"color",value:l,onChange:(c,h)=>{const u=new y.Color(h);e.updateObject(o.uuid,c,u);const d=e.getScene(o.uuid);if(d!==null){const p=d.getObjectByProperty("uuid",o.uuid);Ye(p,c,u)}}}):r.push({title:tm(a),prop:a,type:typeof l,value:l,step:typeof l=="number"?.01:void 0,onChange:(c,h)=>{e.updateObject(o.uuid,c,h);const u=e.getScene(o.uuid);if(u!==null){const d=u.getObjectByProperty("uuid",o.uuid);Ye(d,c,h)}}}))}return E.jsx(hs,{three:e,title:"Light",items:r,expanded:i,onToggle:a=>{n(a)}})}function ZN(o){const e=o.object,t=o.three;function s(){return`${t.name}_animation`}const i=localStorage.getItem(s()),n=i!==null?i==="open":!1;function r(d){localStorage.setItem(s(),d?"open":"closed")}const a=[],l=[];let c=0;e.animations.forEach(d=>{c=Math.max(c,d.duration),d.duration>0&&l.push({title:d.name,items:[{title:"Duration",type:"number",value:d.duration,disabled:!0},{title:"Blend Mode",type:"option",disabled:!0,options:[{title:"Normal",value:2500},{title:"Additive",value:2501}]}]})}),a.push({title:"Animations",items:l});let h;const u=t.getScene(e.uuid);if(u!==null){const d=u.getObjectByProperty("uuid",e.uuid);if(d!==void 0){const p=d.mixer;if(p!==void 0){const m=[{title:"Time Scale",type:"range",value:p.timeScale,step:.01,min:-1,max:2,onChange:(x,g)=>{p.timeScale=g,t.updateObject(e.uuid,"mixer.timeScale",g)}}];m.push({title:"Stop All",type:"button",onChange:()=>{p.stopAllAction(),t.requestMethod(e.uuid,"stopAllAction",void 0,"mixer")}}),a.push({title:"Mixer",items:m}),h=new y.SkeletonHelper(d),tt.instance?.scene.add(h)}}}return W.useEffect(()=>()=>{h!==void 0&&Ls(h)},[]),E.jsx(hs,{three:o.three,title:"Animation",items:a,expanded:n,onToggle:d=>{r(d)}})}const hh={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 Qy(o){const[e,t]=W.useState(hh);W.useEffect(()=>{function r(l){t(l.value)}function a(){t(hh)}return o.three.addEventListener(ce.CLEAR_OBJECT,a),o.three.addEventListener(ce.SET_SCENE,a),o.three.addEventListener(ce.SET_OBJECT,r),()=>{o.three.removeEventListener(ce.CLEAR_OBJECT,a),o.three.removeEventListener(ce.SET_SCENE,a),o.three.removeEventListener(ce.SET_OBJECT,r)}},[]);const s=e.type.toLowerCase(),i=e.animations.length>0||e.mixer!==void 0,n=s.search("mesh")>-1||s.search("line")>-1||s.search("points")>-1;return E.jsx(Qn,{three:o.three,label:"Inspector",button:e.uuid.length>0?E.jsx("button",{className:"remove",onClick:()=>{mt.instance.remove(e.name),t(hh)}}):void 0,children:E.jsx("div",{id:"Inspector",className:o.class,children:e.uuid.length>0&&E.jsxs(E.Fragment,{children:[E.jsxs(E.Fragment,{children:[E.jsx(Ra,{type:"string",title:"Name",prop:"name",value:e.name,disabled:!0}),E.jsx(Ra,{type:"string",title:"Type",prop:"type",value:e.type,disabled:!0}),E.jsx(Ra,{type:"string",title:"UUID",prop:"uuid",value:e.uuid,disabled:!0})]}),E.jsxs(E.Fragment,{children:[E.jsx(Fl,{object:e,three:o.three}),i?E.jsx(ZN,{object:e,three:o.three}):null,s.search("camera")>-1?T_(e,o.three):null,s.search("light")>-1?XN(e,o.three):null,n?x_(e,o.three):null]})]})})},"Inspector")}class KN extends W.Component{autoClear=!0;autoClearColor=!0;autoClearDepth=!0;autoClearStencil=!0;outputColorSpace=y.SRGBColorSpace;localClippingEnabled=!1;clearColor=new y.Color(0);clearAlpha=1;toneMapping=y.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),tt.instance){const i=tt.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 y.WebGLRenderer&&(this.localClippingEnabled=i.localClippingEnabled,i.getClearColor(this.clearColor)))}this.props.three.addEventListener(ce.ADD_RENDERER,this.onAddRenderer)}componentwillunmount(){this.props.three.removeEventListener(ce.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,y.LinearSRGBColorSpace),y.ColorManagement.enabled=t.colorManagement,tt.instance){const s=tt.instance.renderer;s&&(s.autoClearColor=this.autoClearColor,s.outputColorSpace=this.outputColorSpace,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(tt.instance){const t=tt.instance.renderer;t&&(t.autoClearColor=this.autoClearColor,t.outputColorSpace=this.outputColorSpace,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:y.ColorManagement.enabled,toneMapping:this.toneMapping,toneMappingExposure:this.toneMappingExposure}))}};return E.jsx(hs,{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:y.ColorManagement.enabled,onChange:(t,s)=>{y.ColorManagement.enabled=s,e()}},{type:"option",title:"Color Space",value:this.outputColorSpace,options:[{title:"No Color Space",value:y.NoColorSpace},{title:"SRB Color Space",value:y.SRGBColorSpace},{title:"Linear SRB Color Space",value:y.LinearSRGBColorSpace}],onChange:(t,s)=>{this.outputColorSpace=s,e()}},{type:"option",title:"Tone Mapping",value:this.toneMapping,options:[{title:"None ",value:y.NoToneMapping},{title:"Linear ",value:y.LinearToneMapping},{title:"Reinhard",value:y.ReinhardToneMapping},{title:"Cineon ",value:y.CineonToneMapping},{title:"ACES Filmic",value:y.ACESFilmicToneMapping},{title:"AgX",value:y.AgXToneMapping},{title:"Neutral",value:y.NeutralToneMapping},{title:"Custom",value:y.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 Jy(o){const[e]=W.useState([]),[t]=W.useState([]),[s,i]=W.useState(0),n=c=>{const h=c.value;e.push(h),t.push(E.jsx(Qn,{three:o.three,label:`Scene: ${h.name}`,scene:h,open:!1,visible:!1,onRefresh:()=>{o.three.refreshScene(h.name)},children:E.jsx(Aa,{child:h,scene:h,three:o.three})},h.name)),i(Date.now())},r=c=>{const h=c.value;for(let u=0;u<e.length;u++)if(h.uuid===e[u].uuid){e[u]=h,t[u]=E.jsx(Qn,{three:o.three,label:`Scene: ${h.name}`,scene:h,open:t[u].props.open,visible:t[u].props.visible,onRefresh:()=>{o.three.refreshScene(h.name)},children:E.jsx(Aa,{child:h,scene:h,three:o.three})},h.name),i(Date.now());return}},a=c=>{const h=c.value;for(let u=0;u<e.length;u++)if(h.uuid===e[u].uuid){e.splice(u,1),t.splice(u,1),i(Date.now());return}},l=c=>{const h=c.value.name;for(let u=0;u<e.length;u++){const d=e[u];if(d.name===h){t[u]=E.jsx(Qn,{three:o.three,label:`Scene: ${d.name}`,scene:d,open:!0,visible:!0,onRefresh:()=>{o.three.refreshScene(d.name)},children:E.jsx(Aa,{child:d,scene:d,three:o.three})},d.name);break}}i(Date.now())};return W.useEffect(()=>(o.three.addEventListener(ce.ADD_SCENE,n),o.three.addEventListener(ce.SET_SCENE,l),o.three.addEventListener(ce.REFRESH_SCENE,r),o.three.addEventListener(ce.REMOVE_SCENE,a),()=>{o.three.removeEventListener(ce.ADD_SCENE,n),o.three.removeEventListener(ce.SET_SCENE,l),o.three.removeEventListener(ce.REFRESH_SCENE,r),o.three.removeEventListener(ce.REMOVE_SCENE,a)}),[]),E.jsxs("div",{id:"SidePanel",children:[E.jsx("div",{className:"scenes",children:t},s),E.jsx(Qy,{three:o.three}),E.jsx(KN,{three:o.three}),E.jsx(_e,{three:o.three})]})}function e0(o){return E.jsxs("div",{className:"editor",ref:o.ref,style:o.style,children:[E.jsx("div",{className:"header",children:o.header}),o.children,E.jsx("div",{className:"footer",children:o.footer})]})}function QN(o){return E.jsx(e0,{children:E.jsxs(E.Fragment,{children:[E.jsx(tt,{three:o.three,scenes:o.scenes,onSceneAdd:o.onSceneAdd,onSceneResize:o.onSceneResize,onSceneUpdate:o.onSceneUpdate}),E.jsx(Jy,{three:o.three})]})})}exports.Accordion=Qn;exports.Application=Ex;exports.BaseRemote=Kh;exports.ChildObject=Jh;exports.ContainerObject=Aa;exports.Draggable=mm;exports.DraggableItem=fm;exports.Dropdown=gm;exports.DropdownItem=ym;exports.Editor=e0;exports.ElementProxy=Mx;exports.ElementProxyReceiver=dm;exports.ExportTexture=Ni;exports.InfiniteGridHelper=Xy;exports.InfiniteGridMaterial=Yy;exports.Inspector=Qy;exports.MultiView=tt;exports.NavButton=Qh;exports.ProxyManager=Cx;exports.RemoteTheatre=Nx;exports.RemoteThree=Ix;exports.SidePanel=Jy;exports.Spline=Ga;exports.SplineEditor=Ky;exports.ThreeEditor=QN;exports.Transform=mt;exports.UVMaterial=Zy;exports.WebworkerEventHandlers=vx;exports.anchorGeometry=hm;exports.anchorGeometryTL=ix;exports.animateObjectMaterial=J0;exports.animateObjectTransform=K0;exports.applyObjectMaterial=cm;exports.capitalize=yo;exports.clamp=Si;exports.clearComposerGroups=fx;exports.colorToHex=uh;exports.copyToClipboard=sm;exports.createMask=ax;exports.cubicBezier=q0;exports.customizeTheatreElements=Z0;exports.damp=G0;exports.defaultTheatreCallback=D0;exports.detectMaxFrameRate=rm;exports.detectSettings=om;exports.dispose=Ls;exports.disposeMaterial=Xh;exports.disposeTexture=dh;exports.distance=z0;exports.generateCubemap=mx;exports.getAngle=V0;exports.getObjectMaterialObject=lm;exports.getObjectMaterialProps=am;exports.hierarchyUUID=Ha;exports.inspectComposer=px;exports.inspectComposerPass=um;exports.isColor=im;exports.map=k0;exports.mix=lr;exports.noop=go;exports.normalize=Va;exports.orthoCamera=ex;exports.parseModelLite=tx;exports.randomID=ht;exports.renderToTexture=sx;exports.resetThreeObjects=ph;exports.rgbaToHex=Y0;exports.roundTo=is;exports.setMaterialBlendAdd=hx;exports.setMaterialBlendMultiply=ux;exports.setMaterialBlendNormal=cx;exports.setMaterialBlendScreen=dx;exports.supportsOffscreenCanvas=ox;exports.triangle=ul;exports.updateCameraOrtho=nx;exports.updateCameraOrtho16x9=rx;exports.useMask=lx;exports.useStudio=X0;
|
|
600
|
+
}`;class Zy extends y.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:ON,fragmentShader:BN})}}const Qi=new y.Raycaster,_t=new y.Vector3,bi=new y.Vector3,He=new y.Quaternion,qf={X:new y.Vector3(1,0,0),Y:new y.Vector3(0,1,0),Z:new y.Vector3(0,0,1)},ah={type:"change"},Yf={type:"mouseDown",mode:null},Xf={type:"mouseUp",mode:null},Zf={type:"objectChange"};class IN extends y.Controls{constructor(e,t=null){super(void 0,t);const s=new VN(this);this._root=s;const i=new HN;this._gizmo=i,s.add(i);const n=new WN;this._plane=n,s.add(n);const r=this;function a(b,T){let S=T;Object.defineProperty(r,b,{get:function(){return S!==void 0?S:T},set:function(C){S!==C&&(S=C,n[b]=C,i[b]=C,r.dispatchEvent({type:b+"-changed",value:C}),r.dispatchEvent(ah))}}),r[b]=T,n[b]=T,i[b]=T}a("camera",e),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0),a("minX",-1/0),a("maxX",1/0),a("minY",-1/0),a("maxY",1/0),a("minZ",-1/0),a("maxZ",1/0);const l=new y.Vector3,c=new y.Vector3,h=new y.Quaternion,u=new y.Quaternion,d=new y.Vector3,p=new y.Quaternion,f=new y.Vector3,m=new y.Vector3,x=new y.Vector3,g=0,_=new y.Vector3;a("worldPosition",l),a("worldPositionStart",c),a("worldQuaternion",h),a("worldQuaternionStart",u),a("cameraPosition",d),a("cameraQuaternion",p),a("pointStart",f),a("pointEnd",m),a("rotationAxis",x),a("rotationAngle",g),a("eye",_),this._offset=new y.Vector3,this._startNorm=new y.Vector3,this._endNorm=new y.Vector3,this._cameraScale=new y.Vector3,this._parentPosition=new y.Vector3,this._parentQuaternion=new y.Quaternion,this._parentQuaternionInv=new y.Quaternion,this._parentScale=new y.Vector3,this._worldScaleStart=new y.Vector3,this._worldQuaternionInv=new y.Quaternion,this._worldScale=new y.Vector3,this._positionStart=new y.Vector3,this._quaternionStart=new y.Quaternion,this._scaleStart=new y.Vector3,this._getPointer=LN.bind(this),this._onPointerDown=kN.bind(this),this._onPointerHover=UN.bind(this),this._onPointerMove=zN.bind(this),this._onPointerUp=GN.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&&Qi.setFromCamera(e,this.camera);const t=lh(this._gizmo.picker[this.mode],Qi);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&&Qi.setFromCamera(e,this.camera);const t=lh(this._plane,Qi,!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,Yf.mode=this.mode,this.dispatchEvent(Yf)}}pointerMove(e){const t=this.axis,s=this.mode,i=this.object;let n=this.space;if(s==="scale"?n="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(n="world"),i===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&Qi.setFromCamera(e,this.camera);const r=lh(this._plane,Qi,!0);if(r){if(this.pointEnd.copy(r.point).sub(this.worldPositionStart),s==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),n==="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),n==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),i.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(n==="local"&&(i.position.applyQuaternion(He.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this._quaternionStart)),n==="world"&&(i.parent&&i.position.add(_t.setFromMatrixPosition(i.parent.matrixWorld)),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(_t.setFromMatrixPosition(i.parent.matrixWorld)))),i.position.x=Math.max(this.minX,Math.min(this.maxX,i.position.x)),i.position.y=Math.max(this.minY,Math.min(this.maxY,i.position.y)),i.position.z=Math.max(this.minZ,Math.min(this.maxZ,i.position.z));else if(s==="scale"){if(t.search("XYZ")!==-1){let a=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(a*=-1),bi.set(a,a,a)}else _t.copy(this.pointStart),bi.copy(this.pointEnd),_t.applyQuaternion(this._worldQuaternionInv),bi.applyQuaternion(this._worldQuaternionInv),bi.divide(_t),t.search("X")===-1&&(bi.x=1),t.search("Y")===-1&&(bi.y=1),t.search("Z")===-1&&(bi.z=1);i.scale.copy(this._scaleStart).multiply(bi),this.scaleSnap&&(t.search("X")!==-1&&(i.scale.x=Math.round(i.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(i.scale.y=Math.round(i.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(i.scale.z=Math.round(i.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(s==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const a=20/this.worldPosition.distanceTo(_t.setFromMatrixPosition(this.camera.matrixWorld));let l=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(_t.copy(this.rotationAxis).cross(this.eye))*a):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(qf[t]),_t.copy(qf[t]),n==="local"&&_t.applyQuaternion(this.worldQuaternion),_t.cross(this.eye),_t.length()===0?l=!0:this.rotationAngle=this._offset.dot(_t.normalize())*a),(t==="E"||l)&&(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),n==="local"&&t!=="E"&&t!=="XYZE"?(i.quaternion.copy(this._quaternionStart),i.quaternion.multiply(He.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),i.quaternion.copy(He.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(ah),this.dispatchEvent(Zf)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(Xf.mode=this.mode,this.dispatchEvent(Xf)),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(ah),this.dispatchEvent(Zf),this.pointStart.copy(this.pointEnd))}getRaycaster(){return Qi}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}}function LN(o){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:o.button};{const e=this.domElement.getBoundingClientRect();return{x:(o.clientX-e.left)/e.width*2-1,y:-(o.clientY-e.top)/e.height*2+1,button:o.button}}}function UN(o){if(this.enabled)switch(o.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(o));break}}function kN(o){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(o.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(o)),this.pointerDown(this._getPointer(o)))}function zN(o){this.enabled&&this.pointerMove(this._getPointer(o))}function GN(o){this.enabled&&(this.domElement.releasePointerCapture(o.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(o)))}function lh(o,e,t){const s=e.intersectObject(o,!0);for(let i=0;i<s.length;i++)if(s[i].object.visible||t)return s[i];return!1}const wa=new y.Euler,Oe=new y.Vector3(0,1,0),Kf=new y.Vector3(0,0,0),Qf=new y.Matrix4,Ma=new y.Quaternion,za=new y.Quaternion,Ns=new y.Vector3,Jf=new y.Matrix4,ro=new y.Vector3(1,0,0),nn=new y.Vector3(0,1,0),oo=new y.Vector3(0,0,1),Ca=new y.Vector3,Zr=new y.Vector3,Kr=new y.Vector3;class VN extends y.Object3D{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 HN extends y.Object3D{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new y.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new y.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),s=e.clone();s.opacity=.15;const i=t.clone();i.opacity=.5;const n=e.clone();n.color.setHex(16711680);const r=e.clone();r.color.setHex(65280);const a=e.clone();a.color.setHex(255);const l=e.clone();l.color.setHex(16711680),l.opacity=.5;const c=e.clone();c.color.setHex(65280),c.opacity=.5;const h=e.clone();h.color.setHex(255),h.opacity=.5;const u=e.clone();u.opacity=.25;const d=e.clone();d.color.setHex(16776960),d.opacity=.25,e.clone().color.setHex(16776960);const f=e.clone();f.color.setHex(7895160);const m=new y.CylinderGeometry(0,.04,.1,12);m.translate(0,.05,0);const x=new y.BoxGeometry(.08,.08,.08);x.translate(0,.04,0);const g=new y.BufferGeometry;g.setAttribute("position",new y.Float32BufferAttribute([0,0,0,1,0,0],3));const _=new y.CylinderGeometry(.0075,.0075,.5,3);_.translate(0,.25,0);function b(Z,Me){const de=new y.TorusGeometry(Z,.0075,3,64,Me*Math.PI*2);return de.rotateY(Math.PI/2),de.rotateX(Math.PI/2),de}function T(){const Z=new y.BufferGeometry;return Z.setAttribute("position",new y.Float32BufferAttribute([0,0,0,1,1,1],3)),Z}const S={X:[[new y.Mesh(m,n),[.5,0,0],[0,0,-Math.PI/2]],[new y.Mesh(m,n),[-.5,0,0],[0,0,Math.PI/2]],[new y.Mesh(_,n),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new y.Mesh(m,r),[0,.5,0]],[new y.Mesh(m,r),[0,-.5,0],[Math.PI,0,0]],[new y.Mesh(_,r)]],Z:[[new y.Mesh(m,a),[0,0,.5],[Math.PI/2,0,0]],[new y.Mesh(m,a),[0,0,-.5],[-Math.PI/2,0,0]],[new y.Mesh(_,a),null,[Math.PI/2,0,0]]],XYZ:[[new y.Mesh(new y.OctahedronGeometry(.1,0),u.clone()),[0,0,0]]],XY:[[new y.Mesh(new y.BoxGeometry(.15,.15,.01),h.clone()),[.15,.15,0]]],YZ:[[new y.Mesh(new y.BoxGeometry(.15,.15,.01),l.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new y.Mesh(new y.BoxGeometry(.15,.15,.01),c.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},C={X:[[new y.Mesh(new y.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new y.Mesh(new y.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new y.Mesh(new y.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new y.Mesh(new y.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new y.Mesh(new y.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new y.Mesh(new y.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new y.Mesh(new y.OctahedronGeometry(.2,0),s)]],XY:[[new y.Mesh(new y.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new y.Mesh(new y.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new y.Mesh(new y.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]]},w={START:[[new y.Mesh(new y.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],END:[[new y.Mesh(new y.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],DELTA:[[new y.Line(T(),i),null,null,null,"helper"]],X:[[new y.Line(g,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new y.Line(g,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new y.Line(g,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},R={XYZE:[[new y.Mesh(b(.5,1),f),null,[0,Math.PI/2,0]]],X:[[new y.Mesh(b(.5,.5),n)]],Y:[[new y.Mesh(b(.5,.5),r),null,[0,0,-Math.PI/2]]],Z:[[new y.Mesh(b(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new y.Mesh(b(.75,1),d),null,[0,Math.PI/2,0]]]},P={AXIS:[[new y.Line(g,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},z={XYZE:[[new y.Mesh(new y.SphereGeometry(.25,10,8),s)]],X:[[new y.Mesh(new y.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new y.Mesh(new y.TorusGeometry(.5,.1,4,24),s),[0,0,0],[Math.PI/2,0,0]]],Z:[[new y.Mesh(new y.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,0,-Math.PI/2]]],E:[[new y.Mesh(new y.TorusGeometry(.75,.1,2,24),s)]]},$={X:[[new y.Mesh(x,n),[.5,0,0],[0,0,-Math.PI/2]],[new y.Mesh(_,n),[0,0,0],[0,0,-Math.PI/2]],[new y.Mesh(x,n),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new y.Mesh(x,r),[0,.5,0]],[new y.Mesh(_,r)],[new y.Mesh(x,r),[0,-.5,0],[0,0,Math.PI]]],Z:[[new y.Mesh(x,a),[0,0,.5],[Math.PI/2,0,0]],[new y.Mesh(_,a),[0,0,0],[Math.PI/2,0,0]],[new y.Mesh(x,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new y.Mesh(new y.BoxGeometry(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new y.Mesh(new y.BoxGeometry(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new y.Mesh(new y.BoxGeometry(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new y.Mesh(new y.BoxGeometry(.1,.1,.1),u.clone())]]},q={X:[[new y.Mesh(new y.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new y.Mesh(new y.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new y.Mesh(new y.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new y.Mesh(new y.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new y.Mesh(new y.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new y.Mesh(new y.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new y.Mesh(new y.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new y.Mesh(new y.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new y.Mesh(new y.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new y.Mesh(new y.BoxGeometry(.2,.2,.2),s),[0,0,0]]]},j={X:[[new y.Line(g,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new y.Line(g,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new y.Line(g,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function X(Z){const Me=new y.Object3D;for(const de in Z)for(let ye=Z[de].length;ye--;){const se=Z[de][ye][0].clone(),Ce=Z[de][ye][1],ze=Z[de][ye][2],ot=Z[de][ye][3],Te=Z[de][ye][4];se.name=de,se.tag=Te,Ce&&se.position.set(Ce[0],Ce[1],Ce[2]),ze&&se.rotation.set(ze[0],ze[1],ze[2]),ot&&se.scale.set(ot[0],ot[1],ot[2]),se.updateMatrix();const at=se.geometry.clone();at.applyMatrix4(se.matrix),se.geometry=at,se.renderOrder=1/0,se.position.set(0,0,0),se.rotation.set(0,0,0),se.scale.set(1,1,1),Me.add(se)}return Me}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=X(S)),this.add(this.gizmo.rotate=X(R)),this.add(this.gizmo.scale=X($)),this.add(this.picker.translate=X(C)),this.add(this.picker.rotate=X(z)),this.add(this.picker.scale=X(q)),this.add(this.helper.translate=X(w)),this.add(this.helper.rotate=X(P)),this.add(this.helper.scale=X(j)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const s=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:za;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 i=[];i=i.concat(this.picker[this.mode].children),i=i.concat(this.gizmo[this.mode].children),i=i.concat(this.helper[this.mode].children);for(let n=0;n<i.length;n++){const r=i[n];r.visible=!0,r.rotation.set(0,0,0),r.position.copy(this.worldPosition);let a;if(this.camera.isOrthographicCamera?a=(this.camera.top-this.camera.bottom)/this.camera.zoom:a=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),r.scale.set(1,1,1).multiplyScalar(a*this.size/4),r.tag==="helper"){r.visible=!1,r.name==="AXIS"?(r.visible=!!this.axis,this.axis==="X"&&(He.setFromEuler(wa.set(0,0,0)),r.quaternion.copy(s).multiply(He),Math.abs(Oe.copy(ro).applyQuaternion(s).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Y"&&(He.setFromEuler(wa.set(0,0,Math.PI/2)),r.quaternion.copy(s).multiply(He),Math.abs(Oe.copy(nn).applyQuaternion(s).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Z"&&(He.setFromEuler(wa.set(0,Math.PI/2,0)),r.quaternion.copy(s).multiply(He),Math.abs(Oe.copy(oo).applyQuaternion(s).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="XYZE"&&(He.setFromEuler(wa.set(0,Math.PI/2,0)),Oe.copy(this.rotationAxis),r.quaternion.setFromRotationMatrix(Qf.lookAt(Kf,Oe,nn)),r.quaternion.multiply(He),r.visible=this.dragging),this.axis==="E"&&(r.visible=!1)):r.name==="START"?(r.position.copy(this.worldPositionStart),r.visible=this.dragging):r.name==="END"?(r.position.copy(this.worldPosition),r.visible=this.dragging):r.name==="DELTA"?(r.position.copy(this.worldPositionStart),r.quaternion.copy(this.worldQuaternionStart),_t.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),_t.applyQuaternion(this.worldQuaternionStart.clone().invert()),r.scale.copy(_t),r.visible=this.dragging):(r.quaternion.copy(s),this.dragging?r.position.copy(this.worldPositionStart):r.position.copy(this.worldPosition),this.axis&&(r.visible=this.axis.search(r.name)!==-1));continue}r.quaternion.copy(s),this.mode==="translate"||this.mode==="scale"?(r.name==="X"&&Math.abs(Oe.copy(ro).applyQuaternion(s).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Y"&&Math.abs(Oe.copy(nn).applyQuaternion(s).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Z"&&Math.abs(Oe.copy(oo).applyQuaternion(s).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XY"&&Math.abs(Oe.copy(oo).applyQuaternion(s).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="YZ"&&Math.abs(Oe.copy(ro).applyQuaternion(s).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XZ"&&Math.abs(Oe.copy(nn).applyQuaternion(s).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1)):this.mode==="rotate"&&(Ma.copy(s),Oe.copy(this.eye).applyQuaternion(He.copy(s).invert()),r.name.search("E")!==-1&&r.quaternion.setFromRotationMatrix(Qf.lookAt(this.eye,Kf,nn)),r.name==="X"&&(He.setFromAxisAngle(ro,Math.atan2(-Oe.y,Oe.z)),He.multiplyQuaternions(Ma,He),r.quaternion.copy(He)),r.name==="Y"&&(He.setFromAxisAngle(nn,Math.atan2(Oe.x,Oe.z)),He.multiplyQuaternions(Ma,He),r.quaternion.copy(He)),r.name==="Z"&&(He.setFromAxisAngle(oo,Math.atan2(Oe.y,Oe.x)),He.multiplyQuaternions(Ma,He),r.quaternion.copy(He))),r.visible=r.visible&&(r.name.indexOf("X")===-1||this.showX),r.visible=r.visible&&(r.name.indexOf("Y")===-1||this.showY),r.visible=r.visible&&(r.name.indexOf("Z")===-1||this.showZ),r.visible=r.visible&&(r.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),r.material._color=r.material._color||r.material.color.clone(),r.material._opacity=r.material._opacity||r.material.opacity,r.material.color.copy(r.material._color),r.material.opacity=r.material._opacity,this.enabled&&this.axis&&(r.name===this.axis||this.axis.split("").some(function(l){return r.name===l}))&&(r.material.color.setHex(16776960),r.material.opacity=1)}super.updateMatrixWorld(e)}}class WN extends y.Mesh{constructor(){super(new y.PlaneGeometry(1e5,1e5,2,2),new y.MeshBasicMaterial({visible:!1,wireframe:!0,side:y.DoubleSide,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"),Ca.copy(ro).applyQuaternion(t==="local"?this.worldQuaternion:za),Zr.copy(nn).applyQuaternion(t==="local"?this.worldQuaternion:za),Kr.copy(oo).applyQuaternion(t==="local"?this.worldQuaternion:za),Oe.copy(Zr),this.mode){case"translate":case"scale":switch(this.axis){case"X":Oe.copy(this.eye).cross(Ca),Ns.copy(Ca).cross(Oe);break;case"Y":Oe.copy(this.eye).cross(Zr),Ns.copy(Zr).cross(Oe);break;case"Z":Oe.copy(this.eye).cross(Kr),Ns.copy(Kr).cross(Oe);break;case"XY":Ns.copy(Kr);break;case"YZ":Ns.copy(Ca);break;case"XZ":Oe.copy(Kr),Ns.copy(Zr);break;case"XYZ":case"E":Ns.set(0,0,0);break}break;case"rotate":default:Ns.set(0,0,0)}Ns.length()===0?this.quaternion.copy(this.cameraQuaternion):(Jf.lookAt(_t.set(0,0,0),Ns,Oe),this.quaternion.setFromRotationMatrix(Jf)),super.updateMatrixWorld(e)}}class mt extends y.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(ce.SET_SCENE,this.setScene)}clear(){for(const e of this.controls.values()){e.detach(),e.disconnect();const t=e.getHelper();Ls(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 IN(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:mt.DRAG_START})}),t.addEventListener("mouseUp",()=>{this.dispatchEvent({type:mt.DRAG_END})}),t.addEventListener("dragging-changed",i=>{tt.instance?.toggleOrbitControls(i.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(),Ls(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 mt._instance||(mt._instance=new mt),mt._instance}}const $N=new y.BoxGeometry,ch=new y.Vector2;class Ga extends y.Object3D{curve=new y.CatmullRomCurve3;line;draggable;curvePos;tension=.5;closed=!1;subdivide=50;curveType;offset=1;lineMaterial;_camera;_curvePercentage=0;_draggableScale=10;_transform;raycaster;draggedMat=new y.MeshBasicMaterial;parentGroup;group;constructor(e,t){const s=new y.Color(Pi(.5,1,Math.random()),Pi(.5,1,Math.random()),Pi(.5,1,Math.random()));super(),this.name=e,this.lineMaterial=new y.LineBasicMaterial({color:s}),this.line=new y.Line(new y.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 y.Object3D,this.draggable.name="draggablePoints",this.add(this.draggable),this.curvePos=new y.Mesh(new y.SphereGeometry(1.5),new y.MeshBasicMaterial({color:s})),this.curvePos.name="curvePos",this.curvePos.scale.setScalar(this._draggableScale),this.curvePos.visible=!1,this.add(this.curvePos),this.raycaster=new y.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),mt.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([is(t.position.x,3),is(t.position.y,3),is(t.position.z,3)])}),sm({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,i=new y.Mesh($N,this.draggedMat);i.name=`point_${s}`,i.position.copy(e),i.scale.setScalar(this._draggableScale),this.draggable.add(i),this._transform?.attach(i);const n=this.points.length>1;return n&&t&&this.updateSpline(),this.line.visible=n,this.updateCurrentPoint(),i};addNextPt=()=>{const e=this.draggable.children.length,t=e>1?this.draggable.children[e-1].position.clone():new y.Vector3,s=this.addPoint(t);this.group.current?.setField("Current Point",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.group.current?.setField("Current Point",t.position)}Ls(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 y.CatmullRomCurve3(this.points,this.closed,this.curveType,this.tension),this.line.geometry.dispose(),this.line.geometry=new y.BufferGeometry().setFromPoints(this.curve.getPoints(this.subdivide)),this.curvePos.position.copy(this.getPointAt(this._curvePercentage)))};onMouseClick=e=>{if(!tt.instance||!tt.instance.currentWindow||this._transform&&!this._transform.getHelper().visible)return;const s=tt.instance.currentWindow.current.getBoundingClientRect();ch.x=(e.clientX-s.x)/s.width*2-1,ch.y=-((e.clientY-s.y)/s.height)*2+1,this.raycaster.setFromCamera(ch,this.camera);const i=this.raycaster.intersectObjects(this.draggable.children,!1);if(i.length>0){const n=i[0].object;n!==this._transform?.object&&(this._transform?.attach(n),this.group.current?.setField("Current Point",n.position))}};getPointAt(e){return this.curve.points.length>1?this.curve.getPointAt(e):this.curve.points.length===1?this.curve.points[0]:new y.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.group.current?.setField("Current Point",e.position)}}onUpdateTransform=()=>{this.updateCurrentPoint(),this.updateSpline()};initDebug(e){const t=this.draggable.children;this.parentGroup=e,this._transform=mt.instance.add(this.name),this._transform.camera=this._camera,this._transform.addEventListener("objectChange",this.onUpdateTransform),t.length>0&&this._transform.attach(t[t.length-1]),tt.instance?.helpersContainer.add(this._transform.getHelper());const s=t.length>0?t[t.length-1].position:{x:0,y:0,z:0};this.group=e.addGroup({title:this.name,expanded:!0,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:s}],onUpdate:(i,n)=>{switch(i){case"Closed":this.closed=n,this.updateSpline();break;case"Visible":this.visible=n;break;case"Color":this.lineMaterial.color.setStyle(n),this.draggedMat.color.setStyle(n);break;case"Curve":this.curveType=n,this.updateSpline();break;case"Draggable Scale":this.draggableScale=n;break;case"Subdivide":this.subdivide=n,this.updateSpline();break;case"Tension":this.tension=n,this.updateSpline();break;case"New Pt Offset":this.offset=n;break;case"Curve At":this.curvePos.position.copy(this.getPointAt(n));break;case"Show Position":this.curvePos.visible=n;break;case"Show Points":this.draggable.visible=n;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,Ls(this);break;case"Current Point":if(this.group.current&&this._transform?.object){const r=this._transform?.object;r.name.search("point")>-1&&(r.position.copy(n),this.updateSpline())}break}}}),this.draggable.children.forEach(i=>{this.debugPoint(i)})}debugPoint=e=>{e.name,e.visible=this.draggable.visible}}let Ea=0;class Ky extends y.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(ce.ADD_SPLINE,this.onAddSpline)}initDebug(){this.group=_e.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(ce.ADD_SPLINE,this.onAddSpline),_e.removeEditorGroup(this.name)}addSpline(e){e.draggableScale=this.defaultScale,e.hideTransform(),this.group?.current!==null&&e.initDebug(this.group.current),this.add(e),this.currentSpline=e}createSpline=(e=[])=>{const t=`Spline ${Ea+1}`,s=new Ga(t,this._camera);return s.addPoints(e),this.addSpline(s),Ea++,s};createSplineFromArray=e=>{const t=[];return e.forEach(s=>{t.push(new y.Vector3(s[0],s[1],s[2]))}),this.createSpline(t)};createSplineFromCatmullRom=e=>this.createSpline(e.points);createSplineFromJSON=e=>{const t=[];e.points.forEach(i=>{t.push(new y.Vector3(i[0],i[1],i[2]))});const s=new Ga(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),s};showPoints=(e=!0)=>{this.children.forEach(t=>{t.showPoints(e)})};onAddSpline=e=>{const t=JSON.parse(e.value),s=`Spline ${Ea+1}`,i=[];t.points.forEach(r=>{i.push(new y.Vector3(r[0],r[1],r[2]))});const n=new Ga(s,this.camera);n.addPoints(i),this.addSpline(n),Ea++};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(),i=(e.clientX-s.left)/s.width*2-1,n=-((e.clientY-s.top)/s.height)*2+1;if(tt.instance){const a=new y.Raycaster;a.setFromCamera(new y.Vector2(i,n),this._camera);const l=a.intersectObjects(tt.instance.helpersContainer.children,!0);for(let c=0;c<l.length;c++){const h=l[c];if(!(h.object.isLine||h.object.isTransformControlsPlane)&&h.object.isObject3D)return}}this.currentSpline===null&&(this.currentSpline=this.createSpline());const r=this.mouseToSplinePos(i,n,s.width,s.height);this.currentSpline?.addPoint(r),this.isMouseDown=!0};onMouseMove=e=>{if(!this.isMouseDown)return;const s=e.target.getBoundingClientRect(),i=(e.clientX-s.left)/s.width*2-1,n=-((e.clientY-s.top)/s.height)*2+1,r=this.mouseToSplinePos(i,n,s.width,s.height);this.currentSpline?.updateLastPoint(r)};onMouseUp=()=>{this.isMouseDown=!1};mouseToSplinePos(e,t,s,i){const n=new y.Vector3,r=Math.PI/2,a=this._camera,l=a.zoom,c=a.rotation.x===-6123233995736766e-32&&a.rotation.y===0&&a.rotation.z===0,h=a.rotation.x===-Math.PI&&a.rotation.y===12246467991473532e-32&&a.rotation.z===Math.PI,u=a.rotation.x===-6162975822039155e-48&&a.rotation.y===-r&&a.rotation.z===0,d=a.rotation.x===-6162975822039155e-48&&a.rotation.y===r&&a.rotation.z===0,p=a.rotation.x===-1.5707953264174506&&a.rotation.y===0&&a.rotation.z===0,f=a.rotation.x===1.5707953264174506&&a.rotation.y===0&&a.rotation.z===0;let m=e,x=t;h||d?m*=-1:p&&(x*=-1);const g=s/2/l,_=i/2/l;if(this.currentSpline===null&&(this.currentSpline=this.createSpline()),c||h){const b=m*g+a.position.x,T=x*_+a.position.y;n.set(b,T,0)}else if(u||d){const b=m*g+a.position.z,T=x*_+a.position.y;n.set(0,T,b)}else if(p||f){const b=m*g+a.position.x,T=x*_+a.position.z;n.set(b,0,T)}return n}get camera(){return this._camera}set camera(e){this._camera=e,this.children.forEach(t=>{const s=t;s.camera=e})}}const em=["Single","Side by Side","Stacked","Quad"],jN="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",qN="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==",YN="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAQ0lEQVQ4jWP8////fwYqAxYozUhFM/8zkaKYWIWkGEq0b0ZdSjQY5i79TyWagRGaTUdzFEEw6lLqGzqwLoVVJ1StpwA9sBwbUqAh5gAAAABJRU5ErkJggg==";class tt extends W.Component{static instance=null;scene;renderer;currentScene;scenes=new Map;cameras=new Map;controls=new Map;currentCamera;currentWindow;helpersContainer=new y.Group;grid=new Xy;cameraHelpers=new Map;lightHelpers=new Map;interactionHelper=new y.AxesHelper(25);currentTransform;splineEditor;depthMaterial=new y.MeshDepthMaterial;normalsMaterial=new y.MeshNormalMaterial;uvMaterial=new Zy;wireframeMaterial=new y.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;selectedItem=void 0;debugCamera;raycaster=new y.Raycaster;pointer=new y.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(ce.ADD_RENDERER,this.setupRenderer),this.scene=new y.Scene,this.scene.name=this.scene.uuid="",this.canvasRef=W.createRef(),this.containerRef=W.createRef(),this.tlWindow=W.createRef(),this.trWindow=W.createRef(),this.blWindow=W.createRef(),this.brWindow=W.createRef();const t=e.three.name,s=localStorage,i=s.getItem(`${t}_mode`);this.state={mode:i!==null?i:"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 n={Vector2:y.Vector2,Vector3:y.Vector3,Vector4:y.Vector4,Quaternion:y.Quaternion,Matrix4:y.Matrix4,Spherical:y.Spherical,Box3:y.Box3,Sphere:y.Sphere,Raycaster:y.Raycaster};Ds.install({THREE:n}),this.setupScene(),this.setupTools();const r=localStorage.getItem(this.expandedCameraVisibility);r!==null&&(this.cameraVisibility=r==="open"),this.saveExpandedCameraVisibility();const a=localStorage.getItem(this.expandedLightVisibility);a!==null&&(this.lightVisibility=a==="open"),this.saveExpandedLightVisibility();const l=localStorage.getItem(this.expandedGridVisibility);l!==null&&(this.gridVisibility=l==="open"),this.grid.visible=this.gridVisibility,this.saveExpandedGridVisibility(),tt.instance=this}componentDidMount(){this.enable(),this.assignControls(),this.resize(),this.play(),mt.instance.setApp(this.props.three),mt.instance.activeCamera=this.debugCamera}componentDidUpdate(e,t,s){t.mode!==this.state.mode&&(this.assignControls(),this.resize())}componentWillUnmount(){this.disable(),this.clear(),_e.removeEditorGroup("View Settings")}render(){const e=[];return this.cameras.forEach((t,s)=>{e.push(s)}),E.jsxs("div",{className:"multiview",children:[E.jsx("canvas",{ref:this.canvasRef}),E.jsxs("div",{className:`cameras ${this.state.mode==="Single"||this.state.mode==="Stacked"?"single":""}`,ref:this.containerRef,children:[this.state.mode==="Single"&&E.jsx(E.Fragment,{children:E.jsx(Ki,{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")&&E.jsxs(E.Fragment,{children:[E.jsx(Ki,{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)}}),E.jsx(Ki,{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"&&E.jsxs(E.Fragment,{children:[E.jsx(Ki,{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)}}),E.jsx(Ki,{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)}}),E.jsx(Ki,{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)}}),E.jsx(Ki,{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)}})]})]}),E.jsxs("div",{className:"settings",children:[E.jsx(hl,{title:"View",index:em.indexOf(this.state.mode),options:em,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})}}),E.jsx(hl,{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})}}),E.jsx(oh,{name:"cameraHelper",icon:jN,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)}}}),E.jsx(oh,{name:"lightHelper",icon:qN,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)}}}),E.jsx(oh,{name:"gridHelper",icon:YN,selected:this.gridVisibility,height:21,width:21,onClick:t=>{this.setGridVisibility(t)}})]},this.state.lastUpdate)]})}setupRenderer=e=>{this.renderer&&this.renderer.dispose();const t=this.canvasRef.current;this.props.three.canvas=t;const s=e.value;s.type==="WebGLRenderer"?(this.renderer=new y.WebGLRenderer({canvas:t,stencil:!1}),this.grid.visible=!0):s.type==="WebGPURenderer"&&(this.renderer=new xa({canvas:t,stencil:!1}),this.grid.visible=!1),this.renderer&&(this.renderer.autoClear=!1,this.renderer.shadowMap.enabled=!0,this.renderer.setPixelRatio(devicePixelRatio),this.renderer.setClearColor(0),this.resize(),this.props.three.renderer=this.renderer)};setupScene(){this.helpersContainer.name="helpers",this.scene.add(this.helpersContainer),this.scene.add(this.grid),this.interactionHelper.name="interactionHelper",this.interactionHelper.visible=!1,this.helpersContainer.add(this.interactionHelper);const e=(n,r)=>{const a=new y.OrthographicCamera(-100,100,100,-100,0,3e3);return a.name=n,a.position.copy(r),a.lookAt(0,0,0),this.cameras.set(n,a),a},t=1e3;e("Top",new y.Vector3(0,t,0)),e("Bottom",new y.Vector3(0,-t,0)),e("Left",new y.Vector3(-t,0,0)),e("Right",new y.Vector3(t,0,0)),e("Front",new y.Vector3(0,0,t)),e("Back",new y.Vector3(0,0,-t)),e("Orthographic",new y.Vector3(t,t,t)),e("UI",new y.Vector3),this.debugCamera=new y.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,i=this.props.three.name;this.tlCam=this.cameras.get(s.getItem(`${i}_tlCam`)),this.trCam=this.cameras.get(s.getItem(`${i}_trCam`)),this.blCam=this.cameras.get(s.getItem(`${i}_blCam`)),this.brCam=this.cameras.get(s.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")),_e.addEditorGroup({title:"Editor",items:[{type:"number",prop:"Grid Position",value:this.grid.position.y}],onUpdate:(n,r)=>{switch(n){case"Grid Position":this.grid.position.y=r;break}}})}setupTools(){this.splineEditor=new Ky(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:ce.CLEAR_OBJECT}),_e.removeAllGroups(),this.clearLightHelpers(),this.clearControls(),this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),mt.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=void 0,mt.instance.clear(),this.cameras.forEach(e=>{this.editorCameras.indexOf(e.name)<0&&this.three.dispatchEvent({type:ce.REMOVE_CAMERA,value:e})}),this.currentCamera=this.debugCamera,this.currentScene=void 0,this.scenes.forEach(e=>{this.three.dispatchEvent({type:ce.REMOVE_SCENE,value:e})}),this.scenes.clear()}setGridVisibility(e){this.gridVisibility=e,this.saveExpandedGridVisibility(),this.grid.visible=e}update(){this.renderer&&(this.renderer instanceof y.WebGLRenderer?this.renderer?.clear():this.renderer instanceof xa&&this.renderer?.clearAsync()),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(){switch(this.renderer&&(this.renderer instanceof y.WebGLRenderer?this.renderer?.clear():this.renderer instanceof xa&&this.renderer?.clearAsync()),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(ce.ADD_SCENE,this.addScene),this.three.addEventListener(ce.SET_SCENE,this.sceneUpdate),this.three.addEventListener(ce.REMOVE_SCENE,this.removeScene),this.three.addEventListener(ce.ADD_CAMERA,this.addCamera),this.three.addEventListener(ce.REMOVE_CAMERA,this.removeCamera),this.three.addEventListener(ce.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(ce.ADD_SCENE,this.addScene),this.three.removeEventListener(ce.SET_SCENE,this.sceneUpdate),this.three.removeEventListener(ce.ADD_CAMERA,this.addCamera),this.three.removeEventListener(ce.REMOVE_CAMERA,this.removeCamera),this.three.removeEventListener(ce.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,i=this.height;switch(this.state.mode){case"Side by Side":s=e,i=this.height;break;case"Stacked":s=this.width,i=t;break;case"Quad":s=e,i=t;break}const n=s/i;this.cameras.forEach(r=>{r instanceof y.OrthographicCamera?(r.left=s/-2,r.right=s/2,r.top=i/2,r.bottom=i/-2,r.name==="UI"&&(r.position.x=this.width/2,r.position.y=this.height/-2,r.position.z=100),r.updateProjectionMatrix()):r instanceof y.PerspectiveCamera&&(r.aspect=n,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(()=>{Ls(s)},100),this.clearLightHelpers()};addCamera=e=>{const t=e.value,s=t.uuid,i=this.props.three.scene?.getObjectByProperty("uuid",t.uuid);if(i!==void 0){const n=i;this.cameras.set(s,n);const r=new y.CameraHelper(n);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,i=this.cameraHelpers.get(s);i!==void 0&&(this.helpersContainer.remove(i),i.dispose()),this.cameras.delete(s),this.setState({lastUpdate:Date.now()})};onMouseMove=e=>{const t=new y.Vector2;this.renderer?.getSize(t);const s=Math.min(e.clientX,t.x),i=Math.min(e.clientY,t.y);this.pointer.x=Ji(s,0,t.x,-1,1),this.pointer.y=Ji(i,0,t.y,1,-1);const n=t.x/2,r=t.y/2,a=()=>{s<n?this.pointer.x=Ji(s,0,n,-1,1):this.pointer.x=Ji(s,n,t.x,-1,1)},l=()=>{i<r?this.pointer.y=Ji(i,0,r,1,-1):this.pointer.y=Ji(i,r,t.y,1,-1)};switch(this.state.mode){case"Quad":a(),l();break;case"Side by Side":a();break;case"Stacked":l(),l();break}if(this.updateCamera(s,i,n,r),this.state.interactionMode==="Orbit"||this.currentScene===void 0)return;const c=this.raycaster.intersectObjects(this.currentScene.children);c.length>0&&this.interactionHelper.position.copy(c[0].point)};onClick=e=>{if(this.state.interactionMode==="Orbit"||this.currentScene===void 0)return;const t=new y.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 Ds(this.currentCamera,this.currentWindow.current),this.selectedItem instanceof y.Mesh||this.selectedItem instanceof y.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 Ds(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 Ds(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 Ds(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 Ds(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 Ds(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Wa(45),Wa(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),mt.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=mt.instance.add(e.value.name),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),Fl.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 y.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 y.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 fN(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 y.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 y.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 i=new gN(e,t);switch(i.enableDamping=!0,i.dampingFactor=.1,e.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":i.enableRotate=!1;break}this.controls.set(e.name,i)}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,i)=>{switch(this.state.mode){case"Quad":t<i?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<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),mt.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,i=new y.Clock;i.start(),this.selectedItem.getWorldPosition(e.target0);const n=()=>{const r=i.getDelta();this.cameraControls&&this.cameraControls.update(r),t&&(e.target.lerp(e.target0,s),e.object.position.lerp(e.position0,s),e.object.zoom=lr(e.object.zoom,e.zoom0,s),e.object.updateProjectionMatrix(),e.dispatchEvent({type:"change"})),i.getElapsedTime()>=.5?(cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.clearControls()):this.cameraControlsRafID=requestAnimationFrame(n)};n()};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,i,n,r){switch(n.name){case"Left":case"Right":this.grid.rotation.z=Math.PI/2;break;case"Front":case"Back":this.grid.rotation.x=Math.PI/2;break}this.scene.overrideMaterial=r,this.renderer&&(this.renderer?.setViewport(e,t,s,i),this.renderer?.setScissor(e,t,s,i),this.renderer instanceof y.WebGLRenderer?this.renderer?.render(this.scene,n):this.renderer instanceof xa&&this.renderer?.renderAsync(this.scene,n)),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),i=Math.floor(this.height/2);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 n=this.height-i;this.drawTo(0,n,this.width,i,this.tlCam,e),this.drawTo(0,0,this.width,i,this.trCam,t)}};drawQuad=()=>{const e=this.getSceneOverride(this.tlRender),t=this.getSceneOverride(this.trRender),s=this.getSceneOverride(this.blRender),i=this.getSceneOverride(this.brRender),n=Math.floor(this.width/2),r=Math.floor(this.height/2);let a=0,l=0;l=this.height-r,a=0,this.drawTo(a,l,n,r,this.tlCam,e),a=n,this.drawTo(a,l,n,r,this.trCam,t),l=0,a=0,this.scene.overrideMaterial=s,this.drawTo(a,l,n,r,this.blCam,s),a=n,this.drawTo(a,l,n,r,this.brCam,i)};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 Fl extends W.Component{static instance;matrix=new y.Matrix4;position=new y.Vector3;rotation=new y.Euler;scale=new y.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)),Fl.instance=this}update(){if(tt.instance){const e=tt.instance.selectedItem;if(e===void 0)return;this.position.x=is(e.position.x,3),this.position.y=is(e.position.y,3),this.position.z=is(e.position.z,3),this.rotation.copy(e.rotation),this.scale.x=is(e.scale.x,3),this.scale.y=is(e.scale.y,3),this.scale.z=is(e.scale.z,3),this.setState({lastUpdated:Date.now()})}}render(){return E.jsx(hs,{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 i=this.props.three.getScene(this.props.object.uuid);if(i){const n=i.getObjectByProperty("uuid",this.props.object.uuid);Ye(n,e,s)}};saveExpanded(){localStorage.setItem(this.expandedName,this.open?"open":"closed")}get expandedName(){return`${this.props.three.name}_transform`}}function tm(o){switch(o){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 o}function XN(o,e){function t(){return`${e.name}_light`}const s=localStorage.getItem(t()),i=s!==null?s==="open":!1;function n(a){localStorage.setItem(t(),a?"open":"closed")}const r=[];if(o.lightInfo!==void 0)for(const a in o.lightInfo){const l=o.lightInfo[a];l!==void 0&&(l.isColor!==void 0?r.push({title:tm(a),prop:a,type:"color",value:l,onChange:(c,h)=>{const u=new y.Color(h);e.updateObject(o.uuid,c,u);const d=e.getScene(o.uuid);if(d!==null){const p=d.getObjectByProperty("uuid",o.uuid);Ye(p,c,u)}}}):r.push({title:tm(a),prop:a,type:typeof l,value:l,step:typeof l=="number"?.01:void 0,onChange:(c,h)=>{e.updateObject(o.uuid,c,h);const u=e.getScene(o.uuid);if(u!==null){const d=u.getObjectByProperty("uuid",o.uuid);Ye(d,c,h)}}}))}return E.jsx(hs,{three:e,title:"Light",items:r,expanded:i,onToggle:a=>{n(a)}})}function ZN(o){const e=o.object,t=o.three;function s(){return`${t.name}_animation`}const i=localStorage.getItem(s()),n=i!==null?i==="open":!1;function r(d){localStorage.setItem(s(),d?"open":"closed")}const a=[],l=[];let c=0;e.animations.forEach(d=>{c=Math.max(c,d.duration),d.duration>0&&l.push({title:d.name,items:[{title:"Duration",type:"number",value:d.duration,disabled:!0},{title:"Blend Mode",type:"option",disabled:!0,options:[{title:"Normal",value:2500},{title:"Additive",value:2501}]}]})}),a.push({title:"Animations",items:l});let h;const u=t.getScene(e.uuid);if(u!==null){const d=u.getObjectByProperty("uuid",e.uuid);if(d!==void 0){const p=d.mixer;if(p!==void 0){const m=[{title:"Time Scale",type:"range",value:p.timeScale,step:.01,min:-1,max:2,onChange:(x,g)=>{p.timeScale=g,t.updateObject(e.uuid,"mixer.timeScale",g)}}];m.push({title:"Stop All",type:"button",onChange:()=>{p.stopAllAction(),t.requestMethod(e.uuid,"stopAllAction",void 0,"mixer")}}),a.push({title:"Mixer",items:m}),h=new y.SkeletonHelper(d),tt.instance?.scene.add(h)}}}return W.useEffect(()=>()=>{h!==void 0&&Ls(h)},[]),E.jsx(hs,{three:o.three,title:"Animation",items:a,expanded:n,onToggle:d=>{r(d)}})}const hh={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 Qy(o){const[e,t]=W.useState(hh);W.useEffect(()=>{function r(l){t(l.value)}function a(){t(hh)}return o.three.addEventListener(ce.CLEAR_OBJECT,a),o.three.addEventListener(ce.SET_SCENE,a),o.three.addEventListener(ce.SET_OBJECT,r),()=>{o.three.removeEventListener(ce.CLEAR_OBJECT,a),o.three.removeEventListener(ce.SET_SCENE,a),o.three.removeEventListener(ce.SET_OBJECT,r)}},[]);const s=e.type.toLowerCase(),i=e.animations.length>0||e.mixer!==void 0,n=s.search("mesh")>-1||s.search("line")>-1||s.search("points")>-1;return E.jsx(Qn,{three:o.three,label:"Inspector",button:e.uuid.length>0?E.jsx("button",{className:"remove",onClick:()=>{mt.instance.remove(e.name),t(hh)}}):void 0,children:E.jsx("div",{id:"Inspector",className:o.class,children:e.uuid.length>0&&E.jsxs(E.Fragment,{children:[E.jsxs(E.Fragment,{children:[E.jsx(Ra,{type:"string",title:"Name",prop:"name",value:e.name,disabled:!0}),E.jsx(Ra,{type:"string",title:"Type",prop:"type",value:e.type,disabled:!0}),E.jsx(Ra,{type:"string",title:"UUID",prop:"uuid",value:e.uuid,disabled:!0})]}),E.jsxs(E.Fragment,{children:[E.jsx(Fl,{object:e,three:o.three}),i?E.jsx(ZN,{object:e,three:o.three}):null,s.search("camera")>-1?T_(e,o.three):null,s.search("light")>-1?XN(e,o.three):null,n?x_(e,o.three):null]})]})})},"Inspector")}class KN extends W.Component{autoClear=!0;autoClearColor=!0;autoClearDepth=!0;autoClearStencil=!0;outputColorSpace=y.SRGBColorSpace;localClippingEnabled=!1;clearColor=new y.Color(0);clearAlpha=1;toneMapping=y.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),tt.instance){const i=tt.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 y.WebGLRenderer&&(this.localClippingEnabled=i.localClippingEnabled,i.getClearColor(this.clearColor)))}this.props.three.addEventListener(ce.ADD_RENDERER,this.onAddRenderer)}componentwillunmount(){this.props.three.removeEventListener(ce.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,y.LinearSRGBColorSpace),y.ColorManagement.enabled=t.colorManagement,tt.instance){const s=tt.instance.renderer;s&&(s.autoClearColor=this.autoClearColor,s.outputColorSpace=this.outputColorSpace,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(tt.instance){const t=tt.instance.renderer;t&&(t.autoClearColor=this.autoClearColor,t.outputColorSpace=this.outputColorSpace,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:y.ColorManagement.enabled,toneMapping:this.toneMapping,toneMappingExposure:this.toneMappingExposure}))}};return E.jsx(hs,{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:y.ColorManagement.enabled,onChange:(t,s)=>{y.ColorManagement.enabled=s,e()}},{type:"option",title:"Color Space",value:this.outputColorSpace,options:[{title:"No Color Space",value:y.NoColorSpace},{title:"SRB Color Space",value:y.SRGBColorSpace},{title:"Linear SRB Color Space",value:y.LinearSRGBColorSpace}],onChange:(t,s)=>{this.outputColorSpace=s,e()}},{type:"option",title:"Tone Mapping",value:this.toneMapping,options:[{title:"None ",value:y.NoToneMapping},{title:"Linear ",value:y.LinearToneMapping},{title:"Reinhard",value:y.ReinhardToneMapping},{title:"Cineon ",value:y.CineonToneMapping},{title:"ACES Filmic",value:y.ACESFilmicToneMapping},{title:"AgX",value:y.AgXToneMapping},{title:"Neutral",value:y.NeutralToneMapping},{title:"Custom",value:y.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 Jy(o){const[e]=W.useState([]),[t]=W.useState([]),[s,i]=W.useState(0),n=c=>{const h=c.value;e.push(h),t.push(E.jsx(Qn,{three:o.three,label:`Scene: ${h.name}`,scene:h,open:!1,visible:!1,onRefresh:()=>{o.three.refreshScene(h.name)},children:E.jsx(Aa,{child:h,scene:h,three:o.three})},h.name)),i(Date.now())},r=c=>{const h=c.value;for(let u=0;u<e.length;u++)if(h.uuid===e[u].uuid){e[u]=h,t[u]=E.jsx(Qn,{three:o.three,label:`Scene: ${h.name}`,scene:h,open:t[u].props.open,visible:t[u].props.visible,onRefresh:()=>{o.three.refreshScene(h.name)},children:E.jsx(Aa,{child:h,scene:h,three:o.three})},h.name),i(Date.now());return}},a=c=>{const h=c.value;for(let u=0;u<e.length;u++)if(h.uuid===e[u].uuid){e.splice(u,1),t.splice(u,1),i(Date.now());return}},l=c=>{const h=c.value.name;for(let u=0;u<e.length;u++){const d=e[u];if(d.name===h){t[u]=E.jsx(Qn,{three:o.three,label:`Scene: ${d.name}`,scene:d,open:!0,visible:!0,onRefresh:()=>{o.three.refreshScene(d.name)},children:E.jsx(Aa,{child:d,scene:d,three:o.three})},d.name);break}}i(Date.now())};return W.useEffect(()=>(o.three.addEventListener(ce.ADD_SCENE,n),o.three.addEventListener(ce.SET_SCENE,l),o.three.addEventListener(ce.REFRESH_SCENE,r),o.three.addEventListener(ce.REMOVE_SCENE,a),()=>{o.three.removeEventListener(ce.ADD_SCENE,n),o.three.removeEventListener(ce.SET_SCENE,l),o.three.removeEventListener(ce.REFRESH_SCENE,r),o.three.removeEventListener(ce.REMOVE_SCENE,a)}),[]),E.jsxs("div",{id:"SidePanel",children:[E.jsx("div",{className:"scenes",children:t},s),E.jsx(Qy,{three:o.three}),E.jsx(KN,{three:o.three}),E.jsx(_e,{three:o.three})]})}function e0(o){return E.jsxs("div",{className:"editor",ref:o.ref,style:o.style,children:[E.jsx("div",{className:"header",children:o.header}),o.children,E.jsx("div",{className:"footer",children:o.footer})]})}function QN(o){return E.jsx(e0,{children:E.jsxs(E.Fragment,{children:[E.jsx(tt,{three:o.three,scenes:o.scenes,onSceneAdd:o.onSceneAdd,onSceneResize:o.onSceneResize,onSceneUpdate:o.onSceneUpdate}),E.jsx(Jy,{three:o.three})]})})}exports.Accordion=Qn;exports.Application=Ex;exports.BaseRemote=Kh;exports.ChildObject=Jh;exports.ContainerObject=Aa;exports.Draggable=mm;exports.DraggableItem=fm;exports.Dropdown=gm;exports.DropdownItem=ym;exports.Editor=e0;exports.ElementProxy=Mx;exports.ElementProxyReceiver=dm;exports.ExportTexture=Ni;exports.InfiniteGridHelper=Xy;exports.InfiniteGridMaterial=Yy;exports.Inspector=Qy;exports.MultiView=tt;exports.NavButton=Qh;exports.ProxyManager=Cx;exports.RemoteTheatre=Nx;exports.RemoteThree=Ix;exports.SidePanel=Jy;exports.Spline=Ga;exports.SplineEditor=Ky;exports.ThreeEditor=QN;exports.Transform=mt;exports.UVMaterial=Zy;exports.WebworkerEventHandlers=vx;exports.anchorGeometry=hm;exports.anchorGeometryTL=ix;exports.animateObjectMaterial=J0;exports.animateObjectTransform=K0;exports.applyObjectMaterial=cm;exports.capitalize=yo;exports.clamp=Si;exports.clearComposerGroups=fx;exports.colorToHex=uh;exports.copyToClipboard=sm;exports.createMask=ax;exports.cubicBezier=q0;exports.customizeTheatreElements=Z0;exports.damp=G0;exports.defaultTheatreCallback=D0;exports.detectMaxFrameRate=rm;exports.detectSettings=om;exports.dispose=Ls;exports.disposeMaterial=Xh;exports.disposeTexture=dh;exports.distance=z0;exports.generateCubemap=mx;exports.getAngle=V0;exports.getObjectMaterialObject=lm;exports.getObjectMaterialProps=am;exports.hierarchyUUID=Ha;exports.inspectComposer=px;exports.inspectComposerPass=um;exports.isColor=im;exports.map=k0;exports.mix=lr;exports.noop=go;exports.normalize=Va;exports.orthoCamera=ex;exports.parseModelLite=tx;exports.randomID=ht;exports.renderToTexture=sx;exports.resetThreeObjects=ph;exports.rgbaToHex=Y0;exports.roundTo=is;exports.setMaterialBlendAdd=hx;exports.setMaterialBlendMultiply=ux;exports.setMaterialBlendNormal=cx;exports.setMaterialBlendScreen=dx;exports.supportsOffscreenCanvas=ox;exports.triangle=ul;exports.updateCameraOrtho=nx;exports.updateCameraOrtho16x9=rx;exports.useMask=lx;exports.useStudio=X0;
|
package/dist/hermes.es.js
CHANGED
|
@@ -43620,7 +43620,7 @@ class ut extends qa {
|
|
|
43620
43620
|
const e = (n, r) => {
|
|
43621
43621
|
const o = new dl(-100, 100, 100, -100, 0, 3e3);
|
|
43622
43622
|
return o.name = n, o.position.copy(r), o.lookAt(0, 0, 0), this.cameras.set(n, o), o;
|
|
43623
|
-
}, t =
|
|
43623
|
+
}, t = 1e3;
|
|
43624
43624
|
e("Top", new Z(0, t, 0)), e("Bottom", new Z(0, -t, 0)), e("Left", new Z(-t, 0, 0)), e("Right", new Z(t, 0, 0)), e("Front", new Z(0, 0, t)), e("Back", new Z(0, 0, -t)), e("Orthographic", new Z(t, t, t)), e("UI", new Z()), this.debugCamera = new tp(60, 1, 0.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;
|
|
43625
43625
|
const s = localStorage, i = this.props.three.name;
|
|
43626
43626
|
this.tlCam = this.cameras.get(s.getItem(`${i}_tlCam`)), this.trCam = this.cameras.get(s.getItem(`${i}_trCam`)), this.blCam = this.cameras.get(s.getItem(`${i}_blCam`)), this.brCam = this.cameras.get(s.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")), _e.addEditorGroup({
|
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.15",
|
|
11
11
|
"homepage": "https://github.com/tomorrowevening/hermes#readme",
|
|
12
12
|
"bugs": {
|
|
13
13
|
"url": "https://github.com/tomorrowevening/hermes/issues"
|