@awayjs/graphics
Version:
AwayJS graphics classes
1 lines • 347 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@awayjs/core"),require("@awayjs/renderer"),require("@awayjs/stage"),require("@awayjs/view")):"function"==typeof define&&define.amd?define(["exports","@awayjs/core","@awayjs/renderer","@awayjs/stage","@awayjs/view"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).AwayjsGraphics={},t.AwayjsCore,t.AwayjsRenderer,t.AwayjsStage,t.AwayjsView)}(this,(function(t,e,i,A,n){"use strict";var r=function(){function t(){this._pVertexBuffer=new Array(8),this._pBufferContext=new Array(8),this._pBufferDirty=new Array(8),this.numProcessedVertices=0,this.previousTime=Number.NEGATIVE_INFINITY,this.animationParticles=new Array;for(var e=0;e<8;e++)this._pBufferDirty[e]=!0;this._iUniqueId=t.SUBGEOM_ID_COUNT++}return t.prototype.createVertexData=function(t,e){this._numVertices=t,this._totalLenOfOneVertex=e,this._pVertexData=new Float32Array(t*e)},t.prototype.activateVertexBuffer=function(t,e,i,A){var n=i.stageIndex,r=i.context,o=this._pVertexBuffer[n];o&&this._pBufferContext[n]==r||(o=this._pVertexBuffer[n]=r.createVertexBuffer(this._numVertices,4*this._totalLenOfOneVertex),this._pBufferContext[n]=r,this._pBufferDirty[n]=!0),this._pBufferDirty[n]&&(o.uploadFromArray(this._pVertexData,0,this._numVertices),this._pBufferDirty[n]=!1),r.setVertexBufferAt(t,o,4*e,A)},t.prototype.dispose=function(){for(;this._pVertexBuffer.length;){var t=this._pVertexBuffer.pop();t&&t.dispose()}},t.prototype.invalidateBuffer=function(){for(var t=0;t<8;t++)this._pBufferDirty[t]=!0},Object.defineProperty(t.prototype,"vertexData",{get:function(){return this._pVertexData},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"numVertices",{get:function(){return this._numVertices},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"totalLenOfOneVertex",{get:function(){return this._totalLenOfOneVertex},enumerable:!1,configurable:!0}),t.SUBGEOM_ID_COUNT=0,t}(),o=function(){function t(t,e){if(t<=0||t>=1)throw new Error("life exceeds range (0,1)");this._life=t,this._color=e}return Object.defineProperty(t.prototype,"color",{get:function(){return this._color},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"life",{get:function(){return this._life},enumerable:!1,configurable:!0}),t}(),s=function(){function t(){this.orientation=new e.Quaternion,this.translation=new e.Vector3D}return t.prototype.toMatrix3D=function(t){return void 0===t&&(t=null),null==t&&(t=new e.Matrix3D),this.orientation.toMatrix3D(t),t.appendTranslation(this.translation.x,this.translation.y,this.translation.z),t},t.prototype.copyFrom=function(t){var e=t.orientation,i=t.translation;this.orientation.x=e.x,this.orientation.y=e.y,this.orientation.z=e.z,this.orientation.w=e.w,this.translation.x=i.x,this.translation.y=i.y,this.translation.z=i.z},t}(),a=function(t,e,i,A,n){this.index=t,this.startTime=e,this.totalTime=i+A,this.duration=i,this.delay=A,this.startVertexIndex=n.startVertexIndex,this.numVertices=n.numVertices},g=function(){},l=function(){function t(){}return t.GLOBAL=0,t.LOCAL_STATIC=1,t.LOCAL_DYNAMIC=2,t}(),h=function(t,e){return h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},h(t,e)};function I(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}h(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}"function"==typeof SuppressedError&&SuppressedError;var c=function(t){function e(){var e=t.call(this)||this;return e.joints=new Array,e}return I(e,t),Object.defineProperty(e.prototype,"numJoints",{get:function(){return this.joints.length},enumerable:!1,configurable:!0}),e.prototype.jointFromName=function(t){var e=this.jointIndexFromName(t);return-1!=e?this.joints[e]:null},e.prototype.jointIndexFromName=function(t){for(var e,i;i<this.joints.length;i++){if(this.joints[i].name==t)return e;e++}return-1},e.prototype.dispose=function(){this.joints.length=0},Object.defineProperty(e.prototype,"assetType",{get:function(){return e.assetType},enumerable:!1,configurable:!0}),e.assetType="[asset Skeleton]",e}(e.AssetBase),p=function(){this.parentIndex=-1},C=function(t){function e(){var e=t.call(this)||this;return e.jointPoses=new Array,e}return I(e,t),Object.defineProperty(e.prototype,"numJointPoses",{get:function(){return this.jointPoses.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"assetType",{get:function(){return e.assetType},enumerable:!1,configurable:!0}),e.prototype.jointPoseFromName=function(t){var e=this.jointPoseIndexFromName(t);return-1!=e?this.jointPoses[e]:null},e.prototype.jointPoseIndexFromName=function(t){for(var e,i;i<this.jointPoses.length;i++){if(this.jointPoses[i].name==t)return e;e++}return-1},e.prototype.clone=function(){for(var t=new e,i=this.jointPoses.length,A=0;A<i;A++){var n=new s,r=this.jointPoses[A];n.name=r.name,n.copyFrom(r),t.jointPoses[A]=n}return t},e.prototype.dispose=function(){this.jointPoses.length=0},e.assetType="[asset SkeletonPose]",e}(e.AssetBase),u=function(){function t(){}return t.ADDITIVE="additive",t.ABSOLUTE="absolute",t}(),d=function(t){function i(){var i=t.call(this)||this;return i._pLooping=!0,i._pTotalDuration=0,i._pStitchDirty=!0,i._pStitchFinalFrame=!1,i._pNumFrames=0,i._pDurations=new Array,i._pTotalDelta=new e.Vector3D,i.fixedFrameRate=!0,i}return I(i,t),Object.defineProperty(i.prototype,"looping",{get:function(){return this._pLooping},set:function(t){this._pLooping!=t&&(this._pLooping=t,this._pStitchDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"stitchFinalFrame",{get:function(){return this._pStitchFinalFrame},set:function(t){this._pStitchFinalFrame!=t&&(this._pStitchFinalFrame=t,this._pStitchDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"totalDuration",{get:function(){return this._pStitchDirty&&this._pUpdateStitch(),this._pTotalDuration},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"totalDelta",{get:function(){return this._pStitchDirty&&this._pUpdateStitch(),this._pTotalDelta},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"lastFrame",{get:function(){return this._pStitchDirty&&this._pUpdateStitch(),this._pLastFrame},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"durations",{get:function(){return this._pDurations},enumerable:!1,configurable:!0}),i.prototype._pUpdateStitch=function(){this._pStitchDirty=!1,this._pLastFrame=this._pStitchFinalFrame?this._pNumFrames:this._pNumFrames-1,this._pTotalDuration=0,this._pTotalDelta.x=0,this._pTotalDelta.y=0,this._pTotalDelta.z=0},i}(i.AnimationNodeBase),_=function(){function t(t,i){this._pRootDelta=new e.Vector3D,this._pPositionDeltaDirty=!0,this._pStartTime=0,this._pAnimator=t,this._pAnimationNode=i}return Object.defineProperty(t.prototype,"positionDelta",{get:function(){return this._pPositionDeltaDirty&&this._pUpdatePositionDelta(),this._pRootDelta},enumerable:!1,configurable:!0}),t.prototype.offset=function(t){this._pStartTime=t,this._pPositionDeltaDirty=!0},t.prototype.update=function(t){this._pTime!=t-this._pStartTime&&this._pUpdateTime(t)},t.prototype.phase=function(t){},t.prototype._pUpdateTime=function(t){this._pTime=t-this._pStartTime,this._pPositionDeltaDirty=!0},t.prototype._pUpdatePositionDelta=function(){},t}(),f=function(t){function e(e,i,A){void 0===A&&(A=!1);var n=t.call(this,e,i)||this;return n._pDynamicProperties=new Array,n._pDynamicPropertiesDirty=new Object,n._pParticleAnimator=e,n._particleNode=i,n._pNeedUpdateTime=A,n}return I(e,t),Object.defineProperty(e.prototype,"needUpdateTime",{get:function(){return this._pNeedUpdateTime},enumerable:!1,configurable:!0}),e.prototype.setRenderState=function(t,e,i,A){},e.prototype._pUpdateDynamicProperties=function(t){this._pDynamicPropertiesDirty[t._iUniqueId]=!0;for(var e,i,A,n,r,o=t.animationParticles,s=t.vertexData,a=t.totalLenOfOneVertex,g=this._particleNode.dataLength,l=this._particleNode._iDataOffset,h=this._pDynamicProperties.length,I=0,c=0,p=0;I<h;){for(;c<h&&(r=o[c]).index==I;){for(n=this._pDynamicProperties[I],e=r.numVertices*a,i=r.startVertexIndex*a+l,p=0;p<e;p+=a)for(A=i+p,p=0;p<e;p+=a)A=i+p,s[A++]=n.x,s[A++]=n.y,s[A++]=n.z,4==g&&(s[A++]=n.w);c++}I++}t.invalidateBuffer()},e}(_),E=function(t){function i(e,i){var A=t.call(this,e,i)||this;return A._particleAccelerationNode=i,A._acceleration=A._particleAccelerationNode._acceleration,A.updateAccelerationData(),A}return I(i,t),Object.defineProperty(i.prototype,"acceleration",{get:function(){return this._acceleration},set:function(t){this._acceleration.x=t.x,this._acceleration.y=t.y,this._acceleration.z=t.z,this.updateAccelerationData()},enumerable:!1,configurable:!0}),i.prototype.setRenderState=function(t,e,n,r){var o=r.getRegisterIndex(this._pAnimationNode,i.ACCELERATION_INDEX);this._particleAccelerationNode.mode==l.LOCAL_STATIC?n.activateVertexBuffer(o,this._particleAccelerationNode._iDataOffset,t.stage,A.ContextGLVertexBufferFormat.FLOAT_3):t.setVertexConst(o,this._halfAcceleration.x,this._halfAcceleration.y,this._halfAcceleration.z)},i.prototype.updateAccelerationData=function(){this._particleAccelerationNode.mode==l.GLOBAL&&(this._halfAcceleration=new e.Vector3D(this._acceleration.x/2,this._acceleration.y/2,this._acceleration.z/2))},i.ACCELERATION_INDEX=0,i}(f),y=function(t){function e(i,A,n,r){void 0===r&&(r=1);var o=t.call(this)||this;return o._pDataLength=3,i+=e.MODES[A],o.name=i,o._pMode=A,o._priority=r,o._pDataLength=n,o._pOneData=new Array(o._pDataLength),o}return I(e,t),Object.defineProperty(e.prototype,"mode",{get:function(){return this._pMode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"priority",{get:function(){return this._priority},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dataLength",{get:function(){return this._pDataLength},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"oneData",{get:function(){return this._pOneData},enumerable:!1,configurable:!0}),e.prototype.getAGALVertexCode=function(t,e,i,A){return""},e.prototype.getAGALFragmentCode=function(t,e,i,A){return""},e.prototype.getAGALUVCode=function(t,e,i,A){return""},e.prototype._iGeneratePropertyOfOneParticle=function(t){},e.prototype._iProcessAnimationSetting=function(t){},e.GLOBAL="Global",e.LOCAL_STATIC="LocalStatic",e.LOCAL_DYNAMIC="LocalDynamic",e.MODES={0:e.GLOBAL,1:e.LOCAL_STATIC,2:e.LOCAL_DYNAMIC},e}(i.AnimationNodeBase),B=function(t){function i(i,A){void 0===A&&(A=null);var n=t.call(this,"ParticleAcceleration",i,3)||this;return n._pStateClass=E,n._acceleration=A||new e.Vector3D,n}return I(i,t),i.prototype.getAGALVertexCode=function(t,e,i,A){var n=this._pMode==l.GLOBAL?i.getFreeVertexConstant():i.getFreeVertexAttribute();A.setRegisterIndex(this,E.ACCELERATION_INDEX,n.index);var r=i.getFreeVertexVectorTemp();i.addVertexTempUsages(r,1);var o="mul "+r+","+A.vertexTime+","+n+"\n";if(e.needVelocity){var s=i.getFreeVertexVectorTemp();o+="mul "+s+","+r+","+A.vertexTwoConst+"\n",o+="add "+A.velocityTarget+".xyz,"+s+".xyz,"+A.velocityTarget+".xyz\n"}return i.removeVertexTempUsage(r),o+="mul "+r+","+r+","+A.vertexTime+"\n",o+="add "+A.positionTarget+".xyz,"+r+","+A.positionTarget+".xyz\n"},i.prototype.getAnimationState=function(t){return t.getAnimationState(this)},i.prototype._iGeneratePropertyOfOneParticle=function(t){var e=t[i.ACCELERATION_VECTOR3D];if(!e)throw new Error("there is no "+i.ACCELERATION_VECTOR3D+" in param!");this._pOneData[0]=e.x/2,this._pOneData[1]=e.y/2,this._pOneData[2]=e.z/2},i.ACCELERATION_VECTOR3D="AccelerationVector3D",i}(y),m=function(t){function e(e,i){var A=t.call(this,e,i)||this;return A._particleBezierCurveNode=i,A._controlPoint=A._particleBezierCurveNode._iControlPoint,A._endPoint=A._particleBezierCurveNode._iEndPoint,A}return I(e,t),Object.defineProperty(e.prototype,"controlPoint",{get:function(){return this._controlPoint},set:function(t){this._controlPoint=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endPoint",{get:function(){return this._endPoint},set:function(t){this._endPoint=t},enumerable:!1,configurable:!0}),e.prototype.setRenderState=function(t,i,n,r){var o=r.getRegisterIndex(this._pAnimationNode,e.BEZIER_CONTROL_INDEX),s=r.getRegisterIndex(this._pAnimationNode,e.BEZIER_END_INDEX);this._particleBezierCurveNode.mode==l.LOCAL_STATIC?(n.activateVertexBuffer(o,this._particleBezierCurveNode._iDataOffset,t.stage,A.ContextGLVertexBufferFormat.FLOAT_3),n.activateVertexBuffer(s,this._particleBezierCurveNode._iDataOffset+3,t.stage,A.ContextGLVertexBufferFormat.FLOAT_3)):(t.setVertexConst(o,this._controlPoint.x,this._controlPoint.y,this._controlPoint.z),t.setVertexConst(s,this._endPoint.x,this._endPoint.y,this._endPoint.z))},e.BEZIER_CONTROL_INDEX=0,e.BEZIER_END_INDEX=1,e}(f),Q=function(t){function i(i,A,n){void 0===A&&(A=null),void 0===n&&(n=null);var r=t.call(this,"ParticleBezierCurve",i,6)||this;return r._pStateClass=m,r._iControlPoint=A||new e.Vector3D,r._iEndPoint=n||new e.Vector3D,r}return I(i,t),i.prototype.getAGALVertexCode=function(t,e,i,n){var r=this._pMode==l.GLOBAL?i.getFreeVertexConstant():i.getFreeVertexAttribute();n.setRegisterIndex(this,m.BEZIER_CONTROL_INDEX,r.index);var o=this._pMode==l.GLOBAL?i.getFreeVertexConstant():i.getFreeVertexAttribute();n.setRegisterIndex(this,m.BEZIER_END_INDEX,o.index);var s=i.getFreeVertexVectorTemp(),a=new A.ShaderRegisterElement(s.regName,s.index,0),g=new A.ShaderRegisterElement(s.regName,s.index,1),h=new A.ShaderRegisterElement(s.regName,s.index,2);i.addVertexTempUsages(s,1);var I=i.getFreeVertexVectorTemp(),c=new A.ShaderRegisterElement(I.regName,I.index);i.removeVertexTempUsage(s);var p="";return p+="sub "+a+","+n.vertexOneConst+","+n.vertexLife+"\n",p+="mul "+g+","+n.vertexLife+","+n.vertexLife+"\n",p+="mul "+h+","+n.vertexLife+","+a+"\n",p+="mul "+h+","+h+","+n.vertexTwoConst+"\n",p+="mul "+c+".xyz,"+h+","+r+"\n",p+="add "+n.positionTarget+".xyz,"+c+".xyz,"+n.positionTarget+".xyz\n",p+="mul "+c+".xyz,"+g+","+o+"\n",p+="add "+n.positionTarget+".xyz,"+c+".xyz,"+n.positionTarget+".xyz\n",e.needVelocity&&(p+="mul "+g+","+n.vertexLife+","+n.vertexTwoConst+"\n",p+="sub "+h+","+n.vertexOneConst+","+g+"\n",p+="mul "+h+","+n.vertexTwoConst+","+h+"\n",p+="mul "+c+".xyz,"+r+","+h+"\n",p+="add "+n.velocityTarget+".xyz,"+c+".xyz,"+n.velocityTarget+".xyz\n",p+="mul "+c+".xyz,"+o+","+g+"\n",p+="add "+n.velocityTarget+".xyz,"+c+".xyz,"+n.velocityTarget+".xyz\n"),p},i.prototype.getAnimationState=function(t){return t.getAnimationState(this)},i.prototype._iGeneratePropertyOfOneParticle=function(t){var e=t[i.BEZIER_CONTROL_VECTOR3D];if(!e)throw new Error("there is no "+i.BEZIER_CONTROL_VECTOR3D+" in param!");var A=t[i.BEZIER_END_VECTOR3D];if(!A)throw new Error("there is no "+i.BEZIER_END_VECTOR3D+" in param!");this._pOneData[0]=e.x,this._pOneData[1]=e.y,this._pOneData[2]=e.z,this._pOneData[3]=A.x,this._pOneData[4]=A.y,this._pOneData[5]=A.z},i.BEZIER_CONTROL_VECTOR3D="BezierControlVector3D",i.BEZIER_END_VECTOR3D="BezierEndVector3D",i}(y),D=function(t){function i(i,A){var n=t.call(this,i,A)||this;return n._matrix=new e.Matrix3D,n._billboardAxis=A._iBillboardAxis,n}return I(i,t),i.prototype.setRenderState=function(t,A,n,r){var o;if(this._billboardAxis){var s=A.entity.node.getMatrix3D().position,a=t.view.projection.transform.matrix3D.position.subtract(s),g=a.crossProduct(this._billboardAxis);g.normalize(),(a=this.billboardAxis.crossProduct(g)).normalize(),this._matrix.copyFrom(A.entity.node.getMatrix3D()),o=this._matrix.decompose(e.Orientation3D.AXIS_ANGLE),this._matrix.copyColumnFrom(0,g),this._matrix.copyColumnFrom(1,this.billboardAxis),this._matrix.copyColumnFrom(2,a),this._matrix.copyColumnFrom(3,s),this._matrix.appendRotation(-o[1].w*e.MathConsts.RADIANS_TO_DEGREES,o[1])}else this._matrix.copyFrom(A.entity.node.getMatrix3D()),this._matrix.append(t.view.projection.transform.inverseMatrix3D),o=this._matrix.decompose(e.Orientation3D.AXIS_ANGLE),this._matrix.identity(),this._matrix.appendRotation(-o[1].w*e.MathConsts.RADIANS_TO_DEGREES,o[1]);t.setVertexConstFromMatrix(r.getRegisterIndex(this._pAnimationNode,i.MATRIX_INDEX),this._matrix)},Object.defineProperty(i.prototype,"billboardAxis",{get:function(){return this.billboardAxis},set:function(t){this.billboardAxis=t?t.clone():null,this.billboardAxis&&this.billboardAxis.normalize()},enumerable:!1,configurable:!0}),i.MATRIX_INDEX=0,i}(f),v=function(t){function e(e){void 0===e&&(e=null);var i=t.call(this,"ParticleBillboard",l.GLOBAL,0,4)||this;return i._pStateClass=D,i._iBillboardAxis=e,i}return I(e,t),e.prototype.getAGALVertexCode=function(t,e,i,A){var n=i.getFreeVertexConstant();A.setRegisterIndex(this,D.MATRIX_INDEX,n.index),i.getFreeVertexConstant(),i.getFreeVertexConstant(),i.getFreeVertexConstant();for(var r,o=i.getFreeVertexVectorTemp(),s="m33 "+o+".xyz,"+A.scaleAndRotateTarget+","+n+"\nmov "+A.scaleAndRotateTarget+".xyz,"+o+"\n",a=0;a<A.rotationRegisters.length;a++)s+="m33 "+o+".xyz,"+(r=A.rotationRegisters[a])+","+n+"\nmov "+r+".xyz,"+r+"\n";return s},e.prototype.getAnimationState=function(t){return t.getAnimationState(this)},e.prototype._iProcessAnimationSetting=function(t){t.hasBillboard=!0},e}(y),x=function(t){function i(e,i){var A=t.call(this,e,i)||this;return A._particleColorNode=i,A._usesMultiplier=A._particleColorNode._iUsesMultiplier,A._usesOffset=A._particleColorNode._iUsesOffset,A._usesCycle=A._particleColorNode._iUsesCycle,A._usesPhase=A._particleColorNode._iUsesPhase,A._startColor=A._particleColorNode._iStartColor,A._endColor=A._particleColorNode._iEndColor,A._cycleDuration=A._particleColorNode._iCycleDuration,A._cyclePhase=A._particleColorNode._iCyclePhase,A.updateColorData(),A}return I(i,t),Object.defineProperty(i.prototype,"startColor",{get:function(){return this._startColor},set:function(t){this._startColor=t,this.updateColorData()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"endColor",{get:function(){return this._endColor},set:function(t){this._endColor=t,this.updateColorData()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"cycleDuration",{get:function(){return this._cycleDuration},set:function(t){this._cycleDuration=t,this.updateColorData()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"cyclePhase",{get:function(){return this._cyclePhase},set:function(t){this._cyclePhase=t,this.updateColorData()},enumerable:!1,configurable:!0}),i.prototype.setRenderState=function(t,e,n,r){if(t.usesFragmentAnimation){var o=this._particleColorNode._iDataOffset;this._usesCycle&&t.setVertexConst(r.getRegisterIndex(this._pAnimationNode,i.CYCLE_INDEX),this._cycleData.x,this._cycleData.y,this._cycleData.z,this._cycleData.w),this._usesMultiplier&&(this._particleColorNode.mode==l.LOCAL_STATIC?(n.activateVertexBuffer(r.getRegisterIndex(this._pAnimationNode,i.START_MULTIPLIER_INDEX),o,t.stage,A.ContextGLVertexBufferFormat.FLOAT_4),o+=4,n.activateVertexBuffer(r.getRegisterIndex(this._pAnimationNode,i.DELTA_MULTIPLIER_INDEX),o,t.stage,A.ContextGLVertexBufferFormat.FLOAT_4),o+=4):(t.setVertexConst(r.getRegisterIndex(this._pAnimationNode,i.START_MULTIPLIER_INDEX),this._startMultiplierData.x,this._startMultiplierData.y,this._startMultiplierData.z,this._startMultiplierData.w),t.setVertexConst(r.getRegisterIndex(this._pAnimationNode,i.DELTA_MULTIPLIER_INDEX),this._deltaMultiplierData.x,this._deltaMultiplierData.y,this._deltaMultiplierData.z,this._deltaMultiplierData.w))),this._usesOffset&&(this._particleColorNode.mode==l.LOCAL_STATIC?(n.activateVertexBuffer(r.getRegisterIndex(this._pAnimationNode,i.START_OFFSET_INDEX),o,t.stage,A.ContextGLVertexBufferFormat.FLOAT_4),o+=4,n.activateVertexBuffer(r.getRegisterIndex(this._pAnimationNode,i.DELTA_OFFSET_INDEX),o,t.stage,A.ContextGLVertexBufferFormat.FLOAT_4)):(t.setVertexConst(r.getRegisterIndex(this._pAnimationNode,i.START_OFFSET_INDEX),this._startOffsetData.x,this._startOffsetData.y,this._startOffsetData.z,this._startOffsetData.w),t.setVertexConst(r.getRegisterIndex(this._pAnimationNode,i.DELTA_OFFSET_INDEX),this._deltaOffsetData.x,this._deltaOffsetData.y,this._deltaOffsetData.z,this._deltaOffsetData.w)))}},i.prototype.updateColorData=function(){if(this._usesCycle){if(this._cycleDuration<=0)throw new Error("the cycle duration must be greater than zero");this._cycleData=new e.Vector3D(2*Math.PI/this._cycleDuration,this._cyclePhase*Math.PI/180,0,0)}this._particleColorNode.mode==l.GLOBAL&&(this._usesCycle?(this._usesMultiplier&&(this._startMultiplierData=new e.Vector3D((this._startColor.redMultiplier+this._endColor.redMultiplier)/2,(this._startColor.greenMultiplier+this._endColor.greenMultiplier)/2,(this._startColor.blueMultiplier+this._endColor.blueMultiplier)/2,(this._startColor.alphaMultiplier+this._endColor.alphaMultiplier)/2),this._deltaMultiplierData=new e.Vector3D((this._endColor.redMultiplier-this._startColor.redMultiplier)/2,(this._endColor.greenMultiplier-this._startColor.greenMultiplier)/2,(this._endColor.blueMultiplier-this._startColor.blueMultiplier)/2,(this._endColor.alphaMultiplier-this._startColor.alphaMultiplier)/2)),this._usesOffset&&(this._startOffsetData=new e.Vector3D((this._startColor.redOffset+this._endColor.redOffset)/510,(this._startColor.greenOffset+this._endColor.greenOffset)/510,(this._startColor.blueOffset+this._endColor.blueOffset)/510,(this._startColor.alphaOffset+this._endColor.alphaOffset)/510),this._deltaOffsetData=new e.Vector3D((this._endColor.redOffset-this._startColor.redOffset)/510,(this._endColor.greenOffset-this._startColor.greenOffset)/510,(this._endColor.blueOffset-this._startColor.blueOffset)/510,(this._endColor.alphaOffset-this._startColor.alphaOffset)/510))):(this._usesMultiplier&&(this._startMultiplierData=new e.Vector3D(this._startColor.redMultiplier,this._startColor.greenMultiplier,this._startColor.blueMultiplier,this._startColor.alphaMultiplier),this._deltaMultiplierData=new e.Vector3D(this._endColor.redMultiplier-this._startColor.redMultiplier,this._endColor.greenMultiplier-this._startColor.greenMultiplier,this._endColor.blueMultiplier-this._startColor.blueMultiplier,this._endColor.alphaMultiplier-this._startColor.alphaMultiplier)),this._usesOffset&&(this._startOffsetData=new e.Vector3D(this._startColor.redOffset/255,this._startColor.greenOffset/255,this._startColor.blueOffset/255,this._startColor.alphaOffset/255),this._deltaOffsetData=new e.Vector3D((this._endColor.redOffset-this._startColor.redOffset)/255,(this._endColor.greenOffset-this._startColor.greenOffset)/255,(this._endColor.blueOffset-this._startColor.blueOffset)/255,(this._endColor.alphaOffset-this._startColor.alphaOffset)/255))))},i.START_MULTIPLIER_INDEX=0,i.DELTA_MULTIPLIER_INDEX=1,i.START_OFFSET_INDEX=2,i.DELTA_OFFSET_INDEX=3,i.CYCLE_INDEX=4,i}(f),S=function(t){function e(e,i){var A=t.call(this,e,i,!0)||this;return A._particleTimeNode=i,A}return I(e,t),e.prototype.setRenderState=function(t,i,n,r){n.activateVertexBuffer(r.getRegisterIndex(this._pAnimationNode,e.TIME_STREAM_INDEX),this._particleTimeNode._iDataOffset,t.stage,A.ContextGLVertexBufferFormat.FLOAT_4);var o=this._pTime/1e3;t.setVertexConst(r.getRegisterIndex(this._pAnimationNode,e.TIME_CONSTANT_INDEX),o,o,o,o)},e.TIME_STREAM_INDEX=0,e.TIME_CONSTANT_INDEX=1,e}(f),w=function(t){function e(e,i,A){void 0===e&&(e=!1),void 0===i&&(i=!1),void 0===A&&(A=!1);var n=t.call(this,"ParticleTime",l.LOCAL_STATIC,4,0)||this;return n._pStateClass=S,n._iUsesDuration=e,n._iUsesLooping=i,n._iUsesDelay=A,n}return I(e,t),e.prototype.getAGALVertexCode=function(t,e,i,A){var n=i.getFreeVertexAttribute();A.setRegisterIndex(this,S.TIME_STREAM_INDEX,n.index);var r=i.getFreeVertexConstant();A.setRegisterIndex(this,S.TIME_CONSTANT_INDEX,r.index);var o="";o+="sub "+A.vertexTime+","+r+","+n+".x\n";var s=i.getFreeVertexSingleTemp();if(o+="sge "+s+","+A.vertexTime+","+A.vertexZeroConst+"\n",o+="mul "+A.scaleAndRotateTarget+".xyz,"+A.scaleAndRotateTarget+".xyz,"+s+"\n",this._iUsesDuration)if(this._iUsesLooping){var a=i.getFreeVertexSingleTemp();this._iUsesDelay?(o+="div "+a+","+A.vertexTime+","+n+".z\n",o+="frc "+a+","+a+"\n",o+="mul "+A.vertexTime+","+a+","+n+".z\n",o+="slt "+a+","+A.vertexTime+","+n+".y\n",o+="mul "+A.scaleAndRotateTarget+".xyz,"+A.scaleAndRotateTarget+".xyz,"+a+"\n"):(o+="mul "+a+","+A.vertexTime+","+n+".w\n",o+="frc "+a+","+a+"\n",o+="mul "+A.vertexTime+","+a+","+n+".y\n")}else{var g=i.getFreeVertexSingleTemp();o+="sge "+g+","+n+".y,"+A.vertexTime+"\n",o+="mul "+A.scaleAndRotateTarget+".xyz,"+A.scaleAndRotateTarget+".xyz,"+g+"\n"}return o+="mul "+A.vertexLife+","+A.vertexTime+","+n+".w\n"},e.prototype.getAnimationState=function(t){return t.getAnimationState(this)},e.prototype._iGeneratePropertyOfOneParticle=function(t){this._pOneData[0]=t.startTime,this._pOneData[1]=t.duration,this._pOneData[2]=t.delay+t.duration,this._pOneData[3]=1/t.duration},e}(y),b=function(t){function e(e){return t.call(this,e)||this}return I(e,t),e}(e.ErrorBase),N=function(t){function i(){var e=t.call(this)||this;return e._animations=new Array,e._animationNames=new Array,e._animationDictionary=new Object,e}return I(i,t),i.prototype._pFindTempReg=function(t,e){void 0===e&&(e=null);for(var i,A=0;;){if(i="vt"+A,-1==t.indexOf(i)&&e!=i)return i;++A}},Object.defineProperty(i.prototype,"usesCPU",{get:function(){return this._usesCPU},enumerable:!1,configurable:!0}),i.prototype.resetGPUCompatibility=function(){this._usesCPU=!1},i.prototype.cancelGPUCompatibility=function(){this._usesCPU=!0},i.prototype.getAGALVertexCode=function(t,i,A){throw new e.AbstractMethodError},i.prototype.getAGALFragmentCode=function(t,i,A){throw new e.AbstractMethodError},i.prototype.getAGALUVCode=function(t,i,A){throw new e.AbstractMethodError},i.prototype.doneAGALCode=function(t){throw new e.AbstractMethodError},Object.defineProperty(i.prototype,"assetType",{get:function(){return i.assetType},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"animations",{get:function(){return this._animations},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"animationNames",{get:function(){return this._animationNames},enumerable:!1,configurable:!0}),i.prototype.hasAnimation=function(t){return null!=this._animationDictionary[t]},i.prototype.getAnimation=function(t){return this._animationDictionary[t]},i.prototype.addAnimation=function(t){if(this._animationDictionary[t.name])throw new b("root node name '"+t.name+"' already exists in the set");this._animationDictionary[t.name]=t,this._animations.push(t),this._animationNames.push(t.name)},i.prototype.dispose=function(){},i.assetType="[asset AnimationSet]",i}(e.AssetBase),R=function(t){function e(e,i,A){void 0===e&&(e=!1),void 0===i&&(i=!1),void 0===A&&(A=!1);var n=t.call(this)||this;return n._animationElements=new Object,n._particleNodes=new Array,n._localDynamicNodes=new Array,n._localStaticNodes=new Array,n._totalLenOfOneVertex=0,n.addAnimation(n._timeNode=new w(e,i,A)),n}return I(e,t),Object.defineProperty(e.prototype,"particleNodes",{get:function(){return this._particleNodes},enumerable:!1,configurable:!0}),e.prototype.addAnimation=function(e){var i,A=e;for(A._iProcessAnimationSetting(this),A.mode==l.LOCAL_STATIC?(A._iDataOffset=this._totalLenOfOneVertex,this._totalLenOfOneVertex+=A.dataLength,this._localStaticNodes.push(A)):A.mode==l.LOCAL_DYNAMIC&&this._localDynamicNodes.push(A),i=this._particleNodes.length-1;i>=0&&!(this._particleNodes[i].priority<=A.priority);i--);this._particleNodes.splice(i+1,0,A),t.prototype.addAnimation.call(this,e)},e.prototype.getAGALVertexCode=function(t,A,n){this._iAnimationRegisterData=t.animationRegisterData,null==this._iAnimationRegisterData&&(this._iAnimationRegisterData=t.animationRegisterData=new i.AnimationRegisterData),this._iAnimationRegisterData.reset(A,n,this.needVelocity);for(var r,o="",s=n.animatableAttributes.length,a=0;a<s;a++)o+="mov "+n.animationTargetRegisters[a]+","+n.animatableAttributes[a]+"\n";for(o+="mov "+this._iAnimationRegisterData.positionTarget+".xyz,"+this._iAnimationRegisterData.vertexZeroConst+"\n",this.needVelocity&&(o+="mov "+this._iAnimationRegisterData.velocityTarget+".xyz,"+this._iAnimationRegisterData.vertexZeroConst+"\n"),a=0;a<this._particleNodes.length;a++)(r=this._particleNodes[a]).priority<e.POST_PRIORITY&&(o+=r.getAGALVertexCode(t,this,A,this._iAnimationRegisterData));for(o+="add "+this._iAnimationRegisterData.scaleAndRotateTarget+".xyz,"+this._iAnimationRegisterData.scaleAndRotateTarget+".xyz,"+this._iAnimationRegisterData.positionTarget+".xyz\n",a=0;a<this._particleNodes.length;a++)(r=this._particleNodes[a]).priority>=e.POST_PRIORITY&&r.priority<e.COLOR_PRIORITY&&(o+=r.getAGALVertexCode(t,this,A,this._iAnimationRegisterData));for(this.hasColorMulNode&&(this._iAnimationRegisterData.colorMulTarget=A.getFreeVertexVectorTemp(),A.addVertexTempUsages(this._iAnimationRegisterData.colorMulTarget,1),this._iAnimationRegisterData.colorMulVary=A.getFreeVarying(),o+="mov "+this._iAnimationRegisterData.colorMulTarget+","+this._iAnimationRegisterData.vertexOneConst+"\n"),this.hasColorAddNode&&(this._iAnimationRegisterData.colorAddTarget=A.getFreeVertexVectorTemp(),A.addVertexTempUsages(this._iAnimationRegisterData.colorAddTarget,1),this._iAnimationRegisterData.colorAddVary=A.getFreeVarying(),o+="mov "+this._iAnimationRegisterData.colorAddTarget+","+this._iAnimationRegisterData.vertexZeroConst+"\n"),a=0;a<this._particleNodes.length;a++)(r=this._particleNodes[a]).priority>=e.COLOR_PRIORITY&&(o+=r.getAGALVertexCode(t,this,A,this._iAnimationRegisterData));return t.usesFragmentAnimation&&(this.hasColorAddNode||this.hasColorMulNode)&&(this.hasColorMulNode&&(o+="mov "+this._iAnimationRegisterData.colorMulVary+","+this._iAnimationRegisterData.colorMulTarget+"\n"),this.hasColorAddNode&&(o+="mov "+this._iAnimationRegisterData.colorAddVary+","+this._iAnimationRegisterData.colorAddTarget+"\n")),o},e.prototype.getAGALUVCode=function(t,e,i){var A="";if(this.hasUVNode){this._iAnimationRegisterData.setUVSourceAndTarget(i),A+="mov "+this._iAnimationRegisterData.uvTarget+".xy,"+this._iAnimationRegisterData.uvAttribute.toString()+"\n";for(var n=void 0,r=0;r<this._particleNodes.length;r++)n=this._particleNodes[r];A+=n.getAGALUVCode(t,this,e,this._iAnimationRegisterData),A+="mov "+this._iAnimationRegisterData.uvVar+","+this._iAnimationRegisterData.uvTarget+".xy\n"}else A+="mov "+i.animatedUV+","+i.uvInput+"\n";return A},e.prototype.getAGALFragmentCode=function(t,e,i){var A="";return t.usesFragmentAnimation&&(this.hasColorAddNode||this.hasColorMulNode)&&(this.hasColorMulNode&&(A+="mul "+i+","+i+","+this._iAnimationRegisterData.colorMulVary+"\n"),this.hasColorAddNode&&(A+="add "+i+","+i+","+this._iAnimationRegisterData.colorAddVary+"\n")),A},e.prototype.doneAGALCode=function(t){t.setVertexConst(this._iAnimationRegisterData.vertexZeroConst.index,0,1,2,0)},Object.defineProperty(e.prototype,"usesCPU",{get:function(){return!1},enumerable:!1,configurable:!0}),e.prototype.cancelGPUCompatibility=function(){},e.prototype.dispose=function(){for(var e in this._animationElements)this._animationElements[e].dispose();t.prototype.dispose.call(this)},e.prototype.getAnimationElements=function(t,e){var i=this._animationElements[e.id];return i||(this._iGenerateAnimationElements(t),this._animationElements[e.id])},e.prototype._iGenerateAnimationElements=function(t){if(null==this.initParticleFunc)throw new Error("no initParticleFunc set");var e,i,A,n,o,s,l=!1;for(e=0;e<t.numElements;e++)o=t.elements[e],this._animationElements[o.id]||((n=this._animationElements[o.id]=new r).createVertexData(o.numVertices,this._totalLenOfOneVertex),l=!0);if(l){var h,I,c,p,C,u,d,_,f,E,y,B=t.particles,m=B.length,Q=t.numParticles,D=new g;for(D.total=Q,D.startTime=0,D.duration=1e3,D.delay=.1,e=0,i=0;e<Q;){for(D.index=e,this.initParticleFunc.call(this.initParticleScope,D),A=0;A<this._localStaticNodes.length;A++)this._localStaticNodes[A]._iGeneratePropertyOfOneParticle(D);for(;i<m&&(h=B[i]).particleIndex==e;){for(A=0;A<t.numElements;A++)if((o=t.elements[A])==h.elements){n=this._animationElements[o.id];break}for(d=h.numVertices,_=n.vertexData,f=d*this._totalLenOfOneVertex,E=n.numProcessedVertices*this._totalLenOfOneVertex,A=0;A<this._localStaticNodes.length;A++)for(u=(s=this._localStaticNodes[A]).oneData,I=s.dataLength,c=E+s._iDataOffset,p=0;p<f;p+=this._totalLenOfOneVertex)for(y=c+p,C=0;C<I;C++)_[y+C]=u[C];this._localDynamicNodes.length&&n.animationParticles.push(new a(e,D.startTime,D.duration,D.delay,h)),n.numProcessedVertices+=d,i++}e++}}},e.POST_PRIORITY=9,e.COLOR_PRIORITY=18,e}(N),F=function(t){function i(i,A,n,r,o,s,a,g,l){void 0===A&&(A=!0),void 0===n&&(n=!0),void 0===r&&(r=!1),void 0===o&&(o=!1),void 0===s&&(s=null),void 0===a&&(a=null),void 0===g&&(g=1),void 0===l&&(l=0);var h=t.call(this,"ParticleColor",i,A&&n?16:8,R.COLOR_PRIORITY)||this;return h._pStateClass=x,h._iUsesMultiplier=A,h._iUsesOffset=n,h._iUsesCycle=r,h._iUsesPhase=o,h._iStartColor=s||new e.ColorTransform,h._iEndColor=a||new e.ColorTransform,h._iCycleDuration=g,h._iCyclePhase=l,h}return I(i,t),i.prototype.getAGALVertexCode=function(t,e,i,A){var n="";if(t.usesFragmentAnimation){var r=i.getFreeVertexVectorTemp();if(this._iUsesCycle){var o=i.getFreeVertexConstant();A.setRegisterIndex(this,x.CYCLE_INDEX,o.index),i.addVertexTempUsages(r,1);var s=i.getFreeVertexSingleTemp();i.removeVertexTempUsage(r),n+="mul "+s+","+A.vertexTime+","+o+".x\n",this._iUsesPhase&&(n+="add "+s+","+s+","+o+".y\n"),n+="sin "+s+","+s+"\n"}if(this._iUsesMultiplier){var a=this._pMode==l.GLOBAL?i.getFreeVertexConstant():i.getFreeVertexAttribute(),g=this._pMode==l.GLOBAL?i.getFreeVertexConstant():i.getFreeVertexAttribute();A.setRegisterIndex(this,x.START_MULTIPLIER_INDEX,a.index),A.setRegisterIndex(this,x.DELTA_MULTIPLIER_INDEX,g.index),n+="mul "+r+","+g+","+(this._iUsesCycle?s:A.vertexLife)+"\n",n+="add "+r+","+r+","+a+"\n",n+="mul "+A.colorMulTarget+","+r+","+A.colorMulTarget+"\n"}if(this._iUsesOffset){var h=this._pMode==l.LOCAL_STATIC?i.getFreeVertexAttribute():i.getFreeVertexConstant(),I=this._pMode==l.LOCAL_STATIC?i.getFreeVertexAttribute():i.getFreeVertexConstant();A.setRegisterIndex(this,x.START_OFFSET_INDEX,h.index),A.setRegisterIndex(this,x.DELTA_OFFSET_INDEX,I.index),n+="mul "+r+","+I+","+(this._iUsesCycle?s:A.vertexLife)+"\n",n+="add "+r+","+r+","+h+"\n",n+="add "+A.colorAddTarget+","+r+","+A.colorAddTarget+"\n"}}return n},i.prototype.getAnimationState=function(t){return t.getAnimationState(this)},i.prototype._iProcessAnimationSetting=function(t){this._iUsesMultiplier&&(t.hasColorMulNode=!0),this._iUsesOffset&&(t.hasColorAddNode=!0)},i.prototype._iGeneratePropertyOfOneParticle=function(t){var e=t[i.COLOR_START_COLORTRANSFORM];if(!e)throw new Error("there is no "+i.COLOR_START_COLORTRANSFORM+" in param!");var A=t[i.COLOR_END_COLORTRANSFORM];if(!A)throw new Error("there is no "+i.COLOR_END_COLORTRANSFORM+" in param!");var n=0;this._iUsesCycle?(this._iUsesMultiplier&&(this._pOneData[n++]=(e.redMultiplier+A.redMultiplier)/2,this._pOneData[n++]=(e.greenMultiplier+A.greenMultiplier)/2,this._pOneData[n++]=(e.blueMultiplier+A.blueMultiplier)/2,this._pOneData[n++]=(e.alphaMultiplier+A.alphaMultiplier)/2,this._pOneData[n++]=(e.redMultiplier-A.redMultiplier)/2,this._pOneData[n++]=(e.greenMultiplier-A.greenMultiplier)/2,this._pOneData[n++]=(e.blueMultiplier-A.blueMultiplier)/2,this._pOneData[n++]=(e.alphaMultiplier-A.alphaMultiplier)/2),this._iUsesOffset&&(this._pOneData[n++]=(e.redOffset+A.redOffset)/510,this._pOneData[n++]=(e.greenOffset+A.greenOffset)/510,this._pOneData[n++]=(e.blueOffset+A.blueOffset)/510,this._pOneData[n++]=(e.alphaOffset+A.alphaOffset)/510,this._pOneData[n++]=(e.redOffset-A.redOffset)/510,this._pOneData[n++]=(e.greenOffset-A.greenOffset)/510,this._pOneData[n++]=(e.blueOffset-A.blueOffset)/510,this._pOneData[n++]=(e.alphaOffset-A.alphaOffset)/510)):(this._iUsesMultiplier&&(this._pOneData[n++]=e.redMultiplier,this._pOneData[n++]=e.greenMultiplier,this._pOneData[n++]=e.blueMultiplier,this._pOneData[n++]=e.alphaMultiplier,this._pOneData[n++]=A.redMultiplier-e.redMultiplier,this._pOneData[n++]=A.greenMultiplier-e.greenMultiplier,this._pOneData[n++]=A.blueMultiplier-e.blueMultiplier,this._pOneData[n++]=A.alphaMultiplier-e.alphaMultiplier),this._iUsesOffset&&(this._pOneData[n++]=e.redOffset/255,this._pOneData[n++]=e.greenOffset/255,this._pOneData[n++]=e.blueOffset/255,this._pOneData[n++]=e.alphaOffset/255,this._pOneData[n++]=(A.redOffset-e.redOffset)/255,this._pOneData[n++]=(A.greenOffset-e.greenOffset)/255,this._pOneData[n++]=(A.blueOffset-e.blueOffset)/255,this._pOneData[n++]=(A.alphaOffset-e.alphaOffset)/255))},i.COLOR_START_COLORTRANSFORM="ColorStartColorTransform",i.COLOR_END_COLORTRANSFORM="ColorEndColorTransform",i}(y),T=function(t){function i(i,A){var n=t.call(this,i,A,!0)||this;return n._targetPos=new e.Vector3D,n._targetEuler=new e.Vector3D,n._temp=new e.Vector3D,n._particleFollowNode=A,n._smooth=A._iSmooth,n}return I(i,t),Object.defineProperty(i.prototype,"followTarget",{get:function(){return this._followTarget},set:function(t){this._followTarget=t},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"smooth",{get:function(){return this._smooth},set:function(t){this._smooth=t},enumerable:!1,configurable:!0}),i.prototype.setRenderState=function(t,e,n,r){this._followTarget&&(this._particleFollowNode._iUsesPosition&&(this._targetPos.x=this._followTarget.transform.position.x/e.entity.node.container.transform.scale.x,this._targetPos.y=this._followTarget.transform.position.y/e.entity.node.container.transform.scale.y,this._targetPos.z=this._followTarget.transform.position.z/e.entity.node.container.transform.scale.z),this._particleFollowNode._iUsesRotation&&(this._targetEuler.x=this._followTarget.transform.rotation.x,this._targetEuler.y=this._followTarget.transform.rotation.y,this._targetEuler.z=this._followTarget.transform.rotation.z)),this._prePos||(this._prePos=this._targetPos.clone()),this._preEuler||(this._preEuler=this._targetEuler.clone());var o=this._pTime/1e3,s=n.previousTime,a=o-s,g=s!=o;this._particleFollowNode._iUsesPosition&&this._particleFollowNode._iUsesRotation?(g&&this.processPositionAndRotation(o,a,n),n.activateVertexBuffer(r.getRegisterIndex(this._pAnimationNode,i.FOLLOW_POSITION_INDEX),this._particleFollowNode._iDataOffset,t.stage,A.ContextGLVertexBufferFormat.FLOAT_3),n.activateVertexBuffer(r.getRegisterIndex(this._pAnimationNode,i.FOLLOW_ROTATION_INDEX),this._particleFollowNode._iDataOffset+3,t.stage,A.ContextGLVertexBufferFormat.FLOAT_3)):this._particleFollowNode._iUsesPosition?(g&&this.processPosition(o,a,n),n.activateVertexBuffer(r.getRegisterIndex(this._pAnimationNode,i.FOLLOW_POSITION_INDEX),this._particleFollowNode._iDataOffset,t.stage,A.ContextGLVertexBufferFormat.FLOAT_3)):this._particleFollowNode._iUsesRotation&&(g&&this.precessRotation(o,a,n),n.activateVertexBuffer(r.getRegisterIndex(this._pAnimationNode,i.FOLLOW_ROTATION_INDEX),this._particleFollowNode._iDataOffset,t.stage,A.ContextGLVertexBufferFormat.FLOAT_3)),this._prePos.copyFrom(this._targetPos),this._targetEuler.copyFrom(this._targetEuler),n.previousTime=o},i.prototype.processPosition=function(t,e,i){var A,n,r=i.animationParticles,o=i.vertexData,s=!1,a=r.length;this._smooth?(n=this._prePos.subtract(this._targetPos)).scaleBy(1/e):A=this._targetPos;for(var g=0;g<a;g++){var l=(t-r[g].startTime)/r[g].totalTime,h=(l-Math.floor(l))*r[g].totalTime;if(h-e<=0){var I=r[g].startVertexIndex*i.totalLenOfOneVertex+this._particleFollowNode._iDataOffset;if(this._smooth&&(this._temp.copyFrom(n),this._temp.scaleBy(h),A=this._targetPos.add(this._temp)),o[I]!=A.x||o[I+1]!=A.y||o[I+2]!=A.z){s=!0;for(var c=0;c<r[g].numVertices;c++)o[I++]=A.x,o[I++]=A.y,o[I++]=A.z}}}s&&i.invalidateBuffer()},i.prototype.precessRotation=function(t,e,i){var A,n,r=i.animationParticles,o=i.vertexData,s=!1,a=r.length;this._smooth?(n=this._preEuler.subtract(this._targetEuler)).scaleBy(1/e):A=this._targetEuler;for(var g=0;g<a;g++){var l=(t-r[g].startTime)/r[g].totalTime,h=(l-Math.floor(l))*r[g].totalTime;if(h-e<=0){var I=r[g].startVertexIndex*i.totalLenOfOneVertex+this._particleFollowNode._iDataOffset;if(this._smooth&&(this._temp.copyFrom(n),this._temp.scaleBy(h),A=this._targetEuler.add(this._temp)),o[I]!=A.x||o[I+1]!=A.y||o[I+2]!=A.z){s=!0;for(var c=0;c<r[g].numVertices;c++)o[I++]=A.x,o[I++]=A.y,o[I++]=A.z}}}s&&i.invalidateBuffer()},i.prototype.processPositionAndRotation=function(t,e,i){var A,n,r,o,s=i.animationParticles,a=i.vertexData,g=!1,l=s.length;this._smooth?((r=this._prePos.subtract(this._targetPos)).scaleBy(1/e),(o=this._preEuler.subtract(this._targetEuler)).scaleBy(1/e)):(A=this._targetPos,n=this._targetEuler);for(var h=0;h<l;h++){var I=(t-s[h].startTime)/s[h].totalTime,c=(I-Math.floor(I))*s[h].totalTime;if(c-e<=0){var p=s[h].startVertexIndex*i.totalLenOfOneVertex+this._particleFollowNode._iDataOffset;if(this._smooth&&(this._temp.copyFrom(r),this._temp.scaleBy(c),A=this._targetPos.add(this._temp),this._temp.copyFrom(o),this._temp.scaleBy(c),n=this._targetEuler.add(this._temp)),a[p]!=A.x||a[p+1]!=A.y||a[p+2]!=A.z||a[p+3]!=n.x||a[p+4]!=n.y||a[p+5]!=n.z){g=!0;for(var C=0;C<s[h].numVertices;C++)a[p++]=A.x,a[p++]=A.y,a[p++]=A.z,a[p++]=n.x,a[p++]=n.y,a[p++]=n.z}}}g&&i.invalidateBuffer()},i.FOLLOW_POSITION_INDEX=0,i.FOLLOW_ROTATION_INDEX=1,i}(f),O=function(t){function e(e,i,A){void 0===e&&(e=!0),void 0===i&&(i=!0),void 0===A&&(A=!1);var n=t.call(this,"ParticleFollow",l.LOCAL_DYNAMIC,e&&i?6:3,R.POST_PRIORITY)||this;return n._pStateClass=T,n._iUsesPosition=e,n._iUsesRotation=i,n._iSmooth=A,n}return I(e,t),e.prototype.getAGALVertexCode=function(t,e,i,A){var n="";if(this._iUsesRotation){var r=i.getFreeVertexAttribute();A.setRegisterIndex(this,T.FOLLOW_ROTATION_INDEX,r.index);var o=i.getFreeVertexVectorTemp();i.addVertexTempUsages(o,1);var s=i.getFreeVertexVectorTemp();i.addVertexTempUsages(s,1);var a=i.getFreeVertexVectorTemp(),g=void 0;e.hasBillboard&&(i.addVertexTempUsages(a,1),g=i.getFreeVertexVectorTemp()),i.removeVertexTempUsage(o),i.removeVertexTempUsage(s),e.hasBillboard&&i.removeVertexTempUsage(a);var l=A.rotationRegisters.length,h=void 0;if(n+="mov "+o+","+A.vertexZeroConst+"\n",n+="mov "+o+".x,"+A.vertexOneConst+"\n",n+="mov "+a+","+A.vertexZeroConst+"\n",n+="sin "+a+".y,"+r+".x\n",n+="cos "+a+".z,"+r+".x\n",n+="mov "+s+".x,"+A.vertexZeroConst+"\n",n+="mov "+s+".y,"+a+".z\n",n+="neg "+s+".z,"+a+".y\n",e.hasBillboard)n+="m33 "+g+".xyz,"+A.positionTarget+".xyz,"+o+"\n";else for(n+="m33 "+A.scaleAndRotateTarget+".xyz,"+A.scaleAndRotateTarget+".xyz,"+o+"\n",h=0;h<l;h++)n+="m33 "+A.rotationRegisters[h]+".xyz,"+A.rotationRegisters[h]+","+o+"\n";if(n+="mov "+o+","+A.vertexZeroConst+"\n",n+="cos "+o+".x,"+r+".y\n",n+="sin "+o+".z,"+r+".y\n",n+="mov "+s+","+A.vertexZeroConst+"\n",n+="mov "+s+".y,"+A.vertexOneConst+"\n",n+="mov "+a+","+A.vertexZeroConst+"\n",n+="neg "+a+".x,"+o+".z\n",n+="mov "+a+".z,"+o+".x\n",e.hasBillboard)n+="m33 "+g+".xyz,"+g+".xyz,"+o+"\n";else for(n+="m33 "+A.scaleAndRotateTarget+".xyz,"+A.scaleAndRotateTarget+".xyz,"+o+"\n",h=0;h<l;h++)n+="m33 "+A.rotationRegisters[h]+".xyz,"+A.rotationRegisters[h]+","+o+"\n";if(n+="mov "+s+","+A.vertexZeroConst+"\n",n+="sin "+s+".x,"+r+".z\n",n+="cos "+s+".y,"+r+".z\n",n+="mov "+o+","+A.vertexZeroConst+"\n",n+="mov "+o+".x,"+s+".y\n",n+="neg "+o+".y,"+s+".x\n",n+="mov "+a+","+A.vertexZeroConst+"\n",n+="mov "+a+".z,"+A.vertexOneConst+"\n",e.hasBillboard)n+="m33 "+g+".xyz,"+g+".xyz,"+o+"\n",n+="sub "+g+".xyz,"+g+".xyz,"+A.positionTarget+".xyz\n",n+="add "+A.scaleAndRotateTarget+".xyz,"+g+".xyz,"+A.scaleAndRotateTarget+".xyz\n";else for(n+="m33 "+A.scaleAndRotateTarget+".xyz,"+A.scaleAndRotateTarget+".xyz,"+o+"\n",h=0;h<l;h++)n+="m33 "+A.rotationRegisters[h]+".xyz,"+A.rotationRegisters[h]+","+o+"\n"}if(this._iUsesPosition){var I=i.getFreeVertexAttribute();A.setRegisterIndex(this,T.FOLLOW_POSITION_INDEX,I.index),n+="add "+A.scaleAndRotateTarget+".xyz,"+I+","+A.scaleAndRotateTarget+".xyz\n"}return n},e.prototype.getAnimationState=function(t){return t.getAnimationState(this)},e}(y),M=function(t){function i(e,i){var A=t.call(this,e,i)||this;return A._particleInitialColorNode=i,A._usesMultiplier=i._iUsesMultiplier,A._usesOffset=i._iUsesOffset,A._initialColor=i._iInitialColor,A.updateColorData(),A}return I(i,t),Object.defineProperty(i.prototype,"initialColor",{get:function(){return this._initialColor},set:function(t){this._initialColor=t},enumerable:!1,configurable:!0}),i.prototype.setRenderState=function(t,e,n,r){if(t.usesFragmentAnimation)if(this._particleInitialColorNode.mode==l.LOCAL_STATIC){var o=this._particleInitialColorNode._iDataOffset;this._usesMultiplier&&(n.activateVertexBuffer(r.getRegisterIndex(this._pAnimationNode,i.MULTIPLIER_INDEX),o,t.stage,A.ContextGLVertexBufferFormat.FLOAT_4),o+=4),this._usesOffset&&n.activateVertexBuffer(r.getRegisterIndex(this._pAnimationNode,i.OFFSET_INDEX),o,t.stage,A.ContextGLVertexBufferFormat.FLOAT_4)}else this._usesMultiplier&&t.setVertexConst(r.getRegisterIndex(this._pAnimationNode,i.MULTIPLIER_INDEX),this._multiplierData.x,this._multiplierData.y,this._multiplierData.z,this._multiplierData.w),this._usesOffset&&t.setVertexConst(r.getRegisterIndex(this._pAnimationNode,i.OFFSET_INDEX),this._offsetData.x,this._offsetData.y,this._offsetData.z,this._offsetData.w)},i.prototype.updateColorData=function(){this._particleInitialColorNode.mode==l.GLOBAL&&(this._usesMultiplier&&(this._multiplierData=new e.Vector3D(this._initialColor.redMultiplier,this._initialColor.greenMultiplier,this._initialColor.blueMultiplier,this._initialColor.alphaMultiplier)),this._usesOffset&&(this._offsetData=new e.Vector3D(this._initialColor.redOffset/255,this._initialColor.greenOffset/255,this._initialColor.blueOffset/255,this._initialColor.alphaOffset/255)))},i.MULTIPLIER_INDEX=0,i.OFFSET_INDEX=1,i}(f),P=function(t){function i(i,A,n,r){void 0===A&&(A=!0),void 0===n&&(n=!1),void 0===r&&(r=null);var o=t.call(this,"ParticleInitialColor",i,A&&n?8:4,R.COLOR_PRIORITY)||this;return o._pStateClass=M,o._iUsesMultiplier=A,o._iUsesOffset=n,o._iInitialColor=r||new e.ColorTransform,o}return I(i,t),i.prototype.getAGALVertexCode=function(t,e,i,A){var n="";if(t.usesFragmentAnimation){if(this._iUsesMultiplier){var r=this._pMode==l.GLOBAL?i.getFreeVertexConstant():i.getFreeVertexAttribute();A.setRegisterIndex(this,M.MULTIPLIER_INDEX,r.index),n+="mul "+A.colorMulTarget+","+r+","+A.colorMulTarget+"\n"}if(this._iUsesOffset){var o=this._pMode==l.LOCAL_STATIC?i.getFreeVertexAttribute():i.getFreeVertexConstant();A.setRegisterIndex(this,M.OFFSET_INDEX,o.index),n+="add "+A.colorAddTarget+","+o+","+A.colorAddTarget+"\n"}}return n},i.prototype._iProcessAnimationSetting=function(t){this._iUsesMultiplier&&(t.hasColorMulNode=!0),this._iUsesOffset&&(t.hasColorAddNode=!0)},i.prototype._iGeneratePropertyOfOneParticle=function(t){var e=t[i.COLOR_INITIAL_COLORTRANSFORM];if(!e)throw new Error("there is no "+i.COLOR_INITIAL_COLORTRANSFORM+" in param!");var A=0;this._iUsesMultiplier&&(this._pOneData[A++]=e.redMultiplier,this._pOneData[A++]=e.greenMultiplier,this._pOneData[A++]=e.blueMultiplier,this._pOneData[A++]=e.alphaMultiplier),this._iUsesOffset&&(this._pOneData[A++]=e.redOffset/255,this._pOneData[A++]=e.greenOffset/255,this._pOneData[A++]=e.blueOffset/255,this._pOneData[A++]=e.alphaOffset/255)},i.COLOR_INITIAL_COLORTRANSFORM="ColorInitialColorTransform",i}(y),L=function(t){function i(e,i){var A=t.call(this,e,i)||this;return A._particleOrbitNode=i,A._usesEulers=A._particleOrbitNode._iUsesEulers,A._usesCycle=A._particleOrbitNode._iUsesCycle,A._usesPhase=A._particleOrbitNode._iUsesPhase,A._eulers=A._particleOrbitNode._iEulers,A._radius=A._particleOrbitNode._iRadius,A._cycleDuration=A._particleOrbitNode._iCycleDuration,A._cyclePhase=A._particleOrbitNode._iCyclePhase,A.updateOrbitData(),A}return I(i,t),Object.defineProperty(i.prototype,"radius",{get:function(){return this._radius},set:function(t){this._radius=t,this.updateOrbitData()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"cycleDuration",{get:function(){return this._cycleDuration},set:function(t){this._cycleDuration=t,this.updateOrbitData()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"cyclePhase",{get:function(){return this._cyclePhase},set:function(t){this._cyclePhase=t,this.updateOrbitData()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"eulers",{get:function(){return this._eulers},set:function(t){this._eulers=t,this.updateOrbitData()},enumerable:!1,configurable:!0}),i.prototype.setRenderState=function(t,e,n,r){var o=r.getRegisterIndex(this._pAnimationNode,i.ORBIT_INDEX);this._particleOrbitNode.mode==l.LOCAL_STATIC?this._usesPhase?n.activateVertexBuffer(o,this._particleOrbitNode._iDataOffset,t.stage,A.ContextGLVertexBufferFormat.FLOAT_4):n.activateVertexBuffer(o,this._particleOrbitNode._iDataOffset,t.stage,A.ContextGLVertexBufferFormat.FLOAT_3):t.setVertexConst(o,this._orbitData.x,this._orbitData.y,this._orbitData.z,this._orbitData.w),this._usesEulers&&t.setVertexConstFromMatrix(r.getRegisterIndex(this._pAnimationNode,i.EULERS_INDEX),this._eulersMatrix)},i.prototype.updateOrbitData=function(){if(this._usesEulers&&(this._eulersMatrix=new e.Matrix3D,this._eulersMatrix.appendRotation(this._eulers.x,e.Vector3D.X_AXIS),this._eulersMatrix.appendRotation(this._eulers.y,e.Vector3D.Y_AXIS),this._eulersMatrix.appendRotation(this._eulers.z,e.Vector3D.Z_AXIS)),this._particleOrbitNode.mode==l.GLOBAL)if(this._orbitData=new e.Vector3D(this._radius,0,this._radius*Math.PI*2,this._cyclePhase*Math.PI/180),this._usesCycle){if(this._cycleDuration<=0)throw new Error("the cycle duration must be greater than zero");this._orbitData.y=2*Math.PI/this._cycleDuration}else this._orbitData.y=2*Math.PI},i.ORBIT_INDEX=0,i.EULERS_INDEX=1,i}(f),U=function(t){function i(i,A,n,r,o,s,a,g){void 0===A&&(A=!0),void 0===n&&(n=!1),void 0===r&&(r=!1),voi