Files
lifeRestart/public/libs/laya/min/laya.d3.min.js
Vick Scarlet f40698d63e add laya
2021-10-31 00:13:22 +08:00

1 line
946 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
!function(c,S){S.un,S.uns;var l=S.static,p=S.class,_=S.getset,v=S.__newvec,i=(laya.ani.AnimationContent,laya.ani.AnimationPlayer),r=(laya.ani.AnimationState,laya.ani.AnimationTemplet),f=laya.maths.Arith,o=laya.webgl.atlas.AtlasResourceManager,t=laya.webgl.shader.BaseShader,x=laya.utils.Browser,s=laya.webgl.utils.Buffer,g=laya.utils.Byte,a=(laya.ani.bone.canvasmesh.CacheAbleSkinMesh,laya.utils.ClassUtils),h=S.Config,n=(laya.events.Event,laya.events.EventDispatcher),D=laya.utils.Handler,W=laya.net.Loader,u=laya.net.LoaderManager,O=laya.maths.MathUtil,d=laya.display.Node,m=laya.renders.Render,E=(laya.renders.RenderContext,laya.renders.RenderSprite,laya.webgl.utils.RenderState2D),T=laya.resource.Resource,M=laya.utils.RunDriver,R=(laya.webgl.shader.Shader,laya.webgl.utils.ShaderCompile),e=laya.display.Sprite,I=laya.utils.Stat,A=laya.utils.StringKey,C=(laya.display.css.Style,laya.resource.Texture,laya.net.URL),y=laya.utils.Utils,N=laya.webgl.WebGL,V=laya.webgl.WebGLContext;laya.webgl.canvas.WebGLContext2D;S.interface("laya.d3.core.IClone"),S.interface("laya.d3.graphics.IVertex"),S.interface("laya.d3.core.render.IUpdate"),S.interface("laya.d3.core.scene.ITreeNode"),S.interface("laya.d3.core.render.IRenderable");var L=(p(w,"laya.d3.animation.AnimationClipParser01"),w.READ_DATA=function(){w._DATA.offset=w._reader.getUint32(),w._DATA.size=w._reader.getUint32()},w.READ_BLOCK=function(){for(var e=w._BLOCK.count=w._reader.getUint16(),t=w._BLOCK.blockStarts=[],n=w._BLOCK.blockLengths=[],i=0;i<e;i++)t.push(w._reader.getUint32()),n.push(w._reader.getUint32())},w.READ_STRINGS=function(){var e=w._reader.getUint32(),t=w._reader.getUint16(),n=w._reader.pos;w._reader.pos=e+w._DATA.offset;for(var i=0;i<t;i++)w._strings[i]=w._reader.readUTFString();w._reader.pos=n},w.parse=function(e,t){w._animationClip=e;(w._reader=t).__getBuffer();w.READ_DATA(),w.READ_BLOCK(),w.READ_STRINGS();for(var n=0,i=w._BLOCK.count;n<i;n++){var r=t.getUint16(),a=w._strings[r],o=w["READ_"+a];if(null==o)throw new Error("model file err,no this function:"+r+" "+a);o.call()}},w.READ_ANIMATIONS=function(){var e=0,t=0,n=w._reader,i=n.__getBuffer(),r=[],a=n.getUint8();for(r.length=a,e=0;e<a;e++)r[e]=n.getUint16();var o=[],s=n.getUint16();for(o.length=s,e=0;e<s;e++)o[e]=n.getFloat32();var l=w._animationClip;l.name=w._strings[n.getUint16()];var h=l._duration=n.getFloat32();l.islooping=!!n.getByte(),l._frameRate=n.getInt16();var _=n.getInt16(),u=l._nodes=new Array;u.length=_,(l._publicClipDatas=[]).length=_;for(var d=l._nodesMap={},c=0,f=0,e=0;e<_;e++){var m=u[e]=new z,p=n.getUint16(),E=m.path=[];for(E.length=p,t=0;t<p;t++)E[t]=w._strings[n.getUint16()];var v=E.join("/"),g=d[v];g||(d[v]=g=[]),g.push(m);v=n.getInt16();-1!==v&&(m.componentType=w._strings[v]);g=U._propertyIndexDic[w._strings[n.getUint16()]];if(null==g)throw new Error("AnimationClipParser01:unknown property name.");v=g<4,v=!v||v&&""===E[0];(m._cacheProperty=v)?c++:f++,m.propertyNameID=g;var T=r[n.getUint8()];m.keyFrameWidth=T/4;for(var S=m.keyFrames=[],D=S.length=n.getUint16(),x=null,M=NaN,t=0;t<D;t++){var R=S[t]=new H,M=R.startTime=o[n.getUint16()],I=n.pos;R.inTangent=new Float32Array(i.slice(I,I+T)),n.pos+=T,I=n.pos,R.outTangent=new Float32Array(i.slice(I,I+T)),n.pos+=T,I=n.pos,R.data=new Float32Array(i.slice(I,I+T)),n.pos+=T,x&&(x.next=R,x.duration=M-x.startTime),x=R}R.next=null,R.duration=h-M}var A=l._nodeToCachePropertyMap=new Int32Array(_),C=l._cachePropertyMap=new Int32Array(c),y=l._unCachePropertyMap=new Int32Array(f),c=f=0;for(e=0;e<_;e++)(m=u[e])._cacheProperty?(A[e]=c,C[c++]=e):y[f++]=e},w._animationClip=null,w._reader=null,w._strings=[],l(w,["_BLOCK",function(){return this._BLOCK={count:0}},"_DATA",function(){return this._DATA={offset:0,size:0}}]),w);function w(){}var F=(p(P,"laya.d3.animation.AnimationClipParser02"),P.READ_DATA=function(){P._DATA.offset=P._reader.getUint32(),P._DATA.size=P._reader.getUint32()},P.READ_BLOCK=function(){for(var e=P._BLOCK.count=P._reader.getUint16(),t=P._BLOCK.blockStarts=[],n=P._BLOCK.blockLengths=[],i=0;i<e;i++)t.push(P._reader.getUint32()),n.push(P._reader.getUint32())},P.READ_STRINGS=function(){var e=P._reader.getUint32(),t=P._reader.getUint16(),n=P._reader.pos;P._reader.pos=e+P._DATA.offset;for(var i=0;i<t;i++)P._strings[i]=P._reader.readUTFString();P._reader.pos=n},P.parse=function(e,t){P._animationClip=e;(P._reader=t).__getBuffer();P.READ_DATA(),P.READ_BLOCK(),P.READ_STRINGS();for(var n=0,i=P._BLOCK.count;n<i;n++){var r=t.getUint16(),a=P._strings[r],o=P["READ_"+a];if(null==o)throw new Error("model file err,no this function:"+r+" "+a);o.call()}},P.READ_ANIMATIONS=function(){var e=0,t=0,n=P._reader,i=n.__getBuffer(),r=[],a=n.getUint8();for(r.length=a,e=0;e<a;e++)r[e]=n.getUint16();var o=[],s=n.getUint16();for(o.length=s,e=0;e<s;e++)o[e]=n.getFloat32();var l=P._animationClip;l.name=P._strings[n.getUint16()];var h=l._duration=n.getFloat32();l.islooping=!!n.getByte(),l._frameRate=n.getInt16();var _=n.getInt16(),u=l._nodes=new Array;u.length=_,(l._publicClipDatas=[]).length=_;for(var d=l._nodesMap={},c=0,f=0,e=0;e<_;e++){var m=u[e]=new z,p=n.getUint16(),E=m.path=[];for(E.length=p,t=0;t<p;t++)E[t]=P._strings[n.getUint16()];var v=E.join("/"),g=d[v];g||(d[v]=g=[]),g.push(m);v=n.getInt16();-1!==v&&(m.componentType=P._strings[v]);g=U._propertyIndexDic[P._strings[n.getUint16()]];if(null==g)throw new Error("AnimationClipParser02:unknown property name.");v=g<4,v=!v||v&&""===E[0];(m._cacheProperty=v)?c++:f++,m.propertyNameID=g;var T=r[n.getUint8()];m.keyFrameWidth=T/4;for(var S=m.keyFrames=[],D=S.length=n.getUint16(),x=null,M=NaN,t=0;t<D;t++){var R=S[t]=new H,M=R.startTime=o[n.getUint16()],I=n.pos;R.inTangent=new Float32Array(i.slice(I,I+T)),n.pos+=T,I=n.pos,R.outTangent=new Float32Array(i.slice(I,I+T)),n.pos+=T,I=n.pos,R.data=new Float32Array(i.slice(I,I+T)),n.pos+=T,x&&(x.next=R,x.duration=M-x.startTime),x=R}R.next=null,R.duration=h-M}var A=n.getUint16();for(e=0;e<A;e++){var C,y=new b;y.time=n.getFloat32(),y.eventName=P._strings[n.getUint16()];var O=n.getUint16();for(0<O&&(y.params=C=[]),t=0;t<O;t++)switch(n.getByte()){case 0:C.push(!!n.getByte());break;case 1:C.push(n.getInt32());break;case 2:C.push(n.getFloat32());break;case 3:C.push(P._strings[n.getUint16()]);break;default:throw new Error("unknown type.")}l.addEvent(y)}var N=l._nodeToCachePropertyMap=new Int32Array(_),V=l._cachePropertyMap=new Int32Array(c),L=l._unCachePropertyMap=new Int32Array(f),c=f=0;for(e=0;e<_;e++)(m=u[e])._cacheProperty?(N[e]=c,V[c++]=e):L[f++]=e},P._animationClip=null,P._reader=null,P._strings=[],l(P,["_BLOCK",function(){return this._BLOCK={count:0}},"_DATA",function(){return this._DATA={offset:0,size:0}}]),P);function P(){}var b=(p(B,"laya.d3.animation.AnimationEvent"),B);function B(){this.time=NaN,this.eventName=null,this.params=null}var U=function(){function i(){this._childs=[],this.transform=new Bn(this)}p(i,"laya.d3.animation.AnimationNode");var e=i.prototype;return S.imps(e,{"laya.d3.core.IClone":!0}),e.addChild=function(e){e._parent=this,e.transform.setParent(this.transform),this._childs.push(e)},e.removeChild=function(e){e=this._childs.indexOf(e);-1!==e&&this._childs.splice(e,1)},e.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},e.getChildByIndex=function(e){return this._childs[e]},e.getChildCount=function(){return this._childs.length},e.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);r=r.transform,a=a.transform;a.setLocalPosition(r.getLocalPosition()),a.setLocalRotation(r.getLocalRotation()),a.setLocalScale(r.getLocalScale()),a._localRotationEuler=r._localRotationEuler,a._setWorldMatrixIgnoreUpdate(r.getWorldMatrix())}},e.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},i.__init__=function(){i.registerAnimationNodeProperty("localPosition",i._getLocalPosition,i._setLocalPosition),i.registerAnimationNodeProperty("localRotation",i._getLocalRotation,i._setLocalRotation),i.registerAnimationNodeProperty("localScale",i._getLocalScale,i._setLocalScale),i.registerAnimationNodeProperty("localRotationEuler",i._getLocalRotationEuler,i._setLocalRotationEuler),i.registerAnimationNodeProperty("particleRender.sharedMaterial.tintColor",i._getParticleRenderSharedMaterialTintColor,i._setParticleRenderSharedMaterialTintColor),i.registerAnimationNodeProperty("meshRender.sharedMaterial.tilingOffset",i._getMeshRenderSharedMaterialTilingOffset,i._setMeshRenderSharedMaterialTilingOffset),i.registerAnimationNodeProperty("meshRender.sharedMaterial.albedoColor",i._getMeshRenderSharedMaterialAlbedo,i._setMeshRenderSharedMaterialAlbedo),i.registerAnimationNodeProperty("skinnedMeshRender.sharedMaterial.tilingOffset",i._getSkinnedMeshRenderSharedMaterialTilingOffset,i._setSkinnedMeshRenderSharedMaterialTilingOffset),i.registerAnimationNodeProperty("skinnedMeshRender.sharedMaterial.albedoColor",i._getSkinnedMeshRenderSharedMaterialAlbedo,i._setSkinnedMeshRenderSharedMaterialAlbedo),i.registerAnimationNodeProperty("meshRender.sharedMaterial.albedo",i._getMeshRenderSharedMaterialAlbedo,i._setMeshRenderSharedMaterialAlbedo),i.registerAnimationNodeProperty("skinnedMeshRender.sharedMaterial.albedo",i._getSkinnedMeshRenderSharedMaterialAlbedo,i._setSkinnedMeshRenderSharedMaterialAlbedo),i.registerAnimationNodeProperty("meshRender.sharedMaterial.intensity",i._getMeshRenderSharedMaterialIntensity,i._setMeshRenderSharedMaterialIntensity),i.registerAnimationNodeProperty("meshRender.sharedMaterial.alpha",i._getMeshRenderSharedMaterialAlpha,i._setMeshRenderSharedMaterialAlpha),i.registerAnimationNodeProperty("meshRender.sharedMaterial.alphaColor",i._getMeshRenderSharedMaterialAlphaColor,i._setMeshRenderSharedMaterialAlphaColor),i.registerAnimationNodeProperty("meshRender.sharedMaterial.baseColor",i._getMeshRenderSharedMaterialBaseColor,i._setMeshRenderSharedMaterialBaseColor),i.registerAnimationNodeProperty("meshRender.sharedMaterial.dissolve",i._getMeshRenderSharedMaterialDissolve,i._setMeshRenderSharedMaterialDissolve),i.registerAnimationNodeProperty("meshRender.sharedMaterial.dissolveSpeed",i._getMeshRenderSharedMaterialDissolveSpeed,i._setMeshRenderSharedMaterialDissolveSpeed),i.registerAnimationNodeProperty("meshRender.sharedMaterial.mMultiplier",i._getMeshRenderSharedMaterialMMultiplier,i._setMeshRenderSharedMaterialMMultiplier),i.registerAnimationNodeProperty("meshRender.sharedMaterial.baseScrollSpeedX",i._getMeshRenderSharedMaterialBaseScrollSpeedX,i._setMeshRenderSharedMaterialBaseScrollSpeedX),i.registerAnimationNodeProperty("meshRender.sharedMaterial.baseScrollSpeedY",i._getMeshRenderSharedMaterialBaseScrollSpeedY,i._setMeshRenderSharedMaterialBaseScrollSpeedY),i.registerAnimationNodeProperty("meshRender.sharedMaterial.secondScrollSpeedX",i._getMeshRenderSharedMaterialSecondScrollSpeedX,i._setMeshRenderSharedMaterialSecondScrollSpeedX),i.registerAnimationNodeProperty("meshRender.sharedMaterial.secondScrollSpeedY",i._getMeshRenderSharedMaterialSecondScrollSpeedY,i._setMeshRenderSharedMaterialSecondScrollSpeedY),i.registerAnimationNodeProperty("meshRender.sharedMaterial.detailTilingOffset",i._getMeshRenderSharedMaterialDetailTilingOffset,i._setMeshRenderSharedMaterialDetailTilingOffset),i.registerAnimationNodeProperty("meshRender.sharedMaterial.dissolveTilingOffset",i._getMeshRenderSharedMaterialDissolveTilingOffset,i._setMeshRenderSharedMaterialDissolveTilingOffset),i.registerAnimationNodeProperty("meshRender.sharedMaterial.maskTilingOffset",i._getMeshRenderSharedMaterialMaskTilingOffset,i._setMeshRenderSharedMaterialMaskTilingOffset)},i.registerAnimationNodeProperty=function(e,t,n){if(i._propertyIndexDic[e])throw new Error("AnimationNode: this propertyName has registered.");i._propertyIndexDic[e]=i._propertyIDCounter,i._propertyGetFuncs[i._propertyIDCounter]=t,i._propertySetFuncs[i._propertyIDCounter]=n,i._propertyIDCounter++},i._getLocalPosition=function(e,t){return e?e.transform.getLocalPosition():t._transform.localPosition.elements},i._setLocalPosition=function(e,t,n){e?e.transform.setLocalPosition(n):((t=(e=t._transform).localPosition).elements=n,e.localPosition=t)},i._getLocalRotation=function(e,t){return e?e.transform.getLocalRotation():t._transform.localRotation.elements},i._setLocalRotation=function(e,t,n){e?e.transform.setLocalRotation(n):((t=(e=t._transform).localRotation).elements=n,e.localRotation=t)},i._getLocalScale=function(e,t){return e?e.transform.getLocalScale():t._transform.localScale.elements},i._setLocalScale=function(e,t,n){e?e.transform.setLocalScale(n):((t=(e=t._transform).localScale).elements=n,e.localScale=t)},i._getLocalRotationEuler=function(e,t){return e?e.transform.getLocalRotationEuler():t._transform.localRotationEuler.elements},i._setLocalRotationEuler=function(e,t,n){e?e.transform.setLocalRotationEuler(n):((t=(e=t._transform).localRotationEuler).elements=n,e.localRotationEuler=t)},i._getMeshRenderSharedMaterialTilingOffset=function(e,t){if(e){e=e.transform._entity;return e?e.owner.meshRender.sharedMaterial.tilingOffset.elements:null}return t.meshRender.sharedMaterial.tilingOffset.elements},i._setMeshRenderSharedMaterialTilingOffset=function(e,t,n){var i,r;e?(e=e.transform._entity)&&((r=(i=e.owner.meshRender.material).tilingOffset).elements=n,i.tilingOffset=r):((r=(i=t.meshRender.material).tilingOffset).elements=n,i.tilingOffset=r)},i._getMeshRenderSharedMaterialAlbedo=function(e,t){if(e){e=e.transform._entity;return e?e.owner.meshRender.sharedMaterial.albedoColor.elements:null}return t.meshRender.sharedMaterial.albedoColor.elements},i._setMeshRenderSharedMaterialAlbedo=function(e,t,n){var i,r;e?(e=e.transform._entity)&&((r=(i=e.owner.meshRender.material).albedoColor).elements=n,i.albedoColor=r):((r=(i=t.meshRender.material).albedoColor).elements=n,i.albedoColor=r)},i._getSkinnedMeshRenderSharedMaterialTilingOffset=function(e,t){if(e){e=e.transform._entity;return e?e.owner.skinnedMeshRender.sharedMaterial.tilingOffset.elements:null}return t.skinnedMeshRender.sharedMaterial.tilingOffset.elements},i._setSkinnedMeshRenderSharedMaterialTilingOffset=function(e,t,n){var i,r;e?(e=e.transform._entity)&&((r=(i=e.owner.skinnedMeshRender.material).tilingOffset).elements=n,i.tilingOffset=r):((r=(i=t.skinnedMeshRender.material).tilingOffset).elements=n,i.tilingOffset=r)},i._getSkinnedMeshRenderSharedMaterialAlbedo=function(e,t){if(e){e=e.transform._entity;return e?e.owner.skinnedMeshRender.sharedMaterial.albedoColor.elements:null}return t.skinnedMeshRender.sharedMaterial.albedoColor.elements},i._setSkinnedMeshRenderSharedMaterialAlbedo=function(e,t,n){var i,r;e?(e=e.transform._entity)&&((r=(i=e.owner.skinnedMeshRender.material).albedoColor).elements=n,i.albedoColor=r):((r=(i=t.skinnedMeshRender.material).albedoColor).elements=n,i.albedoColor=r)},i._getParticleRenderSharedMaterialTintColor=function(e,t){if(e){e=e.transform._entity;return e?e.owner.particleRender.sharedMaterial.tintColor.elements:null}return t.particleRender.sharedMaterial.tintColor.elements},i._setParticleRenderSharedMaterialTintColor=function(e,t,n){var i,r;e?(e=e.transform._entity)&&((r=(i=e.owner.particleRender.material).tintColor).elements=n,i.tintColor=r):((r=(i=t.particleRender.material).tintColor).elements=n,i.tintColor=r)},i._getMeshRenderSharedMaterialAlphaColor=function(e,t){if(e){e=e.transform._entity;return e?e.owner.meshRender.sharedMaterial.alphaColor.elements:null}return t.meshRender.sharedMaterial.alphaColor.elements},i._setMeshRenderSharedMaterialAlphaColor=function(e,t,n){var i,r;e?(e=e.transform._entity)&&((r=(i=e.owner.meshRender.material).alphaColor).elements=n,i.alphaColor=r):((r=(i=t.meshRender.material).alphaColor).elements=n,i.alphaColor=r)},i._getMeshRenderSharedMaterialBaseColor=function(e,t){if(e){e=e.transform._entity;return e?e.owner.meshRender.sharedMaterial.baseColor.elements:null}return t.meshRender.sharedMaterial.baseColor.elements},i._setMeshRenderSharedMaterialBaseColor=function(e,t,n){var i,r;e?(e=e.transform._entity)&&((r=(i=e.owner.meshRender.material).baseColor).elements=n,i.baseColor=r):((r=(i=t.meshRender.material).baseColor).elements=n,i.baseColor=r)},i._getMeshRenderSharedMaterialDissolve=function(e,t){if(e){e=e.transform._entity;return e?e.owner.meshRender.sharedMaterial.dissolve:0}return t.meshRender.sharedMaterial.dissolve},i._setMeshRenderSharedMaterialDissolve=function(e,t,n){e?(e=e.transform._entity)&&(e.owner.meshRender.material.dissolve=n[0]):t.meshRender.material.dissolve=n[0]},i._getMeshRenderSharedMaterialDissolveSpeed=function(e,t){if(e){e=e.transform._entity;return e?e.owner.meshRender.sharedMaterial.dissolveSpeed:0}return t.meshRender.sharedMaterial.dissolveSpeed},i._setMeshRenderSharedMaterialDissolveSpeed=function(e,t,n){e?(e=e.transform._entity)&&(e.owner.meshRender.material.dissolveSpeed=n[0]):t.meshRender.material.dissolveSpeed=n[0]},i._getMeshRenderSharedMaterialMMultiplier=function(e,t){if(e){e=e.transform._entity;return e?e.owner.meshRender.sharedMaterial.mMultiplier:0}return t.meshRender.sharedMaterial.mMultiplier},i._setMeshRenderSharedMaterialMMultiplier=function(e,t,n){e?(e=e.transform._entity)&&(e.owner.meshRender.material.mMultiplier=n[0]):t.meshRender.material.mMultiplier=n[0]},i._getMeshRenderSharedMaterialBaseScrollSpeedX=function(e,t){if(e){e=e.transform._entity;return e?e.owner.meshRender.sharedMaterial.baseScrollSpeedX:0}return t.meshRender.sharedMaterial.baseScrollSpeedX},i._setMeshRenderSharedMaterialBaseScrollSpeedX=function(e,t,n){e?(e=e.transform._entity)&&(e.owner.meshRender.material.baseScrollSpeedX=n[0]):t.meshRender.material.baseScrollSpeedX=n[0]},i._getMeshRenderSharedMaterialBaseScrollSpeedY=function(e,t){if(e){e=e.transform._entity;return e?e.owner.meshRender.sharedMaterial.baseScrollSpeedY:0}return t.meshRender.sharedMaterial.baseScrollSpeedY},i._setMeshRenderSharedMaterialBaseScrollSpeedY=function(e,t,n){e?(e=e.transform._entity)&&(e.owner.meshRender.material.baseScrollSpeedY=n[0]):t.meshRender.material.baseScrollSpeedY=n[0]},i._getMeshRenderSharedMaterialSecondScrollSpeedX=function(e,t){if(e){e=e.transform._entity;return e?e.owner.meshRender.sharedMaterial.secondScrollSpeedX:0}return t.meshRender.sharedMaterial.secondScrollSpeedX},i._setMeshRenderSharedMaterialSecondScrollSpeedX=function(e,t,n){e?(e=e.transform._entity)&&(e.owner.meshRender.material.secondScrollSpeedX=n[0]):t.meshRender.material.secondScrollSpeedX=n[0]},i._getMeshRenderSharedMaterialSecondScrollSpeedY=function(e,t){if(e){e=e.transform._entity;return e?e.owner.meshRender.sharedMaterial.secondScrollSpeedY:0}return t.meshRender.sharedMaterial.secondScrollSpeedY},i._setMeshRenderSharedMaterialSecondScrollSpeedY=function(e,t,n){e?(e=e.transform._entity)&&(e.owner.meshRender.material.secondScrollSpeedY=n[0]):t.meshRender.material.secondScrollSpeedY=n[0]},i._getMeshRenderSharedMaterialAlpha=function(e,t){if(e){e=e.transform._entity;return e?e.owner.meshRender.sharedMaterial.alpha:0}return t.meshRender.sharedMaterial.alpha},i._setMeshRenderSharedMaterialAlpha=function(e,t,n){e?(e=e.transform._entity)&&(e.owner.meshRender.material.alpha=n[0]):t.meshRender.material.alpha=n[0]},i._getMeshRenderSharedMaterialIntensity=function(e,t){if(e){e=e.transform._entity;return e?e.owner.meshRender.sharedMaterial.intensity:0}return t.meshRender.sharedMaterial.intensity},i._setMeshRenderSharedMaterialIntensity=function(e,t,n){e?(e=e.transform._entity)&&(e.owner.meshRender.material.intensity=n[0]):t.meshRender.material.intensity=n[0]},i._getMeshRenderSharedMaterialDetailTilingOffset=function(e,t){if(e){e=e.transform._entity;return e?e.owner.meshRender.sharedMaterial.detailTilingOffset.elements:null}return t.meshRender.sharedMaterial.detailTilingOffset.elements},i._setMeshRenderSharedMaterialDetailTilingOffset=function(e,t,n){var i,r;e?(e=e.transform._entity)&&((r=(i=e.owner.meshRender.material).detailTilingOffset).elements=n,i.detailTilingOffset=r):((r=(i=t.meshRender.material).detailTilingOffset).elements=n,i.detailTilingOffset=r)},i._getMeshRenderSharedMaterialDissolveTilingOffset=function(e,t){if(e){e=e.transform._entity;return e?e.owner.meshRender.sharedMaterial.dissolveTilingOffset.elements:null}return t.meshRender.sharedMaterial.dissolveTilingOffset.elements},i._setMeshRenderSharedMaterialDissolveTilingOffset=function(e,t,n){var i,r;e?(e=e.transform._entity)&&((r=(i=e.owner.meshRender.material).dissolveTilingOffset).elements=n,i.dissolveTilingOffset=r):((r=(i=t.meshRender.material).dissolveTilingOffset).elements=n,i.dissolveTilingOffset=r)},i._getMeshRenderSharedMaterialMaskTilingOffset=function(e,t){if(e){e=e.transform._entity;return e?e.owner.meshRender.sharedMaterial.maskTilingOffset.elements:null}return t.meshRender.sharedMaterial.maskTilingOffset.elements},i._setMeshRenderSharedMaterialMaskTilingOffset=function(e,t,n){var i,r;e?(e=e.transform._entity)&&((r=(i=e.owner.meshRender.material).maskTilingOffset).elements=n,i.maskTilingOffset=r):((r=(i=t.meshRender.material).maskTilingOffset).elements=n,i.maskTilingOffset=r)},i._propertyIDCounter=0,i._propertyIndexDic={},i._propertySetFuncs=[],i._propertyGetFuncs=[],i}(),H=(p(G,"laya.d3.animation.Keyframe"),G);function G(){this.startTime=NaN,this.inTangent=null,this.outTangent=null,this.data=null,this.duration=NaN,this.next=null}var z=(p(k,"laya.d3.animation.KeyframeNode"),k);function k(){this._cacheProperty=!1,this.path=null,this.componentType=null,this.propertyNameID=0,this.keyFrameWidth=0,this.defaultData=null,this.keyFrames=null}var X=function(){function e(){this._tempVector30=new hn,this._tempVector31=new hn,this._tempVector32=new hn,this._a=new hn,this._b=new hn,this._c=new hn,this._d=new hn}p(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),hn.scale(e,2,this._a),hn.scale(n,2,this._tempVector30),hn.subtract(this._a,this._tempVector30,this._a),hn.add(this._a,t,this._a),hn.add(this._a,i,this._a),hn.scale(n,3,this._b),hn.scale(e,3,this._tempVector30),hn.subtract(this._b,this._tempVector30,this._b),hn.subtract(this._b,i,this._b),hn.scale(t,2,this._tempVector30),hn.subtract(this._b,this._tempVector30,this._b)},t.Slerp=function(e,t){hn.scale(this._a,e*e*e,this._tempVector30),hn.scale(this._b,e*e,this._tempVector31),hn.scale(this._c,e,this._tempVector32),hn.add(this._tempVector30,this._tempVector31,t),hn.add(t,this._tempVector32,t),hn.add(t,this._d,t)},e}(),Y=function(){function y(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}p(y,"laya.d3.core.HeightMap");var e=y.prototype;return e._inBounds=function(e,t){return 0<=e&&e<this._h&&0<=t&&t<this._w},e.getHeight=function(e,t){return this._inBounds(e,t)?this._datas[e][t]:NaN},_(0,e,"width",function(){return this._w}),_(0,e,"height",function(){return this._h}),_(0,e,"maxHeight",function(){return this._maxHeight}),_(0,e,"minHeight",function(){return this._minHeight}),y.creatFromMesh=function(e,t,n,i){for(var r=[],a=[],o=e.getSubMeshCount(),s=0;s<o;s++){for(var l=e.getSubMesh(s),h=l._getVertexBuffer(),_=h.getData(),u=[],d=0;d<_.length;d+=h.vertexDeclaration.vertexStride/4){var c=new hn(_[d+0],_[d+1],_[d+2]);u.push(c)}r.push(u);l=l._getIndexBuffer();a.push(l.getData())}var f=e.boundingBox,m=f.min.x,p=f.min.z,E=f.max.x,v=f.max.z,g=f.min.y,f=f.max.y,v=v-p,T=i.elements[0]=(E-m)/(t-1),S=i.elements[1]=v/(n-1),D=new y(t,n,g,f),x=y._tempRay,g=x.direction.elements;g[0]=0,g[1]=-1,g[2]=0;var M=f+.1;x.origin.elements[1]=M;for(var R=0;R<n;R++){var I=p+R*S;D._datas[R]=[];for(var A=0;A<t;A++){var C=x.origin.elements;C[0]=m+A*T,C[2]=I;C=y._getPosition(x,r,a);D._datas[R][A]=C===Number.MAX_VALUE?NaN:M-C}}return D},y.createFromImage=function(e,t,n){for(var i=e.width,r=e.height,a=new y(i,r,t,n),o=(n-t)/254,s=e.getPixels(),l=0,h=0;h<r;h++)for(var _=a._datas[h]=[],u=0;u<i;u++){var d=s[l++],c=s[l++],f=s[l++],m=s[l++];_[u]=255==d&&255==c&&255==f&&255==m?NaN:(d+c+f)/3*o+t}return a},y._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]],_=yn.rayIntersectsTriangle(e,l,h,_);!isNaN(_)&&_<i&&(i=_)}return i},l(y,["_tempRay",function(){return this._tempRay=new on(new hn,new hn)}]),y}(),Z=function(){function r(){this._visible=!0,this._nonRigidbodyOffset=0,this._colliders=[]}p(r,"laya.d3.core.Layer");var e=r.prototype;return e._binarySearchIndex=function(){for(var e=0,t=r._collsionTestList.length-1;e<=t;){var n=Math.floor((e+t)/2),i=r._collsionTestList[n];if(i==this._number)return n;i>this._number?t=n-1:e=n+1}return e},e._addCollider=function(e){0===this._colliders.length&&r._collsionTestList.splice(this._binarySearchIndex(),0,this._number),e._isRigidbody?(this._colliders.unshift(e),this._nonRigidbodyOffset++):this._colliders.push(e)},e._removeCollider=function(e){e=this._colliders.indexOf(e);e<this._nonRigidbodyOffset&&this._nonRigidbodyOffset--,this._colliders.splice(e,1),0===this._colliders.length&&r._collsionTestList.splice(r._collsionTestList.indexOf(this._number),1)},_(0,e,"number",function(){return this._number}),_(0,e,"visible",function(){return this._visible},function(e){this._visible=e,r._visibleLayers=e?r._visibleLayers|this.mask:r._visibleLayers&~this.mask}),_(0,e,"mask",function(){return this._mask}),_(1,r,"visibleLayers",function(){return r._visibleLayers},function(e){r._visibleLayers=e;for(var t=0,n=r._layerList.length;t<n;t++){var i=r._layerList[t];i._visible=0!=(i._mask&r._visibleLayers)}}),r.__init__=function(){r._layerList.length=31;for(var e=0;e<31;e++){var t=new r;r._layerList[e]=t,0===e?(t.name="Default Layer",t.visible=!0):(t.name="Layer-"+e,t.visible=!1),t._number=e,t._mask=Math.pow(2,e)}r.currentCreationLayer=r._layerList[0]},r.getLayerByNumber=function(e){if(e<0||30<e)throw new Error("无法返回指定Layer该number超出范围");return r._layerList[e]},r.getLayerByName=function(e){for(var t=0;t<31;t++)if(r._layerList[t].name===e)return r._layerList[t];throw new Error("无法返回指定Layer,该name不存在")},r.isVisible=function(e){return 0!=(e&r._currentCameraCullingMask&r._visibleLayers)},r._layerList=[],r._visibleLayers=2147483647,r._collsionTestList=[],r._currentCameraCullingMask=2147483647,r.maxCount=31,r.currentCreationLayer=null,r}(),j=function(){function e(e,t,n){this._time=NaN,this._minCount=0,this._maxCount=0,this._time=e,this._minCount=t,this._maxCount=n}p(e,"laya.d3.core.particleShuriKen.module.Burst");var t=e.prototype;return S.imps(t,{"laya.d3.core.IClone":!0}),t.cloneTo=function(e){e._time=this._time,e._minCount=this._minCount,e._maxCount=this._maxCount},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},_(0,t,"time",function(){return this._time}),_(0,t,"minCount",function(){return this._minCount}),_(0,t,"maxCount",function(){return this._maxCount}),e}(),K=function(){function e(e){this._color=null,this.enbale=!1,this._color=e}p(e,"laya.d3.core.particleShuriKen.module.ColorOverLifetime");var t=e.prototype;return t.cloneTo=function(e){this._color.cloneTo(e._color),e.enbale=this.enbale},t.clone=function(){var e;switch(this._color.type){case 0:e=J.createByConstant(this._color.constant.clone());break;case 1:e=J.createByGradient(this._color.gradient.clone());break;case 2:e=J.createByRandomTwoConstant(this._color.constantMin.clone(),this._color.constantMax.clone());break;case 3:e=J.createByRandomTwoGradient(this._color.gradientMin.clone(),this._color.gradientMax.clone())}var t=new this.constructor(e);return t.enbale=this.enbale,t},_(0,t,"color",function(){return this._color}),e}(),q=function(){function e(){this._destroyed=!1,this._emissionRate=0,this._bursts=null,this.enbale=!1,this._destroyed=!1,this.emissionRate=10,this._bursts=[]}p(e,"laya.d3.core.particleShuriKen.module.Emission");var t=e.prototype;return S.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(0<t)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){e=this._bursts.indexOf(e);-1!==e&&this._bursts.splice(e,1)},t.removeBurstByIndex=function(e){this._bursts.splice(e,1)},t.clearBurst=function(){this._bursts.length=0},t.cloneTo=function(e){var e=e,t=e._bursts;t.length=this._bursts.length;for(var n=0,i=this._bursts.length;n<i;n++){var r=t[n];r?this._bursts[n].cloneTo(r):t[n]=this._bursts[n].clone()}e._emissionRate=this._emissionRate,e.enbale=this.enbale},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},_(0,t,"destroyed",function(){return this._destroyed}),_(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 i(){this._type=0,this._constant=0,this._overTime=null,this._constantMin=0,this._constantMax=0,this._overTimeMin=null,this._overTimeMax=null}p(i,"laya.d3.core.particleShuriKen.module.FrameOverTime");var e=i.prototype;return S.imps(e,{"laya.d3.core.IClone":!0}),e.cloneTo=function(e){e._type=this._type,e._constant=this._constant,this._overTime.cloneTo(e._overTime),e._constantMin=this._constantMin,e._constantMax=this._constantMax,this._overTimeMin.cloneTo(e._overTimeMin),this._overTimeMax.cloneTo(e._overTimeMax)},e.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},_(0,e,"frameOverTimeData",function(){return this._overTime}),_(0,e,"constant",function(){return this._constant}),_(0,e,"type",function(){return this._type}),_(0,e,"frameOverTimeDataMin",function(){return this._overTimeMin}),_(0,e,"constantMin",function(){return this._constantMin}),_(0,e,"frameOverTimeDataMax",function(){return this._overTimeMax}),_(0,e,"constantMax",function(){return this._constantMax}),i.createByConstant=function(e){var t=new i;return t._type=0,t._constant=e,t},i.createByOverTime=function(e){var t=new i;return t._type=1,t._overTime=e,t},i.createByRandomTwoConstant=function(e,t){var n=new i;return n._type=2,n._constantMin=e,n._constantMax=t,n},i.createByRandomTwoOverTime=function(e,t){var n=new i;return n._type=3,n._overTimeMin=e,n._overTimeMax=t,n},i}(),$=function(){function h(){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}p(h,"laya.d3.core.particleShuriKen.module.GradientAngularVelocity");var e=h.prototype;return S.imps(e,{"laya.d3.core.IClone":!0}),e.cloneTo=function(e){e._type=this._type,e._separateAxes=this._separateAxes,e._constant=this._constant,this._constantSeparate.cloneTo(e._constantSeparate),this._gradient.cloneTo(e._gradient),this._gradientX.cloneTo(e._gradientX),this._gradientY.cloneTo(e._gradientY),this._gradientZ.cloneTo(e._gradientZ),e._constantMin=this._constantMin,e._constantMax=this._constantMax,this._constantMinSeparate.cloneTo(e._constantMinSeparate),this._constantMaxSeparate.cloneTo(e._constantMaxSeparate),this._gradientMin.cloneTo(e._gradientMin),this._gradientMax.cloneTo(e._gradientMax),this._gradientXMin.cloneTo(e._gradientXMin),this._gradientXMax.cloneTo(e._gradientXMax),this._gradientYMin.cloneTo(e._gradientYMin),this._gradientYMax.cloneTo(e._gradientYMax),this._gradientZMin.cloneTo(e._gradientZMin),this._gradientZMax.cloneTo(e._gradientZMax)},e.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},_(0,e,"gradientZ",function(){return this._gradientZ}),_(0,e,"constant",function(){return this._constant}),_(0,e,"gradient",function(){return this._gradient}),_(0,e,"separateAxes",function(){return this._separateAxes}),_(0,e,"type",function(){return this._type}),_(0,e,"constantSeparate",function(){return this._constantSeparate}),_(0,e,"gradientX",function(){return this._gradientX}),_(0,e,"gradientY",function(){return this._gradientY}),_(0,e,"gradientW",function(){return this._gradientW}),_(0,e,"gradientMin",function(){return this._gradientMin}),_(0,e,"constantMin",function(){return this._constantMin}),_(0,e,"gradientMax",function(){return this._gradientMax}),_(0,e,"constantMax",function(){return this._constantMax}),_(0,e,"gradientWMin",function(){return this._gradientWMin}),_(0,e,"constantMinSeparate",function(){return this._constantMinSeparate}),_(0,e,"constantMaxSeparate",function(){return this._constantMaxSeparate}),_(0,e,"gradientXMin",function(){return this._gradientXMin}),_(0,e,"gradientXMax",function(){return this._gradientXMax}),_(0,e,"gradientWMax",function(){return this._gradientWMax}),_(0,e,"gradientYMin",function(){return this._gradientYMin}),_(0,e,"gradientYMax",function(){return this._gradientYMax}),_(0,e,"gradientZMin",function(){return this._gradientZMin}),_(0,e,"gradientZMax",function(){return this._gradientZMax}),h.createByConstant=function(e){var t=new h;return t._type=0,t._separateAxes=!1,t._constant=e,t},h.createByConstantSeparate=function(e){var t=new h;return t._type=0,t._separateAxes=!0,t._constantSeparate=e,t},h.createByGradient=function(e){var t=new h;return t._type=1,t._separateAxes=!1,t._gradient=e,t},h.createByGradientSeparate=function(e,t,n,i){var r=new h;return r._type=1,r._separateAxes=!0,r._gradientX=e,r._gradientY=t,r._gradientZ=n,r._gradientW=i,r},h.createByRandomTwoConstant=function(e,t){var n=new h;return n._type=2,n._separateAxes=!1,n._constantMin=e,n._constantMax=t,n},h.createByRandomTwoConstantSeparate=function(e,t){var n=new h;return n._type=2,n._separateAxes=!0,n._constantMinSeparate=e,n._constantMaxSeparate=t,n},h.createByRandomTwoGradient=function(e,t){var n=new h;return n._type=3,n._separateAxes=!1,n._gradientMin=e,n._gradientMax=t,n},h.createByRandomTwoGradientSeparate=function(e,t,n,i,r,a,o,s){var l=new h;return l._type=3,l._separateAxes=!0,l._gradientXMin=e,l._gradientXMax=t,l._gradientYMin=n,l._gradientYMax=i,l._gradientZMin=r,l._gradientZMax=a,l._gradientWMin=o,l._gradientWMax=s,l},h}(),J=function(){function i(){this._type=0,this._constant=null,this._constantMin=null,this._constantMax=null,this._gradient=null,this._gradientMin=null,this._gradientMax=null}p(i,"laya.d3.core.particleShuriKen.module.GradientColor");var e=i.prototype;return S.imps(e,{"laya.d3.core.IClone":!0}),e.cloneTo=function(e){e._type=this._type,this._constant.cloneTo(e._constant),this._constantMin.cloneTo(e._constantMin),this._constantMax.cloneTo(e._constantMax),this._gradient.cloneTo(e._gradient),this._gradientMin.cloneTo(e._gradientMin),this._gradientMax.cloneTo(e._gradientMax)},e.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},_(0,e,"gradient",function(){return this._gradient}),_(0,e,"constant",function(){return this._constant}),_(0,e,"type",function(){return this._type}),_(0,e,"gradientMin",function(){return this._gradientMin}),_(0,e,"constantMin",function(){return this._constantMin}),_(0,e,"gradientMax",function(){return this._gradientMax}),_(0,e,"constantMax",function(){return this._constantMax}),i.createByConstant=function(e){var t=new i;return t._type=0,t._constant=e,t},i.createByGradient=function(e){var t=new i;return t._type=1,t._gradient=e,t},i.createByRandomTwoConstant=function(e,t){var n=new i;return n._type=2,n._constantMin=e,n._constantMax=t,n},i.createByRandomTwoGradient=function(e,t){var n=new i;return n._type=3,n._gradientMin=e,n._gradientMax=t,n},i}(),ee=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)}p(e,"laya.d3.core.particleShuriKen.module.GradientDataColor");var t=e.prototype;return S.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 e=e,t=0,n=0;e._alphaCurrentLength=this._alphaCurrentLength;var i=e._alphaElements;for(i.length=this._alphaElements.length,t=0,n=this._alphaElements.length;t<n;t++)i[t]=this._alphaElements[t];e._rgbCurrentLength=this._rgbCurrentLength;var r=e._rgbElements;for(r.length=this._rgbElements.length,t=0,n=this._rgbElements.length;t<n;t++)r[t]=this._rgbElements[t]},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},_(0,t,"alphaGradientCount",function(){return this._alphaCurrentLength/2}),_(0,t,"rgbGradientCount",function(){return this._rgbCurrentLength/4}),e}(),te=function(){function e(){this._currentLength=0,this._elements=null,this._elements=new Float32Array(8)}p(e,"laya.d3.core.particleShuriKen.module.GradientDataInt");var t=e.prototype;return S.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){e._currentLength=this._currentLength;var t=e._elements;t.length=this._elements.length;for(var n=0,i=this._elements.length;n<i;n++)t[n]=this._elements[n]},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},_(0,t,"gradientCount",function(){return this._currentLength/2}),e}(),ne=function(){function e(){this._currentLength=0,this._elements=null,this._elements=new Float32Array(8)}p(e,"laya.d3.core.particleShuriKen.module.GradientDataNumber");var t=e.prototype;return S.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){e._currentLength=this._currentLength;var t=e._elements;t.length=this._elements.length;for(var n=0,i=this._elements.length;n<i;n++)t[n]=this._elements[n]},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},_(0,t,"gradientCount",function(){return this._currentLength/2}),e}(),ie=(function(){function e(){this._currentLength=0,this._elements=null,this._elements=new Float32Array(12)}p(e,"laya.d3.core.particleShuriKen.module.GradientDataVector2");var t=e.prototype;S.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){e._currentLength=this._currentLength;var t=e._elements;t.length=this._elements.length;for(var n=0,i=this._elements.length;n<i;n++)t[n]=this._elements[n]},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},_(0,t,"gradientCount",function(){return this._currentLength/3})}(),function(){function s(){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}p(s,"laya.d3.core.particleShuriKen.module.GradientSize");var e=s.prototype;return S.imps(e,{"laya.d3.core.IClone":!0}),e.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:n=this._separateAxes?(n=Math.max(this._constantMinSeparate.x,this._constantMaxSeparate.x),n=Math.max(n,this._constantMinSeparate.y),Math.max(n,this._constantMaxSeparate.y)):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},e.cloneTo=function(e){e._type=this._type,e._separateAxes=this._separateAxes,this._gradient.cloneTo(e._gradient),this._gradientX.cloneTo(e._gradientX),this._gradientY.cloneTo(e._gradientY),this._gradientZ.cloneTo(e._gradientZ),e._constantMin=this._constantMin,e._constantMax=this._constantMax,this._constantMinSeparate.cloneTo(e._constantMinSeparate),this._constantMaxSeparate.cloneTo(e._constantMaxSeparate),this._gradientMin.cloneTo(e._gradientMin),this._gradientMax.cloneTo(e._gradientMax),this._gradientXMin.cloneTo(e._gradientXMin),this._gradientXMax.cloneTo(e._gradientXMax),this._gradientYMin.cloneTo(e._gradientYMin),this._gradientYMax.cloneTo(e._gradientYMax),this._gradientZMin.cloneTo(e._gradientZMin),this._gradientZMax.cloneTo(e._gradientZMax)},e.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},_(0,e,"gradientZ",function(){return this._gradientZ}),_(0,e,"gradient",function(){return this._gradient}),_(0,e,"separateAxes",function(){return this._separateAxes}),_(0,e,"type",function(){return this._type}),_(0,e,"gradientMin",function(){return this._gradientMin}),_(0,e,"constantMin",function(){return this._constantMin}),_(0,e,"gradientX",function(){return this._gradientX}),_(0,e,"gradientY",function(){return this._gradientY}),_(0,e,"gradientMax",function(){return this._gradientMax}),_(0,e,"constantMax",function(){return this._constantMax}),_(0,e,"constantMinSeparate",function(){return this._constantMinSeparate}),_(0,e,"constantMaxSeparate",function(){return this._constantMaxSeparate}),_(0,e,"gradientXMin",function(){return this._gradientXMin}),_(0,e,"gradientXMax",function(){return this._gradientXMax}),_(0,e,"gradientYMin",function(){return this._gradientYMin}),_(0,e,"gradientYMax",function(){return this._gradientYMax}),_(0,e,"gradientZMin",function(){return this._gradientZMin}),_(0,e,"gradientZMax",function(){return this._gradientZMax}),s.createByGradient=function(e){var t=new s;return t._type=0,t._separateAxes=!1,t._gradient=e,t},s.createByGradientSeparate=function(e,t,n){var i=new s;return i._type=0,i._separateAxes=!0,i._gradientX=e,i._gradientY=t,i._gradientZ=n,i},s.createByRandomTwoConstant=function(e,t){var n=new s;return n._type=1,n._separateAxes=!1,n._constantMin=e,n._constantMax=t,n},s.createByRandomTwoConstantSeparate=function(e,t){var n=new s;return n._type=1,n._separateAxes=!0,n._constantMinSeparate=e,n._constantMaxSeparate=t,n},s.createByRandomTwoGradient=function(e,t){var n=new s;return n._type=2,n._separateAxes=!1,n._gradientMin=e,n._gradientMax=t,n},s.createByRandomTwoGradientSeparate=function(e,t,n,i,r,a){var o=new s;return o._type=2,o._separateAxes=!0,o._gradientXMin=e,o._gradientXMax=t,o._gradientYMin=n,o._gradientYMax=i,o._gradientZMin=r,o._gradientZMax=a,o},s}()),re=function(){function s(){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}p(s,"laya.d3.core.particleShuriKen.module.GradientVelocity");var e=s.prototype;return S.imps(e,{"laya.d3.core.IClone":!0}),e.cloneTo=function(e){e._type=this._type,this._constant.cloneTo(e._constant),this._gradientX.cloneTo(e._gradientX),this._gradientY.cloneTo(e._gradientY),this._gradientZ.cloneTo(e._gradientZ),this._constantMin.cloneTo(e._constantMin),this._constantMax.cloneTo(e._constantMax),this._gradientXMin.cloneTo(e._gradientXMin),this._gradientXMax.cloneTo(e._gradientXMax),this._gradientYMin.cloneTo(e._gradientYMin),this._gradientYMax.cloneTo(e._gradientYMax),this._gradientZMin.cloneTo(e._gradientZMin),this._gradientZMax.cloneTo(e._gradientZMax)},e.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},_(0,e,"gradientZ",function(){return this._gradientZ}),_(0,e,"constant",function(){return this._constant}),_(0,e,"type",function(){return this._type}),_(0,e,"gradientXMax",function(){return this._gradientXMax}),_(0,e,"constantMin",function(){return this._constantMin}),_(0,e,"gradientX",function(){return this._gradientX}),_(0,e,"gradientY",function(){return this._gradientY}),_(0,e,"gradientXMin",function(){return this._gradientXMin}),_(0,e,"constantMax",function(){return this._constantMax}),_(0,e,"gradientYMin",function(){return this._gradientYMin}),_(0,e,"gradientYMax",function(){return this._gradientYMax}),_(0,e,"gradientZMin",function(){return this._gradientZMin}),_(0,e,"gradientZMax",function(){return this._gradientZMax}),s.createByConstant=function(e){var t=new s;return t._type=0,t._constant=e,t},s.createByGradient=function(e,t,n){var i=new s;return i._type=1,i._gradientX=e,i._gradientY=t,i._gradientZ=n,i},s.createByRandomTwoConstant=function(e,t){var n=new s;return n._type=2,n._constantMin=e,n._constantMax=t,n},s.createByRandomTwoGradient=function(e,t,n,i,r,a){var o=new s;return o._type=3,o._gradientXMin=e,o._gradientXMax=t,o._gradientYMin=n,o._gradientYMax=i,o._gradientZMin=r,o._gradientZMax=a,o},s}(),ae=function(){function e(e){this._angularVelocity=null,this.enbale=!1,this._angularVelocity=e}p(e,"laya.d3.core.particleShuriKen.module.RotationOverLifetime");var t=e.prototype;return S.imps(t,{"laya.d3.core.IClone":!0}),t.cloneTo=function(e){this._angularVelocity.cloneTo(e._angularVelocity),e.enbale=this.enbale},t.clone=function(){var e;switch(this._angularVelocity.type){case 0:e=this._angularVelocity.separateAxes?$.createByConstantSeparate(this._angularVelocity.constantSeparate.clone()):$.createByConstant(this._angularVelocity.constant);break;case 1:e=this._angularVelocity.separateAxes?$.createByGradientSeparate(this._angularVelocity.gradientX.clone(),this._angularVelocity.gradientY.clone(),this._angularVelocity.gradientZ.clone(),this._angularVelocity.gradientW.clone()):$.createByGradient(this._angularVelocity.gradient.clone());break;case 2:e=this._angularVelocity.separateAxes?$.createByRandomTwoConstantSeparate(this._angularVelocity.constantMinSeparate.clone(),this._angularVelocity.constantMaxSeparate.clone()):$.createByRandomTwoConstant(this._angularVelocity.constantMin,this._angularVelocity.constantMax);break;case 3:e=this._angularVelocity.separateAxes?$.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()):$.createByRandomTwoGradient(this._angularVelocity.gradientMin.clone(),this._angularVelocity.gradientMax.clone())}var t=new this.constructor(e);return t.enbale=this.enbale,t},_(0,t,"angularVelocity",function(){return this._angularVelocity}),e}(),oe=function(){function e(){this.enable=!1,this.randomDirection=!1}p(e,"laya.d3.core.particleShuriKen.module.shape.BaseShape");var t=e.prototype;return S.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;hn.multiply(i,t,i),hn.multiply(r,t,r);var a=new kt(new hn,new hn);this.randomDirection?(a.min=new hn(-1,-1,-1),a.max=new hn(1,1,1)):this._getSpeedBoundBox(a);var o=new kt(new hn,new hn),s=o.min,i=o.max;hn.scale(a.min,n.y,s),hn.scale(a.max,n.y,i),hn.add(e.min,s,s),hn.add(e.max,i,i),hn.min(e.min,s,e.min),hn.max(e.max,s,e.max);t=new kt(new hn,new hn),r=t.min,o=t.max;hn.scale(a.min,n.x,r),hn.scale(a.max,n.x,o),hn.min(t.min,o,s),hn.max(t.min,o,i),hn.min(e.min,s,e.min),hn.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}(),se=(p(le,"laya.d3.core.particleShuriKen.module.shape.ShapeUtils"),le._randomPointUnitArcCircle=function(e,t,n){var i=t.elements,t=NaN,t=n?n.getFloat()*e:Math.random()*e;i[0]=Math.cos(t),i[1]=Math.sin(t)},le._randomPointInsideUnitArcCircle=function(e,t,n){var i=t.elements;le._randomPointUnitArcCircle(e,t,n);t=NaN,t=n?Math.pow(n.getFloat(),.5):Math.pow(Math.random(),.5);i[0]=i[0]*t,i[1]=i[1]*t},le._randomPointUnitCircle=function(e,t){var n=e.elements,e=NaN,e=t?t.getFloat()*Math.PI*2:Math.random()*Math.PI*2;n[0]=Math.cos(e),n[1]=Math.sin(e)},le._randomPointInsideUnitCircle=function(e,t){var n=e.elements;le._randomPointUnitCircle(e);e=NaN,e=t?Math.pow(t.getFloat(),.5):Math.pow(Math.random(),.5);n[0]=n[0]*e,n[1]=n[1]*e},le._randomPointUnitSphere=function(e,t){var n=e.elements,i=NaN,e=NaN,e=t?(i=n[2]=2*t.getFloat()-1,t.getFloat()*Math.PI*2):(i=n[2]=2*Math.random()-1,Math.random()*Math.PI*2),i=Math.sqrt(1-i*i);n[0]=i*Math.cos(e),n[1]=i*Math.sin(e)},le._randomPointInsideUnitSphere=function(e,t){var n=e.elements;le._randomPointUnitSphere(e);e=NaN,e=t?Math.pow(t.getFloat(),1/3):Math.pow(Math.random(),1/3);n[0]=n[0]*e,n[1]=n[1]*e,n[2]=n[2]*e},le._randomPointInsideHalfUnitBox=function(e,t){e=e.elements;t?(e[0]=t.getFloat()-.5,e[1]=t.getFloat()-.5,e[2]=t.getFloat()-.5):(e[0]=Math.random()-.5,e[1]=Math.random()-.5,e[2]=Math.random()-.5)},le);function le(){}var he=function(){function e(e){this._size=null,this.enbale=!1,this._size=e}p(e,"laya.d3.core.particleShuriKen.module.SizeOverLifetime");var t=e.prototype;return S.imps(t,{"laya.d3.core.IClone":!0}),t.cloneTo=function(e){this._size.cloneTo(e._size),e.enbale=this.enbale},t.clone=function(){var e;switch(this._size.type){case 0:e=this._size.separateAxes?ie.createByGradientSeparate(this._size.gradientX.clone(),this._size.gradientY.clone(),this._size.gradientZ.clone()):ie.createByGradient(this._size.gradient.clone());break;case 1:e=this._size.separateAxes?ie.createByRandomTwoConstantSeparate(this._size.constantMinSeparate.clone(),this._size.constantMaxSeparate.clone()):ie.createByRandomTwoConstant(this._size.constantMin,this._size.constantMax);break;case 2:e=this._size.separateAxes?ie.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()):ie.createByRandomTwoGradient(this._size.gradientMin.clone(),this._size.gradientMax.clone())}var t=new this.constructor(e);return t.enbale=this.enbale,t},_(0,t,"size",function(){return this._size}),e}(),_e=function(){function i(){this._type=0,this._constant=NaN,this._constantMin=NaN,this._constantMax=NaN}p(i,"laya.d3.core.particleShuriKen.module.StartFrame");var e=i.prototype;return S.imps(e,{"laya.d3.core.IClone":!0}),e.cloneTo=function(e){e._type=this._type,e._constant=this._constant,e._constantMin=this._constantMin,e._constantMax=this._constantMax},e.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},_(0,e,"constant",function(){return this._constant}),_(0,e,"type",function(){return this._type}),_(0,e,"constantMin",function(){return this._constantMin}),_(0,e,"constantMax",function(){return this._constantMax}),i.createByConstant=function(e){var t=new i;return t._type=0,t._constant=e,t},i.createByRandomTwoConstant=function(e,t){var n=new i;return n._type=1,n._constantMin=e,n._constantMax=t,n},i}(),ue=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 ln(1,1),this.type=0,this.randomRow=!0,this.rowIndex=0,this.cycles=1,this.enableUVChannels=1,this._frame=e,this._startFrame=t}p(e,"laya.d3.core.particleShuriKen.module.TextureSheetAnimation");var t=e.prototype;return S.imps(t,{"laya.d3.core.IClone":!0}),t.cloneTo=function(e){this.tiles.cloneTo(e.tiles),e.type=this.type,e.randomRow=this.randomRow,this._frame.cloneTo(e._frame),this._startFrame.cloneTo(e._startFrame),e.cycles=this.cycles,e.enableUVChannels=this.enableUVChannels,e.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=_e.createByConstant(this._startFrame.constant);break;case 1:t=_e.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},_(0,t,"frame",function(){return this._frame}),_(0,t,"startFrame",function(){return this._startFrame}),e}(),de=function(){function e(e){this._velocity=null,this.enbale=!1,this.space=0,this._velocity=e}p(e,"laya.d3.core.particleShuriKen.module.VelocityOverLifetime");var t=e.prototype;return S.imps(t,{"laya.d3.core.IClone":!0}),t.cloneTo=function(e){this._velocity.cloneTo(e._velocity),e.enbale=this.enbale,e.space=this.space},t.clone=function(){var e;switch(this._velocity.type){case 0:e=re.createByConstant(this._velocity.constant.clone());break;case 1:e=re.createByGradient(this._velocity.gradientX.clone(),this._velocity.gradientY.clone(),this._velocity.gradientZ.clone());break;case 2:e=re.createByRandomTwoConstant(this._velocity.constantMin.clone(),this._velocity.constantMax.clone());break;case 3:e=re.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},_(0,t,"velocity",function(){return this._velocity}),e}(),ce=(p(fe,"laya.d3.core.particleShuriKen.ShurikenParticleData"),fe._getStartLifetimeFromGradient=function(e,t){for(var n=1,i=e.gradientCount;n<i;n++){var r=e.getKeyByIndex(n);if(t<=r){var a=e.getKeyByIndex(n-1),a=(t-a)/(r-a);return O.lerp(e.getValueByIndex(n-1),e.getValueByIndex(n),a)}}throw new Error("ShurikenParticleData: can't get value foam startLifeTimeGradient.")},fe._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])},fe._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(),e=r<t?-e:e},fe.create=function(e,t,n){var i=e.autoRandomSeed,r=e._rand,a=e._randomSeeds;switch(e.startColorType){case 0:var o=e.startColorConstant.elements;fe.startColor[0]=o[0],fe.startColor[1]=o[1],fe.startColor[2]=o[2],fe.startColor[3]=o[3];break;case 2:i?O.lerpVector4(e.startColorConstantMin.elements,e.startColorConstantMax.elements,Math.random(),fe.startColor):(r.seed=a[3],O.lerpVector4(e.startColorConstantMin.elements,e.startColorConstantMax.elements,r.getFloat(),fe.startColor),a[3]=r.seed)}var s=e.colorOverLifetime;if(s&&s.enbale){var l=s.color;switch(l.type){case 0:fe.startColor[0]=fe.startColor[0]*l.constant.x,fe.startColor[1]=fe.startColor[1]*l.constant.y,fe.startColor[2]=fe.startColor[2]*l.constant.z,fe.startColor[3]=fe.startColor[3]*l.constant.w;break;case 2:var h=NaN;i?h=Math.random():(r.seed=a[10],h=r.getFloat(),a[10]=r.seed);var _=l.constantMin,u=l.constantMax;fe.startColor[0]=fe.startColor[0]*O.lerp(_.x,u.x,h),fe.startColor[1]=fe.startColor[1]*O.lerp(_.y,u.y,h),fe.startColor[2]=fe.startColor[2]*O.lerp(_.z,u.z,h),fe.startColor[3]=fe.startColor[3]*O.lerp(_.w,u.w,h)}}var d,c,f=fe.startSize;switch(e.startSizeType){case 0:e.threeDStartSize?(c=e.startSizeConstantSeparate,f[0]=c.x,f[1]=c.y,f[2]=c.z):f[0]=f[1]=f[2]=e.startSizeConstant;break;case 2:e.threeDStartSize?(d=e.startSizeConstantMinSeparate,c=e.startSizeConstantMaxSeparate,i?(f[0]=O.lerp(d.x,c.x,Math.random()),f[1]=O.lerp(d.y,c.y,Math.random()),f[2]=O.lerp(d.z,c.z,Math.random())):(r.seed=a[4],f[0]=O.lerp(d.x,c.x,r.getFloat()),f[1]=O.lerp(d.y,c.y,r.getFloat()),f[2]=O.lerp(d.z,c.z,r.getFloat()),a[4]=r.seed)):i?f[0]=f[1]=f[2]=O.lerp(e.startSizeConstantMin,e.startSizeConstantMax,Math.random()):(r.seed=a[4],f[0]=f[1]=f[2]=O.lerp(e.startSizeConstantMin,e.startSizeConstantMax,r.getFloat()),a[4]=r.seed)}s=e.sizeOverLifetime;s&&s.enbale&&1===s.size.type&&((S=s.size).separateAxes?i?(f[0]=f[0]*O.lerp(S.constantMinSeparate.x,S.constantMaxSeparate.x,Math.random()),f[1]=f[1]*O.lerp(S.constantMinSeparate.y,S.constantMaxSeparate.y,Math.random()),f[2]=f[2]*O.lerp(S.constantMinSeparate.z,S.constantMaxSeparate.z,Math.random())):(r.seed=a[11],f[0]=f[0]*O.lerp(S.constantMinSeparate.x,S.constantMaxSeparate.x,r.getFloat()),f[1]=f[1]*O.lerp(S.constantMinSeparate.y,S.constantMaxSeparate.y,r.getFloat()),f[2]=f[2]*O.lerp(S.constantMinSeparate.z,S.constantMaxSeparate.z,r.getFloat()),a[11]=r.seed):(M=NaN,i?M=O.lerp(S.constantMin,S.constantMax,Math.random()):(r.seed=a[11],M=O.lerp(S.constantMin,S.constantMax,r.getFloat()),a[11]=r.seed),f[0]=f[0]*M,f[1]=f[1]*M,f[2]=f[2]*M));var m,p,E,v=t.renderMode;if(1!==v)switch(e.startRotationType){case 0:e.threeDStartRotation?(p=e.startRotationConstantSeparate,E=fe._tempVector30.elements,fe._randomInvertRoationArray(p.elements,E,e.randomizeRotationDirection,i?null:r,a),fe.startRotation[0]=E[0],fe.startRotation[1]=E[1],fe.startRotation[2]=4!==v?-E[2]:E[2]):fe.startRotation[0]=fe._randomInvertRoation(e.startRotationConstant,e.randomizeRotationDirection,i?null:r,a);break;case 2:e.threeDStartRotation?(m=e.startRotationConstantMinSeparate,p=e.startRotationConstantMaxSeparate,E=fe._tempVector30.elements,i?(E[0]=O.lerp(m.x,p.x,Math.random()),E[1]=O.lerp(m.y,p.y,Math.random()),E[2]=O.lerp(m.z,p.z,Math.random())):(r.seed=a[5],E[0]=O.lerp(m.x,p.x,r.getFloat()),E[1]=O.lerp(m.y,p.y,r.getFloat()),E[2]=O.lerp(m.z,p.z,r.getFloat()),a[5]=r.seed),fe._randomInvertRoationArray(E,E,e.randomizeRotationDirection,i?null:r,a),fe.startRotation[0]=E[0],fe.startRotation[1]=E[1],fe.startRotation[2]=4!==v?-E[2]:E[2]):i?fe.startRotation[0]=fe._randomInvertRoation(O.lerp(e.startRotationConstantMin,e.startRotationConstantMax,Math.random()),e.randomizeRotationDirection,i?null:r,a):(r.seed=a[5],fe.startRotation[0]=fe._randomInvertRoation(O.lerp(e.startRotationConstantMin,e.startRotationConstantMax,r.getFloat()),e.randomizeRotationDirection,i?null:r,a),a[5]=r.seed)}switch(e.startLifetimeType){case 0:fe.startLifeTime=e.startLifetimeConstant;break;case 1:fe.startLifeTime=fe._getStartLifetimeFromGradient(e.startLifeTimeGradient,e.emissionTime);break;case 2:i?fe.startLifeTime=O.lerp(e.startLifetimeConstantMin,e.startLifetimeConstantMax,Math.random()):(r.seed=a[7],fe.startLifeTime=O.lerp(e.startLifetimeConstantMin,e.startLifetimeConstantMax,r.getFloat()),a[7]=r.seed);break;case 3:var g=e.emissionTime;i?fe.startLifeTime=O.lerp(fe._getStartLifetimeFromGradient(e.startLifeTimeGradientMin,g),fe._getStartLifetimeFromGradient(e.startLifeTimeGradientMax,g),Math.random()):(r.seed=a[7],fe.startLifeTime=O.lerp(fe._getStartLifetimeFromGradient(e.startLifeTimeGradientMin,g),fe._getStartLifetimeFromGradient(e.startLifeTimeGradientMax,g),r.getFloat()),a[7]=r.seed)}switch(e.startSpeedType){case 0:fe.startSpeed=e.startSpeedConstant;break;case 2:i?fe.startSpeed=O.lerp(e.startSpeedConstantMin,e.startSpeedConstantMax,Math.random()):(r.seed=a[8],fe.startSpeed=O.lerp(e.startSpeedConstantMin,e.startSpeedConstantMax,r.getFloat()),a[8]=r.seed)}var T=e.textureSheetAnimation;if(T&&T.enable){var S=T.tiles,D=S.x,x=S.y,M=1/D,t=1/x,R=0,I=T.startFrame;switch(I.type){case 0:R=I.constant;break;case 1:i?R=O.lerp(I.constantMin,I.constantMax,Math.random()):(r.seed=a[14],R=O.lerp(I.constantMin,I.constantMax,r.getFloat()),a[14]=r.seed)}var A=T.frame;switch(A.type){case 0:R+=A.constant;break;case 2:i?R+=O.lerp(A.constantMin,A.constantMax,Math.random()):(r.seed=a[15],R+=O.lerp(A.constantMin,A.constantMax,r.getFloat()),a[15]=r.seed)}var C=0;switch(T.type){case 0:C=Math.floor(R/D);break;case 1:T.randomRow?i?C=Math.floor(Math.random()*x):(r.seed=a[13],C=Math.floor(r.getFloat()*x),a[13]=r.seed):C=T.rowIndex}S=Math.floor(R%D);fe.startUVInfo[0]=M,fe.startUVInfo[1]=t,fe.startUVInfo[2]=S*M,fe.startUVInfo[3]=C*t}else fe.startUVInfo[0]=1,fe.startUVInfo[1]=1,fe.startUVInfo[2]=0,fe.startUVInfo[3]=0;switch(e.simulationSpace){case 0:var y=n.position.elements;fe.simulationWorldPostion[0]=y[0],fe.simulationWorldPostion[1]=y[1],fe.simulationWorldPostion[2]=y[2];y=n.rotation.elements;fe.simulationWorldRotation[0]=y[0],fe.simulationWorldRotation[1]=y[1],fe.simulationWorldRotation[2]=y[2],fe.simulationWorldRotation[3]=y[3];break;case 1:break;default:throw new Error("ShurikenParticleMaterial: SimulationSpace value is invalid.")}},fe.startLifeTime=NaN,fe.startSpeed=NaN,l(fe,["_tempVector30",function(){return this._tempVector30=new hn},"_tempQuaternion",function(){return this._tempQuaternion=new rn},"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)}]),fe);function fe(){}var me=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 vn,this._vb=Gi.create(e._vertexDeclaration,this._defaultBufferSize/this._floatSizePerVer,35048),this._ib=Ui.create("ushort",this._defaultBufferSize,35048),this._sharderNameID=Vi.nameKey.getID("LINE"),this._shaderCompile=$n._preCompileShader[this._sharderNameID]}p(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),I.drawCall++,N.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”基元")},l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(28,[new Xe(0,"vector3",0),new Xe(12,"vector4",1)])}]),e}(),pe=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 vn}p(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(),e=t.vertexDeclaration,i=e.getVertexElementByUsage(0).offset/4,r=e.getVertexElementByUsage(3).offset/4,t=this._sprite3D.transform,a=t.worldMatrix,o=t.rotation,s=e.vertexStride/4,l=0,h=n.length;l<h;l+=s){var _=l+i,u=l+r;wn.transformVector3ArrayToVector3ArrayCoordinate(n,_,a,n,_),wn.transformVector3ArrayByQuat(n,u,o,n,u)}return n},t.getBakedIndices=function(){return this._renderObj._getIndexBuffer().getData()},t._destroy=function(){this._staticBatch&&this._staticBatch._manager._garbageCollection(this)},_(0,t,"id",function(){return this._id}),_(0,t,"renderObj",function(){return this._renderObj},function(e){this._renderObj!==e&&(this._renderObj=e)}),e._uniqueIDCounter=0,e}(),Ee=function(){function t(e){this._id=0,this._needSort=!1,this._renderElements=null,this._renderableRenderObjects=null,this._dynamicBatchCombineRenderElements=null,this._finalElements=null,this._scene=null,this._id=++t._uniqueIDCounter,this._needSort=!1,this._scene=e,this._renderElements=[],this._renderableRenderObjects=[],this._dynamicBatchCombineRenderElements=[]}p(t,"laya.d3.core.render.RenderQueue");var e=t.prototype;return e._sortOpaqueFunc=function(e,t){if(e._render&&t._render){var n=e._material.renderQueue-t._material.renderQueue;return 0==n?e._render._distanceForSort-t._render._distanceForSort:n}return 0},e._sortAlphaFunc=function(e,t){if(e._render&&t._render){var n=e._material.renderQueue-t._material.renderQueue;return 0==n?t._render._distanceForSort-e._render._distanceForSort:n}return 0},e._begainRenderElement=function(e,t,n){return!!t._beforeRender(e)},e._sortAlpha=function(e){t._cameraPosition=e,this._finalElements.sort(this._sortAlphaFunc)},e._sortOpaque=function(e){t._cameraPosition=e,this._finalElements.sort(this._sortOpaqueFunc)},e._preRender=function(e){this._finalElements=this._renderElements.concat(this._dynamicBatchCombineRenderElements)},e._render=function(e,t){for(var n,i,r,a,o,s,l=I.loopCount,h=this._scene,_=e.camera,u=(_.id,!1),d=0,c=this._finalElements.length;d<c;d++){var f,m,p,E=this._finalElements[d];if(null!=E._onPreRenderFunction&&E._onPreRenderFunction.call(E._sprite3D,e),0===E._type){if(e.owner=p=E._sprite3D,e.renderElement=E,p._preRenderUpdateComponents(e),f=E.renderObj,m=E._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 v=0;v<n.length;v++){var g=n[v];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===E._type&&(E.renderObj,e.owner=p=E._sprite3D,e.renderElement=E,e._batchIndexStart=E._tempBatchIndexStart,e._batchIndexEnd=E._tempBatchIndexEnd,f=E.renderObj,m=E._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))}},e._renderShadow=function(e,t){for(var n,i,r,a,o,s=I.loopCount,l=this._scene,h=e.camera,_=0,u=this._finalElements.length;_<u;_++){var d,c,f,m=this._finalElements[_];0===m._type&&(e.owner=f=m._sprite3D,t||f._projectionViewWorldUpdateCamera===h&&f._projectionViewWorldUpdateLoopCount===I.loopCount||(f._render._renderUpdate(e._projectionViewMatrix),f._projectionViewWorldUpdateLoopCount=I.loopCount,f._projectionViewWorldUpdateCamera=h),e.renderElement=m,f._preRenderUpdateComponents(e),d=m.renderObj,c=m._material,this._begainRenderElement(e,d,null)&&(i=(n=d._getVertexBuffer(0)).vertexDeclaration,r=(m=e._shader=c._getShader(l._shaderDefineValue,i.shaderDefineValue,f._shaderDefineValue)).bind()||s!==m._uploadLoopCount,m._uploadVertexBuffer===n&&!r||(m.uploadAttributes(i.shaderValues.data,null),m._uploadVertexBuffer=n),h===m._uploadCamera&&m._uploadSprite3D===f&&!r||(m.uploadSpriteUniforms(f._shaderValues.data),m._uploadSprite3D=f),h===m._uploadCamera&&!r||(m.uploadCameraUniforms(h._shaderValues.data),m._uploadCamera=h),m._uploadMaterial===c&&!r||(c._upload(),m._uploadMaterial=c),m._uploadRenderElement,a!==c?(c._setRenderStateFrontFace(!1,f.transform),a=c,o=f):o!==f&&(c._setRenderStateFrontFace(!1,f.transform),o=f),d._render(e),m._uploadLoopCount=s),f._postRenderUpdateComponents(e))}},e._clearRenderElements=function(){this._dynamicBatchCombineRenderElements.length=0,this._renderElements.length=0,this._needSort=!0},e._addRenderElement=function(e){this._renderElements.push(e),this._needSort=!0},e._addDynamicBatchElement=function(e){this._dynamicBatchCombineRenderElements.push(e)},_(0,e,"id",function(){return this._id}),t._uniqueIDCounter=0,t._cameraPosition=null,t}(),ve=(p(ge,"laya.d3.core.render.RenderState"),ge.clientWidth=0,ge.clientHeight=0,ge);function ge(){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}var Te=function(){function i(e,t){this._exactBox=null,this._relaxBox=null,this._scene=null,this._parent=null,this._currentDepth=0,this._boundingSphere=new Yt(new hn,0),this._corners=[new hn,new hn,new hn,new hn,new hn,new hn,new hn,new hn],this._boundingBoxCenter=new hn,this._children=v(8),this._objects=[],this._tempBoundBoxCorners=[new hn,new hn,new hn,new hn,new hn,new hn,new hn,new hn],this._scene=e,this._currentDepth=t}p(i,"laya.d3.core.scene.OctreeNode");var e=i.prototype;return S.imps(e,{"laya.d3.core.scene.ITreeNode":!0}),e.init=function(e,t){var n=new hn,i=new hn;hn.scale(t,-.5,n),hn.scale(t,.5,i),hn.add(n,e,n),hn.add(i,e,i),this.exactBox=new kt(n,i),this.relaxBox=new kt(n,i)},e.addTreeNode=function(e){1===Zt.boxContainsBox(this._relaxBox,e.boundingBox)?this.addNodeDown(e,0):this.addObject(e)},e.addChild=function(e){var t,n=this._children[e];return null==n&&(n=new i(this._scene,this._currentDepth+1),(this._children[e]=n)._parent=this,hn.subtract(this._exactBox.max,this._exactBox.min,i.tempSize),hn.multiply(i.tempSize,i._octreeSplit[e],i.tempCenter),hn.add(this._exactBox.min,i.tempCenter,i.tempCenter),hn.scale(i.tempSize,.25,i.tempSize),t=new hn,e=new hn,hn.subtract(i.tempCenter,i.tempSize,t),hn.add(i.tempCenter,i.tempSize,e),n.exactBox=new kt(t,e),hn.scale(i.tempSize,i.relax,i.tempSize),t=new hn,e=new hn,hn.subtract(i.tempCenter,i.tempSize,t),hn.add(i.tempCenter,i.tempSize,e),n.relaxBox=new kt(t,e)),n},e.addObject=function(e){(e._treeNode=this)._objects.push(e)},e.removeObject=function(e){if(e._treeNode!=this)return console.log("OctreeNode::removeObject error"),!1;e=this._objects.indexOf(e);return-1!==e&&(this._objects.splice(e,1),!0)},e.clearObject=function(){this._objects.length=0},e.addNodeUp=function(e,t){this._parent&&1!==Zt.boxContainsBox(this._exactBox,e.boundingBox)?this._parent.addNodeUp(e,t-1):this.addNodeDown(e,t)},e.addNodeDown=function(e,t){var n;t<this._scene.treeLevel?(n=this.inChildIndex(e.boundingBoxCenter),n=this.addChild(n),1===Zt.boxContainsBox(n._relaxBox,e.boundingBox)?n.addNodeDown(e,++t):this.addObject(e)):this.addObject(e)},e.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)},e.updateObject=function(e){1===Zt.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))},e.cullingObjects=function(e,t,n,i,r){for(var a=0,o=0,s=this._scene._dynamicBatchManager,a=0,l=this._objects.length;a<l;a++){var h=this._objects[a];if(Z.isVisible(h._owner.layer.mask)&&h.enable&&(!t||(I.treeSpriteCollision+=1,0!==e.containsBoundSphere(h.boundingSphere)))){h._renderUpdate(r),h._distanceForSort=hn.distance(h.boundingSphere.center,i)+h.sortingFudge;for(var _=h._renderElements,o=0,u=_.length;o<u;o++){var d=_[o],c=d._staticBatch;c&&c._material===d._material?c._addBatchRenderElement(d):(c=d.renderObj).triangleCount<10&&1===c._vertexBufferCount&&c._getIndexBuffer()&&d._material.renderQueue<2&&d._canDynamicBatch&&!h._owner.isStatic?s._addPrepareRenderElement(d):this._scene.getRenderQueue(d._material.renderQueue)._addRenderElement(d)}}}for(a=0;a<8;a++){var f=this._children[a];if(null!=f){var m=t;if(t){var p=e.containsBoundBox(f._relaxBox);if(I.treeNodeCollision+=1,0===p)continue;m=2===p}f.cullingObjects(e,m,n,i,r)}}},e.cullingShadowObjects=function(e,t,n,i,r){for(var a=0,o=0,a=(this._scene._dynamicBatchManager,0),s=this._objects.length;a<s;a++){var l=this._objects[a];if(l.castShadow&&Z.isVisible(l._owner.layer.mask)&&l.enable&&(!n||0!==e[0].containsBoundSphere(l.boundingSphere)))for(var h=1,_=e.length;h<_;h++){var u=t[h-1];if(0!==e[h].containsBoundSphere(l.boundingSphere))for(var d=l._renderElements,o=0,c=d.length;o<c;o++)u._addRenderElement(d[o])}}for(a=0;a<8;a++){var f=this._children[a];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)}}},e.cullingShadowObjectsOnePSSM=function(e,t,n,i,r,a){for(var o=t[0],s=0,l=0,s=0,h=this._objects.length;s<h;s++){var _=this._objects[s];if(_.castShadow&&Z.isVisible(_._owner.layer.mask)&&_.enable&&(!i||0!==e.containsBoundSphere(_.boundingSphere))){_._renderUpdate(n);for(var u=_._renderElements,l=0,d=u.length;l<d;l++)o._addRenderElement(u[l])}}for(s=0;s<8;s++){var c=this._children[s];if(null!=c){var f=i;if(i){var m=e.containsBoundBox(c._relaxBox);if(0===m)continue;f=2===m}c.cullingShadowObjectsOnePSSM(e,t,n,f,r,a)}}},e.renderBoudingBox=function(e){this._renderBoudingBox(e);for(var t=0;t<8;++t){var n=this._children[t];n&&n.renderBoudingBox(e)}},e.buildAllChild=function(e){if(e<this._scene.treeLevel)for(var t=0;t<8;t++)this.addChild(t).buildAllChild(e+1)},e._renderBoudingBox=function(e){},_(0,e,"exactBox",function(){return this._exactBox},function(e){this._exactBox=e,hn.add(e.min,e.max,this._boundingBoxCenter),hn.scale(this._boundingBoxCenter,.5,this._boundingBoxCenter)}),_(0,e,"relaxBox",function(){return this._relaxBox},function(e){(this._relaxBox=e).getCorners(this._corners),Yt.createfromPoints(this._corners,this._boundingSphere)}),i.debugMode=!1,i.relax=1.15,i.CHILDNUM=8,l(i,["tempVector0",function(){return this.tempVector0=new hn},"tempSize",function(){return this.tempSize=new hn},"tempCenter",function(){return this.tempCenter=new hn},"_octreeSplit",function(){return this._octreeSplit=[new hn(.25,.25,.25),new hn(.75,.25,.25),new hn(.25,.75,.25),new hn(.75,.75,.25),new hn(.25,.25,.75),new hn(.75,.25,.75),new hn(.25,.75,.75),new hn(.75,.75,.75)]}]),i}();p(Se,"laya.d3.core.scene.SceneManager");function Se(){}var De=(p(xe,"laya.d3.core.trail.module.Color",null,"Color$1"),xe.prototype.cloneTo=function(e){e._r=this._r,e._g=this._g,e._b=this._b,e._a=this._a},l(xe,["RED",function(){return this.RED=new xe(1,0,0,1)},"GREEN",function(){return this.GREEN=new xe(0,1,0,1)},"BLUE",function(){return this.BLUE=new xe(0,0,1,1)},"CYAN",function(){return this.CYAN=new xe(0,1,1,1)},"YELLOW",function(){return this.YELLOW=new xe(1,.92,.016,1)},"MAGENTA",function(){return this.MAGENTA=new xe(1,0,1,1)},"GRAY",function(){return this.GRAY=new xe(.5,.5,.5,1)},"WHITE",function(){return this.WHITE=new xe(1,1,1,1)},"BLACK",function(){return this.BLACK=new xe(0,0,0,1)}]),xe);function xe(e,t,n,i){this._r=NaN,this._g=NaN,this._b=NaN,this._a=NaN,void 0===t&&(t=1),void 0===n&&(n=1),void 0===i&&(i=1),this._r=e=void 0===e?1:e,this._g=t,this._b=n,this._a=i}var Me=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=[]}p(e,"laya.d3.core.trail.module.Gradient");var t=e.prototype;return t.setKeys=function(e,t){this._colorKeys=e;for(var n,i=this.index=0;i<e.length;i++){var r,a=(r=e[i]).color;this._colorKeyData[this.index++]=a._r,this._colorKeyData[this.index++]=a._g,this._colorKeyData[this.index++]=a._b,this._colorKeyData[this.index++]=r.time}this._alphaKeys=t;for(var o=this.index=0;o<t.length;o++)n=t[o],this._alphaKeyData[this.index++]=n.alpha,this._alphaKeyData[this.index++]=n.time},t.cloneTo=function(e){for(var t=0,n=0,i=this.colorKeys,r=[],t=0,n=i.length;t<n;t++){var a=new Ie;i[t].cloneTo(a),r.push(a)}var o=this.alphaKeys,s=[];for(t=0,n=o.length;t<n;t++){var l=new Re;o[t].cloneTo(l),s.push(l)}e.setKeys(r,s)},_(0,t,"mode",function(){return this._mode},function(e){this._mode=e}),_(0,t,"colorKeys",function(){return this._colorKeys},function(e){this._colorKeys=e;for(var t=this.index=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}}),_(0,t,"alphaKeys",function(){return this._alphaKeys},function(e){this._alphaKeys=e;for(var t=this.index=0;t<e.length;t++){var n=e[t];this._alphaKeyData[this.index++]=n.alpha,this._alphaKeyData[this.index++]=n.time}}),e}(),Re=function(){function e(e,t){this._alpha=NaN,this._time=NaN,void 0===t&&(t=0),this._alpha=e=void 0===e?0:e,this._time=t}p(e,"laya.d3.core.trail.module.GradientAlphaKey");var t=e.prototype;return t.cloneTo=function(e){e.alpha=this.alpha,e.time=this.time},_(0,t,"alpha",function(){return this._alpha},function(e){this._alpha=e}),_(0,t,"time",function(){return this._time},function(e){this._time=e}),e}(),Ie=function(){function e(e,t){this._color=null,this._time=NaN,void 0===t&&(t=0),this._color=e||new De,this._time=t}p(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},_(0,t,"color",function(){return this._color},function(e){this._color=e}),_(0,t,"time",function(){return this._time},function(e){this._time=e}),e}();p(Ae,"laya.d3.core.trail.module.GradientMode"),Ae.Blend=0,Ae.Fixed=1;function Ae(){}p(Ce,"laya.d3.core.trail.module.TextureMode"),Ce.Stretch=0,Ce.Tile=1;function Ce(){}var ye=(p(Oe,"laya.d3.core.trail.module.TrailKeyFrame"),Oe.prototype.cloneTo=function(e){e.time=this.time,e.inTangent=this.inTangent,e.outTangent=this.outTangent,e.value=this.value},Oe);function Oe(){this.time=NaN,this.inTangent=NaN,this.outTangent=NaN,this.value=NaN}var Ne=function(){function t(e){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 hn,this._curPosition=new hn,this._delVector3=new hn,this._lastFixedVertexPosition=new hn,this._pointAtoBVector3=new hn,this._pointA=new hn,this._pointB=new hn,this._owner=e,this._id=t.renderElementCount++,(0==this._id?e._owner.transform.position:e._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 Gi(Ve.vertexDeclaration1,this._maxVerticesCount,35044,!0),this._vertexBuffer2=new Gi(Ve.vertexDeclaration2,this._maxVerticesCount,35044,!0),this._vertexBuffers=[],this._vertexBuffers.push(this._vertexBuffer1),this._vertexBuffers.push(this._vertexBuffer2)}p(t,"laya.d3.core.trail.TrailRenderElement");var e=t.prototype;return S.imps(e,{"laya.d3.core.render.IRenderable":!0}),e._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)},e._addTrailByFirstPosition=function(e,t){hn.subtract(t,e,this._delVector3),hn.cross(this._delVector3,this._camera.forward,this._pointAtoBVector3),hn.normalize(this._pointAtoBVector3,this._pointAtoBVector3),hn.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},e._addTrailByNextPosition=function(e){hn.subtract(e,this._lastFixedVertexPosition,this._delVector3),hn.cross(this._delVector3,this._camera.forward,this._pointAtoBVector3),hn.normalize(this._pointAtoBVector3,this._pointAtoBVector3),hn.scale(this._pointAtoBVector3,this._owner.widthMultiplier/2,this._pointAtoBVector3),this._delLength=hn.scalarLength(this._delVector3),this._delLength-this._owner.minVertexDistance>=qt.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)},e._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},e._updateVertexBuffer2=function(){for(var e=0,t=0,n=0,n=0,i=(this._verticesCount+this._virtualVerticesCount)/2;n<i;n++)t=0==this._owner.textureMode?(this._VerticesToTailLength[n]-this._owner._trailDeadLength)/(this._owner._trailTotalLength+this._owner._trailSupplementLength-this._owner._trailDeadLength):this._owner._trailTotalLength+this._owner._trailSupplementLength-this._VerticesToTailLength[n],this._vertices2[e++]=1-t,this._vertices2[e++]=1-t;this._vertexBuffer2.setData(this._vertices2,0,0,this._verticesCount+this._virtualVerticesCount)},e._onTrailRenderElementFinish=function(){this._lastFixedVertexPosition.cloneTo(this._owner._curSubTrailFinishPosition),this._pointAtoBVector3.cloneTo(this._owner._curSubTrailFinishDirection),this._owner._curSubTrailFinishCurTime=this._owner._curtime,this._isFinish=!0},e._updateDisappear=function(){for(var e=0,e=this._curDisappearIndex,t=(this._verticesCount+this._virtualVerticesCount)/2;e<t;e++)this._owner._curtime-this._everyGroupVertexBirthTime[e]>=this._owner.time+qt.zeroTolerance&&(this._curDisappearIndex++,this._owner._trailDeadLength+=this._everyVertexToPreVertexDistance[this._curDisappearIndex],this._curDisappearIndex>=(this._verticesCount+this._virtualVerticesCount)/2&&(this._isDead=!0))},e._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),hn.equals(this._lastPosition,this._curPosition)||this._updateTrail()):this._isFinish&&(this._isFinish=!1,this._owner._curSubTrailFinished=!0),0<this._verticesCount)&&(this._updateVertexBuffer2(),this._updateDisappear(),!0))},e._render=function(e){this._isDead||(N.mainContext.drawArrays(5,2*this._curDisappearIndex,this._verticesCount+this._virtualVerticesCount-2*this._curDisappearIndex),I.drawCall++,I.trianglesFaces+=this._verticesCount+this._virtualVerticesCount-2*this._curDisappearIndex-2)},e._getVertexBuffer=function(e){return 0===(e=void 0===e?0:e)?this._vertexBuffer1:1===e?this._vertexBuffer2:null},e._getVertexBuffers=function(){return this._vertexBuffers},e._getIndexBuffer=function(){return null},e.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)},e._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},_(0,e,"_vertexBufferCount",function(){return this._vertexBuffers.length}),_(0,e,"triangleCount",function(){return 0}),t.renderElementCount=0,t}(),Ve=function(){function e(){}p(e,"laya.d3.core.trail.VertexTrail");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration1}),_(1,e,"vertexDeclaration1",function(){return e._vertexDeclaration1}),_(1,e,"vertexDeclaration2",function(){return e._vertexDeclaration2}),l(e,["_vertexDeclaration1",function(){return this._vertexDeclaration1=new ke(32,[new Xe(0,"vector3",0),new Xe(12,"vector3",41),new Xe(24,"single",33),new Xe(28,"single",40)])},"_vertexDeclaration2",function(){return this._vertexDeclaration2=new ke(4,[new Xe(0,"single",38)])}]),e}();p(Le,"laya.d3.extension.domino.DominoKeyFrame");function Le(){this.position=hn.ZERO,this.rotation=rn.DEFAULT,this.scale=new hn(.3,.6,.1)}var we=function(){function t(e){this._owner=null,this.id=0,this._curDominoCount=0,this._perDominoVertexCount=24,this._perDominoIndiceCount=36,this._vertexBuffers=null,this._vertices1=null,this._vertexBuffer1=null,this._floatCountPerVertices1=4,this._verticesIndex1=0,this._everyAddVerticeCount1=0,this._vertices2=null,this._vertexBuffer2=null,this._floatCountPerVertices2=6,this._verticesIndex2=0,this._everyAddVerticeCount2=0,this._everyUpdateVerticeCount2=0,this._indices=null,this._indexBuffer=null,this._indicesIndex=0,this._everyAddindiceCount=0,this._index=0,this._color=new _n(Math.random(),Math.random(),Math.random(),1),this._topColor=this._color,this._buttomColor=this._color,this._leftColor=this._color,this._rightColor=this._color,this._frontColor=this._color,this._backColor=this._color,this._localMatrix=new Jt,this._localPostion=new hn,this._localNormal=new hn,this._owner=e,this.id=t.renderElementCount++;e=this._owner.DominoRenderElementMaxDominoCount*this._perDominoVertexCount;this._vertices1=new Float32Array(e*this._floatCountPerVertices1),this._vertices2=new Float32Array(e*this._floatCountPerVertices2),this._vertexBuffer1=new Gi(Fe.vertexDeclaration1,e,35044,!0),this._vertexBuffer2=new Gi(Fe.vertexDeclaration2,e,35044,!0),this._vertexBuffers=[],this._vertexBuffers.push(this._vertexBuffer1),this._vertexBuffers.push(this._vertexBuffer2);e=this._owner.DominoRenderElementMaxDominoCount*this._perDominoIndiceCount;this._indices=new Uint16Array(e),this._indexBuffer=new Ui("ushort",e,35044,!0)}p(t,"laya.d3.extension.domino.DominoRenderElement");var e=t.prototype;return S.imps(e,{"laya.d3.core.render.IRenderable":!0}),e.addDomino=function(e,t,n){void 0===e&&(e=hn.ZERO),void 0===t&&(t=rn.DEFAULT),void 0===n&&(n=hn.ONE),this._curDominoCount++,this._owner.dominoCount++,this._owner.dominoPosition.push(e),this.addDataForVertexBuffer1(),this.addDataForVertexBuffer2(e,t,n),this.addDataForIndexBuffer()},e.updateDomino=function(e,t,n,i){void 0===t&&(t=hn.ZERO),void 0===n&&(n=rn.DEFAULT),void 0===i&&(i=hn.ONE),this._everyUpdateVerticeCount2=0;var r,a,o,s,l,h,_,u=this._perDominoVertexCount*this._floatCountPerVertices2*e,d=Ti._positions,c=Ti._normals,f=0,m=d.length;for(Jt.createAffineTransformation(t,n,i,this._localMatrix),f=0;f<m;f++)hn.transformCoordinate(d[f],this._localMatrix,this._localPostion),r=(s=this._localPostion.elements)[0],a=s[1],o=s[2],this._vertices2[u+this._everyUpdateVerticeCount2++]=r,this._vertices2[u+this._everyUpdateVerticeCount2++]=a,this._vertices2[u+this._everyUpdateVerticeCount2++]=o,hn.TransformNormal(c[f],this._localMatrix,this._localNormal),l=(s=this._localNormal.elements)[0],h=s[1],_=s[2],this._vertices2[u+this._everyUpdateVerticeCount2++]=l,this._vertices2[u+this._everyUpdateVerticeCount2++]=h,this._vertices2[u+this._everyUpdateVerticeCount2++]=_;this._vertexBuffer2.setData(this._vertices2,u,u,this._everyUpdateVerticeCount2)},e.updateDominos=function(e,t,n){this._everyUpdateVerticeCount2=0;for(var i,r,a,o,s,l,h,_,u=this._perDominoVertexCount*this._floatCountPerVertices2*e,d=Ti._positions,c=Ti._normals,f=0,m=0,p=d.length,f=0;f<t;f++)for(_=n[f],Jt.createAffineTransformation(_.position,_.rotation,_.scale,this._localMatrix),m=0;m<p;m++)hn.transformCoordinate(d[m],this._localMatrix,this._localPostion),i=(o=this._localPostion.elements)[0],r=o[1],a=o[2],this._vertices2[u+this._everyUpdateVerticeCount2++]=i,this._vertices2[u+this._everyUpdateVerticeCount2++]=r,this._vertices2[u+this._everyUpdateVerticeCount2++]=a,hn.TransformNormal(c[m],this._localMatrix,this._localNormal),s=(o=this._localNormal.elements)[0],l=o[1],h=o[2],this._vertices2[u+this._everyUpdateVerticeCount2++]=s,this._vertices2[u+this._everyUpdateVerticeCount2++]=l,this._vertices2[u+this._everyUpdateVerticeCount2++]=h;this._vertexBuffer2.setData(this._vertices2,u,u,this._everyUpdateVerticeCount2)},e.addDataForVertexBuffer1=function(){this._everyAddVerticeCount1=0,this.addDataForVertices1(this._topColor),this.addDataForVertices1(this._buttomColor),this.addDataForVertices1(this._leftColor),this.addDataForVertices1(this._rightColor),this.addDataForVertices1(this._frontColor),this.addDataForVertices1(this._backColor),this._vertexBuffer1.setData(this._vertices1,this._verticesIndex1,this._verticesIndex1,this._everyAddVerticeCount1),this._verticesIndex1+=this._everyAddVerticeCount1},e.addDataForVertexBuffer2=function(e,t,n){void 0===e&&(e=hn.ZERO),void 0===t&&(t=rn.DEFAULT),void 0===n&&(n=hn.ONE),this._everyAddVerticeCount2=0;var i,r,a,o,s,l,h,_=Ti._positions,u=Ti._normals,d=0,c=_.length;for(Jt.createAffineTransformation(e,t,n,this._localMatrix),d=0;d<c;d++)hn.transformCoordinate(_[d],this._localMatrix,this._localPostion),i=(o=this._localPostion.elements)[0],r=o[1],a=o[2],this._vertices2[this._verticesIndex2+this._everyAddVerticeCount2++]=i,this._vertices2[this._verticesIndex2+this._everyAddVerticeCount2++]=r,this._vertices2[this._verticesIndex2+this._everyAddVerticeCount2++]=a,hn.TransformNormal(u[d],this._localMatrix,this._localNormal),s=(o=this._localNormal.elements)[0],l=o[1],h=o[2],this._vertices2[this._verticesIndex2+this._everyAddVerticeCount2++]=s,this._vertices2[this._verticesIndex2+this._everyAddVerticeCount2++]=l,this._vertices2[this._verticesIndex2+this._everyAddVerticeCount2++]=h;this._vertexBuffer2.setData(this._vertices2,this._verticesIndex2,this._verticesIndex2,this._everyAddVerticeCount2),this._verticesIndex2+=this._everyAddVerticeCount2},e.addDataForIndexBuffer=function(){this._everyAddindiceCount=0,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+0,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+1,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+2,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+2,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+3,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+0,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+4,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+7,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+6,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+6,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+5,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+4,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+8,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+9,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+10,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+10,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+11,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+8,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+12,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+15,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+14,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+14,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+13,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+12,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+16,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+17,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+18,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+18,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+19,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+16,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+20,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+23,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+22,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+22,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+21,this._indices[this._indicesIndex+this._everyAddindiceCount++]=this._index+20,this._indexBuffer.setData(this._indices,this._indicesIndex,this._indicesIndex,this._everyAddindiceCount),this._indicesIndex+=this._everyAddindiceCount,this._index+=this._perDominoVertexCount},e.addDataForVertices1=function(e){for(var e=e.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=0;a<4;a++)this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=t,this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=n,this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=i,this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=r},e._beforeRender=function(e){return this._indexBuffer._bind(),!0},e._render=function(e){N.mainContext.drawElements(4,this._indicesIndex,5123,0),I.drawCall++,I.trianglesFaces+=this._indicesIndex/3},e._getIndexBuffer=function(){return this._indexBuffer},e._getVertexBuffer=function(e){return 0===(e=void 0===e?0:e)?this._vertexBuffer1:1===e?this._vertexBuffer2:null},e._getVertexBuffers=function(){return this._vertexBuffers},e._getIndexBuffer=function(){return null},_(0,e,"_vertexBufferCount",function(){return this._vertexBuffers.length}),_(0,e,"triangleCount",function(){return this._indicesIndex/3}),t.renderElementCount=0,t}(),Fe=function(){function e(){}p(e,"laya.d3.extension.domino.DominoVertex");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration1}),_(1,e,"vertexDeclaration1",function(){return e._vertexDeclaration1}),_(1,e,"vertexDeclaration2",function(){return e._vertexDeclaration2}),l(e,["_vertexDeclaration1",function(){return this._vertexDeclaration1=new ke(16,[new Xe(0,"vector4",1)])},"_vertexDeclaration2",function(){return this._vertexDeclaration2=new ke(24,[new Xe(0,"vector3",0),new Xe(12,"vector3",3)])}]),e}(),Pe=(p(be,"laya.d3.extension.lineRender.LineVertex"),_(0,be.prototype,"vertexDeclaration",function(){return be._vertexDeclaration1}),_(1,be,"vertexDeclaration1",function(){return be._vertexDeclaration1}),_(1,be,"vertexDeclaration2",function(){return be._vertexDeclaration2}),_(1,be,"vertexDeclaration3",function(){return be._vertexDeclaration3}),l(be,["_vertexDeclaration1",function(){return this._vertexDeclaration1=new ke(16,[new Xe(0,"vector3",0),new Xe(12,"single",40)])},"_vertexDeclaration2",function(){return this._vertexDeclaration2=new ke(12,[new Xe(0,"vector3",41)])},"_vertexDeclaration3",function(){return this._vertexDeclaration3=new ke(8,[new Xe(0,"single",38),new Xe(4,"single",39)])}]),be);function be(){}var Be=function(){function T(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}p(T,"laya.d3.graphics.DynamicBatch");var e=T.prototype;return S.imps(e,{"laya.d3.core.render.IRenderable":!0}),e._getVertexBuffer=function(e){return 0===(e=void 0===e?0:e)?this._vertexBuffer:null},e._getIndexBuffer=function(){return this._indexBuffer},e._getCombineRenderElementFromPool=function(e,t,n){var i=this._combineRenderElementPool[this._combineRenderElementPoolIndex++];return i||(this._combineRenderElementPool[this._combineRenderElementPoolIndex-1]=i=new pe,i._sprite3D=new fr),i._sprite3D._render._renderUpdate(n),i},e._getRenderElement=function(e,t,n){this._vertexDatas||(this._vertexDatas=new Float32Array(this._vertexDeclaration.vertexStride/4*T.maxVertexCount),this._indexDatas=new Uint16Array(T.maxIndexCount),this._vertexBuffer=Gi.create(this._vertexDeclaration,T.maxVertexCount,35048),this._indexBuffer=Ui.create("ushort",T.maxIndexCount,35048));for(var i=this._merageElements.length=0,r=0,a=0,o=this._combineRenderElements.length;a<o;a++){var s=this._combineRenderElements[a],l=s.getDynamicBatchBakedVertexs(0),h=s.getBakedIndices(),_=s._sprite3D.transform._isFrontFaceInvert,u=i/(this._vertexDeclaration.vertexStride/4),d=r,c=d+h.length;s._tempBatchIndexStart=d,s._tempBatchIndexEnd=c,this._indexDatas.set(h,r);var f=0;if(_)for(f=d;f<c;f+=3){this._indexDatas[f]=u+this._indexDatas[f];var m=this._indexDatas[f+1],p=this._indexDatas[f+2];this._indexDatas[f+1]=u+p,this._indexDatas[f+2]=u+m}else for(f=d;f<c;f+=3)this._indexDatas[f]=u+this._indexDatas[f],this._indexDatas[f+1]=u+this._indexDatas[f+1],this._indexDatas[f+2]=u+this._indexDatas[f+2];r+=h.length,this._vertexDatas.set(l,i),i+=l.length}for(this._vertexBuffer.setData(this._vertexDatas),this._indexBuffer.setData(this._indexDatas),a=this._combineRenderElementPoolIndex=0,o=this._materials.length;a<o;a++){var E=this._getCombineRenderElementFromPool(e,t,n);E._type=2,E._staticBatch=null;var v=(E.renderObj=this)._combineRenderElements[this._materialToRenderElementsOffsets[a]]._tempBatchIndexStart,g=a+1===this._materialToRenderElementsOffsets.length?r:this._combineRenderElements[this._materialToRenderElementsOffsets[a+1]]._tempBatchIndexStart;E._tempBatchIndexStart=v,E._tempBatchIndexEnd=g,E._material=this._materials[a],this._merageElements.push(E)}},e._addCombineRenderObjTest=function(e){var t=e.renderObj,e=this._currentCombineIndexCount+t._getIndexBuffer().indexCount,t=this._currentCombineVertexCount+t._getVertexBuffer().vertexCount;return!(T.maxVertexCount<t||T.maxIndexCount<e)},e._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},e._addCombineMaterial=function(e){this._materials.push(e)},e._addMaterialToRenderElementOffset=function(e){this._materialToRenderElementsOffsets.push(e)},e._clearRenderElements=function(){this._combineRenderElements.length=0,this._materials.length=0,this._materialToRenderElementsOffsets.length=0,this._currentCombineVertexCount=0,this._currentCombineIndexCount=0},e._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])},e._beforeRender=function(e){return this._vertexBuffer._bind(),this._indexBuffer._bind(),!0},e._render=function(e){var t=e._batchIndexEnd-e._batchIndexStart;N.mainContext.drawElements(4,t,5123,2*e._batchIndexStart),I.drawCall++,I.trianglesFaces+=t/3},e._getVertexBuffers=function(){return null},_(0,e,"_vertexBufferCount",function(){return 1}),_(0,e,"triangleCount",function(){return this._indexBuffer.indexCount/3}),_(0,e,"combineRenderElementsCount",function(){return this._combineRenderElements.length}),T.maxVertexCount=2e4,T.maxIndexCount=4e4,T.maxCombineTriangleCount=10,T}(),Ue=function(){function v(){this._dynamicBatches=null,this._prepareDynamicBatchCombineElements=null,this._dynamicBatches={},this._prepareDynamicBatchCombineElements=[]}p(v,"laya.d3.graphics.DynamicBatchManager");var e=v.prototype;return e.getDynamicBatch=function(e,t){var n,t=e.id.toString()+t;return this._dynamicBatches[t]?n=this._dynamicBatches[t]:this._dynamicBatches[t]=n=new Be(e),n},e._garbageCollection=function(){for(var e in this._dynamicBatches)0===this._dynamicBatches[e].combineRenderElementsCount&&delete this._dynamicBatches[e]},e._addPrepareRenderElement=function(e){this._prepareDynamicBatchCombineElements.push(e)},e._finishCombineDynamicBatch=function(e){var t,n;this._prepareDynamicBatchCombineElements.sort(v._sortPrepareDynamicBatch);for(var i,r,a,o=-1,s=!0,l=0,h=-1,_=0,u=this._prepareDynamicBatchCombineElements.length;_<u;_++){var d,c=(d=this._prepareDynamicBatchCombineElements[_]).renderObj._getVertexBuffer(0).vertexDeclaration,f=n!==c;f&&(l=0,n=c);var m,p,E=l!==o;E&&(o=l),(f||E)&&(i=this.getDynamicBatch(c,l),t=null),s?s=i._addCombineRenderObjTest(d)?(t!==(p=d._material)?(r&&(e.getRenderQueue(a._material.renderQueue)._addRenderElement(a),a=r=null,h=-1),h=i.combineRenderElementsCount,a=d,t=r=p):r?(c=a.renderObj,m=d.renderObj,c._getVertexBuffer().vertexCount+m._getVertexBuffer().vertexCount>Be.maxVertexCount||c._getIndexBuffer().indexCount+m._getIndexBuffer().indexCount>Be.maxIndexCount?(e.getRenderQueue(a._material.renderQueue)._addRenderElement(a),r=p,h=i.combineRenderElementsCount,a=d):(i._addCombineMaterial(r),i._addMaterialToRenderElementOffset(h),i._addCombineRenderObj(a),a=r=null,h=-1,i._addCombineRenderObj(d))):i._addCombineRenderObj(d),!0):(r&&(e.getRenderQueue(a._material.renderQueue)._addRenderElement(a),a=r=null,h=-1),l++,!1):(m=this._prepareDynamicBatchCombineElements[_-1],i._addMaterialToRenderElementOffset(i.combineRenderElementsCount),t=m._material,i._addCombineMaterial(t),i._addCombineRenderObj(m),s=!0,t!==(p=d._material)?(r=p,h=i.combineRenderElementsCount,a=d):i._addCombineRenderObj(d),t=p)}r&&(e.getRenderQueue(a._material.renderQueue)._addRenderElement(a),a=r=null,h=-1),this._prepareDynamicBatchCombineElements.length=0},e._clearRenderElements=function(){for(var e in this._dynamicBatches)this._dynamicBatches[e]._clearRenderElements()},e._addToRenderQueue=function(e,t,n,i){for(var r in this._dynamicBatches){r=this._dynamicBatches[r];0<r.combineRenderElementsCount&&r._addToRenderQueue(e,t,n,i)}},e.dispose=function(){this._dynamicBatches=null},v._sortPrepareDynamicBatch=function(e,t){return e._mainSortID-t._mainSortID},v}(),He=(p(Ge,"laya.d3.graphics.FrustumCulling"),Ge.renderShadowObjectCulling=function(e,t,n,i,r){for(var a=0,o=0,s=0,l=0,a=0,s=n.length;a<s;a++){var h=n[a];h&&h._clearRenderElements()}var _,u,d,c=e._cullingRenders;if(1<r){for(a=0,s=e._cullingRendersLength;a<s;a++)if((_=c[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=(d=_._renderElements).length;o<l;o++)u._addRenderElement(d[o])}else for(a=0,s=e._cullingRendersLength;a<s;a++)if((_=c[a]).castShadow&&Z.isVisible(_._owner.layer.mask)&&_.enable&&0!==t[0].containsBoundSphere(_.boundingSphere))for(_._renderUpdate(i),u=n[0],o=0,l=(d=_._renderElements).length;o<l;o++)u._addRenderElement(d[o])},Ge.renderShadowObjectCullingOctree=function(e,t,n,i,r){for(var a=0,o=n.length;a<o;a++){var s=n[a];s&&s._clearRenderElements()}1<r?e.treeRoot.cullingShadowObjects(t,n,!0,0,e):e.treeRoot.cullingShadowObjectsOnePSSM(t[0],n,i,!0,0,e)},Ge.renderObjectCulling=function(e,t,n,i,r,a){for(var o=0,s=0,l=0,h=t._quenes,_=t._dynamicBatchManager,u=t._cullingRenders,o=0,s=h.length;o<s;o++){var d=h[o];d&&d._clearRenderElements()}var c=ze._staticBatchManagers;for(o=0,s=c.length;o<s;o++)c[o]._clearRenderElements();_._clearRenderElements();var f=n.transform.position;for(o=0,s=t._cullingRendersLength;o<s;o++){var m=u[o];if(Z.isVisible(m._owner.layer.mask)&&m.enable&&0!==e.containsBoundSphere(m.boundingSphere)&&m._renderUpdate(a)){m._distanceForSort=hn.distance(m.boundingSphere.center,f)+m.sortingFudge;for(var p=m._renderElements,l=0,E=p.length;l<E;l++){var v=p[l],g=v._staticBatch;g&&g._material===v._material?g._addBatchRenderElement(v):(g=v.renderObj).triangleCount<10&&1===g._vertexBufferCount&&g._getIndexBuffer()&&v._material.renderQueue<2&&v._canDynamicBatch&&!m._owner.isStatic?_._addPrepareRenderElement(v):t.getRenderQueue(v._material.renderQueue)._addRenderElement(v)}}}for(o=0,s=c.length;o<s;o++)c[o]._addToRenderQueue(t,i,r,a);_._finishCombineDynamicBatch(t),_._addToRenderQueue(t,i,r,a)},Ge.renderObjectCullingOctree=function(e,t,n,i,r,a){for(var o=0,s=0,l=t._quenes,h=t._dynamicBatchManager,o=0,s=l.length;o<s;o++){var _=l[o];_&&_._clearRenderElements()}var u=ze._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)},Ge.renderObjectCullingNoBoundFrustum=function(e,t,n,i,r){for(var a=0,o=0,s=0,l=e._quenes,h=e._dynamicBatchManager,_=e._cullingRenders,a=0,o=l.length;a<o;a++){var u=l[a];u&&u._clearRenderElements()}var d=ze._staticBatchManagers;for(a=0,o=d.length;a<o;a++)d[a]._clearRenderElements();h._clearRenderElements();var c=t.transform.position;for(a=0,o=e._cullingRendersLength;a<o;a++){var f=_[a];if(Z.isVisible(f._owner.layer.mask)&&f.enable){f._renderUpdate(r),f._distanceForSort=hn.distance(f.boundingSphere.center,c)+f.sortingFudge;for(var m=f._renderElements,s=0,p=m.length;s<p;s++){var E=m[s],v=E._staticBatch;v&&v._material===E._material?v._addBatchRenderElement(E):(v=E.renderObj).triangleCount<10&&1===v._vertexBufferCount&&v._getIndexBuffer()&&E._material.renderQueue<2&&E._canDynamicBatch&&!f._owner.isStatic?h._addPrepareRenderElement(E):e.getRenderQueue(E._material.renderQueue)._addRenderElement(E)}}}for(a=0,o=d.length;a<o;a++)d[a]._addToRenderQueue(e,n,i,r);h._finishCombineDynamicBatch(e),h._addToRenderQueue(e,n,i,r)},Ge);function Ge(){}var ze=function(){function a(){this._initBatchRenderElements=null,this._staticBatches=null,this._initBatchRenderElements=[],this._staticBatches={}}p(a,"laya.d3.graphics.StaticBatchManager");var e=a.prototype;return e._finishInit=function(){for(var e in this._staticBatches)this._staticBatches[e]._finishInit();this._initBatchRenderElements.length=0},e._initStaticBatchs=function(e){throw new Error("StaticBatchManager:must override this function.")},e._addInitBatchSprite=function(e){for(var t=e._render._renderElements,n=0,i=t.length;n<i;n++)this._initBatchRenderElements.push(t[n])},e._clearRenderElements=function(){for(var e in this._staticBatches)this._staticBatches[e]._clearRenderElements()},e._garbageCollection=function(e){var t=e._staticBatch,n=t._initBatchRenderElements,e=n.indexOf(e);n.splice(e,1),0===n.length&&(t.dispose(),delete this._staticBatches[t._key])},e._addToRenderQueue=function(e,t,n,i){for(var r in this._staticBatches){r=this._staticBatches[r];0<r._batchRenderElements.length&&r._updateToRenderQueue(e,i)}},e.dispose=function(){this._staticBatches=null},a._addToStaticBatchQueue=function(e){e instanceof laya.d3.core.RenderableSprite3D&&e._addToInitStaticBatchManager();for(var t=0,n=e.numChildren;t<n;t++)a._addToStaticBatchQueue(e._childs[t])},a.combine=function(e,t){var n,i=0,r=0;if(t)for(i=0,r=t.length;i<r;i++)t[i]._addToInitStaticBatchManager();else e&&a._addToStaticBatchQueue(e);for(i=0,r=a._staticBatchManagers.length;i<r;i++)(n=a._staticBatchManagers[i])._initStaticBatchs(e),n._finishInit()},a._staticBatchManagers=[],a}(),We=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}p(e,"laya.d3.graphics.StaticBatch");var t=e.prototype;return S.imps(t,{"laya.d3.core.render.IRenderable":!0,"laya.resource.IDispose":!0}),t._binarySearch=function(e){for(var t,n=0,i=this._batchRenderElements.length-1;n<=i;)t=Math.floor((n+i)/2),this._compareBatchRenderElement(this._batchRenderElements[t],e)?i=t-1:n=t+1;return n},t._compareBatchRenderElement=function(e,t){throw new Error("StaticBatch:must override this function.")},t._getVertexDecLightMap=function(e){return e===It.vertexDeclaration?St.vertexDeclaration:e===Rt.vertexDeclaration?Tt.vertexDeclaration:e===ft.vertexDeclaration?ht.vertexDeclaration:e===Ot.vertexDeclaration?null:e===rt.vertexDeclaration?at.vertexDeclaration:e===Ct.vertexDeclaration?xt.vertexDeclaration:e===vt.vertexDeclaration?gt.vertexDeclaration:e===At.vertexDeclaration?Dt.vertexDeclaration:e===Rt.vertexDeclaration?Tt.vertexDeclaration:e===mt.vertexDeclaration?_t.vertexDeclaration:e===Ot.vertexDeclaration?null:e===rt.vertexDeclaration?at.vertexDeclaration:e===yt.vertexDeclaration?Mt.vertexDeclaration:e===vt.vertexDeclaration?gt.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},_(0,t,"_vertexBufferCount",function(){return 1}),_(0,t,"triangleCount",function(){return 0}),e.combine=function(e){console.log("StaticBatch: discard property,please use StaticBatchManager.combine() function instead."),ze.combine(e)},e.maxBatchVertexCount=65535,e}(),ke=function(){function a(e,t){if(this._id=0,this._shaderValues=null,this._shaderDefineValue=0,this._vertexStride=0,this._vertexElements=null,this._vertexElementsDic=null,this._id=++a._uniqueIDCounter,this._id>a.maxVertexDeclaration)throw new Error("VertexDeclaration: VertexDeclaration count should not large than ",a.maxVertexDeclaration);this._shaderValues=new vn,this._vertexElementsDic={},this._vertexStride=e,this._vertexElements=t;for(var n=0;n<t.length;n++){var i=t[n],r=i.elementUsage;this._vertexElementsDic[r]=i;i=[a._getTypeSize(i.elementFormat)/4,5126,!1,this._vertexStride,i.offset];switch(this._shaderValues.setValue(r,i),r){case 1:this._addShaderDefine($n.SHADERDEFINE_COLOR);break;case 2:this._addShaderDefine($n.SHADERDEFINE_UV0);break;case 15:this._addShaderDefine($n.SHADERDEFINE_UV1)}}}p(a,"laya.d3.graphics.VertexDeclaration");var e=a.prototype;return e._addShaderDefine=function(e){this._shaderDefineValue|=e},e._removeShaderDefine=function(e){this._shaderDefineValue&=~e},e.getVertexElements=function(){return this._vertexElements.slice()},e.getVertexElementByUsage=function(e){return this._vertexElementsDic[e]},e.unBinding=function(){},_(0,e,"shaderDefineValue",function(){return this._shaderDefineValue}),_(0,e,"id",function(){return this._id}),_(0,e,"vertexStride",function(){return this._vertexStride}),_(0,e,"shaderValues",function(){return this._shaderValues}),a._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},a.getVertexStride=function(e){for(var t=0,n=0;n<e.Length;n++){var i=e[n],i=i.offset+a._getTypeSize(i.elementFormat);t<i&&(t=i)}return t},a._maxVertexDeclarationBit=1e3,a._uniqueIDCounter=1,l(a,["maxVertexDeclaration",function(){return this.maxVertexDeclaration=2147483647-1e3*Math.floor(2147483.647)}]),a}(),Xe=(p(Ye,"laya.d3.graphics.VertexElement"),Ye);function Ye(e,t,n){this.offset=0,this.elementFormat=null,this.elementUsage=0,this.offset=e,this.elementFormat=t,this.elementUsage=n}p(Ze,"laya.d3.graphics.VertexElementFormat"),Ze.Single="single",Ze.Vector2="vector2",Ze.Vector3="vector3",Ze.Vector4="vector4",Ze.Color="color",Ze.Byte4="byte4",Ze.Short2="short2",Ze.Short4="short4",Ze.NormalizedShort2="normalizedshort2",Ze.NormalizedShort4="normalizedshort4",Ze.HalfVector2="halfvector2",Ze.HalfVector4="halfvector4";function Ze(){}p(je,"laya.d3.graphics.VertexElementUsage"),je.POSITION0=0,je.COLOR0=1,je.TEXTURECOORDINATE0=2,je.NORMAL0=3,je.BINORMAL0=4,je.TANGENT0=5,je.BLENDINDICES0=6,je.BLENDWEIGHT0=7,je.DEPTH0=8,je.FOG0=9,je.POINTSIZE0=10,je.SAMPLE0=11,je.TESSELLATEFACTOR0=12,je.COLOR1=13,je.NEXTTEXTURECOORDINATE0=14,je.TEXTURECOORDINATE1=15,je.NEXTTEXTURECOORDINATE1=16,je.CORNERTEXTURECOORDINATE0=17,je.VELOCITY0=18,je.STARTCOLOR0=19,je.STARTSIZE=20,je.AGEADDSCALE0=21,je.STARTROTATION=22,je.ENDCOLOR0=23,je.STARTLIFETIME=24,je.TIME0=33,je.SHAPEPOSITIONSTARTLIFETIME=30,je.DIRECTIONTIME=32,je.SIZEROTATION0=27,je.RADIUS0=28,je.RADIAN0=29,je.STARTSPEED=31,je.RANDOM0=34,je.RANDOM1=35,je.SIMULATIONWORLDPOSTION=36,je.SIMULATIONWORLDROTATION=37,je.TEXTURECOORDINATE0X=38,je.TEXTURECOORDINATE0X1=39,je.TEXTURECOORDINATE0Y=40,je.OFFSETVECTOR=41;function je(){}var Ke=function(){function e(e,t,n){this._position=null,this._textureCoordinate0=null,this._time=NaN,this._position=e,this._textureCoordinate0=t,this._time=n}p(e,"laya.d3.graphics.VertexGlitter");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"textureCoordinate",function(){return this._textureCoordinate0}),_(0,t,"position",function(){return this._position}),_(0,t,"time",function(){return this._time}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(24,[new Xe(0,"vector3",0),new Xe(12,"vector2",2),new Xe(20,"single",33)])}]),e}(),qe=(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}p(e,"laya.d3.graphics.VertexParticle");var t=e.prototype;S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"endColor",function(){return this._endColor}),_(0,t,"cornerTextureCoordinate",function(){return this._cornerTextureCoordinate}),_(0,t,"sizeRotation",function(){return this._sizeRotation}),_(0,t,"velocity",function(){return this._velocity}),_(0,t,"position",function(){return this._position}),_(0,t,"startColor",function(){return this._startColor}),_(0,t,"radius",function(){return this._radius}),_(0,t,"radian",function(){return this._radian}),_(0,t,"ageAddScale",function(){return this._ageAddScale}),_(0,t,"time",function(){return this._time}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(116,[new Xe(0,"vector4",17),new Xe(16,"vector3",0),new Xe(28,"vector3",18),new Xe(40,"vector4",19),new Xe(56,"vector4",23),new Xe(72,"vector3",27),new Xe(84,"vector2",28),new Xe(92,"vector4",29),new Xe(108,"single",24),new Xe(112,"single",33)])}])}(),function(){function e(e){this._position=null,this._position=e}p(e,"laya.d3.graphics.VertexPosition");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"position",function(){return this._position}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(12,[new Xe(0,"vector3",0)])}]),e}()),Qe=function(){function e(e,t){this._position=null,this._normal=null,this._position=e,this._normal=t}p(e,"laya.d3.graphics.VertexPositionNormal");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(24,[new Xe(0,"vector3",0),new Xe(12,"vector3",3)])}]),e}(),$e=function(){function e(e,t,n){this._position=null,this._normal=null,this._color=null,this._position=e,this._normal=t,this._color=n}p(e,"laya.d3.graphics.VertexPositionNormalColor");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"color",function(){return this._color}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(40,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector4",1)])}]),e}(),Je=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}p(e,"laya.d3.graphics.VertexPositionNormalColorSkin");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"blendWeight",function(){return this._blendWeight}),_(0,t,"color",function(){return this._color}),_(0,t,"blendIndex",function(){return this._blendIndex}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(72,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector4",1),new Xe(40,"vector4",7),new Xe(56,"vector4",6)])}]),e}(),et=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}p(e,"laya.d3.graphics.VertexPositionNormalColorSkinSTangent");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"tangent",function(){return this._tangent}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"blendWeight",function(){return this._blendWeight}),_(0,t,"color",function(){return this._color}),_(0,t,"blendIndex",function(){return this._blendIndex}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(88,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector4",1),new Xe(40,"vector4",7),new Xe(56,"vector4",6),new Xe(72,"vector4",5)])}]),e}(),tt=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}p(e,"laya.d3.graphics.VertexPositionNormalColorSkinTangent");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"tangent",function(){return this._tangent}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"blendWeight",function(){return this._blendWeight}),_(0,t,"color",function(){return this._color}),_(0,t,"blendIndex",function(){return this._blendIndex}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(84,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector4",1),new Xe(40,"vector4",7),new Xe(56,"vector4",6),new Xe(72,"vector3",5)])}]),e}(),nt=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}p(e,"laya.d3.graphics.VertexPositionNormalColorSTangent");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"tangent",function(){return this._tangent}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"color",function(){return this._color}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(56,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector4",1),new Xe(40,"vector4",5)])}]),e}(),it=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}p(e,"laya.d3.graphics.VertexPositionNormalColorTangent");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"tangent",function(){return this._tangent}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"color",function(){return this._color}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(52,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector4",1),new Xe(40,"vector3",5)])}]),e}(),rt=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}p(e,"laya.d3.graphics.VertexPositionNormalColorTexture");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"textureCoordinate",function(){return this._textureCoordinate}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"color",function(){return this._color}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(48,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector4",1),new Xe(40,"vector2",2)])}]),e}(),at=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}p(e,"laya.d3.graphics.VertexPositionNormalColorTexture0Texture1");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"color",function(){return this._color}),_(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(56,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector4",1),new Xe(40,"vector2",2),new Xe(48,"vector2",15)])}]),e}(),ot=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}p(e,"laya.d3.graphics.VertexPositionNormalColorTexture0Texture1Skin");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"blendWeight",function(){return this._blendWeight}),_(0,t,"color",function(){return this._color}),_(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),_(0,t,"blendIndex",function(){return this._blendIndex}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(88,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector4",1),new Xe(40,"vector2",2),new Xe(48,"vector2",15),new Xe(56,"vector4",7),new Xe(72,"vector4",6)])}]),e}(),st=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}p(e,"laya.d3.graphics.VertexPositionNormalColorTexture0Texture1SkinSTangent");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"tangent",function(){return this._tangent}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"blendWeight",function(){return this._blendWeight}),_(0,t,"color",function(){return this._color}),_(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),_(0,t,"blendIndex",function(){return this._blendIndex}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(104,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector4",1),new Xe(40,"vector2",2),new Xe(48,"vector2",15),new Xe(56,"vector4",7),new Xe(72,"vector4",6),new Xe(88,"vector4",5)])}]),e}(),lt=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}p(e,"laya.d3.graphics.VertexPositionNormalColorTexture0Texture1SkinTangent");var t=e.prototype;return S.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},_(0,t,"tangent",function(){return this._tangent}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"blendWeight",function(){return this._blendWeight}),_(0,t,"color",function(){return this._color}),_(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),_(0,t,"blendIndex",function(){return this._blendIndex}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(100,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector4",1),new Xe(40,"vector2",2),new Xe(48,"vector2",15),new Xe(56,"vector4",7),new Xe(72,"vector4",6),new Xe(88,"vector3",5)])}]),e}(),ht=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}p(e,"laya.d3.graphics.VertexPositionNormalColorTexture0Texture1STangent");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"tangent",function(){return this._tangent}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"color",function(){return this._color}),_(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(72,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector4",1),new Xe(40,"vector2",2),new Xe(48,"vector2",15),new Xe(56,"vector4",5)])}]),e}(),_t=function(){function e(){this._position=null,this._normal=null,this._color=null,this._textureCoordinate0=null,this._textureCoordinate1=null,this._tangent=null}p(e,"laya.d3.graphics.VertexPositionNormalColorTexture0Texture1Tangent");var t=e.prototype;return S.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},_(0,t,"tangent",function(){return this._tangent}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"color",function(){return this._color}),_(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(68,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector4",1),new Xe(40,"vector2",2),new Xe(48,"vector2",15),new Xe(56,"vector3",5)])}]),e}(),ut=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}p(e,"laya.d3.graphics.VertexPositionNormalColorTextureSkin");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"textureCoordinate",function(){return this._textureCoordinate}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"blendWeight",function(){return this._blendWeight}),_(0,t,"color",function(){return this._color}),_(0,t,"blendIndex",function(){return this._blendIndex}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(80,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector4",1),new Xe(40,"vector2",2),new Xe(48,"vector4",7),new Xe(64,"vector4",6)])}]),e}(),dt=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}p(e,"laya.d3.graphics.VertexPositionNormalColorTextureSkinSTangent");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"tangent",function(){return this._tangent}),_(0,t,"textureCoordinate",function(){return this._textureCoordinate}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"blendWeight",function(){return this._blendWeight}),_(0,t,"color",function(){return this._color}),_(0,t,"blendIndex",function(){return this._blendIndex}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(96,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector4",1),new Xe(40,"vector2",2),new Xe(48,"vector4",7),new Xe(64,"vector4",6),new Xe(80,"vector4",5)])}]),e}(),ct=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}p(e,"laya.d3.graphics.VertexPositionNormalColorTextureSkinTangent");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"tangent",function(){return this._tangent}),_(0,t,"textureCoordinate",function(){return this._textureCoordinate}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"blendWeight",function(){return this._blendWeight}),_(0,t,"color",function(){return this._color}),_(0,t,"blendIndex",function(){return this._blendIndex}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(92,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector4",1),new Xe(40,"vector2",2),new Xe(48,"vector4",7),new Xe(64,"vector4",6),new Xe(80,"vector3",5)])}]),e}(),ft=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}p(e,"laya.d3.graphics.VertexPositionNormalColorTextureSTangent");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"tangent",function(){return this._tangent}),_(0,t,"textureCoordinate",function(){return this._textureCoordinate}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"color",function(){return this._color}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(64,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector4",1),new Xe(40,"vector2",2),new Xe(48,"vector4",5)])}]),e}(),mt=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}p(e,"laya.d3.graphics.VertexPositionNormalColorTextureTangent");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"tangent",function(){return this._tangent}),_(0,t,"textureCoordinate",function(){return this._textureCoordinate}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"color",function(){return this._color}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(60,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector4",1),new Xe(40,"vector2",2),new Xe(48,"vector3",5)])}]),e}(),pt=function(){function e(e,t,n){this._position=null,this._normal=null,this._tangent=null,this._position=e,this._normal=t,this._tangent=n}p(e,"laya.d3.graphics.VertexPositionNormalSTangent");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"tangent",function(){return this._tangent}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(40,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector4",5)])}]),e}(),Et=function(){function e(e,t,n){this._position=null,this._normal=null,this._tangent=null,this._position=e,this._normal=t,this._tangent=n}p(e,"laya.d3.graphics.VertexPositionNormalTangent");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"tangent",function(){return this._tangent}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(36,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector3",5)])}]),e}(),vt=function(){function e(e,t,n){this._position=null,this._normal=null,this._textureCoordinate=null,this._position=e,this._normal=t,this._textureCoordinate=n}p(e,"laya.d3.graphics.VertexPositionNormalTexture");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"textureCoordinate",function(){return this._textureCoordinate}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(32,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector2",2)])}]),e}(),gt=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}p(e,"laya.d3.graphics.VertexPositionNormalTexture0Texture1");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(40,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector2",2),new Xe(32,"vector2",15)])}]),e}(),Tt=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}p(e,"laya.d3.graphics.VertexPositionNormalTexture0Texture1Skin");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),_(0,t,"blendIndex",function(){return this._blendIndex}),_(0,t,"blendWeight",function(){return this._blendWeight}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(72,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector2",2),new Xe(32,"vector2",15),new Xe(40,"vector4",7),new Xe(56,"vector4",6)])}]),e}(),St=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}p(e,"laya.d3.graphics.VertexPositionNormalTexture0Texture1SkinSTangent");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"tangent",function(){return this._tangent}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),_(0,t,"blendIndex",function(){return this._blendIndex}),_(0,t,"blendWeight",function(){return this._blendWeight}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(88,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector2",2),new Xe(32,"vector2",15),new Xe(40,"vector4",7),new Xe(56,"vector4",6),new Xe(72,"vector4",5)])}]),e}(),Dt=function(){function e(){this._position=null,this._normal=null,this._textureCoordinate0=null,this._textureCoordinate1=null,this._blendIndex=null,this._blendWeight=null,this._tangent=null}p(e,"laya.d3.graphics.VertexPositionNormalTexture0Texture1SkinTangent");var t=e.prototype;return S.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},_(0,t,"tangent",function(){return this._tangent}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),_(0,t,"blendIndex",function(){return this._blendIndex}),_(0,t,"blendWeight",function(){return this._blendWeight}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(84,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector2",2),new Xe(32,"vector2",15),new Xe(40,"vector4",7),new Xe(56,"vector4",6),new Xe(72,"vector3",5)])}]),e}(),xt=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}p(e,"laya.d3.graphics.VertexPositionNormalTexture0Texture1STangent");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"tangent",function(){return this._tangent}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(56,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector2",2),new Xe(32,"vector2",15),new Xe(40,"vector4",5)])}]),e}(),Mt=function(){function e(){this._position=null,this._normal=null,this._textureCoordinate0=null,this._textureCoordinate1=null,this._tangent=null}p(e,"laya.d3.graphics.VertexPositionNormalTexture0Texture1Tangent");var t=e.prototype;return S.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},_(0,t,"tangent",function(){return this._tangent}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(52,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector2",2),new Xe(32,"vector2",15),new Xe(40,"vector3",5)])}]),e}(),Rt=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}p(e,"laya.d3.graphics.VertexPositionNormalTextureSkin");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"textureCoordinate",function(){return this._textureCoordinate}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"blendIndex",function(){return this._blendIndex}),_(0,t,"blendWeight",function(){return this._blendWeight}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(64,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector2",2),new Xe(32,"vector4",7),new Xe(48,"vector4",6)])}]),e}(),It=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}p(e,"laya.d3.graphics.VertexPositionNormalTextureSkinSTangent");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"tangent",function(){return this._tangent}),_(0,t,"textureCoordinate",function(){return this._textureCoordinate}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"blendIndex",function(){return this._blendIndex}),_(0,t,"blendWeight",function(){return this._blendWeight}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(80,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector2",2),new Xe(32,"vector4",7),new Xe(48,"vector4",6),new Xe(64,"vector4",5)])}]),e}(),At=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}p(e,"laya.d3.graphics.VertexPositionNormalTextureSkinTangent");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"tangent",function(){return this._tangent}),_(0,t,"textureCoordinate",function(){return this._textureCoordinate}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"blendIndex",function(){return this._blendIndex}),_(0,t,"blendWeight",function(){return this._blendWeight}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(76,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector2",2),new Xe(32,"vector4",7),new Xe(48,"vector4",6),new Xe(64,"vector3",5)])}]),e}(),Ct=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}p(e,"laya.d3.graphics.VertexPositionNormalTextureSTangent");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"tangent",function(){return this._tangent}),_(0,t,"textureCoordinate",function(){return this._textureCoordinate}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(48,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector2",2),new Xe(32,"vector4",5)])}]),e}(),yt=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}p(e,"laya.d3.graphics.VertexPositionNormalTextureTangent");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"tangent",function(){return this._tangent}),_(0,t,"textureCoordinate",function(){return this._textureCoordinate}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(44,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector2",2),new Xe(32,"vector3",5)])}]),e}(),Ot=function(){function e(e,t,n){this._position=null,this._normal=null,this._textureCoordinate=null,this._position=e,this._normal=t,this._textureCoordinate=n}p(e,"laya.d3.graphics.VertexPositionNTBTexture");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"textureCoordinate",function(){return this._textureCoordinate}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(56,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector3",5),new Xe(36,"vector3",4),new Xe(48,"vector2",2)])}]),e}(),Nt=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,this._blendIndex=o,this._blendWeight=s}p(e,"laya.d3.graphics.VertexPositionNTBTexture0Texture1Skin");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"tangent",function(){return this._tangent}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(0,t,"textureCoordinate1",function(){return this._textureCoordinate1}),_(0,t,"blendIndex",function(){return this._blendIndex}),_(0,t,"blendWeight",function(){return this._blendWeight}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(96,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector3",5),new Xe(36,"vector3",4),new Xe(48,"vector2",2),new Xe(56,"vector2",15),new Xe(64,"vector4",7),new Xe(80,"vector4",6)])}]),e}(),Vt=function(){function e(e,t,n){this._position=null,this._normal=null,this._textureCoordinate=null,this._position=e,this._normal=t,this._textureCoordinate=n}p(e,"laya.d3.graphics.VertexPositionNTBTextureSkin");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"textureCoordinate",function(){return this._textureCoordinate}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(88,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector3",5),new Xe(36,"vector3",4),new Xe(48,"vector2",2),new Xe(56,"vector4",7),new Xe(72,"vector4",6)])}]),e}(),Lt=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}p(e,"laya.d3.graphics.VertexPositionTerrain");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"normal",function(){return this._normal}),_(0,t,"position",function(){return this._position}),_(0,t,"textureCoord0",function(){return this._textureCoord0}),_(0,t,"textureCoord1",function(){return this._textureCoord1}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(40,[new Xe(0,"vector3",0),new Xe(12,"vector3",3),new Xe(24,"vector2",2),new Xe(32,"vector2",15)])}]),e}(),wt=function(){function e(e,t){this._position=null,this._textureCoordinate0=null,this._position=e,this._textureCoordinate0=t}p(e,"laya.d3.graphics.VertexPositionTexture0");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"position",function(){return this._position}),_(0,t,"textureCoordinate0",function(){return this._textureCoordinate0}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(20,[new Xe(0,"vector3",0),new Xe(12,"vector2",2)])}]),e}(),Ft=function(){function e(e,t,n,i,r,a,o,s,l,h,_,u,d,c){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=c}p(e,"laya.d3.graphics.VertexShurikenParticleBillboard");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"cornerTextureCoordinate",function(){return this._cornerTextureCoordinate}),_(0,t,"random1",function(){return this._randoms1}),_(0,t,"startRotation2",function(){return this._startRotation2}),_(0,t,"positionStartLifeTime",function(){return this._positionStartLifeTime}),_(0,t,"velocity",function(){return this._velocity}),_(0,t,"random0",function(){return this._randoms0}),_(0,t,"startSize",function(){return this._startSize}),_(0,t,"startColor",function(){return this._startColor}),_(0,t,"startRotation0",function(){return this._startRotation0}),_(0,t,"startRotation1",function(){return this._startRotation1}),_(0,t,"startLifeTime",function(){return this._startLifeTime}),_(0,t,"time",function(){return this._time}),_(0,t,"startSpeed",function(){return this._startSpeed}),_(0,t,"simulationWorldPostion",function(){return this._simulationWorldPostion}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(152,[new Xe(0,"vector4",17),new Xe(16,"vector4",30),new Xe(32,"vector4",32),new Xe(48,"vector4",19),new Xe(64,"vector3",20),new Xe(76,"vector3",22),new Xe(88,"single",31),new Xe(92,"vector4",34),new Xe(108,"vector4",35),new Xe(124,"vector3",36),new Xe(136,"vector4",37)])}]),e}(),Pt=function(){function e(e,t,n,i,r,a,o,s,l,h,_,u,d,c){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=c}p(e,"laya.d3.graphics.VertexShurikenParticleMesh");var t=e.prototype;return S.imps(t,{"laya.d3.graphics.IVertex":!0}),_(0,t,"cornerTextureCoordinate",function(){return this._cornerTextureCoordinate}),_(0,t,"velocity",function(){return this._velocity}),_(0,t,"position",function(){return this._positionStartLifeTime}),_(0,t,"random0",function(){return this._randoms0}),_(0,t,"startSize",function(){return this._startSize}),_(0,t,"startColor",function(){return this._startColor}),_(0,t,"startRotation0",function(){return this._startRotation0}),_(0,t,"startRotation1",function(){return this._startRotation1}),_(0,t,"random1",function(){return this._randoms1}),_(0,t,"startRotation2",function(){return this._startRotation2}),_(0,t,"startLifeTime",function(){return this._startLifeTime}),_(0,t,"time",function(){return this._time}),_(0,t,"startSpeed",function(){return this._startSpeed}),_(0,t,"simulationWorldPostion",function(){return this._simulationWorldPostion}),_(0,t,"vertexDeclaration",function(){return e._vertexDeclaration}),_(1,e,"vertexDeclaration",function(){return e._vertexDeclaration}),l(e,["_vertexDeclaration",function(){return this._vertexDeclaration=new ke(172,[new Xe(0,"vector3",0),new Xe(12,"vector4",1),new Xe(28,"vector2",2),new Xe(36,"vector4",30),new Xe(52,"vector4",32),new Xe(68,"vector4",19),new Xe(84,"vector3",20),new Xe(96,"vector3",22),new Xe(108,"single",31),new Xe(112,"vector4",34),new Xe(128,"vector4",35),new Xe(144,"vector3",36),new Xe(156,"vector4",37)])}]),e}(),bt=function(){function d(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)}p(d,"laya.d3.loaders.LoadModelV01");var e=d.prototype;return e._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},e.onError=function(){},e._readString=function(){return this._strings[this._readData.getUint16()]},e.READ_BLOCK=function(){this._readData.getUint16();return this._BLOCK.count=this._readData.getUint16(),!0},e.READ_DATA=function(){return this._DATA.offset=this._readData.getUint32(),this._DATA.size=this._readData.getUint32(),!0},e.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},e.READ_MATERIAL=function(){var e=this._readData.getUint16(),t=(this._readString(),this._readString());return this._materials[e]="null"!==t?W.getRes(this._materialMap[t]):new ri,!0},e.READ_MESH=function(){this._readString();switch(this._version){case"LAYAMODEL:01":console.log("Warning: The (.lm) file is converted by old fbxTools,please reConverted it use lastest fbxTools version,later we will remove the support of old version (.lm) support.");break;case"LAYASKINANI:01":case"LAYAMODEL:02":var e,t=this._readData.__getBuffer(),n=0,i=this._readData.getUint32(),r=this._readData.getUint32(),i=(new Float32Array(t.slice(i+this._DATA.offset,i+this._DATA.offset+r)),this._readData.getUint32()),r=this._readData.getUint32(),a=new Float32Array(t.slice(i+this._DATA.offset,i+this._DATA.offset+r));for(this.mesh._inverseBindPoses=[],n=0,e=a.length;n<e;n+=16){var o=new Jt(a[n+0],a[n+1],a[n+2],a[n+3],a[n+4],a[n+5],a[n+6],a[n+7],a[n+8],a[n+9],a[n+10],a[n+11],a[n+12],a[n+13],a[n+14],a[n+15]);this.mesh._inverseBindPoses.push(o)}break;default:throw new Error("LoadModel:unknown version.")}return!0},e.READ_SUBMESH=function(){this._readString(),this._readData.getUint8();var e=this._readString();this._shaderAttributes=e.match(d._attrReg);var t=this._readData.getUint32(),n=this._readData.getUint32(),i=(this._readData.getUint32(),this._readData.getUint32(),this._readData.getUint32()),r=this._readData.getUint32(),a=this._readData.getUint32(),o=this._readData.getUint32(),s=this._readData.__getBuffer(),l=new cn(this._mesh),e=this._getVertexDeclaration(),h=Gi.create(e,r/e.vertexStride,35044,!0),i=i+this._DATA.offset,r=s.slice(i,i+r);h.setData(new Float32Array(r));for(var _=(l._vertexBuffer=h).vertexDeclaration.getVertexElements(),u=0;u<_.length;u++)l._bufferUsage[_[u].elementUsage]=h;r=Ui.create("ushort",n/2,35044,!0),t+=this._DATA.offset,n=s.slice(t,t+n);r.setData(new Uint16Array(n)),l._indexBuffer=r;o=s.slice(a+this._DATA.offset,a+this._DATA.offset+o);return l._boneIndicesList[0]=new Uint8Array(o),this._subMeshes.push(l),!0},e.READ_DATAAREA=function(){return!1},e._getVertexDeclaration=function(){for(var e,t=!1,n=!1,i=!1,r=!1,a=!1,o=!1,s=!1,l=!1,h=!1,_=0;_<this._shaderAttributes.length;_+=8)switch(this._shaderAttributes[_]){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}return t&&n&&i&&r&&a&&s&&l&&o?e=lt.vertexDeclaration:t&&n&&i&&r&&a&&s&&l?e=ot.vertexDeclaration:t&&n&&r&&a&&s&&l&&o?e=Dt.vertexDeclaration:t&&n&&r&&a&&s&&l?e=Tt.vertexDeclaration:t&&n&&i&&r&&s&&l&&o?e=ct.vertexDeclaration:t&&n&&i&&r&&s&&l?e=ut.vertexDeclaration:t&&n&&o&&h&&r&&s&&l?e=Vt.vertexDeclaration:t&&n&&r&&s&&l&&o?e=At.vertexDeclaration:t&&n&&r&&s&&l?e=Rt.vertexDeclaration:t&&n&&i&&s&&l&&o?e=tt.vertexDeclaration:t&&n&&i&&s&&l?e=Je.vertexDeclaration:t&&n&&i&&r&&a&&o?e=_t.vertexDeclaration:t&&n&&i&&r&&a?e=at.vertexDeclaration:t&&n&&r&&a&&o?e=Mt.vertexDeclaration:t&&n&&r&&a?e=gt.vertexDeclaration:t&&n&&i&&r&&o?e=mt.vertexDeclaration:t&&n&&r&&o&&h?e=Ot.vertexDeclaration:t&&n&&i&&r?e=rt.vertexDeclaration:t&&n&&r&&o?e=yt.vertexDeclaration:t&&n&&r?e=vt.vertexDeclaration:t&&n&&i&&o?e=it.vertexDeclaration:t&&n&&i&&(e=$e.vertexDeclaration),e},_(0,e,"mesh",function(){return this._mesh}),d._attrReg=new RegExp("(\\w+)|([:,;])","g"),d}(),Bt=(p(Ut,"laya.d3.loaders.LoadModelV02"),Ut.parse=function(e,t,n,i,r,a){Ut._mesh=n,Ut._materials=i,Ut._subMeshes=r,Ut._materialMap=a,Ut._version=t,Ut._readData=e,Ut.READ_DATA(),Ut.READ_BLOCK(),Ut.READ_STRINGS();for(var o=0,s=Ut._BLOCK.count;o<s;o++){Ut._readData.pos=Ut._BLOCK.blockStarts[o];var l=Ut._readData.getUint16(),h=Ut._strings[l],_=Ut["READ_"+h];if(null==_)throw new Error("model file err,no this function:"+l+" "+h);_.call()}Ut._strings.length=0,Ut._readData=null,Ut._version=null,Ut._mesh=null,Ut._materials=null,Ut._subMeshes=null,Ut._materialMap=null},Ut._readString=function(){return Ut._strings[Ut._readData.getUint16()]},Ut.READ_DATA=function(){Ut._DATA.offset=Ut._readData.getUint32(),Ut._DATA.size=Ut._readData.getUint32()},Ut.READ_BLOCK=function(){for(var e=Ut._BLOCK.count=Ut._readData.getUint16(),t=Ut._BLOCK.blockStarts=[],n=Ut._BLOCK.blockLengths=[],i=0;i<e;i++)t.push(Ut._readData.getUint32()),n.push(Ut._readData.getUint32())},Ut.READ_STRINGS=function(){var e=Ut._readData.getUint32(),t=Ut._readData.getUint16(),n=Ut._readData.pos;Ut._readData.pos=e+Ut._DATA.offset;for(var i=0;i<t;i++)Ut._strings[i]=Ut._readData.readUTFString();Ut._readData.pos=n},Ut.READ_MATERIAL=function(){Ut._readString(),Ut._readString();var e=Ut._readString();return""!==e&&Ut._materials.push(W.getRes(Ut._materialMap[e])),!0},Ut.READ_MESH=function(){Ut._readString();for(var e,t=Ut._readData.__getBuffer(),n=0,i=Ut._readData.getInt16(),r=Ut._DATA.offset,n=0;n<i;n++){var a=r+Ut._readData.getUint32(),o=Ut._readData.getUint32(),a=new Float32Array(t.slice(a,a+o)),o=Ut._readString().match(Ut._attrReg),o=Ut._getVertexDeclaration(o),o=Gi.create(o,4*a.length/o.vertexStride,35044,!0);o.setData(a),Ut._mesh._vertexBuffers.push(o)}var s=r+Ut._readData.getUint32(),l=Ut._readData.getUint32(),s=new Uint16Array(t.slice(s,s+l)),l=Ui.create("ushort",l/2,35044,!0);l.setData(s),Ut._mesh._indexBuffer=l;var h=Ut._mesh._boneNames=[],_=Ut._readData.getUint16();for(h.length=_,n=0;n<_;n++)h[n]=Ut._strings[Ut._readData.getUint16()];var s=Ut._readData.getUint32(),l=Ut._readData.getUint32(),s=(new Float32Array(t.slice(r+s,r+s+l)),Ut._readData.getUint32()),l=Ut._readData.getUint32(),u=new Float32Array(t.slice(r+s,r+s+l));for(Ut._mesh._inverseBindPoses=[],n=0,e=u.length;n<e;n+=16){var d=new Jt(u[n+0],u[n+1],u[n+2],u[n+3],u[n+4],u[n+5],u[n+6],u[n+7],u[n+8],u[n+9],u[n+10],u[n+11],u[n+12],u[n+13],u[n+14],u[n+15]);Ut._mesh._inverseBindPoses.push(d)}return Ut._mesh._skinnedDatas=new Float32Array(16*u.length),!0},Ut.READ_SUBMESH=function(){var e=Ut._readData.__getBuffer(),t=new cn(Ut._mesh),n=Ut._readData.getInt16(),i=Ut._readData.getUint32(),r=Ut._readData.getUint32();t._vertexBuffer=Ut._mesh._vertexBuffers[n],t._vertexStart=i,t._vertexCount=r;n=Ut._readData.getUint32(),i=Ut._readData.getUint32(),r=Ut._mesh._indexBuffer;t._indexBuffer=r,t._indexStart=n,t._indexCount=i,t._indices=new Uint16Array(r.getData().buffer,2*n,i);var a=Ut._DATA.offset,o=t._subIndexBufferStart,s=t._subIndexBufferCount,i=t._boneIndicesList,l=Ut._readData.getUint16();o.length=l,s.length=l,i.length=l;for(var h=0;h<l;h++){o[h]=Ut._readData.getUint32(),s[h]=Ut._readData.getUint32();var _=Ut._readData.getUint32(),u=Ut._readData.getUint32();t._boneIndicesList[h]=new Uint8Array(e.slice(a+_,a+_+u))}return Ut._subMeshes.push(t),!0},Ut._getVertexDeclaration=function(e){for(var t,n=!1,i=!1,r=!1,a=!1,o=!1,s=!1,l=!1,h=!1,_=!1,u=0;u<e.length;u++)switch(e[u]){case"POSITION":n=!0;break;case"NORMAL":i=!0;break;case"COLOR":r=!0;break;case"UV":a=!0;break;case"UV1":o=!0;break;case"BLENDWEIGHT":l=!0;break;case"BLENDINDICES":h=!0;break;case"TANGENT":s=!0;break;case"BINORMAL":_=!0}return n&&i&&r&&a&&o&&l&&h&&s?t=lt.vertexDeclaration:n&&i&&r&&a&&o&&l&&h?t=ot.vertexDeclaration:n&&i&&a&&o&&l&&h&&s?t=Dt.vertexDeclaration:n&&i&&a&&o&&l&&h?t=Tt.vertexDeclaration:n&&i&&r&&a&&l&&h&&s?t=ct.vertexDeclaration:n&&i&&r&&a&&l&&h?t=ut.vertexDeclaration:n&&i&&a&&l&&h&&s?t=At.vertexDeclaration:n&&i&&a&&l&&h?t=Rt.vertexDeclaration:n&&i&&r&&l&&h&&s?t=tt.vertexDeclaration:n&&i&&r&&l&&h?t=Je.vertexDeclaration:n&&i&&r&&a&&o&&s?t=_t.vertexDeclaration:n&&i&&r&&a&&o?t=at.vertexDeclaration:n&&i&&a&&o&&s?t=Mt.vertexDeclaration:n&&i&&a&&o?t=gt.vertexDeclaration:n&&i&&r&&a&&s?t=mt.vertexDeclaration:n&&i&&a&&s&&_?t=Ot.vertexDeclaration:n&&i&&r&&a?t=rt.vertexDeclaration:n&&i&&a&&s?t=yt.vertexDeclaration:n&&i&&a?t=vt.vertexDeclaration:n&&i&&r&&s?t=it.vertexDeclaration:n&&i&&r&&(t=$e.vertexDeclaration),t},Ut._attrReg=new RegExp("(\\w+)|([:,;])","g"),Ut._strings=[],Ut._readData=null,Ut._version=null,Ut._mesh=null,Ut._materials=null,Ut._subMeshes=null,Ut._materialMap=null,l(Ut,["_BLOCK",function(){return this._BLOCK={count:0}},"_DATA",function(){return this._DATA={offset:0,size:0}}]),Ut);function Ut(){}var Ht=(p(Gt,"laya.d3.loaders.LoadModelV03"),Gt.parse=function(e,t,n,i,r){Gt._mesh=n,Gt._subMeshes=i,Gt._materialMap=r,Gt._version=t,Gt._readData=e,Gt.READ_DATA(),Gt.READ_BLOCK(),Gt.READ_STRINGS();for(var a=0,o=Gt._BLOCK.count;a<o;a++){Gt._readData.pos=Gt._BLOCK.blockStarts[a];var s=Gt._readData.getUint16(),l=Gt._strings[s],h=Gt["READ_"+l];if(null==h)throw new Error("model file err,no this function:"+s+" "+l);h.call()}Gt._strings.length=0,Gt._readData=null,Gt._version=null,Gt._mesh=null,Gt._subMeshes=null,Gt._materialMap=null},Gt._readString=function(){return Gt._strings[Gt._readData.getUint16()]},Gt.READ_DATA=function(){Gt._DATA.offset=Gt._readData.getUint32(),Gt._DATA.size=Gt._readData.getUint32()},Gt.READ_BLOCK=function(){for(var e=Gt._BLOCK.count=Gt._readData.getUint16(),t=Gt._BLOCK.blockStarts=[],n=Gt._BLOCK.blockLengths=[],i=0;i<e;i++)t.push(Gt._readData.getUint32()),n.push(Gt._readData.getUint32())},Gt.READ_STRINGS=function(){var e=Gt._readData.getUint32(),t=Gt._readData.getUint16(),n=Gt._readData.pos;Gt._readData.pos=e+Gt._DATA.offset;for(var i=0;i<t;i++)Gt._strings[i]=Gt._readData.readUTFString();Gt._readData.pos=n},Gt.READ_MESH=function(){Gt._readString();for(var e,t=Gt._readData.__getBuffer(),n=0,i=Gt._readData.getInt16(),r=Gt._DATA.offset,n=0;n<i;n++){var a,o=r+Gt._readData.getUint32(),s=Gt._readData.getUint32(),o=new Float32Array(t.slice(o,o+s)),l=Gt._readString();switch(Gt._version){case"LAYAMODEL:03":a=Gt._vertexDeclarationMap_Discard[l];break;case"LAYAMODEL:0301":a=Gt._vertexDeclarationMap[l];break;default:throw new Error("LoadModelV03: unknown version.")}if(!a)throw new Error("LoadModelV03: unknown vertexDeclaration.");s=Gi.create(a,4*o.length/a.vertexStride,35044,!0);s.setData(o),Gt._mesh._vertexBuffers.push(s)}var h=r+Gt._readData.getUint32(),_=Gt._readData.getUint32(),h=new Uint16Array(t.slice(h,h+_)),_=Ui.create("ushort",_/2,35044,!0);_.setData(h),Gt._mesh._indexBuffer=_;var u=Gt._mesh._boneNames=[],d=Gt._readData.getUint16();for(u.length=d,n=0;n<d;n++)u[n]=Gt._strings[Gt._readData.getUint16()];Gt._readData.pos+=8;var h=Gt._readData.getUint32(),_=Gt._readData.getUint32(),c=new Float32Array(t.slice(r+h,r+h+_));for(Gt._mesh._inverseBindPoses=[],n=0,e=c.length;n<e;n+=16){var f=new Jt(c[n+0],c[n+1],c[n+2],c[n+3],c[n+4],c[n+5],c[n+6],c[n+7],c[n+8],c[n+9],c[n+10],c[n+11],c[n+12],c[n+13],c[n+14],c[n+15]);Gt._mesh._inverseBindPoses.push(f)}return Gt._mesh._skinnedDatas=new Float32Array(16*c.length),!0},Gt.READ_SUBMESH=function(){var e=Gt._readData.__getBuffer(),t=new cn(Gt._mesh),n=Gt._readData.getInt16(),i=Gt._readData.getUint32(),r=Gt._readData.getUint32();t._vertexBuffer=Gt._mesh._vertexBuffers[n],t._vertexStart=i,t._vertexCount=r;n=Gt._readData.getUint32(),i=Gt._readData.getUint32(),r=Gt._mesh._indexBuffer;t._indexBuffer=r,t._indexStart=n,t._indexCount=i,t._indices=new Uint16Array(r.getData().buffer,2*n,i);var a=Gt._DATA.offset,o=t._subIndexBufferStart,s=t._subIndexBufferCount,l=t._boneIndicesList,h=Gt._readData.getUint16();o.length=h,s.length=h,l.length=h;for(var _=0;_<h;_++){o[_]=Gt._readData.getUint32(),s[_]=Gt._readData.getUint32();var u=Gt._readData.getUint32(),d=Gt._readData.getUint32();l[_]=new Uint8Array(e.slice(a+u,a+u+d))}return Gt._subMeshes.push(t),!0},Gt._strings=[],Gt._readData=null,Gt._version=null,Gt._mesh=null,Gt._subMeshes=null,Gt._materialMap=null,l(Gt,["_vertexDeclarationMap_Discard",function(){return this._vertexDeclarationMap_Discard={"POSITION,NORMAL,COLOR,UV,UV1,BLENDWEIGHT,BLENDINDICES,TANGENT":lt.vertexDeclaration,"POSITION,NORMAL,COLOR,UV,UV1,BLENDWEIGHT,BLENDINDICES":ot.vertexDeclaration,"POSITION,NORMAL,TANGENT,BINORMAL,UV,UV1,BLENDWEIGHT,BLENDINDICES,":Nt.vertexDeclaration,"POSITION,NORMAL,UV,UV1,BLENDWEIGHT,BLENDINDICES,TANGENT":Dt.vertexDeclaration,"POSITION,NORMAL,UV,UV1,BLENDWEIGHT,BLENDINDICES":Tt.vertexDeclaration,"POSITION,NORMAL,COLOR,UV,BLENDWEIGHT,BLENDINDICES,TANGENT":ct.vertexDeclaration,"POSITION,NORMAL,COLOR,UV,BLENDWEIGHT,BLENDINDICES":ut.vertexDeclaration,"POSITION,NORMAL,UV,BLENDWEIGHT,BLENDINDICES,TANGENT":At.vertexDeclaration,"POSITION,NORMAL,UV,BLENDWEIGHT,BLENDINDICES":Rt.vertexDeclaration,"POSITION,NORMAL,COLOR,BLENDWEIGHT,BLENDINDICES,TANGENT":tt.vertexDeclaration,"POSITION,NORMAL,COLOR,BLENDWEIGHT,BLENDINDICES":Je.vertexDeclaration,"POSITION,NORMAL,COLOR,UV,UV1,TANGENT":_t.vertexDeclaration,"POSITION,NORMAL,COLOR,UV,UV1":at.vertexDeclaration,"POSITION,NORMAL,UV,UV1,TANGENT":Mt.vertexDeclaration,"POSITION,NORMAL,UV,UV1":gt.vertexDeclaration,"POSITION,NORMAL,COLOR,UV,TANGENT":mt.vertexDeclaration,"POSITION,NORMAL,UV,TANGENT,BINORMAL":Ot.vertexDeclaration,"POSITION,NORMAL,COLOR,UV":rt.vertexDeclaration,"POSITION,NORMAL,UV,TANGENT":yt.vertexDeclaration,"POSITION,NORMAL,UV":vt.vertexDeclaration,"POSITION,NORMAL,COLOR,TANGENT":it.vertexDeclaration,"POSITION,NORMAL,COLOR":$e.vertexDeclaration,"POSITION,NORMAL,TANGENT":Et.vertexDeclaration,"POSITION,NORMAL":Qe.vertexDeclaration,"POSITION,UV":wt.vertexDeclaration,POSITION:qe.vertexDeclaration}},"_vertexDeclarationMap",function(){return this._vertexDeclarationMap={"POSITION,NORMAL,COLOR,UV,UV1,BLENDWEIGHT,BLENDINDICES,TANGENT":st.vertexDeclaration,"POSITION,NORMAL,COLOR,UV,UV1,BLENDWEIGHT,BLENDINDICES":ot.vertexDeclaration,"POSITION,NORMAL,TANGENT,BINORMAL,UV,UV1,BLENDWEIGHT,BLENDINDICES,":Nt.vertexDeclaration,"POSITION,NORMAL,UV,UV1,BLENDWEIGHT,BLENDINDICES,TANGENT":St.vertexDeclaration,"POSITION,NORMAL,UV,UV1,BLENDWEIGHT,BLENDINDICES":Tt.vertexDeclaration,"POSITION,NORMAL,COLOR,UV,BLENDWEIGHT,BLENDINDICES,TANGENT":dt.vertexDeclaration,"POSITION,NORMAL,COLOR,UV,BLENDWEIGHT,BLENDINDICES":ut.vertexDeclaration,"POSITION,NORMAL,UV,BLENDWEIGHT,BLENDINDICES,TANGENT":It.vertexDeclaration,"POSITION,NORMAL,UV,BLENDWEIGHT,BLENDINDICES":Rt.vertexDeclaration,"POSITION,NORMAL,COLOR,BLENDWEIGHT,BLENDINDICES,TANGENT":et.vertexDeclaration,"POSITION,NORMAL,COLOR,BLENDWEIGHT,BLENDINDICES":Je.vertexDeclaration,"POSITION,NORMAL,COLOR,UV,UV1,TANGENT":ht.vertexDeclaration,"POSITION,NORMAL,COLOR,UV,UV1":at.vertexDeclaration,"POSITION,NORMAL,UV,UV1,TANGENT":xt.vertexDeclaration,"POSITION,NORMAL,UV,UV1":gt.vertexDeclaration,"POSITION,NORMAL,COLOR,UV,TANGENT":ft.vertexDeclaration,"POSITION,NORMAL,UV,TANGENT,BINORMAL":Ot.vertexDeclaration,"POSITION,NORMAL,COLOR,UV":rt.vertexDeclaration,"POSITION,NORMAL,UV,TANGENT":Ct.vertexDeclaration,"POSITION,NORMAL,UV":vt.vertexDeclaration,"POSITION,NORMAL,COLOR,TANGENT":nt.vertexDeclaration,"POSITION,NORMAL,COLOR":$e.vertexDeclaration,"POSITION,NORMAL,TANGENT":pt.vertexDeclaration,"POSITION,NORMAL":Qe.vertexDeclaration,"POSITION,UV":wt.vertexDeclaration,POSITION:qe.vertexDeclaration}},"_BLOCK",function(){return this._BLOCK={count:0}},"_DATA",function(){return this._DATA={offset:0,size:0}}]),Gt);function Gt(){}var zt=(p(Wt,"laya.d3.loaders.MeshReader"),Wt.read=function(e,t,n,i,r){var a=new g(e);a.pos=0;var o=a.readUTFString();switch(o){case"LAYAMODEL:01":case"LAYASKINANI:01":Wt._readVersion01(a,o,t,n,i,r);break;case"LAYAMODEL:02":Bt.parse(a,o,t,n,i,r);break;case"LAYAMODEL:03":case"LAYAMODEL:0301":Ht.parse(a,o,t,i,r);break;default:throw new Error("MeshReader: unknown mesh version.")}t._setSubMeshes(i)},Wt._readVersion01=function(e,t,n,i,r,a){new bt(e,t,n,i,r,a)},Wt);function Wt(){}var kt=function(){function e(e,t){this.min=null,this.max=null,this.min=e,this.max=t}p(e,"laya.d3.math.BoundBox");var t=e.prototype;return S.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],t=n[1],n=n[2];e[0]=new hn(i,t,n),e[1]=new hn(o,t,n),e[2]=new hn(o,r,n),e[3]=new hn(i,r,n),e[4]=new hn(i,t,a),e[5]=new hn(o,t,a),e[6]=new hn(o,r,a),e[7]=new hn(i,r,a)},t.toDefault=function(){this.min.toDefault(),this.max.toDefault()},t.cloneTo=function(e){this.min.cloneTo(e.min),this.max.cloneTo(e.max)},t.clone=function(){var e=new this.constructor(new hn,new hn);return this.cloneTo(e),e},e.createfromPoints=function(e,t){if(null==e)throw new Error("points");var n=t.min,i=t.max,t=n.elements;t[0]=Number.MAX_VALUE,t[1]=Number.MAX_VALUE,t[2]=Number.MAX_VALUE;t=i.elements;t[0]=-Number.MAX_VALUE,t[1]=-Number.MAX_VALUE,t[2]=-Number.MAX_VALUE;for(var r=0,a=e.length;r<a;++r)hn.min(n,e[r],n),hn.max(i,e[r],i)},e.merge=function(e,t,n){hn.min(e.min,t.min,n.min),hn.max(e.max,t.max,n.max)},e}(),Xt=function(){function o(e){this._matrix=null,this._near=null,this._far=null,this._left=null,this._right=null,this._top=null,this._bottom=null,this._matrix=e,this._near=new tn(new hn),this._far=new tn(new hn),this._left=new tn(new hn),this._right=new tn(new hn),this._top=new tn(new hn),this._bottom=new tn(new hn),o._getPlanesFromMatrix(this._matrix,this._near,this._far,this._left,this._right,this._top,this._bottom)}p(o,"laya.d3.math.BoundFrustum");var e=o.prototype;return e.equalsBoundFrustum=function(e){return this._matrix.equalsOtherMatrix(e.matrix)},e.equalsObj=function(e){return e instanceof laya.d3.math.BoundFrustum&&this.equalsBoundFrustum(e)},e.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}},e.getCorners=function(e){o._get3PlaneInterPoint(this._near,this._bottom,this._right).cloneTo(e[0]),o._get3PlaneInterPoint(this._near,this._top,this._right).cloneTo(e[1]),o._get3PlaneInterPoint(this._near,this._top,this._left).cloneTo(e[2]),o._get3PlaneInterPoint(this._near,this._bottom,this._left).cloneTo(e[3]),o._get3PlaneInterPoint(this._far,this._bottom,this._right).cloneTo(e[4]),o._get3PlaneInterPoint(this._far,this._top,this._right).cloneTo(e[5]),o._get3PlaneInterPoint(this._far,this._top,this._left).cloneTo(e[6]),o._get3PlaneInterPoint(this._far,this._bottom,this._left).cloneTo(e[7])},e.containsPoint=function(e){for(var t=tn.PlaneIntersectionType_Front,n=tn.PlaneIntersectionType_Front,i=0;i<6;i++){switch(i){case 0:n=Zt.intersectsPlaneAndPoint(this._near,e);break;case 1:n=Zt.intersectsPlaneAndPoint(this._far,e);break;case 2:n=Zt.intersectsPlaneAndPoint(this._left,e);break;case 3:n=Zt.intersectsPlaneAndPoint(this._right,e);break;case 4:n=Zt.intersectsPlaneAndPoint(this._top,e);break;case 5:n=Zt.intersectsPlaneAndPoint(this._bottom,e)}switch(n){case tn.PlaneIntersectionType_Back:return 0;case tn.PlaneIntersectionType_Intersecting:t=tn.PlaneIntersectionType_Intersecting}}return t!==tn.PlaneIntersectionType_Intersecting?1:2},e.containsBoundBox=function(e){for(var t,n=o._tempV30,i=o._tempV31,r=1,a=0;a<6;a++){if(t=this.getPlane(a),this._getBoxToPlanePVertexNVertex(e,t.normal,n,i),Zt.intersectsPlaneAndPoint(t,n)===tn.PlaneIntersectionType_Back)return 0;Zt.intersectsPlaneAndPoint(t,i)===tn.PlaneIntersectionType_Back&&(r=2)}return r},e.containsBoundSphere=function(e){for(var t=tn.PlaneIntersectionType_Front,n=tn.PlaneIntersectionType_Front,i=0;i<6;i++){switch(i){case 0:n=Zt.intersectsPlaneAndSphere(this._near,e);break;case 1:n=Zt.intersectsPlaneAndSphere(this._far,e);break;case 2:n=Zt.intersectsPlaneAndSphere(this._left,e);break;case 3:n=Zt.intersectsPlaneAndSphere(this._right,e);break;case 4:n=Zt.intersectsPlaneAndSphere(this._top,e);break;case 5:n=Zt.intersectsPlaneAndSphere(this._bottom,e)}switch(n){case tn.PlaneIntersectionType_Back:return 0;case tn.PlaneIntersectionType_Intersecting:t=tn.PlaneIntersectionType_Intersecting}}return t!==tn.PlaneIntersectionType_Intersecting?1:2},e._getBoxToPlanePVertexNVertex=function(e,t,n,i){var r=e.min,a=r.elements,o=e.max,s=o.elements,l=t.elements,e=l[0],t=l[1],l=l[2];r.cloneTo(n);n=n.elements;0<=e&&(n[0]=s[0]),0<=t&&(n[1]=s[1]),0<=l&&(n[2]=s[2]),o.cloneTo(i);i=i.elements;0<=e&&(i[0]=a[0]),0<=t&&(i[1]=a[1]),0<=l&&(i[2]=a[2])},_(0,e,"top",function(){return this._top}),_(0,e,"matrix",function(){return this._matrix},function(e){this._matrix=e,o._getPlanesFromMatrix(this._matrix,this._near,this._far,this._left,this._right,this._top,this._bottom)}),_(0,e,"near",function(){return this._near}),_(0,e,"far",function(){return this._far}),_(0,e,"left",function(){return this._left}),_(0,e,"right",function(){return this._right}),_(0,e,"bottom",function(){return this._bottom}),o._getPlanesFromMatrix=function(e,t,n,i,r,a,o){var s=e.elements,l=s[0],h=s[1],_=s[2],u=s[3],d=s[4],c=s[5],f=s[6],m=s[7],p=s[8],E=s[9],v=s[10],g=s[11],T=s[12],S=s[13],D=s[14],e=s[15],s=t.normal.elements;s[0]=u+_,s[1]=m+f,s[2]=g+v,t.distance=e+D,t.normalize();t=n.normal.elements;t[0]=u-_,t[1]=m-f,t[2]=g-v,n.distance=e-D,n.normalize();n=i.normal.elements;n[0]=u+l,n[1]=m+d,n[2]=g+p,i.distance=e+T,i.normalize();i=r.normal.elements;i[0]=u-l,i[1]=m-d,i[2]=g-p,r.distance=e-T,r.normalize();r=a.normal.elements;r[0]=u-h,r[1]=m-c,r[2]=g-E,a.distance=e-S,a.normalize();a=o.normal.elements;a[0]=u+h,a[1]=m+c,a[2]=g+E,o.distance=e+S,o.normalize()},o._get3PlaneInterPoint=function(e,t,n){var i=e.normal,r=t.normal,a=n.normal;hn.cross(r,a,o._tempV30),hn.cross(a,i,o._tempV31),hn.cross(i,r,o._tempV32);i=hn.dot(i,o._tempV30),r=hn.dot(r,o._tempV31),a=hn.dot(a,o._tempV32);return hn.scale(o._tempV30,-e.distance/i,o._tempV33),hn.scale(o._tempV31,-t.distance/r,o._tempV34),hn.scale(o._tempV32,-n.distance/a,o._tempV35),hn.add(o._tempV33,o._tempV34,o._tempV36),hn.add(o._tempV35,o._tempV36,o._tempV37),o._tempV37},l(o,["_tempV30",function(){return this._tempV30=new hn},"_tempV31",function(){return this._tempV31=new hn},"_tempV32",function(){return this._tempV32=new hn},"_tempV33",function(){return this._tempV33=new hn},"_tempV34",function(){return this._tempV34=new hn},"_tempV35",function(){return this._tempV35=new hn},"_tempV36",function(){return this._tempV36=new hn},"_tempV37",function(){return this._tempV37=new hn}]),o}(),Yt=function(){function _(e,t){this.center=null,this.radius=NaN,this.center=e,this.radius=t}p(_,"laya.d3.math.BoundSphere");var e=_.prototype;return S.imps(e,{"laya.d3.core.IClone":!0}),e.toDefault=function(){this.center.toDefault(),this.radius=0},e.intersectsRayDistance=function(e){return Zt.intersectsRayAndSphereRD(e,this)},e.intersectsRayPoint=function(e,t){return Zt.intersectsRayAndSphereRP(e,this,t)},e.cloneTo=function(e){this.center.cloneTo(e.center),e.radius=this.radius},e.clone=function(){var e=new this.constructor(new hn,new hn);return this.cloneTo(e),e},_.createFromSubPoints=function(e,t,n,i){if(null==e)throw new Error("points");if(t<0||t>=e.length)throw new Error("start"+t+"Must be in the range [0, "+(e.length-1)+"]");if(n<0||t+n>e.length)throw new Error("count"+n+"Must be in the range <= "+e.length+"}");var r=t+n,a=_._tempVector3;a.elements[0]=0,a.elements[1]=0,a.elements[2]=0;for(var o=t;o<r;++o)hn.add(e[o],a,a);var s=i.center;hn.scale(a,1/n,s);for(var l=0,o=t;o<r;++o){var h=hn.distanceSquared(s,e[o]);l<h&&(l=h)}i.radius=Math.sqrt(l)},_.createfromPoints=function(e,t){if(null==e)throw new Error("points");_.createFromSubPoints(e,0,e.length,t)},l(_,["_tempVector3",function(){return this._tempVector3=new hn}]),_}(),Zt=(p(jt,"laya.d3.math.Collision"),jt.distancePlaneToPoint=function(e,t){return hn.dot(e.normal,t)-e.distance},jt.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],n=t.elements,e=n[0],o=n[1],t=n[2],n=0;return e<i&&(n+=(i-e)*(i-e)),s<e&&(n+=(s-e)*(s-e)),o<r&&(n+=(r-o)*(r-o)),l<o&&(n+=(l-o)*(l-o)),t<a&&(n+=(a-t)*(a-t)),h<t&&(n+=(h-t)*(h-t)),Math.sqrt(n)},jt.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],d=_[1],c=_[2],n=t.max.elements,e=n[0],o=n[1],_=n[2],t=0,n=NaN;return e<i?t+=(n=i-e)*n:s<u&&(t+=(n=u-s)*n),o<r?t+=(n=r-o)*n:l<d&&(t+=(n=d-l)*n),_<a?t+=(n=a-_)*n:h<c&&(t+=(n=c-h)*n),Math.sqrt(t)},jt.distanceSphereToPoint=function(e,t){t=Math.sqrt(hn.distanceSquared(e.center,t));return t-=e.radius,Math.max(t,0)},jt.distanceSphereToSphere=function(e,t){var n=Math.sqrt(hn.distanceSquared(e.center,t.center));return n-=e.radius+t.radius,Math.max(n,0)},jt.intersectsRayAndTriangleRD=function(e,t,n,i,r){var a=e.origin.elements,o=a[0],s=a[1],l=a[2],h=e.direction.elements,_=h[0],u=h[1],d=h[2],c=t.elements,f=c[0],m=c[1],p=c[2],E=n.elements,v=E[0],g=E[1],T=E[2],S=i.elements,D=S[0],x=S[1],M=S[2],a=jt._tempV30.elements,e=a[0],h=a[1],t=a[2],c=jt._tempV31.elements,n=c[0],E=c[1],i=c[2],S=jt._tempV32.elements,a=S[0],c=S[1],S=S[2],x=(e=v-f)*(a=u*(i=M-p)-d*(E=x-m))+(h=g-m)*(c=d*(n=D-f)-_*i)+(t=T-p)*(S=_*E-u*n);if(qt.isZero(x))return!1;g=1/x,D=jt._tempV33.elements,T=D[0],x=D[1],D=D[2],c=(T=o-f)*a+(x=s-m)*c+(D=l-p)*S;if((c*=g)<0||1<c)return!1;l=jt._tempV34.elements,p=l[0],S=l[1],l=l[2],e=_*(p=x*t-D*h)+u*(S=D*e-T*t)+d*(l=T*h-x*e);if((e*=g)<0||1<c+e)return!1;l=n*p+E*S+i*l;return!((l*=g)<0)},jt.intersectsRayAndTriangleRP=function(e,t,n,i,r){return jt.intersectsRayAndTriangleRD(e,t,n,i,NaN)?(hn.scale(e.direction,NaN,jt._tempV30),hn.add(e.origin,jt._tempV30,r),!0):(r=hn.ZERO,!1)},jt.intersectsRayAndPoint=function(e,t){hn.subtract(e.origin,t,jt._tempV30);t=hn.dot(jt._tempV30,e.direction),e=hn.dot(jt._tempV30,jt._tempV30)-qt.zeroTolerance;return!(0<e&&0<t)&&!(t*t-e<0)},jt.intersectsRayAndRay=function(e,t,n){var i=e.origin,r=i.elements,a=r[0],o=r[1],s=r[2],l=e.direction,h=l.elements,_=h[0],u=h[1],d=h[2],c=t.origin,f=c.elements,m=f[0],p=f[1],E=f[2],v=t.direction,r=v.elements,e=r[0],h=r[1],f=r[2];hn.cross(l,v,jt._tempV30);t=jt._tempV30.elements,r=hn.scalarLengthSquared(jt._tempV30);if(qt.isZero(r)&&qt.nearEqual(m,a)&&qt.nearEqual(p,o)&&qt.nearEqual(E,s))return hn.ZERO.cloneTo(n),!0;m-=a,a=p-o,p=E-s,o=e,E=h,s=f,e=t[0],h=t[1],f=t[2],t=m*E*f+a*s*e+p*o*h-m*s*h-a*o*f-p*E*e,e=(m*(E=u)*f+a*(s=d)*e+p*(o=_)*h-m*s*h-a*o*f-p*E*e)/r;hn.scale(l,t/r,jt._tempV30),hn.scale(v,e,jt._tempV31),hn.add(i,jt._tempV30,jt._tempV32),hn.add(c,jt._tempV31,jt._tempV33);i=jt._tempV32.elements,c=jt._tempV33.elements;return qt.nearEqual(c[0],i[0])&&qt.nearEqual(c[1],i[1])&&qt.nearEqual(c[2],i[2])?(jt._tempV32.cloneTo(n),!0):(hn.ZERO.cloneTo(n),!1)},jt.intersectsPlaneAndTriangle=function(e,t,n,i){t=jt.intersectsPlaneAndPoint(e,t),n=jt.intersectsPlaneAndPoint(e,n),i=jt.intersectsPlaneAndPoint(e,i);return t==tn.PlaneIntersectionType_Front&&n==tn.PlaneIntersectionType_Front&&i==tn.PlaneIntersectionType_Front?tn.PlaneIntersectionType_Front:t==tn.PlaneIntersectionType_Back&&n==tn.PlaneIntersectionType_Back&&i==tn.PlaneIntersectionType_Back?tn.PlaneIntersectionType_Back:tn.PlaneIntersectionType_Intersecting},jt.intersectsRayAndPlaneRD=function(e,t,n){var i=t.normal,r=hn.dot(i,e.direction);if(qt.isZero(r))return!1;e=hn.dot(i,e.origin);return!((-t.distance-e)/r<0)},jt.intersectsRayAndPlaneRP=function(e,t,n){return jt.intersectsRayAndPlaneRD(e,t,NaN)?(hn.scale(e.direction,NaN,jt._tempV30),hn.add(e.origin,jt._tempV30,jt._tempV31),!0):(hn.ZERO,!1)},jt.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],d=_[1],c=_[2],n=t.max.elements,e=n[0],o=n[1],_=n[2],t=0,n=qt.MaxValue;if(qt.isZero(s)){if(i<u||e<i)return-1}else{s=1/s,u=(u-i)*s,i=(e-i)*s;if(i<u&&(s=u,u=i,i=s),t=Math.max(u,t),(n=Math.min(i,n))<t)return-1}if(qt.isZero(l)){if(r<d||o<r)return-1}else{l=1/l,d=(d-r)*l,r=(o-r)*l;if(r<d&&(l=d,d=r,r=l),t=Math.max(d,t),(n=Math.min(r,n))<t)return-1}if(qt.isZero(h)){if(a<c||_<a)return-1}else{h=1/h,c=(c-a)*h,a=(_-a)*h;if(a<c&&(h=c,c=a,a=h),t=Math.max(c,t),(n=Math.min(a,n))<t)return-1}return t},jt.intersectsRayAndBoxRP=function(e,t,n){t=jt.intersectsRayAndBoxRD(e,t);return-1===t?hn.ZERO.cloneTo(n):(hn.scale(e.direction,t,jt._tempV30),hn.add(e.origin,jt._tempV30,jt._tempV31),jt._tempV31.cloneTo(n)),t},jt.intersectsRayAndSphereRD=function(e,t){var n=t.radius;hn.subtract(e.origin,t.center,jt._tempV30);e=hn.dot(jt._tempV30,e.direction),n=hn.dot(jt._tempV30,jt._tempV30)-n*n;if(0<n&&0<e)return-1;n=e*e-n;if(n<0)return-1;n=-e-Math.sqrt(n);return n=n<0?0:n},jt.intersectsRayAndSphereRP=function(e,t,n){t=jt.intersectsRayAndSphereRD(e,t);return-1===t?hn.ZERO.cloneTo(n):(hn.scale(e.direction,t,jt._tempV30),hn.add(e.origin,jt._tempV30,jt._tempV31),jt._tempV31.cloneTo(n)),t},jt.intersectsSphereAndTriangle=function(e,t,n,i){var r=e.center,e=e.radius;return jt.closestPointPointTriangle(r,t,n,i,jt._tempV30),hn.subtract(jt._tempV30,r,jt._tempV31),hn.dot(jt._tempV31,jt._tempV31)<=e*e},jt.intersectsPlaneAndPoint=function(e,t){e=hn.dot(e.normal,t)+e.distance;return 0<e?tn.PlaneIntersectionType_Front:e<0?tn.PlaneIntersectionType_Back:tn.PlaneIntersectionType_Intersecting},jt.intersectsPlaneAndPlane=function(e,t){hn.cross(e.normal,t.normal,jt._tempV30);t=hn.dot(jt._tempV30,jt._tempV30);return!qt.isZero(t)},jt.intersectsPlaneAndPlaneRL=function(e,t,n){var i=e.normal,r=t.normal;hn.cross(i,r,jt._tempV34);var a=hn.dot(jt._tempV34,jt._tempV34);return!qt.isZero(a)&&(hn.scale(r,e.distance,jt._tempV30),hn.scale(i,t.distance,jt._tempV31),hn.subtract(jt._tempV30,jt._tempV31,jt._tempV32),hn.cross(jt._tempV32,jt._tempV34,jt._tempV33),hn.normalize(jt._tempV34,jt._tempV34),new on(jt._tempV33,jt._tempV34),!0)},jt.intersectsPlaneAndBox=function(e,t){var n=e.distance,i=e.normal,r=i.elements,a=r[0],o=r[1],s=r[2],l=t.min.elements,h=l[0],_=l[1],e=l[2],r=t.max.elements,l=r[0],t=r[1],r=r[2];jt._tempV30.elements[0]=0<a?h:l,jt._tempV30.elements[1]=0<o?_:t,jt._tempV30.elements[2]=0<s?e:r,jt._tempV31.elements[0]=0<a?l:h,jt._tempV31.elements[1]=0<o?t:_,jt._tempV31.elements[2]=0<s?r:e;e=hn.dot(i,jt._tempV30);return 0<e+n?tn.PlaneIntersectionType_Front:(e=hn.dot(i,jt._tempV31))+n<0?tn.PlaneIntersectionType_Back:tn.PlaneIntersectionType_Intersecting},jt.intersectsPlaneAndSphere=function(e,t){var n=t.radius,e=hn.dot(e.normal,t.center)+e.distance;return n<e?tn.PlaneIntersectionType_Front:e<-n?tn.PlaneIntersectionType_Back:tn.PlaneIntersectionType_Intersecting},jt.intersectsBoxAndBox=function(e,t){var n=e.min.elements,i=e.max.elements,e=t.min.elements,t=t.max.elements;return!(n[0]>t[0]||e[0]>i[0])&&(!(n[1]>t[1]||e[1]>i[1])&&!(n[2]>t[2]||e[2]>i[2]))},jt.intersectsBoxAndSphere=function(e,t){var n=t.center,t=t.radius;return hn.Clamp(n,e.min,e.max,jt._tempV30),hn.distanceSquared(n,jt._tempV30)<=t*t},jt.intersectsSphereAndSphere=function(e,t){var n=e.radius+t.radius;return hn.distanceSquared(e.center,t.center)<=n*n},jt.boxContainsPoint=function(e,t){var n=e.min.elements,e=e.max.elements,t=t.elements;return n[0]<=t[0]&&e[0]>=t[0]&&n[1]<=t[1]&&e[1]>=t[1]&&n[2]<=t[2]&&e[2]>=t[2]?1:0},jt.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],n=_[1],e=_[2],o=t.max.elements,_=o[0],t=o[1],o=o[2];return s<u||_<i||l<n||t<r||h<e||o<a?0:i<=u&&_<=_&&r<=n&&t<=l&&a<=e&&o<=h?1:2},jt.boxContainsSphere=function(e,t){var n=e.min,i=n.elements,r=i[0],a=i[1],o=i[2],s=e.max,l=s.elements,h=l[0],_=l[1],u=l[2],d=t.center,i=d.elements,e=i[0],l=i[1],i=i[2],t=t.radius;return hn.Clamp(d,n,s,jt._tempV30),t*t<hn.distanceSquared(d,jt._tempV30)?0:r+t<=e&&e<=h-t&&t<h-r&&a+t<=l&&l<=_-t&&t<_-a&&o+t<=i&&i<=u-t&&t<u-o?1:2},jt.sphereContainsPoint=function(e,t){return hn.distanceSquared(t,e.center)<=e.radius*e.radius?1:0},jt.sphereContainsTriangle=function(e,t,n,i){var r=jt.sphereContainsPoint(e,t),a=jt.sphereContainsPoint(e,n),o=jt.sphereContainsPoint(e,i);return 1==r&&1==a&&1==o?1:jt.intersectsSphereAndTriangle(e,t,n,i)?2:0},jt.sphereContainsBox=function(e,t){var n=e.center.elements,i=(n[0],n[1],n[2],e.radius),r=t.min.elements,a=(r[0],r[1],r[2],t.max.elements),n=(a[0],a[1]),r=a[2],a=jt._tempV30.elements;a[0],a[1],a[2];if(!jt.intersectsBoxAndSphere(t,e))return 0;i*=i;return hn.scalarLengthSquared(jt._tempV30)>i||hn.scalarLengthSquared(jt._tempV30)>i?2:hn.scalarLengthSquared(jt._tempV30)>i?2:hn.scalarLengthSquared(jt._tempV30)>i?2:hn.scalarLengthSquared(jt._tempV30)>i?2:hn.scalarLengthSquared(jt._tempV30)>i?2:hn.scalarLengthSquared(jt._tempV30)>i?2:hn.scalarLengthSquared(jt._tempV30)>i?2:1},jt.sphereContainsSphere=function(e,t){var n=e.radius,i=t.radius,t=hn.distance(e.center,t.center);return n+i<t?0:n-i<t?2:1},jt.closestPointPointTriangle=function(e,t,n,i,r){hn.subtract(n,t,jt._tempV30),hn.subtract(i,t,jt._tempV31),hn.subtract(e,t,jt._tempV32),hn.subtract(e,n,jt._tempV33),hn.subtract(e,i,jt._tempV34);var a=hn.dot(jt._tempV30,jt._tempV32),o=hn.dot(jt._tempV31,jt._tempV32),s=hn.dot(jt._tempV30,jt._tempV33),l=hn.dot(jt._tempV31,jt._tempV33),h=hn.dot(jt._tempV30,jt._tempV34),_=hn.dot(jt._tempV31,jt._tempV34);if(a<=0&&o<=0)t.cloneTo(r);else if(0<=s&&l<=s)n.cloneTo(r);else{e=a*l-s*o;if(e<=0&&0<=a&&s<=0)return hn.scale(jt._tempV30,a/(a-s),r),void hn.add(t,r,r);if(0<=_&&h<=_)i.cloneTo(r);else{a=h*o-a*_;if(a<=0&&0<=o&&_<=0)return hn.scale(jt._tempV31,o/(o-_),r),void hn.add(t,r,r);o=s*_-h*l;if(o<=0&&0<=l-s&&0<=h-_){_=(l-s)/(l-s+(h-_));return hn.subtract(i,n,r),hn.scale(r,_,r),void hn.add(n,r,r)}o=1/(o+a+e),e=e*o;hn.scale(jt._tempV30,a*o,jt._tempV35),hn.scale(jt._tempV31,e,jt._tempV36),hn.add(jt._tempV35,jt._tempV36,r),hn.add(t,r,r)}}},jt.closestPointPlanePoint=function(e,t,n){var i=e.normal,e=hn.dot(i,t)-e.distance;hn.scale(i,e,jt._tempV30),hn.subtract(t,jt._tempV30,n)},jt.closestPointBoxPoint=function(e,t,n){hn.max(t,e.min,jt._tempV30),hn.min(jt._tempV30,e.max,n)},jt.closestPointSpherePoint=function(e,t,n){var i=e.center;hn.subtract(t,i,n),hn.normalize(n,n),hn.scale(n,e.radius,n),hn.add(n,i,n)},jt.closestPointSphereSphere=function(e,t,n){var i=e.center;hn.subtract(t.center,i,n),hn.normalize(n,n),hn.scale(n,e.radius,n),hn.add(n,i,n)},l(jt,["_tempV30",function(){return this._tempV30=new hn},"_tempV31",function(){return this._tempV31=new hn},"_tempV32",function(){return this._tempV32=new hn},"_tempV33",function(){return this._tempV33=new hn},"_tempV34",function(){return this._tempV34=new hn},"_tempV35",function(){return this._tempV35=new hn},"_tempV36",function(){return this._tempV36=new hn}]),jt);function jt(){}p(Kt,"laya.d3.math.ContainmentType"),Kt.Disjoint=0,Kt.Contains=1,Kt.Intersects=2;function Kt(){}var qt=(p(Qt,"laya.d3.math.MathUtils3D"),Qt.isZero=function(e){return Math.abs(e)<Qt.zeroTolerance},Qt.nearEqual=function(e,t){return!!Qt.isZero(e-t)},Qt.fastInvSqrt=function(e){return Qt.isZero(e)?e:1/Math.sqrt(e)},l(Qt,["zeroTolerance",function(){return this.zeroTolerance=1e-6},"MaxValue",function(){return this.MaxValue=340282347e30},"MinValue",function(){return this.MinValue=-340282347e30}]),Qt);function Qt(){}var $t=function(){function r(){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}p(r,"laya.d3.math.Matrix3x3");var e=r.prototype;return S.imps(e,{"laya.d3.core.IClone":!0}),e.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],e=e[8];return t*(e*a-o*l)+n*(-e*r+o*s)+i*(l*r-a*s)},e.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],t=i[7],e=i[8],i=r[0],r=r[1];n[0]=a,n[1]=o,n[2]=s,n[3]=l,n[4]=h,n[5]=_,n[6]=i*a+r*l+u,n[7]=i*o+r*h+t,n[8]=i*s+r*_+e},e.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],t=i[8],i=Math.sin(e),e=Math.cos(e);n[0]=e*r+i*s,n[1]=e*a+i*l,n[2]=e*o+i*h,n[3]=e*s-i*r,n[4]=e*l-i*a,n[5]=e*h-i*o,n[6]=_,n[7]=u,n[8]=t},e.scale=function(e,t){var n=t.elements,i=this.elements,t=e.elements,e=t[0],t=t[1];n[0]=e*i[0],n[1]=e*i[1],n[2]=e*i[2],n[3]=t*i[3],n[4]=t*i[4],n[5]=t*i[5],n[6]=i[6],n[7]=i[7],n[8]=i[8]},e.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],d=u*s-l*_,c=-u*o+l*h,f=_*o-s*h,n=i*d+r*c+a*f;n||(e=null),t[0]=d*(n=1/n),t[1]=(-u*r+a*_)*n,t[2]=(l*r-a*s)*n,t[3]=c*n,t[4]=(u*i-a*h)*n,t[5]=(-l*i+a*o)*n,t[6]=f*n,t[7]=(-_*i+r*h)*n,t[8]=(s*i-r*o)*n},e.transpose=function(e){var t,n,i=e.elements,r=this.elements;e===this?(t=r[1],n=r[2],e=r[5],i[1]=r[3],i[2]=r[6],i[3]=t,i[5]=r[7],i[6]=n,i[7]=e):(i[0]=r[0],i[1]=r[3],i[2]=r[6],i[3]=r[1],i[4]=r[4],i[5]=r[7],i[6]=r[2],i[7]=r[5],i[8]=r[8])},e.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},e.cloneTo=function(e){var t,n=this.elements,i=e.elements;if(n!==i)for(t=0;t<9;++t)i[t]=n[t]},e.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},r.createFromTranslation=function(e,t){t.elements;e=e.elements;t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=e[0],t[7]=e[1],t[8]=1},r.createFromRotation=function(e,t){var n=t.elements,t=Math.sin(e),e=Math.cos(e);n[0]=e,n[1]=t,n[2]=0,n[3]=-t,n[4]=e,n[5]=0,n[6]=0,n[7]=0,n[8]=1},r.createFromScaling=function(e,t){t=t.elements,e=e.elements;t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=e[1],t[5]=0,t[6]=0,t[7]=0,t[8]=1},r.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]},r.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],d=r[6],c=r[7],f=r[8],m=a[0],p=a[1],E=a[2],v=a[3],n=a[4],e=a[5],t=a[6],r=a[7],a=a[8];i[0]=m*o+p*h+E*d,i[1]=m*s+p*_+E*c,i[2]=m*l+p*u+E*f,i[3]=v*o+n*h+e*d,i[4]=v*s+n*_+e*c,i[5]=v*l+n*u+e*f,i[6]=t*o+r*h+a*d,i[7]=t*s+r*_+a*c,i[8]=t*l+r*u+a*f},r.lookAt=function(e,t,n,i){hn.subtract(e,t,r._tempV30),hn.normalize(r._tempV30,r._tempV30),hn.cross(n,r._tempV30,r._tempV31),hn.normalize(r._tempV31,r._tempV31),hn.cross(r._tempV30,r._tempV31,r._tempV32);e=r._tempV30.elements,t=r._tempV31.elements,n=r._tempV32.elements,i=i.elements;i[0]=t[0],i[3]=t[1],i[6]=t[2],i[1]=n[0],i[4]=n[1],i[7]=n[2],i[2]=e[0],i[5]=e[1],i[8]=e[2]},r.DEFAULT=new r,l(r,["_tempV30",function(){return this._tempV30=new hn},"_tempV31",function(){return this._tempV31=new hn},"_tempV32",function(){return this._tempV32=new hn}]),r}(),Jt=function(){function E(e,t,n,i,r,a,o,s,l,h,_,u,d,c,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===d&&(d=0),void 0===c&&(c=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]=d,p[13]=c,p[14]=f,p[15]=m}p(E,"laya.d3.math.Matrix4x4");var e=E.prototype;return S.imps(e,{"laya.d3.core.IClone":!0}),e.getElementByRowColumn=function(e,t){if(e<0||3<e)throw new Error("row","Rows and columns for matrices run from 0 to 3, inclusive.");if(t<0||3<t)throw new Error("column","Rows and columns for matrices run from 0 to 3, inclusive.");return this.elements[4*e+t]},e.setElementByRowColumn=function(e,t,n){if(e<0||3<e)throw new Error("row","Rows and columns for matrices run from 0 to 3, inclusive.");if(t<0||3<t)throw new Error("column","Rows and columns for matrices run from 0 to 3, inclusive.");this.elements[4*e+t]=n},e.equalsOtherMatrix=function(e){var t=this.elements,e=e.elements;return qt.nearEqual(t[0],e[0])&&qt.nearEqual(t[1],e[1])&&qt.nearEqual(t[2],e[2])&&qt.nearEqual(t[3],e[3])&&qt.nearEqual(t[4],e[4])&&qt.nearEqual(t[5],e[5])&&qt.nearEqual(t[6],e[6])&&qt.nearEqual(t[7],e[7])&&qt.nearEqual(t[8],e[8])&&qt.nearEqual(t[9],e[9])&&qt.nearEqual(t[10],e[10])&&qt.nearEqual(t[11],e[11])&&qt.nearEqual(t[12],e[12])&&qt.nearEqual(t[13],e[13])&&qt.nearEqual(t[14],e[14])&&qt.nearEqual(t[15],e[15])},e.decomposeTransRotScale=function(e,t,n){var i=E._tempMatrix4x4;return this.decomposeTransRotMatScale(e,i,n)?(rn.createFromMatrix4x4(i,t),!0):(t.identity(),!1)},e.decomposeTransRotMatScale=function(e,t,n){var i=this.elements,r=e.elements,a=t.elements,o=n.elements;r[0]=i[12],r[1]=i[13],r[2]=i[14];var s=i[0],l=i[1],h=i[2],_=i[4],u=i[5],d=i[6],c=i[8],f=i[9],m=i[10],p=o[0]=Math.sqrt(s*s+l*l+h*h),e=o[1]=Math.sqrt(_*_+u*u+d*d),t=o[2]=Math.sqrt(c*c+f*f+m*m);if(qt.isZero(p)||qt.isZero(e)||qt.isZero(t))return a[1]=a[2]=a[3]=a[4]=a[6]=a[7]=a[8]=a[9]=a[11]=a[12]=a[13]=a[14]=0,!(a[0]=a[5]=a[10]=a[15]=1);n=E._tempVector0,r=n.elements;r[0]=c/t,r[1]=f/t,r[2]=m/t;i=E._tempVector1,r=i.elements;r[0]=s/p,r[1]=l/p,r[2]=h/p;r=E._tempVector2;hn.cross(n,i,r);i=E._tempVector1;return hn.cross(r,n,i),a[3]=a[7]=a[11]=a[12]=a[13]=a[14]=0,a[15]=1,a[0]=i.x,a[1]=i.y,a[2]=i.z,a[4]=r.x,a[5]=r.y,a[6]=r.z,a[8]=n.x,a[9]=n.y,a[10]=n.z,a[0]*s+a[1]*l+a[2]*h<0&&(o[0]=-p),a[4]*_+a[5]*u+a[6]*d<0&&(o[1]=-e),a[8]*c+a[9]*f+a[10]*m<0&&(o[2]=-t),!0},e.decomposeYawPitchRoll=function(e){var t=e.elements,e=Math.asin(-this.elements[9]);t[1]=e,Math.cos(e)>qt.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)},e.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&&(e[0]=t*(r=1/r),e[1]=n*r,e[2]=i*r)},e.transpose=function(){var e=this.elements,t=e[1];return 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},e.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],d=t[9],c=t[10],f=t[11],m=t[12],p=t[13],E=t[14],v=t[15],g=i*l-r*s,T=i*h-a*s,S=i*_-o*s,D=r*h-a*l,x=r*_-o*l,M=a*_-o*h,R=u*p-d*m,I=u*E-c*m,A=u*v-f*m,C=d*E-c*p,y=d*v-f*p,e=c*v-f*E,t=g*e-T*y+S*C+D*A-x*I+M*R;0!==Math.abs(t)&&(n[0]=(l*e-h*y+_*C)*(t=1/t),n[1]=(a*y-r*e-o*C)*t,n[2]=(p*M-E*x+v*D)*t,n[3]=(c*x-d*M-f*D)*t,n[4]=(h*A-s*e-_*I)*t,n[5]=(i*e-a*A+o*I)*t,n[6]=(E*S-m*M-v*T)*t,n[7]=(u*M-c*S+f*T)*t,n[8]=(s*y-l*A+_*R)*t,n[9]=(r*A-i*y-o*R)*t,n[10]=(m*x-p*S+v*g)*t,n[11]=(d*S-u*x-f*g)*t,n[12]=(l*I-s*C-h*R)*t,n[13]=(i*C-r*I+a*R)*t,n[14]=(p*T-m*D-E*g)*t,n[15]=(u*D-d*T+c*g)*t)},e.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},e.cloneTo=function(e){var t,n=this.elements,i=e.elements;if(n!==i)for(t=0;t<16;++t)i[t]=n[t]},e.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},e.getTranslationVector=function(e){var t=this.elements,e=e.elements;e[0]=t[12],e[1]=t[13],e[2]=t[14]},e.setTranslationVector=function(e){var t=this.elements,e=e.elements;t[12]=e[0],t[13]=e[1],t[14]=e[2]},e.getForward=function(e){var t=this.elements,e=e.elements;e[0]=-t[8],e[1]=-t[9],e[2]=-t[10]},e.setForward=function(e){var t=this.elements,e=e.elements;t[8]=-e[0],t[9]=-e[1],t[10]=-e[2]},E.createRotationX=function(e,t){var n=t.elements,t=Math.sin(e),e=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]=e,n[6]=t,n[9]=-t},E.createRotationY=function(e,t){var n=t.elements,t=Math.sin(e),e=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]=e,n[2]=-t,n[8]=t},E.createRotationZ=function(e,t){var n=t.elements,t=Math.sin(e),e=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]=e,n[1]=t,n[4]=-t},E.createRotationYawPitchRoll=function(e,t,n,i){rn.createFromYawPitchRoll(e,t,n,E._tempQuaternion),E.createRotationQuaternion(E._tempQuaternion,i)},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,e=r*a,i=r*o,t=a*o,n=n.elements;n[3]=n[7]=n[11]=n[12]=n[13]=n[14]=0,n[15]=1,n[0]=h+s*(1-h),n[1]=e-s*e+l*o,n[2]=i-s*i-l*a,n[4]=e-s*e-l*o,n[5]=_+s*(1-_),n[6]=t-s*t+l*r,n[8]=i-s*i+l*a,n[9]=t-s*t-l*r,n[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,e=o*s,t=o*r,n=a*s,o=a*o,s=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+e),i[2]=2*(t-n),i[4]=2*(u-e),i[5]=1-2*(_+l),i[6]=2*(o+s),i[8]=2*(t+n),i[9]=2*(o-s),i[10]=1-2*(h+l)},E.createTranslate=function(e,t){e=e.elements,t=t.elements;t[4]=t[8]=t[1]=t[9]=t[2]=t[6]=t[3]=t[7]=t[11]=0,t[0]=t[5]=t[10]=t[15]=1,t[12]=e[0],t[13]=e[1],t[14]=e[2]},E.createScaling=function(e,t){e=e.elements,t=t.elements;t[0]=e[0],t[5]=e[1],t[10]=e[2],t[1]=t[4]=t[8]=t[12]=t[9]=t[13]=t[2]=t[6]=t[14]=t[3]=t[7]=t[11]=0,t[15]=1},E.multiply=function(e,t,n){var i,r,a,o,s,l=n.elements,h=e.elements,_=t.elements;if(l===_)for(_=new Float32Array(16),i=0;i<16;++i)_[i]=l[i];for(i=0;i<4;i++)r=h[i],a=h[i+4],o=h[i+8],s=h[i+12],l[i]=r*_[0]+a*_[1]+o*_[2]+s*_[3],l[i+4]=r*_[4]+a*_[5]+o*_[6]+s*_[7],l[i+8]=r*_[8]+a*_[9]+o*_[10]+s*_[11],l[i+12]=r*_[12]+a*_[13]+o*_[14]+s*_[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,t=r*l,e=a*l,i=a*h,r=o*l,a=o*h,o=o*_,l=s*l,h=s*h,_=s*_;n[0]=1-i-o,n[1]=e+_,n[2]=r-h,n[3]=0,n[4]=e-_,n[5]=1-t-o,n[6]=a+l,n[7]=0,n[8]=r+h,n[9]=a-l,n[10]=1-t-i,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],d=l+l,c=h+h,e=_+_,t=l*d,n=l*c,i=l*e,a=h*c,l=h*e,h=_*e,_=u*d,d=u*c,c=u*e,u=o[0],e=o[1],o=o[2];s[0]=(1-(a+h))*u,s[1]=(n+c)*u,s[2]=(i-d)*u,s[3]=0,s[4]=(n-c)*e,s[5]=(1-(t+h))*e,s[6]=(l+_)*e,s[7]=0,s[8]=(i+d)*o,s[9]=(l-_)*o,s[10]=(1-(t+a))*o,s[11]=0,s[12]=r[0],s[13]=r[1],s[14]=r[2],s[15]=1},E.createLookAt=function(e,t,n,i){var r=i.elements,a=E._tempVector0,o=E._tempVector1,s=E._tempVector2;hn.subtract(e,t,s),hn.normalize(s,s),hn.cross(n,s,a),hn.normalize(a,a),hn.cross(s,a,o),i.identity(),r[0]=a.x,r[4]=a.y,r[8]=a.z,r[1]=o.x,r[5]=o.y,r[9]=o.z,r[2]=s.x,r[6]=s.y,r[10]=s.z,r[12]=-hn.dot(a,e),r[13]=-hn.dot(o,e),r[14]=-hn.dot(s,e)},E.createPerspective=function(e,t,n,i,r){var a=r.elements,r=1/Math.tan(e/2),e=1/(n-i);a[0]=r/t,a[5]=r,a[10]=(i+n)*e,a[11]=-1,a[14]=2*i*n*e,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),o=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*o,s[12]=(e+t)*l,s[13]=(i+n)*h,s[14]=(a+r)*o},E.translation=function(e,t){e=e.elements,t=t.elements;t[0]=t[5]=t[10]=t[15]=1,t[12]=e[0],t[13]=e[1],t[14]=e[2]},l(E,["_tempMatrix4x4",function(){return this._tempMatrix4x4=new E},"_tempVector0",function(){return this._tempVector0=new hn},"_tempVector1",function(){return this._tempVector1=new hn},"_tempVector2",function(){return this._tempVector2=new hn},"_tempQuaternion",function(){return this._tempQuaternion=new rn},"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}(),en=function(){function f(e,t){this.extents=null,this.transformation=null,this.extents=e,this.transformation=t}p(f,"laya.d3.math.OrientedBoundBox");var e=f.prototype;return e.getCorners=function(e){var t=f._tempV30.elements,n=f._tempV31.elements,i=f._tempV32.elements,r=this.extents.elements;t[0]=r[0],t[1]=t[2]=0,n[1]=r[1],n[0]=n[2]=0,i[2]=r[2],i[0]=i[1]=0,hn.TransformNormal(f._tempV30,this.transformation,f._tempV30),hn.TransformNormal(f._tempV31,this.transformation,f._tempV31),hn.TransformNormal(f._tempV32,this.transformation,f._tempV32);i=f._tempV33;this.transformation.getTranslationVector(i),e.length=8,hn.add(i,f._tempV30,f._tempV34),hn.add(f._tempV34,f._tempV31,f._tempV34),hn.add(f._tempV34,f._tempV32,e[0]),hn.add(i,f._tempV30,f._tempV34),hn.add(f._tempV34,f._tempV31,f._tempV34),hn.subtract(f._tempV34,f._tempV32,e[1]),hn.subtract(i,f._tempV30,f._tempV34),hn.add(f._tempV34,f._tempV31,f._tempV34),hn.subtract(f._tempV34,f._tempV32,e[2]),hn.subtract(i,f._tempV30,f._tempV34),hn.add(f._tempV34,f._tempV31,f._tempV34),hn.add(f._tempV34,f._tempV32,e[3]),hn.add(i,f._tempV30,f._tempV34),hn.subtract(f._tempV34,f._tempV31,f._tempV34),hn.add(f._tempV34,f._tempV32,e[4]),hn.add(i,f._tempV30,f._tempV34),hn.subtract(f._tempV34,f._tempV31,f._tempV34),hn.subtract(f._tempV34,f._tempV32,e[5]),hn.subtract(i,f._tempV30,f._tempV34),hn.subtract(f._tempV34,f._tempV31,f._tempV34),hn.subtract(f._tempV34,f._tempV32,e[6]),hn.subtract(i,f._tempV30,f._tempV34),hn.subtract(f._tempV34,f._tempV31,f._tempV34),hn.add(f._tempV34,f._tempV32,e[7])},e.transform=function(e){Jt.multiply(this.transformation,e,this.transformation)},e.scale=function(e){hn.multiply(this.extents,e,this.extents)},e.translate=function(e){this.transformation.getTranslationVector(f._tempV30),hn.add(f._tempV30,e,f._tempV31),this.transformation.setTranslationVector(f._tempV31)},e.Size=function(e){hn.scale(this.extents,2,e)},e.getSize=function(e){var t=this.extents.elements;f._tempV30.x=t[0],f._tempV31.y=t[1],f._tempV32.z=t[2],hn.TransformNormal(f._tempV30,this.transformation,f._tempV30),hn.TransformNormal(f._tempV31,this.transformation,f._tempV31),hn.TransformNormal(f._tempV31,this.transformation,f._tempV32);e=e.elements;e[0]=hn.scalarLength(f._tempV30),e[1]=hn.scalarLength(f._tempV31),e[2]=hn.scalarLength(f._tempV32)},e.getSizeSquared=function(e){var t=this.extents.elements;f._tempV30.x=t[0],f._tempV31.y=t[1],f._tempV32.z=t[2],hn.TransformNormal(f._tempV30,this.transformation,f._tempV30),hn.TransformNormal(f._tempV31,this.transformation,f._tempV31),hn.TransformNormal(f._tempV31,this.transformation,f._tempV32);e=e.elements;e[0]=hn.scalarLengthSquared(f._tempV30),e[1]=hn.scalarLengthSquared(f._tempV31),e[2]=hn.scalarLengthSquared(f._tempV32)},e.getCenter=function(e){this.transformation.getTranslationVector(e)},e.containsPoint=function(e){var t=this.extents.elements,n=t[0],i=t[1],r=t[2];this.transformation.invert(f._tempM0),hn.transformCoordinate(e,f._tempM0,f._tempV30);var a=f._tempV30.elements,t=Math.abs(a[0]),e=Math.abs(a[1]),a=Math.abs(a[2]);return qt.nearEqual(t,n)&&qt.nearEqual(e,i)&&qt.nearEqual(a,r)?2:t<n&&e<i&&a<r?1:0},e.containsPoints=function(e){var t=this.extents.elements,n=t[0],i=t[1],r=t[2];this.transformation.invert(f._tempM0);for(var a=!0,o=!1,s=0;s<e.length;s++){hn.transformCoordinate(e[s],f._tempM0,f._tempV30);var l=f._tempV30.elements,h=Math.abs(l[0]),_=Math.abs(l[1]),l=Math.abs(l[2]);qt.nearEqual(h,n)&&qt.nearEqual(_,i)&&qt.nearEqual(l,r)&&(o=!0),h<n&&_<i&&l<r?o=!0:a=!1}return a?1:o?2:0},e.containsSphere=function(e,t){void 0===t&&(t=!1);var n=this.extents.elements,i=n[0],r=n[1],a=n[2],o=e.radius;this.transformation.invert(f._tempM0),hn.transformCoordinate(e.center,f._tempM0,f._tempV30);var s=NaN,s=t?o:(hn.scale(hn.UnitX,o,f._tempV31),hn.TransformNormal(f._tempV31,f._tempM0,f._tempV31),hn.scalarLength(f._tempV31));if(hn.scale(this.extents,-1,f._tempV32),hn.Clamp(f._tempV30,f._tempV32,this.extents,f._tempV33),s*s<hn.distanceSquared(f._tempV30,f._tempV33))return 0;var l=f._tempV30.elements,h=l[0],n=l[1],e=l[2],t=f._tempV32.elements,o=t[0],l=t[1],t=t[2];return o+s<=h&&h<=i-s&&s<i-o&&l+s<=n&&n<=r-s&&s<r-l&&t+s<=e&&e<=a-s&&s<a-t?1:2},e.containsOrientedBoundBox=function(e){var t=0,n=0;e.getCorners(f._corners);var i=this.containsPoints(f._corners);if(0!=i)return i;var r=this.extents.elements;e.extents.cloneTo(f._tempV35);var a=f._tempV35.elements;f._getRows(this.transformation,f._rows1),f._getRows(e.transformation,f._rows2);for(var o,t=0;t<4;t++)for(n=0;n<4;n++)3==t||3==n?(f._tempM0.setElementByRowColumn(t,n,0),f._tempM1.setElementByRowColumn(t,n,0)):(o=hn.dot(f._rows1[t],f._rows2[n]),f._tempM0.setElementByRowColumn(t,n,o),f._tempM1.setElementByRowColumn(t,n,Math.abs(o)));e.getCenter(f._tempV34),this.getCenter(f._tempV36),hn.subtract(f._tempV34,f._tempV36,f._tempV30);var s=f._tempV31.elements;s[0]=hn.dot(f._tempV30,f._rows1[0]),s[1]=hn.dot(f._tempV30,f._rows1[1]),s[2]=hn.dot(f._tempV30,f._rows1[2]);var l=f._tempV32.elements,h=f._tempV33.elements;for(t=0;t<3;t++)if(l[0]=f._tempM1.getElementByRowColumn(t,0),l[1]=f._tempM1.getElementByRowColumn(t,1),l[2]=f._tempM1.getElementByRowColumn(t,2),r[t]+hn.dot(f._tempV35,f._tempV32)<Math.abs(s[t]))return 0;for(n=0;n<3;n++)if(l[0]=f._tempM1.getElementByRowColumn(0,n),l[1]=f._tempM1.getElementByRowColumn(1,n),l[2]=f._tempM1.getElementByRowColumn(2,n),h[0]=f._tempM0.getElementByRowColumn(0,n),h[1]=f._tempM0.getElementByRowColumn(1,n),h[2]=f._tempM0.getElementByRowColumn(2,n),hn.dot(this.extents,f._tempV32)+a[n]<Math.abs(hn.dot(f._tempV31,f._tempV33)))return 0;for(t=0;t<3;t++)for(n=0;n<3;n++){var _=(t+1)%3,u=(t+2)%3,d=(n+1)%3,c=(n+2)%3;if(r[_]*f._tempM1.getElementByRowColumn(u,n)+r[u]*f._tempM1.getElementByRowColumn(_,n)+(a[d]*f._tempM1.getElementByRowColumn(t,c)+a[c]*f._tempM1.getElementByRowColumn(t,d))<Math.abs(s[u]*f._tempM0.getElementByRowColumn(_,n)-s[_]*f._tempM0.getElementByRowColumn(u,n)))return 0}return 2},e.containsLine=function(e,t){f._corners[0]=e,f._corners[1]=t;var n=this.containsPoints(f._corners);if(0!=n)return n;var i=this.extents.elements,r=i[0],a=i[1],o=i[2];this.transformation.invert(f._tempM0),hn.transformCoordinate(e,f._tempM0,f._tempV30),hn.transformCoordinate(t,f._tempM0,f._tempV31),hn.add(f._tempV30,f._tempV31,f._tempV32),hn.scale(f._tempV32,.5,f._tempV32),hn.subtract(f._tempV30,f._tempV32,f._tempV33);var s=f._tempV33.elements,l=s[0],h=s[1],_=s[2],u=f._tempV34.elements,n=u[0]=Math.abs(s[0]),i=u[1]=Math.abs(s[1]),e=u[2]=Math.abs(s[2]),t=f._tempV32.elements,u=t[0],s=t[1],t=t[2];return Math.abs(u)>r+n||Math.abs(s)>a+i||Math.abs(t)>o+e||Math.abs(s*_-t*h)>a*e+o*i||Math.abs(u*_-t*l)>r*e+o*n||Math.abs(u*h-s*l)>r*i+a*n?0:2},e.containsBoundBox=function(e){var t=0,n=0,i=e.min,r=e.max;e.getCorners(f._corners);e=this.containsPoints(f._corners);if(0!=e)return e;hn.subtract(r,i,f._tempV30),hn.scale(f._tempV30,.5,f._tempV30),hn.add(i,f._tempV30,f._tempV30),hn.subtract(r,f._tempV30,f._tempV31);var a=this.extents.elements,o=f._tempV31.elements;f._getRows(this.transformation,f._rows1),this.transformation.invert(f._tempM0);for(t=0;t<3;t++)for(n=0;n<3;n++)f._tempM1.setElementByRowColumn(t,n,Math.abs(f._tempM0.getElementByRowColumn(t,n)));this.getCenter(f._tempV35),hn.subtract(f._tempV30,f._tempV35,f._tempV32);var s=f._tempV31.elements;s[0]=hn.dot(f._tempV32,f._rows1[0]),s[1]=hn.dot(f._tempV32,f._rows1[1]),s[2]=hn.dot(f._tempV32,f._rows1[2]);var l=f._tempV33.elements,h=f._tempV34.elements;for(t=0;t<3;t++)if(l[0]=f._tempM1.getElementByRowColumn(t,0),l[1]=f._tempM1.getElementByRowColumn(t,1),l[2]=f._tempM1.getElementByRowColumn(t,2),a[t]+hn.dot(f._tempV31,f._tempV33)<Math.abs(s[t]))return 0;for(n=0;n<3;n++)if(l[0]=f._tempM1.getElementByRowColumn(0,n),l[1]=f._tempM1.getElementByRowColumn(1,n),l[2]=f._tempM1.getElementByRowColumn(2,n),h[0]=f._tempM0.getElementByRowColumn(0,n),h[1]=f._tempM0.getElementByRowColumn(1,n),h[2]=f._tempM0.getElementByRowColumn(2,n),hn.dot(this.extents,f._tempV33)+o[n]<Math.abs(hn.dot(f._tempV31,f._tempV34)))return 0;for(t=0;t<3;t++)for(n=0;n<3;n++){var _=(t+1)%3,u=(t+2)%3,d=(n+1)%3,c=(n+2)%3;if(a[_]*f._tempM1.getElementByRowColumn(u,n)+a[u]*f._tempM1.getElementByRowColumn(_,n)+(o[d]*f._tempM1.getElementByRowColumn(t,c)+o[c]*f._tempM1.getElementByRowColumn(t,d))<Math.abs(s[u]*f._tempM0.getElementByRowColumn(_,n)-s[_]*f._tempM0.getElementByRowColumn(u,n)))return 0}return 2},e.intersectsRay=function(e,t){hn.scale(this.extents,-1,f._tempV30),this.transformation.invert(f._tempM0),hn.TransformNormal(e.direction,f._tempM0,f._ray.direction),hn.transformCoordinate(e.origin,f._tempM0,f._ray.origin),f._boxBound1.min=f._tempV30,f._boxBound1.max=this.extents;e=Zt.intersectsRayAndBoxRP(f._ray,f._boxBound1,t);return-1!==e&&hn.transformCoordinate(t,this.transformation,t),e},e._getLocalCorners=function(e){e.length=8;var t=this.extents.elements;f._tempV30.x=t[0],f._tempV31.y=t[1],f._tempV32.z=t[2],hn.add(f._tempV30,f._tempV31,f._tempV33),hn.add(f._tempV33,f._tempV32,e[0]),hn.add(f._tempV30,f._tempV31,f._tempV33),hn.subtract(f._tempV33,f._tempV32,e[1]),hn.subtract(f._tempV31,f._tempV30,f._tempV33),hn.subtract(f._tempV33,f._tempV30,e[2]),hn.subtract(f._tempV31,f._tempV30,f._tempV33),hn.add(f._tempV33,f._tempV32,e[3]),hn.subtract(f._tempV30,f._tempV31,f._tempV33),hn.add(f._tempV33,f._tempV32,e[4]),hn.subtract(f._tempV30,f._tempV31,f._tempV33),hn.subtract(f._tempV33,f._tempV32,e[5]),hn.scale(e[0],-1,e[6]),hn.subtract(f._tempV32,f._tempV30,f._tempV33),hn.subtract(f._tempV33,f._tempV31,e[7])},e.equals=function(e){return this.extents==e.extents&&this.transformation==e.transformation},e.cloneTo=function(e){this.extents.cloneTo(e.extents),this.transformation.cloneTo(e.transformation)},f.createByBoundBox=function(e,t){var n=e.min,e=e.max;hn.subtract(e,n,f._tempV30),hn.scale(f._tempV30,.5,f._tempV30),hn.add(n,f._tempV30,f._tempV31),hn.subtract(e,f._tempV31,f._tempV32),Jt.translation(f._tempV31,f._tempM0);n=f._tempV32.clone(),e=f._tempM0.clone();t.extents=n,t.transformation=e},f.createByMinAndMaxVertex=function(e,t){return hn.subtract(t,e,f._tempV30),hn.scale(f._tempV30,.5,f._tempV30),hn.add(e,f._tempV30,f._tempV31),hn.subtract(t,f._tempV31,f._tempV32),Jt.translation(f._tempV31,f._tempM0),new f(f._tempV32,f._tempM0)},f._getRows=function(e,t){t.length=3;var n=e.elements,e=t[0].elements;e[0]=n[0],e[1]=n[1],e[2]=n[2];e=t[1].elements;e[0]=n[4],e[1]=n[5],e[2]=n[6];t=t[2].elements;t[0]=n[8],t[1]=n[9],t[2]=n[10]},f.getObbtoObbMatrix4x4=function(e,t,n,i){var r=e.transformation,a=t.transformation;if(n){f._getRows(r,f._rows1),f._getRows(a,f._rows2);for(var o=0;o<3;o++)for(var s=0;s<3;s++)i.setElementByRowColumn(o,s,hn.dot(f._rows2[o],f._rows1[s]));t.getCenter(f._tempV30),e.getCenter(f._tempV31),hn.subtract(f._tempV30,f._tempV31,f._tempV32);e=i.elements;e[12]=hn.dot(f._tempV32,f._rows1[0]),e[13]=hn.dot(f._tempV32,f._rows1[1]),e[14]=hn.dot(f._tempV32,f._rows1[2]),e[15]=1}else r.invert(f._tempM0),Jt.multiply(a,f._tempM0,i)},f.merge=function(e,t,n){var i=e.extents,r=e.transformation;f.getObbtoObbMatrix4x4(e,t,n,f._tempM0),t._getLocalCorners(f._corners),hn.transformCoordinate(f._corners[0],f._tempM0,f._corners[0]),hn.transformCoordinate(f._corners[1],f._tempM0,f._corners[1]),hn.transformCoordinate(f._corners[2],f._tempM0,f._corners[2]),hn.transformCoordinate(f._corners[3],f._tempM0,f._corners[3]),hn.transformCoordinate(f._corners[4],f._tempM0,f._corners[4]),hn.transformCoordinate(f._corners[5],f._tempM0,f._corners[5]),hn.transformCoordinate(f._corners[6],f._tempM0,f._corners[6]),hn.transformCoordinate(f._corners[7],f._tempM0,f._corners[7]),hn.scale(i,-1,f._boxBound1.min),i.cloneTo(f._boxBound1.max),kt.createfromPoints(f._corners,f._boxBound2),kt.merge(f._boxBound2,f._boxBound1,f._boxBound3);n=f._boxBound3.min,t=f._boxBound3.max;hn.subtract(t,n,f._tempV30),hn.scale(f._tempV30,.5,f._tempV30),hn.add(n,f._tempV30,f._tempV32),hn.subtract(t,f._tempV32,i),hn.transformCoordinate(f._tempV32,r,f._tempV33)},l(f,["_tempV30",function(){return this._tempV30=new hn},"_tempV31",function(){return this._tempV31=new hn},"_tempV32",function(){return this._tempV32=new hn},"_tempV33",function(){return this._tempV33=new hn},"_tempV34",function(){return this._tempV34=new hn},"_tempV35",function(){return this._tempV35=new hn},"_tempV36",function(){return this._tempV36=new hn},"_tempM0",function(){return this._tempM0=new Jt},"_tempM1",function(){return this._tempM1=new Jt},"_corners",function(){return this._corners=[new hn,new hn,new hn,new hn,new hn,new hn,new hn,new hn]},"_rows1",function(){return this._rows1=[new hn,new hn,new hn]},"_rows2",function(){return this._rows2=[new hn,new hn,new hn]},"_ray",function(){return this._ray=new on(new hn,new hn)},"_boxBound1",function(){return this._boxBound1=new kt(new hn,new hn)},"_boxBound2",function(){return this._boxBound2=new kt(new hn,new hn)},"_boxBound3",function(){return this._boxBound3=new kt(new hn,new hn)}]),f}(),tn=(p(nn,"laya.d3.math.Plane"),nn.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},nn.createPlaneBy3P=function(e,t,n){var i=e.elements,r=t.elements,a=n.elements,o=r[0]-i[0],s=r[1]-i[1],e=r[2]-i[2],t=a[0]-i[0],n=a[1]-i[1],r=a[2]-i[2],a=s*r-e*n,r=e*t-o*r,s=o*n-s*t,t=1/Math.sqrt(a*a+r*r+s*s),a=a*t,r=r*t,s=s*t,t=nn._TEMPVec3.elements;t[0]=a,t[1]=r,t[2]=s;i=-(a*i[0]+r*i[1]+s*i[2]);return new nn(nn._TEMPVec3,i)},nn.PlaneIntersectionType_Back=0,nn.PlaneIntersectionType_Front=1,nn.PlaneIntersectionType_Intersecting=2,l(nn,["_TEMPVec3",function(){return this._TEMPVec3=new hn}]),nn);function nn(e,t){this.normal=null,this.distance=NaN,void 0===t&&(t=0),this.normal=e,this.distance=t}var rn=function(){function r(e,t,n,i){this.elements=new Float32Array(4),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=1),this.elements[0]=e=void 0===e?0:e,this.elements[1]=t,this.elements[2]=n,this.elements[3]=i}p(r,"laya.d3.math.Quaternion");var e=r.prototype;return S.imps(e,{"laya.d3.core.IClone":!0}),e.scaling=function(e,t){var n=t.elements,t=this.elements;n[0]=t[0]*e,n[1]=t[1]*e,n[2]=t[2]*e,n[3]=t[3]*e},e.normalize=function(e){var t=e.elements,n=this.elements,i=n[0],r=n[1],a=n[2],e=n[3],n=i*i+r*r+a*a+e*e;0<n&&(n=1/Math.sqrt(n),t[0]=i*n,t[1]=r*n,t[2]=a*n,t[3]=e*n)},e.length=function(){var e=this.elements,t=e[0],n=e[1],i=e[2],e=e[3];return Math.sqrt(t*t+n*n+i*i+e*e)},e.rotateX=function(e,t){var n=t.elements,i=this.elements;e*=.5;var r=i[0],a=i[1],o=i[2],t=i[3],i=Math.sin(e),e=Math.cos(e);n[0]=r*e+t*i,n[1]=a*e+o*i,n[2]=o*e-a*i,n[3]=t*e-r*i},e.rotateY=function(e,t){var n=t.elements,i=this.elements;e*=.5;var r=i[0],a=i[1],o=i[2],t=i[3],i=Math.sin(e),e=Math.cos(e);n[0]=r*e-o*i,n[1]=a*e+t*i,n[2]=o*e+r*i,n[3]=t*e-a*i},e.rotateZ=function(e,t){var n=t.elements,i=this.elements;e*=.5;var r=i[0],a=i[1],o=i[2],t=i[3],i=Math.sin(e),e=Math.cos(e);n[0]=r*e+a*i,n[1]=a*e-r*i,n[2]=o*e+t*i,n[3]=t*e-o*i},e.getYawPitchRoll=function(e){hn.transformQuat(hn.ForwardRH,this,r.TEMPVector31),hn.transformQuat(hn.Up,this,r.TEMPVector32);var t=r.TEMPVector32.elements;r.angleTo(hn.ZERO,r.TEMPVector31,r.TEMPVector33);var n=r.TEMPVector33.elements;n[0]==Math.PI/2?(n[1]=r.arcTanAngle(t[2],t[0]),n[2]=0):n[0]==-Math.PI/2?(n[1]=r.arcTanAngle(-t[2],-t[0]),n[2]=0):(Jt.createRotationY(-n[1],r.TEMPMatrix0),Jt.createRotationX(-n[0],r.TEMPMatrix1),hn.transformCoordinate(r.TEMPVector32,r.TEMPMatrix0,r.TEMPVector32),hn.transformCoordinate(r.TEMPVector32,r.TEMPMatrix1,r.TEMPVector32),n[2]=r.arcTanAngle(t[1],-t[0])),n[1]<=-Math.PI&&(n[1]=Math.PI),n[2]<=-Math.PI&&(n[2]=Math.PI),n[1]>=Math.PI&&n[2]>=Math.PI&&(n[1]=0,n[2]=0,n[0]=Math.PI-n[0]);e=e.elements;e[0]=n[1],e[1]=n[0],e[2]=n[2]},e.invert=function(e){var t=e.elements,n=this.elements,i=n[0],r=n[1],a=n[2],e=n[3],n=i*i+r*r+a*a+e*e,n=n?1/n:0;t[0]=-i*n,t[1]=-r*n,t[2]=-a*n,t[3]=e*n},e.identity=function(){var e=this.elements;e[0]=0,e[1]=0,e[2]=0,e[3]=1},e.fromArray=function(e,t){this.elements[0]=e[(t=void 0===t?0:t)+0],this.elements[1]=e[t+1],this.elements[2]=e[t+2],this.elements[3]=e[t+3]},e.cloneTo=function(e){var t,n=this.elements,i=e.elements;if(n!==i)for(t=0;t<4;++t)i[t]=n[t]},e.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},e.equals=function(e){var t=this.elements,e=e.elements;return qt.nearEqual(t[0],e[0])&&qt.nearEqual(t[1],e[1])&&qt.nearEqual(t[2],e[2])&&qt.nearEqual(t[3],e[3])},e.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},_(0,e,"x",function(){return this.elements[0]}),_(0,e,"y",function(){return this.elements[1]}),_(0,e,"z",function(){return this.elements[2]}),_(0,e,"w",function(){return this.elements[3]}),r.createFromYawPitchRoll=function(e,t,n,i){var r=.5*n,a=.5*t,o=.5*e,n=Math.sin(r),t=Math.cos(r),e=Math.sin(a),r=Math.cos(a),a=Math.sin(o),o=Math.cos(o),i=i.elements;i[0]=o*e*t+a*r*n,i[1]=a*r*t-o*e*n,i[2]=o*r*n-a*e*t,i[3]=o*r*t+a*e*n},r.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],e=r[2],t=r[3],n=l*_-o*e,i=o*u-s*_,r=o*_+s*u+l*e;a[0]=o*t+_*h+(s*e-l*u),a[1]=s*t+u*h+n,a[2]=l*t+e*h+i,a[3]=h*t-r},r.arcTanAngle=function(e,t){return 0==e?1==t?Math.PI/2:-Math.PI/2:0<e?Math.atan(t/e):e<0?0<t?Math.atan(t/e)+Math.PI:Math.atan(t/e)-Math.PI:0},r.angleTo=function(e,t,n){hn.subtract(t,e,r.TEMPVector30),hn.normalize(r.TEMPVector30,r.TEMPVector30),n.elements[0]=Math.asin(r.TEMPVector30.y),n.elements[1]=r.arcTanAngle(-r.TEMPVector30.z,-r.TEMPVector30.x)},r.createFromAxisAngle=function(e,t,n){var i=n.elements,n=e.elements;t*=.5;e=Math.sin(t);i[0]=e*n[0],i[1]=e*n[1],i[2]=e*n[2],i[3]=Math.cos(t)},r.createFromMatrix3x3=function(e,t){var n,i=t.elements,r=e.elements,a=r[0]+r[4]+r[8];0<a?(n=Math.sqrt(a+1),i[3]=.5*n,i[0]=(r[5]-r[7])*(n=.5/n),i[1]=(r[6]-r[2])*n,i[2]=(r[1]-r[3])*n):(r[4]>r[t=0]&&(t=1),e=((t=r[8]>r[3*t+t]?2:t)+1)%3,a=(t+2)%3,n=Math.sqrt(r[3*t+t]-r[3*e+e]-r[3*a+a]+1),i[t]=.5*n,i[3]=(r[3*e+a]-r[3*a+e])*(n=.5/n),i[e]=(r[3*e+t]+r[3*t+e])*n,i[a]=(r[3*a+t]+r[3*t+a])*n)},r.createFromMatrix4x4=function(e,t){var n,i,r=e.elements,e=t.elements,t=r[0]+r[5]+r[10];0<t?(n=Math.sqrt(t+1),e[3]=.5*n,e[0]=(r[6]-r[9])*(n=.5/n),e[1]=(r[8]-r[2])*n,e[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])),e[0]=.5*n,e[1]=(r[1]+r[4])*i,e[2]=(r[2]+r[8])*i,e[3]=(r[6]-r[9])*i):r[5]>r[10]?(n=Math.sqrt(1+r[5]-r[0]-r[10]),e[0]=(r[4]+r[1])*(i=.5/n),e[1]=.5*n,e[2]=(r[9]+r[6])*i,e[3]=(r[8]-r[2])*i):(n=Math.sqrt(1+r[10]-r[0]-r[5]),e[0]=(r[8]+r[2])*(i=.5/n),e[1]=(r[9]+r[6])*i,e[2]=.5*n,e[3]=(r[1]-r[4])*i)},r.slerp=function(e,t,n,i){var r,a=e.elements,o=t.elements,s=i.elements,l=a[0],h=a[1],_=a[2],u=a[3],d=o[0],e=o[1],t=o[2],i=o[3],a=l*d+h*e+_*t+u*i;return a<0&&(a=-a,d=-d,e=-e,t=-t,i=-i),n=1e-6<1-a?(o=Math.acos(a),a=Math.sin(o),r=Math.sin((1-n)*o)/a,Math.sin(n*o)/a):(r=1-n,n),s[0]=r*l+n*d,s[1]=r*h+n*e,s[2]=r*_+n*t,s[3]=r*u+n*i,s},r.lerp=function(e,t,n,i){var r=i.elements,a=e.elements,o=t.elements,i=a[0],e=a[1],t=a[2],a=a[3];r[0]=i+n*(o[0]-i),r[1]=e+n*(o[1]-e),r[2]=t+n*(o[2]-t),r[3]=a+n*(o[3]-a)},r.add=function(e,t,n){n=n.elements,e=e.elements,t=t.elements;n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n[3]=e[3]+t[3]},r.dot=function(e,t){e=e.elements,t=t.elements;return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},r.rotationLookAt=function(e,t,n){r.lookAt(hn.ZERO,e,t,n)},r.lookAt=function(e,t,n,i){$t.lookAt(e,t,n,r._tempMatrix3x3),r.rotationMatrix(r._tempMatrix3x3,i)},r.invert=function(e,t){var n=e.elements,t=t.elements,e=e.lengthSquared();qt.isZero(e)||(t[0]=-n[0]*(e=1/e),t[1]=-n[1]*e,t[2]=-n[2]*e,t[3]=n[3]*e)},r.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],d=t.elements,e=NaN,n=NaN,t=i+s+u;0<t?(e=Math.sqrt(t+1),d[3]=.5*e,d[0]=(l-_)*(e=.5/e),d[1]=(h-a)*e,d[2]=(r-o)*e):s<=i&&u<=i?(n=.5/(e=Math.sqrt(1+i-s-u)),d[0]=.5*e,d[1]=(r+o)*n,d[2]=(a+h)*n,d[3]=(l-_)*n):u<s?(e=Math.sqrt(1+s-i-u),d[0]=(o+r)*(n=.5/e),d[1]=.5*e,d[2]=(_+l)*n,d[3]=(h-a)*n):(e=Math.sqrt(1+u-i-s),d[0]=(h+a)*(n=.5/e),d[1]=(_+l)*n,d[2]=.5*e,d[3]=(r-o)*n)},r.DEFAULT=new r,l(r,["TEMPVector30",function(){return this.TEMPVector30=new hn},"TEMPVector31",function(){return this.TEMPVector31=new hn},"TEMPVector32",function(){return this.TEMPVector32=new hn},"TEMPVector33",function(){return this.TEMPVector33=new hn},"TEMPMatrix0",function(){return this.TEMPMatrix0=new Jt},"TEMPMatrix1",function(){return this.TEMPMatrix1=new Jt},"_tempMatrix3x3",function(){return this._tempMatrix3x3=new $t},"NAN",function(){return this.NAN=new r(NaN,NaN,NaN,NaN)}]),r}(),an=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}p(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},_(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}(),on=(function(){function n(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]}p(n,"laya.d3.math.RandX");var e=n.prototype;e.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,s=0,r=0;s=(e^=s=e<<23|(-512&t)>>>9)^(this._state0U=n),r=(t^=r=t<<23)^(this._state0L=i);s^=e>>>18,r^=t>>>18|(262143&e)<<14;return r^=i>>>5|(31&n)<<27,this._state1U=s^=n>>>5,this._state1L=r,[a,o]},e.random=function(){var e=this.randomint(),t=e[0],e=0|(e[1]>>>12|(4095&t)<<20);return n._CONVERTION_BUFFER.setUint32(0,1023<<20|t>>>12,!1),n._CONVERTION_BUFFER.setUint32(4,e,!1),an._CONVERTION_BUFFER.getFloat64(0,!1)-1},l(n,["_CONVERTION_BUFFER",function(){return this._CONVERTION_BUFFER=new DataView(new ArrayBuffer(8))},"defaultRand",function(){return this.defaultRand=new an([0,Date.now()/65536,0,Date.now()%65536])}])}(),p(sn,"laya.d3.math.Ray"),sn);function sn(e,t){this.origin=null,this.direction=null,this.origin=e,this.direction=t}var ln=function(){function e(e,t){this.elements=new Float32Array(2),void 0===t&&(t=0);var n=this.elements;n[0]=e=void 0===e?0:e,n[1]=t}p(e,"laya.d3.math.Vector2");var t=e.prototype;return S.imps(t,{"laya.d3.core.IClone":!0}),t.fromArray=function(e,t){this.elements[0]=e[(t=void 0===t?0:t)+0],this.elements[1]=e[t+1]},t.cloneTo=function(e){var t=e.elements,e=this.elements;t[0]=e[0],t[1]=e[1]},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},_(0,t,"x",function(){return this.elements[0]},function(e){this.elements[0]=e}),_(0,t,"y",function(){return this.elements[1]},function(e){this.elements[1]=e}),e.scale=function(e,t,n){n=n.elements,e=e.elements;n[0]=e[0]*t,n[1]=e[1]*t},l(e,["ZERO",function(){return this.ZERO=new e(0,0)},"ONE",function(){return this.ONE=new e(1,1)}]),e}(),hn=function(){function o(e,t,n){this.elements=new Float32Array(3),void 0===t&&(t=0),void 0===n&&(n=0);var i=this.elements;i[0]=e=void 0===e?0:e,i[1]=t,i[2]=n}p(o,"laya.d3.math.Vector3");var e=o.prototype;return S.imps(e,{"laya.d3.core.IClone":!0}),e.fromArray=function(e,t){this.elements[0]=e[(t=void 0===t?0:t)+0],this.elements[1]=e[t+1],this.elements[2]=e[t+2]},e.cloneTo=function(e){var t=e.elements,e=this.elements;t[0]=e[0],t[1]=e[1],t[2]=e[2]},e.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},e.toDefault=function(){this.elements[0]=0,this.elements[1]=0,this.elements[2]=0},_(0,e,"x",function(){return this.elements[0]},function(e){this.elements[0]=e}),_(0,e,"y",function(){return this.elements[1]},function(e){this.elements[1]=e}),_(0,e,"z",function(){return this.elements[2]},function(e){this.elements[2]=e}),o.distanceSquared=function(e,t){var n=e.elements,i=t.elements,e=n[0]-i[0],t=n[1]-i[1],i=n[2]-i[2];return e*e+t*t+i*i},o.distance=function(e,t){var n=e.elements,i=t.elements,e=n[0]-i[0],t=n[1]-i[1],i=n[2]-i[2];return Math.sqrt(e*e+t*t+i*i)},o.min=function(e,t,n){n=n.elements,e=e.elements,t=t.elements;n[0]=Math.min(e[0],t[0]),n[1]=Math.min(e[1],t[1]),n[2]=Math.min(e[2],t[2])},o.max=function(e,t,n){n=n.elements,e=e.elements,t=t.elements;n[0]=Math.max(e[0],t[0]),n[1]=Math.max(e[1],t[1]),n[2]=Math.max(e[2],t[2])},o.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],n=a[2],e=a[3],t=e*o+_*l-n*s,r=e*s+n*o-h*l,a=e*l+h*s-_*o,l=-h*o-_*s-n*l;i[0]=t*e+l*-h+r*-n-a*-_,i[1]=r*e+l*-_+a*-h-t*-n,i[2]=a*e+l*-n+t*-_-r*-h},o.scalarLength=function(e){var t=e.elements,n=t[0],e=t[1],t=t[2];return Math.sqrt(n*n+e*e+t*t)},o.scalarLengthSquared=function(e){var t=e.elements,n=t[0],e=t[1],t=t[2];return n*n+e*e+t*t},o.normalize=function(e,t){var n=e.elements,i=t.elements,r=n[0],e=n[1],t=n[2],t=r*r+e*e+t*t;0<t&&(t=1/Math.sqrt(t),i[0]=n[0]*t,i[1]=n[1]*t,i[2]=n[2]*t)},o.multiply=function(e,t,n){n=n.elements,e=e.elements,t=t.elements;n[0]=e[0]*t[0],n[1]=e[1]*t[1],n[2]=e[2]*t[2]},o.scale=function(e,t,n){n=n.elements,e=e.elements;n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t},o.lerp=function(e,t,n,i){var r=i.elements,a=e.elements,i=t.elements,e=a[0],t=a[1],a=a[2];r[0]=e+n*(i[0]-e),r[1]=t+n*(i[1]-t),r[2]=a+n*(i[2]-a)},o.transformV3ToV3=function(e,t,n){var i=o._tempVector4;o.transformV3ToV4(e,t,i);i=i.elements,n=n.elements;n[0]=i[0],n[1]=i[1],n[2]=i[2]},o.transformV3ToV4=function(e,t,n){var i=e.elements,r=i[0],e=i[1],i=i[2],t=t.elements,n=n.elements;n[0]=r*t[0]+e*t[4]+i*t[8]+t[12],n[1]=r*t[1]+e*t[5]+i*t[9]+t[13],n[2]=r*t[2]+e*t[6]+i*t[10]+t[14],n[3]=r*t[3]+e*t[7]+i*t[11]+t[15]},o.TransformNormal=function(e,t,n){var i=e.elements,r=i[0],e=i[1],i=i[2],t=t.elements,n=n.elements;n[0]=r*t[0]+e*t[4]+i*t[8],n[1]=r*t[1]+e*t[5]+i*t[9],n[2]=r*t[2]+e*t[6]+i*t[10]},o.transformCoordinate=function(e,t,n){var i=o._tempVector4.elements,r=e.elements,a=r[0],e=r[1],r=r[2],t=t.elements;i[0]=a*t[0]+e*t[4]+r*t[8]+t[12],i[1]=a*t[1]+e*t[5]+r*t[9]+t[13],i[2]=a*t[2]+e*t[6]+r*t[10]+t[14],i[3]=1/(a*t[3]+e*t[7]+r*t[11]+t[15]);n=n.elements;n[0]=i[0]*i[3],n[1]=i[1]*i[3],n[2]=i[2]*i[3]},o.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],e=l[1],r=l[2],t=n.elements,l=t[0],n=t[1],t=t[2],i=i.elements,o=(o=n<o?n:o)<e?e:o,s=(s=t<s?t:s)<r?r:s;i[0]=a=(a=l<a?l:a)<h?h:a,i[1]=o,i[2]=s},o.add=function(e,t,n){n=n.elements,e=e.elements,t=t.elements;n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2]},o.subtract=function(e,t,n){n=n.elements,e=e.elements,t=t.elements;n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2]},o.cross=function(e,t,n){var i=e.elements,r=t.elements,a=n.elements,o=i[0],e=i[1],t=i[2],n=r[0],i=r[1],r=r[2];a[0]=e*r-t*i,a[1]=t*n-o*r,a[2]=o*i-e*n},o.dot=function(e,t){e=e.elements,t=t.elements;return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},o.equals=function(e,t){e=e.elements,t=t.elements;return qt.nearEqual(Math.abs(e[0]),Math.abs(t[0]))&&qt.nearEqual(Math.abs(e[1]),Math.abs(t[1]))&&qt.nearEqual(Math.abs(e[2]),Math.abs(t[2]))},o.ZERO=new o(0,0,0),o.ONE=new o(1,1,1),o.NegativeUnitX=new o(-1,0,0),o.UnitX=new o(1,0,0),o.UnitY=new o(0,1,0),o.UnitZ=new o(0,0,1),o.ForwardRH=new o(0,0,-1),o.ForwardLH=new o(0,0,1),o.Up=new o(0,1,0),o.NAN=new o(NaN,NaN,NaN),l(o,["_tempVector4",function(){return this._tempVector4=new _n}]),o}(),_n=function(){function e(e,t,n,i){this.elements=new Float32Array(4),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0);var r=this.elements;r[0]=e=void 0===e?0:e,r[1]=t,r[2]=n,r[3]=i}p(e,"laya.d3.math.Vector4");var t=e.prototype;return S.imps(t,{"laya.d3.core.IClone":!0}),t.fromArray=function(e,t){this.elements[0]=e[(t=void 0===t?0: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,e=this.elements;t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[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},_(0,t,"x",function(){return this.elements[0]},function(e){this.elements[0]=e}),_(0,t,"y",function(){return this.elements[1]},function(e){this.elements[1]=e}),_(0,t,"z",function(){return this.elements[2]},function(e){this.elements[2]=e}),_(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,i=a[0],e=a[1],t=a[2],a=a[3];r[0]=i+n*(o[0]-i),r[1]=e+n*(o[1]-e),r[2]=t+n*(o[2]-t),r[3]=a+n*(o[3]-a)},e.transformByM4x4=function(e,t,n){var i=e.elements,r=i[0],a=i[1],e=i[2],i=i[3],t=t.elements,n=n.elements;n[0]=r*t[0]+a*t[4]+e*t[8]+i*t[12],n[1]=r*t[1]+a*t[5]+e*t[9]+i*t[13],n[2]=r*t[2]+a*t[6]+e*t[10]+i*t[14],n[3]=r*t[3]+a*t[7]+e*t[11]+i*t[15]},e.equals=function(e,t){e=e.elements,t=t.elements;return qt.nearEqual(Math.abs(e[0]),Math.abs(t[0]))&&qt.nearEqual(Math.abs(e[1]),Math.abs(t[1]))&&qt.nearEqual(Math.abs(e[2]),Math.abs(t[2]))&&qt.nearEqual(Math.abs(e[3]),Math.abs(t[3]))},e.normalize=function(e,t){var n=e.elements,t=t.elements,e=e.length();0<e&&(t[0]=n[0]*e,t[1]=n[1]*e,t[2]=n[2]*e,t[3]=n[3]*e)},e.add=function(e,t,n){n=n.elements,e=e.elements,t=t.elements;n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n[3]=e[3]+t[3]},e.subtract=function(e,t,n){n=n.elements,e=e.elements,t=t.elements;n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n[3]=e[3]-t[3]},e.multiply=function(e,t,n){n=n.elements,e=e.elements,t=t.elements;n[0]=e[0]*t[0],n[1]=e[1]*t[1],n[2]=e[2]*t[2],n[3]=e[3]*t[3]},e.scale=function(e,t,n){n=n.elements,e=e.elements;n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n[3]=e[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],d=h[2],e=h[3],r=n.elements,t=r[0],h=r[1],n=r[2],r=r[3],i=i.elements,o=(o=h<o?h:o)<u?u:o,s=(s=n<s?n:s)<d?d:s,l=(l=r<l?r:l)<e?e:l;i[0]=a=(a=t<a?t:a)<_?_:a,i[1]=o,i[2]=s,i[3]=l},e.distanceSquared=function(e,t){var n=e.elements,i=t.elements,r=n[0]-i[0],e=n[1]-i[1],t=n[2]-i[2],i=n[3]-i[3];return r*r+e*e+t*t+i*i},e.distance=function(e,t){var n=e.elements,i=t.elements,r=n[0]-i[0],e=n[1]-i[1],t=n[2]-i[2],i=n[3]-i[3];return Math.sqrt(r*r+e*e+t*t+i*i)},e.dot=function(e,t){e=e.elements,t=t.elements;return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},e.min=function(e,t,n){n=n.elements,e=e.elements,t=t.elements;n[0]=Math.min(e[0],t[0]),n[1]=Math.min(e[1],t[1]),n[2]=Math.min(e[2],t[2]),n[3]=Math.min(e[3],t[3])},e.max=function(e,t,n){n=n.elements,e=e.elements,t=t.elements;n[0]=Math.max(e[0],t[0]),n[1]=Math.max(e[1],t[1]),n[2]=Math.max(e[2],t[2]),n[3]=Math.max(e[3],t[3])},l(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}(),un=function(){function a(e,t,n,i){this.minDepth=0,this.maxDepth=1,this.x=e,this.y=t,this.width=n,this.height=i}p(a,"laya.d3.math.Viewport");var e=a.prototype;return e.project=function(e,t,n){hn.transformV3ToV3(e,t,n);e=e.elements,t=t.elements,n=n.elements,t=e[0]*t[3]+e[1]*t[7]+e[2]*t[11]+t[15];1!==t&&(n[0]=n[0]/t,n[1]=n[1]/t,n[2]=n[2]/t),n[0]=.5*(n[0]+1)*this.width+this.x,n[1]=.5*(1-n[1])*this.height+this.y,n[2]=n[2]*(this.maxDepth-this.minDepth)+this.minDepth},e.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);e=(this.maxDepth-this.minDepth)/2;a[2]=(i[2]-this.minDepth-e)/e;r=a[0]*r[3]+a[1]*r[7]+a[2]*r[11]+r[15];hn.transformV3ToV3(n,t,n),1!==r&&(a[0]=a[0]/r,a[1]=a[1]/r,a[2]=a[2]/r)},e.unprojectFromWVP=function(e,t,n,i,r){Jt.multiply(t,n,a._tempMatrix4x4),i&&Jt.multiply(a._tempMatrix4x4,i,a._tempMatrix4x4),a._tempMatrix4x4.invert(a._tempMatrix4x4),this.unprojectFromMat(e,a._tempMatrix4x4,r)},l(a,["_tempMatrix4x4",function(){return this._tempMatrix4x4=new Jt}]),a}(),dn=function(){function e(){this._alphaBlending=1,this._colorIntensity=1,this._shaderValue=new vn}p(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(){var e;this._environmentSpecular.loaded?((e=this._environmentSpecular.simLodInfo)&&e instanceof Float32Array&&this.__ownerCamera._shaderValues.setValue(9,e),this.__ownerCamera._shaderValues.setValue(8,this._environmentSpecular)):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},_(0,t,"_ownerCamera",null,function(e){this.__ownerCamera=e,this._environmentDiffuse&&this._setEnvironmentDiffuse(),this._environmentSpecular&&this._setEnvironmentSpecular()}),_(0,t,"alphaBlending",function(){return this._alphaBlending},function(e){this._alphaBlending=e,this._alphaBlending<0&&(this._alphaBlending=0),1<this._alphaBlending&&(this._alphaBlending=1)}),_(0,t,"envDiffuseSHBlue",null,function(e){this.__ownerCamera._shaderValues.setValue(12,e)}),_(0,t,"colorIntensity",function(){return this._colorIntensity},function(e){this._colorIntensity=e,this._colorIntensity<0&&(this._colorIntensity=0)}),_(0,t,"envDiffuseSHGreen",null,function(e){this.__ownerCamera._shaderValues.setValue(11,e)}),_(0,t,"envDiffuseSHRed",null,function(e){this.__ownerCamera._shaderValues.setValue(10,e)}),_(0,t,"environmentDiffuse",function(){return this._environmentDiffuse},function(e){e.minFifter=9728,this._environmentDiffuse=e,this.__ownerCamera&&this._setEnvironmentDiffuse()}),_(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}(),cn=function(){function x(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=[]}p(x,"laya.d3.resource.models.SubMesh");var e=x.prototype;return S.imps(e,{"laya.d3.core.render.IRenderable":!0,"laya.resource.IDispose":!0}),e._getVertexBuffer=function(e){return 0===(e=void 0===e?0:e)?this._vertexBuffer:null},e._getIndexBuffer=function(){return this._indexBuffer},e._getStaticBatchBakedVertexs=function(e,t){var n,i,r=this._vertexBuffer,a=r.vertexDeclaration,o=a.getVertexElementByUsage(0).offset/4,s=a.getVertexElementByUsage(3).offset/4,l=t.meshRender.lightmapScaleOffset,h=0,_=0,u=0,d=0,c=0,f=0;if(l)if(n=a.getVertexElementByUsage(15))u=a.vertexStride/4,m=0<this._vertexCount?r.getData().slice(this._vertexStart*u,(this._vertexStart+this._vertexCount)*u):r.getData().slice(),d=n.offset/4;else for(var u=(f=a.vertexStride/4)+2,m=this._vertexCount?new Float32Array(this._vertexCount*(r.vertexDeclaration.vertexStride/4+2)):new Float32Array(r.vertexCount*(r.vertexDeclaration.vertexStride/4+2)),d=(c=a.getVertexElementByUsage(2).offset/4)+2,p=r.getData(),h=0,_=p.length/f;h<_;h++){for(var E=0,E=0<this._vertexCount?(this._vertexStart+h)*f:h*f,v=h*u,g=0,g=0;g<d;g++)m[v+g]=p[E+g];for(g=d;g<f;g++)m[v+g+2]=p[E+g]}else u=a.vertexStride/4,m=this._vertexCount?r.getData().slice(this._vertexStart*u,(this._vertexStart+this._vertexCount)*u):r.getData().slice();e?(e.worldMatrix.invert(r=x._tempMatrix4x40),e=t.transform.worldMatrix,Jt.multiply(r,e,i=x._tempMatrix4x41)):i=t.transform.worldMatrix;var T=x._tempQuaternion0;for(i.decomposeTransRotScale(x._tempVector30,T,x._tempVector31),h=0,_=m.length/u;h<_;h++){var S=h*u+o,D=h*u+s;wn.transformVector3ArrayToVector3ArrayCoordinate(m,S,i,m,S),wn.transformVector3ArrayByQuat(m,D,T,m,D),l&&(D=h*u+d,n?wn.transformLightingMapTexcoordByUV1Array(m,D,l,m,D):wn.transformLightingMapTexcoordByUV0Array(p,h*f+c,l,m,D))}return m},e._getVertexBuffers=function(){return null},e._beforeRender=function(e){return this._vertexBuffer._bind(),this._indexBuffer._bind(),!0},e._render=function(e){var t,n=0,i=e.renderElement;if(1<this._indexCount){var r=this._boneIndicesList.length;if(1<r){for(var a=0;a<r;a++)(t=i._skinAnimationDatas||this._skinAnimationDatas)&&(i._shaderValue.setValue(0,t[a]),e._shader.uploadRenderElementUniforms(i._shaderValue.data)),N.mainContext.drawElements(4,this._subIndexBufferCount[a],5123,2*this._subIndexBufferStart[a]);I.drawCall+=r}else(t=i._skinAnimationDatas||this._skinAnimationDatas)&&(i._shaderValue.setValue(0,t[0]),e._shader.uploadRenderElementUniforms(i._shaderValue.data)),N.mainContext.drawElements(4,this._indexCount,5123,2*this._indexStart),I.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)),N.mainContext.drawElements(4,n,5123,0),I.drawCall++;I.trianglesFaces+=n/3},e.getIndices=function(){return 0<this._indexCount?this._indices:this._indexBuffer.getData()},e.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},_(0,e,"_vertexBufferCount",function(){return 1}),_(0,e,"triangleCount",function(){return this._indexBuffer.indexCount/3}),l(x,["_tempVector30",function(){return this._tempVector30=new hn},"_tempVector31",function(){return this._tempVector31=new hn},"_tempQuaternion0",function(){return this._tempQuaternion0=new rn},"_tempMatrix4x40",function(){return this._tempMatrix4x40=new Jt},"_tempMatrix4x41",function(){return this._tempMatrix4x41=new Jt}]),x}(),fn=(p(mn,"laya.d3.shader.ShaderDefines",null,"ShaderDefines$1"),mn.prototype.registerDefine=function(e){var t=Math.pow(2,this.defineCounter++);return this.defines[t]=e,t},mn);function mn(e){this.defineCounter=0,this.defines=null,e?(this.defineCounter=e.defineCounter,this.defines=e.defines.slice()):(this.defineCounter=0,this.defines=[])}var pn=(p(En,"laya.d3.shader.ShaderInit3D"),En.__init__=function(){$n._globalRegDefine("HIGHPRECISION",$n.SHADERDEFINE_HIGHPRECISION),$n._globalRegDefine("FOG",$n.SHADERDEFINE_FOG),$n._globalRegDefine("DIRECTIONLIGHT",$n.SHADERDEFINE_DIRECTIONLIGHT),$n._globalRegDefine("POINTLIGHT",$n.SHADERDEFINE_POINTLIGHT),$n._globalRegDefine("SPOTLIGHT",$n.SHADERDEFINE_SPOTLIGHT),$n._globalRegDefine("UV",$n.SHADERDEFINE_UV0),$n._globalRegDefine("COLOR",$n.SHADERDEFINE_COLOR),$n._globalRegDefine("UV1",$n.SHADERDEFINE_UV1),$n._globalRegDefine("CASTSHADOW",gn.SHADERDEFINE_CAST_SHADOW),$n._globalRegDefine("SHADOWMAP_PSSM1",gn.SHADERDEFINE_SHADOW_PSSM1),$n._globalRegDefine("SHADOWMAP_PSSM2",gn.SHADERDEFINE_SHADOW_PSSM2),$n._globalRegDefine("SHADOWMAP_PSSM3",gn.SHADERDEFINE_SHADOW_PSSM3),$n._globalRegDefine("SHADOWMAP_PCF_NO",gn.SHADERDEFINE_SHADOW_PCF_NO),$n._globalRegDefine("SHADOWMAP_PCF1",gn.SHADERDEFINE_SHADOW_PCF1),$n._globalRegDefine("SHADOWMAP_PCF2",gn.SHADERDEFINE_SHADOW_PCF2),$n._globalRegDefine("SHADOWMAP_PCF3",gn.SHADERDEFINE_SHADOW_PCF3),$n._globalRegDefine("DEPTHFOG",$n.SAHDERDEFINE_DEPTHFOG),Vi.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"),Vi.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"),Vi.addInclude("ShadowHelper.glsl","uniform sampler2D u_shadowMap1;\nuniform sampler2D u_shadowMap2;\nuniform sampler2D u_shadowMap3;\nuniform vec2\t u_shadowPCFoffset;\nuniform vec3 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],vec3 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],vec3 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,vec3 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}"),Vi.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; 为了提高精度这里只保留sincos部分实际使用的时候再乘回来。\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"),Vi.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}"),Vi.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"),Vi.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'),Vi.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={a_Position:0,a_Color:1,a_Normal:3,a_Texcoord0:2,a_Texcoord1:15,a_BoneWeights:7,a_BoneIndices:6,a_Tangent0:5},t={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_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]},n=Vi.nameKey.add("BLINNPHONG"),i=$n.add(n,'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}','#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)\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)\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#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\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\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)\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)\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\t\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\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',e,t);yi.SHADERDEFINE_DIFFUSEMAP=i.registerMaterialDefine("DIFFUSEMAP"),yi.SHADERDEFINE_NORMALMAP=i.registerMaterialDefine("NORMALMAP"),yi.SHADERDEFINE_SPECULARMAP=i.registerMaterialDefine("SPECULARMAP"),yi.SHADERDEFINE_REFLECTMAP=i.registerMaterialDefine("REFLECTMAP"),yi.SHADERDEFINE_TILINGOFFSET=i.registerMaterialDefine("TILINGOFFSET"),yi.SHADERDEFINE_ADDTIVEFOG=i.registerMaterialDefine("ADDTIVEFOG");e={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},t={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]},n=Vi.nameKey.add("SIMPLE"),i=$n.add(n,"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}",'#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',e,t);Pi.SHADERDEFINE_DIFFUSEMAP=i.registerMaterialDefine("DIFFUSEMAP"),Pi.SHADERDEFINE_NORMALMAP=i.registerMaterialDefine("NORMALMAP"),Pi.SHADERDEFINE_SPECULARMAP=i.registerMaterialDefine("SPECULARMAP"),Pi.SHADERDEFINE_EMISSIVEMAP=i.registerMaterialDefine("EMISSIVEMAP"),Pi.SHADERDEFINE_AMBIENTMAP=i.registerMaterialDefine("AMBIENTMAP"),Pi.SHADERDEFINE_REFLECTMAP=i.registerMaterialDefine("REFLECTMAP"),Pi.SHADERDEFINE_UVTRANSFORM=i.registerMaterialDefine("UVTRANSFORM"),Pi.SHADERDEFINE_TILINGOFFSET=i.registerMaterialDefine("TILINGOFFSET"),Pi.SHADERDEFINE_ADDTIVEFOG=i.registerMaterialDefine("ADDTIVEFOG"),e={a_Position:0,a_Color:1},t={u_MvpMatrix:[1,2]};n=Vi.nameKey.add("LINE");$n.add(n,"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}","#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",e,t),e={a_position:0,a_normal:3,tangent:5,binormal:4,uv:2,a_BoneWeights:7,a_BoneIndices:6,a_Tangent0:5},t={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]};n=Vi.nameKey.add("PBR");i=$n.add(n,"\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",'//#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',e,t),Li.SHADERDEFINE_FIX_METALESS=i.registerMaterialDefine("FIX_METALESS"),Li.SHADERDEFINE_FIX_ROUGHNESS=i.registerMaterialDefine("FIX_ROUGHNESS"),Li.SHADERDEFINE_HAS_TANGENT=i.registerMaterialDefine("HAS_TANGENT"),Li.SHADERDEFINE_HAS_PBRINFO=i.registerMaterialDefine("HAS_PBRINFO"),Li.SHADERDEFINE_USE_GROUNDTRUTH=i.registerMaterialDefine("USE_GROUNDTRUTH"),Li.SHADERDEFINE_TEST_CLIPZ=i.registerMaterialDefine("CLIPZ"),e={a_Position:0,a_Normal:3,a_Tangent0:5,a_Texcoord0:2,a_BoneWeights:7,a_BoneIndices:6},t={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]};n=Vi.nameKey.add("PBRStandard");i=$n.add(n,"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}",'#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 vec3 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',e,t),Fi.SHADERDEFINE_DIFFUSETEXTURE=i.registerMaterialDefine("DIFFUSETEXTURE"),Fi.SHADERDEFINE_METALLICGLOSSTEXTURE=i.registerMaterialDefine("METALLICGLOSSTEXTURE"),Fi.SHADERDEFINE_SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA=i.registerMaterialDefine("SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA"),Fi.SHADERDEFINE_NORMALTEXTURE=i.registerMaterialDefine("NORMALTEXTURE"),Fi.SHADERDEFINE_PARALLAXTEXTURE=i.registerMaterialDefine("PARALLAXTEXTURE"),Fi.SHADERDEFINE_OCCLUSIONTEXTURE=i.registerMaterialDefine("OCCLUSIONTEXTURE"),Fi.SHADERDEFINE_EMISSION=i.registerMaterialDefine("EMISSION"),Fi.SHADERDEFINE_EMISSIONTEXTURE=i.registerMaterialDefine("EMISSIONTEXTURE"),Fi.SHADERDEFINE_TILINGOFFSET=i.registerMaterialDefine("TILINGOFFSET"),e={a_Position:0,a_Normal:3,a_Tangent0:5,a_Texcoord0:2,a_BoneWeights:7,a_BoneIndices:6},t={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]};n=Vi.nameKey.add("PBRSpecular");i=$n.add(n,"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}",'#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 vec3 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',e,t),wi.SHADERDEFINE_DIFFUSETEXTURE=i.registerMaterialDefine("DIFFUSETEXTURE"),wi.SHADERDEFINE_SPECULARTEXTURE=i.registerMaterialDefine("SPECULARTEXTURE"),wi.SHADERDEFINE_SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA=i.registerMaterialDefine("SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA"),wi.SHADERDEFINE_NORMALTEXTURE=i.registerMaterialDefine("NORMALTEXTURE"),wi.SHADERDEFINE_PARALLAXTEXTURE=i.registerMaterialDefine("PARALLAXTEXTURE"),wi.SHADERDEFINE_OCCLUSIONTEXTURE=i.registerMaterialDefine("OCCLUSIONTEXTURE"),wi.SHADERDEFINE_EMISSION=i.registerMaterialDefine("EMISSION"),wi.SHADERDEFINE_EMISSIONTEXTURE=i.registerMaterialDefine("EMISSIONTEXTURE"),wi.SHADERDEFINE_TILINGOFFSET=i.registerMaterialDefine("TILINGOFFSET"),e={a_position:0,a_normal:3,uv:2},t={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]};n=Vi.nameKey.add("Water");i=$n.add(n,'\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',"//#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",e,t),Bi.SHADERDEFINE_CUBE_ENV=i.registerMaterialDefine("CUBE_ENV"),Bi.SHADERDEFINE_HDR_ENV=i.registerMaterialDefine("HDR_ENV"),Bi.SHADERDEFINE_SHOW_NORMAL=i.registerMaterialDefine("SHOW_NORMAL"),Bi.SHADERDEFINE_USEVERTEXHEIGHT=i.registerMaterialDefine("USE_VERTEX_DEEPINFO"),Bi.SHADERDEFINE_USE_FOAM=i.registerMaterialDefine("USE_FOAM"),Bi.SHADERDEFINE_USE_REFRACT_TEX=i.registerMaterialDefine("USE_REFR_TEX"),e={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},t={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]};n=Vi.nameKey.add("PARTICLESHURIKEN");i=$n.add(n,"#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","#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}",e,t),Hi.SHADERDEFINE_DIFFUSEMAP=i.registerMaterialDefine("DIFFUSEMAP"),Hi.SHADERDEFINE_TINTCOLOR=i.registerMaterialDefine("TINTCOLOR"),Hi.SHADERDEFINE_ADDTIVEFOG=i.registerMaterialDefine("ADDTIVEFOG"),Hi.SHADERDEFINE_TILINGOFFSET=i.registerMaterialDefine("TILINGOFFSET"),mr.SHADERDEFINE_RENDERMODE_BILLBOARD=i.registerSpriteDefine("SPHERHBILLBOARD"),mr.SHADERDEFINE_RENDERMODE_STRETCHEDBILLBOARD=i.registerSpriteDefine("STRETCHEDBILLBOARD"),mr.SHADERDEFINE_RENDERMODE_HORIZONTALBILLBOARD=i.registerSpriteDefine("HORIZONTALBILLBOARD"),mr.SHADERDEFINE_RENDERMODE_VERTICALBILLBOARD=i.registerSpriteDefine("VERTICALBILLBOARD"),mr.SHADERDEFINE_COLOROVERLIFETIME=i.registerSpriteDefine("COLOROVERLIFETIME"),mr.SHADERDEFINE_RANDOMCOLOROVERLIFETIME=i.registerSpriteDefine("RANDOMCOLOROVERLIFETIME"),mr.SHADERDEFINE_VELOCITYOVERLIFETIMECONSTANT=i.registerSpriteDefine("VELOCITYOVERLIFETIMECONSTANT"),mr.SHADERDEFINE_VELOCITYOVERLIFETIMECURVE=i.registerSpriteDefine("VELOCITYOVERLIFETIMECURVE"),mr.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCONSTANT=i.registerSpriteDefine("VELOCITYOVERLIFETIMERANDOMCONSTANT"),mr.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCURVE=i.registerSpriteDefine("VELOCITYOVERLIFETIMERANDOMCURVE"),mr.SHADERDEFINE_TEXTURESHEETANIMATIONCURVE=i.registerSpriteDefine("TEXTURESHEETANIMATIONCURVE"),mr.SHADERDEFINE_TEXTURESHEETANIMATIONRANDOMCURVE=i.registerSpriteDefine("TEXTURESHEETANIMATIONRANDOMCURVE"),mr.SHADERDEFINE_ROTATIONOVERLIFETIME=i.registerSpriteDefine("ROTATIONOVERLIFETIME"),mr.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE=i.registerSpriteDefine("ROTATIONOVERLIFETIMESEPERATE"),mr.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT=i.registerSpriteDefine("ROTATIONOVERLIFETIMECONSTANT"),mr.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE=i.registerSpriteDefine("ROTATIONOVERLIFETIMECURVE"),mr.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS=i.registerSpriteDefine("ROTATIONOVERLIFETIMERANDOMCONSTANTS"),mr.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCURVES=i.registerSpriteDefine("ROTATIONOVERLIFETIMERANDOMCURVES"),mr.SHADERDEFINE_SIZEOVERLIFETIMECURVE=i.registerSpriteDefine("SIZEOVERLIFETIMECURVE"),mr.SHADERDEFINE_SIZEOVERLIFETIMECURVESEPERATE=i.registerSpriteDefine("SIZEOVERLIFETIMECURVESEPERATE"),mr.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVES=i.registerSpriteDefine("SIZEOVERLIFETIMERANDOMCURVES"),mr.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVESSEPERATE=i.registerSpriteDefine("SIZEOVERLIFETIMERANDOMCURVESSEPERATE"),mr.SHADERDEFINE_RENDERMODE_MESH=i.registerSpriteDefine("RENDERMODE_MESH"),mr.SHADERDEFINE_SHAPE=i.registerSpriteDefine("SHAPE"),e={a_Position:0,a_Texcoord0:2,a_Time:33},t={u_Texture:[1,1],u_Albedo:[2,1],u_Color:[3,1],u_CurrentTime:[2,2],u_Duration:[3,2],u_MvpMatrix:[1,2]};n=Vi.nameKey.add("GLITTER");i=$n.add(n,"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","#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",e,t),e={a_Position:0},t={u_Intensity:[1,1],u_AlphaBlending:[2,1],u_CubeTexture:[3,1],u_MvpMatrix:[4,3]};i=Vi.nameKey.add("SkyBox");$n.add(i,"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","#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",e,t),e={a_Position:0,a_Texcoord0:2},t={u_Intensity:[1,1],u_AlphaBlending:[2,1],u_texture:[3,1],u_MvpMatrix:[4,3]};i=Vi.nameKey.add("SkyDome");$n.add(i,"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","#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",e,t),e={a_Position:0,a_Normal:3,a_Texcoord0:2,a_Texcoord1:15},t={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]};i=Vi.nameKey.add("Terrain"),i=$n.add(i,"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}",'#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',e,t);bi.SHADERDEFINE_DETAIL_NUM1=i.registerMaterialDefine("DETAIL_NUM1"),bi.SHADERDEFINE_DETAIL_NUM2=i.registerMaterialDefine("DETAIL_NUM2"),bi.SHADERDEFINE_DETAIL_NUM4=i.registerMaterialDefine("DETAIL_NUM4"),bi.SHADERDEFINE_DETAIL_NUM3=i.registerMaterialDefine("DETAIL_NUM3"),e={a_Position:0,a_Normal:3,a_Texcoord0:2},t={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]};i=Vi.nameKey.add("ExtendTerrain"),i=$n.add(i,"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}",'#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',e,t);i.addSpriteDefines(lr.shaderDefines),i.addMaterialDefines(Oi.shaderDefines),e={a_Position:0,a_OffsetVector:41,a_Texcoord0X:38,a_Texcoord0Y:40,a_BirthTime:33},t={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]};i=Vi.nameKey.add("Trail"),t=$n.add(i,"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","#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",e,t);zi.SHADERDEFINE_DIFFUSETEXTURE=t.registerMaterialDefine("DIFFUSETEXTURE"),zi.SHADERDEFINE_TILINGOFFSET=t.registerSpriteDefine("TILINGOFFSET"),Er.SHADERDEFINE_GRADIENTMODE_BLEND=t.registerSpriteDefine("GRADIENTMODE_BLEND")},En);function En(){}var vn=function(){function e(){this._data=null,this._data=[]}p(e,"laya.d3.shader.ValusArray");var t=e.prototype;return t.setValue=function(e,t){this._data[e]=t},_(0,t,"data",function(){return this._data}),e}(),gn=function(){function u(){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 hn(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 hn,this._tempLookAt4=new _n,this._tempValue=new _n,this._tempPos=new hn,this._tempLightUp=new hn,this._tempMin=new _n,this._tempMax=new _n,this._tempMatrix44=new Jt,this._splitFrustumCulling=new Xt(Jt.DEFAULT),this._tempScaleMatrix44=new Jt,this._shadowPCFOffset=new ln(1/1024,1/1024),this._shaderValueDistance=new _n;for(var e=0,e=0;e<this._spiltDistance.length;e++)this._spiltDistance[e]=0;for(e=0;e<this._dimension.length;e++)this._dimension[e]=new ln;for(e=0;e<this._frustumPos.length;e++)this._frustumPos[e]=new hn;for(e=0;e<this._boundingBox.length;e++)this._boundingBox[e]=new kt(new hn,new hn);for(e=0;e<this._boundingSphere.length;e++)this._boundingSphere[e]=new Yt(new hn,0);Jt.createScaling(new hn(.5,.5,1),this._tempScaleMatrix44),this._tempScaleMatrix44.elements[12]=.5,this._tempScaleMatrix44.elements[13]=.5}p(u,"laya.d3.shadowMap.ParallelSplitShadowMap");var e=u.prototype;return e.setInfo=function(e,t,n,i,r,a){3<r&&(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},e.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)}},e.getPCFType=function(){return this._PCFType},e.setFarDistance=function(e){this._maxDistance!=e&&(this._maxDistance=e,this._statesDirty=!0)},e.getFarDistance=function(){return this._maxDistance},e._setGlobalParallelLightDir=function(e){this._globalParallelLightDir=e},e.getGlobalParallelLightDir=function(){return this._globalParallelLightDir},e.getCurrentPSSM=function(){return this._currentPSSM},e.getLightCamera=function(e){return this._lightCameras[e]},e._beginSampler=function(e,t){if(e<0||e>this._numberOfPSSM)throw new Error("ParallelSplitShadowMap: beginSample invalid index");this._currentPSSM=e,this._update(t)},e.endSampler=function(e){this._currentPSSM=-1},e._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)},e._recalculate=function(e,t,n){this._calcSplitDistance(e),this._calcBoundingBox(t,n),this._rebuildRenderInfo()},e._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)},e._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))}},e._calcSplitDistance=function(e){for(var t=this._maxDistance,n=1/this._numberOfPSSM,i=0,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]},e._calcBoundingBox=function(e,t){for(var n,i,r,a,o=Math.tan(3.1415926*e/180/2),s=NaN,l=NaN,h=0,h=0;h<=this._numberOfPSSM;h++){var _=this._spiltDistance[h],u=this._frustumPos[4*h+0].elements;u[0]=-(l=(s=_*o)*t),u[1]=-s,u[2]=-_,(u=this._frustumPos[4*h+1].elements)[0]=l,u[1]=-s,u[2]=-_,(u=this._frustumPos[4*h+2].elements)[0]=-l,u[1]=s,u[2]=-_,(u=this._frustumPos[4*h+3].elements)[0]=l,u[1]=s,u[2]=-_,(u=this._dimension[h].elements)[0]=l,u[1]=s}for(h=1;h<=this._numberOfPSSM;h++)n=this._dimension[h].elements,(i=this._boundingBox[h].min.elements)[0]=-n[0],i[1]=-n[1],i[2]=-this._spiltDistance[h],(r=this._boundingBox[h].max.elements)[0]=n[0],r[1]=n[1],r[2]=-this._spiltDistance[h-1],(a=this._boundingSphere[h].center.elements)[0]=.5*(i[0]+r[0]),a[1]=.5*(i[1]+r[1]),a[2]=.5*(i[2]+r[2]),this._boundingSphere[h].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))},e.calcSplitFrustum=function(e){0<this._currentPSSM?Jt.createPerspective(3.1416*e.fieldOfView/180,e.aspectRatio,this._spiltDistance[this._currentPSSM-1],this._spiltDistance[this._currentPSSM],this._tempMatrix44):Jt.createPerspective(3.1416*e.fieldOfView/180,e.aspectRatio,this._spiltDistance[0],this._spiltDistance[this._numberOfPSSM],this._tempMatrix44),Jt.multiply(this._tempMatrix44,e.viewMatrix,this._tempMatrix44),this._splitFrustumCulling.matrix=this._tempMatrix44},e._rebuildRenderInfo=function(){var e=this._numberOfPSSM+1,t=0;if(null==this._renderTarget)for(this._renderTarget=v(e),this._renderTarget[0]=null,t=1;t<e;t++)this._renderTarget[t]=new tr(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 tr(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 tr(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=v(e),t=0;t<this._lightCulling.length;t++)this._lightCulling[t]=new Xt(Jt.DEFAULT);if(null==this._lightVPMatrix||this._lightVPMatrix.length!=e)for(this._lightVPMatrix?this._lightVPMatrix.length=e:this._lightVPMatrix=v(e),t=0;t<this._lightVPMatrix.length;t++)this._lightVPMatrix[t]=new Jt;if(null==this._lightCameras||this._lightCameras.length!=e)for(this._lightCameras?this._lightCameras.length=e:this._lightCameras=v(e),t=0;t<this._lightCameras.length;t++)this._lightCameras[t]=new dr,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=v(this._numberOfPSSM),t=0;t<this._shadowQuenes.length;t++)this._shadowQuenes[t]=new Ee(this._scene);if(null==this._shaderValueVPs||this._shaderValueVPs.length!=e)for(this._shaderValueVPs?this._shaderValueVPs.length=e:this._shaderValueVPs=v(e),this._shaderValueLightVP=new Float32Array(16*e),t=0;t<e;t++)this._shaderValueVPs[t]=new Float32Array(this._shaderValueLightVP.buffer,64*t)},e._calcLightViewProject=function(e){var t=this._boundingSphere[this._currentPSSM],n=e.transform.worldMatrix;t.radius;t.center.cloneTo(this._tempLookAt3),hn.transformV3ToV4(this._tempLookAt3,n,this._tempLookAt4);var i=this._tempLookAt3.elements,r=this._tempLookAt4.elements;i[0]=r[0],i[1]=r[1],i[2]=r[2];r=this._tempLightUp.elements,e=e.forward.elements;r[0]=e[0],r[1]=1,r[2]=e[2],hn.normalize(this._tempLightUp,this._tempLightUp),hn.scale(this._globalParallelLightDir,4*t.radius,this._tempPos),hn.subtract(this._tempLookAt3,this._tempPos,this._tempPos);e=this._lightCameras[this._currentPSSM];e.transform.position=this._tempPos,e.transform.lookAt(this._tempLookAt3,this._tempLightUp,!1);var a=this._tempMax.elements,o=this._tempMin.elements;a[0]=a[1]=a[2]=-1e5,a[3]=1,o[0]=o[1]=o[2]=1e5,o[3]=1,Jt.multiply(e.viewMatrix,n,this._tempMatrix44);var s=this._tempValue.elements,l=[];l.length=8,this._boundingBox[this._currentPSSM].getCorners(l);for(var h=0;h<8;h++){var _=l[h].elements;s[0]=_[0],s[1]=_[1],s[2]=_[2],s[3]=1,_n.transformByM4x4(this._tempValue,this._tempMatrix44,this._tempValue),o[0]=(s[0]<o[0]?s:o)[0],o[1]=(s[1]<o[1]?s:o)[1],o[2]=(s[2]<o[2]?s:o)[2],a[0]=(s[0]>a[0]?s:a)[0],a[1]=(s[1]>a[1]?s:a)[1],a[2]=(s[2]>a[2]?s:a)[2]}_n.add(this._tempMax,this._tempMin,this._tempValue),s[0]*=.5,s[1]*=.5,s[2]*=.5,s[3]=1,_n.transformByM4x4(this._tempValue,e.transform.worldMatrix,this._tempValue);t=Math.abs(-this._tempMax.z),n=t>this._maxDistance?t:this._maxDistance;hn.scale(this._globalParallelLightDir,n,this._tempPos);t=this._tempPos.elements;t[0]=s[0]-t[0],t[1]=s[1]-t[1],t[2]=s[2]-t[2],e.transform.position=this._tempPos,e.transform.lookAt(this._tempLookAt3,this._tempLightUp,!1),Jt.createOrthoOffCenterRH(o[0],a[0],o[1],a[1],1,n+.5*(a[2]-o[2]),e.projectionMatrix),e.projectionViewMatrix.cloneTo(this._lightVPMatrix[this._currentPSSM]),this._lightCulling[this._currentPSSM].matrix=this._lightVPMatrix[this._currentPSSM],u.multiplyMatrixOutFloat32Array(this._tempScaleMatrix44,this._lightVPMatrix[this._currentPSSM],this._shaderValueVPs[this._currentPSSM])},e.getLightFrustumCulling=function(e){return this._lightCulling[e]},e.getSplitFrustumCulling=function(){return this._splitFrustumCulling},e.getSplitDistance=function(e){return this._spiltDistance[e]},e.setShadowMapTextureSize=function(e){e!==this._shadowMapTextureSize&&(this._shadowMapTextureSize=e,this._shadowPCFOffset.x=1/this._shadowMapTextureSize,this._shadowPCFOffset.y=1/this._shadowMapTextureSize,this._statesDirty=!0)},e.getShadowMapTextureSize=function(){return this._shadowMapTextureSize},e.beginRenderTarget=function(e){this._renderTarget[e].start()},e.endRenderTarget=function(e){this._renderTarget[e].end()},e.getRenderTarget=function(e){return this._renderTarget[e]},e.disposeAllRenderTarget=function(){for(var e=0,t=this._numberOfPSSM+1;e<t;e++)this._renderTarget[e]&&(this._renderTarget[e].destroy(),this._renderTarget[e]=null)},_(0,e,"PSSMNum",function(){return this._numberOfPSSM},function(e){this._numberOfPSSM!=(e=(e=0<e?e:1)<=3?e:3)&&(this._numberOfPSSM=e,this._ratioOfDistance=1/this._numberOfPSSM,this._statesDirty=!0)}),u.multiplyMatrixOutFloat32Array=function(e,t,n){for(var i,r,a,o,s=e.elements,l=t.elements,h=0;h<4;h++)i=s[h],r=s[h+4],a=s[h+8],o=s[h+12],n[h]=i*l[0]+r*l[1]+a*l[2]+o*l[3],n[h+4]=i*l[4]+r*l[5]+a*l[6]+o*l[7],n[h+8]=i*l[8]+r*l[9]+a*l[10]+o*l[11],n[h+12]=i*l[12]+r*l[13]+a*l[14]+o*l[15]},u.SHADERDEFINE_RECEIVE_SHADOW=1,u.SHADERDEFINE_CAST_SHADOW=512,u.SHADERDEFINE_SHADOW_PSSM1=1024,u.SHADERDEFINE_SHADOW_PSSM2=2048,u.SHADERDEFINE_SHADOW_PSSM3=4096,u.SHADERDEFINE_SHADOW_PCF_NO=8192,u.SHADERDEFINE_SHADOW_PCF1=16384,u.SHADERDEFINE_SHADOW_PCF2=32768,u.SHADERDEFINE_SHADOW_PCF3=65536,u.MAX_PSSM_COUNT=3,u}(),Tn=function(){function T(){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,T.__init__(),this._currentLODLevel=0}p(T,"laya.d3.terrain.TerrainLeaf");var e=T.prototype;return e.calcVertextNorml=function(e,t,n,i,r,a){var o,s=-1*T.getHeightFromTerrainHeightData(e-1,t-1,n,i,r);s+=-1*T.getHeightFromTerrainHeightData(e-1,t,n,i,r),s+=-1*T.getHeightFromTerrainHeightData(e-1,t+1,n,i,r),s+=+T.getHeightFromTerrainHeightData(e+1,t-1,n,i,r),s+=+T.getHeightFromTerrainHeightData(e+1,t,n,i,r),s+=+T.getHeightFromTerrainHeightData(e+1,t+1,n,i,r),o=-1*T.getHeightFromTerrainHeightData(e-1,t-1,n,i,r),o+=-1*T.getHeightFromTerrainHeightData(e,t-1,n,i,r),o+=-1*T.getHeightFromTerrainHeightData(e+1,t-1,n,i,r),o+=+T.getHeightFromTerrainHeightData(e-1,t+1,n,i,r),o+=+T.getHeightFromTerrainHeightData(e,t+1,n,i,r),o+=+T.getHeightFromTerrainHeightData(e+1,t+1,n,i,r),a.x=-s,a.y=6,a.z=-o,hn.normalize(a,a)},e.calcVertextNormlUV=function(e,t,n,i,r){r.x=e/n,r.y=t/i,r.z=t/i},e.calcVertextBuffer=function(e,t,n,i,r,a,o,s,l,h,_,u){1!=u||T.__ADAPT_MATRIX__||(T.__ADAPT_MATRIX__=new Jt,u=new Jt,Jt.createRotationY(Math.PI,T.__ADAPT_MATRIX__),Jt.createTranslate(new hn(0,0,(_-1)*r),u),Jt.multiply(u,T.__ADAPT_MATRIX__,T.__ADAPT_MATRIX__),T.__ADAPT_MATRIX_INV__=new Jt,T.__ADAPT_MATRIX__.invert(T.__ADAPT_MATRIX_INV__)),this._gridSize=r,this._beginGridX=e*T.CHUNK_GRID_NUM+n,this._beginGridZ=t*T.CHUNK_GRID_NUM+i;for(var d=o*s,c=2147483647,f=-2147483648,m=new hn,p=0,E=T.LEAF_GRID_NUM+1;p<E;p++)for(var v=0,g=T.LEAF_GRID_NUM+1;v<g;v++)T.__VECTOR3__.x=(this._beginGridX+v)*this._gridSize,T.__VECTOR3__.z=(this._beginGridZ+p)*this._gridSize,T.__VECTOR3__.y=l[(this._beginGridZ+p)*h+(this._beginGridX+v)],c=T.__VECTOR3__.y<c?T.__VECTOR3__.y:c,f=T.__VECTOR3__.y>f?T.__VECTOR3__.y:f,T.__ADAPT_MATRIX__&&hn.transformV3ToV3(T.__VECTOR3__,T.__ADAPT_MATRIX__,T.__VECTOR3__),a[d]=T.__VECTOR3__.x,a[++d]=T.__VECTOR3__.y,a[++d]=T.__VECTOR3__.z,d++,this.calcVertextNormlUV(this._beginGridX+v,this._beginGridZ+p,h,_,m),a[d]=m.x,a[++d]=m.y,a[++d]=m.z,a[++d]=(n+v)/T.CHUNK_GRID_NUM,a[++d]=(i+p)/T.CHUNK_GRID_NUM,a[++d]=this._beginGridX+v,a[++d]=this._beginGridZ+p,d++;this._sizeOfY=new ln(c-1,f+1),this.calcLODErrors(l,h,_),this.calcOriginalBoudingBoxAndSphere()},e.calcSkirtVertextBuffer=function(e,t,n,i,r,a,o,s,l,h,_){this._gridSize=r,this._beginGridX=e*T.CHUNK_GRID_NUM+n,this._beginGridZ=t*T.CHUNK_GRID_NUM+i;for(var u=o*s,d=0,c=0,f=T.LEAF_GRID_NUM+1,m=new hn,p=0,E=0,d=0;d<2;d++)for(c=0;c<f;c++)T.__VECTOR3__.x=(this._beginGridX+c)*this._gridSize,T.__VECTOR3__.y=1==d?l[this._beginGridZ*h+(this._beginGridX+c)]:-this._gridSize,T.__VECTOR3__.z=(this._beginGridZ+0)*this._gridSize,T.__ADAPT_MATRIX__&&hn.transformV3ToV3(T.__VECTOR3__,T.__ADAPT_MATRIX__,T.__VECTOR3__),a[u]=T.__VECTOR3__.x,a[++u]=T.__VECTOR3__.y,a[++u]=T.__VECTOR3__.z,u++,p=0==d?this._beginGridZ-1:this._beginGridZ,this.calcVertextNormlUV(this._beginGridX+c,p,h,_,m),a[u]=m.x,a[++u]=m.y,a[++u]=m.z,a[++u]=(n+c)/T.CHUNK_GRID_NUM,a[++u]=(i+0)/T.CHUNK_GRID_NUM,a[++u]=this._beginGridX+c,a[++u]=p,u++;for(d=0;d<2;d++)for(c=0;c<f;c++)T.__VECTOR3__.x=(this._beginGridX+c)*this._gridSize,T.__VECTOR3__.y=0==d?l[(this._beginGridZ+T.LEAF_GRID_NUM)*h+(this._beginGridX+c)]:-this._gridSize,T.__VECTOR3__.z=(this._beginGridZ+T.LEAF_GRID_NUM)*this._gridSize,T.__ADAPT_MATRIX__&&hn.transformV3ToV3(T.__VECTOR3__,T.__ADAPT_MATRIX__,T.__VECTOR3__),a[u]=T.__VECTOR3__.x,a[++u]=T.__VECTOR3__.y,a[++u]=T.__VECTOR3__.z,u++,p=0==d?this._beginGridZ+T.LEAF_GRID_NUM:this._beginGridZ+T.LEAF_GRID_NUM+1,this.calcVertextNormlUV(this._beginGridX+c,p,h,_,m),a[u]=m.x,a[++u]=m.y,a[++u]=m.z,a[++u]=(n+c)/T.CHUNK_GRID_NUM,a[++u]=(i+T.LEAF_GRID_NUM)/T.CHUNK_GRID_NUM,a[++u]=this._beginGridX+c,a[++u]=p,u++;for(d=0;d<2;d++)for(c=0;c<f;c++)T.__VECTOR3__.x=(this._beginGridX+0)*this._gridSize,T.__VECTOR3__.y=0==d?l[(this._beginGridZ+c)*h+(this._beginGridX+0)]:-this._gridSize,T.__VECTOR3__.z=(this._beginGridZ+c)*this._gridSize,T.__ADAPT_MATRIX__&&hn.transformV3ToV3(T.__VECTOR3__,T.__ADAPT_MATRIX__,T.__VECTOR3__),a[u]=T.__VECTOR3__.x,a[++u]=T.__VECTOR3__.y,a[++u]=T.__VECTOR3__.z,u++,E=0==d?this._beginGridX:this._beginGridX-1,this.calcVertextNormlUV(E,this._beginGridZ+c,h,_,m),a[u]=m.x,a[++u]=m.y,a[++u]=m.z,a[++u]=(n+0)/T.CHUNK_GRID_NUM,a[++u]=(i+c)/T.CHUNK_GRID_NUM,a[++u]=E,a[++u]=this._beginGridZ+c,u++;for(d=0;d<2;d++)for(c=0;c<f;c++)T.__VECTOR3__.x=(this._beginGridX+T.LEAF_GRID_NUM)*this._gridSize,T.__VECTOR3__.y=1==d?l[(this._beginGridZ+c)*h+(this._beginGridX+T.LEAF_GRID_NUM)]:-this._gridSize,T.__VECTOR3__.z=(this._beginGridZ+c)*this._gridSize,T.__ADAPT_MATRIX__&&hn.transformV3ToV3(T.__VECTOR3__,T.__ADAPT_MATRIX__,T.__VECTOR3__),a[u]=T.__VECTOR3__.x,a[++u]=T.__VECTOR3__.y,a[++u]=T.__VECTOR3__.z,u++,E=0==d?this._beginGridX+T.LEAF_GRID_NUM+1:this._beginGridX+T.LEAF_GRID_NUM,this.calcVertextNormlUV(E,this._beginGridZ+c,h,_,m),a[u]=m.x,a[++u]=m.y,a[++u]=m.z,a[++u]=(n+T.LEAF_GRID_NUM)/T.CHUNK_GRID_NUM,a[++u]=(i+c)/T.CHUNK_GRID_NUM,a[++u]=E,a[++u]=this._beginGridZ+c,u++},e.calcOriginalBoudingBoxAndSphere=function(){var e=new hn(this._beginGridX*this._gridSize,this._sizeOfY.x,this._beginGridZ*this._gridSize),t=new hn((this._beginGridX+T.LEAF_GRID_NUM)*this._gridSize,this._sizeOfY.y,(this._beginGridZ+T.LEAF_GRID_NUM)*this._gridSize);T.__ADAPT_MATRIX__&&(hn.transformV3ToV3(e,T.__ADAPT_MATRIX__,e),hn.transformV3ToV3(t,T.__ADAPT_MATRIX__,t)),this._originalBoundingBox=new kt(e,t);var n=new hn;hn.subtract(t,e,n),hn.scale(n,.5,n);t=new hn;hn.add(e,n,t),this._originalBoundingSphere=new Yt(t,hn.scalarLength(n)),this._originalBoundingBoxCorners=v(8,null),this._originalBoundingBox.getCorners(this._originalBoundingBoxCorners),this._boundingBox=new kt(new hn(-.5,-.5,-.5),new hn(.5,.5,.5)),this._boundingSphere=new Yt(new hn(0,0,0),1)},e.calcLeafBoudingBox=function(e){for(var t=0;t<8;t++)hn.transformCoordinate(this._originalBoundingBoxCorners[t],e,Gn._tempBoundBoxCorners[t]);kt.createfromPoints(Gn._tempBoundBoxCorners,this._boundingBox)},e.calcLeafBoudingSphere=function(e,t){hn.transformCoordinate(this._originalBoundingSphere.center,e,this._boundingSphere.center),this._boundingSphere.radius=this._originalBoundingSphere.radius*t},e.calcLODErrors=function(e,t,n){this._LODError=new Float32Array(T._maxLODLevel+1);for(var i=1,r=0,a=T._maxLODLevel+1;r<a;r++){for(var o=0,s=0,l=T.LEAF_GRID_NUM;s<l;s+=i)for(var h=0,_=T.LEAF_GRID_NUM;h<_;h+=i)for(var u=e[(this._beginGridZ+s)*t+(this._beginGridX+h)],d=e[(this._beginGridZ+s)*t+(this._beginGridX+h)+i],c=e[(this._beginGridZ+s+i)*t+(this._beginGridX+h)],f=e[(this._beginGridZ+s+i)*t+(this._beginGridX+h)+i],m=0;m<i;m++)for(var p=m/i,E=0;E<i;E++)var v=E/i,g=e[(this._beginGridZ+s+m)*t+(this._beginGridX+h)+E],g=Math.abs((v+p<=1?u+(d-u)*v+(c-u)*p:f+(c-f)*(1-v)+(d-f)*(1-p))-g),o=Math.max(o,g);i*=2,this._LODError[r]=o}},e.determineLod=function(e,t,n,i){var r=hn.distance(e,this._boundingSphere.center),e=T._maxLODLevel;if(!i){if(this._lastDistanceToEye==r)return this._currentLODLevel;this._lastDistanceToEye>r&&(e=this._currentLODLevel)}for(var a=e;1<=a;a--)if(_r.LOD_DISTANCE_FACTOR*this._LODError[a]/r*t<n){this._currentLODLevel=a;break}return this._lastDistanceToEye=r,this._currentLODLevel},T.__init__=function(){if(!T._bInit){var e=T.CHUNK_GRID_NUM/T.LEAF_GRID_NUM*(T.CHUNK_GRID_NUM/T.LEAF_GRID_NUM);T._planeLODIndex=v(e);for(var t=0,n=0,i=0,r=0,a=0,o=0,s=null,l=null,t=0;t<e;t++)T._planeLODIndex[t]=new Array(T._maxLODLevel+1);for(t=0,r=T._maxLODLevel+1;t<r;t++)T._planeLODIndex[0][t]=T.calcPlaneLODIndex(t);for(t=1;t<e;t++)for(o=t*T.LEAF_PLANE_VERTEXT_COUNT,n=0,a=T._maxLODLevel+1;n<a;n++){for(s=T._planeLODIndex[0][n],l=new Uint16Array(s.length),i=0;i<s.length;i++)l[i]=s[i]+o;T._planeLODIndex[t][n]=l}for(T._skirtLODIndex=v(e),t=0;t<e;t++)T._skirtLODIndex[t]=new Array(T._maxLODLevel+1);for(t=0,r=T._maxLODLevel+1;t<r;t++)T._skirtLODIndex[0][t]=T.calcSkirtLODIndex(t);for(t=1;t<e;t++)for(o=t*T.LEAF_SKIRT_VERTEXT_COUNT,n=0,a=T._maxLODLevel+1;n<a;n++){for(s=T._skirtLODIndex[0][n],l=new Uint16Array(s.length),i=0;i<s.length;i++)l[i]=s[i]+o;T._skirtLODIndex[t][n]=l}T._bInit=!0}},T.getPlaneLODIndex=function(e,t){return T._planeLODIndex[e][t]},T.getSkirtLODIndex=function(e,t){return T._skirtLODIndex[e][t]},T.calcPlaneLODIndex=function(e){e>T._maxLODLevel&&(e=T._maxLODLevel);for(var t=T.LEAF_GRID_NUM+1,n=0,i=null,e=laya.d3.terrain.TerrainLeaf.LEAF_GRID_NUM/Math.pow(2,e),i=new Uint16Array(e*e*6),r=laya.d3.terrain.TerrainLeaf.LEAF_GRID_NUM/e,a=0;a<T.LEAF_GRID_NUM;a+=r)for(var o=0;o<T.LEAF_GRID_NUM;o+=r)i[n]=(a+r)*t+o,i[++n]=a*t+o,i[++n]=a*t+o+r,i[++n]=a*t+o+r,i[++n]=(a+r)*t+o+r,i[++n]=(a+r)*t+o,n++;return i},T.calcSkirtLODIndex=function(e){e>T._maxLODLevel&&(e=T._maxLODLevel);for(var t=T.CHUNK_GRID_NUM/T.LEAF_GRID_NUM*(T.CHUNK_GRID_NUM/T.LEAF_GRID_NUM)*T.LEAF_PLANE_VERTEXT_COUNT,n=T.LEAF_GRID_NUM+1,i=0,r=null,e=laya.d3.terrain.TerrainLeaf.LEAF_GRID_NUM/Math.pow(2,e),r=new Uint16Array(4*e*6),a=laya.d3.terrain.TerrainLeaf.LEAF_GRID_NUM/e,o=0;o<4;o++){for(var s=0;s<T.LEAF_GRID_NUM;s+=a)r[i]=t+n+s,r[++i]=t+s,r[++i]=t+s+a,r[++i]=t+s+a,r[++i]=t+n+s+a,r[++i]=t+n+s,i++;t+=2*n}return r},T.getHeightFromTerrainHeightData=function(e,t,n,i,r){return n[(t=r<=(t=t<0?0:t)?r-1:t)*i+(e=i<=(e=e<0?0:e)?i-1:e)]},T.CHUNK_GRID_NUM=64,T.LEAF_GRID_NUM=32,T.__ADAPT_MATRIX__=null,T.__ADAPT_MATRIX_INV__=null,T._planeLODIndex=null,T._skirtLODIndex=null,T._bInit=!1,l(T,["LEAF_PLANE_VERTEXT_COUNT",function(){return this.LEAF_PLANE_VERTEXT_COUNT=(T.LEAF_GRID_NUM+1)*(T.LEAF_GRID_NUM+1)},"LEAF_SKIRT_VERTEXT_COUNT",function(){return this.LEAF_SKIRT_VERTEXT_COUNT=2*(T.LEAF_GRID_NUM+1)*4},"LEAF_VERTEXT_COUNT",function(){return this.LEAF_VERTEXT_COUNT=T.LEAF_PLANE_VERTEXT_COUNT+T.LEAF_SKIRT_VERTEXT_COUNT},"LEAF_PLANE_MAX_INDEX_COUNT",function(){return this.LEAF_PLANE_MAX_INDEX_COUNT=T.LEAF_GRID_NUM*T.LEAF_GRID_NUM*6},"LEAF_SKIRT_MAX_INDEX_COUNT",function(){return this.LEAF_SKIRT_MAX_INDEX_COUNT=4*T.LEAF_GRID_NUM*6},"LEAF_MAX_INDEX_COUNT",function(){return this.LEAF_MAX_INDEX_COUNT=T.LEAF_PLANE_MAX_INDEX_COUNT+T.LEAF_SKIRT_MAX_INDEX_COUNT},"__VECTOR3__",function(){return this.__VECTOR3__=new hn},"_maxLODLevel",function(){return this._maxLODLevel=Math.log2(T.LEAF_GRID_NUM)}]),T}(),Sn=(p(Dn,"laya.d3.terrain.unit.ChunkInfo"),Dn);function Dn(){this.alphaMap=null,this.detailID=null,this.normalMap=null}var xn=(p(Mn,"laya.d3.terrain.unit.DetailTextureInfo"),Mn);function Mn(){this.diffuseTexture=null,this.normalTexture=null,this.scale=null,this.offset=null}var Rn=(p(In,"laya.d3.terrain.unit.MaterialInfo"),In);function In(){this.ambientColor=null,this.diffuseColor=null,this.specularColor=null}var An=(p(Cn,"laya.d3.utils.Physics"),Cn.__init__=function(){Cn._layerCollsionMatrix.length=31;for(var e=0;e<31;e++){var t=[],n=31-e;t.length=n;for(var i=0;i<n;i++)t[i]=i===n-1;Cn._layerCollsionMatrix[e]=t}},Cn.setLayerCollision=function(e,t,n){Cn._layerCollsionMatrix[e.number][30-t.number]=n},Cn.getLayerCollision=function(e,t){return Cn._layerCollsionMatrix[e.number][30-t.number]},Cn.setColliderCollision=function(e,t,n){n?(delete e._ignoreCollisonMap[t.id],delete t._ignoreCollisonMap[e.id]):(e._ignoreCollisonMap[t.id]=t)._ignoreCollisonMap[e.id]=e},Cn.getIColliderCollision=function(e,t){return!!e._ignoreCollisonMap[t.id]},Cn.rayCast=function(e,t,n,i){void 0===n&&(n=179e306),void 0===i&&(i=0),Cn._outHitAllInfo.length=0;for(var r=Z.getLayerByNumber(i)._colliders,a=0,o=r.length;a<o;a++){var s=r[a];s.enable&&(s.raycast(e,Cn._outHitInfo,n),-1!==Cn._outHitInfo.distance&&Cn._outHitInfo.distance<=n&&(s=new Nn,Cn._outHitInfo.cloneTo(s),Cn._outHitAllInfo.push(s)))}if(0==Cn._outHitAllInfo.length)return t.sprite3D=null,void(t.distance=-1);for(var l=Number.MAX_VALUE,h=0,_=0;_<Cn._outHitAllInfo.length;_++)Cn._outHitAllInfo[_].distance<l&&(l=Cn._outHitAllInfo[_].distance,h=_);Cn._outHitAllInfo[h].cloneTo(t)},Cn.rayCastAll=function(e,t,n,i){void 0===n&&(n=179e306),void 0===i&&(i=0),t.length=0;for(var r=Z.getLayerByNumber(i)._colliders,a=0,o=r.length;a<o;a++){var s=r[a];s.enable&&(Cn._outHitInfo.distance=-1,Cn._outHitInfo.sprite3D=null,s.raycast(e,Cn._outHitInfo,n),-1!==Cn._outHitInfo.distance&&Cn._outHitInfo.distance<=n&&(s=new Nn,Cn._outHitInfo.cloneTo(s),t.push(s)))}},Cn._outHitAllInfo=[],Cn._layerCollsionMatrix=[],l(Cn,["_outHitInfo",function(){return this._outHitInfo=new Nn},"collisionManager",function(){return this.collisionManager=new Wn},"gravity",function(){return this.gravity=new hn(0,-9.81,0)}]),Cn);function Cn(){}var yn=(p(On,"laya.d3.utils.Picker"),On.calculateCursorRay=function(e,t,n,i,r,a){var o=e.elements[0],s=e.elements[1],l=On._tempVector30,h=l.elements;h[0]=o,h[1]=s,h[2]=t.minDepth;e=On._tempVector31,h=e.elements;h[0]=o,h[1]=s,h[2]=t.maxDepth;s=a.origin,h=On._tempVector32;t.unprojectFromWVP(l,n,i,r,s),t.unprojectFromWVP(e,n,i,r,h);r=a.direction.elements;r[0]=h.x-s.x,r[1]=h.y-s.y,r[2]=h.z-s.z,hn.normalize(a.direction,a.direction)},On.rayIntersectsPositionsAndIndices=function(e,t,n,i,r){for(var a=n.vertexStride/4,o=n.getVertexElementByUsage(0).offset/4,s=Number.MAX_VALUE,l=-1,h=-1,_=-1,u=0;u<i.length;u+=3){var d=On._tempVector35,c=d.elements,f=i[u]*a,m=f+o;c[0]=t[m],c[1]=t[1+m],c[2]=t[2+m];var p=On._tempVector36,E=p.elements,v=i[u+1]*a,g=v+o;E[0]=t[g],E[1]=t[1+g],E[2]=t[2+g];c=On._tempVector37,m=c.elements,E=i[u+2]*a,g=E+o;m[0]=t[g],m[1]=t[1+g],m[2]=t[2+g];c=laya.d3.utils.Picker.rayIntersectsTriangle(e,d,p,c);!isNaN(c)&&c<s&&(s=c,l=f,h=v,_=E)}if(s===Number.MAX_VALUE)return r.position.toDefault(),r.distance=Number.MAX_VALUE,r.trianglePositions[0].toDefault(),r.trianglePositions[1].toDefault(),r.trianglePositions[2].toDefault(),r.triangleNormals[0].toDefault(),r.triangleNormals[1].toDefault(),r.triangleNormals[2].toDefault(),!1;r.distance=s,hn.scale(e.direction,s,r.position),hn.add(e.origin,r.position,r.position);var T=r.trianglePositions,S=T[0],D=T[1],x=T[2],T=S.elements,S=D.elements,D=x.elements,x=l+o;T[0]=t[x],T[1]=t[x+1],T[2]=t[x+2];x=h+o;S[0]=t[x],S[1]=t[x+1],S[2]=t[x+2];S=_+o;D[0]=t[S],D[1]=t[S+1],D[2]=t[S+2];x=n.getVertexElementByUsage(3);return x&&(D=x.offset/4,n=(S=r.triangleNormals)[0],x=S[1],r=S[2],S=n.elements,n=x.elements,x=r.elements,S[0]=t[r=l+D],S[1]=t[r+1],S[2]=t[r+2],n[0]=t[r=h+D],n[1]=t[r+1],n[2]=t[r+2],x[0]=t[D=_+D],x[1]=t[D+1],x[2]=t[D+2]),!0},On.rayIntersectsTriangle=function(e,t,n,i){var r=On._tempVector30,a=On._tempVector31;hn.subtract(n,t,r),hn.subtract(i,t,a);var o=On._tempVector32;if(hn.cross(e.direction,a,o),(n=hn.dot(r,o))>-Number.MIN_VALUE&&n<Number.MIN_VALUE)return Number.NaN;i=1/n,n=On._tempVector33;if(hn.subtract(e.origin,t,n),t=hn.dot(n,o),(t*=i)<0||1<t)return Number.NaN;o=On._tempVector34;return hn.cross(n,r,o),e=hn.dot(e.direction,o),(e*=i)<0||1<t+e?Number.NaN:(o=hn.dot(a,o),(o*=i)<0?Number.NaN:o)},l(On,["_tempVector30",function(){return this._tempVector30=new hn},"_tempVector31",function(){return this._tempVector31=new hn},"_tempVector32",function(){return this._tempVector32=new hn},"_tempVector33",function(){return this._tempVector33=new hn},"_tempVector34",function(){return this._tempVector34=new hn},"_tempVector35",function(){return this._tempVector35=new hn},"_tempVector36",function(){return this._tempVector36=new hn},"_tempVector37",function(){return this._tempVector37=new hn}]),On);function On(){}var Nn=(p(Vn,"laya.d3.utils.RaycastHit"),Vn.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},Vn);function Vn(){this.distance=NaN,this.trianglePositions=null,this.triangleNormals=null,this.position=null,this.sprite3D=null,this.distance=-1,this.trianglePositions=[new hn,new hn,new hn],this.trianglePositions.length=3,this.triangleNormals=[new hn,new hn,new hn],this.triangleNormals.length=3,this.position=new hn}var Ln=function(){function e(e,t){this._width=0,this._height=0,this._width=e,this._height=t}p(e,"laya.d3.utils.Size");var t=e.prototype;return _(0,t,"width",function(){return-1===this._width?ve.clientWidth:this._width}),_(0,t,"height",function(){return-1===this._height?ve.clientHeight:this._height}),_(1,e,"fullScreen",function(){return new e(-1,-1)}),e}(),wn=(p(Fn,"laya.d3.utils.Utils3D"),Fn._rotationTransformScaleSkinAnimation=function(e,t,n,i,r,a,o,s,l,h,_,u){var d,c,f,m,p,E=Fn._tempArray16_0,v=Fn._tempArray16_1,g=Fn._tempArray16_2,T=i+i,S=r+r,D=a+a,x=i*T,M=r*T,R=r*S,i=a*T,r=a*S,a=a*D,T=o*T,S=o*S,D=o*D;for(E[15]=1,E[0]=1-R-a,E[1]=M+D,E[2]=i-S,E[4]=M-D,E[5]=1-x-a,E[6]=r+T,E[8]=i+S,E[9]=r-T,E[10]=1-x-R,v[15]=1,v[0]=s,v[5]=l,v[10]=h,d=0;d<4;d++)c=E[d],f=E[d+4],m=E[d+8],p=E[d+12],g[d]=c,g[d+4]=f,g[d+8]=m,g[d+12]=c*e+f*t+m*n+p;for(d=0;d<4;d++)c=g[d],f=g[d+4],m=g[d+8],p=g[d+12],_[d+u]=c*v[0]+f*v[1]+m*v[2]+p*v[3],_[d+u+4]=c*v[4]+f*v[5]+m*v[6]+p*v[7],_[d+u+8]=c*v[8]+f*v[9]+m*v[10]+p*v[11],_[d+u+12]=c*v[12]+f*v[13]+m*v[14]+p*v[15]},Fn._createNodeByJson=function(e,t,n,i){if(!n)switch(t.type){case"Sprite3D":n=new Ci;break;case"MeshSprite3D":n=new fr;break;case"SkinnedMeshSprite3D":n=new pr;break;case"ShuriKenParticle3D":n=new mr;break;case"TrailSprite3D":n=new Er;break;case"Terrain":n=new _r;break;case"Camera":n=new dr;break;case"DirectionLight":n=new cr;break;default:throw new Error("Utils3D:unidentified class type in (.lh) file.")}var r=t.props;if(r)for(var a in r)n[a]=r[a];var o=t.customProps;o&&(n instanceof laya.d3.core.Sprite3D?(n._parseBaseCustomProps(o),n._parseCustomProps(e,i,o,t),n._parseCustomComponent(e,i,t.components)):n._parseCustomProps(e,i,o,t));var s=t.child;if(s)for(var l=0,h=s.length;l<h;l++){var _=Fn._createNodeByJson(e,s[l],null,i);n.addChild(_)}return n},Fn._computeBoneAndAnimationDatasByBindPoseMatrxix=function(e,t,n,i,r,a){for(var o,s=0,l=0,h=e.length,_=0;_<h;s+=e[_].keyframeWidth,l+=16,_++)laya.d3.utils.Utils3D._rotationTransformScaleSkinAnimation(t[s+0],t[s+1],t[s+2],t[s+3],t[s+4],t[s+5],t[s+6],t[s+7],t[s+8],t[s+9],i,l),0!=_&&(o=16*e[_].parentIndex,laya.d3.utils.Utils3D.mulMatrixByArray(i,o,i,l,i,l));var u=n.length;for(_=0;_<u;_++)laya.d3.utils.Utils3D.mulMatrixByArrayAndMatrixFast(i,16*a[_],n[_],r,16*_)},Fn._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)},Fn._computeBoneAndAnimationDatasByBindPoseMatrxixOld=function(e,t,n,i,r){for(var a,o=0,s=0,l=e.length,h=0;h<l;o+=e[h].keyframeWidth,s+=16,h++)laya.d3.utils.Utils3D._rotationTransformScaleSkinAnimation(t[o+7],t[o+8],t[o+9],t[o+3],t[o+4],t[o+5],t[o+6],t[o+0],t[o+1],t[o+2],i,s),0!=h&&(a=16*e[h].parentIndex,laya.d3.utils.Utils3D.mulMatrixByArray(i,a,i,s,i,s));var _=n.length;for(h=0;h<_;h++){var u=16*h;laya.d3.utils.Utils3D.mulMatrixByArrayAndMatrixFast(i,u,n[h],r,u)}},Fn._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)}},Fn._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)},Fn.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],n=a[3],e=n*o+_*l-u*s,t=n*s+u*o-h*l,a=n*l+h*s-_*o,l=-h*o-_*s-u*l;i[r]=e*n+l*-h+t*-u-a*-_,i[r+1]=t*n+l*-_+a*-h-e*-u,i[r+2]=a*n+l*-u+e*-_-t*-h},Fn.mulMatrixByArray=function(e,t,n,i,r,a){var o,s,l,h,_;if(r===n){for(n=Fn._tempArray16_3,o=0;o<16;++o)n[o]=r[a+o];i=0}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]},Fn.mulMatrixByArrayFast=function(e,t,n,i,r,a){for(var o,s,l,h,_=0;_<4;_++)o=e[t+_],s=e[t+_+4],l=e[t+_+8],h=e[t+_+12],r[a+_]=o*n[i+0]+s*n[i+1]+l*n[i+2]+h*n[i+3],r[a+_+4]=o*n[i+4]+s*n[i+5]+l*n[i+6]+h*n[i+7],r[a+_+8]=o*n[i+8]+s*n[i+9]+l*n[i+10]+h*n[i+11],r[a+_+12]=o*n[i+12]+s*n[i+13]+l*n[i+14]+h*n[i+15]},Fn.mulMatrixByArrayAndMatrixFast=function(e,t,n,i,r){for(var a,o,s,l,n=n.elements,h=n[0],_=n[1],u=n[2],d=n[3],c=n[4],f=n[5],m=n[6],p=n[7],E=n[8],v=n[9],g=n[10],T=n[11],S=n[12],D=n[13],x=n[14],M=n[15],R=t,I=t+4,A=t+8,C=t+12,y=r,O=r+4,N=r+8,V=r+12,L=0;L<4;L++)a=e[R+L],o=e[I+L],s=e[A+L],l=e[C+L],i[y+L]=a*h+o*_+s*u+l*d,i[O+L]=a*c+o*f+s*m+l*p,i[N+L]=a*E+o*v+s*g+l*T,i[V+L]=a*S+o*D+s*x+l*M},Fn.createAffineTransformationArray=function(e,t,n,i,r,a,o,s,l,h,_,u){var d=i+i,c=r+r,f=a+a,m=i*d,p=i*c,E=i*f,i=r*c,r=r*f,a=a*f,d=o*d,c=o*c,f=o*f;_[u+0]=(1-(i+a))*s,_[u+1]=(p+f)*s,_[u+2]=(E-c)*s,_[u+3]=0,_[u+4]=(p-f)*l,_[u+5]=(1-(m+a))*l,_[u+6]=(r+d)*l,_[u+7]=0,_[u+8]=(E+c)*h,_[u+9]=(r-d)*h,_[u+10]=(1-(m+i))*h,_[u+11]=0,_[u+12]=e,_[u+13]=t,_[u+14]=n,_[u+15]=1},Fn.transformVector3ArrayToVector3ArrayCoordinate=function(e,t,n,i,r){var a=Fn._tempArray4_0,o=e[t+0],s=e[t+1],t=e[t+2],n=n.elements;a[0]=o*n[0]+s*n[4]+t*n[8]+n[12],a[1]=o*n[1]+s*n[5]+t*n[9]+n[13],a[2]=o*n[2]+s*n[6]+t*n[10]+n[14],a[3]=1/(o*n[3]+s*n[7]+t*n[11]+n[15]),i[r+0]=a[0]*a[3],i[r+1]=a[1]*a[3],i[r+2]=a[2]*a[3]},Fn.transformLightingMapTexcoordByUV0Array=function(e,t,n,i,r){n=n.elements;i[r+0]=e[t+0]*n[0]+n[2],i[r+1]=(e[t+1]-1)*n[1]+n[3]},Fn.transformLightingMapTexcoordByUV1Array=function(e,t,n,i,r){n=n.elements;i[r+0]=e[t+0]*n[0]+n[2],i[r+1]=1+e[t+1]*n[1]+n[3]},Fn.getURLVerion=function(e){var t=e.indexOf("?");return 0<=t?e.substr(t):null},Fn._quaternionCreateFromYawPitchRollArray=function(e,t,n,i){var r=.5*n,a=.5*t,o=.5*e,n=Math.sin(r),t=Math.cos(r),e=Math.sin(a),r=Math.cos(a),a=Math.sin(o),o=Math.cos(o);i[0]=o*e*t+a*r*n,i[1]=a*r*t-o*e*n,i[2]=o*r*n-a*e*t,i[3]=o*r*t+a*e*n},Fn._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,d=r*h,c=r*_,t=a*h,r=a*_,a=o*_,o=s*l,l=s*h,h=s*_,s=n[0],_=n[1],n=n[2];i[0]=(1-(t+a))*s,i[1]=(d+h)*s,i[2]=(c-l)*s,i[3]=0,i[4]=(d-h)*_,i[5]=(1-(u+a))*_,i[6]=(r+o)*_,i[7]=0,i[8]=(c+l)*n,i[9]=(r-o)*n,i[10]=(1-(u+t))*n,i[11]=0,i[12]=e[0],i[13]=e[1],i[14]=e[2],i[15]=1},Fn._mulMatrixArray=function(e,t,n,i){for(var r,a,o,s,t=t.elements,l=t[0],h=t[1],_=t[2],u=t[3],d=t[4],c=t[5],f=t[6],m=t[7],p=t[8],E=t[9],v=t[10],g=t[11],T=t[12],S=t[13],D=t[14],x=t[15],M=i,R=i+4,I=i+8,A=i+12,C=0;C<4;C++)r=e[C],a=e[C+4],o=e[C+8],s=e[C+12],n[M+C]=r*l+a*h+o*_+s*u,n[R+C]=r*d+a*c+o*f+s*m,n[I+C]=r*p+a*E+o*v+s*g,n[A+C]=r*T+a*S+o*D+s*x},Fn.getYawPitchRoll=function(e,t){Fn.transformQuat(hn.ForwardRH,e,rn.TEMPVector31),Fn.transformQuat(hn.Up,e,rn.TEMPVector32);var n=rn.TEMPVector32.elements;Fn.angleTo(hn.ZERO,rn.TEMPVector31,rn.TEMPVector33);e=rn.TEMPVector33.elements;e[0]==Math.PI/2?(e[1]=Fn.arcTanAngle(n[2],n[0]),e[2]=0):e[0]==-Math.PI/2?(e[1]=Fn.arcTanAngle(-n[2],-n[0]),e[2]=0):(Jt.createRotationY(-e[1],rn.TEMPMatrix0),Jt.createRotationX(-e[0],rn.TEMPMatrix1),hn.transformCoordinate(rn.TEMPVector32,rn.TEMPMatrix0,rn.TEMPVector32),hn.transformCoordinate(rn.TEMPVector32,rn.TEMPMatrix1,rn.TEMPVector32),e[2]=Fn.arcTanAngle(n[1],-n[0])),e[1]<=-Math.PI&&(e[1]=Math.PI),e[2]<=-Math.PI&&(e[2]=Math.PI),e[1]>=Math.PI&&e[2]>=Math.PI&&(e[1]=0,e[2]=0,e[0]=Math.PI-e[0]),t[0]=e[1],t[1]=e[0],t[2]=e[2]},Fn.arcTanAngle=function(e,t){return 0==e?1==t?Math.PI/2:-Math.PI/2:0<e?Math.atan(t/e):e<0?0<t?Math.atan(t/e)+Math.PI:Math.atan(t/e)-Math.PI:0},Fn.angleTo=function(e,t,n){hn.subtract(t,e,rn.TEMPVector30),hn.normalize(rn.TEMPVector30,rn.TEMPVector30),n.elements[0]=Math.asin(rn.TEMPVector30.y),n.elements[1]=Fn.arcTanAngle(-rn.TEMPVector30.z,-rn.TEMPVector30.x)},Fn.transformQuat=function(e,t,n){var i=n.elements,r=e.elements,a=r[0],o=r[1],s=r[2],l=t[0],h=t[1],_=t[2],n=t[3],e=n*a+h*s-_*o,r=n*o+_*a-l*s,t=n*s+l*o-h*a,s=-l*a-h*o-_*s;i[0]=e*n+s*-l+r*-_-t*-h,i[1]=r*n+s*-h+t*-l-e*-_,i[2]=t*n+s*-_+e*-h-r*-l},Fn.quaterionNormalize=function(e,t){var n=e[0],i=e[1],r=e[2],a=e[3],e=n*n+i*i+r*r+a*a;0<e&&(e=1/Math.sqrt(e),t[0]=n*e,t[1]=i*e,t[2]=r*e,t[3]=a*e)},Fn.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]},Fn.matrix4x4MultiplyMFM=function(e,t,n){Fn.matrix4x4MultiplyFFF(e.elements,t,n.elements)},l(Fn,["_typeToFunO",function(){return this._typeToFunO={INT16:"writeInt16",SHORT:"writeInt16",UINT16:"writeUint16",UINT32:"writeUint32",FLOAT32:"writeFloat32",INT:"writeInt32",UINT:"writeUint32",BYTE:"writeByte",STRING:"writeUTFString"}},"_tempVector3_0",function(){return this._tempVector3_0=new hn},"_tempVector3_1",function(){return this._tempVector3_1=new hn},"_tempVector3_2",function(){return this._tempVector3_2=new hn},"_tempVector3_3",function(){return this._tempVector3_3=new hn},"_tempVector3_4",function(){return this._tempVector3_4=new hn},"_tempVector3_5",function(){return this._tempVector3_5=new hn},"_tempVector3_6",function(){return this._tempVector3_6=new hn},"_tempArray4_0",function(){return this._tempArray4_0=new Float32Array(4)},"_tempArray16_0",function(){return this._tempArray16_0=new Float32Array(16)},"_tempArray16_1",function(){return this._tempArray16_1=new Float32Array(16)},"_tempArray16_2",function(){return this._tempArray16_2=new Float32Array(16)},"_tempArray16_3",function(){return this._tempArray16_3=new Float32Array(16)}]),Fn);function Fn(){}var Pn=(p(bn,"Laya3D"),bn._cancelLoadByUrl=function(e){S.loader.cancelLoadByUrl(e),bn._innerFirstLevelLoaderManager.cancelLoadByUrl(e),bn._innerSecondLevelLoaderManager.cancelLoadByUrl(e),bn._innerThirdLevelLoaderManager.cancelLoadByUrl(e),bn._innerFourthLevelLoaderManager.cancelLoadByUrl(e)},bn._changeWebGLSize=function(e,t){N.onStageResize(e,t),ve.clientWidth=e,ve.clientHeight=t},bn.__init__=function(){var e=u.createMap;e.lh=[Ci,"SPRITE3DHIERARCHY"],e.ls=[Ai,"SPRITE3DHIERARCHY"],e.lm=[er,"MESH"],e.lmat=[Pi,"MATERIAL"],e.lpbr=[Li,"MATERIAL"],e.ltc=[ar,"TEXTURECUBE"],e.jpg=[rr,"nativeimage"],e.jpeg=[rr,"nativeimage"],e.png=[rr,"nativeimage"],e.pkm=[rr,"arraybuffer"],e.lsani=[r,"arraybuffer"],e.lrani=[r,"arraybuffer"],e.raw=[$i,"arraybuffer"],e.mipmaps=[$i,"arraybuffer"],e.thdata=[si,"arraybuffer"],e.lt=[hi,"TERRAIN"],e.lani=[ni,"arraybuffer"],e.lav=[ii,"json"],e.ani=[r,"arraybuffer"],W.parserMap.SPRITE3DHIERARCHY=bn._loadHierarchy,W.parserMap.MESH=bn._loadMesh,W.parserMap.MATERIAL=bn._loadMaterial,W.parserMap.TEXTURECUBE=bn._loadTextureCube,W.parserMap.TERRAIN=bn._loadTerrain,bn._innerFirstLevelLoaderManager.on("error",null,bn._eventLoadManagerError),bn._innerSecondLevelLoaderManager.on("error",null,bn._eventLoadManagerError),bn._innerThirdLevelLoaderManager.on("error",null,bn._eventLoadManagerError),bn._innerFourthLevelLoaderManager.on("error",null,bn._eventLoadManagerError)},bn.READ_BLOCK=function(){return bn._readData.pos+=4,!0},bn.READ_DATA=function(){return bn._DATA.offset=bn._readData.getUint32(),bn._DATA.size=bn._readData.getUint32(),!0},bn.READ_STRINGS=function(){var e=[],t={offset:0,size:0};t.offset=bn._readData.getUint16(),t.size=bn._readData.getUint16();bn._readData.pos;bn._readData.pos=t.offset+bn._DATA.offset;for(var n=0;n<t.size;n++){var i=bn._readData.readUTFString();-1===i.lastIndexOf(".lmat")&&-1===i.lastIndexOf(".lpbr")||e.push(i)}return e},bn.formatRelativePath=function(e,t){var n;if("."===t.charAt(0)){for(var i,r=(e+t).split("/"),a=0,o=r.length;a<o;a++)".."!=r[a]||0<(i=a-1)&&".."!==r[i]&&(r.splice(i,2),a-=2);n=r.join("/")}else n=e+t;return n=null!=C.customFormat?C.customFormat(n,null):n},bn._eventLoadManagerError=function(e){S.loader.event("error",e)},bn._addHierarchyInnerUrls=function(e,t,n,i,r,a){i=bn.formatRelativePath(i,r);n&&(i+=n),e.push({url:i,clas:a}),t[r]=i},bn._getSprite3DHierarchyInnerUrls=function(e,t,n,i,r,a,o){var s=0,l=0;switch(e.type){case"Scene":for(var h=e.customProps.lightmaps,s=0,l=h.length;s<l;s++){var _=h[s].replace(".exr",".png");bn._addHierarchyInnerUrls(i,r,a,o,_,rr)}break;case"MeshSprite3D":case"TrailSprite3D":case"LineSprite3D":case"SkinnedMeshSprite3D":if(e.instanceParams)(m=e.instanceParams.loadPath)&&bn._addHierarchyInnerUrls(t,r,a,o,m,er);else{(m=(p=e.customProps).meshPath)&&bn._addHierarchyInnerUrls(t,r,a,o,m,er);var u=p.materials;if(u)for(s=0,l=u.length;s<l;s++){var d=u[s],c=d.type.split("."),f=x.window;if(c.forEach(function(e){f=f[e]}),"function"!=typeof f)throw"_getSprite3DHierarchyInnerUrls 错误: "+d.type+" 不是类";bn._addHierarchyInnerUrls(n,r,a,o,d.path,f)}}break;case"ShuriKenParticle3D":var m=(p=e.customProps).meshPath;m&&bn._addHierarchyInnerUrls(t,r,a,o,m,er);var p,m=p.material;m?(c=m.type.split("."),f=x.window,c.forEach(function(e){f=f[e]}),bn._addHierarchyInnerUrls(n,r,a,o,m.path,f)):(m=p.materialPath)?bn._addHierarchyInnerUrls(n,r,a,o,m,Hi):(p=p.texturePath)&&bn._addHierarchyInnerUrls(i,r,a,o,p,rr);break;case"Terrain":bn._addHierarchyInnerUrls(i,r,a,o,e.customProps.dataPath,hi)}var E,v=e.components;for(E in v){var g=v[E];if("Animator"===E){var T=g.avatarPath;T?bn._addHierarchyInnerUrls(i,r,a,o,T,ii):(T=g.avatar)&&bn._addHierarchyInnerUrls(i,r,a,o,T.path,ii);var S=g.clipPaths;for(s=0,l=S.length;s<l;s++)bn._addHierarchyInnerUrls(i,r,a,o,S[s],ni)}}var D=e.child;for(s=0,l=D.length;s<l;s++)bn._getSprite3DHierarchyInnerUrls(D[s],t,n,i,r,a,o)},bn._loadHierarchy=function(e){e.on("loaded",null,bn._onHierarchylhLoaded,[e,e._class._getGroup()]),e.load(e.url,"json",!1,null,!0)},bn._onHierarchylhLoaded=function(e,t,n){var i,r,a,o,s,l,h,_;e._class.destroyed?e.endLoad():(s=e.url,_=wn.getURLVerion(s),l=C.getPath(s),bn._getSprite3DHierarchyInnerUrls(n,i=[],r=[],a=[],o={},_,l),bn._onProcessChange(e,0,l=1/(_=(s=i.length+r.length+a.length)+1),1),0<a.length?(_=D.create(null,bn._onProcessChange,[e,l,h=s/_],!1),bn._innerFourthLevelLoaderManager.create(a,D.create(null,bn._onHierarchyInnerForthLevResouLoaded,[e,t,_,n,o,i,r,l+h*a.length,h]),_,null,null,1,!0,t)):bn._onHierarchyInnerForthLevResouLoaded(e,t,null,n,o,i,r,l,h))},bn._onHierarchyInnerForthLevResouLoaded=function(e,t,n,i,r,a,o,s,l){var h;e._class.destroyed?e.endLoad():(n&&n.recover(),0<o.length?(h=D.create(null,bn._onProcessChange,[e,s,l],!1),bn._innerSecondLevelLoaderManager.create(o,D.create(null,bn._onHierarchyInnerSecondLevResouLoaded,[e,t,h,i,r,a,s+l*o.length,l]),n,null,null,1,!0,t)):bn._onHierarchyInnerSecondLevResouLoaded(e,t,null,i,r,a,s,l))},bn._onHierarchyInnerSecondLevResouLoaded=function(e,t,n,i,r,a,o,s){e._class.destroyed?e.endLoad():(n&&n.recover(),0<a.length?(s=D.create(null,bn._onProcessChange,[e,o,s],!1),bn._innerFirstLevelLoaderManager.create(a,D.create(null,bn._onHierarchyInnerFirstLevResouLoaded,[e,s,i,r]),n,null,null,1,!0,t)):bn._onHierarchyInnerFirstLevResouLoaded(e,null,i,r))},bn._onHierarchyInnerFirstLevResouLoaded=function(e,t,n,i){t&&t.recover(),e.endLoad([n,i])},bn._loadTerrain=function(e){e.on("loaded",null,bn._onTerrainLtLoaded,[e,e._class._getGroup()]),e.load(e.url,"json",!1,null,!0)},bn._onTerrainLtLoaded=function(e,t,n){if(e._class.destroyed)e.endLoad();else{var i=e.url,r=wn.getURLVerion(i),a=C.getPath(i),o=[],s={},l=0,h=0,_=n.heightData,u=_.url;p=bn.formatRelativePath(a,u),r&&(p+=r),u=s[u]=p;for(var d=n.detailTexture,l=0,h=d.length;l<h;l++)o.push({url:d[l].diffuse});var c=n.normalMap;for(l=0,h=c.length;l<h;l++)o.push({url:c[l]});var f=n.alphaMap;for(l=0,h=f.length;l<h;l++)o.push({url:f[l],params:[!1,!1,6408,!0]});for(l=0,h=o.length;l<h;l++){var m=o[l].url,p=bn.formatRelativePath(a,m);r&&(p+=r),o[l].url=p,s[m]=p}var E=o.length,v=E+2,g=1/v;bn._onProcessChange(e,0,g,1);var T={heightMapLoaded:!1,texturesLoaded:!1},i=D.create(null,bn._onProcessChange,[e,g,g],!1);bn._innerFourthLevelLoaderManager.create(u,D.create(null,bn._onTerrainHeightMapLoaded,[e,i,n,s,T]),i,null,[_.numX,_.numZ,_.bitType,_.value],1,!0,t);v=D.create(null,bn._onProcessChange,[e,2*g,E/v],!1);bn._innerFourthLevelLoaderManager.create(o,D.create(null,bn._onTerrainTexturesLoaded,[e,v,n,s,T]),v,null,null,1,!0,t)}},bn._onTerrainHeightMapLoaded=function(e,t,n,i,r){r.heightMapLoaded=!0,r.texturesLoaded&&(e.endLoad([n,i]),t.recover())},bn._onTerrainTexturesLoaded=function(e,t,n,i,r){r.texturesLoaded=!0,r.heightMapLoaded&&(e.endLoad([n,i]),t.recover())},bn._loadMesh=function(e){e.on("loaded",null,bn._onMeshLmLoaded,[e,e._class._getGroup()]),e.load(e.url,"arraybuffer",!1,null,!0)},bn._onMeshLmLoaded=function(e,t,n){if(e._class.destroyed)e.endLoad();else{var i,r,a=e.url,o=wn.getURLVerion(a),s=C.getPath(a),l={},h=0;switch((bn._readData=new g(n)).pos=0,bn._readData.readUTFString()){case"LAYAMODEL:02":case"LAYAMODEL:03":case"LAYAMODEL:0301":var _=bn._readData.getUint32();bn._readData.pos=bn._readData.pos+4,d=bn._readData.getUint16(),bn._readData.pos=bn._readData.pos+8*d;var u=bn._readData.getUint32(),d=bn._readData.getUint16();for(bn._readData.pos=_+u,i=[],h=0;h<d;h++){var c=bn._readData.readUTFString();-1!==c.lastIndexOf(".lmat")&&i.push(c)}break;default:for(bn.READ_BLOCK(),h=0;h<2;h++){var f=bn._readData.getUint16(),m=bn._strings[f],p=bn["READ_"+m];if(null==p)throw new Error("model file err,no this function:"+f+" "+m);1===h?i=p.call():p.call()}}for(h=0,r=i.length;h<r;h++){var E=i[h],v=bn.formatRelativePath(s,E);o&&(v+=o),i[h]=v,l[E]=v}0<i.length?(bn._onProcessChange(e,0,.5,1),a=D.create(null,bn._onProcessChange,[e,.5,.5],!1),bn._innerSecondLevelLoaderManager.create(i,D.create(null,bn._onMeshMateialLoaded,[e,a,n,l]),a,null,null,1,!0,t)):e.endLoad([n,l])}},bn._onMeshMateialLoaded=function(e,t,n,i){e.endLoad([n,i]),t.recover()},bn._getMaterialTexturePath=function(e,t,n){var i=e.length-4;return e.indexOf(".dds")!=i&&e.indexOf(".tga")!=i&&e.indexOf(".exr")!=i&&e.indexOf(".DDS")!=i&&e.indexOf(".TGA")!=i&&e.indexOf(".EXR")!=i||(e=e.substr(0,i)+".png"),e=bn.formatRelativePath(n,e),t&&(e+=t),e},bn._loadMaterial=function(e){e.on("loaded",null,bn._onMaterilLmatLoaded,[e,e._class._getGroup()]),e.load(e.url,"json",!1,null,!0)},bn._onMaterilLmatLoaded=function(e,t,n){if(e._class.destroyed)e.endLoad();else{var i,r=e.url,a=wn.getURLVerion(r),o=C.getPath(r),s=[],l={},h=n.customProps,r=n.version;if(r)switch(r){case"LAYAMATERIAL:01":case"LAYAMATERIAL:02":for(var _=n.props.textures,u=0,d=_.length;u<d;u++){var c,f=_[u],m=f.path;m&&(c=m.length-4,m.indexOf(".exr")!=c&&m.indexOf(".EXR")!=c||(m=m.substr(0,c)+".png"),i=bn.formatRelativePath(o,m),a&&(i+=a),s.push({url:i,params:f.params}),l[m]=i)}break;default:throw new Error("Laya3D:unkonwn version.")}else{var p,r=h.diffuseTexture.texture2D;r&&(i=bn._getMaterialTexturePath(r,a,o),s.push(i),l[r]=i),!h.normalTexture||(r=h.normalTexture.texture2D)&&(i=bn._getMaterialTexturePath(r,a,o),s.push(i),l[r]=i),!h.specularTexture||(p=h.specularTexture.texture2D)&&(i=bn._getMaterialTexturePath(p,a,o),s.push(i),l[p]=i),!h.emissiveTexture||(p=h.emissiveTexture.texture2D)&&(i=bn._getMaterialTexturePath(p,a,o),s.push(i),l[p]=i),!h.ambientTexture||(E=h.ambientTexture.texture2D)&&(i=bn._getMaterialTexturePath(E,a,o),s.push(i),l[E]=i),!h.reflectTexture||(v=h.reflectTexture.texture2D)&&(i=bn._getMaterialTexturePath(v,a,o),s.push(i),l[v]=i)}var E=s.length,h=E+1,v=1/h;bn._onProcessChange(e,0,v,1),0<E?(h=D.create(null,bn._onProcessChange,[e,v,E/h],!1),bn._innerFourthLevelLoaderManager.create(s,D.create(null,bn._onMateialTexturesLoaded,[e,h,n,l]),h,rr,null,1,!0,t)):bn._onMateialTexturesLoaded(e,null,n,null)}},bn._onMateialTexturesLoaded=function(e,t,n,i){e.endLoad([n,i]),t&&t.recover()},bn._loadTextureCube=function(e){e.on("loaded",null,bn._onTextureCubeLtcLoaded,[e]),e.load(e.url,"json",!1,null,!0)},bn._onTextureCubeLtcLoaded=function(e,t){var n;e._class.destroyed?e.endLoad():(n=C.getPath(e.url),n=[bn.formatRelativePath(n,t.px),bn.formatRelativePath(n,t.nx),bn.formatRelativePath(n,t.py),bn.formatRelativePath(n,t.ny),bn.formatRelativePath(n,t.pz),bn.formatRelativePath(n,t.nz)],bn._onProcessChange(e,0,1/7,1),t=D.create(null,bn._onProcessChange,[e,1/7,6/7],!1),bn._innerFourthLevelLoaderManager.load(n,D.create(null,bn._onTextureCubeImagesLoaded,[e,n,t]),t,"nativeimage"))},bn._onTextureCubeImagesLoaded=function(e,t,n){var i=[];i.length=6;for(var r=0;r<6;r++){var a=t[r];i[r]=W.getRes(a),W.clearRes(a)}e.endLoad(i),n.recover()},bn._onProcessChange=function(e,t,n,i){(i=t+i*n)<1&&e.event("progress",i)},bn.init=function(e,t,n,i,r,a){void 0===n&&(n=!1),void 0===i&&(i=!1),void 0===r&&(r=!0),void 0===a&&(a=!0),bn._isinit||(bn._isinit=!0,M.update3DLoop=function(){Wn._triggerCollision()},M.cancelLoadByUrl=function(e){bn._cancelLoadByUrl(e)},h.isAntialias=n,h.isAlpha=i,h.premultipliedAlpha=r,h.isStencil=a,N.enable()?(M.changeWebGLSize=bn._changeWebGLSize,m.is3DMode=!0,S.init(e,t),Z.__init__(),An.__init__(),Oi.__init__(),pn.__init__(),fr.__init__(),U.__init__(),bn.__init__(),o.maxTextureCount=2,(bn.debugMode||Te.debugMode)&&(bn._debugPhasorSprite=new me)):alert("Laya3D init error,must support webGL!"))},bn.HIERARCHY="SPRITE3DHIERARCHY",bn.MESH="MESH",bn.MATERIAL="MATERIAL",bn.PBRMATERIAL="PBRMTL",bn.TEXTURECUBE="TEXTURECUBE",bn.TERRAIN="TERRAIN",bn._readData=null,bn._debugPhasorSprite=null,bn.debugMode=!1,bn._isinit=!1,l(bn,["_DATA",function(){return this._DATA={offset:0,size:0}},"_strings",function(){return this._strings=["BLOCK","DATA","STRINGS"]},"_innerFirstLevelLoaderManager",function(){return this._innerFirstLevelLoaderManager=new u},"_innerSecondLevelLoaderManager",function(){return this._innerSecondLevelLoaderManager=new u},"_innerThirdLevelLoaderManager",function(){return this._innerThirdLevelLoaderManager=new u},"_innerFourthLevelLoaderManager",function(){return this._innerFourthLevelLoaderManager=new u}]),bn);function bn(){}var Bn=function(){function r(e){r.__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}p(r,"laya.d3.animation.AnimationTransform3D",n);var e=r.prototype;return e._getlocalMatrix=function(){return this._localUpdate&&(wn._createAffineTransformationArray(this._localPosition,this._localRotation,this._localScale,this._localMatrix),this._localUpdate=!1),this._localMatrix},e._onWorldTransform=function(){if(!this._worldUpdate){this._worldUpdate=!0;for(var e=0,t=this._childs.length;e<t;e++)this._childs[e]._onWorldTransform()}},e._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 wn.matrix4x4MultiplyFFF(this._parent.getWorldMatrix(),this._getlocalMatrix(),this._worldMatrix);this._worldUpdate=!1},e._setWorldMatrixNoUpdate=function(e){this._worldMatrix=e},e._setWorldMatrixIgnoreUpdate=function(e){this._worldMatrix=e,this._worldUpdate=!1},e.getLocalPosition=function(){return this._localPosition},e.setLocalPosition=function(e){var t,n,i;this._parent?(this._localPosition=e,this._localUpdate=!0,this._onWorldTransform()):(t=this._entity.owner._transform,(i=(n=this._entity.localPosition).elements)[0]=e[0],i[1]=e[1],i[2]=e[2],t.localPosition=n)},e.getLocalRotation=function(){var e;return this._localQuaternionUpdate&&(e=this._localRotationEuler,wn._quaternionCreateFromYawPitchRollArray(e[1]/r._angleToRandin,e[0]/r._angleToRandin,e[2]/r._angleToRandin,this._localRotation),this._localQuaternionUpdate=!1),this._localRotation},e.setLocalRotation=function(e){var t,n,i;this._parent?(this._localRotation=e,wn.quaterionNormalize(this._localRotation,this._localRotation),this._locaEulerlUpdate=!0,this._localQuaternionUpdate=!1,this._localUpdate=!0,this._onWorldTransform()):(t=this._entity.owner._transform,(i=(n=this._entity.localRotation).elements)[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],t.localRotation=n)},e.getLocalScale=function(){return this._localScale},e.setLocalScale=function(e){var t,n,i;this._parent?(this._localScale=e,this._localUpdate=!0,this._onWorldTransform()):(t=this._entity.owner._transform,(i=(n=this._entity.localScale).elements)[0]=e[0],i[1]=e[1],i[2]=e[2],t.localScale=n)},e.getLocalRotationEuler=function(){var e,t;return this._locaEulerlUpdate&&(wn.getYawPitchRoll(this._localRotation,r._tempVector3),e=r._tempVector3,(t=this._localRotationEuler)[0]=e[1]*r._angleToRandin,t[1]=e[0]*r._angleToRandin,t[2]=e[2]*r._angleToRandin,this._locaEulerlUpdate=!1),this._localRotationEuler},e.setLocalRotationEuler=function(e){var t,n,i;this._parent?(wn._quaternionCreateFromYawPitchRollArray(e[1]/r._angleToRandin,e[0]/r._angleToRandin,e[2]/r._angleToRandin,this._localRotation),this._localRotationEuler=e,this._locaEulerlUpdate=!1,this._localQuaternionUpdate=!1,this._localUpdate=!0,this._onWorldTransform()):(t=this._entity.owner._transform,(i=(n=this._entity.localRotationEuler).elements)[0]=e[0],i[1]=e[1],i[2]=e[2],t.localRotationEuler=n)},e.getWorldMatrix=function(){if(this._worldUpdate){if(null!=this._parent._parent)wn.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},e.setParent=function(e){var t,n;this._parent!==e&&(this._parent&&(n=(t=this._parent._childs).indexOf(this),t.splice(n,1)),e&&(e._childs.push(this),e&&this._onWorldTransform()),this._parent=e)},l(r,["_tempVector3",function(){return this._tempVector3=new Float32Array(3)},"_angleToRandin",function(){return this._angleToRandin=180/Math.PI}]),r}(),Un=function(){function e(){this._destroyed=!1,this._id=0,this._enable=!1,this._owner=null,this.started=!1,e.__super.call(this),this._destroyed=!1,this._id=e._uniqueIDCounter,e._uniqueIDCounter++}p(e,"laya.d3.component.Component3D",n);var t=e.prototype;return S.imps(t,{"laya.d3.core.render.IUpdate":!0,"laya.resource.IDestroy":!0}),t._initialize=function(e){this._owner=e,this._enable=!0,this.started=!1,this._load(e)},t._destroy=function(){this._unload(this._owner),this._owner=null,this._destroyed=!0},t._load=function(e){},t._start=function(e){},t._update=function(e){},t._lateUpdate=function(e){},t._preRenderUpdate=function(e){},t._postRenderUpdate=function(e){},t._unload=function(e){this.offAll()},t._cloneTo=function(e){},_(0,t,"id",function(){return this._id}),_(0,t,"destroyed",function(){return this._destroyed}),_(0,t,"owner",function(){return this._owner}),_(0,t,"enable",function(){return this._enable},function(e){this._enable!==e&&(this._enable=e,this.event("enablechanged",this._enable))}),_(0,t,"isSingleton",function(){return e._isSingleton}),e._isSingleton=!0,e._uniqueIDCounter=1,e}(),Hn=function(){function e(){this._destroyed=!1,e.__super.call(this),this._destroyed=!1}p(e,"laya.d3.core.GeometryFilter",n);var t=e.prototype;return S.imps(t,{"laya.resource.IDestroy":!0}),t._destroy=function(){this.offAll(),this._destroyed=!0},_(0,t,"_isAsyncLoaded",function(){return!0}),_(0,t,"_originalBoundingBoxCorners",function(){throw new Error("BaseRender: must override it.")}),_(0,t,"_originalBoundingSphere",function(){throw new Error("BaseRender: must override it.")}),_(0,t,"_originalBoundingBox",function(){throw new Error("BaseRender: must override it.")}),_(0,t,"destroyed",function(){return this._destroyed}),e}(),Gn=function(){function i(e){i.__super.call(this),this._id=++i._uniqueIDCounter,this._indexInSceneFrustumCullingObjects=-1,this._boundingBox=new kt(new hn,new hn),this._boundingBoxCenter=new hn,this._boundingSphere=new Yt(new hn,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)}p(i,"laya.d3.core.render.BaseRender",n);var e=i.prototype;return S.imps(e,{"laya.resource.IDestroy":!0}),e._changeMaterialReference=function(e,t){e&&e._removeReference(),t._addReference()},e._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},e._setShaderValuelightMap=function(e){this._setShaderValueTexture(3,e)},e._onWorldMatNeedChange=function(){this._boundingSphereNeedChange=!0,this._boundingBoxNeedChange=!0,this._boundingBoxCenterNeedChange=!0,this._octreeNodeNeedChange=!0},e._renderRenderableBoundBox=function(){var e=Pn._debugPhasorSprite,t=this.boundingBox,n=i._tempBoundBoxCorners;t.getCorners(n),e.line(n[0],i._greenColor,n[1],i._greenColor),e.line(n[2],i._greenColor,n[3],i._greenColor),e.line(n[4],i._greenColor,n[5],i._greenColor),e.line(n[6],i._greenColor,n[7],i._greenColor),e.line(n[0],i._greenColor,n[3],i._greenColor),e.line(n[1],i._greenColor,n[2],i._greenColor),e.line(n[2],i._greenColor,n[6],i._greenColor),e.line(n[3],i._greenColor,n[7],i._greenColor),e.line(n[0],i._greenColor,n[4],i._greenColor),e.line(n[1],i._greenColor,n[5],i._greenColor),e.line(n[4],i._greenColor,n[7],i._greenColor),e.line(n[5],i._greenColor,n[6],i._greenColor)},e._calculateBoundingSphere=function(){throw"BaseRender: must override it."},e._calculateBoundingBox=function(){throw"BaseRender: must override it."},e._setShaderValueTexture=function(e,t){this._owner._shaderValues.setValue(e,t)},e._setShaderValueMatrix4x4=function(e,t){this._owner._shaderValues.setValue(e,t?t.elements:null)},e._setShaderValueColor=function(e,t){this._owner._shaderValues.setValue(e,t?t.elements:null)},e._setShaderValueBuffer=function(e,t){this._owner._shaderValues.setValue(e,t)},e._setShaderValueInt=function(e,t){this._owner._shaderValues.setValue(e,t)},e._setShaderValueBool=function(e,t){this._owner._shaderValues.setValue(e,t)},e._setShaderValueNumber=function(e,t){this._owner._shaderValues.setValue(e,t)},e._setShaderValueVector2=function(e,t){this._owner._shaderValues.setValue(e,t?t.elements:null)},e._addShaderDefine=function(e){this._owner._shaderDefineValue|=e},e._removeShaderDefine=function(e){this._owner._shaderDefineValue&=~e},e._renderUpdate=function(e){return!0},e._applyLightMapParams=function(){var e,t;0<=this._lightmapIndex&&(e=this._owner.scene)&&(t=e.getlightmaps()[this._lightmapIndex])?(this._addShaderDefine(lr.SAHDERDEFINE_LIGHTMAP),t.loaded?this._setShaderValuelightMap(t):t.once("loaded",this,this._setShaderValuelightMap)):this._removeShaderDefine(lr.SAHDERDEFINE_LIGHTMAP)},e._updateOctreeNode=function(){var e=this._treeNode;e&&this._octreeNodeNeedChange&&(e.updateObject(this),this._octreeNodeNeedChange=!1)},e._destroy=function(){this.offAll();for(var e=0,t=0,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},_(0,e,"boundingSphere",function(){return this._boundingSphereNeedChange&&(this._calculateBoundingSphere(),this._boundingSphereNeedChange=!1),this._boundingSphere}),_(0,e,"id",function(){return this._id}),_(0,e,"material",function(){var e=this._materials[0];return e&&!this._materialsInstance[0]&&(e=this._getInstanceMaterial(e,0),this.event("materialchanged",[this,0,e])),this._materials[0]},function(e){this.sharedMaterial=e}),_(0,e,"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]))}),_(0,e,"lightmapIndex",function(){return this._lightmapIndex},function(e){this._lightmapIndex=e,this._applyLightMapParams()}),_(0,e,"lightmapScaleOffset",function(){return this._lightmapScaleOffset},function(e){this._lightmapScaleOffset=e,this._setShaderValueColor(2,e),this._addShaderDefine(lr.SHADERDEFINE_SCALEOFFSETLIGHTINGMAPUV)}),_(0,e,"enable",function(){return this._enable},function(e){this._enable=e,this.event("enablechanged",[this,e])}),_(0,e,"materials",function(){for(var e,t=0,n=this._materials.length;t<n;t++)this._materialsInstance[t]||(e=this._getInstanceMaterial(this._materials[t],t),this.event("materialchanged",[this,t,e]));return this._materials.slice()},function(e){this.sharedMaterials=e}),_(0,e,"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}),_(0,e,"boundingBox",function(){return this._boundingBoxNeedChange&&(this._calculateBoundingBox(),this._boundingBoxNeedChange=!1),this._boundingBox}),_(0,e,"boundingBoxCenter",function(){var e;return this._boundingBoxCenterNeedChange&&(e=this.boundingBox,hn.add(e.min,e.max,this._boundingBoxCenter),hn.scale(this._boundingBoxCenter,.5,this._boundingBoxCenter),this._boundingBoxCenterNeedChange=!1),this._boundingBoxCenter}),_(0,e,"receiveShadow",function(){return this._receiveShadow},function(e){this._receiveShadow!==e&&((this._receiveShadow=e)?this._addShaderDefine(gn.SHADERDEFINE_RECEIVE_SHADOW):this._removeShaderDefine(gn.SHADERDEFINE_RECEIVE_SHADOW))}),_(0,e,"destroyed",function(){return this._destroyed}),i._uniqueIDCounter=0,l(i,["_tempBoundBoxCorners",function(){return this._tempBoundBoxCorners=[new hn,new hn,new hn,new hn,new hn,new hn,new hn,new hn]},"_greenColor",function(){return this._greenColor=new _n(0,1,0,1)}]),i}(),zn=function(){function o(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,o.__super.call(this),this._localPosition=new hn,this._localRotation=new rn(0,0,0,1),this._localScale=new hn(1,1,1),this._localRotationEuler=new hn,this._localMatrix=new Jt,this._position=new hn,this._rotation=new rn(0,0,0,1),this._scale=new hn(1,1,1),this._worldMatrix=new Jt,this._forward=new hn,this._up=new hn,this._right=new hn,this._owner=e,this._childs=[]}p(o,"laya.d3.core.Transform3D",n);var e=o.prototype;return e._updateLocalMatrix=function(){var e,t,n,i;!this.pivot||0===this.pivot.x&&0===this.pivot.y&&0===this.pivot.z?Jt.createAffineTransformation(this._localPosition,this.localRotation,this._localScale,this._localMatrix):(i=o._tempVector30,hn.multiply(this.pivot,this._localScale,i),e=o._tempVector31,hn.subtract(i,this.pivot,e),t=o._tempVector32,n=this.localRotation,hn.transformQuat(i,n,t),hn.subtract(t,i,t),i=o._tempVector33,hn.subtract(this._localPosition,e,i),hn.subtract(i,t,i),Jt.createAffineTransformation(i,n,this._localScale,this._localMatrix))},e._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()}},e._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()}},e._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()}},e._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()}},e._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()}},e._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()}},e.translate=function(e,t){(t=void 0===t?!0:t)?(Jt.createFromQuaternion(this.localRotation,o._tempMatrix0),hn.transformCoordinate(e,o._tempMatrix0,o._tempVector30),hn.add(this.localPosition,o._tempVector30,this._localPosition),this.localPosition=this._localPosition):(hn.add(this.position,e,this._position),this.position=this._position)},e.rotate=function(e,t,n){void 0===t&&(t=!0),e=(n=void 0===n?!0:n)?e:(hn.scale(e,Math.PI/180,o._tempVector30),o._tempVector30),rn.createFromYawPitchRoll(e.y,e.x,e.z,o._tempQuaternion0),t?(rn.multiply(this._localRotation,o._tempQuaternion0,this._localRotation),this.localRotation=this._localRotation):(rn.multiply(o._tempQuaternion0,this.rotation,this._rotation),this.rotation=this._rotation)},e.lookAt=function(e,t,n){var i,r=e.elements;(n=void 0===n?!1:n)?(i=this._localPosition.elements,Math.abs(i[0]-r[0])<qt.zeroTolerance&&Math.abs(i[1]-r[1])<qt.zeroTolerance&&Math.abs(i[2]-r[2])<qt.zeroTolerance||(rn.lookAt(this._localPosition,e,t,this._localRotation),this._localRotation.invert(this._localRotation),this.localRotation=this._localRotation)):(i=(n=this.position).elements,Math.abs(i[0]-r[0])<qt.zeroTolerance&&Math.abs(i[1]-r[1])<qt.zeroTolerance&&Math.abs(i[2]-r[2])<qt.zeroTolerance||(rn.lookAt(n,e,t,this._rotation),this._rotation.invert(this._rotation),this.rotation=this._rotation))},_(0,e,"_isFrontFaceInvert",function(){var e=this.scale,t=e.x<0;return e.y<0&&(t=!t),t=e.z<0?!t:t}),_(0,e,"owner",function(){return this._owner}),_(0,e,"localRotation",function(){var e;return this._localQuaternionUpdate&&(e=this._localRotationEuler.elements,rn.createFromYawPitchRoll(e[1]/o._angleToRandin,e[0]/o._angleToRandin,e[2]/o._angleToRandin,this._localRotation)),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()}),_(0,e,"worldMatrix",function(){return this._worldUpdate&&(null!=this._parent?Jt.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),Jt.multiply(this._localMatrix,e,this._localMatrix)),this.localMatrix=this._localMatrix,this._worldMatrix=e,this._worldUpdate=!1}),_(0,e,"worldNeedUpdate",function(){return this._worldUpdate}),_(0,e,"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()}),_(0,e,"dummy",function(){return this._dummy},function(e){this._dummy!==e&&(this._dummy&&(this._dummy._entity=null),e&&(e._entity=this),this._dummy=e)}),_(0,e,"localPosition",function(){return this._localPosition},function(e){this._localPosition=e,this._localUpdate=!0,this._onWorldPositionTransform()}),_(0,e,"position",function(){var e;return this._positionUpdate&&(null!=this._parent?(e=this._parent.position,hn.multiply(this._localPosition,this._parent.scale,o._tempVector30),hn.transformQuat(o._tempVector30,this._parent.rotation,o._tempVector30),hn.add(e,o._tempVector30,this._position)):this._localPosition.cloneTo(this._position),this._positionUpdate=!1),this._position},function(e){var t,n,i,r,a;null!=this._parent?(hn.subtract(e,this._parent.position,this._localPosition),t=(a=this._parent.scale.elements)[0],n=a[1],i=a[2],1===t&&1===n&&1===i||((a=(r=o._tempVector30).elements)[0]=1/t,a[1]=1/n,a[2]=1/i,hn.multiply(this._localPosition,r,this._localPosition)),this._parent.rotation.invert(o._tempQuaternion0),hn.transformQuat(this._localPosition,o._tempQuaternion0,this._localPosition)):e.cloneTo(this._localPosition),this.localPosition=this._localPosition,this._position=e,this._positionUpdate=!1}),_(0,e,"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()}),_(0,e,"localRotationEuler",function(){var e,t;return this._locaEulerlUpdate&&(this._localRotation.getYawPitchRoll(o._tempVector30),e=o._tempVector30.elements,(t=this._localRotationEuler.elements)[0]=e[1]*o._angleToRandin,t[1]=e[0]*o._angleToRandin,t[2]=e[2]*o._angleToRandin),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()}),_(0,e,"rotation",function(){return this._rotationUpdate&&(null!=this._parent?rn.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(o._tempQuaternion0),rn.multiply(e,o._tempQuaternion0,this._localRotation)):e.cloneTo(this._localRotation),this.localRotation=this._localRotation,this._rotation=e,this._rotationUpdate=!1}),_(0,e,"scale",function(){return this._scaleUpdate&&(null!==this._parent?hn.multiply(this._parent.scale,this._localScale,this._scale):this._localScale.cloneTo(this._scale),this._scaleUpdate=!1),this._scale},function(e){var t,n;null!==this._parent?(t=this._parent.scale.elements,(n=o._tempVector30.elements)[0]=1/t[0],n[1]=1/t[1],n[2]=1/t[2],hn.multiply(e,o._tempVector30,this._localScale)):e.cloneTo(this._localScale),this.localScale=this._localScale,this._scale=e,this._scaleUpdate=!1}),_(0,e,"rotationEuler",null,function(e){rn.createFromYawPitchRoll(e.y,e.x,e.z,this._rotation),this.rotation=this._rotation}),_(0,e,"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}),_(0,e,"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}),_(0,e,"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}),_(0,e,"parent",function(){return this._parent},function(e){var t,n;this._parent!==e&&(this._parent&&(n=(t=this._parent._childs).indexOf(this),t.splice(n,1)),e&&(e._childs.push(this),e&&this._onWorldTransform()),this._parent=e)}),l(o,["_tempVector30",function(){return this._tempVector30=new hn},"_tempVector31",function(){return this._tempVector31=new hn},"_tempVector32",function(){return this._tempVector32=new hn},"_tempVector33",function(){return this._tempVector33=new hn},"_tempQuaternion0",function(){return this._tempQuaternion0=new rn},"_tempMatrix0",function(){return this._tempMatrix0=new Jt},"_angleToRandin",function(){return this._angleToRandin=180/Math.PI}]),o}(),Wn=(function(){function e(){this._rotation=0,this._matNeedUpdte=!1,e.__super.call(this),this._matrix=new Jt,this._offset=new ln,this._tiling=new ln(1,1)}p(e,"laya.d3.core.TransformUV",n);var t=e.prototype;S.imps(t,{"laya.d3.core.IClone":!0}),t._updateMatrix=function(){e._tempOffsetV3.elements[0]=this._offset.x,e._tempOffsetV3.elements[1]=this._offset.y,rn.createFromYawPitchRoll(0,0,this._rotation,e._tempRotationQua),e._tempTitlingV3.elements[0]=this._tiling.x,e._tempTitlingV3.elements[1]=this._tiling.y,Jt.createAffineTransformation(e._tempOffsetV3,e._tempRotationQua,e._tempTitlingV3,this._matrix)},t.cloneTo=function(e){e._matrix=this._matrix.clone(),e._offset=this._offset.clone(),e._rotation=this._rotation,e._tiling=this._tiling.clone()},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},_(0,t,"matrix",function(){return this._matNeedUpdte&&(this._updateMatrix(),this._matNeedUpdte=!1),this._matrix}),_(0,t,"tiling",function(){return this._tiling},function(e){this._tiling=e,this._matNeedUpdte=!0}),_(0,t,"offset",function(){return this._offset},function(e){this._offset=e,this._matNeedUpdte=!0}),_(0,t,"rotation",function(){return this._rotation},function(e){this._rotation=e,this._matNeedUpdte=!0}),l(e,["_tempOffsetV3",function(){return this._tempOffsetV3=new hn(0,0,0)},"_tempRotationQua",function(){return this._tempRotationQua=new rn},"_tempTitlingV3",function(){return this._tempTitlingV3=new hn(1,1,1)}])}(),p(kn,"laya.d3.utils.CollisionManager",n),kn._onTrigger=function(e,t,n,i,r){var a=0,o=0,s=e.id,l=t.id;if(!e._ignoreCollisonMap[l]){var h=An.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{_=e._runtimeCollisonMap;if(_[l]){for(delete _[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])}}},kn._triggerCollision=function(){for(var e=Z._collsionTestList,t=e.length,n=An._layerCollsionMatrix,i=0;i<t;i++)for(var r=e[i],a=Z.getLayerByNumber(r),o=a._colliders,s=a._nonRigidbodyOffset,l=t-1;i<=l;l--){var h=e[l];if(n[r][30-h]){var _,u,d,c,f=0,m=0,p=0,E=Z.getLayerByNumber(h),v=E._colliders,g=E._nonRigidbodyOffset;if(a!==E){for(f=0;f<s;f++)if((u=o[f]).enable){for(c=u.owner._scripts,m=0,p=g;m<p;m++)(d=v[m]).enable&&kn._onTrigger(u,d,c,d.owner._scripts,!0);for(m=g,p=v.length;m<p;m++)(d=v[m]).enable&&kn._onTrigger(u,d,c,d.owner._scripts,!1)}for(f=s,_=o.length;f<_;f++)if((u=o[f]).enable)for(c=u.owner._scripts,m=0,p=E._nonRigidbodyOffset;m<p;m++)(d=v[m]).enable&&kn._onTrigger(d,u,c,d.owner._scripts,!1)}else for(f=0;f<s;f++)if((u=o[f]).enable){for(c=u.owner._scripts,m=f+1,p=s;m<p;m++)(d=v[m]).enable&&kn._onTrigger(u,d,c,d.owner._scripts,!0);for(m=s,p=o.length;m<p;m++)(d=v[m]).enable&&kn._onTrigger(u,d,c,d.owner._scripts,!1)}}}},kn);function kn(){kn.__super.call(this)}!function(r){function e(){e.__super.call(this)}p(e,"laya.d3.core.glitter.SplineCurvePosition",r);var t=e.prototype;t._CalcVelocity=function(e,t,n){hn.subtract(e,t,n),hn.scale(n,.5,n)},t.Init=function(e,t,n,i){this._CalcVelocity(t,e,this._tempVector30),this._CalcVelocity(i,n,this._tempVector31),r.prototype.Init.call(this,t,this._tempVector30,i,this._tempVector31)}}(X);var Xn=function(t){function e(){this.x=NaN,this.y=NaN,this.z=NaN,e.__super.call(this),this.x=1,this.y=1,this.z=1,this.randomDirection=!1}p(e,"laya.d3.core.particleShuriKen.module.shape.BoxShape",t);var n=e.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;e=e.max.elements;e[0]=.5*this.x,e[1]=.5*this.y,e[2]=.5*this.z},n._getSpeedBoundBox=function(e){var t=e.min.elements;t[0]=0,t[1]=0,t[2]=0;e=e.max.elements;e[0]=0,e[1]=1,e[2]=0},n.generatePositionAndDirection=function(e,t,n,i){var r=e.elements,a=t.elements;n?(n.seed=i[16],se._randomPointInsideHalfUnitBox(e,n),i[16]=n.seed):se._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],se._randomPointUnitSphere(t,n),i[17]=n.seed):se._randomPointUnitSphere(t):(a[0]=0,a[1]=0,a[2]=1)},n.cloneTo=function(e){t.prototype.cloneTo.call(this,e);e.x=this.x,e.y=this.y,e.z=this.z,e.randomDirection=this.randomDirection},e}(oe),Yn=function(t){function o(){this.radius=NaN,this.arc=NaN,this.emitFromEdge=!1,o.__super.call(this),this.radius=1,this.arc=2*Math.PI,this.emitFromEdge=!1,this.randomDirection=!1}p(o,"laya.d3.core.particleShuriKen.module.shape.CircleShape",t);var e=o.prototype;return e._getShapeBoundBox=function(e){var t=e.min.elements;t[0]=t[2]=-this.radius,t[1]=0;e=e.max.elements;e[0]=e[2]=this.radius,e[1]=0},e._getSpeedBoundBox=function(e){var t=e.min.elements;t[0]=t[1]=-1,t[2]=0;e=e.max.elements;e[0]=e[1]=1,e[2]=0},e.generatePositionAndDirection=function(e,t,n,i){var r=e.elements,a=o._tempPositionPoint.elements;n?(n.seed=i[16],this.emitFromEdge?se._randomPointUnitArcCircle(this.arc,o._tempPositionPoint,n):se._randomPointInsideUnitArcCircle(this.arc,o._tempPositionPoint,n),i[16]=n.seed):this.emitFromEdge?se._randomPointUnitArcCircle(this.arc,o._tempPositionPoint):se._randomPointInsideUnitArcCircle(this.arc,o._tempPositionPoint),r[0]=-a[0],r[1]=a[1],r[2]=0,hn.scale(e,this.radius,e),this.randomDirection?n?(n.seed=i[17],se._randomPointUnitSphere(t,n),i[17]=n.seed):se._randomPointUnitSphere(t):e.cloneTo(t)},e.cloneTo=function(e){t.prototype.cloneTo.call(this,e);e.radius=this.radius,e.arc=this.arc,e.emitFromEdge=this.emitFromEdge,e.randomDirection=this.randomDirection},l(o,["_tempPositionPoint",function(){return this._tempPositionPoint=new ln}]),o}(oe),Zn=function(t){function d(){this.angle=NaN,this.radius=NaN,this.length=NaN,this.emitType=0,d.__super.call(this),this.angle=25/180*Math.PI,this.radius=1,this.length=5,this.emitType=0,this.randomDirection=!1}p(d,"laya.d3.core.particleShuriKen.module.shape.ConeShape",t);var e=d.prototype;return e._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;e=e.max.elements;e[0]=e[1]=t,e[2]=n},e._getSpeedBoundBox=function(e){var t=Math.sin(this.angle),n=e.min.elements;n[0]=n[1]=-t,n[2]=0;e=e.max.elements;e[0]=n[1]=t,e[2]=1},e.generatePositionAndDirection=function(e,t,n,i){var r,a=e.elements,o=t.elements,s=d._tempPositionPoint.elements,l=NaN,h=NaN,_=Math.cos(this.angle),u=Math.sin(this.angle);switch(this.emitType){case 0:n?(n.seed=i[16],se._randomPointInsideUnitCircle(d._tempPositionPoint,n),i[16]=n.seed):se._randomPointInsideUnitCircle(d._tempPositionPoint),l=s[0],h=s[1],a[0]=l*this.radius,a[1]=h*this.radius,a[2]=0,this.randomDirection?(n?(n.seed=i[17],se._randomPointInsideUnitCircle(d._tempDirectionPoint,n),i[17]=n.seed):se._randomPointInsideUnitCircle(d._tempDirectionPoint),r=d._tempDirectionPoint.elements,o[0]=r[0]*u,o[1]=r[1]*u):(o[0]=l*u,o[1]=h*u),o[2]=_;break;case 1:n?(n.seed=i[16],se._randomPointUnitCircle(d._tempPositionPoint,n),i[16]=n.seed):se._randomPointUnitCircle(d._tempPositionPoint),l=s[0],h=s[1],a[0]=l*this.radius,a[1]=h*this.radius,a[2]=0,this.randomDirection?(n?(n.seed=i[17],se._randomPointInsideUnitCircle(d._tempDirectionPoint,n),i[17]=n.seed):se._randomPointInsideUnitCircle(d._tempDirectionPoint),r=d._tempDirectionPoint.elements,o[0]=r[0]*u,o[1]=r[1]*u):(o[0]=l*u,o[1]=h*u),o[2]=_;break;case 2:n?(n.seed=i[16],se._randomPointInsideUnitCircle(d._tempPositionPoint,n)):se._randomPointInsideUnitCircle(d._tempPositionPoint),l=s[0],h=s[1],a[0]=l*this.radius,a[1]=h*this.radius,o[a[2]=0]=l*u,o[1]=h*u,o[2]=_,hn.normalize(t,t),n?(hn.scale(t,this.length*n.getFloat(),t),i[16]=n.seed):hn.scale(t,this.length*Math.random(),t),hn.add(e,t,e),this.randomDirection&&(n?(n.seed=i[17],se._randomPointUnitSphere(t,n),i[17]=n.seed):se._randomPointUnitSphere(t));break;case 3:n?(n.seed=i[16],se._randomPointUnitCircle(d._tempPositionPoint,n)):se._randomPointUnitCircle(d._tempPositionPoint),l=s[0],h=s[1],a[0]=l*this.radius,a[1]=h*this.radius,o[a[2]=0]=l*u,o[1]=h*u,o[2]=_,hn.normalize(t,t),n?(hn.scale(t,this.length*n.getFloat(),t),i[16]=n.seed):hn.scale(t,this.length*Math.random(),t),hn.add(e,t,e),this.randomDirection&&(n?(n.seed=i[17],se._randomPointUnitSphere(t,n),i[17]=n.seed):se._randomPointUnitSphere(t));break;default:throw new Error("ConeShape:emitType is invalid.")}},e.cloneTo=function(e){t.prototype.cloneTo.call(this,e);e.angle=this.angle,e.radius=this.radius,e.length=this.length,e.emitType=this.emitType,e.randomDirection=this.randomDirection},l(d,["_tempPositionPoint",function(){return this._tempPositionPoint=new ln},"_tempDirectionPoint",function(){return this._tempDirectionPoint=new ln}]),d}(oe),jn=function(t){function e(){this.radius=NaN,this.emitFromShell=!1,e.__super.call(this),this.radius=1,this.emitFromShell=!1,this.randomDirection=!1}p(e,"laya.d3.core.particleShuriKen.module.shape.HemisphereShape",t);var n=e.prototype;return n._getShapeBoundBox=function(e){var t=e.min.elements;t[0]=t[1]=t[2]=-this.radius;e=e.max.elements;e[0]=e[1]=this.radius,e[2]=0},n._getSpeedBoundBox=function(e){var t=e.min.elements;t[0]=t[1]=-1,t[2]=0;e=e.max.elements;e[0]=e[1]=e[2]=1},n.generatePositionAndDirection=function(e,t,n,i){var r=e.elements;n?(n.seed=i[16],this.emitFromShell?se._randomPointUnitSphere(e,n):se._randomPointInsideUnitSphere(e,n),i[16]=n.seed):this.emitFromShell?se._randomPointUnitSphere(e):se._randomPointInsideUnitSphere(e),hn.scale(e,this.radius,e);var a=r[2];a<0&&(r[2]=-1*a),this.randomDirection?n?(n.seed=i[17],se._randomPointUnitSphere(t,n),i[17]=n.seed):se._randomPointUnitSphere(t):e.cloneTo(t)},n.cloneTo=function(e){t.prototype.cloneTo.call(this,e);e.radius=this.radius,e.emitFromShell=this.emitFromShell,e.randomDirection=this.randomDirection},e}(oe),Kn=function(t){function e(){this.radius=NaN,this.emitFromShell=!1,e.__super.call(this),this.radius=1,this.emitFromShell=!1,this.randomDirection=!1}p(e,"laya.d3.core.particleShuriKen.module.shape.SphereShape",t);var n=e.prototype;return n._getShapeBoundBox=function(e){var t=e.min.elements;t[0]=t[1]=t[2]=-this.radius;e=e.max.elements;e[0]=e[1]=e[2]=this.radius},n._getSpeedBoundBox=function(e){var t=e.min.elements;t[0]=t[1]=t[2]=-1;e=e.max.elements;e[0]=e[1]=e[2]=1},n.generatePositionAndDirection=function(e,t,n,i){n?(n.seed=i[16],this.emitFromShell?se._randomPointUnitSphere(e,n):se._randomPointInsideUnitSphere(e,n),i[16]=n.seed):this.emitFromShell?se._randomPointUnitSphere(e):se._randomPointInsideUnitSphere(e),hn.scale(e,this.radius,e),this.randomDirection?n?(n.seed=i[17],se._randomPointUnitSphere(t,n),i[17]=n.seed):se._randomPointUnitSphere(t):e.cloneTo(t)},n.cloneTo=function(e){t.prototype.cloneTo.call(this,e);e.radius=this.radius,e.emitFromShell=this.emitFromShell,e.randomDirection=this.randomDirection},e}(oe),qn=(p(Qn,"laya.d3.core.render.SubMeshRenderElement",pe),Qn);function Qn(){this._batchIndexStart=0,this._batchIndexEnd=0,this._skinAnimationDatas=null,Qn.__super.call(this)}var $n=function(){function f(e,t,n,i,r,a){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[gn.SHADERDEFINE_RECEIVE_SHADOW]="RECEIVESHADOW",this._spriteInt2name[lr.SHADERDEFINE_SCALEOFFSETLIGHTINGMAPUV]="SCALEOFFSETLIGHTINGMAPUV",this._spriteInt2name[lr.SAHDERDEFINE_LIGHTMAP]="LIGHTMAP",this._spriteInt2name[pr.SHADERDEFINE_BONE]="BONE",this._materialInt2name[ri.SHADERDEFINE_ALPHATEST]="ALPHATEST";f.__super.call(this,e,t,n,null,{}),this._attributeMap=i;for(var o in r){var s=r[o];switch(s[1]){case 0:this._renderElementUniformMap[o]=s[0];break;case 1:this._materialUniformMap[o]=s[0];break;case 2:this._spriteUniformMap[o]=s[0];break;case 3:this._cameraUniformMap[o]=s[0];break;case 4:this._sceneUniformMap[o]=s[0];break;default:throw new Error("ShaderCompile3D: period is unkonw.")}}}p(f,"laya.d3.shader.ShaderCompile3D",R);var e=f.prototype;return e._definesToNameDic=function(e,t){for(var n,i,r={},a=0;a<32&&!(e<(n=1<<a));a++)e&n&&((i=t[n])&&(r[i]=""));return r},e.withCompile=function(e,t,n){var i,r=this.sharders[e];if(r)if(i=r[t]){if(c=i[n])return c}else i=r[t]=[];else i=(r=this.sharders[e]=[])[t]=[];var a,o=this._definesToNameDic(e,f._globalInt2name),s=this._definesToNameDic(t,this._spriteInt2name),r=this._definesToNameDic(n,this._materialInt2name);if(laya.d3.shader.ShaderCompile3D.debugMode){var l="";for(a in o)l+=a+" ";var h="";for(a in s)h+=a+" ";var _="";for(a in r)_+=a+" ";console.log("ShaderCompile3DDebugMode---(Name:"+Vi.nameKey.getName(this._name)+" PublicDefine:"+e+" SpriteDefine:"+t+" MaterialDefine:"+n+" PublicDefineGroup:"+l+" SpriteDefineGroup:"+h+"MaterialDefineGroup: "+_+")---ShaderCompile3DDebugMode")}var u={},d="";if(o)for(a in o)d+="#define "+a+"\n",u[a]=!0;if(s)for(a in s)d+="#define "+a+"\n",u[a]=!0;if(r)for(a in r)d+="#define "+a+"\n",u[a]=!0;var s=this._VS.toscript(u,[]),r=this._PS.toscript(u,[]),c=Vi.create(d+s.join("\n"),d+r.join("\n"),this._attributeMap,this._sceneUniformMap,this._cameraUniformMap,this._spriteUniformMap,this._materialUniformMap,this._renderElementUniformMap);return i[n]=c},e.precompileShaderWithShaderDefine=function(e,t,n){this.withCompile(e,t,n)},e.addMaterialDefines=function(e){var t,n=e.defines;for(t in n){var i=n[t],r=parseInt(t);this._materialInt2name[r]=i,this._materialName2Int[i]=r}},e.addSpriteDefines=function(e){var t,n=e.defines;for(t in n){var i=n[t],r=parseInt(t);this._spriteInt2name[r]=i,this._spriteName2Int[i]=r}},e.getMaterialDefineByName=function(e){return this._materialName2Int[e]},e.registerMaterialDefine=function(e){var t=Math.pow(2,this._materialDefineCounter++);return this._materialInt2name[t]=e,this._materialName2Int[e]=t},e.registerSpriteDefine=function(e){var t=Math.pow(2,this._spriteDefineCounter++);return this._spriteInt2name[t]=e,this._spriteName2Int[e]=t},f._globalRegDefine=function(e,t){f._globalInt2name[t]=e},f.add=function(e,t,n,i,r){return laya.d3.shader.ShaderCompile3D._preCompileShader[e]=new f(e,t,n,i,r,R.includes)},f.get=function(e){return laya.d3.shader.ShaderCompile3D._preCompileShader[Vi.nameKey.getID(e)]},f._preCompileShader={},f._globalInt2name=[],f.debugMode=!1,f.SHADERDEFINE_HIGHPRECISION=1,f.SHADERDEFINE_FOG=4,f.SHADERDEFINE_DIRECTIONLIGHT=8,f.SHADERDEFINE_POINTLIGHT=16,f.SHADERDEFINE_SPOTLIGHT=32,f.SHADERDEFINE_UV0=64,f.SHADERDEFINE_COLOR=128,f.SHADERDEFINE_UV1=256,f.SAHDERDEFINE_DEPTHFOG=131072,f}(),Jn=function(){function f(){f.__super.call(this)}p(f,"laya.d3.graphics.MeshSprite3DStaticBatchManager",ze);var e=f.prototype;return e._getStaticBatch=function(e,t,n,i){var r,i=e?e.id.toString()+n.id.toString()+t.id.toString()+i.toString():n.id.toString()+t.id.toString()+i.toString();return this._staticBatches[i]?r=this._staticBatches[i]:this._staticBatches[i]=r=new ei(i,this,e,t,n),r},e._initStaticBatchs=function(e){var t,n;this._initBatchRenderElements.sort(f._sortPrepareStaticBatch);for(var i,r=!1,a=0,o=0,s=this._initBatchRenderElements.length;o<s;o++){var l,h,_,u,d=this._initBatchRenderElements[o],c=d.renderObj._getVertexBuffer(0);d._sprite3D;n===c.vertexDeclaration&&t===d._material?r?i._addCombineBatchRenderObjTest(d)?(l=d._staticBatch)!==i&&(l&&l._deleteCombineBatchRenderObj(d),i._addCombineBatchRenderObj(d)):(r=!1,a++):(_=(h=this._initBatchRenderElements[o-1]).renderObj,u=d.renderObj,r=!(65535<_._getVertexBuffer().vertexCount+u._getVertexBuffer().vertexCount)&&(i=this._getStaticBatch(e,n,t,a),(l=h._staticBatch)!==i&&(l&&l._deleteCombineBatchRenderObj(h),i._addCombineBatchRenderObj(h)),(l=d._staticBatch)!==i&&(l&&l._deleteCombineBatchRenderObj(d),i._addCombineBatchRenderObj(d)),!0)):(r=!1,a=0),t=d._material,n=c.vertexDeclaration}},f._sortPrepareStaticBatch=function(e,t){var n=e._render,i=t._render,r=n.lightmapIndex-i.lightmapIndex;if(0!=r)return r;i=n.receiveShadow-i.receiveShadow;if(0!=i)return i;i=e._mainSortID-t._mainSortID;return 0==i?e.renderObj.triangleCount-t.renderObj.triangleCount:i},f}(),ei=function(){function a(e,t,n,i,r){this._batchOwnerIndices=null,this._batchOwners=null,this._needFinishCombine=!1,this._currentCombineVertexCount=0,this._currentCombineIndexCount=0,this._vertexDeclaration=null,this._vertexBuffer=null,this._indexBuffer=null,a.__super.call(this,e,t,n),this._batchOwnerIndices=[],this._batchOwners=[],this._needFinishCombine=!1,this._currentCombineVertexCount=0,this._currentCombineIndexCount=0,this._vertexDeclaration=i,this._material=r}p(a,"laya.d3.graphics.SubMeshStaticBatch",We);var e=a.prototype;return e._compareBatchRenderElement=function(e,t){return e._batchIndexStart>t._batchIndexStart},e._addCombineBatchRenderObjTest=function(e){var t=e.renderObj._vertexCount;return!(65535<(0<t?this._currentCombineVertexCount+t:this._currentCombineVertexCount+e.renderObj._getVertexBuffer().vertexCount))},e._addCombineBatchRenderObj=function(e){var t=e.renderObj,n=t._vertexCount;this._initBatchRenderElements.push(e),e._staticBatch=this,0<n?(this._currentCombineIndexCount+=t._indexCount,this._currentCombineVertexCount+=n):(this._currentCombineIndexCount=this._currentCombineIndexCount+t._getIndexBuffer().indexCount,this._currentCombineVertexCount=this._currentCombineVertexCount+t._getVertexBuffer().vertexCount),this._needFinishCombine=!0},e._deleteCombineBatchRenderObj=function(e){var t=e.renderObj,n=this._initBatchRenderElements.indexOf(e);-1!==n&&(this._initBatchRenderElements.splice(n,1),e._staticBatch=null,0<(e=t._vertexCount)?(this._currentCombineIndexCount=this._currentCombineIndexCount-t._indexCount,this._currentCombineVertexCount=this._currentCombineVertexCount-e):(this._currentCombineIndexCount=this._currentCombineIndexCount-t._getIndexBuffer().indexCount,this._currentCombineVertexCount=this._currentCombineVertexCount-t._getVertexBuffer().vertexCount),this._needFinishCombine=!0)},e._finishInit=function(){if(this._needFinishCombine){var e=0,t=0;(0<=this._initBatchRenderElements[0]._sprite3D._render.lightmapIndex||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=Gi.create(this._vertexDeclaration,this._currentCombineVertexCount,35044),this._indexBuffer=Ui.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,s=t,d=s+h.length;o._batchIndexStart=s,o._batchIndexEnd=d,i.set(h,t);var c=0;if(_)for(c=s;c<d;c+=3){i[c]=u+i[c];var f=i[c+1],m=i[c+2];i[c+1]=u+m,i[c+2]=u+f}else for(c=s;c<d;c+=3)i[c]=u+i[c],i[c+1]=u+i[c+1],i[c+2]=u+i[c+2];t+=h.length,n.set(l,e),e+=l.length}this._vertexBuffer.setData(n),this._indexBuffer.setData(i),this._needFinishCombine=!1}},e._getCombineRenderElementFromPool=function(){return this._combineRenderElementPool[this._combineRenderElementPoolIndex++]||(this._combineRenderElementPool[this._combineRenderElementPoolIndex-1]=new qn)},e._getRenderElement=function(e,t,n){for(var i=this._batchRenderElements.length,r=!0,a=0;a<i;a++){var o,s,l,h,_,u,d=(o=this._batchRenderElements[a])._sprite3D._render;(r=0!==a?(_=(h=this._batchRenderElements[a-1])._sprite3D._render).lightmapIndex!==d.lightmapIndex||_.receiveShadow!==d.receiveShadow||h._batchIndexEnd!==o._batchIndexStart:r)?((s=this._getCombineRenderElementFromPool()).renderObj=this,s._material=this._material,s._batchIndexStart=o._batchIndexStart,s._batchIndexEnd=o._batchIndexEnd,l=d.lightmapIndex,void 0===(_=(h=(h=this._batchOwnerIndices[_=l+1])||(this._batchOwnerIndices[_]=[]))[o._render.receiveShadow?1:0])?(h[d.receiveShadow?1:0]=this._batchOwners.length,(u=new fr(null,"StaticBatchMeshSprite3D"))._scene=t,u._transform=this._rootOwner?this._rootOwner._transform:null,u._render.lightmapIndex=l,u._render.receiveShadow=o._render.receiveShadow,this._batchOwners.push(u)):u=this._batchOwners[_],u._render._renderUpdate(n),s._sprite3D=u,e.push(s)):s._batchIndexEnd=o._batchIndexEnd}},e._beforeRender=function(e){return this._vertexBuffer._bind(),this._indexBuffer._bind(),!0},e._render=function(e){var t=e.renderElement,e=t._batchIndexStart,t=t._batchIndexEnd-e;N.mainContext.drawElements(4,t,5123,2*e),I.drawCall++,I.trianglesFaces+=t/3},e.dispose=function(){this._batchOwnerIndices=null,this._batchOwners=null,this._vertexDeclaration=null,this._vertexBuffer.destroy(),this._indexBuffer.destroy()},e._getVertexBuffer=function(e){return void 0===e&&(e=0),this._vertexBuffer},a}(),ti=(function(e){function d(){d.__super.call(this),d._nameNumber++,this.loadShaderParams(),this.createResource(),this.alphaBlending=1,this.colorIntensity=1}p(d,"laya.d3.resource.models.SkyBox",e);var t=d.prototype;t._getShader=function(e){e=e.scene._shaderDefineValue;return this._shader=this._shaderCompile.withCompile(e,0,0),this._shader},t.createResource=function(){this._numberVertices=36,this._numberIndices=36;var e=new Uint16Array(this._numberIndices),t=d._vertexDeclaration.vertexStride/4,n=new Float32Array(this._numberVertices*t),i=new hn(-.5,.5,.5),r=new hn(-.5,-.5,.5),a=new hn(.5,.5,.5),o=new hn(.5,-.5,.5),s=new hn(-.5,.5,-.5),l=new hn(.5,.5,-.5),h=new hn(-.5,-.5,-.5),_=new hn(.5,-.5,-.5),t=this._addVertex(n,0,i);t=this._addVertex(n,t,r),t=this._addVertex(n,t,a),t=this._addVertex(n,t,r),t=this._addVertex(n,t,o),t=this._addVertex(n,t,a),t=this._addVertex(n,t,s),t=this._addVertex(n,t,l),t=this._addVertex(n,t,h),t=this._addVertex(n,t,h),t=this._addVertex(n,t,l),t=this._addVertex(n,t,_),t=this._addVertex(n,t,i),t=this._addVertex(n,t,l),t=this._addVertex(n,t,s),t=this._addVertex(n,t,i),t=this._addVertex(n,t,a),t=this._addVertex(n,t,l),t=this._addVertex(n,t,r),t=this._addVertex(n,t,h),t=this._addVertex(n,t,_),t=this._addVertex(n,t,r),t=this._addVertex(n,t,_),t=this._addVertex(n,t,o),t=this._addVertex(n,t,i),t=this._addVertex(n,t,h),t=this._addVertex(n,t,r),t=this._addVertex(n,t,s),t=this._addVertex(n,t,h),t=this._addVertex(n,t,i),t=this._addVertex(n,t,a),t=this._addVertex(n,t,o),t=this._addVertex(n,t,_),t=this._addVertex(n,t,l),t=this._addVertex(n,t,a),this._addVertex(n,t,_);for(var u=0;u<36;u++)e[u]=u;this._vertexBuffer=new Gi(d._vertexDeclaration,this._numberVertices,35044,!0),this._indexBuffer=new Ui("ushort",this._numberIndices,35044,!0),this._vertexBuffer.setData(n),this._indexBuffer.setData(e)},t._addVertex=function(e,t,n){n=n.elements;return e[t+0]=n[0],e[t+1]=n[1],e[t+2]=n[2],t+3},t.loadShaderParams=function(){this._sharderNameID=Vi.nameKey.getID("SkyBox"),this._shaderCompile=$n._preCompileShader[this._sharderNameID]},t._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(d._tempMatrix4x40),d._tempMatrix4x40.transpose(),Jt.multiply(e._projectionMatrix,d._tempMatrix4x40,d._tempMatrix4x41),e.camera._shaderValues.setValue(4,d._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(d._vertexDeclaration.shaderValues.data,null),this._shader.uploadMaterialUniforms(this._shaderValue.data),N.mainContext.drawElements(4,36,5123,0),I.trianglesFaces+=12,I.drawCall++)},t.destroy=function(){e.prototype.destroy.call(this),this._textureCube&&(this._textureCube._removeReference(),this._textureCube=null)},_(0,t,"textureCube",function(){return this._textureCube},function(e){this._textureCube!==e&&(this._textureCube&&this._textureCube._removeReference(),(this._textureCube=e)&&e._addReference())}),d._nameNumber=1,l(d,["_tempMatrix4x40",function(){return this._tempMatrix4x40=new Jt},"_tempMatrix4x41",function(){return this._tempMatrix4x41=new Jt},"_vertexDeclaration",function(){return this._vertexDeclaration=new ke(12,[new Xe(0,"vector3",0)])}])}(dn),function(e){function f(){this._stacks=16,this._slices=16,this._radius=1,f.__super.call(this),f._nameNumber++,this.loadShaderParams(),this.recreateResource(),this.alphaBlending=1,this.colorIntensity=1}p(f,"laya.d3.resource.models.SkyDome",e);var t=f.prototype;t._getShader=function(e){e=e.scene._shaderDefineValue;return this._shader=this._shaderCompile.withCompile(e,0,0),this._shader},t.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=f._vertexDeclaration.vertexStride/4,n=new Float32Array(this._numberVertices*t),i=Math.PI/this._stacks,r=2*Math.PI/this._slices,a=0,o=0,s=0,l=0;l<this._stacks+1;l++)for(var h=Math.sin(l*i),_=Math.cos(l*i),u=0;u<this._slices+1;u++){var d=h*Math.sin(u*r),c=h*Math.cos(u*r);n[o+0]=d*this._radius,n[o+1]=_*this._radius,n[o+2]=c*this._radius,n[o+3]=.75-u/this._slices,n[o+4]=l/this._stacks,o+=t,l!=this._stacks-1&&(e[s++]=a+1,e[s++]=a,e[s++]=a+(this._slices+1),e[s++]=a+(this._slices+1),e[s++]=a,e[s++]=a+this._slices,a++)}this._vertexBuffer=new Gi(f._vertexDeclaration,this._numberVertices,35044),this._indexBuffer=new Ui("ushort",this._numberIndices,35044),this._vertexBuffer.setData(n),this._indexBuffer.setData(e)},t.loadShaderParams=function(){this._sharderNameID=Vi.nameKey.getID("SkyDome"),this._shaderCompile=$n._preCompileShader[this._sharderNameID]},t._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(f._tempMatrix4x40),f._tempMatrix4x40.transpose(),Jt.multiply(e._projectionMatrix,f._tempMatrix4x40,f._tempMatrix4x41),e.camera._shaderValues.setValue(4,f._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(f._vertexDeclaration.shaderValues.data,null),this._shader.uploadMaterialUniforms(this._shaderValue.data),N.mainContext.drawElements(4,this._indexBuffer.indexCount,5123,0),I.trianglesFaces+=this._numberIndices/3,I.drawCall++)},t.onEnvDescLoaded=function(e){var t="",n=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));0<n&&(t=e.substr(0,n+1));e=S.loader.getRes(e);null!=e.ev&&this.__ownerCamera?this.__ownerCamera._shaderValues.setValue(13,Math.pow(2,e.ev)):this.__ownerCamera._shaderValues.setValue(13,Math.pow(2,0)),this.texture=rr.load(t+e.skytex),this.environmentSpecular=$i.load(t+e.prefiltedEnv);e=new Float32Array(e.IrradianceMat);this.envDiffuseSHRed=e.slice(0,16),this.envDiffuseSHGreen=e.slice(16,32),this.envDiffuseSHBlue=e.slice(32,48)},t.loadEnvInfo=function(e){S.loader.load(e,D.create(this,this.onEnvDescLoaded,[e]))},t.destroy=function(){e.prototype.destroy.call(this),this._texture&&(this._texture._removeReference(),this._texture=null)},_(0,t,"texture",function(){return this._texture},function(e){this._texture!==e&&(this._texture&&this._texture._removeReference(),(this._texture=e)&&e._addReference())}),f._nameNumber=1,l(f,["_tempMatrix4x40",function(){return this._tempMatrix4x40=new Jt},"_tempMatrix4x41",function(){return this._tempMatrix4x41=new Jt},"_vertexDeclaration",function(){return this._vertexDeclaration=new ke(20,[new Xe(0,"vector3",0),new Xe(12,"vector2",2)])}])}(dn),function(){function e(){this._componentsMap=null,this._typeComponentsIndices=null,this._components=null,this._scripts=null,e.__super.call(this),this._componentsMap=[],this._typeComponentsIndices=[],this._components=[],this._scripts=[]}p(e,"laya.d3.core.ComponentNode",d);var t=e.prototype;return t.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+"组件已存在!");e=a.getInstance(e);return t.push(this._components.length),this._components.push(e),e instanceof laya.d3.component.Script&&this._scripts.push(e),e._initialize(this),e},t._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;0<=s;s--){var l=n[s];if(!(i<l))break;n[s]=--l}r._destroy()},t.getComponentByType=function(e,t){void 0===t&&(t=0);e=this._componentsMap.indexOf(e);return-1===e?null:this._components[this._typeComponentsIndices[e][t]]},t.getComponentsByType=function(e,t){e=this._componentsMap.indexOf(e);if(-1!==e){var n=this._typeComponentsIndices[e],i=n.length;t.length=i;for(var r=0;r<i;r++)t[r]=this._components[n[r]]}else t.length=0},t.getComponentByIndex=function(e){return this._components[e]},t.removeComponentByType=function(e,t){void 0===t&&(t=0);e=this._componentsMap.indexOf(e);-1!==e&&this._removeComponent(e,t)},t.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)},t.removeAllComponent=function(){for(var e=0,t=this._componentsMap.length;e<t;this._componentsMap.length<t?t--:e++)this.removeComponentsByType(this._componentsMap[e])},t._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)}},t._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)}},t._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)}},t._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)}},e}()),ni=function(){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=[]}p(t,"laya.d3.animation.AnimationClip",T);var e=t.prototype;return e.duration=function(){return this._duration},e._hermiteInterpolate=function(e,t,n,i){for(var r=e.data,a=e.outTangent,e=e.next,o=e.data,s=e.inTangent,l=!1,h=NaN,_=NaN,u=NaN,d=NaN,c=0,f=i.length;c<f;c++){var m,p,E=a[c],v=s[c];Number.isFinite(E)&&Number.isFinite(v)?(l||(h=2*(p=(m=t*t)*t)-3*m+1,_=p-2*m+t,u=p-m,d=-2*p+3*m,l=!0),i[c]=h*r[c]+_*E*n+u*v*n+d*o[c]):i[c]=r[c]}},e._getFullKeyframeIndicesWithCache=function(e){return this._fullKeyframeIndicesCache[e]},e._cacheFullKeyframeIndices=function(e,t){this._fullKeyframeIndicesCache[e]=t},e._getAnimationDataWithCache=function(e,t){e=this._animationDatasCache[e];return e?e[t]:null},e._cacheAnimationData=function(e,t,n){(this._animationDatasCache[e]||(this._animationDatasCache[e]=[]))[t]=n},e._getAvatarDataWithCache=function(e,t,n){e=this._avatarDatasCache[e.id];if(e){t=e[t];return t?t[n]:null}return null},e._cacheAvatarData=function(e,t,n,i){e=this._avatarDatasCache[e.id]||(this._avatarDatasCache[e.id]=[]);(e[t]||(e[t]=[]))[n]=i},e._evaluateAnimationlDatasCacheMode=function(e,t,n,i,r){for(var a=0,o=0,s=0,l=(r||this._nodes).length;s<l;s++){var h=r?r[s]:s,_=this._nodes[h],u=_._cacheProperty;if(e[h]){var d,c=t[h],f=c[n.currentFrameIndex],m=0;if(-1!==f){var p=_.keyFrames[f];if(p.next){r&&!u?d=(d=i[h])||(i[h]=new Float32Array(_.keyFrameWidth)):(d=new Float32Array(_.keyFrameWidth),i[s]=d);var E=NaN,v=p.duration,E=0!==v?(n.currentFrameTime-p.startTime)/v:0;this._hermiteInterpolate(p,E,v,d)}else{if(r&&!u)d=(d=i[h])||(i[h]=new Float32Array(_.keyFrameWidth));else{if(-1!==(m=n._lastFrameIndex)&&c[m]===f)continue;d=new Float32Array(_.keyFrameWidth),i[s]=d}for(var g=p.data,a=0,o=d.length;a<o;a++)d[a]=g[a]}}else{if(r&&!u)d=(d=i[h])||(i[h]=new Float32Array(_.keyFrameWidth));else{if(-1!==(m=n._lastFrameIndex)&&c[m]===f)continue;d=new Float32Array(_.keyFrameWidth),i[s]=d}var T=_.keyFrames[0].data;for(a=0,o=d.length;a<o;a++)d[a]=T[a]}}}},e._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||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 d=0,c=0,f=(f=n[s])||(n[s]=new Float32Array(l.keyFrameWidth)),m=_[this._realTimeCurrentFrameIndexes[s]];if(m)if(m.next){var p=m.duration,E=NaN,E=0!==p?(t-m.startTime)/p:0;this._hermiteInterpolate(m,E,p,f)}else for(var v=m.data,d=0,c=f.length;d<c;d++)f[d]=v[d];else{var g=l.keyFrames[0].data;for(d=0,c=f.length;d<c;d++)f[d]=g[d]}m=e[s];m&&(i?U._propertySetFuncs[l.propertyNameID](m,null,f):U._propertySetFuncs[l.propertyNameID](null,m,f))}},e._binarySearchEventIndex=function(e){for(var t=0,n=this._animationEvents.length-1;t<=n;){var i=Math.floor((t+n)/2),r=this._animationEvents[i].time;if(r==e)return i;e<r?n=i-1:t=i+1}return t},e.addEvent=function(e){var t=this._binarySearchEventIndex(e.time);this._animationEvents.splice(t,0,e)},e.onAsynLoaded=function(e,t,n){var i=new g(t);switch(this._version=i.readUTFString(),this._version){case"LAYAANIMATION:01":L.parse(this,i);break;case"LAYAANIMATION:02":F.parse(this,i)}this.completeCreate(),this._endLoaded()},e.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 S.loader.create(e,null,null,t)},t}(),ii=function(){function t(){t.__super.call(this)}p(t,"laya.d3.core.Avatar",T);var e=t.prototype;return S.imps(e,{"laya.d3.core.IClone":!0}),e._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)},e._parseNode=function(e,t){var n,i=e.props.name;t.name=i,t._parent&&(n=e.customProps,(i=t.transform)._localRotationEuler=new Float32Array(3),i.setLocalPosition(new Float32Array(n.translate)),i.setLocalRotation(new Float32Array(n.rotation)),i.setLocalScale(new Float32Array(n.scale)),i._setWorldMatrixAndUpdate(new Float32Array(16)));for(var r=e.child,a=0,o=r.length;a<o;a++){var s=r[a],l=new U;t.addChild(l),this._parseNode(s,l)}},e.onAsynLoaded=function(e,t,n){var i;this._rootNode=new U,t.version?(this._version=t.version,(i=t.rootNode)&&this._parseNode(i,this._rootNode)):this._parseNode(t,this._rootNode),this._endLoaded()},e._cloneDatasToAnimator=function(e){var t=this._rootNode.clone();t.transform._setWorldMatrixIgnoreUpdate(null);e._avatarNodeMap={},e._avatarNodes=[],this._initCloneToAnimator(t,e)},e.cloneTo=function(e){var t=e,e=this._rootNode.clone();t._rootNode=e},e.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},t.load=function(e){return S.loader.create(e,null,null,t)},t}(),ri=function(i){function e(){e.__super.call(this),this._shaderDefineValue=0,this._disablePublicShaderDefine=0,this._shaderValues=new vn,this._values=[],this.renderQueue=2e3,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 _n(1,1,1,1),this.blendEquation=0,this.blendEquationRGB=0,this.blendEquationAlpha=0,this.depthTest=513,this.depthWrite=!0}p(e,"laya.d3.core.material.BaseMaterial",i);var t=e.prototype;return S.imps(t,{"laya.d3.core.IClone":!0}),t._addShaderDefine=function(e){this._shaderDefineValue|=e},t._removeShaderDefine=function(e){this._shaderDefineValue&=~e},t._addDisablePublicShaderDefine=function(e){this._disablePublicShaderDefine|=e},t._removeDisablePublicShaderDefine=function(e){this._disablePublicShaderDefine&=~e},t._setBuffer=function(e,t){this._shaderValues.setValue(e,t),this._values[e]=t},t._getBuffer=function(e){return this._values[e]},t._setMatrix4x4=function(e,t){this._shaderValues.setValue(e,t?t.elements:null),this._values[e]=t},t._getMatrix4x4=function(e){return this._values[e]},t._setInt=function(e,t){this._shaderValues.setValue(e,t),this._values[e]=t},t._getInt=function(e){return this._values[e]},t._setNumber=function(e,t){this._shaderValues.setValue(e,t),this._values[e]=t},t._getNumber=function(e){return this._values[e]},t._setBool=function(e,t){this._shaderValues.setValue(e,t),this._values[e]=t},t._getBool=function(e){return this._values[e]},t._setVector2=function(e,t){this._shaderValues.setValue(e,t?t.elements:null),this._values[e]=t},t._getVector2=function(e){return this._values[e]},t._setColor=function(e,t){this._shaderValues.setValue(e,t?t.elements:null),this._values[e]=t},t._getColor=function(e){return this._values[e]},t._setTexture=function(e,t){var n=this._values[e];this._values[e]=t,this._shaderValues.setValue(e,t),0<this.referenceCount&&(n&&n._removeReference(),t&&t._addReference())},t._getTexture=function(e){return this._values[e]},t._upload=function(){this._shader.uploadMaterialUniforms(this._shaderValues.data)},t._getShader=function(e,t,n){t=(e|t)&~this._disablePublicShaderDefine;return this._shader=this._shaderCompile.withCompile(t,n,this._shaderDefineValue),this._shader},t._setRenderStateBlendDepth=function(){var e=N.mainContext;switch(V.setDepthMask(e,this.depthWrite),0===this.depthTest?V.setDepthTest(e,!1):(V.setDepthTest(e,!0),V.setDepthFunc(e,this.depthTest)),this.blend){case 0:V.setBlend(e,!1);break;case 1:V.setBlend(e,!0),V.setBlendFunc(e,this.srcBlend,this.dstBlend);break;case 2:V.setBlend(e,!0)}},t._setRenderStateFrontFace=function(e,t){var n=N.mainContext,i=0;switch(this.cull){case 0:V.setCullFace(n,!1);break;case 1:V.setCullFace(n,!0),i=e?t&&t._isFrontFaceInvert?2305:2304:t&&t._isFrontFaceInvert?2304:2305,V.setFrontFace(n,i);break;case 2:V.setCullFace(n,!0),i=e?t&&t._isFrontFaceInvert?2304:2305:t&&t._isFrontFaceInvert?2305:2304,V.setFrontFace(n,i)}},t.onAsynLoaded=function(e,t,n){var i=t[0],r=t[1];switch(i.version){case"LAYAMATERIAL:01":var a,o=0,s=0,l=i.props;for(a in l)switch(a){case"vectors":for(var h=l[a],o=0,s=h.length;o<s;o++){var _=h[o],u=_.value;switch(u.length){case 2:this[_.name]=new ln(u[0],u[1]);break;case 3:this[_.name]=new hn(u[0],u[1],u[2]);break;case 4:this[_.name]=new _n(u[0],u[1],u[2],u[3]);break;default:throw new Error("BaseMaterial:unkonwn color length.")}}break;case"textures":var d=l[a];for(o=0,s=d.length;o<s;o++){var c=d[o],f=c.path;f&&(this[c.name]=W.getRes(r[f]))}break;case"defines":var m=l[a];for(o=0,s=m.length;o<s;o++){var p=this._shaderCompile.getMaterialDefineByName(m[o]);this._addShaderDefine(p)}break;case"cull":case"blend":case"srcBlend":case"dstBlend":case"depthWrite":this[a]=l[a];break;case"renderQueue":switch(l[a]){case 1:this.renderQueue=2e3;break;case 2:this.renderQueue=3e3}break;default:this[a]=l[a]}break;case"LAYAMATERIAL:02":for(a in l=i.props)switch(a){case"vectors":for(o=0,s=(h=l[a]).length;o<s;o++)switch((u=(_=h[o]).value).length){case 2:this[_.name]=new ln(u[0],u[1]);break;case 3:this[_.name]=new hn(u[0],u[1],u[2]);break;case 4:this[_.name]=new _n(u[0],u[1],u[2],u[3]);break;default:throw new Error("BaseMaterial:unkonwn color length.")}break;case"textures":for(o=0,s=(d=l[a]).length;o<s;o++)(f=(c=d[o]).path)&&(this[c.name]=W.getRes(r[f]));break;case"defines":for(o=0,s=(m=l[a]).length;o<s;o++)p=this._shaderCompile.getMaterialDefineByName(m[o]),this._addShaderDefine(p);break;default:this[a]=l[a]}break;default:throw new Error("BaseMaterial:unkonwn version.")}this._endLoaded()},t._addReference=function(){i.prototype._addReference.call(this);for(var e=0,t=this._values.length;e<t;e++){var n=this._values[e];n&&n instanceof laya.d3.resource.BaseTexture&&n._addReference()}},t._removeReference=function(){i.prototype._removeReference.call(this);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()}},t.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},t.setShaderName=function(e){e=Vi.nameKey.getID(e);if(-1===e)throw new Error("BaseMaterial: unknown shader name.");this._shaderCompile=$n._preCompileShader[e]},t.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=0,i=t._shaderValues;t._shaderValues.data.length=this._shaderValues.data.length;for(var e=this._values.length,r=t._values,n=0,a=r.length=e;n<a;n++){var o,s,l=this._values[n];l&&("number"==typeof l||"number"==typeof l&&Math.floor(l)==l||"boolean"==typeof l?(r[n]=l,i.data[n]=l):l instanceof laya.d3.math.Vector2?(o=r[n]||(r[n]=new ln),l.cloneTo(o),i.data[n]=o.elements):l instanceof laya.d3.math.Vector3?(o=r[n]||(r[n]=new hn),l.cloneTo(o),i.data[n]=o.elements):l instanceof laya.d3.math.Vector4?(s=r[n]||(r[n]=new _n),l.cloneTo(s),i.data[n]=s.elements):l instanceof laya.d3.math.Matrix4x4?(s=r[n]||(r[n]=new Jt),l.cloneTo(s),i.data[n]=s.elements):l instanceof laya.d3.resource.BaseTexture&&(r[n]=l,i.data[n]=l))}},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},_(0,t,"alphaTestValue",function(){return this._getNumber(0)},function(e){this._setNumber(0,e)}),_(0,t,"alphaTest",function(){return this._alphaTest},function(e){(this._alphaTest=e)?this._addShaderDefine(laya.d3.core.material.BaseMaterial.SHADERDEFINE_ALPHATEST):this._removeShaderDefine(laya.d3.core.material.BaseMaterial.SHADERDEFINE_ALPHATEST)}),e.__init__=function(){e.SHADERDEFINE_ALPHATEST=e.shaderDefines.registerDefine("ALPHATEST")},e.RENDERQUEUE_OPAQUE=2e3,e.RENDERQUEUE_ALPHATEST=2450,e.RENDERQUEUE_TRANSPARENT=3e3,e.CULL_NONE=0,e.CULL_FRONT=1,e.CULL_BACK=2,e.BLEND_DISABLE=0,e.BLEND_ENABLE_ALL=1,e.BLEND_ENABLE_SEPERATE=2,e.BLENDPARAM_ZERO=0,e.BLENDPARAM_ONE=1,e.BLENDPARAM_SRC_COLOR=768,e.BLENDPARAM_ONE_MINUS_SRC_COLOR=769,e.BLENDPARAM_DST_COLOR=774,e.BLENDPARAM_ONE_MINUS_DST_COLOR=775,e.BLENDPARAM_SRC_ALPHA=770,e.BLENDPARAM_ONE_MINUS_SRC_ALPHA=771,e.BLENDPARAM_DST_ALPHA=772,e.BLENDPARAM_ONE_MINUS_DST_ALPHA=773,e.BLENDPARAM_SRC_ALPHA_SATURATE=776,e.BLENDEQUATION_ADD=0,e.BLENDEQUATION_SUBTRACT=1,e.BLENDEQUATION_REVERSE_SUBTRACT=2,e.DEPTHTEST_OFF=0,e.DEPTHTEST_NEVER=512,e.DEPTHTEST_LESS=513,e.DEPTHTEST_EQUAL=514,e.DEPTHTEST_LEQUAL=515,e.DEPTHTEST_GREATER=516,e.DEPTHTEST_NOTEQUAL=517,e.DEPTHTEST_GEQUAL=518,e.DEPTHTEST_ALWAYS=519,e.SHADERDEFINE_ALPHATEST=1,e.ALPHATESTVALUE=0,l(e,["shaderDefines",function(){return this.shaderDefines=new fn}]),e}(T),ai=function(){function e(){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,this._conchTexture=null,this._wrapModeU=0,this._wrapModeV=0,e.__super.call(this),this._repeat=!0,this.mipmap=!0,this.minFifter=-1,this.magFifter=-1}p(e,"laya.d3.resource.BaseTexture",T);var t=e.prototype;return _(0,t,"width",function(){return this._width}),_(0,t,"repeat",function(){return this._repeat},function(e){this._repeat!==e&&(this._repeat=e,this._source&&(e=N.mainContext,V.bindTexture(e,this._type,this._source),f.isPOT(this._width,this._height)&&this._repeat?(e.texParameteri(this._type,10242,10497),e.texParameteri(this._type,10243,10497)):(e.texParameteri(this._type,10242,33071),e.texParameteri(this._type,10243,33071))))}),_(0,t,"height",function(){return this._height}),_(0,t,"magFifter",function(){return this._magFifter},function(e){(this._magFifter=e)!=this._magFifter&&this._conchTexture&&this._conchTexture.setMaxFifter(e)}),_(0,t,"wrapModeV",function(){return this._wrapModeV}),_(0,t,"size",function(){return this._size}),_(0,t,"wrapModeU",function(){return this._wrapModeU}),_(0,t,"mipmap",function(){return this._mipmap},function(e){this._mipmap=e,this._mipmap!=e&&this._conchTexture&&this._conchTexture.setMipMap(e)}),_(0,t,"minFifter",function(){return this._minFifter},function(e){this._minFifter=e,this._minFifter!=e&&this._conchTexture&&this._conchTexture.setMinFifter(e)}),_(0,t,"format",function(){return this._format}),_(0,t,"source",function(){return this.activeResource(),this._source}),_(0,t,"defaulteTexture",function(){return nr.grayTexture}),e.WARPMODE_REPEAT=0,e.WARPMODE_CLAMP=1,e}(),oi=function(){function e(){this._subMeshCount=0,this._boundingBox=null,this._boundingSphere=null,this._boundingBoxCorners=null,this._positions=null,e.__super.call(this),this._boundingBoxCorners=v(8,null)}p(e,"laya.d3.resource.models.BaseMesh",T);var t=e.prototype;return t._getPositions=function(){throw new Error("未Override,请重载该属性!")},t._generateBoundingObject=function(){this._boundingSphere=new Yt(new hn,0),Yt.createfromPoints(this._positions,this._boundingSphere),this._boundingBox=new kt(new hn,new hn),kt.createfromPoints(this._positions,this._boundingBox),this._boundingBox.getCorners(this._boundingBoxCorners)},t.getRenderElementsCount=function(){throw new Error("未Override,请重载该属性!")},t.getRenderElement=function(e){throw new Error("未Override,请重载该属性!")},_(0,t,"subMeshCount",function(){return this._subMeshCount}),_(0,t,"boundingBox",function(){return this._boundingBox}),_(0,t,"boundingBoxCorners",function(){return this._boundingBoxCorners}),_(0,t,"boundingSphere",function(){return this._boundingSphere}),e}(),si=(p(li,"laya.d3.terrain.TerrainHeightData",T),li.prototype.onAsynLoaded=function(e,t,n){var i;this._width=n[0],this._height=n[1],this._bitType=n[2],this._value=n[3];var 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()},li.load=function(e,t,n,i,r){return S.loader.create(e,null,null,li,[t,n,i,r],1,!1)},li);function li(){this._terrainHeightData=null,this._width=0,this._height=0,this._bitType=0,this._value=NaN,li.__super.call(this)}var hi=function(){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)}p(t,"laya.d3.terrain.TerrainRes",T);var e=t.prototype;return e.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;this._heightDataX=i.numX,this._heightDataZ=i.numZ,this._heightDataBitType=i.bitType,this._heightDataValue=i.value,this._heightDataUrl=n[i.url],this._materialInfo=new Rn,t.material&&(e=t.material.ambient,i=t.material.diffuse,l=t.material.specular,this._materialInfo.ambientColor=new hn(e[0],e[1],e[2]),this._materialInfo.diffuseColor=new hn(i[0],i[1],i[2]),this._materialInfo.specularColor=new _n(l[0],l[1],l[2],l[3]));var r=t.detailTexture;this._detailTextureInfos=v(r.length);for(var a=0;a<r.length;a++){var o=r[a],s=new xn;s.diffuseTexture=n[o.diffuse],s.normalTexture=o.normal?n[o.normal]:null,o.scale?s.scale=new ln(o.scale[0],o.scale[1]):s.scale=new ln(1,1),o.offset?s.offset=new ln(o.offset[0],o.offset[1]):s.offset=new ln(0,0),this._detailTextureInfos[a]=s}var l=t.alphaMap;for(this._alphaMaps=v(l.length),a=0;a<this._alphaMaps.length;a++)this._alphaMaps[a]=t.alphaMap[a];l=t.normalMap;for(this._normalMaps=v(l.length),a=0;a<this._normalMaps.length;a++)this._normalMaps[a]=t.normalMap[a];var h=t.chunkInfo;if(this._chunkNumX*this._chunkNumZ!=h.length)return alert("terrain data error"),!1;for(this._chunkInfos=v(h.length),a=0;a<h.length;a++){var _=h[a],u=new Sn,d=_.alphaMap.length,c=_.detailID.length;if(d!=c)return alert("terrain chunk data error"),!1;u.alphaMap=v(d),u.detailID=v(c),u.normalMap=n[this._normalMaps[_.normalMap]];for(var f=0;f<d;f++){u.alphaMap[f]=n[this._alphaMaps[_.alphaMap[f]]];var m=_.detailID[f],p=m.length;u.detailID[f]=new Uint8Array(p);for(var E=0;E<p;E++)u.detailID[f][E]=m[E]}this._chunkInfos[a]=u}this._heightData=W.getRes(this._heightDataUrl),this.onLoadTerrainComplete(this._heightData)}return!0},e.onLoadTerrainComplete=function(e){this._endLoaded()},e.onAsynLoaded=function(e,t,n){this.parseData(t)},t.load=function(e){return S.loader.create(e,null,null,t,null,1,!1)},t}(),dn=function(t){function e(){this._player=null,this._templet=null,e.__super.call(this),this._player=new i}p(e,"laya.d3.component.animation.KeyframeAnimations",t);var n=e.prototype;return n._updateAnimtionPlayer=function(){this._player._update(S.timer.delta)},n._addUpdatePlayerToTimer=function(){S.timer.frameLoop(1,this,this._updateAnimtionPlayer)},n._removeUpdatePlayerToTimer=function(){S.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(e){t.prototype._unload.call(this,e),e.activeInHierarchy&&this._removeUpdatePlayerToTimer(),e.off("activeinhierarchychanged",this,this._onOwnerActiveHierarchyChanged),this._player._destroy(),this._player=null,this._templet=null},_(0,n,"url",null,function(e){console.log("Warning: discard property,please use templet property instead.");e=S.loader.create(e,null,null,r);this._templet!==e&&(0!==this._player.state&&this._player.stop(!0),this._templet=e,this._player.templet=e,this.event("animationchanged",this))}),_(0,n,"player",function(){return this._player}),_(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))}),_(0,n,"currentFrameIndex",function(){return this._player.currentKeyframeIndex}),_(0,n,"currentAnimationClipIndex",function(){return this._player.currentAnimationClipIndex}),_(0,n,"nodeCount",function(){return this._templet.getNodeCount(this._player.currentAnimationClipIndex)}),e}(Un),_i=function(n){function h(){h.__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}p(h,"laya.d3.component.Animator",n);var e=h.prototype;return S.imps(e,{"laya.resource.IDestroy":!0}),e._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 d=U._propertyGetFuncs[s.propertyNameID](o);if(d){var c=new Float32Array(s.keyFrameWidth);for(r[a]=c,h=0,_=d.length;h<_;h++)c[h]=d[h]}}}},e._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++){for(var o=this._owner,s=t[a],l=s.path,h=0,_=0,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 d=U._propertyGetFuncs[s.propertyNameID](null,o);if(d){var c=new Float32Array(s.keyFrameWidth);for(r[a]=c,h=0,_=d.length;h<_;h++)c[h]=d[h]}}}},e._offClipAndAvatarRelateEvent=function(e,t){e.loaded?t.loaded||t.off("loaded",this,this._getAvatarOwnersByClip):e.off("loaded",this,this._getAvatarOwnersAndInitDatasAsync)},e._getAvatarOwnersByClipAsync=function(e,t){t.loaded?this._getAvatarOwnersByClip(e):t.once("loaded",this,this._getAvatarOwnersByClip,[e])},e._offGetSpriteOwnersByClipAsyncEvent=function(e){e.loaded||e.off("loaded",this,this._getSpriteOwnersByClipAsync)},e._getSpriteOwnersByClipAsync=function(e,t){t.loaded?this._handleSpriteOwnersByClip(e):t.once("loaded",this,this._handleSpriteOwnersByClip,[e])},e._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)},e._offGetClipCacheFullKeyframeIndicesEvent=function(e){e.loaded||e.off("loaded",this,this._computeCacheFullKeyframeIndices)},e._computeCacheFullKeyframeIndices=function(e){var t=this._clips[e],n=this._cacheFrameRateInterval*this._cachePlayRate;if(i=t._getFullKeyframeIndicesWithCache(n))this._cacheFullFrames[e]=i;else{var i=this._cacheFullFrames[e]=[],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,d=_.length;u<d;u++)for(var c=_[u],f=c.startTime,m=f+c.duration;f<=m;)h[Math.ceil(f/n-1e-5)]=u,f+=n;i[s]=h}t._cacheFullKeyframeIndices(n,i)}},e._updateAnimtionPlayer=function(){this._updatePlayer(S.timer.delta/1e3)},e._onOwnerActiveHierarchyChanged=function(){this._owner.activeInHierarchy?(S.timer.frameLoop(1,this,this._updateAnimtionPlayer),this.playOnWake&&this.clip&&this.play()):(0!==this.playState&&(this._stoped=!0),S.timer.clear(this,this._updateAnimtionPlayer))},e._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)}}},e._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)},e._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},e._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&&U._propertySetFuncs[i[a].propertyNameID](s,null,n[a])}else for(var l=this._cacheNodesSpriteOwners[t],a=0,o=l.length;a<o;a++){var h=l[a];h&&U._propertySetFuncs[i[a].propertyNameID](null,h,n[a])}},e._onAnimationStop=function(){var e=0,t=0;this._lastFrameIndex=-1;var n=this._currentPlayClip._nodes;if(this._avatar)for(var i=this._cacheNodesAvatarOwners[this._currentPlayClipIndex],e=0,t=i.length;e<t;e++){var r,a,o=i[e],s=(a=(r=n[e]).keyFrames)[a.length-1].data;o&&U._propertySetFuncs[r.propertyNameID](o,null,s)}else{var l=this._cacheNodesSpriteOwners[this._currentPlayClipIndex];for(e=0,t=l.length;e<t;e++){var h=l[e];s=(a=(r=n[e]).keyFrames)[a.length-1].data,h&&U._propertySetFuncs[r.propertyNameID](null,h,s)}}},e._setAnimationClipPropertyToAnimationNode=function(e,t,n){for(var i=0,r=t.length;i<r;i++){var a,o=t[i],s=e[o];s&&(a=this._currentPlayClip._nodes[o],(o=n[o])&&U._propertySetFuncs[a.propertyNameID](s,null,o))}},e._setAnimationClipPropertyToSprite3D=function(e,t){for(var n=0,i=e.length;n<i;n++){var r,a,o=e[n];o&&(r=this._currentPlayClip._nodes[n],(a=t[n])&&U._propertySetFuncs[r.propertyNameID](null,o,a))}},e._handleSpriteOwnersBySprite=function(e,t,n,i){var r=this._clips[e],n=n.join("/"),a=r._nodesMap[n];if(a)for(var o=this._cacheNodesSpriteOwners[e],s=r._nodes,l=this._cacheNodesDefaultlValues[e],h=0,_=a.length;h<_;h++){var u=a[h],d=s.indexOf(u);if(t){o[d]=i;var c=U._propertyGetFuncs[u.propertyNameID](null,i);if(c){var f=l[d];f||(l[d]=f=new Float32Array(u.keyFrameWidth));for(var m=0,p=c.length;m<p;m++)f[m]=c[m]}}else o[d]=null}},e._evaluateAvatarNodesCacheMode=function(e,t,n,i,r){t._evaluateAnimationlDatasCacheMode(e,this._cacheFullFrames[this._currentPlayClipIndex],this,n,r),this._setAnimationClipPropertyToAnimationNode(e,r,n);for(var a=0,o=this._avatarNodes.length;a<o;a++){var s,l=this._avatarNodes[a].transform;l._worldUpdate?(s=new Float32Array(16),i[a]=s,l._setWorldMatrixAndUpdate(s)):(l=l.getWorldMatrix(),i[a]=l||h.deafaultMatrix)}},e._evaluateAvatarNodesRealTime=function(e,t,n,i,r){t._evaluateAnimationlDatasRealTime(e,this.currentPlayTime,n,r),this._setAnimationClipPropertyToAnimationNode(e,r,n);for(var a=0,o=this._avatarNodes.length;a<o;a++){var s=this._avatarNodes[a].transform;s._worldUpdate?s._setWorldMatrixNoUpdate(i[a]):i[a]=h.deafaultMatrix}},e._updateAvatarNodesToSpriteCacheMode=function(e,t){for(var n=0,i=this._cacheSpriteToNodesMap.length;n<i;n++){var r,a=this._cacheSpriteToNodesMap[n],o=t[a];o!==h.deafaultMatrix&&(a=(r=this._avatarNodes[a].transform._entity).worldMatrix,wn.matrix4x4MultiplyMFM(this._owner._transform.worldMatrix,o,a),r.worldMatrix=a)}},e._updateAvatarNodesToSpriteRealTime=function(){for(var e=0,t=this._cacheSpriteToNodesMap.length;e<t;e++){var n=this._avatarNodes[this._cacheSpriteToNodesMap[e]],i=n.transform._entity,r=n.transform;r._worldUpdate&&(n=h._tempMatrix4x40,r._setWorldMatrixAndUpdate(n),r=i.worldMatrix,wn.matrix4x4MultiplyMFM(this._owner._transform.worldMatrix,n,r),i.worldMatrix=r)}},e._updatePlayer=function(e){if(null!=this._currentPlayClip&&!this._stoped&&this._currentPlayClip.loaded){var t=this._cacheFrameRateInterval*this._cachePlayRate,n=0;this._startUpdateLoopCount!==I.loopCount&&(n=e*this.playbackRate,this._elapsedPlaybackTime+=n);var i=this._currentPlayClip._frameRate,e=this._playStartFrames[this._currentPlayClipIndex]/i,r=Math.min(this._playEndFrames[this._currentPlayClipIndex]/i,this._currentPlayClip._duration)-e;if(!this._currentPlayClip.islooping&&this._elapsedPlaybackTime>=r)return this._onAnimationStop(),this._setPlayParamsWhenStop(r,t),void this.event("stopped");if(n+=this._currentTime,0<r)if(r<=n)for(;(n-=r)<r&&(this._setPlayParams(n,t),this.event("complete")),this._playEventIndex=0,this._eventScript(0,n),r<=n;);else this._setPlayParams(n,t);else this._currentTime=this._currentFrameTime=this._currentFrameIndex=this._playEventIndex=0,this.event("complete")}},e._update=function(e){var t=this._currentPlayClip;if(2===this.playState&&t&&t.loaded){var n=this.playbackRate*S.timer.scale,i=this._cachePlayRate;this._canCache=this.isCache&&i<=n;var r=-1;if(this._canCache){if(r=this._currentFrameIndex,this._lastFrameIndex===r)return;var a,o,s=t._getAnimationDataWithCache(i,r);this._avatar?(o=this._cacheNodesAvatarOwners[this._currentPlayClipIndex],0<(n=(a=t._cachePropertyMap).length)&&(s||((s=[]).length=n,t._cacheAnimationData(i,r,s),t._evaluateAnimationlDatasCacheMode(o,this._cacheFullFrames[this._currentPlayClipIndex],this,s,a)),this._setAnimationClipPropertyToAnimationNode(o,a,s)),this._curAvatarNodeDatas=t._getAvatarDataWithCache(this._avatar,this._cachePlayRate,r),this._curAvatarNodeDatas||(this._curAvatarNodeDatas=[],this._curAvatarNodeDatas.length=this._avatarNodes.length,t._cacheAvatarData(this._avatar,this._cachePlayRate,r,this._curAvatarNodeDatas),this._evaluateAvatarNodesCacheMode(o,t,t._publicClipDatas,this._curAvatarNodeDatas,t._unCachePropertyMap)),this._updateAvatarNodesToSpriteCacheMode(t,this._curAvatarNodeDatas)):(o=this._cacheNodesSpriteOwners[this._currentPlayClipIndex],s||((s=[]).length=this._currentPlayClip._nodes.length,t._evaluateAnimationlDatasCacheMode(o,this._cacheFullFrames[this._currentPlayClipIndex],this,s,null),t._cacheAnimationData(i,r,s)),this._setAnimationClipPropertyToSprite3D(o,s))}else if(s=t._publicClipDatas,this._avatar){if(t._evaluateAnimationlDatasRealTime(this._cacheNodesAvatarOwners[this._currentPlayClipIndex],this.currentPlayTime,s,t._cachePropertyMap),!this._publicAvatarNodeDatas){this._publicAvatarNodeDatas=[];var l=this._avatarNodes.length;this._publicAvatarNodeDatas.length=l;for(var h=1;h<l;h++)this._publicAvatarNodeDatas[h]=new Float32Array(16)}this._curAvatarNodeDatas=this._publicAvatarNodeDatas,this._evaluateAvatarNodesRealTime(this._cacheNodesAvatarOwners[this._currentPlayClipIndex],t,s,this._curAvatarNodeDatas,t._unCachePropertyMap),this._updateAvatarNodesToSpriteRealTime()}else t._evaluateAnimationlDatasRealTime(this._cacheNodesSpriteOwners[this._currentPlayClipIndex],this.currentPlayTime,s,null);this._lastFrameIndex=r}},e._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))},e._load=function(e){e.activeInHierarchy&&S.timer.frameLoop(1,this,this._updateAnimtionPlayer),this._owner.on("activeinhierarchychanged",this,this._onOwnerActiveHierarchyChanged)},e._unload=function(e){n.prototype._unload.call(this,e),e.activeInHierarchy&&S.timer.clear(this,this._updateAnimtionPlayer),this._owner.off("activeinhierarchychanged",this,this._onOwnerActiveHierarchyChanged),this._curAvatarNodeDatas=null},e._destroy=function(){n.prototype._destroy.call(this);for(var e=0,t=this._clips.length;e<t;e++)this._clips[e]._removeReference();this._currentPlayClip=null,this._clipNames=null,this._cacheNodesSpriteOwners=null,this._cacheNodesAvatarOwners=null,this._cacheNodesDefaultlValues=null,this._clips=null,this._cacheFullFrames=null},e._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]);if(this.clip&&(t.clip=this.clip),this._linkSpritesData)for(var r in t._linkSpritesData={},this._linkSpritesData)t._linkSpritesData[r]=this._linkSpritesData[r].slice()},e.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{r=this._clips.indexOf(e);if(n<0||i<0)throw new Error("Animator:startFrame and endFrame must large than zero.");if(i<n)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(),r=this._clips.length-1,this._avatar?this._avatar.loaded?this._getAvatarOwnersByClipAsync(r,e):this._avatar.once("loaded",this,this._getAvatarOwnersByClipAsync,[r,e]):this._getSpriteOwnersByClipAsync(r,e),e.loaded?this._computeCacheFullKeyframeIndices(r):e.once("loaded",this,this._computeCacheFullKeyframeIndices,[r])}},e.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())},e.removeClipByName=function(e){var t=this._clipNames.indexOf(e);-1!==t&&(e=this._clips[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.getClip=function(e){e=this._clipNames.indexOf(e);return-1!==e?this._clips[e]:null},e.getClipCount=function(){return this._clips.length},e.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=I.loopCount,this._lastPlayAnimationClip&&this._lastPlayAnimationClip!==this._currentPlayClip&&this._revertKeyframeNodes(this._lastPlayAnimationClip,this._lastPlayAnimationClipIndex),this._updatePlayer(0),this._lastPlayAnimationClip=this._currentPlayClip,this._lastPlayAnimationClipIndex=this._currentPlayClipIndex},e.stop=function(){0!==this.playState&&(this._stoped=!0,this.event("stopped"))},e._getLinkSpritePath=function(e,t){t.unshift(e.name);e=e._parent;e._hierarchyAnimator===this?this._getLinkSpritePath(e,t):t.shift()},e.linkSprite3DToAvatarNode=function(e,t){if(t._hierarchyAnimator!==this)throw"Animator:sprite3D must belong to this Animator";if(this._avatar){var n=this._avatarNodeMap[e];if(n){this._linkSpritesData=this._linkSpritesData||{};var i=[];return this._getLinkSpritePath(t,i),this._linkSpritesData[e]=i,t._isLinkSpriteToAnimationNode(this,n,!0),!0}return!1}return!1},e.unLinkSprite3DToAvatarNode=function(e){if(this._avatar){var t=e.transform.dummy;if(t){t=this._avatarNodeMap[t._owner.name];return e._isLinkSpriteToAnimationNode(this,t,!1),!0}return!1}return!1},_(0,e,"playState",function(){return null==this._currentPlayClip||this._stoped?0:2}),_(0,e,"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))}}),_(0,e,"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)}}),_(0,e,"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)}),_(0,e,"currentFrameIndex",function(){return this._currentFrameIndex}),_(0,e,"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)}}),_(0,e,"currentFrameTime",function(){return this._currentFrameTime}),_(0,e,"currentPlayClip",function(){return this._currentPlayClip}),_(0,e,"currentPlayTime",function(){return this._currentTime+this._playStartFrames[this._currentPlayClipIndex]/this._currentPlayClip._frameRate}),_(0,e,"playbackTime",null,function(e){var t;null!=this._currentPlayClip&&this._currentPlayClip&&this._currentPlayClip.loaded&&(this._startUpdateLoopCount=I.loopCount,t=this._cacheFrameRateInterval*this._cachePlayRate,this._currentTime=e,this._currentFrameIndex=Math.floor(this.currentPlayTime/t),this._currentFrameTime=this._currentFrameIndex*t)}),_(0,e,"paused",function(){return this._stoped},function(e){(this._stoped=e)&&this.event("paused")}),l(h,["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)}]),h}(Un),ui=(function(t){function e(){this._attachSkeleton=null,this._extenData=null,this.attachBones=null,this.matrixs=null,e.__super.call(this),this.attachBones=[],this.matrixs=[]}p(e,"laya.d3.component.AttachPoint",t);var n=e.prototype;n._load=function(e){t.prototype._load.call(this,e),this._attachSkeleton=e.getComponentByType(ji)},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++){for(var s=16*n.getNodeIndexWithName(t.currentAnimationClipIndex,this.attachBones[a]),l=this.matrixs[a],h=(l=l||(this.matrixs[a]=new Jt)).elements,_=0;_<16;_++)h[_]=i[s+_];Jt.multiply(r,l,l)}this.event("complete")}}}(Un),function(e){function t(){t.__super.call(this),this._isRigidbody=!1,this._runtimeCollisonMap={},this._runtimeCollisonTestMap={},this._ignoreCollisonMap={},this.isTrigger=!0}p(t,"laya.d3.component.physics.Collider",e);var n=t.prototype;return n._clearCollsionMap=function(){for(var e in this._runtimeCollisonMap){e=this._runtimeCollisonMap[e];delete e._runtimeCollisonMap[this.id],e._isRigidbody&&delete e._runtimeCollisonTestMap[this.id];e=e.id;delete this._runtimeCollisonMap[e],this._isRigidbody&&delete this._runtimeCollisonTestMap[e]}},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){this._isRigidbody!==e&&(this._isRigidbody=e,(e=this._owner).displayedInStage&&((e=e.layer)._removeCollider(this),e._addCollider(this)))},n._getType=function(){return-1},n._collisonTo=function(e){return!1},n.raycast=function(e,t,n){throw void 0===n&&(n=179e306),new Error("Collider:Must override it.")},_(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))}),_(0,n,"isSingleton",function(){return t._isSingleton}),t._isSingleton=!1,t}(Un)),di=function(e){function t(){t.__super.call(this)}p(t,"laya.d3.component.Rigidbody",e);var n=t.prototype;return _(0,n,"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}(Un),ci=(function(){function e(){e.__super.call(this)}p(e,"laya.d3.component.Script",Un);var t=e.prototype;t.onTriggerEnter=function(e){},t.onTriggerExit=function(e){},t.onTriggerStay=function(e){},_(0,t,"isSingleton",function(){return e._isSingleton}),e._isSingleton=!1}(),function(){function t(e){t.__super.call(this,e)}p(t,"laya.d3.core.GlitterRender",Gn);var e=t.prototype;return e._calculateBoundingBox=function(){var e=this._boundingBox.min.elements;e[0]=-Number.MAX_VALUE,e[1]=-Number.MAX_VALUE,e[2]=-Number.MAX_VALUE;e=this._boundingBox.min.elements;e[0]=Number.MAX_VALUE,e[1]=Number.MAX_VALUE,e[2]=Number.MAX_VALUE},e._calculateBoundingSphere=function(){var e=this._boundingSphere.center.elements;e[0]=0,e[1]=0,e[2]=0,this._boundingSphere.radius=Number.MAX_VALUE},e._renderUpdate=function(e){this._setShaderValueMatrix4x4(0,this._owner.transform.worldMatrix);e=this._owner.getProjectionViewWorldMatrix(e);this._setShaderValueMatrix4x4(1,e);e=this._owner.templet;return this._setShaderValueNumber(3,e.lifeTime),this._setShaderValueNumber(2,e._currentTime),!0},t}()),fi=function(e){function t(e){this._owner=null,this._sharedMesh=null,t.__super.call(this),this._owner=e}p(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)},_(0,n,"sharedMesh",function(){return this._sharedMesh},function(e){var t=this._sharedMesh;t&&t._removeReference(),(this._sharedMesh=e)._addReference(),this.event("meshchanged",[this,t,e]),e.loaded||this._sharedMesh.once("loaded",this,this._sharedMeshLoaded)}),_(0,n,"_isAsyncLoaded",function(){return this._sharedMesh.loaded}),_(0,n,"_originalBoundingBoxCorners",function(){return this._sharedMesh.boundingBoxCorners}),_(0,n,"_originalBoundingSphere",function(){return this._sharedMesh.boundingSphere}),_(0,n,"_originalBoundingBox",function(){return this._sharedMesh.boundingBox}),t}(Hn),mi=function(){function t(e){t.__super.call(this,e),e.meshFilter.on("meshchanged",this,this._onMeshChanged)}p(t,"laya.d3.core.MeshRender",Gn);var e=t.prototype;return e._onMeshChanged=function(e,t,n){n.loaded?this._boundingSphereNeedChange=this._boundingBoxNeedChange=this._boundingBoxCenterNeedChange=this._octreeNodeNeedChange=!0:n.once("loaded",this,this._onMeshLoaed)},e._onMeshLoaed=function(e,t){this._boundingSphereNeedChange=this._boundingBoxNeedChange=this._boundingBoxCenterNeedChange=this._octreeNodeNeedChange=!0},e._calculateBoundingSphereByInitSphere=function(e){var t=NaN,n=this._owner.transform,i=n.scale.elements,r=Math.abs(i[0]),a=Math.abs(i[1]),i=Math.abs(i[2]),t=a<=r&&i<=r?r:i<=a?a:i;hn.transformCoordinate(e.center,n.worldMatrix,this._boundingSphere.center),this._boundingSphere.radius=e.radius*t},e._calculateBoundBoxByInitCorners=function(e){for(var t=this._owner.transform.worldMatrix,n=0;n<8;n++)hn.transformCoordinate(e[n],t,Gn._tempBoundBoxCorners[n]);kt.createfromPoints(Gn._tempBoundBoxCorners,this._boundingBox)},e._calculateBoundingSphere=function(){var e=this._owner.meshFilter.sharedMesh;null==e||null==e.boundingSphere?this._boundingSphere.toDefault():this._calculateBoundingSphereByInitSphere(e.boundingSphere)},e._calculateBoundingBox=function(){var e=this._owner.meshFilter.sharedMesh;null==e||null==e.boundingBox?this._boundingBox.toDefault():this._calculateBoundBoxByInitCorners(e.boundingBoxCorners)},e._renderUpdate=function(e){var t=this._owner.transform;return t?(this._setShaderValueMatrix4x4(0,t.worldMatrix),t=this._owner.getProjectionViewWorldMatrix(e),this._setShaderValueMatrix4x4(1,t)):(this._setShaderValueMatrix4x4(0,Jt.DEFAULT),this._setShaderValueMatrix4x4(1,e)),Pn.debugMode&&this._renderRenderableBoundBox(),!0},t}(),pi=function(e){function z(e){z.__super.call(this),this._tempRotationMatrix=new Jt,this._uvLength=new ln,this._firstActiveElement=0,this._firstNewElement=0,this._firstFreeElement=0,this._firstRetiredElement=0,this._owner=e,this._ownerRender=e.particleRender,this._boundingBoxCorners=v(8,null),this._boundingSphere=new Yt(new hn,Number.MAX_VALUE),this._boundingBox=new kt(new hn(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),new hn(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 ne,this._startLifetimeConstantMin=0,this._startLifetimeConstantMax=5,this._startLifeTimeGradientMin=new ne,this._startLifeTimeGradientMax=new ne,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 hn(1,1,1),this.startSizeConstantMin=0,this.startSizeConstantMax=1,this.startSizeConstantMinSeparate=new hn(0,0,0),this.startSizeConstantMaxSeparate=new hn(1,1,1),this.threeDStartRotation=!1,this.startRotationType=0,this.startRotationConstant=0,this.startRotationConstantSeparate=new hn(0,0,0),this.startRotationConstantMin=0,this.startRotationConstantMax=0,this.startRotationConstantMinSeparate=new hn(0,0,0),this.startRotationConstantMaxSeparate=new hn(0,0,0),this.randomizeRotationDirection=0,this.startColorType=0,this.startColorConstant=new _n(1,1,1,1),this.startColorConstantMin=new _n(1,1,1,1),this.startColorConstantMax=new _n(1,1,1,1),this.gravityModifier=0,this.simulationSpace=1,this.scaleMode=0,this.playOnAwake=!0,this._rand=new an(0),this.autoRandomSeed=!0,this.randomSeed=new Uint32Array(1),this._randomSeeds=new Uint32Array(z._RANDOMOFFSET.length),this.isPerformanceMode=!0,this._emission=new q,this._emission.enbale=!0,this._owner.on("activeinhierarchychanged",this,this._onOwnerActiveHierarchyChanged)}p(z,"laya.d3.core.particleShuriKen.ShurikenParticleSystem",e);var t=z.prototype;return S.imps(t,{"laya.d3.core.render.IRenderable":!0,"laya.d3.core.IClone":!0}),t._getVertexBuffer=function(e){return 0===(e=void 0===e?0:e)?this._vertexBuffer:null},t._getIndexBuffer=function(){return this._indexBuffer},t._generateBoundingSphere=function(){var e=this._boundingSphere.center.elements;e[0]=0,e[1]=0,e[2]=0,this._boundingSphere.radius=Number.MAX_VALUE},t._generateBoundingBox=function(){var e=this._owner.particleRender,t=this._boundingBox.min,n=this._boundingBox.max,i=0,r=0,a=NaN;switch(this.startLifetimeType){case 0:a=this.startLifetimeConstant;break;case 1:for(var a=-Number.MAX_VALUE,o=o,i=0,r=o.gradientCount;i<r;i++)a=Math.max(a,o.getValueByIndex(i));break;case 2:a=Math.max(this.startLifetimeConstantMin,this.startLifetimeConstantMax);break;case 3:a=-Number.MAX_VALUE;var s=s;for(i=0,r=s.gradientCount;i<r;i++)a=Math.max(a,s.getValueByIndex(i));var l=l;for(i=0,r=l.gradientCount;i<r;i++)a=Math.max(a,l.getValueByIndex(i))}var h,_,u,d,c=NaN,f=NaN;switch(this.startSpeedType){case 0:c=f=this.startSpeedConstant;break;case 1:break;case 2:c=this.startLifetimeConstantMin,f=this.startLifetimeConstantMax}this._shape&&this._shape.enable||(h=_=hn.ZERO,u=hn.ZERO,d=hn.UnitZ);var m,p=new hn(u.x*c,u.y*c,u.z*c),E=new hn(d.x*f,d.y*f,d.z*f);if(this._velocityOverLifetime&&this._velocityOverLifetime.enbale){var v=this._velocityOverLifetime.velocity;switch(v.type){case 0:v.constant;break;case 1:new hn(v.gradientX.getAverageValue(),v.gradientY.getAverageValue(),v.gradientZ.getAverageValue());break;case 2:v.constantMin,v.constantMax;break;case 3:new hn(v.gradientXMin.getAverageValue(),v.gradientYMin.getAverageValue(),v.gradientZMin.getAverageValue()),new hn(v.gradientXMax.getAverageValue(),v.gradientYMax.getAverageValue(),v.gradientZMax.getAverageValue())}}var g,T,S=this._owner.transform,D=S.position,x=z._tempVector39,M=x.elements,R=e.renderMode;switch(this.scaleMode){case 0:var I=S.scale,A=I;M[0]=I.x,M[1]=I.z,M[2]=I.y,1===R&&(m=I);break;case 1:I=S.localScale;M[0]=(A=I).x,M[1]=I.z,M[2]=I.y,1===R&&(m=I);break;case 2:A=S.scale,(M[0]=M[1]=M[2]=1)===R&&(m=hn.ONE)}switch(this._velocityOverLifetime&&this._velocityOverLifetime.enbale||(g=new hn(p.x*a,p.y*a,p.z*a),T=new hn(E.x*a,E.y*a,E.z*a),2!=this.scaleMode?(hn.add(h,g,t),hn.multiply(A,t,t),hn.add(_,T,n),hn.multiply(A,n,n)):(hn.multiply(A,h,t),hn.add(t,g,t),hn.multiply(A,_,n),hn.add(n,T,n))),this.simulationSpace){case 0:break;case 1:hn.add(t,D,t),hn.add(n,D,n)}var C=NaN,y=NaN;switch(this.startSizeType){case 0:this.threeDStartSize?(C=Math.max((void 0).x,(void 0).y),1===R&&(y=(void 0).y)):(C=this.startSizeConstant,1===R&&(y=this.startSizeConstant));break;case 1:break;case 2:this.threeDStartSize?(C=Math.max((void 0).x,(void 0).y),1===R&&(y=(void 0).y)):(C=this.startSizeConstantMax,1===R&&(y=this.startSizeConstantMax))}this._sizeOverLifetime&&this._sizeOverLifetime.enbale&&(this._sizeOverLifetime.size,C*=this._sizeOverLifetime.size.getMaxSizeInGradient());var O=z._tempVector30,N=O.elements,V=NaN,L=NaN;switch(R){case 0:V=C*z.halfKSqrtOf2,hn.scale(x,C,O),hn.subtract(t,O,t),hn.add(n,O,n);break;case 1:var w=z._tempVector31,F=z._tempVector32,P=z._tempVector33,b=z._tempVector34;this._velocityOverLifetime&&this._velocityOverLifetime.enbale||(hn.multiply(m,E,F),hn.multiply(m,p,P));var B=y*e.stretchedBillboardLengthScale,U=hn.scalarLength(F)*e.stretchedBillboardSpeedScale+B,H=hn.scalarLength(P)*e.stretchedBillboardSpeedScale+B,G=z._tempVector35,B=z._tempVector36;hn.normalize(F,G),hn.scale(G,U,b),hn.subtract(T,b,b),hn.normalize(P,B),hn.scale(B,H,w),hn.add(g,w,w),V=C*z.halfKSqrtOf2,hn.scale(x,V,O);P=z._tempVector37,H=z._tempVector38;hn.scale(G,.5,P),hn.scale(B,.5,H),hn.multiply(P,x,P),hn.multiply(H,x,H),hn.add(t,H,t),hn.min(t,b,t),hn.subtract(t,O,t),hn.subtract(n,P,n),hn.max(n,w,n),hn.add(n,O,n);break;case 2:C*=Math.cos(.7853981633974483),N[0]=x.x*(L=.5*C),N[1]=x.z*L,hn.subtract(t,O,t),hn.add(n,O,n);break;case 3:C*=Math.cos(.7853981633974483),hn.scale(x,L=.5*C,O),hn.subtract(t,O,t),hn.add(n,O,n)}this._boundingBox.getCorners(this._boundingBoxCorners)},t._updateEmission=function(){var e;S.stage.isVisibility&&this.isAlive&&(this._simulateUpdate?this._simulateUpdate=!1:(e=this._startUpdateLoopCount===I.loopCount||this._isPaused?0:S.timer.delta/1e3,e=Math.min(z._maxElapsedTime,e),this._updateParticles(e)))},t._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))},t._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)<this._playStartDelay?this._totalDelayTime=e:this._emission.enbale&&this._advanceTime(e,e)},t._addUpdateEmissionToTimer=function(){S.timer.frameLoop(1,this,this._updateEmission)},t._removeUpdateEmissionToTimer=function(){S.timer.clear(this,this._updateEmission)},t._onOwnerActiveHierarchyChanged=function(e){this._owner.displayedInStage&&(e?this._addUpdateEmissionToTimer():this._removeUpdateEmissionToTimer())},t._retireActiveParticles=function(){for(;this._firstActiveElement!=this._firstNewElement;){var e=this._firstActiveElement*this._floatCountPerVertex*this._vertexStride,t=e+this._timeIndex;if(1e-4+(this._currentTime-this._vertices[t])<this._vertices[e+this._startLifeTimeIndex])break;this._vertices[t]=this._drawCounter,this._firstActiveElement++,this._firstActiveElement>=this._bufferMaxParticles&&(this._firstActiveElement=0)}},t._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)}},t._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;o=0;this.autoRandomSeed?o=O.lerp(a.minCount,a.maxCount,Math.random()):(this._rand.seed=this._randomSeeds[0],o=O.lerp(a.minCount,a.maxCount,this._rand.getFloat()),this._randomSeeds[0]=this._rand.seed),n+=o}return n},t._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);i=this.emission.emissionRate;if(0<i){var a=1/i;for(this._frameRateTime+=a,this._frameRateTime=this._currentTime-(this._currentTime-this._frameRateTime)%this._maxStartLifetime;this._frameRateTime<=t&&this.emit(this._frameRateTime);)this._frameRateTime+=a;this._frameRateTime=Math.floor(t/a)*a}},t._initBufferDatas=function(){this._vertexBuffer&&(this._vertexBuffer.destroy(),this._indexBuffer.destroy());var e=this._ownerRender,t=e.renderMode;if(-1!==t&&0<this.maxParticles){var n,i,r,a=0,o=0,s=0,l=e.mesh;if(4===t){if(l){if(1<l._vertexBuffers.length)throw new Error("ShurikenParticleSystem: submesh Count mesh be One or all subMeshes have the same vertexDeclaration.");r=Pt.vertexDeclaration,this._floatCountPerVertex=r.vertexStride/4,this._startLifeTimeIndex=12,this._timeIndex=16,this._vertexStride=l._vertexBuffers[0].vertexCount;e=this._bufferMaxParticles*this._vertexStride,t=e%65535;if(1<Math.floor(e/65535)+1)throw new Error("ShurikenParticleSystem:the maxParticleCount multiply mesh vertexCount is large than 65535.");this._vertexBuffer=Gi.create(r,t,35048),this._vertices=new Float32Array(this._floatCountPerVertex*t),this._indexStride=l._indexBuffer.indexCount;var h=l._indexBuffer.getData(),l=this._bufferMaxParticles*this._indexStride;for(this._indexBuffer=Ui.create("ushort",l,35044),n=new Uint16Array(l),a=s=0;a<this._bufferMaxParticles;a++)for(var _=a*this._vertexStride,o=0,u=h.length;o<u;o++)n[s++]=_+h[o];this._indexBuffer.setData(n)}}else{for(r=Ft.vertexDeclaration,this._floatCountPerVertex=r.vertexStride/4,this._startLifeTimeIndex=7,this._timeIndex=11,this._vertexStride=4,this._vertexBuffer=Gi.create(r,this._bufferMaxParticles*this._vertexStride,35048),this._vertices=new Float32Array(this._floatCountPerVertex*this._bufferMaxParticles*this._vertexStride),a=0;a<this._bufferMaxParticles;a++)i=a*this._floatCountPerVertex*this._vertexStride,this._vertices[i]=-.5,this._vertices[1+i]=-.5,this._vertices[2+i]=0,this._vertices[3+i]=1,i+=this._floatCountPerVertex,this._vertices[i]=.5,this._vertices[i+1]=-.5,this._vertices[i+2]=1,this._vertices[i+3]=1,i+=this._floatCountPerVertex,this._vertices[i]=.5,this._vertices[i+1]=.5,this._vertices[i+2]=1,this._vertices[i+3]=0,i+=this._floatCountPerVertex,this._vertices[i]=-.5,this._vertices[i+1]=.5,this._vertices[i+2]=0,this._vertices[i+3]=0;for(this._indexStride=6,this._indexBuffer=Ui.create("ushort",6*this._bufferMaxParticles,35044),n=new Uint16Array(6*this._bufferMaxParticles),a=0;a<this._bufferMaxParticles;a++){var s=6*a,d=a*this._vertexStride,c=2+d;n[s++]=d,n[s++]=c,n[s++]=1+d,n[s++]=d,n[s++]=3+d,n[s++]=c}this._indexBuffer.setData(n)}}},t._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},t.emit=function(e){var t,n,i=z._tempPosition,r=z._tempDirection;return this._shape&&this._shape.enable?this.autoRandomSeed?this._shape.generatePositionAndDirection(i,r):this._shape.generatePositionAndDirection(i,r,this._rand,this._randomSeeds):(t=i.elements,(n=r.elements)[t[0]=t[1]=t[2]=0]=n[1]=0,n[2]=1),this.addParticle(i,r,e)},t.addParticle=function(e,t,n){hn.normalize(t,t);var i=this._firstFreeElement+1;if((i=i>=this._bufferMaxParticles?0:i)===this._firstRetiredElement)return!1;if(ce.create(this,this._ownerRender,this._owner.transform),this._currentTime-n>=ce.startLifeTime)return!0;var r,a=NaN,o=NaN,s=NaN,l=NaN,h=NaN,_=NaN,u=NaN,d=this._velocityOverLifetime&&this._velocityOverLifetime.enbale;d&&(2===(r=this._velocityOverLifetime.velocity.type)||3===r)?this.autoRandomSeed?(a=Math.random(),o=Math.random(),s=Math.random()):(this._rand.seed=this._randomSeeds[9],a=this._rand.getFloat(),o=this._rand.getFloat(),s=this._rand.getFloat(),this._randomSeeds[9]=this._rand.seed):d=!1;var c=this._colorOverLifetime&&this._colorOverLifetime.enbale;c&&3===this._colorOverLifetime.color.type?this.autoRandomSeed?l=Math.random():(this._rand.seed=this._randomSeeds[10],l=this._rand.getFloat(),this._randomSeeds[10]=this._rand.seed):c=!1;var f=this._sizeOverLifetime&&this._sizeOverLifetime.enbale;f&&3===this._sizeOverLifetime.size.type?this.autoRandomSeed?h=Math.random():(this._rand.seed=this._randomSeeds[11],h=this._rand.getFloat(),this._randomSeeds[11]=this._rand.seed):f=!1;var m=this._rotationOverLifetime&&this._rotationOverLifetime.enbale;m&&(2===(g=this._rotationOverLifetime.angularVelocity.type)||3===g)?this.autoRandomSeed?_=Math.random():(this._rand.seed=this._randomSeeds[12],_=this._rand.getFloat(),this._randomSeeds[12]=this._rand.seed):m=!1;var p=this._textureSheetAnimation&&this._textureSheetAnimation.enable;p&&3===this._textureSheetAnimation.frame.type?this.autoRandomSeed?u=Math.random():(this._rand.seed=this._randomSeeds[15],u=this._rand.getFloat(),this._randomSeeds[15]=this._rand.seed):p=!1;var E,v,g=this._firstFreeElement*this._floatCountPerVertex*this._vertexStride,T=ce.startUVInfo[0],S=ce.startUVInfo[1],D=ce.startUVInfo[2],x=ce.startUVInfo[3],M=e.elements,R=t.elements,I=0,A=0,C=0,y=0,O=0,N=this._ownerRender;4===N.renderMode?(E=(t=N.mesh._vertexBuffers[0]).getData(),A=(v=t.vertexDeclaration).getVertexElementByUsage(0).offset/4,C=(t=v.getVertexElementByUsage(1))?t.offset/4:-1,y=(t=v.getVertexElementByUsage(2))?t.offset/4:-1,I=v.vertexStride/4,O=0):(this._vertices[2+g]=D,this._vertices[3+g]=x+S,v=g+this._floatCountPerVertex,this._vertices[v+2]=D+T,this._vertices[v+3]=x+S,v=v+this._floatCountPerVertex,this._vertices[v+2]=D+T,this._vertices[v+3]=x,v=v+this._floatCountPerVertex,this._vertices[v+2]=D,this._vertices[v+3]=x);for(var V=g,L=g+this._floatCountPerVertex*this._vertexStride;V<L;V+=this._floatCountPerVertex){var w,F,P=0;switch(4===N.renderMode?(P=V,F=(w=I*O++)+A,this._vertices[P++]=E[F++],this._vertices[P++]=E[F++],this._vertices[P++]=E[F],-1===C?(this._vertices[P++]=1,this._vertices[P++]=1,this._vertices[P++]=1,this._vertices[P++]=1):(F=w+C,this._vertices[P++]=E[F++],this._vertices[P++]=E[F++],this._vertices[P++]=E[F++],this._vertices[P++]=E[F]),-1===y?(this._vertices[P++]=0,this._vertices[P++]=0):(F=w+y,this._vertices[P++]=D+E[F++]*T,this._vertices[P++]=x+E[F]*S)):P=V+4,this._vertices[P++]=M[0],this._vertices[P++]=M[1],this._vertices[P++]=M[2],this._vertices[P++]=ce.startLifeTime,this._vertices[P++]=R[0],this._vertices[P++]=R[1],this._vertices[P++]=R[2],this._vertices[P++]=n,this._vertices[P++]=ce.startColor[0],this._vertices[P++]=ce.startColor[1],this._vertices[P++]=ce.startColor[2],this._vertices[P++]=ce.startColor[3],this._vertices[P++]=ce.startSize[0],this._vertices[P++]=ce.startSize[1],this._vertices[P++]=ce.startSize[2],this._vertices[P++]=ce.startRotation[0],this._vertices[P++]=ce.startRotation[1],this._vertices[P++]=ce.startRotation[2],this._vertices[P++]=ce.startSpeed,c&&(this._vertices[P+1]=l),f&&(this._vertices[P+2]=h),m&&(this._vertices[P+3]=_),p&&(this._vertices[P+4]=u),d&&(this._vertices[P+5]=a,this._vertices[P+6]=o,this._vertices[P+7]=s),this.simulationSpace){case 0:P+=8,this._vertices[P++]=ce.simulationWorldPostion[0],this._vertices[P++]=ce.simulationWorldPostion[1],this._vertices[P++]=ce.simulationWorldPostion[2],this._vertices[P++]=ce.simulationWorldRotation[0],this._vertices[P++]=ce.simulationWorldRotation[1],this._vertices[P++]=ce.simulationWorldRotation[2],this._vertices[P++]=ce.simulationWorldRotation[3];break;case 1:break;default:throw new Error("ShurikenParticleMaterial: SimulationSpace value is invalid.")}}return this._firstFreeElement=i,!0},t.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),0<this._firstFreeElement&&this._vertexBuffer.setData(this._vertices,0,0,this._firstFreeElement*this._vertexStride*this._floatCountPerVertex)),this._firstNewElement=this._firstFreeElement},t._beforeRender=function(e){return this._firstNewElement!=this._firstFreeElement&&this.addNewParticlesToVertexBuffer(),this._drawCounter++,this._firstActiveElement!=this._firstFreeElement&&(this._vertexBuffer._bind(),this._indexBuffer._bind(),!0)},t._render=function(e){var t=0,n=N.mainContext;this._firstActiveElement<this._firstFreeElement?(t=(this._firstFreeElement-this._firstActiveElement)*this._indexStride,n.drawElements(4,t,5123,2*this._firstActiveElement*this._indexStride),I.trianglesFaces+=t/3,I.drawCall++):(t=(this._bufferMaxParticles-this._firstActiveElement)*this._indexStride,n.drawElements(4,t,5123,2*this._firstActiveElement*this._indexStride),I.trianglesFaces+=t/3,I.drawCall++,0<this._firstFreeElement&&(t=this._firstFreeElement*this._indexStride,n.drawElements(4,t,5123,0),I.trianglesFaces+=t/3,I.drawCall++))},t.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,t=this._randomSeeds.length;e<t;e++)this._randomSeeds[e]=this.randomSeed[0]+z._RANDOMOFFSET[e];switch(this.startDelayType){case 0:this._playStartDelay=this.startDelay;break;case 1:this.autoRandomSeed?this._playStartDelay=O.lerp(this.startDelayMin,this.startDelayMax,Math.random()):(this._rand.seed=this._randomSeeds[2],this._playStartDelay=O.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=I.loopCount,this.event("played")},t.pause=function(){this._isPaused=!0,this.event("paused")},t.simulate=function(e,t){void 0===t&&(t=!0),this._simulateUpdate=!0,t?this._updateParticlesSimulationRestart(e):(this._isPaused=!1,this._updateParticles(e)),this.pause()},t.stop=function(){this._burstsIndex=0,this._isEmitting=!1,this._emissionTime=0,this.event("stopped")},t.cloneTo=function(e){e.duration=this.duration,e.looping=this.looping,e.prewarm=this.prewarm,e.startDelayType=this.startDelayType,e.startDelay=this.startDelay,e.startDelayMin=this.startDelayMin,e.startDelayMax=this.startDelayMax,e._maxStartLifetime=this._maxStartLifetime,e.startLifetimeType=this.startLifetimeType,e.startLifetimeConstant=this.startLifetimeConstant,this.startLifeTimeGradient.cloneTo(e.startLifeTimeGradient),e.startLifetimeConstantMin=this.startLifetimeConstantMin,e.startLifetimeConstantMax=this.startLifetimeConstantMax,this.startLifeTimeGradientMin.cloneTo(e.startLifeTimeGradientMin),this.startLifeTimeGradientMax.cloneTo(e.startLifeTimeGradientMax),e.startSpeedType=this.startSpeedType,e.startSpeedConstant=this.startSpeedConstant,e.startSpeedConstantMin=this.startSpeedConstantMin,e.startSpeedConstantMax=this.startSpeedConstantMax,e.threeDStartSize=this.threeDStartSize,e.startSizeType=this.startSizeType,e.startSizeConstant=this.startSizeConstant,this.startSizeConstantSeparate.cloneTo(e.startSizeConstantSeparate),e.startSizeConstantMin=this.startSizeConstantMin,e.startSizeConstantMax=this.startSizeConstantMax,this.startSizeConstantMinSeparate.cloneTo(e.startSizeConstantMinSeparate),this.startSizeConstantMaxSeparate.cloneTo(e.startSizeConstantMaxSeparate),e.threeDStartRotation=this.threeDStartRotation,e.startRotationType=this.startRotationType,e.startRotationConstant=this.startRotationConstant,this.startRotationConstantSeparate.cloneTo(e.startRotationConstantSeparate),e.startRotationConstantMin=this.startRotationConstantMin,e.startRotationConstantMax=this.startRotationConstantMax,this.startRotationConstantMinSeparate.cloneTo(e.startRotationConstantMinSeparate),this.startRotationConstantMaxSeparate.cloneTo(e.startRotationConstantMaxSeparate),e.randomizeRotationDirection=this.randomizeRotationDirection,e.startColorType=this.startColorType,this.startColorConstant.cloneTo(e.startColorConstant),this.startColorConstantMin.cloneTo(e.startColorConstantMin),this.startColorConstantMax.cloneTo(e.startColorConstantMax),e.gravityModifier=this.gravityModifier,e.simulationSpace=this.simulationSpace,e.scaleMode=this.scaleMode,e.playOnAwake=this.playOnAwake,e.maxParticles=this.maxParticles,this._emission&&(e._emission=this._emission.clone()),this.shape&&(e.shape=this.shape.clone()),this.velocityOverLifetime&&(e.velocityOverLifetime=this.velocityOverLifetime.clone()),this.colorOverLifetime&&(e.colorOverLifetime=this.colorOverLifetime.clone()),this.sizeOverLifetime&&(e.sizeOverLifetime=this.sizeOverLifetime.clone()),this.rotationOverLifetime&&(e.rotationOverLifetime=this.rotationOverLifetime.clone()),this.textureSheetAnimation&&(e.textureSheetAnimation=this.textureSheetAnimation.clone()),e.isPerformanceMode=this.isPerformanceMode,e._isEmitting=this._isEmitting,e._isPlaying=this._isPlaying,e._isPaused=this._isPaused,e._playStartDelay=this._playStartDelay,e._frameRateTime=this._frameRateTime,e._emissionTime=this._emissionTime,e._totalDelayTime=this._totalDelayTime,e._burstsIndex=this._burstsIndex},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},t._getVertexBuffers=function(){return null},_(0,t,"maxParticles",function(){return this._bufferMaxParticles-1},function(e){e+=1;e!==this._bufferMaxParticles&&(this._bufferMaxParticles=e,this._initBufferDatas())}),_(0,t,"isEmitting",function(){return this._isEmitting}),_(0,t,"isAlive",function(){return!!(this._isPlaying||0<this.aliveParticleCount)}),_(0,t,"shape",function(){return this._shape},function(e){this._shape!==e&&(e&&e.enable?this._ownerRender._addShaderDefine(mr.SHADERDEFINE_SHAPE):this._ownerRender._removeShaderDefine(mr.SHADERDEFINE_SHAPE),this._shape=e)}),_(0,t,"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(mr.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE):t._addShaderDefine(mr.SHADERDEFINE_ROTATIONOVERLIFETIME),r){case 0:t._addShaderDefine(mr.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT);break;case 1:t._addShaderDefine(mr.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE);break;case 2:t._addShaderDefine(mr.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS);break;case 3:t._addShaderDefine(mr.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCURVES)}else t._removeShaderDefine(mr.SHADERDEFINE_ROTATIONOVERLIFETIME),t._removeShaderDefine(mr.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE),t._removeShaderDefine(mr.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT),t._removeShaderDefine(mr.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE),t._removeShaderDefine(mr.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS),t._removeShaderDefine(mr.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(mr.SHADERDEFINE_ROTATIONOVERLIFETIME),t._removeShaderDefine(mr.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE),t._removeShaderDefine(mr.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT),t._removeShaderDefine(mr.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE),t._removeShaderDefine(mr.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS),t._removeShaderDefine(mr.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}),_(0,t,"emission",function(){return this._emission}),_(0,t,"emissionTime",function(){return this._emissionTime>this.duration?this.duration:this._emissionTime}),_(0,t,"aliveParticleCount",function(){return this._firstNewElement>=this._firstRetiredElement?this._firstNewElement-this._firstRetiredElement:this._bufferMaxParticles-this._firstRetiredElement+this._firstNewElement}),_(0,t,"isPlaying",function(){return this._isPlaying}),_(0,t,"isPaused",function(){return this._isPaused}),_(0,t,"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;for(var i=i,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}),_(0,t,"_originalBoundingSphere",function(){return this._boundingSphere}),_(0,t,"startLifetimeConstant",function(){return this._startLifetimeConstant},function(e){0===this._startLifetimeType&&(this._maxStartLifetime=e),this._startLifetimeConstant=e}),_(0,t,"startLifetimeConstantMin",function(){return this._startLifetimeConstantMin},function(e){2===this._startLifetimeType&&(this._maxStartLifetime=Math.max(e,this._startLifetimeConstantMax)),this._startLifetimeConstantMin=e}),_(0,t,"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}),_(0,t,"startLifetimeConstantMax",function(){return this._startLifetimeConstantMax},function(e){2===this._startLifetimeType&&(this._maxStartLifetime=Math.max(this._startLifetimeConstantMin,e)),this._startLifetimeConstantMax=e}),_(0,t,"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}),_(0,t,"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}),_(0,t,"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(mr.SHADERDEFINE_VELOCITYOVERLIFETIMECONSTANT);break;case 1:t._addShaderDefine(mr.SHADERDEFINE_VELOCITYOVERLIFETIMECURVE);break;case 2:t._addShaderDefine(mr.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCONSTANT);break;case 3:t._addShaderDefine(mr.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCURVE)}else t._removeShaderDefine(mr.SHADERDEFINE_VELOCITYOVERLIFETIMECONSTANT),t._removeShaderDefine(mr.SHADERDEFINE_VELOCITYOVERLIFETIMECURVE),t._removeShaderDefine(mr.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCONSTANT),t._removeShaderDefine(mr.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(mr.SHADERDEFINE_VELOCITYOVERLIFETIMECONSTANT),t._removeShaderDefine(mr.SHADERDEFINE_VELOCITYOVERLIFETIMECURVE),t._removeShaderDefine(mr.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCONSTANT),t._removeShaderDefine(mr.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}),_(0,t,"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(mr.SHADERDEFINE_COLOROVERLIFETIME);break;case 3:t._addShaderDefine(mr.SHADERDEFINE_RANDOMCOLOROVERLIFETIME)}else t._removeShaderDefine(mr.SHADERDEFINE_COLOROVERLIFETIME),t._removeShaderDefine(mr.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(mr.SHADERDEFINE_COLOROVERLIFETIME),t._removeShaderDefine(mr.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}),_(0,t,"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(mr.SHADERDEFINE_SIZEOVERLIFETIMECURVESEPERATE):t._addShaderDefine(mr.SHADERDEFINE_SIZEOVERLIFETIMECURVE);break;case 2:i?t._addShaderDefine(mr.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVESSEPERATE):t._addShaderDefine(mr.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVES)}else t._removeShaderDefine(mr.SHADERDEFINE_SIZEOVERLIFETIMECURVE),t._removeShaderDefine(mr.SHADERDEFINE_SIZEOVERLIFETIMECURVESEPERATE),t._removeShaderDefine(mr.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVES),t._removeShaderDefine(mr.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(mr.SHADERDEFINE_SIZEOVERLIFETIMECURVE),t._removeShaderDefine(mr.SHADERDEFINE_SIZEOVERLIFETIMECURVESEPERATE),t._removeShaderDefine(mr.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVES),t._removeShaderDefine(mr.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}),_(0,t,"textureSheetAnimation",function(){return this._textureSheetAnimation},function(e){var t=this._ownerRender;if(e){var n,i,r=e.frame,a=r.type;if(e.enable)switch(a){case 1:t._addShaderDefine(mr.SHADERDEFINE_TEXTURESHEETANIMATIONCURVE);break;case 3:t._addShaderDefine(mr.SHADERDEFINE_TEXTURESHEETANIMATIONRANDOMCURVE)}else t._removeShaderDefine(mr.SHADERDEFINE_TEXTURESHEETANIMATIONCURVE),t._removeShaderDefine(mr.SHADERDEFINE_TEXTURESHEETANIMATIONRANDOMCURVE);switch(1!==a&&3!==a||(t._setShaderValueInt(48,e.cycles),n=e.tiles,(i=this._uvLength.elements)[0]=1/n.x,i[1]=1/n.y,t._setShaderValueVector2(49,this._uvLength)),a){case 1:t._setShaderValueBuffer(50,r.frameOverTimeData._elements);break;case 3:t._setShaderValueBuffer(50,r.frameOverTimeDataMin._elements),t._setShaderValueBuffer(51,r.frameOverTimeDataMax._elements)}}else t._removeShaderDefine(mr.SHADERDEFINE_TEXTURESHEETANIMATIONCURVE),t._removeShaderDefine(mr.SHADERDEFINE_TEXTURESHEETANIMATIONRANDOMCURVE),t._setShaderValueInt(48,void 0),t._setShaderValueVector2(49,null),t._setShaderValueBuffer(50,null),t._setShaderValueBuffer(51,null);this._textureSheetAnimation=e}),_(0,t,"_vertexBufferCount",function(){return 1}),_(0,t,"triangleCount",function(){return this._indexBuffer?this._indexBuffer.indexCount/3:0}),_(0,t,"_originalBoundingBox",function(){return this._boundingBox}),_(0,t,"_originalBoundingBoxCorners",function(){return this._boundingBoxCorners}),z.halfKSqrtOf2=.71,l(z,["_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 hn},"_tempVector31",function(){return this._tempVector31=new hn},"_tempVector32",function(){return this._tempVector32=new hn},"_tempVector33",function(){return this._tempVector33=new hn},"_tempVector34",function(){return this._tempVector34=new hn},"_tempVector35",function(){return this._tempVector35=new hn},"_tempVector36",function(){return this._tempVector36=new hn},"_tempVector37",function(){return this._tempVector37=new hn},"_tempVector38",function(){return this._tempVector38=new hn},"_tempVector39",function(){return this._tempVector39=new hn},"_tempPosition",function(){return this._tempPosition=new hn},"_tempDirection",function(){return this._tempDirection=new hn}]),z}(Hn),Ei=function(e){function t(e){this._finalGravity=new hn,this._tempRotationMatrix=new Jt,t.__super.call(this,e),this._defaultBoundBox=new kt(new hn,new hn),this._renderMode=-1,this.stretchedBillboardCameraSpeedScale=0,this.stretchedBillboardSpeedScale=0,this.stretchedBillboardLengthScale=1}p(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;e=this._boundingBox.min.elements;e[0]=Number.MAX_VALUE,e[1]=Number.MAX_VALUE,e[2]=Number.MAX_VALUE},n._calculateBoundingSphere=function(){var e=this._owner.particleSystem._boundingSphere,t=NaN,n=this._owner.transform,i=n.scale.elements,r=Math.abs(i[0]),a=Math.abs(i[1]),i=Math.abs(i[2]),t=a<=r&&i<=r?r:i<=a?a:i;hn.transformCoordinate(e.center,n.worldMatrix,this._boundingSphere.center),this._boundingSphere.radius=e.radius*t},n._renderUpdate=function(e){var t=this._owner.particleSystem;if(!S.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:i=n.localScale;this._setShaderValueColor(4,i),this._setShaderValueColor(5,i);break;case 2:this._setShaderValueColor(4,n.scale),this._setShaderValueColor(5,hn.ONE)}var r=this._finalGravity.elements,a=An.gravity.elements,o=t.gravityModifier;return r[0]=a[0]*o,r[1]=a[1]*o,r[2]=a[2]*o,this._setShaderValueBuffer(7,r),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),Pn.debugMode&&this._renderRenderableBoundBox(),!0},n._destroy=function(){e.prototype._destroy.call(this),this._mesh&&(this._mesh._removeReference(),this._mesh=null)},_(0,n,"boundingBox",function(){return this._owner.particleSystem.isAlive?(this._boundingBoxNeedChange&&(this._calculateBoundingBox(),this._boundingBoxNeedChange=!1),this._boundingBox):this._defaultBoundBox}),_(0,n,"renderMode",function(){return this._renderMode},function(e){if(this._renderMode!==e){switch(this._renderMode){case 0:this._removeShaderDefine(mr.SHADERDEFINE_RENDERMODE_BILLBOARD);break;case 1:this._removeShaderDefine(mr.SHADERDEFINE_RENDERMODE_STRETCHEDBILLBOARD);break;case 2:this._removeShaderDefine(mr.SHADERDEFINE_RENDERMODE_HORIZONTALBILLBOARD);break;case 3:this._removeShaderDefine(mr.SHADERDEFINE_RENDERMODE_VERTICALBILLBOARD);break;case 4:this._removeShaderDefine(mr.SHADERDEFINE_RENDERMODE_MESH)}switch(this._renderMode=e){case 0:this._addShaderDefine(mr.SHADERDEFINE_RENDERMODE_BILLBOARD);break;case 1:this._addShaderDefine(mr.SHADERDEFINE_RENDERMODE_STRETCHEDBILLBOARD);break;case 2:this._addShaderDefine(mr.SHADERDEFINE_RENDERMODE_HORIZONTALBILLBOARD);break;case 3:this._addShaderDefine(mr.SHADERDEFINE_RENDERMODE_VERTICALBILLBOARD);break;case 4:this._addShaderDefine(mr.SHADERDEFINE_RENDERMODE_MESH);break;default:throw new Error("ShurikenParticleRender: unknown renderMode Value.")}this._owner.particleSystem._initBufferDatas()}}),_(0,n,"mesh",function(){return this._mesh},function(e){this._mesh!==e&&(this._mesh&&this._mesh._removeReference(),(this._mesh=e)&&e._addReference(),this._owner.particleSystem._initBufferDatas())}),t}(Gn),vi=function(t){function n(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,n.__super.call(this),this._curSubTrailFinishPosition=new hn,this._curSubTrailFinishDirection=new hn,this._owner=e,this._trailRenderElements=[],this.addRenderElement()}p(n,"laya.d3.core.trail.TrailFilter",t);var e=n.prototype;return e.getRenderElementsCount=function(){return this._trailRenderElements.length},e.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 Ne(this);return this._trailRenderElements.push(t),this._trailRenderElements.length-1},e.getRenderElement=function(e){return this._trailRenderElements[e]},e._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]]))},e.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},e._destroy=function(){t.prototype._destroy.call(this);for(var e=0;e<this._trailRenderElements.length;e++)this._trailRenderElements[e]._destroy();this._trailRenderElements=null,this._widthCurve=null,this._colorGradient=null,this._curSubTrailFinishPosition=null,this._curSubTrailFinishDirection=null},_(0,e,"widthMultiplier",function(){return this._widthMultiplier},function(e){this._widthMultiplier=e}),_(0,e,"time",function(){return this._time},function(e){this._time=e,this._owner._render._setShaderValueNumber(4,e)}),_(0,e,"widthCurve",function(){return this._widthCurve},function(e){this._widthCurve=e;for(var t=new Float32Array(4*e.length),n=0,i=0,n=0,r=e.length;n<r;n++)t[i++]=e[n].time,t[i++]=e[n].inTangent,t[i++]=e[n].outTangent,t[i++]=e[n].value;this._owner._render._setShaderValueBuffer(5,t),this._owner._render._setShaderValueInt(6,e.length)}),_(0,e,"minVertexDistance",function(){return this._minVertexDistance},function(e){this._minVertexDistance=e}),_(0,e,"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(Er.SHADERDEFINE_GRADIENTMODE_BLEND):this._owner._render._removeShaderDefine(Er.SHADERDEFINE_GRADIENTMODE_BLEND)}),_(0,e,"textureMode",function(){return this._textureMode},function(e){this._textureMode=e}),n}(Hn),gi=function(){function t(e){t.__super.call(this,e)}p(t,"laya.d3.core.trail.TrailRenderer",Gn);var e=t.prototype;return e._calculateBoundingBox=function(){var e=this._boundingBox.min.elements;e[0]=-Number.MAX_VALUE,e[1]=-Number.MAX_VALUE,e[2]=-Number.MAX_VALUE;e=this._boundingBox.min.elements;e[0]=Number.MAX_VALUE,e[1]=Number.MAX_VALUE,e[2]=Number.MAX_VALUE},e._calculateBoundingSphere=function(){var e=this._boundingSphere.center.elements;e[0]=0,e[1]=0,e[2]=0,this._boundingSphere.radius=Number.MAX_VALUE},e._renderUpdate=function(e){return!0},t}(),Ti=function(){function t(e){this._owner=null,this.dominoCount=0,this.DominoRenderElementMaxDominoCount=2e3,this._dominoRenderElements=null,t.__super.call(this),this.dominoPosition=[],this._owner=e,this.initPositionsAndNormal(),this._dominoRenderElements=[],this.addDominoRenderElement()}p(t,"laya.d3.extension.domino.DominoFilter",Hn);var e=t.prototype;return e.addDomino=function(e,t,n){void 0===e&&(e=hn.ZERO),void 0===t&&(t=rn.DEFAULT),void 0===n&&(n=hn.ZERO);var i,r=this._dominoRenderElements[this._dominoRenderElements.length-1];r._curDominoCount>=this.DominoRenderElementMaxDominoCount&&(i=this.addDominoRenderElement(),this.event("dominofilterchange",[i,this._dominoRenderElements[i]])),(r=this._dominoRenderElements[this._dominoRenderElements.length-1]).addDomino(e,t,n)},e.updateDomino=function(e,t,n,i){void 0===t&&(t=hn.ZERO),void 0===n&&(n=rn.DEFAULT),void 0===i&&(i=hn.ZERO);var r=Math.floor(e/this.DominoRenderElementMaxDominoCount),e=e%this.DominoRenderElementMaxDominoCount;this._dominoRenderElements[r].updateDomino(e,t,n,i)},e.updateDominos=function(e,t,n){var i,r=e+t-1,a=Math.floor(e/this.DominoRenderElementMaxDominoCount),o=Math.floor(r/this.DominoRenderElementMaxDominoCount),s=e%this.DominoRenderElementMaxDominoCount,l=r%this.DominoRenderElementMaxDominoCount,h=o-a+1;if(h<=1)(i=this._dominoRenderElements[a]).updateDominos(s,t,n);else for(var _,u=0,d=0,c=0,f=0;f<h;f++)i=this._dominoRenderElements[a+f],0==f?(d=this.DominoRenderElementMaxDominoCount-(u=s),_=n.slice(0,d),c+=d):f==h-1?(u=0,d=1+l,_=n.slice(c,n.length)):(u=0,d=this.DominoRenderElementMaxDominoCount,_=n.slice(c,c+this.DominoRenderElementMaxDominoCount),c+=this.DominoRenderElementMaxDominoCount),i.updateDominos(u,d,_)},e.addDominoRenderElement=function(){var e=new we(this);return this._dominoRenderElements.push(e),this._dominoRenderElements.length-1},e.getDominoRenderElementsCount=function(){return this._dominoRenderElements.length},e.getRenderElement=function(e){return this._dominoRenderElements[e]},e._update=function(e){},e.initPositionsAndNormal=function(){0!=t._positions.length&&0!=t._normals.length||(t._positions.push(new hn(-.5,.5,-.5)),t._positions.push(new hn(.5,.5,-.5)),t._positions.push(new hn(.5,.5,.5)),t._positions.push(new hn(-.5,.5,.5)),t._positions.push(new hn(-.5,-.5,-.5)),t._positions.push(new hn(.5,-.5,-.5)),t._positions.push(new hn(.5,-.5,.5)),t._positions.push(new hn(-.5,-.5,.5)),t._positions.push(new hn(-.5,.5,-.5)),t._positions.push(new hn(-.5,.5,.5)),t._positions.push(new hn(-.5,-.5,.5)),t._positions.push(new hn(-.5,-.5,-.5)),t._positions.push(new hn(.5,.5,-.5)),t._positions.push(new hn(.5,.5,.5)),t._positions.push(new hn(.5,-.5,.5)),t._positions.push(new hn(.5,-.5,-.5)),t._positions.push(new hn(-.5,.5,.5)),t._positions.push(new hn(.5,.5,.5)),t._positions.push(new hn(.5,-.5,.5)),t._positions.push(new hn(-.5,-.5,.5)),t._positions.push(new hn(-.5,.5,-.5)),t._positions.push(new hn(.5,.5,-.5)),t._positions.push(new hn(.5,-.5,-.5)),t._positions.push(new hn(-.5,-.5,-.5)),t._normals.push(new hn(0,1,0)),t._normals.push(new hn(0,1,0)),t._normals.push(new hn(0,1,0)),t._normals.push(new hn(0,1,0)),t._normals.push(new hn(0,-1,0)),t._normals.push(new hn(0,-1,0)),t._normals.push(new hn(0,-1,0)),t._normals.push(new hn(0,-1,0)),t._normals.push(new hn(-1,0,0)),t._normals.push(new hn(-1,0,0)),t._normals.push(new hn(-1,0,0)),t._normals.push(new hn(-1,0,0)),t._normals.push(new hn(1,0,0)),t._normals.push(new hn(1,0,0)),t._normals.push(new hn(1,0,0)),t._normals.push(new hn(1,0,0)),t._normals.push(new hn(0,0,1)),t._normals.push(new hn(0,0,1)),t._normals.push(new hn(0,0,1)),t._normals.push(new hn(0,0,1)),t._normals.push(new hn(0,0,-1)),t._normals.push(new hn(0,0,-1)),t._normals.push(new hn(0,0,-1)),t._normals.push(new hn(0,0,-1)))},t._positions=[],t._normals=[],t}(),Si=function(e){function t(e){this._owner=null,this._camera=null,this._useWorldSpace=!1,this._widthMultiplier=.02,this._widthCurve=null,this._colorGradient=null,this._textureMode=0,this._curFixedNum=0,this._vertexBuffers=null,this._maxVertexCount=512,this._vertexCount=0,this._vertices1=null,this._vertexBuffer1=null,this._verticesIndex1=0,this._everyAddVerticeCount1=0,this._floatCountPerVertices1=4,this._vertices2=null,this._vertexBuffer2=null,this._verticesIndex2=0,this._everyAddVerticeCount2=0,this._floatCountPerVertices2=3,this._vertices3=null,this._vertexBuffer3=null,this._verticesIndex3=0,this._everyAddVerticeCount3=0,this._floatCountPerVertices3=2,this._delLength=0,this._pointe=null,this._pointAtoBVector3e=null,this._everyToFirstDistance=null,this._curTotalLength=0,t.__super.call(this),this._positions=[],this._normals=[],this._firstPosition=new hn,this._delVector3=new hn,this._lastPosition=new hn,this._pointAtoBVector3=new hn,this._cameraToPointV3=new hn,this._curDirection=new hn,this._lastDirection=new hn,this._fixedDirection=new hn,this._owner=e,this._initData(),this._vertices1=new Float32Array(this._maxVertexCount*this._floatCountPerVertices1),this._vertices2=new Float32Array(this._maxVertexCount*this._floatCountPerVertices2),this._vertices3=new Float32Array(this._maxVertexCount*this._floatCountPerVertices3),this._vertexBuffer1=new Gi(Pe.vertexDeclaration1,this._maxVertexCount,35044,!0),this._vertexBuffer2=new Gi(Pe.vertexDeclaration2,this._maxVertexCount,35044,!0),this._vertexBuffer3=new Gi(Pe.vertexDeclaration3,this._maxVertexCount,35044,!0),this._vertexBuffers=[],this._vertexBuffers.push(this._vertexBuffer1),this._vertexBuffers.push(this._vertexBuffer2),this._vertexBuffers.push(this._vertexBuffer3),this._everyToFirstDistance=new Float32Array(this._maxVertexCount/2)}p(t,"laya.d3.extension.lineRender.LineFilter",e);var n=t.prototype;return S.imps(n,{"laya.d3.core.render.IRenderable":!0}),n.addPosition=function(e,t){var n=new hn;e.cloneTo(n),this._positions.push(n);e=new hn;t.cloneTo(e),this._normals.push(e),this._updateVertexBuffer1(n),this._vertexCount+=2},n._updateVertexBuffer1=function(e){this._everyAddVerticeCount1=0,this._pointe=e.elements,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++]=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++]=0,this._vertexBuffer1.setData(this._vertices1,this._verticesIndex1,this._verticesIndex1,this._everyAddVerticeCount1),this._verticesIndex1+=this._everyAddVerticeCount1},n._updateVertexBuffer2=function(){this._verticesIndex2=0;for(var e=this._curFixedNum;e<this._positions.length;e++)0==e?(hn.subtract(this._positions[1],this._positions[0],this._delVector3),hn.cross(this._delVector3,this._normals[0],this._pointAtoBVector3),hn.normalize(this._pointAtoBVector3,this._pointAtoBVector3),hn.scale(this._pointAtoBVector3,this._widthMultiplier/2,this._pointAtoBVector3),this._everyToFirstDistance[e]=0,this._updateVertices2(this._positions[0],0)):(hn.subtract(this._positions[e],this._positions[e-1],this._delVector3),hn.cross(this._delVector3,this._normals[e],this._pointAtoBVector3),hn.normalize(this._pointAtoBVector3,this._pointAtoBVector3),hn.scale(this._pointAtoBVector3,this._widthMultiplier/2,this._pointAtoBVector3),this._delLength=hn.scalarLength(this._delVector3),this._curTotalLength=this._everyToFirstDistance[e]=this._curTotalLength+this._delLength,this._updateVertices2(this._positions[e],e)),this._curFixedNum=e+1;this._vertexBuffer2.setData(this._vertices2,0,0,this._verticesIndex2)},n._updateVertexBuffer3=function(){for(var e,t,n=0,i=0,i=0,r=this._vertexCount/2;i<r;i++)e=this._everyToFirstDistance[i]/this._curTotalLength,t=this._everyToFirstDistance[i],this._vertices3[n++]=e,this._vertices3[n++]=t,this._vertices3[n++]=e,this._vertices3[n++]=t;this._vertexBuffer3.setData(this._vertices3,0,0,2*this._vertexCount)},n._beforeRender=function(e){return null==this._camera?(this._camera=e.camera,!1):0<this._vertexCount&&(this._updateVertexBuffer2(),this._updateVertexBuffer3(),!0)},n._render=function(e){N.mainContext.drawArrays(5,0,this._vertexCount),I.drawCall++},n._updateVertices2=function(e,t){this._everyAddVerticeCount2=0,this._pointAtoBVector3e=this._pointAtoBVector3.elements,this._vertices2[this._verticesIndex2+this._everyAddVerticeCount2++]=this._pointAtoBVector3e[0],this._vertices2[this._verticesIndex2+this._everyAddVerticeCount2++]=this._pointAtoBVector3e[1],this._vertices2[this._verticesIndex2+this._everyAddVerticeCount2++]=this._pointAtoBVector3e[2],this._vertices2[this._verticesIndex2+this._everyAddVerticeCount2++]=-this._pointAtoBVector3e[0],this._vertices2[this._verticesIndex2+this._everyAddVerticeCount2++]=-this._pointAtoBVector3e[1],this._vertices2[this._verticesIndex2+this._everyAddVerticeCount2++]=-this._pointAtoBVector3e[2],this._verticesIndex2+=this._everyAddVerticeCount2},n._initData=function(){this.useWorldSpace=!0,this.widthMultiplier=.02,this.textureMode=0;var e=[],t=new ye;t.time=0,t.inTangent=0,t.outTangent=0,t.value=1,e.push(t);var n=new ye;n.time=1,n.inTangent=0,n.outTangent=0,n.value=1,e.push(n),this.widthCurve=e;var i=new Me;i.mode=0;t=[],n=new Ie;n.time=0,n.color=De.WHITE,t.push(n);e=new Ie;e.time=1,e.color=De.WHITE,t.push(e);n=[],e=new Re;e.time=0,e.alpha=1,n.push(e);e=new Re;e.time=1,e.alpha=1,n.push(e),i.setKeys(t,n),this.colorGradient=i},n._update=function(e){},n._getVertexBuffer=function(e){return 0===(e=void 0===e?0:e)?this._vertexBuffer1:null},n._getVertexBuffers=function(){return this._vertexBuffers},n._getIndexBuffer=function(){return null},n._destroy=function(){e.prototype._destroy.call(this),this._vertexBuffer1.destroy(),this._vertexBuffer2.destroy(),this._vertexBuffer3.destroy(),this._vertexBuffers=null,this._vertices1=null,this._vertices2=null,this._vertices3=null,this._owner=null,this._camera=null,this._widthCurve=null,this._colorGradient=null,this._positions=null,this._normals=null,this._firstPosition=null,this._delVector3=null,this._lastPosition=null,this._pointAtoBVector3=null,this._cameraToPointV3=null,this._delVector3=null,this._pointe=null,this._pointAtoBVector3e=null,this._curDirection=null,this._lastDirection=null,this._fixedDirection=null,this._everyToFirstDistance=null},_(0,n,"widthCurve",function(){return this._widthCurve},function(e){this._widthCurve=e;for(var t=new Float32Array(4*e.length),n=0,i=0,n=0,r=e.length;n<r;n++)t[i++]=e[n].time,t[i++]=e[n].inTangent,t[i++]=e[n].outTangent,t[i++]=e[n].value;this._owner._render._setShaderValueBuffer(3,t),this._owner._render._setShaderValueInt(4,e.length)}),_(0,n,"useWorldSpace",function(){return this._useWorldSpace},function(e){(this._useWorldSpace=e)?this._owner._render._addShaderDefine(vr.SHADERDEFINE_WORLDSPACE):this._owner._render._removeShaderDefine(vr.SHADERDEFINE_WORLDSPACE)}),_(0,n,"triangleCount",function(){return 0}),_(0,n,"widthMultiplier",function(){return this._widthMultiplier},function(e){this._widthMultiplier=e}),_(0,n,"colorGradient",function(){return this._colorGradient},function(e){this._colorGradient=e,this._owner._render._setShaderValueBuffer(5,e._colorKeyData),this._owner._render._setShaderValueBuffer(6,e._alphaKeyData),0==e.mode?this._owner._render._addShaderDefine(vr.SHADERDEFINE_GRADIENTMODE_BLEND):this._owner._render._removeShaderDefine(vr.SHADERDEFINE_GRADIENTMODE_BLEND)}),_(0,n,"textureMode",function(){return this._textureMode},function(e){0==(this._textureMode=e)?this._owner._render._addShaderDefine(vr.SHADERDEFINE_TEXTUREMODE_STRETCH):this._owner._render._removeShaderDefine(vr.SHADERDEFINE_TEXTUREMODE_STRETCH)}),_(0,n,"_vertexBufferCount",function(){return this._vertexBuffers.length}),t}(Hn),Di=function(){function t(e){t.__super.call(this,e)}p(t,"laya.d3.extension.domino.DominoRenderer",Gn);var e=t.prototype;return e._calculateBoundingBox=function(){var e=this._boundingBox.min.elements;e[0]=-Number.MAX_VALUE,e[1]=-Number.MAX_VALUE,e[2]=-Number.MAX_VALUE;e=this._boundingBox.min.elements;e[0]=Number.MAX_VALUE,e[1]=Number.MAX_VALUE,e[2]=Number.MAX_VALUE},e._calculateBoundingSphere=function(){var e=this._boundingSphere.center.elements;e[0]=0,e[1]=0,e[2]=0,this._boundingSphere.radius=Number.MAX_VALUE},e._renderUpdate=function(e){var t=this._owner.transform;return t?(this._setShaderValueMatrix4x4(0,t.worldMatrix),t=this._owner.getProjectionViewWorldMatrix(e),this._setShaderValueMatrix4x4(1,t)):(this._setShaderValueMatrix4x4(0,Jt.DEFAULT),this._setShaderValueMatrix4x4(1,e)),!0},t}(),xi=function(){function t(e){t.__super.call(this,e)}p(t,"laya.d3.extension.lineRender.LineRenderer",Gn);var e=t.prototype;return e._calculateBoundingBox=function(){var e=this._boundingBox.min.elements;e[0]=-Number.MAX_VALUE,e[1]=-Number.MAX_VALUE,e[2]=-Number.MAX_VALUE;e=this._boundingBox.min.elements;e[0]=Number.MAX_VALUE,e[1]=Number.MAX_VALUE,e[2]=Number.MAX_VALUE},e._calculateBoundingSphere=function(){var e=this._boundingSphere.center.elements;e[0]=0,e[1]=0,e[2]=0,this._boundingSphere.radius=Number.MAX_VALUE},e._renderUpdate=function(e){var t=this._owner.transform;return t?(this._setShaderValueMatrix4x4(0,t.worldMatrix),t=this._owner.getProjectionViewWorldMatrix(e),this._setShaderValueMatrix4x4(1,t)):(this._setShaderValueMatrix4x4(0,Jt.DEFAULT),this._setShaderValueMatrix4x4(1,e)),!0},t}(),Mi=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 hn,this._tempVector1=new hn,this._tempVector2=new hn,this._tempVector3=new hn,this._posModeLastPosition0=new hn,this._posModeLastPosition1=new hn,this._posModePosition0=new hn,this._posModePosition1=new hn,this._posVelModePosition0=new hn,this._posVelModeVelocity0=new hn,this._posVelModePosition1=new hn,this._posVelModeVelocity1=new hn,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 hn,this._lastPatchAddPos1=new hn,this.scLeft=new X,this.scRight=new X,this.lifeTime=.5,this.minSegmentDistance=.1,this.minInterpDistance=.6,this.maxSlerpCount=128,this._maxSegments=200,this._owner.on("activeinhierarchychanged",this,this._onActiveHierarchyChanged)}p(t,"laya.d3.resource.tempelet.GlitterTemplet",e);var n=t.prototype;return S.imps(n,{"laya.d3.core.render.IRenderable":!0}),n._getVertexBuffer=function(e){return 0===(e=void 0===e?0:e)?this._vertexBuffer:null},n._getIndexBuffer=function(){return null},n._initialize=function(){this._vertexBuffer=Gi.create(Ke.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)),0<this._firstFreeElement&&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,r=(r+1)*this._floatCountPerVertex;this._vertices[3+a]=this._vertices[3+r]=(this._vertices[5+a]-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;){if(this._drawCounter-this._vertices[this._firstRetiredElement*e+5]<3)break;this._firstRetiredElement++,this._firstRetiredElement>=this.maxSegments&&(this._firstRetiredElement=0)}},n._calcVelocity=function(e,t,n){hn.subtract(e,t,n),hn.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),0<this._firstFreeElement&&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.");for(var r=e.elements,a=t.elements,o=0,s=this._firstFreeElement*this._floatCountPerVertex*2,o=0;o<3;o++)this._vertices[s+o]=r[o];this._vertices[3+s]=0,this._vertices[4+s]=0,this._vertices[5+s]=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=N.mainContext;this._firstActiveElement<this._firstFreeElement?(t=2*(this._firstFreeElement-this._firstActiveElement),n.drawArrays(5,2*this._firstActiveElement,t),I.trianglesFaces+=t-2,I.drawCall++):(t=2*(this.maxSegments-this._firstActiveElement),n.drawArrays(5,2*this._firstActiveElement,t),I.trianglesFaces+=t-2,I.drawCall++,0<this._firstFreeElement&&(t=2*this._firstFreeElement,n.drawArrays(5,0,t),I.trianglesFaces+=t-2,I.drawCall++))},n.addVertexPosition=function(e,t){var n,i;this._owner.activeInHierarchy&&(this._numPositionMode<2?(0===this._numPositionMode?(e.cloneTo(this._posModeLastPosition0),t.cloneTo(this._posModeLastPosition1)):(e.cloneTo(this._posModePosition0),t.cloneTo(this._posModePosition1)),this._numPositionMode++):(n=this._tempVector2,this._calcVelocity(e,this._posModeLastPosition0,n),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;hn.subtract(e,this._posVelModePosition0,r);var a=hn.scalarLength(r);hn.subtract(n,this._posVelModePosition1,r);var o,r=hn.scalarLength(r);if(a<void 0&&r<void 0)return;if(1===(o=1+Math.floor(Math.max(a,r)/this.minInterpDistance)))this._addGlitter(e,n,this._currentTime);else{o=Math.min(o,this.maxSlerpCount),this.scLeft.Init(this._posVelModePosition0,this._posVelModeVelocity0,e,t),this.scRight.Init(this._posVelModePosition1,this._posVelModeVelocity1,n,i);for(var s=1/o,l=s,h=this._currentTime-this._lastTime,_=1;_<=o;_++){var u=this._tempVector0;this.scLeft.Slerp(l,u);var d=this._tempVector1;this.scRight.Slerp(l,d);var c=this._lastTime+h*_/o;this._addGlitter(u,d,c),l+=s}}}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},_(0,n,"maxSegments",function(){return this._maxSegments-1},function(e){e+=1;e!==this._maxSegments&&(this._maxSegments=e,this._vertexBuffer&&this._vertexBuffer.destroy(),this._initialize())}),_(0,n,"_vertexBufferCount",function(){return 1}),_(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}),_(0,n,"_originalBoundingSphere",function(){return S.superGet(Hn,this,"_originalBoundingSphere")}),_(0,n,"_originalBoundingBox",function(){return S.superGet(Hn,this,"_originalBoundingBox")}),t}(Hn),Ri=function(e){function h(e,t,n,i,r,a,o,s){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,h.__super.call(this),this._owner=e,this._cameraPos=new hn,this._chunkOffsetX=t,this._chunkOffsetZ=n,this._gridSize=i,this._terrainHeightData=r,this._terrainHeightDataWidth=a,this._terrainHeightDataHeight=o,this._leafNum=Tn.CHUNK_GRID_NUM/Tn.LEAF_GRID_NUM*(Tn.CHUNK_GRID_NUM/Tn.LEAF_GRID_NUM),this._leafs=v(this._leafNum),this._cameraCoordinateInverse=s;for(var l=0;l<this._leafNum;l++)this._leafs[l]=new Tn;this.recreateResource()}p(h,"laya.d3.terrain.TerrainFilter",e);var t=h.prototype;return S.imps(t,{"laya.d3.core.render.IRenderable":!0}),t._destroy=function(){e.prototype._destroy.call(this),this._owner=null,this._vertexBuffer&&this._vertexBuffer.destroy(),this._indexBuffer&&this._indexBuffer.destroy()},t.recreateResource=function(){this._currentNumberIndices=0,this._numberTriangle=0;var e=Tn.LEAF_VERTEXT_COUNT,t=Tn.LEAF_MAX_INDEX_COUNT;this._numberVertices=e*this._leafNum,this._maxNumberIndices=t*this._leafNum,this._indexArrayBuffer=new Uint16Array(this._maxNumberIndices);for(var t=Lt.vertexDeclaration,n=t.vertexStride/4,i=new Float32Array(this._numberVertices*n),r=Tn.CHUNK_GRID_NUM/Tn.LEAF_GRID_NUM,a=0,o=0,s=0,a=0;a<this._leafNum;a++)o=a%r,s=Math.floor(a/r),this._leafs[a].calcVertextBuffer(this._chunkOffsetX,this._chunkOffsetZ,o*Tn.LEAF_GRID_NUM,s*Tn.LEAF_GRID_NUM,this._gridSize,i,a*Tn.LEAF_PLANE_VERTEXT_COUNT,n,this._terrainHeightData,this._terrainHeightDataWidth,this._terrainHeightDataHeight,this._cameraCoordinateInverse);for(a=0;a<this._leafNum;a++)o=a%r,s=Math.floor(a/r),this._leafs[a].calcSkirtVertextBuffer(this._chunkOffsetX,this._chunkOffsetZ,o*Tn.LEAF_GRID_NUM,s*Tn.LEAF_GRID_NUM,this._gridSize,i,this._leafNum*Tn.LEAF_PLANE_VERTEXT_COUNT+a*Tn.LEAF_SKIRT_VERTEXT_COUNT,n,this._terrainHeightData,this._terrainHeightDataWidth,this._terrainHeightDataHeight);this.assembleIndexInit(),this._vertexBuffer=new Gi(t,this._numberVertices,35044,!1),this._indexBuffer=new Ui("ushort",this._maxNumberIndices,35044,!1),this._vertexBuffer.setData(i),this._indexBuffer.setData(this._indexArrayBuffer),this.memorySize=2*(this._vertexBuffer._byteLength+this._indexBuffer._byteLength),this.calcOriginalBoudingBoxAndSphere()},t.setLODLevel=function(e){if(4!=e.length)return!0;e=(e[0]+1<<24)+(e[1]+1<<16)+(e[2]+1<<8)+(e[3]+1);return this._currentLOD!=e&&(this._currentLOD=e,!0)},t.assembleIndexInit=function(){this._currentNumberIndices=0;for(var e=this._numberTriangle=0,t=0;t<this._leafNum;t++){var n=Tn.getPlaneLODIndex(t,0);this._indexArrayBuffer.set(n,e),e+=n.length;var i=Tn.getSkirtLODIndex(t,0);this._indexArrayBuffer.set(i,e),e+=i.length,this._currentNumberIndices+=n.length+i.length}this._numberTriangle=this._currentNumberIndices/3},t.isNeedAssemble=function(e,t){e=Math.min(e.viewport.width,e.viewport.height)/(2*Math.tan(Math.PI*e.fieldOfView/180));return this._perspectiveFactor!=e?(this._perspectiveFactor=e,1):this._LODTolerance!=_r.LOD_TOLERANCE_VALUE?(this._LODTolerance=_r.LOD_TOLERANCE_VALUE,1):0==hn.equals(t,this._cameraPos)?(this._cameraPos.x=t.x,this._cameraPos.y=t.y,this._cameraPos.z=t.z,2):0},t.assembleIndex=function(e,t){var n=this.isNeedAssemble(e,t);if(0<n){for(var i=0;i<this._leafNum;i++)h._TEMP_ARRAY_BUFFER[i]=this._leafs[i].determineLod(t,this._perspectiveFactor,_r.LOD_TOLERANCE_VALUE,1==n);if(this.setLODLevel(h._TEMP_ARRAY_BUFFER)){this._currentNumberIndices=0;for(var r=this._numberTriangle=0,i=0;i<this._leafNum;i++){var a=h._TEMP_ARRAY_BUFFER[i],o=Tn.getPlaneLODIndex(i,a);this._indexArrayBuffer.set(o,r),r+=o.length;a=Tn.getSkirtLODIndex(i,a);this._indexArrayBuffer.set(a,r),r+=a.length,this._currentNumberIndices+=o.length+a.length}return this._numberTriangle=this._currentNumberIndices/3,!0}}return!1},t.calcOriginalBoudingBoxAndSphere=function(){for(var e=new ln(2147483647,-2147483647),t=0;t<this._leafNum;t++)e.x=(this._leafs[t]._sizeOfY.x<e.x?this._leafs[t]._sizeOfY:e).x,e.y=(this._leafs[t]._sizeOfY.y>e.y?this._leafs[t]._sizeOfY:e).y;var n=new hn(this._chunkOffsetX*Tn.CHUNK_GRID_NUM*this._gridSize,e.x,this._chunkOffsetZ*Tn.CHUNK_GRID_NUM*this._gridSize),i=new hn((this._chunkOffsetX+1)*Tn.CHUNK_GRID_NUM*this._gridSize,e.y,(this._chunkOffsetZ+1)*Tn.CHUNK_GRID_NUM*this._gridSize);Tn.__ADAPT_MATRIX__&&(hn.transformV3ToV3(n,Tn.__ADAPT_MATRIX__,n),hn.transformV3ToV3(i,Tn.__ADAPT_MATRIX__,i)),this._boundingBox=new kt(n,i);var r=new hn;hn.subtract(i,n,r),hn.scale(r,.5,r);i=new hn;hn.add(n,r,i),this._boundingSphere=new Yt(i,hn.scalarLength(r)),this._boundingBoxCorners=v(8,null),this._boundingBox.getCorners(this._boundingBoxCorners)},t.calcLeafBoudingBox=function(e){for(var t=0;t<this._leafNum;t++)this._leafs[t].calcLeafBoudingBox(e)},t.calcLeafBoudingSphere=function(e,t){for(var n=0;n<this._leafNum;n++)this._leafs[n].calcLeafBoudingSphere(e,t)},t._getVertexBuffer=function(e){return 0==(e=void 0===e?0:e)?this._vertexBuffer:null},t._getIndexBuffer=function(){return this._indexBuffer},t._beforeRender=function(e){return this._vertexBuffer._bind(),this._indexBuffer._bind(),0==e.renderElement._material.blend&&(e=e.camera,this.assembleIndex(e,e.position)&&this._indexBuffer.setData(this._indexArrayBuffer)),!0},t._getVertexBuffers=function(){return null},t._render=function(e){N.mainContext.drawElements(_r.RENDER_LINE_MODEL?1:4,this._currentNumberIndices,5123,0),I.trianglesFaces+=this._numberTriangle,I.drawCall++},_(0,t,"_originalBoundingSphere",function(){return this._boundingSphere}),_(0,t,"_originalBoundingBox",function(){return this._boundingBox}),_(0,t,"_vertexBufferCount",function(){return this._numberVertices}),_(0,t,"triangleCount",function(){return this._numberTriangle}),l(h,["_TEMP_ARRAY_BUFFER",function(){return this._TEMP_ARRAY_BUFFER=new Uint32Array(Tn.CHUNK_GRID_NUM/Tn.LEAF_GRID_NUM*Tn.CHUNK_GRID_NUM/Tn.LEAF_GRID_NUM)}]),h}(Hn),Ii=function(e){function t(e){this._terrainSprite3DOwner=null,t.__super.call(this,e),this._terrainSprite3DOwner=e}p(t,"laya.d3.terrain.TerrainRender",e);var n=t.prototype;return n._calculateBoundingSphere=function(){var e,t,n,i,r=this._terrainSprite3DOwner.terrainFilter;null==r?this._boundingSphere.toDefault():(e=r._originalBoundingSphere,i=NaN,i=(n=(t=this._terrainSprite3DOwner.transform).scale).x>=n.y&&n.x>=n.z?n.x:n.y>=n.z?n.y:n.z,hn.transformCoordinate(e.center,t.worldMatrix,this._boundingSphere.center),this._boundingSphere.radius=e.radius*i,r.calcLeafBoudingSphere(t.worldMatrix,i))},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++)hn.transformCoordinate(n[i],t,Gn._tempBoundBoxCorners[i]);kt.createfromPoints(Gn._tempBoundBoxCorners,this._boundingBox),e.calcLeafBoudingBox(t)}},n._renderUpdate=function(e){this._setShaderValueMatrix4x4(0,this._owner.transform.worldMatrix);e=this._owner.getProjectionViewWorldMatrix(e);return this._setShaderValueMatrix4x4(1,e),!0},n._destroy=function(){e.prototype._destroy.call(this),this._terrainSprite3DOwner=null},t}(Gn),Ai=(function(e){function t(e){t.__super.call(this,e)}p(t,"laya.d3.water.WaterRender",e);var n=t.prototype;n._calculateBoundingSphere=function(){},n._calculateBoundingBox=function(){},n._destroy=function(){e.prototype._destroy.call(this)}}(Gn),function(t){function i(){this._time=0,this._enableLightCount=3,this._customRenderQueneIndex=11,this.enableLight=!0,i.__super.call(this),this._renderState=new ve,this._lights=[],this._quenes=[],this._cameraPool=[],this._renderableSprite3Ds=[],this.__loaded=!0,this._lightmaps=[],this._shaderValues=new vn,this.parallelSplitShadowMaps=[],this._dynamicBatchManager=new Ue,this._cullingRenders=[],this._cullingRendersLength=0,this.enableFog=!1,this.fogStart=300,this.fogRange=1e3,this.fogColor=new hn(.7,.7,.7),this.ambientColor=new hn(.212,.227,.259),N.shaderHighPrecision&&this.addShaderDefine($n.SHADERDEFINE_HIGHPRECISION),this.on("display",this,this._display),this.on("undisplay",this,this._unDisplay),this._componentsMap=[],this._typeComponentsIndices=[],this._components=[]}p(i,"laya.d3.core.scene.Scene",t);var e=i.prototype;return S.imps(e,{"laya.webgl.submit.ISubmit":!0,"laya.resource.ICreateResource":!0}),e._setUrl=function(e){this._url=e},e._getGroup=function(){return this._group},e._setGroup=function(e){this._group=e},e._display=function(){S.stage._scenes.push(this),S.stage._scenes.sort(i._sortScenes);for(var e=0,t=this._childs.length;e<t;e++){var n=this._childs[e];n.active&&n._activeHierarchy()}},e._unDisplay=function(){var e=S.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()}},e._addChild3D=function(e){e.transform._onWorldTransform(),e._setBelongScene(this),this.displayedInStage&&e.active&&e._activeHierarchy()},e._removeChild3D=function(e){e.transform.parent=null,this.displayedInStage&&e.active&&e._inActiveHierarchy(),e._setUnBelongScene()},e.initOctree=function(e,t,n,i,r){void 0===r&&(r=6),this.treeSize=new hn(e,t,n),this.treeLevel=r,this.treeRoot=new Te(this,0),this.treeRoot.init(i,this.treeSize)},e._prepareUpdateToRenderState=function(e,t){t.elapsedTime=this._lastCurrentTime?this.timer.currTimer-this._lastCurrentTime:0,this._lastCurrentTime=this.timer.currTimer,t.scene=this},e._prepareSceneToRender=function(e){var t=this._lights.length;if(0<t)for(var n=0,i=0;i<t&&!(this._lights[i]._prepareToScene(e)&&++n>=this._enableLightCount);i++);},e._updateChilds=function(e){for(var t=0,n=this._childs.length;t<n;++t)this._childs[t]._update(e)},e._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?He.renderObjectCullingOctree(n,this,l,r,a,o):He.renderObjectCulling(n,this,l,r,a,o):He.renderObjectCullingNoBoundFrustum(this,l,r,a,o),s=0,i=this._quenes.length;s<i;s++)this._quenes[s]&&this._quenes[s]._preRender(t)},e._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 _,u=i.clearColor;if(u&&(e.enable(3089),e.scissor(r,a,o,s),_=u.elements,e.clearColor(_[0],_[1],_[2],_[3]),l|=16384),h)switch(u||(l=16384),h.depthStencilFormat){case 33189:l|=256;break;case 36168:l|=1024;break;case 34041:l|=256,l|=1024}e.clear(l),u&&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.")}},e._renderScene=function(e,t){for(var n,i,r,a=t.camera,o=0,o=0;o<2;o++)(i=this._quenes[o])&&(a.renderTarget?i._render(t,!0):i._render(t,!1));for(1!==a.clearFlag||(r=a.sky)&&(V.setCullFace(e,!1),V.setDepthFunc(e,515),V.setDepthMask(e,!1),r._render(t),V.setDepthFunc(e,513),V.setDepthMask(e,!0)),o=2,n=this._quenes.length;o<n;o++)(i=this._quenes[o])&&(i._sortAlpha(t.camera.transform.position),a.renderTarget?i._render(t,!0):i._render(t,!1))},e._set3DRenderConfig=function(e){e.disable(3042),V._blend=!1,e.blendFunc(770,771),V._sFactor=770,V._dFactor=771,e.disable(2929),V._depthTest=!1,e.enable(2884),V._cullFace=!0,e.depthMask(1),V._depthMask=!0,e.frontFace(2304),V._frontFace=2304},e._set2DRenderConfig=function(e){V.setBlend(e,!0),V.setBlendFunc(e,1,771),V.setDepthTest(e,!1),V.setCullFace(e,!1),V.setDepthMask(e,!0),V.setFrontFace(e,2305),e.viewport(0,0,E.width,E.height)},e._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]=W.getRes(t[r[s].replace(".exr",".png")]);this.setlightmaps(o);var l=i.customProps.ambientColor;l&&(this.ambientColor=new hn(l[0],l[1],l[2]));i=i.customProps.fogColor;i&&(this.fogColor=new hn(i[0],i[1],i[2]))},e._addLight=function(e){this._lights.indexOf(e)<0&&this._lights.push(e)},e._removeLight=function(e){e=this._lights.indexOf(e);0<=e&&this._lights.splice(e,1)},e._updateScene=function(){var e=this._renderState;this._prepareUpdateToRenderState(N.mainContext,e),this._updateComponents(e),this._updateChilds(e),this._lateUpdateComponents(e),this._time+=e.elapsedTime/1e3,this._shaderValues.setValue(22,this._time)},e._updateSceneConch=function(){var e=this._renderState;this._prepareUpdateToRenderState(N.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)._prepareCameraToRender()}},e._preRenderShadow=function(e,t,n,i,r){this.treeRoot?He.renderShadowObjectCullingOctree(this,t,n,i,r):He.renderShadowObjectCulling(this,t,n,i,r);for(var a=0,o=n.length;a<o;a++)n[a]&&n[a]._preRender(e)},e._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(gn.SHADERDEFINE_CAST_SHADOW),1<s)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(gn.SHADERDEFINE_CAST_SHADOW)},e.addTreeNode=function(e){this.treeRoot.addTreeNode(e)},e.removeTreeNode=function(e){this.treeSize&&e._treeNode&&e._treeNode.removeObject(e)},e.setlightmaps=function(e){this._lightmaps=e;for(var t=0,n=this._renderableSprite3Ds.length;t<n;t++)this._renderableSprite3Ds[t]._render._applyLightMapParams()},e.getlightmaps=function(){return this._lightmaps},e.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;var n;if(e.zOrder&&this._set$P("hasZorder",!0),0<=t&&t<=this._childs.length)return e._parent===this?(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()):(e.parent&&e.parent.removeChild(e),this._childs===d.ARRAY_EMPTY&&(this._childs=[]),this._childs.splice(t,0,e),this.conchModel&&this.conchModel.addChildAt(e.conchModel,t),(e.parent=this)._addChild3D(e)),e;throw new Error("appendChildAt:The index is out of bounds")},e.addChild=function(e){if(!(e instanceof laya.d3.core.Sprite3D))throw new Error("Sprite3D:Node type must Sprite3D.");return!e||this.destroyed||e===this||(e.zOrder&&this._set$P("hasZorder",!0),e._parent===this?(t=this.getChildIndex(e))!==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()):(e.parent&&e.parent.removeChild(e),this._childs===d.ARRAY_EMPTY&&(this._childs=[]),this._childs.push(e),this.conchModel&&this.conchModel.addChildAt(e.conchModel,this._childs.length-1),(e.parent=this)._childChanged(),this._addChild3D(e))),e;var t},e.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},e.removeChildren=function(e,t){if(void 0===e&&(e=0),void 0===t&&(t=2147483647),this._childs&&0<this._childs.length){var n,i=this._childs;0===e&&a<=t?(n=i,this._childs=d.ARRAY_EMPTY):n=i.splice(e,t-e);for(var r=0,a=n.length;r<a;r++)this._removeChild3D(n[r]),n[r].parent=null,this.conchModel&&this.conchModel.removeChild(n[r].conchModel)}return this},e.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++)},e.removeFrustumCullingObject=function(e){var t,n;this.treeRoot?this.removeTreeNode(e):(this._cullingRendersLength--,(t=e._indexInSceneFrustumCullingObjects)!==this._cullingRendersLength&&(n=this._cullingRenders[this._cullingRendersLength],(this._cullingRenders[t]=n)._indexInSceneFrustumCullingObjects=t,e._indexInSceneFrustumCullingObjects=-1))},e.getRenderQueue=function(e){return e<3e3?this._quenes[1]||(this._quenes[1]=new Ee(this)):this._quenes[2]||(this._quenes[2]=new Ee(this))},e.addRenderQuene=function(){this._quenes[this._customRenderQueneIndex++]=new Ee(this)},e.addShaderDefine=function(e){this._shaderDefineValue|=e},e.removeShaderDefine=function(e){this._shaderDefineValue&=~e},e.addScript=function(e){return this._addComponent(e)},e.getScriptByType=function(e,t){return this._getComponentByType(e,t=void 0===t?0:t)},e.getScriptsByType=function(e,t){this._getComponentsByType(e,t)},e.getScriptByIndex=function(e){return this._getComponentByIndex(e)},e.removeScriptByType=function(e,t){this._removeComponentByType(e,t=void 0===t?0:t)},e.removeScriptsByType=function(e){this._removeComponentByType(e)},e.removeAllScript=function(){this._removeAllComponent()},e.render=function(e,t,n){(m._context.ctx._renderKey=0)<this._childs.length&&e.addRenderObject(this)},e.renderSubmit=function(){var e=N.mainContext,t=this._renderState;this._set3DRenderConfig(e),this._prepareSceneToRender(this._renderState);var n,i=0,r=0;if(Pn.debugMode||Te.debugMode)for(i=0,r=this._cameraPool.length;i<r;i++)n=this._cameraPool[i],Pn._debugPhasorSprite.begin(1,n),n.activeInHierarchy&&n._renderCamera(e,t,this),Pn._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},e.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.");t=t[1];wn._createNodeByJson(this,i,this,t),this.event("hierarchyloaded",[this]),this.__loaded=!0},e.destroy=function(e){void 0===e&&(e=!0),this.destroyed||(t.prototype.destroy.call(this,e),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,W.clearRes(this.url),this.loaded||Pn._cancelLoadByUrl(this.url))},e.getRenderType=function(){return 0},e.releaseRender=function(){},e._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+"组件已存在!");e=a.getInstance(e);t.push(this._components.length),this._components.push(e);return e._initialize(this),e},e._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;0<=s;s--){var l=n[s];if(!(i<l))break;n[s]=--l}r._destroy()},e._getComponentByType=function(e,t){void 0===t&&(t=0);e=this._componentsMap.indexOf(e);return-1===e?null:this._components[this._typeComponentsIndices[e][t]]},e._getComponentsByType=function(e,t){e=this._componentsMap.indexOf(e);if(-1!==e){var n=this._typeComponentsIndices[e],i=n.length;t.length=i;for(var r=0;r<i;r++)t[r]=this._components[n[r]]}else t.length=0},e._getComponentByIndex=function(e){return this._components[e]},e._removeComponentByType=function(e,t){void 0===t&&(t=0);e=this._componentsMap.indexOf(e);-1!==e&&this._removeComponent(e,t)},e._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)},e._removeAllComponent=function(){for(var e=0,t=this._componentsMap.length;e<t;this._componentsMap.length<t?t--:e++)this._removeComponentsByType(this._componentsMap[e])},e._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)}},e._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)}},e._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)}},e._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)}},_(0,e,"_loaded",null,function(e){this.__loaded=e}),_(0,e,"fogColor",function(){return this._fogColor},function(e){this._fogColor=e,this._shaderValues.setValue(0,e.elements)}),_(0,e,"enableFog",function(){return this._enableFog},function(e){this._enableFog!==e&&((this._enableFog=e)?(this.addShaderDefine($n.SHADERDEFINE_FOG),this.removeShaderDefine($n.SAHDERDEFINE_DEPTHFOG)):this.removeShaderDefine($n.SHADERDEFINE_FOG))}),_(0,e,"url",function(){return this._url}),_(0,e,"loaded",function(){return this.__loaded}),_(0,e,"enableDepthFog",function(){return this._enableDepthFog},function(e){this._enableDepthFog!=e&&((this._enableDepthFog=e)?(this.addShaderDefine($n.SAHDERDEFINE_DEPTHFOG),this.removeShaderDefine($n.SHADERDEFINE_FOG)):this.removeShaderDefine($n.SAHDERDEFINE_DEPTHFOG))}),_(0,e,"fogStart",function(){return this._fogStart},function(e){this._fogStart=e,this._shaderValues.setValue(1,e)}),_(0,e,"fogRange",function(){return this._fogRange},function(e){this._fogRange=e,this._shaderValues.setValue(2,e)}),_(0,e,"ambientColor",function(){return this._ambientColor},function(e){this._ambientColor=e,this._shaderValues.setValue(21,e.elements)}),_(0,e,"scene",function(){return this}),_(0,e,"renderableSprite3Ds",function(){return this._renderableSprite3Ds.slice()}),i._sortScenes=function(e,t){if(e.parent!==S.stage||t.parent!==S.stage)return e.parent!==S.stage&&t.parent!==S.stage?i._sortScenes(e.parent,t.parent):e.parent===S.stage?-1:1;var n=S.stage._childs;return n.indexOf(e)-n.indexOf(t)},i.load=function(e){return S.loader.create(e,null,null,i)},i.FOGCOLOR=0,i.FOGSTART=1,i.FOGRANGE=2,i.LIGHTDIRECTION=3,i.LIGHTDIRCOLOR=4,i.POINTLIGHTPOS=5,i.POINTLIGHTRANGE=6,i.POINTLIGHTATTENUATION=7,i.POINTLIGHTCOLOR=8,i.SPOTLIGHTPOS=9,i.SPOTLIGHTDIRECTION=10,i.SPOTLIGHTSPOT=11,i.SPOTLIGHTRANGE=12,i.SPOTLIGHTATTENUATION=13,i.SPOTLIGHTCOLOR=14,i.SHADOWDISTANCE=15,i.SHADOWLIGHTVIEWPROJECT=16,i.SHADOWMAPPCFOFFSET=17,i.SHADOWMAPTEXTURE1=18,i.SHADOWMAPTEXTURE2=19,i.SHADOWMAPTEXTURE3=20,i.AMBIENTCOLOR=21,i.TIME=22,i}(e)),Ci=function(){function t(e){t.__super.call(this),this.__loaded=!0,this._projectionViewWorldUpdateLoopCount=-1,this._activeInHierarchy=!1,this._projectionViewWorldMatrix=new Jt,this._shaderValues=new vn,this._colliders=[],this._id=++t._uniqueIDCounter,this._transform=new zn(this),this.name=e||"Sprite3D-"+t._nameNumberCounter++,this.layer=Z.currentCreationLayer,this.active=!0}p(t,"laya.d3.core.Sprite3D",ti);var e=t.prototype;return S.imps(e,{"laya.d3.core.render.IUpdate":!0,"laya.resource.ICreateResource":!0,"laya.d3.core.IClone":!0}),e._setUrl=function(e){this._url=e},e._getGroup=function(){return this._group},e._setGroup=function(e){this._group=e},e._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())},e._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]))},e._parseBaseCustomProps=function(e){var t=this.transform.localPosition;t.fromArray(e.translate),this.transform.localPosition=t;t=this.transform.localRotation;t.fromArray(e.rotation),this.transform.localRotation=t;t=this.transform.localScale;t.fromArray(e.scale),this.transform.localScale=t;e=e.layer;null!=e&&(this.layer=Z.getLayerByNumber(e))},e._parseCustomComponent=function(e,t,n){for(var i in n){var r=n[i];switch(i){case"Animator":var a,o=this.addComponent(_i);r.avatarPath?o.avatar=W.getRes(t[r.avatarPath]):(a=r.avatar)&&(o.avatar=W.getRes(t[a.path]),(_=a.linkSprites)&&e.once("hierarchyloaded",this,this._onRootNodeHierarchyLoaded,[o,_]));for(var s=r.clipPaths,l=s.length,h=0;h<l;h++)o.addClip(W.getRes(t[s[h]]));o.clip=W.getRes(t[s[0]]);var _=r.playOnWake;void 0!==_&&(o.playOnWake=_);break;case"Rigidbody":this.addComponent(di);break;case"SphereCollider":var u=this.addComponent(Qi);u.isTrigger=r.isTrigger;var d=u.center;d.fromArray(r.center),u.center=d,u.radius=r.radius;break;case"BoxCollider":d=this.addComponent(Ki);d.isTrigger=r.isTrigger,d.center.fromArray(r.center);u=d.size;u.fromArray(r.size),d.size=u;break;case"MeshCollider":this.addComponent(qi)}}},e._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)}},e._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)}},e._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)}},e._getAnimatorToLinkSprite3D=function(e,t,n){var i=this.getComponentByType(_i);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),(i=this._parent)._hierarchyAnimator&&i._getAnimatorToLinkSprite3D(e,t,n))},e._setAnimatorToLinkSprite3DNoAvatar=function(e,t,n){for(var i=0,r=0,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)}},e._changeHierarchyAnimator=function(e){this._hierarchyAnimator=e},e._isLinkSpriteToAnimationNode=function(e,t,n){var i=e._avatarNodes.indexOf(t),r=e._cacheSpriteToNodesMap;n?(this._transform.dummy=t.transform,e._cacheNodesToSpriteMap[i]=r.length,r.push(i)):(this._transform.dummy=null,t=e._cacheNodesToSpriteMap[i],e._cacheNodesToSpriteMap[i]=null,r.splice(t,1))},e._setBelongScene=function(e){this._scene=e;for(var t=0,n=this._childs.length;t<n;t++)this._childs[t]._setBelongScene(e)},e._setUnBelongScene=function(){this._scene=null;for(var e=0,t=this._childs.length;e<t;e++)this._childs[e]._setUnBelongScene()},e._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()}},e._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()}},e.addComponent=function(e){var t=this._componentsMap.indexOf(e);if(-1===t)n=[],this._componentsMap.push(e),this._typeComponentsIndices.push(n);else if(n=this._typeComponentsIndices[t],this._components[n[0]].isSingleton)throw new Error("无法单实例创建"+e+"组件,"+e+"组件已存在!");e=a.getInstance(e);if(n.push(this._components.length),this._components.push(e),e instanceof laya.d3.component.physics.Collider)this.getComponentByType(di)&&(e._isRigidbody=!0),this._activeInHierarchy&&this._layer._addCollider(e),this._colliders.push(e);else if(e instanceof laya.d3.component.Animator){var n=e;this._setHierarchyAnimator(n,this._parent?this._parent._hierarchyAnimator:null),this._setAnimatorToLinkSprite3DNoAvatar(n,!0,[])}else if(e instanceof laya.d3.component.Rigidbody)for(var i=0,r=this._colliders.length;i<r;i++)this._colliders[i]._setIsRigidbody(!0);return e instanceof laya.d3.component.Script&&this._scripts.push(e),e._initialize(this),e},e._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)this._clearHierarchyAnimator(o,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 l=this._colliders[n];l._setIsRigidbody(!1);var h,_=l._runtimeCollisonMap,u=l._runtimeCollisonTestMap;for(h in _)delete u[h]}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;0<=d;d--){var c=r[d];if(!(a<c))break;r[d]=--c}o._destroy()},e._clearSelfRenderObjects=function(){},e._addSelfRenderObjects=function(){},e._parseCustomProps=function(e,t,n,i){},e._updateChilds=function(e){var t=this._childs.length;if(0!==t)for(var n=0;n<t;++n)this._childs[n]._update(e)},e._getSortID=function(e,t){return 1e3*t.id+e._getVertexBuffer().vertexDeclaration.id},e._update=function(e){(e.owner=this)._activeInHierarchy&&(this._updateComponents(e),this._lateUpdateComponents(e),I.spriteCount++,this._childs.length&&this._updateChilds(e))},e.getProjectionViewWorldMatrix=function(e){return Jt.multiply(e,this.transform.worldMatrix,this._projectionViewWorldMatrix),this._projectionViewWorldMatrix},e.loadHierarchy=function(e){this.addChild(laya.d3.core.Sprite3D.load(e))},e.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;var n;if(e.zOrder&&this._set$P("hasZorder",!0),0<=t&&t<=this._childs.length)return e._parent===this?(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()):(e.parent&&e.parent.removeChild(e),this._childs===d.ARRAY_EMPTY&&(this._childs=[]),this._childs.splice(t,0,e),this.conchModel&&this.conchModel.addChildAt(e.conchModel,t),(e.parent=this)._addChild3D(e)),e;throw new Error("appendChildAt:The index is out of bounds")},e.addChild=function(e){if(!(e instanceof laya.d3.core.Sprite3D))throw new Error("Sprite3D:Node type must Sprite3D.");return!e||this.destroyed||e===this||(e.zOrder&&this._set$P("hasZorder",!0),e._parent===this?(t=this.getChildIndex(e))!==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()):(e.parent&&e.parent.removeChild(e),this._childs===d.ARRAY_EMPTY&&(this._childs=[]),this._childs.push(e),this.conchModel&&this.conchModel.addChildAt(e.conchModel,this._childs.length-1),(e.parent=this)._childChanged(),this._addChild3D(e))),e;var t},e.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},e.removeChildren=function(e,t){if(void 0===e&&(e=0),void 0===t&&(t=2147483647),this._childs&&0<this._childs.length){var n,i=this._childs;0===e&&a<=t?(n=i,this._childs=d.ARRAY_EMPTY):n=i.splice(e,t-e);for(var r=0,a=n.length;r<a;r++)this._removeChild3D(n[r]),n[r].parent=null,this.conchModel&&this.conchModel.removeChild(n[r].conchModel)}return this},e.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.");t=t[1];wn._createNodeByJson(this,i,this,t),this.event("hierarchyloaded",[this]),this.__loaded=!0},e.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;e=t.transform.localPosition;this.transform.localPosition.cloneTo(e),t.transform.localPosition=e;e=t.transform.localRotation;this.transform.localRotation.cloneTo(e),t.transform.localRotation=e;e=t.transform.localScale;this.transform.localScale.cloneTo(e),t.transform.localScale=e,t.isStatic=this.isStatic;for(var n=0,i=0,n=0,i=this._componentsMap.length;n<i;n++){var r=t.addComponent(this._componentsMap[n]);this._components[n]._cloneTo(r)}for(n=0,i=this._childs.length;n<i;n++)t.addChild(this._childs[n].clone());var a=t.getComponentByType(_i);if(a){var o=a._linkSpritesData;if(o)for(var s in o){for(var l=o[s],h=t,_=0,u=l.length;_<u&&(h=h.getChildByName(l[_]));_++);h&&(s=a._avatarNodeMap[s],h._isLinkSpriteToAnimationNode(a,s,!0))}}},e.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},e.destroy=function(e){if(void 0===e&&(e=!0),!this.destroyed){laya.display.Node.prototype.destroy.call(this,e);for(var t=0,t=0,n=this._components.length;t<n;t++)this._components[t]._destroy();this._components=null,this._componentsMap=null,this._typeComponentsIndices=null,this._transform=null,this._colliders=null,W.clearRes(this.url),this.loaded||Pn._cancelLoadByUrl(this.url)}},e._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)},e._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)},_(0,e,"activeInHierarchy",function(){return this._activeInHierarchy}),_(0,e,"_loaded",null,function(e){this.__loaded=e}),_(0,e,"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()))}),_(0,e,"componentsCount",function(){return this._components.length}),_(0,e,"loaded",function(){return this.__loaded}),_(0,e,"id",function(){return this._id}),_(0,e,"url",function(){return this._url}),_(0,e,"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)}}),_(0,e,"scene",function(){return this._scene}),_(0,e,"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);t=a.transform;return n?(n=t.worldMatrix,e.transform.worldMatrix.cloneTo(n),t.worldMatrix=n):(i&&(t.position=i),r&&(t.rotation=r)),a},t.load=function(e){return S.loader.create(e,null,null,t)},t.WORLDMATRIX=0,t.MVPMATRIX=1,t._uniqueIDCounter=0,t._nameNumberCounter=0,t}(),yi=function(t){function n(){n.__super.call(this),this.setShaderName("BLINNPHONG"),this._albedoIntensity=1,this._albedoColor=new _n(1,1,1,1),this._setColor(6,new _n(1,1,1,1)),this._setColor(8,new hn(1,1,1)),this._setNumber(9,.078125),this._setColor(10,new hn(1,1,1)),this._setNumber(0,.5),this._setColor(11,new _n(1,1,0,0)),this._enableLighting=!0,this.renderMode=0}p(n,"laya.d3.core.material.BlinnPhongMaterial",t);var e=n.prototype;return e.disableLight=function(){this._addDisablePublicShaderDefine($n.SHADERDEFINE_POINTLIGHT|$n.SHADERDEFINE_SPOTLIGHT|$n.SHADERDEFINE_DIRECTIONLIGHT)},e.disableFog=function(){this._addDisablePublicShaderDefine($n.SHADERDEFINE_FOG)},e.cloneTo=function(e){t.prototype.cloneTo.call(this,e);e._enableLighting=this._enableLighting,e._albedoIntensity=this._albedoIntensity,this._albedoColor.cloneTo(e._albedoColor)},_(0,e,"renderMode",null,function(e){switch(e){case 0:this.renderQueue=2e3,this.depthWrite=!0,this.cull=2,this.blend=0,this.alphaTest=!1,this.depthTest=513,this._removeShaderDefine(n.SHADERDEFINE_ADDTIVEFOG);break;case 1:this.depthWrite=!0,this.cull=2,this.blend=0,this.renderQueue=2e3,this.alphaTest=!0,this.depthTest=513,this._removeShaderDefine(n.SHADERDEFINE_ADDTIVEFOG);break;case 2:this.renderQueue=3e3,this.depthWrite=!1,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=771,this.alphaTest=!1,this.depthTest=513,this._removeShaderDefine(n.SHADERDEFINE_ADDTIVEFOG);break;case 3:this.renderQueue=3e3,this.depthWrite=!1,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=1,this.alphaTest=!1,this.depthTest=513,this._addShaderDefine(n.SHADERDEFINE_ADDTIVEFOG);break;default:throw new Error("Material:renderMode value error.")}this._conchMaterial&&this._conchMaterial.setRenderMode(e)}),_(0,e,"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)}),_(0,e,"reflectColor",function(){return this._getColor(10)},function(e){this._setColor(10,e)}),_(0,e,"tilingOffset",function(){return this._getColor(11)},function(e){var t;e&&(1!=(t=e.elements)[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),this._setColor(11,e)}),_(0,e,"specularColor",function(){return this._getColor(8)},function(e){this._setColor(8,e)}),_(0,e,"albedoColor",function(){return this._albedoColor},function(e){var t=this._getColor(6);_n.scale(e,this._albedoIntensity,t),this._albedoColor=e}),_(0,e,"albedoIntensity",function(){return this._albedoIntensity},function(e){var t;this._albedoIntensity!==e&&(t=this._getColor(6),_n.scale(this._albedoColor,e,t),this._albedoIntensity=e)}),_(0,e,"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)}),_(0,e,"shininess",function(){return this._getNumber(9)},function(e){e=Math.max(0,Math.min(1,e)),this._setNumber(9,e)}),_(0,e,"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)}),_(0,e,"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)}),_(0,e,"enableLighting",function(){return this._enableLighting},function(e){this._enableLighting!==e&&(e?this._removeDisablePublicShaderDefine($n.SHADERDEFINE_POINTLIGHT|$n.SHADERDEFINE_SPOTLIGHT|$n.SHADERDEFINE_DIRECTIONLIGHT):this._addDisablePublicShaderDefine($n.SHADERDEFINE_POINTLIGHT|$n.SHADERDEFINE_SPOTLIGHT|$n.SHADERDEFINE_DIRECTIONLIGHT),this._enableLighting=e)}),n.__init__=function(){n.SHADERDEFINE_DIFFUSEMAP=n.shaderDefines.registerDefine("DIFFUSEMAP"),n.SHADERDEFINE_NORMALMAP=n.shaderDefines.registerDefine("NORMALMAP"),n.SHADERDEFINE_SPECULARMAP=n.shaderDefines.registerDefine("SPECULARMAP"),n.SHADERDEFINE_REFLECTMAP=n.shaderDefines.registerDefine("REFLECTMAP"),n.SHADERDEFINE_TILINGOFFSET=n.shaderDefines.registerDefine("TILINGOFFSET"),n.SHADERDEFINE_ADDTIVEFOG=n.shaderDefines.registerDefine("ADDTIVEFOG")},n.load=function(e){return S.loader.create(e,null,null,n)},n.SPECULARSOURCE_DIFFUSEMAPALPHA=0,n.SPECULARSOURCE_SPECULARMAP=0,n.RENDERMODE_OPAQUE=0,n.RENDERMODE_CUTOUT=1,n.RENDERMODE_TRANSPARENT=2,n.RENDERMODE_ADDTIVE=3,n.SHADERDEFINE_DIFFUSEMAP=0,n.SHADERDEFINE_NORMALMAP=0,n.SHADERDEFINE_SPECULARMAP=0,n.SHADERDEFINE_REFLECTMAP=0,n.SHADERDEFINE_TILINGOFFSET=0,n.SHADERDEFINE_ADDTIVEFOG=0,n.ALBEDOTEXTURE=1,n.NORMALTEXTURE=2,n.SPECULARTEXTURE=3,n.EMISSIVETEXTURE=4,n.REFLECTTEXTURE=5,n.ALBEDOCOLOR=6,n.MATERIALSPECULAR=8,n.SHININESS=9,n.MATERIALREFLECT=10,n.TILINGOFFSET=11,l(n,["defaultMaterial",function(){return this.defaultMaterial=new n},"shaderDefines",function(){return this.shaderDefines=new fn(ri.shaderDefines)}]),n}(ri),Oi=function(){function e(){e.__super.call(this),this.setShaderName("ExtendTerrain"),this.renderMode=1}p(e,"laya.d3.core.material.ExtendTerrainMaterial",ri);var t=e.prototype;return t._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)}},t.disableLight=function(){this._addDisablePublicShaderDefine($n.SHADERDEFINE_POINTLIGHT|$n.SHADERDEFINE_SPOTLIGHT|$n.SHADERDEFINE_DIRECTIONLIGHT)},_(0,t,"diffuseScaleOffset2",null,function(e){this._setColor(7,e)}),_(0,t,"splatAlphaTexture",function(){return this._getTexture(0)},function(e){this._setTexture(0,e)}),_(0,t,"diffuseScaleOffset3",null,function(e){this._setColor(8,e)}),_(0,t,"diffuseTexture1",null,function(e){this._setTexture(1,e),this._setDetailNum(1)}),_(0,t,"renderMode",null,function(e){switch(e){case 1:this.renderQueue=2e3,this.depthWrite=!0,this.cull=2,this.blend=0,this.depthTest=513;break;case 2:this.renderQueue=2e3,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)}),_(0,t,"diffuseTexture2",function(){return this._getTexture(2)},function(e){this._setTexture(2,e),this._setDetailNum(2)}),_(0,t,"diffuseScaleOffset1",null,function(e){this._setColor(6,e)}),_(0,t,"diffuseTexture3",function(){return this._getTexture(3)},function(e){this._setTexture(3,e),this._setDetailNum(3)}),_(0,t,"diffuseTexture4",function(){return this._getTexture(4)},function(e){this._setTexture(4,e),this._setDetailNum(4)}),_(0,t,"diffuseTexture5",function(){return this._getTexture(5)},function(e){this._setTexture(5,e),this._setDetailNum(5)}),_(0,t,"diffuseScaleOffset4",null,function(e){this._setColor(9,e)}),_(0,t,"diffuseScaleOffset5",null,function(e){this._setColor(10,e)}),_(0,t,"albedo",function(){return this._getColor(14)},function(e){this._setColor(14,e)}),_(0,t,"ambientColor",function(){return this._getColor(11)},function(e){this._setColor(11,e)}),_(0,t,"diffuseColor",function(){return this._getColor(12)},function(e){this._setColor(12,e)}),_(0,t,"specularColor",function(){return this._getColor(13)},function(e){this._setColor(13,e)}),e.__init__=function(){e.SHADERDEFINE_DETAIL_NUM1=e.shaderDefines.registerDefine("ExtendTerrain_DETAIL_NUM1"),e.SHADERDEFINE_DETAIL_NUM2=e.shaderDefines.registerDefine("ExtendTerrain_DETAIL_NUM2"),e.SHADERDEFINE_DETAIL_NUM3=e.shaderDefines.registerDefine("ExtendTerrain_DETAIL_NUM3"),e.SHADERDEFINE_DETAIL_NUM4=e.shaderDefines.registerDefine("ExtendTerrain_DETAIL_NUM4"),e.SHADERDEFINE_DETAIL_NUM5=e.shaderDefines.registerDefine("ExtendTerrain_DETAIL_NUM5")},e.RENDERMODE_OPAQUE=1,e.RENDERMODE_TRANSPARENT=2,e.SPLATALPHATEXTURE=0,e.DIFFUSETEXTURE1=1,e.DIFFUSETEXTURE2=2,e.DIFFUSETEXTURE3=3,e.DIFFUSETEXTURE4=4,e.DIFFUSETEXTURE5=5,e.DIFFUSESCALEOFFSET1=6,e.DIFFUSESCALEOFFSET2=7,e.DIFFUSESCALEOFFSET3=8,e.DIFFUSESCALEOFFSET4=9,e.DIFFUSESCALEOFFSET5=10,e.MATERIALAMBIENT=11,e.MATERIALDIFFUSE=12,e.MATERIALSPECULAR=13,e.MATERIALALBEDO=14,e.SHADERDEFINE_DETAIL_NUM1=0,e.SHADERDEFINE_DETAIL_NUM2=0,e.SHADERDEFINE_DETAIL_NUM3=0,e.SHADERDEFINE_DETAIL_NUM4=0,e.SHADERDEFINE_DETAIL_NUM5=0,l(e,["shaderDefines",function(){return this.shaderDefines=new fn(ri.shaderDefines)}]),e}(),Ni=function(t){function n(){n.__super.call(this),this.setShaderName("GLITTER"),this.renderMode=1,this._setColor(3,new _n(1,1,1,1)),this._setColor(2,new _n(1,1,1,1))}p(n,"laya.d3.core.material.GlitterMaterial",t);var e=n.prototype;return e.setShaderName=function(e){t.prototype.setShaderName.call(this,e)},_(0,e,"renderMode",null,function(e){switch(e){case 1:this.renderQueue=2e3,this.depthWrite=!0,this.cull=2,this.blend=0;break;case 2:this.renderQueue=2e3,this.depthWrite=!0,this.cull=0,this.blend=0;break;case 13:this.renderQueue=3e3,this.depthWrite=!0,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=771;break;case 14:this.renderQueue=3e3,this.depthWrite=!0,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=771;break;case 15:this.renderQueue=3e3,this.depthWrite=!0,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=1;break;case 16:this.renderQueue=3e3,this.depthWrite=!0,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=1;break;case 5:this.renderQueue=3e3,this.depthWrite=!1,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=771;break;case 6:this.renderQueue=3e3,this.depthWrite=!1,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=771;break;case 7:this.renderQueue=3e3,this.depthWrite=!1,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=1;break;case 8:this.renderQueue=3e3,this.depthWrite=!1,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=1;break;case 9:this.renderQueue=3e3,this.depthTest=513,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=771;break;case 10:this.renderQueue=3e3,this.depthTest=513,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=771;break;case 11:this.renderQueue=3e3,this.depthTest=513,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=1;break;case 12:this.renderQueue=3e3,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)}),_(0,e,"diffuseTexture",function(){return this._getTexture(1)},function(e){this._setTexture(1,e)}),_(0,e,"albedo",function(){return this._getColor(2)},function(e){this._setColor(2,e)}),_(0,e,"color",function(){return this._getColor(3)},function(e){this._setColor(3,e)}),n.load=function(e){return S.loader.create(e,null,null,n)},n.RENDERMODE_OPAQUE=1,n.RENDERMODE_OPAQUEDOUBLEFACE=2,n.RENDERMODE_TRANSPARENT=13,n.RENDERMODE_TRANSPARENTDOUBLEFACE=14,n.RENDERMODE_ADDTIVE=15,n.RENDERMODE_ADDTIVEDOUBLEFACE=16,n.RENDERMODE_DEPTHREAD_TRANSPARENT=5,n.RENDERMODE_DEPTHREAD_TRANSPARENTDOUBLEFACE=6,n.RENDERMODE_DEPTHREAD_ADDTIVE=7,n.RENDERMODE_DEPTHREAD_ADDTIVEDOUBLEFACE=8,n.RENDERMODE_NONDEPTH_TRANSPARENT=9,n.RENDERMODE_NONDEPTH_TRANSPARENTDOUBLEFACE=10,n.RENDERMODE_NONDEPTH_ADDTIVE=11,n.RENDERMODE_NONDEPTH_ADDTIVEDOUBLEFACE=12,n.DIFFUSETEXTURE=1,n.ALBEDO=2,n.UNICOLOR=3,l(n,["defaultMaterial",function(){return this.defaultMaterial=new n}]),n}(ri),Vi=function(){function h(e,t,n,i,r,a,o,s){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=[],h.__super.call(this),!e||!t)throw"Shader Error";this._id=++h._count,this._vs=e,this._ps=t,this._attributeMap=n,this._sceneUniformMap=i,this._cameraUniformMap=r,this._spriteUniformMap=a,this._materialUniformMap=o,this._renderElementUniformMap=s,this.recreateResource()}p(h,"laya.d3.shader.Shader3D",t);var e=h.prototype;return e.recreateResource=function(){this._compile(),this.completeCreate(),this.memorySize=0},e.disposeResource=function(){N.mainContext.deleteShader(this._vshader),N.mainContext.deleteShader(this._pshader),N.mainContext.deleteProgram(this._program),this._vshader=this._pshader=this._program=null,this._attributeParams=null,this._uniformParams=null,this.memorySize=0,this._curActTexIndex=0},e._compile=function(){if(this._vs&&this._ps&&!this._attributeParams&&!this._uniformParams){this._reCompile=!0,this._attributeParams=[],this._uniformParams=[];var e=[this._vs,this._ps],t=N.mainContext;if(this._program=t.createProgram(),this._vshader=h._createShader(t,e[0],35633),this._pshader=h._createShader(t,e[1],35632),t.attachShader(this._program,this._vshader),t.attachShader(this._program,this._pshader),t.linkProgram(this._program),!m.isConchApp&&$n.debugMode&&!t.getProgramParameter(this._program,35714))throw t.getProgramInfoLog(this._program);for(var n=0,i=0,r=0,r=m.isConchApp?t.getProgramParameterEx(this._vs,this._ps,"",35721):t.getProgramParameter(this._program,35721),n=0;n<r;n++){var a=null,o={vartype:"attribute",ivartype:0,attrib:a=m.isConchApp?t.getActiveAttribEx(this._vs,this._ps,"",n):t.getActiveAttrib(this._program,n),location:t.getAttribLocation(this._program,a.name),name:a.name,type:a.type,isArray:!1,isSame:!1,preValue:null,indexOfParams:0};this._attributeParams.push(o)}var s=0,s=m.isConchApp?t.getProgramParameterEx(this._vs,this._ps,"",35718):t.getProgramParameter(this._program,35718);for(n=0;n<s;n++){var l=null,l=m.isConchApp?t.getActiveUniformEx(this._vs,this._ps,"",n):t.getActiveUniform(this._program,n);0<(o={vartype:"uniform",ivartype:1,attrib:a,location:t.getUniformLocation(this._program,l.name),name:l.name,type:l.type,isArray:!1,isSame:!1,preValue:null,indexOfParams:0}).name.indexOf("[0]")&&(o.name=o.name.substr(0,o.name.length-3),o.isArray=!0,o.location=t.getUniformLocation(this._program,o.name)),this._uniformParams.push(o)}for(n=0,i=this._attributeParams.length;n<i;n++)(o=this._attributeParams[n]).indexOfParams=n,o.index=1,o.value=[o.location,null],o.codename=o.name,o.name=null!=this._attributeMap[o.codename]?this._attributeMap[o.codename]:o.codename,this._attributeParamsMap.push(o.name),this._attributeParamsMap.push(o),o._this=this,o.uploadedValue=[],o.fun=this._attribute;for(n=0,i=this._uniformParams.length;n<i;n++)switch((o=this._uniformParams[n]).indexOfParams=n,o.index=1,o.value=[o.location,null],o.codename=o.name,null!=this._sceneUniformMap[o.codename]?(o.name=this._sceneUniformMap[o.codename],this._sceneUniformParamsMap.push(o.name),this._sceneUniformParamsMap.push(o)):null!=this._cameraUniformMap[o.codename]?(o.name=this._cameraUniformMap[o.codename],this._cameraUniformParamsMap.push(o.name),this._cameraUniformParamsMap.push(o)):null!=this._spriteUniformMap[o.codename]?(o.name=this._spriteUniformMap[o.codename],this._spriteUniformParamsMap.push(o.name),this._spriteUniformParamsMap.push(o)):null!=this._materialUniformMap[o.codename]?(o.name=this._materialUniformMap[o.codename],this._materialUniformParamsMap.push(o.name),this._materialUniformParamsMap.push(o)):null!=this._renderElementUniformMap[o.codename]?(o.name=this._renderElementUniformMap[o.codename],this._renderElementUniformParamsMap.push(o.name),this._renderElementUniformParamsMap.push(o)):console.log("Shader:can't find uinform name:"+o.codename+" in shader file."),o._this=this,o.uploadedValue=[],o.type){case 5124:o.fun=o.isArray?this._uniform1iv:this._uniform1i;break;case 5126:o.fun=o.isArray?this._uniform1fv:this._uniform1f;break;case 35664:o.fun=o.isArray?this._uniform_vec2v:this._uniform_vec2;break;case 35665:o.fun=o.isArray?this._uniform_vec3v:this._uniform_vec3;break;case 35666:o.fun=o.isArray?this._uniform_vec4v:this._uniform_vec4;break;case 35678:o.fun=this._uniform_sampler2D;break;case 35680:o.fun=this._uniform_samplerCube;break;case 35676:o.fun=this._uniformMatrix4fv;break;case 35670:o.fun=this._uniform1i;break;case 35674:o.fun=this._uinformMatrix2fv;break;case 35675:o.fun=this._uinformMatrix3fv;break;default:throw new Error("compile shader err!")}}},e._attribute=function(e,t){var n=N.mainContext,i=s._enableAtributes,e=e.location;return i[e]||n.enableVertexAttribArray(e),n.vertexAttribPointer(e,t[0],t[1],t[2],t[3],t[4]),i[e]=s._bindVertexBuffer,1},e._uniform1f=function(e,t){var n=e.uploadedValue;return n[0]!==t?(N.mainContext.uniform1f(e.location,n[0]=t),1):0},e._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]?(N.mainContext.uniform1fv(e.location,t),n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],1):0}return N.mainContext.uniform1fv(e.location,t),1},e._uniform_vec2=function(e,t){var n=e.uploadedValue;return n[0]!==t[0]||n[1]!==t[1]?(N.mainContext.uniform2f(e.location,n[0]=t[0],n[1]=t[1]),1):0},e._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]?(N.mainContext.uniform2fv(e.location,t),n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],1):0}return N.mainContext.uniform2fv(e.location,t),1},e._uniform_vec3=function(e,t){var n=e.uploadedValue;return n[0]!==t[0]||n[1]!==t[1]||n[2]!==t[2]?(N.mainContext.uniform3f(e.location,n[0]=t[0],n[1]=t[1],n[2]=t[2]),1):0},e._uniform_vec3v=function(e,t){return N.mainContext.uniform3fv(e.location,t),1},e._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]?(N.mainContext.uniform4f(e.location,n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3]),1):0},e._uniform_vec4v=function(e,t){return N.mainContext.uniform4fv(e.location,t),1},e._uniformMatrix2fv=function(e,t){return N.mainContext.uniformMatrix2fv(e.location,!1,t),1},e._uniformMatrix3fv=function(e,t){return N.mainContext.uniformMatrix3fv(e.location,!1,t),1},e._uniformMatrix4fv=function(e,t){return N.mainContext.uniformMatrix4fv(e.location,!1,t),1},e._uinformMatrix2fv=function(e,t){return N.mainContext.uniformMatrix2fv(e.location,!1,t),1},e._uinformMatrix3fv=function(e,t){return N.mainContext.uniformMatrix3fv(e.location,!1,t),1},e._uniform1i=function(e,t){var n=e.uploadedValue;return n[0]!==t?(N.mainContext.uniform1i(e.location,n[0]=t),1):0},e._uniform1iv=function(e,t){return N.mainContext.uniform1iv(e.location,t),1},e._uniform_ivec2=function(e,t){var n=e.uploadedValue;return n[0]!==t[0]||n[1]!==t[1]?(N.mainContext.uniform2i(e.location,n[0]=t[0],n[1]=t[1]),1):0},e._uniform_ivec2v=function(e,t){return N.mainContext.uniform2iv(e.location,t),1},e._uniform_vec3i=function(e,t){var n=e.uploadedValue;return n[0]!==t[0]||n[1]!==t[1]||n[2]!==t[2]?(N.mainContext.uniform3i(e.location,n[0]=t[0],n[1]=t[1],n[2]=t[2]),1):0},e._uniform_vec3vi=function(e,t){return N.mainContext.uniform3iv(e.location,t),1},e._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]?(N.mainContext.uniform4i(e.location,n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3]),1):0},e._uniform_vec4vi=function(e,t){return N.mainContext.uniform4iv(e.location,t),1},e._uniform_sampler2D=function(e,t){var n=t.source||t.defaulteTexture.source,i=N.mainContext,t=e.uploadedValue;if(null!=t[0])return i.activeTexture(h._TEXTURES[t[0]]),n&&V.bindTexture(i,3553,n),0;if(7<this._curActTexIndex)throw new Error("Shader3D: shader support textures max count is 8,can't large than it.");return t[0]=this._curActTexIndex,i.uniform1i(e.location,this._curActTexIndex),i.activeTexture(h._TEXTURES[this._curActTexIndex]),n&&V.bindTexture(i,3553,n),this._curActTexIndex++,1},e._uniform_samplerCube=function(e,t){var n=t.source||t.defaulteTexture.source,i=N.mainContext,t=e.uploadedValue;if(null!=t[0])return i.activeTexture(h._TEXTURES[t[0]]),n?V.bindTexture(i,34067,n):V.bindTexture(i,34067,ir.grayTexture.source),0;if(7<this._curActTexIndex)throw new Error("Shader3D: shader support textures max count is 8,can't large than it.");return t[0]=this._curActTexIndex,i.uniform1i(e.location,this._curActTexIndex),i.activeTexture(h._TEXTURES[this._curActTexIndex]),n?V.bindTexture(i,34067,n):V.bindTexture(i,34067,ir.grayTexture.source),this._curActTexIndex++,1},e._noSetValue=function(e){console.log("no....:"+e.name)},e.bind=function(){return t.activeShader=this,(t.bindShader=this).activeResource(),V.UseProgram(this._program)},e.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));I.shaderCall+=r},e.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));I.shaderCall+=r},e.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));I.shaderCall+=i},e.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));I.shaderCall+=i},e.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));I.shaderCall+=i},e.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));I.shaderCall+=i},e.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));I.shaderCall+=i},h.create=function(e,t,n,i,r,a,o,s){return new h(e,t,n,i,r,a,o,s)},h.addInclude=function(e,t){R.addInclude(e,t)},h._createShader=function(e,t,n){n=e.createShader(n);if(e.shaderSource(n,t),e.compileShader(n),$n.debugMode&&!e.getShaderParameter(n,35713))throw e.getShaderInfoLog(n);return n},h.PERIOD_RENDERELEMENT=0,h.PERIOD_MATERIAL=1,h.PERIOD_SPRITE=2,h.PERIOD_CAMERA=3,h.PERIOD_SCENE=4,h._TEXTURES=[33984,33985,33986,33987,33988,33989,33990,33991],h._count=0,l(h,["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 A}]),h}(),Li=function(i){function t(){if(this._transformUV=null,t.__super.call(this),!laya.d3.core.material.PBRMaterial.pbrlutTex){var e=x.window.__pbrlutdata;if(!e)throw alert("no pbr lutdata, need pbrlut.js"),"no pbr lutdata, need pbrlut.js";e=$i.create(new Uint32Array(e).buffer,256,256,9728,9728,!1);laya.d3.core.material.PBRMaterial.pbrlutTex=e}this._setTexture(4,laya.d3.core.material.PBRMaterial.pbrlutTex),this.setShaderName("PBR"),this._setNumber(0,.5),this.use_groundtruth=!1}p(t,"laya.d3.core.material.PBRMaterial",i);var e=t.prototype;return e.disableLight=function(){this._addDisablePublicShaderDefine($n.SHADERDEFINE_POINTLIGHT|$n.SHADERDEFINE_SPOTLIGHT|$n.SHADERDEFINE_DIRECTIONLIGHT)},e.disableFog=function(){this._addDisablePublicShaderDefine($n.SHADERDEFINE_FOG)},e.onAsynLoaded=function(e,t,n){i.prototype.onAsynLoaded.call(this,e,t,n)},e.radicalInverse_VdC=function(e){var t=new Uint32Array(1);return e=e,t[0]=(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,2.3283064365386963e-10*t[0]},e.createHammersleyTex=function(e,t){for(var n=new Uint8Array(e*t*4),i=0,r=0,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},_(0,e,"normalTexture",function(){return this._getTexture(2)},function(e){this._setTexture(2,e)}),_(0,e,"has_tangent",null,function(e){this._addShaderDefine(t.SHADERDEFINE_HAS_TANGENT)}),_(0,e,"roughness",function(){return this._getNumber(6)},function(e){this._setNumber(6,e),this._addShaderDefine(t.SHADERDEFINE_FIX_ROUGHNESS)}),_(0,e,"metaless",function(){return this._getNumber(7)},function(e){this._setNumber(7,e),this._addShaderDefine(t.SHADERDEFINE_FIX_METALESS)}),_(0,e,"pbrlutTexture",function(){return this._getTexture(4)},function(e){this._setTexture(4,e)}),_(0,e,"use_groundtruth",null,function(e){e?(this._addShaderDefine(t.SHADERDEFINE_USE_GROUNDTRUTH),laya.d3.core.material.PBRMaterial.HammersleyNoiseTex||(e=this.createHammersleyTex(32,32),laya.d3.core.material.PBRMaterial.HammersleyNoiseTex=$i.create(e.buffer,32,32,9728,9728,!1)),this._setTexture(15,t.HammersleyNoiseTex)):(laya.d3.core.material.PBRMaterial.HammersleyNoiseTex=null,this._removeShaderDefine(t.SHADERDEFINE_USE_GROUNDTRUTH))}),_(0,e,"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)}),_(0,e,"diffuseTexture",function(){return this._getTexture(1)},function(e){this._setTexture(1,e)}),_(0,e,"renderMode",null,function(e){switch(e){case 1:this.renderQueue=2e3,this.depthWrite=!0,this.cull=2,this.blend=0,this.alphaTest=!1;break;case 2:this.renderQueue=2e3,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=2e3;break;case 13:this.renderQueue=3e3,this.depthWrite=!0,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=771;break;default:throw new Error("PBRMaterial:renderMode value error.")}}),_(0,e,"pbrInfoTexture",function(){return this._getTexture(3)},function(e){this._setTexture(3,e),this._addShaderDefine(t.SHADERDEFINE_HAS_PBRINFO)}),_(0,e,"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 S.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,l(t,["defaultMaterial",function(){return this.defaultMaterial=new t},"shaderDefines",function(){return this.shaderDefines=new fn(ri.shaderDefines)}]),t}(ri),wi=function(){function e(){e.__super.call(this),this.setShaderName("PBRSpecular"),this._setColor(7,new _n(1,1,1,1)),this._setColor(9,new _n(0,0,0,0)),this._setColor(8,new _n(.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)}p(e,"laya.d3.core.material.PBRSpecularMaterial",ri);var t=e.prototype;return _(0,t,"albedoColor",function(){return this._getColor(7)},function(e){this._setColor(7,e)}),_(0,t,"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)}),_(0,t,"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)}),_(0,t,"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)}),_(0,t,"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)}),_(0,t,"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)}),_(0,t,"emissionColor",function(){return this._getColor(9)},function(e){this._setColor(9,e)}),_(0,t,"normalTextureScale",function(){return this._getNumber(14)},function(e){this._setNumber(14,e)}),_(0,t,"parallaxTextureScale",function(){return this._getNumber(15)},function(e){e=Math.max(.005,Math.min(.08,e)),this._setNumber(15,e)}),_(0,t,"occlusionTextureStrength",function(){return this._getNumber(13)},function(e){e=Math.max(0,Math.min(1,e)),this._setNumber(13,e)}),_(0,t,"specularColor",function(){return this._getColor(8)},function(e){this._setColor(8,e)}),_(0,t,"smoothness",function(){return this._getNumber(10)},function(e){e=Math.max(0,Math.min(1,e)),this._setNumber(10,e)}),_(0,t,"smoothnessTextureScale",function(){return this._getNumber(11)},function(e){e=Math.max(0,Math.min(1,e)),this._setNumber(11,e)}),_(0,t,"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)}),_(0,t,"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)}),_(0,t,"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)}),_(0,t,"tilingOffset",function(){return this._getColor(17)},function(e){var t;e&&(1!=(t=e.elements)[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),this._setColor(17,e)}),e.__init__=function(){e.SHADERDEFINE_DIFFUSETEXTURE=e.shaderDefines.registerDefine("DIFFUSETEXTURE"),e.SHADERDEFINE_SPECULARTEXTURE=e.shaderDefines.registerDefine("SPECULARTEXTURE"),e.SHADERDEFINE_SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA=e.shaderDefines.registerDefine("SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA"),e.SHADERDEFINE_NORMALTEXTURE=e.shaderDefines.registerDefine("NORMALTEXTURE"),e.SHADERDEFINE_PARALLAXTEXTURE=e.shaderDefines.registerDefine("PARALLAXTEXTURE"),e.SHADERDEFINE_OCCLUSIONTEXTURE=e.shaderDefines.registerDefine("OCCLUSIONTEXTURE"),e.SHADERDEFINE_EMISSION=e.shaderDefines.registerDefine("EMISSION"),e.SHADERDEFINE_EMISSIONTEXTURE=e.shaderDefines.registerDefine("EMISSIONTEXTURE"),e.SHADERDEFINE_TILINGOFFSET=e.shaderDefines.registerDefine("TILINGOFFSET")},e.SmoothnessSource_MetallicGlossTexture_Alpha=0,e.SmoothnessSource_DiffuseTexture_Alpha=1,e.SHADERDEFINE_DIFFUSETEXTURE=0,e.SHADERDEFINE_NORMALTEXTURE=0,e.SHADERDEFINE_SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA=0,e.SHADERDEFINE_SPECULARTEXTURE=0,e.SHADERDEFINE_OCCLUSIONTEXTURE=0,e.SHADERDEFINE_PARALLAXTEXTURE=0,e.SHADERDEFINE_EMISSION=0,e.SHADERDEFINE_EMISSIONTEXTURE=0,e.SHADERDEFINE_TILINGOFFSET=0,e.DIFFUSETEXTURE=1,e.SPECULARTEXTURE=2,e.NORMALTEXTURE=3,e.PARALLAXTEXTURE=4,e.OCCLUSIONTEXTURE=5,e.EMISSIONTEXTURE=6,e.DIFFUSECOLOR=7,e.SPECULARCOLOR=8,e.EMISSIONCOLOR=9,e.SMOOTHNESS=10,e.SMOOTHNESSSCALE=11,e.SMOOTHNESSSOURCE=12,e.OCCLUSIONSTRENGTH=13,e.NORMALSCALE=14,e.PARALLAXSCALE=15,e.ENABLEEMISSION=16,e.TILINGOFFSET=17,l(e,["shaderDefines",function(){return this.shaderDefines=new fn(ri.shaderDefines)}]),e}(),Fi=function(){function e(){e.__super.call(this),this.setShaderName("PBRStandard"),this._setColor(7,new _n(1,1,1,1)),this._setColor(8,new _n(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)}p(e,"laya.d3.core.material.PBRStandardMaterial",ri);var t=e.prototype;return _(0,t,"albedoColor",function(){return this._getColor(7)},function(e){this._setColor(7,e)}),_(0,t,"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)}),_(0,t,"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)}),_(0,t,"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)}),_(0,t,"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)}),_(0,t,"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)}),_(0,t,"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)}),_(0,t,"emissionColor",function(){return this._getColor(8)},function(e){this._setColor(8,e)}),_(0,t,"normalTextureScale",function(){return this._getNumber(14)},function(e){this._setNumber(14,e)}),_(0,t,"parallaxTextureScale",function(){return this._getNumber(15)},function(e){e=Math.max(.005,Math.min(.08,e)),this._setNumber(15,e)}),_(0,t,"occlusionTextureStrength",function(){return this._getNumber(13)},function(e){e=Math.max(0,Math.min(1,e)),this._setNumber(13,e)}),_(0,t,"metallic",function(){return this._getNumber(9)},function(e){e=Math.max(0,Math.min(1,e)),this._setNumber(9,e)}),_(0,t,"smoothness",function(){return this._getNumber(10)},function(e){e=Math.max(0,Math.min(1,e)),this._setNumber(10,e)}),_(0,t,"smoothnessTextureScale",function(){return this._getNumber(11)},function(e){e=Math.max(0,Math.min(1,e)),this._setNumber(11,e)}),_(0,t,"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)}),_(0,t,"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)}),_(0,t,"tilingOffset",function(){return this._getColor(17)},function(e){var t;e&&(1!=(t=e.elements)[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),this._setColor(17,e)}),e.__init__=function(){e.SHADERDEFINE_DIFFUSETEXTURE=e.shaderDefines.registerDefine("DIFFUSETEXTURE"),e.SHADERDEFINE_METALLICGLOSSTEXTURE=e.shaderDefines.registerDefine("METALLICGLOSSTEXTURE"),e.SHADERDEFINE_SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA=e.shaderDefines.registerDefine("SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA"),e.SHADERDEFINE_NORMALTEXTURE=e.shaderDefines.registerDefine("NORMALTEXTURE"),e.SHADERDEFINE_PARALLAXTEXTURE=e.shaderDefines.registerDefine("PARALLAXTEXTURE"),e.SHADERDEFINE_OCCLUSIONTEXTURE=e.shaderDefines.registerDefine("OCCLUSIONTEXTURE"),e.SHADERDEFINE_EMISSION=e.shaderDefines.registerDefine("EMISSION"),e.SHADERDEFINE_EMISSIONTEXTURE=e.shaderDefines.registerDefine("EMISSIONTEXTURE"),e.SHADERDEFINE_TILINGOFFSET=e.shaderDefines.registerDefine("TILINGOFFSET")},e.SmoothnessSource_MetallicGlossTexture_Alpha=0,e.SmoothnessSource_DiffuseTexture_Alpha=1,e.SHADERDEFINE_DIFFUSETEXTURE=0,e.SHADERDEFINE_NORMALTEXTURE=0,e.SHADERDEFINE_SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA=0,e.SHADERDEFINE_METALLICGLOSSTEXTURE=0,e.SHADERDEFINE_OCCLUSIONTEXTURE=0,e.SHADERDEFINE_PARALLAXTEXTURE=0,e.SHADERDEFINE_EMISSION=0,e.SHADERDEFINE_EMISSIONTEXTURE=0,e.SHADERDEFINE_TILINGOFFSET=0,e.DIFFUSETEXTURE=1,e.METALLICGLOSSTEXTURE=2,e.NORMALTEXTURE=3,e.PARALLAXTEXTURE=4,e.OCCLUSIONTEXTURE=5,e.EMISSIONTEXTURE=6,e.DIFFUSECOLOR=7,e.EMISSIONCOLOR=8,e.METALLIC=9,e.SMOOTHNESS=10,e.SMOOTHNESSSCALE=11,e.SMOOTHNESSSOURCE=12,e.OCCLUSIONSTRENGTH=13,e.NORMALSCALE=14,e.PARALLAXSCALE=15,e.ENABLEEMISSION=16,e.TILINGOFFSET=17,l(e,["shaderDefines",function(){return this.shaderDefines=new fn(ri.shaderDefines)}]),e}(),Pi=function(o){function s(){this._transformUV=null,s.__super.call(this),this.setShaderName("SIMPLE"),this._setColor(9,new hn(.6,.6,.6)),this._setColor(10,new hn(1,1,1)),this._setColor(11,new _n(1,1,1,8)),this._setColor(12,new hn(1,1,1)),this._setColor(7,new _n(1,1,1,1)),this._setNumber(0,.5),this._setColor(15,new _n(1,1,0,0)),this.renderMode=1}p(s,"laya.d3.core.material.StandardMaterial",o);var e=s.prototype;return e.disableLight=function(){this._addDisablePublicShaderDefine($n.SHADERDEFINE_POINTLIGHT|$n.SHADERDEFINE_SPOTLIGHT|$n.SHADERDEFINE_DIRECTIONLIGHT)},e.disableFog=function(){this._addDisablePublicShaderDefine($n.SHADERDEFINE_FOG)},e.onAsynLoaded=function(e,t,n){var i=t[0];if(i.version)o.prototype.onAsynLoaded.call(this,e,t,n);else{var r,t=t[1],a=i.props;for(r in a)this[r]=a[r];s._parseStandardMaterial(t,this,i),this._endLoaded()}},e.cloneTo=function(e){o.prototype.cloneTo.call(this,e);this._transformUV&&(e._transformUV=this._transformUV.clone())},_(0,e,"ambientColor",function(){return this._getColor(9)},function(e){this._setColor(9,e)}),_(0,e,"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)}),_(0,e,"renderMode",null,function(e){switch(e){case 1:this.renderQueue=2e3,this.depthWrite=!0,this.cull=2,this.blend=0,this.alphaTest=!1,this._removeShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;case 2:this.renderQueue=2e3,this.depthWrite=!0,this.cull=0,this.blend=0,this.alphaTest=!1,this._removeShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;case 3:this.depthWrite=!0,this.cull=2,this.blend=0,this.renderQueue=2e3,this.alphaTest=!0,this._removeShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;case 4:this.renderQueue=2e3,this.depthWrite=!0,this.cull=0,this.blend=0,this.alphaTest=!0,this._removeShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;case 13:this.renderQueue=3e3,this.depthWrite=!0,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=771,this.alphaTest=!1,this._removeShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;case 14:this.renderQueue=3e3,this.depthWrite=!0,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=771,this.alphaTest=!1,this._removeShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;case 15:this.renderQueue=3e3,this.depthWrite=!0,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=1,this.alphaTest=!1,this._addShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;case 16:this.renderQueue=3e3,this.depthWrite=!0,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=1,this.alphaTest=!1,this._addShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;case 5:this.renderQueue=3e3,this.depthWrite=!1,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=771,this.alphaTest=!1,this._removeShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;case 6:this.renderQueue=3e3,this.depthWrite=!1,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=771,this.alphaTest=!1,this._removeShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;case 7:this.renderQueue=3e3,this.depthWrite=!1,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=1,this.alphaTest=!1,this._addShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;case 8:this.renderQueue=3e3,this.depthWrite=!1,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=1,this.alphaTest=!1,this._addShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;case 9:this.renderQueue=3e3,this.depthTest=513,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=771,this.alphaTest=!1,this._removeShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;case 10:this.renderQueue=3e3,this.depthTest=513,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=771,this.alphaTest=!1,this._removeShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;case 11:this.renderQueue=3e3,this.depthTest=513,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=1,this.alphaTest=!1,this._addShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;case 12:this.renderQueue=3e3,this.depthTest=513,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=1,this.alphaTest=!1,this._addShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;default:throw new Error("Material:renderMode value error.")}this._conchMaterial&&this._conchMaterial.setRenderMode(e)}),_(0,e,"reflectColor",function(){return this._getColor(12)},function(e){this._setColor(12,e)}),_(0,e,"tilingOffset",function(){return this._getColor(15)},function(e){var t;e&&(1!=(t=e.elements)[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),this._setColor(15,e)}),_(0,e,"albedo",function(){return this._getColor(7)},function(e){this._setColor(7,e)}),_(0,e,"diffuseColor",function(){return this._getColor(10)},function(e){this._setColor(10,e)}),_(0,e,"albedoColor",function(){return this._getColor(7)},function(e){this._setColor(7,e)}),_(0,e,"specularColor",function(){return this._getColor(11)},function(e){this._setColor(11,e)}),_(0,e,"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)}),_(0,e,"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)}),_(0,e,"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)}),_(0,e,"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)}),_(0,e,"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)}),_(0,e,"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)}),s.__init__=function(){s.SHADERDEFINE_DIFFUSEMAP=s.shaderDefines.registerDefine("DIFFUSEMAP"),s.SHADERDEFINE_NORMALMAP=s.shaderDefines.registerDefine("NORMALMAP"),s.SHADERDEFINE_SPECULARMAP=s.shaderDefines.registerDefine("SPECULARMAP"),s.SHADERDEFINE_EMISSIVEMAP=s.shaderDefines.registerDefine("EMISSIVEMAP"),s.SHADERDEFINE_AMBIENTMAP=s.shaderDefines.registerDefine("AMBIENTMAP"),s.SHADERDEFINE_REFLECTMAP=s.shaderDefines.registerDefine("REFLECTMAP"),s.SHADERDEFINE_UVTRANSFORM=s.shaderDefines.registerDefine("UVTRANSFORM"),s.SHADERDEFINE_TILINGOFFSET=s.shaderDefines.registerDefine("TILINGOFFSET"),s.SHADERDEFINE_ADDTIVEFOG=s.shaderDefines.registerDefine("ADDTIVEFOG")},s.load=function(e){return S.loader.create(e,null,null,s)},s._parseStandardMaterial=function(e,t,n){var i=n.customProps,n=i.ambientColor;t.ambientColor=new hn(n[0],n[1],n[2]);n=i.diffuseColor;t.diffuseColor=new hn(n[0],n[1],n[2]);n=i.specularColor;t.specularColor=new _n(n[0],n[1],n[2],n[3]);n=i.reflectColor;t.reflectColor=new hn(n[0],n[1],n[2]);n=i.albedoColor;n&&(t.albedo=new _n(n[0],n[1],n[2],n[3]));n=i.diffuseTexture.texture2D;n&&(t.diffuseTexture=W.getRes(e[n]));n=i.normalTexture.texture2D;n&&(t.normalTexture=W.getRes(e[n]));n=i.specularTexture.texture2D;n&&(t.specularTexture=W.getRes(e[n]));n=i.emissiveTexture.texture2D;n&&(t.emissiveTexture=W.getRes(e[n]));n=i.ambientTexture.texture2D;n&&(t.ambientTexture=W.getRes(e[n]));i=i.reflectTexture.texture2D;i&&(t.reflectTexture=W.getRes(e[i]))},s.RENDERMODE_OPAQUE=1,s.RENDERMODE_OPAQUEDOUBLEFACE=2,s.RENDERMODE_CUTOUT=3,s.RENDERMODE_CUTOUTDOUBLEFACE=4,s.RENDERMODE_TRANSPARENT=13,s.RENDERMODE_TRANSPARENTDOUBLEFACE=14,s.RENDERMODE_ADDTIVE=15,s.RENDERMODE_ADDTIVEDOUBLEFACE=16,s.RENDERMODE_DEPTHREAD_TRANSPARENT=5,s.RENDERMODE_DEPTHREAD_TRANSPARENTDOUBLEFACE=6,s.RENDERMODE_DEPTHREAD_ADDTIVE=7,s.RENDERMODE_DEPTHREAD_ADDTIVEDOUBLEFACE=8,s.RENDERMODE_NONDEPTH_TRANSPARENT=9,s.RENDERMODE_NONDEPTH_TRANSPARENTDOUBLEFACE=10,s.RENDERMODE_NONDEPTH_ADDTIVE=11,s.RENDERMODE_NONDEPTH_ADDTIVEDOUBLEFACE=12,s.SHADERDEFINE_DIFFUSEMAP=0,s.SHADERDEFINE_NORMALMAP=0,s.SHADERDEFINE_SPECULARMAP=0,s.SHADERDEFINE_EMISSIVEMAP=0,s.SHADERDEFINE_AMBIENTMAP=0,s.SHADERDEFINE_REFLECTMAP=0,s.SHADERDEFINE_UVTRANSFORM=0,s.SHADERDEFINE_TILINGOFFSET=0,s.SHADERDEFINE_ADDTIVEFOG=0,s.DIFFUSETEXTURE=1,s.NORMALTEXTURE=2,s.SPECULARTEXTURE=3,s.EMISSIVETEXTURE=4,s.AMBIENTTEXTURE=5,s.REFLECTTEXTURE=6,s.ALBEDO=7,s.UVANIAGE=8,s.MATERIALAMBIENT=9,s.MATERIALDIFFUSE=10,s.MATERIALSPECULAR=11,s.MATERIALREFLECT=12,s.UVMATRIX=13,s.UVAGE=14,s.TILINGOFFSET=15,l(s,["defaultMaterial",function(){return this.defaultMaterial=new s},"shaderDefines",function(){return this.shaderDefines=new fn(ri.shaderDefines)}]),s}(ri),bi=function(t){function n(){this._diffuseScale1=null,this._diffuseScale2=null,this._diffuseScale3=null,this._diffuseScale4=null,n.__super.call(this),this.setShaderName("Terrain"),this.renderMode=1,this._diffuseScale1=new ln,this._diffuseScale2=new ln,this._diffuseScale3=new ln,this._diffuseScale4=new ln,this.ambientColor=new hn(.6,.6,.6),this.diffuseColor=new hn(1,1,1),this.specularColor=new _n(.2,.2,.2,32)}p(n,"laya.d3.core.material.TerrainMaterial",t);var e=n.prototype;return e.setDiffuseScale1=function(e,t){this._diffuseScale1.x=e,this._diffuseScale1.y=t,this._setColor(6,this._diffuseScale1)},e.setDiffuseScale2=function(e,t){this._diffuseScale2.x=e,this._diffuseScale2.y=t,this._setColor(7,this._diffuseScale2)},e.setDiffuseScale3=function(e,t){this._diffuseScale3.x=e,this._diffuseScale3.y=t,this._setColor(8,this._diffuseScale3)},e.setDiffuseScale4=function(e,t){this._diffuseScale4.x=e,this._diffuseScale4.y=t,this._setColor(9,this._diffuseScale4)},e.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)}},e.disableLight=function(){this._addDisablePublicShaderDefine($n.SHADERDEFINE_POINTLIGHT|$n.SHADERDEFINE_SPOTLIGHT|$n.SHADERDEFINE_DIRECTIONLIGHT)},e.setShaderName=function(e){t.prototype.setShaderName.call(this,e)},_(0,e,"renderMode",null,function(e){switch(e){case 1:this.renderQueue=2e3,this.depthWrite=!0,this.cull=2,this.blend=0,this.depthTest=513;break;case 2:this.renderQueue=2e3,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)}),_(0,e,"diffuseTexture2",function(){return this._getTexture(3)},function(e){this._setTexture(3,e)}),_(0,e,"ambientColor",function(){return this._getColor(10)},function(e){this._setColor(10,e)}),_(0,e,"diffuseTexture4",function(){return this._getTexture(5)},function(e){this._setTexture(5,e)}),_(0,e,"diffuseColor",function(){return this._getColor(11)},function(e){this._setColor(11,e)}),_(0,e,"diffuseTexture1",function(){return this._getTexture(2)},function(e){this._setTexture(2,e)}),_(0,e,"specularColor",function(){return this._getColor(12)},function(e){this._setColor(12,e)}),_(0,e,"diffuseTexture3",function(){return this._getTexture(4)},function(e){this._setTexture(4,e)}),_(0,e,"splatAlphaTexture",function(){return this._getTexture(0)},function(e){this._setTexture(0,e)}),_(0,e,"normalTexture",function(){return this._getTexture(1)},function(e){this._setTexture(1,e)}),n.__init__=function(){n.SHADERDEFINE_DETAIL_NUM1=n.shaderDefines.registerDefine("DETAIL_NUM1"),n.SHADERDEFINE_DETAIL_NUM2=n.shaderDefines.registerDefine("DETAIL_NUM2"),n.SHADERDEFINE_DETAIL_NUM4=n.shaderDefines.registerDefine("DETAIL_NUM4"),n.SHADERDEFINE_DETAIL_NUM3=n.shaderDefines.registerDefine("DETAIL_NUM3")},n.load=function(e){return S.loader.create(e,null,null,n)},n.RENDERMODE_OPAQUE=1,n.RENDERMODE_TRANSPARENT=2,n.SPLATALPHATEXTURE=0,n.NORMALTEXTURE=1,n.DIFFUSETEXTURE1=2,n.DIFFUSETEXTURE2=3,n.DIFFUSETEXTURE3=4,n.DIFFUSETEXTURE4=5,n.DIFFUSESCALE1=6,n.DIFFUSESCALE2=7,n.DIFFUSESCALE3=8,n.DIFFUSESCALE4=9,n.MATERIALAMBIENT=10,n.MATERIALDIFFUSE=11,n.MATERIALSPECULAR=12,n.SHADERDEFINE_DETAIL_NUM1=0,n.SHADERDEFINE_DETAIL_NUM2=0,n.SHADERDEFINE_DETAIL_NUM3=0,n.SHADERDEFINE_DETAIL_NUM4=0,l(n,["defaultMaterial",function(){return this.defaultMaterial=new n},"shaderDefines",function(){return this.shaderDefines=new fn(ri.shaderDefines)}]),n}(ri),Bi=function(i){function t(){this._useVertexDeep=!1,t.__super.call(this),this.setShaderName("Water")}p(t,"laya.d3.core.material.WaterMaterial",i);var e=t.prototype;return e.disableFog=function(){this._addDisablePublicShaderDefine($n.SHADERDEFINE_FOG)},e.onAsynLoaded=function(e,t,n){i.prototype.onAsynLoaded.call(this,e,t,n)},_(0,e,"diffuseTexture",function(){return this._getTexture(1)},function(e){this._setTexture(1,e)}),_(0,e,"normalTexture",function(){return this._getTexture(2)},function(e){this._setTexture(2,e)}),_(0,e,"underWaterTexture",function(){return this._getTexture(3)},function(e){this._setTexture(3,e)}),_(0,e,"deepColorTexture",function(){return this._getTexture(10)},function(e){this._setTexture(10,e)}),_(0,e,"useFoam",null,function(e){e?this._addShaderDefine(t.SHADERDEFINE_USE_FOAM):this._removeShaderDefine(t.SHADERDEFINE_USE_FOAM)}),_(0,e,"skyTexture",function(){return this._getTexture(11)},function(e){this._setTexture(11,e)}),_(0,e,"deepScale",function(){return this._getNumber(20)},function(e){this._setNumber(20,e)}),_(0,e,"detailTexture",function(){return this._getTexture(9)},function(e){this._setTexture(9,e)}),_(0,e,"foamTexture",function(){return this._getTexture(17)},function(e){this._setTexture(17,e)}),_(0,e,"waterInfoTexture",function(){return this._getTexture(16)},function(e){this._setTexture(16,e)}),_(0,e,"vertexDispTexture",function(){return this._getTexture(4)},function(e){this._setTexture(4,e)}),_(0,e,"currentTm",function(){return this._getNumber(8)},function(e){this._setNumber(8,e)}),_(0,e,"waveInfo",function(){return this._getBuffer(12)},function(e){this._setBuffer(12,e)}),_(0,e,"waveInfoD",function(){return this._getBuffer(13)},function(e){this._setBuffer(13,e)}),_(0,e,"waveMainDir",function(){return this._getNumber(14)},function(e){this._setNumber(14,e*Math.PI/180)}),_(0,e,"geoWaveUVScale",function(){return this._getNumber(18)},function(e){this._setNumber(18,e)}),_(0,e,"windSpeed",function(){return 0},function(e){}),_(0,e,"scrsize",null,function(e){this._setBuffer(15,e)}),_(0,e,"seaColor",function(){return this._getBuffer(19)},function(e){this._setBuffer(19,e)}),_(0,e,"useVertexDeep",function(){return this._useVertexDeep},function(e){(this._useVertexDeep=e)?this._addShaderDefine(t.SHADERDEFINE_USEVERTEXHEIGHT):this._removeShaderDefine(t.SHADERDEFINE_USEVERTEXHEIGHT)}),_(0,e,"windDir",function(){return 0},function(e){}),_(0,e,"useRefractTexture",null,function(e){e?this._addShaderDefine(t.SHADERDEFINE_USE_REFRACT_TEX):this._removeShaderDefine(t.SHADERDEFINE_USE_REFRACT_TEX)}),_(0,e,"renderMode",null,function(e){switch(e){case 1:this.renderQueue=2e3,this.depthWrite=!0,this.cull=2,this.blend=0,this.alphaTest=!1;break;case 2:this.renderQueue=2e3,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=2e3;break;case 13:this.renderQueue=3e3,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 S.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,l(t,["defaultMaterial",function(){return this.defaultMaterial=new t},"shaderDefines",function(){return this.shaderDefines=new fn(ri.shaderDefines)}]),t}(ri),Ui=function(e){function r(e,t,n,i){this._indexType=null,this._indexTypeByteCount=0,this._indexCount=0,this._canRead=!1,void 0===n&&(n=35044),void 0===i&&(i=!1),r.__super.call(this),this._indexType=e,this._indexCount=t,this._bufferUsage=n,this._bufferType=34963,this._canRead=i;n=0;if("ushort"==e)this._indexTypeByteCount=2;else{if("ubyte"!=e)throw new Error("unidentification index type.");this._indexTypeByteCount=1}n=this._indexTypeByteCount*t,this._byteLength=n,this._bind(),s._gl.bufferData(this._bufferType,n,this._bufferUsage),i?("ushort"==e?this._buffer=new Uint16Array(t):"ubyte"==e&&(this._buffer=new Uint8Array(t)),this.memorySize=2*n):this.memorySize=n}p(r,"laya.d3.graphics.IndexBuffer3D",e);var t=r.prototype;return t.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(),s._gl.bufferSubData(this._bufferType,t*r,e),this._canRead)if(0!==t||0!==n||4294967295!==i){n=this._buffer.length-t;n<i&&(i=n);for(var a=0;a<i;a++)this._buffer[t+a]=e[a]}else this._buffer=e},t.getData=function(){if(this._canRead)return this._buffer;throw new Error("Can't read data from VertexBuffer with only write flag!")},t.disposeResource=function(){e.prototype.disposeResource.call(this),this._buffer=null,this.memorySize=0},_(0,t,"indexType",function(){return this._indexType}),_(0,t,"indexTypeByteCount",function(){return this._indexTypeByteCount}),_(0,t,"indexCount",function(){return this._indexCount}),_(0,t,"canRead",function(){return this._canRead}),r.INDEXTYPE_UBYTE="ubyte",r.INDEXTYPE_USHORT="ushort",r.create=function(e,t,n,i){return new r(e,t,n=void 0===n?35044:n,i=void 0===i?!1:i)},r}(s),Hi=function(o){function s(){s.__super.call(this),this.setShaderName("PARTICLESHURIKEN"),this.renderMode=6}p(s,"laya.d3.core.particleShuriKen.ShurikenParticleMaterial",o);var e=s.prototype;return e.onAsynLoaded=function(e,t,n){var i=t[0];if(i.version)o.prototype.onAsynLoaded.call(this,e,t,n);else{var r,t=t[1],a=i.props;for(r in a)this[r]=a[r];s._parseShurikenParticleMaterial(t,this,i),this._endLoaded()}},_(0,e,"renderMode",null,function(e){switch(e){case 1:this.renderQueue=2e3,this.depthWrite=!0,this.cull=2,this.blend=0,this.alphaTest=!1,this._removeShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;case 2:this.renderQueue=2e3,this.depthWrite=!0,this.cull=0,this.blend=0,this.alphaTest=!1,this._removeShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;case 3:this.depthWrite=!0,this.cull=2,this.blend=0,this.renderQueue=2e3,this.alphaTest=!0,this._removeShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;case 4:this.renderQueue=2e3,this.depthWrite=!0,this.cull=0,this.blend=0,this.alphaTest=!0,this._removeShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;case 13:this.renderQueue=3e3,this.depthWrite=!0,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=771,this.alphaTest=!1,this._removeShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;case 14:this.renderQueue=3e3,this.depthWrite=!0,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=771,this.alphaTest=!1,this._removeShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;case 15:this.renderQueue=3e3,this.depthWrite=!0,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=1,this.alphaTest=!1,this._addShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;case 16:this.renderQueue=3e3,this.depthWrite=!0,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=1,this.alphaTest=!1,this._addShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;case 5:this.renderQueue=3e3,this.depthWrite=!1,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=771,this.alphaTest=!1,this._removeShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;case 6:this.renderQueue=3e3,this.depthWrite=!1,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=771,this.alphaTest=!1,this._removeShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;case 7:this.renderQueue=3e3,this.depthWrite=!1,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=1,this.alphaTest=!1,this._addShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;case 8:this.renderQueue=3e3,this.depthWrite=!1,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=1,this.alphaTest=!1,this._addShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;case 9:this.renderQueue=3e3,this.depthTest=513,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=771,this.alphaTest=!1,this._removeShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;case 10:this.renderQueue=3e3,this.depthTest=513,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=771,this.alphaTest=!1,this._removeShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;case 11:this.renderQueue=3e3,this.depthTest=513,this.cull=2,this.blend=1,this.srcBlend=770,this.dstBlend=1,this.alphaTest=!1,this._addShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;case 12:this.renderQueue=3e3,this.depthTest=513,this.cull=0,this.blend=1,this.srcBlend=770,this.dstBlend=1,this.alphaTest=!1,this._addShaderDefine(s.SHADERDEFINE_ADDTIVEFOG);break;default:throw new Error("Material:renderMode value error.")}this._conchMaterial&&this._conchMaterial.setRenderMode(e)}),_(0,e,"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)}),_(0,e,"tilingOffset",function(){return this._getColor(3)},function(e){var t;e&&(1!=(t=e.elements)[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),this._setColor(3,e)}),_(0,e,"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)}),s.__init__=function(){s.SHADERDEFINE_DIFFUSEMAP=s.shaderDefines.registerDefine("DIFFUSEMAP"),s.SHADERDEFINE_TINTCOLOR=s.shaderDefines.registerDefine("TINTCOLOR"),s.SHADERDEFINE_ADDTIVEFOG=s.shaderDefines.registerDefine("ADDTIVEFOG"),s.SHADERDEFINE_TILINGOFFSET=s.shaderDefines.registerDefine("TILINGOFFSET")},s.load=function(e){return S.loader.create(e,null,null,s)},s._parseShurikenParticleMaterial=function(e,t,n){var i=n.customProps,n=i.diffuseTexture.texture2D;n&&(t.diffuseTexture=W.getRes(e[n]));i=i.tintColor;i&&(t.tintColor=new _n(i[0],i[1],i[2],i[3]))},s.RENDERMODE_OPAQUE=1,s.RENDERMODE_OPAQUEDOUBLEFACE=2,s.RENDERMODE_CUTOUT=3,s.RENDERMODE_CUTOUTDOUBLEFACE=4,s.RENDERMODE_TRANSPARENT=13,s.RENDERMODE_TRANSPARENTDOUBLEFACE=14,s.RENDERMODE_ADDTIVE=15,s.RENDERMODE_ADDTIVEDOUBLEFACE=16,s.RENDERMODE_DEPTHREAD_TRANSPARENT=5,s.RENDERMODE_DEPTHREAD_TRANSPARENTDOUBLEFACE=6,s.RENDERMODE_DEPTHREAD_ADDTIVE=7,s.RENDERMODE_DEPTHREAD_ADDTIVEDOUBLEFACE=8,s.RENDERMODE_NONDEPTH_TRANSPARENT=9,s.RENDERMODE_NONDEPTH_TRANSPARENTDOUBLEFACE=10,s.RENDERMODE_NONDEPTH_ADDTIVE=11,s.RENDERMODE_NONDEPTH_ADDTIVEDOUBLEFACE=12,s.SHADERDEFINE_DIFFUSEMAP=0,s.SHADERDEFINE_TINTCOLOR=0,s.SHADERDEFINE_TILINGOFFSET=0,s.SHADERDEFINE_ADDTIVEFOG=0,s.DIFFUSETEXTURE=1,s.TINTCOLOR=2,s.TILINGOFFSET=3,l(s,["defaultMaterial",function(){return this.defaultMaterial=new s},"shaderDefines",function(){return this.shaderDefines=new fn(ri.shaderDefines)}]),s}(ri),Gi=function(a){function r(e,t,n,i){this._vertexDeclaration=null,this._vertexCount=0,this._canRead=!1,void 0===i&&(i=!1),r.__super.call(this),this._vertexDeclaration=e,this._vertexCount=t,this._bufferUsage=n,this._bufferType=34962,this._canRead=i,this.memorySize=this._byteLength=this._vertexDeclaration.vertexStride*t,this._bind(),s._gl.bufferData(this._bufferType,this._byteLength,this._bufferUsage),i&&(this._buffer=new Float32Array(this._byteLength/4))}p(r,"laya.d3.graphics.VertexBuffer3D",a);var e=r.prototype;return e.bindWithIndexBuffer=function(e){e&&e._bind(),this._bind()},e.setData=function(e,t,n,i){if(void 0===t&&(t=0),void 0===i&&(i=4294967295),0===(n=void 0===n?0:n)&&4294967295===i||(e=new Float32Array(e.buffer,4*n,i)),this._bind(),s._gl.bufferSubData(this._bufferType,4*t,e),this._canRead)if(0!==t||0!==n||4294967295!==i){n=this._buffer.length-t;n<i&&(i=n);for(var r=0;r<i;r++)this._buffer[t+r]=e[r]}else this._buffer=e},e.getData=function(){if(this._canRead)return this._buffer;throw new Error("Can't read data from VertexBuffer with only write flag!")},e.disposeResource=function(){for(var e=N.mainContext,t=this._vertexDeclaration.getVertexElements(),n=s._enableAtributes,i=0,r=t.length;i<r;i++)n[i]===this._glBuffer&&(e.disableVertexAttribArray(i),n[i]=null);a.prototype.disposeResource.call(this),this._buffer=null,this._vertexDeclaration=null,this.memorySize=0},_(0,e,"vertexDeclaration",function(){return this._vertexDeclaration}),_(0,e,"vertexCount",function(){return this._vertexCount}),_(0,e,"canRead",function(){return this._canRead}),r.create=function(e,t,n,i){return new r(e,t,n=void 0===n?35044:n,i=void 0===i?!1:i)},r}(s),zi=function(){function t(){t.__super.call(this),this.setShaderName("Trail"),this._setColor(2,new _n(1,1,1,1))}p(t,"laya.d3.core.trail.TrailMaterial",ri);var e=t.prototype;return _(0,e,"tintColor",function(){return this._getColor(2)},function(e){this._setColor(2,e)}),_(0,e,"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)}),_(0,e,"tilingOffset",function(){return this._getColor(3)},function(e){var t;e&&(1!=(t=e.elements)[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),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 S.loader.create(e,null,null,t)},t.SHADERDEFINE_DIFFUSETEXTURE=0,t.SHADERDEFINE_TILINGOFFSET=0,t.DIFFUSETEXTURE=1,t.TINTCOLOR=2,t.TILINGOFFSET=3,l(t,["defaultMaterial",function(){return this.defaultMaterial=new t},"shaderDefines",function(){return this.shaderDefines=new fn(ri.shaderDefines)}]),t}(),Wi=(function(){function e(){e.__super.call(this),this.setShaderName("CartoonShader"),this._setColor(5,new _n(.6663285,.6544118,1,1)),this._setNumber(6,0),this._setNumber(7,.7956449),this._setNumber(8,.9820514),this._setNumber(9,1)}p(e,"laya.d3.extension.cartoonRender.CartoonMaterial",ri);var t=e.prototype;_(0,t,"specularTexture",function(){return this._getTexture(2)},function(e){e?this._addShaderDefine(laya.d3.extension.cartoonRender.CartoonMaterial.SHADERDEFINE_SPECULARTEXTURE):this._removeShaderDefine(laya.d3.extension.cartoonRender.CartoonMaterial.SHADERDEFINE_SPECULARTEXTURE),this._setTexture(2,e)}),_(0,t,"albedoTexture",function(){return this._getTexture(1)},function(e){e?this._addShaderDefine(laya.d3.extension.cartoonRender.CartoonMaterial.SHADERDEFINE_ALBEDOTEXTURE):this._removeShaderDefine(laya.d3.extension.cartoonRender.CartoonMaterial.SHADERDEFINE_ALBEDOTEXTURE),this._setTexture(1,e)}),_(0,t,"shadowColor",function(){return this._getColor(5)},function(e){this._setColor(5,e)}),_(0,t,"shadowIntensity",function(){return this._getNumber(7)},function(e){e=Math.max(0,Math.min(1,e)),this._setNumber(7,e)}),_(0,t,"shadowRange",function(){return this._getNumber(6)},function(e){e=Math.max(0,Math.min(1,e)),this._setNumber(6,e)}),_(0,t,"tilingOffset",function(){return this._getColor(4)},function(e){var t;e&&(1!=(t=e.elements)[0]||1!=t[1]||0!=t[2]||0!=t[3])?this._addShaderDefine(laya.d3.extension.cartoonRender.CartoonMaterial.SHADERDEFINE_TILINGOFFSET):this._removeShaderDefine(laya.d3.extension.cartoonRender.CartoonMaterial.SHADERDEFINE_TILINGOFFSET),this._setColor(4,e)}),_(0,t,"specularRange",function(){return this._getNumber(8)},function(e){e=Math.max(.9,Math.min(1,e)),this._setNumber(8,e)}),_(0,t,"specularIntensity",function(){return this._getNumber(9)},function(e){e=Math.max(0,Math.min(1,e)),this._setNumber(9,e)}),e.__init__=function(){e.SHADERDEFINE_ALBEDOTEXTURE=e.shaderDefines.registerDefine("DIFFUSETEXTURE"),e.SHADERDEFINE_SPECULARTEXTURE=e.shaderDefines.registerDefine("SPECULARTEXTURE")},e.initShader=function(){var e=Vi.nameKey.add("CartoonShader"),e=$n.add(e,"attribute vec4 a_Position;\nattribute vec3 a_Normal;\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_PositionWorld;\nvarying vec3 v_ViewDir;\n\nvoid main()\n{\n\tgl_Position = u_MvpMatrix * a_Position;\n\t\n\tmat3 worldMat = mat3(u_WorldMat);\n\tv_PositionWorld = (u_WorldMat * a_Position).xyz;\n\tv_Normal = worldMat * a_Normal;\n\tv_Texcoord0 = a_Texcoord0;\n\t\n\tv_ViewDir = u_CameraPos - v_PositionWorld;\n}","#ifdef FSHIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\nstruct DirectionLight\n{\n\tvec3 Color;\n\tvec3 Direction;\n};\n\nvarying vec2 v_Texcoord0;\nvarying vec3 v_Normal;\nvarying vec3 v_PositionWorld;\nvarying vec3 v_ViewDir;\n\n#ifdef ALBEDOTEXTURE\n\tuniform sampler2D u_AlbedoTexture;\n#endif\n\n#ifdef SPECULARTEXTURE\n\tuniform sampler2D u_SpecularTexture;\n#endif\n\nuniform vec4 u_ShadowColor;\nuniform float u_ShadowRange;\nuniform float u_ShadowIntensity;\nuniform float u_SpecularRange;\nuniform float u_SpecularIntensity;\n\nuniform DirectionLight u_DirectionLight;\n\nvoid main()\n{\n\tvec3 normal = normalize(v_Normal);\n\tvec3 viewdir = normalize(v_ViewDir);\n\tvec3 lightDir = normalize(u_DirectionLight.Direction);\n\t\n\tvec4 albedoTextureColor = vec4(1.0);\n\t#ifdef ALBEDOTEXTURE\n\t\talbedoTextureColor = texture2D(u_AlbedoTexture, v_Texcoord0);\n\t#endif\n\t\n\tvec4 specularTextureColor = vec4(1.0); \n\t#ifdef SPECULARTEXTURE\n\t\tspecularTextureColor = texture2D(u_SpecularTexture, v_Texcoord0);\n\t#endif\n\t\n\tspecularTextureColor = specularTextureColor;\n\t\n\t//specularTextureColor = vec4(1.0, 1.0, 1.0, 1.0);\n\t\n\tfloat specTexColorG = specularTextureColor.g;\n\t\n\t//Overlay BlendMode 叠加\n\tvec3 albedoColor;\n\talbedoColor.r = albedoTextureColor.r > 0.5 ? 1.0 - 2.0 * (1.0 - albedoTextureColor.r) * (1.0 - specTexColorG) : 2.0 * albedoTextureColor.r * specTexColorG;\n\talbedoColor.g = albedoTextureColor.g > 0.5 ? 1.0 - 2.0 * (1.0 - albedoTextureColor.g) * (1.0 - specTexColorG) : 2.0 * albedoTextureColor.g * specTexColorG;\n\talbedoColor.b = albedoTextureColor.b > 0.5 ? 1.0 - 2.0 * (1.0 - albedoTextureColor.b) * (1.0 - specTexColorG) : 2.0 * albedoTextureColor.b * specTexColorG;\n\t\n\talbedoColor = clamp(albedoColor, 0.0, 1.0);\n\t\n\tfloat nl = max(dot(normal, -lightDir), 0.0);\n\t\n\tfloat shadowValue = nl + specTexColorG - 0.5;\n\tfloat shadow = step(shadowValue, u_ShadowRange);\n\tif(u_ShadowRange > (shadowValue + 0.01))\n\t\tshadow = 1.0;\n\telse if(u_ShadowRange < (shadowValue - 0.01))\n\t\tshadow = 0.0;\n\telse\n\t\tshadow = (u_ShadowRange - (shadowValue - 0.01)) / 0.02;\n\t\t\n\tshadow = clamp(shadow, 0.0, 1.0);\n\t\n\t//specularTextureColor.r 影响高光范围\n\tfloat specular = step(u_SpecularRange, clamp(pow(nl, specularTextureColor.r), 0.0, 1.0));\n\t//specularTextureColor.b 影响高光强度\n\tspecular = step(0.1, specular * specularTextureColor.b);\n\t\n\tvec3 albedoAreaColor = (1.0 - shadow) * albedoColor;\n\tvec3 shadowAreaColor = shadow * albedoColor * u_ShadowColor.rgb * u_ShadowIntensity;\n\tvec3 speculAreaColor = (1.0 - shadow) * albedoColor * u_SpecularIntensity * specular;\n\t\n\tvec3 finalColor = albedoAreaColor + speculAreaColor + shadowAreaColor;\n\t\n\tgl_FragColor = vec4(finalColor, 1.0);\n}\n",{a_Position:0,a_Normal:3,a_Texcoord0:2},{u_MvpMatrix:[1,2],u_WorldMat:[0,2],u_CameraPos:[0,3],u_AlbedoTexture:[1,1],u_SpecularTexture:[2,1],u_ShadowColor:[5,1],u_ShadowRange:[6,1],u_ShadowIntensity:[7,1],u_SpecularRange:[8,1],u_SpecularIntensity:[9,1],"u_DirectionLight.Direction":[3,4],"u_DirectionLight.Color":[4,4]});laya.d3.extension.cartoonRender.CartoonMaterial.SHADERDEFINE_ALBEDOTEXTURE=e.registerMaterialDefine("ALBEDOTEXTURE"),laya.d3.extension.cartoonRender.CartoonMaterial.SHADERDEFINE_SPECULARTEXTURE=e.registerMaterialDefine("SPECULARTEXTURE"),laya.d3.extension.cartoonRender.CartoonMaterial.SHADERDEFINE_TILINGOFFSET=e.registerMaterialDefine("TILINGOFFSET")},e.ALBEDOTEXTURE=1,e.SPECULARTEXTURE=2,e.TILINGOFFSET=4,e.SHADOWCOLOR=5,e.SHADOWRANGE=6,e.SHADOWINTENSITY=7,e.SPECULARRANGE=8,e.SPECULARINTENSITY=9,e.SHADERDEFINE_ALBEDOTEXTURE=0,e.SHADERDEFINE_SPECULARTEXTURE=0,e.SHADERDEFINE_TILINGOFFSET=0,l(e,["shaderDefines",function(){return this.shaderDefines=new fn(ri.shaderDefines)}])}(),function(){function e(){e.__super.call(this),this.setShaderName("OutlineShader"),this._setNumber(2,.01581197),this._setNumber(3,1)}p(e,"laya.d3.extension.cartoonRender.OutlineMaterial",ri);var t=e.prototype;_(0,t,"outlineTexture",function(){return this._getTexture(1)},function(e){e?this._addShaderDefine(laya.d3.extension.cartoonRender.OutlineMaterial.SHADERDEFINE_OUTLINETEXTURE):this._removeShaderDefine(laya.d3.extension.cartoonRender.OutlineMaterial.SHADERDEFINE_OUTLINETEXTURE),this._setTexture(1,e)}),_(0,t,"outlineWidth",function(){return this._getNumber(2)},function(e){e=Math.max(0,Math.min(.05,e)),this._setNumber(2,e)}),_(0,t,"outlineLightness",function(){return this._getNumber(3)},function(e){e=Math.max(0,Math.min(1,e)),this._setNumber(3,e)}),e.__init__=function(){e.SHADERDEFINE_OUTLINETEXTURE=e.shaderDefines.registerDefine("OUTLINETEXTURE")},e.initShader=function(){var e=Vi.nameKey.add("OutlineShader"),e=$n.add(e,"attribute vec4 a_Position;\nattribute vec3 a_Normal;\nattribute vec2 a_Texcoord0;\n\nuniform mat4 u_MvpMatrix;\nuniform float u_OutlineWidth;\n\nvarying vec2 v_Texcoord0;\n\nvoid main()\n{\n\tv_Texcoord0 = a_Texcoord0;\n\t\n\tvec4 position = vec4(a_Position.xyz + a_Normal * u_OutlineWidth, 1.0);\n\tgl_Position = u_MvpMatrix * position;\n}","#ifdef FSHIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\nstruct DirectionLight\n{\n\tvec3 Color;\n\tvec3 Direction;\n};\n\nvarying vec2 v_Texcoord0;\n\n#ifdef OUTLINETEXTURE\n\tuniform sampler2D u_OutlineTexture;\n#endif\nuniform float u_OutlineLightness;\n\nvoid main()\n{\n\tvec4 outlineTextureColor = vec4(1.0);\n\t#ifdef OUTLINETEXTURE\n\t\toutlineTextureColor = texture2D(u_OutlineTexture, v_Texcoord0);\n\t#endif\n\t\n\tvec3 finalColor = outlineTextureColor.rgb * u_OutlineLightness;\n\t\n\tgl_FragColor = vec4(finalColor,0.0);\n}\n",{a_Position:0,a_Normal:3,a_Texcoord0:2},{u_MvpMatrix:[1,2],u_OutlineTexture:[1,1],u_OutlineWidth:[2,1],u_OutlineLightness:[3,1]});laya.d3.extension.cartoonRender.OutlineMaterial.SHADERDEFINE_OUTLINETEXTURE=e.registerMaterialDefine("OUTLINETEXTURE")},e.OUTLINETEXTURE=1,e.OUTLINEWIDTH=2,e.OUTLINELIGHTNESS=3,e.SHADERDEFINE_OUTLINETEXTURE=0,l(e,["shaderDefines",function(){return this.shaderDefines=new fn(ri.shaderDefines)}])}(),p(ki,"laya.d3.extension.domino.DominoMaterial",ri),ki.__init__=function(){},ki.initShader=function(){var e=Vi.nameKey.add("DominoShader");$n.add(e,"attribute vec4 a_Position;\nattribute vec3 a_Normal;\nattribute vec2 a_Texcoord0;\nattribute vec4 a_Color;\n\nuniform mat4 u_MvpMatrix;\nuniform mat4 u_WorldMat;\nuniform vec3 u_CameraPos;\n\nvarying vec2 v_Texcoord0;\nvarying vec4 v_Color;\nvarying vec3 v_PositionWorld;\nvarying vec3 v_Normal;\nvarying vec3 v_ViewDir;\n\nvoid main()\n{\n\tv_Texcoord0 = a_Texcoord0;\n\tv_Color = a_Color;\n\t\n\tgl_Position = u_MvpMatrix * a_Position;\n\t\n\tv_Normal = mat3(u_WorldMat) * a_Normal;\n\tv_PositionWorld = (u_WorldMat * a_Position).xyz;\n\tv_ViewDir = u_CameraPos - v_PositionWorld;\n}","#ifdef FSHIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\nstruct DirectionLight\n{\n\tvec3 Color;\n\tvec3 Direction;\n};\nuniform DirectionLight u_DirectionLight;\n\nvarying vec2 v_Texcoord0;\nvarying vec4 v_Color;\nvarying vec3 v_ViewDir; \nvarying vec3 v_Normal;\n\nvoid LayaAirBlinnPhongDiectionLight (in vec3 normal, in vec3 viewDir, in DirectionLight light,out vec3 diffuseColor)\n{\n\tvec3 lightVec = normalize(light.Direction);\n\t\n\t//mediump vec3 h = normalize(viewDir-light.Direction);\n\t//float nh = max (0.0, dot (h,normal));\n\t\n lowp float ln = max (0.0, dot (-lightVec,normal));\n\tdiffuseColor = light.Color * ln;\n}\n\nvoid main()\n{\n\tvec3 diffuseColor;\n\tvec3 normal = normalize(v_Normal);\n\tvec3 viewDir = normalize(v_ViewDir);\n\tLayaAirBlinnPhongDiectionLight(normal, viewDir, u_DirectionLight, diffuseColor);\n\t\n\tgl_FragColor.xyz = diffuseColor * v_Color.xyz * 2.0;\n}\n\n",{a_Position:0,a_Normal:3,a_Color:1},{u_MvpMatrix:[1,2],u_WorldMat:[0,2],u_CameraPos:[0,3],"u_DirectionLight.Direction":[3,4],"u_DirectionLight.Color":[4,4]})},l(ki,["defaultMaterial",function(){return this.defaultMaterial=new ki},"shaderDefines",function(){return this.shaderDefines=new fn(ri.shaderDefines)}]),ki);function ki(){ki.__super.call(this),this.setShaderName("DominoShader")}var Xi=function(){function t(){t.__super.call(this),this.setShaderName("LineShader"),this._setColor(2,new _n(1,1,1,1)),this.cull=0}p(t,"laya.d3.extension.lineRender.LineMaterial",ri);var e=t.prototype;return _(0,e,"tintColor",function(){return this._getColor(2)},function(e){this._setColor(2,e)}),_(0,e,"diffuseTexture",function(){return this._getTexture(1)},function(e){e?this._addShaderDefine(laya.d3.extension.lineRender.LineMaterial.SHADERDEFINE_DIFFUSETEXTURE):this._removeShaderDefine(laya.d3.extension.lineRender.LineMaterial.SHADERDEFINE_DIFFUSETEXTURE),this._setTexture(1,e)}),_(0,e,"tilingOffset",function(){return this._getColor(3)},function(e){var t;e&&(1!=(t=e.elements)[0]||1!=t[1]||0!=t[2]||0!=t[3])?this._addShaderDefine(laya.d3.extension.lineRender.LineMaterial.SHADERDEFINE_TILINGOFFSET):this._removeShaderDefine(laya.d3.extension.lineRender.LineMaterial.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 S.loader.create(e,null,null,t)},t.initShader=function(){var e=Vi.nameKey.add("LineShader"),e=$n.add(e,"attribute vec3 a_Position;\nattribute vec3 a_OffsetVector;\nattribute float a_Texcoord0X;\nattribute float a_Texcoord0X1;\nattribute float a_Texcoord0Y;\n\nuniform mat4 u_MvpMatrix;\nuniform mat4 u_VMatrix;\nuniform mat4 u_PMatrix;\n\nuniform vec4 u_TilingOffset;\n\nuniform vec4 u_WidthCurve[10];\nuniform int u_WidthCurveKeyLength;\n\nuniform vec4 u_GradientColorkey[10];\nuniform vec2 u_GradientAlphakey[10];\n\nvarying vec4 v_Color;\nvarying vec2 v_Texcoord0;\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 = 0; 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 = 0; 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\t#ifdef TEXTUREMODE_STRETCH\n\t\tv_Texcoord0 = vec2(a_Texcoord0X, a_Texcoord0Y);\n\t#else\n\t\tv_Texcoord0 = vec2(a_Texcoord0X1, a_Texcoord0Y);\n\t#endif\n\t\n\t#ifdef TILINGOFFSET\n\t\tv_Texcoord0 = v_Texcoord0 * u_TilingOffset.xy + u_TilingOffset.zw;\n\t#endif\n\t\n\t#ifdef GRADIENTMODE_BLEND\n\t\tv_Color = getColorFromGradientByBlend(u_GradientColorkey, u_GradientAlphakey, a_Texcoord0X);\n\t#else\n\t\tv_Color = getColorFromGradientByFixed(u_GradientColorkey, u_GradientAlphakey, a_Texcoord0X);\n\t#endif\n\t\n\t#ifdef WORLDSPACE\n\t\tgl_Position = u_PMatrix * u_VMatrix * vec4(a_Position + a_OffsetVector * getCurWidth(a_Texcoord0X),1.0);\n\t#else\n\t\tgl_Position = u_MvpMatrix * vec4(a_Position + a_OffsetVector * getCurWidth(a_Texcoord0X),1.0);\n\t#endif\n}","#ifdef FSHIGHPRECISION\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{\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",{a_Position:0,a_OffsetVector:41,a_Texcoord0X:38,a_Texcoord0X1:39,a_Texcoord0Y:40},{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_WidthCurve:[3,2],u_WidthCurveKeyLength:[4,2],u_GradientColorkey:[5,2],u_GradientAlphakey:[6,2]});laya.d3.extension.lineRender.LineMaterial.SHADERDEFINE_DIFFUSETEXTURE=e.registerMaterialDefine("DIFFUSETEXTURE"),laya.d3.extension.lineRender.LineMaterial.SHADERDEFINE_TILINGOFFSET=e.registerMaterialDefine("TILINGOFFSET"),vr.SHADERDEFINE_GRADIENTMODE_BLEND=e.registerSpriteDefine("GRADIENTMODE_BLEND"),vr.SHADERDEFINE_TEXTUREMODE_STRETCH=e.registerSpriteDefine("TEXTUREMODE_STRETCH"),vr.SHADERDEFINE_WORLDSPACE=e.registerSpriteDefine("WORLDSPACE")},t.SHADERDEFINE_DIFFUSETEXTURE=0,t.SHADERDEFINE_TILINGOFFSET=0,t.DIFFUSETEXTURE=1,t.TINTCOLOR=2,t.TILINGOFFSET=3,l(t,["defaultMaterial",function(){return this.defaultMaterial=new t},"shaderDefines",function(){return this.shaderDefines=new fn(ri.shaderDefines)}]),t}(),Yi=(function(){function e(){e.__super.call(this),this.setShaderName("Dissolve"),this._setColor(9,new _n(1,1,1,1)),this._setNumber(7,0),this._setNumber(8,5)}p(e,"laya.d3.extension.lulingmen.DissolveMaterial",ri);var t=e.prototype;_(0,t,"albedoColor",function(){return this._getColor(9)},function(e){this._setColor(9,e)}),_(0,t,"mainTexture",function(){return this._getTexture(1)},function(e){e?this._addShaderDefine(laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_MAINTEXTURE):this._removeShaderDefine(laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_MAINTEXTURE),this._setTexture(1,e)}),_(0,t,"dissolveSpeed",function(){return this._getNumber(8)},function(e){this._setNumber(8,e)}),_(0,t,"tilingOffset",function(){return this._getColor(4)},function(e){var t;e&&(1!=(t=e.elements)[0]||1!=t[1]||0!=t[2]||0!=t[3])?this._addShaderDefine(laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_MAINTILINGOFFSET):this._removeShaderDefine(laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_MAINTILINGOFFSET),this._setColor(4,e)}),_(0,t,"dissolveTexture",function(){return this._getTexture(2)},function(e){e?this._addShaderDefine(laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_DISSOLVETEXTURE):this._removeShaderDefine(laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_DISSOLVETEXTURE),this._setTexture(2,e)}),_(0,t,"maskTexture",function(){return this._getTexture(3)},function(e){e?this._addShaderDefine(laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_MASKTEXTURE):this._removeShaderDefine(laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_MASKTEXTURE),this._setTexture(3,e)}),_(0,t,"dissolveTilingOffset",function(){return this._getColor(5)},function(e){var t;e&&(1!=(t=e.elements)[0]||1!=t[1]||0!=t[2]||0!=t[3])?this._addShaderDefine(laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_DISSOLVETILINGOFFSET):this._removeShaderDefine(laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_DISSOLVETILINGOFFSET),this._setColor(5,e)}),_(0,t,"maskTilingOffset",function(){return this._getColor(6)},function(e){var t;e&&(1!=(t=e.elements)[0]||1!=t[1]||0!=t[2]||0!=t[3])?this._addShaderDefine(laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_MASKTILINGOFFSET):this._removeShaderDefine(laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_MASKTILINGOFFSET),this._setColor(6,e)}),_(0,t,"dissolve",function(){return this._getNumber(7)},function(e){this._setNumber(7,e)}),e.__init__=function(){e.SHADERDEFINE_MAINTEXTURE=e.shaderDefines.registerDefine("MAINTEXTURE"),e.SHADERDEFINE_DISSOLVETEXTURE=e.shaderDefines.registerDefine("DISSOLVETEXTURE"),e.SHADERDEFINE_MASKTEXTURE=e.shaderDefines.registerDefine("MASKTEXTURE"),e.SHADERDEFINE_MAINTILINGOFFSET=e.shaderDefines.registerDefine("MAINTILINGOFFSET"),e.SHADERDEFINE_DISSOLVETILINGOFFSET=e.shaderDefines.registerDefine("DISSOLVETILINGOFFSET"),e.SHADERDEFINE_MASKTILINGOFFSET=e.shaderDefines.registerDefine("MASKTILINGOFFSET")},e.initShader=function(){var e=Vi.nameKey.add("Dissolve"),e=$n.add(e,"attribute vec4 a_Position;\nattribute vec3 a_Normal;\nattribute vec2 a_Texcoord0;\n\nuniform mat4 u_MvpMatrix;\n\nuniform vec4 u_MainTilingOffset;\nuniform vec4 u_DissolveTilingOffset;\nuniform vec4 u_MaskTilingOffset;\n\nvarying vec2 v_Texcoord0;\nvarying vec2 v_Texcoord1;\nvarying vec2 v_Texcoord2;\n\nvoid main()\n{\n\tv_Texcoord0 = a_Texcoord0;\n\t#ifdef MAINTILINGOFFSET\n\t\tv_Texcoord0 = (vec2(v_Texcoord0.x, v_Texcoord0.y - 1.0) * u_MainTilingOffset.xy) + u_MainTilingOffset.zw;\n\t\tv_Texcoord0 = vec2(v_Texcoord0.x, 1.0 + v_Texcoord0.y);\n\t#endif\n\t\n\tv_Texcoord1 = a_Texcoord0;\n\t#ifdef DISSOLVETILINGOFFSET\n\t\tv_Texcoord1 = (vec2(v_Texcoord1.x, v_Texcoord1.y - 1.0) * u_DissolveTilingOffset.xy) + u_DissolveTilingOffset.zw;\n\t\tv_Texcoord1 = vec2(v_Texcoord1.x, 1.0 + v_Texcoord1.y);\n\t#endif\n\t\n\tv_Texcoord2 = a_Texcoord0;\n\t\n\tgl_Position = u_MvpMatrix * a_Position;\n}","#ifdef FSHIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\nvarying vec2 v_Texcoord0;\nvarying vec2 v_Texcoord1;\nvarying vec2 v_Texcoord2;\n\n#ifdef MAINTEXTURE\n\tuniform sampler2D u_MainTexture;\n#endif\n\n#ifdef DISSOLVETEXTURE\n\tuniform sampler2D u_DissolveTexture;\n#endif\n\n#ifdef MASKTEXTURE\n\tuniform sampler2D u_MaskTexture;\n#endif\n\nuniform vec4 u_BaseColor;\nuniform float u_Dissolve;\nuniform float u_DissolveSpeed;\n\nvoid main()\n{\n\tvec4 mainColor = u_BaseColor;\n\tmainColor.a = 1.0;\n\t#ifdef MAINTEXTURE\n\t\tmainColor *= texture2D(u_MainTexture, v_Texcoord0);\n\t#endif\n\t\n\tvec4 dissolveColor = vec4(1.0);\n\t#ifdef DISSOLVETEXTURE\n\t\tdissolveColor = texture2D(u_DissolveTexture, v_Texcoord1);\n\t#endif\n\t\n\tvec4 maskColor = vec4(1.0);\n\t#ifdef MASKTEXTURE\n\t\tmaskColor = texture2D(u_MaskTexture, v_Texcoord2);\n\t#endif\n\t\n\tvec4 outColor = mix(vec4(0.0), mainColor, maskColor);\n\tif(dissolveColor.a <= u_Dissolve){\n\t\tfloat alpha = clamp(outColor.a - u_Dissolve * 2.0 + dissolveColor.a, 0.0, 1.0);\n\t\talpha = pow(alpha, u_DissolveSpeed);\n\t\toutColor.a = alpha;\n\t}\n\t\n\tgl_FragColor = outColor;\n}\n",{a_Position:0,a_Normal:3,a_Texcoord0:2},{u_MvpMatrix:[1,2],u_MainTexture:[1,1],u_DissolveTexture:[2,1],u_MaskTexture:[3,1],u_BaseColor:[9,1],u_MainTilingOffset:[4,1],u_DissolveTilingOffset:[5,1],u_MaskTilingOffset:[6,1],u_Dissolve:[7,1],u_DissolveSpeed:[8,1]});laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_MAINTEXTURE=e.registerMaterialDefine("MAINTEXTURE"),laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_DISSOLVETEXTURE=e.registerMaterialDefine("DISSOLVETEXTURE"),laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_MASKTEXTURE=e.registerMaterialDefine("MASKTEXTURE"),laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_MAINTILINGOFFSET=e.registerMaterialDefine("MAINTILINGOFFSET"),laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_DISSOLVETILINGOFFSET=e.registerMaterialDefine("DISSOLVETILINGOFFSET"),laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_MASKTILINGOFFSET=e.registerMaterialDefine("MASKTILINGOFFSET")},e.MAINTEXTURE=1,e.DISSOLVETEXTURE=2,e.MASKTEXTURE=3,e.MAINTILINGOFFSET=4,e.DISSOLVETILINGOFFSET=5,e.MASKTILINGOFFSET=6,e.DISSOLVE=7,e.DISSOLVESPEED=8,e.BASECOLOR=9,e.SHADERDEFINE_MAINTEXTURE=0,e.SHADERDEFINE_DISSOLVETEXTURE=0,e.SHADERDEFINE_MASKTEXTURE=0,e.SHADERDEFINE_MAINTILINGOFFSET=0,e.SHADERDEFINE_DISSOLVETILINGOFFSET=0,e.SHADERDEFINE_MASKTILINGOFFSET=0,l(e,["shaderDefines",function(){return this.shaderDefines=new fn(ri.shaderDefines)}])}(),function(){function e(){e.__super.call(this),this.setShaderName("MeshParticle"),this._setColor(3,new _n(1,1,1,1)),this._setColor(4,new _n(1,1,1,1)),this._setNumber(5,1),this._setNumber(6,1)}p(e,"laya.d3.extension.lulingmen.MeshParticleMaterial",ri);var t=e.prototype;return _(0,t,"alpha",function(){return this._getNumber(6)},function(e){e=Math.max(0,Math.min(1,e)),this._setNumber(6,e)}),_(0,t,"mainTexture",function(){return this._getTexture(1)},function(e){e?this._addShaderDefine(laya.d3.extension.lulingmen.MeshParticleMaterial.SHADERDEFINE_MAINTEXTURE):this._removeShaderDefine(laya.d3.extension.lulingmen.MeshParticleMaterial.SHADERDEFINE_MAINTEXTURE),this._setTexture(1,e)}),_(0,t,"maskTexture",function(){return this._getTexture(2)},function(e){e?this._addShaderDefine(laya.d3.extension.lulingmen.MeshParticleMaterial.SHADERDEFINE_MASKTEXTURE):this._removeShaderDefine(laya.d3.extension.lulingmen.MeshParticleMaterial.SHADERDEFINE_MASKTEXTURE),this._setTexture(2,e)}),_(0,t,"albedoColor",function(){return this._getColor(3)},function(e){this._setColor(3,e)}),_(0,t,"intensity",function(){return this._getNumber(5)},function(e){this._setNumber(5,e)}),_(0,t,"alphaColor",function(){return this._getColor(4)},function(e){this._setColor(4,e)}),_(0,t,"tilingOffset",function(){return this._getColor(7)},function(e){var t;e&&(1!=(t=e.elements)[0]||1!=t[1]||0!=t[2]||0!=t[3])?this._addShaderDefine(laya.d3.extension.lulingmen.MeshParticleMaterial.SHADERDEFINE_TILINGOFFSET1):this._removeShaderDefine(laya.d3.extension.lulingmen.MeshParticleMaterial.SHADERDEFINE_TILINGOFFSET1),this._setColor(7,e)}),_(0,t,"maskTilingOffset",function(){return this._getColor(8)},function(e){var t;e&&(1!=(t=e.elements)[0]||1!=t[1]||0!=t[2]||0!=t[3])?this._addShaderDefine(laya.d3.extension.lulingmen.MeshParticleMaterial.SHADERDEFINE_TILINGOFFSET2):this._removeShaderDefine(laya.d3.extension.lulingmen.MeshParticleMaterial.SHADERDEFINE_TILINGOFFSET2),this._setColor(8,e)}),e.__init__=function(){e.SHADERDEFINE_MAINTEXTURE=e.shaderDefines.registerDefine("MAINTEXTURE"),e.SHADERDEFINE_MASKTEXTURE=e.shaderDefines.registerDefine("MASKTEXTURE"),e.SHADERDEFINE_TILINGOFFSET1=e.shaderDefines.registerDefine("TILINGOFFSET1"),e.SHADERDEFINE_TILINGOFFSET2=e.shaderDefines.registerDefine("TILINGOFFSET2")},e.initShader=function(){var e=Vi.nameKey.add("MeshParticle"),e=$n.add(e,"attribute vec4 a_Position;\nattribute vec3 a_Normal;\nattribute vec2 a_Texcoord0;\nattribute vec4 a_Color;\n\nuniform mat4 u_MvpMatrix;\n\nuniform vec4 u_TilingOffset1;\nuniform vec4 u_TilingOffset2;\n\nvarying vec2 v_Texcoord0;\nvarying vec2 v_Texcoord1;\nvarying vec4 v_Color;\n\nvoid main()\n{\n\tv_Texcoord0 = a_Texcoord0;\n\t#ifdef TILINGOFFSET1\n\t\tv_Texcoord0 = (vec2(v_Texcoord0.x, v_Texcoord0.y - 1.0) * u_TilingOffset1.xy) + u_TilingOffset1.zw;\n\t\tv_Texcoord0 = vec2(v_Texcoord0.x, 1.0 + v_Texcoord0.y);\n\t#endif\n\t\n\tv_Texcoord1 = a_Texcoord0;\n\t#ifdef TILINGOFFSET2\n\t\tv_Texcoord1 = (vec2(v_Texcoord1.x, v_Texcoord1.y - 1.0) * u_TilingOffset2.xy) + u_TilingOffset2.zw;\n\t\tv_Texcoord1 = vec2(v_Texcoord1.x, 1.0 + v_Texcoord1.y);\n\t#endif\n\t\n\tv_Color = vec4(1.0);\n\t#ifdef COLOR\n\t\tv_Color = a_Color;\n\t#endif\n\t\n\tgl_Position = u_MvpMatrix * a_Position;\n}","#ifdef FSHIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\nvarying vec2 v_Texcoord0;\nvarying vec2 v_Texcoord1;\nvarying vec4 v_Color;\n\n#ifdef MAINTEXTURE\n\tuniform sampler2D u_MainTexture;\n#endif\n\n#ifdef MASKTEXTURE\n\tuniform sampler2D u_MaskTexture;\n#endif\n\nuniform vec4 u_BaseColor;\nuniform vec4 u_AlphaColor;\nuniform float u_Instensity;\nuniform float u_Alpha;\n\nvoid main()\n{\n\tvec4 mainTextureColor = vec4(1.0);\n\t#ifdef MAINTEXTURE\n\t\tmainTextureColor = texture2D(u_MainTexture, v_Texcoord0);\n\t#endif\n\t\n\tvec4 maskTextureColor = vec4(1.0);\n\t#ifdef MASKTEXTURE\n\t\tmaskTextureColor = texture2D(u_MaskTexture, v_Texcoord1);\n\t#endif\n\t\n\tvec4 outColor = mix(vec4(0.0), mainTextureColor, maskTextureColor);\n\t\n\tgl_FragColor = 2.0 * outColor * u_BaseColor * u_AlphaColor * u_Instensity * v_Color;\n\tgl_FragColor.a *= u_Alpha;\n}\n",{a_Position:0,a_Normal:3,a_Color:1,a_Texcoord0:2},{u_MvpMatrix:[1,2],u_MainTexture:[1,1],u_MaskTexture:[2,1],u_BaseColor:[3,1],u_AlphaColor:[4,1],u_Instensity:[5,1],u_Alpha:[6,1],u_TilingOffset1:[7,1],u_TilingOffset2:[8,1]});laya.d3.extension.lulingmen.MeshParticleMaterial.SHADERDEFINE_MAINTEXTURE=e.registerMaterialDefine("MAINTEXTURE"),laya.d3.extension.lulingmen.MeshParticleMaterial.SHADERDEFINE_MASKTEXTURE=e.registerMaterialDefine("MASKTEXTURE"),laya.d3.extension.lulingmen.MeshParticleMaterial.SHADERDEFINE_TILINGOFFSET1=e.registerMaterialDefine("TILINGOFFSET1"),laya.d3.extension.lulingmen.MeshParticleMaterial.SHADERDEFINE_TILINGOFFSET2=e.registerMaterialDefine("TILINGOFFSET2")},e.MAINTEXTURE=1,e.MASKTEXTURE=2,e.BASECOLOR=3,e.ALPHACOLOR=4,e.INTENSITY=5,e.ALPHA=6,e.TILINGOFFSET1=7,e.TILINGOFFSET2=8,e.SHADERDEFINE_MAINTEXTURE=0,e.SHADERDEFINE_MASKTEXTURE=0,e.SHADERDEFINE_TILINGOFFSET1=0,e.SHADERDEFINE_TILINGOFFSET2=0,l(e,["shaderDefines",function(){return this.shaderDefines=new fn(ri.shaderDefines)}]),e}()),Zi=(function(){function e(){e.__super.call(this),this.setShaderName("Particle"),this._setColor(3,new _n(1,1,1,1)),this._setColor(4,new _n(1,1,1,1)),this._setNumber(5,1),this._setNumber(6,1)}p(e,"laya.d3.extension.lulingmen.ParticleMaterial",ri);var t=e.prototype;_(0,t,"alpha",function(){return this._getNumber(6)},function(e){e=Math.max(0,Math.min(1,e)),this._setNumber(6,e)}),_(0,t,"tintColor",function(){return this._getColor(3)},function(e){this._setColor(3,e)}),_(0,t,"mainTexture",function(){return this._getTexture(1)},function(e){e?this._addShaderDefine(Yi.SHADERDEFINE_MAINTEXTURE):this._removeShaderDefine(Yi.SHADERDEFINE_MAINTEXTURE),this._setTexture(1,e)}),_(0,t,"maskTexture",function(){return this._getTexture(2)},function(e){e?this._addShaderDefine(Yi.SHADERDEFINE_MASKTEXTURE):this._removeShaderDefine(Yi.SHADERDEFINE_MASKTEXTURE),this._setTexture(2,e)}),_(0,t,"intensity",function(){return this._getNumber(5)},function(e){this._setNumber(5,e)}),_(0,t,"alphaColor",function(){return this._getColor(4)},function(e){this._setColor(4,e)}),_(0,t,"tilingOffset",function(){return this._getColor(7)},function(e){var t;e&&(1!=(t=e.elements)[0]||1!=t[1]||0!=t[2]||0!=t[3])?this._addShaderDefine(Yi.SHADERDEFINE_TILINGOFFSET1):this._removeShaderDefine(Yi.SHADERDEFINE_TILINGOFFSET1),this._setColor(7,e)}),_(0,t,"maskTilingOffset",function(){return this._getColor(8)},function(e){var t;e&&(1!=(t=e.elements)[0]||1!=t[1]||0!=t[2]||0!=t[3])?this._addShaderDefine(Yi.SHADERDEFINE_TILINGOFFSET2):this._removeShaderDefine(Yi.SHADERDEFINE_TILINGOFFSET2),this._setColor(8,e)}),e.__init__=function(){e.SHADERDEFINE_MAINTEXTURE=e.shaderDefines.registerDefine("MAINTEXTURE"),e.SHADERDEFINE_MASKTEXTURE=e.shaderDefines.registerDefine("MASKTEXTURE"),e.SHADERDEFINE_TILINGOFFSET1=e.shaderDefines.registerDefine("TILINGOFFSET1"),e.SHADERDEFINE_TILINGOFFSET2=e.shaderDefines.registerDefine("TILINGOFFSET2")},e.initShader=function(){var e=Vi.nameKey.add("Particle"),e=$n.add(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 MAINTEXTURE\n\tvarying vec2 v_TextureCoordinate;\n\t#ifdef TILINGOFFSET1\n\t\tuniform vec4 u_TilingOffset1;\n\t#endif\n#endif\n\n#ifdef MASKTEXTURE\n\t#ifdef TILINGOFFSET2\n\t\tuniform vec4 u_TilingOffset2;\n\t#endif\n#endif\n\nvarying vec2 v_Texcoord0;\nvarying vec2 v_Texcoord1;\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\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 MAINTEXTURE\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\tv_Texcoord0 = v_TextureCoordinate;\n\t\t#ifdef TILINGOFFSET1 \n\t\t\tv_Texcoord0=vec2(v_TextureCoordinate.x,1.0-v_TextureCoordinate.y)*u_TilingOffset1.xy+vec2(u_TilingOffset1.z,-u_TilingOffset1.w);//需要特殊处理\n\t\t\tv_Texcoord0=vec2(v_TextureCoordinate.x,1.0-v_TextureCoordinate.y);//需要特殊处理\n\t\t#endif\n\t\t\n\t\tv_Texcoord1 = v_TextureCoordinate;\n\t\t#ifdef TILINGOFFSET2 \n\t\t\tv_Texcoord1=vec2(v_TextureCoordinate.x,1.0-v_TextureCoordinate.y)*u_TilingOffset2.xy+vec2(u_TilingOffset2.z,-u_TilingOffset2.w);//需要特殊处理\n\t\t\tv_Texcoord1=vec2(v_TextureCoordinate.x,1.0-v_TextureCoordinate.y);//需要特殊处理\n\t\t#endif\n\t\t\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","#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_Texcoord0;\nvarying vec2 v_Texcoord1;\n\nuniform vec4 u_BaseColor;\nuniform vec4 u_AlphaColor;\nuniform float u_Instensity;\nuniform float u_Alpha;\n\n#ifdef MAINTEXTURE\n\tuniform sampler2D u_MainTexture;\n#endif\n\n#ifdef MASKTEXTURE\n\tuniform sampler2D u_MaskTexture;\n#endif\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\tvec4 mainTextureColor = vec4(1.0);\n\t#ifdef MAINTEXTURE\n\t\tmainTextureColor = texture2D(u_MainTexture, v_Texcoord0);\n\t#endif\n\t\n\tvec4 maskTextureColor = vec4(1.0);\n\t#ifdef MASKTEXTURE\n\t\tmaskTextureColor = texture2D(u_MaskTexture, v_Texcoord1);\n\t#endif\n\t\n\tvec4 outColor = mix(vec4(0.0), mainTextureColor, maskTextureColor);\n\t\n\tgl_FragColor *= 2.0 * outColor * u_BaseColor * u_AlphaColor * v_Color * u_Instensity;\n\tgl_FragColor.a *= u_Alpha;\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_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},{u_MainTexture:[1,1],u_MaskTexture:[2,1],u_BaseColor:[3,1],u_AlphaColor:[4,1],u_Instensity:[5,1],u_Alpha:[6,1],u_TilingOffset1:[7,1],u_TilingOffset2:[8,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]});Yi.SHADERDEFINE_MAINTEXTURE=e.registerMaterialDefine("MAINTEXTURE"),Yi.SHADERDEFINE_MASKTEXTURE=e.registerMaterialDefine("MASKTEXTURE"),Yi.SHADERDEFINE_TILINGOFFSET1=e.registerMaterialDefine("TILINGOFFSET1"),Yi.SHADERDEFINE_TILINGOFFSET2=e.registerMaterialDefine("TILINGOFFSET2"),mr.SHADERDEFINE_RENDERMODE_BILLBOARD=e.registerSpriteDefine("SPHERHBILLBOARD"),mr.SHADERDEFINE_RENDERMODE_STRETCHEDBILLBOARD=e.registerSpriteDefine("STRETCHEDBILLBOARD"),mr.SHADERDEFINE_RENDERMODE_HORIZONTALBILLBOARD=e.registerSpriteDefine("HORIZONTALBILLBOARD"),mr.SHADERDEFINE_RENDERMODE_VERTICALBILLBOARD=e.registerSpriteDefine("VERTICALBILLBOARD"),mr.SHADERDEFINE_COLOROVERLIFETIME=e.registerSpriteDefine("COLOROVERLIFETIME"),mr.SHADERDEFINE_RANDOMCOLOROVERLIFETIME=e.registerSpriteDefine("RANDOMCOLOROVERLIFETIME"),mr.SHADERDEFINE_VELOCITYOVERLIFETIMECONSTANT=e.registerSpriteDefine("VELOCITYOVERLIFETIMECONSTANT"),mr.SHADERDEFINE_VELOCITYOVERLIFETIMECURVE=e.registerSpriteDefine("VELOCITYOVERLIFETIMECURVE"),mr.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCONSTANT=e.registerSpriteDefine("VELOCITYOVERLIFETIMERANDOMCONSTANT"),mr.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCURVE=e.registerSpriteDefine("VELOCITYOVERLIFETIMERANDOMCURVE"),mr.SHADERDEFINE_TEXTURESHEETANIMATIONCURVE=e.registerSpriteDefine("TEXTURESHEETANIMATIONCURVE"),mr.SHADERDEFINE_TEXTURESHEETANIMATIONRANDOMCURVE=e.registerSpriteDefine("TEXTURESHEETANIMATIONRANDOMCURVE"),mr.SHADERDEFINE_ROTATIONOVERLIFETIME=e.registerSpriteDefine("ROTATIONOVERLIFETIME"),mr.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE=e.registerSpriteDefine("ROTATIONOVERLIFETIMESEPERATE"),mr.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT=e.registerSpriteDefine("ROTATIONOVERLIFETIMECONSTANT"),mr.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE=e.registerSpriteDefine("ROTATIONOVERLIFETIMECURVE"),mr.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS=e.registerSpriteDefine("ROTATIONOVERLIFETIMERANDOMCONSTANTS"),mr.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCURVES=e.registerSpriteDefine("ROTATIONOVERLIFETIMERANDOMCURVES"),mr.SHADERDEFINE_SIZEOVERLIFETIMECURVE=e.registerSpriteDefine("SIZEOVERLIFETIMECURVE"),mr.SHADERDEFINE_SIZEOVERLIFETIMECURVESEPERATE=e.registerSpriteDefine("SIZEOVERLIFETIMECURVESEPERATE"),mr.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVES=e.registerSpriteDefine("SIZEOVERLIFETIMERANDOMCURVES"),mr.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVESSEPERATE=e.registerSpriteDefine("SIZEOVERLIFETIMERANDOMCURVESSEPERATE"),mr.SHADERDEFINE_RENDERMODE_MESH=e.registerSpriteDefine("RENDERMODE_MESH"),mr.SHADERDEFINE_SHAPE=e.registerSpriteDefine("SHAPE")},e.MAINTEXTURE=1,e.MASKTEXTURE=2,e.BASECOLOR=3,e.ALPHACOLOR=4,e.INTENSITY=5,e.ALPHA=6,e.TILINGOFFSET1=7,e.TILINGOFFSET2=8,e.SHADERDEFINE_MAINTEXTURE=0,e.SHADERDEFINE_MASKTEXTURE=0,e.SHADERDEFINE_TILINGOFFSET1=0,e.SHADERDEFINE_TILINGOFFSET2=0,l(e,["shaderDefines",function(){return this.shaderDefines=new fn(ri.shaderDefines)}])}(),function(){function e(){e.__super.call(this),this.setShaderName("UVSine"),this._setColor(3,new _n(1,1,1,1)),this._setNumber(4,0),this._setNumber(5,0),this._setNumber(6,0),this._setNumber(7,0),this._setNumber(8,1),this._setNumber(9,1)}p(e,"laya.d3.extension.lulingmen.UVSineMaterial",ri);var t=e.prototype;_(0,t,"alpha",function(){return this._getNumber(9)},function(e){e=Math.max(0,Math.min(1,e)),this._setNumber(9,e)}),_(0,t,"baseTexture",function(){return this._getTexture(1)},function(e){e?this._addShaderDefine(laya.d3.extension.lulingmen.UVSineMaterial.SHADERDEFINE_BASETEXTURE):this._removeShaderDefine(laya.d3.extension.lulingmen.UVSineMaterial.SHADERDEFINE_BASETEXTURE),this._setTexture(1,e)}),_(0,t,"baseScrollSpeedX",function(){return this._getNumber(4)},function(e){this._setNumber(4,e)}),_(0,t,"secondTexture",function(){return this._getTexture(2)},function(e){e?this._addShaderDefine(laya.d3.extension.lulingmen.UVSineMaterial.SHADERDEFINE_SECONDTEXTURE):this._removeShaderDefine(laya.d3.extension.lulingmen.UVSineMaterial.SHADERDEFINE_SECONDTEXTURE),this._setTexture(2,e)}),_(0,t,"mMultiplier",function(){return this._getNumber(8)},function(e){this._setNumber(8,e)}),_(0,t,"baseScrollSpeedY",function(){return this._getNumber(5)},function(e){this._setNumber(5,e)}),_(0,t,"albedoColor",function(){return this._getColor(3)},function(e){this._setColor(3,e)}),_(0,t,"secondScrollSpeedX",function(){return this._getNumber(6)},function(e){this._setNumber(6,e)}),_(0,t,"secondScrollSpeedY",function(){return this._getNumber(7)},function(e){this._setNumber(7,e)}),_(0,t,"tilingOffset",function(){return this._getColor(10)},function(e){var t;e&&(1!=(t=e.elements)[0]||1!=t[1]||0!=t[2]||0!=t[3])?this._addShaderDefine(laya.d3.extension.lulingmen.UVSineMaterial.SHADERDEFINE_TILINGOFFSET1):this._removeShaderDefine(laya.d3.extension.lulingmen.UVSineMaterial.SHADERDEFINE_TILINGOFFSET1),this._setColor(10,e)}),_(0,t,"detailTilingOffset",function(){return this._getColor(11)},function(e){var t;e&&(1!=(t=e.elements)[0]||1!=t[1]||0!=t[2]||0!=t[3])?this._addShaderDefine(laya.d3.extension.lulingmen.UVSineMaterial.SHADERDEFINE_TILINGOFFSET2):this._removeShaderDefine(laya.d3.extension.lulingmen.UVSineMaterial.SHADERDEFINE_TILINGOFFSET2),this._setColor(11,e)}),e.__init__=function(){e.SHADERDEFINE_BASETEXTURE=e.shaderDefines.registerDefine("BASETEXTURE"),e.SHADERDEFINE_SECONDTEXTURE=e.shaderDefines.registerDefine("SECONDTEXTURE"),e.SHADERDEFINE_TILINGOFFSET1=e.shaderDefines.registerDefine("TILINGOFFSET1"),e.SHADERDEFINE_TILINGOFFSET2=e.shaderDefines.registerDefine("TILINGOFFSET2")},e.initShader=function(){var e=Vi.nameKey.add("UVSine"),e=$n.add(e,"attribute vec4 a_Position;\nattribute vec3 a_Normal;\nattribute vec2 a_Texcoord0;\nattribute vec4 a_Color;\n\nuniform mat4 u_MvpMatrix;\nuniform float u_Time;\nuniform float u_BaseScrollSpeedX;\nuniform float u_BaseScrollSpeedY;\nuniform float u_SecondScrollSpeedX;\nuniform float u_SecondScrollSpeedY;\n\nuniform vec4 u_TilingOffset1;\nuniform vec4 u_TilingOffset2;\n\nvarying vec2 v_Texcoord0;\nvarying vec2 v_Texcoord1;\nvarying vec4 v_Color;\n\nvoid main()\n{\n\tv_Texcoord0 = a_Texcoord0;\n\t#ifdef TILINGOFFSET1\n\t\tv_Texcoord0 = (vec2(v_Texcoord0.x, v_Texcoord0.y - 1.0) * u_TilingOffset1.xy) + u_TilingOffset1.zw;\n\t\tv_Texcoord0 = vec2(v_Texcoord0.x, 1.0 + v_Texcoord0.y);\n\t#endif\n\t\n\tv_Texcoord1 = a_Texcoord0;\n\t#ifdef TILINGOFFSET2\n\t\tv_Texcoord1 = (vec2(v_Texcoord1.x, v_Texcoord1.y - 1.0) * u_TilingOffset2.xy) + u_TilingOffset2.zw;\n\t\tv_Texcoord1 = vec2(v_Texcoord1.x, 1.0 + v_Texcoord1.y);\n\t#endif\n\t\n\tv_Texcoord0 = v_Texcoord0 + vec2(fract(u_BaseScrollSpeedX * u_Time / 20.0), fract(-u_BaseScrollSpeedY * u_Time));\n\tv_Texcoord1 = v_Texcoord1 + vec2(fract(u_SecondScrollSpeedX * u_Time / 20.0), fract(-u_SecondScrollSpeedY * u_Time));\n\t\n\tv_Color = vec4(1.0);\n\t#ifdef COLOR\n\t\tv_Color = a_Color;\n\t#endif\n\t\n\tgl_Position = u_MvpMatrix * a_Position;\n}","#ifdef FSHIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\nvarying vec2 v_Texcoord0;\nvarying vec2 v_Texcoord1;\nvarying vec4 v_Color;\n\n#ifdef BASETEXTURE\n\tuniform sampler2D u_BaseTexture;\n#endif\n\n#ifdef SECONDTEXTURE\n\tuniform sampler2D u_SecondTexture;\n#endif\n\nuniform vec4 u_BaseColor;\nuniform float u_MMultiplier;\nuniform float u_Alpha;\n\nvoid main()\n{\n\tvec4 baseTextureColor = vec4(1.0);\n\t#ifdef BASETEXTURE\n\t\tbaseTextureColor = texture2D(u_BaseTexture, v_Texcoord0);\n\t#endif\n\t\n\tvec4 secondTextureColor = vec4(1.0);\n\t#ifdef SECONDTEXTURE\n\t\tsecondTextureColor = texture2D(u_SecondTexture, v_Texcoord1);\n\t#endif\n\t\n\tgl_FragColor = baseTextureColor * secondTextureColor * u_BaseColor * u_MMultiplier * v_Color;\n\tgl_FragColor.a *= u_Alpha;\n}\n",{a_Position:0,a_Normal:3,a_Color:1,a_Texcoord0:2},{u_MvpMatrix:[1,2],u_Time:[22,4],u_BaseTexture:[1,1],u_SecondTexture:[2,1],u_BaseColor:[3,1],u_BaseScrollSpeedX:[4,1],u_BaseScrollSpeedY:[5,1],u_SecondScrollSpeedX:[6,1],u_SecondScrollSpeedY:[7,1],u_MMultiplier:[8,1],u_Alpha:[9,1],u_TilingOffset1:[10,1],u_TilingOffset2:[11,1]});laya.d3.extension.lulingmen.UVSineMaterial.SHADERDEFINE_BASETEXTURE=e.registerMaterialDefine("BASETEXTURE"),laya.d3.extension.lulingmen.UVSineMaterial.SHADERDEFINE_SECONDTEXTURE=e.registerMaterialDefine("SECONDTEXTURE"),laya.d3.extension.lulingmen.UVSineMaterial.SHADERDEFINE_TILINGOFFSET1=e.registerMaterialDefine("TILINGOFFSET1"),laya.d3.extension.lulingmen.UVSineMaterial.SHADERDEFINE_TILINGOFFSET2=e.registerMaterialDefine("TILINGOFFSET2")},e.BASETEXTURE=1,e.SECONDTEXTURE=2,e.BASECOLOR=3,e.BASESCROLLSPEEDX=4,e.BASESCROLLSPEEDY=5,e.SECONDSCROLLSPEEDX=6,e.SECONDSCROLLSPEEDY=7,e.MMULTIPLIER=8,e.ALPHA=9,e.TILINGOFFSET1=10,e.TILINGOFFSET2=11,e.SHADERDEFINE_BASETEXTURE=0,e.SHADERDEFINE_SECONDTEXTURE=0,e.SHADERDEFINE_TILINGOFFSET1=0,e.SHADERDEFINE_TILINGOFFSET2=0,l(e,["shaderDefines",function(){return this.shaderDefines=new fn(ri.shaderDefines)}])}(),function(){function e(){this._startTm=0,e.__super.call(this),laya.d3.water.WaterDetailMaterial.init(),this.setShaderName("WaterDetail"),this.cull=0,this._startTm=S.timer.currTimer}p(e,"laya.d3.water.WaterDetailMaterial",ri);var t=e.prototype;return _(0,t,"currentTm",function(){return this._getNumber(1)},function(e){this._setNumber(1,e-this._startTm)}),_(0,t,"waveInfo",function(){return this._getBuffer(12)},function(e){this._setBuffer(12,e)}),_(0,t,"waveInfoD",function(){return this._getBuffer(13)},function(e){this._setBuffer(13,e)}),_(0,t,"texWaveUVScale",function(){return this._getNumber(15)},function(e){this._setNumber(15,e)}),e.init=function(){var e;laya.d3.water.WaterDetailMaterial._bInited||(laya.d3.water.WaterDetailMaterial._bInited=!0,e=Vi.nameKey.add("WaterDetail"),$n.add(e,"\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 uv;\n\nvarying vec2 vUv;\nvarying vec3 vWorldNorm;\nvarying vec3 vWorldTangent;\nvarying vec3 vWorldBinormal;\n\n\nvoid main() {\n\tvec3 pos = a_position;\n\tif(pos.z!=0.)pos.y=pos.z;\n\tpos.z=0.5;\n\tgl_Position = vec4(pos,1.);\n vUv = uv;\n\t//vWorldNorm = normalize((modelMat*vec4(a_normal,0.0)).xyz);\n\t//vWorldTangent = normalize((modelMat*vec4(tangent,0.0)).xyz);\n\t//vWorldBinormal = normalize((modelMat*vec4(binormal,0.0)).xyz);\n}\n",'precision highp float;\nprecision lowp int;\n\nconst float PI = 3.14159265358979323846264;\nconst float _2PI = 6.2831853071796;\nvarying vec2 vUv;\nvarying vec3 vWorldNorm;\nvarying vec3 vWorldTangent;\nvarying vec3 vWorldBinormal;\n\nuniform float u_curTm;\n\n#include "WaveFunction.glsl"\n\nvoid main() {\n\tvec3 wave_N,wave_B,wave_T;\n\tcalcWave(u_curTm, vUv,wave_B,wave_T,wave_N);\n\tgl_FragColor.rgb = normalize(wave_N)*0.5+vec3(0.5);// vec3(0.1,.4,0.1);\n gl_FragColor.a = 1.0;\n}\n',{a_position:0,a_normal:3,uv:2},{u_curTm:[1,1],u_WaveInfo:[12,1],u_WaveInfoD:[13,1],TEXWAVE_UV_SCALE:[15,1]}))},e.CURTM=1,e.WAVEINFO=12,e.WAVEINFOD=13,e.WAVEMAINDIR=14,e.TEXWAVE_UV_SCALE=15,e._bInited=!1,e}()),ji=(function(t){function e(){this._animationSprites=null,this._animationSpritesInitLocalMatrix=null,this._tempCurAnimationData=null,this._curOriginalData=null,this._lastFrameIndex=-1,this._curAnimationDatas=null,e.__super.call(this),this._animationSprites=[],this._animationSpritesInitLocalMatrix=[]}p(e,"laya.d3.component.animation.RigidAnimations",t);var n=e.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=(h=this._animationSpritesInitLocalMatrix[a])||(this._animationSpritesInitLocalMatrix[a]=new Jt);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(e){t.prototype._load.call(this,e),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*S.timer.scale,n=this._player.cachePlayRate,i=this._player.isCache&&n<=t,r=i?this.currentFrameIndex:-1;if(-1===r||this._lastFrameIndex!==r){var a=this.currentAnimationClipIndex,o=this._templet.getNodes(a),t=this._templet._animationDatasCache;if(i){var s=this._templet.getAnimationDataWithCache(n,t,a,r);if(s)return this._curAnimationDatas=s,this._lastFrameIndex=r,void this._effectAnimation(o)}s=16*o.length;i?this._curAnimationDatas=new Float32Array(s):(this._tempCurAnimationData||(this._tempCurAnimationData=new Float32Array(s)),this._curAnimationDatas=this._tempCurAnimationData),this._curOriginalData||(this._curOriginalData=new Float32Array(this._templet.getTotalkeyframesLength(a))),i?this._templet.getOriginalData(a,this._curOriginalData,this._player._fullFrames[a],r,this._player.currentFrameTime):this._templet.getOriginalDataUnfixedRate(a,this._curOriginalData,this._player.currentPlayTime),wn._computeRootAnimationData(o,this._curOriginalData,this._curAnimationDatas),i&&this._templet.setAnimationDataWithCache(n,t,a,r,this._curAnimationDatas),this._lastFrameIndex=r,this._effectAnimation(o)}}},n._unload=function(e){t.prototype._unload.call(this,e),this._animationSprites=null,this._animationSpritesInitLocalMatrix=null,this._tempCurAnimationData=null,this._curOriginalData=null,this._curAnimationDatas=null},_(0,n,"url",null,function(e){console.log("Warning: discard property,please use templet property instead.");e=S.loader.create(e,null,null,r);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))}),_(0,n,"templet",t.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))})}(dn),function(n){function g(){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,g.__super.call(this),this._boneIndexToMeshList=[]}p(g,"laya.d3.component.animation.SkinAnimations",n);var e=g.prototype;return e._computeBoneIndexToMeshOnTemplet=function(){this._templet.loaded?this._computeBoneIndexToMeshOnMesh():this._templet.once("loaded",this,this._computeBoneIndexToMeshOnMesh)},e._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)},e._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]=[])).length=n;for(var s=i[r],l=0;l<n;l++)o[l]=s.bone3DMap[t[l]]}},e._getAnimationDatasWithCache=function(e,t,n,i,r){i=n[i];if(i){e=i[e];if(e){t=e[t.id];return t?t[r]:null}return null}return null},e._setAnimationDatasWithCache=function(e,t,n,i,r,a){i=n[i]||(n[i]={}),e=i[e]||(i[e]={});(e[t.id]||(e[t.id]=[]))[r]=a},e._onAnimationPlayMeshLoaded=function(){for(var e=this._ownerMesh.meshRender._renderElements,t=0,n=e.length;t<n;t++)e[t]._canDynamicBatch=!1},e._onAnimationPlay=function(){this._ownerMesh._render._addShaderDefine(pr.SHADERDEFINE_BONE);var e=this._ownerMesh.meshFilter.sharedMesh;e.loaded?this._onAnimationPlayMeshLoaded():e.once("loaded",this,this._onAnimationPlayMeshLoaded)},e._onAnimationStop=function(){this._lastFrameIndex=-1,this._player.returnToZeroStopped&&(this._curBonesDatas=null,this._curAnimationDatas=null,this._ownerMesh._render._removeShaderDefine(pr.SHADERDEFINE_BONE));for(var e=this._ownerMesh.meshRender._renderElements,t=0,n=e.length;t<n;t++)e[t]._canDynamicBatch=!0},e._load=function(e){n.prototype._load.call(this,e),this._ownerMesh=e,this._player.on("played",this,this._onAnimationPlay),this._player.on("stopped",this,this._onAnimationStop),this._owner.meshFilter.on("meshchanged",this,this._computeBoneIndexToMeshOnTemplet)},e._update=function(e){var t=this._ownerMesh.meshFilter.sharedMesh;if(2===this._player.state&&this._templet&&this._templet.loaded&&t.loaded){var n=this._player.playbackRate*S.timer.scale,i=this._player.cachePlayRate,r=this._player.isCache&&i<=n,a=r?this.currentFrameIndex:-1;if(-1===a||this._lastFrameIndex!==a){var o=this.currentAnimationClipIndex,s=this._templet._animationDatasCache[0],l=this._templet._animationDatasCache[1];if(r){var h=this._getAnimationDatasWithCache(i,t,l,o,a);if(h)return this._curAnimationDatas=h,this._curBonesDatas=this._templet.getAnimationDataWithCache(i,s,o,a),void(this._lastFrameIndex=a)}var _=!1;r&&(this._curBonesDatas=this._templet.getAnimationDataWithCache(i,s,o,a),_=!!this._curBonesDatas);var u=this._templet.getNodes(o),n=16*u.length,h=t.InverseAbsoluteBindPoses;this._oldVersion?this._curMeshAnimationData||(this._curMeshAnimationData=new Float32Array(n)):this._curMeshAnimationData||(this._curMeshAnimationData=new Float32Array(16*h.length));var d,c=0,f=0,m=0,p=t.getSubMeshCount();if(r){for(this._curAnimationDatas=[],this._curAnimationDatas.length=p,c=0;c<p;c++)for(v=this._curAnimationDatas[c]=[],m=(d=t.getSubMesh(c))._boneIndicesList.length,v.length=m,f=0;f<m;f++)v[f]=new Float32Array(16*d._boneIndicesList[f].length);_||(this._curBonesDatas=new Float32Array(n))}else{if(!this._tempCurAnimationData)for(this._tempCurAnimationData=[],this._tempCurAnimationData.length=p,c=0;c<p;c++)for(v=this._tempCurAnimationData[c]=[],m=(d=t.getSubMesh(c))._boneIndicesList.length,v.length=m,f=0;f<m;f++)v[f]=new Float32Array(16*d._boneIndicesList[f].length);this._tempCurBonesData||(this._tempCurBonesData=new Float32Array(n)),this._curAnimationDatas=this._tempCurAnimationData,this._curBonesDatas=this._tempCurBonesData}for(this._curOriginalData||(this._curOriginalData=new Float32Array(this._templet.getTotalkeyframesLength(o))),r?this._templet.getOriginalData(o,this._curOriginalData,this._player._fullFrames[o],a,this._player.currentFrameTime):this._templet.getOriginalDataUnfixedRate(o,this._curOriginalData,this._player.currentPlayTime),this._oldVersion?r&&_?wn._computeAnimationDatasByArrayAndMatrixFastOld(h,this._curBonesDatas,this._curMeshAnimationData):wn._computeBoneAndAnimationDatasByBindPoseMatrxixOld(u,this._curOriginalData,h,this._curBonesDatas,this._curMeshAnimationData):(n=this._boneIndexToMeshList[o],r&&_?wn._computeAnimationDatasByArrayAndMatrixFast(h,this._curBonesDatas,this._curMeshAnimationData,n):wn._computeBoneAndAnimationDatasByBindPoseMatrxix(u,this._curOriginalData,h,this._curBonesDatas,this._curMeshAnimationData,n)),c=0;c<p;c++)for(var E=t.getSubMesh(c)._boneIndicesList,m=E.length,v=this._curAnimationDatas[c],f=0;f<m;f++)g._splitAnimationDatas(E[f],this._curMeshAnimationData,v[f]);r&&(this._setAnimationDatasWithCache(i,t,l,o,a,this._curAnimationDatas),_||this._templet.setAnimationDataWithCache(i,s,o,a,this._curBonesDatas)),this._lastFrameIndex=a}}},e._preRenderUpdate=function(e){e=e.renderElement.renderObj;this._curAnimationDatas?e._skinAnimationDatas=this._curAnimationDatas[e._indexInMesh]:e._skinAnimationDatas=null},e._unload=function(e){2==this.player.state&&this._ownerMesh._render._removeShaderDefine(pr.SHADERDEFINE_BONE),this._templet&&!this._templet.loaded&&this._templet.off("loaded",this,this._computeBoneIndexToMeshOnMesh);var t=this._ownerMesh.meshFilter.sharedMesh;t.loaded||t.off("loaded",this,this._onAnimationPlayMeshLoaded),n.prototype._unload.call(this,e),this._tempCurAnimationData=null,this._tempCurBonesData=null,this._curOriginalData=null,this._curMeshAnimationData=null,this._curBonesDatas=null,this._curAnimationDatas=null,this._ownerMesh=null},_(0,e,"curBonesDatas",function(){return this._curBonesDatas}),_(0,e,"templet",n.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))}),g._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]},g}(dn)),Ki=function(){function a(){this._size=null,this._transformOrientedBoundBox=null,this.center=null,a.__super.call(this),this._needUpdate=!1}p(a,"laya.d3.component.physics.BoxCollider",ui);var e=a.prototype;return e._updateCollider=function(){var e,t,n,i,r;this._needUpdate&&(i=this._transformOrientedBoundBox.transformation,n=(e=this._owner.transform).rotation,r=e.scale,0===(t=this.center.elements)[0]&&0===t[1]&&0===t[2]?Jt.createAffineTransformation(e.position,n,hn.ONE,i):(hn.multiply(this.center,r,a._deviationV3),hn.transformQuat(a._deviationV3,n,a._deviationV3),hn.add(e.position,a._deviationV3,a._deviationV3),Jt.createAffineTransformation(a._deviationV3,n,hn.ONE,i)),this._transformOrientedBoundBox.transformation=i,n=this._transformOrientedBoundBox.extents.elements,i=this._size.elements,r=r.elements,n[0]=.5*i[0]*r[0],n[1]=.5*i[1]*r[1],n[2]=.5*i[2]*r[2],this._needUpdate=!1)},e._onWorldMatrixChanged=function(){for(var e in this._needUpdate=!0,this._runtimeCollisonMap)this._runtimeCollisonTestMap[e]=!0,this._runtimeCollisonMap[e]._runtimeCollisonTestMap[this.id]=!0},e._initialize=function(e){laya.d3.component.Component3D.prototype._initialize.call(this,e),this._transformOrientedBoundBox=new en(new hn,new Jt),this._size=new hn,this.center=new hn,e.transform.on("worldmatrixneedchanged",this,this._onWorldMatrixChanged),this._needUpdate=!0},e._getType=function(){return 1},e._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:if(0===this.boundBox.containsBoundBox(e._boundBox))return!1;for(var t=e.mesh._positions,n=0,i=t.length;n<i;n++)if(1===this.boundBox.containsPoint(t[n]))return!0;return!1;default:throw new Error("BoxCollider:unknown collider type.")}},e._cloneTo=function(e){var t=e,e=t.size;this.size.cloneTo(e),t.size=e,this.center.cloneTo(t.center)},e.raycast=function(e,t,n){void 0===n&&(n=179e306),this._updateCollider();e=this._transformOrientedBoundBox.intersectsRay(e,t.position);return-1!==e&&e<=n?(t.distance=e,t.sprite3D=this._owner,!0):(t.distance=-1,t.sprite3D=null,!1)},e.setFromBoundBox=function(e){en.createByBoundBox(e,this._transformOrientedBoundBox);var t=this._transformOrientedBoundBox.extents;this._size=new hn(2*t.x,2*t.y,2*t.z),this.center=new hn,hn.add(e.min,e.max,this.center),hn.scale(this.center,.5,this.center),this._needUpdate=!0},_(0,e,"boundBox",function(){return this._updateCollider(),this._transformOrientedBoundBox}),_(0,e,"size",function(){return this._size},function(e){this._size=e,this._needUpdate=!0}),l(a,["_deviationV3",function(){return this._deviationV3=new hn},"_obbCenterV3",function(){return this._obbCenterV3=new hn}]),a}(),qi=function(){function m(){this._transformBoundingBox=null,this._mesh=null,m.__super.call(this),this._transformBoundingBox=new kt(new hn,new hn),this._needUpdate=!1}p(m,"laya.d3.component.physics.MeshCollider",ui);var e=m.prototype;return e._updateBoundBoxCollider=function(){if(this._needUpdate){for(var e=this._owner.transform.worldMatrix,t=this._mesh.boundingBoxCorners,n=0;n<8;n++)hn.transformCoordinate(t[n],e,m._tempBoundBoxCorners[n]);kt.createfromPoints(m._tempBoundBoxCorners,this._transformBoundingBox),this._needUpdate=!1}},e._raycastMesh=function(e,t,n,i){void 0===i&&(i=179e306);var r=t.transform.worldMatrix,a=m._tempMatrix4x40;r.invert(a);var o=e.origin,e=e.direction,s=m._tempRay0;hn.transformCoordinate(o,a,s.origin),hn.TransformNormal(e,a,s.direction);for(var l=Number.MAX_VALUE,h=0,_=this._mesh.getRenderElementsCount();h<_;h++){var u=this._mesh.getRenderElement(h),d=u._getVertexBuffer(0),c=d.getData(),f=u._getIndexBuffer().getData(),u=m._tempRaycastHit;if(yn.rayIntersectsPositionsAndIndices(s,c,d.vertexDeclaration,f,u)){hn.transformCoordinate(u.position,r,u.position);d=m._tempVector30;hn.subtract(o,u.position,d);f=hn.scalarLength(d);if(f<i&&f<l){u.distance=f,u.sprite3D=t;d=u.trianglePositions;hn.transformCoordinate(d[0],r,d[0]),hn.transformCoordinate(d[1],r,d[1]),hn.transformCoordinate(d[2],r,d[2]);d=u.triangleNormals;return hn.transformCoordinate(d[0],r,d[0]),hn.transformCoordinate(d[1],r,d[1]),hn.transformCoordinate(d[2],r,d[2]),l=f,u.cloneTo(n),!0}return!1}}return!1},e._onWorldMatrixChanged=function(){this._needUpdate=!0},e._initialize=function(e){laya.d3.component.Component3D.prototype._initialize.call(this,e),e.transform.on("worldmatrixneedchanged",this,this._onWorldMatrixChanged),this._needUpdate=!0},e._getType=function(){return 2},e._collisonTo=function(e){var t=0,n=0,i=this.mesh._positions;switch(e._getType()){case 0:var r=e;if(0===Zt.sphereContainsBox(r.boundSphere,this._boundBox))return!1;for(t=0,n=i.length;t<n;t++)if(1===Zt.sphereContainsPoint(r.boundSphere,i[t]))return!0;return!1;case 1:var a=e;if(0===a.boundBox.containsBoundBox(this._boundBox))return!1;for(t=0,n=i.length;t<n;t++)if(1===a.boundBox.containsPoint(i[t]))return!0;return!1;case 2:return 1!==Zt.intersectsBoxAndBox(e._boundBox,this._boundBox);default:throw new Error("MeshCollider:unknown collider type.")}},e._cloneTo=function(e){e.mesh=this._mesh},e.raycast=function(e,t,n){if(void 0===n&&(n=179e306),null==this._mesh||!this._mesh.loaded)return!1;var i=Zt.intersectsRayAndBoxRD(e,this._boundBox);return!!(-1!==i&&i<=n&&this._raycastMesh(e,this._owner,t,n))||(t.distance=-1,t.sprite3D=null,!1)},_(0,e,"_boundBox",function(){return this._updateBoundBoxCollider(),this._transformBoundingBox}),_(0,e,"mesh",function(){return this._mesh},function(e){this._mesh=e}),l(m,["_tempRay0",function(){return this._tempRay0=new on(new hn,new hn)},"_tempVector30",function(){return this._tempVector30=new hn},"_tempMatrix4x40",function(){return this._tempMatrix4x40=new Jt},"_tempRaycastHit",function(){return this._tempRaycastHit=new Nn},"_tempBoundBoxCorners",function(){return this._tempBoundBoxCorners=[new hn,new hn,new hn,new hn,new hn,new hn,new hn,new hn]}]),m}(),Qi=function(){function e(){this._originalBoundSphere=null,this._transformBoundSphere=null,e.__super.call(this),this._needUpdate=!1}p(e,"laya.d3.component.physics.SphereCollider",ui);var t=e.prototype;return t._updateCollider=function(){var e,t,n;this._needUpdate&&(n=NaN,n=(t=(e=this._owner.transform).scale).x>=t.y&&t.x>=t.z?t.x:t.y>=t.z?t.y:t.z,hn.transformCoordinate(this._originalBoundSphere.center,e.worldMatrix,this._transformBoundSphere.center),this._transformBoundSphere.radius=this._originalBoundSphere.radius*n,this._needUpdate=!1)},t._onWorldMatrixChanged=function(){for(var e in this._needUpdate=!0,this._runtimeCollisonMap)this._runtimeCollisonTestMap[e]=!0,this._runtimeCollisonMap[e]._runtimeCollisonTestMap[this.id]=!0},t._initialize=function(e){laya.d3.component.Component3D.prototype._initialize.call(this,e),this._originalBoundSphere=new Yt(new hn(0,0,0),.5),this._transformBoundSphere=new Yt(new hn(0,0,0),.5),e.transform.on("worldmatrixneedchanged",this,this._onWorldMatrixChanged),this._needUpdate=!0},t._getType=function(){return 0},t._collisonTo=function(e){switch(e._getType()){case 0:return 0!==Zt.sphereContainsSphere(this.boundSphere,e.boundSphere);case 1:return 0!==e.boundBox.containsSphere(this.boundSphere);case 2:var t=e;if(0===Zt.sphereContainsBox(this.boundSphere,t._boundBox))return!1;for(var n=t.mesh._positions,i=0,r=n.length;i<r;i++)if(1===Zt.sphereContainsPoint(this.boundSphere,n[i]))return!0;return!1;default:throw new Error("SphereCollider:unknown collider type.")}},t._cloneTo=function(e){var t=e;t.radius=this.radius;e=t.center;this.center.cloneTo(e),t.center=e},t.raycast=function(e,t,n){void 0===n&&(n=179e306),this._updateCollider();e=this._transformBoundSphere.intersectsRayPoint(e,t.position);return-1!==e&&e<=n?(t.distance=e,t.sprite3D=this._owner,!0):(t.distance=-1,t.sprite3D=null,!1)},_(0,t,"center",function(){return this._originalBoundSphere.center},function(e){this._originalBoundSphere.center=e}),_(0,t,"radius",function(){return this._originalBoundSphere.radius},function(e){this._originalBoundSphere.radius=e}),_(0,t,"boundSphere",function(){return this._updateCollider(),this._transformBoundSphere}),e}(),$i=function(){function c(){this.simLodInfo=null,this._src=null,this._buffer=null,this._mipmaps=null,this._recreateLock=!1,this._needReleaseAgain=!1,c.__super.call(this),this._type=3553}p(c,"laya.d3.resource.DataTexture2D",ai);var e=c.prototype;return e.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},e._onTextureLoaded=function(e){},e._createWebGlTexture=function(){if(!this._buffer&&!this._mipmaps)throw"create GLTextur err:no data";var e=N.mainContext;e.getExtension("EXT_shader_texture_lod");var t=this._source=e.createTexture(),n=this._width,i=this._height,r=V.curBindTexTarget,a=V.curBindTexValue;if(V.bindTexture(e,this._type,t),this._mipmaps){if(laya.d3.resource.DataTexture2D.lodasatlas){var o=0;e.texImage2D(this._type,0,6408,this._width,this._height,0,6408,5121,null);for(var s=0;s<this._mipmaps.length;s++){if(this._mipmaps[s].byteLength!=l*h*4)throw"mipmap size error level:"+s;e.texSubImage2D(this._type,0,c.simLodRect[o++],c.simLodRect[o++],c.simLodRect[o++],c.simLodRect[o++],6408,5121,new Uint8Array(this._mipmaps[s]))}this.minFifter=9729,this.magFifter=9729}else{var l=this._width,h=this._height,o=0;for(e.texImage2D(this._type,0,6408,this._width,this._height,0,6408,5121,null),s=0;s<this._mipmaps.length;s++){if(this._mipmaps[s].byteLength!=l*h*4)throw"mipmap size error level:"+s;e.texImage2D(this._type,s,6408,l,h,0,6408,5121,new Uint8Array(this._mipmaps[s])),(l/=2)<1&&(l=1),(h/=2)<1&&(h=1),this.minFifter=9987,this.magFifter=9729}}this.mipmap=!1}else e.texImage2D(this._type,0,6408,n,i,0,6408,5121,new Uint8Array(this._buffer));var _=this._minFifter,u=this._magFifter,d=this._repeat?10497:33071,t=f.isPOT(n,i);if(!t)throw"data texture must be POT";this._mipmap||this._mipmaps?-1!==_||(_=9987):-1!==_||(_=9729),-1!==u||(u=9729),e.texParameteri(this._type,10241,_),e.texParameteri(this._type,10240,u),e.texParameteri(this._type,10242,d),this._mipmaps?e.texParameteri(this._type,10243,33071):e.texParameteri(this._type,10243,d),this._mipmap&&e.generateMipmap(this._type),r&&a&&V.bindTexture(e,r,a),this.src&&0<this.src.length&&(this._buffer=null),this.memorySize=t?n*i*4*(1+1/3):n*i*4,this._recreateLock=!1},e.recreateResource=function(){(this._buffer||null!=this._src&&""!==this._src)&&(this._needReleaseAgain=!1,this._buffer||this._mipmaps?this._recreateLock||(this._createWebGlTexture(),this.completeCreate()):this._recreateLock=!0)},e.onAsynLoaded=function(e,t,n){var i;(i=n?n[0].call(this,t):i)&&(this._width=i.width,this._height=i.height,this._buffer=i.data),this._src=e,this._size=new Ln(this._width,this._height),this._conchTexture?alert("怎么给runtime传递datatexture数据"):this.activeResource(),this._endLoaded()},e.getPixels=function(){return new Uint8Array(this._buffer)},e.disposeResource=function(){this._recreateLock&&(this._needReleaseAgain=!0),this._source&&(N.mainContext.deleteTexture(this._source),this._source=null,this._buffer=null,this.memorySize=0)},_(0,e,"src",function(){return this._src}),c.create=function(e,t,n,i,r,a){if(void 0===i&&(i=9729),void 0===r&&(r=9729),void 0===a&&(a=!0),!e||e.byteLength<t*n*4)throw"DataTexture2D create error";var o=new c;return o._buffer=e,o._width=t,o._height=n,o._mipmap=a,o._magFifter=i,o._minFifter=r,o._size=new Ln(o._width,o._height),o._conchTexture?alert("怎么给runtime传递datatexture数据"):o.activeResource(),o},c.load=function(e,t,n,i,r){if(void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=9729),void 0===r&&(r=9729),"mipmaps"===y.getFileExtension(e)){var a=S.loader.create(e,null,null,c,[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){a.simLodInfo=new Float32Array(40);for(var o=0;o<a.simLodInfo.length;)a.simLodInfo[o]=(c.simLodRect[o]+.5)/1024,a.simLodInfo[++o]=(c.simLodRect[o]+.5)/256,a.simLodInfo[++o]=Math.max(c.simLodRect[o]-1,.1)/1024,a.simLodInfo[++o]=Math.max(c.simLodRect[o]-1.5,.1)/256,o++}return a}if("number"==typeof t)return S.loader.create(e,null,null,c,[function(e){return this._width=t,this._height=n,this._buffer=e,null}]);if("function"==typeof t)return S.loader.create(e,null,null,c,[t]);throw new Error("unknown params.")},c.lodasatlas=!1,l(c,["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])}]),c}(),Ji=function(){function e(){this._numberVertices=0,this._numberIndices=0,this._vertexBuffer=null,this._indexBuffer=null,e.__super.call(this)}p(e,"laya.d3.resource.models.PrimitiveMesh",oi);var t=e.prototype;return S.imps(t,{"laya.d3.core.render.IRenderable":!0}),t._getVertexBuffer=function(e){return 0===(e=void 0===e?0:e)?this._vertexBuffer:null},t._getVertexBuffers=function(){return null},t._getIndexBuffer=function(){return this._indexBuffer},t._getPositions=function(){for(var e,t=[],n=this._vertexBuffer.vertexDeclaration.getVertexElements(),i=0,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,o=new hn(a[o+0],a[o+1],a[o+2]);t.push(o)}return t},t.getRenderElement=function(e){return this},t.getRenderElementsCount=function(){return 1},t.disposeResource=function(){this._vertexBuffer&&(this._vertexBuffer.destroy(),this._vertexBuffer=null),this._indexBuffer&&(this._indexBuffer.destroy(),this._indexBuffer=null),this.memorySize=0},t._beforeRender=function(e){return this._vertexBuffer._bind(),this._indexBuffer._bind(),!0},t._render=function(e){N.mainContext.drawElements(4,this._numberIndices,5123,0),I.drawCall++,I.trianglesFaces+=this._numberIndices/3},_(0,t,"_vertexBufferCount",function(){return 1}),_(0,t,"triangleCount",function(){return this._indexBuffer.indexCount/3}),e}(),er=function(){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=[]}p(t,"laya.d3.resource.models.Mesh",oi);var e=t.prototype;return e._getPositions=function(){var e,t,n,i=[],r=0,a=0,o=0;if(0!==this._vertexBuffers.length)for(var s=this._vertexBuffers.length,r=0;r<s;r++){for(_=(h=this._vertexBuffers[r]).vertexDeclaration.getVertexElements(),a=0;a<_.length;a++)if("vector3"===(t=_[a]).elementFormat&&0===t.elementUsage){e=t;break}for(n=h.getData(),a=0;a<n.length;a+=h.vertexDeclaration.vertexStride/4)o=a+e.offset/4,i.push(new hn(n[o+0],n[o+1],n[o+2]))}else{var l=this._subMeshes.length;for(r=0;r<l;r++){for(var h,_=(h=this._subMeshes[r]._getVertexBuffer()).vertexDeclaration.getVertexElements(),a=0;a<_.length;a++)if("vector3"===(t=_[a]).elementFormat&&0===t.elementUsage){e=t;break}for(n=h.getData(),a=0;a<n.length;a+=h.vertexDeclaration.vertexStride/4)o=a+e.offset/4,i.push(new hn(n[o+0],n[o+1],n[o+2]))}}return i},e._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()},e.onAsynLoaded=function(e,t,n){var i=t[0],t=t[1];zt.read(i,this,this._materials,this._subMeshes,t),this.completeCreate(),this._endLoaded()},e.getSubMesh=function(e){return this._subMeshes[e]},e.getSubMeshCount=function(){return this._subMeshes.length},e.getRenderElementsCount=function(){return this._subMeshes.length},e.getRenderElement=function(e){return this._subMeshes[e]},e.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},_(0,e,"materials",function(){return this._materials.slice()}),_(0,e,"InverseAbsoluteBindPoses",function(){return this._inverseBindPoses}),t.load=function(e){return S.loader.create(e,null,null,t)},t}(),tr=function(){function h(e,t,n,i,r,a,o,s,l){this._alreadyResolved=!1,this._surfaceFormat=0,this._surfaceType=0,this._depthStencilFormat=0,this._frameBuffer=null,this._depthStencilBuffer=null,void 0===n&&(n=6408),void 0===i&&(i=5121),void 0===r&&(r=33189),void 0===a&&(a=!1),void 0===o&&(o=!1),void 0===s&&(s=-1),void 0===l&&(l=-1),h.__super.call(this),this._type=3553,this._width=e,this._height=t,this._size=new Ln(e,t),this._surfaceFormat=n,this._surfaceType=i,this._depthStencilFormat=r,m.isConchWebGL&&34041===this._depthStencilFormat&&(this._depthStencilFormat=33189),this._mipmap=a,this._repeat=o,this._minFifter=s,this._magFifter=l,this.activeResource(),this._alreadyResolved=!0}p(h,"laya.d3.resource.RenderTexture",ai);var e=h.prototype;return e.recreateResource=function(){var e=N.mainContext;this._frameBuffer=e.createFramebuffer(),this._source=e.createTexture();var t=V.curBindTexTarget,n=V.curBindTexValue;V.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(f.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!==r||(r=9729),e.texParameteri(this._type,10241,i=-1===i?9729: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&&V.bindTexture(e,t,n),e.bindRenderbuffer(36161,null),this.memorySize=this._width*this._height*4,this.completeCreate()},e.start=function(){N.mainContext.bindFramebuffer(36160,this.frameBuffer),(h._currentRenderTarget=this)._alreadyResolved=!1},e.end=function(){N.mainContext.bindFramebuffer(36160,null),h._currentRenderTarget=null,this._alreadyResolved=!0},e.getData=function(e,t,n,i){var r=N.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},e.disposeResource=function(){var e;this._frameBuffer&&((e=N.mainContext).deleteTexture(this._source),e.deleteFramebuffer(this._frameBuffer),e.deleteRenderbuffer(this._depthStencilBuffer),this._source=null,this._frameBuffer=null,this._depthStencilBuffer=null,this.memorySize=0)},_(0,e,"surfaceFormat",function(){return this._surfaceFormat}),_(0,e,"surfaceType",function(){return this._surfaceType}),_(0,e,"depthStencilFormat",function(){return this._depthStencilFormat}),_(0,e,"source",function(){return this._alreadyResolved?S.superGet(ai,this,"source"):null}),_(0,e,"depthStencilBuffer",function(){return this._depthStencilBuffer}),_(0,e,"frameBuffer",function(){return this._frameBuffer}),h._currentRenderTarget=null,h}(),nr=function(){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 Ln(this.width,this.height),this._color=e,this._pixels=new Uint8Array([255*e.x,255*e.y,255*e.z,255*e.w])}p(t,"laya.d3.resource.SolidColorTexture2D",ai);var e=t.prototype;return e._createWebGlTexture=function(){var e=N.mainContext,t=this._source=e.createTexture(),n=this._width,i=this._height,r=V.curBindTexTarget,a=V.curBindTexValue;V.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,t=f.isPOT(n,i);t?(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!==s||(s=9729),e.texParameteri(this._type,10241,o=-1===o?9729:o),e.texParameteri(this._type,10240,s),e.texParameteri(this._type,10242,33071),e.texParameteri(this._type,10243,33071)),r&&a&&V.bindTexture(e,r,a),this.memorySize=t?n*i*4*(1+1/3):n*i*4},e.recreateResource=function(){this._createWebGlTexture(),this.completeCreate()},e.disposeResource=function(){this._source&&(N.mainContext.deleteTexture(this._source),this._source=null,this.memorySize=0)},l(t,["magentaTexture",function(){return this.magentaTexture=new t(new _n(1,0,1,1))},"grayTexture",function(){return this.grayTexture=new t(new _n(.5,.5,.5,1))}]),t}(),ir=function(){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 Ln(this.width,this.height),this._color=e,this._pixels=new Uint8Array([255*e.x,255*e.y,255*e.z,255*e.w])}p(t,"laya.d3.resource.SolidColorTextureCube",ai);var e=t.prototype;return e._createWebGlTexture=function(){var e=N.mainContext,t=this._source=e.createTexture(),n=this._width,i=this._height,r=V.curBindTexTarget,a=V.curBindTexValue;V.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,t=f.isPOT(n,i);t?(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!==s||(s=9729),e.texParameteri(this._type,10241,o=-1===o?9729:o),e.texParameteri(this._type,10240,s),e.texParameteri(this._type,10242,33071),e.texParameteri(this._type,10243,33071)),r&&a&&V.bindTexture(e,r,a),this.memorySize=t?n*i*4*(1+1/3)*this._texCount:n*i*4*this._texCount},e.recreateResource=function(){this._createWebGlTexture(),this.completeCreate()},e.disposeResource=function(){this._source&&(N.mainContext.deleteTexture(this._source),this._source=null,this.memorySize=0)},l(t,["magentaTexture",function(){return this.magentaTexture=new t(new _n(1,0,1,1))},"grayTexture",function(){return this.grayTexture=new t(new _n(.5,.5,.5,1))}]),t}(),rr=function(){function r(e,t,n,i){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===i&&(i=!0),r.__super.call(this),this._type=3553,this._repeat=t,this._canRead=e,this._format=n,this._mipmap=i}p(r,"laya.d3.resource.Texture2D",ai);var e=r.prototype;return e._createWebGlTexture=function(){if(!this._image)throw"create GLTextur err:no data:"+this._image;var e=N.mainContext,t=this._source=e.createTexture(),n=this._width,i=this._height,r=V.curBindTexTarget,a=V.curBindTexValue;switch(V.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 N.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=0==this._wrapModeU?10497:33071,_=0==this._wrapModeV?10497:33071,t=f.isPOT(n,i);t?(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),e.texParameteri(this._type,10242,h),e.texParameteri(this._type,10243,_),this._mipmap&&e.generateMipmap(this._type)):(-1!==s||(s=9729),e.texParameteri(this._type,10241,o=-1===o?9729:o),e.texParameteri(this._type,10240,s),e.texParameteri(this._type,10242,33071),e.texParameteri(this._type,10243,33071)),r&&a&&V.bindTexture(e,r,a),this._image.onload=null,this._image=null,this.memorySize=t?n*i*4*(1+1/3):n*i*4},e.recreateResource=function(){this._createWebGlTexture(),this.completeCreate()},e.onAsynLoaded=function(e,t,n){var i;switch(n&&(void 0!==(i=n[0])&&(this._canRead=i),void 0!==(i=n[1])&&(this._repeat=i),void 0!==(i=n[2])&&(this._format=i),void 0!==(i=n[3])&&(this._mipmap=i),void 0!==(i=n.wrapModeU)&&(this._wrapModeU=i),void 0!==(n=n.wrapModeV)&&(this._wrapModeV=n)),this._format){case 6407:case 6408:var r=(this._image=t).width,a=t.height;this._width=r,this._height=a,this._size=new Ln(r,a),this._canRead&&(m.isConchApp?t instanceof c.HTMLElement&&(this._pixels=new Uint8Array(t.getImageData(0,0,r,a))):(x.canvas.size(r,a),x.canvas.clear(),x.context.drawImage(t,0,0,r,a),this._pixels=new Uint8Array(x.context.getImageData(0,0,r,a).data.buffer)));break;case N.compressEtc1.COMPRESSED_RGB_ETC1_WEBGL:a=new g(t),a.readUTFBytes(4),a.readUTFBytes(2),a.getInt16();a.endian="bigEndian",this._width=a.getInt16(),this._height=a.getInt16(),this._size=new Ln(this._width,this._height);a.getInt16(),a.getInt16();this._image=new Uint8Array(t,a.pos)}this.recreateResource(),this._endLoaded()},e.getPixels=function(){if(this._canRead)return this._pixels;throw new Error("Texture2D: must set texture canRead is true.")},e.disposeResource=function(){this._source&&(N.mainContext.deleteTexture(this._source),this._source=null,this._image=null,this.memorySize=0)},_(0,e,"_src",function(){return this.url}),_(0,e,"src",function(){return this.url}),r.load=function(e){return S.loader.create(e,null,null,r)},r}(),ar=function(){function t(){t.__super.call(this),this._type=34067}p(t,"laya.d3.resource.TextureCube",ai);var e=t.prototype;return e._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 Ln(t,n)},e._createWebGlTexture=function(){for(var e=0,e=0;e<6;e++)if(!this._images[e])throw"create GLTextur err:no data:"+this._images[e];var t=N.mainContext,n=this._source=t.createTexture(),i=this._width,r=this._height,a=V.curBindTexTarget,o=V.curBindTexValue;V.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,n=f.isPOT(i,r);for(n?(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!==l||(l=9729),t.texParameteri(this._type,10241,s=-1===s?9729:s),t.texParameteri(this._type,10240,l),t.texParameteri(this._type,10242,33071),t.texParameteri(this._type,10243,33071)),a&&o&&V.bindTexture(t,a,o),e=0;e<6;e++)this._images[e].onload=null,this._images[e]=null;this.memorySize=n?i*r*4*(1+1/3)*6:i*r*4*6},e.recreateResource=function(){null!=this._url&&(this._createWebGlTexture(),this.completeCreate())},e.onAsynLoaded=function(e,t,n){this._onTextureLoaded(t),this.activeResource(),this._endLoaded()},e.disposeResource=function(){this._source&&(N.mainContext.deleteTexture(this._source),this._source=null,this.memorySize=0)},_(0,e,"defaulteTexture",function(){return ir.grayTexture}),t.load=function(e){return S.loader.create(e,null,null,t)},t}(),or=function(i){function m(e){this._hasIndependentBound=!0,m.__super.call(this,e),this._owner.transform.off("worldmatrixneedchanged",this,this._onWorldMatNeedChange),this._cacheAnimationNodeIndex=[],this._cacheAnimationNode=[],this._localBoundingBoxCorners=v(8,null),this._owner.meshFilter.on("meshchanged",this,this._$3__onMeshChanged)}p(m,"laya.d3.core.SkinnedMeshRender",i);var e=m.prototype;return e._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)}},e._offComputeBoneIndexToMeshEvent=function(e,t){e.loaded?t.loaded||t.off("loaded",this,this._getCacheAnimationNodes):e.off("loaded",this,this._computeBoneIndexToMeshWithAsyncMesh)},e._computeBoneIndexToMeshWithAsyncAvatar=function(){this._cacheAvatar.loaded?this._computeBoneIndexToMeshWithAsyncMesh():this._cacheAvatar.once("loaded",this,this._computeBoneIndexToMeshWithAsyncMesh)},e._computeBoneIndexToMeshWithAsyncMesh=function(){this._cacheMesh.loaded?this._getCacheAnimationNodes():this._cacheMesh.on("loaded",this,this._getCacheAnimationNodes)},e._$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())},e._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)},e._setCacheAnimator=function(e){this._cacheAnimator=e,this._rootBone&&(this._rootIndex=e._avatarNodes.indexOf(e._avatarNodeMap[this._rootBone]))},e._setRootBone=function(e){this._rootBone=e,this._cacheAnimator&&(this._rootIndex=this._cacheAnimator._avatarNodes.indexOf(this._cacheAnimator._avatarNodeMap[e]))},e._setCacheAvatar=function(e){this._cacheAvatar!==e&&(this._cacheMesh?(this._cacheAvatar&&this._offComputeBoneIndexToMeshEvent(this._cacheAvatar,this._cacheMesh),(this._cacheAvatar=e)&&(this._addShaderDefine(pr.SHADERDEFINE_BONE),this._computeBoneIndexToMeshWithAsyncAvatar())):this._cacheAvatar=e)},e._calculateBoundingBox=function(){var e,t,n;this._hasIndependentBound?this._cacheAnimator&&(t=(e=this._owner.transform).worldMatrix,this._cacheAnimator._canCache?(n=this._cacheAnimator._curAvatarNodeDatas,wn.matrix4x4MultiplyMFM(this._cacheAnimator.owner.transform.worldMatrix,n[this._rootIndex],t)):wn.matrix4x4MultiplyMFM(this._cacheAnimator.owner.transform.worldMatrix,this._cacheAnimator._avatarNodeMap[this._rootBone].transform.getWorldMatrix(),t),e.worldMatrix=t,null==this._cacheAnimator._avatarNodeMap[this._rootBone]||null==this._localBoundBox?this._boundingBox.toDefault():this._calculateBoundBoxByInitCorners(this._localBoundingBoxCorners)):i.prototype._calculateBoundingBox.call(this)},e._calculateBoundingSphere=function(){var e,t,n;this._hasIndependentBound?this._cacheAnimator&&(t=(e=this._owner.transform).worldMatrix,this._cacheAnimator._canCache?(n=this._cacheAnimator._curAvatarNodeDatas,wn.matrix4x4MultiplyMFM(this._cacheAnimator.owner.transform.worldMatrix,n[this._rootIndex],t)):wn.matrix4x4MultiplyMFM(this._cacheAnimator.owner.transform.worldMatrix,this._cacheAnimator._avatarNodeMap[this._rootBone].transform.getWorldMatrix(),t),e.worldMatrix=t,null==this._cacheAnimator._avatarNodeMap[this._rootBone]||null==this.localBoundSphere?this._boundingSphere.toDefault():this._calculateBoundingSphereByInitSphere(this.localBoundSphere)):i.prototype._calculateBoundingSphere.call(this)},e._updateOctreeNode=function(){var e=this._treeNode;e&&e.updateObject(this)},e._renderUpdate=function(e){var t=this._cacheAnimator,n=this._cacheMesh.subMeshCount,i=this._owner.transform;if(t){var r=t._canCache,a=this._cacheAnimator._curAvatarNodeDatas,o=t.owner;if(this._setShaderValueMatrix4x4(0,o._transform.worldMatrix),o=o.getProjectionViewWorldMatrix(e),this._setShaderValueMatrix4x4(1,o),this._cacheMesh&&this._cacheMesh.loaded&&this._cacheAvatar&&this._cacheAvatar.loaded){var s=0,l=0,h=this._cacheMesh._inverseBindPoses,_=this._cacheMesh._skinnedDatas;if(r)for(s=0,l=h.length;s<l;s++)wn._mulMatrixArray(a[this._cacheAnimationNodeIndex[s]],h[s],_,16*s);else for(s=0,l=h.length;s<l;s++)wn._mulMatrixArray(this._cacheAnimationNode[s].transform.getWorldMatrix(),h[s],_,16*s);for(s=0;s<n;s++){for(var u=this._cacheMesh.getSubMesh(s)._boneIndicesList,d=u.length,c=this._subSkinnedDatas[s],f=0;f<d;f++)m._splitAnimationDatas(u[f],_,c[f]);this._renderElements[s]._skinAnimationDatas=c}}}else this._setShaderValueMatrix4x4(0,i.worldMatrix),o=this._owner.getProjectionViewWorldMatrix(e),this._setShaderValueMatrix4x4(1,o);return Pn.debugMode&&this._renderRenderableBoundBox(),!0},_(0,e,"localBoundBox",function(){return this._localBoundBox},function(e){(this._localBoundBox=e).getCorners(this._localBoundingBoxCorners)}),_(0,e,"boundingSphere",function(){return this._calculateBoundingSphere(),this._boundingSphere}),_(0,e,"boundingBox",function(){return this._calculateBoundingBox(),this._boundingBox}),_(0,e,"boundingBoxCenter",function(){var e=this.boundingBox;return hn.add(e.min,e.max,this._boundingBoxCenter),hn.scale(this._boundingBoxCenter,.5,this._boundingBoxCenter),this._boundingBoxCenter}),m._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]},m}(mi),sr=function(t){function n(e,t){n.__super.call(this),void 0===e&&(e=.3),void 0===t&&(t=1e3),this._tempVector3=new hn,this._position=new hn,this._up=new hn,this._forward=new hn,this._right=new hn,this._fieldOfView=60,this._useUserProjectionMatrix=!1,this._orthographic=!1,this._viewportExpressedInClipSpace=!0,this._renderTargetSize=Ln.fullScreen,this._orthographicVerticalSize=10,this.renderingOrder=0,this._nearPlane=e,this._farPlane=t,this.cullingMask=2147483647,this.clearFlag=0,this.useOcclusionCulling=!0,this._calculateProjectionMatrix(),S.stage.on("resize",this,this._onScreenSizeChanged)}p(n,"laya.d3.core.BaseCamera",t);var e=n.prototype;return e._sortCamerasByRenderingOrder=function(){if(this._displayedInStage)for(var e,t=this.scene._cameraPool,n=t.length-1,i=0;i<n;i++)t[i].renderingOrder>t[n].renderingOrder&&(e=t[i],t[i]=t[n],t[n]=e)},e._calculateProjectionMatrix=function(){},e._onScreenSizeChanged=function(){this._calculateProjectionMatrix()},e._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)},e._prepareCameraViewProject=function(e,t){var n=this._shaderValues;n.setValue(1,e.elements),n.setValue(2,t.elements)},e._renderCamera=function(e,t,n){},e.addLayer=function(e){29!==e.number&&30!=e.number&&(this.cullingMask=this.cullingMask|e.mask)},e.removeLayer=function(e){29!==e.number&&30!=e.number&&(this.cullingMask=this.cullingMask&~e.mask)},e.addAllLayers=function(){this.cullingMask=2147483647},e.removeAllLayers=function(){this.cullingMask=0|Z.getLayerByNumber(29).mask|Z.getLayerByNumber(30).mask},e.ResetProjectionMatrix=function(){this._useUserProjectionMatrix=!1,this._calculateProjectionMatrix()},e.moveForward=function(e){this._tempVector3.elements[0]=this._tempVector3.elements[1]=0,this._tempVector3.elements[2]=e,this.transform.translate(this._tempVector3)},e.moveRight=function(e){this._tempVector3.elements[1]=this._tempVector3.elements[2]=0,this._tempVector3.elements[0]=e,this.transform.translate(this._tempVector3)},e.moveVertical=function(e){this._tempVector3.elements[0]=this._tempVector3.elements[2]=0,this._tempVector3.elements[1]=e,this.transform.translate(this._tempVector3,!1)},e._addSelfRenderObjects=function(){var e=this.scene._cameraPool,t=e.length;if(0<t){for(var n=t-1;0<=n;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)},e._clearSelfRenderObjects=function(){var e=this.scene._cameraPool;e.splice(e.indexOf(this),1)},e.destroy=function(e){void 0===e&&(e=!0),this._sky&&this._sky.destroy(),this.renderTarget=null,S.stage.off("resize",this,this._onScreenSizeChanged),t.prototype.destroy.call(this,e)},_(0,e,"sky",function(){return this._sky},function(e){(this._sky=e)._ownerCamera=this}),_(0,e,"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}),_(0,e,"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}),_(0,e,"renderTarget",function(){return this._renderTarget},function(e){null!=(this._renderTarget=e)&&(this._renderTargetSize=e.size)}),_(0,e,"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}),_(0,e,"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}),_(0,e,"renderTargetSize",function(){return this._renderTargetSize},function(e){null!=this.renderTarget&&this._renderTargetSize,this._renderTargetSize=e,this._calculateProjectionMatrix()}),_(0,e,"fieldOfView",function(){return this._fieldOfView},function(e){this._fieldOfView=e,this._calculateProjectionMatrix()}),_(0,e,"nearPlane",function(){return this._nearPlane},function(e){this._nearPlane=e,this._calculateProjectionMatrix()}),_(0,e,"farPlane",function(){return this._farPlane},function(e){this._farPlane=e,this._calculateProjectionMatrix()}),_(0,e,"orthographic",function(){return this._orthographic},function(e){this._orthographic=e,this._calculateProjectionMatrix()}),_(0,e,"orthographicVerticalSize",function(){return this._orthographicVerticalSize},function(e){this._orthographicVerticalSize=e,this._calculateProjectionMatrix()}),_(0,e,"renderingOrder",function(){return this._renderingOrder},function(e){this._renderingOrder=e,this._sortCamerasByRenderingOrder()}),n.CAMERAPOS=0,n.VIEWMATRIX=1,n.PROJECTMATRIX=2,n.VPMATRIX=3,n.VPMATRIX_NO_TRANSLATE=4,n.CAMERADIRECTION=5,n.CAMERAUP=6,n.ENVIRONMENTDIFFUSE=7,n.ENVIRONMENTSPECULAR=8,n.SIMLODINFO=9,n.DIFFUSEIRRADMATR=10,n.DIFFUSEIRRADMATG=11,n.DIFFUSEIRRADMATB=12,n.HDREXPOSURE=13,n.RENDERINGTYPE_DEFERREDLIGHTING="DEFERREDLIGHTING",n.RENDERINGTYPE_FORWARDRENDERING="FORWARDRENDERING",n.CLEARFLAG_SOLIDCOLOR=0,n.CLEARFLAG_SKY=1,n.CLEARFLAG_DEPTHONLY=2,n.CLEARFLAG_NONE=3,l(n,["_invertYScaleMatrix",function(){return this._invertYScaleMatrix=new Jt(1,0,0,0,0,-1,0,0,0,0,1,0,0,0,0,1)},"_invertYProjectionMatrix",function(){return this._invertYProjectionMatrix=new Jt},"_invertYProjectionViewMatrix",function(){return this._invertYProjectionViewMatrix=new Jt}]),n}(Ci),lr=function(n){function t(e){this._render=null,this._geometryFilter=null,t.__super.call(this,e)}p(t,"laya.d3.core.RenderableSprite3D",n);var e=t.prototype;return e._addToInitStaticBatchManager=function(){},e._setBelongScene=function(e){n.prototype._setBelongScene.call(this,e),e._renderableSprite3Ds.push(this),this._render._applyLightMapParams()},e._setUnBelongScene=function(){var e=this._scene._renderableSprite3Ds,t=e.indexOf(this);e.splice(t,1),this._render._removeShaderDefine(laya.d3.core.RenderableSprite3D.SAHDERDEFINE_LIGHTMAP),n.prototype._setUnBelongScene.call(this)},e._update=function(e){(e.owner=this)._activeInHierarchy&&(this._updateComponents(e),this._render._updateOctreeNode(),this._lateUpdateComponents(e),I.spriteCount++,this._childs.length&&this._updateChilds(e))},e.destroy=function(e){n.prototype.destroy.call(this,e=void 0===e?!0:e),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,l(t,["shaderDefines",function(){return this.shaderDefines=new fn}]),t}(Ci),hr=function(){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 hn,this.color=new hn(1,1,1),this._shadow=!1,this._shadowFarPlane=8,this._shadowMapSize=512,this._shadowMapCount=1,this._shadowMapPCFType=0,this._lightmapBakedType=t.LIGHTMAPBAKEDTYPE_REALTIME}p(t,"laya.d3.core.light.LightSprite",Ci);var e=t.prototype;return e._parseCustomProps=function(e,t,n,i){var r=n.color,n=this.color.elements;n[0]=r[0],n[1]=r[1],n[2]=r[2]},e._addSelfRenderObjects=function(){this.lightmapBakedType!==t.LIGHTMAPBAKEDTYPE_BAKED&&this._scene._addLight(this)},e._clearSelfRenderObjects=function(){this.lightmapBakedType!==t.LIGHTMAPBAKEDTYPE_BAKED&&this._scene._removeLight(this)},e._prepareToScene=function(e){return!1},_(0,e,"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)))}),_(0,e,"shadowPCFType",function(){return this._shadowMapPCFType},function(e){this._shadowMapPCFType=e,this._parallelSplitShadowMap&&this._parallelSplitShadowMap.setPCFType(e)}),_(0,e,"intensity",function(){return this._intensity},function(e){this._intensity=e}),_(0,e,"shadow",function(){return this._shadow},function(e){throw new Error("LightSprite: must override it.")}),_(0,e,"shadowDistance",function(){return this._shadowFarPlane},function(e){this._shadowFarPlane=e,this._parallelSplitShadowMap&&this._parallelSplitShadowMap.setFarDistance(e)}),_(0,e,"shadowPSSMCount",function(){return this._shadowMapCount},function(e){this._shadowMapCount=e,this._parallelSplitShadowMap&&(this._parallelSplitShadowMap.PSSMNum=e)}),_(0,e,"shadowResolution",function(){return this._shadowMapSize},function(e){this._shadowMapSize=e,this._parallelSplitShadowMap&&this._parallelSplitShadowMap.setShadowMapTextureSize(e)}),_(0,e,"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}(),_r=function(){function s(e){this._terrainRes=null,this._lightmapScaleOffset=null,s.__super.call(this),this._lightmapScaleOffset=new _n(1,1,0,0),e&&((this._terrainRes=e).loaded?this.buildTerrain(e):e.once("loaded",this,this.buildTerrain))}p(s,"laya.d3.terrain.Terrain",Ci);var e=s.prototype;return e._parseCustomProps=function(e,t,n,i){this.terrainRes=W.getRes(t[n.dataPath]);t=n.lightmapIndex;null!=t&&this.setLightmapIndex(t);n=n.lightmapScaleOffset;n&&this.setLightmapScaleOffset(new _n(n[0],n[1],n[2],n[3]))},e.setLightmapIndex=function(e){for(var t=0;t<this._childs.length;t++)this._childs[t].terrainRender.lightmapIndex=e},e.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}},e.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()},e.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 gr(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,d=1<_?e._detailTextureInfos[l.detailID[h][1]].diffuseTexture:null,c=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,E=2<_?e._detailTextureInfos[l.detailID[h][2]].scale:null,v=3<_?e._detailTextureInfos[l.detailID[h][3]].scale:null;s.buildRenderElementAndMaterial(_,l.normalMap,l.alphaMap[h],u,d,c,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,E?E.x:1,E?E.y:1,v?v.x:1,v?v.y:1)}s.terrainRender.receiveShadow=!0,s.terrainRender.lightmapScaleOffset=this._lightmapScaleOffset,this.addChild(s)}},e.width=function(){return this._terrainRes._chunkNumX*Tn.CHUNK_GRID_NUM*this._terrainRes._gridSize},e.depth=function(){return this._terrainRes._chunkNumZ*Tn.CHUNK_GRID_NUM*this._terrainRes._gridSize},e.getHeightXZ=function(e,t){if(!this._terrainRes||!this._terrainRes.loaded)return NaN;if(e-=this.transform.position.x,t-=this.transform.position.z,s.__VECTOR3__||(s.__VECTOR3__=new hn),s.__VECTOR3__.elements[0]=e,s.__VECTOR3__.elements[1]=0,s.__VECTOR3__.elements[2]=t,hn.transformV3ToV3(s.__VECTOR3__,Tn.__ADAPT_MATRIX_INV__,s.__VECTOR3__),e=s.__VECTOR3__.elements[0],t=s.__VECTOR3__.elements[2],e<0||e>this.width()||t<0||t>this.depth())return NaN;var n=this._terrainRes._gridSize,i=parseInt(""+e/n),r=parseInt(""+t/n),a=e-i*n,o=t-r*n,e=NaN,t=this._terrainRes._heightData;return n<a+o?(e=t._terrainHeightData[(r+1-1)*t._width+i+1])+(t._terrainHeightData[(r+1-1)*t._width+i]-e)*((n-a)/n)+(t._terrainHeightData[(r-1)*t._width+i+1]-e)*((n-o)/n):(e=t._terrainHeightData[Math.max(0,r-1)*t._width+i])+(t._terrainHeightData[Math.min(t._width*t._height-1,(r+1-1)*t._width+i)]-e)*(o/n)+(t._terrainHeightData[Math.min(t._width*t._height-1,Math.max(0,r-1)*t._width+i+1)]-e)*(a/n)},_(0,e,"terrainRes",null,function(e){e&&((this._terrainRes=e).loaded?this.buildTerrain(e):e.once("loaded",this,this.buildTerrain))}),s.load=function(e){return S.loader.create(e,null,null,s,null,1,!1)},s.RENDER_LINE_MODEL=!1,s.LOD_TOLERANCE_VALUE=4,s.LOD_DISTANCE_FACTOR=2,s.__VECTOR3__=null,s}(),ur=(function(){function i(e,t,n){this._long=NaN,this._width=NaN,this._height=NaN,void 0===e&&(e=1),void 0===t&&(t=1),void 0===n&&(n=1),i.__super.call(this),this._long=e,this._width=t,this._height=n,this.activeResource(),this._positions=this._getPositions(),this._generateBoundingObject()}p(i,"laya.d3.resource.models.BoxMesh",Ji);var e=i.prototype;e.recreateResource=function(){this._numberVertices=24,this._numberIndices=36;var e=vt.vertexDeclaration,t=(e.vertexStride,this._long/2),n=this._height/2,i=this._width/2,n=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]),i=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 Gi(e,this._numberVertices,35044,!0),this._indexBuffer=new Ui("ushort",this._numberIndices,35044,!0),this._vertexBuffer.setData(n),this._indexBuffer.setData(i),this.memorySize=2*(this._vertexBuffer._byteLength+this._indexBuffer._byteLength),this.completeCreate()},_(0,e,"long",function(){return this._long},function(e){this._long!==e&&(this._long=e,this.releaseResource(),this.activeResource())}),_(0,e,"width",function(){return this._width},function(e){this._width!==e&&(this._width=e,this.releaseResource(),this.activeResource())}),_(0,e,"height",function(){return this._height},function(e){this._height!==e&&(this._height=e,this.releaseResource(),this.activeResource())})}(),function(){function r(e,t,n,i){this._radius=NaN,this._height=NaN,this._slices=0,void(this._stacks=0)===e&&(e=.5),void 0===t&&(t=2),void 0===n&&(n=16),void 0===i&&(i=32),r.__super.call(this),this._radius=e,this._height=t<2*e?2*e:t,this._stacks=n,this._slices=i,this.recreateResource(),this._positions=this._getPositions(),this._generateBoundingObject()}p(r,"laya.d3.resource.models.CapsuleMesh",Ji);var e=r.prototype;e.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;for(var e=vt.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,d=0,c=0,f=0,c=0;c<=this._stacks;c++)for(f=0;f<=this._slices;f++)s=this._radius*Math.cos(c*r)*Math.cos(f*a+Math.PI),l=this._radius*Math.sin(c*r),h=this._radius*Math.cos(c*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-c/this._stacks)*(Math.PI*this._radius/2/(this._height+Math.PI*this._radius)),c<this._stacks&&(i[u++]=c*(this._slices+1)+f+(this._slices+1),i[u++]=c*(this._slices+1)+f,i[u++]=c*(this._slices+1)+f+1,i[u++]=c*(this._slices+1)+f+this._slices,i[u++]=c*(this._slices+1)+f,i[u++]=c*(this._slices+1)+f+(this._slices+1));for(d+=(this._stacks+1)*(this._slices+1),c=0;c<=this._stacks;c++)for(f=0;f<=this._slices;f++)s=this._radius*Math.cos(c*r)*Math.cos(f*a+Math.PI),l=this._radius*Math.sin(-c*r),h=this._radius*Math.cos(c*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[_++]=(c/this._stacks*(Math.PI*this._radius/2)+(this._height+Math.PI*this._radius/2))/(this._height+Math.PI*this._radius),c<this._stacks&&(i[u++]=d+c*(this._slices+1)+f,i[u++]=d+c*(this._slices+1)+f+(this._slices+1),i[u++]=d+c*(this._slices+1)+f+1,i[u++]=d+c*(this._slices+1)+f,i[u++]=d+c*(this._slices+1)+f+this._slices,i[u++]=d+c*(this._slices+1)+f+(this._slices+1));for(d+=(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-+f/this._slices,n[_+8*(this._slices+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+d+(this._slices+1),i[u++]=f+d+1,i[u++]=f+d,i[u++]=f+d+(this._slices+1),i[u++]=f+d+(this._slices+1)+1,i[u++]=f+d+1;d+=2*(this._slices+1),this._vertexBuffer=new Gi(e,this._numberVertices,35044,!0),this._indexBuffer=new Ui("ushort",this._numberIndices,35044,!0),this._vertexBuffer.setData(n),this._indexBuffer.setData(i),this.memorySize=2*(this._vertexBuffer._byteLength+this._indexBuffer._byteLength),this.completeCreate()},_(0,e,"radius",function(){return this._radius},function(e){this._radius!==e&&(this._radius=e,this.releaseResource(),this.activeResource())}),_(0,e,"height",function(){return this._height},function(e){this._height!==e&&(this._height=e,this.releaseResource(),this.activeResource())}),_(0,e,"stacks",function(){return this._stacks},function(e){this._stacks!==e&&(this._stacks=e,this.releaseResource(),this.activeResource())}),_(0,e,"slices",function(){return this._slices},function(e){this._slices!==e&&(this._slices=e,this.releaseResource(),this.activeResource())})}(),function(){function i(e,t,n){this._radius=NaN,this._height=NaN,void(this._slices=0)===e&&(e=.5),void 0===t&&(t=2),void 0===n&&(n=32),i.__super.call(this),this._radius=e,this._height=t,this._slices=n,this.recreateResource(),this._positions=this._getPositions(),this._generateBoundingObject()}p(i,"laya.d3.resource.models.CylinderMesh",Ji);var e=i.prototype;e.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=vt.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,d=0,c=0;c<=this._slices;c++)0===c&&(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=c*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[d++]=0,i[d++]=f+1,i[d++]=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-+m/this._slices,n[u+8*(this._slices+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[d++]=p+s+(this._slices+1),i[d++]=p+s+1,i[d++]=p+s,i[d++]=p+s+(this._slices+1),i[d++]=p+s+(this._slices+1)+1,i[d++]=p+s+1;s+=2*(this._slices+1);for(var E=0;E<=this._slices;E++)0===E&&(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=E*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 v=0;v<this._slices;v++)i[d++]=0+s,i[d++]=v+2+s,i[d++]=v+1+s;s+=this._slices+1+1,this._vertexBuffer=new Gi(e,this._numberVertices,35044,!0),this._indexBuffer=new Ui("ushort",this._numberIndices,35044,!0),this._vertexBuffer.setData(n),this._indexBuffer.setData(i),this.memorySize=2*(this._vertexBuffer._byteLength+this._indexBuffer._byteLength),this.completeCreate()},_(0,e,"radius",function(){return this._radius},function(e){this._radius!==e&&(this._radius=e,this.releaseResource(),this.activeResource())}),_(0,e,"height",function(){return this._height},function(e){this._height!==e&&(this._height=e,this.releaseResource(),this.activeResource())}),_(0,e,"slices",function(){return this._slices},function(e){this._slices!==e&&(this._slices=e,this.releaseResource(),this.activeResource())})}(),function(){function r(e,t,n,i){this._long=NaN,this._width=NaN,this._stacks=0,void(this._slices=0)===e&&(e=10),void 0===t&&(t=10),void 0===n&&(n=10),void 0===i&&(i=10),r.__super.call(this),this._long=e,this._width=t,this._stacks=n,this._slices=i,this.activeResource(),this._positions=this._getPositions(),this._generateBoundingObject()}p(r,"laya.d3.resource.models.PlaneMesh",Ji);var e=r.prototype;e.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=vt.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++]=+_/this._stacks,i[l++]=+h/this._slices;for(var u=0,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 Gi(t,this._numberVertices,35044,!0),this._indexBuffer=new Ui("ushort",this._numberIndices,35044,!0),this._vertexBuffer.setData(i),this._indexBuffer.setData(e),this.memorySize=2*(this._vertexBuffer._byteLength+this._indexBuffer._byteLength),this.completeCreate()},_(0,e,"long",function(){return this._long},function(e){this._long!==e&&(this._long=e,this.releaseResource(),this.activeResource())}),_(0,e,"width",function(){return this._width},function(e){this._width!==e&&(this._width=e,this.releaseResource(),this.activeResource())}),_(0,e,"stacks",function(){return this._stacks},function(e){this._stacks!==e&&(this._stacks=e,this.releaseResource(),this.activeResource())}),_(0,e,"slices",function(){return this._slices},function(e){this._slices!==e&&(this._slices=e,this.releaseResource(),this.activeResource())})}(),function(){function n(e,t){this._long=NaN,this._width=NaN,void 0===e&&(e=1),void 0===t&&(t=1),n.__super.call(this),this._long=e,this._width=t,this.activeResource(),this._positions=this._getPositions(),this._generateBoundingObject()}p(n,"laya.d3.resource.models.QuadMesh",Ji);var e=n.prototype;return e.recreateResource=function(){this._numberVertices=4,this._numberIndices=6;var e=vt.vertexDeclaration,t=(e.vertexStride,this._long/2),n=this._width/2,t=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]),n=new Uint16Array([0,1,2,3,2,1]);this._vertexBuffer=new Gi(e,this._numberVertices,35044,!0),this._indexBuffer=new Ui("ushort",this._numberIndices,35044,!0),this._vertexBuffer.setData(t),this._indexBuffer.setData(n),this.memorySize=2*(this._vertexBuffer._byteLength+this._indexBuffer._byteLength),this.completeCreate()},_(0,e,"long",function(){return this._long},function(e){this._long!==e&&(this._long=e,this.releaseResource(),this.activeResource())}),_(0,e,"width",function(){return this._width},function(e){this._width!==e&&(this._width=e,this.releaseResource(),this.activeResource())}),n}()),dr=(function(){function i(e,t,n){this._radius=NaN,this._slices=0,void(this._stacks=0)===e&&(e=.5),void 0===t&&(t=32),void 0===n&&(n=32),i.__super.call(this),this._radius=e,this._stacks=t,this._slices=n,this.activeResource(),this._positions=this._getPositions(),this._generateBoundingObject()}p(i,"laya.d3.resource.models.SphereMesh",Ji);var e=i.prototype;e.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=vt.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),d=0;d<this._slices+1;d++){var c=_*Math.sin(d*a+ +Math.PI/2),f=_*Math.cos(d*a+ +Math.PI/2);i[s+0]=c*this._radius,i[s+1]=u*this._radius,i[s+2]=f*this._radius,i[s+3]=c,i[s+4]=u,i[s+5]=f,i[s+6]=d/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 Gi(t,this._numberVertices,35044,!0),this._indexBuffer=new Ui("ushort",this._numberIndices,35044,!0),this._vertexBuffer.setData(i),this._indexBuffer.setData(e),this.memorySize=2*(this._vertexBuffer._byteLength+this._indexBuffer._byteLength),this.completeCreate()},_(0,e,"radius",function(){return this._radius},function(e){this._radius!==e&&(this._radius=e,this.releaseResource(),this.activeResource())}),_(0,e,"slices",function(){return this._slices},function(e){this._slices!==e&&(this._slices=e,this.releaseResource(),this.activeResource())}),_(0,e,"stacks",function(){return this._stacks},function(e){this._stacks!==e&&(this._stacks=e,this.releaseResource(),this.activeResource())})}(),function(){function a(e,t,n){void 0===e&&(e=0),void 0===t&&(t=.3),void 0===n&&(n=1e3),this._viewMatrix=new Jt,this._projectionMatrix=new Jt,this._projectionViewMatrix=new Jt,this._viewport=new un(0,0,0,0),this._normalizedViewport=new un(0,0,1,1),this._aspectRatio=e,this._boundFrustumUpdate=!0,this._boundFrustum=new Xt(Jt.DEFAULT),a.__super.call(this,t,n),this.transform.on("worldmatrixneedchanged",this,this._onWorldMatrixChanged)}p(a,"laya.d3.core.Camera",sr);var e=a.prototype;return e._onWorldMatrixChanged=function(){this._boundFrustumUpdate=!0},e._parseCustomProps=function(e,t,n,i){var r=n.clearColor;this.clearColor=new _n(r[0],r[1],r[2],r[3]);n=n.viewport;this.normalizedViewport=new un(n[0],n[1],n[2],n[3])},e._calculateProjectionMatrix=function(){var e,t;this._useUserProjectionMatrix||(this._orthographic?(e=this.orthographicVerticalSize*this.aspectRatio*.5,t=.5*this.orthographicVerticalSize,Jt.createOrthoOffCenterRH(-e,e,-t,t,this.nearPlane,this.farPlane,this._projectionMatrix)):Jt.createPerspective(3.1416*this.fieldOfView/180,this.aspectRatio,this.nearPlane,this.farPlane,this._projectionMatrix)),this._boundFrustumUpdate=!0},e._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)},e._renderCamera=function(e,t,n){var i;n.parallelSplitShadowMaps[0]&&n._renderShadowMap(e,t,this),(t.camera=this)._prepareCameraToRender(),n._preRenderUpdateComponents(t);var r=t._viewMatrix=this.viewMatrix,a=this._renderTarget;a?(a.start(),Jt.multiply(sr._invertYScaleMatrix,this._projectionMatrix,sr._invertYProjectionMatrix),Jt.multiply(sr._invertYScaleMatrix,this.projectionViewMatrix,sr._invertYProjectionViewMatrix),i=t._projectionMatrix=sr._invertYProjectionMatrix,t._projectionViewMatrix=sr._invertYProjectionViewMatrix):(i=t._projectionMatrix=this._projectionMatrix,t._projectionViewMatrix=this.projectionViewMatrix),this._prepareCameraViewProject(r,i),t._viewport=this.viewport,n._preRenderScene(e,t,this.boundFrustum),n._clear(e,t),n._renderScene(e,t),n._postRenderUpdateComponents(t),a&&a.end()},e.viewportPointToRay=function(e,t){yn.calculateCursorRay(e,this.viewport,this._projectionMatrix,this.viewMatrix,null,t)},e.normalizedViewportPointToRay=function(e,t){var n=a._tempVector20,i=this.viewport,r=e.elements,e=n.elements;e[0]=r[0]*i.width,e[1]=r[1]*i.height,yn.calculateCursorRay(n,this.viewport,this._projectionMatrix,this.viewMatrix,null,t)},e.worldToViewportPoint=function(e,t){Jt.multiply(this._projectionMatrix,this._viewMatrix,this._projectionViewMatrix),this.viewport.project(e,this._projectionViewMatrix,t);t=t.elements;t[0]=t[0]/S.stage.clientScaleX,t[1]=t[1]/S.stage.clientScaleY},e.worldToNormalizedViewportPoint=function(e,t){Jt.multiply(this._projectionMatrix,this._viewMatrix,this._projectionViewMatrix),this.normalizedViewport.project(e,this._projectionViewMatrix,t);t=t.elements;t[0]=t[0]/S.stage.clientScaleX,t[1]=t[1]/S.stage.clientScaleY},e.convertScreenCoordToOrthographicCoord=function(e,t){if(this._orthographic){var n=ve.clientWidth,i=ve.clientHeight,r=this.orthographicVerticalSize*this.aspectRatio/n,a=this.orthographicVerticalSize/i,o=e.elements,e=t.elements;return e[0]=(-n/2+o[0])*r,e[1]=(i/2-o[1])*a,e[2]=(this.nearPlane-this.farPlane)*(o[2]+1)/2-this.nearPlane,hn.transformCoordinate(t,this.transform.worldMatrix,t),!0}return!1},_(0,e,"projectionViewMatrix",function(){return Jt.multiply(this.projectionMatrix,this.viewMatrix,this._projectionViewMatrix),this._projectionViewMatrix}),_(0,e,"aspectRatio",function(){if(0!==this._aspectRatio)return this._aspectRatio;var e=this.viewport;return e.width/e.height},function(e){if(e<0)throw new Error("Camera: the aspect ratio has to be a positive real number.");this._aspectRatio=e,this._calculateProjectionMatrix()}),_(0,e,"boundFrustum",function(){return this._boundFrustumUpdate&&(this._boundFrustum.matrix=this.projectionViewMatrix),this._boundFrustum}),_(0,e,"needViewport",function(){var e=this.normalizedViewport;return 0===e.x&&0===e.y&&1===e.width&&1===e.height}),_(0,e,"viewport",function(){var e,t,n;return this._viewportExpressedInClipSpace&&(e=this._normalizedViewport,t=(n=this.renderTargetSize).width,n=n.height,this._viewport.x=e.x*t,this._viewport.y=e.y*n,this._viewport.width=e.width*t,this._viewport.height=e.height*n),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()}),_(0,e,"normalizedViewport",function(){var e,t,n;return this._viewportExpressedInClipSpace||(e=this._viewport,t=(n=this.renderTargetSize).width,n=n.height,this._normalizedViewport.x=e.x/t,this._normalizedViewport.y=e.y/n,this._normalizedViewport.width=e.width/t,this._normalizedViewport.height=e.height/n),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.")),1<e.x+e.width&&(e.width=1-e.x,console.warn("Camera: viewport.width + viewport.x must less than 1.0.")),1<e.y+e.height&&(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()}),_(0,e,"projectionMatrix",function(){return this._projectionMatrix},function(e){this._projectionMatrix=e,this._useUserProjectionMatrix=!0}),_(0,e,"viewMatrix",function(){return this.transform.worldMatrix.invert(this._viewMatrix),this._viewMatrix}),l(a,["_tempVector20",function(){return this._tempVector20=new ln}]),a}()),cr=(function(t){function n(){n.__super.call(this),this._render=new ci(this),this._render.on("materialchanged",this,this._onMaterialChanged);var e=new Ni;this._render.sharedMaterial=e,this._geometryFilter=new Mi(this),e.renderMode=8,this._changeRenderObject(0)}p(n,"laya.d3.core.glitter.Glitter",t);var e=n.prototype;e._changeRenderObject=function(e){var t=this._render._renderElements,n=t[e];(n=n||(t[e]=new pe))._render=this._render;t=(t=this._render.sharedMaterials[e])||Ni.defaultMaterial,e=this._geometryFilter;return n._mainSortID=0,n._sprite3D=this,n.renderObj=e,n._material=t,n},e._onMaterialChanged=function(e,t,n){t<e._renderElements.length&&this._changeRenderObject(t)},e._clearSelfRenderObjects=function(){this.scene.removeFrustumCullingObject(this._render)},e._addSelfRenderObjects=function(){this.scene.addFrustumCullingObject(this._render)},e._update=function(e){this._geometryFilter._update(e.elapsedTime),t.prototype._update.call(this,e)},e.addGlitterByPositions=function(e,t){this._geometryFilter.addVertexPosition(e,t)},e.addGlitterByPositionsVelocitys=function(e,t,n,i){this._geometryFilter.addVertexPositionVelocity(e,t,n,i)},e.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;i=t._render,t=this._render;i.sharedMaterials=t.sharedMaterials,i.enable=t.enable,laya.d3.core.Sprite3D.prototype.cloneTo.call(this,e)},e.destroy=function(e){void 0===e&&(e=!0),this.destroyed||(t.prototype.destroy.call(this,e),this._geometryFilter._destroy(),this._geometryFilter=null)},_(0,e,"templet",function(){return this._geometryFilter}),_(0,e,"glitterRender",function(){return this._render}),n.CURRENTTIME=2,n.DURATION=3}(lr),function(e){function t(){this._direction=null,this._updateDirection=!1,t.__super.call(this),this._updateDirection=!1,this._direction=new hn,this.transform.on("worldmatrixneedchanged",this,this._onWorldMatrixChange)}p(t,"laya.d3.core.light.DirectionLight",e);var n=t.prototype;return n._initShadow=function(){var e;this._shadow?(this._parallelSplitShadowMap=new gn,this.scene.parallelSplitShadowMaps.push(this._parallelSplitShadowMap),this.transform.worldMatrix.getForward(this._direction),hn.normalize(this._direction,this._direction),this._parallelSplitShadowMap.setInfo(this.scene,this._shadowFarPlane,this._direction,this._shadowMapSize,this._shadowMapCount,this._shadowMapPCFType)):((e=this.scene.parallelSplitShadowMaps).splice(e.indexOf(this._parallelSplitShadowMap),1),this._parallelSplitShadowMap.disposeAllRenderTarget(),this._parallelSplitShadowMap=null,this.scene.removeShaderDefine(gn.SHADERDEFINE_SHADOW_PSSM1),this.scene.removeShaderDefine(gn.SHADERDEFINE_SHADOW_PSSM2),this.scene.removeShaderDefine(gn.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($n.SHADERDEFINE_DIRECTIONLIGHT)},n._prepareToScene=function(e){var t=e.scene;if(t.enableLight&&this._activeInHierarchy){e=t._shaderValues;return t.addShaderDefine($n.SHADERDEFINE_DIRECTIONLIGHT),hn.scale(this.color,this._intensity,this._intensityColor),e.setValue(4,this._intensityColor.elements),this.transform.worldMatrix.getForward(this._direction),hn.normalize(this._direction,this._direction),e.setValue(3,this._direction.elements),!0}return t.removeShaderDefine($n.SHADERDEFINE_DIRECTIONLIGHT),!1},n._onWorldMatrixChange=function(){this._updateDirection=!0},_(0,n,"shadow",e.prototype._$get_shadow,function(e){this._shadow!==e&&(this._shadow=e,this.scene&&this._initShadow())}),_(0,n,"direction",function(){return console.log("Warning: discard property,please use transform's property instead."),this._updateDirection&&(this.transform.worldMatrix.getForward(this._direction),hn.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,hn.normalize(e,e),this._direction=e,this.shadow&&this._parallelSplitShadowMap&&this._parallelSplitShadowMap._setGlobalParallelLightDir(this._direction)}),t}(hr)),fr=(function(){function e(){this._range=NaN,this._attenuation=null,e.__super.call(this),this._range=6,this._attenuation=new hn(.6,.6,.6)}p(e,"laya.d3.core.light.PointLight",hr);var t=e.prototype;t._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($n.SHADERDEFINE_POINTLIGHT)},t._prepareToScene=function(e){var t=e.scene;if(t.enableLight&&this._activeInHierarchy){e=t._shaderValues;return t.addShaderDefine($n.SHADERDEFINE_POINTLIGHT),hn.scale(this.color,this._intensity,this._intensityColor),e.setValue(8,this._intensityColor.elements),e.setValue(5,this.transform.position.elements),e.setValue(6,this.range),e.setValue(7,this.attenuation.elements),!0}return t.removeShaderDefine($n.SHADERDEFINE_POINTLIGHT),!1},_(0,t,"range",function(){return this._range},function(e){this._range=e}),_(0,t,"attenuation",function(){return this._attenuation},function(e){this._attenuation=e})}(),function(){function e(){this._updateDirection=!1,this._direction=null,this._spot=NaN,this._range=NaN,this._attenuation=null,e.__super.call(this),this._updateDirection=!1,this.direction=new hn(0,-1,-1),this._attenuation=new hn(.6,.6,.6),this._spot=96,this._range=6,this.transform.on("worldmatrixneedchanged",this,this._onWorldMatrixChange)}p(e,"laya.d3.core.light.SpotLight",hr);var t=e.prototype;t._onWorldMatrixChange=function(){this._updateDirection=!0},t._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($n.SHADERDEFINE_SPOTLIGHT)},t._prepareToScene=function(e){var t=e.scene;if(t.enableLight&&this._activeInHierarchy){e=t._shaderValues;return t.addShaderDefine($n.SHADERDEFINE_SPOTLIGHT),hn.scale(this.color,this._intensity,this._intensityColor),e.setValue(14,this._intensityColor.elements),e.setValue(9,this.transform.position.elements),this.transform.worldMatrix.getForward(this._direction),hn.normalize(this._direction,this._direction),e.setValue(10,this._direction.elements),e.setValue(12,this.range),e.setValue(11,this.spot),e.setValue(13,this.attenuation.elements),!0}return t.removeShaderDefine($n.SHADERDEFINE_SPOTLIGHT),!1},_(0,t,"spot",function(){return this._spot},function(e){this._spot=e}),_(0,t,"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}),_(0,t,"range",function(){return this._range},function(e){this._range=e}),_(0,t,"attenuation",function(){return this._attenuation},function(e){this._attenuation=e})}(),function(n){function i(e,t){i.__super.call(this,t),this._geometryFilter=new fi(this),this._render=new mi(this),this._geometryFilter.on("meshchanged",this,this._onMeshChanged),this._render.on("materialchanged",this,this._onMaterialChanged),e&&(this._geometryFilter.sharedMesh=e)instanceof laya.d3.resource.models.Mesh&&(e.loaded?this._render.sharedMaterials=e.materials:e.once("loaded",this,this._applyMeshMaterials))}p(i,"laya.d3.core.MeshSprite3D",n);var e=i.prototype;return e._changeRenderObjectByMesh=function(e){var t=this._render._renderElements,n=t[e];(n=n||(t[e]=new qn))._render=this._render;t=(t=this._render.sharedMaterials[e])||Pi.defaultMaterial,e=this._geometryFilter.sharedMesh.getRenderElement(e);return n._mainSortID=this._getSortID(e,t),n._sprite3D=this,n.renderObj=e,n._material=t,n},e._changeRenderObjectByMaterial=function(e,t){var n=this._render._renderElements[e];t=t||Pi.defaultMaterial;e=this._geometryFilter.sharedMesh.getRenderElement(e);return n._mainSortID=this._getSortID(e,t),n._sprite3D=this,n.renderObj=e,n._material=t,n},e._changeRenderObjectsByMesh=function(){var e=this._geometryFilter.sharedMesh.getRenderElementsCount();this._render._renderElements.length=e;for(var t=0;t<e;t++)this._changeRenderObjectByMesh(t)},e._onMeshChanged=function(e){e=e.sharedMesh;e.loaded?this._changeRenderObjectsByMesh():e.once("loaded",this,this._onMeshLoaded)},e._onMeshLoaded=function(e){e===this.meshFilter.sharedMesh&&this._changeRenderObjectsByMesh()},e._onMaterialChanged=function(e,t,n){t<this._render._renderElements.length&&this._changeRenderObjectByMaterial(t,n)},e._clearSelfRenderObjects=function(){this.scene.removeFrustumCullingObject(this._render)},e._addSelfRenderObjects=function(){this.scene.addFrustumCullingObject(this._render)},e._parseCustomProps=function(e,t,n,i){var r=this.meshRender,a=n.lightmapIndex;null!=a&&(r.lightmapIndex=a);var o,s,a=n.lightmapScaleOffset;if(a&&(r.lightmapScaleOffset=new _n(a[0],a[1],a[2],a[3])),i.instanceParams)(o=i.instanceParams.loadPath)&&(s=W.getRes(t[o]),(this.meshFilter.sharedMesh=s).loaded?r.sharedMaterials=s.materials:s.once("loaded",this,this._applyMeshMaterials));else{(o=n.meshPath)&&(s=W.getRes(t[o]),this.meshFilter.sharedMesh=s);var l=n.materials;if(l){var h=r.sharedMaterials,_=l.length;h.length=_;for(var u=0;u<_;u++)h[u]=W.getRes(t[l[u].path]);r.sharedMaterials=h}}},e._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},e._addToInitStaticBatchManager=function(){i._staticBatchManager._addInitBatchSprite(this)},e.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;t=n.lightmapScaleOffset;t&&(i.lightmapScaleOffset=t.clone()),i.lightmapIndex=n.lightmapIndex,i.receiveShadow=n.receiveShadow,i.sortingFudge=n.sortingFudge,laya.d3.core.Sprite3D.prototype.cloneTo.call(this,e)},e.destroy=function(e){var t;void 0===e&&(e=!0),this.destroyed||((t=this.meshFilter.sharedMesh).loaded||t.off("loaded",this,this._applyMeshMaterials),n.prototype.destroy.call(this,e),this._geometryFilter._destroy())},_(0,e,"meshFilter",function(){return this._geometryFilter}),_(0,e,"meshRender",function(){return this._render}),i.__init__=function(){ze._staticBatchManagers.push(i._staticBatchManager)},i.load=function(e){return S.loader.create(e,null,null,i)},l(i,["_staticBatchManager",function(){return this._staticBatchManager=new Jn}]),i}(lr)),mr=function(t){function z(e){z.__super.call(this),this._render=new Ei(this),this._render.on("materialchanged",this,this._onMaterialChanged),this._geometryFilter=new pi(this),this._createRenderElement(0),e&&(this._render.sharedMaterial=e)}p(z,"laya.d3.core.particleShuriKen.ShuriKenParticle3D",t);var e=z.prototype;return e._initParticleVelocity=function(e){for(var t=new ne,n=e.velocitys,i=0,r=n.length;i<r;i++){var a=n[i];t.add(a.key,a.value)}return t},e._initParticleColor=function(e){for(var t=new ee,n=e.alphas,i=0,r=0,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 hn(l[0],l[1],l[2]))}return t},e._initParticleSize=function(e){for(var t=new ne,n=e.sizes,i=0,r=n.length;i<r;i++){var a=n[i];t.add(a.key,a.value)}return t},e._initParticleRotation=function(e){for(var t=new ne,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},e._initParticleFrame=function(e){for(var t=new te,n=e.frames,i=0,r=n.length;i<r;i++){var a=n[i];t.add(a.key,a.value)}return t},e._createRenderElement=function(e){var t=this._render._renderElements[e]=new pe;t._render=this._render;var n=(n=this._render.sharedMaterials[e])||Hi.defaultMaterial,e=this._geometryFilter;t._mainSortID=0,t._sprite3D=this,t.renderObj=e,t._material=n},e._onMaterialChanged=function(e,t,n){e=e._renderElements;t<e.length&&(e[t]._material=n||Hi.defaultMaterial)},e._clearSelfRenderObjects=function(){this.scene.removeFrustumCullingObject(this._render)},e._addSelfRenderObjects=function(){this.scene.addFrustumCullingObject(this._render)},e._parseCustomProps=function(e,t,n,i){var r,a=Math.PI/180,o=0,s=this.particleRender,l=n.material;l?h=W.getRes(t[l.path]):(l=n.materialPath)?h=W.getRes(t[l]):(h=new Hi).diffuseTexture=t?W.getRes(t[n.texturePath]):rr.load(n.texturePath),s.sharedMaterial=h;var h=n.meshPath;h&&(s.mesh=W.getRes(t[h])),s.renderMode=n.renderMode,s.stretchedBillboardCameraSpeedScale=n.stretchedBillboardCameraSpeedScale,s.stretchedBillboardSpeedScale=n.stretchedBillboardSpeedScale,s.stretchedBillboardLengthScale=n.stretchedBillboardLengthScale,s.sortingFudge=n.sortingFudge||0;t=this.particleSystem;t.isPerformanceMode=n.isPerformanceMode,t.duration=n.duration,t.looping=n.looping,t.prewarm=n.prewarm,t.startDelayType=n.startDelayType,t.startDelay=n.startDelay,t.startDelayMin=n.startDelayMin,t.startDelayMax=n.startDelayMax,t.startLifetimeType=n.startLifetimeType,t.startLifetimeConstant=n.startLifetimeConstant,t.startLifeTimeGradient=z._initStartLife(n.startLifetimeGradient),t.startLifetimeConstantMin=n.startLifetimeConstantMin,t.startLifetimeConstantMax=n.startLifetimeConstantMax,t.startLifeTimeGradientMin=z._initStartLife(n.startLifetimeGradientMin),t.startLifeTimeGradientMax=z._initStartLife(n.startLifetimeGradientMax),t.startSpeedType=n.startSpeedType,t.startSpeedConstant=n.startSpeedConstant,t.startSpeedConstantMin=n.startSpeedConstantMin,t.startSpeedConstantMax=n.startSpeedConstantMax,t.threeDStartSize=n.threeDStartSize,t.startSizeType=n.startSizeType,t.startSizeConstant=n.startSizeConstant;h=n.startSizeConstantSeparate,s=t.startSizeConstantSeparate.elements;s[0]=h[0],s[1]=h[1],s[2]=h[2],t.startSizeConstantMin=n.startSizeConstantMin,t.startSizeConstantMax=n.startSizeConstantMax;s=n.startSizeConstantMinSeparate,h=t.startSizeConstantMinSeparate.elements;h[0]=s[0],h[1]=s[1],h[2]=s[2];h=n.startSizeConstantMaxSeparate,s=t.startSizeConstantMaxSeparate.elements;s[0]=h[0],s[1]=h[1],s[2]=h[2],t.threeDStartRotation=n.threeDStartRotation,t.startRotationType=n.startRotationType,t.startRotationConstant=n.startRotationConstant*a;s=n.startRotationConstantSeparate,h=t.startRotationConstantSeparate.elements;h[0]=s[0]*a,h[1]=s[1]*a,h[2]=s[2]*a,t.startRotationConstantMin=n.startRotationConstantMin*a,t.startRotationConstantMax=n.startRotationConstantMax*a;h=n.startRotationConstantMinSeparate,s=t.startRotationConstantMinSeparate.elements;s[0]=h[0]*a,s[1]=h[1]*a,s[2]=h[2]*a;s=n.startRotationConstantMaxSeparate,h=t.startRotationConstantMaxSeparate.elements;h[0]=s[0]*a,h[1]=s[1]*a,h[2]=s[2]*a,t.randomizeRotationDirection=n.randomizeRotationDirection,t.startColorType=n.startColorType;h=n.startColorConstant,s=t.startColorConstant.elements;s[0]=h[0],s[1]=h[1],s[2]=h[2],s[3]=h[3];s=n.startColorConstantMin,h=t.startColorConstantMin.elements;h[0]=s[0],h[1]=s[1],h[2]=s[2],h[3]=s[3];h=n.startColorConstantMax,s=t.startColorConstantMax.elements;s[0]=h[0],s[1]=h[1],s[2]=h[2],s[3]=h[3],t.gravityModifier=n.gravityModifier,t.simulationSpace=n.simulationSpace,t.scaleMode=n.scaleMode,t.playOnAwake=n.playOnAwake,t.maxParticles=n.maxParticles;h=n.autoRandomSeed;null!=h&&(t.autoRandomSeed=h);h=n.randomSeed;null!=h&&(t.randomSeed[0]=h);var h=n.emission,_=t.emission;if(h){_.emissionRate=h.emissionRate;var u=h.bursts;if(u)for(o=0,r=u.length;o<r;o++){var d=u[o];_.addBurst(new j(d.time,d.min,d.max))}_.enbale=h.enable}else _.enbale=!1;var c,f,m=n.shape;if(m){switch(m.shapeType){case 0:var p,E=p=new Kn;p.radius=m.sphereRadius,p.emitFromShell=m.sphereEmitFromShell,p.randomDirection=m.sphereRandomDirection;break;case 1:E=p=new jn,p.radius=m.hemiSphereRadius,p.emitFromShell=m.hemiSphereEmitFromShell,p.randomDirection=m.hemiSphereRandomDirection;break;case 2:E=c=new Zn,c.angle=m.coneAngle*a,c.radius=m.coneRadius,c.length=m.coneLength,c.emitType=m.coneEmitType,c.randomDirection=m.coneRandomDirection;break;case 3:E=c=new Xn,c.x=m.boxX,c.y=m.boxY,c.z=m.boxZ,c.randomDirection=m.boxRandomDirection;break;case 7:E=f=new Yn,f.radius=m.circleRadius,f.arc=m.circleArc*a,f.emitFromEdge=m.circleEmitFromEdge,f.randomDirection=m.circleRandomDirection;break;default:E=f=new Yn,f.radius=m.circleRadius,f.arc=m.circleArc*a,f.emitFromEdge=m.circleEmitFromEdge,f.randomDirection=m.circleRandomDirection}E.enable=m.enable,t.shape=E}h=n.velocityOverLifetime;if(h){var v=h.velocity;switch(v.type){case 0:var g=v.constant,T=re.createByConstant(new hn(g[0],g[1],g[2]));break;case 1:T=re.createByGradient(this._initParticleVelocity(v.gradientX),this._initParticleVelocity(v.gradientY),this._initParticleVelocity(v.gradientZ));break;case 2:var S=v.constantMin,g=v.constantMax;T=re.createByRandomTwoConstant(new hn(S[0],S[1],S[2]),new hn(g[0],g[1],g[2]));break;case 3:T=re.createByRandomTwoGradient(this._initParticleVelocity(v.gradientXMin),this._initParticleVelocity(v.gradientXMax),this._initParticleVelocity(v.gradientYMin),this._initParticleVelocity(v.gradientYMax),this._initParticleVelocity(v.gradientZMin),this._initParticleVelocity(v.gradientZMax))}var D=new de(T);D.space=h.space,D.enbale=h.enable,t.velocityOverLifetime=D}D=n.colorOverLifetime;if(D){var x=D.color;switch(x.type){case 0:var M=x.constant,R=J.createByConstant(new _n(M[0],M[1],M[2],M[3]));break;case 1:R=J.createByGradient(this._initParticleColor(x.gradient));break;case 2:var I=x.constantMin,M=x.constantMax;R=J.createByRandomTwoConstant(new _n(I[0],I[1],I[2],I[3]),new _n(M[0],M[1],M[2],M[3]));break;case 3:R=J.createByRandomTwoGradient(this._initParticleColor(x.gradientMin),this._initParticleColor(x.gradientMax))}var A=new K(R);A.enbale=D.enable,t.colorOverLifetime=A}A=n.sizeOverLifetime;if(A){var C,y,O,N=A.size;switch(N.type){case 0:O=N.separateAxes?ie.createByGradientSeparate(this._initParticleSize(N.gradientX),this._initParticleSize(N.gradientY),this._initParticleSize(N.gradientZ)):ie.createByGradient(this._initParticleSize(N.gradient));break;case 1:O=N.separateAxes?(C=N.constantMinSeparate,y=N.constantMaxSeparate,ie.createByRandomTwoConstantSeparate(new hn(C[0],C[1],C[2]),new hn(y[0],y[1],y[2]))):ie.createByRandomTwoConstant(N.constantMin,N.constantMax);break;case 2:O=N.separateAxes?ie.createByRandomTwoGradientSeparate(this._initParticleSize(N.gradientXMin),this._initParticleSize(N.gradientYMin),this._initParticleSize(N.gradientZMin),this._initParticleSize(N.gradientXMax),this._initParticleSize(N.gradientYMax),this._initParticleSize(N.gradientZMax)):ie.createByRandomTwoGradient(this._initParticleSize(N.gradientMin),this._initParticleSize(N.gradientMax))}var V=new he(O);V.enbale=A.enable,t.sizeOverLifetime=V}V=n.rotationOverLifetime;if(V){var L,w,F,P=V.angularVelocity;switch(P.type){case 0:P.separateAxes||(F=$.createByConstant(P.constant*a));break;case 1:P.separateAxes||(F=$.createByGradient(this._initParticleRotation(P.gradient)));break;case 2:F=P.separateAxes?(L=P.constantMinSeparate,w=P.constantMaxSeparate,$.createByRandomTwoConstantSeparate(new hn(L[0]*a,L[1]*a,L[2]*a),new hn(w[0]*a,w[1]*a,w[2]*a))):$.createByRandomTwoConstant(P.constantMin*a,P.constantMax*a);break;case 3:P.separateAxes||(F=$.createByRandomTwoGradient(this._initParticleRotation(P.gradientMin),this._initParticleRotation(P.gradientMax)))}var b=new ae(F);b.enbale=V.enable,t.rotationOverLifetime=b}V=n.textureSheetAnimation;if(V){var B,U=V.frame;switch(U.type){case 0:B=Q.createByConstant(U.constant);break;case 1:B=Q.createByOverTime(this._initParticleFrame(U.overTime));break;case 2:B=Q.createByRandomTwoConstant(U.constantMin,U.constantMax);break;case 3:B=Q.createByRandomTwoOverTime(this._initParticleFrame(U.overTimeMin),this._initParticleFrame(U.overTimeMax))}var H,G=V.startFrame;switch(G.type){case 0:H=_e.createByConstant(G.constant);break;case 1:H=_e.createByRandomTwoConstant(G.constantMin,G.constantMax)}b=new ue(B,H);b.enable=V.enable;n=V.tiles;b.tiles=new ln(n[0],n[1]),b.type=V.type,b.randomRow=V.randomRow;n=V.rowIndex;void 0!==n&&(b.rowIndex=n),b.cycles=V.cycles,t.textureSheetAnimation=b}},e._activeHierarchy=function(){laya.d3.core.Sprite3D.prototype._activeHierarchy.call(this),this.particleSystem.playOnAwake&&this.particleSystem.play()},e._inActiveHierarchy=function(){laya.d3.core.Sprite3D.prototype._inActiveHierarchy.call(this),this.particleSystem.isAlive&&this.particleSystem.simulate(0,!0)},e.cloneTo=function(e){var t=e,n=t._geometryFilter;this._geometryFilter.cloneTo(n);n=t._render,t=this._render;n.sharedMaterials=t.sharedMaterials,n.enable=t.enable,n.renderMode=t.renderMode,n.mesh=t.mesh,n.stretchedBillboardCameraSpeedScale=t.stretchedBillboardCameraSpeedScale,n.stretchedBillboardSpeedScale=t.stretchedBillboardSpeedScale,n.stretchedBillboardLengthScale=t.stretchedBillboardLengthScale,n.sortingFudge=t.sortingFudge,laya.d3.core.Sprite3D.prototype.cloneTo.call(this,e)},e.destroy=function(e){void 0===e&&(e=!0),this.destroyed||(t.prototype.destroy.call(this,e),this._geometryFilter._destroy(),this._geometryFilter=null)},_(0,e,"particleSystem",function(){return this._geometryFilter}),_(0,e,"particleRender",function(){return this._render}),z.__init__=function(){z.SHADERDEFINE_RENDERMODE_BILLBOARD=z.shaderDefines.registerDefine("SPHERHBILLBOARD"),z.SHADERDEFINE_RENDERMODE_STRETCHEDBILLBOARD=z.shaderDefines.registerDefine("STRETCHEDBILLBOARD"),z.SHADERDEFINE_RENDERMODE_HORIZONTALBILLBOARD=z.shaderDefines.registerDefine("HORIZONTALBILLBOARD"),z.SHADERDEFINE_RENDERMODE_VERTICALBILLBOARD=z.shaderDefines.registerDefine("VERTICALBILLBOARD"),z.SHADERDEFINE_COLOROVERLIFETIME=z.shaderDefines.registerDefine("COLOROVERLIFETIME"),z.SHADERDEFINE_RANDOMCOLOROVERLIFETIME=z.shaderDefines.registerDefine("RANDOMCOLOROVERLIFETIME"),z.SHADERDEFINE_VELOCITYOVERLIFETIMECONSTANT=z.shaderDefines.registerDefine("VELOCITYOVERLIFETIMECONSTANT"),z.SHADERDEFINE_VELOCITYOVERLIFETIMECURVE=z.shaderDefines.registerDefine("VELOCITYOVERLIFETIMECURVE"),z.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCONSTANT=z.shaderDefines.registerDefine("VELOCITYOVERLIFETIMERANDOMCONSTANT"),z.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCURVE=z.shaderDefines.registerDefine("VELOCITYOVERLIFETIMERANDOMCURVE"),z.SHADERDEFINE_TEXTURESHEETANIMATIONCURVE=z.shaderDefines.registerDefine("TEXTURESHEETANIMATIONCURVE"),z.SHADERDEFINE_TEXTURESHEETANIMATIONRANDOMCURVE=z.shaderDefines.registerDefine("TEXTURESHEETANIMATIONRANDOMCURVE"),z.SHADERDEFINE_ROTATIONOVERLIFETIME=z.shaderDefines.registerDefine("ROTATIONOVERLIFETIME"),z.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE=z.shaderDefines.registerDefine("ROTATIONOVERLIFETIMESEPERATE"),z.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT=z.shaderDefines.registerDefine("ROTATIONOVERLIFETIMECONSTANT"),z.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE=z.shaderDefines.registerDefine("ROTATIONOVERLIFETIMECURVE"),z.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS=z.shaderDefines.registerDefine("ROTATIONOVERLIFETIMERANDOMCURVES"),z.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCURVES=z.shaderDefines.registerDefine("ROTATIONOVERLIFETIMERANDOMCURVES"),z.SHADERDEFINE_SIZEOVERLIFETIMECURVE=z.shaderDefines.registerDefine("SIZEOVERLIFETIMECURVE"),z.SHADERDEFINE_SIZEOVERLIFETIMECURVESEPERATE=z.shaderDefines.registerDefine("SIZEOVERLIFETIMECURVESEPERATE"),z.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVES=z.shaderDefines.registerDefine("SIZEOVERLIFETIMERANDOMCURVES"),z.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVESSEPERATE=z.shaderDefines.registerDefine("SIZEOVERLIFETIMERANDOMCURVESSEPERATE"),z.SHADERDEFINE_RENDERMODE_MESH=z.shaderDefines.registerDefine("RENDERMODE_MESH"),z.SHADERDEFINE_SHAPE=z.shaderDefines.registerDefine("SHAPE")},z.load=function(e){return S.loader.create(e,null,null,z)},z._initStartLife=function(e){for(var t=new ne,n=e.startLifetimes,i=0,r=n.length;i<r;i++){var a=n[i];t.add(a.key,a.value)}return t},z.SHADERDEFINE_RENDERMODE_BILLBOARD=0,z.SHADERDEFINE_RENDERMODE_STRETCHEDBILLBOARD=0,z.SHADERDEFINE_RENDERMODE_HORIZONTALBILLBOARD=0,z.SHADERDEFINE_RENDERMODE_VERTICALBILLBOARD=0,z.SHADERDEFINE_COLOROVERLIFETIME=0,z.SHADERDEFINE_RANDOMCOLOROVERLIFETIME=0,z.SHADERDEFINE_VELOCITYOVERLIFETIMECONSTANT=0,z.SHADERDEFINE_VELOCITYOVERLIFETIMECURVE=0,z.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCONSTANT=0,z.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCURVE=0,z.SHADERDEFINE_TEXTURESHEETANIMATIONCURVE=0,z.SHADERDEFINE_TEXTURESHEETANIMATIONRANDOMCURVE=0,z.SHADERDEFINE_ROTATIONOVERLIFETIME=0,z.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE=0,z.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT=0,z.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE=0,z.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS=0,z.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCURVES=0,z.SHADERDEFINE_SIZEOVERLIFETIMECURVE=0,z.SHADERDEFINE_SIZEOVERLIFETIMECURVESEPERATE=0,z.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVES=0,z.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVESSEPERATE=0,z.SHADERDEFINE_RENDERMODE_MESH=0,z.SHADERDEFINE_SHAPE=0,z.WORLDPOSITION=0,z.WORLDROTATION=1,z.POSITIONSCALE=4,z.SIZESCALE=5,z.SCALINGMODE=6,z.GRAVITY=7,z.THREEDSTARTROTATION=8,z.STRETCHEDBILLBOARDLENGTHSCALE=9,z.STRETCHEDBILLBOARDSPEEDSCALE=10,z.SIMULATIONSPACE=11,z.CURRENTTIME=12,z.VOLVELOCITYCONST=13,z.VOLVELOCITYGRADIENTX=14,z.VOLVELOCITYGRADIENTY=15,z.VOLVELOCITYGRADIENTZ=16,z.VOLVELOCITYCONSTMAX=17,z.VOLVELOCITYGRADIENTXMAX=18,z.VOLVELOCITYGRADIENTYMAX=19,z.VOLVELOCITYGRADIENTZMAX=20,z.VOLSPACETYPE=21,z.COLOROVERLIFEGRADIENTALPHAS=22,z.COLOROVERLIFEGRADIENTCOLORS=23,z.MAXCOLOROVERLIFEGRADIENTALPHAS=24,z.MAXCOLOROVERLIFEGRADIENTCOLORS=25,z.SOLSIZEGRADIENT=26,z.SOLSIZEGRADIENTX=27,z.SOLSIZEGRADIENTY=28,z.SOLSizeGradientZ=29,z.SOLSizeGradientMax=30,z.SOLSIZEGRADIENTXMAX=31,z.SOLSIZEGRADIENTYMAX=32,z.SOLSizeGradientZMAX=33,z.ROLANGULARVELOCITYCONST=34,z.ROLANGULARVELOCITYCONSTSEPRARATE=35,z.ROLANGULARVELOCITYGRADIENT=36,z.ROLANGULARVELOCITYGRADIENTX=37,z.ROLANGULARVELOCITYGRADIENTY=38,z.ROLANGULARVELOCITYGRADIENTZ=39,z.ROLANGULARVELOCITYGRADIENTW=40,z.ROLANGULARVELOCITYCONSTMAX=41,z.ROLANGULARVELOCITYCONSTMAXSEPRARATE=42,z.ROLANGULARVELOCITYGRADIENTMAX=43,z.ROLANGULARVELOCITYGRADIENTXMAX=44,z.ROLANGULARVELOCITYGRADIENTYMAX=45,z.ROLANGULARVELOCITYGRADIENTZMAX=46,z.ROLANGULARVELOCITYGRADIENTWMAX=47,z.TEXTURESHEETANIMATIONCYCLES=48,z.TEXTURESHEETANIMATIONSUBUVLENGTH=49,z.TEXTURESHEETANIMATIONGRADIENTUVS=50,z.TEXTURESHEETANIMATIONGRADIENTMAXUVS=51,l(z,["shaderDefines",function(){return this.shaderDefines=new fn(lr.shaderDefines)}]),z}(lr),pr=function(t){function n(e,t){this._subMeshOffset=null,n.__super.call(this,t),this._subMeshOffset=[],this._geometryFilter=new fi(this),this._render=new or(this),this._geometryFilter.on("meshchanged",this,this._onMeshChanged),this._render.on("materialchanged",this,this._onMaterialChanged),e&&(this._geometryFilter.sharedMesh=e)}p(n,"laya.d3.core.SkinnedMeshSprite3D",t);var e=n.prototype;return e._changeRenderObjectByMesh=function(e){var t=this._render._renderElements,n=t[e];(n=n||(t[e]=new qn))._render=this._render;t=(t=this._render.sharedMaterials[e])||Pi.defaultMaterial,e=this._geometryFilter.sharedMesh.getRenderElement(e);return n._mainSortID=this._getSortID(e,t),n._sprite3D=this,n.renderObj=e,n._material=t,n},e._changeRenderObjectByMaterial=function(e,t){var n=this._render._renderElements[e];t=t||Pi.defaultMaterial;e=this._geometryFilter.sharedMesh.getRenderElement(e);return n._mainSortID=this._getSortID(e,t),n._sprite3D=this,n.renderObj=e,n._material=t,n},e._changeRenderObjectsByMesh=function(){var e=this._geometryFilter.sharedMesh.getRenderElementsCount();this._render._renderElements.length=e;for(var t=0;t<e;t++)this._changeRenderObjectByMesh(t)},e._onMeshChanged=function(e){e=e.sharedMesh;e.loaded?this._changeRenderObjectsByMesh():e.once("loaded",this,this._changeRenderObjectsByMesh)},e._onMaterialChanged=function(e,t,n){t<this._render._renderElements.length&&this._changeRenderObjectByMaterial(t,n)},e._parseCustomProps=function(e,t,n,i){var r=this.skinnedMeshRender,a=n.lightmapIndex;null!=a&&(r.lightmapIndex=a);a=n.lightmapScaleOffset;if(a&&(r.lightmapScaleOffset=new _n(a[0],a[1],a[2],a[3])),i.instanceParams)(_=i.instanceParams.loadPath)&&(u=W.getRes(t[_]),(this.meshFilter.sharedMesh=u).loaded?r.sharedMaterials=u.materials:u.once("loaded",this,this._applyMeshMaterials));else{(_=n.meshPath)&&(u=W.getRes(t[_]),this.meshFilter.sharedMesh=u);var o=n.materials;if(o){var s=r.sharedMaterials,l=o.length;s.length=l;for(var h=0;h<l;h++)s[h]=W.getRes(t[o[h].path]);r.sharedMaterials=s}var _=n.rootBone;_&&r._setRootBone(_);var u=n.boundBox;u?(_=u.min,d=u.max,d=new kt(new hn(_[0],_[1],_[2]),new hn(d[0],d[1],d[2])),r.localBoundBox=d):r._hasIndependentBound=!1;var d=n.boundSphere;d&&(n=d.center,d=new Yt(new hn(n[0],n[1],n[2]),d.radius),r.localBoundSphere=d)}},e._changeHierarchyAnimator=function(e){var t,n;e&&((t=this.skinnedMeshRender)._setCacheAnimator(e),(n=e.avatar)&&t._setCacheAvatar(n)),laya.d3.core.Sprite3D.prototype._changeHierarchyAnimator.call(this,e)},e._clearSelfRenderObjects=function(){this._scene.removeFrustumCullingObject(this._render)},e._addSelfRenderObjects=function(){this._scene.addFrustumCullingObject(this._render)},e._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},e.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;t=n.lightmapScaleOffset;t&&(i.lightmapScaleOffset=t.clone()),i.receiveShadow=n.receiveShadow,i.sortingFudge=n.sortingFudge,i._rootBone=n._rootBone;t=n.localBoundSphere;t&&(i.localBoundSphere=t.clone());t=n.localBoundBox;t&&(i.localBoundBox=t.clone()),i._hasIndependentBound=n._hasIndependentBound,laya.d3.core.Sprite3D.prototype.cloneTo.call(this,e)},e.destroy=function(e){void 0===e&&(e=!0),this.destroyed||(t.prototype.destroy.call(this,e),this._geometryFilter._destroy())},_(0,e,"meshFilter",function(){return this._geometryFilter}),_(0,e,"skinnedMeshRender",function(){return this._render}),n.__init__=function(){n.SHADERDEFINE_BONE=n.shaderDefines.registerDefine("BONE")},n.load=function(e){return S.loader.create(e,null,null,n)},n.SHADERDEFINE_BONE=8,n.BONES=0,l(n,["shaderDefines",function(){return this.shaderDefines=new fn(lr.shaderDefines)}]),n}(lr),Er=(function(){function a(e,t,n,i,r){void 0===e&&(e=.1),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=.3),void 0===r&&(r=1e3),this._tempMatrix=new Jt,this._leftViewMatrix=new Jt,this._leftProjectionMatrix=new Jt,this._leftProjectionViewMatrix=new Jt,this._leftViewport=new un(0,0,0,0),this._leftNormalizedViewport=new un(0,0,.5,1),this._leftAspectRatio=t,this._rightViewMatrix=new Jt,this._rightProjectionMatrix=new Jt,this._rightProjectionViewMatrix=new Jt,this._rightViewport=new un(0,0,0,0),this._rightNormalizedViewport=new un(.5,0,.5,1),this._rightAspectRatio=n,this._pupilDistande=e,this._leftBoundFrustumUpdate=!0,this._leftBoundFrustum=new Xt(Jt.DEFAULT),this._rightBoundFrustumUpdate=!0,this._rightBoundFrustum=new Xt(Jt.DEFAULT),a.__super.call(this,i,r),this.transform.on("worldmatrixneedchanged",this,this._onWorldMatrixChanged)}p(a,"laya.d3.core.VRCamera",sr);var e=a.prototype;e._onWorldMatrixChanged=function(){this._leftBoundFrustumUpdate=this._rightBoundFrustumUpdate=!0},e._calculatePupilOffset=function(){var e=this._tempVector3;return hn.scale(this.right,this._pupilDistande/2,e),e.elements},e._calculateLeftProjectionMatrix=function(){var e,t;this._useUserProjectionMatrix||(this._orthographic?(e=this.orthographicVerticalSize*this.leftAspectRatio*.5,t=.5*this.orthographicVerticalSize,Jt.createOrthoOffCenterRH(-e,e,-t,t,this.nearPlane,this.farPlane,this._leftProjectionMatrix)):Jt.createPerspective(3.1416*this.fieldOfView/180,this.leftAspectRatio,this.nearPlane,this.farPlane,this._rightProjectionMatrix)),this._leftBoundFrustumUpdate=!0},e._calculateRightProjectionMatrix=function(){var e,t;this._useUserProjectionMatrix||(this._orthographic?(e=this.orthographicVerticalSize*this.rightAspectRatio*.5,t=.5*this.orthographicVerticalSize,Jt.createOrthoOffCenterRH(-e,e,t,t,this.nearPlane,this.farPlane,this._rightProjectionMatrix)):Jt.createPerspective(3.1416*this.fieldOfView/180,this.rightAspectRatio,this.nearPlane,this.farPlane,this._rightProjectionMatrix)),this._rightBoundFrustumUpdate=!0},e._calculateProjectionMatrix=function(){var e,t,n,i;this._useUserProjectionMatrix||(this._orthographic?(e=this.orthographicVerticalSize*this.leftAspectRatio*.5,t=.5*this.orthographicVerticalSize,n=this.orthographicVerticalSize*this.rightAspectRatio*.5,i=.5*this.orthographicVerticalSize,Jt.createOrthoOffCenterRH(-e,e,-t,t,this.nearPlane,this.farPlane,this._leftProjectionMatrix),Jt.createOrthoOffCenterRH(-n,n,i,i,this.nearPlane,this.farPlane,this._rightProjectionMatrix)):(Jt.createPerspective(3.1416*this.fieldOfView/180,this.leftAspectRatio,this.nearPlane,this.farPlane,this._leftProjectionMatrix),Jt.createPerspective(3.1416*this.fieldOfView/180,this.rightAspectRatio,this.nearPlane,this.farPlane,this._rightProjectionMatrix))),this._leftBoundFrustumUpdate=this._rightBoundFrustumUpdate=!0},e._renderCamera=function(e,t,n){(t.camera=this)._prepareCameraToRender(),n._preRenderUpdateComponents(t);var i,r,a=t._viewMatrix=this.leftViewMatrix,o=this._renderTarget;o?(o.start(),Jt.multiply(sr._invertYScaleMatrix,this._leftProjectionMatrix,sr._invertYProjectionMatrix),Jt.multiply(sr._invertYScaleMatrix,this.leftProjectionViewMatrix,sr._invertYProjectionViewMatrix),i=t._projectionMatrix=sr._invertYProjectionMatrix,t._projectionViewMatrix=sr._invertYProjectionViewMatrix):(i=t._projectionMatrix=this._leftProjectionMatrix,t._projectionViewMatrix=this.leftProjectionViewMatrix),this._prepareCameraViewProject(a,i),t._viewport=this.leftViewport,n._preRenderScene(e,t,this.leftBoundFrustum),n._clear(e,t),n._renderScene(e,t),i=t._viewMatrix=this.rightViewMatrix,o?(o.start(),Jt.multiply(sr._invertYScaleMatrix,this._rightProjectionMatrix,sr._invertYProjectionMatrix),Jt.multiply(sr._invertYScaleMatrix,this.rightProjectionViewMatrix,sr._invertYProjectionViewMatrix),t._projectionMatrix=sr._invertYProjectionMatrix,r=t._projectionViewMatrix=sr._invertYProjectionViewMatrix):(r=t._projectionMatrix=this._rightProjectionMatrix,t._projectionViewMatrix=this.rightProjectionViewMatrix),this._prepareCameraViewProject(i,r),t._viewport=this.rightViewport,n._preRenderScene(e,t,this.rightBoundFrustum),n._clear(e,t),n._renderScene(e,t),n._postRenderUpdateComponents(t),o&&o.end()},_(0,e,"rightBoundFrustum",function(){return this._rightBoundFrustumUpdate&&(this._rightBoundFrustum.matrix=this.rightProjectionViewMatrix),this._rightBoundFrustum}),_(0,e,"leftNormalizedViewport",function(){var e,t,n;return this._viewportExpressedInClipSpace||(e=this._leftViewport,t=(n=this.renderTargetSize).width,n=n.height,this._leftNormalizedViewport.x=e.x/t,this._leftNormalizedViewport.y=e.y/n,this._leftNormalizedViewport.width=e.width/t,this._leftNormalizedViewport.height=e.height/n),this._leftNormalizedViewport}),_(0,e,"rightViewport",function(){var e,t,n;return this._viewportExpressedInClipSpace&&(e=this._rightNormalizedViewport,t=(n=this.renderTargetSize).width,n=n.height,this._rightViewport.x=e.x*t,this._rightViewport.y=e.y*n,this._rightViewport.width=e.width*t,this._rightViewport.height=e.height*n),this._rightViewport}),_(0,e,"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 un(0,0,e.width/2,e.height),this._rightViewport=new un(e.width/2,0,e.width/2,e.height),this._calculateProjectionMatrix()}),_(0,e,"leftAspectRatio",function(){if(0!==this._leftAspectRatio)return this._leftAspectRatio;var e=this.leftViewport;return e.width/e.height}),_(0,e,"rightAspectRatio",function(){if(0!==this._rightAspectRatio)return this._rightAspectRatio;var e=this.rightViewport;return e.width/e.height}),_(0,e,"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()}),_(0,e,"rightNormalizedViewport",function(){var e,t,n;return this._viewportExpressedInClipSpace||(e=this._rightViewport,t=(n=this.renderTargetSize).width,n=n.height,this._rightNormalizedViewport.x=e.x/t,this._rightNormalizedViewport.y=e.y/n,this._rightNormalizedViewport.width=e.width/t,this._rightNormalizedViewport.height=e.height/n),this._rightNormalizedViewport}),_(0,e,"normalizedViewport",null,function(e){if(e.x<0||e.y<0||1<e.x+e.width||1<e.x+e.height)throw new Error("VRCamera: viewport size invalid.","value");this._viewportExpressedInClipSpace=!0,this._leftNormalizedViewport=new un(0,0,e.width/2,e.height),this._rightNormalizedViewport=new un(e.width/2,0,e.width/2,e.height),this._calculateProjectionMatrix()}),_(0,e,"leftViewport",function(){var e,t,n;return this._viewportExpressedInClipSpace&&(e=this._leftNormalizedViewport,t=(n=this.renderTargetSize).width,n=n.height,this._leftViewport.x=e.x*t,this._leftViewport.y=e.y*n,this._leftViewport.width=e.width*t,this._leftViewport.height=e.height*n),this._leftViewport}),_(0,e,"needLeftViewport",function(){var e=this.leftNormalizedViewport;return 0===e.x&&0===e.y&&1===e.width&&1===e.height}),_(0,e,"needRightViewport",function(){var e=this.rightNormalizedViewport;return 0===e.x&&0===e.y&&1===e.width&&1===e.height}),_(0,e,"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}),_(0,e,"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}),_(0,e,"leftProjectionMatrix",function(){return this._leftProjectionMatrix}),_(0,e,"leftProjectionViewMatrix",function(){return Jt.multiply(this.leftProjectionMatrix,this.leftViewMatrix,this._leftProjectionViewMatrix),this._leftProjectionViewMatrix}),_(0,e,"rightProjectionMatrix",function(){return this._rightProjectionMatrix}),_(0,e,"rightProjectionViewMatrix",function(){return Jt.multiply(this.rightProjectionMatrix,this.rightViewMatrix,this._rightProjectionViewMatrix),this._rightProjectionViewMatrix}),_(0,e,"leftBoundFrustum",function(){return this._leftBoundFrustumUpdate&&(this._leftBoundFrustum.matrix=this.leftProjectionViewMatrix),this._leftBoundFrustum})}(),function(t){function e(){e.__super.call(this),this._geometryFilter=new vi(this),this._render=new gi(this),this._changeRenderObjectsByMaterial(this._render,0,zi.defaultMaterial),this._render.on("materialchanged",this,this._changeRenderObjectsByMaterial),this._geometryFilter.on("trailfilterchange",this,this._changeRenderObjectsByRenderElement)}p(e,"laya.d3.core.trail.TrailSprite3D",t);var n=e.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||zi.defaultMaterial;var i=n[e];(i=i||(n[e]=new pe))._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 pe))._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(e){t.prototype._update.call(this,e),this._geometryFilter._update(e)},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]=W.getRes(t[l[o].path]);r.sharedMaterials=h}i=i.props;a.time=i.time,a.minVertexDistance=i.minVertexDistance,a.widthMultiplier=i.widthMultiplier,a.textureMode=i.textureMode;for(var u=[],d=n.widthCurve,o=0,s=d.length;o<s;o++){var c=new ye;c.time=d[o].time,c.inTangent=d[o].inTangent,c.outTangent=d[o].outTangent,c.value=d[o].value,u.push(c)}a.widthCurve=u;i=n.colorGradient,n=new Me;n.mode=i.mode;var f,m=[],p=i.colorKeys;for(o=0,s=p.length;o<s;o++)f=p[o],f=new Ie(new De(f.value[0],f.value[1],f.value[2],1),f.time),m.push(f);var E,v=[],g=i.alphaKeys;for(o=0,s=g.length;o<s;o++)E=g[o],E=new Re(E.value,E.time),v.push(E);n.setKeys(m,v),a.colorGradient=n},n.reset=function(){this.trailFilter.reset()},n.cloneTo=function(e){laya.d3.core.Sprite3D.prototype.cloneTo.call(this,e);var t=0,n=e,i=n.trailFilter;i.time=this.trailFilter.time,i.minVertexDistance=this.trailFilter.minVertexDistance,i.widthMultiplier=this.trailFilter.widthMultiplier;for(var r=this.trailFilter.widthCurve,a=[],t=0,o=r.length;t<o;t++){var s=new ye;r[t].cloneTo(s),a.push(s)}i.widthCurve=a;e=new Me;this.trailFilter.colorGradient.cloneTo(e),i.colorGradient=e,i.textureMode=this.trailFilter.textureMode,n.trailRender.sharedMaterial=this.trailRender.sharedMaterial},n.destroy=function(e){void 0===e&&(e=!0),this.destroyed||(t.prototype.destroy.call(this,e),this._geometryFilter._destroy(),this._geometryFilter=null)},_(0,n,"trailFilter",function(){return this._geometryFilter}),_(0,n,"trailRender",function(){return this._render}),e.__init__=function(){e.SHADERDEFINE_GRADIENTMODE_BLEND=e.shaderDefines.registerDefine("GRADIENTMODE_BLEND")},e.CURTIME=3,e.LIFETIME=4,e.WIDTHCURVE=5,e.WIDTHCURVEKEYLENGTH=6,e.GRADIENTCOLORKEY=7,e.GRADIENTALPHAKEY=8,e.SHADERDEFINE_GRADIENTMODE_BLEND=0,l(e,["shaderDefines",function(){return this.shaderDefines=new fn(lr.shaderDefines)}]),e}(lr)),vr=(function(t){function e(){e.__super.call(this),this._defaultScale=new hn(.4,1,.12),this._geometryFilter=new Ti(this),this._render=new Di(this),this._changeRenderObjects(this._render,0,Wi.defaultMaterial),this._render.on("materialchanged",this,this._changeRenderObjects),this._geometryFilter.on("dominofilterchange",this,this._changeRenderObjectsByRenderElement)}p(e,"laya.d3.extension.domino.DominoSprite3D",t);var n=e.prototype;n.addDomino=function(e,t,n){void 0===e&&(e=hn.ZERO),void 0===t&&(t=rn.DEFAULT),void 0===n&&(n=this._defaultScale),this._geometryFilter.addDomino(e,t,n)},n.updateDomino=function(e,t,n,i){void 0===t&&(t=hn.ZERO),void 0===n&&(n=rn.DEFAULT),void 0===i&&(i=this._defaultScale),this._geometryFilter.updateDomino(e,t,n,i)},n.updateDominos=function(e,t,n){if(t>n.length)throw Error("Update domino count can't more than keyFrames Count!");this._geometryFilter.updateDominos(e,t,n)},n._changeRenderObjects=function(e,t,n){var i=this._geometryFilter.getDominoRenderElementsCount();this._render._renderElements.length=i;for(var r=0;r<i;r++)this._changeRenderObject(r,n)},n._changeRenderObject=function(e,t){var n=this._render._renderElements;t=t||Wi.defaultMaterial;var i=n[e];(i=i||(n[e]=new pe))._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 pe))._sprite3D=this,i.renderObj=t,i._render=this._render,i._material=this._render.sharedMaterial||Wi.defaultMaterial},n._clearSelfRenderObjects=function(){this.scene.removeFrustumCullingObject(this._render)},n._addSelfRenderObjects=function(){this.scene.addFrustumCullingObject(this._render)},n._update=function(e){t.prototype._update.call(this,e),this._geometryFilter._update(e)},_(0,n,"dominoFilter",function(){return this._geometryFilter}),_(0,n,"dominoRender",function(){return this._render})}(lr),function(t){function e(){e.__super.call(this),this._position=new hn,this._render=new xi(this),this._geometryFilter=new Si(this),this._changeRenderObjects(this._render,0,Xi.defaultMaterial),this._render.on("materialchanged",this,this._changeRenderObjects)}p(e,"laya.d3.extension.lineRender.LineSprite3D",t);var n=e.prototype;return n.addPosition=function(e,t){this._geometryFilter.addPosition(e,t)},n._changeRenderObjects=function(e,t,n){var i=this._render._renderElements;n=n||Xi.defaultMaterial;var r=i[t];(r=r||(i[t]=new pe))._sprite3D=this,r.renderObj=this._geometryFilter,r._render=this._render,r._material=n},n._clearSelfRenderObjects=function(){this.scene.removeFrustumCullingObject(this._render)},n._addSelfRenderObjects=function(){this.scene.addFrustumCullingObject(this._render)},n._update=function(e){t.prototype._update.call(this,e),this._geometryFilter._update(e)},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]=W.getRes(t[l[o].path]);r.sharedMaterials=h}r=i.props;a.widthMultiplier=r.widthMultiplier,a.textureMode=r.textureMode;for(var u=[],d=n.widthCurve,o=0,s=d.length;o<s;o++){var c=new ye;c.time=d[o].time,c.inTangent=d[o].inTangent,c.outTangent=d[o].outTangent,c.value=d[o].value,u.push(c)}a.widthCurve=u;i=n.colorGradient,r=new Me;r.mode=i.mode;var f,m=[],p=i.colorKeys;for(o=0,s=p.length;o<s;o++)f=p[o],f=new Ie(new De(f.value[0],f.value[1],f.value[2],1),f.time),m.push(f);var E,v=[],g=i.alphaKeys;for(o=0,s=g.length;o<s;o++)E=g[o],E=new Re(E.value,E.time),v.push(E);r.setKeys(m,v),a.colorGradient=r;var T,n=n.positions,S=n.size,D=n.values;for(o=0;o<S;o++)T=D[o],this._position.x=T[0],this._position.y=T[1],this._position.z=T[2],this.addPosition(this._position)},n.destroy=function(e){void 0===e&&(e=!0),this.destroyed||(t.prototype.destroy.call(this,e),this._geometryFilter._destroy(),this._position=null)},_(0,n,"lineFilter",function(){return this._geometryFilter}),_(0,n,"lineRender",function(){return this._render}),e.__init__=function(){e.SHADERDEFINE_GRADIENTMODE_BLEND=e.shaderDefines.registerDefine("GRADIENTMODE_BLEND"),e.SHADERDEFINE_TEXTUREMODE_STRETCH=e.shaderDefines.registerDefine("TEXTUREMODE"),e.SHADERDEFINE_WORLDSPACE=e.shaderDefines.registerDefine("WORLDSPACE")},e.WIDTHCURVE=3,e.WIDTHCURVEKEYLENGTH=4,e.GRADIENTCOLORKEY=5,e.GRADIENTALPHAKEY=6,e.SHADERDEFINE_WORLDSPACE=0,e.SHADERDEFINE_GRADIENTMODE_BLEND=0,e.SHADERDEFINE_TEXTUREMODE_STRETCH=0,l(e,["shaderDefines",function(){return this.shaderDefines=new fn(lr.shaderDefines)}]),e}(lr)),gr=function(t){function l(e,t,n,i,r,a,o,s){l.__super.call(this,s),this._geometryFilter=new Ri(this,e,t,n,i,r,a,o),this._render=new Ii(this)}p(l,"laya.d3.terrain.TerrainChunk",t);var e=l.prototype;return e.buildRenderElementAndMaterial=function(e,t,n,i,r,a,o,s,l,h,_,u,d,c,f,m,p,E){void 0===_&&(_=1),void 0===u&&(u=1),void 0===d&&(d=1),void 0===c&&(c=1),void 0===f&&(f=1),void 0===m&&(m=1),void 0===p&&(p=1),void 0===E&&(E=1);var v=new bi;l&&(v.diffuseColor=l),s&&(v.ambientColor=s),h&&(v.specularColor=h),v.splatAlphaTexture=W.getRes(n),v.normalTexture=t?W.getRes(t):null,v.diffuseTexture1=i?W.getRes(i):null,v.diffuseTexture2=r?W.getRes(r):null,v.diffuseTexture3=a?W.getRes(a):null,v.diffuseTexture4=o?W.getRes(o):null,v.setDiffuseScale1(_,u),v.setDiffuseScale2(d,c),v.setDiffuseScale3(f,m),v.setDiffuseScale4(p,E),v.setDetailNum(e),0!=this._render._renderElements.length&&(v.renderMode=2);e=new pe;e._mainSortID=0,e._sprite3D=this,e.renderObj=this._geometryFilter,e._material=v,this._render._materials.push(v),this._render._renderElements.push(e)},e._clearSelfRenderObjects=function(){this.scene.removeFrustumCullingObject(this._render)},e._addSelfRenderObjects=function(){this.scene.addFrustumCullingObject(this._render)},e._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},e.cloneTo=function(e){console.log("Terrain Chunk can't clone")},e.destroy=function(e){void 0===e&&(e=!0),this.destroyed||(t.prototype.destroy.call(this,e),this._geometryFilter._destroy())},_(0,e,"terrainFilter",function(){return this._geometryFilter}),_(0,e,"terrainRender",function(){return this._render}),l.load=function(e){return S.loader.create(e,null,null,l,null,1,!1)},l}(lr);(function(){function h(e,t,n){this._minX=NaN,this._minZ=NaN,this._cellSize=null,this._heightMap=null,h.__super.call(this,e,n),this._heightMap=t,this._cellSize=new ln}p(h,"laya.d3.core.MeshTerrainSprite3D",fr);var e=h.prototype;e._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},e._getScaleX=function(){var e=this.transform.worldMatrix.elements,t=e[0],n=e[1],e=e[2];return Math.sqrt(t*t+n*n+e*e)},e._getScaleZ=function(){var e=this.transform.worldMatrix.elements,t=e[8],n=e[9],e=e[10];return Math.sqrt(t*t+n*n+e*e)},e._initCreateFromMesh=function(e,t){this._heightMap=Y.creatFromMesh(this.meshFilter.sharedMesh,e,t,this._cellSize);e=this.meshFilter.sharedMesh.boundingBox,t=e.min,e.max;this._minX=t.x,this._minZ=t.z},e._initCreateFromMeshHeightMap=function(e,t,n){var i=this,r=this.meshFilter.sharedMesh.boundingBox;e.loaded?(this._heightMap=Y.createFromImage(e,t,n),this._computeCellSize(r)):e.once("loaded",null,function(){i._heightMap=Y.createFromImage(e,t,n),i._computeCellSize(r)});var a=r.min;r.max;this._minX=a.x,this._minZ=a.z},e._computeCellSize=function(e){var t=e.min,n=e.max,i=t.x,e=t.z,t=n.x,e=n.z-e;this._cellSize.elements[0]=(t-i)/(this._heightMap.width-1),this._cellSize.elements[1]=e/(this._heightMap.height-1)},e._update=function(e){this._disableRotation(),laya.d3.core.RenderableSprite3D.prototype._update.call(this,e)},e.getHeight=function(e,t){h._tempVector3.elements[0]=e,h._tempVector3.elements[1]=0,h._tempVector3.elements[2]=t,this._disableRotation();var n=this.transform.worldMatrix;n.invert(h._tempMatrix4x4),hn.transformCoordinate(h._tempVector3,h._tempMatrix4x4,h._tempVector3),e=h._tempVector3.elements[0],t=h._tempVector3.elements[2];var i=(e-this._minX)/this._cellSize.x,r=(t-this._minZ)/this._cellSize.y,a=Math.floor(r),o=Math.floor(i),s=i-o,l=r-a,e=n.elements,t=e[4],i=e[5],r=e[6],n=Math.sqrt(t*t+i*i+r*r),t=e[13],i=this._heightMap.getHeight(a,o+1),r=this._heightMap.getHeight(a+1,o);if(isNaN(i)||isNaN(r))return NaN;if(s+l<=1){e=this._heightMap.getHeight(a,o);return isNaN(e)?NaN:(e+s*(i-e)+l*(r-e))*n+t}o=this._heightMap.getHeight(a+1,o+1);return isNaN(o)?NaN:(o+(1-s)*(r-o)+(1-l)*(i-o))*n+t},_(0,e,"minX",function(){var e=this.transform.worldMatrix.elements;return this._minX*this._getScaleX()+e[12]}),_(0,e,"width",function(){return(this._heightMap.width-1)*this._cellSize.x*this._getScaleX()}),_(0,e,"minZ",function(){var e=this.transform.worldMatrix.elements;return this._minZ*this._getScaleZ()+e[14]}),_(0,e,"depth",function(){return(this._heightMap.height-1)*this._cellSize.y*this._getScaleZ()}),h.createFromMesh=function(e,t,n,i){i=new h(e,null,i);return e.loaded?i._initCreateFromMesh(t,n):e.once("loaded",i,i._initCreateFromMesh,[t,n]),i},h.createFromMeshAndHeightMap=function(e,t,n,i,r){r=new h(e,null,r);return e.loaded?r._initCreateFromMeshHeightMap(t,n,i):e.once("loaded",r,r._initCreateFromMeshHeightMap,[t,n,i]),r},l(h,["_tempVector3",function(){return this._tempVector3=new hn},"_tempMatrix4x4",function(){return this._tempMatrix4x4=new Jt}])})(),function(){function d(e,t){this.mtl=null,this.detailMtl=null,this.mesh=null,this.useRefrTex=!0,this.renderDetailWav=!0,this._stop=!1,this._texWave=null,this._texRefract=null,this._detailMesh=null,this._texWaveDegTest=0,this._shownormal=!1,this._refractQueue=null,this._waterLoaded=!1,this._waterFogStart=0,this._waterFogRange=20,this.startTm=0,this.curTm=0,this._syncObj=null,this.afterDescLoaded=null,this._geoWaveInfo=new Float32Array(4*d._waveInfoEleNum),this._geoWaveInfoDir=new Float32Array(8),this._texWaveInfo=new Float32Array(15*d._waveInfoEleNum),this._texWaveInfoDir=new Float32Array(30),this._texWaveTrans=new Float32Array(9),this._refractObjStack=[],this._refractObjecs=[],this._scrSizeInfo=new Float32Array(2),this._waterColor=new hn,d.__super.call(this,e,t),this.mtl=new Bi,this.startTm=S.timer.currTimer,this.curTm=0}p(d,"laya.d3.water.WaterSprite",fr);var e=d.prototype;e._getWaveInfo=function(e,t,n,i,r,a,o){var s=n*d._waveInfoEleNum,n=2*n,i=i*d.deg2rad;t[n++]=Math.cos(i),t[n++]=Math.sin(i),e[s++]=a,e[s++]=o,e[s++]=d._2pi/r,e[+s]=7.846987702957/Math.sqrt(r)},e.onDescLoaded=function(e){var n=this,t=er.load(e.mesh);this._texWave=new tr(e.detailTexSize[0],e.detailTexSize[1],6408,5121,33189,!1,!1),this.useRefrTex?(this._texRefract=new tr(e.refracTexSize[0],e.refracTexSize[1]),this._texRefract.repeat=!1,this._texRefract.mipmap=!0,this.mtl.useRefractTexture=!0):this.mtl.useRefractTexture=!1,(this._geometryFilter.sharedMesh=t).once("loaded",this,this._applyMeshMaterials),t.on("loaded",this,this.onMeshLoaded),".ltc"===e.skyTexture.substr(e.skyTexture.length-4).toLowerCase()?(this.mtl.skyTexture=ar.load(e.skyTexture),this.mtl._addShaderDefine(Bi.SHADERDEFINE_CUBE_ENV)):(this.mtl.skyTexture=rr.load(e.skyTexture),this.mtl._removeShaderDefine(Bi.SHADERDEFINE_CUBE_ENV)),e.hdrsky&&this.mtl._addShaderDefine(Bi.SHADERDEFINE_HDR_ENV),null!=e.deepScale&&(this.mtl.deepScale=e.deepScale),e.useVertexDeep&&(this.mtl.useVertexDeep=!0),this.mtl.skyTexture.repeat=!0;t=rr.load(e.infoTexture);t.repeat=!1,this.mtl.waterInfoTexture=t;t=rr.load(e.foamTexture);if(t.repeat=!0,this.mtl.foamTexture=t,this.mtl.renderMode=13,this.mtl.waveMainDir=e.geoWaveData[0].dir,this.mtl.geoWaveUVScale=e.geoWaveUVScale,this._detailMesh=new ur(2,2),this.detailMtl=new Zi,this.detailMtl.texWaveUVScale=e.detailWaveUVScale,4!=e.geoWaveData.length)throw"error 3";if(4!=e.detailData.length)throw"error 4";e.geoWaveData.forEach(function(e,t){n._getWaveInfo(n._geoWaveInfo,n._geoWaveInfoDir,t,e.dir,e.L,e.Q,e.A)});e.detailData.forEach(function(e,t){n._getWaveInfo(n._texWaveInfo,n._texWaveInfoDir,t,e.dir,e.L,1.5,.01*e.L)}),this._waterColor.x=e.color[0]/255,this._waterColor.y=e.color[1]/255,this._waterColor.z=e.color[2]/255,this.mtl.seaColor=new Float32Array([this._waterColor.x,this._waterColor.y,this._waterColor.z]),this._waterFogStart=e.fogStart,this._waterFogRange=e.fogRange,this.afterDescLoaded&&this.afterDescLoaded.call(this)},e.onMeshLoaded=function(){if(this._refractQueue=new Ee(this._scene),this._scrSizeInfo[0]=S.stage.width,this._scrSizeInfo[1]=S.stage.height,this.mtl.scrsize=this._scrSizeInfo,this.meshRender.sharedMaterial=this.mtl,!(0<this._render._renderElements.length))throw"error2";this._render._renderElements[0]._onPreRenderFunction=this.onPreRender,this._waterLoaded=!0},e.stop=function(){this._stop=!this._stop},e.addRefractObj=function(e){this._refractObjStack.push(e),this._refractObjecs.push(e)},e.onPreRender=function(t){var n=this;if(this._waterLoaded){if(this._refractObjStack.length)for(var e=0;e<this._refractObjStack.length;e++){var i=this._refractObjStack[e];i._render._renderElements.length&&(i._render._renderElements.forEach(function(e){n._refractQueue._addRenderElement(e)}),this._refractObjStack.splice(e,1),e--)}var r,a,o,s=N.mainContext,l=s.getParameter(2929),h=s.getParameter(2884),_=s.getParameter(2978),u=!1;this.useRefrTex&&(this._texRefract.start(),u=!0,s.viewport(0,0,this._texRefract.width,this._texRefract.height),s.clearColor(this._waterColor.x,this._waterColor.y,this._waterColor.z,1),s.clear(16640),this._refractObjecs.forEach(function(e){e._renderUpdate(t._projectionViewMatrix)}),this._refractQueue._preRender(t),this._refractQueue._render(t,!1),this._texRefract.end(),this._texRefract.repeat=!0),this.renderDetailWav&&(this._texWave.start(),s.disable(2929),s.disable(2884),u=!0,s.viewport(0,0,d.detailTexWidth,d.detailTexHeight),(r=this._detailMesh.getRenderElement(0))._beforeRender(t),this.detailMtl.currentTm=S.timer.currTimer,this.detailMtl.waveInfo=this._texWaveInfo,this.detailMtl.waveInfoD=this._texWaveInfoDir,(a=this.detailMtl._getShader(0,0,0)).bind(),o=this._detailMesh._getVertexBuffer(0),a.uploadAttributes(o.vertexDeclaration.shaderValues.data,null),this.detailMtl._upload(),r._render(t),this._texWave.end(),l&&s.enable(2929),h&&s.enable(2884)),u&&s.viewport(_[0],_[1],_[2],_[3]),this._syncObj?this.mtl.detailTexture=this._syncObj._texWave:this.mtl.detailTexture=this._texWave,this.mtl.waveInfo=this._geoWaveInfo,this.mtl.waveInfoD=this._geoWaveInfoDir,this.mtl.underWaterTexture=this._texRefract,this._stop||(this._syncObj?this.curTm=this._syncObj.curTm:this.curTm=S.timer.currTimer-this.startTm,this.mtl._setNumber(8,this.curTm)),c.shownormal&&!this._shownormal&&(this._shownormal=!0,this.mtl._addShaderDefine(Bi.SHADERDEFINE_SHOW_NORMAL)),c.shownormal&&this._shownormal&&(this._shownormal=!1,this.mtl._removeShaderDefine(Bi.SHADERDEFINE_SHOW_NORMAL))}},e._update=function(e){laya.d3.core.RenderableSprite3D.prototype._update.call(this,e)},_(0,e,"src",null,function(e){var t=new W;t.on("complete",this,this.onDescLoaded),t.load(e)}),_(0,e,"syncObj",null,function(e){this._syncObj=e,this.renderDetailWav=!1}),d._waveInfoEleNum=4,d.detailTexWidth=256,d.detailTexHeight=256,l(d,["deg2rad",function(){return this.deg2rad=Math.PI/180},"_2pi",function(){return this._2pi=2*Math.PI}])}()}(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)}});