mirror of
https://github.com/Cola-Echo/memory-manager-concurrent.git
synced 2026-06-06 20:35:52 +00:00
13 lines
395 KiB
JavaScript
13 lines
395 KiB
JavaScript
!function(e,t,n){var i=(n.un,n.uns,n["static"]),r=n["class"],a=n.getset,s=(n.__newvec,laya.ani.AnimationPlayer),o=(laya.ani.AnimationState,laya.ani.AnimationTemplet),l=laya.maths.Arith,h=(laya.resource.Bitmap,laya.utils.Browser),u=laya.webgl.utils.Buffer,c=(laya.webgl.utils.Buffer2D,laya.utils.Byte),_=laya.utils.ClassUtils,d=n.Config,m=laya.particle.emitter.EmitterBase,f=(laya.events.Event,laya.events.EventDispatcher),p=laya.utils.Handler,v=laya.webgl.utils.IndexBuffer2D,g=laya.net.Loader,T=laya.net.LoaderManager,x=laya.maths.MathUtil,M=laya.display.Node,E=(laya.particle.ParticleSetting,laya.particle.shader.ParticleShader),y=laya.particle.ParticleTemplateWebGL,S=(laya.maths.Rectangle,laya.renders.Render),R=(laya.renders.RenderContext,laya.renders.RenderSprite,laya.webgl.utils.RenderState2D),A=laya.resource.Resource,I=laya.utils.RunDriver,C=laya.webgl.shader.Shader,V=laya.webgl.shader.ShaderDefines,D=laya.display.Sprite,L=laya.utils.Stat,O=laya.net.URL,b=laya.webgl.utils.ValusArray,P=laya.webgl.utils.VertexBuffer2D,w=laya.webgl.WebGL,N=laya.webgl.WebGLContext;laya.webgl.canvas.WebGLContext2D,laya.webgl.resource.WebGLImage;n["interface"]("laya.d3.core.IClone"),n["interface"]("laya.d3.graphics.IVertex"),n["interface"]("laya.d3.core.render.IUpdate"),n["interface"]("laya.d3.core.render.IRenderable");var B=function(){function e(){this._tempVector30=new Qe,this._tempVector31=new Qe,this._tempVector32=new Qe,this._a=new Qe,this._b=new Qe,this._c=new Qe,this._d=new Qe}r(e,"laya.d3.core.glitter.SplineCurvePositionVelocity");var t=e.prototype;return t.Init=function(e,t,n,i){e.cloneTo(this._d),t.cloneTo(this._c),Qe.scale(e,2,this._a),Qe.scale(n,2,this._tempVector30),Qe.subtract(this._a,this._tempVector30,this._a),Qe.add(this._a,t,this._a),Qe.add(this._a,i,this._a),Qe.scale(n,3,this._b),Qe.scale(e,3,this._tempVector30),Qe.subtract(this._b,this._tempVector30,this._b),Qe.subtract(this._b,i,this._b),Qe.scale(t,2,this._tempVector30),Qe.subtract(this._b,this._tempVector30,this._b)},t.Slerp=function(e,t){Qe.scale(this._a,e*e*e,this._tempVector30),Qe.scale(this._b,e*e,this._tempVector31),Qe.scale(this._c,e,this._tempVector32),Qe.add(this._tempVector30,this._tempVector31,t),Qe.add(t,this._tempVector32,t),Qe.add(t,this._d,t)},e}(),F=function(){function e(e,t,n,i){this._datas=null,this._w=0,this._h=0,this._minHeight=NaN,this._maxHeight=NaN,this._datas=[],this._w=e,this._h=t,this._minHeight=n,this._maxHeight=i}r(e,"laya.d3.core.HeightMap");var t=e.prototype;return t._inBounds=function(e,t){return e>=0&&e<this._h&&t>=0&&t<this._w},t.getHeight=function(e,t){return this._inBounds(e,t)?this._datas[e][t]:NaN},a(0,t,"width",function(){return this._w}),a(0,t,"height",function(){return this._h}),a(0,t,"maxHeight",function(){return this._maxHeight}),a(0,t,"minHeight",function(){return this._minHeight}),e.creatFromMesh=function(t,n,i,r){for(var a=[],s=[],o=t.getSubMeshCount(),l=0;o>l;l++){for(var h=t.getSubMesh(l),u=h._getVertexBuffer(),c=u.getData(),_=[],d=0;d<c.length;d+=u.vertexDeclaration.vertexStride/4){var m=new Qe(c[d+0],c[d+1],c[d+2]);_.push(m)}a.push(_);var f=h._getIndexBuffer();s.push(f.getData())}var p=t.boundingBox,v=p.min.x,g=p.min.z,T=p.max.x,x=p.max.z,M=p.min.y,E=p.max.y,y=T-v,S=x-g,R=r.elements[0]=y/(n-1),A=r.elements[1]=S/(i-1),I=new e(n,i,M,E),C=e._tempRay,V=C.direction.elements;V[0]=0,V[1]=-1,V[2]=0;var D=.1,L=E+D;C.origin.elements[1]=L;for(var O=0;n>O;O++){var b=g+O*A;I._datas[O]=[];for(var P=0;i>P;P++){var w=v+P*R,N=C.origin.elements;N[0]=w,N[2]=b;var B=e._getPosition(C,a,s);I._datas[O][P]=B===Number.MAX_VALUE?NaN:L-B}}return I},e.createFromImage=function(t,n,i){var r=t.width,a=t.height,s=new e(r,a,n,i),o=(i-n)/254;h.canvas.size(r,a),h.context.drawImage(t._image,0,0,r,a);for(var l=h.context.getImageData(0,0,r,a).data,u=0,c=0;r>c;c++)for(var _=s._datas[c]=[],d=0;a>d;d++){var m=l[u++],f=l[u++],p=l[u++],v=l[u++];255==m&&255==f&&255==p&&255==v?_[d]=NaN:_[d]=(m+f+p)/3*o+n}return s},e._getPosition=function(e,t,n){for(var i=Number.MAX_VALUE,r=0;r<t.length;r++)for(var a=t[r],s=n[r],o=0;o<s.length;o+=3){var l=a[s[o+0]],h=a[s[o+1]],u=a[s[o+2]],c=tt.rayIntersectsTriangle(e,l,h,u);!isNaN(c)&&i>c&&(i=c)}return i},i(e,["_tempRay",function(){return this._tempRay=new qe(new Qe,new Qe)}]),e}(),U=function(){function e(){if(this._id=0,this._number=0,this._mask=0,this._active=!0,this._visible=!0,this.name=null,this._id=e._uniqueIDCounter,e._uniqueIDCounter++,this._id>32)throw new Error("不允许创建Layer,请参考函数getLayerByNumber、getLayerByMask、getLayerByName!")}r(e,"laya.d3.core.Layer");var t=e.prototype;return a(0,t,"number",function(){return this._number}),a(0,t,"visible",function(){return this._visible},function(t){29!==this._number&&30!=this._number&&(this._visible=t,t?e._visibleLayers=e._visibleLayers|this.mask:e._visibleLayers=e._visibleLayers&~this.mask)}),a(0,t,"mask",function(){return this._mask}),a(0,t,"active",function(){return this._active},function(t){29!==this._number&&30!=this._number&&(this._active=t,t?e._activeLayers=e._activeLayers|this.mask:e._activeLayers=e._activeLayers&~this.mask)}),a(1,e,"activeLayers",function(){return e._activeLayers},function(t){e._activeLayers=t|e.getLayerByNumber(29).mask|e.getLayerByNumber(30).mask;for(var n=0;n<e._layerList.length;n++){var i=e._layerList[n];i._active=0!==(i._mask&e._activeLayers)}}),a(1,e,"visibleLayers",function(){return e._visibleLayers},function(t){e._visibleLayers=t|e.getLayerByNumber(29).mask|e.getLayerByNumber(30).mask;for(var n=0;n<e._layerList.length;n++){var i=e._layerList[n];i._visible=0!==(i._mask&e._visibleLayers)}}),e.__init__=function(){e._layerList.length=31;for(var t=0;31>t;t++){var n=new e;e._layerList[t]=n,0===t?n.name="Default Layer":29===t?n.name="Reserved Layer0":30===t?n.name="Reserved Layer1":n.name="Layer-"+t,n._number=t,n._mask=Math.pow(2,t)}e._activeLayers=2147483647,e._visibleLayers=2147483647,e._currentCameraCullingMask=2147483647,e.currentCreationLayer=e._layerList[0]},e.getLayerByNumber=function(t){if(0>t||t>30)throw new Error("无法返回指定Layer,该number超出范围!");return e._layerList[t]},e.getLayerByMask=function(t){for(var n=0;31>n;n++)if(e._layerList[n].mask===t)return e._layerList[n];throw new Error("无法返回指定Layer,该mask不存在")},e.getLayerByName=function(t){for(var n=0;31>n;n++)if(e._layerList[n].name===t)return e._layerList[n];throw new Error("无法返回指定Layer,该name不存在")},e.isActive=function(t){return 0!=(t&e._activeLayers)},e.isVisible=function(t){return 0!=(t&e._currentCameraCullingMask&e._visibleLayers)},e._uniqueIDCounter=1,e._layerCount=31,e._layerList=[],e._activeLayers=0,e._visibleLayers=0,e._currentCameraCullingMask=0,e.currentCreationLayer=null,e}(),G=function(){function e(e,t,n){this._time=NaN,this._minCount=0,this._maxCount=0,this._time=e,this._minCount=t,this._maxCount=n}r(e,"laya.d3.core.particleShuriKen.module.Burst");var t=e.prototype;return a(0,t,"time",function(){return this._time}),a(0,t,"minCount",function(){return this._minCount}),a(0,t,"maxCount",function(){return this._maxCount}),e}(),z=function(){function e(e){this._color=null,this.enbale=!1,this._color=e}r(e,"laya.d3.core.particleShuriKen.module.ColorOverLifetime");var t=e.prototype;return t.cloneTo=function(e){var t=e;this._color.cloneTo(t._color),t.enbale=this.enbale},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,t,"color",function(){return this._color}),e}(),H=function(){function e(){this._type=0,this._constant=0,this._overTime=null,this._constantMin=0,this._constantMax=0,this._overTimeMin=null,this._overTimeMax=null}r(e,"laya.d3.core.particleShuriKen.module.FrameOverTime");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.cloneTo=function(e){var t=e;t._type=this._type,t._constant=this._constant,this._overTime.cloneTo(t._overTime),t._constantMin=this._constantMin,t._constantMax=this._constantMax,this._overTimeMin.cloneTo(t._overTimeMin),this._overTimeMax.cloneTo(t._overTimeMax)},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,t,"frameOverTimeData",function(){return this._overTime}),a(0,t,"constant",function(){return this._constant}),a(0,t,"type",function(){return this._type}),a(0,t,"frameOverTimeDataMin",function(){return this._overTimeMin}),a(0,t,"constantMin",function(){return this._constantMin}),a(0,t,"frameOverTimeDataMax",function(){return this._overTimeMax}),a(0,t,"constantMax",function(){return this._constantMax}),e.createByConstant=function(t){var n=new e;return n._type=0,n._constant=t,n},e.createByOverTime=function(t){var n=new e;return n._type=1,n._overTime=t,n},e.createByRandomTwoConstant=function(t,n){var i=new e;return i._type=2,i._constantMin=t,i._constantMax=n,i},e.createByRandomTwoOverTime=function(t,n){var i=new e;return i._type=3,i._overTimeMin=t,i._overTimeMax=n,i},e}(),k=function(){function e(){this._type=0,this._separateAxes=!1,this._constant=NaN,this._constantSeparate=null,this._gradient=null,this._gradientX=null,this._gradientY=null,this._gradientZ=null,this._constantMin=NaN,this._constantMax=NaN,this._constantMinSeparate=null,this._constantMaxSeparate=null,this._gradientMin=null,this._gradientMax=null,this._gradientXMin=null,this._gradientXMax=null,this._gradientYMin=null,this._gradientYMax=null,this._gradientZMin=null,this._gradientZMax=null}r(e,"laya.d3.core.particleShuriKen.module.GradientAngularVelocity");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.cloneTo=function(e){var t=e;t._type=this._type,t._separateAxes=this._separateAxes,t._constant=this._constant,this._constantSeparate.cloneTo(t._constantSeparate),this._gradient.cloneTo(t._gradient),this._gradientX.cloneTo(t._gradientX),this._gradientY.cloneTo(t._gradientY),this._gradientZ.cloneTo(t._gradientZ),t._constantMin=this._constantMin,t._constantMax=this._constantMax,this._constantMinSeparate.cloneTo(t._constantMinSeparate),this._constantMaxSeparate.cloneTo(t._constantMaxSeparate),this._gradientMin.cloneTo(t._gradientMin),this._gradientMax.cloneTo(t._gradientMax),this._gradientXMin.cloneTo(t._gradientXMin),this._gradientXMax.cloneTo(t._gradientXMax),this._gradientYMin.cloneTo(t._gradientYMin),this._gradientYMax.cloneTo(t._gradientYMax),this._gradientZMin.cloneTo(t._gradientZMin),this._gradientZMax.cloneTo(t._gradientZMax)},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,t,"gradientZ",function(){return this._gradientZ}),a(0,t,"constant",function(){return this._constant}),a(0,t,"gradient",function(){return this._gradient}),a(0,t,"separateAxes",function(){return this._separateAxes}),a(0,t,"type",function(){return this._type}),a(0,t,"constantSeparate",function(){return this._constantSeparate}),a(0,t,"gradientMin",function(){return this._gradientMin}),a(0,t,"constantMin",function(){return this._constantMin}),a(0,t,"gradientX",function(){return this._gradientX}),a(0,t,"gradientY",function(){return this._gradientY}),a(0,t,"gradientMax",function(){return this._gradientMax}),a(0,t,"constantMax",function(){return this._constantMax}),a(0,t,"constantMinSeparate",function(){return this._constantMinSeparate}),a(0,t,"constantMaxSeparate",function(){return this._constantMaxSeparate}),a(0,t,"gradientXMin",function(){return this._gradientXMin}),a(0,t,"gradientXMax",function(){return this._gradientXMax}),a(0,t,"gradientYMin",function(){return this._gradientYMin}),a(0,t,"gradientYMax",function(){return this._gradientYMax}),a(0,t,"gradientZMin",function(){return this._gradientZMin}),a(0,t,"gradientZMax",function(){return this._gradientZMax}),e.createByConstant=function(t){var n=new e;return n._type=0,n._separateAxes=!1,n._constant=t,n},e.createByConstantSeparate=function(t){var n=new e;return n._type=0,n._separateAxes=!0,n._constantSeparate=t,n},e.createByGradient=function(t){var n=new e;return n._type=1,n._separateAxes=!1,n._gradient=t,n},e.createByGradientSeparate=function(t,n,i){var r=new e;return r._type=1,r._separateAxes=!0,r._gradientX=t,r._gradientY=n,r._gradientZ=i,r},e.createByRandomTwoConstant=function(t,n){var i=new e;return i._type=2,i._separateAxes=!1,i._constantMin=t,i._constantMax=n,i},e.createByRandomTwoConstantSeparate=function(t,n){var i=new e;return i._type=2,i._separateAxes=!0,i._constantMinSeparate=t,i._constantMaxSeparate=n,i},e.createByRandomTwoGradient=function(t,n){var i=new e;return i._type=3,i._separateAxes=!1,i._gradientMin=t,i._gradientMax=n,i},e.createByRandomTwoGradientSeparate=function(t,n,i,r,a,s){var o=new e;return o._type=3,o._separateAxes=!0,o._gradientXMin=t,o._gradientXMax=n,o._gradientYMin=i,o._gradientYMax=r,o._gradientZMin=a,o._gradientZMax=s,o},e}(),X=function(){function e(){this._type=0,this._constant=null,this._constantMin=null,this._constantMax=null,this._gradient=null,this._gradientMin=null,this._gradientMax=null}r(e,"laya.d3.core.particleShuriKen.module.GradientColor");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.cloneTo=function(e){var t=e;t._type=this._type,this._constant.cloneTo(t._constant),this._constantMin.cloneTo(t._constantMin),this._constantMax.cloneTo(t._constantMax),this._gradient.cloneTo(t._gradient),this._gradientMin.cloneTo(t._gradientMin),this._gradientMax.cloneTo(t._gradientMax)},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,t,"gradient",function(){return this._gradient}),a(0,t,"constant",function(){return this._constant}),a(0,t,"type",function(){return this._type}),a(0,t,"gradientMin",function(){return this._gradientMin}),a(0,t,"constantMin",function(){return this._constantMin}),a(0,t,"gradientMax",function(){return this._gradientMax}),a(0,t,"constantMax",function(){return this._constantMax}),e.createByConstant=function(t){var n=new e;return n._type=0,n._constant=t,n},e.createByGradient=function(t){var n=new e;return n._type=1,n._gradient=t,n},e.createByRandomTwoConstant=function(t,n){var i=new e;return i._type=2,i._constantMin=t,i._constantMax=n,i},e.createByRandomTwoGradient=function(t,n){var i=new e;return i._type=3,i._gradientMin=t,i._gradientMax=n,i},e}(),Y=function(){function e(){this._alphaCurrentLength=0,this._rgbCurrentLength=0,this._alphaElements=null,this._rgbElements=null,this._alphaElements=new Float32Array(8),this._rgbElements=new Float32Array(16)}r(e,"laya.d3.core.particleShuriKen.module.GradientDataColor");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.addAlpha=function(e,t){if(!(this._alphaCurrentLength<8))throw new Error("GradientDataColor:Alpha count must less than 4.");this._alphaElements[this._alphaCurrentLength++]=e,this._alphaElements[this._alphaCurrentLength++]=t},t.addRGB=function(e,t){if(!(this._rgbCurrentLength<16))throw new Error("GradientDataColor:RGB count must less than 4.");this._rgbElements[this._rgbCurrentLength++]=e,this._rgbElements[this._rgbCurrentLength++]=t.x,this._rgbElements[this._rgbCurrentLength++]=t.y,this._rgbElements[this._rgbCurrentLength++]=t.z},t.cloneTo=function(e){var t=e,n=0,i=0;t._alphaCurrentLength=this._alphaCurrentLength;var r=t._alphaElements;for(r.length=this._alphaElements.length,n=0,i=this._alphaElements.length;i>n;n++)r[n]=this._alphaElements[n];t._rgbCurrentLength=this._rgbCurrentLength;var a=t._rgbElements;for(a.length=this._rgbElements.length,n=0,i=this._rgbElements.length;i>n;n++)a[n]=this._rgbElements[n]},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,t,"alphaGradientCount",function(){return this._alphaCurrentLength/2}),a(0,t,"rgbGradientCount",function(){return this._rgbCurrentLength/4}),e}(),j=function(){function e(){this._currentLength=0,this._elements=null,this._elements=new Float32Array(8)}r(e,"laya.d3.core.particleShuriKen.module.GradientDataInt");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.add=function(e,t){if(!(this._currentLength<8))throw new Error("GradientDataInt: Count must less than 4.");this._elements[this._currentLength++]=e,this._elements[this._currentLength++]=t},t.cloneTo=function(e){var t=e;t._currentLength=this._currentLength;var n=t._elements;n.length=this._elements.length;for(var i=0,r=this._elements.length;r>i;i++)n[i]=this._elements[i]},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,t,"gradientCount",function(){return this._currentLength/2}),e}(),W=function(){function e(){this._currentLength=0,this._elements=null,this._elements=new Float32Array(8)}r(e,"laya.d3.core.particleShuriKen.module.GradientDataNumber");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.add=function(e,t){if(!(this._currentLength<8))throw new Error("GradientDataNumber: Count must less than 4.");this._elements[this._currentLength++]=e,this._elements[this._currentLength++]=t},t.getKeyByIndex=function(e){return this._elements[2*e]},t.getValueByIndex=function(e){return this._elements[2*e+1]},t.cloneTo=function(e){var t=e;t._currentLength=this._currentLength;var n=t._elements;n.length=this._elements.length;for(var i=0,r=this._elements.length;r>i;i++)n[i]=this._elements[i]},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,t,"gradientCount",function(){return this._currentLength/2}),e}(),Z=(function(){function e(){this._currentLength=0,this._elements=null,this._elements=new Float32Array(12)}r(e,"laya.d3.core.particleShuriKen.module.GradientDataVector2");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.add=function(e,t){if(!(this._currentLength<8))throw new Error("GradientDataVector2: Count must less than 4.");this._elements[this._currentLength++]=e,this._elements[this._currentLength++]=t.x,this._elements[this._currentLength++]=t.y},t.cloneTo=function(e){var t=e;t._currentLength=this._currentLength;var n=t._elements;n.length=this._elements.length;for(var i=0,r=this._elements.length;r>i;i++)n[i]=this._elements[i]},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,t,"gradientCount",function(){return this._currentLength/3}),e}(),function(){function e(){this._type=0,this._separateAxes=!1,this._gradient=null,this._gradientX=null,this._gradientY=null,this._gradientZ=null,this._constantMin=NaN,this._constantMax=NaN,this._constantMinSeparate=null,this._constantMaxSeparate=null,this._gradientMin=null,this._gradientMax=null,this._gradientXMin=null,this._gradientXMax=null,this._gradientYMin=null,this._gradientYMax=null,this._gradientZMin=null,this._gradientZMax=null}r(e,"laya.d3.core.particleShuriKen.module.GradientSize");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.cloneTo=function(e){var t=e;t._type=this._type,t._separateAxes=this._separateAxes,this._gradient.cloneTo(t._gradient),this._gradientX.cloneTo(t._gradientX),this._gradientY.cloneTo(t._gradientY),this._gradientZ.cloneTo(t._gradientZ),t._constantMin=this._constantMin,t._constantMax=this._constantMax,this._constantMinSeparate.cloneTo(t._constantMinSeparate),this._constantMaxSeparate.cloneTo(t._constantMaxSeparate),this._gradientMin.cloneTo(t._gradientMin),this._gradientMax.cloneTo(t._gradientMax),this._gradientXMin.cloneTo(t._gradientXMin),this._gradientXMax.cloneTo(t._gradientXMax),this._gradientYMin.cloneTo(t._gradientYMin),this._gradientYMax.cloneTo(t._gradientYMax),this._gradientZMin.cloneTo(t._gradientZMin),this._gradientZMax.cloneTo(t._gradientZMax)},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,t,"separateAxes",function(){return this._separateAxes}),a(0,t,"type",function(){return this._type}),a(0,t,"gradientSizeX",function(){return this._gradientX}),a(0,t,"gradientSize",function(){return this._gradient}),a(0,t,"gradientMin",function(){return this._gradientMin}),a(0,t,"constantMin",function(){return this._constantMin}),a(0,t,"gradientZMin",function(){return this._gradientZMin}),a(0,t,"gradientSizeY",function(){return this._gradientY}),a(0,t,"constantMinSeparate",function(){return this._constantMinSeparate}),a(0,t,"gradientSizeZ",function(){return this._gradientZ}),a(0,t,"gradientMax",function(){return this._gradientMax}),a(0,t,"constantMax",function(){return this._constantMax}),a(0,t,"constantMaxSeparate",function(){return this._constantMaxSeparate}),a(0,t,"gradientXMin",function(){return this._gradientXMin}),a(0,t,"gradientXMax",function(){return this._gradientXMax}),a(0,t,"gradientYMin",function(){return this._gradientYMin}),a(0,t,"gradientYMax",function(){return this._gradientYMax}),a(0,t,"gradientZMax",function(){return this._gradientZMax}),e.createByGradient=function(t){var n=new e;return n._type=0,n._separateAxes=!1,n._gradient=t,n},e.createByGradientSeparate=function(t,n,i){var r=new e;return r._type=0,r._separateAxes=!0,r._gradientX=t,r._gradientY=n,r._gradientZ=i,r},e.createByRandomTwoConstant=function(t,n){var i=new e;return i._type=1,i._separateAxes=!1,i._constantMin=t,i._constantMax=n,i},e.createByRandomTwoConstantSeparate=function(t,n){var i=new e;return i._type=1,i._separateAxes=!0,i._constantMinSeparate=t,i._constantMaxSeparate=n,i},e.createByRandomTwoGradient=function(t,n){var i=new e;return i._type=2,i._separateAxes=!1,i._gradientMin=t,i._gradientMax=n,i},e.createByRandomTwoGradientSeparate=function(t,n,i,r,a,s){var o=new e;return o._type=2,o._separateAxes=!0,o._gradientXMin=t,o._gradientXMax=n,o._gradientYMin=i,o._gradientYMax=r,o._gradientZMin=a,o._gradientZMax=s,o},e}()),q=function(){function e(){this._type=0,this._constant=null,this._gradientX=null,this._gradientY=null,this._gradientZ=null,this._constantMin=null,this._constantMax=null,this._gradientXMin=null,this._gradientXMax=null,this._gradientYMin=null,this._gradientYMax=null,this._gradientZMin=null,this._gradientZMax=null}r(e,"laya.d3.core.particleShuriKen.module.GradientVelocity");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.cloneTo=function(e){var t=e;t._type=this._type,this._constant.cloneTo(t._constant),this._gradientX.cloneTo(t._gradientX),this._gradientY.cloneTo(t._gradientY),this._gradientZ.cloneTo(t._gradientZ),this._constantMin.cloneTo(t._constantMin),this._constantMax.cloneTo(t._constantMax),this._gradientXMin.cloneTo(t._gradientXMin),this._gradientXMax.cloneTo(t._gradientXMax),this._gradientYMin.cloneTo(t._gradientYMin),this._gradientYMax.cloneTo(t._gradientYMax),this._gradientZMin.cloneTo(t._gradientZMin),this._gradientZMax.cloneTo(t._gradientZMax)},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,t,"gradientZ",function(){return this._gradientZ}),a(0,t,"constant",function(){return this._constant}),a(0,t,"type",function(){return this._type}),a(0,t,"gradientXMax",function(){return this._gradientXMax}),a(0,t,"constantMin",function(){return this._constantMin}),a(0,t,"gradientX",function(){return this._gradientX}),a(0,t,"gradientY",function(){return this._gradientY}),a(0,t,"gradientXMin",function(){return this._gradientXMin}),a(0,t,"constantMax",function(){return this._constantMax}),a(0,t,"gradientYMin",function(){return this._gradientYMin}),a(0,t,"gradientYMax",function(){return this._gradientYMax}),a(0,t,"gradientZMin",function(){return this._gradientZMin}),a(0,t,"gradientZMax",function(){return this._gradientZMax}),e.createByConstant=function(t){var n=new e;return n._type=0,n._constant=t,n},e.createByGradient=function(t,n,i){var r=new e;return r._type=1,r._gradientX=t,r._gradientY=n,r._gradientZ=i,r},e.createByRandomTwoConstant=function(t,n){var i=new e;return i._type=2,i._constantMin=t,i._constantMax=n,i},e.createByRandomTwoGradient=function(t,n,i,r,a,s){var o=new e;return o._type=3,o._gradientXMin=t,o._gradientXMax=n,o._gradientYMin=i,o._gradientYMax=r,o._gradientZMin=a,o._gradientZMax=s,o},e}(),K=function(){function e(e){this._angularVelocity=null,this.enbale=!1,this._angularVelocity=e}r(e,"laya.d3.core.particleShuriKen.module.RotationOverLifetime");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.cloneTo=function(e){var t=e;this._angularVelocity.cloneTo(t._angularVelocity),t.enbale=this.enbale},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,t,"angularVelocity",function(){return this._angularVelocity}),e}(),Q=function(){function e(){this.enbale=!1}r(e,"laya.d3.core.particleShuriKen.module.shape.BaseShape");var t=e.prototype;return t.generatePositionAndDirection=function(e,t){throw new Error("BaseShape: must override it.")},e}(),$=function(){function e(){}return r(e,"laya.d3.core.particleShuriKen.module.shape.ShapeUtils"),e._randomPointUnitArcCircle=function(e,t){var n=t.elements,i=Math.random()*e;n[0]=Math.cos(i),n[1]=Math.sin(i)},e._randomPointInsideUnitArcCircle=function(t,n){var i=n.elements;e._randomPointUnitArcCircle(t,n);var r=Math.pow(Math.random(),.5);i[0]=i[0]*r,i[1]=i[1]*r},e._randomPointUnitCircle=function(e){var t=e.elements,n=Math.random()*Math.PI*2;t[0]=Math.cos(n),t[1]=Math.sin(n)},e._randomPointInsideUnitCircle=function(t){var n=t.elements;e._randomPointUnitCircle(t);var i=Math.pow(Math.random(),.5);n[0]=n[0]*i,n[1]=n[1]*i},e._randomPointUnitSphere=function(e){var t=e.elements,n=t[2]=2*Math.random()-1,i=Math.random()*Math.PI*2,r=Math.sqrt(1-n*n);t[0]=r*Math.cos(i),t[1]=r*Math.sin(i)},e._randomPointInsideUnitSphere=function(t){var n=t.elements;e._randomPointUnitSphere(t);var i=Math.pow(Math.random(),1/3);n[0]=n[0]*i,n[1]=n[1]*i,n[2]=n[2]*i},e._randomPointInsideHalfUnitBox=function(e){var t=e.elements;t[0]=Math.random()-.5,t[1]=Math.random()-.5,t[2]=Math.random()-.5},e}(),J=function(){function e(e){this._size=null,this.enbale=!1,this._size=e}r(e,"laya.d3.core.particleShuriKen.module.SizeOverLifetime");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.cloneTo=function(e){var t=e;this._size.cloneTo(t._size),t.enbale=this.enbale},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,t,"size",function(){return this._size}),e}(),ee=function(){function e(){this._type=0,this._constant=NaN,this._constantMin=NaN,this._constantMax=NaN}r(e,"laya.d3.core.particleShuriKen.module.StartFrame");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.cloneTo=function(e){var t=e;t._type=this._type,t._constant=this._constant,t._constantMin=this._constantMin,t._constantMax=this._constantMax},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,t,"constant",function(){return this._constant}),a(0,t,"type",function(){return this._type}),a(0,t,"constantMin",function(){return this._constantMin}),a(0,t,"constantMax",function(){return this._constantMax}),e.createByConstant=function(t){var n=new e;return n._type=0,n._constant=t,n},e.createByRandomTwoConstant=function(t,n){var i=new e;return i._type=1,i._constantMin=t,i._constantMax=n,i},e}(),te=function(){function e(e,t){this.tiles=null,this.type=0,this.randomRow=!1,this.frame=null,this.startFrame=null,this.cycles=0,this.enableUVChannels=0,this.enbale=!1,this.tiles=new Ke(1,1),this.type=0,this.randomRow=!0,this.cycles=1,this.enableUVChannels=1,this.frame=e,this.startFrame=t}r(e,"laya.d3.core.particleShuriKen.module.TextureSheetAnimation");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.cloneTo=function(e){var t=e;this.tiles.clone(t.tiles),t.type=this.type,t.randomRow=this.randomRow,this.frame.cloneTo(t.frame),this.startFrame.cloneTo(t.startFrame),t.cycles=this.cycles,t.enableUVChannels=this.enableUVChannels,t.enbale=this.enbale},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},e}(),ne=function(){function e(e){this._velocity=null,this.enbale=!1,this.space=0,this._velocity=e}r(e,"laya.d3.core.particleShuriKen.module.VelocityOverLifetime");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.cloneTo=function(e){var t=e;this._velocity.cloneTo(t._velocity),t.enbale=this.enbale,t.space=this.space},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,t,"velocity",function(){return this._velocity}),e}(),ie=function(){function e(){this.startLifeTime=NaN,this.position=null,this.direction=null,this.startColor=null,this.startSize=null,this.startRotation0=null,this.startRotation1=null,this.startRotation2=null,this.time=NaN,this.startSpeed=NaN,this.startUVInfo=null,this.simulationWorldPostion=null}return r(e,"laya.d3.core.particleShuriKen.ShurikenParticleData"),e._getStartLifetimeFromGradient=function(e,t){for(var n=1,i=e.gradientCount;i>n;n++){var r=e.getKeyByIndex(n);if(r>=t){var a=e.getKeyByIndex(n-1),s=(t-a)/(r-a);return x.lerp(e.getValueByIndex(n-1),e.getValueByIndex(n),s)}}throw new Error("ShurikenParticleData: can't get value foam startLifeTimeGradient.")},e.create=function(t,n,i,r,a,s){var o=new e;switch(o.position=i,x.scaleVector3(r,1,e._tempDirection),o.direction=e._tempDirection,o.startColor=e._tempStartColor,t.startColorType){case 0:var l=o.startColor,h=t.startColorConstant.elements;l[0]=h[0],l[1]=h[1],l[2]=h[2],l[3]=h[3];break;case 2:x.lerpVector4(t.startColorConstantMin.elements,t.startColorConstantMax.elements,Math.random(),o.startColor)}var u=t.colorOverLifetime;if(u&&u.enbale){var c=o.startColor,_=u.color;switch(_.type){case 0:c[0]=c[0]*_.constant.x,c[1]=c[1]*_.constant.y,c[2]=c[2]*_.constant.z,c[3]=c[3]*_.constant.w;break;case 2:var d=Math.random(),m=_.constantMin,f=_.constantMax;c[0]=c[0]*x.lerp(m.x,f.x,d),c[1]=c[1]*x.lerp(m.y,f.y,d),c[2]=c[2]*x.lerp(m.z,f.z,d),c[3]=c[3]*x.lerp(m.w,f.w,d)}}o.startSize=e._tempStartSize;var p=o.startSize;switch(t.startSizeType){case 0:if(t.threeDStartSize){var v=t.startSizeConstantSeparate;p[0]=v.x,p[1]=v.y,p[2]=v.z}else p[0]=p[1]=p[2]=t.startSizeConstant;break;case 2:if(t.threeDStartSize){var g=t.startSizeConstantMinSeparate,T=t.startSizeConstantMaxSeparate;p[0]=x.lerp(g.x,T.x,Math.random()),p[1]=x.lerp(g.y,T.y,Math.random()),p[2]=x.lerp(g.z,T.z,Math.random())}else p[0]=p[1]=p[2]=x.lerp(t.startSizeConstantMin,t.startSizeConstantMax,Math.random())}var M=t.sizeOverLifetime;if(M&&M.enbale&&1===M.size.type){var E=M.size;if(E.separateAxes)p[0]=p[0]*x.lerp(E.constantMinSeparate.x,E.constantMaxSeparate.x,Math.random()),p[1]=p[1]*x.lerp(E.constantMinSeparate.y,E.constantMaxSeparate.y,Math.random()),p[2]=p[2]*x.lerp(E.constantMinSeparate.z,E.constantMaxSeparate.z,Math.random());else{var y=x.lerp(E.constantMin,E.constantMax,Math.random());p[0]=p[0]*y,p[1]=p[1]*y,p[2]=p[2]*y}}var S,R,A,I;switch(t.startRotationType){case 0:if(t.threeDStartRotation&&1!==n.renderMode&&1!==n.renderMode){var C=t.startRotationConstantSeparate;je.createRotationYawPitchRoll(C.y,C.x,C.z,e._tempRotationMatrix),I=e._tempRotationMatrix.elements,o.startRotation0=e._tempStartRotation0,S=o.startRotation0,S[0]=I[0],S[1]=I[1],S[2]=I[2],o.startRotation1=e._tempStartRotation1,R=o.startRotation1,R[0]=I[4],R[1]=I[5],R[2]=I[6],o.startRotation2=e._tempStartRotation2,A=o.startRotation2,A[0]=I[8],A[1]=I[9],A[2]=I[10]}else o.startRotation0=e._tempStartRotation0,S=o.startRotation0,S[0]=S[1]=S[2]=t.startRotationConstant;break;case 2:if(t.threeDStartRotation&&1!==n.renderMode&&2!==n.renderMode){o.startRotation0=e._tempStartRotation0,S=o.startRotation0;var V=t.startRotationConstantMinSeparate,D=t.startRotationConstantMaxSeparate;je.createRotationYawPitchRoll(x.lerp(V.y,D.y,Math.random()),x.lerp(V.x,D.x,Math.random()),x.lerp(V.z,D.z,Math.random()),e._tempRotationMatrix),I=e._tempRotationMatrix.elements,o.startRotation0=e._tempStartRotation0,S=o.startRotation0,S[0]=I[0],S[1]=I[1],S[2]=I[2],o.startRotation1=e._tempStartRotation1,R=o.startRotation1,R[0]=I[4],R[1]=I[5],R[2]=I[6],o.startRotation2=e._tempStartRotation2,A=o.startRotation2,A[0]=I[8],A[1]=I[9],A[2]=I[10]}else o.startRotation0=e._tempStartRotation0,S=o.startRotation0,S[0]=S[1]=S[2]=x.lerp(t.startRotationConstantMin,t.startRotationConstantMax,Math.random())}switch(Math.random()<t.randomizeRotationDirection&&(S[0]=-S[0],S[1]=-S[1],S[2]=-S[2]),o.startRotation1=e._tempStartRotation1,o.startRotation2=e._tempStartRotation2,t.startLifetimeType){case 0:o.startLifeTime=t.startLifetimeConstant;break;case 1:o.startLifeTime=e._getStartLifetimeFromGradient(t.startLifeTimeGradient,t.emission.emissionTime);break;case 2:o.startLifeTime=x.lerp(t.startLifetimeConstantMin,t.startLifetimeConstantMax,Math.random());break;case 3:var L=t.emission.emissionTime;o.startLifeTime=x.lerp(e._getStartLifetimeFromGradient(t.startLifeTimeGradientMin,L),e._getStartLifetimeFromGradient(t.startLifeTimeGradientMax,L),Math.random());
|
||
}switch(t.startSpeedType){case 0:o.startSpeed=t.startSpeedConstant;break;case 2:o.startSpeed=x.lerp(t.startSpeedConstantMin,t.startSpeedConstantMax,Math.random())}o.startUVInfo=e._tempStartUVInfo;var O,b=t.textureSheetAnimation,P=b&&b.enbale;if(P){var w=b.tiles,N=w.x,B=w.y,F=1/N,U=1/B,G=0,z=0,H=b.randomRow;switch(b.type){case 0:G=N*B;break;case 1:G=N,z=H?Math.round(Math.random()*B):0}var k=0,X=b.startFrame;switch(X.type){case 0:k=X.constant;break;case 1:k=Math.round(x.lerp(X.constantMin,X.constantMax,Math.random()))}var Y=b.frame;switch(Y.type){case 0:k+=Y.constant;break;case 2:k+=Math.round(x.lerp(Y.constantMin,Y.constantMax,Math.random()))}H||(z=Math.floor(k/N));var j=k%N;O=o.startUVInfo,O[0]=F,O[1]=U,O[2]=j*F,O[3]=z*U}else O=o.startUVInfo,O[0]=1,O[1]=1,O[2]=0,O[3]=0;o.time=a,o.simulationWorldPostion=e._tempSimulationWorldPostion;var W=o.simulationWorldPostion;if(0===t.simulationSpace){var Z=s.position.elements;W[0]=Z[0],W[1]=Z[1],W[2]=Z[2]}else W[0]=0,W[1]=0,W[2]=0;return o},i(e,["_tempRotationMatrix",function(){return this._tempRotationMatrix=new je},"_tempDirection",function(){return this._tempDirection=new Float32Array(3)},"_tempStartColor",function(){return this._tempStartColor=new Float32Array(4)},"_tempStartSize",function(){return this._tempStartSize=new Float32Array(3)},"_tempStartRotation0",function(){return this._tempStartRotation0=new Float32Array(3)},"_tempStartRotation1",function(){return this._tempStartRotation1=new Float32Array(3)},"_tempStartRotation2",function(){return this._tempStartRotation2=new Float32Array(3)},"_tempStartUVInfo",function(){return this._tempStartUVInfo=new Float32Array(4)},"_tempSimulationWorldPostion",function(){return this._tempSimulationWorldPostion=new Float32Array(3)}]),e}(),re=function(){function e(e){this._owner=null,this._vertices=null,this._floatCountPerVertex=0,this._firstActiveElement=0,this._firstNewElement=0,this._firstFreeElement=0,this._firstRetiredElement=0,this._drawCounter=0,this._currentTime=NaN,this._vertexBuffer=null,this._indexBuffer=null,this._maxParticles=0,this._emission=null,this._aliveParticleCount=0,this._shape=null,this._startUpdateLoopCount=0,this.duration=NaN,this.looping=!1,this.prewarm=!1,this.startDelayType=0,this.startDelay=NaN,this.startDelayMin=NaN,this.startDelayMax=NaN,this.startLifetimeType=0,this.startLifetimeConstant=NaN,this.startLifeTimeGradient=null,this.startLifetimeConstantMin=NaN,this.startLifetimeConstantMax=NaN,this.startLifeTimeGradientMin=null,this.startLifeTimeGradientMax=null,this.startSpeedType=0,this.startSpeedConstant=NaN,this.startSpeedConstantMin=NaN,this.startSpeedConstantMax=NaN,this.threeDStartSize=!1,this.startSizeType=0,this.startSizeConstant=NaN,this.startSizeConstantSeparate=null,this.startSizeConstantMin=NaN,this.startSizeConstantMax=NaN,this.startSizeConstantMinSeparate=null,this.startSizeConstantMaxSeparate=null,this.threeDStartRotation=!1,this.startRotationType=0,this.startRotationConstant=NaN,this.startRotationConstantSeparate=null,this.startRotationConstantMin=NaN,this.startRotationConstantMax=NaN,this.startRotationConstantMinSeparate=null,this.startRotationConstantMaxSeparate=null,this.randomizeRotationDirection=NaN,this.startColorType=0,this.startColorConstant=null,this.startColorConstantMin=null,this.startColorConstantMax=null,this.gravity=null,this.gravityModifier=NaN,this.simulationSpace=0,this.scaleMode=0,this.playOnAwake=!1,this.velocityOverLifetime=null,this.colorOverLifetime=null,this.sizeOverLifetime=null,this.rotationOverLifetime=null,this.textureSheetAnimation=null,this.isPerformanceMode=!1,this._owner=e,this._currentTime=0,this._floatCountPerVertex=40,this._maxParticles=1e3,this.duration=5,this.looping=!0,this.prewarm=!1,this.startDelayType=0,this.startDelay=0,this.startDelayMin=0,this.startDelayMax=0,this.startLifetimeType=0,this.startLifetimeConstant=5,this.startRotationConstantSeparate=new Qe(0,0,0),this.startLifetimeConstantMin=0,this.startLifetimeConstantMax=5,this.startRotationConstantMinSeparate=new Qe(0,0,0),this.startRotationConstantMaxSeparate=new Qe(0,0,0),this.startSpeedType=0,this.startSpeedConstant=5,this.startSpeedConstantMin=0,this.startSpeedConstantMax=5,this.threeDStartSize=!1,this.startSizeType=0,this.startSizeConstant=1,this.startSizeConstantSeparate=new Qe(1,1,1),this.startSizeConstantMin=0,this.startSizeConstantMax=1,this.startSizeConstantMinSeparate=new Qe(0,0,0),this.startSizeConstantMaxSeparate=new Qe(1,1,1),this.threeDStartRotation=!1,this.startRotationType=0,this.startRotationConstant=0,this.startRotationConstantMin=0,this.startRotationConstantMax=0,this.randomizeRotationDirection=0,this.startColorType=0,this.startColorConstant=new $e(1,1,1,1),this.startColorConstantMin=new $e(1,1,1,1),this.startColorConstantMax=new $e(1,1,1,1),this.gravity=new Qe(0,-9.81,0),this.gravityModifier=0,this.simulationSpace=1,this.scaleMode=0,this.playOnAwake=!0,this.isPerformanceMode=!0}r(e,"laya.d3.core.particleShuriKen.ShurikenParticleSystem");var t=e.prototype;return n.imps(t,{"laya.d3.core.render.IRenderable":!0}),t._getVertexBuffer=function(e){return void 0===e&&(e=0),0===e?this._vertexBuffer:null},t._getIndexBuffer=function(){return this._indexBuffer},t._retireActiveParticles=function(){for(var e=1e-4;this._firstActiveElement!=this._firstNewElement;){var t=this._firstActiveElement*this._floatCountPerVertex*4,n=t+27,i=this._currentTime-this._vertices[n];if(i+e<this._vertices[t+26])break;this._vertices[n]=this._drawCounter,this._firstActiveElement++,this._firstActiveElement>=this._maxParticles&&(this._firstActiveElement=0)}},t._freeRetiredParticles=function(){for(;this._firstRetiredElement!=this._firstActiveElement;){var e=this._drawCounter-this._vertices[this._firstRetiredElement*this._floatCountPerVertex*4+27];if(this.isPerformanceMode&&3>e)break;this._firstRetiredElement++,this._firstRetiredElement>=this._maxParticles&&(this._firstRetiredElement=0)}},t._setPartVertexDatas=function(e,t,n,i){for(var r=0;r<this._maxParticles;r++){var a=r*this._floatCountPerVertex*4;this._vertices[a+0*this._floatCountPerVertex+0]=-.5,this._vertices[a+0*this._floatCountPerVertex+1]=-.5,this._vertices[a+1*this._floatCountPerVertex+0]=.5,this._vertices[a+1*this._floatCountPerVertex+1]=-.5,this._vertices[a+2*this._floatCountPerVertex+0]=.5,this._vertices[a+2*this._floatCountPerVertex+1]=.5,this._vertices[a+3*this._floatCountPerVertex+0]=-.5,this._vertices[a+3*this._floatCountPerVertex+1]=.5}},t._initPartVertexDatas=function(){this._vertexBuffer=Bt.create(Te.vertexDeclaration,4*this._maxParticles,35048),this._vertices=new Float32Array(this._maxParticles*this._floatCountPerVertex*4);var e=this.textureSheetAnimation&&this.textureSheetAnimation.enbale;if(e){var t=this.textureSheetAnimation.tiles,n=t.x,i=t.y,r=1/n,a=1/i,s=0,o=0,l=this.textureSheetAnimation.randomRow;switch(this.textureSheetAnimation.type){case 0:s=n*i;break;case 1:s=n,o=l?Math.round(Math.random()*i):0}var h=0,u=this.textureSheetAnimation.startFrame;switch(u.type){case 0:h=u.constant;break;case 1:h=Math.round(x.lerp(u.constantMin,u.constantMax,Math.random()))}var c=this.textureSheetAnimation.frame;switch(c.type){case 0:h+=c.constant;break;case 2:h+=Math.round(x.lerp(c.constantMin,c.constantMax,Math.random()))}l||(o=Math.floor(h/n));var _=h%n;this._setPartVertexDatas(r,a,_*r,o*a)}else this._setPartVertexDatas(1,1,0,0)},t._initIndexDatas=function(){this._indexBuffer=Nt.create("ushort",6*this._maxParticles,35044);for(var e=new Uint16Array(6*this._maxParticles),t=0;t<this._maxParticles;t++){var n=6*t,i=4*t;e[n+0]=i+0,e[n+1]=i+2,e[n+2]=i+1,e[n+3]=i+0,e[n+4]=i+3,e[n+5]=i+2}this._indexBuffer.setData(e)},t._destroy=function(){this._vertexBuffer.dispose(),this._indexBuffer.dispose(),this._emission._destroy(),this._owner=null,this._vertices=null,this._vertexBuffer=null,this._indexBuffer=null,this._emission=null,this._shape=null,this.startLifeTimeGradient=null,this.startLifeTimeGradientMin=null,this.startLifeTimeGradientMax=null,this.startSizeConstantSeparate=null,this.startSizeConstantMinSeparate=null,this.startSizeConstantMaxSeparate=null,this.startRotationConstantSeparate=null,this.startRotationConstantMinSeparate=null,this.startRotationConstantMaxSeparate=null,this.startColorConstant=null,this.startColorConstantMin=null,this.startColorConstantMax=null,this.gravity=null,this.velocityOverLifetime=null,this.colorOverLifetime=null,this.sizeOverLifetime=null,this.rotationOverLifetime=null,this.textureSheetAnimation=null},t.update=function(e){var t=0;this._startUpdateLoopCount!==L.loopCount&&(t=e.elapsedTime/1e3,this._currentTime+=t),this._retireActiveParticles(),this._freeRetiredParticles(),this._emission.update(t,this._owner.transform),this._firstActiveElement===this._firstFreeElement&&(this._currentTime=0),this._firstRetiredElement===this._firstActiveElement&&(this._drawCounter=0),this._firstNewElement>=this._firstRetiredElement?this._aliveParticleCount=this._firstNewElement-this._firstRetiredElement:this._aliveParticleCount=this._maxParticles-this._firstRetiredElement+this._firstNewElement},t.addParticle=function(e,t,n){Qe.normalize(t,t);var i=e.elements,r=t.elements,a=this._firstFreeElement+1;if(a>=this._maxParticles&&(a=0),a===this._firstRetiredElement)return!1;var s=ie.create(this,this._owner.particleRender,i,r,this._currentTime,n),o=this._firstFreeElement*this._floatCountPerVertex*4,l=Math.random(),h=Math.random(),u=Math.random(),c=Math.random(),_=Math.random(),d=Math.random(),m=Math.random(),f=Math.random(),p=s.startUVInfo[0],v=s.startUVInfo[1],g=s.startUVInfo[2],T=s.startUVInfo[3];this._vertices[o+2]=g,this._vertices[o+3]=T+v,this._vertices[o+this._floatCountPerVertex+2]=g+p,this._vertices[o+this._floatCountPerVertex+3]=T+v,this._vertices[o+2*this._floatCountPerVertex+2]=g+p,this._vertices[o+2*this._floatCountPerVertex+3]=T,this._vertices[o+3*this._floatCountPerVertex+2]=g,this._vertices[o+3*this._floatCountPerVertex+3]=T;for(var x=0;4>x;x++){var M=o+x*this._floatCountPerVertex,E=0,y=0;for(E=0,y=4;3>E;E++)this._vertices[M+y+E]=s.position[E];for(E=0,y=7;3>E;E++)this._vertices[M+y+E]=s.direction[E];for(E=0,y=10;4>E;E++)this._vertices[M+y+E]=s.startColor[E];for(E=0,y=14;3>E;E++)this._vertices[M+y+E]=s.startSize[E];for(E=0,y=17;3>E;E++)this._vertices[M+y+E]=s.startRotation0[E];for(E=0,y=20;3>E;E++)this._vertices[M+y+E]=s.startRotation1[E];for(E=0,y=23;3>E;E++)this._vertices[M+y+E]=s.startRotation2[E];for(this._vertices[M+26]=s.startLifeTime,this._vertices[M+27]=s.time,this._vertices[M+28]=s.startSpeed,this._vertices[M+29]=l,this._vertices[M+30]=h,this._vertices[M+31]=u,this._vertices[M+32]=c,this._vertices[M+33]=_,this._vertices[M+34]=d,this._vertices[M+35]=m,this._vertices[M+36]=f,E=0,y=37;3>E;E++)this._vertices[M+y+E]=s.simulationWorldPostion[E]}return this._firstFreeElement=a,!0},t.addNewParticlesToVertexBuffer=function(){var e=0;this._firstNewElement<this._firstFreeElement?(e=4*this._firstNewElement*this._floatCountPerVertex,this._vertexBuffer.setData(this._vertices,e,e,4*(this._firstFreeElement-this._firstNewElement)*this._floatCountPerVertex)):(e=4*this._firstNewElement*this._floatCountPerVertex,this._vertexBuffer.setData(this._vertices,e,e,4*(this._maxParticles-this._firstNewElement)*this._floatCountPerVertex),this._firstFreeElement>0&&this._vertexBuffer.setData(this._vertices,0,0,4*this._firstFreeElement*this._floatCountPerVertex)),this._firstNewElement=this._firstFreeElement},t._beforeRender=function(e){return this._firstNewElement!=this._firstFreeElement&&this.addNewParticlesToVertexBuffer(),this._drawCounter++,this._firstActiveElement!=this._firstFreeElement?(this._vertexBuffer._bind(),this._indexBuffer._bind(),!0):!1},t._render=function(e){var t=0,n=w.mainContext;this._firstActiveElement<this._firstFreeElement?(t=6*(this._firstFreeElement-this._firstActiveElement),n.drawElements(4,t,5123,6*this._firstActiveElement*2),L.trianglesFaces+=t/3,L.drawCall++):(t=6*(this._maxParticles-this._firstActiveElement),n.drawElements(4,t,5123,6*this._firstActiveElement*2),L.trianglesFaces+=t/3,L.drawCall++,this._firstFreeElement>0&&(t=6*this._firstFreeElement,n.drawElements(4,t,5123,0),L.trianglesFaces+=t/3,L.drawCall++))},a(0,t,"currentTime",function(){return this._currentTime}),a(0,t,"indexOfHost",function(){return 0}),a(0,t,"maxParticles",function(){return this._maxParticles-1},function(e){var t=e+1;t!==this._maxParticles&&(this._maxParticles=t,this._vertexBuffer&&(this._vertexBuffer.dispose(),this._indexBuffer.dispose()),this._initPartVertexDatas(),this._initIndexDatas())}),a(0,t,"isAlive",function(){return!!(this._emission.isPlaying||this._aliveParticleCount>0)}),a(0,t,"shape",function(){return this._shape},function(e){this._shape=e,this._emission._shape=e}),a(0,t,"emission",function(){return this._emission},function(e){this._emission=e,e._particleSystem=this,e._shape=this._shape}),a(0,t,"aliveParticleCount",function(){return this._aliveParticleCount}),a(0,t,"_vertexBufferCount",function(){return 1}),a(0,t,"triangleCount",function(){return this._indexBuffer.indexCount/3}),e}(),ae=(function(){function e(){this._tempInt0=0,this._tempInt1=0,this._tempUint0=0,this._tempUint1=0,this._tempUint2=0,this._tempUint3=0,this._tempUint4=0,this._tempUint5=0,this._tempUint6=0,this._tempUint7=0,this._tempNumver0=NaN,this._tempNumver1=NaN,this._tempNumver2=NaN,this._tempNumver3=NaN,this._floatSizePerVer=7,this._defaultBufferSize=600*this._floatSizePerVer,this._vb=null,this._posInVBData=0,this._ib=null,this._posInIBData=0,this._primitiveType=NaN,this._hasBegun=!1,this._numVertsPerPrimitive=0,this._renderState=null,this._sharderNameID=0,this._shader=null,this._posShaderValue=[3,5126,!1,28,0],this._colorShaderValue=[4,5126,!1,28,12],this._albedo=new $e(1,1,1,1),this._vbData=new Float32Array(this._defaultBufferSize),this._ibData=new Uint16Array(this._defaultBufferSize),this._wvpMatrix=new je,this._vb=new P(-1,35048),this._ib=new v,this._sharderNameID=C.nameKey.get("SIMPLE")}r(e,"laya.d3.core.PhasorSpriter3D");var t=e.prototype;return t.line=function(e,t,n,i,r,a,s,o,l,h,u,c,_,d){return this._hasBegun&&1===this._primitiveType||this.drawLinesException(),(this._posInVBData+2*this._floatSizePerVer>this._vbData.length||this._posInIBData+2>this._ibData.length)&&this.flush(),this._tempUint0=this._posInVBData/this._floatSizePerVer,this.addVertex(e,t,n,i,r,a,s),this.addVertex(o,l,h,u,c,_,d),this.addIndexes(this._tempUint0,this._tempUint0+1),this},t.circle=function(e,t,n,i,r,a){for(this._hasBegun&&1===this._primitiveType||this.drawLinesException(),this._tempUint0=2*t,(this._posInVBData+this._tempUint0*this._floatSizePerVer>this._vbData.length||this._posInIBData+2*this._tempUint0>this._ibData.length)&&this.flush(),this._tempUint1=this._posInVBData/this._floatSizePerVer,this._tempNumver0=0,this._tempInt0=0;this._tempNumver0<6.2832;this._tempNumver0=this._tempNumver0+3.1416/t,this._tempInt0++)this.addVertex(Math.sin(this._tempNumver0)*e,Math.cos(this._tempNumver0)*e,0,n,i,r,a),0===this._tempInt0?this.addIndexes(this._tempUint1):this._tempInt0===this._tempUint0-1?(this._tempUint2=this._tempUint1+this._tempInt0,this.addIndexes(this._tempUint2,this._tempUint2,this._tempUint1)):(this._tempUint2=this._tempUint1+this._tempInt0,this.addIndexes(this._tempUint2,this._tempUint2));return this},t.plane=function(e,t,n,i,r,a,s,o,l){return this._hasBegun&&4===this._primitiveType||this.drawTrianglesException(),(this._posInVBData+4*this._floatSizePerVer>this._vbData.length||this._posInIBData+6>this._ibData.length)&&this.flush(),this._tempNumver0=i/2,this._tempNumver1=r/2,this._tempUint0=this._posInVBData/this._floatSizePerVer,this.addVertex(e-this._tempNumver0,t+this._tempNumver1,n,a,s,o,l),this.addVertex(e+this._tempNumver0,t+this._tempNumver1,n,a,s,o,l),this.addVertex(e-this._tempNumver0,t-this._tempNumver1,n,a,s,o,l),this.addVertex(e+this._tempNumver0,t-this._tempNumver1,n,a,s,o,l),this._tempUint1=this._tempUint0+1,this._tempUint2=this._tempUint0+2,this.addIndexes(this._tempUint0,this._tempUint1,this._tempUint2,this._tempUint2,this._tempUint1,this._tempUint0+3),this},t.box=function(e,t,n,i,r,a,s,o,l,h){return this._hasBegun&&4===this._primitiveType||this.drawTrianglesException(),(this._posInVBData+8*this._floatSizePerVer>this._vbData.length||this._posInIBData+36>this._ibData.length)&&this.flush(),this._tempNumver0=i/2,this._tempNumver1=r/2,this._tempNumver2=a/2,this._tempUint0=this._posInVBData/this._floatSizePerVer,this.addVertex(e-this._tempNumver0,t+this._tempNumver1,n+this._tempNumver2,s,o,l,h),this.addVertex(e+this._tempNumver0,t+this._tempNumver1,n+this._tempNumver2,s,o,l,h),this.addVertex(e-this._tempNumver0,t-this._tempNumver1,n+this._tempNumver2,s,o,l,h),this.addVertex(e+this._tempNumver0,t-this._tempNumver1,n+this._tempNumver2,s,o,l,h),this.addVertex(e+this._tempNumver0,t+this._tempNumver1,n-this._tempNumver2,s,o,l,h),this.addVertex(e-this._tempNumver0,t+this._tempNumver1,n-this._tempNumver2,s,o,l,h),this.addVertex(e+this._tempNumver0,t-this._tempNumver1,n-this._tempNumver2,s,o,l,h),this.addVertex(e-this._tempNumver0,t-this._tempNumver1,n-this._tempNumver2,s,o,l,h),this._tempUint1=this._tempUint0+1,this._tempUint2=this._tempUint0+2,this._tempUint3=this._tempUint0+3,this._tempUint4=this._tempUint0+4,this._tempUint5=this._tempUint0+5,this._tempUint6=this._tempUint0+6,this._tempUint7=this._tempUint0+7,this.addIndexes(this._tempUint0,this._tempUint1,this._tempUint2,this._tempUint2,this._tempUint1,this._tempUint3,this._tempUint4,this._tempUint5,this._tempUint6,this._tempUint6,this._tempUint5,this._tempUint7,this._tempUint5,this._tempUint0,this._tempUint7,this._tempUint7,this._tempUint0,this._tempUint2,this._tempUint1,this._tempUint4,this._tempUint3,this._tempUint3,this._tempUint4,this._tempUint6,this._tempUint5,this._tempUint4,this._tempUint0,this._tempUint0,this._tempUint4,this._tempUint1,this._tempUint2,this._tempUint3,this._tempUint7,this._tempUint7,this._tempUint3,this._tempUint6),this},t.cone=function(e,t,n,i,r,a,s){for(this._hasBegun&&4===this._primitiveType||this.drawTrianglesException(),(this._posInVBData+(2*n+2)*this._floatSizePerVer>this._vbData.length||this._posInIBData+6*n>this._ibData.length)&&this.flush(),this._tempUint0=this._posInVBData,this._tempUint1=this._posInVBData/this._floatSizePerVer,this._tempNumver0=2*Math.PI/n,this.addVertexIndex(0,t,0,i,r,a,s,this._tempUint0),this.addVertexIndex(0,0,0,i,r,a,s,this._tempUint0+this._floatSizePerVer),this._tempInt0=2,this._tempNumver1=0,this._tempInt1=0;this._tempInt1<n;this._tempInt1++)this._tempNumver2=Math.cos(this._tempNumver1),this._tempNumver3=Math.sin(this._tempNumver1),this.addVertexIndex(e*this._tempNumver2,0,e*this._tempNumver3,i,r,a,s,this._tempUint0+this._tempInt0*this._floatSizePerVer),this.addIndexes(this._tempUint1,this._tempUint1+this._tempInt0),this._tempInt1==n-1?this.addIndexes(this._tempUint1+2):this.addIndexes(this._tempUint1+this._tempInt0+1),this.addVertexIndex(e*this._tempNumver2,0,e*this._tempNumver3,i,r,a,s,this._tempUint0+(this._tempInt0+n)*this._floatSizePerVer),this.addIndexes(this._tempUint1+1),this._tempInt1==n-1?this.addIndexes(this._tempUint1+n+2):this.addIndexes(this._tempUint1+this._tempInt0+n+1),this.addIndexes(this._tempUint1+this._tempInt0+n),this._tempInt0++,this._tempNumver1+=this._tempNumver0;return this},t.boundingBoxLine=function(e,t,n,i,r,a,s,o,l,h){return this._hasBegun&&1===this._primitiveType||this.drawLinesException(),(this._posInVBData+8*this._floatSizePerVer>this._vbData.length||this._posInIBData+48>this._ibData.length)&&this.flush(),this._tempUint0=this._posInVBData/this._floatSizePerVer,this.addVertex(e,r,a,s,o,l,h),this.addVertex(i,r,a,s,o,l,h),this.addVertex(e,t,a,s,o,l,h),this.addVertex(i,t,a,s,o,l,h),this.addVertex(i,r,n,s,o,l,h),this.addVertex(e,r,n,s,o,l,h),this.addVertex(i,t,n,s,o,l,h),this.addVertex(e,t,n,s,o,l,h),this._tempUint1=this._tempUint0+1,this._tempUint2=this._tempUint0+2,this._tempUint3=this._tempUint0+3,this._tempUint4=this._tempUint0+4,this._tempUint5=this._tempUint0+5,this._tempUint6=this._tempUint0+6,this._tempUint7=this._tempUint0+7,this.addIndexes(this._tempUint0,this._tempUint1,this._tempUint1,this._tempUint3,this._tempUint3,this._tempUint2,this._tempUint2,this._tempUint0,this._tempUint4,this._tempUint5,this._tempUint5,this._tempUint7,this._tempUint7,this._tempUint6,this._tempUint6,this._tempUint4,this._tempUint5,this._tempUint0,this._tempUint0,this._tempUint2,this._tempUint2,this._tempUint7,this._tempUint7,this._tempUint5,this._tempUint1,this._tempUint4,this._tempUint4,this._tempUint6,this._tempUint6,this._tempUint3,this._tempUint3,this._tempUint1,this._tempUint5,this._tempUint4,this._tempUint4,this._tempUint1,this._tempUint1,this._tempUint0,this._tempUint0,this._tempUint5,this._tempUint2,this._tempUint3,this._tempUint3,this._tempUint6,this._tempUint6,this._tempUint7,this._tempUint7,this._tempUint2),this},t.addVertex=function(e,t,n,i,r,a,s){return this._hasBegun||this.addVertexIndexException(),this._vbData[this._posInVBData]=e,this._vbData[this._posInVBData+1]=t,this._vbData[this._posInVBData+2]=n,this._vbData[this._posInVBData+3]=i,this._vbData[this._posInVBData+4]=r,this._vbData[this._posInVBData+5]=a,this._vbData[this._posInVBData+6]=s,this._posInVBData+=this._floatSizePerVer,this},t.addVertexIndex=function(e,t,n,i,r,a,s,o){return this._hasBegun||this.addVertexIndexException(),this._vbData[o]=e,this._vbData[o+1]=t,this._vbData[o+2]=n,this._vbData[o+3]=i,this._vbData[o+4]=r,this._vbData[o+5]=a,this._vbData[o+6]=s,o+=this._floatSizePerVer,o>this._posInVBData&&(this._posInVBData=o),this},t.addIndexes=function(e){var t=arguments;this._hasBegun||this.addVertexIndexException();for(var n=0;n<t.length;n++)this._ibData[this._posInIBData]=t[n],this._posInIBData++;return this},t.begin=function(e,t,n){return this._hasBegun&&this.beginException0(),1!==e&&4!==e&&this.beginException1(),this._primitiveType=e,this._wvpMatrix=t,this._renderState=n,this._hasBegun=!0,this},t.end=function(){return this._hasBegun||this.endException(),this.flush(),this._hasBegun=!1,this},t.flush=function(){if(0!==this._posInVBData){this._ib.clear(),this._ib.append(this._ibData),this._vb.clear(),this._vb.append(this._vbData),this._vb.bind_upload(this._ib);var e=this._renderState.shaderValue.length,t=this._renderState.shaderDefines.getValue();this._shader=this.getShader(this._renderState),this._renderState.shaderValue.pushValue("POSITION",this._posShaderValue),this._renderState.shaderValue.pushValue("COLOR",this._colorShaderValue),this._renderState.shaderValue.pushValue("MVPMATRIX",this._wvpMatrix.elements),this._renderState.shaderValue.pushValue("ALBEDO",this._albedo.elements),this._shader.uploadArray(this._renderState.shaderValue.data,this._renderState.shaderValue.length,null),this._renderState.shaderDefines.setValue(t),this._renderState.shaderValue.length=e,L.drawCall++,w.mainContext.drawElements(this._primitiveType,this._posInIBData,5123,0),this._posInIBData=0,this._posInVBData=0}},t.getShader=function(e){var t=e.shaderDefines._value;e.shaderDefines._value=-28673&t,e.shaderDefines.add(2048);var n=e.shaderDefines.getValue()+2e-4*this._sharderNameID,i=this._shader?this._shader:C.getShader(n);return i||(i=C.withCompile(this._sharderNameID,e.shaderDefines.toNameDic(),n,null))},t.addVertexIndexException=function(){throw new Error("请先调用begin()函数")},t.beginException0=function(){throw new Error("调用begin()前请确保已成功调用end()!")},t.beginException1=function(){throw new Error("只支持“LINES”和“TRIANGLES”两种基元!")},t.endException=function(){throw new Error("调用end()前请确保已成功调用begin()!")},t.drawLinesException=function(){throw new Error("您必须确保在此之前已调用begin()且使用“LINES”基元!")},t.drawTrianglesException=function(){throw new Error("您必须确保在此之前已调用begin()且使用“TRIANGLES”基元!")},e}(),function(){function e(){this.depthTest=!0,this.depthMask=1,this.blend=!1,this.cullFace=!0,this.sFactor=1,this.dFactor=0,this.frontFace=2304}return r(e,"laya.d3.core.render.RenderConfig"),e}()),se=function(){function e(){this._type=0,this._mainSortID=0,this._renderObject=null,this._sprite3D=null,this._material=null,this._renderObj=null,this._staticBatch=null,this._batchIndexStart=0,this._batchIndexEnd=0,this._canDynamicBatch=!1,this._canDynamicBatch=!0}r(e,"laya.d3.core.render.RenderElement");var t=e.prototype;return t.getStaticBatchBakedVertexs=function(t){var n=4,i=this._renderObj._getVertexBuffer(t),r=i.getData().slice(),a=i.vertexDeclaration,s=a.getVertexElementByUsage("POSITION").offset/n,o=a.getVertexElementByUsage("NORMAL").offset/n,l=this._staticBatch._rootSprite.transform.worldMatrix,h=this._sprite3D.transform.worldMatrix,u=e._tempMatrix4x40,c=e._tempMatrix4x41;l.invert(u),je.multiply(u,h,c);var _=e._tempQuaternion0;c.decompose(e._tempVector30,_,e._tempVector31);for(var d=a.vertexStride/n,m=0,f=r.length;f>m;m+=d){var p=m+s;rt.transformVector3ArrayToVector3ArrayCoordinate(r,p,c,r,p),rt.transformVector3ArrayByQuat(r,o,_,r,o)}return r},t.getDynamicBatchBakedVertexs=function(e){for(var t=4,n=this._renderObj._getVertexBuffer(e),i=n.getData().slice(),r=n.vertexDeclaration,a=r.getVertexElementByUsage("POSITION").offset/t,s=r.getVertexElementByUsage("NORMAL").offset/t,o=this._sprite3D.transform,l=o.worldMatrix,h=o.rotation,u=r.vertexStride/t,c=0,_=i.length;_>c;c+=u){var d=c+a;rt.transformVector3ArrayToVector3ArrayCoordinate(i,d,l,i,d),rt.transformVector3ArrayByQuat(i,s,h,i,s)}return i},t.getBakedIndices=function(){return this._renderObj._getIndexBuffer().getData()},a(0,t,"renderObj",function(){return this._renderObj},function(e){this._renderObj!==e&&(this._renderObj=e)}),i(e,["_tempVector30",function(){return this._tempVector30=new Qe},"_tempVector31",function(){return this._tempVector31=new Qe},"_tempQuaternion0",function(){return this._tempQuaternion0=new Ze},"_tempMatrix4x40",function(){return this._tempMatrix4x40=new je},"_tempMatrix4x41",function(){return this._tempMatrix4x41=new je}]),e}(),oe=function(){function e(t,n){this._id=0,this._needSort=!1,this._renderElements=null,this._staticBatches=null,this._renderableRenderObjects=null,this._renderConfig=null,this._staticBatchCombineRenderElements=null,this._dynamicBatchCombineRenderElements=null,this._finalElements=null,this._scene=null,this._id=++e._uniqueIDCounter,this._needSort=!1,this._renderConfig=t,this._scene=n,this._renderElements=[],this._renderableRenderObjects=[],this._staticBatchCombineRenderElements=[],this._dynamicBatchCombineRenderElements=[],this._staticBatches=[]}r(e,"laya.d3.core.render.RenderQueue");var t=e.prototype;return t._sortAlphaFunc=function(t,n){return t._renderObject&&n._renderObject?Qe.distance(n._renderObject._boundingSphere.center,e._cameraPosition)-Qe.distance(t._renderObject._boundingSphere.center,e._cameraPosition):0},t._begainRenderElement=function(e,t,n){return t._beforeRender(e)?(e.shaderValue.pushArray(t._getVertexBuffer(0).vertexDeclaration.shaderValues),!0):!1},t._endRenderElement=function(e,t,n){n._upload(e,t._getVertexBuffer(0).vertexDeclaration,null),t._render(e)},t._preRenderUpdateComponents=function(e,t){for(var n=0;n<e.componentsCount;n++){var i=e.getComponentByIndex(n);!i.started&&(i._start(t),i.started=!0),i.isActive&&i._preRenderUpdate(t)}},t._postRenderUpdateComponents=function(e,t){for(var n=0;n<e.componentsCount;n++){var i=e.getComponentByIndex(n);!i.started&&(i._start(t),i.started=!0),i.isActive&&i._postRenderUpdate(t)}},t._sortAlpha=function(t){e._cameraPosition=t,this._finalElements.sort(this._sortAlphaFunc)},t._setState=function(e,t){N.setDepthTest(e,this._renderConfig.depthTest),N.setDepthMask(e,this._renderConfig.depthMask),N.setBlend(e,this._renderConfig.blend),N.setBlendFunc(e,this._renderConfig.sFactor,this._renderConfig.dFactor),N.setCullFace(e,this._renderConfig.cullFace),t.camera.renderTarget?N.setFrontFaceCCW(e,2304===this._renderConfig.frontFace?2305:2304):N.setFrontFaceCCW(e,this._renderConfig.frontFace)},t._preRender=function(e){this._staticBatchCombineRenderElements.length=0;for(var t=0,n=this._staticBatches.length;n>t;t++)this._staticBatches[t]._getRenderElement(this._staticBatchCombineRenderElements);this._finalElements=this._renderElements.concat(this._staticBatchCombineRenderElements,this._dynamicBatchCombineRenderElements)},t._render=function(e){for(var t=e.shaderValue.length,n=e.shaderDefines.getValue(),i=0,r=this._finalElements.length;r>i;i++){var a,s,o=this._finalElements[i];if(0===o._type){var l=o._sprite3D;e.owner=l,e.renderElement=o,this._preRenderUpdateComponents(l,e),a=o.renderObj,s=o._material,this._begainRenderElement(e,a,s)&&(s._setLoopShaderParams(e,e.projectionViewMatrix,l.transform.worldMatrix,o.renderObj,s),this._endRenderElement(e,a,s)),this._postRenderUpdateComponents(l,e)}else if(1===o._type){var h=o.renderObj;e.owner=null,e.renderElement=o,e._batchIndexStart=o._batchIndexStart,e._batchIndexEnd=o._batchIndexEnd,a=o.renderObj,s=o._material,this._begainRenderElement(e,a,s)&&(o._material._setLoopShaderParams(e,e.projectionViewMatrix,h._rootSprite.transform.worldMatrix,o.renderObj,o._material),this._endRenderElement(e,a,s))}else if(2===o._type){o.renderObj;e.owner=null,e.renderElement=o,e._batchIndexStart=o._batchIndexStart,e._batchIndexEnd=o._batchIndexEnd,a=o.renderObj,s=o._material,this._begainRenderElement(e,a,s)&&(o._material._setLoopShaderParams(e,e.projectionViewMatrix,je.DEFAULT,o.renderObj,o._material),this._endRenderElement(e,a,s))}e.shaderDefines.setValue(n),e.shaderValue.length=t}},t._clearRenderElements=function(){this._staticBatches.length=0,this._dynamicBatchCombineRenderElements.length=0,this._renderElements.length=0,this._needSort=!0},t._addRenderElement=function(e){this._renderElements.push(e),this._needSort=!0},t._addStaticBatch=function(e){this._staticBatches.push(e)},t._addDynamicBatchElement=function(e){this._dynamicBatchCombineRenderElements.push(e)},a(0,t,"id",function(){return this._id}),e._uniqueIDCounter=0,e.OPAQUE=1,e.OPAQUE_DOUBLEFACE=2,e.ALPHA_BLEND=3,e.ALPHA_BLEND_DOUBLEFACE=4,e.ALPHA_ADDTIVE_BLEND=5,e.ALPHA_ADDTIVE_BLEND_DOUBLEFACE=6,e.DEPTHREAD_ALPHA_BLEND=7,e.DEPTHREAD_ALPHA_BLEND_DOUBLEFACE=8,e.DEPTHREAD_ALPHA_ADDTIVE_BLEND=9,e.DEPTHREAD_ALPHA_ADDTIVE_BLEND_DOUBLEFACE=10,e.NONDEPTH_ALPHA_BLEND=11,e.NONDEPTH_ALPHA_BLEND_DOUBLEFACE=12,e.NONDEPTH_ALPHA_ADDTIVE_BLEND=13,e.NONDEPTH_ALPHA_ADDTIVE_BLEND_DOUBLEFACE=14,e._cameraPosition=null,e}(),le=function(){function e(){this.elapsedTime=NaN,this.loopCount=0,this.context=null,this.scene=null,this.owner=null,this.renderElement=null,this._staticBatch=null,this._batchIndexStart=0,this._batchIndexEnd=0,this.camera=null,this.viewMatrix=null,this.projectionMatrix=null,this.projectionViewMatrix=null,this.cameraBoundingFrustum=null,this.viewport=null,this.shaderValue=new b,this.shaderDefines=new ct,this.reset()}r(e,"laya.d3.core.render.RenderState");var t=e.prototype;return t.reset=function(){this.shaderValue.length=0,this.shaderDefines.setValue(0)},e.VERTEXSHADERING=4,e.PIXELSHADERING=8,e.clientWidth=0,e.clientHeight=0,e}(),he=function(){function e(e){this._vertexDeclaration=null,this._vertexDatas=null,this._indexDatas=null,this._vertexBuffer=null,this._indexBuffer=null,this._currentCombineVertexCount=0,this._currentCombineIndexCount=0,this._combineRenderElements=null,this._materials=null,this._materialToRenderElementsOffsets=null,this._merageElements=null,this._combineRenderElementPool=null,this._combineRenderElementPoolIndex=0,this._currentCombineVertexCount=0,this._currentCombineIndexCount=0,this._combineRenderElements=[],this._materialToRenderElementsOffsets=[],this._materials=[],this._merageElements=[],this._combineRenderElementPool=[],this._combineRenderElementPoolIndex=0,this._vertexDeclaration=e}r(e,"laya.d3.graphics.DynamicBatch");var t=e.prototype;return n.imps(t,{"laya.d3.core.render.IRenderable":!0}),t._getVertexBuffer=function(e){return void 0===e&&(e=0),0===e?this._vertexBuffer:null},t._getIndexBuffer=function(){return this._indexBuffer},t._getCombineRenderElementFromPool=function(){var e=this._combineRenderElementPool[this._combineRenderElementPoolIndex++];return e||(this._combineRenderElementPool[this._combineRenderElementPoolIndex-1]=new se)},t._getRenderElement=function(){this._vertexDatas||(this._vertexDatas=new Float32Array(this._vertexDeclaration.vertexStride/4*e.maxVertexCount),
|
||
this._indexDatas=new Uint16Array(e.maxIndexCount),this._vertexBuffer=Bt.create(this._vertexDeclaration,e.maxVertexCount,35048),this._indexBuffer=Nt.create("ushort",e.maxIndexCount,35048)),this._merageElements.length=0;for(var t=0,n=0,i=0,r=this._combineRenderElements.length;r>i;i++){var a=this._combineRenderElements[i],s=a.getDynamicBatchBakedVertexs(0),o=a.getBakedIndices(),l=t/(this._vertexDeclaration.vertexStride/4),h=n,u=h+o.length;a._batchIndexStart=h,a._batchIndexEnd=u,this._indexDatas.set(o,n);for(var c=h;u>c;c++)this._indexDatas[c]=l+this._indexDatas[c];n+=o.length,this._vertexDatas.set(s,t),t+=s.length}for(this._vertexBuffer.setData(this._vertexDatas),this._indexBuffer.setData(this._indexDatas),this._combineRenderElementPoolIndex=0,i=0,r=this._materials.length;r>i;i++){var _=this._getCombineRenderElementFromPool();_._type=2,_._staticBatch=null,_.renderObj=this;var d=this._combineRenderElements[this._materialToRenderElementsOffsets[i]]._batchIndexStart,m=i+1===this._materialToRenderElementsOffsets.length?n:this._combineRenderElements[this._materialToRenderElementsOffsets[i+1]]._batchIndexStart;_._batchIndexStart=d,_._batchIndexEnd=m,_._material=this._materials[i],this._merageElements.push(_)}},t._addCombineRenderObjTest=function(t){var n=t.renderObj,i=this._currentCombineIndexCount+n._getIndexBuffer().indexCount,r=this._currentCombineVertexCount+n._getVertexBuffer().vertexCount;return!(r>e.maxVertexCount||i>e.maxIndexCount)},t._addCombineRenderObj=function(e){var t=e.renderObj;this._combineRenderElements.push(e),this._currentCombineIndexCount=this._currentCombineIndexCount+t._getIndexBuffer().indexCount,this._currentCombineVertexCount=this._currentCombineVertexCount+t._getVertexBuffer().vertexCount},t._addCombineMaterial=function(e){this._materials.push(e)},t._addMaterialToRenderElementOffset=function(e){this._materialToRenderElementsOffsets.push(e)},t._clearRenderElements=function(){this._combineRenderElements.length=0,this._materials.length=0,this._materialToRenderElementsOffsets.length=0,this._currentCombineVertexCount=0,this._currentCombineIndexCount=0},t._addToRenderQueue=function(e){this._getRenderElement();for(var t=0,n=this._materials.length;n>t;t++)e.getRenderQueue(this._materials[t].renderQueue)._addDynamicBatchElement(this._merageElements[t])},t._beforeRender=function(e){return this._vertexBuffer._bind(),this._indexBuffer._bind(),!0},t._render=function(e){var t=e._batchIndexEnd-e._batchIndexStart;e.context.drawElements(4,t,5123,2*e._batchIndexStart),L.drawCall++,L.trianglesFaces+=t/3},a(0,t,"indexOfHost",function(){return 0}),a(0,t,"_vertexBufferCount",function(){return 1}),a(0,t,"triangleCount",function(){return this._indexBuffer.indexCount/3}),a(0,t,"combineRenderElementsCount",function(){return this._combineRenderElements.length}),e.maxVertexCount=2e4,e.maxIndexCount=4e4,e.maxCombineTriangleCount=50,e}(),ue=function(){function e(){this._dynamicBatches=null,this._prepareDynamicBatchCombineElements=null,this._dynamicBatches={},this._prepareDynamicBatchCombineElements=[]}r(e,"laya.d3.graphics.DynamicBatchManager");var t=e.prototype;return t.getDynamicBatch=function(e,t){var n,i=e.id.toString()+t;return this._dynamicBatches[i]?n=this._dynamicBatches[i]:this._dynamicBatches[i]=n=new he(e),n},t._garbageCollection=function(){for(var e in this._dynamicBatches)0===this._dynamicBatches[e].combineRenderElementsCount&&delete this._dynamicBatches[e]},t._addPrepareRenderElement=function(e){this._prepareDynamicBatchCombineElements.push(e)},t._finishCombineDynamicBatch=function(t){this._prepareDynamicBatchCombineElements.sort(e._sortPrepareDynamicBatch);for(var n,i,r,a,s,o,l,h,u=-1,c=!0,_=0,d=-1,m=0,f=this._prepareDynamicBatchCombineElements.length;f>m;m++){s=this._prepareDynamicBatchCombineElements[m];var p=s.renderObj._getVertexBuffer(0).vertexDeclaration,v=i!==p;v&&(_=0,i=p);var g=_!==u;if(g&&(u=_),(v||g)&&(o=this.getDynamicBatch(p,_),n=null),c)if(o._addCombineRenderObjTest(s)){if(a=s._material,n!==a)l&&(t.getRenderQueue(h._material.renderQueue)._addRenderElement(h),l=null,h=null,d=-1),l=a,d=o.combineRenderElementsCount,h=s,n=a;else if(l){var T=h.renderObj,x=s.renderObj;T._getVertexBuffer().vertexCount+x._getVertexBuffer().vertexCount>he.maxVertexCount||T._getIndexBuffer().indexCount+x._getIndexBuffer().indexCount>he.maxIndexCount?(t.getRenderQueue(h._material.renderQueue)._addRenderElement(h),l=a,d=o.combineRenderElementsCount,h=s):(o._addCombineMaterial(l),o._addMaterialToRenderElementOffset(d),o._addCombineRenderObj(h),l=null,h=null,d=-1,o._addCombineRenderObj(s))}else o._addCombineRenderObj(s);c=!0}else l&&(t.getRenderQueue(h._material.renderQueue)._addRenderElement(h),l=null,h=null,d=-1),_++,c=!1;else r=this._prepareDynamicBatchCombineElements[m-1],o._addMaterialToRenderElementOffset(o.combineRenderElementsCount),n=r._material,o._addCombineMaterial(n),o._addCombineRenderObj(r),c=!0,a=s._material,n!==a?(l=a,d=o.combineRenderElementsCount,h=s):o._addCombineRenderObj(s),n=a}l&&(t.getRenderQueue(h._material.renderQueue)._addRenderElement(h),l=null,h=null,d=-1),this._prepareDynamicBatchCombineElements.length=0},t._clearRenderElements=function(){for(var e in this._dynamicBatches)this._dynamicBatches[e]._clearRenderElements()},t._addToRenderQueue=function(e){for(var t in this._dynamicBatches){var n=this._dynamicBatches[t];n.combineRenderElementsCount>0&&n._addToRenderQueue(e)}},t.dispose=function(){this._dynamicBatches=null},e._sortPrepareDynamicBatch=function(e,t){return e._mainSortID-t._mainSortID},e}(),ce=function(){function e(){}return r(e,"laya.d3.graphics.FrustumCulling"),e.RenderObjectCulling=function(e,t){var n,i,r=0,a=0,s=0,o=0,l=t._quenes,h=t._staticBatchManager,u=t._dynamicBatchManager,c=t._frustumCullingObjects;for(r=0,a=l.length;a>r;r++)l[r]&&l[r]._clearRenderElements();for(h._clearRenderElements(),u._clearRenderElements(),r=0,a=c.length;a>r;r++)if(n=c[r],U.isVisible(n._layerMask)&&n._ownerEnable&&n._enable&&0!==e.ContainsBoundSphere(n._boundingSphere))for(s=0,o=n._renderElements.length;o>s;s++){i=n._renderElements[s];var _=i._staticBatch;if(_&&_._material===i._material)_._addRenderElement(i);else{var d=i.renderObj;d.triangleCount<50&&1===d._vertexBufferCount&&d._getIndexBuffer()&&i._material.renderQueue<3&&i._canDynamicBatch?u._addPrepareRenderElement(i):t.getRenderQueue(i._material.renderQueue)._addRenderElement(i)}}h._addToRenderQueue(t),u._finishCombineDynamicBatch(t),u._addToRenderQueue(t)},e}(),_e=function(){function e(){this._render=null,this._renderElements=null,this._layerMask=0,this._ownerEnable=!1,this._enable=!1,this._renderElements=[]}r(e,"laya.d3.graphics.RenderObject");var t=e.prototype;return a(0,t,"_boundingSphere",function(){return this._render.boundingSphere}),e}(),de=function(){function e(e,t,n){this._vertexBuffer=null,this._indexBuffer=null,this._renderElements=null,this._combineRenderElementPool=null,this._combineRenderElementPoolIndex=0,this._combineRenderElements=null,this._currentCombineVertexCount=0,this._currentCombineIndexCount=0,this._needFinishCombine=!1,this._rootSprite=null,this._vertexDeclaration=null,this._material=null,this._currentCombineVertexCount=0,this._currentCombineIndexCount=0,this._needFinishCombine=!1,this._renderElements=[],this._combineRenderElements=[],this._combineRenderElementPool=[],this._combineRenderElementPoolIndex=0,this._rootSprite=e,this._vertexDeclaration=t,this._material=n}r(e,"laya.d3.graphics.StaticBatch");var t=e.prototype;return n.imps(t,{"laya.d3.core.render.IRenderable":!0}),t._getVertexBuffer=function(e){return void 0===e&&(e=0),0===e?this._vertexBuffer:null},t._getIndexBuffer=function(){return this._indexBuffer},t._getCombineRenderElementFromPool=function(){var e=this._combineRenderElementPool[this._combineRenderElementPoolIndex++];return e||(this._combineRenderElementPool[this._combineRenderElementPoolIndex-1]=new se)},t._addCombineRenderObjTest=function(t){var n=t.renderObj,i=this._currentCombineVertexCount+n._getVertexBuffer().vertexCount;return!(i>e.maxVertexCount)},t._addCombineRenderObj=function(e){var t=e.renderObj;this._combineRenderElements.push(e),e._staticBatch=this,this._currentCombineIndexCount=this._currentCombineIndexCount+t._getIndexBuffer().indexCount,this._currentCombineVertexCount=this._currentCombineVertexCount+t._getVertexBuffer().vertexCount,this._needFinishCombine=!0},t._deleteCombineRenderObj=function(e){var t=e.renderObj,n=this._combineRenderElements.indexOf(e);-1!==n&&(this._combineRenderElements.splice(n,1),e._staticBatch=null,this._currentCombineIndexCount=this._currentCombineIndexCount-t._getIndexBuffer().indexCount,this._currentCombineVertexCount=this._currentCombineVertexCount-t._getVertexBuffer().vertexCount,this._needFinishCombine=!0)},t._finshCombine=function(){if(this._needFinishCombine){var e=0,t=0,n=new Float32Array(this._vertexDeclaration.vertexStride/4*this._currentCombineVertexCount),i=new Uint16Array(this._currentCombineIndexCount);this._vertexBuffer&&(this._vertexBuffer.dispose(),this._indexBuffer.dispose()),this._vertexBuffer=Bt.create(this._vertexDeclaration,this._currentCombineVertexCount,35044),this._indexBuffer=Nt.create("ushort",this._currentCombineIndexCount,35044);for(var r=0,a=this._combineRenderElements.length;a>r;r++){var s=this._combineRenderElements[r],o=s.getStaticBatchBakedVertexs(0),l=s.getBakedIndices(),h=e/(this._vertexDeclaration.vertexStride/4),u=t,c=u+l.length;s._batchIndexStart=u,s._batchIndexEnd=c,i.set(l,t);for(var _=u;c>_;_++)i[_]=h+i[_];t+=l.length,n.set(o,e),e+=o.length}this._vertexBuffer.setData(n),this._indexBuffer.setData(i),this._needFinishCombine=!1}},t._clearRenderElements=function(){this._renderElements.length=0},t._addRenderElement=function(e){for(var t=0,n=this._renderElements.length;n>t;t++)if(this._renderElements[t]._batchIndexStart>e._batchIndexStart)return void this._renderElements.splice(t,0,e);this._renderElements.push(e)},t._getRenderElement=function(e){this._combineRenderElementPoolIndex=0;var t=this._renderElements.length,n=this._getCombineRenderElementFromPool();if(n._type=1,n._staticBatch=null,n.renderObj=this,n._batchIndexStart=this._renderElements[0]._batchIndexStart,n._batchIndexEnd=this._renderElements[0]._batchIndexEnd,n._material=this._material,n._material=this._material,e.push(n),t>1)for(var i=1;t>i;i++){var r=this._renderElements[i];this._renderElements[i-1]._batchIndexEnd!==r._batchIndexStart?(n=this._getCombineRenderElementFromPool(),n._type=1,n._staticBatch=null,n.renderObj=this,n._batchIndexStart=r._batchIndexStart,n._batchIndexEnd=r._batchIndexEnd,n._material=this._material,e.push(n)):n._batchIndexEnd=r._batchIndexEnd}},t._addToRenderQueue=function(e){this._renderElements.length>0&&e.getRenderQueue(this._material.renderQueue)._addStaticBatch(this)},t._beforeRender=function(e){return this._vertexBuffer._bind(),this._indexBuffer._bind(),!0},t._render=function(e){var t=e._batchIndexEnd-e._batchIndexStart;e.context.drawElements(4,t,5123,2*e._batchIndexStart),L.drawCall++,L.trianglesFaces+=t/3},a(0,t,"_vertexBufferCount",function(){return 1}),a(0,t,"indexOfHost",function(){return 0}),a(0,t,"triangleCount",function(){return this._indexBuffer.indexCount/3}),e._addToRenderQueueStaticBatch=function(t,n){var i=0,r=0;if(n instanceof laya.d3.core.MeshSprite3D&&n.isStatic){var a=n.meshRender.renderObject._renderElements;for(i=0,r=a.length;r>i;i++){var s=a[i];1===s.renderObj._vertexBufferCount&&t._staticBatchManager._addPrepareRenderElement(s)}}for(i=0,r=n.numChildren;r>i;i++)e._addToRenderQueueStaticBatch(t,n._childs[i])},e.combine=function(t){var n=t.scene;if(!n)throw new Error("BaseScene: staticBatchRoot is not a part of scene.");e._addToRenderQueueStaticBatch(n,t),n._staticBatchManager._finishCombineStaticBatch(t)},e.maxVertexCount=65535,e}(),me=function(){function e(){this._staticBatches=null,this._prepareStaticBatchCombineElements=null,this._staticBatches={},this._prepareStaticBatchCombineElements=[]}r(e,"laya.d3.graphics.StaticBatchManager");var t=e.prototype;return t._finshCombine=function(){for(var e in this._staticBatches)this._staticBatches[e]._finshCombine()},t.getStaticBatch=function(e,t,n,i){var r,a=e.id.toString()+n.id.toString()+t.id.toString()+i;return this._staticBatches[a]?r=this._staticBatches[a]:this._staticBatches[a]=r=new de(e,t,n),r},t._garbageCollection=function(){for(var e in this._staticBatches)0===this._staticBatches[e].combineRenderElementsCount&&delete this._staticBatches[e]},t._addPrepareRenderElement=function(e){this._prepareStaticBatchCombineElements.push(e)},t._finishCombineStaticBatch=function(t){this._prepareStaticBatchCombineElements.sort(e._sortPrepareStaticBatch);for(var n,i,r,a,s,o,l,h=!1,u=0,c=0,_=this._prepareStaticBatchCombineElements.length;_>c;c++){if(a=this._prepareStaticBatchCombineElements[c],o=a.renderObj._getVertexBuffer(0),i===o.vertexDeclaration&&n===a._material)if(h)r._addCombineRenderObjTest(a)?(l=a._staticBatch,l&&l!==r&&l._deleteCombineRenderObj(a),r._addCombineRenderObj(a)):(h=!1,u++);else{s=this._prepareStaticBatchCombineElements[c-1];var d=s.renderObj,m=a.renderObj;d._getVertexBuffer().vertexCount+m._getVertexBuffer().vertexCount>de.maxVertexCount?h=!1:(r=this.getStaticBatch(t,i,n,u),l=s._staticBatch,l&&l!==r&&l._deleteCombineRenderObj(s),r._addCombineRenderObj(s),l=a._staticBatch,l&&l!==r&&l._deleteCombineRenderObj(a),r._addCombineRenderObj(a),h=!0)}else h=!1,u=0;n=a._material,i=o.vertexDeclaration}this._garbageCollection(),this._finshCombine(),this._prepareStaticBatchCombineElements.length=0},t._clearRenderElements=function(){for(var e in this._staticBatches)this._staticBatches[e]._clearRenderElements()},t._addToRenderQueue=function(e){for(var t in this._staticBatches)this._staticBatches[t]._addToRenderQueue(e)},t.dispose=function(){this._staticBatches=null},e._sortPrepareStaticBatch=function(e,t){var n=e._mainSortID-t._mainSortID;return 0===n?e.renderObj.triangleCount-t.renderObj.triangleCount:n},e}(),fe=function(){function e(t,n){if(this._id=0,this._shaderValues=null,this._shaderDefineValue=0,this._vertexStride=0,this._vertexElements=null,this._vertexElementsDic=null,this._id=++e._uniqueIDCounter,this._id>e.maxVertexDeclaration)throw new Error("VertexDeclaration: VertexDeclaration count should not large than ",e.maxVertexDeclaration);this._shaderValues=new b,this._vertexElementsDic={},this._vertexStride=t,this._vertexElements=n;for(var i=0;i<n.length;i++){var r=n[i],a=r.elementUsage;this._vertexElementsDic[a]=r;var s=[e._getTypeSize(r.elementFormat)/4,5126,!1,this._vertexStride,r.offset];switch(this._shaderValues.pushValue(a,s),a){case"UV":this._shaderDefineValue|=1024;break;case"COLOR":this._shaderDefineValue|=2048}}}r(e,"laya.d3.graphics.VertexDeclaration");var t=e.prototype;return t.getVertexElements=function(){return this._vertexElements.slice()},t.getVertexElementByUsage=function(e){return this._vertexElementsDic[e]},t.unBinding=function(){},a(0,t,"shaderDefineValue",function(){return this._shaderDefineValue}),a(0,t,"id",function(){return this._id}),a(0,t,"vertexStride",function(){return this._vertexStride}),a(0,t,"shaderValues",function(){return this._shaderValues}),e._getTypeSize=function(e){switch(e){case"single":return 4;case"vector2":return 8;case"vector3":return 12;case"vector4":return 16;case"color":return 4;case"byte4":return 4;case"short2":return 4;case"short4":return 8;case"normalizedshort2":return 4;case"normalizedshort4":return 8;case"halfvector2":return 4;case"halfvector4":return 8}return 0},e.getVertexStride=function(t){for(var n=0,i=0;i<t.Length;i++){var r=t[i],a=r.offset+e._getTypeSize(r.elementFormat);a>n&&(n=a)}return n},e._maxVertexDeclarationBit=1e3,e._uniqueIDCounter=1,i(e,["maxVertexDeclaration",function(){return this.maxVertexDeclaration=2147483647-1e3*Math.floor(2147483.647)}]),e}(),pe=function(){function e(e,t,n){this.offset=0,this.elementFormat=null,this.elementUsage=null,this.offset=e,this.elementFormat=t,this.elementUsage=n}return r(e,"laya.d3.graphics.VertexElement"),e}(),ve=(function(){function e(){}return r(e,"laya.d3.graphics.VertexElementFormat"),e.Single="single",e.Vector2="vector2",e.Vector3="vector3",e.Vector4="vector4",e.Color="color",e.Byte4="byte4",e.Short2="short2",e.Short4="short4",e.NormalizedShort2="normalizedshort2",e.NormalizedShort4="normalizedshort4",e.HalfVector2="halfvector2",e.HalfVector4="halfvector4",e}(),function(){function e(){}return r(e,"laya.d3.graphics.VertexElementUsage"),e.POSITION0="POSITION",e.COLOR0="COLOR",e.TEXTURECOORDINATE0="UV",e.NORMAL0="NORMAL",e.BINORMAL0="BINORMAL",e.TANGENT0="TANGENT0",e.BLENDINDICES0="BLENDINDICES",e.BLENDWEIGHT0="BLENDWEIGHT",e.DEPTH0="DEPTH",e.FOG0="FOG",e.POINTSIZE0="POINTSIZE",e.SAMPLE0="SAMPLE",e.TESSELLATEFACTOR0="TESSELLATEFACTOR",e.COLOR1="COLOR1",e.NEXTTEXTURECOORDINATE0="NEXTUV",e.TEXTURECOORDINATE1="UV1",e.NEXTTEXTURECOORDINATE1="NEXTUV1",e.CORNERTEXTURECOORDINATE0="CORNERTEXTURECOORDINATE",e.VELOCITY0="VELOCITY",e.STARTCOLOR0="STARTCOLOR",e.STARTSIZE="STARTSIZE",e.AGEADDSCALE0="AGEADDSCALE0",e.STARTROTATION0="STARTROTATION0",e.STARTROTATION1="STARTROTATION1",e.STARTROTATION2="STARTROTATION2",e.ENDCOLOR0="ENDCOLOR",e.SIZEROTATION0="SIZEROTATION",e.RADIUS0="RADIUS",e.RADIAN0="RADIAN",e.STARTLIFETIME="STARTLIFETIME",e.STARTSPEED="STARTSPEED",e.DIRECTION="DIRECTION",e.TIME0="TIME",e.RANDOM0="RANDOM0",e.RANDOM1="RANDOM1",e.SIMULATIONWORLDPOSTION="SIMULATIONWORLDPOSTION",e}(),function(){function e(e,t,n){this._position=null,this._textureCoordinate0=null,this._time=NaN,this._position=e,this._textureCoordinate0=t,this._time=n}r(e,"laya.d3.graphics.VertexGlitter");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"textureCoordinate",function(){return this._textureCoordinate0}),a(0,t,"position",function(){return this._position}),a(0,t,"time",function(){return this._time}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(24,[new pe(0,"vector3","POSITION"),new pe(12,"vector2","UV"),new pe(20,"single","TIME")])}]),e}()),ge=function(){function e(e,t,n,i,r,a,s,o,l,h){this._cornerTextureCoordinate=null,this._position=null,this._velocity=null,this._startColor=null,this._endColor=null,this._sizeRotation=null,this._radius=null,this._radian=null,this._ageAddScale=NaN,this._time=NaN,this._cornerTextureCoordinate=e,this._position=t,this._velocity=n,this._startColor=i,this._endColor=r,this._sizeRotation=a,this._radius=s,this._radian=o,this._ageAddScale=l,this._time=h}r(e,"laya.d3.graphics.VertexParticle");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"endColor",function(){return this._endColor}),a(0,t,"cornerTextureCoordinate",function(){return this._cornerTextureCoordinate}),a(0,t,"sizeRotation",function(){return this._sizeRotation}),a(0,t,"velocity",function(){return this._velocity}),a(0,t,"position",function(){return this._position}),a(0,t,"startColor",function(){return this._startColor}),a(0,t,"radius",function(){return this._radius}),a(0,t,"radian",function(){return this._radian}),a(0,t,"ageAddScale",function(){return this._ageAddScale}),a(0,t,"time",function(){return this._time}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(116,[new pe(0,"vector4","CORNERTEXTURECOORDINATE"),new pe(16,"vector3","POSITION"),new pe(28,"vector3","VELOCITY"),new pe(40,"vector4","STARTCOLOR"),new pe(56,"vector4","ENDCOLOR"),new pe(72,"vector3","SIZEROTATION"),new pe(84,"vector2","RADIUS"),new pe(92,"vector4","RADIAN"),new pe(108,"single","STARTLIFETIME"),new pe(112,"single","TIME")])}]),e}(),Te=function(){function e(e,t,n,i,r,a,s,o,l,h,u,c,_,d){this._cornerTextureCoordinate=null,this._position=null,this._velocity=null,this._startColor=null,this._startSize=null,this._startRotation0=null,this._startRotation1=null,this._startRotation2=null,this._startLifeTime=NaN,this._time=NaN,this._startSpeed=NaN,this._randoms0=null,this._randoms1=null,this._simulationWorldPostion=null,this._cornerTextureCoordinate=e,this._position=t,this._velocity=n,this._startColor=i,this._startSize=r,this._startRotation0=a,this._startRotation1=s,this._startRotation2=o,this._startLifeTime=l,this._time=h,this._startSpeed=u,this._randoms0=this.random0,this._randoms1=this.random1,this._simulationWorldPostion=d}r(e,"laya.d3.graphics.VertexParticleShuriken");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"cornerTextureCoordinate",function(){return this._cornerTextureCoordinate}),a(0,t,"velocity",function(){return this._velocity}),a(0,t,"position",function(){return this._position}),a(0,t,"random0",function(){return this._randoms0}),a(0,t,"startSize",function(){return this._startSize}),a(0,t,"startColor",function(){return this._startColor}),a(0,t,"startRotation0",function(){return this._startRotation0}),a(0,t,"startRotation1",function(){return this._startRotation1}),a(0,t,"random1",function(){return this._randoms1}),a(0,t,"startRotation2",function(){return this._startRotation2}),a(0,t,"startLifeTime",function(){return this._startLifeTime}),a(0,t,"time",function(){return this._time}),a(0,t,"startSpeed",function(){return this._startSpeed}),a(0,t,"simulationWorldPostion",function(){return this._simulationWorldPostion}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(160,[new pe(0,"vector4","CORNERTEXTURECOORDINATE"),new pe(16,"vector3","POSITION"),new pe(28,"vector3","DIRECTION"),new pe(40,"vector4","STARTCOLOR"),new pe(56,"vector3","STARTSIZE"),new pe(68,"vector3","STARTROTATION0"),new pe(80,"vector3","STARTROTATION1"),new pe(92,"vector3","STARTROTATION2"),new pe(104,"single","STARTLIFETIME"),new pe(108,"single","TIME"),new pe(112,"single","STARTSPEED"),new pe(116,"vector4","RANDOM0"),new pe(132,"vector4","RANDOM1"),new pe(148,"vector3","SIMULATIONWORLDPOSTION")])}]),e}(),xe=function(){function e(e,t,n){this._position=null,this._normal=null,this._color=null,this._position=e,this._normal=t,this._color=n}r(e,"laya.d3.graphics.VertexPositionNormalColor");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"color",function(){return this._color}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(40,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector4","COLOR")])}]),e}(),Me=function(){function e(e,t,n,i,r){this._position=null,this._normal=null,this._color=null,this._blendIndex=null,this._blendWeight=null,this._position=e,this._normal=t,this._color=n,this._blendIndex=i,this._blendWeight=r}r(e,"laya.d3.graphics.VertexPositionNormalColorSkin");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"blendWeight",function(){return this._blendWeight}),a(0,t,"color",function(){return this._color}),a(0,t,"blendIndex",function(){return this._blendIndex}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(72,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector4","COLOR"),new pe(40,"vector4","BLENDWEIGHT"),new pe(56,"vector4","BLENDINDICES")])}]),e}(),Ee=function(){function e(e,t,n,i,r,a){this._position=null,this._normal=null,this._color=null,this._blendIndex=null,this._blendWeight=null,this._tangent=null,this._position=e,this._normal=t,this._color=n,this._tangent=i,this._blendIndex=r,this._blendWeight=a}r(e,"laya.d3.graphics.VertexPositionNormalColorSkinTangent");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"tangent",function(){return this._tangent}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"blendWeight",function(){return this._blendWeight}),a(0,t,"color",function(){return this._color}),a(0,t,"blendIndex",function(){return this._blendIndex}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(84,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector4","COLOR"),new pe(40,"vector4","BLENDWEIGHT"),new pe(56,"vector4","BLENDINDICES"),new pe(72,"vector3","TANGENT0")])}]),e}(),ye=function(){function e(e,t,n,i){this._position=null,this._normal=null,this._color=null,this._tangent=null,this._position=e,this._normal=t,this._color=n,this._tangent=i}r(e,"laya.d3.graphics.VertexPositionNormalColorTangent");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"tangent",function(){return this._tangent}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"color",function(){return this._color}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(52,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector4","COLOR"),new pe(40,"vector3","TANGENT0")])}]),e}(),Se=function(){function e(e,t,n,i){this._position=null,this._normal=null,this._color=null,this._textureCoordinate=null,this._position=e,this._normal=t,this._color=n,this._textureCoordinate=i}r(e,"laya.d3.graphics.VertexPositionNormalColorTexture");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"textureCoordinate",function(){return this._textureCoordinate}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"color",function(){return this._color}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(48,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector4","COLOR"),new pe(40,"vector2","UV")])}]),e}(),Re=function(){function e(e,t,n,i,r){this._position=null,this._normal=null,this._color=null,this._textureCoordinate0=null,this._textureCoordinate1=null,this._position=e,this._normal=t,this._color=n,this._textureCoordinate0=i,this._textureCoordinate1=r}r(e,"laya.d3.graphics.VertexPositionNormalColorTexture0Texture1");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"color",function(){return this._color}),a(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(56,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector4","COLOR"),new pe(40,"vector2","UV"),new pe(48,"vector2","UV1")])}]),e}(),Ae=function(){function e(e,t,n,i,r,a,s){this._position=null,this._normal=null,this._color=null,this._textureCoordinate0=null,this._textureCoordinate1=null,this._blendIndex=null,this._blendWeight=null,this._position=e,this._normal=t,this._color=n,this._textureCoordinate0=i,this._textureCoordinate1=r,this._blendIndex=a,this._blendWeight=s}r(e,"laya.d3.graphics.VertexPositionNormalColorTexture0Texture1Skin");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"blendWeight",function(){return this._blendWeight}),a(0,t,"color",function(){return this._color}),a(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),a(0,t,"blendIndex",function(){return this._blendIndex}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(88,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector4","COLOR"),new pe(40,"vector2","UV"),new pe(48,"vector2","UV1"),new pe(56,"vector4","BLENDWEIGHT"),new pe(72,"vector4","BLENDINDICES")])}]),e}(),Ie=function(){function e(){this._position=null,this._normal=null,this._color=null,this._textureCoordinate0=null,this._textureCoordinate1=null,this._blendIndex=null,this._blendWeight=null,this._tangent=null}r(e,"laya.d3.graphics.VertexPositionNormalColorTexture0Texture1SkinTangent");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),t.VertexPositionNormalColorTexture0SkinTangent=function(e,t,n,i,r,a,s,o){this._position=e,this._normal=t,this._color=n,this._textureCoordinate0=i,this._textureCoordinate1=r,this._tangent=a,this._blendIndex=s,this._blendWeight=o},a(0,t,"tangent",function(){return this._tangent}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"blendWeight",function(){return this._blendWeight}),a(0,t,"color",function(){return this._color}),a(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),a(0,t,"blendIndex",function(){return this._blendIndex}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(100,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector4","COLOR"),new pe(40,"vector2","UV"),new pe(48,"vector2","UV1"),new pe(56,"vector4","BLENDWEIGHT"),new pe(72,"vector4","BLENDINDICES"),new pe(88,"vector3","TANGENT0")])}]),e}(),Ce=function(){function e(){this._position=null,this._normal=null,this._color=null,this._textureCoordinate0=null,this._textureCoordinate1=null,this._tangent=null}r(e,"laya.d3.graphics.VertexPositionNormalColorTexture0Texture1Tangent");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),t.VertexPositionNormalColorTexture0Tangent=function(e,t,n,i,r,a){this._position=e,this._normal=t,this._color=n,this._textureCoordinate0=i,this._textureCoordinate1=r,this._tangent=a},a(0,t,"tangent",function(){return this._tangent}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"color",function(){return this._color}),a(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(68,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector4","COLOR"),new pe(40,"vector2","UV"),new pe(48,"vector2","UV1"),new pe(56,"vector3","TANGENT0")])}]),e}(),Ve=function(){function e(e,t,n,i,r,a){this._position=null,this._normal=null,this._color=null,this._textureCoordinate=null,this._blendIndex=null,this._blendWeight=null,this._position=e,this._normal=t,this._color=n,this._textureCoordinate=i,this._blendIndex=r,this._blendWeight=a}r(e,"laya.d3.graphics.VertexPositionNormalColorTextureSkin");
|
||
var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"textureCoordinate",function(){return this._textureCoordinate}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"blendWeight",function(){return this._blendWeight}),a(0,t,"color",function(){return this._color}),a(0,t,"blendIndex",function(){return this._blendIndex}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(80,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector4","COLOR"),new pe(40,"vector2","UV"),new pe(48,"vector4","BLENDWEIGHT"),new pe(64,"vector4","BLENDINDICES")])}]),e}(),De=function(){function e(e,t,n,i,r,a,s){this._position=null,this._normal=null,this._color=null,this._textureCoordinate=null,this._blendIndex=null,this._blendWeight=null,this._tangent=null,this._position=e,this._normal=t,this._color=n,this._textureCoordinate=i,this._tangent=r,this._blendIndex=a,this._blendWeight=s}r(e,"laya.d3.graphics.VertexPositionNormalColorTextureSkinTangent");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"tangent",function(){return this._tangent}),a(0,t,"textureCoordinate",function(){return this._textureCoordinate}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"blendWeight",function(){return this._blendWeight}),a(0,t,"color",function(){return this._color}),a(0,t,"blendIndex",function(){return this._blendIndex}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(92,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector4","COLOR"),new pe(40,"vector2","UV"),new pe(48,"vector4","BLENDWEIGHT"),new pe(64,"vector4","BLENDINDICES"),new pe(80,"vector3","TANGENT0")])}]),e}(),Le=function(){function e(e,t,n,i,r){this._position=null,this._normal=null,this._color=null,this._textureCoordinate=null,this._tangent=null,this._position=e,this._normal=t,this._color=n,this._textureCoordinate=i,this._tangent=r}r(e,"laya.d3.graphics.VertexPositionNormalColorTextureTangent");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"tangent",function(){return this._tangent}),a(0,t,"textureCoordinate",function(){return this._textureCoordinate}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"color",function(){return this._color}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(60,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector4","COLOR"),new pe(40,"vector2","UV"),new pe(48,"vector3","TANGENT0")])}]),e}(),Oe=function(){function e(e,t,n){this._position=null,this._normal=null,this._textureCoordinate=null,this._position=e,this._normal=t,this._textureCoordinate=n}r(e,"laya.d3.graphics.VertexPositionNormalTexture");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"textureCoordinate",function(){return this._textureCoordinate}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(32,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector2","UV")])}]),e}(),be=function(){function e(e,t,n,i){this._position=null,this._normal=null,this._textureCoordinate0=null,this._textureCoordinate1=null,this._position=e,this._normal=t,this._textureCoordinate0=n,this._textureCoordinate1=i}r(e,"laya.d3.graphics.VertexPositionNormalTexture0Texture1");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(40,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector2","UV"),new pe(32,"vector2","UV1")])}]),e}(),Pe=function(){function e(e,t,n,i,r,a){this._position=null,this._normal=null,this._textureCoordinate0=null,this._textureCoordinate1=null,this._blendIndex=null,this._blendWeight=null,this._position=e,this._normal=t,this._textureCoordinate0=n,this._textureCoordinate1=i,this._blendIndex=r,this._blendWeight=a}r(e,"laya.d3.graphics.VertexPositionNormalTexture0Texture1Skin");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),a(0,t,"blendIndex",function(){return this._blendIndex}),a(0,t,"blendWeight",function(){return this._blendWeight}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(72,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector2","UV"),new pe(32,"vector2","UV1"),new pe(40,"vector4","BLENDWEIGHT"),new pe(56,"vector4","BLENDINDICES")])}]),e}(),we=function(){function e(){this._position=null,this._normal=null,this._textureCoordinate0=null,this._textureCoordinate1=null,this._blendIndex=null,this._blendWeight=null,this._tangent=null}r(e,"laya.d3.graphics.VertexPositionNormalTexture0Texture1SkinTangent");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),t.VertexPositionNormalTexture0SkinTangent=function(e,t,n,i,r,a,s){this._position=e,this._normal=t,this._textureCoordinate0=n,this._textureCoordinate1=i,this._tangent=r,this._blendIndex=a,this._blendWeight=s},a(0,t,"tangent",function(){return this._tangent}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),a(0,t,"blendIndex",function(){return this._blendIndex}),a(0,t,"blendWeight",function(){return this._blendWeight}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(84,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector2","UV"),new pe(32,"vector2","UV1"),new pe(40,"vector4","BLENDWEIGHT"),new pe(56,"vector4","BLENDINDICES"),new pe(72,"vector3","TANGENT0")])}]),e}(),Ne=function(){function e(){this._position=null,this._normal=null,this._textureCoordinate0=null,this._textureCoordinate1=null,this._tangent=null}r(e,"laya.d3.graphics.VertexPositionNormalTexture0Texture1Tangent");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),t.VertexPositionNormalTexture0Tangent=function(e,t,n,i,r){this._position=e,this._normal=t,this._textureCoordinate0=n,this._textureCoordinate1=i,this._tangent=r},a(0,t,"tangent",function(){return this._tangent}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(52,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector2","UV"),new pe(32,"vector2","UV1"),new pe(40,"vector3","TANGENT0")])}]),e}(),Be=function(){function e(e,t,n,i,r){this._position=null,this._normal=null,this._textureCoordinate=null,this._blendIndex=null,this._blendWeight=null,this._position=e,this._normal=t,this._textureCoordinate=n,this._blendIndex=i,this._blendWeight=r}r(e,"laya.d3.graphics.VertexPositionNormalTextureSkin");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"textureCoordinate",function(){return this._textureCoordinate}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"blendIndex",function(){return this._blendIndex}),a(0,t,"blendWeight",function(){return this._blendWeight}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(64,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector2","UV"),new pe(32,"vector4","BLENDWEIGHT"),new pe(48,"vector4","BLENDINDICES")])}]),e}(),Fe=function(){function e(e,t,n,i,r,a){this._position=null,this._normal=null,this._textureCoordinate=null,this._blendIndex=null,this._blendWeight=null,this._tangent=null,this._position=e,this._normal=t,this._textureCoordinate=n,this._tangent=i,this._blendIndex=r,this._blendWeight=a}r(e,"laya.d3.graphics.VertexPositionNormalTextureSkinTangent");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"tangent",function(){return this._tangent}),a(0,t,"textureCoordinate",function(){return this._textureCoordinate}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"blendIndex",function(){return this._blendIndex}),a(0,t,"blendWeight",function(){return this._blendWeight}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(76,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector2","UV"),new pe(32,"vector4","BLENDWEIGHT"),new pe(48,"vector4","BLENDINDICES"),new pe(64,"vector3","TANGENT0")])}]),e}(),Ue=function(){function e(e,t,n,i){this._position=null,this._normal=null,this._textureCoordinate=null,this._tangent=null,this._position=e,this._normal=t,this._textureCoordinate=n,this._tangent=i}r(e,"laya.d3.graphics.VertexPositionNormalTextureTangent");var t=e.prototype;return n.imps(t,{"laya.d3.graphics.IVertex":!0}),a(0,t,"tangent",function(){return this._tangent}),a(0,t,"textureCoordinate",function(){return this._textureCoordinate}),a(0,t,"normal",function(){return this._normal}),a(0,t,"position",function(){return this._position}),a(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),a(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),i(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new fe(44,[new pe(0,"vector3","POSITION"),new pe(12,"vector3","NORMAL"),new pe(24,"vector2","UV"),new pe(32,"vector3","TANGENT0")])}]),e}(),Ge=function(){function e(e,t,n,i){this._version=null,this._strings=["BLOCK","DATA","STRINGS"],this._materials=null,this._materialMap=null,this._fileData=null,this._readData=null,this._mesh=null,this._BLOCK={count:0},this._DATA={offset:0,size:0},this._STRINGS={offset:0,size:0},this._shaderAttributes=null,this._mesh=t,this._materials=n,this._materialMap=i,this._onLoaded(e)}r(e,"laya.d3.loaders.LoadModel");var t=e.prototype;return t._onLoaded=function(e){this._fileData=e,this._readData=new c(this._fileData),this._readData.pos=0,this._version=this._readData.readUTFString(),this.READ_BLOCK();for(var t=0;t<this._BLOCK.count;t++){var n=this._readData.getUint16(),i=this._strings[n],r=this["READ_"+i];if(null==r)throw new Error("model file err,no this function:"+n+" "+i);if(!r.call(this))break}return this._mesh},t.onError=function(){},t._readString=function(){return this._strings[this._readData.getUint16()]},t.READ_BLOCK=function(){this._readData.getUint16();return this._BLOCK.count=this._readData.getUint16(),!0},t.READ_DATA=function(){return this._DATA.offset=this._readData.getUint32(),this._DATA.size=this._readData.getUint32(),!0},t.READ_STRINGS=function(){this._STRINGS.offset=this._readData.getUint16(),this._STRINGS.size=this._readData.getUint16();var e=this._readData.pos;this._readData.pos=this._STRINGS.offset+this._DATA.offset;for(var t=0;t<this._STRINGS.size;t++)this._strings[t]=this._readData.readUTFString();return this._readData.pos=e,!0},t.READ_MATERIAL=function(){var e=this._readData.getUint16(),t=(this._readString(),this._readString());return"null"!==t?this._materials[e]=g.getRes(this._materialMap[t]):this._materials[e]=new gt,!0},t.READ_MESH=function(){this._readString();switch(this._version){case"LAYAMODEL:01":console.log("Warning: The (.lm) file is converted by old fbxTools,please reConverted it use lastest fbxTools version,later we will remove the support of old version (.lm) support.");break;case"LAYASKINANI:01":var e=this._readData.__getBuffer(),t=0,n=0,i=this._readData.getUint32(),r=this._readData.getUint32(),a=new Float32Array(e.slice(i+this._DATA.offset,i+this._DATA.offset+r));for(this.mesh._bindPoses=[],t=0,n=a.length;n>t;t+=16){var s=new je(a[t+0],a[t+1],a[t+2],a[t+3],a[t+4],a[t+5],a[t+6],a[t+7],a[t+8],a[t+9],a[t+10],a[t+11],a[t+12],a[t+13],a[t+14],a[t+15]);this.mesh._bindPoses.push(s)}var o=this._readData.getUint32(),l=this._readData.getUint32(),h=new Float32Array(e.slice(o+this._DATA.offset,o+this._DATA.offset+l));for(this.mesh._inverseBindPoses=[],t=0,n=h.length;n>t;t+=16){var u=new je(h[t+0],h[t+1],h[t+2],h[t+3],h[t+4],h[t+5],h[t+6],h[t+7],h[t+8],h[t+9],h[t+10],h[t+11],h[t+12],h[t+13],h[t+14],h[t+15]);this.mesh._inverseBindPoses.push(u)}break;default:throw new Error("LoadModel:unknown version.")}return!0},t.READ_SUBMESH=function(){var t=(this._readString(),this._readData.getUint8(),this._readString());this._shaderAttributes=t.match(e._attrReg);var n=this._readData.getUint32(),i=this._readData.getUint32(),r=(this._readData.getUint32(),this._readData.getUint32(),this._readData.getUint32()),a=this._readData.getUint32(),s=this._readData.getUint32(),o=this._readData.getUint32(),l=this._readData.__getBuffer(),h=new et,u=this._getVertexDeclaration(),c=Bt.create(u,a/u.vertexStride,35044,!0),_=r+this._DATA.offset,d=l.slice(_,_+a);c.setData(new Float32Array(d)),h._vertexBuffer=c;for(var m=c.vertexDeclaration.getVertexElements(),f=0;f<m.length;f++)h._bufferUsage[m[f].elementUsage]=c;var p=Nt.create("ushort",i/2,35044,!0),v=n+this._DATA.offset,g=l.slice(v,v+i);p.setData(new Uint16Array(g)),h._indexBuffer=p;var T=l.slice(s+this._DATA.offset,s+this._DATA.offset+o);return h._boneIndices=new Uint8Array(T),this._mesh._add(h),!0},t.READ_DATAAREA=function(){return!1},t._getVertexDeclaration=function(){for(var e=!1,t=!1,n=!1,i=!1,r=!1,a=!1,s=!1,o=!1,l=0;l<this._shaderAttributes.length;l+=8)switch(this._shaderAttributes[l]){case"POSITION":e=!0;break;case"NORMAL":t=!0;break;case"COLOR":n=!0;break;case"UV":i=!0;break;case"UV1":r=!0;break;case"BLENDWEIGHT":s=!0;break;case"BLENDINDICES":o=!0;break;case"TANGENT":a=!0}var h;return e&&t&&n&&i&&r&&s&&o&&a?h=Ie.vertexDeclaration:e&&t&&n&&i&&r&&s&&o?h=Ae.vertexDeclaration:e&&t&&i&&r&&s&&o&&a?h=we.vertexDeclaration:e&&t&&i&&r&&s&&o?h=Pe.vertexDeclaration:e&&t&&n&&i&&s&&o&&a?h=De.vertexDeclaration:e&&t&&n&&i&&s&&o?h=Ve.vertexDeclaration:e&&t&&i&&s&&o&&a?h=Fe.vertexDeclaration:e&&t&&i&&s&&o?h=Be.vertexDeclaration:e&&t&&n&&s&&o&&a?h=Ee.vertexDeclaration:e&&t&&n&&s&&o?h=Me.vertexDeclaration:e&&t&&n&&i&&r&&a?h=Ce.vertexDeclaration:e&&t&&n&&i&&r?h=Re.vertexDeclaration:e&&t&&i&&r&&a?h=Ne.vertexDeclaration:e&&t&&i&&r?h=be.vertexDeclaration:e&&t&&n&&i&&a?h=Le.vertexDeclaration:e&&t&&n&&i?h=Se.vertexDeclaration:e&&t&&i&&a?h=Ue.vertexDeclaration:e&&t&&i?h=Oe.vertexDeclaration:e&&t&&n&&a?h=ye.vertexDeclaration:e&&t&&n&&(h=xe.vertexDeclaration),h},a(0,t,"mesh",function(){return this._mesh}),e._attrReg=new RegExp("(\\w+)|([:,;])","g"),e}(),ze=function(){function e(e,t){this.min=null,this.max=null,this.min=e,this.max=t}r(e,"laya.d3.math.BoundBox");var t=e.prototype;return t.getCorners=function(e){e.length=8;var t=this.min.elements,n=this.max.elements,i=t[0],r=t[1],a=t[2],s=n[0],o=n[1],l=n[2];e[0]=new Qe(i,o,l),e[1]=new Qe(s,o,l),e[2]=new Qe(s,r,l),e[3]=new Qe(i,r,l),e[4]=new Qe(i,o,a),e[5]=new Qe(s,o,a),e[6]=new Qe(s,r,a),e[7]=new Qe(i,r,a)},t.toDefault=function(){this.min.toDefault(),this.max.toDefault()},e.createfromPoints=function(e,t){if(null==e)throw new Error("points");for(var n=new Qe(Number.MAX_VALUE),i=new Qe(-Number.MAX_VALUE),r=0;r<e.length;++r)Qe.min(n,e[r],n),Qe.max(i,e[r],i);t.min=n,t.max=i},e}(),He=function(){function e(t){this._matrix=null,this._near=null,this._far=null,this._left=null,this._right=null,this._top=null,this._bottom=null,this._matrix=t,this._near=new We(new Qe),this._far=new We(new Qe),this._left=new We(new Qe),this._right=new We(new Qe),this._top=new We(new Qe),this._bottom=new We(new Qe),e._getPlanesFromMatrix(this._matrix,this._near,this._far,this._left,this._right,this._top,this._bottom)}r(e,"laya.d3.math.BoundFrustum");var t=e.prototype;return t.equalsBoundFrustum=function(e){return this._matrix.equalsOtherMatrix(e.matrix)},t.equalsObj=function(e){if(e instanceof laya.d3.math.BoundFrustum){var t=e;return this.equalsBoundFrustum(t)}return!1},t.getPlane=function(e){switch(e){case 0:return this._near;case 1:return this._far;case 2:return this._left;case 3:return this._right;case 4:return this._top;case 5:return this._bottom;default:return null}},t.getCorners=function(t){t[0]=e.get3PlaneInterPoint(this._near,this._bottom,this._right),t[1]=e.get3PlaneInterPoint(this._near,this._top,this._right),t[2]=e.get3PlaneInterPoint(this._near,this._top,this._left),t[3]=e.get3PlaneInterPoint(this._near,this._bottom,this._left),t[4]=e.get3PlaneInterPoint(this._far,this._bottom,this._right),t[5]=e.get3PlaneInterPoint(this._far,this._top,this._right),t[6]=e.get3PlaneInterPoint(this._far,this._top,this._left),t[7]=e.get3PlaneInterPoint(this._far,this._bottom,this._left)},t.ContainsPoint=function(e){for(var t=We.PlaneIntersectionType_Front,n=We.PlaneIntersectionType_Front,i=0;6>i;i++){switch(i){case 0:n=Xe.intersectsPlaneAndPoint(this._near,e);break;case 1:n=Xe.intersectsPlaneAndPoint(this._far,e);break;case 2:n=Xe.intersectsPlaneAndPoint(this._left,e);break;case 3:n=Xe.intersectsPlaneAndPoint(this._right,e);break;case 4:n=Xe.intersectsPlaneAndPoint(this._top,e);break;case 5:n=Xe.intersectsPlaneAndPoint(this._bottom,e)}switch(n){case We.PlaneIntersectionType_Back:return 0;case We.PlaneIntersectionType_Intersecting:t=We.PlaneIntersectionType_Intersecting}}switch(t){case We.PlaneIntersectionType_Intersecting:return 2;default:return 1}},t.ContainsBoundBox=function(t){for(var n,i=1,r=0;6>r;r++){if(n=this.getPlane(r),this._getBoxToPlanePVertexNVertex(t,n.normal,e._tempV30,e._tempV31),Xe.intersectsPlaneAndPoint(n,e._tempV30)==We.PlaneIntersectionType_Back)return 0;Xe.intersectsPlaneAndPoint(n,e._tempV31)==We.PlaneIntersectionType_Back&&(i=2)}return i},t.ContainsBoundSphere=function(e){for(var t=We.PlaneIntersectionType_Front,n=We.PlaneIntersectionType_Front,i=0;6>i;i++){switch(i){case 0:n=Xe.intersectsPlaneAndSphere(this._near,e);break;case 1:n=Xe.intersectsPlaneAndSphere(this._far,e);break;case 2:n=Xe.intersectsPlaneAndSphere(this._left,e);break;case 3:n=Xe.intersectsPlaneAndSphere(this._right,e);break;case 4:n=Xe.intersectsPlaneAndSphere(this._top,e);break;case 5:n=Xe.intersectsPlaneAndSphere(this._bottom,e)}switch(n){case We.PlaneIntersectionType_Back:return 0;case We.PlaneIntersectionType_Intersecting:t=We.PlaneIntersectionType_Intersecting}}switch(t){case We.PlaneIntersectionType_Intersecting:return 2;default:return 1}},t._getBoxToPlanePVertexNVertex=function(e,t,n,i){var r=e.min,a=r.elements,s=e.max,o=s.elements,l=t.elements,h=l[0],u=l[1],c=l[2];n=r;var _=n.elements;h>=0&&(_[0]=o[0]),u>=0&&(_[1]=o[1]),c>=0&&(_[2]=o[2]),i=s;var d=i.elements;h>=0&&(d[0]=a[0]),u>=0&&(d[1]=a[1]),c>=0&&(d[2]=a[2])},a(0,t,"top",function(){return this._top}),a(0,t,"matrix",function(){return this._matrix},function(t){this._matrix=t,e._getPlanesFromMatrix(this._matrix,this._near,this._far,this._left,this._right,this._top,this._bottom)}),a(0,t,"near",function(){return this._near}),a(0,t,"far",function(){return this._far}),a(0,t,"left",function(){return this._left}),a(0,t,"right",function(){return this._right}),a(0,t,"bottom",function(){return this._bottom}),e._getPlanesFromMatrix=function(e,t,n,i,r,a,s){var o=e.elements,l=o[0],h=o[1],u=o[2],c=o[3],_=o[4],d=o[5],m=o[6],f=o[7],p=o[8],v=o[9],g=o[10],T=o[11],x=o[12],M=o[13],E=o[14],y=o[15],S=t.normal.elements;S[0]=u,S[1]=m,S[2]=g,t.distance=E,t.normalize();var R=n.normal.elements;R[0]=c-u,R[1]=f-m,R[2]=T-g,n.distance=y-E,n.normalize();var A=i.normal.elements;A[0]=c+l,A[1]=f+_,A[2]=T+p,i.distance=y+x,i.normalize();var I=r.normal.elements;I[0]=c-l,I[1]=f-_,I[2]=T-p,r.distance=y-x,r.normalize();var C=a.normal.elements;C[0]=c-h,C[1]=f-d,C[2]=T-v,a.distance=y-M,a.normalize();var V=s.normal.elements;V[0]=c+h,V[1]=f+d,V[2]=T+v,s.distance=y+M,s.normalize()},e.get3PlaneInterPoint=function(t,n,i){var r=t.normal,a=n.normal,s=i.normal;Qe.cross(a,s,e._tempV30),Qe.cross(s,r,e._tempV31),Qe.cross(r,a,e._tempV32);var o=Qe.dot(r,e._tempV30),l=Qe.dot(a,e._tempV31),h=Qe.dot(s,e._tempV32);Qe.scale(e._tempV30,-t.distance/o,e._tempV33),Qe.scale(e._tempV31,-n.distance/l,e._tempV34),Qe.scale(e._tempV32,-i.distance/h,e._tempV35),Qe.add(e._tempV33,e._tempV34,e._tempV36),Qe.add(e._tempV35,e._tempV36,e._tempV37);var u=e._tempV37;return u},i(e,["_tempV30",function(){return this._tempV30=new Qe},"_tempV31",function(){return this._tempV31=new Qe},"_tempV32",function(){return this._tempV32=new Qe},"_tempV33",function(){return this._tempV33=new Qe},"_tempV34",function(){return this._tempV34=new Qe},"_tempV35",function(){return this._tempV35=new Qe},"_tempV36",function(){return this._tempV36=new Qe},"_tempV37",function(){return this._tempV37=new Qe}]),e}(),ke=function(){function e(e,t){this.center=null,this.radius=NaN,this.center=e,this.radius=t}r(e,"laya.d3.math.BoundSphere");var t=e.prototype;return t.toDefault=function(){this.center.toDefault(),this.radius=0},e.createFromSubPoints=function(t,n,i,r){if(null==t)throw new Error("points");if(0>n||n>=t.length)throw new Error("start"+n+"Must be in the range [0, "+(t.length-1)+"]");if(0>i||n+i>t.length)throw new Error("count"+i+"Must be in the range <= "+t.length+"}");var a=n+i,s=e._tempVector3;s.elements[0]=0,s.elements[1]=0,s.elements[2]=0;for(var o=n;a>o;++o)Qe.add(t[o],s,s);var l=r.center;Qe.scale(s,1/i,l);var h=0;for(o=n;a>o;++o){var u=Qe.distanceSquared(l,t[o]);u>h&&(h=u)}r.radius=Math.sqrt(h)},e.createfromPoints=function(t,n){if(null==t)throw new Error("points");e.createFromSubPoints(t,0,t.length,n)},i(e,["_tempVector3",function(){return this._tempVector3=new Qe}]),e}(),Xe=function(){function e(){}return r(e,"laya.d3.math.Collision"),e.distancePlaneToPoint=function(e,t){var n=Qe.dot(e.normal,t);return n-e.distance},e.distanceBoxToPoint=function(e,t){var n=e.min.elements,i=n[0],r=n[1],a=n[2],s=e.max.elements,o=s[0],l=s[1],h=s[2],u=t.elements,c=u[0],_=u[1],d=u[2],m=0;return i>c&&(m+=(i-c)*(i-c)),c>o&&(m+=(o-c)*(o-c)),r>_&&(m+=(r-_)*(r-_)),_>l&&(m+=(l-_)*(l-_)),a>d&&(m+=(a-d)*(a-d)),d>h&&(m+=(h-d)*(h-d)),Math.sqrt(m)},e.distanceBoxToBox=function(e,t){var n=e.min.elements,i=n[0],r=n[1],a=n[2],s=e.max.elements,o=s[0],l=s[1],h=s[2],u=t.min.elements,c=u[0],_=u[1],d=u[2],m=t.max.elements,f=m[0],p=m[1],v=m[2],g=0,T=NaN;return i>f?(T=i-f,g+=T*T):c>o&&(T=c-o,g+=T*T),r>p?(T=r-p,g+=T*T):_>l&&(T=_-l,g+=T*T),a>v?(T=a-v,g+=T*T):d>h&&(T=d-h,g+=T*T),Math.sqrt(g)},e.distanceSphereToPoint=function(e,t){var n=Math.sqrt(Qe.distanceSquared(e.center,t));return n-=e.radius,Math.max(n,0)},e.distanceSphereToSphere=function(e,t){var n=Math.sqrt(Qe.distanceSquared(e.center,t.center));return n-=e.radius+t.radius,Math.max(n,0)},e.intersectsRayAndTriangleRD=function(t,n,i,r,a){var s=t.origin,o=s.elements,l=o[0],h=o[1],u=o[2],c=t.direction,_=c.elements,d=_[0],m=_[1],f=_[2],p=n.elements,v=p[0],g=p[1],T=p[2],x=i.elements,M=x[0],E=x[1],y=x[2],S=r.elements,R=S[0],A=S[1],I=S[2],C=e._tempV30.elements,V=C[0],D=C[1],L=C[2];V=M-v,D=E-g,L=y-T;var O=e._tempV31.elements,b=O[0],P=O[1],w=O[2];b=R-v,P=A-g,w=I-T;var N=e._tempV32.elements,B=N[0],F=N[1],U=N[2];B=m*w-f*P,F=f*b-d*w,U=d*P-m*b;var G=V*B+D*F+L*U;if(Ye.isZero(G))return a=0,!1;var z=1/G,H=e._tempV33.elements,k=H[0],X=H[1],Y=H[2];k=l-v,X=h-g,Y=u-T;var j=k*B+X*F+Y*U;if(j*=z,0>j||j>1)return a=0,!1;var W=e._tempV34.elements,Z=W[0],q=W[1],K=W[2];Z=X*L-Y*D,q=Y*V-k*L,K=k*D-X*V;var Q=d*Z+m*q+f*K;if(Q*=z,0>Q||j+Q>1)return a=0,!1;var $=b*Z+P*q+w*K;return $*=z,0>$?(a=0,!1):(a=$,!0)},e.intersectsRayAndTriangleRP=function(t,n,i,r,a){var s=NaN;return e.intersectsRayAndTriangleRD(t,n,i,r,s)?(Qe.scale(t.direction,s,e._tempV30),Qe.add(t.origin,e._tempV30,a),!0):(a=Qe.ZERO,!1)},e.intersectsRayAndPoint=function(t,n){Qe.subtract(t.origin,n,e._tempV30);var i=Qe.dot(e._tempV30,t.direction),r=Qe.dot(e._tempV30,e._tempV30)-Ye.zeroTolerance;if(r>0&&i>0)return!1;var a=i*i-r;return!(0>a)},e.intersectsRayAndRay=function(t,n,i){var r=t.origin,a=r.elements,s=a[0],o=a[1],l=a[2],h=t.direction,u=h.elements,c=u[0],_=u[1],d=u[2],m=n.origin,f=m.elements,p=f[0],v=f[1],g=f[2],T=n.direction,x=T.elements,M=x[0],E=x[1],y=x[2];Qe.cross(h,T,e._tempV30);var S=e._tempV30.elements,R=Qe.scalarLength(e._tempV30);if(Ye.isZero(R)&&Ye.nearEqual(p,s)&&Ye.nearEqual(v,o)&&Ye.nearEqual(g,l))return i=Qe.ZERO,!0;R*=R;var A=p-s,I=v-o,C=g-l,V=M,D=E,L=y,O=S[0],b=S[1],P=S[2],w=A*D*P+I*L*O+C*V*b-A*L*b-I*V*P-C*D*O;V=c,D=_,L=d;var N=w/R;Qe.scale(h,N,e._tempV30),Qe.scale(T,N,e._tempV31),Qe.add(r,e._tempV30,e._tempV32),Qe.add(m,e._tempV31,e._tempV33);var B=e._tempV32.elements,F=e._tempV33.elements;return Ye.nearEqual(F[0],B[0])&&Ye.nearEqual(F[1],B[1])&&Ye.nearEqual(F[2],B[2])?(i=e._tempV32,!0):(i=Qe.ZERO,!1)},e.intersectsPlaneAndTriangle=function(t,n,i,r){var a=e.intersectsPlaneAndPoint(t,n),s=e.intersectsPlaneAndPoint(t,i),o=e.intersectsPlaneAndPoint(t,r);return a==We.PlaneIntersectionType_Front&&s==We.PlaneIntersectionType_Front&&o==We.PlaneIntersectionType_Front?We.PlaneIntersectionType_Front:a==We.PlaneIntersectionType_Back&&s==We.PlaneIntersectionType_Back&&o==We.PlaneIntersectionType_Back?We.PlaneIntersectionType_Back:We.PlaneIntersectionType_Intersecting},e.intersectsRayAndPlaneRD=function(e,t,n){var i=t.normal,r=Qe.dot(i,e.direction);if(Ye.isZero(r))return n=0,!1;var a=Qe.dot(i,e.origin);return n=(-t.distance-a)/r,0>n?(n=0,!1):!0},e.intersectsRayAndPlaneRP=function(t,n,i){var r=NaN;return e.intersectsRayAndPlaneRD(t,n,r)?(Qe.scale(t.direction,r,e._tempV30),Qe.add(t.origin,e._tempV30,e._tempV31),i=e._tempV31,!0):(i=Qe.ZERO,!1)},e.intersectsRayAndBoxRD=function(e,t,n){var i=e.origin.elements,r=i[0],a=i[1],s=i[2],o=e.direction.elements,l=o[0],h=o[1],u=o[2],c=t.min.elements,_=c[0],d=c[1],m=c[2],f=t.max.elements,p=f[0],v=f[1],g=f[2];n=0;var T=Ye.MaxValue;if(Ye.isZero(l)){if(_>r||r>p)return n=0,!1}else{var x=1/l,M=(_-r)*x,E=(p-r)*x;if(M>E){var y=M;M=E,E=y}if(n=Math.max(M,n),T=Math.min(E,T),n>T)return n=0,!1}if(Ye.isZero(h)){if(d>a||a>v)return n=0,!1}else{var S=1/h,R=(d-a)*S,A=(v-a)*S;if(R>A){var I=R;R=A,A=I}if(n=Math.max(R,n),T=Math.min(A,T),n>T)return n=0,!1}if(Ye.isZero(u)){if(m>s||s>g)return n=0,!1}else{var C=1/u,V=(m-s)*C,D=(g-s)*C;if(V>D){var L=V;V=D,D=L}if(n=Math.max(V,n),T=Math.min(D,T),n>T)return n=0,!1}return!0},e.intersectsRayAndBoxRP=function(t,n,i){var r=NaN;return e.intersectsRayAndBoxRD(t,n,r)?(Qe.scale(t.direction,r,e._tempV30),Qe.add(t.origin,e._tempV30,e._tempV31),i=e._tempV31,!0):(i=Qe.ZERO,!1)},e.intersectsRayAndSphereRD=function(t,n,i){var r=n.radius;Qe.subtract(t.origin,n.center,e._tempV30);var a=Qe.dot(e._tempV30,t.direction),s=Qe.dot(e._tempV30,e._tempV30)-r*r;if(s>0&&a>0)return i=0,!1;var o=a*a-s;return 0>o?(i=0,!1):(i=-a-Math.sqrt(o),0>i&&(i=0),!0)},e.intersectsRayAndSphereRP=function(t,n,i){var r=NaN;return e.intersectsRayAndSphereRD(t,n,r)?(Qe.scale(t.direction,r,e._tempV30),Qe.add(t.origin,e._tempV30,e._tempV31),i=e._tempV31,!0):(i=Qe.ZERO,!1)},e.intersectsSphereAndTriangle=function(t,n,i,r){var a=t.center,s=t.radius;e.closestPointPointTriangle(a,n,i,r,e._tempV30),Qe.subtract(e._tempV30,a,e._tempV31);var o=Qe.dot(e._tempV31,e._tempV31);return s*s>=o},e.intersectsPlaneAndPoint=function(e,t){var n=Qe.dot(e.normal,t)+e.distance;return n>0?We.PlaneIntersectionType_Front:0>n?We.PlaneIntersectionType_Back:We.PlaneIntersectionType_Intersecting},e.intersectsPlaneAndPlane=function(t,n){Qe.cross(t.normal,n.normal,e._tempV30);var i=Qe.dot(e._tempV30,e._tempV30);return!Ye.isZero(i)},e.intersectsPlaneAndPlaneRL=function(t,n,i){var r=t.normal,a=n.normal;Qe.cross(r,a,e._tempV34);var s=Qe.dot(e._tempV34,e._tempV34);return Ye.isZero(s)?!1:(Qe.scale(a,t.distance,e._tempV30),Qe.scale(r,n.distance,e._tempV31),Qe.subtract(e._tempV30,e._tempV31,e._tempV32),Qe.cross(e._tempV32,e._tempV34,e._tempV33),Qe.normalize(e._tempV34,e._tempV34),i=new qe(e._tempV33,e._tempV34),!0)},e.intersectsPlaneAndBox=function(t,n){var i=t.distance,r=t.normal,a=r.elements,s=a[0],o=a[1],l=a[2],h=n.min.elements,u=h[0],c=h[1],_=h[2],d=n.max.elements,m=d[0],f=d[1],p=d[2];e._tempV30.elements[0]=s>0?u:m,e._tempV30.elements[1]=o>0?c:f,e._tempV30.elements[2]=l>0?_:p,e._tempV31.elements[0]=s>0?m:u,e._tempV31.elements[1]=o>0?f:c,e._tempV31.elements[2]=l>0?p:_;var v=Qe.dot(r,e._tempV30);return v+i>0?We.PlaneIntersectionType_Front:(v=Qe.dot(r,e._tempV31),0>v+i?We.PlaneIntersectionType_Back:We.PlaneIntersectionType_Intersecting)},e.intersectsPlaneAndSphere=function(e,t){var n=t.radius,i=Qe.dot(e.normal,t.center)+e.distance;return i>n?We.PlaneIntersectionType_Front:-n>i?We.PlaneIntersectionType_Back:We.PlaneIntersectionType_Intersecting},e.intersectsBoxAndBox=function(e,t){var n=e.min.elements,i=e.max.elements,r=t.min.elements,a=t.max.elements;return n[0]>a[0]||r[0]>i[0]?!1:n[1]>a[1]||r[1]>i[1]?!1:!(n[2]>a[2]||r[2]>i[2])},e.intersectsBoxAndSphere=function(t,n){var i=n.center,r=n.radius;Qe.Clamp(i,t.min,t.max,e._tempV30);var a=Qe.distanceSquared(i,e._tempV30);return r*r>=a},e.intersectsSphereAndSphere=function(e,t){var n=e.radius+t.radius;return Qe.distanceSquared(e.center,t.center)<=n*n},e.boxContainsPoint=function(e,t){var n=e.min.elements,i=e.max.elements,r=t.elements;return n[0]<=r[0]&&i[0]>=r[0]&&n[1]<=r[1]&&i[1]>=r[1]&&n[2]<=r[2]&&i[2]>=r[2]?1:0},e.boxContainsBox=function(e,t){var n=e.min.elements,i=n[0],r=n[1],a=n[2],s=e.max.elements,o=s[0],l=s[1],h=s[2],u=t.min.elements,c=u[0],_=u[1],d=u[2],m=t.max.elements,f=m[0],p=m[1],v=m[2];return c>o||i>f?0:_>l||r>p?0:d>h||a>v?0:c>=i&&c>=f&&_>=r&&l>=p&&d>=a&&h>=v?1:2},e.boxContainsSphere=function(t,n){var i=t.min,r=i.elements,a=r[0],s=r[1],o=r[2],l=t.max,h=l.elements,u=h[0],c=h[1],_=h[2],d=n.center,m=d.elements,f=m[0],p=m[1],v=m[2],g=n.radius;Qe.Clamp(d,i,l,e._tempV30);var T=Qe.distanceSquared(d,e._tempV30);return T>g*g?0:f>=a+g&&u-g>=f&&u-a>g&&p>=s+g&&c-g>=p&&c-s>g&&v>=o+g&&_-g>=v&&_-o>g?1:2},e.sphereContainsPoint=function(e,t){return Qe.distanceSquared(t,e.center)<=e.radius*e.radius?1:0},e.sphereContainsTriangle=function(t,n,i,r){var a=e.sphereContainsPoint(t,n),s=e.sphereContainsPoint(t,i),o=e.sphereContainsPoint(t,r);return 1==a&&1==s&&1==o?1:e.intersectsSphereAndTriangle(t,n,i,r)?2:0},e.sphereContainsBox=function(t,n){var i=t.center,r=i.elements,a=r[0],s=r[1],o=r[2],l=t.radius,h=n.min,u=h.elements,c=u[0],_=u[1],d=u[2],m=n.max,f=m.elements,p=f[0],v=f[1],g=f[2],T=e._tempV30.elements,x=T[0],M=T[1],E=T[2];
|
||
if(!e.intersectsBoxAndSphere(n,t))return 0;var y=l*l;return x=a-c,M=s-v,E=o-g,Qe.scalarLengthSquared(e._tempV30)>y?2:(x=a-p,M=s-v,E=o-g,Qe.scalarLengthSquared(e._tempV30)>y?2:(x=a-p,M=s-_,E=o-g,Qe.scalarLengthSquared(e._tempV30)>y?2:(x=a-c,M=s-_,E=o-g,Qe.scalarLengthSquared(e._tempV30)>y?2:(x=a-c,M=s-v,E=o-d,Qe.scalarLengthSquared(e._tempV30)>y?2:(x=a-p,M=s-v,E=o-d,Qe.scalarLengthSquared(e._tempV30)>y?2:(x=a-p,M=s-_,E=o-d,Qe.scalarLengthSquared(e._tempV30)>y?2:(x=a-c,M=s-_,E=o-d,Qe.scalarLengthSquared(e._tempV30)>y?2:1)))))))},e.sphereContainsSphere=function(e,t){var n=e.radius,i=t.radius,r=Qe.distance(e.center,t.center);return r>n+i?0:r>n-i?2:1},e.closestPointPointTriangle=function(t,n,i,r,a){Qe.subtract(i,n,e._tempV30),Qe.subtract(r,n,e._tempV31),Qe.subtract(t,n,e._tempV32),Qe.subtract(t,i,e._tempV33),Qe.subtract(t,r,e._tempV34);var s=Qe.dot(e._tempV30,e._tempV32),o=Qe.dot(e._tempV31,e._tempV32),l=Qe.dot(e._tempV30,e._tempV33),h=Qe.dot(e._tempV31,e._tempV33),u=Qe.dot(e._tempV30,e._tempV34),c=Qe.dot(e._tempV31,e._tempV34);if(0>=s&&0>=o)return void n.cloneTo(a);if(l>=0&&l>=h)return void i.cloneTo(a);var _=s*h-l*o;if(0>=_&&s>=0&&0>=l){var d=s/(s-l);return Qe.scale(e._tempV30,d,a),void Qe.add(n,a,a)}if(c>=0&&c>=u)return void r.cloneTo(a);var m=u*o-s*c;if(0>=m&&o>=0&&0>=c){var f=o/(o-c);return Qe.scale(e._tempV31,f,a),void Qe.add(n,a,a)}var p=l*c-u*h;if(0>=p&&h-l>=0&&u-c>=0){var v=(h-l)/(h-l+(u-c));return Qe.subtract(r,i,a),Qe.scale(a,v,a),void Qe.add(i,a,a)}var g=1/(p+m+_),T=m*g,x=_*g;Qe.scale(e._tempV30,T,e._tempV35),Qe.scale(e._tempV31,x,e._tempV36),Qe.add(e._tempV35,e._tempV36,a),Qe.add(n,a,a)},e.closestPointPlanePoint=function(t,n,i){var r=t.normal,a=Qe.dot(r,n)-t.distance;Qe.scale(r,a,e._tempV30),Qe.subtract(n,e._tempV30,i)},e.closestPointBoxPoint=function(t,n,i){Qe.max(n,t.min,e._tempV30),Qe.min(e._tempV30,t.max,i)},e.closestPointSpherePoint=function(e,t,n){var i=e.center;Qe.subtract(t,i,n),Qe.normalize(n,n),Qe.scale(n,e.radius,n),Qe.add(n,i,n)},e.closestPointSphereSphere=function(e,t,n){var i=e.center;Qe.subtract(t.center,i,n),Qe.normalize(n,n),Qe.scale(n,e.radius,n),Qe.add(n,i,n)},i(e,["_tempV30",function(){return this._tempV30=new Qe},"_tempV31",function(){return this._tempV31=new Qe},"_tempV32",function(){return this._tempV32=new Qe},"_tempV33",function(){return this._tempV33=new Qe},"_tempV34",function(){return this._tempV34=new Qe},"_tempV35",function(){return this._tempV35=new Qe},"_tempV36",function(){return this._tempV36=new Qe}]),e}(),Ye=(function(){function e(){}return r(e,"laya.d3.math.ContainmentType"),e.Disjoint=0,e.Contains=1,e.Intersects=2,e}(),function(){function e(){}return r(e,"laya.d3.math.MathUtils3D"),e.isZero=function(t){return Math.abs(t)<e.zeroTolerance},e.nearEqual=function(t,n){return!!e.isZero(t-n)},e.fastInvSqrt=function(t){return e.isZero(t)?t:1/Math.sqrt(t)},i(e,["zeroTolerance",function(){return this.zeroTolerance=1e-6},"MaxValue",function(){return this.MaxValue=3.40282347e38},"MinValue",function(){return this.MinValue=-3.40282347e38}]),e}()),je=(function(){function e(){var e=this.elements=new Float32Array(9);e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1}r(e,"laya.d3.math.Matrix3x3");var t=e.prototype;return t.determinant=function(){var e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],h=e[8];return t*(h*a-s*l)+n*(-h*r+s*o)+i*(l*r-a*o)},t.translate=function(e,t){var n=t.elements,i=this.elements,r=e.elements,a=i[0],s=i[1],o=i[2],l=i[3],h=i[4],u=i[5],c=i[6],_=i[7],d=i[8],m=r[0],f=r[1];n[0]=a,n[1]=s,n[2]=o,n[3]=l,n[4]=h,n[5]=u,n[6]=m*a+f*l+c,n[7]=m*s+f*h+_,n[8]=m*o+f*u+d},t.rotate=function(e,t){var n=t.elements,i=this.elements,r=i[0],a=i[1],s=i[2],o=i[3],l=i[4],h=i[5],u=i[6],c=i[7],_=i[8],d=Math.sin(e),m=Math.cos(e);n[0]=m*r+d*o,n[1]=m*a+d*l,n[2]=m*s+d*h,n[3]=m*o-d*r,n[4]=m*l-d*a,n[5]=m*h-d*s,n[6]=u,n[7]=c,n[8]=_},t.scale=function(e,t){var n=t.elements,i=this.elements,r=e.elements,a=r[0],s=r[1];n[0]=a*i[0],n[1]=a*i[1],n[2]=a*i[2],n[3]=s*i[3],n[4]=s*i[4],n[5]=s*i[5],n[6]=i[6],n[7]=i[7],n[8]=i[8]},t.invert=function(e){var t=e.elements,n=this.elements,i=n[0],r=n[1],a=n[2],s=n[3],o=n[4],l=n[5],h=n[6],u=n[7],c=n[8],_=c*o-l*u,d=-c*s+l*h,m=u*s-o*h,f=i*_+r*d+a*m;f||(e=null),f=1/f,t[0]=_*f,t[1]=(-c*r+a*u)*f,t[2]=(l*r-a*o)*f,t[3]=d*f,t[4]=(c*i-a*h)*f,t[5]=(-l*i+a*s)*f,t[6]=m*f,t[7]=(-u*i+r*h)*f,t[8]=(o*i-r*s)*f},t.transpose=function(e){var t=e.elements,n=this.elements;if(e===this){var i=n[1],r=n[2],a=n[5];t[1]=n[3],t[2]=n[6],t[3]=i,t[5]=n[7],t[6]=r,t[7]=a}else t[0]=n[0],t[1]=n[3],t[2]=n[6],t[3]=n[1],t[4]=n[4],t[5]=n[7],t[6]=n[2],t[7]=n[5],t[8]=n[8]},t.identity=function(){var e=this.elements;e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1},t.cloneTo=function(e){var t,n,i;if(n=this.elements,i=e.elements,n!==i)for(t=0;9>t;++t)i[t]=n[t]},t.copyFrom=function(e){var t,n,i;if(n=e.elements,i=this.elements,n!==i)for(t=0;9>t;++t)i[t]=n[t]},t.copyFromArray=function(e){var t,n;if(n=this.elements,e!==n)for(t=0;9>t;++t)n[t]=e[t]},e.createFromTranslation=function(e,t){var n=(t.elements,e.elements);t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=n[0],t[7]=n[1],t[8]=1},e.createFromRotation=function(e,t){var n=t.elements,i=Math.sin(e),r=Math.cos(e);n[0]=r,n[1]=i,n[2]=0,n[3]=-i,n[4]=r,n[5]=0,n[6]=0,n[7]=0,n[8]=1},e.createFromScaling=function(e,t){var n=t.elements,i=e.elements;n[0]=i[0],n[1]=0,n[2]=0,n[3]=0,n[4]=i[1],n[5]=0,n[6]=0,n[7]=0,n[8]=1},e.createFromMatrix4x4=function(e,t){t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10]},e.multiply=function(e,t,n){var i=n.elements,r=e.elements,a=t.elements,s=r[0],o=r[1],l=r[2],h=r[3],u=r[4],c=r[5],_=r[6],d=r[7],m=r[8],f=a[0],p=a[1],v=a[2],g=a[3],T=a[4],x=a[5],M=a[6],E=a[7],y=a[8];i[0]=f*s+p*h+v*_,i[1]=f*o+p*u+v*d,i[2]=f*l+p*c+v*m,i[3]=g*s+T*h+x*_,i[4]=g*o+T*u+x*d,i[5]=g*l+T*c+x*m,i[6]=M*s+E*h+y*_,i[7]=M*o+E*u+y*d,i[8]=M*l+E*c+y*m},e.DEFAULT=new e,e}(),function(){function e(e,t,n,i,r,a,s,o,l,h,u,c,_,d,m,f){void 0===e&&(e=1),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===a&&(a=1),void 0===s&&(s=0),void 0===o&&(o=0),void 0===l&&(l=0),void 0===h&&(h=0),void 0===u&&(u=1),void 0===c&&(c=0),void 0===_&&(_=0),void 0===d&&(d=0),void 0===m&&(m=0),void 0===f&&(f=1);var p=this.elements=new Float32Array(16);p[0]=e,p[1]=t,p[2]=n,p[3]=i,p[4]=r,p[5]=a,p[6]=s,p[7]=o,p[8]=l,p[9]=h,p[10]=u,p[11]=c,p[12]=_,p[13]=d,p[14]=m,p[15]=f}r(e,"laya.d3.math.Matrix4x4");var t=e.prototype;return t.equalsOtherMatrix=function(e){var t=this.elements,n=e.elements;return Ye.nearEqual(t[0],n[0])&&Ye.nearEqual(t[1],n[1])&&Ye.nearEqual(t[2],n[2])&&Ye.nearEqual(t[3],n[3])&&Ye.nearEqual(t[4],n[4])&&Ye.nearEqual(t[5],n[5])&&Ye.nearEqual(t[6],n[6])&&Ye.nearEqual(t[7],n[7])&&Ye.nearEqual(t[8],n[8])&&Ye.nearEqual(t[9],n[9])&&Ye.nearEqual(t[10],n[10])&&Ye.nearEqual(t[11],n[11])&&Ye.nearEqual(t[12],n[12])&&Ye.nearEqual(t[13],n[13])&&Ye.nearEqual(t[14],n[14])&&Ye.nearEqual(t[15],n[15])},t.decompose=function(t,n,i){var r=this.elements,a=t.elements,s=n.elements,o=i.elements;if(a[0]=r[12],a[1]=r[13],a[2]=r[14],o[0]=Math.sqrt(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]),o[1]=Math.sqrt(r[4]*r[4]+r[5]*r[5]+r[6]*r[6]),o[2]=Math.sqrt(r[8]*r[8]+r[9]*r[9]+r[10]*r[10]),Ye.isZero(o[0])||Ye.isZero(o[1])||Ye.isZero(o[2]))return s[0]=s[1]=s[2]=0,s[3]=1,!1;var l=new e,h=l.elements;return h[0]=r[0]/o[0],h[1]=r[1]/o[0],h[2]=r[2]/o[0],h[4]=r[4]/o[1],h[5]=r[5]/o[1],h[6]=r[6]/o[1],h[8]=r[8]/o[2],h[9]=r[9]/o[2],h[10]=r[10]/o[2],l[15]=1,Ze.createFromMatrix4x4(l,n),!0},t.normalize=function(){var e=this.elements,t=e[0],n=e[1],i=e[2],r=Math.sqrt(t*t+n*n+i*i);return r?void(1!=r&&(r=1/r,e[0]=t*r,e[1]=n*r,e[2]=i*r)):(e[0]=0,e[1]=0,void(e[2]=0))},t.transpose=function(){var e,t;return e=this.elements,t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this},t.invert=function(e){var t=this.elements,n=e.elements,i=t[0],r=t[1],a=t[2],s=t[3],o=t[4],l=t[5],h=t[6],u=t[7],c=t[8],_=t[9],d=t[10],m=t[11],f=t[12],p=t[13],v=t[14],g=t[15],T=i*l-r*o,x=i*h-a*o,M=i*u-s*o,E=r*h-a*l,y=r*u-s*l,S=a*u-s*h,R=c*p-_*f,A=c*v-d*f,I=c*g-m*f,C=_*v-d*p,V=_*g-m*p,D=d*g-m*v,L=T*D-x*V+M*C+E*I-y*A+S*R;0!==Math.abs(L)&&(L=1/L,n[0]=(l*D-h*V+u*C)*L,n[1]=(a*V-r*D-s*C)*L,n[2]=(p*S-v*y+g*E)*L,n[3]=(d*y-_*S-m*E)*L,n[4]=(h*I-o*D-u*A)*L,n[5]=(i*D-a*I+s*A)*L,n[6]=(v*M-f*S-g*x)*L,n[7]=(c*S-d*M+m*x)*L,n[8]=(o*V-l*I+u*R)*L,n[9]=(r*I-i*V-s*R)*L,n[10]=(f*y-p*M+g*T)*L,n[11]=(_*M-c*y-m*T)*L,n[12]=(l*A-o*C-h*R)*L,n[13]=(i*C-r*A+a*R)*L,n[14]=(p*x-f*E-v*T)*L,n[15]=(c*E-_*x+d*T)*L)},t.identity=function(){var e=this.elements;e[1]=e[2]=e[3]=e[4]=e[6]=e[7]=e[8]=e[9]=e[11]=e[12]=e[13]=e[14]=0,e[0]=e[5]=e[10]=e[15]=1},t.cloneTo=function(e){var t,n,i;if(n=this.elements,i=e.elements,n!==i)for(t=0;16>t;++t)i[t]=n[t]},t.copyFrom=function(e){var t,n,i;if(n=e.elements,i=this.elements,n!==i)for(t=0;16>t;++t)i[t]=n[t]},t.copyFromArray=function(e){var t,n;if(n=this.elements,e!==n)for(t=0;16>t;++t)n[t]=e[t]},a(0,t,"translationVector",function(){var t=this.elements,n=e._translationVector.elements;return n[0]=t[12],n[1]=t[13],n[2]=t[14],e._translationVector},function(e){var t=this.elements,n=e.elements;t[12]=n[0],t[13]=n[1],t[14]=n[2]}),e.createRotationX=function(e,t){var n=t.elements,i=Math.sin(e),r=Math.cos(e);n[1]=n[2]=n[3]=n[4]=n[7]=n[8]=n[11]=n[12]=n[13]=n[14]=0,n[0]=n[15]=1,n[5]=n[10]=r,n[6]=i,n[9]=-i},e.createRotationY=function(e,t){var n=t.elements,i=Math.sin(e),r=Math.cos(e);n[1]=n[3]=n[4]=n[6]=n[7]=n[9]=n[11]=n[12]=n[13]=n[14]=0,n[5]=n[15]=1,n[0]=n[10]=r,n[2]=-i,n[8]=i},e.createRotationZ=function(e,t){var n=t.elements,i=Math.sin(e),r=Math.cos(e);n[2]=n[3]=n[6]=n[7]=n[8]=n[9]=n[11]=n[12]=n[13]=n[14]=0,n[10]=n[15]=1,n[0]=n[5]=r,n[1]=i,n[4]=-i},e.createRotationYawPitchRoll=function(t,n,i,r){Ze.createFromYawPitchRoll(t,n,i,e._tempQuaternion),e.createRotationQuaternion(e._tempQuaternion,r)},e.createRotationQuaternion=function(e,t){var n=e.elements,i=t.elements,r=n[0],a=n[1],s=n[2],o=n[3],l=r*r,h=a*a,u=s*s,c=r*a,_=s*o,d=s*r,m=a*o,f=a*s,p=r*o;i[3]=i[7]=i[11]=i[12]=i[13]=i[14]=0,i[15]=1,i[0]=1-2*(h+u),i[1]=2*(c+_),i[2]=2*(d-m),i[4]=2*(c-_),i[5]=1-2*(u+l),i[6]=2*(f+p),i[8]=2*(d+m),i[9]=2*(f-p),i[10]=1-2*(h+l)},e.createTranslate=function(e,t){var n=e.elements,i=t.elements;i[4]=i[8]=i[1]=i[9]=i[2]=i[6]=i[3]=i[7]=i[11]=0,i[0]=i[5]=i[10]=i[15]=1,i[12]=n[0],i[13]=n[1],i[14]=n[2]},e.createScaling=function(e,t){var n=e.elements,i=t.elements;i[0]=n[0],i[5]=n[1],i[10]=n[2],i[1]=i[4]=i[8]=i[12]=i[9]=i[13]=i[2]=i[6]=i[14]=i[3]=i[7]=i[11]=0,i[15]=1},e.multiply=function(e,t,n){var i,r,a,s,o,l,h,u;if(r=n.elements,a=e.elements,s=t.elements,r===s)for(s=new Float32Array(16),i=0;16>i;++i)s[i]=r[i];for(i=0;4>i;i++)o=a[i],l=a[i+4],h=a[i+8],u=a[i+12],r[i]=o*s[0]+l*s[1]+h*s[2]+u*s[3],r[i+4]=o*s[4]+l*s[5]+h*s[6]+u*s[7],r[i+8]=o*s[8]+l*s[9]+h*s[10]+u*s[11],r[i+12]=o*s[12]+l*s[13]+h*s[14]+u*s[15]},e.createFromQuaternion=function(e,t){var n=t.elements,i=e.elements,r=i[0],a=i[1],s=i[2],o=i[3],l=r+r,h=a+a,u=s+s,c=r*l,_=a*l,d=a*h,m=s*l,f=s*h,p=s*u,v=o*l,g=o*h,T=o*u;n[0]=1-d-p,n[1]=_+T,n[2]=m-g,n[3]=0,n[4]=_-T,n[5]=1-c-p,n[6]=f+v,n[7]=0,n[8]=m+g,n[9]=f-v,n[10]=1-c-d,n[11]=0,n[12]=0,n[13]=0,n[14]=0,t[15]=1},e.createAffineTransformation=function(e,t,n,i){var r=e.elements,a=t.elements,s=n.elements,o=i.elements,l=a[0],h=a[1],u=a[2],c=a[3],_=l+l,d=h+h,m=u+u,f=l*_,p=l*d,v=l*m,g=h*d,T=h*m,x=u*m,M=c*_,E=c*d,y=c*m,S=s[0],R=s[1],A=s[2];o[0]=(1-(g+x))*S,o[1]=(p+y)*S,o[2]=(v-E)*S,o[3]=0,o[4]=(p-y)*R,o[5]=(1-(f+x))*R,o[6]=(T+M)*R,o[7]=0,o[8]=(v+E)*A,o[9]=(T-M)*A,o[10]=(1-(f+g))*A,o[11]=0,o[12]=r[0],o[13]=r[1],o[14]=r[2],o[15]=1},e.createLookAt=function(e,t,n,i){var r,a,s,o,l,h,u,c,_,d,m=e.elements,f=t.elements,p=n.elements,v=i.elements,g=m[0],T=m[1],x=m[2],M=p[0],E=p[1],y=p[2],S=f[0],R=f[1],A=f[2];return Math.abs(g-S)<Ye.zeroTolerance&&Math.abs(T-R)<Ye.zeroTolerance&&Math.abs(x-A)<Ye.zeroTolerance?void i.identity():(u=g-S,c=T-R,_=x-A,d=1/Math.sqrt(u*u+c*c+_*_),u*=d,c*=d,_*=d,r=E*_-y*c,a=y*u-M*_,s=M*c-E*u,d=Math.sqrt(r*r+a*a+s*s),d?(d=1/d,r*=d,a*=d,s*=d):r=a=s=0,o=c*s-_*a,l=_*r-u*s,h=u*a-c*r,d=Math.sqrt(o*o+l*l+h*h),d?(d=1/d,o*=d,l*=d,h*=d):o=l=h=0,v[0]=r,v[1]=o,v[2]=u,v[3]=0,v[4]=a,v[5]=l,v[6]=c,v[7]=0,v[8]=s,v[9]=h,v[10]=_,v[11]=0,v[12]=-(r*g+a*T+s*x),v[13]=-(o*g+l*T+h*x),v[14]=-(u*g+c*T+_*x),void(v[15]=1))},e.createPerspective=function(e,t,n,i,r){var a=r.elements,s=1/Math.tan(.5*e),o=i/(n-i);a[0]=s/t,a[5]=s,a[10]=o,a[11]=-1,a[14]=o*n,a[1]=a[2]=a[3]=a[4]=a[6]=a[7]=a[8]=a[9]=a[12]=a[13]=a[15]=0},e.createOrthogonal=function(e,t,n,i,r,a,s){var o=s.elements,l=1/(e-t),h=1/(n-i),u=1/(r-a);o[1]=o[2]=o[3]=o[4]=o[6]=o[7]=o[8]=o[9]=o[11]=0,o[15]=1,o[0]=-2*l,o[5]=-2*h,o[10]=2*u,o[12]=(e+t)*l,o[13]=(i+n)*h,o[14]=(a+r)*u},e.translation=function(e,t){var n=e.elements,i=t.elements;i[0]=i[5]=i[10]=i[15]=1,i[12]=n[0],i[13]=n[1],i[14]=n[2]},e._tempMatrix4x4=new e,e.DEFAULT=new e,i(e,["_tempQuaternion",function(){return this._tempQuaternion=new Ze},"_translationVector",function(){return this._translationVector=new Qe}]),e}()),We=(function(){function e(t){this.extents=null,this.transformation=null;var n=t.min,i=t.max;Qe.subtract(i,n,e._tempV30),Qe.scale(e._tempV30,.5,e._tempV30),Qe.add(n,e._tempV30,e._tempV31),Qe.subtract(i,e._tempV31,this.extents),je.translation(e._tempV31,this.transformation)}r(e,"laya.d3.math.OrientedBoundBox");var t=e.prototype;return t.getCorners=function(t){var n=this.extents.elements;t.length=8,e._tempV30.x=n[0],e._tempV31.y=n[1],e._tempV32.z=n[2],Qe.TransformNormal(e._tempV30,this.transformation,e._tempV30),Qe.TransformNormal(e._tempV31,this.transformation,e._tempV31),Qe.TransformNormal(e._tempV32,this.transformation,e._tempV32),e._tempV33=this.transformation.translationVector,Qe.add(e._tempV33,e._tempV30,e._tempV34),Qe.add(e._tempV34,e._tempV31,e._tempV34),Qe.add(e._tempV34,e._tempV32,t[0]),Qe.add(e._tempV33,e._tempV30,e._tempV34),Qe.add(e._tempV34,e._tempV31,e._tempV34),Qe.subtract(e._tempV34,e._tempV32,t[1]),Qe.subtract(e._tempV33,e._tempV30,e._tempV34),Qe.add(e._tempV34,e._tempV31,e._tempV34),Qe.subtract(e._tempV34,e._tempV32,t[2]),Qe.subtract(e._tempV33,e._tempV30,e._tempV34),Qe.add(e._tempV34,e._tempV31,e._tempV34),Qe.add(e._tempV34,e._tempV32,t[3]),Qe.add(e._tempV33,e._tempV30,e._tempV34),Qe.subtract(e._tempV34,e._tempV31,e._tempV34),Qe.add(e._tempV34,e._tempV32,t[4]),Qe.add(e._tempV33,e._tempV30,e._tempV34),Qe.subtract(e._tempV34,e._tempV31,e._tempV34),Qe.subtract(e._tempV34,e._tempV32,t[5]),Qe.subtract(e._tempV33,e._tempV30,e._tempV34),Qe.subtract(e._tempV34,e._tempV31,e._tempV34),Qe.subtract(e._tempV34,e._tempV32,t[6]),Qe.subtract(e._tempV33,e._tempV30,e._tempV34),Qe.subtract(e._tempV34,e._tempV31,e._tempV34),Qe.add(e._tempV34,e._tempV32,t[7])},t.transform=function(e){je.multiply(this.transformation,e,this.transformation)},t.scale=function(e){Qe.multiply(this.extents,e,this.extents)},t.translate=function(t){var n=this.transformation.translationVector;Qe.add(n,t,e._tempV30),this.transformation.translationVector=e._tempV30},t.Size=function(e){Qe.scale(this.extents,2,e)},t.getSize=function(t){var n=this.extents.elements;e._tempV30.x=n[0],e._tempV31.y=n[1],e._tempV32.z=n[2],Qe.TransformNormal(e._tempV30,this.transformation,e._tempV30),Qe.TransformNormal(e._tempV31,this.transformation,e._tempV31),Qe.TransformNormal(e._tempV31,this.transformation,e._tempV32);var i=t.elements;i[0]=Qe.scalarLength(e._tempV30),i[1]=Qe.scalarLength(e._tempV31),i[2]=Qe.scalarLength(e._tempV32)},t.getSizeSquared=function(t){var n=this.extents.elements;e._tempV30.x=n[0],e._tempV31.y=n[1],e._tempV32.z=n[2],Qe.TransformNormal(e._tempV30,this.transformation,e._tempV30),Qe.TransformNormal(e._tempV31,this.transformation,e._tempV31),Qe.TransformNormal(e._tempV31,this.transformation,e._tempV32);var i=t.elements;i[0]=Qe.scalarLengthSquared(e._tempV30),i[1]=Qe.scalarLengthSquared(e._tempV31),i[2]=Qe.scalarLengthSquared(e._tempV32)},t.getCenter=function(){return this.transformation.translationVector},t.containsPoint=function(t){var n=this.extents.elements,i=n[0],r=n[1],a=n[2];this.transformation.invert(e._tempM0),Qe.transformCoordinate(t,e._tempM0,e._tempV30);var s=e._tempV30.elements,o=Math.abs(s[0]),l=Math.abs(s[1]),h=Math.abs(s[2]);return Ye.nearEqual(o,i)&&Ye.nearEqual(l,r)&&Ye.nearEqual(h,a)?2:i>o&&r>l&&a>h?1:0},t.containsSphere=function(t,n){void 0===n&&(n=!1);var i=this.extents.elements,r=i[0],a=i[1],s=i[2],o=t.radius;this.transformation.invert(e._tempM0),Qe.transformCoordinate(t.center,e._tempM0,e._tempV30);var l=NaN;n?l=o:(Qe.scale(Qe.UnitX,o,e._tempV31),Qe.TransformNormal(e._tempV31,e._tempM0,e._tempV31),l=Qe.scalarLength(e._tempV31)),Qe.scale(this.extents,-1,e._tempV32),Qe.Clamp(e._tempV30,e._tempV32,this.extents,e._tempV33);var h=Qe.distanceSquared(e._tempV30,e._tempV33);if(h>l*l)return 0;var u=e._tempV30.elements,c=u[0],_=u[1],d=u[2],m=e._tempV32.elements,f=m[0],p=m[1],v=m[2];return c>=f+l&&r-l>=c&&r-f>l&&_>=p+l&&a-l>=_&&a-p>l&&d>=v+l&&s-l>=d&&s-v>l?1:2},e._getRows=function(e,t){t.length=3;var n=e.elements,i=t[0].elements;i[0]=n[0],i[1]=n[1],i[2]=n[2];var r=t[1].elements;r[0]=n[4],r[1]=n[5],r[2]=n[6];var a=t[2].elements;a[0]=n[8],a[1]=n[9],a[2]=n[10]},i(e,["_tempV30",function(){return this._tempV30=new Qe},"_tempV31",function(){return this._tempV31=new Qe},"_tempV32",function(){return this._tempV32=new Qe},"_tempV33",function(){return this._tempV33=new Qe},"_tempV34",function(){return this._tempV34=new Qe},"_tempM0",function(){return this._tempM0=new je},"_tempM1",function(){return this._tempM1=new je}]),e}(),function(){function e(e,t){this.normal=null,this.distance=NaN,void 0===t&&(t=0),this.normal=e,this.distance=t}r(e,"laya.d3.math.Plane");var t=e.prototype;return t.normalize=function(){var e=this.normal.elements,t=e[0],n=e[1],i=e[2],r=1/Math.sqrt(t*t+n*n+i*i);e[0]=t*r,e[1]=n*r,e[2]=i*r,this.distance*=r},e.createPlaneBy3P=function(t,n,i){var r=t.elements,a=n.elements,s=i.elements,o=a[0]-r[0],l=a[1]-r[1],h=a[2]-r[2],u=s[0]-r[0],c=s[1]-r[1],_=s[2]-r[2],d=l*_-h*c,m=h*u-o*_,f=o*c-l*u,p=1/Math.sqrt(d*d+m*m+f*f),v=d*p,g=m*p,T=f*p,x=e._TEMPVec3.elements;x[0]=v,x[1]=g,x[2]=T;var M=-(v*r[0]+g*r[1]+T*r[2]),E=new e(e._TEMPVec3,M);return E},e.PlaneIntersectionType_Back=0,e.PlaneIntersectionType_Front=1,e.PlaneIntersectionType_Intersecting=2,i(e,["_TEMPVec3",function(){return this._TEMPVec3=new Qe}]),e}()),Ze=function(){function e(e,t,n,i){this.elements=new Float32Array(4),void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=1),this.elements[0]=e,this.elements[1]=t,this.elements[2]=n,this.elements[3]=i}r(e,"laya.d3.math.Quaternion");var t=e.prototype;return t.scaling=function(e,t){var n=t.elements,i=this.elements;n[0]=i[0]*e,n[1]=i[1]*e,n[2]=i[2]*e,n[3]=i[3]*e},t.normalize=function(e){var t=e.elements,n=this.elements,i=n[0],r=n[1],a=n[2],s=n[3],o=i*i+r*r+a*a+s*s;o>0&&(o=1/Math.sqrt(o),t[0]=i*o,t[1]=r*o,t[2]=a*o,t[3]=s*o)},t.length=function(){var e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3];return Math.sqrt(t*t+n*n+i*i+r*r)},t.rotateX=function(e,t){var n=t.elements,i=this.elements;e*=.5;var r=i[0],a=i[1],s=i[2],o=i[3],l=Math.sin(e),h=Math.cos(e);n[0]=r*h+o*l,n[1]=a*h+s*l,n[2]=s*h-a*l,n[3]=o*h-r*l},t.rotateY=function(e,t){var n=t.elements,i=this.elements;e*=.5;var r=i[0],a=i[1],s=i[2],o=i[3],l=Math.sin(e),h=Math.cos(e);n[0]=r*h-s*l,n[1]=a*h+o*l,n[2]=s*h+r*l,n[3]=o*h-a*l},t.rotateZ=function(e,t){var n=t.elements,i=this.elements;e*=.5;var r=i[0],a=i[1],s=i[2],o=i[3],l=Math.sin(e),h=Math.cos(e);n[0]=r*h+a*l,n[1]=a*h-r*l,n[2]=s*h+o*l,n[3]=o*h-s*l},t.getYawPitchRoll=function(t){Qe.transformQuat(Qe.ForwardRH,this,e.TEMPVector31),Qe.transformQuat(Qe.Up,this,e.TEMPVector32);var n=e.TEMPVector32.elements;e.angleTo(Qe.ZERO,e.TEMPVector31,e.TEMPVector33);var i=e.TEMPVector33.elements;i[0]==Math.PI/2?(i[1]=e.arcTanAngle(n[2],n[0]),i[2]=0):i[0]==-Math.PI/2?(i[1]=e.arcTanAngle(-n[2],-n[0]),i[2]=0):(je.createRotationY(-i[1],e.TEMPMatrix0),je.createRotationX(-i[0],e.TEMPMatrix1),Qe.transformCoordinate(e.TEMPVector32,e.TEMPMatrix0,e.TEMPVector32),Qe.transformCoordinate(e.TEMPVector32,e.TEMPMatrix1,e.TEMPVector32),i[2]=e.arcTanAngle(n[1],-n[0])),i[1]<=-Math.PI&&(i[1]=Math.PI),i[2]<=-Math.PI&&(i[2]=Math.PI),i[1]>=Math.PI&&i[2]>=Math.PI&&(i[1]=0,i[2]=0,i[0]=Math.PI-i[0]);var r=t.elements;r[0]=i[1],r[1]=i[0],r[2]=i[2]},t.invert=function(e){var t=e.elements,n=this.elements,i=n[0],r=n[1],a=n[2],s=n[3],o=i*i+r*r+a*a+s*s,l=o?1/o:0;t[0]=-i*l,t[1]=-r*l,t[2]=-a*l,t[3]=s*l},t.identity=function(){var e=this.elements;e[0]=0,e[1]=0,e[2]=0,e[3]=1},t.cloneTo=function(e){var t,n,i;if(n=this.elements,i=e.elements,n!==i)for(t=0;4>t;++t)i[t]=n[t]},t.copyFrom=function(e){var t,n,i;if(n=e.elements,i=this.elements,n!==i)for(t=0;4>t;++t)i[t]=n[t]},t.copyFromArray=function(e){var t,n;if(n=this.elements,e!==n)for(t=0;4>t;++t)n[t]=e[t]},a(0,t,"x",function(){return this.elements[0]}),a(0,t,"y",function(){return this.elements[1]}),a(0,t,"z",function(){return this.elements[2]}),a(0,t,"w",function(){return this.elements[3]}),e.createFromYawPitchRoll=function(e,t,n,i){var r=.5*n,a=.5*t,s=.5*e,o=Math.sin(r),l=Math.cos(r),h=Math.sin(a),u=Math.cos(a),c=Math.sin(s),_=Math.cos(s),d=i.elements;d[0]=_*h*l+c*u*o,d[1]=c*u*l-_*h*o,d[2]=_*u*o-c*h*l,d[3]=_*u*l+c*h*o},e.multiply=function(e,t,n){var i=e.elements,r=t.elements,a=n.elements,s=i[0],o=i[1],l=i[2],h=i[3],u=r[0],c=r[1],_=r[2],d=r[3],m=o*_-l*c,f=l*u-s*_,p=s*c-o*u,v=s*u+o*c+l*_;a[0]=s*d+u*h+m,a[1]=o*d+c*h+f,a[2]=l*d+_*h+p,a[3]=h*d-v},e.arcTanAngle=function(e,t){return 0==e?1==t?Math.PI/2:-Math.PI/2:e>0?Math.atan(t/e):0>e?t>0?Math.atan(t/e)+Math.PI:Math.atan(t/e)-Math.PI:0},e.angleTo=function(t,n,i){Qe.subtract(n,t,e.TEMPVector30),Qe.normalize(e.TEMPVector30,e.TEMPVector30),i.elements[0]=Math.asin(e.TEMPVector30.y),i.elements[1]=e.arcTanAngle(-e.TEMPVector30.z,-e.TEMPVector30.x)},e.createFromAxisAngle=function(e,t,n){var i=n.elements,r=e.elements;t=.5*t;var a=Math.sin(t);i[0]=a*r[0],i[1]=a*r[1],i[2]=a*r[2],i[3]=Math.cos(t)},e.createFromMatrix3x3=function(e,t){var n,i=t.elements,r=e.elements,a=r[0]+r[4]+r[8];if(a>0)n=Math.sqrt(a+1),i[3]=.5*n,n=.5/n,i[0]=(r[5]-r[7])*n,i[1]=(r[6]-r[2])*n,i[2]=(r[1]-r[3])*n;else{var s=0;r[4]>r[0]&&(s=1),r[8]>r[3*s+s]&&(s=2);var o=(s+1)%3,l=(s+2)%3;n=Math.sqrt(r[3*s+s]-r[3*o+o]-r[3*l+l]+1),i[s]=.5*n,n=.5/n,i[3]=(r[3*o+l]-r[3*l+o])*n,i[o]=(r[3*o+s]+r[3*s+o])*n,i[l]=(r[3*l+s]+r[3*s+l])*n}},e.createFromMatrix4x4=function(e,t){var n,i,r=e.elements,a=t.elements,s=r[0]+r[5]+r[10];s>0?(n=Math.sqrt(s+1),a[3]=.5*n,n=.5/n,a[0]=(r[6]-r[9])*n,a[1]=(r[8]-r[2])*n,a[2]=(r[1]-r[4])*n):r[0]>=r[5]&&r[0]>=r[10]?(n=Math.sqrt(1+r[0]-r[5]-r[10]),i=.5/n,a[0]=.5*n,a[1]=(r[1]+r[4])*i,a[2]=(r[2]+r[8])*i,a[3]=(r[6]-r[9])*i):r[5]>r[10]?(n=Math.sqrt(1+r[5]-r[0]-r[10]),i=.5/n,a[0]=(r[4]+r[1])*i,a[1]=.5*n,a[2]=(r[9]+r[6])*i,a[3]=(r[8]-r[2])*i):(n=Math.sqrt(1+r[10]-r[0]-r[5]),i=.5/n,a[0]=(r[8]+r[2])*i,a[1]=(r[9]+r[6])*i,a[2]=.5*n,a[3]=(r[1]-r[4])*i)},e.slerp=function(e,t,n,i){var r,a,s,o,l,h=e.elements,u=t.elements,c=i.elements,_=h[0],d=h[1],m=h[2],f=h[3],p=u[0],v=u[1],g=u[2],T=u[3];return a=_*p+d*v+m*g+f*T,0>a&&(a=-a,p=-p,v=-v,g=-g,T=-T),1-a>1e-6?(r=Math.acos(a),s=Math.sin(r),o=Math.sin((1-n)*r)/s,l=Math.sin(n*r)/s):(o=1-n,l=n),c[0]=o*_+l*p,c[1]=o*d+l*v,c[2]=o*m+l*g,c[3]=o*f+l*T,c},e.lerp=function(e,t,n,i){var r=i.elements,a=e.elements,s=t.elements,o=a[0],l=a[1],h=a[2],u=a[3];r[0]=o+n*(s[0]-o),r[1]=l+n*(s[1]-l),r[2]=h+n*(s[2]-h),r[3]=u+n*(s[3]-u)},e.add=function(e,t,n){var i=n.elements,r=e.elements,a=t.elements;i[0]=r[0]+a[0],i[1]=r[1]+a[1],i[2]=r[2]+a[2],i[3]=r[3]+a[3]},e.dot=function(e,t){var n=e.elements,i=t.elements;return n[0]*i[0]+n[1]*i[1]+n[2]*i[2]+n[3]*i[3]},e.DEFAULT=new e,i(e,["TEMPVector30",function(){return this.TEMPVector30=new Qe},"TEMPVector31",function(){return this.TEMPVector31=new Qe},"TEMPVector32",function(){return this.TEMPVector32=new Qe},"TEMPVector33",function(){return this.TEMPVector33=new Qe},"TEMPMatrix0",function(){return this.TEMPMatrix0=new je},"TEMPMatrix1",function(){return this.TEMPMatrix1=new je}]),e}(),qe=function(){function e(e,t){this.origin=null,this.direction=null,this.origin=e,this.direction=t}return r(e,"laya.d3.math.Ray"),e}(),Ke=function(){function e(e,t){this.elements=new Float32Array(2),void 0===e&&(e=0),void 0===t&&(t=0);var n=this.elements;n[0]=e,n[1]=t}r(e,"laya.d3.math.Vector2");var t=e.prototype;return t.clone=function(e){var t=this.elements,n=e.elements;t[0]=n[0],t[1]=n[1]},a(0,t,"x",function(){return this.elements[0]}),a(0,t,"y",function(){return this.elements[1]}),e.scale=function(e,t,n){var i=n.elements,r=e.elements;i[0]=r[0]*t,i[1]=r[1]*t},i(e,["ZERO",function(){return this.ZERO=new e(0,0)},"ONE",function(){return this.ONE=new e(1,1)}]),e}(),Qe=function(){function e(e,t,n){this.elements=new Float32Array(3),void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0);var i=this.elements;i[0]=e,i[1]=t,i[2]=n}r(e,"laya.d3.math.Vector3");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.cloneTo=function(e){var t=e,n=t.elements,i=this.elements;n[0]=i[0],n[1]=i[1],n[2]=i[2]},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},t.toDefault=function(){this.elements[0]=0,this.elements[1]=0,this.elements[2]=0},a(0,t,"x",function(){return this.elements[0]},function(e){this.elements[0]=e}),a(0,t,"y",function(){return this.elements[1]},function(e){this.elements[1]=e}),a(0,t,"z",function(){return this.elements[2]},function(e){this.elements[2]=e}),e.distanceSquared=function(e,t){var n=e.elements,i=t.elements,r=n[0]-i[0],a=n[1]-i[1],s=n[2]-i[2];return r*r+a*a+s*s},e.distance=function(e,t){var n=e.elements,i=t.elements,r=n[0]-i[0],a=n[1]-i[1],s=n[2]-i[2];return Math.sqrt(r*r+a*a+s*s)},e.min=function(e,t,n){var i=n.elements,r=e.elements,a=t.elements;i[0]=Math.min(r[0],a[0]),i[1]=Math.min(r[1],a[1]),i[2]=Math.min(r[2],a[2])},e.max=function(e,t,n){var i=n.elements,r=e.elements,a=t.elements;i[0]=Math.max(r[0],a[0]),i[1]=Math.max(r[1],a[1]),i[2]=Math.max(r[2],a[2])},e.transformQuat=function(e,t,n){var i=n.elements,r=e.elements,a=t.elements,s=r[0],o=r[1],l=r[2],h=a[0],u=a[1],c=a[2],_=a[3],d=_*s+u*l-c*o,m=_*o+c*s-h*l,f=_*l+h*o-u*s,p=-h*s-u*o-c*l;i[0]=d*_+p*-h+m*-c-f*-u,i[1]=m*_+p*-u+f*-h-d*-c,i[2]=f*_+p*-c+d*-u-m*-h},e.scalarLength=function(e){var t=e.elements,n=t[0],i=t[1],r=t[2];return Math.sqrt(n*n+i*i+r*r)},e.scalarLengthSquared=function(e){var t=e.elements,n=t[0],i=t[1],r=t[2];return n*n+i*i+r*r},e.normalize=function(e,t){var n=e.elements,i=t.elements,r=n[0],a=n[1],s=n[2],o=r*r+a*a+s*s;o>0&&(o=1/Math.sqrt(o),i[0]=n[0]*o,i[1]=n[1]*o,i[2]=n[2]*o)},e.multiply=function(e,t,n){var i=n.elements,r=e.elements,a=t.elements;i[0]=r[0]*a[0],i[1]=r[1]*a[1],i[2]=r[2]*a[2]},e.scale=function(e,t,n){var i=n.elements,r=e.elements;i[0]=r[0]*t,i[1]=r[1]*t,i[2]=r[2]*t},e.lerp=function(e,t,n,i){var r=i.elements,a=e.elements,s=t.elements,o=a[0],l=a[1],h=a[2];r[0]=o+n*(s[0]-o),r[1]=l+n*(s[1]-l),r[2]=h+n*(s[2]-h)},e.transformV3ToV3=function(t,n,i){var r=new $e;e.transformV3ToV4(t,n,r);var a=r.elements,s=i.elements;s[0]=a[0],s[1]=a[1],s[2]=a[2]},e.transformV3ToV4=function(e,t,n){var i=e.elements,r=i[0],a=i[1],s=i[2],o=t.elements,l=n.elements;l[0]=r*o[0]+a*o[4]+s*o[8]+o[12],l[1]=r*o[1]+a*o[5]+s*o[9]+o[13],l[2]=r*o[2]+a*o[6]+s*o[10]+o[14],l[3]=r*o[3]+a*o[7]+s*o[11]+o[15]},e.TransformNormal=function(e,t,n){var i=e.elements,r=i[0],a=i[1],s=i[2],o=t.elements,l=n.elements;l[0]=r*o[0]+a*o[4]+s*o[8],l[1]=r*o[1]+a*o[5]+s*o[9],l[2]=r*o[2]+a*o[6]+s*o[10]},e.transformCoordinate=function(t,n,i){var r=e.TEMPVec4.elements,a=t.elements,s=a[0],o=a[1],l=a[2],h=n.elements;r[0]=s*h[0]+o*h[4]+l*h[8]+h[12],r[1]=s*h[1]+o*h[5]+l*h[9]+h[13],r[2]=s*h[2]+o*h[6]+l*h[10]+h[14],r[3]=1/(s*h[3]+o*h[7]+l*h[11]+h[15]);var u=i.elements;u[0]=r[0]*r[3],u[1]=r[1]*r[3],u[2]=r[2]*r[3]},e.Clamp=function(e,t,n,i){var r=e.elements,a=r[0],s=r[1],o=r[2],l=t.elements,h=l[0],u=l[1],c=l[2],_=n.elements,d=_[0],m=_[1],f=_[2],p=i.elements;a=a>d?d:a,a=h>a?h:a,s=s>m?m:s,s=u>s?u:s,o=o>f?f:o,o=c>o?c:o,p[0]=a,p[1]=s,p[2]=o},e.add=function(e,t,n){var i=n.elements,r=e.elements,a=t.elements;i[0]=r[0]+a[0],i[1]=r[1]+a[1],i[2]=r[2]+a[2]},e.subtract=function(e,t,n){var i=n.elements,r=e.elements,a=t.elements;i[0]=r[0]-a[0],i[1]=r[1]-a[1],i[2]=r[2]-a[2]},e.cross=function(e,t,n){var i=e.elements,r=t.elements,a=n.elements,s=i[0],o=i[1],l=i[2],h=r[0],u=r[1],c=r[2];a[0]=o*c-l*u,a[1]=l*h-s*c,a[2]=s*u-o*h},e.dot=function(e,t){var n=e.elements,i=t.elements,r=n[0]*i[0]+n[1]*i[1]+n[2]*i[2];return r},e.equals=function(e,t){var n=e.elements,i=t.elements;return Ye.nearEqual(Math.abs(n[0]),Math.abs(i[0]))&&Ye.nearEqual(Math.abs(n[1]),Math.abs(i[1]))&&Ye.nearEqual(Math.abs(n[2]),Math.abs(i[2]))},i(e,["TEMPVec4",function(){return this.TEMPVec4=new $e},"ZERO",function(){return this.ZERO=new e(0,0,0)},"ONE",function(){return this.ONE=new e(1,1,1)},"NegativeUnitX",function(){return this.NegativeUnitX=new e(-1,0,0)},"UnitX",function(){return this.UnitX=new e(1,0,0)},"UnitY",function(){return this.UnitY=new e(0,1,0)},"UnitZ",function(){return this.UnitZ=new e(0,0,1)},"ForwardRH",function(){return this.ForwardRH=new e(0,0,-1)},"ForwardLH",function(){return this.ForwardLH=new e(0,0,1)},"Up",function(){return this.Up=new e(0,1,0)}]),e}(),$e=function(){function e(e,t,n,i){this.elements=new Float32Array(4),void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0);var r=this.elements;r[0]=e,r[1]=t,r[2]=n,r[3]=i}r(e,"laya.d3.math.Vector4");var t=e.prototype;return n.imps(t,{"laya.d3.core.IClone":!0}),t.cloneTo=function(e){var t=e,n=t.elements,i=this.elements;n[0]=i[0],n[1]=i[1],n[2]=i[2],n[3]=i[3]},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},a(0,t,"x",function(){return this.elements[0]}),a(0,t,"y",function(){return this.elements[1]}),a(0,t,"z",function(){return this.elements[2]}),a(0,t,"w",function(){return this.elements[3]}),e.lerp=function(e,t,n,i){var r=i.elements,a=e.elements,s=t.elements,o=a[0],l=a[1],h=a[2],u=a[3];r[0]=o+n*(s[0]-o),r[1]=l+n*(s[1]-l),r[2]=h+n*(s[2]-h),r[3]=u+n*(s[3]-u)},i(e,["ZERO",function(){return this.ZERO=new e}]),e}(),Je=function(){function e(e,t,n,i){this.minDepth=0,this.maxDepth=1,this.x=e,this.y=t,this.width=n,this.height=i}r(e,"laya.d3.math.Viewport");var t=e.prototype;return t.project=function(e,t,n){Qe.transformV3ToV3(e,t,n);var i=e.elements,r=t.elements,a=n.elements,s=i[0]*r[3]+i[1]*r[7]+i[2]*r[11]+r[15];1!==s&&(a[0]=a[0]/s,a[1]=a[1]/s,a[2]=a[2]/s),a[0]=.5*(a[0]+1)*this.width+this.x,a[1]=.5*(-a[1]+1)*this.height+this.y,a[2]=a[2]*(this.maxDepth-this.minDepth)+this.minDepth},t.unprojectFromMat=function(e,t,n){var i=e.elements,r=t.elements,a=n.elements;a[0]=(i[0]-this.x)/this.width*2-1,a[1]=-((i[1]-this.y)/this.height*2-1);var s=(this.maxDepth-this.minDepth)/2;a[2]=(i[2]-this.minDepth-s)/s;var o=a[0]*r[3]+a[1]*r[7]+a[2]*r[11]+r[15];Qe.transformV3ToV3(n,t,n),1!==o&&(a[0]=a[0]/o,a[1]=a[1]/o,a[2]=a[2]/o)},t.unprojectFromWVP=function(t,n,i,r,a){je.multiply(n,i,e._tempMatrix4x4),r&&je.multiply(e._tempMatrix4x4,r,e._tempMatrix4x4),e._tempMatrix4x4.invert(e._tempMatrix4x4),this.unprojectFromMat(t,e._tempMatrix4x4,a)},i(e,["_tempMatrix4x4",function(){return this._tempMatrix4x4=new je}]),e}(),et=function(){function e(){this._indexBuffer=null,this._vertexBuffer=null,this._boneIndices=null,this._bufferUsage=null,this._indexInMesh=0,this._bufferUsage={}}r(e,"laya.d3.resource.models.SubMesh");var t=e.prototype;return n.imps(t,{"laya.d3.core.render.IRenderable":!0,"laya.resource.IDispose":!0}),t._getVertexBuffer=function(e){return void 0===e&&(e=0),0===e?this._vertexBuffer:null},t._getIndexBuffer=function(){return this._indexBuffer},t._beforeRender=function(e){return this._vertexBuffer._bind(),this._indexBuffer._bind(),!0},t._render=function(e){var t=this._indexBuffer.indexCount;e.context.drawElements(4,t,5123,0),L.drawCall++,L.trianglesFaces+=t/3},t.dispose=function(){this._boneIndices=null,this._indexBuffer.dispose(),this._vertexBuffer.dispose()},a(0,t,"_vertexBufferCount",function(){return 1}),a(0,t,"indexOfHost",function(){return this._indexInMesh}),a(0,t,"triangleCount",function(){return this._indexBuffer.indexCount/3;
|
||
}),e}(),tt=(function(){function e(){}return r(e,"laya.d3.utils.Physics"),e.rayCastNode=function(t,n,i){if(n instanceof laya.d3.core.MeshSprite3D){var r=n,a=n.transform.worldMatrix,s=e._tempMatrix4x40;a.invert(s);var o=e._tempVector30,l=e._tempVector31,h=t.origin,u=t.direction;h.cloneTo(o),u.cloneTo(l),Qe.transformCoordinate(h,s,h),Qe.TransformNormal(u,s,u),Qe.normalize(u,u);for(var c=r.meshRender.renderObject._renderElements,_=0,d=c.length;d>_;_++){var m=c[_].renderObj,f=m._getVertexBuffer(0),p=f.getData(),v=m._getIndexBuffer().getData(),g=e._tempRaycastHit0,T=tt.rayIntersectsPositionsAndIndices(t,p,f.vertexDeclaration,v,g);if(T){Qe.transformCoordinate(g.position,a,g.position);var x=g.trianglePositions;Qe.transformCoordinate(x[0],a,x[0]),Qe.transformCoordinate(x[1],a,x[1]),Qe.transformCoordinate(x[2],a,x[2]);var M=g.triangleNormals;Qe.transformCoordinate(M[0],a,M[0]),Qe.transformCoordinate(M[1],a,M[1]),Qe.transformCoordinate(M[2],a,M[2]);var E=e._tempVector33;Qe.subtract(o,g.position,E),i.distance=Qe.scalarLength(E)}T&&g.distance<i.distance&&g.copy(i)}o.cloneTo(h),l.cloneTo(u)}for(var y=0,S=n._childs.length;S>y;y++)e.rayCast(t,n._childs[y],i)},e.rayCast=function(t,n,i){i.position.toDefault(),i.distance=Number.MAX_VALUE,i.trianglePositions[0].toDefault(),i.trianglePositions[1].toDefault(),i.trianglePositions[2].toDefault(),i.triangleNormals[0].toDefault(),i.triangleNormals[1].toDefault(),i.triangleNormals[2].toDefault(),e.rayCastNode(t,n,i)},i(e,["_tempVector30",function(){return this._tempVector30=new Qe},"_tempVector31",function(){return this._tempVector31=new Qe},"_tempVector33",function(){return this._tempVector33=new Qe},"_tempMatrix4x40",function(){return this._tempMatrix4x40=new je},"_tempRaycastHit0",function(){return this._tempRaycastHit0=new nt}]),e}(),function(){function e(){}return r(e,"laya.d3.utils.Picker"),e.calculateCursorRay=function(t,n,i,r,a,s){var o=t.elements[0],l=t.elements[1],h=e._tempVector30,u=h.elements;u[0]=o,u[1]=l,u[2]=n.minDepth;var c=e._tempVector31,_=c.elements;_[0]=o,_[1]=l,_[2]=n.maxDepth;var d=s.origin,m=e._tempVector32;n.unprojectFromWVP(h,i,r,a,d),n.unprojectFromWVP(c,i,r,a,m);var f=s.direction.elements;f[0]=m.x-d.x,f[1]=m.y-d.y,f[2]=m.z-d.z,Qe.normalize(s.direction,s.direction)},e.rayIntersectsPositionsAndIndices=function(t,n,i,r,a){for(var s=i.vertexStride/4,o=i.getVertexElementByUsage("POSITION").offset/4,l=Number.MAX_VALUE,h=-1,u=-1,c=-1,_=0;_<r.length;_+=3){var d=e._tempVector35,m=d.elements,f=r[_]*s,p=f+o;m[0]=n[p],m[1]=n[p+1],m[2]=n[p+2];var v=e._tempVector36,g=v.elements,T=r[_+1]*s,x=T+o;g[0]=n[x],g[1]=n[x+1],g[2]=n[x+2];var M=e._tempVector37,E=M.elements,y=r[_+2]*s,S=y+o;E[0]=n[S],E[1]=n[S+1],E[2]=n[S+2];var R=laya.d3.utils.Picker.rayIntersectsTriangle(t,d,v,M);!isNaN(R)&&l>R&&(l=R,h=f,u=T,c=y)}if(l!==Number.MAX_VALUE){a.distance=l,Qe.normalize(t.direction,t.direction),Qe.scale(t.direction,l,a.position),Qe.add(t.origin,a.position,a.position);var A=a.trianglePositions,I=A[0],C=A[1],V=A[2],D=I.elements,L=C.elements,O=V.elements,b=h+o;D[0]=n[b],D[1]=n[b+1],D[2]=n[b+2];var P=u+o;L[0]=n[P],L[1]=n[P+1],L[2]=n[P+2];var w=c+o;O[0]=n[w],O[1]=n[w+1],O[2]=n[w+2];var N=i.getVertexElementByUsage("NORMAL");if(N){var B=N.offset/4,F=a.triangleNormals,U=F[0],G=F[1],z=F[2],H=U.elements,k=G.elements,X=z.elements,Y=h+B;H[0]=n[Y],H[1]=n[Y+1],H[2]=n[Y+2];var j=u+B;k[0]=n[j],k[1]=n[j+1],k[2]=n[j+2];var W=c+B;X[0]=n[W],X[1]=n[W+1],X[2]=n[W+2]}return!0}return a.position.toDefault(),a.distance=Number.MAX_VALUE,a.trianglePositions[0].toDefault(),a.trianglePositions[1].toDefault(),a.trianglePositions[2].toDefault(),a.triangleNormals[0].toDefault(),a.triangleNormals[1].toDefault(),a.triangleNormals[2].toDefault(),!1},e.rayIntersectsTriangle=function(t,n,i,r){var a,s=e._tempVector30,o=e._tempVector31;Qe.subtract(i,n,s),Qe.subtract(r,n,o);var l=e._tempVector32;Qe.cross(t.direction,o,l);var h;if(h=Qe.dot(s,l),h>-Number.MIN_VALUE&&h<Number.MIN_VALUE)return a=Number.NaN;var u=1/h,c=e._tempVector33;Qe.subtract(t.origin,n,c);var _;if(_=Qe.dot(c,l),_*=u,0>_||_>1)return a=Number.NaN;var d=e._tempVector34;Qe.cross(c,s,d);var m;if(m=Qe.dot(t.direction,d),m*=u,0>m||_+m>1)return a=Number.NaN;var f;return f=Qe.dot(o,d),f*=u,a=0>f?Number.NaN:f},i(e,["_tempVector30",function(){return this._tempVector30=new Qe},"_tempVector31",function(){return this._tempVector31=new Qe},"_tempVector32",function(){return this._tempVector32=new Qe},"_tempVector33",function(){return this._tempVector33=new Qe},"_tempVector34",function(){return this._tempVector34=new Qe},"_tempVector35",function(){return this._tempVector35=new Qe},"_tempVector36",function(){return this._tempVector36=new Qe},"_tempVector37",function(){return this._tempVector37=new Qe}]),e}()),nt=function(){function e(){this.distance=NaN,this.trianglePositions=null,this.triangleNormals=null,this.position=null,this.distance=Number.MAX_VALUE,this.trianglePositions=[new Qe,new Qe,new Qe],this.trianglePositions.length=3,this.triangleNormals=[new Qe,new Qe,new Qe],this.triangleNormals.length=3,this.position=new Qe}r(e,"laya.d3.utils.RaycastHit");var t=e.prototype;return t.copy=function(e){e.distance=this.distance,this.trianglePositions[0].cloneTo(e.trianglePositions[0]),this.trianglePositions[1].cloneTo(e.trianglePositions[1]),this.trianglePositions[2].cloneTo(e.trianglePositions[2]),this.triangleNormals[0].cloneTo(e.triangleNormals[0]),this.triangleNormals[1].cloneTo(e.triangleNormals[1]),this.triangleNormals[2].cloneTo(e.triangleNormals[2]),this.position.cloneTo(e.position)},e}(),it=function(){function e(e,t){this._width=0,this._height=0,this._width=e,this._height=t}r(e,"laya.d3.utils.Size");var t=e.prototype;return a(0,t,"width",function(){return-1===this._width?le.clientWidth:this._width}),a(0,t,"height",function(){return-1===this._height?le.clientHeight:this._height}),a(1,e,"fullScreen",function(){return new e(-1,-1)}),e}(),rt=function(){function e(){}r(e,"laya.d3.utils.Utils3D");var t=e.prototype;return t.testTangent=function(e,t,n,i){var r=t.vertexDeclaration,a=e._material;if(a.normalTexture&&!r.getVertexElementByUsage("TANGENT0")){var s=t.getData(),o=laya.d3.utils.Utils3D.generateTangent(s,r.vertexStride/4,r.getVertexElementByUsage("POSITION").offset/4,r.getVertexElementByUsage("UV").offset/4,n.getData());r=laya.d3.utils.Utils3D.getVertexTangentDeclaration(r.getVertexElements());var l=Bt.create(r,35044);return l.setData(o),t.dispose(),i.TANGENT0=l,l}return t},e._getTexturePath=function(e){var t=e.length-4;return e.indexOf(".dds")!=t&&e.indexOf(".tga")!=t&&e.indexOf(".exr")!=t&&e.indexOf(".DDS")!=t&&e.indexOf(".TGA")!=t&&e.indexOf(".EXR")!=t||(e=e.substr(0,t)+".png"),e=O.formatURL(e)},e._rotationTransformScaleSkinAnimation=function(t,n,i,r,a,s,o,l,h,u,c,_){var d=e._tempArray16_0,m=e._tempArray16_1,f=e._tempArray16_2,p=r+r,v=a+a,g=s+s,T=r*p,x=a*p,M=a*v,E=s*p,y=s*v,S=s*g,R=o*p,A=o*v,I=o*g;d[15]=1,d[0]=1-M-S,d[1]=x+I,d[2]=E-A,d[4]=x-I,d[5]=1-T-S,d[6]=y+R,d[8]=E+A,d[9]=y-R,d[10]=1-T-M,m[15]=1,m[0]=l,m[5]=h,m[10]=u;var C,V,D,L,O;for(C=0;4>C;C++)V=d[C],D=d[C+4],L=d[C+8],O=d[C+12],f[C]=V,f[C+4]=D,f[C+8]=L,f[C+12]=V*t+D*n+L*i+O;for(C=0;4>C;C++)V=f[C],D=f[C+4],L=f[C+8],O=f[C+12],c[C+_]=V*m[0]+D*m[1]+L*m[2]+O*m[3],c[C+_+4]=V*m[4]+D*m[5]+L*m[6]+O*m[7],c[C+_+8]=V*m[8]+D*m[9]+L*m[10]+O*m[11],c[C+_+12]=V*m[12]+D*m[13]+L*m[14]+O*m[15]},e._applyMeshMaterials=function(e,t){for(var n=e.meshRender,i=n.sharedMaterials,r=t.materials,a=0,s=r.length;s>a;a++)i[a]||(i[a]=r[a]);n.sharedMaterials=i},e._loadParticle=function(t,n,i){var r=Math.PI/180,a=0,s=0,o=new Ft;o.diffuseTexture=i?g.getRes(i[t.texturePath]):kt.load(t.texturePath),o.renderMode=8,n.particleRender.sharedMaterial=o;var l=n.particleSystem;l.isPerformanceMode=t.isPerformanceMode,l.duration=t.duration,l.looping=t.looping,l.prewarm=t.prewarm,l.startDelayType=t.startDelayType,l.startDelay=t.startDelay,l.startDelayMin=t.startDelayMin,l.startDelayMax=t.startDelayMax,l.startLifetimeType=t.startLifetimeType,l.startLifetimeConstant=t.startLifetimeConstant,l.startLifeTimeGradient=e._initStartLife(t.startLifetimeGradient),l.startLifetimeConstantMin=t.startLifetimeConstantMin,l.startLifetimeConstantMax=t.startLifetimeConstantMax,l.startLifeTimeGradientMin=e._initStartLife(t.startLifetimeGradientMin),l.startLifeTimeGradientMax=e._initStartLife(t.startLifetimeGradientMax),l.startSpeedType=t.startSpeedType,l.startSpeedConstant=t.startSpeedConstant,l.startSpeedConstantMin=t.startSpeedConstantMin,l.startSpeedConstantMax=t.startSpeedConstantMax,l.threeDStartSize=t.threeDStartSize,l.startSizeType=t.startSizeType,l.startSizeConstant=t.startSizeConstant;var h=t.startSizeConstantSeparate,u=l.startSizeConstantSeparate.elements;u[0]=h[0],u[1]=h[1],u[2]=h[2],l.startSizeConstantMin=t.startSizeConstantMin,l.startSizeConstantMax=t.startSizeConstantMax;var c=t.startSizeConstantMinSeparate,_=l.startSizeConstantMinSeparate.elements;_[0]=c[0],_[1]=c[1],_[2]=c[2];var d=t.startSizeConstantMaxSeparate,m=l.startSizeConstantMaxSeparate.elements;m[0]=d[0],m[1]=d[1],m[2]=d[2],l.threeDStartRotation=t.threeDStartRotation,l.startRotationType=t.startRotationType,l.startRotationConstant=t.startRotationConstant*r;var f=t.startRotationConstantSeparate,p=l.startRotationConstantSeparate.elements;p[0]=f[0]*r,p[1]=f[1]*r,p[2]=f[2]*r,l.startRotationConstantMin=t.startRotationConstantMin*r,l.startRotationConstantMax=t.startRotationConstantMax*r;var v=t.startRotationConstantMinSeparate,T=l.startRotationConstantMinSeparate.elements;T[0]=v[0]*r,T[1]=v[1]*r,T[2]=v[2]*r;var x=t.startRotationConstantMaxSeparate,M=l.startRotationConstantMaxSeparate.elements;M[0]=x[0]*r,M[1]=x[1]*r,M[2]=x[2]*r,l.randomizeRotationDirection=t.randomizeRotationDirection,l.startColorType=t.startColorType;var E=t.startColorConstant,y=l.startColorConstant.elements;y[0]=E[0],y[1]=E[1],y[2]=E[2],y[3]=E[3];var S=t.startColorConstantMin,R=l.startColorConstantMin.elements;R[0]=S[0],R[1]=S[1],R[2]=S[2],R[3]=S[3];var A=t.startColorConstantMax,I=l.startColorConstantMax.elements;I[0]=A[0],I[1]=A[1],I[2]=A[2],I[3]=A[3];var C=t.gravity,V=l.gravity.elements;V[0]=C[0],V[1]=C[1],V[2]=C[2],l.gravityModifier=t.gravityModifier,l.simulationSpace=t.simulationSpace,l.scaleMode=t.scaleMode,l.playOnAwake=t.playOnAwake,l.maxParticles=t.maxParticles;var D=t.emission,L=new lt;L.emissionRate=D.emissionRate;var O=D.bursts;if(O)for(a=0,s=O.length;s>a;a++){var b=O[a];L.addBurst(new G(b.time,b.min,b.max))}L.enbale=D.enable,l.emission=L;var P,w=t.shape;switch(w.shapeType){case 0:var N;P=N=new pt,N.radius=w.sphereRadius,N.emitFromShell=w.sphereEmitFromShell,N.randomDirection=w.sphereRandomDirection;break;case 1:var B;P=B=new ft,B.radius=w.hemiSphereRadius,B.emitFromShell=w.hemiSphereEmitFromShell,B.randomDirection=w.hemiSphereRandomDirection;break;case 2:var F;P=F=new mt,F.angle=w.coneAngle*r,F.radius=w.coneRadius,F.length=w.coneLength,F.emitType=w.coneEmitType,F.randomDirection=w.coneRandomDirection;break;case 3:var U;P=U=new _t,U.x=w.boxX,U.y=w.boxY,U.z=w.boxZ,U.randomDirection=w.boxRandomDirection;break;case 7:var Y;P=Y=new dt,Y.radius=w.circleRadius,Y.arc=w.circleArc*r,Y.emitFromEdge=w.circleEmitFromEdge,Y.randomDirection=w.circleRandomDirection}P.enbale=w.enable,l.shape=P;var j=t.velocityOverLifetime;if(j){var W,Q=j.velocity;switch(Q.type){case 0:var $=Q.constant;W=q.createByConstant(new Qe($[0],$[1],$[2]));break;case 1:W=q.createByGradient(e._initParticleVelocity(Q.gradientX),e._initParticleVelocity(Q.gradientY),e._initParticleVelocity(Q.gradientZ));break;case 2:var ie=Q.constantMin,re=Q.constantMax;W=q.createByRandomTwoConstant(new Qe(ie[0],ie[1],ie[2]),new Qe(re[0],re[1],re[2]));break;case 3:W=q.createByRandomTwoGradient(e._initParticleVelocity(Q.gradientXMin),e._initParticleVelocity(Q.gradientXMax),e._initParticleVelocity(Q.gradientYMin),e._initParticleVelocity(Q.gradientYMax),e._initParticleVelocity(Q.gradientZMin),e._initParticleVelocity(Q.gradientZMax))}var ae=new ne(W);ae.space=j.space,ae.enbale=j.enable,l.velocityOverLifetime=ae}var se=t.colorOverLifetime;if(se){var oe,le=se.color;switch(le.type){case 0:var he=le.constant;oe=X.createByConstant(new $e(he[0],he[1],he[2],he[3]));break;case 1:oe=X.createByGradient(e._initParticleColor(le.gradient));break;case 2:var ue=le.constantMin,ce=le.constantMax;oe=X.createByRandomTwoConstant(new $e(ue[0],ue[1],ue[2],ue[3]),new $e(ce[0],ce[1],ce[2],ce[3]));break;case 3:oe=X.createByRandomTwoGradient(e._initParticleColor(le.gradientMin),e._initParticleColor(le.gradientMax))}var _e=new z(oe);_e.enbale=se.enable,l.colorOverLifetime=_e}var de=t.sizeOverLifetime;if(de){var me,fe=de.size;switch(fe.type){case 0:me=fe.separateAxes?Z.createByGradientSeparate(e._initParticleSize(fe.gradientX),e._initParticleSize(fe.gradientY),e._initParticleSize(fe.gradientZ)):Z.createByGradient(e._initParticleSize(fe.gradient));break;case 1:if(fe.separateAxes){var pe=fe.constantMinSeparate,ve=fe.constantMaxSeparate;me=Z.createByRandomTwoConstantSeparate(new Qe(pe[0],pe[1],pe[2]),new Qe(ve[0],ve[1],ve[2]))}else me=Z.createByRandomTwoConstant(fe.constantMin,fe.constantMax);break;case 2:me=fe.separateAxes?Z.createByRandomTwoGradientSeparate(e._initParticleSize(fe.gradientXMin),e._initParticleSize(fe.gradientYMin),e._initParticleSize(fe.gradientZMin),e._initParticleSize(fe.gradientXMax),e._initParticleSize(fe.gradientYMax),e._initParticleSize(fe.gradientZMax)):Z.createByRandomTwoGradient(e._initParticleSize(fe.gradientMin),e._initParticleSize(fe.gradientMax))}var ge=new J(me);ge.enbale=de.enable,l.sizeOverLifetime=ge}var Te=t.rotationOverLifetime;if(Te){var xe,Me=Te.angularVelocity;switch(Me.type){case 0:Me.separateAxes||(xe=k.createByConstant(Me.constant*r));break;case 1:Me.separateAxes||(xe=k.createByGradient(e._initParticleRotation(Me.gradient)));break;case 2:Me.separateAxes||(xe=k.createByRandomTwoConstant(Me.constantMin*r,Me.constantMax*r));break;case 3:Me.separateAxes||(xe=k.createByRandomTwoGradient(e._initParticleRotation(Me.gradientMin),e._initParticleRotation(Me.gradientMax)))}var Ee=new K(xe);Ee.enbale=Te.enable,l.rotationOverLifetime=Ee}var ye=t.textureSheetAnimation;if(ye){var Se,Re=ye.frame;switch(Re.type){case 0:Se=H.createByConstant(Re.constant);break;case 1:Se=H.createByOverTime(e._initParticleFrame(Re.overTime));break;case 2:Se=H.createByRandomTwoConstant(Re.constantMin,Re.constantMax);break;case 3:Se=H.createByRandomTwoOverTime(e._initParticleFrame(Re.overTimeMin),e._initParticleFrame(Re.overTimeMax))}var Ae,Ie=ye.startFrame;switch(Ie.type){case 0:Ae=ee.createByConstant(Ie.constant);break;case 1:Ae=ee.createByRandomTwoConstant(Ie.constantMin,Ie.constantMax)}var Ce=new te(Se,Ae);Ce.enbale=ye.enable;var Ve=ye.tiles;Ce.tiles=new Ke(Ve[0],Ve[1]),Ce.type=ye.type,Ce.randomRow=ye.randomRow,Ce.cycles=ye.cycles,l.textureSheetAnimation=Ce}var De=n.particleRender;De.renderMode=t.renderMode,De.stretchedBillboardCameraSpeedScale=t.stretchedBillboardCameraSpeedScale,De.stretchedBillboardSpeedScale=t.stretchedBillboardSpeedScale,De.stretchedBillboardLengthScale=t.stretchedBillboardLengthScale,l.playOnAwake&&L.play()},e._parseHierarchyProp=function(t,n,i){var r=i.customProps,a=r.translate,s=n.transform.localPosition,o=s.elements;o[0]=a[0],o[1]=a[1],o[2]=a[2],n.transform.localPosition=s;var l=r.rotation,h=n.transform.localRotation,u=h.elements;u[0]=l[0],u[1]=l[1],u[2]=l[2],u[3]=l[3],n.transform.localRotation=h;var c=r.scale,_=n.transform.localScale,d=_.elements;switch(d[0]=c[0],d[1]=c[1],d[2]=c[2],n.transform.localScale=_,i.type){case"Sprite3D":break;case"MeshSprite3D":var m=g.getRes(t[i.instanceParams.loadPath]),f=n;f.meshFilter.sharedMesh=m,m.loaded?f.meshRender.sharedMaterials=m.materials:m.once("loaded",f,f._applyMeshMaterials);break;case"ShuriKenParticle3D":var p=n;e._loadParticle(r,p,t)}},e._parseHierarchyNode=function(e){switch(e.type){case"Sprite3D":return new vt;case"MeshSprite3D":return new Lt;case"ShuriKenParticle3D":return new Ot;default:throw new Error("Utils3D:unidentified class type in (.lh) file.")}},e._initStartLife=function(e){for(var t=new W,n=e.startLifetimes,i=0,r=n.length;r>i;i++){var a=n[i];t.add(a.key,a.value)}return t},e._initParticleVelocity=function(e){for(var t=new W,n=e.velocitys,i=0,r=n.length;r>i;i++){var a=n[i];t.add(a.key,a.value)}return t},e._initParticleColor=function(e){var t=new Y,n=e.alphas,i=0,r=0;for(i=0,r=n.length;r>i;i++){var a=n[i];t.addAlpha(a.key,a.value)}var s=e.rgbs;for(i=0,r=s.length;r>i;i++){var o=s[i],l=o.value;t.addRGB(o.key,new Qe(l[0],l[1],l[2]))}return t},e._initParticleSize=function(e){for(var t=new W,n=e.sizes,i=0,r=n.length;r>i;i++){var a=n[i];t.add(a.key,a.value)}return t},e._initParticleRotation=function(e){for(var t=new W,n=e.angularVelocitys,i=0,r=n.length;r>i;i++){var a=n[i];t.add(a.key,a.value/180*Math.PI)}return t},e._initParticleFrame=function(e){for(var t=new j,n=e.frames,i=0,r=n.length;r>i;i++){var a=n[i];t.add(a.key,a.value)}return t},e._parseMaterial=function(e,t,n){var i=n.customProps,r=i.ambientColor;t.ambientColor=new Qe(r[0],r[1],r[2]);var a=i.diffuseColor;t.diffuseColor=new Qe(a[0],a[1],a[2]);var s=i.specularColor;t.specularColor=new $e(s[0],s[1],s[2],s[3]);var o=i.reflectColor;t.reflectColor=new Qe(o[0],o[1],o[2]);var l=i.diffuseTexture.texture2D;l&&(t.diffuseTexture=g.getRes(e[l]));var h=i.normalTexture.texture2D;h&&(t.normalTexture=g.getRes(e[h]));var u=i.specularTexture.texture2D;u&&(t.specularTexture=g.getRes(e[u]));var c=i.emissiveTexture.texture2D;c&&(t.emissiveTexture=g.getRes(e[c]));var _=i.ambientTexture.texture2D;_&&(t.ambientTexture=g.getRes(e[_]));var d=i.reflectTexture.texture2D;d&&(t.reflectTexture=g.getRes(e[d]))},e._computeBoneAndAnimationDatas=function(e,t,n,i,r){var a,s,o=0,l=0,h=n.length/2,u=e.length;for(a=0;u>a;o+=e[a].keyframeWidth,l+=16,a++)laya.d3.utils.Utils3D._rotationTransformScaleSkinAnimation(t[o+7],t[o+8],t[o+9],t[o+3],t[o+4],t[o+5],t[o+6],t[o+0],t[o+1],t[o+2],i,l),0!=a&&(s=16*e[a].parentIndex,laya.d3.utils.Utils3D.mulMatrixByArray(i,s,i,l,i,l));for(a=0;h>a;a+=16)laya.d3.utils.Utils3D.mulMatrixByArrayFast(i,a,n,h+a,r,a)},e._computeAnimationDatas=function(e,t,n){for(var i=e.length/2,r=0;i>r;r+=16)laya.d3.utils.Utils3D.mulMatrixByArrayFast(t,r,e,i+r,n,r)},e._computeBoneAndAnimationDatasByBindPoseMatrxix=function(e,t,n,i,r){var a,s,o=0,l=0,h=e.length;for(a=0;h>a;o+=e[a].keyframeWidth,l+=16,a++)laya.d3.utils.Utils3D._rotationTransformScaleSkinAnimation(t[o+7],t[o+8],t[o+9],t[o+3],t[o+4],t[o+5],t[o+6],t[o+0],t[o+1],t[o+2],i,l),0!=a&&(s=16*e[a].parentIndex,laya.d3.utils.Utils3D.mulMatrixByArray(i,s,i,l,i,l));var u=n.length;for(a=0;u>a;a++){var c=16*a;laya.d3.utils.Utils3D.mulMatrixByArrayAndMatrixFast(i,c,n[a],r,c)}},e._computeAnimationDatasByArrayAndMatrixFast=function(e,t,n){for(var i=e.length,r=0;i>r;r++){var a=16*r;laya.d3.utils.Utils3D.mulMatrixByArrayAndMatrixFast(t,a,e[r],n,a)}},e._computeRootAnimationData=function(e,t,n){for(var i=0,r=0,a=0,s=e.length;s>i;r+=e[i].keyframeWidth,a+=16,i++)laya.d3.utils.Utils3D.createAffineTransformationArray(t[r+0],t[r+1],t[r+2],t[r+3],t[r+4],t[r+5],t[r+6],t[r+7],t[r+8],t[r+9],n,a)},e.generateTangent=function(t,n,i,r,a){for(var s=3,o=n+s,l=new Float32Array(o*(t.length/n)),h=0;h<a.length;h+=3){var u=a[h+0],c=a[h+1],_=a[h+2],d=n*u+i,m=e._tempVector3_0;m.x=t[d+0],m.y=t[d+1],m.z=t[d+2];var f=n*c+i,p=e._tempVector3_1;p.x=t[f+0],p.y=t[f+1],p.z=t[f+2];var v=n*_+i,g=e._tempVector3_2;g.x=t[v+0],g.y=t[v+1],g.z=t[v+2];var T=n*u+r,x=t[T+0],M=t[T+1],E=n*c+r,y=t[E+0],S=t[E+1],R=n*_+r,A=t[R+0],I=t[R+1],C=e._tempVector3_3;Qe.subtract(p,m,C);var V=e._tempVector3_4;Qe.subtract(g,m,V),Qe.scale(C,I-M,C),Qe.scale(V,S-M,V);var D=e._tempVector3_5;Qe.subtract(C,V,D),Qe.scale(D,1/((y-x)*(I-M)-(S-M)*(A-x)),D);var L=0;for(L=0;n>L;L++)l[o*u+L]=t[n*u+L];for(L=0;s>L;L++)l[o*u+n+L]=+D.elements[L];for(L=0;n>L;L++)l[o*c+L]=t[n*c+L];for(L=0;s>L;L++)l[o*c+n+L]=+D.elements[L];for(L=0;n>L;L++)l[o*_+L]=t[n*_+L];for(L=0;s>L;L++)l[o*_+n+L]=+D.elements[L]}for(h=0;h<l.length;h+=o){var O=o*h+n,b=e._tempVector3_6;b.x=l[O+0],b.y=l[O+1],b.z=l[O+2],Qe.normalize(b,b),l[O+0]=b.x,l[O+1]=b.y,l[O+2]=b.z}return l},e.getVertexTangentDeclaration=function(e){for(var t=!1,n=!1,i=!1,r=!1,a=!1,s=!1,o=!1,l=0;l<e.length;l++)switch(e[l].elementUsage){case"POSITION":t=!0;break;case"NORMAL":n=!0;break;case"COLOR":i=!0;break;case"UV":r=!0;break;case"UV1":a=!0;break;case"BLENDWEIGHT":s=!0;break;case"BLENDINDICES":o=!0}var h;return t&&n&&i&&r&&a&&s&&o&&(h=Ie.vertexDeclaration),t&&n&&i&&r&&s&&o?h=De.vertexDeclaration:t&&n&&r&&a&&s&&o?h=we.vertexDeclaration:t&&n&&r&&s&&o?h=Fe.vertexDeclaration:t&&n&&i&&s&&o?h=Ee.vertexDeclaration:t&&n&&i&&r&&a?h=Ce.vertexDeclaration:t&&n&&i&&r?h=Le.vertexDeclaration:t&&n&&r&&a?h=Ne.vertexDeclaration:t&&n&&r?h=Ue.vertexDeclaration:t&&n&&i&&(h=ye.vertexDeclaration),h},e.transformVector3ArrayByQuat=function(e,t,n,i,r){var a=n.elements,s=e[t],o=e[t+1],l=e[t+2],h=a[0],u=a[1],c=a[2],_=a[3],d=_*s+u*l-c*o,m=_*o+c*s-h*l,f=_*l+h*o-u*s,p=-h*s-u*o-c*l;i[r]=d*_+p*-h+m*-c-f*-u,i[r+1]=m*_+p*-u+f*-h-d*-c,i[r+2]=f*_+p*-c+d*-u-m*-h},e.mulMatrixByArray=function(t,n,i,r,a,s){var o,l,h,u,c;if(a===i){for(i=e._tempArray16_3,o=0;16>o;++o)i[o]=a[s+o];r=0}for(o=0;4>o;o++)l=t[n+o],h=t[n+o+4],u=t[n+o+8],c=t[n+o+12],a[s+o]=l*i[r+0]+h*i[r+1]+u*i[r+2]+c*i[r+3],a[s+o+4]=l*i[r+4]+h*i[r+5]+u*i[r+6]+c*i[r+7],a[s+o+8]=l*i[r+8]+h*i[r+9]+u*i[r+10]+c*i[r+11],a[s+o+12]=l*i[r+12]+h*i[r+13]+u*i[r+14]+c*i[r+15]},e.mulMatrixByArrayFast=function(e,t,n,i,r,a){var s,o,l,h,u;for(s=0;4>s;s++)o=e[t+s],l=e[t+s+4],h=e[t+s+8],u=e[t+s+12],r[a+s]=o*n[i+0]+l*n[i+1]+h*n[i+2]+u*n[i+3],r[a+s+4]=o*n[i+4]+l*n[i+5]+h*n[i+6]+u*n[i+7],r[a+s+8]=o*n[i+8]+l*n[i+9]+h*n[i+10]+u*n[i+11],r[a+s+12]=o*n[i+12]+l*n[i+13]+h*n[i+14]+u*n[i+15]},e.mulMatrixByArrayAndMatrixFast=function(e,t,n,i,r){var a,s,o,l,h,u=n.elements,c=u[0],_=u[1],d=u[2],m=u[3],f=u[4],p=u[5],v=u[6],g=u[7],T=u[8],x=u[9],M=u[10],E=u[11],y=u[12],S=u[13],R=u[14],A=u[15],I=t,C=t+4,V=t+8,D=t+12,L=r,O=r+4,b=r+8,P=r+12;for(a=0;4>a;a++)s=e[I+a],o=e[C+a],l=e[V+a],h=e[D+a],i[L+a]=s*c+o*_+l*d+h*m,i[O+a]=s*f+o*p+l*v+h*g,i[b+a]=s*T+o*x+l*M+h*E,i[P+a]=s*y+o*S+l*R+h*A},e.createAffineTransformationArray=function(e,t,n,i,r,a,s,o,l,h,u,c){var _=i+i,d=r+r,m=a+a,f=i*_,p=i*d,v=i*m,g=r*d,T=r*m,x=a*m,M=s*_,E=s*d,y=s*m;u[c+0]=(1-(g+x))*o,u[c+1]=(p+y)*o,u[c+2]=(v-E)*o,u[c+3]=0,u[c+4]=(p-y)*l,u[c+5]=(1-(f+x))*l,u[c+6]=(T+M)*l,u[c+7]=0,u[c+8]=(v+E)*h,u[c+9]=(T-M)*h,u[c+10]=(1-(f+g))*h,u[c+11]=0,u[c+12]=e,u[c+13]=t,u[c+14]=n,u[c+15]=1},e.transformVector3ArrayToVector3ArrayCoordinate=function(t,n,i,r,a){var s=e._tempArray4_0,o=t[n+0],l=t[n+1],h=t[n+2],u=i.elements;s[0]=o*u[0]+l*u[4]+h*u[8]+u[12],s[1]=o*u[1]+l*u[5]+h*u[9]+u[13],s[2]=o*u[2]+l*u[6]+h*u[10]+u[14],s[3]=1/(o*u[3]+l*u[7]+h*u[11]+u[15]),r[a+0]=s[0]*s[3],r[a+1]=s[1]*s[3],r[a+2]=s[2]*s[3]},e.convert3DCoordTo2DScreenCoord=function(e,t){var n=e.elements,i=t.elements;i[0]=-le.clientWidth/2+n[0],i[1]=le.clientHeight/2-n[1],i[2]=n[2]},e.getURLVerion=function(e){var t=e.indexOf("?");return t>=0?e.substr(t):null},e._tempVector3_0=new Qe,e._tempVector3_1=new Qe,e._tempVector3_2=new Qe,e._tempVector3_3=new Qe,e._tempVector3_4=new Qe,e._tempVector3_5=new Qe,e._tempVector3_6=new Qe,e._tempArray4_0=new Float32Array(4),e._tempArray16_0=new Float32Array(16),e._tempArray16_1=new Float32Array(16),e._tempArray16_2=new Float32Array(16),e._tempArray16_3=new Float32Array(16),i(e,["_typeToFunO",function(){return this._typeToFunO={INT16:"writeInt16",SHORT:"writeInt16",UINT16:"writeUint16",UINT32:"writeUint32",FLOAT32:"writeFloat32",INT:"writeInt32",UINT:"writeUint32",BYTE:"writeByte",STRING:"writeUTFString"}}]),e}(),at=(function(){function e(){}return r(e,"Laya3D"),e._changeWebGLSize=function(e,t){w.onStageResize(e,t),le.clientWidth=e,le.clientHeight=t},e._initShader=function(){C.addInclude("LightHelper.glsl","\nstruct DirectionLight\n{\n vec3 Direction;\n vec3 Diffuse;\n vec3 Ambient;\n vec3 Specular;\n};\n\nstruct PointLight\n{\n vec3 Diffuse;\n vec3 Ambient;\n vec3 Specular;\n vec3 Attenuation;\n vec3 Position;\n float Range;\n};\n\nstruct SpotLight\n{\n vec3 Diffuse;\n vec3 Ambient;\n vec3 Specular;\n vec3 Attenuation;\n vec3 Position;\n vec3 Direction;\n float Spot;\n float Range;\n};\n\n\nvoid computeDirectionLight(in vec3 matDif,in vec3 matAmb,in vec4 matSpe,in DirectionLight dirLight,in vec3 normal,in vec3 toEye,out vec3 dif,out vec3 amb,out vec3 spec)\n{\n dif=vec3(0.0);//不初始化在IOS中闪烁,PC中不会闪烁\n amb=vec3(0.0);\n spec=vec3(0.0);\n vec3 lightVec=-normalize(dirLight.Direction);\n \n amb=matAmb*dirLight.Ambient;\n \n float diffuseFactor=dot(lightVec, normal);\n \n if(diffuseFactor>0.0)\n {\n vec3 v = reflect(-lightVec, normal);\n float specFactor = pow(max(dot(v, toEye), 0.0), matSpe.w);\n \n dif = diffuseFactor * matDif * dirLight.Diffuse;\n spec = specFactor * matSpe.rgb * dirLight.Specular;\n }\n \n}\n\nvoid computePointLight(in vec3 matDif,in vec3 matAmb,in vec4 matSpe,in PointLight poiLight, in vec3 pos,in vec3 normal,in vec3 toEye,out vec3 dif,out vec3 amb,out vec3 spec)\n{\n dif=vec3(0.0);\n amb=vec3(0.0);\n spec=vec3(0.0);\n vec3 lightVec = poiLight.Position - pos;\n \n float d = length(lightVec);\n \n if( d > poiLight.Range )\n return;\n \n lightVec /= d; \n \n amb = matAmb * poiLight.Ambient; \n\n float diffuseFactor = dot(lightVec, normal);\n\n if( diffuseFactor > 0.0 )\n {\n vec3 v= reflect(-lightVec, normal);\n float specFactor = pow(max(dot(v, toEye), 0.0), matSpe.w);\n \n dif = diffuseFactor * matDif * poiLight.Diffuse;\n spec = specFactor * matSpe.rgb * poiLight.Specular;\n }\n\n float attenuate = 1.0 / dot(poiLight.Attenuation, vec3(1.0, d, d*d));\n\n dif *= attenuate;\n spec*= attenuate;\n}\n\nvoid ComputeSpotLight(in vec3 matDif,in vec3 matAmb,in vec4 matSpe,in SpotLight spoLight,in vec3 pos, in vec3 normal,in vec3 toEye,out vec3 dif,out vec3 amb,out vec3 spec)\n{\n amb = vec3(0.0);\n dif =vec3(0.0);\n spec= vec3(0.0);\n vec3 lightVec = spoLight.Position - pos;\n \n float d = length(lightVec);\n \n if( d > spoLight.Range)\n return;\n \n lightVec /= d; \n \n amb = matAmb * spoLight.Ambient; \n\n float diffuseFactor = dot(lightVec, normal);\n\n if(diffuseFactor > 0.0)\n {\n vec3 v= reflect(-lightVec, normal);\n float specFactor = pow(max(dot(v, toEye), 0.0), matSpe.w);\n \n dif = diffuseFactor * matDif * spoLight.Diffuse;\n spec = specFactor * matSpe.rgb * spoLight.Specular;\n }\n \n float spot = pow(max(dot(-lightVec, normalize(spoLight.Direction)), 0.0), spoLight.Spot);\n\n float attenuate = spot/dot(spoLight.Attenuation, vec3(1.0, d, d*d));\n\n amb *= spot;\n dif *= attenuate;\n spec*= attenuate;\n}\n\nvec3 NormalSampleToWorldSpace(vec3 normalMapSample, vec3 unitNormal, vec3 tangent)\n{\n vec3 normalT = 2.0*normalMapSample - 1.0;\n\n // Build orthonormal basis.\n vec3 N = normalize(unitNormal);\n vec3 T = normalize(tangent- dot(tangent, N)*N);\n vec3 B = cross(T, N);\n\n mat3 TBN = mat3(T, B, N);\n\n // Transform from tangent space to world space.\n vec3 bumpedNormal = TBN*normalT;\n\n return bumpedNormal;\n}\n"),C.addInclude("VRHelper.glsl","\nvec4 DistortFishEye(vec4 p)\n{\n vec2 v = p.xy / p.w;\n float radius = length(v);// Convert to polar coords\n if (radius > 0.0)\n {\n float theta = atan(v.y,v.x);\n \n radius = pow(radius, 0.93);// Distort:\n\n v.x = radius * cos(theta);// Convert back to Cartesian\n v.y = radius * sin(theta);\n p.xy = v.xy * p.w;\n }\n return p;\n}");var e,t,n={a_Position:"POSITION",a_Color:"COLOR",a_Normal:"NORMAL",a_Texcoord0:"UV",a_Texcoord1:"UV1",a_TexcoordNext0:"NEXTUV",a_BoneWeights:"BLENDWEIGHT",a_BoneIndices:"BLENDINDICES",a_Tangent0:"TANGENT0",u_CameraPos:"CAMERAPOS",u_FogStart:"FOGSTART",u_FogRange:"FOGRANGE",u_FogColor:"FOGCOLOR","u_DirectionLight.Direction":"LIGHTDIRECTION","u_DirectionLight.Diffuse":"LIGHTDIRDIFFUSE","u_DirectionLight.Ambient":"LIGHTDIRAMBIENT","u_DirectionLight.Specular":"LIGHTDIRSPECULAR","u_PointLight.Position":"POINTLIGHTPOS","u_PointLight.Range":"POINTLIGHTRANGE","u_PointLight.Attenuation":"POINTLIGHTATTENUATION","u_PointLight.Diffuse":"POINTLIGHTDIFFUSE","u_PointLight.Ambient":"POINTLIGHTAMBIENT","u_PointLight.Specular":"POINTLIGHTSPECULAR","u_SpotLight.Position":"SPOTLIGHTPOS","u_SpotLight.Direction":"SPOTLIGHTDIRECTION","u_SpotLight.Range":"SPOTLIGHTRANGE","u_SpotLight.Spot":"SPOTLIGHTSPOT","u_SpotLight.Attenuation":"SPOTLIGHTATTENUATION","u_SpotLight.Diffuse":"SPOTLIGHTDIFFUSE","u_SpotLight.Ambient":"SPOTLIGHTAMBIENT","u_SpotLight.Specular":"SPOTLIGHTSPECULAR",u_WorldMat:"MATRIX1",u_DiffuseTexture:"DIFFUSETEXTURE",u_SpecularTexture:"SPECULARTEXTURE",u_NormalTexture:"NORMALTEXTURE",u_AmbientTexture:"AMBIENTTEXTURE",u_ReflectTexture:"REFLECTTEXTURE",u_MvpMatrix:"MVPMATRIX",u_Bones:"MATRIXARRAY0",u_Albedo:"ALBEDO",u_AlphaTestValue:"ALPHATESTVALUE",u_UVMatrix:"MATRIX2",u_UVAge:"FLOAT0",u_UVAniAge:"UVAGEX",u_MaterialDiffuse:"MATERIALDIFFUSE",u_MaterialAmbient:"MATERIALAMBIENT",u_MaterialSpecular:"MATERIALSPECULAR",u_MaterialReflect:"MATERIALREFLECT"},i=C.nameKey.add("SIMPLE");e='#include?VR "VRHelper.glsl";\nattribute vec4 a_Position;\nuniform mat4 u_MvpMatrix;\n\n\n\n#ifdef DIFFUSEMAP||((DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT)&&(COLOR&&SPECULARMAP||NORMALMAP))\nattribute vec2 a_Texcoord0;\nvarying vec2 v_Texcoord0;\n #ifdef MIXUV\n attribute vec2 a_TexcoordNext0;\n uniform float u_UVAge;\n #endif\n #ifdef UVTRANSFORM \n uniform mat4 u_UVMatrix;\n #endif\n#endif\n\n#ifdef AMBIENTMAP\nattribute vec2 a_Texcoord1;\nvarying vec2 v_Texcoord1;\n#endif\n\n#ifdef COLOR\nattribute vec4 a_Color;\nvarying vec4 v_Color;\n#endif\n\n#ifdef BONE\nattribute vec4 a_BoneIndices;\nattribute vec4 a_BoneWeights;\nconst int c_MaxBoneCount = 24;\nuniform mat4 u_Bones[c_MaxBoneCount];\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||REFLECTMAP\nattribute vec3 a_Normal;\nvarying vec3 v_Normal;\n#endif\n\n#ifdef (DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||REFLECTMAP)&&NORMALMAP\nattribute vec3 a_Tangent0;\nvarying vec3 v_Tangent0;\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||FOG||REFLECTMAP\nuniform mat4 u_WorldMat;\nvarying vec3 v_PositionWorld;\n#endif\n\n\nvoid main()\n{\n #ifdef BONE\n mat4 skinTransform=mat4(0.0);\n skinTransform += u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\n skinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\n skinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\n skinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\n vec4 position=skinTransform*a_Position;\n #ifdef VR\n gl_Position = DistortFishEye(u_MvpMatrix * position);\n #else\n gl_Position = u_MvpMatrix * position;\n #endif\n #else\n #ifdef VR\n gl_Position = DistortFishEye(u_MvpMatrix * a_Position);\n #else\n gl_Position = u_MvpMatrix * a_Position;\n #endif\n #endif\n \n\n #ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||REFLECTMAP\n mat3 worldMat;\n #ifdef BONE\n worldMat=mat3(u_WorldMat*skinTransform);\n #else\n worldMat=mat3(u_WorldMat);\n #endif \n v_Normal=worldMat*a_Normal;\n #ifdef (DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT)&&NORMALMAP\n v_Tangent0=worldMat*a_Tangent0;\n #endif\n #endif\n \n #ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||FOG\n #ifdef BONE\n v_PositionWorld=(u_WorldMat*position).xyz;\n #else\n v_PositionWorld=(u_WorldMat*a_Position).xyz;\n #endif\n #endif\n \n#ifdef DIFFUSEMAP||((DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT)&&(COLOR&&SPECULARMAP||NORMALMAP))\n #ifdef MIXUV\n v_Texcoord0=mix(a_Texcoord0,a_TexcoordNext0,u_UVAge);\n #else\n v_Texcoord0=a_Texcoord0;\n #endif\n #ifdef UVTRANSFORM\n v_Texcoord0=(u_UVMatrix*vec4(v_Texcoord0,0.0,1.0)).xy;\n #endif\n#endif\n\n#ifdef AMBIENTMAP\nv_Texcoord1=a_Texcoord1;\n#endif\n\n \n#ifdef COLOR\nv_Color=a_Color;\n#endif\n}',t='#ifdef FSHIGHPRECISION\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\n#include?DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT "LightHelper.glsl";\n\nuniform vec4 u_Albedo;\n\n#ifdef ALPHATEST\nuniform float u_AlphaTestValue;\n#endif\n\n#ifdef DIFFUSEMAP\nuniform sampler2D u_DiffuseTexture;\n#endif\n\n#ifdef REFLECTMAP\nuniform samplerCube u_ReflectTexture;\nuniform vec3 u_MaterialReflect;\n#endif\n\n#ifdef DIFFUSEMAP||((DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT)&&(COLOR&&SPECULARMAP||NORMALMAP))\nvarying vec2 v_Texcoord0;\n#endif\n\n#ifdef AMBIENTMAP\nvarying vec2 v_Texcoord1;\nuniform sampler2D u_AmbientTexture;\n#endif\n\n#ifdef COLOR\nvarying vec4 v_Color;\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT\nuniform vec3 u_MaterialDiffuse;\nuniform vec4 u_MaterialSpecular;\n #ifdef (DIFFUSEMAP||COLOR)&&SPECULARMAP \n uniform sampler2D u_SpecularTexture;\n #endif\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||AMBIENTMAP\nuniform vec3 u_MaterialAmbient;\n#endif\n\n#ifdef FOG\nuniform float u_FogStart;\nuniform float u_FogRange;\nuniform vec3 u_FogColor;\n#endif\n\n#ifdef MIXUV\nuniform float u_UVAniAge;\n#endif\n\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||REFLECTMAP\nvarying vec3 v_Normal;\n#endif\n\n#ifdef (DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT)&&NORMALMAP\nuniform sampler2D u_NormalTexture;\nvarying vec3 v_Tangent0;\n#endif\n\n#ifdef DIRECTIONLIGHT\nuniform DirectionLight u_DirectionLight;\n#endif\n\n#ifdef POINTLIGHT\nuniform PointLight u_PointLight;\n#endif\n\n#ifdef SPOTLIGHT\nuniform SpotLight u_SpotLight;\n#endif\n\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||FOG||REFLECTMAP\nuniform vec3 u_CameraPos;\nvarying vec3 v_PositionWorld;\n#endif\n\n\nvoid main()\n{\n #ifdef DIFFUSEMAP&&!COLOR\n gl_FragColor=texture2D(u_DiffuseTexture, v_Texcoord0);\n #endif \n \n #ifdef COLOR&&!DIFFUSEMAP\n gl_FragColor=v_Color;\n #endif \n \n #ifdef DIFFUSEMAP&&COLOR\n vec4 texColor=texture2D(u_DiffuseTexture, v_Texcoord0);\n gl_FragColor=texColor*v_Color;\n #endif\n \n #ifdef !DIFFUSEMAP&&!COLOR\n gl_FragColor=vec4(1.0,1.0,1.0,1.0);\n #endif \n \n #ifdef AMBIENTMAP\n gl_FragColor.rgb=gl_FragColor.rgb*(u_MaterialAmbient+texture2D(u_AmbientTexture, v_Texcoord1).rgb);\n #endif \n \n gl_FragColor=gl_FragColor*u_Albedo;\n \n #ifdef ALPHATEST\n if(gl_FragColor.a-u_AlphaTestValue<0.0)\n discard;\n #endif\n \n \n #ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||REFLECTMAP\n vec3 normal;\n #ifdef (DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT)&&NORMALMAP\n vec3 normalMapSample = texture2D(u_NormalTexture, v_Texcoord0).rgb;\n normal = normalize(NormalSampleToWorldSpace(normalMapSample, v_Normal, v_Tangent0));\n #else\n normal = normalize(v_Normal);\n #endif\n #endif\n \n #ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT\n vec3 diffuse = vec3(0.0);\n vec3 ambient = vec3(0.0);\n vec3 specular= vec3(0.0);\n vec3 dif, amb, spe;\n #endif\n \n #ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||FOG||REFLECTMAP\n vec3 toEye;\n #ifdef FOG\n toEye=u_CameraPos-v_PositionWorld;\n float toEyeLength=length(toEye);\n toEye/=toEyeLength;\n #else\n toEye=normalize(u_CameraPos-v_PositionWorld);\n #endif\n #endif\n \n #ifdef DIRECTIONLIGHT\n computeDirectionLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_DirectionLight,normal,toEye, dif, amb, spe);\n diffuse+=dif;\n ambient+=amb;\n specular+=spe;\n #endif\n \n #ifdef POINTLIGHT\n computePointLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_PointLight,v_PositionWorld,normal,toEye, dif, amb, spe);\n diffuse+=dif;\n ambient+=amb;\n specular+=spe;\n #endif\n\n #ifdef SPOTLIGHT\n ComputeSpotLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_SpotLight,v_PositionWorld,normal,toEye, dif, amb, spe);\n diffuse+=dif;\n ambient+=amb;\n specular+=spe;\n #endif\n \n\n \n \n \n #ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT\n #ifdef (DIFFUSEMAP||COLOR)&&SPECULARMAP\n specular =specular*texture2D(u_SpecularTexture, v_Texcoord0).rgb;\n #endif\n gl_FragColor =vec4( gl_FragColor.rgb*(ambient + diffuse) + specular,gl_FragColor.a);\n #endif\n \n #ifdef REFLECTMAP\n vec3 incident = -toEye;\n vec3 reflectionVector = reflect(incident,normal);\n vec3 reflectionColor = textureCube(u_ReflectTexture,reflectionVector).rgb;\n gl_FragColor.rgb += u_MaterialReflect*reflectionColor;\n #endif\n \n #ifdef FOG\n float lerpFact=clamp((toEyeLength-u_FogStart)/u_FogRange,0.0,1.0);\n gl_FragColor.rgb=mix(gl_FragColor.rgb,u_FogColor,lerpFact);\n #endif\n}\n\n',
|
||
C.preCompile(i,e,t,n);var r=C.nameKey.add("SIMPLEVEXTEX");e='#include?DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT "LightHelper.glsl";\n\nattribute vec4 a_Position;\nuniform mat4 u_MvpMatrix;\n\n#include?VR "VRHelper.glsl";\n\n\n\n#ifdef DIFFUSEMAP||((DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT)&&COLOR&&SPECULARMAP)\nattribute vec2 a_Texcoord0;\nvarying vec2 v_Texcoord0;\n #ifdef MIXUV\n attribute vec2 a_TexcoordNext0;\n uniform float u_UVAge;\n #endif\n #ifdef UVTRANSFORM\n uniform mat4 u_UVMatrix;\n #endif\n#endif\n\n#ifdef AMBIENTMAP\nattribute vec2 a_Texcoord1;\nvarying vec2 v_Texcoord1;\n#endif\n\n\n#ifdef COLOR\nattribute vec4 a_Color;\nvarying vec4 v_Color;\n#endif\n\n#ifdef BONE\nattribute vec4 a_BoneIndices;\nattribute vec4 a_BoneWeights;\nconst int c_MaxBoneCount = 24;\nuniform mat4 u_Bones[c_MaxBoneCount];\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||REFLECTMAP\nattribute vec3 a_Normal;\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||FOG||REFLECTMAP\nuniform mat4 u_WorldMat;\nuniform vec3 u_CameraPos;\n#endif\n\n#ifdef DIRECTIONLIGHT\nuniform DirectionLight u_DirectionLight;\n#endif\n\n#ifdef POINTLIGHT\nuniform PointLight u_PointLight;\n#endif\n\n#ifdef SPOTLIGHT\nuniform SpotLight u_SpotLight;\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT\nuniform vec3 u_MaterialDiffuse;\nuniform vec4 u_MaterialSpecular;\n\nvarying vec3 v_Diffuse;\nvarying vec3 v_Ambient;\nvarying vec3 v_Specular;\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||AMBIENTMAP\nuniform vec3 u_MaterialAmbient;\n#endif\n\n#ifdef FOG\nvarying float v_ToEyeLength;\n#endif\n\n#ifdef REFLECTMAP\nvarying vec3 v_ToEye;\nvarying vec3 v_Normal;\n#endif\n\n\nvoid main()\n{\n #ifdef BONE\n mat4 skinTransform=mat4(0.0);\n skinTransform += u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\n skinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\n skinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\n skinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\n vec4 position=skinTransform*a_Position;\n #ifdef VR\n gl_Position = DistortFishEye(u_MvpMatrix * position);\n #else\n gl_Position = u_MvpMatrix * position;\n #endif\n #else\n #ifdef VR\n gl_Position = DistortFishEye(u_MvpMatrix * a_Position);\n #else\n gl_Position = u_MvpMatrix * a_Position;\n #endif\n #endif\n \n \n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||REFLECTMAP\n #ifdef BONE\n vec3 normal=normalize( mat3(u_WorldMat*skinTransform)*a_Normal);\n #else\n vec3 normal=normalize( mat3(u_WorldMat)*a_Normal);\n #endif\n \n #ifdef REFLECTMAP\n v_Normal=normal;\n #endif\n#endif\n \n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT\n v_Diffuse=vec3(0.0);\n v_Ambient=vec3(0.0);\n v_Specular=vec3(0.0);\n vec3 dif, amb, spe;\n#endif\n\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||FOG||REFLECTMAP\n #ifdef BONE\n vec3 positionWorld=(u_WorldMat*position).xyz;\n #else\n vec3 positionWorld=(u_WorldMat*a_Position).xyz;\n #endif\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||FOG||REFLECTMAP\nvec3 toEye;\n #ifdef FOG\n toEye=u_CameraPos-positionWorld;\n v_ToEyeLength=length(toEye);\n toEye/=v_ToEyeLength;\n #else\n toEye=normalize(u_CameraPos-positionWorld);\n #endif\n \n #ifdef REFLECTMAP\n v_ToEye=toEye;\n #endif\n#endif\n \n#ifdef DIRECTIONLIGHT\ncomputeDirectionLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_DirectionLight,normal,toEye, dif, amb, spe);\nv_Diffuse+=dif;\nv_Ambient+=amb;\nv_Specular+=spe;\n#endif\n \n#ifdef POINTLIGHT\ncomputePointLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_PointLight,positionWorld,normal,toEye, dif, amb, spe);\nv_Diffuse+=dif;\nv_Ambient+=amb;\nv_Specular+=spe;\n#endif\n\n#ifdef SPOTLIGHT\nComputeSpotLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_SpotLight,positionWorld,normal,toEye, dif, amb, spe);\nv_Diffuse+=dif;\nv_Ambient+=amb;\nv_Specular+=spe;\n#endif\n \n#ifdef DIFFUSEMAP||((DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT)&&COLOR&&SPECULARMAP)\n #ifdef MIXUV\n v_Texcoord0=mix(a_Texcoord0,a_TexcoordNext0,u_UVAge);\n #else\n v_Texcoord0=a_Texcoord0;\n #endif\n #ifdef UVTRANSFORM\n v_Texcoord0=(u_UVMatrix*vec4(v_Texcoord0,0.0,1.0)).xy;\n #endif\n#endif\n\n#ifdef AMBIENTMAP\nv_Texcoord1=a_Texcoord1;\n#endif\n \n#ifdef COLOR\nv_Color=a_Color;\n#endif\n}',t="#ifdef FSHIGHPRECISION\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform vec4 u_Albedo;\n\n#ifdef ALPHATEST\nuniform float u_AlphaTestValue;\n#endif\n\n#ifdef DIFFUSEMAP\nuniform sampler2D u_DiffuseTexture;\n#endif\n\n#ifdef REFLECTMAP\nuniform samplerCube u_ReflectTexture;\nuniform vec3 u_MaterialReflect;\n#endif\n\n\n#ifdef DIFFUSEMAP||((DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT)&&COLOR&&SPECULARMAP)\nvarying vec2 v_Texcoord0;\n#endif\n\n#ifdef AMBIENTMAP\nvarying vec2 v_Texcoord1;\nuniform sampler2D u_AmbientTexture;\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT||AMBIENTMAP\nuniform vec3 u_MaterialAmbient;\n#endif\n\n#ifdef COLOR\nvarying vec4 v_Color;\n#endif\n\n#ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT\nvarying vec3 v_Diffuse;\nvarying vec3 v_Ambient;\nvarying vec3 v_Specular;\n #ifdef (DIFFUSEMAP||COLOR)&&SPECULARMAP\n uniform sampler2D u_SpecularTexture;\n #endif\n#endif\n\n#ifdef FOG\nuniform float u_FogStart;\nuniform float u_FogRange;\nuniform vec3 u_FogColor;\nvarying float v_ToEyeLength;\n#endif\n\n#ifdef MIXUV\nuniform float u_UVAniAge;\n#endif\n\n#ifdef REFLECTMAP\nvarying vec3 v_Normal;\nvarying vec3 v_ToEye;\n#endif\n\n\nvoid main()\n{\n #ifdef DIFFUSEMAP&&!COLOR\n gl_FragColor=texture2D(u_DiffuseTexture, v_Texcoord0);\n #endif \n \n #ifdef COLOR&&!DIFFUSEMAP\n gl_FragColor=v_Color;\n #endif \n \n #ifdef DIFFUSEMAP&&COLOR\n vec4 texColor=texture2D(u_DiffuseTexture, v_Texcoord0);\n gl_FragColor=texColor*v_Color;\n #endif\n \n #ifdef !DIFFUSEMAP&&!COLOR\n gl_FragColor=vec4(1.0,1.0,1.0,1.0);\n #endif \n \n #ifdef AMBIENTMAP\n gl_FragColor.rgb=gl_FragColor.rgb*(u_MaterialAmbient+texture2D(u_AmbientTexture, v_Texcoord1).rgb);\n #endif \n \n gl_FragColor=gl_FragColor*u_Albedo;\n \n #ifdef ALPHATEST\n if(gl_FragColor.a-u_AlphaTestValue<0.0)\n discard;\n #endif\n \n \n #ifdef REFLECTMAP\n vec3 normal=normalize(v_Normal);\n #endif \n\n \n #ifdef DIRECTIONLIGHT||POINTLIGHT||SPOTLIGHT\n #ifdef (DIFFUSEMAP||COLOR)&&SPECULARMAP\n vec3 specular =v_Specular*texture2D(u_SpecularTexture,v_Texcoord0).rgb;\n gl_FragColor =vec4( gl_FragColor.rgb*(v_Ambient + v_Diffuse)+specular,gl_FragColor.a);\n #else\n gl_FragColor =vec4( gl_FragColor.rgb*(v_Ambient + v_Diffuse)+v_Specular,gl_FragColor.a);\n #endif\n #endif\n \n #ifdef REFLECTMAP\n vec3 incident = -v_ToEye;\n vec3 reflectionVector = reflect(incident,v_Normal);\n vec3 reflectionColor = textureCube(u_ReflectTexture,reflectionVector).rgb;\n gl_FragColor.rgb += u_MaterialReflect*reflectionColor;\n #endif\n \n #ifdef FOG\n float lerpFact=clamp((v_ToEyeLength-u_FogStart)/u_FogRange,0.0,1.0);\n gl_FragColor.rgb=mix(gl_FragColor.rgb,u_FogColor,lerpFact);\n #endif\n}\n\n",C.preCompile(r,e,t,n),n={a_Position:"POSITION",a_Texcoord:"UV",u_FogStart:"FOGSTART",u_FogRange:"FOGRANGE",u_FogColor:"FOGCOLOR",u_CameraPos:"CAMERAPOS",u_WorldMat:"MATRIX1",u_BlendTexture:"DIFFUSETEXTURE",u_LayerTexture0:"NORMALTEXTURE",u_LayerTexture1:"SPECULARTEXTURE",u_LayerTexture2:"EMISSIVETEXTURE",u_LayerTexture3:"AMBIENTTEXTURE",u_MvpMatrix:"MVPMATRIX",u_Albedo:"ALBEDO",u_Ambient:"MATERIALAMBIENT",u_UVMatrix:"MATRIX2"};var a=C.nameKey.add("TERRAIN");e='#include?VR "VRHelper.glsl";\nattribute vec4 a_Position;\nuniform mat4 u_MvpMatrix;\nuniform mat4 u_UVMatrix;\n\n#ifdef DIFFUSEMAP&&NORMALMAP&&SPECULARMAP&&EMISSIVEMAP&&AMBIENTMAP\nattribute vec2 a_Texcoord;\nvarying vec2 v_Texcoord;\nvarying vec2 v_TiledTexcoord;\n#endif\n\n#ifdef FOG\nuniform mat4 u_WorldMat;\nvarying vec3 v_PositionWorld;\n#endif\n\n\nvoid main()\n{\n #ifdef VR\n gl_Position = DistortFishEye(u_MvpMatrix * a_Position);\n #else\n gl_Position = u_MvpMatrix * a_Position;\n #endif\n \n #ifdef FOG\n v_PositionWorld=(u_WorldMat*a_Position).xyz;\n #endif\n \n #ifdef DIFFUSEMAP&&NORMALMAP&&SPECULARMAP&&EMISSIVEMAP&&AMBIENTMAP\n v_Texcoord=a_Texcoord;\n v_TiledTexcoord=(u_UVMatrix*vec4(a_Texcoord,0.0,1.0)).xy;\n #endif\n}',t="#ifdef FSHIGHPRECISION\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform vec4 u_Albedo;\nuniform vec3 u_Ambient;\n\n#ifdef FOG\nuniform vec3 u_CameraPos;\nvarying vec3 v_PositionWorld;\n\nuniform float u_FogStart;\nuniform float u_FogRange;\nuniform vec3 u_FogColor;\n#endif\n\n#ifdef DIFFUSEMAP&&NORMALMAP&&SPECULARMAP&&EMISSIVEMAP&&AMBIENTMAP\n varying vec2 v_Texcoord;\n varying vec2 v_TiledTexcoord;\n uniform sampler2D u_BlendTexture;\n uniform sampler2D u_LayerTexture0;\n uniform sampler2D u_LayerTexture1;\n uniform sampler2D u_LayerTexture2;\n uniform sampler2D u_LayerTexture3;\n#endif\n\nvoid main()\n{ \n #ifdef DIFFUSEMAP&&NORMALMAP&&SPECULARMAP&&EMISSIVEMAP&&AMBIENTMAP\n vec4 blend=texture2D(u_BlendTexture, v_Texcoord);\n vec4 c0=texture2D(u_LayerTexture0, v_TiledTexcoord);\n vec4 c1=texture2D(u_LayerTexture1, v_TiledTexcoord);\n vec4 c2=texture2D(u_LayerTexture2, v_TiledTexcoord);\n vec4 c3=texture2D(u_LayerTexture3, v_TiledTexcoord);\n vec4 texColor = c0;\n texColor = mix(texColor, c1, blend.r);\n texColor = mix(texColor, c2, blend.g);\n texColor = mix(texColor, c3, blend.b);\n gl_FragColor=vec4(texColor.rgb*u_Ambient.rgb*blend.a,1.0);\n gl_FragColor=gl_FragColor*u_Albedo;\n #endif \n \n #ifdef FOG\n vec3 toEye=u_CameraPos-v_PositionWorld;\n float toEyeLength=length(toEye);\n \n float lerpFact=clamp((toEyeLength-u_FogStart)/u_FogRange,0.0,1.0);\n gl_FragColor.rgb=mix(gl_FragColor.rgb,u_FogColor,lerpFact);\n #endif\n}\n\n",C.preCompile(a,e,t,n),n={a_CornerTextureCoordinate:"CORNERTEXTURECOORDINATE",a_Position:"POSITION",a_Velocity:"VELOCITY",a_StartColor:"STARTCOLOR",a_EndColor:"ENDCOLOR",a_SizeRotation:"SIZEROTATION",a_Radius:"RADIUS",a_Radian:"RADIAN",a_AgeAddScale:"STARTLIFETIME",a_Time:"TIME",u_WorldMat:"MVPMATRIX",u_View:"MATRIX1",u_Projection:"MATRIX2",u_ViewportScale:"VIEWPORTSCALE",u_CurrentTime:"CURRENTTIME",u_Duration:"DURATION",u_Gravity:"GRAVITY",u_EndVelocity:"ENDVELOCITY",u_texture:"DIFFUSETEXTURE"};var s=C.nameKey.add("PARTICLE");C.preCompile(s,E.vs,E.ps,n),n={a_CornerTextureCoordinate:"CORNERTEXTURECOORDINATE",a_Position:"POSITION",a_Direction:"DIRECTION",a_StartColor:"STARTCOLOR",a_EndColor:"ENDCOLOR",a_StartSize:"STARTSIZE",a_StartRotation0:"STARTROTATION0",a_StartRotation1:"STARTROTATION1",a_StartRotation2:"STARTROTATION2",a_StartLifeTime:"STARTLIFETIME",a_StartSpeed:"STARTSPEED",a_Time:"TIME",a_Random0:"RANDOM0",a_Random1:"RANDOM1",a_SimulationWorldPostion:"SIMULATIONWORLDPOSTION",u_WorldPosition:"WORLDPOSITION",u_WorldRotationMat:"WORLDROTATIONMATRIX",u_ThreeDStartRotation:"THREEDSTARTROTATION",u_ScalingMode:"SCALINGMODE",u_PositionScale:"POSITIONSCALE",u_SizeScale:"SIZESCALE",u_View:"MATRIX1",u_Projection:"MATRIX2",u_CurrentTime:"CURRENTTIME",u_Gravity:"GRAVITY",u_texture:"DIFFUSETEXTURE",u_CameraDirection:"CAMERADIRECTION",u_CameraUp:"CAMERAUP",u_StretchedBillboardLengthScale:"STRETCHEDBILLBOARDLENGTHSCALE",u_StretchedBillboardSpeedScale:"STRETCHEDBILLBOARDSPEEDSCALE",u_ColorOverLifeGradientAlphas:"COLOROVERLIFEGRADIENTALPHAS",u_ColorOverLifeGradientColors:"COLOROVERLIFEGRADIENTCOLORS",u_MaxColorOverLifeGradientAlphas:"MAXCOLOROVERLIFEGRADIENTALPHAS",u_MaxColorOverLifeGradientColors:"MAXCOLOROVERLIFEGRADIENTCOLORS",u_SimulationSpace:"SIMULATIONSPACE",u_VOLType:"VOLTYPE",u_VOLVelocityConst:"VOLVELOCITYCONST",u_VOLVelocityGradientX:"VOLVELOCITYGRADIENTX",u_VOLVelocityGradientY:"VOLVELOCITYGRADIENTY",u_VOLVelocityGradientZ:"VOLVELOCITYGRADIENTZ",u_VOLVelocityConstMax:"VOLVELOCITYCONSTMAX",u_VOLVelocityGradientMaxX:"VOLVELOCITYGRADIENTXMAX",u_VOLVelocityGradientMaxY:"VOLVELOCITYGRADIENTYMAX",u_VOLVelocityGradientMaxZ:"VOLVELOCITYGRADIENTZMAX",u_VOLSpaceType:"VOLSPACETYPE",u_SOLType:"SOLTYPE",u_SOLSeprarate:"SOLSEPRARATE",u_SOLSizeGradient:"SOLSIZEGRADIENT",u_SOLSizeGradientX:"SOLSIZEGRADIENTX",u_SOLSizeGradientY:"SOLSIZEGRADIENTY",u_SOLSizeGradientZ:"SOLSizeGradientZ",u_SOLSizeGradientMax:"SOLSizeGradientMax",u_SOLSizeGradientMaxX:"SOLSIZEGRADIENTXMAX",u_SOLSizeGradientMaxY:"SOLSIZEGRADIENTYMAX",u_SOLSizeGradientMaxZ:"SOLSizeGradientZMAX",u_ROLType:"ROLTYPE",u_ROLSeprarate:"ROLSEPRARATE",u_ROLAngularVelocityConst:"ROLANGULARVELOCITYCONST",u_ROLAngularVelocityConstSeprarate:"ROLANGULARVELOCITYCONSTSEPRARATE",u_ROLAngularVelocityGradient:"ROLANGULARVELOCITYGRADIENT",u_ROLAngularVelocityGradientX:"ROLANGULARVELOCITYGRADIENTX",u_ROLAngularVelocityGradientY:"ROLANGULARVELOCITYGRADIENTY",u_ROLAngularVelocityGradientZ:"ROLANGULARVELOCITYGRADIENTZ",u_ROLAngularVelocityConstMax:"ROLANGULARVELOCITYCONSTMAX",u_ROLAngularVelocityConstMaxSeprarate:"ROLANGULARVELOCITYCONSTMAXSEPRARATE",u_ROLAngularVelocityGradientMax:"ROLANGULARVELOCITYGRADIENTMAX",u_ROLAngularVelocityGradientMaxX:"ROLANGULARVELOCITYGRADIENTXMAX",u_ROLAngularVelocityGradientMaxY:"ROLANGULARVELOCITYGRADIENTYMAX",u_ROLAngularVelocityGradientMaxZ:"ROLANGULARVELOCITYGRADIENTZMAX",u_TSAType:"TEXTURESHEETANIMATIONTYPE",u_TSACycles:"TEXTURESHEETANIMATIONCYCLES",u_TSASubUVLength:"TEXTURESHEETANIMATIONSUBUVLENGTH",u_TSAGradientUVs:"TEXTURESHEETANIMATIONGRADIENTUVS",u_TSAMaxGradientUVs:"TEXTURESHEETANIMATIONGRADIENTMAXUVS"};var o=C.nameKey.add("PARTICLESHURIKEN");e="attribute vec4 a_CornerTextureCoordinate;\nattribute vec3 a_Position;\nattribute vec3 a_Direction;\nattribute vec4 a_StartColor;\nattribute vec3 a_StartSize;\nattribute vec3 a_StartRotation0;\nattribute vec3 a_StartRotation1;\nattribute vec3 a_StartRotation2;\nattribute float a_StartLifeTime;\nattribute float a_Time;\nattribute float a_StartSpeed;\n#ifdef VELOCITYOVERLIFETIME||COLOROVERLIFETIME||RANDOMCOLOROVERLIFETIME||SIZEOVERLIFETIME||ROTATIONOVERLIFETIME\n attribute vec4 a_Random0;\n#endif\n#ifdef TEXTURESHEETANIMATION\n attribute vec4 a_Random1;\n#endif\nattribute vec3 a_SimulationWorldPostion;\n\nvarying float v_Discard;\nvarying vec4 v_Color;\nvarying vec2 v_TextureCoordinate;\n\nuniform float u_CurrentTime;\nuniform vec3 u_Gravity;\n\nuniform vec3 u_WorldPosition;\nuniform mat4 u_WorldRotationMat;\nuniform bool u_ThreeDStartRotation;\nuniform int u_ScalingMode;\nuniform vec3 u_PositionScale;\nuniform vec3 u_SizeScale;\nuniform mat4 u_View;\nuniform mat4 u_Projection;\n\nuniform vec3 u_CameraDirection;//TODO:只有几种广告牌模式需要用\nuniform vec3 u_CameraUp;\n\nuniform float u_StretchedBillboardLengthScale;\nuniform float u_StretchedBillboardSpeedScale;\nuniform int u_SimulationSpace;\n\n#ifdef VELOCITYOVERLIFETIME\n uniform int u_VOLType;\n uniform vec3 u_VOLVelocityConst;\n uniform vec2 u_VOLVelocityGradientX[4];//x为key,y为速度\n uniform vec2 u_VOLVelocityGradientY[4];//x为key,y为速度\n uniform vec2 u_VOLVelocityGradientZ[4];//x为key,y为速度\n uniform vec3 u_VOLVelocityConstMax;\n uniform vec2 u_VOLVelocityGradientMaxX[4];//x为key,y为速度\n uniform vec2 u_VOLVelocityGradientMaxY[4];//x为key,y为速度\n uniform vec2 u_VOLVelocityGradientMaxZ[4];//x为key,y为速度\n uniform int u_VOLSpaceType;\n#endif\n\n#ifdef COLOROVERLIFETIME\n uniform vec4 u_ColorOverLifeGradientColors[4];//x为key,yzw为Color\n uniform vec2 u_ColorOverLifeGradientAlphas[4];//x为key,y为Alpha\n#endif\n\n#ifdef RANDOMCOLOROVERLIFETIME\n uniform vec4 u_ColorOverLifeGradientColors[4];//x为key,yzw为Color\n uniform vec2 u_ColorOverLifeGradientAlphas[4];//x为key,y为Alpha\n uniform vec4 u_MaxColorOverLifeGradientColors[4];//x为key,yzw为Color\n uniform vec2 u_MaxColorOverLifeGradientAlphas[4];//x为key,y为Alpha\n#endif\n\n#ifdef SIZEOVERLIFETIME\n uniform int u_SOLType;\n uniform bool u_SOLSeprarate;\n uniform vec2 u_SOLSizeGradient[4];//x为key,y为尺寸\n uniform vec2 u_SOLSizeGradientX[4];//x为key,y为尺寸\n uniform vec2 u_SOLSizeGradientY[4];//x为key,y为尺寸\n uniform vec2 u_SOLSizeGradientZ[4];//x为key,y为尺寸\n uniform vec2 u_SOLSizeGradientMax[4];//x为key,y为尺寸\n uniform vec2 u_SOLSizeGradientMaxX[4];//x为key,y为尺寸\n uniform vec2 u_SOLSizeGradientMaxY[4];//x为key,y为尺寸\n uniform vec2 u_SOLSizeGradientMaxZ[4];//x为key,y为尺寸\n#endif\n\n\n#ifdef ROTATIONOVERLIFETIME\n uniform int u_ROLType;\n uniform bool u_ROLSeprarate;\n uniform float u_ROLAngularVelocityConst;\n uniform vec3 u_ROLAngularVelocityConstSeprarate;\n uniform vec2 u_ROLAngularVelocityGradient[4];//x为key,y为旋转\n uniform vec2 u_ROLAngularVelocityGradientX[4];//x为key,y为旋转\n uniform vec2 u_ROLAngularVelocityGradientY[4];//x为key,y为旋转\n uniform vec2 u_ROLAngularVelocityGradientZ[4];//x为key,y为旋转\n uniform float u_ROLAngularVelocityConstMax;\n uniform vec3 u_ROLAngularVelocityConstMaxSeprarate;\n uniform vec2 u_ROLAngularVelocityGradientMax[4];//x为key,y为旋转\n uniform vec2 u_ROLAngularVelocityGradientMaxX[4];//x为key,y为旋转\n uniform vec2 u_ROLAngularVelocityGradientMaxY[4];//x为key,y为旋转\n uniform vec2 u_ROLAngularVelocityGradientMaxZ[4];//x为key,y为旋转\n#endif\n\n#ifdef TEXTURESHEETANIMATION\n uniform int u_TSAType;\n uniform float u_TSACycles;\n uniform vec2 u_TSASubUVLength;\n uniform vec2 u_TSAGradientUVs[4];//x为key,y为frame\n uniform vec2 u_TSAMaxGradientUVs[4];//x为key,y为frame\n#endif\n\nfloat getCurValueFromGradientFloat(in vec2 gradientNumbers[4],in float normalizedAge)\n{\n float curValue;\n for(int i=1;i<4;i++)\n {\n vec2 gradientNumber=gradientNumbers[i];\n float key=gradientNumber.x;\n if(key>=normalizedAge)\n {\n vec2 lastGradientNumber=gradientNumbers[i-1];\n float lastKey=lastGradientNumber.x;\n float age=(normalizedAge-lastKey)/(key-lastKey);\n curValue=mix(lastGradientNumber.y,gradientNumber.y,age);\n break;\n }\n }\n return curValue;\n}\n\n#ifdef VELOCITYOVERLIFETIME\n//float getTotalPositionFromGradientFloat(in vec2 gradientNumbers[4],in float normalizedAge)\n//{\n// float totalPosition=0.0;\n// for(int i=1;i<4;i++)\n// {\n// vec2 gradientNumber=gradientNumbers[i];\n// float key=gradientNumber.x;\n// vec2 lastGradientNumber=gradientNumbers[i-1];\n// float lastValue=lastGradientNumber.y;\n// \n// if(key>=normalizedAge){\n// float lastKey=lastGradientNumber.x;\n// float age=(normalizedAge-lastKey)/(key-lastKey);\n// \n// float velocity=(lastValue+mix(lastValue,gradientNumber.y,age))/2.0;\n// totalPosition+=velocity*a_StartLifeTime*(normalizedAge-lastKey);//TODO:计算POSITION时可用优化,用已计算好速度\n// break;\n// }\n// else{\n// float velocity=(lastValue+gradientNumber.y)/2.0;\n// totalPosition+=velocity*a_StartLifeTime*(key-lastGradientNumber.x);\n// }\n// }\n// return totalPosition;\n//}\n#endif\n\n\nfloat getTotalValueFromGradientFloat(in vec2 gradientNumbers[4],in float normalizedAge)\n{\n float totalValue=0.0;\n for(int i=1;i<4;i++)\n {\n vec2 gradientNumber=gradientNumbers[i];\n float key=gradientNumber.x;\n vec2 lastGradientNumber=gradientNumbers[i-1];\n float lastValue=lastGradientNumber.y;\n \n if(key>=normalizedAge){\n float lastKey=lastGradientNumber.x;\n float age=(normalizedAge-lastKey)/(key-lastKey);\n totalValue+=(lastValue+mix(lastValue,gradientNumber.y,age))/2.0*a_StartLifeTime*(normalizedAge-lastKey);\n break;\n }\n else{\n totalValue+=(lastValue+gradientNumber.y)/2.0*a_StartLifeTime*(key-lastGradientNumber.x);\n }\n }\n return totalValue;\n}\n\nvec4 getColorFromGradient(in vec2 gradientAlphas[4],in vec4 gradientColors[4],in float normalizedAge)\n{\n vec4 overTimeColor;\n for(int i=1;i<4;i++)\n {\n vec2 gradientAlpha=gradientAlphas[i];\n float alphaKey=gradientAlpha.x;\n if(alphaKey>=normalizedAge)\n {\n vec2 lastGradientAlpha=gradientAlphas[i-1];\n float lastAlphaKey=lastGradientAlpha.x;\n float age=(normalizedAge-lastAlphaKey)/(alphaKey-lastAlphaKey);\n overTimeColor.a=mix(lastGradientAlpha.y,gradientAlpha.y,age);\n break;\n }\n }\n \n for(int i=1;i<4;i++)\n {\n vec4 gradientColor=gradientColors[i];\n float colorKey=gradientColor.x;\n if(colorKey>=normalizedAge)\n {\n vec4 lastGradientColor=gradientColors[i-1];\n float lastColorKey=lastGradientColor.x;\n float age=(normalizedAge-lastColorKey)/(colorKey-lastColorKey);\n overTimeColor.rgb=mix(gradientColors[i-1].yzw,gradientColor.yzw,age);\n break;\n }\n }\n return overTimeColor;\n}\n\n\n\nfloat getFrameFromGradient(in vec2 gradientFrames[4],in float normalizedAge)\n{\n float overTimeFrame;\n for(int i=1;i<4;i++)\n {\n vec2 gradientFrame=gradientFrames[i];\n float key=gradientFrame.x;\n if(key>=normalizedAge)\n {\n vec2 lastGradientFrame=gradientFrames[i-1];\n float lastKey=lastGradientFrame.x;\n float age=(normalizedAge-lastKey)/(key-lastKey);\n overTimeFrame=mix(lastGradientFrame.y,gradientFrame.y,age);\n break;\n }\n }\n return floor(overTimeFrame);\n}\n\n#ifdef VELOCITYOVERLIFETIME\nvec3 computeParticleLifeVelocity(in float normalizedAge)\n{\n vec3 outLifeVelocity;\n if(u_VOLType==0)\n outLifeVelocity=u_VOLVelocityConst; \n else if(u_VOLType==1)\n outLifeVelocity= vec3(getCurValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge));\n else if(u_VOLType==2)\n outLifeVelocity=mix(u_VOLVelocityConst,u_VOLVelocityConstMax,a_Random0.x); \n else if(u_VOLType==3)\n outLifeVelocity=vec3(mix(getCurValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientMaxX,normalizedAge),a_Random0.x),\n mix(getCurValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientMaxY,normalizedAge),a_Random0.x),\n mix(getCurValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientMaxZ,normalizedAge),a_Random0.x));\n \n return outLifeVelocity;\n} \n#endif\n\nvec3 computeParticlePosition(in vec3 startVelocity, in vec3 lifeVelocity,in float age,in float normalizedAge)\n{\n vec3 startPosition;\n vec3 lifePosition;\n #ifdef VELOCITYOVERLIFETIME\n if(u_VOLType==0){\n startPosition=startVelocity*age;\n lifePosition=lifeVelocity*age;\n }\n else if(u_VOLType==1){\n startPosition=startVelocity*age;\n lifePosition=vec3(getTotalValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge));\n }\n else if(u_VOLType==2){\n startPosition=startVelocity*age;\n lifePosition=lifeVelocity*age;\n }\n else if(u_VOLType==3){\n startPosition=startVelocity*age;\n lifePosition=vec3(mix(getTotalValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientMaxX,normalizedAge),a_Random0.x)\n ,mix(getTotalValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientMaxY,normalizedAge),a_Random0.x)\n ,mix(getTotalValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientMaxZ,normalizedAge),a_Random0.x));\n }\n \n vec3 finalPosition;\n if(u_VOLSpaceType==0){\n if(u_ScalingMode!=2)\n finalPosition =mat3(u_WorldRotationMat)*(u_PositionScale*(a_Position+startPosition+lifePosition));\n else\n finalPosition =mat3(u_WorldRotationMat)*(u_PositionScale*a_Position+startPosition+lifePosition);\n }\n else{\n if(u_ScalingMode!=2)\n finalPosition = mat3(u_WorldRotationMat)*(u_PositionScale*(a_Position+startPosition))+lifePosition;\n else\n finalPosition = mat3(u_WorldRotationMat)*(u_PositionScale*a_Position+startPosition)+lifePosition;\n }\n #else\n startPosition=startVelocity*age;\n vec3 finalPosition;\n if(u_ScalingMode!=2)\n finalPosition = mat3(u_WorldRotationMat)*(u_PositionScale*(a_Position+startPosition));\n else\n finalPosition = mat3(u_WorldRotationMat)*(u_PositionScale*a_Position+startPosition);\n #endif\n \n if(u_SimulationSpace==0)\n finalPosition=finalPosition+a_SimulationWorldPostion;\n else if(u_SimulationSpace==1) \n finalPosition=finalPosition+u_WorldPosition;\n \n finalPosition+=u_Gravity*age*normalizedAge;//计算受重力影响的位置//TODO:移除\n \n return finalPosition;\n}\n\n\nvec4 computeParticleColor(in vec4 color,in float normalizedAge)\n{\n #ifdef COLOROVERLIFETIME\n color*=getColorFromGradient(u_ColorOverLifeGradientAlphas,u_ColorOverLifeGradientColors,normalizedAge);\n #endif\n \n #ifdef RANDOMCOLOROVERLIFETIME\n color*=mix(getColorFromGradient(u_ColorOverLifeGradientAlphas,u_ColorOverLifeGradientColors,normalizedAge),getColorFromGradient(u_MaxColorOverLifeGradientAlphas,u_MaxColorOverLifeGradientColors,normalizedAge),a_Random0.y);\n #endif\n\n return color;\n}\n\nvec2 computeParticleSize(in vec2 size,in float normalizedAge)\n{\n #ifdef SIZEOVERLIFETIME\n if(u_SOLType==0){\n if(u_SOLSeprarate){\n size*=vec2(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge));\n }\n else{\n size*=getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge);\n }\n }\n else if(u_SOLType==2){\n if(u_SOLSeprarate){\n size*=vec2(mix(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxX,normalizedAge),a_Random0.z)\n ,mix(getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxY,normalizedAge),a_Random0.z));\n }\n else{\n size*=mix(getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMax,normalizedAge),a_Random0.z); \n }\n }\n #endif\n return size;\n}\n\nvec3 computeParticleRotation(in vec3 rotation,in float age,in float normalizedAge)//TODO:不分轴是否无需计算XY,Billboard模式下好像是,待确认。\n{ \n #ifdef ROTATIONOVERLIFETIME\n if(u_ROLType==0){\n if(u_ROLSeprarate){\n vec3 ageRot=u_ROLAngularVelocityConstSeprarate*age;\n rotation+=ageRot;\n }\n else{\n float ageRot=u_ROLAngularVelocityConst*age;\n rotation+=ageRot;\n }\n }\n else if(u_ROLType==1){\n if(u_ROLSeprarate){\n rotation+=vec3(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge));\n }\n else{\n rotation+=getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge);\n }\n }\n else if(u_ROLType==2){\n if(u_ROLSeprarate){\n vec3 ageRot=mix(u_ROLAngularVelocityConstSeprarate,u_ROLAngularVelocityConstMaxSeprarate,a_Random0.w)*age;\n rotation+=ageRot;\n }\n else{\n float ageRot=mix(u_ROLAngularVelocityConst,u_ROLAngularVelocityConstMax,a_Random0.w)*age;\n rotation+=ageRot;\n }\n }\n else if(u_ROLType==3){\n if(u_ROLSeprarate){\n rotation+=vec3(mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxX,normalizedAge),a_Random0.w)\n ,mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxY,normalizedAge),a_Random0.w)\n ,mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxZ,normalizedAge),a_Random0.w));\n }\n else{\n rotation+=mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMax,normalizedAge),a_Random0.w);\n }\n }\n #endif\n return rotation;\n}\n\nvec2 computeParticleUV(in vec2 uv,in float normalizedAge)\n{ \n #ifdef TEXTURESHEETANIMATION\n if(u_TSAType==1){\n float cycleNormalizedAge=normalizedAge*u_TSACycles;\n float frame=getFrameFromGradient(u_TSAGradientUVs,cycleNormalizedAge-floor(cycleNormalizedAge));\n float totalULength=frame*u_TSASubUVLength.x;\n float floorTotalULength=floor(totalULength);\n uv.x=uv.x+totalULength-floorTotalULength;\n uv.y=uv.y+floorTotalULength*u_TSASubUVLength.y;\n }\n else if(u_TSAType==3){\n float cycleNormalizedAge=normalizedAge*u_TSACycles;\n float uvNormalizedAge=cycleNormalizedAge-floor(cycleNormalizedAge);\n float frame=floor(mix(getFrameFromGradient(u_TSAGradientUVs,uvNormalizedAge),getFrameFromGradient(u_TSAMaxGradientUVs,uvNormalizedAge),a_Random1.x));\n float totalULength=frame*u_TSASubUVLength.x;\n float floorTotalULength=floor(totalULength);\n uv.x=uv.x+totalULength-floorTotalULength;\n uv.y=uv.y+floorTotalULength*u_TSASubUVLength.y;\n }\n #endif\n return uv;\n}\n\nvoid main()\n{\n float age = u_CurrentTime - a_Time;\n float normalizedAge = age/a_StartLifeTime;\n vec3 lifeVelocity;\n if(normalizedAge<1.0){ \n vec3 startVelocity=a_Direction*a_StartSpeed;\n #ifdef VELOCITYOVERLIFETIME\n lifeVelocity= computeParticleLifeVelocity(normalizedAge);//计算粒子生命周期速度\n #endif \n \n vec3 center=computeParticlePosition(startVelocity, lifeVelocity, age, normalizedAge);//计算粒子位置\n vec2 corner=a_CornerTextureCoordinate.xy;//Billboard模式z轴无效\n \n #ifdef SPHERHBILLBOARD\n vec3 cameraUpVector =normalize(u_CameraUp);//TODO:是否外面归一化\n vec3 sideVector = normalize(cross(u_CameraDirection,cameraUpVector));\n vec3 upVector = normalize(cross(sideVector,u_CameraDirection));\n corner*=computeParticleSize(a_StartSize.xy,normalizedAge);\n if(u_ThreeDStartRotation){\n center += u_SizeScale.xzy*(mat3(a_StartRotation0,a_StartRotation1,a_StartRotation2)*(corner.x*sideVector+corner.y*upVector));\n }\n else{\n vec3 rotationAng = computeParticleRotation(a_StartRotation0, age,normalizedAge);\n float rot=rotationAng.z;\n float c = cos(rot);\n float s = sin(rot);\n mat2 rotation= mat2(c, -s, s, c);\n corner=rotation*corner;\n center += u_SizeScale.xzy*(corner.x*sideVector+corner.y*upVector);\n }\n \n #endif\n \n #ifdef STRETCHEDBILLBOARD\n vec3 velocity;\n #ifdef VELOCITYOVERLIFETIME\n if(u_VOLSpaceType==0)\n velocity=mat3(u_WorldRotationMat)*(u_SizeScale*(startVelocity+lifeVelocity));\n else\n velocity=mat3(u_WorldRotationMat)*(u_SizeScale*startVelocity)+lifeVelocity;\n #else\n velocity= mat3(u_WorldRotationMat)*(u_SizeScale*startVelocity);\n #endif \n vec3 cameraUpVector =normalize(velocity);\n vec3 sideVector = normalize(cross(u_CameraDirection,cameraUpVector));\n vec2 size=computeParticleSize(a_StartSize.xy,normalizedAge);\n const mat2 rotaionZHalfPI=mat2(0.0, -1.0, 1.0, 0.0);\n corner=rotaionZHalfPI*corner;\n corner.y=corner.y-abs(corner.y);\n float speed=length(velocity);//TODO:\n center +=u_SizeScale.xzy*size.x*corner.x*sideVector+((cameraUpVector*speed)*u_StretchedBillboardSpeedScale+cameraUpVector*size.y*u_StretchedBillboardLengthScale)*corner.y;\n #endif\n \n #ifdef HORIZONTALBILLBOARD\n const vec3 cameraUpVector =vec3(0.0,0.0,-1.0);\n const vec3 sideVector = vec3(1.0,0.0,0.0);\n corner*=computeParticleSize(a_StartSize.xy,normalizedAge);\n vec3 rotationAng = computeParticleRotation(a_StartRotation0, age,normalizedAge);\n float rot=rotationAng.z;\n float c = cos(rot);\n float s = sin(rot);\n mat2 rotation= mat2(c, -s, s, c);\n corner=rotation*corner*cos(0.78539816339744830961566084581988);//TODO:临时缩小cos45,不确定U3D原因\n center +=u_SizeScale.xzy*(corner.x*sideVector+ corner.y*cameraUpVector);\n #endif\n \n #ifdef VERTICALBILLBOARD\n const vec3 cameraUpVector =vec3(0.0,1.0,0.0);\n vec3 sideVector = normalize(cross(u_CameraDirection,cameraUpVector));\n corner*=computeParticleSize(a_StartSize.xy,normalizedAge);\n vec3 rotationAng = computeParticleRotation(a_StartRotation0, age,normalizedAge);\n float rot=rotationAng.z;\n float c = cos(rot);\n float s = sin(rot);\n mat2 rotation= mat2(c, -s, s, c);\n corner=rotation*corner*cos(0.78539816339744830961566084581988);//TODO:临时缩小cos45,不确定U3D原因\n center +=u_SizeScale.xzy*(corner.x*sideVector+ corner.y*cameraUpVector);\n #endif\n \n gl_Position=u_Projection*u_View*vec4(center,1.0);\n v_Color = computeParticleColor(a_StartColor, normalizedAge);\n v_TextureCoordinate =computeParticleUV(a_CornerTextureCoordinate.zw, normalizedAge);\n v_Discard=0.0;\n }\n else\n {\n v_Discard=1.0;\n }\n}\n\n",
|
||
t="#ifdef FSHIGHPRECISION\n precision highp float;\n#else\n precision mediump float;\n#endif\n\nvarying float v_Discard;\nvarying vec4 v_Color;\nvarying vec2 v_TextureCoordinate;\nuniform sampler2D u_texture;\n\n\nvoid main()\n{ \n #ifdef DIFFUSEMAP\n if(v_Discard!=0.0)\n discard;\n gl_FragColor=texture2D(u_texture,v_TextureCoordinate)*v_Color;\n #else\n gl_FragColor=vec4(0.0);\n #endif\n}",C.preCompile(o,e,t,n),n={a_Position:"POSITION",a_Texcoord0:"UV",a_Time:"TIME",u_Texture:"DIFFUSETEXTURE",u_MvpMatrix:"MVPMATRIX",u_Albedo:"ALBEDO",u_CurrentTime:"CURRENTTIME",u_Color:"UNICOLOR",u_Duration:"DURATION"};var l=C.nameKey.add("GLITTER");e="attribute vec4 a_Position;\nattribute vec2 a_Texcoord0;\nattribute float a_Time;\n\nuniform mat4 u_MvpMatrix;\nuniform float u_CurrentTime;\nuniform vec4 u_Color;\nuniform float u_Duration;\n\nvarying vec2 v_Texcoord;\nvarying vec4 v_Color;\n\n\nvoid main()\n{\n gl_Position = u_MvpMatrix * a_Position;\n \n float age = u_CurrentTime-a_Time;\n float normalizedAge = clamp(age / u_Duration,0.0,1.0);\n \n v_Texcoord=a_Texcoord0;\n \n v_Color=u_Color;\n v_Color.a*=1.0-normalizedAge;\n}\n",t="#ifdef FSHIGHPRECISION\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform vec4 u_Albedo;\nuniform sampler2D u_Texture;\n\nvarying vec2 v_Texcoord;\nvarying vec4 v_Color;\n\n\nvoid main()\n{ \n gl_FragColor=texture2D(u_Texture, v_Texcoord)*v_Color;\n gl_FragColor=gl_FragColor*u_Albedo;\n}\n\n",C.preCompile(l,e,t,n),n={a_Position:"POSITION",u_MvpMatrix:"MVPMATRIX",u_Intensity:"INTENSITY",u_AlphaBlending:"ALPHABLENDING",u_CubeTexture:"DIFFUSETEXTURE"};var h=C.nameKey.add("SkyBox");e="attribute vec4 a_Position;\nuniform mat4 u_MvpMatrix;\nvarying vec3 v_Texcoord;\n\n\nvoid main()\n{\n gl_Position = (u_MvpMatrix*a_Position).xyww;\n v_Texcoord=a_Position.xyz;\n}\n",t="#ifdef FSHIGHPRECISION\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform float u_Intensity;\nuniform float u_AlphaBlending;\nuniform samplerCube u_CubeTexture;\n\nvarying vec3 v_Texcoord;\n\n\nvoid main()\n{ \n gl_FragColor=vec4(textureCube(u_CubeTexture, v_Texcoord).rgb*u_Intensity,u_AlphaBlending);\n}\n\n",C.preCompile(h,e,t,n),n={a_Position:"POSITION",a_Texcoord0:"UV",u_MvpMatrix:"MVPMATRIX",u_Intensity:"INTENSITY",u_AlphaBlending:"ALPHABLENDING",u_texture:"DIFFUSETEXTURE"};var u=C.nameKey.add("SkyDome");e="attribute vec4 a_Position;\nattribute vec2 a_Texcoord0;\nuniform mat4 u_MvpMatrix;\nvarying vec2 v_Texcoord;\n\n\nvoid main()\n{\n gl_Position = (u_MvpMatrix*a_Position).xyww;\n v_Texcoord = a_Texcoord0;\n}\n",t="#ifdef FSHIGHPRECISION\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform float u_Intensity;\nuniform float u_AlphaBlending;\nuniform sampler2D u_texture;\n\nvarying vec2 v_Texcoord;\n\n\nvoid main()\n{ \n gl_FragColor=vec4(texture2D(u_texture, v_Texcoord).rgb*u_Intensity,u_AlphaBlending);\n}\n\n",C.preCompile(u,e,t,n)},e._initResourceLoad=function(){var t=T.createMap;t.lh=[vt,"SPRITE3DHIERARCHY"],t.lm=[zt,"MESH"],t.lmat=[wt,"MATERIAL"],t.ltc=[Xt,"TEXTURECUBE"],t.jpg=[kt,"nativeimage"],t.jpeg=[kt,"nativeimage"],t.png=[kt,"nativeimage"],t.lsani=[o,"arraybuffer"],t.lrani=[o,"arraybuffer"],t.ani=[o,"arraybuffer"],t.lani=[o,"arraybuffer"],g.parserMap.SPRITE3DHIERARCHY=e._loadSprite3DHierarchy,g.parserMap.MESH=e._loadMesh,g.parserMap.MATERIAL=e._loadMaterial,g.parserMap.TEXTURECUBE=e._loadTextureCube},e.READ_BLOCK=function(){return e._readData.pos+=4,!0},e.READ_DATA=function(){return e._DATA.offset=e._readData.getUint32(),e._DATA.size=e._readData.getUint32(),!0},e.READ_STRINGS=function(){var t=[],n={offset:0,size:0};n.offset=e._readData.getUint16(),n.size=e._readData.getUint16();e._readData.pos;e._readData.pos=n.offset+e._DATA.offset;for(var i=0;i<n.size;i++){var r=e._readData.readUTFString();-1!==r.lastIndexOf(".lmat")&&t.push(r)}return t},e._getSprite3DHierarchyInnerUrls=function(t,n,i,r){var a,s;switch(t.type){case"MeshSprite3D":a=t.instanceParams.loadPath,s=zt;break;case"ShuriKenParticle3D":a=t.customProps.texturePath,s=kt}if(a){var o=O.formatURL(a);r&&(o+=r),n.push({url:o,clas:s}),i[a]=o}for(var l=t.child,h=0,u=l.length;u>h;h++)e._getSprite3DHierarchyInnerUrls(l[h],n,i,r)},e._loadSprite3DHierarchy=function(t){var n=new g;n.on("complete",null,e._onSprite3DHierarchylhLoaded,[t]),n.load(t.url,"text",!1,null,!0)},e._onSprite3DHierarchylhLoaded=function(t,n){var i=t.url,r=rt.getURLVerion(i),a=O.basePath;O.basePath=O.getPath(O.formatURL(i));var s=[],o={},l=JSON.parse(n);e._getSprite3DHierarchyInnerUrls(l,s,o,r);var h=s.length,u=h+1,c=1/u;if(e._onProcessChange(t,0,c,1),h>0){var _=p.create(null,e._onProcessChange,[t,c,h/u],!1);e._innerSprite3DHierarchyLoaderManager.create(s,p.create(null,e._onSprite3DMeshsLoaded,[t,_,n,o]),_)}else e._onSprite3DMeshsLoaded(t,null,n,null);O.basePath=a},e._onSprite3DMeshsLoaded=function(e,t,n,i){e.endLoad([n,i]),t&&t.recover()},e._loadMesh=function(t){var n=new g;n.on("complete",null,e._onMeshLmLoaded,[t]),n.load(t.url,"arraybuffer",!1,null,!0)},e._onMeshLmLoaded=function(t,n){var i=t.url,r=rt.getURLVerion(i),a=O.basePath;O.basePath=O.getPath(O.formatURL(i));var s,o,l={};e._readData=new c(n),e._readData.pos=0,e._readData.readUTFString(),e.READ_BLOCK();var h=0,u=0;for(h=0;2>h;h++){var _=e._readData.getUint16(),d=e._strings[_],m=e["READ_"+d];if(null==m)throw new Error("model file err,no this function:"+_+" "+d);1===h?s=m.call():m.call()}for(h=0,u=s.length;u>h;h++){var f=s[h];o=O.formatURL(f),r&&(o+=r),s[h]=o,l[f]=o}var v=1,g=v+1,T=1/g;e._onProcessChange(t,0,T,1);var x=p.create(null,e._onProcessChange,[t,T,v/g],!1);e._innerMeshLoaderManager.create(s,p.create(null,e._onMeshMateialLoaded,[t,x,n,l]),x,wt),O.basePath=a},e._onMeshMateialLoaded=function(e,t,n,i){e.endLoad([n,i]),t.recover()},e._getMaterialTexturePath=function(e,t){var n=e.length-4;return e.indexOf(".dds")!=n&&e.indexOf(".tga")!=n&&e.indexOf(".exr")!=n&&e.indexOf(".DDS")!=n&&e.indexOf(".TGA")!=n&&e.indexOf(".EXR")!=n||(e=e.substr(0,n)+".png"),e=O.formatURL(e),t&&(e+=t),e},e._loadMaterial=function(t){var n=new g;n.on("complete",null,e._onMaterilLmatLoaded,[t]),n.load(t.url,"json",!1,null,!0)},e._onMaterilLmatLoaded=function(t,n){var i=t.url,r=rt.getURLVerion(i),a=O.basePath;O.basePath=O.getPath(O.formatURL(i));var s,o=[],l={},h=n.customProps,u=h.diffuseTexture.texture2D;u&&(s=e._getMaterialTexturePath(u,r),o.push(s),l[u]=s);var c=h.normalTexture.texture2D;c&&(s=e._getMaterialTexturePath(c,r),o.push(s),l[c]=s);var _=h.specularTexture.texture2D;_&&(s=e._getMaterialTexturePath(_,r),o.push(s),l[_]=s);var d=h.emissiveTexture.texture2D;d&&(s=e._getMaterialTexturePath(d,r),o.push(s),l[d]=s);var m=h.ambientTexture.texture2D;m&&(s=e._getMaterialTexturePath(m,r),o.push(s),l[m]=s);var f=h.reflectTexture.texture2D;f&&(s=e._getMaterialTexturePath(f,r),o.push(s),l[f]=s);var v=o.length,g=v+1,T=1/g;if(e._onProcessChange(t,0,T,1),v>0){var x=p.create(null,e._onProcessChange,[t,T,v/g],!1);e._innerMaterialLoaderManager.create(o,p.create(null,e._onMateialTexturesLoaded,[t,x,n,l]),x,kt)}else e._onMateialTexturesLoaded(t,null,n,null);O.basePath=a},e._onMateialTexturesLoaded=function(e,t,n,i){e.endLoad([n,i]),t&&t.recover()},e._loadTextureCube=function(t){var n=new g;n.on("complete",null,e._onTextureCubeLtcLoaded,[t]),n.load(t.url,"json",!1,null,!0)},e._onTextureCubeLtcLoaded=function(t,n){var i=O.basePath;O.basePath=O.getPath(O.formatURL(t.url));var r=[O.formatURL(n.px),O.formatURL(n.nx),O.formatURL(n.py),O.formatURL(n.ny),O.formatURL(n.pz),O.formatURL(n.nz)],a=1/7;e._onProcessChange(t,0,a,1);var s=p.create(null,e._onProcessChange,[t,a,6/7],!1);e._innerTextureCubeLoaderManager.load(r,p.create(null,e._onTextureCubeImagesLoaded,[t,r,s]),s,"nativeimage"),O.basePath=i},e._onTextureCubeImagesLoaded=function(e,t,n){var i=[];i.length=6;for(var r=0;6>r;r++){var a=t[r];i[r]=g.getRes(a),g.clearRes(a)}e.endLoad(i),n.recover()},e._onProcessChange=function(e,t,n,i){var i=t+i*n;1>i&&e.event("progress",i)},e.init=function(t,i,r,a,s){return void 0===r&&(r=!1),void 0===a&&(a=!1),void 0===s&&(s=!1),w.enable()?(e._innerTextureCubeLoaderManager.maxLoader=1,e._innerMaterialLoaderManager.maxLoader=1,e._innerMeshLoaderManager.maxLoader=1,e._innerSprite3DHierarchyLoaderManager.maxLoader=1,I.changeWebGLSize=e._changeWebGLSize,d.isAntialias=r,d.isAlpha=a,d.premultipliedAlpha=s,S.is3DMode=!0,n.init(t,i),U.__init__(),ct.__init__(),e._initShader(),void e._initResourceLoad()):void alert("Laya3D init err,must support webGL!")},e._readData=null,e.SPRITE3DHIERARCHY="SPRITE3DHIERARCHY",e.MESH="MESH",e.MATERIAL="MATERIAL",e.TEXTURECUBE="TEXTURECUBE",i(e,["_DATA",function(){return this._DATA={offset:0,size:0}},"_strings",function(){return this._strings=["BLOCK","DATA","STRINGS"]},"_innerTextureCubeLoaderManager",function(){return this._innerTextureCubeLoaderManager=new T},"_innerMaterialLoaderManager",function(){return this._innerMaterialLoaderManager=new T},"_innerMeshLoaderManager",function(){return this._innerMeshLoaderManager=new T},"_innerSprite3DHierarchyLoaderManager",function(){return this._innerSprite3DHierarchyLoaderManager=new T}]),e}(),function(e){function t(){this._id=0,this._cachedOwnerLayerMask=0,this._cachedOwnerEnable=!1,this._enable=!1,this._owner=null,this.started=!1,t.__super.call(this),this._id=t._uniqueIDCounter,t._uniqueIDCounter++}r(t,"laya.d3.component.Component3D",e);var i=t.prototype;return n.imps(i,{"laya.d3.core.render.IUpdate":!0}),i._onLayerChanged=function(e){this._cachedOwnerLayerMask=e.mask},i._onEnableChanged=function(e){this._cachedOwnerEnable=e},i._initialize=function(e){this._owner=e,this.enable=!0,this.started=!1,this._cachedOwnerLayerMask=e.layer.mask,this._owner.on("layerchanged",this,this._onLayerChanged),this._cachedOwnerEnable=e.enable,this._owner.on("enabledchanged",this,this._onEnableChanged),this._load(e)},i._uninitialize=function(){this._unload(this.owner),this._owner=null},i._load=function(e){},i._start=function(e){},i._update=function(e){},i._lateUpdate=function(e){},i._preRenderUpdate=function(e){},i._postRenderUpdate=function(e){},i._unload=function(e){this.offAll()},a(0,i,"id",function(){return this._id}),a(0,i,"owner",function(){return this._owner}),a(0,i,"enable",function(){return this._enable},function(e){this._enable!==e&&(this._enable=e,this.event("enabledchanged",this._enable))}),a(0,i,"isActive",function(){return U.isActive(this._cachedOwnerLayerMask)&&this._cachedOwnerEnable&&this._enable}),a(0,i,"isVisible",function(){return U.isVisible(this._cachedOwnerLayerMask)&&this._cachedOwnerEnable&&this._enable}),t._uniqueIDCounter=1,t}(f)),st=function(e){function t(e){this._owner=null,this._enable=!1,this._renderObject=null,this._materials=null,this._boundingSphereNeedChange=!1,this._boundingBoxNeedChange=!1,this._boundingSphere=null,this._boundingBox=null,t.__super.call(this),this._owner=e,this._enable=!0,this._boundingBox=new ze(new Qe,new Qe),this._boundingSphere=new ke(new Qe,0),this._boundingSphereNeedChange=!0,this._boundingBoxNeedChange=!0,this._renderObject=new _e,this._renderObject._render=this,this._renderObject._layerMask=this._owner.layer.mask,this._renderObject._ownerEnable=this._owner.enable,this._renderObject._enable=this._enable,this._materials=[],this._owner.transform.on("worldmatrixneedchanged",this,this._onWorldMatNeedChange),this._owner.on("layerchanged",this,this._onOwnerLayerChanged),this._owner.on("enabledchanged",this,this._onOwnerEnableChanged),this.on("enabledchanged",this,this._onEnableChanged)}r(t,"laya.d3.core.render.BaseRender",e);var i=t.prototype;return n.imps(i,{"laya.resource.IDestroy":!0}),i._onWorldMatNeedChange=function(){this._boundingSphereNeedChange=!0,this._boundingBoxNeedChange=!0},i._onOwnerLayerChanged=function(e){this._renderObject._layerMask=e.mask},i._onOwnerEnableChanged=function(e){this._renderObject._ownerEnable=e},i._onEnableChanged=function(e,t){this._renderObject._enable=t},i._calculateBoundingSphere=function(){throw"BaseRender: must override it."},i._calculateBoundingBox=function(){throw"BaseRender: must override it."},i._destroy=function(){this.offAll(),this._owner=null,this._renderObject=null,this._materials=null,this._boundingBox=null,this._boundingSphere=null},a(0,i,"enable",function(){return this._enable},function(e){this._enable=e,this.event("enabledchanged",[this,e])}),a(0,i,"boundingBox",function(){return this._boundingBoxNeedChange&&(this._calculateBoundingBox(),this._boundingBoxNeedChange=!1),this._boundingBox}),a(0,i,"sharedMaterials",function(){var e=this._materials.slice();return e},function(e){if(!e)throw new Error("MeshRender: shadredMaterials value can't be null.");this._materials=e;for(var t=0,n=e.length;n>t;t++)this.event("materialchanged",[this,t,e[t]])}),a(0,i,"renderObject",function(){return this._renderObject}),a(0,i,"boundingSphere",function(){return this._boundingSphereNeedChange&&(this._calculateBoundingSphere(),this._boundingSphereNeedChange=!1),this._boundingSphere}),a(0,i,"material",function(){var e=this._materials[0];if(e&&!e._isInstance){var t=new e.constructor;e.cloneTo(t),t.name=t.name+"(Instance)",t._isInstance=!0,this._materials[0]=t,this.event("materialchanged",[this,0,t])}return this._materials[0]},function(e){this._materials[0]=e,this.event("materialchanged",[this,0,e])}),a(0,i,"materials",function(){for(var e=0,t=this._materials.length;t>e;e++){var n=this._materials[e];if(!n._isInstance){var i=new n.constructor;n.cloneTo(i),i.name=i.name+"(Instance)",i._isInstance=!0,this._materials[e]=i,this.event("materialchanged",[this,e,i])}}return this._materials.slice()},function(e){if(!e)throw new Error("MeshRender: materials value can't be null.");this._materials=e;for(var t=0,n=e.length;n>t;t++)this.event("materialchanged",[this,t,e[t]])}),a(0,i,"sharedMaterial",function(){return this._materials[0]},function(e){this._materials[0]=e,this.event("materialchanged",[this,0,e])}),t}(f),ot=function(e){function t(e){this._owner=null,this._sharedMesh=null,t.__super.call(this),this._owner=e}r(t,"laya.d3.core.MeshFilter",e);var i=t.prototype;return n.imps(i,{"laya.resource.IDestroy":!0}),i._destroy=function(){this.offAll(),this._owner=null,this._sharedMesh=null},a(0,i,"sharedMesh",function(){return this._sharedMesh},function(e){var t=this._sharedMesh;this._sharedMesh=e,this.event("meshchanged",[this,t,e])}),t}(f),lt=function(e){function t(){this._burstsIndex=0,this._bursts=null,this._startDelay=NaN,this._isPlaying=!1,this._isPaused=!1,this._frameTime=NaN,this._emissionTime=NaN,this._playbackTime=NaN,this._minEmissionTime=NaN,this._emissionRate=0,this._particleSystem=null,this._shape=null,this.enbale=!1,t.__super.call(this),this._burstsIndex=0,this._isPlaying=!1,this._isPaused=!1,this._frameTime=0,this._emissionTime=0,this._playbackTime=0,this.emissionRate=10,this._bursts=[]}r(t,"laya.d3.core.particleShuriKen.module.Emission",e);var s=t.prototype;return n.imps(s,{"laya.resource.IDestroy":!0}),s._burst=function(e,t){for(var n=0,i=this._bursts.length;this._burstsIndex<i;this._burstsIndex++){var r=this._bursts[this._burstsIndex],a=r.time;if(!(a>=e&&t>=a))break;var s=x.lerp(r.minCount,r.maxCount,Math.random());n+=s}return n},s._advanceTime=function(e,t){if(this._isPlaying&&!this._isPaused&&(this._playbackTime+=e,!(this._playbackTime<this._startDelay))){var n=0,i=this._emissionTime;this._emissionTime+=e;var r=this._particleSystem.duration,a=0;if(this._emissionTime>r){if(a+=this._burst(i,r),!this._particleSystem.looping){for(this._isPlaying=!1,a=Math.min(this._particleSystem.maxParticles-this._particleSystem.aliveParticleCount,a),n=0;a>n;n++)this.emit(t);return void this.event("stopped")}this._emissionTime-=r,this.event("complete"),this._burstsIndex=0,a+=this._burst(0,this._emissionTime)}else a+=this._burst(i,this._emissionTime);for(a=Math.min(this._particleSystem.maxParticles-this._particleSystem.aliveParticleCount,a),n=0;a>n;n++)this.emit(t);if(this._frameTime+=e,!(this._frameTime<this._minEmissionTime))for(;this._frameTime>this._minEmissionTime&&this.emit(t);)this._frameTime-=this._minEmissionTime}},s._destroy=function(){this.offAll(),this._bursts=null,this._particleSystem=null},s.play=function(){switch(this._burstsIndex=0,this._isPlaying=!0,this._isPaused=!1,this._frameTime=0,this._emissionTime=0,this._playbackTime=0,this._particleSystem.startDelayType){case 0:this._startDelay=this._particleSystem.startDelay;break;case 1:this._startDelay=x.lerp(this._particleSystem.startDelayMin,this._particleSystem.startDelayMax,Math.random());break;default:throw new Error("Utils3D: startDelayType is invalid.")}this._particleSystem._startUpdateLoopCount=L.loopCount,this.event("played")},s.pause=function(){this._isPaused=!0,this.event("paused")},s.stop=function(){this._burstsIndex=0,this._frameTime=0,this._isPlaying=!1,this._isPaused=!1,this._emissionTime=0,this._playbackTime=0,this.event("stopped")},s.getBurstsCount=function(){return this._bursts.length},s.getBurstByIndex=function(e){return this._bursts[e]},s.addBurst=function(e){var t=this._bursts.length;if(t>0)for(var n=0;t>n;n++)this._bursts[n].time>e.time&&this._bursts.splice(n,0,e);else this._bursts.push(e)},s.removeBurst=function(e){var t=this._bursts.indexOf(e);if(-1!==t){this._bursts.splice(t,1);var n=this._bursts.length;this._burstsIndex>n&&(this._burstsIndex=n)}},s.removeBurstByIndex=function(e){this._bursts.splice(e,1);var t=this._bursts.length;this._burstsIndex>t&&(this._burstsIndex=t)},s.clearBurst=function(){this._burstsIndex=0,this._bursts.length=0},s.update=function(e,t){this.enbale&&this._advanceTime(e,t)},s.emit=function(e){var n=t._tempPosition,i=t._tempDirection;if(this._shape.enbale)this._shape.generatePositionAndDirection(n,i);else{var r=n.elements,a=i.elements;r[0]=r[1]=r[2]=0,a[0]=a[1]=0,a[2]=1}return this._particleSystem.addParticle(n,i,e)},a(0,s,"playbackTime",function(){return this._playbackTime}),a(0,s,"isPlaying",function(){return this._isPlaying}),a(0,s,"isPaused",function(){return this._isPaused}),a(0,s,"emissionTime",function(){var e=this._particleSystem.duration;return this._emissionTime>e?e:this._emissionTime}),a(0,s,"emissionRate",function(){return this._emissionRate},function(e){if(0>e)throw new Error("ParticleBaseShape:emissionRate value must large or equal than 0.");this._emissionRate=e,0===e?this._minEmissionTime=2147483647:this._minEmissionTime=1/e}),i(t,["_tempPosition",function(){return this._tempPosition=new Qe},"_tempDirection",function(){return this._tempDirection=new Qe}]),t}(f),ht=function(e){function t(e){this._owner=null,this._preWorldTransformModifyID=-1,this._localUpdate=!1,this._worldUpdate=!0,this._parent=null,t.__super.call(this),this._tempMatrix0=new je,this._tempQuaternion0=new Ze,this._tempVector30=new Qe,this._localPosition=new Qe,this._localRotation=new Ze(0,0,0,1),this._localScale=new Qe(1,1,1),this._localMatrix=new je,this._position=new Qe,this._rotation=new Ze(0,0,0,1),this._scale=new Qe(1,1,1),this._worldMatrix=new je,this._forward=new Qe,this._up=new Qe,this._right=new Qe,this._owner=e}r(t,"laya.d3.core.Transform3D",e);var n=t.prototype;return n._updateLocalMatrix=function(){je.createAffineTransformation(this._localPosition,this._localRotation,this._localScale,this._localMatrix)},n._onLocalTransform=function(){this._localUpdate=!0},n._onWorldTransform=function(){if(!this._worldUpdate){this._worldUpdate=!0,this.event("worldmatrixneedchanged");for(var e=0,t=this._owner._childs.length;t>e;e++)this._owner._childs[e].transform._onWorldTransform()}},n.translate=function(e,t){void 0===t&&(t=!0),t?(je.createFromQuaternion(this.localRotation,this._tempMatrix0),Qe.transformCoordinate(e,this._tempMatrix0,this._tempVector30),Qe.add(this.localPosition,this._tempVector30,this._localPosition),this.localPosition=this._localPosition):(Qe.add(this.position,e,this._position),this.position=this._position)},n.rotate=function(e,t,n){void 0===t&&(t=!0),void 0===n&&(n=!0);var i;n?i=e:(Qe.scale(e,Math.PI/180,this._tempVector30),i=this._tempVector30),Ze.createFromYawPitchRoll(i.y,i.x,i.z,this._tempQuaternion0),t?(Ze.multiply(this._localRotation,this._tempQuaternion0,this._localRotation),this.localRotation=this._localRotation):(Ze.multiply(this._tempQuaternion0,this.rotation,this._rotation),this.rotation=this._rotation)},a(0,n,"localRotation",function(){return this._localRotation},function(e){this._localRotation=e,this._localRotation.normalize(this._localRotation),this._onLocalTransform(),this._onWorldTransform()}),a(0,n,"worldMatrix",function(){return this._worldUpdate?(null!=this._parent?je.multiply(this._parent.worldMatrix,this.localMatrix,this._worldMatrix):this.localMatrix.cloneTo(this._worldMatrix),this._worldUpdate=!1,this._worldMatrix):this._worldMatrix},function(e){null===this._parent?this.localMatrix=e:(this._parent.worldMatrix.invert(this._localMatrix),je.multiply(this._localMatrix,e,this._localMatrix),this.localMatrix=this._localMatrix)}),a(0,n,"worldNeedUpdate",function(){return this._worldUpdate}),a(0,n,"localMatrix",function(){return this._localUpdate&&(this._updateLocalMatrix(),this._localUpdate=!1),this._localMatrix},function(e){this._localMatrix=e,this._localMatrix.decompose(this._localPosition,this._localRotation,this._localScale),this._onWorldTransform()}),a(0,n,"localPosition",function(){return this._localPosition},function(e){this._localPosition=e,this._onLocalTransform(),this._onWorldTransform()}),a(0,n,"localScale",function(){return this._localScale},function(e){this._localScale=e,this._onLocalTransform(),this._onWorldTransform()}),a(0,n,"position",function(){if(null!==this._parent){var e=this.worldMatrix.elements;this._position.elements[0]=e[12],this._position.elements[1]=e[13],this._position.elements[2]=e[14]}else this._localPosition.cloneTo(this._position);return this._position},function(e){null!==this._parent?(this._parent.worldMatrix.invert(this._tempMatrix0),Qe.transformCoordinate(e,this._tempMatrix0,this._localPosition),this.localPosition=this._localPosition):(e.cloneTo(this._localPosition),this.localPosition=this._localPosition)}),a(0,n,"rotation",function(){return null!==this._parent?this.worldMatrix.decompose(this._position,this._rotation,this._scale):this._localRotation.cloneTo(this._rotation),this._rotation},function(e){null!==this._parent?(this._parent.rotation.invert(this._tempQuaternion0),Ze.multiply(e,this._tempQuaternion0,this._localRotation),this.localRotation=this._localRotation):(e.cloneTo(this._localRotation),this.localRotation=this._localRotation)}),a(0,n,"localRotationEuler",null,function(e){Ze.createFromYawPitchRoll(e.y,e.x,e.z,this._localRotation),this._onLocalTransform(),this._onWorldTransform()}),a(0,n,"scale",function(){return null!==this._parent?Qe.multiply(this._parent.scale,this._localScale,this._scale):this._localScale.cloneTo(this._scale),this._scale}),a(0,n,"rotationEuler",null,function(e){Ze.createFromYawPitchRoll(e.y,e.x,e.z,this._rotation),this.rotation=this._rotation}),a(0,n,"forward",function(){var e=this.worldMatrix.elements;return this._forward.elements[0]=-e[8],this._forward.elements[1]=-e[9],this._forward.elements[2]=-e[10],this._forward}),a(0,n,"up",function(){var e=this.worldMatrix.elements;return this._up.elements[0]=e[4],this._up.elements[1]=e[5],this._up.elements[2]=e[6],this._up}),a(0,n,"right",function(){var e=this.worldMatrix.elements;return this._right.elements[0]=e[0],this._right.elements[1]=e[1],this._right.elements[2]=e[2],this._right}),a(0,n,"parent",null,function(e){this._parent=e,this._onWorldTransform()}),t}(f),ut=(function(e){function t(){this._rotation=0,this._matNeedUpdte=!1,t.__super.call(this),this._tempTitlingV3=new Qe,this._tempRotationMatrix=new je,this._tempTitlingMatrix=new je,this._matrix=new je,this._offset=new Ke,this._tiling=new Ke}r(t,"laya.d3.core.TransformUV",e);var n=t.prototype;return n._updateMatrix=function(){this._tempTitlingV3.elements[0]=this._tiling.x,this._tempTitlingV3.elements[1]=this._tiling.y,this._tempTitlingV3.elements[2]=1,je.createScaling(this._tempTitlingV3,this._tempTitlingMatrix),je.createRotationZ(this._rotation,this._tempRotationMatrix),je.multiply(this._tempRotationMatrix,this._tempTitlingMatrix,this._matrix);var e=this._matrix.elements;e[12]=this._offset.x,e[13]=this._offset.y,e[14]=0},a(0,n,"matrix",function(){return this._matNeedUpdte&&(this._updateMatrix(),this._matNeedUpdte=!1),this._matrix}),a(0,n,"tiling",function(){return this._tiling},function(e){this._tiling=e,this._matNeedUpdte=!0}),a(0,n,"offset",function(){return this._offset},function(e){this._offset=e,this._matNeedUpdte=!0}),a(0,n,"rotation",function(){return this._rotation},function(e){this._rotation=e,this._matNeedUpdte=!0}),t}(f),function(e){function t(e){this._floatCountPerVertex=6,this._owner=null,this._vertices=null,this._vertexBuffer=null,this._firstActiveElement=0,this._firstNewElement=0,this._firstFreeElement=0,this._firstRetiredElement=0,this._currentTime=NaN,this._drawCounter=0,this.scLeft=null,this.scRight=null,this._numPositionMode=0,this._numPositionVelocityMode=0,this._lastTime=NaN,this._needPatch=!1,this._lastPatchAddPos0=null,this._lastPatchAddPos1=null,this._lastPatchAddTime=NaN,this.lifeTime=NaN,this.minSegmentDistance=NaN,this.minInterpDistance=NaN,this.maxSlerpCount=0,this.color=null,this._maxSegments=0,t.__super.call(this),this._tempVector0=new Qe,this._tempVector1=new Qe,this._tempVector2=new Qe,this._tempVector3=new Qe,this._albedo=new $e(1,1,1,1),this._posModeLastPosition0=new Qe,this._posModeLastPosition1=new Qe,this._posModePosition0=new Qe,this._posModePosition1=new Qe,this._posVelModePosition0=new Qe,this._posVelModeVelocity0=new Qe,this._posVelModePosition1=new Qe,this._posVelModeVelocity1=new Qe,this._owner=e,this._lastTime=0,this._firstActiveElement=0,this._firstNewElement=0,this._firstFreeElement=0,this._firstRetiredElement=0,this._currentTime=0,this._drawCounter=0,this._needPatch=!1,this._lastPatchAddPos0=new Qe,this._lastPatchAddPos1=new Qe,this.scLeft=new B,this.scRight=new B,this.lifeTime=.5,this.minSegmentDistance=.1,this.minInterpDistance=.6,this.maxSlerpCount=128,this.color=new $e(1,1,1,1),this._maxSegments=200,this._owner.on("enabledchanged",this,this._onEnableChanged)}r(t,"laya.d3.resource.tempelet.GlitterTemplet",e);var i=t.prototype;return n.imps(i,{"laya.d3.core.render.IRenderable":!0}),i._getVertexBuffer=function(e){return void 0===e&&(e=0),0===e?this._vertexBuffer:null},i._getIndexBuffer=function(){return null},i._initialize=function(){this._vertexBuffer=Bt.create(ve.vertexDeclaration,2*this.maxSegments,35048),this._vertices=new Float32Array(this.maxSegments*this._floatCountPerVertex*2)},i._onEnableChanged=function(e){e||(this._numPositionMode=0,this._numPositionVelocityMode=0,this._firstActiveElement=0,this._firstNewElement=0,this._firstFreeElement=0,this._firstRetiredElement=0,this._currentTime=0,this._drawCounter=0)},i._updateTextureCoordinates=function(){this._firstActiveElement<this._firstFreeElement?this._updateSubTextureCoordinates(this._firstActiveElement,2*(this._firstFreeElement-this._firstActiveElement)):(this._updateSubTextureCoordinates(this._firstActiveElement,2*(this.maxSegments-this._firstActiveElement)),this._firstFreeElement>0&&this._updateSubTextureCoordinates(0,2*this._firstFreeElement))},i._updateSubTextureCoordinates=function(e,t){for(var n=2*e,i=0;t>i;i+=2){var r=n+i,a=r*this._floatCountPerVertex,s=(r+1)*this._floatCountPerVertex;this._vertices[a+3]=this._vertices[s+3]=(this._vertices[a+5]-this._currentTime)/this.lifeTime}},i._retireActiveGlitter=function(){for(var e=this.lifeTime,t=2*this._floatCountPerVertex;this._firstActiveElement!=this._firstNewElement;){var n=this._firstActiveElement*t+5,i=this._currentTime-this._vertices[n];if(e>i)break;this._vertices[n]=this._drawCounter,this._firstActiveElement++,this._firstActiveElement>=this.maxSegments&&(this._firstActiveElement=0)}},i._freeRetiredGlitter=function(){for(var e=2*this._floatCountPerVertex;this._firstRetiredElement!=this._firstActiveElement;){var t=this._drawCounter-this._vertices[this._firstRetiredElement*e+5];if(3>t)break;this._firstRetiredElement++,this._firstRetiredElement>=this.maxSegments&&(this._firstRetiredElement=0)}},i._calcVelocity=function(e,t,n){Qe.subtract(e,t,n),Qe.scale(n,.5,n)},i._addNewGlitterSegementToVertexBuffer=function(){var e=0;this._firstActiveElement<this._firstFreeElement?(e=2*this._firstActiveElement*this._floatCountPerVertex,this._vertexBuffer.setData(this._vertices,e,e,2*(this._firstFreeElement-this._firstActiveElement)*this._floatCountPerVertex)):(e=2*this._firstActiveElement*this._floatCountPerVertex,this._vertexBuffer.setData(this._vertices,e,e,2*(this.maxSegments-this._firstActiveElement)*this._floatCountPerVertex),this._firstFreeElement>0&&this._vertexBuffer.setData(this._vertices,0,0,2*this._firstFreeElement*this._floatCountPerVertex)),this._firstNewElement=this._firstFreeElement},i._addGlitter=function(e,t,n){this._needPatch&&(this._needPatch=!1,this._addGlitter(this._lastPatchAddPos0,this._lastPatchAddPos1,this._lastPatchAddTime));var i=this._firstFreeElement+1;if(i>=this.maxSegments&&(i=0,e.cloneTo(this._lastPatchAddPos0),t.cloneTo(this._lastPatchAddPos1),this._lastPatchAddTime=n,this._needPatch=!0),i===this._firstRetiredElement)throw new Error("GlitterTemplet:current segement count have large than maxSegments,please adjust the value of maxSegments or add Glitter Vertex Frequency.");var r=e.elements,a=t.elements,s=0,o=this._firstFreeElement*this._floatCountPerVertex*2;for(s=0;3>s;s++)this._vertices[o+s]=r[s];this._vertices[o+3]=0,this._vertices[o+4]=0,this._vertices[o+5]=n;var l=o+this._floatCountPerVertex;for(s=0;3>s;s++)this._vertices[l+s]=a[s];this._vertices[l+3]=0,this._vertices[l+4]=1,this._vertices[l+5]=n,this._firstFreeElement=i},i._update=function(e){this._currentTime+=e/1e3,this._retireActiveGlitter(),this._freeRetiredGlitter(),this._firstActiveElement==this._firstFreeElement&&(this._currentTime=0),this._firstRetiredElement==this._firstActiveElement&&(this._drawCounter=0),this._updateTextureCoordinates()},i._beforeRender=function(e){return this._firstNewElement!=this._firstFreeElement&&this._addNewGlitterSegementToVertexBuffer(),this._drawCounter++,this._firstActiveElement!=this._firstFreeElement?(this._vertexBuffer.bindWithIndexBuffer(null),!0):!1},i._render=function(e){var t=0,n=w.mainContext;this._firstActiveElement<this._firstFreeElement?(t=2*(this._firstFreeElement-this._firstActiveElement),n.drawArrays(5,2*this._firstActiveElement,t),L.trianglesFaces+=t-2,L.drawCall++):(t=2*(this.maxSegments-this._firstActiveElement),n.drawArrays(5,2*this._firstActiveElement,t),L.trianglesFaces+=t-2,L.drawCall++,this._firstFreeElement>0&&(t=2*this._firstFreeElement,n.drawArrays(5,0,t),L.trianglesFaces+=t-2,L.drawCall++))},i.addVertexPosition=function(e,t){if(this._owner.enable)if(this._numPositionMode<2)0===this._numPositionMode?(e.cloneTo(this._posModeLastPosition0),t.cloneTo(this._posModeLastPosition1)):(e.cloneTo(this._posModePosition0),t.cloneTo(this._posModePosition1)),this._numPositionMode++;else{var n=this._tempVector2;this._calcVelocity(e,this._posModeLastPosition0,n);var i=this._tempVector3;this._calcVelocity(t,this._posModeLastPosition1,i),this.addVertexPositionVelocity(this._posModePosition0,n,this._posModePosition1,i),this._posModePosition0.cloneTo(this._posModeLastPosition0),this._posModePosition1.cloneTo(this._posModeLastPosition1),e.cloneTo(this._posModePosition0),t.cloneTo(this._posModePosition1)}},i.addVertexPositionVelocity=function(e,t,n,i){if(this._owner.enable){if(0===this._numPositionVelocityMode)this._numPositionVelocityMode++;else{var r=this._tempVector0;Qe.subtract(e,this._posVelModePosition0,r);var a=Qe.scalarLength(r);Qe.subtract(n,this._posVelModePosition1,r);var s=Qe.scalarLength(r),o=0,l=l;if(l>a&&l>s)return;if(o=1+Math.floor(Math.max(a,s)/this.minInterpDistance),1===o)this._addGlitter(e,n,this._currentTime);else{o=Math.min(o,this.maxSlerpCount),this.scLeft.Init(this._posVelModePosition0,this._posVelModeVelocity0,e,t),this.scRight.Init(this._posVelModePosition1,this._posVelModeVelocity1,n,i);
|
||
for(var h=1/o,u=h,c=this._currentTime-this._lastTime,_=1;o>=_;_++){var d=this._tempVector0;this.scLeft.Slerp(u,d);var m=this._tempVector1;this.scRight.Slerp(u,m);var f=this._lastTime+c*_/o;this._addGlitter(d,m,f),u+=h}}}this._lastTime=this._currentTime,e.cloneTo(this._posVelModePosition0),t.cloneTo(this._posVelModeVelocity0),n.cloneTo(this._posVelModePosition1),i.cloneTo(this._posVelModeVelocity1)}},i.dispose=function(){this._owner.off("enabledchanged",this,this._onEnableChanged)},a(0,i,"maxSegments",function(){return this._maxSegments-1},function(e){var t=e+1;t!==this._maxSegments&&(this._maxSegments=t,this._vertexBuffer&&this._vertexBuffer.dispose(),this._initialize())}),a(0,i,"indexOfHost",function(){return 0}),a(0,i,"_vertexBufferCount",function(){return 1}),a(0,i,"triangleCount",function(){var e=0;return this._firstActiveElement<this._firstFreeElement?e=2*(this._firstFreeElement-this._firstActiveElement)-2:(e=2*(this.maxSegments-this._firstActiveElement)-2,e+=2*this._firstFreeElement-2),e}),t}(f)),ct=(function(e){function t(e){this._settings=null,this._particle3D=null,t.__super.call(this),this._resultPosition=new Qe,this._resultVelocity=new Qe,this.centerPosition=new Qe,this.size=new Qe,this.velocity=new Qe,this.velocityAddVariance=new Qe,this._particle3D=e;for(var n=e.templet.settings,i=0;3>i;i++)this.centerPosition.elements[i]=n.boxEmitterCenterPosition[i],this.size.elements[i]=n.boxEmitterSize[i],this.velocity.elements[i]=n.boxEmitterVelocity[i],this.velocityAddVariance.elements[i]=n.boxEmitterVelocityAddVariance[i];this.emissionRate=n.emissionRate}r(t,"laya.d3.core.particle.EmitterBox",e);var n=t.prototype;return n._randomPositionOnBox=function(){var e=this._resultPosition.elements,t=this.centerPosition.elements,n=this.size.elements;return e[0]=t[0]+n[0]*(Math.random()-.5),e[1]=t[1]+n[1]*(Math.random()-.5),e[2]=t[2]+n[2]*(Math.random()-.5),this._resultPosition},n._randomVelocityOnBox=function(){var e=this._resultVelocity.elements,t=this.velocity.elements,n=this.velocityAddVariance.elements;return e[0]=t[0]+n[0]*Math.random(),e[1]=t[1]+n[1]*Math.random(),e[2]=t[2]+n[2]*Math.random(),this._resultVelocity},n.emit=function(){e.prototype.emit.call(this),this._particle3D.templet.addParticle(this._randomPositionOnBox(),this._randomVelocityOnBox())},n.update=function(e){this.advanceTime(e.elapsedTime/1e3)},t}(m),function(e){function t(e){this._settings=null,this._particle3D=null,t.__super.call(this),this._resultPosition=new Qe,this._resultVelocity=new Qe,this.position=new Qe,this.positionVariance=new Qe,this.velocity=new Qe,this.velocityAddVariance=new Qe,this._particle3D=e;for(var n=e.templet.settings,i=0;3>i;i++)this.position.elements[i]=n.pointEmitterPosition[i],this.positionVariance.elements[i]=n.pointEmitterPositionVariance[i],this.velocity.elements[i]=n.pointEmitterVelocity[i],this.velocityAddVariance.elements[i]=n.pointEmitterVelocityAddVariance[i];this.emissionRate=n.emissionRate}r(t,"laya.d3.core.particle.EmitterPoint",e);var n=t.prototype;return n._randomPositionOnPoint=function(){var e=this._resultPosition.elements,t=this.position.elements,n=this.positionVariance.elements;return e[0]=t[0]+n[0]*(Math.random()-.5)*2,e[1]=t[1]+n[1]*(Math.random()-.5)*2,e[2]=t[2]+n[2]*(Math.random()-.5)*2,this._resultPosition},n._randomVelocityOnPoint=function(){var e=this._resultVelocity.elements,t=this.velocity.elements,n=this.velocityAddVariance.elements;return e[0]=t[0]+n[0]*Math.random(),e[1]=t[1]+n[1]*Math.random(),e[2]=t[2]+n[2]*Math.random(),this._resultVelocity},n.emit=function(){e.prototype.emit.call(this),this._particle3D.templet.addParticle(this._randomPositionOnPoint(),this._randomVelocityOnPoint())},n.update=function(e){this.advanceTime(e.elapsedTime/1e3)},t}(m),function(e){function t(e){this._settings=null,this._particle3D=null,this.radius=30,this.velocity=0,this.velocityAddVariance=0,this.up=2,t.__super.call(this),this._resultPosition=new Qe,this._resultVelocity=new Qe,this._direction=new Qe,this.centerPosition=new Qe,this._particle3D=e;for(var n=e.templet.settings,i=0;3>i;i++)this.centerPosition.elements[i]=n.ringEmitterCenterPosition[i];this.radius=n.ringEmitterRadius,this.velocity=n.ringEmitterVelocity,this.velocityAddVariance=n.ringEmitterVelocityAddVariance,this.emissionRate=n.emissionRate}r(t,"laya.d3.core.particle.EmitterRing",e);var n=t.prototype;return n._randomPointOnRing=function(){var e=Math.random()*Math.PI*2,t=Math.cos(e),n=Math.sin(e),i=this._resultPosition.elements,r=this.centerPosition.elements;switch(this.up){case 0:i[0]=r[0]+0,i[1]=r[1]+t*this.radius,i[2]=r[2]+n*this.radius;break;case 1:i[0]=r[0]+t*this.radius,i[1]=r[1]+0,i[2]=r[2]+n*this.radius;break;case 2:i[0]=r[0]+t*this.radius,i[1]=r[1]+n*this.radius,i[2]=r[2]+0}return this._resultPosition},n._randomVelocityOnRing=function(){var e=this._resultVelocity.elements;this._resultPosition.cloneTo(this._direction),Qe.normalize(this._direction,this._direction);var t=this._direction.elements;return e[0]=t[0]*(this.velocity+this.velocityAddVariance*Math.random()),e[1]=t[1]*(this.velocity+this.velocityAddVariance*Math.random()),e[2]=t[2]*(this.velocity+this.velocityAddVariance*Math.random()),this._resultVelocity},n.emit=function(){e.prototype.emit.call(this),this._particle3D.templet.addParticle(this._randomPointOnRing(),this._randomVelocityOnRing())},n.update=function(e){this.advanceTime(e/1e3)},t}(m),function(e){function t(e){this._settings=null,this._particle3D=null,this.radius=1,this.velocity=0,this.velocityAddVariance=0,t.__super.call(this),this._reultPosition=new Qe,this._resultVelocity=new Qe,this._direction=new Qe,this.centerPosition=new Qe,this._particle3D=e;for(var n=e.templet.settings,i=0;3>i;i++)this.centerPosition.elements[i]=n.sphereEmitterCenterPosition[i];this.radius=n.sphereEmitterRadius,this.velocity=n.sphereEmitterVelocity,this.velocityAddVariance=n.sphereEmitterVelocityAddVariance,this.emissionRate=n.emissionRate}r(t,"laya.d3.core.particle.EmitterSphere",e);var n=t.prototype;return n._randomPositionOnSphere=function(){var e=Math.random()*Math.PI*2,t=Math.random()*Math.PI*2,n=Math.cos(e)*this.radius,i=Math.sin(e)*this.radius,r=Math.cos(t)*n,a=Math.sin(t)*n,s=this._reultPosition.elements,o=this.centerPosition.elements;return s[0]=o[0]+r,s[1]=o[1]+i,s[2]=o[2]+a,this._reultPosition},n._randomVelocityOnSphere=function(){var e=this._resultVelocity.elements;this._reultPosition.cloneTo(this._direction),Qe.normalize(this._direction,this._direction);var t=this._direction.elements;return e[0]=t[0]*(this.velocity+this.velocityAddVariance*Math.random()),e[1]=t[1]*(this.velocity+this.velocityAddVariance*Math.random()),e[2]=t[2]*(this.velocity+this.velocityAddVariance*Math.random()),this._resultVelocity},n.emit=function(){e.prototype.emit.call(this),this._particle3D.templet.addParticle(this._randomPositionOnSphere(),this._randomVelocityOnSphere())},n.update=function(e){this.advanceTime(e.elapsedTime/1e3)},t}(m),function(e){function t(){t.__super.call(this)}r(t,"laya.d3.core.glitter.SplineCurvePosition",e);var n=t.prototype;return n._CalcVelocity=function(e,t,n){Qe.subtract(e,t,n),Qe.scale(n,.5,n)},n.Init=function(t,n,i,r){this._CalcVelocity(n,t,this._tempVector30),this._CalcVelocity(r,i,this._tempVector31),e.prototype.Init.call(this,n,this._tempVector30,r,this._tempVector31)},t}(B),function(e){function t(){t.__super.call(this,t._name2int,t._int2name,t._int2nameMap)}return r(t,"laya.d3.shader.ShaderDefines3D",e),t.__init__=function(){t.reg("FSHIGHPRECISION",128),t.reg("DIFFUSEMAP",1),t.reg("NORMALMAP",2),t.reg("SPECULARMAP",4),t.reg("EMISSIVEMAP",8),t.reg("AMBIENTMAP",16),t.reg("REFLECTMAP",32),t.reg("PARTICLE3D",262144),t.reg("COLOR",2048),t.reg("UV",1024),t.reg("SKINNED",65536),t.reg("DIRECTIONLIGHT",4096),t.reg("POINTLIGHT",8192),t.reg("SPOTLIGHT",16384),t.reg("BONE",32768),t.reg("ALPHATEST",131072),t.reg("UVTRANSFORM",256),t.reg("FOG",512),t.reg("VR",64),t.reg("SPHERHBILLBOARD",524288),t.reg("STRETCHEDBILLBOARD",1048576),t.reg("HORIZONTALBILLBOARD",2097152),t.reg("VERTICALBILLBOARD",4194304),t.reg("COLOROVERLIFETIME",8388608),t.reg("RANDOMCOLOROVERLIFETIME",16777216),t.reg("SIZEOVERLIFETIME",33554432),t.reg("ROTATIONOVERLIFETIME",67108864),t.reg("TEXTURESHEETANIMATION",134217728),t.reg("VELOCITYOVERLIFETIME",268435456)},t.reg=function(e,n){V._reg(e,n,t._name2int,t._int2name)},t.toText=function(e,t,n){return V._toText(e,t,n)},t.toInt=function(e){return V._toInt(e,t._name2int)},t.FSHIGHPRECISION=128,t.VR=64,t.FOG=512,t.DIRECTIONLIGHT=4096,t.POINTLIGHT=8192,t.SPOTLIGHT=16384,t.DIFFUSEMAP=1,t.NORMALMAP=2,t.SPECULARMAP=4,t.EMISSIVEMAP=8,t.AMBIENTMAP=16,t.REFLECTMAP=32,t.UVTRANSFORM=256,t.UV=1024,t.COLOR=2048,t.BONE=32768,t.SKINNED=65536,t.ALPHATEST=131072,t.PARTICLE3D=262144,t.SPHERHBILLBOARD=524288,t.STRETCHEDBILLBOARD=1048576,t.HORIZONTALBILLBOARD=2097152,t.VERTICALBILLBOARD=4194304,t.COLOROVERLIFETIME=8388608,t.RANDOMCOLOROVERLIFETIME=16777216,t.SIZEOVERLIFETIME=33554432,t.ROTATIONOVERLIFETIME=67108864,t.TEXTURESHEETANIMATION=134217728,t.VELOCITYOVERLIFETIME=268435456,t._name2int={},t._int2name=[],t._int2nameMap=[],t}(V)),_t=function(e){function t(){this.x=NaN,this.y=NaN,this.z=NaN,this.randomDirection=!1,t.__super.call(this),this.x=1,this.y=1,this.z=1,this.randomDirection=!1}r(t,"laya.d3.core.particleShuriKen.module.shape.BoxShape",e);var n=t.prototype;return n.generatePositionAndDirection=function(e,t){var n=e.elements,i=t.elements;$._randomPointInsideHalfUnitBox(e),n[0]=this.x*n[0],n[1]=this.y*n[1],n[2]=this.z*n[2],this.randomDirection?$._randomPointUnitSphere(t):(i[0]=0,i[1]=0,i[2]=-1)},t}(Q),dt=function(e){function t(){this.radius=NaN,this.arc=NaN,this.emitFromEdge=!1,this.randomDirection=!1,t.__super.call(this),this.radius=1,this.arc=2*Math.PI,this.emitFromEdge=!1,this.randomDirection=!1}r(t,"laya.d3.core.particleShuriKen.module.shape.CircleShape",e);var n=t.prototype;return n.generatePositionAndDirection=function(e,n){var i=e.elements,r=t._tempPositionPoint.elements;this.emitFromEdge?$._randomPointUnitArcCircle(this.arc,t._tempPositionPoint):$._randomPointInsideUnitArcCircle(this.arc,t._tempPositionPoint),i[0]=r[0],i[1]=r[1],i[2]=0,Qe.scale(e,this.radius,e),this.randomDirection?$._randomPointUnitSphere(n):e.cloneTo(n)},i(t,["_tempPositionPoint",function(){return this._tempPositionPoint=new Ke}]),t}(Q),mt=function(e){function t(){this.angle=NaN,this.radius=NaN,this.length=NaN,this.emitType=0,this.randomDirection=!1,t.__super.call(this),this.angle=25/180*Math.PI,this.radius=1,this.length=5,this.emitType=0,this.randomDirection=!1}r(t,"laya.d3.core.particleShuriKen.module.shape.ConeShape",e);var n=t.prototype;return n.generatePositionAndDirection=function(e,n){var i,r=e.elements,a=n.elements,s=t._tempPositionPoint.elements,o=NaN,l=NaN,h=Math.cos(this.angle),u=Math.sin(this.angle);switch(this.emitType){case 0:$._randomPointInsideUnitCircle(t._tempPositionPoint),o=s[0],l=s[1],r[0]=o*this.radius,r[1]=l*this.radius,r[2]=0,this.randomDirection?($._randomPointInsideUnitCircle(t._tempDirectionPoint),i=t._tempDirectionPoint.elements,a[0]=i[0]*u,a[1]=i[1]*u):(a[0]=o*u,a[1]=l*u),a[2]=-h;break;case 1:$._randomPointUnitCircle(t._tempPositionPoint),o=s[0],l=s[1],r[0]=o*this.radius,r[1]=l*this.radius,r[2]=0,this.randomDirection?($._randomPointInsideUnitCircle(t._tempDirectionPoint),i=t._tempDirectionPoint.elements,a[0]=i[0]*u,a[1]=i[1]*u):(a[0]=o*u,a[1]=l*u),a[2]=-h;break;case 2:$._randomPointInsideUnitCircle(t._tempPositionPoint),o=s[0],l=s[1],r[0]=o*this.radius,r[1]=l*this.radius,r[2]=0,a[0]=o*u,a[1]=l*u,a[2]=-h,Qe.normalize(n,n),Qe.scale(n,this.length*Math.random(),n),Qe.add(e,n,e),this.randomDirection&&$._randomPointUnitSphere(n);break;case 3:$._randomPointUnitCircle(t._tempPositionPoint),o=s[0],l=s[1],r[0]=o*this.radius,r[1]=l*this.radius,r[2]=0,a[0]=o*u,a[1]=l*u,a[2]=-h,Qe.normalize(n,n),Qe.scale(n,this.length*Math.random(),n),Qe.add(e,n,e),this.randomDirection&&$._randomPointUnitSphere(n);break;default:throw new Error("ConeShape:emitType is invalid.")}},i(t,["_tempPositionPoint",function(){return this._tempPositionPoint=new Ke},"_tempDirectionPoint",function(){return this._tempDirectionPoint=new Ke}]),t}(Q),ft=function(e){function t(){this.radius=NaN,this.emitFromShell=!1,this.randomDirection=!1,t.__super.call(this),this.radius=1,this.emitFromShell=!1,this.randomDirection=!1}r(t,"laya.d3.core.particleShuriKen.module.shape.HemisphereShape",e);var n=t.prototype;return n.generatePositionAndDirection=function(e,t){var n=e.elements;this.emitFromShell?$._randomPointUnitSphere(e):$._randomPointInsideUnitSphere(e),Qe.scale(e,this.radius,e);var i=n[2];i>0&&(n[2]=-1*i),this.randomDirection?$._randomPointUnitSphere(t):e.cloneTo(t)},t}(Q),pt=function(e){function t(){this.radius=NaN,this.emitFromShell=!1,this.randomDirection=!1,t.__super.call(this),this.radius=1,this.emitFromShell=!1,this.randomDirection=!1}r(t,"laya.d3.core.particleShuriKen.module.shape.SphereShape",e);var n=t.prototype;return n.generatePositionAndDirection=function(e,t){this.emitFromShell?$._randomPointUnitSphere(e):$._randomPointInsideUnitSphere(e),Qe.scale(e,this.radius,e),this.randomDirection?$._randomPointUnitSphere(t):e.cloneTo(t)},t}(Q),vt=function(e){function t(e){this._id=0,this._enable=!1,this._layerMask=0,this._componentsMap=[],this.transform=null,this.isStatic=!1,t.__super.call(this),this._components=[],e?this.name=e:this.name="Sprite3D-"+t._nameNumberCounter++,this._enable=!0,this._id=++t._uniqueIDCounter,this.layer=U.currentCreationLayer,this.transform=new ht(this),this.on("display",this,this._onDisplay),this.on("undisplay",this,this._onUnDisplay)}r(t,"laya.d3.core.Sprite3D",e);var i=t.prototype;return n.imps(i,{"laya.d3.core.render.IUpdate":!0,"laya.resource.ICreateResource":!0,"laya.d3.core.IClone":!0}),i._onDisplay=function(){this.transform.parent=this._parent.transform,this._addSelfRenderObjects()},i._onUnDisplay=function(){this.transform.parent=null,this._clearSelfRenderObjects()},i._clearSelfRenderObjects=function(){},i._addSelfRenderObjects=function(){},i._updateComponents=function(e){for(var t=0,n=this._components.length;n>t;t++){var i=this._components[t];!i.started&&(i._start(e),i.started=!0),i.isActive&&i._update(e)}},i._lateUpdateComponents=function(e){for(var t=0;t<this._components.length;t++){var n=this._components[t];!n.started&&(n._start(e),n.started=!0),n.isActive&&n._lateUpdate(e)}},i._updateChilds=function(e){var t=this._childs.length;if(0!==t)for(var n=0;t>n;++n)this._childs[n]._update(e)},i._getSortID=function(e,t){return e._getVertexBuffer().vertexDeclaration.id+1e3*t.id},i._update=function(e){e.owner=this,this._enable&&(this._updateComponents(e),this._lateUpdateComponents(e)),L.spriteCount++,this._childs.length&&this._updateChilds(e)},i.loadHierarchy=function(e){this.addChild(laya.d3.core.Sprite3D.load(e))},i.addChildAt=function(t,n){if(!(t instanceof laya.d3.core.Sprite3D))throw new Error("Sprite3D:Node type must Sprite3D.");return e.prototype.addChildAt.call(this,t,n)},i.addChild=function(t){if(!(t instanceof laya.d3.core.Sprite3D))throw new Error("Sprite3D:Node type must Sprite3D.");return e.prototype.addChild.call(this,t)},i.addComponent=function(e){if(-1!==this._componentsMap.indexOf(e))throw new Error("无法创建"+e+"组件,"+e+"组件已存在!");var t=_.getInstance(e);return t._initialize(this),this._componentsMap.push(e),this._components.push(t),this.event("componentadded",t),t},i.getComponentByType=function(e){var t=this._componentsMap.indexOf(e);return-1===t?null:this._components[t]},i.getComponentByIndex=function(e){return this._components[e]},i.removeComponent=function(e){var t=this._componentsMap.indexOf(e);if(-1!==t){var n=this._components[t];this._components.splice(t,1),this._componentsMap.splice(t,1),n._uninitialize(),this.event("componentremoved",n)}},i.removeAllComponent=function(){for(var e in this._componentsMap)this.removeComponent(e)},i.onAsynLoaded=function(e,t){var n=t[0],i=t[1];_.createByJson(n,this,this,p.create(null,rt._parseHierarchyProp,[i],!1),p.create(null,rt._parseHierarchyNode,null,!1)),this.event("hierarchyloaded",[this])},i.cloneTo=function(e){var t=e;t.name=this.name,t.destroyed=this.destroyed,t.timer=this.timer,t._displayedInStage=this._displayedInStage,t._$P=this._$P,t._enable=this._enable,t._layerMask=this._layerMask;var n=t.transform.localMatrix;this.transform.localMatrix.cloneTo(n),t.transform.localMatrix=n,t.isStatic=this.isStatic;var i=0,r=0;for(i=0,r=this._componentsMap.length;r>i;i++)t.addComponent(this._componentsMap[i]);for(i=0,r=this._childs.length;r>i;i++)t.addChild(this._childs[i].clone())},i.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},i.destroy=function(t){void 0===t&&(t=!0),e.prototype.destroy.call(this,t);for(var n=0,i=this._components.length;i>n;n++)this._components[n]._uninitialize();this._components=null,this._componentsMap=null,this.transform=null},a(0,i,"componentsCount",function(){return this._components.length}),a(0,i,"id",function(){return this._id}),a(0,i,"layer",function(){return U.getLayerByMask(this._layerMask)},function(e){this._layerMask=e.mask,this.event("layerchanged",e)}),a(0,i,"enable",function(){return this._enable},function(e){this._enable!==e&&(this._enable=e,this.event("enabledchanged",this._enable))}),a(0,i,"active",function(){return U.isActive(this._layerMask)&&this._enable}),a(0,i,"visible",function(){return U.isVisible(this._layerMask)&&this._enable}),a(0,i,"scene",function(){return this.parent?this.parent.scene:null}),t.instantiate=function(e,t,n,i,r){void 0===r&&(r=!0);var a,s=e.clone();if(t||n)i&&i.addChild(s),a=s.transform,t&&(a.position=t),n&&(a.rotation=n);else if(r){if(a=s.transform,i){var o=a.position,l=a.rotation;i.addChild(s),a.position=o,a.rotation=l}}else i&&i.addChild(s);return s},t.load=function(e){return n.loader.create(e,null,null,t,1,!1)},t._uniqueIDCounter=0,t._nameNumberCounter=0,t}(M),gt=function(e){function t(){this._renderQueue=0,this._renderMode=0,this._sharderNameID=0,this._shaderDefineValue=0,this._disableShaderDefineValue=0,this._shaderValues=null,this._textureSharderIndices=null,this._colorSharderIndices=null,this._numberSharderIndices=null,this._matrix4x4SharderIndices=null,this._textures=null,this._colors=null,this._numbers=null,this._matrix4x4s=null,this._isInstance=!1,this.shader=null,t.__super.call(this),this._loaded=!0,this._isInstance=!1,this._shaderDefineValue=0,this._disableShaderDefineValue=0,this._shaderValues=new b,this._textures=[],this._colors=[],this._numbers=[],this._matrix4x4s=[],this._textureSharderIndices=[],this._colorSharderIndices=[],this._numberSharderIndices=[],this._matrix4x4SharderIndices=[],this.renderMode=1}r(t,"laya.d3.core.material.BaseMaterial",e);var i=t.prototype;return n.imps(i,{"laya.d3.core.IClone":!0}),i._uploadTextures=function(){for(var e=0,t=this._textures.length;t>e;e++){var n=this._textures[e];if(n){var i=n.source;i?this._uploadTexture(e,i):this._uploadTexture(e,Ht.grayTexture.source)}}},i._getShader=function(e,t){var n=e._value|t|this._shaderDefineValue;this._disableShaderDefineValue&&(n&=~this._disableShaderDefineValue),e._value=n;var i=n+2e-4*this._sharderNameID;this.shader=C.withCompile(this._sharderNameID,e.toNameDic(),i,null)},i._uploadTexture=function(e,t){this._shaderValues.data[this._textureSharderIndices[e]]=t},i._addShaderDefine=function(e){this._shaderDefineValue|=e},i._removeShaderDefine=function(e){this._shaderDefineValue&=~e},i._addDisableShaderDefine=function(e){this._disableShaderDefineValue|=e},i._removeDisableShaderDefine=function(e){this._disableShaderDefineValue&=~e},i._setMatrix4x4=function(e,t,n){var i=this._shaderValues,r=this._matrix4x4SharderIndices[e];!r&&n&&(this._matrix4x4SharderIndices[e]=r=i.length+1,i.pushValue(t,null)),i.data[r]=n.elements,this._matrix4x4s[e]=n},i._getMatrix4x4=function(e){return this._matrix4x4s[e]},i._setNumber=function(e,t,n){var i=this._shaderValues,r=this._numberSharderIndices[e];!r&&n&&(this._numberSharderIndices[e]=r=i.length+1,i.pushValue(t,null)),i.data[r]=n,this._numbers[e]=n},i._getNumber=function(e){return this._numbers[e]},i._setColor=function(e,t,n){var i=this._shaderValues,r=this._colorSharderIndices[e];!r&&n&&(this._colorSharderIndices[e]=r=i.length+1,i.pushValue(t,null)),i.data[r]=n.elements,this._colors[e]=n},i._getColor=function(e){return this._colors[e]},i._setTexture=function(e,t,n){var i=this._shaderValues,r=this._textureSharderIndices[t];!r&&e&&(this._textureSharderIndices[t]=r=i.length+1,i.pushValue(n,null)),this._textures[t]=e},i._getTexture=function(e){return this._textures[e]},i._upload=function(e,t,n){this._uploadTextures(),this._getShader(e.shaderDefines,t.shaderDefineValue);var i=e.shaderValue;i.pushArray(this._shaderValues),this.shader.uploadArray(i.data,i.length,n)},i._setLoopShaderParams=function(e,t,n,i,r){throw new Error("Marterial:must override it.")},i.onAsynLoaded=function(e,t){var n=t[0],i=t[1],r=p.create(null,rt._parseMaterial,[i],!1);_.createByJson(n,this,null,r,null),r.recover(),this.event("loaded",this)},i.setShaderName=function(e){this._sharderNameID=C.nameKey.get(e)},i.cloneTo=function(e){var t=e;t.name=this.name,t._loaded=this._loaded,t._renderQueue=this._renderQueue,t._renderMode=this._renderMode,t.shader=this.shader,t._sharderNameID=this._sharderNameID,t._disableShaderDefineValue=this._disableShaderDefineValue,t._shaderDefineValue=this._shaderDefineValue;var n=0,i=0,r=0,a=t._shaderValues;t._shaderValues.length=this._shaderValues.length,t._colorSharderIndices=this._colorSharderIndices.slice();var s=this._colors.length,o=t._colors;for(o.length=s,n=0,i=s;i>n;n++){var l=o[n];this._colors[n].cloneTo(l),r=this._colorSharderIndices[n]-1,a.data[r]=this._shaderValues.data[r],a.data[r+1]=l.elements}t._numberSharderIndices=this._numberSharderIndices.slice();var h=this._numbers.length,u=t._numbers;for(u.length=h,n=0,i=h;i>n;n++){var c=this._numbers[n];u[n]=c,r=this._numberSharderIndices[n]-1,a.data[r]=this._shaderValues.data[r],a.data[r+1]=c}t._matrix4x4SharderIndices=this._matrix4x4SharderIndices.slice();var _=this._matrix4x4s.length,d=t._matrix4x4s;for(d.length=_,n=0,i=_;i>n;n++){var m=d[n];this._matrix4x4s[n].cloneTo(m),r=this._matrix4x4SharderIndices[n]-1,a.data[r]=this._shaderValues.data[r],a.data[r+1]=m.elements}t._textureSharderIndices=this._textureSharderIndices.slice();var f=this._textures.length,p=t._textures;for(p.length=f,n=0,i=f;i>n;n++)p[n]=this._textures[n],r=this._textureSharderIndices[n]-1,a.data[r]=this._shaderValues.data[r]},i.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},i.dispose=function(){this.resourceManager.removeResource(this),e.prototype.dispose.call(this)},a(0,i,"renderQueue",function(){return this._renderQueue}),a(0,i,"renderMode",function(){return this._renderMode},function(e){switch(this._renderMode=e,e){case 1:this._renderQueue=1,this.event("renderqueuechanged",this);break;case 2:this._renderQueue=2,this.event("renderqueuechanged",this);break;case 3:this._renderQueue=1,this.event("renderqueuechanged",this);break;case 4:this._renderQueue=2,this.event("renderqueuechanged",this);break;case 13:this._renderQueue=3,this.event("renderqueuechanged",this);break;case 14:this._renderQueue=4,this.event("renderqueuechanged",this);break;case 15:this._renderQueue=5,this.event("renderqueuechanged",this);break;case 16:this._renderQueue=6,this.event("renderqueuechanged",this);break;case 5:this._renderQueue=7,this.event("renderqueuechanged",this);break;case 6:this._renderQueue=8,this.event("renderqueuechanged",this);break;case 7:this._renderQueue=9,this.event("renderqueuechanged",this);break;case 8:this._renderQueue=10,this.event("renderqueuechanged",this);break;case 9:this._renderQueue=11,this.event("renderqueuechanged",this);break;case 10:this._renderQueue=12,this.event("renderqueuechanged",this);break;case 11:this._renderQueue=13,this.event("renderqueuechanged",this);break;case 12:this._renderQueue=14,this.event("renderqueuechanged",this);break;default:throw new Error("Material:renderMode value error.")}3===this._renderMode||4===this._renderMode?this._addShaderDefine(131072):this._removeShaderDefine(131072)}),t.RENDERMODE_OPAQUE=1,t.RENDERMODE_OPAQUEDOUBLEFACE=2,t.RENDERMODE_CUTOUT=3,t.RENDERMODE_CUTOUTDOUBLEFACE=4,t.RENDERMODE_TRANSPARENT=13,t.RENDERMODE_TRANSPARENTDOUBLEFACE=14,t.RENDERMODE_ADDTIVE=15,t.RENDERMODE_ADDTIVEDOUBLEFACE=16,t.RENDERMODE_DEPTHREAD_TRANSPARENT=5,t.RENDERMODE_DEPTHREAD_TRANSPARENTDOUBLEFACE=6,t.RENDERMODE_DEPTHREAD_ADDTIVE=7,t.RENDERMODE_DEPTHREAD_ADDTIVEDOUBLEFACE=8,t.RENDERMODE_NONDEPTH_TRANSPARENT=9,t.RENDERMODE_NONDEPTH_TRANSPARENTDOUBLEFACE=10,t.RENDERMODE_NONDEPTH_ADDTIVE=11,t.RENDERMODE_NONDEPTH_ADDTIVEDOUBLEFACE=12,t}(A),Tt=function(e){function t(){this._width=0,this._height=0,this._size=null,this._repeat=!1,this._mipmap=!1,this._minFifter=0,this._magFifter=0,this._source=null,t.__super.call(this),this._repeat=!0,this._mipmap=!0,this._minFifter=-1,this._magFifter=-1}r(t,"laya.d3.resource.BaseTexture",e);var n=t.prototype;return n.dispose=function(){this.resourceManager.removeResource(this),e.prototype.dispose.call(this)},a(0,n,"width",function(){return this._width}),a(0,n,"repeat",function(){return this._repeat}),a(0,n,"height",function(){return this._height}),a(0,n,"magFifter",function(){return this._magFifter}),a(0,n,"size",function(){return this._size}),a(0,n,"mipmap",function(){return this._mipmap}),a(0,n,"minFifter",function(){return this._minFifter}),a(0,n,"source",function(){return this.activeResource(),this._source}),t}(A),xt=function(e){function t(){this._subMeshCount=0,this._boundingBox=null,this._boundingSphere=null,t.__super.call(this),this._loaded=!1}r(t,"laya.d3.resource.models.BaseMesh",e);var n=t.prototype;return n.getRenderElementsCount=function(){throw new Error("未Override,请重载该属性!")},n.getRenderElement=function(e){throw new Error("未Override,请重载该属性!")},a(0,n,"positions",function(){throw new Error("未Override,请重载该属性!")}),a(0,n,"subMeshCount",function(){return this._subMeshCount}),a(0,n,"boundingBox",function(){return this._boundingBox}),a(0,n,"boundingSphere",function(){return this._boundingSphere}),t}(A),Mt=function(e){function t(){t.__super.call(this)}r(t,"laya.d3.resource.models.Sky",e);var n=t.prototype;return n._render=function(e){},t.MVPMATRIX="MVPMATRIX",t.INTENSITY="INTENSITY",t.ALPHABLENDING="ALPHABLENDING",t.DIFFUSETEXTURE="DIFFUSETEXTURE",t}(A),Et=function(e){function t(){this._player=null,this._templet=null,t.__super.call(this),this._player=new s}r(t,"laya.d3.component.animation.KeyframeAnimations",e);var i=t.prototype;return i._updateAnimtionPlayer=function(){this._player.update(n.timer.delta)},i._addUpdatePlayerToTimer=function(){n.timer.frameLoop(1,this,this._updateAnimtionPlayer)},i._removeUpdatePlayerToTimer=function(){n.timer.clear(this,this._updateAnimtionPlayer)},i._onOwnerEnableChanged=function(e){this._owner.displayedInStage&&(e?this._addUpdatePlayerToTimer():this._removeUpdatePlayerToTimer())},i._onDisplayInStage=function(){this._owner.enable&&this._addUpdatePlayerToTimer()},i._onUnDisplayInStage=function(){this._owner.enable&&this._removeUpdatePlayerToTimer()},i._load=function(e){this._owner.displayedInStage&&this._owner.enable&&this._addUpdatePlayerToTimer(),this._owner.on("enabledchanged",this,this._onOwnerEnableChanged),this._owner.on("display",this,this._onDisplayInStage),this._owner.on("undisplay",this,this._onUnDisplayInStage)},i._unload=function(t){e.prototype._unload.call(this,t),this._owner.displayedInStage&&this._owner.enable&&this._removeUpdatePlayerToTimer(),this._owner.off("enabledchanged",this,this._onOwnerEnableChanged),this._owner.off("display",this,this._onDisplayInStage),this._owner.off("undisplay",this,this._onUnDisplayInStage),this._player._destroy(),this._player=null,this._templet=null},a(0,i,"url",null,function(e){console.log("Warning: discard property,please use templet property instead.");var t=n.loader.create(e,null,null,o);this._templet!==t&&(0!==this._player.state&&this._player.stop(!0),this._templet=t,this._player.templet=t,this.event("animationchanged",this))}),a(0,i,"player",function(){return this._player}),a(0,i,"templet",function(){return this._templet},function(e){this._templet!==e&&(0!==this._player.state&&this._player.stop(!0),this._templet=e,this._player.templet=e,this.event("animationchanged",this))}),a(0,i,"currentFrameIndex",function(){return this._player.currentKeyframeIndex}),a(0,i,"currentAnimationClipIndex",function(){return this._player.currentAnimationClipIndex}),a(0,i,"nodeCount",function(){return this._templet.getNodeCount(this._player.currentAnimationClipIndex)}),t}(at),yt=(function(e){function t(){this._attachSkeleton=null,this._data=null,this._extenData=null,this.attachBones=null,this.matrixs=null,t.__super.call(this),this.attachBones=[],this.matrixs=[]}r(t,"laya.d3.component.AttachPoint",e);var n=t.prototype;return n._load=function(t){e.prototype._load.call(this,t),this._attachSkeleton=t.getComponentByType(Ut)},n._update=function(e){if(this._attachSkeleton&&2===this._attachSkeleton.player.state&&this._attachSkeleton.curBonesDatas){var t=this._attachSkeleton.player;this.matrixs.length=this.attachBones.length;for(var n=0;n<this.attachBones.length;n++){var i=this._attachSkeleton.templet.getNodeIndexWithName(t.currentAnimationClipIndex,this.attachBones[n]);this._data=this._attachSkeleton.curBonesDatas.subarray(16*i,16*(i+1));var r=this.matrixs[n];r||(r=this.matrixs[n]=new je),r.copyFromArray(this._data),je.multiply(this.owner.transform.worldMatrix,r,r)}}},t}(at),function(e){function t(){t.__super.call(this)}return r(t,"laya.d3.component.Script",e),t}(at),function(e){function t(e){t.__super.call(this,e)}r(t,"laya.d3.core.GlitterRender",e);var n=t.prototype;return n._calculateBoundingBox=function(){var e=this._boundingBox.min.elements;e[0]=-Number.MAX_VALUE,e[1]=-Number.MAX_VALUE,e[2]=-Number.MAX_VALUE;var t=this._boundingBox.min.elements;t[0]=Number.MAX_VALUE,t[1]=Number.MAX_VALUE,t[2]=Number.MAX_VALUE},n._calculateBoundingSphere=function(){var e=this._boundingSphere.center.elements;e[0]=0,e[1]=0,e[2]=0,this._boundingSphere.radius=Number.MAX_VALUE},t}(st)),St=function(e){function t(e){this._meshSprite3DOwner=null,this.castShadow=!1,this.receiveShadow=!1,t.__super.call(this,e),this._meshSprite3DOwner=e,this.castShadow=!0,this.receiveShadow=!0,this._meshSprite3DOwner.meshFilter.on("meshchanged",this,this._onMeshChanged)}r(t,"laya.d3.core.MeshRender",e);var n=t.prototype;return n._onMeshChanged=function(e,t,n){n.loaded?(this._boundingSphereNeedChange=!0,this._boundingBoxNeedChange=!0):n.once("loaded",this,this._onMeshLoaed)},n._onMeshLoaed=function(e,t){this._boundingSphereNeedChange=!0,this._boundingBoxNeedChange=!0},n._calculateBoundingSphere=function(){if(null===this._meshSprite3DOwner.meshFilter.sharedMesh||null===this._meshSprite3DOwner.meshFilter.sharedMesh.boundingSphere)this._boundingSphere.toDefault();else{var e=this._meshSprite3DOwner.meshFilter.sharedMesh.boundingSphere,t=NaN,n=this._meshSprite3DOwner.transform,i=n.scale;t=i.x>=i.y&&i.x>=i.z?i.x:i.y>=i.z?i.y:i.z,Qe.transformCoordinate(e.center,n.worldMatrix,this._boundingSphere.center),this._boundingSphere.radius=e.radius*t}},n._calculateBoundingBox=function(){if(null===this._meshSprite3DOwner.meshFilter.sharedMesh||null===this._meshSprite3DOwner.meshFilter.sharedMesh.boundingBox)this._boundingBox.toDefault();else{var e=this._meshSprite3DOwner.meshFilter.sharedMesh.boundingBox,t=this._meshSprite3DOwner.transform.worldMatrix;Qe.transformCoordinate(e.min,t,this._boundingBox.min),Qe.transformCoordinate(e.max,t,this._boundingBox.max)}},n._destroy=function(){e.prototype._destroy.call(this),this._meshSprite3DOwner=null},t}(st),Rt=function(e){function t(e){t.__super.call(this,e)}r(t,"laya.d3.core.ParticleRender",e);var n=t.prototype;return n._calculateBoundingBox=function(){var e=this._boundingBox.min.elements;e[0]=-Number.MAX_VALUE,e[1]=-Number.MAX_VALUE,e[2]=-Number.MAX_VALUE;var t=this._boundingBox.min.elements;t[0]=Number.MAX_VALUE,t[1]=Number.MAX_VALUE,t[2]=Number.MAX_VALUE},n._calculateBoundingSphere=function(){var e=this._boundingSphere.center.elements;e[0]=0,e[1]=0,e[2]=0,
|
||
this._boundingSphere.radius=Number.MAX_VALUE},t}(st),At=function(e){function t(e){this.renderMode=0,this.stretchedBillboardCameraSpeedScale=0,this.stretchedBillboardSpeedScale=0,this.stretchedBillboardLengthScale=1,t.__super.call(this,e),this.renderMode=0}r(t,"laya.d3.core.particleShuriKen.ShurikenParticleRender",e);var n=t.prototype;return n._calculateBoundingBox=function(){var e=this._boundingBox.min.elements;e[0]=-Number.MAX_VALUE,e[1]=-Number.MAX_VALUE,e[2]=-Number.MAX_VALUE;var t=this._boundingBox.min.elements;t[0]=Number.MAX_VALUE,t[1]=Number.MAX_VALUE,t[2]=Number.MAX_VALUE},n._calculateBoundingSphere=function(){var e=this._boundingSphere.center.elements;e[0]=0,e[1]=0,e[2]=0,this._boundingSphere.radius=Number.MAX_VALUE},t}(st),It=function(e){function t(e,n){this._owner=null,this._vertexBuffer3D=null,this._indexBuffer3D=null,t.__super.call(this,n),this._owner=e,this.initialize(),this._vertexBuffer=this._vertexBuffer3D=Bt.create(ge.vertexDeclaration,4*n.maxPartices,35048),this._indexBuffer=this._indexBuffer3D=Nt.create("ushort",6*n.maxPartices,35044,!0),this.loadContent()}r(t,"laya.d3.resource.tempelet.ParticleTemplet3D",e);var i=t.prototype;return n.imps(i,{"laya.d3.core.render.IRenderable":!0}),i._getVertexBuffer=function(e){return void 0===e&&(e=0),0===e?this._vertexBuffer3D:null},i._getIndexBuffer=function(){return this._indexBuffer3D},i.addParticle=function(e,t){this.addParticleArray(e.elements,t.elements)},i.loadContent=function(){for(var e=new Uint16Array(6*this.settings.maxPartices),t=0;t<this.settings.maxPartices;t++)e[6*t+0]=4*t+0,e[6*t+1]=4*t+1,e[6*t+2]=4*t+2,e[6*t+3]=4*t+0,e[6*t+4]=4*t+2,e[6*t+5]=4*t+3;this._indexBuffer3D.setData(e)},i.addNewParticlesToVertexBuffer=function(){var e=0;this._firstNewElement<this._firstFreeElement?(e=4*this._firstNewElement*this._floatCountPerVertex,this._vertexBuffer3D.setData(this._vertices,e,e,4*(this._firstFreeElement-this._firstNewElement)*this._floatCountPerVertex)):(e=4*this._firstNewElement*this._floatCountPerVertex,this._vertexBuffer3D.setData(this._vertices,e,e,4*(this.settings.maxPartices-this._firstNewElement)*this._floatCountPerVertex),this._firstFreeElement>0&&this._vertexBuffer3D.setData(this._vertices,0,0,4*this._firstFreeElement*this._floatCountPerVertex)),this._firstNewElement=this._firstFreeElement},i._beforeRender=function(e){return this._firstNewElement!=this._firstFreeElement&&this.addNewParticlesToVertexBuffer(),this._drawCounter++,this._firstActiveElement!=this._firstFreeElement?(this._vertexBuffer3D._bind(),this._indexBuffer._bind(),!0):!1},i._render=function(e){var t=0,n=w.mainContext;this._firstActiveElement<this._firstFreeElement?(t=6*(this._firstFreeElement-this._firstActiveElement),n.drawElements(4,t,5123,6*this._firstActiveElement*2),L.trianglesFaces+=t/3,L.drawCall++):(t=6*(this.settings.maxPartices-this._firstActiveElement),n.drawElements(4,t,5123,6*this._firstActiveElement*2),L.trianglesFaces+=t/3,L.drawCall++,this._firstFreeElement>0&&(t=6*this._firstFreeElement,n.drawElements(4,t,5123,0),L.trianglesFaces+=t/3,L.drawCall++))},a(0,i,"indexOfHost",function(){return 0}),a(0,i,"_vertexBufferCount",function(){return 1}),a(0,i,"triangleCount",function(){return this._indexBuffer3D.indexCount/3}),t}(y),Ct=function(e){function t(){this._invertYProjectionMatrix=null,this._invertYProjectionViewMatrix=null,this._invertYScaleMatrix=null,this._boundFrustum=null,this._enableLightCount=3,this._renderTargetTexture=null,this._customRenderQueneIndex=11,this._lastCurrentTime=NaN,this._staticBatchManager=null,this._dynamicBatchManager=null,this.enableFog=!1,this.fogStart=NaN,this.fogRange=NaN,this.fogColor=null,this.enableLight=!0,t.__super.call(this),this._renderState=new le,this._lights=new Array,this._renderConfigs=[],this._frustumCullingObjects=[],this._quenes=[],this._cameraPool=[],this._invertYProjectionMatrix=new je,this._invertYProjectionViewMatrix=new je,this._invertYScaleMatrix=new je,je.createScaling(new Qe(1,-1,1),this._invertYScaleMatrix),this._staticBatchManager=new me,this._dynamicBatchManager=new ue,this._boundFrustum=new He(je.DEFAULT),this.enableFog=!1,this.fogStart=300,this.fogRange=1e3,this.fogColor=new Qe(.7,.7,.7);var e;e=this._renderConfigs[1]=new ae,e=this._renderConfigs[2]=new ae,e.cullFace=!1,e=this._renderConfigs[3]=new ae,e.blend=!0,e.sFactor=770,e.dFactor=771,e=this._renderConfigs[4]=new ae,e.cullFace=!1,e.blend=!0,e.sFactor=770,e.dFactor=771,e=this._renderConfigs[5]=new ae,e.blend=!0,e.sFactor=770,e.dFactor=1,e=this._renderConfigs[6]=new ae,e.cullFace=!1,e.blend=!0,e.sFactor=770,e.dFactor=1,e=this._renderConfigs[7]=new ae,e.blend=!0,e.depthMask=0,e.sFactor=770,e.dFactor=771,e=this._renderConfigs[9]=new ae,e.blend=!0,e.depthMask=0,e.sFactor=770,e.dFactor=1,e=this._renderConfigs[8]=new ae,e.cullFace=!1,e.blend=!0,e.depthMask=0,e.sFactor=770,e.dFactor=771,e=this._renderConfigs[10]=new ae,e.cullFace=!1,e.blend=!0,e.depthMask=0,e.sFactor=770,e.dFactor=1,e=this._renderConfigs[11]=new ae,e.blend=!0,e.depthTest=!1,e.sFactor=770,e.dFactor=771,e=this._renderConfigs[13]=new ae,e.blend=!0,e.depthTest=!1,e.sFactor=770,e.dFactor=1,e=this._renderConfigs[12]=new ae,e.cullFace=!1,e.blend=!0,e.depthTest=!1,e.sFactor=770,e.dFactor=771,e=this._renderConfigs[14]=new ae,e.cullFace=!1,e.blend=!0,e.depthTest=!1,e.sFactor=770,e.dFactor=1,this.on("display",this,this._$3__onDisplay),this.on("undisplay",this,this._onUnDisplay)}r(t,"laya.d3.core.scene.BaseScene",e);var i=t.prototype;return n.imps(i,{"laya.webgl.submit.ISubmit":!0}),i._$3__onDisplay=function(){n.stage._scenes.push(this),n.stage._scenes.sort(t._sortScenes)},i._onUnDisplay=function(){var e=n.stage._scenes;e.splice(e.indexOf(this),1)},i._prepareUpdateToRenderState=function(e,t){t.context=w.mainContext,t.elapsedTime=this._lastCurrentTime?this.timer.currTimer-this._lastCurrentTime:0,this._lastCurrentTime=this.timer.currTimer,t.loopCount=L.loopCount,t.scene=this},i._prepareRenderToRenderState=function(e,t){var n=t.shaderDefines;w.frameShaderHighPrecision&&n.addInt(128),U._currentCameraCullingMask=e.cullingMask,t.camera=e;var i=t.shaderValue;if(e&&i.pushValue("CAMERAPOS",e.transform.position.elements),this._lights.length>0)for(var r=0,a=0;a<this._lights.length;a++){var s=this._lights[a];if(s.active){if(r++,r>this._enableLightCount)break;s.updateToWorldState(t)}}this.enableFog&&(n.addInt(512),i.pushValue("FOGSTART",this.fogStart),i.pushValue("FOGRANGE",this.fogRange),i.pushValue("FOGCOLOR",this.fogColor.elements))},i._endRenderToRenderState=function(e){e.reset()},i._updateScene=function(){var e=this._renderState;this._prepareUpdateToRenderState(w.mainContext,e),this.beforeUpate(e),this._updateChilds(e),this.lateUpate(e)},i._updateChilds=function(e){for(var t=0,n=this._childs.length;n>t;++t)this._childs[t]._update(e)},i._preRenderScene=function(e,t){this._boundFrustum.matrix=t.projectionViewMatrix,ce.RenderObjectCulling(this._boundFrustum,this);for(var n=0,i=this._quenes.length;i>n;n++)this._quenes[n]&&this._quenes[n]._preRender(t)},i._clear=function(e,t){var n=t.viewport,i=t.camera,r=i.renderTargetSize.height;e.viewport(n.x,r-n.y-n.height,n.width,n.height);var a=0;switch(i.clearFlag){case 0:if(i.clearColor){e.enable(3089),e.scissor(n.x,r-n.y-n.height,n.width,n.height);var s=i.clearColor.elements;if(e.clearColor(s[0],s[1],s[2],s[3]),a=16384,i.renderTarget)switch(i.renderTarget.depthStencilFormat){case 33189:a|=256;break;case 36168:a|=1024;break;case 34041:a|=256,a|=1024}else a|=256;e.clear(a),e.disable(3089)}else e.clear(256);break;case 1:case 2:if(i.renderTarget)switch(i.renderTarget.depthStencilFormat){case 33189:a|=256;break;case 36168:a|=1024;break;case 34041:a|=256,a|=1024}else a|=256;break;case 3:break;default:throw new Error("BaseScene:camera clearFlag invalid.")}},i._renderScene=function(e,t){var n,i=t.camera,r=0,a=0;for(r=0;3>r;r++)n=this._quenes[r],n&&(n._setState(e,t),n._render(t));if(1===i.clearFlag){var s=i.sky;s&&(N.setCullFace(e,!1),N.setDepthFunc(e,515),N.setDepthMask(e,0),s._render(t),N.setDepthFunc(e,513),N.setDepthMask(e,1))}for(r=3,a=this._quenes.length;a>r;r++)n=this._quenes[r],n&&(n._sortAlpha(t.camera.transform.position),n._setState(e,t),n._render(t))},i._set3DRenderConfig=function(e){e.disable(3042),N._blend=!1,e.blendFunc(770,771),N._sFactor=770,N._dFactor=771,e.disable(2929),N._depthTest=!1,e.enable(2884),N._cullFace=!0,e.depthMask(1),N._depthMask=1,e.frontFace(2304),N._frontFace=2304},i._set2DRenderConfig=function(e){N.setBlend(e,!0),N.setBlendFunc(e,770,771),N.setDepthTest(e,!1),N.setCullFace(e,!1),N.setDepthMask(e,1),N.setFrontFaceCCW(e,2305),e.viewport(0,0,R.width,R.height)},i._addLight=function(e){this._lights.indexOf(e)<0&&this._lights.push(e)},i._removeLight=function(e){var t=this._lights.indexOf(e);t>=0&&this._lights.splice(t,1)},i.addChildAt=function(e,t){if(!(e instanceof laya.d3.core.Sprite3D))throw new Error("Sprite3D:Node type must Sprite3D.");return laya.display.Node.prototype.addChildAt.call(this,e,t)},i.addChild=function(e){if(!(e instanceof laya.d3.core.Sprite3D))throw new Error("Sprite3D:Node type must Sprite3D.");return laya.display.Node.prototype.addChild.call(this,e)},i.addFrustumCullingObject=function(e){this._frustumCullingObjects.push(e)},i.removeFrustumCullingObject=function(e){var t=this._frustumCullingObjects.indexOf(e);-1!==t&&this._frustumCullingObjects.splice(t,1)},i.getRenderQueue=function(e){return this._quenes[e]||(this._quenes[e]=new oe(this._renderConfigs[e],this))},i.addRenderQuene=function(e){this._quenes[this._customRenderQueneIndex++]=new oe(e,this)},i.beforeUpate=function(e){},i.lateUpate=function(e){},i.beforeRender=function(e){},i.lateRender=function(e){},i.render=function(t,n,i){S._context.ctx._shader2D.glTexture=null,this._childs.length>0&&t.addRenderObject(this),this._renderType&=-2049,e.prototype.render.call(this,t,n,i)},i.renderSubmit=function(){return 1},i.getRenderType=function(){return 0},i.releaseRender=function(){},a(0,i,"scene",function(){return this}),t._sortScenes=function(e,i){if(e.parent===n.stage&&i.parent===n.stage){var r=n.stage._childs;return r.indexOf(e)-r.indexOf(i)}return e.parent!==n.stage&&i.parent!==n.stage?t._sortScenes(e.parent,i.parent):e.parent===n.stage?-1:1},t.FOGCOLOR="FOGCOLOR",t.FOGSTART="FOGSTART",t.FOGRANGE="FOGRANGE",t.CAMERAPOS="CAMERAPOS",t.LIGHTDIRECTION="LIGHTDIRECTION",t.LIGHTDIRDIFFUSE="LIGHTDIRDIFFUSE",t.LIGHTDIRAMBIENT="LIGHTDIRAMBIENT",t.LIGHTDIRSPECULAR="LIGHTDIRSPECULAR",t.POINTLIGHTPOS="POINTLIGHTPOS",t.POINTLIGHTRANGE="POINTLIGHTRANGE",t.POINTLIGHTATTENUATION="POINTLIGHTATTENUATION",t.POINTLIGHTDIFFUSE="POINTLIGHTDIFFUSE",t.POINTLIGHTAMBIENT="POINTLIGHTAMBIENT",t.POINTLIGHTSPECULAR="POINTLIGHTSPECULAR",t.SPOTLIGHTPOS="SPOTLIGHTPOS",t.SPOTLIGHTDIRECTION="SPOTLIGHTDIRECTION",t.SPOTLIGHTSPOT="SPOTLIGHTSPOT",t.SPOTLIGHTRANGE="SPOTLIGHTRANGE",t.SPOTLIGHTATTENUATION="SPOTLIGHTATTENUATION",t.SPOTLIGHTDIFFUSE="SPOTLIGHTDIFFUSE",t.SPOTLIGHTAMBIENT="SPOTLIGHTAMBIENT",t.SPOTLIGHTSPECULAR="SPOTLIGHTSPECULAR",t}(D),Vt=function(e){function t(e,i){this._projectionMatrixModifyID=0,t.__super.call(this),void 0===e&&(e=.1),void 0===i&&(i=1e3),this._tempVector3=new Qe,this._position=new Qe,this._up=new Qe,this._forward=new Qe,this._right=new Qe,this._fieldOfView=60,this._useUserProjectionMatrix=!1,this._orthographic=!1,this._viewportExpressedInClipSpace=!0,this._renderTargetSize=it.fullScreen,this._orthographicVerticalSize=10,this.renderingOrder=0,this._nearPlane=e,this._farPlane=i,this.cullingMask=2147483647,this.clearColor=new $e(.26,.26,.26,1),this.clearFlag=0,this._calculateProjectionMatrix(),n.stage.on("resize",this,this._onScreenSizeChanged)}r(t,"laya.d3.core.BaseCamera",e);var i=t.prototype;return i._sortCamerasByRenderingOrder=function(){if(this._displayedInStage)for(var e=this.scene._cameraPool,t=e.length-1,n=0;t>n;n++)if(e[n].renderingOrder>e[t].renderingOrder){var i=e[n];e[n]=e[t],e[t]=i}},i._calculateProjectionMatrix=function(){},i._onScreenSizeChanged=function(){this._calculateProjectionMatrix()},i.addLayer=function(e){29!==e.number&&30!=e.number&&(this.cullingMask=this.cullingMask|e.mask)},i.removeLayer=function(e){29!==e.number&&30!=e.number&&(this.cullingMask=this.cullingMask&~e.mask)},i.addAllLayers=function(){this.cullingMask=2147483647},i.removeAllLayers=function(){this.cullingMask=0|U.getLayerByNumber(29).mask|U.getLayerByNumber(30).mask},i.ResetProjectionMatrix=function(){this._useUserProjectionMatrix=!1,this._calculateProjectionMatrix()},i.destroy=function(t){void 0===t&&(t=!0),this.sky=null,this.renderTarget=null,n.stage.off("resize",this,this._onScreenSizeChanged),e.prototype.destroy.call(this,t)},i.moveForward=function(e){this._tempVector3.elements[0]=this._tempVector3.elements[1]=0,this._tempVector3.elements[2]=e,this.transform.translate(this._tempVector3)},i.moveRight=function(e){this._tempVector3.elements[1]=this._tempVector3.elements[2]=0,this._tempVector3.elements[0]=e,this.transform.translate(this._tempVector3)},i.moveVertical=function(e){this._tempVector3.elements[0]=this._tempVector3.elements[2]=0,this._tempVector3.elements[1]=e,this.transform.translate(this._tempVector3,!1)},i._addSelfRenderObjects=function(){var e=this.scene._cameraPool,t=e.length;if(t>0){for(var n=t-1;n>=0;n--)if(this.renderingOrder<=e[n].renderingOrder){e.splice(n+1,0,this);break}}else e.push(this)},i._clearSelfRenderObjects=function(){var e=this.scene._cameraPool;e.splice(e.indexOf(this),1)},a(0,i,"forward",function(){var e=this.transform.worldMatrix.elements,t=this._forward.elements;return t[0]=-e[8],t[1]=-e[9],t[2]=-e[10],this._forward}),a(0,i,"position",function(){var e=this.transform.worldMatrix.elements,t=this._position.elements;return t[0]=e[12],t[1]=e[13],t[2]=e[14],this._position}),a(0,i,"farPlane",function(){return this._farPlane},function(e){this._farPlane=e,this._calculateProjectionMatrix()}),a(0,i,"renderTarget",function(){return this._renderTarget},function(e){this._renderTarget=e,null!=e&&(this._renderTargetSize=e.size)}),a(0,i,"up",function(){var e=this.transform.worldMatrix.elements,t=this._up.elements;return t[0]=e[4],t[1]=e[5],t[2]=e[6],this._up}),a(0,i,"right",function(){var e=this.transform.worldMatrix.elements,t=this._right.elements;return t[0]=e[0],t[1]=e[1],t[2]=e[2],this._right}),a(0,i,"renderTargetSize",function(){return this._renderTargetSize},function(e){null!=this.renderTarget&&this._renderTargetSize!=e,this._renderTargetSize=e,this._calculateProjectionMatrix()}),a(0,i,"fieldOfView",function(){return this._fieldOfView},function(e){this._fieldOfView=e,this._calculateProjectionMatrix()}),a(0,i,"nearPlane",function(){return this._nearPlane},function(e){this._nearPlane=e,this._calculateProjectionMatrix()}),a(0,i,"orthographicProjection",function(){return this._orthographic},function(e){this._orthographic=e,this._calculateProjectionMatrix()}),a(0,i,"orthographicVerticalSize",function(){return this._orthographicVerticalSize},function(e){this._orthographicVerticalSize=e,this._calculateProjectionMatrix()}),a(0,i,"renderingOrder",function(){return this._renderingOrder},function(e){this._renderingOrder=e,this._sortCamerasByRenderingOrder()}),t.RENDERINGTYPE_DEFERREDLIGHTING="DEFERREDLIGHTING",t.RENDERINGTYPE_FORWARDRENDERING="FORWARDRENDERING",t.CLEARFLAG_SOLIDCOLOR=0,t.CLEARFLAG_SKY=1,t.CLEARFLAG_DEPTHONLY=2,t.CLEARFLAG_NONE=3,t}(vt),Dt=(function(e){function t(){this._templet=null,this._glitterRender=null,t.__super.call(this),this._glitterRender=new yt(this),this._glitterRender.on("materialchanged",this,this._onMaterialChanged);var e=new bt;this._glitterRender.sharedMaterial=e,this._templet=new ut(this),e.renderMode=8,this._changeRenderObject(0)}r(t,"laya.d3.core.glitter.Glitter",e);var n=t.prototype;return n._changeRenderObject=function(e){var t=this._glitterRender.renderObject._renderElements,n=t[e];n||(n=t[e]=new se),n._renderObject=this._glitterRender.renderObject;var i=this._glitterRender.sharedMaterials[e];i||(i=bt.defaultMaterial);var r=this._templet;return n._mainSortID=0,n._sprite3D=this,n.renderObj=r,n._material=i,n},n._onMaterialChanged=function(e,t,n){var i=e.renderObject._renderElements.length;i>t&&this._changeRenderObject(t)},n._clearSelfRenderObjects=function(){this.scene.removeFrustumCullingObject(this._glitterRender.renderObject)},n._addSelfRenderObjects=function(){this.scene.addFrustumCullingObject(this._glitterRender.renderObject)},n._update=function(e){this._templet._update(e.elapsedTime),e.owner=this,L.spriteCount++,this._childs.length&&this._updateChilds(e)},n.addGlitterByPositions=function(e,t){this._templet.addVertexPosition(e,t)},n.addGlitterByPositionsVelocitys=function(e,t,n,i){this._templet.addVertexPositionVelocity(e,t,n,i)},n.cloneTo=function(t){e.prototype.cloneTo.call(this,t);var n=t,i=n.templet;i.lifeTime=this._templet.lifeTime,i.minSegmentDistance=this._templet.minSegmentDistance,i.minInterpDistance=this._templet.minInterpDistance,i.maxSlerpCount=this._templet.maxSlerpCount,this._templet.color.cloneTo(i.color),i._maxSegments=this._templet._maxSegments;var r=n._glitterRender;r.sharedMaterials=this._glitterRender.sharedMaterials,r.enable=this._glitterRender.enable},n.destroy=function(t){void 0===t&&(t=!0),e.prototype.destroy.call(this,t),this._glitterRender._destroy(),this._templet=null},a(0,n,"templet",function(){return this._templet}),a(0,n,"glitterRender",function(){return this._glitterRender}),t}(vt),function(e){function t(){this._diffuseColor=null,this._ambientColor=null,this._specularColor=null,this._reflectColor=null,t.__super.call(this),this.on("added",this,this._onAdded),this.on("removed",this,this._onRemoved),this._diffuseColor=new Qe(.8,.8,.8),this._ambientColor=new Qe(.6,.6,.6),this._specularColor=new Qe(1,1,1),this._reflectColor=new Qe(1,1,1)}r(t,"laya.d3.core.light.LightSprite",e);var n=t.prototype;return n._onRemoved=function(){this.scene._removeLight(this)},n._onAdded=function(){this.scene._addLight(this)},n.updateToWorldState=function(e){},a(0,n,"diffuseColor",function(){return this._diffuseColor},function(e){this._diffuseColor=e}),a(0,n,"ambientColor",function(){return this._ambientColor},function(e){this._ambientColor=e}),a(0,n,"lightType",function(){return-1}),a(0,n,"specularColor",function(){return this._specularColor},function(e){this._specularColor=e}),a(0,n,"reflectColor",function(){return this._reflectColor},function(e){this._reflectColor=e}),t.TYPE_DIRECTIONLIGHT=1,t.TYPE_POINTLIGHT=2,t.TYPE_SPOTLIGHT=3,t}(vt)),Lt=function(e){function t(e,n){this._meshFilter=null,this._meshRender=null,t.__super.call(this,n),this._meshFilter=new ot(this),this._meshRender=new St(this),this._meshFilter.on("meshchanged",this,this._onMeshChanged),this._meshRender.on("materialchanged",this,this._onMaterialChanged),e&&(this._meshFilter.sharedMesh=e,e instanceof laya.d3.resource.models.Mesh&&(e.loaded?this._meshRender.sharedMaterials=e.materials:e.once("loaded",this,this._applyMeshMaterials)))}r(t,"laya.d3.core.MeshSprite3D",e);var n=t.prototype;return n._changeRenderObjectByMesh=function(e){var t=this._meshRender.renderObject._renderElements,n=t[e];n||(n=t[e]=new se),n._renderObject=this._meshRender.renderObject;var i=this._meshRender.sharedMaterials[e];i||(i=wt.defaultMaterial);var r=this._meshFilter.sharedMesh.getRenderElement(e);return n._mainSortID=this._getSortID(r,i),n._sprite3D=this,n.renderObj=r,n._material=i,n},n._changeRenderObjectByMaterial=function(e,t){var n=this._meshRender.renderObject._renderElements[e],i=this._meshFilter.sharedMesh.getRenderElement(e);return n._mainSortID=this._getSortID(i,t),n._sprite3D=this,n.renderObj=i,n._material=t,n},n._changeRenderObjectsByMesh=function(){var e=this._meshFilter.sharedMesh.getRenderElementsCount();this._meshRender.renderObject._renderElements.length=e;for(var t=0;e>t;t++)this._changeRenderObjectByMesh(t)},n._onMeshChanged=function(e){var t=e.sharedMesh;t.loaded?this._changeRenderObjectsByMesh():t.once("loaded",this,this._onMeshLoaded)},n._onMeshLoaded=function(e){e===this.meshFilter.sharedMesh&&this._changeRenderObjectsByMesh()},n._onMaterialChanged=function(e,t,n){var i=this._meshRender.renderObject._renderElements.length;i>t&&this._changeRenderObjectByMaterial(t,n)},n._clearSelfRenderObjects=function(){this.scene.removeFrustumCullingObject(this._meshRender.renderObject)},n._addSelfRenderObjects=function(){this.scene.addFrustumCullingObject(this._meshRender.renderObject)},n._applyMeshMaterials=function(e){for(var t=this._meshRender.sharedMaterials,n=e.materials,i=0,r=n.length;r>i;i++)t[i]||(t[i]=n[i]);this._meshRender.sharedMaterials=t},n._update=function(e){e.owner=this,this._enable&&(this._updateComponents(e),this._lateUpdateComponents(e)),L.spriteCount++,this._childs.length&&this._updateChilds(e)},n.cloneTo=function(t){e.prototype.cloneTo.call(this,t);var n=t;n._meshFilter.sharedMesh=this._meshFilter.sharedMesh;var i=n._meshRender;i.enable=this._meshRender.enable,i.sharedMaterials=this._meshRender.sharedMaterials,i.castShadow=this._meshRender.castShadow,i.receiveShadow=this._meshRender.receiveShadow},n.destroy=function(t){void 0===t&&(t=!0),e.prototype.destroy.call(this,t),this._meshFilter._destroy(),this._meshRender._destroy()},a(0,n,"meshFilter",function(){return this._meshFilter}),a(0,n,"meshRender",function(){return this._meshRender}),t}(vt),Ot=(function(e){function t(e){this._setting=null,this._templet=null,this._particleRender=null,t.__super.call(this),this._setting=e,this._particleRender=new Rt(this),this._particleRender.on("materialchanged",this,this._onMaterialChanged);var n=new Pt;e.textureName&&(n.diffuseTexture=kt.load(e.textureName)),this._particleRender.sharedMaterial=n,this._templet=new It(this,e),0===e.blendState?n.renderMode=5:1===e.blendState&&(n.renderMode=7),this._changeRenderObject(0)}r(t,"laya.d3.core.particle.Particle3D",e);var n=t.prototype;return n._changeRenderObject=function(e){var t=this._particleRender.renderObject._renderElements,n=t[e];n||(n=t[e]=new se),n._renderObject=this._particleRender.renderObject;var i=this._particleRender.sharedMaterials[e];i||(i=Pt.defaultMaterial);var r=this._templet;return n._mainSortID=0,n._sprite3D=this,n.renderObj=r,n._material=i,n},n._onMaterialChanged=function(e,t,n){var i=e.renderObject._renderElements.length;i>t&&this._changeRenderObject(t)},n._clearSelfRenderObjects=function(){this.scene.removeFrustumCullingObject(this._particleRender.renderObject)},n._addSelfRenderObjects=function(){this.scene.addFrustumCullingObject(this._particleRender.renderObject)},n._update=function(e){this._templet.update(e.elapsedTime),e.owner=this,L.spriteCount++,this._childs.length&&this._updateChilds(e)},n.addParticle=function(e,t){Qe.add(this.transform.localPosition,e,e),this._templet.addParticle(e,t)},n.cloneTo=function(t){e.prototype.cloneTo.call(this,t);var n=t;n._templet=this._templet;var i=n._particleRender;i.sharedMaterials=this._particleRender.sharedMaterials,i.enable=this._particleRender.enable},n.destroy=function(t){void 0===t&&(t=!0),e.prototype.destroy.call(this,t),this._particleRender._destroy(),this._templet=null},a(0,n,"templet",function(){return this._templet}),a(0,n,"particleRender",function(){return this._particleRender}),t}(vt),function(e){function t(e){this._particleSystem=null,this._particleRender=null,t.__super.call(this),this._particleRender=new At(this),this._particleRender.on("materialchanged",this,this._onMaterialChanged),this._particleSystem=new re(this),this._changeRenderObject(0),e&&(this._particleRender.sharedMaterial=e)}r(t,"laya.d3.core.particleShuriKen.ShuriKenParticle3D",e);var n=t.prototype;return n._changeRenderObject=function(e){var t=this._particleRender.renderObject._renderElements,n=t[e];n||(n=t[e]=new se),n._renderObject=this._particleRender.renderObject;var i=this._particleRender.sharedMaterials[e];i||(i=Ft.defaultMaterial);var r=this._particleSystem;return n._mainSortID=0,n._sprite3D=this,n.renderObj=r,n._material=i,n},n._onMaterialChanged=function(e,t,n){var i=e.renderObject._renderElements.length;i>t&&this._changeRenderObject(t)},n._clearSelfRenderObjects=function(){this.scene.removeFrustumCullingObject(this._particleRender.renderObject)},n._addSelfRenderObjects=function(){this.scene.addFrustumCullingObject(this._particleRender.renderObject)},n._update=function(e){e.owner=this,this._particleSystem.update(e),L.spriteCount++,this._childs.length&&this._updateChilds(e)},n.cloneTo=function(t){e.prototype.cloneTo.call(this,t);var n=t,i=n._particleSystem;i.duration=this._particleSystem.duration,i.looping=this._particleSystem.looping,i.prewarm=this._particleSystem.prewarm,i.startDelayType=this._particleSystem.startDelayType,i.startDelay=this._particleSystem.startDelay,i.startDelayMin=this._particleSystem.startDelayMin,i.startDelayMax=this._particleSystem.startDelayMax,i.startLifetimeType=this._particleSystem.startLifetimeType,i.startLifetimeConstant=this._particleSystem.startLifetimeConstant,this._particleSystem.startLifeTimeGradient.cloneTo(i.startLifeTimeGradient),i.startLifetimeConstantMin=this._particleSystem.startLifetimeConstantMin,i.startLifetimeConstantMax=this._particleSystem.startLifetimeConstantMax,this._particleSystem.startLifeTimeGradientMin.cloneTo(i.startLifeTimeGradientMin),this._particleSystem.startLifeTimeGradientMax.cloneTo(i.startLifeTimeGradientMax),i.startSpeedType=this._particleSystem.startSpeedType,i.startSpeedConstant=this._particleSystem.startSpeedConstant,i.startSpeedConstantMin=this._particleSystem.startSpeedConstantMin,i.startSpeedConstantMax=this._particleSystem.startSpeedConstantMax,i.threeDStartSize=this._particleSystem.threeDStartSize,i.startSizeType=this._particleSystem.startSizeType,i.startSizeConstant=this._particleSystem.startSizeConstant,this._particleSystem.startSizeConstantSeparate.cloneTo(i.startSizeConstantSeparate),i.startSizeConstantMin=this._particleSystem.startSizeConstantMin,i.startSizeConstantMax=this._particleSystem.startSizeConstantMax,this._particleSystem.startSizeConstantMinSeparate.cloneTo(i.startSizeConstantMinSeparate),this._particleSystem.startSizeConstantMaxSeparate.cloneTo(i.startSizeConstantMaxSeparate),i.threeDStartRotation=this._particleSystem.threeDStartRotation,i.startRotationType=this._particleSystem.startRotationType,i.startRotationConstant=this._particleSystem.startRotationConstant,this._particleSystem.startRotationConstantSeparate.cloneTo(i.startRotationConstantSeparate),i.startRotationConstantMin=this._particleSystem.startRotationConstantMin,i.startRotationConstantMax=this._particleSystem.startRotationConstantMax,this._particleSystem.startRotationConstantMinSeparate.cloneTo(i.startRotationConstantMinSeparate),this._particleSystem.startRotationConstantMaxSeparate.cloneTo(i.startRotationConstantMaxSeparate),i.randomizeRotationDirection=this._particleSystem.randomizeRotationDirection,i.startColorType=this._particleSystem.startColorType,this._particleSystem.startColorConstant.cloneTo(i.startColorConstant),this._particleSystem.startColorConstantMin.cloneTo(i.startColorConstantMin),this._particleSystem.startColorConstantMax.cloneTo(i.startColorConstantMax),this._particleSystem.gravity.cloneTo(i.gravity),i.gravityModifier=this._particleSystem.gravityModifier,i.simulationSpace=this._particleSystem.simulationSpace,i.scaleMode=this._particleSystem.scaleMode,i.playOnAwake=this._particleSystem.playOnAwake,this._particleSystem.velocityOverLifetime.cloneTo(i.velocityOverLifetime),this._particleSystem.colorOverLifetime.cloneTo(i.colorOverLifetime),this._particleSystem.sizeOverLifetime.cloneTo(i.sizeOverLifetime),this._particleSystem.rotationOverLifetime.cloneTo(i.rotationOverLifetime),this._particleSystem.textureSheetAnimation.cloneTo(i.textureSheetAnimation),i.isPerformanceMode=this._particleSystem.isPerformanceMode;var r=n._particleRender;r.sharedMaterials=this._particleRender.sharedMaterials,r.enable=this._particleRender.enable,r.renderMode=this._particleRender.renderMode,r.stretchedBillboardCameraSpeedScale=this._particleRender.stretchedBillboardCameraSpeedScale,r.stretchedBillboardSpeedScale=this._particleRender.stretchedBillboardSpeedScale,r.stretchedBillboardLengthScale=this._particleRender.stretchedBillboardLengthScale},n.destroy=function(t){void 0===t&&(t=!0),e.prototype.destroy.call(this,t),this._particleRender._destroy(),this._particleSystem._destroy(),this._particleRender=null,this._particleSystem=null},a(0,n,"particleSystem",function(){return this._particleSystem}),a(0,n,"particleRender",function(){return this._particleRender}),t}(vt)),bt=function(e){function t(){t.__super.call(this),this.setShaderName("GLITTER")}r(t,"laya.d3.core.material.GlitterMaterial",e);var s=t.prototype;return s._setLoopShaderParams=function(e,t,n,i,r){var a=e.owner,s=a.templet;e.shaderValue.pushValue("UNICOLOR",s.color.elements),e.shaderValue.pushValue("MVPMATRIX",e.projectionViewMatrix.elements),e.shaderValue.pushValue("DURATION",s.lifeTime),e.shaderValue.pushValue("ALBEDO",s._albedo.elements),e.shaderValue.pushValue("CURRENTTIME",s._currentTime)},a(0,s,"diffuseTexture",function(){return this._getTexture(0)},function(e){e?this._addShaderDefine(1):this._removeShaderDefine(1),this._setTexture(e,0,"DIFFUSETEXTURE")}),t.load=function(e){return n.loader.create(e,null,null,t)},t.TIME="TIME",t.DIFFUSETEXTURE="DIFFUSETEXTURE",t.MVPMATRIX="MVPMATRIX",t.ALBEDO="ALBEDO",t.CURRENTTIME="CURRENTTIME",t.UNICOLOR="UNICOLOR",t.DURATION="DURATION",t._diffuseTextureIndex=0,i(t,["defaultMaterial",function(){return this.defaultMaterial=new t}]),t}(gt),Pt=function(e){function t(){t.__super.call(this),this._addShaderDefine(262144),this.setShaderName("PARTICLE")}r(t,"laya.d3.core.material.ParticleMaterial",e);var s=t.prototype;return s._setLoopShaderParams=function(e,t,n,i,r){var a=e.owner,s=a.templet,o=s.settings;e.shaderValue.pushValue("DURATION",o.duration),e.shaderValue.pushValue("GRAVITY",o.gravity),e.shaderValue.pushValue("ENDVELOCITY",o.endVelocity),e.shaderValue.pushValue("MVPMATRIX",n.elements),e.shaderValue.pushValue("MATRIX1",e.viewMatrix.elements),e.shaderValue.pushValue("MATRIX2",e.projectionMatrix.elements);var l=e.viewport.width/e.viewport.height,h=new Ke(.5/l,-.5);e.shaderValue.pushValue("VIEWPORTSCALE",h.elements),e.shaderValue.pushValue("CURRENTTIME",s._currentTime)},a(0,s,"diffuseTexture",function(){return this._getTexture(0)},function(e){e?this._addShaderDefine(1):this._removeShaderDefine(1),this._setTexture(e,0,"DIFFUSETEXTURE")}),t.load=function(e){return n.loader.create(e,null,null,t)},t.WORLDMATRIX="MVPMATRIX",t.VIEWMATRIX="MATRIX1",t.PROJECTIONMATRIX="MATRIX2",t.VIEWPORTSCALE="VIEWPORTSCALE",t.CURRENTTIME="CURRENTTIME",t.DURATION="DURATION",t.GRAVITY="GRAVITY",t.ENDVELOCITY="ENDVELOCITY",t.DIFFUSETEXTURE="DIFFUSETEXTURE",t._diffuseTextureIndex=0,i(t,["defaultMaterial",function(){return this.defaultMaterial=new t}]),t}(gt),wt=function(e){function t(){this._transformUV=null,t.__super.call(this),this._setColor(0,"MATERIALAMBIENT",new Qe(.6,.6,.6)),this._setColor(1,"MATERIALDIFFUSE",new Qe(1,1,1)),this._setColor(2,"MATERIALSPECULAR",new $e(1,1,1,8)),this._setColor(3,"MATERIALREFLECT",new Qe(1,1,1)),this._setColor(4,"ALBEDO",new $e(1,1,1,1)),this._setNumber(0,"ALPHATESTVALUE",.5),this.setShaderName("SIMPLE")}r(t,"laya.d3.core.material.StandardMaterial",e);var s=t.prototype;return s.disableLight=function(){this._addDisableShaderDefine(28672)},s.disableFog=function(){this._addDisableShaderDefine(512)},s._setLoopShaderParams=function(e,n,i,r,a){this._transformUV&&this._transformUV.matrix;var s;i===je.DEFAULT?s=n:(s=t._tempMatrix4x40,je.multiply(n,i,s)),e.shaderValue.pushValue("MATRIX1",i.elements),e.shaderValue.pushValue("MVPMATRIX",s.elements)},a(0,s,"ambientColor",function(){return this._getColor(0)},function(e){this._setColor(0,"MATERIALAMBIENT",e)}),a(0,s,"albedo",function(){return this._getColor(4)},function(e){this._setColor(4,"ALBEDO",e)}),a(0,s,"diffuseColor",function(){return this._getColor(1)},function(e){this._setColor(1,"MATERIALDIFFUSE",e)}),a(0,s,"specularColor",function(){return this._getColor(2)},function(e){this._setColor(2,"MATERIALSPECULAR",e)}),a(0,s,"normalTexture",function(){return this._getTexture(1)},function(e){
|
||
e?this._addShaderDefine(2):this._removeShaderDefine(2),this._setTexture(e,1,"NORMALTEXTURE")}),a(0,s,"reflectColor",function(){return this._getColor(3)},function(e){this._setColor(3,"MATERIALREFLECT",e)}),a(0,s,"diffuseTexture",function(){return this._getTexture(0)},function(e){e?this._addShaderDefine(1):this._removeShaderDefine(1),this._setTexture(e,0,"DIFFUSETEXTURE")}),a(0,s,"alphaTestValue",function(){return this._getNumber(0)},function(e){this._setNumber(0,"ALPHATESTVALUE",e)}),a(0,s,"specularTexture",function(){return this._getTexture(2)},function(e){e?this._addShaderDefine(4):this._removeShaderDefine(4),this._setTexture(e,2,"SPECULARTEXTURE")}),a(0,s,"emissiveTexture",function(){return this._getTexture(3)},function(e){e?this._addShaderDefine(8):this._removeShaderDefine(8),this._setTexture(e,3,"EMISSIVETEXTURE")}),a(0,s,"ambientTexture",function(){return this._getTexture(4)},function(e){e?this._addShaderDefine(16):this._removeShaderDefine(16),this._setTexture(e,4,"AMBIENTTEXTURE")}),a(0,s,"reflectTexture",function(){return this._getTexture(5)},function(e){e?this._addShaderDefine(32):this._removeShaderDefine(32),this._setTexture(e,5,"REFLECTTEXTURE")}),a(0,s,"transformUV",function(){return this._transformUV},function(e){this._transformUV=e,this._setMatrix4x4(0,"MATRIX2",e.matrix),e?this._addShaderDefine(256):this._removeShaderDefine(256)}),t.load=function(e){return n.loader.create(e,null,null,t)},t.WORLDMATRIX="MATRIX1",t.MVPMATRIX="MVPMATRIX",t.DIFFUSETEXTURE="DIFFUSETEXTURE",t.NORMALTEXTURE="NORMALTEXTURE",t.SPECULARTEXTURE="SPECULARTEXTURE",t.EMISSIVETEXTURE="EMISSIVETEXTURE",t.AMBIENTTEXTURE="AMBIENTTEXTURE",t.REFLECTTEXTURE="REFLECTTEXTURE",t.Bones="MATRIXARRAY0",t.ALBEDO="ALBEDO",t.ALPHATESTVALUE="ALPHATESTVALUE",t.UVANIAGE="UVAGEX",t.MATERIALAMBIENT="MATERIALAMBIENT",t.MATERIALDIFFUSE="MATERIALDIFFUSE",t.MATERIALSPECULAR="MATERIALSPECULAR",t.MATERIALREFLECT="MATERIALREFLECT",t.UVMATRIX="MATRIX2",t.UVAGE="FLOAT0",t._ambientColorIndex=0,t._diffuseColorIndex=1,t._speclarColorIndex=2,t._reflectColorIndex=3,t._albedoColorIndex=4,t._alphaTestValueIndex=0,t._diffuseTextureIndex=0,t._normalTextureIndex=1,t._specularTextureIndex=2,t._emissiveTextureIndex=3,t._ambientTextureIndex=4,t._reflectTextureIndex=5,t.TRANSFORMUV=0,i(t,["_tempMatrix4x40",function(){return this._tempMatrix4x40=new je},"defaultMaterial",function(){return this.defaultMaterial=new t}]),t}(gt),Nt=function(e){function t(e,n,i,r){this._indexType=null,this._indexTypeByteCount=0,this._indexCount=0,this._canRead=!1,void 0===i&&(i=35044),void 0===r&&(r=!1),t.__super.call(this),this._indexType=e,this._indexCount=n,this._bufferUsage=i,this._bufferType=34963,this._canRead=r,this._bind();var a=0;if("ushort"==e)this._indexTypeByteCount=2;else{if("ubyte"!=e)throw new Error("unidentification index type.");this._indexTypeByteCount=1}a=this._indexTypeByteCount*n,this._byteLength=a,u._gl.bufferData(this._bufferType,a,this._bufferUsage),r?("ushort"==e?this._buffer=new Uint16Array(n):"ubyte"==e&&(this._buffer=new Uint8Array(n)),this.memorySize=2*a):this.memorySize=a}r(t,"laya.d3.graphics.IndexBuffer3D",e);var n=t.prototype;return n.setData=function(e,t,n,i){void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=4294967295);var r=0;if("ushort"==this._indexType?(r=2,0===n&&4294967295===i||(e=new Uint16Array(e.buffer,n*r,i))):"ubyte"==this._indexType&&(r=1,0===n&&4294967295===i||(e=new Uint8Array(e.buffer,n*r,i))),this._bind(),u._gl.bufferSubData(this._bufferType,t*r,e),this._canRead)if(0!==t||0!==n||4294967295!==i){var a=this._buffer.length-t;i>a&&(i=a);for(var s=0;i>s;s++)this._buffer[t+s]=e[s]}else this._buffer=e},n.getData=function(){if(this._canRead)return this._buffer;throw new Error("Can't read data from VertexBuffer with only write flag!")},n.dispose=function(){this._buffer=null,e.prototype.dispose.call(this),this.memorySize=0},a(0,n,"indexType",function(){return this._indexType}),a(0,n,"indexTypeByteCount",function(){return this._indexTypeByteCount}),a(0,n,"indexCount",function(){return this._indexCount}),a(0,n,"canRead",function(){return this._canRead}),t.INDEXTYPE_UBYTE="ubyte",t.INDEXTYPE_USHORT="ushort",t.create=function(e,n,i,r){return void 0===i&&(i=35044),void 0===r&&(r=!1),new t(e,n,i,r)},t}(u),Bt=function(e){function t(e,n,i,r){this._vertexDeclaration=null,this._vertexCount=0,this._canRead=!1,void 0===r&&(r=!1),t.__super.call(this),this._vertexDeclaration=e,this._vertexCount=n,this._bufferUsage=i,this._bufferType=34962,this._canRead=r,this._bind();var a=this._vertexDeclaration.vertexStride*n;this.memorySize=a,this._byteLength=a,u._gl.bufferData(this._bufferType,a,this._bufferUsage),r&&(this._buffer=new Float32Array(a/4))}r(t,"laya.d3.graphics.VertexBuffer3D",e);var n=t.prototype;return n.bindWithIndexBuffer=function(e){e&&e._bind(),this._bind()},n.setData=function(e,t,n,i){if(void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=4294967295),0===n&&4294967295===i||(e=new Float32Array(e.buffer,4*n,i)),this._bind(),u._gl.bufferSubData(this._bufferType,4*t,e),this._canRead)if(0!==t||0!==n||4294967295!==i){var r=this._buffer.length-t;i>r&&(i=r);for(var a=0;i>a;a++)this._buffer[t+a]=e[a]}else this._buffer=e},n.getData=function(){if(this._canRead)return this._buffer;throw new Error("Can't read data from VertexBuffer with only write flag!")},n.detoryResource=function(){for(var t=this._vertexDeclaration.getVertexElements(),n=0;n<t.length;n++)w.mainContext.disableVertexAttribArray(n);e.prototype.detoryResource.call(this)},n.dispose=function(){e.prototype.dispose.call(this),this._buffer=null,this._vertexDeclaration=null,this.memorySize=0},a(0,n,"vertexDeclaration",function(){return this._vertexDeclaration}),a(0,n,"vertexCount",function(){return this._vertexCount}),a(0,n,"canRead",function(){return this._canRead}),t.create=function(e,n,i,r){return void 0===i&&(i=35044),void 0===r&&(r=!1),new t(e,n,i,r)},t}(u),Ft=function(e){function t(){this._tempRotationMatrix=new je,this._uvLength=new Ke,t.__super.call(this),this.setShaderName("PARTICLESHURIKEN")}r(t,"laya.d3.core.particleShuriKen.ShurikenParticleMaterial",e);var s=t.prototype;return s._setLoopShaderParams=function(e,n,i,r,a){var s=e.owner,o=s.particleSystem,l=s.particleRender,h=s.transform,u=t._tempGravity.elements,c=o.gravity.elements,_=o.gravityModifier;u[0]=c[0]*_,u[1]=c[1]*_,u[2]=c[2]*_;var d=e.shaderValue;switch(d.pushValue("GRAVITY",u),d.pushValue("SIMULATIONSPACE",o.simulationSpace),o.simulationSpace){case 0:d.pushValue("WORLDPOSITION",Qe.ZERO.elements);break;case 1:d.pushValue("WORLDPOSITION",h.position.elements);break;default:throw new Error("ShurikenParticleMaterial: SimulationSpace value is invalid.")}switch(je.createFromQuaternion(h.rotation,this._tempRotationMatrix),d.pushValue("WORLDROTATIONMATRIX",this._tempRotationMatrix.elements),d.pushValue("THREEDSTARTROTATION",o.threeDStartRotation),d.pushValue("SCALINGMODE",o.scaleMode),o.scaleMode){case 0:d.pushValue("POSITIONSCALE",h.scale.elements),d.pushValue("SIZESCALE",h.scale.elements);break;case 1:d.pushValue("POSITIONSCALE",h.localScale.elements),d.pushValue("SIZESCALE",h.localScale.elements);break;case 2:d.pushValue("POSITIONSCALE",h.scale.elements),d.pushValue("SIZESCALE",Qe.ONE.elements)}switch(d.pushValue("CAMERADIRECTION",e.camera.forward.elements),d.pushValue("CAMERAUP",e.camera.up.elements),d.pushValue("MATRIX1",e.viewMatrix.elements),d.pushValue("MATRIX2",e.projectionMatrix.elements),d.pushValue("STRETCHEDBILLBOARDLENGTHSCALE",l.stretchedBillboardLengthScale),d.pushValue("STRETCHEDBILLBOARDSPEEDSCALE",l.stretchedBillboardSpeedScale),d.pushValue("CURRENTTIME",o.currentTime),l.renderMode){case 0:e.shaderDefines.add(524288);break;case 1:e.shaderDefines.add(1048576);break;case 2:e.shaderDefines.add(2097152);break;case 3:e.shaderDefines.add(4194304)}var m=o.velocityOverLifetime;if(m&&m.enbale){e.shaderDefines.add(268435456);var f=m.velocity,p=f.type;switch(d.pushValue("VOLTYPE",p),p){case 0:d.pushValue("VOLVELOCITYCONST",f.constant.elements);break;case 1:d.pushValue("VOLVELOCITYGRADIENTX",f.gradientX._elements),d.pushValue("VOLVELOCITYGRADIENTY",f.gradientY._elements),d.pushValue("VOLVELOCITYGRADIENTZ",f.gradientZ._elements);break;case 2:d.pushValue("VOLVELOCITYCONST",f.constantMin.elements),d.pushValue("VOLVELOCITYCONSTMAX",f.constantMax.elements);break;case 3:d.pushValue("VOLVELOCITYGRADIENTX",f.gradientXMin._elements),d.pushValue("VOLVELOCITYGRADIENTXMAX",f.gradientXMax._elements),d.pushValue("VOLVELOCITYGRADIENTY",f.gradientYMin._elements),d.pushValue("VOLVELOCITYGRADIENTYMAX",f.gradientYMax._elements),d.pushValue("VOLVELOCITYGRADIENTZ",f.gradientZMin._elements),d.pushValue("VOLVELOCITYGRADIENTZMAX",f.gradientZMax._elements)}var v=m.space;d.pushValue("VOLSPACETYPE",v)}var g=o.colorOverLifetime;if(g&&g.enbale){var T=g.color;switch(T.type){case 1:e.shaderDefines.add(8388608);var x=T.gradient;d.pushValue("COLOROVERLIFEGRADIENTALPHAS",x._alphaElements),d.pushValue("COLOROVERLIFEGRADIENTCOLORS",x._rgbElements);break;case 3:e.shaderDefines.add(16777216);var M=T.gradientMin,E=T.gradientMax;d.pushValue("COLOROVERLIFEGRADIENTALPHAS",M._alphaElements),d.pushValue("COLOROVERLIFEGRADIENTCOLORS",M._rgbElements),d.pushValue("MAXCOLOROVERLIFEGRADIENTALPHAS",E._alphaElements),d.pushValue("MAXCOLOROVERLIFEGRADIENTCOLORS",E._rgbElements)}}var y=o.sizeOverLifetime;if(y&&y.enbale){var S=y.size,R=S.type,A=!1;switch(R){case 0:A=S.separateAxes,e.shaderDefines.add(33554432),d.pushValue("SOLTYPE",R),d.pushValue("SOLSEPRARATE",A),A?(d.pushValue("SOLSIZEGRADIENTX",S.gradientSizeX._elements),d.pushValue("SOLSIZEGRADIENTY",S.gradientSizeY._elements),d.pushValue("SOLSizeGradientZ",S.gradientSizeZ._elements)):d.pushValue("SOLSIZEGRADIENT",S.gradientSize._elements);break;case 2:A=S.separateAxes,e.shaderDefines.add(33554432),d.pushValue("SOLTYPE",R),d.pushValue("SOLSEPRARATE",A),A?(d.pushValue("SOLSIZEGRADIENTX",S.gradientXMin._elements),d.pushValue("SOLSIZEGRADIENTXMAX",S.gradientXMax._elements),d.pushValue("SOLSIZEGRADIENTY",S.gradientYMin._elements),d.pushValue("SOLSIZEGRADIENTYMAX",S.gradientYMax._elements),d.pushValue("SOLSizeGradientZ",S.gradientZMin._elements),d.pushValue("SOLSizeGradientZMAX",S.gradientZMax._elements)):(d.pushValue("SOLSIZEGRADIENT",S.gradientMin._elements),d.pushValue("SOLSizeGradientMax",S.gradientMax._elements))}}var I=o.rotationOverLifetime;if(I&&I.enbale){e.shaderDefines.add(67108864);var C=I.angularVelocity,V=C.type,D=C.separateAxes;switch(d.pushValue("ROLTYPE",V),d.pushValue("ROLSEPRARATE",D),V){case 0:D?d.pushValue("ROLANGULARVELOCITYCONSTSEPRARATE",C.constantSeparate.elements):d.pushValue("ROLANGULARVELOCITYCONST",C.constant);break;case 1:D?(d.pushValue("ROLANGULARVELOCITYGRADIENTX",C.gradientX._elements),d.pushValue("ROLANGULARVELOCITYGRADIENTY",C.gradientY._elements),d.pushValue("ROLANGULARVELOCITYGRADIENTZ",C.gradientZ._elements)):d.pushValue("ROLANGULARVELOCITYGRADIENT",C.gradient._elements);break;case 2:D?(d.pushValue("ROLANGULARVELOCITYCONSTSEPRARATE",C.constantMinSeparate.elements),d.pushValue("ROLANGULARVELOCITYCONSTMAXSEPRARATE",C.constantMaxSeparate.elements)):(d.pushValue("ROLANGULARVELOCITYCONST",C.constantMin),d.pushValue("ROLANGULARVELOCITYCONSTMAX",C.constantMax));break;case 3:D?(d.pushValue("ROLANGULARVELOCITYGRADIENTX",C.gradientXMin._elements),d.pushValue("ROLANGULARVELOCITYGRADIENTXMAX",C.gradientXMax._elements),d.pushValue("ROLANGULARVELOCITYGRADIENTY",C.gradientYMin._elements),d.pushValue("ROLANGULARVELOCITYGRADIENTYMAX",C.gradientYMax._elements),d.pushValue("ROLANGULARVELOCITYGRADIENTZ",C.gradientZMin._elements),d.pushValue("ROLANGULARVELOCITYGRADIENTZMAX",C.gradientZMax._elements)):(d.pushValue("ROLANGULARVELOCITYGRADIENT",C.gradientMin._elements),d.pushValue("ROLANGULARVELOCITYGRADIENTMAX",C.gradientMax._elements))}}var L=o.textureSheetAnimation;if(L&&L.enbale){var O=L.frame,b=O.type;if(1===b||3===b){e.shaderDefines.add(134217728),d.pushValue("TEXTURESHEETANIMATIONTYPE",b),d.pushValue("TEXTURESHEETANIMATIONCYCLES",L.cycles);var P=L.tiles,w=this._uvLength.elements;w[0]=1/P.x,w[1]=1/P.y,d.pushValue("TEXTURESHEETANIMATIONSUBUVLENGTH",this._uvLength.elements)}switch(b){case 1:d.pushValue("TEXTURESHEETANIMATIONGRADIENTUVS",O.frameOverTimeData._elements);break;case 3:d.pushValue("TEXTURESHEETANIMATIONGRADIENTUVS",O.frameOverTimeDataMin._elements),d.pushValue("TEXTURESHEETANIMATIONGRADIENTMAXUVS",O.frameOverTimeDataMax._elements)}}},a(0,s,"diffuseTexture",function(){return this._getTexture(0)},function(e){e?this._addShaderDefine(1):this._removeShaderDefine(1),this._setTexture(e,0,"DIFFUSETEXTURE")}),t.load=function(e){return n.loader.create(e,null,null,t)},t.WORLDPOSITION="WORLDPOSITION",t.WORLDROTATIONMATRIX="WORLDROTATIONMATRIX",t.THREEDSTARTROTATION="THREEDSTARTROTATION",t.SCALINGMODE="SCALINGMODE",t.POSITIONSCALE="POSITIONSCALE",t.SIZESCALE="SIZESCALE",t.VIEWMATRIX="MATRIX1",t.PROJECTIONMATRIX="MATRIX2",t.CURRENTTIME="CURRENTTIME",t.GRAVITY="GRAVITY",t.DIFFUSETEXTURE="DIFFUSETEXTURE",t.CAMERADIRECTION="CAMERADIRECTION",t.CAMERAUP="CAMERAUP",t.STRETCHEDBILLBOARDLENGTHSCALE="STRETCHEDBILLBOARDLENGTHSCALE",t.STRETCHEDBILLBOARDSPEEDSCALE="STRETCHEDBILLBOARDSPEEDSCALE",t.SIMULATIONSPACE="SIMULATIONSPACE",t.VOLTYPE="VOLTYPE",t.VOLVELOCITYCONST="VOLVELOCITYCONST",t.VOLVELOCITYGRADIENTX="VOLVELOCITYGRADIENTX",t.VOLVELOCITYGRADIENTY="VOLVELOCITYGRADIENTY",t.VOLVELOCITYGRADIENTZ="VOLVELOCITYGRADIENTZ",t.VOLVELOCITYCONSTMAX="VOLVELOCITYCONSTMAX",t.VOLVELOCITYGRADIENTXMAX="VOLVELOCITYGRADIENTXMAX",t.VOLVELOCITYGRADIENTYMAX="VOLVELOCITYGRADIENTYMAX",t.VOLVELOCITYGRADIENTZMAX="VOLVELOCITYGRADIENTZMAX",t.VOLSPACETYPE="VOLSPACETYPE",t.COLOROVERLIFEGRADIENTALPHAS="COLOROVERLIFEGRADIENTALPHAS",t.COLOROVERLIFEGRADIENTCOLORS="COLOROVERLIFEGRADIENTCOLORS",t.MAXCOLOROVERLIFEGRADIENTALPHAS="MAXCOLOROVERLIFEGRADIENTALPHAS",t.MAXCOLOROVERLIFEGRADIENTCOLORS="MAXCOLOROVERLIFEGRADIENTCOLORS",t.SOLTYPE="SOLTYPE",t.SOLSEPRARATE="SOLSEPRARATE",t.SOLSIZEGRADIENT="SOLSIZEGRADIENT",t.SOLSIZEGRADIENTX="SOLSIZEGRADIENTX",t.SOLSIZEGRADIENTY="SOLSIZEGRADIENTY",t.SOLSizeGradientZ="SOLSizeGradientZ",t.SOLSizeGradientMax="SOLSizeGradientMax",t.SOLSIZEGRADIENTXMAX="SOLSIZEGRADIENTXMAX",t.SOLSIZEGRADIENTYMAX="SOLSIZEGRADIENTYMAX",t.SOLSizeGradientZMAX="SOLSizeGradientZMAX",t.ROLTYPE="ROLTYPE",t.ROLSEPRARATE="ROLSEPRARATE",t.ROLANGULARVELOCITYCONST="ROLANGULARVELOCITYCONST",t.ROLANGULARVELOCITYCONSTSEPRARATE="ROLANGULARVELOCITYCONSTSEPRARATE",t.ROLANGULARVELOCITYGRADIENT="ROLANGULARVELOCITYGRADIENT",t.ROLANGULARVELOCITYGRADIENTX="ROLANGULARVELOCITYGRADIENTX",t.ROLANGULARVELOCITYGRADIENTY="ROLANGULARVELOCITYGRADIENTY",t.ROLANGULARVELOCITYGRADIENTZ="ROLANGULARVELOCITYGRADIENTZ",t.ROLANGULARVELOCITYCONSTMAX="ROLANGULARVELOCITYCONSTMAX",t.ROLANGULARVELOCITYCONSTMAXSEPRARATE="ROLANGULARVELOCITYCONSTMAXSEPRARATE",t.ROLANGULARVELOCITYGRADIENTMAX="ROLANGULARVELOCITYGRADIENTMAX",t.ROLANGULARVELOCITYGRADIENTXMAX="ROLANGULARVELOCITYGRADIENTXMAX",t.ROLANGULARVELOCITYGRADIENTYMAX="ROLANGULARVELOCITYGRADIENTYMAX",t.ROLANGULARVELOCITYGRADIENTZMAX="ROLANGULARVELOCITYGRADIENTZMAX",t.TEXTURESHEETANIMATIONTYPE="TEXTURESHEETANIMATIONTYPE",t.TEXTURESHEETANIMATIONCYCLES="TEXTURESHEETANIMATIONCYCLES",t.TEXTURESHEETANIMATIONSUBUVLENGTH="TEXTURESHEETANIMATIONSUBUVLENGTH",t.TEXTURESHEETANIMATIONGRADIENTUVS="TEXTURESHEETANIMATIONGRADIENTUVS",t.TEXTURESHEETANIMATIONGRADIENTMAXUVS="TEXTURESHEETANIMATIONGRADIENTMAXUVS",t._diffuseTextureIndex=0,i(t,["_tempGravity",function(){return this._tempGravity=new Qe},"defaultMaterial",function(){return this.defaultMaterial=new t}]),t}(gt),Ut=(function(e){function t(){this._tempCurAnimationData=null,this._lastFrameIndex=-1,this._currentTransform=null,this._originalAnimationTransform=null,this._originalFov=0,this._camera=null,this._cacheAnimationDatas=[],this._currentAnimationData=null,this.localMode=!0,this.addMode=!0,this._tempVector30=new Qe,this._tempVector31=new Qe,this._tempVector32=new Qe,t.__super.call(this)}r(t,"laya.d3.component.animation.CameraAnimations",e);var i=t.prototype;return i._effect=function(){var e=0;for(e=0;3>e;e++)this._tempVector30.elements[e]=this._currentAnimationData[e],this._tempVector31.elements[e]=this._currentAnimationData[e+3],this._tempVector32.elements[e]=this._currentAnimationData[e+6];this._currentTransform||(this._currentTransform=new je),je.createLookAt(this._tempVector30,this._tempVector31,this._tempVector32,this._currentTransform),this._currentTransform.invert(this._currentTransform),this.addMode&&je.multiply(this._originalAnimationTransform,this._currentTransform,this._currentTransform),this.localMode?this.owner.transform.localMatrix=this._currentTransform:this.owner.transform.worldMatrix=this._currentTransform,this._camera.fieldOfView=this._currentAnimationData[9]},i._load=function(e){var t=this;if(!(e instanceof laya.d3.core.Camera))throw new Error("该Sprite3D并非Camera");this._camera=e,this._player.on("stopped",this,function(){t._player.returnToZeroStopped&&(t.localMode?t._originalAnimationTransform&&(e.transform.localMatrix=t._originalAnimationTransform):t._originalAnimationTransform&&(e.transform.worldMatrix=t._originalAnimationTransform),t._camera.fieldOfView=t._originalFov)})},i._update=function(e){if(this._templet&&this._templet.loaded&&2===this._player.state){var t=this._player.playbackRate*n.timer.scale,i=this._player.isCache&&t>=1?this.currentFrameIndex:-1,r=this.currentAnimationClipIndex;if(-1!==i&&this._lastFrameIndex===i)return void laya.d3.component.Component3D.prototype._update.call(this,e);if(this._player.isCache&&t>=1){var a=this._templet.getAnimationDataWithCache(this._player.cacheFrameRate,this._cacheAnimationDatas,r,i);if(a)return this._currentAnimationData=a,this._lastFrameIndex=i,laya.d3.component.Component3D.prototype._update.call(this,e),void this._effect()}var s=this._templet.getNodes(r),o=s.length;this._player.isCache&&t>=1?this._currentAnimationData=new Float32Array(10*o):(this._tempCurAnimationData||(this._tempCurAnimationData=new Float32Array(10*o)),this._currentAnimationData=this._tempCurAnimationData),this._player.isCache&&t>=1?this._templet.getOriginalData(r,this._currentAnimationData,this._player._fullFrames[r],i,this._player.currentPlayTime):this._templet.getOriginalDataUnfixedRate(r,this._currentAnimationData,this._player.currentPlayTime),this._player.isCache&&t>=1&&this._templet.setAnimationDataWithCache(this._player.cacheFrameRate,this._cacheAnimationDatas,r,i,this._currentAnimationData),this._lastFrameIndex=i,laya.d3.component.Component3D.prototype._update.call(this,e),this._effect()}},t}(Et),function(e){function t(){this._animationSprites=null,this._animationSpritesInitLocalMatrix=null,this._tempCurAnimationData=null,this._curOriginalData=null,this._lastFrameIndex=-1,this._curAnimationDatas=null,t.__super.call(this),this._animationSprites=[],this._animationSpritesInitLocalMatrix=[]}r(t,"laya.d3.component.animation.RigidAnimations",e);var i=t.prototype;return i._init=function(){for(var e=this._templet.getNodes(this.currentAnimationClipIndex),t=this._owner,n=e.length,i=0,r=new Uint16Array(this._templet.getPublicExtData()),a=0;n>a;a++){var s=r.slice(i+1,i+1+r[i]);i+=r[i]+1;for(var o=1;o<s.length;o++){s[o];t=t._childs[s[o]]}var l=t.getChildByName(e[a].name);if(!l)break;this._animationSprites[a]=l;var h=this._animationSpritesInitLocalMatrix[a];h||(h=this._animationSpritesInitLocalMatrix[a]=new je),l.transform.localMatrix.cloneTo(h),t=this._owner}},i._animtionPlay=function(){this._templet.loaded?this._init():this._templet.once("loaded",this,this._init)},i._animtionStop=function(){if(this._lastFrameIndex=-1,this._player.returnToZeroStopped){this._curAnimationDatas=null;for(var e=0;e<this._animationSprites.length;e++)this._animationSprites[e].transform.localMatrix=this._animationSpritesInitLocalMatrix[e]}},i._effectAnimation=function(e){for(var t=0,n=this._animationSprites.length;n>t;t++){for(var i=this._animationSprites[t],r=i.transform.localMatrix,a=r.elements,s=0;16>s;s++)a[s]=this._curAnimationDatas[16*t+s];i.transform.localMatrix=r}},i._load=function(t){e.prototype._load.call(this,t),this._player.on("stopped",this,this._animtionStop),this._player.on("played",this,this._animtionPlay)},i._update=function(e){if(2===this._player.state&&this._templet&&this._templet.loaded){var t=this._player.playbackRate*n.timer.scale,i=this._player.cachePlayRate,r=this._player.isCache&&t>=i,a=r?this.currentFrameIndex:-1;if(-1===a||this._lastFrameIndex!==a){var s=this.currentAnimationClipIndex,o=this._templet.getNodes(s),l=this._templet._animationDatasCache;if(r){var h=this._templet.getAnimationDataWithCache(i,l,s,a);if(h)return this._curAnimationDatas=h,this._lastFrameIndex=a,void this._effectAnimation(o)}var u=16*o.length;r?this._curAnimationDatas=new Float32Array(u):(this._tempCurAnimationData||(this._tempCurAnimationData=new Float32Array(u)),this._curAnimationDatas=this._tempCurAnimationData),this._curOriginalData||(this._curOriginalData=new Float32Array(this._templet.getTotalkeyframesLength(s))),r?this._templet.getOriginalData(s,this._curOriginalData,this._player._fullFrames[s],a,this._player.currentFrameTime):this._templet.getOriginalDataUnfixedRate(s,this._curOriginalData,this._player.currentPlayTime),rt._computeRootAnimationData(o,this._curOriginalData,this._curAnimationDatas),r&&this._templet.setAnimationDataWithCache(i,l,s,a,this._curAnimationDatas),this._lastFrameIndex=a,this._effectAnimation(o)}}},i._unload=function(t){e.prototype._unload.call(this,t),this._animationSprites=null,this._animationSpritesInitLocalMatrix=null,this._tempCurAnimationData=null,this._curOriginalData=null,this._curAnimationDatas=null},a(0,i,"url",null,function(t){e.prototype._$set_url.call(this,t),this._curOriginalData=null,this._curAnimationDatas=null,this._tempCurAnimationData=null,this._templet._animationDatasCache||(this._templet._animationDatasCache=[])}),a(0,i,"templet",e.prototype._$get_templet,function(t){e.prototype._$set_templet.call(this,t),this._curOriginalData=null,this._curAnimationDatas=null,this._tempCurAnimationData=null,this._templet._animationDatasCache||(this._templet._animationDatasCache=[])}),t}(Et),function(e){function t(){this._tempCurAnimationData=null,this._tempCurBonesData=null,this._curOriginalData=null,this._extenData=null,this._lastFrameIndex=-1,this._curMeshAnimationData=null,this._curBonesDatas=null,this._curAnimationDatas=null,this._ownerMesh=null,t.__super.call(this)}r(t,"laya.d3.component.animation.SkinAnimations",e);var i=t.prototype;return i._getAnimationDatasWithCache=function(e,t,n,i,r){var a=n[i];if(a){var s=a[e];if(s){var o=s[t.id];return o?o[r]:null}return null}return null},i._setAnimationDatasWithCache=function(e,t,n,i,r,a){var s=n[i]||(n[i]={}),o=s[e]||(s[e]={}),l=o[t.id]||(o[t.id]=[]);l[r]=a},i._onAnimationPlayMeshLoaded=function(){for(var e=this._ownerMesh.meshRender.renderObject._renderElements,t=0,n=e.length;n>t;t++)e[t]._canDynamicBatch=!1},i._onAnimationPlay=function(){var e=this._ownerMesh.meshFilter.sharedMesh;e.loaded?this._onAnimationPlayMeshLoaded():e.on("loaded",this,this._onAnimationPlayMeshLoaded)},i._onAnimationStop=function(){this._lastFrameIndex=-1,this._player.returnToZeroStopped&&(this._curBonesDatas=null,this._curAnimationDatas=null);for(var e=this._ownerMesh.meshRender.renderObject._renderElements,t=0,n=e.length;n>t;t++)e[t]._canDynamicBatch=!0},i._load=function(t){e.prototype._load.call(this,t),this._ownerMesh=t,this._player.on("played",this,this._onAnimationPlay),this._player.on("stopped",this,this._onAnimationStop)},i.preComputeKeyFrames=function(e){if(!this._templet.loaded||!this._ownerMesh.meshFilter.sharedMesh.loaded)throw new Error("SkinAnimations: must to be sure animation templet and mesh templet has loaded.");for(var n=this._player.cachePlayRate,i=this._player.cacheFrameRateInterval*n,r=Math.floor(this._templet.getAniDuration(e)/i),a=0;r>=a;a++){var s=this._templet._animationDatasCache[0],o=this._templet._animationDatasCache[1],l=this._ownerMesh.meshFilter.sharedMesh,h=this._getAnimationDatasWithCache(n,l,o,e,a);if(!h){var u=this._templet.getNodes(e),c=16*u.length;this._curMeshAnimationData||(this._curMeshAnimationData=new Float32Array(c));var _=0,d=0;for(this._curAnimationDatas=[],_=0,d=l.getSubMeshCount();d>_;_++)this._curAnimationDatas[_]=new Float32Array(16*l.getSubMesh(_)._boneIndices.length);this._curBonesDatas=new Float32Array(c),this._curOriginalData||(this._curOriginalData=new Float32Array(this._templet.getTotalkeyframesLength(e))),this._templet.getOriginalData(e,this._curOriginalData,this._player._fullFrames[e],a,i*a);var m=l.InverseAbsoluteBindPoses;for(m?rt._computeBoneAndAnimationDatasByBindPoseMatrxix(u,this._curOriginalData,m,this._curBonesDatas,this._curMeshAnimationData):(this._extenData||(this._extenData=new Float32Array(this._templet.getPublicExtData())),rt._computeBoneAndAnimationDatas(u,this._curOriginalData,this._extenData,this._curBonesDatas,this._curMeshAnimationData)),_=0,d=l.getSubMeshCount();d>_;_++){var f=l.getSubMesh(_);t._computeSubMeshAniDatas(_,f._boneIndices,this._curMeshAnimationData,this._curAnimationDatas)}this._setAnimationDatasWithCache(n,l,o,e,a,this._curAnimationDatas),this._templet.setAnimationDataWithCache(n,s,e,a,this._curBonesDatas)}}},i._update=function(e){var i=this._ownerMesh.meshFilter.sharedMesh;if(2===this._player.state&&this._templet&&this._templet.loaded&&i.loaded){var r=this._player.playbackRate*n.timer.scale,a=this._player.cachePlayRate,s=this._player.isCache&&r>=a,o=s?this.currentFrameIndex:-1;if(-1===o||this._lastFrameIndex!==o){var l=this.currentAnimationClipIndex,h=this._templet._animationDatasCache[0],u=this._templet._animationDatasCache[1];if(s){var c=this._getAnimationDatasWithCache(a,i,u,l,o);if(c)return this._curAnimationDatas=c,this._curBonesDatas=this._templet.getAnimationDataWithCache(a,h,l,o),void(this._lastFrameIndex=o)}var _=!1;s&&(this._curBonesDatas=this._templet.getAnimationDataWithCache(a,h,l,o),_=!!this._curBonesDatas);var d=this._templet.getNodes(l),m=16*d.length;this._curMeshAnimationData||(this._curMeshAnimationData=new Float32Array(m));var f=0,p=0;if(s){for(this._curAnimationDatas=[],f=0,p=i.getSubMeshCount();p>f;f++)this._curAnimationDatas[f]=new Float32Array(16*i.getSubMesh(f)._boneIndices.length);_||(this._curBonesDatas=new Float32Array(m))}else{if(!this._tempCurAnimationData)for(this._tempCurAnimationData=[],f=0,p=i.getSubMeshCount();p>f;f++)this._tempCurAnimationData[f]=new Float32Array(16*i.getSubMesh(f)._boneIndices.length);this._tempCurBonesData||(this._tempCurBonesData=new Float32Array(m)),this._curAnimationDatas=this._tempCurAnimationData,this._curBonesDatas=this._tempCurBonesData}this._curOriginalData||(this._curOriginalData=new Float32Array(this._templet.getTotalkeyframesLength(l))),s?this._templet.getOriginalData(l,this._curOriginalData,this._player._fullFrames[l],o,this._player.currentFrameTime):this._templet.getOriginalDataUnfixedRate(l,this._curOriginalData,this._player.currentPlayTime);var v=i.InverseAbsoluteBindPoses;for(v?s&&_?rt._computeAnimationDatasByArrayAndMatrixFast(v,this._curBonesDatas,this._curMeshAnimationData):rt._computeBoneAndAnimationDatasByBindPoseMatrxix(d,this._curOriginalData,v,this._curBonesDatas,this._curMeshAnimationData):(this._extenData||(this._extenData=new Float32Array(this._templet.getPublicExtData())),s&&_?rt._computeAnimationDatas(this._extenData,this._curBonesDatas,this._curMeshAnimationData):rt._computeBoneAndAnimationDatas(d,this._curOriginalData,this._extenData,this._curBonesDatas,this._curMeshAnimationData)),f=0,p=i.getSubMeshCount();p>f;f++){var g=i.getSubMesh(f);t._computeSubMeshAniDatas(f,g._boneIndices,this._curMeshAnimationData,this._curAnimationDatas)}s&&(this._setAnimationDatasWithCache(a,i,u,l,o,this._curAnimationDatas),_||this._templet.setAnimationDataWithCache(a,h,l,o,this._curBonesDatas)),this._lastFrameIndex=o}}},i._preRenderUpdate=function(e){if(this._curAnimationDatas){e.shaderDefines.addInt(32768);var t=e.renderElement.renderObj.indexOfHost;e.shaderValue.pushValue("MATRIXARRAY0",this._curAnimationDatas[t])}},i._unload=function(t){e.prototype._unload.call(this,t),this._tempCurAnimationData=null,this._tempCurBonesData=null,this._curOriginalData=null,this._extenData=null,this._curMeshAnimationData=null,this._curBonesDatas=null,this._curAnimationDatas=null,this._ownerMesh=null},a(0,i,"curBonesDatas",function(){return this._curBonesDatas}),a(0,i,"curAnimationDatas",function(){return this._curAnimationDatas}),a(0,i,"url",null,function(t){e.prototype._$set_url.call(this,t),this._curOriginalData=this._extenData=null,this._curMeshAnimationData=null,this._tempCurBonesData=null,this._tempCurAnimationData=null,this._templet._animationDatasCache||(this._templet._animationDatasCache=[[],[]])}),a(0,i,"templet",e.prototype._$get_templet,function(t){e.prototype._$set_templet.call(this,t),this._curOriginalData=this._extenData=null,this._curMeshAnimationData=null,this._tempCurBonesData=null,this._tempCurAnimationData=null,this._templet._animationDatasCache||(this._templet._animationDatasCache=[[],[]])}),t._computeSubMeshAniDatas=function(e,t,n,i){for(var r=i[e],a=0,s=t.length,o=0;s>a;a++)for(var l=0;16>l;l++,o++)r[o]=n[(t[a]<<4)+l]},t._copyBone=function(e,t,n){for(var i=0,r=e.length,a=0;r>i;i++)for(var s=0;16>s;s++,a++)n[a]=t[(e[i]<<4)+s]},t}(Et)),Gt=(function(e){function t(){this._nodes=null,this._lasstInitIndex=-1,this._materials=null,this._mesh=null,this._meshDataInited=!1,this._uvDatasCount=0,this._subMeshIndexToNodeIndex=[],this._keyframeAges=[],this._ages=[],this._bufferUsages=[],this._originalShaderAttributes=[],this._uvShaderValues=[],this._uvNextShaderValues=[],this._uvAnimationBuffers=[],t.__super.call(this),this._meshDataInited=!1}r(t,"laya.d3.component.animation.UVAnimations",e);var n=t.prototype;return n._initMeshData=function(){this._materials=this._mesh.meshRender.sharedMaterials,this._meshDataInited=!0},n._initAnimationData=function(e){},n._load=function(e){if(!(e instanceof laya.d3.core.MeshSprite3D))throw new Error("该Sprite3D并非Mesh");this._mesh=e,e.on("loaded",this,function(e){}),this.on("loaded",this,function(){}),this.player.on("played",this,function(){}),this.player.on("stopped",this,function(){})},n._update=function(e){if(this.player.update(e.elapsedTime),this._templet&&this._templet.loaded&&2===this.player.state){for(var t=this.currentAnimationClipIndex,n=this._templet.getNodesCurrentFrameIndex(t,this.player.currentPlayTime),i=0;i<this._nodes.length;i++){var r=n[i];this._keyframeAges[i]=(this.player.currentPlayTime-this._nodes[i].keyFrame[r].startTime)/this._nodes[i].keyFrame[r].duration,this._ages[i]=this.player.currentPlayTime/this._nodes[i].playTime;var a=this._nodes[i].keyframeWidth/this._uvDatasCount;this._uvShaderValues[i]||(this._uvShaderValues[i]=[]),this._uvNextShaderValues[i]||(this._uvNextShaderValues[i]=[]);for(var s=0;s<this._uvDatasCount;s++){var o=[2,5126,!1,0,r*a*4],l=[2,5126,!1,0,(r+1)*a*4];this._uvShaderValues[i][s]=o,this._uvNextShaderValues[i][s]=l}}laya.d3.component.Component3D.prototype._update.call(this,e)}},n._preRenderUpdate=function(e){},t}(Et),function(e){function t(){this._numberVertices=0,this._numberIndices=0,this._vertexBuffer=null,this._indexBuffer=null,this._indexOfHost=0,t.__super.call(this),this._indexOfHost=0}r(t,"laya.d3.resource.models.PrimitiveMesh",e);var i=t.prototype;return n.imps(i,{"laya.d3.core.render.IRenderable":!0}),i._getVertexBuffer=function(e){return void 0===e&&(e=0),0===e?this._vertexBuffer:null},i._getIndexBuffer=function(){return this._indexBuffer},i.getRenderElement=function(e){return this},i.getRenderElementsCount=function(){return 1},i.detoryResource=function(){this._vertexBuffer&&(this._vertexBuffer.dispose(),this._vertexBuffer=null),this._indexBuffer&&(this._indexBuffer.dispose(),this._indexBuffer=null),this.memorySize=0},i._beforeRender=function(e){return this._vertexBuffer._bind(),this._indexBuffer._bind(),!0},i._render=function(e){e.context.drawElements(4,this._numberIndices,5123,0),L.drawCall++,L.trianglesFaces+=this._numberIndices/3},a(0,i,"indexOfHost",function(){return this._indexOfHost}),a(0,i,"_vertexBufferCount",function(){
|
||
return 1}),a(0,i,"triangleCount",function(){return this._indexBuffer.indexCount/3}),a(0,i,"positions",function(){var e,t=[],n=this._vertexBuffer.vertexDeclaration.getVertexElements(),i=0;for(i=0;i<n.length;i++){var r=n[i];if("vector3"===r.elementFormat&&"POSITION"===r.elementUsage){e=r;break}}var a=this._vertexBuffer.getData();for(i=0;i<a.length;i+=this._vertexBuffer.vertexDeclaration.vertexStride/4){var s=i+e.offset/4,o=new Qe(a[s+0],a[s+1],a[s+2]);t.push(o)}return t}),t}(xt)),zt=function(e){function t(){this._materials=null,this._subMeshes=null,this._bindPoses=null,this._inverseBindPoses=null,t.__super.call(this),this._subMeshes=[],this._materials=[],this._loaded?this._generateBoundingObject():this.once("loaded",this,this._generateBoundingObject)}r(t,"laya.d3.resource.models.Mesh",e);var i=t.prototype;return i._generateBoundingObject=function(){var e=this.positions;this._boundingBox=new ze(new Qe,new Qe),ze.createfromPoints(e,this._boundingBox),this._boundingSphere=new ke(new Qe,0),ke.createfromPoints(e,this._boundingSphere)},i._add=function(e){e._indexInMesh=this._subMeshes.length,this._subMeshes.push(e),this._subMeshCount++},i._remove=function(e){var t=this._subMeshes.indexOf(e);return 0>t?!1:(this._subMeshes.splice(t,1),this._subMeshCount--,!0)},i.onAsynLoaded=function(e,t){var n=t[0],i=t[1];new Ge(n,this,this._materials,i),this._loaded=!0,this.event("loaded",this)},i.getSubMesh=function(e){return this._subMeshes[e]},i.getSubMeshCount=function(){return this._subMeshes.length},i.getRenderElementsCount=function(){return this._subMeshes.length},i.getRenderElement=function(e){return this._subMeshes[e]},i.dispose=function(){this._resourceManager.removeResource(this),laya.resource.Resource.prototype.dispose.call(this);for(var e=0;e<this._subMeshes.length;e++)this._subMeshes[e].dispose();this._subMeshes=null,this._subMeshCount=0},a(0,i,"positions",function(){for(var e=[],t=this._subMeshes.length,n=0;t>n;n++){var i,r=this._subMeshes[n],a=r._getVertexBuffer(),s=a.vertexDeclaration.getVertexElements(),o=0;for(o=0;o<s.length;o++){var l=s[o];if("vector3"===l.elementFormat&&"POSITION"===l.elementUsage){i=l;break}}var h=a.getData();for(o=0;o<h.length;o+=a.vertexDeclaration.vertexStride/4){var u=o+i.offset/4,c=new Qe(h[u+0],h[u+1],h[u+2]);e.push(c)}}return e}),a(0,i,"materials",function(){return this._materials.slice()}),a(0,i,"bindPoses",function(){return this._bindPoses}),a(0,i,"InverseAbsoluteBindPoses",function(){return this._inverseBindPoses}),t.load=function(e){return n.loader.create(e,null,null,t)},t}(xt),Ht=(function(e){function t(e,n,i,r,a,s,o,l,h){this._alreadyResolved=!1,this._surfaceFormat=0,this._surfaceType=0,this._depthStencilFormat=0,this._frameBuffer=null,this._depthStencilBuffer=null,void 0===i&&(i=6408),void 0===r&&(r=5121),void 0===a&&(a=33189),void 0===s&&(s=!1),void 0===o&&(o=!1),void 0===l&&(l=-1),void 0===h&&(h=-1),t.__super.call(this),this._width=e,this._height=n,this._size=new it(e,n),this._surfaceFormat=i,this._surfaceType=r,this._depthStencilFormat=a,this._mipmap=s,this._repeat=o,this._minFifter=l,this._magFifter=h,this.activeResource(),this._loaded=!0,this._alreadyResolved=!0}r(t,"laya.d3.resource.RenderTexture",e);var n=t.prototype;return n.recreateResource=function(){this.startCreate();var e=w.mainContext;this._frameBuffer=e.createFramebuffer(),this._source=e.createTexture();var t=N.curBindTexTarget,n=N.curBindTexValue;N.bindTexture(e,3553,this._source),e.texImage2D(3553,0,6408,this._width,this._height,0,this._surfaceFormat,this._surfaceType,null);var i=this._minFifter,r=this._magFifter,a=this._repeat?10497:33071,s=l.isPOT(this._width,this._height);if(s?(this._mipmap?-1!==i||(i=9987):-1!==i||(i=9729),-1!==r||(r=9729),e.texParameteri(3553,10241,i),e.texParameteri(3553,10240,r),e.texParameteri(3553,10242,a),e.texParameteri(3553,10243,a),this._mipmap&&e.generateMipmap(3553)):(-1!==i||(i=9729),-1!==r||(r=9729),e.texParameteri(3553,10241,i),e.texParameteri(3553,10240,r),e.texParameteri(3553,10242,33071),e.texParameteri(3553,10243,33071)),e.bindFramebuffer(36160,this._frameBuffer),e.framebufferTexture2D(36160,36064,3553,this._source,0),this._depthStencilFormat)switch(this._depthStencilBuffer=e.createRenderbuffer(),e.bindRenderbuffer(36161,this._depthStencilBuffer),e.renderbufferStorage(36161,this._depthStencilFormat,this._width,this._height),this._depthStencilFormat){case 33189:e.framebufferRenderbuffer(36160,36096,36161,this._depthStencilBuffer);break;case 36168:e.framebufferRenderbuffer(36160,36128,36161,this._depthStencilBuffer);break;case 34041:e.framebufferRenderbuffer(36160,33306,36161,this._depthStencilBuffer)}e.bindFramebuffer(36160,null),t&&n&&N.bindTexture(e,t,n),e.bindRenderbuffer(36161,null),this.memorySize=this._width*this._height*4,this.completeCreate()},n.start=function(){w.mainContext.bindFramebuffer(36160,this.frameBuffer),t._currentRenderTarget=this,this._alreadyResolved=!1},n.end=function(){w.mainContext.bindFramebuffer(36160,null),t._currentRenderTarget=null,this._alreadyResolved=!0},n.getData=function(e,t,n,i){var r=w.mainContext;r.bindFramebuffer(36160,this._frameBuffer);var a=36053===r.checkFramebufferStatus(36160);if(!a)return r.bindFramebuffer(36160,null),null;var s=new Uint8Array(this._width*this._height*4);return r.readPixels(e,t,n,i,this._surfaceFormat,this._surfaceType,s),r.bindFramebuffer(36160,null),s},n.detoryResource=function(){if(this._frameBuffer){var e=w.mainContext;e.deleteTexture(this._source),e.deleteFramebuffer(this._frameBuffer),e.deleteRenderbuffer(this._depthStencilBuffer),this._source=null,this._frameBuffer=null,this._depthStencilBuffer=null,this.memorySize=0}},a(0,n,"surfaceFormat",function(){return this._surfaceFormat}),a(0,n,"surfaceType",function(){return this._surfaceType}),a(0,n,"depthStencilFormat",function(){return this._depthStencilFormat}),a(0,n,"source",function(){return this._alreadyResolved?e.prototype._$get_source.call(this):null}),a(0,n,"depthStencilBuffer",function(){return this._depthStencilBuffer}),a(0,n,"frameBuffer",function(){return this._frameBuffer}),t._currentRenderTarget=null,t}(Tt),function(e){function t(e){this._color=null,this._pixels=null,t.__super.call(this),this._width=1,this._height=1,this._size=new it(this.width,this.height),this._color=e,this._pixels=new Uint8Array([255*e.x,255*e.y,255*e.z,255*e.w])}r(t,"laya.d3.resource.SolidColorTexture2D",e);var n=t.prototype;return n._createWebGlTexture=function(){var e=w.mainContext,t=this._source=e.createTexture(),n=this._width,i=this._height,r=N.curBindTexTarget,a=N.curBindTexValue;N.bindTexture(e,3553,t),e.texImage2D(3553,0,6408,n,i,0,6408,5121,this._pixels);var s=this._minFifter,o=this._magFifter,h=this._repeat?10497:33071,u=l.isPOT(n,i);u?(this._mipmap?-1!==s||(s=9987):-1!==s||(s=9729),-1!==o||(o=9729),e.texParameteri(3553,10241,s),e.texParameteri(3553,10240,o),e.texParameteri(3553,10242,h),e.texParameteri(3553,10243,h),this._mipmap&&e.generateMipmap(3553)):(-1!==s||(s=9729),-1!==o||(o=9729),e.texParameteri(3553,10241,s),e.texParameteri(3553,10240,o),e.texParameteri(3553,10242,33071),e.texParameteri(3553,10243,33071)),r&&a&&N.bindTexture(e,r,a),u?this.memorySize=n*i*4*(1+1/3):this.memorySize=n*i*4},n.recreateResource=function(){this.startCreate(),this._createWebGlTexture(),this.completeCreate()},n.detoryResource=function(){this._source&&(w.mainContext.deleteTexture(this._source),this._source=null,this.memorySize=0)},a(0,n,"source",function(){return e.prototype._$get_source.call(this)}),i(t,["magentaTexture",function(){return this.magentaTexture=new t(new $e(1,0,1,1))},"grayTexture",function(){return this.grayTexture=new t(new $e(.5,.5,.5,1))}]),t}(Tt)),kt=(function(e){function t(){this._sharderNameID=0,this._shader=null,this._numberVertices=0,this._numberIndices=0,this._vertexBuffer=null,this._indexBuffer=null,this._alphaBlending=1,this._colorIntensity=1,this._textureCube=null,this._shaderValue=new b,t.__super.call(this),this.name="Skybox-"+t._nameNumber,t._nameNumber++,this.loadShaderParams(),this.recreateResource()}r(t,"laya.d3.resource.models.SkyBox",e);var n=t.prototype;return n._getShader=function(e){var t=e.shaderDefines,n=t._value,i=t._value+2e-4*this._sharderNameID;return this._shader=C.withCompile(this._sharderNameID,e.shaderDefines.toNameDic(),i,null),t._value=n,this._shader},n.recreateResource=function(){this.startCreate(),this._numberVertices=36,this._numberIndices=36;var e=new Uint16Array(this._numberIndices),n=t._vertexDeclaration.vertexStride/4,i=new Float32Array(this._numberVertices*n),r=1,a=1,s=1,o=r/2,l=a/2,h=s/2,u=new Qe(-o,l,h),c=new Qe(-o,-l,h),_=new Qe(o,l,h),d=new Qe(o,-l,h),m=new Qe(-o,l,-h),f=new Qe(o,l,-h),p=new Qe(-o,-l,-h),v=new Qe(o,-l,-h),g=0;g=this._addVertex(i,g,u),g=this._addVertex(i,g,c),g=this._addVertex(i,g,_),g=this._addVertex(i,g,c),g=this._addVertex(i,g,d),g=this._addVertex(i,g,_),g=this._addVertex(i,g,m),g=this._addVertex(i,g,f),g=this._addVertex(i,g,p),g=this._addVertex(i,g,p),g=this._addVertex(i,g,f),g=this._addVertex(i,g,v),g=this._addVertex(i,g,u),g=this._addVertex(i,g,f),g=this._addVertex(i,g,m),g=this._addVertex(i,g,u),g=this._addVertex(i,g,_),g=this._addVertex(i,g,f),g=this._addVertex(i,g,c),g=this._addVertex(i,g,p),g=this._addVertex(i,g,v),g=this._addVertex(i,g,c),g=this._addVertex(i,g,v),g=this._addVertex(i,g,d),g=this._addVertex(i,g,u),g=this._addVertex(i,g,p),g=this._addVertex(i,g,c),g=this._addVertex(i,g,m),g=this._addVertex(i,g,p),g=this._addVertex(i,g,u),g=this._addVertex(i,g,_),g=this._addVertex(i,g,d),g=this._addVertex(i,g,v),g=this._addVertex(i,g,f),g=this._addVertex(i,g,_),g=this._addVertex(i,g,v);for(var T=0;36>T;T++)e[T]=T;this._vertexBuffer=new Bt(t._vertexDeclaration,this._numberVertices,35044,!0),this._indexBuffer=new Nt("ushort",this._numberIndices,35044,!0),this._vertexBuffer.setData(i),this._indexBuffer.setData(e),this.memorySize=2*(this._vertexBuffer.byteLength+this._indexBuffer.byteLength),this.completeCreate()},n._addVertex=function(e,t,n){var i=n.elements;return e[t+0]=i[0],e[t+1]=i[1],e[t+2]=i[2],t+3},n.loadShaderParams=function(){this._sharderNameID=C.nameKey.get("SkyBox"),this._shaderValue.pushValue("DIFFUSETEXTURE",null)},n._render=function(e){if(this._textureCube&&this._textureCube.loaded){this._vertexBuffer._bind(),this._indexBuffer._bind(),this._shader=this._getShader(e);var n=this._shaderValue.length;this._shaderValue.pushArray(e.shaderValue),this._shaderValue.pushArray(this._vertexBuffer.vertexDeclaration.shaderValues),e.camera.transform.worldMatrix.cloneTo(t._tempMatrix4x40),t._tempMatrix4x40.transpose(),je.multiply(e.projectionMatrix,t._tempMatrix4x40,t._tempMatrix4x41),this._shaderValue.pushValue("MVPMATRIX",t._tempMatrix4x41.elements),this._shaderValue.pushValue("INTENSITY",this._colorIntensity),this._shaderValue.pushValue("ALPHABLENDING",this.alphaBlending),this._shaderValue.data[1]=this.textureCube.source,this._shader.uploadArray(this._shaderValue.data,this._shaderValue.length,null),this._shaderValue.length=n,w.mainContext.drawElements(4,36,5123,0),L.trianglesFaces+=12,L.drawCall++}},a(0,n,"alphaBlending",function(){return this._alphaBlending},function(e){this._alphaBlending=e,this._alphaBlending<0&&(this._alphaBlending=0),this._alphaBlending>1&&(this._alphaBlending=1)}),a(0,n,"textureCube",function(){return this._textureCube},function(e){this._textureCube=e}),a(0,n,"colorIntensity",function(){return this._colorIntensity},function(e){this._colorIntensity=e,this._colorIntensity<0&&(this._colorIntensity=0)}),t._nameNumber=1,i(t,["_tempMatrix4x40",function(){return this._tempMatrix4x40=new je},"_tempMatrix4x41",function(){return this._tempMatrix4x41=new je},"_vertexDeclaration",function(){return this._vertexDeclaration=new fe(12,[new pe(0,"vector3","POSITION")])}]),t}(Mt),function(e){function t(){this._sharderNameID=0,this._shader=null,this._numberVertices=0,this._numberIndices=0,this._vertexBuffer=null,this._indexBuffer=null,this._alphaBlending=1,this._colorIntensity=1,this._texture=null,this._stacks=16,this._slices=16,this._radius=1,this._shaderValue=new b,t.__super.call(this),this.name="SkyDome-"+t._nameNumber,t._nameNumber++,this.loadShaderParams(),this.recreateResource()}r(t,"laya.d3.resource.models.SkyDome",e);var n=t.prototype;return n._getShader=function(e){var t=e.shaderDefines,n=t._value,i=t._value+2e-4*this._sharderNameID;return this._shader=C.withCompile(this._sharderNameID,e.shaderDefines.toNameDic(),i,null),t._value=n,this._shader},n.recreateResource=function(){this.startCreate(),this._numberVertices=(this._stacks+1)*(this._slices+1),this._numberIndices=3*this._stacks*(this._slices+1)*2;for(var e=new Uint16Array(this._numberIndices),n=t._vertexDeclaration.vertexStride/4,i=new Float32Array(this._numberVertices*n),r=Math.PI/this._stacks,a=2*Math.PI/this._slices,s=0,o=0,l=0,h=0;h<this._stacks+1;h++)for(var u=Math.sin(h*r),c=Math.cos(h*r),_=0;_<this._slices+1;_++){var d=u*Math.sin(_*a),m=u*Math.cos(_*a);i[o+0]=d*this._radius,i[o+1]=c*this._radius,i[o+2]=m*this._radius,i[o+3]=_/this._slices,i[o+4]=h/this._stacks,o+=n,h!=this._stacks-1&&(e[l++]=s+1,e[l++]=s,e[l++]=s+(this._slices+1),e[l++]=s+(this._slices+1),e[l++]=s,e[l++]=s+this._slices,s++)}this._vertexBuffer=new Bt(t._vertexDeclaration,this._numberVertices,35044),this._indexBuffer=new Nt("ushort",this._numberIndices,35044),this._vertexBuffer.setData(i),this._indexBuffer.setData(e),this.memorySize=2*(this._vertexBuffer.byteLength+this._indexBuffer.byteLength),this.completeCreate()},n.loadShaderParams=function(){this._sharderNameID=C.nameKey.get("SkyDome"),this._shaderValue.pushValue("DIFFUSETEXTURE",null)},n._render=function(e){if(this._texture&&this._texture.loaded){this._vertexBuffer._bind(),this._indexBuffer._bind(),this._shader=this._getShader(e);var n=this._shaderValue.length;this._shaderValue.pushArray(e.shaderValue),this._shaderValue.pushArray(this._vertexBuffer.vertexDeclaration.shaderValues),e.camera.transform.worldMatrix.cloneTo(t._tempMatrix4x40),t._tempMatrix4x40.transpose(),je.multiply(e.projectionMatrix,t._tempMatrix4x40,t._tempMatrix4x41),this._shaderValue.pushValue("MVPMATRIX",t._tempMatrix4x41.elements),this._shaderValue.pushValue("INTENSITY",this._colorIntensity),this._shaderValue.pushValue("ALPHABLENDING",this.alphaBlending),this._shaderValue.data[1]=this.texture.source,this._shader.uploadArray(this._shaderValue.data,this._shaderValue.length,null),this._shaderValue.length=n,w.mainContext.drawElements(4,this._indexBuffer.indexCount,5123,0),L.trianglesFaces+=this._numberIndices/3,L.drawCall++}},a(0,n,"alphaBlending",function(){return this._alphaBlending},function(e){this._alphaBlending=e,this._alphaBlending<0&&(this._alphaBlending=0),this._alphaBlending>1&&(this._alphaBlending=1)}),a(0,n,"colorIntensity",function(){return this._colorIntensity},function(e){this._colorIntensity=e,this._colorIntensity<0&&(this._colorIntensity=0)}),a(0,n,"texture",function(){return this._texture},function(e){this._texture=e}),t._nameNumber=1,i(t,["_tempMatrix4x40",function(){return this._tempMatrix4x40=new je},"_tempMatrix4x41",function(){return this._tempMatrix4x41=new je},"_vertexDeclaration",function(){return this._vertexDeclaration=new fe(20,[new pe(0,"vector3","POSITION"),new pe(12,"vector2","UV")])}]),t}(Mt),function(e){function t(){this._src=null,this._image=null,this._recreateLock=!1,this._needReleaseAgain=!1,t.__super.call(this)}r(t,"laya.d3.resource.Texture2D",e);var i=t.prototype;return i._onTextureLoaded=function(e){this._image=e;var t=e.width,n=e.height;this._width=t,this._height=n,this._size=new it(t,n)},i._createWebGlTexture=function(){if(!this._image)throw"create GLTextur err:no data:"+this._image;var e=w.mainContext,t=this._source=e.createTexture(),n=this._width,i=this._height,r=N.curBindTexTarget,a=N.curBindTexValue;N.bindTexture(e,3553,t),e.texImage2D(3553,0,6408,6408,5121,this._image);var s=this._minFifter,o=this._magFifter,h=this._repeat?10497:33071,u=l.isPOT(n,i);u?(this._mipmap?-1!==s||(s=9987):-1!==s||(s=9729),-1!==o||(o=9729),e.texParameteri(3553,10241,s),e.texParameteri(3553,10240,o),e.texParameteri(3553,10242,h),e.texParameteri(3553,10243,h),this._mipmap&&e.generateMipmap(3553)):(-1!==s||(s=9729),-1!==o||(o=9729),e.texParameteri(3553,10241,s),e.texParameteri(3553,10240,o),e.texParameteri(3553,10242,33071),e.texParameteri(3553,10243,33071)),r&&a&&N.bindTexture(e,r,a),this._image.onload=null,this._image=null,u?this.memorySize=n*i*4*(1+1/3):this.memorySize=n*i*4,this._recreateLock=!1},i.recreateResource=function(){if(null!=this._src&&""!==this._src)if(this._needReleaseAgain=!1,this._image){if(this._recreateLock)return;this.startCreate(),this._createWebGlTexture(),this.completeCreate()}else{this._recreateLock=!0,this.startCreate();var e=this;this._image=new h.window.Image,this._image.crossOrigin="",this._image.onload=function(){return e._needReleaseAgain?(e._needReleaseAgain=!1,e._image.onload=null,void(e._image=null)):(e._createWebGlTexture(),void e.completeCreate())},this._image.src=this._src}},i.onAsynLoaded=function(e,t){this._src=e,this._onTextureLoaded(t),this.activeResource(),this._loaded=!0,this.event("loaded",this)},i.detoryResource=function(){this._recreateLock&&(this._needReleaseAgain=!0),this._source&&(w.mainContext.deleteTexture(this._source),this._source=null,this._image=null,this.memorySize=0)},a(0,i,"src",function(){return this._src}),t.load=function(e){return n.loader.create(e,null,null,t)},t}(Tt)),Xt=function(e){function t(){this._texCount=6,this._recreateLock=!1,this._needReleaseAgain=!1,t.__super.call(this)}r(t,"laya.d3.resource.TextureCube",e);var i=t.prototype;return i._onTextureLoaded=function(e){this._images=e;for(var t=2147483647,n=2147483647,i=0;6>i;i++){var r=e[i];t=Math.min(t,r.width),n=Math.min(n,r.height)}this._width=t,this._height=n,this._size=new it(t,n)},i._createWebGlTexture=function(){var e=0;for(e=0;e<this._texCount;e++)if(!this._images[e])throw"create GLTextur err:no data:"+this._images[e];var t=w.mainContext,n=this._source=t.createTexture(),i=this._width,r=this._height,a=N.curBindTexTarget,s=N.curBindTexValue;N.bindTexture(t,34067,n),t.texImage2D(34069,0,6408,6408,5121,this._images[0]),t.texImage2D(34070,0,6408,6408,5121,this._images[1]),t.texImage2D(34071,0,6408,6408,5121,this._images[2]),t.texImage2D(34072,0,6408,6408,5121,this._images[3]),t.texImage2D(34073,0,6408,6408,5121,this._images[4]),t.texImage2D(34074,0,6408,6408,5121,this._images[5]);var o=this.minFifter,h=this.magFifter,u=this.repeat?10497:33071,c=l.isPOT(i,r);for(c?(this.mipmap?-1!==o||(o=9987):-1!==o||(o=9729),-1!==h||(h=9729),t.texParameteri(34067,10241,o),t.texParameteri(34067,10240,h),t.texParameteri(34067,10242,u),t.texParameteri(34067,10243,u),this.mipmap&&t.generateMipmap(34067)):(-1!==o||(o=9729),-1!==h||(h=9729),t.texParameteri(34067,10241,o),t.texParameteri(34067,10240,h),t.texParameteri(34067,10242,33071),t.texParameteri(34067,10243,33071)),a&&s&&N.bindTexture(t,a,s),e=0;6>e;e++)this._images[e].onload=null,this._images[e]=null;c?this.memorySize=i*r*4*(1+1/3)*this._texCount:this.memorySize=i*r*4*this._texCount,this._recreateLock=!1},i.recreateResource=function(){var e=this;if(null!=this._srcs)if(this._needReleaseAgain=!1,this._images[0]){if(this._recreateLock)return;this.startCreate(),this._createWebGlTexture(),this.completeCreate()}else{this._recreateLock=!0,this.startCreate();for(var t=this,n=0;n<this._texCount;n++){this._images[n]=new h.window.Image,this._images[n].crossOrigin="";var i=n;this._images[i].onload=function(){var n=0;if(t._needReleaseAgain){for(n=0;n<e._texCount;n++)if(!t._images[n].complete)return;for(t._needReleaseAgain=!1,n=0;n<e._texCount;n++)t._images[n].onload=null,t._images[n]=null}else{for(n=0;n<e._texCount;n++)if(!t._images[n].complete)return;t._createWebGlTexture(),t.completeCreate()}},this._images[n].src=this._srcs[n]}}},i.onAsynLoaded=function(e,t){this._srcs=e,this._onTextureLoaded(t),this.activeResource(),this._loaded=!0,this.event("loaded",this)},i.detoryResource=function(){this._recreateLock&&(this._needReleaseAgain=!0),this._source&&(w.mainContext.deleteTexture(this._source),this._source=null,this.memorySize=0)},a(0,i,"srcs",function(){return this._srcs}),t.load=function(e){return n.loader.create(e,null,null,t)},t}(Tt);(function(e){function t(){t.__super.call(this)}r(t,"laya.d3.core.scene.Scene",e);var n=t.prototype;return n._renderCamera=function(e,t,n){this._prepareRenderToRenderState(n,t),this.beforeRender(t);var i=n.renderTarget;i?(i.start(),je.multiply(this._invertYScaleMatrix,n.projectionMatrix,this._invertYProjectionMatrix),je.multiply(this._invertYScaleMatrix,n.projectionViewMatrix,this._invertYProjectionViewMatrix),t.projectionMatrix=this._invertYProjectionMatrix,t.projectionViewMatrix=this._invertYProjectionViewMatrix):(t.projectionMatrix=n.projectionMatrix,t.projectionViewMatrix=n.projectionViewMatrix),t.viewMatrix=n.viewMatrix,t.viewport=n.viewport,this._preRenderScene(e,t),this._clear(e,t),this._renderScene(e,t),this.lateRender(t),this._endRenderToRenderState(t),i&&i.end()},n.renderSubmit=function(){var e=w.mainContext;this._set3DRenderConfig(e);for(var t=0,n=this._cameraPool.length;n>t;t++){var i=this._cameraPool[t];i.enable&&this._renderCamera(e,this._renderState,i)}return this._set2DRenderConfig(e),1},t})(Ct),function(e){function t(){t.__super.call(this)}r(t,"laya.d3.core.scene.VRScene",e);var n=t.prototype;return n.renderCamera=function(e,t,n){this._prepareRenderToRenderState(n,t),t.shaderDefines.add(64),this.beforeRender(t);var i=n.renderTarget;i?(i.start(),je.multiply(this._invertYScaleMatrix,n.leftProjectionMatrix,this._invertYProjectionMatrix),je.multiply(this._invertYScaleMatrix,n.leftProjectionViewMatrix,this._invertYProjectionViewMatrix),t.projectionMatrix=this._invertYProjectionMatrix,t.projectionViewMatrix=this._invertYProjectionViewMatrix):(t.projectionMatrix=n.leftProjectionMatrix,t.projectionViewMatrix=n.leftProjectionViewMatrix),t.viewMatrix=n.leftViewMatrix,t.viewport=n.leftViewport,this._preRenderScene(e,t),this._clear(e,t),this._renderScene(e,t),i?(i.start(),je.multiply(this._invertYScaleMatrix,n.rightProjectionMatrix,this._invertYProjectionMatrix),je.multiply(this._invertYScaleMatrix,n.rightProjectionViewMatrix,this._invertYProjectionViewMatrix),t.projectionMatrix=this._invertYProjectionMatrix,t.projectionViewMatrix=this._invertYProjectionViewMatrix):(t.projectionMatrix=n.rightProjectionMatrix,t.projectionViewMatrix=n.rightProjectionViewMatrix),t.viewMatrix=n.rightViewMatrix,t.viewport=n.rightViewport,this._preRenderScene(e,t),this._clear(e,t),this._renderScene(e,t),this.lateRender(t),i&&i.end()},n.renderSubmit=function(){var e=w.mainContext,t=this._renderState;this._set3DRenderConfig(e);for(var n=0,i=this._cameraPool.length;i>n;n++){var r=this._cameraPool[n];r.enable&&this.renderCamera(e,t,r)}return this._set2DRenderConfig(e),1},t}(Ct),function(e){function t(e,n,i){void 0===e&&(e=0),void 0===n&&(n=.1),void 0===i&&(i=1e3),this._viewMatrix=new je,this._projectionMatrix=new je,this._projectionViewMatrix=new je,this._viewport=new Je(0,0,0,0),this._normalizedViewport=new Je(0,0,1,1),this._aspectRatio=e,t.__super.call(this,n,i)}r(t,"laya.d3.core.Camera",e);var n=t.prototype;return n._calculateProjectionMatrix=function(){if(!this._useUserProjectionMatrix)if(this.orthographicProjection){var e=this.orthographicVerticalSize*this.aspectRatio*.5,t=.5*this.orthographicVerticalSize;je.createOrthogonal(-e,e,-t,t,this.nearPlane,this.farPlane,this._projectionMatrix)}else je.createPerspective(3.1416*this.fieldOfView/180,this.aspectRatio,this.nearPlane,this.farPlane,this._projectionMatrix);this._projectionMatrixModifyID+=.01/this.id},n.viewportPointToRay=function(e,t){tt.calculateCursorRay(e,this.viewport,this._projectionMatrix,this.viewMatrix,null,t)},n.normalizedViewportPointToRay=function(e,n){var i=t._tempVector2,r=this.viewport,a=e.elements,s=i.elements;s[0]=a[0]*r.width,s[1]=a[1]*r.height,tt.calculateCursorRay(i,this.viewport,this._projectionMatrix,this.viewMatrix,null,n)},n.worldToViewportPoint=function(e,t){if(je.multiply(this._projectionMatrix,this._viewMatrix,this._projectionViewMatrix),this.viewport.project(e,this._projectionViewMatrix,t),t.z<0||t.z>1){var n=t.elements;n[0]=n[1]=n[2]=NaN}},n.worldToNormalizedViewportPoint=function(e,t){if(je.multiply(this._projectionMatrix,this._viewMatrix,this._projectionViewMatrix),this.normalizedViewport.project(e,this._projectionViewMatrix,t),t.z<0||t.z>1){var n=t.elements;n[0]=n[1]=n[2]=NaN}},a(0,n,"projectionViewMatrix",function(){return je.multiply(this.projectionMatrix,this.viewMatrix,this._projectionViewMatrix),this._projectionViewMatrix}),a(0,n,"aspectRatio",function(){if(0===this._aspectRatio){var e=this.viewport;return e.width/e.height}return this._aspectRatio},function(e){if(0>e)throw new Error("Camera: the aspect ratio has to be a positive real number.");this._aspectRatio=e,this._calculateProjectionMatrix()}),a(0,n,"needViewport",function(){var e=this.normalizedViewport;return 0===e.x&&0===e.y&&1===e.width&&1===e.height}),a(0,n,"viewport",function(){if(this._viewportExpressedInClipSpace){var e=this._normalizedViewport,t=this.renderTargetSize,n=t.width,i=t.height;this._viewport.x=e.x*n,this._viewport.y=e.y*i,this._viewport.width=e.width*n,this._viewport.height=e.height*i}return this._viewport},function(e){if(null!=this.renderTarget&&(e.x<0||e.y<0||0==e.width||0==e.height))throw new Error("Camera: viewport size invalid.","value");this._viewportExpressedInClipSpace=!1,this._viewport=e,this._calculateProjectionMatrix()}),a(0,n,"normalizedViewport",function(){if(!this._viewportExpressedInClipSpace){var e=this._viewport,t=this.renderTargetSize,n=t.width,i=t.height;this._normalizedViewport.x=e.x/n,this._normalizedViewport.y=e.y/i,this._normalizedViewport.width=e.width/n,this._normalizedViewport.height=e.height/i}return this._normalizedViewport},function(e){if(e.x<0||e.y<0||e.x+e.width>1||e.x+e.height>1)throw new Error("Camera: viewport size invalid.","value");this._viewportExpressedInClipSpace=!0,this._normalizedViewport=e,this._calculateProjectionMatrix()}),a(0,n,"projectionMatrix",function(){return this._projectionMatrix},function(e){this._projectionMatrix=e,this._useUserProjectionMatrix=!0}),a(0,n,"viewMatrix",function(){return this.transform.worldMatrix.invert(this._viewMatrix),this._viewMatrix}),i(t,["_tempVector2",function(){return this._tempVector2=new Ke}]),t}(Vt),function(e){function t(){this._direction=null,t.__super.call(this),this._diffuseColor=new Qe(1,1,1),this._ambientColor=new Qe(.6,.6,.6),this._specularColor=new Qe(1,1,1),this._reflectColor=new Qe(1,1,1),this._direction=new Qe(0,-.5,-1)}r(t,"laya.d3.core.light.DirectionLight",e);var n=t.prototype;return n.updateToWorldState=function(e){if(e.scene.enableLight){var t=e.shaderValue;e.shaderDefines.add(4096),t.pushValue("LIGHTDIRDIFFUSE",this.diffuseColor.elements),t.pushValue("LIGHTDIRAMBIENT",this.ambientColor.elements),t.pushValue("LIGHTDIRSPECULAR",this.specularColor.elements),t.pushValue("LIGHTDIRECTION",this.direction.elements)}},a(0,n,"direction",function(){return this._direction},function(e){this._direction=e}),a(0,n,"lightType",function(){return 1}),t}(Dt),function(e){function t(){this._attenuation=null,this._range=NaN,t.__super.call(this),this._diffuseColor=new Qe(1,1,1),this._ambientColor=new Qe(.2,.2,.2),this._specularColor=new Qe(1,0,0),this._reflectColor=new Qe(1,1,1),this.transform.position=new Qe(0,0,0),this._range=6,this._attenuation=new Qe(.6,.6,.6)}r(t,"laya.d3.core.light.PointLight",e);var n=t.prototype;return n.updateToWorldState=function(e){if(e.scene.enableLight){var t=e.shaderValue;e.shaderDefines.add(8192),t.pushValue("POINTLIGHTDIFFUSE",this.diffuseColor.elements),t.pushValue("POINTLIGHTAMBIENT",this.ambientColor.elements),t.pushValue("POINTLIGHTSPECULAR",this.specularColor.elements),t.pushValue("POINTLIGHTPOS",this.transform.position.elements),t.pushValue("POINTLIGHTRANGE",this.range),t.pushValue("POINTLIGHTATTENUATION",this.attenuation.elements)}},a(0,n,"range",function(){return this._range},function(e){this._range=e}),a(0,n,"lightType",function(){return 2}),a(0,n,"attenuation",function(){return this._attenuation},function(e){this._attenuation=e}),t}(Dt),function(e){function t(){this._direction=null,this._attenuation=null,this._spot=NaN,this._range=NaN,t.__super.call(this),this._diffuseColor=new Qe(1,1,1),this._ambientColor=new Qe(.2,.2,.2),this._specularColor=new Qe(1,1,1),this._reflectColor=new Qe(1,1,1),this.transform.position=new Qe(0,1,1),this._direction=new Qe(0,-1,-1),this._attenuation=new Qe(.6,.6,.6),this._spot=96,this._range=6}r(t,"laya.d3.core.light.SpotLight",e);var n=t.prototype;return n.updateToWorldState=function(e){if(e.scene.enableLight){var t=e.shaderValue;e.shaderDefines.add(16384),t.pushValue("SPOTLIGHTDIFFUSE",this.diffuseColor.elements),t.pushValue("SPOTLIGHTAMBIENT",this.ambientColor.elements),t.pushValue("SPOTLIGHTSPECULAR",this.specularColor.elements),t.pushValue("SPOTLIGHTPOS",this.transform.position.elements),t.pushValue("SPOTLIGHTDIRECTION",this.direction.elements),t.pushValue("SPOTLIGHTRANGE",this.range),t.pushValue("SPOTLIGHTSPOT",this.spot),t.pushValue("SPOTLIGHTATTENUATION",this.attenuation.elements)}},a(0,n,"range",function(){return this._range},function(e){this._range=e}),a(0,n,"direction",function(){return this._direction},function(e){this._direction=e}),a(0,n,"lightType",function(){return 3}),a(0,n,"attenuation",function(){return this._attenuation},function(e){this._attenuation=e}),a(0,n,"spot",function(){return this._spot},function(e){this._spot=e}),t}(Dt),function(e){function t(e,n,i){this._minX=NaN,this._minZ=NaN,this._cellSize=null,this._heightMap=null,t.__super.call(this,e,i),this._heightMap=n,this._cellSize=new Ke}r(t,"laya.d3.core.MeshTerrainSprite3D",e);var n=t.prototype;return n._disableRotation=function(){var e=this.transform.rotation;e.elements[0]=0,e.elements[1]=0,e.elements[2]=0,e.elements[3]=1,this.transform.rotation=e},n._getScaleX=function(){var e=this.transform.worldMatrix,t=e.elements,n=t[0],i=t[1],r=t[2];return Math.sqrt(n*n+i*i+r*r)},n._getScaleZ=function(){var e=this.transform.worldMatrix,t=e.elements,n=t[8],i=t[9],r=t[10];return Math.sqrt(n*n+i*i+r*r)},n._initCreateFromMesh=function(e,t){this._heightMap=F.creatFromMesh(this.meshFilter.sharedMesh,e,t,this._cellSize);var n=this.meshFilter.sharedMesh.boundingBox,i=n.min;n.max;this._minX=i.x,this._minZ=i.z},n._createFromMeshAndHeightMapMeshLoaded=function(e,t,n,i){this._initCreateFromMeshHeightMap(t,n,i)},n._initCreateFromMeshHeightMap=function(e,t,n){var i=this,r=this.meshFilter.sharedMesh.boundingBox;e.loaded?(this._heightMap=F.createFromImage(e,t,n),this._computeCellSize(r)):e.once("loaded",null,function(){i._heightMap=F.createFromImage(e,t,n),i._computeCellSize(r)});var a=r.min;r.max;this._minX=a.x,this._minZ=a.z},n._computeCellSize=function(e){var t=e.min,n=e.max,i=t.x,r=t.z,a=n.x,s=n.z,o=a-i,l=s-r;this._cellSize.elements[0]=o/(this._heightMap.width-1),this._cellSize.elements[1]=l/(this._heightMap.height-1)},n._update=function(t){this._disableRotation(),e.prototype._update.call(this,t)},n.getHeight=function(e,n){t._tempVector3.elements[0]=e,t._tempVector3.elements[1]=0,t._tempVector3.elements[2]=n,this._disableRotation();var i=this.transform.worldMatrix;i.invert(t._tempMatrix4x4),Qe.transformCoordinate(t._tempVector3,t._tempMatrix4x4,t._tempVector3),e=t._tempVector3.elements[0],n=t._tempVector3.elements[2];var r=(e-this._minX)/this._cellSize.x,a=(n-this._minZ)/this._cellSize.y,s=Math.floor(a),o=Math.floor(r),l=r-o,h=a-s,u=NaN,c=NaN,_=i.elements,d=_[4],m=_[5],f=_[6],p=Math.sqrt(d*d+m*m+f*f),v=_[13],g=this._heightMap.getHeight(s,o+1),T=this._heightMap.getHeight(s+1,o);if(isNaN(g)||isNaN(T))return NaN;if(1>=l+h){var x=this._heightMap.getHeight(s,o);return isNaN(x)?NaN:(u=g-x,c=T-x,(x+l*u+h*c)*p+v)}var M=this._heightMap.getHeight(s+1,o+1);return isNaN(M)?NaN:(u=T-M,c=g-M,(M+(1-l)*u+(1-h)*c)*p+v)},a(0,n,"minX",function(){var e=this.transform.worldMatrix,t=e.elements;return this._minX*this._getScaleX()+t[12]}),a(0,n,"width",function(){return(this._heightMap.width-1)*this._cellSize.x*this._getScaleX();
|
||
}),a(0,n,"minZ",function(){var e=this.transform.worldMatrix,t=e.elements;return this._minZ*this._getScaleZ()+t[14]}),a(0,n,"depth",function(){return(this._heightMap.height-1)*this._cellSize.y*this._getScaleZ()}),t.createFromMesh=function(e,n,i,r){var a=new t(e,null,r);return e.loaded?a._initCreateFromMesh(n,i):e.once("loaded",a,a._initCreateFromMesh,[n,i]),a},t.createFromMeshAndHeightMap=function(e,n,i,r,a){var s=new t(e,null,a);return e.loaded?s._initCreateFromMeshHeightMap(n,i,r):e.once("loaded",s,s._createFromMeshAndHeightMapMeshLoaded,[n,r]),s},i(t,["_tempVector3",function(){return this._tempVector3=new Qe},"_tempMatrix4x4",function(){return this._tempMatrix4x4=new je}]),t}(Lt),function(e){function t(e,n,i,r,a){void 0===e&&(e=.1),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=.1),void 0===a&&(a=1e3),this._tempMatrix=new je,this._leftViewMatrix=new je,this._leftProjectionMatrix=new je,this._leftProjectionViewMatrix=new je,this._leftViewport=new Je(0,0,0,0),this._leftNormalizedViewport=new Je(0,0,.5,1),this._leftAspectRatio=n,this._rightViewMatrix=new je,this._rightProjectionMatrix=new je,this._rightProjectionViewMatrix=new je,this._rightViewport=new Je(0,0,0,0),this._rightNormalizedViewport=new Je(.5,0,.5,1),this._rightAspectRatio=i,this._pupilDistande=e,t.__super.call(this,r,a)}r(t,"laya.d3.core.VRCamera",e);var n=t.prototype;return n._calculatePupilOffset=function(){var e=this._tempVector3;return Qe.scale(this.right,this._pupilDistande/2,e),e.elements},n._calculateLeftProjectionMatrix=function(){if(!this._useUserProjectionMatrix)if(this.orthographicProjection){var e=this.orthographicVerticalSize*this.leftAspectRatio*.5,t=.5*this.orthographicVerticalSize;je.createOrthogonal(-e,e,-t,t,this.nearPlane,this.farPlane,this._leftProjectionMatrix)}else je.createPerspective(3.1416*this.fieldOfView/180,this.leftAspectRatio,this.nearPlane,this.farPlane,this._rightProjectionMatrix);this._projectionMatrixModifyID+=.01/this.id},n._calculateRightProjectionMatrix=function(){if(!this._useUserProjectionMatrix)if(this.orthographicProjection){var e=this.orthographicVerticalSize*this.rightAspectRatio*.5,t=.5*this.orthographicVerticalSize;je.createOrthogonal(-e,e,t,t,this.nearPlane,this.farPlane,this._rightProjectionMatrix)}else je.createPerspective(3.1416*this.fieldOfView/180,this.rightAspectRatio,this.nearPlane,this.farPlane,this._rightProjectionMatrix);this._projectionMatrixModifyID+=.01/this.id},n._calculateProjectionMatrix=function(){if(!this._useUserProjectionMatrix)if(this.orthographicProjection){var e=this.orthographicVerticalSize*this.leftAspectRatio*.5,t=.5*this.orthographicVerticalSize,n=this.orthographicVerticalSize*this.rightAspectRatio*.5,i=.5*this.orthographicVerticalSize;je.createOrthogonal(-e,e,-t,t,this.nearPlane,this.farPlane,this._leftProjectionMatrix),je.createOrthogonal(-n,n,i,i,this.nearPlane,this.farPlane,this._rightProjectionMatrix)}else je.createPerspective(3.1416*this.fieldOfView/180,this.leftAspectRatio,this.nearPlane,this.farPlane,this._leftProjectionMatrix),je.createPerspective(3.1416*this.fieldOfView/180,this.rightAspectRatio,this.nearPlane,this.farPlane,this._rightProjectionMatrix);this._projectionMatrixModifyID+=.01/this.id},a(0,n,"leftNormalizedViewport",function(){if(!this._viewportExpressedInClipSpace){var e=this._leftViewport,t=this.renderTargetSize,n=t.width,i=t.height;this._leftNormalizedViewport.x=e.x/n,this._leftNormalizedViewport.y=e.y/i,this._leftNormalizedViewport.width=e.width/n,this._leftNormalizedViewport.height=e.height/i}return this._leftNormalizedViewport}),a(0,n,"rightViewport",function(){if(this._viewportExpressedInClipSpace){var e=this._rightNormalizedViewport,t=this.renderTargetSize,n=t.width,i=t.height;this._rightViewport.x=e.x*n,this._rightViewport.y=e.y*i,this._rightViewport.width=e.width*n,this._rightViewport.height=e.height*i}return this._rightViewport}),a(0,n,"viewport",null,function(e){if(null!=this.renderTarget&&(e.x<0||e.y<0||0==e.width||0==e.height))throw new Error("VRCamera: viewport size invalid.","value");this._viewportExpressedInClipSpace=!1,this._leftViewport=new Je(0,0,e.width/2,e.height),this._rightViewport=new Je(e.width/2,0,e.width/2,e.height),this._calculateProjectionMatrix()}),a(0,n,"leftAspectRatio",function(){if(0===this._leftAspectRatio){var e=this.leftViewport;return e.width/e.height}return this._leftAspectRatio}),a(0,n,"rightAspectRatio",function(){if(0===this._rightAspectRatio){var e=this.rightViewport;return e.width/e.height}return this._rightAspectRatio}),a(0,n,"aspectRatio",null,function(e){if(0>e)throw new Error("VRCamera: the aspect ratio has to be a positive real number.");this._leftAspectRatio=e,this._rightAspectRatio=e,this._calculateRightProjectionMatrix()}),a(0,n,"rightNormalizedViewport",function(){if(!this._viewportExpressedInClipSpace){var e=this._rightViewport,t=this.renderTargetSize,n=t.width,i=t.height;this._rightNormalizedViewport.x=e.x/n,this._rightNormalizedViewport.y=e.y/i,this._rightNormalizedViewport.width=e.width/n,this._rightNormalizedViewport.height=e.height/i}return this._rightNormalizedViewport}),a(0,n,"normalizedViewport",null,function(e){if(e.x<0||e.y<0||e.x+e.width>1||e.x+e.height>1)throw new Error("VRCamera: viewport size invalid.","value");this._viewportExpressedInClipSpace=!0,this._leftNormalizedViewport=new Je(0,0,e.width/2,e.height),this._rightNormalizedViewport=new Je(e.width/2,0,e.width/2,e.height),this._calculateProjectionMatrix()}),a(0,n,"leftViewport",function(){if(this._viewportExpressedInClipSpace){var e=this._leftNormalizedViewport,t=this.renderTargetSize,n=t.width,i=t.height;this._leftViewport.x=e.x*n,this._leftViewport.y=e.y*i,this._leftViewport.width=e.width*n,this._leftViewport.height=e.height*i}return this._leftViewport}),a(0,n,"needLeftViewport",function(){var e=this.leftNormalizedViewport;return 0===e.x&&0===e.y&&1===e.width&&1===e.height}),a(0,n,"needRightViewport",function(){var e=this.rightNormalizedViewport;return 0===e.x&&0===e.y&&1===e.width&&1===e.height}),a(0,n,"leftViewMatrix",function(){var e=this._calculatePupilOffset(),t=this._tempMatrix;this.transform.worldMatrix.cloneTo(t);var n=t.elements;return n[12]-=e[0],n[13]-=e[1],n[14]-=e[2],t.invert(this._leftViewMatrix),this._leftViewMatrix}),a(0,n,"rightViewMatrix",function(){var e=this._calculatePupilOffset(),t=this._tempMatrix;this.transform.worldMatrix.cloneTo(t);var n=t.elements;return n[12]+=e[0],n[13]+=e[1],n[14]+=e[2],t.invert(this._rightViewMatrix),this._rightViewMatrix}),a(0,n,"leftProjectionMatrix",function(){return this._leftProjectionMatrix}),a(0,n,"leftProjectionViewMatrix",function(){return je.multiply(this.leftProjectionMatrix,this.leftViewMatrix,this._leftProjectionViewMatrix),this._leftProjectionViewMatrix}),a(0,n,"rightProjectionMatrix",function(){return this._rightProjectionMatrix}),a(0,n,"rightProjectionViewMatrix",function(){return je.multiply(this.rightProjectionMatrix,this.rightViewMatrix,this._rightProjectionViewMatrix),this._rightProjectionViewMatrix}),t}(Vt),function(e){function t(e,n,i){this._long=NaN,this._width=NaN,this._height=NaN,void 0===e&&(e=1),void 0===n&&(n=1),void 0===i&&(i=1),t.__super.call(this),this._long=e,this._width=n,this._height=i,this.recreateResource(),this._loaded=!0;var r=this.positions;this._boundingBox=new ze(new Qe,new Qe),ze.createfromPoints(r,this._boundingBox),this._boundingSphere=new ke(new Qe,0),ke.createfromPoints(r,this._boundingSphere)}r(t,"laya.d3.resource.models.BoxMesh",e);var n=t.prototype;return n.recreateResource=function(){this.startCreate(),this._numberVertices=24,this._numberIndices=36;var e=new Uint16Array(this._numberIndices),t=Oe.vertexDeclaration,n=t.vertexStride/4,i=new Float32Array(this._numberVertices*n),r=this._long/2,a=this._width/2,s=0;i[s+0]=-r,i[s+1]=this._height,i[s+2]=-a,i[s+3]=0,i[s+4]=1,i[s+5]=0,i[s+6]=0,i[s+7]=0,s+=8,i[s+0]=r,i[s+1]=this._height,i[s+2]=-a,i[s+3]=0,i[s+4]=1,i[s+5]=0,i[s+6]=1,i[s+7]=0,s+=8,i[s+0]=r,i[s+1]=this._height,i[s+2]=a,i[s+3]=0,i[s+4]=1,i[s+5]=0,i[s+6]=1,i[s+7]=1,s+=8,i[s+0]=-r,i[s+1]=this._height,i[s+2]=a,i[s+3]=0,i[s+4]=1,i[s+5]=0,i[s+6]=0,i[s+7]=1,s+=8,i[s+0]=-r,i[s+1]=0,i[s+2]=-a,i[s+3]=0,i[s+4]=-1,i[s+5]=0,i[s+6]=1,i[s+7]=0,s+=8,i[s+0]=r,i[s+1]=0,i[s+2]=-a,i[s+3]=0,i[s+4]=-1,i[s+5]=0,i[s+6]=0,i[s+7]=0,s+=8,i[s+0]=r,i[s+1]=0,i[s+2]=a,i[s+3]=0,i[s+4]=-1,i[s+5]=0,i[s+6]=0,i[s+7]=1,s+=8,i[s+0]=-r,i[s+1]=0,i[s+2]=a,i[s+3]=0,i[s+4]=-1,i[s+5]=0,i[s+6]=1,i[s+7]=1,s+=8,i[s+0]=-r,i[s+1]=this._height,i[s+2]=-a,i[s+3]=-1,i[s+4]=0,i[s+5]=0,i[s+6]=0,i[s+7]=0,s+=8,i[s+0]=-r,i[s+1]=this._height,i[s+2]=a,i[s+3]=-1,i[s+4]=0,i[s+5]=0,i[s+6]=1,i[s+7]=0,s+=8,i[s+0]=-r,i[s+1]=0,i[s+2]=a,i[s+3]=-1,i[s+4]=0,i[s+5]=0,i[s+6]=1,i[s+7]=1,s+=8,i[s+0]=-r,i[s+1]=0,i[s+2]=-a,i[s+3]=-1,i[s+4]=0,i[s+5]=0,i[s+6]=0,i[s+7]=1,s+=8,i[s+0]=r,i[s+1]=this._height,i[s+2]=-a,i[s+3]=1,i[s+4]=0,i[s+5]=0,i[s+6]=1,i[s+7]=0,s+=8,i[s+0]=r,i[s+1]=this._height,i[s+2]=a,i[s+3]=1,i[s+4]=0,i[s+5]=0,i[s+6]=0,i[s+7]=0,s+=8,i[s+0]=r,i[s+1]=0,i[s+2]=a,i[s+3]=1,i[s+4]=0,i[s+5]=0,i[s+6]=0,i[s+7]=1,s+=8,i[s+0]=r,i[s+1]=0,i[s+2]=-a,i[s+3]=1,i[s+4]=0,i[s+5]=0,i[s+6]=1,i[s+7]=1,s+=8,i[s+0]=-r,i[s+1]=this._height,i[s+2]=a,i[s+3]=0,i[s+4]=0,i[s+5]=1,i[s+6]=0,i[s+7]=0,s+=8,i[s+0]=r,i[s+1]=this._height,i[s+2]=a,i[s+3]=0,i[s+4]=0,i[s+5]=1,i[s+6]=1,i[s+7]=0,s+=8,i[s+0]=r,i[s+1]=0,i[s+2]=a,i[s+3]=0,i[s+4]=0,i[s+5]=1,i[s+6]=1,i[s+7]=1,s+=8,i[s+0]=-r,i[s+1]=0,i[s+2]=a,i[s+3]=0,i[s+4]=0,i[s+5]=1,i[s+6]=0,i[s+7]=1,s+=8,i[s+0]=-r,i[s+1]=this._height,i[s+2]=-a,i[s+3]=0,i[s+4]=0,i[s+5]=-1,i[s+6]=1,i[s+7]=0,s+=8,i[s+0]=r,i[s+1]=this._height,i[s+2]=-a,i[s+3]=0,i[s+4]=0,i[s+5]=-1,i[s+6]=0,i[s+7]=0,s+=8,i[s+0]=r,i[s+1]=0,i[s+2]=-a,i[s+3]=0,i[s+4]=0,i[s+5]=-1,i[s+6]=0,i[s+7]=1,s+=8,i[s+0]=-r,i[s+1]=0,i[s+2]=-a,i[s+3]=0,i[s+4]=0,i[s+5]=-1,i[s+6]=1,i[s+7]=1;var o=0;e[o+0]=0,e[o+1]=1,e[o+2]=2,o+=3,e[o+0]=2,e[o+1]=3,e[o+2]=0,o+=3,e[o+0]=4,e[o+1]=7,e[o+2]=6,o+=3,e[o+0]=6,e[o+1]=5,e[o+2]=4,o+=3,e[o+0]=8,e[o+1]=9,e[o+2]=10,o+=3,e[o+0]=10,e[o+1]=11,e[o+2]=8,o+=3,e[o+0]=12,e[o+1]=15,e[o+2]=14,o+=3,e[o+0]=14,e[o+1]=13,e[o+2]=12,o+=3,e[o+0]=16,e[o+1]=17,e[o+2]=18,o+=3,e[o+0]=18,e[o+1]=19,e[o+2]=16,o+=3,e[o+0]=20,e[o+1]=23,e[o+2]=22,o+=3,e[o+0]=22,e[o+1]=21,e[o+2]=20,this._vertexBuffer=new Bt(t,this._numberVertices,35044,!0),this._indexBuffer=new Nt("ushort",this._numberIndices,35044,!0),this._vertexBuffer.setData(i),this._indexBuffer.setData(e),this.memorySize=2*(this._vertexBuffer.byteLength+this._indexBuffer.byteLength),this.completeCreate()},a(0,n,"long",function(){return this._long},function(e){this._long=e,this.recreateResource()}),a(0,n,"width",function(){return this._width},function(e){this._width=e,this.recreateResource()}),a(0,n,"height",function(){return this._height},function(e){this._height=e,this.recreateResource()}),t}(Gt),function(e){function t(e,n,i,r){this._radius=NaN,this._height=NaN,this._slices=0,this._stacks=0,void 0===e&&(e=10),void 0===n&&(n=10),void 0===i&&(i=8),void 0===r&&(r=8),t.__super.call(this),this._radius=e,this._height=n,this._stacks=i,this._slices=r,this.recreateResource(),this._loaded=!0;var a=this.positions;this._boundingBox=new ze(new Qe,new Qe),ze.createfromPoints(a,this._boundingBox),this._boundingSphere=new ke(new Qe,0),ke.createfromPoints(a,this._boundingSphere)}r(t,"laya.d3.resource.models.CylinderMesh",e);var n=t.prototype;return n.recreateResource=function(){this.startCreate(),this._numberVertices=(this._stacks+1+2)*(this._slices+1),this._numberIndices=2*(this._slices-1+this._stacks*this._slices)*3;for(var e=new Uint16Array(this._numberIndices),t=Oe.vertexDeclaration,n=t.vertexStride/4,i=new Float32Array(this._numberVertices*n),r=2*Math.PI/this._slices,a=0,s=.5,o=.5,l=.5,h=.5,u=.5,c=0,_=0,d=1,m=1,f=0,p=0,v=0,g=0;g<this._slices+1;g++){var T=Math.cos(a),x=Math.sin(a);a+=r,i[v++]=this._radius*T,i[v++]=this._radius*x,i[v++]=0,i[v++]=0,i[v++]=0,i[v++]=-1,i[v++]=l*T+s,i[v++]=l*x+o}for(g=2;g<this._slices+1;g++)e[f++]=0,e[f++]=g-1,e[f++]=g;p+=this._slices+1;for(var M=this._height/this._stacks,E=0,y=0;y<this._stacks+1;y++){for(g=0;g<this._slices+1;g++){var S=i[g*n],R=i[g*n+1];if(i[v++]=S,i[v++]=R,i[v++]=E,i[v++]=S,i[v++]=R,i[v++]=0,i[v++]=c+g*(d-c)/this._slices,i[v++]=m+y*(_-m)/this._stacks,y>0&&g>0){var A=p-1,I=p,C=p-(this._slices+1),V=p-(this._slices+1)-1;e[f++]=V,e[f++]=A,e[f++]=I,e[f++]=V,e[f++]=I,e[f++]=C}p++}E+=M}for(g=0;g<this._slices+1;g++)S=i[g*n],R=i[g*n+1],i[v++]=S,i[v++]=R,i[v++]=this._height,i[v++]=0,i[v++]=0,i[v++]=1,i[v++]=l*S/this._radius+h,i[v++]=l*R/this._radius+u;for(g=2;g<this._slices+1;g++)e[f++]=p,e[f++]=p+g,e[f++]=p+g-1;p+=this._slices+1,this._vertexBuffer=new Bt(t,this._numberVertices,35044,!0),this._indexBuffer=new Nt("ushort",this._numberIndices,35044,!0),this._vertexBuffer.setData(i),this._indexBuffer.setData(e),this.memorySize=2*(this._vertexBuffer.byteLength+this._indexBuffer.byteLength),this.completeCreate()},a(0,n,"radius",function(){return this._radius},function(e){this._radius=e,this.recreateResource()}),a(0,n,"slices",function(){return this._slices},function(e){this._slices=e,this.recreateResource()}),a(0,n,"stacks",function(){return this._stacks},function(e){this._stacks=e,this.recreateResource()}),t}(Gt),function(e){function t(e,n,i){this._radius=NaN,this._slices=0,this._stacks=0,void 0===e&&(e=10),void 0===n&&(n=8),void 0===i&&(i=8),t.__super.call(this),this._radius=e,this._stacks=n,this._slices=i,this.recreateResource(),this._loaded=!0;var r=this.positions;this._boundingBox=new ze(new Qe,new Qe),ze.createfromPoints(r,this._boundingBox),this._boundingSphere=new ke(new Qe,0),ke.createfromPoints(r,this._boundingSphere)}r(t,"laya.d3.resource.models.SphereMesh",e);var n=t.prototype;return n.recreateResource=function(){this.startCreate(),this._numberVertices=(this._stacks+1)*(this._slices+1),this._numberIndices=3*this._stacks*(this._slices+1)*2;for(var e=new Uint16Array(this._numberIndices),t=Oe.vertexDeclaration,n=t.vertexStride/4,i=new Float32Array(this._numberVertices*n),r=Math.PI/this._stacks,a=2*Math.PI/this._slices,s=0,o=0,l=0,h=0;h<this._stacks+1;h++)for(var u=Math.sin(h*r),c=Math.cos(h*r),_=0;_<this._slices+1;_++){var d=u*Math.sin(_*a),m=u*Math.cos(_*a);i[o+0]=d*this._radius,i[o+1]=c*this._radius,i[o+2]=m*this._radius,i[o+3]=d,i[o+4]=c,i[o+5]=m,i[o+6]=_/this._slices,i[o+7]=h/this._stacks,o+=n,h!=this._stacks-1&&(e[l++]=s+(this._slices+1),e[l++]=s,e[l++]=s+1,e[l++]=s+this._slices,e[l++]=s,e[l++]=s+(this._slices+1),s++)}this._vertexBuffer=new Bt(t,this._numberVertices,35044,!0),this._indexBuffer=new Nt("ushort",this._numberIndices,35044,!0),this._vertexBuffer.setData(i),this._indexBuffer.setData(e),this.memorySize=2*(this._vertexBuffer.byteLength+this._indexBuffer.byteLength),this.completeCreate()},a(0,n,"radius",function(){return this._radius},function(e){this._radius=e,this.recreateResource()}),a(0,n,"slices",function(){return this._slices},function(e){this._slices=e,this.recreateResource()}),a(0,n,"stacks",function(){return this._stacks},function(e){this._stacks=e,this.recreateResource()}),t}(Gt)}(window,document,Laya); |