UNPKG

@babylonjs/viewer

Version:

The Babylon Viewer aims to simplify a specific but common Babylon.js use case: loading, viewing, and interacting with a 3D model.

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