import{F as f,h as u}from"./KHR_interactivity-BRnQ0PPJ.js";import{e as a,f as c,b as i,c as y,h as A,g as m,l as d,R as h}from"./declarationMapper-YJJdbZ_c.js";import{ao as w,aB as k,V as F,ai as C,R as s}from"./index-T8LZyOXI.js";import{F as n}from"./flowGraphBinaryOperationBlock-ChE5HYy3.js";import{F as B}from"./flowGraphUnaryOperationBlock-DJO8_uax.js";import"./index-BkylzejB.js";import"./objectModelMapping-D1pI71RW.js";import"./flowGraphCachedOperationBlock-BfX4DVbZ.js";function D(e,o){return e.x*o.x+e.y*o.y+e.z*o.z}function T(e,o){return e.x*o.x+e.y*o.y+e.z*o.z+e.w*o.w}function R(e,o){return Math.acos(k(T(e,o),-1,1))*2}function N(e,o){const r=new w;return Q(e,o,r),r}function Q(e,o,r){const t=F.Cross(e,o),l=Math.acos(k(D(e,o),-1,1));return w.RotationAxisToRef(t,l,r),r}const G="cachedOperationAxis",V="cachedOperationAngle",x="cachedExecutionId";class z extends B{constructor(o){super(h,i,r=>this._polymorphicLength(r),"FlowGraphLengthBlock",o)}_polymorphicLength(o){switch(u(o)){case"Vector2":case"Vector3":case"Vector4":case"Quaternion":return o.length();default:throw new Error(`Cannot compute length of value ${o}`)}}}s("FlowGraphLengthBlock",z);class _ extends B{constructor(o){super(h,h,r=>this._polymorphicNormalize(r),"FlowGraphNormalizeBlock",o)}_polymorphicNormalize(o){const r=u(o);let t;switch(r){case"Vector2":case"Vector3":case"Vector4":case"Quaternion":return t=o.normalizeToNew(),this.config?.nanOnZeroLength&&o.length()===0&&t.setAll(NaN),t;default:throw new Error(`Cannot normalize value ${o}`)}}}s("FlowGraphNormalizeBlock",_);class E extends n{constructor(o){super(h,h,i,(r,t)=>this._polymorphicDot(r,t),"FlowGraphDotBlock",o)}_polymorphicDot(o,r){switch(u(o)){case"Vector2":case"Vector3":case"Vector4":case"Quaternion":return o.dot(r);default:throw new Error(`Cannot get dot product of ${o} and ${r}`)}}}s("FlowGraphDotBlock",E);class O extends n{constructor(o){super(a,a,a,(r,t)=>F.Cross(r,t),"FlowGraphCrossBlock",o)}}s("FlowGraphCrossBlock",O);class I extends n{constructor(o){super(d,i,d,(r,t)=>r.rotate(t),"FlowGraphRotate2DBlock",o)}}s("FlowGraphRotate2DBlock",I);class L extends n{constructor(o){super(a,c,a,(r,t)=>r.applyRotationQuaternion(t),"FlowGraphRotate3DBlock",o)}}s("FlowGraphRotate3DBlock",L);function M(e,o){switch(u(e)){case"Vector2":return o.transformVector(e);case"Vector3":return o.transformVector(e);case"Vector4":return e=e,new C(e.x*o.m[0]+e.y*o.m[1]+e.z*o.m[2]+e.w*o.m[3],e.x*o.m[4]+e.y*o.m[5]+e.z*o.m[6]+e.w*o.m[7],e.x*o.m[8]+e.y*o.m[9]+e.z*o.m[10]+e.w*o.m[11],e.x*o.m[12]+e.y*o.m[13]+e.z*o.m[14]+e.w*o.m[15]);default:throw new Error(`Cannot transform value ${e}`)}}class v extends n{constructor(o){const r=o?.vectorType||"Vector3",t=r==="Vector2"?"Matrix2D":r==="Vector3"?"Matrix3D":"Matrix";super(m(r),m(t),m(r),M,"FlowGraphTransformVectorBlock",o)}}s("FlowGraphTransformVectorBlock",v);class $ extends n{constructor(o){super(a,A,a,(r,t)=>F.TransformCoordinates(r,t),"FlowGraphTransformCoordinatesBlock",o)}}s("FlowGraphTransformCoordinatesBlock",$);class j extends B{constructor(o){super(c,c,r=>r.conjugate(),"FlowGraphConjugateBlock",o)}}s("FlowGraphConjugateBlock",j);class U extends n{constructor(o){super(c,c,i,(r,t)=>R(r,t),"FlowGraphAngleBetweenBlock",o)}}s("FlowGraphAngleBetweenBlock",U);class Z extends n{constructor(o){super(a,i,c,(r,t)=>w.RotationAxis(r,t),"FlowGraphQuaternionFromAxisAngleBlock",o)}}s("FlowGraphQuaternionFromAxisAngleBlock",Z);class q extends f{constructor(o){super(o),this.a=this.registerDataInput("a",c),this.axis=this.registerDataOutput("axis",a),this.angle=this.registerDataOutput("angle",i),this.isValid=this.registerDataOutput("isValid",y)}_updateOutputs(o){const r=o._getExecutionVariable(this,x,-1),t=o._getExecutionVariable(this,G,null),l=o._getExecutionVariable(this,V,null);if(t!=null&&l!==void 0&&l!==null&&r===o.executionId)this.axis.setValue(t,o),this.angle.setValue(l,o);else try{const{axis:p,angle:g}=this.a.getValue(o).toAxisAngle();o._setExecutionVariable(this,G,p),o._setExecutionVariable(this,V,g),o._setExecutionVariable(this,x,o.executionId),this.axis.setValue(p,o),this.angle.setValue(g,o),this.isValid.setValue(!0,o)}catch{this.isValid.setValue(!1,o)}}getClassName(){return"FlowGraphAxisAngleFromQuaternionBlock"}}s("FlowGraphAxisAngleFromQuaternionBlock",q);class b extends n{constructor(o){super(a,a,c,(r,t)=>N(r,t),"FlowGraphQuaternionFromDirectionsBlock",o)}}export{U as FlowGraphAngleBetweenBlock,q as FlowGraphAxisAngleFromQuaternionBlock,j as FlowGraphConjugateBlock,O as FlowGraphCrossBlock,E as FlowGraphDotBlock,z as FlowGraphLengthBlock,_ as FlowGraphNormalizeBlock,Z as FlowGraphQuaternionFromAxisAngleBlock,b as FlowGraphQuaternionFromDirectionsBlock,I as FlowGraphRotate2DBlock,L as FlowGraphRotate3DBlock,v as FlowGraphTransformBlock,$ as FlowGraphTransformCoordinatesBlock};
