!function(n,r,a){a.un,a.uns;var o=a.static,s=a.class,l=a.getset,h=a.__newvec,_=(laya.ani.AnimationContent,laya.ani.AnimationPlayer),u=(laya.ani.AnimationState,laya.ani.AnimationTemplet),c=laya.maths.Arith,d=laya.webgl.atlas.AtlasResourceManager,f=laya.webgl.shader.BaseShader,m=laya.utils.Browser,p=laya.webgl.utils.Buffer,v=laya.utils.Byte,E=(laya.ani.bone.canvasmesh.CacheAbleSkinMesh,laya.utils.ClassUtils),g=a.Config,D=(laya.events.Event,laya.events.EventDispatcher),T=laya.utils.Handler,S=laya.net.Loader,x=laya.net.LoaderManager,M=laya.maths.MathUtil,R=laya.display.Node,A=laya.renders.Render,I=(laya.renders.RenderContext,laya.renders.RenderSprite,laya.webgl.utils.RenderState2D),y=laya.resource.Resource,C=laya.utils.RunDriver,N=(laya.webgl.shader.Shader,laya.webgl.utils.ShaderCompile),O=laya.display.Sprite,w=laya.utils.Stat,V=laya.utils.StringKey,P=(laya.display.css.Style,laya.resource.Texture,laya.net.URL),L=laya.utils.Utils,b=laya.webgl.WebGL,F=laya.webgl.WebGLContext;laya.webgl.canvas.WebGLContext2D,a.interface("laya.d3.core.IClone"),a.interface("laya.d3.graphics.IVertex"),a.interface("laya.d3.core.render.IUpdate"),a.interface("laya.d3.core.scene.ITreeNode"),a.interface("laya.d3.core.render.IRenderable");var B=function(){function e(){}return s(e,"laya.d3.animation.AnimationClipParser01"),e.READ_DATA=function(){e._DATA.offset=e._reader.getUint32(),e._DATA.size=e._reader.getUint32()},e.READ_BLOCK=function(){for(var t=e._BLOCK.count=e._reader.getUint16(),n=e._BLOCK.blockStarts=[],i=e._BLOCK.blockLengths=[],r=0;r<t;r++)n.push(e._reader.getUint32()),i.push(e._reader.getUint32())},e.READ_STRINGS=function(){var t=e._reader.getUint32(),n=e._reader.getUint16(),i=e._reader.pos;e._reader.pos=t+e._DATA.offset;for(var r=0;r<n;r++)e._strings[r]=e._reader.readUTFString();e._reader.pos=i},e.parse=function(t,n){e._animationClip=t,e._reader=n,n.__getBuffer(),e.READ_DATA(),e.READ_BLOCK(),e.READ_STRINGS();for(var i=0,r=e._BLOCK.count;i<r;i++){var a=n.getUint16(),o=e._strings[a],s=e["READ_"+o];if(null==s)throw new Error("model file err,no this function:"+a+" "+o);s.call()}},e.READ_ANIMATIONS=function(){var t,n=0,i=0,r=e._reader,a=r.__getBuffer(),o=[],s=r.getUint8();for(o.length=s,n=0;n<s;n++)o[n]=r.getUint16();var l=[],h=r.getUint16();for(l.length=h,n=0;n<h;n++)l[n]=r.getFloat32();var _=e._animationClip;_.name=e._strings[r.getUint16()];var u=_._duration=r.getFloat32();_.islooping=!!r.getByte(),_._frameRate=r.getInt16();var c=r.getInt16(),d=_._nodes=new Array;d.length=c,(_._publicClipDatas=[]).length=c;var f=_._nodesMap={},m=0,p=0;for(n=0;n<c;n++){t=d[n]=new W;var v=r.getUint16(),E=t.path=[];for(E.length=v,i=0;i<v;i++)E[i]=e._strings[r.getUint16()];var g=E.join("/"),D=f[g];D||(f[g]=D=[]),D.push(t);var T=r.getInt16();-1!==T&&(t.componentType=e._strings[T]);var S=G._propertyIndexDic[e._strings[r.getUint16()]];if(null==S)throw new Error("AnimationClipParser01:unknown property name.");var x=S<4,M=!x||x&&""===E[0];t._cacheProperty=M,M?m++:p++,t.propertyNameID=S;var R=o[r.getUint8()];t.keyFrameWidth=R/4;var A=t.keyFrames=[],I=A.length=r.getUint16(),y=null,C=NaN;for(i=0;i<I;i++){var N=A[i]=new z;C=N.startTime=l[r.getUint16()];var O=r.pos;N.inTangent=new Float32Array(a.slice(O,O+R)),r.pos+=R,O=r.pos,N.outTangent=new Float32Array(a.slice(O,O+R)),r.pos+=R,O=r.pos,N.data=new Float32Array(a.slice(O,O+R)),r.pos+=R,y&&(y.next=N,y.duration=C-y.startTime),y=N}N.next=null,N.duration=u-C}var w=_._nodeToCachePropertyMap=new Int32Array(c),V=_._cachePropertyMap=new Int32Array(m),P=_._unCachePropertyMap=new Int32Array(p);for(m=p=0,n=0;n<c;n++)(t=d[n])._cacheProperty?(w[n]=m,V[m++]=n):P[p++]=n},e._animationClip=null,e._reader=null,e._strings=[],o(e,["_BLOCK",function(){return this._BLOCK={count:0}},"_DATA",function(){return this._DATA={offset:0,size:0}}]),e}(),U=function(){function e(){}return s(e,"laya.d3.animation.AnimationClipParser02"),e.READ_DATA=function(){e._DATA.offset=e._reader.getUint32(),e._DATA.size=e._reader.getUint32()},e.READ_BLOCK=function(){for(var t=e._BLOCK.count=e._reader.getUint16(),n=e._BLOCK.blockStarts=[],i=e._BLOCK.blockLengths=[],r=0;r<t;r++)n.push(e._reader.getUint32()),i.push(e._reader.getUint32())},e.READ_STRINGS=function(){var t=e._reader.getUint32(),n=e._reader.getUint16(),i=e._reader.pos;e._reader.pos=t+e._DATA.offset;for(var r=0;r<n;r++)e._strings[r]=e._reader.readUTFString();e._reader.pos=i},e.parse=function(t,n){e._animationClip=t,e._reader=n,n.__getBuffer(),e.READ_DATA(),e.READ_BLOCK(),e.READ_STRINGS();for(var i=0,r=e._BLOCK.count;i<r;i++){var a=n.getUint16(),o=e._strings[a],s=e["READ_"+o];if(null==s)throw new Error("model file err,no this function:"+a+" "+o);s.call()}},e.READ_ANIMATIONS=function(){var t,n=0,i=0,r=e._reader,a=r.__getBuffer(),o=[],s=r.getUint8();for(o.length=s,n=0;n<s;n++)o[n]=r.getUint16();var l=[],h=r.getUint16();for(l.length=h,n=0;n<h;n++)l[n]=r.getFloat32();var _=e._animationClip;_.name=e._strings[r.getUint16()];var u=_._duration=r.getFloat32();_.islooping=!!r.getByte(),_._frameRate=r.getInt16();var c=r.getInt16(),d=_._nodes=new Array;d.length=c,(_._publicClipDatas=[]).length=c;var f=_._nodesMap={},m=0,p=0;for(n=0;n<c;n++){t=d[n]=new W;var v=r.getUint16(),E=t.path=[];for(E.length=v,i=0;i<v;i++)E[i]=e._strings[r.getUint16()];var g=E.join("/"),D=f[g];D||(f[g]=D=[]),D.push(t);var T=r.getInt16();-1!==T&&(t.componentType=e._strings[T]);var S=G._propertyIndexDic[e._strings[r.getUint16()]];if(null==S)throw new Error("AnimationClipParser02:unknown property name.");var x=S<4,M=!x||x&&""===E[0];t._cacheProperty=M,M?m++:p++,t.propertyNameID=S;var R=o[r.getUint8()];t.keyFrameWidth=R/4;var A=t.keyFrames=[],I=A.length=r.getUint16(),y=null,C=NaN;for(i=0;i<I;i++){var N=A[i]=new z;C=N.startTime=l[r.getUint16()];var O=r.pos;N.inTangent=new Float32Array(a.slice(O,O+R)),r.pos+=R,O=r.pos,N.outTangent=new Float32Array(a.slice(O,O+R)),r.pos+=R,O=r.pos,N.data=new Float32Array(a.slice(O,O+R)),r.pos+=R,y&&(y.next=N,y.duration=C-y.startTime),y=N}N.next=null,N.duration=u-C}var w=r.getUint16();for(n=0;n<w;n++){var V=new H;V.time=r.getFloat32(),V.eventName=e._strings[r.getUint16()];var P,L=r.getUint16();for(L>0&&(V.params=P=[]),i=0;i<L;i++)switch(r.getByte()){case 0:P.push(!!r.getByte());break;case 1:P.push(r.getInt32());break;case 2:P.push(r.getFloat32());break;case 3:P.push(e._strings[r.getUint16()]);break;default:throw new Error("unknown type.")}_.addEvent(V)}var b=_._nodeToCachePropertyMap=new Int32Array(c),F=_._cachePropertyMap=new Int32Array(m),B=_._unCachePropertyMap=new Int32Array(p);for(m=p=0,n=0;n<c;n++)(t=d[n])._cacheProperty?(b[n]=m,F[m++]=n):B[p++]=n},e._animationClip=null,e._reader=null,e._strings=[],o(e,["_BLOCK",function(){return this._BLOCK={count:0}},"_DATA",function(){return this._DATA={offset:0,size:0}}]),e}(),H=function(){function e(){this.time=NaN,this.eventName=null,this.params=null}return s(e,"laya.d3.animation.AnimationEvent"),e}(),G=function(){function e(){this._childs=[],this.transform=new tn(this)}s(e,"laya.d3.animation.AnimationNode");var t=e.prototype;return a.imps(t,{"laya.d3.core.IClone":!0}),t.addChild=function(e){e._parent=this,e.transform.setParent(this.transform),this._childs.push(e)},t.removeChild=function(e){var t=this._childs.indexOf(e);-1!==t&&this._childs.splice(t,1)},t.getChildByName=function(e){for(var t=0,n=this._childs.length;t<n;t++){var i=this._childs[t];if(i.name===e)return i}return null},t.getChildByIndex=function(e){return this._childs[e]},t.getChildCount=function(){return this._childs.length},t.cloneTo=function(e){var t=e;t.name=this.name;for(var n=0,i=this._childs.length;n<i;n++){var r=this._childs[n],a=r.clone();t.addChild(a);var o=r.transform,s=a.transform;s.setLocalPosition(o.getLocalPosition()),s.setLocalRotation(o.getLocalRotation()),s.setLocalScale(o.getLocalScale()),s._localRotationEuler=o._localRotationEuler,s._setWorldMatrixIgnoreUpdate(o.getWorldMatrix())}},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},e.__init__=function(){e.registerAnimationNodeProperty("localPosition",e._getLocalPosition,e._setLocalPosition),e.registerAnimationNodeProperty("localRotation",e._getLocalRotation,e._setLocalRotation),e.registerAnimationNodeProperty("localScale",e._getLocalScale,e._setLocalScale),e.registerAnimationNodeProperty("localRotationEuler",e._getLocalRotationEuler,e._setLocalRotationEuler),e.registerAnimationNodeProperty("particleRender.sharedMaterial.tintColor",e._getParticleRenderSharedMaterialTintColor,e._setParticleRenderSharedMaterialTintColor),e.registerAnimationNodeProperty("meshRender.sharedMaterial.tilingOffset",e._getMeshRenderSharedMaterialTilingOffset,e._setMeshRenderSharedMaterialTilingOffset),e.registerAnimationNodeProperty("meshRender.sharedMaterial.albedoColor",e._getMeshRenderSharedMaterialAlbedo,e._setMeshRenderSharedMaterialAlbedo),e.registerAnimationNodeProperty("skinnedMeshRender.sharedMaterial.tilingOffset",e._getSkinnedMeshRenderSharedMaterialTilingOffset,e._setSkinnedMeshRenderSharedMaterialTilingOffset),e.registerAnimationNodeProperty("skinnedMeshRender.sharedMaterial.albedoColor",e._getSkinnedMeshRenderSharedMaterialAlbedo,e._setSkinnedMeshRenderSharedMaterialAlbedo),e.registerAnimationNodeProperty("meshRender.sharedMaterial.albedo",e._getMeshRenderSharedMaterialAlbedo,e._setMeshRenderSharedMaterialAlbedo),e.registerAnimationNodeProperty("skinnedMeshRender.sharedMaterial.albedo",e._getSkinnedMeshRenderSharedMaterialAlbedo,e._setSkinnedMeshRenderSharedMaterialAlbedo)},e.registerAnimationNodeProperty=function(t,n,i){if(e._propertyIndexDic[t])throw new Error("AnimationNode: this propertyName has registered.");e._propertyIndexDic[t]=e._propertyIDCounter,e._propertyGetFuncs[e._propertyIDCounter]=n,e._propertySetFuncs[e._propertyIDCounter]=i,e._propertyIDCounter++},e._getLocalPosition=function(e,t){return e?e.transform.getLocalPosition():t._transform.localPosition.elements},e._setLocalPosition=function(e,t,n){if(e)e.transform.setLocalPosition(n);else{var i=t._transform,r=i.localPosition;r.elements=n,i.localPosition=r}},e._getLocalRotation=function(e,t){return e?e.transform.getLocalRotation():t._transform.localRotation.elements},e._setLocalRotation=function(e,t,n){if(e)e.transform.setLocalRotation(n);else{var i=t._transform,r=i.localRotation;r.elements=n,i.localRotation=r}},e._getLocalScale=function(e,t){return e?e.transform.getLocalScale():t._transform.localScale.elements},e._setLocalScale=function(e,t,n){if(e)e.transform.setLocalScale(n);else{var i=t._transform,r=i.localScale;r.elements=n,i.localScale=r}},e._getLocalRotationEuler=function(e,t){return e?e.transform.getLocalRotationEuler():t._transform.localRotationEuler.elements},e._setLocalRotationEuler=function(e,t,n){if(e)e.transform.setLocalRotationEuler(n);else{var i=t._transform,r=i.localRotationEuler;r.elements=n,i.localRotationEuler=r}},e._getMeshRenderSharedMaterialTilingOffset=function(e,t){if(e){var n=e.transform._entity;return n?n.owner.meshRender.sharedMaterial.tilingOffset.elements:null}return t.meshRender.sharedMaterial.tilingOffset.elements},e._setMeshRenderSharedMaterialTilingOffset=function(e,t,n){var i,r;if(e){var a=e.transform._entity;a&&((r=(i=a.owner.meshRender.material).tilingOffset).elements=n,i.tilingOffset=r)}else(r=(i=t.meshRender.material).tilingOffset).elements=n,i.tilingOffset=r},e._getMeshRenderSharedMaterialAlbedo=function(e,t){if(e){var n=e.transform._entity;return n?n.owner.meshRender.sharedMaterial.albedoColor.elements:null}return t.meshRender.sharedMaterial.albedoColor.elements},e._setMeshRenderSharedMaterialAlbedo=function(e,t,n){var i,r;if(e){var a=e.transform._entity;a&&((r=(i=a.owner.meshRender.material).albedoColor).elements=n,i.albedoColor=r)}else(r=(i=t.meshRender.material).albedoColor).elements=n,i.albedoColor=r},e._getSkinnedMeshRenderSharedMaterialTilingOffset=function(e,t){if(e){var n=e.transform._entity;return n?n.owner.skinnedMeshRender.sharedMaterial.tilingOffset.elements:null}return t.skinnedMeshRender.sharedMaterial.tilingOffset.elements},e._setSkinnedMeshRenderSharedMaterialTilingOffset=function(e,t,n){var i,r;if(e){var a=e.transform._entity;a&&((r=(i=a.owner.skinnedMeshRender.material).tilingOffset).elements=n,i.tilingOffset=r)}else(r=(i=t.skinnedMeshRender.material).tilingOffset).elements=n,i.tilingOffset=r},e._getSkinnedMeshRenderSharedMaterialAlbedo=function(e,t){if(e){var n=e.transform._entity;return n?n.owner.skinnedMeshRender.sharedMaterial.albedoColor.elements:null}return t.skinnedMeshRender.sharedMaterial.albedoColor.elements},e._setSkinnedMeshRenderSharedMaterialAlbedo=function(e,t,n){var i,r;if(e){var a=e.transform._entity;a&&((r=(i=a.owner.skinnedMeshRender.material).albedoColor).elements=n,i.albedoColor=r)}else(r=(i=t.skinnedMeshRender.material).albedoColor).elements=n,i.albedoColor=r},e._getParticleRenderSharedMaterialTintColor=function(e,t){if(e){var n=e.transform._entity;return n?n.owner.particleRender.sharedMaterial.tintColor.elements:null}return t.particleRender.sharedMaterial.tintColor.elements},e._setParticleRenderSharedMaterialTintColor=function(e,t,n){var i,r;if(e){var a=e.transform._entity;a&&((r=(i=a.owner.particleRender.material).tintColor).elements=n,i.tintColor=r)}else(r=(i=t.particleRender.material).tintColor).elements=n,i.tintColor=r},e._propertyIDCounter=0,e._propertyIndexDic={},e._propertySetFuncs=[],e._propertyGetFuncs=[],e}(),z=function(){function e(){this.startTime=NaN,this.inTangent=null,this.outTangent=null,this.data=null,this.duration=NaN,this.next=null}return s(e,"laya.d3.animation.Keyframe"),e}(),W=function(){function e(){this._cacheProperty=!1,this.path=null,this.componentType=null,this.propertyNameID=0,this.keyFrameWidth=0,this.defaultData=null,this.keyFrames=null}return s(e,"laya.d3.animation.KeyframeNode"),e}(),k=function(){function e(){this._tempVector30=new bt,this._tempVector31=new bt,this._tempVector32=new bt,this._a=new bt,this._b=new bt,this._c=new bt,this._d=new bt}s(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),bt.scale(e,2,this._a),bt.scale(n,2,this._tempVector30),bt.subtract(this._a,this._tempVector30,this._a),bt.add(this._a,t,this._a),bt.add(this._a,i,this._a),bt.scale(n,3,this._b),bt.scale(e,3,this._tempVector30),bt.subtract(this._b,this._tempVector30,this._b),bt.subtract(this._b,i,this._b),bt.scale(t,2,this._tempVector30),bt.subtract(this._b,this._tempVector30,this._b)},t.Slerp=function(e,t){bt.scale(this._a,e*e*e,this._tempVector30),bt.scale(this._b,e*e,this._tempVector31),bt.scale(this._c,e,this._tempVector32),bt.add(this._tempVector30,this._tempVector31,t),bt.add(t,this._tempVector32,t),bt.add(t,this._d,t)},e}(),X=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}s(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},l(0,t,"width",function(){return this._w}),l(0,t,"height",function(){return this._h}),l(0,t,"maxHeight",function(){return this._maxHeight}),l(0,t,"minHeight",function(){return this._minHeight}),e.creatFromMesh=function(t,n,i,r){for(var a=[],o=[],s=t.getSubMeshCount(),l=0;l<s;l++){for(var h=t.getSubMesh(l),_=h._getVertexBuffer(),u=_.getData(),c=[],d=0;d<u.length;d+=_.vertexDeclaration.vertexStride/4){var f=new bt(u[d+0],u[d+1],u[d+2]);c.push(f)}a.push(c);var m=h._getIndexBuffer();o.push(m.getData())}var p=t.boundingBox,v=p.min.x,E=p.min.z,g=p.max.x,D=p.max.z,T=p.min.y,S=p.max.y,x=g-v,M=D-E,R=r.elements[0]=x/(n-1),A=r.elements[1]=M/(i-1),I=new e(n,i,T,S),y=e._tempRay,C=y.direction.elements;C[0]=0,C[1]=-1,C[2]=0;var N=S+.1;y.origin.elements[1]=N;for(var O=0;O<i;O++){var w=E+O*A;I._datas[O]=[];for(var V=0;V<n;V++){var P=v+V*R,L=y.origin.elements;L[0]=P,L[2]=w;var b=e._getPosition(y,a,o);I._datas[O][V]=b===Number.MAX_VALUE?NaN:N-b}}return I},e.createFromImage=function(t,n,i){for(var r=t.width,a=t.height,o=new e(r,a,n,i),s=(i-n)/254,l=t.getPixels(),h=0,_=0;_<a;_++)for(var u=o._datas[_]=[],c=0;c<r;c++){var d=l[h++],f=l[h++],m=l[h++],p=l[h++];u[c]=255==d&&255==f&&255==m&&255==p?NaN:(d+f+m)/3*s+n}return o},e._getPosition=function(e,t,n){for(var i=Number.MAX_VALUE,r=0;r<t.length;r++)for(var a=t[r],o=n[r],s=0;s<o.length;s+=3){var l=a[o[s+0]],h=a[o[s+1]],_=a[o[s+2]],u=qt.rayIntersectsTriangle(e,l,h,_);!isNaN(u)&&u<i&&(i=u)}return i},o(e,["_tempRay",function(){return this._tempRay=new Pt(new bt,new bt)}]),e}(),Z=function(){function e(){this._visible=!0,this._nonRigidbodyOffset=0,this._colliders=[]}s(e,"laya.d3.core.Layer");var t=e.prototype;return t._binarySearchIndex=function(){for(var t=0,n=e._collsionTestList.length-1,i=0;t<=n;){i=Math.floor((t+n)/2);var r=e._collsionTestList[i];if(r==this._number)return i;r>this._number?n=i-1:t=i+1}return t},t._addCollider=function(t){0===this._colliders.length&&e._collsionTestList.splice(this._binarySearchIndex(),0,this._number),t._isRigidbody?(this._colliders.unshift(t),this._nonRigidbodyOffset++):this._colliders.push(t)},t._removeCollider=function(t){var n=this._colliders.indexOf(t);n<this._nonRigidbodyOffset&&this._nonRigidbodyOffset--,this._colliders.splice(n,1),0===this._colliders.length&&e._collsionTestList.splice(e._collsionTestList.indexOf(this._number),1)},l(0,t,"number",function(){return this._number}),l(0,t,"visible",function(){return this._visible},function(t){this._visible=t,e._visibleLayers=t?e._visibleLayers|this.mask:e._visibleLayers&~this.mask}),l(0,t,"mask",function(){return this._mask}),l(1,e,"visibleLayers",function(){return e._visibleLayers},function(t){e._visibleLayers=t;for(var n=0,i=e._layerList.length;n<i;n++){var r=e._layerList[n];r._visible=0!=(r._mask&e._visibleLayers)}}),e.__init__=function(){e._layerList.length=31;for(var t=0;t<31;t++){var n=new e;e._layerList[t]=n,0===t?(n.name="Default Layer",n.visible=!0):(n.name="Layer-"+t,n.visible=!1),n._number=t,n._mask=Math.pow(2,t)}e.currentCreationLayer=e._layerList[0]},e.getLayerByNumber=function(t){if(t<0||t>30)throw new Error("无法返回指定Layer，该number超出范围！");return e._layerList[t]},e.getLayerByName=function(t){for(var n=0;n<31;n++)if(e._layerList[n].name===t)return e._layerList[n];throw new Error("无法返回指定Layer,该name不存在")},e.isVisible=function(t){return 0!=(t&e._currentCameraCullingMask&e._visibleLayers)},e._layerList=[],e._visibleLayers=2147483647,e._collsionTestList=[],e._currentCameraCullingMask=2147483647,e.maxCount=31,e.currentCreationLayer=null,e}(),Y=function(){function e(e,t,n){this._time=NaN,this._minCount=0,this._maxCount=0,this._time=e,this._minCount=t,this._maxCount=n}s(e,"laya.d3.core.particleShuriKen.module.Burst");var t=e.prototype;return a.imps(t,{"laya.d3.core.IClone":!0}),t.cloneTo=function(e){var t=e;t._time=this._time,t._minCount=this._minCount,t._maxCount=this._maxCount},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},l(0,t,"time",function(){return this._time}),l(0,t,"minCount",function(){return this._minCount}),l(0,t,"maxCount",function(){return this._maxCount}),e}(),j=function(){function e(e){this._color=null,this.enbale=!1,this._color=e}s(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;switch(this._color.type){case 0:e=$.createByConstant(this._color.constant.clone());break;case 1:e=$.createByGradient(this._color.gradient.clone());break;case 2:e=$.createByRandomTwoConstant(this._color.constantMin.clone(),this._color.constantMax.clone());break;case 3:e=$.createByRandomTwoGradient(this._color.gradientMin.clone(),this._color.gradientMax.clone())}var t=new this.constructor(e);return t.enbale=this.enbale,t},l(0,t,"color",function(){return this._color}),e}(),K=function(){function e(){this._destroyed=!1,this._emissionRate=0,this._bursts=null,this.enbale=!1,this._destroyed=!1,this.emissionRate=10,this._bursts=[]}s(e,"laya.d3.core.particleShuriKen.module.Emission");var t=e.prototype;return a.imps(t,{"laya.d3.core.IClone":!0,"laya.resource.IDestroy":!0}),t._destroy=function(){this._bursts=null,this._destroyed=!0},t.getBurstsCount=function(){return this._bursts.length},t.getBurstByIndex=function(e){return this._bursts[e]},t.addBurst=function(e){var t=this._bursts.length;if(t>0)for(var n=0;n<t;n++)this._bursts[n].time>e.time&&this._bursts.splice(n,0,e);this._bursts.push(e)},t.removeBurst=function(e){var t=this._bursts.indexOf(e);-1!==t&&this._bursts.splice(t,1)},t.removeBurstByIndex=function(e){this._bursts.splice(e,1)},t.clearBurst=function(){this._bursts.length=0},t.cloneTo=function(e){var t=e,n=t._bursts;n.length=this._bursts.length;for(var i=0,r=this._bursts.length;i<r;i++){var a=n[i];a?this._bursts[i].cloneTo(a):n[i]=this._bursts[i].clone()}t._emissionRate=this._emissionRate,t.enbale=this.enbale},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},l(0,t,"destroyed",function(){return this._destroyed}),l(0,t,"emissionRate",function(){return this._emissionRate},function(e){if(e<0)throw new Error("ParticleBaseShape:emissionRate value must large or equal than 0.");this._emissionRate=e}),e}(),q=function(){function e(){this._type=0,this._constant=0,this._overTime=null,this._constantMin=0,this._constantMax=0,this._overTimeMin=null,this._overTimeMax=null}s(e,"laya.d3.core.particleShuriKen.module.FrameOverTime");var t=e.prototype;return a.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},l(0,t,"frameOverTimeData",function(){return this._overTime}),l(0,t,"constant",function(){return this._constant}),l(0,t,"type",function(){return this._type}),l(0,t,"frameOverTimeDataMin",function(){return this._overTimeMin}),l(0,t,"constantMin",function(){return this._constantMin}),l(0,t,"frameOverTimeDataMax",function(){return this._overTimeMax}),l(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}(),Q=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._gradientW=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,this._gradientWMin=null,this._gradientWMax=null}s(e,"laya.d3.core.particleShuriKen.module.GradientAngularVelocity");var t=e.prototype;return a.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},l(0,t,"gradientZ",function(){return this._gradientZ}),l(0,t,"constant",function(){return this._constant}),l(0,t,"gradient",function(){return this._gradient}),l(0,t,"separateAxes",function(){return this._separateAxes}),l(0,t,"type",function(){return this._type}),l(0,t,"constantSeparate",function(){return this._constantSeparate}),l(0,t,"gradientX",function(){return this._gradientX}),l(0,t,"gradientY",function(){return this._gradientY}),l(0,t,"gradientW",function(){return this._gradientW}),l(0,t,"gradientMin",function(){return this._gradientMin}),l(0,t,"constantMin",function(){return this._constantMin}),l(0,t,"gradientMax",function(){return this._gradientMax}),l(0,t,"constantMax",function(){return this._constantMax}),l(0,t,"gradientWMin",function(){return this._gradientWMin}),l(0,t,"constantMinSeparate",function(){return this._constantMinSeparate}),l(0,t,"constantMaxSeparate",function(){return this._constantMaxSeparate}),l(0,t,"gradientXMin",function(){return this._gradientXMin}),l(0,t,"gradientXMax",function(){return this._gradientXMax}),l(0,t,"gradientWMax",function(){return this._gradientWMax}),l(0,t,"gradientYMin",function(){return this._gradientYMin}),l(0,t,"gradientYMax",function(){return this._gradientYMax}),l(0,t,"gradientZMin",function(){return this._gradientZMin}),l(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,r){var a=new e;return a._type=1,a._separateAxes=!0,a._gradientX=t,a._gradientY=n,a._gradientZ=i,a._gradientW=r,a},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,o,s,l){var h=new e;return h._type=3,h._separateAxes=!0,h._gradientXMin=t,h._gradientXMax=n,h._gradientYMin=i,h._gradientYMax=r,h._gradientZMin=a,h._gradientZMax=o,h._gradientWMin=s,h._gradientWMax=l,h},e}(),$=function(){function e(){this._type=0,this._constant=null,this._constantMin=null,this._constantMax=null,this._gradient=null,this._gradientMin=null,this._gradientMax=null}s(e,"laya.d3.core.particleShuriKen.module.GradientColor");var t=e.prototype;return a.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},l(0,t,"gradient",function(){return this._gradient}),l(0,t,"constant",function(){return this._constant}),l(0,t,"type",function(){return this._type}),l(0,t,"gradientMin",function(){return this._gradientMin}),l(0,t,"constantMin",function(){return this._constantMin}),l(0,t,"gradientMax",function(){return this._gradientMax}),l(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}(),J=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)}s(e,"laya.d3.core.particleShuriKen.module.GradientDataColor");var t=e.prototype;return a.imps(t,{"laya.d3.core.IClone":!0}),t.addAlpha=function(e,t){this._alphaCurrentLength<8?(6===this._alphaCurrentLength&&1!==e&&(e=1,console.log("GradientDataColor warning:the forth key is  be force set to 1.")),this._alphaElements[this._alphaCurrentLength++]=e,this._alphaElements[this._alphaCurrentLength++]=t):console.log("GradientDataColor warning:data count must lessEqual than 4")},t.addRGB=function(e,t){this._rgbCurrentLength<16?(12===this._rgbCurrentLength&&1!==e&&(e=1,console.log("GradientDataColor warning:the forth key is  be force set to 1.")),this._rgbElements[this._rgbCurrentLength++]=e,this._rgbElements[this._rgbCurrentLength++]=t.x,this._rgbElements[this._rgbCurrentLength++]=t.y,this._rgbElements[this._rgbCurrentLength++]=t.z):console.log("GradientDataColor warning:data count must lessEqual than 4")},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;n<i;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;n<i;n++)a[n]=this._rgbElements[n]},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},l(0,t,"alphaGradientCount",function(){return this._alphaCurrentLength/2}),l(0,t,"rgbGradientCount",function(){return this._rgbCurrentLength/4}),e}(),ee=function(){function e(){this._currentLength=0,this._elements=null,this._elements=new Float32Array(8)}s(e,"laya.d3.core.particleShuriKen.module.GradientDataInt");var t=e.prototype;return a.imps(t,{"laya.d3.core.IClone":!0}),t.add=function(e,t){this._currentLength<8?(6===this._currentLength&&1!==e&&(e=1,console.log("Warning:the forth key is  be force set to 1.")),this._elements[this._currentLength++]=e,this._elements[this._currentLength++]=t):console.log("Warning:data count must lessEqual than 4")},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;i<r;i++)n[i]=this._elements[i]},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},l(0,t,"gradientCount",function(){return this._currentLength/2}),e}(),te=function(){function e(){this._currentLength=0,this._elements=null,this._elements=new Float32Array(8)}s(e,"laya.d3.core.particleShuriKen.module.GradientDataNumber");var t=e.prototype;return a.imps(t,{"laya.d3.core.IClone":!0}),t.add=function(e,t){this._currentLength<8?(6===this._currentLength&&1!==e&&(e=1,console.log("GradientDataNumber warning:the forth key is  be force set to 1.")),this._elements[this._currentLength++]=e,this._elements[this._currentLength++]=t):console.log("GradientDataNumber warning:data count must lessEqual than 4")},t.getKeyByIndex=function(e){return this._elements[2*e]},t.getValueByIndex=function(e){return this._elements[2*e+1]},t.getAverageValue=function(){for(var e=0,t=this._currentLength-2;e<t;e+=2)this._elements[e+1],this._elements[e+3],this._elements[e+2],this._elements[e];return 0},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;i<r;i++)n[i]=this._elements[i]},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},l(0,t,"gradientCount",function(){return this._currentLength/2}),e}(),ne=(function(){function e(){this._currentLength=0,this._elements=null,this._elements=new Float32Array(12)}s(e,"laya.d3.core.particleShuriKen.module.GradientDataVector2");var t=e.prototype;a.imps(t,{"laya.d3.core.IClone":!0}),t.add=function(e,t){this._currentLength<8?(6===this._currentLength&&1!==e&&(e=1,console.log("GradientDataVector2 warning:the forth key is  be force set to 1.")),this._elements[this._currentLength++]=e,this._elements[this._currentLength++]=t.x,this._elements[this._currentLength++]=t.y):console.log("GradientDataVector2 warning:data count must lessEqual than 4")},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;i<r;i++)n[i]=this._elements[i]},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},l(0,t,"gradientCount",function(){return this._currentLength/3})}(),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}s(e,"laya.d3.core.particleShuriKen.module.GradientSize");var t=e.prototype;return a.imps(t,{"laya.d3.core.IClone":!0}),t.getMaxSizeInGradient=function(){var e=0,t=0,n=-Number.MAX_VALUE;switch(this._type){case 0:if(this._separateAxes){for(e=0,t=this._gradientX.gradientCount;e<t;e++)n=Math.max(n,this._gradientX.getValueByIndex(e));for(e=0,t=this._gradientY.gradientCount;e<t;e++)n=Math.max(n,this._gradientY.getValueByIndex(e))}else for(e=0,t=this._gradient.gradientCount;e<t;e++)n=Math.max(n,this._gradient.getValueByIndex(e));break;case 1:this._separateAxes?(n=Math.max(this._constantMinSeparate.x,this._constantMaxSeparate.x),n=Math.max(n,this._constantMinSeparate.y),n=Math.max(n,this._constantMaxSeparate.y)):n=Math.max(this._constantMin,this._constantMax);break;case 2:if(this._separateAxes){for(e=0,t=this._gradientXMin.gradientCount;e<t;e++)n=Math.max(n,this._gradientXMin.getValueByIndex(e));for(e=0,t=this._gradientXMax.gradientCount;e<t;e++)n=Math.max(n,this._gradientXMax.getValueByIndex(e));for(e=0,t=this._gradientYMin.gradientCount;e<t;e++)n=Math.max(n,this._gradientYMin.getValueByIndex(e));for(e=0,t=this._gradientZMax.gradientCount;e<t;e++)n=Math.max(n,this._gradientZMax.getValueByIndex(e))}else{for(e=0,t=this._gradientMin.gradientCount;e<t;e++)n=Math.max(n,this._gradientMin.getValueByIndex(e));for(e=0,t=this._gradientMax.gradientCount;e<t;e++)n=Math.max(n,this._gradientMax.getValueByIndex(e))}}return n},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},l(0,t,"gradientZ",function(){return this._gradientZ}),l(0,t,"gradient",function(){return this._gradient}),l(0,t,"separateAxes",function(){return this._separateAxes}),l(0,t,"type",function(){return this._type}),l(0,t,"gradientMin",function(){return this._gradientMin}),l(0,t,"constantMin",function(){return this._constantMin}),l(0,t,"gradientX",function(){return this._gradientX}),l(0,t,"gradientY",function(){return this._gradientY}),l(0,t,"gradientMax",function(){return this._gradientMax}),l(0,t,"constantMax",function(){return this._constantMax}),l(0,t,"constantMinSeparate",function(){return this._constantMinSeparate}),l(0,t,"constantMaxSeparate",function(){return this._constantMaxSeparate}),l(0,t,"gradientXMin",function(){return this._gradientXMin}),l(0,t,"gradientXMax",function(){return this._gradientXMax}),l(0,t,"gradientYMin",function(){return this._gradientYMin}),l(0,t,"gradientYMax",function(){return this._gradientYMax}),l(0,t,"gradientZMin",function(){return this._gradientZMin}),l(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,o){var s=new e;return s._type=2,s._separateAxes=!0,s._gradientXMin=t,s._gradientXMax=n,s._gradientYMin=i,s._gradientYMax=r,s._gradientZMin=a,s._gradientZMax=o,s},e}()),ie=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}s(e,"laya.d3.core.particleShuriKen.module.GradientVelocity");var t=e.prototype;return a.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},l(0,t,"gradientZ",function(){return this._gradientZ}),l(0,t,"constant",function(){return this._constant}),l(0,t,"type",function(){return this._type}),l(0,t,"gradientXMax",function(){return this._gradientXMax}),l(0,t,"constantMin",function(){return this._constantMin}),l(0,t,"gradientX",function(){return this._gradientX}),l(0,t,"gradientY",function(){return this._gradientY}),l(0,t,"gradientXMin",function(){return this._gradientXMin}),l(0,t,"constantMax",function(){return this._constantMax}),l(0,t,"gradientYMin",function(){return this._gradientYMin}),l(0,t,"gradientYMax",function(){return this._gradientYMax}),l(0,t,"gradientZMin",function(){return this._gradientZMin}),l(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,o){var s=new e;return s._type=3,s._gradientXMin=t,s._gradientXMax=n,s._gradientYMin=i,s._gradientYMax=r,s._gradientZMin=a,s._gradientZMax=o,s},e}(),re=function(){function e(e){this._angularVelocity=null,this.enbale=!1,this._angularVelocity=e}s(e,"laya.d3.core.particleShuriKen.module.RotationOverLifetime");var t=e.prototype;return a.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;switch(this._angularVelocity.type){case 0:e=this._angularVelocity.separateAxes?Q.createByConstantSeparate(this._angularVelocity.constantSeparate.clone()):Q.createByConstant(this._angularVelocity.constant);break;case 1:e=this._angularVelocity.separateAxes?Q.createByGradientSeparate(this._angularVelocity.gradientX.clone(),this._angularVelocity.gradientY.clone(),this._angularVelocity.gradientZ.clone(),this._angularVelocity.gradientW.clone()):Q.createByGradient(this._angularVelocity.gradient.clone());break;case 2:e=this._angularVelocity.separateAxes?Q.createByRandomTwoConstantSeparate(this._angularVelocity.constantMinSeparate.clone(),this._angularVelocity.constantMaxSeparate.clone()):Q.createByRandomTwoConstant(this._angularVelocity.constantMin,this._angularVelocity.constantMax);break;case 3:e=this._angularVelocity.separateAxes?Q.createByRandomTwoGradientSeparate(this._angularVelocity.gradientXMin.clone(),this._angularVelocity.gradientYMin.clone(),this._angularVelocity.gradientZMin.clone(),this._angularVelocity.gradientWMin.clone(),this._angularVelocity.gradientXMax.clone(),this._angularVelocity.gradientYMax.clone(),this._angularVelocity.gradientZMax.clone(),this._angularVelocity.gradientWMax.clone()):Q.createByRandomTwoGradient(this._angularVelocity.gradientMin.clone(),this._angularVelocity.gradientMax.clone())}var t=new this.constructor(e);return t.enbale=this.enbale,t},l(0,t,"angularVelocity",function(){return this._angularVelocity}),e}(),ae=function(){function e(){this.enable=!1,this.randomDirection=!1}s(e,"laya.d3.core.particleShuriKen.module.shape.BaseShape");var t=e.prototype;return a.imps(t,{"laya.d3.core.IClone":!0}),t._getShapeBoundBox=function(e){throw new Error("BaseShape: must override it.")},t._getSpeedBoundBox=function(e){throw new Error("BaseShape: must override it.")},t.generatePositionAndDirection=function(e,t,n,i){throw new Error("BaseShape: must override it.")},t._calculateProceduralBounds=function(e,t,n){this._getShapeBoundBox(e);var i=e.min,r=e.max;bt.multiply(i,t,i),bt.multiply(r,t,r);var a=new xt(new bt,new bt);this.randomDirection?(a.min=new bt(-1,-1,-1),a.max=new bt(1,1,1)):this._getSpeedBoundBox(a);var o=new xt(new bt,new bt),s=o.min,l=o.max;bt.scale(a.min,n.y,s),bt.scale(a.max,n.y,l),bt.add(e.min,s,s),bt.add(e.max,l,l),bt.min(e.min,s,e.min),bt.max(e.max,s,e.max);var h=new xt(new bt,new bt),_=h.min,u=h.max;bt.scale(a.min,n.x,_),bt.scale(a.max,n.x,u),bt.min(h.min,u,s),bt.max(h.min,u,l),bt.min(e.min,s,e.min),bt.max(e.max,s,e.max)},t.cloneTo=function(e){e.enable=this.enable},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},e}(),oe=function(){function e(){}return s(e,"laya.d3.core.particleShuriKen.module.shape.ShapeUtils"),e._randomPointUnitArcCircle=function(e,t,n){var i,r=t.elements;i=n?n.getFloat()*e:Math.random()*e,r[0]=Math.cos(i),r[1]=Math.sin(i)},e._randomPointInsideUnitArcCircle=function(t,n,i){var r=n.elements;e._randomPointUnitArcCircle(t,n,i);var a;a=i?Math.pow(i.getFloat(),.5):Math.pow(Math.random(),.5),r[0]=r[0]*a,r[1]=r[1]*a},e._randomPointUnitCircle=function(e,t){var n,i=e.elements;n=t?t.getFloat()*Math.PI*2:Math.random()*Math.PI*2,i[0]=Math.cos(n),i[1]=Math.sin(n)},e._randomPointInsideUnitCircle=function(t,n){var i=t.elements;e._randomPointUnitCircle(t);var r;r=n?Math.pow(n.getFloat(),.5):Math.pow(Math.random(),.5),i[0]=i[0]*r,i[1]=i[1]*r},e._randomPointUnitSphere=function(e,t){var n=e.elements,i=NaN,r=NaN;t?(i=n[2]=2*t.getFloat()-1,r=t.getFloat()*Math.PI*2):(i=n[2]=2*Math.random()-1,r=Math.random()*Math.PI*2);var a=Math.sqrt(1-i*i);n[0]=a*Math.cos(r),n[1]=a*Math.sin(r)},e._randomPointInsideUnitSphere=function(t,n){var i=t.elements;e._randomPointUnitSphere(t);var r;r=n?Math.pow(n.getFloat(),1/3):Math.pow(Math.random(),1/3),i[0]=i[0]*r,i[1]=i[1]*r,i[2]=i[2]*r},e._randomPointInsideHalfUnitBox=function(e,t){var n=e.elements;t?(n[0]=t.getFloat()-.5,n[1]=t.getFloat()-.5,n[2]=t.getFloat()-.5):(n[0]=Math.random()-.5,n[1]=Math.random()-.5,n[2]=Math.random()-.5)},e}(),se=function(){function e(e){this._size=null,this.enbale=!1,this._size=e}s(e,"laya.d3.core.particleShuriKen.module.SizeOverLifetime");var t=e.prototype;return a.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;switch(this._size.type){case 0:e=this._size.separateAxes?ne.createByGradientSeparate(this._size.gradientX.clone(),this._size.gradientY.clone(),this._size.gradientZ.clone()):ne.createByGradient(this._size.gradient.clone());break;case 1:e=this._size.separateAxes?ne.createByRandomTwoConstantSeparate(this._size.constantMinSeparate.clone(),this._size.constantMaxSeparate.clone()):ne.createByRandomTwoConstant(this._size.constantMin,this._size.constantMax);break;case 2:e=this._size.separateAxes?ne.createByRandomTwoGradientSeparate(this._size.gradientXMin.clone(),this._size.gradientYMin.clone(),this._size.gradientZMin.clone(),this._size.gradientXMax.clone(),this._size.gradientYMax.clone(),this._size.gradientZMax.clone()):ne.createByRandomTwoGradient(this._size.gradientMin.clone(),this._size.gradientMax.clone())}var t=new this.constructor(e);return t.enbale=this.enbale,t},l(0,t,"size",function(){return this._size}),e}(),le=function(){function e(){this._type=0,this._constant=NaN,this._constantMin=NaN,this._constantMax=NaN}s(e,"laya.d3.core.particleShuriKen.module.StartFrame");var t=e.prototype;return a.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},l(0,t,"constant",function(){return this._constant}),l(0,t,"type",function(){return this._type}),l(0,t,"constantMin",function(){return this._constantMin}),l(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}(),he=function(){function e(e,t){this._frame=null,this._startFrame=null,this.tiles=null,this.type=0,this.randomRow=!1,this.rowIndex=0,this.cycles=0,this.enableUVChannels=0,this.enable=!1,this.tiles=new Lt(1,1),this.type=0,this.randomRow=!0,this.rowIndex=0,this.cycles=1,this.enableUVChannels=1,this._frame=e,this._startFrame=t}s(e,"laya.d3.core.particleShuriKen.module.TextureSheetAnimation");var t=e.prototype;return a.imps(t,{"laya.d3.core.IClone":!0}),t.cloneTo=function(e){var t=e;this.tiles.cloneTo(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.enable=this.enable},t.clone=function(){var e,t;switch(this._frame.type){case 0:e=q.createByConstant(this._frame.constant);break;case 1:e=q.createByOverTime(this._frame.frameOverTimeData.clone());break;case 2:e=q.createByRandomTwoConstant(this._frame.constantMin,this._frame.constantMax);break;case 3:e=q.createByRandomTwoOverTime(this._frame.frameOverTimeDataMin.clone(),this._frame.frameOverTimeDataMax.clone())}switch(this._startFrame.type){case 0:t=le.createByConstant(this._startFrame.constant);break;case 1:t=le.createByRandomTwoConstant(this._startFrame.constantMin,this._startFrame.constantMax)}var n=new this.constructor(e,t);return this.tiles.cloneTo(n.tiles),n.type=this.type,n.randomRow=this.randomRow,n.cycles=this.cycles,n.enableUVChannels=this.enableUVChannels,n.enable=this.enable,n},l(0,t,"frame",function(){return this._frame}),l(0,t,"startFrame",function(){return this._startFrame}),e}(),_e=function(){function e(e){this._velocity=null,this.enbale=!1,this.space=0,this._velocity=e}s(e,"laya.d3.core.particleShuriKen.module.VelocityOverLifetime");var t=e.prototype;return a.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;switch(this._velocity.type){case 0:e=ie.createByConstant(this._velocity.constant.clone());break;case 1:e=ie.createByGradient(this._velocity.gradientX.clone(),this._velocity.gradientY.clone(),this._velocity.gradientZ.clone());break;case 2:e=ie.createByRandomTwoConstant(this._velocity.constantMin.clone(),this._velocity.constantMax.clone());break;case 3:e=ie.createByRandomTwoGradient(this._velocity.gradientXMin.clone(),this._velocity.gradientYMin.clone(),this._velocity.gradientZMin.clone(),this._velocity.gradientXMax.clone(),this._velocity.gradientYMax.clone(),this._velocity.gradientZMax.clone())}var t=new this.constructor(e);return t.enbale=this.enbale,t.space=this.space,t},l(0,t,"velocity",function(){return this._velocity}),e}(),ue=function(){function e(){}return s(e,"laya.d3.core.particleShuriKen.ShurikenParticleData"),e._getStartLifetimeFromGradient=function(e,t){for(var n=1,i=e.gradientCount;n<i;n++){var r=e.getKeyByIndex(n);if(r>=t){var a=e.getKeyByIndex(n-1),o=(t-a)/(r-a);return M.lerp(e.getValueByIndex(n-1),e.getValueByIndex(n),o)}}throw new Error("ShurikenParticleData: can't get value foam startLifeTimeGradient.")},e._randomInvertRoationArray=function(e,t,n,i,r){var a=NaN;i?(i.seed=r[6],a=i.getFloat(),r[6]=i.seed):a=Math.random(),a<n?(t[0]=-e[0],t[1]=-e[1],t[2]=-e[2]):(t[0]=e[0],t[1]=e[1],t[2]=e[2])},e._randomInvertRoation=function(e,t,n,i){var r=NaN;return n?(n.seed=i[6],r=n.getFloat(),i[6]=n.seed):r=Math.random(),r<t&&(e=-e),e},e.create=function(t,n,i){var r=t.autoRandomSeed,a=t._rand,o=t._randomSeeds;switch(t.startColorType){case 0:var s=t.startColorConstant.elements;e.startColor[0]=s[0],e.startColor[1]=s[1],e.startColor[2]=s[2],e.startColor[3]=s[3];break;case 2:r?M.lerpVector4(t.startColorConstantMin.elements,t.startColorConstantMax.elements,Math.random(),e.startColor):(a.seed=o[3],M.lerpVector4(t.startColorConstantMin.elements,t.startColorConstantMax.elements,a.getFloat(),e.startColor),o[3]=a.seed)}var l=t.colorOverLifetime;if(l&&l.enbale){var h=l.color;switch(h.type){case 0:e.startColor[0]=e.startColor[0]*h.constant.x,e.startColor[1]=e.startColor[1]*h.constant.y,e.startColor[2]=e.startColor[2]*h.constant.z,e.startColor[3]=e.startColor[3]*h.constant.w;break;case 2:var _=NaN;r?_=Math.random():(a.seed=o[10],_=a.getFloat(),o[10]=a.seed);var u=h.constantMin,c=h.constantMax;e.startColor[0]=e.startColor[0]*M.lerp(u.x,c.x,_),e.startColor[1]=e.startColor[1]*M.lerp(u.y,c.y,_),e.startColor[2]=e.startColor[2]*M.lerp(u.z,c.z,_),e.startColor[3]=e.startColor[3]*M.lerp(u.w,c.w,_)}}var d=e.startSize;switch(t.startSizeType){case 0:if(t.threeDStartSize){var f=t.startSizeConstantSeparate;d[0]=f.x,d[1]=f.y,d[2]=f.z}else d[0]=d[1]=d[2]=t.startSizeConstant;break;case 2:if(t.threeDStartSize){var m=t.startSizeConstantMinSeparate,p=t.startSizeConstantMaxSeparate;r?(d[0]=M.lerp(m.x,p.x,Math.random()),d[1]=M.lerp(m.y,p.y,Math.random()),d[2]=M.lerp(m.z,p.z,Math.random())):(a.seed=o[4],d[0]=M.lerp(m.x,p.x,a.getFloat()),d[1]=M.lerp(m.y,p.y,a.getFloat()),d[2]=M.lerp(m.z,p.z,a.getFloat()),o[4]=a.seed)}else r?d[0]=d[1]=d[2]=M.lerp(t.startSizeConstantMin,t.startSizeConstantMax,Math.random()):(a.seed=o[4],d[0]=d[1]=d[2]=M.lerp(t.startSizeConstantMin,t.startSizeConstantMax,a.getFloat()),o[4]=a.seed)}var v=t.sizeOverLifetime;if(v&&v.enbale&&1===v.size.type){var E=v.size;if(E.separateAxes)r?(d[0]=d[0]*M.lerp(E.constantMinSeparate.x,E.constantMaxSeparate.x,Math.random()),d[1]=d[1]*M.lerp(E.constantMinSeparate.y,E.constantMaxSeparate.y,Math.random()),d[2]=d[2]*M.lerp(E.constantMinSeparate.z,E.constantMaxSeparate.z,Math.random())):(a.seed=o[11],d[0]=d[0]*M.lerp(E.constantMinSeparate.x,E.constantMaxSeparate.x,a.getFloat()),d[1]=d[1]*M.lerp(E.constantMinSeparate.y,E.constantMaxSeparate.y,a.getFloat()),d[2]=d[2]*M.lerp(E.constantMinSeparate.z,E.constantMaxSeparate.z,a.getFloat()),o[11]=a.seed);else{var g=NaN;r?g=M.lerp(E.constantMin,E.constantMax,Math.random()):(a.seed=o[11],g=M.lerp(E.constantMin,E.constantMax,a.getFloat()),o[11]=a.seed),d[0]=d[0]*g,d[1]=d[1]*g,d[2]=d[2]*g}}var D=n.renderMode;if(1!==D)switch(t.startRotationType){case 0:if(t.threeDStartRotation){var T=t.startRotationConstantSeparate,S=e._tempVector30.elements;e._randomInvertRoationArray(T.elements,S,t.randomizeRotationDirection,r?null:a,o),e.startRotation[0]=S[0],e.startRotation[1]=S[1],e.startRotation[2]=4!==D?-S[2]:S[2]}else e.startRotation[0]=e._randomInvertRoation(t.startRotationConstant,t.randomizeRotationDirection,r?null:a,o);break;case 2:if(t.threeDStartRotation){var x=t.startRotationConstantMinSeparate,R=t.startRotationConstantMaxSeparate,A=e._tempVector30.elements;r?(A[0]=M.lerp(x.x,R.x,Math.random()),A[1]=M.lerp(x.y,R.y,Math.random()),A[2]=M.lerp(x.z,R.z,Math.random())):(a.seed=o[5],A[0]=M.lerp(x.x,R.x,a.getFloat()),A[1]=M.lerp(x.y,R.y,a.getFloat()),A[2]=M.lerp(x.z,R.z,a.getFloat()),o[5]=a.seed),e._randomInvertRoationArray(A,A,t.randomizeRotationDirection,r?null:a,o),e.startRotation[0]=A[0],e.startRotation[1]=A[1],e.startRotation[2]=4!==D?-A[2]:A[2]}else r?e.startRotation[0]=e._randomInvertRoation(M.lerp(t.startRotationConstantMin,t.startRotationConstantMax,Math.random()),t.randomizeRotationDirection,r?null:a,o):(a.seed=o[5],e.startRotation[0]=e._randomInvertRoation(M.lerp(t.startRotationConstantMin,t.startRotationConstantMax,a.getFloat()),t.randomizeRotationDirection,r?null:a,o),o[5]=a.seed)}switch(t.startLifetimeType){case 0:e.startLifeTime=t.startLifetimeConstant;break;case 1:e.startLifeTime=e._getStartLifetimeFromGradient(t.startLifeTimeGradient,t.emissionTime);break;case 2:r?e.startLifeTime=M.lerp(t.startLifetimeConstantMin,t.startLifetimeConstantMax,Math.random()):(a.seed=o[7],e.startLifeTime=M.lerp(t.startLifetimeConstantMin,t.startLifetimeConstantMax,a.getFloat()),o[7]=a.seed);break;case 3:var I=t.emissionTime;r?e.startLifeTime=M.lerp(e._getStartLifetimeFromGradient(t.startLifeTimeGradientMin,I),e._getStartLifetimeFromGradient(t.startLifeTimeGradientMax,I),Math.random()):(a.seed=o[7],e.startLifeTime=M.lerp(e._getStartLifetimeFromGradient(t.startLifeTimeGradientMin,I),e._getStartLifetimeFromGradient(t.startLifeTimeGradientMax,I),a.getFloat()),o[7]=a.seed)}switch(t.startSpeedType){case 0:e.startSpeed=t.startSpeedConstant;break;case 2:r?e.startSpeed=M.lerp(t.startSpeedConstantMin,t.startSpeedConstantMax,Math.random()):(a.seed=o[8],e.startSpeed=M.lerp(t.startSpeedConstantMin,t.startSpeedConstantMax,a.getFloat()),o[8]=a.seed)}var y=t.textureSheetAnimation;if(y&&y.enable){var C=y.tiles,N=C.x,O=C.y,w=1/N,V=1/O,P=0,L=y.startFrame;switch(L.type){case 0:P=L.constant;break;case 1:r?P=M.lerp(L.constantMin,L.constantMax,Math.random()):(a.seed=o[14],P=M.lerp(L.constantMin,L.constantMax,a.getFloat()),o[14]=a.seed)}var b=y.frame;switch(b.type){case 0:P+=b.constant;break;case 2:r?P+=M.lerp(b.constantMin,b.constantMax,Math.random()):(a.seed=o[15],P+=M.lerp(b.constantMin,b.constantMax,a.getFloat()),o[15]=a.seed)}var F=0;switch(y.type){case 0:F=Math.floor(P/N);break;case 1:y.randomRow?r?F=Math.floor(Math.random()*O):(a.seed=o[13],F=Math.floor(a.getFloat()*O),o[13]=a.seed):F=y.rowIndex}var B=Math.floor(P%N);(e.startUVInfo=e.startUVInfo)[0]=w,e.startUVInfo[1]=V,e.startUVInfo[2]=B*w,e.startUVInfo[3]=F*V}else(e.startUVInfo=e.startUVInfo)[0]=1,e.startUVInfo[1]=1,e.startUVInfo[2]=0,e.startUVInfo[3]=0;switch(t.simulationSpace){case 0:var U=i.position.elements;e.simulationWorldPostion[0]=U[0],e.simulationWorldPostion[1]=U[1],e.simulationWorldPostion[2]=U[2];var H=i.rotation.elements;e.simulationWorldRotation[0]=H[0],e.simulationWorldRotation[1]=H[1],e.simulationWorldRotation[2]=H[2],e.simulationWorldRotation[3]=H[3];break;case 1:break;default:throw new Error("ShurikenParticleMaterial: SimulationSpace value is invalid.")}},e.startLifeTime=NaN,e.startSpeed=NaN,o(e,["_tempVector30",function(){return this._tempVector30=new bt},"_tempQuaternion",function(){return this._tempQuaternion=new wt},"startColor",function(){return this.startColor=new Float32Array(4)},"startSize",function(){return this.startSize=new Float32Array(3)},"startRotation",function(){return this.startRotation=new Float32Array(3)},"startUVInfo",function(){return this.startUVInfo=new Float32Array(4)},"simulationWorldPostion",function(){return this.simulationWorldPostion=new Float32Array(3)},"simulationWorldRotation",function(){return this.simulationWorldRotation=new Float32Array(4)}]),e}(),ce=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._camera=null,this._sharderNameID=0,this._shader=null,this._shaderCompile=null,this._vbData=new Float32Array(this._defaultBufferSize),this._ibData=new Uint16Array(this._defaultBufferSize),this._spriteShaderValue=new Wt,this._vb=$n.create(e._vertexDeclaration,this._defaultBufferSize/this._floatSizePerVer,35048),this._ib=Qn.create("ushort",this._defaultBufferSize,35048),this._sharderNameID=Gn.nameKey.getID("LINE"),this._shaderCompile=fn._preCompileShader[this._sharderNameID]}s(e,"laya.d3.core.PhasorSpriter3D");var t=e.prototype;return t.line=function(e,t,n,i){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.x,e.y,e.z,t.x,t.y,t.z,t.w),this.addVertex(n.x,n.y,n.z,i.x,i.y,i.z,i.w),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,o,s,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,o,s,l),this.addVertex(e+this._tempNumver0,t+this._tempNumver1,n,a,o,s,l),this.addVertex(e-this._tempNumver0,t-this._tempNumver1,n,a,o,s,l),this.addVertex(e+this._tempNumver0,t-this._tempNumver1,n,a,o,s,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,o,s,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,o,s,l,h),this.addVertex(e+this._tempNumver0,t+this._tempNumver1,n+this._tempNumver2,o,s,l,h),this.addVertex(e-this._tempNumver0,t-this._tempNumver1,n+this._tempNumver2,o,s,l,h),this.addVertex(e+this._tempNumver0,t-this._tempNumver1,n+this._tempNumver2,o,s,l,h),this.addVertex(e+this._tempNumver0,t+this._tempNumver1,n-this._tempNumver2,o,s,l,h),this.addVertex(e-this._tempNumver0,t+this._tempNumver1,n-this._tempNumver2,o,s,l,h),this.addVertex(e+this._tempNumver0,t-this._tempNumver1,n-this._tempNumver2,o,s,l,h),this.addVertex(e-this._tempNumver0,t-this._tempNumver1,n-this._tempNumver2,o,s,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,o){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,o,this._tempUint0),this.addVertexIndex(0,0,0,i,r,a,o,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,o,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,o,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,o,s,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,o,s,l,h),this.addVertex(i,r,a,o,s,l,h),this.addVertex(e,t,a,o,s,l,h),this.addVertex(i,t,a,o,s,l,h),this.addVertex(i,r,n,o,s,l,h),this.addVertex(e,r,n,o,s,l,h),this.addVertex(i,t,n,o,s,l,h),this.addVertex(e,t,n,o,s,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,o){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]=o,this._posInVBData+=this._floatSizePerVer,this},t.addVertexIndex=function(e,t,n,i,r,a,o,s){return this._hasBegun||this.addVertexIndexException(),this._vbData[s]=e,this._vbData[s+1]=t,this._vbData[s+2]=n,this._vbData[s+3]=i,this._vbData[s+4]=r,this._vbData[s+5]=a,this._vbData[s+6]=o,(s+=this._floatSizePerVer)>this._posInVBData&&(this._posInVBData=s),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){return this._hasBegun&&this.beginException0(),1!==e&&4!==e&&this.beginException1(),this._primitiveType=e,this._camera=t,this._hasBegun=!0,this},t.end=function(){return this._hasBegun||this.endException(),this.flush(),this._hasBegun=!1,this},t.flush=function(){0!==this._posInVBData&&(this._ib.setData(this._ibData),this._vb.setData(this._vbData),this._vb._bind(),this._ib._bind(),this._shader=this._shaderCompile.withCompile(0,0,0),this._shader.bind(),this._shader.uploadAttributes(e._vertexDeclaration.shaderValues.data,null),this._spriteShaderValue.setValue(1,this._camera.projectionViewMatrix.elements),this._shader.uploadSpriteUniforms(this._spriteShaderValue.data),w.drawCall++,b.mainContext.drawElements(this._primitiveType,this._posInIBData,5123,0),this._posInIBData=0,this._posInVBData=0)},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”基元！")},o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(28,[new Ne(0,"vector3",0),new Ne(12,"vector4",1)])}]),e}(),de=function(){function e(){this._id=0,this._type=0,this._mainSortID=0,this._render=null,this._sprite3D=null,this._material=null,this._renderObj=null,this._staticBatch=null,this._tempBatchIndexStart=0,this._tempBatchIndexEnd=0,this._canDynamicBatch=!1,this._shaderValue=null,this._onPreRenderFunction=null,this._id=++e._uniqueIDCounter,this._canDynamicBatch=!0,this._shaderValue=new Wt}s(e,"laya.d3.core.render.RenderElement");var t=e.prototype;return t.getDynamicBatchBakedVertexs=function(e){for(var t=this._renderObj._getVertexBuffer(e),n=t.getData().slice(),i=t.vertexDeclaration,r=i.getVertexElementByUsage(0).offset/4,a=i.getVertexElementByUsage(3).offset/4,o=this._sprite3D.transform,s=o.worldMatrix,l=o.rotation,h=i.vertexStride/4,_=0,u=n.length;_<u;_+=h){var c=_+r,d=_+a;Jt.transformVector3ArrayToVector3ArrayCoordinate(n,c,s,n,c),Jt.transformVector3ArrayByQuat(n,d,l,n,d)}return n},t.getBakedIndices=function(){return this._renderObj._getIndexBuffer().getData()},t._destroy=function(){this._staticBatch&&this._staticBatch._manager._garbageCollection(this)},l(0,t,"id",function(){return this._id}),l(0,t,"renderObj",function(){return this._renderObj},function(e){this._renderObj!==e&&(this._renderObj=e)}),e._uniqueIDCounter=0,e}(),fe=function(){function e(t){this._id=0,this._needSort=!1,this._renderElements=null,this._renderableRenderObjects=null,this._dynamicBatchCombineRenderElements=null,this._finalElements=null,this._scene=null,this._id=++e._uniqueIDCounter,this._needSort=!1,this._scene=t,this._renderElements=[],this._renderableRenderObjects=[],this._dynamicBatchCombineRenderElements=[]}s(e,"laya.d3.core.render.RenderQueue");var t=e.prototype;return t._sortOpaqueFunc=function(e,t){return e._render&&t._render?e._render._distanceForSort-t._render._distanceForSort:0},t._sortAlphaFunc=function(e,t){return e._render&&t._render?t._render._distanceForSort-e._render._distanceForSort:0},t._begainRenderElement=function(e,t,n){return!!t._beforeRender(e)},t._sortAlpha=function(t){e._cameraPosition=t,this._finalElements.sort(this._sortAlphaFunc)},t._sortOpaque=function(t){e._cameraPosition=t,this._finalElements.sort(this._sortOpaqueFunc)},t._preRender=function(e){this._finalElements=this._renderElements.concat(this._dynamicBatchCombineRenderElements)},t._render=function(e,t){for(var n,i,r,a,o,s,l=w.loopCount,h=this._scene,_=e.camera,u=(_.id,!1),c=0,d=this._finalElements.length;c<d;c++){var f,m,p,v=this._finalElements[c];if(null!=v._onPreRenderFunction&&v._onPreRenderFunction.call(v._sprite3D,e),0===v._type){if(e.owner=p=v._sprite3D,e.renderElement=v,p._preRenderUpdateComponents(e),f=v.renderObj,m=v._material,this._begainRenderElement(e,f,m)){if(n=f._getVertexBuffers(),r=(i=f._getVertexBuffer(0)).vertexDeclaration,u=(a=e._shader=m._getShader(h._shaderDefineValue,r.shaderDefineValue,p._shaderDefineValue)).bind()||l!==a._uploadLoopCount,n){if(a._uploadVertexBuffer!==n||u){for(var E=0;E<n.length;E++){var g=n[E];a.uploadAttributesX(g.vertexDeclaration.shaderValues.data,g)}a._uploadVertexBuffer=n}}else(a._uploadVertexBuffer!==i||u)&&(a.uploadAttributes(r.shaderValues.data,null),a._uploadVertexBuffer=i);(a._uploadScene!==h||u)&&(a.uploadSceneUniforms(h._shaderValues.data),a._uploadScene=h),(_!==a._uploadCamera||a._uploadSprite3D!==p||u)&&(a.uploadSpriteUniforms(p._shaderValues.data),a._uploadSprite3D=p),(_!==a._uploadCamera||u)&&(a.uploadCameraUniforms(_._shaderValues.data),a._uploadCamera=_),(a._uploadMaterial!==m||u)&&(m._upload(),a._uploadMaterial=m),o!==m?(m._setRenderStateBlendDepth(),m._setRenderStateFrontFace(t,p.transform),o=m,s=p):s!==p&&(m._setRenderStateFrontFace(t,p.transform),s=p),f._render(e),a._uploadLoopCount=l}p._postRenderUpdateComponents(e)}else 2===v._type&&(v.renderObj,e.owner=p=v._sprite3D,e.renderElement=v,e._batchIndexStart=v._tempBatchIndexStart,e._batchIndexEnd=v._tempBatchIndexEnd,f=v.renderObj,m=v._material,this._begainRenderElement(e,f,m)&&(r=(i=f._getVertexBuffer(0)).vertexDeclaration,u=(a=e._shader=m._getShader(h._shaderDefineValue,r.shaderDefineValue,p._shaderDefineValue)).bind()||l!==a._uploadLoopCount,(a._uploadVertexBuffer!==i||u)&&(a.uploadAttributes(r.shaderValues.data,null),a._uploadVertexBuffer=i),(a._uploadScene!==h||u)&&(a.uploadSceneUniforms(h._shaderValues.data),a._uploadScene=h),(_!==a._uploadCamera||a._uploadSprite3D!==p||u)&&(a.uploadSpriteUniforms(p._shaderValues.data),a._uploadSprite3D=p),(_!==a._uploadCamera||u)&&(a.uploadCameraUniforms(_._shaderValues.data),a._uploadCamera=_),(a._uploadMaterial!==m||u)&&(m._upload(),a._uploadMaterial=m),o!==m?(m._setRenderStateBlendDepth(),m._setRenderStateFrontFace(t,p.transform),o=m,s=p):s!==p&&(m._setRenderStateFrontFace(t,p.transform),s=p),f._render(e),a._uploadLoopCount=l))}},t._renderShadow=function(e,t){for(var n,i,r,a,o,s=w.loopCount,l=this._scene,h=e.camera,_=!1,u=0,c=this._finalElements.length;u<c;u++){var d,f,m,p=this._finalElements[u];0===p._type&&(e.owner=m=p._sprite3D,t||m._projectionViewWorldUpdateCamera===h&&m._projectionViewWorldUpdateLoopCount===w.loopCount||(m._render._renderUpdate(e._projectionViewMatrix),m._projectionViewWorldUpdateLoopCount=w.loopCount,m._projectionViewWorldUpdateCamera=h),e.renderElement=p,m._preRenderUpdateComponents(e),d=p.renderObj,f=p._material,this._begainRenderElement(e,d,null)&&(i=(n=d._getVertexBuffer(0)).vertexDeclaration,_=(r=e._shader=f._getShader(l._shaderDefineValue,i.shaderDefineValue,m._shaderDefineValue)).bind()||s!==r._uploadLoopCount,(r._uploadVertexBuffer!==n||_)&&(r.uploadAttributes(i.shaderValues.data,null),r._uploadVertexBuffer=n),(h!==r._uploadCamera||r._uploadSprite3D!==m||_)&&(r.uploadSpriteUniforms(m._shaderValues.data),r._uploadSprite3D=m),(h!==r._uploadCamera||_)&&(r.uploadCameraUniforms(h._shaderValues.data),r._uploadCamera=h),(r._uploadMaterial!==f||_)&&(f._upload(),r._uploadMaterial=f),r._uploadRenderElement,a!==f?(f._setRenderStateFrontFace(!1,m.transform),a=f,o=m):o!==m&&(f._setRenderStateFrontFace(!1,m.transform),o=m),d._render(e),r._uploadLoopCount=s),m._postRenderUpdateComponents(e))}},t._clearRenderElements=function(){this._dynamicBatchCombineRenderElements.length=0,this._renderElements.length=0,this._needSort=!0},t._addRenderElement=function(e){this._renderElements.push(e),this._needSort=!0},t._addDynamicBatchElement=function(e){this._dynamicBatchCombineRenderElements.push(e)},l(0,t,"id",function(){return this._id}),e._uniqueIDCounter=0,e.OPAQUE=1,e.TRANSPARENT=2,e._cameraPosition=null,e}(),me=function(){function e(){this._staticBatch=null,this._batchIndexStart=0,this._batchIndexEnd=0,this._viewMatrix=null,this._projectionMatrix=null,this._projectionViewMatrix=null,this._viewport=null,this._shader=null,this.elapsedTime=NaN,this.scene=null,this.owner=null,this.renderElement=null,this.camera=null}return s(e,"laya.d3.core.render.RenderState"),e.clientWidth=0,e.clientHeight=0,e}(),pe=function(){function e(e,t){this._exactBox=null,this._relaxBox=null,this._scene=null,this._parent=null,this._currentDepth=0,this._boundingSphere=new Rt(new bt,0),this._corners=[new bt,new bt,new bt,new bt,new bt,new bt,new bt,new bt],this._boundingBoxCenter=new bt,this._children=h(8),this._objects=[],this._tempBoundBoxCorners=[new bt,new bt,new bt,new bt,new bt,new bt,new bt,new bt],this._scene=e,this._currentDepth=t}s(e,"laya.d3.core.scene.OctreeNode");var t=e.prototype;return a.imps(t,{"laya.d3.core.scene.ITreeNode":!0}),t.init=function(e,t){var n=new bt,i=new bt;bt.scale(t,-.5,n),bt.scale(t,.5,i),bt.add(n,e,n),bt.add(i,e,i),this.exactBox=new xt(n,i),this.relaxBox=new xt(n,i)},t.addTreeNode=function(e){1===At.boxContainsBox(this._relaxBox,e.boundingBox)?this.addNodeDown(e,0):this.addObject(e)},t.addChild=function(t){var n=this._children[t];if(null==n){n=new e(this._scene,this._currentDepth+1),this._children[t]=n,n._parent=this,bt.subtract(this._exactBox.max,this._exactBox.min,e.tempSize),bt.multiply(e.tempSize,e._octreeSplit[t],e.tempCenter),bt.add(this._exactBox.min,e.tempCenter,e.tempCenter),bt.scale(e.tempSize,.25,e.tempSize);var i=new bt,r=new bt;bt.subtract(e.tempCenter,e.tempSize,i),bt.add(e.tempCenter,e.tempSize,r),n.exactBox=new xt(i,r),bt.scale(e.tempSize,e.relax,e.tempSize);var a=new bt,o=new bt;bt.subtract(e.tempCenter,e.tempSize,a),bt.add(e.tempCenter,e.tempSize,o),n.relaxBox=new xt(a,o)}return n},t.addObject=function(e){e._treeNode=this,this._objects.push(e)},t.removeObject=function(e){if(e._treeNode!=this)return console.log("OctreeNode::removeObject error"),!1;var t=this._objects.indexOf(e);return-1!==t&&(this._objects.splice(t,1),!0)},t.clearObject=function(){this._objects.length=0},t.addNodeUp=function(e,t){this._parent&&1!==At.boxContainsBox(this._exactBox,e.boundingBox)?this._parent.addNodeUp(e,t-1):this.addNodeDown(e,t)},t.addNodeDown=function(e,t){if(t<this._scene.treeLevel){var n=this.inChildIndex(e.boundingBoxCenter),i=this.addChild(n);1===At.boxContainsBox(i._relaxBox,e.boundingBox)?i.addNodeDown(e,++t):this.addObject(e)}else this.addObject(e)},t.inChildIndex=function(e){return 4*(e.z<this._boundingBoxCenter.z?0:1)+2*(e.y<this._boundingBoxCenter.y?0:1)+(e.x<this._boundingBoxCenter.x?0:1)},t.updateObject=function(e){1===At.boxContainsBox(this._relaxBox,e.boundingBox)?(this.removeObject(e),e._treeNode=null,this.addNodeDown(e,this._currentDepth)):this._parent&&(this.removeObject(e),e._treeNode=null,this._parent.addNodeUp(e,this._currentDepth-1))},t.cullingObjects=function(e,t,n,i,r){var a,o=0,s=0,l=0,h=this._scene._dynamicBatchManager;for(o=0,a=this._objects.length;o<a;o++){var _=this._objects[o];if(Z.isVisible(_._owner.layer.mask)&&_.enable){if(t&&(w.treeSpriteCollision+=1,0===e.containsBoundSphere(_.boundingSphere)))continue;_._renderUpdate(r),_._distanceForSort=bt.distance(_.boundingSphere.center,i)+_.sortingFudge;var u=_._renderElements;for(s=0,l=u.length;s<l;s++){var c=u[s],d=c._staticBatch;if(d&&d._material===c._material)d._addBatchRenderElement(c);else{var f=c.renderObj;f.triangleCount<10&&1===f._vertexBufferCount&&f._getIndexBuffer()&&c._material.renderQueue<2&&c._canDynamicBatch&&!_._owner.isStatic?h._addPrepareRenderElement(c):this._scene.getRenderQueue(c._material.renderQueue)._addRenderElement(c)}}}}for(o=0;o<8;o++){var m=this._children[o];if(null!=m){var p=t;if(t){var v=e.containsBoundBox(m._relaxBox);if(w.treeNodeCollision+=1,0===v)continue;p=2===v}m.cullingObjects(e,p,n,i,r)}}},t.cullingShadowObjects=function(e,t,n,i,r){var a,o=0,s=0,l=0;for(this._scene._dynamicBatchManager,o=0,a=this._objects.length;o<a;o++){var h=this._objects[o];if(h.castShadow&&Z.isVisible(h._owner.layer.mask)&&h.enable){if(n&&0===e[0].containsBoundSphere(h.boundingSphere))continue;for(var _=1,u=e.length;_<u;_++){var c=t[_-1];if(0!==e[_].containsBoundSphere(h.boundingSphere)){var d=h._renderElements;for(s=0,l=d.length;s<l;s++)c._addRenderElement(d[s])}}}}for(o=0;o<8;o++){var f=this._children[o];if(null!=f){var m=n;if(n){var p=e[0].containsBoundBox(f._relaxBox);if(0===p)continue;m=2===p}f.cullingShadowObjects(e,t,m,i,r)}}},t.cullingShadowObjectsOnePSSM=function(e,t,n,i,r,a){var o,s=t[0],l=0,h=0,_=0;for(l=0,o=this._objects.length;l<o;l++){var u=this._objects[l];if(u.castShadow&&Z.isVisible(u._owner.layer.mask)&&u.enable){if(i&&0===e.containsBoundSphere(u.boundingSphere))continue;u._renderUpdate(n);var c=u._renderElements;for(h=0,_=c.length;h<_;h++)s._addRenderElement(c[h])}}for(l=0;l<8;l++){var d=this._children[l];if(null!=d){var f=i;if(i){var m=e.containsBoundBox(d._relaxBox);if(0===m)continue;f=2===m}d.cullingShadowObjectsOnePSSM(e,t,n,f,r,a)}}},t.renderBoudingBox=function(e){this._renderBoudingBox(e);for(var t=0;t<8;++t){var n=this._children[t];n&&n.renderBoudingBox(e)}},t.buildAllChild=function(e){if(e<this._scene.treeLevel)for(var t=0;t<8;t++)this.addChild(t).buildAllChild(e+1)},t._renderBoudingBox=function(e){},l(0,t,"exactBox",function(){return this._exactBox},function(e){this._exactBox=e,bt.add(e.min,e.max,this._boundingBoxCenter),bt.scale(this._boundingBoxCenter,.5,this._boundingBoxCenter)}),l(0,t,"relaxBox",function(){return this._relaxBox},function(e){this._relaxBox=e,e.getCorners(this._corners),Rt.createfromPoints(this._corners,this._boundingSphere)}),e.debugMode=!1,e.relax=1.15,e.CHILDNUM=8,o(e,["tempVector0",function(){return this.tempVector0=new bt},"tempSize",function(){return this.tempSize=new bt},"tempCenter",function(){return this.tempCenter=new bt},"_octreeSplit",function(){return this._octreeSplit=[new bt(.25,.25,.25),new bt(.75,.25,.25),new bt(.25,.75,.25),new bt(.75,.75,.25),new bt(.25,.25,.75),new bt(.75,.25,.75),new bt(.25,.75,.75),new bt(.75,.75,.75)]}]),e}(),ve=(function(){s(function(){},"laya.d3.core.scene.SceneManager")}(),function(){function e(e,t,n,i){this._r=NaN,this._g=NaN,this._b=NaN,this._a=NaN,void 0===e&&(e=1),void 0===t&&(t=1),void 0===n&&(n=1),void 0===i&&(i=1),this._r=e,this._g=t,this._b=n,this._a=i}return s(e,"laya.d3.core.trail.module.Color",null,"Color$1"),e.prototype.cloneTo=function(e){e._r=this._r,e._g=this._g,e._b=this._b,e._a=this._a},o(e,["RED",function(){return this.RED=new e(1,0,0,1)},"GREEN",function(){return this.GREEN=new e(0,1,0,1)},"BLUE",function(){return this.BLUE=new e(0,0,1,1)},"CYAN",function(){return this.CYAN=new e(0,1,1,1)},"YELLOW",function(){return this.YELLOW=new e(1,.92,.016,1)},"MAGENTA",function(){return this.MAGENTA=new e(1,0,1,1)},"GRAY",function(){return this.GRAY=new e(.5,.5,.5,1)},"WHITE",function(){return this.WHITE=new e(1,1,1,1)},"BLACK",function(){return this.BLACK=new e(0,0,0,1)}]),e}()),Ee=function(){function e(){this._mode=0,this._colorKeys=null,this._alphaKeys=null,this.index=0,this._colorKeyData=new Float32Array(40),this._alphaKeyData=new Float32Array(20),this._colorKeys=[],this._alphaKeys=[]}s(e,"laya.d3.core.trail.module.Gradient");var t=e.prototype;return t.setKeys=function(e,t){this._colorKeys=e,this.index=0;for(var n,i=0;i<e.length;i++){var r=(n=e[i]).color;this._colorKeyData[this.index++]=r._r,this._colorKeyData[this.index++]=r._g,this._colorKeyData[this.index++]=r._b,this._colorKeyData[this.index++]=n.time}this._alphaKeys=t,this.index=0;for(var a,o=0;o<t.length;o++)a=t[o],this._alphaKeyData[this.index++]=a.alpha,this._alphaKeyData[this.index++]=a.time},t.cloneTo=function(e){var t=0,n=0,i=this.colorKeys,r=[];for(t=0,n=i.length;t<n;t++){var a=new De;i[t].cloneTo(a),r.push(a)}var o=this.alphaKeys,s=[];for(t=0,n=o.length;t<n;t++){var l=new ge;o[t].cloneTo(l),s.push(l)}e.setKeys(r,s)},l(0,t,"mode",function(){return this._mode},function(e){this._mode=e}),l(0,t,"colorKeys",function(){return this._colorKeys},function(e){this._colorKeys=e,this.index=0;for(var t=0;t<e.length;t++){var n=e[t],i=n.color;this._colorKeyData[this.index++]=i._r,this._colorKeyData[this.index++]=i._g,this._colorKeyData[this.index++]=i._b,this._colorKeyData[this.index++]=n.time}}),l(0,t,"alphaKeys",function(){return this._alphaKeys},function(e){this._alphaKeys=e,this.index=0;for(var t=0;t<e.length;t++){var n=e[t];this._alphaKeyData[this.index++]=n.alpha,this._alphaKeyData[this.index++]=n.time}}),e}(),ge=function(){function e(e,t){this._alpha=NaN,this._time=NaN,void 0===e&&(e=0),void 0===t&&(t=0),this._alpha=e,this._time=t}s(e,"laya.d3.core.trail.module.GradientAlphaKey");var t=e.prototype;return t.cloneTo=function(e){e.alpha=this.alpha,e.time=this.time},l(0,t,"alpha",function(){return this._alpha},function(e){this._alpha=e}),l(0,t,"time",function(){return this._time},function(e){this._time=e}),e}(),De=function(){function e(e,t){this._color=null,this._time=NaN,void 0===t&&(t=0),this._color=e||new ve,this._time=t}s(e,"laya.d3.core.trail.module.GradientColorKey");var t=e.prototype;return t.cloneTo=function(e){this.color.cloneTo(e.color),e.time=this.time},l(0,t,"color",function(){return this._color},function(e){this._color=e}),l(0,t,"time",function(){return this._time},function(e){this._time=e}),e}(),Te=(function(){function e(){}s(e,"laya.d3.core.trail.module.GradientMode"),e.Blend=0,e.Fixed=1}(),function(){function e(){}s(e,"laya.d3.core.trail.module.TextureMode"),e.Stretch=0,e.Tile=1}(),function(){function e(){this.time=NaN,this.inTangent=NaN,this.outTangent=NaN,this.value=NaN}return s(e,"laya.d3.core.trail.module.TrailKeyFrame"),e.prototype.cloneTo=function(e){e.time=this.time,e.inTangent=this.inTangent,e.outTangent=this.outTangent,e.value=this.value},e}()),Se=function(){function e(t){this._id=0,this._owner=null,this._camera=null,this._vertexBuffers=null,this._verticesCount=0,this._virtualVerticesCount=0,this._maxVerticesCount=256,this._vertices1=null,this._vertexBuffer1=null,this._floatCountPerVertices1=8,this._verticesIndex1=0,this._everyAddVerticeCount1=0,this._delLength=0,this._vertices2=null,this._vertexBuffer2=null,this._floatCountPerVertices2=1,this._everyGroupVertexBirthTime=null,this._VerticesToTailLength=null,this._everyVertexToPreVertexDistance=null,this._pointe=null,this._pointAtoBVector3e=null,this._isStart=!1,this._isFinish=!1,this._isDead=!1,this._curtime=NaN,this._curDisappearIndex=0,this._lastPosition=new bt,this._curPosition=new bt,this._delVector3=new bt,this._lastFixedVertexPosition=new bt,this._pointAtoBVector3=new bt,this._pointA=new bt,this._pointB=new bt,this._owner=t,this._id=e.renderElementCount++,0==this._id?t._owner.transform.position.cloneTo(this._lastPosition):t._curSubTrailFinishPosition.cloneTo(this._lastPosition),this._everyGroupVertexBirthTime=[],this._VerticesToTailLength=new Float32Array(this._maxVerticesCount),this._everyVertexToPreVertexDistance=new Float32Array(this._maxVerticesCount),this._vertices1=new Float32Array(this._maxVerticesCount*this._floatCountPerVertices1),this._vertices2=new Float32Array(this._maxVerticesCount*this._floatCountPerVertices2),this._vertexBuffer1=new $n(xe.vertexDeclaration1,this._maxVerticesCount,35044,!0),this._vertexBuffer2=new $n(xe.vertexDeclaration2,this._maxVerticesCount,35044,!0),this._vertexBuffers=[],this._vertexBuffers.push(this._vertexBuffer1),this._vertexBuffers.push(this._vertexBuffer2)}s(e,"laya.d3.core.trail.TrailRenderElement");var t=e.prototype;return a.imps(t,{"laya.d3.core.render.IRenderable":!0}),t._updateTrail=function(){this._everyAddVerticeCount1=0,this._isStart||this._addTrailByFirstPosition(this._lastPosition,this._curPosition),this._addTrailByNextPosition(this._curPosition),this._vertexBuffer1.setData(this._vertices1,this._verticesIndex1,this._verticesIndex1,this._everyAddVerticeCount1),this._verticesIndex1+=this._everyAddVerticeCount1,this._curPosition.cloneTo(this._lastPosition),2==this._virtualVerticesCount&&(this._verticesIndex1-=2*this._floatCountPerVertices1)},t._addTrailByFirstPosition=function(e,t){bt.subtract(t,e,this._delVector3),bt.cross(this._delVector3,this._camera.forward,this._pointAtoBVector3),bt.normalize(this._pointAtoBVector3,this._pointAtoBVector3),bt.scale(this._pointAtoBVector3,this._owner.widthMultiplier/2,this._pointAtoBVector3),this._updateVerticesByPosition(e),e.cloneTo(this._lastFixedVertexPosition),this._verticesCount+=2,this._curtime=this._owner._hasLifeSubTrail?this._owner._curSubTrailFinishCurTime:this._owner._curtime,this._everyGroupVertexBirthTime.push(this._curtime),this._isStart=!0,this._owner._hasLifeSubTrail=!0},t._addTrailByNextPosition=function(e){bt.subtract(e,this._lastFixedVertexPosition,this._delVector3),bt.cross(this._delVector3,this._camera.forward,this._pointAtoBVector3),bt.normalize(this._pointAtoBVector3,this._pointAtoBVector3),bt.scale(this._pointAtoBVector3,this._owner.widthMultiplier/2,this._pointAtoBVector3),this._delLength=bt.scalarLength(this._delVector3),this._delLength-this._owner.minVertexDistance>=It.zeroTolerance?(this._owner._trailTotalLength+=this._delLength,this._owner._trailSupplementLength=0,this._updateVerticesByPosition(e),e.cloneTo(this._lastFixedVertexPosition),this._verticesCount+=2,this._virtualVerticesCount=0,this._everyGroupVertexBirthTime.push(this._owner._curtime),this._verticesCount==this._maxVerticesCount&&this._onTrailRenderElementFinish()):(this._owner._trailSupplementLength=this._delLength,this._updateVerticesByPosition(e),this._virtualVerticesCount=2)},t._updateVerticesByPosition=function(e){this._pointe=e.elements,this._pointAtoBVector3e=this._pointAtoBVector3.elements,this._curtime=this._owner._curtime,this._owner._hasLifeSubTrail&&0==this._isStart&&(this._pointe=this._owner._curSubTrailFinishPosition.elements,this._pointAtoBVector3e=this._owner._curSubTrailFinishDirection.elements,this._curtime=this._owner._curSubTrailFinishCurTime),this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=this._pointe[0],this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=this._pointe[1],this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=this._pointe[2],this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=-this._pointAtoBVector3e[0],this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=-this._pointAtoBVector3e[1],this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=-this._pointAtoBVector3e[2],this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=this._curtime,this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=1,this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=this._pointe[0],this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=this._pointe[1],this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=this._pointe[2],this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=this._pointAtoBVector3e[0],this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=this._pointAtoBVector3e[1],this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=this._pointAtoBVector3e[2],this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=this._curtime,this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=0,this._VerticesToTailLength[this._verticesCount/2]=this._owner._trailTotalLength+this._owner._trailSupplementLength,0==this._owner._trailSupplementLength?this._everyVertexToPreVertexDistance[this._verticesCount/2]=this._delLength:this._everyVertexToPreVertexDistance[this._verticesCount/2]=this._isStart?this._owner._trailSupplementLength:0},t._updateVertexBuffer2=function(){var e,t=0,n=0,i=0;for(i=0,e=(this._verticesCount+this._virtualVerticesCount)/2;i<e;i++)n=0==this._owner.textureMode?(this._VerticesToTailLength[i]-this._owner._trailDeadLength)/(this._owner._trailTotalLength+this._owner._trailSupplementLength-this._owner._trailDeadLength):this._owner._trailTotalLength+this._owner._trailSupplementLength-this._VerticesToTailLength[i],this._vertices2[t++]=1-n,this._vertices2[t++]=1-n;this._vertexBuffer2.setData(this._vertices2,0,0,this._verticesCount+this._virtualVerticesCount)},t._onTrailRenderElementFinish=function(){this._lastFixedVertexPosition.cloneTo(this._owner._curSubTrailFinishPosition),this._pointAtoBVector3.cloneTo(this._owner._curSubTrailFinishDirection),this._owner._curSubTrailFinishCurTime=this._owner._curtime,this._isFinish=!0},t._updateDisappear=function(){var e,t=0;for(t=this._curDisappearIndex,e=(this._verticesCount+this._virtualVerticesCount)/2;t<e;t++)this._owner._curtime-this._everyGroupVertexBirthTime[t]>=this._owner.time+It.zeroTolerance&&(this._curDisappearIndex++,this._owner._trailDeadLength+=this._everyVertexToPreVertexDistance[this._curDisappearIndex],this._curDisappearIndex>=(this._verticesCount+this._virtualVerticesCount)/2&&(this._isDead=!0))},t._beforeRender=function(e){return this._camera=e.camera,null!=this._camera&&(this._owner._owner.transform.position.cloneTo(this._curPosition),!this._isDead&&(this._verticesCount<this._maxVerticesCount?(this._owner._isStart||(this._owner._owner.transform.position.cloneTo(this._lastPosition),this._owner._isStart=!0),bt.equals(this._lastPosition,this._curPosition)||this._updateTrail()):this._isFinish&&(this._isFinish=!1,this._owner._curSubTrailFinished=!0),this._verticesCount>0)&&(this._updateVertexBuffer2(),this._updateDisappear(),!0))},t._render=function(e){this._isDead||(b.mainContext.drawArrays(5,2*this._curDisappearIndex,this._verticesCount+this._virtualVerticesCount-2*this._curDisappearIndex),console.log(2*this._curDisappearIndex,this._verticesCount+this._virtualVerticesCount-2*this._curDisappearIndex),w.drawCall++,w.trianglesFaces+=this._verticesCount+this._virtualVerticesCount-2*this._curDisappearIndex-2)},t._getVertexBuffer=function(e){return void 0===e&&(e=0),0===e?this._vertexBuffer1:1===e?this._vertexBuffer2:null},t._getVertexBuffers=function(){return this._vertexBuffers},t._getIndexBuffer=function(){return null},t.reActivate=function(){this._id=laya.d3.core.trail.TrailRenderElement.renderElementCount++,this._isStart=!1,this._isFinish=!1,this._isDead=!1,this._verticesCount=0,this._virtualVerticesCount=0,this._verticesIndex1=0,this._delLength=0,this._curDisappearIndex=0,this._everyGroupVertexBirthTime=[],this._owner._curSubTrailFinishPosition.cloneTo(this._lastPosition)},t._destroy=function(){this._vertexBuffer1.dispose(),this._vertexBuffer2.dispose(),this._vertices1=null,this._vertexBuffer1=null,this._vertices2=null,this._vertexBuffer2=null,this._vertexBuffers=null,this._everyGroupVertexBirthTime=null,this._VerticesToTailLength=null,this._everyVertexToPreVertexDistance=null,this._lastPosition=null,this._curPosition=null,this._delVector3=null,this._lastFixedVertexPosition=null,this._pointAtoBVector3=null,this._pointe=null,this._pointAtoBVector3e=null,this._pointA=null,this._pointB=null},l(0,t,"_vertexBufferCount",function(){return this._vertexBuffers.length}),l(0,t,"triangleCount",function(){return 0}),e.renderElementCount=0,e}(),xe=function(){function e(){}s(e,"laya.d3.core.trail.VertexTrail");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration1}),l(1,e,"vertexDeclaration1",function(){return e._vertexDeclaration1}),l(1,e,"vertexDeclaration2",function(){return e._vertexDeclaration2}),o(e,["_vertexDeclaration1",function(){return this._vertexDeclaration1=new Ce(32,[new Ne(0,"vector3",0),new Ne(12,"vector3",41),new Ne(24,"single",33),new Ne(28,"single",40)])},"_vertexDeclaration2",function(){return this._vertexDeclaration2=new Ce(4,[new Ne(0,"single",38)])}]),e}(),Me=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}s(e,"laya.d3.graphics.DynamicBatch");var t=e.prototype;return a.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(e,t,n){var i=this._combineRenderElementPool[this._combineRenderElementPoolIndex++];return i||(this._combineRenderElementPool[this._combineRenderElementPoolIndex-1]=i=new de,i._sprite3D=new Di),i._sprite3D._render._renderUpdate(n),i},t._getRenderElement=function(t,n,i){this._vertexDatas||(this._vertexDatas=new Float32Array(this._vertexDeclaration.vertexStride/4*e.maxVertexCount),this._indexDatas=new Uint16Array(e.maxIndexCount),this._vertexBuffer=$n.create(this._vertexDeclaration,e.maxVertexCount,35048),this._indexBuffer=Qn.create("ushort",e.maxIndexCount,35048)),this._merageElements.length=0;for(var r=0,a=0,o=0,s=this._combineRenderElements.length;o<s;o++){var l=this._combineRenderElements[o],h=l.getDynamicBatchBakedVertexs(0),_=l.getBakedIndices(),u=l._sprite3D.transform._isFrontFaceInvert,c=r/(this._vertexDeclaration.vertexStride/4),d=a,f=d+_.length;l._tempBatchIndexStart=d,l._tempBatchIndexEnd=f,this._indexDatas.set(_,a);var m=0;if(u)for(m=d;m<f;m+=3){this._indexDatas[m]=c+this._indexDatas[m];var p=this._indexDatas[m+1],v=this._indexDatas[m+2];this._indexDatas[m+1]=c+v,this._indexDatas[m+2]=c+p}else for(m=d;m<f;m+=3)this._indexDatas[m]=c+this._indexDatas[m],this._indexDatas[m+1]=c+this._indexDatas[m+1],this._indexDatas[m+2]=c+this._indexDatas[m+2];a+=_.length,this._vertexDatas.set(h,r),r+=h.length}for(this._vertexBuffer.setData(this._vertexDatas),this._indexBuffer.setData(this._indexDatas),this._combineRenderElementPoolIndex=0,o=0,s=this._materials.length;o<s;o++){var E=this._getCombineRenderElementFromPool(t,n,i);E._type=2,E._staticBatch=null,E.renderObj=this;var g=this._combineRenderElements[this._materialToRenderElementsOffsets[o]]._tempBatchIndexStart,D=o+1===this._materialToRenderElementsOffsets.length?a:this._combineRenderElements[this._materialToRenderElementsOffsets[o+1]]._tempBatchIndexStart;E._tempBatchIndexStart=g,E._tempBatchIndexEnd=D,E._material=this._materials[o],this._merageElements.push(E)}},t._addCombineRenderObjTest=function(t){var n=t.renderObj,i=this._currentCombineIndexCount+n._getIndexBuffer().indexCount;return!(this._currentCombineVertexCount+n._getVertexBuffer().vertexCount>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,t,n,i){this._getRenderElement(t,n,i);for(var r=0,a=this._materials.length;r<a;r++)e.getRenderQueue(this._materials[r].renderQueue)._addDynamicBatchElement(this._merageElements[r])},t._beforeRender=function(e){return this._vertexBuffer._bind(),this._indexBuffer._bind(),!0},t._render=function(e){var t=e._batchIndexEnd-e._batchIndexStart;b.mainContext.drawElements(4,t,5123,2*e._batchIndexStart),w.drawCall++,w.trianglesFaces+=t/3},t._getVertexBuffers=function(){return null},l(0,t,"_vertexBufferCount",function(){return 1}),l(0,t,"triangleCount",function(){return this._indexBuffer.indexCount/3}),l(0,t,"combineRenderElementsCount",function(){return this._combineRenderElements.length}),e.maxVertexCount=2e4,e.maxIndexCount=4e4,e.maxCombineTriangleCount=10,e}(),Re=function(){function e(){this._dynamicBatches=null,this._prepareDynamicBatchCombineElements=null,this._dynamicBatches={},this._prepareDynamicBatchCombineElements=[]}s(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 Me(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,o,s,l,h,_=-1,u=!0,c=0,d=-1,f=0,m=this._prepareDynamicBatchCombineElements.length;f<m;f++){var p=(o=this._prepareDynamicBatchCombineElements[f]).renderObj._getVertexBuffer(0).vertexDeclaration,v=i!==p;v&&(c=0,i=p);var E=c!==_;if(E&&(_=c),(v||E)&&(s=this.getDynamicBatch(p,c),n=null),u)if(s._addCombineRenderObjTest(o)){if(n!==(a=o._material))l&&(t.getRenderQueue(h._material.renderQueue)._addRenderElement(h),l=null,h=null,d=-1),l=a,d=s.combineRenderElementsCount,h=o,n=a;else if(l){var g=h.renderObj,D=o.renderObj;g._getVertexBuffer().vertexCount+D._getVertexBuffer().vertexCount>Me.maxVertexCount||g._getIndexBuffer().indexCount+D._getIndexBuffer().indexCount>Me.maxIndexCount?(t.getRenderQueue(h._material.renderQueue)._addRenderElement(h),l=a,d=s.combineRenderElementsCount,h=o):(s._addCombineMaterial(l),s._addMaterialToRenderElementOffset(d),s._addCombineRenderObj(h),l=null,h=null,d=-1,s._addCombineRenderObj(o))}else s._addCombineRenderObj(o);u=!0}else l&&(t.getRenderQueue(h._material.renderQueue)._addRenderElement(h),l=null,h=null,d=-1),c++,u=!1;else r=this._prepareDynamicBatchCombineElements[f-1],s._addMaterialToRenderElementOffset(s.combineRenderElementsCount),n=r._material,s._addCombineMaterial(n),s._addCombineRenderObj(r),u=!0,n!==(a=o._material)?(l=a,d=s.combineRenderElementsCount,h=o):s._addCombineRenderObj(o),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,t,n,i){for(var r in this._dynamicBatches){var a=this._dynamicBatches[r];a.combineRenderElementsCount>0&&a._addToRenderQueue(e,t,n,i)}},t.dispose=function(){this._dynamicBatches=null},e._sortPrepareDynamicBatch=function(e,t){return e._mainSortID-t._mainSortID},e}(),Ae=function(){function e(){}return s(e,"laya.d3.graphics.FrustumCulling"),e.renderShadowObjectCulling=function(e,t,n,i,r){var a=0,o=0,s=0,l=0;for(a=0,s=n.length;a<s;a++){var h=n[a];h&&h._clearRenderElements()}var _,u,c,d=e._cullingRenders;if(r>1){for(a=0,s=e._cullingRendersLength;a<s;a++)if((_=d[a]).castShadow&&Z.isVisible(_._owner.layer.mask)&&_.enable)for(var f=1,m=t.length;f<m;f++)if(u=n[f-1],0!==t[f].containsBoundSphere(_.boundingSphere))for(o=0,l=(c=_._renderElements).length;o<l;o++)u._addRenderElement(c[o])}else for(a=0,s=e._cullingRendersLength;a<s;a++)if((_=d[a]).castShadow&&Z.isVisible(_._owner.layer.mask)&&_.enable&&0!==t[0].containsBoundSphere(_.boundingSphere))for(_._renderUpdate(i),u=n[0],o=0,l=(c=_._renderElements).length;o<l;o++)u._addRenderElement(c[o])},e.renderShadowObjectCullingOctree=function(e,t,n,i,r){for(var a=0,o=n.length;a<o;a++){var s=n[a];s&&s._clearRenderElements()}r>1?e.treeRoot.cullingShadowObjects(t,n,!0,0,e):e.treeRoot.cullingShadowObjectsOnePSSM(t[0],n,i,!0,0,e)},e.renderObjectCulling=function(e,t,n,i,r,a){var o=0,s=0,l=0,h=0,_=t._quenes,u=t._dynamicBatchManager,c=t._cullingRenders;for(o=0,s=_.length;o<s;o++){var d=_[o];d&&d._clearRenderElements()}var f=Ie._staticBatchManagers;for(o=0,s=f.length;o<s;o++)f[o]._clearRenderElements();u._clearRenderElements();var m=n.transform.position;for(o=0,s=t._cullingRendersLength;o<s;o++){var p=c[o];if(Z.isVisible(p._owner.layer.mask)&&p.enable&&0!==e.containsBoundSphere(p.boundingSphere)&&p._renderUpdate(a)){p._distanceForSort=bt.distance(p.boundingSphere.center,m)+p.sortingFudge;var v=p._renderElements;for(l=0,h=v.length;l<h;l++){var E=v[l],g=E._staticBatch;if(g&&g._material===E._material)g._addBatchRenderElement(E);else{var D=E.renderObj;D.triangleCount<10&&1===D._vertexBufferCount&&D._getIndexBuffer()&&E._material.renderQueue<2&&E._canDynamicBatch&&!p._owner.isStatic?u._addPrepareRenderElement(E):t.getRenderQueue(E._material.renderQueue)._addRenderElement(E)}}}}for(o=0,s=f.length;o<s;o++)f[o]._addToRenderQueue(t,i,r,a);u._finishCombineDynamicBatch(t),u._addToRenderQueue(t,i,r,a)},e.renderObjectCullingOctree=function(e,t,n,i,r,a){var o=0,s=0,l=t._quenes,h=t._dynamicBatchManager;for(o=0,s=l.length;o<s;o++){var _=l[o];_&&_._clearRenderElements()}var u=Ie._staticBatchManagers;for(o=0,s=u.length;o<s;o++)u[o]._clearRenderElements();for(h._clearRenderElements(),t._cullingRenders.length=0,t.treeRoot.cullingObjects(e,!0,0,n.transform.position,a),o=0,s=u.length;o<s;o++)u[o]._addToRenderQueue(t,i,r,a);h._finishCombineDynamicBatch(t),h._addToRenderQueue(t,i,r,a)},e.renderObjectCullingNoBoundFrustum=function(e,t,n,i,r){var a=0,o=0,s=0,l=0,h=e._quenes,_=e._dynamicBatchManager,u=e._cullingRenders;for(a=0,o=h.length;a<o;a++){var c=h[a];c&&c._clearRenderElements()}var d=Ie._staticBatchManagers;for(a=0,o=d.length;a<o;a++)d[a]._clearRenderElements();_._clearRenderElements();var f=t.transform.position;for(a=0,o=e._cullingRendersLength;a<o;a++){var m=u[a];if(Z.isVisible(m._owner.layer.mask)&&m.enable){m._renderUpdate(r),m._distanceForSort=bt.distance(m.boundingSphere.center,f)+m.sortingFudge;var p=m._renderElements;for(s=0,l=p.length;s<l;s++){var v=p[s],E=v._staticBatch;if(E&&E._material===v._material)E._addBatchRenderElement(v);else{var g=v.renderObj;g.triangleCount<10&&1===g._vertexBufferCount&&g._getIndexBuffer()&&v._material.renderQueue<2&&v._canDynamicBatch&&!m._owner.isStatic?_._addPrepareRenderElement(v):e.getRenderQueue(v._material.renderQueue)._addRenderElement(v)}}}}for(a=0,o=d.length;a<o;a++)d[a]._addToRenderQueue(e,n,i,r);_._finishCombineDynamicBatch(e),_._addToRenderQueue(e,n,i,r)},e}(),Ie=function(){function e(){this._initBatchRenderElements=null,this._staticBatches=null,this._initBatchRenderElements=[],this._staticBatches={}}s(e,"laya.d3.graphics.StaticBatchManager");var t=e.prototype;return t._finishInit=function(){for(var e in this._staticBatches)this._staticBatches[e]._finishInit();this._initBatchRenderElements.length=0},t._initStaticBatchs=function(e){throw new Error("StaticBatchManager:must override this function.")},t._addInitBatchSprite=function(e){for(var t=e._render._renderElements,n=0,i=t.length;n<i;n++)this._initBatchRenderElements.push(t[n])},t._clearRenderElements=function(){for(var e in this._staticBatches)this._staticBatches[e]._clearRenderElements()},t._garbageCollection=function(e){var t=e._staticBatch,n=t._initBatchRenderElements,i=n.indexOf(e);n.splice(i,1),0===n.length&&(t.dispose(),delete this._staticBatches[t._key])},t._addToRenderQueue=function(e,t,n,i){for(var r in this._staticBatches){var a=this._staticBatches[r];a._batchRenderElements.length>0&&a._updateToRenderQueue(e,i)}},t.dispose=function(){this._staticBatches=null},e._addToStaticBatchQueue=function(t){t instanceof laya.d3.core.RenderableSprite3D&&t._addToInitStaticBatchManager();for(var n=0,i=t.numChildren;n<i;n++)e._addToStaticBatchQueue(t._childs[n])},e.combine=function(t,n){var i,r=0,a=0;if(n)for(r=0,a=n.length;r<a;r++)n[r]._addToInitStaticBatchManager();else t&&e._addToStaticBatchQueue(t);for(r=0,a=e._staticBatchManagers.length;r<a;r++)(i=e._staticBatchManagers[r])._initStaticBatchs(t),i._finishInit()},e._staticBatchManagers=[],e}(),ye=function(){function e(e,t,n){this._combineRenderElementPoolIndex=0,this._combineRenderElementPool=null,this._initBatchRenderElements=null,this._batchRenderElements=null,this._material=null,this._rootOwner=null,this._key=null,this._manager=null,this._key=e,this._manager=t,this._combineRenderElementPoolIndex=0,this._combineRenderElementPool=[],this._initBatchRenderElements=[],this._batchRenderElements=[],this._rootOwner=n}s(e,"laya.d3.graphics.StaticBatch");var t=e.prototype;return a.imps(t,{"laya.d3.core.render.IRenderable":!0,"laya.resource.IDispose":!0}),t._binarySearch=function(e){for(var t=0,n=this._batchRenderElements.length-1,i=0;t<=n;)i=Math.floor((t+n)/2),this._compareBatchRenderElement(this._batchRenderElements[i],e)?n=i-1:t=i+1;return t},t._compareBatchRenderElement=function(e,t){throw new Error("StaticBatch:must override this function.")},t._getVertexDecLightMap=function(e){return e===lt.vertexDeclaration?it.vertexDeclaration:e===st.vertexDeclaration?nt.vertexDeclaration:e===qe.vertexDeclaration?Xe.vertexDeclaration:e===ct.vertexDeclaration?null:e===He.vertexDeclaration?Ge.vertexDeclaration:e===_t.vertexDeclaration?at.vertexDeclaration:e===et.vertexDeclaration?tt.vertexDeclaration:e===ht.vertexDeclaration?rt.vertexDeclaration:e===st.vertexDeclaration?nt.vertexDeclaration:e===Qe.vertexDeclaration?Ze.vertexDeclaration:e===ct.vertexDeclaration?null:e===He.vertexDeclaration?Ge.vertexDeclaration:e===ut.vertexDeclaration?ot.vertexDeclaration:e===et.vertexDeclaration?tt.vertexDeclaration:e},t._getCombineRenderElementFromPool=function(){throw new Error("StaticBatch:must override this function.")},t._addBatchRenderElement=function(e){this._batchRenderElements.splice(this._binarySearch(e),0,e)},t._updateToRenderQueue=function(e,t){this._combineRenderElementPoolIndex=0,this._getRenderElement(e.getRenderQueue(this._material.renderQueue)._renderElements,e,t)},t._getRenderElement=function(e,t,n){throw new Error("StaticBatch:must override this function.")},t._finishInit=function(){throw new Error("StaticBatch:must override this function.")},t._clearRenderElements=function(){this._batchRenderElements.length=0},t.dispose=function(){},t._getVertexBuffer=function(e){return void 0===e&&(e=0),null},t._getIndexBuffer=function(){return null},t._beforeRender=function(e){return!0},t._render=function(e){},t._getVertexBuffers=function(){return null},l(0,t,"_vertexBufferCount",function(){return 1}),l(0,t,"triangleCount",function(){return 0}),e.combine=function(e){console.log("StaticBatch: discard property,please use StaticBatchManager.combine() function instead."),Ie.combine(e)},e.maxBatchVertexCount=65535,e}(),Ce=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 Wt,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 o=[e._getTypeSize(r.elementFormat)/4,5126,!1,this._vertexStride,r.offset];switch(this._shaderValues.setValue(a,o),a){case 1:this._addShaderDefine(fn.SHADERDEFINE_COLOR);break;case 2:this._addShaderDefine(fn.SHADERDEFINE_UV0);break;case 15:this._addShaderDefine(fn.SHADERDEFINE_UV1)}}}s(e,"laya.d3.graphics.VertexDeclaration");var t=e.prototype;return t._addShaderDefine=function(e){this._shaderDefineValue|=e},t._removeShaderDefine=function(e){this._shaderDefineValue&=~e},t.getVertexElements=function(){return this._vertexElements.slice()},t.getVertexElementByUsage=function(e){return this._vertexElementsDic[e]},t.unBinding=function(){},l(0,t,"shaderDefineValue",function(){return this._shaderDefineValue}),l(0,t,"id",function(){return this._id}),l(0,t,"vertexStride",function(){return this._vertexStride}),l(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":case"byte4":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);n<a&&(n=a)}return n},e._maxVertexDeclarationBit=1e3,e._uniqueIDCounter=1,o(e,["maxVertexDeclaration",function(){return this.maxVertexDeclaration=2147483647-1e3*Math.floor(2147483.647)}]),e}(),Ne=function(){function e(e,t,n){this.offset=0,this.elementFormat=null,this.elementUsage=0,this.offset=e,this.elementFormat=t,this.elementUsage=n}return s(e,"laya.d3.graphics.VertexElement"),e}(),Oe=(function(){function e(){}s(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"}(),function(){function e(){}s(e,"laya.d3.graphics.VertexElementUsage"),e.POSITION0=0,e.COLOR0=1,e.TEXTURECOORDINATE0=2,e.NORMAL0=3,e.BINORMAL0=4,e.TANGENT0=5,e.BLENDINDICES0=6,e.BLENDWEIGHT0=7,e.DEPTH0=8,e.FOG0=9,e.POINTSIZE0=10,e.SAMPLE0=11,e.TESSELLATEFACTOR0=12,e.COLOR1=13,e.NEXTTEXTURECOORDINATE0=14,e.TEXTURECOORDINATE1=15,e.NEXTTEXTURECOORDINATE1=16,e.CORNERTEXTURECOORDINATE0=17,e.VELOCITY0=18,e.STARTCOLOR0=19,e.STARTSIZE=20,e.AGEADDSCALE0=21,e.STARTROTATION=22,e.ENDCOLOR0=23,e.STARTLIFETIME=24,e.TIME0=33,e.SHAPEPOSITIONSTARTLIFETIME=30,e.DIRECTIONTIME=32,e.SIZEROTATION0=27,e.RADIUS0=28,e.RADIAN0=29,e.STARTSPEED=31,e.RANDOM0=34,e.RANDOM1=35,e.SIMULATIONWORLDPOSTION=36,e.SIMULATIONWORLDROTATION=37,e.TEXTURECOORDINATE0X=38,e.TEXTURECOORDINATE0X1=39,e.TEXTURECOORDINATE0Y=40,e.OFFSETVECTOR=41}(),function(){function e(e,t,n){this._position=null,this._textureCoordinate0=null,this._time=NaN,this._position=e,this._textureCoordinate0=t,this._time=n}s(e,"laya.d3.graphics.VertexGlitter");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"textureCoordinate",function(){return this._textureCoordinate0}),l(0,t,"position",function(){return this._position}),l(0,t,"time",function(){return this._time}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(24,[new Ne(0,"vector3",0),new Ne(12,"vector2",2),new Ne(20,"single",33)])}]),e}()),we=(function(){function e(e,t,n,i,r,a,o,s,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=o,this._radian=s,this._ageAddScale=l,this._time=h}s(e,"laya.d3.graphics.VertexParticle");var t=e.prototype;a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"endColor",function(){return this._endColor}),l(0,t,"cornerTextureCoordinate",function(){return this._cornerTextureCoordinate}),l(0,t,"sizeRotation",function(){return this._sizeRotation}),l(0,t,"velocity",function(){return this._velocity}),l(0,t,"position",function(){return this._position}),l(0,t,"startColor",function(){return this._startColor}),l(0,t,"radius",function(){return this._radius}),l(0,t,"radian",function(){return this._radian}),l(0,t,"ageAddScale",function(){return this._ageAddScale}),l(0,t,"time",function(){return this._time}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(116,[new Ne(0,"vector4",17),new Ne(16,"vector3",0),new Ne(28,"vector3",18),new Ne(40,"vector4",19),new Ne(56,"vector4",23),new Ne(72,"vector3",27),new Ne(84,"vector2",28),new Ne(92,"vector4",29),new Ne(108,"single",24),new Ne(112,"single",33)])}])}(),function(){function e(e){this._position=null,this._position=e}s(e,"laya.d3.graphics.VertexPosition");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"position",function(){return this._position}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(12,[new Ne(0,"vector3",0)])}]),e}()),Ve=function(){function e(e,t){this._position=null,this._normal=null,this._position=e,this._normal=t}s(e,"laya.d3.graphics.VertexPositionNormal");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(24,[new Ne(0,"vector3",0),new Ne(12,"vector3",3)])}]),e}(),Pe=function(){function e(e,t,n){this._position=null,this._normal=null,this._color=null,this._position=e,this._normal=t,this._color=n}s(e,"laya.d3.graphics.VertexPositionNormalColor");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"color",function(){return this._color}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(40,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector4",1)])}]),e}(),Le=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}s(e,"laya.d3.graphics.VertexPositionNormalColorSkin");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"blendWeight",function(){return this._blendWeight}),l(0,t,"color",function(){return this._color}),l(0,t,"blendIndex",function(){return this._blendIndex}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(72,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector4",1),new Ne(40,"vector4",7),new Ne(56,"vector4",6)])}]),e}(),be=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}s(e,"laya.d3.graphics.VertexPositionNormalColorSkinSTangent");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"tangent",function(){return this._tangent}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"blendWeight",function(){return this._blendWeight}),l(0,t,"color",function(){return this._color}),l(0,t,"blendIndex",function(){return this._blendIndex}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(88,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector4",1),new Ne(40,"vector4",7),new Ne(56,"vector4",6),new Ne(72,"vector4",5)])}]),e}(),Fe=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}s(e,"laya.d3.graphics.VertexPositionNormalColorSkinTangent");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"tangent",function(){return this._tangent}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"blendWeight",function(){return this._blendWeight}),l(0,t,"color",function(){return this._color}),l(0,t,"blendIndex",function(){return this._blendIndex}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(84,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector4",1),new Ne(40,"vector4",7),new Ne(56,"vector4",6),new Ne(72,"vector3",5)])}]),e}(),Be=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}s(e,"laya.d3.graphics.VertexPositionNormalColorSTangent");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"tangent",function(){return this._tangent}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"color",function(){return this._color}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(56,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector4",1),new Ne(40,"vector4",5)])}]),e}(),Ue=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}s(e,"laya.d3.graphics.VertexPositionNormalColorTangent");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"tangent",function(){return this._tangent}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"color",function(){return this._color}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(52,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector4",1),new Ne(40,"vector3",5)])}]),e}(),He=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}s(e,"laya.d3.graphics.VertexPositionNormalColorTexture");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"textureCoordinate",function(){return this._textureCoordinate}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"color",function(){return this._color}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(48,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector4",1),new Ne(40,"vector2",2)])}]),e}(),Ge=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}s(e,"laya.d3.graphics.VertexPositionNormalColorTexture0Texture1");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"color",function(){return this._color}),l(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(56,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector4",1),new Ne(40,"vector2",2),new Ne(48,"vector2",15)])}]),e}(),ze=function(){function e(e,t,n,i,r,a,o){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=o}s(e,"laya.d3.graphics.VertexPositionNormalColorTexture0Texture1Skin");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"blendWeight",function(){return this._blendWeight}),l(0,t,"color",function(){return this._color}),l(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),l(0,t,"blendIndex",function(){return this._blendIndex}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(88,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector4",1),new Ne(40,"vector2",2),new Ne(48,"vector2",15),new Ne(56,"vector4",7),new Ne(72,"vector4",6)])}]),e}(),We=function(){function e(e,t,n,i,r,a,o,s){this._position=null,this._normal=null,this._color=null,this._textureCoordinate0=null,this._textureCoordinate1=null,this._blendIndex=null,this._blendWeight=null,this._tangent=null,this._position=e,this._normal=t,this._color=n,this._textureCoordinate0=i,this._textureCoordinate1=r,this._tangent=a,this._blendIndex=o,this._blendWeight=s}s(e,"laya.d3.graphics.VertexPositionNormalColorTexture0Texture1SkinSTangent");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"tangent",function(){return this._tangent}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"blendWeight",function(){return this._blendWeight}),l(0,t,"color",function(){return this._color}),l(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),l(0,t,"blendIndex",function(){return this._blendIndex}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(104,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector4",1),new Ne(40,"vector2",2),new Ne(48,"vector2",15),new Ne(56,"vector4",7),new Ne(72,"vector4",6),new Ne(88,"vector4",5)])}]),e}(),ke=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}s(e,"laya.d3.graphics.VertexPositionNormalColorTexture0Texture1SkinTangent");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),t.VertexPositionNormalColorTexture0SkinTangent=function(e,t,n,i,r,a,o,s){this._position=e,this._normal=t,this._color=n,this._textureCoordinate0=i,this._textureCoordinate1=r,this._tangent=a,this._blendIndex=o,this._blendWeight=s},l(0,t,"tangent",function(){return this._tangent}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"blendWeight",function(){return this._blendWeight}),l(0,t,"color",function(){return this._color}),l(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),l(0,t,"blendIndex",function(){return this._blendIndex}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(100,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector4",1),new Ne(40,"vector2",2),new Ne(48,"vector2",15),new Ne(56,"vector4",7),new Ne(72,"vector4",6),new Ne(88,"vector3",5)])}]),e}(),Xe=function(){function e(e,t,n,i,r,a){this._position=null,this._normal=null,this._color=null,this._textureCoordinate0=null,this._textureCoordinate1=null,this._tangent=null,this._position=e,this._normal=t,this._color=n,this._textureCoordinate0=i,this._textureCoordinate1=r,this._tangent=a}s(e,"laya.d3.graphics.VertexPositionNormalColorTexture0Texture1STangent");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"tangent",function(){return this._tangent}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"color",function(){return this._color}),l(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(72,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector4",1),new Ne(40,"vector2",2),new Ne(48,"vector2",15),new Ne(56,"vector4",5)])}]),e}(),Ze=function(){function e(){this._position=null,this._normal=null,this._color=null,this._textureCoordinate0=null,this._textureCoordinate1=null,this._tangent=null}s(e,"laya.d3.graphics.VertexPositionNormalColorTexture0Texture1Tangent");var t=e.prototype;return a.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},l(0,t,"tangent",function(){return this._tangent}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"color",function(){return this._color}),l(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(68,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector4",1),new Ne(40,"vector2",2),new Ne(48,"vector2",15),new Ne(56,"vector3",5)])}]),e}(),Ye=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}s(e,"laya.d3.graphics.VertexPositionNormalColorTextureSkin");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"textureCoordinate",function(){return this._textureCoordinate}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"blendWeight",function(){return this._blendWeight}),l(0,t,"color",function(){return this._color}),l(0,t,"blendIndex",function(){return this._blendIndex}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(80,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector4",1),new Ne(40,"vector2",2),new Ne(48,"vector4",7),new Ne(64,"vector4",6)])}]),e}(),je=function(){function e(e,t,n,i,r,a,o){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=o}s(e,"laya.d3.graphics.VertexPositionNormalColorTextureSkinSTangent");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"tangent",function(){return this._tangent}),l(0,t,"textureCoordinate",function(){return this._textureCoordinate}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"blendWeight",function(){return this._blendWeight}),l(0,t,"color",function(){return this._color}),l(0,t,"blendIndex",function(){return this._blendIndex}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(96,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector4",1),new Ne(40,"vector2",2),new Ne(48,"vector4",7),new Ne(64,"vector4",6),new Ne(80,"vector4",5)])}]),e}(),Ke=function(){function e(e,t,n,i,r,a,o){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=o}s(e,"laya.d3.graphics.VertexPositionNormalColorTextureSkinTangent");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"tangent",function(){return this._tangent}),l(0,t,"textureCoordinate",function(){return this._textureCoordinate}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"blendWeight",function(){return this._blendWeight}),l(0,t,"color",function(){return this._color}),l(0,t,"blendIndex",function(){return this._blendIndex}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(92,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector4",1),new Ne(40,"vector2",2),new Ne(48,"vector4",7),new Ne(64,"vector4",6),new Ne(80,"vector3",5)])}]),e}(),qe=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}s(e,"laya.d3.graphics.VertexPositionNormalColorTextureSTangent");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"tangent",function(){return this._tangent}),l(0,t,"textureCoordinate",function(){return this._textureCoordinate}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"color",function(){return this._color}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(64,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector4",1),new Ne(40,"vector2",2),new Ne(48,"vector4",5)])}]),e}(),Qe=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}s(e,"laya.d3.graphics.VertexPositionNormalColorTextureTangent");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"tangent",function(){return this._tangent}),l(0,t,"textureCoordinate",function(){return this._textureCoordinate}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"color",function(){return this._color}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(60,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector4",1),new Ne(40,"vector2",2),new Ne(48,"vector3",5)])}]),e}(),$e=function(){function e(e,t,n){this._position=null,this._normal=null,this._tangent=null,this._position=e,this._normal=t,this._tangent=n}s(e,"laya.d3.graphics.VertexPositionNormalSTangent");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"tangent",function(){return this._tangent}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(40,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector4",5)])}]),e}(),Je=function(){function e(e,t,n){this._position=null,this._normal=null,this._tangent=null,this._position=e,this._normal=t,this._tangent=n}s(e,"laya.d3.graphics.VertexPositionNormalTangent");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"tangent",function(){return this._tangent}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(36,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector3",5)])}]),e}(),et=function(){function e(e,t,n){this._position=null,this._normal=null,this._textureCoordinate=null,this._position=e,this._normal=t,this._textureCoordinate=n}s(e,"laya.d3.graphics.VertexPositionNormalTexture");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"textureCoordinate",function(){return this._textureCoordinate}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(32,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector2",2)])}]),e}(),tt=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}s(e,"laya.d3.graphics.VertexPositionNormalTexture0Texture1");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(40,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector2",2),new Ne(32,"vector2",15)])}]),e}(),nt=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}s(e,"laya.d3.graphics.VertexPositionNormalTexture0Texture1Skin");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),l(0,t,"blendIndex",function(){return this._blendIndex}),l(0,t,"blendWeight",function(){return this._blendWeight}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(72,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector2",2),new Ne(32,"vector2",15),new Ne(40,"vector4",7),new Ne(56,"vector4",6)])}]),e}(),it=function(){function e(e,t,n,i,r,a,o){this._position=null,this._normal=null,this._textureCoordinate0=null,this._textureCoordinate1=null,this._blendIndex=null,this._blendWeight=null,this._tangent=null,this._position=e,this._normal=t,this._textureCoordinate0=n,this._textureCoordinate1=i,this._tangent=r,this._blendIndex=a,this._blendWeight=o}s(e,"laya.d3.graphics.VertexPositionNormalTexture0Texture1SkinSTangent");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"tangent",function(){return this._tangent}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),l(0,t,"blendIndex",function(){return this._blendIndex}),l(0,t,"blendWeight",function(){return this._blendWeight}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(88,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector2",2),new Ne(32,"vector2",15),new Ne(40,"vector4",7),new Ne(56,"vector4",6),new Ne(72,"vector4",5)])}]),e}(),rt=function(){function e(){this._position=null,this._normal=null,this._textureCoordinate0=null,this._textureCoordinate1=null,this._blendIndex=null,this._blendWeight=null,this._tangent=null}s(e,"laya.d3.graphics.VertexPositionNormalTexture0Texture1SkinTangent");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),t.VertexPositionNormalTexture0SkinTangent=function(e,t,n,i,r,a,o){this._position=e,this._normal=t,this._textureCoordinate0=n,this._textureCoordinate1=i,this._tangent=r,this._blendIndex=a,this._blendWeight=o},l(0,t,"tangent",function(){return this._tangent}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),l(0,t,"blendIndex",function(){return this._blendIndex}),l(0,t,"blendWeight",function(){return this._blendWeight}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(84,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector2",2),new Ne(32,"vector2",15),new Ne(40,"vector4",7),new Ne(56,"vector4",6),new Ne(72,"vector3",5)])}]),e}(),at=function(){function e(e,t,n,i,r){this._position=null,this._normal=null,this._textureCoordinate0=null,this._textureCoordinate1=null,this._tangent=null,this._position=e,this._normal=t,this._textureCoordinate0=n,this._textureCoordinate1=i,this._tangent=r}s(e,"laya.d3.graphics.VertexPositionNormalTexture0Texture1STangent");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"tangent",function(){return this._tangent}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(56,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector2",2),new Ne(32,"vector2",15),new Ne(40,"vector4",5)])}]),e}(),ot=function(){function e(){this._position=null,this._normal=null,this._textureCoordinate0=null,this._textureCoordinate1=null,this._tangent=null}s(e,"laya.d3.graphics.VertexPositionNormalTexture0Texture1Tangent");var t=e.prototype;return a.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},l(0,t,"tangent",function(){return this._tangent}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(52,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector2",2),new Ne(32,"vector2",15),new Ne(40,"vector3",5)])}]),e}(),st=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}s(e,"laya.d3.graphics.VertexPositionNormalTextureSkin");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"textureCoordinate",function(){return this._textureCoordinate}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"blendIndex",function(){return this._blendIndex}),l(0,t,"blendWeight",function(){return this._blendWeight}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(64,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector2",2),new Ne(32,"vector4",7),new Ne(48,"vector4",6)])}]),e}(),lt=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}s(e,"laya.d3.graphics.VertexPositionNormalTextureSkinSTangent");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"tangent",function(){return this._tangent}),l(0,t,"textureCoordinate",function(){return this._textureCoordinate}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"blendIndex",function(){return this._blendIndex}),l(0,t,"blendWeight",function(){return this._blendWeight}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(80,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector2",2),new Ne(32,"vector4",7),new Ne(48,"vector4",6),new Ne(64,"vector4",5)])}]),e}(),ht=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}s(e,"laya.d3.graphics.VertexPositionNormalTextureSkinTangent");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"tangent",function(){return this._tangent}),l(0,t,"textureCoordinate",function(){return this._textureCoordinate}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"blendIndex",function(){return this._blendIndex}),l(0,t,"blendWeight",function(){return this._blendWeight}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(76,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector2",2),new Ne(32,"vector4",7),new Ne(48,"vector4",6),new Ne(64,"vector3",5)])}]),e}(),_t=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}s(e,"laya.d3.graphics.VertexPositionNormalTextureSTangent");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"tangent",function(){return this._tangent}),l(0,t,"textureCoordinate",function(){return this._textureCoordinate}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(48,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector2",2),new Ne(32,"vector4",5)])}]),e}(),ut=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}s(e,"laya.d3.graphics.VertexPositionNormalTextureTangent");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"tangent",function(){return this._tangent}),l(0,t,"textureCoordinate",function(){return this._textureCoordinate}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(44,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector2",2),new Ne(32,"vector3",5)])}]),e}(),ct=function(){function e(e,t,n){this._position=null,this._normal=null,this._textureCoordinate=null,this._position=e,this._normal=t,this._textureCoordinate=n}s(e,"laya.d3.graphics.VertexPositionNTBTexture");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"textureCoordinate",function(){return this._textureCoordinate}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(56,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector3",5),new Ne(36,"vector3",4),new Ne(48,"vector2",2)])}]),e}(),dt=function(){function e(e,t,n,i,r,a,o,s){this._position=null,this._normal=null,this._textureCoordinate0=null,this._textureCoordinate1=null,this._blendIndex=null,this._blendWeight=null,this._tangent=null,this.binormal=null,this._position=e,this._normal=t,this._textureCoordinate0=i,this._textureCoordinate1=r,this._tangent=a,n=n,this._blendIndex=o,this._blendWeight=s}s(e,"laya.d3.graphics.VertexPositionNTBTexture0Texture1Skin");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"tangent",function(){return this._tangent}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),l(0,t,"blendIndex",function(){return this._blendIndex}),l(0,t,"blendWeight",function(){return this._blendWeight}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(96,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector3",5),new Ne(36,"vector3",4),new Ne(48,"vector2",2),new Ne(56,"vector2",15),new Ne(64,"vector4",7),new Ne(80,"vector4",6)])}]),e}(),ft=function(){function e(e,t,n){this._position=null,this._normal=null,this._textureCoordinate=null,this._position=e,this._normal=t,this._textureCoordinate=n}s(e,"laya.d3.graphics.VertexPositionNTBTextureSkin");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"textureCoordinate",function(){return this._textureCoordinate}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(88,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector3",5),new Ne(36,"vector3",4),new Ne(48,"vector2",2),new Ne(56,"vector4",7),new Ne(72,"vector4",6)])}]),e}(),mt=function(){function e(e,t,n,i){this._position=null,this._normal=null,this._textureCoord0=null,this._textureCoord1=null,this._position=e,this._normal=t,this._textureCoord0=n,this._textureCoord1=i}s(e,"laya.d3.graphics.VertexPositionTerrain");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"normal",function(){return this._normal}),l(0,t,"position",function(){return this._position}),l(0,t,"textureCoord0",function(){return this._textureCoord0}),l(0,t,"textureCoord1",function(){return this._textureCoord1}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(40,[new Ne(0,"vector3",0),new Ne(12,"vector3",3),new Ne(24,"vector2",2),new Ne(32,"vector2",15)])}]),e}(),pt=function(){function e(e,t){this._position=null,this._textureCoordinate0=null,this._position=e,this._textureCoordinate0=t}s(e,"laya.d3.graphics.VertexPositionTexture0");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"position",function(){return this._position}),l(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(20,[new Ne(0,"vector3",0),new Ne(12,"vector2",2)])}]),e}(),vt=function(){function e(e,t,n,i,r,a,o,s,l,h,_,u,c,d){this._cornerTextureCoordinate=null,this._positionStartLifeTime=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._positionStartLifeTime=t,this._velocity=n,this._startColor=i,this._startSize=r,this._startRotation0=a,this._startRotation1=o,this._startRotation2=s,this._startLifeTime=l,this._time=h,this._startSpeed=_,this._randoms0=this.random0,this._randoms1=this.random1,this._simulationWorldPostion=d}s(e,"laya.d3.graphics.VertexShurikenParticleBillboard");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"cornerTextureCoordinate",function(){return this._cornerTextureCoordinate}),l(0,t,"random1",function(){return this._randoms1}),l(0,t,"startRotation2",function(){return this._startRotation2}),l(0,t,"positionStartLifeTime",function(){return this._positionStartLifeTime}),l(0,t,"velocity",function(){return this._velocity}),l(0,t,"random0",function(){return this._randoms0}),l(0,t,"startSize",function(){return this._startSize}),l(0,t,"startColor",function(){return this._startColor}),l(0,t,"startRotation0",function(){return this._startRotation0}),l(0,t,"startRotation1",function(){return this._startRotation1}),l(0,t,"startLifeTime",function(){return this._startLifeTime}),l(0,t,"time",function(){return this._time}),l(0,t,"startSpeed",function(){return this._startSpeed}),l(0,t,"simulationWorldPostion",function(){return this._simulationWorldPostion}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(152,[new Ne(0,"vector4",17),new Ne(16,"vector4",30),new Ne(32,"vector4",32),new Ne(48,"vector4",19),new Ne(64,"vector3",20),new Ne(76,"vector3",22),new Ne(88,"single",31),new Ne(92,"vector4",34),new Ne(108,"vector4",35),new Ne(124,"vector3",36),new Ne(136,"vector4",37)])}]),e}(),Et=function(){function e(e,t,n,i,r,a,o,s,l,h,_,u,c,d){this._cornerTextureCoordinate=null,this._positionStartLifeTime=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._positionStartLifeTime=t,this._velocity=n,this._startColor=i,this._startSize=r,this._startRotation0=a,this._startRotation1=o,this._startRotation2=s,this._startLifeTime=l,this._time=h,this._startSpeed=_,this._randoms0=this.random0,this._randoms1=this.random1,this._simulationWorldPostion=d}s(e,"laya.d3.graphics.VertexShurikenParticleMesh");var t=e.prototype;return a.imps(t,{"laya.d3.graphics.IVertex":!0}),l(0,t,"cornerTextureCoordinate",function(){return this._cornerTextureCoordinate}),l(0,t,"velocity",function(){return this._velocity}),l(0,t,"position",function(){return this._positionStartLifeTime}),l(0,t,"random0",function(){return this._randoms0}),l(0,t,"startSize",function(){return this._startSize}),l(0,t,"startColor",function(){return this._startColor}),l(0,t,"startRotation0",function(){return this._startRotation0}),l(0,t,"startRotation1",function(){return this._startRotation1}),l(0,t,"random1",function(){return this._randoms1}),l(0,t,"startRotation2",function(){return this._startRotation2}),l(0,t,"startLifeTime",function(){return this._startLifeTime}),l(0,t,"time",function(){return this._time}),l(0,t,"startSpeed",function(){return this._startSpeed}),l(0,t,"simulationWorldPostion",function(){return this._simulationWorldPostion}),l(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),l(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),o(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(172,[new Ne(0,"vector3",0),new Ne(12,"vector4",1),new Ne(28,"vector2",2),new Ne(36,"vector4",30),new Ne(52,"vector4",32),new Ne(68,"vector4",19),new Ne(84,"vector3",20),new Ne(96,"vector3",22),new Ne(108,"single",31),new Ne(112,"vector4",34),new Ne(128,"vector4",35),new Ne(144,"vector3",36),new Ne(156,"vector4",37)])}]),e}(),gt=function(){function e(e,t,n,i,r,a){this._version=null,this._strings=["BLOCK","DATA","STRINGS"],this._materials=null,this._subMeshes=null,this._materialMap=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=n,this._materials=i,this._subMeshes=r,this._materialMap=a,this._version=t,this._onLoaded(e)}s(e,"laya.d3.loaders.LoadModelV01");var t=e.prototype;return t._onLoaded=function(e){this._readData=e,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(){return this._readData.getUint16(),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 this._materials[e]="null"!==t?S.getRes(this._materialMap[t]):new Dn,!0},t.READ_MESH=function(){switch(this._readString(),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":case"LAYAMODEL:02":var e,t=this._readData.__getBuffer(),n=0,i=this._readData.getUint32(),r=this._readData.getUint32(),a=(new Float32Array(t.slice(i+this._DATA.offset,i+this._DATA.offset+r)),this._readData.getUint32()),o=this._readData.getUint32(),s=new Float32Array(t.slice(a+this._DATA.offset,a+this._DATA.offset+o));for(this.mesh._inverseBindPoses=[],n=0,e=s.length;n<e;n+=16){var l=new Ct(s[n+0],s[n+1],s[n+2],s[n+3],s[n+4],s[n+5],s[n+6],s[n+7],s[n+8],s[n+9],s[n+10],s[n+11],s[n+12],s[n+13],s[n+14],s[n+15]);this.mesh._inverseBindPoses.push(l)}break;default:throw new Error("LoadModel:unknown version.")}return!0},t.READ_SUBMESH=function(){this._readString(),this._readData.getUint8();var t=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(),o=this._readData.getUint32(),s=this._readData.getUint32(),l=this._readData.__getBuffer(),h=new Ht(this._mesh),_=this._getVertexDeclaration(),u=$n.create(_,a/_.vertexStride,35044,!0),c=r+this._DATA.offset,d=l.slice(c,c+a);u.setData(new Float32Array(d)),h._vertexBuffer=u;for(var f=u.vertexDeclaration.getVertexElements(),m=0;m<f.length;m++)h._bufferUsage[f[m].elementUsage]=u;var p=Qn.create("ushort",i/2,35044,!0),v=n+this._DATA.offset,E=l.slice(v,v+i);p.setData(new Uint16Array(E)),h._indexBuffer=p;var g=l.slice(o+this._DATA.offset,o+this._DATA.offset+s);return h._boneIndicesList[0]=new Uint8Array(g),this._subMeshes.push(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,o=!1,s=!1,l=!1,h=0;h<this._shaderAttributes.length;h+=8)switch(this._shaderAttributes[h]){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":o=!0;break;case"BLENDINDICES":s=!0;break;case"TANGENT":a=!0;break;case"BINORMAL":l=!0}var _;return e&&t&&n&&i&&r&&o&&s&&a?_=ke.vertexDeclaration:e&&t&&n&&i&&r&&o&&s?_=ze.vertexDeclaration:e&&t&&i&&r&&o&&s&&a?_=rt.vertexDeclaration:e&&t&&i&&r&&o&&s?_=nt.vertexDeclaration:e&&t&&n&&i&&o&&s&&a?_=Ke.vertexDeclaration:e&&t&&n&&i&&o&&s?_=Ye.vertexDeclaration:e&&t&&a&&l&&i&&o&&s?_=ft.vertexDeclaration:e&&t&&i&&o&&s&&a?_=ht.vertexDeclaration:e&&t&&i&&o&&s?_=st.vertexDeclaration:e&&t&&n&&o&&s&&a?_=Fe.vertexDeclaration:e&&t&&n&&o&&s?_=Le.vertexDeclaration:e&&t&&n&&i&&r&&a?_=Ze.vertexDeclaration:e&&t&&n&&i&&r?_=Ge.vertexDeclaration:e&&t&&i&&r&&a?_=ot.vertexDeclaration:e&&t&&i&&r?_=tt.vertexDeclaration:e&&t&&n&&i&&a?_=Qe.vertexDeclaration:e&&t&&i&&a&&l?_=ct.vertexDeclaration:e&&t&&n&&i?_=He.vertexDeclaration:e&&t&&i&&a?_=ut.vertexDeclaration:e&&t&&i?_=et.vertexDeclaration:e&&t&&n&&a?_=Ue.vertexDeclaration:e&&t&&n&&(_=Pe.vertexDeclaration),_},l(0,t,"mesh",function(){return this._mesh}),e._attrReg=new RegExp("(\\w+)|([:,;])","g"),e}(),Dt=function(){function e(){}return s(e,"laya.d3.loaders.LoadModelV02"),e.parse=function(t,n,i,r,a,o){e._mesh=i,e._materials=r,e._subMeshes=a,e._materialMap=o,e._version=n,e._readData=t,e.READ_DATA(),e.READ_BLOCK(),e.READ_STRINGS();for(var s=0,l=e._BLOCK.count;s<l;s++){e._readData.pos=e._BLOCK.blockStarts[s];var h=e._readData.getUint16(),_=e._strings[h],u=e["READ_"+_];if(null==u)throw new Error("model file err,no this function:"+h+" "+_);u.call()}e._strings.length=0,e._readData=null,e._version=null,e._mesh=null,e._materials=null,e._subMeshes=null,e._materialMap=null},e._readString=function(){return e._strings[e._readData.getUint16()]},e.READ_DATA=function(){e._DATA.offset=e._readData.getUint32(),e._DATA.size=e._readData.getUint32()},e.READ_BLOCK=function(){for(var t=e._BLOCK.count=e._readData.getUint16(),n=e._BLOCK.blockStarts=[],i=e._BLOCK.blockLengths=[],r=0;r<t;r++)n.push(e._readData.getUint32()),i.push(e._readData.getUint32())},e.READ_STRINGS=function(){var t=e._readData.getUint32(),n=e._readData.getUint16(),i=e._readData.pos;e._readData.pos=t+e._DATA.offset;for(var r=0;r<n;r++)e._strings[r]=e._readData.readUTFString();e._readData.pos=i},e.READ_MATERIAL=function(){e._readString(),e._readString();var t=e._readString();return""!==t&&e._materials.push(S.getRes(e._materialMap[t])),!0},e.READ_MESH=function(){e._readString();var t,n=e._readData.__getBuffer(),i=0,r=e._readData.getInt16(),a=e._DATA.offset;for(i=0;i<r;i++){var o=a+e._readData.getUint32(),s=e._readData.getUint32(),l=new Float32Array(n.slice(o,o+s)),h=e._readString().match(e._attrReg),_=e._getVertexDeclaration(h),u=$n.create(_,4*l.length/_.vertexStride,35044,!0);u.setData(l),e._mesh._vertexBuffers.push(u)}var c=a+e._readData.getUint32(),d=e._readData.getUint32(),f=new Uint16Array(n.slice(c,c+d)),m=Qn.create("ushort",d/2,35044,!0);m.setData(f),e._mesh._indexBuffer=m;var p=e._mesh._boneNames=[],v=e._readData.getUint16();for(p.length=v,i=0;i<v;i++)p[i]=e._strings[e._readData.getUint16()];var E=e._readData.getUint32(),g=e._readData.getUint32(),D=(new Float32Array(n.slice(a+E,a+E+g)),e._readData.getUint32()),T=e._readData.getUint32(),S=new Float32Array(n.slice(a+D,a+D+T));for(e._mesh._inverseBindPoses=[],i=0,t=S.length;i<t;i+=16){var x=new Ct(S[i+0],S[i+1],S[i+2],S[i+3],S[i+4],S[i+5],S[i+6],S[i+7],S[i+8],S[i+9],S[i+10],S[i+11],S[i+12],S[i+13],S[i+14],S[i+15]);e._mesh._inverseBindPoses.push(x)}return e._mesh._skinnedDatas=new Float32Array(16*S.length),!0},e.READ_SUBMESH=function(){var t=e._readData.__getBuffer(),n=new Ht(e._mesh),i=e._readData.getInt16(),r=e._readData.getUint32(),a=e._readData.getUint32();n._vertexBuffer=e._mesh._vertexBuffers[i],n._vertexStart=r,n._vertexCount=a;var o=e._readData.getUint32(),s=e._readData.getUint32(),l=e._mesh._indexBuffer;n._indexBuffer=l,n._indexStart=o,n._indexCount=s,n._indices=new Uint16Array(l.getData().buffer,2*o,s);var h=e._DATA.offset,_=n._subIndexBufferStart,u=n._subIndexBufferCount,c=n._boneIndicesList,d=e._readData.getUint16();_.length=d,u.length=d,c.length=d;for(var f=0;f<d;f++){_[f]=e._readData.getUint32(),u[f]=e._readData.getUint32();var m=e._readData.getUint32(),p=e._readData.getUint32();n._boneIndicesList[f]=new Uint8Array(t.slice(h+m,h+m+p))}return e._subMeshes.push(n),!0},e._getVertexDeclaration=function(e){for(var t=!1,n=!1,i=!1,r=!1,a=!1,o=!1,s=!1,l=!1,h=!1,_=0;_<e.length;_++)switch(e[_]){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":l=!0;break;case"TANGENT":o=!0;break;case"BINORMAL":h=!0}var u;return t&&n&&i&&r&&a&&s&&l&&o?u=ke.vertexDeclaration:t&&n&&i&&r&&a&&s&&l?u=ze.vertexDeclaration:t&&n&&r&&a&&s&&l&&o?u=rt.vertexDeclaration:t&&n&&r&&a&&s&&l?u=nt.vertexDeclaration:t&&n&&i&&r&&s&&l&&o?u=Ke.vertexDeclaration:t&&n&&i&&r&&s&&l?u=Ye.vertexDeclaration:t&&n&&r&&s&&l&&o?u=ht.vertexDeclaration:t&&n&&r&&s&&l?u=st.vertexDeclaration:t&&n&&i&&s&&l&&o?u=Fe.vertexDeclaration:t&&n&&i&&s&&l?u=Le.vertexDeclaration:t&&n&&i&&r&&a&&o?u=Ze.vertexDeclaration:t&&n&&i&&r&&a?u=Ge.vertexDeclaration:t&&n&&r&&a&&o?u=ot.vertexDeclaration:t&&n&&r&&a?u=tt.vertexDeclaration:t&&n&&i&&r&&o?u=Qe.vertexDeclaration:t&&n&&r&&o&&h?u=ct.vertexDeclaration:t&&n&&i&&r?u=He.vertexDeclaration:t&&n&&r&&o?u=ut.vertexDeclaration:t&&n&&r?u=et.vertexDeclaration:t&&n&&i&&o?u=Ue.vertexDeclaration:t&&n&&i&&(u=Pe.vertexDeclaration),u},e._attrReg=new RegExp("(\\w+)|([:,;])","g"),e._strings=[],e._readData=null,e._version=null,e._mesh=null,e._materials=null,e._subMeshes=null,e._materialMap=null,o(e,["_BLOCK",function(){return this._BLOCK={count:0}},"_DATA",function(){return this._DATA={offset:0,size:0}}]),e}(),Tt=function(){function e(){}return s(e,"laya.d3.loaders.LoadModelV03"),e.parse=function(t,n,i,r,a){e._mesh=i,e._subMeshes=r,e._materialMap=a,e._version=n,e._readData=t,e.READ_DATA(),e.READ_BLOCK(),e.READ_STRINGS();for(var o=0,s=e._BLOCK.count;o<s;o++){e._readData.pos=e._BLOCK.blockStarts[o];var l=e._readData.getUint16(),h=e._strings[l],_=e["READ_"+h];if(null==_)throw new Error("model file err,no this function:"+l+" "+h);_.call()}e._strings.length=0,e._readData=null,e._version=null,e._mesh=null,e._subMeshes=null,e._materialMap=null},e._readString=function(){return e._strings[e._readData.getUint16()]},e.READ_DATA=function(){e._DATA.offset=e._readData.getUint32(),e._DATA.size=e._readData.getUint32()},e.READ_BLOCK=function(){for(var t=e._BLOCK.count=e._readData.getUint16(),n=e._BLOCK.blockStarts=[],i=e._BLOCK.blockLengths=[],r=0;r<t;r++)n.push(e._readData.getUint32()),i.push(e._readData.getUint32())},e.READ_STRINGS=function(){var t=e._readData.getUint32(),n=e._readData.getUint16(),i=e._readData.pos;e._readData.pos=t+e._DATA.offset;for(var r=0;r<n;r++)e._strings[r]=e._readData.readUTFString();e._readData.pos=i},e.READ_MESH=function(){e._readString();var t,n=e._readData.__getBuffer(),i=0,r=e._readData.getInt16(),a=e._DATA.offset;for(i=0;i<r;i++){var o,s=a+e._readData.getUint32(),l=e._readData.getUint32(),h=new Float32Array(n.slice(s,s+l)),_=e._readString();switch(e._version){case"LAYAMODEL:03":o=e._vertexDeclarationMap_Discard[_];break;case"LAYAMODEL:0301":o=e._vertexDeclarationMap[_];break;default:throw new Error("LoadModelV03: unknown version.")}if(!o)throw new Error("LoadModelV03: unknown vertexDeclaration.");var u=$n.create(o,4*h.length/o.vertexStride,35044,!0);u.setData(h),e._mesh._vertexBuffers.push(u)}var c=a+e._readData.getUint32(),d=e._readData.getUint32(),f=new Uint16Array(n.slice(c,c+d)),m=Qn.create("ushort",d/2,35044,!0);m.setData(f),e._mesh._indexBuffer=m;var p=e._mesh._boneNames=[],v=e._readData.getUint16();for(p.length=v,i=0;i<v;i++)p[i]=e._strings[e._readData.getUint16()];e._readData.pos+=8;var E=e._readData.getUint32(),g=e._readData.getUint32(),D=new Float32Array(n.slice(a+E,a+E+g));for(e._mesh._inverseBindPoses=[],i=0,t=D.length;i<t;i+=16){var T=new Ct(D[i+0],D[i+1],D[i+2],D[i+3],D[i+4],D[i+5],D[i+6],D[i+7],D[i+8],D[i+9],D[i+10],D[i+11],D[i+12],D[i+13],D[i+14],D[i+15]);e._mesh._inverseBindPoses.push(T)}return e._mesh._skinnedDatas=new Float32Array(16*D.length),!0},e.READ_SUBMESH=function(){var t=e._readData.__getBuffer(),n=new Ht(e._mesh),i=e._readData.getInt16(),r=e._readData.getUint32(),a=e._readData.getUint32();n._vertexBuffer=e._mesh._vertexBuffers[i],n._vertexStart=r,n._vertexCount=a;var o=e._readData.getUint32(),s=e._readData.getUint32(),l=e._mesh._indexBuffer;n._indexBuffer=l,n._indexStart=o,n._indexCount=s,n._indices=new Uint16Array(l.getData().buffer,2*o,s);var h=e._DATA.offset,_=n._subIndexBufferStart,u=n._subIndexBufferCount,c=n._boneIndicesList,d=e._readData.getUint16();_.length=d,u.length=d,c.length=d;for(var f=0;f<d;f++){_[f]=e._readData.getUint32(),u[f]=e._readData.getUint32();var m=e._readData.getUint32(),p=e._readData.getUint32();c[f]=new Uint8Array(t.slice(h+m,h+m+p))}return e._subMeshes.push(n),!0},e._strings=[],e._readData=null,e._version=null,e._mesh=null,e._subMeshes=null,e._materialMap=null,o(e,["_vertexDeclarationMap_Discard",function(){return this._vertexDeclarationMap_Discard={"POSITION,NORMAL,COLOR,UV,UV1,BLENDWEIGHT,BLENDINDICES,TANGENT":ke.vertexDeclaration,"POSITION,NORMAL,COLOR,UV,UV1,BLENDWEIGHT,BLENDINDICES":ze.vertexDeclaration,"POSITION,NORMAL,TANGENT,BINORMAL,UV,UV1,BLENDWEIGHT,BLENDINDICES,":dt.vertexDeclaration,"POSITION,NORMAL,UV,UV1,BLENDWEIGHT,BLENDINDICES,TANGENT":rt.vertexDeclaration,"POSITION,NORMAL,UV,UV1,BLENDWEIGHT,BLENDINDICES":nt.vertexDeclaration,"POSITION,NORMAL,COLOR,UV,BLENDWEIGHT,BLENDINDICES,TANGENT":Ke.vertexDeclaration,"POSITION,NORMAL,COLOR,UV,BLENDWEIGHT,BLENDINDICES":Ye.vertexDeclaration,"POSITION,NORMAL,UV,BLENDWEIGHT,BLENDINDICES,TANGENT":ht.vertexDeclaration,"POSITION,NORMAL,UV,BLENDWEIGHT,BLENDINDICES":st.vertexDeclaration,"POSITION,NORMAL,COLOR,BLENDWEIGHT,BLENDINDICES,TANGENT":Fe.vertexDeclaration,"POSITION,NORMAL,COLOR,BLENDWEIGHT,BLENDINDICES":Le.vertexDeclaration,"POSITION,NORMAL,COLOR,UV,UV1,TANGENT":Ze.vertexDeclaration,"POSITION,NORMAL,COLOR,UV,UV1":Ge.vertexDeclaration,"POSITION,NORMAL,UV,UV1,TANGENT":ot.vertexDeclaration,"POSITION,NORMAL,UV,UV1":tt.vertexDeclaration,"POSITION,NORMAL,COLOR,UV,TANGENT":Qe.vertexDeclaration,"POSITION,NORMAL,UV,TANGENT,BINORMAL":ct.vertexDeclaration,"POSITION,NORMAL,COLOR,UV":He.vertexDeclaration,"POSITION,NORMAL,UV,TANGENT":ut.vertexDeclaration,"POSITION,NORMAL,UV":et.vertexDeclaration,"POSITION,NORMAL,COLOR,TANGENT":Ue.vertexDeclaration,"POSITION,NORMAL,COLOR":Pe.vertexDeclaration,"POSITION,NORMAL,TANGENT":Je.vertexDeclaration,"POSITION,NORMAL":Ve.vertexDeclaration,"POSITION,UV":pt.vertexDeclaration,POSITION:we.vertexDeclaration}},"_vertexDeclarationMap",function(){return this._vertexDeclarationMap={"POSITION,NORMAL,COLOR,UV,UV1,BLENDWEIGHT,BLENDINDICES,TANGENT":We.vertexDeclaration,"POSITION,NORMAL,COLOR,UV,UV1,BLENDWEIGHT,BLENDINDICES":ze.vertexDeclaration,"POSITION,NORMAL,TANGENT,BINORMAL,UV,UV1,BLENDWEIGHT,BLENDINDICES,":dt.vertexDeclaration,"POSITION,NORMAL,UV,UV1,BLENDWEIGHT,BLENDINDICES,TANGENT":it.vertexDeclaration,"POSITION,NORMAL,UV,UV1,BLENDWEIGHT,BLENDINDICES":nt.vertexDeclaration,"POSITION,NORMAL,COLOR,UV,BLENDWEIGHT,BLENDINDICES,TANGENT":je.vertexDeclaration,"POSITION,NORMAL,COLOR,UV,BLENDWEIGHT,BLENDINDICES":Ye.vertexDeclaration,"POSITION,NORMAL,UV,BLENDWEIGHT,BLENDINDICES,TANGENT":lt.vertexDeclaration,"POSITION,NORMAL,UV,BLENDWEIGHT,BLENDINDICES":st.vertexDeclaration,"POSITION,NORMAL,COLOR,BLENDWEIGHT,BLENDINDICES,TANGENT":be.vertexDeclaration,"POSITION,NORMAL,COLOR,BLENDWEIGHT,BLENDINDICES":Le.vertexDeclaration,"POSITION,NORMAL,COLOR,UV,UV1,TANGENT":Xe.vertexDeclaration,"POSITION,NORMAL,COLOR,UV,UV1":Ge.vertexDeclaration,"POSITION,NORMAL,UV,UV1,TANGENT":at.vertexDeclaration,"POSITION,NORMAL,UV,UV1":tt.vertexDeclaration,"POSITION,NORMAL,COLOR,UV,TANGENT":qe.vertexDeclaration,"POSITION,NORMAL,UV,TANGENT,BINORMAL":ct.vertexDeclaration,"POSITION,NORMAL,COLOR,UV":He.vertexDeclaration,"POSITION,NORMAL,UV,TANGENT":_t.vertexDeclaration,"POSITION,NORMAL,UV":et.vertexDeclaration,"POSITION,NORMAL,COLOR,TANGENT":Be.vertexDeclaration,"POSITION,NORMAL,COLOR":Pe.vertexDeclaration,"POSITION,NORMAL,TANGENT":$e.vertexDeclaration,"POSITION,NORMAL":Ve.vertexDeclaration,"POSITION,UV":pt.vertexDeclaration,POSITION:we.vertexDeclaration}},"_BLOCK",function(){return this._BLOCK={count:0}},"_DATA",function(){return this._DATA={offset:0,size:0}}]),e}(),St=function(){function e(){}return s(e,"laya.d3.loaders.MeshReader"),e.read=function(t,n,i,r,a){var o=new v(t);o.pos=0;var s=o.readUTFString();switch(s){case"LAYAMODEL:01":case"LAYASKINANI:01":e._readVersion01(o,s,n,i,r,a);break;case"LAYAMODEL:02":Dt.parse(o,s,n,i,r,a);break;case"LAYAMODEL:03":case"LAYAMODEL:0301":Tt.parse(o,s,n,r,a);break;default:throw new Error("MeshReader: unknown mesh version.")}n._setSubMeshes(r)},e._readVersion01=function(e,t,n,i,r,a){new gt(e,t,n,i,r,a)},e}(),xt=function(){function e(e,t){this.min=null,this.max=null,this.min=e,this.max=t}s(e,"laya.d3.math.BoundBox");var t=e.prototype;return a.imps(t,{"laya.d3.core.IClone":!0}),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],o=n[0],s=n[1],l=n[2];e[0]=new bt(i,s,l),e[1]=new bt(o,s,l),e[2]=new bt(o,r,l),e[3]=new bt(i,r,l),e[4]=new bt(i,s,a),e[5]=new bt(o,s,a),e[6]=new bt(o,r,a),e[7]=new bt(i,r,a)},t.toDefault=function(){this.min.toDefault(),this.max.toDefault()},t.cloneTo=function(e){var t=e;this.min.cloneTo(t.min),this.max.cloneTo(t.max)},t.clone=function(){var e=new this.constructor(new bt,new bt);return this.cloneTo(e),e},e.createfromPoints=function(e,t){if(null==e)throw new Error("points");var n=t.min,i=t.max,r=n.elements;r[0]=Number.MAX_VALUE,r[1]=Number.MAX_VALUE,r[2]=Number.MAX_VALUE;var a=i.elements;a[0]=-Number.MAX_VALUE,a[1]=-Number.MAX_VALUE,a[2]=-Number.MAX_VALUE;for(var o=0,s=e.length;o<s;++o)bt.min(n,e[o],n),bt.max(i,e[o],i)},e.merge=function(e,t,n){bt.min(e.min,t.min,n.min),bt.max(e.max,t.max,n.max)},e}(),Mt=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 Ot(new bt),this._far=new Ot(new bt),this._left=new Ot(new bt),this._right=new Ot(new bt),this._top=new Ot(new bt),this._bottom=new Ot(new bt),e._getPlanesFromMatrix(this._matrix,this._near,this._far,this._left,this._right,this._top,this._bottom)}s(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){e._get3PlaneInterPoint(this._near,this._bottom,this._right).cloneTo(t[0]),e._get3PlaneInterPoint(this._near,this._top,this._right).cloneTo(t[1]),e._get3PlaneInterPoint(this._near,this._top,this._left).cloneTo(t[2]),e._get3PlaneInterPoint(this._near,this._bottom,this._left).cloneTo(t[3]),e._get3PlaneInterPoint(this._far,this._bottom,this._right).cloneTo(t[4]),e._get3PlaneInterPoint(this._far,this._top,this._right).cloneTo(t[5]),e._get3PlaneInterPoint(this._far,this._top,this._left).cloneTo(t[6]),e._get3PlaneInterPoint(this._far,this._bottom,this._left).cloneTo(t[7])},t.containsPoint=function(e){for(var t=Ot.PlaneIntersectionType_Front,n=Ot.PlaneIntersectionType_Front,i=0;i<6;i++){switch(i){case 0:n=At.intersectsPlaneAndPoint(this._near,e);break;case 1:n=At.intersectsPlaneAndPoint(this._far,e);break;case 2:n=At.intersectsPlaneAndPoint(this._left,e);break;case 3:n=At.intersectsPlaneAndPoint(this._right,e);break;case 4:n=At.intersectsPlaneAndPoint(this._top,e);break;case 5:n=At.intersectsPlaneAndPoint(this._bottom,e)}switch(n){case Ot.PlaneIntersectionType_Back:return 0;case Ot.PlaneIntersectionType_Intersecting:t=Ot.PlaneIntersectionType_Intersecting}}switch(t){case Ot.PlaneIntersectionType_Intersecting:return 2;default:return 1}},t.containsBoundBox=function(t){for(var n,i=e._tempV30,r=e._tempV31,a=1,o=0;o<6;o++){if(n=this.getPlane(o),this._getBoxToPlanePVertexNVertex(t,n.normal,i,r),At.intersectsPlaneAndPoint(n,i)===Ot.PlaneIntersectionType_Back)return 0;At.intersectsPlaneAndPoint(n,r)===Ot.PlaneIntersectionType_Back&&(a=2)}return a},t.containsBoundSphere=function(e){for(var t=Ot.PlaneIntersectionType_Front,n=Ot.PlaneIntersectionType_Front,i=0;i<6;i++){switch(i){case 0:n=At.intersectsPlaneAndSphere(this._near,e);break;case 1:n=At.intersectsPlaneAndSphere(this._far,e);break;case 2:n=At.intersectsPlaneAndSphere(this._left,e);break;case 3:n=At.intersectsPlaneAndSphere(this._right,e);break;case 4:n=At.intersectsPlaneAndSphere(this._top,e);break;case 5:n=At.intersectsPlaneAndSphere(this._bottom,e)}switch(n){case Ot.PlaneIntersectionType_Back:return 0;case Ot.PlaneIntersectionType_Intersecting:t=Ot.PlaneIntersectionType_Intersecting}}switch(t){case Ot.PlaneIntersectionType_Intersecting:return 2;default:return 1}},t._getBoxToPlanePVertexNVertex=function(e,t,n,i){var r=e.min,a=r.elements,o=e.max,s=o.elements,l=t.elements,h=l[0],_=l[1],u=l[2];r.cloneTo(n);var c=n.elements;h>=0&&(c[0]=s[0]),_>=0&&(c[1]=s[1]),u>=0&&(c[2]=s[2]),o.cloneTo(i);var d=i.elements;h>=0&&(d[0]=a[0]),_>=0&&(d[1]=a[1]),u>=0&&(d[2]=a[2])},l(0,t,"top",function(){return this._top}),l(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)}),l(0,t,"near",function(){return this._near}),l(0,t,"far",function(){return this._far}),l(0,t,"left",function(){return this._left}),l(0,t,"right",function(){return this._right}),l(0,t,"bottom",function(){return this._bottom}),e._getPlanesFromMatrix=function(e,t,n,i,r,a,o){var s=e.elements,l=s[0],h=s[1],_=s[2],u=s[3],c=s[4],d=s[5],f=s[6],m=s[7],p=s[8],v=s[9],E=s[10],g=s[11],D=s[12],T=s[13],S=s[14],x=s[15],M=t.normal.elements;M[0]=u+_,M[1]=m+f,M[2]=g+E,t.distance=x+S,t.normalize();var R=n.normal.elements;R[0]=u-_,R[1]=m-f,R[2]=g-E,n.distance=x-S,n.normalize();var A=i.normal.elements;A[0]=u+l,A[1]=m+c,A[2]=g+p,i.distance=x+D,i.normalize();var I=r.normal.elements;I[0]=u-l,I[1]=m-c,I[2]=g-p,r.distance=x-D,r.normalize();var y=a.normal.elements;y[0]=u-h,y[1]=m-d,y[2]=g-v,a.distance=x-T,a.normalize();var C=o.normal.elements;C[0]=u+h,C[1]=m+d,C[2]=g+v,o.distance=x+T,o.normalize()},e._get3PlaneInterPoint=function(t,n,i){var r=t.normal,a=n.normal,o=i.normal;bt.cross(a,o,e._tempV30),bt.cross(o,r,e._tempV31),bt.cross(r,a,e._tempV32);var s=bt.dot(r,e._tempV30),l=bt.dot(a,e._tempV31),h=bt.dot(o,e._tempV32);return bt.scale(e._tempV30,-t.distance/s,e._tempV33),bt.scale(e._tempV31,-n.distance/l,e._tempV34),bt.scale(e._tempV32,-i.distance/h,e._tempV35),bt.add(e._tempV33,e._tempV34,e._tempV36),bt.add(e._tempV35,e._tempV36,e._tempV37),e._tempV37},o(e,["_tempV30",function(){return this._tempV30=new bt},"_tempV31",function(){return this._tempV31=new bt},"_tempV32",function(){return this._tempV32=new bt},"_tempV33",function(){return this._tempV33=new bt},"_tempV34",function(){return this._tempV34=new bt},"_tempV35",function(){return this._tempV35=new bt},"_tempV36",function(){return this._tempV36=new bt},"_tempV37",function(){return this._tempV37=new bt}]),e}(),Rt=function(){function e(e,t){this.center=null,this.radius=NaN,this.center=e,this.radius=t}s(e,"laya.d3.math.BoundSphere");var t=e.prototype;return a.imps(t,{"laya.d3.core.IClone":!0}),t.toDefault=function(){this.center.toDefault(),this.radius=0},t.intersectsRayDistance=function(e){return At.intersectsRayAndSphereRD(e,this)},t.intersectsRayPoint=function(e,t){return At.intersectsRayAndSphereRP(e,this,t)},t.cloneTo=function(e){var t=e;this.center.cloneTo(t.center),t.radius=this.radius},t.clone=function(){var e=new this.constructor(new bt,new bt);return this.cloneTo(e),e},e.createFromSubPoints=function(t,n,i,r){if(null==t)throw new Error("points");if(n<0||n>=t.length)throw new Error("start"+n+"Must be in the range [0, "+(t.length-1)+"]");if(i<0||n+i>t.length)throw new Error("count"+i+"Must be in the range <= "+t.length+"}");var a=n+i,o=e._tempVector3;o.elements[0]=0,o.elements[1]=0,o.elements[2]=0;for(var s=n;s<a;++s)bt.add(t[s],o,o);var l=r.center;bt.scale(o,1/i,l);var h=0;for(s=n;s<a;++s){var _=bt.distanceSquared(l,t[s]);_>h&&(h=_)}r.radius=Math.sqrt(h)},e.createfromPoints=function(t,n){if(null==t)throw new Error("points");e.createFromSubPoints(t,0,t.length,n)},o(e,["_tempVector3",function(){return this._tempVector3=new bt}]),e}(),At=function(){function e(){}return s(e,"laya.d3.math.Collision"),e.distancePlaneToPoint=function(e,t){return bt.dot(e.normal,t)-e.distance},e.distanceBoxToPoint=function(e,t){var n=e.min.elements,i=n[0],r=n[1],a=n[2],o=e.max.elements,s=o[0],l=o[1],h=o[2],_=t.elements,u=_[0],c=_[1],d=_[2],f=0;return u<i&&(f+=(i-u)*(i-u)),u>s&&(f+=(s-u)*(s-u)),c<r&&(f+=(r-c)*(r-c)),c>l&&(f+=(l-c)*(l-c)),d<a&&(f+=(a-d)*(a-d)),d>h&&(f+=(h-d)*(h-d)),Math.sqrt(f)},e.distanceBoxToBox=function(e,t){var n=e.min.elements,i=n[0],r=n[1],a=n[2],o=e.max.elements,s=o[0],l=o[1],h=o[2],_=t.min.elements,u=_[0],c=_[1],d=_[2],f=t.max.elements,m=f[0],p=f[1],v=f[2],E=0,g=NaN;return i>m?E+=(g=i-m)*g:u>s&&(E+=(g=u-s)*g),r>p?E+=(g=r-p)*g:c>l&&(E+=(g=c-l)*g),a>v?E+=(g=a-v)*g:d>h&&(E+=(g=d-h)*g),Math.sqrt(E)},e.distanceSphereToPoint=function(e,t){var n=Math.sqrt(bt.distanceSquared(e.center,t));return n-=e.radius,Math.max(n,0)},e.distanceSphereToSphere=function(e,t){var n=Math.sqrt(bt.distanceSquared(e.center,t.center));return n-=e.radius+t.radius,Math.max(n,0)},e.intersectsRayAndTriangleRD=function(t,n,i,r,a){var o=t.origin.elements,s=o[0],l=o[1],h=o[2],_=t.direction.elements,u=_[0],c=_[1],d=_[2],f=n.elements,m=f[0],p=f[1],v=f[2],E=i.elements,g=E[0],D=E[1],T=E[2],S=r.elements,x=S[0],M=S[1],R=S[2],A=e._tempV30.elements,I=A[0],y=A[1],C=A[2];I=g-m,y=D-p,C=T-v;var N=e._tempV31.elements,O=N[0],w=N[1],V=N[2];O=x-m,w=M-p,V=R-v;var P=e._tempV32.elements,L=P[0],b=P[1],F=P[2],B=I*(L=c*V-d*w)+y*(b=d*O-u*V)+C*(F=u*w-c*O);if(It.isZero(B))return!1;var U=1/B,H=e._tempV33.elements,G=H[0],z=H[1],W=H[2],k=(G=s-m)*L+(z=l-p)*b+(W=h-v)*F;if((k*=U)<0||k>1)return!1;var X=e._tempV34.elements,Z=X[0],Y=X[1],j=X[2],K=u*(Z=z*C-W*y)+c*(Y=W*I-G*C)+d*(j=G*y-z*I);if((K*=U)<0||k+K>1)return!1;var q=O*Z+w*Y+V*j;return!((q*=U)<0)},e.intersectsRayAndTriangleRP=function(t,n,i,r,a){return e.intersectsRayAndTriangleRD(t,n,i,r,NaN)?(bt.scale(t.direction,NaN,e._tempV30),bt.add(t.origin,e._tempV30,a),!0):(a=bt.ZERO,!1)},e.intersectsRayAndPoint=function(t,n){bt.subtract(t.origin,n,e._tempV30);var i=bt.dot(e._tempV30,t.direction),r=bt.dot(e._tempV30,e._tempV30)-It.zeroTolerance;return!(r>0&&i>0)&&!(i*i-r<0)},e.intersectsRayAndRay=function(t,n,i){var r=t.origin,a=r.elements,o=a[0],s=a[1],l=a[2],h=t.direction,_=h.elements,u=_[0],c=_[1],d=_[2],f=n.origin,m=f.elements,p=m[0],v=m[1],E=m[2],g=n.direction,D=g.elements,T=D[0],S=D[1],x=D[2];bt.cross(h,g,e._tempV30);var M=e._tempV30.elements,R=bt.scalarLengthSquared(e._tempV30);if(It.isZero(R)&&It.nearEqual(p,o)&&It.nearEqual(v,s)&&It.nearEqual(E,l))return bt.ZERO.cloneTo(i),!0;var A=p-o,I=v-s,y=E-l,C=T,N=S,O=x,w=M[0],V=M[1],P=M[2],L=(A*N*P+I*O*w+y*C*V-A*O*V-I*C*P-y*N*w)/R,b=(A*(N=c)*P+I*(O=d)*w+y*(C=u)*V-A*O*V-I*C*P-y*N*w)/R;bt.scale(h,L,e._tempV30),bt.scale(g,b,e._tempV31),bt.add(r,e._tempV30,e._tempV32),bt.add(f,e._tempV31,e._tempV33);var F=e._tempV32.elements,B=e._tempV33.elements;return It.nearEqual(B[0],F[0])&&It.nearEqual(B[1],F[1])&&It.nearEqual(B[2],F[2])?(e._tempV32.cloneTo(i),!0):(bt.ZERO.cloneTo(i),!1)},e.intersectsPlaneAndTriangle=function(t,n,i,r){var a=e.intersectsPlaneAndPoint(t,n),o=e.intersectsPlaneAndPoint(t,i),s=e.intersectsPlaneAndPoint(t,r);return a==Ot.PlaneIntersectionType_Front&&o==Ot.PlaneIntersectionType_Front&&s==Ot.PlaneIntersectionType_Front?Ot.PlaneIntersectionType_Front:a==Ot.PlaneIntersectionType_Back&&o==Ot.PlaneIntersectionType_Back&&s==Ot.PlaneIntersectionType_Back?Ot.PlaneIntersectionType_Back:Ot.PlaneIntersectionType_Intersecting},e.intersectsRayAndPlaneRD=function(e,t,n){var i=t.normal,r=bt.dot(i,e.direction);if(It.isZero(r))return!1;var a=bt.dot(i,e.origin);return!((-t.distance-a)/r<0)},e.intersectsRayAndPlaneRP=function(t,n,i){return e.intersectsRayAndPlaneRD(t,n,NaN)?(bt.scale(t.direction,NaN,e._tempV30),bt.add(t.origin,e._tempV30,e._tempV31),e._tempV31,!0):(bt.ZERO,!1)},e.intersectsRayAndBoxRD=function(e,t){var n=e.origin.elements,i=n[0],r=n[1],a=n[2],o=e.direction.elements,s=o[0],l=o[1],h=o[2],_=t.min.elements,u=_[0],c=_[1],d=_[2],f=t.max.elements,m=f[0],p=f[1],v=f[2],E=0,g=It.MaxValue;if(It.isZero(s)){if(i<u||i>m)return-1}else{var D=1/s,T=(u-i)*D,S=(m-i)*D;if(T>S){var x=T;T=S,S=x}if((E=Math.max(T,E))>(g=Math.min(S,g)))return-1}if(It.isZero(l)){if(r<c||r>p)return-1}else{var M=1/l,R=(c-r)*M,A=(p-r)*M;if(R>A){var I=R;R=A,A=I}if((E=Math.max(R,E))>(g=Math.min(A,g)))return-1}if(It.isZero(h)){if(a<d||a>v)return-1}else{var y=1/h,C=(d-a)*y,N=(v-a)*y;if(C>N){var O=C;C=N,N=O}if((E=Math.max(C,E))>(g=Math.min(N,g)))return-1}return E},e.intersectsRayAndBoxRP=function(t,n,i){var r=e.intersectsRayAndBoxRD(t,n);return-1===r?(bt.ZERO.cloneTo(i),r):(bt.scale(t.direction,r,e._tempV30),bt.add(t.origin,e._tempV30,e._tempV31),e._tempV31.cloneTo(i),r)},e.intersectsRayAndSphereRD=function(t,n){var i=n.radius;bt.subtract(t.origin,n.center,e._tempV30);var r=bt.dot(e._tempV30,t.direction),a=bt.dot(e._tempV30,e._tempV30)-i*i;if(a>0&&r>0)return-1;var o=r*r-a;if(o<0)return-1;var s=-r-Math.sqrt(o);return s<0&&(s=0),s},e.intersectsRayAndSphereRP=function(t,n,i){var r=e.intersectsRayAndSphereRD(t,n);return-1===r?(bt.ZERO.cloneTo(i),r):(bt.scale(t.direction,r,e._tempV30),bt.add(t.origin,e._tempV30,e._tempV31),e._tempV31.cloneTo(i),r)},e.intersectsSphereAndTriangle=function(t,n,i,r){var a=t.center,o=t.radius;return e.closestPointPointTriangle(a,n,i,r,e._tempV30),bt.subtract(e._tempV30,a,e._tempV31),bt.dot(e._tempV31,e._tempV31)<=o*o},e.intersectsPlaneAndPoint=function(e,t){var n=bt.dot(e.normal,t)+e.distance;return n>0?Ot.PlaneIntersectionType_Front:n<0?Ot.PlaneIntersectionType_Back:Ot.PlaneIntersectionType_Intersecting},e.intersectsPlaneAndPlane=function(t,n){bt.cross(t.normal,n.normal,e._tempV30);var i=bt.dot(e._tempV30,e._tempV30);return!It.isZero(i)},e.intersectsPlaneAndPlaneRL=function(t,n,i){var r=t.normal,a=n.normal;bt.cross(r,a,e._tempV34);var o=bt.dot(e._tempV34,e._tempV34);return!It.isZero(o)&&(bt.scale(a,t.distance,e._tempV30),bt.scale(r,n.distance,e._tempV31),bt.subtract(e._tempV30,e._tempV31,e._tempV32),bt.cross(e._tempV32,e._tempV34,e._tempV33),bt.normalize(e._tempV34,e._tempV34),new Pt(e._tempV33,e._tempV34),!0)},e.intersectsPlaneAndBox=function(t,n){var i=t.distance,r=t.normal,a=r.elements,o=a[0],s=a[1],l=a[2],h=n.min.elements,_=h[0],u=h[1],c=h[2],d=n.max.elements,f=d[0],m=d[1],p=d[2];e._tempV30.elements[0]=o>0?_:f,e._tempV30.elements[1]=s>0?u:m,e._tempV30.elements[2]=l>0?c:p,e._tempV31.elements[0]=o>0?f:_,e._tempV31.elements[1]=s>0?m:u,e._tempV31.elements[2]=l>0?p:c;var v=bt.dot(r,e._tempV30);return v+i>0?Ot.PlaneIntersectionType_Front:(v=bt.dot(r,e._tempV31))+i<0?Ot.PlaneIntersectionType_Back:Ot.PlaneIntersectionType_Intersecting},e.intersectsPlaneAndSphere=function(e,t){var n=t.radius,i=bt.dot(e.normal,t.center)+e.distance;return i>n?Ot.PlaneIntersectionType_Front:i<-n?Ot.PlaneIntersectionType_Back:Ot.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]||n[1]>a[1]||r[1]>i[1]||n[2]>a[2]||r[2]>i[2])},e.intersectsBoxAndSphere=function(t,n){var i=n.center,r=n.radius;return bt.Clamp(i,t.min,t.max,e._tempV30),bt.distanceSquared(i,e._tempV30)<=r*r},e.intersectsSphereAndSphere=function(e,t){var n=e.radius+t.radius;return bt.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],o=e.max.elements,s=o[0],l=o[1],h=o[2],_=t.min.elements,u=_[0],c=_[1],d=_[2],f=t.max.elements,m=f[0],p=f[1],v=f[2];return s<u||i>m?0:l<c||r>p?0:h<d||a>v?0:i<=u&&m<=m&&r<=c&&p<=l&&a<=d&&v<=h?1:2},e.boxContainsSphere=function(t,n){var i=t.min,r=i.elements,a=r[0],o=r[1],s=r[2],l=t.max,h=l.elements,_=h[0],u=h[1],c=h[2],d=n.center,f=d.elements,m=f[0],p=f[1],v=f[2],E=n.radius;return bt.Clamp(d,i,l,e._tempV30),bt.distanceSquared(d,e._tempV30)>E*E?0:a+E<=m&&m<=_-E&&_-a>E&&o+E<=p&&p<=u-E&&u-o>E&&s+E<=v&&v<=c-E&&c-s>E?1:2},e.sphereContainsPoint=function(e,t){return bt.distanceSquared(t,e.center)<=e.radius*e.radius?1:0},e.sphereContainsTriangle=function(t,n,i,r){var a=e.sphereContainsPoint(t,n),o=e.sphereContainsPoint(t,i),s=e.sphereContainsPoint(t,r);return 1==a&&1==o&&1==s?1:e.intersectsSphereAndTriangle(t,n,i,r)?2:0},e.sphereContainsBox=function(t,n){var i=t.center.elements,r=(i[0],i[1],i[2],t.radius),a=n.min.elements,o=(a[0],a[1],a[2],n.max.elements),s=(o[0],o[1],o[2],e._tempV30.elements);if(s[0],s[1],s[2],!e.intersectsBoxAndSphere(n,t))return 0;var l=r*r;return bt.scalarLengthSquared(e._tempV30)>l?2:bt.scalarLengthSquared(e._tempV30)>l?2:bt.scalarLengthSquared(e._tempV30)>l?2:bt.scalarLengthSquared(e._tempV30)>l?2:bt.scalarLengthSquared(e._tempV30)>l?2:bt.scalarLengthSquared(e._tempV30)>l?2:bt.scalarLengthSquared(e._tempV30)>l?2:bt.scalarLengthSquared(e._tempV30)>l?2:1},e.sphereContainsSphere=function(e,t){var n=e.radius,i=t.radius,r=bt.distance(e.center,t.center);return n+i<r?0:n-i<r?2:1},e.closestPointPointTriangle=function(t,n,i,r,a){bt.subtract(i,n,e._tempV30),bt.subtract(r,n,e._tempV31),bt.subtract(t,n,e._tempV32),bt.subtract(t,i,e._tempV33),bt.subtract(t,r,e._tempV34);var o=bt.dot(e._tempV30,e._tempV32),s=bt.dot(e._tempV31,e._tempV32),l=bt.dot(e._tempV30,e._tempV33),h=bt.dot(e._tempV31,e._tempV33),_=bt.dot(e._tempV30,e._tempV34),u=bt.dot(e._tempV31,e._tempV34);if(o<=0&&s<=0)n.cloneTo(a);else if(l>=0&&h<=l)i.cloneTo(a);else{var c=o*h-l*s;if(c<=0&&o>=0&&l<=0){var d=o/(o-l);return bt.scale(e._tempV30,d,a),void bt.add(n,a,a)}if(u>=0&&_<=u)r.cloneTo(a);else{var f=_*s-o*u;if(f<=0&&s>=0&&u<=0){var m=s/(s-u);return bt.scale(e._tempV31,m,a),void bt.add(n,a,a)}var p=l*u-_*h;if(p<=0&&h-l>=0&&_-u>=0){var v=(h-l)/(h-l+(_-u));return bt.subtract(r,i,a),bt.scale(a,v,a),void bt.add(i,a,a)}var E=1/(p+f+c),g=f*E,D=c*E;bt.scale(e._tempV30,g,e._tempV35),bt.scale(e._tempV31,D,e._tempV36),bt.add(e._tempV35,e._tempV36,a),bt.add(n,a,a)}}},e.closestPointPlanePoint=function(t,n,i){var r=t.normal,a=bt.dot(r,n)-t.distance;bt.scale(r,a,e._tempV30),bt.subtract(n,e._tempV30,i)},e.closestPointBoxPoint=function(t,n,i){bt.max(n,t.min,e._tempV30),bt.min(e._tempV30,t.max,i)},e.closestPointSpherePoint=function(e,t,n){var i=e.center;bt.subtract(t,i,n),bt.normalize(n,n),bt.scale(n,e.radius,n),bt.add(n,i,n)},e.closestPointSphereSphere=function(e,t,n){var i=e.center;bt.subtract(t.center,i,n),bt.normalize(n,n),bt.scale(n,e.radius,n),bt.add(n,i,n)},o(e,["_tempV30",function(){return this._tempV30=new bt},"_tempV31",function(){return this._tempV31=new bt},"_tempV32",function(){return this._tempV32=new bt},"_tempV33",function(){return this._tempV33=new bt},"_tempV34",function(){return this._tempV34=new bt},"_tempV35",function(){return this._tempV35=new bt},"_tempV36",function(){return this._tempV36=new bt}]),e}(),It=(function(){function e(){}s(e,"laya.d3.math.ContainmentType"),e.Disjoint=0,e.Contains=1,e.Intersects=2}(),function(){function e(){}return s(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)},o(e,["zeroTolerance",function(){return this.zeroTolerance=1e-6},"MaxValue",function(){return this.MaxValue=3.40282347e38},"MinValue",function(){return this.MinValue=-3.40282347e38}]),e}()),yt=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}s(e,"laya.d3.math.Matrix3x3");var t=e.prototype;return a.imps(t,{"laya.d3.core.IClone":!0}),t.determinant=function(){var e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],s=e[6],l=e[7],h=e[8];return t*(h*a-o*l)+n*(-h*r+o*s)+i*(l*r-a*s)},t.translate=function(e,t){var n=t.elements,i=this.elements,r=e.elements,a=i[0],o=i[1],s=i[2],l=i[3],h=i[4],_=i[5],u=i[6],c=i[7],d=i[8],f=r[0],m=r[1];n[0]=a,n[1]=o,n[2]=s,n[3]=l,n[4]=h,n[5]=_,n[6]=f*a+m*l+u,n[7]=f*o+m*h+c,n[8]=f*s+m*_+d},t.rotate=function(e,t){var n=t.elements,i=this.elements,r=i[0],a=i[1],o=i[2],s=i[3],l=i[4],h=i[5],_=i[6],u=i[7],c=i[8],d=Math.sin(e),f=Math.cos(e);n[0]=f*r+d*s,n[1]=f*a+d*l,n[2]=f*o+d*h,n[3]=f*s-d*r,n[4]=f*l-d*a,n[5]=f*h-d*o,n[6]=_,n[7]=u,n[8]=c},t.scale=function(e,t){var n=t.elements,i=this.elements,r=e.elements,a=r[0],o=r[1];n[0]=a*i[0],n[1]=a*i[1],n[2]=a*i[2],n[3]=o*i[3],n[4]=o*i[4],n[5]=o*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],o=n[3],s=n[4],l=n[5],h=n[6],_=n[7],u=n[8],c=u*s-l*_,d=-u*o+l*h,f=_*o-s*h,m=i*c+r*d+a*f;m||(e=null),m=1/m,t[0]=c*m,t[1]=(-u*r+a*_)*m,t[2]=(l*r-a*s)*m,t[3]=d*m,t[4]=(u*i-a*h)*m,t[5]=(-l*i+a*o)*m,t[6]=f*m,t[7]=(-_*i+r*h)*m,t[8]=(s*i-r*o)*m},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))for(t=0;t<9;++t)i[t]=n[t]},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},e.createFromTranslation=function(e,t){t.elements;var n=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,o=r[0],s=r[1],l=r[2],h=r[3],_=r[4],u=r[5],c=r[6],d=r[7],f=r[8],m=a[0],p=a[1],v=a[2],E=a[3],g=a[4],D=a[5],T=a[6],S=a[7],x=a[8];i[0]=m*o+p*h+v*c,i[1]=m*s+p*_+v*d,i[2]=m*l+p*u+v*f,i[3]=E*o+g*h+D*c,i[4]=E*s+g*_+D*d,i[5]=E*l+g*u+D*f,i[6]=T*o+S*h+x*c,i[7]=T*s+S*_+x*d,i[8]=T*l+S*u+x*f},e.lookAt=function(t,n,i,r){bt.subtract(t,n,e._tempV30),bt.normalize(e._tempV30,e._tempV30),bt.cross(i,e._tempV30,e._tempV31),bt.normalize(e._tempV31,e._tempV31),bt.cross(e._tempV30,e._tempV31,e._tempV32);var a=e._tempV30.elements,o=e._tempV31.elements,s=e._tempV32.elements,l=r.elements;l[0]=o[0],l[3]=o[1],l[6]=o[2],l[1]=s[0],l[4]=s[1],l[7]=s[2],l[2]=a[0],l[5]=a[1],l[8]=a[2]},e.DEFAULT=new e,o(e,["_tempV30",function(){return this._tempV30=new bt},"_tempV31",function(){return this._tempV31=new bt},"_tempV32",function(){return this._tempV32=new bt}]),e}(),Ct=function(){function e(e,t,n,i,r,a,o,s,l,h,_,u,c,d,f,m){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===o&&(o=0),void 0===s&&(s=0),void 0===l&&(l=0),void 0===h&&(h=0),void 0===_&&(_=1),void 0===u&&(u=0),void 0===c&&(c=0),void 0===d&&(d=0),void 0===f&&(f=0),void 0===m&&(m=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]=o,p[7]=s,p[8]=l,p[9]=h,p[10]=_,p[11]=u,p[12]=c,p[13]=d,p[14]=f,p[15]=m}s(e,"laya.d3.math.Matrix4x4");var t=e.prototype;return a.imps(t,{"laya.d3.core.IClone":!0}),t.getElementByRowColumn=function(e,t){if(e<0||e>3)throw new Error("row","Rows and columns for matrices run from 0 to 3, inclusive.");if(t<0||t>3)throw new Error("column","Rows and columns for matrices run from 0 to 3, inclusive.");return this.elements[4*e+t]},t.setElementByRowColumn=function(e,t,n){if(e<0||e>3)throw new Error("row","Rows and columns for matrices run from 0 to 3, inclusive.");if(t<0||t>3)throw new Error("column","Rows and columns for matrices run from 0 to 3, inclusive.");this.elements[4*e+t]=n},t.equalsOtherMatrix=function(e){var t=this.elements,n=e.elements;return It.nearEqual(t[0],n[0])&&It.nearEqual(t[1],n[1])&&It.nearEqual(t[2],n[2])&&It.nearEqual(t[3],n[3])&&It.nearEqual(t[4],n[4])&&It.nearEqual(t[5],n[5])&&It.nearEqual(t[6],n[6])&&It.nearEqual(t[7],n[7])&&It.nearEqual(t[8],n[8])&&It.nearEqual(t[9],n[9])&&It.nearEqual(t[10],n[10])&&It.nearEqual(t[11],n[11])&&It.nearEqual(t[12],n[12])&&It.nearEqual(t[13],n[13])&&It.nearEqual(t[14],n[14])&&It.nearEqual(t[15],n[15])},t.decomposeTransRotScale=function(t,n,i){var r=e._tempMatrix4x4;return this.decomposeTransRotMatScale(t,r,i)?(wt.createFromMatrix4x4(r,n),!0):(n.identity(),!1)},t.decomposeTransRotMatScale=function(t,n,i){var r=this.elements,a=t.elements,o=n.elements,s=i.elements;a[0]=r[12],a[1]=r[13],a[2]=r[14];var l=r[0],h=r[1],_=r[2],u=r[4],c=r[5],d=r[6],f=r[8],m=r[9],p=r[10],v=s[0]=Math.sqrt(l*l+h*h+_*_),E=s[1]=Math.sqrt(u*u+c*c+d*d),g=s[2]=Math.sqrt(f*f+m*m+p*p);if(It.isZero(v)||It.isZero(E)||It.isZero(g))return o[1]=o[2]=o[3]=o[4]=o[6]=o[7]=o[8]=o[9]=o[11]=o[12]=o[13]=o[14]=0,o[0]=o[5]=o[10]=o[15]=1,!1;var D=e._tempVector0,T=D.elements;T[0]=f/g,T[1]=m/g,T[2]=p/g;var S=e._tempVector1,x=S.elements;x[0]=l/v,x[1]=h/v,x[2]=_/v;var M=e._tempVector2;bt.cross(D,S,M);var R=e._tempVector1;return bt.cross(M,D,R),o[3]=o[7]=o[11]=o[12]=o[13]=o[14]=0,o[15]=1,o[0]=R.x,o[1]=R.y,o[2]=R.z,o[4]=M.x,o[5]=M.y,o[6]=M.z,o[8]=D.x,o[9]=D.y,o[10]=D.z,o[0]*l+o[1]*h+o[2]*_<0&&(s[0]=-v),o[4]*u+o[5]*c+o[6]*d<0&&(s[1]=-E),o[8]*f+o[9]*m+o[10]*p<0&&(s[2]=-g),!0},t.decomposeYawPitchRoll=function(e){var t=e.elements,n=Math.asin(-this.elements[9]);t[1]=n,Math.cos(n)>It.zeroTolerance?(t[2]=Math.atan2(this.elements[1],this.elements[5]),t[0]=Math.atan2(this.elements[8],this.elements[10])):(t[2]=Math.atan2(-this.elements[4],this.elements[0]),t[0]=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);if(!r)return e[0]=0,e[1]=0,void(e[2]=0);1!=r&&(r=1/r,e[0]=t*r,e[1]=n*r,e[2]=i*r)},t.transpose=function(){var e,t;return t=(e=this.elements)[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],o=t[3],s=t[4],l=t[5],h=t[6],_=t[7],u=t[8],c=t[9],d=t[10],f=t[11],m=t[12],p=t[13],v=t[14],E=t[15],g=i*l-r*s,D=i*h-a*s,T=i*_-o*s,S=r*h-a*l,x=r*_-o*l,M=a*_-o*h,R=u*p-c*m,A=u*v-d*m,I=u*E-f*m,y=c*v-d*p,C=c*E-f*p,N=d*E-f*v,O=g*N-D*C+T*y+S*I-x*A+M*R;0!==Math.abs(O)&&(O=1/O,n[0]=(l*N-h*C+_*y)*O,n[1]=(a*C-r*N-o*y)*O,n[2]=(p*M-v*x+E*S)*O,n[3]=(d*x-c*M-f*S)*O,n[4]=(h*I-s*N-_*A)*O,n[5]=(i*N-a*I+o*A)*O,n[6]=(v*T-m*M-E*D)*O,n[7]=(u*M-d*T+f*D)*O,n[8]=(s*C-l*I+_*R)*O,n[9]=(r*I-i*C-o*R)*O,n[10]=(m*x-p*T+E*g)*O,n[11]=(c*T-u*x-f*g)*O,n[12]=(l*A-s*y-h*R)*O,n[13]=(i*y-r*A+a*R)*O,n[14]=(p*D-m*S-v*g)*O,n[15]=(u*S-c*D+d*g)*O)},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))for(t=0;t<16;++t)i[t]=n[t]},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},t.getTranslationVector=function(e){var t=this.elements,n=e.elements;n[0]=t[12],n[1]=t[13],n[2]=t[14]},t.setTranslationVector=function(e){var t=this.elements,n=e.elements;t[12]=n[0],t[13]=n[1],t[14]=n[2]},t.getForward=function(e){var t=this.elements,n=e.elements;n[0]=-t[8],n[1]=-t[9],n[2]=-t[10]},t.setForward=function(e){var t=this.elements,n=e.elements;t[8]=-n[0],t[9]=-n[1],t[10]=-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){wt.createFromYawPitchRoll(t,n,i,e._tempQuaternion),e.createRotationQuaternion(e._tempQuaternion,r)},e.createRotationAxis=function(e,t,n){var i=e.elements,r=i[0],a=i[1],o=i[2],s=Math.cos(t),l=Math.sin(t),h=r*r,_=a*a,u=o*o,c=r*a,d=r*o,f=a*o,m=n.elements;m[3]=m[7]=m[11]=m[12]=m[13]=m[14]=0,m[15]=1,m[0]=h+s*(1-h),m[1]=c-s*c+l*o,m[2]=d-s*d-l*a,m[4]=c-s*c-l*o,m[5]=_+s*(1-_),m[6]=f-s*f+l*r,m[8]=d-s*d+l*a,m[9]=f-s*f-l*r,m[10]=u+s*(1-u)},e.createRotationQuaternion=function(e,t){var n=e.elements,i=t.elements,r=n[0],a=n[1],o=n[2],s=n[3],l=r*r,h=a*a,_=o*o,u=r*a,c=o*s,d=o*r,f=a*s,m=a*o,p=r*s;i[3]=i[7]=i[11]=i[12]=i[13]=i[14]=0,i[15]=1,i[0]=1-2*(h+_),i[1]=2*(u+c),i[2]=2*(d-f),i[4]=2*(u-c),i[5]=1-2*(_+l),i[6]=2*(m+p),i[8]=2*(d+f),i[9]=2*(m-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,o,s,l,h,_;if(r=n.elements,a=e.elements,r===(o=t.elements))for(o=new Float32Array(16),i=0;i<16;++i)o[i]=r[i];for(i=0;i<4;i++)s=a[i],l=a[i+4],h=a[i+8],_=a[i+12],r[i]=s*o[0]+l*o[1]+h*o[2]+_*o[3],r[i+4]=s*o[4]+l*o[5]+h*o[6]+_*o[7],r[i+8]=s*o[8]+l*o[9]+h*o[10]+_*o[11],r[i+12]=s*o[12]+l*o[13]+h*o[14]+_*o[15]},e.createFromQuaternion=function(e,t){var n=t.elements,i=e.elements,r=i[0],a=i[1],o=i[2],s=i[3],l=r+r,h=a+a,_=o+o,u=r*l,c=a*l,d=a*h,f=o*l,m=o*h,p=o*_,v=s*l,E=s*h,g=s*_;n[0]=1-d-p,n[1]=c+g,n[2]=f-E,n[3]=0,n[4]=c-g,n[5]=1-u-p,n[6]=m+v,n[7]=0,n[8]=f+E,n[9]=m-v,n[10]=1-u-d,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1},e.createAffineTransformation=function(e,t,n,i){var r=e.elements,a=t.elements,o=n.elements,s=i.elements,l=a[0],h=a[1],_=a[2],u=a[3],c=l+l,d=h+h,f=_+_,m=l*c,p=l*d,v=l*f,E=h*d,g=h*f,D=_*f,T=u*c,S=u*d,x=u*f,M=o[0],R=o[1],A=o[2];s[0]=(1-(E+D))*M,s[1]=(p+x)*M,s[2]=(v-S)*M,s[3]=0,s[4]=(p-x)*R,s[5]=(1-(m+D))*R,s[6]=(g+T)*R,s[7]=0,s[8]=(v+S)*A,s[9]=(g-T)*A,s[10]=(1-(m+E))*A,s[11]=0,s[12]=r[0],s[13]=r[1],s[14]=r[2],s[15]=1},e.createLookAt=function(t,n,i,r){var a=r.elements,o=e._tempVector0,s=e._tempVector1,l=e._tempVector2;bt.subtract(t,n,l),bt.normalize(l,l),bt.cross(i,l,o),bt.normalize(o,o),bt.cross(l,o,s),r.identity(),a[0]=o.x,a[4]=o.y,a[8]=o.z,a[1]=s.x,a[5]=s.y,a[9]=s.z,a[2]=l.x,a[6]=l.y,a[10]=l.z,a[12]=-bt.dot(o,t),a[13]=-bt.dot(s,t),a[14]=-bt.dot(l,t)},e.createPerspective=function(e,t,n,i,r){var a=r.elements,o=1/Math.tan(e/2),s=1/(n-i);a[0]=o/t,a[5]=o,a[10]=(i+n)*s,a[11]=-1,a[14]=2*i*n*s,a[1]=a[2]=a[3]=a[4]=a[6]=a[7]=a[8]=a[9]=a[12]=a[13]=a[15]=0},e.createOrthoOffCenterRH=function(e,t,n,i,r,a,o){var s=o.elements,l=1/(e-t),h=1/(n-i),_=1/(r-a);s[1]=s[2]=s[3]=s[4]=s[6]=s[7]=s[8]=s[9]=s[11]=0,s[15]=1,s[0]=-2*l,s[5]=-2*h,s[10]=2*_,s[12]=(e+t)*l,s[13]=(i+n)*h,s[14]=(a+r)*_},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]},o(e,["_tempMatrix4x4",function(){return this._tempMatrix4x4=new e},"_tempVector0",function(){return this._tempVector0=new bt},"_tempVector1",function(){return this._tempVector1=new bt},"_tempVector2",function(){return this._tempVector2=new bt},"_tempQuaternion",function(){return this._tempQuaternion=new wt},"DEFAULT",function(){return this.DEFAULT=new e},"ZERO",function(){return this.ZERO=new e(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}]),e}(),Nt=function(){function e(e,t){this.extents=null,this.transformation=null,this.extents=e,this.transformation=t}s(e,"laya.d3.math.OrientedBoundBox");var t=e.prototype;return t.getCorners=function(t){var n=e._tempV30.elements,i=e._tempV31.elements,r=e._tempV32.elements,a=this.extents.elements;n[0]=a[0],n[1]=n[2]=0,i[1]=a[1],i[0]=i[2]=0,r[2]=a[2],r[0]=r[1]=0,bt.TransformNormal(e._tempV30,this.transformation,e._tempV30),bt.TransformNormal(e._tempV31,this.transformation,e._tempV31),bt.TransformNormal(e._tempV32,this.transformation,e._tempV32);var o=e._tempV33;this.transformation.getTranslationVector(o),t.length=8,bt.add(o,e._tempV30,e._tempV34),bt.add(e._tempV34,e._tempV31,e._tempV34),bt.add(e._tempV34,e._tempV32,t[0]),bt.add(o,e._tempV30,e._tempV34),bt.add(e._tempV34,e._tempV31,e._tempV34),bt.subtract(e._tempV34,e._tempV32,t[1]),bt.subtract(o,e._tempV30,e._tempV34),bt.add(e._tempV34,e._tempV31,e._tempV34),bt.subtract(e._tempV34,e._tempV32,t[2]),bt.subtract(o,e._tempV30,e._tempV34),bt.add(e._tempV34,e._tempV31,e._tempV34),bt.add(e._tempV34,e._tempV32,t[3]),bt.add(o,e._tempV30,e._tempV34),bt.subtract(e._tempV34,e._tempV31,e._tempV34),bt.add(e._tempV34,e._tempV32,t[4]),bt.add(o,e._tempV30,e._tempV34),bt.subtract(e._tempV34,e._tempV31,e._tempV34),bt.subtract(e._tempV34,e._tempV32,t[5]),bt.subtract(o,e._tempV30,e._tempV34),bt.subtract(e._tempV34,e._tempV31,e._tempV34),bt.subtract(e._tempV34,e._tempV32,t[6]),bt.subtract(o,e._tempV30,e._tempV34),bt.subtract(e._tempV34,e._tempV31,e._tempV34),bt.add(e._tempV34,e._tempV32,t[7])},t.transform=function(e){Ct.multiply(this.transformation,e,this.transformation)},t.scale=function(e){bt.multiply(this.extents,e,this.extents)},t.translate=function(t){this.transformation.getTranslationVector(e._tempV30),bt.add(e._tempV30,t,e._tempV31),this.transformation.setTranslationVector(e._tempV31)},t.Size=function(e){bt.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],bt.TransformNormal(e._tempV30,this.transformation,e._tempV30),bt.TransformNormal(e._tempV31,this.transformation,e._tempV31),bt.TransformNormal(e._tempV31,this.transformation,e._tempV32);var i=t.elements;i[0]=bt.scalarLength(e._tempV30),i[1]=bt.scalarLength(e._tempV31),i[2]=bt.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],bt.TransformNormal(e._tempV30,this.transformation,e._tempV30),bt.TransformNormal(e._tempV31,this.transformation,e._tempV31),bt.TransformNormal(e._tempV31,this.transformation,e._tempV32);var i=t.elements;i[0]=bt.scalarLengthSquared(e._tempV30),i[1]=bt.scalarLengthSquared(e._tempV31),i[2]=bt.scalarLengthSquared(e._tempV32)},t.getCenter=function(e){this.transformation.getTranslationVector(e)},t.containsPoint=function(t){var n=this.extents.elements,i=n[0],r=n[1],a=n[2];this.transformation.invert(e._tempM0),bt.transformCoordinate(t,e._tempM0,e._tempV30);var o=e._tempV30.elements,s=Math.abs(o[0]),l=Math.abs(o[1]),h=Math.abs(o[2]);return It.nearEqual(s,i)&&It.nearEqual(l,r)&&It.nearEqual(h,a)?2:s<i&&l<r&&h<a?1:0},t.containsPoints=function(t){var n=this.extents.elements,i=n[0],r=n[1],a=n[2];this.transformation.invert(e._tempM0);for(var o=!0,s=!1,l=0;l<t.length;l++){bt.transformCoordinate(t[l],e._tempM0,e._tempV30);var h=e._tempV30.elements,_=Math.abs(h[0]),u=Math.abs(h[1]),c=Math.abs(h[2]);It.nearEqual(_,i)&&It.nearEqual(u,r)&&It.nearEqual(c,a)&&(s=!0),_<i&&u<r&&c<a?s=!0:o=!1}return o?1:s?2:0},t.containsSphere=function(t,n){void 0===n&&(n=!1);var i=this.extents.elements,r=i[0],a=i[1],o=i[2],s=t.radius;this.transformation.invert(e._tempM0),bt.transformCoordinate(t.center,e._tempM0,e._tempV30);var l=NaN;if(n?l=s:(bt.scale(bt.UnitX,s,e._tempV31),bt.TransformNormal(e._tempV31,e._tempM0,e._tempV31),l=bt.scalarLength(e._tempV31)),bt.scale(this.extents,-1,e._tempV32),bt.Clamp(e._tempV30,e._tempV32,this.extents,e._tempV33),bt.distanceSquared(e._tempV30,e._tempV33)>l*l)return 0;var h=e._tempV30.elements,_=h[0],u=h[1],c=h[2],d=e._tempV32.elements,f=d[0],m=d[1],p=d[2];return f+l<=_&&_<=r-l&&r-f>l&&m+l<=u&&u<=a-l&&a-m>l&&p+l<=c&&c<=o-l&&o-p>l?1:2},t.containsOrientedBoundBox=function(t){var n=0,i=0;t.getCorners(e._corners);var r=this.containsPoints(e._corners);if(0!=r)return r;var a=this.extents.elements;t.extents.cloneTo(e._tempV35);var o=e._tempV35.elements;e._getRows(this.transformation,e._rows1),e._getRows(t.transformation,e._rows2);var s=NaN,l=NaN,h=NaN;for(n=0;n<4;n++)for(i=0;i<4;i++)3==n||3==i?(e._tempM0.setElementByRowColumn(n,i,0),e._tempM1.setElementByRowColumn(n,i,0)):(h=bt.dot(e._rows1[n],e._rows2[i]),e._tempM0.setElementByRowColumn(n,i,h),e._tempM1.setElementByRowColumn(n,i,Math.abs(h)));t.getCenter(e._tempV34),this.getCenter(e._tempV36),bt.subtract(e._tempV34,e._tempV36,e._tempV30);var _=e._tempV31.elements;_[0]=bt.dot(e._tempV30,e._rows1[0]),_[1]=bt.dot(e._tempV30,e._rows1[1]),_[2]=bt.dot(e._tempV30,e._rows1[2]);var u=e._tempV32.elements,c=e._tempV33.elements;for(n=0;n<3;n++)if(u[0]=e._tempM1.getElementByRowColumn(n,0),u[1]=e._tempM1.getElementByRowColumn(n,1),u[2]=e._tempM1.getElementByRowColumn(n,2),s=a[n],l=bt.dot(e._tempV35,e._tempV32),Math.abs(_[n])>s+l)return 0;for(i=0;i<3;i++)if(u[0]=e._tempM1.getElementByRowColumn(0,i),u[1]=e._tempM1.getElementByRowColumn(1,i),u[2]=e._tempM1.getElementByRowColumn(2,i),c[0]=e._tempM0.getElementByRowColumn(0,i),c[1]=e._tempM0.getElementByRowColumn(1,i),c[2]=e._tempM0.getElementByRowColumn(2,i),s=bt.dot(this.extents,e._tempV32),l=o[i],Math.abs(bt.dot(e._tempV31,e._tempV33))>s+l)return 0;for(n=0;n<3;n++)for(i=0;i<3;i++){var d=(n+1)%3,f=(n+2)%3,m=(i+1)%3,p=(i+2)%3;if(s=a[d]*e._tempM1.getElementByRowColumn(f,i)+a[f]*e._tempM1.getElementByRowColumn(d,i),l=o[m]*e._tempM1.getElementByRowColumn(n,p)+o[p]*e._tempM1.getElementByRowColumn(n,m),Math.abs(_[f]*e._tempM0.getElementByRowColumn(d,i)-_[d]*e._tempM0.getElementByRowColumn(f,i))>s+l)return 0}return 2},t.containsLine=function(t,n){e._corners[0]=t,e._corners[1]=n;var i=this.containsPoints(e._corners);if(0!=i)return i;var r=this.extents.elements,a=r[0],o=r[1],s=r[2];this.transformation.invert(e._tempM0),bt.transformCoordinate(t,e._tempM0,e._tempV30),bt.transformCoordinate(n,e._tempM0,e._tempV31),bt.add(e._tempV30,e._tempV31,e._tempV32),bt.scale(e._tempV32,.5,e._tempV32),bt.subtract(e._tempV30,e._tempV32,e._tempV33);var l=e._tempV33.elements,h=l[0],_=l[1],u=l[2],c=e._tempV34.elements,d=c[0]=Math.abs(l[0]),f=c[1]=Math.abs(l[1]),m=c[2]=Math.abs(l[2]),p=e._tempV32.elements,v=p[0],E=p[1],g=p[2];return Math.abs(v)>a+d?0:Math.abs(E)>o+f?0:Math.abs(g)>s+m?0:Math.abs(E*u-g*_)>o*m+s*f?0:Math.abs(v*u-g*h)>a*m+s*d?0:Math.abs(v*_-E*h)>a*f+o*d?0:2},t.containsBoundBox=function(t){var n=0,i=0,r=t.min,a=t.max;t.getCorners(e._corners);var o=this.containsPoints(e._corners);if(0!=o)return o;bt.subtract(a,r,e._tempV30),bt.scale(e._tempV30,.5,e._tempV30),bt.add(r,e._tempV30,e._tempV30),bt.subtract(a,e._tempV30,e._tempV31);var s=this.extents.elements,l=e._tempV31.elements;e._getRows(this.transformation,e._rows1),this.transformation.invert(e._tempM0);var h=NaN,_=NaN;for(n=0;n<3;n++)for(i=0;i<3;i++)e._tempM1.setElementByRowColumn(n,i,Math.abs(e._tempM0.getElementByRowColumn(n,i)));this.getCenter(e._tempV35),bt.subtract(e._tempV30,e._tempV35,e._tempV32);var u=e._tempV31.elements;u[0]=bt.dot(e._tempV32,e._rows1[0]),u[1]=bt.dot(e._tempV32,e._rows1[1]),u[2]=bt.dot(e._tempV32,e._rows1[2]);var c=e._tempV33.elements,d=e._tempV34.elements;for(n=0;n<3;n++)if(c[0]=e._tempM1.getElementByRowColumn(n,0),c[1]=e._tempM1.getElementByRowColumn(n,1),c[2]=e._tempM1.getElementByRowColumn(n,2),h=s[n],_=bt.dot(e._tempV31,e._tempV33),Math.abs(u[n])>h+_)return 0;for(i=0;i<3;i++)if(c[0]=e._tempM1.getElementByRowColumn(0,i),c[1]=e._tempM1.getElementByRowColumn(1,i),c[2]=e._tempM1.getElementByRowColumn(2,i),d[0]=e._tempM0.getElementByRowColumn(0,i),d[1]=e._tempM0.getElementByRowColumn(1,i),d[2]=e._tempM0.getElementByRowColumn(2,i),h=bt.dot(this.extents,e._tempV33),_=l[i],Math.abs(bt.dot(e._tempV31,e._tempV34))>h+_)return 0;for(n=0;n<3;n++)for(i=0;i<3;i++){var f=(n+1)%3,m=(n+2)%3,p=(i+1)%3,v=(i+2)%3;if(h=s[f]*e._tempM1.getElementByRowColumn(m,i)+s[m]*e._tempM1.getElementByRowColumn(f,i),_=l[p]*e._tempM1.getElementByRowColumn(n,v)+l[v]*e._tempM1.getElementByRowColumn(n,p),Math.abs(u[m]*e._tempM0.getElementByRowColumn(f,i)-u[f]*e._tempM0.getElementByRowColumn(m,i))>h+_)return 0}return 2},t.intersectsRay=function(t,n){bt.scale(this.extents,-1,e._tempV30),this.transformation.invert(e._tempM0),bt.TransformNormal(t.direction,e._tempM0,e._ray.direction),bt.transformCoordinate(t.origin,e._tempM0,e._ray.origin),e._boxBound1.min=e._tempV30,e._boxBound1.max=this.extents;var i=At.intersectsRayAndBoxRP(e._ray,e._boxBound1,n);return-1!==i&&bt.transformCoordinate(n,this.transformation,n),i},t._getLocalCorners=function(t){t.length=8;var n=this.extents.elements;e._tempV30.x=n[0],e._tempV31.y=n[1],e._tempV32.z=n[2],bt.add(e._tempV30,e._tempV31,e._tempV33),bt.add(e._tempV33,e._tempV32,t[0]),bt.add(e._tempV30,e._tempV31,e._tempV33),bt.subtract(e._tempV33,e._tempV32,t[1]),bt.subtract(e._tempV31,e._tempV30,e._tempV33),bt.subtract(e._tempV33,e._tempV30,t[2]),bt.subtract(e._tempV31,e._tempV30,e._tempV33),bt.add(e._tempV33,e._tempV32,t[3]),bt.subtract(e._tempV30,e._tempV31,e._tempV33),bt.add(e._tempV33,e._tempV32,t[4]),bt.subtract(e._tempV30,e._tempV31,e._tempV33),bt.subtract(e._tempV33,e._tempV32,t[5]),bt.scale(t[0],-1,t[6]),bt.subtract(e._tempV32,e._tempV30,e._tempV33),bt.subtract(e._tempV33,e._tempV31,t[7])},t.equals=function(e){return this.extents==e.extents&&this.transformation==e.transformation},t.cloneTo=function(e){var t=e;this.extents.cloneTo(t.extents),this.transformation.cloneTo(t.transformation)},e.createByBoundBox=function(t,n){var i=t.min,r=t.max;bt.subtract(r,i,e._tempV30),bt.scale(e._tempV30,.5,e._tempV30),bt.add(i,e._tempV30,e._tempV31),bt.subtract(r,e._tempV31,e._tempV32),Ct.translation(e._tempV31,e._tempM0);var a=e._tempV32.clone(),o=e._tempM0.clone();n.extents=a,n.transformation=o},e.createByMinAndMaxVertex=function(t,n){return bt.subtract(n,t,e._tempV30),bt.scale(e._tempV30,.5,e._tempV30),bt.add(t,e._tempV30,e._tempV31),bt.subtract(n,e._tempV31,e._tempV32),Ct.translation(e._tempV31,e._tempM0),new e(e._tempV32,e._tempM0)},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]},e.getObbtoObbMatrix4x4=function(t,n,i,r){var a=t.transformation,o=n.transformation;if(i){e._getRows(a,e._rows1),e._getRows(o,e._rows2);for(var s=0;s<3;s++)for(var l=0;l<3;l++)r.setElementByRowColumn(s,l,bt.dot(e._rows2[s],e._rows1[l]));n.getCenter(e._tempV30),t.getCenter(e._tempV31),bt.subtract(e._tempV30,e._tempV31,e._tempV32);var h=r.elements;h[12]=bt.dot(e._tempV32,e._rows1[0]),h[13]=bt.dot(e._tempV32,e._rows1[1]),h[14]=bt.dot(e._tempV32,e._rows1[2]),h[15]=1}else a.invert(e._tempM0),Ct.multiply(o,e._tempM0,r)},e.merge=function(t,n,i){var r=t.extents,a=t.transformation;e.getObbtoObbMatrix4x4(t,n,i,e._tempM0),n._getLocalCorners(e._corners),bt.transformCoordinate(e._corners[0],e._tempM0,e._corners[0]),bt.transformCoordinate(e._corners[1],e._tempM0,e._corners[1]),bt.transformCoordinate(e._corners[2],e._tempM0,e._corners[2]),bt.transformCoordinate(e._corners[3],e._tempM0,e._corners[3]),bt.transformCoordinate(e._corners[4],e._tempM0,e._corners[4]),bt.transformCoordinate(e._corners[5],e._tempM0,e._corners[5]),bt.transformCoordinate(e._corners[6],e._tempM0,e._corners[6]),bt.transformCoordinate(e._corners[7],e._tempM0,e._corners[7]),bt.scale(r,-1,e._boxBound1.min),r.cloneTo(e._boxBound1.max),xt.createfromPoints(e._corners,e._boxBound2),xt.merge(e._boxBound2,e._boxBound1,e._boxBound3);var o=e._boxBound3.min,s=e._boxBound3.max;bt.subtract(s,o,e._tempV30),bt.scale(e._tempV30,.5,e._tempV30),bt.add(o,e._tempV30,e._tempV32),bt.subtract(s,e._tempV32,r),bt.transformCoordinate(e._tempV32,a,e._tempV33)},o(e,["_tempV30",function(){return this._tempV30=new bt},"_tempV31",function(){return this._tempV31=new bt},"_tempV32",function(){return this._tempV32=new bt},"_tempV33",function(){return this._tempV33=new bt},"_tempV34",function(){return this._tempV34=new bt},"_tempV35",function(){return this._tempV35=new bt},"_tempV36",function(){return this._tempV36=new bt},"_tempM0",function(){return this._tempM0=new Ct},"_tempM1",function(){return this._tempM1=new Ct},"_corners",function(){return this._corners=[new bt,new bt,new bt,new bt,new bt,new bt,new bt,new bt]},"_rows1",function(){return this._rows1=[new bt,new bt,new bt]},"_rows2",function(){return this._rows2=[new bt,new bt,new bt]},"_ray",function(){return this._ray=new Pt(new bt,new bt)},"_boxBound1",function(){return this._boxBound1=new xt(new bt,new bt)},"_boxBound2",function(){return this._boxBound2=new xt(new bt,new bt)},"_boxBound3",function(){return this._boxBound3=new xt(new bt,new bt)}]),e}(),Ot=function(){function e(e,t){this.normal=null,this.distance=NaN,void 0===t&&(t=0),this.normal=e,this.distance=t}return s(e,"laya.d3.math.Plane"),e.prototype.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,o=i.elements,s=a[0]-r[0],l=a[1]-r[1],h=a[2]-r[2],_=o[0]-r[0],u=o[1]-r[1],c=o[2]-r[2],d=l*c-h*u,f=h*_-s*c,m=s*u-l*_,p=1/Math.sqrt(d*d+f*f+m*m),v=d*p,E=f*p,g=m*p,D=e._TEMPVec3.elements;D[0]=v,D[1]=E,D[2]=g;var T=-(v*r[0]+E*r[1]+g*r[2]);return new e(e._TEMPVec3,T)},e.PlaneIntersectionType_Back=0,e.PlaneIntersectionType_Front=1,e.PlaneIntersectionType_Intersecting=2,o(e,["_TEMPVec3",function(){return this._TEMPVec3=new bt}]),e}(),wt=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}s(e,"laya.d3.math.Quaternion");var t=e.prototype;return a.imps(t,{"laya.d3.core.IClone":!0}),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],o=n[3],s=i*i+r*r+a*a+o*o;s>0&&(s=1/Math.sqrt(s),t[0]=i*s,t[1]=r*s,t[2]=a*s,t[3]=o*s)},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],o=i[2],s=i[3],l=Math.sin(e),h=Math.cos(e);n[0]=r*h+s*l,n[1]=a*h+o*l,n[2]=o*h-a*l,n[3]=s*h-r*l},t.rotateY=function(e,t){var n=t.elements,i=this.elements;e*=.5;var r=i[0],a=i[1],o=i[2],s=i[3],l=Math.sin(e),h=Math.cos(e);n[0]=r*h-o*l,n[1]=a*h+s*l,n[2]=o*h+r*l,n[3]=s*h-a*l},t.rotateZ=function(e,t){var n=t.elements,i=this.elements;e*=.5;var r=i[0],a=i[1],o=i[2],s=i[3],l=Math.sin(e),h=Math.cos(e);n[0]=r*h+a*l,n[1]=a*h-r*l,n[2]=o*h+s*l,n[3]=s*h-o*l},t.getYawPitchRoll=function(t){bt.transformQuat(bt.ForwardRH,this,e.TEMPVector31),bt.transformQuat(bt.Up,this,e.TEMPVector32);var n=e.TEMPVector32.elements;e.angleTo(bt.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):(Ct.createRotationY(-i[1],e.TEMPMatrix0),Ct.createRotationX(-i[0],e.TEMPMatrix1),bt.transformCoordinate(e.TEMPVector32,e.TEMPMatrix0,e.TEMPVector32),bt.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],o=n[3],s=i*i+r*r+a*a+o*o,l=s?1/s:0;t[0]=-i*l,t[1]=-r*l,t[2]=-a*l,t[3]=o*l},t.identity=function(){var e=this.elements;e[0]=0,e[1]=0,e[2]=0,e[3]=1},t.fromArray=function(e,t){void 0===t&&(t=0),this.elements[0]=e[t+0],this.elements[1]=e[t+1],this.elements[2]=e[t+2],this.elements[3]=e[t+3]},t.cloneTo=function(e){var t,n,i;if((n=this.elements)!==(i=e.elements))for(t=0;t<4;++t)i[t]=n[t]},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},t.equals=function(e){var t=this.elements,n=e.elements;return It.nearEqual(t[0],n[0])&&It.nearEqual(t[1],n[1])&&It.nearEqual(t[2],n[2])&&It.nearEqual(t[3],n[3])},t.lengthSquared=function(){var e=this.elements[0],t=this.elements[1],n=this.elements[2],i=this.elements[3];return e*e+t*t+n*n+i*i},l(0,t,"x",function(){return this.elements[0]}),l(0,t,"y",function(){return this.elements[1]}),l(0,t,"z",function(){return this.elements[2]}),l(0,t,"w",function(){return this.elements[3]}),e.createFromYawPitchRoll=function(e,t,n,i){var r=.5*n,a=.5*t,o=.5*e,s=Math.sin(r),l=Math.cos(r),h=Math.sin(a),_=Math.cos(a),u=Math.sin(o),c=Math.cos(o),d=i.elements;d[0]=c*h*l+u*_*s,d[1]=u*_*l-c*h*s,d[2]=c*_*s-u*h*l,d[3]=c*_*l+u*h*s},e.multiply=function(e,t,n){var i=e.elements,r=t.elements,a=n.elements,o=i[0],s=i[1],l=i[2],h=i[3],_=r[0],u=r[1],c=r[2],d=r[3],f=s*c-l*u,m=l*_-o*c,p=o*u-s*_,v=o*_+s*u+l*c;a[0]=o*d+_*h+f,a[1]=s*d+u*h+m,a[2]=l*d+c*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):e<0?t>0?Math.atan(t/e)+Math.PI:Math.atan(t/e)-Math.PI:0},e.angleTo=function(t,n,i){bt.subtract(n,t,e.TEMPVector30),bt.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;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 o=0;r[4]>r[0]&&(o=1),r[8]>r[3*o+o]&&(o=2);var s=(o+1)%3,l=(o+2)%3;n=Math.sqrt(r[3*o+o]-r[3*s+s]-r[3*l+l]+1),i[o]=.5*n,n=.5/n,i[3]=(r[3*s+l]-r[3*l+s])*n,i[s]=(r[3*s+o]+r[3*o+s])*n,i[l]=(r[3*l+o]+r[3*o+l])*n}},e.createFromMatrix4x4=function(e,t){var n,i,r=e.elements,a=t.elements,o=r[0]+r[5]+r[10];o>0?(n=Math.sqrt(o+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]?(i=.5/(n=Math.sqrt(1+r[0]-r[5]-r[10])),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]?(i=.5/(n=Math.sqrt(1+r[5]-r[0]-r[10])),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):(i=.5/(n=Math.sqrt(1+r[10]-r[0]-r[5])),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,o,s,l,h=e.elements,_=t.elements,u=i.elements,c=h[0],d=h[1],f=h[2],m=h[3],p=_[0],v=_[1],E=_[2],g=_[3];return(a=c*p+d*v+f*E+m*g)<0&&(a=-a,p=-p,v=-v,E=-E,g=-g),1-a>1e-6?(r=Math.acos(a),o=Math.sin(r),s=Math.sin((1-n)*r)/o,l=Math.sin(n*r)/o):(s=1-n,l=n),u[0]=s*c+l*p,u[1]=s*d+l*v,u[2]=s*f+l*E,u[3]=s*m+l*g,u},e.lerp=function(e,t,n,i){var r=i.elements,a=e.elements,o=t.elements,s=a[0],l=a[1],h=a[2],_=a[3];r[0]=s+n*(o[0]-s),r[1]=l+n*(o[1]-l),r[2]=h+n*(o[2]-h),r[3]=_+n*(o[3]-_)},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.rotationLookAt=function(t,n,i){e.lookAt(bt.ZERO,t,n,i)},e.lookAt=function(t,n,i,r){yt.lookAt(t,n,i,e._tempMatrix3x3),e.rotationMatrix(e._tempMatrix3x3,r)},e.invert=function(e,t){var n=e.elements,i=t.elements,r=e.lengthSquared();It.isZero(r)||(r=1/r,i[0]=-n[0]*r,i[1]=-n[1]*r,i[2]=-n[2]*r,i[3]=n[3]*r)},e.rotationMatrix=function(e,t){var n=e.elements,i=n[0],r=n[1],a=n[2],o=n[3],s=n[4],l=n[5],h=n[6],_=n[7],u=n[8],c=t.elements,d=NaN,f=NaN,m=i+s+u;m>0?(d=Math.sqrt(m+1),c[3]=.5*d,d=.5/d,c[0]=(l-_)*d,c[1]=(h-a)*d,c[2]=(r-o)*d):i>=s&&i>=u?(f=.5/(d=Math.sqrt(1+i-s-u)),c[0]=.5*d,c[1]=(r+o)*f,c[2]=(a+h)*f,c[3]=(l-_)*f):s>u?(f=.5/(d=Math.sqrt(1+s-i-u)),c[0]=(o+r)*f,c[1]=.5*d,c[2]=(_+l)*f,c[3]=(h-a)*f):(f=.5/(d=Math.sqrt(1+u-i-s)),c[0]=(h+a)*f,c[1]=(_+l)*f,c[2]=.5*d,c[3]=(r-o)*f)},e.DEFAULT=new e,o(e,["TEMPVector30",function(){return this.TEMPVector30=new bt},"TEMPVector31",function(){return this.TEMPVector31=new bt},"TEMPVector32",function(){return this.TEMPVector32=new bt},"TEMPVector33",function(){return this.TEMPVector33=new bt},"TEMPMatrix0",function(){return this.TEMPMatrix0=new Ct},"TEMPMatrix1",function(){return this.TEMPMatrix1=new Ct},"_tempMatrix3x3",function(){return this._tempMatrix3x3=new yt},"NAN",function(){return this.NAN=new e(NaN,NaN,NaN,NaN)}]),e}(),Vt=function(){function e(e){this._temp=new Uint32Array(1),this.seeds=new Uint32Array(4),this.seeds[0]=e,this.seeds[1]=1812433253*this.seeds[0]+1,this.seeds[2]=1812433253*this.seeds[1]+1,this.seeds[3]=1812433253*this.seeds[2]+1}s(e,"laya.d3.math.Rand");var t=e.prototype;return t.getUint=function(){return this._temp[0]=this.seeds[0]^this.seeds[0]<<11,this.seeds[0]=this.seeds[1],this.seeds[1]=this.seeds[2],this.seeds[2]=this.seeds[3],this.seeds[3]=this.seeds[3]^this.seeds[3]>>>19^this._temp[0]^this._temp[0]>>>8,this.seeds[3]},t.getFloat=function(){return this.getUint(),(8388607&this.seeds[3])*(1/8388607)},t.getSignedFloat=function(){return 2*this.getFloat()-1},l(0,t,"seed",function(){return this.seeds[0]},function(e){this.seeds[0]=e,this.seeds[1]=1812433253*this.seeds[0]+1,this.seeds[2]=1812433253*this.seeds[1]+1,this.seeds[3]=1812433253*this.seeds[2]+1}),e.getFloatFromInt=function(e){return 1/8388607*(8388607&e)},e.getByteFromInt=function(e){return(8388607&e)>>>15},e}(),Pt=(function(){function e(e){if(this._state0U=NaN,this._state0L=NaN,this._state1U=NaN,this._state1L=NaN,!(e instanceof Array)||4!==e.length)throw new Error("Rand:Seed must be an array with 4 numbers");this._state0U=0|e[0],this._state0L=0|e[1],this._state1U=0|e[2],this._state1L=0|e[3]}s(e,"laya.d3.math.RandX");var t=e.prototype;t.randomint=function(){var e=this._state0U,t=this._state0L,n=this._state1U,i=this._state1L,r=(i>>>0)+(t>>>0),a=n+e+(r/2>>>31)>>>0,o=r>>>0;this._state0U=n,this._state0L=i;var s=0,l=0;return s=(e^=s=e<<23|(-512&t)>>>9)^n,l=(t^=l=t<<23)^i,s^=e>>>18,l^=t>>>18|(262143&e)<<14,s^=n>>>5,l^=i>>>5|(31&n)<<27,this._state1U=s,this._state1L=l,[a,o]},t.random=function(){var t=this.randomint(),n=t[0],i=1023<<20|n>>>12,r=t[1]>>>12|(4095&n)<<20|0;return e._CONVERTION_BUFFER.setUint32(0,i,!1),e._CONVERTION_BUFFER.setUint32(4,r,!1),Vt._CONVERTION_BUFFER.getFloat64(0,!1)-1},o(e,["_CONVERTION_BUFFER",function(){return this._CONVERTION_BUFFER=new DataView(new ArrayBuffer(8))},"defaultRand",function(){return this.defaultRand=new Vt([0,Date.now()/65536,0,Date.now()%65536])}])}(),function(){function e(e,t){this.origin=null,this.direction=null,this.origin=e,this.direction=t}return s(e,"laya.d3.math.Ray"),e}()),Lt=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}s(e,"laya.d3.math.Vector2");var t=e.prototype;return a.imps(t,{"laya.d3.core.IClone":!0}),t.fromArray=function(e,t){void 0===t&&(t=0),this.elements[0]=e[t+0],this.elements[1]=e[t+1]},t.cloneTo=function(e){var t=e.elements,n=this.elements;t[0]=n[0],t[1]=n[1]},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},l(0,t,"x",function(){return this.elements[0]},function(e){this.elements[0]=e}),l(0,t,"y",function(){return this.elements[1]},function(e){this.elements[1]=e}),e.scale=function(e,t,n){var i=n.elements,r=e.elements;i[0]=r[0]*t,i[1]=r[1]*t},o(e,["ZERO",function(){return this.ZERO=new e(0,0)},"ONE",function(){return this.ONE=new e(1,1)}]),e}(),bt=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}s(e,"laya.d3.math.Vector3");var t=e.prototype;return a.imps(t,{"laya.d3.core.IClone":!0}),t.fromArray=function(e,t){void 0===t&&(t=0),this.elements[0]=e[t+0],this.elements[1]=e[t+1],this.elements[2]=e[t+2]},t.cloneTo=function(e){var t=e.elements,n=this.elements;t[0]=n[0],t[1]=n[1],t[2]=n[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},l(0,t,"x",function(){return this.elements[0]},function(e){this.elements[0]=e}),l(0,t,"y",function(){return this.elements[1]},function(e){this.elements[1]=e}),l(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],o=n[2]-i[2];return r*r+a*a+o*o},e.distance=function(e,t){var n=e.elements,i=t.elements,r=n[0]-i[0],a=n[1]-i[1],o=n[2]-i[2];return Math.sqrt(r*r+a*a+o*o)},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,o=r[0],s=r[1],l=r[2],h=a[0],_=a[1],u=a[2],c=a[3],d=c*o+_*l-u*s,f=c*s+u*o-h*l,m=c*l+h*s-_*o,p=-h*o-_*s-u*l;i[0]=d*c+p*-h+f*-u-m*-_,i[1]=f*c+p*-_+m*-h-d*-u,i[2]=m*c+p*-u+d*-_-f*-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],o=n[2],s=r*r+a*a+o*o;s>0&&(s=1/Math.sqrt(s),i[0]=n[0]*s,i[1]=n[1]*s,i[2]=n[2]*s)},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,o=t.elements,s=a[0],l=a[1],h=a[2];r[0]=s+n*(o[0]-s),r[1]=l+n*(o[1]-l),r[2]=h+n*(o[2]-h)},e.transformV3ToV3=function(t,n,i){var r=e._tempVector4;e.transformV3ToV4(t,n,r);var a=r.elements,o=i.elements;o[0]=a[0],o[1]=a[1],o[2]=a[2]},e.transformV3ToV4=function(e,t,n){var i=e.elements,r=i[0],a=i[1],o=i[2],s=t.elements,l=n.elements;l[0]=r*s[0]+a*s[4]+o*s[8]+s[12],l[1]=r*s[1]+a*s[5]+o*s[9]+s[13],l[2]=r*s[2]+a*s[6]+o*s[10]+s[14],l[3]=r*s[3]+a*s[7]+o*s[11]+s[15]},e.TransformNormal=function(e,t,n){var i=e.elements,r=i[0],a=i[1],o=i[2],s=t.elements,l=n.elements;l[0]=r*s[0]+a*s[4]+o*s[8],l[1]=r*s[1]+a*s[5]+o*s[9],l[2]=r*s[2]+a*s[6]+o*s[10]},e.transformCoordinate=function(t,n,i){var r=e._tempVector4.elements,a=t.elements,o=a[0],s=a[1],l=a[2],h=n.elements;r[0]=o*h[0]+s*h[4]+l*h[8]+h[12],r[1]=o*h[1]+s*h[5]+l*h[9]+h[13],r[2]=o*h[2]+s*h[6]+l*h[10]+h[14],r[3]=1/(o*h[3]+s*h[7]+l*h[11]+h[15]);var _=i.elements;_[0]=r[0]*r[3],_[1]=r[1]*r[3],_[2]=r[2]*r[3]},e.Clamp=function(e,t,n,i){var r=e.elements,a=r[0],o=r[1],s=r[2],l=t.elements,h=l[0],_=l[1],u=l[2],c=n.elements,d=c[0],f=c[1],m=c[2],p=i.elements;a=(a=a>d?d:a)<h?h:a,o=(o=o>f?f:o)<_?_:o,s=(s=s>m?m:s)<u?u:s,p[0]=a,p[1]=o,p[2]=s},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,o=i[0],s=i[1],l=i[2],h=r[0],_=r[1],u=r[2];a[0]=s*u-l*_,a[1]=l*h-o*u,a[2]=o*_-s*h},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]},e.equals=function(e,t){var n=e.elements,i=t.elements;return It.nearEqual(Math.abs(n[0]),Math.abs(i[0]))&&It.nearEqual(Math.abs(n[1]),Math.abs(i[1]))&&It.nearEqual(Math.abs(n[2]),Math.abs(i[2]))},e.ZERO=new e(0,0,0),e.ONE=new e(1,1,1),e.NegativeUnitX=new e(-1,0,0),e.UnitX=new e(1,0,0),e.UnitY=new e(0,1,0),e.UnitZ=new e(0,0,1),e.ForwardRH=new e(0,0,-1),e.ForwardLH=new e(0,0,1),e.Up=new e(0,1,0),e.NAN=new e(NaN,NaN,NaN),o(e,["_tempVector4",function(){return this._tempVector4=new Ft}]),e}(),Ft=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}s(e,"laya.d3.math.Vector4");var t=e.prototype;return a.imps(t,{"laya.d3.core.IClone":!0}),t.fromArray=function(e,t){void 0===t&&(t=0),this.elements[0]=e[t+0],this.elements[1]=e[t+1],this.elements[2]=e[t+2],this.elements[3]=e[t+3]},t.cloneTo=function(e){var t=e.elements,n=this.elements;t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3]},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},t.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},t.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},l(0,t,"x",function(){return this.elements[0]},function(e){this.elements[0]=e}),l(0,t,"y",function(){return this.elements[1]},function(e){this.elements[1]=e}),l(0,t,"z",function(){return this.elements[2]},function(e){this.elements[2]=e}),l(0,t,"w",function(){return this.elements[3]},function(e){this.elements[3]=e}),e.lerp=function(e,t,n,i){var r=i.elements,a=e.elements,o=t.elements,s=a[0],l=a[1],h=a[2],_=a[3];r[0]=s+n*(o[0]-s),r[1]=l+n*(o[1]-l),r[2]=h+n*(o[2]-h),r[3]=_+n*(o[3]-_)},e.transformByM4x4=function(e,t,n){var i=e.elements,r=i[0],a=i[1],o=i[2],s=i[3],l=t.elements,h=n.elements;h[0]=r*l[0]+a*l[4]+o*l[8]+s*l[12],h[1]=r*l[1]+a*l[5]+o*l[9]+s*l[13],h[2]=r*l[2]+a*l[6]+o*l[10]+s*l[14],h[3]=r*l[3]+a*l[7]+o*l[11]+s*l[15]},e.equals=function(e,t){var n=e.elements,i=t.elements;return It.nearEqual(Math.abs(n[0]),Math.abs(i[0]))&&It.nearEqual(Math.abs(n[1]),Math.abs(i[1]))&&It.nearEqual(Math.abs(n[2]),Math.abs(i[2]))&&It.nearEqual(Math.abs(n[3]),Math.abs(i[3]))},e.normalize=function(e,t){var n=e.elements,i=t.elements,r=e.length();r>0&&(i[0]=n[0]*r,i[1]=n[1]*r,i[2]=n[2]*r,i[3]=n[3]*r)},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.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],i[3]=r[3]-a[3]},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],i[3]=r[3]*a[3]},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,i[3]=r[3]*t},e.Clamp=function(e,t,n,i){var r=e.elements,a=r[0],o=r[1],s=r[2],l=r[3],h=t.elements,_=h[0],u=h[1],c=h[2],d=h[3],f=n.elements,m=f[0],p=f[1],v=f[2],E=f[3],g=i.elements;a=(a=a>m?m:a)<_?_:a,o=(o=o>p?p:o)<u?u:o,s=(s=s>v?v:s)<c?c:s,l=(l=l>E?E:l)<d?d:l,g[0]=a,g[1]=o,g[2]=s,g[3]=l},e.distanceSquared=function(e,t){var n=e.elements,i=t.elements,r=n[0]-i[0],a=n[1]-i[1],o=n[2]-i[2],s=n[3]-i[3];return r*r+a*a+o*o+s*s},e.distance=function(e,t){var n=e.elements,i=t.elements,r=n[0]-i[0],a=n[1]-i[1],o=n[2]-i[2],s=n[3]-i[3];return Math.sqrt(r*r+a*a+o*o+s*s)},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.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]),i[3]=Math.min(r[3],a[3])},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]),i[3]=Math.max(r[3],a[3])},o(e,["ZERO",function(){return this.ZERO=new e},"ONE",function(){return this.ONE=new e(1,1,1,1)},"UnitX",function(){return this.UnitX=new e(1,0,0,0)},"UnitY",function(){return this.UnitY=new e(0,1,0,0)},"UnitZ",function(){return this.UnitZ=new e(0,0,1,0)},"UnitW",function(){return this.UnitW=new e(0,0,0,1)}]),e}(),Bt=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}s(e,"laya.d3.math.Viewport");var t=e.prototype;return t.project=function(e,t,n){bt.transformV3ToV3(e,t,n);var i=e.elements,r=t.elements,a=n.elements,o=i[0]*r[3]+i[1]*r[7]+i[2]*r[11]+r[15];1!==o&&(a[0]=a[0]/o,a[1]=a[1]/o,a[2]=a[2]/o),a[0]=.5*(a[0]+1)*this.width+this.x,a[1]=.5*(1-a[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 o=(this.maxDepth-this.minDepth)/2;a[2]=(i[2]-this.minDepth-o)/o;var s=a[0]*r[3]+a[1]*r[7]+a[2]*r[11]+r[15];bt.transformV3ToV3(n,t,n),1!==s&&(a[0]=a[0]/s,a[1]=a[1]/s,a[2]=a[2]/s)},t.unprojectFromWVP=function(t,n,i,r,a){Ct.multiply(n,i,e._tempMatrix4x4),r&&Ct.multiply(e._tempMatrix4x4,r,e._tempMatrix4x4),e._tempMatrix4x4.invert(e._tempMatrix4x4),this.unprojectFromMat(t,e._tempMatrix4x4,a)},o(e,["_tempMatrix4x4",function(){return this._tempMatrix4x4=new Ct}]),e}(),Ut=function(){function e(){this._alphaBlending=1,this._colorIntensity=1,this._shaderValue=new Wt}s(e,"laya.d3.resource.models.Sky");var t=e.prototype;return t._setEnvironmentDiffuse=function(){this._environmentDiffuse.loaded?this.__ownerCamera._shaderValues.setValue(7,this._environmentDiffuse):this._environmentDiffuse.on("loaded",this,this._environmentDiffuseLoaded)},t._setEnvironmentSpecular=function(){if(this._environmentSpecular.loaded){var e=this._environmentSpecular.simLodInfo;e&&e instanceof Float32Array&&this.__ownerCamera._shaderValues.setValue(9,e),this.__ownerCamera._shaderValues.setValue(8,this._environmentSpecular)}else this._environmentSpecular.on("loaded",this,this._environmentSpecularLoaded)},t._environmentDiffuseLoaded=function(){this.__ownerCamera._shaderValues.setValue(7,this._environmentDiffuse)},t._environmentSpecularLoaded=function(){var e=this._environmentSpecular.simLodInfo;e&&e instanceof Float32Array&&this.__ownerCamera._shaderValues.setValue(9,e),this.__ownerCamera._shaderValues.setValue(8,this._environmentSpecular)},t._render=function(e){},t.destroy=function(){this.__ownerCamera=null},l(0,t,"_ownerCamera",null,function(e){this.__ownerCamera=e,this._environmentDiffuse&&this._setEnvironmentDiffuse(),this._environmentSpecular&&this._setEnvironmentSpecular()}),l(0,t,"alphaBlending",function(){return this._alphaBlending},function(e){this._alphaBlending=e,this._alphaBlending<0&&(this._alphaBlending=0),this._alphaBlending>1&&(this._alphaBlending=1)}),l(0,t,"envDiffuseSHBlue",null,function(e){this.__ownerCamera._shaderValues.setValue(12,e)}),l(0,t,"colorIntensity",function(){return this._colorIntensity},function(e){this._colorIntensity=e,this._colorIntensity<0&&(this._colorIntensity=0)}),l(0,t,"envDiffuseSHGreen",null,function(e){this.__ownerCamera._shaderValues.setValue(11,e)}),l(0,t,"envDiffuseSHRed",null,function(e){this.__ownerCamera._shaderValues.setValue(10,e)}),l(0,t,"environmentDiffuse",function(){return this._environmentDiffuse},function(e){e.minFifter=9728,this._environmentDiffuse=e,this.__ownerCamera&&this._setEnvironmentDiffuse()}),l(0,t,"environmentSpecular",function(){return this._environmentSpecular},function(e){this._environmentSpecular=e,this.__ownerCamera&&this._setEnvironmentSpecular()}),e.MVPMATRIX=0,e.INTENSITY=1,e.ALPHABLENDING=2,e.DIFFUSETEXTURE=3,e}(),Ht=function(){function e(e){this._mesh=null,this._boneIndicesList=null,this._subIndexBufferStart=null,this._subIndexBufferCount=null,this._skinAnimationDatas=null,this._bufferUsage=null,this._indexInMesh=0,this._vertexBuffer=null,this._vertexStart=0,this._vertexCount=0,this._indexBuffer=null,this._indexStart=0,this._indexCount=0,this._indices=null,this._bufferUsage={},this._mesh=e,this._boneIndicesList=[],this._subIndexBufferStart=[],this._subIndexBufferCount=[]}s(e,"laya.d3.resource.models.SubMesh");var t=e.prototype;return a.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._getStaticBatchBakedVertexs=function(t,n){var i,r,a=this._vertexBuffer,o=a.vertexDeclaration,s=o.getVertexElementByUsage(0).offset/4,l=o.getVertexElementByUsage(3).offset/4,h=n.meshRender.lightmapScaleOffset,_=0,u=0,c=0,d=0,f=0,m=0;if(h)if(r=o.getVertexElementByUsage(15))c=o.vertexStride/4,i=this._vertexCount>0?a.getData().slice(this._vertexStart*c,(this._vertexStart+this._vertexCount)*c):a.getData().slice(),d=r.offset/4;else{c=2+(m=o.vertexStride/4),i=this._vertexCount?new Float32Array(this._vertexCount*(a.vertexDeclaration.vertexStride/4+2)):new Float32Array(a.vertexCount*(a.vertexDeclaration.vertexStride/4+2)),d=2+(f=o.getVertexElementByUsage(2).offset/4);var p=a.getData();for(_=0,u=p.length/m;_<u;_++){var v;v=this._vertexCount>0?(this._vertexStart+_)*m:_*m;var E=_*c,g=0;for(g=0;g<d;g++)i[E+g]=p[v+g];for(g=d;g<m;g++)i[E+g+2]=p[v+g]}}else c=o.vertexStride/4,i=this._vertexCount?a.getData().slice(this._vertexStart*c,(this._vertexStart+this._vertexCount)*c):a.getData().slice();if(t){var D=t.worldMatrix,T=e._tempMatrix4x40;D.invert(T);var S=e._tempMatrix4x41,x=n.transform.worldMatrix;Ct.multiply(T,x,S)}else S=n.transform.worldMatrix;var M=e._tempQuaternion0;for(S.decomposeTransRotScale(e._tempVector30,M,e._tempVector31),_=0,u=i.length/c;_<u;_++){var R=_*c+s,A=_*c+l;if(Jt.transformVector3ArrayToVector3ArrayCoordinate(i,R,S,i,R),Jt.transformVector3ArrayByQuat(i,A,M,i,A),h){var I=_*c+d;if(r)Jt.transformLightingMapTexcoordByUV1Array(i,I,h,i,I);else{var y=_*m+f;Jt.transformLightingMapTexcoordByUV0Array(p,y,h,i,I)}}}return i},t._getVertexBuffers=function(){return null},t._beforeRender=function(e){return this._vertexBuffer._bind(),this._indexBuffer._bind(),!0},t._render=function(e){var t,n=0,i=e.renderElement;if(this._indexCount>1){var r=this._boneIndicesList.length;if(r>1){for(var a=0;a<r;a++)(t=i._skinAnimationDatas||this._skinAnimationDatas)&&(i._shaderValue.setValue(0,t[a]),e._shader.uploadRenderElementUniforms(i._shaderValue.data)),b.mainContext.drawElements(4,this._subIndexBufferCount[a],5123,2*this._subIndexBufferStart[a]);w.drawCall+=r}else(t=i._skinAnimationDatas||this._skinAnimationDatas)&&(i._shaderValue.setValue(0,t[0]),e._shader.uploadRenderElementUniforms(i._shaderValue.data)),b.mainContext.drawElements(4,this._indexCount,5123,2*this._indexStart),w.drawCall++;n=this._indexCount}else n=this._indexBuffer.indexCount,(t=i._skinAnimationDatas||this._skinAnimationDatas)&&(i._shaderValue.setValue(0,t[0]),e._shader.uploadRenderElementUniforms(i._shaderValue.data)),b.mainContext.drawElements(4,n,5123,0),w.drawCall++;w.trianglesFaces+=n/3},t.getIndices=function(){return this._indexCount>0?this._indices:this._indexBuffer.getData()},t.dispose=function(){this._indexBuffer.destroy(),this._vertexBuffer.destroy(),this._mesh=null,this._boneIndicesList=null,this._subIndexBufferStart=null,this._subIndexBufferCount=null,this._skinAnimationDatas=null,this._bufferUsage=null,this._vertexBuffer=null,this._indexBuffer=null},l(0,t,"_vertexBufferCount",function(){return 1}),l(0,t,"triangleCount",function(){return this._indexBuffer.indexCount/3}),o(e,["_tempVector30",function(){return this._tempVector30=new bt},"_tempVector31",function(){return this._tempVector31=new bt},"_tempQuaternion0",function(){return this._tempQuaternion0=new wt},"_tempMatrix4x40",function(){return this._tempMatrix4x40=new Ct},"_tempMatrix4x41",function(){return this._tempMatrix4x41=new Ct}]),e}(),Gt=function(){function e(e){this.defineCounter=0,this.defines=null,e?(this.defineCounter=e.defineCounter,this.defines=e.defines.slice()):(this.defineCounter=0,this.defines=[])}return s(e,"laya.d3.shader.ShaderDefines",null,"ShaderDefines$1"),e.prototype.registerDefine=function(e){var t=Math.pow(2,this.defineCounter++);return this.defines[t]=e,t},e}(),zt=function(){function e(){}return s(e,"laya.d3.shader.ShaderInit3D"),e.__init__=function(){fn._globalRegDefine("HIGHPRECISION",fn.SHADERDEFINE_HIGHPRECISION),fn._globalRegDefine("FOG",fn.SHADERDEFINE_FOG),fn._globalRegDefine("DIRECTIONLIGHT",fn.SHADERDEFINE_DIRECTIONLIGHT),fn._globalRegDefine("POINTLIGHT",fn.SHADERDEFINE_POINTLIGHT),fn._globalRegDefine("SPOTLIGHT",fn.SHADERDEFINE_SPOTLIGHT),fn._globalRegDefine("UV",fn.SHADERDEFINE_UV0),fn._globalRegDefine("COLOR",fn.SHADERDEFINE_COLOR),fn._globalRegDefine("UV1",fn.SHADERDEFINE_UV1),fn._globalRegDefine("CASTSHADOW",kt.SHADERDEFINE_CAST_SHADOW),fn._globalRegDefine("SHADOWMAP_PSSM1",kt.SHADERDEFINE_SHADOW_PSSM1),fn._globalRegDefine("SHADOWMAP_PSSM2",kt.SHADERDEFINE_SHADOW_PSSM2),fn._globalRegDefine("SHADOWMAP_PSSM3",kt.SHADERDEFINE_SHADOW_PSSM3),fn._globalRegDefine("SHADOWMAP_PCF_NO",kt.SHADERDEFINE_SHADOW_PCF_NO),fn._globalRegDefine("SHADOWMAP_PCF1",kt.SHADERDEFINE_SHADOW_PCF1),fn._globalRegDefine("SHADOWMAP_PCF2",kt.SHADERDEFINE_SHADOW_PCF2),fn._globalRegDefine("SHADOWMAP_PCF3",kt.SHADERDEFINE_SHADOW_PCF3),fn._globalRegDefine("DEPTHFOG",fn.SAHDERDEFINE_DEPTHFOG),Gn.addInclude("LightHelper.glsl","\nstruct DirectionLight\n{\n vec3 Direction;\n vec3 Diffuse;\n};\n\nstruct PointLight\n{\n vec3 Diffuse;\n vec3 Attenuation;\n vec3 Position;\n float Range;\n};\n\nstruct SpotLight\n{\n vec3 Diffuse;\n vec3 Attenuation;\n vec3 Position;\n vec3 Direction;\n float Spot;\n float Range;\n};\n\n\nvec3 NormalSampleToWorldSpace(vec3 normalMapSample, vec3 unitNormal, vec3 tangent)\n{\n\tvec3 normalT = 2.0*normalMapSample - 1.0;\n\n\t// Build orthonormal basis.\n\tvec3 N = normalize(unitNormal);\n\tvec3 T = normalize(tangent- dot(tangent, N)*N);\n\tvec3 B = cross(T, N);\n\n\tmat3 TBN = mat3(T, B, N);\n\n\t// Transform from tangent space to world space.\n\tvec3 bumpedNormal = TBN*normalT;\n\n\treturn bumpedNormal;\n}\n\n\nvoid  computeDirectionLight(in vec3 matDif,in vec3 matAmb,in vec4 matSpe,in DirectionLight dirLight,in vec3 ambinentColor,in vec3 normal,in vec3 toEye,out vec3 dif,out vec3 amb,out vec3 spec)\n{\n\tdif=vec3(0.0);//不初始化在IOS中闪烁，PC中不会闪烁\n\tamb=vec3(0.0);\n\tspec=vec3(0.0);\n\tvec3 lightVec=-normalize(dirLight.Direction);\n\t\n\tamb=matAmb*ambinentColor;\n\t\n\tfloat  diffuseFactor=dot(lightVec, normal);\n\t\n\tif(diffuseFactor>0.0)\n\t{\n\t   vec3 v = reflect(-lightVec, normal);\n\t   float specFactor = pow(max(dot(v, toEye), 0.0), matSpe.w);\n\t   \n\t   dif = diffuseFactor * matDif * dirLight.Diffuse;\n\t   spec = specFactor * matSpe.rgb;\n\t}\n\t\n}\n\nvoid computePointLight(in vec3 matDif,in vec3 matAmb,in vec4 matSpe,in PointLight poiLight,in vec3 ambinentColor, in vec3 pos,in vec3 normal,in vec3 toEye,out vec3 dif,out vec3 amb,out vec3 spec)\n{\n\tdif=vec3(0.0);\n\tamb=vec3(0.0);\n\tspec=vec3(0.0);\n\tvec3 lightVec = poiLight.Position - pos;\n\t\t\n\tfloat d = length(lightVec);\n\t\n\tif( d > poiLight.Range )\n\t\treturn;\n\t\t\n\tlightVec /= d; \n\t\n\tamb = matAmb*ambinentColor;\t\n\n\tfloat diffuseFactor = dot(lightVec, normal);\n\n\tif( diffuseFactor > 0.0 )\n\t{\n\t\tvec3 v= reflect(-lightVec, normal);\n\t\tfloat specFactor = pow(max(dot(v, toEye), 0.0), matSpe.w);\n\t\t\t\t\t\n\t\tdif = diffuseFactor * matDif * poiLight.Diffuse;\n\t\tspec = specFactor * matSpe.rgb;\n\t}\n\n\tfloat attenuate = 1.0 / dot(poiLight.Attenuation, vec3(1.0, d, d*d));\n\n\tdif *= attenuate;\n\tspec*= attenuate;\n}\n\nvoid ComputeSpotLight(in vec3 matDif,in vec3 matAmb,in vec4 matSpe,in SpotLight spoLight,in vec3 ambinentColor,in vec3 pos, in vec3 normal,in vec3 toEye,out vec3 dif,out vec3 amb,out vec3 spec)\n{\n\tamb = vec3(0.0);\n\tdif =vec3(0.0);\n\tspec= vec3(0.0);\n\tvec3 lightVec = spoLight.Position - pos;\n\t\t\n\tfloat d = length(lightVec);\n\t\n\tif( d > spoLight.Range)\n\t\treturn;\n\t\t\n\tlightVec /= d; \n\t\n\tamb = matAmb*ambinentColor;\t\n\n\tfloat diffuseFactor = dot(lightVec, normal);\n\n\tif(diffuseFactor > 0.0)\n\t{\n\t\tvec3 v= reflect(-lightVec, normal);\n\t\tfloat specFactor = pow(max(dot(v, toEye), 0.0), matSpe.w);\n\t\t\t\t\t\n\t\tdif = diffuseFactor * matDif * spoLight.Diffuse;\n\t\tspec = specFactor * matSpe.rgb;\n\t}\n\t\n\tfloat spot = pow(max(dot(-lightVec, normalize(spoLight.Direction)), 0.0), spoLight.Spot);\n\n\tfloat attenuate = spot/dot(spoLight.Attenuation, vec3(1.0, d, d*d));\n\n\tamb *= spot;\n\tdif *= attenuate;\n\tspec*= attenuate;\n}\n\n"),Gn.addInclude("Lighting.glsl","\nstruct DirectionLight\n{\n\tvec3 Color;\n\tvec3 Direction;\n};\n\nstruct PointLight\n{\n\tvec3 Color;\n\tvec3 Position;\n\tfloat Range;\n};\n\nstruct SpotLight\n{\n\tvec3 Color;\n\tvec3 Position;\n\tvec3 Direction;\n\tfloat Spot;\n\tfloat Range;\n};\n\n// U3D中使用衰减纹理,此函数模拟并非正确\n//float U3DAttenuation(in vec3 L,in float invLightRadius)\n//{\n//\tfloat fRatio = clamp(length(L) * invLightRadius,0.0,1.0);\n//\tfRatio *= fRatio;\n//\treturn 1.0 / (1.0 + 25.0 * fRatio)* clamp(4.0*(1.0 - fRatio),0.0,1.0); //fade to black as if 4 pixel texture\n//} \n\n// Same as Just Cause 2 and Crysis 2 (you can read GPU Pro 1 book for more information)\nfloat BasicAttenuation(in vec3 L,in float invLightRadius)\n{\n\tvec3 distance = L * invLightRadius;\n\tfloat attenuation = clamp(1.0 - dot(distance, distance),0.0,1.0); // Equals float attenuation = saturate(1.0f - dot(L, L) / (lightRadius *  lightRadius)); \t\n\treturn attenuation * attenuation;\n} \n\n// Inspired on http://fools.slindev.com/viewtopic.php?f=11&t=21&view=unread#unread\t\nfloat NaturalAttenuation(in vec3 L,in float invLightRadius)\n{\n\tfloat attenuationFactor = 30.0;\n\tvec3 distance = L * invLightRadius;\n\tfloat attenuation = dot(distance, distance); // Equals float attenuation = dot(L, L) / (lightRadius *  lightRadius);\n\tattenuation = 1.0 / (attenuation * attenuationFactor + 1.0);\n\t// Second we move down the function therewith it reaches zero at abscissa 1:\n\tattenuationFactor = 1.0 / (attenuationFactor + 1.0); //attenuationFactor contains now the value we have to subtract\n\tattenuation = max(attenuation - attenuationFactor, 0.0); // The max fixes a bug.\n\t// Finally we expand the equation along the y-axis so that it starts with a function value of 1 again.\n\tattenuation /= 1.0 - attenuationFactor;\n\treturn attenuation;\n} \n\nvoid LayaAirBlinnPhongLight (in vec3 specColor,in float specColorIntensity,in vec3 normal,in vec3 gloss, in vec3 viewDir,in vec3 lightColor, in vec3 lightVec,out vec3 diffuseColor,out vec3 specularColor)\n{\n    mediump vec3 h = normalize(viewDir-lightVec);\n    lowp float ln = max (0.0, dot (-lightVec,normal));\n    float nh = max (0.0, dot (h,normal));\n\tdiffuseColor=lightColor * ln;\n\tspecularColor=lightColor *specColor*pow (nh, specColorIntensity*128.0) * gloss;\n}\n\nvoid LayaAirBlinnPhongDiectionLight (in vec3 specColor,in float specColorIntensity,in vec3 normal,in vec3 gloss, in vec3 viewDir, in DirectionLight light,out vec3 diffuseColor,out vec3 specularColor)\n{\n\tvec3 lightVec=normalize(light.Direction);\n\tLayaAirBlinnPhongLight(specColor,specColorIntensity,normal,gloss,viewDir,light.Color,lightVec,diffuseColor,specularColor);\n}\n\nvoid LayaAirBlinnPhongPointLight (in vec3 pos,in vec3 specColor,in float specColorIntensity,in vec3 normal,in vec3 gloss, in vec3 viewDir, in PointLight light,out vec3 diffuseColor,out vec3 specularColor)\n{\n\tvec3 lightVec =  pos-light.Position;\n\t//if( length(lightVec) > light.Range )\n\t//\treturn;\n\tLayaAirBlinnPhongLight(specColor,specColorIntensity,normal,gloss,viewDir,light.Color,lightVec/length(lightVec),diffuseColor,specularColor);\n\tfloat attenuate = BasicAttenuation(lightVec, 1.0/light.Range);\n\tdiffuseColor *= attenuate;\n\tspecularColor*= attenuate;\n}\n\nvoid LayaAirBlinnPhongSpotLight (in vec3 pos,in vec3 specColor,in float specColorIntensity,in vec3 normal,in vec3 gloss, in vec3 viewDir, in SpotLight light,out vec3 diffuseColor,out vec3 specularColor)\n{\n\tvec3 lightVec =  pos-light.Position;\n\t//if( length(lightVec) > light.Range )\n\t//\treturn;\n\tvec3 normalLightVec=lightVec/length(lightVec);\n\tLayaAirBlinnPhongLight(specColor,specColorIntensity,normal,gloss,viewDir,light.Color,normalLightVec,diffuseColor,specularColor);\n\tfloat spot = pow(max(dot(normalLightVec, normalize(light.Direction)), 0.0), light.Spot);\n\tfloat attenuate = spot*BasicAttenuation(lightVec, 1.0/light.Range);\n\tdiffuseColor *= attenuate;\n\tspecularColor*= attenuate;\n}\n\nvec3 NormalSampleToWorldSpace(vec3 normalMapSample, vec3 unitNormal, vec3 tangent,vec3 binormal)\n{\n\tvec3 normalT =vec3(2.0*normalMapSample.x - 1.0,1.0-2.0*normalMapSample.y,2.0*normalMapSample.z - 1.0);\n\t\n\t// Build orthonormal basis.\n\tvec3 N = normalize(unitNormal);\n\tvec3 T = normalize(tangent);\n\tvec3 B = normalize(binormal);\n\tmat3 TBN = mat3(T, B, N);\n\t\n\t// Transform from tangent space to world space.\n\tvec3 bumpedNormal = TBN*normalT;\n\n\treturn bumpedNormal;\n}\n\n\n"),Gn.addInclude("ShadowHelper.glsl","uniform sampler2D u_shadowMap1;\nuniform sampler2D u_shadowMap2;\nuniform sampler2D u_shadowMap3;\nuniform vec2\t  u_shadowPCFoffset;\nuniform vec4     u_shadowPSSMDistance;\nvec4 packDepth(const in float depth)\n{\n\tconst vec4 bitShift = vec4(256.0*256.0*256.0, 256.0*256.0, 256.0, 1.0);\n\tconst vec4 bitMask\t= vec4(0.0, 1.0/256.0, 1.0/256.0, 1.0/256.0);\n\tvec4 res = mod(depth*bitShift*vec4(255), vec4(256))/vec4(255);\n\tres -= res.xxyz * bitMask;\n\treturn res;\n}\nfloat unpackDepth(const in vec4 rgbaDepth)\n{\n\tconst vec4 bitShift = vec4(1.0/(256.0*256.0*256.0), 1.0/(256.0*256.0), 1.0/256.0, 1.0);\n\tfloat depth = dot(rgbaDepth, bitShift);\n\treturn depth;\n}\nfloat tex2DPCF( sampler2D shadowMap,vec2 texcoord,vec2 invsize,float zRef )\n{\n\tvec2 texelpos =texcoord / invsize;\n\tvec2 lerps = fract( texelpos );\n\tfloat sourcevals[4];\n\tsourcevals[0] = float( unpackDepth(texture2D(shadowMap,texcoord)) > zRef );\n\tsourcevals[1] = float( unpackDepth(texture2D(shadowMap,texcoord + vec2(invsize.x,0))) > zRef );\n\tsourcevals[2] = float( unpackDepth(texture2D(shadowMap,texcoord + vec2(0,invsize.y))) > zRef );\n\tsourcevals[3] = float( unpackDepth(texture2D(shadowMap,texcoord + vec2(invsize.x, invsize.y) )) > zRef );\n\treturn mix( mix(sourcevals[0],sourcevals[2],lerps.y),mix(sourcevals[1],sourcevals[3],lerps.y),lerps.x );\n}\nfloat getShadowPSSM3( sampler2D shadowMap1,sampler2D shadowMap2,sampler2D shadowMap3,mat4 lightShadowVP[4],vec4 pssmDistance,vec2 shadowPCFOffset,vec3 worldPos,float posViewZ,float zBias )\n{\n\tfloat value = 1.0;\n\tint nPSNum = int(posViewZ>pssmDistance.x);\n\tnPSNum += int(posViewZ>pssmDistance.y);\n\tnPSNum += int(posViewZ>pssmDistance.z);\n\t//真SB,webgl不支持在PS中直接访问数组\n\tmat4 lightVP;\n\tif( nPSNum == 0 )\n\t{\n\t\tlightVP = lightShadowVP[1];\n\t}\n\telse if( nPSNum == 1 )\n\t{\n\t\tlightVP = lightShadowVP[2];\n\t}\n\telse if( nPSNum == 2 )\n\t{\n\t\tlightVP = lightShadowVP[3];\n\t}\n\tvec4 vLightMVPPos = lightVP * vec4(worldPos,1.0);\n\t//为了效率，在CPU计算/2.0 + 0.5\n\t//vec3 vText = (vLightMVPPos.xyz / vLightMVPPos.w)/2.0 + 0.5;\n\tvec3 vText = vLightMVPPos.xyz / vLightMVPPos.w;\n\tfloat fMyZ = vText.z - zBias;\n\t/*\n\tbvec4 bInFrustumVec = bvec4 ( vText.x >= 0.0, vText.x <= 1.0, vText.y >= 0.0, vText.y <= 1.0 );\n\tbool bInFrustum = all( bInFrustumVec );\n\tbvec2 bFrustumTestVec = bvec2( bInFrustum, fMyZ <= 1.0 );\n\tbool bFrustumTest = all( bFrustumTestVec );\n\tif ( bFrustumTest ) \n\t*/\n\tif( fMyZ <= 1.0 )\n\t{\n\t\tfloat zdepth=0.0;\n#ifdef SHADOWMAP_PCF3\n\t\tif ( nPSNum == 0 )\n\t\t{\n\t\t\tvalue =  tex2DPCF( shadowMap1, vText.xy,shadowPCFOffset,fMyZ );\n\t\t\tvalue += tex2DPCF( shadowMap1, vText.xy+vec2(shadowPCFOffset.xy),shadowPCFOffset,\tfMyZ );\n\t\t\tvalue += tex2DPCF( shadowMap1, vText.xy+vec2(shadowPCFOffset.x,0),shadowPCFOffset,\tfMyZ );\n\t\t\tvalue += tex2DPCF( shadowMap1, vText.xy+vec2(0,shadowPCFOffset.y),shadowPCFOffset,\tfMyZ );\n\t\t\tvalue = value/4.0;\n\t\t} \n\t\telse if( nPSNum == 1 )\n\t\t{\n\t\t\tvalue = tex2DPCF( shadowMap2,vText.xy,shadowPCFOffset,fMyZ);\n\t\t}\n\t\telse if( nPSNum == 2 )\n\t\t{\n\t\t\tvec4 color = texture2D( shadowMap3,vText.xy );\n\t\t\tzdepth = unpackDepth(color);\n\t\t\tvalue = float(fMyZ < zdepth);\n\t\t}\n#endif\n#ifdef SHADOWMAP_PCF2\n\t\tif ( nPSNum == 0 )\n\t\t{\n\t\t\tvalue = tex2DPCF( shadowMap1,vText.xy,shadowPCFOffset,fMyZ);\n\t\t}\n\t\telse if( nPSNum == 1 )\n\t\t{\n\t\t\tvalue = tex2DPCF( shadowMap2,vText.xy,shadowPCFOffset,fMyZ);\n\t\t}\n\t\telse if( nPSNum == 2 )\n\t\t{\n\t\t\tvec4 color = texture2D( shadowMap3,vText.xy );\n\t\t\tzdepth = unpackDepth(color);\n\t\t\tvalue = float(fMyZ < zdepth);\n\t\t}\n\n#endif\n#ifdef SHADOWMAP_PCF1\n\t\tif ( nPSNum == 0 )\n\t\t{\n\t\t\tvalue = tex2DPCF( shadowMap1,vText.xy,shadowPCFOffset,fMyZ);\n\t\t}\n\t\telse if( nPSNum == 1 )\n\t\t{\n\t\t\tvec4 color = texture2D( shadowMap2,vText.xy );\n\t\t\tzdepth = unpackDepth(color);\n\t\t\tvalue = float(fMyZ < zdepth);\n\t\t}\n\t\telse if( nPSNum == 2 )\n\t\t{\n\t\t\tvec4 color = texture2D( shadowMap3,vText.xy );\n\t\t\tzdepth = unpackDepth(color);\n\t\t\tvalue = float(fMyZ < zdepth);\n\t\t}\n#endif\n#ifdef SHADOWMAP_PCF_NO\n\t\tvec4 color;\n\t\tif ( nPSNum == 0 )\n\t\t{\n\t\t\tcolor = texture2D( shadowMap1,vText.xy );\n\t\t}\n\t\telse if( nPSNum == 1 )\n\t\t{\n\t\t\tcolor = texture2D( shadowMap2,vText.xy );\n\t\t}\n\t\telse if( nPSNum == 2 )\n\t\t{\n\t\t\tcolor = texture2D( shadowMap3,vText.xy );\n\t\t}\n\t\tzdepth = unpackDepth(color);\n\t\tvalue = float(fMyZ < zdepth);\n#endif\n\t}\n\treturn value;\n}\nfloat getShadowPSSM2( sampler2D shadowMap1,sampler2D shadowMap2,mat4 lightShadowVP[4],vec4 pssmDistance,vec2 shadowPCFOffset,vec3 worldPos,float posViewZ,float zBias )\n{\n\tfloat value = 1.0;\n\tint nPSNum = int(posViewZ>pssmDistance.x);\n\tnPSNum += int(posViewZ>pssmDistance.y);\n\t//真SB,webgl不支持在PS中直接访问数组\n\tmat4 lightVP;\n\tif( nPSNum == 0 )\n\t{\n\t\tlightVP = lightShadowVP[1];\n\t}\n\telse if( nPSNum == 1 )\n\t{\n\t\tlightVP = lightShadowVP[2];\n\t}\n\tvec4 vLightMVPPos = lightVP * vec4(worldPos,1.0);\n\t//为了效率，在CPU计算/2.0 + 0.5\n\t//vec3 vText = (vLightMVPPos.xyz / vLightMVPPos.w)/2.0 + 0.5;\n\tvec3 vText = vLightMVPPos.xyz / vLightMVPPos.w;\n\tfloat fMyZ = vText.z - zBias;\n\t/*\n\tbvec4 bInFrustumVec = bvec4 ( vText.x >= 0.0, vText.x <= 1.0, vText.y >= 0.0, vText.y <= 1.0 );\n\tbool bInFrustum = all( bInFrustumVec );\n\tbvec2 bFrustumTestVec = bvec2( bInFrustum, fMyZ <= 1.0 );\n\tbool bFrustumTest = all( bFrustumTestVec );\n\tif ( bFrustumTest ) \n\t*/\n\tif( fMyZ <= 1.0 )\n\t{\n\t\tfloat zdepth=0.0;\n#ifdef SHADOWMAP_PCF3\n\t\tif ( nPSNum == 0 )\n\t\t{\n\t\t\tvalue =  tex2DPCF( shadowMap1, vText.xy,shadowPCFOffset,fMyZ );\n\t\t\tvalue += tex2DPCF( shadowMap1, vText.xy+vec2(shadowPCFOffset.xy),shadowPCFOffset,\tfMyZ );\n\t\t\tvalue += tex2DPCF( shadowMap1, vText.xy+vec2(shadowPCFOffset.x,0),shadowPCFOffset,\tfMyZ );\n\t\t\tvalue += tex2DPCF( shadowMap1, vText.xy+vec2(0,shadowPCFOffset.y),shadowPCFOffset,\tfMyZ );\n\t\t\tvalue = value/4.0;\n\t\t}\n\t\telse if( nPSNum == 1 )\n\t\t{\n\t\t\tvalue = tex2DPCF( shadowMap2,vText.xy,shadowPCFOffset,fMyZ);\n\t\t}\n#endif\n#ifdef SHADOWMAP_PCF2\n\t\tif ( nPSNum == 0 )\n\t\t{\n\t\t\tvalue = tex2DPCF( shadowMap1,vText.xy,shadowPCFOffset,fMyZ);\n\t\t}\n\t\telse if( nPSNum == 1 )\n\t\t{\n\t\t\tvalue = tex2DPCF( shadowMap2,vText.xy,shadowPCFOffset,fMyZ);\n\t\t}\n#endif\n#ifdef SHADOWMAP_PCF1\n\t\tif ( nPSNum == 0 )\n\t\t{\n\t\t\tvalue = tex2DPCF( shadowMap1,vText.xy,shadowPCFOffset,fMyZ);\n\t\t}\n\t\telse if( nPSNum == 1 )\n\t\t{\n\t\t\tvec4 color = texture2D( shadowMap2,vText.xy );\n\t\t\tzdepth = unpackDepth(color);\n\t\t\tvalue = float(fMyZ < zdepth);\n\t\t}\n#endif\n#ifdef SHADOWMAP_PCF_NO\n\t\tvec4 color;\n\t\tif ( nPSNum == 0 )\n\t\t{\n\t\t\tcolor = texture2D( shadowMap1,vText.xy );\n\t\t}\n\t\telse if( nPSNum == 1 )\n\t\t{\n\t\t\tcolor = texture2D( shadowMap2,vText.xy );\n\t\t}\n\t\tzdepth = unpackDepth(color);\n\t\tvalue = float(fMyZ < zdepth);\n#endif\n\t}\n\treturn value;\n}\nfloat getShadowPSSM1( sampler2D shadowMap1,vec4 lightMVPPos,vec4 pssmDistance,vec2 shadowPCFOffset,float posViewZ,float zBias )\n{\n\tfloat value = 1.0;\n\tif( posViewZ < pssmDistance.x )\n\t{\n\t\tvec3 vText = lightMVPPos.xyz / lightMVPPos.w;\n\t\tfloat fMyZ = vText.z - zBias;\n\t\t/*\n\t\tbvec4 bInFrustumVec = bvec4 ( vText.x >= 0.0, vText.x <= 1.0, vText.y >= 0.0, vText.y <= 1.0 );\n\t\tbool bInFrustum = all( bInFrustumVec );\n\t\tbvec2 bFrustumTestVec = bvec2( bInFrustum, fMyZ <= 1.0 );\n\t\tbool bFrustumTest = all( bFrustumTestVec );\n\t\t*/\n\t\tif ( fMyZ <= 1.0 ) \n\t\t{\n\t\t\tfloat zdepth=0.0;\n#ifdef SHADOWMAP_PCF3\n\t\t\tvalue =  tex2DPCF( shadowMap1, vText.xy,shadowPCFOffset,fMyZ );\n\t\t\tvalue += tex2DPCF( shadowMap1, vText.xy+vec2(shadowPCFOffset.xy),shadowPCFOffset,fMyZ );\n\t\t\tvalue += tex2DPCF( shadowMap1, vText.xy+vec2(shadowPCFOffset.x,0),shadowPCFOffset,fMyZ );\n\t\t\tvalue += tex2DPCF( shadowMap1, vText.xy+vec2(0,shadowPCFOffset.y),shadowPCFOffset,fMyZ );\n\t\t\tvalue = value/4.0;\n#endif\n#ifdef SHADOWMAP_PCF2\t\t\n\t\t\tvalue = tex2DPCF( shadowMap1,vText.xy,shadowPCFOffset,fMyZ);\n#endif\n#ifdef SHADOWMAP_PCF1\n\t\t\tvalue = tex2DPCF( shadowMap1,vText.xy,shadowPCFOffset,fMyZ);\n#endif\n#ifdef SHADOWMAP_PCF_NO\t\t\n\t\t\tvec4 color = texture2D( shadowMap1,vText.xy );\n\t\t\tzdepth = unpackDepth(color);\n\t\t\tvalue = float(fMyZ < zdepth);\n#endif\n\t\t}\n\t}\n\treturn value;\n}"),Gn.addInclude("WaveFunction.glsl","\nuniform vec2 u_WaveInfoD[20];\nuniform vec4 u_WaveInfo[20];\n\nuniform float TEXWAVE_UV_SCALE ;//= 20.0; //每texwidth像素代表的实际距离\n/**\n\t这里的计算都是\n*/\n\n/**\n* 计算一个波形\n*  开始计算的时候都按照z向上，最后输出的时候，颠倒一下。\n* @param tm {float} 毫秒\n*/\nvoid calcGerstnerWave(float curtm, vec3 pos, float deep, vec2 uvpos, out vec3 opos, out vec3 B, out vec3 T, out vec3 N, out float foamS){\n\tfloat tm = curtm/1000.;\n\topos = pos;\n\tvec3 wpos=vec3(0.);\t\t//累加的位置\n\tN=vec3(0.,0.,0.);\t//输出的法线初始化一下\n\tT=vec3(0.,0.,0.);\n\tB=vec3(0.,0.,0.);\n\tvec2 cD ;//= D;\n\t//float deepAtt = max(0.,min(deep,1.0));\n\t//A*=deepAtt; //TODO\n\t\n\tfor( int i=0; i<4; i++){\n\t\tcD = u_WaveInfoD[i];//vec2(wi.winfo[0],wi.winfo[1]);// wi.vDir;\n\t\tfloat Q = u_WaveInfo[i].x;//wi.QorK;\n\t\tfloat A = u_WaveInfo[i].y;//wi.A;\n\t\tfloat W = u_WaveInfo[i].z;//wi.omega;\n\t\tfloat P = u_WaveInfo[i].w;//wi.phi;\n\t\tfloat dop = dot(cD,uvpos);\n\t\tfloat c = cos(dop*W - tm*P);//TODO 优化\n\t\tfloat s = sin(dop*W - tm*P);\n\t\tfloat AWs = A*W*s;\n\t\tfloat AWc = A*W*c;\n\t\tfloat _QxyAWs = -Q*cD.x*cD.y*AWs;\n\t\t\n\t\twpos += vec3(Q*A*cD.x*c,\n\t\t\t\t\tQ*A*cD.y*c,\n\t\t\t\t\tA*s);\n\t\tN += vec3(-cD.x*AWc,\n\t\t\t\t-cD.y*AWc,\n\t\t\t\tQ*AWs);//记得最后1-\n\t\tT += vec3(_QxyAWs,\n\t\t\t\tQ*cD.y*cD.y*AWs,//记得1-\n\t\t\t\tcD.y*AWc\n\t\t\t);\n\t\tB += vec3(Q*cD.x*cD.x*AWs,//记得1-\n\t\t\t\t_QxyAWs,\n\t\t\t\tcD.x*AWc\n\t\t\t);\n\t\t//float v1 = exp(-tan((dop*W - tm*P)/2.+1.07));//除2，+pi/2 这样正好能对齐\n#ifdef USE_FOAM\t\t\n\t\tfloat v1 = 0.5-sin((dop*W - tm*P)/1.+2.0)/2.;\n\t\tfoamS += pow(v1,9.)/4.;\n#endif\n\t}\n\tT.y=1.-T.y; B.x=1.-B.x;N.z=1.-N.z;\n\topos += vec3(wpos.x,wpos.z*min(deep/10.,1.),wpos.y);\n\t//y和z交换一下。现在根据uv计算的位置，所以直接交换yz就行。其他情况下有问题么\n\tT.xyz=T.xzy;\n\tB.xyz=B.xzy;\n\tN.xyz=N.xzy;\n}\n\n\nvoid calcWave(float curtm, vec2 uv, out vec3 B, out vec3 T, out vec3 N){\n\tfloat tm = curtm/1000.;\n\tN=vec3(0.,0.,0.);\t//输出的法线初始化一下\n\tvec2 uvpos = uv*TEXWAVE_UV_SCALE; //TODO 这个范围是什么 就是1？\n\tuvpos.y*=-1.;\n\tvec2 cD;// = D;\n\tconst int NumWaves = 4;\n\tfloat scale = 1./float(NumWaves);\n\tfor( int i=0; i<NumWaves; i++){\n\t\tcD = u_WaveInfoD[i];//vec2(wi.winfo[0],wi.winfo[1]);// wi.vDir;\n\t\tfloat k = 1.5;//u_WaveInfo[i].x;//wi.QorK; TODO  不知道为什么，这个取u_WaveInfo[i].x，在mi3w上就会闪。测试发现实际值也传过来了，就是1.5\n\t\tfloat A = u_WaveInfo[i].y;//wi.A;\n\t\tfloat W = u_WaveInfo[i].z;//wi.omega;\n\t\tfloat P = u_WaveInfo[i].w;//wi.phi;\n\t\t\n\t\tfloat dop = dot(cD,uvpos);\n\t\tfloat c = cos(dop*W - tm*P);//TODO 优化\n\t\tfloat s = sin(dop*W - tm*P);\n\t\t/*\n\t\tfloat AWs = A*W*s;\n\t\tfloat AWc = A*W*c;\n\t\tfloat _QxyAWs = -Q*cD.x*cD.y*AWs;\n\t\t\n\t\tN += vec3(-cD.x*AWc,\n\t\t\t\t-cD.y*AWc,\n\t\t\t\tQ*AWs);//记得最后1-\n\t\t*/\n\t\tfloat kWAc = scale*c;//k*W*A*c;  为了提高精度，这里只保留sin，cos部分，实际使用的时候再乘回来。\n\t\t//float kWAc = k*W*A*c;  \n\t\tN += vec3(\n\t\t\t-kWAc*cD.x*pow((s+1.)/2.,k-1.),\n\t\t\t-kWAc*cD.y*pow((s+1.)/2.,k-1.),\n\t\t\t1.\n\t\t);\n\t}\n\t//N.z=1.-N.z;\n\t//y和z交换一下。现在根据uv计算的位置，所以直接交换yz就行。其他情况下有问题么\n\tN.xyz=N.xzy;\n}\n"),Gn.addInclude("BRDF.glsl","vec4 LayaAirBRDF(in vec3 diffuseColor, in vec3 specularColor, in float oneMinusReflectivity, in float smoothness, in vec3 normal, in vec3 viewDir, in vec3 lightDir, in vec3 lightColor, in vec3 gi)\n{\n\tfloat perceptualRoughness = SmoothnessToPerceptualRoughness(smoothness);\n\tvec3 halfDir = SafeNormalize(viewDir - lightDir);\n\t\n\tfloat nv = abs(dot(normal, viewDir));\n\t\n\tfloat nl = clamp(dot(normal,   -lightDir),  0.0, 1.0);\n\tfloat nh = clamp(dot(normal,     halfDir),  0.0, 1.0);\n\tfloat lv = clamp(dot(lightDir,   viewDir),  0.0, 1.0);\n\tfloat lh = clamp(dot(lightDir,  -halfDir),  0.0, 1.0);\n\t\n\tfloat diffuseTerm = DisneyDiffuse(nv, nl, lh, perceptualRoughness) * nl;\n\t\n\tfloat roughness = PerceptualRoughnessToRoughness(perceptualRoughness);\n\t\n\t//#if UNITY_BRDF_GGX\n\tfloat V = SmithJointGGXVisibilityTerm(nl, nv, roughness);\n\tfloat D = GGXTerm(nh, roughness);\n\t\n\tfloat specularTerm = V * D * PI;\n\t\n\tspecularTerm = sqrt(max(0.0001, specularTerm));\n\tspecularTerm = max(0.0, specularTerm * nl);\n\t\n\tvec4 color;\n\tcolor.rgb = diffuseColor * (gi + lightColor * diffuseTerm) + specularTerm * lightColor * FresnelTerm (specularColor, lh);\n\t\n\tcolor.a = 1.0;\n\treturn color;\n}"),Gn.addInclude("PBRUtils.glsl","struct DirectionLight\n{\n\tvec3 Color;\n\tvec3 Direction;\n};\n\nvec3 UnpackScaleNormal(in vec2 uv0)\n{\n\t#ifdef NORMALTEXTURE\n\t\tvec3 normalT;\n\t\tvec4 normalMapSample = texture2D(u_NormalTexture, uv0);\n\t\tnormalT.x = 2.0 * normalMapSample.x - 1.0;\n\t\tnormalT.y = 1.0 - 2.0 * normalMapSample.y;\n\t\tnormalT.xy *= u_normalScale;\n\t\tnormalT.z = sqrt(1.0 - clamp(dot(normalT.xy, normalT.xy), 0.0, 1.0));\n\t\t\n\t\tvec3 T = normalize(v_Tangent);\n\t\tvec3 B = normalize(v_Binormal);\n\t\tvec3 N = normalize(v_Normal);\n\t\tmat3 TBN = mat3(T, B, N);\n\t\t\n\t\tvec3 bumpedNormal = TBN * normalize(normalT);\n\t\treturn bumpedNormal;\n\t#else\n\t\treturn normalize(v_Normal);\n\t#endif\n}\n\nvec4 DielectricSpecularColor = vec4(0.220916301, 0.220916301, 0.220916301, 1.0 - 0.220916301);\n\nfloat PI = 3.14159265359;\n\nvec3 FresnelTerm (in vec3 F0, in float cosA)\n{\n\treturn F0 + (vec3(1.0) - F0) * pow(1.0 - cosA, 5.0);\n}\n\nfloat PerceptualRoughnessToRoughness(in float perceptualRoughness)\n{\n\treturn perceptualRoughness * perceptualRoughness;\n}\n\nfloat PerceptualRoughnessToSpecularPower(in float perceptualRoughness)\n{\n\tfloat m = PerceptualRoughnessToRoughness(perceptualRoughness);\n\tfloat sq = max(0.0001, m * m);\n\tfloat n = (2.0 / sq) - 2.0;\n\tn = max(n, 0.0001);\n\treturn n;\n}\n\nfloat RoughnessToPerceptualRoughness(in float roughness)\n{\n\treturn sqrt(roughness);\n}\n\nfloat SmoothnessToRoughness(in float smoothness)\n{\n\treturn (1.0 - smoothness) * (1.0 - smoothness);\n}\n\nfloat SmoothnessToPerceptualRoughness(in float smoothness)\n{\n\treturn (1.0 - smoothness);\n}\n\nvec3 SafeNormalize(in vec3 inVec)\n{\n\tfloat dp3 = max(0.001,dot(inVec,inVec));\n\treturn inVec * (1.0 / sqrt(dp3));\n}\n\nfloat DisneyDiffuse(in float NdotV, in float NdotL, in float LdotH, in float perceptualRoughness)\n{\n\tfloat fd90 = 0.5 + 2.0 * LdotH * LdotH * perceptualRoughness;\n\tfloat lightScatter\t= (1.0 + (fd90 - 1.0) * pow(1.0 - NdotL,5.0));\n\tfloat viewScatter\t= (1.0 + (fd90 - 1.0) * pow(1.0 - NdotV,5.0));\n\n\treturn lightScatter * viewScatter;\n}\n\nfloat SmithJointGGXVisibilityTerm (float NdotL, float NdotV, float roughness)\n{\n\tfloat a = roughness;\n\tfloat lambdaV = NdotL * (NdotV * (1.0 - a) + a);\n\tfloat lambdaL = NdotV * (NdotL * (1.0 - a) + a);\n\n\treturn 0.5 / (lambdaV + lambdaL + 0.00001);\n}\n\nfloat GGXTerm (float NdotH, float roughness)\n{\n\tfloat a2 = roughness * roughness;\n\tfloat d = (NdotH * a2 - NdotH) * NdotH + 1.0;\n\treturn 0.31830988618 * a2 / (d * d + 0.0000001);\n}\n\nfloat OneMinusReflectivityFromMetallic(in float metallic)\n{\n\tfloat oneMinusDielectricSpec = DielectricSpecularColor.a;\n\treturn oneMinusDielectricSpec - metallic * oneMinusDielectricSpec;\n}\n\nfloat SpecularStrength(vec3 specular)\n{\n    //(SHADER_TARGET < 30)return specular.r; \n    return max (max (specular.r, specular.g), specular.b);\n}\n\nvec3 DiffuseAndSpecularFromMetallic(in vec3 diffuseColor, in float metallic, out vec3 specularColor, out float oneMinusReflectivity)\n{\n\tspecularColor = mix(DielectricSpecularColor.rgb, diffuseColor, metallic);\n\toneMinusReflectivity = OneMinusReflectivityFromMetallic(metallic);\n\treturn diffuseColor * oneMinusReflectivity;\n}\n\nvec3 EnergyConservationBetweenDiffuseAndSpecular(in vec3 diffuseColor, in vec3 specularColor, out float oneMinusReflectivity)\n{\n\toneMinusReflectivity = 1.0 - SpecularStrength(specularColor);\n\treturn diffuseColor * oneMinusReflectivity;\n}\n\nvec4 Occlusion(in vec2 uv0){\n\t#ifdef OCCLUSIONTEXTURE\n\t\tvec4 occlusionTextureColor = texture2D(u_OcclusionTexture, uv0);\n\t\tfloat occ = occlusionTextureColor.g;\n\t\tfloat oneMinusT = 1.0 - u_occlusionStrength;\n\t\tfloat lerpOneTo = oneMinusT + occ * u_occlusionStrength;\n\t\treturn occlusionTextureColor * lerpOneTo;\n\t#else\n\t\treturn vec4(1.0);\n\t#endif\n}\n\nvec2 ParallaxOffset(in vec3 viewDir){\n\t#ifdef PARALLAXTEXTURE\n\t\tfloat h = texture2D(u_ParallaxTexture, v_Texcoord0).g;\n\t\th = h * u_parallaxScale - u_parallaxScale / 2.0;\n\t\tvec3 v = viewDir;\n\t\tv.z += 0.42;\n\t\tvec2 offset = h * (v.xy / v.z);\n\t\treturn v_Texcoord0 + offset;\n\t#else\n\t\treturn v_Texcoord0;\n\t#endif\n}\n\n"),Gn.addInclude("PBRStandardLighting.glsl",'#include "PBRUtils.glsl"\n#include "BRDF.glsl"\n\nvec4 PBRStandardLight(in vec3 diffuseColor, in float metallic, in float smoothness, in vec3 normal, in vec3 viewDir, in vec3 lightDir, in vec3 lightColor, in vec3 gi)\n{\n\tfloat oneMinusReflectivity;\n\tvec3 specularColor;\n\tdiffuseColor = DiffuseAndSpecularFromMetallic (diffuseColor, metallic, specularColor, oneMinusReflectivity);\n\t\n\tvec4 color = LayaAirBRDF(diffuseColor, specularColor, oneMinusReflectivity, smoothness, normal, viewDir, lightDir, lightColor, gi);\n\treturn color;\n}\n\nvec4 PBRStandardDiectionLight (in vec3 diffuseColor, in float metallic, in float smoothness, in vec3 normal, in vec3 viewDir, in DirectionLight light, in vec3 gi)\n{\n\tvec3 lightVec = normalize(light.Direction);\n\treturn PBRStandardLight(diffuseColor, metallic, smoothness, normal, viewDir, lightVec, light.Color, gi);\n}\n\nvec2 MetallicGloss(in float diffuseTextureAlpha, in vec2 uv0)\n{\n\tvec2 mg;\n\t\n\t#ifdef METALLICGLOSSTEXTURE\n\t\tvec4 metallicGlossTextureColor = texture2D(u_MetallicGlossTexture, uv0);\n\t\t#ifdef SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA\n\t\t\tmg.r = metallicGlossTextureColor.r;\n\t\t\tmg.g = diffuseTextureAlpha;\n\t\t#else\n\t\t    mg = metallicGlossTextureColor.ra;\n\t\t#endif\n\t\tmg.g *= u_smoothnessScale;\n\t#else\n\t\tmg.r = u_metallic;\n\t\t#ifdef SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA\n\t\t\tmg.g = diffuseTextureAlpha * u_smoothnessScale;\n\t\t#else\n\t\t\tmg.g = u_smoothness;\n\t\t#endif\n\t#endif\n\t\n\treturn mg;\n}\n\n'),Gn.addInclude("PBRSpecularLighting.glsl",'#include "PBRUtils.glsl"\n#include "BRDF.glsl"\n\nvec4 PBRSpecularLight(in vec3 diffuseColor, in vec3 specularColor, in float smoothness, in vec3 normal, in vec3 viewDir, in vec3 lightDir, in vec3 lightColor, in vec3 gi)\n{\n\tfloat oneMinusReflectivity;\n\tdiffuseColor = EnergyConservationBetweenDiffuseAndSpecular (diffuseColor, specularColor, oneMinusReflectivity);\n\t\n\tvec4 color = LayaAirBRDF(diffuseColor, specularColor, oneMinusReflectivity, smoothness, normal, viewDir, lightDir, lightColor, gi);\n\treturn color;\n}\n\nvec4 PBRSpecularDiectionLight (in vec3 diffuseColor, in vec3 specularColor, in float smoothness, in vec3 normal, in vec3 viewDir, in DirectionLight light, in vec3 gi)\n{\n\tvec3 lightVec = normalize(light.Direction);\n\treturn PBRSpecularLight(diffuseColor, specularColor, smoothness, normal, viewDir, lightVec, light.Color, gi);\n}\n\nvec4 SpecularGloss(float diffuseTextureAlpha, in vec2 uv0)\n{\n    vec4 sg;\n\t\n\t#ifdef SPECULARTEXTURE\n\t\tvec4 specularTextureColor = texture2D(u_SpecularTexture, uv0);\n\t\t#ifdef SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA\n\t\t\tsg.rgb = specularTextureColor.rgb;\n\t\t\tsg.a = diffuseTextureAlpha;\n\t\t#else\n\t\t\tsg = specularTextureColor;\n\t\t#endif\n\t\tsg.a *= u_smoothnessScale;\n\t#else\n\t\tsg.rgb = u_SpecularColor.rgb;\n\t\t#ifdef SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA\n\t\t\tsg.a = diffuseTextureAlpha * u_smoothnessScale;\n\t\t#else\n\t\t\tsg.a = u_smoothness;\n\t\t#endif\n\t#endif\n\t\n    return sg;\n}\n\n');var e,t,n={a_Position:0,a_Color:1,a_Normal:3,a_Texcoord0:2,a_Texcoord1:15,a_BoneWeights:7,a_BoneIndices:6,a_Tangent0:5},i={u_Bones:[0,0],u_DiffuseTexture:[1,1],u_SpecularTexture:[3,1],u_NormalTexture:[2,1],u_ReflectTexture:[5,1],u_AlphaTestValue:[0,1],u_DiffuseColor:[6,1],u_GlowingEdgeColor:[12,1],u_MaterialSpecular:[8,1],u_Shininess:[9,1],u_MaterialReflect:[10,1],u_TilingOffset:[11,1],u_WorldMat:[0,2],u_MvpMatrix:[1,2],u_LightmapScaleOffset:[2,2],u_LightMap:[3,2],u_CameraPos:[0,3],u_FogStart:[1,4],u_FogRange:[2,4],u_FogColor:[0,4],"u_DirectionLight.Color":[4,4],"u_DirectionLight.Direction":[3,4],"u_PointLight.Position":[5,4],"u_PointLight.Range":[6,4],"u_PointLight.Color":[8,4],"u_SpotLight.Position":[9,4],"u_SpotLight.Direction":[10,4],"u_SpotLight.Range":[12,4],"u_SpotLight.Spot":[11,4],"u_SpotLight.Color":[14,4],u_AmbientColor:[21,4],u_shadowMap1:[18,4],u_shadowMap2:[19,4],u_shadowMap3:[20,4],u_shadowPSSMDistance:[15,4],u_lightShadowVP:[16,4],u_shadowPCFoffset:[17,4]},r=Gn.nameKey.add("BLINNPHONG");e='attribute vec4 a_Position;\nuniform mat4 u_MvpMatrix;\n\n#if defined(DIFFUSEMAP)||((defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&(defined(SPECULARMAP)||defined(NORMALMAP)))||(defined(LIGHTMAP)&&defined(UV))\n\tattribute vec2 a_Texcoord0;\n\tvarying vec2 v_Texcoord0;\n#endif\n\n#if defined(LIGHTMAP)&&defined(UV1)\n\tattribute vec2 a_Texcoord1;\n#endif\n\n#ifdef LIGHTMAP\n\tuniform vec4 u_LightmapScaleOffset;\n\tvarying vec2 v_LightMapUV;\n#endif\n\n#ifdef COLOR\n\tattribute vec4 a_Color;\n\tvarying vec4 v_Color;\n#endif\n\n#ifdef BONE\n\tconst int c_MaxBoneCount = 24;\n\tattribute vec4 a_BoneIndices;\n\tattribute vec4 a_BoneWeights;\n\tuniform mat4 u_Bones[c_MaxBoneCount];\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(REFLECTMAP)\n\tattribute vec3 a_Normal;\n\tvarying vec3 v_Normal; \n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(REFLECTMAP)\n\tuniform vec3 u_CameraPos;\n\tvarying vec3 v_ViewDir; \n#endif\n\n#if (defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(REFLECTMAP))&&defined(NORMALMAP)\n\tattribute vec4 a_Tangent0;\n\tvarying vec3 v_Tangent;\n\tvarying vec3 v_Binormal;\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(REFLECTMAP)||defined(RECEIVESHADOW)\n\tuniform mat4 u_WorldMat;\n\tvarying vec3 v_PositionWorld;\n#endif\n\nvarying float v_posViewZ;\n#ifdef RECEIVESHADOW\n  #ifdef SHADOWMAP_PSSM1 \n  varying vec4 v_lightMVPPos;\n  uniform mat4 u_lightShadowVP[4];\n  #endif\n#endif\n\n#ifdef TILINGOFFSET\n\tuniform vec4 u_TilingOffset;\n#endif\n\nvoid main_castShadow()\n{\n\t#ifdef BONE\n\t\tmat4 skinTransform=mat4(0.0);\n\t\tskinTransform += u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\n\t\tvec4 position=skinTransform*a_Position;\n\t\tgl_Position = u_MvpMatrix * position;\n\t#else\n\t\tgl_Position = u_MvpMatrix * a_Position;\n\t#endif\n\t \n\t//TODO没考虑UV动画呢\n\t#if defined(DIFFUSEMAP)&&defined(ALPHATEST)\n\t\tv_Texcoord0=a_Texcoord0;\n\t#endif\n\t\tv_posViewZ = gl_Position.z;\n}\n\nvoid main_normal()\n{\n\t#ifdef BONE\n\t\tmat4 skinTransform=mat4(0.0);\n\t\tskinTransform += u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\n\t\tvec4 position=skinTransform*a_Position;\n\t\tgl_Position = u_MvpMatrix * position;\n\t#else\n\t\tgl_Position = u_MvpMatrix * a_Position;\n\t#endif\n\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(REFLECTMAP)\n\t\tmat3 worldMat;\n\t\t#ifdef BONE\n\t\t\tworldMat=mat3(u_WorldMat*skinTransform);\n\t\t#else\n\t\t\tworldMat=mat3(u_WorldMat);\n\t\t#endif  \n\t\tv_Normal=worldMat*a_Normal;//TODO:法线可以用"魔法"矩阵\n\t\t#if (defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&defined(NORMALMAP)\n\t\t\tv_Tangent=worldMat*a_Tangent0.xyz;\n\t\t\tv_Binormal=cross(v_Normal,v_Tangent)*a_Tangent0.w;\n\t\t#endif\n\t#endif\n\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(REFLECTMAP)||defined(RECEIVESHADOW)\n\t\t#ifdef BONE\n\t\t\tv_PositionWorld=(u_WorldMat*position).xyz;\n\t\t#else\n\t\t\tv_PositionWorld=(u_WorldMat*a_Position).xyz;\n\t\t#endif\n\t#endif\n\t\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(REFLECTMAP)\n\t\tv_ViewDir=u_CameraPos-v_PositionWorld;\n\t#endif\n\n\t#if defined(DIFFUSEMAP)||((defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&(defined(SPECULARMAP)||defined(NORMALMAP)))\n\t\tv_Texcoord0=a_Texcoord0;\n\t\t#ifdef TILINGOFFSET\n\t\t\tv_Texcoord0=(vec2(v_Texcoord0.x,v_Texcoord0.y-1.0)*u_TilingOffset.xy)+u_TilingOffset.zw;\n\t\t\tv_Texcoord0=vec2(v_Texcoord0.x,1.0+v_Texcoord0.y);\n\t\t#endif\n\t#endif\n\n\t#ifdef LIGHTMAP\n\t\t#ifdef SCALEOFFSETLIGHTINGMAPUV\n\t\t\t#ifdef UV1\n\t\t\t\tv_LightMapUV=vec2(a_Texcoord1.x*u_LightmapScaleOffset.x+u_LightmapScaleOffset.z,1.0+a_Texcoord1.y*u_LightmapScaleOffset.y+u_LightmapScaleOffset.w);\n\t\t\t#else\n\t\t\t\tv_LightMapUV=vec2(a_Texcoord0.x,a_Texcoord0.y-1.0)*u_LightmapScaleOffset.xy+u_LightmapScaleOffset.zw;\n\t\t\t#endif \n\t\t#else\n\t\t\t#ifdef UV1\n\t\t\t\tv_LightMapUV=a_Texcoord1;\n\t\t\t#else\n\t\t\t\tv_LightMapUV=a_Texcoord0;\n\t\t\t#endif \n\t\t#endif \n\t#endif\n\n\t#ifdef COLOR\n\t\tv_Color=a_Color;\n\t#endif\n\n\t#ifdef RECEIVESHADOW\n\t\tv_posViewZ = gl_Position.w;\n\t\t#ifdef SHADOWMAP_PSSM1 \n\t\t\tv_lightMVPPos = u_lightShadowVP[0] * vec4(v_PositionWorld,1.0);\n\t\t#endif\n\t#endif\n}\n\nvoid main()\n{\n\t#ifdef CASTSHADOW\n\t\tmain_castShadow();\n\t#else\n\t\tmain_normal();\n\t#endif\n}',t='#ifdef HIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\n#include "Lighting.glsl";\n\nuniform vec4 u_DiffuseColor;\n\n#ifdef COLOR\n\tvarying vec4 v_Color;\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(REFLECTMAP)||defined(GLOWINGEDGE)\n\tvarying vec3 v_ViewDir; \n#endif\n\n#ifdef ALPHATEST\n\tuniform float u_AlphaTestValue;\n#endif\n\n#ifdef DIFFUSEMAP\n\tuniform sampler2D u_DiffuseTexture;\n#endif\n\n#ifdef REFLECTMAP\n\tuniform samplerCube u_ReflectTexture;\n\tuniform vec3 u_MaterialReflect;\n#endif\n\n#if defined(DIFFUSEMAP)||((defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&(defined(SPECULARMAP)||defined(NORMALMAP)))\n\tvarying vec2 v_Texcoord0;\n#endif\n\n#ifdef LIGHTMAP\n\tvarying vec2 v_LightMapUV;\n\tuniform sampler2D u_LightMap;\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n\tuniform vec3 u_MaterialSpecular;\n\tuniform float u_Shininess;\n\t#ifdef SPECULARMAP \n\t\tuniform sampler2D u_SpecularTexture;\n\t#endif\n#endif\n\n#ifdef FOG\n\tuniform float u_FogStart;\n\tuniform float u_FogRange;\n\t#ifdef ADDTIVEFOG\n\t#else\n\t\tuniform vec3 u_FogColor;\n\t#endif\n#endif\n\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(REFLECTMAP)||defined(GLOWINGEDGE)\n\tvarying vec3 v_Normal;\n#endif\n\n#if (defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&defined(NORMALMAP)\n\tuniform sampler2D u_NormalTexture;\n\tvarying vec3 v_Tangent;\n\tvarying vec3 v_Binormal;\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(GLOWINGEDGE)\n\tuniform DirectionLight u_DirectionLight;\n#endif\n\n#ifdef POINTLIGHT\n\tuniform PointLight u_PointLight;\n#endif\n\n#ifdef SPOTLIGHT\n\tuniform SpotLight u_SpotLight;\n#endif\n\nuniform vec3 u_AmbientColor;\n\n\n#if defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(REFLECTMAP)||defined(RECEIVESHADOW)\n\tvarying vec3 v_PositionWorld;\n#endif\n\n#include "ShadowHelper.glsl"\nvarying float v_posViewZ;\n#ifdef RECEIVESHADOW\n\t#if defined(SHADOWMAP_PSSM2)||defined(SHADOWMAP_PSSM3)\n\t\tuniform mat4 u_lightShadowVP[4];\n\t#endif\n\t#ifdef SHADOWMAP_PSSM1 \n\t\tvarying vec4 v_lightMVPPos;\n\t#endif\n#endif\n\n#ifdef GLOWINGEDGE\n\tuniform vec4 u_GlowingEdgeColor;\n#endif\n\nvoid main_castShadow()\n{\n\t//gl_FragColor=vec4(v_posViewZ,0.0,0.0,1.0);\n\tgl_FragColor=packDepth(v_posViewZ);\n\t#if defined(DIFFUSEMAP)&&defined(ALPHATEST)\n\t\tfloat alpha = texture2D(u_DiffuseTexture,v_Texcoord0).w;\n\t\tif( alpha < u_AlphaTestValue )\n\t\t{\n\t\t\tdiscard;\n\t\t}\n\t#endif\n}\nvoid main_normal()\n{\n\tvec4 mainColor=u_DiffuseColor;\n\t#ifdef DIFFUSEMAP\n\t\tvec4 difTexColor=texture2D(u_DiffuseTexture, v_Texcoord0);\n\t\tmainColor=mainColor*difTexColor;\n\t#endif \n\t#ifdef COLOR\n\t\tmainColor=mainColor*v_Color;\n\t#endif \n    \n\t#ifdef ALPHATEST\n\t\tif(mainColor.a<u_AlphaTestValue)\n\t\t\tdiscard;\n\t#endif\n  \n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(REFLECTMAP)||defined(GLOWINGEDGE)\n\t\tvec3 normal;\n\t\t#if (defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&defined(NORMALMAP)\n\t\t\tvec3 normalMapSample = texture2D(u_NormalTexture, v_Texcoord0).rgb;\n\t\t\tnormal = normalize(NormalSampleToWorldSpace(normalMapSample, v_Normal, v_Tangent,v_Binormal));\n\t\t#else\n\t\t\tnormal = normalize(v_Normal);\n\t\t#endif\n\t#endif\n\t\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(GLOWINGEDGE)\n\t\tvec3 viewDir= normalize(v_ViewDir);\n\t\tvec3 diffuse = vec3(0.0);\n\t\tvec3 specular= vec3(0.0);\n\t\tvec3 dif,spe;\n\t\t#ifdef SPECULARMAP\n\t\t\tvec3 gloss=texture2D(u_SpecularTexture, v_Texcoord0).rgb;\n\t\t#else\n\t\t\t#ifdef DIFFUSEMAP\n\t\t\t\tvec3 gloss=vec3(difTexColor.a);\n\t\t\t#else\n\t\t\t\tvec3 gloss=vec3(1.0);\n\t\t\t#endif\n\t\t#endif\n\t#endif\n\n\t\n\t#ifdef DIRECTIONLIGHT\n\t\tLayaAirBlinnPhongDiectionLight(u_MaterialSpecular,u_Shininess,normal,gloss,viewDir,u_DirectionLight,dif,spe);\n\t\tdiffuse+=dif;\n\t\tspecular+=spe;\n\t#endif\n \n\t#ifdef POINTLIGHT\n\t\tLayaAirBlinnPhongPointLight(v_PositionWorld,u_MaterialSpecular,u_Shininess,normal,gloss,viewDir,u_PointLight,dif,spe);\n\t\tdiffuse+=dif;\n\t\tspecular+=spe;\n\t#endif\n\n\t#ifdef SPOTLIGHT\n\t\tLayaAirBlinnPhongSpotLight(v_PositionWorld,u_MaterialSpecular,u_Shininess,normal,gloss,viewDir,u_SpotLight,dif,spe);\n\t\tdiffuse+=dif;\n\t\tspecular+=spe;\n\t#endif\n\n\t\n\tvec3 finalDiffuse;\n\t#ifdef LIGHTMAP\n\t\tfinalDiffuse=texture2D(u_LightMap, v_LightMapUV).rgb*2.0;\n\t\t//float exponent = texture2D(u_LightMap, v_LightMapUV).a;\n\t\t//finalDiffuse = texture2D(u_LightMap, v_LightMapUV).rgb;\n\t\t//float ratio = pow(2.0, exponent * 255.0 - (128.0 + 8.0));\n\t\t//finalDiffuse = finalDiffuse * 255.0 * ratio;\t\n\t\t//finalDiffuse = sqrt(finalDiffuse);\n\t#else\n\t\tfinalDiffuse=vec3(0.0);\n\t#endif\n\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n\t\tfinalDiffuse+=diffuse;\n\t#endif\n\n\t#ifdef RECEIVESHADOW\n\t\tfloat shadowValue = 1.0;\n\t\t#ifdef SHADOWMAP_PSSM3\n\t\t\tshadowValue = getShadowPSSM3( u_shadowMap1,u_shadowMap2,u_shadowMap3,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\n\t\t#endif\n\t\t#ifdef SHADOWMAP_PSSM2\n\t\t\tshadowValue = getShadowPSSM2( u_shadowMap1,u_shadowMap2,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\n\t\t#endif \n\t\t#ifdef SHADOWMAP_PSSM1\n\t\t\tshadowValue = getShadowPSSM1( u_shadowMap1,v_lightMVPPos,u_shadowPSSMDistance,u_shadowPCFoffset,v_posViewZ,0.001);\n\t\t#endif\n\t\tgl_FragColor =vec4(mainColor.rgb*(u_AmbientColor + finalDiffuse)*shadowValue,mainColor.a);\n\t#else\n\t\tgl_FragColor =vec4(mainColor.rgb*(u_AmbientColor + finalDiffuse),mainColor.a);\n\t#endif\n\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n\t\t#ifdef RECEIVESHADOW\n\t\t\tgl_FragColor.rgb+=specular*shadowValue;\n\t\t#else\n\t\t\tgl_FragColor.rgb+=specular;\n\t\t#endif\n\t#endif\n\t\n\t#ifdef GLOWINGEDGE\n\t\tfloat Rim = 1.0 - max(0.0,dot(viewDir, normal));\n\t\tvec3 Emissive = 2.0 * u_DirectionLight.Color * u_GlowingEdgeColor.rgb * pow(Rim,5.0);\n\t\tgl_FragColor.rgb += Emissive;\n\t#endif\n\n\t#ifdef REFLECTMAP\n\t\tvec3 incident = -viewDir;\n\t\tvec3 reflectionVector = reflect(incident,normal);\n\t\tvec3 reflectionColor  = textureCube(u_ReflectTexture,reflectionVector).rgb;\n\t\tgl_FragColor.rgb += u_MaterialReflect*reflectionColor;\n\t#endif\n\t  \n\t#ifdef FOG\n\t\tfloat lerpFact=clamp((1.0/gl_FragCoord.w-u_FogStart)/u_FogRange,0.0,1.0);\n\t\t#ifdef ADDTIVEFOG\n\t\t\tgl_FragColor.rgb=mix(gl_FragColor.rgb,vec3(0.0,0.0,0.0),lerpFact);\n\t\t#else\n\t\t\tgl_FragColor.rgb=mix(gl_FragColor.rgb,u_FogColor,lerpFact);\n\t\t#endif\n\t#endif\n}\n\nvoid main()\n{\n\t#ifdef CASTSHADOW\t\t\n\t\tmain_castShadow();\n\t#else\n\t  main_normal();\n\t#endif  \n}\n\n';var a=fn.add(r,e,t,n,i);zn.SHADERDEFINE_DIFFUSEMAP=a.registerMaterialDefine("DIFFUSEMAP"),zn.SHADERDEFINE_NORMALMAP=a.registerMaterialDefine("NORMALMAP"),zn.SHADERDEFINE_SPECULARMAP=a.registerMaterialDefine("SPECULARMAP"),zn.SHADERDEFINE_REFLECTMAP=a.registerMaterialDefine("REFLECTMAP"),zn.SHADERDEFINE_TILINGOFFSET=a.registerMaterialDefine("TILINGOFFSET"),zn.SHADERDEFINE_ADDTIVEFOG=a.registerMaterialDefine("ADDTIVEFOG"),zn.SHADERDEFINE_GLOWINGEDGE=a.registerMaterialDefine("GLOWINGEDGE"),n={a_Position:0,a_Color:1,a_Normal:3,a_Texcoord0:2,a_Texcoord1:15,a_TexcoordNext0:14,a_BoneWeights:7,a_BoneIndices:6,a_Tangent0:5},i={u_Bones:[0,0],u_DiffuseTexture:[1,1],u_SpecularTexture:[3,1],u_NormalTexture:[2,1],u_AmbientTexture:[5,1],u_ReflectTexture:[6,1],u_AlphaTestValue:[0,1],u_Albedo:[7,1],u_UVMatrix:[13,1],u_UVAge:[14,1],u_UVAniAge:[8,1],u_MaterialDiffuse:[10,1],u_MaterialAmbient:[9,1],u_MaterialSpecular:[11,1],u_MaterialReflect:[12,1],u_TilingOffset:[15,1],u_WorldMat:[0,2],u_MvpMatrix:[1,2],u_LightmapScaleOffset:[2,2],u_LightMap:[3,2],u_CameraPos:[0,3],u_FogStart:[1,4],u_FogRange:[2,4],u_FogColor:[0,4],"u_DirectionLight.Direction":[3,4],"u_DirectionLight.Diffuse":[4,4],"u_PointLight.Position":[5,4],"u_PointLight.Range":[6,4],"u_PointLight.Attenuation":[7,4],"u_PointLight.Diffuse":[8,4],"u_SpotLight.Position":[9,4],"u_SpotLight.Direction":[10,4],"u_SpotLight.Range":[12,4],"u_SpotLight.Spot":[11,4],"u_SpotLight.Attenuation":[13,4],"u_SpotLight.Diffuse":[14,4],u_AmbientColor:[21,4],u_shadowMap1:[18,4],u_shadowMap2:[19,4],u_shadowMap3:[20,4],u_shadowPSSMDistance:[15,4],u_lightShadowVP:[16,4],u_shadowPCFoffset:[17,4]};var o=Gn.nameKey.add("SIMPLE");e="attribute vec4 a_Position;\nuniform mat4 u_MvpMatrix;\n\n\n\n#if defined(DIFFUSEMAP)||((defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&(defined(COLOR)&&defined(SPECULARMAP)||defined(NORMALMAP)))||(defined(LIGHTMAP)&&defined(UV))\nattribute vec2 a_Texcoord0;\nvarying vec2 v_Texcoord0;\n  #ifdef UVTRANSFORM \n  uniform mat4 u_UVMatrix;\n  #endif\n#endif\n\n#if defined(AMBIENTMAP)||(defined(LIGHTMAP)&&defined(UV1))\nattribute vec2 a_Texcoord1;\n#endif\n\n#if defined(AMBIENTMAP)||defined(LIGHTMAP)\nuniform vec4 u_LightmapScaleOffset;\nvarying vec2 v_LightMapUV;\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#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(REFLECTMAP)\nattribute vec3 a_Normal;\nvarying vec3 v_Normal;\n#endif\n\n#if (defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(REFLECTMAP))&&defined(NORMALMAP)\nattribute vec3 a_Tangent0;\nvarying vec3 v_Tangent0;\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)||defined(DEPTHFOG)||defined(REFLECTMAP)||defined(RECEIVESHADOW)\nuniform mat4 u_WorldMat;\nvarying vec3 v_PositionWorld;\n#endif\n\nvarying float v_posViewZ;\n#ifdef RECEIVESHADOW\n  #ifdef SHADOWMAP_PSSM1 \n  varying vec4 v_lightMVPPos;\n  uniform mat4 u_lightShadowVP[4];\n  #endif\n#endif\n\n#ifdef TILINGOFFSET\n\tuniform vec4 u_TilingOffset;\n#endif\n\nvoid main_castShadow()\n{\n#ifdef BONE\n\tmat4 skinTransform=mat4(0.0);\n\tskinTransform += u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\n\tskinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\n\tskinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\n\tskinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\n\tvec4 position=skinTransform*a_Position;\n\tgl_Position = u_MvpMatrix * position;\n#else\n\tgl_Position = u_MvpMatrix * a_Position;\n#endif\n \n//TODO没考虑UV动画呢\n#if defined(DIFFUSEMAP)&&defined(ALPHATEST)\n\tv_Texcoord0=a_Texcoord0;\n#endif\n\tv_posViewZ = gl_Position.z;\n}\n\nvoid main_normal()\n{\n#ifdef BONE\n\tmat4 skinTransform=mat4(0.0);\n\tskinTransform += u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\n\tskinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\n\tskinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\n\tskinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\n\tvec4 position=skinTransform*a_Position;\n\tgl_Position = u_MvpMatrix * position;\n#else\n\tgl_Position = u_MvpMatrix * a_Position;\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(REFLECTMAP)\n\tmat3 worldMat;\n\t#ifdef BONE\n\t\tworldMat=mat3(u_WorldMat*skinTransform);\n\t#else\n\t\tworldMat=mat3(u_WorldMat);\n\t#endif  \n\tv_Normal=worldMat*a_Normal;\n\t#if (defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&defined(NORMALMAP)\n\t\tv_Tangent0=worldMat*a_Tangent0;\n\t#endif\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)||defined(DEPTHFOG)||defined(REFLECTMAP)||defined(RECEIVESHADOW)\n\t#ifdef BONE\n\t\tv_PositionWorld=(u_WorldMat*position).xyz;\n\t#else\n\t\tv_PositionWorld=(u_WorldMat*a_Position).xyz;\n\t#endif\n#endif\n\n#if defined(DIFFUSEMAP)||((defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&(defined(COLOR)&&defined(SPECULARMAP)||defined(NORMALMAP)))\n\tv_Texcoord0=a_Texcoord0;\n\t#ifdef TILINGOFFSET\n\t\tv_Texcoord0=(vec2(v_Texcoord0.x,v_Texcoord0.y-1.0)*u_TilingOffset.xy)+u_TilingOffset.zw;\n\t\tv_Texcoord0=vec2(v_Texcoord0.x,v_Texcoord0.y+1.0);\n\t#endif\n\t#ifdef UVTRANSFORM\n\t\tv_Texcoord0=(u_UVMatrix*vec4(v_Texcoord0,0.0,1.0)).xy;\n\t#endif\n#endif\n\n#if defined(AMBIENTMAP)||defined(LIGHTMAP)\n\t#ifdef SCALEOFFSETLIGHTINGMAPUV\n\t\t#ifdef UV1\n\t\t\tv_LightMapUV=vec2(a_Texcoord1.x*u_LightmapScaleOffset.x+u_LightmapScaleOffset.z,1.0+a_Texcoord1.y*u_LightmapScaleOffset.y+u_LightmapScaleOffset.w);\n\t\t#else\n\t\t\tv_LightMapUV=vec2(a_Texcoord0.x,a_Texcoord0.y-1.0)*u_LightmapScaleOffset.xy+u_LightmapScaleOffset.zw;\n\t\t#endif \n\t#else\n\t\t#ifdef UV1\n\t\t\tv_LightMapUV=a_Texcoord1;\n\t\t#else\n\t\t\tv_LightMapUV=a_Texcoord0;\n\t\t#endif \n\t#endif \n#endif\n\n#ifdef COLOR\n\tv_Color=a_Color;\n#endif\n\n#ifdef RECEIVESHADOW\n\tv_posViewZ = gl_Position.w;\n\t#ifdef SHADOWMAP_PSSM1 \n\t\tv_lightMVPPos = u_lightShadowVP[0] * vec4(v_PositionWorld,1.0);\n\t#endif\n#endif\n}\n\nvoid main()\n{\n#ifdef CASTSHADOW\n\tmain_castShadow();\n#else\n\tmain_normal();\n#endif\n}",t='#ifdef HIGHPRECISION\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\n#include "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#if   defined(DIFFUSEMAP)||((defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&(defined(COLOR)&&defined(SPECULARMAP)||defined(NORMALMAP)))\nvarying vec2 v_Texcoord0;\n#endif\n\n#if defined(AMBIENTMAP)||defined(LIGHTMAP)\nvarying vec2 v_LightMapUV;\n#endif\n#ifdef AMBIENTMAP\nuniform sampler2D u_AmbientTexture;\n#endif\n#ifdef LIGHTMAP\nuniform sampler2D u_LightMap;\n#endif\n\n#ifdef COLOR\nvarying vec4 v_Color;\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\nuniform vec3 u_MaterialDiffuse;\nuniform vec4 u_MaterialSpecular;\n  #if (defined(DIFFUSEMAP)||defined(COLOR))&&defined(SPECULARMAP) \n  uniform sampler2D u_SpecularTexture;\n  #endif\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(AMBIENTMAP)||defined(LIGHTMAP)\nuniform vec3 u_MaterialAmbient;\n#endif\n\n#if defined(FOG)||defined(DEPTHFOG)\n\tuniform float u_FogStart;\n\tuniform float u_FogRange;\n\t#ifdef ADDTIVEFOG\n\t#else\n\t\tuniform vec3 u_FogColor;\n\t#endif\n#endif\n\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(REFLECTMAP)\nvarying vec3 v_Normal;\n#endif\n\n#if (defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&defined(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\nuniform vec3 u_AmbientColor;\n\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)||defined(DEPTHFOG)||defined(REFLECTMAP)||(defined(RECEIVESHADOW)&&(defined(SHADOWMAP_PSM2)||defined(SHADOWMAP_PSM3)))\nuniform vec3 u_CameraPos;\n#endif\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)||defined(DEPTHFOG)||defined(REFLECTMAP)\nvarying vec3 v_PositionWorld;\n#endif\n\n#include "ShadowHelper.glsl"\n#ifdef RECEIVESHADOW\n\t#if defined(SHADOWMAP_PSSM2)||defined(SHADOWMAP_PSSM3)\n\tuniform mat4 u_lightShadowVP[4];\n\t#endif\n\t#ifdef SHADOWMAP_PSSM1 \n\tvarying vec4 v_lightMVPPos;\n\t#endif\n#endif\nvarying float v_posViewZ;\n\n\n\nvoid main_castShadow()\n{\n\t//gl_FragColor=vec4(v_posViewZ,0.0,0.0,1.0);\n\tgl_FragColor=packDepth(v_posViewZ);\n\t#if defined(DIFFUSEMAP)&&defined(ALPHATEST)\n\t\tfloat alpha = texture2D(u_DiffuseTexture,v_Texcoord0).w;\n\t\tif( alpha < u_AlphaTestValue )\n\t\t{\n\t\t\tdiscard;\n\t\t}\n\t#endif\n}\nvoid main_normal()\n{\n#if defined(DIFFUSEMAP)&&!defined(COLOR)\n\tgl_FragColor=texture2D(u_DiffuseTexture, v_Texcoord0);\n#endif \n  \n#if defined(COLOR)&&!defined(DIFFUSEMAP)\n\tgl_FragColor=v_Color;\n#endif \n  \n#if defined(DIFFUSEMAP)&&defined(COLOR)\n\tvec4 texColor=texture2D(u_DiffuseTexture, v_Texcoord0);\n\tgl_FragColor=texColor*v_Color;\n#endif\n  \n#if !defined(DIFFUSEMAP)&&!defined(COLOR)\n\tgl_FragColor=vec4(1.0,1.0,1.0,1.0);\n#endif \n    \n#ifdef ALPHATEST\n\tif(gl_FragColor.a-u_AlphaTestValue<0.0)\n\t\tdiscard;\n#endif\n  \n  \n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(REFLECTMAP)\n\tvec3 normal;\n    #if (defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&defined(NORMALMAP)\n\t\tvec3 normalMapSample = texture2D(u_NormalTexture, v_Texcoord0).rgb;\n\t\tnormal = normalize(NormalSampleToWorldSpace(normalMapSample, v_Normal, v_Tangent0));\n\t#else\n\t\tnormal = normalize(v_Normal);\n    #endif\n#endif\n\t\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n\tvec3 diffuse = vec3(0.0);\n\tvec3 ambient = vec3(0.0);\n\tvec3 specular= vec3(0.0);\n\tvec3 dif, amb, spe;\n#endif\n  \n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)||defined(REFLECTMAP)\n\tvec3 toEye;\n\t#ifdef FOG\n\t\ttoEye=u_CameraPos-v_PositionWorld;\n\t\tfloat toEyeLength=length(toEye);\n\t\ttoEye/=toEyeLength;\n\t#else\n\t\ttoEye=normalize(u_CameraPos-v_PositionWorld);\n\t#endif\n#endif\n\t\n#ifdef DIRECTIONLIGHT\n\tcomputeDirectionLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_DirectionLight,u_AmbientColor,normal,toEye, dif, amb, spe);\n\tdiffuse+=dif;\n\tambient+=amb;\n\tspecular+=spe;\n#endif\n \n#ifdef POINTLIGHT\n\tcomputePointLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_PointLight,u_AmbientColor,v_PositionWorld,normal,toEye, dif, amb, spe);\n\tdiffuse+=dif;\n\tambient+=amb;\n\tspecular+=spe;\n#endif\n\n#ifdef SPOTLIGHT\n\tComputeSpotLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_SpotLight,u_AmbientColor,v_PositionWorld,normal,toEye, dif, amb, spe);\n\tdiffuse+=dif;\n\tambient+=amb;\n\tspecular+=spe;\n#endif\n\n#ifdef RECEIVESHADOW\n\tfloat shadowValue = 1.0;\n\t#ifdef SHADOWMAP_PSSM3\n\t\tshadowValue = getShadowPSSM3( u_shadowMap1,u_shadowMap2,u_shadowMap3,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\n\t#endif\n\t#ifdef SHADOWMAP_PSSM2\n\t\tshadowValue = getShadowPSSM2( u_shadowMap1,u_shadowMap2,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\n\t#endif \n\t#ifdef SHADOWMAP_PSSM1\n\t\tshadowValue = getShadowPSSM1( u_shadowMap1,v_lightMVPPos,u_shadowPSSMDistance,u_shadowPCFoffset,v_posViewZ,0.001);\n\t#endif\n#endif\n\n#ifdef AMBIENTMAP\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n\t\tgl_FragColor.rgb=gl_FragColor.rgb*(u_MaterialAmbient+texture2D(u_AmbientTexture, v_LightMapUV).rgb); \n\t#else\n\t\t#if defined(RECEIVESHADOW)\n\t\t\tgl_FragColor.rgb=gl_FragColor.rgb*(u_MaterialAmbient+texture2D(u_AmbientTexture, v_LightMapUV).rgb * shadowValue);\n\t\t#else\n\t\t\tgl_FragColor.rgb=gl_FragColor.rgb*(u_MaterialAmbient+texture2D(u_AmbientTexture, v_LightMapUV).rgb); \n\t\t#endif\n\t#endif\n#endif\n\n#ifdef LIGHTMAP\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n\t\tgl_FragColor.rgb=gl_FragColor.rgb*(u_MaterialAmbient+texture2D(u_LightMap, v_LightMapUV).rgb); \n\t#else\n\t\t#if defined(RECEIVESHADOW)\n\t\t\tgl_FragColor.rgb=gl_FragColor.rgb*(u_MaterialAmbient+texture2D(u_LightMap, v_LightMapUV).rgb * shadowValue);\n\t\t#else\n\t\t\tgl_FragColor.rgb=gl_FragColor.rgb*(u_MaterialAmbient+texture2D(u_LightMap, v_LightMapUV).rgb); \n\t\t#endif\n\t#endif\n#endif\n\ngl_FragColor=gl_FragColor*u_Albedo;\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n\t#if (defined(DIFFUSEMAP)||defined(COLOR))&&defined(SPECULARMAP)\n\t\tspecular =specular*texture2D(u_SpecularTexture, v_Texcoord0).rgb;\n    #endif\n\t#ifdef RECEIVESHADOW\n\t\tgl_FragColor =vec4( gl_FragColor.rgb*(ambient + diffuse*shadowValue) + specular*shadowValue,gl_FragColor.a);\n\t#else\n\t\tgl_FragColor =vec4( gl_FragColor.rgb*(ambient + diffuse) + specular,gl_FragColor.a);\n\t#endif\n#endif\n  \n#ifdef REFLECTMAP\n\tvec3 incident = -toEye;\n\tvec3 reflectionVector = reflect(incident,normal);\n\tvec3 reflectionColor  = textureCube(u_ReflectTexture,reflectionVector).rgb;\n\tgl_FragColor.rgb += u_MaterialReflect*reflectionColor;\n#endif\n  \n#ifdef FOG\n\tfloat lerpFact=clamp((toEyeLength-u_FogStart)/u_FogRange,0.0,1.0);\n\t#ifdef ADDTIVEFOG\n\t\tgl_FragColor.rgb=mix(gl_FragColor.rgb,vec3(0.0,0.0,0.0),lerpFact);\n\t#else\n\t\tgl_FragColor.rgb=mix(gl_FragColor.rgb,u_FogColor,lerpFact);\n\t#endif\n#endif\n#ifdef DEPTHFOG\n\tfloat lerpFact = (-v_PositionWorld.y-u_FogStart)/u_FogRange;\n\tgl_FragColor.rgb=mix(gl_FragColor.rgb,u_FogColor,lerpFact);\n#endif\n}\n\nvoid main()\n{\n#ifdef CASTSHADOW\t\t\n\tmain_castShadow();\n#else\n  main_normal();\n#endif  \n}\n\n',a=fn.add(o,e,t,n,i),jn.SHADERDEFINE_DIFFUSEMAP=a.registerMaterialDefine("DIFFUSEMAP"),jn.SHADERDEFINE_NORMALMAP=a.registerMaterialDefine("NORMALMAP"),jn.SHADERDEFINE_SPECULARMAP=a.registerMaterialDefine("SPECULARMAP"),jn.SHADERDEFINE_EMISSIVEMAP=a.registerMaterialDefine("EMISSIVEMAP"),jn.SHADERDEFINE_AMBIENTMAP=a.registerMaterialDefine("AMBIENTMAP"),jn.SHADERDEFINE_REFLECTMAP=a.registerMaterialDefine("REFLECTMAP"),jn.SHADERDEFINE_UVTRANSFORM=a.registerMaterialDefine("UVTRANSFORM"),jn.SHADERDEFINE_TILINGOFFSET=a.registerMaterialDefine("TILINGOFFSET"),jn.SHADERDEFINE_ADDTIVEFOG=a.registerMaterialDefine("ADDTIVEFOG"),n={a_Position:0,a_Color:1},i={u_MvpMatrix:[1,2]};var s=Gn.nameKey.add("LINE");e="attribute vec4 a_Position;\nuniform mat4 u_MvpMatrix;\nattribute vec4 a_Color;\nvarying vec4 v_Color;\n\n\nvoid main()\n{\n  gl_Position = u_MvpMatrix * a_Position;\n  v_Color=a_Color;\n}",t="#ifdef HIGHPRECISION\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nvarying vec4 v_Color;\n\nvoid main()\n{\n  gl_FragColor=v_Color; \n}\n\n",fn.add(s,e,t,n,i),n={a_position:0,a_normal:3,tangent:5,binormal:4,uv:2,a_BoneWeights:7,a_BoneIndices:6,a_Tangent0:5},i={u_Bones:[0,0],u_lodRect:[9,3],irrad_mat_red:[10,3],irrad_mat_green:[11,3],irrad_mat_blue:[12,3],u_hdrexposure:[13,3],u_aoObjPos:[14,1],texBaseColor:[1,1],texNormal:[2,1],texPbrInfo:[3,1],texPrefilterdEnv:[8,3],texHSNoise:[15,1],texPrefilterDiff:[7,3],u_AlphaTestValue:[0,1],texBRDFLUT:[4,1],u_UVAniAge:[5,1],u_roughness:[6,1],u_metaless:[7,1],u_UVMatrix:[8,1],u_UVAge:[9,1],modelMatrix:[0,2],mvp:[1,2],cameraPosition:[0,3],u_View:[1,3],u_Project:[2,3],u_FogStart:[1,4],u_FogRange:[2,4],u_FogColor:[0,4],"u_DirectionLight.Direction":[3,4],"u_DirectionLight.Diffuse":[4,4],"u_PointLight.Position":[5,4],"u_PointLight.Range":[6,4],"u_PointLight.Attenuation":[7,4],"u_PointLight.Diffuse":[8,4],"u_SpotLight.Position":[9,4],"u_SpotLight.Direction":[10,4],"u_SpotLight.Range":[12,4],"u_SpotLight.Spot":[11,4],"u_SpotLight.Attenuation":[13,4],"u_SpotLight.Diffuse":[14,4],u_shadowMap1:[18,4],u_shadowMap2:[19,4],u_shadowMap3:[20,4],u_shadowPSSMDistance:[15,4],u_lightShadowVP:[16,4],u_shadowPCFoffset:[17,4]};var l=Gn.nameKey.add("PBR");e="\nuniform mat4 modelMatrix;\n//uniform mat4 modelViewMatrix;\n//uniform mat4 projectionMatrix;\nuniform mat4 u_View;\nuniform mat4 u_Project;\nuniform mat4 mvp;\n//uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n\nattribute vec3 a_position;\nattribute vec3 a_normal;\n#ifdef HAS_TANGENT\nattribute vec3 tangent;\nattribute vec3 binormal;\n#endif\nattribute vec2 uv;\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\nvarying vec2 vUv;\nvarying vec3 vWorldNorm;\nvarying vec4 vViewPos;\nvarying vec4 vWorldPos;\nvarying vec3 vLightDir;\nvarying vec3 vViewDir;\n#ifdef HAS_TANGENT\nvarying vec3 vWorldTangent;\nvarying vec3 vWorldBinormal;\n#endif\n\n#ifdef RECEIVESHADOW\nvarying float v_posViewZ;\n  #ifdef SHADOWMAP_PSSM1 \n  varying vec4 v_lightMVPPos;\n  uniform mat4 u_lightShadowVP[4];\n  #endif\n#endif\n\nvoid main() {\n#ifdef BONE\n\tmat4 skinTransform=mat4(0.0);\n\tskinTransform += u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\n\tskinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\n\tskinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\n\tskinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\n\tgl_Position = mvp*skinTransform*vec4(a_position,1.);\n\tmat4 modelMat = modelMatrix*skinTransform;\n#else\n\tgl_Position = mvp*vec4(a_position,1.);\n\tmat4 modelMat = modelMatrix;\n#endif\t\n\tvWorldPos = modelMat*vec4(a_position,1.);\n\n#ifdef CASTSHADOW \n\t#if defined(DIFFUSEMAP)&&defined(ALPHATEST)\n\t\tvUv = uv;\n\t#endif\t\n#else\n    vUv = uv;\n\tvWorldNorm = normalize((modelMat*vec4(a_normal,0.0)).xyz);\n\t#ifdef HAS_TANGENT\n\tvWorldTangent = normalize((modelMat*vec4(tangent,0.0)).xyz);\n\tvWorldBinormal = normalize((modelMat*vec4(binormal,0.0)).xyz);\n\t#endif\n    \n    vViewDir = (vWorldPos.xyz-cameraPosition);//这个不能normalize。否则无法线性差值了\n#ifdef RECEIVESHADOW\n\tv_posViewZ = gl_Position.z;\n\t#ifdef SHADOWMAP_PSSM1 \n\t\tv_lightMVPPos = u_lightShadowVP[0] * vWorldPos;\n\t#endif\n#endif\t\n#endif\n}\n",t='//#version 300 es\n\nprecision highp float;\nprecision lowp int;\n\nconst float PI = 3.14159265358979323846264;\nconst float _2PI = 6.2831853071796;\nvarying vec2 vUv;\nvarying vec3 vWorldNorm;\n#ifdef HAS_TANGENT\nvarying vec3 vWorldTangent;\nvarying vec3 vWorldBinormal;\n#endif\nvarying vec3 vViewDir;\nvarying vec4 vViewPos;\nvarying vec4 vWorldPos;\n//\nuniform sampler2D texBaseColor;\nuniform sampler2D texNormal;\n//预计算的贴图\nuniform sampler2D texPrefilterdEnv;\nuniform sampler2D texBRDFLUT;\nuniform sampler2D texPrefilterDiff;\n#ifdef HAS_PBRINFO\nuniform sampler2D texPbrInfo;   //Ao, Roughness, Metallic\n#endif\nuniform float u_hdrexposure;\nuniform float u_AlphaTestValue;\n\nuniform float u_roughness;\nuniform float u_metaless;\nconst float maxlv = 7.;\t//现在只支持512分辨率的环境贴图\nconst int nmaxlv = 9;//\n\t\t\t\t\t\t\t\nuniform mat4 irrad_mat_red;\nuniform mat4 irrad_mat_green;\nuniform mat4 irrad_mat_blue;\t\t\t\t\t\t\t\n\nvec3 speccontrib = vec3(0.);\n\nconst float _maxu8 = 255.0;\nconst float _maxu16 = 65535.0;\nconst float _shift8 = 256.0;    //平移的话是*256而不是255\nvec2 _RGBAToU16(const in vec4 rgba){\n    return vec2((rgba.r*_maxu8+rgba.g*_maxu8*_shift8)/_maxu16, (rgba.b*_maxu8+rgba.a*_maxu8*_shift8)/_maxu16);\n}\nvec3 _RGBEToRGB( const in vec4 rgba ){\n    float f = pow(2.0, rgba.w * 255.0 - (128.0 + 8.0));\n    return rgba.rgb * (255.0 * f);\n}\n\nfloat saturate(float v){\n    return min(max(v,0.),1.);\n}\n\nvec4 tex2dLod(sampler2D tex, float u, float v, float lod){\n\tvec2 uv = vec2(u,v);\n\tuv+=mod(gl_FragCoord.xy-vec2(0.5),2.0)*vec2(128.,0.);\n\treturn texture2D(tex,uv,lod-16.);\n}\n\n/*\n* 对一个全景图进行采样。假设x轴指向中心。\n*/\nvec4 texPanorama(sampler2D tex, const in vec3 dir){\n\tfloat envu = atan(dir.z,dir.x)/_2PI+0.5; \t\n\tfloat envv = acos(dir.y)/PI;//(1.0-dir.y)/2.0;\n\treturn texture2D(tex,vec2(envu,envv));\n}\n\nvec4 texPanoramaLod(sampler2D tex, const in vec3 dir, float lod){\n\tfloat envu = atan(dir.z,dir.x)/_2PI+0.5; \t\n\tfloat envv = acos(dir.y)/PI;//(1.0-dir.y)/2.0;\n\treturn tex2dLod(tex,envu,envv,lod);\n}\n\n/*\n    计算sh光照。\n    使用level=2，所以需要9个系数。\n    https://cseweb.ucsd.edu/~ravir/papers/envmap/envmap.pdf\n*/\nfloat environment_exposure = 1.0;\nvec3 diff_sh9(vec3 dir){\n\tvec4 shDir = vec4(dir.x,-dir.z,dir.y,1.0);\n  return max(vec3(0.0), vec3(\n\tdot(shDir, irrad_mat_red * shDir),\n\tdot(shDir, irrad_mat_green * shDir),\n\tdot(shDir, irrad_mat_blue * shDir)\n\t)) * environment_exposure;\t\n}\n\n#ifdef HAS_TANGENT\nvec3 applyNormalTex( vec3 norm, vec3 surf_norm ) {\n    vec3 mapN = norm * 2.0 - 1.0;\n    //mapN.xy = normalScale * mapN.xy;\n    mat3 tsn = mat3( vWorldTangent, vWorldBinormal, surf_norm );\n    return normalize( tsn * mapN );\n}\n#endif\n\nvec4 pbrlight(vec3 normal, float rough, float NoV, vec3 R){\n    vec4 basecolor = texture2D(texBaseColor,vUv);\n\tbasecolor.rgb = pow(basecolor.rgb,vec3(2.2));\n\tfloat metaless = 1.0; \t\n\tconst float ismetalinfov = (128./255.);\n\tif(basecolor.a>=ismetalinfov){//这时候表示金属度\n\t\tmetaless = (basecolor.a-ismetalinfov)*2.;\n\t\tbasecolor.a = 1.0;\n\t}else{\n\t\tmetaless = 0.;\n\t\tbasecolor.a = basecolor.a*2.0;\n\t}\n\t#ifdef FIX_METALESS\n\tmetaless = u_metaless;\n\t#endif\n\t#ifdef HAS_PBRINFO\t\n\tvec4 pbrinfo = texture2D(texPbrInfo, vUv);\n\tmetaless = pbrinfo.b;\n\trough = pbrinfo.g;\n\t#endif\n    const vec3 nonmetalF0 =vec3(0.02);\n    vec3 F0 =  mix(nonmetalF0, basecolor.rgb, metaless);\n\t\n    vec4 PrefilteredColor = texPanoramaLod(texPrefilterdEnv, R, rough*maxlv);\n    PrefilteredColor.rgb = _RGBEToRGB(PrefilteredColor);\n    vec4 EnvBRDF = texture2D(texBRDFLUT,vec2(rough , NoV));//TODO lod\n    vec2 rg = _RGBAToU16(EnvBRDF);    \n    speccontrib = (F0* rg.x + saturate( 50.0 * PrefilteredColor.g ) * rg.y);\n\tvec3 color_spec = PrefilteredColor.rgb*speccontrib;\n\t\n\tvec3 color_diff=diff_sh9(normal);\n\tvec3 outc =  color_diff*mix(basecolor.rgb,vec3(0.),metaless)*(vec3(1.0)-speccontrib)+color_spec;\n\t#ifdef HAS_PBRINFO\n\toutc*=pbrinfo.r;\n\t#endif\n\treturn vec4(outc, basecolor.a);\n}\n\nvec3 oldlight(vec4 normal, float NoV, vec3 R){\n    vec4 basecolor = texture2D(texBaseColor,vUv);\n\tconst vec3 lightdir=normalize(vec3(1.,1.,0.));\n\tconst vec3 spcecol = vec3(1.,0.8,0.8);\n\tconst vec3 amb = vec3(0.5);\n\tvec3 diffv =  (vec3(saturate(dot(lightdir,normal.xyz)))+amb);\n\t//vec3 spec = spcecol* pow(saturate(dot(R,lightdir)),(1.-pbrinfo.g)*5.);\n\treturn diffv*basecolor.rgb;//+spec;\n}\n\n#include "ShadowHelper.glsl"\n#ifdef RECEIVESHADOW\nvarying float v_posViewZ;\n\t#if defined(SHADOWMAP_PSSM2)||defined(SHADOWMAP_PSSM3)\n\tuniform mat4 u_lightShadowVP[4];\n\t#endif\n\t#ifdef SHADOWMAP_PSSM1 \n\tvarying vec4 v_lightMVPPos;\n\t#endif\n#endif\n\nvoid main() {\n#ifdef CASTSHADOW\n\tgl_FragColor=packDepth(gl_FragCoord.w);\n\t#if defined(DIFFUSEMAP)&&defined(ALPHATEST)\n\t\tfloat alpha = texture2D(texBaseColor,vUv).w;\n\t\tif( alpha < u_AlphaTestValue ){\n\t\t\tdiscard;\n\t\t}\n\t#endif\n#else\n\n\t#ifdef RECEIVESHADOW\n\t\tfloat shadowValue = 1.0;\n\t\t#ifdef SHADOWMAP_PSSM3\n\t\t\tshadowValue = getShadowPSSM3( u_shadowMap1,u_shadowMap2,u_shadowMap3,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,vWorldPos.xyz,v_posViewZ,0.0001);\n\t\t#endif\n\t\t#ifdef SHADOWMAP_PSSM2\n\t\t\tshadowValue = getShadowPSSM2( u_shadowMap1,u_shadowMap2,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,vWorldPos.xyz,v_posViewZ,0.0001);\n\t\t#endif \n\t\t#ifdef SHADOWMAP_PSSM1\n\t\t\tshadowValue = getShadowPSSM1( u_shadowMap1,v_lightMVPPos,u_shadowPSSMDistance,u_shadowPCFoffset,v_posViewZ,0.0001);\n\t\t#endif\n\t#endif\t\n\t\n    vec3 normal =  normalize(vWorldNorm);\n\tvec4 normtex = texture2D( texNormal, vUv );\n\t#ifdef HAS_TANGENT\t\n\tnormal = applyNormalTex(normtex.xyz, normal);\n\t#endif\n    vec3 view   = -normalize(vViewDir);\n    float NoV = saturate(dot( view, normal ));\n    vec3 R = 2. * NoV * normal - view;\n\tfloat roughness = normtex.a;\n\t#ifdef FIX_ROUGHNESS\n\troughness = u_roughness;\n\t#endif\n\t\n\tvec4 pbrl = pbrlight(normal,roughness,NoV,R)*u_hdrexposure;\n    gl_FragColor.rgb =  pow(pbrl.rgb,vec3(0.45455));\n\t//gl_FragColor.rgb = oldlight(normtex,NoV,R);\n\t#ifdef RECEIVESHADOW\n\tgl_FragColor.rgb *= max(shadowValue,0.7);\n\t#endif\n\t\n    gl_FragColor.a = pbrl.a;\n\n#endif\n}\n',a=fn.add(l,e,t,n,i),Xn.SHADERDEFINE_FIX_METALESS=a.registerMaterialDefine("FIX_METALESS"),Xn.SHADERDEFINE_FIX_ROUGHNESS=a.registerMaterialDefine("FIX_ROUGHNESS"),Xn.SHADERDEFINE_HAS_TANGENT=a.registerMaterialDefine("HAS_TANGENT"),Xn.SHADERDEFINE_HAS_PBRINFO=a.registerMaterialDefine("HAS_PBRINFO"),Xn.SHADERDEFINE_USE_GROUNDTRUTH=a.registerMaterialDefine("USE_GROUNDTRUTH"),Xn.SHADERDEFINE_TEST_CLIPZ=a.registerMaterialDefine("CLIPZ"),n={a_Position:0,a_Normal:3,a_Tangent0:5,a_Texcoord0:2,a_BoneWeights:7,a_BoneIndices:6},i={u_Bones:[0,0],u_MvpMatrix:[1,2],u_WorldMat:[0,2],u_CameraPos:[0,3],u_AlphaTestValue:[0,1],u_DiffuseColor:[7,1],u_EmissionColor:[8,1],u_DiffuseTexture:[1,1],u_NormalTexture:[3,1],u_ParallaxTexture:[4,1],u_MetallicGlossTexture:[2,1],u_OcclusionTexture:[5,1],u_EmissionTexture:[6,1],u_metallic:[9,1],u_smoothness:[10,1],u_smoothnessScale:[11,1],u_occlusionStrength:[13,1],u_normalScale:[14,1],u_parallaxScale:[15,1],u_TilingOffset:[17,1],"u_DirectionLight.Direction":[3,4],"u_DirectionLight.Color":[4,4],u_AmbientColor:[21,4],u_shadowMap1:[18,4],u_shadowMap2:[19,4],u_shadowMap3:[20,4],u_shadowPSSMDistance:[15,4],u_lightShadowVP:[16,4],u_shadowPCFoffset:[17,4]};var h=Gn.nameKey.add("PBRStandard");e="attribute vec4 a_Position;\nattribute vec3 a_Normal;\nattribute vec4 a_Tangent0;\nattribute vec2 a_Texcoord0;\n\nuniform mat4 u_MvpMatrix;\nuniform mat4 u_WorldMat;\nuniform vec3 u_CameraPos;\n\nvarying vec2 v_Texcoord0;\nvarying vec3 v_Normal;\nvarying vec3 v_Tangent;\nvarying vec3 v_Binormal;\nvarying vec3 v_ViewDir;\nvarying vec3 v_PositionWorld;\n\n#ifdef TILINGOFFSET\n\tuniform vec4 u_TilingOffset;\n#endif\n\nvarying float v_posViewZ;\n#ifdef RECEIVESHADOW\n  #ifdef SHADOWMAP_PSSM1 \n\t  varying vec4 v_lightMVPPos;\n\t  uniform mat4 u_lightShadowVP[4];\n  #endif\n#endif\n\n#ifdef BONE\n\tconst int c_MaxBoneCount = 24;\n\tattribute vec4 a_BoneIndices;\n\tattribute vec4 a_BoneWeights;\n\tuniform mat4 u_Bones[c_MaxBoneCount];\n#endif\n\nvoid main_castShadow()\n{\n\t#ifdef BONE\n\t\tmat4 skinTransform=mat4(0.0);\n\t\tskinTransform += u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\n\t\tvec4 position = skinTransform * a_Position;\n\t\tgl_Position = u_MvpMatrix * position;\n\t#else\n\t\tgl_Position = u_MvpMatrix * a_Position;\n\t#endif\n\t \n\t//TODO没考虑UV动画呢\n\t#if defined(DIFFUSEMAP)&&defined(ALPHATEST)\n\t\tv_Texcoord0 = a_Texcoord0;\n\t#endif\n\t\tv_posViewZ = gl_Position.z;\n}\n\nvoid main_normal()\n{\n\tmat3 worldMat;\n\t#ifdef BONE\n\t\tmat4 skinTransform = mat4(0.0);\n\t\tskinTransform += u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\n\t\tvec4 position = skinTransform * a_Position;\n\t\tgl_Position = u_MvpMatrix * position;\n\t\tworldMat=mat3(u_WorldMat*skinTransform);\n\t\tv_PositionWorld = (u_WorldMat * position).xyz;\n\t#else\n\t\tgl_Position = u_MvpMatrix * a_Position;\n\t\tworldMat = mat3(u_WorldMat);\n\t\tv_PositionWorld = (u_WorldMat * a_Position).xyz;\n\t#endif\n\t\n\tv_Normal = worldMat * a_Normal;\n\tv_Tangent = worldMat * a_Tangent0.xyz;\n\tv_Binormal = cross(v_Normal, v_Tangent) * a_Tangent0.w;\n  \n\tv_Texcoord0 = a_Texcoord0;\n\t#ifdef TILINGOFFSET\n\t\tv_Texcoord0=(vec2(v_Texcoord0.x,v_Texcoord0.y-1.0)*u_TilingOffset.xy)+u_TilingOffset.zw;\n\t#endif\n\t\tv_Texcoord0=vec2(v_Texcoord0.x,1.0 + v_Texcoord0.y);\n  \n\tv_ViewDir = u_CameraPos - v_PositionWorld;\n  \n\t#ifdef RECEIVESHADOW\n\t\tv_posViewZ = gl_Position.w;\n\t\t#ifdef SHADOWMAP_PSSM1 \n\t\t\tv_lightMVPPos = u_lightShadowVP[0] * vec4(v_PositionWorld,1.0);\n\t\t#endif\n\t#endif\n}\n\nvoid main()\n{\n\t#ifdef CASTSHADOW\n\t\tmain_castShadow();\n\t#else\n\t\tmain_normal();\n\t#endif\n}",t='#ifdef FSHIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\nvarying vec2 v_Texcoord0;\nvarying vec3 v_Normal;\nvarying vec3 v_Tangent;\nvarying vec3 v_Binormal;\nvarying vec3 v_ViewDir;\n\nuniform vec4 u_AmbientColor;\nuniform vec4 u_DiffuseColor;\n\n#ifdef DIFFUSETEXTURE\n\tuniform sampler2D u_DiffuseTexture;\n#endif\n#ifdef METALLICGLOSSTEXTURE\n\tuniform sampler2D u_MetallicGlossTexture;\n#endif\n#ifdef NORMALTEXTURE\n\tuniform sampler2D u_NormalTexture;\n\tuniform float u_normalScale;\n#endif\n#ifdef PARALLAXTEXTURE\n\tuniform sampler2D u_ParallaxTexture;\n\tuniform float u_parallaxScale;\n#endif\n#ifdef OCCLUSIONTEXTURE\n\tuniform sampler2D u_OcclusionTexture;\n\tuniform float u_occlusionStrength;\n#endif\n#ifdef EMISSION\n\t#ifdef EMISSIONTEXTURE\n\t\tuniform sampler2D u_EmissionTexture;\n\t#endif\n\tuniform vec4 u_EmissionColor;\n#endif\n\nuniform float u_AlphaTestValue;\nuniform float u_metallic;\nuniform float u_smoothness;\nuniform float u_smoothnessScale;\n\n#include "PBRStandardLighting.glsl"\n#include "ShadowHelper.glsl"\n\nvarying float v_posViewZ;\n#ifdef RECEIVESHADOW\n\t#if defined(SHADOWMAP_PSSM2)||defined(SHADOWMAP_PSSM3)\n\t\tuniform mat4 u_lightShadowVP[4];\n\t#endif\n\t#ifdef SHADOWMAP_PSSM1 \n\t\tvarying vec4 v_lightMVPPos;\n\t#endif\n#endif\n\nuniform DirectionLight u_DirectionLight;\n\nvoid main_castShadow()\n{\n\tgl_FragColor=packDepth(v_posViewZ);\n\t#if defined(DIFFUSEMAP)&&defined(ALPHATEST)\n\t\tfloat alpha = texture2D(u_DiffuseTexture,v_Texcoord0).w;\n\t\tif( alpha < u_AlphaTestValue )\n\t\t{\n\t\t\tdiscard;\n\t\t}\n\t#endif\n}\n\nvoid main_normal()\n{\t\n\tvec3 viewDir = normalize(v_ViewDir);\n\t\n\tvec2 uv0 = ParallaxOffset(viewDir);\n\t\n\tvec2 mg;\n\t#ifdef DIFFUSETEXTURE\n\t\tvec4 diffuseTextureColor = texture2D(u_DiffuseTexture, uv0);\n\t\tvec4 diffuseColor = diffuseTextureColor * u_DiffuseColor;\n\t\tmg = MetallicGloss(diffuseTextureColor.a, uv0);\n\t#else\n\t\tvec4 diffuseColor = u_DiffuseColor;\n\t\tmg = MetallicGloss(1.0, uv0);\n\t#endif\n\t\n\t#ifdef ALPHATEST\n\t\tif(diffuseColor.a < u_AlphaTestValue)\n\t\t\tdiscard;\n\t#endif\n\t\n\tgl_FragColor = diffuseColor;\n\t\n\tvec3 normal = UnpackScaleNormal(uv0);\n  \n\tvec3 gi = (u_AmbientColor * Occlusion(uv0)).rgb;\n  \n\tvec4 color = PBRStandardDiectionLight(diffuseColor.rgb, mg.r, mg.g, normal, viewDir, u_DirectionLight, gi);\n\t\n\tcolor.a = diffuseColor.a;\n\t\n\t#ifdef EMISSION\n\t\tvec4 emissionColor = u_EmissionColor;\n\t\t#ifdef EMISSIONTEXTURE\n\t\t\temissionColor *=  texture2D(u_EmissionTexture, uv0);\n\t\t#endif\n\t\tcolor.rgb += emissionColor.rgb;\n\t#endif\n\t\n\t#ifdef RECEIVESHADOW\n\t\tfloat shadowValue = 1.0;\n\t\t#ifdef SHADOWMAP_PSSM3\n\t\t\tshadowValue = getShadowPSSM3( u_shadowMap1,u_shadowMap2,u_shadowMap3,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\n\t\t#endif\n\t\t#ifdef SHADOWMAP_PSSM2\n\t\t\tshadowValue = getShadowPSSM2( u_shadowMap1,u_shadowMap2,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\n\t\t#endif \n\t\t#ifdef SHADOWMAP_PSSM1\n\t\t\tshadowValue = getShadowPSSM1( u_shadowMap1,v_lightMVPPos,u_shadowPSSMDistance,u_shadowPCFoffset,v_posViewZ,0.001);\n\t\t#endif\n\t\tgl_FragColor = vec4(color.rgb * shadowValue, color.a);\n\t#else\n\t\tgl_FragColor = color;\n\t#endif\n}\n\nvoid main()\n{\n\t#ifdef CASTSHADOW\t\t\n\t\tmain_castShadow();\n\t#else\n\t\tmain_normal();\n\t#endif  \n}\n\n',a=fn.add(h,e,t,n,i),Yn.SHADERDEFINE_DIFFUSETEXTURE=a.registerMaterialDefine("DIFFUSETEXTURE"),Yn.SHADERDEFINE_METALLICGLOSSTEXTURE=a.registerMaterialDefine("METALLICGLOSSTEXTURE"),Yn.SHADERDEFINE_SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA=a.registerMaterialDefine("SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA"),Yn.SHADERDEFINE_NORMALTEXTURE=a.registerMaterialDefine("NORMALTEXTURE"),Yn.SHADERDEFINE_PARALLAXTEXTURE=a.registerMaterialDefine("PARALLAXTEXTURE"),Yn.SHADERDEFINE_OCCLUSIONTEXTURE=a.registerMaterialDefine("OCCLUSIONTEXTURE"),Yn.SHADERDEFINE_EMISSION=a.registerMaterialDefine("EMISSION"),Yn.SHADERDEFINE_EMISSIONTEXTURE=a.registerMaterialDefine("EMISSIONTEXTURE"),Yn.SHADERDEFINE_TILINGOFFSET=a.registerMaterialDefine("TILINGOFFSET"),n={a_Position:0,a_Normal:3,a_Tangent0:5,a_Texcoord0:2,a_BoneWeights:7,a_BoneIndices:6},i={u_Bones:[0,0],u_MvpMatrix:[1,2],u_WorldMat:[0,2],u_CameraPos:[0,3],u_AlphaTestValue:[0,1],u_DiffuseColor:[7,1],u_SpecularColor:[8,1],u_EmissionColor:[9,1],u_DiffuseTexture:[1,1],u_NormalTexture:[3,1],u_ParallaxTexture:[4,1],u_SpecularTexture:[2,1],u_OcclusionTexture:[5,1],u_EmissionTexture:[6,1],u_smoothness:[10,1],u_smoothnessScale:[11,1],u_occlusionStrength:[13,1],u_normalScale:[14,1],u_parallaxScale:[15,1],u_TilingOffset:[17,1],"u_DirectionLight.Direction":[3,4],"u_DirectionLight.Color":[4,4],u_AmbientColor:[21,4],u_shadowMap1:[18,4],u_shadowMap2:[19,4],u_shadowMap3:[20,4],u_shadowPSSMDistance:[15,4],u_lightShadowVP:[16,4],u_shadowPCFoffset:[17,4]};var _=Gn.nameKey.add("PBRSpecular");e="attribute vec4 a_Position;\nattribute vec3 a_Normal;\nattribute vec4 a_Tangent0;\nattribute vec2 a_Texcoord0;\n\nuniform mat4 u_MvpMatrix;\nuniform mat4 u_WorldMat;\nuniform vec3 u_CameraPos;\n\nvarying vec2 v_Texcoord0;\nvarying vec3 v_Normal;\nvarying vec3 v_Tangent;\nvarying vec3 v_Binormal;\nvarying vec3 v_ViewDir;\nvarying vec3 v_PositionWorld;\n\n#ifdef TILINGOFFSET\n\tuniform vec4 u_TilingOffset;\n#endif\n\nvarying float v_posViewZ;\n#ifdef RECEIVESHADOW\n  #ifdef SHADOWMAP_PSSM1 \n\t  varying vec4 v_lightMVPPos;\n\t  uniform mat4 u_lightShadowVP[4];\n  #endif\n#endif\n\n#ifdef BONE\n\tconst int c_MaxBoneCount = 24;\n\tattribute vec4 a_BoneIndices;\n\tattribute vec4 a_BoneWeights;\n\tuniform mat4 u_Bones[c_MaxBoneCount];\n#endif\n\nvoid main_castShadow()\n{\n\t#ifdef BONE\n\t\tmat4 skinTransform=mat4(0.0);\n\t\tskinTransform += u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\n\t\tvec4 position = skinTransform * a_Position;\n\t\tgl_Position = u_MvpMatrix * position;\n\t#else\n\t\tgl_Position = u_MvpMatrix * a_Position;\n\t#endif\n\t \n\t//TODO没考虑UV动画呢\n\t#if defined(DIFFUSEMAP)&&defined(ALPHATEST)\n\t\tv_Texcoord0 = a_Texcoord0;\n\t#endif\n\t\tv_posViewZ = gl_Position.z;\n}\n\nvoid main_normal()\n{\n\tmat3 worldMat;\n\t#ifdef BONE\n\t\tmat4 skinTransform = mat4(0.0);\n\t\tskinTransform += u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\n\t\tvec4 position = skinTransform * a_Position;\n\t\tgl_Position = u_MvpMatrix * position;\n\t\tworldMat=mat3(u_WorldMat*skinTransform);\n\t\tv_PositionWorld = (u_WorldMat * position).xyz;\n\t#else\n\t\tgl_Position = u_MvpMatrix * a_Position;\n\t\tworldMat = mat3(u_WorldMat);\n\t\tv_PositionWorld = (u_WorldMat * a_Position).xyz;\n\t#endif\n\t\n\tv_Normal = worldMat * a_Normal;\n\tv_Tangent = worldMat * a_Tangent0.xyz;\n\tv_Binormal = cross(v_Normal, v_Tangent) * a_Tangent0.w;\n  \n\tv_Texcoord0 = a_Texcoord0;\n\t#ifdef TILINGOFFSET\n\t\tv_Texcoord0=(vec2(v_Texcoord0.x,v_Texcoord0.y-1.0)*u_TilingOffset.xy)+u_TilingOffset.zw;\n\t#endif\n\t\tv_Texcoord0=vec2(v_Texcoord0.x,1.0 + v_Texcoord0.y);\n  \n\tv_ViewDir = u_CameraPos - v_PositionWorld;\n  \n\t#ifdef RECEIVESHADOW\n\t\tv_posViewZ = gl_Position.w;\n\t\t#ifdef SHADOWMAP_PSSM1 \n\t\t\tv_lightMVPPos = u_lightShadowVP[0] * vec4(v_PositionWorld,1.0);\n\t\t#endif\n\t#endif\n}\n\nvoid main()\n{\n\t#ifdef CASTSHADOW\n\t\tmain_castShadow();\n\t#else\n\t\tmain_normal();\n\t#endif\n}",t='#ifdef FSHIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\nvarying vec2 v_Texcoord0;\nvarying vec3 v_Normal;\nvarying vec3 v_Tangent;\nvarying vec3 v_Binormal;\nvarying vec3 v_ViewDir;\n\nuniform vec4 u_AmbientColor;\nuniform vec4 u_DiffuseColor;\nuniform vec4 u_SpecularColor;\n\n#ifdef DIFFUSETEXTURE\n\tuniform sampler2D u_DiffuseTexture;\n#endif\n#ifdef SPECULARTEXTURE\n\tuniform sampler2D u_SpecularTexture;\n#endif\n#ifdef NORMALTEXTURE\n\tuniform sampler2D u_NormalTexture;\n\tuniform float u_normalScale;\n#endif\n#ifdef PARALLAXTEXTURE\n\tuniform sampler2D u_ParallaxTexture;\n\tuniform float u_parallaxScale;\n#endif\n#ifdef OCCLUSIONTEXTURE\n\tuniform sampler2D u_OcclusionTexture;\n\tuniform float u_occlusionStrength;\n#endif\n#ifdef EMISSION\n\t#ifdef EMISSIONTEXTURE\n\t\tuniform sampler2D u_EmissionTexture;\n\t#endif\n\tuniform vec4 u_EmissionColor;\n#endif\n\nuniform float u_AlphaTestValue;\nuniform float u_metallic;\nuniform float u_smoothness;\nuniform float u_smoothnessScale;\n\n#include "PBRSpecularLighting.glsl"\n#include "ShadowHelper.glsl"\n\nvarying float v_posViewZ;\n#ifdef RECEIVESHADOW\n\t#if defined(SHADOWMAP_PSSM2)||defined(SHADOWMAP_PSSM3)\n\t\tuniform mat4 u_lightShadowVP[4];\n\t#endif\n\t#ifdef SHADOWMAP_PSSM1 \n\t\tvarying vec4 v_lightMVPPos;\n\t#endif\n#endif\n\nuniform DirectionLight u_DirectionLight;\n\nvoid main_castShadow()\n{\n\tgl_FragColor=packDepth(v_posViewZ);\n\t#if defined(DIFFUSEMAP)&&defined(ALPHATEST)\n\t\tfloat alpha = texture2D(u_DiffuseTexture,v_Texcoord0).w;\n\t\tif( alpha < u_AlphaTestValue )\n\t\t{\n\t\t\tdiscard;\n\t\t}\n\t#endif\n}\n\nvoid main_normal()\n{\t\n\tvec3 viewDir = normalize(v_ViewDir);\n\t\n\tvec2 uv0 = ParallaxOffset(viewDir);\n\t\n\tvec4 sg;\n\t#ifdef DIFFUSETEXTURE\n\t\tvec4 diffuseTextureColor = texture2D(u_DiffuseTexture, uv0);\n\t\tvec4 diffuseColor = diffuseTextureColor * u_DiffuseColor;\n\t\tsg = SpecularGloss(diffuseTextureColor.a, uv0);\n\t#else\n\t\tvec4 diffuseColor = u_DiffuseColor;\n\t\tsg = SpecularGloss(1.0, uv0);\n\t#endif\n\t\n\t#ifdef ALPHATEST\n\t\tif(diffuseColor.a < u_AlphaTestValue)\n\t\t\tdiscard;\n\t#endif\n  \n\tvec3 normal = UnpackScaleNormal(uv0);\n\t\n\tvec3 gi = (u_AmbientColor * Occlusion(uv0)).rgb;\n\t\n\t//float a = (sg.r+sg.g+sg.b) / 3.0;\n  \n\tvec4 color = PBRSpecularDiectionLight(diffuseColor.rgb, sg.rgb, sg.a, normal,viewDir, u_DirectionLight, gi);\n\t\n\tcolor.a = diffuseColor.a;\n\t\n\t#ifdef EMISSION\n\t\tvec4 emissionColor = u_EmissionColor;\n\t\t#ifdef EMISSIONTEXTURE\n\t\t\temissionColor *=  texture2D(u_EmissionTexture, uv0);\n\t\t#endif\n\t\tcolor.rgb += emissionColor.rgb;\n\t#endif\n\t\n\t#ifdef RECEIVESHADOW\n\t\tfloat shadowValue = 1.0;\n\t\t#ifdef SHADOWMAP_PSSM3\n\t\t\tshadowValue = getShadowPSSM3( u_shadowMap1,u_shadowMap2,u_shadowMap3,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\n\t\t#endif\n\t\t#ifdef SHADOWMAP_PSSM2\n\t\t\tshadowValue = getShadowPSSM2( u_shadowMap1,u_shadowMap2,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\n\t\t#endif \n\t\t#ifdef SHADOWMAP_PSSM1\n\t\t\tshadowValue = getShadowPSSM1( u_shadowMap1,v_lightMVPPos,u_shadowPSSMDistance,u_shadowPCFoffset,v_posViewZ,0.001);\n\t\t#endif\n\t\tgl_FragColor = vec4(color.rgb * shadowValue, color.a);\n\t#else\n\t\tgl_FragColor = color;\n\t#endif\n}\n\nvoid main()\n{\n\t#ifdef CASTSHADOW\t\t\n\t\tmain_castShadow();\n\t#else\n\t\tmain_normal();\n\t#endif  \n}\n\n',a=fn.add(_,e,t,n,i),Zn.SHADERDEFINE_DIFFUSETEXTURE=a.registerMaterialDefine("DIFFUSETEXTURE"),Zn.SHADERDEFINE_SPECULARTEXTURE=a.registerMaterialDefine("SPECULARTEXTURE"),Zn.SHADERDEFINE_SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA=a.registerMaterialDefine("SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA"),Zn.SHADERDEFINE_NORMALTEXTURE=a.registerMaterialDefine("NORMALTEXTURE"),Zn.SHADERDEFINE_PARALLAXTEXTURE=a.registerMaterialDefine("PARALLAXTEXTURE"),Zn.SHADERDEFINE_OCCLUSIONTEXTURE=a.registerMaterialDefine("OCCLUSIONTEXTURE"),Zn.SHADERDEFINE_EMISSION=a.registerMaterialDefine("EMISSION"),Zn.SHADERDEFINE_EMISSIONTEXTURE=a.registerMaterialDefine("EMISSIONTEXTURE"),Zn.SHADERDEFINE_TILINGOFFSET=a.registerMaterialDefine("TILINGOFFSET"),n={a_position:0,a_normal:3,uv:2},i={irrad_mat_red:[10,3],irrad_mat_green:[11,3],irrad_mat_blue:[12,3],u_hdrexposure:[13,3],texBaseColor:[1,1],texNormal:[2,1],texSky:[11,1],texUnderWater:[3,1],texPrefilterdEnv:[8,3],texPrefilterDiff:[7,3],texWaterDisp:[4,1],texWaveDetail:[9,1],texDeepColor:[10,1],texWaterInfo:[16,1],texFoam:[17,1],GEOWAVE_UV_SCALE:[18,1],modelMatrix:[0,2],mvp:[1,2],cameraPosition:[0,3],u_curTm:[8,1],u_scrsize:[15,1],u_WaveInfoD:[13,1],u_WaveInfo:[12,1],u_WaveMainDir:[14,1],u_DeepScale:[20,1],u_SeaColor:[19,1],u_View:[1,3],u_Project:[2,3],u_FogStart:[1,4],u_FogRange:[2,4],u_FogColor:[0,4],"u_DirectionLight.Direction":[3,4],"u_DirectionLight.Diffuse":[4,4],"u_PointLight.Position":[5,4],"u_PointLight.Range":[6,4],"u_PointLight.Attenuation":[7,4],"u_PointLight.Diffuse":[8,4],"u_SpotLight.Position":[9,4],"u_SpotLight.Direction":[10,4],"u_SpotLight.Range":[12,4],"u_SpotLight.Spot":[11,4],"u_SpotLight.Attenuation":[13,4],"u_SpotLight.Diffuse":[14,4]};var u=Gn.nameKey.add("Water");e='\nuniform mat4 modelMatrix;\n//uniform mat4 modelViewMatrix;\n//uniform mat4 projectionMatrix;\nuniform mat4 u_View;\nuniform mat4 u_Project;\nuniform mat4 mvp;\n//uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\nuniform float u_curTm;\n\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 uv;\n//uniform sampler2D texWaterDisp;\n#ifdef USE_VERTEX_DEEPINFO\n#else\nuniform sampler2D texWaterInfo;\nvarying vec4 vWaterInfo;\nuniform float u_DeepScale;//texWaterInfo.r*vDeepScale\n#endif\nuniform float u_WaveMainDir;\t//主波方向\nuniform float GEOWAVE_UV_SCALE ;//= 100.0;\n\n\nvarying vec2 vUv;\nvarying vec3 vWorldNorm;\nvarying vec3 vWorldTan;\nvarying vec3 vWorldBin;\nvarying vec4 vViewPos;\nvarying vec4 vWorldPos;\nvarying vec3 vLightDir;\nvarying vec3 vViewDir;\nvarying vec3 vDisp;\nvarying float fDeep;\nvarying mat2 matUVTrans;\nvarying float fFoam;\n\nconst float PI = 3.14159265358979323846264;\n\n#include "WaveFunction.glsl"\n\nvec2 getPosFromUV(vec2 uv){\n\treturn uv*50.;\n}\n\nvoid main() {\n\tvec3 pos = a_position;\n    vUv = uv;\n\t\n\t//vDisp = texture2D(texWaterDisp,uv).rgb;\n\t//vec3 disp = vDisp;\n\t\n\t//TODO 这里有个潜规则。\n\tfloat tt = pos.y; pos.y=pos.z; pos.z=-tt;\n\t\n\t#ifdef USE_VERTEX_DEEPINFO\n\tfDeep = -pos.y;\n\tpos.y=0.0;\n\t#else\n\tvWaterInfo = texture2D(texWaterInfo,uv);\n\tfDeep = vWaterInfo.r*u_DeepScale;\n\t#endif\n\t\n\t\n\t//计算波形\n\tmat4 modelMat = modelMatrix;\n\tvec3 opos, T,B,N;\n\tfloat foams=0.;\n\tvec2 uvpos = uv*GEOWAVE_UV_SCALE+vec2(modelMat[3][0],0.);//TODO 如果有旋转缩放怎么办\n\tcalcGerstnerWave(u_curTm, pos,fDeep, uvpos,opos,B,T,N,foams);\n\tfFoam = foams;\n\tgl_Position = mvp*vec4(opos,1.);\n\tvWorldPos = modelMat*vec4(opos,1.);\n\n\tvWorldNorm = normalize((modelMatrix*vec4(N,0.0)).xyz);\n\tvWorldTan = normalize((modelMatrix*vec4(T,0.0)).xyz);\n\tvWorldBin = normalize((modelMatrix*vec4(B,0.0)).xyz);\n    vViewDir = vWorldPos.xyz-cameraPosition; //这个不能取normalize，否则会引入非线性\n\t\n\tfloat s = sin(u_WaveMainDir);\n\tfloat c = cos(u_WaveMainDir);\n\tmatUVTrans = mat2(c,-s,s,c);\n}\n',t="//#version 300 es\n\nprecision highp float;\nprecision lowp int;\n\nconst float PI = 3.14159265358979323846264;\nconst float _2PI = 6.2831853071796;\nvarying vec2 vUv;\nvarying vec3 vWorldNorm;\nvarying vec3 vWorldTan;\nvarying vec3 vWorldBin;\nvarying vec3 vViewDir;//入射。pos-cam\nvarying vec4 vViewPos;\nvarying vec4 vWorldPos;\nvarying float fDeep;\nvarying mat2 matUVTrans;\n#ifdef USE_VERTEX_DEEPINFO\n#else\nvarying vec4 vWaterInfo;\n#endif\nmat3 matTBNOff;//\n\n//\nuniform sampler2D texBaseColor;\nuniform sampler2D texNormal;\n#ifdef CUBE_ENV\nuniform samplerCube texSky;\n#else\nuniform sampler2D texSky;\n#endif\nuniform sampler2D texUnderWater;\nuniform sampler2D texWaveDetail;\n//uniform sampler2D texDeepColor;\nuniform sampler2D texFoam;\nvarying float fFoam;\nuniform float u_curTm;\nuniform vec2 u_scrsize;\nuniform vec3 u_SeaColor;//\n\nconst int NumTexWaves=4;\nconst float Amp_over_L = 0.01;\n//const vec3 SEA_COLOR1 = vec3(0.0292,0.672,0.7467);//大洋\n//const vec3 SEA_COLOR2 = vec3(0,0.927,0.43);//近海\n\nconst float _maxu8 = 255.0;\nconst float _maxu16 = 65535.0;\nconst float _shift8 = 256.0;    //平移的话是*256而不是255\nvec2 _RGBAToU16(const in vec4 rgba){\n    return vec2((rgba.r*_maxu8+rgba.g*_maxu8*_shift8)/_maxu16, (rgba.b*_maxu8+rgba.a*_maxu8*_shift8)/_maxu16);\n}\nvec3 _RGBEToRGB( const in vec4 rgba ){\n    float f = pow(2.0, rgba.w * 255.0 - (128.0 + 8.0));\n    return rgba.rgb * (255.0 * f);\n}\n\nfloat saturate(float v){\n    return min(max(v,0.),1.);\n}\n\n/*\n\t各种 ToneMap\n*/\n//Reinhard\nvec3 ReinhardToneMapping(vec3 color, float adapted_lum) {\n    const float MIDDLE_GREY = 1.;\n    color *= MIDDLE_GREY / adapted_lum;\n    return color / (1.0 + color);\n}\n\n//CE2\nvec3 CEToneMapping(vec3 color, float adapted_lum){\n    return 1. - exp(-adapted_lum * color);\n}\n\n//UC2\nvec3 F1(vec3 x){\n\tconst float A = 0.22;\n\tconst float B = 0.30;\n\tconst float C = 0.10;\n\tconst float D = 0.20;\n\tconst float E = 0.01;\n\tconst float F = 0.30;\n \n\treturn ((x * (A * x + C * B) + D * E) / (x * (A * x + B) + D * F)) - E / F;\n}\n\nvec3 Uncharted2ToneMapping(vec3 color, float adapted_lum){\n\tconst vec3 WHITE = vec3(11.2);\n\treturn F1(1.6 * adapted_lum * color) / F1(WHITE);\n}\n\n//ACES\nvec3 ACESToneMapping(vec3 color, float adapted_lum){\n\tconst float A = 2.51;\n\tconst float B = 0.03;\n\tconst float C = 2.43;\n\tconst float D = 0.59;\n\tconst float E = 0.14;\n\n\tcolor *= adapted_lum;\n\treturn (color * (A * color + B)) / (color * (C * color + D) + E);\n}\n\n/*\n* 对一个全景图进行采样。假设x轴指向中心。\n*/\nvec4 texPanorama(sampler2D tex, const in vec3 dir){\n\tfloat envu = atan(dir.z,dir.x)/_2PI+0.5; \t\n\tfloat envv = acos(dir.y)/PI;//(1.0-dir.y)/2.0;\n\treturn texture2D(tex,vec2(envu,envv));\n}\n\n/*\n\t与位于0点的测试棒的相交测试交点\n\t这个是瞎写的，只是为了测试\n*/\nbool hitClydiner(vec3 pos, vec3 dir, out vec3 hitpos, out vec3 hitnormal){\n\tconst float r = 0.5;\n\tfloat a = dir.x*dir.x+dir.z*dir.z;\n\tfloat b = 2.*dir.x*pos.x+2.*dir.z*pos.z;\n\tfloat c = pos.x*pos.x+pos.z*pos.z-r*r;\n\tfloat d = b*b-4.*a*c;\n\tif(d>=0.0){\n\t\tfloat t = (-b+sqrt(d))/2./a;\n\t\tt =min(t, (-b-sqrt(d))/2./a);\n\t\thitpos = pos+dir*t;\n\t\treturn true;\n\t}\n\t/*\n\tvec3 v1 = normalize(cross(dir,vec3(0.,1.,0.)));//公垂线\n\tfloat dist = dot(pos,v1);//最短距离\n\tif(abs(dist)<r){\n\t\treturn true;\n\t}\n\t*/\n\treturn false;\n}\n\n///* 根据散射公式来计算某个方向的颜色 *///\n//\nfloat phase_function(float costheta, float g, float g2){\n\treturn 1.5*( (1.0-g2) / (2.0+g2) ) * (1.0+costheta*costheta) / pow(1.0+g2-2.0*g*costheta, 1.5);\t\n}\n\nconst float _density = .2;\nconst vec3 _vLightDir=vec3(0.,-1.,0.);//必须是规格化的\nconst int _SAMPLENUM = 20;\nconst float _K1 = 1.0;\nconst float _g = -0.93;\n//\nvec3 calcScatter(vec3 start, vec3 dir, vec3 end){\n\tfloat len = length(end-start);\n\tfloat costheta = dot(dir,_vLightDir);\n\tfloat g2 = _g*_g;\n\tfloat K = _K1*len*_density*phase_function(costheta,_g,g2);\n\t//用分段的方式来积分\n\tfloat dlen = len/float(_SAMPLENUM);//距离平分\n\tfloat ddeep = (start.y-end.y)/float(_SAMPLENUM);//深度平分\n\tfloat sum=0.;\n\tfor( int i=0; i<_SAMPLENUM; i++){\n\t\tfloat fi = float(i);\n\t\tfloat v1 = exp(-_density*(dlen+ddeep)*fi);//TODO 应该可以用分析法计算出来\n\t\tsum += v1;\n\t}\n\treturn vec3(K*sum);\n}\n///* 根据散射公式来计算某个方向的亮度  END *///\n\nconst float cDeep = -2.;\t//假设水的深度\nvec3 getShuiDiColor(vec3 pos, vec3 dir, vec3 normal){\n\t//一个无限大的水底，黑白格纹理。纹理长度为1米\n\tfloat t = ( cDeep-pos.y )/dir.y;\n\tif(t<0.) return vec3(1.,0.,0.);//TEST\n\tbool bhit = false;\n\tvec3 hitpos;\n\tvec3 hitcolor;\n\tvec3 hn;\n\tif(hitClydiner(pos,dir,hitpos,hn) && hitpos.y>cDeep && hitpos.y<pos.y){\n\t\tbhit=true;\n\t\thitcolor = vec3(.8,.8,.8);\n\n\t}else\n\t{\n\t\thitpos = pos+dir*t;\n\t\tvec3 hp = floor(hitpos);\n\t\tfloat a = mod((hp.x+hp.z),2.);\n\t\thitcolor = (a<.9)?vec3(0.,0.,0.):vec3(1.,1.,1.);\n\t\t//hitcolor = texture2D(texUnderWater,hitpos.xz/10.).rgb;\n\t}\n\t\n\tfloat l = length(hitpos-pos);\n\t//return texture2D(texDeepColor,vec2(min(max(l/400.,0.),1.),0.5)).rgb;\n\t//return SEA_COLOR1*calcScatter(pos,dir,hitpos);\n\tfloat left = pow(0.8,l);//假设透过率为80%，则到达水底的时候的光强。\n\treturn mix(hitcolor,u_SeaColor,1.-left);\n}\n\n/*\n\tview已经normalize了\n*/\nvec3 getRefractColor(vec3 view,vec3 normal){\n\tvec3 T = refract(-view, normal, 0.7);\n\treturn getShuiDiColor(vWorldPos.xyz,T,normal); \n}\n\nvec4 calcWaterC(vec3 view, vec3 normal, float von, vec3 R, float rough){\n\t/*\n\t只有浪顶的法线向下，也就是波形形成了交叠的时候，才会这样，所以要通过参数控制避免出现这种情况，而不是在这里保护。\n\tif(dot(R,vec3(0.,1.,0.))<0.){\n\t\tR = -R;\n\t}\n\t*/\n\t//vec3 refr = getRefractColor(-view,normal);\n#ifdef USE_REFR_TEX\t\n\tvec3 refr = texture2D(texUnderWater, gl_FragCoord.xy/u_scrsize+normal.xz/8.).rgb;\n#else\n\tvec3 refr = u_SeaColor;\n#endif\n\tfloat F0=0.02;\n\t//菲涅尔，越大反射越强\n\tfloat f =  F0+(1.0-F0)*exp2((-5.55473*von-6.98316)*von);\n\t//float f = F0+(1.0-F0)*pow(1.-von,5.);\n\t//能看到水底的程度。反射剩余的*水中的衰减\n\t//float a = (1.-f)*(1.-deepk);\n#ifdef CUBE_ENV\n\tvec4 reflc = textureCube(texSky,R);\n#else\n\tvec4 reflc = texPanorama(texSky, R);\n#endif\n#ifdef HDR_ENV\n\tvec3 refl = _RGBEToRGB(reflc)*f;\n#else\n\tvec3 refl = reflc.rgb*f;\n#endif\n\t//return vec4(refl*(1.-rough),1.);\n\t\n\t//vec3 refl = reflc.rgb*f;\n\tvec3 final = mix(refr, u_SeaColor, min(fDeep/10.,1.))+refl*(max(0.,1.-rough));\n#ifdef HDR_ENV\n\tfinal = ACESToneMapping(final,1.);//TODO 这个要uniform传入\n#endif\n\treturn vec4(final,f);\n}\n\nvoid main() {\n    vec3 normal =  normalize(vWorldNorm);\n\t//如果uv=1为100米，希望每个细节纹理表示20米的小波形，则uv缩放是 100/20。细节纹理内部也要用这个值，即pos=uv*20\n\tvec2 ruv = matUVTrans*vUv;\n\tvec3 detailNorm = texture2D(texWaveDetail,fract(ruv*5.)).rgb*2.-vec3(1.);//TODO uv怎么算\n\tfloat texNormScale = 2.*PI*float(NumTexWaves)*Amp_over_L*2.5;\n\tdetailNorm *= vec3(texNormScale,1.,texNormScale);\n\t//旋转\n\t//细节纹理来自rendertarget，因此需要颠倒z\n\t\n\tmatTBNOff = mat3(matUVTrans[0][0],0.,matUVTrans[1][0],\n\t0.,1.,0.,\n\tmatUVTrans[0][1],0.,matUVTrans[1][1]\n\t);\n\t\n\t/*\n\tmatTBNOff = mat3(0.,0.,1.,\n\t0.,1.,0.,\n\t-1.,0.,0.\n\t);\n\t*/\n\n    mat3 tsn = mat3( vWorldBin, normal, vWorldTan);\t\n    //normal = normalize(tsn * matTBNOff * detailNorm);\n\tnormal = normalize(tsn * detailNorm); //这个应该更正确。因为本身方向就是根据uv算的，如果是静态图片才需要转换。\n\t//vec4 normtex = texture2D( texNormal, vUv );\n    vec3 view   = -normalize(vViewDir);//view 是指向camera的\n    float NoV = saturate(dot( view, normal ));\n    //vec3 R = 2. * NoV * normal - view;\n\t\n#ifdef USE_FOAM\t\n\tvec4 foamc = (texture2D(texFoam,vUv*50.)+texture2D(texFoam,vUv*20.))/2.;\n\tfloat nearcoast = 1.-min(fDeep/10.,1.);// 1.-vWaterInfo.r;\n\tfloat foams = (nearcoast/4.+fFoam)*2.*nearcoast;\n#else\n\tfloat foams =0.;\n#endif\n\t\n\tvec3 R = reflect(-view,normal);\n\tvec4 wc = calcWaterC(view, normal,NoV,R, foams);\n\n\tgl_FragColor.rgb = wc.rgb;//normalize(detailNorm).rrr;//((normal)+vec3(0.0))/1.;//normalize(normal).rgb;//texture2D(texWaveDetail,vUv).rgb;// fracColor * texture2D(texUnderWater, vUv*20.0).rgb;// vec3(1.0);//pbrl.rgb;\n    gl_FragColor.a = 1.0;//wc.a;\n#ifdef USE_FOAM\n\tgl_FragColor.rgb = mix(gl_FragColor.rgb,vec3(1.),foamc.a*foams);\n\tgl_FragColor.a = foamc.r;\n#endif\n\t//if(mod(vUv.x*100.,1.0)<0.02 || mod(vUv.y*100.,1.0)<0.02) gl_FragColor.rgb=vec3(0.5,.5,.5);\n\t//gl_FragColor.rgb = detailNorm;\n}\n",a=fn.add(u,e,t,n,i),qn.SHADERDEFINE_CUBE_ENV=a.registerMaterialDefine("CUBE_ENV"),qn.SHADERDEFINE_HDR_ENV=a.registerMaterialDefine("HDR_ENV"),qn.SHADERDEFINE_SHOW_NORMAL=a.registerMaterialDefine("SHOW_NORMAL"),qn.SHADERDEFINE_USEVERTEXHEIGHT=a.registerMaterialDefine("USE_VERTEX_DEEPINFO"),qn.SHADERDEFINE_USE_FOAM=a.registerMaterialDefine("USE_FOAM"),qn.SHADERDEFINE_USE_REFRACT_TEX=a.registerMaterialDefine("USE_REFR_TEX"),n={a_CornerTextureCoordinate:17,a_MeshPosition:0,a_MeshColor:1,a_MeshTextureCoordinate:2,a_ShapePositionStartLifeTime:30,a_DirectionTime:32,a_StartColor:19,a_EndColor:23,a_StartSize:20,a_StartRotation0:22,a_StartSpeed:31,a_Random0:34,a_Random1:35,a_SimulationWorldPostion:36,a_SimulationWorldRotation:37},i={u_Tintcolor:[2,1],u_TilingOffset:[3,1],u_texture:[1,1],u_WorldPosition:[0,2],u_WorldRotation:[1,2],u_PositionScale:[4,2],u_SizeScale:[5,2],u_ScalingMode:[6,2],u_Gravity:[7,2],u_ThreeDStartRotation:[8,2],u_StretchedBillboardLengthScale:[9,2],u_StretchedBillboardSpeedScale:[10,2],u_SimulationSpace:[11,2],u_CurrentTime:[12,2],u_ColorOverLifeGradientAlphas:[22,2],u_ColorOverLifeGradientColors:[23,2],u_MaxColorOverLifeGradientAlphas:[24,2],u_MaxColorOverLifeGradientColors:[25,2],u_VOLVelocityConst:[13,2],u_VOLVelocityGradientX:[14,2],u_VOLVelocityGradientY:[15,2],u_VOLVelocityGradientZ:[16,2],u_VOLVelocityConstMax:[17,2],u_VOLVelocityGradientMaxX:[18,2],u_VOLVelocityGradientMaxY:[19,2],u_VOLVelocityGradientMaxZ:[20,2],u_VOLSpaceType:[21,2],u_SOLSizeGradient:[26,2],u_SOLSizeGradientX:[27,2],u_SOLSizeGradientY:[28,2],u_SOLSizeGradientZ:[29,2],u_SOLSizeGradientMax:[30,2],u_SOLSizeGradientMaxX:[31,2],u_SOLSizeGradientMaxY:[32,2],u_SOLSizeGradientMaxZ:[33,2],u_ROLAngularVelocityConst:[34,2],u_ROLAngularVelocityConstSeprarate:[35,2],u_ROLAngularVelocityGradient:[36,2],u_ROLAngularVelocityGradientX:[37,2],u_ROLAngularVelocityGradientY:[38,2],u_ROLAngularVelocityGradientZ:[39,2],u_ROLAngularVelocityGradientW:[40,2],u_ROLAngularVelocityConstMax:[41,2],u_ROLAngularVelocityConstMaxSeprarate:[42,2],u_ROLAngularVelocityGradientMax:[43,2],u_ROLAngularVelocityGradientMaxX:[44,2],u_ROLAngularVelocityGradientMaxY:[45,2],u_ROLAngularVelocityGradientMaxZ:[46,2],u_ROLAngularVelocityGradientMaxW:[47,2],u_TSACycles:[48,2],u_TSASubUVLength:[49,2],u_TSAGradientUVs:[50,2],u_TSAMaxGradientUVs:[51,2],u_CameraPosition:[0,3],u_CameraDirection:[5,3],u_CameraUp:[6,3],u_View:[1,3],u_Projection:[2,3],u_FogStart:[1,4],u_FogRange:[2,4],u_FogColor:[0,4]};var c=Gn.nameKey.add("PARTICLESHURIKEN");e="#ifdef HIGHPRECISION\n  precision highp float;\n#else\n  precision mediump float;\n#endif\n\n#if defined(SPHERHBILLBOARD)||defined(STRETCHEDBILLBOARD)||defined(HORIZONTALBILLBOARD)||defined(VERTICALBILLBOARD)\n\tattribute vec4 a_CornerTextureCoordinate;\n#endif\n#ifdef RENDERMODE_MESH\n\tattribute vec3 a_MeshPosition;\n\tattribute vec4 a_MeshColor;\n\tattribute vec2 a_MeshTextureCoordinate;\n\tvarying vec4 v_MeshColor;\n#endif\n\nattribute vec4 a_ShapePositionStartLifeTime;\nattribute vec4 a_DirectionTime;\nattribute vec4 a_StartColor;\nattribute vec3 a_StartSize;\nattribute vec3 a_StartRotation0;\nattribute float a_StartSpeed;\n#if defined(COLOROVERLIFETIME)||defined(RANDOMCOLOROVERLIFETIME)||defined(SIZEOVERLIFETIMERANDOMCURVES)||defined(SIZEOVERLIFETIMERANDOMCURVESSEPERATE)||defined(ROTATIONOVERLIFETIMERANDOMCONSTANTS)||defined(ROTATIONOVERLIFETIMERANDOMCURVES)\n  attribute vec4 a_Random0;\n#endif\n#if defined(TEXTURESHEETANIMATIONRANDOMCURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\n  attribute vec4 a_Random1;\n#endif\nattribute vec3 a_SimulationWorldPostion;\nattribute vec4 a_SimulationWorldRotation;\n\nvarying float v_Discard;\nvarying vec4 v_Color;\n#ifdef DIFFUSEMAP\n\tvarying vec2 v_TextureCoordinate;\n#endif\n\nuniform float u_CurrentTime;\nuniform vec3 u_Gravity;\n\nuniform vec3 u_WorldPosition;\nuniform vec4 u_WorldRotation;\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\n#ifdef STRETCHEDBILLBOARD\n\tuniform vec3 u_CameraPosition;\n#endif\nuniform vec3 u_CameraDirection;//TODO:只有几种广告牌模式需要用\nuniform vec3 u_CameraUp;\n\nuniform  float u_StretchedBillboardLengthScale;\nuniform  float u_StretchedBillboardSpeedScale;\nuniform int u_SimulationSpace;\n\n#if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\n  uniform  int  u_VOLSpaceType;\n#endif\n#if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)\n  uniform  vec3 u_VOLVelocityConst;\n#endif\n#if defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\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#endif\n#ifdef VELOCITYOVERLIFETIMERANDOMCONSTANT\n  uniform  vec3 u_VOLVelocityConstMax;\n#endif\n#ifdef VELOCITYOVERLIFETIMERANDOMCURVE\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#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#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\n#if defined(SIZEOVERLIFETIMECURVE)||defined(SIZEOVERLIFETIMERANDOMCURVES)\n  uniform  vec2 u_SOLSizeGradient[4];//x为key,y为尺寸\n#endif\n#ifdef SIZEOVERLIFETIMERANDOMCURVES\n  uniform  vec2 u_SOLSizeGradientMax[4];//x为key,y为尺寸\n#endif\n#if defined(SIZEOVERLIFETIMECURVESEPERATE)||defined(SIZEOVERLIFETIMERANDOMCURVESSEPERATE)\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#endif\n#ifdef SIZEOVERLIFETIMERANDOMCURVESSEPERATE\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  #if defined(ROTATIONOVERLIFETIMECONSTANT)||defined(ROTATIONOVERLIFETIMERANDOMCONSTANTS)\n    uniform  float u_ROLAngularVelocityConst;\n  #endif\n  #ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\n    uniform  float u_ROLAngularVelocityConstMax;\n  #endif\n  #if defined(ROTATIONOVERLIFETIMECURVE)||defined(ROTATIONOVERLIFETIMERANDOMCURVES)\n    uniform  vec2 u_ROLAngularVelocityGradient[4];//x为key,y为旋转\n  #endif\n  #ifdef ROTATIONOVERLIFETIMERANDOMCURVES\n    uniform  vec2 u_ROLAngularVelocityGradientMax[4];//x为key,y为旋转\n  #endif\n#endif\n#ifdef ROTATIONOVERLIFETIMESEPERATE\n  #if defined(ROTATIONOVERLIFETIMECONSTANT)||defined(ROTATIONOVERLIFETIMERANDOMCONSTANTS)\n    uniform  vec3 u_ROLAngularVelocityConstSeprarate;\n  #endif\n  #ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\n    uniform  vec3 u_ROLAngularVelocityConstMaxSeprarate;\n  #endif\n  #if defined(ROTATIONOVERLIFETIMECURVE)||defined(ROTATIONOVERLIFETIMERANDOMCURVES)\n    uniform  vec2 u_ROLAngularVelocityGradientX[4];\n    uniform  vec2 u_ROLAngularVelocityGradientY[4];\n    uniform  vec2 u_ROLAngularVelocityGradientZ[4];\n\tuniform  vec2 u_ROLAngularVelocityGradientW[4];\n  #endif\n  #ifdef ROTATIONOVERLIFETIMERANDOMCURVES\n    uniform  vec2 u_ROLAngularVelocityGradientMaxX[4];\n    uniform  vec2 u_ROLAngularVelocityGradientMaxY[4];\n    uniform  vec2 u_ROLAngularVelocityGradientMaxZ[4];\n\tuniform  vec2 u_ROLAngularVelocityGradientMaxW[4];\n  #endif\n#endif\n\n#if defined(TEXTURESHEETANIMATIONCURVE)||defined(TEXTURESHEETANIMATIONRANDOMCURVE)\n  uniform  float u_TSACycles;\n  uniform  vec2 u_TSASubUVLength;\n  uniform  vec2 u_TSAGradientUVs[4];//x为key,y为frame\n#endif\n#ifdef TEXTURESHEETANIMATIONRANDOMCURVE\n  uniform  vec2 u_TSAMaxGradientUVs[4];//x为key,y为frame\n#endif\n\n#ifdef FOG\n\tvarying vec3 v_PositionWorld;\n#endif\n\n#ifdef TILINGOFFSET\n\tuniform vec4 u_TilingOffset;\n#endif\n\nvec3 rotationByEuler(in vec3 vector,in vec3 rot)\n{\n\tfloat halfRoll = rot.z * 0.5;\n    float halfPitch = rot.x * 0.5;\n\tfloat halfYaw = rot.y * 0.5;\n\n\tfloat sinRoll = sin(halfRoll);\n\tfloat cosRoll = cos(halfRoll);\n\tfloat sinPitch = sin(halfPitch);\n\tfloat cosPitch = cos(halfPitch);\n\tfloat sinYaw = sin(halfYaw);\n\tfloat cosYaw = cos(halfYaw);\n\n\tfloat quaX = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch * sinRoll);\n\tfloat quaY = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch * sinRoll);\n\tfloat quaZ = (cosYaw * cosPitch * sinRoll) - (sinYaw * sinPitch * cosRoll);\n\tfloat quaW = (cosYaw * cosPitch * cosRoll) + (sinYaw * sinPitch * sinRoll);\n\t\n\t//vec4 q=vec4(quaX,quaY,quaZ,quaW);\n\t//vec3 temp = cross(q.xyz, vector) + q.w * vector;\n\t//return (cross(temp, -q.xyz) + dot(q.xyz,vector) * q.xyz + q.w * temp);\n\t\n\tfloat x = quaX + quaX;\n    float y = quaY + quaY;\n    float z = quaZ + quaZ;\n    float wx = quaW * x;\n    float wy = quaW * y;\n    float wz = quaW * z;\n\tfloat xx = quaX * x;\n    float xy = quaX * y;\n\tfloat xz = quaX * z;\n    float yy = quaY * y;\n    float yz = quaY * z;\n    float zz = quaZ * z;\n\n    return vec3(((vector.x * ((1.0 - yy) - zz)) + (vector.y * (xy - wz))) + (vector.z * (xz + wy)),\n                ((vector.x * (xy + wz)) + (vector.y * ((1.0 - xx) - zz))) + (vector.z * (yz - wx)),\n                ((vector.x * (xz - wy)) + (vector.y * (yz + wx))) + (vector.z * ((1.0 - xx) - yy)));\n\t\n}\n\n//假定axis已经归一化\nvec3 rotationByAxis(in vec3 vector,in vec3 axis, in float angle)\n{\n\tfloat halfAngle = angle * 0.5;\n\tfloat sin = sin(halfAngle);\n\t\n\tfloat quaX = axis.x * sin;\n\tfloat quaY = axis.y * sin;\n\tfloat quaZ = axis.z * sin;\n\tfloat quaW = cos(halfAngle);\n\t\n\t//vec4 q=vec4(quaX,quaY,quaZ,quaW);\n\t//vec3 temp = cross(q.xyz, vector) + q.w * vector;\n\t//return (cross(temp, -q.xyz) + dot(q.xyz,vector) * q.xyz + q.w * temp);\n\t\n\tfloat x = quaX + quaX;\n    float y = quaY + quaY;\n    float z = quaZ + quaZ;\n    float wx = quaW * x;\n    float wy = quaW * y;\n    float wz = quaW * z;\n\tfloat xx = quaX * x;\n    float xy = quaX * y;\n\tfloat xz = quaX * z;\n    float yy = quaY * y;\n    float yz = quaY * z;\n    float zz = quaZ * z;\n\n    return vec3(((vector.x * ((1.0 - yy) - zz)) + (vector.y * (xy - wz))) + (vector.z * (xz + wy)),\n                ((vector.x * (xy + wz)) + (vector.y * ((1.0 - xx) - zz))) + (vector.z * (yz - wx)),\n                ((vector.x * (xz - wy)) + (vector.y * (yz + wx))) + (vector.z * ((1.0 - xx) - yy)));\n\t\n}\n\nvec3 rotationByQuaternions(in vec3 v,in vec4 q) \n{\n\treturn v + 2.0 * cross(q.xyz, cross(q.xyz, v) + q.w * v);\n}\n\n \n#if defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)||defined(SIZEOVERLIFETIMECURVE)||defined(SIZEOVERLIFETIMECURVESEPERATE)||defined(SIZEOVERLIFETIMERANDOMCURVES)||defined(SIZEOVERLIFETIMERANDOMCURVESSEPERATE)\nfloat getCurValueFromGradientFloat(in vec2 gradientNumbers[4],in float normalizedAge)\n{\n\tfloat curValue;\n\tfor(int i=1;i<4;i++)\n\t{\n\t\tvec2 gradientNumber=gradientNumbers[i];\n\t\tfloat key=gradientNumber.x;\n\t\tif(key>=normalizedAge)\n\t\t{\n\t\t\tvec2 lastGradientNumber=gradientNumbers[i-1];\n\t\t\tfloat lastKey=lastGradientNumber.x;\n\t\t\tfloat age=(normalizedAge-lastKey)/(key-lastKey);\n\t\t\tcurValue=mix(lastGradientNumber.y,gradientNumber.y,age);\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn curValue;\n}\n#endif\n\n#if defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)||defined(ROTATIONOVERLIFETIMECURVE)||defined(ROTATIONOVERLIFETIMERANDOMCURVES)\nfloat getTotalValueFromGradientFloat(in vec2 gradientNumbers[4],in float normalizedAge)\n{\n\tfloat totalValue=0.0;\n\tfor(int i=1;i<4;i++)\n\t{\n\t\tvec2 gradientNumber=gradientNumbers[i];\n\t\tfloat key=gradientNumber.x;\n\t\tvec2 lastGradientNumber=gradientNumbers[i-1];\n\t\tfloat lastValue=lastGradientNumber.y;\n\t\t\n\t\tif(key>=normalizedAge){\n\t\t\tfloat lastKey=lastGradientNumber.x;\n\t\t\tfloat age=(normalizedAge-lastKey)/(key-lastKey);\n\t\t\ttotalValue+=(lastValue+mix(lastValue,gradientNumber.y,age))/2.0*a_ShapePositionStartLifeTime.w*(normalizedAge-lastKey);\n\t\t\tbreak;\n\t\t}\n\t\telse{\n\t\t\ttotalValue+=(lastValue+gradientNumber.y)/2.0*a_ShapePositionStartLifeTime.w*(key-lastGradientNumber.x);\n\t\t}\n\t}\n\treturn totalValue;\n}\n#endif\n\n#if defined(COLOROVERLIFETIME)||defined(RANDOMCOLOROVERLIFETIME)\nvec4 getColorFromGradient(in vec2 gradientAlphas[4],in vec4 gradientColors[4],in float normalizedAge)\n{\n\tvec4 overTimeColor;\n\tfor(int i=1;i<4;i++)\n\t{\n\t\tvec2 gradientAlpha=gradientAlphas[i];\n\t\tfloat alphaKey=gradientAlpha.x;\n\t\tif(alphaKey>=normalizedAge)\n\t\t{\n\t\t\tvec2 lastGradientAlpha=gradientAlphas[i-1];\n\t\t\tfloat lastAlphaKey=lastGradientAlpha.x;\n\t\t\tfloat age=(normalizedAge-lastAlphaKey)/(alphaKey-lastAlphaKey);\n\t\t\toverTimeColor.a=mix(lastGradientAlpha.y,gradientAlpha.y,age);\n\t\t\tbreak;\n\t\t}\n\t}\n\t\n\tfor(int i=1;i<4;i++)\n\t{\n\t\tvec4 gradientColor=gradientColors[i];\n\t\tfloat colorKey=gradientColor.x;\n\t\tif(colorKey>=normalizedAge)\n\t\t{\n\t\t\tvec4 lastGradientColor=gradientColors[i-1];\n\t\t\tfloat lastColorKey=lastGradientColor.x;\n\t\t\tfloat age=(normalizedAge-lastColorKey)/(colorKey-lastColorKey);\n\t\t\toverTimeColor.rgb=mix(gradientColors[i-1].yzw,gradientColor.yzw,age);\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn overTimeColor;\n}\n#endif\n\n\n#if defined(TEXTURESHEETANIMATIONCURVE)||defined(TEXTURESHEETANIMATIONRANDOMCURVE)\nfloat getFrameFromGradient(in vec2 gradientFrames[4],in float normalizedAge)\n{\n\tfloat overTimeFrame;\n\tfor(int i=1;i<4;i++)\n\t{\n\t\tvec2 gradientFrame=gradientFrames[i];\n\t\tfloat key=gradientFrame.x;\n\t\tif(key>=normalizedAge)\n\t\t{\n\t\t\tvec2 lastGradientFrame=gradientFrames[i-1];\n\t\t\tfloat lastKey=lastGradientFrame.x;\n\t\t\tfloat age=(normalizedAge-lastKey)/(key-lastKey);\n\t\t\toverTimeFrame=mix(lastGradientFrame.y,gradientFrame.y,age);\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn floor(overTimeFrame);\n}\n#endif\n\n#if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\nvec3 computeParticleLifeVelocity(in float normalizedAge)\n{\n  vec3 outLifeVelocity;\n  #ifdef VELOCITYOVERLIFETIMECONSTANT\n\t outLifeVelocity=u_VOLVelocityConst; \n  #endif\n  #ifdef VELOCITYOVERLIFETIMECURVE\n     outLifeVelocity= vec3(getCurValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge));\n  #endif\n  #ifdef VELOCITYOVERLIFETIMERANDOMCONSTANT\n\t outLifeVelocity=mix(u_VOLVelocityConst,u_VOLVelocityConstMax,vec3(a_Random1.y,a_Random1.z,a_Random1.w)); \n  #endif\n  #ifdef VELOCITYOVERLIFETIMERANDOMCURVE\n     outLifeVelocity=vec3(mix(getCurValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientMaxX,normalizedAge),a_Random1.y),\n\t                 mix(getCurValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientMaxY,normalizedAge),a_Random1.z),\n\t\t\t\t\t mix(getCurValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientMaxZ,normalizedAge),a_Random1.w));\n  #endif\n\t\t\t\t\t\n  return outLifeVelocity;\n} \n#endif\n\nvec3 computeParticlePosition(in vec3 startVelocity, in vec3 lifeVelocity,in float age,in float normalizedAge,vec3 gravityVelocity,vec4 worldRotation)\n{\n   vec3 startPosition;\n   vec3 lifePosition;\n   #if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\n\t#ifdef VELOCITYOVERLIFETIMECONSTANT\n\t\t  startPosition=startVelocity*age;\n\t\t  lifePosition=lifeVelocity*age;\n\t#endif\n\t#ifdef VELOCITYOVERLIFETIMECURVE\n\t\t  startPosition=startVelocity*age;\n\t\t  lifePosition=vec3(getTotalValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge));\n\t#endif\n\t#ifdef VELOCITYOVERLIFETIMERANDOMCONSTANT\n\t\t  startPosition=startVelocity*age;\n\t\t  lifePosition=lifeVelocity*age;\n\t#endif\n\t#ifdef VELOCITYOVERLIFETIMERANDOMCURVE\n\t\t  startPosition=startVelocity*age;\n\t\t  lifePosition=vec3(mix(getTotalValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientMaxX,normalizedAge),a_Random1.y)\n\t      ,mix(getTotalValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientMaxY,normalizedAge),a_Random1.z)\n\t      ,mix(getTotalValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientMaxZ,normalizedAge),a_Random1.w));\n\t#endif\n\t\n\tvec3 finalPosition;\n\tif(u_VOLSpaceType==0){\n\t  if(u_ScalingMode!=2)\n\t   finalPosition =rotationByQuaternions(u_PositionScale*(a_ShapePositionStartLifeTime.xyz+startPosition+lifePosition),worldRotation);\n\t  else\n\t   finalPosition =rotationByQuaternions(u_PositionScale*a_ShapePositionStartLifeTime.xyz+startPosition+lifePosition,worldRotation);\n\t}\n\telse{\n\t  if(u_ScalingMode!=2)\n\t    finalPosition = rotationByQuaternions(u_PositionScale*(a_ShapePositionStartLifeTime.xyz+startPosition),worldRotation)+lifePosition;\n\t  else\n\t    finalPosition = rotationByQuaternions(u_PositionScale*a_ShapePositionStartLifeTime.xyz+startPosition,worldRotation)+lifePosition;\n\t}\n  #else\n\t startPosition=startVelocity*age;\n\t vec3 finalPosition;\n\t if(u_ScalingMode!=2)\n\t   finalPosition = rotationByQuaternions(u_PositionScale*(a_ShapePositionStartLifeTime.xyz+startPosition),worldRotation);\n\t else\n\t   finalPosition = rotationByQuaternions(u_PositionScale*a_ShapePositionStartLifeTime.xyz+startPosition,worldRotation);\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+=0.5*gravityVelocity*age;\n \n  return  finalPosition;\n}\n\n\nvec4 computeParticleColor(in vec4 color,in float normalizedAge)\n{\n\t#ifdef COLOROVERLIFETIME\n\t  color*=getColorFromGradient(u_ColorOverLifeGradientAlphas,u_ColorOverLifeGradientColors,normalizedAge);\n\t#endif\n\t\n\t#ifdef RANDOMCOLOROVERLIFETIME\n\t  color*=mix(getColorFromGradient(u_ColorOverLifeGradientAlphas,u_ColorOverLifeGradientColors,normalizedAge),getColorFromGradient(u_MaxColorOverLifeGradientAlphas,u_MaxColorOverLifeGradientColors,normalizedAge),a_Random0.y);\n\t#endif\n\n    return color;\n}\n\nvec2 computeParticleSizeBillbard(in vec2 size,in float normalizedAge)\n{\n\t#ifdef SIZEOVERLIFETIMECURVE\n\t\tsize*=getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge);\n\t#endif\n\t#ifdef SIZEOVERLIFETIMERANDOMCURVES\n\t    size*=mix(getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMax,normalizedAge),a_Random0.z); \n\t#endif\n\t#ifdef SIZEOVERLIFETIMECURVESEPERATE\n\t\tsize*=vec2(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge));\n\t#endif\n\t#ifdef SIZEOVERLIFETIMERANDOMCURVESSEPERATE\n\t    size*=vec2(mix(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxX,normalizedAge),a_Random0.z)\n\t    ,mix(getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxY,normalizedAge),a_Random0.z));\n\t#endif\n\treturn size;\n}\n\n#ifdef RENDERMODE_MESH\nvec3 computeParticleSizeMesh(in vec3 size,in float normalizedAge)\n{\n\t#ifdef SIZEOVERLIFETIMECURVE\n\t\tsize*=getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge);\n\t#endif\n\t#ifdef SIZEOVERLIFETIMERANDOMCURVES\n\t    size*=mix(getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMax,normalizedAge),a_Random0.z); \n\t#endif\n\t#ifdef SIZEOVERLIFETIMECURVESEPERATE\n\t\tsize*=vec3(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientZ,normalizedAge));\n\t#endif\n\t#ifdef SIZEOVERLIFETIMERANDOMCURVESSEPERATE\n\t    size*=vec3(mix(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxX,normalizedAge),a_Random0.z)\n\t    ,mix(getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxY,normalizedAge),a_Random0.z)\n\t\t,mix(getCurValueFromGradientFloat(u_SOLSizeGradientZ,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxZ,normalizedAge),a_Random0.z));\n\t#endif\n\treturn size;\n}\n#endif\n\nfloat computeParticleRotationFloat(in float rotation,in float age,in float normalizedAge)\n{ \n\t#ifdef ROTATIONOVERLIFETIME\n\t\t#ifdef ROTATIONOVERLIFETIMECONSTANT\n\t\t\tfloat ageRot=u_ROLAngularVelocityConst*age;\n\t        rotation+=ageRot;\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMECURVE\n\t\t\trotation+=getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge);\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\n\t\t\tfloat ageRot=mix(u_ROLAngularVelocityConst,u_ROLAngularVelocityConstMax,a_Random0.w)*age;\n\t        rotation+=ageRot;\n\t    #endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCURVES\n\t\t\trotation+=mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMax,normalizedAge),a_Random0.w);\n\t\t#endif\n\t#endif\n\t#ifdef ROTATIONOVERLIFETIMESEPERATE\n\t\t#ifdef ROTATIONOVERLIFETIMECONSTANT\n\t\t\tfloat ageRot=u_ROLAngularVelocityConstSeprarate.z*age;\n\t        rotation+=ageRot;\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMECURVE\n\t\t\trotation+=getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge);\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\n\t\t\tfloat ageRot=mix(u_ROLAngularVelocityConstSeprarate.z,u_ROLAngularVelocityConstMaxSeprarate.z,a_Random0.w)*age;\n\t        rotation+=ageRot;\n\t    #endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCURVES\n\t\t\trotation+=mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxZ,normalizedAge),a_Random0.w));\n\t\t#endif\n\t#endif\n\treturn rotation;\n}\n\n\n#if defined(RENDERMODE_MESH)&&(defined(ROTATIONOVERLIFETIME)||defined(ROTATIONOVERLIFETIMESEPERATE))\nvec3 computeParticleRotationVec3(in vec3 rotation,in float age,in float normalizedAge)\n{ \n\t#ifdef ROTATIONOVERLIFETIME\n\t#ifdef ROTATIONOVERLIFETIMECONSTANT\n\t\t\tfloat ageRot=u_ROLAngularVelocityConst*age;\n\t        rotation+=ageRot;\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMECURVE\n\t\t\trotation+=getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge);\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\n\t\t\tfloat ageRot=mix(u_ROLAngularVelocityConst,u_ROLAngularVelocityConstMax,a_Random0.w)*age;\n\t        rotation+=ageRot;\n\t    #endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCURVES\n\t\t\trotation+=mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMax,normalizedAge),a_Random0.w);\n\t\t#endif\n\t#endif\n\t#ifdef ROTATIONOVERLIFETIMESEPERATE\n\t#ifdef ROTATIONOVERLIFETIMECONSTANT\n\t\t\tvec3 ageRot=u_ROLAngularVelocityConstSeprarate*age;\n\t        rotation+=ageRot;\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMECURVE\n\t\t\trotation+=vec3(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge));\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\n\t\t\tvec3 ageRot=mix(u_ROLAngularVelocityConstSeprarate,u_ROLAngularVelocityConstMaxSeprarate,a_Random0.w)*age;\n\t        rotation+=ageRot;\n\t    #endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCURVES\n\t\t\trotation+=vec3(mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxX,normalizedAge),a_Random0.w)\n\t        ,mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxY,normalizedAge),a_Random0.w)\n\t        ,mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxZ,normalizedAge),a_Random0.w));\n\t\t#endif\n\t#endif\n\treturn rotation;\n}\n#endif\n\nvec2 computeParticleUV(in vec2 uv,in float normalizedAge)\n{ \n\t#ifdef TEXTURESHEETANIMATIONCURVE\n\t\tfloat cycleNormalizedAge=normalizedAge*u_TSACycles;\n\t\tfloat frame=getFrameFromGradient(u_TSAGradientUVs,cycleNormalizedAge-floor(cycleNormalizedAge));\n\t\tfloat totalULength=frame*u_TSASubUVLength.x;\n\t\tfloat floorTotalULength=floor(totalULength);\n\t    uv.x+=totalULength-floorTotalULength;\n\t\tuv.y+=floorTotalULength*u_TSASubUVLength.y;\n    #endif\n\t#ifdef TEXTURESHEETANIMATIONRANDOMCURVE\n\t\tfloat cycleNormalizedAge=normalizedAge*u_TSACycles;\n\t\tfloat uvNormalizedAge=cycleNormalizedAge-floor(cycleNormalizedAge);\n\t    float frame=floor(mix(getFrameFromGradient(u_TSAGradientUVs,uvNormalizedAge),getFrameFromGradient(u_TSAMaxGradientUVs,uvNormalizedAge),a_Random1.x));\n\t\tfloat totalULength=frame*u_TSASubUVLength.x;\n\t\tfloat floorTotalULength=floor(totalULength);\n\t    uv.x+=totalULength-floorTotalULength;\n\t\tuv.y+=floorTotalULength*u_TSASubUVLength.y;\n    #endif\n\treturn uv;\n}\n\nvoid main()\n{\n\tfloat age = u_CurrentTime - a_DirectionTime.w;\n\tfloat normalizedAge = age/a_ShapePositionStartLifeTime.w;\n\tvec3 lifeVelocity;\n\tif(normalizedAge<1.0){ \n\tvec3 startVelocity=a_DirectionTime.xyz*a_StartSpeed;\n\t#if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\n\t\tlifeVelocity= computeParticleLifeVelocity(normalizedAge);//计算粒子生命周期速度\n\t#endif \n\tvec3 gravityVelocity=u_Gravity*age;\n\t\n\tvec4 worldRotation;\n\tif(u_SimulationSpace==0)\n\t\tworldRotation=a_SimulationWorldRotation;\n\telse\n\t\tworldRotation=u_WorldRotation;\n\t\n\tvec3 center=computeParticlePosition(startVelocity, lifeVelocity, age, normalizedAge,gravityVelocity,worldRotation);//计算粒子位置\n   \n   \n   #ifdef SPHERHBILLBOARD\n\t\tvec2 corner=a_CornerTextureCoordinate.xy;//Billboard模式z轴无效\n        vec3 cameraUpVector =normalize(u_CameraUp);//TODO:是否外面归一化\n        vec3 sideVector = normalize(cross(u_CameraDirection,cameraUpVector));\n        vec3 upVector = normalize(cross(sideVector,u_CameraDirection));\n\t    corner*=computeParticleSizeBillbard(a_StartSize.xy,normalizedAge);\n\t\t#if defined(ROTATIONOVERLIFETIME)||defined(ROTATIONOVERLIFETIMESEPERATE)\n\t\t\tif(u_ThreeDStartRotation){\n\t\t\t\tvec3 rotation=vec3(a_StartRotation0.xy,computeParticleRotationFloat(a_StartRotation0.z,age,normalizedAge));\n\t\t\t\tcenter += u_SizeScale.xzy*rotationByEuler(corner.x*sideVector+corner.y*upVector,rotation);\n\t\t\t}\n\t\t\telse{\n\t\t\t\tfloat rot = computeParticleRotationFloat(a_StartRotation0.x, age,normalizedAge);\n\t\t\t\tfloat c = cos(rot);\n\t\t\t\tfloat s = sin(rot);\n\t\t\t\tmat2 rotation= mat2(c, -s, s, c);\n\t\t\t\tcorner=rotation*corner;\n\t\t\t\tcenter += u_SizeScale.xzy*(corner.x*sideVector+corner.y*upVector);\n\t\t\t}\n\t\t#else\n\t\t\tif(u_ThreeDStartRotation){\n\t\t\t\tcenter += u_SizeScale.xzy*rotationByEuler(corner.x*sideVector+corner.y*upVector,a_StartRotation0);\n\t\t\t}\n\t\t\telse{\n\t\t\t\tfloat c = cos(a_StartRotation0.x);\n\t\t\t\tfloat s = sin(a_StartRotation0.x);\n\t\t\t\tmat2 rotation= mat2(c, -s, s, c);\n\t\t\t\tcorner=rotation*corner;\n\t\t\t\tcenter += u_SizeScale.xzy*(corner.x*sideVector+corner.y*upVector);\n\t\t\t}\n\t\t#endif\n   #endif\n   \n   #ifdef STRETCHEDBILLBOARD\n\tvec2 corner=a_CornerTextureCoordinate.xy;//Billboard模式z轴无效\n\tvec3 velocity;\n\t#if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\n\t    if(u_VOLSpaceType==0)\n\t\t  velocity=rotationByQuaternions(u_SizeScale*(startVelocity+lifeVelocity),worldRotation)+gravityVelocity;\n\t    else\n\t\t  velocity=rotationByQuaternions(u_SizeScale*startVelocity,worldRotation)+lifeVelocity+gravityVelocity;\n    #else\n\t    velocity= rotationByQuaternions(u_SizeScale*startVelocity,worldRotation)+gravityVelocity;\n    #endif\t\n\t\tvec3 cameraUpVector = normalize(velocity);\n\t\tvec3 direction = normalize(center-u_CameraPosition);\n        vec3 sideVector = normalize(cross(direction,normalize(velocity)));\n\t\t\n\t\tsideVector=u_SizeScale.xzy*sideVector;\n\t\tcameraUpVector=length(vec3(u_SizeScale.x,0.0,0.0))*cameraUpVector;\n\t\t\n\t    vec2 size=computeParticleSizeBillbard(a_StartSize.xy,normalizedAge);\n\t\t\n\t    const mat2 rotaionZHalfPI=mat2(0.0, -1.0, 1.0, 0.0);\n\t    corner=rotaionZHalfPI*corner;\n\t    corner.y=corner.y-abs(corner.y);\n\t\t\n\t    float speed=length(velocity);//TODO:\n\t    center +=sign(u_SizeScale.x)*(sign(u_StretchedBillboardLengthScale)*size.x*corner.x*sideVector+(speed*u_StretchedBillboardSpeedScale+size.y*u_StretchedBillboardLengthScale)*corner.y*cameraUpVector);\n   #endif\n   \n   #ifdef HORIZONTALBILLBOARD\n\t\tvec2 corner=a_CornerTextureCoordinate.xy;//Billboard模式z轴无效\n        const vec3 cameraUpVector=vec3(0.0,0.0,1.0);\n\t    const vec3 sideVector = vec3(-1.0,0.0,0.0);\n\t\t\n\t\tfloat rot = computeParticleRotationFloat(a_StartRotation0.x, age,normalizedAge);\n        float c = cos(rot);\n        float s = sin(rot);\n        mat2 rotation= mat2(c, -s, s, c);\n\t    corner=rotation*corner*cos(0.78539816339744830961566084581988);//TODO:临时缩小cos45,不确定U3D原因\n\t\tcorner*=computeParticleSizeBillbard(a_StartSize.xy,normalizedAge);\n        center +=u_SizeScale.xzy*(corner.x*sideVector+ corner.y*cameraUpVector);\n   #endif\n   \n   #ifdef VERTICALBILLBOARD\n\t\tvec2 corner=a_CornerTextureCoordinate.xy;//Billboard模式z轴无效\n        const vec3 cameraUpVector =vec3(0.0,1.0,0.0);\n        vec3 sideVector = normalize(cross(u_CameraDirection,cameraUpVector));\n\t\t\n\t\tfloat rot = computeParticleRotationFloat(a_StartRotation0.x, age,normalizedAge);\n        float c = cos(rot);\n        float s = sin(rot);\n        mat2 rotation= mat2(c, -s, s, c);\n\t    corner=rotation*corner*cos(0.78539816339744830961566084581988);//TODO:临时缩小cos45,不确定U3D原因\n\t\tcorner*=computeParticleSizeBillbard(a_StartSize.xy,normalizedAge);\n        center +=u_SizeScale.xzy*(corner.x*sideVector+ corner.y*cameraUpVector);\n   #endif\n   \n   #ifdef RENDERMODE_MESH\n\t    vec3 size=computeParticleSizeMesh(a_StartSize,normalizedAge);\n\t\t#if defined(ROTATIONOVERLIFETIME)||defined(ROTATIONOVERLIFETIMESEPERATE)\n\t\t\tif(u_ThreeDStartRotation){\n\t\t\t\tvec3 rotation=vec3(a_StartRotation0.xy,-computeParticleRotationFloat(a_StartRotation0.z, age,normalizedAge));\n\t\t\t\tcenter+= rotationByQuaternions(u_SizeScale*rotationByEuler(a_MeshPosition*size,rotation),worldRotation);\n\t\t\t}\n\t\t\telse{\n\t\t\t\t#ifdef ROTATIONOVERLIFETIME\n\t\t\t\t\tfloat angle=computeParticleRotationFloat(a_StartRotation0.x, age,normalizedAge);\n\t\t\t\t\tif(a_ShapePositionStartLifeTime.x!=0.0||a_ShapePositionStartLifeTime.y!=0.0){\n\t\t\t\t\t\tcenter+= (rotationByQuaternions(rotationByAxis(u_SizeScale*a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),angle),worldRotation));//已验证\n\t\t\t\t\t}\n\t\t\t\t\telse{\n\t\t\t\t\t\t#ifdef SHAPE\n\t\t\t\t\t\t\tcenter+= u_SizeScale.xzy*(rotationByQuaternions(rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),angle),worldRotation));\n\t\t\t\t\t\t#else\n\t\t\t\t\t\t\tif(u_SimulationSpace==0)\n\t\t\t\t\t\t\t\tcenter+=rotationByAxis(u_SizeScale*a_MeshPosition*size,vec3(0.0,0.0,-1.0),angle);//已验证\n\t\t\t\t\t\t\telse if(u_SimulationSpace==1)\n\t\t\t\t\t\t\t\tcenter+=rotationByQuaternions(u_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,0.0,-1.0),angle),worldRotation);//已验证\n\t\t\t\t\t\t#endif\n\t\t\t\t\t}\n\t\t\t\t#endif\n\t\t\t\t#ifdef ROTATIONOVERLIFETIMESEPERATE\n\t\t\t\t\t//TODO:是否应合并if(u_ThreeDStartRotation)分支代码,待测试\n\t\t\t\t\tvec3 angle=computeParticleRotationVec3(vec3(0.0,0.0,a_StartRotation0.z), age,normalizedAge);\n\t\t\t\t\tcenter+= (rotationByQuaternions(rotationByEuler(u_SizeScale*a_MeshPosition*size,vec3(angle.x,angle.y,angle.z)),worldRotation));//已验证\n\t\t\t\t#endif\t\n\t\t\t}\n\t\t#else\n\t\t\tif(u_ThreeDStartRotation){\n\t\t\t\tcenter+= rotationByQuaternions(u_SizeScale*rotationByEuler(a_MeshPosition*size,a_StartRotation0),worldRotation);//已验证\n\t\t\t}\n\t\t\telse{\n\t\t\t\tif(a_ShapePositionStartLifeTime.x!=0.0||a_ShapePositionStartLifeTime.y!=0.0){\n\t\t\t\t\tif(u_SimulationSpace==0)\n\t\t\t\t\t\tcenter+= rotationByAxis(u_SizeScale*a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),a_StartRotation0.x);\n\t\t\t\t\telse if(u_SimulationSpace==1)\n\t\t\t\t\t\tcenter+= (rotationByQuaternions(u_SizeScale*rotationByAxis(a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),a_StartRotation0.x),worldRotation));//已验证\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\t#ifdef SHAPE\n\t\t\t\t\t\tif(u_SimulationSpace==0)\n\t\t\t\t\t\t\tcenter+= u_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),a_StartRotation0.x);\n\t\t\t\t\t\telse if(u_SimulationSpace==1)\n\t\t\t\t\t\t\tcenter+= rotationByQuaternions(u_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),a_StartRotation0.x),worldRotation);\t\n\t\t\t\t\t#else\n\t\t\t\t\t\tif(u_SimulationSpace==0)\n\t\t\t\t\t\t\tcenter+= rotationByAxis(u_SizeScale*a_MeshPosition*size,vec3(0.0,0.0,-1.0),a_StartRotation0.x);\n\t\t\t\t\t\telse if(u_SimulationSpace==1)\n\t\t\t\t\t\t\tcenter+= rotationByQuaternions(u_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,0.0,-1.0),a_StartRotation0.x),worldRotation);//已验证\n\t\t\t\t\t#endif\n\t\t\t\t}\n\t\t\t}\n\t\t#endif\n\t\tv_MeshColor=a_MeshColor;\n   #endif\n   \n    gl_Position=u_Projection*u_View*vec4(center,1.0);\n    v_Color = computeParticleColor(a_StartColor, normalizedAge);\n\t#ifdef DIFFUSEMAP\n\t\t#if defined(SPHERHBILLBOARD)||defined(STRETCHEDBILLBOARD)||defined(HORIZONTALBILLBOARD)||defined(VERTICALBILLBOARD)\n\t\t\tv_TextureCoordinate =computeParticleUV(a_CornerTextureCoordinate.zw, normalizedAge);\n\t\t#endif\n\t\t#ifdef RENDERMODE_MESH\n\t\t\tv_TextureCoordinate =computeParticleUV(a_MeshTextureCoordinate, normalizedAge);\n\t\t#endif\n\t\t\n\t\t#ifdef TILINGOFFSET\n\t\t\tv_TextureCoordinate=vec2(v_TextureCoordinate.x,1.0-v_TextureCoordinate.y)*u_TilingOffset.xy+vec2(u_TilingOffset.z,-u_TilingOffset.w);//需要特殊处理\n\t\t\tv_TextureCoordinate=vec2(v_TextureCoordinate.x,1.0-v_TextureCoordinate.y);//需要特殊处理\n\t\t#endif\n\t#endif\n    v_Discard=0.0;\n\t  \n\t#ifdef FOG\n\t\tv_PositionWorld=center;\n\t#endif\n   }\n   else\n\t{\n\t\tv_Discard=1.0;\n\t}\n}\n\n",t="#ifdef HIGHPRECISION\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;\nuniform vec4 u_Tintcolor;\n\n#ifdef RENDERMODE_MESH\n\tvarying vec4 v_MeshColor;\n#endif\n\n#ifdef FOG\n\tvarying vec3 v_PositionWorld;\n\tuniform vec3 u_CameraPosition;\n\tuniform float u_FogStart;\n\tuniform float u_FogRange;\n\t#ifdef ADDTIVEFOG\n\t#else\n\t\tuniform vec3 u_FogColor;\n\t#endif\n#endif\n\n\nvoid main()\n{\t\n\t#ifdef RENDERMODE_MESH\n\t\tgl_FragColor=v_MeshColor;\n\t#else\n\t\tgl_FragColor=vec4(1.0);\t\n\t#endif\n\t\t\n\t#ifdef DIFFUSEMAP\n\t\tif(v_Discard!=0.0)\n\t\t\tdiscard;\n\t\t#ifdef TINTCOLOR\n\t\t\tgl_FragColor*=texture2D(u_texture,v_TextureCoordinate)*u_Tintcolor*2.0*v_Color;\n\t\t#else\n\t\t\tgl_FragColor*=texture2D(u_texture,v_TextureCoordinate)*v_Color;\n\t\t#endif\n\t#else\n\t\t#ifdef TINTCOLOR\n\t\t\tgl_FragColor*=u_Tintcolor*2.0*v_Color;\n\t\t#else\n\t\t\tgl_FragColor*=v_Color;\n\t\t#endif\n\t#endif\n\t\n\t#ifdef FOG\n\t\tvec3 toEye=u_CameraPosition-v_PositionWorld;\n\t\tfloat toEyeLength=length(toEye);\n\t\ttoEye/=toEyeLength;\n\t\t\n\t\tfloat lerpFact=clamp((toEyeLength-u_FogStart)/u_FogRange,0.0,1.0);\n\t\t#ifdef ADDTIVEFOG\n\t\t\tgl_FragColor.rgb=mix(gl_FragColor.rgb,vec3(0.0,0.0,0.0),lerpFact);\n\t\t#else\n\t\t\tgl_FragColor.rgb=mix(gl_FragColor.rgb,u_FogColor,lerpFact);\n\t\t#endif\n\t#endif\n}",a=fn.add(c,e,t,n,i),Jn.SHADERDEFINE_DIFFUSEMAP=a.registerMaterialDefine("DIFFUSEMAP"),Jn.SHADERDEFINE_TINTCOLOR=a.registerMaterialDefine("TINTCOLOR"),Jn.SHADERDEFINE_ADDTIVEFOG=a.registerMaterialDefine("ADDTIVEFOG"),Jn.SHADERDEFINE_TILINGOFFSET=a.registerMaterialDefine("TILINGOFFSET"),Ti.SHADERDEFINE_RENDERMODE_BILLBOARD=a.registerSpriteDefine("SPHERHBILLBOARD"),Ti.SHADERDEFINE_RENDERMODE_STRETCHEDBILLBOARD=a.registerSpriteDefine("STRETCHEDBILLBOARD"),Ti.SHADERDEFINE_RENDERMODE_HORIZONTALBILLBOARD=a.registerSpriteDefine("HORIZONTALBILLBOARD"),Ti.SHADERDEFINE_RENDERMODE_VERTICALBILLBOARD=a.registerSpriteDefine("VERTICALBILLBOARD"),Ti.SHADERDEFINE_COLOROVERLIFETIME=a.registerSpriteDefine("COLOROVERLIFETIME"),Ti.SHADERDEFINE_RANDOMCOLOROVERLIFETIME=a.registerSpriteDefine("RANDOMCOLOROVERLIFETIME"),Ti.SHADERDEFINE_VELOCITYOVERLIFETIMECONSTANT=a.registerSpriteDefine("VELOCITYOVERLIFETIMECONSTANT"),Ti.SHADERDEFINE_VELOCITYOVERLIFETIMECURVE=a.registerSpriteDefine("VELOCITYOVERLIFETIMECURVE"),Ti.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCONSTANT=a.registerSpriteDefine("VELOCITYOVERLIFETIMERANDOMCONSTANT"),Ti.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCURVE=a.registerSpriteDefine("VELOCITYOVERLIFETIMERANDOMCURVE"),Ti.SHADERDEFINE_TEXTURESHEETANIMATIONCURVE=a.registerSpriteDefine("TEXTURESHEETANIMATIONCURVE"),Ti.SHADERDEFINE_TEXTURESHEETANIMATIONRANDOMCURVE=a.registerSpriteDefine("TEXTURESHEETANIMATIONRANDOMCURVE"),Ti.SHADERDEFINE_ROTATIONOVERLIFETIME=a.registerSpriteDefine("ROTATIONOVERLIFETIME"),Ti.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE=a.registerSpriteDefine("ROTATIONOVERLIFETIMESEPERATE"),Ti.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT=a.registerSpriteDefine("ROTATIONOVERLIFETIMECONSTANT"),Ti.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE=a.registerSpriteDefine("ROTATIONOVERLIFETIMECURVE"),Ti.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS=a.registerSpriteDefine("ROTATIONOVERLIFETIMERANDOMCONSTANTS"),Ti.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCURVES=a.registerSpriteDefine("ROTATIONOVERLIFETIMERANDOMCURVES"),Ti.SHADERDEFINE_SIZEOVERLIFETIMECURVE=a.registerSpriteDefine("SIZEOVERLIFETIMECURVE"),Ti.SHADERDEFINE_SIZEOVERLIFETIMECURVESEPERATE=a.registerSpriteDefine("SIZEOVERLIFETIMECURVESEPERATE"),Ti.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVES=a.registerSpriteDefine("SIZEOVERLIFETIMERANDOMCURVES"),Ti.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVESSEPERATE=a.registerSpriteDefine("SIZEOVERLIFETIMERANDOMCURVESSEPERATE"),Ti.SHADERDEFINE_RENDERMODE_MESH=a.registerSpriteDefine("RENDERMODE_MESH"),Ti.SHADERDEFINE_SHAPE=a.registerSpriteDefine("SHAPE"),n={a_Position:0,a_Texcoord0:2,a_Time:33},i={u_Texture:[1,1],u_Albedo:[2,1],u_Color:[3,1],u_CurrentTime:[2,2],u_Duration:[3,2],u_MvpMatrix:[1,2]};var d=Gn.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 HIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision 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{\t\n  gl_FragColor=texture2D(u_Texture, v_Texcoord)*v_Color;\n  gl_FragColor=gl_FragColor*u_Albedo;\n}\n\n",a=fn.add(d,e,t,n,i),n={a_Position:0},i={u_Intensity:[1,1],u_AlphaBlending:[2,1],u_CubeTexture:[3,1],u_MvpMatrix:[4,3]};var f=Gn.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 HIGHPRECISION\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{\t\n  gl_FragColor=vec4(textureCube(u_CubeTexture, v_Texcoord).rgb*u_Intensity,u_AlphaBlending);\n}\n\n",fn.add(f,e,t,n,i),n={a_Position:0,a_Texcoord0:2},i={u_Intensity:[1,1],u_AlphaBlending:[2,1],u_texture:[3,1],u_MvpMatrix:[4,3]};var m=Gn.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 HIGHPRECISION\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{\t\n  gl_FragColor=vec4(texture2D(u_texture, v_Texcoord).rgb*u_Intensity,u_AlphaBlending);\n}\n\n",fn.add(m,e,t,n,i),n={a_Position:0,a_Normal:3,a_Texcoord0:2,a_Texcoord1:15},i={u_MvpMatrix:[1,2],u_WorldMat:[0,2],u_LightmapScaleOffset:[2,2],u_LightMap:[3,2],u_SplatAlphaTexture:[0,1],u_NormalTexture:[1,1],u_DiffuseTexture1:[2,1],u_DiffuseTexture2:[3,1],u_DiffuseTexture3:[4,1],u_DiffuseTexture4:[5,1],u_DiffuseScale1:[6,1],u_DiffuseScale2:[7,1],u_DiffuseScale3:[8,1],u_DiffuseScale4:[9,1],u_MaterialDiffuse:[11,1],u_MaterialAmbient:[10,1],u_MaterialSpecular:[12,1],u_CameraPos:[0,3],u_FogStart:[1,4],u_FogRange:[2,4],u_FogColor:[0,4],"u_DirectionLight.Direction":[3,4],"u_DirectionLight.Diffuse":[4,4],"u_PointLight.Position":[5,4],"u_PointLight.Range":[6,4],"u_PointLight.Attenuation":[7,4],"u_PointLight.Diffuse":[8,4],"u_SpotLight.Position":[9,4],"u_SpotLight.Direction":[10,4],"u_SpotLight.Range":[12,4],"u_SpotLight.Spot":[11,4],"u_SpotLight.Attenuation":[13,4],"u_SpotLight.Diffuse":[14,4],u_AmbientColor:[21,4],u_shadowMap1:[18,4],u_shadowMap2:[19,4],u_shadowMap3:[20,4],u_shadowPSSMDistance:[15,4],u_lightShadowVP:[16,4],u_shadowPCFoffset:[17,4]};var p=Gn.nameKey.add("Terrain");e="attribute vec4 a_Position;\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(LIGHTMAP)\n\tattribute vec3 a_Normal;\n\tvarying vec3 v_Normal;\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||(defined(RECEIVESHADOW)&&defined(SHADOWMAP_PSSM1))\n\tuniform mat4 u_WorldMat;\n\tvarying vec3 v_PositionWorld;\n#endif\n\nvarying float v_posViewZ;\n#ifdef RECEIVESHADOW\n  #ifdef SHADOWMAP_PSSM1 \n  varying vec4 v_lightMVPPos;\n  uniform mat4 u_lightShadowVP[4];\n  #endif\n#endif\n\n#ifdef LIGHTMAP\n\tuniform vec4 u_LightmapScaleOffset;\n\tvarying vec2 v_LightMapUV;\n#endif\n\nattribute vec2 a_Texcoord0;\nattribute vec2 a_Texcoord1;\nvarying vec2 v_Texcoord0;\nvarying vec2 v_Texcoord1;\nuniform mat4 u_MvpMatrix;\n\nvoid main()\n{\n\tgl_Position = u_MvpMatrix * a_Position;\n\tv_Texcoord0=a_Texcoord0;\n\tv_Texcoord1=a_Texcoord1;\n\t\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n\tv_Normal=a_Normal;\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||(defined(RECEIVESHADOW)&&defined(SHADOWMAP_PSSM1))\n\tv_PositionWorld=(u_WorldMat*a_Position).xyz;\n#endif\n\n#ifdef LIGHTMAP\n\t//这个地方使用a_Normal 并不是真的代表normal，其实凑巧法线图的uv正好是符合 light_Map的UV\n\tv_LightMapUV=vec2(a_Normal.x*u_LightmapScaleOffset.x+u_LightmapScaleOffset.z,(a_Normal.y-1.0)*u_LightmapScaleOffset.y+u_LightmapScaleOffset.w);\n#endif\n\n#ifdef RECEIVESHADOW\n\tv_posViewZ = gl_Position.w;\n\t#ifdef SHADOWMAP_PSSM1\n\t\tv_lightMVPPos = u_lightShadowVP[0] * vec4(v_PositionWorld,1.0);\n\t#endif\n#endif\n\n}",t='#ifdef HIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\n#include "LightHelper.glsl";\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n\tuniform vec3 u_MaterialDiffuse;\n\tuniform vec4 u_MaterialSpecular;\n\tuniform vec3 u_CameraPos;\n\tvarying vec3 v_Normal;\n\tvarying vec3 v_PositionWorld;\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(LIGHTMAP)\n\tuniform vec3 u_MaterialAmbient;\n#endif\n\n#ifdef FOG\n\tuniform float u_FogStart;\n\tuniform float u_FogRange;\n\tuniform vec3 u_FogColor;\n#endif\n\n\n#ifdef DIRECTIONLIGHT\n\tuniform DirectionLight u_DirectionLight;\n#endif\n\n#ifdef POINTLIGHT\n\tuniform PointLight u_PointLight;\n#endif\n\n#ifdef SPOTLIGHT\n\tuniform SpotLight u_SpotLight;\n#endif\n\nuniform vec3 u_AmbientColor;\n\n#include "ShadowHelper.glsl"\n#ifdef RECEIVESHADOW\n\t#if defined(SHADOWMAP_PSSM2)||defined(SHADOWMAP_PSSM3)\n\tuniform mat4 u_lightShadowVP[4];\n\t#endif\n\t#ifdef SHADOWMAP_PSSM1 \n\tvarying vec4 v_lightMVPPos;\n\t#endif\n#endif\nvarying float v_posViewZ;\n\n\nuniform sampler2D u_SplatAlphaTexture;\nuniform sampler2D u_NormalTexture;\nuniform sampler2D u_DiffuseTexture1;\nuniform sampler2D u_DiffuseTexture2;\nuniform sampler2D u_DiffuseTexture3;\nuniform sampler2D u_DiffuseTexture4;\nuniform vec2 u_DiffuseScale1;\nuniform vec2 u_DiffuseScale2;\nuniform vec2 u_DiffuseScale3;\nuniform vec2 u_DiffuseScale4;\nvarying vec2 v_Texcoord0;\nvarying vec2 v_Texcoord1;\n\n#ifdef LIGHTMAP\n\tuniform sampler2D u_LightMap;\n\tvarying vec2 v_LightMapUV;\n#endif\n\nvoid main()\n{\n#ifdef DETAIL_NUM1\n\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord1/u_DiffuseScale1);\n\tvec4 splatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\n\tgl_FragColor.xyz = color1.xyz;\n#endif\n#ifdef DETAIL_NUM2\n\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord1/u_DiffuseScale1);\n\tvec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord1/u_DiffuseScale2);\n\tvec4 splatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\n\tgl_FragColor.xyz = color1.xyz * (1.0-splatAlpha.r) + color2.xyz * splatAlpha.r;\n#endif\n#ifdef DETAIL_NUM3\n\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord1/u_DiffuseScale1);\n\tvec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord1/u_DiffuseScale2);\n\tvec4 color3 = texture2D(u_DiffuseTexture3, v_Texcoord1/u_DiffuseScale3);\n\tvec4 splatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\n\tgl_FragColor.xyz = color1.xyz * (1.0-(splatAlpha.r+splatAlpha.g)) + color2.xyz * splatAlpha.r + color3.xyz * splatAlpha.g;\n#endif\n#ifdef DETAIL_NUM4\n\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord1/u_DiffuseScale1);\n\tvec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord1/u_DiffuseScale2);\n\tvec4 color3 = texture2D(u_DiffuseTexture3, v_Texcoord1/u_DiffuseScale3);\n\tvec4 color4 = texture2D(u_DiffuseTexture4, v_Texcoord1/u_DiffuseScale4);\n\tvec4 splatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\n\tgl_FragColor.xyz = color1.xyz * (1.0-(splatAlpha.r+splatAlpha.g+splatAlpha.b))+ color2.xyz * splatAlpha.r + color3.xyz * splatAlpha.g + color4.xyz * splatAlpha.b;\n#endif\n\tgl_FragColor.w = splatAlpha.a;\n\t\t\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n    vec3 normal = texture2D(u_NormalTexture,v_Normal.xy).xyz;\n\tnormal = normal*2.0 - vec3(1.0);\n\tvec3 diffuse = vec3(0.0);\n\tvec3 ambient = vec3(0.0);\n\tvec3 specular= vec3(0.0);\n\tvec3 dif, amb, spe;\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)\n\tvec3 toEye;\n\t#ifdef FOG\n\t\ttoEye=u_CameraPos-v_PositionWorld;\n\t\tfloat toEyeLength=length(toEye);\n\t\ttoEye/=toEyeLength;\n\t#else\n\t\ttoEye=normalize(u_CameraPos-v_PositionWorld);\n\t#endif\n#endif\n\n#ifdef DIRECTIONLIGHT\n\tcomputeDirectionLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_DirectionLight,u_AmbientColor,normal,toEye, dif, amb, spe);\n\tdiffuse+=dif;\n\tambient+=amb;\n\tspecular+=spe;\n#endif\n \n#ifdef POINTLIGHT\n\tcomputePointLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_PointLight,u_AmbientColor,v_PositionWorld,normal,toEye, dif, amb, spe);\n\tdiffuse+=dif;\n\tambient+=amb;\n\tspecular+=spe;\n#endif\n\n#ifdef SPOTLIGHT\n\tComputeSpotLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_SpotLight,u_AmbientColor,v_PositionWorld,normal,toEye, dif, amb, spe);\n\tdiffuse+=dif;\n\tambient+=amb;\n\tspecular+=spe;\n#endif\n\n#ifdef RECEIVESHADOW\n\tfloat shadowValue = 1.0;\n\t#ifdef SHADOWMAP_PSSM3\n\t\tshadowValue = getShadowPSSM3( u_shadowMap1,u_shadowMap2,u_shadowMap3,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\n\t#endif\n\t#ifdef SHADOWMAP_PSSM2\n\t\tshadowValue = getShadowPSSM2( u_shadowMap1,u_shadowMap2,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\n\t#endif \n\t#ifdef SHADOWMAP_PSSM1\n\t\tshadowValue = getShadowPSSM1( u_shadowMap1,v_lightMVPPos,u_shadowPSSMDistance,u_shadowPCFoffset,v_posViewZ,0.001);\n\t#endif\n#endif\n\n#ifdef LIGHTMAP\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n\t\tgl_FragColor.rgb=gl_FragColor.rgb*(u_MaterialAmbient + texture2D(u_LightMap, v_LightMapUV).rgb);\n\t#else\n\t\t#if defined(RECEIVESHADOW)\n\t\t\tgl_FragColor.rgb=gl_FragColor.rgb*(u_MaterialAmbient + texture2D(u_LightMap, v_LightMapUV).rgb * shadowValue);\n\t\t#else\n\t\t\tgl_FragColor.rgb=gl_FragColor.rgb*(u_MaterialAmbient + texture2D(u_LightMap, v_LightMapUV).rgb);\n\t\t#endif\n\t#endif\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n\t#ifdef RECEIVESHADOW\n\t\tgl_FragColor =vec4( gl_FragColor.rgb*(ambient + diffuse*shadowValue) + specular * shadowValue,gl_FragColor.a);\n\t#else\n\t\tgl_FragColor =vec4( gl_FragColor.rgb*(ambient + diffuse) + specular, gl_FragColor.a);\n\t#endif\n#endif\n\n#ifdef FOG\n\tfloat lerpFact=clamp((toEyeLength-u_FogStart)/u_FogRange,0.0,1.0);\n\tgl_FragColor.rgb=mix(gl_FragColor.rgb,u_FogColor,lerpFact);\n#endif\n}\n\n';var v=fn.add(p,e,t,n,i);Kn.SHADERDEFINE_DETAIL_NUM1=v.registerMaterialDefine("DETAIL_NUM1"),Kn.SHADERDEFINE_DETAIL_NUM2=v.registerMaterialDefine("DETAIL_NUM2"),Kn.SHADERDEFINE_DETAIL_NUM4=v.registerMaterialDefine("DETAIL_NUM4"),Kn.SHADERDEFINE_DETAIL_NUM3=v.registerMaterialDefine("DETAIL_NUM3"),n={a_Position:0,a_Normal:3,a_Texcoord0:2},i={u_MvpMatrix:[1,2],u_WorldMat:[0,2],u_CameraPos:[0,3],u_LightmapScaleOffset:[2,2],u_LightMap:[3,2],u_SplatAlphaTexture:[0,1],u_DiffuseTexture1:[1,1],u_DiffuseTexture2:[2,1],u_DiffuseTexture3:[3,1],u_DiffuseTexture4:[4,1],u_DiffuseTexture5:[5,1],u_DiffuseScaleOffset1:[6,1],u_DiffuseScaleOffset2:[7,1],u_DiffuseScaleOffset3:[8,1],u_DiffuseScaleOffset4:[9,1],u_DiffuseScaleOffset5:[10,1],u_MaterialAlbedo:[14,1],u_MaterialDiffuse:[12,1],u_MaterialAmbient:[11,1],u_MaterialSpecular:[13,1],u_FogStart:[1,4],u_FogRange:[2,4],u_FogColor:[0,4],"u_DirectionLight.Direction":[3,4],"u_DirectionLight.Diffuse":[4,4],"u_PointLight.Position":[5,4],"u_PointLight.Range":[6,4],"u_PointLight.Attenuation":[7,4],"u_PointLight.Diffuse":[8,4],"u_SpotLight.Position":[9,4],"u_SpotLight.Direction":[10,4],"u_SpotLight.Range":[12,4],"u_SpotLight.Spot":[11,4],"u_SpotLight.Attenuation":[13,4],"u_SpotLight.Diffuse":[14,4],u_AmbientColor:[21,4],u_shadowMap1:[18,4],u_shadowMap2:[19,4],u_shadowMap3:[20,4],u_shadowPSSMDistance:[15,4],u_lightShadowVP:[16,4],u_shadowPCFoffset:[17,4]};var E=Gn.nameKey.add("ExtendTerrain");e="attribute vec4 a_Position;\nattribute vec2 a_Texcoord0;\n\nuniform mat4 u_MvpMatrix;\n\nvarying vec2 v_Texcoord0;\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(LIGHTMAP)\n\tattribute vec3 a_Normal;\n\tvarying vec3 v_Normal;\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)||(defined(RECEIVESHADOW)&&defined(SHADOWMAP_PSSM1))\n\tuniform mat4 u_WorldMat;\n\tvarying vec3 v_PositionWorld;\n#endif\n\n#ifdef LIGHTMAP\n\tvarying vec2 v_LightMapUV;\n\tuniform vec4 u_LightmapScaleOffset;\n#endif\n\n#ifdef RECEIVESHADOW\n\tvarying float v_posViewZ;\n\t#ifdef SHADOWMAP_PSSM1 \n\t\tvarying vec4 v_lightMVPPos;\n\t\tuniform mat4 u_lightShadowVP[4];\n\t#endif\n#endif\n\nvoid main()\n{\n\tgl_Position = u_MvpMatrix * a_Position;\n  \n\tv_Texcoord0 = a_Texcoord0;\n  \n\t#ifdef LIGHTMAP\n\t\tv_LightMapUV = vec2(a_Texcoord0.x*u_LightmapScaleOffset.x+u_LightmapScaleOffset.z,(a_Texcoord0.y-1.0)*u_LightmapScaleOffset.y+u_LightmapScaleOffset.w);\n\t#endif\n  \n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n\t\tv_Normal = a_Normal;\n\t#endif\n\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)||(defined(RECEIVESHADOW)&&defined(SHADOWMAP_PSSM1))\n\t\tv_PositionWorld=(u_WorldMat*a_Position).xyz;\n\t#endif\n\n\t#ifdef RECEIVESHADOW\n\t\tv_posViewZ = gl_Position.w;\n\t\t#ifdef SHADOWMAP_PSSM1\n\t\t\tv_lightMVPPos = u_lightShadowVP[0] * vec4(v_PositionWorld,1.0);\n\t\t#endif\n\t#endif\n}",t='#ifdef HIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\n#include "LightHelper.glsl";\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)\n\tuniform vec3 u_MaterialDiffuse;\n\tuniform vec4 u_MaterialSpecular;\n\tuniform vec3 u_CameraPos;\n\tvarying vec3 v_Normal;\n\tvarying vec3 v_PositionWorld;\n#endif\n\n#ifdef FOG\n\tuniform float u_FogStart;\n\tuniform float u_FogRange;\n\tuniform vec3 u_FogColor;\n#endif\n\n\n#ifdef DIRECTIONLIGHT\n\tuniform DirectionLight u_DirectionLight;\n#endif\n\n#ifdef POINTLIGHT\n\tuniform PointLight u_PointLight;\n#endif\n\n#ifdef SPOTLIGHT\n\tuniform SpotLight u_SpotLight;\n#endif\n\nuniform vec3 u_AmbientColor;\n\n#include "ShadowHelper.glsl"\n#ifdef RECEIVESHADOW\n\t#if defined(SHADOWMAP_PSSM2)||defined(SHADOWMAP_PSSM3)\n\tuniform mat4 u_lightShadowVP[4];\n\t#endif\n\t#ifdef SHADOWMAP_PSSM1 \n\tvarying vec4 v_lightMVPPos;\n\t#endif\n#endif\nvarying float v_posViewZ;\n\n\nuniform sampler2D u_SplatAlphaTexture;\n\nuniform sampler2D u_DiffuseTexture1;\nuniform sampler2D u_DiffuseTexture2;\nuniform sampler2D u_DiffuseTexture3;\nuniform sampler2D u_DiffuseTexture4;\nuniform sampler2D u_DiffuseTexture5;\n\nuniform vec4 u_DiffuseScaleOffset1;\nuniform vec4 u_DiffuseScaleOffset2;\nuniform vec4 u_DiffuseScaleOffset3;\nuniform vec4 u_DiffuseScaleOffset4;\nuniform vec4 u_DiffuseScaleOffset5;\n\nvarying vec2 v_Texcoord0;\n\nuniform vec3 u_MaterialAmbient;\nuniform vec4 u_MaterialAlbedo;\n\n#ifdef LIGHTMAP\n\tuniform sampler2D u_LightMap;\n\tvarying vec2 v_LightMapUV;\n#endif\n\nvoid main()\n{\n\t#ifdef ExtendTerrain_DETAIL_NUM1\n\t\tvec4 splatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\n\t\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\n\t\tgl_FragColor.xyz = color1.xyz * splatAlpha.r;\n\t#endif\n\t#ifdef ExtendTerrain_DETAIL_NUM2\n\t\tvec4 splatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\n\t\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\n\t\tvec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord0 * u_DiffuseScaleOffset2.xy);\n\t\tgl_FragColor.xyz = color1.xyz * splatAlpha.r + color2.xyz * (1.0 - splatAlpha.r);\n\t#endif\n\t#ifdef ExtendTerrain_DETAIL_NUM3\n\t\tvec4 splatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\n\t\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\n\t\tvec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord0 * u_DiffuseScaleOffset2.xy);\n\t\tvec4 color3 = texture2D(u_DiffuseTexture3, v_Texcoord0 * u_DiffuseScaleOffset3.xy);\n\t\tgl_FragColor.xyz = color1.xyz * splatAlpha.r  + color2.xyz * splatAlpha.g + color3.xyz * (1.0 - splatAlpha.r - splatAlpha.g);\n\t#endif\n\t#ifdef ExtendTerrain_DETAIL_NUM4\n\t\tvec4 splatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\n\t\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\n\t\tvec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord0 * u_DiffuseScaleOffset2.xy);\n\t\tvec4 color3 = texture2D(u_DiffuseTexture3, v_Texcoord0 * u_DiffuseScaleOffset3.xy);\n\t\tvec4 color4 = texture2D(u_DiffuseTexture4, v_Texcoord0 * u_DiffuseScaleOffset4.xy);\n\t\tgl_FragColor.xyz = color1.xyz * splatAlpha.r  + color2.xyz * splatAlpha.g + color3.xyz * splatAlpha.b + color4.xyz * (1.0 - splatAlpha.r - splatAlpha.g - splatAlpha.b);\n\t#endif\n\t#ifdef ExtendTerrain_DETAIL_NUM5\n\t\tvec4 splatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\n\t\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\n\t\tvec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord0 * u_DiffuseScaleOffset2.xy);\n\t\tvec4 color3 = texture2D(u_DiffuseTexture3, v_Texcoord0 * u_DiffuseScaleOffset3.xy);\n\t\tvec4 color4 = texture2D(u_DiffuseTexture4, v_Texcoord0 * u_DiffuseScaleOffset4.xy);\n\t\tvec4 color5 = texture2D(u_DiffuseTexture5, v_Texcoord0 * u_DiffuseScaleOffset5.xy);\n\t\tgl_FragColor.xyz = color1.xyz * splatAlpha.r  + color2.xyz * splatAlpha.g + color3.xyz * splatAlpha.b + color4.xyz * splatAlpha.a + color5.xyz * (1.0 - splatAlpha.r - splatAlpha.g - splatAlpha.b - splatAlpha.a);\n\t#endif\n\t\tgl_FragColor.w = splatAlpha.a;\n\t\t\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n    vec3 normal = v_Normal;\n\tvec3 diffuse = vec3(0.0);\n\tvec3 ambient = vec3(0.0);\n\tvec3 specular= vec3(0.0);\n\tvec3 dif, amb, spe;\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)\n\tvec3 toEye;\n\t#ifdef FOG\n\t\ttoEye=u_CameraPos-v_PositionWorld;\n\t\tfloat toEyeLength=length(toEye);\n\t\ttoEye/=toEyeLength;\n\t#else\n\t\ttoEye=normalize(u_CameraPos-v_PositionWorld);\n\t#endif\n#endif\n\n#ifdef DIRECTIONLIGHT\n\tcomputeDirectionLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_DirectionLight,u_AmbientColor,normal,toEye, dif, amb, spe);\n\tdiffuse+=dif;\n\tambient+=amb;\n\tspecular+=spe;\n#endif\n \n#ifdef POINTLIGHT\n\tcomputePointLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_PointLight,u_AmbientColor,v_PositionWorld,normal,toEye, dif, amb, spe);\n\tdiffuse+=dif;\n\tambient+=amb;\n\tspecular+=spe;\n#endif\n\n#ifdef SPOTLIGHT\n\tComputeSpotLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_SpotLight,u_AmbientColor,v_PositionWorld,normal,toEye, dif, amb, spe);\n\tdiffuse+=dif;\n\tambient+=amb;\n\tspecular+=spe;\n#endif\n\n#ifdef RECEIVESHADOW\n\tfloat shadowValue = 1.0;\n\t#ifdef SHADOWMAP_PSSM3\n\t\tshadowValue = getShadowPSSM3( u_shadowMap1,u_shadowMap2,u_shadowMap3,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\n\t#endif\n\t#ifdef SHADOWMAP_PSSM2\n\t\tshadowValue = getShadowPSSM2( u_shadowMap1,u_shadowMap2,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\n\t#endif \n\t#ifdef SHADOWMAP_PSSM1\n\t\tshadowValue = getShadowPSSM1( u_shadowMap1,v_lightMVPPos,u_shadowPSSMDistance,u_shadowPCFoffset,v_posViewZ,0.001);\n\t#endif\n#endif\n\n#ifdef LIGHTMAP\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n\t\tgl_FragColor.rgb=gl_FragColor.rgb*(u_MaterialAmbient + texture2D(u_LightMap, v_LightMapUV).rgb);\n\t#else\n\t\t#if defined(RECEIVESHADOW)\t\t\n\t\t\tgl_FragColor.rgb=gl_FragColor.rgb*(u_MaterialAmbient+texture2D(u_LightMap, v_LightMapUV).rgb * shadowValue);\n\t\t\t//vec3 tColor= u_MaterialAmbient + texture2D(u_LightMap, v_LightMapUV).rgb * shadowValue + mix(vec3(0.15,0.15,0.15),vec3(0.0),shadowValue);\n\t\t\t//gl_FragColor.rgb*=tColor;\n\t\t#else\n\t\t\tgl_FragColor.rgb=gl_FragColor.rgb*(u_MaterialAmbient + texture2D(u_LightMap, v_LightMapUV).rgb);\n\t\t#endif\n\t#endif\n#endif\n\ngl_FragColor=gl_FragColor*u_MaterialAlbedo;\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n\t#ifdef RECEIVESHADOW\n\t\tgl_FragColor = vec4( gl_FragColor.rgb*(ambient + diffuse*shadowValue) + specular * shadowValue,gl_FragColor.a);\n\t#else\n\t\tgl_FragColor =vec4( gl_FragColor.rgb*(ambient + diffuse) + specular, gl_FragColor.a);\n\t#endif\n#endif\n\n#ifdef FOG\n\tfloat lerpFact=clamp((toEyeLength-u_FogStart)/u_FogRange,0.0,1.0);\n\tgl_FragColor.rgb=mix(gl_FragColor.rgb,u_FogColor,lerpFact);\n#endif\n}\n\n\n\n\n\n';var g=fn.add(E,e,t,n,i);g.addSpriteDefines(mi.shaderDefines),g.addSpriteDefines(Wn.shaderDefines),n={a_Position:0,a_OffsetVector:41,a_Texcoord0X:38,a_Texcoord0Y:40,a_BirthTime:33},i={u_MvpMatrix:[1,2],u_VMatrix:[1,3],u_PMatrix:[2,3],u_TilingOffset:[3,1],u_MainTexture:[1,1],u_MainColor:[2,1],u_CurTime:[3,2],u_LifeTime:[4,2],u_WidthCurve:[5,2],u_WidthCurveKeyLength:[6,2],u_GradientColorkey:[7,2],u_GradientAlphakey:[8,2]};var D=Gn.nameKey.add("Trail");e="attribute vec3 a_Position;\nattribute vec3 a_OffsetVector;\nattribute vec4 a_Color;\nattribute float a_Texcoord0X;\nattribute float a_Texcoord0Y;\nattribute float a_BirthTime;\n\nuniform mat4 u_VMatrix;\nuniform mat4 u_PMatrix;\n\nuniform vec4 u_TilingOffset;\n\nuniform float u_CurTime;\nuniform float u_LifeTime;\nuniform vec4 u_WidthCurve[10];\nuniform int u_WidthCurveKeyLength;\n\nuniform vec4 u_GradientColorkey[10];\nuniform vec2 u_GradientAlphakey[10];\n\nvarying vec2 v_Texcoord0;\nvarying vec4 v_Color;\n\nfloat hermiteInterpolate(float t, float outTangent, float inTangent, float duration, float value1, float value2)\n{\n\tfloat t2 = t * t;\n\tfloat t3 = t2 * t;\n\tfloat a = 2.0 * t3 - 3.0 * t2 + 1.0;\n\tfloat b = t3 - 2.0 * t2 + t;\n\tfloat c = t3 - t2;\n\tfloat d = -2.0 * t3 + 3.0 * t2;\n\treturn a * value1 + b * outTangent * duration + c * inTangent * duration + d * value2;\n}\n\nfloat getCurWidth(in float normalizeTime)\n{\n\tif(normalizeTime == 0.0){\n\t\treturn u_WidthCurve[0].w;\n\t}\n\telse if(normalizeTime >= 1.0){\n\t\treturn u_WidthCurve[u_WidthCurveKeyLength - 1].w;\n\t}\n\telse{\n\t\tfor(int i = 0; i < 10; i ++ )\n\t\t{\n\t\t\tif(normalizeTime == u_WidthCurve[i].x)\n\t\t\t{\n\t\t\t\treturn u_WidthCurve[i].w;\n\t\t\t}\n\t\t\t\n\t\t\tvec4 lastFrame = u_WidthCurve[i];\n\t\t\tvec4 nextFrame = u_WidthCurve[i + 1];\n\t\t\tif(normalizeTime > lastFrame.x && normalizeTime < nextFrame.x)\n\t\t\t{\n\t\t\t\tfloat duration = nextFrame.x - lastFrame.x;\n\t\t\t\tfloat t = (normalizeTime - lastFrame.x) / duration;\n\t\t\t\tfloat outTangent = lastFrame.z;\n\t\t\t\tfloat inTangent = nextFrame.y;\n\t\t\t\tfloat value1 = lastFrame.w;\n\t\t\t\tfloat value2 = nextFrame.w;\n\t\t\t\treturn hermiteInterpolate(t, outTangent, inTangent, duration, value1, value2);\n\t\t\t}\n\t\t}\t\n\t}\n}\t\n\nvec4 getColorFromGradientByBlend(in vec4 gradientColors[10], in vec2 gradientAlphas[10], in float normalizeTime)\n{\n\tvec4 color;\n\tfor(int i = 1; i < 10; i++)\n\t{\n\t\tvec4 gradientColor = gradientColors[i];\n\t\tfloat colorKey = gradientColor.w;\n\t\tif(colorKey >= normalizeTime)\n\t\t{\n\t\t\tvec4 lastGradientColor = gradientColors[i-1];\n\t\t\tfloat lastColorKey = lastGradientColor.w;\n\t\t\tfloat age = (normalizeTime - lastColorKey) / (colorKey - lastColorKey);\n\t\t\tcolor.rgb = mix(gradientColors[i-1].xyz, gradientColor.xyz, age);\n\t\t\tbreak;\n\t\t}\n\t}\n\tfor(int i = 1; i < 10; i++)\n\t{\n\t\tvec2 gradientAlpha = gradientAlphas[i];\n\t\tfloat alphaKey = gradientAlpha.y;\n\t\tif(alphaKey >= normalizeTime)\n\t\t{\n\t\t\tvec2 lastGradientAlpha = gradientAlphas[i-1];\n\t\t\tfloat lastAlphaKey = lastGradientAlpha.y;\n\t\t\tfloat age = (normalizeTime - lastAlphaKey) / (alphaKey - lastAlphaKey);\n\t\t\tcolor.a = mix(lastGradientAlpha.x, gradientAlpha.x, age);\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn color;\n}\n\nvec4 getColorFromGradientByFixed(in vec4 gradientColors[10], in vec2 gradientAlphas[10], in float normalizeTime)\n{\n\tvec4 color;\n\tfor(int i = 1; i < 10; i++)\n\t{\n\t\tvec4 gradientColor = gradientColors[i];\n\t\tif(gradientColor.w >= normalizeTime)\n\t\t{\n\t\t\tcolor.rgb = gradientColor.xyz;\n\t\t\tbreak;\n\t\t}\n\t}\n\tfor(int i = 1; i < 10; i++)\n\t{\n\t\tvec2 gradientAlpha = gradientAlphas[i];\n\t\tif(gradientAlpha.y >= normalizeTime)\n\t\t{\n\t\t\tcolor.a = gradientAlpha.x;\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn color;\n}\n\nvoid main()\n{\n\tfloat normalizeTime = (u_CurTime - a_BirthTime) / u_LifeTime;\n\t\n\tgl_Position = u_PMatrix * u_VMatrix * vec4(a_Position + a_OffsetVector * getCurWidth(normalizeTime),1.0);\n\t\n\t#ifdef TILINGOFFSET\n\t\tv_Texcoord0 = (vec2(a_Texcoord0X, a_Texcoord0Y) * u_TilingOffset.xy) + u_TilingOffset.zw;\n\t#else\n\t\tv_Texcoord0 = vec2(a_Texcoord0X, a_Texcoord0Y);\n\t#endif\n\t\n\t#ifdef GRADIENTMODE_BLEND\n\t\tv_Color = getColorFromGradientByBlend(u_GradientColorkey, u_GradientAlphakey, normalizeTime);\n\t#else\n\t\tv_Color = getColorFromGradientByFixed(u_GradientColorkey, u_GradientAlphakey, normalizeTime);\n\t#endif\n}\n\n\n\n",t="#ifdef HIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\nuniform sampler2D u_MainTexture;\nuniform vec4 u_MainColor;\n\nvarying vec2 v_Texcoord0;\nvarying vec4 v_Color;\n\nvoid main()\n{\t\n\tvec4 color = 2.0 * u_MainColor * v_Color;\n\t#ifdef DIFFUSETEXTURE\n\t\tvec4 mainTextureColor = texture2D(u_MainTexture, v_Texcoord0);\n\t\tcolor *= mainTextureColor;\n\t#endif\n\tgl_FragColor = color;\n}\n\n";var T=fn.add(D,e,t,n,i);ei.SHADERDEFINE_DIFFUSETEXTURE=T.registerMaterialDefine("DIFFUSETEXTURE"),ei.SHADERDEFINE_TILINGOFFSET=T.registerSpriteDefine("TILINGOFFSET"),xi.SHADERDEFINE_GRADIENTMODE_BLEND=T.registerSpriteDefine("GRADIENTMODE_BLEND")},e}(),Wt=function(){function e(){this._data=null,this._data=[]}s(e,"laya.d3.shader.ValusArray");var t=e.prototype;return t.setValue=function(e,t){this._data[e]=t},l(0,t,"data",function(){return this._data}),e}(),kt=function(){function e(){this._currentPSSM=-1,this._numberOfPSSM=3,this._maxDistance=200,this._ratioOfDistance=1/this._numberOfPSSM,this._statesDirty=!0,this._lightCulling=null,this._renderTarget=null,this._lightVPMatrix=null,this._lightCameras=null,this._shadowQuenes=null,this._shadowMapTextureSize=1024,this._scene=null,this._PCFType=0,this._shaderValueLightVP=null,this._shaderValueVPs=null,this._spiltDistance=new Array(4),this._globalParallelLightDir=new bt(0,-1,0),this._boundingSphere=new Array(4),this._boundingBox=new Array(4),this._frustumPos=new Array(16),this._uniformDistance=new Array(4),this._logDistance=new Array(4),this._dimension=new Array(4),this._tempLookAt3=new bt,this._tempLookAt4=new Ft,this._tempValue=new Ft,this._tempPos=new bt,this._tempLightUp=new bt,this._tempMin=new Ft,this._tempMax=new Ft,this._tempMatrix44=new Ct,this._splitFrustumCulling=new Mt(Ct.DEFAULT),this._tempScaleMatrix44=new Ct,this._shadowPCFOffset=new Lt(1/1024,1/1024),this._shaderValueDistance=new Ft;var e=0;for(e=0;e<this._spiltDistance.length;e++)this._spiltDistance[e]=0;for(e=0;e<this._dimension.length;e++)this._dimension[e]=new Lt;for(e=0;e<this._frustumPos.length;e++)this._frustumPos[e]=new bt;for(e=0;e<this._boundingBox.length;e++)this._boundingBox[e]=new xt(new bt,new bt);for(e=0;e<this._boundingSphere.length;e++)this._boundingSphere[e]=new Rt(new bt,0);Ct.createScaling(new bt(.5,.5,1),this._tempScaleMatrix44),this._tempScaleMatrix44.elements[12]=.5,this._tempScaleMatrix44.elements[13]=.5}s(e,"laya.d3.shadowMap.ParallelSplitShadowMap");var t=e.prototype;return t.setInfo=function(e,t,n,i,r,a){r>3&&(this._numberOfPSSM=3),this._scene=e,this._maxDistance=t,this.PSSMNum=r,this._globalParallelLightDir=n,this._ratioOfDistance=1/this._numberOfPSSM;for(var o=0;o<this._spiltDistance.length;o++)this._spiltDistance[o]=0;this._shadowMapTextureSize=i,this._shadowPCFOffset.x=1/this._shadowMapTextureSize,this._shadowPCFOffset.y=1/this._shadowMapTextureSize,this.setPCFType(a),this._statesDirty=!0},t.setPCFType=function(e){switch(this._PCFType=e,this._PCFType){case 0:this._scene.addShaderDefine(laya.d3.shadowMap.ParallelSplitShadowMap.SHADERDEFINE_SHADOW_PCF_NO),this._scene.removeShaderDefine(laya.d3.shadowMap.ParallelSplitShadowMap.SHADERDEFINE_SHADOW_PCF1),this._scene.removeShaderDefine(laya.d3.shadowMap.ParallelSplitShadowMap.SHADERDEFINE_SHADOW_PCF2),this._scene.removeShaderDefine(laya.d3.shadowMap.ParallelSplitShadowMap.SHADERDEFINE_SHADOW_PCF3);break;case 1:this._scene.addShaderDefine(laya.d3.shadowMap.ParallelSplitShadowMap.SHADERDEFINE_SHADOW_PCF1),this._scene.removeShaderDefine(laya.d3.shadowMap.ParallelSplitShadowMap.SHADERDEFINE_SHADOW_PCF_NO),this._scene.removeShaderDefine(laya.d3.shadowMap.ParallelSplitShadowMap.SHADERDEFINE_SHADOW_PCF2),this._scene.removeShaderDefine(laya.d3.shadowMap.ParallelSplitShadowMap.SHADERDEFINE_SHADOW_PCF3);break;case 2:this._scene.addShaderDefine(laya.d3.shadowMap.ParallelSplitShadowMap.SHADERDEFINE_SHADOW_PCF2),this._scene.removeShaderDefine(laya.d3.shadowMap.ParallelSplitShadowMap.SHADERDEFINE_SHADOW_PCF_NO),this._scene.removeShaderDefine(laya.d3.shadowMap.ParallelSplitShadowMap.SHADERDEFINE_SHADOW_PCF1),this._scene.removeShaderDefine(laya.d3.shadowMap.ParallelSplitShadowMap.SHADERDEFINE_SHADOW_PCF3);break;case 3:this._scene.addShaderDefine(laya.d3.shadowMap.ParallelSplitShadowMap.SHADERDEFINE_SHADOW_PCF3),this._scene.removeShaderDefine(laya.d3.shadowMap.ParallelSplitShadowMap.SHADERDEFINE_SHADOW_PCF_NO),this._scene.removeShaderDefine(laya.d3.shadowMap.ParallelSplitShadowMap.SHADERDEFINE_SHADOW_PCF1),this._scene.removeShaderDefine(laya.d3.shadowMap.ParallelSplitShadowMap.SHADERDEFINE_SHADOW_PCF2)}},t.getPCFType=function(){return this._PCFType},t.setFarDistance=function(e){this._maxDistance!=e&&(this._maxDistance=e,this._statesDirty=!0)},t.getFarDistance=function(){return this._maxDistance},t._setGlobalParallelLightDir=function(e){this._globalParallelLightDir=e},t.getGlobalParallelLightDir=function(){return this._globalParallelLightDir},t.getCurrentPSSM=function(){return this._currentPSSM},t.getLightCamera=function(e){return this._lightCameras[e]},t._beginSampler=function(e,t){if(e<0||e>this._numberOfPSSM)throw new Error("ParallelSplitShadowMap: beginSample invalid index");this._currentPSSM=e,this._update(t)},t.endSampler=function(e){this._currentPSSM=-1},t._calcAllLightCameraInfo=function(e){if(1===this._numberOfPSSM)this._beginSampler(0,e),this.endSampler(e);else for(var t=0,n=this._numberOfPSSM+1;t<n;t++)this._beginSampler(t,e),this.endSampler(e)},t._recalculate=function(e,t,n){this._calcSplitDistance(e),this._calcBoundingBox(t,n),this._rebuildRenderInfo()},t._update=function(e){var t=e.nearPlane,n=e.fieldOfView,i=e.aspectRatio;(this._statesDirty||this.lastNearPlane!==t||this.lastFieldOfView!==n||this.lastAspectRatio!==i)&&(this._recalculate(t,n,i),this._uploadShaderValue(),this._statesDirty=!1,this.lastNearPlane=t,this.lastFieldOfView=n,this.lastAspectRatio=i),this._calcLightViewProject(e)},t._uploadShaderValue=function(){var e=this._scene;switch(this._numberOfPSSM){case 1:e.addShaderDefine(laya.d3.shadowMap.ParallelSplitShadowMap.SHADERDEFINE_SHADOW_PSSM1),e.removeShaderDefine(laya.d3.shadowMap.ParallelSplitShadowMap.SHADERDEFINE_SHADOW_PSSM2),e.removeShaderDefine(laya.d3.shadowMap.ParallelSplitShadowMap.SHADERDEFINE_SHADOW_PSSM3);break;case 2:e.addShaderDefine(laya.d3.shadowMap.ParallelSplitShadowMap.SHADERDEFINE_SHADOW_PSSM2),e.removeShaderDefine(laya.d3.shadowMap.ParallelSplitShadowMap.SHADERDEFINE_SHADOW_PSSM1),e.removeShaderDefine(laya.d3.shadowMap.ParallelSplitShadowMap.SHADERDEFINE_SHADOW_PSSM3);break;case 3:e.addShaderDefine(laya.d3.shadowMap.ParallelSplitShadowMap.SHADERDEFINE_SHADOW_PSSM3),e.removeShaderDefine(laya.d3.shadowMap.ParallelSplitShadowMap.SHADERDEFINE_SHADOW_PSSM1),e.removeShaderDefine(laya.d3.shadowMap.ParallelSplitShadowMap.SHADERDEFINE_SHADOW_PSSM2)}var t=e._shaderValues;switch(t.setValue(15,this._shaderValueDistance.elements),t.setValue(16,this._shaderValueLightVP),t.setValue(17,this._shadowPCFOffset.elements),this._numberOfPSSM){case 3:t.setValue(18,this.getRenderTarget(1)),t.setValue(19,this.getRenderTarget(2)),t.setValue(20,this.getRenderTarget(3));break;case 2:t.setValue(18,this.getRenderTarget(1)),t.setValue(19,this.getRenderTarget(2));break;case 1:t.setValue(18,this.getRenderTarget(1))}},t._calcSplitDistance=function(e){var t=this._maxDistance,n=1/this._numberOfPSSM,i=0;for(i=0;i<=this._numberOfPSSM;i++)this._uniformDistance[i]=e+(t-e)*i*n;var r=t/e;for(i=0;i<=this._numberOfPSSM;i++){var a=Math.pow(r,i*n);this._logDistance[i]=e*a}for(i=0;i<=this._numberOfPSSM;i++)this._spiltDistance[i]=this._uniformDistance[i]*this._ratioOfDistance+this._logDistance[i]*(1-this._ratioOfDistance);this._shaderValueDistance.x=this._spiltDistance[1],this._shaderValueDistance.y=this._spiltDistance[2],this._shaderValueDistance.z=this._spiltDistance[3],this._shaderValueDistance.w=this._spiltDistance[4]},t._calcBoundingBox=function(e,t){var n,i,r,a,o=3.1415926*e/180,s=Math.tan(o/2),l=NaN,h=NaN,_=NaN,u=0;for(u=0;u<=this._numberOfPSSM;u++){h=(l=(_=this._spiltDistance[u])*s)*t;var c=this._frustumPos[4*u+0].elements;c[0]=-h,c[1]=-l,c[2]=-_,(c=this._frustumPos[4*u+1].elements)[0]=h,c[1]=-l,c[2]=-_,(c=this._frustumPos[4*u+2].elements)[0]=-h,c[1]=l,c[2]=-_,(c=this._frustumPos[4*u+3].elements)[0]=h,c[1]=l,c[2]=-_,(c=this._dimension[u].elements)[0]=h,c[1]=l}for(u=1;u<=this._numberOfPSSM;u++)n=this._dimension[u].elements,(i=this._boundingBox[u].min.elements)[0]=-n[0],i[1]=-n[1],i[2]=-this._spiltDistance[u],(r=this._boundingBox[u].max.elements)[0]=n[0],r[1]=n[1],r[2]=-this._spiltDistance[u-1],(a=this._boundingSphere[u].center.elements)[0]=.5*(i[0]+r[0]),a[1]=.5*(i[1]+r[1]),a[2]=.5*(i[2]+r[2]),this._boundingSphere[u].radius=.5*Math.sqrt(Math.pow(r[0]-i[0],2)+Math.pow(r[1]-i[1],2)+Math.pow(r[2]-i[2],2));i=this._boundingBox[0].min.elements,n=this._dimension[this._numberOfPSSM].elements,i[0]=-n[0],i[1]=-n[1],i[2]=-this._spiltDistance[this._numberOfPSSM],(r=this._boundingBox[0].max.elements)[0]=n[0],r[1]=n[1],r[2]=-this._spiltDistance[0],(a=this._boundingSphere[0].center.elements)[0]=.5*(i[0]+r[0]),a[1]=.5*(i[1]+r[1]),a[2]=.5*(i[2]+r[2]),this._boundingSphere[0].radius=.5*Math.sqrt(Math.pow(r[0]-i[0],2)+Math.pow(r[1]-i[1],2)+Math.pow(r[2]-i[2],2))},t.calcSplitFrustum=function(e){this._currentPSSM>0?Ct.createPerspective(3.1416*e.fieldOfView/180,e.aspectRatio,this._spiltDistance[this._currentPSSM-1],this._spiltDistance[this._currentPSSM],this._tempMatrix44):Ct.createPerspective(3.1416*e.fieldOfView/180,e.aspectRatio,this._spiltDistance[0],this._spiltDistance[this._numberOfPSSM],this._tempMatrix44),Ct.multiply(this._tempMatrix44,e.viewMatrix,this._tempMatrix44),this._splitFrustumCulling.matrix=this._tempMatrix44},t._rebuildRenderInfo=function(){var e=this._numberOfPSSM+1,t=0;if(null==this._renderTarget)for(this._renderTarget=h(e),this._renderTarget[0]=null,t=1;t<e;t++)this._renderTarget[t]=new li(this._shadowMapTextureSize,this._shadowMapTextureSize,6408,5121,33189,!1,!1,9728,9728);else if(this._renderTarget.length!=e)for(this.disposeAllRenderTarget(),this._renderTarget.length=e,this._renderTarget[0]=null,t=1;t<e;t++)this._renderTarget[t]=new li(this._shadowMapTextureSize,this._shadowMapTextureSize,6408,5121,33189,!1,!1,9728,9728);else for(t=1;t<e;t++)null!=this._renderTarget[t]&&this._renderTarget[t].width==this._shadowMapTextureSize&&this._renderTarget[t].height==this._shadowMapTextureSize||(null!=this._renderTarget[t]&&this._renderTarget[t].destroy(),this._renderTarget[t]=new li(this._shadowMapTextureSize,this._shadowMapTextureSize,6408,5121,33189,!1,!1,9728,9728));if(null==this._lightCulling||this._lightCulling.length!=e)for(this._lightCulling?this._lightCulling.length=e:this._lightCulling=h(e),t=0;t<this._lightCulling.length;t++)this._lightCulling[t]=new Mt(Ct.DEFAULT);if(null==this._lightVPMatrix||this._lightVPMatrix.length!=e)for(this._lightVPMatrix?this._lightVPMatrix.length=e:this._lightVPMatrix=h(e),t=0;t<this._lightVPMatrix.length;t++)this._lightVPMatrix[t]=new Ct;if(null==this._lightCameras||this._lightCameras.length!=e)for(this._lightCameras?this._lightCameras.length=e:this._lightCameras=h(e),t=0;t<this._lightCameras.length;t++)this._lightCameras[t]=new Ei,this._lightCameras[t].name="lightCamera"+t;if(null==this._shadowQuenes||this._shadowQuenes.length!=this._numberOfPSSM)for(this._shadowQuenes?this._shadowQuenes.length=this._numberOfPSSM:this._shadowQuenes=h(this._numberOfPSSM),t=0;t<this._shadowQuenes.length;t++)this._shadowQuenes[t]=new fe(this._scene);if(null==this._shaderValueVPs||this._shaderValueVPs.length!=e)for(this._shaderValueVPs?this._shaderValueVPs.length=e:this._shaderValueVPs=h(e),this._shaderValueLightVP=new Float32Array(16*e),t=0;t<e;t++)this._shaderValueVPs[t]=new Float32Array(this._shaderValueLightVP.buffer,64*t)},t._calcLightViewProject=function(t){var n=this._boundingSphere[this._currentPSSM],i=t.transform.worldMatrix;n.radius,n.center.cloneTo(this._tempLookAt3),bt.transformV3ToV4(this._tempLookAt3,i,this._tempLookAt4);var r=this._tempLookAt3.elements,a=this._tempLookAt4.elements;r[0]=a[0],r[1]=a[1],r[2]=a[2];var o=this._tempLightUp.elements,s=t.forward.elements;o[0]=s[0],o[1]=1,o[2]=s[2],bt.normalize(this._tempLightUp,this._tempLightUp),bt.scale(this._globalParallelLightDir,4*n.radius,this._tempPos),bt.subtract(this._tempLookAt3,this._tempPos,this._tempPos);var l=this._lightCameras[this._currentPSSM];l.transform.position=this._tempPos,l.transform.lookAt(this._tempLookAt3,this._tempLightUp,!1);var h=this._tempMax.elements,_=this._tempMin.elements;h[0]=h[1]=h[2]=-1e5,h[3]=1,_[0]=_[1]=_[2]=1e5,_[3]=1,Ct.multiply(l.viewMatrix,i,this._tempMatrix44);var u=this._tempValue.elements,c=[];c.length=8,this._boundingBox[this._currentPSSM].getCorners(c);for(var d=0;d<8;d++){var f=c[d].elements;u[0]=f[0],u[1]=f[1],u[2]=f[2],u[3]=1,Ft.transformByM4x4(this._tempValue,this._tempMatrix44,this._tempValue),_[0]=u[0]<_[0]?u[0]:_[0],_[1]=u[1]<_[1]?u[1]:_[1],_[2]=u[2]<_[2]?u[2]:_[2],h[0]=u[0]>h[0]?u[0]:h[0],h[1]=u[1]>h[1]?u[1]:h[1],h[2]=u[2]>h[2]?u[2]:h[2]}Ft.add(this._tempMax,this._tempMin,this._tempValue),u[0]*=.5,u[1]*=.5,u[2]*=.5,u[3]=1,Ft.transformByM4x4(this._tempValue,l.transform.worldMatrix,this._tempValue);var m=Math.abs(-this._tempMax.z),p=m>this._maxDistance?m:this._maxDistance;bt.scale(this._globalParallelLightDir,p,this._tempPos);var v=this._tempPos.elements;v[0]=u[0]-v[0],v[1]=u[1]-v[1],v[2]=u[2]-v[2],l.transform.position=this._tempPos,l.transform.lookAt(this._tempLookAt3,this._tempLightUp,!1),Ct.createOrthoOffCenterRH(_[0],h[0],_[1],h[1],1,p+.5*(h[2]-_[2]),l.projectionMatrix),l.projectionViewMatrix.cloneTo(this._lightVPMatrix[this._currentPSSM]),this._lightCulling[this._currentPSSM].matrix=this._lightVPMatrix[this._currentPSSM],e.multiplyMatrixOutFloat32Array(this._tempScaleMatrix44,this._lightVPMatrix[this._currentPSSM],this._shaderValueVPs[this._currentPSSM])},t.getLightFrustumCulling=function(e){return this._lightCulling[e]},t.getSplitFrustumCulling=function(){return this._splitFrustumCulling},t.getSplitDistance=function(e){return this._spiltDistance[e]},t.setShadowMapTextureSize=function(e){e!==this._shadowMapTextureSize&&(this._shadowMapTextureSize=e,this._shadowPCFOffset.x=1/this._shadowMapTextureSize,this._shadowPCFOffset.y=1/this._shadowMapTextureSize,this._statesDirty=!0)},t.getShadowMapTextureSize=function(){return this._shadowMapTextureSize},t.beginRenderTarget=function(e){this._renderTarget[e].start()},t.endRenderTarget=function(e){this._renderTarget[e].end()},t.getRenderTarget=function(e){return this._renderTarget[e]},t.disposeAllRenderTarget=function(){for(var e=0,t=this._numberOfPSSM+1;e<t;e++)this._renderTarget[e]&&(this._renderTarget[e].destroy(),this._renderTarget[e]=null)},l(0,t,"PSSMNum",function(){return this._numberOfPSSM},function(e){e=(e=e>0?e:1)<=3?e:3,this._numberOfPSSM!=e&&(this._numberOfPSSM=e,this._ratioOfDistance=1/this._numberOfPSSM,this._statesDirty=!0)}),e.multiplyMatrixOutFloat32Array=function(e,t,n){var i,r,a,o,s,l,h;for(r=e.elements,a=t.elements,i=0;i<4;i++)o=r[i],s=r[i+4],l=r[i+8],h=r[i+12],n[i]=o*a[0]+s*a[1]+l*a[2]+h*a[3],n[i+4]=o*a[4]+s*a[5]+l*a[6]+h*a[7],n[i+8]=o*a[8]+s*a[9]+l*a[10]+h*a[11],n[i+12]=o*a[12]+s*a[13]+l*a[14]+h*a[15]},e.SHADERDEFINE_RECEIVE_SHADOW=1,e.SHADERDEFINE_CAST_SHADOW=512,e.SHADERDEFINE_SHADOW_PSSM1=1024,e.SHADERDEFINE_SHADOW_PSSM2=2048,e.SHADERDEFINE_SHADOW_PSSM3=4096,e.SHADERDEFINE_SHADOW_PCF_NO=8192,e.SHADERDEFINE_SHADOW_PCF1=16384,e.SHADERDEFINE_SHADOW_PCF2=32768,e.SHADERDEFINE_SHADOW_PCF3=65536,e.MAX_PSSM_COUNT=3,e}(),Xt=function(){function e(){this._boundingSphere=null,this._boundingBox=null,this._sizeOfY=null,this._currentLODLevel=0,this._lastDistanceToEye=NaN,this._originalBoundingSphere=null,this._originalBoundingBox=null,this._originalBoundingBoxCorners=null,this._bUseStrip=!1,this._gridSize=NaN,this._beginGridX=0,this._beginGridZ=0,this._LODError=null,e.__init__(),this._currentLODLevel=0}s(e,"laya.d3.terrain.TerrainLeaf");var t=e.prototype;return t.calcVertextNorml=function(t,n,i,r,a,o){var s=0,l=0;l=-1*e.getHeightFromTerrainHeightData(t-1,n-1,i,r,a),l+=-1*e.getHeightFromTerrainHeightData(t-1,n,i,r,a),l+=-1*e.getHeightFromTerrainHeightData(t-1,n+1,i,r,a),l+=1*e.getHeightFromTerrainHeightData(t+1,n-1,i,r,a),l+=1*e.getHeightFromTerrainHeightData(t+1,n,i,r,a),l+=1*e.getHeightFromTerrainHeightData(t+1,n+1,i,r,a),s=-1*e.getHeightFromTerrainHeightData(t-1,n-1,i,r,a),s+=-1*e.getHeightFromTerrainHeightData(t,n-1,i,r,a),s+=-1*e.getHeightFromTerrainHeightData(t+1,n-1,i,r,a),s+=1*e.getHeightFromTerrainHeightData(t-1,n+1,i,r,a),s+=1*e.getHeightFromTerrainHeightData(t,n+1,i,r,a),s+=1*e.getHeightFromTerrainHeightData(t+1,n+1,i,r,a),o.x=-l,o.y=6,o.z=-s,bt.normalize(o,o)},t.calcVertextNormlUV=function(e,t,n,i,r){r.x=e/n,r.y=t/i,r.z=t/i},t.calcVertextBuffer=function(t,n,i,r,a,o,s,l,h,_,u,c){if(1==c&&!e.__ADAPT_MATRIX__){e.__ADAPT_MATRIX__=new Ct;var d=new Ct;Ct.createRotationY(Math.PI,e.__ADAPT_MATRIX__),Ct.createTranslate(new bt(0,0,(u-1)*a),d),Ct.multiply(d,e.__ADAPT_MATRIX__,e.__ADAPT_MATRIX__),e.__ADAPT_MATRIX_INV__=new Ct,e.__ADAPT_MATRIX__.invert(e.__ADAPT_MATRIX_INV__)}this._gridSize=a,this._beginGridX=t*e.CHUNK_GRID_NUM+i,this._beginGridZ=n*e.CHUNK_GRID_NUM+r;for(var f=s*l,m=2147483647,p=-2147483648,v=new bt,E=0,g=e.LEAF_GRID_NUM+1;E<g;E++)for(var D=0,T=e.LEAF_GRID_NUM+1;D<T;D++)e.__VECTOR3__.x=(this._beginGridX+D)*this._gridSize,e.__VECTOR3__.z=(this._beginGridZ+E)*this._gridSize,e.__VECTOR3__.y=h[(this._beginGridZ+E)*_+(this._beginGridX+D)],m=e.__VECTOR3__.y<m?e.__VECTOR3__.y:m,p=e.__VECTOR3__.y>p?e.__VECTOR3__.y:p,e.__ADAPT_MATRIX__&&bt.transformV3ToV3(e.__VECTOR3__,e.__ADAPT_MATRIX__,e.__VECTOR3__),o[f]=e.__VECTOR3__.x,o[++f]=e.__VECTOR3__.y,o[++f]=e.__VECTOR3__.z,f++,this.calcVertextNormlUV(this._beginGridX+D,this._beginGridZ+E,_,u,v),o[f]=v.x,o[++f]=v.y,o[++f]=v.z,o[++f]=(i+D)/e.CHUNK_GRID_NUM,o[++f]=(r+E)/e.CHUNK_GRID_NUM,o[++f]=this._beginGridX+D,o[++f]=this._beginGridZ+E,f++;this._sizeOfY=new Lt(m-1,p+1),this.calcLODErrors(h,_,u),this.calcOriginalBoudingBoxAndSphere()},t.calcSkirtVertextBuffer=function(t,n,i,r,a,o,s,l,h,_,u){this._gridSize=a,this._beginGridX=t*e.CHUNK_GRID_NUM+i,this._beginGridZ=n*e.CHUNK_GRID_NUM+r;var c=s*l,d=0,f=0,m=e.LEAF_GRID_NUM+1,p=new bt,v=0,E=0;for(d=0;d<2;d++)for(f=0;f<m;f++)e.__VECTOR3__.x=(this._beginGridX+f)*this._gridSize,e.__VECTOR3__.y=1==d?h[this._beginGridZ*_+(this._beginGridX+f)]:-this._gridSize,e.__VECTOR3__.z=(this._beginGridZ+0)*this._gridSize,e.__ADAPT_MATRIX__&&bt.transformV3ToV3(e.__VECTOR3__,e.__ADAPT_MATRIX__,e.__VECTOR3__),o[c]=e.__VECTOR3__.x,o[++c]=e.__VECTOR3__.y,o[++c]=e.__VECTOR3__.z,c++,v=0==d?this._beginGridZ-1:this._beginGridZ,this.calcVertextNormlUV(this._beginGridX+f,v,_,u,p),o[c]=p.x,o[++c]=p.y,o[++c]=p.z,o[++c]=(i+f)/e.CHUNK_GRID_NUM,o[++c]=(r+0)/e.CHUNK_GRID_NUM,o[++c]=this._beginGridX+f,o[++c]=v,c++;for(d=0;d<2;d++)for(f=0;f<m;f++)e.__VECTOR3__.x=(this._beginGridX+f)*this._gridSize,e.__VECTOR3__.y=0==d?h[(this._beginGridZ+e.LEAF_GRID_NUM)*_+(this._beginGridX+f)]:-this._gridSize,e.__VECTOR3__.z=(this._beginGridZ+e.LEAF_GRID_NUM)*this._gridSize,e.__ADAPT_MATRIX__&&bt.transformV3ToV3(e.__VECTOR3__,e.__ADAPT_MATRIX__,e.__VECTOR3__),o[c]=e.__VECTOR3__.x,o[++c]=e.__VECTOR3__.y,o[++c]=e.__VECTOR3__.z,c++,v=0==d?this._beginGridZ+e.LEAF_GRID_NUM:this._beginGridZ+e.LEAF_GRID_NUM+1,this.calcVertextNormlUV(this._beginGridX+f,v,_,u,p),o[c]=p.x,o[++c]=p.y,o[++c]=p.z,o[++c]=(i+f)/e.CHUNK_GRID_NUM,o[++c]=(r+e.LEAF_GRID_NUM)/e.CHUNK_GRID_NUM,o[++c]=this._beginGridX+f,o[++c]=v,c++;for(d=0;d<2;d++)for(f=0;f<m;f++)e.__VECTOR3__.x=(this._beginGridX+0)*this._gridSize,e.__VECTOR3__.y=0==d?h[(this._beginGridZ+f)*_+(this._beginGridX+0)]:-this._gridSize,e.__VECTOR3__.z=(this._beginGridZ+f)*this._gridSize,e.__ADAPT_MATRIX__&&bt.transformV3ToV3(e.__VECTOR3__,e.__ADAPT_MATRIX__,e.__VECTOR3__),o[c]=e.__VECTOR3__.x,o[++c]=e.__VECTOR3__.y,o[++c]=e.__VECTOR3__.z,c++,E=0==d?this._beginGridX:this._beginGridX-1,this.calcVertextNormlUV(E,this._beginGridZ+f,_,u,p),o[c]=p.x,o[++c]=p.y,o[++c]=p.z,o[++c]=(i+0)/e.CHUNK_GRID_NUM,o[++c]=(r+f)/e.CHUNK_GRID_NUM,o[++c]=E,o[++c]=this._beginGridZ+f,c++;for(d=0;d<2;d++)for(f=0;f<m;f++)e.__VECTOR3__.x=(this._beginGridX+e.LEAF_GRID_NUM)*this._gridSize,e.__VECTOR3__.y=1==d?h[(this._beginGridZ+f)*_+(this._beginGridX+e.LEAF_GRID_NUM)]:-this._gridSize,e.__VECTOR3__.z=(this._beginGridZ+f)*this._gridSize,e.__ADAPT_MATRIX__&&bt.transformV3ToV3(e.__VECTOR3__,e.__ADAPT_MATRIX__,e.__VECTOR3__),o[c]=e.__VECTOR3__.x,o[++c]=e.__VECTOR3__.y,o[++c]=e.__VECTOR3__.z,c++,E=0==d?this._beginGridX+e.LEAF_GRID_NUM+1:this._beginGridX+e.LEAF_GRID_NUM,this.calcVertextNormlUV(E,this._beginGridZ+f,_,u,p),o[c]=p.x,o[++c]=p.y,o[++c]=p.z,o[++c]=(i+e.LEAF_GRID_NUM)/e.CHUNK_GRID_NUM,o[++c]=(r+f)/e.CHUNK_GRID_NUM,o[++c]=E,o[++c]=this._beginGridZ+f,c++},t.calcOriginalBoudingBoxAndSphere=function(){var t=new bt(this._beginGridX*this._gridSize,this._sizeOfY.x,this._beginGridZ*this._gridSize),n=new bt((this._beginGridX+e.LEAF_GRID_NUM)*this._gridSize,this._sizeOfY.y,(this._beginGridZ+e.LEAF_GRID_NUM)*this._gridSize);e.__ADAPT_MATRIX__&&(bt.transformV3ToV3(t,e.__ADAPT_MATRIX__,t),bt.transformV3ToV3(n,e.__ADAPT_MATRIX__,n)),this._originalBoundingBox=new xt(t,n);var i=new bt;bt.subtract(n,t,i),bt.scale(i,.5,i);var r=new bt;bt.add(t,i,r),this._originalBoundingSphere=new Rt(r,bt.scalarLength(i)),this._originalBoundingBoxCorners=h(8,null),this._originalBoundingBox.getCorners(this._originalBoundingBoxCorners),this._boundingBox=new xt(new bt(-.5,-.5,-.5),new bt(.5,.5,.5)),this._boundingSphere=new Rt(new bt(0,0,0),1)},t.calcLeafBoudingBox=function(e){for(var t=0;t<8;t++)bt.transformCoordinate(this._originalBoundingBoxCorners[t],e,an._tempBoundBoxCorners[t]);xt.createfromPoints(an._tempBoundBoxCorners,this._boundingBox)},t.calcLeafBoudingSphere=function(e,t){bt.transformCoordinate(this._originalBoundingSphere.center,e,this._boundingSphere.center),this._boundingSphere.radius=this._originalBoundingSphere.radius*t},t.calcLODErrors=function(t,n,i){this._LODError=new Float32Array(e._maxLODLevel+1);for(var r=1,a=0,o=e._maxLODLevel+1;a<o;a++){for(var s=0,l=0,h=e.LEAF_GRID_NUM;l<h;l+=r)for(var _=0,u=e.LEAF_GRID_NUM;_<u;_+=r)for(var c=t[(this._beginGridZ+l)*n+(this._beginGridX+_)],d=t[(this._beginGridZ+l)*n+(this._beginGridX+_)+r],f=t[(this._beginGridZ+l+r)*n+(this._beginGridX+_)],m=t[(this._beginGridZ+l+r)*n+(this._beginGridX+_)+r],p=0;p<r;p++)for(var v=p/r,E=0;E<r;E++){var g=E/r,D=t[(this._beginGridZ+l+p)*n+(this._beginGridX+_)+E],T=g+v<=1?c+(d-c)*g+(f-c)*v:m+(f-m)*(1-g)+(d-m)*(1-v),S=Math.abs(T-D);s=Math.max(s,S)}r*=2,this._LODError[a]=s}},t.determineLod=function(t,n,i,r){var a=bt.distance(t,this._boundingSphere.center),o=e._maxLODLevel;if(!r){if(this._lastDistanceToEye==a)return this._currentLODLevel;this._lastDistanceToEye>a&&(o=this._currentLODLevel)}for(var s=o;s>=1;s--)if(vi.LOD_DISTANCE_FACTOR*this._LODError[s]/a*n<i){this._currentLODLevel=s;break}return this._lastDistanceToEye=a,this._currentLODLevel},e.__init__=function(){if(!e._bInit){var t=e.CHUNK_GRID_NUM/e.LEAF_GRID_NUM*(e.CHUNK_GRID_NUM/e.LEAF_GRID_NUM);e._planeLODIndex=h(t);var n=0,i=0,r=0,a=0,o=0,s=0,l=null,_=null;for(n=0;n<t;n++)e._planeLODIndex[n]=new Array(e._maxLODLevel+1);for(n=0,a=e._maxLODLevel+1;n<a;n++)e._planeLODIndex[0][n]=e.calcPlaneLODIndex(n);for(n=1;n<t;n++)for(s=n*e.LEAF_PLANE_VERTEXT_COUNT,i=0,o=e._maxLODLevel+1;i<o;i++){for(l=e._planeLODIndex[0][i],_=new Uint16Array(l.length),r=0;r<l.length;r++)_[r]=l[r]+s;e._planeLODIndex[n][i]=_}for(e._skirtLODIndex=h(t),n=0;n<t;n++)e._skirtLODIndex[n]=new Array(e._maxLODLevel+1);for(n=0,a=e._maxLODLevel+1;n<a;n++)e._skirtLODIndex[0][n]=e.calcSkirtLODIndex(n);for(n=1;n<t;n++)for(s=n*e.LEAF_SKIRT_VERTEXT_COUNT,i=0,o=e._maxLODLevel+1;i<o;i++){for(l=e._skirtLODIndex[0][i],_=new Uint16Array(l.length),r=0;r<l.length;r++)_[r]=l[r]+s;e._skirtLODIndex[n][i]=_}e._bInit=!0}},e.getPlaneLODIndex=function(t,n){return e._planeLODIndex[t][n]},e.getSkirtLODIndex=function(t,n){return e._skirtLODIndex[t][n]},e.calcPlaneLODIndex=function(t){t>e._maxLODLevel&&(t=e._maxLODLevel);var n=e.LEAF_GRID_NUM+1,i=0,r=null,a=laya.d3.terrain.TerrainLeaf.LEAF_GRID_NUM/Math.pow(2,t);r=new Uint16Array(a*a*6);for(var o=laya.d3.terrain.TerrainLeaf.LEAF_GRID_NUM/a,s=0;s<e.LEAF_GRID_NUM;s+=o)for(var l=0;l<e.LEAF_GRID_NUM;l+=o)r[i]=(s+o)*n+l,r[++i]=s*n+l,r[++i]=s*n+l+o,r[++i]=s*n+l+o,r[++i]=(s+o)*n+l+o,r[++i]=(s+o)*n+l,i++;return r},e.calcSkirtLODIndex=function(t){t>e._maxLODLevel&&(t=e._maxLODLevel);var n=e.CHUNK_GRID_NUM/e.LEAF_GRID_NUM*(e.CHUNK_GRID_NUM/e.LEAF_GRID_NUM)*e.LEAF_PLANE_VERTEXT_COUNT,i=e.LEAF_GRID_NUM+1,r=0,a=null,o=laya.d3.terrain.TerrainLeaf.LEAF_GRID_NUM/Math.pow(2,t);a=new Uint16Array(4*o*6);for(var s=laya.d3.terrain.TerrainLeaf.LEAF_GRID_NUM/o,l=0;l<4;l++){for(var h=0;h<e.LEAF_GRID_NUM;h+=s)a[r]=n+i+h,a[++r]=n+h,a[++r]=n+h+s,a[++r]=n+h+s,a[++r]=n+i+h+s,a[++r]=n+i+h,r++;n+=2*i}return a},e.getHeightFromTerrainHeightData=function(e,t,n,i,r){return n[(t=(t=t<0?0:t)>=r?r-1:t)*i+(e=(e=e<0?0:e)>=i?i-1:e)]},e.CHUNK_GRID_NUM=64,e.LEAF_GRID_NUM=32,e.__ADAPT_MATRIX__=null,e.__ADAPT_MATRIX_INV__=null,e._planeLODIndex=null,e._skirtLODIndex=null,e._bInit=!1,o(e,["LEAF_PLANE_VERTEXT_COUNT",function(){return this.LEAF_PLANE_VERTEXT_COUNT=(e.LEAF_GRID_NUM+1)*(e.LEAF_GRID_NUM+1)},"LEAF_SKIRT_VERTEXT_COUNT",function(){return this.LEAF_SKIRT_VERTEXT_COUNT=2*(e.LEAF_GRID_NUM+1)*4},"LEAF_VERTEXT_COUNT",function(){return this.LEAF_VERTEXT_COUNT=e.LEAF_PLANE_VERTEXT_COUNT+e.LEAF_SKIRT_VERTEXT_COUNT},"LEAF_PLANE_MAX_INDEX_COUNT",function(){return this.LEAF_PLANE_MAX_INDEX_COUNT=e.LEAF_GRID_NUM*e.LEAF_GRID_NUM*6},"LEAF_SKIRT_MAX_INDEX_COUNT",function(){return this.LEAF_SKIRT_MAX_INDEX_COUNT=4*e.LEAF_GRID_NUM*6},"LEAF_MAX_INDEX_COUNT",function(){return this.LEAF_MAX_INDEX_COUNT=e.LEAF_PLANE_MAX_INDEX_COUNT+e.LEAF_SKIRT_MAX_INDEX_COUNT},"__VECTOR3__",function(){return this.__VECTOR3__=new bt},"_maxLODLevel",function(){return this._maxLODLevel=Math.log2(e.LEAF_GRID_NUM)}]),e}(),Zt=function(){function e(){this.alphaMap=null,this.detailID=null,this.normalMap=null}return s(e,"laya.d3.terrain.unit.ChunkInfo"),e}(),Yt=function(){function e(){this.diffuseTexture=null,this.normalTexture=null,this.scale=null,this.offset=null}return s(e,"laya.d3.terrain.unit.DetailTextureInfo"),e}(),jt=function(){function e(){this.ambientColor=null,this.diffuseColor=null,this.specularColor=null}return s(e,"laya.d3.terrain.unit.MaterialInfo"),e}(),Kt=function(){function e(){}return s(e,"laya.d3.utils.Physics"),e.__init__=function(){e._layerCollsionMatrix.length=31;for(var t=0;t<31;t++){var n=[],i=31-t;n.length=i;for(var r=0;r<i;r++)n[r]=r===i-1;e._layerCollsionMatrix[t]=n}},e.setLayerCollision=function(t,n,i){e._layerCollsionMatrix[t.number][30-n.number]=i},e.getLayerCollision=function(t,n){return e._layerCollsionMatrix[t.number][30-n.number]},e.setColliderCollision=function(e,t,n){n?(delete e._ignoreCollisonMap[t.id],delete t._ignoreCollisonMap[e.id]):(e._ignoreCollisonMap[t.id]=t,t._ignoreCollisonMap[e.id]=e)},e.getIColliderCollision=function(e,t){return!!e._ignoreCollisonMap[t.id]},e.rayCast=function(t,n,i,r){void 0===i&&(i=1.79e308),void 0===r&&(r=0),e._outHitAllInfo.length=0;for(var a=Z.getLayerByNumber(r)._colliders,o=0,s=a.length;o<s;o++){var l=a[o];if(l.enable&&(l.raycast(t,e._outHitInfo,i),-1!==e._outHitInfo.distance&&e._outHitInfo.distance<=i)){var h=new Qt;e._outHitInfo.cloneTo(h),e._outHitAllInfo.push(h)}}if(0==e._outHitAllInfo.length)return n.sprite3D=null,void(n.distance=-1);for(var _=Number.MAX_VALUE,u=0,c=0;c<e._outHitAllInfo.length;c++)e._outHitAllInfo[c].distance<_&&(_=e._outHitAllInfo[c].distance,u=c);e._outHitAllInfo[u].cloneTo(n)},e.rayCastAll=function(t,n,i,r){void 0===i&&(i=1.79e308),void 0===r&&(r=0),n.length=0;for(var a=Z.getLayerByNumber(r)._colliders,o=0,s=a.length;o<s;o++){var l=a[o];if(l.enable&&(e._outHitInfo.distance=-1,e._outHitInfo.sprite3D=null,l.raycast(t,e._outHitInfo,i),-1!==e._outHitInfo.distance&&e._outHitInfo.distance<=i)){var h=new Qt;e._outHitInfo.cloneTo(h),n.push(h)}}},e._outHitAllInfo=[],e._layerCollsionMatrix=[],o(e,["_outHitInfo",function(){return this._outHitInfo=new Qt},"collisionManager",function(){return this.collisionManager=new sn},"gravity",function(){return this.gravity=new bt(0,-9.81,0)}]),e}(),qt=function(){function e(){}return s(e,"laya.d3.utils.Picker"),e.calculateCursorRay=function(t,n,i,r,a,o){var s=t.elements[0],l=t.elements[1],h=e._tempVector30,_=h.elements;_[0]=s,_[1]=l,_[2]=n.minDepth;var u=e._tempVector31,c=u.elements;c[0]=s,c[1]=l,c[2]=n.maxDepth;var d=o.origin,f=e._tempVector32;n.unprojectFromWVP(h,i,r,a,d),n.unprojectFromWVP(u,i,r,a,f);var m=o.direction.elements;m[0]=f.x-d.x,m[1]=f.y-d.y,m[2]=f.z-d.z,bt.normalize(o.direction,o.direction)},e.rayIntersectsPositionsAndIndices=function(t,n,i,r,a){for(var o=i.vertexStride/4,s=i.getVertexElementByUsage(0).offset/4,l=Number.MAX_VALUE,h=-1,_=-1,u=-1,c=0;c<r.length;c+=3){var d=e._tempVector35,f=d.elements,m=r[c]*o,p=m+s;f[0]=n[p],f[1]=n[p+1],f[2]=n[p+2];var v=e._tempVector36,E=v.elements,g=r[c+1]*o,D=g+s;E[0]=n[D],E[1]=n[D+1],E[2]=n[D+2];var T=e._tempVector37,S=T.elements,x=r[c+2]*o,M=x+s;S[0]=n[M],S[1]=n[M+1],S[2]=n[M+2];var R=laya.d3.utils.Picker.rayIntersectsTriangle(t,d,v,T);!isNaN(R)&&R<l&&(l=R,h=m,_=g,u=x)}if(l!==Number.MAX_VALUE){a.distance=l,bt.scale(t.direction,l,a.position),bt.add(t.origin,a.position,a.position);var A=a.trianglePositions,I=A[0],y=A[1],C=A[2],N=I.elements,O=y.elements,w=C.elements,V=h+s;N[0]=n[V],N[1]=n[V+1],N[2]=n[V+2];var P=_+s;O[0]=n[P],O[1]=n[P+1],O[2]=n[P+2];var L=u+s;w[0]=n[L],w[1]=n[L+1],w[2]=n[L+2];var b=i.getVertexElementByUsage(3);if(b){var F=b.offset/4,B=a.triangleNormals,U=B[0],H=B[1],G=B[2],z=U.elements,W=H.elements,k=G.elements,X=h+F;z[0]=n[X],z[1]=n[X+1],z[2]=n[X+2];var Z=_+F;W[0]=n[Z],W[1]=n[Z+1],W[2]=n[Z+2];var Y=u+F;k[0]=n[Y],k[1]=n[Y+1],k[2]=n[Y+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=e._tempVector30,o=e._tempVector31;bt.subtract(i,n,a),bt.subtract(r,n,o);var s,l=e._tempVector32;if(bt.cross(t.direction,o,l),(s=bt.dot(a,l))>-Number.MIN_VALUE&&s<Number.MIN_VALUE)return Number.NaN;var h,_=1/s,u=e._tempVector33;if(bt.subtract(t.origin,n,u),h=bt.dot(u,l),(h*=_)<0||h>1)return Number.NaN;var c,d,f=e._tempVector34;return bt.cross(u,a,f),c=bt.dot(t.direction,f),(c*=_)<0||h+c>1?Number.NaN:(d=bt.dot(o,f),(d*=_)<0?Number.NaN:d)},o(e,["_tempVector30",function(){return this._tempVector30=new bt},"_tempVector31",function(){return this._tempVector31=new bt},"_tempVector32",function(){return this._tempVector32=new bt},"_tempVector33",function(){return this._tempVector33=new bt},"_tempVector34",function(){return this._tempVector34=new bt},"_tempVector35",function(){return this._tempVector35=new bt},"_tempVector36",function(){return this._tempVector36=new bt},"_tempVector37",function(){return this._tempVector37=new bt}]),e}(),Qt=function(){function e(){this.distance=NaN,this.trianglePositions=null,this.triangleNormals=null,this.position=null,this.sprite3D=null,this.distance=-1,this.trianglePositions=[new bt,new bt,new bt],this.trianglePositions.length=3,this.triangleNormals=[new bt,new bt,new bt],this.triangleNormals.length=3,this.position=new bt}return s(e,"laya.d3.utils.RaycastHit"),e.prototype.cloneTo=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.sprite3D=this.sprite3D},e}(),$t=function(){function e(e,t){this._width=0,this._height=0,this._width=e,this._height=t}s(e,"laya.d3.utils.Size");var t=e.prototype;return l(0,t,"width",function(){return-1===this._width?me.clientWidth:this._width}),l(0,t,"height",function(){return-1===this._height?me.clientHeight:this._height}),l(1,e,"fullScreen",function(){return new e(-1,-1)}),e}(),Jt=function(){function e(){}return s(e,"laya.d3.utils.Utils3D"),e._rotationTransformScaleSkinAnimation=function(t,n,i,r,a,o,s,l,h,_,u,c){var d,f,m,p,v,E=e._tempArray16_0,g=e._tempArray16_1,D=e._tempArray16_2,T=r+r,S=a+a,x=o+o,M=r*T,R=a*T,A=a*S,I=o*T,y=o*S,C=o*x,N=s*T,O=s*S,w=s*x;for(E[15]=1,E[0]=1-A-C,E[1]=R+w,E[2]=I-O,E[4]=R-w,E[5]=1-M-C,E[6]=y+N,E[8]=I+O,E[9]=y-N,E[10]=1-M-A,g[15]=1,g[0]=l,g[5]=h,g[10]=_,d=0;d<4;d++)f=E[d],m=E[d+4],p=E[d+8],v=E[d+12],D[d]=f,D[d+4]=m,D[d+8]=p,D[d+12]=f*t+m*n+p*i+v;for(d=0;d<4;d++)f=D[d],m=D[d+4],p=D[d+8],v=D[d+12],u[d+c]=f*g[0]+m*g[1]+p*g[2]+v*g[3],u[d+c+4]=f*g[4]+m*g[5]+p*g[6]+v*g[7],u[d+c+8]=f*g[8]+m*g[9]+p*g[10]+v*g[11],u[d+c+12]=f*g[12]+m*g[13]+p*g[14]+v*g[15]},e._createNodeByJson=function(t,n,i,r){if(!i)switch(n.type){case"Sprite3D":i=new Hn;break;case"MeshSprite3D":i=new Di;break;case"SkinnedMeshSprite3D":i=new Si;break;case"ShuriKenParticle3D":i=new Ti;break;case"TrailSprite3D":i=new xi;break;case"LineSprite3D":break;case"Terrain":i=new vi;break;case"Camera":i=new Ei;break;case"DirectionLight":i=new gi;break;default:throw new Error("Utils3D:unidentified class type in (.lh) file.")}var a=n.props;if(a)for(var o in a)i[o]=a[o];var s=n.customProps;s&&(i instanceof laya.d3.core.Sprite3D?(i._parseBaseCustomProps(s),i._parseCustomProps(t,r,s,n),i._parseCustomComponent(t,r,n.components)):i._parseCustomProps(t,r,s,n));var l=n.child;if(l)for(var h=0,_=l.length;h<_;h++){var u=e._createNodeByJson(t,l[h],null,r);i.addChild(u)}return i},e._computeBoneAndAnimationDatasByBindPoseMatrxix=function(e,t,n,i,r,a){var o,s,l=0,h=0,_=e.length;for(o=0;o<_;l+=e[o].keyframeWidth,h+=16,o++)laya.d3.utils.Utils3D._rotationTransformScaleSkinAnimation(t[l+0],t[l+1],t[l+2],t[l+3],t[l+4],t[l+5],t[l+6],t[l+7],t[l+8],t[l+9],i,h),0!=o&&(s=16*e[o].parentIndex,laya.d3.utils.Utils3D.mulMatrixByArray(i,s,i,h,i,h));var u=n.length;for(o=0;o<u;o++)laya.d3.utils.Utils3D.mulMatrixByArrayAndMatrixFast(i,16*a[o],n[o],r,16*o)},e._computeAnimationDatasByArrayAndMatrixFast=function(e,t,n,i){for(var r=0,a=e.length;r<a;r++)laya.d3.utils.Utils3D.mulMatrixByArrayAndMatrixFast(t,16*i[r],e[r],n,16*r)},e._computeBoneAndAnimationDatasByBindPoseMatrxixOld=function(e,t,n,i,r){var a,o,s=0,l=0,h=e.length;for(a=0;a<h;s+=e[a].keyframeWidth,l+=16,a++)laya.d3.utils.Utils3D._rotationTransformScaleSkinAnimation(t[s+7],t[s+8],t[s+9],t[s+3],t[s+4],t[s+5],t[s+6],t[s+0],t[s+1],t[s+2],i,l),0!=a&&(o=16*e[a].parentIndex,laya.d3.utils.Utils3D.mulMatrixByArray(i,o,i,l,i,l));var _=n.length;for(a=0;a<_;a++){var u=16*a;laya.d3.utils.Utils3D.mulMatrixByArrayAndMatrixFast(i,u,n[a],r,u)}},e._computeAnimationDatasByArrayAndMatrixFastOld=function(e,t,n){for(var i=e.length,r=0;r<i;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,o=e.length;i<o;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.transformVector3ArrayByQuat=function(e,t,n,i,r){var a=n.elements,o=e[t],s=e[t+1],l=e[t+2],h=a[0],_=a[1],u=a[2],c=a[3],d=c*o+_*l-u*s,f=c*s+u*o-h*l,m=c*l+h*s-_*o,p=-h*o-_*s-u*l;i[r]=d*c+p*-h+f*-u-m*-_,i[r+1]=f*c+p*-_+m*-h-d*-u,i[r+2]=m*c+p*-u+d*-_-f*-h},e.mulMatrixByArray=function(t,n,i,r,a,o){var s,l,h,_,u;if(a===i){for(i=e._tempArray16_3,s=0;s<16;++s)i[s]=a[o+s];r=0}for(s=0;s<4;s++)l=t[n+s],h=t[n+s+4],_=t[n+s+8],u=t[n+s+12],a[o+s]=l*i[r+0]+h*i[r+1]+_*i[r+2]+u*i[r+3],a[o+s+4]=l*i[r+4]+h*i[r+5]+_*i[r+6]+u*i[r+7],a[o+s+8]=l*i[r+8]+h*i[r+9]+_*i[r+10]+u*i[r+11],a[o+s+12]=l*i[r+12]+h*i[r+13]+_*i[r+14]+u*i[r+15]},e.mulMatrixByArrayFast=function(e,t,n,i,r,a){var o,s,l,h,_;for(o=0;o<4;o++)s=e[t+o],l=e[t+o+4],h=e[t+o+8],_=e[t+o+12],r[a+o]=s*n[i+0]+l*n[i+1]+h*n[i+2]+_*n[i+3],r[a+o+4]=s*n[i+4]+l*n[i+5]+h*n[i+6]+_*n[i+7],r[a+o+8]=s*n[i+8]+l*n[i+9]+h*n[i+10]+_*n[i+11],r[a+o+12]=s*n[i+12]+l*n[i+13]+h*n[i+14]+_*n[i+15]},e.mulMatrixByArrayAndMatrixFast=function(e,t,n,i,r){var a,o,s,l,h,_=n.elements,u=_[0],c=_[1],d=_[2],f=_[3],m=_[4],p=_[5],v=_[6],E=_[7],g=_[8],D=_[9],T=_[10],S=_[11],x=_[12],M=_[13],R=_[14],A=_[15],I=t,y=t+4,C=t+8,N=t+12,O=r,w=r+4,V=r+8,P=r+12;for(a=0;a<4;a++)o=e[I+a],s=e[y+a],l=e[C+a],h=e[N+a],i[O+a]=o*u+s*c+l*d+h*f,i[w+a]=o*m+s*p+l*v+h*E,i[V+a]=o*g+s*D+l*T+h*S,i[P+a]=o*x+s*M+l*R+h*A},e.createAffineTransformationArray=function(e,t,n,i,r,a,o,s,l,h,_,u){var c=i+i,d=r+r,f=a+a,m=i*c,p=i*d,v=i*f,E=r*d,g=r*f,D=a*f,T=o*c,S=o*d,x=o*f;_[u+0]=(1-(E+D))*s,_[u+1]=(p+x)*s,_[u+2]=(v-S)*s,_[u+3]=0,_[u+4]=(p-x)*l,_[u+5]=(1-(m+D))*l,_[u+6]=(g+T)*l,_[u+7]=0,_[u+8]=(v+S)*h,_[u+9]=(g-T)*h,_[u+10]=(1-(m+E))*h,_[u+11]=0,_[u+12]=e,_[u+13]=t,_[u+14]=n,_[u+15]=1},e.transformVector3ArrayToVector3ArrayCoordinate=function(t,n,i,r,a){var o=e._tempArray4_0,s=t[n+0],l=t[n+1],h=t[n+2],_=i.elements;o[0]=s*_[0]+l*_[4]+h*_[8]+_[12],o[1]=s*_[1]+l*_[5]+h*_[9]+_[13],o[2]=s*_[2]+l*_[6]+h*_[10]+_[14],o[3]=1/(s*_[3]+l*_[7]+h*_[11]+_[15]),r[a+0]=o[0]*o[3],r[a+1]=o[1]*o[3],r[a+2]=o[2]*o[3]},e.transformLightingMapTexcoordByUV0Array=function(e,t,n,i,r){var a=n.elements;i[r+0]=e[t+0]*a[0]+a[2],i[r+1]=(e[t+1]-1)*a[1]+a[3]},e.transformLightingMapTexcoordByUV1Array=function(e,t,n,i,r){var a=n.elements;i[r+0]=e[t+0]*a[0]+a[2],i[r+1]=1+e[t+1]*a[1]+a[3]},e.getURLVerion=function(e){var t=e.indexOf("?");return t>=0?e.substr(t):null},e._quaternionCreateFromYawPitchRollArray=function(e,t,n,i){var r=.5*n,a=.5*t,o=.5*e,s=Math.sin(r),l=Math.cos(r),h=Math.sin(a),_=Math.cos(a),u=Math.sin(o),c=Math.cos(o);i[0]=c*h*l+u*_*s,i[1]=u*_*l-c*h*s,i[2]=c*_*s-u*h*l,i[3]=c*_*l+u*h*s},e._createAffineTransformationArray=function(e,t,n,i){var r=t[0],a=t[1],o=t[2],s=t[3],l=r+r,h=a+a,_=o+o,u=r*l,c=r*h,d=r*_,f=a*h,m=a*_,p=o*_,v=s*l,E=s*h,g=s*_,D=n[0],T=n[1],S=n[2];i[0]=(1-(f+p))*D,i[1]=(c+g)*D,i[2]=(d-E)*D,i[3]=0,i[4]=(c-g)*T,i[5]=(1-(u+p))*T,i[6]=(m+v)*T,i[7]=0,i[8]=(d+E)*S,i[9]=(m-v)*S,i[10]=(1-(u+f))*S,i[11]=0,i[12]=e[0],i[13]=e[1],i[14]=e[2],i[15]=1},e._mulMatrixArray=function(e,t,n,i){var r,a,o,s,l,h=t.elements,_=h[0],u=h[1],c=h[2],d=h[3],f=h[4],m=h[5],p=h[6],v=h[7],E=h[8],g=h[9],D=h[10],T=h[11],S=h[12],x=h[13],M=h[14],R=h[15],A=i,I=i+4,y=i+8,C=i+12;for(r=0;r<4;r++)a=e[r],o=e[r+4],s=e[r+8],l=e[r+12],n[A+r]=a*_+o*u+s*c+l*d,n[I+r]=a*f+o*m+s*p+l*v,n[y+r]=a*E+o*g+s*D+l*T,n[C+r]=a*S+o*x+s*M+l*R},e.getYawPitchRoll=function(t,n){e.transformQuat(bt.ForwardRH,t,wt.TEMPVector31),e.transformQuat(bt.Up,t,wt.TEMPVector32);var i=wt.TEMPVector32.elements;e.angleTo(bt.ZERO,wt.TEMPVector31,wt.TEMPVector33);var r=wt.TEMPVector33.elements;r[0]==Math.PI/2?(r[1]=e.arcTanAngle(i[2],i[0]),r[2]=0):r[0]==-Math.PI/2?(r[1]=e.arcTanAngle(-i[2],-i[0]),r[2]=0):(Ct.createRotationY(-r[1],wt.TEMPMatrix0),Ct.createRotationX(-r[0],wt.TEMPMatrix1),bt.transformCoordinate(wt.TEMPVector32,wt.TEMPMatrix0,wt.TEMPVector32),bt.transformCoordinate(wt.TEMPVector32,wt.TEMPMatrix1,wt.TEMPVector32),r[2]=e.arcTanAngle(i[1],-i[0])),r[1]<=-Math.PI&&(r[1]=Math.PI),r[2]<=-Math.PI&&(r[2]=Math.PI),r[1]>=Math.PI&&r[2]>=Math.PI&&(r[1]=0,r[2]=0,r[0]=Math.PI-r[0]),n[0]=r[1],n[1]=r[0],n[2]=r[2]},e.arcTanAngle=function(e,t){return 0==e?1==t?Math.PI/2:-Math.PI/2:e>0?Math.atan(t/e):e<0?t>0?Math.atan(t/e)+Math.PI:Math.atan(t/e)-Math.PI:0},e.angleTo=function(t,n,i){bt.subtract(n,t,wt.TEMPVector30),bt.normalize(wt.TEMPVector30,wt.TEMPVector30),i.elements[0]=Math.asin(wt.TEMPVector30.y),i.elements[1]=e.arcTanAngle(-wt.TEMPVector30.z,-wt.TEMPVector30.x)},e.transformQuat=function(e,t,n){var i=n.elements,r=e.elements,a=t,o=r[0],s=r[1],l=r[2],h=a[0],_=a[1],u=a[2],c=a[3],d=c*o+_*l-u*s,f=c*s+u*o-h*l,m=c*l+h*s-_*o,p=-h*o-_*s-u*l;i[0]=d*c+p*-h+f*-u-m*-_,i[1]=f*c+p*-_+m*-h-d*-u,i[2]=m*c+p*-u+d*-_-f*-h},e.quaterionNormalize=function(e,t){var n=e[0],i=e[1],r=e[2],a=e[3],o=n*n+i*i+r*r+a*a;o>0&&(o=1/Math.sqrt(o),t[0]=n*o,t[1]=i*o,t[2]=r*o,t[3]=a*o)},e.matrix4x4MultiplyFFF=function(e,t,n){var i,r,a,o,s;if(n===t)for(t=new Float32Array(16),i=0;i<16;++i)t[i]=n[i];for(i=0;i<4;i++)r=e[i],a=e[i+4],o=e[i+8],s=e[i+12],n[i]=r*t[0]+a*t[1]+o*t[2]+s*t[3],n[i+4]=r*t[4]+a*t[5]+o*t[6]+s*t[7],n[i+8]=r*t[8]+a*t[9]+o*t[10]+s*t[11],n[i+12]=r*t[12]+a*t[13]+o*t[14]+s*t[15]},e.matrix4x4MultiplyMFM=function(t,n,i){e.matrix4x4MultiplyFFF(t.elements,n,i.elements)},e._tempVector3_0=new bt,e._tempVector3_1=new bt,e._tempVector3_2=new bt,e._tempVector3_3=new bt,e._tempVector3_4=new bt,e._tempVector3_5=new bt,e._tempVector3_6=new bt,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),o(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}(),en=function(){function e(){}return s(e,"Laya3D"),e._cancelLoadByUrl=function(t){a.loader.cancelLoadByUrl(t),e._innerFirstLevelLoaderManager.cancelLoadByUrl(t),e._innerSecondLevelLoaderManager.cancelLoadByUrl(t),e._innerThirdLevelLoaderManager.cancelLoadByUrl(t),e._innerFourthLevelLoaderManager.cancelLoadByUrl(t)},e._changeWebGLSize=function(e,t){b.onStageResize(e,t),me.clientWidth=e,me.clientHeight=t},e.__init__=function(){var t=x.createMap;t.lh=[Hn,"SPRITE3DHIERARCHY"],t.ls=[Un,"SPRITE3DHIERARCHY"],t.lm=[si,"MESH"],t.lmat=[jn,"MATERIAL"],t.lpbr=[Xn,"MATERIAL"],t.ltc=[ci,"TEXTURECUBE"],t.jpg=[ui,"nativeimage"],t.jpeg=[ui,"nativeimage"],t.png=[ui,"nativeimage"],t.pkm=[ui,"arraybuffer"],t.lsani=[u,"arraybuffer"],t.lrani=[u,"arraybuffer"],t.raw=[ai,"arraybuffer"],t.mipmaps=[ai,"arraybuffer"],t.thdata=[xn,"arraybuffer"],t.lt=[Mn,"TERRAIN"],t.lani=[En,"arraybuffer"],t.lav=[gn,"json"],t.ani=[u,"arraybuffer"],S.parserMap.SPRITE3DHIERARCHY=e._loadHierarchy,S.parserMap.MESH=e._loadMesh,S.parserMap.MATERIAL=e._loadMaterial,S.parserMap.TEXTURECUBE=e._loadTextureCube,S.parserMap.TERRAIN=e._loadTerrain,e._innerFirstLevelLoaderManager.on("error",null,e._eventLoadManagerError),e._innerSecondLevelLoaderManager.on("error",null,e._eventLoadManagerError),e._innerThirdLevelLoaderManager.on("error",null,e._eventLoadManagerError),e._innerFourthLevelLoaderManager.on("error",null,e._eventLoadManagerError)},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")&&-1===r.lastIndexOf(".lpbr")||t.push(r)}return t},e.formatRelativePath=function(e,t){var n;if("."===t.charAt(0)){for(var i=(e+t).split("/"),r=0,a=i.length;r<a;r++)if(".."==i[r]){var o=r-1;o>0&&".."!==i[o]&&(i.splice(o,2),r-=2)}n=i.join("/")}else n=e+t;return null!=P.customFormat&&(n=P.customFormat(n,null)),n},e._eventLoadManagerError=function(e){a.loader.event("error",e)},e._addHierarchyInnerUrls=function(t,n,i,r,a,o){var s=e.formatRelativePath(r,a);i&&(s+=i),t.push({url:s,clas:o}),n[a]=s},e._getSprite3DHierarchyInnerUrls=function(t,n,i,r,a,o,s){var l,h=0,_=0;switch(t.type){case"Scene":var u=t.customProps.lightmaps;for(h=0,_=u.length;h<_;h++){var c=u[h].replace(".exr",".png");e._addHierarchyInnerUrls(r,a,o,s,c,ui)}break;case"MeshSprite3D":case"TrailSprite3D":case"LineSprite3D":case"SkinnedMeshSprite3D":var d;if(t.instanceParams)(d=t.instanceParams.loadPath)&&e._addHierarchyInnerUrls(n,a,o,s,d,si);else{(d=(l=t.customProps).meshPath)&&e._addHierarchyInnerUrls(n,a,o,s,d,si);var f=l.materials;if(f)for(h=0,_=f.length;h<_;h++){var p=f[h],v=p.type.split("."),E=m.window;if(v.forEach(function(e){E=E[e]}),"function"!=typeof E)throw"_getSprite3DHierarchyInnerUrls 错误: "+p.type+" 不是类";e._addHierarchyInnerUrls(i,a,o,s,p.path,E)}}break;case"ShuriKenParticle3D":var g=(l=t.customProps).meshPath;g&&e._addHierarchyInnerUrls(n,a,o,s,g,si);var D=l.material;if(D)v=D.type.split("."),E=m.window,v.forEach(function(e){E=E[e]}),e._addHierarchyInnerUrls(i,a,o,s,D.path,E);else{var T=l.materialPath;if(T)e._addHierarchyInnerUrls(i,a,o,s,T,Jn);else{var S=l.texturePath;S&&e._addHierarchyInnerUrls(r,a,o,s,S,ui)}}break;case"Terrain":e._addHierarchyInnerUrls(r,a,o,s,t.customProps.dataPath,Mn)}var x=t.components;for(var M in x){var R=x[M];switch(M){case"Animator":var A=R.avatarPath;if(A)e._addHierarchyInnerUrls(r,a,o,s,A,gn);else{var I=R.avatar;I&&e._addHierarchyInnerUrls(r,a,o,s,I.path,gn)}var y=R.clipPaths;for(h=0,_=y.length;h<_;h++)e._addHierarchyInnerUrls(r,a,o,s,y[h],En)}}var C=t.child;for(h=0,_=C.length;h<_;h++)e._getSprite3DHierarchyInnerUrls(C[h],n,i,r,a,o,s)},e._loadHierarchy=function(t){t.on("loaded",null,e._onHierarchylhLoaded,[t,t._class._getGroup()]),t.load(t.url,"json",!1,null,!0)},e._onHierarchylhLoaded=function(t,n,i){if(t._class.destroyed)t.endLoad();else{var r=t.url,a=Jt.getURLVerion(r),o=P.getPath(r),s=[],l=[],h=[],_={};e._getSprite3DHierarchyInnerUrls(i,s,l,h,_,a,o);var u=s.length+l.length+h.length,c=u+1,d=1/c;if(e._onProcessChange(t,0,d,1),h.length>0){var f=u/c,m=T.create(null,e._onProcessChange,[t,d,f],!1);e._innerFourthLevelLoaderManager.create(h,T.create(null,e._onHierarchyInnerForthLevResouLoaded,[t,n,m,i,_,s,l,d+f*h.length,f]),m,null,null,1,!0,n)}else e._onHierarchyInnerForthLevResouLoaded(t,n,null,i,_,s,l,d,f)}},e._onHierarchyInnerForthLevResouLoaded=function(t,n,i,r,a,o,s,l,h){if(t._class.destroyed)t.endLoad();else if(i&&i.recover(),s.length>0){var _=T.create(null,e._onProcessChange,[t,l,h],!1);e._innerSecondLevelLoaderManager.create(s,T.create(null,e._onHierarchyInnerSecondLevResouLoaded,[t,n,_,r,a,o,l+h*s.length,h]),i,null,null,1,!0,n)}else e._onHierarchyInnerSecondLevResouLoaded(t,n,null,r,a,o,l,h)},e._onHierarchyInnerSecondLevResouLoaded=function(t,n,i,r,a,o,s,l){if(t._class.destroyed)t.endLoad();else if(i&&i.recover(),o.length>0){var h=T.create(null,e._onProcessChange,[t,s,l],!1);e._innerFirstLevelLoaderManager.create(o,T.create(null,e._onHierarchyInnerFirstLevResouLoaded,[t,h,r,a]),i,null,null,1,!0,n)}else e._onHierarchyInnerFirstLevResouLoaded(t,null,r,a)},e._onHierarchyInnerFirstLevResouLoaded=function(e,t,n,i){t&&t.recover(),e.endLoad([n,i])},e._loadTerrain=function(t){t.on("loaded",null,e._onTerrainLtLoaded,[t,t._class._getGroup()]),t.load(t.url,"json",!1,null,!0)},e._onTerrainLtLoaded=function(t,n,i){if(t._class.destroyed)t.endLoad();else{var r,a,o=t.url,s=Jt.getURLVerion(o),l=P.getPath(o),h=[],_={},u=0,c=0,d=i.heightData;r=d.url,a=e.formatRelativePath(l,r),s&&(a+=s),_[r]=a,r=a;var f=i.detailTexture;for(u=0,c=f.length;u<c;u++)h.push({url:f[u].diffuse});var m=i.normalMap;for(u=0,c=m.length;u<c;u++)h.push({url:m[u]});var p=i.alphaMap;for(u=0,c=p.length;u<c;u++)h.push({url:p[u],params:[!1,!1,6408,!0]});for(u=0,c=h.length;u<c;u++){var v=h[u].url;a=e.formatRelativePath(l,v),s&&(a+=s),h[u].url=a,_[v]=a}var E=h.length,g=E+2,D=1/g;e._onProcessChange(t,0,D,1);var S={heightMapLoaded:!1,texturesLoaded:!1},x=T.create(null,e._onProcessChange,[t,D,D],!1);e._innerFourthLevelLoaderManager.create(r,T.create(null,e._onTerrainHeightMapLoaded,[t,x,i,_,S]),x,null,[d.numX,d.numZ,d.bitType,d.value],1,!0,n);var M=T.create(null,e._onProcessChange,[t,2*D,E/g],!1);e._innerFourthLevelLoaderManager.create(h,T.create(null,e._onTerrainTexturesLoaded,[t,M,i,_,S]),M,null,null,1,!0,n)}},e._onTerrainHeightMapLoaded=function(e,t,n,i,r){r.heightMapLoaded=!0,r.texturesLoaded&&(e.endLoad([n,i]),t.recover())},e._onTerrainTexturesLoaded=function(e,t,n,i,r){r.texturesLoaded=!0,r.heightMapLoaded&&(e.endLoad([n,i]),t.recover())},e._loadMesh=function(t){t.on("loaded",null,e._onMeshLmLoaded,[t,t._class._getGroup()]),t.load(t.url,"arraybuffer",!1,null,!0)},e._onMeshLmLoaded=function(t,n,i){if(t._class.destroyed)t.endLoad();else{var r,a,o,s=t.url,l=Jt.getURLVerion(s),h=P.getPath(s),_={},u=0,c=0;switch((e._readData=new v(i)).pos=0,e._readData.readUTFString()){case"LAYAMODEL:02":case"LAYAMODEL:03":case"LAYAMODEL:0301":var d=e._readData.getUint32();e._readData.pos=e._readData.pos+4,c=e._readData.getUint16(),e._readData.pos=e._readData.pos+8*c;var f=e._readData.getUint32();for(c=e._readData.getUint16(),e._readData.pos=d+f,r=[],u=0;u<c;u++){var m=e._readData.readUTFString();-1!==m.lastIndexOf(".lmat")&&r.push(m)}break;default:for(e.READ_BLOCK(),u=0;u<2;u++){var p=e._readData.getUint16(),E=e._strings[p],g=e["READ_"+E];if(null==g)throw new Error("model file err,no this function:"+p+" "+E);1===u?r=g.call():g.call()}}for(u=0,o=r.length;u<o;u++){var D=r[u];a=e.formatRelativePath(h,D),l&&(a+=l),r[u]=a,_[D]=a}if(r.length>0){e._onProcessChange(t,0,.5,1);var S=T.create(null,e._onProcessChange,[t,.5,.5],!1);e._innerSecondLevelLoaderManager.create(r,T.create(null,e._onMeshMateialLoaded,[t,S,i,_]),S,null,null,1,!0,n)}else t.endLoad([i,_])}},e._onMeshMateialLoaded=function(e,t,n,i){e.endLoad([n,i]),t.recover()},e._getMaterialTexturePath=function(t,n,i){var r=t.length-4;return t.indexOf(".dds")!=r&&t.indexOf(".tga")!=r&&t.indexOf(".exr")!=r&&t.indexOf(".DDS")!=r&&t.indexOf(".TGA")!=r&&t.indexOf(".EXR")!=r||(t=t.substr(0,r)+".png"),t=e.formatRelativePath(i,t),n&&(t+=n),t},e._loadMaterial=function(t){t.on("loaded",null,e._onMaterilLmatLoaded,[t,t._class._getGroup()]),t.load(t.url,"json",!1,null,!0)},e._onMaterilLmatLoaded=function(t,n,i){if(t._class.destroyed)t.endLoad();else{var r,a=t.url,o=Jt.getURLVerion(a),s=P.getPath(a),l=[],h={},_=i.customProps,u=i.version;if(u)switch(u){case"LAYAMATERIAL:01":for(var c=i.props.textures,d=0,f=c.length;d<f;d++){var m=c[d],p=m.path;if(p){var v=p.length-4;p.indexOf(".exr")!=v&&p.indexOf(".EXR")!=v||(p=p.substr(0,v)+".png"),r=e.formatRelativePath(s,p),o&&(r+=o),l.push({url:r,params:m.params}),h[p]=r}}break;default:throw new Error("Laya3D:unkonwn version.")}else{var E=_.diffuseTexture.texture2D;if(E&&(r=e._getMaterialTexturePath(E,o,s),l.push(r),h[E]=r),_.normalTexture){var g=_.normalTexture.texture2D;g&&(r=e._getMaterialTexturePath(g,o,s),l.push(r),h[g]=r)}if(_.specularTexture){var D=_.specularTexture.texture2D;D&&(r=e._getMaterialTexturePath(D,o,s),l.push(r),h[D]=r)}if(_.emissiveTexture){var S=_.emissiveTexture.texture2D;S&&(r=e._getMaterialTexturePath(S,o,s),l.push(r),h[S]=r)}if(_.ambientTexture){var x=_.ambientTexture.texture2D;x&&(r=e._getMaterialTexturePath(x,o,s),l.push(r),h[x]=r)}if(_.reflectTexture){var M=_.reflectTexture.texture2D;M&&(r=e._getMaterialTexturePath(M,o,s),l.push(r),h[M]=r)}}var R=l.length,A=R+1,I=1/A;if(e._onProcessChange(t,0,I,1),R>0){var y=T.create(null,e._onProcessChange,[t,I,R/A],!1);e._innerFourthLevelLoaderManager.create(l,T.create(null,e._onMateialTexturesLoaded,[t,y,i,h]),y,ui,null,1,!0,n)}else e._onMateialTexturesLoaded(t,null,i,null)}},e._onMateialTexturesLoaded=function(e,t,n,i){e.endLoad([n,i]),t&&t.recover()},e._loadTextureCube=function(t){t.on("loaded",null,e._onTextureCubeLtcLoaded,[t]),t.load(t.url,"json",!1,null,!0)},e._onTextureCubeLtcLoaded=function(t,n){if(t._class.destroyed)t.endLoad();else{var i=P.getPath(t.url),r=[e.formatRelativePath(i,n.px),e.formatRelativePath(i,n.nx),e.formatRelativePath(i,n.py),e.formatRelativePath(i,n.ny),e.formatRelativePath(i,n.pz),e.formatRelativePath(i,n.nz)];e._onProcessChange(t,0,1/7,1);var a=T.create(null,e._onProcessChange,[t,1/7,6/7],!1);e._innerFourthLevelLoaderManager.load(r,T.create(null,e._onTextureCubeImagesLoaded,[t,r,a]),a,"nativeimage")}},e._onTextureCubeImagesLoaded=function(e,t,n){var i=[];i.length=6;for(var r=0;r<6;r++){var a=t[r];i[r]=S.getRes(a),S.clearRes(a)}e.endLoad(i),n.recover()},e._onProcessChange=function(e,t,n,i){(i=t+i*n)<1&&e.event("progress",i)},e.init=function(t,n,i,r,o,s){void 0===i&&(i=!1),void 0===r&&(r=!1),void 0===o&&(o=!0),void 0===s&&(s=!0),C.update3DLoop=function(){sn._triggerCollision()},C.cancelLoadByUrl=function(t){e._cancelLoadByUrl(t)},g.isAntialias=i,g.isAlpha=r,g.premultipliedAlpha=o,g.isStencil=s,b.enable()?(C.changeWebGLSize=e._changeWebGLSize,A.is3DMode=!0,a.init(t,n),Z.__init__(),Kt.__init__(),zt.__init__(),Di.__init__(),G.__init__(),e.__init__(),d.maxTextureCount=2,(e.debugMode||pe.debugMode)&&(e._debugPhasorSprite=new ce)):alert("Laya3D init error,must support webGL!")},e.HIERARCHY="SPRITE3DHIERARCHY",e.MESH="MESH",e.MATERIAL="MATERIAL",e.PBRMATERIAL="PBRMTL",e.TEXTURECUBE="TEXTURECUBE",e.TERRAIN="TERRAIN",e._readData=null,e._debugPhasorSprite=null,e.debugMode=!1,o(e,["_DATA",function(){return this._DATA={offset:0,size:0}},"_strings",function(){return this._strings=["BLOCK","DATA","STRINGS"]},"_innerFirstLevelLoaderManager",function(){return this._innerFirstLevelLoaderManager=new x},"_innerSecondLevelLoaderManager",function(){return this._innerSecondLevelLoaderManager=new x},"_innerThirdLevelLoaderManager",function(){return this._innerThirdLevelLoaderManager=new x},"_innerFourthLevelLoaderManager",function(){return this._innerFourthLevelLoaderManager=new x}]),e}(),tn=function(e){function t(e){t.__super.call(this),this._owner=e,this._childs=[],this._localMatrix=new Float32Array(16),this._localQuaternionUpdate=!1,this._locaEulerlUpdate=!1,this._localUpdate=!1,this._worldUpdate=!0}s(t,"laya.d3.animation.AnimationTransform3D",D);var n=t.prototype;return n._getlocalMatrix=function(){return this._localUpdate&&(Jt._createAffineTransformationArray(this._localPosition,this._localRotation,this._localScale,this._localMatrix),this._localUpdate=!1),this._localMatrix},n._onWorldTransform=function(){if(!this._worldUpdate){this._worldUpdate=!0;for(var e=0,t=this._childs.length;e<t;e++)this._childs[e]._onWorldTransform()}},n._setWorldMatrixAndUpdate=function(e){if(this._worldMatrix=e,null==this._parent)throw new Error("don't need to set worldMatrix to root Node.");if(null==this._parent._parent)for(var t=this._getlocalMatrix(),n=0;n<16;++n)this._worldMatrix[n]=t[n];else Jt.matrix4x4MultiplyFFF(this._parent.getWorldMatrix(),this._getlocalMatrix(),this._worldMatrix);this._worldUpdate=!1},n._setWorldMatrixNoUpdate=function(e){this._worldMatrix=e},n._setWorldMatrixIgnoreUpdate=function(e){this._worldMatrix=e,this._worldUpdate=!1},n.getLocalPosition=function(){return this._localPosition},n.setLocalPosition=function(e){if(this._parent)this._localPosition=e,this._localUpdate=!0,this._onWorldTransform();else{var t=this._entity.owner._transform,n=this._entity.localPosition,i=n.elements;i[0]=e[0],i[1]=e[1],i[2]=e[2],t.localPosition=n}},n.getLocalRotation=function(){if(this._localQuaternionUpdate){var e=this._localRotationEuler;Jt._quaternionCreateFromYawPitchRollArray(e[1]/t._angleToRandin,e[0]/t._angleToRandin,e[2]/t._angleToRandin,this._localRotation),this._localQuaternionUpdate=!1}return this._localRotation},n.setLocalRotation=function(e){if(this._parent)this._localRotation=e,Jt.quaterionNormalize(this._localRotation,this._localRotation),this._locaEulerlUpdate=!0,this._localQuaternionUpdate=!1,this._localUpdate=!0,this._onWorldTransform();else{var t=this._entity.owner._transform,n=this._entity.localRotation,i=n.elements;i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],t.localRotation=n}},n.getLocalScale=function(){return this._localScale},n.setLocalScale=function(e){if(this._parent)this._localScale=e,this._localUpdate=!0,this._onWorldTransform();else{var t=this._entity.owner._transform,n=this._entity.localScale,i=n.elements;i[0]=e[0],i[1]=e[1],i[2]=e[2],t.localScale=n}},n.getLocalRotationEuler=function(){if(this._locaEulerlUpdate){Jt.getYawPitchRoll(this._localRotation,t._tempVector3);var e=t._tempVector3,n=this._localRotationEuler;n[0]=e[1]*t._angleToRandin,n[1]=e[0]*t._angleToRandin,n[2]=e[2]*t._angleToRandin,this._locaEulerlUpdate=!1}return this._localRotationEuler},n.setLocalRotationEuler=function(e){if(this._parent)Jt._quaternionCreateFromYawPitchRollArray(e[1]/t._angleToRandin,e[0]/t._angleToRandin,e[2]/t._angleToRandin,this._localRotation),this._localRotationEuler=e,this._locaEulerlUpdate=!1,this._localQuaternionUpdate=!1,this._localUpdate=!0,this._onWorldTransform();else{var n=this._entity.owner._transform,i=this._entity.localRotationEuler,r=i.elements;r[0]=e[0],r[1]=e[1],r[2]=e[2],n.localRotationEuler=i}},n.getWorldMatrix=function(){if(this._worldUpdate){if(null!=this._parent._parent)Jt.matrix4x4MultiplyFFF(this._parent.getWorldMatrix(),this._getlocalMatrix(),this._worldMatrix);else for(var e=this._getlocalMatrix(),t=0;t<16;++t)this._worldMatrix[t]=e[t];this._worldUpdate=!1}return this._worldMatrix},n.setParent=function(e){if(this._parent!==e){if(this._parent){var t=this._parent._childs,n=t.indexOf(this);t.splice(n,1)}e&&(e._childs.push(this),e&&this._onWorldTransform()),this._parent=e}},o(t,["_tempVector3",function(){return this._tempVector3=new Float32Array(3)},"_angleToRandin",function(){return this._angleToRandin=180/Math.PI}]),t}(),nn=function(e){function t(){this._destroyed=!1,this._id=0,this._enable=!1,this._owner=null,this.started=!1,t.__super.call(this),this._destroyed=!1,this._id=t._uniqueIDCounter,t._uniqueIDCounter++}s(t,"laya.d3.component.Component3D",D);var n=t.prototype;return a.imps(n,{"laya.d3.core.render.IUpdate":!0,"laya.resource.IDestroy":!0}),n._initialize=function(e){this._owner=e,this._enable=!0,this.started=!1,this._load(e)},n._destroy=function(){this._unload(this._owner),this._owner=null,this._destroyed=!0},n._load=function(e){},n._start=function(e){},n._update=function(e){},n._lateUpdate=function(e){},n._preRenderUpdate=function(e){},n._postRenderUpdate=function(e){},n._unload=function(e){this.offAll()},n._cloneTo=function(e){},l(0,n,"id",function(){return this._id}),l(0,n,"destroyed",function(){return this._destroyed}),l(0,n,"owner",function(){return this._owner}),l(0,n,"enable",function(){return this._enable},function(e){this._enable!==e&&(this._enable=e,this.event("enablechanged",this._enable))}),l(0,n,"isSingleton",function(){return t._isSingleton}),t._isSingleton=!0,t._uniqueIDCounter=1,t}(),rn=function(e){function t(){this._destroyed=!1,t.__super.call(this),this._destroyed=!1}s(t,"laya.d3.core.GeometryFilter",D);var n=t.prototype;return a.imps(n,{"laya.resource.IDestroy":!0}),n._destroy=function(){this.offAll(),this._destroyed=!0},l(0,n,"_isAsyncLoaded",function(){return!0}),l(0,n,"_originalBoundingBoxCorners",function(){throw new Error("BaseRender: must override it.")}),l(0,n,"_originalBoundingSphere",function(){throw new Error("BaseRender: must override it.")}),l(0,n,"_originalBoundingBox",function(){throw new Error("BaseRender: must override it.")}),l(0,n,"destroyed",function(){return this._destroyed}),t}(),an=function(e){function t(e){t.__super.call(this),this._id=++t._uniqueIDCounter,this._indexInSceneFrustumCullingObjects=-1,this._boundingBox=new xt(new bt,new bt),this._boundingBoxCenter=new bt,this._boundingSphere=new Rt(new bt,0),this._boundingSphereNeedChange=!0,this._boundingBoxNeedChange=!0,this._boundingBoxCenterNeedChange=!0,this._octreeNodeNeedChange=!0,this._materials=[],this._renderElements=[],this._isPartOfStaticBatch=!1,this._destroyed=!1,this._owner=e,this._enable=!0,this._materialsInstance=[],this.lightmapIndex=-1,this.castShadow=!1,this.receiveShadow=!1,this.sortingFudge=0,this._owner.transform.on("worldmatrixneedchanged",this,this._onWorldMatNeedChange)}s(t,"laya.d3.core.render.BaseRender",D);var n=t.prototype;return a.imps(n,{"laya.resource.IDestroy":!0}),n._changeMaterialReference=function(e,t){e&&e._removeReference(),t._addReference()},n._getInstanceMaterial=function(e,t){var n=new e.constructor;return e.cloneTo(n),n.name=n.name+"(Instance)",this._materialsInstance[t]=!0,this._changeMaterialReference(this._materials[t],n),this._materials[t]=n,n},n._setShaderValuelightMap=function(e){this._setShaderValueTexture(3,e)},n._onWorldMatNeedChange=function(){this._boundingSphereNeedChange=!0,this._boundingBoxNeedChange=!0,this._boundingBoxCenterNeedChange=!0,this._octreeNodeNeedChange=!0},n._renderRenderableBoundBox=function(){var e=en._debugPhasorSprite,n=this.boundingBox,i=t._tempBoundBoxCorners;n.getCorners(i),e.line(i[0],t._greenColor,i[1],t._greenColor),e.line(i[2],t._greenColor,i[3],t._greenColor),e.line(i[4],t._greenColor,i[5],t._greenColor),e.line(i[6],t._greenColor,i[7],t._greenColor),e.line(i[0],t._greenColor,i[3],t._greenColor),e.line(i[1],t._greenColor,i[2],t._greenColor),e.line(i[2],t._greenColor,i[6],t._greenColor),e.line(i[3],t._greenColor,i[7],t._greenColor),e.line(i[0],t._greenColor,i[4],t._greenColor),e.line(i[1],t._greenColor,i[5],t._greenColor),e.line(i[4],t._greenColor,i[7],t._greenColor),e.line(i[5],t._greenColor,i[6],t._greenColor)},n._calculateBoundingSphere=function(){throw"BaseRender: must override it."},n._calculateBoundingBox=function(){throw"BaseRender: must override it."},n._setShaderValueTexture=function(e,t){this._owner._shaderValues.setValue(e,t)},n._setShaderValueMatrix4x4=function(e,t){this._owner._shaderValues.setValue(e,t?t.elements:null)},n._setShaderValueColor=function(e,t){this._owner._shaderValues.setValue(e,t?t.elements:null)},n._setShaderValueBuffer=function(e,t){this._owner._shaderValues.setValue(e,t)},n._setShaderValueInt=function(e,t){this._owner._shaderValues.setValue(e,t)},n._setShaderValueBool=function(e,t){this._owner._shaderValues.setValue(e,t)},n._setShaderValueNumber=function(e,t){this._owner._shaderValues.setValue(e,t)},n._setShaderValueVector2=function(e,t){this._owner._shaderValues.setValue(e,t?t.elements:null)},n._addShaderDefine=function(e){this._owner._shaderDefineValue|=e},n._removeShaderDefine=function(e){this._owner._shaderDefineValue&=~e},n._renderUpdate=function(e){return!0},n._applyLightMapParams=function(){if(this._lightmapIndex>=0){var e=this._owner.scene;if(e){var t=e.getlightmaps()[this._lightmapIndex];t?(this._addShaderDefine(mi.SAHDERDEFINE_LIGHTMAP),t.loaded?this._setShaderValuelightMap(t):t.once("loaded",this,this._setShaderValuelightMap)):this._removeShaderDefine(mi.SAHDERDEFINE_LIGHTMAP)}else this._removeShaderDefine(mi.SAHDERDEFINE_LIGHTMAP)}else this._removeShaderDefine(mi.SAHDERDEFINE_LIGHTMAP)},n._updateOctreeNode=function(){var e=this._treeNode;e&&this._octreeNodeNeedChange&&(e.updateObject(this),this._octreeNodeNeedChange=!1)},n._destroy=function(){this.offAll();var e=0,t=0;for(e=0,t=this._renderElements.length;e<t;e++)this._renderElements[e]._destroy();for(e=0,t=this._materials.length;e<t;e++)this._materials[e]._removeReference();this._renderElements=null,this._owner=null,this._materials=null,this._boundingBox=null,this._boundingBoxCenter=null,this._boundingSphere=null,this._lightmapScaleOffset=null,this._destroyed=!0},l(0,n,"boundingSphere",function(){return this._boundingSphereNeedChange&&(this._calculateBoundingSphere(),this._boundingSphereNeedChange=!1),this._boundingSphere}),l(0,n,"id",function(){return this._id}),l(0,n,"material",function(){var e=this._materials[0];if(e&&!this._materialsInstance[0]){var t=this._getInstanceMaterial(e,0);this.event("materialchanged",[this,0,t])}return this._materials[0]},function(e){this.sharedMaterial=e}),l(0,n,"sharedMaterial",function(){return this._materials[0]},function(e){var t=this._materials[0];t!==e&&(this._materials[0]=e,this._materialsInstance[0]=!1,this._changeMaterialReference(t,e),this.event("materialchanged",[this,0,e]))}),l(0,n,"lightmapIndex",function(){return this._lightmapIndex},function(e){this._lightmapIndex=e,this._applyLightMapParams()}),l(0,n,"lightmapScaleOffset",function(){return this._lightmapScaleOffset},function(e){this._lightmapScaleOffset=e,this._setShaderValueColor(2,e),this._addShaderDefine(mi.SHADERDEFINE_SCALEOFFSETLIGHTINGMAPUV)}),l(0,n,"enable",function(){return this._enable},function(e){this._enable=e,this.event("enablechanged",[this,e])}),l(0,n,"materials",function(){for(var e=0,t=this._materials.length;e<t;e++)if(!this._materialsInstance[e]){var n=this._getInstanceMaterial(this._materials[e],e);this.event("materialchanged",[this,e,n])}return this._materials.slice()},function(e){this.sharedMaterials=e}),l(0,n,"sharedMaterials",function(){return this._materials.slice()},function(e){if(!e)throw new Error("MeshRender: shadredMaterials value can't be null.");var t=e.length;this._materialsInstance.length=t;for(var n=0;n<t;n++){var i=this._materials[n];i!==e[n]&&(this._materialsInstance[n]=!1,this._changeMaterialReference(i,e[n]),this.event("materialchanged",[this,n,e[n]]))}this._materials=e}),l(0,n,"boundingBox",function(){return this._boundingBoxNeedChange&&(this._calculateBoundingBox(),this._boundingBoxNeedChange=!1),this._boundingBox}),l(0,n,"boundingBoxCenter",function(){if(this._boundingBoxCenterNeedChange){var e=this.boundingBox;bt.add(e.min,e.max,this._boundingBoxCenter),bt.scale(this._boundingBoxCenter,.5,this._boundingBoxCenter),this._boundingBoxCenterNeedChange=!1}return this._boundingBoxCenter}),l(0,n,"receiveShadow",function(){return this._receiveShadow},function(e){this._receiveShadow!==e&&(this._receiveShadow=e,e?this._addShaderDefine(kt.SHADERDEFINE_RECEIVE_SHADOW):this._removeShaderDefine(kt.SHADERDEFINE_RECEIVE_SHADOW))}),l(0,n,"destroyed",function(){return this._destroyed}),t._uniqueIDCounter=0,o(t,["_tempBoundBoxCorners",function(){return this._tempBoundBoxCorners=[new bt,new bt,new bt,new bt,new bt,new bt,new bt,new bt]},"_greenColor",function(){return this._greenColor=new Ft(0,1,0,1)}]),t}(),on=function(e){function t(e){this._owner=null,this._localQuaternionUpdate=!1,this._locaEulerlUpdate=!1,this._localUpdate=!1,this._worldUpdate=!0,this._positionUpdate=!0,this._rotationUpdate=!0,this._scaleUpdate=!0,this._parent=null,this._childs=null,this._dummy=null,this.pivot=null,t.__super.call(this),this._localPosition=new bt,this._localRotation=new wt(0,0,0,1),this._localScale=new bt(1,1,1),this._localRotationEuler=new bt,this._localMatrix=new Ct,this._position=new bt,this._rotation=new wt(0,0,0,1),this._scale=new bt(1,1,1),this._worldMatrix=new Ct,this._forward=new bt,this._up=new bt,this._right=new bt,this._owner=e,this._childs=[]}s(t,"laya.d3.core.Transform3D",D);var n=t.prototype;return n._updateLocalMatrix=function(){if(!this.pivot||0===this.pivot.x&&0===this.pivot.y&&0===this.pivot.z)Ct.createAffineTransformation(this._localPosition,this.localRotation,this._localScale,this._localMatrix);else{var e=t._tempVector30;bt.multiply(this.pivot,this._localScale,e);var n=t._tempVector31;bt.subtract(e,this.pivot,n);var i=t._tempVector32,r=this.localRotation;bt.transformQuat(e,r,i),bt.subtract(i,e,i);var a=t._tempVector33;bt.subtract(this._localPosition,n,a),bt.subtract(a,i,a),Ct.createAffineTransformation(a,r,this._localScale,this._localMatrix)}},n._onWorldPositionRotationTransform=function(){if(!this._worldUpdate||!this._positionUpdate||!this._rotationUpdate){this._worldUpdate=this._positionUpdate=this._rotationUpdate=!0,this.event("worldmatrixneedchanged");for(var e=0,t=this._childs.length;e<t;e++)this._childs[e]._onWorldPositionRotationTransform()}},n._onWorldPositionScaleTransform=function(){if(!this._worldUpdate||!this._positionUpdate||!this._scaleUpdate){this._worldUpdate=this._positionUpdate=this._scaleUpdate=!0,this.event("worldmatrixneedchanged");for(var e=0,t=this._childs.length;e<t;e++)this._childs[e]._onWorldPositionScaleTransform()}},n._onWorldPositionTransform=function(){if(!this._worldUpdate||!this._positionUpdate){this._worldUpdate=this._positionUpdate=!0,this.event("worldmatrixneedchanged");for(var e=0,t=this._childs.length;e<t;e++)this._childs[e]._onWorldPositionTransform()}},n._onWorldRotationTransform=function(){if(!this._worldUpdate||!this._rotationUpdate){this._worldUpdate=this._rotationUpdate=!0,this.event("worldmatrixneedchanged");for(var e=0,t=this._childs.length;e<t;e++)this._childs[e]._onWorldPositionRotationTransform()}},n._onWorldScaleTransform=function(){if(!this._worldUpdate||!this._scaleUpdate){this._worldUpdate=this._scaleUpdate=!0,this.event("worldmatrixneedchanged");for(var e=0,t=this._childs.length;e<t;e++)this._childs[e]._onWorldPositionScaleTransform()}},n._onWorldTransform=function(){if(!(this._worldUpdate&&this._positionUpdate&&this._rotationUpdate&&this._scaleUpdate)){this._worldUpdate=this._positionUpdate=this._rotationUpdate=this._scaleUpdate=!0,this.event("worldmatrixneedchanged");for(var e=0,t=this._childs.length;e<t;e++)this._childs[e]._onWorldTransform()}},n.translate=function(e,n){void 0===n&&(n=!0),n?(Ct.createFromQuaternion(this.localRotation,t._tempMatrix0),bt.transformCoordinate(e,t._tempMatrix0,t._tempVector30),bt.add(this.localPosition,t._tempVector30,this._localPosition),this.localPosition=this._localPosition):(bt.add(this.position,e,this._position),this.position=this._position)},n.rotate=function(e,n,i){var r;void 0===n&&(n=!0),void 0===i&&(i=!0),i?r=e:(bt.scale(e,Math.PI/180,t._tempVector30),r=t._tempVector30),wt.createFromYawPitchRoll(r.y,r.x,r.z,t._tempQuaternion0),n?(wt.multiply(this._localRotation,t._tempQuaternion0,this._localRotation),this.localRotation=this._localRotation):(wt.multiply(t._tempQuaternion0,this.rotation,this._rotation),this.rotation=this._rotation)},n.lookAt=function(e,t,n){void 0===n&&(n=!1);var i,r=e.elements;if(n){if(i=this._localPosition.elements,Math.abs(i[0]-r[0])<It.zeroTolerance&&Math.abs(i[1]-r[1])<It.zeroTolerance&&Math.abs(i[2]-r[2])<It.zeroTolerance)return;wt.lookAt(this._localPosition,e,t,this._localRotation),this._localRotation.invert(this._localRotation),this.localRotation=this._localRotation}else{var a=this.position;if(i=a.elements,Math.abs(i[0]-r[0])<It.zeroTolerance&&Math.abs(i[1]-r[1])<It.zeroTolerance&&Math.abs(i[2]-r[2])<It.zeroTolerance)return;wt.lookAt(a,e,t,this._rotation),this._rotation.invert(this._rotation),this.rotation=this._rotation}},l(0,n,"_isFrontFaceInvert",function(){var e=this.scale,t=e.x<0;return e.y<0&&(t=!t),e.z<0&&(t=!t),t}),l(0,n,"owner",function(){return this._owner}),l(0,n,"localRotation",function(){if(this._localQuaternionUpdate){var e=this._localRotationEuler.elements;wt.createFromYawPitchRoll(e[1]/t._angleToRandin,e[0]/t._angleToRandin,e[2]/t._angleToRandin,this._localRotation)}return this._localRotation},function(e){this._localRotation=e,this._localRotation.normalize(this._localRotation),this._locaEulerlUpdate=!0,this._localQuaternionUpdate=!1,this._localUpdate=!0,!this.pivot||0===this.pivot.x&&0===this.pivot.y&&0===this.pivot.z?this._onWorldRotationTransform():this._onWorldPositionRotationTransform()}),l(0,n,"worldMatrix",function(){return this._worldUpdate&&(null!=this._parent?Ct.multiply(this._parent.worldMatrix,this.localMatrix,this._worldMatrix):this.localMatrix.cloneTo(this._worldMatrix),this._worldUpdate=!1),this._worldMatrix},function(e){null===this._parent?e.cloneTo(this._localMatrix):(this._parent.worldMatrix.invert(this._localMatrix),Ct.multiply(this._localMatrix,e,this._localMatrix)),this.localMatrix=this._localMatrix,this._worldMatrix=e,this._worldUpdate=!1}),l(0,n,"worldNeedUpdate",function(){return this._worldUpdate}),l(0,n,"localMatrix",function(){return this._localUpdate&&(this._updateLocalMatrix(),this._localUpdate=!1),this._localMatrix},function(e){this._localMatrix=e,this._localMatrix.decomposeTransRotScale(this._localPosition,this._localRotation,this._localScale),this._localUpdate=!1,this._onWorldTransform()}),l(0,n,"dummy",function(){return this._dummy},function(e){this._dummy!==e&&(this._dummy&&(this._dummy._entity=null),e&&(e._entity=this),this._dummy=e)}),l(0,n,"localPosition",function(){return this._localPosition},function(e){this._localPosition=e,this._localUpdate=!0,this._onWorldPositionTransform()}),l(0,n,"position",function(){if(this._positionUpdate){if(null!=this._parent){var e=this._parent.position;bt.multiply(this._localPosition,this._parent.scale,t._tempVector30),bt.transformQuat(t._tempVector30,this._parent.rotation,t._tempVector30),bt.add(e,t._tempVector30,this._position)}else this._localPosition.cloneTo(this._position);this._positionUpdate=!1}return this._position},function(e){if(null!=this._parent){bt.subtract(e,this._parent.position,this._localPosition);var n=this._parent.scale.elements,i=n[0],r=n[1],a=n[2];if(1!==i||1!==r||1!==a){var o=t._tempVector30,s=o.elements;s[0]=1/i,s[1]=1/r,s[2]=1/a,bt.multiply(this._localPosition,o,this._localPosition)}this._parent.rotation.invert(t._tempQuaternion0),bt.transformQuat(this._localPosition,t._tempQuaternion0,this._localPosition)}else e.cloneTo(this._localPosition);this.localPosition=this._localPosition,this._position=e,this._positionUpdate=!1}),l(0,n,"localScale",function(){return this._localScale},function(e){this._localScale=e,this._localUpdate=!0,!this.pivot||0===this.pivot.x&&0===this.pivot.y&&0===this.pivot.z?this._onWorldScaleTransform():this._onWorldPositionScaleTransform()}),l(0,n,"localRotationEuler",function(){if(this._locaEulerlUpdate){this._localRotation.getYawPitchRoll(t._tempVector30);var e=t._tempVector30.elements,n=this._localRotationEuler.elements;n[0]=e[1]*t._angleToRandin,n[1]=e[0]*t._angleToRandin,n[2]=e[2]*t._angleToRandin}return this._localRotationEuler},function(e){this._localRotationEuler=e,this._locaEulerlUpdate=!1,this._localQuaternionUpdate=!0,this._localUpdate=!0,!this.pivot||0===this.pivot.x&&0===this.pivot.y&&0===this.pivot.z?this._onWorldRotationTransform():this._onWorldPositionRotationTransform()}),l(0,n,"rotation",function(){return this._rotationUpdate&&(null!=this._parent?wt.multiply(this._parent.rotation,this.localRotation,this._rotation):this.localRotation.cloneTo(this._rotation),this._rotationUpdate=!1),this._rotation},function(e){null!=this._parent?(this._parent.rotation.invert(t._tempQuaternion0),wt.multiply(e,t._tempQuaternion0,this._localRotation)):e.cloneTo(this._localRotation),this.localRotation=this._localRotation,this._rotation=e,this._rotationUpdate=!1}),l(0,n,"scale",function(){return this._scaleUpdate?(null!==this._parent?bt.multiply(this._parent.scale,this._localScale,this._scale):this._localScale.cloneTo(this._scale),this._scaleUpdate=!1,this._scale):this._scale},function(e){if(null!==this._parent){var n=this._parent.scale.elements,i=t._tempVector30.elements;i[0]=1/n[0],i[1]=1/n[1],i[2]=1/n[2],bt.multiply(e,t._tempVector30,this._localScale)}else e.cloneTo(this._localScale);this.localScale=this._localScale,this._scale=e,this._scaleUpdate=!1}),l(0,n,"rotationEuler",null,function(e){wt.createFromYawPitchRoll(e.y,e.x,e.z,this._rotation),this.rotation=this._rotation}),l(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}),l(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}),l(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}),l(0,n,"parent",function(){return this._parent},function(e){if(this._parent!==e){if(this._parent){var t=this._parent._childs,n=t.indexOf(this);t.splice(n,1)}e&&(e._childs.push(this),e&&this._onWorldTransform()),this._parent=e}}),o(t,["_tempVector30",function(){return this._tempVector30=new bt},"_tempVector31",function(){return this._tempVector31=new bt},"_tempVector32",function(){return this._tempVector32=new bt},"_tempVector33",function(){return this._tempVector33=new bt},"_tempQuaternion0",function(){return this._tempQuaternion0=new wt},"_tempMatrix0",function(){return this._tempMatrix0=new Ct},"_angleToRandin",function(){return this._angleToRandin=180/Math.PI}]),t}(),sn=(function(e){function t(){this._rotation=0,this._matNeedUpdte=!1,t.__super.call(this),this._matrix=new Ct,this._offset=new Lt,this._tiling=new Lt(1,1)}s(t,"laya.d3.core.TransformUV",D);var n=t.prototype;a.imps(n,{"laya.d3.core.IClone":!0}),n._updateMatrix=function(){t._tempOffsetV3.elements[0]=this._offset.x,t._tempOffsetV3.elements[1]=this._offset.y,wt.createFromYawPitchRoll(0,0,this._rotation,t._tempRotationQua),t._tempTitlingV3.elements[0]=this._tiling.x,t._tempTitlingV3.elements[1]=this._tiling.y,Ct.createAffineTransformation(t._tempOffsetV3,t._tempRotationQua,t._tempTitlingV3,this._matrix)},n.cloneTo=function(e){e._matrix=this._matrix.clone(),e._offset=this._offset.clone(),e._rotation=this._rotation,e._tiling=this._tiling.clone()},n.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},l(0,n,"matrix",function(){return this._matNeedUpdte&&(this._updateMatrix(),this._matNeedUpdte=!1),this._matrix}),l(0,n,"tiling",function(){return this._tiling},function(e){this._tiling=e,this._matNeedUpdte=!0}),l(0,n,"offset",function(){return this._offset},function(e){this._offset=e,this._matNeedUpdte=!0}),l(0,n,"rotation",function(){return this._rotation},function(e){this._rotation=e,this._matNeedUpdte=!0}),o(t,["_tempOffsetV3",function(){return this._tempOffsetV3=new bt(0,0,0)},"_tempRotationQua",function(){return this._tempRotationQua=new wt},"_tempTitlingV3",function(){return this._tempTitlingV3=new bt(1,1,1)}])}(),function(e){function t(){t.__super.call(this)}return s(t,"laya.d3.utils.CollisionManager",D),t._onTrigger=function(e,t,n,i,r){var a=0,o=0,s=e.id,l=t.id;if(!e._ignoreCollisonMap[l]){var h=Kt.collisionManager,_=e._runtimeCollisonTestMap[l];if(null!=_)if(_)if(e._collisonTo(t))if(e._runtimeCollisonMap[l]){for(a=0,o=n.length;a<o;a++)n[a].onTriggerStay(t);for(a=0,o=i.length;a<o;a++)i[a].onTriggerStay(e);h.event("triggerstay",[e,t])}else{for(e._runtimeCollisonMap[l]=t,e._runtimeCollisonTestMap[l]=!1,t._runtimeCollisonMap[s]=e,r&&(t._runtimeCollisonTestMap[s]=!1),a=0,o=n.length;a<o;a++)n[a].onTriggerEnter(t);for(a=0,o=i.length;a<o;a++)i[a].onTriggerEnter(e);h.event("triggerenter",[e,t])}else{var u=e._runtimeCollisonMap;if(u[l]){for(delete u[l],delete e._runtimeCollisonTestMap[l],delete t._runtimeCollisonMap[s],r&&delete t._runtimeCollisonTestMap[s],a=0,o=n.length;a<o;a++)n[a].onTriggerExit(t);for(a=0,o=i.length;a<o;a++)i[a].onTriggerExit(e);h.event("triggerexit",[e,t])}}else{for(a=0,o=n.length;a<o;a++)n[a].onTriggerStay(t);for(a=0,o=i.length;a<o;a++)i[a].onTriggerStay(e);h.event("triggerstay",[e,t])}else if(e._collisonTo(t)){for(e._runtimeCollisonMap[l]=t,e._runtimeCollisonTestMap[l]=!1,t._runtimeCollisonMap[s]=e,r&&(t._runtimeCollisonTestMap[s]=!1),a=0,o=n.length;a<o;a++)n[a].onTriggerEnter(t);for(a=0,o=i.length;a<o;a++)i[a].onTriggerEnter(e);h.event("triggerenter",[e,t])}}},t._triggerCollision=function(){for(var e=Z._collsionTestList,n=e.length,i=Kt._layerCollsionMatrix,r=0;r<n;r++)for(var a=e[r],o=Z.getLayerByNumber(a),s=o._colliders,l=o._nonRigidbodyOffset,h=n-1;h>=r;h--){var _=e[h];if(i[a][30-_]){var u,c,d,f=0,m=0,p=0,v=0,E=Z.getLayerByNumber(_),g=E._colliders,D=E._nonRigidbodyOffset;if(o!==E){for(f=0;f<l;f++)if((u=s[f]).enable){for(d=u.owner._scripts,p=0,v=D;p<v;p++)(c=g[p]).enable&&t._onTrigger(u,c,d,c.owner._scripts,!0);for(p=D,v=g.length;p<v;p++)(c=g[p]).enable&&t._onTrigger(u,c,d,c.owner._scripts,!1)}for(f=l,m=s.length;f<m;f++)if((u=s[f]).enable)for(d=u.owner._scripts,p=0,v=E._nonRigidbodyOffset;p<v;p++)(c=g[p]).enable&&t._onTrigger(c,u,d,c.owner._scripts,!1)}else for(f=0;f<l;f++)if((u=s[f]).enable){for(d=u.owner._scripts,p=f+1,v=l;p<v;p++)(c=g[p]).enable&&t._onTrigger(u,c,d,c.owner._scripts,!0);for(p=l,v=s.length;p<v;p++)(c=g[p]).enable&&t._onTrigger(u,c,d,c.owner._scripts,!1)}}}},t}()),ln=(function(e){function t(){t.__super.call(this)}s(t,"laya.d3.core.glitter.SplineCurvePosition",e);var n=t.prototype;n._CalcVelocity=function(e,t,n){bt.subtract(e,t,n),bt.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)}}(k),function(e){function t(){this.x=NaN,this.y=NaN,this.z=NaN,t.__super.call(this),this.x=1,this.y=1,this.z=1,this.randomDirection=!1}s(t,"laya.d3.core.particleShuriKen.module.shape.BoxShape",e);var n=t.prototype;return n._getShapeBoundBox=function(e){var t=e.min.elements;t[0]=.5*-this.x,t[1]=.5*-this.y,t[2]=.5*-this.z;var n=e.max.elements;n[0]=.5*this.x,n[1]=.5*this.y,n[2]=.5*this.z},n._getSpeedBoundBox=function(e){var t=e.min.elements;t[0]=0,t[1]=0,t[2]=0;var n=e.max.elements;n[0]=0,n[1]=1,n[2]=0},n.generatePositionAndDirection=function(e,t,n,i){var r=e.elements,a=t.elements;n?(n.seed=i[16],oe._randomPointInsideHalfUnitBox(e,n),i[16]=n.seed):oe._randomPointInsideHalfUnitBox(e),r[0]=this.x*r[0],r[1]=this.y*r[1],r[2]=this.z*r[2],this.randomDirection?n?(n.seed=i[17],oe._randomPointUnitSphere(t,n),i[17]=n.seed):oe._randomPointUnitSphere(t):(a[0]=0,a[1]=0,a[2]=1)},n.cloneTo=function(t){e.prototype.cloneTo.call(this,t);var n=t;n.x=this.x,n.y=this.y,n.z=this.z,n.randomDirection=this.randomDirection},t}(ae)),hn=function(e){function t(){this.radius=NaN,this.arc=NaN,this.emitFromEdge=!1,t.__super.call(this),this.radius=1,this.arc=2*Math.PI,this.emitFromEdge=!1,this.randomDirection=!1}s(t,"laya.d3.core.particleShuriKen.module.shape.CircleShape",e);var n=t.prototype;return n._getShapeBoundBox=function(e){var t=e.min.elements;t[0]=t[2]=-this.radius,t[1]=0;var n=e.max.elements;n[0]=n[2]=this.radius,n[1]=0},n._getSpeedBoundBox=function(e){var t=e.min.elements;t[0]=t[1]=-1,t[2]=0;var n=e.max.elements;n[0]=n[1]=1,n[2]=0},n.generatePositionAndDirection=function(e,n,i,r){var a=e.elements,o=t._tempPositionPoint.elements;i?(i.seed=r[16],this.emitFromEdge?oe._randomPointUnitArcCircle(this.arc,t._tempPositionPoint,i):oe._randomPointInsideUnitArcCircle(this.arc,t._tempPositionPoint,i),r[16]=i.seed):this.emitFromEdge?oe._randomPointUnitArcCircle(this.arc,t._tempPositionPoint):oe._randomPointInsideUnitArcCircle(this.arc,t._tempPositionPoint),a[0]=-o[0],a[1]=o[1],a[2]=0,bt.scale(e,this.radius,e),this.randomDirection?i?(i.seed=r[17],oe._randomPointUnitSphere(n,i),r[17]=i.seed):oe._randomPointUnitSphere(n):e.cloneTo(n)},n.cloneTo=function(t){e.prototype.cloneTo.call(this,t);var n=t;n.radius=this.radius,n.arc=this.arc,n.emitFromEdge=this.emitFromEdge,n.randomDirection=this.randomDirection},o(t,["_tempPositionPoint",function(){return this._tempPositionPoint=new Lt}]),t}(ae),_n=function(e){function t(){this.angle=NaN,this.radius=NaN,this.length=NaN,this.emitType=0,t.__super.call(this),this.angle=25/180*Math.PI,this.radius=1,this.length=5,this.emitType=0,this.randomDirection=!1}s(t,"laya.d3.core.particleShuriKen.module.shape.ConeShape",e);var n=t.prototype;return n._getShapeBoundBox=function(e){var t=this.radius+this.length*Math.sin(this.angle),n=this.length*Math.cos(this.angle),i=e.min.elements;i[0]=i[1]=-t,i[2]=0;var r=e.max.elements;r[0]=r[1]=t,r[2]=n},n._getSpeedBoundBox=function(e){var t=Math.sin(this.angle),n=e.min.elements;n[0]=n[1]=-t,n[2]=0;var i=e.max.elements;i[0]=n[1]=t,i[2]=1},n.generatePositionAndDirection=function(e,n,i,r){var a,o=e.elements,s=n.elements,l=t._tempPositionPoint.elements,h=NaN,_=NaN,u=Math.cos(this.angle),c=Math.sin(this.angle);switch(this.emitType){case 0:i?(i.seed=r[16],oe._randomPointInsideUnitCircle(t._tempPositionPoint,i),r[16]=i.seed):oe._randomPointInsideUnitCircle(t._tempPositionPoint),h=l[0],_=l[1],o[0]=h*this.radius,o[1]=_*this.radius,o[2]=0,this.randomDirection?(i?(i.seed=r[17],oe._randomPointInsideUnitCircle(t._tempDirectionPoint,i),r[17]=i.seed):oe._randomPointInsideUnitCircle(t._tempDirectionPoint),a=t._tempDirectionPoint.elements,s[0]=a[0]*c,s[1]=a[1]*c):(s[0]=h*c,s[1]=_*c),s[2]=u;break;case 1:i?(i.seed=r[16],oe._randomPointUnitCircle(t._tempPositionPoint,i),r[16]=i.seed):oe._randomPointUnitCircle(t._tempPositionPoint),h=l[0],_=l[1],o[0]=h*this.radius,o[1]=_*this.radius,o[2]=0,this.randomDirection?(i?(i.seed=r[17],oe._randomPointInsideUnitCircle(t._tempDirectionPoint,i),r[17]=i.seed):oe._randomPointInsideUnitCircle(t._tempDirectionPoint),a=t._tempDirectionPoint.elements,s[0]=a[0]*c,s[1]=a[1]*c):(s[0]=h*c,s[1]=_*c),s[2]=u;break;case 2:i?(i.seed=r[16],oe._randomPointInsideUnitCircle(t._tempPositionPoint,i)):oe._randomPointInsideUnitCircle(t._tempPositionPoint),h=l[0],_=l[1],o[0]=h*this.radius,o[1]=_*this.radius,o[2]=0,s[0]=h*c,s[1]=_*c,s[2]=u,bt.normalize(n,n),i?(bt.scale(n,this.length*i.getFloat(),n),r[16]=i.seed):bt.scale(n,this.length*Math.random(),n),bt.add(e,n,e),this.randomDirection&&(i?(i.seed=r[17],oe._randomPointUnitSphere(n,i),r[17]=i.seed):oe._randomPointUnitSphere(n));break;case 3:i?(i.seed=r[16],oe._randomPointUnitCircle(t._tempPositionPoint,i)):oe._randomPointUnitCircle(t._tempPositionPoint),h=l[0],_=l[1],o[0]=h*this.radius,o[1]=_*this.radius,o[2]=0,s[0]=h*c,s[1]=_*c,s[2]=u,bt.normalize(n,n),i?(bt.scale(n,this.length*i.getFloat(),n),r[16]=i.seed):bt.scale(n,this.length*Math.random(),n),bt.add(e,n,e),this.randomDirection&&(i?(i.seed=r[17],oe._randomPointUnitSphere(n,i),r[17]=i.seed):oe._randomPointUnitSphere(n));break;default:throw new Error("ConeShape:emitType is invalid.")}},n.cloneTo=function(t){e.prototype.cloneTo.call(this,t);var n=t;n.angle=this.angle,n.radius=this.radius,n.length=this.length,n.emitType=this.emitType,n.randomDirection=this.randomDirection},o(t,["_tempPositionPoint",function(){return this._tempPositionPoint=new Lt},"_tempDirectionPoint",function(){return this._tempDirectionPoint=new Lt}]),t}(ae),un=function(e){function t(){this.radius=NaN,this.emitFromShell=!1,t.__super.call(this),this.radius=1,this.emitFromShell=!1,this.randomDirection=!1}s(t,"laya.d3.core.particleShuriKen.module.shape.HemisphereShape",e);var n=t.prototype;return n._getShapeBoundBox=function(e){var t=e.min.elements;t[0]=t[1]=t[2]=-this.radius;var n=e.max.elements;n[0]=n[1]=this.radius,n[2]=0},n._getSpeedBoundBox=function(e){var t=e.min.elements;t[0]=t[1]=-1,t[2]=0;var n=e.max.elements;n[0]=n[1]=n[2]=1},n.generatePositionAndDirection=function(e,t,n,i){var r=e.elements;n?(n.seed=i[16],this.emitFromShell?oe._randomPointUnitSphere(e,n):oe._randomPointInsideUnitSphere(e,n),i[16]=n.seed):this.emitFromShell?oe._randomPointUnitSphere(e):oe._randomPointInsideUnitSphere(e),bt.scale(e,this.radius,e);var a=r[2];a<0&&(r[2]=-1*a),this.randomDirection?n?(n.seed=i[17],oe._randomPointUnitSphere(t,n),i[17]=n.seed):oe._randomPointUnitSphere(t):e.cloneTo(t)},n.cloneTo=function(t){e.prototype.cloneTo.call(this,t);var n=t;n.radius=this.radius,n.emitFromShell=this.emitFromShell,n.randomDirection=this.randomDirection},t}(ae),cn=function(e){function t(){this.radius=NaN,this.emitFromShell=!1,t.__super.call(this),this.radius=1,this.emitFromShell=!1,this.randomDirection=!1}s(t,"laya.d3.core.particleShuriKen.module.shape.SphereShape",e);var n=t.prototype;return n._getShapeBoundBox=function(e){var t=e.min.elements;t[0]=t[1]=t[2]=-this.radius;var n=e.max.elements;n[0]=n[1]=n[2]=this.radius},n._getSpeedBoundBox=function(e){var t=e.min.elements;t[0]=t[1]=t[2]=-1;var n=e.max.elements;n[0]=n[1]=n[2]=1},n.generatePositionAndDirection=function(e,t,n,i){n?(n.seed=i[16],this.emitFromShell?oe._randomPointUnitSphere(e,n):oe._randomPointInsideUnitSphere(e,n),i[16]=n.seed):this.emitFromShell?oe._randomPointUnitSphere(e):oe._randomPointInsideUnitSphere(e),bt.scale(e,this.radius,e),this.randomDirection?n?(n.seed=i[17],oe._randomPointUnitSphere(t,n),i[17]=n.seed):oe._randomPointUnitSphere(t):e.cloneTo(t)},n.cloneTo=function(t){e.prototype.cloneTo.call(this,t);var n=t;n.radius=this.radius,n.emitFromShell=this.emitFromShell,n.randomDirection=this.randomDirection},t}(ae),dn=function(e){function t(){this._batchIndexStart=0,this._batchIndexEnd=0,this._skinAnimationDatas=null,t.__super.call(this)}return s(t,"laya.d3.core.render.SubMeshRenderElement",de),t}(),fn=function(e){function t(e,n,i,r,a,o){var s;for(s in this._name=NaN,this._attributeMap=null,this._renderElementUniformMap=null,this._materialUniformMap=null,this._spriteUniformMap=null,this._cameraUniformMap=null,this._sceneUniformMap=null,this.sharders=null,this._spriteDefineCounter=3,this._spriteInt2name=[],this._spriteName2Int={},this._materialDefineCounter=1,this._materialInt2name=[],this._materialName2Int={},this._conchShader=null,this._name=e,this._renderElementUniformMap={},this._materialUniformMap={},this._spriteUniformMap={},this._cameraUniformMap={},this._sceneUniformMap={},this.sharders=[],this._spriteInt2name[kt.SHADERDEFINE_RECEIVE_SHADOW]="RECEIVESHADOW",this._spriteInt2name[mi.SHADERDEFINE_SCALEOFFSETLIGHTINGMAPUV]="SCALEOFFSETLIGHTINGMAPUV",this._spriteInt2name[mi.SAHDERDEFINE_LIGHTMAP]="LIGHTMAP",this._spriteInt2name[Si.SHADERDEFINE_BONE]="BONE",this._materialInt2name[Dn.SHADERDEFINE_ALPHATEST]="ALPHATEST",t.__super.call(this,e,n,i,null,{}),this._attributeMap=r,a){var l=a[s];switch(l[1]){case 0:this._renderElementUniformMap[s]=l[0];break;case 1:this._materialUniformMap[s]=l[0];break;case 2:this._spriteUniformMap[s]=l[0];break;case 3:this._cameraUniformMap[s]=l[0];break;case 4:this._sceneUniformMap[s]=l[0];break;default:throw new Error("ShaderCompile3D: period is unkonw.")}}}s(t,"laya.d3.shader.ShaderCompile3D",N);var n=t.prototype;return n._definesToNameDic=function(e,t){for(var n={},i=1,r=0;r<32&&!((i=1<<r)>e);r++)if(e&i){var a=t[i];a&&(n[a]="")}return n},n.withCompile=function(e,n,i){var r,a,o;if(a=this.sharders[e])if(o=a[n]){if(r=o[i])return r}else o=a[n]=[];else o=(a=this.sharders[e]=[])[n]=[];var s,l=this._definesToNameDic(e,t._globalInt2name),h=this._definesToNameDic(n,this._spriteInt2name),_=this._definesToNameDic(i,this._materialInt2name);if(laya.d3.shader.ShaderCompile3D.debugMode){var u="";for(s in l)u+=s+" ";var c="";for(s in h)c+=s+" ";var d="";for(s in _)d+=s+" ";console.log("ShaderCompile3DDebugMode---(Name:"+Gn.nameKey.getName(this._name)+" PublicDefine:"+e+" SpriteDefine:"+n+" MaterialDefine:"+i+" PublicDefineGroup:"+u+" SpriteDefineGroup:"+c+"MaterialDefineGroup: "+d+")---ShaderCompile3DDebugMode")}var f={},m="";if(l)for(s in l)m+="#define "+s+"\n",f[s]=!0;if(h)for(s in h)m+="#define "+s+"\n",f[s]=!0;if(_)for(s in _)m+="#define "+s+"\n",f[s]=!0;var p=this._VS.toscript(f,[]),v=this._PS.toscript(f,[]);return r=Gn.create(m+p.join("\n"),m+v.join("\n"),this._attributeMap,this._sceneUniformMap,this._cameraUniformMap,this._spriteUniformMap,this._materialUniformMap,this._renderElementUniformMap),o[i]=r,r},n.precompileShaderWithShaderDefine=function(e,t,n){this.withCompile(e,t,n)},n.addMaterialDefines=function(e){var t=e.defines;for(var n in t){var i=t[n],r=parseInt(n);this._materialInt2name[r]=i,this._materialName2Int[i]=r}},n.addSpriteDefines=function(e){var t=e.defines;for(var n in t){var i=t[n],r=parseInt(n);this._spriteInt2name[r]=i,this._spriteName2Int[i]=r}},n.getMaterialDefineByName=function(e){return this._materialName2Int[e]},n.registerMaterialDefine=function(e){var t=Math.pow(2,this._materialDefineCounter++);return this._materialInt2name[t]=e,this._materialName2Int[e]=t,t},n.registerSpriteDefine=function(e){var t=Math.pow(2,this._spriteDefineCounter++);return this._spriteInt2name[t]=e,this._spriteName2Int[e]=t,t},t._globalRegDefine=function(e,n){t._globalInt2name[n]=e},t.add=function(e,n,i,r,a){return laya.d3.shader.ShaderCompile3D._preCompileShader[e]=new t(e,n,i,r,a,N.includes)},t.get=function(e){return laya.d3.shader.ShaderCompile3D._preCompileShader[Gn.nameKey.getID(e)]},t._preCompileShader={},t._globalInt2name=[],t.debugMode=!1,t.SHADERDEFINE_HIGHPRECISION=1,t.SHADERDEFINE_FOG=4,t.SHADERDEFINE_DIRECTIONLIGHT=8,t.SHADERDEFINE_POINTLIGHT=16,t.SHADERDEFINE_SPOTLIGHT=32,t.SHADERDEFINE_UV0=64,t.SHADERDEFINE_COLOR=128,t.SHADERDEFINE_UV1=256,t.SAHDERDEFINE_DEPTHFOG=131072,t}(),mn=function(e){function t(){t.__super.call(this)}s(t,"laya.d3.graphics.MeshSprite3DStaticBatchManager",Ie);var n=t.prototype;return n._getStaticBatch=function(e,t,n,i){var r,a;return a=e?e.id.toString()+n.id.toString()+t.id.toString()+i.toString():n.id.toString()+t.id.toString()+i.toString(),this._staticBatches[a]?r=this._staticBatches[a]:this._staticBatches[a]=r=new pn(a,this,e,t,n),r},n._initStaticBatchs=function(e){this._initBatchRenderElements.sort(t._sortPrepareStaticBatch);for(var n,i,r,a=!1,o=0,s=0,l=this._initBatchRenderElements.length;s<l;s++){var h,_=this._initBatchRenderElements[s],u=_.renderObj._getVertexBuffer(0);if(_._sprite3D,i===u.vertexDeclaration&&n===_._material)if(a)r._addCombineBatchRenderObjTest(_)?(h=_._staticBatch)!==r&&(h&&h._deleteCombineBatchRenderObj(_),r._addCombineBatchRenderObj(_)):(a=!1,o++);else{var c=this._initBatchRenderElements[s-1],d=c.renderObj,f=_.renderObj;d._getVertexBuffer().vertexCount+f._getVertexBuffer().vertexCount>65535?a=!1:(r=this._getStaticBatch(e,i,n,o),(h=c._staticBatch)!==r&&(h&&h._deleteCombineBatchRenderObj(c),r._addCombineBatchRenderObj(c)),(h=_._staticBatch)!==r&&(h&&h._deleteCombineBatchRenderObj(_),r._addCombineBatchRenderObj(_)),a=!0)}else a=!1,o=0;n=_._material,i=u.vertexDeclaration}},t._sortPrepareStaticBatch=function(e,t){var n=e._render,i=t._render,r=n.lightmapIndex-i.lightmapIndex;if(0===r){var a=n.receiveShadow-i.receiveShadow;if(0===a){var o=e._mainSortID-t._mainSortID;return 0===o?e.renderObj.triangleCount-t.renderObj.triangleCount:o}return a}return r},t}(),pn=function(e){function t(e,n,i,r,a){this._batchOwnerIndices=null,this._batchOwners=null,this._needFinishCombine=!1,this._currentCombineVertexCount=0,this._currentCombineIndexCount=0,this._vertexDeclaration=null,this._vertexBuffer=null,this._indexBuffer=null,t.__super.call(this,e,n,i),this._batchOwnerIndices=[],this._batchOwners=[],this._needFinishCombine=!1,this._currentCombineVertexCount=0,this._currentCombineIndexCount=0,this._vertexDeclaration=r,this._material=a}s(t,"laya.d3.graphics.SubMeshStaticBatch",ye);var n=t.prototype;return n._compareBatchRenderElement=function(e,t){return e._batchIndexStart>t._batchIndexStart},n._addCombineBatchRenderObjTest=function(e){var t=e.renderObj._vertexCount;return!((t>0?this._currentCombineVertexCount+t:this._currentCombineVertexCount+e.renderObj._getVertexBuffer().vertexCount)>65535)},n._addCombineBatchRenderObj=function(e){var t=e.renderObj,n=t._vertexCount;this._initBatchRenderElements.push(e),e._staticBatch=this,n>0?(this._currentCombineIndexCount+=t._indexCount,this._currentCombineVertexCount+=n):(this._currentCombineIndexCount=this._currentCombineIndexCount+t._getIndexBuffer().indexCount,this._currentCombineVertexCount=this._currentCombineVertexCount+t._getVertexBuffer().vertexCount),this._needFinishCombine=!0},n._deleteCombineBatchRenderObj=function(e){var t=e.renderObj,n=this._initBatchRenderElements.indexOf(e);if(-1!==n){this._initBatchRenderElements.splice(n,1),e._staticBatch=null;var i=t._vertexCount;i>0?(this._currentCombineIndexCount=this._currentCombineIndexCount-t._indexCount,this._currentCombineVertexCount=this._currentCombineVertexCount-i):(this._currentCombineIndexCount=this._currentCombineIndexCount-t._getIndexBuffer().indexCount,this._currentCombineVertexCount=this._currentCombineVertexCount-t._getVertexBuffer().vertexCount),this._needFinishCombine=!0}},n._finishInit=function(){if(this._needFinishCombine){var e=0,t=0;this._initBatchRenderElements[0]._sprite3D._render.lightmapIndex>=0?this._vertexDeclaration=this._getVertexDecLightMap(this._vertexDeclaration):this._material instanceof laya.d3.core.material.StandardMaterial&&this._material.ambientTexture&&(this._vertexDeclaration=this._getVertexDecLightMap(this._vertexDeclaration));var n=new Float32Array(this._vertexDeclaration.vertexStride/4*this._currentCombineVertexCount),i=new Uint16Array(this._currentCombineIndexCount);this._vertexBuffer&&(this._vertexBuffer.destroy(),this._indexBuffer.destroy()),this._vertexBuffer=$n.create(this._vertexDeclaration,this._currentCombineVertexCount,35044),this._indexBuffer=Qn.create("ushort",this._currentCombineIndexCount,35044);for(var r=0,a=this._initBatchRenderElements.length;r<a;r++){var o=this._initBatchRenderElements[r],s=o.renderObj,l=s._getStaticBatchBakedVertexs(this._rootOwner?this._rootOwner._transform:null,o._sprite3D),h=s.getIndices(),_=o._sprite3D.transform._isFrontFaceInvert,u=e/(this._vertexDeclaration.vertexStride/4)-s._vertexStart,c=t,d=c+h.length;o._batchIndexStart=c,o._batchIndexEnd=d,i.set(h,t);var f=0;if(_)for(f=c;f<d;f+=3){i[f]=u+i[f];var m=i[f+1],p=i[f+2];i[f+1]=u+p,i[f+2]=u+m}else for(f=c;f<d;f+=3)i[f]=u+i[f],i[f+1]=u+i[f+1],i[f+2]=u+i[f+2];t+=h.length,n.set(l,e),e+=l.length}this._vertexBuffer.setData(n),this._indexBuffer.setData(i),this._needFinishCombine=!1}},n._getCombineRenderElementFromPool=function(){return this._combineRenderElementPool[this._combineRenderElementPoolIndex++]||(this._combineRenderElementPool[this._combineRenderElementPoolIndex-1]=new dn)},n._getRenderElement=function(e,t,n){for(var i,r,a=this._batchRenderElements.length,o=!0,s=0;s<a;s++){var l,h,_=(r=this._batchRenderElements[s])._sprite3D._render;if(0!==s&&(o=(l=(i=this._batchRenderElements[s-1])._sprite3D._render).lightmapIndex!==_.lightmapIndex||l.receiveShadow!==_.receiveShadow||i._batchIndexEnd!==r._batchIndexStart),o){(h=this._getCombineRenderElementFromPool()).renderObj=this,h._material=this._material,h._batchIndexStart=r._batchIndexStart,h._batchIndexEnd=r._batchIndexEnd;var u=_.lightmapIndex,c=u+1,d=this._batchOwnerIndices[c];d||(d=this._batchOwnerIndices[c]=[]);var f,m=d[r._render.receiveShadow?1:0];void 0===m?(d[_.receiveShadow?1:0]=this._batchOwners.length,(f=new Di(null,"StaticBatchMeshSprite3D"))._scene=t,f._transform=this._rootOwner?this._rootOwner._transform:null,f._render.lightmapIndex=u,f._render.receiveShadow=r._render.receiveShadow,this._batchOwners.push(f)):f=this._batchOwners[m],f._render._renderUpdate(n),h._sprite3D=f,e.push(h)}else h._batchIndexEnd=r._batchIndexEnd}},n._beforeRender=function(e){return this._vertexBuffer._bind(),this._indexBuffer._bind(),!0},n._render=function(e){var t=e.renderElement,n=t._batchIndexStart,i=t._batchIndexEnd-n;b.mainContext.drawElements(4,i,5123,2*n),w.drawCall++,w.trianglesFaces+=i/3},n.dispose=function(){this._batchOwnerIndices=null,this._batchOwners=null,this._vertexDeclaration=null,this._vertexBuffer.destroy(),this._indexBuffer.destroy()},n._getVertexBuffer=function(e){return void 0===e&&(e=0),this._vertexBuffer},t}(),vn=(function(e){function t(){t.__super.call(this),t._nameNumber++,this.loadShaderParams(),this.createResource(),this.alphaBlending=1,this.colorIntensity=1}s(t,"laya.d3.resource.models.SkyBox",e);var n=t.prototype;n._getShader=function(e){var t=e.scene._shaderDefineValue;return this._shader=this._shaderCompile.withCompile(t,0,0),this._shader},n.createResource=function(){this._numberVertices=36,this._numberIndices=36;var e=new Uint16Array(this._numberIndices),n=t._vertexDeclaration.vertexStride/4,i=new Float32Array(this._numberVertices*n),r=new bt(-.5,.5,.5),a=new bt(-.5,-.5,.5),o=new bt(.5,.5,.5),s=new bt(.5,-.5,.5),l=new bt(-.5,.5,-.5),h=new bt(.5,.5,-.5),_=new bt(-.5,-.5,-.5),u=new bt(.5,-.5,-.5),c=0;c=this._addVertex(i,c,r),c=this._addVertex(i,c,a),c=this._addVertex(i,c,o),c=this._addVertex(i,c,a),c=this._addVertex(i,c,s),c=this._addVertex(i,c,o),c=this._addVertex(i,c,l),c=this._addVertex(i,c,h),c=this._addVertex(i,c,_),c=this._addVertex(i,c,_),c=this._addVertex(i,c,h),c=this._addVertex(i,c,u),c=this._addVertex(i,c,r),c=this._addVertex(i,c,h),c=this._addVertex(i,c,l),c=this._addVertex(i,c,r),c=this._addVertex(i,c,o),c=this._addVertex(i,c,h),c=this._addVertex(i,c,a),c=this._addVertex(i,c,_),c=this._addVertex(i,c,u),c=this._addVertex(i,c,a),c=this._addVertex(i,c,u),c=this._addVertex(i,c,s),c=this._addVertex(i,c,r),c=this._addVertex(i,c,_),c=this._addVertex(i,c,a),c=this._addVertex(i,c,l),c=this._addVertex(i,c,_),c=this._addVertex(i,c,r),c=this._addVertex(i,c,o),c=this._addVertex(i,c,s),c=this._addVertex(i,c,u),c=this._addVertex(i,c,h),c=this._addVertex(i,c,o),c=this._addVertex(i,c,u);for(var d=0;d<36;d++)e[d]=d;this._vertexBuffer=new $n(t._vertexDeclaration,this._numberVertices,35044,!0),this._indexBuffer=new Qn("ushort",this._numberIndices,35044,!0),this._vertexBuffer.setData(i),this._indexBuffer.setData(e)},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=Gn.nameKey.getID("SkyBox"),this._shaderCompile=fn._preCompileShader[this._sharderNameID]},n._render=function(e){this._textureCube&&this._textureCube.loaded&&(this._vertexBuffer._bind(),this._indexBuffer._bind(),this._shader=this._getShader(e),this._shader.bind(),e.camera.transform.worldMatrix.cloneTo(t._tempMatrix4x40),t._tempMatrix4x40.transpose(),Ct.multiply(e._projectionMatrix,t._tempMatrix4x40,t._tempMatrix4x41),e.camera._shaderValues.setValue(4,t._tempMatrix4x41.elements),this._shader.uploadCameraUniforms(e.camera._shaderValues.data),this._shaderValue.setValue(1,this._colorIntensity),this._shaderValue.setValue(2,this._alphaBlending),this._shaderValue.setValue(3,this.textureCube),this._shader.uploadAttributes(t._vertexDeclaration.shaderValues.data,null),this._shader.uploadMaterialUniforms(this._shaderValue.data),b.mainContext.drawElements(4,36,5123,0),w.trianglesFaces+=12,w.drawCall++)},n.destroy=function(){e.prototype.destroy.call(this),this._textureCube&&(this._textureCube._removeReference(),this._textureCube=null)},l(0,n,"textureCube",function(){return this._textureCube},function(e){this._textureCube!==e&&(this._textureCube&&this._textureCube._removeReference(),this._textureCube=e,e&&e._addReference())}),t._nameNumber=1,o(t,["_tempMatrix4x40",function(){return this._tempMatrix4x40=new Ct},"_tempMatrix4x41",function(){return this._tempMatrix4x41=new Ct},"_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(12,[new Ne(0,"vector3",0)])}])}(Ut),function(e){function t(){this._stacks=16,this._slices=16,this._radius=1,t.__super.call(this),t._nameNumber++,this.loadShaderParams(),this.recreateResource(),this.alphaBlending=1,this.colorIntensity=1}s(t,"laya.d3.resource.models.SkyDome",e);var n=t.prototype;n._getShader=function(e){var t=e.scene._shaderDefineValue;return this._shader=this._shaderCompile.withCompile(t,0,0),this._shader},n.recreateResource=function(){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,o=0,s=0,l=0,h=0;h<this._stacks+1;h++)for(var _=Math.sin(h*r),u=Math.cos(h*r),c=0;c<this._slices+1;c++){var d=_*Math.sin(c*a),f=_*Math.cos(c*a);i[s+0]=d*this._radius,i[s+1]=u*this._radius,i[s+2]=f*this._radius,i[s+3]=-c/this._slices+.75,i[s+4]=h/this._stacks,s+=n,h!=this._stacks-1&&(e[l++]=o+1,e[l++]=o,e[l++]=o+(this._slices+1),e[l++]=o+(this._slices+1),e[l++]=o,e[l++]=o+this._slices,o++)}this._vertexBuffer=new $n(t._vertexDeclaration,this._numberVertices,35044),this._indexBuffer=new Qn("ushort",this._numberIndices,35044),this._vertexBuffer.setData(i),this._indexBuffer.setData(e)},n.loadShaderParams=function(){this._sharderNameID=Gn.nameKey.getID("SkyDome"),this._shaderCompile=fn._preCompileShader[this._sharderNameID]},n._render=function(e){this._texture&&this._texture.loaded&&(this._vertexBuffer._bind(),this._indexBuffer._bind(),this._shader=this._getShader(e),this._shader.bind(),e.camera.transform.worldMatrix.cloneTo(t._tempMatrix4x40),t._tempMatrix4x40.transpose(),Ct.multiply(e._projectionMatrix,t._tempMatrix4x40,t._tempMatrix4x41),e.camera._shaderValues.setValue(4,t._tempMatrix4x41.elements),this._shader.uploadCameraUniforms(e.camera._shaderValues.data),this._shaderValue.setValue(1,this._colorIntensity),this._shaderValue.setValue(2,this._alphaBlending),this._shaderValue.setValue(3,this.texture),this._shader.uploadAttributes(t._vertexDeclaration.shaderValues.data,null),this._shader.uploadMaterialUniforms(this._shaderValue.data),b.mainContext.drawElements(4,this._indexBuffer.indexCount,5123,0),w.trianglesFaces+=this._numberIndices/3,w.drawCall++)},n.onEnvDescLoaded=function(e){var t="",n=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));n>0&&(t=e.substr(0,n+1));var i=a.loader.getRes(e);null!=i.ev&&this.__ownerCamera?this.__ownerCamera._shaderValues.setValue(13,Math.pow(2,i.ev)):this.__ownerCamera._shaderValues.setValue(13,Math.pow(2,0)),this.texture=ui.load(t+i.skytex),this.environmentSpecular=ai.load(t+i.prefiltedEnv);var r=new Float32Array(i.IrradianceMat);this.envDiffuseSHRed=r.slice(0,16),this.envDiffuseSHGreen=r.slice(16,32),this.envDiffuseSHBlue=r.slice(32,48)},n.loadEnvInfo=function(e){a.loader.load(e,T.create(this,this.onEnvDescLoaded,[e]))},n.destroy=function(){e.prototype.destroy.call(this),this._texture&&(this._texture._removeReference(),this._texture=null)},l(0,n,"texture",function(){return this._texture},function(e){this._texture!==e&&(this._texture&&this._texture._removeReference(),this._texture=e,e&&e._addReference())}),t._nameNumber=1,o(t,["_tempMatrix4x40",function(){return this._tempMatrix4x40=new Ct},"_tempMatrix4x41",function(){return this._tempMatrix4x41=new Ct},"_vertexDeclaration",function(){return this._vertexDeclaration=new Ce(20,[new Ne(0,"vector3",0),new Ne(12,"vector2",2)])}])}(Ut),function(e){function t(){this._componentsMap=null,this._typeComponentsIndices=null,this._components=null,this._scripts=null,t.__super.call(this),this._componentsMap=[],this._typeComponentsIndices=[],this._components=[],this._scripts=[]}s(t,"laya.d3.core.ComponentNode",R);var n=t.prototype;return n.addComponent=function(e){var t,n=this._componentsMap.indexOf(e);if(-1===n)t=[],this._componentsMap.push(e),this._typeComponentsIndices.push(t);else if(t=this._typeComponentsIndices[n],this._components[t[0]].isSingleton)throw new Error("无法单实例创建"+e+"组件，"+e+"组件已存在！");var i=E.getInstance(e);return t.push(this._components.length),this._components.push(i),i instanceof laya.d3.component.Script&&this._scripts.push(i),i._initialize(this),i},n._removeComponent=function(e,t){var n=this._typeComponentsIndices[e],i=n[t],r=this._components[i];this._components.splice(i,1),r instanceof laya.d3.component.Script&&this._scripts.splice(this._scripts.indexOf(r),1),n.splice(t,1),0===n.length&&(this._typeComponentsIndices.splice(e,1),this._componentsMap.splice(e,1));for(var a=0,o=this._componentsMap.length;a<o;a++)for(var s=(n=this._typeComponentsIndices[a]).length-1;s>=0;s--){var l=n[s];if(!(l>i))break;n[s]=--l}r._destroy()},n.getComponentByType=function(e,t){void 0===t&&(t=0);var n=this._componentsMap.indexOf(e);return-1===n?null:this._components[this._typeComponentsIndices[n][t]]},n.getComponentsByType=function(e,t){var n=this._componentsMap.indexOf(e);if(-1!==n){var i=this._typeComponentsIndices[n],r=i.length;t.length=r;for(var a=0;a<r;a++)t[a]=this._components[i[a]]}else t.length=0},n.getComponentByIndex=function(e){return this._components[e]},n.removeComponentByType=function(e,t){void 0===t&&(t=0);var n=this._componentsMap.indexOf(e);-1!==n&&this._removeComponent(n,t)},n.removeComponentsByType=function(e){var t=this._componentsMap.indexOf(e);if(-1!==t)for(var n=this._typeComponentsIndices[t],i=0,r=n.length;i<r;n.length<r?r--:i++)this._removeComponent(t,i)},n.removeAllComponent=function(){for(var e=0,t=this._componentsMap.length;e<t;this._componentsMap.length<t?t--:e++)this.removeComponentsByType(this._componentsMap[e])},n._updateComponents=function(e){for(var t=0,n=this._components.length;t<n;t++){var i=this._components[t];!i.started&&(i._start(e),i.started=!0),i.enable&&i._update(e)}},n._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.enable&&n._lateUpdate(e)}},n._preRenderUpdateComponents=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.enable&&n._preRenderUpdate(e)}},n._postRenderUpdateComponents=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.enable&&n._postRenderUpdate(e)}},t}()),En=function(e){function t(){this._realTimeCurrentFrameIndexes=null,this._realTimeCurrentTimes=null,this._fullKeyframeIndicesCache=null,this._animationDatasCache=null,this._avatarDatasCache=null,this._skinnedDatasCache=null,this._version=null,this._nodes=null,this._nodesMap=null,this._cachePropertyMap=null,this._nodeToCachePropertyMap=null,this._unCachePropertyMap=null,this._duration=NaN,this._frameRate=0,this._animationEvents=null,this._publicClipDatas=null,this.islooping=!1,t.__super.call(this),this._fullKeyframeIndicesCache={},this._animationDatasCache=[],this._avatarDatasCache=[],this._skinnedDatasCache=[],this._animationEvents=[]}s(t,"laya.d3.animation.AnimationClip",y);var n=t.prototype;return n.duration=function(){return this._duration},n._hermiteInterpolate=function(e,t,n,i){for(var r=e.data,a=e.outTangent,o=e.next,s=o.data,l=o.inTangent,h=!1,_=NaN,u=NaN,c=NaN,d=NaN,f=0,m=i.length;f<m;f++){var p=a[f],v=l[f];if(Number.isFinite(p)&&Number.isFinite(v)){if(!h){var E=t*t,g=E*t;_=2*g-3*E+1,u=g-2*E+t,c=g-E,d=-2*g+3*E,h=!0}i[f]=_*r[f]+u*p*n+c*v*n+d*s[f]}else i[f]=r[f]}},n._getFullKeyframeIndicesWithCache=function(e){return this._fullKeyframeIndicesCache[e]},n._cacheFullKeyframeIndices=function(e,t){this._fullKeyframeIndicesCache[e]=t},n._getAnimationDataWithCache=function(e,t){var n=this._animationDatasCache[e];return n?n[t]:null},n._cacheAnimationData=function(e,t,n){(this._animationDatasCache[e]||(this._animationDatasCache[e]=[]))[t]=n},n._getAvatarDataWithCache=function(e,t,n){var i=this._avatarDatasCache[e.id];if(i){var r=i[t];return r?r[n]:null}return null},n._cacheAvatarData=function(e,t,n,i){var r=this._avatarDatasCache[e.id]||(this._avatarDatasCache[e.id]=[]);(r[t]||(r[t]=[]))[n]=i},n._evaluateAnimationlDatasCacheMode=function(e,t,n,i,r){for(var a=0,o=0,s=0,l=r?r.length:this._nodes.length;s<l;s++){var h=r?r[s]:s,_=this._nodes[h],u=_._cacheProperty;if(e[h]){var c,d=t[h],f=d[n.currentFrameIndex],m=0;if(-1!==f){var p=_.keyFrames[f];if(p.next){r&&!u?(c=i[h])||(c=i[h]=new Float32Array(_.keyFrameWidth)):(c=new Float32Array(_.keyFrameWidth),i[s]=c);var v,E=p.duration;v=0!==E?(n.currentFrameTime-p.startTime)/E:0,this._hermiteInterpolate(p,v,E,c)}else{if(r&&!u)(c=i[h])||(c=i[h]=new Float32Array(_.keyFrameWidth));else{if(-1!==(m=n._lastFrameIndex)&&d[m]===f)continue;c=new Float32Array(_.keyFrameWidth),i[s]=c}var g=p.data;for(a=0,o=c.length;a<o;a++)c[a]=g[a]}}else{if(r&&!u)(c=i[h])||(c=i[h]=new Float32Array(_.keyFrameWidth));else{if(-1!==(m=n._lastFrameIndex)&&d[m]===f)continue;c=new Float32Array(_.keyFrameWidth),i[s]=c}var D=_.keyFrames[0].data;for(a=0,o=c.length;a<o;a++)c[a]=D[a]}}}},n._evaluateAnimationlDatasRealTime=function(e,t,n,i){var r=0,a=0,o=this._nodes;if(!this._realTimeCurrentFrameIndexes){for(this._realTimeCurrentFrameIndexes=new Int32Array(o.length),r=0,a=o.length;r<a;r++)this._realTimeCurrentFrameIndexes[r]=-1;this._realTimeCurrentTimes=new Float32Array(o.length)}for(r=0,a=i?i.length:this._nodes.length;r<a;r++){var s=i?i[r]:r,l=o[s];t<this._realTimeCurrentTimes[s]&&(this._realTimeCurrentFrameIndexes[s]=-1),this._realTimeCurrentTimes[s]=t;for(var h=this._realTimeCurrentFrameIndexes[s]+1,_=l.keyFrames,u=_.length;h<u;){if(_[h].startTime>t){this._realTimeCurrentFrameIndexes[s]=h-1;break}h++}h===u&&(this._realTimeCurrentFrameIndexes[s]=u-1);var c=0,d=0,f=n[s];f||(f=n[s]=new Float32Array(l.keyFrameWidth));var m=_[this._realTimeCurrentFrameIndexes[s]];if(m)if(m.next){var p,v=m.duration;p=0!==v?(t-m.startTime)/v:0,this._hermiteInterpolate(m,p,v,f)}else{var E=m.data;for(c=0,d=f.length;c<d;c++)f[c]=E[c]}else{var g=l.keyFrames[0].data;for(c=0,d=f.length;c<d;c++)f[c]=g[c]}var D=e[s];D&&(i?G._propertySetFuncs[l.propertyNameID](D,null,f):G._propertySetFuncs[l.propertyNameID](null,D,f))}},n._binarySearchEventIndex=function(e){for(var t=0,n=this._animationEvents.length-1,i=0;t<=n;){i=Math.floor((t+n)/2);var r=this._animationEvents[i].time;if(r==e)return i;r>e?n=i-1:t=i+1}return t},n.addEvent=function(e){var t=this._binarySearchEventIndex(e.time);this._animationEvents.splice(t,0,e)},n.onAsynLoaded=function(e,t,n){var i=new v(t);switch(this._version=i.readUTFString(),this._version){case"LAYAANIMATION:01":B.parse(this,i);break;case"LAYAANIMATION:02":U.parse(this,i)}this.completeCreate(),this._endLoaded()},n.disposeResource=function(){this._realTimeCurrentFrameIndexes=null,this._realTimeCurrentTimes=null,this._fullKeyframeIndicesCache=null,this._animationDatasCache=null,this._avatarDatasCache=null,this._skinnedDatasCache=null,this._version=null,this._nodes=null,this._nodesMap=null,this._cachePropertyMap=null,this._nodeToCachePropertyMap=null,this._unCachePropertyMap=null,this._publicClipDatas=null},t.load=function(e){return a.loader.create(e,null,null,t)},t}(),gn=function(e){function t(){t.__super.call(this)}s(t,"laya.d3.core.Avatar",y);var n=t.prototype;return a.imps(n,{"laya.d3.core.IClone":!0}),n._initCloneToAnimator=function(e,t){t._avatarNodeMap[e.name]=e,t._avatarNodes.push(e);for(var n=0,i=e.getChildCount();n<i;n++)this._initCloneToAnimator(e.getChildByIndex(n),t)},n._parseNode=function(e,t){var n=e.props.name;if(t.name=n,t._parent){var i=e.customProps,r=t.transform;r._localRotationEuler=new Float32Array(3),r.setLocalPosition(new Float32Array(i.translate)),r.setLocalRotation(new Float32Array(i.rotation)),r.setLocalScale(new Float32Array(i.scale)),r._setWorldMatrixAndUpdate(new Float32Array(16))}for(var a=e.child,o=0,s=a.length;o<s;o++){var l=a[o],h=new G;t.addChild(h),this._parseNode(l,h)}},n.onAsynLoaded=function(e,t,n){if(this._rootNode=new G,t.version){this._version=t.version;var i=t.rootNode;i&&this._parseNode(i,this._rootNode)}else this._parseNode(t,this._rootNode);this._endLoaded()},n._cloneDatasToAnimator=function(e){var t=this._rootNode.clone();t.transform._setWorldMatrixIgnoreUpdate(null),e._avatarNodeMap={},e._avatarNodes=[],this._initCloneToAnimator(t,e)},n.cloneTo=function(e){var t=e,n=this._rootNode.clone();t._rootNode=n},n.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},t.load=function(e){return a.loader.create(e,null,null,t)},t}(),Dn=function(e){function t(){t.__super.call(this),this._shaderDefineValue=0,this._disablePublicShaderDefine=0,this._shaderValues=new Wt,this._values=[],this.renderQueue=1,this._alphaTest=!1,this.cull=2,this.blend=0,this.srcBlend=1,this.dstBlend=0,this.srcBlendRGB=1,this.dstBlendRGB=0,this.srcBlendAlpha=1,this.dstBlendAlpha=0,this.blendConstColor=new Ft(1,1,1,1),this.blendEquation=0,this.blendEquationRGB=0,this.blendEquationAlpha=0,this.depthTest=513,this.depthWrite=!0}s(t,"laya.d3.core.material.BaseMaterial",e);var n=t.prototype;return a.imps(n,{"laya.d3.core.IClone":!0}),n._addShaderDefine=function(e){this._shaderDefineValue|=e},n._removeShaderDefine=function(e){this._shaderDefineValue&=~e},n._addDisablePublicShaderDefine=function(e){this._disablePublicShaderDefine|=e},n._removeDisablePublicShaderDefine=function(e){this._disablePublicShaderDefine&=~e},n._setBuffer=function(e,t){this._shaderValues.setValue(e,t),this._values[e]=t},n._getBuffer=function(e){return this._values[e]},n._setMatrix4x4=function(e,t){this._shaderValues.setValue(e,t?t.elements:null),this._values[e]=t},n._getMatrix4x4=function(e){return this._values[e]},n._setInt=function(e,t){this._shaderValues.setValue(e,t),this._values[e]=t},n._getInt=function(e){return this._values[e]},n._setNumber=function(e,t){this._shaderValues.setValue(e,t),this._values[e]=t},n._getNumber=function(e){return this._values[e]},n._setBool=function(e,t){this._shaderValues.setValue(e,t),this._values[e]=t},n._getBool=function(e){return this._values[e]},n._setVector2=function(e,t){this._shaderValues.setValue(e,t?t.elements:null),this._values[e]=t},n._getVector2=function(e){return this._values[e]},n._setColor=function(e,t){this._shaderValues.setValue(e,t?t.elements:null),this._values[e]=t},n._getColor=function(e){return this._values[e]},n._setTexture=function(e,t){var n=this._values[e];this._values[e]=t,this._shaderValues.setValue(e,t),this.referenceCount>0&&(n&&n._removeReference(),t&&t._addReference())},n._getTexture=function(e){return this._values[e]},n._upload=function(){this._shader.uploadMaterialUniforms(this._shaderValues.data)},n._getShader=function(e,t,n){var i=(e|t)&~this._disablePublicShaderDefine;return this._shader=this._shaderCompile.withCompile(i,n,this._shaderDefineValue),this._shader},n._setRenderStateBlendDepth=function(){var e=b.mainContext;switch(F.setDepthMask(e,this.depthWrite),0===this.depthTest?F.setDepthTest(e,!1):(F.setDepthTest(e,!0),F.setDepthFunc(e,this.depthTest)),this.blend){case 0:F.setBlend(e,!1);break;case 1:F.setBlend(e,!0),F.setBlendFunc(e,this.srcBlend,this.dstBlend);break;case 2:F.setBlend(e,!0)}},n._setRenderStateFrontFace=function(e,t){var n=b.mainContext,i=0;switch(this.cull){case 0:F.setCullFace(n,!1);break;case 1:F.setCullFace(n,!0),i=e?t&&t._isFrontFaceInvert?2305:2304:t&&t._isFrontFaceInvert?2304:2305,F.setFrontFace(n,i);break;case 2:F.setCullFace(n,!0),i=e?t&&t._isFrontFaceInvert?2304:2305:t&&t._isFrontFaceInvert?2305:2304,F.setFrontFace(n,i)}},n.onAsynLoaded=function(e,t,n){var i=t[0],r=t[1];switch(i.version){case"LAYAMATERIAL:01":var a=0,o=0,s=i.props;for(var l in s)switch(l){case"vectors":var h=s[l];for(a=0,o=h.length;a<o;a++){var _=h[a],u=_.value;switch(u.length){case 2:this[_.name]=new Lt(u[0],u[1]);break;case 3:this[_.name]=new bt(u[0],u[1],u[2]);break;case 4:this[_.name]=new Ft(u[0],u[1],u[2],u[3]);break;default:throw new Error("BaseMaterial:unkonwn color length.")}}break;case"textures":var c=s[l];for(a=0,o=c.length;a<o;a++){var d=c[a],f=d.path;f&&(this[d.name]=S.getRes(r[f]))}break;case"defines":var m=s[l];for(a=0,o=m.length;a<o;a++){var p=this._shaderCompile.getMaterialDefineByName(m[a]);this._addShaderDefine(p)}break;default:this[l]=s[l]}break;default:throw new Error("BaseMaterial:unkonwn version.")}this._endLoaded()},n._addReference=function(){e.prototype._addReference.call(this);for(var t=0,n=this._values.length;t<n;t++){var i=this._values[t];i&&i instanceof laya.d3.resource.BaseTexture&&i._addReference()}},n._removeReference=function(){e.prototype._removeReference.call(this);for(var t=0,n=this._values.length;t<n;t++){var i=this._values[t];i&&i instanceof laya.d3.resource.BaseTexture&&i._removeReference()}},n.disposeResource=function(){this.blendConstColor=null,this._shader=null,this._shaderValues=null;for(var e=0,t=this._values.length;e<t;e++){var n=this._values[e];n&&n instanceof laya.d3.resource.BaseTexture&&n._removeReference()}this._values=null},n.setShaderName=function(e){var t=Gn.nameKey.getID(e);if(-1===t)throw new Error("BaseMaterial: unknown shader name.");this._shaderCompile=fn._preCompileShader[t]},n.cloneTo=function(e){var t=e;t.name=this.name,t.cull=this.cull,t.blend=this.blend,t.srcBlend=this.srcBlend,t.dstBlend=this.dstBlend,t.srcBlendRGB=this.srcBlendRGB,t.dstBlendRGB=this.dstBlendRGB,t.srcBlendAlpha=this.srcBlendAlpha,t.dstBlendAlpha=this.dstBlendAlpha,this.blendConstColor.cloneTo(t.blendConstColor),t.blendEquation=this.blendEquation,t.blendEquationRGB=this.blendEquationRGB,t.blendEquationAlpha=this.blendEquationAlpha,t.depthTest=this.depthTest,t.depthWrite=this.depthWrite,t.renderQueue=this.renderQueue,t._shader=this._shader,t._disablePublicShaderDefine=this._disablePublicShaderDefine,t._shaderDefineValue=this._shaderDefineValue;var n,i=0,r=t._shaderValues;t._shaderValues.data.length=this._shaderValues.data.length;var a=this._values.length,o=t._values;for(o.length=a,i=0,n=a;i<n;i++){var s=this._values[i];if(s)if("number"==typeof s)o[i]=s,r.data[i]=s;else if("number"==typeof s&&Math.floor(s)==s)o[i]=s,r.data[i]=s;else if("boolean"==typeof s)o[i]=s,r.data[i]=s;else if(s instanceof laya.d3.math.Vector2){var l=o[i]||(o[i]=new Lt);s.cloneTo(l),r.data[i]=l.elements}else if(s instanceof laya.d3.math.Vector3){var h=o[i]||(o[i]=new bt);s.cloneTo(h),r.data[i]=h.elements}else if(s instanceof laya.d3.math.Vector4){var _=o[i]||(o[i]=new Ft);s.cloneTo(_),r.data[i]=_.elements}else if(s instanceof laya.d3.math.Matrix4x4){var u=o[i]||(o[i]=new Ct);s.cloneTo(u),r.data[i]=u.elements}else s instanceof laya.d3.resource.BaseTexture&&(o[i]=s,r.data[i]=s)}},n.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},l(0,n,"alphaTestValue",function(){return this._getNumber(0)},function(e){this._setNumber(0,e)}),l(0,n,"alphaTest",function(){return this._alphaTest},function(e){this._alphaTest=e,e?this._addShaderDefine(laya.d3.core.material.BaseMaterial.SHADERDEFINE_ALPHATEST):this._removeShaderDefine(laya.d3.core.material.BaseMaterial.SHADERDEFINE_ALPHATEST)}),t.__init__=function(){t.SHADERDEFINE_ALPHATEST=t.shaderDefines.registerDefine("ALPHATEST")},t.CULL_NONE=0,t.CULL_FRONT=1,t.CULL_BACK=2,t.BLEND_DISABLE=0,t.BLEND_ENABLE_ALL=1,t.BLEND_ENABLE_SEPERATE=2,t.BLENDPARAM_ZERO=0,t.BLENDPARAM_ONE=1,t.BLENDPARAM_SRC_COLOR=768,t.BLENDPARAM_ONE_MINUS_SRC_COLOR=769,t.BLENDPARAM_DST_COLOR=774,t.BLENDPARAM_ONE_MINUS_DST_COLOR=775,t.BLENDPARAM_SRC_ALPHA=770,t.BLENDPARAM_ONE_MINUS_SRC_ALPHA=771,t.BLENDPARAM_DST_ALPHA=772,t.BLENDPARAM_ONE_MINUS_DST_ALPHA=773,t.BLENDPARAM_SRC_ALPHA_SATURATE=776,t.BLENDEQUATION_ADD=0,t.BLENDEQUATION_SUBTRACT=1,t.BLENDEQUATION_REVERSE_SUBTRACT=2,t.DEPTHTEST_OFF=0,t.DEPTHTEST_NEVER=512,t.DEPTHTEST_LESS=513,t.DEPTHTEST_EQUAL=514,t.DEPTHTEST_LEQUAL=515,t.DEPTHTEST_GREATER=516,t.DEPTHTEST_NOTEQUAL=517,t.DEPTHTEST_GEQUAL=518,t.DEPTHTEST_ALWAYS=519,t.SHADERDEFINE_ALPHATEST=1,t.ALPHATESTVALUE=0,o(t,["shaderDefines",function(){return this.shaderDefines=new Gt}]),t}(y),Tn=function(e){function t(){this._type=0,this._width=0,this._height=0,this._size=null,this._repeat=!1,this._mipmap=!1,this._minFifter=0,this._magFifter=0,this._format=0,this._source=null,t.__super.call(this),this._conchTexture,this._repeat=!0,this.mipmap=!0,this.minFifter=-1,this.magFifter=-1}s(t,"laya.d3.resource.BaseTexture",y);var n=t.prototype;return l(0,n,"width",function(){return this._width}),l(0,n,"format",function(){return this._format}),l(0,n,"repeat",function(){return this._repeat},function(e){if(this._repeat!==e&&(this._repeat=e,this._source)){var t=b.mainContext;F.bindTexture(t,this._type,this._source),c.isPOT(this._width,this._height)&&this._repeat?(t.texParameteri(this._type,10242,10497),t.texParameteri(this._type,10243,10497)):(t.texParameteri(this._type,10242,33071),t.texParameteri(this._type,10243,33071))}}),l(0,n,"height",function(){return this._height}),l(0,n,"magFifter",function(){return this._magFifter},function(e){this._magFifter=e,e!=this._magFifter&&this._conchTexture&&this._conchTexture.setMaxFifter(e)}),l(0,n,"size",function(){return this._size}),l(0,n,"mipmap",function(){return this._mipmap},function(e){this._mipmap=e,this._mipmap!=e&&this._conchTexture&&this._conchTexture.setMipMap(e)}),l(0,n,"minFifter",function(){return this._minFifter},function(e){this._minFifter=e,this._minFifter!=e&&this._conchTexture&&this._conchTexture.setMinFifter(e)}),l(0,n,"source",function(){return this.activeResource(),this._source}),l(0,n,"defaulteTexture",function(){return hi.grayTexture}),t}(),Sn=function(e){function t(){this._subMeshCount=0,this._boundingBox=null,this._boundingSphere=null,this._boundingBoxCorners=null,this._positions=null,t.__super.call(this),this._boundingBoxCorners=h(8,null)}s(t,"laya.d3.resource.models.BaseMesh",y);var n=t.prototype;return n._getPositions=function(){throw new Error("未Override,请重载该属性！")},n._generateBoundingObject=function(){this._boundingSphere=new Rt(new bt,0),Rt.createfromPoints(this._positions,this._boundingSphere),this._boundingBox=new xt(new bt,new bt),xt.createfromPoints(this._positions,this._boundingBox),this._boundingBox.getCorners(this._boundingBoxCorners)},n.getRenderElementsCount=function(){throw new Error("未Override,请重载该属性！")},n.getRenderElement=function(e){throw new Error("未Override,请重载该属性！")},l(0,n,"subMeshCount",function(){return this._subMeshCount}),l(0,n,"boundingBox",function(){return this._boundingBox}),l(0,n,"boundingBoxCorners",function(){return this._boundingBoxCorners}),l(0,n,"boundingSphere",function(){return this._boundingSphere}),t}(),xn=function(e){function t(){this._terrainHeightData=null,this._width=0,this._height=0,this._bitType=0,this._value=NaN,t.__super.call(this)}return s(t,"laya.d3.terrain.TerrainHeightData",y),t.prototype.onAsynLoaded=function(e,t,n){this._width=n[0],this._height=n[1],this._bitType=n[2],this._value=n[3];var i,r=NaN;8==this._bitType?(i=new Uint8Array(t),r=1/255):16==this._bitType&&(i=new Int16Array(t),r=1/32766),this._terrainHeightData=new Float32Array(this._height*this._width);for(var a=0,o=this._height*this._width;a<o;a++)this._terrainHeightData[a]=i[a]*r*this._value/2;this._endLoaded()},t.load=function(e,n,i,r,o){return a.loader.create(e,null,null,t,[n,i,r,o],1,!1)},t}(),Mn=function(e){function t(){this._version=NaN,this._cameraCoordinateInverse=!1,this._gridSize=NaN,this._chunkNumX=0,this._chunkNumZ=0,this._heightDataX=0,this._heightDataZ=0,this._heightDataBitType=0,this._heightDataValue=NaN,this._heightDataUrl=null,this._detailTextureInfos=null,this._chunkInfos=null,this._heightData=null,this._materialInfo=null,this._alphaMaps=null,this._normalMaps=null,t.__super.call(this)}s(t,"laya.d3.terrain.TerrainRes",y);var n=t.prototype;return n.parseData=function(e){var t=e[0],n=e[1];if(this._version=t.version,1==this._version){this._cameraCoordinateInverse=t.cameraCoordinateInverse,this._gridSize=t.gridSize,this._chunkNumX=t.chunkNumX,this._chunkNumZ=t.chunkNumZ;var i=t.heightData;if(this._heightDataX=i.numX,this._heightDataZ=i.numZ,this._heightDataBitType=i.bitType,this._heightDataValue=i.value,this._heightDataUrl=n[i.url],this._materialInfo=new jt,t.material){var r=t.material.ambient,a=t.material.diffuse,o=t.material.specular;this._materialInfo.ambientColor=new bt(r[0],r[1],r[2]),this._materialInfo.diffuseColor=new bt(a[0],a[1],a[2]),this._materialInfo.specularColor=new Ft(o[0],o[1],o[2],o[3])}var s=t.detailTexture;this._detailTextureInfos=h(s.length);for(var l=0;l<s.length;l++){var _=s[l],u=new Yt;u.diffuseTexture=n[_.diffuse],u.normalTexture=_.normal?n[_.normal]:null,_.scale?u.scale=new Lt(_.scale[0],_.scale[1]):u.scale=new Lt(1,1),_.offset?u.offset=new Lt(_.offset[0],_.offset[1]):u.offset=new Lt(0,0),this._detailTextureInfos[l]=u}var c=t.alphaMap;for(this._alphaMaps=h(c.length),l=0;l<this._alphaMaps.length;l++)this._alphaMaps[l]=t.alphaMap[l];var d=t.normalMap;for(this._normalMaps=h(d.length),l=0;l<this._normalMaps.length;l++)this._normalMaps[l]=t.normalMap[l];var f=t.chunkInfo;if(this._chunkNumX*this._chunkNumZ!=f.length)return alert("terrain data error"),!1;for(this._chunkInfos=h(f.length),l=0;l<f.length;l++){var m=f[l],p=new Zt,v=m.alphaMap.length,E=m.detailID.length;if(v!=E)return alert("terrain chunk data error"),!1;p.alphaMap=h(v),p.detailID=h(E),p.normalMap=n[this._normalMaps[m.normalMap]];for(var g=0;g<v;g++){p.alphaMap[g]=n[this._alphaMaps[m.alphaMap[g]]];var D=m.detailID[g],T=D.length;p.detailID[g]=new Uint8Array(T);for(var x=0;x<T;x++)p.detailID[g][x]=D[x]}this._chunkInfos[l]=p}this._heightData=S.getRes(this._heightDataUrl),this.onLoadTerrainComplete(this._heightData)}return!0},n.onLoadTerrainComplete=function(e){this._endLoaded()},n.onAsynLoaded=function(e,t,n){this.parseData(t)},t.load=function(e){return a.loader.create(e,null,null,t,null,1,!1)},t}(),Rn=function(e){function t(){this._player=null,this._templet=null,t.__super.call(this),this._player=new _}s(t,"laya.d3.component.animation.KeyframeAnimations",e);var n=t.prototype;return n._updateAnimtionPlayer=function(){this._player._update(a.timer.delta)},n._addUpdatePlayerToTimer=function(){a.timer.frameLoop(1,this,this._updateAnimtionPlayer)},n._removeUpdatePlayerToTimer=function(){a.timer.clear(this,this._updateAnimtionPlayer)},n._onOwnerActiveHierarchyChanged=function(e){this._owner.displayedInStage&&(e?this._addUpdatePlayerToTimer():this._removeUpdatePlayerToTimer())},n._load=function(e){e.activeInHierarchy&&this._addUpdatePlayerToTimer(),e.on("activeinhierarchychanged",this,this._onOwnerActiveHierarchyChanged)},n._unload=function(t){e.prototype._unload.call(this,t),t.activeInHierarchy&&this._removeUpdatePlayerToTimer(),t.off("activeinhierarchychanged",this,this._onOwnerActiveHierarchyChanged),this._player._destroy(),this._player=null,this._templet=null},l(0,n,"url",null,function(e){console.log("Warning: discard property,please use templet property instead.");var t=a.loader.create(e,null,null,u);this._templet!==t&&(0!==this._player.state&&this._player.stop(!0),this._templet=t,this._player.templet=t,this.event("animationchanged",this))}),l(0,n,"player",function(){return this._player}),l(0,n,"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))}),l(0,n,"currentFrameIndex",function(){return this._player.currentKeyframeIndex}),l(0,n,"currentAnimationClipIndex",function(){return this._player.currentAnimationClipIndex}),l(0,n,"nodeCount",function(){return this._templet.getNodeCount(this._player.currentAnimationClipIndex)}),t}(nn),An=function(e){function t(){t.__super.call(this),this._clipNames=[],this._clips=[],this._playStartFrames=[],this._playEndFrames=[],this._cacheNodesSpriteOwners=[],this._cacheNodesAvatarOwners=[],this._cacheNodesDefaultlValues=[],this._cacheNodesToSpriteMap=[],this._cacheSpriteToNodesMap=[],this._cacheFullFrames=[],this._publicClipsDatas=[],this._playEventIndex=-1,this._updateTransformPropertyLoopCount=-1,this._lastFrameIndex=-1,this._defaultClipIndex=-1,this._cachePlayRate=1,this._currentPlayClip=null,this._currentFrameIndex=-1,this._currentTime=0,this._elapsedPlaybackTime=0,this._startUpdateLoopCount=-1,this.isCache=!0,this.cacheFrameRate=60,this.playbackRate=1,this.playOnWake=!0}s(t,"laya.d3.component.Animator",e);var n=t.prototype;return a.imps(n,{"laya.resource.IDestroy":!0}),n._getAvatarOwnersByClip=function(e){var t=this._clips[e]._nodes,n=t.length,i=this._cacheNodesAvatarOwners[e];i.length=n;var r=this._cacheNodesDefaultlValues[e];r.length=n;for(var a=0;a<n;a++){for(var o=this._avatarNodes[0],s=t[a],l=s.path,h=0,_=l.length;h<_;h++){var u=l[h];if(""===u)break;if(!(o=o.getChildByName(u)))break}if(o){i[a]=o;var c=G._propertyGetFuncs[s.propertyNameID](o);if(c){var d=new Float32Array(s.keyFrameWidth);for(r[a]=d,h=0,_=c.length;h<_;h++)d[h]=c[h]}}}},n._handleSpriteOwnersByClip=function(e){var t=this._clips[e]._nodes,n=t.length,i=this._cacheNodesSpriteOwners[e];i.length=n;var r=this._cacheNodesDefaultlValues[e];r.length=n;for(var a=0;a<n;a++){var o=this._owner,s=t[a],l=s.path,h=0,_=0;for(h=0,_=l.length;h<_;h++){var u=l[h];if(""===u)break;if(!(o=o.getChildByName(u)))break}if(o){i[a]=o;var c=G._propertyGetFuncs[s.propertyNameID](null,o);if(c){var d=new Float32Array(s.keyFrameWidth);for(r[a]=d,h=0,_=c.length;h<_;h++)d[h]=c[h]}}}},n._offClipAndAvatarRelateEvent=function(e,t){e.loaded?t.loaded||t.off("loaded",this,this._getAvatarOwnersByClip):e.off("loaded",this,this._getAvatarOwnersAndInitDatasAsync)},n._getAvatarOwnersByClipAsync=function(e,t){t.loaded?this._getAvatarOwnersByClip(e):t.once("loaded",this,this._getAvatarOwnersByClip,[e])},n._offGetSpriteOwnersByClipAsyncEvent=function(e){e.loaded||e.off("loaded",this,this._getSpriteOwnersByClipAsync)},n._getSpriteOwnersByClipAsync=function(e,t){t.loaded?this._handleSpriteOwnersByClip(e):t.once("loaded",this,this._handleSpriteOwnersByClip,[e])},n._getAvatarOwnersAndInitDatasAsync=function(){for(var e=0,t=this._clips.length;e<t;e++)this._getAvatarOwnersByClipAsync(e,this._clips[e]);for(this._avatar._cloneDatasToAnimator(this),e=0,t=this._avatarNodes.length;e<t;e++)this._checkAnimationNode(this._avatarNodes[e],this._owner)},n._offGetClipCacheFullKeyframeIndicesEvent=function(e){e.loaded||e.off("loaded",this,this._computeCacheFullKeyframeIndices)},n._computeCacheFullKeyframeIndices=function(e){var t=this._clips[e],n=this._cacheFrameRateInterval*this._cachePlayRate,i=t._getFullKeyframeIndicesWithCache(n);if(i)this._cacheFullFrames[e]=i;else{i=this._cacheFullFrames[e]=[];var r=t._nodes,a=r.length;i.length=a;for(var o=Math.ceil(t._duration/n-1e-5)+1,s=0;s<a;s++){var l=r[s],h=new Int32Array(o);h.fill(-1);for(var _=l.keyFrames,u=0,c=_.length;u<c;u++)for(var d=_[u],f=d.startTime,m=f+d.duration;f<=m;)h[Math.ceil(f/n-1e-5)]=u,f+=n;i[s]=h}t._cacheFullKeyframeIndices(n,i)}},n._updateAnimtionPlayer=function(){this._updatePlayer(a.timer.delta/1e3)},n._onOwnerActiveHierarchyChanged=function(){this._owner.activeInHierarchy?(a.timer.frameLoop(1,this,this._updateAnimtionPlayer),this.playOnWake&&this.clip&&this.play()):(0!==this.playState&&(this._stoped=!0),a.timer.clear(this,this._updateAnimtionPlayer))},n._eventScript=function(e,t){for(var n=this._currentPlayClip._animationEvents,i=n.length;this._playEventIndex<i;this._playEventIndex++){var r=n[this._playEventIndex],a=r.time;if(!(e<=a&&a<t))break;for(var o=this._owner._scripts,s=0,l=o.length;s<l;s++){var h=o[s],_=h[r.eventName];_&&_.apply(h,r.params)}}},n._setPlayParams=function(e,t){var n=this._currentTime;this._currentTime=e,this._currentFrameIndex=Math.max(Math.floor(this.currentPlayTime/t-1e-5),0),this._currentFrameTime=this._currentFrameIndex*t,this._eventScript(n,e)},n._setPlayParamsWhenStop=function(e,t){var n=this._currentTime;this._currentTime=e,this._currentFrameIndex=Math.max(Math.floor(e/t-1e-5),0),this._currentFrameTime=this._currentFrameIndex*t,this._eventScript(n,e),this._currentPlayClip=null},n._revertKeyframeNodes=function(e,t){var n=this._cacheNodesDefaultlValues[t],i=e._nodes;if(this._avatar)for(var r=this._cacheNodesAvatarOwners[t],a=0,o=r.length;a<o;a++){var s=r[a];s&&G._propertySetFuncs[i[a].propertyNameID](s,null,n[a])}else{var l=this._cacheNodesSpriteOwners[t];for(a=0,o=l.length;a<o;a++){var h=l[a];h&&G._propertySetFuncs[i[a].propertyNameID](null,h,n[a])}}},n._onAnimationStop=function(){var e,t,n,i=0,r=0;this._lastFrameIndex=-1;var a=this._currentPlayClip._nodes;if(this._avatar){var o=this._cacheNodesAvatarOwners[this._currentPlayClipIndex];for(i=0,r=o.length;i<r;i++){var s=o[i];n=(t=(e=a[i]).keyFrames)[t.length-1].data,s&&G._propertySetFuncs[e.propertyNameID](s,null,n)}}else{var l=this._cacheNodesSpriteOwners[this._currentPlayClipIndex];for(i=0,r=l.length;i<r;i++){var h=l[i];n=(t=(e=a[i]).keyFrames)[t.length-1].data,h&&G._propertySetFuncs[e.propertyNameID](null,h,n)}}},n._setAnimationClipPropertyToAnimationNode=function(e,t,n){for(var i=0,r=t.length;i<r;i++){var a=t[i],o=e[a];if(o){var s=this._currentPlayClip._nodes[a],l=n[a];l&&G._propertySetFuncs[s.propertyNameID](o,null,l)}}},n._setAnimationClipPropertyToSprite3D=function(e,t){for(var n=0,i=e.length;n<i;n++){var r=e[n];if(r){var a=this._currentPlayClip._nodes[n],o=t[n];o&&G._propertySetFuncs[a.propertyNameID](null,r,o)}}},n._handleSpriteOwnersBySprite=function(e,t,n,i){var r=this._clips[e],a=n.join("/"),o=r._nodesMap[a];if(o)for(var s=this._cacheNodesSpriteOwners[e],l=r._nodes,h=this._cacheNodesDefaultlValues[e],_=0,u=o.length;_<u;_++){var c=o[_],d=l.indexOf(c);if(t){s[d]=i;var f=G._propertyGetFuncs[c.propertyNameID](null,i);if(f){var m=h[d];m||(h[d]=m=new Float32Array(c.keyFrameWidth));for(var p=0,v=f.length;p<v;p++)m[p]=f[p]}}else s[d]=null}},n._evaluateAvatarNodesCacheMode=function(e,n,i,r,a){n._evaluateAnimationlDatasCacheMode(e,this._cacheFullFrames[this._currentPlayClipIndex],this,i,a),this._setAnimationClipPropertyToAnimationNode(e,a,i);for(var o=0,s=this._avatarNodes.length;o<s;o++){var l=this._avatarNodes[o].transform;if(l._worldUpdate){var h=new Float32Array(16);r[o]=h,l._setWorldMatrixAndUpdate(h)}else{var _=l.getWorldMatrix();r[o]=_||t.deafaultMatrix}}},n._evaluateAvatarNodesRealTime=function(e,n,i,r,a){n._evaluateAnimationlDatasRealTime(e,this.currentPlayTime,i,a),this._setAnimationClipPropertyToAnimationNode(e,a,i);for(var o=0,s=this._avatarNodes.length;o<s;o++){var l=this._avatarNodes[o].transform;l._worldUpdate?l._setWorldMatrixNoUpdate(r[o]):r[o]=t.deafaultMatrix}},n._updateAvatarNodesToSpriteCacheMode=function(e,n){for(var i=0,r=this._cacheSpriteToNodesMap.length;i<r;i++){var a=this._cacheSpriteToNodesMap[i],o=n[a];if(o!==t.deafaultMatrix){var s=this._avatarNodes[a].transform._entity,l=s.worldMatrix;Jt.matrix4x4MultiplyMFM(this._owner._transform.worldMatrix,o,l),s.worldMatrix=l}}},n._updateAvatarNodesToSpriteRealTime=function(){for(var e=0,n=this._cacheSpriteToNodesMap.length;e<n;e++){var i=this._avatarNodes[this._cacheSpriteToNodesMap[e]],r=i.transform._entity,a=i.transform;if(a._worldUpdate){var o=t._tempMatrix4x40;a._setWorldMatrixAndUpdate(o);var s=r.worldMatrix;Jt.matrix4x4MultiplyMFM(this._owner._transform.worldMatrix,o,s),r.worldMatrix=s}}},n._updatePlayer=function(e){if(null!=this._currentPlayClip&&!this._stoped&&this._currentPlayClip.loaded){var t=this._cacheFrameRateInterval*this._cachePlayRate,n=0;this._startUpdateLoopCount!==w.loopCount&&(n=e*this.playbackRate,this._elapsedPlaybackTime+=n);var i=this._currentPlayClip._frameRate,r=this._playStartFrames[this._currentPlayClipIndex]/i,a=Math.min(this._playEndFrames[this._currentPlayClipIndex]/i,this._currentPlayClip._duration)-r;if(!this._currentPlayClip.islooping&&this._elapsedPlaybackTime>=a)return this._onAnimationStop(),this._setPlayParamsWhenStop(a,t),void this.event("stopped");if(n+=this._currentTime,a>0)if(n>=a)do{(n-=a)<a&&(this._setPlayParams(n,t),this.event("complete")),this._playEventIndex=0,this._eventScript(0,n)}while(n>=a);else this._setPlayParams(n,t);else this._currentTime=this._currentFrameTime=this._currentFrameIndex=this._playEventIndex=0,this.event("complete")}},n._update=function(e){var t=this._currentPlayClip;if(2===this.playState&&t&&t.loaded){var n=this.playbackRate*a.timer.scale,i=this._cachePlayRate;this._canCache=this.isCache&&n>=i;var r,o=-1;if(this._canCache){if(o=this._currentFrameIndex,this._lastFrameIndex===o)return;if(r=t._getAnimationDataWithCache(i,o),this._avatar){var s=this._cacheNodesAvatarOwners[this._currentPlayClipIndex],l=t._cachePropertyMap,h=l.length;h>0&&(r||((r=[]).length=h,t._cacheAnimationData(i,o,r),t._evaluateAnimationlDatasCacheMode(s,this._cacheFullFrames[this._currentPlayClipIndex],this,r,l)),this._setAnimationClipPropertyToAnimationNode(s,l,r)),this._curAvatarNodeDatas=t._getAvatarDataWithCache(this._avatar,this._cachePlayRate,o),this._curAvatarNodeDatas||(this._curAvatarNodeDatas=[],this._curAvatarNodeDatas.length=this._avatarNodes.length,t._cacheAvatarData(this._avatar,this._cachePlayRate,o,this._curAvatarNodeDatas),this._evaluateAvatarNodesCacheMode(s,t,t._publicClipDatas,this._curAvatarNodeDatas,t._unCachePropertyMap)),this._updateAvatarNodesToSpriteCacheMode(t,this._curAvatarNodeDatas)}else{var _=this._cacheNodesSpriteOwners[this._currentPlayClipIndex];r||((r=[]).length=this._currentPlayClip._nodes.length,t._evaluateAnimationlDatasCacheMode(_,this._cacheFullFrames[this._currentPlayClipIndex],this,r,null),t._cacheAnimationData(i,o,r)),this._setAnimationClipPropertyToSprite3D(_,r)}}else if(r=t._publicClipDatas,this._avatar){if(t._evaluateAnimationlDatasRealTime(this._cacheNodesAvatarOwners[this._currentPlayClipIndex],this.currentPlayTime,r,t._cachePropertyMap),!this._publicAvatarNodeDatas){this._publicAvatarNodeDatas=[];var u=this._avatarNodes.length;this._publicAvatarNodeDatas.length=u;for(var c=1;c<u;c++)this._publicAvatarNodeDatas[c]=new Float32Array(16)}this._curAvatarNodeDatas=this._publicAvatarNodeDatas,this._evaluateAvatarNodesRealTime(this._cacheNodesAvatarOwners[this._currentPlayClipIndex],t,r,this._curAvatarNodeDatas,t._unCachePropertyMap),this._updateAvatarNodesToSpriteRealTime()}else t._evaluateAnimationlDatasRealTime(this._cacheNodesSpriteOwners[this._currentPlayClipIndex],this.currentPlayTime,r,null);this._lastFrameIndex=o}},n._checkAnimationNode=function(e,t){e.name!==t.name||t._transform.dummy||t._isLinkSpriteToAnimationNode(this,e,!0);for(var n=0,i=t._childs.length;n<i;n++)this._checkAnimationNode(e,t.getChildAt(n))},n._load=function(e){e.activeInHierarchy&&a.timer.frameLoop(1,this,this._updateAnimtionPlayer),this._owner.on("activeinhierarchychanged",this,this._onOwnerActiveHierarchyChanged)},n._unload=function(t){e.prototype._unload.call(this,t),t.activeInHierarchy&&a.timer.clear(this,this._updateAnimtionPlayer),this._owner.off("activeinhierarchychanged",this,this._onOwnerActiveHierarchyChanged),this._curAvatarNodeDatas=null},n._destroy=function(){e.prototype._destroy.call(this);for(var t=0,n=this._clips.length;t<n;t++)this._clips[t]._removeReference();this._currentPlayClip=null,this._clipNames=null,this._cacheNodesSpriteOwners=null,this._cacheNodesAvatarOwners=null,this._cacheNodesDefaultlValues=null,this._clips=null,this._cacheFullFrames=null},n._cloneTo=function(e){var t=e;t.avatar=this.avatar,this._clips.length;for(var n=0,i=this._clips.length;n<i;n++)t.addClip(this._clips[n]);this.clip&&(t.clip=this.clip)},n.addClip=function(e,t,n,i){void 0===n&&(n=0),void 0===i&&(i=4294967295),t=t||e.name;var r=this._clipNames.indexOf(t);if(-1!==r){if(this._clips[r]!==e)throw new Error("Animation:this playName has exist with another clip.")}else{var a=this._clips.indexOf(e);if(n<0||i<0)throw new Error("Animator:startFrame and endFrame must large than zero.");if(n>i)throw new Error("Animator:startFrame must less than endFrame.");this._clipNames.push(t),this._clips.push(e),this._playStartFrames.push(n),this._playEndFrames.push(i),this._cacheNodesSpriteOwners.push([]),this._cacheNodesAvatarOwners.push([]),this._cacheNodesDefaultlValues.push([]),this._publicClipsDatas.push([]),e._addReference(),a=this._clips.length-1,this._avatar?this._avatar.loaded?this._getAvatarOwnersByClipAsync(a,e):this._avatar.once("loaded",this,this._getAvatarOwnersByClipAsync,[a,e]):this._getSpriteOwnersByClipAsync(a,e),e.loaded?this._computeCacheFullKeyframeIndices(a):e.once("loaded",this,this._computeCacheFullKeyframeIndices,[a])}},n.removeClip=function(e){var t=this._clips.indexOf(e);-1!==t&&(this._avatar?this._offClipAndAvatarRelateEvent(this._avatar,e):this._offGetSpriteOwnersByClipAsyncEvent(e),this._offGetClipCacheFullKeyframeIndicesEvent(e),this._clipNames.splice(t,1),this._clips.splice(t,1),this._playStartFrames.splice(t,1),this._playEndFrames.splice(t,1),this._cacheNodesSpriteOwners.splice(t,1),this._cacheNodesAvatarOwners.splice(t,1),this._cacheNodesDefaultlValues.splice(t,1),this._publicClipsDatas.splice(t,1),e._removeReference())},n.removeClipByName=function(e){var t=this._clipNames.indexOf(e);if(-1!==t){var n=this._clips[t];this._avatar?this._offClipAndAvatarRelateEvent(this._avatar,n):this._offGetSpriteOwnersByClipAsyncEvent(n),this._offGetClipCacheFullKeyframeIndicesEvent(n),this._clipNames.splice(t,1),this._clips.splice(t,1),this._playStartFrames.splice(t,1),this._playEndFrames.splice(t,1),this._cacheNodesSpriteOwners.splice(t,1),this._cacheNodesAvatarOwners.splice(t,1),this._cacheNodesDefaultlValues.splice(t,1),this._publicClipsDatas.splice(t,1)}},n.getClip=function(e){var t=this._clipNames.indexOf(e);return-1!==t?this._clips[t]:null},n.getClipCount=function(){return this._clips.length},n.play=function(e,t){if(void 0===t&&(t=1),!e&&-1==this._defaultClipIndex)throw new Error("Animator:must have  default clip value,please set clip property.");e?(this._currentPlayClipIndex=this._clipNames.indexOf(e),this._currentPlayClip=this._clips[this._currentPlayClipIndex]):(this._currentPlayClipIndex=this._defaultClipIndex,this._currentPlayClip=this._clips[this._defaultClipIndex]),this._currentTime=0,this._currentFrameTime=0,this._elapsedPlaybackTime=0,this._playEventIndex=0,this.playbackRate=t,this._stoped=!1,this._currentFrameIndex=0,this._startUpdateLoopCount=w.loopCount,this._lastPlayAnimationClip&&this._lastPlayAnimationClip!==this._currentPlayClip&&this._revertKeyframeNodes(this._lastPlayAnimationClip,this._lastPlayAnimationClipIndex),this._updatePlayer(0),this._lastPlayAnimationClip=this._currentPlayClip,this._lastPlayAnimationClipIndex=this._currentPlayClipIndex},n.stop=function(){0!==this.playState&&(this._stoped=!0,this.event("stopped"))},n.linkSprite3DToAvatarNode=function(e,t){if(this._avatar){var n=this._avatarNodeMap[e];return!!n&&(t._isLinkSpriteToAnimationNode(this,n,!0),!0)}return!1},n.unLinkSprite3DToAvatarNode=function(e){if(this._avatar){var t=e.transform.dummy;if(t){var n=this._avatarNodeMap[t._owner.name];return e._isLinkSpriteToAnimationNode(this,n,!1),!0}return!1}return!1},l(0,n,"playState",function(){return null==this._currentPlayClip?0:this._stoped?0:2}),l(0,n,"avatar",function(){return this._avatar},function(e){if(this._avatar!==e){var t=this._avatar;this._avatar=e;for(var n=this._clips.length,i=0;i<n;i++)this._offClipAndAvatarRelateEvent(t,this._clips[i]);e&&(e.loaded?this._getAvatarOwnersAndInitDatasAsync():e.once("loaded",this,this._getAvatarOwnersAndInitDatasAsync))}}),l(0,n,"cacheFrameRate",function(){return this._cacheFrameRate},function(e){if(this._cacheFrameRate!==e){this._cacheFrameRate=e,this._cacheFrameRateInterval=1/this._cacheFrameRate;for(var t=0,n=this._clips.length;t<n;t++)this._clips[t].loaded&&this._computeCacheFullKeyframeIndices(t)}}),l(0,n,"clip",function(){return this._clips[this._defaultClipIndex]},function(e){var t=e?this._clips.indexOf(e):-1;this._defaultClipIndex!==t&&(-1!==this._defaultClipIndex&&this.removeClip(this._clips[this._defaultClipIndex]),-1!==t&&this.addClip(e,e.name),this._defaultClipIndex=t)}),l(0,n,"currentFrameIndex",function(){return this._currentFrameIndex}),l(0,n,"cachePlayRate",function(){return this._cachePlayRate},function(e){if(this._cachePlayRate!==e){this._cachePlayRate=e;for(var t=0,n=this._clips.length;t<n;t++)this._clips[t].loaded&&this._computeCacheFullKeyframeIndices(t)}}),l(0,n,"currentFrameTime",function(){return this._currentFrameTime}),l(0,n,"currentPlayClip",function(){return this._currentPlayClip}),l(0,n,"currentPlayTime",function(){return this._currentTime+this._playStartFrames[this._currentPlayClipIndex]/this._currentPlayClip._frameRate}),l(0,n,"playbackTime",null,function(e){if(null!=this._currentPlayClip&&this._currentPlayClip&&this._currentPlayClip.loaded){this._startUpdateLoopCount=w.loopCount;var t=this._cacheFrameRateInterval*this._cachePlayRate;this._currentTime=e,this._currentFrameIndex=Math.floor(this.currentPlayTime/t),this._currentFrameTime=this._currentFrameIndex*t}}),l(0,n,"paused",function(){return this._stoped},function(e){this._stoped=e,e&&this.event("paused")}),o(t,["deafaultMatrix",function(){return this.deafaultMatrix=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])},"_tempMatrix4x40",function(){return this._tempMatrix4x40=new Float32Array(16)}]),t}(nn),In=(function(e){function t(){this._attachSkeleton=null,this._extenData=null,this.attachBones=null,this.matrixs=null,t.__super.call(this),this.attachBones=[],this.matrixs=[]}s(t,"laya.d3.component.AttachPoint",e);var n=t.prototype;n._load=function(t){e.prototype._load.call(this,t),this._attachSkeleton=t.getComponentByType(ti)},n._update=function(e){if(this._attachSkeleton&&!this._attachSkeleton.destroyed&&0!==this._attachSkeleton.player.state&&this._attachSkeleton.curBonesDatas){var t=this._attachSkeleton.player,n=this._attachSkeleton.templet;this.matrixs.length=this.attachBones.length;for(var i=this._attachSkeleton.curBonesDatas,r=this.owner.transform.worldMatrix,a=0,o=this.attachBones.length;a<o;a++){var s=16*n.getNodeIndexWithName(t.currentAnimationClipIndex,this.attachBones[a]),l=this.matrixs[a];l||(l=this.matrixs[a]=new Ct);for(var h=l.elements,_=0;_<16;_++)h[_]=i[s+_];Ct.multiply(r,l,l)}this.event("complete")}}}(nn),function(e){function t(){t.__super.call(this),this._isRigidbody=!1,this._runtimeCollisonMap={},this._runtimeCollisonTestMap={},this._ignoreCollisonMap={},this.isTrigger=!0}s(t,"laya.d3.component.physics.Collider",e);var n=t.prototype;return n._clearCollsionMap=function(){for(var e in this._runtimeCollisonMap){var t=this._runtimeCollisonMap[e];delete t._runtimeCollisonMap[this.id],t._isRigidbody&&delete t._runtimeCollisonTestMap[this.id];var n=t.id;delete this._runtimeCollisonMap[n],this._isRigidbody&&delete this._runtimeCollisonTestMap[n]}},n._unload=function(e){for(var t in this._runtimeCollisonMap){var n=this._runtimeCollisonMap[t];delete n._runtimeCollisonMap[this.id],n._isRigidbody&&delete n._runtimeCollisonTestMap[this.id],delete this._ignoreCollisonMap[t]._ignoreCollisonMap[this.id]}},n._setIsRigidbody=function(e){if(this._isRigidbody!==e){this._isRigidbody=e;var t=this._owner;if(t.displayedInStage){var n=t.layer;n._removeCollider(this),n._addCollider(this)}}},n._getType=function(){return-1},n._collisonTo=function(e){return!1},n.raycast=function(e,t,n){throw void 0===n&&(n=1.79e308),new Error("Collider:Must override it.")},l(0,n,"enable",e.prototype._$get_enable,function(e){this._enable!==e&&(this._owner.displayedInStage&&(e||this._clearCollsionMap()),this._enable=e,this.event("enablechanged",this._enable))}),l(0,n,"isSingleton",function(){return t._isSingleton}),t._isSingleton=!1,t}(nn)),yn=function(e){function t(){t.__super.call(this)}return s(t,"laya.d3.component.Rigidbody",e),l(0,t.prototype,"enable",e.prototype._$get_enable,function(e){if(this._enable!==e){for(var t=this._owner._colliders,n=0,i=t.length;n<i;n++){var r=t[n];r._setIsRigidbody(e);var a=r._runtimeCollisonMap,o=r._runtimeCollisonTestMap;if(!e)for(var s in a)delete o[s]}this._enable=e,this.event("enablechanged",this._enable)}}),t}(nn),Cn=(function(e){function t(){t.__super.call(this)}s(t,"laya.d3.component.Script",nn);var n=t.prototype;n.onTriggerEnter=function(e){},n.onTriggerExit=function(e){},n.onTriggerStay=function(e){},l(0,n,"isSingleton",function(){return t._isSingleton}),t._isSingleton=!1}(),function(e){function t(e){t.__super.call(this,e)}s(t,"laya.d3.core.GlitterRender",an);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},n._renderUpdate=function(e){this._setShaderValueMatrix4x4(0,this._owner.transform.worldMatrix);var t=this._owner.getProjectionViewWorldMatrix(e);this._setShaderValueMatrix4x4(1,t);var n=this._owner.templet;return this._setShaderValueNumber(3,n.lifeTime),this._setShaderValueNumber(2,n._currentTime),!0},t}()),Nn=function(e){function t(e){this._owner=null,this._sharedMesh=null,t.__super.call(this),this._owner=e}s(t,"laya.d3.core.MeshFilter",e);var n=t.prototype;return n._sharedMeshLoaded=function(){this.event("loaded")},n._destroy=function(){e.prototype._destroy.call(this),this._owner=null,this._sharedMesh&&(this._sharedMesh._removeReference(),this._sharedMesh=null)},l(0,n,"sharedMesh",function(){return this._sharedMesh},function(e){var t=this._sharedMesh;t&&t._removeReference(),this._sharedMesh=e,e._addReference(),this.event("meshchanged",[this,t,e]),e.loaded||this._sharedMesh.once("loaded",this,this._sharedMeshLoaded)}),l(0,n,"_isAsyncLoaded",function(){return this._sharedMesh.loaded}),l(0,n,"_originalBoundingBoxCorners",function(){return this._sharedMesh.boundingBoxCorners}),l(0,n,"_originalBoundingSphere",function(){return this._sharedMesh.boundingSphere}),l(0,n,"_originalBoundingBox",function(){return this._sharedMesh.boundingBox}),t}(rn),On=function(e){function t(e){t.__super.call(this,e),e.meshFilter.on("meshchanged",this,this._onMeshChanged)}s(t,"laya.d3.core.MeshRender",an);var n=t.prototype;return n._onMeshChanged=function(e,t,n){n.loaded?this._boundingSphereNeedChange=this._boundingBoxNeedChange=this._boundingBoxCenterNeedChange=this._octreeNodeNeedChange=!0:n.once("loaded",this,this._onMeshLoaed)},n._onMeshLoaed=function(e,t){this._boundingSphereNeedChange=this._boundingBoxNeedChange=this._boundingBoxCenterNeedChange=this._octreeNodeNeedChange=!0},n._calculateBoundingSphereByInitSphere=function(e){var t,n=this._owner.transform,i=n.scale.elements,r=Math.abs(i[0]),a=Math.abs(i[1]),o=Math.abs(i[2]);t=r>=a&&r>=o?r:a>=o?a:o,bt.transformCoordinate(e.center,n.worldMatrix,this._boundingSphere.center),this._boundingSphere.radius=e.radius*t},n._calculateBoundBoxByInitCorners=function(e){for(var t=this._owner.transform.worldMatrix,n=0;n<8;n++)bt.transformCoordinate(e[n],t,an._tempBoundBoxCorners[n]);xt.createfromPoints(an._tempBoundBoxCorners,this._boundingBox)},n._calculateBoundingSphere=function(){var e=this._owner.meshFilter.sharedMesh;null==e||null==e.boundingSphere?this._boundingSphere.toDefault():this._calculateBoundingSphereByInitSphere(e.boundingSphere)},n._calculateBoundingBox=function(){var e=this._owner.meshFilter.sharedMesh;null==e||null==e.boundingBox?this._boundingBox.toDefault():this._calculateBoundBoxByInitCorners(e.boundingBoxCorners)},n._renderUpdate=function(e){var t=this._owner.transform;if(t){this._setShaderValueMatrix4x4(0,t.worldMatrix);var n=this._owner.getProjectionViewWorldMatrix(e);this._setShaderValueMatrix4x4(1,n)}else this._setShaderValueMatrix4x4(0,Ct.DEFAULT),this._setShaderValueMatrix4x4(1,e);return en.debugMode&&this._renderRenderableBoundBox(),!0},t}(),wn=function(e){function t(e){t.__super.call(this),this._tempRotationMatrix=new Ct,this._uvLength=new Lt,this._firstActiveElement=0,this._firstNewElement=0,this._firstFreeElement=0,this._firstRetiredElement=0,this._owner=e,this._ownerRender=e.particleRender,this._boundingBoxCorners=h(8,null),this._boundingSphere=new Rt(new bt,Number.MAX_VALUE),this._boundingBox=new xt(new bt(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),new bt(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)),this._currentTime=0,this._isEmitting=!1,this._isPlaying=!1,this._isPaused=!1,this._burstsIndex=0,this._frameRateTime=0,this._emissionTime=0,this._totalDelayTime=0,this._simulateUpdate=!1,this._bufferMaxParticles=1,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._startLifeTimeGradient=new te,this._startLifetimeConstantMin=0,this._startLifetimeConstantMax=5,this._startLifeTimeGradientMin=new te,this._startLifeTimeGradientMax=new te,this._maxStartLifetime=5,this.startSpeedType=0,this.startSpeedConstant=5,this.startSpeedConstantMin=0,this.startSpeedConstantMax=5,this.threeDStartSize=!1,this.startSizeType=0,this.startSizeConstant=1,this.startSizeConstantSeparate=new bt(1,1,1),this.startSizeConstantMin=0,this.startSizeConstantMax=1,this.startSizeConstantMinSeparate=new bt(0,0,0),this.startSizeConstantMaxSeparate=new bt(1,1,1),this.threeDStartRotation=!1,this.startRotationType=0,this.startRotationConstant=0,this.startRotationConstantSeparate=new bt(0,0,0),this.startRotationConstantMin=0,this.startRotationConstantMax=0,this.startRotationConstantMinSeparate=new bt(0,0,0),this.startRotationConstantMaxSeparate=new bt(0,0,0),this.randomizeRotationDirection=0,this.startColorType=0,this.startColorConstant=new Ft(1,1,1,1),this.startColorConstantMin=new Ft(1,1,1,1),this.startColorConstantMax=new Ft(1,1,1,1),this.gravityModifier=0,this.simulationSpace=1,this.scaleMode=0,this.playOnAwake=!0,this._rand=new Vt(0),this.autoRandomSeed=!0,this.randomSeed=new Uint32Array(1),this._randomSeeds=new Uint32Array(t._RANDOMOFFSET.length),this.isPerformanceMode=!0,this._emission=new K,this._emission.enbale=!0,this._owner.on("activeinhierarchychanged",this,this._onOwnerActiveHierarchyChanged)}s(t,"laya.d3.core.particleShuriKen.ShurikenParticleSystem",e);var n=t.prototype;return a.imps(n,{"laya.d3.core.render.IRenderable":!0,"laya.d3.core.IClone":!0}),n._getVertexBuffer=function(e){return void 0===e&&(e=0),0===e?this._vertexBuffer:null},n._getIndexBuffer=function(){return this._indexBuffer},n._generateBoundingSphere=function(){var e=this._boundingSphere.center.elements;e[0]=0,e[1]=0,e[2]=0,this._boundingSphere.radius=Number.MAX_VALUE},n._generateBoundingBox=function(){var e=this._owner.particleRender,n=this._boundingBox.min,i=this._boundingBox.max,r=0,a=0,o=NaN;switch(this.startLifetimeType){case 0:o=this.startLifetimeConstant;break;case 1:o=-Number.MAX_VALUE;var s=s;for(r=0,a=s.gradientCount;r<a;r++)o=Math.max(o,s.getValueByIndex(r));break;case 2:o=Math.max(this.startLifetimeConstantMin,this.startLifetimeConstantMax);break;case 3:o=-Number.MAX_VALUE;var l=l;for(r=0,a=l.gradientCount;r<a;r++)o=Math.max(o,l.getValueByIndex(r));var h=h;for(r=0,a=h.gradientCount;r<a;r++)o=Math.max(o,h.getValueByIndex(r))}var _,u,c,d,f=NaN,m=NaN;switch(this.startSpeedType){case 0:f=m=this.startSpeedConstant;break;case 1:break;case 2:f=this.startLifetimeConstantMin,m=this.startLifetimeConstantMax}this._shape&&this._shape.enable||(_=u=bt.ZERO,c=bt.ZERO,d=bt.UnitZ);var p=new bt(c.x*f,c.y*f,c.z*f),v=new bt(d.x*m,d.y*m,d.z*m);if(this._velocityOverLifetime&&this._velocityOverLifetime.enbale){var E=this._velocityOverLifetime.velocity;switch(E.type){case 0:E.constant;break;case 1:new bt(E.gradientX.getAverageValue(),E.gradientY.getAverageValue(),E.gradientZ.getAverageValue());break;case 2:E.constantMin,E.constantMax;break;case 3:new bt(E.gradientXMin.getAverageValue(),E.gradientYMin.getAverageValue(),E.gradientZMin.getAverageValue()),new bt(E.gradientXMax.getAverageValue(),E.gradientYMax.getAverageValue(),E.gradientZMax.getAverageValue())}}var g,D,T,S,x=this._owner.transform,M=x.position,R=t._tempVector39,A=R.elements,I=e.renderMode;switch(this.scaleMode){case 0:var y=x.scale;g=y,A[0]=y.x,A[1]=y.z,A[2]=y.y,1===I&&(D=y);break;case 1:var C=x.localScale;g=C,A[0]=C.x,A[1]=C.z,A[2]=C.y,1===I&&(D=C);break;case 2:g=x.scale,A[0]=A[1]=A[2]=1,1===I&&(D=bt.ONE)}switch(this._velocityOverLifetime&&this._velocityOverLifetime.enbale||(T=new bt(p.x*o,p.y*o,p.z*o),S=new bt(v.x*o,v.y*o,v.z*o),2!=this.scaleMode?(bt.add(_,T,n),bt.multiply(g,n,n),bt.add(u,S,i),bt.multiply(g,i,i)):(bt.multiply(g,_,n),bt.add(n,T,n),bt.multiply(g,u,i),bt.add(i,S,i))),this.simulationSpace){case 0:break;case 1:bt.add(n,M,n),bt.add(i,M,i)}var N=NaN,O=NaN;switch(this.startSizeType){case 0:if(this.threeDStartSize){var w=w;N=Math.max(w.x,w.y),1===I&&(O=w.y)}else N=this.startSizeConstant,1===I&&(O=this.startSizeConstant);break;case 1:break;case 2:if(this.threeDStartSize){var V=V;N=Math.max(V.x,V.y),1===I&&(O=V.y)}else N=this.startSizeConstantMax,1===I&&(O=this.startSizeConstantMax)}this._sizeOverLifetime&&this._sizeOverLifetime.enbale&&(this._sizeOverLifetime.size,N*=this._sizeOverLifetime.size.getMaxSizeInGradient());var P=t._tempVector30,L=P.elements,b=NaN,F=NaN;switch(I){case 0:b=N*t.halfKSqrtOf2,bt.scale(R,N,P),bt.subtract(n,P,n),bt.add(i,P,i);break;case 1:var B=t._tempVector31,U=t._tempVector32,H=t._tempVector33,G=t._tempVector34;this._velocityOverLifetime&&this._velocityOverLifetime.enbale||(bt.multiply(D,v,U),bt.multiply(D,p,H));var z=O*e.stretchedBillboardLengthScale,W=bt.scalarLength(U)*e.stretchedBillboardSpeedScale+z,k=bt.scalarLength(H)*e.stretchedBillboardSpeedScale+z,X=t._tempVector35,Z=t._tempVector36;bt.normalize(U,X),bt.scale(X,W,G),bt.subtract(S,G,G),bt.normalize(H,Z),bt.scale(Z,k,B),bt.add(T,B,B),b=N*t.halfKSqrtOf2,bt.scale(R,b,P);var Y=t._tempVector37,j=t._tempVector38;bt.scale(X,.5,Y),bt.scale(Z,.5,j),bt.multiply(Y,R,Y),bt.multiply(j,R,j),bt.add(n,j,n),bt.min(n,G,n),bt.subtract(n,P,n),bt.subtract(i,Y,i),bt.max(i,B,i),bt.add(i,P,i);break;case 2:F=.5*(N*=Math.cos(.7853981633974483)),L[0]=R.x*F,L[1]=R.z*F,bt.subtract(n,P,n),bt.add(i,P,i);break;case 3:F=.5*(N*=Math.cos(.7853981633974483)),bt.scale(R,F,P),bt.subtract(n,P,n),bt.add(i,P,i)}this._boundingBox.getCorners(this._boundingBoxCorners)},n._updateEmission=function(){if(a.stage.isVisibility&&this.isAlive)if(this._simulateUpdate)this._simulateUpdate=!1;else{var e=this._startUpdateLoopCount===w.loopCount||this._isPaused?0:a.timer.delta/1e3;e=Math.min(t._maxElapsedTime,e),this._updateParticles(e)}},n._updateParticles=function(e){(4!==this._ownerRender.renderMode||this._ownerRender.mesh)&&(this._currentTime+=e,this._retireActiveParticles(),this._freeRetiredParticles(),this._totalDelayTime+=e,this._totalDelayTime<this._playStartDelay||this._emission.enbale&&this._isEmitting&&!this._isPaused&&this._advanceTime(e,this._currentTime))},n._updateParticlesSimulationRestart=function(e){this._firstActiveElement=0,this._firstNewElement=0,this._firstFreeElement=0,this._firstRetiredElement=0,this._burstsIndex=0,this._frameRateTime=e,this._emissionTime=0,this._totalDelayTime=0,this._currentTime=e;var t=e;t<this._playStartDelay?this._totalDelayTime=t:this._emission.enbale&&this._advanceTime(e,e)},n._addUpdateEmissionToTimer=function(){a.timer.frameLoop(1,this,this._updateEmission)},n._removeUpdateEmissionToTimer=function(){a.timer.clear(this,this._updateEmission)},n._onOwnerActiveHierarchyChanged=function(e){this._owner.displayedInStage&&(e?this._addUpdateEmissionToTimer():this._removeUpdateEmissionToTimer())},n._retireActiveParticles=function(){for(;this._firstActiveElement!=this._firstNewElement;){var e=this._firstActiveElement*this._floatCountPerVertex*this._vertexStride,t=e+this._timeIndex;if(this._currentTime-this._vertices[t]+1e-4<this._vertices[e+this._startLifeTimeIndex])break;this._vertices[t]=this._drawCounter,this._firstActiveElement++,this._firstActiveElement>=this._bufferMaxParticles&&(this._firstActiveElement=0)}},n._freeRetiredParticles=function(){for(;this._firstRetiredElement!=this._firstActiveElement;){var e=this._drawCounter-this._vertices[this._firstRetiredElement*this._floatCountPerVertex*this._vertexStride+this._timeIndex];if(this.isPerformanceMode&&e<3)break;this._firstRetiredElement++,this._firstRetiredElement>=this._bufferMaxParticles&&(this._firstRetiredElement=0)}},n._burst=function(e,t){for(var n=0,i=this._emission._bursts,r=i.length;this._burstsIndex<r;this._burstsIndex++){var a=i[this._burstsIndex],o=a.time;if(!(e<=o&&o<t))break;var s=0;this.autoRandomSeed?s=M.lerp(a.minCount,a.maxCount,Math.random()):(this._rand.seed=this._randomSeeds[0],s=M.lerp(a.minCount,a.maxCount,this._rand.getFloat()),this._randomSeeds[0]=this._rand.seed),n+=s}return n},n._advanceTime=function(e,t){var n=0,i=this._emissionTime;this._emissionTime+=e;var r=0;if(this._emissionTime>this.duration){if(!this.looping){for(r=Math.min(this.maxParticles-this.aliveParticleCount,r),n=0;n<r;n++)this.emit(t);return this._isPlaying=!1,void this.stop()}r+=this._burst(i,this._emissionTime),this._emissionTime-=this.duration,this.event("complete"),this._burstsIndex=0,r+=this._burst(0,this._emissionTime)}else r+=this._burst(i,this._emissionTime);for(r=Math.min(this.maxParticles-this.aliveParticleCount,r),n=0;n<r;n++)this.emit(t);var a=this.emission.emissionRate;if(a>0){var o=1/a;for(this._frameRateTime+=o,this._frameRateTime=this._currentTime-(this._currentTime-this._frameRateTime)%this._maxStartLifetime;this._frameRateTime<=t&&this.emit(this._frameRateTime);)this._frameRateTime+=o;this._frameRateTime=Math.floor(t/o)*o}},n._initBufferDatas=function(){this._vertexBuffer&&(this._vertexBuffer.destroy(),this._indexBuffer.destroy());var e=this._ownerRender,t=e.renderMode;if(-1!==t&&this.maxParticles>0){var n,i,r=0,a=0,o=0,s=0,l=0,h=e.mesh;if(4===t){if(h){if(h._vertexBuffers.length>1)throw new Error("ShurikenParticleSystem: submesh Count mesh be One or all subMeshes have the same vertexDeclaration.");i=Et.vertexDeclaration,this._floatCountPerVertex=i.vertexStride/4,this._startLifeTimeIndex=12,this._timeIndex=16,this._vertexStride=h._vertexBuffers[0].vertexCount;var _=this._bufferMaxParticles*this._vertexStride,u=_%65535;if(Math.floor(_/65535)+1>1)throw new Error("ShurikenParticleSystem:the maxParticleCount multiply mesh vertexCount is large than 65535.");this._vertexBuffer=$n.create(i,u,35048),this._vertices=new Float32Array(this._floatCountPerVertex*u),this._indexStride=h._indexBuffer.indexCount;var c=h._indexBuffer.getData(),d=this._bufferMaxParticles*this._indexStride;for(this._indexBuffer=Qn.create("ushort",d,35044),n=new Uint16Array(d),s=0,r=0;r<this._bufferMaxParticles;r++){var f=r*this._vertexStride;for(a=0,o=c.length;a<o;a++)n[s++]=f+c[a]}this._indexBuffer.setData(n)}}else{for(i=vt.vertexDeclaration,this._floatCountPerVertex=i.vertexStride/4,this._startLifeTimeIndex=7,this._timeIndex=11,this._vertexStride=4,this._vertexBuffer=$n.create(i,this._bufferMaxParticles*this._vertexStride,35048),this._vertices=new Float32Array(this._floatCountPerVertex*this._bufferMaxParticles*this._vertexStride),r=0;r<this._bufferMaxParticles;r++)l=r*this._floatCountPerVertex*this._vertexStride,this._vertices[l]=-.5,this._vertices[l+1]=-.5,this._vertices[l+2]=0,this._vertices[l+3]=1,l+=this._floatCountPerVertex,this._vertices[l]=.5,this._vertices[l+1]=-.5,this._vertices[l+2]=1,this._vertices[l+3]=1,l+=this._floatCountPerVertex,this._vertices[l]=.5,this._vertices[l+1]=.5,this._vertices[l+2]=1,this._vertices[l+3]=0,l+=this._floatCountPerVertex,this._vertices[l]=-.5,this._vertices[l+1]=.5,this._vertices[l+2]=0,this._vertices[l+3]=0;for(this._indexStride=6,this._indexBuffer=Qn.create("ushort",6*this._bufferMaxParticles,35044),n=new Uint16Array(6*this._bufferMaxParticles),r=0;r<this._bufferMaxParticles;r++){s=6*r;var m=r*this._vertexStride,p=m+2;n[s++]=m,n[s++]=p,n[s++]=m+1,n[s++]=m,n[s++]=m+3,n[s++]=p}this._indexBuffer.setData(n)}}},n._destroy=function(){e.prototype._destroy.call(this),this._owner.activeInHierarchy&&this._removeUpdateEmissionToTimer(),this._vertexBuffer.destroy(),this._indexBuffer.destroy(),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._velocityOverLifetime=null,this._colorOverLifetime=null,this._sizeOverLifetime=null,this._rotationOverLifetime=null,this._textureSheetAnimation=null},n.emit=function(e){var n=t._tempPosition,i=t._tempDirection;if(this._shape&&this._shape.enable)this.autoRandomSeed?this._shape.generatePositionAndDirection(n,i):this._shape.generatePositionAndDirection(n,i,this._rand,this._randomSeeds);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.addParticle(n,i,e)},n.addParticle=function(e,t,n){bt.normalize(t,t);var i=this._firstFreeElement+1;if(i>=this._bufferMaxParticles&&(i=0),i===this._firstRetiredElement)return!1;if(ue.create(this,this._ownerRender,this._owner.transform),this._currentTime-n>=ue.startLifeTime)return!0;var r=NaN,a=NaN,o=NaN,s=NaN,l=NaN,h=NaN,_=NaN,u=this._velocityOverLifetime&&this._velocityOverLifetime.enbale;if(u){var c=this._velocityOverLifetime.velocity.type;2===c||3===c?this.autoRandomSeed?(r=Math.random(),a=Math.random(),o=Math.random()):(this._rand.seed=this._randomSeeds[9],r=this._rand.getFloat(),a=this._rand.getFloat(),o=this._rand.getFloat(),this._randomSeeds[9]=this._rand.seed):u=!1}else u=!1;var d=this._colorOverLifetime&&this._colorOverLifetime.enbale;d&&3===this._colorOverLifetime.color.type?this.autoRandomSeed?s=Math.random():(this._rand.seed=this._randomSeeds[10],s=this._rand.getFloat(),this._randomSeeds[10]=this._rand.seed):d=!1;var f=this._sizeOverLifetime&&this._sizeOverLifetime.enbale;f&&3===this._sizeOverLifetime.size.type?this.autoRandomSeed?l=Math.random():(this._rand.seed=this._randomSeeds[11],l=this._rand.getFloat(),this._randomSeeds[11]=this._rand.seed):f=!1;var m=this._rotationOverLifetime&&this._rotationOverLifetime.enbale;if(m){var p=this._rotationOverLifetime.angularVelocity.type;2===p||3===p?this.autoRandomSeed?h=Math.random():(this._rand.seed=this._randomSeeds[12],h=this._rand.getFloat(),this._randomSeeds[12]=this._rand.seed):m=!1}else m=!1;var v=this._textureSheetAnimation&&this._textureSheetAnimation.enable;v&&3===this._textureSheetAnimation.frame.type?this.autoRandomSeed?_=Math.random():(this._rand.seed=this._randomSeeds[15],_=this._rand.getFloat(),this._randomSeeds[15]=this._rand.seed):v=!1;var E,g=this._firstFreeElement*this._floatCountPerVertex*this._vertexStride,D=ue.startUVInfo[0],T=ue.startUVInfo[1],S=ue.startUVInfo[2],x=ue.startUVInfo[3],M=e.elements,R=t.elements,A=0,I=0,y=0,C=0,N=0,O=this._ownerRender;if(4===O.renderMode){var w=O.mesh._vertexBuffers[0];E=w.getData();var V=w.vertexDeclaration;I=V.getVertexElementByUsage(0).offset/4;var P=V.getVertexElementByUsage(1);y=P?P.offset/4:-1;var L=V.getVertexElementByUsage(2);C=L?L.offset/4:-1,A=V.vertexStride/4,N=0}else{this._vertices[g+2]=S,this._vertices[g+3]=x+T;var b=g+this._floatCountPerVertex;this._vertices[b+2]=S+D,this._vertices[b+3]=x+T;var F=b+this._floatCountPerVertex;this._vertices[F+2]=S+D,this._vertices[F+3]=x;var B=F+this._floatCountPerVertex;this._vertices[B+2]=S,this._vertices[B+3]=x}for(var U=g,H=g+this._floatCountPerVertex*this._vertexStride;U<H;U+=this._floatCountPerVertex){var G=0;if(4===O.renderMode){G=U;var z=A*N++,W=z+I;this._vertices[G++]=E[W++],this._vertices[G++]=E[W++],this._vertices[G++]=E[W],-1===y?(this._vertices[G++]=1,this._vertices[G++]=1,this._vertices[G++]=1,this._vertices[G++]=1):(W=z+y,this._vertices[G++]=E[W++],this._vertices[G++]=E[W++],this._vertices[G++]=E[W++],this._vertices[G++]=E[W]),-1===C?(this._vertices[G++]=0,this._vertices[G++]=0):(W=z+C,this._vertices[G++]=S+E[W++]*D,this._vertices[G++]=x+E[W]*T)}else G=U+4;switch(this._vertices[G++]=M[0],this._vertices[G++]=M[1],this._vertices[G++]=M[2],this._vertices[G++]=ue.startLifeTime,this._vertices[G++]=R[0],this._vertices[G++]=R[1],this._vertices[G++]=R[2],this._vertices[G++]=n,this._vertices[G++]=ue.startColor[0],this._vertices[G++]=ue.startColor[1],this._vertices[G++]=ue.startColor[2],this._vertices[G++]=ue.startColor[3],this._vertices[G++]=ue.startSize[0],this._vertices[G++]=ue.startSize[1],this._vertices[G++]=ue.startSize[2],this._vertices[G++]=ue.startRotation[0],this._vertices[G++]=ue.startRotation[1],this._vertices[G++]=ue.startRotation[2],this._vertices[G++]=ue.startSpeed,d&&(this._vertices[G+1]=s),f&&(this._vertices[G+2]=l),m&&(this._vertices[G+3]=h),v&&(this._vertices[G+4]=_),u&&(this._vertices[G+5]=r,this._vertices[G+6]=a,this._vertices[G+7]=o),this.simulationSpace){case 0:G+=8,this._vertices[G++]=ue.simulationWorldPostion[0],this._vertices[G++]=ue.simulationWorldPostion[1],this._vertices[G++]=ue.simulationWorldPostion[2],this._vertices[G++]=ue.simulationWorldRotation[0],this._vertices[G++]=ue.simulationWorldRotation[1],this._vertices[G++]=ue.simulationWorldRotation[2],this._vertices[G++]=ue.simulationWorldRotation[3];break;case 1:break;default:throw new Error("ShurikenParticleMaterial: SimulationSpace value is invalid.")}}return this._firstFreeElement=i,!0},n.addNewParticlesToVertexBuffer=function(){var e=0;this._firstNewElement<this._firstFreeElement?(e=this._firstNewElement*this._vertexStride*this._floatCountPerVertex,this._vertexBuffer.setData(this._vertices,e,e,(this._firstFreeElement-this._firstNewElement)*this._vertexStride*this._floatCountPerVertex)):(e=this._firstNewElement*this._vertexStride*this._floatCountPerVertex,this._vertexBuffer.setData(this._vertices,e,e,(this._bufferMaxParticles-this._firstNewElement)*this._vertexStride*this._floatCountPerVertex),this._firstFreeElement>0&&this._vertexBuffer.setData(this._vertices,0,0,this._firstFreeElement*this._vertexStride*this._floatCountPerVertex)),this._firstNewElement=this._firstFreeElement},n._beforeRender=function(e){return this._firstNewElement!=this._firstFreeElement&&this.addNewParticlesToVertexBuffer(),this._drawCounter++,this._firstActiveElement!=this._firstFreeElement&&(this._vertexBuffer._bind(),this._indexBuffer._bind(),!0)},n._render=function(e){var t=0,n=b.mainContext;this._firstActiveElement<this._firstFreeElement?(t=(this._firstFreeElement-this._firstActiveElement)*this._indexStride,n.drawElements(4,t,5123,2*this._firstActiveElement*this._indexStride),w.trianglesFaces+=t/3,w.drawCall++):(t=(this._bufferMaxParticles-this._firstActiveElement)*this._indexStride,n.drawElements(4,t,5123,2*this._firstActiveElement*this._indexStride),w.trianglesFaces+=t/3,w.drawCall++,this._firstFreeElement>0&&(t=this._firstFreeElement*this._indexStride,n.drawElements(4,t,5123,0),w.trianglesFaces+=t/3,w.drawCall++))},n.play=function(){if(this._burstsIndex=0,this._isEmitting=!0,this._isPlaying=!0,this._isPaused=!1,this._emissionTime=0,this._totalDelayTime=0,!this.autoRandomSeed)for(var e=0,n=this._randomSeeds.length;e<n;e++)this._randomSeeds[e]=this.randomSeed[0]+t._RANDOMOFFSET[e];switch(this.startDelayType){case 0:this._playStartDelay=this.startDelay;break;case 1:this.autoRandomSeed?this._playStartDelay=M.lerp(this.startDelayMin,this.startDelayMax,Math.random()):(this._rand.seed=this._randomSeeds[2],this._playStartDelay=M.lerp(this.startDelayMin,this.startDelayMax,this._rand.getFloat()),this._randomSeeds[2]=this._rand.seed);break;default:throw new Error("Utils3D: startDelayType is invalid.")}this._frameRateTime=this._currentTime+this._playStartDelay,this._startUpdateLoopCount=w.loopCount,this.event("played")},n.pause=function(){this._isPaused=!0,this.event("paused")},n.simulate=function(e,t){void 0===t&&(t=!0),this._simulateUpdate=!0,t?this._updateParticlesSimulationRestart(e):(this._isPaused=!1,this._updateParticles(e)),this.pause()},n.stop=function(){this._burstsIndex=0,this._isEmitting=!1,this._emissionTime=0,this.event("stopped")},n.cloneTo=function(e){var t=e;t.duration=this.duration,t.looping=this.looping,t.prewarm=this.prewarm,t.startDelayType=this.startDelayType,t.startDelay=this.startDelay,t.startDelayMin=this.startDelayMin,t.startDelayMax=this.startDelayMax,t._maxStartLifetime=this._maxStartLifetime,t.startLifetimeType=this.startLifetimeType,t.startLifetimeConstant=this.startLifetimeConstant,this.startLifeTimeGradient.cloneTo(t.startLifeTimeGradient),t.startLifetimeConstantMin=this.startLifetimeConstantMin,t.startLifetimeConstantMax=this.startLifetimeConstantMax,this.startLifeTimeGradientMin.cloneTo(t.startLifeTimeGradientMin),this.startLifeTimeGradientMax.cloneTo(t.startLifeTimeGradientMax),t.startSpeedType=this.startSpeedType,t.startSpeedConstant=this.startSpeedConstant,t.startSpeedConstantMin=this.startSpeedConstantMin,t.startSpeedConstantMax=this.startSpeedConstantMax,t.threeDStartSize=this.threeDStartSize,t.startSizeType=this.startSizeType,t.startSizeConstant=this.startSizeConstant,this.startSizeConstantSeparate.cloneTo(t.startSizeConstantSeparate),t.startSizeConstantMin=this.startSizeConstantMin,t.startSizeConstantMax=this.startSizeConstantMax,this.startSizeConstantMinSeparate.cloneTo(t.startSizeConstantMinSeparate),this.startSizeConstantMaxSeparate.cloneTo(t.startSizeConstantMaxSeparate),t.threeDStartRotation=this.threeDStartRotation,t.startRotationType=this.startRotationType,t.startRotationConstant=this.startRotationConstant,this.startRotationConstantSeparate.cloneTo(t.startRotationConstantSeparate),t.startRotationConstantMin=this.startRotationConstantMin,t.startRotationConstantMax=this.startRotationConstantMax,this.startRotationConstantMinSeparate.cloneTo(t.startRotationConstantMinSeparate),this.startRotationConstantMaxSeparate.cloneTo(t.startRotationConstantMaxSeparate),t.randomizeRotationDirection=this.randomizeRotationDirection,t.startColorType=this.startColorType,this.startColorConstant.cloneTo(t.startColorConstant),this.startColorConstantMin.cloneTo(t.startColorConstantMin),this.startColorConstantMax.cloneTo(t.startColorConstantMax),t.gravityModifier=this.gravityModifier,t.simulationSpace=this.simulationSpace,t.scaleMode=this.scaleMode,t.playOnAwake=this.playOnAwake,t.maxParticles=this.maxParticles,this._emission&&(t._emission=this._emission.clone()),this.shape&&(t.shape=this.shape.clone()),this.velocityOverLifetime&&(t.velocityOverLifetime=this.velocityOverLifetime.clone()),this.colorOverLifetime&&(t.colorOverLifetime=this.colorOverLifetime.clone()),this.sizeOverLifetime&&(t.sizeOverLifetime=this.sizeOverLifetime.clone()),this.rotationOverLifetime&&(t.rotationOverLifetime=this.rotationOverLifetime.clone()),this.textureSheetAnimation&&(t.textureSheetAnimation=this.textureSheetAnimation.clone()),t.isPerformanceMode=this.isPerformanceMode,t._isEmitting=this._isEmitting,t._isPlaying=this._isPlaying,t._isPaused=this._isPaused,t._playStartDelay=this._playStartDelay,t._frameRateTime=this._frameRateTime,t._emissionTime=this._emissionTime,t._totalDelayTime=this._totalDelayTime,t._burstsIndex=this._burstsIndex},n.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},n._getVertexBuffers=function(){return null},l(0,n,"maxParticles",function(){return this._bufferMaxParticles-1},function(e){var t=e+1;t!==this._bufferMaxParticles&&(this._bufferMaxParticles=t,this._initBufferDatas())}),l(0,n,"isEmitting",function(){return this._isEmitting}),l(0,n,"isAlive",function(){return!!(this._isPlaying||this.aliveParticleCount>0)}),l(0,n,"shape",function(){return this._shape},function(e){this._shape!==e&&(e&&e.enable?this._ownerRender._addShaderDefine(Ti.SHADERDEFINE_SHAPE):this._ownerRender._removeShaderDefine(Ti.SHADERDEFINE_SHAPE),this._shape=e)}),l(0,n,"rotationOverLifetime",function(){return this._rotationOverLifetime},function(e){var t=this._ownerRender;if(e){var n=e.angularVelocity;if(!n)return;var i=n.separateAxes,r=n.type;if(e.enbale)switch(i?t._addShaderDefine(Ti.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE):t._addShaderDefine(Ti.SHADERDEFINE_ROTATIONOVERLIFETIME),r){case 0:t._addShaderDefine(Ti.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT);break;case 1:t._addShaderDefine(Ti.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE);break;case 2:t._addShaderDefine(Ti.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS);break;case 3:t._addShaderDefine(Ti.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCURVES)}else t._removeShaderDefine(Ti.SHADERDEFINE_ROTATIONOVERLIFETIME),t._removeShaderDefine(Ti.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE),t._removeShaderDefine(Ti.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT),t._removeShaderDefine(Ti.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE),t._removeShaderDefine(Ti.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS),t._removeShaderDefine(Ti.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCURVES);switch(r){case 0:i?t._setShaderValueColor(35,n.constantSeparate):t._setShaderValueNumber(34,n.constant);break;case 1:i?(t._setShaderValueBuffer(37,n.gradientX._elements),t._setShaderValueBuffer(38,n.gradientY._elements),t._setShaderValueBuffer(39,n.gradientZ._elements),t._setShaderValueBuffer(40,n.gradientW._elements)):t._setShaderValueBuffer(36,n.gradient._elements);break;case 2:i?(t._setShaderValueColor(35,n.constantMinSeparate),t._setShaderValueColor(42,n.constantMaxSeparate)):(t._setShaderValueNumber(34,n.constantMin),t._setShaderValueNumber(41,n.constantMax));break;case 3:i?(t._setShaderValueBuffer(37,n.gradientXMin._elements),t._setShaderValueBuffer(44,n.gradientXMax._elements),t._setShaderValueBuffer(38,n.gradientYMin._elements),t._setShaderValueBuffer(45,n.gradientYMax._elements),t._setShaderValueBuffer(39,n.gradientZMin._elements),t._setShaderValueBuffer(46,n.gradientZMax._elements),t._setShaderValueBuffer(40,n.gradientWMin._elements),t._setShaderValueBuffer(47,n.gradientWMax._elements)):(t._setShaderValueBuffer(36,n.gradientMin._elements),t._setShaderValueBuffer(43,n.gradientMax._elements))}}else t._removeShaderDefine(Ti.SHADERDEFINE_ROTATIONOVERLIFETIME),t._removeShaderDefine(Ti.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE),t._removeShaderDefine(Ti.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT),t._removeShaderDefine(Ti.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE),t._removeShaderDefine(Ti.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS),t._removeShaderDefine(Ti.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCURVES),t._setShaderValueColor(35,null),t._setShaderValueColor(42,null),t._setShaderValueNumber(34,void 0),t._setShaderValueNumber(41,void 0),t._setShaderValueBuffer(37,null),t._setShaderValueBuffer(44,null),t._setShaderValueBuffer(38,null),t._setShaderValueBuffer(45,null),t._setShaderValueBuffer(39,null),t._setShaderValueBuffer(46,null),t._setShaderValueBuffer(40,null),t._setShaderValueBuffer(47,null),t._setShaderValueBuffer(36,null),t._setShaderValueBuffer(43,null);this._rotationOverLifetime=e}),l(0,n,"emission",function(){return this._emission}),l(0,n,"emissionTime",function(){return this._emissionTime>this.duration?this.duration:this._emissionTime}),l(0,n,"aliveParticleCount",function(){return this._firstNewElement>=this._firstRetiredElement?this._firstNewElement-this._firstRetiredElement:this._bufferMaxParticles-this._firstRetiredElement+this._firstNewElement}),l(0,n,"isPlaying",function(){return this._isPlaying}),l(0,n,"isPaused",function(){return this._isPaused}),l(0,n,"startLifetimeType",function(){return this._startLifetimeType},function(e){var t=0,n=0;switch(this.startLifetimeType){case 0:this._maxStartLifetime=this.startLifetimeConstant;break;case 1:this._maxStartLifetime=-Number.MAX_VALUE;var i=i;for(t=0,n=i.gradientCount;t<n;t++)this._maxStartLifetime=Math.max(this._maxStartLifetime,i.getValueByIndex(t));break;case 2:this._maxStartLifetime=Math.max(this.startLifetimeConstantMin,this.startLifetimeConstantMax);break;case 3:this._maxStartLifetime=-Number.MAX_VALUE;var r=r;for(t=0,n=r.gradientCount;t<n;t++)this._maxStartLifetime=Math.max(this._maxStartLifetime,r.getValueByIndex(t));var a=a;for(t=0,n=a.gradientCount;t<n;t++)this._maxStartLifetime=Math.max(this._maxStartLifetime,a.getValueByIndex(t))}this._startLifetimeType=e}),l(0,n,"_originalBoundingSphere",function(){return this._boundingSphere}),l(0,n,"startLifetimeConstant",function(){return this._startLifetimeConstant},function(e){0===this._startLifetimeType&&(this._maxStartLifetime=e),this._startLifetimeConstant=e}),l(0,n,"startLifetimeConstantMin",function(){return this._startLifetimeConstantMin},function(e){2===this._startLifetimeType&&(this._maxStartLifetime=Math.max(e,this._startLifetimeConstantMax)),this._startLifetimeConstantMin=e}),l(0,n,"startLifeTimeGradient",function(){return this._startLifeTimeGradient},function(e){if(1===this._startLifetimeType){this._maxStartLifetime=-Number.MAX_VALUE;for(var t=0,n=e.gradientCount;t<n;t++)this._maxStartLifetime=Math.max(this._maxStartLifetime,e.getValueByIndex(t))}this._startLifeTimeGradient=e}),l(0,n,"startLifetimeConstantMax",function(){return this._startLifetimeConstantMax},function(e){2===this._startLifetimeType&&(this._maxStartLifetime=Math.max(this._startLifetimeConstantMin,e)),this._startLifetimeConstantMax=e}),l(0,n,"startLifeTimeGradientMin",function(){return this._startLifeTimeGradientMin},function(e){if(3===this._startLifetimeType){var t=0,n=0;for(this._maxStartLifetime=-Number.MAX_VALUE,t=0,n=e.gradientCount;t<n;t++)this._maxStartLifetime=Math.max(this._maxStartLifetime,e.getValueByIndex(t));for(t=0,n=this._startLifeTimeGradientMax.gradientCount;t<n;t++)this._maxStartLifetime=Math.max(this._maxStartLifetime,this._startLifeTimeGradientMax.getValueByIndex(t))}this._startLifeTimeGradientMin=e}),l(0,n,"startLifeTimeGradientMax",function(){return this._startLifeTimeGradientMax},function(e){if(3===this._startLifetimeType){var t=0,n=0;for(this._maxStartLifetime=-Number.MAX_VALUE,t=0,n=this._startLifeTimeGradientMin.gradientCount;t<n;t++)this._maxStartLifetime=Math.max(this._maxStartLifetime,this._startLifeTimeGradientMin.getValueByIndex(t));for(t=0,n=e.gradientCount;t<n;t++)this._maxStartLifetime=Math.max(this._maxStartLifetime,e.getValueByIndex(t))}this._startLifeTimeGradientMax=e}),l(0,n,"velocityOverLifetime",function(){return this._velocityOverLifetime},function(e){var t=this._ownerRender;if(e){var n=e.velocity,i=n.type;if(e.enbale)switch(i){case 0:t._addShaderDefine(Ti.SHADERDEFINE_VELOCITYOVERLIFETIMECONSTANT);break;case 1:t._addShaderDefine(Ti.SHADERDEFINE_VELOCITYOVERLIFETIMECURVE);break;case 2:t._addShaderDefine(Ti.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCONSTANT);break;case 3:t._addShaderDefine(Ti.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCURVE)}else t._removeShaderDefine(Ti.SHADERDEFINE_VELOCITYOVERLIFETIMECONSTANT),t._removeShaderDefine(Ti.SHADERDEFINE_VELOCITYOVERLIFETIMECURVE),t._removeShaderDefine(Ti.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCONSTANT),t._removeShaderDefine(Ti.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCURVE);switch(i){case 0:t._setShaderValueColor(13,n.constant);break;case 1:t._setShaderValueBuffer(14,n.gradientX._elements),t._setShaderValueBuffer(15,n.gradientY._elements),t._setShaderValueBuffer(16,n.gradientZ._elements);break;case 2:t._setShaderValueColor(13,n.constantMin),t._setShaderValueColor(17,n.constantMax);break;case 3:t._setShaderValueBuffer(14,n.gradientXMin._elements),t._setShaderValueBuffer(18,n.gradientXMax._elements),t._setShaderValueBuffer(15,n.gradientYMin._elements),t._setShaderValueBuffer(19,n.gradientYMax._elements),t._setShaderValueBuffer(16,n.gradientZMin._elements),t._setShaderValueBuffer(20,n.gradientZMax._elements)}t._setShaderValueInt(21,e.space)}else t._removeShaderDefine(Ti.SHADERDEFINE_VELOCITYOVERLIFETIMECONSTANT),t._removeShaderDefine(Ti.SHADERDEFINE_VELOCITYOVERLIFETIMECURVE),t._removeShaderDefine(Ti.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCONSTANT),t._removeShaderDefine(Ti.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCURVE),t._setShaderValueColor(13,null),t._setShaderValueBuffer(14,null),t._setShaderValueBuffer(15,null),t._setShaderValueBuffer(16,null),t._setShaderValueColor(13,null),t._setShaderValueColor(17,null),t._setShaderValueBuffer(14,null),t._setShaderValueBuffer(18,null),t._setShaderValueBuffer(15,null),t._setShaderValueBuffer(19,null),t._setShaderValueBuffer(16,null),t._setShaderValueBuffer(20,null),t._setShaderValueInt(21,void 0);this._velocityOverLifetime=e}),l(0,n,"colorOverLifetime",function(){return this._colorOverLifetime},function(e){var t=this._ownerRender;if(e){var n=e.color;if(e.enbale)switch(n.type){case 1:t._addShaderDefine(Ti.SHADERDEFINE_COLOROVERLIFETIME);break;case 3:t._addShaderDefine(Ti.SHADERDEFINE_RANDOMCOLOROVERLIFETIME)}else t._removeShaderDefine(Ti.SHADERDEFINE_COLOROVERLIFETIME),t._removeShaderDefine(Ti.SHADERDEFINE_RANDOMCOLOROVERLIFETIME);switch(n.type){case 1:var i=n.gradient;t._setShaderValueBuffer(22,i._alphaElements),t._setShaderValueBuffer(23,i._rgbElements);break;case 3:var r=n.gradientMin,a=n.gradientMax;t._setShaderValueBuffer(22,r._alphaElements),t._setShaderValueBuffer(23,r._rgbElements),t._setShaderValueBuffer(24,a._alphaElements),t._setShaderValueBuffer(25,a._rgbElements)}}else t._removeShaderDefine(Ti.SHADERDEFINE_COLOROVERLIFETIME),t._removeShaderDefine(Ti.SHADERDEFINE_RANDOMCOLOROVERLIFETIME),t._setShaderValueBuffer(22,i._alphaElements),t._setShaderValueBuffer(23,i._rgbElements),t._setShaderValueBuffer(22,r._alphaElements),t._setShaderValueBuffer(23,r._rgbElements),t._setShaderValueBuffer(24,a._alphaElements),t._setShaderValueBuffer(25,a._rgbElements);this._colorOverLifetime=e}),l(0,n,"sizeOverLifetime",function(){return this._sizeOverLifetime},function(e){var t=this._ownerRender;if(e){var n=e.size,i=n.separateAxes,r=n.type;if(e.enbale)switch(r){case 0:i?t._addShaderDefine(Ti.SHADERDEFINE_SIZEOVERLIFETIMECURVESEPERATE):t._addShaderDefine(Ti.SHADERDEFINE_SIZEOVERLIFETIMECURVE);break;case 2:i?t._addShaderDefine(Ti.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVESSEPERATE):t._addShaderDefine(Ti.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVES)}else t._removeShaderDefine(Ti.SHADERDEFINE_SIZEOVERLIFETIMECURVE),t._removeShaderDefine(Ti.SHADERDEFINE_SIZEOVERLIFETIMECURVESEPERATE),t._removeShaderDefine(Ti.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVES),t._removeShaderDefine(Ti.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVESSEPERATE);switch(r){case 0:i?(t._setShaderValueBuffer(27,n.gradientX._elements),t._setShaderValueBuffer(28,n.gradientY._elements),t._setShaderValueBuffer(29,n.gradientZ._elements)):t._setShaderValueBuffer(26,n.gradient._elements);break;case 2:i?(t._setShaderValueBuffer(27,n.gradientXMin._elements),t._setShaderValueBuffer(31,n.gradientXMax._elements),t._setShaderValueBuffer(28,n.gradientYMin._elements),t._setShaderValueBuffer(32,n.gradientYMax._elements),t._setShaderValueBuffer(29,n.gradientZMin._elements),t._setShaderValueBuffer(33,n.gradientZMax._elements)):(t._setShaderValueBuffer(26,n.gradientMin._elements),t._setShaderValueBuffer(30,n.gradientMax._elements))}}else t._removeShaderDefine(Ti.SHADERDEFINE_SIZEOVERLIFETIMECURVE),t._removeShaderDefine(Ti.SHADERDEFINE_SIZEOVERLIFETIMECURVESEPERATE),t._removeShaderDefine(Ti.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVES),t._removeShaderDefine(Ti.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVESSEPERATE),t._setShaderValueBuffer(27,null),t._setShaderValueBuffer(31,null),t._setShaderValueBuffer(28,null),t._setShaderValueBuffer(32,null),t._setShaderValueBuffer(29,null),t._setShaderValueBuffer(33,null),t._setShaderValueBuffer(26,null),t._setShaderValueBuffer(30,null);this._sizeOverLifetime=e}),l(0,n,"textureSheetAnimation",function(){return this._textureSheetAnimation},function(e){var t=this._ownerRender;if(e){var n=e.frame,i=n.type;if(e.enable)switch(i){case 1:t._addShaderDefine(Ti.SHADERDEFINE_TEXTURESHEETANIMATIONCURVE);break;case 3:t._addShaderDefine(Ti.SHADERDEFINE_TEXTURESHEETANIMATIONRANDOMCURVE)}else t._removeShaderDefine(Ti.SHADERDEFINE_TEXTURESHEETANIMATIONCURVE),t._removeShaderDefine(Ti.SHADERDEFINE_TEXTURESHEETANIMATIONRANDOMCURVE);if(1===i||3===i){t._setShaderValueInt(48,e.cycles);var r=e.tiles,a=this._uvLength.elements;a[0]=1/r.x,a[1]=1/r.y,t._setShaderValueVector2(49,this._uvLength)}switch(i){case 1:t._setShaderValueBuffer(50,n.frameOverTimeData._elements);break;case 3:t._setShaderValueBuffer(50,n.frameOverTimeDataMin._elements),t._setShaderValueBuffer(51,n.frameOverTimeDataMax._elements)}}else t._removeShaderDefine(Ti.SHADERDEFINE_TEXTURESHEETANIMATIONCURVE),t._removeShaderDefine(Ti.SHADERDEFINE_TEXTURESHEETANIMATIONRANDOMCURVE),t._setShaderValueInt(48,void 0),t._setShaderValueVector2(49,null),t._setShaderValueBuffer(50,null),t._setShaderValueBuffer(51,null);this._textureSheetAnimation=e}),l(0,n,"_vertexBufferCount",function(){return 1}),l(0,n,"triangleCount",function(){return this._indexBuffer?this._indexBuffer.indexCount/3:0}),l(0,n,"_originalBoundingBox",function(){return this._boundingBox}),l(0,n,"_originalBoundingBoxCorners",function(){return this._boundingBoxCorners}),t.halfKSqrtOf2=.71,o(t,["_RANDOMOFFSET",function(){return this._RANDOMOFFSET=new Uint32Array([592910910,3276756734,322376503,306581307,1793934638,3737431713,2527743459,2368504881,4085612399,3774601268,326370691,1494990940,1089181156,3159510623,2941263940,2786374529,271901988,4233252447])},"_maxElapsedTime",function(){return this._maxElapsedTime=1/3},"_tempVector30",function(){return this._tempVector30=new bt},"_tempVector31",function(){return this._tempVector31=new bt},"_tempVector32",function(){return this._tempVector32=new bt},"_tempVector33",function(){return this._tempVector33=new bt},"_tempVector34",function(){return this._tempVector34=new bt},"_tempVector35",function(){return this._tempVector35=new bt},"_tempVector36",function(){return this._tempVector36=new bt},"_tempVector37",function(){return this._tempVector37=new bt},"_tempVector38",function(){return this._tempVector38=new bt},"_tempVector39",function(){return this._tempVector39=new bt},"_tempPosition",function(){return this._tempPosition=new bt},"_tempDirection",function(){return this._tempDirection=new bt}]),t}(rn),Vn=function(e){function t(e){this._finalGravity=new bt,this._tempRotationMatrix=new Ct,t.__super.call(this,e),this._defaultBoundBox=new xt(new bt,new bt),this._renderMode=-1,this.stretchedBillboardCameraSpeedScale=0,this.stretchedBillboardSpeedScale=0,this.stretchedBillboardLengthScale=1}s(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,t=this._owner.particleSystem._boundingSphere,n=this._owner.transform,i=n.scale.elements,r=Math.abs(i[0]),a=Math.abs(i[1]),o=Math.abs(i[2]);e=r>=a&&r>=o?r:a>=o?a:o,bt.transformCoordinate(t.center,n.worldMatrix,this._boundingSphere.center),this._boundingSphere.radius=t.radius*e},n._renderUpdate=function(e){var t=this._owner.particleSystem;if(!a.stage.isVisibility||!t.isAlive)return!1;var n=this._owner.transform;switch(t.simulationSpace){case 0:break;case 1:this._setShaderValueColor(0,n.position),this._setShaderValueColor(1,n.rotation);break;default:throw new Error("ShurikenParticleMaterial: SimulationSpace value is invalid.")}switch(t.scaleMode){case 0:var i=n.scale;this._setShaderValueColor(4,i),this._setShaderValueColor(5,i);break;case 1:var r=n.localScale;this._setShaderValueColor(4,r),this._setShaderValueColor(5,r);break;case 2:this._setShaderValueColor(4,n.scale),this._setShaderValueColor(5,bt.ONE)}var o=this._finalGravity.elements,s=Kt.gravity.elements,l=t.gravityModifier;return o[0]=s[0]*l,o[1]=s[1]*l,o[2]=s[2]*l,this._setShaderValueBuffer(7,o),this._setShaderValueInt(11,t.simulationSpace),this._setShaderValueBool(8,t.threeDStartRotation),this._setShaderValueInt(6,t.scaleMode),this._setShaderValueInt(9,this.stretchedBillboardLengthScale),this._setShaderValueInt(10,this.stretchedBillboardSpeedScale),this._setShaderValueNumber(12,t._currentTime),en.debugMode&&this._renderRenderableBoundBox(),!0},n._destroy=function(){e.prototype._destroy.call(this),this._mesh&&(this._mesh._removeReference(),this._mesh=null)},l(0,n,"boundingBox",function(){return this._owner.particleSystem.isAlive?(this._boundingBoxNeedChange&&(this._calculateBoundingBox(),this._boundingBoxNeedChange=!1),this._boundingBox):this._defaultBoundBox}),l(0,n,"renderMode",function(){return this._renderMode},function(e){if(this._renderMode!==e){switch(this._renderMode){case 0:this._removeShaderDefine(Ti.SHADERDEFINE_RENDERMODE_BILLBOARD);break;case 1:this._removeShaderDefine(Ti.SHADERDEFINE_RENDERMODE_STRETCHEDBILLBOARD);break;case 2:this._removeShaderDefine(Ti.SHADERDEFINE_RENDERMODE_HORIZONTALBILLBOARD);break;case 3:this._removeShaderDefine(Ti.SHADERDEFINE_RENDERMODE_VERTICALBILLBOARD);break;case 4:this._removeShaderDefine(Ti.SHADERDEFINE_RENDERMODE_MESH)}switch(this._renderMode=e,e){case 0:this._addShaderDefine(Ti.SHADERDEFINE_RENDERMODE_BILLBOARD);break;case 1:this._addShaderDefine(Ti.SHADERDEFINE_RENDERMODE_STRETCHEDBILLBOARD);break;case 2:this._addShaderDefine(Ti.SHADERDEFINE_RENDERMODE_HORIZONTALBILLBOARD);break;case 3:this._addShaderDefine(Ti.SHADERDEFINE_RENDERMODE_VERTICALBILLBOARD);break;case 4:this._addShaderDefine(Ti.SHADERDEFINE_RENDERMODE_MESH);break;default:throw new Error("ShurikenParticleRender: unknown renderMode Value.")}this._owner.particleSystem._initBufferDatas()}}),l(0,n,"mesh",function(){return this._mesh},function(e){this._mesh!==e&&(this._mesh&&this._mesh._removeReference(),this._mesh=e,e&&e._addReference(),this._owner.particleSystem._initBufferDatas())}),t}(an),Pn=function(e){function t(e){this._owner=null,this._trailRenderElements=null,this._minVertexDistance=NaN,this._widthMultiplier=NaN,this._time=NaN,this._widthCurve=null,this._colorGradient=null,this._textureMode=0,this._curtime=0,this._curSubTrailFinishCurTime=0,this._curSubTrailFinished=!1,this._hasLifeSubTrail=!1,this._trailTotalLength=0,this._trailSupplementLength=0,this._trailDeadLength=0,this._isStart=!1,this._trailRenderElementIndex=0,t.__super.call(this),this._curSubTrailFinishPosition=new bt,this._curSubTrailFinishDirection=new bt,this._owner=e,this._trailRenderElements=[],this.addRenderElement()}s(t,"laya.d3.core.trail.TrailFilter",e);var n=t.prototype;return n.getRenderElementsCount=function(){return this._trailRenderElements.length},n.addRenderElement=function(){for(var e=0;e<this._trailRenderElements.length;e++)if(1==this._trailRenderElements[e]._isDead)return this._trailRenderElements[e].reActivate(),e;var t=new Se(this);return this._trailRenderElements.push(t),this._trailRenderElements.length-1},n.getRenderElement=function(e){return this._trailRenderElements[e]},n._update=function(e){this._curtime+=e.elapsedTime/1e3,this._owner._render._setShaderValueNumber(3,this._curtime),this._curSubTrailFinished&&(this._curSubTrailFinished=!1,this._trailRenderElementIndex=this.addRenderElement(),this.event("trailfilterchange",[this._trailRenderElementIndex,this._trailRenderElements[this._trailRenderElementIndex]]))},n.reset=function(){for(var e=0;e<this._trailRenderElements.length;e++)this._trailRenderElements[e].reActivate();this._isStart=!1,this._hasLifeSubTrail=!1,this._curSubTrailFinished=!1,this._curSubTrailFinishCurTime=0,this._trailTotalLength=0,this._trailSupplementLength=0,this._trailDeadLength=0},n._destroy=function(){e.prototype._destroy.call(this);for(var t=0;t<this._trailRenderElements.length;t++)this._trailRenderElements[t]._destroy();this._trailRenderElements=null,this._widthCurve=null,this._colorGradient=null,this._curSubTrailFinishPosition=null,this._curSubTrailFinishDirection=null},l(0,n,"widthMultiplier",function(){return this._widthMultiplier},function(e){this._widthMultiplier=e}),l(0,n,"time",function(){return this._time},function(e){this._time=e,this._owner._render._setShaderValueNumber(4,e)}),l(0,n,"widthCurve",function(){return this._widthCurve},function(e){this._widthCurve=e;var t,n=new Float32Array(4*e.length),i=0,r=0;for(i=0,t=e.length;i<t;i++)n[r++]=e[i].time,n[r++]=e[i].inTangent,n[r++]=e[i].outTangent,n[r++]=e[i].value;this._owner._render._setShaderValueBuffer(5,n),this._owner._render._setShaderValueInt(6,e.length)}),l(0,n,"minVertexDistance",function(){return this._minVertexDistance},function(e){this._minVertexDistance=e}),l(0,n,"colorGradient",function(){return this._colorGradient},function(e){this._colorGradient=e,this._owner._render._setShaderValueBuffer(7,e._colorKeyData),this._owner._render._setShaderValueBuffer(8,e._alphaKeyData),0==e.mode?this._owner._render._addShaderDefine(xi.SHADERDEFINE_GRADIENTMODE_BLEND):this._owner._render._removeShaderDefine(xi.SHADERDEFINE_GRADIENTMODE_BLEND)}),l(0,n,"textureMode",function(){return this._textureMode},function(e){this._textureMode=e}),t}(rn),Ln=function(e){function t(e){t.__super.call(this,e)}s(t,"laya.d3.core.trail.TrailRenderer",an);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},n._renderUpdate=function(e){return!0},t}(),bn=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._maxSegments=0,t.__super.call(this),this._tempVector0=new bt,this._tempVector1=new bt,this._tempVector2=new bt,this._tempVector3=new bt,this._posModeLastPosition0=new bt,this._posModeLastPosition1=new bt,this._posModePosition0=new bt,this._posModePosition1=new bt,this._posVelModePosition0=new bt,this._posVelModeVelocity0=new bt,this._posVelModePosition1=new bt,this._posVelModeVelocity1=new bt,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 bt,this._lastPatchAddPos1=new bt,this.scLeft=new k,this.scRight=new k,this.lifeTime=.5,this.minSegmentDistance=.1,this.minInterpDistance=.6,this.maxSlerpCount=128,this._maxSegments=200,this._owner.on("activeinhierarchychanged",this,this._onActiveHierarchyChanged)}s(t,"laya.d3.resource.tempelet.GlitterTemplet",e);var n=t.prototype;return a.imps(n,{"laya.d3.core.render.IRenderable":!0}),n._getVertexBuffer=function(e){return void 0===e&&(e=0),0===e?this._vertexBuffer:null},n._getIndexBuffer=function(){return null},n._initialize=function(){this._vertexBuffer=$n.create(Oe.vertexDeclaration,2*this.maxSegments,35048),this._vertices=new Float32Array(this.maxSegments*this._floatCountPerVertex*2)},n._onActiveHierarchyChanged=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)},n._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))},n._updateSubTextureCoordinates=function(e,t){for(var n=2*e,i=0;i<t;i+=2){var r=n+i,a=r*this._floatCountPerVertex,o=(r+1)*this._floatCountPerVertex;this._vertices[a+3]=this._vertices[o+3]=(this._vertices[a+5]-this._currentTime)/this.lifeTime}},n._retireActiveGlitter=function(){for(var e=this.lifeTime,t=2*this._floatCountPerVertex;this._firstActiveElement!=this._firstNewElement;){var n=this._firstActiveElement*t+5;if(this._currentTime-this._vertices[n]<e)break;this._vertices[n]=this._drawCounter,this._firstActiveElement++,this._firstActiveElement>=this.maxSegments&&(this._firstActiveElement=0)}},n._freeRetiredGlitter=function(){for(var e=2*this._floatCountPerVertex;this._firstRetiredElement!=this._firstActiveElement&&!(this._drawCounter-this._vertices[this._firstRetiredElement*e+5]<3);)this._firstRetiredElement++,this._firstRetiredElement>=this.maxSegments&&(this._firstRetiredElement=0)},n._calcVelocity=function(e,t,n){bt.subtract(e,t,n),bt.scale(n,.5,n)},n._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},n._addGlitter=function(e,t,n){this._needPatch&&(this._needPatch=!1,this._addGlitter(this._lastPatchAddPos0,this._lastPatchAddPos1,this._lastPatchAddTime));var i=this._firstFreeElement+1;i>=this.maxSegments&&(i=0,e.cloneTo(this._lastPatchAddPos0),t.cloneTo(this._lastPatchAddPos1),this._lastPatchAddTime=n,this._needPatch=!0),i===this._firstRetiredElement&&console.log("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,o=0,s=this._firstFreeElement*this._floatCountPerVertex*2;for(o=0;o<3;o++)this._vertices[s+o]=r[o];this._vertices[s+3]=0,this._vertices[s+4]=0,this._vertices[s+5]=n;var l=s+this._floatCountPerVertex;for(o=0;o<3;o++)this._vertices[l+o]=a[o];this._vertices[l+3]=0,this._vertices[l+4]=1,this._vertices[l+5]=n,this._firstFreeElement=i},n._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()},n._beforeRender=function(e){return this._firstNewElement!=this._firstFreeElement&&this._addNewGlitterSegementToVertexBuffer(),this._drawCounter++,this._firstActiveElement!=this._firstFreeElement&&(this._vertexBuffer.bindWithIndexBuffer(null),!0)},n._render=function(e){var t=0,n=b.mainContext;this._firstActiveElement<this._firstFreeElement?(t=2*(this._firstFreeElement-this._firstActiveElement),n.drawArrays(5,2*this._firstActiveElement,t),w.trianglesFaces+=t-2,w.drawCall++):(t=2*(this.maxSegments-this._firstActiveElement),n.drawArrays(5,2*this._firstActiveElement,t),w.trianglesFaces+=t-2,w.drawCall++,this._firstFreeElement>0&&(t=2*this._firstFreeElement,n.drawArrays(5,0,t),w.trianglesFaces+=t-2,w.drawCall++))},n.addVertexPosition=function(e,t){if(this._owner.activeInHierarchy)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)}},n.addVertexPositionVelocity=function(e,t,n,i){if(this._owner.activeInHierarchy){if(0===this._numPositionVelocityMode)this._numPositionVelocityMode++;else{var r=this._tempVector0;bt.subtract(e,this._posVelModePosition0,r);var a=bt.scalarLength(r);bt.subtract(n,this._posVelModePosition1,r);var o=bt.scalarLength(r),s=0,l=l;if(a<l&&o<l)return;if(1===(s=1+Math.floor(Math.max(a,o)/this.minInterpDistance)))this._addGlitter(e,n,this._currentTime);else{s=Math.min(s,this.maxSlerpCount),this.scLeft.Init(this._posVelModePosition0,this._posVelModeVelocity0,e,t),this.scRight.Init(this._posVelModePosition1,this._posVelModeVelocity1,n,i);for(var h=1/s,_=h,u=this._currentTime-this._lastTime,c=1;c<=s;c++){var d=this._tempVector0;this.scLeft.Slerp(_,d);var f=this._tempVector1;this.scRight.Slerp(_,f);var m=this._lastTime+u*c/s;this._addGlitter(d,f,m),_+=h}}}this._lastTime=this._currentTime,e.cloneTo(this._posVelModePosition0),t.cloneTo(this._posVelModeVelocity0),n.cloneTo(this._posVelModePosition1),i.cloneTo(this._posVelModeVelocity1)}},n._destroy=function(){e.prototype._destroy.call(this),this._tempVector0=null,this._tempVector1=null,this._tempVector2=null,this._tempVector3=null,this._owner=null,this._vertices=null,this._vertexBuffer.destroy(),this._vertexBuffer=null,this.scLeft=null,this.scRight=null,this._posModeLastPosition0=null,this._posModeLastPosition1=null,this._posModePosition0=null,this._posModePosition1=null,this._posVelModePosition0=null,this._posVelModeVelocity0=null,this._posVelModePosition1=null,this._posVelModeVelocity1=null,this._lastPatchAddPos0=null,this._lastPatchAddPos1=null},n._getVertexBuffers=function(){return null},l(0,n,"maxSegments",function(){return this._maxSegments-1},function(e){var t=e+1;t!==this._maxSegments&&(this._maxSegments=t,this._vertexBuffer&&this._vertexBuffer.destroy(),this._initialize())}),l(0,n,"_vertexBufferCount",function(){return 1}),l(0,n,"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}),l(0,n,"_originalBoundingSphere",function(){return a.superGet(rn,this,"_originalBoundingSphere")}),l(0,n,"_originalBoundingBox",function(){return a.superGet(rn,this,"_originalBoundingBox")}),t}(rn),Fn=function(e){function t(e,n,i,r,a,o,s,l){this._owner=null,this._gridSize=NaN,this.memorySize=0,this._numberVertices=0,this._maxNumberIndices=0,this._currentNumberIndices=0,this._numberTriangle=0,this._vertexBuffer=null,this._indexBuffer=null,this._boundingSphere=null,this._boundingBox=null,this._indexArrayBuffer=null,this._boundingBoxCorners=null,this._leafs=null,this._leafNum=0,this._terrainHeightData=null,this._terrainHeightDataWidth=0,this._terrainHeightDataHeight=0,this._chunkOffsetX=0,this._chunkOffsetZ=0,this._cameraCoordinateInverse=!1,this._cameraPos=null,this._currentLOD=0,this._perspectiveFactor=NaN,this._LODTolerance=0,t.__super.call(this),this._owner=e,this._cameraPos=new bt,this._chunkOffsetX=n,this._chunkOffsetZ=i,this._gridSize=r,this._terrainHeightData=a,this._terrainHeightDataWidth=o,this._terrainHeightDataHeight=s,this._leafNum=Xt.CHUNK_GRID_NUM/Xt.LEAF_GRID_NUM*(Xt.CHUNK_GRID_NUM/Xt.LEAF_GRID_NUM),this._leafs=h(this._leafNum),this._cameraCoordinateInverse=l;for(var _=0;_<this._leafNum;_++)this._leafs[_]=new Xt;this.recreateResource()}s(t,"laya.d3.terrain.TerrainFilter",e);var n=t.prototype;return a.imps(n,{"laya.d3.core.render.IRenderable":!0}),n._destroy=function(){e.prototype._destroy.call(this),this._owner=null,this._vertexBuffer&&this._vertexBuffer.destroy(),this._indexBuffer&&this._indexBuffer.destroy()},n.recreateResource=function(){this._currentNumberIndices=0,this._numberTriangle=0;var e=Xt.LEAF_VERTEXT_COUNT,t=Xt.LEAF_MAX_INDEX_COUNT;this._numberVertices=e*this._leafNum,this._maxNumberIndices=t*this._leafNum,this._indexArrayBuffer=new Uint16Array(this._maxNumberIndices);var n=mt.vertexDeclaration,i=n.vertexStride/4,r=new Float32Array(this._numberVertices*i),a=Xt.CHUNK_GRID_NUM/Xt.LEAF_GRID_NUM,o=0,s=0,l=0;for(o=0;o<this._leafNum;o++)s=o%a,l=Math.floor(o/a),this._leafs[o].calcVertextBuffer(this._chunkOffsetX,this._chunkOffsetZ,s*Xt.LEAF_GRID_NUM,l*Xt.LEAF_GRID_NUM,this._gridSize,r,o*Xt.LEAF_PLANE_VERTEXT_COUNT,i,this._terrainHeightData,this._terrainHeightDataWidth,this._terrainHeightDataHeight,this._cameraCoordinateInverse);for(o=0;o<this._leafNum;o++)s=o%a,l=Math.floor(o/a),this._leafs[o].calcSkirtVertextBuffer(this._chunkOffsetX,this._chunkOffsetZ,s*Xt.LEAF_GRID_NUM,l*Xt.LEAF_GRID_NUM,this._gridSize,r,this._leafNum*Xt.LEAF_PLANE_VERTEXT_COUNT+o*Xt.LEAF_SKIRT_VERTEXT_COUNT,i,this._terrainHeightData,this._terrainHeightDataWidth,this._terrainHeightDataHeight);this.assembleIndexInit(),this._vertexBuffer=new $n(n,this._numberVertices,35044,!1),this._indexBuffer=new Qn("ushort",this._maxNumberIndices,35044,!1),this._vertexBuffer.setData(r),this._indexBuffer.setData(this._indexArrayBuffer),this.memorySize=2*(this._vertexBuffer._byteLength+this._indexBuffer._byteLength),this.calcOriginalBoudingBoxAndSphere()},n.setLODLevel=function(e){if(4!=e.length)return!0;var t=(e[0]+1<<24)+(e[1]+1<<16)+(e[2]+1<<8)+(e[3]+1);return this._currentLOD!=t&&(this._currentLOD=t,!0)},n.assembleIndexInit=function(){this._currentNumberIndices=0,this._numberTriangle=0;for(var e=0,t=0;t<this._leafNum;t++){var n=Xt.getPlaneLODIndex(t,0);this._indexArrayBuffer.set(n,e),e+=n.length;var i=Xt.getSkirtLODIndex(t,0);this._indexArrayBuffer.set(i,e),e+=i.length,this._currentNumberIndices+=n.length+i.length}this._numberTriangle=this._currentNumberIndices/3},n.isNeedAssemble=function(e,t){var n=Math.min(e.viewport.width,e.viewport.height)/(2*Math.tan(Math.PI*e.fieldOfView/180));return this._perspectiveFactor!=n?(this._perspectiveFactor=n,1):this._LODTolerance!=vi.LOD_TOLERANCE_VALUE?(this._LODTolerance=vi.LOD_TOLERANCE_VALUE,1):0==bt.equals(t,this._cameraPos)?(this._cameraPos.x=t.x,this._cameraPos.y=t.y,this._cameraPos.z=t.z,2):0},n.assembleIndex=function(e,n){var i=this.isNeedAssemble(e,n);if(i>0){for(var r=0;r<this._leafNum;r++)t._TEMP_ARRAY_BUFFER[r]=this._leafs[r].determineLod(n,this._perspectiveFactor,vi.LOD_TOLERANCE_VALUE,1==i);if(this.setLODLevel(t._TEMP_ARRAY_BUFFER)){this._currentNumberIndices=0,this._numberTriangle=0;var a=0;for(r=0;r<this._leafNum;r++){var o=t._TEMP_ARRAY_BUFFER[r],s=Xt.getPlaneLODIndex(r,o);this._indexArrayBuffer.set(s,a),a+=s.length;var l=Xt.getSkirtLODIndex(r,o);this._indexArrayBuffer.set(l,a),a+=l.length,this._currentNumberIndices+=s.length+l.length}return this._numberTriangle=this._currentNumberIndices/3,!0}}return!1},n.calcOriginalBoudingBoxAndSphere=function(){for(var e=new Lt(2147483647,-2147483647),t=0;t<this._leafNum;t++)e.x=this._leafs[t]._sizeOfY.x<e.x?this._leafs[t]._sizeOfY.x:e.x,e.y=this._leafs[t]._sizeOfY.y>e.y?this._leafs[t]._sizeOfY.y:e.y;var n=new bt(this._chunkOffsetX*Xt.CHUNK_GRID_NUM*this._gridSize,e.x,this._chunkOffsetZ*Xt.CHUNK_GRID_NUM*this._gridSize),i=new bt((this._chunkOffsetX+1)*Xt.CHUNK_GRID_NUM*this._gridSize,e.y,(this._chunkOffsetZ+1)*Xt.CHUNK_GRID_NUM*this._gridSize);Xt.__ADAPT_MATRIX__&&(bt.transformV3ToV3(n,Xt.__ADAPT_MATRIX__,n),bt.transformV3ToV3(i,Xt.__ADAPT_MATRIX__,i)),this._boundingBox=new xt(n,i);var r=new bt;bt.subtract(i,n,r),bt.scale(r,.5,r);var a=new bt;bt.add(n,r,a),this._boundingSphere=new Rt(a,bt.scalarLength(r)),this._boundingBoxCorners=h(8,null),this._boundingBox.getCorners(this._boundingBoxCorners)},n.calcLeafBoudingBox=function(e){for(var t=0;t<this._leafNum;t++)this._leafs[t].calcLeafBoudingBox(e)},n.calcLeafBoudingSphere=function(e,t){for(var n=0;n<this._leafNum;n++)this._leafs[n].calcLeafBoudingSphere(e,t)},n._getVertexBuffer=function(e){return void 0===e&&(e=0),0==e?this._vertexBuffer:null},n._getIndexBuffer=function(){return this._indexBuffer},n._beforeRender=function(e){if(this._vertexBuffer._bind(),this._indexBuffer._bind(),0==e.renderElement._material.blend){var t=e.camera;this.assembleIndex(t,t.position)&&this._indexBuffer.setData(this._indexArrayBuffer)}return!0},n._getVertexBuffers=function(){return null},n._render=function(e){b.mainContext.drawElements(vi.RENDER_LINE_MODEL?1:4,this._currentNumberIndices,5123,0),w.trianglesFaces+=this._numberTriangle,w.drawCall++},l(0,n,"_originalBoundingSphere",function(){return this._boundingSphere}),l(0,n,"_originalBoundingBox",function(){return this._boundingBox}),l(0,n,"_vertexBufferCount",function(){return this._numberVertices}),l(0,n,"triangleCount",function(){return this._numberTriangle}),o(t,["_TEMP_ARRAY_BUFFER",function(){return this._TEMP_ARRAY_BUFFER=new Uint32Array(Xt.CHUNK_GRID_NUM/Xt.LEAF_GRID_NUM*Xt.CHUNK_GRID_NUM/Xt.LEAF_GRID_NUM)}]),t}(rn),Bn=function(e){function t(e){this._terrainSprite3DOwner=null,t.__super.call(this,e),this._terrainSprite3DOwner=e}s(t,"laya.d3.terrain.TerrainRender",e);var n=t.prototype;return n._calculateBoundingSphere=function(){var e=this._terrainSprite3DOwner.terrainFilter;if(null==e)this._boundingSphere.toDefault();else{var t,n=e._originalBoundingSphere,i=this._terrainSprite3DOwner.transform,r=i.scale;t=r.x>=r.y&&r.x>=r.z?r.x:r.y>=r.z?r.y:r.z,bt.transformCoordinate(n.center,i.worldMatrix,this._boundingSphere.center),this._boundingSphere.radius=n.radius*t,e.calcLeafBoudingSphere(i.worldMatrix,t)}},n._calculateBoundingBox=function(){var e=this._terrainSprite3DOwner.terrainFilter;if(null==e)this._boundingBox.toDefault();else{for(var t=this._terrainSprite3DOwner.transform.worldMatrix,n=e._boundingBoxCorners,i=0;i<8;i++)bt.transformCoordinate(n[i],t,an._tempBoundBoxCorners[i]);xt.createfromPoints(an._tempBoundBoxCorners,this._boundingBox),e.calcLeafBoudingBox(t)}},n._renderUpdate=function(e){this._setShaderValueMatrix4x4(0,this._owner.transform.worldMatrix);var t=this._owner.getProjectionViewWorldMatrix(e);return this._setShaderValueMatrix4x4(1,t),!0},n._destroy=function(){e.prototype._destroy.call(this),this._terrainSprite3DOwner=null},t}(an),Un=function(e){function t(){this._time=0,this._enableLightCount=3,this._customRenderQueneIndex=11,this.enableLight=!0,t.__super.call(this),this._renderState=new me,this._lights=[],this._quenes=[],this._cameraPool=[],this._renderableSprite3Ds=[],this.__loaded=!0,this._lightmaps=[],this._shaderValues=new Wt,this.parallelSplitShadowMaps=[],this._dynamicBatchManager=new Re,this._cullingRenders=[],this._cullingRendersLength=0,this.enableFog=!1,this.fogStart=300,this.fogRange=1e3,this.fogColor=new bt(.7,.7,.7),this.ambientColor=new bt(.212,.227,.259),b.shaderHighPrecision&&this.addShaderDefine(fn.SHADERDEFINE_HIGHPRECISION),this.on("display",this,this._display),this.on("undisplay",this,this._unDisplay),this._componentsMap=[],this._typeComponentsIndices=[],this._components=[]}s(t,"laya.d3.core.scene.Scene",e);var n=t.prototype;return a.imps(n,{"laya.webgl.submit.ISubmit":!0,"laya.resource.ICreateResource":!0}),n._setUrl=function(e){this._url=e},n._getGroup=function(){return this._group},n._setGroup=function(e){this._group=e},n._display=function(){a.stage._scenes.push(this),a.stage._scenes.sort(t._sortScenes);for(var e=0,n=this._childs.length;e<n;e++){var i=this._childs[e];i.active&&i._activeHierarchy()}},n._unDisplay=function(){var e=a.stage._scenes;e.splice(e.indexOf(this),1);for(var t=0,n=this._childs.length;t<n;t++){var i=this._childs[t];i.active&&i._inActiveHierarchy()}},n._addChild3D=function(e){e.transform._onWorldTransform(),e._setBelongScene(this),this.displayedInStage&&e.active&&e._activeHierarchy()},n._removeChild3D=function(e){e.transform.parent=null,this.displayedInStage&&e.active&&e._inActiveHierarchy(),e._setUnBelongScene()},n.initOctree=function(e,t,n,i,r){void 0===r&&(r=6),this.treeSize=new bt(e,t,n),this.treeLevel=r,this.treeRoot=new pe(this,0),this.treeRoot.init(i,this.treeSize)},n._prepareUpdateToRenderState=function(e,t){t.elapsedTime=this._lastCurrentTime?this.timer.currTimer-this._lastCurrentTime:0,this._lastCurrentTime=this.timer.currTimer,t.scene=this},n._prepareSceneToRender=function(e){var t=this._lights.length;if(t>0)for(var n=0,i=0;i<t&&!(this._lights[i]._prepareToScene(e)&&++n>=this._enableLightCount);i++);},n._updateChilds=function(e){for(var t=0,n=this._childs.length;t<n;++t)this._childs[t]._update(e)},n._preRenderScene=function(e,t,n){var i,r=t._viewMatrix,a=t._projectionMatrix,o=t._projectionViewMatrix,s=0,l=t.camera;for(l.useOcclusionCulling?this.treeRoot?Ae.renderObjectCullingOctree(n,this,l,r,a,o):Ae.renderObjectCulling(n,this,l,r,a,o):Ae.renderObjectCullingNoBoundFrustum(this,l,r,a,o),s=0,i=this._quenes.length;s<i;s++)this._quenes[s]&&this._quenes[s]._preRender(t)},n._clear=function(e,t){var n=t._viewport,i=t.camera,r=n.x,a=i.renderTargetSize.height-n.y-n.height,o=n.width,s=n.height;e.viewport(r,a,o,s);var l=256,h=i.renderTarget;switch(i.clearFlag){case 0:var _=i.clearColor;if(_){e.enable(3089),e.scissor(r,a,o,s);var u=_.elements;e.clearColor(u[0],u[1],u[2],u[3]),l|=16384}if(h)switch(_||(l=16384),h.depthStencilFormat){case 33189:l|=256;break;case 36168:l|=1024;break;case 34041:l|=256,l|=1024}e.clear(l),_&&e.disable(3089);break;case 1:case 2:if(h)switch(l=16384,h.depthStencilFormat){case 33189:l|=256;break;case 36168:l|=1024;break;case 34041:l|=256,l|=1024}e.clear(l);break;case 3:break;default:throw new Error("BaseScene:camera clearFlag invalid.")}},n._renderScene=function(e,t){var n,i,r=t.camera,a=0;for(a=0;a<2;a++)(n=this._quenes[a])&&(r.renderTarget?n._render(t,!0):n._render(t,!1));if(1===r.clearFlag){var o=r.sky;o&&(F.setCullFace(e,!1),F.setDepthFunc(e,515),F.setDepthMask(e,!1),o._render(t),F.setDepthFunc(e,513),F.setDepthMask(e,!0))}for(a=2,i=this._quenes.length;a<i;a++)(n=this._quenes[a])&&(n._sortAlpha(t.camera.transform.position),r.renderTarget?n._render(t,!0):n._render(t,!1))},n._set3DRenderConfig=function(e){e.disable(3042),F._blend=!1,e.blendFunc(770,771),F._sFactor=770,F._dFactor=771,e.disable(2929),F._depthTest=!1,e.enable(2884),F._cullFace=!0,e.depthMask(1),F._depthMask=!0,e.frontFace(2304),F._frontFace=2304},n._set2DRenderConfig=function(e){F.setBlend(e,!0),F.setBlendFunc(e,1,771),F.setDepthTest(e,!1),F.setCullFace(e,!1),F.setDepthMask(e,!0),F.setFrontFace(e,2305),e.viewport(0,0,I.width,I.height)},n._parseCustomProps=function(e,t,n,i){var r=i.customProps.lightmaps,a=r.length,o=this._lightmaps;o.length=a;for(var s=0;s<a;s++)o[s]=S.getRes(t[r[s].replace(".exr",".png")]);this.setlightmaps(o);var l=i.customProps.ambientColor;l&&(this.ambientColor=new bt(l[0],l[1],l[2]));var h=i.customProps.fogColor;h&&(this.fogColor=new bt(h[0],h[1],h[2]))},n._addLight=function(e){this._lights.indexOf(e)<0&&this._lights.push(e)},n._removeLight=function(e){var t=this._lights.indexOf(e);t>=0&&this._lights.splice(t,1)},n._updateScene=function(){var e=this._renderState;this._prepareUpdateToRenderState(b.mainContext,e),this._updateComponents(e),this._updateChilds(e),this._lateUpdateComponents(e),this._time+=e.elapsedTime/1e3,this._shaderValues.setValue(22,this._time)},n._updateSceneConch=function(){var e=this._renderState;this._prepareUpdateToRenderState(b.mainContext,e),this._updateComponents(e),this._lateUpdateComponents(e),this._prepareSceneToRender(e);for(var t=0,n=this._cameraPool.length;t<n;t++){var i=this._cameraPool[t];e.camera=i,i._prepareCameraToRender()}},n._preRenderShadow=function(e,t,n,i,r){this.treeRoot?Ae.renderShadowObjectCullingOctree(this,t,n,i,r):Ae.renderShadowObjectCulling(this,t,n,i,r);for(var a=0,o=n.length;a<o;a++)n[a]&&n[a]._preRender(e)},n._renderShadowMap=function(e,t,n){var i=this.parallelSplitShadowMaps[0];i._calcAllLightCameraInfo(n);var r,a,o,s=i.PSSMNum;if(this._preRenderShadow(t,i._lightCulling,i._shadowQuenes,i._lightVPMatrix[0],s),this.addShaderDefine(kt.SHADERDEFINE_CAST_SHADOW),s>1)for(var l=0;l<s;l++)r=i.getRenderTarget(l+1),i.beginRenderTarget(l+1),e.clearColor(1,1,1,1),e.clear(16640),e.viewport(0,0,r.width,r.height),t.camera=o=i.getLightCamera(l),o._prepareCameraToRender(),o._prepareCameraViewProject(o.viewMatrix,o.projectionMatrix),t._projectionViewMatrix=i._lightVPMatrix[l+1],(a=i._shadowQuenes[l])._preRender(t),a._renderShadow(t,!1),i.endRenderTarget(l+1);else r=i.getRenderTarget(1),i.beginRenderTarget(1),e.clearColor(1,1,1,1),e.clear(16640),e.viewport(0,0,r.width,r.height),t.camera=o=i.getLightCamera(0),o._prepareCameraToRender(),o._prepareCameraViewProject(o.viewMatrix,o.projectionMatrix),t._projectionViewMatrix=i._lightVPMatrix[0],(a=i._shadowQuenes[0])._preRender(t),a._renderShadow(t,!0),i.endRenderTarget(1);this.removeShaderDefine(kt.SHADERDEFINE_CAST_SHADOW)},n.addTreeNode=function(e){this.treeRoot.addTreeNode(e)},n.removeTreeNode=function(e){this.treeSize&&e._treeNode&&e._treeNode.removeObject(e)},n.setlightmaps=function(e){this._lightmaps=e;for(var t=0,n=this._renderableSprite3Ds.length;t<n;t++)this._renderableSprite3Ds[t]._render._applyLightMapParams()},n.getlightmaps=function(){return this._lightmaps},n.addChildAt=function(e,t){if(!(e instanceof laya.d3.core.Sprite3D))throw new Error("Sprite3D:Node type must Sprite3D.");if(!e||this.destroyed||e===this)return e;if(e.zOrder&&this._set$P("hasZorder",!0),t>=0&&t<=this._childs.length){if(e._parent===this){var n=this.getChildIndex(e);this._childs.splice(n,1),this._childs.splice(t,0,e),this.conchModel&&(this.conchModel.removeChild(e.conchModel),this.conchModel.addChildAt(e.conchModel,t)),this._childChanged()}else e.parent&&e.parent.removeChild(e),this._childs===R.ARRAY_EMPTY&&(this._childs=[]),this._childs.splice(t,0,e),this.conchModel&&this.conchModel.addChildAt(e.conchModel,t),e.parent=this,this._addChild3D(e);return e}throw new Error("appendChildAt:The index is out of bounds")},n.addChild=function(e){if(!(e instanceof laya.d3.core.Sprite3D))throw new Error("Sprite3D:Node type must Sprite3D.");if(!e||this.destroyed||e===this)return e;if(e.zOrder&&this._set$P("hasZorder",!0),e._parent===this){var t=this.getChildIndex(e);t!==this._childs.length-1&&(this._childs.splice(t,1),this._childs.push(e),this.conchModel&&(this.conchModel.removeChild(e.conchModel),this.conchModel.addChildAt(e.conchModel,this._childs.length-1)),this._childChanged())}else e.parent&&e.parent.removeChild(e),this._childs===R.ARRAY_EMPTY&&(this._childs=[]),this._childs.push(e),this.conchModel&&this.conchModel.addChildAt(e.conchModel,this._childs.length-1),e.parent=this,this._childChanged(),this._addChild3D(e);return e},n.removeChildAt=function(e){var t=this.getChildAt(e);return t&&(this._removeChild3D(t),this._childs.splice(e,1),this.conchModel&&this.conchModel.removeChild(t.conchModel),t.parent=null),t},n.removeChildren=function(e,t){if(void 0===e&&(e=0),void 0===t&&(t=2147483647),this._childs&&this._childs.length>0){var n=this._childs;if(0===e&&t>=a){var i=n;this._childs=R.ARRAY_EMPTY}else i=n.splice(e,t-e);for(var r=0,a=i.length;r<a;r++)this._removeChild3D(i[r]),i[r].parent=null,this.conchModel&&this.conchModel.removeChild(i[r].conchModel)}return this},n.addFrustumCullingObject=function(e){this.treeRoot?this.addTreeNode(e):(this._cullingRendersLength===this._cullingRenders.length?this._cullingRenders.push(e):this._cullingRenders[this._cullingRendersLength]=e,e._indexInSceneFrustumCullingObjects=this._cullingRendersLength++)},n.removeFrustumCullingObject=function(e){if(this.treeRoot)this.removeTreeNode(e);else{this._cullingRendersLength--;var t=e._indexInSceneFrustumCullingObjects;if(t!==this._cullingRendersLength){var n=this._cullingRenders[this._cullingRendersLength];this._cullingRenders[t]=n,n._indexInSceneFrustumCullingObjects=t,e._indexInSceneFrustumCullingObjects=-1}}},n.getRenderQueue=function(e){return this._quenes[e]||(this._quenes[e]=new fe(this))},n.addRenderQuene=function(){this._quenes[this._customRenderQueneIndex++]=new fe(this)},n.addShaderDefine=function(e){this._shaderDefineValue|=e},n.removeShaderDefine=function(e){this._shaderDefineValue&=~e},n.addScript=function(e){return this._addComponent(e)},n.getScriptByType=function(e,t){return void 0===t&&(t=0),this._getComponentByType(e,t)},n.getScriptsByType=function(e,t){this._getComponentsByType(e,t)},n.getScriptByIndex=function(e){return this._getComponentByIndex(e)},n.removeScriptByType=function(e,t){void 0===t&&(t=0),this._removeComponentByType(e,t)},n.removeScriptsByType=function(e){this._removeComponentByType(e)},n.removeAllScript=function(){this._removeAllComponent()},n.render=function(e,t,n){A._context.ctx._renderKey=0,this._childs.length>0&&e.addRenderObject(this)},n.renderSubmit=function(){var e=b.mainContext,t=this._renderState;this._set3DRenderConfig(e),this._prepareSceneToRender(this._renderState);var n,i=0,r=0;if(en.debugMode||pe.debugMode)for(i=0,r=this._cameraPool.length;i<r;i++)n=this._cameraPool[i],en._debugPhasorSprite.begin(1,n),n.activeInHierarchy&&n._renderCamera(e,t,this),en._debugPhasorSprite.end();else for(i=0,r=this._cameraPool.length;i<r;i++)(n=this._cameraPool[i]).activeInHierarchy&&n._renderCamera(e,t,this);return this._set2DRenderConfig(e),1},n.onAsynLoaded=function(e,t,n){var i=t[0];if("Scene"!==i.type)throw new Error("Scene: the .lh file root type must be Scene,please use other function to  load  this file.");var r=t[1];Jt._createNodeByJson(this,i,this,r),this.event("hierarchyloaded",[this]),this.__loaded=!0},n.destroy=function(t){void 0===t&&(t=!0),this.destroyed||(e.prototype.destroy.call(this,t),this._renderState=null,this._lights=null,this._lightmaps=null,this._renderTargetTexture=null,this._shaderValues=null,this._cullingRenders=null,this._dynamicBatchManager=null,this._quenes=null,this._cameraPool=null,this._renderableSprite3Ds=null,this.treeRoot=null,this.treeSize=null,this.parallelSplitShadowMaps=null,this._typeComponentsIndices=null,this._components=null,S.clearRes(this.url),this.loaded||en._cancelLoadByUrl(this.url))},n.getRenderType=function(){return 0},n.releaseRender=function(){},n._addComponent=function(e){var t,n=this._componentsMap.indexOf(e);if(-1===n)t=[],this._componentsMap.push(e),this._typeComponentsIndices.push(t);else if(t=this._typeComponentsIndices[n],this._components[t[0]].isSingleton)throw new Error("无法单实例创建"+e+"组件，"+e+"组件已存在！");var i=E.getInstance(e);return t.push(this._components.length),this._components.push(i),i._initialize(this),i},n._removeComponent=function(e,t){var n=this._typeComponentsIndices[e],i=n[t],r=this._components[i];this._components.splice(i,1),n.splice(t,1),0===n.length&&(this._typeComponentsIndices.splice(e,1),this._componentsMap.splice(e,1));for(var a=0,o=this._componentsMap.length;a<o;a++)for(var s=(n=this._typeComponentsIndices[a]).length-1;s>=0;s--){var l=n[s];if(!(l>i))break;n[s]=--l}r._destroy()},n._getComponentByType=function(e,t){void 0===t&&(t=0);var n=this._componentsMap.indexOf(e);return-1===n?null:this._components[this._typeComponentsIndices[n][t]]},n._getComponentsByType=function(e,t){var n=this._componentsMap.indexOf(e);if(-1!==n){var i=this._typeComponentsIndices[n],r=i.length;t.length=r;for(var a=0;a<r;a++)t[a]=this._components[i[a]]}else t.length=0},n._getComponentByIndex=function(e){return this._components[e]},n._removeComponentByType=function(e,t){void 0===t&&(t=0);var n=this._componentsMap.indexOf(e);-1!==n&&this._removeComponent(n,t)},n._removeComponentsByType=function(e){var t=this._componentsMap.indexOf(e);if(-1!==t)for(var n=this._typeComponentsIndices[t],i=0,r=n.length;i<r;n.length<r?r--:i++)this._removeComponent(t,i)},n._removeAllComponent=function(){for(var e=0,t=this._componentsMap.length;e<t;this._componentsMap.length<t?t--:e++)this._removeComponentsByType(this._componentsMap[e])},n._updateComponents=function(e){for(var t=0,n=this._components.length;t<n;t++){var i=this._components[t];!i.started&&(i._start(e),i.started=!0),i.enable&&i._update(e)}},n._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.enable&&n._lateUpdate(e)}},n._preRenderUpdateComponents=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.enable&&n._preRenderUpdate(e)}},n._postRenderUpdateComponents=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.enable&&n._postRenderUpdate(e)}},l(0,n,"_loaded",null,function(e){this.__loaded=e}),l(0,n,"fogColor",function(){return this._fogColor},function(e){this._fogColor=e,this._shaderValues.setValue(0,e.elements)}),l(0,n,"enableFog",function(){return this._enableFog},function(e){this._enableFog!==e&&(this._enableFog=e,e?(this.addShaderDefine(fn.SHADERDEFINE_FOG),this.removeShaderDefine(fn.SAHDERDEFINE_DEPTHFOG)):this.removeShaderDefine(fn.SHADERDEFINE_FOG))}),l(0,n,"url",function(){return this._url}),l(0,n,"loaded",function(){return this.__loaded}),l(0,n,"enableDepthFog",function(){return this._enableDepthFog},function(e){this._enableDepthFog!=e&&(this._enableDepthFog=e,e?(this.addShaderDefine(fn.SAHDERDEFINE_DEPTHFOG),this.removeShaderDefine(fn.SHADERDEFINE_FOG)):this.removeShaderDefine(fn.SAHDERDEFINE_DEPTHFOG))}),l(0,n,"fogStart",function(){return this._fogStart},function(e){this._fogStart=e,this._shaderValues.setValue(1,e)}),l(0,n,"fogRange",function(){return this._fogRange},function(e){this._fogRange=e,this._shaderValues.setValue(2,e)}),l(0,n,"ambientColor",function(){return this._ambientColor},function(e){this._ambientColor=e,this._shaderValues.setValue(21,e.elements)}),l(0,n,"scene",function(){return this}),l(0,n,"renderableSprite3Ds",function(){return this._renderableSprite3Ds.slice()}),t._sortScenes=function(e,n){if(e.parent===a.stage&&n.parent===a.stage){var i=a.stage._childs;return i.indexOf(e)-i.indexOf(n)}return e.parent!==a.stage&&n.parent!==a.stage?t._sortScenes(e.parent,n.parent):e.parent===a.stage?-1:1},t.load=function(e){return a.loader.create(e,null,null,t)},t.FOGCOLOR=0,t.FOGSTART=1,t.FOGRANGE=2,t.LIGHTDIRECTION=3,t.LIGHTDIRCOLOR=4,t.POINTLIGHTPOS=5,t.POINTLIGHTRANGE=6,t.POINTLIGHTATTENUATION=7,t.POINTLIGHTCOLOR=8,t.SPOTLIGHTPOS=9,t.SPOTLIGHTDIRECTION=10,t.SPOTLIGHTSPOT=11,t.SPOTLIGHTRANGE=12,t.SPOTLIGHTATTENUATION=13,t.SPOTLIGHTCOLOR=14,t.SHADOWDISTANCE=15,t.SHADOWLIGHTVIEWPROJECT=16,t.SHADOWMAPPCFOFFSET=17,t.SHADOWMAPTEXTURE1=18,t.SHADOWMAPTEXTURE2=19,t.SHADOWMAPTEXTURE3=20,t.AMBIENTCOLOR=21,t.TIME=22,t}(O),Hn=function(e){function t(e){t.__super.call(this),this.__loaded=!0,this._projectionViewWorldUpdateLoopCount=-1,this._activeInHierarchy=!1,this._projectionViewWorldMatrix=new Ct,this._shaderValues=new Wt,this._colliders=[],this._id=++t._uniqueIDCounter,this._transform=new on(this),this.name=e||"Sprite3D-"+t._nameNumberCounter++,this.layer=Z.currentCreationLayer,this.active=!0}s(t,"laya.d3.core.Sprite3D",vn);var n=t.prototype;return a.imps(n,{"laya.d3.core.render.IUpdate":!0,"laya.resource.ICreateResource":!0,"laya.d3.core.IClone":!0}),n._setUrl=function(e){this._url=e},n._getGroup=function(){return this._group},n._setGroup=function(e){this._group=e},n._addChild3D=function(e){e.transform.parent=this.transform,this._hierarchyAnimator&&(!e._hierarchyAnimator&&e._setHierarchyAnimator(this._hierarchyAnimator,null),this._getAnimatorToLinkSprite3D(e,!0,[e.name])),this._scene&&(e._setBelongScene(this._scene),this._activeInHierarchy&&e._active&&e._activeHierarchy())},n._removeChild3D=function(e){e.transform.parent=null,this._scene&&(this._activeInHierarchy&&e._active&&e._inActiveHierarchy(),e._setUnBelongScene()),this._hierarchyAnimator&&(e._hierarchyAnimator==this._hierarchyAnimator&&e._clearHierarchyAnimator(this._hierarchyAnimator,null),this._getAnimatorToLinkSprite3D(e,!1,[e.name]))},n._parseBaseCustomProps=function(e){var t=this.transform.localPosition;t.fromArray(e.translate),this.transform.localPosition=t;var n=this.transform.localRotation;n.fromArray(e.rotation),this.transform.localRotation=n;var i=this.transform.localScale;i.fromArray(e.scale),this.transform.localScale=i;var r=e.layer;null!=r&&(this.layer=Z.getLayerByNumber(r))},n._parseCustomComponent=function(e,t,n){for(var i in n){var r=n[i];switch(i){case"Animator":var a=this.addComponent(An);if(r.avatarPath)a.avatar=S.getRes(t[r.avatarPath]);else{var o=r.avatar;if(o){a.avatar=S.getRes(t[o.path]);var s=o.linkSprites;s&&e.once("hierarchyloaded",this,this._onRootNodeHierarchyLoaded,[a,s])}}for(var l=r.clipPaths,h=l.length,_=0;_<h;_++)a.addClip(S.getRes(t[l[_]]));a.clip=S.getRes(t[l[0]]);var u=r.playOnWake;void 0!==u&&(a.playOnWake=u);break;case"Rigidbody":this.addComponent(yn);break;case"SphereCollider":var c=this.addComponent(ri);c.isTrigger=r.isTrigger;var d=c.center;d.fromArray(r.center),c.center=d,c.radius=r.radius;break;case"BoxCollider":var f=this.addComponent(ni);f.isTrigger=r.isTrigger,f.center.fromArray(r.center);var m=f.size;m.fromArray(r.size),f.size=m;break;case"MeshCollider":this.addComponent(ii)}}},n._onRootNodeHierarchyLoaded=function(e,t){for(var n in t){for(var i=this,r=t[n],a=0,o=r.length;a<o;a++){var s=r[a];if(""===s)break;if(!(i=i.getChildByName(s)))break}i&&e.linkSprite3DToAvatarNode(n,i)}},n._setHierarchyAnimator=function(e,t){this._changeHierarchyAnimator(e);for(var n=0,i=this._childs.length;n<i;n++){var r=this._childs[n];r._hierarchyAnimator==t&&r._setHierarchyAnimator(e,t)}},n._clearHierarchyAnimator=function(e,t){this._changeHierarchyAnimator(t);for(var n=0,i=this._childs.length;n<i;n++){var r=this._childs[n];r._hierarchyAnimator==e&&r._clearHierarchyAnimator(e,t)}},n._getAnimatorToLinkSprite3D=function(e,t,n){var i=this.getComponentByType(An);if(i&&(i.avatar?i.avatar._version||e._setAnimatorToLinkAvatar(i,t):e._setAnimatorToLinkSprite3DNoAvatar(i,t,n)),this._parent&&this._parent instanceof laya.d3.core.Sprite3D){n.unshift(this._parent.name);var r=this._parent;r._hierarchyAnimator&&r._getAnimatorToLinkSprite3D(e,t,n)}},n._setAnimatorToLinkSprite3DNoAvatar=function(e,t,n){var i=0,r=0;for(i=0,r=e.getClipCount();i<r;i++)e._handleSpriteOwnersBySprite(i,t,n,this);for(i=0,r=this._childs.length;i<r;i++){var a=this._childs[i],o=n.length;n.push(a.name),a._setAnimatorToLinkSprite3DNoAvatar(e,t,n),n.splice(o,1)}},n._changeHierarchyAnimator=function(e){this._hierarchyAnimator=e},n._isLinkSpriteToAnimationNode=function(e,t,n){var i=e._avatarNodes.indexOf(t),r=e._cacheSpriteToNodesMap;if(n)this._transform.dummy=t.transform,e._cacheNodesToSpriteMap[i]=r.length,r.push(i);else{this._transform.dummy=null;var a=e._cacheNodesToSpriteMap[i];e._cacheNodesToSpriteMap[i]=null,r.splice(a,1)}},n._setBelongScene=function(e){this._scene=e;for(var t=0,n=this._childs.length;t<n;t++)this._childs[t]._setBelongScene(e)},n._setUnBelongScene=function(){this._scene=null;for(var e=0,t=this._childs.length;e<t;e++)this._childs[e]._setUnBelongScene()},n._activeHierarchy=function(){var e=0,t=0;for(this._activeInHierarchy=!0,this._addSelfRenderObjects(),e=0,t=this._colliders.length;e<t;e++)this._layer._addCollider(this._colliders[e]);for(this.event("activeinhierarchychanged",!0),e=0,t=this._childs.length;e<t;e++){var n=this._childs[e];n._active&&n._activeHierarchy()}},n._inActiveHierarchy=function(){var e=0,t=0;for(this._activeInHierarchy=!1,this._clearSelfRenderObjects(),e=0,t=this._colliders.length;e<t;e++){var n=this._colliders[e];n._clearCollsionMap(),this._layer._removeCollider(n)}for(this.event("activeinhierarchychanged",!1),e=0,t=this._childs.length;e<t;e++){var i=this._childs[e];i._active&&i._inActiveHierarchy()}},n.addComponent=function(e){var t,n=this._componentsMap.indexOf(e);if(-1===n)t=[],this._componentsMap.push(e),this._typeComponentsIndices.push(t);else if(t=this._typeComponentsIndices[n],this._components[t[0]].isSingleton)throw new Error("无法单实例创建"+e+"组件，"+e+"组件已存在！");var i=E.getInstance(e);if(t.push(this._components.length),this._components.push(i),i instanceof laya.d3.component.physics.Collider)this.getComponentByType(yn)&&(i._isRigidbody=!0),this._activeInHierarchy&&this._layer._addCollider(i),this._colliders.push(i);else if(i instanceof laya.d3.component.Animator){var r=i;this._setHierarchyAnimator(r,this._parent?this._parent._hierarchyAnimator:null),this._setAnimatorToLinkSprite3DNoAvatar(r,!0,[])}else if(i instanceof laya.d3.component.Rigidbody)for(var a=0,o=this._colliders.length;a<o;a++)this._colliders[a]._setIsRigidbody(!0);return i instanceof laya.d3.component.Script&&this._scripts.push(i),i._initialize(this),i},n._removeComponent=function(e,t){var n=0,i=0,r=this._typeComponentsIndices[e],a=r[t],o=this._components[a];if(o instanceof laya.d3.component.physics.Collider){var s=o;this._activeInHierarchy&&this._layer._removeCollider(s),this._colliders.splice(this._colliders.indexOf(s),1)}else if(o instanceof laya.d3.component.Animator){var l=o;this._clearHierarchyAnimator(l,this._parent?this._parent._hierarchyAnimator:null)}else if(o instanceof laya.d3.component.Rigidbody)for(n=0,i=this._colliders.length;n<i;n++){var h=this._colliders[n];h._setIsRigidbody(!1);var _=h._runtimeCollisonMap,u=h._runtimeCollisonTestMap;for(var c in _)delete u[c]}for(this._components.splice(a,1),o instanceof laya.d3.component.Script&&this._scripts.splice(this._scripts.indexOf(o),1),r.splice(t,1),0===r.length&&(this._typeComponentsIndices.splice(e,1),this._componentsMap.splice(e,1)),n=0,i=this._componentsMap.length;n<i;n++)for(var d=(r=this._typeComponentsIndices[n]).length-1;d>=0;d--){var f=r[d];if(!(f>a))break;r[d]=--f}o._destroy()},n._clearSelfRenderObjects=function(){},n._addSelfRenderObjects=function(){},n._parseCustomProps=function(e,t,n,i){},n._updateChilds=function(e){var t=this._childs.length;if(0!==t)for(var n=0;n<t;++n)this._childs[n]._update(e)},n._getSortID=function(e,t){return 1e3*t.id+e._getVertexBuffer().vertexDeclaration.id},n._update=function(e){e.owner=this,this._activeInHierarchy&&(this._updateComponents(e),this._lateUpdateComponents(e),w.spriteCount++,this._childs.length&&this._updateChilds(e))},n.getProjectionViewWorldMatrix=function(e){return Ct.multiply(e,this.transform.worldMatrix,this._projectionViewWorldMatrix),this._projectionViewWorldMatrix},n.loadHierarchy=function(e){this.addChild(laya.d3.core.Sprite3D.load(e))},n.addChildAt=function(e,t){if(!(e instanceof laya.d3.core.Sprite3D))throw new Error("Sprite3D:Node type must Sprite3D.");if(!e||this.destroyed||e===this)return e;if(e.zOrder&&this._set$P("hasZorder",!0),t>=0&&t<=this._childs.length){if(e._parent===this){var n=this.getChildIndex(e);this._childs.splice(n,1),this._childs.splice(t,0,e),this.conchModel&&(this.conchModel.removeChild(e.conchModel),this.conchModel.addChildAt(e.conchModel,t)),this._childChanged()}else e.parent&&e.parent.removeChild(e),this._childs===R.ARRAY_EMPTY&&(this._childs=[]),this._childs.splice(t,0,e),this.conchModel&&this.conchModel.addChildAt(e.conchModel,t),e.parent=this,this._addChild3D(e);return e}throw new Error("appendChildAt:The index is out of bounds")},n.addChild=function(e){if(!(e instanceof laya.d3.core.Sprite3D))throw new Error("Sprite3D:Node type must Sprite3D.");if(!e||this.destroyed||e===this)return e;if(e.zOrder&&this._set$P("hasZorder",!0),e._parent===this){var t=this.getChildIndex(e);t!==this._childs.length-1&&(this._childs.splice(t,1),this._childs.push(e),this.conchModel&&(this.conchModel.removeChild(e.conchModel),this.conchModel.addChildAt(e.conchModel,this._childs.length-1)),this._childChanged())}else e.parent&&e.parent.removeChild(e),this._childs===R.ARRAY_EMPTY&&(this._childs=[]),this._childs.push(e),this.conchModel&&this.conchModel.addChildAt(e.conchModel,this._childs.length-1),e.parent=this,this._childChanged(),this._addChild3D(e);return e},n.removeChildAt=function(e){var t=this.getChildAt(e);return t&&(this._removeChild3D(t),this._childs.splice(e,1),this.conchModel&&this.conchModel.removeChild(t.conchModel),t.parent=null),t},n.removeChildren=function(e,t){if(void 0===e&&(e=0),void 0===t&&(t=2147483647),this._childs&&this._childs.length>0){var n=this._childs;if(0===e&&t>=a){var i=n;this._childs=R.ARRAY_EMPTY}else i=n.splice(e,t-e);for(var r=0,a=i.length;r<a;r++)this._removeChild3D(i[r]),i[r].parent=null,this.conchModel&&this.conchModel.removeChild(i[r].conchModel)}return this},n.onAsynLoaded=function(e,t,n){var i=t[0];if("Sprite3D"!==i.type)throw new Error("Sprite3D: The .lh file root type must be Sprite3D,please use other function to  load  this file.");var r=t[1];Jt._createNodeByJson(this,i,this,r),this.event("hierarchyloaded",[this]),this.__loaded=!0},n.cloneTo=function(e){if(this.destroyed)throw new Error("Sprite3D: Can't be cloned if the Sprite3D has destroyed.");var t=e;t.name=this.name,t._destroyed=this._destroyed,t.timer=this.timer,t._$P=this._$P,t.active=this._active;var n=t.transform.localPosition,i=t.transform.position;this.transform.localPosition.cloneTo(n),this.transform.position.cloneTo(i),t.transform.localPosition=n,t.transform.position=i;var r=t.transform.localRotation;this.transform.localRotation.cloneTo(r),t.transform.localRotation=r;var a=t.transform.localScale;this.transform.localScale.cloneTo(a),t.transform.localScale=a,t.isStatic=this.isStatic;var o=0,s=0;for(o=0,s=this._componentsMap.length;o<s;o++){var l=t.addComponent(this._componentsMap[o]);this._components[o]._cloneTo(l)}for(o=0,s=this._childs.length;o<s;o++)t.addChild(this._childs[o].clone())},n.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},n.destroy=function(e){if(void 0===e&&(e=!0),!this.destroyed){laya.display.Node.prototype.destroy.call(this,e);var t,n=0;for(n=0,t=this._components.length;n<t;n++)this._components[n]._destroy();this._components=null,this._componentsMap=null,this._typeComponentsIndices=null,this._transform=null,this._colliders=null,S.clearRes(this.url),this.loaded||en._cancelLoadByUrl(this.url)}},n._handleSpriteToAvatar=function(e,t){e._avatarNodes;var n=e._avatarNodeMap[this.name];n&&n.name===this.name&&!this._transform.dummy&&this._isLinkSpriteToAnimationNode(e,n,t)},n._setAnimatorToLinkAvatar=function(e,t){this._handleSpriteToAvatar(e,t);for(var n=0,i=this._childs.length;n<i;n++)this._childs[n]._setAnimatorToLinkAvatar(e,t)},l(0,n,"activeInHierarchy",function(){return this._activeInHierarchy}),l(0,n,"_loaded",null,function(e){this.__loaded=e}),l(0,n,"active",function(){return this._active},function(e){this._active!==e&&(this._active=e,this._parent&&(this._parent===this._scene&&this._parent.displayedInStage||this._parent._activeInHierarchy)&&(e?this._activeHierarchy():this._inActiveHierarchy()))}),l(0,n,"componentsCount",function(){return this._components.length}),l(0,n,"loaded",function(){return this.__loaded}),l(0,n,"id",function(){return this._id}),l(0,n,"url",function(){return this._url}),l(0,n,"layer",function(){return this._layer},function(e){if(this._layer!==e){if(!e)throw new Error("Layer value can be null.");if(this._activeInHierarchy){var t=0,n=this._colliders.length;if(this._layer)for(t=0;t<n;t++)this._layer._removeCollider(this._colliders[t]);for(t=0;t<n;t++)e._addCollider(this._colliders[t])}this._layer=e,this.event("layerchanged",e)}}),l(0,n,"scene",function(){return this._scene}),l(0,n,"transform",function(){return this._transform}),t.instantiate=function(e,t,n,i,r){void 0===n&&(n=!0);var a=e.clone();t&&t.addChild(a);var o=a.transform;if(n){var s=o.worldMatrix;e.transform.worldMatrix.cloneTo(s),o.worldMatrix=s}else i&&(o.position=i),r&&(o.rotation=r);return a},t.load=function(e){return a.loader.create(e,null,null,t)},t.WORLDMATRIX=0,t.MVPMATRIX=1,t._uniqueIDCounter=0,t._nameNumberCounter=0,t}(),Gn=function(e){function t(e,n,i,r,a,o,s,l){if(this._curActTexIndex=0,this._program=null,this._attributeParams=null,this._uniformParams=null,this._attributeParamsMap=[],this._sceneUniformParamsMap=[],this._cameraUniformParamsMap=[],this._spriteUniformParamsMap=[],this._materialUniformParamsMap=[],this._renderElementUniformParamsMap=[],t.__super.call(this),!e||!n)throw"Shader Error";this._id=++t._count,this._vs=e,this._ps=n,this._attributeMap=i,this._sceneUniformMap=r,this._cameraUniformMap=a,this._spriteUniformMap=o,this._materialUniformMap=s,this._renderElementUniformMap=l,this.recreateResource()}s(t,"laya.d3.shader.Shader3D",f);var n=t.prototype;return n.recreateResource=function(){this._compile(),this.completeCreate(),this.memorySize=0},n.disposeResource=function(){b.mainContext.deleteShader(this._vshader),b.mainContext.deleteShader(this._pshader),b.mainContext.deleteProgram(this._program),this._vshader=this._pshader=this._program=null,this._attributeParams=null,this._uniformParams=null,this.memorySize=0,this._curActTexIndex=0},n._compile=function(){if(this._vs&&this._ps&&!this._attributeParams&&!this._uniformParams){this._reCompile=!0,this._attributeParams=[],this._uniformParams=[];var e=[this._vs,this._ps],n=b.mainContext;if(this._program=n.createProgram(),this._vshader=t._createShader(n,e[0],35633),this._pshader=t._createShader(n,e[1],35632),n.attachShader(this._program,this._vshader),n.attachShader(this._program,this._pshader),n.linkProgram(this._program),!A.isConchApp&&fn.debugMode&&!n.getProgramParameter(this._program,35714))throw n.getProgramInfoLog(this._program);var i,r,a=0,o=0;for(r=A.isConchApp?n.getProgramParameterEx(this._vs,this._ps,"",35721):n.getProgramParameter(this._program,35721),a=0;a<r;a++){var s=null;i={vartype:"attribute",ivartype:0,attrib:s=A.isConchApp?n.getActiveAttribEx(this._vs,this._ps,"",a):n.getActiveAttrib(this._program,a),location:n.getAttribLocation(this._program,s.name),name:s.name,type:s.type,isArray:!1,isSame:!1,preValue:null,indexOfParams:0},this._attributeParams.push(i)}var l;for(l=A.isConchApp?n.getProgramParameterEx(this._vs,this._ps,"",35718):n.getProgramParameter(this._program,35718),a=0;a<l;a++){var h;h=A.isConchApp?n.getActiveUniformEx(this._vs,this._ps,"",a):n.getActiveUniform(this._program,a),(i={vartype:"uniform",ivartype:1,attrib:s,location:n.getUniformLocation(this._program,h.name),name:h.name,type:h.type,isArray:!1,isSame:!1,preValue:null,indexOfParams:0}).name.indexOf("[0]")>0&&(i.name=i.name.substr(0,i.name.length-3),i.isArray=!0,i.location=n.getUniformLocation(this._program,i.name)),this._uniformParams.push(i)}for(a=0,o=this._attributeParams.length;a<o;a++)(i=this._attributeParams[a]).indexOfParams=a,i.index=1,i.value=[i.location,null],i.codename=i.name,i.name=null!=this._attributeMap[i.codename]?this._attributeMap[i.codename]:i.codename,this._attributeParamsMap.push(i.name),this._attributeParamsMap.push(i),i._this=this,i.uploadedValue=[],i.fun=this._attribute;for(a=0,o=this._uniformParams.length;a<o;a++)switch(i=this._uniformParams[a],i.indexOfParams=a,i.index=1,i.value=[i.location,null],i.codename=i.name,null!=this._sceneUniformMap[i.codename]?(i.name=this._sceneUniformMap[i.codename],this._sceneUniformParamsMap.push(i.name),this._sceneUniformParamsMap.push(i)):null!=this._cameraUniformMap[i.codename]?(i.name=this._cameraUniformMap[i.codename],this._cameraUniformParamsMap.push(i.name),this._cameraUniformParamsMap.push(i)):null!=this._spriteUniformMap[i.codename]?(i.name=this._spriteUniformMap[i.codename],this._spriteUniformParamsMap.push(i.name),this._spriteUniformParamsMap.push(i)):null!=this._materialUniformMap[i.codename]?(i.name=this._materialUniformMap[i.codename],this._materialUniformParamsMap.push(i.name),this._materialUniformParamsMap.push(i)):null!=this._renderElementUniformMap[i.codename]?(i.name=this._renderElementUniformMap[i.codename],this._renderElementUniformParamsMap.push(i.name),this._renderElementUniformParamsMap.push(i)):console.log("Shader:can't find uinform name:"+i.codename+" in shader file."),i._this=this,i.uploadedValue=[],i.type){case 5124:i.fun=i.isArray?this._uniform1iv:this._uniform1i;break;case 5126:i.fun=i.isArray?this._uniform1fv:this._uniform1f;break;case 35664:i.fun=i.isArray?this._uniform_vec2v:this._uniform_vec2;break;case 35665:i.fun=i.isArray?this._uniform_vec3v:this._uniform_vec3;break;case 35666:i.fun=i.isArray?this._uniform_vec4v:this._uniform_vec4;break;case 35678:i.fun=this._uniform_sampler2D;break;case 35680:i.fun=this._uniform_samplerCube;break;case 35676:i.fun=this._uniformMatrix4fv;break;case 35670:i.fun=this._uniform1i;break;case 35674:i.fun=this._uinformMatrix2fv;break;case 35675:i.fun=this._uinformMatrix3fv;break;default:throw new Error("compile shader err!")}}},n._attribute=function(e,t){var n=b.mainContext,i=p._enableAtributes,r=e.location;return i[r]||n.enableVertexAttribArray(r),n.vertexAttribPointer(r,t[0],t[1],t[2],t[3],t[4]),i[r]=p._bindVertexBuffer,1},n._uniform1f=function(e,t){var n=e.uploadedValue;return n[0]!==t?(b.mainContext.uniform1f(e.location,n[0]=t),1):0},n._uniform1fv=function(e,t){if(t.length<4){var n=e.uploadedValue;return n[0]!==t[0]||n[1]!==t[1]||n[2]!==t[2]||n[3]!==t[3]?(b.mainContext.uniform1fv(e.location,t),n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],1):0}return b.mainContext.uniform1fv(e.location,t),1},n._uniform_vec2=function(e,t){var n=e.uploadedValue;return n[0]!==t[0]||n[1]!==t[1]?(b.mainContext.uniform2f(e.location,n[0]=t[0],n[1]=t[1]),1):0},n._uniform_vec2v=function(e,t){if(t.length<2){var n=e.uploadedValue;return n[0]!==t[0]||n[1]!==t[1]||n[2]!==t[2]||n[3]!==t[3]?(b.mainContext.uniform2fv(e.location,t),n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],1):0}return b.mainContext.uniform2fv(e.location,t),1},n._uniform_vec3=function(e,t){var n=e.uploadedValue;return n[0]!==t[0]||n[1]!==t[1]||n[2]!==t[2]?(b.mainContext.uniform3f(e.location,n[0]=t[0],n[1]=t[1],n[2]=t[2]),1):0},n._uniform_vec3v=function(e,t){return b.mainContext.uniform3fv(e.location,t),1},n._uniform_vec4=function(e,t){var n=e.uploadedValue;return n[0]!==t[0]||n[1]!==t[1]||n[2]!==t[2]||n[3]!==t[3]?(b.mainContext.uniform4f(e.location,n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3]),1):0},n._uniform_vec4v=function(e,t){return b.mainContext.uniform4fv(e.location,t),1},n._uniformMatrix2fv=function(e,t){return b.mainContext.uniformMatrix2fv(e.location,!1,t),1},n._uniformMatrix3fv=function(e,t){return b.mainContext.uniformMatrix3fv(e.location,!1,t),1},n._uniformMatrix4fv=function(e,t){return b.mainContext.uniformMatrix4fv(e.location,!1,t),1},n._uinformMatrix2fv=function(e,t){return b.mainContext.uniformMatrix2fv(e.location,!1,t),1},n._uinformMatrix3fv=function(e,t){return b.mainContext.uniformMatrix3fv(e.location,!1,t),1},n._uniform1i=function(e,t){var n=e.uploadedValue;return n[0]!==t?(b.mainContext.uniform1i(e.location,n[0]=t),1):0},n._uniform1iv=function(e,t){return b.mainContext.uniform1iv(e.location,t),1},n._uniform_ivec2=function(e,t){var n=e.uploadedValue;return n[0]!==t[0]||n[1]!==t[1]?(b.mainContext.uniform2i(e.location,n[0]=t[0],n[1]=t[1]),1):0},n._uniform_ivec2v=function(e,t){return b.mainContext.uniform2iv(e.location,t),1},n._uniform_vec3i=function(e,t){var n=e.uploadedValue;return n[0]!==t[0]||n[1]!==t[1]||n[2]!==t[2]?(b.mainContext.uniform3i(e.location,n[0]=t[0],n[1]=t[1],n[2]=t[2]),1):0},n._uniform_vec3vi=function(e,t){return b.mainContext.uniform3iv(e.location,t),1},n._uniform_vec4i=function(e,t){var n=e.uploadedValue;return n[0]!==t[0]||n[1]!==t[1]||n[2]!==t[2]||n[3]!==t[3]?(b.mainContext.uniform4i(e.location,n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3]),1):0},n._uniform_vec4vi=function(e,t){return b.mainContext.uniform4iv(e.location,t),1},n._uniform_sampler2D=function(e,n){var i=n.source||n.defaulteTexture.source,r=b.mainContext,a=e.uploadedValue;if(null==a[0]){if(this._curActTexIndex>7)throw new Error("Shader3D: shader support textures max count is 8,can't large than it.");return a[0]=this._curActTexIndex,r.uniform1i(e.location,this._curActTexIndex),r.activeTexture(t._TEXTURES[this._curActTexIndex]),i&&F.bindTexture(r,3553,i),this._curActTexIndex++,1}return r.activeTexture(t._TEXTURES[a[0]]),i&&F.bindTexture(r,3553,i),0},n._uniform_samplerCube=function(e,n){var i=n.source||n.defaulteTexture.source,r=b.mainContext,a=e.uploadedValue;if(null==a[0]){if(this._curActTexIndex>7)throw new Error("Shader3D: shader support textures max count is 8,can't large than it.");return a[0]=this._curActTexIndex,r.uniform1i(e.location,this._curActTexIndex),r.activeTexture(t._TEXTURES[this._curActTexIndex]),i?F.bindTexture(r,34067,i):F.bindTexture(r,34067,_i.grayTexture.source),this._curActTexIndex++,1}return r.activeTexture(t._TEXTURES[a[0]]),i?F.bindTexture(r,34067,i):F.bindTexture(r,34067,_i.grayTexture.source),0},n._noSetValue=function(e){console.log("no....:"+e.name)},n.bind=function(){return f.activeShader=this,f.bindShader=this,this.activeResource(),F.UseProgram(this._program)},n.uploadAttributes=function(e,t){for(var n,i,r=0,a=0,o=this._attributeParamsMap.length;a<o;a+=2)i=this._attributeParamsMap[a+1],null!=(n=e[this._attributeParamsMap[a]])&&(t&&t[i.name]&&t[i.name].bind(),r+=i.fun.call(this,i,n));w.shaderCall+=r},n.uploadAttributesX=function(e,t){for(var n,i,r=0,a=0,o=this._attributeParamsMap.length;a<o;a+=2)i=this._attributeParamsMap[a+1],null!=(n=e[this._attributeParamsMap[a]])&&(t._bind(),r+=i.fun.call(this,i,n));w.shaderCall+=r},n.uploadSceneUniforms=function(e){for(var t,n,i=0,r=0,a=this._sceneUniformParamsMap.length;r<a;r+=2)n=this._sceneUniformParamsMap[r+1],null!=(t=e[this._sceneUniformParamsMap[r]])&&(i+=n.fun.call(this,n,t));w.shaderCall+=i},n.uploadCameraUniforms=function(e){for(var t,n,i=0,r=0,a=this._cameraUniformParamsMap.length;r<a;r+=2)n=this._cameraUniformParamsMap[r+1],null!=(t=e[this._cameraUniformParamsMap[r]])&&(i+=n.fun.call(this,n,t));w.shaderCall+=i},n.uploadSpriteUniforms=function(e){for(var t,n,i=0,r=0,a=this._spriteUniformParamsMap.length;r<a;r+=2)n=this._spriteUniformParamsMap[r+1],null!=(t=e[this._spriteUniformParamsMap[r]])&&(i+=n.fun.call(this,n,t));w.shaderCall+=i},n.uploadMaterialUniforms=function(e){for(var t,n,i=0,r=0,a=this._materialUniformParamsMap.length;r<a;r+=2)n=this._materialUniformParamsMap[r+1],null!=(t=e[this._materialUniformParamsMap[r]])&&(i+=n.fun.call(this,n,t));w.shaderCall+=i},n.uploadRenderElementUniforms=function(e){for(var t,n,i=0,r=0,a=this._renderElementUniformParamsMap.length;r<a;r+=2)n=this._renderElementUniformParamsMap[r+1],null!=(t=e[this._renderElementUniformParamsMap[r]])&&(i+=n.fun.call(this,n,t));w.shaderCall+=i},t.create=function(e,n,i,r,a,o,s,l){return new t(e,n,i,r,a,o,s,l)},t.addInclude=function(e,t){N.addInclude(e,t)},t._createShader=function(e,t,n){var i=e.createShader(n);if(e.shaderSource(i,t),e.compileShader(i),fn.debugMode&&!e.getShaderParameter(i,35713))throw e.getShaderInfoLog(i);return i},t.PERIOD_RENDERELEMENT=0,t.PERIOD_MATERIAL=1,t.PERIOD_SPRITE=2,t.PERIOD_CAMERA=3,t.PERIOD_SCENE=4,t._TEXTURES=[33984,33985,33986,33987,33988,33989,33990,33991],t._count=0,o(t,["shaderParamsMap",function(){return this.shaderParamsMap={float:5126,int:5124,bool:35670,vec2:35664,vec3:35665,vec4:35666,ivec2:35667,ivec3:35668,ivec4:35669,bvec2:35671,bvec3:35672,bvec4:35673,mat2:35674,mat3:35675,mat4:35676,sampler2D:35678,samplerCube:35680}},"nameKey",function(){return this.nameKey=new V}]),t}(),zn=function(e){function t(){t.__super.call(this),this.setShaderName("BLINNPHONG"),this._albedoIntensity=1,this._albedoColor=new Ft(1,1,1,1),this._setColor(6,new Ft(1,1,1,1)),this._setColor(8,new bt(1,1,1)),this._setNumber(9,.078125),this._setColor(10,new bt(1,1,1)),this._setNumber(0,.5),this._setColor(11,new Ft(1,1,0,0)),this._enableLighting=!0,this.renderMode=0,this._setColor(12,new Ft(1,1,1,1))}s(t,"laya.d3.core.material.BlinnPhongMaterial",e);var n=t.prototype;return n.disableLight=function(){this._addDisablePublicShaderDefine(fn.SHADERDEFINE_POINTLIGHT|fn.SHADERDEFINE_SPOTLIGHT|fn.SHADERDEFINE_DIRECTIONLIGHT)},n.disableFog=function(){this._addDisablePublicShaderDefine(fn.SHADERDEFINE_FOG)},n.cloneTo=function(t){e.prototype.cloneTo.call(this,t);var n=t;n._enableLighting=this._enableLighting,n._albedoIntensity=this._albedoIntensity,this._albedoColor.cloneTo(n._albedoColor)},l(0,n,"renderMode",null,function(e){switch(e){case 0:this.renderQueue=1,this.depthWrite=!0,this.cull=2,this.blend=0,this.alphaTest=!1,this.depthTest=513,this._removeShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 1:this.depthWrite=!0,this.cull=2,this.blend=0,this.renderQueue=1,this.alphaTest=!0,this.depthTest=513,this._removeShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 2:this.renderQueue=2,this.depthWrite=!1,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=771,this.alphaTest=!1,this.depthTest=513,this._removeShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 3:this.renderQueue=2,this.depthWrite=!1,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=1,this.alphaTest=!1,this.depthTest=513,this._addShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;default:throw new Error("Material:renderMode value error.")}this._conchMaterial&&this._conchMaterial.setRenderMode(e)}),l(0,n,"normalTexture",function(){return this._getTexture(2)},function(e){e?this._addShaderDefine(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_NORMALMAP):this._removeShaderDefine(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_NORMALMAP),this._setTexture(2,e)}),l(0,n,"reflectColor",function(){return this._getColor(10)},function(e){this._setColor(10,e)}),l(0,n,"tilingOffset",function(){return this._getColor(11)},function(e){if(e){var t=e.elements;1!=t[0]||1!=t[1]||0!=t[2]||0!=t[3]?this._addShaderDefine(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_TILINGOFFSET):this._removeShaderDefine(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_TILINGOFFSET)}else this._removeShaderDefine(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_TILINGOFFSET);this._setColor(11,e)}),l(0,n,"specularColor",function(){return this._getColor(8)},function(e){this._setColor(8,e)}),l(0,n,"albedoColor",function(){return this._albedoColor},function(e){var t=this._getColor(6);Ft.scale(e,this._albedoIntensity,t),this._albedoColor=e}),l(0,n,"albedoIntensity",function(){return this._albedoIntensity},function(e){if(this._albedoIntensity!==e){var t=this._getColor(6);Ft.scale(this._albedoColor,e,t),this._albedoIntensity=e}}),l(0,n,"albedoTexture",function(){return this._getTexture(1)},function(e){e?this._addShaderDefine(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_DIFFUSEMAP):this._removeShaderDefine(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_DIFFUSEMAP),this._setTexture(1,e)}),l(0,n,"shininess",function(){return this._getNumber(9)},function(e){e=Math.max(0,Math.min(1,e)),this._setNumber(9,e)}),l(0,n,"specularTexture",function(){return this._getTexture(3)},function(e){e?this._addShaderDefine(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_SPECULARMAP):this._removeShaderDefine(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_SPECULARMAP),this._setTexture(3,e)}),l(0,n,"reflectTexture",function(){return this._getTexture(5)},function(e){e?this._addShaderDefine(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_REFLECTMAP):this._removeShaderDefine(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_REFLECTMAP),this._setTexture(5,e)}),l(0,n,"enableLighting",function(){return this._enableLighting},function(e){this._enableLighting!==e&&(e?this._removeDisablePublicShaderDefine(fn.SHADERDEFINE_POINTLIGHT|fn.SHADERDEFINE_SPOTLIGHT|fn.SHADERDEFINE_DIRECTIONLIGHT):this._addDisablePublicShaderDefine(fn.SHADERDEFINE_POINTLIGHT|fn.SHADERDEFINE_SPOTLIGHT|fn.SHADERDEFINE_DIRECTIONLIGHT),this._enableLighting=e)}),l(0,n,"glowingEdgeColor",function(){return this._getColor(12)},function(e){this._setColor(12,e)}),l(0,n,"enableGlowingEdge",null,function(e){e?this._addShaderDefine(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_GLOWINGEDGE):this._removeShaderDefine(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_GLOWINGEDGE)}),t.__init__=function(){t.SHADERDEFINE_DIFFUSEMAP=t.shaderDefines.registerDefine("DIFFUSEMAP"),t.SHADERDEFINE_NORMALMAP=t.shaderDefines.registerDefine("NORMALMAP"),t.SHADERDEFINE_SPECULARMAP=t.shaderDefines.registerDefine("SPECULARMAP"),t.SHADERDEFINE_REFLECTMAP=t.shaderDefines.registerDefine("REFLECTMAP"),t.SHADERDEFINE_TILINGOFFSET=t.shaderDefines.registerDefine("TILINGOFFSET"),t.SHADERDEFINE_ADDTIVEFOG=t.shaderDefines.registerDefine("ADDTIVEFOG"),t.SHADERDEFINE_GLOWINGEDGE=t.shaderDefines.registerDefine("GLOWINGEDGE")},t.load=function(e){return a.loader.create(e,null,null,t)},t.SPECULARSOURCE_DIFFUSEMAPALPHA=0,t.SPECULARSOURCE_SPECULARMAP=0,t.RENDERMODE_OPAQUE=0,t.RENDERMODE_CUTOUT=1,t.RENDERMODE_TRANSPARENT=2,t.RENDERMODE_ADDTIVE=3,t.SHADERDEFINE_DIFFUSEMAP=0,t.SHADERDEFINE_NORMALMAP=0,t.SHADERDEFINE_SPECULARMAP=0,t.SHADERDEFINE_REFLECTMAP=0,t.SHADERDEFINE_TILINGOFFSET=0,t.SHADERDEFINE_ADDTIVEFOG=0,t.SHADERDEFINE_GLOWINGEDGE=0,t.ALBEDOTEXTURE=1,t.NORMALTEXTURE=2,t.SPECULARTEXTURE=3,t.EMISSIVETEXTURE=4,t.REFLECTTEXTURE=5,t.ALBEDOCOLOR=6,t.MATERIALSPECULAR=8,t.SHININESS=9,t.MATERIALREFLECT=10,t.TILINGOFFSET=11,t.GLOWINGEDGECOLOR=12,o(t,["defaultMaterial",function(){return this.defaultMaterial=new t},"shaderDefines",function(){return this.shaderDefines=new Gt(Dn.shaderDefines)}]),t}(Dn),Wn=function(e){function t(){t.__super.call(this),this.setShaderName("ExtendTerrain"),this.renderMode=1}s(t,"laya.d3.core.material.ExtendTerrainMaterial",Dn);var n=t.prototype;return n._setDetailNum=function(e){switch(e){case 1:this._addShaderDefine(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM1),this._removeShaderDefine(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM2),this._removeShaderDefine(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM3),this._removeShaderDefine(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM4),this._removeShaderDefine(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM5);break;case 2:this._addShaderDefine(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM2),this._removeShaderDefine(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM1),this._removeShaderDefine(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM3),this._removeShaderDefine(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM4),this._removeShaderDefine(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM5);break;case 3:this._addShaderDefine(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM3),this._removeShaderDefine(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM1),this._removeShaderDefine(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM2),this._removeShaderDefine(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM4),this._removeShaderDefine(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM5);break;case 4:this._addShaderDefine(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM4),this._removeShaderDefine(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM1),this._removeShaderDefine(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM2),this._removeShaderDefine(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM3),this._removeShaderDefine(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM5);break;case 5:this._addShaderDefine(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM5),this._removeShaderDefine(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM1),this._removeShaderDefine(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM2),this._removeShaderDefine(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM3),this._removeShaderDefine(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM4)}},n.disableLight=function(){this._addDisablePublicShaderDefine(fn.SHADERDEFINE_POINTLIGHT|fn.SHADERDEFINE_SPOTLIGHT|fn.SHADERDEFINE_DIRECTIONLIGHT)},l(0,n,"diffuseScaleOffset2",null,function(e){this._setColor(7,e)}),l(0,n,"splatAlphaTexture",function(){return this._getTexture(0)},function(e){this._setTexture(0,e)}),l(0,n,"diffuseScaleOffset3",null,function(e){this._setColor(8,e)}),l(0,n,"diffuseTexture1",null,function(e){this._setTexture(1,e),this._setDetailNum(1)}),l(0,n,"renderMode",null,function(e){switch(e){case 1:this.renderQueue=1,this.depthWrite=!0,this.cull=2,this.blend=0,this.depthTest=513;break;case 2:this.renderQueue=1,this.depthWrite=!1,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=771,this.depthTest=515;break;default:throw new Error("ExtendTerrainMaterial:renderMode value error.")}this._conchMaterial&&this._conchMaterial.setRenderMode(e)}),l(0,n,"diffuseTexture2",function(){return this._getTexture(2)},function(e){this._setTexture(2,e),this._setDetailNum(2)}),l(0,n,"diffuseScaleOffset1",null,function(e){this._setColor(6,e)}),l(0,n,"diffuseTexture3",function(){return this._getTexture(3)},function(e){this._setTexture(3,e),this._setDetailNum(3)}),l(0,n,"diffuseTexture4",function(){return this._getTexture(4)},function(e){this._setTexture(4,e),this._setDetailNum(4)}),l(0,n,"diffuseTexture5",function(){return this._getTexture(5)},function(e){this._setTexture(5,e),this._setDetailNum(5)}),l(0,n,"diffuseScaleOffset4",null,function(e){this._setColor(9,e)}),l(0,n,"diffuseScaleOffset5",null,function(e){this._setColor(10,e)}),l(0,n,"albedo",function(){return this._getColor(14)},function(e){this._setColor(14,e)}),l(0,n,"ambientColor",function(){return this._getColor(11)},function(e){this._setColor(11,e)}),l(0,n,"diffuseColor",function(){return this._getColor(12)},function(e){this._setColor(12,e)}),l(0,n,"specularColor",function(){return this._getColor(13)},function(e){this._setColor(13,e)}),t.__init__=function(){t.SHADERDEFINE_DETAIL_NUM1=t.shaderDefines.registerDefine("ExtendTerrain_DETAIL_NUM1"),t.SHADERDEFINE_DETAIL_NUM2=t.shaderDefines.registerDefine("ExtendTerrain_DETAIL_NUM2"),t.SHADERDEFINE_DETAIL_NUM3=t.shaderDefines.registerDefine("ExtendTerrain_DETAIL_NUM3"),t.SHADERDEFINE_DETAIL_NUM4=t.shaderDefines.registerDefine("ExtendTerrain_DETAIL_NUM4"),t.SHADERDEFINE_DETAIL_NUM5=t.shaderDefines.registerDefine("ExtendTerrain_DETAIL_NUM5")},t.RENDERMODE_OPAQUE=1,t.RENDERMODE_TRANSPARENT=2,t.SPLATALPHATEXTURE=0,t.DIFFUSETEXTURE1=1,t.DIFFUSETEXTURE2=2,t.DIFFUSETEXTURE3=3,t.DIFFUSETEXTURE4=4,t.DIFFUSETEXTURE5=5,t.DIFFUSESCALEOFFSET1=6,t.DIFFUSESCALEOFFSET2=7,t.DIFFUSESCALEOFFSET3=8,t.DIFFUSESCALEOFFSET4=9,t.DIFFUSESCALEOFFSET5=10,t.MATERIALAMBIENT=11,t.MATERIALDIFFUSE=12,t.MATERIALSPECULAR=13,t.MATERIALALBEDO=14,t.SHADERDEFINE_DETAIL_NUM1=0,t.SHADERDEFINE_DETAIL_NUM2=0,t.SHADERDEFINE_DETAIL_NUM3=0,t.SHADERDEFINE_DETAIL_NUM4=0,t.SHADERDEFINE_DETAIL_NUM5=0,o(t,["shaderDefines",function(){return this.shaderDefines=new Gt(Dn.shaderDefines)}]),t}(),kn=function(e){function t(){t.__super.call(this),this.setShaderName("GLITTER"),this.renderMode=1,this._setColor(3,new Ft(1,1,1,1)),this._setColor(2,new Ft(1,1,1,1))}s(t,"laya.d3.core.material.GlitterMaterial",e);var n=t.prototype;return n.setShaderName=function(t){e.prototype.setShaderName.call(this,t)},l(0,n,"renderMode",null,function(e){switch(e){case 1:this.renderQueue=1,this.depthWrite=!0,this.cull=2,this.blend=0;break;case 2:this.renderQueue=1,this.depthWrite=!0,this.cull=0,this.blend=0;break;case 13:this.renderQueue=2,this.depthWrite=!0,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=771;break;case 14:this.renderQueue=2,this.depthWrite=!0,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=771;break;case 15:this.renderQueue=2,this.depthWrite=!0,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=1;break;case 16:this.renderQueue=2,this.depthWrite=!0,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=1;break;case 5:this.renderQueue=2,this.depthWrite=!1,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=771;break;case 6:this.renderQueue=2,this.depthWrite=!1,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=771;break;case 7:this.renderQueue=2,this.depthWrite=!1,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=1;break;case 8:this.renderQueue=2,this.depthWrite=!1,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=1;break;case 9:this.renderQueue=2,this.depthTest=513,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=771;break;case 10:this.renderQueue=2,this.depthTest=513,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=771;break;case 11:this.renderQueue=2,this.depthTest=513,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=1;break;case 12:this.renderQueue=2,this.depthTest=513,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=1;break;default:throw new Error("Material:renderMode value error.")}this._conchMaterial&&this._conchMaterial.setRenderMode(e)}),l(0,n,"diffuseTexture",function(){return this._getTexture(1)},function(e){this._setTexture(1,e)}),l(0,n,"albedo",function(){return this._getColor(2)},function(e){this._setColor(2,e)}),l(0,n,"color",function(){return this._getColor(3)},function(e){this._setColor(3,e)}),t.load=function(e){return a.loader.create(e,null,null,t)},t.RENDERMODE_OPAQUE=1,t.RENDERMODE_OPAQUEDOUBLEFACE=2,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.DIFFUSETEXTURE=1,t.ALBEDO=2,t.UNICOLOR=3,o(t,["defaultMaterial",function(){return this.defaultMaterial=new t}]),t}(Dn),Xn=function(e){function t(){if(this._transformUV=null,t.__super.call(this),!laya.d3.core.material.PBRMaterial.pbrlutTex){var e=m.window.__pbrlutdata;if(!e)throw alert("no pbr lutdata, need pbrlut.js"),"no pbr lutdata, need pbrlut.js";var n=ai.create(new Uint32Array(e).buffer,256,256,9728,9728,!1);laya.d3.core.material.PBRMaterial.pbrlutTex=n}this._setTexture(4,laya.d3.core.material.PBRMaterial.pbrlutTex),this.setShaderName("PBR"),this._setNumber(0,.5),this.use_groundtruth=!1}s(t,"laya.d3.core.material.PBRMaterial",e);var n=t.prototype;return n.disableLight=function(){this._addDisablePublicShaderDefine(fn.SHADERDEFINE_POINTLIGHT|fn.SHADERDEFINE_SPOTLIGHT|fn.SHADERDEFINE_DIRECTIONLIGHT)},n.disableFog=function(){this._addDisablePublicShaderDefine(fn.SHADERDEFINE_FOG)},n.onAsynLoaded=function(t,n,i){e.prototype.onAsynLoaded.call(this,t,n,i)},n.radicalInverse_VdC=function(e){var t=new Uint32Array(1);return function(e){return e=(16711935&(e=(252645135&(e=(858993459&(e=(1431655765&(e=e<<16|e>>>16))<<1|(2863311530&e)>>>1))<<2|(3435973836&e)>>>2))<<4|(4042322160&e)>>>4))<<8|(4278255360&e)>>>8,t[0]=e,2.3283064365386963e-10*t[0]}(e)},n.createHammersleyTex=function(e,t){var n=new Uint8Array(e*t*4),i=0,r=0;for(r=0;r<e*t;r++){var a=this.radicalInverse_VdC(r);n[i++]=255*a,n[i++]=0,n[i++]=0,n[i++]=255}return n},l(0,n,"normalTexture",function(){return this._getTexture(2)},function(e){this._setTexture(2,e)}),l(0,n,"has_tangent",null,function(e){this._addShaderDefine(t.SHADERDEFINE_HAS_TANGENT)}),l(0,n,"roughness",function(){return this._getNumber(6)},function(e){this._setNumber(6,e),this._addShaderDefine(t.SHADERDEFINE_FIX_ROUGHNESS)}),l(0,n,"metaless",function(){return this._getNumber(7)},function(e){this._setNumber(7,e),this._addShaderDefine(t.SHADERDEFINE_FIX_METALESS)}),l(0,n,"pbrlutTexture",function(){return this._getTexture(4)},function(e){this._setTexture(4,e)}),l(0,n,"use_groundtruth",null,function(e){if(e){if(this._addShaderDefine(t.SHADERDEFINE_USE_GROUNDTRUTH),!laya.d3.core.material.PBRMaterial.HammersleyNoiseTex){var n=this.createHammersleyTex(32,32);laya.d3.core.material.PBRMaterial.HammersleyNoiseTex=ai.create(n.buffer,32,32,9728,9728,!1)}this._setTexture(15,t.HammersleyNoiseTex)}else laya.d3.core.material.PBRMaterial.HammersleyNoiseTex=null,this._removeShaderDefine(t.SHADERDEFINE_USE_GROUNDTRUTH)}),l(0,n,"transformUV",function(){return this._transformUV},function(e){this._transformUV=e,this._setMatrix4x4(8,e.matrix),this._conchMaterial&&this._conchMaterial.setShaderValue(8,e.matrix.elements,0)}),l(0,n,"diffuseTexture",function(){return this._getTexture(1)},function(e){this._setTexture(1,e)}),l(0,n,"renderMode",null,function(e){switch(e){case 1:this.renderQueue=1,this.depthWrite=!0,this.cull=2,this.blend=0,this.alphaTest=!1;break;case 2:this.renderQueue=1,this.depthWrite=!0,this.cull=0,this.blend=0,this.alphaTest=!1;break;case 3:this.depthWrite=!0,this.cull=2,this.blend=0,this.renderQueue=1;break;case 13:this.renderQueue=2,this.depthWrite=!0,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=771;break;default:throw new Error("PBRMaterial:renderMode value error.")}}),l(0,n,"pbrInfoTexture",function(){return this._getTexture(3)},function(e){this._setTexture(3,e),this._addShaderDefine(t.SHADERDEFINE_HAS_PBRINFO)}),l(0,n,"testClipZ",null,function(e){this._addShaderDefine(t.SHADERDEFINE_TEST_CLIPZ)}),t.__init__=function(){t.SHADERDEFINE_FIX_METALESS=t.shaderDefines.registerDefine("FIX_METALESS"),t.SHADERDEFINE_FIX_ROUGHNESS=t.shaderDefines.registerDefine("FIX_ROUGHNESS"),t.SHADERDEFINE_HAS_TANGENT=t.shaderDefines.registerDefine("HAS_TANGENT"),t.SHADERDEFINE_HAS_PBRINFO=t.shaderDefines.registerDefine("HAS_PBRINFO"),t.SHADERDEFINE_USE_GROUNDTRUTH=t.shaderDefines.registerDefine("USE_GROUNDTRUTH"),t.SHADERDEFINE_TEST_CLIPZ=t.shaderDefines.registerDefine("CLIPZ")},t.load=function(e){return a.loader.create(e,null,null,t)},t.DIFFUSETEXTURE=1,t.NORMALTEXTURE=2,t.PBRINFOTEXTURE=3,t.PBRLUTTEXTURE=4,t.UVANIAGE=5,t.MATERIALROUGHNESS=6,t.MATERIALMETALESS=7,t.UVMATRIX=8,t.UVAGE=9,t.AOOBJPOS=14,t.HSNOISETEXTURE=15,t.SHADERDEFINE_FIX_ROUGHNESS=0,t.SHADERDEFINE_FIX_METALESS=0,t.SHADERDEFINE_HAS_TANGENT=0,t.SHADERDEFINE_TEST_CLIPZ=0,t.SHADERDEFINE_HAS_PBRINFO=0,t.SHADERDEFINE_USE_GROUNDTRUTH=0,t.RENDERMODE_OPAQUE=1,t.RENDERMODE_OPAQUEDOUBLEFACE=2,t.RENDERMODE_CUTOUT=3,t.RENDERMODE_CUTOUTDOUBLEFACE=4,t.RENDERMODE_TRANSPARENT=13,t.pbrlutTex=null,t.HammersleyNoiseTex=null,o(t,["defaultMaterial",function(){return this.defaultMaterial=new t},"shaderDefines",function(){return this.shaderDefines=new Gt(Dn.shaderDefines)}]),t}(Dn),Zn=function(e){function t(){t.__super.call(this),this.setShaderName("PBRSpecular"),this._setColor(7,new Ft(1,1,1,1)),this._setColor(9,new Ft(0,0,0,0)),this._setColor(8,new Ft(.2,.2,.2,.2)),this._setNumber(10,.5),this._setNumber(11,1),this._setNumber(12,0),this._setNumber(13,1),this._setNumber(14,1),this._setNumber(15,.001),this._setBool(16,!1),this._setNumber(0,.5)}s(t,"laya.d3.core.material.PBRSpecularMaterial",Dn);var n=t.prototype;return l(0,n,"albedoColor",function(){return this._getColor(7)},function(e){this._setColor(7,e)}),l(0,n,"specularTexture",function(){return this._getTexture(2)},function(e){e?this._addShaderDefine(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_SPECULARTEXTURE):this._removeShaderDefine(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_SPECULARTEXTURE),this._setTexture(2,e)}),l(0,n,"albedoTexture",function(){return this._getTexture(1)},function(e){e?this._addShaderDefine(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_DIFFUSETEXTURE):this._removeShaderDefine(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_DIFFUSETEXTURE),this._setTexture(1,e)}),l(0,n,"occlusionTexture",function(){return this._getTexture(5)},function(e){e?this._addShaderDefine(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_OCCLUSIONTEXTURE):this._removeShaderDefine(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_OCCLUSIONTEXTURE),this._setTexture(5,e)}),l(0,n,"normalTexture",function(){return this._getTexture(3)},function(e){e?this._addShaderDefine(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_NORMALTEXTURE):this._removeShaderDefine(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_NORMALTEXTURE),this._setTexture(3,e)}),l(0,n,"parallaxTexture",function(){return this._getTexture(4)},function(e){e?this._addShaderDefine(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_PARALLAXTEXTURE):this._removeShaderDefine(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_PARALLAXTEXTURE),this._setTexture(4,e)}),l(0,n,"emissionColor",function(){return this._getColor(9)},function(e){this._setColor(9,e)}),l(0,n,"normalTextureScale",function(){return this._getNumber(14)},function(e){this._setNumber(14,e)}),l(0,n,"parallaxTextureScale",function(){return this._getNumber(15)},function(e){e=Math.max(.005,Math.min(.08,e)),this._setNumber(15,e)}),l(0,n,"occlusionTextureStrength",function(){return this._getNumber(13)},function(e){e=Math.max(0,Math.min(1,e)),this._setNumber(13,e)}),l(0,n,"specularColor",function(){return this._getColor(8)},function(e){this._setColor(8,e)}),l(0,n,"smoothness",function(){return this._getNumber(10)},function(e){e=Math.max(0,Math.min(1,e)),this._setNumber(10,e)}),l(0,n,"smoothnessTextureScale",function(){return this._getNumber(11)},function(e){e=Math.max(0,Math.min(1,e)),this._setNumber(11,e)}),l(0,n,"smoothnessSource",function(){return this._getNumber(12)},function(e){1==e?this._addShaderDefine(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA):(this._removeShaderDefine(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA),e=0),this._setNumber(12,e)}),l(0,n,"enableEmission",function(){return this._getBool(16)},function(e){e?this._addShaderDefine(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_EMISSION):this._removeShaderDefine(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_EMISSION),this._setBool(16,e)}),l(0,n,"emissionTexture",function(){return this._getTexture(6)},function(e){e?this._addShaderDefine(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_EMISSIONTEXTURE):this._removeShaderDefine(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_EMISSIONTEXTURE),this._setTexture(6,e)}),l(0,n,"tilingOffset",function(){return this._getColor(17)},function(e){if(e){var t=e.elements;1!=t[0]||1!=t[1]||0!=t[2]||0!=t[3]?this._addShaderDefine(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_TILINGOFFSET):this._removeShaderDefine(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_TILINGOFFSET)}else this._removeShaderDefine(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_TILINGOFFSET);this._setColor(17,e)}),t.__init__=function(){t.SHADERDEFINE_DIFFUSETEXTURE=t.shaderDefines.registerDefine("DIFFUSETEXTURE"),t.SHADERDEFINE_SPECULARTEXTURE=t.shaderDefines.registerDefine("SPECULARTEXTURE"),t.SHADERDEFINE_SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA=t.shaderDefines.registerDefine("SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA"),t.SHADERDEFINE_NORMALTEXTURE=t.shaderDefines.registerDefine("NORMALTEXTURE"),t.SHADERDEFINE_PARALLAXTEXTURE=t.shaderDefines.registerDefine("PARALLAXTEXTURE"),t.SHADERDEFINE_OCCLUSIONTEXTURE=t.shaderDefines.registerDefine("OCCLUSIONTEXTURE"),t.SHADERDEFINE_EMISSION=t.shaderDefines.registerDefine("EMISSION"),t.SHADERDEFINE_EMISSIONTEXTURE=t.shaderDefines.registerDefine("EMISSIONTEXTURE"),t.SHADERDEFINE_TILINGOFFSET=t.shaderDefines.registerDefine("TILINGOFFSET")},t.SmoothnessSource_MetallicGlossTexture_Alpha=0,t.SmoothnessSource_DiffuseTexture_Alpha=1,t.SHADERDEFINE_DIFFUSETEXTURE=0,t.SHADERDEFINE_NORMALTEXTURE=0,t.SHADERDEFINE_SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA=0,t.SHADERDEFINE_SPECULARTEXTURE=0,t.SHADERDEFINE_OCCLUSIONTEXTURE=0,t.SHADERDEFINE_PARALLAXTEXTURE=0,t.SHADERDEFINE_EMISSION=0,t.SHADERDEFINE_EMISSIONTEXTURE=0,t.SHADERDEFINE_TILINGOFFSET=0,t.DIFFUSETEXTURE=1,t.SPECULARTEXTURE=2,t.NORMALTEXTURE=3,t.PARALLAXTEXTURE=4,t.OCCLUSIONTEXTURE=5,t.EMISSIONTEXTURE=6,t.DIFFUSECOLOR=7,t.SPECULARCOLOR=8,t.EMISSIONCOLOR=9,t.SMOOTHNESS=10,t.SMOOTHNESSSCALE=11,t.SMOOTHNESSSOURCE=12,t.OCCLUSIONSTRENGTH=13,t.NORMALSCALE=14,t.PARALLAXSCALE=15,t.ENABLEEMISSION=16,t.TILINGOFFSET=17,o(t,["shaderDefines",function(){return this.shaderDefines=new Gt(Dn.shaderDefines)}]),t}(),Yn=function(e){function t(){t.__super.call(this),this.setShaderName("PBRStandard"),this._setColor(7,new Ft(1,1,1,1)),this._setColor(8,new Ft(0,0,0,0)),this._setNumber(9,0),this._setNumber(10,.5),this._setNumber(11,1),this._setNumber(12,0),this._setNumber(13,1),this._setNumber(14,1),this._setNumber(15,.001),this._setBool(16,!1),this._setNumber(0,.5)}s(t,"laya.d3.core.material.PBRStandardMaterial",Dn);var n=t.prototype;return l(0,n,"albedoColor",function(){return this._getColor(7)},function(e){this._setColor(7,e)}),l(0,n,"albedoTexture",function(){return this._getTexture(1)},function(e){e?this._addShaderDefine(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_DIFFUSETEXTURE):this._removeShaderDefine(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_DIFFUSETEXTURE),this._setTexture(1,e)}),l(0,n,"enableEmission",function(){return this._getBool(16)},function(e){e?this._addShaderDefine(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_EMISSION):this._removeShaderDefine(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_EMISSION),this._setBool(16,e)}),l(0,n,"metallicGlossTexture",function(){return this._getTexture(2)},function(e){e?this._addShaderDefine(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_METALLICGLOSSTEXTURE):this._removeShaderDefine(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_METALLICGLOSSTEXTURE),this._setTexture(2,e)}),l(0,n,"occlusionTexture",function(){return this._getTexture(5)},function(e){e?this._addShaderDefine(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_OCCLUSIONTEXTURE):this._removeShaderDefine(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_OCCLUSIONTEXTURE),this._setTexture(5,e)}),l(0,n,"normalTexture",function(){return this._getTexture(3)},function(e){e?this._addShaderDefine(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_NORMALTEXTURE):this._removeShaderDefine(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_NORMALTEXTURE),this._setTexture(3,e)}),l(0,n,"parallaxTexture",function(){return this._getTexture(4)},function(e){e?this._addShaderDefine(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_PARALLAXTEXTURE):this._removeShaderDefine(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_PARALLAXTEXTURE),this._setTexture(4,e)}),l(0,n,"emissionColor",function(){return this._getColor(8)},function(e){this._setColor(8,e)}),l(0,n,"normalTextureScale",function(){return this._getNumber(14)},function(e){this._setNumber(14,e)}),l(0,n,"parallaxTextureScale",function(){return this._getNumber(15)},function(e){e=Math.max(.005,Math.min(.08,e)),this._setNumber(15,e)}),l(0,n,"occlusionTextureStrength",function(){return this._getNumber(13)},function(e){e=Math.max(0,Math.min(1,e)),this._setNumber(13,e)}),l(0,n,"metallic",function(){return this._getNumber(9)},function(e){e=Math.max(0,Math.min(1,e)),this._setNumber(9,e)}),l(0,n,"smoothness",function(){return this._getNumber(10)},function(e){e=Math.max(0,Math.min(1,e)),this._setNumber(10,e)}),l(0,n,"smoothnessTextureScale",function(){return this._getNumber(11)},function(e){e=Math.max(0,Math.min(1,e)),this._setNumber(11,e)}),l(0,n,"smoothnessSource",function(){return this._getNumber(12)},function(e){1==e?this._addShaderDefine(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA):(this._removeShaderDefine(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA),e=0),this._setNumber(12,e)}),l(0,n,"emissionTexture",function(){return this._getTexture(6)},function(e){e?this._addShaderDefine(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_EMISSIONTEXTURE):this._removeShaderDefine(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_EMISSIONTEXTURE),this._setTexture(6,e)}),l(0,n,"tilingOffset",function(){return this._getColor(17)},function(e){if(e){var t=e.elements;1!=t[0]||1!=t[1]||0!=t[2]||0!=t[3]?this._addShaderDefine(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_TILINGOFFSET):this._removeShaderDefine(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_TILINGOFFSET)}else this._removeShaderDefine(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_TILINGOFFSET);this._setColor(17,e)}),t.__init__=function(){t.SHADERDEFINE_DIFFUSETEXTURE=t.shaderDefines.registerDefine("DIFFUSETEXTURE"),t.SHADERDEFINE_METALLICGLOSSTEXTURE=t.shaderDefines.registerDefine("METALLICGLOSSTEXTURE"),t.SHADERDEFINE_SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA=t.shaderDefines.registerDefine("SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA"),t.SHADERDEFINE_NORMALTEXTURE=t.shaderDefines.registerDefine("NORMALTEXTURE"),t.SHADERDEFINE_PARALLAXTEXTURE=t.shaderDefines.registerDefine("PARALLAXTEXTURE"),t.SHADERDEFINE_OCCLUSIONTEXTURE=t.shaderDefines.registerDefine("OCCLUSIONTEXTURE"),t.SHADERDEFINE_EMISSION=t.shaderDefines.registerDefine("EMISSION"),t.SHADERDEFINE_EMISSIONTEXTURE=t.shaderDefines.registerDefine("EMISSIONTEXTURE"),t.SHADERDEFINE_TILINGOFFSET=t.shaderDefines.registerDefine("TILINGOFFSET")},t.SmoothnessSource_MetallicGlossTexture_Alpha=0,t.SmoothnessSource_DiffuseTexture_Alpha=1,t.SHADERDEFINE_DIFFUSETEXTURE=0,t.SHADERDEFINE_NORMALTEXTURE=0,t.SHADERDEFINE_SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA=0,t.SHADERDEFINE_METALLICGLOSSTEXTURE=0,t.SHADERDEFINE_OCCLUSIONTEXTURE=0,t.SHADERDEFINE_PARALLAXTEXTURE=0,t.SHADERDEFINE_EMISSION=0,t.SHADERDEFINE_EMISSIONTEXTURE=0,t.SHADERDEFINE_TILINGOFFSET=0,t.DIFFUSETEXTURE=1,t.METALLICGLOSSTEXTURE=2,t.NORMALTEXTURE=3,t.PARALLAXTEXTURE=4,t.OCCLUSIONTEXTURE=5,t.EMISSIONTEXTURE=6,t.DIFFUSECOLOR=7,t.EMISSIONCOLOR=8,t.METALLIC=9,t.SMOOTHNESS=10,t.SMOOTHNESSSCALE=11,t.SMOOTHNESSSOURCE=12,t.OCCLUSIONSTRENGTH=13,t.NORMALSCALE=14,t.PARALLAXSCALE=15,t.ENABLEEMISSION=16,t.TILINGOFFSET=17,o(t,["shaderDefines",function(){return this.shaderDefines=new Gt(Dn.shaderDefines)}]),t}(),jn=function(e){function t(){this._transformUV=null,t.__super.call(this),this.setShaderName("SIMPLE"),this._setColor(9,new bt(.6,.6,.6)),this._setColor(10,new bt(1,1,1)),this._setColor(11,new Ft(1,1,1,8)),this._setColor(12,new bt(1,1,1)),this._setColor(7,new Ft(1,1,1,1)),this._setNumber(0,.5),this._setColor(15,new Ft(1,1,0,0)),this.renderMode=1}s(t,"laya.d3.core.material.StandardMaterial",e);var n=t.prototype;return n.disableLight=function(){this._addDisablePublicShaderDefine(fn.SHADERDEFINE_POINTLIGHT|fn.SHADERDEFINE_SPOTLIGHT|fn.SHADERDEFINE_DIRECTIONLIGHT)},n.disableFog=function(){this._addDisablePublicShaderDefine(fn.SHADERDEFINE_FOG)},n.onAsynLoaded=function(n,i,r){var a=i[0];if(a.version)e.prototype.onAsynLoaded.call(this,n,i,r);else{var o=i[1],s=a.props;for(var l in s)this[l]=s[l];t._parseStandardMaterial(o,this,a),this._endLoaded()}},n.cloneTo=function(t){e.prototype.cloneTo.call(this,t);var n=t;this._transformUV&&(n._transformUV=this._transformUV.clone())},l(0,n,"ambientColor",function(){return this._getColor(9)},function(e){this._setColor(9,e)}),l(0,n,"ambientTexture",function(){return this._getTexture(5)},function(e){e?this._addShaderDefine(laya.d3.core.material.StandardMaterial.SHADERDEFINE_AMBIENTMAP):this._removeShaderDefine(laya.d3.core.material.StandardMaterial.SHADERDEFINE_AMBIENTMAP),this._setTexture(5,e)}),l(0,n,"renderMode",null,function(e){switch(e){case 1:this.renderQueue=1,this.depthWrite=!0,this.cull=2,this.blend=0,this.alphaTest=!1,this._removeShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 2:this.renderQueue=1,this.depthWrite=!0,this.cull=0,this.blend=0,this.alphaTest=!1,this._removeShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 3:this.depthWrite=!0,this.cull=2,this.blend=0,this.renderQueue=1,this.alphaTest=!0,this._removeShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 4:this.renderQueue=1,this.depthWrite=!0,this.cull=0,this.blend=0,this.alphaTest=!0,this._removeShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 13:this.renderQueue=2,this.depthWrite=!0,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=771,this.alphaTest=!1,this._removeShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 14:this.renderQueue=2,this.depthWrite=!0,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=771,this.alphaTest=!1,this._removeShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 15:this.renderQueue=2,this.depthWrite=!0,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=1,this.alphaTest=!1,this._addShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 16:this.renderQueue=2,this.depthWrite=!0,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=1,this.alphaTest=!1,this._addShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 5:this.renderQueue=2,this.depthWrite=!1,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=771,this.alphaTest=!1,this._removeShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 6:this.renderQueue=2,this.depthWrite=!1,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=771,this.alphaTest=!1,this._removeShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 7:this.renderQueue=2,this.depthWrite=!1,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=1,this.alphaTest=!1,this._addShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 8:this.renderQueue=2,this.depthWrite=!1,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=1,this.alphaTest=!1,this._addShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 9:this.renderQueue=2,this.depthTest=513,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=771,this.alphaTest=!1,this._removeShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 10:this.renderQueue=2,this.depthTest=513,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=771,this.alphaTest=!1,this._removeShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 11:this.renderQueue=2,this.depthTest=513,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=1,this.alphaTest=!1,this._addShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 12:this.renderQueue=2,this.depthTest=513,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=1,this.alphaTest=!1,this._addShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;default:throw new Error("Material:renderMode value error.")}this._conchMaterial&&this._conchMaterial.setRenderMode(e)}),l(0,n,"reflectColor",function(){return this._getColor(12)},function(e){this._setColor(12,e)}),l(0,n,"tilingOffset",function(){return this._getColor(15)},function(e){if(e){var t=e.elements;1!=t[0]||1!=t[1]||0!=t[2]||0!=t[3]?this._addShaderDefine(laya.d3.core.material.StandardMaterial.SHADERDEFINE_TILINGOFFSET):this._removeShaderDefine(laya.d3.core.material.StandardMaterial.SHADERDEFINE_TILINGOFFSET)}else this._removeShaderDefine(laya.d3.core.material.StandardMaterial.SHADERDEFINE_TILINGOFFSET);this._setColor(15,e)}),l(0,n,"albedo",function(){return this._getColor(7)},function(e){this._setColor(7,e)}),l(0,n,"diffuseColor",function(){return this._getColor(10)},function(e){this._setColor(10,e)}),l(0,n,"albedoColor",function(){return this._getColor(7)},function(e){this._setColor(7,e)}),l(0,n,"specularColor",function(){return this._getColor(11)},function(e){this._setColor(11,e)}),l(0,n,"diffuseTexture",function(){return this._getTexture(1)},function(e){e?this._addShaderDefine(laya.d3.core.material.StandardMaterial.SHADERDEFINE_DIFFUSEMAP):this._removeShaderDefine(laya.d3.core.material.StandardMaterial.SHADERDEFINE_DIFFUSEMAP),this._setTexture(1,e)}),l(0,n,"normalTexture",function(){return this._getTexture(2)},function(e){e?this._addShaderDefine(laya.d3.core.material.StandardMaterial.SHADERDEFINE_NORMALMAP):this._removeShaderDefine(laya.d3.core.material.StandardMaterial.SHADERDEFINE_NORMALMAP),this._setTexture(2,e)}),l(0,n,"specularTexture",function(){return this._getTexture(3)},function(e){e?this._addShaderDefine(laya.d3.core.material.StandardMaterial.SHADERDEFINE_SPECULARMAP):this._removeShaderDefine(laya.d3.core.material.StandardMaterial.SHADERDEFINE_SPECULARMAP),this._setTexture(3,e)}),l(0,n,"emissiveTexture",function(){return this._getTexture(4)},function(e){e?this._addShaderDefine(laya.d3.core.material.StandardMaterial.SHADERDEFINE_EMISSIVEMAP):this._removeShaderDefine(laya.d3.core.material.StandardMaterial.SHADERDEFINE_EMISSIVEMAP),this._setTexture(4,e)}),l(0,n,"reflectTexture",function(){return this._getTexture(6)},function(e){e?this._addShaderDefine(laya.d3.core.material.StandardMaterial.SHADERDEFINE_REFLECTMAP):this._removeShaderDefine(laya.d3.core.material.StandardMaterial.SHADERDEFINE_REFLECTMAP),this._setTexture(6,e)}),l(0,n,"transformUV",function(){return this._transformUV},function(e){this._transformUV=e,this._setMatrix4x4(13,e.matrix),e?this._addShaderDefine(laya.d3.core.material.StandardMaterial.SHADERDEFINE_UVTRANSFORM):this._removeShaderDefine(laya.d3.core.material.StandardMaterial.SHADERDEFINE_UVTRANSFORM),this._conchMaterial&&this._conchMaterial.setShaderValue(13,e.matrix.elements,0)}),t.__init__=function(){t.SHADERDEFINE_DIFFUSEMAP=t.shaderDefines.registerDefine("DIFFUSEMAP"),t.SHADERDEFINE_NORMALMAP=t.shaderDefines.registerDefine("NORMALMAP"),t.SHADERDEFINE_SPECULARMAP=t.shaderDefines.registerDefine("SPECULARMAP"),t.SHADERDEFINE_EMISSIVEMAP=t.shaderDefines.registerDefine("EMISSIVEMAP"),t.SHADERDEFINE_AMBIENTMAP=t.shaderDefines.registerDefine("AMBIENTMAP"),t.SHADERDEFINE_REFLECTMAP=t.shaderDefines.registerDefine("REFLECTMAP"),t.SHADERDEFINE_UVTRANSFORM=t.shaderDefines.registerDefine("UVTRANSFORM"),t.SHADERDEFINE_TILINGOFFSET=t.shaderDefines.registerDefine("TILINGOFFSET"),t.SHADERDEFINE_ADDTIVEFOG=t.shaderDefines.registerDefine("ADDTIVEFOG")},t.load=function(e){return a.loader.create(e,null,null,t)},t._parseStandardMaterial=function(e,t,n){var i=n.customProps,r=i.ambientColor;t.ambientColor=new bt(r[0],r[1],r[2]);var a=i.diffuseColor;t.diffuseColor=new bt(a[0],a[1],a[2]);var o=i.specularColor;t.specularColor=new Ft(o[0],o[1],o[2],o[3]);var s=i.reflectColor;t.reflectColor=new bt(s[0],s[1],s[2]);var l=i.albedoColor;l&&(t.albedo=new Ft(l[0],l[1],l[2],l[3]));var h=i.diffuseTexture.texture2D;h&&(t.diffuseTexture=S.getRes(e[h]));var _=i.normalTexture.texture2D;_&&(t.normalTexture=S.getRes(e[_]));var u=i.specularTexture.texture2D;u&&(t.specularTexture=S.getRes(e[u]));var c=i.emissiveTexture.texture2D;c&&(t.emissiveTexture=S.getRes(e[c]));var d=i.ambientTexture.texture2D;d&&(t.ambientTexture=S.getRes(e[d]));var f=i.reflectTexture.texture2D;f&&(t.reflectTexture=S.getRes(e[f]))},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.SHADERDEFINE_DIFFUSEMAP=0,t.SHADERDEFINE_NORMALMAP=0,t.SHADERDEFINE_SPECULARMAP=0,t.SHADERDEFINE_EMISSIVEMAP=0,t.SHADERDEFINE_AMBIENTMAP=0,t.SHADERDEFINE_REFLECTMAP=0,t.SHADERDEFINE_UVTRANSFORM=0,t.SHADERDEFINE_TILINGOFFSET=0,t.SHADERDEFINE_ADDTIVEFOG=0,t.DIFFUSETEXTURE=1,t.NORMALTEXTURE=2,t.SPECULARTEXTURE=3,t.EMISSIVETEXTURE=4,t.AMBIENTTEXTURE=5,t.REFLECTTEXTURE=6,t.ALBEDO=7,t.UVANIAGE=8,t.MATERIALAMBIENT=9,t.MATERIALDIFFUSE=10,t.MATERIALSPECULAR=11,t.MATERIALREFLECT=12,t.UVMATRIX=13,t.UVAGE=14,t.TILINGOFFSET=15,o(t,["defaultMaterial",function(){return this.defaultMaterial=new t},"shaderDefines",function(){return this.shaderDefines=new Gt(Dn.shaderDefines)}]),t}(Dn),Kn=function(e){function t(){this._diffuseScale1=null,this._diffuseScale2=null,this._diffuseScale3=null,this._diffuseScale4=null,t.__super.call(this),this.setShaderName("Terrain"),this.renderMode=1,this._diffuseScale1=new Lt,this._diffuseScale2=new Lt,this._diffuseScale3=new Lt,this._diffuseScale4=new Lt,this.ambientColor=new bt(.6,.6,.6),this.diffuseColor=new bt(1,1,1),this.specularColor=new Ft(.2,.2,.2,32)}s(t,"laya.d3.core.material.TerrainMaterial",e);var n=t.prototype;return n.setDiffuseScale1=function(e,t){this._diffuseScale1.x=e,this._diffuseScale1.y=t,this._setColor(6,this._diffuseScale1)},n.setDiffuseScale2=function(e,t){this._diffuseScale2.x=e,this._diffuseScale2.y=t,this._setColor(7,this._diffuseScale2)},n.setDiffuseScale3=function(e,t){this._diffuseScale3.x=e,this._diffuseScale3.y=t,this._setColor(8,this._diffuseScale3)},n.setDiffuseScale4=function(e,t){this._diffuseScale4.x=e,this._diffuseScale4.y=t,this._setColor(9,this._diffuseScale4)},n.setDetailNum=function(e){switch(e){case 1:this._addShaderDefine(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM1),this._removeShaderDefine(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM2),this._removeShaderDefine(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM3),this._removeShaderDefine(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM4);break;case 2:this._addShaderDefine(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM2),this._removeShaderDefine(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM1),this._removeShaderDefine(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM3),this._removeShaderDefine(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM4);break;case 3:this._addShaderDefine(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM3),this._removeShaderDefine(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM1),this._removeShaderDefine(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM2),this._removeShaderDefine(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM4);break;case 4:this._addShaderDefine(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM4),this._removeShaderDefine(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM1),this._removeShaderDefine(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM2),this._removeShaderDefine(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM3)}},n.disableLight=function(){this._addDisablePublicShaderDefine(fn.SHADERDEFINE_POINTLIGHT|fn.SHADERDEFINE_SPOTLIGHT|fn.SHADERDEFINE_DIRECTIONLIGHT)},n.setShaderName=function(t){e.prototype.setShaderName.call(this,t)},l(0,n,"renderMode",null,function(e){switch(e){case 1:this.renderQueue=1,this.depthWrite=!0,this.cull=2,this.blend=0,this.depthTest=513;break;case 2:this.renderQueue=1,this.depthWrite=!1,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=771,this.depthTest=515;break;default:throw new Error("TerrainMaterial:renderMode value error.")}this._conchMaterial&&this._conchMaterial.setRenderMode(e)}),l(0,n,"diffuseTexture2",function(){return this._getTexture(3)},function(e){this._setTexture(3,e)}),l(0,n,"ambientColor",function(){return this._getColor(10)},function(e){this._setColor(10,e)}),l(0,n,"diffuseTexture4",function(){return this._getTexture(5)},function(e){this._setTexture(5,e)}),l(0,n,"diffuseColor",function(){return this._getColor(11)},function(e){this._setColor(11,e)}),l(0,n,"diffuseTexture1",function(){return this._getTexture(2)},function(e){this._setTexture(2,e)}),l(0,n,"specularColor",function(){return this._getColor(12)},function(e){this._setColor(12,e)}),l(0,n,"diffuseTexture3",function(){return this._getTexture(4)},function(e){this._setTexture(4,e)}),l(0,n,"splatAlphaTexture",function(){return this._getTexture(0)},function(e){this._setTexture(0,e)}),l(0,n,"normalTexture",function(){return this._getTexture(1)},function(e){this._setTexture(1,e)}),t.__init__=function(){t.SHADERDEFINE_DETAIL_NUM1=t.shaderDefines.registerDefine("DETAIL_NUM1"),t.SHADERDEFINE_DETAIL_NUM2=t.shaderDefines.registerDefine("DETAIL_NUM2"),t.SHADERDEFINE_DETAIL_NUM4=t.shaderDefines.registerDefine("DETAIL_NUM4"),t.SHADERDEFINE_DETAIL_NUM3=t.shaderDefines.registerDefine("DETAIL_NUM3")},t.load=function(e){return a.loader.create(e,null,null,t)},t.RENDERMODE_OPAQUE=1,t.RENDERMODE_TRANSPARENT=2,t.SPLATALPHATEXTURE=0,t.NORMALTEXTURE=1,t.DIFFUSETEXTURE1=2,t.DIFFUSETEXTURE2=3,t.DIFFUSETEXTURE3=4,t.DIFFUSETEXTURE4=5,t.DIFFUSESCALE1=6,t.DIFFUSESCALE2=7,t.DIFFUSESCALE3=8,t.DIFFUSESCALE4=9,t.MATERIALAMBIENT=10,t.MATERIALDIFFUSE=11,t.MATERIALSPECULAR=12,t.SHADERDEFINE_DETAIL_NUM1=0,t.SHADERDEFINE_DETAIL_NUM2=0,t.SHADERDEFINE_DETAIL_NUM3=0,t.SHADERDEFINE_DETAIL_NUM4=0,o(t,["defaultMaterial",function(){return this.defaultMaterial=new t},"shaderDefines",function(){return this.shaderDefines=new Gt(Dn.shaderDefines)}]),t}(Dn),qn=function(e){function t(){this._useVertexDeep=!1,t.__super.call(this),this.setShaderName("Water")}s(t,"laya.d3.core.material.WaterMaterial",e);var n=t.prototype;return n.disableFog=function(){this._addDisablePublicShaderDefine(fn.SHADERDEFINE_FOG)},n.onAsynLoaded=function(t,n,i){e.prototype.onAsynLoaded.call(this,t,n,i)},l(0,n,"diffuseTexture",function(){return this._getTexture(1)},function(e){this._setTexture(1,e)}),l(0,n,"normalTexture",function(){return this._getTexture(2)},function(e){this._setTexture(2,e)}),l(0,n,"underWaterTexture",function(){return this._getTexture(3)},function(e){this._setTexture(3,e)}),l(0,n,"deepColorTexture",function(){return this._getTexture(10)},function(e){this._setTexture(10,e)}),l(0,n,"useFoam",null,function(e){e?this._addShaderDefine(t.SHADERDEFINE_USE_FOAM):this._removeShaderDefine(t.SHADERDEFINE_USE_FOAM)}),l(0,n,"skyTexture",function(){return this._getTexture(11)},function(e){this._setTexture(11,e)}),l(0,n,"deepScale",function(){return this._getNumber(20)},function(e){this._setNumber(20,e)}),l(0,n,"detailTexture",function(){return this._getTexture(9)},function(e){this._setTexture(9,e)}),l(0,n,"foamTexture",function(){return this._getTexture(17)},function(e){this._setTexture(17,e)}),l(0,n,"waterInfoTexture",function(){return this._getTexture(16)},function(e){this._setTexture(16,e)}),l(0,n,"vertexDispTexture",function(){return this._getTexture(4)},function(e){this._setTexture(4,e)}),l(0,n,"currentTm",function(){return this._getNumber(8)},function(e){this._setNumber(8,e)}),l(0,n,"waveInfo",function(){return this._getBuffer(12)},function(e){this._setBuffer(12,e)}),l(0,n,"waveInfoD",function(){return this._getBuffer(13)},function(e){this._setBuffer(13,e)}),l(0,n,"waveMainDir",function(){return this._getNumber(14)},function(e){this._setNumber(14,e*Math.PI/180)}),l(0,n,"geoWaveUVScale",function(){return this._getNumber(18)},function(e){this._setNumber(18,e)}),l(0,n,"windSpeed",function(){return 0},function(e){}),l(0,n,"scrsize",null,function(e){this._setBuffer(15,e)}),l(0,n,"seaColor",function(){return this._getBuffer(19)},function(e){this._setBuffer(19,e)}),l(0,n,"useVertexDeep",function(){return this._useVertexDeep},function(e){this._useVertexDeep=e,e?this._addShaderDefine(t.SHADERDEFINE_USEVERTEXHEIGHT):this._removeShaderDefine(t.SHADERDEFINE_USEVERTEXHEIGHT)}),l(0,n,"windDir",function(){return 0},function(e){}),l(0,n,"useRefractTexture",null,function(e){e?this._addShaderDefine(t.SHADERDEFINE_USE_REFRACT_TEX):this._removeShaderDefine(t.SHADERDEFINE_USE_REFRACT_TEX)}),l(0,n,"renderMode",null,function(e){switch(e){case 1:this.renderQueue=1,this.depthWrite=!0,this.cull=2,this.blend=0,this.alphaTest=!1;break;case 2:this.renderQueue=1,this.depthWrite=!0,this.cull=0,this.blend=0,this.alphaTest=!1;break;case 3:this.depthWrite=!0,this.cull=2,this.blend=0,this.renderQueue=1;break;case 13:this.renderQueue=2,this.depthWrite=!0,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=771;break;default:throw new Error("PBRMaterial:renderMode value error.")}}),t.__init__=function(){t.SHADERDEFINE_CUBE_ENV=t.shaderDefines.registerDefine("CUBE_ENV"),t.SHADERDEFINE_HDR_ENV=t.shaderDefines.registerDefine("HDR_ENV"),t.SHADERDEFINE_SHOW_NORMAL=t.shaderDefines.registerDefine("SHOW_NORMAL"),t.SHADERDEFINE_USEVERTEXHEIGHT=t.shaderDefines.registerDefine("USE_VERTEX_DEEPINFO"),t.SHADERDEFINE_USE_FOAM=t.shaderDefines.registerDefine("USE_FOAM"),t.SHADERDEFINE_USE_REFRACT_TEX=t.shaderDefines.registerDefine("USE_REFR_TEX")},t.load=function(e){return a.loader.create(e,null,null,t)},t.DIFFUSETEXTURE=1,t.NORMALTEXTURE=2,t.UNDERWATERTEXTURE=3,t.VERTEXDISPTEXTURE=4,t.UVANIAGE=5,t.UVMATRIX=6,t.UVAGE=7,t.CURTM=8,t.DETAILTEXTURE=9,t.DEEPCOLORTEXTURE=10,t.SKYTEXTURE=11,t.WAVEINFO=12,t.WAVEINFOD=13,t.WAVEMAINDIR=14,t.SCRSIZE=15,t.WATERINFO=16,t.FOAMTEXTURE=17,t.GEOWAVE_UV_SCALE=18,t.SEA_COLOR=19,t.WAVEINFODEEPSCALE=20,t.SHADERDEFINE_SHOW_NORMAL=0,t.SHADERDEFINE_CUBE_ENV=0,t.SHADERDEFINE_HDR_ENV=0,t.SHADERDEFINE_USE_FOAM=0,t.SHADERDEFINE_USE_REFRACT_TEX=0,t.SHADERDEFINE_USEVERTEXHEIGHT=0,t.RENDERMODE_OPAQUE=1,t.RENDERMODE_OPAQUEDOUBLEFACE=2,t.RENDERMODE_CUTOUT=3,t.RENDERMODE_CUTOUTDOUBLEFACE=4,t.RENDERMODE_TRANSPARENT=13,o(t,["defaultMaterial",function(){return this.defaultMaterial=new t},"shaderDefines",function(){return this.shaderDefines=new Gt(Dn.shaderDefines)}]),t}(Dn),Qn=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;var a;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,this._bind(),p._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}s(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(),p._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 o=0;o<i;o++)this._buffer[t+o]=e[o]}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.disposeResource=function(){e.prototype.disposeResource.call(this),this._buffer=null,this.memorySize=0},l(0,n,"indexType",function(){return this._indexType}),l(0,n,"indexTypeByteCount",function(){return this._indexTypeByteCount}),l(0,n,"indexCount",function(){return this._indexCount}),l(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}(p),$n=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.memorySize=this._byteLength=this._vertexDeclaration.vertexStride*n,this._bind(),p._gl.bufferData(this._bufferType,this._byteLength,this._bufferUsage),r&&(this._buffer=new Float32Array(this._byteLength/4))}s(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(),p._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;a<i;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.disposeResource=function(){for(var t=b.mainContext,n=this._vertexDeclaration.getVertexElements(),i=p._enableAtributes,r=0,a=n.length;r<a;r++)i[r]===this._glBuffer&&(t.disableVertexAttribArray(r),i[r]=null);e.prototype.disposeResource.call(this),this._buffer=null,this._vertexDeclaration=null,this.memorySize=0},l(0,n,"vertexDeclaration",function(){return this._vertexDeclaration}),l(0,n,"vertexCount",function(){return this._vertexCount}),l(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}(p),Jn=function(e){function t(){t.__super.call(this),this.setShaderName("PARTICLESHURIKEN"),this.renderMode=6}s(t,"laya.d3.core.particleShuriKen.ShurikenParticleMaterial",e);var n=t.prototype;return n.onAsynLoaded=function(n,i,r){var a=i[0];if(a.version)e.prototype.onAsynLoaded.call(this,n,i,r);else{var o=i[1],s=a.props;for(var l in s)this[l]=s[l];t._parseShurikenParticleMaterial(o,this,a),this._endLoaded()}},l(0,n,"renderMode",null,function(e){switch(e){case 1:this.renderQueue=1,this.depthWrite=!0,this.cull=2,this.blend=0,this.alphaTest=!1,this._removeShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 2:this.renderQueue=1,this.depthWrite=!0,this.cull=0,this.blend=0,this.alphaTest=!1,this._removeShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 3:this.depthWrite=!0,this.cull=2,this.blend=0,this.renderQueue=1,this.alphaTest=!0,this._removeShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 4:this.renderQueue=1,this.depthWrite=!0,this.cull=0,this.blend=0,this.alphaTest=!0,this._removeShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 13:this.renderQueue=2,this.depthWrite=!0,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=771,this.alphaTest=!1,this._removeShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 14:this.renderQueue=2,this.depthWrite=!0,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=771,this.alphaTest=!1,this._removeShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 15:this.renderQueue=2,this.depthWrite=!0,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=1,this.alphaTest=!1,this._addShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 16:this.renderQueue=2,this.depthWrite=!0,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=1,this.alphaTest=!1,this._addShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 5:this.renderQueue=2,this.depthWrite=!1,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=771,this.alphaTest=!1,this._removeShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 6:this.renderQueue=2,this.depthWrite=!1,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=771,this.alphaTest=!1,this._removeShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 7:this.renderQueue=2,this.depthWrite=!1,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=1,this.alphaTest=!1,this._addShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 8:this.renderQueue=2,this.depthWrite=!1,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=1,this.alphaTest=!1,this._addShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 9:this.renderQueue=2,this.depthTest=513,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=771,this.alphaTest=!1,this._removeShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 10:this.renderQueue=2,this.depthTest=513,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=771,this.alphaTest=!1,this._removeShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 11:this.renderQueue=2,this.depthTest=513,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=1,this.alphaTest=!1,this._addShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;case 12:this.renderQueue=2,this.depthTest=513,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=1,this.alphaTest=!1,this._addShaderDefine(t.SHADERDEFINE_ADDTIVEFOG);break;default:throw new Error("Material:renderMode value error.")}this._conchMaterial&&this._conchMaterial.setRenderMode(e)}),l(0,n,"tintColor",function(){return this._getColor(2)},function(e){e?this._addShaderDefine(laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SHADERDEFINE_TINTCOLOR):this._removeShaderDefine(laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SHADERDEFINE_TINTCOLOR),this._setColor(2,e)}),l(0,n,"tilingOffset",function(){return this._getColor(3)},function(e){if(e){var t=e.elements;1!=t[0]||1!=t[1]||0!=t[2]||0!=t[3]?this._addShaderDefine(laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SHADERDEFINE_TILINGOFFSET):this._removeShaderDefine(laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SHADERDEFINE_TILINGOFFSET)}else this._removeShaderDefine(laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SHADERDEFINE_TILINGOFFSET);this._setColor(3,e)}),l(0,n,"diffuseTexture",function(){return this._getTexture(1)},function(e){e?this._addShaderDefine(laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SHADERDEFINE_DIFFUSEMAP):this._removeShaderDefine(laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SHADERDEFINE_DIFFUSEMAP),this._setTexture(1,e)}),t.__init__=function(){t.SHADERDEFINE_DIFFUSEMAP=t.shaderDefines.registerDefine("DIFFUSEMAP"),t.SHADERDEFINE_TINTCOLOR=t.shaderDefines.registerDefine("TINTCOLOR"),t.SHADERDEFINE_ADDTIVEFOG=t.shaderDefines.registerDefine("ADDTIVEFOG"),t.SHADERDEFINE_TILINGOFFSET=t.shaderDefines.registerDefine("TILINGOFFSET")},t.load=function(e){return a.loader.create(e,null,null,t)},t._parseShurikenParticleMaterial=function(e,t,n){var i=n.customProps,r=i.diffuseTexture.texture2D;r&&(t.diffuseTexture=S.getRes(e[r]));var a=i.tintColor;a&&(t.tintColor=new Ft(a[0],a[1],a[2],a[3]))},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.SHADERDEFINE_DIFFUSEMAP=0,t.SHADERDEFINE_TINTCOLOR=0,t.SHADERDEFINE_TILINGOFFSET=0,t.SHADERDEFINE_ADDTIVEFOG=0,t.DIFFUSETEXTURE=1,t.TINTCOLOR=2,t.TILINGOFFSET=3,o(t,["defaultMaterial",function(){return this.defaultMaterial=new t},"shaderDefines",function(){return this.shaderDefines=new Gt(Dn.shaderDefines)}]),t}(Dn),ei=function(e){function t(){t.__super.call(this),this.setShaderName("Trail"),this._setColor(2,new Ft(1,1,1,1))}s(t,"laya.d3.core.trail.TrailMaterial",Dn);var n=t.prototype;return l(0,n,"tintColor",function(){return this._getColor(2)},function(e){this._setColor(2,e)}),l(0,n,"diffuseTexture",function(){return this._getTexture(1)},function(e){e?this._addShaderDefine(laya.d3.core.trail.TrailMaterial.SHADERDEFINE_DIFFUSETEXTURE):this._removeShaderDefine(laya.d3.core.trail.TrailMaterial.SHADERDEFINE_DIFFUSETEXTURE),this._setTexture(1,e)}),l(0,n,"tilingOffset",function(){return this._getColor(3)},function(e){if(e){var t=e.elements;1!=t[0]||1!=t[1]||0!=t[2]||0!=t[3]?this._addShaderDefine(laya.d3.core.trail.TrailMaterial.SHADERDEFINE_TILINGOFFSET):this._removeShaderDefine(laya.d3.core.trail.TrailMaterial.SHADERDEFINE_TILINGOFFSET)}else this._removeShaderDefine(laya.d3.core.trail.TrailMaterial.SHADERDEFINE_TILINGOFFSET);this._setColor(3,e)}),t.__init__=function(){t.SHADERDEFINE_DIFFUSETEXTURE=t.shaderDefines.registerDefine("DIFFUSETEXTURE"),t.SHADERDEFINE_TILINGOFFSET=t.shaderDefines.registerDefine("TILINGOFFSET")},t.load=function(e){return a.loader.create(e,null,null,t)},t.SHADERDEFINE_DIFFUSETEXTURE=0,t.SHADERDEFINE_TILINGOFFSET=0,t.DIFFUSETEXTURE=1,t.TINTCOLOR=2,t.TILINGOFFSET=3,o(t,["defaultMaterial",function(){return this.defaultMaterial=new t},"shaderDefines",function(){return this.shaderDefines=new Gt(Dn.shaderDefines)}]),t}(),ti=(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=[]}s(t,"laya.d3.component.animation.RigidAnimations",e);var n=t.prototype;n._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;a<n;a++){var o=r.slice(i+1,i+1+r[i]);i+=r[i]+1;for(var s=1;s<o.length;s++)o[s],t=t._childs[o[s]];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 Ct),l.transform.localMatrix.cloneTo(h),t=this._owner}},n._animtionPlay=function(){this._templet.loaded?this._init():this._templet.once("loaded",this,this._init)},n._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]}},n._effectAnimation=function(e){for(var t=0,n=this._animationSprites.length;t<n;t++){for(var i=this._animationSprites[t],r=i.transform.localMatrix,a=r.elements,o=0;o<16;o++)a[o]=this._curAnimationDatas[16*t+o];i.transform.localMatrix=r}},n._load=function(t){e.prototype._load.call(this,t),this._player.on("stopped",this,this._animtionStop),this._player.on("played",this,this._animtionPlay)},n._update=function(e){if(2===this._player.state&&this._templet&&this._templet.loaded){var t=this._player.playbackRate*a.timer.scale,n=this._player.cachePlayRate,i=this._player.isCache&&t>=n,r=i?this.currentFrameIndex:-1;if(-1===r||this._lastFrameIndex!==r){var o=this.currentAnimationClipIndex,s=this._templet.getNodes(o),l=this._templet._animationDatasCache;if(i){var h=this._templet.getAnimationDataWithCache(n,l,o,r);if(h)return this._curAnimationDatas=h,this._lastFrameIndex=r,void this._effectAnimation(s)}var _=16*s.length;i?this._curAnimationDatas=new Float32Array(_):(this._tempCurAnimationData||(this._tempCurAnimationData=new Float32Array(_)),this._curAnimationDatas=this._tempCurAnimationData),this._curOriginalData||(this._curOriginalData=new Float32Array(this._templet.getTotalkeyframesLength(o))),i?this._templet.getOriginalData(o,this._curOriginalData,this._player._fullFrames[o],r,this._player.currentFrameTime):this._templet.getOriginalDataUnfixedRate(o,this._curOriginalData,this._player.currentPlayTime),Jt._computeRootAnimationData(s,this._curOriginalData,this._curAnimationDatas),i&&this._templet.setAnimationDataWithCache(n,l,o,r,this._curAnimationDatas),this._lastFrameIndex=r,this._effectAnimation(s)}}},n._unload=function(t){e.prototype._unload.call(this,t),this._animationSprites=null,this._animationSpritesInitLocalMatrix=null,this._tempCurAnimationData=null,this._curOriginalData=null,this._curAnimationDatas=null},l(0,n,"url",null,function(e){console.log("Warning: discard property,please use templet property instead.");var t=a.loader.create(e,null,null,u);this._templet!==t&&(0!==this._player.state&&this._player.stop(!0),this._templet=t,this._player.templet=t,this._curOriginalData=null,this._curAnimationDatas=null,this._tempCurAnimationData=null,this._templet._animationDatasCache||(this._templet._animationDatasCache=[]),this.event("animationchanged",this))}),l(0,n,"templet",e.prototype._$get_templet,function(e){this._templet!==e&&(0!==this._player.state&&this._player.stop(!0),this._templet=e,this._player.templet=e,this._curOriginalData=null,this._curAnimationDatas=null,this._tempCurAnimationData=null,this._templet._animationDatasCache||(this._templet._animationDatasCache=[]),this.event("animationchanged",this))})}(Rn),function(e){function t(){this._tempCurAnimationData=null,this._tempCurBonesData=null,this._curOriginalData=null,this._lastFrameIndex=-1,this._curMeshAnimationData=null,this._curBonesDatas=null,this._curAnimationDatas=null,this._ownerMesh=null,this._boneIndexToMeshList=null,this._oldVersion=!1,t.__super.call(this),this._boneIndexToMeshList=[]}s(t,"laya.d3.component.animation.SkinAnimations",e);var n=t.prototype;return n._computeBoneIndexToMeshOnTemplet=function(){this._templet.loaded?this._computeBoneIndexToMeshOnMesh():this._templet.once("loaded",this,this._computeBoneIndexToMeshOnMesh)},n._computeBoneIndexToMeshOnMesh=function(){"LAYAANIMATION:02"===this._templet._aniVersion?this._oldVersion=!1:this._oldVersion=!0;var e=this._owner.meshFilter.sharedMesh;e.loaded?this._computeBoneIndexToMesh(e):e.on("loaded",this,this._computeBoneIndexToMesh)},n._computeBoneIndexToMesh=function(e){var t=e._boneNames;if(t)for(var n=t.length,i=this._templet._anis,r=0,a=i.length;r<a;r++){var o=this._boneIndexToMeshList[r];o||(o=this._boneIndexToMeshList[r]=[]),o.length=n;for(var s=i[r],l=0;l<n;l++)o[l]=s.bone3DMap[t[l]]}},n._getAnimationDatasWithCache=function(e,t,n,i,r){var a=n[i];if(a){var o=a[e];if(o){var s=o[t.id];return s?s[r]:null}return null}return null},n._setAnimationDatasWithCache=function(e,t,n,i,r,a){var o=n[i]||(n[i]={}),s=o[e]||(o[e]={});(s[t.id]||(s[t.id]=[]))[r]=a},n._onAnimationPlayMeshLoaded=function(){for(var e=this._ownerMesh.meshRender._renderElements,t=0,n=e.length;t<n;t++)e[t]._canDynamicBatch=!1},n._onAnimationPlay=function(){this._ownerMesh._render._addShaderDefine(Si.SHADERDEFINE_BONE);var e=this._ownerMesh.meshFilter.sharedMesh;e.loaded?this._onAnimationPlayMeshLoaded():e.once("loaded",this,this._onAnimationPlayMeshLoaded)},n._onAnimationStop=function(){this._lastFrameIndex=-1,this._player.returnToZeroStopped&&(this._curBonesDatas=null,this._curAnimationDatas=null,this._ownerMesh._render._removeShaderDefine(Si.SHADERDEFINE_BONE));for(var e=this._ownerMesh.meshRender._renderElements,t=0,n=e.length;t<n;t++)e[t]._canDynamicBatch=!0},n._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),this._owner.meshFilter.on("meshchanged",this,this._computeBoneIndexToMeshOnTemplet)},n._update=function(e){var n=this._ownerMesh.meshFilter.sharedMesh;if(2===this._player.state&&this._templet&&this._templet.loaded&&n.loaded){var i=this._player.playbackRate*a.timer.scale,r=this._player.cachePlayRate,o=this._player.isCache&&i>=r,s=o?this.currentFrameIndex:-1;if(-1===s||this._lastFrameIndex!==s){var l=this.currentAnimationClipIndex,h=this._templet._animationDatasCache[0],_=this._templet._animationDatasCache[1];if(o){var u=this._getAnimationDatasWithCache(r,n,_,l,s);if(u)return this._curAnimationDatas=u,this._curBonesDatas=this._templet.getAnimationDataWithCache(r,h,l,s),void(this._lastFrameIndex=s)}var c=!1;o&&(this._curBonesDatas=this._templet.getAnimationDataWithCache(r,h,l,s),c=!!this._curBonesDatas);var d=this._templet.getNodes(l),f=16*d.length,m=n.InverseAbsoluteBindPoses;this._oldVersion?this._curMeshAnimationData||(this._curMeshAnimationData=new Float32Array(f)):this._curMeshAnimationData||(this._curMeshAnimationData=new Float32Array(16*m.length));var p,v,E=0,g=0,D=0,T=n.getSubMeshCount();if(o){for(this._curAnimationDatas=[],this._curAnimationDatas.length=T,E=0;E<T;E++)for(p=this._curAnimationDatas[E]=[],D=(v=n.getSubMesh(E))._boneIndicesList.length,p.length=D,g=0;g<D;g++)p[g]=new Float32Array(16*v._boneIndicesList[g].length);c||(this._curBonesDatas=new Float32Array(f))}else{if(!this._tempCurAnimationData)for(this._tempCurAnimationData=[],this._tempCurAnimationData.length=T,E=0;E<T;E++)for(p=this._tempCurAnimationData[E]=[],D=(v=n.getSubMesh(E))._boneIndicesList.length,p.length=D,g=0;g<D;g++)p[g]=new Float32Array(16*v._boneIndicesList[g].length);this._tempCurBonesData||(this._tempCurBonesData=new Float32Array(f)),this._curAnimationDatas=this._tempCurAnimationData,this._curBonesDatas=this._tempCurBonesData}if(this._curOriginalData||(this._curOriginalData=new Float32Array(this._templet.getTotalkeyframesLength(l))),o?this._templet.getOriginalData(l,this._curOriginalData,this._player._fullFrames[l],s,this._player.currentFrameTime):this._templet.getOriginalDataUnfixedRate(l,this._curOriginalData,this._player.currentPlayTime),this._oldVersion)o&&c?Jt._computeAnimationDatasByArrayAndMatrixFastOld(m,this._curBonesDatas,this._curMeshAnimationData):Jt._computeBoneAndAnimationDatasByBindPoseMatrxixOld(d,this._curOriginalData,m,this._curBonesDatas,this._curMeshAnimationData);else{var S=this._boneIndexToMeshList[l];o&&c?Jt._computeAnimationDatasByArrayAndMatrixFast(m,this._curBonesDatas,this._curMeshAnimationData,S):Jt._computeBoneAndAnimationDatasByBindPoseMatrxix(d,this._curOriginalData,m,this._curBonesDatas,this._curMeshAnimationData,S)}for(E=0;E<T;E++){var x=n.getSubMesh(E)._boneIndicesList;for(D=x.length,p=this._curAnimationDatas[E],g=0;g<D;g++)t._splitAnimationDatas(x[g],this._curMeshAnimationData,p[g])}o&&(this._setAnimationDatasWithCache(r,n,_,l,s,this._curAnimationDatas),c||this._templet.setAnimationDataWithCache(r,h,l,s,this._curBonesDatas)),this._lastFrameIndex=s}}},n._preRenderUpdate=function(e){var t=e.renderElement.renderObj;this._curAnimationDatas?t._skinAnimationDatas=this._curAnimationDatas[t._indexInMesh]:t._skinAnimationDatas=null},n._unload=function(t){2==this.player.state&&this._ownerMesh._render._removeShaderDefine(Si.SHADERDEFINE_BONE),this._templet&&!this._templet.loaded&&this._templet.off("loaded",this,this._computeBoneIndexToMeshOnMesh);var n=this._ownerMesh.meshFilter.sharedMesh;n.loaded||n.off("loaded",this,this._onAnimationPlayMeshLoaded),e.prototype._unload.call(this,t),this._tempCurAnimationData=null,this._tempCurBonesData=null,this._curOriginalData=null,this._curMeshAnimationData=null,this._curBonesDatas=null,this._curAnimationDatas=null,this._ownerMesh=null},l(0,n,"curBonesDatas",function(){return this._curBonesDatas}),l(0,n,"templet",e.prototype._$get_templet,function(e){this._templet!==e&&(0!==this._player.state&&this._player.stop(!0),this._templet=e,this._player.templet=e,this._computeBoneIndexToMeshOnTemplet(),this._curOriginalData=null,this._curMeshAnimationData=null,this._tempCurBonesData=null,this._tempCurAnimationData=null,this._templet._animationDatasCache||(this._templet._animationDatasCache=[[],[]]),this.event("animationchanged",this))}),t._splitAnimationDatas=function(e,t,n){for(var i=0,r=e.length,a=0;i<r;i++)for(var o=0;o<16;o++,a++)n[a]=t[(e[i]<<4)+o]},t}(Rn)),ni=function(e){function t(){this._size=null,this._transformOrientedBoundBox=null,this.center=null,t.__super.call(this),this._needUpdate=!1}s(t,"laya.d3.component.physics.BoxCollider",In);var n=t.prototype;return n._updateCollider=function(){if(this._needUpdate){var e=this._transformOrientedBoundBox.transformation,n=this._owner.transform,i=n.rotation,r=n.scale,a=this.center.elements;0===a[0]&&0===a[1]&&0===a[2]?Ct.createAffineTransformation(n.position,i,bt.ONE,e):(bt.multiply(this.center,r,t._deviationV3),bt.transformQuat(t._deviationV3,i,t._deviationV3),bt.add(n.position,t._deviationV3,t._deviationV3),Ct.createAffineTransformation(t._deviationV3,i,bt.ONE,e)),this._transformOrientedBoundBox.transformation=e;var o=this._transformOrientedBoundBox.extents.elements,s=this._size.elements,l=r.elements;o[0]=.5*s[0]*l[0],o[1]=.5*s[1]*l[1],o[2]=.5*s[2]*l[2],this._needUpdate=!1}},n._onWorldMatrixChanged=function(){for(var e in this._needUpdate=!0,this._runtimeCollisonMap)this._runtimeCollisonTestMap[e]=!0,this._runtimeCollisonMap[e]._runtimeCollisonTestMap[this.id]=!0},n._initialize=function(e){laya.d3.component.Component3D.prototype._initialize.call(this,e),this._transformOrientedBoundBox=new Nt(new bt,new Ct),this._size=new bt,this.center=new bt,e.transform.on("worldmatrixneedchanged",this,this._onWorldMatrixChanged),this._needUpdate=!0},n._getType=function(){return 1},n._collisonTo=function(e){switch(e._getType()){case 0:return 0!==this.boundBox.containsSphere(e.boundSphere);case 1:return 0!==this.boundBox.containsOrientedBoundBox(e.boundBox);case 2:var t=e;if(0!==this.boundBox.containsBoundBox(t._boundBox)){for(var n=e.mesh._positions,i=0,r=n.length;i<r;i++)if(1===this.boundBox.containsPoint(n[i]))return!0;return!1}return!1;default:throw new Error("BoxCollider:unknown collider type.")}},n._cloneTo=function(e){var t=e,n=t.size;this.size.cloneTo(n),t.size=n,this.center.cloneTo(t.center)},n.raycast=function(e,t,n){void 0===n&&(n=1.79e308),this._updateCollider();var i=this._transformOrientedBoundBox.intersectsRay(e,t.position);return-1!==i&&i<=n?(t.distance=i,t.sprite3D=this._owner,!0):(t.distance=-1,t.sprite3D=null,!1)},n.setFromBoundBox=function(e){Nt.createByBoundBox(e,this._transformOrientedBoundBox);var t=this._transformOrientedBoundBox.extents;this._size=new bt(2*t.x,2*t.y,2*t.z),this.center=new bt,bt.add(e.min,e.max,this.center),bt.scale(this.center,.5,this.center),this._needUpdate=!0},l(0,n,"boundBox",function(){return this._updateCollider(),this._transformOrientedBoundBox}),l(0,n,"size",function(){return this._size},function(e){this._size=e,this._needUpdate=!0}),o(t,["_deviationV3",function(){return this._deviationV3=new bt},"_obbCenterV3",function(){return this._obbCenterV3=new bt}]),t}(),ii=function(e){function t(){this._transformBoundingBox=null,this._mesh=null,t.__super.call(this),this._transformBoundingBox=new xt(new bt,new bt),this._needUpdate=!1}s(t,"laya.d3.component.physics.MeshCollider",In);var n=t.prototype;return n._updateBoundBoxCollider=function(){if(this._needUpdate){for(var e=this._owner.transform.worldMatrix,n=this._mesh.boundingBoxCorners,i=0;i<8;i++)bt.transformCoordinate(n[i],e,t._tempBoundBoxCorners[i]);xt.createfromPoints(t._tempBoundBoxCorners,this._transformBoundingBox),this._needUpdate=!1}},n._raycastMesh=function(e,n,i,r){void 0===r&&(r=1.79e308);var a=n.transform.worldMatrix,o=t._tempMatrix4x40;a.invert(o);var s=e.origin,l=e.direction,h=t._tempRay0;bt.transformCoordinate(s,o,h.origin),bt.TransformNormal(l,o,h.direction);for(var _=Number.MAX_VALUE,u=0,c=this._mesh.getRenderElementsCount();u<c;u++){var d=this._mesh.getRenderElement(u),f=d._getVertexBuffer(0),m=f.getData(),p=d._getIndexBuffer().getData(),v=t._tempRaycastHit;if(qt.rayIntersectsPositionsAndIndices(h,m,f.vertexDeclaration,p,v)){bt.transformCoordinate(v.position,a,v.position);var E=t._tempVector30;bt.subtract(s,v.position,E);var g=bt.scalarLength(E);if(g<r&&g<_){v.distance=g,v.sprite3D=n;var D=v.trianglePositions;bt.transformCoordinate(D[0],a,D[0]),bt.transformCoordinate(D[1],a,D[1]),bt.transformCoordinate(D[2],a,D[2]);var T=v.triangleNormals;return bt.transformCoordinate(T[0],a,T[0]),bt.transformCoordinate(T[1],a,T[1]),bt.transformCoordinate(T[2],a,T[2]),_=g,v.cloneTo(i),!0}return!1}}return!1},n._onWorldMatrixChanged=function(){this._needUpdate=!0},n._initialize=function(e){laya.d3.component.Component3D.prototype._initialize.call(this,e),e.transform.on("worldmatrixneedchanged",this,this._onWorldMatrixChanged),this._needUpdate=!0},n._getType=function(){return 2},n._collisonTo=function(e){var t=0,n=0,i=this.mesh._positions;switch(e._getType()){case 0:var r=e;if(0!==At.sphereContainsBox(r.boundSphere,this._boundBox)){for(t=0,n=i.length;t<n;t++)if(1===At.sphereContainsPoint(r.boundSphere,i[t]))return!0;return!1}return!1;case 1:var a=e;if(0!==a.boundBox.containsBoundBox(this._boundBox)){for(t=0,n=i.length;t<n;t++)if(1===a.boundBox.containsPoint(i[t]))return!0;return!1}return!1;case 2:var o=e;return 1!==At.intersectsBoxAndBox(o._boundBox,this._boundBox);default:throw new Error("MeshCollider:unknown collider type.")}},n._cloneTo=function(e){e.mesh=this._mesh},n.raycast=function(e,t,n){if(void 0===n&&(n=1.79e308),null==this._mesh||!this._mesh.loaded)return!1;var i=At.intersectsRayAndBoxRD(e,this._boundBox);return!!(-1!==i&&i<=n&&this._raycastMesh(e,this._owner,t,n))||(t.distance=-1,t.sprite3D=null,!1)},l(0,n,"_boundBox",function(){return this._updateBoundBoxCollider(),this._transformBoundingBox}),l(0,n,"mesh",function(){return this._mesh},function(e){this._mesh=e}),o(t,["_tempRay0",function(){return this._tempRay0=new Pt(new bt,new bt)},"_tempVector30",function(){return this._tempVector30=new bt},"_tempMatrix4x40",function(){return this._tempMatrix4x40=new Ct},"_tempRaycastHit",function(){return this._tempRaycastHit=new Qt},"_tempBoundBoxCorners",function(){return this._tempBoundBoxCorners=[new bt,new bt,new bt,new bt,new bt,new bt,new bt,new bt]}]),t}(),ri=function(e){function t(){this._originalBoundSphere=null,this._transformBoundSphere=null,t.__super.call(this),this._needUpdate=!1}s(t,"laya.d3.component.physics.SphereCollider",In);var n=t.prototype;return n._updateCollider=function(){if(this._needUpdate){var e,t=this._owner.transform,n=t.scale;e=n.x>=n.y&&n.x>=n.z?n.x:n.y>=n.z?n.y:n.z,bt.transformCoordinate(this._originalBoundSphere.center,t.worldMatrix,this._transformBoundSphere.center),this._transformBoundSphere.radius=this._originalBoundSphere.radius*e,this._needUpdate=!1}},n._onWorldMatrixChanged=function(){for(var e in this._needUpdate=!0,this._runtimeCollisonMap)this._runtimeCollisonTestMap[e]=!0,this._runtimeCollisonMap[e]._runtimeCollisonTestMap[this.id]=!0},n._initialize=function(e){laya.d3.component.Component3D.prototype._initialize.call(this,e),this._originalBoundSphere=new Rt(new bt(0,0,0),.5),this._transformBoundSphere=new Rt(new bt(0,0,0),.5),e.transform.on("worldmatrixneedchanged",this,this._onWorldMatrixChanged),this._needUpdate=!0},n._getType=function(){return 0},n._collisonTo=function(e){switch(e._getType()){case 0:return 0!==At.sphereContainsSphere(this.boundSphere,e.boundSphere);case 1:return 0!==e.boundBox.containsSphere(this.boundSphere);case 2:var t=e;if(0!==At.sphereContainsBox(this.boundSphere,t._boundBox)){for(var n=t.mesh._positions,i=0,r=n.length;i<r;i++)if(1===At.sphereContainsPoint(this.boundSphere,n[i]))return!0;return!1}return!1;default:throw new Error("SphereCollider:unknown collider type.")}},n._cloneTo=function(e){var t=e;t.radius=this.radius;var n=t.center;this.center.cloneTo(n),t.center=n},n.raycast=function(e,t,n){void 0===n&&(n=1.79e308),this._updateCollider();var i=this._transformBoundSphere.intersectsRayPoint(e,t.position);return-1!==i&&i<=n?(t.distance=i,t.sprite3D=this._owner,!0):(t.distance=-1,t.sprite3D=null,!1)},l(0,n,"center",function(){return this._originalBoundSphere.center},function(e){this._originalBoundSphere.center=e}),l(0,n,"radius",function(){return this._originalBoundSphere.radius},function(e){this._originalBoundSphere.radius=e}),l(0,n,"boundSphere",function(){return this._updateCollider(),this._transformBoundSphere}),t}(),ai=function(e){function t(){this.simLodInfo=null,this._src=null,this._buffer=null,this._mipmaps=null,this._recreateLock=!1,this._needReleaseAgain=!1,t.__super.call(this),this._type=3553}s(t,"laya.d3.resource.DataTexture2D",Tn);var n=t.prototype;return n.genDebugMipmaps=function(){var e=[];return e.push(new Uint8Array(new Uint32Array(131072).fill(4278190335).buffer)),e.push(new Uint8Array(new Uint32Array(32768).fill(4278223103).buffer)),e.push(new Uint8Array(new Uint32Array(8192).fill(4278255615).buffer)),e.push(new Uint8Array(new Uint32Array(2048).fill(4278255360).buffer)),e.push(new Uint8Array(new Uint32Array(512).fill(4286595072).buffer)),e.push(new Uint8Array(new Uint32Array(128).fill(4294901760).buffer)),e.push(new Uint8Array(new Uint32Array(32).fill(4294901888).buffer)),e.push(new Uint8Array(new Uint32Array(8).fill(0).buffer)),e.push(new Uint8Array(new Uint32Array(2).fill(4286611584).buffer)),e.push(new Uint8Array(new Uint32Array(1).fill(4294967295).buffer)),e},n._onTextureLoaded=function(e){},n._createWebGlTexture=function(){if(!this._buffer&&!this._mipmaps)throw"create GLTextur err:no data";var e=b.mainContext;e.getExtension("EXT_shader_texture_lod");var n=this._source=e.createTexture(),i=this._width,r=this._height,a=F.curBindTexTarget,o=F.curBindTexValue;if(F.bindTexture(e,this._type,n),this._mipmaps){if(laya.d3.resource.DataTexture2D.lodasatlas){var s=0;e.texImage2D(this._type,0,6408,this._width,this._height,0,6408,5121,null);for(var l=0;l<this._mipmaps.length;l++){if(this._mipmaps[l].byteLength!=h*_*4)throw"mipmap size error  level:"+l;e.texSubImage2D(this._type,0,t.simLodRect[s++],t.simLodRect[s++],t.simLodRect[s++],t.simLodRect[s++],6408,5121,new Uint8Array(this._mipmaps[l]))}this.minFifter=9729,this.magFifter=9729}else{var h=this._width,_=this._height;for(s=0,e.texImage2D(this._type,0,6408,this._width,this._height,0,6408,5121,null),l=0;l<this._mipmaps.length;l++){if(this._mipmaps[l].byteLength!=h*_*4)throw"mipmap size error  level:"+l;e.texImage2D(this._type,l,6408,h,_,0,6408,5121,new Uint8Array(this._mipmaps[l])),(h/=2)<1&&(h=1),(_/=2)<1&&(_=1),this.minFifter=9987,this.magFifter=9729}}this.mipmap=!1}else e.texImage2D(this._type,0,6408,i,r,0,6408,5121,new Uint8Array(this._buffer));var u=this._minFifter,d=this._magFifter,f=this._repeat?10497:33071,m=c.isPOT(i,r);if(!m)throw"data texture must be POT";this._mipmap||this._mipmaps?-1!==u||(u=9987):-1!==u||(u=9729),-1!==d||(d=9729),e.texParameteri(this._type,10241,u),e.texParameteri(this._type,10240,d),e.texParameteri(this._type,10242,f),this._mipmaps?e.texParameteri(this._type,10243,33071):e.texParameteri(this._type,10243,f),this._mipmap&&e.generateMipmap(this._type),a&&o&&F.bindTexture(e,a,o),this.src&&this.src.length>0&&(this._buffer=null),this.memorySize=m?i*r*4*(1+1/3):i*r*4,this._recreateLock=!1},n.recreateResource=function(){if(this._buffer||null!=this._src&&""!==this._src)if(this._needReleaseAgain=!1,this._buffer||this._mipmaps){if(this._recreateLock)return;this._createWebGlTexture(),this.completeCreate()}else this._recreateLock=!0},n.onAsynLoaded=function(e,t,n){var i;n&&(i=n[0].call(this,t)),i&&(this._width=i.width,this._height=i.height,this._buffer=i.data),this._src=e,this._size=new $t(this._width,this._height),this._conchTexture?alert("怎么给runtime传递datatexture数据"):this.activeResource(),this._endLoaded()},n.getPixels=function(){return new Uint8Array(this._buffer)},n.disposeResource=function(){this._recreateLock&&(this._needReleaseAgain=!0),this._source&&(b.mainContext.deleteTexture(this._source),this._source=null,this._buffer=null,this.memorySize=0)},l(0,n,"src",function(){return this._src}),t.create=function(e,n,i,r,a,o){if(void 0===r&&(r=9729),void 0===a&&(a=9729),void 0===o&&(o=!0),!e||e.byteLength<n*i*4)throw"DataTexture2D create error";var s=new t;return s._buffer=e,s._width=n,s._height=i,s._mipmap=o,s._magFifter=r,s._minFifter=a,s._size=new $t(s._width,s._height),s._conchTexture?alert("怎么给runtime传递datatexture数据"):s.activeResource(),s},t.load=function(e,n,i,r,o){if(void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=9729),void 0===o&&(o=9729),"mipmaps"===L.getFileExtension(e)){var s=a.loader.create(e,null,null,t,[function(e){this._mipmaps=[];var t=new Uint32Array(e);this._width=t[0];var n=512;if(laya.d3.resource.DataTexture2D.lodasatlas&&(this._width*=2,n=1024),this._width!=n)throw console.error("现在只支持512x256的环境贴图。当前的是"+t[0]),"现在只支持512x256的环境贴图。当前的是"+t[0];this._height=t[1];for(var i=laya.d3.resource.DataTexture2D.lodasatlas?this._width/2:this._width,r=this._height,a=8;;){var o=i*r*4;if(a+o>e.byteLength)throw"load mipmaps data size error ";var s=new Uint8Array(e,a,o);if(this._mipmaps.push(s),a+=o,1==i&&1==r)break;(i/=2)<1&&(i=1),(r/=2)<1&&(r=1)}return null}]);if(laya.d3.resource.DataTexture2D.lodasatlas){s.simLodInfo=new Float32Array(40);for(var l=0;l<s.simLodInfo.length;)s.simLodInfo[l]=(t.simLodRect[l]+.5)/1024,l++,s.simLodInfo[l]=(t.simLodRect[l]+.5)/256,l++,s.simLodInfo[l]=Math.max(t.simLodRect[l]-1,.1)/1024,l++,s.simLodInfo[l]=Math.max(t.simLodRect[l]-1.5,.1)/256,l++}return s}if("number"==typeof n)return a.loader.create(e,null,null,t,[function(e){return this._width=n,this._height=i,this._buffer=e,null}]);if("function"==typeof n)return a.loader.create(e,null,null,t,[n]);throw new Error("unknown params.")},t.lodasatlas=!1,o(t,["simLodRect",function(){return this.simLodRect=new Uint32Array([0,0,512,256,512,0,256,128,768,0,128,64,896,0,64,32,960,0,32,16,992,0,16,8,1008,0,8,4,1016,0,4,2,1020,0,2,1,1022,0,1,1])}]),t}(),oi=function(e){function t(){this._numberVertices=0,this._numberIndices=0,this._vertexBuffer=null,this._indexBuffer=null,t.__super.call(this)}s(t,"laya.d3.resource.models.PrimitiveMesh",Sn);var n=t.prototype;return a.imps(n,{"laya.d3.core.render.IRenderable":!0}),n._getVertexBuffer=function(e){return void 0===e&&(e=0),0===e?this._vertexBuffer:null},n._getVertexBuffers=function(){return null},n._getIndexBuffer=function(){return this._indexBuffer},n._getPositions=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&&0===r.elementUsage){e=r;break}}var a=this._vertexBuffer.getData();for(i=0;i<a.length;i+=this._vertexBuffer.vertexDeclaration.vertexStride/4){var o=i+e.offset/4,s=new bt(a[o+0],a[o+1],a[o+2]);t.push(s)}return t},n.getRenderElement=function(e){return this},n.getRenderElementsCount=function(){return 1},n.disposeResource=function(){this._vertexBuffer&&(this._vertexBuffer.destroy(),this._vertexBuffer=null),this._indexBuffer&&(this._indexBuffer.destroy(),this._indexBuffer=null),this.memorySize=0},n._beforeRender=function(e){return this._vertexBuffer._bind(),this._indexBuffer._bind(),!0},n._render=function(e){b.mainContext.drawElements(4,this._numberIndices,5123,0),w.drawCall++,w.trianglesFaces+=this._numberIndices/3},l(0,n,"_vertexBufferCount",function(){return 1}),l(0,n,"triangleCount",function(){return this._indexBuffer.indexCount/3}),t}(),si=function(e){function t(){this._materials=null,this._subMeshes=null,this._vertexBuffers=null,this._indexBuffer=null,this._boneNames=null,this._inverseBindPoses=null,this._skinnedDatas=null,t.__super.call(this),this._subMeshes=[],this._materials=[],this._vertexBuffers=[]}s(t,"laya.d3.resource.models.Mesh",Sn);var n=t.prototype;return n._getPositions=function(){var e,t,n,i,r,a=[],o=0,s=0,l=0;if(0!==this._vertexBuffers.length){var h=this._vertexBuffers.length;for(o=0;o<h;o++){for(n=(e=this._vertexBuffers[o]).vertexDeclaration.getVertexElements(),s=0;s<n.length;s++)if("vector3"===(i=n[s]).elementFormat&&0===i.elementUsage){t=i;break}for(r=e.getData(),s=0;s<r.length;s+=e.vertexDeclaration.vertexStride/4)l=s+t.offset/4,a.push(new bt(r[l+0],r[l+1],r[l+2]))}}else{var _=this._subMeshes.length;for(o=0;o<_;o++){for(n=(e=this._subMeshes[o]._getVertexBuffer()).vertexDeclaration.getVertexElements(),s=0;s<n.length;s++)if("vector3"===(i=n[s]).elementFormat&&0===i.elementUsage){t=i;break}for(r=e.getData(),s=0;s<r.length;s+=e.vertexDeclaration.vertexStride/4)l=s+t.offset/4,a.push(new bt(r[l+0],r[l+1],r[l+2]))}}return a},n._setSubMeshes=function(e){this._subMeshes=e,this._subMeshCount=e.length;for(var t=0;t<this._subMeshCount;t++)e[t]._indexInMesh=t;this._positions=this._getPositions(),this._generateBoundingObject()},n.onAsynLoaded=function(e,t,n){var i=t[0],r=t[1];St.read(i,this,this._materials,this._subMeshes,r),this.completeCreate(),this._endLoaded()},n.getSubMesh=function(e){return this._subMeshes[e]},n.getSubMeshCount=function(){return this._subMeshes.length},n.getRenderElementsCount=function(){return this._subMeshes.length},n.getRenderElement=function(e){return this._subMeshes[e]},n.disposeResource=function(){for(var e=0;e<this._subMeshes.length;e++)this._subMeshes[e].dispose();this._materials=null,this._subMeshes=null,this._vertexBuffers=null,this._indexBuffer=null,this._boneNames=null,this._inverseBindPoses=null},l(0,n,"materials",function(){return this._materials.slice()}),l(0,n,"InverseAbsoluteBindPoses",function(){return this._inverseBindPoses}),t.load=function(e){return a.loader.create(e,null,null,t)},t}(),li=function(e){function t(e,n,i,r,a,o,s,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===o&&(o=!1),void 0===s&&(s=!1),void 0===l&&(l=-1),void 0===h&&(h=-1),t.__super.call(this),this._type=3553,this._width=e,this._height=n,this._size=new $t(e,n),this._surfaceFormat=i,this._surfaceType=r,this._depthStencilFormat=a,this._mipmap=o,this._repeat=s,this._minFifter=l,this._magFifter=h,this.activeResource(),this._alreadyResolved=!0}s(t,"laya.d3.resource.RenderTexture",Tn);var n=t.prototype;return n.recreateResource=function(){var e=b.mainContext;this._frameBuffer=e.createFramebuffer(),this._source=e.createTexture();var t=F.curBindTexTarget,n=F.curBindTexValue;F.bindTexture(e,this._type,this._source),e.texImage2D(this._type,0,6408,this._width,this._height,0,this._surfaceFormat,this._surfaceType,null);var i=this._minFifter,r=this._magFifter,a=this._repeat?10497:33071;if(c.isPOT(this._width,this._height)?(this._mipmap?-1!==i||(i=9987):-1!==i||(i=9729),-1!==r||(r=9729),e.texParameteri(this._type,10241,i),e.texParameteri(this._type,10240,r),e.texParameteri(this._type,10242,a),e.texParameteri(this._type,10243,a),this._mipmap&&e.generateMipmap(this._type)):(-1!==i||(i=9729),-1!==r||(r=9729),e.texParameteri(this._type,10241,i),e.texParameteri(this._type,10240,r),e.texParameteri(this._type,10242,33071),e.texParameteri(this._type,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&&F.bindTexture(e,t,n),e.bindRenderbuffer(36161,null),this.memorySize=this._width*this._height*4,this.completeCreate()},n.start=function(){b.mainContext.bindFramebuffer(36160,this.frameBuffer),t._currentRenderTarget=this,this._alreadyResolved=!1},n.end=function(){b.mainContext.bindFramebuffer(36160,null),t._currentRenderTarget=null,this._alreadyResolved=!0},n.getData=function(e,t,n,i){var r=b.mainContext;if(r.bindFramebuffer(36160,this._frameBuffer),36053!==r.checkFramebufferStatus(36160))return r.bindFramebuffer(36160,null),null;var a=new Uint8Array(this._width*this._height*4);return r.readPixels(e,t,n,i,this._surfaceFormat,this._surfaceType,a),r.bindFramebuffer(36160,null),a},n.disposeResource=function(){if(this._frameBuffer){var e=b.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}},l(0,n,"surfaceFormat",function(){return this._surfaceFormat}),l(0,n,"surfaceType",function(){return this._surfaceType}),l(0,n,"depthStencilFormat",function(){return this._depthStencilFormat}),l(0,n,"source",function(){return this._alreadyResolved?a.superGet(Tn,this,"source"):null}),l(0,n,"depthStencilBuffer",function(){return this._depthStencilBuffer}),l(0,n,"frameBuffer",function(){return this._frameBuffer}),t._currentRenderTarget=null,t}(),hi=function(e){function t(e){this._color=null,this._pixels=null,t.__super.call(this),this._type=3553,this._width=1,this._height=1,this._size=new $t(this.width,this.height),this._color=e,this._pixels=new Uint8Array([255*e.x,255*e.y,255*e.z,255*e.w])}s(t,"laya.d3.resource.SolidColorTexture2D",Tn);var n=t.prototype;return n._createWebGlTexture=function(){var e=b.mainContext,t=this._source=e.createTexture(),n=this._width,i=this._height,r=F.curBindTexTarget,a=F.curBindTexValue;F.bindTexture(e,this._type,t),e.texImage2D(this._type,0,6408,n,i,0,6408,5121,this._pixels);var o=this._minFifter,s=this._magFifter,l=this._repeat?10497:33071,h=c.isPOT(n,i);h?(this._mipmap?-1!==o||(o=9987):-1!==o||(o=9729),-1!==s||(s=9729),e.texParameteri(this._type,10241,o),e.texParameteri(this._type,10240,s),e.texParameteri(this._type,10242,l),e.texParameteri(this._type,10243,l),this._mipmap&&e.generateMipmap(this._type)):(-1!==o||(o=9729),-1!==s||(s=9729),e.texParameteri(this._type,10241,o),e.texParameteri(this._type,10240,s),e.texParameteri(this._type,10242,33071),e.texParameteri(this._type,10243,33071)),r&&a&&F.bindTexture(e,r,a),this.memorySize=h?n*i*4*(1+1/3):n*i*4},n.recreateResource=function(){this._createWebGlTexture(),this.completeCreate()},n.disposeResource=function(){this._source&&(b.mainContext.deleteTexture(this._source),this._source=null,this.memorySize=0)},o(t,["magentaTexture",function(){return this.magentaTexture=new t(new Ft(1,0,1,1))},"grayTexture",function(){return this.grayTexture=new t(new Ft(.5,.5,.5,1))}]),t}(),_i=function(e){function t(e){this._color=null,this._pixels=null,this._texCount=6,t.__super.call(this),this._type=34067,this._width=1,this._height=1,this._size=new $t(this.width,this.height),this._color=e,this._pixels=new Uint8Array([255*e.x,255*e.y,255*e.z,255*e.w])}s(t,"laya.d3.resource.SolidColorTextureCube",Tn);var n=t.prototype;return n._createWebGlTexture=function(){var e=b.mainContext,t=this._source=e.createTexture(),n=this._width,i=this._height,r=F.curBindTexTarget,a=F.curBindTexValue;F.bindTexture(e,this._type,t),e.texImage2D(34069,0,6408,n,i,0,6408,5121,this._pixels),e.texImage2D(34070,0,6408,n,i,0,6408,5121,this._pixels),e.texImage2D(34071,0,6408,n,i,0,6408,5121,this._pixels),e.texImage2D(34072,0,6408,n,i,0,6408,5121,this._pixels),e.texImage2D(34073,0,6408,n,i,0,6408,5121,this._pixels),e.texImage2D(34074,0,6408,n,i,0,6408,5121,this._pixels);var o=this.minFifter,s=this.magFifter,l=this._repeat?10497:33071,h=c.isPOT(n,i);h?(this.mipmap?-1!==o||(o=9987):-1!==o||(o=9729),-1!==s||(s=9729),e.texParameteri(this._type,10241,o),e.texParameteri(this._type,10240,s),e.texParameteri(this._type,10242,l),e.texParameteri(this._type,10243,l),this.mipmap&&e.generateMipmap(this._type)):(-1!==o||(o=9729),-1!==s||(s=9729),e.texParameteri(this._type,10241,o),e.texParameteri(this._type,10240,s),e.texParameteri(this._type,10242,33071),e.texParameteri(this._type,10243,33071)),r&&a&&F.bindTexture(e,r,a),this.memorySize=h?n*i*4*(1+1/3)*this._texCount:n*i*4*this._texCount},n.recreateResource=function(){this._createWebGlTexture(),this.completeCreate()},n.disposeResource=function(){this._source&&(b.mainContext.deleteTexture(this._source),this._source=null,this.memorySize=0)},o(t,["magentaTexture",function(){return this.magentaTexture=new t(new Ft(1,0,1,1))},"grayTexture",function(){return this.grayTexture=new t(new Ft(.5,.5,.5,1))}]),t}(),ui=function(e){function i(e,t,n,r){this._canRead=!1,this._image=null,this._pixels=null,void 0===e&&(e=!1),void 0===t&&(t=!0),void 0===n&&(n=6408),void 0===r&&(r=!0),i.__super.call(this),this._type=3553,this._repeat=t,this._canRead=e,this._format=n,this._mipmap=r}s(i,"laya.d3.resource.Texture2D",Tn);var t=i.prototype;return t._createWebGlTexture=function(){if(!this._image)throw"create GLTextur err:no data:"+this._image;var e=b.mainContext,t=this._source=e.createTexture(),n=this._width,i=this._height,r=F.curBindTexTarget,a=F.curBindTexValue;switch(F.bindTexture(e,this._type,t),this._format){case 6407:case 6408:this._canRead?e.texImage2D(this._type,0,this._format,n,i,0,this._format,5121,this._pixels):e.texImage2D(this._type,0,this._format,this._format,5121,this._image);break;case b.compressEtc1.COMPRESSED_RGB_ETC1_WEBGL:e.compressedTexImage2D(this._type,0,this._format,this._width,this._height,0,this._image)}var o=this._minFifter,s=this._magFifter,l=this._repeat?10497:33071,h=c.isPOT(n,i);h?(this._mipmap?-1!==o||(o=9987):-1!==o||(o=9729),-1!==s||(s=9729),e.texParameteri(this._type,10241,o),e.texParameteri(this._type,10240,s),e.texParameteri(this._type,10242,l),e.texParameteri(this._type,10243,l),this._mipmap&&e.generateMipmap(this._type)):(-1!==o||(o=9729),-1!==s||(s=9729),e.texParameteri(this._type,10241,o),e.texParameteri(this._type,10240,s),e.texParameteri(this._type,10242,33071),e.texParameteri(this._type,10243,33071)),r&&a&&F.bindTexture(e,r,a),this._image.onload=null,this._image=null,this.memorySize=h?n*i*4*(1+1/3):n*i*4},t.recreateResource=function(){this._createWebGlTexture(),this.completeCreate()},t.onAsynLoaded=function(e,t,i){if(i){var r=i[0];void 0!==r&&(this._canRead=r);var a=i[1];void 0!==a&&(this._repeat=a);var o=i[2];void 0!==o&&(this._format=o);var s=i[3];void 0!==s&&(this._mipmap=s)}switch(this._format){case 6407:case 6408:this._image=t;var l=t.width,h=t.height;this._width=l,this._height=h,this._size=new $t(l,h),this._canRead&&(A.isConchApp?t instanceof n.HTMLElement&&(this._pixels=new Uint8Array(t.getImageData(0,0,l,h))):(m.canvas.size(l,h),m.canvas.clear(),m.context.drawImage(t,0,0,l,h),this._pixels=new Uint8Array(m.context.getImageData(0,0,l,h).data.buffer)));break;case b.compressEtc1.COMPRESSED_RGB_ETC1_WEBGL:var _=new v(t);_.readUTFBytes(4),_.readUTFBytes(2),_.getInt16(),_.endian="bigEndian",this._width=_.getInt16(),this._height=_.getInt16(),this._size=new $t(this._width,this._height),_.getInt16(),_.getInt16(),this._image=new Uint8Array(t,_.pos)}this.recreateResource(),this._endLoaded()},t.getPixels=function(){if(this._canRead)return this._pixels;throw new Error("Texture2D: must set texture canRead is true.")},t.disposeResource=function(){this._source&&(b.mainContext.deleteTexture(this._source),this._source=null,this._image=null,this.memorySize=0)},l(0,t,"_src",function(){return this.url}),l(0,t,"src",function(){return this.url}),i.load=function(e){return a.loader.create(e,null,null,i)},i}(),ci=function(e){function t(){t.__super.call(this),this._type=34067}s(t,"laya.d3.resource.TextureCube",Tn);var n=t.prototype;return n._onTextureLoaded=function(e){this._images=e;for(var t=2147483647,n=2147483647,i=0;i<6;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 $t(t,n)},n._createWebGlTexture=function(){var e=0;for(e=0;e<6;e++)if(!this._images[e])throw"create GLTextur err:no data:"+this._images[e];var t=b.mainContext,n=this._source=t.createTexture(),i=this._width,r=this._height,a=F.curBindTexTarget,o=F.curBindTexValue;F.bindTexture(t,this._type,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 s=this.minFifter,l=this.magFifter,h=this._repeat?10497:33071,_=c.isPOT(i,r);for(_?(this.mipmap?-1!==s||(s=9987):-1!==s||(s=9729),-1!==l||(l=9729),t.texParameteri(this._type,10241,s),t.texParameteri(this._type,10240,l),t.texParameteri(this._type,10242,h),t.texParameteri(this._type,10243,h),this.mipmap&&t.generateMipmap(this._type)):(-1!==s||(s=9729),-1!==l||(l=9729),t.texParameteri(this._type,10241,s),t.texParameteri(this._type,10240,l),t.texParameteri(this._type,10242,33071),t.texParameteri(this._type,10243,33071)),a&&o&&F.bindTexture(t,a,o),e=0;e<6;e++)this._images[e].onload=null,this._images[e]=null;this.memorySize=_?i*r*4*(1+1/3)*6:i*r*4*6},n.recreateResource=function(){null!=this._url&&(this._createWebGlTexture(),this.completeCreate())},n.onAsynLoaded=function(e,t,n){this._onTextureLoaded(t),this.activeResource(),this._endLoaded()},n.disposeResource=function(){this._source&&(b.mainContext.deleteTexture(this._source),this._source=null,this.memorySize=0)},l(0,n,"defaulteTexture",function(){return _i.grayTexture}),t.load=function(e){return a.loader.create(e,null,null,t)},t}(),di=function(e){function t(e){this._hasIndependentBound=!0,t.__super.call(this,e),this._owner.transform.off("worldmatrixneedchanged",this,this._onWorldMatNeedChange),this._cacheAnimationNodeIndex=[],this._cacheAnimationNode=[],this._localBoundingBoxCorners=h(8,null),this._owner.meshFilter.on("meshchanged",this,this._$3__onMeshChanged)}s(t,"laya.d3.core.SkinnedMeshRender",e);var n=t.prototype;return n._getCacheAnimationNodes=function(){var e=this._cacheMesh._boneNames,t=e.length;this._cacheAnimationNode.length=t,this._cacheAnimationNodeIndex.length=t;for(var n=this._cacheAnimator._avatarNodes,i=this._cacheAnimator._avatarNodeMap,r=0;r<t;r++){var a=i[e[r]];this._cacheAnimationNode[r]=a,this._cacheAnimationNodeIndex[r]=n.indexOf(a)}},n._offComputeBoneIndexToMeshEvent=function(e,t){e.loaded?t.loaded||t.off("loaded",this,this._getCacheAnimationNodes):e.off("loaded",this,this._computeBoneIndexToMeshWithAsyncMesh)},n._computeBoneIndexToMeshWithAsyncAvatar=function(){this._cacheAvatar.loaded?this._computeBoneIndexToMeshWithAsyncMesh():this._cacheAvatar.once("loaded",this,this._computeBoneIndexToMeshWithAsyncMesh)},n._computeBoneIndexToMeshWithAsyncMesh=function(){this._cacheMesh.loaded?this._getCacheAnimationNodes():this._cacheMesh.on("loaded",this,this._getCacheAnimationNodes)},n._$3__onMeshChanged=function(e,t,n){this._cacheMesh=n,t&&!t.loaded&&n.off("loaded",this,this._onMeshLoaded),n.loaded?this._onMeshLoaded(n):n.on("loaded",this,this._onMeshLoaded),this._cacheAvatar&&(t&&this._offComputeBoneIndexToMeshEvent(this._cacheAvatar,t),n&&this._computeBoneIndexToMeshWithAsyncAvatar())},n._onMeshLoaded=function(e){var t=e.subMeshCount;this._subSkinnedDatas=[],this._subSkinnedDatas.length=t;for(var n=0;n<t;n++)for(var i=this._subSkinnedDatas[n]=[],r=e.getSubMesh(n)._boneIndicesList,a=0,o=r.length;a<o;a++)i[a]=new Float32Array(16*r[a].length)},n._setCacheAnimator=function(e){this._cacheAnimator=e,this._rootBone&&(this._rootIndex=e._avatarNodes.indexOf(e._avatarNodeMap[this._rootBone]))},n._setRootBone=function(e){this._rootBone=e,this._cacheAnimator&&(this._rootIndex=this._cacheAnimator._avatarNodes.indexOf(this._cacheAnimator._avatarNodeMap[e]))},n._setCacheAvatar=function(e){this._cacheAvatar!==e&&(this._cacheMesh?(this._cacheAvatar&&this._offComputeBoneIndexToMeshEvent(this._cacheAvatar,this._cacheMesh),this._cacheAvatar=e,e&&(this._addShaderDefine(Si.SHADERDEFINE_BONE),this._computeBoneIndexToMeshWithAsyncAvatar())):this._cacheAvatar=e)},n._calculateBoundingBox=function(){if(this._hasIndependentBound){if(this._cacheAnimator){var t=this._owner.transform,n=t.worldMatrix;if(this._cacheAnimator._canCache){var i=this._cacheAnimator._curAvatarNodeDatas;Jt.matrix4x4MultiplyMFM(this._cacheAnimator.owner.transform.worldMatrix,i[this._rootIndex],n)}else Jt.matrix4x4MultiplyMFM(this._cacheAnimator.owner.transform.worldMatrix,this._cacheAnimator._avatarNodeMap[this._rootBone].transform.getWorldMatrix(),n);t.worldMatrix=n,null==this._cacheAnimator._avatarNodeMap[this._rootBone]||null==this._localBoundBox?this._boundingBox.toDefault():this._calculateBoundBoxByInitCorners(this._localBoundingBoxCorners)}}else e.prototype._calculateBoundingBox.call(this)},n._calculateBoundingSphere=function(){if(this._hasIndependentBound){if(this._cacheAnimator){var t=this._owner.transform,n=t.worldMatrix;if(this._cacheAnimator._canCache){var i=this._cacheAnimator._curAvatarNodeDatas;Jt.matrix4x4MultiplyMFM(this._cacheAnimator.owner.transform.worldMatrix,i[this._rootIndex],n)}else Jt.matrix4x4MultiplyMFM(this._cacheAnimator.owner.transform.worldMatrix,this._cacheAnimator._avatarNodeMap[this._rootBone].transform.getWorldMatrix(),n);t.worldMatrix=n,null==this._cacheAnimator._avatarNodeMap[this._rootBone]||null==this.localBoundSphere?this._boundingSphere.toDefault():this._calculateBoundingSphereByInitSphere(this.localBoundSphere)}}else e.prototype._calculateBoundingSphere.call(this)},n._updateOctreeNode=function(){var e=this._treeNode;e&&e.updateObject(this)},n._renderUpdate=function(e){var n,i=this._cacheAnimator,r=this._cacheMesh.subMeshCount,a=this._owner.transform;if(i){var o=i._canCache,s=this._cacheAnimator._curAvatarNodeDatas,l=i.owner;if(this._setShaderValueMatrix4x4(0,l._transform.worldMatrix),n=l.getProjectionViewWorldMatrix(e),this._setShaderValueMatrix4x4(1,n),this._cacheMesh&&this._cacheMesh.loaded&&this._cacheAvatar&&this._cacheAvatar.loaded){var h=0,_=0,u=this._cacheMesh._inverseBindPoses,c=this._cacheMesh._skinnedDatas;if(o)for(h=0,_=u.length;h<_;h++)Jt._mulMatrixArray(s[this._cacheAnimationNodeIndex[h]],u[h],c,16*h);else for(h=0,_=u.length;h<_;h++)Jt._mulMatrixArray(this._cacheAnimationNode[h].transform.getWorldMatrix(),u[h],c,16*h);for(h=0;h<r;h++){for(var d=this._cacheMesh.getSubMesh(h)._boneIndicesList,f=d.length,m=this._subSkinnedDatas[h],p=0;p<f;p++)t._splitAnimationDatas(d[p],c,m[p]);this._renderElements[h]._skinAnimationDatas=m}}}else this._setShaderValueMatrix4x4(0,a.worldMatrix),n=this._owner.getProjectionViewWorldMatrix(e),this._setShaderValueMatrix4x4(1,n);return en.debugMode&&this._renderRenderableBoundBox(),!0},l(0,n,"localBoundBox",function(){return this._localBoundBox},function(e){this._localBoundBox=e,e.getCorners(this._localBoundingBoxCorners)}),l(0,n,"boundingSphere",function(){return this._calculateBoundingSphere(),this._boundingSphere}),l(0,n,"boundingBox",function(){return this._calculateBoundingBox(),this._boundingBox}),l(0,n,"boundingBoxCenter",function(){var e=this.boundingBox;return bt.add(e.min,e.max,this._boundingBoxCenter),bt.scale(this._boundingBoxCenter,.5,this._boundingBoxCenter),this._boundingBoxCenter}),t._splitAnimationDatas=function(e,t,n){for(var i=0,r=e.length,a=0;i<r;i++)for(var o=e[i]<<4,s=0;s<16;s++,a++)n[a]=t[o+s]},t}(On),fi=function(e){function t(e,n){t.__super.call(this),void 0===e&&(e=.3),void 0===n&&(n=1e3),this._tempVector3=new bt,this._position=new bt,this._up=new bt,this._forward=new bt,this._right=new bt,this._fieldOfView=60,this._useUserProjectionMatrix=!1,this._orthographic=!1,this._viewportExpressedInClipSpace=!0,this._renderTargetSize=$t.fullScreen,this._orthographicVerticalSize=10,this.renderingOrder=0,this._nearPlane=e,this._farPlane=n,this.cullingMask=2147483647,this.clearFlag=0,this.useOcclusionCulling=!0,this._calculateProjectionMatrix(),a.stage.on("resize",this,this._onScreenSizeChanged)}s(t,"laya.d3.core.BaseCamera",e);var n=t.prototype;return n._sortCamerasByRenderingOrder=function(){if(this._displayedInStage)for(var e=this.scene._cameraPool,t=e.length-1,n=0;n<t;n++)if(e[n].renderingOrder>e[t].renderingOrder){var i=e[n];e[n]=e[t],e[t]=i}},n._calculateProjectionMatrix=function(){},n._onScreenSizeChanged=function(){this._calculateProjectionMatrix()},n._prepareCameraToRender=function(){Z._currentCameraCullingMask=this.cullingMask;var e=this._shaderValues;e.setValue(0,this.transform.position.elements),e.setValue(5,this.forward.elements),e.setValue(6,this.up.elements)},n._prepareCameraViewProject=function(e,t){var n=this._shaderValues;n.setValue(1,e.elements),n.setValue(2,t.elements)},n._renderCamera=function(e,t,n){},n.addLayer=function(e){29!==e.number&&30!=e.number&&(this.cullingMask=this.cullingMask|e.mask)},n.removeLayer=function(e){29!==e.number&&30!=e.number&&(this.cullingMask=this.cullingMask&~e.mask)},n.addAllLayers=function(){this.cullingMask=2147483647},n.removeAllLayers=function(){this.cullingMask=0|Z.getLayerByNumber(29).mask|Z.getLayerByNumber(30).mask},n.ResetProjectionMatrix=function(){this._useUserProjectionMatrix=!1,this._calculateProjectionMatrix()},n.moveForward=function(e){this._tempVector3.elements[0]=this._tempVector3.elements[1]=0,this._tempVector3.elements[2]=e,this.transform.translate(this._tempVector3)},n.moveRight=function(e){this._tempVector3.elements[1]=this._tempVector3.elements[2]=0,this._tempVector3.elements[0]=e,this.transform.translate(this._tempVector3)},n.moveVertical=function(e){this._tempVector3.elements[0]=this._tempVector3.elements[2]=0,this._tempVector3.elements[1]=e,this.transform.translate(this._tempVector3,!1)},n._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),this.scene.conchModel&&this.scene.conchModel.setCurrentCamera(this.conchModel)},n._clearSelfRenderObjects=function(){var e=this.scene._cameraPool;e.splice(e.indexOf(this),1)},n.destroy=function(t){void 0===t&&(t=!0),this._sky&&this._sky.destroy(),this.renderTarget=null,a.stage.off("resize",this,this._onScreenSizeChanged),e.prototype.destroy.call(this,t)},l(0,n,"sky",function(){return this._sky},function(e){this._sky=e,e._ownerCamera=this}),l(0,n,"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}),l(0,n,"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}),l(0,n,"renderTarget",function(){return this._renderTarget},function(e){this._renderTarget=e,null!=e&&(this._renderTargetSize=e.size)}),l(0,n,"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}),l(0,n,"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}),l(0,n,"renderTargetSize",function(){return this._renderTargetSize},function(e){null!=this.renderTarget&&this._renderTargetSize,this._renderTargetSize=e,this._calculateProjectionMatrix()}),l(0,n,"fieldOfView",function(){return this._fieldOfView},function(e){this._fieldOfView=e,this._calculateProjectionMatrix()}),l(0,n,"nearPlane",function(){return this._nearPlane},function(e){this._nearPlane=e,this._calculateProjectionMatrix()}),l(0,n,"farPlane",function(){return this._farPlane},function(e){this._farPlane=e,this._calculateProjectionMatrix()}),l(0,n,"orthographic",function(){return this._orthographic},function(e){this._orthographic=e,this._calculateProjectionMatrix()}),l(0,n,"orthographicVerticalSize",function(){return this._orthographicVerticalSize},function(e){this._orthographicVerticalSize=e,this._calculateProjectionMatrix()}),l(0,n,"renderingOrder",function(){return this._renderingOrder},function(e){this._renderingOrder=e,this._sortCamerasByRenderingOrder()}),t.CAMERAPOS=0,t.VIEWMATRIX=1,t.PROJECTMATRIX=2,t.VPMATRIX=3,t.VPMATRIX_NO_TRANSLATE=4,t.CAMERADIRECTION=5,t.CAMERAUP=6,t.ENVIRONMENTDIFFUSE=7,t.ENVIRONMENTSPECULAR=8,t.SIMLODINFO=9,t.DIFFUSEIRRADMATR=10,t.DIFFUSEIRRADMATG=11,t.DIFFUSEIRRADMATB=12,t.HDREXPOSURE=13,t.RENDERINGTYPE_DEFERREDLIGHTING="DEFERREDLIGHTING",t.RENDERINGTYPE_FORWARDRENDERING="FORWARDRENDERING",t.CLEARFLAG_SOLIDCOLOR=0,t.CLEARFLAG_SKY=1,t.CLEARFLAG_DEPTHONLY=2,t.CLEARFLAG_NONE=3,o(t,["_invertYScaleMatrix",function(){return this._invertYScaleMatrix=new Ct(1,0,0,0,0,-1,0,0,0,0,1,0,0,0,0,1)},"_invertYProjectionMatrix",function(){return this._invertYProjectionMatrix=new Ct},"_invertYProjectionViewMatrix",function(){return this._invertYProjectionViewMatrix=new Ct}]),t}(Hn),mi=function(e){function t(e){this._render=null,this._geometryFilter=null,t.__super.call(this,e)}s(t,"laya.d3.core.RenderableSprite3D",e);var n=t.prototype;return n._addToInitStaticBatchManager=function(){},n._setBelongScene=function(t){e.prototype._setBelongScene.call(this,t),t._renderableSprite3Ds.push(this),this._render._applyLightMapParams()},n._setUnBelongScene=function(){var t=this._scene._renderableSprite3Ds,n=t.indexOf(this);t.splice(n,1),this._render._removeShaderDefine(laya.d3.core.RenderableSprite3D.SAHDERDEFINE_LIGHTMAP),e.prototype._setUnBelongScene.call(this)},n._update=function(e){e.owner=this,this._activeInHierarchy&&(this._updateComponents(e),this._render._updateOctreeNode(),this._lateUpdateComponents(e),w.spriteCount++,this._childs.length&&this._updateChilds(e))},n.destroy=function(t){void 0===t&&(t=!0),e.prototype.destroy.call(this,t),this._render._destroy(),this._render=null},t.__init__=function(){t.SHADERDEFINE_SCALEOFFSETLIGHTINGMAPUV=t.shaderDefines.registerDefine("SCALEOFFSETLIGHTINGMAPUV"),t.SAHDERDEFINE_LIGHTMAP=t.shaderDefines.registerDefine("LIGHTMAP")},t.SHADERDEFINE_SCALEOFFSETLIGHTINGMAPUV=2,t.SAHDERDEFINE_LIGHTMAP=4,t.LIGHTMAPSCALEOFFSET=2,t.LIGHTMAP=3,o(t,["shaderDefines",function(){return this.shaderDefines=new Gt}]),t}(Hn),pi=function(e){function t(){this._intensityColor=null,this._intensity=NaN,this._shadow=!1,this._shadowFarPlane=0,this._shadowMapSize=0,this._shadowMapCount=0,this._shadowMapPCFType=0,this._parallelSplitShadowMap=null,this._lightmapBakedType=0,this.color=null,t.__super.call(this),this._intensity=1,this._intensityColor=new bt,this.color=new bt(1,1,1),this._shadow=!1,this._shadowFarPlane=8,this._shadowMapSize=512,this._shadowMapCount=1,this._shadowMapPCFType=0,this._lightmapBakedType=t.LIGHTMAPBAKEDTYPE_REALTIME}s(t,"laya.d3.core.light.LightSprite",Hn);var n=t.prototype;return n._parseCustomProps=function(e,t,n,i){var r=n.color,a=this.color.elements;a[0]=r[0],a[1]=r[1],a[2]=r[2]},n._addSelfRenderObjects=function(){this.lightmapBakedType!==t.LIGHTMAPBAKEDTYPE_BAKED&&this._scene._addLight(this)},n._clearSelfRenderObjects=function(){this.lightmapBakedType!==t.LIGHTMAPBAKEDTYPE_BAKED&&this._scene._removeLight(this)},n._prepareToScene=function(e){return!1},l(0,n,"lightmapBakedType",function(){return this._lightmapBakedType},function(e){this._lightmapBakedType!==e&&(this._lightmapBakedType=e,this._activeInHierarchy&&(e!==t.LIGHTMAPBAKEDTYPE_BAKED?this._scene._addLight(this):this._scene._removeLight(this)))}),l(0,n,"shadowPCFType",function(){return this._shadowMapPCFType},function(e){this._shadowMapPCFType=e,this._parallelSplitShadowMap&&this._parallelSplitShadowMap.setPCFType(e)}),l(0,n,"intensity",function(){return this._intensity},function(e){this._intensity=e}),l(0,n,"shadow",function(){return this._shadow},function(e){throw new Error("LightSprite: must override it.")}),l(0,n,"shadowDistance",function(){return this._shadowFarPlane},function(e){this._shadowFarPlane=e,this._parallelSplitShadowMap&&this._parallelSplitShadowMap.setFarDistance(e)}),l(0,n,"shadowPSSMCount",function(){return this._shadowMapCount},function(e){this._shadowMapCount=e,this._parallelSplitShadowMap&&(this._parallelSplitShadowMap.PSSMNum=e)}),l(0,n,"shadowResolution",function(){return this._shadowMapSize},function(e){this._shadowMapSize=e,this._parallelSplitShadowMap&&this._parallelSplitShadowMap.setShadowMapTextureSize(e)}),l(0,n,"diffuseColor",function(){return console.log("LightSprite: discard property,please use color property instead."),this.color},function(e){console.log("LightSprite: discard property,please use color property instead."),this.color=e}),t.LIGHTMAPBAKEDTYPE_REALTIME=0,t.LIGHTMAPBAKEDTYPE_MIXED=1,t.LIGHTMAPBAKEDTYPE_BAKED=2,t}(),vi=function(e){function t(e){this._terrainRes=null,this._lightmapScaleOffset=null,t.__super.call(this),this._lightmapScaleOffset=new Ft(1,1,0,0),e&&(this._terrainRes=e,e.loaded?this.buildTerrain(e):e.once("loaded",this,this.buildTerrain))}s(t,"laya.d3.terrain.Terrain",Hn);var n=t.prototype;return n._parseCustomProps=function(e,t,n,i){this.terrainRes=S.getRes(t[n.dataPath]);var r=n.lightmapIndex;null!=r&&this.setLightmapIndex(r);var a=n.lightmapScaleOffset;a&&this.setLightmapScaleOffset(new Ft(a[0],a[1],a[2],a[3]))},n.setLightmapIndex=function(e){for(var t=0;t<this._childs.length;t++)this._childs[t].terrainRender.lightmapIndex=e},n.setLightmapScaleOffset=function(e){if(e){e.cloneTo(this._lightmapScaleOffset);for(var t=0;t<this._childs.length;t++)this._childs[t].terrainRender.lightmapScaleOffset=this._lightmapScaleOffset}},n.disableLight=function(){for(var e=0,t=this._childs.length;e<t;e++)for(var n=this._childs[e],i=0,r=n._render.sharedMaterials.length;i<r;i++)n._render.sharedMaterials[i].disableLight()},n.buildTerrain=function(e){for(var t=e._chunkNumX,n=e._chunkNumZ,i=e._heightData,r=0,a=0;a<n;a++)for(var o=0;o<t;o++){for(var s=new Mi(o,a,e._gridSize,i._terrainHeightData,i._width,i._height,e._cameraCoordinateInverse),l=e._chunkInfos[r++],h=0;h<l.alphaMap.length;h++){var _=l.detailID[h].length,u=_>0?e._detailTextureInfos[l.detailID[h][0]].diffuseTexture:null,c=_>1?e._detailTextureInfos[l.detailID[h][1]].diffuseTexture:null,d=_>2?e._detailTextureInfos[l.detailID[h][2]].diffuseTexture:null,f=_>3?e._detailTextureInfos[l.detailID[h][3]].diffuseTexture:null,m=_>0?e._detailTextureInfos[l.detailID[h][0]].scale:null,p=_>1?e._detailTextureInfos[l.detailID[h][1]].scale:null,v=_>2?e._detailTextureInfos[l.detailID[h][2]].scale:null,E=_>3?e._detailTextureInfos[l.detailID[h][3]].scale:null;s.buildRenderElementAndMaterial(_,l.normalMap,l.alphaMap[h],u,c,d,f,e._materialInfo.ambientColor,e._materialInfo.diffuseColor,e._materialInfo.specularColor,m?m.x:1,m?m.y:1,p?p.x:1,p?p.y:1,v?v.x:1,v?v.y:1,E?E.x:1,E?E.y:1)}s.terrainRender.receiveShadow=!0,s.terrainRender.lightmapScaleOffset=this._lightmapScaleOffset,this.addChild(s)}},n.width=function(){return this._terrainRes._chunkNumX*Xt.CHUNK_GRID_NUM*this._terrainRes._gridSize},n.depth=function(){return this._terrainRes._chunkNumZ*Xt.CHUNK_GRID_NUM*this._terrainRes._gridSize},n.getHeightXZ=function(e,n){if(!this._terrainRes||!this._terrainRes.loaded)return NaN;if(e-=this.transform.position.x,n-=this.transform.position.z,t.__VECTOR3__||(t.__VECTOR3__=new bt),t.__VECTOR3__.elements[0]=e,t.__VECTOR3__.elements[1]=0,t.__VECTOR3__.elements[2]=n,bt.transformV3ToV3(t.__VECTOR3__,Xt.__ADAPT_MATRIX_INV__,t.__VECTOR3__),e=t.__VECTOR3__.elements[0],n=t.__VECTOR3__.elements[2],e<0||e>this.width()||n<0||n>this.depth())return NaN;var i=this._terrainRes._gridSize,r=parseInt(""+e/i),a=parseInt(""+n/i),o=e-r*i,s=n-a*i,l=NaN,h=this._terrainRes._heightData;return o+s>i?(l=h._terrainHeightData[(a+1-1)*h._width+r+1])+(h._terrainHeightData[(a+1-1)*h._width+r]-l)*((i-o)/i)+(h._terrainHeightData[(a-1)*h._width+r+1]-l)*((i-s)/i):(l=h._terrainHeightData[Math.max(0,a-1)*h._width+r])+(h._terrainHeightData[Math.min(h._width*h._height-1,(a+1-1)*h._width+r)]-l)*(s/i)+(h._terrainHeightData[Math.min(h._width*h._height-1,Math.max(0,a-1)*h._width+r+1)]-l)*(o/i)},l(0,n,"terrainRes",null,function(e){e&&(this._terrainRes=e,e.loaded?this.buildTerrain(e):e.once("loaded",this,this.buildTerrain))}),t.load=function(e){return a.loader.create(e,null,null,t,null,1,!1)},t.RENDER_LINE_MODEL=!1,t.LOD_TOLERANCE_VALUE=4,t.LOD_DISTANCE_FACTOR=2,t.__VECTOR3__=null,t}(),Ei=(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.activeResource(),this._positions=this._getPositions(),this._generateBoundingObject()}s(t,"laya.d3.resource.models.BoxMesh",oi);var n=t.prototype;n.recreateResource=function(){this._numberVertices=24,this._numberIndices=36;var e=et.vertexDeclaration,t=(e.vertexStride,this._long/2),n=this._height/2,i=this._width/2,r=new Float32Array([-t,n,-i,0,1,0,0,0,t,n,-i,0,1,0,1,0,t,n,i,0,1,0,1,1,-t,n,i,0,1,0,0,1,-t,-n,-i,0,-1,0,0,1,t,-n,-i,0,-1,0,1,1,t,-n,i,0,-1,0,1,0,-t,-n,i,0,-1,0,0,0,-t,n,-i,-1,0,0,0,0,-t,n,i,-1,0,0,1,0,-t,-n,i,-1,0,0,1,1,-t,-n,-i,-1,0,0,0,1,t,n,-i,1,0,0,1,0,t,n,i,1,0,0,0,0,t,-n,i,1,0,0,0,1,t,-n,-i,1,0,0,1,1,-t,n,i,0,0,1,0,0,t,n,i,0,0,1,1,0,t,-n,i,0,0,1,1,1,-t,-n,i,0,0,1,0,1,-t,n,-i,0,0,-1,1,0,t,n,-i,0,0,-1,0,0,t,-n,-i,0,0,-1,0,1,-t,-n,-i,0,0,-1,1,1]),a=new Uint16Array([0,1,2,2,3,0,4,7,6,6,5,4,8,9,10,10,11,8,12,15,14,14,13,12,16,17,18,18,19,16,20,23,22,22,21,20]);this._vertexBuffer=new $n(e,this._numberVertices,35044,!0),this._indexBuffer=new Qn("ushort",this._numberIndices,35044,!0),this._vertexBuffer.setData(r),this._indexBuffer.setData(a),this.memorySize=2*(this._vertexBuffer._byteLength+this._indexBuffer._byteLength),this.completeCreate()},l(0,n,"long",function(){return this._long},function(e){this._long!==e&&(this._long=e,this.releaseResource(),this.activeResource())}),l(0,n,"width",function(){return this._width},function(e){this._width!==e&&(this._width=e,this.releaseResource(),this.activeResource())}),l(0,n,"height",function(){return this._height},function(e){this._height!==e&&(this._height=e,this.releaseResource(),this.activeResource())})}(),function(e){function t(e,n,i,r){this._radius=NaN,this._height=NaN,this._slices=0,this._stacks=0,void 0===e&&(e=.5),void 0===n&&(n=2),void 0===i&&(i=16),void 0===r&&(r=32),t.__super.call(this),this._radius=e,this._height=n<2*e?2*e:n,this._stacks=i,this._slices=r,this.recreateResource(),this._positions=this._getPositions(),this._generateBoundingObject()}s(t,"laya.d3.resource.models.CapsuleMesh",oi);var n=t.prototype;n.recreateResource=function(){this._numberVertices=(this._stacks+1)*(this.slices+1)*2+2*(this._slices+1),this._numberIndices=3*this._stacks*(this._slices+1)*2*2+2*this._slices*3;var e=et.vertexDeclaration,t=e.vertexStride/4,n=new Float32Array(this._numberVertices*t),i=new Uint16Array(this._numberIndices),r=Math.PI/2/this._stacks,a=2*Math.PI/this._slices,o=this._height/2-this._radius,s=0,l=0,h=0,_=0,u=0,c=0,d=0,f=0;for(d=0;d<=this._stacks;d++)for(f=0;f<=this._slices;f++)s=this._radius*Math.cos(d*r)*Math.cos(f*a+Math.PI),l=this._radius*Math.sin(d*r),h=this._radius*Math.cos(d*r)*Math.sin(f*a+Math.PI),n[_++]=s,n[_++]=l+o,n[_++]=h,n[_++]=s,n[_++]=l,n[_++]=h,n[_++]=1-f/this._slices,n[_++]=(1-d/this._stacks)*(Math.PI*this._radius/2/(this._height+Math.PI*this._radius)),d<this._stacks&&(i[u++]=d*(this._slices+1)+f+(this._slices+1),i[u++]=d*(this._slices+1)+f,i[u++]=d*(this._slices+1)+f+1,i[u++]=d*(this._slices+1)+f+this._slices,i[u++]=d*(this._slices+1)+f,i[u++]=d*(this._slices+1)+f+(this._slices+1));for(c+=(this._stacks+1)*(this._slices+1),d=0;d<=this._stacks;d++)for(f=0;f<=this._slices;f++)s=this._radius*Math.cos(d*r)*Math.cos(f*a+Math.PI),l=this._radius*Math.sin(-d*r),h=this._radius*Math.cos(d*r)*Math.sin(f*a+Math.PI),n[_++]=s,n[_++]=l-o,n[_++]=h,n[_++]=s,n[_++]=l,n[_++]=h,n[_++]=1-f/this._slices,n[_++]=(d/this._stacks*(Math.PI*this._radius/2)+(this._height+Math.PI*this._radius/2))/(this._height+Math.PI*this._radius),d<this._stacks&&(i[u++]=c+d*(this._slices+1)+f,i[u++]=c+d*(this._slices+1)+f+(this._slices+1),i[u++]=c+d*(this._slices+1)+f+1,i[u++]=c+d*(this._slices+1)+f,i[u++]=c+d*(this._slices+1)+f+this._slices,i[u++]=c+d*(this._slices+1)+f+(this._slices+1));for(c+=(this._stacks+1)*(this._slices+1),f=0;f<=this._slices;f++)s=this._radius*Math.cos(f*a+Math.PI),l=o,h=this._radius*Math.sin(f*a+Math.PI),n[_++]=s,n[_+8*(this._slices+1)-1]=s,n[_++]=l,n[_+8*(this._slices+1)-1]=-l,n[_++]=h,n[_+8*(this._slices+1)-1]=h,n[_++]=s,n[_+8*(this._slices+1)-1]=s,n[_++]=0,n[_+8*(this._slices+1)-1]=0,n[_++]=h,n[_+8*(this._slices+1)-1]=h,n[_++]=1-1*f/this._slices,n[_+8*(this._slices+1)-1]=1-1*f/this._slices,n[_++]=Math.PI*this._radius/2/(this._height+Math.PI*this._radius),n[_+8*(this._slices+1)-1]=(Math.PI*this._radius/2+this._height)/(this._height+Math.PI*this._radius);for(f=0;f<this._slices;f++)i[u++]=f+c+(this._slices+1),i[u++]=f+c+1,i[u++]=f+c,i[u++]=f+c+(this._slices+1),i[u++]=f+c+(this._slices+1)+1,i[u++]=f+c+1;c+=2*(this._slices+1),this._vertexBuffer=new $n(e,this._numberVertices,35044,!0),this._indexBuffer=new Qn("ushort",this._numberIndices,35044,!0),this._vertexBuffer.setData(n),this._indexBuffer.setData(i),this.memorySize=2*(this._vertexBuffer._byteLength+this._indexBuffer._byteLength),this.completeCreate()},l(0,n,"radius",function(){return this._radius},function(e){this._radius!==e&&(this._radius=e,this.releaseResource(),this.activeResource())}),l(0,n,"height",function(){return this._height},function(e){this._height!==e&&(this._height=e,this.releaseResource(),this.activeResource())}),l(0,n,"stacks",function(){return this._stacks},function(e){this._stacks!==e&&(this._stacks=e,this.releaseResource(),this.activeResource())}),l(0,n,"slices",function(){return this._slices},function(e){this._slices!==e&&(this._slices=e,this.releaseResource(),this.activeResource())})}(),function(e){function t(e,n,i){this._radius=NaN,this._height=NaN,this._slices=0,void 0===e&&(e=.5),void 0===n&&(n=2),void 0===i&&(i=32),t.__super.call(this),this._radius=e,this._height=n,this._slices=i,this.recreateResource(),this._positions=this._getPositions(),this._generateBoundingObject()}s(t,"laya.d3.resource.models.CylinderMesh",oi);var n=t.prototype;n.recreateResource=function(){this._numberVertices=this._slices+1+1+2*(this._slices+1)+(this._slices+1+1),this._numberIndices=3*this._slices+6*this._slices+3*this._slices;for(var e=et.vertexDeclaration,t=e.vertexStride/4,n=new Float32Array(this._numberVertices*t),i=new Uint16Array(this._numberIndices),r=2*Math.PI/this._slices,a=this._height/2,o=0,s=0,l=0,h=0,_=0,u=0,c=0,d=0;d<=this._slices;d++)0===d&&(n[u++]=0,n[u++]=a,n[u++]=0,n[u++]=0,n[u++]=1,n[u++]=0,n[u++]=.5,n[u++]=.5),o=d*r,l=Math.cos(o)*this._radius,h=a,_=Math.sin(o)*this._radius,n[u++]=l,n[u++]=h,n[u++]=_,n[u++]=0,n[u++]=1,n[u++]=0,n[u++]=.5+.5*Math.cos(o),n[u++]=.5+.5*Math.sin(o);for(var f=0;f<this._slices;f++)i[c++]=0,i[c++]=f+1,i[c++]=f+2;s+=this._slices+1+1;for(var m=0;m<=this._slices;m++)o=m*r,l=Math.cos(o+Math.PI)*this._radius,h=a,_=Math.sin(o+Math.PI)*this._radius,n[u++]=l,n[u+8*(this._slices+1)-1]=l,n[u++]=h,n[u+8*(this._slices+1)-1]=-h,n[u++]=_,n[u+8*(this._slices+1)-1]=_,n[u++]=l,n[u+8*(this._slices+1)-1]=l,n[u++]=0,n[u+8*(this._slices+1)-1]=0,n[u++]=_,n[u+8*(this._slices+1)-1]=_,n[u++]=1-1*m/this._slices,n[u+8*(this._slices+1)-1]=1-1*m/this._slices,n[u++]=0,n[u+8*(this._slices+1)-1]=1;u+=8*(this._slices+1);for(var p=0;p<this._slices;p++)i[c++]=p+s+(this._slices+1),i[c++]=p+s+1,i[c++]=p+s,i[c++]=p+s+(this._slices+1),i[c++]=p+s+(this._slices+1)+1,i[c++]=p+s+1;s+=2*(this._slices+1);for(var v=0;v<=this._slices;v++)0===v&&(n[u++]=0,n[u++]=-a,n[u++]=0,n[u++]=0,n[u++]=-1,n[u++]=0,n[u++]=.5,n[u++]=.5),o=v*r,l=Math.cos(o+Math.PI)*this._radius,h=-a,_=Math.sin(o+Math.PI)*this._radius,n[u++]=l,n[u++]=h,n[u++]=_,n[u++]=0,n[u++]=-1,n[u++]=0,n[u++]=.5+.5*Math.cos(o),n[u++]=.5+.5*Math.sin(o);for(var E=0;E<this._slices;E++)i[c++]=0+s,i[c++]=E+2+s,i[c++]=E+1+s;s+=this._slices+1+1,this._vertexBuffer=new $n(e,this._numberVertices,35044,!0),this._indexBuffer=new Qn("ushort",this._numberIndices,35044,!0),this._vertexBuffer.setData(n),this._indexBuffer.setData(i),this.memorySize=2*(this._vertexBuffer._byteLength+this._indexBuffer._byteLength),this.completeCreate()},l(0,n,"radius",function(){return this._radius},function(e){this._radius!==e&&(this._radius=e,this.releaseResource(),this.activeResource())}),l(0,n,"height",function(){return this._height},function(e){this._height!==e&&(this._height=e,this.releaseResource(),this.activeResource())}),l(0,n,"slices",function(){return this._slices},function(e){this._slices!==e&&(this._slices=e,this.releaseResource(),this.activeResource())})}(),function(e){function t(e,n,i,r){this._long=NaN,this._width=NaN,this._stacks=0,this._slices=0,void 0===e&&(e=10),void 0===n&&(n=10),void 0===i&&(i=10),void 0===r&&(r=10),t.__super.call(this),this._long=e,this._width=n,this._stacks=i,this._slices=r,this.activeResource(),this._positions=this._getPositions(),this._generateBoundingObject()}s(t,"laya.d3.resource.models.PlaneMesh",oi);var n=t.prototype;n.recreateResource=function(){this._numberVertices=(this._stacks+1)*(this._slices+1),this._numberIndices=this._stacks*this._slices*2*3;for(var e=new Uint16Array(this._numberIndices),t=et.vertexDeclaration,n=t.vertexStride/4,i=new Float32Array(this._numberVertices*n),r=this._long/2,a=this._width/2,o=this._long/this._stacks,s=this._width/this._slices,l=0,h=0;h<=this._slices;h++)for(var _=0;_<=this._stacks;_++)i[l++]=_*o-r,i[l++]=0,i[l++]=h*s-a,i[l++]=0,i[l++]=1,i[l++]=0,i[l++]=1*_/this._stacks,i[l++]=1*h/this._slices;var u=0;for(h=0;h<this._slices;h++)for(_=0;_<this._stacks;_++)e[u++]=(h+1)*(this._stacks+1)+_,e[u++]=h*(this._stacks+1)+_,e[u++]=(h+1)*(this._stacks+1)+_+1,e[u++]=h*(this._stacks+1)+_,e[u++]=h*(this._stacks+1)+_+1,e[u++]=(h+1)*(this._stacks+1)+_+1;this._vertexBuffer=new $n(t,this._numberVertices,35044,!0),this._indexBuffer=new Qn("ushort",this._numberIndices,35044,!0),this._vertexBuffer.setData(i),this._indexBuffer.setData(e),this.memorySize=2*(this._vertexBuffer._byteLength+this._indexBuffer._byteLength),this.completeCreate()},l(0,n,"long",function(){return this._long},function(e){this._long!==e&&(this._long=e,this.releaseResource(),this.activeResource())}),l(0,n,"width",function(){return this._width},function(e){this._width!==e&&(this._width=e,this.releaseResource(),this.activeResource())}),l(0,n,"stacks",function(){return this._stacks},function(e){this._stacks!==e&&(this._stacks=e,this.releaseResource(),this.activeResource())}),l(0,n,"slices",function(){return this._slices},function(e){this._slices!==e&&(this._slices=e,this.releaseResource(),this.activeResource())})}(),function(e){function t(e,n){this._long=NaN,this._width=NaN,void 0===e&&(e=1),void 0===n&&(n=1),t.__super.call(this),this._long=e,this._width=n,this.activeResource(),this._positions=this._getPositions(),this._generateBoundingObject()}s(t,"laya.d3.resource.models.QuadMesh",oi);var n=t.prototype;n.recreateResource=function(){this._numberVertices=4,this._numberIndices=6;var e=et.vertexDeclaration,t=(e.vertexStride,this._long/2),n=this._width/2,i=new Float32Array([-t,n,0,0,0,1,0,0,t,n,0,0,0,1,1,0,-t,-n,0,0,0,1,0,1,t,-n,0,0,0,1,1,1]),r=new Uint16Array([0,1,2,3,2,1]);this._vertexBuffer=new $n(e,this._numberVertices,35044,!0),this._indexBuffer=new Qn("ushort",this._numberIndices,35044,!0),this._vertexBuffer.setData(i),this._indexBuffer.setData(r),this.memorySize=2*(this._vertexBuffer._byteLength+this._indexBuffer._byteLength),this.completeCreate()},l(0,n,"long",function(){return this._long},function(e){this._long!==e&&(this._long=e,this.releaseResource(),this.activeResource())}),l(0,n,"width",function(){return this._width},function(e){this._width!==e&&(this._width=e,this.releaseResource(),this.activeResource())})}(),function(e){function t(e,n,i){this._radius=NaN,this._slices=0,this._stacks=0,void 0===e&&(e=.5),void 0===n&&(n=32),void 0===i&&(i=32),t.__super.call(this),this._radius=e,this._stacks=n,this._slices=i,this.activeResource(),this._positions=this._getPositions(),this._generateBoundingObject()}s(t,"laya.d3.resource.models.SphereMesh",oi);var n=t.prototype;n.recreateResource=function(){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=et.vertexDeclaration,n=t.vertexStride/4,i=new Float32Array(this._numberVertices*n),r=Math.PI/this._stacks,a=2*Math.PI/this._slices,o=0,s=0,l=0,h=0;h<this._stacks+1;h++)for(var _=Math.sin(h*r),u=Math.cos(h*r),c=0;c<this._slices+1;c++){var d=_*Math.sin(c*a+1*Math.PI/2),f=_*Math.cos(c*a+1*Math.PI/2);i[s+0]=d*this._radius,i[s+1]=u*this._radius,i[s+2]=f*this._radius,i[s+3]=d,i[s+4]=u,i[s+5]=f,i[s+6]=c/this._slices,i[s+7]=h/this._stacks,s+=n,h!=this._stacks-1&&(e[l++]=o+(this._slices+1),e[l++]=o,e[l++]=o+1,e[l++]=o+this._slices,e[l++]=o,e[l++]=o+(this._slices+1),o++)}this._vertexBuffer=new $n(t,this._numberVertices,35044,!0),this._indexBuffer=new Qn("ushort",this._numberIndices,35044,!0),this._vertexBuffer.setData(i),this._indexBuffer.setData(e),this.memorySize=2*(this._vertexBuffer._byteLength+this._indexBuffer._byteLength),this.completeCreate()},l(0,n,"radius",function(){return this._radius},function(e){this._radius!==e&&(this._radius=e,this.releaseResource(),this.activeResource())}),l(0,n,"slices",function(){return this._slices},function(e){this._slices!==e&&(this._slices=e,this.releaseResource(),this.activeResource())}),l(0,n,"stacks",function(){return this._stacks},function(e){this._stacks!==e&&(this._stacks=e,this.releaseResource(),this.activeResource())})}(),function(e){function t(e,n,i){void 0===e&&(e=0),void 0===n&&(n=.3),void 0===i&&(i=1e3),this._viewMatrix=new Ct,this._projectionMatrix=new Ct,this._projectionViewMatrix=new Ct,this._viewport=new Bt(0,0,0,0),this._normalizedViewport=new Bt(0,0,1,1),this._aspectRatio=e,this._boundFrustumUpdate=!0,this._boundFrustum=new Mt(Ct.DEFAULT),t.__super.call(this,n,i),this.transform.on("worldmatrixneedchanged",this,this._onWorldMatrixChanged)}s(t,"laya.d3.core.Camera",fi);var n=t.prototype;return n._onWorldMatrixChanged=function(){this._boundFrustumUpdate=!0},n._parseCustomProps=function(e,t,n,i){var r=n.clearColor;this.clearColor=new Ft(r[0],r[1],r[2],r[3]);var a=n.viewport;this.normalizedViewport=new Bt(a[0],a[1],a[2],a[3])},n._calculateProjectionMatrix=function(){if(!this._useUserProjectionMatrix)if(this._orthographic){var e=this.orthographicVerticalSize*this.aspectRatio*.5,t=.5*this.orthographicVerticalSize;Ct.createOrthoOffCenterRH(-e,e,-t,t,this.nearPlane,this.farPlane,this._projectionMatrix)}else Ct.createPerspective(3.1416*this.fieldOfView/180,this.aspectRatio,this.nearPlane,this.farPlane,this._projectionMatrix);this._boundFrustumUpdate=!0},n._update=function(e){this.conchModel&&(this.conchModel.setViewMatrix(this.viewMatrix.elements),this.conchModel.setProjectMatrix(this.projectionMatrix.elements)),laya.d3.core.Sprite3D.prototype._update.call(this,e)},n._renderCamera=function(e,t,n){var i,r;n.parallelSplitShadowMaps[0]&&n._renderShadowMap(e,t,this),t.camera=this,this._prepareCameraToRender(),n._preRenderUpdateComponents(t),i=t._viewMatrix=this.viewMatrix;var a=this._renderTarget;a?(a.start(),Ct.multiply(fi._invertYScaleMatrix,this._projectionMatrix,fi._invertYProjectionMatrix),Ct.multiply(fi._invertYScaleMatrix,this.projectionViewMatrix,fi._invertYProjectionViewMatrix),r=t._projectionMatrix=fi._invertYProjectionMatrix,t._projectionViewMatrix=fi._invertYProjectionViewMatrix):(r=t._projectionMatrix=this._projectionMatrix,t._projectionViewMatrix=this.projectionViewMatrix),this._prepareCameraViewProject(i,r),t._viewport=this.viewport,n._preRenderScene(e,t,this.boundFrustum),n._clear(e,t),n._renderScene(e,t),n._postRenderUpdateComponents(t),a&&a.end()},n.viewportPointToRay=function(e,t){qt.calculateCursorRay(e,this.viewport,this._projectionMatrix,this.viewMatrix,null,t)},n.normalizedViewportPointToRay=function(e,n){var i=t._tempVector20,r=this.viewport,a=e.elements,o=i.elements;o[0]=a[0]*r.width,o[1]=a[1]*r.height,qt.calculateCursorRay(i,this.viewport,this._projectionMatrix,this.viewMatrix,null,n)},n.worldToViewportPoint=function(e,t){Ct.multiply(this._projectionMatrix,this._viewMatrix,this._projectionViewMatrix),this.viewport.project(e,this._projectionViewMatrix,t);var n=t.elements;n[0]=n[0]/a.stage.clientScaleX,n[1]=n[1]/a.stage.clientScaleY},n.worldToNormalizedViewportPoint=function(e,t){Ct.multiply(this._projectionMatrix,this._viewMatrix,this._projectionViewMatrix),this.normalizedViewport.project(e,this._projectionViewMatrix,t);var n=t.elements;n[0]=n[0]/a.stage.clientScaleX,n[1]=n[1]/a.stage.clientScaleY},n.convertScreenCoordToOrthographicCoord=function(e,t){if(this._orthographic){var n=me.clientWidth,i=me.clientHeight,r=this.orthographicVerticalSize*this.aspectRatio/n,a=this.orthographicVerticalSize/i,o=e.elements,s=t.elements;return s[0]=(-n/2+o[0])*r,s[1]=(i/2-o[1])*a,s[2]=(this.nearPlane-this.farPlane)*(o[2]+1)/2-this.nearPlane,bt.transformCoordinate(t,this.transform.worldMatrix,t),!0}return!1},l(0,n,"projectionViewMatrix",function(){return Ct.multiply(this.projectionMatrix,this.viewMatrix,this._projectionViewMatrix),this._projectionViewMatrix}),l(0,n,"aspectRatio",function(){if(0===this._aspectRatio){var e=this.viewport;return e.width/e.height}return this._aspectRatio},function(e){if(e<0)throw new Error("Camera: the aspect ratio has to be a positive real number.");this._aspectRatio=e,this._calculateProjectionMatrix()}),l(0,n,"boundFrustum",function(){return this._boundFrustumUpdate&&(this._boundFrustum.matrix=this.projectionViewMatrix),this._boundFrustum}),l(0,n,"needViewport",function(){var e=this.normalizedViewport;return 0===e.x&&0===e.y&&1===e.width&&1===e.height}),l(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()}),l(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){e.x<0&&(e.x=0,console.warn("Camera: viewport.x must large than 0.0.")),e.y<0&&(e.y=0,console.warn("Camera: viewport.y must large than 0.0.")),e.x+e.width>1&&(e.width=1-e.x,console.warn("Camera: viewport.width + viewport.x must less than 1.0.")),e.y+e.height>1&&(e.height=1-e.y,console.warn("Camera: viewport.height + viewport.y must less than 1.0.")),this._viewportExpressedInClipSpace=!0,this._normalizedViewport=e,this._calculateProjectionMatrix()}),l(0,n,"projectionMatrix",function(){return this._projectionMatrix},function(e){this._projectionMatrix=e,this._useUserProjectionMatrix=!0}),l(0,n,"viewMatrix",function(){return this.transform.worldMatrix.invert(this._viewMatrix),this._viewMatrix}),o(t,["_tempVector20",function(){return this._tempVector20=new Lt}]),t}()),gi=(function(e){function t(){t.__super.call(this),this._render=new Cn(this),this._render.on("materialchanged",this,this._onMaterialChanged);var e=new kn;this._render.sharedMaterial=e,this._geometryFilter=new bn(this),e.renderMode=8,this._changeRenderObject(0)}s(t,"laya.d3.core.glitter.Glitter",e);var n=t.prototype;n._changeRenderObject=function(e){var t=this._render._renderElements,n=t[e];n||(n=t[e]=new de),n._render=this._render;var i=this._render.sharedMaterials[e];i||(i=kn.defaultMaterial);var r=this._geometryFilter;return n._mainSortID=0,n._sprite3D=this,n.renderObj=r,n._material=i,n},n._onMaterialChanged=function(e,t,n){t<e._renderElements.length&&this._changeRenderObject(t)},n._clearSelfRenderObjects=function(){this.scene.removeFrustumCullingObject(this._render)},n._addSelfRenderObjects=function(){this.scene.addFrustumCullingObject(this._render)},n._update=function(t){this._geometryFilter._update(t.elapsedTime),e.prototype._update.call(this,t)},n.addGlitterByPositions=function(e,t){this._geometryFilter.addVertexPosition(e,t)},n.addGlitterByPositionsVelocitys=function(e,t,n,i){this._geometryFilter.addVertexPositionVelocity(e,t,n,i)},n.cloneTo=function(e){var t=e,n=t.templet,i=this._geometryFilter;n.lifeTime=i.lifeTime,n.minSegmentDistance=i.minSegmentDistance,n.minInterpDistance=i.minInterpDistance,n.maxSlerpCount=i.maxSlerpCount,n._maxSegments=i._maxSegments;var r=t._render,a=this._render;r.sharedMaterials=a.sharedMaterials,r.enable=a.enable,laya.d3.core.Sprite3D.prototype.cloneTo.call(this,e)},n.destroy=function(t){void 0===t&&(t=!0),this.destroyed||(e.prototype.destroy.call(this,t),this._geometryFilter._destroy(),this._geometryFilter=null)},l(0,n,"templet",function(){return this._geometryFilter}),l(0,n,"glitterRender",function(){return this._render}),t.CURRENTTIME=2,t.DURATION=3}(mi),function(e){function t(){this._direction=null,this._updateDirection=!1,t.__super.call(this),this._updateDirection=!1,this._direction=new bt,this.transform.on("worldmatrixneedchanged",this,this._onWorldMatrixChange)}s(t,"laya.d3.core.light.DirectionLight",e);var n=t.prototype;return n._initShadow=function(){if(this._shadow)this._parallelSplitShadowMap=new kt,this.scene.parallelSplitShadowMaps.push(this._parallelSplitShadowMap),this.transform.worldMatrix.getForward(this._direction),bt.normalize(this._direction,this._direction),this._parallelSplitShadowMap.setInfo(this.scene,this._shadowFarPlane,this._direction,this._shadowMapSize,this._shadowMapCount,this._shadowMapPCFType);else{var e=this.scene.parallelSplitShadowMaps;e.splice(e.indexOf(this._parallelSplitShadowMap),1),this._parallelSplitShadowMap.disposeAllRenderTarget(),this._parallelSplitShadowMap=null,this.scene.removeShaderDefine(kt.SHADERDEFINE_SHADOW_PSSM1),this.scene.removeShaderDefine(kt.SHADERDEFINE_SHADOW_PSSM2),this.scene.removeShaderDefine(kt.SHADERDEFINE_SHADOW_PSSM3)}},n._addSelfRenderObjects=function(){e.prototype._addSelfRenderObjects.call(this),this._shadow&&this._initShadow()},n._clearSelfRenderObjects=function(){var e=this.scene,t=e._shaderValues;t.setValue(4,null),t.setValue(3,null),e.removeShaderDefine(fn.SHADERDEFINE_DIRECTIONLIGHT)},n._prepareToScene=function(e){var t=e.scene;if(t.enableLight&&this._activeInHierarchy){var n=t._shaderValues;return t.addShaderDefine(fn.SHADERDEFINE_DIRECTIONLIGHT),bt.scale(this.color,this._intensity,this._intensityColor),n.setValue(4,this._intensityColor.elements),this.transform.worldMatrix.getForward(this._direction),bt.normalize(this._direction,this._direction),n.setValue(3,this._direction.elements),!0}return t.removeShaderDefine(fn.SHADERDEFINE_DIRECTIONLIGHT),!1},n._onWorldMatrixChange=function(){this._updateDirection=!0},l(0,n,"shadow",e.prototype._$get_shadow,function(e){this._shadow!==e&&(this._shadow=e,this.scene&&this._initShadow())}),l(0,n,"direction",function(){return console.log("Warning: discard property,please use transform's property instead."),this._updateDirection&&(this.transform.worldMatrix.getForward(this._direction),bt.normalize(this._direction,this._direction),this._updateDirection=!1),this._direction},function(e){console.log("Warning: discard property,please use transform's property instead.");var t=this.transform.worldMatrix;t.setForward(e),this.transform.worldMatrix=t,bt.normalize(e,e),this._direction=e,this.shadow&&this._parallelSplitShadowMap&&this._parallelSplitShadowMap._setGlobalParallelLightDir(this._direction)}),t}(pi)),Di=(function(e){function t(){this._range=NaN,this._attenuation=null,t.__super.call(this),this._range=6,this._attenuation=new bt(.6,.6,.6)}s(t,"laya.d3.core.light.PointLight",pi);var n=t.prototype;n._clearSelfRenderObjects=function(){var e=this.scene,t=e._shaderValues;t.setValue(8,null),t.setValue(5,null),t.setValue(6,null),t.setValue(7,null),e.removeShaderDefine(fn.SHADERDEFINE_POINTLIGHT)},n._prepareToScene=function(e){var t=e.scene;if(t.enableLight&&this._activeInHierarchy){var n=t._shaderValues;return t.addShaderDefine(fn.SHADERDEFINE_POINTLIGHT),bt.scale(this.color,this._intensity,this._intensityColor),n.setValue(8,this._intensityColor.elements),n.setValue(5,this.transform.position.elements),n.setValue(6,this.range),n.setValue(7,this.attenuation.elements),!0}return t.removeShaderDefine(fn.SHADERDEFINE_POINTLIGHT),!1},l(0,n,"range",function(){return this._range},function(e){this._range=e}),l(0,n,"attenuation",function(){return this._attenuation},function(e){this._attenuation=e})}(),function(e){function t(){this._updateDirection=!1,this._direction=null,this._spot=NaN,this._range=NaN,this._attenuation=null,t.__super.call(this),this._updateDirection=!1,this.direction=new bt(0,-1,-1),this._attenuation=new bt(.6,.6,.6),this._spot=96,this._range=6,this.transform.on("worldmatrixneedchanged",this,this._onWorldMatrixChange)}s(t,"laya.d3.core.light.SpotLight",pi);var n=t.prototype;n._onWorldMatrixChange=function(){this._updateDirection=!0},n._clearSelfRenderObjects=function(){var e=this.scene,t=e._shaderValues;t.setValue(14,null),t.setValue(9,null),t.setValue(10,null),t.setValue(12,null),t.setValue(11,null),t.setValue(13,null),e.removeShaderDefine(fn.SHADERDEFINE_SPOTLIGHT)},n._prepareToScene=function(e){var t=e.scene;if(t.enableLight&&this._activeInHierarchy){var n=t._shaderValues;return t.addShaderDefine(fn.SHADERDEFINE_SPOTLIGHT),bt.scale(this.color,this._intensity,this._intensityColor),n.setValue(14,this._intensityColor.elements),n.setValue(9,this.transform.position.elements),this.transform.worldMatrix.getForward(this._direction),bt.normalize(this._direction,this._direction),n.setValue(10,this._direction.elements),n.setValue(12,this.range),n.setValue(11,this.spot),n.setValue(13,this.attenuation.elements),!0}return t.removeShaderDefine(fn.SHADERDEFINE_SPOTLIGHT),!1},l(0,n,"spot",function(){return this._spot},function(e){this._spot=e}),l(0,n,"direction",function(){return console.log("Warning: discard property,please use transform's property instead."),this._updateDirection&&(this.transform.worldMatrix.getForward(this._direction),this._updateDirection=!1),this._direction},function(e){console.log("Warning: discard property,please use transform's property instead.");var t=this.transform.worldMatrix;t.setForward(e),this.transform.worldMatrix=t,this._direction=e}),l(0,n,"range",function(){return this._range},function(e){this._range=e}),l(0,n,"attenuation",function(){return this._attenuation},function(e){this._attenuation=e})}(),function(e){function t(e,n){t.__super.call(this,n),this._geometryFilter=new Nn(this),this._render=new On(this),this._geometryFilter.on("meshchanged",this,this._onMeshChanged),this._render.on("materialchanged",this,this._onMaterialChanged),e&&(this._geometryFilter.sharedMesh=e,e instanceof laya.d3.resource.models.Mesh&&(e.loaded?this._render.sharedMaterials=e.materials:e.once("loaded",this,this._applyMeshMaterials)))}s(t,"laya.d3.core.MeshSprite3D",e);var n=t.prototype;return n._changeRenderObjectByMesh=function(e){var t=this._render._renderElements,n=t[e];n||(n=t[e]=new dn),n._render=this._render;var i=this._render.sharedMaterials[e];i||(i=jn.defaultMaterial);var r=this._geometryFilter.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._render._renderElements[e];t||(t=jn.defaultMaterial);var i=this._geometryFilter.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._geometryFilter.sharedMesh.getRenderElementsCount();this._render._renderElements.length=e;for(var t=0;t<e;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){t<this._render._renderElements.length&&this._changeRenderObjectByMaterial(t,n)},n._clearSelfRenderObjects=function(){this.scene.removeFrustumCullingObject(this._render)},n._addSelfRenderObjects=function(){this.scene.addFrustumCullingObject(this._render)},n._parseCustomProps=function(e,t,n,i){var r=this.meshRender,a=n.lightmapIndex;null!=a&&(r.lightmapIndex=a);var o,s,l=n.lightmapScaleOffset;if(l&&(r.lightmapScaleOffset=new Ft(l[0],l[1],l[2],l[3])),i.instanceParams)(o=i.instanceParams.loadPath)&&(s=S.getRes(t[o]),this.meshFilter.sharedMesh=s,s.loaded?r.sharedMaterials=s.materials:s.once("loaded",this,this._applyMeshMaterials));else{(o=n.meshPath)&&(s=S.getRes(t[o]),this.meshFilter.sharedMesh=s);var h=n.materials;if(h){var _=r.sharedMaterials,u=h.length;_.length=u;for(var c=0;c<u;c++)_[c]=S.getRes(t[h[c].path]);r.sharedMaterials=_}}},n._applyMeshMaterials=function(e){for(var t=this._render.sharedMaterials,n=e.materials,i=0,r=n.length;i<r;i++)t[i]||(t[i]=n[i]);this._render.sharedMaterials=t},n._addToInitStaticBatchManager=function(){t._staticBatchManager._addInitBatchSprite(this)},n.cloneTo=function(e){var t=e;t._geometryFilter.sharedMesh=this._geometryFilter.sharedMesh;var n=this._render,i=t._render;i.enable=n.enable,i.sharedMaterials=n.sharedMaterials,i.castShadow=n.castShadow;var r=n.lightmapScaleOffset;r&&(i.lightmapScaleOffset=r.clone()),i.lightmapIndex=n.lightmapIndex,i.receiveShadow=n.receiveShadow,i.sortingFudge=n.sortingFudge,laya.d3.core.Sprite3D.prototype.cloneTo.call(this,e)},n.destroy=function(t){if(void 0===t&&(t=!0),!this.destroyed){var n=this.meshFilter.sharedMesh;n.loaded||n.off("loaded",this,this._applyMeshMaterials),e.prototype.destroy.call(this,t),this._geometryFilter._destroy()}},l(0,n,"meshFilter",function(){return this._geometryFilter}),l(0,n,"meshRender",function(){return this._render}),t.__init__=function(){Ie._staticBatchManagers.push(t._staticBatchManager)},t.load=function(e){return a.loader.create(e,null,null,t)},o(t,["_staticBatchManager",function(){return this._staticBatchManager=new mn}]),t}(mi)),Ti=function(e){function t(e){t.__super.call(this),this._render=new Vn(this),this._render.on("materialchanged",this,this._onMaterialChanged),this._geometryFilter=new wn(this),this._createRenderElement(0),e&&(this._render.sharedMaterial=e)}s(t,"laya.d3.core.particleShuriKen.ShuriKenParticle3D",e);var n=t.prototype;return n._initParticleVelocity=function(e){for(var t=new te,n=e.velocitys,i=0,r=n.length;i<r;i++){var a=n[i];t.add(a.key,a.value)}return t},n._initParticleColor=function(e){var t=new J,n=e.alphas,i=0,r=0;for(i=0,r=n.length;i<r;i++){var a=n[i];t.addAlpha(a.key,a.value)}var o=e.rgbs;for(i=0,r=o.length;i<r;i++){var s=o[i],l=s.value;t.addRGB(s.key,new bt(l[0],l[1],l[2]))}return t},n._initParticleSize=function(e){for(var t=new te,n=e.sizes,i=0,r=n.length;i<r;i++){var a=n[i];t.add(a.key,a.value)}return t},n._initParticleRotation=function(e){for(var t=new te,n=e.angularVelocitys,i=0,r=n.length;i<r;i++){var a=n[i];t.add(a.key,a.value/180*Math.PI)}return t},n._initParticleFrame=function(e){for(var t=new ee,n=e.frames,i=0,r=n.length;i<r;i++){var a=n[i];t.add(a.key,a.value)}return t},n._createRenderElement=function(e){var t=this._render._renderElements[e]=new de;t._render=this._render;var n=this._render.sharedMaterials[e];n||(n=Jn.defaultMaterial);var i=this._geometryFilter;t._mainSortID=0,t._sprite3D=this,t.renderObj=i,t._material=n},n._onMaterialChanged=function(e,t,n){var i=e._renderElements;t<i.length&&(i[t]._material=n||Jn.defaultMaterial)},n._clearSelfRenderObjects=function(){this.scene.removeFrustumCullingObject(this._render)},n._addSelfRenderObjects=function(){this.scene.addFrustumCullingObject(this._render)},n._parseCustomProps=function(e,n,i,r){var a,o=Math.PI/180,s=0,l=0,h=this.particleRender,_=i.material;if(_)a=S.getRes(n[_.path]);else{var u=i.materialPath;u?a=S.getRes(n[u]):(a=new Jn).diffuseTexture=n?S.getRes(n[i.texturePath]):ui.load(i.texturePath)}h.sharedMaterial=a;var c=i.meshPath;c&&(h.mesh=S.getRes(n[c])),h.renderMode=i.renderMode,h.stretchedBillboardCameraSpeedScale=i.stretchedBillboardCameraSpeedScale,h.stretchedBillboardSpeedScale=i.stretchedBillboardSpeedScale,h.stretchedBillboardLengthScale=i.stretchedBillboardLengthScale,h.sortingFudge=i.sortingFudge?i.sortingFudge:0;var d=this.particleSystem;d.isPerformanceMode=i.isPerformanceMode,d.duration=i.duration,d.looping=i.looping,d.prewarm=i.prewarm,d.startDelayType=i.startDelayType,d.startDelay=i.startDelay,d.startDelayMin=i.startDelayMin,d.startDelayMax=i.startDelayMax,d.startLifetimeType=i.startLifetimeType,d.startLifetimeConstant=i.startLifetimeConstant,d.startLifeTimeGradient=t._initStartLife(i.startLifetimeGradient),d.startLifetimeConstantMin=i.startLifetimeConstantMin,d.startLifetimeConstantMax=i.startLifetimeConstantMax,d.startLifeTimeGradientMin=t._initStartLife(i.startLifetimeGradientMin),d.startLifeTimeGradientMax=t._initStartLife(i.startLifetimeGradientMax),d.startSpeedType=i.startSpeedType,d.startSpeedConstant=i.startSpeedConstant,d.startSpeedConstantMin=i.startSpeedConstantMin,d.startSpeedConstantMax=i.startSpeedConstantMax,d.threeDStartSize=i.threeDStartSize,d.startSizeType=i.startSizeType,d.startSizeConstant=i.startSizeConstant;var f=i.startSizeConstantSeparate,m=d.startSizeConstantSeparate.elements;m[0]=f[0],m[1]=f[1],m[2]=f[2],d.startSizeConstantMin=i.startSizeConstantMin,d.startSizeConstantMax=i.startSizeConstantMax;var p=i.startSizeConstantMinSeparate,v=d.startSizeConstantMinSeparate.elements;v[0]=p[0],v[1]=p[1],v[2]=p[2];var E=i.startSizeConstantMaxSeparate,g=d.startSizeConstantMaxSeparate.elements;g[0]=E[0],g[1]=E[1],g[2]=E[2],d.threeDStartRotation=i.threeDStartRotation,d.startRotationType=i.startRotationType,d.startRotationConstant=i.startRotationConstant*o;var D=i.startRotationConstantSeparate,T=d.startRotationConstantSeparate.elements;T[0]=D[0]*o,T[1]=D[1]*o,T[2]=D[2]*o,d.startRotationConstantMin=i.startRotationConstantMin*o,d.startRotationConstantMax=i.startRotationConstantMax*o;var x=i.startRotationConstantMinSeparate,M=d.startRotationConstantMinSeparate.elements;M[0]=x[0]*o,M[1]=x[1]*o,M[2]=x[2]*o;var R=i.startRotationConstantMaxSeparate,A=d.startRotationConstantMaxSeparate.elements;A[0]=R[0]*o,A[1]=R[1]*o,A[2]=R[2]*o,d.randomizeRotationDirection=i.randomizeRotationDirection,d.startColorType=i.startColorType;var I=i.startColorConstant,y=d.startColorConstant.elements;y[0]=I[0],y[1]=I[1],y[2]=I[2],y[3]=I[3];var C=i.startColorConstantMin,N=d.startColorConstantMin.elements;N[0]=C[0],N[1]=C[1],N[2]=C[2],N[3]=C[3];var O=i.startColorConstantMax,w=d.startColorConstantMax.elements;w[0]=O[0],w[1]=O[1],w[2]=O[2],w[3]=O[3],d.gravityModifier=i.gravityModifier,d.simulationSpace=i.simulationSpace,d.scaleMode=i.scaleMode,d.playOnAwake=i.playOnAwake,d.maxParticles=i.maxParticles;var V=i.autoRandomSeed;null!=V&&(d.autoRandomSeed=V);var P=i.randomSeed;null!=P&&(d.randomSeed[0]=P);var L=i.emission;if(L){var b=d.emission;b.emissionRate=L.emissionRate;var F=L.bursts;if(F)for(s=0,l=F.length;s<l;s++){var B=F[s];b.addBurst(new Y(B.time,B.min,B.max))}b.enbale=L.enable}else b.enbale=!1;var U=i.shape;if(U){var H;switch(U.shapeType){case 0:var G;H=G=new cn,G.radius=U.sphereRadius,G.emitFromShell=U.sphereEmitFromShell,G.randomDirection=U.sphereRandomDirection;break;case 1:var z;H=z=new un,z.radius=U.hemiSphereRadius,z.emitFromShell=U.hemiSphereEmitFromShell,z.randomDirection=U.hemiSphereRandomDirection;break;case 2:var W;H=W=new _n,W.angle=U.coneAngle*o,W.radius=U.coneRadius,W.length=U.coneLength,W.emitType=U.coneEmitType,W.randomDirection=U.coneRandomDirection;break;case 3:var k;H=k=new ln,k.x=U.boxX,k.y=U.boxY,k.z=U.boxZ,k.randomDirection=U.boxRandomDirection;break;case 7:var X;H=X=new hn,X.radius=U.circleRadius,X.arc=U.circleArc*o,X.emitFromEdge=U.circleEmitFromEdge,X.randomDirection=U.circleRandomDirection;break;default:var Z;H=Z=new hn,Z.radius=U.circleRadius,Z.arc=U.circleArc*o,Z.emitFromEdge=U.circleEmitFromEdge,Z.randomDirection=U.circleRandomDirection}H.enable=U.enable,d.shape=H}var K=i.velocityOverLifetime;if(K){var J,ee=K.velocity;switch(ee.type){case 0:var te=ee.constant;J=ie.createByConstant(new bt(te[0],te[1],te[2]));break;case 1:J=ie.createByGradient(this._initParticleVelocity(ee.gradientX),this._initParticleVelocity(ee.gradientY),this._initParticleVelocity(ee.gradientZ));break;case 2:var ae=ee.constantMin,oe=ee.constantMax;J=ie.createByRandomTwoConstant(new bt(ae[0],ae[1],ae[2]),new bt(oe[0],oe[1],oe[2]));break;case 3:J=ie.createByRandomTwoGradient(this._initParticleVelocity(ee.gradientXMin),this._initParticleVelocity(ee.gradientXMax),this._initParticleVelocity(ee.gradientYMin),this._initParticleVelocity(ee.gradientYMax),this._initParticleVelocity(ee.gradientZMin),this._initParticleVelocity(ee.gradientZMax))}var ue=new _e(J);ue.space=K.space,ue.enbale=K.enable,d.velocityOverLifetime=ue}var ce=i.colorOverLifetime;if(ce){var de,fe=ce.color;switch(fe.type){case 0:var me=fe.constant;de=$.createByConstant(new Ft(me[0],me[1],me[2],me[3]));break;case 1:de=$.createByGradient(this._initParticleColor(fe.gradient));break;case 2:var pe=fe.constantMin,ve=fe.constantMax;de=$.createByRandomTwoConstant(new Ft(pe[0],pe[1],pe[2],pe[3]),new Ft(ve[0],ve[1],ve[2],ve[3]));break;case 3:de=$.createByRandomTwoGradient(this._initParticleColor(fe.gradientMin),this._initParticleColor(fe.gradientMax))}var Ee=new j(de);Ee.enbale=ce.enable,d.colorOverLifetime=Ee}var ge=i.sizeOverLifetime;if(ge){var De,Te=ge.size;switch(Te.type){case 0:De=Te.separateAxes?ne.createByGradientSeparate(this._initParticleSize(Te.gradientX),this._initParticleSize(Te.gradientY),this._initParticleSize(Te.gradientZ)):ne.createByGradient(this._initParticleSize(Te.gradient));break;case 1:if(Te.separateAxes){var Se=Te.constantMinSeparate,xe=Te.constantMaxSeparate;De=ne.createByRandomTwoConstantSeparate(new bt(Se[0],Se[1],Se[2]),new bt(xe[0],xe[1],xe[2]))}else De=ne.createByRandomTwoConstant(Te.constantMin,Te.constantMax);break;case 2:De=Te.separateAxes?ne.createByRandomTwoGradientSeparate(this._initParticleSize(Te.gradientXMin),this._initParticleSize(Te.gradientYMin),this._initParticleSize(Te.gradientZMin),this._initParticleSize(Te.gradientXMax),this._initParticleSize(Te.gradientYMax),this._initParticleSize(Te.gradientZMax)):ne.createByRandomTwoGradient(this._initParticleSize(Te.gradientMin),this._initParticleSize(Te.gradientMax))}var Me=new se(De);Me.enbale=ge.enable,d.sizeOverLifetime=Me}var Re=i.rotationOverLifetime;if(Re){var Ae,Ie=Re.angularVelocity;switch(Ie.type){case 0:Ie.separateAxes||(Ae=Q.createByConstant(Ie.constant*o));break;case 1:Ie.separateAxes||(Ae=Q.createByGradient(this._initParticleRotation(Ie.gradient)));break;case 2:if(Ie.separateAxes){var ye=Ie.constantMinSeparate,Ce=Ie.constantMaxSeparate;Ae=Q.createByRandomTwoConstantSeparate(new bt(ye[0]*o,ye[1]*o,ye[2]*o),new bt(Ce[0]*o,Ce[1]*o,Ce[2]*o))}else Ae=Q.createByRandomTwoConstant(Ie.constantMin*o,Ie.constantMax*o);break;case 3:Ie.separateAxes||(Ae=Q.createByRandomTwoGradient(this._initParticleRotation(Ie.gradientMin),this._initParticleRotation(Ie.gradientMax)))}var Ne=new re(Ae);Ne.enbale=Re.enable,d.rotationOverLifetime=Ne}var Oe=i.textureSheetAnimation;if(Oe){var we,Ve=Oe.frame;switch(Ve.type){case 0:we=q.createByConstant(Ve.constant);break;case 1:we=q.createByOverTime(this._initParticleFrame(Ve.overTime));break;case 2:we=q.createByRandomTwoConstant(Ve.constantMin,Ve.constantMax);break;case 3:we=q.createByRandomTwoOverTime(this._initParticleFrame(Ve.overTimeMin),this._initParticleFrame(Ve.overTimeMax))}var Pe,Le=Oe.startFrame;switch(Le.type){case 0:Pe=le.createByConstant(Le.constant);break;case 1:Pe=le.createByRandomTwoConstant(Le.constantMin,Le.constantMax)}var be=new he(we,Pe);be.enable=Oe.enable;var Fe=Oe.tiles;be.tiles=new Lt(Fe[0],Fe[1]),be.type=Oe.type,be.randomRow=Oe.randomRow;var Be=Oe.rowIndex;void 0!==Be&&(be.rowIndex=Be),be.cycles=Oe.cycles,d.textureSheetAnimation=be}},n._activeHierarchy=function(){laya.d3.core.Sprite3D.prototype._activeHierarchy.call(this),this.particleSystem.playOnAwake&&this.particleSystem.play()},n._inActiveHierarchy=function(){laya.d3.core.Sprite3D.prototype._inActiveHierarchy.call(this),this.particleSystem.isAlive&&this.particleSystem.simulate(0,!0)},n.cloneTo=function(e){var t=e,n=t._geometryFilter;this._geometryFilter.cloneTo(n);var i=t._render,r=this._render;i.sharedMaterials=r.sharedMaterials,i.enable=r.enable,i.renderMode=r.renderMode,i.mesh=r.mesh,i.stretchedBillboardCameraSpeedScale=r.stretchedBillboardCameraSpeedScale,i.stretchedBillboardSpeedScale=r.stretchedBillboardSpeedScale,i.stretchedBillboardLengthScale=r.stretchedBillboardLengthScale,i.sortingFudge=r.sortingFudge,laya.d3.core.Sprite3D.prototype.cloneTo.call(this,e)},n.destroy=function(t){void 0===t&&(t=!0),this.destroyed||(e.prototype.destroy.call(this,t),this._geometryFilter._destroy(),this._geometryFilter=null)},l(0,n,"particleSystem",function(){return this._geometryFilter}),l(0,n,"particleRender",function(){return this._render}),t.__init__=function(){t.SHADERDEFINE_RENDERMODE_BILLBOARD=t.shaderDefines.registerDefine("SPHERHBILLBOARD"),t.SHADERDEFINE_RENDERMODE_STRETCHEDBILLBOARD=t.shaderDefines.registerDefine("STRETCHEDBILLBOARD"),t.SHADERDEFINE_RENDERMODE_HORIZONTALBILLBOARD=t.shaderDefines.registerDefine("HORIZONTALBILLBOARD"),t.SHADERDEFINE_RENDERMODE_VERTICALBILLBOARD=t.shaderDefines.registerDefine("VERTICALBILLBOARD"),t.SHADERDEFINE_COLOROVERLIFETIME=t.shaderDefines.registerDefine("COLOROVERLIFETIME"),t.SHADERDEFINE_RANDOMCOLOROVERLIFETIME=t.shaderDefines.registerDefine("RANDOMCOLOROVERLIFETIME"),t.SHADERDEFINE_VELOCITYOVERLIFETIMECONSTANT=t.shaderDefines.registerDefine("VELOCITYOVERLIFETIMECONSTANT"),t.SHADERDEFINE_VELOCITYOVERLIFETIMECURVE=t.shaderDefines.registerDefine("VELOCITYOVERLIFETIMECURVE"),t.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCONSTANT=t.shaderDefines.registerDefine("VELOCITYOVERLIFETIMERANDOMCONSTANT"),t.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCURVE=t.shaderDefines.registerDefine("VELOCITYOVERLIFETIMERANDOMCURVE"),t.SHADERDEFINE_TEXTURESHEETANIMATIONCURVE=t.shaderDefines.registerDefine("TEXTURESHEETANIMATIONCURVE"),t.SHADERDEFINE_TEXTURESHEETANIMATIONRANDOMCURVE=t.shaderDefines.registerDefine("TEXTURESHEETANIMATIONRANDOMCURVE"),t.SHADERDEFINE_ROTATIONOVERLIFETIME=t.shaderDefines.registerDefine("ROTATIONOVERLIFETIME"),t.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE=t.shaderDefines.registerDefine("ROTATIONOVERLIFETIMESEPERATE"),t.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT=t.shaderDefines.registerDefine("ROTATIONOVERLIFETIMECONSTANT"),t.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE=t.shaderDefines.registerDefine("ROTATIONOVERLIFETIMECURVE"),t.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS=t.shaderDefines.registerDefine("ROTATIONOVERLIFETIMERANDOMCURVES"),t.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCURVES=t.shaderDefines.registerDefine("ROTATIONOVERLIFETIMERANDOMCURVES"),t.SHADERDEFINE_SIZEOVERLIFETIMECURVE=t.shaderDefines.registerDefine("SIZEOVERLIFETIMECURVE"),t.SHADERDEFINE_SIZEOVERLIFETIMECURVESEPERATE=t.shaderDefines.registerDefine("SIZEOVERLIFETIMECURVESEPERATE"),t.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVES=t.shaderDefines.registerDefine("SIZEOVERLIFETIMERANDOMCURVES"),t.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVESSEPERATE=t.shaderDefines.registerDefine("SIZEOVERLIFETIMERANDOMCURVESSEPERATE"),t.SHADERDEFINE_RENDERMODE_MESH=t.shaderDefines.registerDefine("RENDERMODE_MESH"),t.SHADERDEFINE_SHAPE=t.shaderDefines.registerDefine("SHAPE")},t.load=function(e){return a.loader.create(e,null,null,t)},t._initStartLife=function(e){for(var t=new te,n=e.startLifetimes,i=0,r=n.length;i<r;i++){var a=n[i];t.add(a.key,a.value)}return t},t.SHADERDEFINE_RENDERMODE_BILLBOARD=0,t.SHADERDEFINE_RENDERMODE_STRETCHEDBILLBOARD=0,t.SHADERDEFINE_RENDERMODE_HORIZONTALBILLBOARD=0,t.SHADERDEFINE_RENDERMODE_VERTICALBILLBOARD=0,t.SHADERDEFINE_COLOROVERLIFETIME=0,t.SHADERDEFINE_RANDOMCOLOROVERLIFETIME=0,t.SHADERDEFINE_VELOCITYOVERLIFETIMECONSTANT=0,t.SHADERDEFINE_VELOCITYOVERLIFETIMECURVE=0,t.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCONSTANT=0,t.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCURVE=0,t.SHADERDEFINE_TEXTURESHEETANIMATIONCURVE=0,t.SHADERDEFINE_TEXTURESHEETANIMATIONRANDOMCURVE=0,t.SHADERDEFINE_ROTATIONOVERLIFETIME=0,t.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE=0,t.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT=0,t.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE=0,t.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS=0,t.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCURVES=0,t.SHADERDEFINE_SIZEOVERLIFETIMECURVE=0,t.SHADERDEFINE_SIZEOVERLIFETIMECURVESEPERATE=0,t.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVES=0,t.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVESSEPERATE=0,t.SHADERDEFINE_RENDERMODE_MESH=0,t.SHADERDEFINE_SHAPE=0,t.WORLDPOSITION=0,t.WORLDROTATION=1,t.POSITIONSCALE=4,t.SIZESCALE=5,t.SCALINGMODE=6,t.GRAVITY=7,t.THREEDSTARTROTATION=8,t.STRETCHEDBILLBOARDLENGTHSCALE=9,t.STRETCHEDBILLBOARDSPEEDSCALE=10,t.SIMULATIONSPACE=11,t.CURRENTTIME=12,t.VOLVELOCITYCONST=13,t.VOLVELOCITYGRADIENTX=14,t.VOLVELOCITYGRADIENTY=15,t.VOLVELOCITYGRADIENTZ=16,t.VOLVELOCITYCONSTMAX=17,t.VOLVELOCITYGRADIENTXMAX=18,t.VOLVELOCITYGRADIENTYMAX=19,t.VOLVELOCITYGRADIENTZMAX=20,t.VOLSPACETYPE=21,t.COLOROVERLIFEGRADIENTALPHAS=22,t.COLOROVERLIFEGRADIENTCOLORS=23,t.MAXCOLOROVERLIFEGRADIENTALPHAS=24,t.MAXCOLOROVERLIFEGRADIENTCOLORS=25,t.SOLSIZEGRADIENT=26,t.SOLSIZEGRADIENTX=27,t.SOLSIZEGRADIENTY=28,t.SOLSizeGradientZ=29,t.SOLSizeGradientMax=30,t.SOLSIZEGRADIENTXMAX=31,t.SOLSIZEGRADIENTYMAX=32,t.SOLSizeGradientZMAX=33,t.ROLANGULARVELOCITYCONST=34,t.ROLANGULARVELOCITYCONSTSEPRARATE=35,t.ROLANGULARVELOCITYGRADIENT=36,t.ROLANGULARVELOCITYGRADIENTX=37,t.ROLANGULARVELOCITYGRADIENTY=38,t.ROLANGULARVELOCITYGRADIENTZ=39,t.ROLANGULARVELOCITYGRADIENTW=40,t.ROLANGULARVELOCITYCONSTMAX=41,t.ROLANGULARVELOCITYCONSTMAXSEPRARATE=42,t.ROLANGULARVELOCITYGRADIENTMAX=43,t.ROLANGULARVELOCITYGRADIENTXMAX=44,t.ROLANGULARVELOCITYGRADIENTYMAX=45,t.ROLANGULARVELOCITYGRADIENTZMAX=46,t.ROLANGULARVELOCITYGRADIENTWMAX=47,t.TEXTURESHEETANIMATIONCYCLES=48,t.TEXTURESHEETANIMATIONSUBUVLENGTH=49,t.TEXTURESHEETANIMATIONGRADIENTUVS=50,t.TEXTURESHEETANIMATIONGRADIENTMAXUVS=51,o(t,["shaderDefines",function(){return this.shaderDefines=new Gt(mi.shaderDefines)}]),t}(mi),Si=function(e){function t(e,n){this._subMeshOffset=null,t.__super.call(this,n),this._subMeshOffset=[],this._geometryFilter=new Nn(this),this._render=new di(this),this._geometryFilter.on("meshchanged",this,this._onMeshChanged),this._render.on("materialchanged",this,this._onMaterialChanged),e&&(this._geometryFilter.sharedMesh=e)}s(t,"laya.d3.core.SkinnedMeshSprite3D",e);var n=t.prototype;return n._changeRenderObjectByMesh=function(e){var t=this._render._renderElements,n=t[e];n||(n=t[e]=new dn),n._render=this._render;var i=this._render.sharedMaterials[e];i||(i=jn.defaultMaterial);var r=this._geometryFilter.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._render._renderElements[e];t||(t=jn.defaultMaterial);var i=this._geometryFilter.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._geometryFilter.sharedMesh.getRenderElementsCount();this._render._renderElements.length=e;for(var t=0;t<e;t++)this._changeRenderObjectByMesh(t)},n._onMeshChanged=function(e){var t=e.sharedMesh;t.loaded?this._changeRenderObjectsByMesh():t.once("loaded",this,this._changeRenderObjectsByMesh)},n._onMaterialChanged=function(e,t,n){t<this._render._renderElements.length&&this._changeRenderObjectByMaterial(t,n)},n._parseCustomProps=function(e,t,n,i){var r=this.skinnedMeshRender,a=n.lightmapIndex;null!=a&&(r.lightmapIndex=a);var o,s,l=n.lightmapScaleOffset;if(l&&(r.lightmapScaleOffset=new Ft(l[0],l[1],l[2],l[3])),i.instanceParams)(o=i.instanceParams.loadPath)&&(s=S.getRes(t[o]),this.meshFilter.sharedMesh=s,s.loaded?r.sharedMaterials=s.materials:s.once("loaded",this,this._applyMeshMaterials));else{(o=n.meshPath)&&(s=S.getRes(t[o]),this.meshFilter.sharedMesh=s);var h=n.materials;if(h){var _=r.sharedMaterials,u=h.length;_.length=u;for(var c=0;c<u;c++)_[c]=S.getRes(t[h[c].path]);r.sharedMaterials=_}var d=n.rootBone;d&&r._setRootBone(d);var f=n.boundBox;if(f){var m=f.min,p=f.max,v=new xt(new bt(m[0],m[1],m[2]),new bt(p[0],p[1],p[2]));r.localBoundBox=v}else r._hasIndependentBound=!1;var E=n.boundSphere;if(E){var g=E.center,D=new Rt(new bt(g[0],g[1],g[2]),E.radius);r.localBoundSphere=D}}},n._changeHierarchyAnimator=function(e){if(e){var t=this.skinnedMeshRender;t._setCacheAnimator(e);var n=e.avatar;n&&t._setCacheAvatar(n)}laya.d3.core.Sprite3D.prototype._changeHierarchyAnimator.call(this,e)},n._clearSelfRenderObjects=function(){this._scene.removeFrustumCullingObject(this._render)},n._addSelfRenderObjects=function(){this._scene.addFrustumCullingObject(this._render)},n._applyMeshMaterials=function(e){for(var t=this._render.sharedMaterials,n=e.materials,i=0,r=n.length;i<r;i++)t[i]||(t[i]=n[i]);this._render.sharedMaterials=t},n.cloneTo=function(e){var t=e;t._geometryFilter.sharedMesh=this._geometryFilter.sharedMesh;var n=this._render,i=t._render;i.enable=n.enable,i.sharedMaterials=n.sharedMaterials,i.castShadow=n.castShadow;var r=n.lightmapScaleOffset;r&&(i.lightmapScaleOffset=r.clone()),i.receiveShadow=n.receiveShadow,i.sortingFudge=n.sortingFudge,i._rootBone=n._rootBone;var a=n.localBoundSphere;a&&(i.localBoundSphere=a.clone());var o=n.localBoundBox;o&&(i.localBoundBox=o.clone()),i._hasIndependentBound=n._hasIndependentBound,laya.d3.core.Sprite3D.prototype.cloneTo.call(this,e)},n.destroy=function(t){void 0===t&&(t=!0),this.destroyed||(e.prototype.destroy.call(this,t),this._geometryFilter._destroy())},l(0,n,"meshFilter",function(){return this._geometryFilter}),l(0,n,"skinnedMeshRender",function(){return this._render}),t.__init__=function(){t.SHADERDEFINE_BONE=t.shaderDefines.registerDefine("BONE")},t.load=function(e){return a.loader.create(e,null,null,t)},t.SHADERDEFINE_BONE=8,t.BONES=0,o(t,["shaderDefines",function(){return this.shaderDefines=new Gt(mi.shaderDefines)}]),t}(mi),xi=(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=.3),void 0===a&&(a=1e3),this._tempMatrix=new Ct,this._leftViewMatrix=new Ct,this._leftProjectionMatrix=new Ct,this._leftProjectionViewMatrix=new Ct,this._leftViewport=new Bt(0,0,0,0),this._leftNormalizedViewport=new Bt(0,0,.5,1),this._leftAspectRatio=n,this._rightViewMatrix=new Ct,this._rightProjectionMatrix=new Ct,this._rightProjectionViewMatrix=new Ct,this._rightViewport=new Bt(0,0,0,0),this._rightNormalizedViewport=new Bt(.5,0,.5,1),this._rightAspectRatio=i,this._pupilDistande=e,this._leftBoundFrustumUpdate=!0,this._leftBoundFrustum=new Mt(Ct.DEFAULT),this._rightBoundFrustumUpdate=!0,this._rightBoundFrustum=new Mt(Ct.DEFAULT),t.__super.call(this,r,a),this.transform.on("worldmatrixneedchanged",this,this._onWorldMatrixChanged)}s(t,"laya.d3.core.VRCamera",fi);var n=t.prototype;n._onWorldMatrixChanged=function(){this._leftBoundFrustumUpdate=this._rightBoundFrustumUpdate=!0},n._calculatePupilOffset=function(){var e=this._tempVector3;return bt.scale(this.right,this._pupilDistande/2,e),e.elements},n._calculateLeftProjectionMatrix=function(){if(!this._useUserProjectionMatrix)if(this._orthographic){var e=this.orthographicVerticalSize*this.leftAspectRatio*.5,t=.5*this.orthographicVerticalSize;Ct.createOrthoOffCenterRH(-e,e,-t,t,this.nearPlane,this.farPlane,this._leftProjectionMatrix)}else Ct.createPerspective(3.1416*this.fieldOfView/180,this.leftAspectRatio,this.nearPlane,this.farPlane,this._rightProjectionMatrix);this._leftBoundFrustumUpdate=!0},n._calculateRightProjectionMatrix=function(){if(!this._useUserProjectionMatrix)if(this._orthographic){var e=this.orthographicVerticalSize*this.rightAspectRatio*.5,t=.5*this.orthographicVerticalSize;Ct.createOrthoOffCenterRH(-e,e,t,t,this.nearPlane,this.farPlane,this._rightProjectionMatrix)}else Ct.createPerspective(3.1416*this.fieldOfView/180,this.rightAspectRatio,this.nearPlane,this.farPlane,this._rightProjectionMatrix);this._rightBoundFrustumUpdate=!0},n._calculateProjectionMatrix=function(){if(!this._useUserProjectionMatrix)if(this._orthographic){var e=this.orthographicVerticalSize*this.leftAspectRatio*.5,t=.5*this.orthographicVerticalSize,n=this.orthographicVerticalSize*this.rightAspectRatio*.5,i=.5*this.orthographicVerticalSize;Ct.createOrthoOffCenterRH(-e,e,-t,t,this.nearPlane,this.farPlane,this._leftProjectionMatrix),Ct.createOrthoOffCenterRH(-n,n,i,i,this.nearPlane,this.farPlane,this._rightProjectionMatrix)}else Ct.createPerspective(3.1416*this.fieldOfView/180,this.leftAspectRatio,this.nearPlane,this.farPlane,this._leftProjectionMatrix),Ct.createPerspective(3.1416*this.fieldOfView/180,this.rightAspectRatio,this.nearPlane,this.farPlane,this._rightProjectionMatrix);this._leftBoundFrustumUpdate=this._rightBoundFrustumUpdate=!0},n._renderCamera=function(e,t,n){var i,r;t.camera=this,this._prepareCameraToRender(),n._preRenderUpdateComponents(t),i=t._viewMatrix=this.leftViewMatrix;var a,o,s=this._renderTarget;s?(s.start(),Ct.multiply(fi._invertYScaleMatrix,this._leftProjectionMatrix,fi._invertYProjectionMatrix),Ct.multiply(fi._invertYScaleMatrix,this.leftProjectionViewMatrix,fi._invertYProjectionViewMatrix),r=t._projectionMatrix=fi._invertYProjectionMatrix,t._projectionViewMatrix=fi._invertYProjectionViewMatrix):(r=t._projectionMatrix=this._leftProjectionMatrix,t._projectionViewMatrix=this.leftProjectionViewMatrix),this._prepareCameraViewProject(i,r),t._viewport=this.leftViewport,n._preRenderScene(e,t,this.leftBoundFrustum),n._clear(e,t),n._renderScene(e,t),a=t._viewMatrix=this.rightViewMatrix,s?(s.start(),Ct.multiply(fi._invertYScaleMatrix,this._rightProjectionMatrix,fi._invertYProjectionMatrix),Ct.multiply(fi._invertYScaleMatrix,this.rightProjectionViewMatrix,fi._invertYProjectionViewMatrix),t._projectionMatrix=fi._invertYProjectionMatrix,o=t._projectionViewMatrix=fi._invertYProjectionViewMatrix):(o=t._projectionMatrix=this._rightProjectionMatrix,t._projectionViewMatrix=this.rightProjectionViewMatrix),this._prepareCameraViewProject(a,o),t._viewport=this.rightViewport,n._preRenderScene(e,t,this.rightBoundFrustum),n._clear(e,t),n._renderScene(e,t),n._postRenderUpdateComponents(t),s&&s.end()},l(0,n,"rightBoundFrustum",function(){return this._rightBoundFrustumUpdate&&(this._rightBoundFrustum.matrix=this.rightProjectionViewMatrix),this._rightBoundFrustum}),l(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}),l(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}),l(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 Bt(0,0,e.width/2,e.height),this._rightViewport=new Bt(e.width/2,0,e.width/2,e.height),this._calculateProjectionMatrix()}),l(0,n,"leftAspectRatio",function(){if(0===this._leftAspectRatio){var e=this.leftViewport;return e.width/e.height}return this._leftAspectRatio}),l(0,n,"rightAspectRatio",function(){if(0===this._rightAspectRatio){var e=this.rightViewport;return e.width/e.height}return this._rightAspectRatio}),l(0,n,"aspectRatio",null,function(e){if(e<0)throw new Error("VRCamera: the aspect ratio has to be a positive real number.");this._leftAspectRatio=e,this._rightAspectRatio=e,this._calculateRightProjectionMatrix()}),l(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}),l(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 Bt(0,0,e.width/2,e.height),this._rightNormalizedViewport=new Bt(e.width/2,0,e.width/2,e.height),this._calculateProjectionMatrix()}),l(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}),l(0,n,"needLeftViewport",function(){var e=this.leftNormalizedViewport;return 0===e.x&&0===e.y&&1===e.width&&1===e.height}),l(0,n,"needRightViewport",function(){var e=this.rightNormalizedViewport;return 0===e.x&&0===e.y&&1===e.width&&1===e.height}),l(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}),l(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}),l(0,n,"leftProjectionMatrix",function(){return this._leftProjectionMatrix}),l(0,n,"leftProjectionViewMatrix",function(){return Ct.multiply(this.leftProjectionMatrix,this.leftViewMatrix,this._leftProjectionViewMatrix),this._leftProjectionViewMatrix}),l(0,n,"rightProjectionMatrix",function(){return this._rightProjectionMatrix}),l(0,n,"rightProjectionViewMatrix",function(){return Ct.multiply(this.rightProjectionMatrix,this.rightViewMatrix,this._rightProjectionViewMatrix),this._rightProjectionViewMatrix}),l(0,n,"leftBoundFrustum",function(){return this._leftBoundFrustumUpdate&&(this._leftBoundFrustum.matrix=this.leftProjectionViewMatrix),this._leftBoundFrustum})}(),function(e){function t(){t.__super.call(this),this._geometryFilter=new Pn(this),this._render=new Ln(this),this._changeRenderObjectsByMaterial(this._render,0,ei.defaultMaterial),this._render.on("materialchanged",this,this._changeRenderObjectsByMaterial),this._geometryFilter.on("trailfilterchange",this,this._changeRenderObjectsByRenderElement)}s(t,"laya.d3.core.trail.TrailSprite3D",e);var n=t.prototype;return n._changeRenderObjectsByMaterial=function(e,t,n){var i=this._geometryFilter.getRenderElementsCount();this._render._renderElements.length=i;for(var r=0;r<i;r++)this._changeRenderObjectByMaterial(r,n)},n._changeRenderObjectByMaterial=function(e,t){var n=this._render._renderElements;t||(t=ei.defaultMaterial);var i=n[e];i||(i=n[e]=new de),i._sprite3D=this,i.renderObj=this._geometryFilter.getRenderElement(e),i._render=this._render,i._material=t},n._changeRenderObjectsByRenderElement=function(e,t){var n=this._render._renderElements,i=n[e];i||(i=n[e]=new de),i._sprite3D=this,i.renderObj=t,i._render=this._render,i._material=this._render.sharedMaterial},n._clearSelfRenderObjects=function(){this.scene.removeFrustumCullingObject(this._render)},n._addSelfRenderObjects=function(){this.scene.addFrustumCullingObject(this._render)},n._update=function(t){e.prototype._update.call(this,t),this._geometryFilter._update(t)},n._parseCustomProps=function(e,t,n,i){var r=this._render,a=this._geometryFilter,o=0,s=0,l=n.materials;if(l){var h=r.sharedMaterials,_=l.length;for(h.length=_,o=0;o<_;o++)h[o]=S.getRes(t[l[o].path]);r.sharedMaterials=h}var u=i.props;a.time=u.time,a.minVertexDistance=u.minVertexDistance,a.widthMultiplier=u.widthMultiplier,a.textureMode=u.textureMode;var c=[],d=n.widthCurve;for(o=0,s=d.length;o<s;o++){var f=new Te;f.time=d[o].time,f.inTangent=d[o].inTangent,f.outTangent=d[o].outTangent,f.value=d[o].value,c.push(f)}a.widthCurve=c;var m=n.colorGradient,p=new Ee;p.mode=m.mode;var v,E,g=[],D=m.colorKeys;for(o=0,s=D.length;o<s;o++)E=D[o],v=new De(new ve(E.value[0],E.value[1],E.value[2],1),E.time),g.push(v);var T,x,M=[],R=m.alphaKeys;for(o=0,s=R.length;o<s;o++)x=R[o],T=new ge(x.value,x.time),M.push(T);p.setKeys(g,M),a.colorGradient=p},n.reset=function(){this.trailFilter.reset()},n.cloneTo=function(e){laya.d3.core.Sprite3D.prototype.cloneTo.call(this,e);var t,n=0,i=e,r=i.trailFilter;r.time=this.trailFilter.time,r.minVertexDistance=this.trailFilter.minVertexDistance,r.widthMultiplier=this.trailFilter.widthMultiplier;var a=this.trailFilter.widthCurve,o=[];for(n=0,t=a.length;n<t;n++){var s=new Te;a[n].cloneTo(s),o.push(s)}r.widthCurve=o;var l=new Ee;this.trailFilter.colorGradient.cloneTo(l),r.colorGradient=l,r.textureMode=this.trailFilter.textureMode,i.trailRender.sharedMaterial=this.trailRender.sharedMaterial},n.destroy=function(t){void 0===t&&(t=!0),this.destroyed||(e.prototype.destroy.call(this,t),this._geometryFilter._destroy(),this._geometryFilter=null)},l(0,n,"trailFilter",function(){return this._geometryFilter}),l(0,n,"trailRender",function(){return this._render}),t.__init__=function(){t.SHADERDEFINE_GRADIENTMODE_BLEND=t.shaderDefines.registerDefine("GRADIENTMODE_BLEND")},t.CURTIME=3,t.LIFETIME=4,t.WIDTHCURVE=5,t.WIDTHCURVEKEYLENGTH=6,t.GRADIENTCOLORKEY=7,t.GRADIENTALPHAKEY=8,t.SHADERDEFINE_GRADIENTMODE_BLEND=0,o(t,["shaderDefines",function(){return this.shaderDefines=new Gt(mi.shaderDefines)}]),t}(mi)),Mi=function(e){function t(e,n,i,r,a,o,s,l){t.__super.call(this,l),this._geometryFilter=new Fn(this,e,n,i,r,a,o,s),this._render=new Bn(this)}s(t,"laya.d3.terrain.TerrainChunk",e);var n=t.prototype;return n.buildRenderElementAndMaterial=function(e,t,n,i,r,a,o,s,l,h,_,u,c,d,f,m,p,v){void 0===_&&(_=1),void 0===u&&(u=1),void 0===c&&(c=1),void 0===d&&(d=1),void 0===f&&(f=1),void 0===m&&(m=1),void 0===p&&(p=1),void 0===v&&(v=1);var E=new Kn;l&&(E.diffuseColor=l),s&&(E.ambientColor=s),h&&(E.specularColor=h),E.splatAlphaTexture=S.getRes(n),E.normalTexture=t?S.getRes(t):null,E.diffuseTexture1=i?S.getRes(i):null,E.diffuseTexture2=r?S.getRes(r):null,E.diffuseTexture3=a?S.getRes(a):null,E.diffuseTexture4=o?S.getRes(o):null,E.setDiffuseScale1(_,u),E.setDiffuseScale2(c,d),E.setDiffuseScale3(f,m),E.setDiffuseScale4(p,v),E.setDetailNum(e),0!=this._render._renderElements.length&&(E.renderMode=2);var g=new de;g._mainSortID=0,g._sprite3D=this,g.renderObj=this._geometryFilter,g._material=E,this._render._materials.push(E),this._render._renderElements.push(g)},n._clearSelfRenderObjects=function(){this.scene.removeFrustumCullingObject(this._render)},n._addSelfRenderObjects=function(){this.scene.addFrustumCullingObject(this._render)},n._applyMeshMaterials=function(e){for(var t=this._render.sharedMaterials,n=e.materials,i=0,r=n.length;i<r;i++)t[i]||(t[i]=n[i]);this._render.sharedMaterials=t},n.cloneTo=function(e){console.log("Terrain Chunk can't clone")},n.destroy=function(t){void 0===t&&(t=!0),this.destroyed||(e.prototype.destroy.call(this,t),this._geometryFilter._destroy())},l(0,n,"terrainFilter",function(){return this._geometryFilter}),l(0,n,"terrainRender",function(){return this._render}),t.load=function(e){return a.loader.create(e,null,null,t,null,1,!1)},t}(mi);!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 Lt}s(t,"laya.d3.core.MeshTerrainSprite3D",Di);var n=t.prototype;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.elements,t=e[0],n=e[1],i=e[2];return Math.sqrt(t*t+n*n+i*i)},n._getScaleZ=function(){var e=this.transform.worldMatrix.elements,t=e[8],n=e[9],i=e[10];return Math.sqrt(t*t+n*n+i*i)},n._initCreateFromMesh=function(e,t){this._heightMap=X.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._initCreateFromMeshHeightMap=function(e,t,n){var i=this,r=this.meshFilter.sharedMesh.boundingBox;e.loaded?(this._heightMap=X.createFromImage(e,t,n),this._computeCellSize(r)):e.once("loaded",null,function(){i._heightMap=X.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-i,o=n.z-r;this._cellSize.elements[0]=a/(this._heightMap.width-1),this._cellSize.elements[1]=o/(this._heightMap.height-1)},n._update=function(e){this._disableRotation(),laya.d3.core.RenderableSprite3D.prototype._update.call(this,e)},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),bt.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,o=Math.floor(a),s=Math.floor(r),l=r-s,h=a-o,_=i.elements,u=_[4],c=_[5],d=_[6],f=Math.sqrt(u*u+c*c+d*d),m=_[13],p=this._heightMap.getHeight(o,s+1),v=this._heightMap.getHeight(o+1,s);if(isNaN(p)||isNaN(v))return NaN;if(l+h<=1){var E=this._heightMap.getHeight(o,s);return isNaN(E)?NaN:(E+l*(p-E)+h*(v-E))*f+m}var g=this._heightMap.getHeight(o+1,s+1);return isNaN(g)?NaN:(g+(1-l)*(v-g)+(1-h)*(p-g))*f+m},l(0,n,"minX",function(){var e=this.transform.worldMatrix.elements;return this._minX*this._getScaleX()+e[12]}),l(0,n,"width",function(){return(this._heightMap.width-1)*this._cellSize.x*this._getScaleX()}),l(0,n,"minZ",function(){var e=this.transform.worldMatrix.elements;return this._minZ*this._getScaleZ()+e[14]}),l(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 o=new t(e,null,a);return e.loaded?o._initCreateFromMeshHeightMap(n,i,r):e.once("loaded",o,o._initCreateFromMeshHeightMap,[n,i,r]),o},o(t,["_tempVector3",function(){return this._tempVector3=new bt},"_tempMatrix4x4",function(){return this._tempMatrix4x4=new Ct}])}()}(window,document,Laya),"function"==typeof define&&define.amd&&define("laya.core",["require","exports"],function(e,t){"use strict";for(var n in Object.defineProperty(t,"__esModule",{value:!0}),Laya){var i=Laya[n];i&&i.__isclass&&(t[n]=i)}});