@tomorrowevening/hermes 0.0.103 → 0.0.104
Sign up to get free protection for your applications and to get access to all the features.
package/dist/hermes.cjs.js
CHANGED
@@ -146,4 +146,4 @@ void main() {
|
|
146
146
|
void main() {
|
147
147
|
#include <clipping_planes_fragment>
|
148
148
|
gl_FragColor = vec4(vec3(vUv, 0.0), 1.0);
|
149
|
-
}`;class Jn extends o.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:qn,fragmentShader:Kn})}}const ke=new o.Raycaster,ie=new o.Vector3,we=new o.Vector3,G=new o.Quaternion,Gi={X:new o.Vector3(1,0,0),Y:new o.Vector3(0,1,0),Z:new o.Vector3(0,0,1)},ei={type:"change"},Zi={type:"mouseDown",mode:null},Wi={type:"mouseUp",mode:null},Xi={type:"objectChange"};class er extends o.Controls{constructor(e,t=null){super(void 0,t);const i=new ar(this);this._root=i;const n=new or;this._gizmo=n,i.add(n);const a=new lr;this._plane=a,i.add(a);const r=this;function l(C,E){let P=E;Object.defineProperty(r,C,{get:function(){return P!==void 0?P:E},set:function(O){P!==O&&(P=O,a[C]=O,n[C]=O,r.dispatchEvent({type:C+"-changed",value:O}),r.dispatchEvent(ei))}}),r[C]=E,a[C]=E,n[C]=E}l("camera",e),l("object",void 0),l("enabled",!0),l("axis",null),l("mode","translate"),l("translationSnap",null),l("rotationSnap",null),l("scaleSnap",null),l("space","world"),l("size",1),l("dragging",!1),l("showX",!0),l("showY",!0),l("showZ",!0);const h=new o.Vector3,d=new o.Vector3,p=new o.Quaternion,m=new o.Quaternion,g=new o.Vector3,y=new o.Quaternion,x=new o.Vector3,M=new o.Vector3,T=new o.Vector3,_=0,v=new o.Vector3;l("worldPosition",h),l("worldPositionStart",d),l("worldQuaternion",p),l("worldQuaternionStart",m),l("cameraPosition",g),l("cameraQuaternion",y),l("pointStart",x),l("pointEnd",M),l("rotationAxis",T),l("rotationAngle",_),l("eye",v),this._offset=new o.Vector3,this._startNorm=new o.Vector3,this._endNorm=new o.Vector3,this._cameraScale=new o.Vector3,this._parentPosition=new o.Vector3,this._parentQuaternion=new o.Quaternion,this._parentQuaternionInv=new o.Quaternion,this._parentScale=new o.Vector3,this._worldScaleStart=new o.Vector3,this._worldQuaternionInv=new o.Quaternion,this._worldScale=new o.Vector3,this._positionStart=new o.Vector3,this._quaternionStart=new o.Quaternion,this._scaleStart=new o.Vector3,this._getPointer=tr.bind(this),this._onPointerDown=sr.bind(this),this._onPointerHover=ir.bind(this),this._onPointerMove=nr.bind(this),this._onPointerUp=rr.bind(this),t!==null&&this.connect()}connect(){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&&ke.setFromCamera(e,this.camera);const t=ti(this._gizmo.picker[this.mode],ke);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&&ke.setFromCamera(e,this.camera);const t=ti(this._plane,ke,!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,Zi.mode=this.mode,this.dispatchEvent(Zi)}}pointerMove(e){const t=this.axis,i=this.mode,n=this.object;let a=this.space;if(i==="scale"?a="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(a="world"),n===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&ke.setFromCamera(e,this.camera);const r=ti(this._plane,ke,!0);if(r){if(this.pointEnd.copy(r.point).sub(this.worldPositionStart),i==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),a==="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),a==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),n.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(a==="local"&&(n.position.applyQuaternion(G.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this._quaternionStart)),a==="world"&&(n.parent&&n.position.add(ie.setFromMatrixPosition(n.parent.matrixWorld)),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.parent&&n.position.sub(ie.setFromMatrixPosition(n.parent.matrixWorld))));else if(i==="scale"){if(t.search("XYZ")!==-1){let l=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(l*=-1),we.set(l,l,l)}else ie.copy(this.pointStart),we.copy(this.pointEnd),ie.applyQuaternion(this._worldQuaternionInv),we.applyQuaternion(this._worldQuaternionInv),we.divide(ie),t.search("X")===-1&&(we.x=1),t.search("Y")===-1&&(we.y=1),t.search("Z")===-1&&(we.z=1);n.scale.copy(this._scaleStart).multiply(we),this.scaleSnap&&(t.search("X")!==-1&&(n.scale.x=Math.round(n.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(n.scale.y=Math.round(n.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(n.scale.z=Math.round(n.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(i==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const l=20/this.worldPosition.distanceTo(ie.setFromMatrixPosition(this.camera.matrixWorld));let h=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(ie.copy(this.rotationAxis).cross(this.eye))*l):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(Gi[t]),ie.copy(Gi[t]),a==="local"&&ie.applyQuaternion(this.worldQuaternion),ie.cross(this.eye),ie.length()===0?h=!0:this.rotationAngle=this._offset.dot(ie.normalize())*l),(t==="E"||h)&&(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),a==="local"&&t!=="E"&&t!=="XYZE"?(n.quaternion.copy(this._quaternionStart),n.quaternion.multiply(G.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(G.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(ei),this.dispatchEvent(Xi)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(Wi.mode=this.mode,this.dispatchEvent(Wi)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.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(ei),this.dispatchEvent(Xi),this.pointStart.copy(this.pointEnd))}getRaycaster(){return ke}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 tr(s){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:s.button};{const e=this.domElement.getBoundingClientRect();return{x:(s.clientX-e.left)/e.width*2-1,y:-(s.clientY-e.top)/e.height*2+1,button:s.button}}}function ir(s){if(this.enabled)switch(s.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(s));break}}function sr(s){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(s.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(s)),this.pointerDown(this._getPointer(s)))}function nr(s){this.enabled&&this.pointerMove(this._getPointer(s))}function rr(s){this.enabled&&(this.domElement.releasePointerCapture(s.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(s)))}function ti(s,e,t){const i=e.intersectObject(s,!0);for(let n=0;n<i.length;n++)if(i[n].object.visible||t)return i[n];return!1}const xt=new o.Euler,V=new o.Vector3(0,1,0),Qi=new o.Vector3(0,0,0),$i=new o.Matrix4,Ot=new o.Quaternion,Rt=new o.Quaternion,ye=new o.Vector3,qi=new o.Matrix4,lt=new o.Vector3(1,0,0),Ue=new o.Vector3(0,1,0),ct=new o.Vector3(0,0,1),Tt=new o.Vector3,rt=new o.Vector3,at=new o.Vector3;class ar extends o.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)}}class or extends o.Object3D{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new o.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new o.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=e.clone();i.opacity=.15;const n=t.clone();n.opacity=.5;const a=e.clone();a.color.setHex(16711680);const r=e.clone();r.color.setHex(65280);const l=e.clone();l.color.setHex(255);const h=e.clone();h.color.setHex(16711680),h.opacity=.5;const d=e.clone();d.color.setHex(65280),d.opacity=.5;const p=e.clone();p.color.setHex(255),p.opacity=.5;const m=e.clone();m.opacity=.25;const g=e.clone();g.color.setHex(16776960),g.opacity=.25,e.clone().color.setHex(16776960);const x=e.clone();x.color.setHex(7895160);const M=new o.CylinderGeometry(0,.04,.1,12);M.translate(0,.05,0);const T=new o.BoxGeometry(.08,.08,.08);T.translate(0,.04,0);const _=new o.BufferGeometry;_.setAttribute("position",new o.Float32BufferAttribute([0,0,0,1,0,0],3));const v=new o.CylinderGeometry(.0075,.0075,.5,3);v.translate(0,.25,0);function C(X,Me){const ne=new o.TorusGeometry(X,.0075,3,64,Me*Math.PI*2);return ne.rotateY(Math.PI/2),ne.rotateX(Math.PI/2),ne}function E(){const X=new o.BufferGeometry;return X.setAttribute("position",new o.Float32BufferAttribute([0,0,0,1,1,1],3)),X}const P={X:[[new o.Mesh(M,a),[.5,0,0],[0,0,-Math.PI/2]],[new o.Mesh(M,a),[-.5,0,0],[0,0,Math.PI/2]],[new o.Mesh(v,a),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new o.Mesh(M,r),[0,.5,0]],[new o.Mesh(M,r),[0,-.5,0],[Math.PI,0,0]],[new o.Mesh(v,r)]],Z:[[new o.Mesh(M,l),[0,0,.5],[Math.PI/2,0,0]],[new o.Mesh(M,l),[0,0,-.5],[-Math.PI/2,0,0]],[new o.Mesh(v,l),null,[Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.OctahedronGeometry(.1,0),m.clone()),[0,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),p.clone()),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),h.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),d.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},O={X:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,.3,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.OctahedronGeometry(.2,0),i)]],XY:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},j={START:[[new o.Mesh(new o.OctahedronGeometry(.01,2),n),null,null,null,"helper"]],END:[[new o.Mesh(new o.OctahedronGeometry(.01,2),n),null,null,null,"helper"]],DELTA:[[new o.Line(E(),n),null,null,null,"helper"]],X:[[new o.Line(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new o.Line(_,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new o.Line(_,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},W={XYZE:[[new o.Mesh(C(.5,1),x),null,[0,Math.PI/2,0]]],X:[[new o.Mesh(C(.5,.5),a)]],Y:[[new o.Mesh(C(.5,.5),r),null,[0,0,-Math.PI/2]]],Z:[[new o.Mesh(C(.5,.5),l),null,[0,Math.PI/2,0]]],E:[[new o.Mesh(C(.75,1),g),null,[0,Math.PI/2,0]]]},he={AXIS:[[new o.Line(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},Se={XYZE:[[new o.Mesh(new o.SphereGeometry(.25,10,8),i)]],X:[[new o.Mesh(new o.TorusGeometry(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new o.Mesh(new o.TorusGeometry(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new o.Mesh(new o.TorusGeometry(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new o.Mesh(new o.TorusGeometry(.75,.1,2,24),i)]]},Qe={X:[[new o.Mesh(T,a),[.5,0,0],[0,0,-Math.PI/2]],[new o.Mesh(v,a),[0,0,0],[0,0,-Math.PI/2]],[new o.Mesh(T,a),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(T,r),[0,.5,0]],[new o.Mesh(v,r)],[new o.Mesh(T,r),[0,-.5,0],[0,0,Math.PI]]],Z:[[new o.Mesh(T,l),[0,0,.5],[Math.PI/2,0,0]],[new o.Mesh(v,l),[0,0,0],[Math.PI/2,0,0]],[new o.Mesh(T,l),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),p),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),h),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),d),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.BoxGeometry(.1,.1,.1),m.clone())]]},Fe={X:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,.3,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.2),i),[0,0,0]]]},ce={X:[[new o.Line(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new o.Line(_,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new o.Line(_,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function J(X){const Me=new o.Object3D;for(const ne in X)for(let Ee=X[ne].length;Ee--;){const te=X[ne][Ee][0].clone(),Pe=X[ne][Ee][1],Re=X[ne][Ee][2],De=X[ne][Ee][3],pt=X[ne][Ee][4];te.name=ne,te.tag=pt,Pe&&te.position.set(Pe[0],Pe[1],Pe[2]),Re&&te.rotation.set(Re[0],Re[1],Re[2]),De&&te.scale.set(De[0],De[1],De[2]),te.updateMatrix();const mt=te.geometry.clone();mt.applyMatrix4(te.matrix),te.geometry=mt,te.renderOrder=1/0,te.position.set(0,0,0),te.rotation.set(0,0,0),te.scale.set(1,1,1),Me.add(te)}return Me}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=J(P)),this.add(this.gizmo.rotate=J(W)),this.add(this.gizmo.scale=J(Qe)),this.add(this.picker.translate=J(O)),this.add(this.picker.rotate=J(Se)),this.add(this.picker.scale=J(Fe)),this.add(this.helper.translate=J(j)),this.add(this.helper.rotate=J(he)),this.add(this.helper.scale=J(ce)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const i=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:Rt;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 n=[];n=n.concat(this.picker[this.mode].children),n=n.concat(this.gizmo[this.mode].children),n=n.concat(this.helper[this.mode].children);for(let a=0;a<n.length;a++){const r=n[a];r.visible=!0,r.rotation.set(0,0,0),r.position.copy(this.worldPosition);let l;if(this.camera.isOrthographicCamera?l=(this.camera.top-this.camera.bottom)/this.camera.zoom:l=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),r.scale.set(1,1,1).multiplyScalar(l*this.size/4),r.tag==="helper"){r.visible=!1,r.name==="AXIS"?(r.visible=!!this.axis,this.axis==="X"&&(G.setFromEuler(xt.set(0,0,0)),r.quaternion.copy(i).multiply(G),Math.abs(V.copy(lt).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Y"&&(G.setFromEuler(xt.set(0,0,Math.PI/2)),r.quaternion.copy(i).multiply(G),Math.abs(V.copy(Ue).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Z"&&(G.setFromEuler(xt.set(0,Math.PI/2,0)),r.quaternion.copy(i).multiply(G),Math.abs(V.copy(ct).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="XYZE"&&(G.setFromEuler(xt.set(0,Math.PI/2,0)),V.copy(this.rotationAxis),r.quaternion.setFromRotationMatrix($i.lookAt(Qi,V,Ue)),r.quaternion.multiply(G),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),ie.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),ie.applyQuaternion(this.worldQuaternionStart.clone().invert()),r.scale.copy(ie),r.visible=this.dragging):(r.quaternion.copy(i),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(i),this.mode==="translate"||this.mode==="scale"?(r.name==="X"&&Math.abs(V.copy(lt).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Y"&&Math.abs(V.copy(Ue).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Z"&&Math.abs(V.copy(ct).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XY"&&Math.abs(V.copy(ct).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="YZ"&&Math.abs(V.copy(lt).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XZ"&&Math.abs(V.copy(Ue).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1)):this.mode==="rotate"&&(Ot.copy(i),V.copy(this.eye).applyQuaternion(G.copy(i).invert()),r.name.search("E")!==-1&&r.quaternion.setFromRotationMatrix($i.lookAt(this.eye,Qi,Ue)),r.name==="X"&&(G.setFromAxisAngle(lt,Math.atan2(-V.y,V.z)),G.multiplyQuaternions(Ot,G),r.quaternion.copy(G)),r.name==="Y"&&(G.setFromAxisAngle(Ue,Math.atan2(V.x,V.z)),G.multiplyQuaternions(Ot,G),r.quaternion.copy(G)),r.name==="Z"&&(G.setFromAxisAngle(ct,Math.atan2(V.y,V.x)),G.multiplyQuaternions(Ot,G),r.quaternion.copy(G))),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(h){return r.name===h}))&&(r.material.color.setHex(16776960),r.material.opacity=1)}super.updateMatrixWorld(e)}}class lr extends o.Mesh{constructor(){super(new o.PlaneGeometry(1e5,1e5,2,2),new o.MeshBasicMaterial({visible:!1,wireframe:!0,side:o.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"),Tt.copy(lt).applyQuaternion(t==="local"?this.worldQuaternion:Rt),rt.copy(Ue).applyQuaternion(t==="local"?this.worldQuaternion:Rt),at.copy(ct).applyQuaternion(t==="local"?this.worldQuaternion:Rt),V.copy(rt),this.mode){case"translate":case"scale":switch(this.axis){case"X":V.copy(this.eye).cross(Tt),ye.copy(Tt).cross(V);break;case"Y":V.copy(this.eye).cross(rt),ye.copy(rt).cross(V);break;case"Z":V.copy(this.eye).cross(at),ye.copy(at).cross(V);break;case"XY":ye.copy(at);break;case"YZ":ye.copy(Tt);break;case"XZ":V.copy(at),ye.copy(rt);break;case"XYZ":case"E":ye.set(0,0,0);break}break;case"rotate":default:ye.set(0,0,0)}ye.length()===0?this.quaternion.copy(this.cameraQuaternion):(qi.lookAt(ie.set(0,0,0),ye,V),this.quaternion.setFromRotationMatrix(qi)),super.updateMatrixWorld(e)}}class le extends o.EventDispatcher{static DRAG_START="Transform::dragStart";static DRAG_END="Transform::dragEnd";static _instance;three;activeCamera;controls=new Map;visibility=new Map;groups=[];clear(){for(const e of this.controls.values()){e.detach(),e.dispose();const t=e.getHelper();t.parent?.remove(t)}this.controls=new Map,this.visibility=new Map}add(e){let t=this.controls.get(e);if(t===void 0){const i=document.querySelector(".clickable");t=new er(this.activeCamera,i),t.getHelper().name=e,t.setSpace("local"),this.controls.set(e,t),this.visibility.set(e,!0),t.addEventListener("mouseDown",()=>{this.dispatchEvent({type:le.DRAG_START})}),t.addEventListener("mouseUp",()=>{this.dispatchEvent({type:le.DRAG_END})}),t.addEventListener("dragging-changed",a=>{be.instance?.toggleOrbitControls(a.value)});const n=`Controls: ${e}`;this.groups.push(n),this.three.addGroup({title:n,items:[{type:"boolean",prop:"enabled",value:t.enabled},{type:"boolean",prop:"visible",value:!0},{type:"button",prop:"Reset"},{type:"option",prop:"Mode",options:[{title:"Translate",value:"translate"},{title:"Rotate",value:"rotate"},{title:"Scale",value:"scale"}]},{type:"option",prop:"Space",options:[{title:"World",value:"world"},{title:"Local",value:"local"}]}],onUpdate:(a,r)=>{if(t!==void 0)switch(a){case"enabled":t.enabled=r;break;case"visible":t.getHelper().visible=r;break;case"Reset":t.reset();break;case"Mode":t.setMode(r);break;case"Space":t.setSpace(r);break}}})}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(),Te(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(i=>{i.camera!==e&&(i.camera=e,e.getWorldPosition(i.cameraPosition),e.getWorldQuaternion(i.cameraQuaternion)),i.domElement!==t&&(i.disconnect(),i.domElement=t,i.connect())})}show(){this.controls.forEach(e=>{const t=e.getHelper(),i=this.visibility.get(t.name);i!==void 0&&(t.visible=i)})}hide(){this.controls.forEach(e=>{const t=e.getHelper();this.visibility.set(t.name,t.visible),t.visible=!1})}static get instance(){return le._instance||(le._instance=new le),le._instance}}const cr=new o.BoxGeometry,ii=new o.Vector2;class Ki extends o.Object3D{curve=new o.CatmullRomCurve3;line;draggable;curvePos;tension=.5;closed=!1;subdivide=50;curveType;offset=1;lineMaterial;_camera;_curvePercentage=0;_draggableScale=10;_transform;raycaster;draggedMat=new o.MeshBasicMaterial;parentGroup;group;constructor(e,t){const i=new o.Color(Ve(.5,1,Math.random()),Ve(.5,1,Math.random()),Ve(.5,1,Math.random()));super(),this.name=e,this.lineMaterial=new o.LineBasicMaterial({color:i}),this.line=new o.Line(new o.BufferGeometry,this.lineMaterial),this.line.name="line",this.add(this.line),this._camera=t,this.curveType="catmullrom",this.draggedMat.color=i,this.draggable=new o.Object3D,this.draggable.name="draggablePoints",this.add(this.draggable),this.curvePos=new o.Mesh(new o.SphereGeometry(1.5),new o.MeshBasicMaterial({color:i})),this.curvePos.name="curvePos",this.curvePos.scale.setScalar(this._draggableScale),this.curvePos.visible=!1,this.add(this.curvePos),this.raycaster=new o.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),le.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([pe(t.position.x,3),pe(t.position.y,3),pe(t.position.z,3)])}),is({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 i=0;i<t;i++)this.addPoint(e[i],!1);this.addPoint(e[t])}else this.addPoint(new o.Vector3(-50,0,0),!1),this.addPoint(new o.Vector3(50,0,0))};addPoint=(e,t=!0)=>{const i=this.draggable.children.length,n=new o.Mesh(cr,this.draggedMat);return n.name=`point_${i}`,n.position.copy(e),n.scale.setScalar(this._draggableScale),this.draggable.add(n),t&&this.updateSpline(),n};addNextPt=()=>{const e=this.draggable.children.length,t=new o.Vector3(Ve(-this.offset,this.offset,Math.random()),Ve(-this.offset,this.offset,Math.random()),Ve(-this.offset,this.offset,Math.random()));e>0&&t.add(this.draggable.children[e-1].position);const i=this.addPoint(t);this._transform?.attach(i),this.group.current?.setField("Current Point",i.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)}Te(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)};updateSpline=()=>{this.curve=new o.CatmullRomCurve3(this.points,this.closed,this.curveType,this.tension),this.line.geometry.setFromPoints(this.getPoints()),this.curvePos.position.copy(this.getPointAt(this._curvePercentage))};onMouseClick=e=>{if(!be.instance||this._transform&&!this._transform.getHelper().visible)return;const i=be.instance.currentWindow.current.getBoundingClientRect();ii.x=(e.clientX-i.x)/i.width*2-1,ii.y=-((e.clientY-i.y)/i.height)*2+1,this.raycaster.setFromCamera(ii,this.camera);const n=this.raycaster.intersectObjects(this.draggable.children,!1);if(n.length>0){const a=n[0].object;a!==this._transform?.object&&(this._transform?.attach(a),this.group.current?.setField("Current Point",a.position))}};getPointAt(e){return this.curve.getPointAt(e)}getPoints(){return this.curve.getPoints(this.subdivide)}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))}onUpdateTransform=()=>{if(this._transform?.object&&this.group){const e=this._transform?.object;e.name.search("point")>-1&&this.group.current?.setField("Current Point",e.position)}this.updateSpline()};initDebug(e){const t=this.draggable.children;this.parentGroup=e,this._transform=le.instance.add(this.name),this._transform.camera=this._camera,this._transform.addEventListener("objectChange",this.onUpdateTransform),this._transform.attach(t.length>0?t[t.length-1]:this),be.instance?.scene.add(this._transform.getHelper());const i=t.length>0?t[t.length-1].position:{x:0,y:0,z:0};this.group=e.addGroup({title:this.name,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:100,step:1,value:this.subdivide},{prop:"Tension",type:"range",min:0,max:1,step:.01,value:this.tension},{prop:"New Pt Offset",type:"range",min:0,max:10,value:this.offset},{prop:"Curve At",type:"range",min:0,max:1,step:.01,value:0},{prop:"Toggle Transform",type:"button"},{prop:"Add Point",type:"button"},{prop:"Remove Point",type:"button"},{prop:"Export",type:"button"},{prop:"Delete",type:"button"},{prop:"Current Point",type:"grid3",value:i}],onUpdate:(n,a)=>{switch(n){case"Closed":this.closed=a,this.updateSpline();break;case"Visible":this.visible=a;break;case"Color":this.lineMaterial.color.setStyle(a),this.draggedMat.color.setStyle(a);break;case"Curve":this.curveType=a,this.updateSpline();break;case"Draggable Scale":this.draggableScale=a;break;case"Subdivide":this.subdivide=a,this.updateSpline();break;case"Tension":this.tension=a,this.updateSpline();break;case"New Pt Offset":this.offset=a;break;case"Curve At":this.curvePos.position.copy(this.getPointAt(a));break;case"Show Position":this.curvePos.visible=a;break;case"Show Points":this.draggable.visible=a;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":Te(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(a),this.updateSpline())}break}}}),this.draggable.children.forEach(n=>{this.debugPoint(n)})}debugPoint=e=>{e.name,e.visible=this.draggable.visible}}let Mt=0;class hr extends o.Object3D{defaultScale=10;_camera;group=null;constructor(e){super(),this.name="Spline Editor",this._camera=e,D.addEventListener(R.ADD_SPLINE,this.onAddSpline)}initDebug(){this.group=$.addEditorGroup({title:this.name,items:[{type:"button",prop:"New Spline"},{type:"boolean",prop:"Show Points",value:!0},{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"Show Points":this.showPoints(t);break;case"Visible":this.visible=t;break;case"Default Scale":this.defaultScale=t;break}}})}dispose(){D.removeEventListener(R.ADD_SPLINE,this.onAddSpline),$.removeEditorGroup(this.name)}addSpline(e){e.draggableScale=this.defaultScale,e.hideTransform(),this.group?.current!==null&&e.initDebug(this.group.current),this.add(e)}createSpline=(e=[])=>{const t=`Spline ${Mt+1}`,i=new Ki(t,this._camera);return i.addPoints(e),this.addSpline(i),Mt++,i};createSplineFromArray=e=>{const t=[];return e.forEach(i=>{t.push(new o.Vector3(i[0],i[1],i[2]))}),this.createSpline(t)};createSplineFromCurve=e=>this.createSpline(e.points);createSplineFromJSON=e=>{const t=this.createSplineFromArray(e.points);return t.name=e.name,t.closed=e.closed,t.subdivide=e.subdivide,t.tension=e.tension,t.type=e.type,t.updateSpline(),t};showPoints=(e=!0)=>{this.children.forEach(t=>{t.showPoints(e)})};onAddSpline=e=>{const t=JSON.parse(e.value),i=`Spline ${Mt+1}`,n=[];t.points.forEach(r=>{n.push(new o.Vector3(r[0],r[1],0))});const a=new Ki(i,this.camera);a.addPoints(n),this.addSpline(a),Mt++};get camera(){return this._camera}set camera(e){this._camera=e,this.children.forEach(t=>{const i=t;i.camera=e})}}const Ji=["Single","Side by Side","Stacked","Quad"];class be extends w.Component{static instance=null;scene=new o.Scene;renderer;currentScene;cameras=new Map;controls=new Map;currentCamera;currentWindow;cameraHelpers=new Map;lightHelpers=new Map;helpersContainer=new o.Group;grid=new $n;axisHelper=new o.AxesHelper(500);interactionHelper=new o.AxesHelper(100);currentTransform;splineEditor;depthMaterial=new o.MeshDepthMaterial;normalsMaterial=new o.MeshNormalMaterial;uvMaterial=new Jn;wireframeMaterial=new o.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0});playing=!1;rafID=-1;width=0;height=0;sceneSet=!1;tlCam=null;trCam=null;blCam=null;brCam=null;tlRender="Renderer";trRender="Renderer";blRender="Renderer";brRender="Renderer";selectedItem=void 0;debugCamera;raycaster=new o.Raycaster;pointer=new o.Vector2;cameraControls=void 0;canvasRef;containerRef;tlWindow;trWindow;blWindow;brWindow;constructor(e){super(e),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.app.appID,i=localStorage,n=i.getItem(`${t}_mode`);this.state={mode:n!==null?n:"Single",modeOpen:!1,renderModeOpen:!1,interactionMode:"Orbit",interactionModeOpen:!1,lastUpdate:Date.now()},i.setItem(`${t}_mode`,this.state.mode),i.setItem(`${t}_tlCam`,i.getItem(`${t}_tlCam`)!==null?i.getItem(`${t}_tlCam`):"Debug"),i.setItem(`${t}_trCam`,i.getItem(`${t}_trCam`)!==null?i.getItem(`${t}_trCam`):"Orthographic"),i.setItem(`${t}_blCam`,i.getItem(`${t}_blCam`)!==null?i.getItem(`${t}_blCam`):"Front"),i.setItem(`${t}_brCam`,i.getItem(`${t}_brCam`)!==null?i.getItem(`${t}_brCam`):"Top"),i.setItem(`${t}_tlRender`,i.getItem(`${t}_tlRender`)!==null?i.getItem(`${t}_tlRender`):"Renderer"),i.setItem(`${t}_trRender`,i.getItem(`${t}_trRender`)!==null?i.getItem(`${t}_trRender`):"Renderer"),i.setItem(`${t}_blRender`,i.getItem(`${t}_blRender`)!==null?i.getItem(`${t}_blRender`):"Renderer"),i.setItem(`${t}_brRender`,i.getItem(`${t}_brRender`)!==null?i.getItem(`${t}_brRender`):"Renderer");const a={Vector2:o.Vector2,Vector3:o.Vector3,Vector4:o.Vector4,Quaternion:o.Quaternion,Matrix4:o.Matrix4,Spherical:o.Spherical,Box3:o.Box3,Sphere:o.Sphere,Raycaster:o.Raycaster};ve.install({THREE:a}),this.setupScene(),this.setupTools(),be.instance=this}componentDidMount(){this.setupRenderer(),this.enable(),this.assignControls(),this.resize(),this.play(),le.instance.three=this.props.three,le.instance.activeCamera=this.debugCamera}componentDidUpdate(e,t,i){t.mode!==this.state.mode&&(this.assignControls(),this.resize())}componentWillUnmount(){this.disable()}render(){const e=[];return this.cameras.forEach((t,i)=>{e.push(i)}),u.jsxs("div",{className:"multiview",children:[u.jsx("canvas",{ref:this.canvasRef}),u.jsxs("div",{className:`cameras ${this.state.mode==="Single"||this.state.mode==="Stacked"?"single":""}`,ref:this.containerRef,children:[this.state.mode==="Single"&&u.jsx(u.Fragment,{children:u.jsx(Le,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=i,localStorage.setItem(`${this.appID}_tlCam`,i.name),this.createControls(i,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}})}),(this.state.mode==="Side by Side"||this.state.mode==="Stacked")&&u.jsxs(u.Fragment,{children:[u.jsx(Le,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=i,localStorage.setItem(`${this.appID}_tlCam`,i.name),this.createControls(i,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),u.jsx(Le,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.trCam),this.trCam=i,localStorage.setItem(`${this.appID}_trCam`,i.name),this.createControls(i,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}})]}),this.state.mode==="Quad"&&u.jsxs(u.Fragment,{children:[u.jsx(Le,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=i,localStorage.setItem(`${this.appID}_tlCam`,i.name),this.createControls(i,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),u.jsx(Le,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.trCam),this.trCam=i,localStorage.setItem(`${this.appID}_trCam`,i.name),this.createControls(i,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}}),u.jsx(Le,{name:"bl",camera:this.blCam,options:e,ref:this.blWindow,onSelectCamera:t=>{this.controls.get(this.blCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.blCam),this.blCam=i,localStorage.setItem(`${this.appID}_blCam`,i.name),this.createControls(i,this.blWindow.current))},onSelectRenderMode:t=>{this.blRender=t,localStorage.setItem(`${this.appID}_blRender`,t)}}),u.jsx(Le,{name:"br",camera:this.brCam,options:e,ref:this.brWindow,onSelectCamera:t=>{this.controls.get(this.brCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.brCam),this.brCam=i,localStorage.setItem(`${this.appID}_brCam`,i.name),this.createControls(i,this.brWindow.current))},onSelectRenderMode:t=>{this.brRender=t,localStorage.setItem(`${this.appID}_brRender`,t)}})]})]}),u.jsxs("div",{className:"settings",children:[u.jsx(It,{title:"View",index:Ji.indexOf(this.state.mode),options:Ji,onSelect:t=>{t!==this.state.mode&&(this.killControls(),this.setState({mode:t}))},open:this.state.modeOpen,onToggle:t=>{this.setState({modeOpen:t,renderModeOpen:!1,interactionModeOpen:!1})}}),u.jsx(It,{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})}})]},this.state.lastUpdate)]})}setupRenderer(){this.renderer=new o.WebGLRenderer({canvas:this.canvasRef.current,stencil:!1}),this.renderer.autoClear=!1,this.renderer.shadowMap.enabled=!0,this.renderer.setPixelRatio(devicePixelRatio),this.renderer.setClearColor(0),this.props.three.renderer=this.renderer}setupScene(){this.scene.name="Debug Scene",this.scene.uuid="",this.helpersContainer.name="helpers",this.scene.add(this.helpersContainer),this.helpersContainer.add(this.grid),this.axisHelper.name="axisHelper",this.helpersContainer.add(this.axisHelper),this.interactionHelper.name="interactionHelper",this.helpersContainer.add(this.interactionHelper),this.interactionHelper.visible=!1;const e=(n,a)=>{const r=new o.OrthographicCamera(-100,100,100,-100,50,5e3);return r.name=n,r.position.copy(a),r.lookAt(0,0,0),this.cameras.set(n,r),r};e("Top",new o.Vector3(0,1e3,0)),e("Bottom",new o.Vector3(0,-1e3,0)),e("Left",new o.Vector3(-1e3,0,0)),e("Right",new o.Vector3(1e3,0,0)),e("Front",new o.Vector3(0,0,1e3)),e("Back",new o.Vector3(0,0,-1e3)),e("Orthographic",new o.Vector3(1e3,1e3,1e3)),e("UI",new o.Vector3),this.debugCamera=new o.PerspectiveCamera(60,1,50,5e3),this.debugCamera.name="Debug",this.debugCamera.position.set(500,500,500),this.debugCamera.lookAt(0,0,0),this.cameras.set("Debug",this.debugCamera),this.currentCamera=this.debugCamera;const t=localStorage,i=this.props.three.app.appID;this.tlCam=this.cameras.get(t.getItem(`${i}_tlCam`)),this.trCam=this.cameras.get(t.getItem(`${i}_trCam`)),this.blCam=this.cameras.get(t.getItem(`${i}_blCam`)),this.brCam=this.cameras.get(t.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"))}setupTools(){this.splineEditor=new hr(this.currentCamera),this.splineEditor.initDebug(),this.scene.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})}update(){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.sceneSet&&this.props.onSceneUpdate(this.currentScene)}draw(){switch(this.renderer?.clear(),this.state.mode){case"Single":this.drawSingle();break;case"Side by Side":case"Stacked":this.drawDouble();break;case"Quad":this.drawQuad();break}}onUpdate=()=>{this.playing&&(this.update(),this.draw(),this.rafID=requestAnimationFrame(this.onUpdate))};enable(){const e=this.containerRef.current;e.addEventListener("mousemove",this.onMouseMove),e.addEventListener("click",this.onClick),window.addEventListener("keydown",this.onKey),window.addEventListener("resize",this.resize),D.addEventListener(R.SET_SCENE,this.sceneUpdate),D.addEventListener(R.ADD_CAMERA,this.addCamera),D.addEventListener(R.REMOVE_CAMERA,this.removeCamera),D.addEventListener(R.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),D.removeEventListener(R.SET_SCENE,this.sceneUpdate),D.removeEventListener(R.ADD_CAMERA,this.addCamera),D.removeEventListener(R.REMOVE_CAMERA,this.removeCamera),D.removeEventListener(R.SET_OBJECT,this.onSetSelectedItem)}resize=()=>{this.width=window.innerWidth-300,this.height=window.innerHeight;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.sceneSet&&this.currentScene!==void 0&&this.props.onSceneResize(this.currentScene,this.width,this.height);let i=this.width,n=this.height;switch(this.state.mode){case"Side by Side":i=e,n=this.height;break;case"Stacked":i=this.width,n=t;break;case"Quad":i=e,n=t;break}const a=i/n;this.cameras.forEach(r=>{r instanceof o.OrthographicCamera?(r.left=i/-2,r.right=i/2,r.top=n/2,r.bottom=n/-2,r.name==="UI"&&(r.position.x=this.width/2,r.position.y=this.height/-2,r.position.z=100),r.updateProjectionMatrix()):r instanceof o.PerspectiveCamera&&(r.aspect=a,r.updateProjectionMatrix(),this.cameraHelpers.get(r.name)?.update())})};sceneUpdate=e=>{this.helpersContainer.add(this.axisHelper),this.clearLightHelpers(),this.scene.remove(this.currentScene),Te(this.currentScene);const t=this.props.scenes.get(e.value.name);if(t!==void 0){const i=new t;this.props.onSceneSet!==void 0&&this.props.onSceneSet(i),this.currentScene=i,this.props.three.scene=this.currentScene,this.scene.add(this.currentScene),this.sceneSet=!0,this.addLightHelpers()}};addCamera=e=>{const t=e.value,i=this.props.three.scene?.getObjectByProperty("uuid",t.uuid);if(i!==void 0&&this.cameras.set(t.name,i),i instanceof o.PerspectiveCamera){const n=new o.CameraHelper(i);this.cameraHelpers.set(i.name,n),this.scene.add(n)}this.setState({lastUpdate:Date.now()})};removeCamera=e=>{const t=this.cameraHelpers.get(e.value.name);t!==void 0&&(this.scene.remove(t),t.dispose()),this.cameras.delete(e.value.name),this.setState({lastUpdate:Date.now()})};onMouseMove=e=>{const t=new o.Vector2;this.renderer.getSize(t);const i=Math.min(e.clientX,t.x),n=Math.min(e.clientY,t.y);this.pointer.x=Be(i,0,t.x,-1,1),this.pointer.y=Be(n,0,t.y,1,-1);const a=t.x/2,r=t.y/2,l=()=>{i<a?this.pointer.x=Be(i,0,a,-1,1):this.pointer.x=Be(i,a,t.x,-1,1)},h=()=>{n<r?this.pointer.y=Be(n,0,r,1,-1):this.pointer.y=Be(n,r,t.y,1,-1)};switch(this.state.mode){case"Quad":l(),h();break;case"Side by Side":l();break;case"Stacked":h(),h();break}if(this.updateCamera(i,n,a,r),this.state.interactionMode==="Orbit")return;const d=this.raycaster.intersectObjects(this.currentScene.children);d.length>0&&this.interactionHelper.position.copy(d[0].point)};onClick=e=>{if(this.state.interactionMode==="Orbit")return;const t=new o.Vector2;if(this.renderer.getSize(t),e.clientX>=t.x)return;this.onMouseMove(e);const i=this.raycaster.intersectObjects(this.currentScene.children);i.length>0&&(this.props.three.getObject(i[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"?(this.clearControls(),this.cameraControls=new ve(this.currentCamera,this.currentWindow.current),this.selectedItem instanceof o.Mesh||this.selectedItem instanceof o.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"?(this.clearControls(),this.cameraControls=new ve(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"?(this.clearControls(),this.cameraControls=new ve(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"?(this.clearControls(),this.cameraControls=new ve(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"?(this.clearControls(),this.cameraControls=new ve(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"&&(this.clearControls(),this.cameraControls=new ve(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(li(45),li(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}}};onSetSelectedItem=e=>{this.selectedItem=this.currentScene.getObjectByProperty("uuid",e.value.uuid),this.selectedItem!==void 0&&(this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),le.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=le.instance.add(e.value.name),this.currentTransform.attach(this.selectedItem),this.scene.add(this.currentTransform.getHelper()),this.currentTransform.addEventListener("objectChange",this.onUpdateTransform))};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),Ut.instance.update())};clearLightHelpers=()=>{this.lightHelpers.forEach(e=>{this.helpersContainer.remove(e),e.dispose()}),this.lightHelpers.clear()};addLightHelpers=()=>{this.currentScene!==void 0&&this.currentScene.traverse(e=>{if(e.type.search("Light")>-1){let t;switch(e.type){case"DirectionalLight":t=new o.DirectionalLightHelper(e,100),t.name=`${e.name}Helper`,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"HemisphereLight":t=new o.HemisphereLightHelper(e,250),t.name=`${e.name}Helper`,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"RectAreaLight":t=new Dn(e),t.name=`${e.name}Helper`,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"PointLight":t=new o.PointLightHelper(e,100),t.name=`${e.name}Helper`,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"SpotLight":t=new o.SpotLightHelper(e),t.name=`${e.name}Helper`,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break}}})};createControls(e,t){const i=this.controls.get(e.name);if(i!==void 0&&i.dispose(),this.controls.delete(e.name),e.name==="UI")return;const n=new In(e,t);switch(n.enableDamping=!0,n.dampingFactor=.05,e.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":n.enableRotate=!1;break}this.controls.set(e.name,n)}clearCamera(e){const t=this.cameraHelpers.get(e.name);t!==void 0&&(this.scene.remove(t),t.dispose(),this.cameraHelpers.delete(e.name));const i=this.controls.get(e.name);i!==void 0&&(i.dispose(),this.controls.delete(e.name))}killControls(){this.controls.forEach((e,t)=>{e.dispose();const i=this.cameraHelpers.get(t);i!==void 0&&(this.scene.remove(i),i.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,i,n)=>{switch(this.state.mode){case"Quad":t<n?e<i?this.currentCamera=this.tlCam:this.currentCamera=this.trCam:e<i?this.currentCamera=this.blCam:this.currentCamera=this.brCam;break;case"Side by Side":e<i?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break;case"Single":this.currentCamera=this.tlCam;break;case"Stacked":t<n?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break}this.splineEditor.camera=this.currentCamera,this.raycaster.setFromCamera(this.pointer,this.currentCamera),this.currentCamera===this.tlCam?this.currentWindow=this.tlWindow:this.currentCamera===this.trCam?this.currentWindow=this.trWindow:this.currentCamera===this.blCam?this.currentWindow=this.blWindow:this.currentCamera===this.brCam&&(this.currentWindow=this.brWindow),le.instance.updateCamera(this.currentCamera,this.currentWindow.current)};updateCameraControls=(e,t=!1)=>{if(this.selectedItem===void 0)return;cancelAnimationFrame(this.rafID),this.rafID=-1,this.cameraControls&&(this.cameraControls.smoothTime=.1);const i=.15,n=new o.Clock;n.start(),this.selectedItem.getWorldPosition(e.target0);const a=()=>{const r=n.getDelta();this.cameraControls&&this.cameraControls.update(r),t&&(e.target.lerp(e.target0,i),e.object.position.lerp(e.position0,i),e.object.zoom=Dt(e.object.zoom,e.zoom0,i),e.object.updateProjectionMatrix(),e.dispatchEvent({type:"change"})),n.getElapsedTime()>=.5?(cancelAnimationFrame(this.rafID),this.rafID=-1,this.clearControls()):this.rafID=requestAnimationFrame(a)};a()};clearControls=()=>{this.cameraControls!==void 0&&(this.cameraControls.disconnect(),this.cameraControls.dispose(),this.cameraControls=void 0)};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}drawSingle(){const e=this.getSceneOverride(this.tlRender);this.scene.overrideMaterial=e,this.renderer?.setViewport(0,0,this.width,this.height),this.renderer?.setScissor(0,0,this.width,this.height),this.renderer?.render(this.scene,this.tlCam)}drawDouble=()=>{const e=this.getSceneOverride(this.tlRender),t=this.getSceneOverride(this.trRender),i=Math.floor(this.width/2),n=Math.floor(this.height/2);if(this.scene.overrideMaterial=e,this.state.mode==="Side by Side")this.renderer?.setViewport(0,0,i,this.height),this.renderer?.setScissor(0,0,i,this.height),this.renderer?.render(this.scene,this.tlCam),this.scene.overrideMaterial=t,this.renderer?.setViewport(i,0,i,this.height),this.renderer?.setScissor(i,0,i,this.height),this.renderer?.render(this.scene,this.trCam);else{const a=this.height-n;this.renderer?.setViewport(0,a,this.width,n),this.renderer?.setScissor(0,a,this.width,n),this.renderer?.render(this.scene,this.tlCam),this.scene.overrideMaterial=t,this.renderer?.setViewport(0,0,this.width,n),this.renderer?.setScissor(0,0,this.width,n),this.renderer?.render(this.scene,this.trCam)}};drawQuad=()=>{const e=this.getSceneOverride(this.tlRender),t=this.getSceneOverride(this.trRender),i=this.getSceneOverride(this.blRender),n=this.getSceneOverride(this.brRender),a=Math.floor(this.width/2),r=Math.floor(this.height/2);let l=0,h=0;h=this.height-r,l=0,this.scene.overrideMaterial=e,this.renderer?.setViewport(l,h,a,r),this.renderer?.setScissor(l,h,a,r),this.renderer?.render(this.scene,this.tlCam),l=a,this.scene.overrideMaterial=t,this.renderer?.setViewport(l,h,a,r),this.renderer?.setScissor(l,h,a,r),this.renderer?.render(this.scene,this.trCam),h=0,l=0,this.scene.overrideMaterial=i,this.renderer?.setViewport(l,h,a,r),this.renderer?.setScissor(l,h,a,r),this.renderer?.render(this.scene,this.blCam),l=a,this.scene.overrideMaterial=n,this.renderer?.setViewport(l,h,a,r),this.renderer?.setScissor(l,h,a,r),this.renderer?.render(this.scene,this.brCam)};get appID(){return this.props.three.app.appID}get mode(){return this.state.mode}get three(){return this.props.three}}class Ut extends w.Component{static instance;matrix=new o.Matrix4;position=new o.Vector3;rotation=new o.Euler;scale=new o.Vector3;open=!1;constructor(e){super(e),this.state={lastUpdated:0,expanded:!1},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)),Ut.instance=this}update(){if(be.instance){const e=be.instance.selectedItem;if(e===void 0)return;this.position.x=pe(e.position.x,3),this.position.y=pe(e.position.y,3),this.position.z=pe(e.position.z,3),this.rotation.copy(e.rotation),this.scale.x=pe(e.scale.x,3),this.scale.y=pe(e.scale.y,3),this.scale.z=pe(e.scale.z,3),this.setState({lastUpdated:Date.now()})}}render(){return u.jsx(fe,{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.state.lastUpdated)}updateTransform=(e,t)=>{const i=e==="rotation"?{x:t._x,y:t._y,z:t._z}:t;this.props.three.updateObject(this.props.object.uuid,e,i);const n=this.props.three.getScene(this.props.object.uuid);if(n){const a=n.getObjectByProperty("uuid",this.props.object.uuid);q(a,e,i)}}}function es(s){switch(s){case"color":return"Color";case"intensity":return"Intensity";case"decay":return"Decay";case"distance":return"Distance";case"angle":return"Angle";case"penumbra":return"Penumbra";case"groundColor":return"Ground Color";case"width":return"Width";case"height":return"Height"}return s}function dr(s,e){const t=[];if(s.lightInfo!==void 0)for(const i in s.lightInfo){const n=s.lightInfo[i];n!==void 0&&(n.isColor!==void 0?t.push({title:es(i),prop:i,type:"color",value:n,onChange:(a,r)=>{const l=new o.Color(r);e.updateObject(s.uuid,a,l);const h=e.getScene(s.uuid);if(h!==null){const d=h.getObjectByProperty("uuid",s.uuid);q(d,a,l)}}}):t.push({title:es(i),prop:i,type:typeof n,value:n,step:typeof n=="number"?.01:void 0,onChange:(a,r)=>{e.updateObject(s.uuid,a,r);const l=e.getScene(s.uuid);if(l!==null){const h=l.getObjectByProperty("uuid",s.uuid);q(h,a,r)}}}))}return u.jsx(fe,{title:"Light",items:t})}function ur(s,e){const t=[],i=[];let n=0;s.animations.forEach(r=>{n=Math.max(n,r.duration),r.duration>0&&i.push({title:r.name,items:[{title:"Duration",type:"number",value:r.duration,disabled:!0},{title:"Blend Mode",type:"option",disabled:!0,options:[{title:"Normal",value:2500},{title:"Additive",value:2501}]}]})}),t.push({title:"Animations",items:i});const a=e.getScene(s.uuid);if(a!==null){const r=a.getObjectByProperty("uuid",s.uuid);let l=!1;if(r!==void 0){const h=r.mixer;if(l=h!==void 0,l){const d=[{title:"Time Scale",type:"range",value:h.timeScale,step:.01,min:-1,max:2,onChange:(p,m)=>{h.timeScale=m,e.updateObject(s.uuid,"mixer.timeScale",m)}}];d.push({title:"Stop All",type:"button",onChange:()=>{h.stopAllAction(),e.requestMethod(s.uuid,"stopAllAction",void 0,"mixer")}}),t.push({title:"Mixer",items:d})}}}return u.jsx(fe,{title:"Animation",items:t})}const ms={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:[]};let oe={...ms};function fs(s){const[e,t]=w.useState(-1);w.useEffect(()=>{function r(h){oe={...h.value},t(Date.now())}function l(){oe={...ms},t(Date.now())}return D.addEventListener(R.SET_SCENE,l),D.addEventListener(R.SET_OBJECT,r),()=>{D.removeEventListener(R.SET_SCENE,l),D.removeEventListener(R.SET_OBJECT,r)}},[]);const i=oe.type.toLowerCase(),n=oe.animations.length>0||oe.mixer!==void 0,a=i.search("mesh")>-1||i.search("line")>-1||i.search("points")>-1;return u.jsx(ut,{label:"Inspector",children:u.jsx("div",{id:"Inspector",className:s.class,children:oe.uuid.length>0&&u.jsxs(u.Fragment,{children:[u.jsxs(u.Fragment,{children:[u.jsx(Pt,{type:"string",title:"Name",prop:"name",value:oe.name,disabled:!0}),u.jsx(Pt,{type:"string",title:"Type",prop:"type",value:oe.type,disabled:!0}),u.jsx(Pt,{type:"string",title:"UUID",prop:"uuid",value:oe.uuid,disabled:!0})]}),u.jsxs(u.Fragment,{children:[u.jsx(Ut,{object:oe,three:s.three}),n?ur(oe,s.three):null,i.search("camera")>-1?Rn(oe,s.three):null,i.search("light")>-1?dr(oe,s.three):null,a?Tn(oe,s.three):null]})]})},e)},"Inspector")}function _s(s){const[e]=w.useState([]),[t]=w.useState([]),[i,n]=w.useState(0),a=h=>{const d=h.value;e.push(d),t.push(u.jsx(ut,{label:`Scene: ${d.name}`,scene:d,open:!0,onRefresh:()=>{s.three.refreshScene(d.name)},children:u.jsx(oi,{child:d,scene:d,three:s.three})},Math.random())),n(Date.now())},r=h=>{const d=h.value;for(let p=0;p<e.length;p++)if(d.uuid===e[p].uuid){e[p]=d,t[p]=u.jsx(ut,{label:`Scene: ${d.name}`,scene:d,open:!0,onRefresh:()=>{s.three.refreshScene(d.name)},children:u.jsx(oi,{child:d,scene:d,three:s.three})},Math.random()),n(Date.now());return}},l=h=>{const d=h.value;for(let p=0;p<e.length;p++)if(d.uuid===e[p].uuid){e.splice(p,1),t.splice(p,1),n(Date.now());return}};return w.useEffect(()=>(D.addEventListener(R.ADD_SCENE,a),D.addEventListener(R.REFRESH_SCENE,r),D.addEventListener(R.REMOVE_SCENE,l),()=>{D.removeEventListener(R.ADD_SCENE,a),D.removeEventListener(R.REFRESH_SCENE,r),D.removeEventListener(R.REMOVE_SCENE,l)}),[]),u.jsxs("div",{id:"SidePanel",children:[u.jsx("div",{className:"scenes",children:t},i),u.jsx(fs,{three:s.three}),u.jsx($,{three:s.three})]})}function pr(s){return w.useEffect(()=>{function e(l){let h=null;return s.three.scenes.forEach(d=>{l.search(d.uuid)>-1&&(h=d)}),h}const t=l=>{const h=l.value,p=e(h)?.getObjectByProperty("uuid",h);p!==void 0&&s.three.setObject(p)},i=(l,h,d)=>{const m=e(l)?.getObjectByProperty("uuid",l);m!==void 0&&q(m,h,d)},n=l=>{const h=l.value,{key:d,value:p,uuid:m}=h;i(m,d,p)},a=l=>{const h=l.value,p=e(h.uuid)?.getObjectByProperty("uuid",h.uuid);if(p!==void 0){const m=g=>{const y=h.key.split(".");switch(y.length){case 1:p[y[0]]=g;break;case 2:p[y[0]][y[1]]=g;break;case 3:p[y[0]][y[1]][y[2]]=g;break;case 4:p[y[0]][y[1]][y[2]][y[3]]=g;break;case 5:p[y[0]][y[1]][y[2]][y[3]][y[4]]=g;break}p.material.needsUpdate=!0};h.value.src.length>0?as(h.value.src).then(g=>{g.offset.set(h.value.offset[0],h.value.offset[1]),g.repeat.set(h.value.repeat[0],h.value.repeat[1]),m(g)}):m(null)}},r=l=>{const{key:h,uuid:d,value:p,subitem:m}=l.value,y=e(d)?.getObjectByProperty("uuid",d);if(y!==void 0)try{m!==void 0?Ks(y,m)[h](p):y[h](p)}catch(x){console.log("Error requesting method:"),console.log(x),console.log(h),console.log(p)}};return D.addEventListener(R.GET_OBJECT,t),D.addEventListener(R.UPDATE_OBJECT,n),D.addEventListener(R.CREATE_TEXTURE,a),D.addEventListener(R.REQUEST_METHOD,r),()=>{D.removeEventListener(R.GET_OBJECT,t),D.removeEventListener(R.UPDATE_OBJECT,n),D.removeEventListener(R.CREATE_TEXTURE,a),D.removeEventListener(R.REQUEST_METHOD,r)}},[]),null}function gs(s){return u.jsxs("div",{className:"editor",ref:s.ref,style:s.style,children:[u.jsx("div",{className:"header",children:s.header}),s.children,u.jsx("div",{className:"footer",children:s.footer})]})}function mr(s){return u.jsx(gs,{children:u.jsxs(u.Fragment,{children:[u.jsx(be,{three:s.three,scenes:s.scenes,onSceneResize:s.onSceneResize,onSceneSet:s.onSceneSet,onSceneUpdate:s.onSceneUpdate}),u.jsx(_s,{three:s.three})]})})}exports.Accordion=ut;exports.Application=Gs;exports.BaseRemote=Lt;exports.ChildObject=pi;exports.ContainerObject=oi;exports.Draggable=ls;exports.DraggableItem=os;exports.Dropdown=cs;exports.DropdownItem=hs;exports.Editor=gs;exports.ExportTexture=ht;exports.Inspector=fs;exports.MultiView=be;exports.NavButton=ui;exports.RemoteComponents=Zs;exports.RemoteController=an;exports.RemoteTheatre=di;exports.RemoteThree=en;exports.SceneInspector=pr;exports.SidePanel=_s;exports.ThreeEditor=mr;exports.ToolEvents=R;exports.capitalize=dt;exports.clamp=Oe;exports.colorToHex=ni;exports.copyToClipboard=is;exports.customizeTheatreElements=Xs;exports.debugDispatcher=D;exports.defaultTheatreCallback=Bs;exports.dispose=Te;exports.disposeMaterial=rs;exports.disposeTexture=Ys;exports.distance=Vs;exports.hierarchyUUID=At;exports.isColor=ns;exports.mix=Dt;exports.noop=hi;exports.normalize=si;exports.randomID=ss;exports.resetThreeObjects=ri;exports.round=pe;exports.theatreEditorApp=Ws;
|
149
|
+
}`;class Jn extends o.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:qn,fragmentShader:Kn})}}const ke=new o.Raycaster,ie=new o.Vector3,we=new o.Vector3,G=new o.Quaternion,Gi={X:new o.Vector3(1,0,0),Y:new o.Vector3(0,1,0),Z:new o.Vector3(0,0,1)},ei={type:"change"},Zi={type:"mouseDown",mode:null},Wi={type:"mouseUp",mode:null},Xi={type:"objectChange"};class er extends o.Controls{constructor(e,t=null){super(void 0,t);const i=new ar(this);this._root=i;const n=new or;this._gizmo=n,i.add(n);const a=new lr;this._plane=a,i.add(a);const r=this;function l(C,E){let P=E;Object.defineProperty(r,C,{get:function(){return P!==void 0?P:E},set:function(O){P!==O&&(P=O,a[C]=O,n[C]=O,r.dispatchEvent({type:C+"-changed",value:O}),r.dispatchEvent(ei))}}),r[C]=E,a[C]=E,n[C]=E}l("camera",e),l("object",void 0),l("enabled",!0),l("axis",null),l("mode","translate"),l("translationSnap",null),l("rotationSnap",null),l("scaleSnap",null),l("space","world"),l("size",1),l("dragging",!1),l("showX",!0),l("showY",!0),l("showZ",!0);const h=new o.Vector3,d=new o.Vector3,p=new o.Quaternion,m=new o.Quaternion,g=new o.Vector3,y=new o.Quaternion,x=new o.Vector3,M=new o.Vector3,T=new o.Vector3,_=0,v=new o.Vector3;l("worldPosition",h),l("worldPositionStart",d),l("worldQuaternion",p),l("worldQuaternionStart",m),l("cameraPosition",g),l("cameraQuaternion",y),l("pointStart",x),l("pointEnd",M),l("rotationAxis",T),l("rotationAngle",_),l("eye",v),this._offset=new o.Vector3,this._startNorm=new o.Vector3,this._endNorm=new o.Vector3,this._cameraScale=new o.Vector3,this._parentPosition=new o.Vector3,this._parentQuaternion=new o.Quaternion,this._parentQuaternionInv=new o.Quaternion,this._parentScale=new o.Vector3,this._worldScaleStart=new o.Vector3,this._worldQuaternionInv=new o.Quaternion,this._worldScale=new o.Vector3,this._positionStart=new o.Vector3,this._quaternionStart=new o.Quaternion,this._scaleStart=new o.Vector3,this._getPointer=tr.bind(this),this._onPointerDown=sr.bind(this),this._onPointerHover=ir.bind(this),this._onPointerMove=nr.bind(this),this._onPointerUp=rr.bind(this),t!==null&&this.connect()}connect(){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&&ke.setFromCamera(e,this.camera);const t=ti(this._gizmo.picker[this.mode],ke);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&&ke.setFromCamera(e,this.camera);const t=ti(this._plane,ke,!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,Zi.mode=this.mode,this.dispatchEvent(Zi)}}pointerMove(e){const t=this.axis,i=this.mode,n=this.object;let a=this.space;if(i==="scale"?a="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(a="world"),n===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&ke.setFromCamera(e,this.camera);const r=ti(this._plane,ke,!0);if(r){if(this.pointEnd.copy(r.point).sub(this.worldPositionStart),i==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),a==="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),a==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),n.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(a==="local"&&(n.position.applyQuaternion(G.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this._quaternionStart)),a==="world"&&(n.parent&&n.position.add(ie.setFromMatrixPosition(n.parent.matrixWorld)),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.parent&&n.position.sub(ie.setFromMatrixPosition(n.parent.matrixWorld))));else if(i==="scale"){if(t.search("XYZ")!==-1){let l=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(l*=-1),we.set(l,l,l)}else ie.copy(this.pointStart),we.copy(this.pointEnd),ie.applyQuaternion(this._worldQuaternionInv),we.applyQuaternion(this._worldQuaternionInv),we.divide(ie),t.search("X")===-1&&(we.x=1),t.search("Y")===-1&&(we.y=1),t.search("Z")===-1&&(we.z=1);n.scale.copy(this._scaleStart).multiply(we),this.scaleSnap&&(t.search("X")!==-1&&(n.scale.x=Math.round(n.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(n.scale.y=Math.round(n.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(n.scale.z=Math.round(n.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(i==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const l=20/this.worldPosition.distanceTo(ie.setFromMatrixPosition(this.camera.matrixWorld));let h=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(ie.copy(this.rotationAxis).cross(this.eye))*l):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(Gi[t]),ie.copy(Gi[t]),a==="local"&&ie.applyQuaternion(this.worldQuaternion),ie.cross(this.eye),ie.length()===0?h=!0:this.rotationAngle=this._offset.dot(ie.normalize())*l),(t==="E"||h)&&(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),a==="local"&&t!=="E"&&t!=="XYZE"?(n.quaternion.copy(this._quaternionStart),n.quaternion.multiply(G.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(G.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(ei),this.dispatchEvent(Xi)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(Wi.mode=this.mode,this.dispatchEvent(Wi)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.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(ei),this.dispatchEvent(Xi),this.pointStart.copy(this.pointEnd))}getRaycaster(){return ke}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 tr(s){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:s.button};{const e=this.domElement.getBoundingClientRect();return{x:(s.clientX-e.left)/e.width*2-1,y:-(s.clientY-e.top)/e.height*2+1,button:s.button}}}function ir(s){if(this.enabled)switch(s.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(s));break}}function sr(s){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(s.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(s)),this.pointerDown(this._getPointer(s)))}function nr(s){this.enabled&&this.pointerMove(this._getPointer(s))}function rr(s){this.enabled&&(this.domElement.releasePointerCapture(s.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(s)))}function ti(s,e,t){const i=e.intersectObject(s,!0);for(let n=0;n<i.length;n++)if(i[n].object.visible||t)return i[n];return!1}const xt=new o.Euler,V=new o.Vector3(0,1,0),Qi=new o.Vector3(0,0,0),$i=new o.Matrix4,Ot=new o.Quaternion,Rt=new o.Quaternion,ye=new o.Vector3,qi=new o.Matrix4,lt=new o.Vector3(1,0,0),Ue=new o.Vector3(0,1,0),ct=new o.Vector3(0,0,1),Tt=new o.Vector3,rt=new o.Vector3,at=new o.Vector3;class ar extends o.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)}}class or extends o.Object3D{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new o.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new o.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=e.clone();i.opacity=.15;const n=t.clone();n.opacity=.5;const a=e.clone();a.color.setHex(16711680);const r=e.clone();r.color.setHex(65280);const l=e.clone();l.color.setHex(255);const h=e.clone();h.color.setHex(16711680),h.opacity=.5;const d=e.clone();d.color.setHex(65280),d.opacity=.5;const p=e.clone();p.color.setHex(255),p.opacity=.5;const m=e.clone();m.opacity=.25;const g=e.clone();g.color.setHex(16776960),g.opacity=.25,e.clone().color.setHex(16776960);const x=e.clone();x.color.setHex(7895160);const M=new o.CylinderGeometry(0,.04,.1,12);M.translate(0,.05,0);const T=new o.BoxGeometry(.08,.08,.08);T.translate(0,.04,0);const _=new o.BufferGeometry;_.setAttribute("position",new o.Float32BufferAttribute([0,0,0,1,0,0],3));const v=new o.CylinderGeometry(.0075,.0075,.5,3);v.translate(0,.25,0);function C(X,Me){const ne=new o.TorusGeometry(X,.0075,3,64,Me*Math.PI*2);return ne.rotateY(Math.PI/2),ne.rotateX(Math.PI/2),ne}function E(){const X=new o.BufferGeometry;return X.setAttribute("position",new o.Float32BufferAttribute([0,0,0,1,1,1],3)),X}const P={X:[[new o.Mesh(M,a),[.5,0,0],[0,0,-Math.PI/2]],[new o.Mesh(M,a),[-.5,0,0],[0,0,Math.PI/2]],[new o.Mesh(v,a),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new o.Mesh(M,r),[0,.5,0]],[new o.Mesh(M,r),[0,-.5,0],[Math.PI,0,0]],[new o.Mesh(v,r)]],Z:[[new o.Mesh(M,l),[0,0,.5],[Math.PI/2,0,0]],[new o.Mesh(M,l),[0,0,-.5],[-Math.PI/2,0,0]],[new o.Mesh(v,l),null,[Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.OctahedronGeometry(.1,0),m.clone()),[0,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),p.clone()),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),h.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),d.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},O={X:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,.3,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.OctahedronGeometry(.2,0),i)]],XY:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},j={START:[[new o.Mesh(new o.OctahedronGeometry(.01,2),n),null,null,null,"helper"]],END:[[new o.Mesh(new o.OctahedronGeometry(.01,2),n),null,null,null,"helper"]],DELTA:[[new o.Line(E(),n),null,null,null,"helper"]],X:[[new o.Line(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new o.Line(_,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new o.Line(_,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},W={XYZE:[[new o.Mesh(C(.5,1),x),null,[0,Math.PI/2,0]]],X:[[new o.Mesh(C(.5,.5),a)]],Y:[[new o.Mesh(C(.5,.5),r),null,[0,0,-Math.PI/2]]],Z:[[new o.Mesh(C(.5,.5),l),null,[0,Math.PI/2,0]]],E:[[new o.Mesh(C(.75,1),g),null,[0,Math.PI/2,0]]]},he={AXIS:[[new o.Line(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},Se={XYZE:[[new o.Mesh(new o.SphereGeometry(.25,10,8),i)]],X:[[new o.Mesh(new o.TorusGeometry(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new o.Mesh(new o.TorusGeometry(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new o.Mesh(new o.TorusGeometry(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new o.Mesh(new o.TorusGeometry(.75,.1,2,24),i)]]},Qe={X:[[new o.Mesh(T,a),[.5,0,0],[0,0,-Math.PI/2]],[new o.Mesh(v,a),[0,0,0],[0,0,-Math.PI/2]],[new o.Mesh(T,a),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(T,r),[0,.5,0]],[new o.Mesh(v,r)],[new o.Mesh(T,r),[0,-.5,0],[0,0,Math.PI]]],Z:[[new o.Mesh(T,l),[0,0,.5],[Math.PI/2,0,0]],[new o.Mesh(v,l),[0,0,0],[Math.PI/2,0,0]],[new o.Mesh(T,l),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),p),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),h),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.15,.15,.01),d),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.BoxGeometry(.1,.1,.1),m.clone())]]},Fe={X:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,.3,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new o.Mesh(new o.CylinderGeometry(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new o.Mesh(new o.BoxGeometry(.2,.2,.2),i),[0,0,0]]]},ce={X:[[new o.Line(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new o.Line(_,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new o.Line(_,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function J(X){const Me=new o.Object3D;for(const ne in X)for(let Ee=X[ne].length;Ee--;){const te=X[ne][Ee][0].clone(),Pe=X[ne][Ee][1],Re=X[ne][Ee][2],De=X[ne][Ee][3],pt=X[ne][Ee][4];te.name=ne,te.tag=pt,Pe&&te.position.set(Pe[0],Pe[1],Pe[2]),Re&&te.rotation.set(Re[0],Re[1],Re[2]),De&&te.scale.set(De[0],De[1],De[2]),te.updateMatrix();const mt=te.geometry.clone();mt.applyMatrix4(te.matrix),te.geometry=mt,te.renderOrder=1/0,te.position.set(0,0,0),te.rotation.set(0,0,0),te.scale.set(1,1,1),Me.add(te)}return Me}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=J(P)),this.add(this.gizmo.rotate=J(W)),this.add(this.gizmo.scale=J(Qe)),this.add(this.picker.translate=J(O)),this.add(this.picker.rotate=J(Se)),this.add(this.picker.scale=J(Fe)),this.add(this.helper.translate=J(j)),this.add(this.helper.rotate=J(he)),this.add(this.helper.scale=J(ce)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const i=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:Rt;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 n=[];n=n.concat(this.picker[this.mode].children),n=n.concat(this.gizmo[this.mode].children),n=n.concat(this.helper[this.mode].children);for(let a=0;a<n.length;a++){const r=n[a];r.visible=!0,r.rotation.set(0,0,0),r.position.copy(this.worldPosition);let l;if(this.camera.isOrthographicCamera?l=(this.camera.top-this.camera.bottom)/this.camera.zoom:l=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),r.scale.set(1,1,1).multiplyScalar(l*this.size/4),r.tag==="helper"){r.visible=!1,r.name==="AXIS"?(r.visible=!!this.axis,this.axis==="X"&&(G.setFromEuler(xt.set(0,0,0)),r.quaternion.copy(i).multiply(G),Math.abs(V.copy(lt).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Y"&&(G.setFromEuler(xt.set(0,0,Math.PI/2)),r.quaternion.copy(i).multiply(G),Math.abs(V.copy(Ue).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Z"&&(G.setFromEuler(xt.set(0,Math.PI/2,0)),r.quaternion.copy(i).multiply(G),Math.abs(V.copy(ct).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="XYZE"&&(G.setFromEuler(xt.set(0,Math.PI/2,0)),V.copy(this.rotationAxis),r.quaternion.setFromRotationMatrix($i.lookAt(Qi,V,Ue)),r.quaternion.multiply(G),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),ie.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),ie.applyQuaternion(this.worldQuaternionStart.clone().invert()),r.scale.copy(ie),r.visible=this.dragging):(r.quaternion.copy(i),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(i),this.mode==="translate"||this.mode==="scale"?(r.name==="X"&&Math.abs(V.copy(lt).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Y"&&Math.abs(V.copy(Ue).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Z"&&Math.abs(V.copy(ct).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XY"&&Math.abs(V.copy(ct).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="YZ"&&Math.abs(V.copy(lt).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XZ"&&Math.abs(V.copy(Ue).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1)):this.mode==="rotate"&&(Ot.copy(i),V.copy(this.eye).applyQuaternion(G.copy(i).invert()),r.name.search("E")!==-1&&r.quaternion.setFromRotationMatrix($i.lookAt(this.eye,Qi,Ue)),r.name==="X"&&(G.setFromAxisAngle(lt,Math.atan2(-V.y,V.z)),G.multiplyQuaternions(Ot,G),r.quaternion.copy(G)),r.name==="Y"&&(G.setFromAxisAngle(Ue,Math.atan2(V.x,V.z)),G.multiplyQuaternions(Ot,G),r.quaternion.copy(G)),r.name==="Z"&&(G.setFromAxisAngle(ct,Math.atan2(V.y,V.x)),G.multiplyQuaternions(Ot,G),r.quaternion.copy(G))),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(h){return r.name===h}))&&(r.material.color.setHex(16776960),r.material.opacity=1)}super.updateMatrixWorld(e)}}class lr extends o.Mesh{constructor(){super(new o.PlaneGeometry(1e5,1e5,2,2),new o.MeshBasicMaterial({visible:!1,wireframe:!0,side:o.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"),Tt.copy(lt).applyQuaternion(t==="local"?this.worldQuaternion:Rt),rt.copy(Ue).applyQuaternion(t==="local"?this.worldQuaternion:Rt),at.copy(ct).applyQuaternion(t==="local"?this.worldQuaternion:Rt),V.copy(rt),this.mode){case"translate":case"scale":switch(this.axis){case"X":V.copy(this.eye).cross(Tt),ye.copy(Tt).cross(V);break;case"Y":V.copy(this.eye).cross(rt),ye.copy(rt).cross(V);break;case"Z":V.copy(this.eye).cross(at),ye.copy(at).cross(V);break;case"XY":ye.copy(at);break;case"YZ":ye.copy(Tt);break;case"XZ":V.copy(at),ye.copy(rt);break;case"XYZ":case"E":ye.set(0,0,0);break}break;case"rotate":default:ye.set(0,0,0)}ye.length()===0?this.quaternion.copy(this.cameraQuaternion):(qi.lookAt(ie.set(0,0,0),ye,V),this.quaternion.setFromRotationMatrix(qi)),super.updateMatrixWorld(e)}}class le extends o.EventDispatcher{static DRAG_START="Transform::dragStart";static DRAG_END="Transform::dragEnd";static _instance;three;activeCamera;controls=new Map;visibility=new Map;groups=[];clear(){for(const e of this.controls.values()){e.detach(),e.dispose();const t=e.getHelper();t.parent?.remove(t)}this.controls=new Map,this.visibility=new Map}add(e){let t=this.controls.get(e);if(t===void 0){const i=document.querySelector(".clickable");t=new er(this.activeCamera,i),t.getHelper().name=e,t.setSpace("local"),this.controls.set(e,t),this.visibility.set(e,!0),t.addEventListener("mouseDown",()=>{this.dispatchEvent({type:le.DRAG_START})}),t.addEventListener("mouseUp",()=>{this.dispatchEvent({type:le.DRAG_END})}),t.addEventListener("dragging-changed",a=>{be.instance?.toggleOrbitControls(a.value)});const n=`Controls: ${e}`;this.groups.push(n),this.three.addGroup({title:n,items:[{type:"boolean",prop:"enabled",value:t.enabled},{type:"boolean",prop:"visible",value:!0},{type:"button",prop:"Reset"},{type:"option",prop:"Mode",options:[{title:"Translate",value:"translate"},{title:"Rotate",value:"rotate"},{title:"Scale",value:"scale"}]},{type:"option",prop:"Space",options:[{title:"World",value:"world"},{title:"Local",value:"local"}]}],onUpdate:(a,r)=>{if(t!==void 0)switch(a){case"enabled":t.enabled=r;break;case"visible":t.getHelper().visible=r;break;case"Reset":t.reset();break;case"Mode":t.setMode(r);break;case"Space":t.setSpace(r);break}}})}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(),Te(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(i=>{i.camera!==e&&(i.camera=e,e.getWorldPosition(i.cameraPosition),e.getWorldQuaternion(i.cameraQuaternion)),i.domElement!==t&&(i.disconnect(),i.domElement=t,i.connect())})}show(){this.controls.forEach(e=>{const t=e.getHelper(),i=this.visibility.get(t.name);i!==void 0&&(t.visible=i)})}hide(){this.controls.forEach(e=>{const t=e.getHelper();this.visibility.set(t.name,t.visible),t.visible=!1})}static get instance(){return le._instance||(le._instance=new le),le._instance}}const cr=new o.BoxGeometry,ii=new o.Vector2;class Ki extends o.Object3D{curve=new o.CatmullRomCurve3;line;draggable;curvePos;tension=.5;closed=!1;subdivide=50;curveType;offset=1;lineMaterial;_camera;_curvePercentage=0;_draggableScale=10;_transform;raycaster;draggedMat=new o.MeshBasicMaterial;parentGroup;group;constructor(e,t){const i=new o.Color(Ve(.5,1,Math.random()),Ve(.5,1,Math.random()),Ve(.5,1,Math.random()));super(),this.name=e,this.lineMaterial=new o.LineBasicMaterial({color:i}),this.line=new o.Line(new o.BufferGeometry,this.lineMaterial),this.line.name="line",this.add(this.line),this._camera=t,this.curveType="catmullrom",this.draggedMat.color=i,this.draggable=new o.Object3D,this.draggable.name="draggablePoints",this.add(this.draggable),this.curvePos=new o.Mesh(new o.SphereGeometry(1.5),new o.MeshBasicMaterial({color:i})),this.curvePos.name="curvePos",this.curvePos.scale.setScalar(this._draggableScale),this.curvePos.visible=!1,this.add(this.curvePos),this.raycaster=new o.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),le.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([pe(t.position.x,3),pe(t.position.y,3),pe(t.position.z,3)])}),is({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 i=0;i<t;i++)this.addPoint(e[i],!1);this.addPoint(e[t])}else this.addPoint(new o.Vector3(-50,0,0),!1),this.addPoint(new o.Vector3(50,0,0))};addPoint=(e,t=!0)=>{const i=this.draggable.children.length,n=new o.Mesh(cr,this.draggedMat);return n.name=`point_${i}`,n.position.copy(e),n.scale.setScalar(this._draggableScale),this.draggable.add(n),t&&this.updateSpline(),n};addNextPt=()=>{const e=this.draggable.children.length,t=new o.Vector3(Ve(-this.offset,this.offset,Math.random()),Ve(-this.offset,this.offset,Math.random()),Ve(-this.offset,this.offset,Math.random()));e>0&&t.add(this.draggable.children[e-1].position);const i=this.addPoint(t);this._transform?.attach(i),this.group.current?.setField("Current Point",i.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)}Te(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)};updateSpline=()=>{this.curve=new o.CatmullRomCurve3(this.points,this.closed,this.curveType,this.tension),this.line.geometry.setFromPoints(this.getPoints()),this.curvePos.position.copy(this.getPointAt(this._curvePercentage))};onMouseClick=e=>{if(!be.instance||this._transform&&!this._transform.getHelper().visible)return;const i=be.instance.currentWindow.current.getBoundingClientRect();ii.x=(e.clientX-i.x)/i.width*2-1,ii.y=-((e.clientY-i.y)/i.height)*2+1,this.raycaster.setFromCamera(ii,this.camera);const n=this.raycaster.intersectObjects(this.draggable.children,!1);if(n.length>0){const a=n[0].object;a!==this._transform?.object&&(this._transform?.attach(a),this.group.current?.setField("Current Point",a.position))}};getPointAt(e){return this.curve.getPointAt(e)}getPoints(){return this.curve.getPoints(this.subdivide)}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))}onUpdateTransform=()=>{if(this._transform?.object&&this.group){const e=this._transform?.object;e.name.search("point")>-1&&this.group.current?.setField("Current Point",e.position)}this.updateSpline()};initDebug(e){const t=this.draggable.children;this.parentGroup=e,this._transform=le.instance.add(this.name),this._transform.camera=this._camera,this._transform.addEventListener("objectChange",this.onUpdateTransform),this._transform.attach(t.length>0?t[t.length-1]:this),be.instance?.scene.add(this._transform.getHelper());const i=t.length>0?t[t.length-1].position:{x:0,y:0,z:0};this.group=e.addGroup({title:this.name,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:100,step:1,value:this.subdivide},{prop:"Tension",type:"range",min:0,max:1,step:.01,value:this.tension},{prop:"New Pt Offset",type:"range",min:0,max:10,value:this.offset},{prop:"Curve At",type:"range",min:0,max:1,step:.01,value:0},{prop:"Toggle Transform",type:"button"},{prop:"Add Point",type:"button"},{prop:"Remove Point",type:"button"},{prop:"Export",type:"button"},{prop:"Delete",type:"button"},{prop:"Current Point",type:"grid3",value:i}],onUpdate:(n,a)=>{switch(n){case"Closed":this.closed=a,this.updateSpline();break;case"Visible":this.visible=a;break;case"Color":this.lineMaterial.color.setStyle(a),this.draggedMat.color.setStyle(a);break;case"Curve":this.curveType=a,this.updateSpline();break;case"Draggable Scale":this.draggableScale=a;break;case"Subdivide":this.subdivide=a,this.updateSpline();break;case"Tension":this.tension=a,this.updateSpline();break;case"New Pt Offset":this.offset=a;break;case"Curve At":this.curvePos.position.copy(this.getPointAt(a));break;case"Show Position":this.curvePos.visible=a;break;case"Show Points":this.draggable.visible=a;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":Te(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(a),this.updateSpline())}break}}}),this.draggable.children.forEach(n=>{this.debugPoint(n)})}debugPoint=e=>{e.name,e.visible=this.draggable.visible}}let Mt=0;class hr extends o.Object3D{defaultScale=10;_camera;group=null;constructor(e){super(),this.name="Spline Editor",this._camera=e,D.addEventListener(R.ADD_SPLINE,this.onAddSpline)}initDebug(){this.group=$.addEditorGroup({title:this.name,items:[{type:"button",prop:"New Spline"},{type:"boolean",prop:"Show Points",value:!0},{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"Show Points":this.showPoints(t);break;case"Visible":this.visible=t;break;case"Default Scale":this.defaultScale=t;break}}})}dispose(){D.removeEventListener(R.ADD_SPLINE,this.onAddSpline),$.removeEditorGroup(this.name)}addSpline(e){e.draggableScale=this.defaultScale,e.hideTransform(),this.group?.current!==null&&e.initDebug(this.group.current),this.add(e)}createSpline=(e=[])=>{const t=`Spline ${Mt+1}`,i=new Ki(t,this._camera);return i.addPoints(e),this.addSpline(i),Mt++,i};createSplineFromArray=e=>{const t=[];return e.forEach(i=>{t.push(new o.Vector3(i[0],i[1],i[2]))}),this.createSpline(t)};createSplineFromCatmullRom=e=>this.createSpline(e.points);createSplineFromJSON=e=>{const t=this.createSplineFromArray(e.points);return t.name=e.name,t.closed=e.closed,t.subdivide=e.subdivide,t.tension=e.tension,t.type=e.type,t.updateSpline(),t};showPoints=(e=!0)=>{this.children.forEach(t=>{t.showPoints(e)})};onAddSpline=e=>{const t=JSON.parse(e.value),i=`Spline ${Mt+1}`,n=[];t.points.forEach(r=>{n.push(new o.Vector3(r[0],r[1],r[2]))});const a=new Ki(i,this.camera);a.addPoints(n),this.addSpline(a),Mt++};get camera(){return this._camera}set camera(e){this._camera=e,this.children.forEach(t=>{const i=t;i.camera=e})}}const Ji=["Single","Side by Side","Stacked","Quad"];class be extends w.Component{static instance=null;scene=new o.Scene;renderer;currentScene;cameras=new Map;controls=new Map;currentCamera;currentWindow;cameraHelpers=new Map;lightHelpers=new Map;helpersContainer=new o.Group;grid=new $n;axisHelper=new o.AxesHelper(500);interactionHelper=new o.AxesHelper(100);currentTransform;splineEditor;depthMaterial=new o.MeshDepthMaterial;normalsMaterial=new o.MeshNormalMaterial;uvMaterial=new Jn;wireframeMaterial=new o.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0});playing=!1;rafID=-1;width=0;height=0;sceneSet=!1;tlCam=null;trCam=null;blCam=null;brCam=null;tlRender="Renderer";trRender="Renderer";blRender="Renderer";brRender="Renderer";selectedItem=void 0;debugCamera;raycaster=new o.Raycaster;pointer=new o.Vector2;cameraControls=void 0;canvasRef;containerRef;tlWindow;trWindow;blWindow;brWindow;constructor(e){super(e),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.app.appID,i=localStorage,n=i.getItem(`${t}_mode`);this.state={mode:n!==null?n:"Single",modeOpen:!1,renderModeOpen:!1,interactionMode:"Orbit",interactionModeOpen:!1,lastUpdate:Date.now()},i.setItem(`${t}_mode`,this.state.mode),i.setItem(`${t}_tlCam`,i.getItem(`${t}_tlCam`)!==null?i.getItem(`${t}_tlCam`):"Debug"),i.setItem(`${t}_trCam`,i.getItem(`${t}_trCam`)!==null?i.getItem(`${t}_trCam`):"Orthographic"),i.setItem(`${t}_blCam`,i.getItem(`${t}_blCam`)!==null?i.getItem(`${t}_blCam`):"Front"),i.setItem(`${t}_brCam`,i.getItem(`${t}_brCam`)!==null?i.getItem(`${t}_brCam`):"Top"),i.setItem(`${t}_tlRender`,i.getItem(`${t}_tlRender`)!==null?i.getItem(`${t}_tlRender`):"Renderer"),i.setItem(`${t}_trRender`,i.getItem(`${t}_trRender`)!==null?i.getItem(`${t}_trRender`):"Renderer"),i.setItem(`${t}_blRender`,i.getItem(`${t}_blRender`)!==null?i.getItem(`${t}_blRender`):"Renderer"),i.setItem(`${t}_brRender`,i.getItem(`${t}_brRender`)!==null?i.getItem(`${t}_brRender`):"Renderer");const a={Vector2:o.Vector2,Vector3:o.Vector3,Vector4:o.Vector4,Quaternion:o.Quaternion,Matrix4:o.Matrix4,Spherical:o.Spherical,Box3:o.Box3,Sphere:o.Sphere,Raycaster:o.Raycaster};ve.install({THREE:a}),this.setupScene(),this.setupTools(),be.instance=this}componentDidMount(){this.setupRenderer(),this.enable(),this.assignControls(),this.resize(),this.play(),le.instance.three=this.props.three,le.instance.activeCamera=this.debugCamera}componentDidUpdate(e,t,i){t.mode!==this.state.mode&&(this.assignControls(),this.resize())}componentWillUnmount(){this.disable()}render(){const e=[];return this.cameras.forEach((t,i)=>{e.push(i)}),u.jsxs("div",{className:"multiview",children:[u.jsx("canvas",{ref:this.canvasRef}),u.jsxs("div",{className:`cameras ${this.state.mode==="Single"||this.state.mode==="Stacked"?"single":""}`,ref:this.containerRef,children:[this.state.mode==="Single"&&u.jsx(u.Fragment,{children:u.jsx(Le,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=i,localStorage.setItem(`${this.appID}_tlCam`,i.name),this.createControls(i,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}})}),(this.state.mode==="Side by Side"||this.state.mode==="Stacked")&&u.jsxs(u.Fragment,{children:[u.jsx(Le,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=i,localStorage.setItem(`${this.appID}_tlCam`,i.name),this.createControls(i,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),u.jsx(Le,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.trCam),this.trCam=i,localStorage.setItem(`${this.appID}_trCam`,i.name),this.createControls(i,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}})]}),this.state.mode==="Quad"&&u.jsxs(u.Fragment,{children:[u.jsx(Le,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=i,localStorage.setItem(`${this.appID}_tlCam`,i.name),this.createControls(i,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),u.jsx(Le,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.trCam),this.trCam=i,localStorage.setItem(`${this.appID}_trCam`,i.name),this.createControls(i,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}}),u.jsx(Le,{name:"bl",camera:this.blCam,options:e,ref:this.blWindow,onSelectCamera:t=>{this.controls.get(this.blCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.blCam),this.blCam=i,localStorage.setItem(`${this.appID}_blCam`,i.name),this.createControls(i,this.blWindow.current))},onSelectRenderMode:t=>{this.blRender=t,localStorage.setItem(`${this.appID}_blRender`,t)}}),u.jsx(Le,{name:"br",camera:this.brCam,options:e,ref:this.brWindow,onSelectCamera:t=>{this.controls.get(this.brCam.name)?.dispose();const i=this.cameras.get(t);i!==void 0&&(this.clearCamera(this.brCam),this.brCam=i,localStorage.setItem(`${this.appID}_brCam`,i.name),this.createControls(i,this.brWindow.current))},onSelectRenderMode:t=>{this.brRender=t,localStorage.setItem(`${this.appID}_brRender`,t)}})]})]}),u.jsxs("div",{className:"settings",children:[u.jsx(It,{title:"View",index:Ji.indexOf(this.state.mode),options:Ji,onSelect:t=>{t!==this.state.mode&&(this.killControls(),this.setState({mode:t}))},open:this.state.modeOpen,onToggle:t=>{this.setState({modeOpen:t,renderModeOpen:!1,interactionModeOpen:!1})}}),u.jsx(It,{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})}})]},this.state.lastUpdate)]})}setupRenderer(){this.renderer=new o.WebGLRenderer({canvas:this.canvasRef.current,stencil:!1}),this.renderer.autoClear=!1,this.renderer.shadowMap.enabled=!0,this.renderer.setPixelRatio(devicePixelRatio),this.renderer.setClearColor(0),this.props.three.renderer=this.renderer}setupScene(){this.scene.name="Debug Scene",this.scene.uuid="",this.helpersContainer.name="helpers",this.scene.add(this.helpersContainer),this.helpersContainer.add(this.grid),this.axisHelper.name="axisHelper",this.helpersContainer.add(this.axisHelper),this.interactionHelper.name="interactionHelper",this.helpersContainer.add(this.interactionHelper),this.interactionHelper.visible=!1;const e=(n,a)=>{const r=new o.OrthographicCamera(-100,100,100,-100,50,5e3);return r.name=n,r.position.copy(a),r.lookAt(0,0,0),this.cameras.set(n,r),r};e("Top",new o.Vector3(0,1e3,0)),e("Bottom",new o.Vector3(0,-1e3,0)),e("Left",new o.Vector3(-1e3,0,0)),e("Right",new o.Vector3(1e3,0,0)),e("Front",new o.Vector3(0,0,1e3)),e("Back",new o.Vector3(0,0,-1e3)),e("Orthographic",new o.Vector3(1e3,1e3,1e3)),e("UI",new o.Vector3),this.debugCamera=new o.PerspectiveCamera(60,1,50,5e3),this.debugCamera.name="Debug",this.debugCamera.position.set(500,500,500),this.debugCamera.lookAt(0,0,0),this.cameras.set("Debug",this.debugCamera),this.currentCamera=this.debugCamera;const t=localStorage,i=this.props.three.app.appID;this.tlCam=this.cameras.get(t.getItem(`${i}_tlCam`)),this.trCam=this.cameras.get(t.getItem(`${i}_trCam`)),this.blCam=this.cameras.get(t.getItem(`${i}_blCam`)),this.brCam=this.cameras.get(t.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"))}setupTools(){this.splineEditor=new hr(this.currentCamera),this.splineEditor.initDebug(),this.scene.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})}update(){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.sceneSet&&this.props.onSceneUpdate(this.currentScene)}draw(){switch(this.renderer?.clear(),this.state.mode){case"Single":this.drawSingle();break;case"Side by Side":case"Stacked":this.drawDouble();break;case"Quad":this.drawQuad();break}}onUpdate=()=>{this.playing&&(this.update(),this.draw(),this.rafID=requestAnimationFrame(this.onUpdate))};enable(){const e=this.containerRef.current;e.addEventListener("mousemove",this.onMouseMove),e.addEventListener("click",this.onClick),window.addEventListener("keydown",this.onKey),window.addEventListener("resize",this.resize),D.addEventListener(R.SET_SCENE,this.sceneUpdate),D.addEventListener(R.ADD_CAMERA,this.addCamera),D.addEventListener(R.REMOVE_CAMERA,this.removeCamera),D.addEventListener(R.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),D.removeEventListener(R.SET_SCENE,this.sceneUpdate),D.removeEventListener(R.ADD_CAMERA,this.addCamera),D.removeEventListener(R.REMOVE_CAMERA,this.removeCamera),D.removeEventListener(R.SET_OBJECT,this.onSetSelectedItem)}resize=()=>{this.width=window.innerWidth-300,this.height=window.innerHeight;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.sceneSet&&this.currentScene!==void 0&&this.props.onSceneResize(this.currentScene,this.width,this.height);let i=this.width,n=this.height;switch(this.state.mode){case"Side by Side":i=e,n=this.height;break;case"Stacked":i=this.width,n=t;break;case"Quad":i=e,n=t;break}const a=i/n;this.cameras.forEach(r=>{r instanceof o.OrthographicCamera?(r.left=i/-2,r.right=i/2,r.top=n/2,r.bottom=n/-2,r.name==="UI"&&(r.position.x=this.width/2,r.position.y=this.height/-2,r.position.z=100),r.updateProjectionMatrix()):r instanceof o.PerspectiveCamera&&(r.aspect=a,r.updateProjectionMatrix(),this.cameraHelpers.get(r.name)?.update())})};sceneUpdate=e=>{this.helpersContainer.add(this.axisHelper),this.clearLightHelpers(),this.scene.remove(this.currentScene),Te(this.currentScene);const t=this.props.scenes.get(e.value.name);if(t!==void 0){const i=new t;this.props.onSceneSet!==void 0&&this.props.onSceneSet(i),this.currentScene=i,this.props.three.scene=this.currentScene,this.scene.add(this.currentScene),this.sceneSet=!0,this.addLightHelpers()}};addCamera=e=>{const t=e.value,i=this.props.three.scene?.getObjectByProperty("uuid",t.uuid);if(i!==void 0&&this.cameras.set(t.name,i),i instanceof o.PerspectiveCamera){const n=new o.CameraHelper(i);this.cameraHelpers.set(i.name,n),this.scene.add(n)}this.setState({lastUpdate:Date.now()})};removeCamera=e=>{const t=this.cameraHelpers.get(e.value.name);t!==void 0&&(this.scene.remove(t),t.dispose()),this.cameras.delete(e.value.name),this.setState({lastUpdate:Date.now()})};onMouseMove=e=>{const t=new o.Vector2;this.renderer.getSize(t);const i=Math.min(e.clientX,t.x),n=Math.min(e.clientY,t.y);this.pointer.x=Be(i,0,t.x,-1,1),this.pointer.y=Be(n,0,t.y,1,-1);const a=t.x/2,r=t.y/2,l=()=>{i<a?this.pointer.x=Be(i,0,a,-1,1):this.pointer.x=Be(i,a,t.x,-1,1)},h=()=>{n<r?this.pointer.y=Be(n,0,r,1,-1):this.pointer.y=Be(n,r,t.y,1,-1)};switch(this.state.mode){case"Quad":l(),h();break;case"Side by Side":l();break;case"Stacked":h(),h();break}if(this.updateCamera(i,n,a,r),this.state.interactionMode==="Orbit")return;const d=this.raycaster.intersectObjects(this.currentScene.children);d.length>0&&this.interactionHelper.position.copy(d[0].point)};onClick=e=>{if(this.state.interactionMode==="Orbit")return;const t=new o.Vector2;if(this.renderer.getSize(t),e.clientX>=t.x)return;this.onMouseMove(e);const i=this.raycaster.intersectObjects(this.currentScene.children);i.length>0&&(this.props.three.getObject(i[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"?(this.clearControls(),this.cameraControls=new ve(this.currentCamera,this.currentWindow.current),this.selectedItem instanceof o.Mesh||this.selectedItem instanceof o.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"?(this.clearControls(),this.cameraControls=new ve(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"?(this.clearControls(),this.cameraControls=new ve(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"?(this.clearControls(),this.cameraControls=new ve(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"?(this.clearControls(),this.cameraControls=new ve(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"&&(this.clearControls(),this.cameraControls=new ve(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(li(45),li(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}}};onSetSelectedItem=e=>{this.selectedItem=this.currentScene.getObjectByProperty("uuid",e.value.uuid),this.selectedItem!==void 0&&(this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),le.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=le.instance.add(e.value.name),this.currentTransform.attach(this.selectedItem),this.scene.add(this.currentTransform.getHelper()),this.currentTransform.addEventListener("objectChange",this.onUpdateTransform))};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),Ut.instance.update())};clearLightHelpers=()=>{this.lightHelpers.forEach(e=>{this.helpersContainer.remove(e),e.dispose()}),this.lightHelpers.clear()};addLightHelpers=()=>{this.currentScene!==void 0&&this.currentScene.traverse(e=>{if(e.type.search("Light")>-1){let t;switch(e.type){case"DirectionalLight":t=new o.DirectionalLightHelper(e,100),t.name=`${e.name}Helper`,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"HemisphereLight":t=new o.HemisphereLightHelper(e,250),t.name=`${e.name}Helper`,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"RectAreaLight":t=new Dn(e),t.name=`${e.name}Helper`,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"PointLight":t=new o.PointLightHelper(e,100),t.name=`${e.name}Helper`,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break;case"SpotLight":t=new o.SpotLightHelper(e),t.name=`${e.name}Helper`,this.lightHelpers.set(e.name,t),this.helpersContainer.add(t);break}}})};createControls(e,t){const i=this.controls.get(e.name);if(i!==void 0&&i.dispose(),this.controls.delete(e.name),e.name==="UI")return;const n=new In(e,t);switch(n.enableDamping=!0,n.dampingFactor=.05,e.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":n.enableRotate=!1;break}this.controls.set(e.name,n)}clearCamera(e){const t=this.cameraHelpers.get(e.name);t!==void 0&&(this.scene.remove(t),t.dispose(),this.cameraHelpers.delete(e.name));const i=this.controls.get(e.name);i!==void 0&&(i.dispose(),this.controls.delete(e.name))}killControls(){this.controls.forEach((e,t)=>{e.dispose();const i=this.cameraHelpers.get(t);i!==void 0&&(this.scene.remove(i),i.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,i,n)=>{switch(this.state.mode){case"Quad":t<n?e<i?this.currentCamera=this.tlCam:this.currentCamera=this.trCam:e<i?this.currentCamera=this.blCam:this.currentCamera=this.brCam;break;case"Side by Side":e<i?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break;case"Single":this.currentCamera=this.tlCam;break;case"Stacked":t<n?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break}this.splineEditor.camera=this.currentCamera,this.raycaster.setFromCamera(this.pointer,this.currentCamera),this.currentCamera===this.tlCam?this.currentWindow=this.tlWindow:this.currentCamera===this.trCam?this.currentWindow=this.trWindow:this.currentCamera===this.blCam?this.currentWindow=this.blWindow:this.currentCamera===this.brCam&&(this.currentWindow=this.brWindow),le.instance.updateCamera(this.currentCamera,this.currentWindow.current)};updateCameraControls=(e,t=!1)=>{if(this.selectedItem===void 0)return;cancelAnimationFrame(this.rafID),this.rafID=-1,this.cameraControls&&(this.cameraControls.smoothTime=.1);const i=.15,n=new o.Clock;n.start(),this.selectedItem.getWorldPosition(e.target0);const a=()=>{const r=n.getDelta();this.cameraControls&&this.cameraControls.update(r),t&&(e.target.lerp(e.target0,i),e.object.position.lerp(e.position0,i),e.object.zoom=Dt(e.object.zoom,e.zoom0,i),e.object.updateProjectionMatrix(),e.dispatchEvent({type:"change"})),n.getElapsedTime()>=.5?(cancelAnimationFrame(this.rafID),this.rafID=-1,this.clearControls()):this.rafID=requestAnimationFrame(a)};a()};clearControls=()=>{this.cameraControls!==void 0&&(this.cameraControls.disconnect(),this.cameraControls.dispose(),this.cameraControls=void 0)};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}drawSingle(){const e=this.getSceneOverride(this.tlRender);this.scene.overrideMaterial=e,this.renderer?.setViewport(0,0,this.width,this.height),this.renderer?.setScissor(0,0,this.width,this.height),this.renderer?.render(this.scene,this.tlCam)}drawDouble=()=>{const e=this.getSceneOverride(this.tlRender),t=this.getSceneOverride(this.trRender),i=Math.floor(this.width/2),n=Math.floor(this.height/2);if(this.scene.overrideMaterial=e,this.state.mode==="Side by Side")this.renderer?.setViewport(0,0,i,this.height),this.renderer?.setScissor(0,0,i,this.height),this.renderer?.render(this.scene,this.tlCam),this.scene.overrideMaterial=t,this.renderer?.setViewport(i,0,i,this.height),this.renderer?.setScissor(i,0,i,this.height),this.renderer?.render(this.scene,this.trCam);else{const a=this.height-n;this.renderer?.setViewport(0,a,this.width,n),this.renderer?.setScissor(0,a,this.width,n),this.renderer?.render(this.scene,this.tlCam),this.scene.overrideMaterial=t,this.renderer?.setViewport(0,0,this.width,n),this.renderer?.setScissor(0,0,this.width,n),this.renderer?.render(this.scene,this.trCam)}};drawQuad=()=>{const e=this.getSceneOverride(this.tlRender),t=this.getSceneOverride(this.trRender),i=this.getSceneOverride(this.blRender),n=this.getSceneOverride(this.brRender),a=Math.floor(this.width/2),r=Math.floor(this.height/2);let l=0,h=0;h=this.height-r,l=0,this.scene.overrideMaterial=e,this.renderer?.setViewport(l,h,a,r),this.renderer?.setScissor(l,h,a,r),this.renderer?.render(this.scene,this.tlCam),l=a,this.scene.overrideMaterial=t,this.renderer?.setViewport(l,h,a,r),this.renderer?.setScissor(l,h,a,r),this.renderer?.render(this.scene,this.trCam),h=0,l=0,this.scene.overrideMaterial=i,this.renderer?.setViewport(l,h,a,r),this.renderer?.setScissor(l,h,a,r),this.renderer?.render(this.scene,this.blCam),l=a,this.scene.overrideMaterial=n,this.renderer?.setViewport(l,h,a,r),this.renderer?.setScissor(l,h,a,r),this.renderer?.render(this.scene,this.brCam)};get appID(){return this.props.three.app.appID}get mode(){return this.state.mode}get three(){return this.props.three}}class Ut extends w.Component{static instance;matrix=new o.Matrix4;position=new o.Vector3;rotation=new o.Euler;scale=new o.Vector3;open=!1;constructor(e){super(e),this.state={lastUpdated:0,expanded:!1},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)),Ut.instance=this}update(){if(be.instance){const e=be.instance.selectedItem;if(e===void 0)return;this.position.x=pe(e.position.x,3),this.position.y=pe(e.position.y,3),this.position.z=pe(e.position.z,3),this.rotation.copy(e.rotation),this.scale.x=pe(e.scale.x,3),this.scale.y=pe(e.scale.y,3),this.scale.z=pe(e.scale.z,3),this.setState({lastUpdated:Date.now()})}}render(){return u.jsx(fe,{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.state.lastUpdated)}updateTransform=(e,t)=>{const i=e==="rotation"?{x:t._x,y:t._y,z:t._z}:t;this.props.three.updateObject(this.props.object.uuid,e,i);const n=this.props.three.getScene(this.props.object.uuid);if(n){const a=n.getObjectByProperty("uuid",this.props.object.uuid);q(a,e,i)}}}function es(s){switch(s){case"color":return"Color";case"intensity":return"Intensity";case"decay":return"Decay";case"distance":return"Distance";case"angle":return"Angle";case"penumbra":return"Penumbra";case"groundColor":return"Ground Color";case"width":return"Width";case"height":return"Height"}return s}function dr(s,e){const t=[];if(s.lightInfo!==void 0)for(const i in s.lightInfo){const n=s.lightInfo[i];n!==void 0&&(n.isColor!==void 0?t.push({title:es(i),prop:i,type:"color",value:n,onChange:(a,r)=>{const l=new o.Color(r);e.updateObject(s.uuid,a,l);const h=e.getScene(s.uuid);if(h!==null){const d=h.getObjectByProperty("uuid",s.uuid);q(d,a,l)}}}):t.push({title:es(i),prop:i,type:typeof n,value:n,step:typeof n=="number"?.01:void 0,onChange:(a,r)=>{e.updateObject(s.uuid,a,r);const l=e.getScene(s.uuid);if(l!==null){const h=l.getObjectByProperty("uuid",s.uuid);q(h,a,r)}}}))}return u.jsx(fe,{title:"Light",items:t})}function ur(s,e){const t=[],i=[];let n=0;s.animations.forEach(r=>{n=Math.max(n,r.duration),r.duration>0&&i.push({title:r.name,items:[{title:"Duration",type:"number",value:r.duration,disabled:!0},{title:"Blend Mode",type:"option",disabled:!0,options:[{title:"Normal",value:2500},{title:"Additive",value:2501}]}]})}),t.push({title:"Animations",items:i});const a=e.getScene(s.uuid);if(a!==null){const r=a.getObjectByProperty("uuid",s.uuid);let l=!1;if(r!==void 0){const h=r.mixer;if(l=h!==void 0,l){const d=[{title:"Time Scale",type:"range",value:h.timeScale,step:.01,min:-1,max:2,onChange:(p,m)=>{h.timeScale=m,e.updateObject(s.uuid,"mixer.timeScale",m)}}];d.push({title:"Stop All",type:"button",onChange:()=>{h.stopAllAction(),e.requestMethod(s.uuid,"stopAllAction",void 0,"mixer")}}),t.push({title:"Mixer",items:d})}}}return u.jsx(fe,{title:"Animation",items:t})}const ms={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:[]};let oe={...ms};function fs(s){const[e,t]=w.useState(-1);w.useEffect(()=>{function r(h){oe={...h.value},t(Date.now())}function l(){oe={...ms},t(Date.now())}return D.addEventListener(R.SET_SCENE,l),D.addEventListener(R.SET_OBJECT,r),()=>{D.removeEventListener(R.SET_SCENE,l),D.removeEventListener(R.SET_OBJECT,r)}},[]);const i=oe.type.toLowerCase(),n=oe.animations.length>0||oe.mixer!==void 0,a=i.search("mesh")>-1||i.search("line")>-1||i.search("points")>-1;return u.jsx(ut,{label:"Inspector",children:u.jsx("div",{id:"Inspector",className:s.class,children:oe.uuid.length>0&&u.jsxs(u.Fragment,{children:[u.jsxs(u.Fragment,{children:[u.jsx(Pt,{type:"string",title:"Name",prop:"name",value:oe.name,disabled:!0}),u.jsx(Pt,{type:"string",title:"Type",prop:"type",value:oe.type,disabled:!0}),u.jsx(Pt,{type:"string",title:"UUID",prop:"uuid",value:oe.uuid,disabled:!0})]}),u.jsxs(u.Fragment,{children:[u.jsx(Ut,{object:oe,three:s.three}),n?ur(oe,s.three):null,i.search("camera")>-1?Rn(oe,s.three):null,i.search("light")>-1?dr(oe,s.three):null,a?Tn(oe,s.three):null]})]})},e)},"Inspector")}function _s(s){const[e]=w.useState([]),[t]=w.useState([]),[i,n]=w.useState(0),a=h=>{const d=h.value;e.push(d),t.push(u.jsx(ut,{label:`Scene: ${d.name}`,scene:d,open:!0,onRefresh:()=>{s.three.refreshScene(d.name)},children:u.jsx(oi,{child:d,scene:d,three:s.three})},Math.random())),n(Date.now())},r=h=>{const d=h.value;for(let p=0;p<e.length;p++)if(d.uuid===e[p].uuid){e[p]=d,t[p]=u.jsx(ut,{label:`Scene: ${d.name}`,scene:d,open:!0,onRefresh:()=>{s.three.refreshScene(d.name)},children:u.jsx(oi,{child:d,scene:d,three:s.three})},Math.random()),n(Date.now());return}},l=h=>{const d=h.value;for(let p=0;p<e.length;p++)if(d.uuid===e[p].uuid){e.splice(p,1),t.splice(p,1),n(Date.now());return}};return w.useEffect(()=>(D.addEventListener(R.ADD_SCENE,a),D.addEventListener(R.REFRESH_SCENE,r),D.addEventListener(R.REMOVE_SCENE,l),()=>{D.removeEventListener(R.ADD_SCENE,a),D.removeEventListener(R.REFRESH_SCENE,r),D.removeEventListener(R.REMOVE_SCENE,l)}),[]),u.jsxs("div",{id:"SidePanel",children:[u.jsx("div",{className:"scenes",children:t},i),u.jsx(fs,{three:s.three}),u.jsx($,{three:s.three})]})}function pr(s){return w.useEffect(()=>{function e(l){let h=null;return s.three.scenes.forEach(d=>{l.search(d.uuid)>-1&&(h=d)}),h}const t=l=>{const h=l.value,p=e(h)?.getObjectByProperty("uuid",h);p!==void 0&&s.three.setObject(p)},i=(l,h,d)=>{const m=e(l)?.getObjectByProperty("uuid",l);m!==void 0&&q(m,h,d)},n=l=>{const h=l.value,{key:d,value:p,uuid:m}=h;i(m,d,p)},a=l=>{const h=l.value,p=e(h.uuid)?.getObjectByProperty("uuid",h.uuid);if(p!==void 0){const m=g=>{const y=h.key.split(".");switch(y.length){case 1:p[y[0]]=g;break;case 2:p[y[0]][y[1]]=g;break;case 3:p[y[0]][y[1]][y[2]]=g;break;case 4:p[y[0]][y[1]][y[2]][y[3]]=g;break;case 5:p[y[0]][y[1]][y[2]][y[3]][y[4]]=g;break}p.material.needsUpdate=!0};h.value.src.length>0?as(h.value.src).then(g=>{g.offset.set(h.value.offset[0],h.value.offset[1]),g.repeat.set(h.value.repeat[0],h.value.repeat[1]),m(g)}):m(null)}},r=l=>{const{key:h,uuid:d,value:p,subitem:m}=l.value,y=e(d)?.getObjectByProperty("uuid",d);if(y!==void 0)try{m!==void 0?Ks(y,m)[h](p):y[h](p)}catch(x){console.log("Error requesting method:"),console.log(x),console.log(h),console.log(p)}};return D.addEventListener(R.GET_OBJECT,t),D.addEventListener(R.UPDATE_OBJECT,n),D.addEventListener(R.CREATE_TEXTURE,a),D.addEventListener(R.REQUEST_METHOD,r),()=>{D.removeEventListener(R.GET_OBJECT,t),D.removeEventListener(R.UPDATE_OBJECT,n),D.removeEventListener(R.CREATE_TEXTURE,a),D.removeEventListener(R.REQUEST_METHOD,r)}},[]),null}function gs(s){return u.jsxs("div",{className:"editor",ref:s.ref,style:s.style,children:[u.jsx("div",{className:"header",children:s.header}),s.children,u.jsx("div",{className:"footer",children:s.footer})]})}function mr(s){return u.jsx(gs,{children:u.jsxs(u.Fragment,{children:[u.jsx(be,{three:s.three,scenes:s.scenes,onSceneResize:s.onSceneResize,onSceneSet:s.onSceneSet,onSceneUpdate:s.onSceneUpdate}),u.jsx(_s,{three:s.three})]})})}exports.Accordion=ut;exports.Application=Gs;exports.BaseRemote=Lt;exports.ChildObject=pi;exports.ContainerObject=oi;exports.Draggable=ls;exports.DraggableItem=os;exports.Dropdown=cs;exports.DropdownItem=hs;exports.Editor=gs;exports.ExportTexture=ht;exports.Inspector=fs;exports.MultiView=be;exports.NavButton=ui;exports.RemoteComponents=Zs;exports.RemoteController=an;exports.RemoteTheatre=di;exports.RemoteThree=en;exports.SceneInspector=pr;exports.SidePanel=_s;exports.ThreeEditor=mr;exports.ToolEvents=R;exports.capitalize=dt;exports.clamp=Oe;exports.colorToHex=ni;exports.copyToClipboard=is;exports.customizeTheatreElements=Xs;exports.debugDispatcher=D;exports.defaultTheatreCallback=Bs;exports.dispose=Te;exports.disposeMaterial=rs;exports.disposeTexture=Ys;exports.distance=Vs;exports.hierarchyUUID=At;exports.isColor=ns;exports.mix=Dt;exports.noop=hi;exports.normalize=si;exports.randomID=ss;exports.resetThreeObjects=ri;exports.round=pe;exports.theatreEditorApp=Ws;
|
package/dist/hermes.es.js
CHANGED
@@ -6487,7 +6487,7 @@ class Ia extends lt {
|
|
6487
6487
|
t.push(new O(i[0], i[1], i[2]));
|
6488
6488
|
}), this.createSpline(t);
|
6489
6489
|
};
|
6490
|
-
|
6490
|
+
createSplineFromCatmullRom = (e) => this.createSpline(e.points);
|
6491
6491
|
createSplineFromJSON = (e) => {
|
6492
6492
|
const t = this.createSplineFromArray(e.points);
|
6493
6493
|
return t.name = e.name, t.closed = e.closed, t.subdivide = e.subdivide, t.tension = e.tension, t.type = e.type, t.updateSpline(), t;
|
@@ -6500,7 +6500,7 @@ class Ia extends lt {
|
|
6500
6500
|
onAddSpline = (e) => {
|
6501
6501
|
const t = JSON.parse(e.value), i = `Spline ${Zt + 1}`, n = [];
|
6502
6502
|
t.points.forEach((r) => {
|
6503
|
-
n.push(new O(r[0], r[1],
|
6503
|
+
n.push(new O(r[0], r[1], r[2]));
|
6504
6504
|
});
|
6505
6505
|
const a = new Os(i, this.camera);
|
6506
6506
|
a.addPoints(n), this.addSpline(a), Zt++;
|
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.0.
|
10
|
+
"version": "0.0.104",
|
11
11
|
"homepage": "https://github.com/tomorrowevening/hermes#readme",
|
12
12
|
"bugs": {
|
13
13
|
"url": "https://github.com/tomorrowevening/hermes/issues"
|
@@ -18,7 +18,7 @@ export default class SplineEditor extends Object3D {
|
|
18
18
|
addSpline(spline: Spline): void;
|
19
19
|
createSpline: (defaultPoints?: Array<Vector3>) => Spline;
|
20
20
|
createSplineFromArray: (points: Array<number[]>) => Spline;
|
21
|
-
|
21
|
+
createSplineFromCatmullRom: (curve: CatmullRomCurve3) => Spline;
|
22
22
|
createSplineFromJSON: (data: SplineJSON) => Spline;
|
23
23
|
showPoints: (visible?: boolean) => void;
|
24
24
|
private onAddSpline;
|