From 33395f0b0ed54037783e144d7e25b24c5a96f191 Mon Sep 17 00:00:00 2001 From: gz65555 Date: Wed, 22 May 2024 09:24:00 +0000 Subject: [PATCH] deploy: 1f79ee7485f801ec68b59587083fcf29c11c88e1 --- ... galacean-animation-benchmark-SzZGhUHK.js} | 2 +- ...> galacean-collider-benchmark-BtnQXXUc.js} | 2 +- ...> galacean-particle-benchmark-DAiG37RQ.js} | 2 +- ...ve.js => galacean-point-light-88Jsv51t.js} | 2 +- assets/main-DN4-Fq5i.js | 2 +- ...{module-BxLNiwNf.js => module-BIoDltUI.js} | 210 +++++++++--------- mpa/galacean/animation-benchmark.html | 4 +- mpa/galacean/collider-benchmark.html | 4 +- mpa/galacean/particle-benchmark.html | 4 +- mpa/galacean/point-light.html | 4 +- 10 files changed, 118 insertions(+), 118 deletions(-) rename assets/{galacean-animation-benchmark-aGSkcfOi.js => galacean-animation-benchmark-SzZGhUHK.js} (94%) rename assets/{galacean-collider-benchmark-CcGWO5G-.js => galacean-collider-benchmark-BtnQXXUc.js} (99%) rename assets/{galacean-particle-benchmark-xLEHfqG5.js => galacean-particle-benchmark-DAiG37RQ.js} (96%) rename assets/{galacean-point-light-Cddt05ve.js => galacean-point-light-88Jsv51t.js} (99%) rename assets/{module-BxLNiwNf.js => module-BIoDltUI.js} (60%) diff --git a/assets/galacean-animation-benchmark-aGSkcfOi.js b/assets/galacean-animation-benchmark-SzZGhUHK.js similarity index 94% rename from assets/galacean-animation-benchmark-aGSkcfOi.js rename to assets/galacean-animation-benchmark-SzZGhUHK.js index 7467d11..5b4b87e 100644 --- a/assets/galacean-animation-benchmark-aGSkcfOi.js +++ b/assets/galacean-animation-benchmark-SzZGhUHK.js @@ -1 +1 @@ -import"./modulepreload-polyfill-B5Qt9EMX.js";import{W as A,C as f,V as p,D as h,A as y,a as C}from"./module-BxLNiwNf.js";A.create({canvas:"canvas",graphicDeviceOptions:{powerPreference:"high-performance"}}).then(t=>{t.canvas.resizeByClientSize();const e=t.sceneManager.activeScene,s=e.createRootEntity();e.ambientLight.diffuseSolidColor.set(1,1,1,1),e.ambientLight.diffuseIntensity=0;const o=s.createChild("Camera");o.transform.setPosition(6.5*1.5,6.58*1.5,8.5*1.5);const d=o.addComponent(f);o.transform.lookAt(new p(0,0,0)),d.farClipPlane=1e3;const r=e.createRootEntity("light").addComponent(h);r.intensity=.6,r.direction.set(0,-.5,-1),console.time("load"),t.resourceManager.load({url:"https://mdn.alipayobjects.com/rms/afts/file/A*DVfMRKjm6bMAAAAAAAAAAAAAARQnAQ/HVGirl.glb",type:y.GLTF}).then(c=>{const m=c.instantiateSceneRoot();m.transform.setScale(5e-4,5e-4,5e-4);for(let n=0;n<15;n++)for(let a=0;a<15;a++){const i=m.clone();s.addChild(i);const{transform:l}=i;l.position.x=-2.4*1.8+n*.6,l.position.z=-2.4*2+a*.6,i.getComponent(C).play(c.animations[1].name,void 0,Math.random())}console.timeEnd("load")}),t.run()}); +import"./modulepreload-polyfill-B5Qt9EMX.js";import{W as A,C as f,V as p,D as h,A as y,a as C}from"./module-BIoDltUI.js";A.create({canvas:"canvas",graphicDeviceOptions:{powerPreference:"high-performance"}}).then(t=>{t.canvas.resizeByClientSize();const e=t.sceneManager.activeScene,s=e.createRootEntity();e.ambientLight.diffuseSolidColor.set(1,1,1,1),e.ambientLight.diffuseIntensity=0;const o=s.createChild("Camera");o.transform.setPosition(6.5*1.5,6.58*1.5,8.5*1.5);const d=o.addComponent(f);o.transform.lookAt(new p(0,0,0)),d.farClipPlane=1e3;const r=e.createRootEntity("light").addComponent(h);r.intensity=.6,r.direction.set(0,-.5,-1),console.time("load"),t.resourceManager.load({url:"https://mdn.alipayobjects.com/rms/afts/file/A*DVfMRKjm6bMAAAAAAAAAAAAAARQnAQ/HVGirl.glb",type:y.GLTF}).then(c=>{const m=c.instantiateSceneRoot();m.transform.setScale(5e-4,5e-4,5e-4);for(let n=0;n<15;n++)for(let a=0;a<15;a++){const i=m.clone();s.addChild(i);const{transform:l}=i;l.position.x=-2.4*1.8+n*.6,l.position.z=-2.4*2+a*.6,i.getComponent(C).play(c.animations[1].name,void 0,Math.random())}console.timeEnd("load")}),t.run()}); diff --git a/assets/galacean-collider-benchmark-CcGWO5G-.js b/assets/galacean-collider-benchmark-BtnQXXUc.js similarity index 99% rename from assets/galacean-collider-benchmark-CcGWO5G-.js rename to assets/galacean-collider-benchmark-BtnQXXUc.js index 2985799..53cf3df 100644 --- a/assets/galacean-collider-benchmark-CcGWO5G-.js +++ b/assets/galacean-collider-benchmark-BtnQXXUc.js @@ -1 +1 @@ -import"./modulepreload-polyfill-B5Qt9EMX.js";import{V as h,Q as y,W as U,C as Q,D as q,S as Y,P as G,M as k,b as V,c as K,d as j,B as Z,e as $}from"./module-BxLNiwNf.js";function A(o,s){return s!=null&&typeof Symbol<"u"&&s[Symbol.hasInstance]?!!s[Symbol.hasInstance](o):o instanceof s}function w(o,s){return w=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},w(o,s)}function m(o,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");o.prototype=Object.create(s&&s.prototype,{constructor:{value:o,writable:!0,configurable:!0}}),s&&w(o,s)}var W=function(){function o(n){n===void 0&&(n=0),this.length=0,this._elements=new Array(n)}var s=o.prototype;return s.add=function(t){this.length===this._elements.length?this._elements.push(t):this._elements[this.length]=t,this.length++},s.delete=function(t){var e=this._elements.indexOf(t);this.deleteByIndex(e)},s.get=function(t){if(t>=this.length)throw"Index is out of range.";return this._elements[t]},s.deleteByIndex=function(t){var e=this._elements,i=null,r=this.length-1;return t!==r&&(i=e[r],e[t]=i),this.length--,i},s.garbageCollection=function(){this._elements.length=this.length},o}(),X;(function(o){o[o.SIMULATION_SHAPE=1]="SIMULATION_SHAPE",o[o.SCENE_QUERY_SHAPE=2]="SCENE_QUERY_SHAPE",o[o.TRIGGER_SHAPE=4]="TRIGGER_SHAPE"})(X||(X={}));var x=function(){function o(n){this._controllers=new W,this._worldScale=new h(1,1,1),this._position=new h,this._rotation=null,this._axis=null,this._physXRotation=new y,this._shapeFlags=3,this._physXPhysics=n}var s=o.prototype;return s.setRotation=function(t){this._rotation=t,y.rotationYawPitchRoll(t.x,t.y,t.z,this._physXRotation),this._axis&&y.multiply(this._physXRotation,this._axis,this._physXRotation),this._physXRotation.normalize(),this._setLocalPose()},s.setPosition=function(t){t!==this._position&&this._position.copyFrom(t);for(var e=this._controllers,i=0,r=e.length;i=0;c--){var u=r.get(c);u.index1==a?(r.deleteByIndex(c),i.push(u)):u.index2==a&&(r.deleteByIndex(c),i.push(u),_[u.index1][a]=void 0)}delete _[a]},s.addCollider=function(t){this._pxScene.addActor(t._pxActor,null)},s.removeCollider=function(t){this._pxScene.removeActor(t._pxActor,!0)},s.addCharacterController=function(t){if(!t._pxController){var e=t._shape;if(e){var i=t._pxManager;i!==this&&(i&&t._destroyPXController(),t._createPXController(this,e))}}t._pxManager=this},s.removeCharacterController=function(t){t._pxManager=null},s.update=function(t){this._simulate(t),this._fetchResults(),this._fireEvent()},s.raycast=function(t,e,i,r){var a=this,l=a._pxRaycastHit;e=Math.min(e,34e37);var _={preFilter:function(M,f,d){return i(f)?2:0},postFilter:function(M,f){}},c=this._pxScene.raycastSingle(t.origin,t.direction,e,l,this._pxFilterData,this._physXPhysics._physX.PxQueryFilterCallback.implement(_));if(c&&r!=null){var u=o._tempPosition,g=o._tempNormal,S=l.position,C=l.normal;u.set(S.x,S.y,S.z),g.set(C.x,C.y,C.z),r(l.getShape().getUUID(),l.distance,u,g)}return c},s._getControllerManager=function(){var t=this._pxControllerManager;return t===null&&(this._pxControllerManager=t=this._pxScene.createControllerManager()),t},s._simulate=function(t){this._pxScene.simulate(t,!0)},s._fetchResults=function(t){t===void 0&&(t=!0),this._pxScene.fetchResults(t)},s._getTrigger=function(t,e){var i;return this._eventPool.length?(i=this._eventPool.pop(),i.index1=t,i.index2=e):i=new it(t,e),this._physXManager._eventMap[t][e]=i,i},s._fireEvent=function(){for(var t=this,e=t._eventPool,i=t._currentEvents,r=i.length-1;r>=0;r--){var a=i.get(r);a.state==0?(this._onTriggerEnter(a.index1,a.index2),a.state=1):a.state==1?this._onTriggerStay(a.index1,a.index2):a.state==2&&(this._onTriggerExit(a.index1,a.index2),i.deleteByIndex(r),e.push(a))}},o}();(function(){R._tempPosition=new h})();(function(){R._tempNormal=new h})();var B;(function(o){o[o.STATIC=1]="STATIC",o[o.DYNAMIC=2]="DYNAMIC",o[o.PRE_FILTER=4]="PRE_FILTER",o[o.POST_FILTER=8]="POST_FILTER",o[o.ANY_HIT=16]="ANY_HIT",o[o.NO_BLOCK=32]="NO_BLOCK"})(B||(B={}));var H;(function(o){o[o.Enter=0]="Enter",o[o.Stay=1]="Stay",o[o.Exit=2]="Exit"})(H||(H={}));var it=function(s,n){this.index1=s,this.index2=n},nt=function(o){m(s,o);function s(n,t,e){var i;return i=o.call(this,n)||this,i._pxActor=n._pxPhysics.createRigidStatic(i._transform(t,e)),i}return s}(F),v;(function(o){o[o.Auto=0]="Auto",o[o.WebAssembly=1]="WebAssembly",o[o.JavaScript=2]="JavaScript"})(v||(v={}));var p=function(){function o(n){this._connectedAnchor=new h,this._breakForce=Number.MAX_VALUE,this._breakTorque=Number.MAX_VALUE,this._physXPhysics=n}var s=o.prototype;return s.setConnectedCollider=function(t){var e,i;this._pxJoint.setActors(((e=t)==null?void 0:e._pxActor)||null,((i=this._collider)==null?void 0:i._pxActor)||null)},s.setConnectedAnchor=function(t){this._connectedAnchor.copyFrom(t),this._setLocalPose(0,t,o._defaultQuat)},s.setConnectedMassScale=function(t){this._pxJoint.setInvMassScale0(1/t)},s.setConnectedInertiaScale=function(t){this._pxJoint.setInvInertiaScale0(1/t)},s.setMassScale=function(t){this._pxJoint.setInvMassScale1(1/t)},s.setInertiaScale=function(t){this._pxJoint.setInvInertiaScale1(1/t)},s.setBreakForce=function(t){this._breakForce=t,this._pxJoint.setBreakForce(this._breakForce,this._breakTorque)},s.setBreakTorque=function(t){this._breakTorque=t,this._pxJoint.setBreakForce(this._breakForce,this._breakTorque)},s._setLocalPose=function(t,e,i){this._pxJoint.setLocalPose(t,e,i)},o}();(function(){p._xAxis=new h(1,0,0)})();(function(){p._defaultVec=new h})();(function(){p._defaultQuat=new y})();var st=function(o){m(s,o);function s(n,t){var e;return e=o.call(this,n)||this,e._collider=t,e._pxJoint=n._pxPhysics.createFixedJoint(null,p._defaultVec,p._defaultQuat,t._pxActor,p._defaultVec,p._defaultQuat),e}return s}(p),ot=function(o){m(s,o);function s(t,e){var i;return i=o.call(this,t)||this,i._axisRotationQuaternion=new y,i._swingOffset=new h,i._collider=e,i._pxJoint=t._pxPhysics.createRevoluteJoint(null,p._defaultVec,p._defaultQuat,e._pxActor,p._defaultVec,p._defaultQuat),i}var n=s.prototype;return n.setAxis=function(e){var i=p._xAxis,r=this._axisRotationQuaternion;i.set(1,0,0),e.normalize();var a=Math.acos(h.dot(i,e));h.cross(i,e,i),y.rotationAxisAngle(i,a,r),this._setLocalPose(0,this._swingOffset,r)},n.setSwingOffset=function(e){this._swingOffset.copyFrom(e),this._setLocalPose(1,this._swingOffset,this._axisRotationQuaternion)},n.getAngle=function(){return this._pxJoint.getAngle()},n.getVelocity=function(){return this._pxJoint.getVelocity()},n.setHardLimit=function(e,i,r){this._pxJoint.setHardLimit(e,i,r)},n.setSoftLimit=function(e,i,r,a){this._pxJoint.setSoftLimit(e,i,r,a)},n.setDriveVelocity=function(e,i){i===void 0&&(i=!0),this._pxJoint.setDriveVelocity(e,i)},n.setDriveForceLimit=function(e){this._pxJoint.setDriveForceLimit(e)},n.setDriveGearRatio=function(e){this._pxJoint.setDriveGearRatio(e)},n.setHingeJointFlag=function(e,i){this._pxJoint.setRevoluteJointFlag(e,i)},s}(p),rt=function(o){m(s,o);function s(t,e){var i;return i=o.call(this,t)||this,i._swingOffset=new h,i._collider=e,i._pxJoint=t._pxPhysics.createDistanceJoint(null,p._defaultVec,p._defaultQuat,e._pxActor,p._defaultVec,p._defaultQuat),i._pxJoint.setDistanceJointFlag(2,!0),i._pxJoint.setDistanceJointFlag(4,!0),i._pxJoint.setDistanceJointFlag(8,!0),i}var n=s.prototype;return n.setSwingOffset=function(e){this._swingOffset.copyFrom(e),this._setLocalPose(1,e,p._defaultQuat)},n.setMinDistance=function(e){this._pxJoint.setMinDistance(e)},n.setMaxDistance=function(e){this._pxJoint.setMaxDistance(e)},n.setTolerance=function(e){this._pxJoint.setTolerance(e)},n.setStiffness=function(e){this._pxJoint.setStiffness(e)},n.setDamping=function(e){this._pxJoint.setDamping(e)},s}(p),at=function(o){m(s,o);function s(n,t,e){var i;return i=o.call(this,n)||this,i._axis=new y(0,0,x.halfSqrt,x.halfSqrt),i._physXRotation.copyFrom(i._axis),i._pxGeometry=new n._physX.PxPlaneGeometry,i._initialize(e,t),i._setLocalPose(),i}return s}(x),lt=function(o){m(s,o);function s(t,e,i,r){var a;return a=o.call(this,t)||this,a._maxScale=1,a._radius=i,a._pxGeometry=new t._physX.PxSphereGeometry(a._radius*a._maxScale),a._initialize(r,e),a._setLocalPose(),a}var n=s.prototype;return n.setRadius=function(e){this._radius=e,this._pxGeometry.radius=e*this._maxScale,this._pxShape.setGeometry(this._pxGeometry)},n.setWorldScale=function(e){o.prototype.setWorldScale.call(this,e),this._maxScale=Math.max(Math.abs(e.x),Math.abs(e.y),Math.abs(e.z)),this._pxGeometry.radius=this._radius*this._maxScale,this._pxShape.setGeometry(this._pxGeometry)},s}(x),ht=function(){function o(n){n===void 0&&(n=v.Auto),this._initializeState=0,this._runTimeMode=n}var s=o.prototype;return s.initialize=function(){var t=this;if(this._initializeState===2)return Promise.resolve();if(this._initializeState===1)return this._initializePromise;var e=this._runTimeMode,i=new Promise(function(a,l){var _=document.createElement("script");if(document.body.appendChild(_),_.async=!0,_.onload=a,_.onerror=l,e==v.Auto){var c=function(){try{if(typeof WebAssembly=="object"&&typeof WebAssembly.instantiate=="function"){var u=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(A(u,WebAssembly.Module))return A(new WebAssembly.Instance(u),WebAssembly.Instance)}}catch{}return!1}();c?e=v.WebAssembly:e=v.JavaScript}e==v.JavaScript?_.src="https://mdn.alipayobjects.com/rms/afts/file/A*rnDeR58NNGoAAAAAAAAAAAAAARQnAQ/physx.release.js.js":e==v.WebAssembly&&(_.src="https://mdn.alipayobjects.com/rms/afts/file/A*nA97QLQehRMAAAAAAAAAAAAAARQnAQ/physx.release.js")}),r=new Promise(function(a,l){i.then(function(){return window.PHYSX().then(function(_){t._init(_),t._initializeState=2,t._initializePromise=null,console.log("PhysX loaded."),a()},l)},l).catch(l)});return this._initializePromise=r,r},s.destroy=function(){this._physX.PxCloseExtensions(),this._pxPhysics.release(),this._pxFoundation.release(),this._physX=null,this._pxFoundation=null,this._pxPhysics=null},s.createPhysicsManager=function(){return new tt},s.createPhysicsScene=function(t,e,i,r,a,l,_){var c=new R(this,t,e,i,r,a,l,_);return c},s.createStaticCollider=function(t,e){return new nt(this,t,e)},s.createDynamicCollider=function(t,e){return new E(this,t,e)},s.createCharacterController=function(){return new O(this)},s.createPhysicsMaterial=function(t,e,i,r,a){return new et(this,t,e,i,r,a)},s.createBoxColliderShape=function(t,e,i){return new b(this,t,e,i)},s.createSphereColliderShape=function(t,e,i){return new lt(this,t,e,i)},s.createPlaneColliderShape=function(t,e){return new at(this,t,e)},s.createCapsuleColliderShape=function(t,e,i,r){return new N(this,t,e,i,r)},s.createFixedJoint=function(t){return new st(this,t)},s.createHingeJoint=function(t){return new ot(this,t)},s.createSpringJoint=function(t){return new rt(this,t)},s._init=function(t){var e=t.PX_PHYSICS_VERSION,i=new t.PxDefaultErrorCallback,r=new t.PxDefaultAllocator,a=t.PxCreateFoundation(e,r,i),l=t.PxCreatePhysics(e,a,new t.PxTolerancesScale,!1,null);t.PxInitExtensions(l,null),this._physX=t,this._pxFoundation=a,this._pxPhysics=l},o}(),J;(function(o){o[o.Uninitialized=0]="Uninitialized",o[o.Initializing=1]="Initializing",o[o.Initialized=2]="Initialized"})(J||(J={}));var ct="1.2.0-beta.4";console.log("Galacean PhysX version: "+ct);function _t(o){const s=new y;pt(o,new h(30,0,30),new h(0,-.5,0),new y);var n=0;setInterval(()=>{n>1e3||(ut(o,new h(.075,.075,.075),new h(Math.random()-.5,Math.random()*2+2.5,Math.random()-.5),s),n++)},16)}function pt(o,s,n,t){const e=new G(o.engine);e.baseColor.set(.2179807202597362,.2939682161541871,.31177952549087606,1),e.roughness=0,e.metallic=0;const i=o.createChild(),r=i.addComponent(k);r.mesh=V.createCuboid(o.engine,s.x,s.y,s.z),r.setMaterial(e),i.transform.position=n,i.transform.rotationQuaternion=t,r.receiveShadows=!1;const a=new K;return a.position.set(0,s.y,0),i.addComponent(j).addShape(a),i}function ut(o,s,n,t){const e=new G(o.engine);e.baseColor.set(Math.random(),Math.random(),Math.random(),1),e.metallic=0,e.roughness=0;const i=o.createChild(),r=i.addComponent(k);r.mesh=V.createCuboid(o.engine,s.x,s.y,s.z),r.setMaterial(e),i.transform.position=n,i.transform.rotationQuaternion=t,r.castShadows=!1;const a=new Z;return a.size=s,i.addComponent($).addShape(a),i}U.create({canvas:"canvas",physics:new ht,graphicDeviceOptions:{powerPreference:"high-performance"}}).then(o=>{o.canvas.resizeByClientSize();const n=o.sceneManager.activeScene.createRootEntity(),t=n.createChild("camera");t.addComponent(Q),t.transform.position.set(-1,1.5,2),t.transform.lookAt(new h);const i=n.createChild("light");i.transform.setPosition(-.3,1,.4),i.transform.lookAt(new h(0,0,0));const r=i.addComponent(q);r.intensity=1,r.shadowType=Y.None,_t(n),o.run()}); +import"./modulepreload-polyfill-B5Qt9EMX.js";import{V as h,Q as y,W as U,C as Q,D as q,S as Y,P as G,M as k,b as V,c as K,d as j,B as Z,e as $}from"./module-BIoDltUI.js";function A(o,s){return s!=null&&typeof Symbol<"u"&&s[Symbol.hasInstance]?!!s[Symbol.hasInstance](o):o instanceof s}function w(o,s){return w=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},w(o,s)}function m(o,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");o.prototype=Object.create(s&&s.prototype,{constructor:{value:o,writable:!0,configurable:!0}}),s&&w(o,s)}var W=function(){function o(n){n===void 0&&(n=0),this.length=0,this._elements=new Array(n)}var s=o.prototype;return s.add=function(t){this.length===this._elements.length?this._elements.push(t):this._elements[this.length]=t,this.length++},s.delete=function(t){var e=this._elements.indexOf(t);this.deleteByIndex(e)},s.get=function(t){if(t>=this.length)throw"Index is out of range.";return this._elements[t]},s.deleteByIndex=function(t){var e=this._elements,i=null,r=this.length-1;return t!==r&&(i=e[r],e[t]=i),this.length--,i},s.garbageCollection=function(){this._elements.length=this.length},o}(),X;(function(o){o[o.SIMULATION_SHAPE=1]="SIMULATION_SHAPE",o[o.SCENE_QUERY_SHAPE=2]="SCENE_QUERY_SHAPE",o[o.TRIGGER_SHAPE=4]="TRIGGER_SHAPE"})(X||(X={}));var x=function(){function o(n){this._controllers=new W,this._worldScale=new h(1,1,1),this._position=new h,this._rotation=null,this._axis=null,this._physXRotation=new y,this._shapeFlags=3,this._physXPhysics=n}var s=o.prototype;return s.setRotation=function(t){this._rotation=t,y.rotationYawPitchRoll(t.x,t.y,t.z,this._physXRotation),this._axis&&y.multiply(this._physXRotation,this._axis,this._physXRotation),this._physXRotation.normalize(),this._setLocalPose()},s.setPosition=function(t){t!==this._position&&this._position.copyFrom(t);for(var e=this._controllers,i=0,r=e.length;i=0;c--){var u=r.get(c);u.index1==a?(r.deleteByIndex(c),i.push(u)):u.index2==a&&(r.deleteByIndex(c),i.push(u),_[u.index1][a]=void 0)}delete _[a]},s.addCollider=function(t){this._pxScene.addActor(t._pxActor,null)},s.removeCollider=function(t){this._pxScene.removeActor(t._pxActor,!0)},s.addCharacterController=function(t){if(!t._pxController){var e=t._shape;if(e){var i=t._pxManager;i!==this&&(i&&t._destroyPXController(),t._createPXController(this,e))}}t._pxManager=this},s.removeCharacterController=function(t){t._pxManager=null},s.update=function(t){this._simulate(t),this._fetchResults(),this._fireEvent()},s.raycast=function(t,e,i,r){var a=this,l=a._pxRaycastHit;e=Math.min(e,34e37);var _={preFilter:function(M,f,d){return i(f)?2:0},postFilter:function(M,f){}},c=this._pxScene.raycastSingle(t.origin,t.direction,e,l,this._pxFilterData,this._physXPhysics._physX.PxQueryFilterCallback.implement(_));if(c&&r!=null){var u=o._tempPosition,g=o._tempNormal,S=l.position,C=l.normal;u.set(S.x,S.y,S.z),g.set(C.x,C.y,C.z),r(l.getShape().getUUID(),l.distance,u,g)}return c},s._getControllerManager=function(){var t=this._pxControllerManager;return t===null&&(this._pxControllerManager=t=this._pxScene.createControllerManager()),t},s._simulate=function(t){this._pxScene.simulate(t,!0)},s._fetchResults=function(t){t===void 0&&(t=!0),this._pxScene.fetchResults(t)},s._getTrigger=function(t,e){var i;return this._eventPool.length?(i=this._eventPool.pop(),i.index1=t,i.index2=e):i=new it(t,e),this._physXManager._eventMap[t][e]=i,i},s._fireEvent=function(){for(var t=this,e=t._eventPool,i=t._currentEvents,r=i.length-1;r>=0;r--){var a=i.get(r);a.state==0?(this._onTriggerEnter(a.index1,a.index2),a.state=1):a.state==1?this._onTriggerStay(a.index1,a.index2):a.state==2&&(this._onTriggerExit(a.index1,a.index2),i.deleteByIndex(r),e.push(a))}},o}();(function(){R._tempPosition=new h})();(function(){R._tempNormal=new h})();var B;(function(o){o[o.STATIC=1]="STATIC",o[o.DYNAMIC=2]="DYNAMIC",o[o.PRE_FILTER=4]="PRE_FILTER",o[o.POST_FILTER=8]="POST_FILTER",o[o.ANY_HIT=16]="ANY_HIT",o[o.NO_BLOCK=32]="NO_BLOCK"})(B||(B={}));var H;(function(o){o[o.Enter=0]="Enter",o[o.Stay=1]="Stay",o[o.Exit=2]="Exit"})(H||(H={}));var it=function(s,n){this.index1=s,this.index2=n},nt=function(o){m(s,o);function s(n,t,e){var i;return i=o.call(this,n)||this,i._pxActor=n._pxPhysics.createRigidStatic(i._transform(t,e)),i}return s}(F),v;(function(o){o[o.Auto=0]="Auto",o[o.WebAssembly=1]="WebAssembly",o[o.JavaScript=2]="JavaScript"})(v||(v={}));var p=function(){function o(n){this._connectedAnchor=new h,this._breakForce=Number.MAX_VALUE,this._breakTorque=Number.MAX_VALUE,this._physXPhysics=n}var s=o.prototype;return s.setConnectedCollider=function(t){var e,i;this._pxJoint.setActors(((e=t)==null?void 0:e._pxActor)||null,((i=this._collider)==null?void 0:i._pxActor)||null)},s.setConnectedAnchor=function(t){this._connectedAnchor.copyFrom(t),this._setLocalPose(0,t,o._defaultQuat)},s.setConnectedMassScale=function(t){this._pxJoint.setInvMassScale0(1/t)},s.setConnectedInertiaScale=function(t){this._pxJoint.setInvInertiaScale0(1/t)},s.setMassScale=function(t){this._pxJoint.setInvMassScale1(1/t)},s.setInertiaScale=function(t){this._pxJoint.setInvInertiaScale1(1/t)},s.setBreakForce=function(t){this._breakForce=t,this._pxJoint.setBreakForce(this._breakForce,this._breakTorque)},s.setBreakTorque=function(t){this._breakTorque=t,this._pxJoint.setBreakForce(this._breakForce,this._breakTorque)},s._setLocalPose=function(t,e,i){this._pxJoint.setLocalPose(t,e,i)},o}();(function(){p._xAxis=new h(1,0,0)})();(function(){p._defaultVec=new h})();(function(){p._defaultQuat=new y})();var st=function(o){m(s,o);function s(n,t){var e;return e=o.call(this,n)||this,e._collider=t,e._pxJoint=n._pxPhysics.createFixedJoint(null,p._defaultVec,p._defaultQuat,t._pxActor,p._defaultVec,p._defaultQuat),e}return s}(p),ot=function(o){m(s,o);function s(t,e){var i;return i=o.call(this,t)||this,i._axisRotationQuaternion=new y,i._swingOffset=new h,i._collider=e,i._pxJoint=t._pxPhysics.createRevoluteJoint(null,p._defaultVec,p._defaultQuat,e._pxActor,p._defaultVec,p._defaultQuat),i}var n=s.prototype;return n.setAxis=function(e){var i=p._xAxis,r=this._axisRotationQuaternion;i.set(1,0,0),e.normalize();var a=Math.acos(h.dot(i,e));h.cross(i,e,i),y.rotationAxisAngle(i,a,r),this._setLocalPose(0,this._swingOffset,r)},n.setSwingOffset=function(e){this._swingOffset.copyFrom(e),this._setLocalPose(1,this._swingOffset,this._axisRotationQuaternion)},n.getAngle=function(){return this._pxJoint.getAngle()},n.getVelocity=function(){return this._pxJoint.getVelocity()},n.setHardLimit=function(e,i,r){this._pxJoint.setHardLimit(e,i,r)},n.setSoftLimit=function(e,i,r,a){this._pxJoint.setSoftLimit(e,i,r,a)},n.setDriveVelocity=function(e,i){i===void 0&&(i=!0),this._pxJoint.setDriveVelocity(e,i)},n.setDriveForceLimit=function(e){this._pxJoint.setDriveForceLimit(e)},n.setDriveGearRatio=function(e){this._pxJoint.setDriveGearRatio(e)},n.setHingeJointFlag=function(e,i){this._pxJoint.setRevoluteJointFlag(e,i)},s}(p),rt=function(o){m(s,o);function s(t,e){var i;return i=o.call(this,t)||this,i._swingOffset=new h,i._collider=e,i._pxJoint=t._pxPhysics.createDistanceJoint(null,p._defaultVec,p._defaultQuat,e._pxActor,p._defaultVec,p._defaultQuat),i._pxJoint.setDistanceJointFlag(2,!0),i._pxJoint.setDistanceJointFlag(4,!0),i._pxJoint.setDistanceJointFlag(8,!0),i}var n=s.prototype;return n.setSwingOffset=function(e){this._swingOffset.copyFrom(e),this._setLocalPose(1,e,p._defaultQuat)},n.setMinDistance=function(e){this._pxJoint.setMinDistance(e)},n.setMaxDistance=function(e){this._pxJoint.setMaxDistance(e)},n.setTolerance=function(e){this._pxJoint.setTolerance(e)},n.setStiffness=function(e){this._pxJoint.setStiffness(e)},n.setDamping=function(e){this._pxJoint.setDamping(e)},s}(p),at=function(o){m(s,o);function s(n,t,e){var i;return i=o.call(this,n)||this,i._axis=new y(0,0,x.halfSqrt,x.halfSqrt),i._physXRotation.copyFrom(i._axis),i._pxGeometry=new n._physX.PxPlaneGeometry,i._initialize(e,t),i._setLocalPose(),i}return s}(x),lt=function(o){m(s,o);function s(t,e,i,r){var a;return a=o.call(this,t)||this,a._maxScale=1,a._radius=i,a._pxGeometry=new t._physX.PxSphereGeometry(a._radius*a._maxScale),a._initialize(r,e),a._setLocalPose(),a}var n=s.prototype;return n.setRadius=function(e){this._radius=e,this._pxGeometry.radius=e*this._maxScale,this._pxShape.setGeometry(this._pxGeometry)},n.setWorldScale=function(e){o.prototype.setWorldScale.call(this,e),this._maxScale=Math.max(Math.abs(e.x),Math.abs(e.y),Math.abs(e.z)),this._pxGeometry.radius=this._radius*this._maxScale,this._pxShape.setGeometry(this._pxGeometry)},s}(x),ht=function(){function o(n){n===void 0&&(n=v.Auto),this._initializeState=0,this._runTimeMode=n}var s=o.prototype;return s.initialize=function(){var t=this;if(this._initializeState===2)return Promise.resolve();if(this._initializeState===1)return this._initializePromise;var e=this._runTimeMode,i=new Promise(function(a,l){var _=document.createElement("script");if(document.body.appendChild(_),_.async=!0,_.onload=a,_.onerror=l,e==v.Auto){var c=function(){try{if(typeof WebAssembly=="object"&&typeof WebAssembly.instantiate=="function"){var u=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(A(u,WebAssembly.Module))return A(new WebAssembly.Instance(u),WebAssembly.Instance)}}catch{}return!1}();c?e=v.WebAssembly:e=v.JavaScript}e==v.JavaScript?_.src="https://mdn.alipayobjects.com/rms/afts/file/A*rnDeR58NNGoAAAAAAAAAAAAAARQnAQ/physx.release.js.js":e==v.WebAssembly&&(_.src="https://mdn.alipayobjects.com/rms/afts/file/A*nA97QLQehRMAAAAAAAAAAAAAARQnAQ/physx.release.js")}),r=new Promise(function(a,l){i.then(function(){return window.PHYSX().then(function(_){t._init(_),t._initializeState=2,t._initializePromise=null,console.log("PhysX loaded."),a()},l)},l).catch(l)});return this._initializePromise=r,r},s.destroy=function(){this._physX.PxCloseExtensions(),this._pxPhysics.release(),this._pxFoundation.release(),this._physX=null,this._pxFoundation=null,this._pxPhysics=null},s.createPhysicsManager=function(){return new tt},s.createPhysicsScene=function(t,e,i,r,a,l,_){var c=new R(this,t,e,i,r,a,l,_);return c},s.createStaticCollider=function(t,e){return new nt(this,t,e)},s.createDynamicCollider=function(t,e){return new E(this,t,e)},s.createCharacterController=function(){return new O(this)},s.createPhysicsMaterial=function(t,e,i,r,a){return new et(this,t,e,i,r,a)},s.createBoxColliderShape=function(t,e,i){return new b(this,t,e,i)},s.createSphereColliderShape=function(t,e,i){return new lt(this,t,e,i)},s.createPlaneColliderShape=function(t,e){return new at(this,t,e)},s.createCapsuleColliderShape=function(t,e,i,r){return new N(this,t,e,i,r)},s.createFixedJoint=function(t){return new st(this,t)},s.createHingeJoint=function(t){return new ot(this,t)},s.createSpringJoint=function(t){return new rt(this,t)},s._init=function(t){var e=t.PX_PHYSICS_VERSION,i=new t.PxDefaultErrorCallback,r=new t.PxDefaultAllocator,a=t.PxCreateFoundation(e,r,i),l=t.PxCreatePhysics(e,a,new t.PxTolerancesScale,!1,null);t.PxInitExtensions(l,null),this._physX=t,this._pxFoundation=a,this._pxPhysics=l},o}(),J;(function(o){o[o.Uninitialized=0]="Uninitialized",o[o.Initializing=1]="Initializing",o[o.Initialized=2]="Initialized"})(J||(J={}));var ct="1.2.0-beta.5";console.log("Galacean PhysX version: "+ct);function _t(o){const s=new y;pt(o,new h(30,0,30),new h(0,-.5,0),new y);var n=0;setInterval(()=>{n>1e3||(ut(o,new h(.075,.075,.075),new h(Math.random()-.5,Math.random()*2+2.5,Math.random()-.5),s),n++)},16)}function pt(o,s,n,t){const e=new G(o.engine);e.baseColor.set(.2179807202597362,.2939682161541871,.31177952549087606,1),e.roughness=0,e.metallic=0;const i=o.createChild(),r=i.addComponent(k);r.mesh=V.createCuboid(o.engine,s.x,s.y,s.z),r.setMaterial(e),i.transform.position=n,i.transform.rotationQuaternion=t,r.receiveShadows=!1;const a=new K;return a.position.set(0,s.y,0),i.addComponent(j).addShape(a),i}function ut(o,s,n,t){const e=new G(o.engine);e.baseColor.set(Math.random(),Math.random(),Math.random(),1),e.metallic=0,e.roughness=0;const i=o.createChild(),r=i.addComponent(k);r.mesh=V.createCuboid(o.engine,s.x,s.y,s.z),r.setMaterial(e),i.transform.position=n,i.transform.rotationQuaternion=t,r.castShadows=!1;const a=new Z;return a.size=s,i.addComponent($).addShape(a),i}U.create({canvas:"canvas",physics:new ht,graphicDeviceOptions:{powerPreference:"high-performance"}}).then(o=>{o.canvas.resizeByClientSize();const n=o.sceneManager.activeScene.createRootEntity(),t=n.createChild("camera");t.addComponent(Q),t.transform.position.set(-1,1.5,2),t.transform.lookAt(new h);const i=n.createChild("light");i.transform.setPosition(-.3,1,.4),i.transform.lookAt(new h(0,0,0));const r=i.addComponent(q);r.intensity=1,r.shadowType=Y.None,_t(n),o.run()}); diff --git a/assets/galacean-particle-benchmark-xLEHfqG5.js b/assets/galacean-particle-benchmark-DAiG37RQ.js similarity index 96% rename from assets/galacean-particle-benchmark-xLEHfqG5.js rename to assets/galacean-particle-benchmark-DAiG37RQ.js index e737382..f1fc57f 100644 --- a/assets/galacean-particle-benchmark-xLEHfqG5.js +++ b/assets/galacean-particle-benchmark-DAiG37RQ.js @@ -1 +1 @@ -import"./modulepreload-polyfill-B5Qt9EMX.js";import{W as y,L as h,f as d,V as u,C as w,A as S,g,h as P,E as v,i as x,j as b,k as E,l}from"./module-BxLNiwNf.js";y.create({canvas:"canvas",graphicDeviceOptions:{powerPreference:"high-performance"}}).then(e=>{h.enable(),e.canvas.resizeByClientSize();const r=e.sceneManager.activeScene,a=r.createRootEntity();r.background.solidColor=new d(0,0,0,1);const n=a.createChild("camera_entity");n.transform.position=new u(0,0,180);const s=n.addComponent(w);s.farClipPlane=200,s.fieldOfView=60;const t=25,o=30,i=3,f=5;e.resourceManager.load({url:"https://mdn.alipayobjects.com/huamei_b4l2if/afts/img/A*JPsCSK5LtYkAAAAAAAAAAAAADil6AQ/original",type:S.Texture2D}).then(M=>{const c=new g(e);c.baseColor=new d(1,1,1,1),c.blendMode=P.Normal,c.baseTexture=M;const A=T(e,c);for(let m=0;m{h.enable(),e.canvas.resizeByClientSize();const r=e.sceneManager.activeScene,a=r.createRootEntity();r.background.solidColor=new d(0,0,0,1);const n=a.createChild("camera_entity");n.transform.position=new u(0,0,180);const s=n.addComponent(w);s.farClipPlane=200,s.fieldOfView=60;const t=25,o=30,i=3,f=5;e.resourceManager.load({url:"https://mdn.alipayobjects.com/huamei_b4l2if/afts/img/A*JPsCSK5LtYkAAAAAAAAAAAAADil6AQ/original",type:S.Texture2D}).then(M=>{const c=new g(e);c.baseColor=new d(1,1,1,1),c.blendMode=P.Normal,c.baseTexture=M;const A=T(e,c);for(let m=0;m #include diff --git a/assets/main-DN4-Fq5i.js b/assets/main-DN4-Fq5i.js index 551a657..b7f7259 100644 --- a/assets/main-DN4-Fq5i.js +++ b/assets/main-DN4-Fq5i.js @@ -1 +1 @@ -import"./modulepreload-polyfill-B5Qt9EMX.js";const L="modulepreload",y=function(l){return"/benchmark/"+l},v={},w=function(m,c,s){let i=Promise.resolve();if(c&&c.length>0){document.getElementsByTagName("link");const e=document.querySelector("meta[property=csp-nonce]"),o=e?.nonce||e?.getAttribute("nonce");i=Promise.all(c.map(n=>{if(n=y(n),n in v)return;v[n]=!0;const t=n.endsWith(".css"),f=t?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${n}"]${f}`))return;const r=document.createElement("link");if(r.rel=t?"stylesheet":L,t||(r.as="script",r.crossOrigin=""),r.href=n,o&&r.setAttribute("nonce",o),document.head.appendChild(r),t)return new Promise((E,a)=>{r.addEventListener("load",E),r.addEventListener("error",()=>a(new Error(`Unable to preload CSS for ${n}`)))})}))}return i.then(()=>m()).catch(e=>{const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=e,window.dispatchEvent(o),!o.defaultPrevented)throw e})},_=(l,m,c)=>{const s=l[m];return s?typeof s=="function"?s():Promise.resolve(s):new Promise((i,e)=>{(typeof queueMicrotask=="function"?queueMicrotask:setTimeout)(e.bind(null,new Error("Unknown variable dynamic import: "+m+(m.split("/").length!==c?". Note that variables only represent file names one level deep.":""))))})},k=document.getElementById("itemList"),P=document.getElementById("searchBar"),O=document.getElementById("iframe"),u=[],d=["galacean","three","babylon"],p=new URL(window.location.href),h=p.searchParams.get("platform")??"galacean";d.splice(d.indexOf(h),1);const b=document.getElementById("button1"),g=document.getElementById("button2");b.innerText=d[0];g.innerText=d[1];b.addEventListener("click",()=>{p.searchParams.set("platform",d[0]),window.location.href=p.toString()});g.addEventListener("click",()=>{p.searchParams.set("platform",d[1]),window.location.href=p.toString()});_(Object.assign({"./mpa/babylon/.demoList.json":()=>w(()=>import("./.demoList-CUn2bIat.js"),[]),"./mpa/galacean/.demoList.json":()=>w(()=>import("./.demoList-BctHAkSt.js"),[]),"./mpa/three/.demoList.json":()=>w(()=>import("./.demoList-WHPukt8F.js"),[])}),`./mpa/${h}/.demoList.json`,4).then(({default:l})=>{Object.keys(l).forEach(i=>{const e=l[i],o=document.createElement("div"),n=document.createElement("div"),t=document.createElement("ul");n.innerHTML=i,n.classList.add("title"),k.appendChild(o),o.appendChild(n),o.appendChild(t),e.forEach(f=>{const{label:r,src:E}=f,a=document.createElement("a");a.innerHTML=r,a.title=`${E}`,a.onclick=function(){c(a)},t.appendChild(a),u.push({itemDOM:a,label:r,src:E})})}),P.oninput=()=>{m(searchBar.value)};function m(i){const e=new RegExp(i,"i");u.forEach(({itemDOM:o,label:n,src:t})=>{e.lastIndex=0,e.test(n)||e.test(t)?o.classList.remove("hide"):o.classList.add("hide")})}function c(i){window.location.hash=`#mpa/${i.title}`}function s(){const i=window.location.hash.split("#")[1],e=window.location.hash.split("#mpa/")[1];if(!i||!u.find(t=>t.src===e)){c(u[0].itemDOM);return}const o=window.location.href.indexOf("/benchmark/")>-1?"/benchmark":"";O.src=o+"/mpa/"+h+"/"+e+".html",u.forEach(({itemDOM:t})=>{`mpa/${h}/${t.title}`===i?t.classList.add("active"):t.classList.remove("active")});function n(){const t=window.location.href.indexOf("/benchmark/")>-1?"/benchmark":"";window.open(t+"/mpa/"+h+"/"+e+".html")}document.getElementById("open").addEventListener("click",n)}window.onhashchange=s,s()}); +import"./modulepreload-polyfill-B5Qt9EMX.js";const L="modulepreload",y=function(l){return"/benchmark/"+l},v={},w=function(m,c,s){let i=Promise.resolve();if(c&&c.length>0){document.getElementsByTagName("link");const e=document.querySelector("meta[property=csp-nonce]"),o=e?.nonce||e?.getAttribute("nonce");i=Promise.all(c.map(n=>{if(n=y(n),n in v)return;v[n]=!0;const t=n.endsWith(".css"),f=t?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${n}"]${f}`))return;const r=document.createElement("link");if(r.rel=t?"stylesheet":L,t||(r.as="script",r.crossOrigin=""),r.href=n,o&&r.setAttribute("nonce",o),document.head.appendChild(r),t)return new Promise((E,a)=>{r.addEventListener("load",E),r.addEventListener("error",()=>a(new Error(`Unable to preload CSS for ${n}`)))})}))}return i.then(()=>m()).catch(e=>{const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=e,window.dispatchEvent(o),!o.defaultPrevented)throw e})},_=(l,m,c)=>{const s=l[m];return s?typeof s=="function"?s():Promise.resolve(s):new Promise((i,e)=>{(typeof queueMicrotask=="function"?queueMicrotask:setTimeout)(e.bind(null,new Error("Unknown variable dynamic import: "+m+(m.split("/").length!==c?". Note that variables only represent file names one level deep.":""))))})},k=document.getElementById("itemList"),P=document.getElementById("searchBar"),O=document.getElementById("iframe"),u=[],d=["galacean","three","babylon"],p=new URL(window.location.href),h=p.searchParams.get("platform")??"galacean";d.splice(d.indexOf(h),1);const b=document.getElementById("button1"),g=document.getElementById("button2");b.innerText=d[0];g.innerText=d[1];b.addEventListener("click",()=>{p.searchParams.set("platform",d[0]),window.location.href=p.toString()});g.addEventListener("click",()=>{p.searchParams.set("platform",d[1]),window.location.href=p.toString()});_(Object.assign({"./mpa/babylon/.demoList.json":()=>w(()=>import("./.demoList-BctHAkSt.js"),[]),"./mpa/galacean/.demoList.json":()=>w(()=>import("./.demoList-WHPukt8F.js"),[]),"./mpa/three/.demoList.json":()=>w(()=>import("./.demoList-CUn2bIat.js"),[])}),`./mpa/${h}/.demoList.json`,4).then(({default:l})=>{Object.keys(l).forEach(i=>{const e=l[i],o=document.createElement("div"),n=document.createElement("div"),t=document.createElement("ul");n.innerHTML=i,n.classList.add("title"),k.appendChild(o),o.appendChild(n),o.appendChild(t),e.forEach(f=>{const{label:r,src:E}=f,a=document.createElement("a");a.innerHTML=r,a.title=`${E}`,a.onclick=function(){c(a)},t.appendChild(a),u.push({itemDOM:a,label:r,src:E})})}),P.oninput=()=>{m(searchBar.value)};function m(i){const e=new RegExp(i,"i");u.forEach(({itemDOM:o,label:n,src:t})=>{e.lastIndex=0,e.test(n)||e.test(t)?o.classList.remove("hide"):o.classList.add("hide")})}function c(i){window.location.hash=`#mpa/${i.title}`}function s(){const i=window.location.hash.split("#")[1],e=window.location.hash.split("#mpa/")[1];if(!i||!u.find(t=>t.src===e)){c(u[0].itemDOM);return}const o=window.location.href.indexOf("/benchmark/")>-1?"/benchmark":"";O.src=o+"/mpa/"+h+"/"+e+".html",u.forEach(({itemDOM:t})=>{`mpa/${h}/${t.title}`===i?t.classList.add("active"):t.classList.remove("active")});function n(){const t=window.location.href.indexOf("/benchmark/")>-1?"/benchmark":"";window.open(t+"/mpa/"+h+"/"+e+".html")}document.getElementById("open").addEventListener("click",n)}window.onhashchange=s,s()}); diff --git a/assets/module-BxLNiwNf.js b/assets/module-BIoDltUI.js similarity index 60% rename from assets/module-BxLNiwNf.js rename to assets/module-BIoDltUI.js index 0c7f8a8..11f25b6 100644 --- a/assets/module-BxLNiwNf.js +++ b/assets/module-BIoDltUI.js @@ -1,5 +1,5 @@ -var et;(function(n){n[n.Disjoint=0]="Disjoint",n[n.Contains=1]="Contains",n[n.Intersects=2]="Intersects"})(et||(et={}));var Lt;(function(n){n[n.Back=0]="Back",n[n.Front=1]="Front",n[n.Intersecting=2]="Intersecting"})(Lt||(Lt={}));var me;(function(n){n[n.Near=0]="Near",n[n.Far=1]="Far",n[n.Left=2]="Left",n[n.Right=3]="Right",n[n.Bottom=4]="Bottom",n[n.Top=5]="Top"})(me||(me={}));function nl(n,s){for(var i=0;ik.zeroTolerance&&(c=1/c,e.set(r*c,a*c,o*c))},n.scale=function(t,e,r){r._x=t._x*e,r._y=t._y*e,r._z=t._z*e,r._onValueChanged&&r._onValueChanged()},n.transformNormal=function(t,e,r){var a=t._x,o=t._y,c=t._z,l=e.elements;r._x=a*l[0]+o*l[4]+c*l[8],r._y=a*l[1]+o*l[5]+c*l[9],r._z=a*l[2]+o*l[6]+c*l[10],r._onValueChanged&&r._onValueChanged()},n.transformToVec3=function(t,e,r){var a=t._x,o=t._y,c=t._z,l=e.elements;r._x=a*l[0]+o*l[4]+c*l[8]+l[12],r._y=a*l[1]+o*l[5]+c*l[9]+l[13],r._z=a*l[2]+o*l[6]+c*l[10]+l[14],r._onValueChanged&&r._onValueChanged()},n.transformToVec4=function(t,e,r){var a=t._x,o=t._y,c=t._z,l=e.elements;r._x=a*l[0]+o*l[4]+c*l[8]+l[12],r._y=a*l[1]+o*l[5]+c*l[9]+l[13],r._z=a*l[2]+o*l[6]+c*l[10]+l[14],r._w=a*l[3]+o*l[7]+c*l[11]+l[15],r._onValueChanged&&r._onValueChanged()},n.transformCoordinate=function(t,e,r){var a=t._x,o=t._y,c=t._z,l=e.elements,_=a*l[3]+o*l[7]+c*l[11]+l[15];_=1/_,r._x=(a*l[0]+o*l[4]+c*l[8]+l[12])*_,r._y=(a*l[1]+o*l[5]+c*l[9]+l[13])*_,r._z=(a*l[2]+o*l[6]+c*l[10]+l[14])*_,r._onValueChanged&&r._onValueChanged()},n.transformByQuat=function(t,e,r){var a=t._x,o=t._y,c=t._z,l=e._x,_=e._y,u=e._z,h=e._w,d=h*a+_*c-u*o,f=h*o+u*a-l*c,v=h*c+l*o-_*a,p=-l*a-_*o-u*c;r._x=d*h-p*l-f*u+v*_,r._y=f*h-p*_-v*l+d*u,r._z=v*h-p*u-d*_+f*l,r._onValueChanged&&r._onValueChanged()},fa(n,[{key:"x",get:function(){return this._x},set:function(t){this._x=t,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(t){this._y=t,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(t){this._z=t,this._onValueChanged&&this._onValueChanged()}}]),n}();(function(){R._zero=new R(0,0,0)})();(function(){R._one=new R(1,1,1)})();var mc=function(){function n(i,t){i===void 0&&(i=null),t===void 0&&(t=0),this.center=new R,this.radius=0,i&&this.center.copyFrom(i),this.radius=t}var s=n.prototype;return s.clone=function(){return new n(this.center,this.radius)},s.copyFrom=function(t){return this.center.copyFrom(t.center),this.radius=t.radius,this},n.fromPoints=function(t,e){if(!t||t.length===0)throw new Error("points must be array and length must > 0");var r=t.length,a=n._tempVec30;a.x=a.y=a.z=0;for(var o=0;oc&&(c=_)}e.radius=Math.sqrt(c)},n.fromBox=function(t,e){var r=e.center,a=t.min,o=t.max;r.x=(a.x+o.x)*.5,r.y=(a.y+o.y)*.5,r.z=(a.z+o.z)*.5,e.radius=R.distance(r,o)},n}();(function(){mc._tempVec30=new R})();var cr=function(){function n(i,t){i===void 0&&(i=null),t===void 0&&(t=null),this.min=new R,this.max=new R,i&&this.min.copyFrom(i),t&&this.max.copyFrom(t)}var s=n.prototype;return s.getCenter=function(t){var e=this,r=e.min,a=e.max,o=a._x+r._x,c=a._y+r._y,l=a._z+r._z;return t.set(isNaN(o)?0:o*.5,isNaN(c)?0:c*.5,isNaN(l)?0:l*.5),t},s.getExtent=function(t){var e=this,r=e.min,a=e.max,o=a._x-r._x,c=a._y-r._y,l=a._z-r._z;return t.set(isNaN(o)?0:o*.5,isNaN(c)?0:c*.5,isNaN(l)?0:l*.5),t},s.getCorners=function(t){t===void 0&&(t=[]);var e=this,r=e.min,a=e.max,o=r.x,c=r.y,l=r.z,_=a.x,u=a.y,h=a.z,d=t.length;if(d<8)for(var f=0,v=8-d;f 0");var r=e.min,a=e.max;r.x=r.y=r.z=Number.MAX_VALUE,a.x=a.y=a.z=-Number.MAX_VALUE;for(var o=0,c=t.length;o0?Lt.Front:e<0?Lt.Back:Lt.Intersecting},n.intersectsPlaneAndBox=function(i,t){var e=t.min,r=t.max,a=i.normal,o=n._tempVec30,c=n._tempVec31;return a.x>=0?(o.x=r.x,c.x=e.x):(o.x=e.x,c.x=r.x),a.y>=0?(o.y=r.y,c.y=e.y):(o.y=e.y,c.y=r.y),a.z>=0?(o.z=r.z,c.z=e.z):(o.z=e.z,c.z=r.z),n.distancePlaneAndPoint(i,o)<0?Lt.Back:n.distancePlaneAndPoint(i,c)>0?Lt.Front:Lt.Intersecting},n.intersectsPlaneAndSphere=function(i,t){var e=t.center,r=t.radius,a=n.distancePlaneAndPoint(i,e);return a>r?Lt.Front:a<-r?Lt.Back:Lt.Intersecting},n.intersectsRayAndPlane=function(i,t){var e=t.normal,r=k.zeroTolerance,a=R.dot(e,i.direction);if(Math.abs(a)c.x)return-1}else{var g=1/l,y=(o.x-h)*g,m=(c.x-h)*g;if(y>m){var x=y;y=m,m=x}if(v=Math.max(y,v),p=Math.min(m,p),v>p)return-1}if(Math.abs(_)c.y)return-1}else{var C=1/_,b=(o.y-d)*C,A=(c.y-d)*C;if(b>A){var S=b;b=A,A=S}if(v=Math.max(b,v),p=Math.min(A,p),v>p)return-1}if(Math.abs(u)c.z)return-1}else{var w=1/u,E=(o.z-f)*w,B=(c.z-f)*w;if(E>B){var M=E;E=B,B=M}if(v=Math.max(E,v),p=Math.min(B,p),v>p)return-1}return v},n.intersectsRayAndSphere=function(i,t){var e=i.origin,r=i.direction,a=t.center,o=t.radius,c=n._tempVec30;R.subtract(e,a,c);var l=R.dot(c,r),_=R.dot(c,c)-o*o;if(l>0&&_>0)return-1;var u=l*l-_;if(u<0)return-1;var h=-l-Math.sqrt(u);return h<0&&(h=0),h},n.intersectsBoxAndBox=function(i,t){return i.min.x>t.max.x||t.min.x>i.max.x||i.min.y>t.max.y||t.min.y>i.max.y?!1:!(i.min.z>t.max.z||t.min.z>i.max.z)},n.intersectsSphereAndSphere=function(i,t){var e=i.radius+t.radius;return R.distanceSquared(i.center,t.center)=0?r.x:e.x,l.y>=0?r.y:e.y,l.z>=0?r.z:e.z),R.dot(l,a)<-c.distance)return!1}return!0},n.frustumContainsPoint=function(i,t){var e=n.distancePlaneAndPoint(i.near,t);return Math.abs(e)=0?(a.x=r.x,o.x=e.x):(a.x=e.x,o.x=r.x),u.y>=0?(a.y=r.y,o.y=e.y):(a.y=e.y,o.y=r.y),u.z>=0?(a.z=r.z,o.z=e.z):(a.z=e.z,o.z=r.z),n.intersectsPlaneAndPoint(_,a)===Lt.Back)return et.Disjoint;n.intersectsPlaneAndPoint(_,o)===Lt.Back&&(c=et.Intersects)}return c},n.frustumContainsSphere=function(i,t){for(var e=et.Contains,r=0;r<6;++r){var a=i.getPlane(r),o=n.intersectsPlaneAndSphere(a,t);if(o===Lt.Back)return et.Disjoint;if(o===Lt.Intersecting){e=et.Intersects;break}}return e},n}();(function(){Tt._tempVec30=new R})();(function(){Tt._tempVec31=new R})();(function(){Tt._tempVec32=new R})();var ht=function(){function n(i,t){i===void 0&&(i=null),t===void 0&&(t=0),this.normal=new R,this.distance=0,i&&this.normal.copyFrom(i),this.distance=t}var s=n.prototype;return s.normalize=function(){return n.normalize(this,this),this},s.clone=function(){var t=new n;return t.copyFrom(this),t},s.copyFrom=function(t){return this.normal.copyFrom(t.normal),this.distance=t.distance,this},n.normalize=function(t,e){var r=t.normal,a=1/r.length();R.scale(r,a,e.normal),e.distance=t.distance*a},n.fromPoints=function(t,e,r,a){var o=t.x,c=t.y,l=t.z,_=e.x-o,u=e.y-c,h=e.z-l,d=r.x-o,f=r.y-c,v=r.z-l,p=u*v-h*f,g=h*d-_*v,y=_*f-u*d,m=1/Math.sqrt(p*p+g*g+y*y),x=p*m,C=g*m,b=y*m,A=a.normal;A.x=x,A.y=C,A.z=b,a.distance=-(x*o+C*c+b*l)},n}(),al=function(){function n(i){i===void 0&&(i=null),this.near=new ht,this.far=new ht,this.left=new ht,this.right=new ht,this.top=new ht,this.bottom=new ht,i&&this.calculateFromMatrix(i)}var s=n.prototype;return s.getPlane=function(t){switch(t){case me.Near:return this.near;case me.Far:return this.far;case me.Left:return this.left;case me.Right:return this.right;case me.Bottom:return this.bottom;case me.Top:return this.top;default:return null}},s.calculateFromMatrix=function(t){var e=t.elements,r=e[0],a=e[1],o=e[2],c=e[3],l=e[4],_=e[5],u=e[6],h=e[7],d=e[8],f=e[9],v=e[10],p=e[11],g=e[12],y=e[13],m=e[14],x=e[15],C=this.near.normal;C.set(c+o,h+u,p+v),this.near.distance=x+m,this.near.normalize();var b=this.far.normal;b.set(c-o,h-u,p-v),this.far.distance=x-m,this.far.normalize();var A=this.left.normal;A.set(c+r,h+l,p+d),this.left.distance=x+g,this.left.normalize();var S=this.right.normal;S.set(c-r,h-l,p-d),this.right.distance=x-g,this.right.normalize();var w=this.bottom.normal;w.set(c+a,h+_,p+f),this.bottom.distance=x+y,this.bottom.normalize();var E=this.top.normal;E.set(c-a,h-_,p-f),this.top.distance=x-y,this.top.normalize()},s.intersectsBox=function(t){return Tt.intersectsFrustumAndBox(this,t)},s.intersectsSphere=function(t){return Tt.frustumContainsSphere(this,t)!==et.Disjoint},s.clone=function(){var t=new n;return t.copyFrom(this),t},s.copyFrom=function(t){return this.near.copyFrom(t.near),this.far.copyFrom(t.far),this.left.copyFrom(t.left),this.right.copyFrom(t.right),this.bottom.copyFrom(t.bottom),this.top.copyFrom(t.top),this},n}(),aa=function(){function n(i,t,e,r,a,o,c,l,_){i===void 0&&(i=1),t===void 0&&(t=0),e===void 0&&(e=0),r===void 0&&(r=0),a===void 0&&(a=1),o===void 0&&(o=0),c===void 0&&(c=0),l===void 0&&(l=0),_===void 0&&(_=1),this.elements=new Float32Array(9);var u=this.elements;u[0]=i,u[1]=t,u[2]=e,u[3]=r,u[4]=a,u[5]=o,u[6]=c,u[7]=l,u[8]=_}var s=n.prototype;return s.set=function(t,e,r,a,o,c,l,_,u){var h=this.elements;return h[0]=t,h[1]=e,h[2]=r,h[3]=a,h[4]=o,h[5]=c,h[6]=l,h[7]=_,h[8]=u,this},s.add=function(t){return n.add(this,t,this),this},s.subtract=function(t){return n.subtract(this,t,this),this},s.multiply=function(t){return n.multiply(this,t,this),this},s.determinant=function(){var t=this.elements,e=t[0],r=t[1],a=t[2],o=t[3],c=t[4],l=t[5],_=t[6],u=t[7],h=t[8],d=h*c-l*u,f=-h*o+l*_,v=u*o-c*_;return e*d+r*f+a*v},s.identity=function(){var t=this.elements;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,this},s.invert=function(){return n.invert(this,this),this},s.rotate=function(t){return n.rotate(this,t,this),this},s.scale=function(t){return n.scale(this,t,this),this},s.translate=function(t){return n.translate(this,t,this),this},s.transpose=function(){return n.transpose(this,this),this},s.clone=function(){var t=this.elements,e=new n(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8]);return e},s.copyFrom=function(t){var e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],this},s.copyFromArray=function(t,e){e===void 0&&(e=0);for(var r=this.elements,a=0;a<12;a++)r[a]=t[a+e];return this},s.copyToArray=function(t,e){e===void 0&&(e=0);var r=this.elements;t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8]},s.copyFromMatrix=function(t){var e=t.elements,r=this.elements;return r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[4],r[4]=e[5],r[5]=e[6],r[6]=e[8],r[7]=e[9],r[8]=e[10],this},n.add=function(t,e,r){var a=t.elements,o=e.elements,c=r.elements;c[0]=a[0]+o[0],c[1]=a[1]+o[1],c[2]=a[2]+o[2],c[3]=a[3]+o[3],c[4]=a[4]+o[4],c[5]=a[5]+o[5],c[6]=a[6]+o[6],c[7]=a[7]+o[7],c[8]=a[8]+o[8]},n.subtract=function(t,e,r){var a=t.elements,o=e.elements,c=r.elements;c[0]=a[0]-o[0],c[1]=a[1]-o[1],c[2]=a[2]-o[2],c[3]=a[3]-o[3],c[4]=a[4]-o[4],c[5]=a[5]-o[5],c[6]=a[6]-o[6],c[7]=a[7]-o[7],c[8]=a[8]-o[8]},n.multiply=function(t,e,r){var a=t.elements,o=e.elements,c=r.elements,l=a[0],_=a[1],u=a[2],h=a[3],d=a[4],f=a[5],v=a[6],p=a[7],g=a[8],y=o[0],m=o[1],x=o[2],C=o[3],b=o[4],A=o[5],S=o[6],w=o[7],E=o[8];c[0]=l*y+h*m+v*x,c[1]=_*y+d*m+p*x,c[2]=u*y+f*m+g*x,c[3]=l*C+h*b+v*A,c[4]=_*C+d*b+p*A,c[5]=u*C+f*b+g*A,c[6]=l*S+h*w+v*E,c[7]=_*S+d*w+p*E,c[8]=u*S+f*w+g*E},n.equals=function(t,e){var r=t.elements,a=e.elements;return k.equals(r[0],a[0])&&k.equals(r[1],a[1])&&k.equals(r[2],a[2])&&k.equals(r[3],a[3])&&k.equals(r[4],a[4])&&k.equals(r[5],a[5])&&k.equals(r[6],a[6])&&k.equals(r[7],a[7])&&k.equals(r[8],a[8])},n.lerp=function(t,e,r,a){var o=t.elements,c=e.elements,l=a.elements,_=1-r;l[0]=o[0]*_+c[0]*r,l[1]=o[1]*_+c[1]*r,l[2]=o[2]*_+c[2]*r,l[3]=o[3]*_+c[3]*r,l[4]=o[4]*_+c[4]*r,l[5]=o[5]*_+c[5]*r,l[6]=o[6]*_+c[6]*r,l[7]=o[7]*_+c[7]*r,l[8]=o[8]*_+c[8]*r},n.rotationQuaternion=function(t,e){var r=e.elements,a=t._x,o=t._y,c=t._z,l=t._w,_=a+a,u=o+o,h=c+c,d=a*_,f=o*_,v=o*u,p=c*_,g=c*u,y=c*h,m=l*_,x=l*u,C=l*h;r[0]=1-v-y,r[3]=f-C,r[6]=p+x,r[1]=f+C,r[4]=1-d-y,r[7]=g-m,r[2]=p-x,r[5]=g+m,r[8]=1-d-v},n.scaling=function(t,e){var r=e.elements;r[0]=t._x,r[1]=0,r[2]=0,r[3]=0,r[4]=t._y,r[5]=0,r[6]=0,r[7]=0,r[8]=1},n.translation=function(i,t){var e=t.elements;e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=i._x,e[7]=i._y,e[8]=1},n.invert=function(t,e){var r=t.elements,a=e.elements,o=r[0],c=r[1],l=r[2],_=r[3],u=r[4],h=r[5],d=r[6],f=r[7],v=r[8],p=v*u-h*f,g=-v*_+h*d,y=f*_-u*d,m=o*p+c*g+l*y;m&&(m=1/m,a[0]=p*m,a[1]=(-v*c+l*f)*m,a[2]=(h*c-l*u)*m,a[3]=g*m,a[4]=(v*o-l*d)*m,a[5]=(-h*o+l*_)*m,a[6]=y*m,a[7]=(-f*o+c*d)*m,a[8]=(u*o-c*_)*m)},n.normalMatrix=function(t,e){var r=t.elements,a=e.elements,o=r[0],c=r[1],l=r[2],_=r[3],u=r[4],h=r[5],d=r[6],f=r[7],v=r[8],p=r[9],g=r[10],y=r[11],m=r[12],x=r[13],C=r[14],b=r[15],A=o*h-c*u,S=o*d-l*u,w=o*f-_*u,E=c*d-l*h,B=c*f-_*h,M=l*f-_*d,D=v*x-p*m,L=v*C-g*m,V=v*b-y*m,N=p*C-g*x,I=p*b-y*x,P=g*b-y*C,z=A*P-S*I+w*N+E*V-B*L+M*D;if(!z)return null;z=1/z,a[0]=(h*P-d*I+f*N)*z,a[1]=(d*V-u*P-f*L)*z,a[2]=(u*I-h*V+f*D)*z,a[3]=(l*I-c*P-_*N)*z,a[4]=(o*P-l*V+_*L)*z,a[5]=(c*V-o*I-_*D)*z,a[6]=(x*M-C*B+b*E)*z,a[7]=(C*w-m*M-b*S)*z,a[8]=(m*B-x*w+b*A)*z},n.rotate=function(t,e,r){var a=t.elements,o=r.elements,c=Math.sin(e),l=Math.cos(e),_=a[0],u=a[1],h=a[2],d=a[3],f=a[4],v=a[5],p=a[6],g=a[7],y=a[8];o[0]=l*_+c*d,o[1]=l*u+c*f,o[2]=l*h+c*v,o[3]=l*d-c*_,o[4]=l*f-c*u,o[5]=l*v-c*h,o[6]=p,o[7]=g,o[8]=y},n.scale=function(t,e,r){var a=e._x,o=e._y,c=t.elements,l=r.elements;l[0]=a*c[0],l[1]=a*c[1],l[2]=a*c[2],l[3]=o*c[3],l[4]=o*c[4],l[5]=o*c[5],l[6]=c[6],l[7]=c[7],l[8]=c[8]},n.translate=function(t,e,r){var a=e._x,o=e._y,c=t.elements,l=r.elements,_=c[0],u=c[1],h=c[2],d=c[3],f=c[4],v=c[5],p=c[6],g=c[7],y=c[8];l[0]=_,l[1]=u,l[2]=h,l[3]=d,l[4]=f,l[5]=v,l[6]=a*_+o*d+p,l[7]=a*u+o*f+g,l[8]=a*h+o*v+y},n.transpose=function(t,e){var r=t.elements,a=e.elements;if(e===t){var o=r[1],c=r[2],l=r[5];a[1]=r[3],a[2]=r[6],a[3]=o,a[5]=r[7],a[6]=c,a[7]=l}else a[0]=r[0],a[1]=r[3],a[2]=r[6],a[3]=r[1],a[4]=r[4],a[5]=r[7],a[6]=r[2],a[7]=r[5],a[8]=r[8]},n}(),Re=function(){function n(i,t,e,r){i===void 0&&(i=0),t===void 0&&(t=0),e===void 0&&(e=0),r===void 0&&(r=1),this._onValueChanged=null,this._x=i,this._y=t,this._z=e,this._w=r}var s=n.prototype;return s.set=function(t,e,r,a){return this._x=t,this._y=e,this._z=r,this._w=a,this._onValueChanged&&this._onValueChanged(),this},s.conjugate=function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onValueChanged&&this._onValueChanged(),this},s.getAxisAngle=function(t){var e=this,r=e._x,a=e._y,o=e._z,c=r*r+a*a+o*o;if(c(1-k.zeroTolerance)*d?(t._x=Math.atan2(2*(c*a-r*o),l+h-_-u),t._y=Math.PI/2,t._z=0):f<-(1-k.zeroTolerance)*d?(t._x=Math.atan2(2*(c*a-r*o),l+h-_-u),t._y=-Math.PI/2,t._z=0):(t._x=Math.atan2(2*(o*r+a*c),u+h-_-l),t._y=Math.asin(f/d),t._z=Math.atan2(2*(r*a+o*c),_+h-u-l))},n.add=function(t,e,r){r._x=t._x+e._x,r._y=t._y+e._y,r._z=t._z+e._z,r._w=t._w+e._w,r._onValueChanged&&r._onValueChanged()},n.multiply=function(t,e,r){var a=t._x,o=t._y,c=t._z,l=t._w,_=e._x,u=e._y,h=e._z,d=e._w;r._x=a*d+l*_+o*h-c*u,r._y=o*d+l*u+c*_-a*h,r._z=c*d+l*h+a*u-o*_,r._w=l*d-a*_-o*u-c*h,r._onValueChanged&&r._onValueChanged()},n.conjugate=function(t,e){e._x=-t._x,e._y=-t._y,e._z=-t._z,e._w=t._w,e._onValueChanged&&e._onValueChanged()},n.dot=function(t,e){return t._x*e._x+t._y*e._y+t._z*e._z+t._w*e._w},n.equals=function(t,e){return k.equals(t._x,e._x)&&k.equals(t._y,e._y)&&k.equals(t._z,e._z)&&k.equals(t._w,e._w)},n.rotationAxisAngle=function(t,e,r){var a=n._tempVector3;R.normalize(t,a),e*=.5;var o=Math.sin(e);r._x=a._x*o,r._y=a._y*o,r._z=a._z*o,r._w=Math.cos(e),r._onValueChanged&&r._onValueChanged()},n.rotationEuler=function(t,e,r,a){n.rotationYawPitchRoll(e,t,r,a)},n.rotationYawPitchRoll=function(t,e,r,a){var o=r*.5,c=e*.5,l=t*.5,_=Math.sin(o),u=Math.cos(o),h=Math.sin(c),d=Math.cos(c),f=Math.sin(l),v=Math.cos(l),p=v*d,g=f*h;a._x=v*h*u+f*d*_,a._y=f*d*u-v*h*_,a._z=p*_-g*u,a._w=p*u+g*_,a._onValueChanged&&a._onValueChanged()},n.rotationMatrix3x3=function(t,e){var r=t.elements,a=r[0],o=r[1],c=r[2],l=r[3],_=r[4],u=r[5],h=r[6],d=r[7],f=r[8],v=a+_+f,p,g;v>0?(p=Math.sqrt(v+1),e._w=p*.5,p=.5/p,e._x=(u-d)*p,e._y=(h-c)*p,e._z=(o-l)*p):a>=_&&a>=f?(p=Math.sqrt(1+a-_-f),g=.5/p,e._x=.5*p,e._y=(o+l)*g,e._z=(c+h)*g,e._w=(u-d)*g):_>f?(p=Math.sqrt(1+_-a-f),g=.5/p,e._x=(l+o)*g,e._y=.5*p,e._z=(d+u)*g,e._w=(h-c)*g):(p=Math.sqrt(1+f-a-_),g=.5/p,e._x=(c+h)*g,e._y=(u+d)*g,e._z=.5*p,e._w=(o-l)*g),e._onValueChanged&&e._onValueChanged()},n.invert=function(t,e){var r=t._x,a=t._y,o=t._z,c=t._w,l=r*r+a*a+o*o+c*c;if(l>k.zeroTolerance){var _=1/l;e._x=-r*_,e._y=-a*_,e._z=-o*_,e._w=c*_,e._onValueChanged&&e._onValueChanged()}},n.lerp=function(t,e,r,a){var o=1-r;n.dot(t,e)>=0?(a._x=t._x*o+e._x*r,a._y=t._y*o+e._y*r,a._z=t._z*o+e._z*r,a._w=t._w*o+e._w*r):(a._x=t._x*o-e._x*r,a._y=t._y*o-e._y*r,a._z=t._z*o-e._z*r,a._w=t._w*o-e._w*r),a.normalize()},n.slerp=function(t,e,r,a){var o,c,l=n.dot(t,e);if(Math.abs(l)>1-k.zeroTolerance)c=1-r,o=r*Math.sign(l);else{var _=Math.acos(Math.abs(l)),u=1/Math.sin(_);c=Math.sin((1-r)*_)*u,o=Math.sin(r*_)*u*Math.sign(l)}a.x=c*t.x+o*e.x,a.y=c*t.y+o*e.y,a.z=c*t.z+o*e.z,a.w=c*t.w+o*e.w,a._onValueChanged&&a._onValueChanged()},n.normalize=function(t,e){var r=t._x,a=t._y,o=t._z,c=t._w,l=Math.sqrt(r*r+a*a+o*o+c*c);l>k.zeroTolerance&&(l=1/l,e._x=r*l,e._y=a*l,e._z=o*l,e._w=c*l,e._onValueChanged&&e._onValueChanged())},n.rotationX=function(t,e){t*=.5;var r=Math.sin(t),a=Math.cos(t);e._x=r,e._y=0,e._z=0,e._w=a,e._onValueChanged&&e._onValueChanged()},n.rotationY=function(t,e){t*=.5;var r=Math.sin(t),a=Math.cos(t);e._x=0,e._y=r,e._z=0,e._w=a,e._onValueChanged&&e._onValueChanged()},n.rotationZ=function(t,e){t*=.5;var r=Math.sin(t),a=Math.cos(t);e._x=0,e._y=0,e._z=r,e._w=a,e._onValueChanged&&e._onValueChanged()},n.rotateX=function(t,e,r){var a=t._x,o=t._y,c=t._z,l=t._w;e*=.5;var _=Math.sin(e),u=Math.cos(e);r._x=a*u+l*_,r._y=o*u+c*_,r._z=c*u-o*_,r._w=l*u-a*_,r._onValueChanged&&r._onValueChanged()},n.rotateY=function(t,e,r){var a=t._x,o=t._y,c=t._z,l=t._w;e*=.5;var _=Math.sin(e),u=Math.cos(e);r._x=a*u-c*_,r._y=o*u+l*_,r._z=c*u+a*_,r._w=l*u-o*_,r._onValueChanged&&r._onValueChanged()},n.rotateZ=function(t,e,r){var a=t._x,o=t._y,c=t._z,l=t._w;e*=.5;var _=Math.sin(e),u=Math.cos(e);r._x=a*u+o*_,r._y=o*u-a*_,r._z=c*u+l*_,r._w=l*u-c*_,r._onValueChanged&&r._onValueChanged()},n.scale=function(t,e,r){r._x=t._x*e,r._y=t._y*e,r._z=t._z*e,r._w=t._w*e,r._onValueChanged&&r._onValueChanged()},fa(n,[{key:"x",get:function(){return this._x},set:function(t){this._x=t,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(t){this._y=t,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(t){this._z=t,this._onValueChanged&&this._onValueChanged()}},{key:"normalized",get:function(){return Math.abs(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w-1)k.zeroTolerance){var a=Math.sqrt(r+1)*2;t._w=.25*a,t._x=(e[6]-e[9])/a,t._y=(e[8]-e[2])/a,t._z=(e[1]-e[4])/a}else if(e[0]>e[5]&&e[0]>e[10]){var o=Math.sqrt(1+e[0]-e[5]-e[10])*2;t._w=(e[6]-e[9])/o,t._x=.25*o,t._y=(e[1]+e[4])/o,t._z=(e[8]+e[2])/o}else if(e[5]>e[10]){var c=Math.sqrt(1+e[5]-e[0]-e[10])*2;t._w=(e[8]-e[2])/c,t._x=(e[1]+e[4])/c,t._y=.25*c,t._z=(e[6]+e[9])/c}else{var l=Math.sqrt(1+e[10]-e[0]-e[5])*2;t._w=(e[1]-e[4])/l,t._x=(e[8]+e[2])/l,t._y=(e[6]+e[9])/l,t._z=.25*l}return t._onValueChanged&&t._onValueChanged(),t},s.getScaling=function(t){var e=this.elements,r=e[0],a=e[1],o=e[2],c=e[4],l=e[5],_=e[6],u=e[8],h=e[9],d=e[10];return t.set(Math.sqrt(r*r+a*a+o*o),Math.sqrt(c*c+l*l+_*_),Math.sqrt(u*u+h*h+d*d)),t},s.getTranslation=function(t){var e=this.elements;return t.set(e[12],e[13],e[14]),t},s.identity=function(){var t=this.elements;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},s.invert=function(){return n.invert(this,this),this},s.rotateAxisAngle=function(t,e){return n.rotateAxisAngle(this,t,e,this),this},s.scale=function(t){return n.scale(this,t,this),this},s.translate=function(t){return n.translate(this,t,this),this},s.transpose=function(){return n.transpose(this,this),this},s.clone=function(){var t=this.elements,e=new n(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15]);return e},s.copyFrom=function(t){var e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],this},s.copyFromArray=function(t,e){e===void 0&&(e=0);for(var r=this.elements,a=0;a<16;a++)r[a]=t[a+e];return this},s.copyToArray=function(t,e){e===void 0&&(e=0);var r=this.elements;t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t[e+9]=r[9],t[e+10]=r[10],t[e+11]=r[11],t[e+12]=r[12],t[e+13]=r[13],t[e+14]=r[14],t[e+15]=r[15]},n.multiply=function(t,e,r){var a=t.elements,o=e.elements,c=r.elements,l=a[0],_=a[1],u=a[2],h=a[3],d=a[4],f=a[5],v=a[6],p=a[7],g=a[8],y=a[9],m=a[10],x=a[11],C=a[12],b=a[13],A=a[14],S=a[15],w=o[0],E=o[1],B=o[2],M=o[3],D=o[4],L=o[5],V=o[6],N=o[7],I=o[8],P=o[9],z=o[10],U=o[11],Y=o[12],Q=o[13],H=o[14],te=o[15];c[0]=l*w+d*E+g*B+C*M,c[1]=_*w+f*E+y*B+b*M,c[2]=u*w+v*E+m*B+A*M,c[3]=h*w+p*E+x*B+S*M,c[4]=l*D+d*L+g*V+C*N,c[5]=_*D+f*L+y*V+b*N,c[6]=u*D+v*L+m*V+A*N,c[7]=h*D+p*L+x*V+S*N,c[8]=l*I+d*P+g*z+C*U,c[9]=_*I+f*P+y*z+b*U,c[10]=u*I+v*P+m*z+A*U,c[11]=h*I+p*P+x*z+S*U,c[12]=l*Y+d*Q+g*H+C*te,c[13]=_*Y+f*Q+y*H+b*te,c[14]=u*Y+v*Q+m*H+A*te,c[15]=h*Y+p*Q+x*H+S*te},n.equals=function(t,e){var r=t.elements,a=e.elements;return k.equals(r[0],a[0])&&k.equals(r[1],a[1])&&k.equals(r[2],a[2])&&k.equals(r[3],a[3])&&k.equals(r[4],a[4])&&k.equals(r[5],a[5])&&k.equals(r[6],a[6])&&k.equals(r[7],a[7])&&k.equals(r[8],a[8])&&k.equals(r[9],a[9])&&k.equals(r[10],a[10])&&k.equals(r[11],a[11])&&k.equals(r[12],a[12])&&k.equals(r[13],a[13])&&k.equals(r[14],a[14])&&k.equals(r[15],a[15])},n.lerp=function(t,e,r,a){var o=t.elements,c=e.elements,l=a.elements,_=1-r;l[0]=o[0]*_+c[0]*r,l[1]=o[1]*_+c[1]*r,l[2]=o[2]*_+c[2]*r,l[3]=o[3]*_+c[3]*r,l[4]=o[4]*_+c[4]*r,l[5]=o[5]*_+c[5]*r,l[6]=o[6]*_+c[6]*r,l[7]=o[7]*_+c[7]*r,l[8]=o[8]*_+c[8]*r,l[9]=o[9]*_+c[9]*r,l[10]=o[10]*_+c[10]*r,l[11]=o[11]*_+c[11]*r,l[12]=o[12]*_+c[12]*r,l[13]=o[13]*_+c[13]*r,l[14]=o[14]*_+c[14]*r,l[15]=o[15]*_+c[15]*r},n.add=function(t,e,r){var a=t.elements,o=e.elements,c=r.elements;c[0]=a[0]+o[0],c[1]=a[1]+o[1],c[2]=a[2]+o[2],c[3]=a[3]+o[3],c[4]=a[4]+o[4],c[5]=a[5]+o[5],c[6]=a[6]+o[6],c[7]=a[7]+o[7],c[8]=a[8]+o[8],c[9]=a[9]+o[9],c[10]=a[10]+o[10],c[11]=a[11]+o[11],c[12]=a[12]+o[12],c[13]=a[13]+o[13],c[14]=a[14]+o[14],c[15]=a[15]+o[15]},n.multiplyScalar=function(t,e,r){var a=t.elements,o=r.elements;o[0]=a[0]*e,o[1]=a[1]*e,o[2]=a[2]*e,o[3]=a[3]*e,o[4]=a[4]*e,o[5]=a[5]*e,o[6]=a[6]*e,o[7]=a[7]*e,o[8]=a[8]*e,o[9]=a[9]*e,o[10]=a[10]*e,o[11]=a[11]*e,o[12]=a[12]*e,o[13]=a[13]*e,o[14]=a[14]*e,o[15]=a[15]*e},n.rotationQuaternion=function(t,e){var r=e.elements,a=t._x,o=t._y,c=t._z,l=t._w,_=a+a,u=o+o,h=c+c,d=a*_,f=o*_,v=o*u,p=c*_,g=c*u,y=c*h,m=l*_,x=l*u,C=l*h;r[0]=1-v-y,r[1]=f+C,r[2]=p-x,r[3]=0,r[4]=f-C,r[5]=1-d-y,r[6]=g+m,r[7]=0,r[8]=p+x,r[9]=g-m,r[10]=1-d-v,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1},n.rotationAxisAngle=function(t,e,r){var a=r.elements,o=t._x,c=t._y,l=t._z,_=Math.sqrt(o*o+c*c+l*l),u,h,d;Math.abs(_)k.zeroTolerance&&(o=1/o,e._x=r*o,e._y=a*o,e._onValueChanged&&e._onValueChanged())},n.scale=function(t,e,r){r._x=t._x*e,r._y=t._y*e,r._onValueChanged&&r._onValueChanged()},fa(n,[{key:"x",get:function(){return this._x},set:function(t){this._x=t,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(t){this._y=t,this._onValueChanged&&this._onValueChanged()}}]),n}();(function(){ee._zero=new ee(0,0)})();(function(){ee._one=new ee(1,1)})();var ie=function(){function n(i,t,e,r){i===void 0&&(i=0),t===void 0&&(t=0),e===void 0&&(e=0),r===void 0&&(r=0),this._onValueChanged=null,this._x=i,this._y=t,this._z=e,this._w=r}var s=n.prototype;return s.set=function(t,e,r,a){return this._x=t,this._y=e,this._z=r,this._w=a,this._onValueChanged&&this._onValueChanged(),this},s.add=function(t){return this._x+=t._x,this._y+=t._y,this._z+=t._z,this._w+=t._w,this._onValueChanged&&this._onValueChanged(),this},s.subtract=function(t){return this._x-=t._x,this._y-=t._y,this._z-=t._z,this._w-=t._w,this._onValueChanged&&this._onValueChanged(),this},s.multiply=function(t){return this._x*=t._x,this._y*=t._y,this._z*=t._z,this._w*=t._w,this._onValueChanged&&this._onValueChanged(),this},s.divide=function(t){return this._x/=t._x,this._y/=t._y,this._z/=t._z,this._w/=t._w,this._onValueChanged&&this._onValueChanged(),this},s.length=function(){var t=this,e=t._x,r=t._y,a=t._z,o=t._w;return Math.sqrt(e*e+r*r+a*a+o*o)},s.lengthSquared=function(){var t=this,e=t._x,r=t._y,a=t._z,o=t._w;return e*e+r*r+a*a+o*o},s.negate=function(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._w=-this._w,this._onValueChanged&&this._onValueChanged(),this},s.normalize=function(){return n.normalize(this,this),this},s.scale=function(t){return this._x*=t,this._y*=t,this._z*=t,this._w*=t,this._onValueChanged&&this._onValueChanged(),this},s.clone=function(){var t=new n(this._x,this._y,this._z,this._w);return t},s.copyFrom=function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onValueChanged&&this._onValueChanged(),this},s.copyFromArray=function(t,e){return e===void 0&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onValueChanged&&this._onValueChanged(),this},s.copyToArray=function(t,e){e===void 0&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w},s.toJSON=function(){return{x:this._x,y:this._y,z:this._z,w:this._w}},n.add=function(t,e,r){r._x=t._x+e._x,r._y=t._y+e._y,r._z=t._z+e._z,r._w=t._w+e._w,r._onValueChanged&&r._onValueChanged()},n.subtract=function(t,e,r){r._x=t._x-e._x,r._y=t._y-e._y,r._z=t._z-e._z,r._w=t._w-e._w,r._onValueChanged&&r._onValueChanged()},n.multiply=function(t,e,r){r._x=t._x*e._x,r._y=t._y*e._y,r._z=t._z*e._z,r._w=t._w*e._w,r._onValueChanged&&r._onValueChanged()},n.divide=function(t,e,r){r._x=t._x/e._x,r._y=t._y/e._y,r._z=t._z/e._z,r._w=t._w/e._w,r._onValueChanged&&r._onValueChanged()},n.dot=function(t,e){return t._x*e._x+t._y*e._y+t._z*e._z+t._w*e._w},n.distance=function(t,e){var r=e._x-t._x,a=e._y-t._y,o=e._z-t._z,c=e._w-t._w;return Math.sqrt(r*r+a*a+o*o+c*c)},n.distanceSquared=function(t,e){var r=e._x-t._x,a=e._y-t._y,o=e._z-t._z,c=e._w-t._w;return r*r+a*a+o*o+c*c},n.equals=function(t,e){return k.equals(t._x,e._x)&&k.equals(t._y,e._y)&&k.equals(t._z,e._z)&&k.equals(t._w,e._w)},n.lerp=function(t,e,r,a){var o=t._x,c=t._y,l=t._z,_=t._w;a._x=o+(e._x-o)*r,a._y=c+(e._y-c)*r,a._z=l+(e._z-l)*r,a._w=_+(e._w-_)*r,a._onValueChanged&&a._onValueChanged()},n.max=function(t,e,r){r._x=Math.max(t._x,e._x),r._y=Math.max(t._y,e._y),r._z=Math.max(t._z,e._z),r._w=Math.max(t._w,e._w),r._onValueChanged&&r._onValueChanged()},n.min=function(t,e,r){r._x=Math.min(t._x,e._x),r._y=Math.min(t._y,e._y),r._z=Math.min(t._z,e._z),r._w=Math.min(t._w,e._w),r._onValueChanged&&r._onValueChanged()},n.negate=function(t,e){e._x=-t._x,e._y=-t._y,e._z=-t._z,e._w=-t._w,e._onValueChanged&&e._onValueChanged()},n.normalize=function(t,e){var r=t._x,a=t._y,o=t._z,c=t._w,l=Math.sqrt(r*r+a*a+o*o+c*c);l>k.zeroTolerance&&(l=1/l,e._x=r*l,e._y=a*l,e._z=o*l,e._w=c*l,e._onValueChanged&&e._onValueChanged())},n.scale=function(t,e,r){r._x=t._x*e,r._y=t._y*e,r._z=t._z*e,r._w=t._w*e,r._onValueChanged&&r._onValueChanged()},n.transform=function(t,e,r){var a=t._x,o=t._y,c=t._z,l=t._w,_=e.elements;r._x=a*_[0]+o*_[4]+c*_[8]+l*_[12],r._y=a*_[1]+o*_[5]+c*_[9]+l*_[13],r._z=a*_[2]+o*_[6]+c*_[10]+l*_[14],r._w=a*_[3]+o*_[7]+c*_[11]+l*_[15],r._onValueChanged&&r._onValueChanged()},n.transformByQuat=function(t,e,r){var a=t._x,o=t._y,c=t._z,l=t._w,_=e._x,u=e._y,h=e._z,d=e._w,f=d*a+u*c-h*o,v=d*o+h*a-_*c,p=d*c+_*o-u*a,g=-_*a-u*o-h*c;r._x=f*d-g*_-v*h+p*u,r._y=v*d-g*u-p*_+f*h,r._z=p*d-g*h-f*u+v*_,r._w=l,r._onValueChanged&&r._onValueChanged()},fa(n,[{key:"x",get:function(){return this._x},set:function(t){this._x=t,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(t){this._y=t,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(t){this._z=t,this._onValueChanged&&this._onValueChanged()}},{key:"w",get:function(){return this._w},set:function(t){this._w=t,this._onValueChanged&&this._onValueChanged()}}]),n}();(function(){ie._zero=new ie(0,0,0,0)})();(function(){ie._one=new ie(1,1,1,1)})();var q=function(){function n(i,t,e,r){i===void 0&&(i=1),t===void 0&&(t=1),e===void 0&&(e=1),r===void 0&&(r=1),this._onValueChanged=null,this._r=i,this._g=t,this._b=e,this._a=r}var s=n.prototype;return s.set=function(t,e,r,a){return this._r=t,this._g=e,this._b=r,this._a=a,this._onValueChanged&&this._onValueChanged(),this},s.add=function(t){return this._r+=t._r,this._g+=t._g,this._b+=t._b,this._a+=t._a,this._onValueChanged&&this._onValueChanged(),this},s.scale=function(t){return this._r*=t,this._g*=t,this._b*=t,this._a*=t,this._onValueChanged&&this._onValueChanged(),this},s.clone=function(){var t=new n(this._r,this._g,this._b,this._a);return t},s.copyFrom=function(t){return this._r=t.r,this._g=t.g,this._b=t.b,this._a=t.a,this._onValueChanged&&this._onValueChanged(),this},s.copyFromArray=function(t,e){return e===void 0&&(e=0),this._r=t[e],this._g=t[e+1],this._b=t[e+2],this._a=t[e+3],this._onValueChanged&&this._onValueChanged(),this},s.copyToArray=function(t,e){e===void 0&&(e=0),t[e]=this._r,t[e+1]=this._g,t[e+2]=this._b,t[e+3]=this._a},s.toLinear=function(t){return t._r=n.gammaToLinearSpace(this._r),t._g=n.gammaToLinearSpace(this._g),t._b=n.gammaToLinearSpace(this._b),this._onValueChanged&&this._onValueChanged(),t},s.toGamma=function(t){return t._r=n.linearToGammaSpace(this._r),t._g=n.linearToGammaSpace(this._g),t._b=n.linearToGammaSpace(this._b),this._onValueChanged&&this._onValueChanged(),t},s.getBrightness=function(){var t=this.r,e=this.g,r=this.b,a=t,o=t;return e>a&&(a=e),r>a&&(a=r),e>>17,t^=e^e>>>26,this._state1=t,this._state0+this._state1>>>0},s.random=function(){return this.randomInt32()/4294967295},s.reset=function(t,e){this._state0=t>>>0,this._state1=e>>>0},n}(),Nt;(function(n){n[n.Android=0]="Android",n[n.IPhone=1]="IPhone",n[n.IPad=2]="IPad",n[n.Mac=3]="Mac",n[n.Unknown=4]="Unknown"})(Nt||(Nt={}));function _e(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function Wo(n,s){for(var i=0;i=0;o--)(a=n[o])&&(r=(e<3?a(r):e>3?a(s,i,r):a(s,i))||r);return e>3&&r&&Object.defineProperty(s,i,r),r}function lt(n,s){return s!=null&&typeof Symbol<"u"&&s[Symbol.hasInstance]?!!s[Symbol.hasInstance](n):n instanceof s}var on;(function(n){n[n.Ignore=0]="Ignore",n[n.Assignment=1]="Assignment",n[n.Shallow=2]="Shallow",n[n.Deep=3]="Deep"})(on||(on={}));function F(n,s){Cr.registerCloneMode(n,s,on.Ignore)}function Me(n,s){Cr.registerCloneMode(n,s,on.Assignment)}function Co(n,s){Cr.registerCloneMode(n,s,on.Shallow)}function J(n,s){Cr.registerCloneMode(n,s,on.Deep)}var Cr=function(){function n(){}return n.registerCloneMode=function(i,t,e){var r=n._subCloneModeMap.get(i.constructor);r||(r=Object.create(null),n._subCloneModeMap.set(i.constructor,r)),r[t]=e},n.getCloneMode=function(i){var t=n._cloneModeMap.get(i);if(!t){t=Object.create(null),n._cloneModeMap.set(i,t);for(var e=n._objectType,r=n._subCloneModeMap;i!==e;){var a=r.get(i);a&&Object.assign(t,a),i=Object.getPrototypeOf(i)}}return t},n.cloneProperty=function(i,t,e,r){if(r!==on.Ignore){var a=i[e];if(lt(a,Object)){if(r===void 0||r===on.Assignment){t[e]=a;return}var o=a.constructor;switch(o){case Uint8Array:case Uint16Array:case Uint32Array:case Int8Array:case Int16Array:case Int32Array:case Float32Array:case Float64Array:var c=t[e];c==null||c.length!==a.length?t[e]=a.slice():c.set(a);break;case Array:var l=t[e],_=a.length;l==null?t[e]=l=new Array(_):l.length=_;for(var u=0;u<_;u++)n.cloneProperty(a,l,u,r);break;default:var h,d,f=(h=t)[d=e]||(h[d]=new a.constructor),v=n.getCloneMode(a.constructor);for(var p in a)n.cloneProperty(a,f,p,v[p]);a._cloneTo&&a._cloneTo(f),a.copyFrom&&f.copyFrom(a);break}}else t[e]=a}},n.deepCloneObject=function(i,t){for(var e in i)n.cloneProperty(i,t,e,on.Deep)},n}();(function(){Cr._subCloneModeMap=new Map})();(function(){Cr._cloneModeMap=new Map})();(function(){Cr._objectType=Object.getPrototypeOf(Object)})();var Yr=function(){function n(i){this.instanceId=++n._instanceIdCounter,this._destroyed=!1,this._engine=i}var s=n.prototype;return s.destroy=function(){this._destroyed||(this._onDestroy(),this._destroyed=!0)},s._onDestroy=function(){var t=this._engine.resourceManager;t._deleteAsset(this),t._deleteContentRestorer(this)},j(n,[{key:"engine",get:function(){return this._engine}},{key:"destroyed",get:function(){return this._destroyed}}]),n}();(function(){Yr._instanceIdCounter=0})();T([F],Yr.prototype,"instanceId",void 0);T([F],Yr.prototype,"_engine",void 0);var Qr=function(n){W(s,n);function s(t){var e;return e=n.call(this,t)||this,e.isGCIgnored=!1,e._refCount=0,e._superResources=null,t.resourceManager._addReferResource(_e(e)),e}var i=s.prototype;return i.destroy=function(e,r){if(e===void 0&&(e=!1),!e){var a;if(this._refCount!==0)return!1;var o=this._superResources;if((a=o)!=null&&a.length)if(r){for(var c=0,l=o.length;c0)return!1}else return!1}return n.prototype.destroy.call(this),!0},i._associationSuperResource=function(e){(this._superResources||(this._superResources=[])).push(e)},i._disassociationSuperResource=function(e){var r=this._superResources,a=r.indexOf(e);r.splice(a,1)},i._getReferCount=function(){return this._refCount},i._addReferCount=function(e){this._refCount+=e},i._addToResourceManager=function(e){this._engine.resourceManager._addAsset(e,this)},i._onDestroy=function(){n.prototype._onDestroy.call(this),this._engine.resourceManager._deleteReferResource(this);var e=this._getReferCount();e>0&&this._addReferCount(-e)},j(s,[{key:"refCount",get:function(){return this._refCount}}]),s}(Yr),yc=function(n){W(s,n);function s(t){var e;return e=n.call(this,t)||this,e._sprites=new Array,e._spriteNamesToIndex={},e}var i=s.prototype;return i.getSprite=function(e){var r=this._sprites[this._spriteNamesToIndex[e]];return r||console.warn("There is no sprite named "+e+" in the atlas."),r},i.getSprites=function(e,r){r.length=0;var a=this._spriteNamesToIndex[e];if(a!==void 0)for(var o=this._sprites;a>=0;a--){var c=o[a];c.name===e&&r.push(c)}else console.warn("The name of the sprite you want to find is not exit in SpriteAtlas.");return r},i._addSprite=function(e){this._spriteNamesToIndex[e.name]=this._sprites.push(e)-1,e._atlas=this,e.isGCIgnored=!0},i._onDestroy=function(){n.prototype._onDestroy.call(this);for(var e=this,r=e._sprites,a=0,o=r.length;a>1,o=i[t],c=i[e-1],l=i[a],_=r(o,c);if(_>0){var u=o;o=c,c=u}var h=r(o,l);if(h>=0){var d=o;o=l,l=c,c=d}else{var f=r(c,l);if(f>0){var v=c;c=l,l=v}}i[t]=o,i[e-1]=l;var p=c,g=t+1,y=e-1;i[a]=i[g],i[g]=p;e:for(var m=g+1;m0){do{if(y--,y==m)break e;var b=i[y];C=r(b,p)}while(C>0);i[m]=i[y],i[y]=x,C<0&&(x=i[m],i[m]=i[g],i[g]=x,g++)}}e-y=t;o--){var l=i[o],_=r(l,c);if(_>0)i[o+1]=l;else break}i[o+1]=c}},n}(),sl=46,cl=/\\(\\)?/g,ll=RegExp(`[^.[\\]]+|\\[(?:([^"'][^[]*)|(["'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))`,"g"),Dr=function(){function n(){this._updateFlags=[],this._listeners=[]}var s=n.prototype;return s.createFlag=function(t){var e=new t;return this.addFlag(e),e},s.addFlag=function(t){this._updateFlags.push(t),t._flagManagers.push(this)},s.removeFlag=function(t){var e=Ue.removeFromArray(this._updateFlags,t);e&&Ue.removeFromArray(t._flagManagers,this)},s.addListener=function(t){this._listeners.push(t)},s.removeListener=function(t){Ue.removeFromArray(this._listeners,t)},s.dispatch=function(t,e){for(var r=this._updateFlags,a=r.length-1;a>=0;a--)r[a].dispatch(t,e);for(var o=this._listeners,c=o.length-1;c>=0;c--)o[c](t,e)},n}(),we;(function(n){n[n.texture=1]="texture",n[n.size=2]="size",n[n.atlasRotate=4]="atlasRotate",n[n.atlasRegion=8]="atlasRegion",n[n.atlasRegionOffset=16]="atlasRegionOffset",n[n.region=32]="region",n[n.pivot=64]="pivot",n[n.border=128]="border",n[n.destroy=256]="destroy"})(we||(we={}));var di=function(n){W(s,n);function s(t,e,r,a,o,c){e===void 0&&(e=null),r===void 0&&(r=null),a===void 0&&(a=null),o===void 0&&(o=null),c===void 0&&(c=null);var l;return l=n.call(this,t)||this,l._automaticWidth=0,l._automaticHeight=0,l._customWidth=void 0,l._customHeight=void 0,l._positions=[new ee,new ee,new ee,new ee],l._uvs=[new ee,new ee,new ee,new ee],l._bounds=new cr,l._texture=null,l._atlasRotated=!1,l._atlasRegion=new kr(0,0,1,1),l._atlasRegionOffset=new ie(0,0,0,0),l._region=new kr(0,0,1,1),l._pivot=new ee(.5,.5),l._border=new ie(0,0,0,0),l._dirtyUpdateFlag=7,l._updateFlagManager=new Dr,l._texture=e,l._onRegionChange=l._onRegionChange.bind(_e(l)),l._onPivotChange=l._onPivotChange.bind(_e(l)),l._onBorderChange=l._onBorderChange.bind(_e(l)),l._region._onValueChanged=l._onRegionChange,l._pivot._onValueChanged=l._onPivotChange,l._border._onValueChanged=l._onBorderChange,r&&l._region.copyFrom(r),a&&l._pivot.copyFrom(a),o&&l._border.copyFrom(o),l.name=c,l}var i=s.prototype;return i.clone=function(){var e=new s(this._engine,this._texture,this._region,this._pivot,this._border,this.name);return e._atlasRotated=this._atlasRotated,e._atlasRegion.copyFrom(this._atlasRegion),e._atlasRegionOffset.copyFrom(this._atlasRegionOffset),e},i._getPositions=function(){return this._dirtyUpdateFlag&1&&this._updatePositions(),this._positions},i._getUVs=function(){return this._dirtyUpdateFlag&2&&this._updateUVs(),this._uvs},i._getBounds=function(){return this._dirtyUpdateFlag&1&&this._updatePositions(),this._bounds},i._addReferCount=function(e){var r;n.prototype._addReferCount.call(this,e),(r=this._atlas)==null||r._addReferCount(e)},i._onDestroy=function(){this._dispatchSpriteChange(we.destroy),n.prototype._onDestroy.call(this),this._positions.length=0,this._positions=null,this._uvs.length=0,this._uvs=null,this._atlasRegion=null,this._atlasRegionOffset=null,this._region=null,this._pivot=null,this._border=null,this._bounds=null,this._atlas=null,this._texture=null,this._updateFlagManager=null},i._calDefaultSize=function(){if(this._texture){var e=this,r=e._texture,a=e._atlasRegion,o=e._atlasRegionOffset,c=e._region,l=1/hn._pixelsPerUnit;this._automaticWidth=r.width*a.width/(1-o.x-o.z)*c.width*l,this._automaticHeight=r.height*a.height/(1-o.y-o.w)*c.height*l}else this._automaticWidth=this._automaticHeight=0;this._dirtyUpdateFlag&=-5},i._updatePositions=function(){var e=this._atlasRegionOffset,r=this._region,a=r.x,o=r.y,c=r.width,l=r.height,_=1-a-c,u=1-o-l,h=Math.max(e.x-a,0)/c,d=Math.max(e.w-o,0)/l,f=1-Math.max(e.z-_,0)/c,v=1-Math.max(e.y-u,0)/l,p=this._positions;p[0].set(h,d),p[1].set(f,d),p[2].set(h,v),p[3].set(f,v);var g=this._bounds,y=g.min,m=g.max;y.set(h,d,0),m.set(f,v,0),this._dirtyUpdateFlag&=-2},i._updateUVs=function(){var e=this,r=e._uvs,a=e._atlasRegionOffset,o=this._region,c=o.x,l=o.y,_=o.width,u=o.height,h=1-c-_,d=1-l-u,f=this._atlasRegion,v=f.x,p=f.y,g=f.width,y=f.height,m=a.x,x=a.y,C=a.z,b=a.w,A=g/(1-m-C),S=y/(1-x-b),w=Math.max(c-m,0)*A+v,E=Math.max(d-x,0)*S+p,B=g+v-Math.max(h-C,0)*A,M=y+p-Math.max(l-b,0)*S,D=this._border,L=D.x,V=D.y,N=D.z,I=D.w;r[0].set(w,M),r[1].set((c-m+L*_)*A+v,y+p-(l-b+V*u)*S),r[2].set(g+v-(h-C+N*_)*A,(d-x+I*u)*S+p),r[3].set(B,E),this._dirtyUpdateFlag&=-3},i._dispatchSpriteChange=function(e){switch(e){case we.texture:this._dirtyUpdateFlag|=4;break;case we.atlasRegionOffset:case we.region:this._dirtyUpdateFlag|=7;break;case we.atlasRegion:this._dirtyUpdateFlag|=6;break;case we.border:this._dirtyUpdateFlag|=2;break}this._updateFlagManager.dispatch(e)},i._onRegionChange=function(){var e=this,r=e._region;r._onValueChanged=null;var a=k.clamp(r.x,0,1),o=k.clamp(r.y,0,1);r.set(a,o,k.clamp(r.width,0,1-a),k.clamp(r.height,0,1-o)),this._dispatchSpriteChange(we.region),(this._customWidth===void 0||this._customHeight===void 0)&&this._dispatchSpriteChange(we.size),r._onValueChanged=this._onRegionChange},i._onPivotChange=function(){this._dispatchSpriteChange(we.pivot)},i._onBorderChange=function(){var e=this,r=e._border;r._onValueChanged=null;var a=k.clamp(r.x,0,1),o=k.clamp(r.y,0,1);r.set(a,o,k.clamp(r.z,0,1-a),k.clamp(r.w,0,1-o)),this._dispatchSpriteChange(we.border),r._onValueChanged=this._onBorderChange},j(s,[{key:"texture",get:function(){return this._texture},set:function(e){this._texture!==e&&(this._texture=e,this._dispatchSpriteChange(we.texture),(this._customWidth===void 0||this._customHeight===void 0)&&this._dispatchSpriteChange(we.size))}},{key:"width",get:function(){return this._customWidth!==void 0?this._customWidth:(this._dirtyUpdateFlag&4&&this._calDefaultSize(),this._automaticWidth)},set:function(e){this._customWidth!==e&&(this._customWidth=e,this._dispatchSpriteChange(we.size))}},{key:"height",get:function(){return this._customHeight!==void 0?this._customHeight:(this._dirtyUpdateFlag&4&&this._calDefaultSize(),this._automaticHeight)},set:function(e){this._customHeight!==e&&(this._customHeight=e,this._dispatchSpriteChange(we.size))}},{key:"atlasRotated",get:function(){return this._atlasRotated},set:function(e){this._atlasRotated!=e&&(this._atlasRotated=e)}},{key:"atlasRegion",get:function(){return this._atlasRegion},set:function(e){var r=k.clamp(e.x,0,1),a=k.clamp(e.y,0,1);this._atlasRegion.set(r,a,k.clamp(e.width,0,1-r),k.clamp(e.height,0,1-a)),this._dispatchSpriteChange(we.atlasRegion),(this._customWidth===void 0||this._customHeight===void 0)&&this._dispatchSpriteChange(we.size)}},{key:"atlasRegionOffset",get:function(){return this._atlasRegionOffset},set:function(e){var r=k.clamp(e.x,0,1),a=k.clamp(e.y,0,1);this._atlasRegionOffset.set(r,a,k.clamp(e.z,0,1-r),k.clamp(e.w,0,1-a)),this._dispatchSpriteChange(we.atlasRegionOffset),(this._customWidth===void 0||this._customHeight===void 0)&&this._dispatchSpriteChange(we.size)}},{key:"region",get:function(){return this._region},set:function(e){this._region!==e&&this._region.copyFrom(e)}},{key:"pivot",get:function(){return this._pivot},set:function(e){this._pivot!==e&&this._pivot.copyFrom(e)}},{key:"border",get:function(){return this._border},set:function(e){this._border!==e&&this._border.copyFrom(e)}}]),s}(Qr),Xo;(function(n){n[n.positions=1]="positions",n[n.uvs=2]="uvs",n[n.automaticSize=4]="automaticSize",n[n.all=7]="all"})(Xo||(Xo={}));var Ao=function(){function n(){this._events=Object.create(null),this._eventCount=0}var s=n.prototype;return s.hasEvent=function(t){return this._events[t]!=null},s.eventNames=function(){return this._eventCount===0?[]:Object.keys(this._events)},s.listenerCount=function(t){var e=this._events[t];return e?Array.isArray(e)?e.length:1:0},s.dispatch=function(t,e){if(!this._events[t])return!1;var r=this._events[t];if(Array.isArray(r)){var a=r.length,o=n._dispatchingListenersPool,c=o.length>0?o.pop():[];c.length=a;for(var l=0;l=0;o--)r[o].fn===e&&(r[o].destroyed=!0,r.splice(o,1));r.length===0?this._clearEvent(t):r.length===1&&(this._events[t]=r[0])}return this},s.removeEventListener=function(t,e){return this.off(t,e)},s.removeAllEventListeners=function(t){t?this._events[t]&&this._clearEvent(t):(this._events=Object.create(null),this._eventCount=0)},s._addEventListener=function(t,e,r){var a={fn:e,once:r},o=this._events,c=o[t];return c?Array.isArray(c)?c.push(a):o[t]=[c,a]:(o[t]=a,this._eventCount++),this},s._clearEvent=function(t){--this._eventCount===0?this._events=Object.create(null):delete this._events[t]},n}();(function(){Ao._dispatchingListenersPool=[]})();var gn=function(n){for(var s=arguments.length,i=new Array(s>1?s-1:0),t=1;ta)){var o=r[e]&~t._maskValue;e==a&&o===0?this._length--:r[e]=o}},s.unionCollection=function(t){var e=t._mask,r=t._length,a=this._mask,o=this._length;if(o=0;o--){var c=r[o]&~e[o];o==a&&c===0?(a--,this._length--):r[o]=c}},s.intersectionCollection=function(t){for(var e=t._mask,r=this._mask,a=this._length-1;a>=0;a--){var o=r[a]&e[a];o==0&&a==this._length-1?this._length--:r[a]=o}},s.isEnable=function(t){var e=t._maskIndex;return e>=this._length?!1:(this._mask[e]&t._maskValue)!==0},s.clear=function(){this._length=0},n.unionCollection=function(t,e,r){var a=r._mask,o,c,l,_;t._lengthk.zeroTolerance&&(c=1/c,e.set(r*c,a*c,o*c))},n.scale=function(t,e,r){r._x=t._x*e,r._y=t._y*e,r._z=t._z*e,r._onValueChanged&&r._onValueChanged()},n.transformNormal=function(t,e,r){var a=t._x,o=t._y,c=t._z,l=e.elements;r._x=a*l[0]+o*l[4]+c*l[8],r._y=a*l[1]+o*l[5]+c*l[9],r._z=a*l[2]+o*l[6]+c*l[10],r._onValueChanged&&r._onValueChanged()},n.transformToVec3=function(t,e,r){var a=t._x,o=t._y,c=t._z,l=e.elements;r._x=a*l[0]+o*l[4]+c*l[8]+l[12],r._y=a*l[1]+o*l[5]+c*l[9]+l[13],r._z=a*l[2]+o*l[6]+c*l[10]+l[14],r._onValueChanged&&r._onValueChanged()},n.transformToVec4=function(t,e,r){var a=t._x,o=t._y,c=t._z,l=e.elements;r._x=a*l[0]+o*l[4]+c*l[8]+l[12],r._y=a*l[1]+o*l[5]+c*l[9]+l[13],r._z=a*l[2]+o*l[6]+c*l[10]+l[14],r._w=a*l[3]+o*l[7]+c*l[11]+l[15],r._onValueChanged&&r._onValueChanged()},n.transformCoordinate=function(t,e,r){var a=t._x,o=t._y,c=t._z,l=e.elements,_=a*l[3]+o*l[7]+c*l[11]+l[15];_=1/_,r._x=(a*l[0]+o*l[4]+c*l[8]+l[12])*_,r._y=(a*l[1]+o*l[5]+c*l[9]+l[13])*_,r._z=(a*l[2]+o*l[6]+c*l[10]+l[14])*_,r._onValueChanged&&r._onValueChanged()},n.transformByQuat=function(t,e,r){var a=t._x,o=t._y,c=t._z,l=e._x,_=e._y,u=e._z,h=e._w,d=h*a+_*c-u*o,f=h*o+u*a-l*c,v=h*c+l*o-_*a,p=-l*a-_*o-u*c;r._x=d*h-p*l-f*u+v*_,r._y=f*h-p*_-v*l+d*u,r._z=v*h-p*u-d*_+f*l,r._onValueChanged&&r._onValueChanged()},pa(n,[{key:"x",get:function(){return this._x},set:function(t){this._x=t,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(t){this._y=t,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(t){this._z=t,this._onValueChanged&&this._onValueChanged()}}]),n}();(function(){R._zero=new R(0,0,0)})();(function(){R._one=new R(1,1,1)})();var xc=function(){function n(i,t){i===void 0&&(i=null),t===void 0&&(t=0),this.center=new R,this.radius=0,i&&this.center.copyFrom(i),this.radius=t}var s=n.prototype;return s.clone=function(){return new n(this.center,this.radius)},s.copyFrom=function(t){return this.center.copyFrom(t.center),this.radius=t.radius,this},n.fromPoints=function(t,e){if(!t||t.length===0)throw new Error("points must be array and length must > 0");var r=t.length,a=n._tempVec30;a.x=a.y=a.z=0;for(var o=0;oc&&(c=_)}e.radius=Math.sqrt(c)},n.fromBox=function(t,e){var r=e.center,a=t.min,o=t.max;r.x=(a.x+o.x)*.5,r.y=(a.y+o.y)*.5,r.z=(a.z+o.z)*.5,e.radius=R.distance(r,o)},n}();(function(){xc._tempVec30=new R})();var lr=function(){function n(i,t){i===void 0&&(i=null),t===void 0&&(t=null),this.min=new R,this.max=new R,i&&this.min.copyFrom(i),t&&this.max.copyFrom(t)}var s=n.prototype;return s.getCenter=function(t){var e=this,r=e.min,a=e.max,o=a._x+r._x,c=a._y+r._y,l=a._z+r._z;return t.set(isNaN(o)?0:o*.5,isNaN(c)?0:c*.5,isNaN(l)?0:l*.5),t},s.getExtent=function(t){var e=this,r=e.min,a=e.max,o=a._x-r._x,c=a._y-r._y,l=a._z-r._z;return t.set(isNaN(o)?0:o*.5,isNaN(c)?0:c*.5,isNaN(l)?0:l*.5),t},s.getCorners=function(t){t===void 0&&(t=[]);var e=this,r=e.min,a=e.max,o=r.x,c=r.y,l=r.z,_=a.x,u=a.y,h=a.z,d=t.length;if(d<8)for(var f=0,v=8-d;f 0");var r=e.min,a=e.max;r.x=r.y=r.z=Number.MAX_VALUE,a.x=a.y=a.z=-Number.MAX_VALUE;for(var o=0,c=t.length;o0?Lt.Front:e<0?Lt.Back:Lt.Intersecting},n.intersectsPlaneAndBox=function(i,t){var e=t.min,r=t.max,a=i.normal,o=n._tempVec30,c=n._tempVec31;return a.x>=0?(o.x=r.x,c.x=e.x):(o.x=e.x,c.x=r.x),a.y>=0?(o.y=r.y,c.y=e.y):(o.y=e.y,c.y=r.y),a.z>=0?(o.z=r.z,c.z=e.z):(o.z=e.z,c.z=r.z),n.distancePlaneAndPoint(i,o)<0?Lt.Back:n.distancePlaneAndPoint(i,c)>0?Lt.Front:Lt.Intersecting},n.intersectsPlaneAndSphere=function(i,t){var e=t.center,r=t.radius,a=n.distancePlaneAndPoint(i,e);return a>r?Lt.Front:a<-r?Lt.Back:Lt.Intersecting},n.intersectsRayAndPlane=function(i,t){var e=t.normal,r=k.zeroTolerance,a=R.dot(e,i.direction);if(Math.abs(a)c.x)return-1}else{var g=1/l,y=(o.x-h)*g,m=(c.x-h)*g;if(y>m){var x=y;y=m,m=x}if(v=Math.max(y,v),p=Math.min(m,p),v>p)return-1}if(Math.abs(_)c.y)return-1}else{var C=1/_,b=(o.y-d)*C,A=(c.y-d)*C;if(b>A){var S=b;b=A,A=S}if(v=Math.max(b,v),p=Math.min(A,p),v>p)return-1}if(Math.abs(u)c.z)return-1}else{var w=1/u,E=(o.z-f)*w,P=(c.z-f)*w;if(E>P){var M=E;E=P,P=M}if(v=Math.max(E,v),p=Math.min(P,p),v>p)return-1}return v},n.intersectsRayAndSphere=function(i,t){var e=i.origin,r=i.direction,a=t.center,o=t.radius,c=n._tempVec30;R.subtract(e,a,c);var l=R.dot(c,r),_=R.dot(c,c)-o*o;if(l>0&&_>0)return-1;var u=l*l-_;if(u<0)return-1;var h=-l-Math.sqrt(u);return h<0&&(h=0),h},n.intersectsBoxAndBox=function(i,t){return i.min.x>t.max.x||t.min.x>i.max.x||i.min.y>t.max.y||t.min.y>i.max.y?!1:!(i.min.z>t.max.z||t.min.z>i.max.z)},n.intersectsSphereAndSphere=function(i,t){var e=i.radius+t.radius;return R.distanceSquared(i.center,t.center)=0?r.x:e.x,l.y>=0?r.y:e.y,l.z>=0?r.z:e.z),R.dot(l,a)<-c.distance)return!1}return!0},n.frustumContainsPoint=function(i,t){var e=n.distancePlaneAndPoint(i.near,t);return Math.abs(e)=0?(a.x=r.x,o.x=e.x):(a.x=e.x,o.x=r.x),u.y>=0?(a.y=r.y,o.y=e.y):(a.y=e.y,o.y=r.y),u.z>=0?(a.z=r.z,o.z=e.z):(a.z=e.z,o.z=r.z),n.intersectsPlaneAndPoint(_,a)===Lt.Back)return et.Disjoint;n.intersectsPlaneAndPoint(_,o)===Lt.Back&&(c=et.Intersects)}return c},n.frustumContainsSphere=function(i,t){for(var e=et.Contains,r=0;r<6;++r){var a=i.getPlane(r),o=n.intersectsPlaneAndSphere(a,t);if(o===Lt.Back)return et.Disjoint;if(o===Lt.Intersecting){e=et.Intersects;break}}return e},n}();(function(){wt._tempVec30=new R})();(function(){wt._tempVec31=new R})();(function(){wt._tempVec32=new R})();var ht=function(){function n(i,t){i===void 0&&(i=null),t===void 0&&(t=0),this.normal=new R,this.distance=0,i&&this.normal.copyFrom(i),this.distance=t}var s=n.prototype;return s.normalize=function(){return n.normalize(this,this),this},s.clone=function(){var t=new n;return t.copyFrom(this),t},s.copyFrom=function(t){return this.normal.copyFrom(t.normal),this.distance=t.distance,this},n.normalize=function(t,e){var r=t.normal,a=1/r.length();R.scale(r,a,e.normal),e.distance=t.distance*a},n.fromPoints=function(t,e,r,a){var o=t.x,c=t.y,l=t.z,_=e.x-o,u=e.y-c,h=e.z-l,d=r.x-o,f=r.y-c,v=r.z-l,p=u*v-h*f,g=h*d-_*v,y=_*f-u*d,m=1/Math.sqrt(p*p+g*g+y*y),x=p*m,C=g*m,b=y*m,A=a.normal;A.x=x,A.y=C,A.z=b,a.distance=-(x*o+C*c+b*l)},n}(),il=function(){function n(i){i===void 0&&(i=null),this.near=new ht,this.far=new ht,this.left=new ht,this.right=new ht,this.top=new ht,this.bottom=new ht,i&&this.calculateFromMatrix(i)}var s=n.prototype;return s.getPlane=function(t){switch(t){case me.Near:return this.near;case me.Far:return this.far;case me.Left:return this.left;case me.Right:return this.right;case me.Bottom:return this.bottom;case me.Top:return this.top;default:return null}},s.calculateFromMatrix=function(t){var e=t.elements,r=e[0],a=e[1],o=e[2],c=e[3],l=e[4],_=e[5],u=e[6],h=e[7],d=e[8],f=e[9],v=e[10],p=e[11],g=e[12],y=e[13],m=e[14],x=e[15],C=this.near.normal;C.set(c+o,h+u,p+v),this.near.distance=x+m,this.near.normalize();var b=this.far.normal;b.set(c-o,h-u,p-v),this.far.distance=x-m,this.far.normalize();var A=this.left.normal;A.set(c+r,h+l,p+d),this.left.distance=x+g,this.left.normalize();var S=this.right.normal;S.set(c-r,h-l,p-d),this.right.distance=x-g,this.right.normalize();var w=this.bottom.normal;w.set(c+a,h+_,p+f),this.bottom.distance=x+y,this.bottom.normalize();var E=this.top.normal;E.set(c-a,h-_,p-f),this.top.distance=x-y,this.top.normalize()},s.intersectsBox=function(t){return wt.intersectsFrustumAndBox(this,t)},s.intersectsSphere=function(t){return wt.frustumContainsSphere(this,t)!==et.Disjoint},s.clone=function(){var t=new n;return t.copyFrom(this),t},s.copyFrom=function(t){return this.near.copyFrom(t.near),this.far.copyFrom(t.far),this.left.copyFrom(t.left),this.right.copyFrom(t.right),this.bottom.copyFrom(t.bottom),this.top.copyFrom(t.top),this},n}(),oa=function(){function n(i,t,e,r,a,o,c,l,_){i===void 0&&(i=1),t===void 0&&(t=0),e===void 0&&(e=0),r===void 0&&(r=0),a===void 0&&(a=1),o===void 0&&(o=0),c===void 0&&(c=0),l===void 0&&(l=0),_===void 0&&(_=1),this.elements=new Float32Array(9);var u=this.elements;u[0]=i,u[1]=t,u[2]=e,u[3]=r,u[4]=a,u[5]=o,u[6]=c,u[7]=l,u[8]=_}var s=n.prototype;return s.set=function(t,e,r,a,o,c,l,_,u){var h=this.elements;return h[0]=t,h[1]=e,h[2]=r,h[3]=a,h[4]=o,h[5]=c,h[6]=l,h[7]=_,h[8]=u,this},s.add=function(t){return n.add(this,t,this),this},s.subtract=function(t){return n.subtract(this,t,this),this},s.multiply=function(t){return n.multiply(this,t,this),this},s.determinant=function(){var t=this.elements,e=t[0],r=t[1],a=t[2],o=t[3],c=t[4],l=t[5],_=t[6],u=t[7],h=t[8],d=h*c-l*u,f=-h*o+l*_,v=u*o-c*_;return e*d+r*f+a*v},s.identity=function(){var t=this.elements;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,this},s.invert=function(){return n.invert(this,this),this},s.rotate=function(t){return n.rotate(this,t,this),this},s.scale=function(t){return n.scale(this,t,this),this},s.translate=function(t){return n.translate(this,t,this),this},s.transpose=function(){return n.transpose(this,this),this},s.clone=function(){var t=this.elements,e=new n(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8]);return e},s.copyFrom=function(t){var e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],this},s.copyFromArray=function(t,e){e===void 0&&(e=0);for(var r=this.elements,a=0;a<12;a++)r[a]=t[a+e];return this},s.copyToArray=function(t,e){e===void 0&&(e=0);var r=this.elements;t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8]},s.copyFromMatrix=function(t){var e=t.elements,r=this.elements;return r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[4],r[4]=e[5],r[5]=e[6],r[6]=e[8],r[7]=e[9],r[8]=e[10],this},n.add=function(t,e,r){var a=t.elements,o=e.elements,c=r.elements;c[0]=a[0]+o[0],c[1]=a[1]+o[1],c[2]=a[2]+o[2],c[3]=a[3]+o[3],c[4]=a[4]+o[4],c[5]=a[5]+o[5],c[6]=a[6]+o[6],c[7]=a[7]+o[7],c[8]=a[8]+o[8]},n.subtract=function(t,e,r){var a=t.elements,o=e.elements,c=r.elements;c[0]=a[0]-o[0],c[1]=a[1]-o[1],c[2]=a[2]-o[2],c[3]=a[3]-o[3],c[4]=a[4]-o[4],c[5]=a[5]-o[5],c[6]=a[6]-o[6],c[7]=a[7]-o[7],c[8]=a[8]-o[8]},n.multiply=function(t,e,r){var a=t.elements,o=e.elements,c=r.elements,l=a[0],_=a[1],u=a[2],h=a[3],d=a[4],f=a[5],v=a[6],p=a[7],g=a[8],y=o[0],m=o[1],x=o[2],C=o[3],b=o[4],A=o[5],S=o[6],w=o[7],E=o[8];c[0]=l*y+h*m+v*x,c[1]=_*y+d*m+p*x,c[2]=u*y+f*m+g*x,c[3]=l*C+h*b+v*A,c[4]=_*C+d*b+p*A,c[5]=u*C+f*b+g*A,c[6]=l*S+h*w+v*E,c[7]=_*S+d*w+p*E,c[8]=u*S+f*w+g*E},n.equals=function(t,e){var r=t.elements,a=e.elements;return k.equals(r[0],a[0])&&k.equals(r[1],a[1])&&k.equals(r[2],a[2])&&k.equals(r[3],a[3])&&k.equals(r[4],a[4])&&k.equals(r[5],a[5])&&k.equals(r[6],a[6])&&k.equals(r[7],a[7])&&k.equals(r[8],a[8])},n.lerp=function(t,e,r,a){var o=t.elements,c=e.elements,l=a.elements,_=1-r;l[0]=o[0]*_+c[0]*r,l[1]=o[1]*_+c[1]*r,l[2]=o[2]*_+c[2]*r,l[3]=o[3]*_+c[3]*r,l[4]=o[4]*_+c[4]*r,l[5]=o[5]*_+c[5]*r,l[6]=o[6]*_+c[6]*r,l[7]=o[7]*_+c[7]*r,l[8]=o[8]*_+c[8]*r},n.rotationQuaternion=function(t,e){var r=e.elements,a=t._x,o=t._y,c=t._z,l=t._w,_=a+a,u=o+o,h=c+c,d=a*_,f=o*_,v=o*u,p=c*_,g=c*u,y=c*h,m=l*_,x=l*u,C=l*h;r[0]=1-v-y,r[3]=f-C,r[6]=p+x,r[1]=f+C,r[4]=1-d-y,r[7]=g-m,r[2]=p-x,r[5]=g+m,r[8]=1-d-v},n.scaling=function(t,e){var r=e.elements;r[0]=t._x,r[1]=0,r[2]=0,r[3]=0,r[4]=t._y,r[5]=0,r[6]=0,r[7]=0,r[8]=1},n.translation=function(i,t){var e=t.elements;e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=i._x,e[7]=i._y,e[8]=1},n.invert=function(t,e){var r=t.elements,a=e.elements,o=r[0],c=r[1],l=r[2],_=r[3],u=r[4],h=r[5],d=r[6],f=r[7],v=r[8],p=v*u-h*f,g=-v*_+h*d,y=f*_-u*d,m=o*p+c*g+l*y;m&&(m=1/m,a[0]=p*m,a[1]=(-v*c+l*f)*m,a[2]=(h*c-l*u)*m,a[3]=g*m,a[4]=(v*o-l*d)*m,a[5]=(-h*o+l*_)*m,a[6]=y*m,a[7]=(-f*o+c*d)*m,a[8]=(u*o-c*_)*m)},n.normalMatrix=function(t,e){var r=t.elements,a=e.elements,o=r[0],c=r[1],l=r[2],_=r[3],u=r[4],h=r[5],d=r[6],f=r[7],v=r[8],p=r[9],g=r[10],y=r[11],m=r[12],x=r[13],C=r[14],b=r[15],A=o*h-c*u,S=o*d-l*u,w=o*f-_*u,E=c*d-l*h,P=c*f-_*h,M=l*f-_*d,D=v*x-p*m,L=v*C-g*m,V=v*b-y*m,N=p*C-g*x,I=p*b-y*x,B=g*b-y*C,z=A*B-S*I+w*N+E*V-P*L+M*D;if(!z)return null;z=1/z,a[0]=(h*B-d*I+f*N)*z,a[1]=(d*V-u*B-f*L)*z,a[2]=(u*I-h*V+f*D)*z,a[3]=(l*I-c*B-_*N)*z,a[4]=(o*B-l*V+_*L)*z,a[5]=(c*V-o*I-_*D)*z,a[6]=(x*M-C*P+b*E)*z,a[7]=(C*w-m*M-b*S)*z,a[8]=(m*P-x*w+b*A)*z},n.rotate=function(t,e,r){var a=t.elements,o=r.elements,c=Math.sin(e),l=Math.cos(e),_=a[0],u=a[1],h=a[2],d=a[3],f=a[4],v=a[5],p=a[6],g=a[7],y=a[8];o[0]=l*_+c*d,o[1]=l*u+c*f,o[2]=l*h+c*v,o[3]=l*d-c*_,o[4]=l*f-c*u,o[5]=l*v-c*h,o[6]=p,o[7]=g,o[8]=y},n.scale=function(t,e,r){var a=e._x,o=e._y,c=t.elements,l=r.elements;l[0]=a*c[0],l[1]=a*c[1],l[2]=a*c[2],l[3]=o*c[3],l[4]=o*c[4],l[5]=o*c[5],l[6]=c[6],l[7]=c[7],l[8]=c[8]},n.translate=function(t,e,r){var a=e._x,o=e._y,c=t.elements,l=r.elements,_=c[0],u=c[1],h=c[2],d=c[3],f=c[4],v=c[5],p=c[6],g=c[7],y=c[8];l[0]=_,l[1]=u,l[2]=h,l[3]=d,l[4]=f,l[5]=v,l[6]=a*_+o*d+p,l[7]=a*u+o*f+g,l[8]=a*h+o*v+y},n.transpose=function(t,e){var r=t.elements,a=e.elements;if(e===t){var o=r[1],c=r[2],l=r[5];a[1]=r[3],a[2]=r[6],a[3]=o,a[5]=r[7],a[6]=c,a[7]=l}else a[0]=r[0],a[1]=r[3],a[2]=r[6],a[3]=r[1],a[4]=r[4],a[5]=r[7],a[6]=r[2],a[7]=r[5],a[8]=r[8]},n}(),Re=function(){function n(i,t,e,r){i===void 0&&(i=0),t===void 0&&(t=0),e===void 0&&(e=0),r===void 0&&(r=1),this._onValueChanged=null,this._x=i,this._y=t,this._z=e,this._w=r}var s=n.prototype;return s.set=function(t,e,r,a){return this._x=t,this._y=e,this._z=r,this._w=a,this._onValueChanged&&this._onValueChanged(),this},s.conjugate=function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onValueChanged&&this._onValueChanged(),this},s.getAxisAngle=function(t){var e=this,r=e._x,a=e._y,o=e._z,c=r*r+a*a+o*o;if(c(1-k.zeroTolerance)*d?(t._x=Math.atan2(2*(c*a-r*o),l+h-_-u),t._y=Math.PI/2,t._z=0):f<-(1-k.zeroTolerance)*d?(t._x=Math.atan2(2*(c*a-r*o),l+h-_-u),t._y=-Math.PI/2,t._z=0):(t._x=Math.atan2(2*(o*r+a*c),u+h-_-l),t._y=Math.asin(f/d),t._z=Math.atan2(2*(r*a+o*c),_+h-u-l))},n.add=function(t,e,r){r._x=t._x+e._x,r._y=t._y+e._y,r._z=t._z+e._z,r._w=t._w+e._w,r._onValueChanged&&r._onValueChanged()},n.multiply=function(t,e,r){var a=t._x,o=t._y,c=t._z,l=t._w,_=e._x,u=e._y,h=e._z,d=e._w;r._x=a*d+l*_+o*h-c*u,r._y=o*d+l*u+c*_-a*h,r._z=c*d+l*h+a*u-o*_,r._w=l*d-a*_-o*u-c*h,r._onValueChanged&&r._onValueChanged()},n.conjugate=function(t,e){e._x=-t._x,e._y=-t._y,e._z=-t._z,e._w=t._w,e._onValueChanged&&e._onValueChanged()},n.dot=function(t,e){return t._x*e._x+t._y*e._y+t._z*e._z+t._w*e._w},n.equals=function(t,e){return k.equals(t._x,e._x)&&k.equals(t._y,e._y)&&k.equals(t._z,e._z)&&k.equals(t._w,e._w)},n.rotationAxisAngle=function(t,e,r){var a=n._tempVector3;R.normalize(t,a),e*=.5;var o=Math.sin(e);r._x=a._x*o,r._y=a._y*o,r._z=a._z*o,r._w=Math.cos(e),r._onValueChanged&&r._onValueChanged()},n.rotationEuler=function(t,e,r,a){n.rotationYawPitchRoll(e,t,r,a)},n.rotationYawPitchRoll=function(t,e,r,a){var o=r*.5,c=e*.5,l=t*.5,_=Math.sin(o),u=Math.cos(o),h=Math.sin(c),d=Math.cos(c),f=Math.sin(l),v=Math.cos(l),p=v*d,g=f*h;a._x=v*h*u+f*d*_,a._y=f*d*u-v*h*_,a._z=p*_-g*u,a._w=p*u+g*_,a._onValueChanged&&a._onValueChanged()},n.rotationMatrix3x3=function(t,e){var r=t.elements,a=r[0],o=r[1],c=r[2],l=r[3],_=r[4],u=r[5],h=r[6],d=r[7],f=r[8],v=a+_+f,p,g;v>0?(p=Math.sqrt(v+1),e._w=p*.5,p=.5/p,e._x=(u-d)*p,e._y=(h-c)*p,e._z=(o-l)*p):a>=_&&a>=f?(p=Math.sqrt(1+a-_-f),g=.5/p,e._x=.5*p,e._y=(o+l)*g,e._z=(c+h)*g,e._w=(u-d)*g):_>f?(p=Math.sqrt(1+_-a-f),g=.5/p,e._x=(l+o)*g,e._y=.5*p,e._z=(d+u)*g,e._w=(h-c)*g):(p=Math.sqrt(1+f-a-_),g=.5/p,e._x=(c+h)*g,e._y=(u+d)*g,e._z=.5*p,e._w=(o-l)*g),e._onValueChanged&&e._onValueChanged()},n.invert=function(t,e){var r=t._x,a=t._y,o=t._z,c=t._w,l=r*r+a*a+o*o+c*c;if(l>k.zeroTolerance){var _=1/l;e._x=-r*_,e._y=-a*_,e._z=-o*_,e._w=c*_,e._onValueChanged&&e._onValueChanged()}},n.lerp=function(t,e,r,a){var o=1-r;n.dot(t,e)>=0?(a._x=t._x*o+e._x*r,a._y=t._y*o+e._y*r,a._z=t._z*o+e._z*r,a._w=t._w*o+e._w*r):(a._x=t._x*o-e._x*r,a._y=t._y*o-e._y*r,a._z=t._z*o-e._z*r,a._w=t._w*o-e._w*r),a.normalize()},n.slerp=function(t,e,r,a){var o,c,l=n.dot(t,e);if(Math.abs(l)>1-k.zeroTolerance)c=1-r,o=r*Math.sign(l);else{var _=Math.acos(Math.abs(l)),u=1/Math.sin(_);c=Math.sin((1-r)*_)*u,o=Math.sin(r*_)*u*Math.sign(l)}a.x=c*t.x+o*e.x,a.y=c*t.y+o*e.y,a.z=c*t.z+o*e.z,a.w=c*t.w+o*e.w,a._onValueChanged&&a._onValueChanged()},n.normalize=function(t,e){var r=t._x,a=t._y,o=t._z,c=t._w,l=Math.sqrt(r*r+a*a+o*o+c*c);l>k.zeroTolerance&&(l=1/l,e._x=r*l,e._y=a*l,e._z=o*l,e._w=c*l,e._onValueChanged&&e._onValueChanged())},n.rotationX=function(t,e){t*=.5;var r=Math.sin(t),a=Math.cos(t);e._x=r,e._y=0,e._z=0,e._w=a,e._onValueChanged&&e._onValueChanged()},n.rotationY=function(t,e){t*=.5;var r=Math.sin(t),a=Math.cos(t);e._x=0,e._y=r,e._z=0,e._w=a,e._onValueChanged&&e._onValueChanged()},n.rotationZ=function(t,e){t*=.5;var r=Math.sin(t),a=Math.cos(t);e._x=0,e._y=0,e._z=r,e._w=a,e._onValueChanged&&e._onValueChanged()},n.rotateX=function(t,e,r){var a=t._x,o=t._y,c=t._z,l=t._w;e*=.5;var _=Math.sin(e),u=Math.cos(e);r._x=a*u+l*_,r._y=o*u+c*_,r._z=c*u-o*_,r._w=l*u-a*_,r._onValueChanged&&r._onValueChanged()},n.rotateY=function(t,e,r){var a=t._x,o=t._y,c=t._z,l=t._w;e*=.5;var _=Math.sin(e),u=Math.cos(e);r._x=a*u-c*_,r._y=o*u+l*_,r._z=c*u+a*_,r._w=l*u-o*_,r._onValueChanged&&r._onValueChanged()},n.rotateZ=function(t,e,r){var a=t._x,o=t._y,c=t._z,l=t._w;e*=.5;var _=Math.sin(e),u=Math.cos(e);r._x=a*u+o*_,r._y=o*u-a*_,r._z=c*u+l*_,r._w=l*u-c*_,r._onValueChanged&&r._onValueChanged()},n.scale=function(t,e,r){r._x=t._x*e,r._y=t._y*e,r._z=t._z*e,r._w=t._w*e,r._onValueChanged&&r._onValueChanged()},pa(n,[{key:"x",get:function(){return this._x},set:function(t){this._x=t,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(t){this._y=t,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(t){this._z=t,this._onValueChanged&&this._onValueChanged()}},{key:"normalized",get:function(){return Math.abs(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w-1)k.zeroTolerance){var a=Math.sqrt(r+1)*2;t._w=.25*a,t._x=(e[6]-e[9])/a,t._y=(e[8]-e[2])/a,t._z=(e[1]-e[4])/a}else if(e[0]>e[5]&&e[0]>e[10]){var o=Math.sqrt(1+e[0]-e[5]-e[10])*2;t._w=(e[6]-e[9])/o,t._x=.25*o,t._y=(e[1]+e[4])/o,t._z=(e[8]+e[2])/o}else if(e[5]>e[10]){var c=Math.sqrt(1+e[5]-e[0]-e[10])*2;t._w=(e[8]-e[2])/c,t._x=(e[1]+e[4])/c,t._y=.25*c,t._z=(e[6]+e[9])/c}else{var l=Math.sqrt(1+e[10]-e[0]-e[5])*2;t._w=(e[1]-e[4])/l,t._x=(e[8]+e[2])/l,t._y=(e[6]+e[9])/l,t._z=.25*l}return t._onValueChanged&&t._onValueChanged(),t},s.getScaling=function(t){var e=this.elements,r=e[0],a=e[1],o=e[2],c=e[4],l=e[5],_=e[6],u=e[8],h=e[9],d=e[10];return t.set(Math.sqrt(r*r+a*a+o*o),Math.sqrt(c*c+l*l+_*_),Math.sqrt(u*u+h*h+d*d)),t},s.getTranslation=function(t){var e=this.elements;return t.set(e[12],e[13],e[14]),t},s.identity=function(){var t=this.elements;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},s.invert=function(){return n.invert(this,this),this},s.rotateAxisAngle=function(t,e){return n.rotateAxisAngle(this,t,e,this),this},s.scale=function(t){return n.scale(this,t,this),this},s.translate=function(t){return n.translate(this,t,this),this},s.transpose=function(){return n.transpose(this,this),this},s.clone=function(){var t=this.elements,e=new n(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15]);return e},s.copyFrom=function(t){var e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],this},s.copyFromArray=function(t,e){e===void 0&&(e=0);for(var r=this.elements,a=0;a<16;a++)r[a]=t[a+e];return this},s.copyToArray=function(t,e){e===void 0&&(e=0);var r=this.elements;t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t[e+9]=r[9],t[e+10]=r[10],t[e+11]=r[11],t[e+12]=r[12],t[e+13]=r[13],t[e+14]=r[14],t[e+15]=r[15]},n.multiply=function(t,e,r){var a=t.elements,o=e.elements,c=r.elements,l=a[0],_=a[1],u=a[2],h=a[3],d=a[4],f=a[5],v=a[6],p=a[7],g=a[8],y=a[9],m=a[10],x=a[11],C=a[12],b=a[13],A=a[14],S=a[15],w=o[0],E=o[1],P=o[2],M=o[3],D=o[4],L=o[5],V=o[6],N=o[7],I=o[8],B=o[9],z=o[10],U=o[11],Y=o[12],Q=o[13],H=o[14],te=o[15];c[0]=l*w+d*E+g*P+C*M,c[1]=_*w+f*E+y*P+b*M,c[2]=u*w+v*E+m*P+A*M,c[3]=h*w+p*E+x*P+S*M,c[4]=l*D+d*L+g*V+C*N,c[5]=_*D+f*L+y*V+b*N,c[6]=u*D+v*L+m*V+A*N,c[7]=h*D+p*L+x*V+S*N,c[8]=l*I+d*B+g*z+C*U,c[9]=_*I+f*B+y*z+b*U,c[10]=u*I+v*B+m*z+A*U,c[11]=h*I+p*B+x*z+S*U,c[12]=l*Y+d*Q+g*H+C*te,c[13]=_*Y+f*Q+y*H+b*te,c[14]=u*Y+v*Q+m*H+A*te,c[15]=h*Y+p*Q+x*H+S*te},n.equals=function(t,e){var r=t.elements,a=e.elements;return k.equals(r[0],a[0])&&k.equals(r[1],a[1])&&k.equals(r[2],a[2])&&k.equals(r[3],a[3])&&k.equals(r[4],a[4])&&k.equals(r[5],a[5])&&k.equals(r[6],a[6])&&k.equals(r[7],a[7])&&k.equals(r[8],a[8])&&k.equals(r[9],a[9])&&k.equals(r[10],a[10])&&k.equals(r[11],a[11])&&k.equals(r[12],a[12])&&k.equals(r[13],a[13])&&k.equals(r[14],a[14])&&k.equals(r[15],a[15])},n.lerp=function(t,e,r,a){var o=t.elements,c=e.elements,l=a.elements,_=1-r;l[0]=o[0]*_+c[0]*r,l[1]=o[1]*_+c[1]*r,l[2]=o[2]*_+c[2]*r,l[3]=o[3]*_+c[3]*r,l[4]=o[4]*_+c[4]*r,l[5]=o[5]*_+c[5]*r,l[6]=o[6]*_+c[6]*r,l[7]=o[7]*_+c[7]*r,l[8]=o[8]*_+c[8]*r,l[9]=o[9]*_+c[9]*r,l[10]=o[10]*_+c[10]*r,l[11]=o[11]*_+c[11]*r,l[12]=o[12]*_+c[12]*r,l[13]=o[13]*_+c[13]*r,l[14]=o[14]*_+c[14]*r,l[15]=o[15]*_+c[15]*r},n.add=function(t,e,r){var a=t.elements,o=e.elements,c=r.elements;c[0]=a[0]+o[0],c[1]=a[1]+o[1],c[2]=a[2]+o[2],c[3]=a[3]+o[3],c[4]=a[4]+o[4],c[5]=a[5]+o[5],c[6]=a[6]+o[6],c[7]=a[7]+o[7],c[8]=a[8]+o[8],c[9]=a[9]+o[9],c[10]=a[10]+o[10],c[11]=a[11]+o[11],c[12]=a[12]+o[12],c[13]=a[13]+o[13],c[14]=a[14]+o[14],c[15]=a[15]+o[15]},n.multiplyScalar=function(t,e,r){var a=t.elements,o=r.elements;o[0]=a[0]*e,o[1]=a[1]*e,o[2]=a[2]*e,o[3]=a[3]*e,o[4]=a[4]*e,o[5]=a[5]*e,o[6]=a[6]*e,o[7]=a[7]*e,o[8]=a[8]*e,o[9]=a[9]*e,o[10]=a[10]*e,o[11]=a[11]*e,o[12]=a[12]*e,o[13]=a[13]*e,o[14]=a[14]*e,o[15]=a[15]*e},n.rotationQuaternion=function(t,e){var r=e.elements,a=t._x,o=t._y,c=t._z,l=t._w,_=a+a,u=o+o,h=c+c,d=a*_,f=o*_,v=o*u,p=c*_,g=c*u,y=c*h,m=l*_,x=l*u,C=l*h;r[0]=1-v-y,r[1]=f+C,r[2]=p-x,r[3]=0,r[4]=f-C,r[5]=1-d-y,r[6]=g+m,r[7]=0,r[8]=p+x,r[9]=g-m,r[10]=1-d-v,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1},n.rotationAxisAngle=function(t,e,r){var a=r.elements,o=t._x,c=t._y,l=t._z,_=Math.sqrt(o*o+c*c+l*l),u,h,d;Math.abs(_)k.zeroTolerance&&(o=1/o,e._x=r*o,e._y=a*o,e._onValueChanged&&e._onValueChanged())},n.scale=function(t,e,r){r._x=t._x*e,r._y=t._y*e,r._onValueChanged&&r._onValueChanged()},pa(n,[{key:"x",get:function(){return this._x},set:function(t){this._x=t,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(t){this._y=t,this._onValueChanged&&this._onValueChanged()}}]),n}();(function(){ee._zero=new ee(0,0)})();(function(){ee._one=new ee(1,1)})();var ie=function(){function n(i,t,e,r){i===void 0&&(i=0),t===void 0&&(t=0),e===void 0&&(e=0),r===void 0&&(r=0),this._onValueChanged=null,this._x=i,this._y=t,this._z=e,this._w=r}var s=n.prototype;return s.set=function(t,e,r,a){return this._x=t,this._y=e,this._z=r,this._w=a,this._onValueChanged&&this._onValueChanged(),this},s.add=function(t){return this._x+=t._x,this._y+=t._y,this._z+=t._z,this._w+=t._w,this._onValueChanged&&this._onValueChanged(),this},s.subtract=function(t){return this._x-=t._x,this._y-=t._y,this._z-=t._z,this._w-=t._w,this._onValueChanged&&this._onValueChanged(),this},s.multiply=function(t){return this._x*=t._x,this._y*=t._y,this._z*=t._z,this._w*=t._w,this._onValueChanged&&this._onValueChanged(),this},s.divide=function(t){return this._x/=t._x,this._y/=t._y,this._z/=t._z,this._w/=t._w,this._onValueChanged&&this._onValueChanged(),this},s.length=function(){var t=this,e=t._x,r=t._y,a=t._z,o=t._w;return Math.sqrt(e*e+r*r+a*a+o*o)},s.lengthSquared=function(){var t=this,e=t._x,r=t._y,a=t._z,o=t._w;return e*e+r*r+a*a+o*o},s.negate=function(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._w=-this._w,this._onValueChanged&&this._onValueChanged(),this},s.normalize=function(){return n.normalize(this,this),this},s.scale=function(t){return this._x*=t,this._y*=t,this._z*=t,this._w*=t,this._onValueChanged&&this._onValueChanged(),this},s.clone=function(){var t=new n(this._x,this._y,this._z,this._w);return t},s.copyFrom=function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onValueChanged&&this._onValueChanged(),this},s.copyFromArray=function(t,e){return e===void 0&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onValueChanged&&this._onValueChanged(),this},s.copyToArray=function(t,e){e===void 0&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w},s.toJSON=function(){return{x:this._x,y:this._y,z:this._z,w:this._w}},n.add=function(t,e,r){r._x=t._x+e._x,r._y=t._y+e._y,r._z=t._z+e._z,r._w=t._w+e._w,r._onValueChanged&&r._onValueChanged()},n.subtract=function(t,e,r){r._x=t._x-e._x,r._y=t._y-e._y,r._z=t._z-e._z,r._w=t._w-e._w,r._onValueChanged&&r._onValueChanged()},n.multiply=function(t,e,r){r._x=t._x*e._x,r._y=t._y*e._y,r._z=t._z*e._z,r._w=t._w*e._w,r._onValueChanged&&r._onValueChanged()},n.divide=function(t,e,r){r._x=t._x/e._x,r._y=t._y/e._y,r._z=t._z/e._z,r._w=t._w/e._w,r._onValueChanged&&r._onValueChanged()},n.dot=function(t,e){return t._x*e._x+t._y*e._y+t._z*e._z+t._w*e._w},n.distance=function(t,e){var r=e._x-t._x,a=e._y-t._y,o=e._z-t._z,c=e._w-t._w;return Math.sqrt(r*r+a*a+o*o+c*c)},n.distanceSquared=function(t,e){var r=e._x-t._x,a=e._y-t._y,o=e._z-t._z,c=e._w-t._w;return r*r+a*a+o*o+c*c},n.equals=function(t,e){return k.equals(t._x,e._x)&&k.equals(t._y,e._y)&&k.equals(t._z,e._z)&&k.equals(t._w,e._w)},n.lerp=function(t,e,r,a){var o=t._x,c=t._y,l=t._z,_=t._w;a._x=o+(e._x-o)*r,a._y=c+(e._y-c)*r,a._z=l+(e._z-l)*r,a._w=_+(e._w-_)*r,a._onValueChanged&&a._onValueChanged()},n.max=function(t,e,r){r._x=Math.max(t._x,e._x),r._y=Math.max(t._y,e._y),r._z=Math.max(t._z,e._z),r._w=Math.max(t._w,e._w),r._onValueChanged&&r._onValueChanged()},n.min=function(t,e,r){r._x=Math.min(t._x,e._x),r._y=Math.min(t._y,e._y),r._z=Math.min(t._z,e._z),r._w=Math.min(t._w,e._w),r._onValueChanged&&r._onValueChanged()},n.negate=function(t,e){e._x=-t._x,e._y=-t._y,e._z=-t._z,e._w=-t._w,e._onValueChanged&&e._onValueChanged()},n.normalize=function(t,e){var r=t._x,a=t._y,o=t._z,c=t._w,l=Math.sqrt(r*r+a*a+o*o+c*c);l>k.zeroTolerance&&(l=1/l,e._x=r*l,e._y=a*l,e._z=o*l,e._w=c*l,e._onValueChanged&&e._onValueChanged())},n.scale=function(t,e,r){r._x=t._x*e,r._y=t._y*e,r._z=t._z*e,r._w=t._w*e,r._onValueChanged&&r._onValueChanged()},n.transform=function(t,e,r){var a=t._x,o=t._y,c=t._z,l=t._w,_=e.elements;r._x=a*_[0]+o*_[4]+c*_[8]+l*_[12],r._y=a*_[1]+o*_[5]+c*_[9]+l*_[13],r._z=a*_[2]+o*_[6]+c*_[10]+l*_[14],r._w=a*_[3]+o*_[7]+c*_[11]+l*_[15],r._onValueChanged&&r._onValueChanged()},n.transformByQuat=function(t,e,r){var a=t._x,o=t._y,c=t._z,l=t._w,_=e._x,u=e._y,h=e._z,d=e._w,f=d*a+u*c-h*o,v=d*o+h*a-_*c,p=d*c+_*o-u*a,g=-_*a-u*o-h*c;r._x=f*d-g*_-v*h+p*u,r._y=v*d-g*u-p*_+f*h,r._z=p*d-g*h-f*u+v*_,r._w=l,r._onValueChanged&&r._onValueChanged()},pa(n,[{key:"x",get:function(){return this._x},set:function(t){this._x=t,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(t){this._y=t,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(t){this._z=t,this._onValueChanged&&this._onValueChanged()}},{key:"w",get:function(){return this._w},set:function(t){this._w=t,this._onValueChanged&&this._onValueChanged()}}]),n}();(function(){ie._zero=new ie(0,0,0,0)})();(function(){ie._one=new ie(1,1,1,1)})();var q=function(){function n(i,t,e,r){i===void 0&&(i=1),t===void 0&&(t=1),e===void 0&&(e=1),r===void 0&&(r=1),this._onValueChanged=null,this._r=i,this._g=t,this._b=e,this._a=r}var s=n.prototype;return s.set=function(t,e,r,a){return this._r=t,this._g=e,this._b=r,this._a=a,this._onValueChanged&&this._onValueChanged(),this},s.add=function(t){return this._r+=t._r,this._g+=t._g,this._b+=t._b,this._a+=t._a,this._onValueChanged&&this._onValueChanged(),this},s.scale=function(t){return this._r*=t,this._g*=t,this._b*=t,this._a*=t,this._onValueChanged&&this._onValueChanged(),this},s.clone=function(){var t=new n(this._r,this._g,this._b,this._a);return t},s.copyFrom=function(t){return this._r=t.r,this._g=t.g,this._b=t.b,this._a=t.a,this._onValueChanged&&this._onValueChanged(),this},s.copyFromArray=function(t,e){return e===void 0&&(e=0),this._r=t[e],this._g=t[e+1],this._b=t[e+2],this._a=t[e+3],this._onValueChanged&&this._onValueChanged(),this},s.copyToArray=function(t,e){e===void 0&&(e=0),t[e]=this._r,t[e+1]=this._g,t[e+2]=this._b,t[e+3]=this._a},s.toLinear=function(t){return t._r=n.gammaToLinearSpace(this._r),t._g=n.gammaToLinearSpace(this._g),t._b=n.gammaToLinearSpace(this._b),this._onValueChanged&&this._onValueChanged(),t},s.toGamma=function(t){return t._r=n.linearToGammaSpace(this._r),t._g=n.linearToGammaSpace(this._g),t._b=n.linearToGammaSpace(this._b),this._onValueChanged&&this._onValueChanged(),t},s.getBrightness=function(){var t=this.r,e=this.g,r=this.b,a=t,o=t;return e>a&&(a=e),r>a&&(a=r),e>>17,t^=e^e>>>26,this._state1=t,this._state0+this._state1>>>0},s.random=function(){return this.randomInt32()/4294967295},s.reset=function(t,e){this._state0=t>>>0,this._state1=e>>>0},n}(),Nt;(function(n){n[n.Android=0]="Android",n[n.IPhone=1]="IPhone",n[n.IPad=2]="IPad",n[n.Mac=3]="Mac",n[n.Unknown=4]="Unknown"})(Nt||(Nt={}));function ce(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function jo(n,s){for(var i=0;i=0;o--)(a=n[o])&&(r=(e<3?a(r):e>3?a(s,i,r):a(s,i))||r);return e>3&&r&&Object.defineProperty(s,i,r),r}function lt(n,s){return s!=null&&typeof Symbol<"u"&&s[Symbol.hasInstance]?!!s[Symbol.hasInstance](n):n instanceof s}var on;(function(n){n[n.Ignore=0]="Ignore",n[n.Assignment=1]="Assignment",n[n.Shallow=2]="Shallow",n[n.Deep=3]="Deep"})(on||(on={}));function F(n,s){Ar.registerCloneMode(n,s,on.Ignore)}function Me(n,s){Ar.registerCloneMode(n,s,on.Assignment)}function Eo(n,s){Ar.registerCloneMode(n,s,on.Shallow)}function J(n,s){Ar.registerCloneMode(n,s,on.Deep)}var Ar=function(){function n(){}return n.registerCloneMode=function(i,t,e){var r=n._subCloneModeMap.get(i.constructor);r||(r=Object.create(null),n._subCloneModeMap.set(i.constructor,r)),r[t]=e},n.getCloneMode=function(i){var t=n._cloneModeMap.get(i);if(!t){t=Object.create(null),n._cloneModeMap.set(i,t);for(var e=n._objectType,r=n._subCloneModeMap;i!==e;){var a=r.get(i);a&&Object.assign(t,a),i=Object.getPrototypeOf(i)}}return t},n.cloneProperty=function(i,t,e,r,a,o,c){if(r!==on.Ignore){var l=i[e];if(lt(l,Object)){if(r===void 0||r===on.Assignment){t[e]=l;return}var _=l.constructor;switch(_){case Uint8Array:case Uint16Array:case Uint32Array:case Int8Array:case Int16Array:case Int32Array:case Float32Array:case Float64Array:var u=t[e];u==null||u.length!==l.length?t[e]=l.slice():u.set(l);break;case Array:var h=t[e],d=l.length;h==null?t[e]=h=new Array(d):h.length=d;for(var f=0;f0)return!1}else return!1}return n.prototype.destroy.call(this),!0},i._associationSuperResource=function(e){(this._superResources||(this._superResources=[])).push(e)},i._disassociationSuperResource=function(e){var r=this._superResources,a=r.indexOf(e);r.splice(a,1)},i._getReferCount=function(){return this._refCount},i._addReferCount=function(e){this._refCount+=e},i._addToResourceManager=function(e){this._engine.resourceManager._addAsset(e,this)},i._onDestroy=function(){n.prototype._onDestroy.call(this),this._engine.resourceManager._deleteReferResource(this);var e=this._getReferCount();e>0&&this._addReferCount(-e)},j(s,[{key:"refCount",get:function(){return this._refCount}}]),s}(Yr),bc=function(n){W(s,n);function s(t){var e;return e=n.call(this,t)||this,e._sprites=new Array,e._spriteNamesToIndex={},e}var i=s.prototype;return i.getSprite=function(e){var r=this._sprites[this._spriteNamesToIndex[e]];return r||console.warn("There is no sprite named "+e+" in the atlas."),r},i.getSprites=function(e,r){r.length=0;var a=this._spriteNamesToIndex[e];if(a!==void 0)for(var o=this._sprites;a>=0;a--){var c=o[a];c.name===e&&r.push(c)}else console.warn("The name of the sprite you want to find is not exit in SpriteAtlas.");return r},i._addSprite=function(e){this._spriteNamesToIndex[e.name]=this._sprites.push(e)-1,e._atlas=this,e.isGCIgnored=!0},i._onDestroy=function(){n.prototype._onDestroy.call(this);for(var e=this,r=e._sprites,a=0,o=r.length;a>1,o=i[t],c=i[e-1],l=i[a],_=r(o,c);if(_>0){var u=o;o=c,c=u}var h=r(o,l);if(h>=0){var d=o;o=l,l=c,c=d}else{var f=r(c,l);if(f>0){var v=c;c=l,l=v}}i[t]=o,i[e-1]=l;var p=c,g=t+1,y=e-1;i[a]=i[g],i[g]=p;e:for(var m=g+1;m0){do{if(y--,y==m)break e;var b=i[y];C=r(b,p)}while(C>0);i[m]=i[y],i[y]=x,C<0&&(x=i[m],i[m]=i[g],i[g]=x,g++)}}e-y=t;o--){var l=i[o],_=r(l,c);if(_>0)i[o+1]=l;else break}i[o+1]=c}},n}(),cl=46,ll=/\\(\\)?/g,_l=RegExp(`[^.[\\]]+|\\[(?:([^"'][^[]*)|(["'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))`,"g"),Er=function(){function n(){this._updateFlags=[],this._listeners=[]}var s=n.prototype;return s.createFlag=function(t){var e=new t;return this.addFlag(e),e},s.addFlag=function(t){this._updateFlags.push(t),t._flagManagers.push(this)},s.removeFlag=function(t){var e=Ue.removeFromArray(this._updateFlags,t);e&&Ue.removeFromArray(t._flagManagers,this)},s.addListener=function(t){this._listeners.push(t)},s.removeListener=function(t){Ue.removeFromArray(this._listeners,t)},s.dispatch=function(t,e){for(var r=this._updateFlags,a=r.length-1;a>=0;a--)r[a].dispatch(t,e);for(var o=this._listeners,c=o.length-1;c>=0;c--)o[c](t,e)},n}(),we;(function(n){n[n.texture=1]="texture",n[n.size=2]="size",n[n.atlasRotate=4]="atlasRotate",n[n.atlasRegion=8]="atlasRegion",n[n.atlasRegionOffset=16]="atlasRegionOffset",n[n.region=32]="region",n[n.pivot=64]="pivot",n[n.border=128]="border",n[n.destroy=256]="destroy"})(we||(we={}));var vi=function(n){W(s,n);function s(t,e,r,a,o,c){e===void 0&&(e=null),r===void 0&&(r=null),a===void 0&&(a=null),o===void 0&&(o=null),c===void 0&&(c=null);var l;return l=n.call(this,t)||this,l._automaticWidth=0,l._automaticHeight=0,l._customWidth=void 0,l._customHeight=void 0,l._positions=[new ee,new ee,new ee,new ee],l._uvs=[new ee,new ee,new ee,new ee],l._bounds=new lr,l._texture=null,l._atlasRotated=!1,l._atlasRegion=new Gr(0,0,1,1),l._atlasRegionOffset=new ie(0,0,0,0),l._region=new Gr(0,0,1,1),l._pivot=new ee(.5,.5),l._border=new ie(0,0,0,0),l._dirtyUpdateFlag=7,l._updateFlagManager=new Er,l._texture=e,l._onRegionChange=l._onRegionChange.bind(ce(l)),l._onPivotChange=l._onPivotChange.bind(ce(l)),l._onBorderChange=l._onBorderChange.bind(ce(l)),l._region._onValueChanged=l._onRegionChange,l._pivot._onValueChanged=l._onPivotChange,l._border._onValueChanged=l._onBorderChange,r&&l._region.copyFrom(r),a&&l._pivot.copyFrom(a),o&&l._border.copyFrom(o),l.name=c,l}var i=s.prototype;return i.clone=function(){var e=new s(this._engine,this._texture,this._region,this._pivot,this._border,this.name);return e._atlasRotated=this._atlasRotated,e._atlasRegion.copyFrom(this._atlasRegion),e._atlasRegionOffset.copyFrom(this._atlasRegionOffset),e},i._getPositions=function(){return this._dirtyUpdateFlag&1&&this._updatePositions(),this._positions},i._getUVs=function(){return this._dirtyUpdateFlag&2&&this._updateUVs(),this._uvs},i._getBounds=function(){return this._dirtyUpdateFlag&1&&this._updatePositions(),this._bounds},i._addReferCount=function(e){var r;n.prototype._addReferCount.call(this,e),(r=this._atlas)==null||r._addReferCount(e)},i._onDestroy=function(){this._dispatchSpriteChange(we.destroy),n.prototype._onDestroy.call(this),this._positions.length=0,this._positions=null,this._uvs.length=0,this._uvs=null,this._atlasRegion=null,this._atlasRegionOffset=null,this._region=null,this._pivot=null,this._border=null,this._bounds=null,this._atlas=null,this._texture=null,this._updateFlagManager=null},i._calDefaultSize=function(){if(this._texture){var e=this,r=e._texture,a=e._atlasRegion,o=e._atlasRegionOffset,c=e._region,l=1/hn._pixelsPerUnit;this._automaticWidth=r.width*a.width/(1-o.x-o.z)*c.width*l,this._automaticHeight=r.height*a.height/(1-o.y-o.w)*c.height*l}else this._automaticWidth=this._automaticHeight=0;this._dirtyUpdateFlag&=-5},i._updatePositions=function(){var e=this._atlasRegionOffset,r=this._region,a=r.x,o=r.y,c=r.width,l=r.height,_=1-a-c,u=1-o-l,h=Math.max(e.x-a,0)/c,d=Math.max(e.w-o,0)/l,f=1-Math.max(e.z-_,0)/c,v=1-Math.max(e.y-u,0)/l,p=this._positions;p[0].set(h,d),p[1].set(f,d),p[2].set(h,v),p[3].set(f,v);var g=this._bounds,y=g.min,m=g.max;y.set(h,d,0),m.set(f,v,0),this._dirtyUpdateFlag&=-2},i._updateUVs=function(){var e=this,r=e._uvs,a=e._atlasRegionOffset,o=this._region,c=o.x,l=o.y,_=o.width,u=o.height,h=1-c-_,d=1-l-u,f=this._atlasRegion,v=f.x,p=f.y,g=f.width,y=f.height,m=a.x,x=a.y,C=a.z,b=a.w,A=g/(1-m-C),S=y/(1-x-b),w=Math.max(c-m,0)*A+v,E=Math.max(d-x,0)*S+p,P=g+v-Math.max(h-C,0)*A,M=y+p-Math.max(l-b,0)*S,D=this._border,L=D.x,V=D.y,N=D.z,I=D.w;r[0].set(w,M),r[1].set((c-m+L*_)*A+v,y+p-(l-b+V*u)*S),r[2].set(g+v-(h-C+N*_)*A,(d-x+I*u)*S+p),r[3].set(P,E),this._dirtyUpdateFlag&=-3},i._dispatchSpriteChange=function(e){switch(e){case we.texture:this._dirtyUpdateFlag|=4;break;case we.atlasRegionOffset:case we.region:this._dirtyUpdateFlag|=7;break;case we.atlasRegion:this._dirtyUpdateFlag|=6;break;case we.border:this._dirtyUpdateFlag|=2;break}this._updateFlagManager.dispatch(e)},i._onRegionChange=function(){var e=this,r=e._region;r._onValueChanged=null;var a=k.clamp(r.x,0,1),o=k.clamp(r.y,0,1);r.set(a,o,k.clamp(r.width,0,1-a),k.clamp(r.height,0,1-o)),this._dispatchSpriteChange(we.region),(this._customWidth===void 0||this._customHeight===void 0)&&this._dispatchSpriteChange(we.size),r._onValueChanged=this._onRegionChange},i._onPivotChange=function(){this._dispatchSpriteChange(we.pivot)},i._onBorderChange=function(){var e=this,r=e._border;r._onValueChanged=null;var a=k.clamp(r.x,0,1),o=k.clamp(r.y,0,1);r.set(a,o,k.clamp(r.z,0,1-a),k.clamp(r.w,0,1-o)),this._dispatchSpriteChange(we.border),r._onValueChanged=this._onBorderChange},j(s,[{key:"texture",get:function(){return this._texture},set:function(e){this._texture!==e&&(this._texture=e,this._dispatchSpriteChange(we.texture),(this._customWidth===void 0||this._customHeight===void 0)&&this._dispatchSpriteChange(we.size))}},{key:"width",get:function(){return this._customWidth!==void 0?this._customWidth:(this._dirtyUpdateFlag&4&&this._calDefaultSize(),this._automaticWidth)},set:function(e){this._customWidth!==e&&(this._customWidth=e,this._dispatchSpriteChange(we.size))}},{key:"height",get:function(){return this._customHeight!==void 0?this._customHeight:(this._dirtyUpdateFlag&4&&this._calDefaultSize(),this._automaticHeight)},set:function(e){this._customHeight!==e&&(this._customHeight=e,this._dispatchSpriteChange(we.size))}},{key:"atlasRotated",get:function(){return this._atlasRotated},set:function(e){this._atlasRotated!=e&&(this._atlasRotated=e)}},{key:"atlasRegion",get:function(){return this._atlasRegion},set:function(e){var r=k.clamp(e.x,0,1),a=k.clamp(e.y,0,1);this._atlasRegion.set(r,a,k.clamp(e.width,0,1-r),k.clamp(e.height,0,1-a)),this._dispatchSpriteChange(we.atlasRegion),(this._customWidth===void 0||this._customHeight===void 0)&&this._dispatchSpriteChange(we.size)}},{key:"atlasRegionOffset",get:function(){return this._atlasRegionOffset},set:function(e){var r=k.clamp(e.x,0,1),a=k.clamp(e.y,0,1);this._atlasRegionOffset.set(r,a,k.clamp(e.z,0,1-r),k.clamp(e.w,0,1-a)),this._dispatchSpriteChange(we.atlasRegionOffset),(this._customWidth===void 0||this._customHeight===void 0)&&this._dispatchSpriteChange(we.size)}},{key:"region",get:function(){return this._region},set:function(e){this._region!==e&&this._region.copyFrom(e)}},{key:"pivot",get:function(){return this._pivot},set:function(e){this._pivot!==e&&this._pivot.copyFrom(e)}},{key:"border",get:function(){return this._border},set:function(e){this._border!==e&&this._border.copyFrom(e)}}]),s}(Qr),qo;(function(n){n[n.positions=1]="positions",n[n.uvs=2]="uvs",n[n.automaticSize=4]="automaticSize",n[n.all=7]="all"})(qo||(qo={}));var wo=function(){function n(){this._events=Object.create(null),this._eventCount=0}var s=n.prototype;return s.hasEvent=function(t){return this._events[t]!=null},s.eventNames=function(){return this._eventCount===0?[]:Object.keys(this._events)},s.listenerCount=function(t){var e=this._events[t];return e?Array.isArray(e)?e.length:1:0},s.dispatch=function(t,e){if(!this._events[t])return!1;var r=this._events[t];if(Array.isArray(r)){var a=r.length,o=n._dispatchingListenersPool,c=o.length>0?o.pop():[];c.length=a;for(var l=0;l=0;o--)r[o].fn===e&&(r[o].destroyed=!0,r.splice(o,1));r.length===0?this._clearEvent(t):r.length===1&&(this._events[t]=r[0])}return this},s.removeEventListener=function(t,e){return this.off(t,e)},s.removeAllEventListeners=function(t){t?this._events[t]&&this._clearEvent(t):(this._events=Object.create(null),this._eventCount=0)},s._addEventListener=function(t,e,r){var a={fn:e,once:r},o=this._events,c=o[t];return c?Array.isArray(c)?c.push(a):o[t]=[c,a]:(o[t]=a,this._eventCount++),this},s._clearEvent=function(t){--this._eventCount===0?this._events=Object.create(null):delete this._events[t]},n}();(function(){wo._dispatchingListenersPool=[]})();var gn=function(n){for(var s=arguments.length,i=new Array(s>1?s-1:0),t=1;ta)){var o=r[e]&~t._maskValue;e==a&&o===0?this._length--:r[e]=o}},s.unionCollection=function(t){var e=t._mask,r=t._length,a=this._mask,o=this._length;if(o=0;o--){var c=r[o]&~e[o];o==a&&c===0?(a--,this._length--):r[o]=c}},s.intersectionCollection=function(t){for(var e=t._mask,r=this._mask,a=this._length-1;a>=0;a--){var o=r[a]&e[a];o==0&&a==this._length-1?this._length--:r[a]=o}},s.isEnable=function(t){var e=t._maskIndex;return e>=this._length?!1:(this._mask[e]&t._maskValue)!==0},s.clear=function(){this._length=0},n.unionCollection=function(t,e,r){var a=r._mask,o,c,l,_;t._length #include #include #include -`,Hl=`#define GLSLIFY 1 -vec2 cellular(vec2 P){vec2 Pi=mod289(floor(P));vec2 Pf=fract(P);vec3 oi=vec3(-1.0,0.0,1.0);vec3 of=vec3(-0.5,0.5,1.5);vec3 px=permute(Pi.x+oi);vec3 p=permute(px.x+Pi.y+oi);vec3 ox=fract(p*K)-Ko;vec3 oy=mod7(floor(p*K))*K-Ko;vec3 dx=Pf.x+0.5+jitter*ox;vec3 dy=Pf.y-of+jitter*oy;vec3 d1=dx*dx+dy*dy;p=permute(px.y+Pi.y+oi);ox=fract(p*K)-Ko;oy=mod7(floor(p*K))*K-Ko;dx=Pf.x-0.5+jitter*ox;dy=Pf.y-of+jitter*oy;vec3 d2=dx*dx+dy*dy;p=permute(px.z+Pi.y+oi);ox=fract(p*K)-Ko;oy=mod7(floor(p*K))*K-Ko;dx=Pf.x-1.5+jitter*ox;dy=Pf.y-of+jitter*oy;vec3 d3=dx*dx+dy*dy;vec3 d1a=min(d1,d2);d2=max(d1,d2);d2=min(d2,d3);d1=min(d1a,d2);d2=max(d1a,d2);d1.xy=(d1.x #include #include -`,Ql=`#define GLSLIFY 1 -float perlin(vec2 P){vec4 Pi=floor(P.xyxy)+vec4(0.0,0.0,1.0,1.0);vec4 Pf=fract(P.xyxy)-vec4(0.0,0.0,1.0,1.0);Pi=mod289(Pi);vec4 ix=Pi.xzxz;vec4 iy=Pi.yyww;vec4 fx=Pf.xzxz;vec4 fy=Pf.yyww;vec4 i=permute(permute(ix)+iy);vec4 gx=fract(i*(1.0/41.0))*2.0-1.0;vec4 gy=abs(gx)-0.5;vec4 tx=floor(gx+0.5);gx=gx-tx;vec2 g00=vec2(gx.x,gy.x);vec2 g10=vec2(gx.y,gy.y);vec2 g01=vec2(gx.z,gy.z);vec2 g11=vec2(gx.w,gy.w);vec4 norm=taylorInvSqrt(vec4(dot(g00,g00),dot(g01,g01),dot(g10,g10),dot(g11,g11)));g00*=norm.x;g01*=norm.y;g10*=norm.z;g11*=norm.w;float n00=dot(g00,vec2(fx.x,fy.x));float n10=dot(g10,vec2(fx.y,fy.y));float n01=dot(g01,vec2(fx.z,fy.z));float n11=dot(g11,vec2(fx.w,fy.w));vec2 fade_xy=fade(Pf.xy);vec2 n_x=mix(vec2(n00,n01),vec2(n10,n11),fade_xy.x);float n_xy=mix(n_x.x,n_x.y,fade_xy.y);return 2.3*n_xy;}float perlin(vec2 P,vec2 rep){vec4 Pi=floor(P.xyxy)+vec4(0.0,0.0,1.0,1.0);vec4 Pf=fract(P.xyxy)-vec4(0.0,0.0,1.0,1.0);Pi=mod(Pi,rep.xyxy);Pi=mod289(Pi);vec4 ix=Pi.xzxz;vec4 iy=Pi.yyww;vec4 fx=Pf.xzxz;vec4 fy=Pf.yyww;vec4 i=permute(permute(ix)+iy);vec4 gx=fract(i*(1.0/41.0))*2.0-1.0;vec4 gy=abs(gx)-0.5;vec4 tx=floor(gx+0.5);gx=gx-tx;vec2 g00=vec2(gx.x,gy.x);vec2 g10=vec2(gx.y,gy.y);vec2 g01=vec2(gx.z,gy.z);vec2 g11=vec2(gx.w,gy.w);vec4 norm=taylorInvSqrt(vec4(dot(g00,g00),dot(g01,g01),dot(g10,g10),dot(g11,g11)));g00*=norm.x;g01*=norm.y;g10*=norm.z;g11*=norm.w;float n00=dot(g00,vec2(fx.x,fy.x));float n10=dot(g10,vec2(fx.y,fy.y));float n01=dot(g01,vec2(fx.z,fy.z));float n11=dot(g11,vec2(fx.w,fy.w));vec2 fade_xy=fade(Pf.xy);vec2 n_x=mix(vec2(n00,n01),vec2(n10,n11),fade_xy.x);float n_xy=mix(n_x.x,n_x.y,fade_xy.y);return 2.3*n_xy;}`,Kl=`#define GLSLIFY 1 -float perlin(vec3 P){vec3 Pi0=floor(P);vec3 Pi1=Pi0+vec3(1.0);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec3 Pf0=fract(P);vec3 Pf1=Pf0-vec3(1.0);vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=Pi0.zzzz;vec4 iz1=Pi1.zzzz;vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 gx0=ixy0*(1.0/7.0);vec4 gy0=fract(floor(gx0)*(1.0/7.0))-0.5;gx0=fract(gx0);vec4 gz0=vec4(0.5)-abs(gx0)-abs(gy0);vec4 sz0=step(gz0,vec4(0.0));gx0-=sz0*(step(0.0,gx0)-0.5);gy0-=sz0*(step(0.0,gy0)-0.5);vec4 gx1=ixy1*(1.0/7.0);vec4 gy1=fract(floor(gx1)*(1.0/7.0))-0.5;gx1=fract(gx1);vec4 gz1=vec4(0.5)-abs(gx1)-abs(gy1);vec4 sz1=step(gz1,vec4(0.0));gx1-=sz1*(step(0.0,gx1)-0.5);gy1-=sz1*(step(0.0,gy1)-0.5);vec3 g000=vec3(gx0.x,gy0.x,gz0.x);vec3 g100=vec3(gx0.y,gy0.y,gz0.y);vec3 g010=vec3(gx0.z,gy0.z,gz0.z);vec3 g110=vec3(gx0.w,gy0.w,gz0.w);vec3 g001=vec3(gx1.x,gy1.x,gz1.x);vec3 g101=vec3(gx1.y,gy1.y,gz1.y);vec3 g011=vec3(gx1.z,gy1.z,gz1.z);vec3 g111=vec3(gx1.w,gy1.w,gz1.w);vec4 norm0=taylorInvSqrt(vec4(dot(g000,g000),dot(g010,g010),dot(g100,g100),dot(g110,g110)));g000*=norm0.x;g010*=norm0.y;g100*=norm0.z;g110*=norm0.w;vec4 norm1=taylorInvSqrt(vec4(dot(g001,g001),dot(g011,g011),dot(g101,g101),dot(g111,g111)));g001*=norm1.x;g011*=norm1.y;g101*=norm1.z;g111*=norm1.w;float n000=dot(g000,Pf0);float n100=dot(g100,vec3(Pf1.x,Pf0.yz));float n010=dot(g010,vec3(Pf0.x,Pf1.y,Pf0.z));float n110=dot(g110,vec3(Pf1.xy,Pf0.z));float n001=dot(g001,vec3(Pf0.xy,Pf1.z));float n101=dot(g101,vec3(Pf1.x,Pf0.y,Pf1.z));float n011=dot(g011,vec3(Pf0.x,Pf1.yz));float n111=dot(g111,Pf1);vec3 fade_xyz=fade(Pf0);vec4 n_z=mix(vec4(n000,n100,n010,n110),vec4(n001,n101,n011,n111),fade_xyz.z);vec2 n_yz=mix(n_z.xy,n_z.zw,fade_xyz.y);float n_xyz=mix(n_yz.x,n_yz.y,fade_xyz.x);return 2.2*n_xyz;}float perlin(vec3 P,vec3 rep){vec3 Pi0=mod(floor(P),rep);vec3 Pi1=mod(Pi0+vec3(1.0),rep);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec3 Pf0=fract(P);vec3 Pf1=Pf0-vec3(1.0);vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=Pi0.zzzz;vec4 iz1=Pi1.zzzz;vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 gx0=ixy0*(1.0/7.0);vec4 gy0=fract(floor(gx0)*(1.0/7.0))-0.5;gx0=fract(gx0);vec4 gz0=vec4(0.5)-abs(gx0)-abs(gy0);vec4 sz0=step(gz0,vec4(0.0));gx0-=sz0*(step(0.0,gx0)-0.5);gy0-=sz0*(step(0.0,gy0)-0.5);vec4 gx1=ixy1*(1.0/7.0);vec4 gy1=fract(floor(gx1)*(1.0/7.0))-0.5;gx1=fract(gx1);vec4 gz1=vec4(0.5)-abs(gx1)-abs(gy1);vec4 sz1=step(gz1,vec4(0.0));gx1-=sz1*(step(0.0,gx1)-0.5);gy1-=sz1*(step(0.0,gy1)-0.5);vec3 g000=vec3(gx0.x,gy0.x,gz0.x);vec3 g100=vec3(gx0.y,gy0.y,gz0.y);vec3 g010=vec3(gx0.z,gy0.z,gz0.z);vec3 g110=vec3(gx0.w,gy0.w,gz0.w);vec3 g001=vec3(gx1.x,gy1.x,gz1.x);vec3 g101=vec3(gx1.y,gy1.y,gz1.y);vec3 g011=vec3(gx1.z,gy1.z,gz1.z);vec3 g111=vec3(gx1.w,gy1.w,gz1.w);vec4 norm0=taylorInvSqrt(vec4(dot(g000,g000),dot(g010,g010),dot(g100,g100),dot(g110,g110)));g000*=norm0.x;g010*=norm0.y;g100*=norm0.z;g110*=norm0.w;vec4 norm1=taylorInvSqrt(vec4(dot(g001,g001),dot(g011,g011),dot(g101,g101),dot(g111,g111)));g001*=norm1.x;g011*=norm1.y;g101*=norm1.z;g111*=norm1.w;float n000=dot(g000,Pf0);float n100=dot(g100,vec3(Pf1.x,Pf0.yz));float n010=dot(g010,vec3(Pf0.x,Pf1.y,Pf0.z));float n110=dot(g110,vec3(Pf1.xy,Pf0.z));float n001=dot(g001,vec3(Pf0.xy,Pf1.z));float n101=dot(g101,vec3(Pf1.x,Pf0.y,Pf1.z));float n011=dot(g011,vec3(Pf0.x,Pf1.yz));float n111=dot(g111,Pf1);vec3 fade_xyz=fade(Pf0);vec4 n_z=mix(vec4(n000,n100,n010,n110),vec4(n001,n101,n011,n111),fade_xyz.z);vec2 n_yz=mix(n_z.xy,n_z.zw,fade_xyz.y);float n_xyz=mix(n_yz.x,n_yz.y,fade_xyz.x);return 2.2*n_xyz;}`,Jl=`#define GLSLIFY 1 -float perlin(vec4 P){vec4 Pi0=floor(P);vec4 Pi1=Pi0+1.0;Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec4 Pf0=fract(P);vec4 Pf1=Pf0-1.0;vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=vec4(Pi0.zzzz);vec4 iz1=vec4(Pi1.zzzz);vec4 iw0=vec4(Pi0.wwww);vec4 iw1=vec4(Pi1.wwww);vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 ixy00=permute(ixy0+iw0);vec4 ixy01=permute(ixy0+iw1);vec4 ixy10=permute(ixy1+iw0);vec4 ixy11=permute(ixy1+iw1);vec4 gx00=ixy00*(1.0/7.0);vec4 gy00=floor(gx00)*(1.0/7.0);vec4 gz00=floor(gy00)*(1.0/6.0);gx00=fract(gx00)-0.5;gy00=fract(gy00)-0.5;gz00=fract(gz00)-0.5;vec4 gw00=vec4(0.75)-abs(gx00)-abs(gy00)-abs(gz00);vec4 sw00=step(gw00,vec4(0.0));gx00-=sw00*(step(0.0,gx00)-0.5);gy00-=sw00*(step(0.0,gy00)-0.5);vec4 gx01=ixy01*(1.0/7.0);vec4 gy01=floor(gx01)*(1.0/7.0);vec4 gz01=floor(gy01)*(1.0/6.0);gx01=fract(gx01)-0.5;gy01=fract(gy01)-0.5;gz01=fract(gz01)-0.5;vec4 gw01=vec4(0.75)-abs(gx01)-abs(gy01)-abs(gz01);vec4 sw01=step(gw01,vec4(0.0));gx01-=sw01*(step(0.0,gx01)-0.5);gy01-=sw01*(step(0.0,gy01)-0.5);vec4 gx10=ixy10*(1.0/7.0);vec4 gy10=floor(gx10)*(1.0/7.0);vec4 gz10=floor(gy10)*(1.0/6.0);gx10=fract(gx10)-0.5;gy10=fract(gy10)-0.5;gz10=fract(gz10)-0.5;vec4 gw10=vec4(0.75)-abs(gx10)-abs(gy10)-abs(gz10);vec4 sw10=step(gw10,vec4(0.0));gx10-=sw10*(step(0.0,gx10)-0.5);gy10-=sw10*(step(0.0,gy10)-0.5);vec4 gx11=ixy11*(1.0/7.0);vec4 gy11=floor(gx11)*(1.0/7.0);vec4 gz11=floor(gy11)*(1.0/6.0);gx11=fract(gx11)-0.5;gy11=fract(gy11)-0.5;gz11=fract(gz11)-0.5;vec4 gw11=vec4(0.75)-abs(gx11)-abs(gy11)-abs(gz11);vec4 sw11=step(gw11,vec4(0.0));gx11-=sw11*(step(0.0,gx11)-0.5);gy11-=sw11*(step(0.0,gy11)-0.5);vec4 g0000=vec4(gx00.x,gy00.x,gz00.x,gw00.x);vec4 g1000=vec4(gx00.y,gy00.y,gz00.y,gw00.y);vec4 g0100=vec4(gx00.z,gy00.z,gz00.z,gw00.z);vec4 g1100=vec4(gx00.w,gy00.w,gz00.w,gw00.w);vec4 g0010=vec4(gx10.x,gy10.x,gz10.x,gw10.x);vec4 g1010=vec4(gx10.y,gy10.y,gz10.y,gw10.y);vec4 g0110=vec4(gx10.z,gy10.z,gz10.z,gw10.z);vec4 g1110=vec4(gx10.w,gy10.w,gz10.w,gw10.w);vec4 g0001=vec4(gx01.x,gy01.x,gz01.x,gw01.x);vec4 g1001=vec4(gx01.y,gy01.y,gz01.y,gw01.y);vec4 g0101=vec4(gx01.z,gy01.z,gz01.z,gw01.z);vec4 g1101=vec4(gx01.w,gy01.w,gz01.w,gw01.w);vec4 g0011=vec4(gx11.x,gy11.x,gz11.x,gw11.x);vec4 g1011=vec4(gx11.y,gy11.y,gz11.y,gw11.y);vec4 g0111=vec4(gx11.z,gy11.z,gz11.z,gw11.z);vec4 g1111=vec4(gx11.w,gy11.w,gz11.w,gw11.w);vec4 norm00=taylorInvSqrt(vec4(dot(g0000,g0000),dot(g0100,g0100),dot(g1000,g1000),dot(g1100,g1100)));g0000*=norm00.x;g0100*=norm00.y;g1000*=norm00.z;g1100*=norm00.w;vec4 norm01=taylorInvSqrt(vec4(dot(g0001,g0001),dot(g0101,g0101),dot(g1001,g1001),dot(g1101,g1101)));g0001*=norm01.x;g0101*=norm01.y;g1001*=norm01.z;g1101*=norm01.w;vec4 norm10=taylorInvSqrt(vec4(dot(g0010,g0010),dot(g0110,g0110),dot(g1010,g1010),dot(g1110,g1110)));g0010*=norm10.x;g0110*=norm10.y;g1010*=norm10.z;g1110*=norm10.w;vec4 norm11=taylorInvSqrt(vec4(dot(g0011,g0011),dot(g0111,g0111),dot(g1011,g1011),dot(g1111,g1111)));g0011*=norm11.x;g0111*=norm11.y;g1011*=norm11.z;g1111*=norm11.w;float n0000=dot(g0000,Pf0);float n1000=dot(g1000,vec4(Pf1.x,Pf0.yzw));float n0100=dot(g0100,vec4(Pf0.x,Pf1.y,Pf0.zw));float n1100=dot(g1100,vec4(Pf1.xy,Pf0.zw));float n0010=dot(g0010,vec4(Pf0.xy,Pf1.z,Pf0.w));float n1010=dot(g1010,vec4(Pf1.x,Pf0.y,Pf1.z,Pf0.w));float n0110=dot(g0110,vec4(Pf0.x,Pf1.yz,Pf0.w));float n1110=dot(g1110,vec4(Pf1.xyz,Pf0.w));float n0001=dot(g0001,vec4(Pf0.xyz,Pf1.w));float n1001=dot(g1001,vec4(Pf1.x,Pf0.yz,Pf1.w));float n0101=dot(g0101,vec4(Pf0.x,Pf1.y,Pf0.z,Pf1.w));float n1101=dot(g1101,vec4(Pf1.xy,Pf0.z,Pf1.w));float n0011=dot(g0011,vec4(Pf0.xy,Pf1.zw));float n1011=dot(g1011,vec4(Pf1.x,Pf0.y,Pf1.zw));float n0111=dot(g0111,vec4(Pf0.x,Pf1.yzw));float n1111=dot(g1111,Pf1);vec4 fade_xyzw=fade(Pf0);vec4 n_0w=mix(vec4(n0000,n1000,n0100,n1100),vec4(n0001,n1001,n0101,n1101),fade_xyzw.w);vec4 n_1w=mix(vec4(n0010,n1010,n0110,n1110),vec4(n0011,n1011,n0111,n1111),fade_xyzw.w);vec4 n_zw=mix(n_0w,n_1w,fade_xyzw.z);vec2 n_yzw=mix(n_zw.xy,n_zw.zw,fade_xyzw.y);float n_xyzw=mix(n_yzw.x,n_yzw.y,fade_xyzw.x);return 2.2*n_xyzw;}float perlin(vec4 P,vec4 rep){vec4 Pi0=mod(floor(P),rep);vec4 Pi1=mod(Pi0+1.0,rep);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec4 Pf0=fract(P);vec4 Pf1=Pf0-1.0;vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=vec4(Pi0.zzzz);vec4 iz1=vec4(Pi1.zzzz);vec4 iw0=vec4(Pi0.wwww);vec4 iw1=vec4(Pi1.wwww);vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 ixy00=permute(ixy0+iw0);vec4 ixy01=permute(ixy0+iw1);vec4 ixy10=permute(ixy1+iw0);vec4 ixy11=permute(ixy1+iw1);vec4 gx00=ixy00*(1.0/7.0);vec4 gy00=floor(gx00)*(1.0/7.0);vec4 gz00=floor(gy00)*(1.0/6.0);gx00=fract(gx00)-0.5;gy00=fract(gy00)-0.5;gz00=fract(gz00)-0.5;vec4 gw00=vec4(0.75)-abs(gx00)-abs(gy00)-abs(gz00);vec4 sw00=step(gw00,vec4(0.0));gx00-=sw00*(step(0.0,gx00)-0.5);gy00-=sw00*(step(0.0,gy00)-0.5);vec4 gx01=ixy01*(1.0/7.0);vec4 gy01=floor(gx01)*(1.0/7.0);vec4 gz01=floor(gy01)*(1.0/6.0);gx01=fract(gx01)-0.5;gy01=fract(gy01)-0.5;gz01=fract(gz01)-0.5;vec4 gw01=vec4(0.75)-abs(gx01)-abs(gy01)-abs(gz01);vec4 sw01=step(gw01,vec4(0.0));gx01-=sw01*(step(0.0,gx01)-0.5);gy01-=sw01*(step(0.0,gy01)-0.5);vec4 gx10=ixy10*(1.0/7.0);vec4 gy10=floor(gx10)*(1.0/7.0);vec4 gz10=floor(gy10)*(1.0/6.0);gx10=fract(gx10)-0.5;gy10=fract(gy10)-0.5;gz10=fract(gz10)-0.5;vec4 gw10=vec4(0.75)-abs(gx10)-abs(gy10)-abs(gz10);vec4 sw10=step(gw10,vec4(0.0));gx10-=sw10*(step(0.0,gx10)-0.5);gy10-=sw10*(step(0.0,gy10)-0.5);vec4 gx11=ixy11*(1.0/7.0);vec4 gy11=floor(gx11)*(1.0/7.0);vec4 gz11=floor(gy11)*(1.0/6.0);gx11=fract(gx11)-0.5;gy11=fract(gy11)-0.5;gz11=fract(gz11)-0.5;vec4 gw11=vec4(0.75)-abs(gx11)-abs(gy11)-abs(gz11);vec4 sw11=step(gw11,vec4(0.0));gx11-=sw11*(step(0.0,gx11)-0.5);gy11-=sw11*(step(0.0,gy11)-0.5);vec4 g0000=vec4(gx00.x,gy00.x,gz00.x,gw00.x);vec4 g1000=vec4(gx00.y,gy00.y,gz00.y,gw00.y);vec4 g0100=vec4(gx00.z,gy00.z,gz00.z,gw00.z);vec4 g1100=vec4(gx00.w,gy00.w,gz00.w,gw00.w);vec4 g0010=vec4(gx10.x,gy10.x,gz10.x,gw10.x);vec4 g1010=vec4(gx10.y,gy10.y,gz10.y,gw10.y);vec4 g0110=vec4(gx10.z,gy10.z,gz10.z,gw10.z);vec4 g1110=vec4(gx10.w,gy10.w,gz10.w,gw10.w);vec4 g0001=vec4(gx01.x,gy01.x,gz01.x,gw01.x);vec4 g1001=vec4(gx01.y,gy01.y,gz01.y,gw01.y);vec4 g0101=vec4(gx01.z,gy01.z,gz01.z,gw01.z);vec4 g1101=vec4(gx01.w,gy01.w,gz01.w,gw01.w);vec4 g0011=vec4(gx11.x,gy11.x,gz11.x,gw11.x);vec4 g1011=vec4(gx11.y,gy11.y,gz11.y,gw11.y);vec4 g0111=vec4(gx11.z,gy11.z,gz11.z,gw11.z);vec4 g1111=vec4(gx11.w,gy11.w,gz11.w,gw11.w);vec4 norm00=taylorInvSqrt(vec4(dot(g0000,g0000),dot(g0100,g0100),dot(g1000,g1000),dot(g1100,g1100)));g0000*=norm00.x;g0100*=norm00.y;g1000*=norm00.z;g1100*=norm00.w;vec4 norm01=taylorInvSqrt(vec4(dot(g0001,g0001),dot(g0101,g0101),dot(g1001,g1001),dot(g1101,g1101)));g0001*=norm01.x;g0101*=norm01.y;g1001*=norm01.z;g1101*=norm01.w;vec4 norm10=taylorInvSqrt(vec4(dot(g0010,g0010),dot(g0110,g0110),dot(g1010,g1010),dot(g1110,g1110)));g0010*=norm10.x;g0110*=norm10.y;g1010*=norm10.z;g1110*=norm10.w;vec4 norm11=taylorInvSqrt(vec4(dot(g0011,g0011),dot(g0111,g0111),dot(g1011,g1011),dot(g1111,g1111)));g0011*=norm11.x;g0111*=norm11.y;g1011*=norm11.z;g1111*=norm11.w;float n0000=dot(g0000,Pf0);float n1000=dot(g1000,vec4(Pf1.x,Pf0.yzw));float n0100=dot(g0100,vec4(Pf0.x,Pf1.y,Pf0.zw));float n1100=dot(g1100,vec4(Pf1.xy,Pf0.zw));float n0010=dot(g0010,vec4(Pf0.xy,Pf1.z,Pf0.w));float n1010=dot(g1010,vec4(Pf1.x,Pf0.y,Pf1.z,Pf0.w));float n0110=dot(g0110,vec4(Pf0.x,Pf1.yz,Pf0.w));float n1110=dot(g1110,vec4(Pf1.xyz,Pf0.w));float n0001=dot(g0001,vec4(Pf0.xyz,Pf1.w));float n1001=dot(g1001,vec4(Pf1.x,Pf0.yz,Pf1.w));float n0101=dot(g0101,vec4(Pf0.x,Pf1.y,Pf0.z,Pf1.w));float n1101=dot(g1101,vec4(Pf1.xy,Pf0.z,Pf1.w));float n0011=dot(g0011,vec4(Pf0.xy,Pf1.zw));float n1011=dot(g1011,vec4(Pf1.x,Pf0.y,Pf1.zw));float n0111=dot(g0111,vec4(Pf0.x,Pf1.yzw));float n1111=dot(g1111,Pf1);vec4 fade_xyzw=fade(Pf0);vec4 n_0w=mix(vec4(n0000,n1000,n0100,n1100),vec4(n0001,n1001,n0101,n1101),fade_xyzw.w);vec4 n_1w=mix(vec4(n0010,n1010,n0110,n1110),vec4(n0011,n1011,n0111,n1111),fade_xyzw.w);vec4 n_zw=mix(n_0w,n_1w,fade_xyzw.z);vec2 n_yzw=mix(n_zw.xy,n_zw.zw,fade_xyzw.y);float n_xyzw=mix(n_yzw.x,n_yzw.y,fade_xyzw.x);return 2.2*n_xyzw;}`,Zl=`#define GLSLIFY 1 -vec2 rgrad2(vec2 p,float rot){float u=permute(permute(p.x)+p.y)*0.0243902439+rot;u=fract(u)*6.28318530718;return vec2(cos(u),sin(u));}vec3 psrdnoise(vec2 pos,vec2 per,float rot){pos.y+=0.01;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 xw=mod(vec3(p0.x,p1.x,p2.x),per.x);vec3 yw=mod(vec3(p0.y,p1.y,p2.y),per.y);vec3 iuw=xw+0.5*yw;vec3 ivw=yw;vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));vec3 dtdx=-2.0*vec3(d0.x,d1.x,d2.x);vec3 dtdy=-2.0*vec3(d0.y,d1.y,d2.y);if(t.x<0.0){dtdx.x=0.0;dtdy.x=0.0;t.x=0.0;}if(t.y<0.0){dtdx.y=0.0;dtdy.y=0.0;t.y=0.0;}if(t.z<0.0){dtdx.z=0.0;dtdy.z=0.0;t.z=0.0;}vec3 t2=t*t;vec3 t4=t2*t2;vec3 t3=t2*t;float n=dot(t4,w);vec2 dt0=vec2(dtdx.x,dtdy.x)*4.0*t3.x;vec2 dn0=t4.x*g0+dt0*w.x;vec2 dt1=vec2(dtdx.y,dtdy.y)*4.0*t3.y;vec2 dn1=t4.y*g1+dt1*w.y;vec2 dt2=vec2(dtdx.z,dtdy.z)*4.0*t3.z;vec2 dn2=t4.z*g2+dt2*w.z;return 11.0*vec3(n,dn0+dn1+dn2);}vec3 psdnoise(vec2 pos,vec2 per){return psrdnoise(pos,per,0.0);}float psrnoise(vec2 pos,vec2 per,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 xw=mod(vec3(p0.x,p1.x,p2.x),per.x);vec3 yw=mod(vec3(p0.y,p1.y,p2.y),per.y);vec3 iuw=xw+0.5*yw;vec3 ivw=yw;vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));t=max(t,0.0);vec3 t2=t*t;vec3 t4=t2*t2;float n=dot(t4,w);return 11.0*n;}float psnoise(vec2 pos,vec2 per){return psrnoise(pos,per,0.0);}vec3 srdnoise(vec2 pos,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 x=vec3(p0.x,p1.x,p2.x);vec3 y=vec3(p0.y,p1.y,p2.y);vec3 iuw=x+0.5*y;vec3 ivw=y;iuw=mod289(iuw);ivw=mod289(ivw);vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));vec3 dtdx=-2.0*vec3(d0.x,d1.x,d2.x);vec3 dtdy=-2.0*vec3(d0.y,d1.y,d2.y);if(t.x<0.0){dtdx.x=0.0;dtdy.x=0.0;t.x=0.0;}if(t.y<0.0){dtdx.y=0.0;dtdy.y=0.0;t.y=0.0;}if(t.z<0.0){dtdx.z=0.0;dtdy.z=0.0;t.z=0.0;}vec3 t2=t*t;vec3 t4=t2*t2;vec3 t3=t2*t;float n=dot(t4,w);vec2 dt0=vec2(dtdx.x,dtdy.x)*4.0*t3.x;vec2 dn0=t4.x*g0+dt0*w.x;vec2 dt1=vec2(dtdx.y,dtdy.y)*4.0*t3.y;vec2 dn1=t4.y*g1+dt1*w.y;vec2 dt2=vec2(dtdx.z,dtdy.z)*4.0*t3.z;vec2 dn2=t4.z*g2+dt2*w.z;return 11.0*vec3(n,dn0+dn1+dn2);}vec3 sdnoise(vec2 pos){return srdnoise(pos,0.0);}float srnoise(vec2 pos,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 x=vec3(p0.x,p1.x,p2.x);vec3 y=vec3(p0.y,p1.y,p2.y);vec3 iuw=x+0.5*y;vec3 ivw=y;iuw=mod289(iuw);ivw=mod289(ivw);vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));t=max(t,0.0);vec3 t2=t*t;vec3 t4=t2*t2;float n=dot(t4,w);return 11.0*n;}float snoise(vec2 pos){return srnoise(pos,0.0);}`,$l=`#define GLSLIFY 1 +`,Kl=`#define GLSLIFY 1 +float perlin(vec2 P){vec4 Pi=floor(P.xyxy)+vec4(0.0,0.0,1.0,1.0);vec4 Pf=fract(P.xyxy)-vec4(0.0,0.0,1.0,1.0);Pi=mod289(Pi);vec4 ix=Pi.xzxz;vec4 iy=Pi.yyww;vec4 fx=Pf.xzxz;vec4 fy=Pf.yyww;vec4 i=permute(permute(ix)+iy);vec4 gx=fract(i*(1.0/41.0))*2.0-1.0;vec4 gy=abs(gx)-0.5;vec4 tx=floor(gx+0.5);gx=gx-tx;vec2 g00=vec2(gx.x,gy.x);vec2 g10=vec2(gx.y,gy.y);vec2 g01=vec2(gx.z,gy.z);vec2 g11=vec2(gx.w,gy.w);vec4 norm=taylorInvSqrt(vec4(dot(g00,g00),dot(g01,g01),dot(g10,g10),dot(g11,g11)));g00*=norm.x;g01*=norm.y;g10*=norm.z;g11*=norm.w;float n00=dot(g00,vec2(fx.x,fy.x));float n10=dot(g10,vec2(fx.y,fy.y));float n01=dot(g01,vec2(fx.z,fy.z));float n11=dot(g11,vec2(fx.w,fy.w));vec2 fade_xy=fade(Pf.xy);vec2 n_x=mix(vec2(n00,n01),vec2(n10,n11),fade_xy.x);float n_xy=mix(n_x.x,n_x.y,fade_xy.y);return 2.3*n_xy;}float perlin(vec2 P,vec2 rep){vec4 Pi=floor(P.xyxy)+vec4(0.0,0.0,1.0,1.0);vec4 Pf=fract(P.xyxy)-vec4(0.0,0.0,1.0,1.0);Pi=mod(Pi,rep.xyxy);Pi=mod289(Pi);vec4 ix=Pi.xzxz;vec4 iy=Pi.yyww;vec4 fx=Pf.xzxz;vec4 fy=Pf.yyww;vec4 i=permute(permute(ix)+iy);vec4 gx=fract(i*(1.0/41.0))*2.0-1.0;vec4 gy=abs(gx)-0.5;vec4 tx=floor(gx+0.5);gx=gx-tx;vec2 g00=vec2(gx.x,gy.x);vec2 g10=vec2(gx.y,gy.y);vec2 g01=vec2(gx.z,gy.z);vec2 g11=vec2(gx.w,gy.w);vec4 norm=taylorInvSqrt(vec4(dot(g00,g00),dot(g01,g01),dot(g10,g10),dot(g11,g11)));g00*=norm.x;g01*=norm.y;g10*=norm.z;g11*=norm.w;float n00=dot(g00,vec2(fx.x,fy.x));float n10=dot(g10,vec2(fx.y,fy.y));float n01=dot(g01,vec2(fx.z,fy.z));float n11=dot(g11,vec2(fx.w,fy.w));vec2 fade_xy=fade(Pf.xy);vec2 n_x=mix(vec2(n00,n01),vec2(n10,n11),fade_xy.x);float n_xy=mix(n_x.x,n_x.y,fade_xy.y);return 2.3*n_xy;}`,Jl=`#define GLSLIFY 1 +float perlin(vec3 P){vec3 Pi0=floor(P);vec3 Pi1=Pi0+vec3(1.0);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec3 Pf0=fract(P);vec3 Pf1=Pf0-vec3(1.0);vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=Pi0.zzzz;vec4 iz1=Pi1.zzzz;vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 gx0=ixy0*(1.0/7.0);vec4 gy0=fract(floor(gx0)*(1.0/7.0))-0.5;gx0=fract(gx0);vec4 gz0=vec4(0.5)-abs(gx0)-abs(gy0);vec4 sz0=step(gz0,vec4(0.0));gx0-=sz0*(step(0.0,gx0)-0.5);gy0-=sz0*(step(0.0,gy0)-0.5);vec4 gx1=ixy1*(1.0/7.0);vec4 gy1=fract(floor(gx1)*(1.0/7.0))-0.5;gx1=fract(gx1);vec4 gz1=vec4(0.5)-abs(gx1)-abs(gy1);vec4 sz1=step(gz1,vec4(0.0));gx1-=sz1*(step(0.0,gx1)-0.5);gy1-=sz1*(step(0.0,gy1)-0.5);vec3 g000=vec3(gx0.x,gy0.x,gz0.x);vec3 g100=vec3(gx0.y,gy0.y,gz0.y);vec3 g010=vec3(gx0.z,gy0.z,gz0.z);vec3 g110=vec3(gx0.w,gy0.w,gz0.w);vec3 g001=vec3(gx1.x,gy1.x,gz1.x);vec3 g101=vec3(gx1.y,gy1.y,gz1.y);vec3 g011=vec3(gx1.z,gy1.z,gz1.z);vec3 g111=vec3(gx1.w,gy1.w,gz1.w);vec4 norm0=taylorInvSqrt(vec4(dot(g000,g000),dot(g010,g010),dot(g100,g100),dot(g110,g110)));g000*=norm0.x;g010*=norm0.y;g100*=norm0.z;g110*=norm0.w;vec4 norm1=taylorInvSqrt(vec4(dot(g001,g001),dot(g011,g011),dot(g101,g101),dot(g111,g111)));g001*=norm1.x;g011*=norm1.y;g101*=norm1.z;g111*=norm1.w;float n000=dot(g000,Pf0);float n100=dot(g100,vec3(Pf1.x,Pf0.yz));float n010=dot(g010,vec3(Pf0.x,Pf1.y,Pf0.z));float n110=dot(g110,vec3(Pf1.xy,Pf0.z));float n001=dot(g001,vec3(Pf0.xy,Pf1.z));float n101=dot(g101,vec3(Pf1.x,Pf0.y,Pf1.z));float n011=dot(g011,vec3(Pf0.x,Pf1.yz));float n111=dot(g111,Pf1);vec3 fade_xyz=fade(Pf0);vec4 n_z=mix(vec4(n000,n100,n010,n110),vec4(n001,n101,n011,n111),fade_xyz.z);vec2 n_yz=mix(n_z.xy,n_z.zw,fade_xyz.y);float n_xyz=mix(n_yz.x,n_yz.y,fade_xyz.x);return 2.2*n_xyz;}float perlin(vec3 P,vec3 rep){vec3 Pi0=mod(floor(P),rep);vec3 Pi1=mod(Pi0+vec3(1.0),rep);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec3 Pf0=fract(P);vec3 Pf1=Pf0-vec3(1.0);vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=Pi0.zzzz;vec4 iz1=Pi1.zzzz;vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 gx0=ixy0*(1.0/7.0);vec4 gy0=fract(floor(gx0)*(1.0/7.0))-0.5;gx0=fract(gx0);vec4 gz0=vec4(0.5)-abs(gx0)-abs(gy0);vec4 sz0=step(gz0,vec4(0.0));gx0-=sz0*(step(0.0,gx0)-0.5);gy0-=sz0*(step(0.0,gy0)-0.5);vec4 gx1=ixy1*(1.0/7.0);vec4 gy1=fract(floor(gx1)*(1.0/7.0))-0.5;gx1=fract(gx1);vec4 gz1=vec4(0.5)-abs(gx1)-abs(gy1);vec4 sz1=step(gz1,vec4(0.0));gx1-=sz1*(step(0.0,gx1)-0.5);gy1-=sz1*(step(0.0,gy1)-0.5);vec3 g000=vec3(gx0.x,gy0.x,gz0.x);vec3 g100=vec3(gx0.y,gy0.y,gz0.y);vec3 g010=vec3(gx0.z,gy0.z,gz0.z);vec3 g110=vec3(gx0.w,gy0.w,gz0.w);vec3 g001=vec3(gx1.x,gy1.x,gz1.x);vec3 g101=vec3(gx1.y,gy1.y,gz1.y);vec3 g011=vec3(gx1.z,gy1.z,gz1.z);vec3 g111=vec3(gx1.w,gy1.w,gz1.w);vec4 norm0=taylorInvSqrt(vec4(dot(g000,g000),dot(g010,g010),dot(g100,g100),dot(g110,g110)));g000*=norm0.x;g010*=norm0.y;g100*=norm0.z;g110*=norm0.w;vec4 norm1=taylorInvSqrt(vec4(dot(g001,g001),dot(g011,g011),dot(g101,g101),dot(g111,g111)));g001*=norm1.x;g011*=norm1.y;g101*=norm1.z;g111*=norm1.w;float n000=dot(g000,Pf0);float n100=dot(g100,vec3(Pf1.x,Pf0.yz));float n010=dot(g010,vec3(Pf0.x,Pf1.y,Pf0.z));float n110=dot(g110,vec3(Pf1.xy,Pf0.z));float n001=dot(g001,vec3(Pf0.xy,Pf1.z));float n101=dot(g101,vec3(Pf1.x,Pf0.y,Pf1.z));float n011=dot(g011,vec3(Pf0.x,Pf1.yz));float n111=dot(g111,Pf1);vec3 fade_xyz=fade(Pf0);vec4 n_z=mix(vec4(n000,n100,n010,n110),vec4(n001,n101,n011,n111),fade_xyz.z);vec2 n_yz=mix(n_z.xy,n_z.zw,fade_xyz.y);float n_xyz=mix(n_yz.x,n_yz.y,fade_xyz.x);return 2.2*n_xyz;}`,Zl=`#define GLSLIFY 1 +float perlin(vec4 P){vec4 Pi0=floor(P);vec4 Pi1=Pi0+1.0;Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec4 Pf0=fract(P);vec4 Pf1=Pf0-1.0;vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=vec4(Pi0.zzzz);vec4 iz1=vec4(Pi1.zzzz);vec4 iw0=vec4(Pi0.wwww);vec4 iw1=vec4(Pi1.wwww);vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 ixy00=permute(ixy0+iw0);vec4 ixy01=permute(ixy0+iw1);vec4 ixy10=permute(ixy1+iw0);vec4 ixy11=permute(ixy1+iw1);vec4 gx00=ixy00*(1.0/7.0);vec4 gy00=floor(gx00)*(1.0/7.0);vec4 gz00=floor(gy00)*(1.0/6.0);gx00=fract(gx00)-0.5;gy00=fract(gy00)-0.5;gz00=fract(gz00)-0.5;vec4 gw00=vec4(0.75)-abs(gx00)-abs(gy00)-abs(gz00);vec4 sw00=step(gw00,vec4(0.0));gx00-=sw00*(step(0.0,gx00)-0.5);gy00-=sw00*(step(0.0,gy00)-0.5);vec4 gx01=ixy01*(1.0/7.0);vec4 gy01=floor(gx01)*(1.0/7.0);vec4 gz01=floor(gy01)*(1.0/6.0);gx01=fract(gx01)-0.5;gy01=fract(gy01)-0.5;gz01=fract(gz01)-0.5;vec4 gw01=vec4(0.75)-abs(gx01)-abs(gy01)-abs(gz01);vec4 sw01=step(gw01,vec4(0.0));gx01-=sw01*(step(0.0,gx01)-0.5);gy01-=sw01*(step(0.0,gy01)-0.5);vec4 gx10=ixy10*(1.0/7.0);vec4 gy10=floor(gx10)*(1.0/7.0);vec4 gz10=floor(gy10)*(1.0/6.0);gx10=fract(gx10)-0.5;gy10=fract(gy10)-0.5;gz10=fract(gz10)-0.5;vec4 gw10=vec4(0.75)-abs(gx10)-abs(gy10)-abs(gz10);vec4 sw10=step(gw10,vec4(0.0));gx10-=sw10*(step(0.0,gx10)-0.5);gy10-=sw10*(step(0.0,gy10)-0.5);vec4 gx11=ixy11*(1.0/7.0);vec4 gy11=floor(gx11)*(1.0/7.0);vec4 gz11=floor(gy11)*(1.0/6.0);gx11=fract(gx11)-0.5;gy11=fract(gy11)-0.5;gz11=fract(gz11)-0.5;vec4 gw11=vec4(0.75)-abs(gx11)-abs(gy11)-abs(gz11);vec4 sw11=step(gw11,vec4(0.0));gx11-=sw11*(step(0.0,gx11)-0.5);gy11-=sw11*(step(0.0,gy11)-0.5);vec4 g0000=vec4(gx00.x,gy00.x,gz00.x,gw00.x);vec4 g1000=vec4(gx00.y,gy00.y,gz00.y,gw00.y);vec4 g0100=vec4(gx00.z,gy00.z,gz00.z,gw00.z);vec4 g1100=vec4(gx00.w,gy00.w,gz00.w,gw00.w);vec4 g0010=vec4(gx10.x,gy10.x,gz10.x,gw10.x);vec4 g1010=vec4(gx10.y,gy10.y,gz10.y,gw10.y);vec4 g0110=vec4(gx10.z,gy10.z,gz10.z,gw10.z);vec4 g1110=vec4(gx10.w,gy10.w,gz10.w,gw10.w);vec4 g0001=vec4(gx01.x,gy01.x,gz01.x,gw01.x);vec4 g1001=vec4(gx01.y,gy01.y,gz01.y,gw01.y);vec4 g0101=vec4(gx01.z,gy01.z,gz01.z,gw01.z);vec4 g1101=vec4(gx01.w,gy01.w,gz01.w,gw01.w);vec4 g0011=vec4(gx11.x,gy11.x,gz11.x,gw11.x);vec4 g1011=vec4(gx11.y,gy11.y,gz11.y,gw11.y);vec4 g0111=vec4(gx11.z,gy11.z,gz11.z,gw11.z);vec4 g1111=vec4(gx11.w,gy11.w,gz11.w,gw11.w);vec4 norm00=taylorInvSqrt(vec4(dot(g0000,g0000),dot(g0100,g0100),dot(g1000,g1000),dot(g1100,g1100)));g0000*=norm00.x;g0100*=norm00.y;g1000*=norm00.z;g1100*=norm00.w;vec4 norm01=taylorInvSqrt(vec4(dot(g0001,g0001),dot(g0101,g0101),dot(g1001,g1001),dot(g1101,g1101)));g0001*=norm01.x;g0101*=norm01.y;g1001*=norm01.z;g1101*=norm01.w;vec4 norm10=taylorInvSqrt(vec4(dot(g0010,g0010),dot(g0110,g0110),dot(g1010,g1010),dot(g1110,g1110)));g0010*=norm10.x;g0110*=norm10.y;g1010*=norm10.z;g1110*=norm10.w;vec4 norm11=taylorInvSqrt(vec4(dot(g0011,g0011),dot(g0111,g0111),dot(g1011,g1011),dot(g1111,g1111)));g0011*=norm11.x;g0111*=norm11.y;g1011*=norm11.z;g1111*=norm11.w;float n0000=dot(g0000,Pf0);float n1000=dot(g1000,vec4(Pf1.x,Pf0.yzw));float n0100=dot(g0100,vec4(Pf0.x,Pf1.y,Pf0.zw));float n1100=dot(g1100,vec4(Pf1.xy,Pf0.zw));float n0010=dot(g0010,vec4(Pf0.xy,Pf1.z,Pf0.w));float n1010=dot(g1010,vec4(Pf1.x,Pf0.y,Pf1.z,Pf0.w));float n0110=dot(g0110,vec4(Pf0.x,Pf1.yz,Pf0.w));float n1110=dot(g1110,vec4(Pf1.xyz,Pf0.w));float n0001=dot(g0001,vec4(Pf0.xyz,Pf1.w));float n1001=dot(g1001,vec4(Pf1.x,Pf0.yz,Pf1.w));float n0101=dot(g0101,vec4(Pf0.x,Pf1.y,Pf0.z,Pf1.w));float n1101=dot(g1101,vec4(Pf1.xy,Pf0.z,Pf1.w));float n0011=dot(g0011,vec4(Pf0.xy,Pf1.zw));float n1011=dot(g1011,vec4(Pf1.x,Pf0.y,Pf1.zw));float n0111=dot(g0111,vec4(Pf0.x,Pf1.yzw));float n1111=dot(g1111,Pf1);vec4 fade_xyzw=fade(Pf0);vec4 n_0w=mix(vec4(n0000,n1000,n0100,n1100),vec4(n0001,n1001,n0101,n1101),fade_xyzw.w);vec4 n_1w=mix(vec4(n0010,n1010,n0110,n1110),vec4(n0011,n1011,n0111,n1111),fade_xyzw.w);vec4 n_zw=mix(n_0w,n_1w,fade_xyzw.z);vec2 n_yzw=mix(n_zw.xy,n_zw.zw,fade_xyzw.y);float n_xyzw=mix(n_yzw.x,n_yzw.y,fade_xyzw.x);return 2.2*n_xyzw;}float perlin(vec4 P,vec4 rep){vec4 Pi0=mod(floor(P),rep);vec4 Pi1=mod(Pi0+1.0,rep);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec4 Pf0=fract(P);vec4 Pf1=Pf0-1.0;vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=vec4(Pi0.zzzz);vec4 iz1=vec4(Pi1.zzzz);vec4 iw0=vec4(Pi0.wwww);vec4 iw1=vec4(Pi1.wwww);vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 ixy00=permute(ixy0+iw0);vec4 ixy01=permute(ixy0+iw1);vec4 ixy10=permute(ixy1+iw0);vec4 ixy11=permute(ixy1+iw1);vec4 gx00=ixy00*(1.0/7.0);vec4 gy00=floor(gx00)*(1.0/7.0);vec4 gz00=floor(gy00)*(1.0/6.0);gx00=fract(gx00)-0.5;gy00=fract(gy00)-0.5;gz00=fract(gz00)-0.5;vec4 gw00=vec4(0.75)-abs(gx00)-abs(gy00)-abs(gz00);vec4 sw00=step(gw00,vec4(0.0));gx00-=sw00*(step(0.0,gx00)-0.5);gy00-=sw00*(step(0.0,gy00)-0.5);vec4 gx01=ixy01*(1.0/7.0);vec4 gy01=floor(gx01)*(1.0/7.0);vec4 gz01=floor(gy01)*(1.0/6.0);gx01=fract(gx01)-0.5;gy01=fract(gy01)-0.5;gz01=fract(gz01)-0.5;vec4 gw01=vec4(0.75)-abs(gx01)-abs(gy01)-abs(gz01);vec4 sw01=step(gw01,vec4(0.0));gx01-=sw01*(step(0.0,gx01)-0.5);gy01-=sw01*(step(0.0,gy01)-0.5);vec4 gx10=ixy10*(1.0/7.0);vec4 gy10=floor(gx10)*(1.0/7.0);vec4 gz10=floor(gy10)*(1.0/6.0);gx10=fract(gx10)-0.5;gy10=fract(gy10)-0.5;gz10=fract(gz10)-0.5;vec4 gw10=vec4(0.75)-abs(gx10)-abs(gy10)-abs(gz10);vec4 sw10=step(gw10,vec4(0.0));gx10-=sw10*(step(0.0,gx10)-0.5);gy10-=sw10*(step(0.0,gy10)-0.5);vec4 gx11=ixy11*(1.0/7.0);vec4 gy11=floor(gx11)*(1.0/7.0);vec4 gz11=floor(gy11)*(1.0/6.0);gx11=fract(gx11)-0.5;gy11=fract(gy11)-0.5;gz11=fract(gz11)-0.5;vec4 gw11=vec4(0.75)-abs(gx11)-abs(gy11)-abs(gz11);vec4 sw11=step(gw11,vec4(0.0));gx11-=sw11*(step(0.0,gx11)-0.5);gy11-=sw11*(step(0.0,gy11)-0.5);vec4 g0000=vec4(gx00.x,gy00.x,gz00.x,gw00.x);vec4 g1000=vec4(gx00.y,gy00.y,gz00.y,gw00.y);vec4 g0100=vec4(gx00.z,gy00.z,gz00.z,gw00.z);vec4 g1100=vec4(gx00.w,gy00.w,gz00.w,gw00.w);vec4 g0010=vec4(gx10.x,gy10.x,gz10.x,gw10.x);vec4 g1010=vec4(gx10.y,gy10.y,gz10.y,gw10.y);vec4 g0110=vec4(gx10.z,gy10.z,gz10.z,gw10.z);vec4 g1110=vec4(gx10.w,gy10.w,gz10.w,gw10.w);vec4 g0001=vec4(gx01.x,gy01.x,gz01.x,gw01.x);vec4 g1001=vec4(gx01.y,gy01.y,gz01.y,gw01.y);vec4 g0101=vec4(gx01.z,gy01.z,gz01.z,gw01.z);vec4 g1101=vec4(gx01.w,gy01.w,gz01.w,gw01.w);vec4 g0011=vec4(gx11.x,gy11.x,gz11.x,gw11.x);vec4 g1011=vec4(gx11.y,gy11.y,gz11.y,gw11.y);vec4 g0111=vec4(gx11.z,gy11.z,gz11.z,gw11.z);vec4 g1111=vec4(gx11.w,gy11.w,gz11.w,gw11.w);vec4 norm00=taylorInvSqrt(vec4(dot(g0000,g0000),dot(g0100,g0100),dot(g1000,g1000),dot(g1100,g1100)));g0000*=norm00.x;g0100*=norm00.y;g1000*=norm00.z;g1100*=norm00.w;vec4 norm01=taylorInvSqrt(vec4(dot(g0001,g0001),dot(g0101,g0101),dot(g1001,g1001),dot(g1101,g1101)));g0001*=norm01.x;g0101*=norm01.y;g1001*=norm01.z;g1101*=norm01.w;vec4 norm10=taylorInvSqrt(vec4(dot(g0010,g0010),dot(g0110,g0110),dot(g1010,g1010),dot(g1110,g1110)));g0010*=norm10.x;g0110*=norm10.y;g1010*=norm10.z;g1110*=norm10.w;vec4 norm11=taylorInvSqrt(vec4(dot(g0011,g0011),dot(g0111,g0111),dot(g1011,g1011),dot(g1111,g1111)));g0011*=norm11.x;g0111*=norm11.y;g1011*=norm11.z;g1111*=norm11.w;float n0000=dot(g0000,Pf0);float n1000=dot(g1000,vec4(Pf1.x,Pf0.yzw));float n0100=dot(g0100,vec4(Pf0.x,Pf1.y,Pf0.zw));float n1100=dot(g1100,vec4(Pf1.xy,Pf0.zw));float n0010=dot(g0010,vec4(Pf0.xy,Pf1.z,Pf0.w));float n1010=dot(g1010,vec4(Pf1.x,Pf0.y,Pf1.z,Pf0.w));float n0110=dot(g0110,vec4(Pf0.x,Pf1.yz,Pf0.w));float n1110=dot(g1110,vec4(Pf1.xyz,Pf0.w));float n0001=dot(g0001,vec4(Pf0.xyz,Pf1.w));float n1001=dot(g1001,vec4(Pf1.x,Pf0.yz,Pf1.w));float n0101=dot(g0101,vec4(Pf0.x,Pf1.y,Pf0.z,Pf1.w));float n1101=dot(g1101,vec4(Pf1.xy,Pf0.z,Pf1.w));float n0011=dot(g0011,vec4(Pf0.xy,Pf1.zw));float n1011=dot(g1011,vec4(Pf1.x,Pf0.y,Pf1.zw));float n0111=dot(g0111,vec4(Pf0.x,Pf1.yzw));float n1111=dot(g1111,Pf1);vec4 fade_xyzw=fade(Pf0);vec4 n_0w=mix(vec4(n0000,n1000,n0100,n1100),vec4(n0001,n1001,n0101,n1101),fade_xyzw.w);vec4 n_1w=mix(vec4(n0010,n1010,n0110,n1110),vec4(n0011,n1011,n0111,n1111),fade_xyzw.w);vec4 n_zw=mix(n_0w,n_1w,fade_xyzw.z);vec2 n_yzw=mix(n_zw.xy,n_zw.zw,fade_xyzw.y);float n_xyzw=mix(n_yzw.x,n_yzw.y,fade_xyzw.x);return 2.2*n_xyzw;}`,$l=`#define GLSLIFY 1 +vec2 rgrad2(vec2 p,float rot){float u=permute(permute(p.x)+p.y)*0.0243902439+rot;u=fract(u)*6.28318530718;return vec2(cos(u),sin(u));}vec3 psrdnoise(vec2 pos,vec2 per,float rot){pos.y+=0.01;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 xw=mod(vec3(p0.x,p1.x,p2.x),per.x);vec3 yw=mod(vec3(p0.y,p1.y,p2.y),per.y);vec3 iuw=xw+0.5*yw;vec3 ivw=yw;vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));vec3 dtdx=-2.0*vec3(d0.x,d1.x,d2.x);vec3 dtdy=-2.0*vec3(d0.y,d1.y,d2.y);if(t.x<0.0){dtdx.x=0.0;dtdy.x=0.0;t.x=0.0;}if(t.y<0.0){dtdx.y=0.0;dtdy.y=0.0;t.y=0.0;}if(t.z<0.0){dtdx.z=0.0;dtdy.z=0.0;t.z=0.0;}vec3 t2=t*t;vec3 t4=t2*t2;vec3 t3=t2*t;float n=dot(t4,w);vec2 dt0=vec2(dtdx.x,dtdy.x)*4.0*t3.x;vec2 dn0=t4.x*g0+dt0*w.x;vec2 dt1=vec2(dtdx.y,dtdy.y)*4.0*t3.y;vec2 dn1=t4.y*g1+dt1*w.y;vec2 dt2=vec2(dtdx.z,dtdy.z)*4.0*t3.z;vec2 dn2=t4.z*g2+dt2*w.z;return 11.0*vec3(n,dn0+dn1+dn2);}vec3 psdnoise(vec2 pos,vec2 per){return psrdnoise(pos,per,0.0);}float psrnoise(vec2 pos,vec2 per,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 xw=mod(vec3(p0.x,p1.x,p2.x),per.x);vec3 yw=mod(vec3(p0.y,p1.y,p2.y),per.y);vec3 iuw=xw+0.5*yw;vec3 ivw=yw;vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));t=max(t,0.0);vec3 t2=t*t;vec3 t4=t2*t2;float n=dot(t4,w);return 11.0*n;}float psnoise(vec2 pos,vec2 per){return psrnoise(pos,per,0.0);}vec3 srdnoise(vec2 pos,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 x=vec3(p0.x,p1.x,p2.x);vec3 y=vec3(p0.y,p1.y,p2.y);vec3 iuw=x+0.5*y;vec3 ivw=y;iuw=mod289(iuw);ivw=mod289(ivw);vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));vec3 dtdx=-2.0*vec3(d0.x,d1.x,d2.x);vec3 dtdy=-2.0*vec3(d0.y,d1.y,d2.y);if(t.x<0.0){dtdx.x=0.0;dtdy.x=0.0;t.x=0.0;}if(t.y<0.0){dtdx.y=0.0;dtdy.y=0.0;t.y=0.0;}if(t.z<0.0){dtdx.z=0.0;dtdy.z=0.0;t.z=0.0;}vec3 t2=t*t;vec3 t4=t2*t2;vec3 t3=t2*t;float n=dot(t4,w);vec2 dt0=vec2(dtdx.x,dtdy.x)*4.0*t3.x;vec2 dn0=t4.x*g0+dt0*w.x;vec2 dt1=vec2(dtdx.y,dtdy.y)*4.0*t3.y;vec2 dn1=t4.y*g1+dt1*w.y;vec2 dt2=vec2(dtdx.z,dtdy.z)*4.0*t3.z;vec2 dn2=t4.z*g2+dt2*w.z;return 11.0*vec3(n,dn0+dn1+dn2);}vec3 sdnoise(vec2 pos){return srdnoise(pos,0.0);}float srnoise(vec2 pos,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 x=vec3(p0.x,p1.x,p2.x);vec3 y=vec3(p0.y,p1.y,p2.y);vec3 iuw=x+0.5*y;vec3 ivw=y;iuw=mod289(iuw);ivw=mod289(ivw);vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));t=max(t,0.0);vec3 t2=t*t;vec3 t4=t2*t2;float n=dot(t4,w);return 11.0*n;}float snoise(vec2 pos){return srnoise(pos,0.0);}`,e_=`#define GLSLIFY 1 #include #include #include #include -`,e_=`#define GLSLIFY 1 -float simplex(vec2 v){const vec4 C=vec4(0.211324865405187,0.366025403784439,-0.577350269189626,0.024390243902439);vec2 i=floor(v+dot(v,C.yy));vec2 x0=v-i+dot(i,C.xx);vec2 i1;i1=(x0.x>x0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec4 x12=x0.xyxy+C.xxzz;x12.xy-=i1;i=mod289(i);vec3 p=permute(permute(i.y+vec3(0.0,i1.y,1.0))+i.x+vec3(0.0,i1.x,1.0));vec3 m=max(0.5-vec3(dot(x0,x0),dot(x12.xy,x12.xy),dot(x12.zw,x12.zw)),0.0);m=m*m;m=m*m;vec3 x=2.0*fract(p*C.www)-1.0;vec3 h=abs(x)-0.5;vec3 ox=floor(x+0.5);vec3 a0=x-ox;m*=1.79284291400159-0.85373472095314*(a0*a0+h*h);vec3 g;g.x=a0.x*x0.x+h.x*x0.y;g.yz=a0.yz*x12.xz+h.yz*x12.yw;return 130.0*dot(m,g);}`,t_=`#define GLSLIFY 1 -float simplex(vec3 v){const vec2 C=vec2(1.0/6.0,1.0/3.0);const vec4 D=vec4(0.0,0.5,1.0,2.0);vec3 i=floor(v+dot(v,C.yyy));vec3 x0=v-i+dot(i,C.xxx);vec3 g=step(x0.yzx,x0.xyz);vec3 l=1.0-g;vec3 i1=min(g.xyz,l.zxy);vec3 i2=max(g.xyz,l.zxy);vec3 x1=x0-i1+C.xxx;vec3 x2=x0-i2+C.yyy;vec3 x3=x0-D.yyy;i=mod289(i);vec4 p=permute(permute(permute(i.z+vec4(0.0,i1.z,i2.z,1.0))+i.y+vec4(0.0,i1.y,i2.y,1.0))+i.x+vec4(0.0,i1.x,i2.x,1.0));float n_=0.142857142857;vec3 ns=n_*D.wyz-D.xzx;vec4 j=p-49.0*floor(p*ns.z*ns.z);vec4 x_=floor(j*ns.z);vec4 y_=floor(j-7.0*x_);vec4 x=x_*ns.x+ns.yyyy;vec4 y=y_*ns.x+ns.yyyy;vec4 h=1.0-abs(x)-abs(y);vec4 b0=vec4(x.xy,y.xy);vec4 b1=vec4(x.zw,y.zw);vec4 s0=floor(b0)*2.0+1.0;vec4 s1=floor(b1)*2.0+1.0;vec4 sh=-step(h,vec4(0.0));vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy;vec4 a1=b1.xzyw+s1.xzyw*sh.zzww;vec3 p0=vec3(a0.xy,h.x);vec3 p1=vec3(a0.zw,h.y);vec3 p2=vec3(a1.xy,h.z);vec3 p3=vec3(a1.zw,h.w);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;vec4 m=max(0.6-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.0);m=m*m;return 42.0*dot(m*m,vec4(dot(p0,x0),dot(p1,x1),dot(p2,x2),dot(p3,x3)));}`,r_=`#define GLSLIFY 1 -float simplex(vec3 v,out vec3 gradient){const vec2 C=vec2(1.0/6.0,1.0/3.0);const vec4 D=vec4(0.0,0.5,1.0,2.0);vec3 i=floor(v+dot(v,C.yyy));vec3 x0=v-i+dot(i,C.xxx);vec3 g=step(x0.yzx,x0.xyz);vec3 l=1.0-g;vec3 i1=min(g.xyz,l.zxy);vec3 i2=max(g.xyz,l.zxy);vec3 x1=x0-i1+C.xxx;vec3 x2=x0-i2+C.yyy;vec3 x3=x0-D.yyy;i=mod289(i);vec4 p=permute(permute(permute(i.z+vec4(0.0,i1.z,i2.z,1.0))+i.y+vec4(0.0,i1.y,i2.y,1.0))+i.x+vec4(0.0,i1.x,i2.x,1.0));float n_=0.142857142857;vec3 ns=n_*D.wyz-D.xzx;vec4 j=p-49.0*floor(p*ns.z*ns.z);vec4 x_=floor(j*ns.z);vec4 y_=floor(j-7.0*x_);vec4 x=x_*ns.x+ns.yyyy;vec4 y=y_*ns.x+ns.yyyy;vec4 h=1.0-abs(x)-abs(y);vec4 b0=vec4(x.xy,y.xy);vec4 b1=vec4(x.zw,y.zw);vec4 s0=floor(b0)*2.0+1.0;vec4 s1=floor(b1)*2.0+1.0;vec4 sh=-step(h,vec4(0.0));vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy;vec4 a1=b1.xzyw+s1.xzyw*sh.zzww;vec3 p0=vec3(a0.xy,h.x);vec3 p1=vec3(a0.zw,h.y);vec3 p2=vec3(a1.xy,h.z);vec3 p3=vec3(a1.zw,h.w);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;vec4 m=max(0.6-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.0);vec4 m2=m*m;vec4 m4=m2*m2;vec4 pdotx=vec4(dot(p0,x0),dot(p1,x1),dot(p2,x2),dot(p3,x3));vec4 temp=m2*m*pdotx;gradient=-8.0*(temp.x*x0+temp.y*x1+temp.z*x2+temp.w*x3);gradient+=m4.x*p0+m4.y*p1+m4.z*p2+m4.w*p3;gradient*=42.0;return 42.0*dot(m4,pdotx);}`,n_=`#define GLSLIFY 1 +`,t_=`#define GLSLIFY 1 +float simplex(vec2 v){const vec4 C=vec4(0.211324865405187,0.366025403784439,-0.577350269189626,0.024390243902439);vec2 i=floor(v+dot(v,C.yy));vec2 x0=v-i+dot(i,C.xx);vec2 i1;i1=(x0.x>x0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec4 x12=x0.xyxy+C.xxzz;x12.xy-=i1;i=mod289(i);vec3 p=permute(permute(i.y+vec3(0.0,i1.y,1.0))+i.x+vec3(0.0,i1.x,1.0));vec3 m=max(0.5-vec3(dot(x0,x0),dot(x12.xy,x12.xy),dot(x12.zw,x12.zw)),0.0);m=m*m;m=m*m;vec3 x=2.0*fract(p*C.www)-1.0;vec3 h=abs(x)-0.5;vec3 ox=floor(x+0.5);vec3 a0=x-ox;m*=1.79284291400159-0.85373472095314*(a0*a0+h*h);vec3 g;g.x=a0.x*x0.x+h.x*x0.y;g.yz=a0.yz*x12.xz+h.yz*x12.yw;return 130.0*dot(m,g);}`,r_=`#define GLSLIFY 1 +float simplex(vec3 v){const vec2 C=vec2(1.0/6.0,1.0/3.0);const vec4 D=vec4(0.0,0.5,1.0,2.0);vec3 i=floor(v+dot(v,C.yyy));vec3 x0=v-i+dot(i,C.xxx);vec3 g=step(x0.yzx,x0.xyz);vec3 l=1.0-g;vec3 i1=min(g.xyz,l.zxy);vec3 i2=max(g.xyz,l.zxy);vec3 x1=x0-i1+C.xxx;vec3 x2=x0-i2+C.yyy;vec3 x3=x0-D.yyy;i=mod289(i);vec4 p=permute(permute(permute(i.z+vec4(0.0,i1.z,i2.z,1.0))+i.y+vec4(0.0,i1.y,i2.y,1.0))+i.x+vec4(0.0,i1.x,i2.x,1.0));float n_=0.142857142857;vec3 ns=n_*D.wyz-D.xzx;vec4 j=p-49.0*floor(p*ns.z*ns.z);vec4 x_=floor(j*ns.z);vec4 y_=floor(j-7.0*x_);vec4 x=x_*ns.x+ns.yyyy;vec4 y=y_*ns.x+ns.yyyy;vec4 h=1.0-abs(x)-abs(y);vec4 b0=vec4(x.xy,y.xy);vec4 b1=vec4(x.zw,y.zw);vec4 s0=floor(b0)*2.0+1.0;vec4 s1=floor(b1)*2.0+1.0;vec4 sh=-step(h,vec4(0.0));vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy;vec4 a1=b1.xzyw+s1.xzyw*sh.zzww;vec3 p0=vec3(a0.xy,h.x);vec3 p1=vec3(a0.zw,h.y);vec3 p2=vec3(a1.xy,h.z);vec3 p3=vec3(a1.zw,h.w);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;vec4 m=max(0.6-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.0);m=m*m;return 42.0*dot(m*m,vec4(dot(p0,x0),dot(p1,x1),dot(p2,x2),dot(p3,x3)));}`,n_=`#define GLSLIFY 1 +float simplex(vec3 v,out vec3 gradient){const vec2 C=vec2(1.0/6.0,1.0/3.0);const vec4 D=vec4(0.0,0.5,1.0,2.0);vec3 i=floor(v+dot(v,C.yyy));vec3 x0=v-i+dot(i,C.xxx);vec3 g=step(x0.yzx,x0.xyz);vec3 l=1.0-g;vec3 i1=min(g.xyz,l.zxy);vec3 i2=max(g.xyz,l.zxy);vec3 x1=x0-i1+C.xxx;vec3 x2=x0-i2+C.yyy;vec3 x3=x0-D.yyy;i=mod289(i);vec4 p=permute(permute(permute(i.z+vec4(0.0,i1.z,i2.z,1.0))+i.y+vec4(0.0,i1.y,i2.y,1.0))+i.x+vec4(0.0,i1.x,i2.x,1.0));float n_=0.142857142857;vec3 ns=n_*D.wyz-D.xzx;vec4 j=p-49.0*floor(p*ns.z*ns.z);vec4 x_=floor(j*ns.z);vec4 y_=floor(j-7.0*x_);vec4 x=x_*ns.x+ns.yyyy;vec4 y=y_*ns.x+ns.yyyy;vec4 h=1.0-abs(x)-abs(y);vec4 b0=vec4(x.xy,y.xy);vec4 b1=vec4(x.zw,y.zw);vec4 s0=floor(b0)*2.0+1.0;vec4 s1=floor(b1)*2.0+1.0;vec4 sh=-step(h,vec4(0.0));vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy;vec4 a1=b1.xzyw+s1.xzyw*sh.zzww;vec3 p0=vec3(a0.xy,h.x);vec3 p1=vec3(a0.zw,h.y);vec3 p2=vec3(a1.xy,h.z);vec3 p3=vec3(a1.zw,h.w);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;vec4 m=max(0.6-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.0);vec4 m2=m*m;vec4 m4=m2*m2;vec4 pdotx=vec4(dot(p0,x0),dot(p1,x1),dot(p2,x2),dot(p3,x3));vec4 temp=m2*m*pdotx;gradient=-8.0*(temp.x*x0+temp.y*x1+temp.z*x2+temp.w*x3);gradient+=m4.x*p0+m4.y*p1+m4.z*p2+m4.w*p3;gradient*=42.0;return 42.0*dot(m4,pdotx);}`,a_=`#define GLSLIFY 1 vec4 grad4(float j,vec4 ip){const vec4 ones=vec4(1.0,1.0,1.0,-1.0);vec4 p,s;p.xyz=floor(fract(vec3(j)*ip.xyz)*7.0)*ip.z-1.0;p.w=1.5-dot(abs(p.xyz),ones.xyz);s=vec4(lessThan(p,vec4(0.0)));p.xyz=p.xyz+(s.xyz*2.0-1.0)*s.www;return p;} #define F4 0.309016994374947451 -float simplex(vec4 v){const vec4 C=vec4(0.138196601125011,0.276393202250021,0.414589803375032,-0.447213595499958);vec4 i=floor(v+dot(v,vec4(F4)));vec4 x0=v-i+dot(i,C.xxxx);vec4 i0;vec3 isX=step(x0.yzw,x0.xxx);vec3 isYZ=step(x0.zww,x0.yyz);i0.x=isX.x+isX.y+isX.z;i0.yzw=1.0-isX;i0.y+=isYZ.x+isYZ.y;i0.zw+=1.0-isYZ.xy;i0.z+=isYZ.z;i0.w+=1.0-isYZ.z;vec4 i3=clamp(i0,0.0,1.0);vec4 i2=clamp(i0-1.0,0.0,1.0);vec4 i1=clamp(i0-2.0,0.0,1.0);vec4 x1=x0-i1+C.xxxx;vec4 x2=x0-i2+C.yyyy;vec4 x3=x0-i3+C.zzzz;vec4 x4=x0+C.wwww;i=mod289(i);float j0=permute(permute(permute(permute(i.w)+i.z)+i.y)+i.x);vec4 j1=permute(permute(permute(permute(i.w+vec4(i1.w,i2.w,i3.w,1.0))+i.z+vec4(i1.z,i2.z,i3.z,1.0))+i.y+vec4(i1.y,i2.y,i3.y,1.0))+i.x+vec4(i1.x,i2.x,i3.x,1.0));vec4 ip=vec4(1.0/294.0,1.0/49.0,1.0/7.0,0.0);vec4 p0=grad4(j0,ip);vec4 p1=grad4(j1.x,ip);vec4 p2=grad4(j1.y,ip);vec4 p3=grad4(j1.z,ip);vec4 p4=grad4(j1.w,ip);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;p4*=taylorInvSqrt(dot(p4,p4));vec3 m0=max(0.6-vec3(dot(x0,x0),dot(x1,x1),dot(x2,x2)),0.0);vec2 m1=max(0.6-vec2(dot(x3,x3),dot(x4,x4)),0.0);m0=m0*m0;m1=m1*m1;return 49.0*(dot(m0*m0,vec3(dot(p0,x0),dot(p1,x1),dot(p2,x2)))+dot(m1*m1,vec2(dot(p3,x3),dot(p4,x4))));}`,a_=`#define GLSLIFY 1 +float simplex(vec4 v){const vec4 C=vec4(0.138196601125011,0.276393202250021,0.414589803375032,-0.447213595499958);vec4 i=floor(v+dot(v,vec4(F4)));vec4 x0=v-i+dot(i,C.xxxx);vec4 i0;vec3 isX=step(x0.yzw,x0.xxx);vec3 isYZ=step(x0.zww,x0.yyz);i0.x=isX.x+isX.y+isX.z;i0.yzw=1.0-isX;i0.y+=isYZ.x+isYZ.y;i0.zw+=1.0-isYZ.xy;i0.z+=isYZ.z;i0.w+=1.0-isYZ.z;vec4 i3=clamp(i0,0.0,1.0);vec4 i2=clamp(i0-1.0,0.0,1.0);vec4 i1=clamp(i0-2.0,0.0,1.0);vec4 x1=x0-i1+C.xxxx;vec4 x2=x0-i2+C.yyyy;vec4 x3=x0-i3+C.zzzz;vec4 x4=x0+C.wwww;i=mod289(i);float j0=permute(permute(permute(permute(i.w)+i.z)+i.y)+i.x);vec4 j1=permute(permute(permute(permute(i.w+vec4(i1.w,i2.w,i3.w,1.0))+i.z+vec4(i1.z,i2.z,i3.z,1.0))+i.y+vec4(i1.y,i2.y,i3.y,1.0))+i.x+vec4(i1.x,i2.x,i3.x,1.0));vec4 ip=vec4(1.0/294.0,1.0/49.0,1.0/7.0,0.0);vec4 p0=grad4(j0,ip);vec4 p1=grad4(j1.x,ip);vec4 p2=grad4(j1.y,ip);vec4 p3=grad4(j1.z,ip);vec4 p4=grad4(j1.w,ip);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;p4*=taylorInvSqrt(dot(p4,p4));vec3 m0=max(0.6-vec3(dot(x0,x0),dot(x1,x1),dot(x2,x2)),0.0);vec2 m1=max(0.6-vec2(dot(x3,x3),dot(x4,x4)),0.0);m0=m0*m0;m1=m1*m1;return 49.0*(dot(m0*m0,vec3(dot(p0,x0),dot(p1,x1),dot(p2,x2)))+dot(m1*m1,vec2(dot(p3,x3),dot(p4,x4))));}`,i_=`#define GLSLIFY 1 #define MIN_PERCEPTUAL_ROUGHNESS 0.045 #define MIN_ROUGHNESS 0.002025 uniform float material_AlphaCutoff;uniform vec4 material_BaseColor;uniform float material_Metal;uniform float material_Roughness;uniform float material_IOR;uniform vec3 material_PBRSpecularColor;uniform float material_Glossiness;uniform vec3 material_EmissiveColor;uniform float material_NormalIntensity;uniform float material_OcclusionIntensity;uniform float material_OcclusionTextureCoord; @@ -403,7 +403,7 @@ vec3 anisotropicT;vec3 anisotropicB;vec3 anisotropicN;float anisotropy; #ifdef MATERIAL_ENABLE_CLEAR_COAT float clearCoat;float clearCoatRoughness; #endif -};`,i_=`#define GLSLIFY 1 +};`,o_=`#define GLSLIFY 1 #include float computeSpecularOcclusion(float ambientOcclusion,float roughness,float dotNV){return saturate(pow(dotNV+ambientOcclusion,exp2(-16.0*roughness-1.0))-1.0+ambientOcclusion);}float getAARoughnessFactor(vec3 normal){ #ifdef HAS_DERIVATIVES @@ -497,7 +497,7 @@ geometry.anisotropicN=getAnisotropicBentNormal(geometry,geometry.normal,material #include #include #include -`,o_=`#define GLSLIFY 1 +`,s_=`#define GLSLIFY 1 float F_Schlick(float f0,float dotLH){return f0+0.96*(pow(1.0-dotLH,5.0));}vec3 F_Schlick(vec3 specularColor,float dotLH){float fresnel=exp2((-5.55473*dotLH-6.98316)*dotLH);return(1.0-specularColor)*fresnel+specularColor;}float G_GGX_SmithCorrelated(float alpha,float dotNL,float dotNV){float a2=pow2(alpha);float gv=dotNL*sqrt(a2+(1.0-a2)*pow2(dotNV));float gl=dotNV*sqrt(a2+(1.0-a2)*pow2(dotNL));return 0.5/max(gv+gl,EPSILON);} #ifdef MATERIAL_ENABLE_ANISOTROPY float G_GGX_SmithCorrelated_Anisotropic(float at,float ab,float ToV,float BoV,float ToL,float BoL,float NoV,float NoL){float lambdaV=NoL*length(vec3(at*ToV,ab*BoV,NoV));float lambdaL=NoV*length(vec3(at*ToL,ab*BoL,NoL));return 0.5/max(lambdaV+lambdaL,EPSILON);} @@ -516,7 +516,7 @@ return anisotropicLobe(halfDir,incidentDirection,geometry,specularColor,alpha,do #else return isotropicLobe(specularColor,alpha,dotNV,dotNL,dotNH,dotLH); #endif -}vec3 BRDF_Diffuse_Lambert(vec3 diffuseColor){return RECIPROCAL_PI*diffuseColor;}`,s_=`#define GLSLIFY 1 +}vec3 BRDF_Diffuse_Lambert(vec3 diffuseColor){return RECIPROCAL_PI*diffuseColor;}`,c_=`#define GLSLIFY 1 #include void addDirectRadiance(vec3 incidentDirection,vec3 color,Geometry geometry,Material material,inout ReflectedLight reflectedLight){float attenuation=1.0; #ifdef MATERIAL_ENABLE_CLEAR_COAT @@ -550,7 +550,7 @@ PointLight pointLight;for(int i=0;i=normalizedAge){vec2 lastKey=keys[i-1];float lastTime=lastKey.x;float age=(normalizedAge-lastTime)/(time-lastTime);value=mix(lastKey.y,key.y,age);break;}}return value;}float evaluateParticleCurveCumulative(in vec2 keys[4],in float normalizedAge){float cumulativeValue=0.0;for(int i=1;i<4;i++){vec2 key=keys[i];float time=key.x;vec2 lastKey=keys[i-1];float lastValue=lastKey.y;if(time>=normalizedAge){float lastTime=lastKey.x;float offsetTime=normalizedAge-lastTime;float age=offsetTime/(time-lastTime);cumulativeValue+=(lastValue+mix(lastValue,key.y,age))*0.5*offsetTime;break;}else{cumulativeValue+=(lastValue+key.y)*0.5*(time-lastKey.x);}}return cumulativeValue;}`,m_=`#define GLSLIFY 1 +`,g_={ShadowCoord:h_,ShadowFragmentDeclaration:d_,shadow_sample_tent:f_,ShadowVertexDeclaration:v_,ShadowVertex:p_},m_=`#define GLSLIFY 1 +vec3 rotationByEuler(in vec3 vector,in vec3 rot){float halfRoll=rot.z*0.5;float halfPitch=rot.x*0.5;float halfYaw=rot.y*0.5;float sinRoll=sin(halfRoll);float cosRoll=cos(halfRoll);float sinPitch=sin(halfPitch);float cosPitch=cos(halfPitch);float sinYaw=sin(halfYaw);float cosYaw=cos(halfYaw);float quaX=(cosYaw*sinPitch*cosRoll)+(sinYaw*cosPitch*sinRoll);float quaY=(sinYaw*cosPitch*cosRoll)-(cosYaw*sinPitch*sinRoll);float quaZ=(cosYaw*cosPitch*sinRoll)-(sinYaw*sinPitch*cosRoll);float quaW=(cosYaw*cosPitch*cosRoll)+(sinYaw*sinPitch*sinRoll);float x=quaX+quaX;float y=quaY+quaY;float z=quaZ+quaZ;float wx=quaW*x;float wy=quaW*y;float wz=quaW*z;float xx=quaX*x;float xy=quaX*y;float xz=quaX*z;float yy=quaY*y;float yz=quaY*z;float zz=quaZ*z;return vec3(((vector.x*((1.0-yy)-zz))+(vector.y*(xy-wz)))+(vector.z*(xz+wy)),((vector.x*(xy+wz))+(vector.y*((1.0-xx)-zz)))+(vector.z*(yz-wx)),((vector.x*(xz-wy))+(vector.y*(yz+wx)))+(vector.z*((1.0-xx)-yy)));}vec3 rotationByAxis(in vec3 vector,in vec3 axis,in float angle){float halfAngle=angle*0.5;float sin=sin(halfAngle);float quaX=axis.x*sin;float quaY=axis.y*sin;float quaZ=axis.z*sin;float quaW=cos(halfAngle);float x=quaX+quaX;float y=quaY+quaY;float z=quaZ+quaZ;float wx=quaW*x;float wy=quaW*y;float wz=quaW*z;float xx=quaX*x;float xy=quaX*y;float xz=quaX*z;float yy=quaY*y;float yz=quaY*z;float zz=quaZ*z;return vec3(((vector.x*((1.0-yy)-zz))+(vector.y*(xy-wz)))+(vector.z*(xz+wy)),((vector.x*(xy+wz))+(vector.y*((1.0-xx)-zz)))+(vector.z*(yz-wx)),((vector.x*(xz-wy))+(vector.y*(yz+wx)))+(vector.z*((1.0-xx)-yy)));}vec3 rotationByQuaternions(in vec3 v,in vec4 q){return v+2.0*cross(q.xyz,cross(q.xyz,v)+q.w*v);}float evaluateParticleCurve(in vec2 keys[4],in float normalizedAge){float value;for(int i=1;i<4;i++){vec2 key=keys[i];float time=key.x;if(time>=normalizedAge){vec2 lastKey=keys[i-1];float lastTime=lastKey.x;float age=(normalizedAge-lastTime)/(time-lastTime);value=mix(lastKey.y,key.y,age);break;}}return value;}float evaluateParticleCurveCumulative(in vec2 keys[4],in float normalizedAge){float cumulativeValue=0.0;for(int i=1;i<4;i++){vec2 key=keys[i];float time=key.x;vec2 lastKey=keys[i-1];float lastValue=lastKey.y;if(time>=normalizedAge){float lastTime=lastKey.x;float offsetTime=normalizedAge-lastTime;float age=offsetTime/(time-lastTime);cumulativeValue+=(lastValue+mix(lastValue,key.y,age))*0.5*offsetTime;break;}else{cumulativeValue+=(lastValue+key.y)*0.5*(time-lastKey.x);}}return cumulativeValue;}`,y_=`#define GLSLIFY 1 #if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE) uniform int renderer_VOLSpace; #if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_RANDOM_CONSTANT) @@ -750,7 +750,7 @@ vec3 finalPosition;if(renderer_VOLSpace==0){finalPosition=rotationByQuaternions( #else vec3 finalPosition=rotationByQuaternions(a_ShapePositionStartLifeTime.xyz+startPosition,worldRotation); #endif -if(renderer_SimulationSpace==0){finalPosition=finalPosition+renderer_WorldPosition;}else if(renderer_SimulationSpace==1){finalPosition=finalPosition+a_SimulationWorldPosition;}finalPosition+=0.5*gravityVelocity*age;return finalPosition;}`,y_=`#define GLSLIFY 1 +if(renderer_SimulationSpace==0){finalPosition=finalPosition+renderer_WorldPosition;}else if(renderer_SimulationSpace==1){finalPosition=finalPosition+a_SimulationWorldPosition;}finalPosition+=0.5*gravityVelocity*age;return finalPosition;}`,x_=`#define GLSLIFY 1 #if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE) #ifdef RENDERER_ROL_CURVE_MODE uniform vec2 renderer_ROLMaxCurveZ[4]; @@ -813,7 +813,7 @@ rotation+=vec3(mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX, #endif return rotation;} #endif -`,x_=`#define GLSLIFY 1 +`,b_=`#define GLSLIFY 1 #ifdef RENDERER_SOL_CURVE_MODE uniform vec2 renderer_SOLMaxCurveX[4]; #ifdef RENDERER_SOL_IS_SEPARATE @@ -859,7 +859,7 @@ size*=vec3(mix(evaluateParticleCurve(renderer_SOLMinCurveX,normalizedAge),evalua #endif return size;} #endif -`,b_=`#define GLSLIFY 1 +`,S_=`#define GLSLIFY 1 #if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS) uniform vec4 renderer_COLMaxGradientColor[4];uniform vec2 renderer_COLMaxGradientAlpha[4]; #ifdef RENDERER_COL_RANDOM_GRADIENTS @@ -880,7 +880,7 @@ gradientColor=mix(evaluateParticleGradient(renderer_COLMinGradientColor,renderer #if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS) color*=gradientColor; #endif -return color;}`,S_=`#define GLSLIFY 1 +return color;}`,C_=`#define GLSLIFY 1 #if defined(RENDERER_TSA_FRAME_CURVE) || defined(RENDERER_TSA_FRAME_RANDOM_CURVES) uniform float renderer_TSACycles;uniform vec3 renderer_TSATillingParams;uniform vec2 renderer_TSAFrameMaxCurve[4]; #endif @@ -895,7 +895,7 @@ normalizedFrame=mix(evaluateParticleCurve(renderer_TSAFrameMinCurve,cycleNormali #endif float frame=floor(normalizedFrame*renderer_TSATillingParams.z);float totalULength=frame*renderer_TSATillingParams.x;float floorTotalULength=floor(totalULength);uv.x+=totalULength-floorTotalULength;uv.y+=floorTotalULength*renderer_TSATillingParams.y; #endif -return uv;}`,C_=`#define GLSLIFY 1 +return uv;}`,A_=`#define GLSLIFY 1 #ifdef RENDERER_MODE_SPHERE_BILLBOARD vec2 corner=a_CornerTextureCoordinate.xy+renderer_PivotOffset.xy;vec3 sideVector=normalize(cross(camera_Forward,camera_Up));vec3 upVector=normalize(cross(sideVector,camera_Forward));corner*=computeParticleSizeBillboard(a_StartSize.xy,normalizedAge); #if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE) @@ -904,7 +904,7 @@ if(renderer_ThreeDStartRotation){vec3 rotation=vec3(a_StartRotation0.xy,computeP if(renderer_ThreeDStartRotation){center+=renderer_SizeScale.xzy*rotationByEuler(corner.x*sideVector+corner.y*upVector,a_StartRotation0);}else{float c=cos(a_StartRotation0.x);float s=sin(a_StartRotation0.x);mat2 rotation=mat2(c,-s,s,c);corner=rotation*corner;center+=renderer_SizeScale.xzy*(corner.x*sideVector+corner.y*upVector);} #endif #endif -`,A_=`#define GLSLIFY 1 +`,E_=`#define GLSLIFY 1 #ifdef RENDERER_MODE_STRETCHED_BILLBOARD vec2 corner=a_CornerTextureCoordinate.xy+renderer_PivotOffset.xy;vec3 velocity; #if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE) @@ -914,15 +914,15 @@ velocity=rotationByQuaternions(renderer_SizeScale*startVelocity,worldRotation)+g #endif vec3 cameraUpVector=normalize(velocity);vec3 direction=normalize(center-camera_Position);vec3 sideVector=normalize(cross(direction,normalize(velocity)));sideVector=renderer_SizeScale.xzy*sideVector;cameraUpVector=length(vec3(renderer_SizeScale.x,0.0,0.0))*cameraUpVector;vec2 size=computeParticleSizeBillboard(a_StartSize.xy,normalizedAge);const mat2 rotationZHalfPI=mat2(0.0,-1.0,1.0,0.0);corner=rotationZHalfPI*corner;corner.y=corner.y-abs(corner.y);float speed=length(velocity);center+=sign(renderer_SizeScale.x)*(sign(renderer_StretchedBillboardLengthScale)*size.x*corner.x*sideVector+(speed*renderer_StretchedBillboardSpeedScale+size.y*renderer_StretchedBillboardLengthScale)*corner.y*cameraUpVector); #endif -`,E_=`#define GLSLIFY 1 +`,w_=`#define GLSLIFY 1 #ifdef RENDERER_MODE_VERTICAL_BILLBOARD vec2 corner=a_CornerTextureCoordinate.xy+renderer_PivotOffset.xy;const vec3 cameraUpVector=vec3(0.0,1.0,0.0);vec3 sideVector=normalize(cross(camera_Forward,cameraUpVector));float rot=computeParticleRotationFloat(a_StartRotation0.x,age,normalizedAge);float c=cos(rot);float s=sin(rot);mat2 rotation=mat2(c,-s,s,c);corner=rotation*corner*cos(0.78539816339744830961566084581988);corner*=computeParticleSizeBillboard(a_StartSize.xy,normalizedAge);center+=renderer_SizeScale.xzy*(corner.x*sideVector+corner.y*cameraUpVector); #endif -`,w_=`#define GLSLIFY 1 +`,T_=`#define GLSLIFY 1 #ifdef RENDERER_MODE_HORIZONTAL_BILLBOARD vec2 corner=a_CornerTextureCoordinate.xy+renderer_PivotOffset.xy;const vec3 cameraUpVector=vec3(0.0,0.0,1.0);const vec3 sideVector=vec3(-1.0,0.0,0.0);float rot=computeParticleRotationFloat(a_StartRotation0.x,age,normalizedAge);float c=cos(rot);float s=sin(rot);mat2 rotation=mat2(c,-s,s,c);corner=rotation*corner*cos(0.78539816339744830961566084581988);corner*=computeParticleSizeBillboard(a_StartSize.xy,normalizedAge);center+=renderer_SizeScale.xzy*(corner.x*sideVector+corner.y*cameraUpVector); #endif -`,T_=`#define GLSLIFY 1 +`,R_=`#define GLSLIFY 1 #ifdef RENDERER_MODE_MESH vec3 size=computeParticleSizeMesh(a_StartSize,normalizedAge); #if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE) @@ -951,7 +951,7 @@ if(renderer_SimulationSpace==1)center+=rotationByAxis(renderer_SizeScale*a_MeshP #endif v_MeshColor=a_MeshColor; #endif -`,R_={particle_common:g_,velocity_over_lifetime_module:m_,rotation_over_lifetime_module:y_,size_over_lifetime_module:x_,color_over_lifetime_module:b_,texture_sheet_animation_module:S_,sphere_billboard:C_,stretched_billboard:A_,vertical_billboard:E_,horizontal_billboard:w_,particle_mesh:T_},M_=`#define GLSLIFY 1 +`,M_={particle_common:m_,velocity_over_lifetime_module:y_,rotation_over_lifetime_module:x_,size_over_lifetime_module:b_,color_over_lifetime_module:S_,texture_sheet_animation_module:C_,sphere_billboard:A_,stretched_billboard:E_,vertical_billboard:w_,horizontal_billboard:T_,particle_mesh:R_},P_=`#define GLSLIFY 1 vec3 getNormal(bool isFrontFacing){ #ifdef RENDERER_HAS_NORMAL vec3 normal=normalize(v_normal); @@ -971,11 +971,11 @@ vec3 dp1=dFdx(position);vec3 dp2=dFdy(position);vec2 duv1=dFdx(uv);vec2 duv2=dFd mat3 tbn=mat3(vec3(0.0),vec3(0.0),normal); #endif #endif -return tbn;}`,ba=no({common:pl,common_vert:gl,transform_declare:ml,camera_declare:vl,color_share:yl,normal_share:Sl,uv_share:Cl,worldpos_share:Al,FogVertexDeclaration:bl,FogFragmentDeclaration:xl,begin_normal_vert:El,begin_position_vert:wl,position_vert:Dl,color_vert:Ml,normal_vert:Bl,skinning_vert:Ll,blendShape_input:Tl,blendShape_vert:Rl,uv_vert:Vl,worldpos_vert:Fl,FogVertex:Pl,light_frag_define:Il,mobile_material_frag:Ol,FogFragment:Nl,begin_mobile_frag:zl,begin_viewdir_frag:Ul,mobile_blinnphong_frag:kl,noise_common:ql,noise_cellular_2D:Hl,noise_cellular_2x2:Wl,noise_cellular_2x2x2:Xl,noise_cellular_3D:jl,noise_cellular:Gl,noise_perlin_2D:Ql,noise_perlin_3D:Kl,noise_perlin_4D:Jl,noise_perlin:Yl,noise_psrd_2D:Zl,noise_simplex_2D:e_,noise_simplex_3D_grad:r_,noise_simplex_3D:t_,noise_simplex_4D:n_,noise_simplex:$l},p_,__,{normal_get:M_},R_),tn=function(){function n(){}return n.parseCustomMacros=function(i){return i.map(function(t){return"#define "+t+` -`}).join("")},n.registerInclude=function(i,t){if(ba[i])throw'The "'+i+'" shader include already exist';ba[i]=t},n.unRegisterInclude=function(i){delete ba[i]},n.parseIncludes=function(i,t){t===void 0&&(t=/^[ \t]*#include +<([\w\d.]+)>/gm);var e=function(a,o){var c=ba[o];return c===void 0?(ve.error('Shader slice "'+a.trim()+'" not founded.'),""):n.parseIncludes(c,t)};return i.replace(t,e)},n.convertTo300=function(i,t){if(i=i.replace(/\bvarying\b/g,t?"in":"out"),i=i.replace(/\btexture(2D|Cube)\b/g,"texture"),i=i.replace(/\btexture2DProj\b/g,"textureProj"),t){if(i=i.replace(/\btexture(2D|Cube)LodEXT\b/g,"textureLod"),i=i.replace(/\btexture(2D|Cube)GradEXT\b/g,"textureGrad"),i=i.replace(/\btexture2DProjLodEXT\b/g,"textureProjLod"),i=i.replace(/\btexture2DProjGradEXT\b/g,"textureProjGrad"),i=i.replace(/\bgl_FragDepthEXT\b/g,"gl_FragDepth"),!n._has300Output(i)){var e=/\bgl_FragData\[.+?\]/g.test(i);if(e){i=i.replace(/\bgl_FragColor\b/g,"gl_FragData[0]");var r=i.match(/\bgl_FragData\[.+?\]/g);i=this._replaceMRTShader(i,r)}else i=i.replace(/void\s+?main\s*\(/g,`out vec4 glFragColor; +return tbn;}`,Ca=io({common:gl,common_vert:ml,transform_declare:yl,camera_declare:pl,color_share:xl,normal_share:Cl,uv_share:Al,worldpos_share:El,FogVertexDeclaration:Sl,FogFragmentDeclaration:bl,begin_normal_vert:wl,begin_position_vert:Tl,position_vert:Ll,color_vert:Pl,normal_vert:Dl,skinning_vert:Vl,blendShape_input:Rl,blendShape_vert:Ml,uv_vert:Fl,worldpos_vert:Nl,FogVertex:Bl,light_frag_define:Ol,mobile_material_frag:zl,FogFragment:Il,begin_mobile_frag:Ul,begin_viewdir_frag:kl,mobile_blinnphong_frag:Gl,noise_common:Yl,noise_cellular_2D:Wl,noise_cellular_2x2:Xl,noise_cellular_2x2x2:jl,noise_cellular_3D:ql,noise_cellular:Hl,noise_perlin_2D:Kl,noise_perlin_3D:Jl,noise_perlin_4D:Zl,noise_perlin:Ql,noise_psrd_2D:$l,noise_simplex_2D:t_,noise_simplex_3D_grad:n_,noise_simplex_3D:r_,noise_simplex_4D:a_,noise_simplex:e_},g_,u_,{normal_get:P_},M_),tn=function(){function n(){}return n.parseCustomMacros=function(i){return i.map(function(t){return"#define "+t+` +`}).join("")},n.registerInclude=function(i,t){if(Ca[i])throw'The "'+i+'" shader include already exist';Ca[i]=t},n.unRegisterInclude=function(i){delete Ca[i]},n.parseIncludes=function(i,t){t===void 0&&(t=/^[ \t]*#include +<([\w\d.]+)>/gm);var e=function(a,o){var c=Ca[o];return c===void 0?(ve.error('Shader slice "'+a.trim()+'" not founded.'),""):n.parseIncludes(c,t)};return i.replace(t,e)},n.convertTo300=function(i,t){if(i=i.replace(/\bvarying\b/g,t?"in":"out"),i=i.replace(/\btexture(2D|Cube)\b/g,"texture"),i=i.replace(/\btexture2DProj\b/g,"textureProj"),t){if(i=i.replace(/\btexture(2D|Cube)LodEXT\b/g,"textureLod"),i=i.replace(/\btexture(2D|Cube)GradEXT\b/g,"textureGrad"),i=i.replace(/\btexture2DProjLodEXT\b/g,"textureProjLod"),i=i.replace(/\btexture2DProjGradEXT\b/g,"textureProjGrad"),i=i.replace(/\bgl_FragDepthEXT\b/g,"gl_FragDepth"),!n._has300Output(i)){var e=/\bgl_FragData\[.+?\]/g.test(i);if(e){i=i.replace(/\bgl_FragColor\b/g,"gl_FragData[0]");var r=i.match(/\bgl_FragData\[.+?\]/g);i=this._replaceMRTShader(i,r)}else i=i.replace(/void\s+?main\s*\(/g,`out vec4 glFragColor; void main(`),i=i.replace(/\bgl_FragColor\b/g,"glFragColor")}}else i=i.replace(/\battribute\b/g,"in");return i},n._has300Output=function(i){return n._has300OutInFragReg.test(i)},n._replaceMRTShader=function(i,t){for(var e="",r=new Set,a=0;a0&&this._groupingSubOtherUniforms(e,!1),r.length>0&&this._groupingSubOtherUniforms(r,!0)},s.bind=function(){var t=this._engine._hardwareRenderer;return t._currentBindShaderProgram!==this?(this._gl.useProgram(this._glProgram),t._currentBindShaderProgram=this,!0):!1},s.destroy=function(){var t=this._gl;this._glProgram&&t.deleteProgram(this._glProgram)},s._groupingSubOtherUniforms=function(t,e){for(var r=t.length-1;r>=0;r--){var a=t[r],o=O._getShaderPropertyGroup(a.name);o!==void 0&&(t.splice(t.indexOf(a),1),this._groupingUniform(a,o,e))}},s._groupingUniform=function(t,e,r){switch(e){case yr.Scene:r?this.sceneUniformBlock.textureUniforms.push(t):this.sceneUniformBlock.constUniforms.push(t);break;case yr.Camera:r?this.cameraUniformBlock.textureUniforms.push(t):this.cameraUniformBlock.constUniforms.push(t);break;case yr.Renderer:r?this.rendererUniformBlock.textureUniforms.push(t):this.rendererUniformBlock.constUniforms.push(t);break;case yr.Material:r?this.materialUniformBlock.textureUniforms.push(t):this.materialUniformBlock.constUniforms.push(t);break;default:r?this.otherUniformBlock.textureUniforms.push(t):this.otherUniformBlock.constUniforms.push(t)}},s._createProgram=function(t,e){var r=this._gl,a=this._createShader(r.VERTEX_SHADER,t);if(!a)return null;var o=this._createShader(r.FRAGMENT_SHADER,e);if(!o)return null;var c=r.createProgram();return c?(r.attachShader(c,a),r.attachShader(c,o),r.linkProgram(c),r.validateProgram(c),r.deleteShader(a),r.deleteShader(o),ve.isEnabled&&!r.getProgramParameter(c,r.LINK_STATUS)&&!r.isContextLost()?(ve.error(`Could not link WebGL program +`}).join("")})();(function(){tn._has300OutInFragReg=/\bout\s+(?:\w+\s+)?(?:vec4)\s+(?:\w+)\s*;/})();var sn=function(){function n(s){this.name=s,this._uniqueId=n._nameCounter++}return n.getByName=function(i){var t,e,r=n._nameMap;return(t=r)[e=i]||(t[e]=new n(i))},n}();(function(){sn._nameCounter=0})();(function(){sn._nameMap=Object.create(null)})();var Sc=function(){function n(){this._tagsMap=Object.create(null)}var s=n.prototype;return s.setTag=function(t,e){var r=typeof t=="string"?sn.getByName(t):t,a=this._tagsMap;a[r._uniqueId]!==void 0&&ve.warn('The value of tag named "'+r.name+'" is being replaced.'),a[r._uniqueId]=e},s.deleteTag=function(t){delete this._tagsMap[(typeof t=="string"?sn.getByName(t):t)._uniqueId]},s.getTagValue=function(t){return this._tagsMap[typeof t=="string"?sn.getByName(t)._uniqueId:t._uniqueId]},j(n,[{key:"name",get:function(){return this._name}}]),n}(),or;(function(n){n[n.Linear=0]="Linear",n[n.Gamma=1]="Gamma"})(or||(or={}));var B_=function(){function n(i){this.textureUseCompareMode=!1;var t=i._hardwareRenderer;this._rhi=t,this._gl=t.gl,this._colorSpace=i.settings.colorSpace}var s=n.prototype;return s.upload1f=function(t,e){this.cacheValue!==e&&(this._gl.uniform1f(t.location,e),this.cacheValue=e)},s.upload1fv=function(t,e){this._gl.uniform1fv(t.location,e)},s.upload2f=function(t,e){var r=this.cacheValue;e.r!==void 0?(r.x!==e.r||r.y!==e.g)&&(this._colorSpace===or.Linear?this._gl.uniform2f(t.location,q.gammaToLinearSpace(e.r),q.gammaToLinearSpace(e.g)):this._gl.uniform2f(t.location,e.r,e.g),r.x=e.r,r.y=e.g):(r.x!==e.x||r.y!==e.y)&&(this._gl.uniform2f(t.location,e.x,e.y),r.x=e.x,r.y=e.y)},s.upload2fv=function(t,e){this._gl.uniform2fv(t.location,e)},s.upload3f=function(t,e){var r=this.cacheValue;e.r!==void 0?(r.x!==e.r||r.y!==e.g||r.z!==e.b)&&(this._colorSpace===or.Linear?this._gl.uniform3f(t.location,q.gammaToLinearSpace(e.r),q.gammaToLinearSpace(e.g),q.gammaToLinearSpace(e.b)):this._gl.uniform3f(t.location,e.r,e.g,e.b),r.x=e.r,r.y=e.g,r.z=e.b):(r.x!==e.x||r.y!==e.y||r.z!==e.z)&&(this._gl.uniform3f(t.location,e.x,e.y,e.z),r.x=e.x,r.y=e.y,r.z=e.z)},s.upload3fv=function(t,e){this._gl.uniform3fv(t.location,e)},s.upload4f=function(t,e){var r=this.cacheValue;e.r!==void 0?(r.x!==e.r||r.y!==e.g||r.z!==e.b||r.w!==e.a)&&(this._colorSpace===or.Linear?this._gl.uniform4f(t.location,q.gammaToLinearSpace(e.r),q.gammaToLinearSpace(e.g),q.gammaToLinearSpace(e.b),e.a):this._gl.uniform4f(t.location,e.r,e.g,e.b,e.a),r.x=e.r,r.y=e.g,r.z=e.b,r.w=e.a):(r.x!==e.x||r.y!==e.y||r.z!==e.z||r.w!==e.w)&&(this._gl.uniform4f(t.location,e.x,e.y,e.z,e.w),r.x=e.x,r.y=e.y,r.z=e.z,r.w=e.w)},s.upload4fv=function(t,e){this._gl.uniform4fv(t.location,e)},s.upload1i=function(t,e){this.cacheValue!==e&&(this._gl.uniform1i(t.location,e),this.cacheValue=e)},s.upload1iv=function(t,e){this._gl.uniform1iv(t.location,e)},s.upload2i=function(t,e){var r=this.cacheValue;e.r!==void 0?(r.x!==e.r||r.y!==e.g)&&(this._gl.uniform2i(t.location,e.r,e.g),r.x=e.r,r.y=e.g):(r.x!==e.x||r.y!==e.y)&&(this._gl.uniform2i(t.location,e.x,e.y),r.x=e.x,r.y=e.y)},s.upload2iv=function(t,e){this._gl.uniform2iv(t.location,e)},s.upload3i=function(t,e){var r=this.cacheValue;e.r!==void 0?(r.x!==e.r||r.y!==e.g||r.z!==e.b)&&(this._gl.uniform3i(t.location,e.r,e.g,e.b),r.x=e.r,r.y=e.g,r.z=e.b):(r.x!==e.x||r.y!==e.y||r.z!==e.z)&&(this._gl.uniform3i(t.location,e.x,e.y,e.z),r.x=e.x,r.y=e.y,r.z=e.z)},s.upload3iv=function(t,e){this._gl.uniform3iv(t.location,e)},s.upload4i=function(t,e){var r=this.cacheValue;e.r!==void 0?(r.x!==e.r||r.y!==e.g||r.z!==e.b||r.w!==e.a)&&(this._gl.uniform4i(t.location,e.r,e.g,e.b,e.a),r.x=e.r,r.y=e.g,r.z=e.b,r.w=e.a):(r.x!==e.x||r.y!==e.y||r.z!==e.z||r.w!==e.w)&&(this._gl.uniform4i(t.location,e.x,e.y,e.z,e.w),r.x=e.x,r.y=e.y,r.z=e.z,r.w=e.w)},s.upload4iv=function(t,e){this._gl.uniform4iv(t.location,e)},s.uploadMat4=function(t,e){this._gl.uniformMatrix4fv(t.location,!1,e.elements)},s.uploadMat4v=function(t,e){this._gl.uniformMatrix4fv(t.location,!1,e)},s.uploadTexture=function(t,e){var r=this._rhi;r.activeTexture(t.textureIndex),r.bindTexture(e._platformTexture),e._setUseDepthCompareMode(t.textureUseCompareMode)},s.uploadTextureArray=function(t,e){for(var r=this._rhi,a=t.textureIndex,o=0;o0&&this._groupingSubOtherUniforms(e,!1),r.length>0&&this._groupingSubOtherUniforms(r,!0)},s.bind=function(){var t=this._engine._hardwareRenderer;return t._currentBindShaderProgram!==this?(this._gl.useProgram(this._glProgram),t._currentBindShaderProgram=this,!0):!1},s.destroy=function(){var t=this._gl;this._glProgram&&t.deleteProgram(this._glProgram)},s._groupingSubOtherUniforms=function(t,e){for(var r=t.length-1;r>=0;r--){var a=t[r],o=O._getShaderPropertyGroup(a.name);o!==void 0&&(t.splice(t.indexOf(a),1),this._groupingUniform(a,o,e))}},s._groupingUniform=function(t,e,r){switch(e){case xr.Scene:r?this.sceneUniformBlock.textureUniforms.push(t):this.sceneUniformBlock.constUniforms.push(t);break;case xr.Camera:r?this.cameraUniformBlock.textureUniforms.push(t):this.cameraUniformBlock.constUniforms.push(t);break;case xr.Renderer:r?this.rendererUniformBlock.textureUniforms.push(t):this.rendererUniformBlock.constUniforms.push(t);break;case xr.Material:r?this.materialUniformBlock.textureUniforms.push(t):this.materialUniformBlock.constUniforms.push(t);break;default:r?this.otherUniformBlock.textureUniforms.push(t):this.otherUniformBlock.constUniforms.push(t)}},s._createProgram=function(t,e){var r=this._gl,a=this._createShader(r.VERTEX_SHADER,t);if(!a)return null;var o=this._createShader(r.FRAGMENT_SHADER,e);if(!o)return null;var c=r.createProgram();return c?(r.attachShader(c,a),r.attachShader(c,o),r.linkProgram(c),r.validateProgram(c),r.deleteShader(a),r.deleteShader(o),ve.isEnabled&&!r.getProgramParameter(c,r.LINK_STATUS)&&!r.isContextLost()?(ve.error(`Could not link WebGL program `+("Shader error: "+r.getError()+` @@ -988,9 +988,9 @@ void main(`),i=i.replace(/\bgl_FragColor\b/g,"glFragColor")}}else i=i.replace(/\ `)+(`Shader information log: `+r.getShaderInfoLog(a)+` `)+(`Shader source: -`+n._addLineNum(e))),r.deleteShader(a),null):a):(console.warn("Context lost while create shader."),null)},s._recordLocation=function(){var t=this,e=this._gl,r=this._glProgram,a=this._getUniformInfos(),o=this._getAttributeInfos();a.forEach(function(c){var l=c.name,_=c.size,u=c.type,h=new P_(t._engine),d=!1,f=!1;l.indexOf("[0]")>0&&(l=l.substr(0,l.length-3),d=!0);var v=e.getUniformLocation(r,l);switch(h.name=l,h.propertyId=O.getByName(l)._uniqueId,h.location=v,u){case e.FLOAT:d?h.applyFunc=h.upload1fv:(h.applyFunc=h.upload1f,h.cacheValue=0);break;case e.FLOAT_VEC2:d?h.applyFunc=h.upload2fv:(h.applyFunc=h.upload2f,h.cacheValue=new ee(0,0));break;case e.FLOAT_VEC3:d?h.applyFunc=h.upload3fv:(h.applyFunc=h.upload3f,h.cacheValue=new R(0,0,0));break;case e.FLOAT_VEC4:d?h.applyFunc=h.upload4fv:(h.applyFunc=h.upload4f,h.cacheValue=new ie(0,0,0,0));break;case e.BOOL:case e.INT:d?h.applyFunc=h.upload1iv:(h.applyFunc=h.upload1i,h.cacheValue=0);break;case e.BOOL_VEC2:case e.INT_VEC2:d?h.applyFunc=h.upload2iv:(h.applyFunc=h.upload2i,h.cacheValue=new ee(0,0));break;case e.BOOL_VEC3:case e.INT_VEC3:d?h.applyFunc=h.upload3iv:(h.applyFunc=h.upload3i,h.cacheValue=new R(0,0,0));break;case e.BOOL_VEC4:case e.INT_VEC4:d?h.applyFunc=h.upload4iv:(h.applyFunc=h.upload4i,h.cacheValue=new ie(0,0,0));break;case e.FLOAT_MAT4:h.applyFunc=d?h.uploadMat4v:h.uploadMat4;break;case e.SAMPLER_2D:case e.SAMPLER_CUBE:case e.UNSIGNED_INT_SAMPLER_2D:case e.SAMPLER_2D_ARRAY:case e.SAMPLER_2D_SHADOW:var p;switch(u){case e.SAMPLER_2D:p=t._engine._magentaTexture2D;break;case e.SAMPLER_CUBE:p=t._engine._magentaTextureCube;break;case e.UNSIGNED_INT_SAMPLER_2D:p=t._engine._uintMagentaTexture2D;break;case e.SAMPLER_2D_ARRAY:p=t._engine._magentaTexture2DArray;break;case e.SAMPLER_2D_SHADOW:p=t._engine._depthTexture2D,h.textureUseCompareMode=!0;break}if(f=!0,d){for(var g=new Array(_),y=new Int32Array(_),m=new Array(_),x=0;x<_;x++)g[x]=p,y[x]=t._activeTextureUint,m[x]=e.TEXTURE0+t._activeTextureUint++;h.textureDefault=g,h.textureIndex=m,h.applyFunc=h.uploadTextureArray,t.bind(),e.uniform1iv(v,y)}else{var C=e.TEXTURE0+t._activeTextureUint;h.textureDefault=p,h.textureIndex=C,h.applyFunc=h.uploadTexture,t.bind(),e.uniform1i(v,t._activeTextureUint++)}break;default:throw new Error("Unsupported uniform type")}var b=O._getShaderPropertyGroup(l);t._groupingUniform(h,b,f)}),o.forEach(function(c){var l=c.name;t.attributeLocation[l]=e.getAttribLocation(r,l)})},s._getUniformInfos=function(){for(var t=this._gl,e=this._glProgram,r=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),a=new Array(r),o=0;o0&&(l=l.substr(0,l.length-3),d=!0);var v=e.getUniformLocation(r,l);switch(h.name=l,h.propertyId=O.getByName(l)._uniqueId,h.location=v,u){case e.FLOAT:d?h.applyFunc=h.upload1fv:(h.applyFunc=h.upload1f,h.cacheValue=0);break;case e.FLOAT_VEC2:d?h.applyFunc=h.upload2fv:(h.applyFunc=h.upload2f,h.cacheValue=new ee(0,0));break;case e.FLOAT_VEC3:d?h.applyFunc=h.upload3fv:(h.applyFunc=h.upload3f,h.cacheValue=new R(0,0,0));break;case e.FLOAT_VEC4:d?h.applyFunc=h.upload4fv:(h.applyFunc=h.upload4f,h.cacheValue=new ie(0,0,0,0));break;case e.BOOL:case e.INT:d?h.applyFunc=h.upload1iv:(h.applyFunc=h.upload1i,h.cacheValue=0);break;case e.BOOL_VEC2:case e.INT_VEC2:d?h.applyFunc=h.upload2iv:(h.applyFunc=h.upload2i,h.cacheValue=new ee(0,0));break;case e.BOOL_VEC3:case e.INT_VEC3:d?h.applyFunc=h.upload3iv:(h.applyFunc=h.upload3i,h.cacheValue=new R(0,0,0));break;case e.BOOL_VEC4:case e.INT_VEC4:d?h.applyFunc=h.upload4iv:(h.applyFunc=h.upload4i,h.cacheValue=new ie(0,0,0));break;case e.FLOAT_MAT4:h.applyFunc=d?h.uploadMat4v:h.uploadMat4;break;case e.SAMPLER_2D:case e.SAMPLER_CUBE:case e.UNSIGNED_INT_SAMPLER_2D:case e.SAMPLER_2D_ARRAY:case e.SAMPLER_2D_SHADOW:var p;switch(u){case e.SAMPLER_2D:p=t._engine._magentaTexture2D;break;case e.SAMPLER_CUBE:p=t._engine._magentaTextureCube;break;case e.UNSIGNED_INT_SAMPLER_2D:p=t._engine._uintMagentaTexture2D;break;case e.SAMPLER_2D_ARRAY:p=t._engine._magentaTexture2DArray;break;case e.SAMPLER_2D_SHADOW:p=t._engine._depthTexture2D,h.textureUseCompareMode=!0;break}if(f=!0,d){for(var g=new Array(_),y=new Int32Array(_),m=new Array(_),x=0;x<_;x++)g[x]=p,y[x]=t._activeTextureUint,m[x]=e.TEXTURE0+t._activeTextureUint++;h.textureDefault=g,h.textureIndex=m,h.applyFunc=h.uploadTextureArray,t.bind(),e.uniform1iv(v,y)}else{var C=e.TEXTURE0+t._activeTextureUint;h.textureDefault=p,h.textureIndex=C,h.applyFunc=h.uploadTexture,t.bind(),e.uniform1i(v,t._activeTextureUint++)}break;default:throw new Error("Unsupported uniform type")}var b=O._getShaderPropertyGroup(l);t._groupingUniform(h,b,f)}),o.forEach(function(c){var l=c.name;t.attributeLocation[l]=e.getAttribLocation(r,l)})},s._getUniformInfos=function(){for(var t=this._gl,e=this._glProgram,r=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),a=new Array(r),o=0;o=r)return a.substring(0,r)+o;for(var l=0;l0)e[0].constructor===vt?a=new n(t,[new _i("Default",e)]):a=new n(t,e.slice());else throw"SubShader or ShaderPass count must large than 0."}else{if(!n._shaderLab)throw"ShaderLab has not been set up yet.";var c=n._shaderLab.parseShader(t);if(o[c.name]){console.error('Shader named "'+c.name+'" already exists.');return}var l=c.subShaders.map(function(u){var h=u.passes.map(function(d){if(typeof d=="string"){var f,v,p=d.split("/");return(v=n.find(p[0]))==null||(f=v.subShaders.find(function(w){return w.name===p[1]}))==null?void 0:f.passes.find(function(w){return w.name===p[2]})}var g=new vt(d.name,d.vertexSource,d.fragmentSource,d.tags),y=d.renderStates,m=new qr;g._renderState=m;var x=y[0];for(var C in x)n._applyConstRenderStates(m,parseInt(C),x[C]);var b=y[1],A={};for(var S in b)A[S]=O.getByName(b[S]);return g._renderStateDataMap=A,g});return new _i(c.name,h,u.tags)});return a=new n(c.name,l),o[c.name]=a,a}return o[t]=a,a},n.find=function(t){return n._shaderMap[t]},n._applyConstRenderStates=function(t,e,r){switch(e){case re.BlendStateEnabled0:t.blendState.targetBlendState.enabled=r;break;case re.BlendStateColorBlendOperation0:t.blendState.targetBlendState.colorBlendOperation=r;break;case re.BlendStateAlphaBlendOperation0:t.blendState.targetBlendState.alphaBlendOperation=r;break;case re.BlendStateSourceColorBlendFactor0:t.blendState.targetBlendState.sourceColorBlendFactor=r;break;case re.BlendStateDestinationColorBlendFactor0:t.blendState.targetBlendState.destinationColorBlendFactor=r;break;case re.BlendStateSourceAlphaBlendFactor0:t.blendState.targetBlendState.sourceAlphaBlendFactor=r;break;case re.BlendStateDestinationAlphaBlendFactor0:t.blendState.targetBlendState.destinationAlphaBlendFactor=r;break;case re.BlendStateColorWriteMask0:t.blendState.targetBlendState.colorWriteMask=r;break;case re.DepthStateEnabled:t.depthState.enabled=r;break;case re.DepthStateWriteEnabled:t.depthState.writeEnabled=r;break;case re.DepthStateCompareFunction:t.depthState.compareFunction=r;break;case re.StencilStateEnabled:t.stencilState.enabled=r;break;case re.StencilStateReferenceValue:t.stencilState.referenceValue=r;break;case re.StencilStateMask:t.stencilState.mask=r;break;case re.StencilStateWriteMask:t.stencilState.writeMask=r;break;case re.StencilStateCompareFunctionFront:t.stencilState.compareFunctionFront=r;break;case re.StencilStateCompareFunctionBack:t.stencilState.compareFunctionBack=r;break;case re.StencilStatePassOperationFront:t.stencilState.passOperationFront=r;break;case re.StencilStatePassOperationBack:t.stencilState.passOperationBack=r;break;case re.StencilStateFailOperationFront:t.stencilState.failOperationFront=r;break;case re.StencilStateFailOperationBack:t.stencilState.failOperationBack=r;break;case re.StencilStateZFailOperationFront:t.stencilState.zFailOperationFront=r;break;case re.StencilStateZFailOperationBack:t.stencilState.zFailOperationBack=r;break;case re.RasterStateCullMode:t.rasterState.cullMode=r;break;case re.RasterStateDepthBias:t.rasterState.depthBias=r;break;case re.RasterStateSlopeScaledDepthBias:t.rasterState.slopeScaledDepthBias=r;break;case re.RenderQueueType:t.renderQueueType=r;break}},n.getMacroByName=function(t,e){return oe.getByName(t,e)},n.getPropertyByName=function(t){return O.getByName(t)},j(n,[{key:"subShaders",get:function(){return this._subShaders}},{key:"destroyed",get:function(){return this._destroyed}}]),n}();(function(){Se._compileMacros=new Qt})();(function(){Se._shaderMap=Object.create(null)})();var zi=function(n){W(s,n);function s(t){var e;return e=n.call(this,t)||this,e._isContentLost=!1,t.resourceManager._addGraphicResource(_e(e)),e}var i=s.prototype;return i._onDestroy=function(){n.prototype._onDestroy.call(this),this.engine.resourceManager._deleteGraphicResource(this)},j(s,[{key:"isContentLost",get:function(){return this._isContentLost}}]),s}(Qr),tt;(function(n){n[n.Point=0]="Point",n[n.Bilinear=1]="Bilinear",n[n.Trilinear=2]="Trilinear"})(tt||(tt={}));var G;(function(n){n[n.R8G8B8=0]="R8G8B8",n[n.R8G8B8A8=1]="R8G8B8A8",n[n.R4G4B4A4=2]="R4G4B4A4",n[n.R5G5B5A1=3]="R5G5B5A1",n[n.R5G6B5=4]="R5G6B5",n[n.Alpha8=5]="Alpha8",n[n.LuminanceAlpha=6]="LuminanceAlpha",n[n.R16G16B16A16=7]="R16G16B16A16",n[n.R32G32B32A32=8]="R32G32B32A32",n[n.R32G32B32A32_UInt=9]="R32G32B32A32_UInt",n[n.BC1=10]="BC1",n[n.BC3=11]="BC3",n[n.BC7=12]="BC7",n[n.ETC1_RGB=13]="ETC1_RGB",n[n.ETC2_RGB=14]="ETC2_RGB",n[n.ETC2_RGBA5=15]="ETC2_RGBA5",n[n.ETC2_RGBA8=16]="ETC2_RGBA8",n[n.PVRTC_RGB2=17]="PVRTC_RGB2",n[n.PVRTC_RGBA2=18]="PVRTC_RGBA2",n[n.PVRTC_RGB4=19]="PVRTC_RGB4",n[n.PVRTC_RGBA4=20]="PVRTC_RGBA4",n[n.ASTC_4x4=21]="ASTC_4x4",n[n.ASTC_5x5=22]="ASTC_5x5",n[n.ASTC_6x6=23]="ASTC_6x6",n[n.ASTC_8x8=24]="ASTC_8x8",n[n.ASTC_10x10=25]="ASTC_10x10",n[n.ASTC_12x12=26]="ASTC_12x12",n[n.Depth=27]="Depth",n[n.Stencil=28]="Stencil",n[n.DepthStencil=29]="DepthStencil",n[n.Depth16=30]="Depth16",n[n.Depth24=31]="Depth24",n[n.Depth32=32]="Depth32",n[n.Depth24Stencil8=33]="Depth24Stencil8",n[n.Depth32Stencil8=34]="Depth32Stencil8",n[n.DXT1=10]="DXT1",n[n.DXT5=11]="DXT5"})(G||(G={}));var Wr=function(n){W(s,n);function s(){var t;return t=n.apply(this,arguments)||this,t._isDepthTexture=!1,t._anisoLevel=1,t._useDepthCompareMode=!1,t}var i=s.prototype;return i.generateMipmaps=function(){this._mipmap&&this._platformTexture.generateMipmaps()},i._setUseDepthCompareMode=function(e){this._useDepthCompareMode!==e&&(this._platformTexture.setUseDepthCompareMode(e),this._useDepthCompareMode=e)},i._rebuild=function(){var e=this._platformTexture;e.wrapModeU=this._wrapModeU,e.wrapModeV=this._wrapModeV,e.filterMode=this._filterMode,e.anisoLevel=this._anisoLevel,this._engine._hardwareRenderer._isWebGL2&&(e.depthCompareFunction=this._depthCompareFunction,e.setUseDepthCompareMode(this._useDepthCompareMode))},i._onDestroy=function(){n.prototype._onDestroy.call(this),this._platformTexture.destroy(),this._platformTexture=null},i._getMaxMiplevel=function(e){return Math.floor(Math.log2(e))},i._getMipmapCount=function(){return this._mipmap?Math.floor(Math.log2(Math.max(this._width,this._height)))+1:1},i._isIntFormat=function(){return G.R32G32B32A32_UInt===this._format},j(s,[{key:"format",get:function(){return this._format}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"usage",get:function(){return this._usage}},{key:"wrapModeU",get:function(){return this._wrapModeU},set:function(e){e!==this._wrapModeU&&(this._wrapModeU=e,this._platformTexture.wrapModeU=e)}},{key:"wrapModeV",get:function(){return this._wrapModeV},set:function(e){e!==this._wrapModeV&&(this._wrapModeV=e,this._platformTexture.wrapModeV=e)}},{key:"mipmapCount",get:function(){return this._mipmapCount}},{key:"filterMode",get:function(){return this._filterMode},set:function(e){if(e!==this._filterMode){if(e!==tt.Point&&this._isIntFormat()){e=tt.Point,ve.warn("Int or UInt format texture only support TextureFilterMode.Point");return}this._filterMode=e,this._platformTexture.filterMode=e}}},{key:"anisoLevel",get:function(){return this._anisoLevel},set:function(e){var r=this._engine._hardwareRenderer.capability.maxAnisoLevel;e>r&&(ve.warn("anisoLevel:"+e+", exceeds the limit and is automatically downgraded to:"+r),e=r),e<1&&(ve.warn("anisoLevel:"+e+", must be greater than 0, and is automatically downgraded to 1"),e=1),e!==this._anisoLevel&&(this._anisoLevel=e,this._platformTexture.anisoLevel=e)}},{key:"depthCompareFunction",get:function(){return this._depthCompareFunction},set:function(e){if(!this._engine._hardwareRenderer._isWebGL2){console.warn("depthCompareFunction only support WebGL2");return}e!==this._depthCompareFunction&&(this._depthCompareFunction=e,this._platformTexture.depthCompareFunction=e)}}]),s}(zi),Fr=function(){function n(i){this._propertyValueMap=Object.create(null),this._macroCollection=new Qt,this._macroMap=Object.create(null),this._refCount=0,this._group=i}var s=n.prototype;return s.getFloat=function(t){return this.getPropertyValue(t)},s.setFloat=function(t,e){this._setPropertyValue(t,Vt.Float,e)},s.getInt=function(t){return this.getPropertyValue(t)},s.setInt=function(t,e){this._setPropertyValue(t,Vt.Int,e)},s.getFloatArray=function(t){return this.getPropertyValue(t)},s.setFloatArray=function(t,e){this._setPropertyValue(t,Vt.FloatArray,e)},s.getIntArray=function(t){return this.getPropertyValue(t)},s.setIntArray=function(t,e){this._setPropertyValue(t,Vt.IntArray,e)},s.getVector2=function(t){return this.getPropertyValue(t)},s.setVector2=function(t,e){this._setPropertyValue(t,Vt.Vector2,e)},s.getVector3=function(t){return this.getPropertyValue(t)},s.setVector3=function(t,e){this._setPropertyValue(t,Vt.Vector3,e)},s.getVector4=function(t){return this.getPropertyValue(t)},s.setVector4=function(t,e){this._setPropertyValue(t,Vt.Vector4,e)},s.getMatrix=function(t){return this.getPropertyValue(t)},s.setMatrix=function(t,e){this._setPropertyValue(t,Vt.Matrix,e)},s.getColor=function(t){return this.getPropertyValue(t)},s.setColor=function(t,e){this._setPropertyValue(t,Vt.Color,e)},s.getTexture=function(t){return this.getPropertyValue(t)},s.setTexture=function(t,e){var r=this._refCount;if(r>0){var a=this.getPropertyValue(t);a&&a._addReferCount(-r),e&&e._addReferCount(r)}this._setPropertyValue(t,Vt.Texture,e)},s.getTextureArray=function(t){return this.getPropertyValue(t)},s.setTextureArray=function(t,e){var r=this._refCount;if(r>0){var a=this.getPropertyValue(t);if(a)for(var o=0,c=a.length;o0&&u._addReferCount(e);else if(lt(u,Array)||lt(u,Float32Array)||lt(u,Int32Array))a[_]=u.slice();else{var h=a[_];h?h.copyFrom(u):a[_]=u.clone()}else a[_]=u}},s._setPropertyValue=function(t,e,r){if(typeof t=="string"&&(t=O.getByName(t)),t._group!==this._group)if(t._group===void 0)t._group=this._group;else throw"Shader property "+t.name+" has been used as "+yr[t._group]+" group.";if(t._type!==e)if(t._type===void 0)t._type=e;else throw"Shader property "+t.name+" has been used as "+Vt[t._type]+" type.";this._propertyValueMap[t._uniqueId]=r},s._getReferCount=function(){return this._refCount},s._addReferCount=function(t){this._refCount+=t;var e=this._propertyValueMap;for(var r in e){var a=e[r];a&<(a,Wr)&&a._addReferCount(t)}},n}();T([F],Fr.prototype,"_group",void 0);T([F],Fr.prototype,"_propertyValueMap",void 0);T([F],Fr.prototype,"_macroCollection",void 0);T([F],Fr.prototype,"_macroMap",void 0);T([F],Fr.prototype,"_refCount",void 0);var Rr,ye=(Rr=function(n){W(s,n);function s(t){var e;e=n.call(this,t)||this,e._onUpdateIndex=-1,e._rendererIndex=-1,e._globalShaderMacro=new Qt,e._bounds=new cr,e._overrideUpdate=!1,e._materials=[],e._dirtyUpdateFlag=0,e._shaderData=new Fr(yr.Renderer),e._mvMatrix=new Z,e._mvpMatrix=new Z,e._mvInvMatrix=new Z,e._normalMatrix=new Z,e._materialsInstanced=[],e._priority=0,e._receiveShadows=!0,e._rendererLayer=new ie,e.castShadows=!0;var r=ye.prototype,a=e.shaderData;return e._overrideUpdate=e.update!==r.update,e._addResourceReferCount(e.shaderData,1),e._onTransformChanged=e._onTransformChanged.bind(_e(e)),e._registerEntityTransformListener(),a.enableMacro(ye._receiveShadowMacro),a.setVector4(ye._rendererLayerProperty,e._rendererLayer),e}var i=s.prototype;return i.getInstanceMaterial=function(e){e===void 0&&(e=0);var r=this._materials;if(r.length>e){var a=r[e];if(a)return this._materialsInstanced[e]?a:this._createInstanceMaterial(a,e)}return null},i.getMaterial=function(e){return e===void 0&&(e=0),this._materials[e]||null},i.setMaterial=function(e,r){r===void 0&&(r=null),typeof e=="number"?this._setMaterial(e,r):this._setMaterial(0,e)},i.getInstanceMaterials=function(){for(var e=this._materials,r=this._materialsInstanced,a=0,o=e.length;a>>16&65535,0,0)},i._updateTransformShaderData=function(e,r){var a=this.shaderData,o=this._mvMatrix,c=this._mvInvMatrix,l=this._normalMatrix;Z.multiply(e.viewMatrix,r,o),Z.invert(o,c),Z.invert(r,l),l.transpose(),a.setMatrix(ye._localMatrixProperty,this.entity.transform.localMatrix),a.setMatrix(ye._worldMatrixProperty,r),a.setMatrix(ye._mvMatrixProperty,o),a.setMatrix(ye._mvInvMatrixProperty,c),a.setMatrix(ye._normalMatrixProperty,l),this._updateMVPShaderData(e,r)},i._updateMVPShaderData=function(e,r){var a=this._mvpMatrix;Z.multiply(e.viewProjectionMatrix,r,a),this.shaderData.setMatrix(ye._mvpMatrixProperty,a)},i._registerEntityTransformListener=function(){this.entity.transform._updateFlagManager.addListener(this._onTransformChanged)},i._unRegisterEntityTransformListener=function(){this.entity.transform._updateFlagManager.removeListener(this._onTransformChanged)},i._updateBounds=function(e){},i._render=function(e){throw"not implement"},i._createInstanceMaterial=function(e,r){var a=e.clone();return a.name=a.name+"(Instance)",this._addResourceReferCount(e,-1),this._addResourceReferCount(a,1),this._materialsInstanced[r]=!0,this._materials[r]=a,a},i._setMaterial=function(e,r){var a=this._materials;e>=a.length&&(a.length=e+1);var o=a[e];if(o!==r){var c=this._materialsInstanced;ee&&(a.length=e)}},{key:"bounds",get:function(){return this._dirtyUpdateFlag&1&&(this._updateBounds(this._bounds),this._dirtyUpdateFlag&=-2),this._bounds}},{key:"priority",get:function(){return this._priority},set:function(e){this._priority=e}}]),s}(Mt),function(){Rr._tempVector0=new R}(),function(){Rr._receiveShadowMacro=oe.getByName("RENDERER_IS_RECEIVE_SHADOWS")}(),function(){Rr._localMatrixProperty=O.getByName("renderer_LocalMat")}(),function(){Rr._worldMatrixProperty=O.getByName("renderer_ModelMat")}(),function(){Rr._mvMatrixProperty=O.getByName("renderer_MVMat")}(),function(){Rr._mvpMatrixProperty=O.getByName("renderer_MVPMat")}(),function(){Rr._mvInvMatrixProperty=O.getByName("renderer_MVInvMat")}(),function(){Rr._normalMatrixProperty=O.getByName("renderer_NormalMat")}(),function(){Rr._rendererLayerProperty=O.getByName("renderer_Layer")}(),Rr);T([F],ye.prototype,"_distanceForSort",void 0);T([F],ye.prototype,"_onUpdateIndex",void 0);T([F],ye.prototype,"_rendererIndex",void 0);T([F],ye.prototype,"_globalShaderMacro",void 0);T([F],ye.prototype,"_bounds",void 0);T([F],ye.prototype,"_renderFrameCount",void 0);T([F],ye.prototype,"_overrideUpdate",void 0);T([F],ye.prototype,"_materials",void 0);T([F],ye.prototype,"_dirtyUpdateFlag",void 0);T([J],ye.prototype,"_shaderData",void 0);T([F],ye.prototype,"_mvMatrix",void 0);T([F],ye.prototype,"_mvpMatrix",void 0);T([F],ye.prototype,"_mvInvMatrix",void 0);T([F],ye.prototype,"_normalMatrix",void 0);T([F],ye.prototype,"_materialsInstanced",void 0);T([Me],ye.prototype,"_priority",void 0);T([Me],ye.prototype,"_receiveShadows",void 0);T([F],ye.prototype,"_rendererLayer",void 0);T([F],ye.prototype,"_onTransformChanged",null);ye=T([za(ge,Gn.CheckOnly)],ye);var Qe;(function(n){n[n.WorldVolume=1]="WorldVolume"})(Qe||(Qe={}));function kt(){return function(n){}}var Ka,nn=(Ka=function(){function n(){}return n.resetData=function(i){var t=i._verticesData,e=t.positions,r=t.uvs;t.vertexCount=e.length=r.length=4;for(var a=0;a<4;a++){var o,c,l,_;(o=e)[c=a]||(o[c]=new R),(l=r)[_=a]||(l[_]=new ee)}t.triangles=nn._rectangleTriangles},n.updatePositions=function(i){var t=i.width,e=i.height,r=i.sprite,a=r.pivot,o=a.x,c=a.y,l=nn._worldMatrix,_=l.elements,u=i.entity.transform.worldMatrix,h=u.elements,d=i.flipX?-t:t,f=i.flipY?-e:e;_[0]=h[0]*d,_[1]=h[1]*d,_[2]=h[2]*d,_[4]=h[4]*f,_[5]=h[5]*f,_[6]=h[6]*f,_[8]=h[8],_[9]=h[9],_[10]=h[10],_[12]=h[12]-o*_[0]-c*_[4],_[13]=h[13]-o*_[1]-c*_[5],_[14]=h[14]-o*_[2]-c*_[6];for(var v=r._getPositions(),p=i._verticesData.positions,g=0;g<4;g++){var y=v[g],m=y.x,x=y.y;p[g].set(_[0]*m+_[4]*x+_[12],_[1]*m+_[5]*x+_[13],_[2]*m+_[6]*x+_[14])}cr.transform(r._getBounds(),l,i._bounds)},n.updateUVs=function(i){var t=i.sprite._getUVs(),e=i._verticesData.uvs,r=t[0],a=r.x,o=r.y,c=t[3],l=c.x,_=c.y;e[0].set(a,o),e[1].set(l,o),e[2].set(a,_),e[3].set(l,_)},n}(),function(){Ka._rectangleTriangles=[0,1,2,2,1,3]}(),function(){Ka._worldMatrix=new Z}(),Ka);nn=T([kt()],nn);var Ja,Ta=(Ja=function(){function n(){}return n.resetData=function(i){var t=i._verticesData,e=t.positions,r=t.uvs;t.vertexCount=e.length=r.length=16;for(var a=0;a<16;a++){var o,c,l,_;(o=e)[c=a]||(o[c]=new R),(l=r)[_=a]||(l[_]=new ee)}t.triangles=Ta._rectangleTriangles},n.updatePositions=function(i){var t=i.width,e=i.height,r=i.sprite,a=i._verticesData,o=a.positions,c=a.uvs,l=r.border,_=r._getUVs(),u=r._getPositions(),h=u[0],d=h.x,f=h.y,v=u[3],p=v.x,g=v.y,y=r.width,m=r.height,x=y*l.x,C=m*l.y,b=y*l.z,A=m*l.w,S,w;if(x+b>t){var E=t/(x+b);S=[y*d*E,x*E,x*E,t-y*(1-p)*E]}else S=[y*d,x,t-b,t-y*(1-p)];if(A+C>e){var B=e/(A+C);w=[m*f*B,C*B,C*B,e-m*(1-g)*B]}else w=[m*f,C,e-A,e-m*(1-g)];var M=i.sprite.pivot,D=M.x,L=M.y,V=i.width*D,N=i.height*L,I=Ta._worldMatrix,P=I.elements,z=i.entity.transform.worldMatrix,U=z.elements,Y=i.flipX?-1:1,Q=i.flipY?-1:1;P[0]=U[0]*Y,P[1]=U[1]*Y,P[2]=U[2]*Y,P[4]=U[4]*Q,P[5]=U[5]*Q,P[6]=U[6]*Q,P[8]=U[8],P[9]=U[9],P[10]=U[10],P[12]=U[12]-V*P[0]-N*P[4],P[13]=U[13]-V*P[1]-N*P[5],P[14]=U[14]-V*P[2]-N*P[6];for(var H=0;H<4;H++)for(var te=S[H],Ce=_[H].x,de=0;de<4;de++){var ae=w[de],Ae=H*4+de;o[Ae].set(P[0]*te+P[4]*ae+P[12],P[1]*te+P[5]*ae+P[13],P[2]*te+P[6]*ae+P[14]),c[Ae].set(Ce,_[de].y)}var je=i._bounds,_t=je.min,xe=je.max;_t.set(S[0],w[0],0),xe.set(S[3],w[3],0),i._bounds.transform(I)},n.updateUVs=function(i){},n}(),function(){Ja._rectangleTriangles=[0,1,4,1,5,4,1,2,5,2,6,5,2,3,6,3,7,6,4,5,8,5,9,8,5,6,9,6,10,9,6,7,10,7,11,10,8,9,12,9,13,12,9,10,13,10,14,13,10,11,14,11,15,14]}(),function(){Ja._worldMatrix=new Z}(),Ja);Ta=T([kt()],Ta);var He=function(){function n(i){i===void 0&&(i=0),this.length=0,this._isLooping=!1,this._blankCount=0,this._elements=new Array(i)}var s=n.prototype;return s.add=function(t){this.length===this._elements.length?this._elements.push(t):this._elements[this.length]=t,this.length++},s.delete=function(t){var e=this._elements.indexOf(t);this.deleteByIndex(e)},s.set=function(t,e){if(t>=this.length)throw"Index is out of range.";this._elements[t]=e},s.get=function(t){if(t>=this.length)throw"Index is out of range.";return this._elements[t]},s.deleteByIndex=function(t){var e=this._elements,r;if(this._isLooping)this._elements[t]=null,this._blankCount++;else{var a=this.length-1;t!==a&&(r=e[a],e[t]=r),e[a]=null,this.length--}return r},s.forEach=function(t,e){this._startLoop();for(var r=this._elements,a=0,o=this.length;a=r)break e;for(;!a[r];)if(e>=--r)break e;var o=a[r];t(o,e),a[e++]=o,a[r--]=null}while(e0){var c,l;(c=o[e])==null||c.buffer._addReferCount(-a),(l=r)==null||l.buffer._addReferCount(a)}o[e]=r,this._bufferStructChanged=!0},i.setVertexBufferBindings=function(e,r){r===void 0&&(r=0);var a=this.vertexBufferBindings,o=e.length,c=r+o;a.length0&&((o=r)==null||o.buffer._addReferCount(-a)),e?(a>0&&e.buffer._addReferCount(a),this._glIndexType=fi._getGLIndexType(e.format),this._glIndexByteCount=fi._getGLIndexByteCount(e.format)):this._glIndexType=void 0,this._bufferStructChanged=((c=r)==null?void 0:c.buffer)!==((l=e)==null?void 0:l.buffer)}},i.draw=function(e,r){this._platformPrimitive.draw(e,r),this._bufferStructChanged=!1},i._addReferCount=function(e){var r;n.prototype._addReferCount.call(this,e);for(var a=this.vertexBufferBindings,o=0,c=a.length;o0&&t.deltaPositions.length!==e[r-1].deltaPositions.length)throw"Frame's deltaPositions length must same with before frame deltaPositions length.";this._frames.push(t),this._frameDataChangeListener(ao.All,t),t._dataChangeManager.addListener(this._frameDataChangeListener)},s._updateUseNormalAndTangent=function(t,e){var r=this._useBlendShapeNormal&&t,a=this._useBlendShapeTangent&&e;(this._useBlendShapeNormal!==r||this._useBlendShapeTangent!==a)&&(this._useBlendShapeNormal=r,this._useBlendShapeTangent=a,this._layoutChangeManager.dispatch(0,this))},s._frameDataChangeListener=function(t,e){this._updateUseNormalAndTangent(!!e.deltaNormals,!!e.deltaTangents),this._dataChangeManager.dispatch()},j(n,[{key:"frames",get:function(){return this._frames}}]),n}(),Ro=function(n){W(s,n);function s(){return n.apply(this,arguments)}var i=s.prototype;return i.setVertexElements=function(e){this._setVertexElements(e)},i.setVertexBufferBinding=function(e,r,a){r===void 0&&(r=0),a===void 0&&(a=0);var o=e,c=o.buffer!==void 0;c||(o=new Hn(e,r));var l=this._primitive.vertexBufferBindings;l.length<=a&&(l.length=a+1),this._setVertexBufferBinding(c?r:a,o)},i.setVertexBufferBindings=function(e,r){r===void 0&&(r=0);var a=this._primitive.vertexBufferBindings,o=e.length,c=r+o;a.length>e,this._height>>e,e,r):_===5?this._platformTexture.getPixelBuffer(e,r,a,o,0,c):_===6&&this._platformTexture.getPixelBuffer(e,r,a,o,c,l)},i._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2D(this),n.prototype._rebuild.call(this)},s}(Wr),Mo=function(n){W(s,n);function s(t,e,r,a,o,c){o===void 0&&(o=G.R8G8B8A8),c===void 0&&(c=!0);var l;return l=n.call(this,t)||this,l._mipmap=c,l._width=e,l._height=r,l._length=a,l._format=o,l._mipmapCount=l._getMipmapCount(),l._platformTexture=t._hardwareRenderer.createPlatformTexture2DArray(_e(l)),l.filterMode=tt.Bilinear,l.wrapModeU=l.wrapModeV=gt.Repeat,l}var i=s.prototype;return i.setPixelBuffer=function(e,r,a,o,c,l,_,u){a===void 0&&(a=0),o===void 0&&(o=0),c===void 0&&(c=0),this._platformTexture.setPixelBuffer(e,r,a,o,c,l,_,u),this._isContentLost=!1},i.setImageSource=function(e,r,a,o,c,l,_){a===void 0&&(a=0),o===void 0&&(o=!1),c===void 0&&(c=!1),l===void 0&&(l=0),_===void 0&&(_=0),this._platformTexture.setImageSource(e,r,a,o,c,l,_),this._isContentLost=!1},i.getPixelBuffer=function(e,r,a,o,c,l,_){var u=arguments.length;u===1?this._platformTexture.getPixelBuffer(e,0,0,this._width,this._height,0,r):u===2?this._platformTexture.getPixelBuffer(e,0,0,this._width>>r,this._height>>r,r,a):u===5?this._platformTexture.getPixelBuffer(e,r,a,o,c,0,l):u===6&&this._platformTexture.getPixelBuffer(e,r,a,o,c,l,_)},i._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2DArray(this),n.prototype._rebuild.call(this)},j(s,[{key:"length",get:function(){return this._length}}]),s}(Wr),jt=function(n){W(s,n);function s(t,e,r,a){r===void 0&&(r=G.R8G8B8A8),a===void 0&&(a=!0);var o;return o=n.call(this,t)||this,o._mipmap=a,o._width=e,o._height=e,o._format=r,o._mipmapCount=o._getMipmapCount(),o._platformTexture=t._hardwareRenderer.createPlatformTextureCube(_e(o)),o.filterMode=tt.Bilinear,o.wrapModeU=o.wrapModeV=gt.Clamp,o}var i=s.prototype;return i.setPixelBuffer=function(e,r,a,o,c,l,_){a===void 0&&(a=0),o===void 0&&(o=0),c===void 0&&(c=0),this._platformTexture.setPixelBuffer(e,r,a,o,c,l,_),this._isContentLost=!1},i.setImageSource=function(e,r,a,o,c,l,_){a===void 0&&(a=0),o===void 0&&(o=!1),c===void 0&&(c=!1),l===void 0&&(l=0),_===void 0&&(_=0),this._platformTexture.setImageSource(e,r,a,o,c,l,_),this._isContentLost=!1},i.getPixelBuffer=function(e,r,a,o,c,l,_){var u=arguments.length;u===2?this._platformTexture.getPixelBuffer(e,0,0,this._width,this._height,0,r):u===3?this._platformTexture.getPixelBuffer(e,0,0,this._width>>r,this._height>>r,r,a):u===6?this._platformTexture.getPixelBuffer(e,r,a,o,c,0,l):u===7&&this._platformTexture.getPixelBuffer(e,r,a,o,c,l,_)},i._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTextureCube(this),n.prototype._rebuild.call(this)},s}(Wr),Tn=function(){function n(i,t){this._blendShapeCount=0,this._blendShapes=[],this._subDataDirtyFlags=[],this._vertexBuffers=[],this._uniformOccupiesCount=0,this._bufferBindingOffset=-1,this._vertexElementOffset=0,this._useBlendNormal=!1,this._useBlendTangent=!1,this._vertexElementCount=0,this._storeInVertexBufferInfo=[],this._maxCountSingleVertexBuffer=0,this._lastHostCreatedInfo=new ie,this._canUseTextureStoreData=!0,this._dataTextureInfo=new R,this._engine=i,this._modelMesh=t,this._canUseTextureStoreData=this._engine._hardwareRenderer.capability.canUseFloatTextureBlendShape,this._updateLayoutChange=this._updateLayoutChange.bind(this)}var s=n.prototype;return s._addBlendShape=function(t){this._blendShapes.push(t),this._blendShapeCount++,t._layoutChangeManager.addListener(this._updateLayoutChange),this._updateLayoutChange(0,t),this._subDataDirtyFlags.push(t._dataChangeManager.createFlag(Ii))},s._clearBlendShapes=function(){for(var t=this._blendShapes,e=0,r=t.length;e0){if(t.enableMacro(n._blendShapeMacro),this._useTextureMode())t.enableMacro(n._blendShapeTextureMacro),t.setTexture(n._blendShapeTextureProperty,this._vertexTexture),t.setVector3(n._blendShapeTextureInfoProperty,this._dataTextureInfo),t.setFloatArray(n._blendShapeWeightsProperty,e.blendShapeWeights),t.enableMacro("RENDERER_BLENDSHAPE_COUNT",r.toString()),this._uniformOccupiesCount=r+1;else{var a=this._getVertexBufferModeSupportCount();if(r>a){var o=e._condensedBlendShapeWeights;o||(o=new Float32Array(a),e._condensedBlendShapeWeights=o),this._filterCondensedBlendShapeWeights(e.blendShapeWeights,o),t.setFloatArray(n._blendShapeWeightsProperty,o),this._modelMesh._primitive.enableVAO=!1,r=a}else t.setFloatArray(n._blendShapeWeightsProperty,e.blendShapeWeights),this._modelMesh._primitive.enableVAO=!0;t.disableMacro(n._blendShapeTextureMacro),t.disableMacro("RENDERER_BLENDSHAPE_COUNT"),this._uniformOccupiesCount=r}this._useBlendNormal?t.enableMacro(n._blendShapeNormalMacro):t.disableMacro(n._blendShapeNormalMacro),this._useBlendTangent?t.enableMacro(n._blendShapeTangentMacro):t.disableMacro(n._blendShapeTangentMacro)}else t.disableMacro(n._blendShapeMacro),t.disableMacro("RENDERER_BLENDSHAPE_COUNT")},s._useTextureMode=function(){return this._canUseTextureStoreData?this._blendShapeCount>this._getVertexBufferModeSupportCount():!1},s._isCreateHost=function(t){var e=this._lastHostCreatedInfo;return e.x!==this._blendShapeCount||!!e.y!==this._useBlendNormal||!!e.z!==this._useBlendTangent||e.w!==t},s._vertexElementsNeedUpdate=function(){var t=this._getVertexBufferModeSupportCount(),e=this._lastHostCreatedInfo;return Math.min(e.x,t)!==Math.min(this._blendShapeCount,t)||!!e.y!==this._useBlendNormal||!!e.z!==this._useBlendTangent},s._needUpdateData=function(){for(var t=this._subDataDirtyFlags,e=0,r=t.length;ee&&(o=Math.ceil(a/e),a=e);var c=this._vertexTexture,l=this._blendShapes.length;c&&c.destroy(),c=new Mo(this._engine,a,o,l,G.R32G32B32A32,!1),c.filterMode=tt.Point,this._vertices=new Float32Array(l*a*o*4),this._vertexTexture=c,this._dataTextureInfo.set(r,a,o)},s._updateVertexBuffers=function(t,e){for(var r=this,a=r._blendShapes,o=r._maxCountSingleVertexBuffer,c=this,l=c._vertices,_=c._vertexBuffers,u=c._storeInVertexBufferInfo,h=this._subDataDirtyFlags,d=this._vertexElementCount*3,f=d*4,v=this._bufferBindingOffset,p=0,g=a.length;p0&&C.deltaPositions.length!==t)throw"BlendShape frame deltaPositions length must same with mesh vertexCount.";var b=Math.floor(p/o),A=p%o,S=_[b],w=S.byteLength/(t*4),E=A*d,B=u[p];B||(u[p]=B=new ee),B.set(v+b,A*f);for(var M=C.deltaPositions,D=0;D0&&p.deltaPositions.length!==t)throw"BlendShape frame deltaPositions length must same with mesh vertexCount.";for(var g=p.deltaPositions,y=p.deltaNormals,m=p.deltaTangents,x=_*d,C=0;C1,a=1,o=e._useBlendShapeNormal,c=e._useBlendShapeTangent;r&&(o&&(o=this._useBlendNormal),c&&(c=this._useBlendTangent)),o&&a++,c&&a++,this._useBlendNormal=o,this._useBlendTangent=c,this._vertexElementCount=a},s._attributeModeUpdateVertexElement=function(t,e,r,a){var o=this._vertexElementOffset+this._vertexElementCount*a,c=e[r],l=c.x,_=c.y,u=t[o];if(u.bindingIndex=l,u.offset=_,this._useBlendNormal){var h=t[++o];_+=12,h.bindingIndex=l,h.offset=_}if(this._useBlendTangent){var d=t[++o];_+=12,d.bindingIndex=l,d.offset=_}},s._getVertexBufferModeSupportCount=function(){return this._useBlendNormal&&this._useBlendTangent?2:this._useBlendNormal||this._useBlendTangent?4:8},s._filterCondensedBlendShapeWeights=function(t,e){for(var r=e.length,a=this._modelMesh._primitive.vertexElements,o=this._storeInVertexBufferInfo,c=Number.POSITIVE_INFINITY,l,_=0,u=Math.min(t.length,this._blendShapeCount);_c){this._attributeModeUpdateVertexElement(a,o,_,l),e[l]=h,c=Number.POSITIVE_INFINITY;for(var d=0;d0&&m._update(e),e&&(this._accessible=!1,this._releaseCache(!1))},i.calculateTangents=function(){var e=this.getPositions(),r=this.getNormals(),a=this.getUVs();if(!r||!a)throw"Set normal and uv before calculation.";for(var o=this,c=o._indices,l=o.vertexCount,_=s._tempVec0,u=s._tempVec1,h=s._tempVec2,d=s._tempVec3,f=s._tempVec4,v=c?c.length/3:e.length/3,p=new Array(l),g=new Array(l),y=0;y0?1:-1;R.scale(U,R.dot(h,U),f),R.subtract(h,f,h),h.normalize(),Q.set(h.x,h.y,h.z,H)}this.setTangents(p)},i._setVertexBufferBinding=function(e,r){var a=this,o=this._primitive.vertexBufferBindings,c=this._vertexBufferInfos,l=function(){a._advancedDataSyncToBuffer||(c[e].dataVersion=a._dataVersionCounter++)},_=o[e];if(_&&_.buffer._dataUpdateManager.removeListener(l),n.prototype._setVertexBufferBinding.call(this,e,r),r){var u,h;r.buffer._dataUpdateManager.addListener(l),((u=c)[h=e]||(u[h]=new B_)).reset(),l()}else e+1==o.length&&o.length--},i._getVertexTypedArray=function(e,r){switch(r){case Ie.BYTE:return new Int8Array(e);case Ie.UNSIGNED_BYTE:return new Uint8Array(e);case Ie.SHORT:return new Int16Array(e);case Ie.UNSIGNED_SHORT:return new Uint16Array(e);case Ie.FLOAT:return new Float32Array(e)}},i._onDestroy=function(){n.prototype._onDestroy.call(this),this._releaseCache(!0)},i._getVertexElementData=function(e,r,a,o){var c=this._advancedVertexDataVersions,l,_=(l=c[a])!=null?l:-1,u=this._primitive._vertexElementMap[r],h=u?this._vertexBufferInfos[u.bindingIndex].dataVersion:-1;return _>=h?e:(c[a]=h,o.call(this,r))},i._beforeSetAdvancedVertexData=function(e,r,a){if(e&&e.length!==this._vertexCount)throw"The array provided needs to be the same size as vertex count.";this._updateAdvancedVertexDataMarks(r,a)},i._updateAdvancedVertexDataMarks=function(e,r){this._advancedElementUpdateFlag|=e,this._advancedDataUpdateFlag|=e,this._advancedVertexDataVersions[r]=this._dataVersionCounter++},i._updateInternalVertexBuffer=function(e){var r=this._internalVertexBufferStride,a=this.vertexCount,o=this._internalVertexBufferCreatedInfo,c=r*a;if(o.x*o.y!==c){var l=o.z;if(l!==-1){var _;(_=this._primitive.vertexBufferBindings[l])==null||_.buffer.destroy(),this._setVertexBufferBinding(l,null)}var u=this._internalVertexBufferIndex,h=r*this.vertexCount>0;if(h){this._advancedDataUpdateFlag|=this._internalVertexElementsFlags;var d=e?Je.Static:Je.Dynamic,f=new Kt(this._engine,Pt.VertexBuffer,c,d,!0);this._setVertexBufferBinding(u,new Hn(f,r))}o.set(r,a,h?u:-1)}},i._readVector2VertexData=function(e){return this._readVertexData(e,function(r,a){return new ee(r[a],r[a+1])})},i._readVector3VertexData=function(e){return this._readVertexData(e,function(r,a){return new R(r[a],r[a+1],r[a+2])})},i._readVector4VertexData=function(e){return this._readVertexData(e,function(r,a){return new ie(r[a],r[a+1],r[a+2],r[a+3])})},i._readColorVertexData=function(e){return this._readVertexData(e,function(r,a){return new q(r[a],r[a+1],r[a+2],r[a+3])})},i._readVertexData=function(e,r){var a,o=this._primitive,c=o._vertexElementMap[e];if(!c)return null;var l=o.vertexBufferBindings[c.bindingIndex],_=(a=l)==null?void 0:a.buffer;if(!_)return null;if(!_.readable)throw"Not allowed to access data while vertex buffer readable is false.";for(var u=this.vertexCount,h=c._formatMetaInfo,d=new Array(u),f=this._getVertexTypedArray(_.data.buffer,h.type),v=c.offset,p=l.stride,g=0;g=this._internalVertexElementsOffset?(this._internalVertexBufferStride-=this._getAttributeByteLength(r),this._internalVertexElementsFlags&=~a):this._internalVertexElementsOffset--,this._blendShapeManager._vertexElementOffset--,this._removeVertexElement(d)}}},i._updateAdvancedVertexElements=function(){var e=this._advancedElementUpdateFlag;e&1&&this._updateAdvancedVertexElement(this._positions,X.Position,1),e&2&&this._updateAdvancedVertexElement(this._normals,X.Normal,2),e&4&&this._updateAdvancedVertexElement(this._colors,X.Color,4),e&16&&this._updateAdvancedVertexElement(this._boneWeights,X.BoneWeight,16),e&32&&this._updateAdvancedVertexElement(this._boneIndices,X.BoneIndex,32),e&8&&this._updateAdvancedVertexElement(this._tangents,X.Tangent,8),e&64&&this._updateAdvancedVertexElement(this._uv,X.UV,64),e&128&&this._updateAdvancedVertexElement(this._uv1,X.UV1,128),e&256&&this._updateAdvancedVertexElement(this._uv2,X.UV2,256),e&512&&this._updateAdvancedVertexElement(this._uv3,X.UV3,512),e&1024&&this._updateAdvancedVertexElement(this._uv4,X.UV4,1024),e&2048&&this._updateAdvancedVertexElement(this._uv5,X.UV5,2048),e&4096&&this._updateAdvancedVertexElement(this._uv6,X.UV6,4096),e&8192&&this._updateAdvancedVertexElement(this._uv7,X.UV7,8192)},i._updateVertexElements=function(){var e=this._primitive.vertexElements,r=this._blendShapeManager,a=e.length,o=r._vertexElementOffset;this._advancedElementUpdateFlag&65535&&(this._updateAdvancedVertexElements(),this._advancedElementUpdateFlag=0);var c=!r._useTextureMode()&&r._vertexElementsNeedUpdate();if(o!==r._vertexElementOffset||c&&r._blendShapeCount>0){var l=r._addVertexElements(this);lv.dataVersion){for(var p=l._formatMetaInfo,g=this._getVertexTypedArray(h.data.buffer,p.type),y=l.offset,m=u.stride,x=g.BYTES_PER_ELEMENT,C=p.normalized,b=p.size,A=p.normalizedScaleFactor,S=0,w=this._vertexCount;S65535)if(i._hardwareRenderer.canIUse(K.elementIndexUint))r=new Uint32Array(e);else throw Error("The vertex count is over limit.");else r=new Uint16Array(e);return r},n._createCapsuleCap=function(i,t,e,r,a,o,c,l,_,u){for(var h=e+1,d=t*.5*c,f=h*h,v=e*e,p=1/h,g=1/e,y=8,m=0;m=0;u--){var h=a[u],d=u*16;h?Ue._floatMatrixMultiply(h.transform.worldMatrix,c[u].elements,0,o,d):o.set(c[u].elements,d),Ue._floatMatrixMultiply(_,o,d,o,d)}},i._updateShaderData=function(e,r){var a=this.entity,o,c=((o=this._rootBone)!=null?o:a).transform.worldMatrix;if(r){this._updateMVPShaderData(e,c);return}this._updateTransformShaderData(e,c);var l=this.shaderData,_=this.mesh,u=_._blendShapeManager;u._updateShaderData(l,this);var h=this._bones;if(h){var d=u._uniformOccupiesCount,f=h.length,v=this._jointDataCreateCache,p=f!==v.x;if(p||d!==v.y){var g=Math.ceil((this._maxVertexUniformVectors-(44+d))/4);if(f>g){var y=this.engine;if(y._hardwareRenderer.canIUseMoreJoints){if(p){var m;(m=this._jointTexture)==null||m.destroy(),this._jointTexture=new Rt(y,4,f,G.R32G32B32A32,!1),this._jointTexture.filterMode=tt.Point,this._jointTexture.isGCIgnored=!0}l.disableMacro("RENDERER_JOINTS_NUM"),l.enableMacro("RENDERER_USE_JOINT_TEXTURE"),l.setTexture(s._jointSamplerProperty,this._jointTexture)}else ve.error("component's joints count("+f+") greater than device's MAX_VERTEX_UNIFORM_VECTORS number "+this._maxVertexUniformVectors+", and don't support jointTexture in this device. suggest joint count less than "+g+".",this)}else{var x;(x=this._jointTexture)==null||x.destroy(),l.disableMacro("RENDERER_USE_JOINT_TEXTURE"),l.enableMacro("RENDERER_JOINTS_NUM",g.toString()),l.setFloatArray(s._jointMatrixProperty,this._jointMatrices)}v.set(f,d)}this._jointTexture&&this._jointTexture.setPixelBuffer(this._jointMatrices)}var C=a.layer;this._rendererLayer.set(C&65535,C>>>16&65535,0,0)},i._onDestroy=function(){var e;n.prototype._onDestroy.call(this),this._rootBone=null,this._jointDataCreateCache=null,this._skin=null,this._blendShapeWeights=null,this._localBounds=null,this._jointMatrices=null,(e=this._jointTexture)==null||e.destroy(),this._jointTexture=null,this._bones=null},i._cloneTo=function(e,r,a){n.prototype._cloneTo.call(this,e,r,a);var o=new Array;if(this.rootBone){var c=this._getEntityHierarchyPath(r,this.rootBone,o);e.rootBone=c?this._getEntityByHierarchyPath(a,o):this.rootBone}var l=this._bones;if(l){for(var _=l.length,u=new Array(_),h=0;h<_;h++){var d=l[h],f=this._getEntityHierarchyPath(r,d,o);u[h]=f?this._getEntityByHierarchyPath(a,o):d}e.bones=u}this._blendShapeWeights&&(e._blendShapeWeights=this._blendShapeWeights.slice())},i._registerEntityTransformListener=function(){var e;((e=this._rootBone)!=null?e:this._entity).transform._updateFlagManager.addListener(this._onTransformChanged)},i._unRegisterEntityTransformListener=function(){var e;((e=this._rootBone)!=null?e:this._entity).transform._updateFlagManager.removeListener(this._onTransformChanged)},i._updateBounds=function(e){if(this._rootBone){var r=this._localBounds,a=this._rootBone.transform.worldMatrix;cr.transform(r,a,e)}else n.prototype._updateBounds.call(this,e)},i._checkBlendShapeWeightLength=function(){var e=this._mesh,r=e?e.blendShapeCount:0,a=this._blendShapeWeights;if(a){var o=a.length;if(o!==r){var c=new Float32Array(r);if(r>o)c.set(a);else for(var l=0;l=0;o--)a=a.children[r[o]];return a},j(s,[{key:"blendShapeWeights",get:function(){return this._checkBlendShapeWeightLength(),this._blendShapeWeights},set:function(e){this._checkBlendShapeWeightLength();var r=this._blendShapeWeights;if(e.length<=r.length)r.set(e);else for(var a=0,o=r.length;a0?(this._jointMatrices=new Float32Array(_*16),u.enableMacro("RENDERER_HAS_SKIN"),u.setInt(s._jointCountProperty,_)):(this._jointMatrices=null,u.disableMacro("RENDERER_HAS_SKIN"))}this._bones=e}}},{key:"skin",get:function(){return this._skin},set:function(e){this._skin=e}}]),s}(Nr);(function(){Et._jointCountProperty=O.getByName("renderer_JointCount")})();(function(){Et._jointSamplerProperty=O.getByName("renderer_JointSampler")})();(function(){Et._jointMatrixProperty=O.getByName("renderer_JointMatrix")})();T([J],Et.prototype,"_localBounds",void 0);T([F],Et.prototype,"_jointDataCreateCache",void 0);T([F],Et.prototype,"_blendShapeWeights",void 0);T([F],Et.prototype,"_maxVertexUniformVectors",void 0);T([F],Et.prototype,"_rootBone",void 0);T([F],Et.prototype,"_jointMatrices",void 0);T([F],Et.prototype,"_jointTexture",void 0);T([F],Et.prototype,"_bones",void 0);T([F],Et.prototype,"_condensedBlendShapeWeights",void 0);T([F],Et.prototype,"_onLocalBoundsChanged",null);var Vn=function(){function n(i){this._elementPoolIndex=0,this._elementPool=[],this._type=i}var s=n.prototype;return s.getFromPool=function(){var t=this,e=t._elementPoolIndex,r=t._elementPool;if(this._elementPoolIndex++,r.length===e){var a=new this._type;return r.push(a),a}else return r[e]},s.resetPool=function(){this._elementPoolIndex=0},s.garbageCollection=function(){for(var t=this,e=t._elementPool,r=e.length-1;r>=0;r--)e[r].dispose&&e[r].dispose()},n}(),Br=function(){function n(i){this._subMeshPool=new Vn(Ui),this._batchedQueue=[],this._meshes=[],this._meshCount=1,this._vertexBuffers=[],this._indiceBuffers=[],this._flushId=0,this._vertexCount=0,this._elementCount=0,this._engine=i,this._initMeshes(i)}var s=n.prototype;return s.drawElement=function(t,e){var r=t.data;if(r.multiRenderData)for(var a=r.charsData,o=e.engine._renderElementPool,c=0,l=a.length;cn.MAX_VERTEX_COUNT&&this.flush(e),this._vertexCount+=r,this._batchedQueue[this._elementCount++]=t},s._createMesh=function(t,e){var r=n.MAX_VERTEX_COUNT,a=new Ro(t,"BufferMesh"+e);a._addReferCount(1);var o=[],c=this.createVertexElements(o),l=this._vertexBuffers[e]=new Kt(t,Pt.VertexBuffer,r*c,Je.Dynamic),_=this._indiceBuffers[e]=new Kt(t,Pt.IndexBuffer,r*6,Je.Dynamic);return a.setVertexBufferBinding(l,c),a.setIndexBufferBinding(_,St.UInt16),a.setVertexElements(o),a},s._updateData=function(t){var e=this,r=e._meshes,a=e._flushId;!n._canUploadSameBuffer&&this._meshCount<=a&&(this._meshCount++,r[a]=this._createMesh(t,a));var o=this,c=o._batchedQueue,l=o._vertices,_=o._indices,u=r[a];u.clearSubMesh();for(var h=0,d=0,f=0,v=0,p=0,g=0,y=null,m=0,x=c.length;m=t?(U=3,P=0):M>k.zeroTolerance?(Q=(t-B)/M,Q=Q%1>=r?Math.ceil(Q):Math.floor(Q),U=4+Q-1,P=2):(U=4,P=1),V>=e?(Y=3,z=0):N>k.zeroTolerance?(H=(e-V)/N,H=H%1>=r?Math.ceil(H):Math.floor(H),Y=4+H-1,z=2):(Y=4,z=1),(U-1)*(Y-1)*4>Br.MAX_VERTEX_COUNT){a.add(t*d),a.add(t*p),o.add(e*f),o.add(e*g),c.add(m.x),c.add(b.x),l.add(m.y),l.add(b.y),ve.warn("The number of vertices exceeds the upper limit("+Br.MAX_VERTEX_COUNT+").");return}switch(P){case 0:I=t/B,a.add(A*d*I),a.add(w*I),a.add(t-A*(1-p)*I),c.add(m.x),c.add(x.x),c.add(C.x),c.add(b.x);break;case 1:a.add(A*d),a.add(w),a.add(t-E),a.add(t-A*(1-p)),c.add(m.x),c.add(x.x),c.add(NaN),c.add(NaN),c.add(C.x),c.add(b.x);break;case 2:I=t/(B+Q*M),a.add(A*d*I),a.add(w*I),c.add(m.x),c.add(x.x),c.add(x.x);for(var te=0,Ce=Q-1;te=t?(P=3,N=0):B>k.zeroTolerance?(U=(t-E)/B,P=4+(U|0),N=2):(P=4,N=1),L>=e?(z=3,I=0):V>k.zeroTolerance?(Y=(e-L)/V,z=4+(Y|0),I=2):(z=4,I=1),(P-1)*(z-1)*4>Br.MAX_VERTEX_COUNT){r.add(t*h),r.add(t*v),a.add(e*d),a.add(e*p),o.add(y.x),o.add(C.x),c.add(y.y),c.add(C.y),ve.warn("The number of vertices exceeds the upper limit("+Br.MAX_VERTEX_COUNT+").");return}switch(N){case 0:var Q=t/E;r.add(b*h*Q),r.add(S*Q),r.add(t-b*(1-v)*Q),o.add(y.x),o.add(m.x),o.add(x.x),o.add(C.x);break;case 1:r.add(b*h),r.add(S),r.add(t-w),r.add(t-b*(1-v)),o.add(y.x),o.add(m.x),o.add(NaN),o.add(NaN),o.add(x.x),o.add(C.x);break;case 2:r.add(b*h),r.add(S),o.add(y.x),o.add(m.x),o.add(m.x);for(var H=U|0,te=0;te=u||1+d>=u)throw Error("The char fontSize is too large.");var f=this._curX+h;f>=u&&(this._curX=l,this._curY=this._nextY+l);var v=this._curY+d;if(v>this._nextY&&(this._nextY=v),v>=u)return!1;r>0&&a>0&&o&&(e.bufferOffset=new ee(this._curX,this._curY),_.setPixelBuffer(o,0,this._curX,this._curY,r,a),_.generateMipmaps());var p=1/u,g=this._curX,y=this._curY,m=r,x=a,C=g*p,b=(g+m)*p,A=y*p,S=(y+x)*p;e.x=g,e.y=y;var w=e.uvs;return w[0].set(C,A),w[1].set(b,A),w[2].set(b,S),w[3].set(C,S),this._curX+=h+l,!0},i.addCharInfo=function(e,r){this._charInfoMap[e.charCodeAt(0)]=r},i.getCharInfo=function(e){return this._charInfoMap[e.charCodeAt(0)]},i._onDestroy=function(){n.prototype._onDestroy.call(this),this.texture.destroy(),this.texture=null,this._charInfoMap={}},s}(Qr),or=function(){function n(){}return n.textContext=function(){var i=n._textContext;if(!i){var t;try{t=new OffscreenCanvas(0,0)}catch{t=document.createElement("canvas")}var e=t.getContext("2d",{willReadFrequently:!0});i={canvas:t,context:e},n._textContext=i}return i},n.measureFont=function(i){var t=n._fontSizeInfoCache,e=t[i];return e||(e=n._measureFontOrChar(i),t[i]=e,e)},n.getNativeFontString=function(i,t,e){var r=e&xn.Bold?"bold ":"";return e&xn.Italic&&(r+="italic "),!/([\"\'])[^\'\"]+\1/.test(i)&&n._genericFontFamilies.indexOf(i)==-1&&(i='"'+i+'"'),r+=t+"px "+i,r},n.measureChar=function(i,t){return n._measureFontOrChar(t,i)},n.measureTextWithWrap=function(i){var t=i._subFont,e=t.nativeFontString,r=n.measureFont(e),a=i.text.split(/(?:\r\n|\r|\n)/),o=new Array,c=new Array,l=new Array,_=hn._pixelsPerUnit,u=r.size+i.lineSpacing*_,h=i.width*_,d=0;t.nativeFontString=e;for(var f=0,v=a.length;f=19968&&L<=40959,I=D.w,P=D.offsetY,z=D.h*.5,U=z+P,Y=z-P;N?(g.length>0&&(b+y>h?(b>0&&this._pushLine(o,c,l,C,b,A,S),d=Math.max(d,b),w=!0,C=g,b=y,A=m,S=x):(C+=g,b+=y,A=Math.max(A,m),S=Math.max(S,x)),g="",y=m=x=0),b+I>h&&b>0?(this._pushLine(o,c,l,C,b,A,S),d=Math.max(d,b),w=!0,V?(C="",b=A=S=0):(C=M,b=D.xAdvance,A=U,S=Y)):(C+=M,b+=D.xAdvance,A=Math.max(A,U),S=Math.max(S,Y))):y+D.w>h?(b>0&&(this._pushLine(o,c,l,C,b,A,S),d=Math.max(d,b),C="",b=A=S=0),y>0&&this._pushLine(o,c,l,g,y,m,x),d=Math.max(d,y),w=!0,g=M,y=D.xAdvance,m=U,x=Y):(g+=M,y+=D.xAdvance,m=Math.max(m,U),x=Math.max(x,Y))}}y>0&&(b+y>h?(b>0&&this._pushLine(o,c,l,C,b,A,S),d=Math.max(d,b),b=0,y>0&&this._pushLine(o,c,l,g,y,m,x),d=Math.max(d,y)):(C+=g,b+=y,A=Math.max(A,m),S=Math.max(S,x))),b>0&&(this._pushLine(o,c,l,C,b,A,S),d=Math.max(d,b))}var Q=i.height*_;return i.overflowMode===kn.Overflow&&(Q=u*o.length),{width:d,height:Q,lines:o,lineWidths:c,lineHeight:u,lineMaxSizes:l}},n.measureTextWithoutWrap=function(i){var t=i._subFont,e=t.nativeFontString,r=n.measureFont(e),a=i.text.split(/(?:\r\n|\r|\n)/),o=a.length,c=new Array,l=new Array,_=new Array,u=hn._pixelsPerUnit,h=r.size+i.lineSpacing*u,d=0;t.nativeFontString=e;for(var f=0;f0&&(this._pushLine(c,l,_,v,p,g,y),d=Math.max(d,p))}var E=i.height*u;return i.overflowMode===kn.Overflow&&(E=h*c.length),{width:d,height:E,lines:c,lineWidths:l,lineHeight:h,lineMaxSizes:_}},n.getNativeFontHash=function(i,t,e){var r=e&xn.Bold?"bold":"";return e&xn.Italic&&(r+="italic"),!/([\"\'])[^\'\"]+\1/.test(i)&&n._genericFontFamilies.indexOf(i)==-1&&(i=""+i),r+=t+"px"+i,r},n._measureFontOrChar=function(i,t){t===void 0&&(t="");var e=n.textContext(),r=e.canvas,a=e.context;a.font=i;var o=t||n._measureString,c=Math.max(1,Math.round(a.measureText(o).width)),l=Math.ceil(a.measureText(n._measureBaseline).width),_=l*n._heightMultiplier;l=n._baselineMultiplier*l|0;var u=n._extendHeight;_+=u,l+=u*.5,r.width=c,r.height=_,a.font=i,a.fillStyle="#000",a.clearRect(0,0,c,_),a.textBaseline="middle",a.fillStyle="#fff",a.fillText(o,0,l);for(var h=a.getImageData(0,0,c,_).data,d=h.length,f=-1,v=-1,p,g=0,y=0,m=0,x=r.width,C=1/x,b=0;bv&&(v=p)}else h[b]=h[b+1]=h[b+2]=255;f!==-1&&v!==-1&&(g=l-f,y=v-l+1,m=g+y);var S={ascent:g,descent:y,size:m};if(t){var w=null;if(m>0){var E=x*4;w=new Uint8Array(h.buffer,f*E,m*E)}return{char:t,x:0,y:0,w:c,h:m,offsetX:0,offsetY:(g-y)*.5,xAdvance:c,uvs:[new ee,new ee,new ee,new ee],ascent:g,descent:y,index:0,data:w}}else return S},n._getCharInfo=function(i,t,e){var r=e._getCharInfo(i);return r||(r=n.measureChar(i,t),e._uploadCharTexture(r),e._addCharInfo(i,r)),r},n._pushLine=function(i,t,e,r,a,o,c){i.push(r),t.push(a),e.push({ascent:o,descent:c,size:o+c})},n}();(function(){or._genericFontFamilies=["serif","sans-serif","monospace","cursive","fantasy","system-ui","math","emoji","fangsong"]})();(function(){or._extendHeight=0})();(function(){or._measureString="|ÉqÅ"})();(function(){or._measureBaseline="M"})();(function(){or._heightMultiplier=2})();(function(){or._baselineMultiplier=1.4})();(function(){or._fontSizeInfoCache={}})();(function(){or._textContext=null})();var k_=function(){function n(i){this._fontAtlases=[],this._lastIndex=-1,this._engine=i}var s=n.prototype;return s.destroy=function(){for(var t=this._fontAtlases,e=0,r=t.length;e0&&p.h>0&&g){var y=p.bufferOffset;f.setPixelBuffer(g,0,y.x,y.y,p.w,p.h)}}f.generateMipmaps()},l}(xr))),r},n}(),ca=function(n){W(s,n);function s(t,e){e===void 0&&(e="");var r;return r=n.call(this,t)||this,r._name="",r._subFontMap={},r._name=e,r}var i=s.prototype;return i._getSubFont=function(e,r){var a=e+"-"+r,o=this._subFontMap,c=o[a];return c||(c=new k_(this.engine),o[a]=c,c)},i._onDestroy=function(){n.prototype._onDestroy.call(this);var e=this._subFontMap;for(var r in e)e[r].destroy();this._subFontMap=null,delete this.engine._fontMap[this._name]},s.createFromOS=function(e,r){if(r){var a=e._fontMap,o=a[r];return o||(o=new s(e,r),a[r]=o,o)}return null},j(s,[{key:"name",get:function(){return this._name}}]),s}(Qr),Rc=function n(){this.localPositions=new ie;var s=[new R,new R,new R,new R];this.renderData=new Po(4,s,null,n.triangles,null)};(function(){Rc.triangles=[0,2,1,2,0,3]})();var G_=function(){function n(i,t){this._elements=[],this._type=i;for(var e=this._elements,r=0;r0?this._elements.pop():new this._type},s.put=function(t){this._elements.push(t)},n}(),rt=function(n){W(s,n);function s(t){var e;return e=n.call(this,t)||this,e._subFont=null,e._charRenderDatas=[],e._dirtyFlag=15,e._color=new q(1,1,1,1),e._text="",e._width=0,e._height=0,e._localBounds=new cr,e._font=null,e._fontSize=24,e._fontStyle=xn.None,e._lineSpacing=0,e._horizontalAlignment=Fn.Center,e._verticalAlignment=Nn.Center,e._enableWrapping=!1,e._overflowMode=kn.Overflow,e._maskInteraction=ct.None,e._maskLayer=ia.Layer0,e._init(),e}var i=s.prototype;return i._init=function(){var e=this.engine;this._font=e._textDefaultFont,this._addResourceReferCount(this._font,1),this.setMaterial(e._spriteDefaultMaterial)},i._onDestroy=function(){this._font&&(this._addResourceReferCount(this._font,-1),this._font=null),n.prototype._onDestroy.call(this);for(var e=this._charRenderDatas,r=0,a=e.length;r0){var x=hn._pixelsPerUnit,C=this.horizontalAlignment,b=1/x,A=this.width*x,S=A*.5,w=this.height*x,E=v*.5,B=0,M=v*.5-p[0].ascent,D=v*.5-p[y-1].descent-1;switch(this.verticalAlignment){case Nn.Top:B=w*.5-E+M;break;case Nn.Center:B=h*.5-E-(D-M)*.5;break;case Nn.Bottom:B=h-w*.5-E-D;break}for(var L=-1,V=Number.MAX_SAFE_INTEGER,N=Number.MAX_SAFE_INTEGER,I=Number.MIN_SAFE_INTEGER,P=Number.MIN_SAFE_INTEGER,z=0;z0){var Y=d[z],Q=0,H=-1;switch(L<0&&(L=z),C){case Fn.Left:Q=-S;break;case Fn.Center:Q=-U*.5;break;case Fn.Right:Q=S-U;break}for(var te=0,Ce=Y.length;te0){var Ae,je;H<0&&(H=te);var _t=(Ae=l)[je=m++]||(Ae[je]=g.get()),xe=_t.renderData,$e=_t.localPositions;_t.texture=_._getTextureByIndex(ae.index),xe.color=c,xe.uvs=ae.uvs;var qe=ae.w,ut=ae.ascent,se=ae.descent,it=Q*b,tr=(Q+qe)*b,Jr=(B+ut)*b,Tr=(B-se)*b;$e.set(it,Jr,tr,Tr),z===L&&(P=Math.max(P,Jr)),N=Math.min(N,Tr),te===H&&(V=Math.min(V,it)),I=Math.max(I,tr)}Q+=ae.xAdvance}}B-=v}L<0?(r.set(0,0,0),a.set(0,0,0)):(r.set(V,N,0),a.set(I,P,0))}else r.set(0,0,0),a.set(0,0,0);var pn=l.length;if(pn>m){for(var Zr=m;Zr0&&l.sort(function(Pn,qa){return Pn.texture.instanceId-qa.texture.instanceId})},i._onTransformChanged=function(e){n.prototype._onTransformChanged.call(this,e),this._setDirtyFlagTrue(12)},i._isTextNoVisible=function(){return this._text===""||this._fontSize===0||this.enableWrapping&&this.width<=0||this.overflowMode===kn.Truncate&&this.height<=0},j(s,[{key:"color",get:function(){return this._color},set:function(e){this._color!==e&&this._color.copyFrom(e)}},{key:"text",get:function(){return this._text},set:function(e){e=e||"",this._text!==e&&(this._text=e,this._setDirtyFlagTrue(14))}},{key:"width",get:function(){return this._width},set:function(e){this._width!==e&&(this._width=e,this._setDirtyFlagTrue(14))}},{key:"height",get:function(){return this._height},set:function(e){this._height!==e&&(this._height=e,this._setDirtyFlagTrue(14))}},{key:"font",get:function(){return this._font},set:function(e){var r=this._font;r!==e&&(r&&this._addResourceReferCount(r,-1),e&&this._addResourceReferCount(e,1),this._font=e,this._setDirtyFlagTrue(15))}},{key:"fontSize",get:function(){return this._fontSize},set:function(e){this._fontSize!==e&&(this._fontSize=e,this._setDirtyFlagTrue(15))}},{key:"fontStyle",get:function(){return this._fontStyle},set:function(e){this.fontStyle!==e&&(this._fontStyle=e,this._setDirtyFlagTrue(15))}},{key:"lineSpacing",get:function(){return this._lineSpacing},set:function(e){this._lineSpacing!==e&&(this._lineSpacing=e,this._setDirtyFlagTrue(14))}},{key:"horizontalAlignment",get:function(){return this._horizontalAlignment},set:function(e){this._horizontalAlignment!==e&&(this._horizontalAlignment=e,this._setDirtyFlagTrue(14))}},{key:"verticalAlignment",get:function(){return this._verticalAlignment},set:function(e){this._verticalAlignment!==e&&(this._verticalAlignment=e,this._setDirtyFlagTrue(14))}},{key:"enableWrapping",get:function(){return this._enableWrapping},set:function(e){this._enableWrapping!==e&&(this._enableWrapping=e,this._setDirtyFlagTrue(14))}},{key:"overflowMode",get:function(){return this._overflowMode},set:function(e){this._overflowMode!==e&&(this._overflowMode=e,this._setDirtyFlagTrue(14))}},{key:"maskInteraction",get:function(){return this._maskInteraction},set:function(e){this._maskInteraction!==e&&(this._maskInteraction=e,this._setDirtyFlagTrue(16))}},{key:"maskLayer",get:function(){return this._maskLayer},set:function(e){this._maskLayer=e}},{key:"bounds",get:function(){if(this._isTextNoVisible()){if(this._isContainDirtyFlag(8)){var e=this._localBounds;e.min.set(0,0,0),e.max.set(0,0,0),this._updateBounds(this._bounds),this._setDirtyFlagFalse(8)}return this._bounds}return this._isContainDirtyFlag(1)&&this._resetSubFont(),this._isContainDirtyFlag(2)&&this._updateLocalData(),this._isContainDirtyFlag(4)&&this._updatePosition(),this._isContainDirtyFlag(8)&&this._updateBounds(this._bounds),this._setDirtyFlagFalse(15),this._bounds}}]),s}(ye);(function(){rt._charRenderDataPool=new G_(Rc,50)})();(function(){rt._tempVec30=new R})();(function(){rt._tempVec31=new R})();T([Me],rt.prototype,"_subFont",void 0);T([F],rt.prototype,"_charRenderDatas",void 0);T([F],rt.prototype,"_dirtyFlag",void 0);T([J],rt.prototype,"_color",void 0);T([Me],rt.prototype,"_text",void 0);T([Me],rt.prototype,"_width",void 0);T([Me],rt.prototype,"_height",void 0);T([F],rt.prototype,"_localBounds",void 0);T([Me],rt.prototype,"_font",void 0);T([Me],rt.prototype,"_fontSize",void 0);T([Me],rt.prototype,"_fontStyle",void 0);T([Me],rt.prototype,"_lineSpacing",void 0);T([Me],rt.prototype,"_horizontalAlignment",void 0);T([Me],rt.prototype,"_verticalAlignment",void 0);T([Me],rt.prototype,"_enableWrapping",void 0);T([Me],rt.prototype,"_overflowMode",void 0);T([Me],rt.prototype,"_maskInteraction",void 0);T([Me],rt.prototype,"_maskLayer",void 0);var es;(function(n){n[n.SubFont=1]="SubFont",n[n.LocalPositionBounds=2]="LocalPositionBounds",n[n.WorldPosition=4]="WorldPosition",n[n.WorldBounds=8]="WorldBounds",n[n.MaskInteraction=16]="MaskInteraction",n[n.Position=14]="Position",n[n.Font=15]="Font"})(es||(es={}));var In;(function(n){n[n.Normal=0]="Normal",n[n.Additive=1]="Additive"})(In||(In={}));var an;(function(n){n[n.Front=0]="Front",n[n.Back=1]="Back",n[n.Double=2]="Double"})(an||(an={}));var br=function(n){W(s,n);function s(t,e){var r;return r=n.call(this,t)||this,r._renderStates=[],r._priority=0,r._shaderData=new Fr(yr.Material),r.shader=e,r}var i=s.prototype;return i.clone=function(){var e=new s(this._engine,this.shader);return this.cloneTo(e),e},i.cloneTo=function(e){e.shader=this.shader,this.shaderData.cloneTo(e.shaderData),Cr.deepCloneObject(this.renderStates,e.renderStates)},i._addReferCount=function(e){this._destroyed||(n.prototype._addReferCount.call(this,e),this.shaderData._addReferCount(e),this._shader._addReferCount(e))},i._onDestroy=function(){n.prototype._onDestroy.call(this),this._shader=null,this._shaderData=null,this._renderStates.length=0,this._renderStates=null},j(s,[{key:"shaderData",get:function(){return this._shaderData}},{key:"shader",get:function(){return this._shader},set:function(e){var r=this._getReferCount();if(r>0){var a;(a=this._shader)==null||a._addReferCount(-r),e._addReferCount(r)}this._shader=e;for(var o=this._renderStates,c=o.length,l=0,_=e.subShaders,u=0;u<_.length;u++)l=Math.max(_[u].passes.length,l);if(c0){var a;(a=this._shader)==null||a._addReferCount(-r),e._addReferCount(r)}this._shader=e;for(var o=this._renderStates,c=o.length,l=0,_=e.subShaders,u=0;u<_.length;u++)l=Math.max(_[u].passes.length,l);if(c0?l.renderQueueType=l.blendState.targetBlendState.enabled?ft.Transparent:ft.AlphaTest:l.renderQueueType=l.blendState.targetBlendState.enabled?ft.Transparent:ft.Opaque}r.setFloat(s._alphaCutoffProp,e)}}},{key:"renderFace",get:function(){return this._renderFace},set:function(e){e!==this._renderFace&&(this.setRenderFace(0,e),this._renderFace=e)}}]),s}(br);(function(){We._baseTextureMacro=oe.getByName("MATERIAL_HAS_BASETEXTURE")})();(function(){We._normalTextureMacro=oe.getByName("MATERIAL_HAS_NORMALTEXTURE")})();(function(){We._emissiveTextureMacro=oe.getByName("MATERIAL_HAS_EMISSIVETEXTURE")})();(function(){We._transparentMacro=oe.getByName("MATERIAL_IS_TRANSPARENT")})();(function(){We._baseColorProp=O.getByName("material_BaseColor")})();(function(){We._baseTextureProp=O.getByName("material_BaseTexture")})();(function(){We._tilingOffsetProp=O.getByName("material_TilingOffset")})();(function(){We._normalTextureProp=O.getByName("material_NormalTexture")})();(function(){We._normalIntensityProp=O.getByName("material_NormalIntensity")})();(function(){We._emissiveColorProp=O.getByName("material_EmissiveColor")})();(function(){We._emissiveTextureProp=O.getByName("material_EmissiveTexture")})();(function(){We._alphaCutoffProp=O.getByName("material_AlphaCutoff")})();(function(){We._alphaCutoffMacro=oe.getByName("MATERIAL_IS_ALPHA_CUTOFF")})();var Ua=function(n){W(s,n);function s(t){var e;e=n.call(this,t,Se.find("blinn-phong"))||this;var r=e.shaderData;return r.enableMacro("MATERIAL_NEED_WORLD_POS"),r.enableMacro("MATERIAL_NEED_TILING_OFFSET"),r.setColor(s._baseColorProp,new q(1,1,1,1)),r.setColor(s._specularColorProp,new q(1,1,1,1)),r.setColor(s._emissiveColorProp,new q(0,0,0,1)),r.setVector4(s._tilingOffsetProp,new ie(1,1,0,0)),r.setFloat(s._shininessProp,16),r.setFloat(s._normalIntensityProp,1),e}var i=s.prototype;return i.clone=function(){var e=new s(this._engine);return this.cloneTo(e),e},j(s,[{key:"baseColor",get:function(){return this.shaderData.getColor(s._baseColorProp)},set:function(e){var r=this.shaderData.getColor(s._baseColorProp);e!==r&&r.copyFrom(e)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(s._baseTextureProp)},set:function(e){this.shaderData.setTexture(s._baseTextureProp,e),e?this.shaderData.enableMacro(s._baseTextureMacro):this.shaderData.disableMacro(s._baseTextureMacro)}},{key:"specularColor",get:function(){return this.shaderData.getColor(s._specularColorProp)},set:function(e){var r=this.shaderData.getColor(s._specularColorProp);e!==r&&r.copyFrom(e)}},{key:"specularTexture",get:function(){return this.shaderData.getTexture(s._specularTextureProp)},set:function(e){this.shaderData.setTexture(s._specularTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_SPECULAR_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_SPECULAR_TEXTURE")}},{key:"emissiveColor",get:function(){return this.shaderData.getColor(s._emissiveColorProp)},set:function(e){var r=this.shaderData.getColor(s._emissiveColorProp);e!==r&&r.copyFrom(e)}},{key:"emissiveTexture",get:function(){return this.shaderData.getTexture(s._emissiveTextureProp)},set:function(e){this.shaderData.setTexture(s._emissiveTextureProp,e),e?this.shaderData.enableMacro(s._emissiveTextureMacro):this.shaderData.disableMacro(s._emissiveTextureMacro)}},{key:"normalTexture",get:function(){return this.shaderData.getTexture(s._normalTextureProp)},set:function(e){this.shaderData.setTexture(s._normalTextureProp,e),e?this.shaderData.enableMacro(s._normalTextureMacro):this.shaderData.disableMacro(s._normalTextureMacro)}},{key:"normalIntensity",get:function(){return this.shaderData.getFloat(s._normalIntensityProp)},set:function(e){this.shaderData.setFloat(s._normalIntensityProp,e)}},{key:"shininess",get:function(){return this.shaderData.getFloat(s._shininessProp)},set:function(e){this.shaderData.setFloat(s._shininessProp,Math.max(e,1e-4))}},{key:"tilingOffset",get:function(){return this.shaderData.getVector4(s._tilingOffsetProp)},set:function(e){var r=this.shaderData.getVector4(s._tilingOffsetProp);e!==r&&r.copyFrom(e)}}]),s}(We);(function(){Ua._specularColorProp=O.getByName("material_SpecularColor")})();(function(){Ua._shininessProp=O.getByName("material_Shininess")})();(function(){Ua._specularTextureProp=O.getByName("material_SpecularTexture")})();var Cn;(function(n){n[n.UV0=0]="UV0",n[n.UV1=1]="UV1",n[n.UV2=2]="UV2",n[n.UV3=3]="UV3",n[n.UV4=4]="UV4",n[n.UV5=5]="UV5",n[n.UV6=6]="UV6",n[n.UV7=7]="UV7"})(Cn||(Cn={}));var Ir=function(n){W(s,n);function s(i,t){var e;e=n.call(this,i,t)||this;var r=e.shaderData;return r.enableMacro("MATERIAL_NEED_WORLD_POS"),r.enableMacro("MATERIAL_NEED_TILING_OFFSET"),r.setColor(s._baseColorProp,new q(1,1,1,1)),r.setColor(s._emissiveColorProp,new q(0,0,0,1)),r.setVector4(s._tilingOffsetProp,new ie(1,1,0,0)),r.setFloat(s._normalIntensityProp,1),r.setFloat(s._occlusionTextureIntensityProp,1),r.setFloat(s._occlusionTextureCoordProp,Cn.UV0),r.setFloat(s._clearCoatProp,0),r.setFloat(s._clearCoatRoughnessProp,0),e}return j(s,[{key:"baseColor",get:function(){return this.shaderData.getColor(s._baseColorProp)},set:function(t){var e=this.shaderData.getColor(s._baseColorProp);t!==e&&e.copyFrom(t)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(s._baseTextureProp)},set:function(t){this.shaderData.setTexture(s._baseTextureProp,t),t?this.shaderData.enableMacro(s._baseTextureMacro):this.shaderData.disableMacro(s._baseTextureMacro)}},{key:"normalTexture",get:function(){return this.shaderData.getTexture(s._normalTextureProp)},set:function(t){this.shaderData.setTexture(s._normalTextureProp,t),t?this.shaderData.enableMacro(s._normalTextureMacro):this.shaderData.disableMacro(s._normalTextureMacro)}},{key:"normalTextureIntensity",get:function(){return this.shaderData.getFloat(s._normalIntensityProp)},set:function(t){this.shaderData.setFloat(s._normalIntensityProp,t)}},{key:"emissiveColor",get:function(){return this.shaderData.getColor(s._emissiveColorProp)},set:function(t){var e=this.shaderData.getColor(s._emissiveColorProp);t!==e&&e.copyFrom(t)}},{key:"emissiveTexture",get:function(){return this.shaderData.getTexture(s._emissiveTextureProp)},set:function(t){this.shaderData.setTexture(s._emissiveTextureProp,t),t?this.shaderData.enableMacro(s._emissiveTextureMacro):this.shaderData.disableMacro(s._emissiveTextureMacro)}},{key:"occlusionTexture",get:function(){return this.shaderData.getTexture(s._occlusionTextureProp)},set:function(t){this.shaderData.setTexture(s._occlusionTextureProp,t),t?this.shaderData.enableMacro("MATERIAL_HAS_OCCLUSION_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_OCCLUSION_TEXTURE")}},{key:"occlusionTextureIntensity",get:function(){return this.shaderData.getFloat(s._occlusionTextureIntensityProp)},set:function(t){this.shaderData.setFloat(s._occlusionTextureIntensityProp,t)}},{key:"occlusionTextureCoord",get:function(){return this.shaderData.getFloat(s._occlusionTextureCoordProp)},set:function(t){t>Cn.UV1&&ve.warn("Occlusion texture uv coordinate must be UV0 or UV1."),this.shaderData.setFloat(s._occlusionTextureCoordProp,t)}},{key:"tilingOffset",get:function(){return this.shaderData.getVector4(s._tilingOffsetProp)},set:function(t){var e=this.shaderData.getVector4(s._tilingOffsetProp);t!==e&&e.copyFrom(t)}},{key:"clearCoat",get:function(){return this.shaderData.getFloat(s._clearCoatProp)},set:function(t){!!this.shaderData.getFloat(s._clearCoatProp)!=!!t&&(t===0?this.shaderData.disableMacro("MATERIAL_ENABLE_CLEAR_COAT"):this.shaderData.enableMacro("MATERIAL_ENABLE_CLEAR_COAT")),this.shaderData.setFloat(s._clearCoatProp,t)}},{key:"clearCoatTexture",get:function(){return this.shaderData.getTexture(s._clearCoatTextureProp)},set:function(t){this.shaderData.setTexture(s._clearCoatTextureProp,t),t?this.shaderData.enableMacro("MATERIAL_HAS_CLEAR_COAT_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_CLEAR_COAT_TEXTURE")}},{key:"clearCoatRoughness",get:function(){return this.shaderData.getFloat(s._clearCoatRoughnessProp)},set:function(t){this.shaderData.setFloat(s._clearCoatRoughnessProp,t)}},{key:"clearCoatRoughnessTexture",get:function(){return this.shaderData.getTexture(s._clearCoatRoughnessTextureProp)},set:function(t){this.shaderData.setTexture(s._clearCoatRoughnessTextureProp,t),t?this.shaderData.enableMacro("MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE")}},{key:"clearCoatNormalTexture",get:function(){return this.shaderData.getTexture(s._clearCoatNormalTextureProp)},set:function(t){this.shaderData.setTexture(s._clearCoatNormalTextureProp,t),t?this.shaderData.enableMacro("MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE")}}]),s}(We);(function(){Ir._occlusionTextureIntensityProp=O.getByName("material_OcclusionIntensity")})();(function(){Ir._occlusionTextureCoordProp=O.getByName("material_OcclusionTextureCoord")})();(function(){Ir._occlusionTextureProp=O.getByName("material_OcclusionTexture")})();(function(){Ir._clearCoatProp=O.getByName("material_ClearCoat")})();(function(){Ir._clearCoatTextureProp=O.getByName("material_ClearCoatTexture")})();(function(){Ir._clearCoatRoughnessProp=O.getByName("material_ClearCoatRoughness")})();(function(){Ir._clearCoatRoughnessTextureProp=O.getByName("material_ClearCoatRoughnessTexture")})();(function(){Ir._clearCoatNormalTextureProp=O.getByName("material_ClearCoatNormalTexture")})();var Xr=function(n){W(s,n);function s(t){var e;e=n.call(this,t,Se.find("pbr"))||this,e._anisotropyRotation=0;var r=e.shaderData;return r.setFloat(s._metallicProp,1),r.setFloat(s._roughnessProp,1),r.setFloat(s._iorProp,1.5),r.setVector3(s._anisotropyInfoProp,new R(1,0,0)),e}var i=s.prototype;return i.clone=function(){var e=new s(this._engine);return this.cloneTo(e),e},j(s,[{key:"ior",get:function(){return this.shaderData.getFloat(s._iorProp)},set:function(e){this.shaderData.setFloat(s._iorProp,Math.max(e,0))}},{key:"metallic",get:function(){return this.shaderData.getFloat(s._metallicProp)},set:function(e){this.shaderData.setFloat(s._metallicProp,e)}},{key:"roughness",get:function(){return this.shaderData.getFloat(s._roughnessProp)},set:function(e){this.shaderData.setFloat(s._roughnessProp,e)}},{key:"roughnessMetallicTexture",get:function(){return this.shaderData.getTexture(s._roughnessMetallicTextureProp)},set:function(e){this.shaderData.setTexture(s._roughnessMetallicTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE")}},{key:"anisotropy",get:function(){return this.shaderData.getVector3(s._anisotropyInfoProp).z},set:function(e){var r=this.shaderData.getVector3(s._anisotropyInfoProp);!!r.z!=!!e&&(e===0?this.shaderData.disableMacro("MATERIAL_ENABLE_ANISOTROPY"):this.shaderData.enableMacro("MATERIAL_ENABLE_ANISOTROPY")),r.z=e}},{key:"anisotropyRotation",get:function(){return this._anisotropyRotation},set:function(e){if(this._anisotropyRotation!==e){this._anisotropyRotation=e;var r=this.shaderData.getVector3(s._anisotropyInfoProp),a=k.degreeToRadFactor*e;r.x=Math.cos(a),r.y=Math.sin(a)}}},{key:"anisotropyTexture",get:function(){return this.shaderData.getTexture(s._anisotropyTextureProp)},set:function(e){this.shaderData.setTexture(s._anisotropyTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_ANISOTROPY_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_ANISOTROPY_TEXTURE")}}]),s}(Ir);(function(){Xr._metallicProp=O.getByName("material_Metal")})();(function(){Xr._roughnessProp=O.getByName("material_Roughness")})();(function(){Xr._roughnessMetallicTextureProp=O.getByName("material_RoughnessMetallicTexture")})();(function(){Xr._iorProp=O.getByName("material_IOR")})();(function(){Xr._anisotropyInfoProp=O.getByName("material_AnisotropyInfo")})();(function(){Xr._anisotropyTextureProp=O.getByName("material_AnisotropyTexture")})();var jn=function(n){W(s,n);function s(t){var e;return e=n.call(this,t,Se.find("pbr-specular"))||this,e.shaderData.setColor(s._specularColorProp,new q(1,1,1,1)),e.shaderData.setFloat(s._glossinessProp,1),e}var i=s.prototype;return i.clone=function(){var e=new s(this._engine);return this.cloneTo(e),e},j(s,[{key:"specularColor",get:function(){return this.shaderData.getColor(s._specularColorProp)},set:function(e){var r=this.shaderData.getColor(s._specularColorProp);e!==r&&r.copyFrom(e)}},{key:"glossiness",get:function(){return this.shaderData.getFloat(s._glossinessProp)},set:function(e){this.shaderData.setFloat(s._glossinessProp,e)}},{key:"specularGlossinessTexture",get:function(){return this.shaderData.getTexture(s._specularGlossinessTextureProp)},set:function(e){this.shaderData.setTexture(s._specularGlossinessTextureProp,e),e?this.shaderData.enableMacro(s._specularGlossinessTextureMacro):this.shaderData.disableMacro(s._specularGlossinessTextureMacro)}}]),s}(Ir);(function(){jn._specularColorProp=O.getByName("material_PBRSpecularColor")})();(function(){jn._glossinessProp=O.getByName("material_Glossiness")})();(function(){jn._specularGlossinessTextureProp=O.getByName("material_SpecularGlossinessTexture")})();(function(){jn._specularGlossinessTextureMacro=oe.getByName("MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE")})();var Mc=function(n){W(s,n);function s(t){var e;e=n.call(this,t,Se.find("unlit"))||this;var r=e.shaderData;return r.enableMacro("MATERIAL_OMIT_NORMAL"),r.enableMacro("MATERIAL_NEED_TILING_OFFSET"),r.setColor(s._baseColorProp,new q(1,1,1,1)),r.setVector4(s._tilingOffsetProp,new ie(1,1,0,0)),e}var i=s.prototype;return i.clone=function(){var e=new s(this._engine);return this.cloneTo(e),e},j(s,[{key:"baseColor",get:function(){return this.shaderData.getColor(s._baseColorProp)},set:function(e){var r=this.shaderData.getColor(s._baseColorProp);e!==r&&r.copyFrom(e)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(s._baseTextureProp)},set:function(e){this.shaderData.setTexture(s._baseTextureProp,e),e?this.shaderData.enableMacro(s._baseTextureMacro):this.shaderData.disableMacro(s._baseTextureMacro)}},{key:"tilingOffset",get:function(){return this.shaderData.getVector4(s._tilingOffsetProp)},set:function(e){var r=this.shaderData.getVector4(s._tilingOffsetProp);e!==r&&r.copyFrom(e)}}]),s}(We),H_=function(){function n(i){var t=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,1,1,1,0]),e=new Float32Array([1,-1,1,0,-1,-1,0,0,1,1,1,1,-1,1,0,1]),r=new br(i,Se.find("blit"));r._addReferCount(1),r.renderState.depthState.enabled=!1,r.renderState.depthState.writeEnabled=!1,this.blitMesh=this._createBlitMesh(i,t),this.flipYBlitMesh=this._createBlitMesh(i,e),this.blitMaterial=r}var s=n.prototype;return s._createBlitMesh=function(t,e){var r=new dt(t);return r._addReferCount(1),r.setVertexElements([new Te("POSITION_UV",0,$.Vector4,0)]),r.setVertexBufferBinding(new Kt(t,Pt.VertexBuffer,e,Je.Static),16),r.addSubMesh(0,4,un.TriangleStrip),r},n}(),An;(function(n){n[n.Layer0=1]="Layer0",n[n.Layer1=2]="Layer1",n[n.Layer2=4]="Layer2",n[n.Layer3=8]="Layer3",n[n.Layer4=16]="Layer4",n[n.Layer5=32]="Layer5",n[n.Layer6=64]="Layer6",n[n.Layer7=128]="Layer7",n[n.Layer8=256]="Layer8",n[n.Layer9=512]="Layer9",n[n.Layer10=1024]="Layer10",n[n.Layer11=2048]="Layer11",n[n.Layer12=4096]="Layer12",n[n.Layer13=8192]="Layer13",n[n.Layer14=16384]="Layer14",n[n.Layer15=32768]="Layer15",n[n.Layer16=65536]="Layer16",n[n.Layer17=131072]="Layer17",n[n.Layer18=262144]="Layer18",n[n.Layer19=524288]="Layer19",n[n.Layer20=1048576]="Layer20",n[n.Layer21=2097152]="Layer21",n[n.Layer22=4194304]="Layer22",n[n.Layer23=8388608]="Layer23",n[n.Layer24=16777216]="Layer24",n[n.Layer25=33554432]="Layer25",n[n.Layer26=67108864]="Layer26",n[n.Layer27=134217728]="Layer27",n[n.Layer28=268435456]="Layer28",n[n.Layer29=536870912]="Layer29",n[n.Layer30=1073741824]="Layer30",n[n.Layer31=2147483648]="Layer31",n[n.Everything=4294967295]="Everything",n[n.Nothing=0]="Nothing"})(An||(An={}));var W_=function(){function n(){}return n.cloneComponent=function(i,t,e,r){var a=Cr.getCloneMode(i.constructor);for(var o in i)Cr.cloneProperty(i,t,o,a[o]);i._cloneTo&&i._cloneTo(t,e,r)},n}(),Hr=function(n){W(s,n);function s(t,e){var r;return r=n.call(this,t)||this,r.layer=An.Layer0,r._isActiveInHierarchy=!1,r._isActiveInScene=!1,r._components=[],r._scripts=new He,r._children=[],r._isRoot=!1,r._isActive=!0,r._siblingIndex=-1,r._isTemplate=!1,r._parent=null,r._invModelMatrix=new Z,r.name=e,r.transform=r.addComponent(ge),r._inverseWorldMatFlag=r.transform.registerWorldChangeFlag(),r}var i=s.prototype;return i.addComponent=function(e){oa._addCheck(this,e);var r=new e(this);return this._components.push(r),r._setActive(!0,ue.All),r},i.getComponent=function(e){for(var r=this._components,a=0,o=r.length;a=0;r--){var a=e[r];a._parent=null;var o=ue.None;a._isActiveInHierarchy&&(o|=ue.Hierarchy),a._isActiveInScene&&(o|=ue.Scene),o&&a._processInActive(o),s._traverseSetOwnerScene(a,null)}e.length=0},i.clone=function(){var e=this._createCloneEntity(this);return this._parseCloneEntity(this,e,this,e),e},i._markAsTemplate=function(e){this._isTemplate=!0,this._templateResource=e},i._createCloneEntity=function(e){var r=new s(e._engine,e.name),a=this._templateResource;a&&(r._templateResource=a,a._addReferCount(1)),r.layer=e.layer,r._isActive=e._isActive;var o=r.transform,c=e.transform;o.position=c.position,o.rotation=c.rotation,o.scale=c.scale;for(var l=e._children,_=0,u=e._children.length;_=0;r--)e[r].destroy();this._components.length=0;for(var a=this._children;a.length>0;)a[0].destroy();this._isRoot?this._scene.removeRootEntity(this):this._setParent(null),this.isActive=!1}},i._removeComponent=function(e){oa._removeCheck(this,e.constructor);var r=this._components;r.splice(r.indexOf(e),1)},i._addScript=function(e){e._entityScriptsIndex=this._scripts.length,this._scripts.add(e)},i._removeScript=function(e){var r=this._scripts.deleteByIndex(e._entityScriptsIndex);r&&(r._entityScriptsIndex=e._entityScriptsIndex),e._entityScriptsIndex=-1},i._removeFromParent=function(){var e=this._parent;if(e!=null){var r=e._children,a=this._siblingIndex;r.splice(a,1);for(var o=r.length;ao)throw"The index "+e+" is out of child list bounds "+o;r._siblingIndex=e,a.splice(e,0,r);for(var c=e+1,l=o+1;c=0;a--){var o=this._components[a];lt(o,e)&&r.push(o)}for(var c=this._children.length-1;c>=0;c--)this._children[c]._getComponentsInChildren(e,r)},i._setActiveComponents=function(e,r){for(var a=this._activeChangedComponents,o=0,c=a.length;o=r;o--){var c=o==r?this:e[o-1];e[o]=c,c._siblingIndex=o}else for(var l=a;l<=r;l++){var _=l==r?this:e[l+1];e[l]=_,_._siblingIndex=l}}},i.getInvModelMatrix=function(){return this._inverseWorldMatFlag.flag&&(Z.invert(this.transform.worldMatrix,this._invModelMatrix),this._inverseWorldMatFlag.flag=!1),this._invModelMatrix},s._findChildByName=function(e,r){for(var a=e._children,o=a.length-1;o>=0;o--){var c=a[o];if(c.name===r)return c}return null},s._traverseSetOwnerScene=function(e,r){e._scene=r;for(var a=e._children,o=a.length-1;o>=0;o--)this._traverseSetOwnerScene(a[o],r)},j(s,[{key:"isActive",get:function(){return this._isActive},set:function(e){if(e!==this._isActive)if(this._isActive=e,e){var r=this._parent,a=ue.None;if(this._isRoot&&this._scene._isActiveInEngine)a|=ue.All;else{var o,c;(o=r)!=null&&o._isActiveInHierarchy&&(a|=ue.Hierarchy),(c=r)!=null&&c._isActiveInScene&&(a|=ue.Scene)}a&&this._processActive(a)}else{var l=ue.None;this._isActiveInHierarchy&&(l|=ue.Hierarchy),this._isActiveInScene&&(l|=ue.Scene),l&&this._processInActive(l)}}},{key:"isActiveInHierarchy",get:function(){return this._isActiveInHierarchy}},{key:"parent",get:function(){return this._parent},set:function(e){this._setParent(e)}},{key:"children",get:function(){return this._children}},{key:"childCount",get:function(){return this._children.length}},{key:"scene",get:function(){return this._scene}},{key:"siblingIndex",get:function(){return this._siblingIndex},set:function(e){if(this._siblingIndex===-1)throw"The entity "+this.name+" is not in the hierarchy";this._setSiblingIndex(this._isRoot?this._scene._rootEntities:this._parent._children,e)}}]),s}(Yr),Yt=function(){function n(){this._projectionParams=new ie,this.flipProjection=!1}var s=n.prototype;return s.applyVirtualCamera=function(t,e){this.virtualCamera=t,this.flipProjection=e;var r=this.camera.shaderData,a=t.viewMatrix,o=t.projectionMatrix,c=t.viewProjectionMatrix;e&&(Z.multiply(n._flipYMatrix,o,n._flipYProjectionMatrix),Z.multiply(n._flipYProjectionMatrix,a,n._flipYViewProjectionMatrix),o=n._flipYProjectionMatrix,c=n._flipYViewProjectionMatrix),this.viewMatrix=a,this.projectionMatrix=o,this.viewProjectionMatrix=c,r.setMatrix(n._viewMatrixProperty,a),r.setMatrix(n._projectionMatrixProperty,o),r.setMatrix(n.vpMatrixProperty,c);var l=this._projectionParams;l.set(e?-1:1,t.nearClipPlane,t.farClipPlane,0),r.setVector4(n._cameraProjectionProperty,l)},s.garbageCollection=function(){this.camera=null},n}();(function(){Yt.vpMatrixProperty=O.getByName("camera_VPMat")})();(function(){Yt.pipelineStageKey=sn.getByName("pipelineStage")})();(function(){Yt._flipYMatrix=new Z(1,0,0,0,0,-1)})();(function(){Yt._cameraProjectionProperty=O.getByName("camera_ProjectionParams")})();(function(){Yt._viewMatrixProperty=O.getByName("camera_ViewMat")})();(function(){Yt._projectionMatrixProperty=O.getByName("camera_ProjMat")})();(function(){Yt._flipYProjectionMatrix=new Z})();(function(){Yt._flipYViewProjectionMatrix=new Z})();var ki=function(){function n(){}var s=n.prototype;return s.setX=function(t,e,r,a){this.component=t,this.material=e,this.primitive=r,this.subPrimitive=a},s.dispose=function(){this.component=null,this.material=null,this.primitive=null,this.subPrimitive=null},n}(),X_=function(){function n(){}var s=n.prototype;return s.set=function(t,e){this.data=t,this.shaderPasses=e},s.dispose=function(){this.data=this.shaderPasses=null},n}(),j_=function(n){W(s,n);function s(){return n.apply(this,arguments)}var i=s.prototype;return i.createVertexElements=function(e){return e[0]=new Te("POSITION",0,$.Vector3,0),e[1]=new Te("TEXCOORD_0",12,$.Vector2,0),20},i.canBatch=function(e,r){var a=e.data,o=r.data;if(a.isAdd!==o.isAdd)return!1;var c=a.component.shaderData,l=o.component.shaderData,_=Bt._textureProperty,u=Bt._alphaCutoffProperty;return c.getTexture(_)===l.getTexture(_)&&c.getTexture(u)===l.getTexture(u)},i.updateVertices=function(e,r,a){for(var o=e.verticesData,c=o.positions,l=o.uvs,_=o.vertexCount,u=0;u<_;u++){var h=c[u],d=l[u];r[a++]=h.x,r[a++]=h.y,r[a++]=h.z,r[a++]=d.x,r[a++]=d.y}return a},i.drawBatches=function(e){for(var r=this,a=r._engine,o=r._batchedQueue,c=this._meshes[this._flushId],l=c.subMeshes,_=c._primitive,u=e.scene.shaderData,h=e.shaderData,d=0,f=l.length;dr.length)throw"The index is out of range.";a=t}else a=r.length,e=t;if(e.engine!==this.engine)throw"The scene is not belong to this engine.";if(e._sceneManager){var o=r.indexOf(e);o!==a&&(r.removeByIndex(o),r.add(a,e))}else e._sceneManager=this,r.add(a,e),e.isActive&&e._processActive(!0)},s.removeScene=function(t){var e=this._scenes,r=e.indexOf(t);if(r!==-1){var a=e.getArray()[r];e.removeByIndex(r),t._sceneManager=null,a.isActive&&a._processActive(!1)}},s.loadScene=function(t,e){e===void 0&&(e=!0);var r=this,a=this.engine.resourceManager.load({url:t,type:Ve.Scene});return a.then(function(o){if(e)for(var c=r._scenes.getArray(),l=0,_=c.length;l<_;l++)c[l].destroy();r.addScene(o)}),a},s.mergeScenes=function(t,e){for(var r=t.rootEntities;r.length>0;)e.addRootEntity(r[0])},s._destroyAllScene=function(){for(var t=this._allCreatedScenes;t.length>0;)t[0].destroy()},j(n,[{key:"scenes",get:function(){return this._scenes.getArray()}},{key:"activeScene",get:function(){return this._scenes.getArray()[0]},set:function(t){var e=this.scenes[0];e&&this.removeScene(e),t&&this.addScene(0,t)}}]),n}(),Pe=function(){function n(i){var t=this;this._state="pending",this._onTaskCompleteCallbacks=[],this._onTaskDetailCallbacks=[],this._promise=new Promise(function(e,r){t._reject=r;var a=function(u){t._state==="pending"&&(e(u),t._state="fulfilled",t._onTaskCompleteCallbacks=void 0,t._onTaskDetailCallbacks=void 0)},o=function(u){t._state==="pending"&&(r(u),t._state="rejected",t._onTaskCompleteCallbacks=void 0,t._onTaskDetailCallbacks=void 0)},c=function(u){t._state==="pending"&&(t._onCancelHandler=u)},l=function(u,h){if(t._state==="pending"){var d=t._taskCompleteProgress||(t._taskCompleteProgress={loaded:u,total:h});d.loaded=u,d.total=h,t._onTaskCompleteCallbacks.forEach(function(f){return f(u,h)})}},_=function(u,h,d){if(t._state==="pending"){var f,v;t._taskDetailProgress||(t._taskDetailProgress={});var p=(f=t._taskDetailProgress)[v=u]||(f[v]={loaded:h,total:d});p.loaded=h,p.total=d,t._onTaskDetailCallbacks.forEach(function(g){return g(u,h,d)})}};i(a,o,l,_,c)})}var s=n.prototype;return s.onProgress=function(t,e){var r=this._taskCompleteProgress,a=this._taskDetailProgress;if(r&&t(r.loaded,r.total),a)for(var o in a){var c=a[o],l=c.loaded,_=c.total;e(o,l,_)}return this._state==="pending"&&(t&&this._onTaskCompleteCallbacks.push(t),e&&this._onTaskDetailCallbacks.push(e)),this},s.then=function(t,e){var r=this;return new n(function(a,o){r._promise.then(t,e).then(a).catch(o)})},s.catch=function(t){var e=this;return new n(function(r,a){e._promise.catch(t).then(r).catch(a)})},s.finally=function(t){return this._promise.finally(t)},s.cancel=function(){if(this._state==="pending")return this._state="canceled",this._reject("canceled"),this._onCancelHandler&&this._onCancelHandler(),this},n.all=function(t){return new n(function(e,r,a){var o=function(f,v){u++,_[f]=v,a(u,l),u===l&&e(_)},c=function(f,v){lt(f,Promise)||lt(f,n)?f.then(function(p){o(v,p)},r):Promise.resolve().then(function(){o(v,f)})},l=t.length,_=new Array(l),u=0;if(l===0)return e(_);for(var h=0;h0?r+"?"+l.join("&"):r}return{assetBaseURL:c,queryPath:o}},s._parseQueryPath=function(t){var e=[];return t.charCodeAt(0)===Z_&&e.push(""),t.replace(eu,function(r,a,o,c){var l=r;o?l=c.replace($_,"$1"):a&&(l=a.trim()),e.push(l)}),e},s.getResourceByRef=function(t){var e=t.refId,r=t.key,a=t.isClone,o=this._objectPool[e],c;if(o)c=Promise.resolve(o);else{var l,_=(l=this._editorResourceConfig[e])==null?void 0:l.path;if(!_)return ve.warn("refId:"+e+" is not find in this._editorResourceConfig."),Promise.resolve(null);_=r?""+_+(_.indexOf("?")>-1?"&":"?")+"q="+r:_,c=this.load({url:_,type:this._editorResourceConfig[e].type})}return c.then(function(u){return a?u.clone():u})},s.initVirtualResources=function(t){var e=this;t.forEach(function(r){e._virtualPathMap[r.virtualPath]=r.path,e._editorResourceConfig[r.id]=r})},n._addLoader=function(t,e,r){this._loaders[t]=e;for(var a=0,o=r.length;a"u")return;var i=navigator.userAgent;/iPhone/i.test(i)?n.platform=Nt.IPhone:/iPad/i.test(i)?n.platform=Nt.IPad:/Android/i.test(i)?n.platform=Nt.Android:/Macintosh/i.test(i)&&(n.platform=Nt.Mac);var t;switch(n.platform){case Nt.IPhone:t=i.match(/OS (\d+)_?(\d+)?_?(\d+)?/),this.operatingSystem=t?"iPhone OS "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"iPhone OS";break;case Nt.IPad:t=i.match(/OS (\d+)_?(\d+)?_?(\d+)?/),this.operatingSystem=t?"iPad OS "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"iPad OS";break;case Nt.Android:t=i.match(/Android (\d+).?(\d+)?.?(\d+)?/),this.operatingSystem=t?"Android "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"Android";break;case Nt.Mac:t=i.match(/Mac OS X (\d+)_?(\d+)?_?(\d+)?/),this.operatingSystem=t?"Mac OS X "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"Mac OS X";break}}},n._detectSIMDSupported=function(){return this._simdSupported===null&&(this._simdSupported=WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]))),this._simdSupported},j(n,null,[{key:"devicePixelRatio",get:function(){return window.devicePixelRatio}}]),n}();(function(){jr.platform=Nt.Unknown})();(function(){jr.operatingSystem=""})();(function(){jr._simdSupported=null})();jr._initialize();var ta;(function(n){n[n.Backquote=0]="Backquote",n[n.Backslash=1]="Backslash",n[n.Backspace=2]="Backspace",n[n.BracketLeft=3]="BracketLeft",n[n.BracketRight=4]="BracketRight",n[n.Comma=5]="Comma",n[n.Digit0=6]="Digit0",n[n.Digit1=7]="Digit1",n[n.Digit2=8]="Digit2",n[n.Digit3=9]="Digit3",n[n.Digit4=10]="Digit4",n[n.Digit5=11]="Digit5",n[n.Digit6=12]="Digit6",n[n.Digit7=13]="Digit7",n[n.Digit8=14]="Digit8",n[n.Digit9=15]="Digit9",n[n.Equal=16]="Equal",n[n.IntlBackslash=17]="IntlBackslash",n[n.IntlRo=18]="IntlRo",n[n.IntlYen=19]="IntlYen",n[n.KeyA=20]="KeyA",n[n.KeyB=21]="KeyB",n[n.KeyC=22]="KeyC",n[n.KeyD=23]="KeyD",n[n.KeyE=24]="KeyE",n[n.KeyF=25]="KeyF",n[n.KeyG=26]="KeyG",n[n.KeyH=27]="KeyH",n[n.KeyI=28]="KeyI",n[n.KeyJ=29]="KeyJ",n[n.KeyK=30]="KeyK",n[n.KeyL=31]="KeyL",n[n.KeyM=32]="KeyM",n[n.KeyN=33]="KeyN",n[n.KeyO=34]="KeyO",n[n.KeyP=35]="KeyP",n[n.KeyQ=36]="KeyQ",n[n.KeyR=37]="KeyR",n[n.KeyS=38]="KeyS",n[n.KeyT=39]="KeyT",n[n.KeyU=40]="KeyU",n[n.KeyV=41]="KeyV",n[n.KeyW=42]="KeyW",n[n.KeyX=43]="KeyX",n[n.KeyY=44]="KeyY",n[n.KeyZ=45]="KeyZ",n[n.Minus=46]="Minus",n[n.Period=47]="Period",n[n.Quote=48]="Quote",n[n.Semicolon=49]="Semicolon",n[n.Slash=50]="Slash",n[n.AltLeft=51]="AltLeft",n[n.AltRight=52]="AltRight",n[n.CapsLock=53]="CapsLock",n[n.ContextMenu=54]="ContextMenu",n[n.ControlLeft=55]="ControlLeft",n[n.ControlRight=56]="ControlRight",n[n.Enter=57]="Enter",n[n.MetaLeft=58]="MetaLeft",n[n.MetaRight=59]="MetaRight",n[n.ShiftLeft=60]="ShiftLeft",n[n.ShiftRight=61]="ShiftRight",n[n.Space=62]="Space",n[n.Tab=63]="Tab",n[n.Convert=64]="Convert",n[n.KanaMode=65]="KanaMode",n[n.Lang1=66]="Lang1",n[n.Lang2=67]="Lang2",n[n.Lang3=68]="Lang3",n[n.Lang4=69]="Lang4",n[n.Lang5=70]="Lang5",n[n.NonConvert=71]="NonConvert",n[n.Delete=72]="Delete",n[n.End=73]="End",n[n.Help=74]="Help",n[n.Home=75]="Home",n[n.Insert=76]="Insert",n[n.PageDown=77]="PageDown",n[n.PageUp=78]="PageUp",n[n.ArrowDown=79]="ArrowDown",n[n.ArrowLeft=80]="ArrowLeft",n[n.ArrowRight=81]="ArrowRight",n[n.ArrowUp=82]="ArrowUp",n[n.NumLock=83]="NumLock",n[n.Numpad0=84]="Numpad0",n[n.Numpad1=85]="Numpad1",n[n.Numpad2=86]="Numpad2",n[n.Numpad3=87]="Numpad3",n[n.Numpad4=88]="Numpad4",n[n.Numpad5=89]="Numpad5",n[n.Numpad6=90]="Numpad6",n[n.Numpad7=91]="Numpad7",n[n.Numpad8=92]="Numpad8",n[n.Numpad9=93]="Numpad9",n[n.NumpadAdd=94]="NumpadAdd",n[n.NumpadBackspace=95]="NumpadBackspace",n[n.NumpadClear=96]="NumpadClear",n[n.NumpadClearEntry=97]="NumpadClearEntry",n[n.NumpadComma=98]="NumpadComma",n[n.NumpadDecimal=99]="NumpadDecimal",n[n.NumpadDivide=100]="NumpadDivide",n[n.NumpadEnter=101]="NumpadEnter",n[n.NumpadEqual=102]="NumpadEqual",n[n.NumpadHash=103]="NumpadHash",n[n.NumpadMemoryAdd=104]="NumpadMemoryAdd",n[n.NumpadMemoryClear=105]="NumpadMemoryClear",n[n.NumpadMemoryRecall=106]="NumpadMemoryRecall",n[n.NumpadMemoryStore=107]="NumpadMemoryStore",n[n.NumpadMemorySubtract=108]="NumpadMemorySubtract",n[n.NumpadMultiply=109]="NumpadMultiply",n[n.NumpadParenLeft=110]="NumpadParenLeft",n[n.NumpadParenRight=111]="NumpadParenRight",n[n.NumpadStar=112]="NumpadStar",n[n.NumpadSubtract=113]="NumpadSubtract",n[n.Escape=114]="Escape",n[n.F1=115]="F1",n[n.F2=116]="F2",n[n.F3=117]="F3",n[n.F4=118]="F4",n[n.F5=119]="F5",n[n.F6=120]="F6",n[n.F7=121]="F7",n[n.F8=122]="F8",n[n.F9=123]="F9",n[n.F10=124]="F10",n[n.F11=125]="F11",n[n.F12=126]="F12",n[n.F13=127]="F13",n[n.F14=128]="F14",n[n.F15=129]="F15",n[n.Fn=130]="Fn",n[n.FnLock=131]="FnLock",n[n.PrintScreen=132]="PrintScreen",n[n.ScrollLock=133]="ScrollLock",n[n.Pause=134]="Pause",n[n.BrowserBack=135]="BrowserBack",n[n.BrowserFavorites=136]="BrowserFavorites",n[n.BrowserForward=137]="BrowserForward",n[n.BrowserHome=138]="BrowserHome",n[n.BrowserRefresh=139]="BrowserRefresh",n[n.BrowserSearch=140]="BrowserSearch",n[n.BrowserStop=141]="BrowserStop",n[n.Eject=142]="Eject",n[n.LaunchApp1=143]="LaunchApp1",n[n.LaunchApp2=144]="LaunchApp2",n[n.LaunchMail=145]="LaunchMail",n[n.MediaPlayPause=146]="MediaPlayPause",n[n.MediaSelect=147]="MediaSelect",n[n.MediaStop=148]="MediaStop",n[n.MediaTrackNext=149]="MediaTrackNext",n[n.MediaTrackPrevious=150]="MediaTrackPrevious",n[n.Power=151]="Power",n[n.Sleep=152]="Sleep",n[n.AudioVolumeDown=153]="AudioVolumeDown",n[n.AudioVolumeMute=154]="AudioVolumeMute",n[n.AudioVolumeUp=155]="AudioVolumeUp",n[n.WakeUp=156]="WakeUp",n[n.Hyper=157]="Hyper",n[n.Super=158]="Super",n[n.Turbo=159]="Turbo",n[n.Abort=160]="Abort",n[n.Resume=161]="Resume",n[n.Suspend=162]="Suspend",n[n.Again=163]="Again",n[n.Copy=164]="Copy",n[n.Cut=165]="Cut",n[n.Find=166]="Find",n[n.Open=167]="Open",n[n.Paste=168]="Paste",n[n.Props=169]="Props",n[n.Select=170]="Select",n[n.Undo=171]="Undo",n[n.Hiragana=172]="Hiragana",n[n.Katakana=173]="Katakana",n[n.Unidentified=174]="Unidentified"})(ta||(ta={}));var ru=function(){function n(i,t){this._curHeldDownKeyToIndexMap=[],this._upKeyToFrameCountMap=[],this._downKeyToFrameCountMap=[],this._curFrameHeldDownList=new He,this._curFrameDownList=new He,this._curFrameUpList=new He,this._nativeEvents=[],this._engine=i,this._onBlur=this._onBlur.bind(this),this._onKeyEvent=this._onKeyEvent.bind(this),this._target=t,this._addEventListener()}var s=n.prototype;return s._update=function(){var t=this,e=t._nativeEvents,r=t._curFrameDownList,a=t._curFrameUpList;if(r.length=0,a.length=0,e.length>0){for(var o=this._engine.time.frameCount,c=this,l=c._curHeldDownKeyToIndexMap,_=c._curFrameHeldDownList,u=c._downKeyToFrameCountMap,h=c._upKeyToFrameCountMap,d=0,f=e.length;d=0;--e)t[e]._onUpdate()},s._callColliderOnLateUpdate=function(){for(var t=this._colliders._elements,e=this._colliders.length-1;e>=0;--e)t[e]._onLateUpdate()},s._gc=function(){this._colliders.garbageCollection()},s._setGravity=function(){this._nativePhysicsScene.setGravity(this._gravity)},j(n,[{key:"gravity",get:function(){return this._gravity},set:function(t){var e=this._gravity;e!==t&&e.copyFrom(t)}},{key:"fixedTimeStep",get:function(){return this._fixedTimeStep},set:function(t){this._fixedTimeStep=Math.max(t,k.zeroTolerance)}}]),n}();(function(){Gt._collision=new nu})();var gi;(function(n){n[n.PreventClimbing=0]="PreventClimbing",n[n.PreventClimbingAndForceSliding=1]="PreventClimbingAndForceSliding"})(gi||(gi={}));var au=function(n){W(s,n);function s(t){var e;return e=n.call(this,t)||this,e._stepOffset=.5,e._nonWalkableMode=gi.PreventClimbing,e._upDirection=new R(0,1,0),e._slopeLimit=.707,e._nativeCollider=Gt._nativePhysics.createCharacterController(),e._setUpDirection=e._setUpDirection.bind(_e(e)),e._upDirection._onValueChanged=e._setUpDirection,e}var i=s.prototype;return i.move=function(e,r,a){return this._nativeCollider.move(e,r,a)},i.addShape=function(e){if(this._shapes.length>0)throw"only allow single shape on controller!";n.prototype.addShape.call(this,e),this._updateFlag.flag=!0},i.clearShapes=function(){this._shapes.length>0&&n.prototype.removeShape.call(this,this._shapes[0])},i._onUpdate=function(){if(this._updateFlag.flag){var e=this.entity.transform,r=this.shapes;this._nativeCollider.setWorldPosition(e.worldPosition);for(var a=e.lossyWorldScale,o=0,c=r.length;o=0;g--)e[g].phase===nr.Leave&&e.splice(g,1);for(var y=0,m=r.length;yM);M++);b=(S=B)[w=M]||(S[w]=new Bc(M)),b._uniqueID=C,b._events.push(x),b.position.set((x.clientX-d)*v,(x.clientY-f)*p),e.splice(M,0,b)}}}r.length=0,this._upList.length=this._downList.length=0,this._buttons=ea.None;for(var D=this._engine.time.frameCount,L=0,V=e.length;L0){for(var f=0;f=0;a--)if(r[a]._uniqueID===t)return r[a];return null},s._updatePointerInfo=function(t,e,r,a,o,c){var l=e._events,_=e.position,u=l.length;if(u>0){var h=this,d=h._upList,f=h._upMap,v=h._downList,p=h._downMap,g=l[u-1],y=(g.clientX-r)*o,m=(g.clientY-a)*c;e.deltaPosition.set(y-_.x,m-_.y),_.set(y,m);for(var x=0;x=0;l--){var _=t[l];if(!(!_.isActive||_.destroyed))for(var u=_._componentsManager,h=u._activeCameras,d=h._elements,f=h.length-1;f>=0;f--){var v=d[f];if(!v.renderTarget){var p=v.viewport,g=p.x,y=p.y,m=p.z,x=p.w;if(e>=g&&r>=y&&e-g<=m&&r-y<=x){if(a.set((e-g)/m,(r-y)/x),_.physics.raycast(v.viewportPointToRay(a,o),Number.MAX_VALUE,v.cullingMask,c))return c.entity;if(v.clearFlags&zt.Color)return null}}}}return null},s._addEventListener=function(){var t=this,e=t._target,r=t._onPointerEvent;e.addEventListener("pointerdown",r),e.addEventListener("pointerup",r),e.addEventListener("pointerleave",r),e.addEventListener("pointermove",r),e.addEventListener("pointercancel",r)},s._removeEventListener=function(){var t=this,e=t._target,r=t._onPointerEvent;e.removeEventListener("pointerdown",r),e.removeEventListener("pointerup",r),e.removeEventListener("pointerleave",r),e.removeEventListener("pointermove",r),e.removeEventListener("pointercancel",r),this._nativeEvents.length=0,this._pointers.length=0,this._downList.length=0,this._upList.length=0},n}();(function(){Hi._tempRay=new il})();(function(){Hi._tempPoint=new ee})();(function(){Hi._tempHitResult=new Dc})();var uu=function(){function n(i,t){this._delta=new R,this._nativeEvents=[],this._onWheelEvent=this._onWheelEvent.bind(this),this._target=t,this._addEventListener()}var s=n.prototype;return s._update=function(){var t=this,e=t._delta;e.set(0,0,0);var r=this,a=r._nativeEvents;if(a.length>0){for(var o=a.length-1;o>=0;o--){var c=a[o];e.x+=c.deltaX,e.y+=c.deltaY,e.z+=c.deltaZ}a.length=0}},s._addEventListener=function(){this._target.addEventListener("wheel",this._onWheelEvent)},s._removeEventListener=function(){this._target.removeEventListener("wheel",this._onWheelEvent),this._nativeEvents.length=0,this._delta.set(0,0,0)},s._destroy=function(){this._removeEventListener(),this._nativeEvents=null,this._delta=null},s._onWheelEvent=function(t){this._nativeEvents.push(t)},n}(),Nc=function(){function n(i,t){this._initialized=!1,this._engine=i;var e=i._canvas._webCanvas;if(typeof OffscreenCanvas>"u"||!lt(e,OffscreenCanvas)){var r,a,o,c;this._wheelManager=new uu(i,(c=(r=t)==null?void 0:r.wheelTarget)!=null?c:e);var l;this._pointerManager=new Hi(i,(l=(a=t)==null?void 0:a.pointerTarget)!=null?l:e);var _;this._keyboardManager=new ru(i,(_=(o=t)==null?void 0:o.keyboardTarget)!=null?_:window),this._initialized=!0}}var s=n.prototype;return s.isKeyHeldDown=function(t){return this._initialized?t===void 0?this._keyboardManager._curFrameHeldDownList.length>0:this._keyboardManager._curHeldDownKeyToIndexMap[t]!=null:!1},s.isKeyDown=function(t){return this._initialized?t===void 0?this._keyboardManager._curFrameDownList.length>0:this._keyboardManager._downKeyToFrameCountMap[t]===this._engine.time.frameCount:!1},s.isKeyUp=function(t){return this._initialized?t===void 0?this._keyboardManager._curFrameUpList.length>0:this._keyboardManager._upKeyToFrameCountMap[t]===this._engine.time.frameCount:!1},s.isPointerHeldDown=function(t){return this._initialized?t===void 0?this._pointerManager._buttons!==0:(this._pointerManager._buttons&t)!==0:!1},s.isPointerDown=function(t){return this._initialized?t===void 0?this._pointerManager._downList.length>0:this._pointerManager._downMap[rs[t]]===this._engine.time.frameCount:!1},s.isPointerUp=function(t){return this._initialized?t===void 0?this._pointerManager._upList.length>0:this._pointerManager._upMap[rs[t]]===this._engine.time.frameCount:!1},s._update=function(){this._initialized&&(this._wheelManager._update(),this._pointerManager._update(),this._keyboardManager._update())},s._firePointerScript=function(t){this._initialized&&this._pointerManager._firePointerScript(t)},s._destroy=function(){this._initialized&&(this._wheelManager._destroy(),this._wheelManager=null,this._pointerManager._destroy(),this._pointerManager=null,this._keyboardManager._destroy(),this._keyboardManager=null)},j(n,[{key:"pointers",get:function(){return this._initialized?this._pointerManager._pointers:[]}},{key:"multiPointerEnabled",get:function(){return this._initialized?this._pointerManager._multiPointerEnabled:!1},set:function(t){this._initialized&&(this._pointerManager._multiPointerEnabled=t)}},{key:"wheelDelta",get:function(){return this._initialized?this._wheelManager._delta:null}}]),n}(),co;(function(n){n.cornerTextureCoordinate="a_CornerTextureCoordinate"})(co||(co={}));var rr;(function(n){n.ShapePositionStartLifeTime="a_ShapePositionStartLifeTime",n.DirectionTime="a_DirectionTime",n.StartColor="a_StartColor",n.StartSize="a_StartSize",n.StartRotation0="a_StartRotation0",n.StartSpeed="a_StartSpeed",n.Random0="a_Random0",n.Random1="a_Random1",n.SimulationWorldPosition="a_SimulationWorldPosition",n.SimulationWorldRotation="a_SimulationWorldRotation",n.SimulationUV="a_SimulationUV"})(rr||(rr={}));var hu=function(s){this.billboardVertexElement=new Te(co.cornerTextureCoordinate,0,$.Vector4,0),this.instanceVertexElements=[new Te(rr.ShapePositionStartLifeTime,0,$.Vector4,1,1),new Te(rr.DirectionTime,16,$.Vector4,1,1),new Te(rr.StartColor,32,$.Vector4,1,1),new Te(rr.StartSize,48,$.Vector3,1,1),new Te(rr.StartRotation0,60,$.Vector3,1,1),new Te(rr.StartSpeed,72,$.Float,1,1),new Te(rr.Random0,76,$.Vector4,1,1),new Te(rr.Random1,92,$.Vector4,1,1),new Te(rr.SimulationWorldPosition,108,$.Vector3,1,1),new Te(rr.SimulationWorldRotation,120,$.Vector4,1,1),new Te(rr.SimulationUV,136,$.Vector4,1,1)],this.instanceVertexStride=152,this.instanceVertexFloatStride=this.instanceVertexStride/4,this.startLifeTimeOffset=3,this.timeOffset=7,this.simulationUVOffset=34,this.billboardIndexCount=6;var i=16,t=new Kt(s,Pt.VertexBuffer,i*4,Je.Static,!1);t.isGCIgnored=!0,this.billboardVertexBufferBinding=new Hn(t,i);var e=new Kt(s,Pt.IndexBuffer,this.billboardIndexCount,Je.Static,!1);e.isGCIgnored=!0,this.billboardIndexBufferBinding=new Ra(e,St.UInt8);var r=new Float32Array([-.5,-.5,0,1,.5,-.5,1,1,.5,.5,1,0,-.5,.5,0,0]),a=new Uint8Array([0,2,3,0,1,2]);t.setData(r),e.setData(a),s.resourceManager.addContentRestorer(new(function(o){W(c,o);function c(){return o.call(this,t)}var l=c.prototype;return l.restoreContent=function(){t.setData(r)},c}(xr))),s.resourceManager.addContentRestorer(new(function(o){W(c,o);function c(){return o.call(this,e)}var l=c.prototype;return l.restoreContent=function(){},c}(xr)))},du=`#define GLSLIFY 1 + `+tn.parseIncludes(this._fragmentSource);return c&&(f=tn.convertTo300(f),v=tn.convertTo300(v,!0)),o=new Cc(e,f,v),a.cache(o),o},i._destroy=function(){for(var e=this._shaderProgramPools,r=0,a=e.length;r0)e[0].constructor===vt?a=new n(t,[new hi("Default",e)]):a=new n(t,e.slice());else throw"SubShader or ShaderPass count must large than 0."}else{if(!n._shaderLab)throw"ShaderLab has not been set up yet.";var c=n._shaderLab.parseShader(t);if(o[c.name]){console.error('Shader named "'+c.name+'" already exists.');return}var l=c.subShaders.map(function(u){var h=u.passes.map(function(d){if(typeof d=="string"){var f,v,p=d.split("/");return(v=n.find(p[0]))==null||(f=v.subShaders.find(function(w){return w.name===p[1]}))==null?void 0:f.passes.find(function(w){return w.name===p[2]})}var g=new vt(d.name,d.vertexSource,d.fragmentSource,d.tags),y=d.renderStates,m=new qr;g._renderState=m;var x=y[0];for(var C in x)n._applyConstRenderStates(m,parseInt(C),x[C]);var b=y[1],A={};for(var S in b)A[S]=O.getByName(b[S]);return g._renderStateDataMap=A,g});return new hi(c.name,h,u.tags)});return a=new n(c.name,l),o[c.name]=a,a}return o[t]=a,a},n.find=function(t){return n._shaderMap[t]},n._applyConstRenderStates=function(t,e,r){switch(e){case re.BlendStateEnabled0:t.blendState.targetBlendState.enabled=r;break;case re.BlendStateColorBlendOperation0:t.blendState.targetBlendState.colorBlendOperation=r;break;case re.BlendStateAlphaBlendOperation0:t.blendState.targetBlendState.alphaBlendOperation=r;break;case re.BlendStateSourceColorBlendFactor0:t.blendState.targetBlendState.sourceColorBlendFactor=r;break;case re.BlendStateDestinationColorBlendFactor0:t.blendState.targetBlendState.destinationColorBlendFactor=r;break;case re.BlendStateSourceAlphaBlendFactor0:t.blendState.targetBlendState.sourceAlphaBlendFactor=r;break;case re.BlendStateDestinationAlphaBlendFactor0:t.blendState.targetBlendState.destinationAlphaBlendFactor=r;break;case re.BlendStateColorWriteMask0:t.blendState.targetBlendState.colorWriteMask=r;break;case re.DepthStateEnabled:t.depthState.enabled=r;break;case re.DepthStateWriteEnabled:t.depthState.writeEnabled=r;break;case re.DepthStateCompareFunction:t.depthState.compareFunction=r;break;case re.StencilStateEnabled:t.stencilState.enabled=r;break;case re.StencilStateReferenceValue:t.stencilState.referenceValue=r;break;case re.StencilStateMask:t.stencilState.mask=r;break;case re.StencilStateWriteMask:t.stencilState.writeMask=r;break;case re.StencilStateCompareFunctionFront:t.stencilState.compareFunctionFront=r;break;case re.StencilStateCompareFunctionBack:t.stencilState.compareFunctionBack=r;break;case re.StencilStatePassOperationFront:t.stencilState.passOperationFront=r;break;case re.StencilStatePassOperationBack:t.stencilState.passOperationBack=r;break;case re.StencilStateFailOperationFront:t.stencilState.failOperationFront=r;break;case re.StencilStateFailOperationBack:t.stencilState.failOperationBack=r;break;case re.StencilStateZFailOperationFront:t.stencilState.zFailOperationFront=r;break;case re.StencilStateZFailOperationBack:t.stencilState.zFailOperationBack=r;break;case re.RasterStateCullMode:t.rasterState.cullMode=r;break;case re.RasterStateDepthBias:t.rasterState.depthBias=r;break;case re.RasterStateSlopeScaledDepthBias:t.rasterState.slopeScaledDepthBias=r;break;case re.RenderQueueType:t.renderQueueType=r;break}},n.getMacroByName=function(t,e){return oe.getByName(t,e)},n.getPropertyByName=function(t){return O.getByName(t)},j(n,[{key:"subShaders",get:function(){return this._subShaders}},{key:"destroyed",get:function(){return this._destroyed}}]),n}();(function(){Se._compileMacros=new Kt})();(function(){Se._shaderMap=Object.create(null)})();var ki=function(n){W(s,n);function s(t){var e;return e=n.call(this,t)||this,e._isContentLost=!1,t.resourceManager._addGraphicResource(ce(e)),e}var i=s.prototype;return i._onDestroy=function(){n.prototype._onDestroy.call(this),this.engine.resourceManager._deleteGraphicResource(this)},j(s,[{key:"isContentLost",get:function(){return this._isContentLost}}]),s}(Qr),tt;(function(n){n[n.Point=0]="Point",n[n.Bilinear=1]="Bilinear",n[n.Trilinear=2]="Trilinear"})(tt||(tt={}));var G;(function(n){n[n.R8G8B8=0]="R8G8B8",n[n.R8G8B8A8=1]="R8G8B8A8",n[n.R4G4B4A4=2]="R4G4B4A4",n[n.R5G5B5A1=3]="R5G5B5A1",n[n.R5G6B5=4]="R5G6B5",n[n.Alpha8=5]="Alpha8",n[n.LuminanceAlpha=6]="LuminanceAlpha",n[n.R16G16B16A16=7]="R16G16B16A16",n[n.R32G32B32A32=8]="R32G32B32A32",n[n.R32G32B32A32_UInt=9]="R32G32B32A32_UInt",n[n.BC1=10]="BC1",n[n.BC3=11]="BC3",n[n.BC7=12]="BC7",n[n.ETC1_RGB=13]="ETC1_RGB",n[n.ETC2_RGB=14]="ETC2_RGB",n[n.ETC2_RGBA5=15]="ETC2_RGBA5",n[n.ETC2_RGBA8=16]="ETC2_RGBA8",n[n.PVRTC_RGB2=17]="PVRTC_RGB2",n[n.PVRTC_RGBA2=18]="PVRTC_RGBA2",n[n.PVRTC_RGB4=19]="PVRTC_RGB4",n[n.PVRTC_RGBA4=20]="PVRTC_RGBA4",n[n.ASTC_4x4=21]="ASTC_4x4",n[n.ASTC_5x5=22]="ASTC_5x5",n[n.ASTC_6x6=23]="ASTC_6x6",n[n.ASTC_8x8=24]="ASTC_8x8",n[n.ASTC_10x10=25]="ASTC_10x10",n[n.ASTC_12x12=26]="ASTC_12x12",n[n.Depth=27]="Depth",n[n.Stencil=28]="Stencil",n[n.DepthStencil=29]="DepthStencil",n[n.Depth16=30]="Depth16",n[n.Depth24=31]="Depth24",n[n.Depth32=32]="Depth32",n[n.Depth24Stencil8=33]="Depth24Stencil8",n[n.Depth32Stencil8=34]="Depth32Stencil8",n[n.DXT1=10]="DXT1",n[n.DXT5=11]="DXT5"})(G||(G={}));var Wr=function(n){W(s,n);function s(){var t;return t=n.apply(this,arguments)||this,t._isDepthTexture=!1,t._anisoLevel=1,t._useDepthCompareMode=!1,t}var i=s.prototype;return i.generateMipmaps=function(){this._mipmap&&this._platformTexture.generateMipmaps()},i._setUseDepthCompareMode=function(e){this._useDepthCompareMode!==e&&(this._platformTexture.setUseDepthCompareMode(e),this._useDepthCompareMode=e)},i._rebuild=function(){var e=this._platformTexture;e.wrapModeU=this._wrapModeU,e.wrapModeV=this._wrapModeV,e.filterMode=this._filterMode,e.anisoLevel=this._anisoLevel,this._engine._hardwareRenderer._isWebGL2&&(e.depthCompareFunction=this._depthCompareFunction,e.setUseDepthCompareMode(this._useDepthCompareMode))},i._onDestroy=function(){n.prototype._onDestroy.call(this),this._platformTexture.destroy(),this._platformTexture=null},i._getMaxMiplevel=function(e){return Math.floor(Math.log2(e))},i._getMipmapCount=function(){return this._mipmap?Math.floor(Math.log2(Math.max(this._width,this._height)))+1:1},i._isIntFormat=function(){return G.R32G32B32A32_UInt===this._format},j(s,[{key:"format",get:function(){return this._format}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"usage",get:function(){return this._usage}},{key:"wrapModeU",get:function(){return this._wrapModeU},set:function(e){e!==this._wrapModeU&&(this._wrapModeU=e,this._platformTexture.wrapModeU=e)}},{key:"wrapModeV",get:function(){return this._wrapModeV},set:function(e){e!==this._wrapModeV&&(this._wrapModeV=e,this._platformTexture.wrapModeV=e)}},{key:"mipmapCount",get:function(){return this._mipmapCount}},{key:"filterMode",get:function(){return this._filterMode},set:function(e){if(e!==this._filterMode){if(e!==tt.Point&&this._isIntFormat()){e=tt.Point,ve.warn("Int or UInt format texture only support TextureFilterMode.Point");return}this._filterMode=e,this._platformTexture.filterMode=e}}},{key:"anisoLevel",get:function(){return this._anisoLevel},set:function(e){var r=this._engine._hardwareRenderer.capability.maxAnisoLevel;e>r&&(ve.warn("anisoLevel:"+e+", exceeds the limit and is automatically downgraded to:"+r),e=r),e<1&&(ve.warn("anisoLevel:"+e+", must be greater than 0, and is automatically downgraded to 1"),e=1),e!==this._anisoLevel&&(this._anisoLevel=e,this._platformTexture.anisoLevel=e)}},{key:"depthCompareFunction",get:function(){return this._depthCompareFunction},set:function(e){if(!this._engine._hardwareRenderer._isWebGL2){console.warn("depthCompareFunction only support WebGL2");return}e!==this._depthCompareFunction&&(this._depthCompareFunction=e,this._platformTexture.depthCompareFunction=e)}}]),s}(ki),Nr=function(){function n(i){this._propertyValueMap=Object.create(null),this._macroCollection=new Kt,this._macroMap=Object.create(null),this._refCount=0,this._group=i}var s=n.prototype;return s.getFloat=function(t){return this.getPropertyValue(t)},s.setFloat=function(t,e){this._setPropertyValue(t,Vt.Float,e)},s.getInt=function(t){return this.getPropertyValue(t)},s.setInt=function(t,e){this._setPropertyValue(t,Vt.Int,e)},s.getFloatArray=function(t){return this.getPropertyValue(t)},s.setFloatArray=function(t,e){this._setPropertyValue(t,Vt.FloatArray,e)},s.getIntArray=function(t){return this.getPropertyValue(t)},s.setIntArray=function(t,e){this._setPropertyValue(t,Vt.IntArray,e)},s.getVector2=function(t){return this.getPropertyValue(t)},s.setVector2=function(t,e){this._setPropertyValue(t,Vt.Vector2,e)},s.getVector3=function(t){return this.getPropertyValue(t)},s.setVector3=function(t,e){this._setPropertyValue(t,Vt.Vector3,e)},s.getVector4=function(t){return this.getPropertyValue(t)},s.setVector4=function(t,e){this._setPropertyValue(t,Vt.Vector4,e)},s.getMatrix=function(t){return this.getPropertyValue(t)},s.setMatrix=function(t,e){this._setPropertyValue(t,Vt.Matrix,e)},s.getColor=function(t){return this.getPropertyValue(t)},s.setColor=function(t,e){this._setPropertyValue(t,Vt.Color,e)},s.getTexture=function(t){return this.getPropertyValue(t)},s.setTexture=function(t,e){var r=this._refCount;if(r>0){var a=this.getPropertyValue(t);a&&a._addReferCount(-r),e&&e._addReferCount(r)}this._setPropertyValue(t,Vt.Texture,e)},s.getTextureArray=function(t){return this.getPropertyValue(t)},s.setTextureArray=function(t,e){var r=this._refCount;if(r>0){var a=this.getPropertyValue(t);if(a)for(var o=0,c=a.length;o0&&u._addReferCount(e);else if(lt(u,Array)||lt(u,Float32Array)||lt(u,Int32Array))a[_]=u.slice();else{var h=a[_];h?h.copyFrom(u):a[_]=u.clone()}else a[_]=u}},s._setPropertyValue=function(t,e,r){if(typeof t=="string"&&(t=O.getByName(t)),t._group!==this._group)if(t._group===void 0)t._group=this._group;else throw"Shader property "+t.name+" has been used as "+xr[t._group]+" group.";if(t._type!==e)if(t._type===void 0)t._type=e;else throw"Shader property "+t.name+" has been used as "+Vt[t._type]+" type.";this._propertyValueMap[t._uniqueId]=r},s._getReferCount=function(){return this._refCount},s._addReferCount=function(t){this._refCount+=t;var e=this._propertyValueMap;for(var r in e){var a=e[r];a&<(a,Wr)&&a._addReferCount(t)}},n}();T([F],Nr.prototype,"_group",void 0);T([F],Nr.prototype,"_propertyValueMap",void 0);T([F],Nr.prototype,"_macroCollection",void 0);T([F],Nr.prototype,"_macroMap",void 0);T([F],Nr.prototype,"_refCount",void 0);var Pr,ye=(Pr=function(n){W(s,n);function s(t){var e;e=n.call(this,t)||this,e._onUpdateIndex=-1,e._rendererIndex=-1,e._globalShaderMacro=new Kt,e._bounds=new lr,e._overrideUpdate=!1,e._materials=[],e._dirtyUpdateFlag=0,e._shaderData=new Nr(xr.Renderer),e._mvMatrix=new Z,e._mvpMatrix=new Z,e._mvInvMatrix=new Z,e._normalMatrix=new Z,e._materialsInstanced=[],e._priority=0,e._receiveShadows=!0,e._rendererLayer=new ie,e.castShadows=!0;var r=ye.prototype,a=e.shaderData;return e._overrideUpdate=e.update!==r.update,e._addResourceReferCount(e.shaderData,1),e._onTransformChanged=e._onTransformChanged.bind(ce(e)),e._registerEntityTransformListener(),a.enableMacro(ye._receiveShadowMacro),a.setVector4(ye._rendererLayerProperty,e._rendererLayer),e}var i=s.prototype;return i.getInstanceMaterial=function(e){e===void 0&&(e=0);var r=this._materials;if(r.length>e){var a=r[e];if(a)return this._materialsInstanced[e]?a:this._createInstanceMaterial(a,e)}return null},i.getMaterial=function(e){return e===void 0&&(e=0),this._materials[e]||null},i.setMaterial=function(e,r){r===void 0&&(r=null),typeof e=="number"?this._setMaterial(e,r):this._setMaterial(0,e)},i.getInstanceMaterials=function(){for(var e=this._materials,r=this._materialsInstanced,a=0,o=e.length;a>>16&65535,0,0)},i._updateTransformShaderData=function(e,r){var a=this.shaderData,o=this._mvMatrix,c=this._mvInvMatrix,l=this._normalMatrix;Z.multiply(e.viewMatrix,r,o),Z.invert(o,c),Z.invert(r,l),l.transpose(),a.setMatrix(ye._localMatrixProperty,this.entity.transform.localMatrix),a.setMatrix(ye._worldMatrixProperty,r),a.setMatrix(ye._mvMatrixProperty,o),a.setMatrix(ye._mvInvMatrixProperty,c),a.setMatrix(ye._normalMatrixProperty,l),this._updateMVPShaderData(e,r)},i._updateMVPShaderData=function(e,r){var a=this._mvpMatrix;Z.multiply(e.viewProjectionMatrix,r,a),this.shaderData.setMatrix(ye._mvpMatrixProperty,a)},i._registerEntityTransformListener=function(){this.entity.transform._updateFlagManager.addListener(this._onTransformChanged)},i._unRegisterEntityTransformListener=function(){this.entity.transform._updateFlagManager.removeListener(this._onTransformChanged)},i._updateBounds=function(e){},i._render=function(e){throw"not implement"},i._createInstanceMaterial=function(e,r){var a=e.clone();return a.name=a.name+"(Instance)",this._addResourceReferCount(e,-1),this._addResourceReferCount(a,1),this._materialsInstanced[r]=!0,this._materials[r]=a,a},i._setMaterial=function(e,r){var a=this._materials;e>=a.length&&(a.length=e+1);var o=a[e];if(o!==r){var c=this._materialsInstanced;ee&&(a.length=e)}},{key:"bounds",get:function(){return this._dirtyUpdateFlag&1&&(this._updateBounds(this._bounds),this._dirtyUpdateFlag&=-2),this._bounds}},{key:"priority",get:function(){return this._priority},set:function(e){this._priority=e}}]),s}(Rt),function(){Pr._tempVector0=new R}(),function(){Pr._receiveShadowMacro=oe.getByName("RENDERER_IS_RECEIVE_SHADOWS")}(),function(){Pr._localMatrixProperty=O.getByName("renderer_LocalMat")}(),function(){Pr._worldMatrixProperty=O.getByName("renderer_ModelMat")}(),function(){Pr._mvMatrixProperty=O.getByName("renderer_MVMat")}(),function(){Pr._mvpMatrixProperty=O.getByName("renderer_MVPMat")}(),function(){Pr._mvInvMatrixProperty=O.getByName("renderer_MVInvMat")}(),function(){Pr._normalMatrixProperty=O.getByName("renderer_NormalMat")}(),function(){Pr._rendererLayerProperty=O.getByName("renderer_Layer")}(),Pr);T([F],ye.prototype,"_distanceForSort",void 0);T([F],ye.prototype,"_onUpdateIndex",void 0);T([F],ye.prototype,"_rendererIndex",void 0);T([F],ye.prototype,"_globalShaderMacro",void 0);T([F],ye.prototype,"_bounds",void 0);T([F],ye.prototype,"_renderFrameCount",void 0);T([F],ye.prototype,"_overrideUpdate",void 0);T([F],ye.prototype,"_materials",void 0);T([F],ye.prototype,"_dirtyUpdateFlag",void 0);T([J],ye.prototype,"_shaderData",void 0);T([F],ye.prototype,"_mvMatrix",void 0);T([F],ye.prototype,"_mvpMatrix",void 0);T([F],ye.prototype,"_mvInvMatrix",void 0);T([F],ye.prototype,"_normalMatrix",void 0);T([F],ye.prototype,"_materialsInstanced",void 0);T([Me],ye.prototype,"_priority",void 0);T([Me],ye.prototype,"_receiveShadows",void 0);T([F],ye.prototype,"_rendererLayer",void 0);T([F],ye.prototype,"_onTransformChanged",null);ye=T([ka(ge,Hn.CheckOnly)],ye);var Qe;(function(n){n[n.WorldVolume=1]="WorldVolume"})(Qe||(Qe={}));function kt(){return function(n){}}var Za,nn=(Za=function(){function n(){}return n.resetData=function(i){var t=i._verticesData,e=t.positions,r=t.uvs;t.vertexCount=e.length=r.length=4;for(var a=0;a<4;a++){var o,c,l,_;(o=e)[c=a]||(o[c]=new R),(l=r)[_=a]||(l[_]=new ee)}t.triangles=nn._rectangleTriangles},n.updatePositions=function(i){var t=i.width,e=i.height,r=i.sprite,a=r.pivot,o=a.x,c=a.y,l=nn._worldMatrix,_=l.elements,u=i.entity.transform.worldMatrix,h=u.elements,d=i.flipX?-t:t,f=i.flipY?-e:e;_[0]=h[0]*d,_[1]=h[1]*d,_[2]=h[2]*d,_[4]=h[4]*f,_[5]=h[5]*f,_[6]=h[6]*f,_[8]=h[8],_[9]=h[9],_[10]=h[10],_[12]=h[12]-o*_[0]-c*_[4],_[13]=h[13]-o*_[1]-c*_[5],_[14]=h[14]-o*_[2]-c*_[6];for(var v=r._getPositions(),p=i._verticesData.positions,g=0;g<4;g++){var y=v[g],m=y.x,x=y.y;p[g].set(_[0]*m+_[4]*x+_[12],_[1]*m+_[5]*x+_[13],_[2]*m+_[6]*x+_[14])}lr.transform(r._getBounds(),l,i._bounds)},n.updateUVs=function(i){var t=i.sprite._getUVs(),e=i._verticesData.uvs,r=t[0],a=r.x,o=r.y,c=t[3],l=c.x,_=c.y;e[0].set(a,o),e[1].set(l,o),e[2].set(a,_),e[3].set(l,_)},n}(),function(){Za._rectangleTriangles=[0,1,2,2,1,3]}(),function(){Za._worldMatrix=new Z}(),Za);nn=T([kt()],nn);var $a,Ma=($a=function(){function n(){}return n.resetData=function(i){var t=i._verticesData,e=t.positions,r=t.uvs;t.vertexCount=e.length=r.length=16;for(var a=0;a<16;a++){var o,c,l,_;(o=e)[c=a]||(o[c]=new R),(l=r)[_=a]||(l[_]=new ee)}t.triangles=Ma._rectangleTriangles},n.updatePositions=function(i){var t=i.width,e=i.height,r=i.sprite,a=i._verticesData,o=a.positions,c=a.uvs,l=r.border,_=r._getUVs(),u=r._getPositions(),h=u[0],d=h.x,f=h.y,v=u[3],p=v.x,g=v.y,y=r.width,m=r.height,x=y*l.x,C=m*l.y,b=y*l.z,A=m*l.w,S,w;if(x+b>t){var E=t/(x+b);S=[y*d*E,x*E,x*E,t-y*(1-p)*E]}else S=[y*d,x,t-b,t-y*(1-p)];if(A+C>e){var P=e/(A+C);w=[m*f*P,C*P,C*P,e-m*(1-g)*P]}else w=[m*f,C,e-A,e-m*(1-g)];var M=i.sprite.pivot,D=M.x,L=M.y,V=i.width*D,N=i.height*L,I=Ma._worldMatrix,B=I.elements,z=i.entity.transform.worldMatrix,U=z.elements,Y=i.flipX?-1:1,Q=i.flipY?-1:1;B[0]=U[0]*Y,B[1]=U[1]*Y,B[2]=U[2]*Y,B[4]=U[4]*Q,B[5]=U[5]*Q,B[6]=U[6]*Q,B[8]=U[8],B[9]=U[9],B[10]=U[10],B[12]=U[12]-V*B[0]-N*B[4],B[13]=U[13]-V*B[1]-N*B[5],B[14]=U[14]-V*B[2]-N*B[6];for(var H=0;H<4;H++)for(var te=S[H],Ce=_[H].x,de=0;de<4;de++){var ae=w[de],Ae=H*4+de;o[Ae].set(B[0]*te+B[4]*ae+B[12],B[1]*te+B[5]*ae+B[13],B[2]*te+B[6]*ae+B[14]),c[Ae].set(Ce,_[de].y)}var je=i._bounds,_t=je.min,xe=je.max;_t.set(S[0],w[0],0),xe.set(S[3],w[3],0),i._bounds.transform(I)},n.updateUVs=function(i){},n}(),function(){$a._rectangleTriangles=[0,1,4,1,5,4,1,2,5,2,6,5,2,3,6,3,7,6,4,5,8,5,9,8,5,6,9,6,10,9,6,7,10,7,11,10,8,9,12,9,13,12,9,10,13,10,14,13,10,11,14,11,15,14]}(),function(){$a._worldMatrix=new Z}(),$a);Ma=T([kt()],Ma);var He=function(){function n(i){i===void 0&&(i=0),this.length=0,this._isLooping=!1,this._blankCount=0,this._elements=new Array(i)}var s=n.prototype;return s.add=function(t){this.length===this._elements.length?this._elements.push(t):this._elements[this.length]=t,this.length++},s.delete=function(t){var e=this._elements.indexOf(t);this.deleteByIndex(e)},s.set=function(t,e){if(t>=this.length)throw"Index is out of range.";this._elements[t]=e},s.get=function(t){if(t>=this.length)throw"Index is out of range.";return this._elements[t]},s.deleteByIndex=function(t){var e=this._elements,r;if(this._isLooping)this._elements[t]=null,this._blankCount++;else{var a=this.length-1;t!==a&&(r=e[a],e[t]=r),e[a]=null,this.length--}return r},s.forEach=function(t,e){this._startLoop();for(var r=this._elements,a=0,o=this.length;a=r)break e;for(;!a[r];)if(e>=--r)break e;var o=a[r];t(o,e),a[e++]=o,a[r--]=null}while(e0){var c,l;(c=o[e])==null||c.buffer._addReferCount(-a),(l=r)==null||l.buffer._addReferCount(a)}o[e]=r,this._bufferStructChanged=!0},i.setVertexBufferBindings=function(e,r){r===void 0&&(r=0);var a=this.vertexBufferBindings,o=e.length,c=r+o;a.length0&&((o=r)==null||o.buffer._addReferCount(-a)),e?(a>0&&e.buffer._addReferCount(a),this._glIndexType=pi._getGLIndexType(e.format),this._glIndexByteCount=pi._getGLIndexByteCount(e.format)):this._glIndexType=void 0,this._bufferStructChanged=((c=r)==null?void 0:c.buffer)!==((l=e)==null?void 0:l.buffer)}},i.draw=function(e,r){this._platformPrimitive.draw(e,r),this._bufferStructChanged=!1},i._addReferCount=function(e){var r;n.prototype._addReferCount.call(this,e);for(var a=this.vertexBufferBindings,o=0,c=a.length;o0&&t.deltaPositions.length!==e[r-1].deltaPositions.length)throw"Frame's deltaPositions length must same with before frame deltaPositions length.";this._frames.push(t),this._frameDataChangeListener(oo.All,t),t._dataChangeManager.addListener(this._frameDataChangeListener)},s._updateUseNormalAndTangent=function(t,e){var r=this._useBlendShapeNormal&&t,a=this._useBlendShapeTangent&&e;(this._useBlendShapeNormal!==r||this._useBlendShapeTangent!==a)&&(this._useBlendShapeNormal=r,this._useBlendShapeTangent=a,this._layoutChangeManager.dispatch(0,this))},s._frameDataChangeListener=function(t,e){this._updateUseNormalAndTangent(!!e.deltaNormals,!!e.deltaTangents),this._dataChangeManager.dispatch()},j(n,[{key:"frames",get:function(){return this._frames}}]),n}(),Po=function(n){W(s,n);function s(){return n.apply(this,arguments)}var i=s.prototype;return i.setVertexElements=function(e){this._setVertexElements(e)},i.setVertexBufferBinding=function(e,r,a){r===void 0&&(r=0),a===void 0&&(a=0);var o=e,c=o.buffer!==void 0;c||(o=new Wn(e,r));var l=this._primitive.vertexBufferBindings;l.length<=a&&(l.length=a+1),this._setVertexBufferBinding(c?r:a,o)},i.setVertexBufferBindings=function(e,r){r===void 0&&(r=0);var a=this._primitive.vertexBufferBindings,o=e.length,c=r+o;a.length>e,this._height>>e,e,r):_===5?this._platformTexture.getPixelBuffer(e,r,a,o,0,c):_===6&&this._platformTexture.getPixelBuffer(e,r,a,o,c,l)},i._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2D(this),n.prototype._rebuild.call(this)},s}(Wr),Bo=function(n){W(s,n);function s(t,e,r,a,o,c){o===void 0&&(o=G.R8G8B8A8),c===void 0&&(c=!0);var l;return l=n.call(this,t)||this,l._mipmap=c,l._width=e,l._height=r,l._length=a,l._format=o,l._mipmapCount=l._getMipmapCount(),l._platformTexture=t._hardwareRenderer.createPlatformTexture2DArray(ce(l)),l.filterMode=tt.Bilinear,l.wrapModeU=l.wrapModeV=gt.Repeat,l}var i=s.prototype;return i.setPixelBuffer=function(e,r,a,o,c,l,_,u){a===void 0&&(a=0),o===void 0&&(o=0),c===void 0&&(c=0),this._platformTexture.setPixelBuffer(e,r,a,o,c,l,_,u),this._isContentLost=!1},i.setImageSource=function(e,r,a,o,c,l,_){a===void 0&&(a=0),o===void 0&&(o=!1),c===void 0&&(c=!1),l===void 0&&(l=0),_===void 0&&(_=0),this._platformTexture.setImageSource(e,r,a,o,c,l,_),this._isContentLost=!1},i.getPixelBuffer=function(e,r,a,o,c,l,_){var u=arguments.length;u===1?this._platformTexture.getPixelBuffer(e,0,0,this._width,this._height,0,r):u===2?this._platformTexture.getPixelBuffer(e,0,0,this._width>>r,this._height>>r,r,a):u===5?this._platformTexture.getPixelBuffer(e,r,a,o,c,0,l):u===6&&this._platformTexture.getPixelBuffer(e,r,a,o,c,l,_)},i._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2DArray(this),n.prototype._rebuild.call(this)},j(s,[{key:"length",get:function(){return this._length}}]),s}(Wr),jt=function(n){W(s,n);function s(t,e,r,a){r===void 0&&(r=G.R8G8B8A8),a===void 0&&(a=!0);var o;return o=n.call(this,t)||this,o._mipmap=a,o._width=e,o._height=e,o._format=r,o._mipmapCount=o._getMipmapCount(),o._platformTexture=t._hardwareRenderer.createPlatformTextureCube(ce(o)),o.filterMode=tt.Bilinear,o.wrapModeU=o.wrapModeV=gt.Clamp,o}var i=s.prototype;return i.setPixelBuffer=function(e,r,a,o,c,l,_){a===void 0&&(a=0),o===void 0&&(o=0),c===void 0&&(c=0),this._platformTexture.setPixelBuffer(e,r,a,o,c,l,_),this._isContentLost=!1},i.setImageSource=function(e,r,a,o,c,l,_){a===void 0&&(a=0),o===void 0&&(o=!1),c===void 0&&(c=!1),l===void 0&&(l=0),_===void 0&&(_=0),this._platformTexture.setImageSource(e,r,a,o,c,l,_),this._isContentLost=!1},i.getPixelBuffer=function(e,r,a,o,c,l,_){var u=arguments.length;u===2?this._platformTexture.getPixelBuffer(e,0,0,this._width,this._height,0,r):u===3?this._platformTexture.getPixelBuffer(e,0,0,this._width>>r,this._height>>r,r,a):u===6?this._platformTexture.getPixelBuffer(e,r,a,o,c,0,l):u===7&&this._platformTexture.getPixelBuffer(e,r,a,o,c,l,_)},i._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTextureCube(this),n.prototype._rebuild.call(this)},s}(Wr),Tn=function(){function n(i,t){this._blendShapeCount=0,this._blendShapes=[],this._subDataDirtyFlags=[],this._vertexBuffers=[],this._uniformOccupiesCount=0,this._bufferBindingOffset=-1,this._vertexElementOffset=0,this._useBlendNormal=!1,this._useBlendTangent=!1,this._vertexElementCount=0,this._storeInVertexBufferInfo=[],this._maxCountSingleVertexBuffer=0,this._lastHostCreatedInfo=new ie,this._canUseTextureStoreData=!0,this._dataTextureInfo=new R,this._engine=i,this._modelMesh=t,this._canUseTextureStoreData=this._engine._hardwareRenderer.capability.canUseFloatTextureBlendShape,this._updateLayoutChange=this._updateLayoutChange.bind(this)}var s=n.prototype;return s._addBlendShape=function(t){this._blendShapes.push(t),this._blendShapeCount++,t._layoutChangeManager.addListener(this._updateLayoutChange),this._updateLayoutChange(0,t),this._subDataDirtyFlags.push(t._dataChangeManager.createFlag(zi))},s._clearBlendShapes=function(){for(var t=this._blendShapes,e=0,r=t.length;e0){if(t.enableMacro(n._blendShapeMacro),this._useTextureMode())t.enableMacro(n._blendShapeTextureMacro),t.setTexture(n._blendShapeTextureProperty,this._vertexTexture),t.setVector3(n._blendShapeTextureInfoProperty,this._dataTextureInfo),t.setFloatArray(n._blendShapeWeightsProperty,e.blendShapeWeights),t.enableMacro("RENDERER_BLENDSHAPE_COUNT",r.toString()),this._uniformOccupiesCount=r+1;else{var a=this._getVertexBufferModeSupportCount();if(r>a){var o=e._condensedBlendShapeWeights;o||(o=new Float32Array(a),e._condensedBlendShapeWeights=o),this._filterCondensedBlendShapeWeights(e.blendShapeWeights,o),t.setFloatArray(n._blendShapeWeightsProperty,o),this._modelMesh._primitive.enableVAO=!1,r=a}else t.setFloatArray(n._blendShapeWeightsProperty,e.blendShapeWeights),this._modelMesh._primitive.enableVAO=!0;t.disableMacro(n._blendShapeTextureMacro),t.disableMacro("RENDERER_BLENDSHAPE_COUNT"),this._uniformOccupiesCount=r}this._useBlendNormal?t.enableMacro(n._blendShapeNormalMacro):t.disableMacro(n._blendShapeNormalMacro),this._useBlendTangent?t.enableMacro(n._blendShapeTangentMacro):t.disableMacro(n._blendShapeTangentMacro)}else t.disableMacro(n._blendShapeMacro),t.disableMacro("RENDERER_BLENDSHAPE_COUNT")},s._useTextureMode=function(){return this._canUseTextureStoreData?this._blendShapeCount>this._getVertexBufferModeSupportCount():!1},s._isCreateHost=function(t){var e=this._lastHostCreatedInfo;return e.x!==this._blendShapeCount||!!e.y!==this._useBlendNormal||!!e.z!==this._useBlendTangent||e.w!==t},s._vertexElementsNeedUpdate=function(){var t=this._getVertexBufferModeSupportCount(),e=this._lastHostCreatedInfo;return Math.min(e.x,t)!==Math.min(this._blendShapeCount,t)||!!e.y!==this._useBlendNormal||!!e.z!==this._useBlendTangent},s._needUpdateData=function(){for(var t=this._subDataDirtyFlags,e=0,r=t.length;ee&&(o=Math.ceil(a/e),a=e);var c=this._vertexTexture,l=this._blendShapes.length;c&&c.destroy(),c=new Bo(this._engine,a,o,l,G.R32G32B32A32,!1),c.filterMode=tt.Point,this._vertices=new Float32Array(l*a*o*4),this._vertexTexture=c,this._dataTextureInfo.set(r,a,o)},s._updateVertexBuffers=function(t,e){for(var r=this,a=r._blendShapes,o=r._maxCountSingleVertexBuffer,c=this,l=c._vertices,_=c._vertexBuffers,u=c._storeInVertexBufferInfo,h=this._subDataDirtyFlags,d=this._vertexElementCount*3,f=d*4,v=this._bufferBindingOffset,p=0,g=a.length;p0&&C.deltaPositions.length!==t)throw"BlendShape frame deltaPositions length must same with mesh vertexCount.";var b=Math.floor(p/o),A=p%o,S=_[b],w=S.byteLength/(t*4),E=A*d,P=u[p];P||(u[p]=P=new ee),P.set(v+b,A*f);for(var M=C.deltaPositions,D=0;D0&&p.deltaPositions.length!==t)throw"BlendShape frame deltaPositions length must same with mesh vertexCount.";for(var g=p.deltaPositions,y=p.deltaNormals,m=p.deltaTangents,x=_*d,C=0;C1,a=1,o=e._useBlendShapeNormal,c=e._useBlendShapeTangent;r&&(o&&(o=this._useBlendNormal),c&&(c=this._useBlendTangent)),o&&a++,c&&a++,this._useBlendNormal=o,this._useBlendTangent=c,this._vertexElementCount=a},s._attributeModeUpdateVertexElement=function(t,e,r,a){var o=this._vertexElementOffset+this._vertexElementCount*a,c=e[r],l=c.x,_=c.y,u=t[o];if(u.bindingIndex=l,u.offset=_,this._useBlendNormal){var h=t[++o];_+=12,h.bindingIndex=l,h.offset=_}if(this._useBlendTangent){var d=t[++o];_+=12,d.bindingIndex=l,d.offset=_}},s._getVertexBufferModeSupportCount=function(){return this._useBlendNormal&&this._useBlendTangent?2:this._useBlendNormal||this._useBlendTangent?4:8},s._filterCondensedBlendShapeWeights=function(t,e){for(var r=e.length,a=this._modelMesh._primitive.vertexElements,o=this._storeInVertexBufferInfo,c=Number.POSITIVE_INFINITY,l,_=0,u=Math.min(t.length,this._blendShapeCount);_c){this._attributeModeUpdateVertexElement(a,o,_,l),e[l]=h,c=Number.POSITIVE_INFINITY;for(var d=0;d0&&m._update(e),e&&(this._accessible=!1,this._releaseCache(!1))},i.calculateTangents=function(){var e=this.getPositions(),r=this.getNormals(),a=this.getUVs();if(!r||!a)throw"Set normal and uv before calculation.";for(var o=this,c=o._indices,l=o.vertexCount,_=s._tempVec0,u=s._tempVec1,h=s._tempVec2,d=s._tempVec3,f=s._tempVec4,v=c?c.length/3:e.length/3,p=new Array(l),g=new Array(l),y=0;y0?1:-1;R.scale(U,R.dot(h,U),f),R.subtract(h,f,h),h.normalize(),Q.set(h.x,h.y,h.z,H)}this.setTangents(p)},i._setVertexBufferBinding=function(e,r){var a=this,o=this._primitive.vertexBufferBindings,c=this._vertexBufferInfos,l=function(){a._advancedDataSyncToBuffer||(c[e].dataVersion=a._dataVersionCounter++)},_=o[e];if(_&&_.buffer._dataUpdateManager.removeListener(l),n.prototype._setVertexBufferBinding.call(this,e,r),r){var u,h;r.buffer._dataUpdateManager.addListener(l),((u=c)[h=e]||(u[h]=new D_)).reset(),l()}else e+1==o.length&&o.length--},i._getVertexTypedArray=function(e,r){switch(r){case Ie.BYTE:return new Int8Array(e);case Ie.UNSIGNED_BYTE:return new Uint8Array(e);case Ie.SHORT:return new Int16Array(e);case Ie.UNSIGNED_SHORT:return new Uint16Array(e);case Ie.FLOAT:return new Float32Array(e)}},i._onDestroy=function(){n.prototype._onDestroy.call(this),this._releaseCache(!0)},i._getVertexElementData=function(e,r,a,o){var c=this._advancedVertexDataVersions,l,_=(l=c[a])!=null?l:-1,u=this._primitive._vertexElementMap[r],h=u?this._vertexBufferInfos[u.bindingIndex].dataVersion:-1;return _>=h?e:(c[a]=h,o.call(this,r))},i._beforeSetAdvancedVertexData=function(e,r,a){if(e&&e.length!==this._vertexCount)throw"The array provided needs to be the same size as vertex count.";this._updateAdvancedVertexDataMarks(r,a)},i._updateAdvancedVertexDataMarks=function(e,r){this._advancedElementUpdateFlag|=e,this._advancedDataUpdateFlag|=e,this._advancedVertexDataVersions[r]=this._dataVersionCounter++},i._updateInternalVertexBuffer=function(e){var r=this._internalVertexBufferStride,a=this.vertexCount,o=this._internalVertexBufferCreatedInfo,c=r*a;if(o.x*o.y!==c){var l=o.z;if(l!==-1){var _;(_=this._primitive.vertexBufferBindings[l])==null||_.buffer.destroy(),this._setVertexBufferBinding(l,null)}var u=this._internalVertexBufferIndex,h=r*this.vertexCount>0;if(h){this._advancedDataUpdateFlag|=this._internalVertexElementsFlags;var d=e?Je.Static:Je.Dynamic,f=new Jt(this._engine,Mt.VertexBuffer,c,d,!0);this._setVertexBufferBinding(u,new Wn(f,r))}o.set(r,a,h?u:-1)}},i._readVector2VertexData=function(e){return this._readVertexData(e,function(r,a){return new ee(r[a],r[a+1])})},i._readVector3VertexData=function(e){return this._readVertexData(e,function(r,a){return new R(r[a],r[a+1],r[a+2])})},i._readVector4VertexData=function(e){return this._readVertexData(e,function(r,a){return new ie(r[a],r[a+1],r[a+2],r[a+3])})},i._readColorVertexData=function(e){return this._readVertexData(e,function(r,a){return new q(r[a],r[a+1],r[a+2],r[a+3])})},i._readVertexData=function(e,r){var a,o=this._primitive,c=o._vertexElementMap[e];if(!c)return null;var l=o.vertexBufferBindings[c.bindingIndex],_=(a=l)==null?void 0:a.buffer;if(!_)return null;if(!_.readable)throw"Not allowed to access data while vertex buffer readable is false.";for(var u=this.vertexCount,h=c._formatMetaInfo,d=new Array(u),f=this._getVertexTypedArray(_.data.buffer,h.type),v=c.offset,p=l.stride,g=0;g=this._internalVertexElementsOffset?(this._internalVertexBufferStride-=this._getAttributeByteLength(r),this._internalVertexElementsFlags&=~a):this._internalVertexElementsOffset--,this._blendShapeManager._vertexElementOffset--,this._removeVertexElement(d)}}},i._updateAdvancedVertexElements=function(){var e=this._advancedElementUpdateFlag;e&1&&this._updateAdvancedVertexElement(this._positions,X.Position,1),e&2&&this._updateAdvancedVertexElement(this._normals,X.Normal,2),e&4&&this._updateAdvancedVertexElement(this._colors,X.Color,4),e&16&&this._updateAdvancedVertexElement(this._boneWeights,X.BoneWeight,16),e&32&&this._updateAdvancedVertexElement(this._boneIndices,X.BoneIndex,32),e&8&&this._updateAdvancedVertexElement(this._tangents,X.Tangent,8),e&64&&this._updateAdvancedVertexElement(this._uv,X.UV,64),e&128&&this._updateAdvancedVertexElement(this._uv1,X.UV1,128),e&256&&this._updateAdvancedVertexElement(this._uv2,X.UV2,256),e&512&&this._updateAdvancedVertexElement(this._uv3,X.UV3,512),e&1024&&this._updateAdvancedVertexElement(this._uv4,X.UV4,1024),e&2048&&this._updateAdvancedVertexElement(this._uv5,X.UV5,2048),e&4096&&this._updateAdvancedVertexElement(this._uv6,X.UV6,4096),e&8192&&this._updateAdvancedVertexElement(this._uv7,X.UV7,8192)},i._updateVertexElements=function(){var e=this._primitive.vertexElements,r=this._blendShapeManager,a=e.length,o=r._vertexElementOffset;this._advancedElementUpdateFlag&65535&&(this._updateAdvancedVertexElements(),this._advancedElementUpdateFlag=0);var c=!r._useTextureMode()&&r._vertexElementsNeedUpdate();if(o!==r._vertexElementOffset||c&&r._blendShapeCount>0){var l=r._addVertexElements(this);lv.dataVersion){for(var p=l._formatMetaInfo,g=this._getVertexTypedArray(h.data.buffer,p.type),y=l.offset,m=u.stride,x=g.BYTES_PER_ELEMENT,C=p.normalized,b=p.size,A=p.normalizedScaleFactor,S=0,w=this._vertexCount;S65535)if(i._hardwareRenderer.canIUse(K.elementIndexUint))r=new Uint32Array(e);else throw Error("The vertex count is over limit.");else r=new Uint16Array(e);return r},n._createCapsuleCap=function(i,t,e,r,a,o,c,l,_,u){for(var h=e+1,d=t*.5*c,f=h*h,v=e*e,p=1/h,g=1/e,y=8,m=0;m=0;r--){var a=e[r];a._parent=null;var o=ue.None;a._isActiveInHierarchy&&(o|=ue.Hierarchy),a._isActiveInScene&&(o|=ue.Scene),o&&a._processInActive(o),s._traverseSetOwnerScene(a,null)}e.length=0},i.clone=function(){var e=this._createCloneEntity(this);return this._parseCloneEntity(this,e,this,e,new Map),e},i._markAsTemplate=function(e){this._isTemplate=!0,this._templateResource=e},i._createCloneEntity=function(e){var r=new s(e._engine,e.name),a=this._templateResource;a&&(r._templateResource=a,a._addReferCount(1)),r.layer=e.layer,r._isActive=e._isActive;var o=r.transform,c=e.transform;o.position=c.position,o.rotation=c.rotation,o.scale=c.scale;for(var l=e._children,_=0,u=e._children.length;_=0;r--)e[r].destroy();this._components.length=0;for(var a=this._children;a.length>0;)a[0].destroy();this._isRoot?this._scene.removeRootEntity(this):this._setParent(null),this.isActive=!1}},i._removeComponent=function(e){ca._removeCheck(this,e.constructor);var r=this._components;r.splice(r.indexOf(e),1)},i._addScript=function(e){e._entityScriptsIndex=this._scripts.length,this._scripts.add(e)},i._removeScript=function(e){var r=this._scripts.deleteByIndex(e._entityScriptsIndex);r&&(r._entityScriptsIndex=e._entityScriptsIndex),e._entityScriptsIndex=-1},i._removeFromParent=function(){var e=this._parent;if(e!=null){var r=e._children,a=this._siblingIndex;r.splice(a,1);for(var o=r.length;ao)throw"The index "+e+" is out of child list bounds "+o;r._siblingIndex=e,a.splice(e,0,r);for(var c=e+1,l=o+1;c=0;a--){var o=this._components[a];lt(o,e)&&r.push(o)}for(var c=this._children.length-1;c>=0;c--)this._children[c]._getComponentsInChildren(e,r)},i._setActiveComponents=function(e,r){for(var a=this._activeChangedComponents,o=0,c=a.length;o=r;o--){var c=o==r?this:e[o-1];e[o]=c,c._siblingIndex=o}else for(var l=a;l<=r;l++){var _=l==r?this:e[l+1];e[l]=_,_._siblingIndex=l}}},i.getInvModelMatrix=function(){return this._inverseWorldMatFlag.flag&&(Z.invert(this.transform.worldMatrix,this._invModelMatrix),this._inverseWorldMatFlag.flag=!1),this._invModelMatrix},s._findChildByName=function(e,r){for(var a=e._children,o=a.length-1;o>=0;o--){var c=a[o];if(c.name===r)return c}return null},s._traverseSetOwnerScene=function(e,r){e._scene=r;for(var a=e._children,o=a.length-1;o>=0;o--)this._traverseSetOwnerScene(a[o],r)},s._getEntityHierarchyPath=function(e,r,a){for(a.length=0;r!==e;){var o=r.parent;if(!o)return!1;a.push(r.siblingIndex),r=o}return!0},s._getEntityByHierarchyPath=function(e,r){for(var a=e,o=r.length-1;o>=0;o--)a=a.children[r[o]];return a},j(s,[{key:"isActive",get:function(){return this._isActive},set:function(e){if(e!==this._isActive)if(this._isActive=e,e){var r=this._parent,a=ue.None;if(this._isRoot&&this._scene._isActiveInEngine)a|=ue.All;else{var o,c;(o=r)!=null&&o._isActiveInHierarchy&&(a|=ue.Hierarchy),(c=r)!=null&&c._isActiveInScene&&(a|=ue.Scene)}a&&this._processActive(a)}else{var l=ue.None;this._isActiveInHierarchy&&(l|=ue.Hierarchy),this._isActiveInScene&&(l|=ue.Scene),l&&this._processInActive(l)}}},{key:"isActiveInHierarchy",get:function(){return this._isActiveInHierarchy}},{key:"parent",get:function(){return this._parent},set:function(e){this._setParent(e)}},{key:"children",get:function(){return this._children}},{key:"childCount",get:function(){return this._children.length}},{key:"scene",get:function(){return this._scene}},{key:"siblingIndex",get:function(){return this._siblingIndex},set:function(e){if(this._siblingIndex===-1)throw"The entity "+this.name+" is not in the hierarchy";this._setSiblingIndex(this._isRoot?this._scene._rootEntities:this._parent._children,e)}}]),s}(Yr),Mn=function(n){W(s,n);function s(t){var e;return e=n.call(this,null)||this,e.name=t,e.inverseBindMatrices=new Array,e._updatedManager=new Er,e._bones=new Array,e._updateMark=-1,e.joints=[],e}var i=s.prototype;return i._updateSkinMatrices=function(e){if(this._updateMark!==e.engine.time.frameCount){for(var r=this,a=r.bones,o=r.inverseBindMatrices,c=r._skinMatrices,l,_=((l=this.rootBone)!=null?l:e.entity).getInvModelMatrix(),u=a.length-1;u>=0;u--){var h=a[u],d=u*16;h?Ue._floatMatrixMultiply(h.transform.worldMatrix,o[u].elements,0,c,d):c.set(o[u].elements,d),Ue._floatMatrixMultiply(_,c,d,c,d)}this._updateMark=e.engine.time.frameCount}},i._cloneTo=function(e,r,a){var o=new Array,c=this.rootBone;if(c){var l=Yt._getEntityHierarchyPath(r,c,o);e.rootBone=l?Yt._getEntityByHierarchyPath(a,o):c}var _=this.bones;if(_.length>0){for(var u=_.length,h=new Array(u),d=0;d0&&r._updateSkinMatrices(this)},i._updateShaderData=function(e,r){var a,o,c=this,l=c.entity,_=c.skin,u,h=((u=(a=_)==null?void 0:a.rootBone)!=null?u:l).transform.worldMatrix;if(r){this._updateMVPShaderData(e,h);return}this._updateTransformShaderData(e,h);var d=this.shaderData,f=this.mesh,v=f._blendShapeManager;v._updateShaderData(d,this);var p=(o=_)==null?void 0:o.bones;if(p){var g=v._uniformOccupiesCount,y=p.length,m=this._jointDataCreateCache,x=y!==m.x;if(x||g!==m.y){var C=Math.ceil((this._maxVertexUniformVectors-(44+g))/4);if(y>C){var b=this.engine;if(b._hardwareRenderer.canIUseMoreJoints){if(x){var A;(A=this._jointTexture)==null||A.destroy(),this._jointTexture=new Tt(b,4,y,G.R32G32B32A32,!1),this._jointTexture.filterMode=tt.Point,this._jointTexture.isGCIgnored=!0}d.disableMacro("RENDERER_JOINTS_NUM"),d.enableMacro("RENDERER_USE_JOINT_TEXTURE"),d.setTexture(s._jointSamplerProperty,this._jointTexture)}else ve.error("component's joints count("+y+") greater than device's MAX_VERTEX_UNIFORM_VECTORS number "+this._maxVertexUniformVectors+", and don't support jointTexture in this device. suggest joint count less than "+C+".",this)}else{var S;(S=this._jointTexture)==null||S.destroy(),d.disableMacro("RENDERER_USE_JOINT_TEXTURE"),d.enableMacro("RENDERER_JOINTS_NUM",C.toString()),d.setFloatArray(s._jointMatrixProperty,_._skinMatrices)}m.set(y,g)}this._jointTexture&&this._jointTexture.setPixelBuffer(_._skinMatrices)}var w=l.layer;this._rendererLayer.set(w&65535,w>>>16&65535,0,0)},i._onDestroy=function(){var e;n.prototype._onDestroy.call(this),this._jointDataCreateCache=null,this._skin=null,this._blendShapeWeights=null,this._localBounds=null,(e=this._jointTexture)==null||e.destroy(),this._jointTexture=null},i._cloneTo=function(e,r,a){n.prototype._cloneTo.call(this,e,r,a),this.skin&&e._applySkin(null,e.skin),this._blendShapeWeights&&(e._blendShapeWeights=this._blendShapeWeights.slice())},i._updateBounds=function(e){var r,a=(r=this.skin)==null?void 0:r.rootBone;a?lr.transform(this._localBounds,a.transform.worldMatrix,e):n.prototype._updateBounds.call(this,e)},i._checkBlendShapeWeightLength=function(){var e=this._mesh,r=e?e.blendShapeCount:0,a=this._blendShapeWeights;if(a){var o=a.length;if(o!==r){var c=new Float32Array(r);if(r>o)c.set(a);else for(var l=0;l0?(a.enableMacro("RENDERER_HAS_SKIN"),a.setInt(s._jointCountProperty,r)):a.disableMacro("RENDERER_HAS_SKIN");break;case ea.RootBoneChanged:this._dirtyUpdateFlag|=Qe.WorldVolume;break}},i._applySkin=function(e,r){var a,o,c,l,_,u,h,d,f,v=(f=(o=e)==null||(a=o.bones)==null?void 0:a.length)!=null?f:0,p,g=(p=(c=e)==null?void 0:c.rootBone)!=null?p:this.entity;(l=e)==null||l._updatedManager.removeListener(this._onSkinUpdated);var y,m=(y=(u=r)==null||(_=u.bones)==null?void 0:_.length)!=null?y:0,x,C=(x=(h=r)==null?void 0:h.rootBone)!=null?x:this.entity;(d=r)==null||d._updatedManager.addListener(this._onSkinUpdated),v!==m&&this._onSkinUpdated(ea.BoneCountChanged,m),g!==C&&this._onSkinUpdated(ea.RootBoneChanged,C)},j(s,[{key:"skin",get:function(){return this._skin},set:function(e){var r=this._skin;r!==e&&(this._applySkin(r,e),this._skin=e)}},{key:"blendShapeWeights",get:function(){return this._checkBlendShapeWeightLength(),this._blendShapeWeights},set:function(e){this._checkBlendShapeWeightLength();var r=this._blendShapeWeights;if(e.length<=r.length)r.set(e);else for(var a=0,o=r.length;a=0;r--)e[r].dispose&&e[r].dispose()},n}(),Lr=function(){function n(i){this._subMeshPool=new Fn(Gi),this._batchedQueue=[],this._meshes=[],this._meshCount=1,this._vertexBuffers=[],this._indiceBuffers=[],this._flushId=0,this._vertexCount=0,this._elementCount=0,this._engine=i,this._initMeshes(i)}var s=n.prototype;return s.drawElement=function(t,e){var r=t.data;if(r.multiRenderData)for(var a=r.charsData,o=e.engine._renderElementPool,c=0,l=a.length;cn.MAX_VERTEX_COUNT&&this.flush(e),this._vertexCount+=r,this._batchedQueue[this._elementCount++]=t},s._createMesh=function(t,e){var r=n.MAX_VERTEX_COUNT,a=new Po(t,"BufferMesh"+e);a._addReferCount(1);var o=[],c=this.createVertexElements(o),l=this._vertexBuffers[e]=new Jt(t,Mt.VertexBuffer,r*c,Je.Dynamic),_=this._indiceBuffers[e]=new Jt(t,Mt.IndexBuffer,r*6,Je.Dynamic);return a.setVertexBufferBinding(l,c),a.setIndexBufferBinding(_,St.UInt16),a.setVertexElements(o),a},s._updateData=function(t){var e=this,r=e._meshes,a=e._flushId;!n._canUploadSameBuffer&&this._meshCount<=a&&(this._meshCount++,r[a]=this._createMesh(t,a));var o=this,c=o._batchedQueue,l=o._vertices,_=o._indices,u=r[a];u.clearSubMesh();for(var h=0,d=0,f=0,v=0,p=0,g=0,y=null,m=0,x=c.length;m=t?(U=3,B=0):M>k.zeroTolerance?(Q=(t-P)/M,Q=Q%1>=r?Math.ceil(Q):Math.floor(Q),U=4+Q-1,B=2):(U=4,B=1),V>=e?(Y=3,z=0):N>k.zeroTolerance?(H=(e-V)/N,H=H%1>=r?Math.ceil(H):Math.floor(H),Y=4+H-1,z=2):(Y=4,z=1),(U-1)*(Y-1)*4>Lr.MAX_VERTEX_COUNT){a.add(t*d),a.add(t*p),o.add(e*f),o.add(e*g),c.add(m.x),c.add(b.x),l.add(m.y),l.add(b.y),ve.warn("The number of vertices exceeds the upper limit("+Lr.MAX_VERTEX_COUNT+").");return}switch(B){case 0:I=t/P,a.add(A*d*I),a.add(w*I),a.add(t-A*(1-p)*I),c.add(m.x),c.add(x.x),c.add(C.x),c.add(b.x);break;case 1:a.add(A*d),a.add(w),a.add(t-E),a.add(t-A*(1-p)),c.add(m.x),c.add(x.x),c.add(NaN),c.add(NaN),c.add(C.x),c.add(b.x);break;case 2:I=t/(P+Q*M),a.add(A*d*I),a.add(w*I),c.add(m.x),c.add(x.x),c.add(x.x);for(var te=0,Ce=Q-1;te=t?(B=3,N=0):P>k.zeroTolerance?(U=(t-E)/P,B=4+(U|0),N=2):(B=4,N=1),L>=e?(z=3,I=0):V>k.zeroTolerance?(Y=(e-L)/V,z=4+(Y|0),I=2):(z=4,I=1),(B-1)*(z-1)*4>Lr.MAX_VERTEX_COUNT){r.add(t*h),r.add(t*v),a.add(e*d),a.add(e*p),o.add(y.x),o.add(C.x),c.add(y.y),c.add(C.y),ve.warn("The number of vertices exceeds the upper limit("+Lr.MAX_VERTEX_COUNT+").");return}switch(N){case 0:var Q=t/E;r.add(b*h*Q),r.add(S*Q),r.add(t-b*(1-v)*Q),o.add(y.x),o.add(m.x),o.add(x.x),o.add(C.x);break;case 1:r.add(b*h),r.add(S),r.add(t-w),r.add(t-b*(1-v)),o.add(y.x),o.add(m.x),o.add(NaN),o.add(NaN),o.add(x.x),o.add(C.x);break;case 2:r.add(b*h),r.add(S),o.add(y.x),o.add(m.x),o.add(m.x);for(var H=U|0,te=0;te=u||1+d>=u)throw Error("The char fontSize is too large.");var f=this._curX+h;f>=u&&(this._curX=l,this._curY=this._nextY+l);var v=this._curY+d;if(v>this._nextY&&(this._nextY=v),v>=u)return!1;r>0&&a>0&&o&&(e.bufferOffset=new ee(this._curX,this._curY),_.setPixelBuffer(o,0,this._curX,this._curY,r,a),_.generateMipmaps());var p=1/u,g=this._curX,y=this._curY,m=r,x=a,C=g*p,b=(g+m)*p,A=y*p,S=(y+x)*p;e.x=g,e.y=y;var w=e.uvs;return w[0].set(C,A),w[1].set(b,A),w[2].set(b,S),w[3].set(C,S),this._curX+=h+l,!0},i.addCharInfo=function(e,r){this._charInfoMap[e.charCodeAt(0)]=r},i.getCharInfo=function(e){return this._charInfoMap[e.charCodeAt(0)]},i._onDestroy=function(){n.prototype._onDestroy.call(this),this.texture.destroy(),this.texture=null,this._charInfoMap={}},s}(Qr),sr=function(){function n(){}return n.textContext=function(){var i=n._textContext;if(!i){var t;try{t=new OffscreenCanvas(0,0)}catch{t=document.createElement("canvas")}var e=t.getContext("2d",{willReadFrequently:!0});i={canvas:t,context:e},n._textContext=i}return i},n.measureFont=function(i){var t=n._fontSizeInfoCache,e=t[i];return e||(e=n._measureFontOrChar(i),t[i]=e,e)},n.getNativeFontString=function(i,t,e){var r=e&xn.Bold?"bold ":"";return e&xn.Italic&&(r+="italic "),!/([\"\'])[^\'\"]+\1/.test(i)&&n._genericFontFamilies.indexOf(i)==-1&&(i='"'+i+'"'),r+=t+"px "+i,r},n.measureChar=function(i,t){return n._measureFontOrChar(t,i)},n.measureTextWithWrap=function(i){var t=i._subFont,e=t.nativeFontString,r=n.measureFont(e),a=i.text.split(/(?:\r\n|\r|\n)/),o=new Array,c=new Array,l=new Array,_=hn._pixelsPerUnit,u=r.size+i.lineSpacing*_,h=i.width*_,d=0;t.nativeFontString=e;for(var f=0,v=a.length;f=19968&&L<=40959,I=D.w,B=D.offsetY,z=D.h*.5,U=z+B,Y=z-B;N?(g.length>0&&(b+y>h?(b>0&&this._pushLine(o,c,l,C,b,A,S),d=Math.max(d,b),w=!0,C=g,b=y,A=m,S=x):(C+=g,b+=y,A=Math.max(A,m),S=Math.max(S,x)),g="",y=m=x=0),b+I>h&&b>0?(this._pushLine(o,c,l,C,b,A,S),d=Math.max(d,b),w=!0,V?(C="",b=A=S=0):(C=M,b=D.xAdvance,A=U,S=Y)):(C+=M,b+=D.xAdvance,A=Math.max(A,U),S=Math.max(S,Y))):y+D.w>h?(b>0&&(this._pushLine(o,c,l,C,b,A,S),d=Math.max(d,b),C="",b=A=S=0),y>0&&this._pushLine(o,c,l,g,y,m,x),d=Math.max(d,y),w=!0,g=M,y=D.xAdvance,m=U,x=Y):(g+=M,y+=D.xAdvance,m=Math.max(m,U),x=Math.max(x,Y))}}y>0&&(b+y>h?(b>0&&this._pushLine(o,c,l,C,b,A,S),d=Math.max(d,b),b=0,y>0&&this._pushLine(o,c,l,g,y,m,x),d=Math.max(d,y)):(C+=g,b+=y,A=Math.max(A,m),S=Math.max(S,x))),b>0&&(this._pushLine(o,c,l,C,b,A,S),d=Math.max(d,b))}var Q=i.height*_;return i.overflowMode===Gn.Overflow&&(Q=u*o.length),{width:d,height:Q,lines:o,lineWidths:c,lineHeight:u,lineMaxSizes:l}},n.measureTextWithoutWrap=function(i){var t=i._subFont,e=t.nativeFontString,r=n.measureFont(e),a=i.text.split(/(?:\r\n|\r|\n)/),o=a.length,c=new Array,l=new Array,_=new Array,u=hn._pixelsPerUnit,h=r.size+i.lineSpacing*u,d=0;t.nativeFontString=e;for(var f=0;f0&&(this._pushLine(c,l,_,v,p,g,y),d=Math.max(d,p))}var E=i.height*u;return i.overflowMode===Gn.Overflow&&(E=h*c.length),{width:d,height:E,lines:c,lineWidths:l,lineHeight:h,lineMaxSizes:_}},n.getNativeFontHash=function(i,t,e){var r=e&xn.Bold?"bold":"";return e&xn.Italic&&(r+="italic"),!/([\"\'])[^\'\"]+\1/.test(i)&&n._genericFontFamilies.indexOf(i)==-1&&(i=""+i),r+=t+"px"+i,r},n._measureFontOrChar=function(i,t){t===void 0&&(t="");var e=n.textContext(),r=e.canvas,a=e.context;a.font=i;var o=t||n._measureString,c=Math.max(1,Math.round(a.measureText(o).width)),l=Math.ceil(a.measureText(n._measureBaseline).width),_=l*n._heightMultiplier;l=n._baselineMultiplier*l|0;var u=n._extendHeight;_+=u,l+=u*.5,r.width=c,r.height=_,a.font=i,a.fillStyle="#000",a.clearRect(0,0,c,_),a.textBaseline="middle",a.fillStyle="#fff",a.fillText(o,0,l);for(var h=a.getImageData(0,0,c,_).data,d=h.length,f=-1,v=-1,p,g=0,y=0,m=0,x=r.width,C=1/x,b=0;bv&&(v=p)}else h[b]=h[b+1]=h[b+2]=255;f!==-1&&v!==-1&&(g=l-f,y=v-l+1,m=g+y);var S={ascent:g,descent:y,size:m};if(t){var w=null;if(m>0){var E=x*4;w=new Uint8Array(h.buffer,f*E,m*E)}return{char:t,x:0,y:0,w:c,h:m,offsetX:0,offsetY:(g-y)*.5,xAdvance:c,uvs:[new ee,new ee,new ee,new ee],ascent:g,descent:y,index:0,data:w}}else return S},n._getCharInfo=function(i,t,e){var r=e._getCharInfo(i);return r||(r=n.measureChar(i,t),e._uploadCharTexture(r),e._addCharInfo(i,r)),r},n._pushLine=function(i,t,e,r,a,o,c){i.push(r),t.push(a),e.push({ascent:o,descent:c,size:o+c})},n}();(function(){sr._genericFontFamilies=["serif","sans-serif","monospace","cursive","fantasy","system-ui","math","emoji","fangsong"]})();(function(){sr._extendHeight=0})();(function(){sr._measureString="|ÉqÅ"})();(function(){sr._measureBaseline="M"})();(function(){sr._heightMultiplier=2})();(function(){sr._baselineMultiplier=1.4})();(function(){sr._fontSizeInfoCache={}})();(function(){sr._textContext=null})();var H_=function(){function n(i){this._fontAtlases=[],this._lastIndex=-1,this._engine=i}var s=n.prototype;return s.destroy=function(){for(var t=this._fontAtlases,e=0,r=t.length;e0&&p.h>0&&g){var y=p.bufferOffset;f.setPixelBuffer(g,0,y.x,y.y,p.w,p.h)}}f.generateMipmaps()},l}(br))),r},n}(),_a=function(n){W(s,n);function s(t,e){e===void 0&&(e="");var r;return r=n.call(this,t)||this,r._name="",r._subFontMap={},r._name=e,r}var i=s.prototype;return i._getSubFont=function(e,r){var a=e+"-"+r,o=this._subFontMap,c=o[a];return c||(c=new H_(this.engine),o[a]=c,c)},i._onDestroy=function(){n.prototype._onDestroy.call(this);var e=this._subFontMap;for(var r in e)e[r].destroy();this._subFontMap=null,delete this.engine._fontMap[this._name]},s.createFromOS=function(e,r){if(r){var a=e._fontMap,o=a[r];return o||(o=new s(e,r),a[r]=o,o)}return null},j(s,[{key:"name",get:function(){return this._name}}]),s}(Qr),Mc=function n(){this.localPositions=new ie;var s=[new R,new R,new R,new R];this.renderData=new Do(4,s,null,n.triangles,null)};(function(){Mc.triangles=[0,2,1,2,0,3]})();var W_=function(){function n(i,t){this._elements=[],this._type=i;for(var e=this._elements,r=0;r0?this._elements.pop():new this._type},s.put=function(t){this._elements.push(t)},n}(),rt=function(n){W(s,n);function s(t){var e;return e=n.call(this,t)||this,e._subFont=null,e._charRenderDatas=[],e._dirtyFlag=15,e._color=new q(1,1,1,1),e._text="",e._width=0,e._height=0,e._localBounds=new lr,e._font=null,e._fontSize=24,e._fontStyle=xn.None,e._lineSpacing=0,e._horizontalAlignment=Nn.Center,e._verticalAlignment=In.Center,e._enableWrapping=!1,e._overflowMode=Gn.Overflow,e._maskInteraction=ct.None,e._maskLayer=sa.Layer0,e._init(),e}var i=s.prototype;return i._init=function(){var e=this.engine;this._font=e._textDefaultFont,this._addResourceReferCount(this._font,1),this.setMaterial(e._spriteDefaultMaterial)},i._onDestroy=function(){this._font&&(this._addResourceReferCount(this._font,-1),this._font=null),n.prototype._onDestroy.call(this);for(var e=this._charRenderDatas,r=0,a=e.length;r0){var x=hn._pixelsPerUnit,C=this.horizontalAlignment,b=1/x,A=this.width*x,S=A*.5,w=this.height*x,E=v*.5,P=0,M=v*.5-p[0].ascent,D=v*.5-p[y-1].descent-1;switch(this.verticalAlignment){case In.Top:P=w*.5-E+M;break;case In.Center:P=h*.5-E-(D-M)*.5;break;case In.Bottom:P=h-w*.5-E-D;break}for(var L=-1,V=Number.MAX_SAFE_INTEGER,N=Number.MAX_SAFE_INTEGER,I=Number.MIN_SAFE_INTEGER,B=Number.MIN_SAFE_INTEGER,z=0;z0){var Y=d[z],Q=0,H=-1;switch(L<0&&(L=z),C){case Nn.Left:Q=-S;break;case Nn.Center:Q=-U*.5;break;case Nn.Right:Q=S-U;break}for(var te=0,Ce=Y.length;te0){var Ae,je;H<0&&(H=te);var _t=(Ae=l)[je=m++]||(Ae[je]=g.get()),xe=_t.renderData,$e=_t.localPositions;_t.texture=_._getTextureByIndex(ae.index),xe.color=c,xe.uvs=ae.uvs;var qe=ae.w,ut=ae.ascent,se=ae.descent,it=Q*b,rr=(Q+qe)*b,Jr=(P+ut)*b,Mr=(P-se)*b;$e.set(it,Jr,rr,Mr),z===L&&(B=Math.max(B,Jr)),N=Math.min(N,Mr),te===H&&(V=Math.min(V,it)),I=Math.max(I,rr)}Q+=ae.xAdvance}}P-=v}L<0?(r.set(0,0,0),a.set(0,0,0)):(r.set(V,N,0),a.set(I,B,0))}else r.set(0,0,0),a.set(0,0,0);var pn=l.length;if(pn>m){for(var Zr=m;Zr0&&l.sort(function(Bn,Qa){return Bn.texture.instanceId-Qa.texture.instanceId})},i._onTransformChanged=function(e){n.prototype._onTransformChanged.call(this,e),this._setDirtyFlagTrue(12)},i._isTextNoVisible=function(){return this._text===""||this._fontSize===0||this.enableWrapping&&this.width<=0||this.overflowMode===Gn.Truncate&&this.height<=0},j(s,[{key:"color",get:function(){return this._color},set:function(e){this._color!==e&&this._color.copyFrom(e)}},{key:"text",get:function(){return this._text},set:function(e){e=e||"",this._text!==e&&(this._text=e,this._setDirtyFlagTrue(14))}},{key:"width",get:function(){return this._width},set:function(e){this._width!==e&&(this._width=e,this._setDirtyFlagTrue(14))}},{key:"height",get:function(){return this._height},set:function(e){this._height!==e&&(this._height=e,this._setDirtyFlagTrue(14))}},{key:"font",get:function(){return this._font},set:function(e){var r=this._font;r!==e&&(r&&this._addResourceReferCount(r,-1),e&&this._addResourceReferCount(e,1),this._font=e,this._setDirtyFlagTrue(15))}},{key:"fontSize",get:function(){return this._fontSize},set:function(e){this._fontSize!==e&&(this._fontSize=e,this._setDirtyFlagTrue(15))}},{key:"fontStyle",get:function(){return this._fontStyle},set:function(e){this.fontStyle!==e&&(this._fontStyle=e,this._setDirtyFlagTrue(15))}},{key:"lineSpacing",get:function(){return this._lineSpacing},set:function(e){this._lineSpacing!==e&&(this._lineSpacing=e,this._setDirtyFlagTrue(14))}},{key:"horizontalAlignment",get:function(){return this._horizontalAlignment},set:function(e){this._horizontalAlignment!==e&&(this._horizontalAlignment=e,this._setDirtyFlagTrue(14))}},{key:"verticalAlignment",get:function(){return this._verticalAlignment},set:function(e){this._verticalAlignment!==e&&(this._verticalAlignment=e,this._setDirtyFlagTrue(14))}},{key:"enableWrapping",get:function(){return this._enableWrapping},set:function(e){this._enableWrapping!==e&&(this._enableWrapping=e,this._setDirtyFlagTrue(14))}},{key:"overflowMode",get:function(){return this._overflowMode},set:function(e){this._overflowMode!==e&&(this._overflowMode=e,this._setDirtyFlagTrue(14))}},{key:"maskInteraction",get:function(){return this._maskInteraction},set:function(e){this._maskInteraction!==e&&(this._maskInteraction=e,this._setDirtyFlagTrue(16))}},{key:"maskLayer",get:function(){return this._maskLayer},set:function(e){this._maskLayer=e}},{key:"bounds",get:function(){if(this._isTextNoVisible()){if(this._isContainDirtyFlag(8)){var e=this._localBounds;e.min.set(0,0,0),e.max.set(0,0,0),this._updateBounds(this._bounds),this._setDirtyFlagFalse(8)}return this._bounds}return this._isContainDirtyFlag(1)&&this._resetSubFont(),this._isContainDirtyFlag(2)&&this._updateLocalData(),this._isContainDirtyFlag(4)&&this._updatePosition(),this._isContainDirtyFlag(8)&&this._updateBounds(this._bounds),this._setDirtyFlagFalse(15),this._bounds}}]),s}(ye);(function(){rt._charRenderDataPool=new W_(Mc,50)})();(function(){rt._tempVec30=new R})();(function(){rt._tempVec31=new R})();T([Me],rt.prototype,"_subFont",void 0);T([F],rt.prototype,"_charRenderDatas",void 0);T([F],rt.prototype,"_dirtyFlag",void 0);T([J],rt.prototype,"_color",void 0);T([Me],rt.prototype,"_text",void 0);T([Me],rt.prototype,"_width",void 0);T([Me],rt.prototype,"_height",void 0);T([F],rt.prototype,"_localBounds",void 0);T([Me],rt.prototype,"_font",void 0);T([Me],rt.prototype,"_fontSize",void 0);T([Me],rt.prototype,"_fontStyle",void 0);T([Me],rt.prototype,"_lineSpacing",void 0);T([Me],rt.prototype,"_horizontalAlignment",void 0);T([Me],rt.prototype,"_verticalAlignment",void 0);T([Me],rt.prototype,"_enableWrapping",void 0);T([Me],rt.prototype,"_overflowMode",void 0);T([Me],rt.prototype,"_maskInteraction",void 0);T([Me],rt.prototype,"_maskLayer",void 0);var rs;(function(n){n[n.SubFont=1]="SubFont",n[n.LocalPositionBounds=2]="LocalPositionBounds",n[n.WorldPosition=4]="WorldPosition",n[n.WorldBounds=8]="WorldBounds",n[n.MaskInteraction=16]="MaskInteraction",n[n.Position=14]="Position",n[n.Font=15]="Font"})(rs||(rs={}));var On;(function(n){n[n.Normal=0]="Normal",n[n.Additive=1]="Additive"})(On||(On={}));var an;(function(n){n[n.Front=0]="Front",n[n.Back=1]="Back",n[n.Double=2]="Double"})(an||(an={}));var Sr=function(n){W(s,n);function s(t,e){var r;return r=n.call(this,t)||this,r._renderStates=[],r._priority=0,r._shaderData=new Nr(xr.Material),r.shader=e,r}var i=s.prototype;return i.clone=function(){var e=new s(this._engine,this.shader);return this.cloneTo(e),e},i.cloneTo=function(e){e.shader=this.shader,this.shaderData.cloneTo(e.shaderData),Ar.deepCloneObject(this.renderStates,e.renderStates,new Map)},i._addReferCount=function(e){this._destroyed||(n.prototype._addReferCount.call(this,e),this.shaderData._addReferCount(e),this._shader._addReferCount(e))},i._onDestroy=function(){n.prototype._onDestroy.call(this),this._shader=null,this._shaderData=null,this._renderStates.length=0,this._renderStates=null},j(s,[{key:"shaderData",get:function(){return this._shaderData}},{key:"shader",get:function(){return this._shader},set:function(e){var r=this._getReferCount();if(r>0){var a;(a=this._shader)==null||a._addReferCount(-r),e._addReferCount(r)}this._shader=e;for(var o=this._renderStates,c=o.length,l=0,_=e.subShaders,u=0;u<_.length;u++)l=Math.max(_[u].passes.length,l);if(c0){var a;(a=this._shader)==null||a._addReferCount(-r),e._addReferCount(r)}this._shader=e;for(var o=this._renderStates,c=o.length,l=0,_=e.subShaders,u=0;u<_.length;u++)l=Math.max(_[u].passes.length,l);if(c0?l.renderQueueType=l.blendState.targetBlendState.enabled?ft.Transparent:ft.AlphaTest:l.renderQueueType=l.blendState.targetBlendState.enabled?ft.Transparent:ft.Opaque}r.setFloat(s._alphaCutoffProp,e)}}},{key:"renderFace",get:function(){return this._renderFace},set:function(e){e!==this._renderFace&&(this.setRenderFace(0,e),this._renderFace=e)}}]),s}(Sr);(function(){We._baseTextureMacro=oe.getByName("MATERIAL_HAS_BASETEXTURE")})();(function(){We._normalTextureMacro=oe.getByName("MATERIAL_HAS_NORMALTEXTURE")})();(function(){We._emissiveTextureMacro=oe.getByName("MATERIAL_HAS_EMISSIVETEXTURE")})();(function(){We._transparentMacro=oe.getByName("MATERIAL_IS_TRANSPARENT")})();(function(){We._baseColorProp=O.getByName("material_BaseColor")})();(function(){We._baseTextureProp=O.getByName("material_BaseTexture")})();(function(){We._tilingOffsetProp=O.getByName("material_TilingOffset")})();(function(){We._normalTextureProp=O.getByName("material_NormalTexture")})();(function(){We._normalIntensityProp=O.getByName("material_NormalIntensity")})();(function(){We._emissiveColorProp=O.getByName("material_EmissiveColor")})();(function(){We._emissiveTextureProp=O.getByName("material_EmissiveTexture")})();(function(){We._alphaCutoffProp=O.getByName("material_AlphaCutoff")})();(function(){We._alphaCutoffMacro=oe.getByName("MATERIAL_IS_ALPHA_CUTOFF")})();var Ga=function(n){W(s,n);function s(t){var e;e=n.call(this,t,Se.find("blinn-phong"))||this;var r=e.shaderData;return r.enableMacro("MATERIAL_NEED_WORLD_POS"),r.enableMacro("MATERIAL_NEED_TILING_OFFSET"),r.setColor(s._baseColorProp,new q(1,1,1,1)),r.setColor(s._specularColorProp,new q(1,1,1,1)),r.setColor(s._emissiveColorProp,new q(0,0,0,1)),r.setVector4(s._tilingOffsetProp,new ie(1,1,0,0)),r.setFloat(s._shininessProp,16),r.setFloat(s._normalIntensityProp,1),e}var i=s.prototype;return i.clone=function(){var e=new s(this._engine);return this.cloneTo(e),e},j(s,[{key:"baseColor",get:function(){return this.shaderData.getColor(s._baseColorProp)},set:function(e){var r=this.shaderData.getColor(s._baseColorProp);e!==r&&r.copyFrom(e)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(s._baseTextureProp)},set:function(e){this.shaderData.setTexture(s._baseTextureProp,e),e?this.shaderData.enableMacro(s._baseTextureMacro):this.shaderData.disableMacro(s._baseTextureMacro)}},{key:"specularColor",get:function(){return this.shaderData.getColor(s._specularColorProp)},set:function(e){var r=this.shaderData.getColor(s._specularColorProp);e!==r&&r.copyFrom(e)}},{key:"specularTexture",get:function(){return this.shaderData.getTexture(s._specularTextureProp)},set:function(e){this.shaderData.setTexture(s._specularTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_SPECULAR_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_SPECULAR_TEXTURE")}},{key:"emissiveColor",get:function(){return this.shaderData.getColor(s._emissiveColorProp)},set:function(e){var r=this.shaderData.getColor(s._emissiveColorProp);e!==r&&r.copyFrom(e)}},{key:"emissiveTexture",get:function(){return this.shaderData.getTexture(s._emissiveTextureProp)},set:function(e){this.shaderData.setTexture(s._emissiveTextureProp,e),e?this.shaderData.enableMacro(s._emissiveTextureMacro):this.shaderData.disableMacro(s._emissiveTextureMacro)}},{key:"normalTexture",get:function(){return this.shaderData.getTexture(s._normalTextureProp)},set:function(e){this.shaderData.setTexture(s._normalTextureProp,e),e?this.shaderData.enableMacro(s._normalTextureMacro):this.shaderData.disableMacro(s._normalTextureMacro)}},{key:"normalIntensity",get:function(){return this.shaderData.getFloat(s._normalIntensityProp)},set:function(e){this.shaderData.setFloat(s._normalIntensityProp,e)}},{key:"shininess",get:function(){return this.shaderData.getFloat(s._shininessProp)},set:function(e){this.shaderData.setFloat(s._shininessProp,Math.max(e,1e-4))}},{key:"tilingOffset",get:function(){return this.shaderData.getVector4(s._tilingOffsetProp)},set:function(e){var r=this.shaderData.getVector4(s._tilingOffsetProp);e!==r&&r.copyFrom(e)}}]),s}(We);(function(){Ga._specularColorProp=O.getByName("material_SpecularColor")})();(function(){Ga._shininessProp=O.getByName("material_Shininess")})();(function(){Ga._specularTextureProp=O.getByName("material_SpecularTexture")})();var Cn;(function(n){n[n.UV0=0]="UV0",n[n.UV1=1]="UV1",n[n.UV2=2]="UV2",n[n.UV3=3]="UV3",n[n.UV4=4]="UV4",n[n.UV5=5]="UV5",n[n.UV6=6]="UV6",n[n.UV7=7]="UV7"})(Cn||(Cn={}));var Or=function(n){W(s,n);function s(i,t){var e;e=n.call(this,i,t)||this;var r=e.shaderData;return r.enableMacro("MATERIAL_NEED_WORLD_POS"),r.enableMacro("MATERIAL_NEED_TILING_OFFSET"),r.setColor(s._baseColorProp,new q(1,1,1,1)),r.setColor(s._emissiveColorProp,new q(0,0,0,1)),r.setVector4(s._tilingOffsetProp,new ie(1,1,0,0)),r.setFloat(s._normalIntensityProp,1),r.setFloat(s._occlusionTextureIntensityProp,1),r.setFloat(s._occlusionTextureCoordProp,Cn.UV0),r.setFloat(s._clearCoatProp,0),r.setFloat(s._clearCoatRoughnessProp,0),e}return j(s,[{key:"baseColor",get:function(){return this.shaderData.getColor(s._baseColorProp)},set:function(t){var e=this.shaderData.getColor(s._baseColorProp);t!==e&&e.copyFrom(t)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(s._baseTextureProp)},set:function(t){this.shaderData.setTexture(s._baseTextureProp,t),t?this.shaderData.enableMacro(s._baseTextureMacro):this.shaderData.disableMacro(s._baseTextureMacro)}},{key:"normalTexture",get:function(){return this.shaderData.getTexture(s._normalTextureProp)},set:function(t){this.shaderData.setTexture(s._normalTextureProp,t),t?this.shaderData.enableMacro(s._normalTextureMacro):this.shaderData.disableMacro(s._normalTextureMacro)}},{key:"normalTextureIntensity",get:function(){return this.shaderData.getFloat(s._normalIntensityProp)},set:function(t){this.shaderData.setFloat(s._normalIntensityProp,t)}},{key:"emissiveColor",get:function(){return this.shaderData.getColor(s._emissiveColorProp)},set:function(t){var e=this.shaderData.getColor(s._emissiveColorProp);t!==e&&e.copyFrom(t)}},{key:"emissiveTexture",get:function(){return this.shaderData.getTexture(s._emissiveTextureProp)},set:function(t){this.shaderData.setTexture(s._emissiveTextureProp,t),t?this.shaderData.enableMacro(s._emissiveTextureMacro):this.shaderData.disableMacro(s._emissiveTextureMacro)}},{key:"occlusionTexture",get:function(){return this.shaderData.getTexture(s._occlusionTextureProp)},set:function(t){this.shaderData.setTexture(s._occlusionTextureProp,t),t?this.shaderData.enableMacro("MATERIAL_HAS_OCCLUSION_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_OCCLUSION_TEXTURE")}},{key:"occlusionTextureIntensity",get:function(){return this.shaderData.getFloat(s._occlusionTextureIntensityProp)},set:function(t){this.shaderData.setFloat(s._occlusionTextureIntensityProp,t)}},{key:"occlusionTextureCoord",get:function(){return this.shaderData.getFloat(s._occlusionTextureCoordProp)},set:function(t){t>Cn.UV1&&ve.warn("Occlusion texture uv coordinate must be UV0 or UV1."),this.shaderData.setFloat(s._occlusionTextureCoordProp,t)}},{key:"tilingOffset",get:function(){return this.shaderData.getVector4(s._tilingOffsetProp)},set:function(t){var e=this.shaderData.getVector4(s._tilingOffsetProp);t!==e&&e.copyFrom(t)}},{key:"clearCoat",get:function(){return this.shaderData.getFloat(s._clearCoatProp)},set:function(t){!!this.shaderData.getFloat(s._clearCoatProp)!=!!t&&(t===0?this.shaderData.disableMacro("MATERIAL_ENABLE_CLEAR_COAT"):this.shaderData.enableMacro("MATERIAL_ENABLE_CLEAR_COAT")),this.shaderData.setFloat(s._clearCoatProp,t)}},{key:"clearCoatTexture",get:function(){return this.shaderData.getTexture(s._clearCoatTextureProp)},set:function(t){this.shaderData.setTexture(s._clearCoatTextureProp,t),t?this.shaderData.enableMacro("MATERIAL_HAS_CLEAR_COAT_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_CLEAR_COAT_TEXTURE")}},{key:"clearCoatRoughness",get:function(){return this.shaderData.getFloat(s._clearCoatRoughnessProp)},set:function(t){this.shaderData.setFloat(s._clearCoatRoughnessProp,t)}},{key:"clearCoatRoughnessTexture",get:function(){return this.shaderData.getTexture(s._clearCoatRoughnessTextureProp)},set:function(t){this.shaderData.setTexture(s._clearCoatRoughnessTextureProp,t),t?this.shaderData.enableMacro("MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE")}},{key:"clearCoatNormalTexture",get:function(){return this.shaderData.getTexture(s._clearCoatNormalTextureProp)},set:function(t){this.shaderData.setTexture(s._clearCoatNormalTextureProp,t),t?this.shaderData.enableMacro("MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE")}}]),s}(We);(function(){Or._occlusionTextureIntensityProp=O.getByName("material_OcclusionIntensity")})();(function(){Or._occlusionTextureCoordProp=O.getByName("material_OcclusionTextureCoord")})();(function(){Or._occlusionTextureProp=O.getByName("material_OcclusionTexture")})();(function(){Or._clearCoatProp=O.getByName("material_ClearCoat")})();(function(){Or._clearCoatTextureProp=O.getByName("material_ClearCoatTexture")})();(function(){Or._clearCoatRoughnessProp=O.getByName("material_ClearCoatRoughness")})();(function(){Or._clearCoatRoughnessTextureProp=O.getByName("material_ClearCoatRoughnessTexture")})();(function(){Or._clearCoatNormalTextureProp=O.getByName("material_ClearCoatNormalTexture")})();var Xr=function(n){W(s,n);function s(t){var e;e=n.call(this,t,Se.find("pbr"))||this,e._anisotropyRotation=0;var r=e.shaderData;return r.setFloat(s._metallicProp,1),r.setFloat(s._roughnessProp,1),r.setFloat(s._iorProp,1.5),r.setVector3(s._anisotropyInfoProp,new R(1,0,0)),e}var i=s.prototype;return i.clone=function(){var e=new s(this._engine);return this.cloneTo(e),e},j(s,[{key:"ior",get:function(){return this.shaderData.getFloat(s._iorProp)},set:function(e){this.shaderData.setFloat(s._iorProp,Math.max(e,0))}},{key:"metallic",get:function(){return this.shaderData.getFloat(s._metallicProp)},set:function(e){this.shaderData.setFloat(s._metallicProp,e)}},{key:"roughness",get:function(){return this.shaderData.getFloat(s._roughnessProp)},set:function(e){this.shaderData.setFloat(s._roughnessProp,e)}},{key:"roughnessMetallicTexture",get:function(){return this.shaderData.getTexture(s._roughnessMetallicTextureProp)},set:function(e){this.shaderData.setTexture(s._roughnessMetallicTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE")}},{key:"anisotropy",get:function(){return this.shaderData.getVector3(s._anisotropyInfoProp).z},set:function(e){var r=this.shaderData.getVector3(s._anisotropyInfoProp);!!r.z!=!!e&&(e===0?this.shaderData.disableMacro("MATERIAL_ENABLE_ANISOTROPY"):this.shaderData.enableMacro("MATERIAL_ENABLE_ANISOTROPY")),r.z=e}},{key:"anisotropyRotation",get:function(){return this._anisotropyRotation},set:function(e){if(this._anisotropyRotation!==e){this._anisotropyRotation=e;var r=this.shaderData.getVector3(s._anisotropyInfoProp),a=k.degreeToRadFactor*e;r.x=Math.cos(a),r.y=Math.sin(a)}}},{key:"anisotropyTexture",get:function(){return this.shaderData.getTexture(s._anisotropyTextureProp)},set:function(e){this.shaderData.setTexture(s._anisotropyTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_ANISOTROPY_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_ANISOTROPY_TEXTURE")}}]),s}(Or);(function(){Xr._metallicProp=O.getByName("material_Metal")})();(function(){Xr._roughnessProp=O.getByName("material_Roughness")})();(function(){Xr._roughnessMetallicTextureProp=O.getByName("material_RoughnessMetallicTexture")})();(function(){Xr._iorProp=O.getByName("material_IOR")})();(function(){Xr._anisotropyInfoProp=O.getByName("material_AnisotropyInfo")})();(function(){Xr._anisotropyTextureProp=O.getByName("material_AnisotropyTexture")})();var qn=function(n){W(s,n);function s(t){var e;return e=n.call(this,t,Se.find("pbr-specular"))||this,e.shaderData.setColor(s._specularColorProp,new q(1,1,1,1)),e.shaderData.setFloat(s._glossinessProp,1),e}var i=s.prototype;return i.clone=function(){var e=new s(this._engine);return this.cloneTo(e),e},j(s,[{key:"specularColor",get:function(){return this.shaderData.getColor(s._specularColorProp)},set:function(e){var r=this.shaderData.getColor(s._specularColorProp);e!==r&&r.copyFrom(e)}},{key:"glossiness",get:function(){return this.shaderData.getFloat(s._glossinessProp)},set:function(e){this.shaderData.setFloat(s._glossinessProp,e)}},{key:"specularGlossinessTexture",get:function(){return this.shaderData.getTexture(s._specularGlossinessTextureProp)},set:function(e){this.shaderData.setTexture(s._specularGlossinessTextureProp,e),e?this.shaderData.enableMacro(s._specularGlossinessTextureMacro):this.shaderData.disableMacro(s._specularGlossinessTextureMacro)}}]),s}(Or);(function(){qn._specularColorProp=O.getByName("material_PBRSpecularColor")})();(function(){qn._glossinessProp=O.getByName("material_Glossiness")})();(function(){qn._specularGlossinessTextureProp=O.getByName("material_SpecularGlossinessTexture")})();(function(){qn._specularGlossinessTextureMacro=oe.getByName("MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE")})();var Pc=function(n){W(s,n);function s(t){var e;e=n.call(this,t,Se.find("unlit"))||this;var r=e.shaderData;return r.enableMacro("MATERIAL_OMIT_NORMAL"),r.enableMacro("MATERIAL_NEED_TILING_OFFSET"),r.setColor(s._baseColorProp,new q(1,1,1,1)),r.setVector4(s._tilingOffsetProp,new ie(1,1,0,0)),e}var i=s.prototype;return i.clone=function(){var e=new s(this._engine);return this.cloneTo(e),e},j(s,[{key:"baseColor",get:function(){return this.shaderData.getColor(s._baseColorProp)},set:function(e){var r=this.shaderData.getColor(s._baseColorProp);e!==r&&r.copyFrom(e)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(s._baseTextureProp)},set:function(e){this.shaderData.setTexture(s._baseTextureProp,e),e?this.shaderData.enableMacro(s._baseTextureMacro):this.shaderData.disableMacro(s._baseTextureMacro)}},{key:"tilingOffset",get:function(){return this.shaderData.getVector4(s._tilingOffsetProp)},set:function(e){var r=this.shaderData.getVector4(s._tilingOffsetProp);e!==r&&r.copyFrom(e)}}]),s}(We),X_=function(){function n(i){var t=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,1,1,1,0]),e=new Float32Array([1,-1,1,0,-1,-1,0,0,1,1,1,1,-1,1,0,1]),r=new Sr(i,Se.find("blit"));r._addReferCount(1),r.renderState.depthState.enabled=!1,r.renderState.depthState.writeEnabled=!1,this.blitMesh=this._createBlitMesh(i,t),this.flipYBlitMesh=this._createBlitMesh(i,e),this.blitMaterial=r}var s=n.prototype;return s._createBlitMesh=function(t,e){var r=new dt(t);return r._addReferCount(1),r.setVertexElements([new Te("POSITION_UV",0,$.Vector4,0)]),r.setVertexBufferBinding(new Jt(t,Mt.VertexBuffer,e,Je.Static),16),r.addSubMesh(0,4,un.TriangleStrip),r},n}(),Qt=function(){function n(){this._projectionParams=new ie,this.flipProjection=!1}var s=n.prototype;return s.applyVirtualCamera=function(t,e){this.virtualCamera=t,this.flipProjection=e;var r=this.camera.shaderData,a=t.viewMatrix,o=t.projectionMatrix,c=t.viewProjectionMatrix;e&&(Z.multiply(n._flipYMatrix,o,n._flipYProjectionMatrix),Z.multiply(n._flipYProjectionMatrix,a,n._flipYViewProjectionMatrix),o=n._flipYProjectionMatrix,c=n._flipYViewProjectionMatrix),this.viewMatrix=a,this.projectionMatrix=o,this.viewProjectionMatrix=c,r.setMatrix(n._viewMatrixProperty,a),r.setMatrix(n._projectionMatrixProperty,o),r.setMatrix(n.vpMatrixProperty,c);var l=this._projectionParams;l.set(e?-1:1,t.nearClipPlane,t.farClipPlane,0),r.setVector4(n._cameraProjectionProperty,l)},s.garbageCollection=function(){this.camera=null},n}();(function(){Qt.vpMatrixProperty=O.getByName("camera_VPMat")})();(function(){Qt.pipelineStageKey=sn.getByName("pipelineStage")})();(function(){Qt._flipYMatrix=new Z(1,0,0,0,0,-1)})();(function(){Qt._cameraProjectionProperty=O.getByName("camera_ProjectionParams")})();(function(){Qt._viewMatrixProperty=O.getByName("camera_ViewMat")})();(function(){Qt._projectionMatrixProperty=O.getByName("camera_ProjMat")})();(function(){Qt._flipYProjectionMatrix=new Z})();(function(){Qt._flipYViewProjectionMatrix=new Z})();var Hi=function(){function n(){}var s=n.prototype;return s.setX=function(t,e,r,a){this.component=t,this.material=e,this.primitive=r,this.subPrimitive=a},s.dispose=function(){this.component=null,this.material=null,this.primitive=null,this.subPrimitive=null},n}(),j_=function(){function n(){}var s=n.prototype;return s.set=function(t,e){this.data=t,this.shaderPasses=e},s.dispose=function(){this.data=this.shaderPasses=null},n}(),q_=function(n){W(s,n);function s(){return n.apply(this,arguments)}var i=s.prototype;return i.createVertexElements=function(e){return e[0]=new Te("POSITION",0,$.Vector3,0),e[1]=new Te("TEXCOORD_0",12,$.Vector2,0),20},i.canBatch=function(e,r){var a=e.data,o=r.data;if(a.isAdd!==o.isAdd)return!1;var c=a.component.shaderData,l=o.component.shaderData,_=Pt._textureProperty,u=Pt._alphaCutoffProperty;return c.getTexture(_)===l.getTexture(_)&&c.getTexture(u)===l.getTexture(u)},i.updateVertices=function(e,r,a){for(var o=e.verticesData,c=o.positions,l=o.uvs,_=o.vertexCount,u=0;u<_;u++){var h=c[u],d=l[u];r[a++]=h.x,r[a++]=h.y,r[a++]=h.z,r[a++]=d.x,r[a++]=d.y}return a},i.drawBatches=function(e){for(var r=this,a=r._engine,o=r._batchedQueue,c=this._meshes[this._flushId],l=c.subMeshes,_=c._primitive,u=e.scene.shaderData,h=e.shaderData,d=0,f=l.length;dr.length)throw"The index is out of range.";a=t}else a=r.length,e=t;if(e.engine!==this.engine)throw"The scene is not belong to this engine.";if(e._sceneManager){var o=r.indexOf(e);o!==a&&(r.removeByIndex(o),r.add(a,e))}else e._sceneManager=this,r.add(a,e),e.isActive&&e._processActive(!0)},s.removeScene=function(t){var e=this._scenes,r=e.indexOf(t);if(r!==-1){var a=e.getArray()[r];e.removeByIndex(r),t._sceneManager=null,a.isActive&&a._processActive(!1)}},s.loadScene=function(t,e){e===void 0&&(e=!0);var r=this,a=this.engine.resourceManager.load({url:t,type:Ve.Scene});return a.then(function(o){if(e)for(var c=r._scenes.getArray(),l=0,_=c.length;l<_;l++)c[l].destroy();r.addScene(o)}),a},s.mergeScenes=function(t,e){for(var r=t.rootEntities;r.length>0;)e.addRootEntity(r[0])},s._destroyAllScene=function(){for(var t=this._allCreatedScenes;t.length>0;)t[0].destroy()},j(n,[{key:"scenes",get:function(){return this._scenes.getArray()}},{key:"activeScene",get:function(){return this._scenes.getArray()[0]},set:function(t){var e=this.scenes[0];e&&this.removeScene(e),t&&this.addScene(0,t)}}]),n}(),Pe=function(){function n(i){var t=this;this._state="pending",this._onTaskCompleteCallbacks=[],this._onTaskDetailCallbacks=[],this._promise=new Promise(function(e,r){t._reject=r;var a=function(u){t._state==="pending"&&(e(u),t._state="fulfilled",t._onTaskCompleteCallbacks=void 0,t._onTaskDetailCallbacks=void 0)},o=function(u){t._state==="pending"&&(r(u),t._state="rejected",t._onTaskCompleteCallbacks=void 0,t._onTaskDetailCallbacks=void 0)},c=function(u){t._state==="pending"&&(t._onCancelHandler=u)},l=function(u,h){if(t._state==="pending"){var d=t._taskCompleteProgress||(t._taskCompleteProgress={loaded:u,total:h});d.loaded=u,d.total=h,t._onTaskCompleteCallbacks.forEach(function(f){return f(u,h)})}},_=function(u,h,d){if(t._state==="pending"){var f,v;t._taskDetailProgress||(t._taskDetailProgress={});var p=(f=t._taskDetailProgress)[v=u]||(f[v]={loaded:h,total:d});p.loaded=h,p.total=d,t._onTaskDetailCallbacks.forEach(function(g){return g(u,h,d)})}};i(a,o,l,_,c)})}var s=n.prototype;return s.onProgress=function(t,e){var r=this._taskCompleteProgress,a=this._taskDetailProgress;if(r&&t(r.loaded,r.total),a)for(var o in a){var c=a[o],l=c.loaded,_=c.total;e(o,l,_)}return this._state==="pending"&&(t&&this._onTaskCompleteCallbacks.push(t),e&&this._onTaskDetailCallbacks.push(e)),this},s.then=function(t,e){var r=this;return new n(function(a,o){r._promise.then(t,e).then(a).catch(o)})},s.catch=function(t){var e=this;return new n(function(r,a){e._promise.catch(t).then(r).catch(a)})},s.finally=function(t){return this._promise.finally(t)},s.cancel=function(){if(this._state==="pending")return this._state="canceled",this._reject("canceled"),this._onCancelHandler&&this._onCancelHandler(),this},n.all=function(t){return new n(function(e,r,a){var o=function(f,v){u++,_[f]=v,a(u,l),u===l&&e(_)},c=function(f,v){lt(f,Promise)||lt(f,n)?f.then(function(p){o(v,p)},r):Promise.resolve().then(function(){o(v,f)})},l=t.length,_=new Array(l),u=0;if(l===0)return e(_);for(var h=0;h0?r+"?"+l.join("&"):r}return{assetBaseURL:c,queryPath:o}},s._parseQueryPath=function(t){var e=[];return t.charCodeAt(0)===$_&&e.push(""),t.replace(tu,function(r,a,o,c){var l=r;o?l=c.replace(eu,"$1"):a&&(l=a.trim()),e.push(l)}),e},s.getResourceByRef=function(t){var e=t.refId,r=t.key,a=t.isClone,o=this._objectPool[e],c;if(o)c=Promise.resolve(o);else{var l,_=(l=this._editorResourceConfig[e])==null?void 0:l.path;if(!_)return ve.warn("refId:"+e+" is not find in this._editorResourceConfig."),Promise.resolve(null);_=r?""+_+(_.indexOf("?")>-1?"&":"?")+"q="+r:_,c=this.load({url:_,type:this._editorResourceConfig[e].type})}return c.then(function(u){return a?u.clone():u})},s.initVirtualResources=function(t){var e=this;t.forEach(function(r){e._virtualPathMap[r.virtualPath]=r.path,e._editorResourceConfig[r.id]=r})},n._addLoader=function(t,e,r){this._loaders[t]=e;for(var a=0,o=r.length;a"u")return;var i=navigator.userAgent;/iPhone/i.test(i)?n.platform=Nt.IPhone:/iPad/i.test(i)?n.platform=Nt.IPad:/Android/i.test(i)?n.platform=Nt.Android:/Macintosh/i.test(i)&&(n.platform=Nt.Mac);var t;switch(n.platform){case Nt.IPhone:t=i.match(/OS (\d+)_?(\d+)?_?(\d+)?/),this.operatingSystem=t?"iPhone OS "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"iPhone OS";break;case Nt.IPad:t=i.match(/OS (\d+)_?(\d+)?_?(\d+)?/),this.operatingSystem=t?"iPad OS "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"iPad OS";break;case Nt.Android:t=i.match(/Android (\d+).?(\d+)?.?(\d+)?/),this.operatingSystem=t?"Android "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"Android";break;case Nt.Mac:t=i.match(/Mac OS X (\d+)_?(\d+)?_?(\d+)?/),this.operatingSystem=t?"Mac OS X "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"Mac OS X";break}}},n._detectSIMDSupported=function(){return this._simdSupported===null&&(this._simdSupported=WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]))),this._simdSupported},j(n,null,[{key:"devicePixelRatio",get:function(){return window.devicePixelRatio}}]),n}();(function(){jr.platform=Nt.Unknown})();(function(){jr.operatingSystem=""})();(function(){jr._simdSupported=null})();jr._initialize();var na;(function(n){n[n.Backquote=0]="Backquote",n[n.Backslash=1]="Backslash",n[n.Backspace=2]="Backspace",n[n.BracketLeft=3]="BracketLeft",n[n.BracketRight=4]="BracketRight",n[n.Comma=5]="Comma",n[n.Digit0=6]="Digit0",n[n.Digit1=7]="Digit1",n[n.Digit2=8]="Digit2",n[n.Digit3=9]="Digit3",n[n.Digit4=10]="Digit4",n[n.Digit5=11]="Digit5",n[n.Digit6=12]="Digit6",n[n.Digit7=13]="Digit7",n[n.Digit8=14]="Digit8",n[n.Digit9=15]="Digit9",n[n.Equal=16]="Equal",n[n.IntlBackslash=17]="IntlBackslash",n[n.IntlRo=18]="IntlRo",n[n.IntlYen=19]="IntlYen",n[n.KeyA=20]="KeyA",n[n.KeyB=21]="KeyB",n[n.KeyC=22]="KeyC",n[n.KeyD=23]="KeyD",n[n.KeyE=24]="KeyE",n[n.KeyF=25]="KeyF",n[n.KeyG=26]="KeyG",n[n.KeyH=27]="KeyH",n[n.KeyI=28]="KeyI",n[n.KeyJ=29]="KeyJ",n[n.KeyK=30]="KeyK",n[n.KeyL=31]="KeyL",n[n.KeyM=32]="KeyM",n[n.KeyN=33]="KeyN",n[n.KeyO=34]="KeyO",n[n.KeyP=35]="KeyP",n[n.KeyQ=36]="KeyQ",n[n.KeyR=37]="KeyR",n[n.KeyS=38]="KeyS",n[n.KeyT=39]="KeyT",n[n.KeyU=40]="KeyU",n[n.KeyV=41]="KeyV",n[n.KeyW=42]="KeyW",n[n.KeyX=43]="KeyX",n[n.KeyY=44]="KeyY",n[n.KeyZ=45]="KeyZ",n[n.Minus=46]="Minus",n[n.Period=47]="Period",n[n.Quote=48]="Quote",n[n.Semicolon=49]="Semicolon",n[n.Slash=50]="Slash",n[n.AltLeft=51]="AltLeft",n[n.AltRight=52]="AltRight",n[n.CapsLock=53]="CapsLock",n[n.ContextMenu=54]="ContextMenu",n[n.ControlLeft=55]="ControlLeft",n[n.ControlRight=56]="ControlRight",n[n.Enter=57]="Enter",n[n.MetaLeft=58]="MetaLeft",n[n.MetaRight=59]="MetaRight",n[n.ShiftLeft=60]="ShiftLeft",n[n.ShiftRight=61]="ShiftRight",n[n.Space=62]="Space",n[n.Tab=63]="Tab",n[n.Convert=64]="Convert",n[n.KanaMode=65]="KanaMode",n[n.Lang1=66]="Lang1",n[n.Lang2=67]="Lang2",n[n.Lang3=68]="Lang3",n[n.Lang4=69]="Lang4",n[n.Lang5=70]="Lang5",n[n.NonConvert=71]="NonConvert",n[n.Delete=72]="Delete",n[n.End=73]="End",n[n.Help=74]="Help",n[n.Home=75]="Home",n[n.Insert=76]="Insert",n[n.PageDown=77]="PageDown",n[n.PageUp=78]="PageUp",n[n.ArrowDown=79]="ArrowDown",n[n.ArrowLeft=80]="ArrowLeft",n[n.ArrowRight=81]="ArrowRight",n[n.ArrowUp=82]="ArrowUp",n[n.NumLock=83]="NumLock",n[n.Numpad0=84]="Numpad0",n[n.Numpad1=85]="Numpad1",n[n.Numpad2=86]="Numpad2",n[n.Numpad3=87]="Numpad3",n[n.Numpad4=88]="Numpad4",n[n.Numpad5=89]="Numpad5",n[n.Numpad6=90]="Numpad6",n[n.Numpad7=91]="Numpad7",n[n.Numpad8=92]="Numpad8",n[n.Numpad9=93]="Numpad9",n[n.NumpadAdd=94]="NumpadAdd",n[n.NumpadBackspace=95]="NumpadBackspace",n[n.NumpadClear=96]="NumpadClear",n[n.NumpadClearEntry=97]="NumpadClearEntry",n[n.NumpadComma=98]="NumpadComma",n[n.NumpadDecimal=99]="NumpadDecimal",n[n.NumpadDivide=100]="NumpadDivide",n[n.NumpadEnter=101]="NumpadEnter",n[n.NumpadEqual=102]="NumpadEqual",n[n.NumpadHash=103]="NumpadHash",n[n.NumpadMemoryAdd=104]="NumpadMemoryAdd",n[n.NumpadMemoryClear=105]="NumpadMemoryClear",n[n.NumpadMemoryRecall=106]="NumpadMemoryRecall",n[n.NumpadMemoryStore=107]="NumpadMemoryStore",n[n.NumpadMemorySubtract=108]="NumpadMemorySubtract",n[n.NumpadMultiply=109]="NumpadMultiply",n[n.NumpadParenLeft=110]="NumpadParenLeft",n[n.NumpadParenRight=111]="NumpadParenRight",n[n.NumpadStar=112]="NumpadStar",n[n.NumpadSubtract=113]="NumpadSubtract",n[n.Escape=114]="Escape",n[n.F1=115]="F1",n[n.F2=116]="F2",n[n.F3=117]="F3",n[n.F4=118]="F4",n[n.F5=119]="F5",n[n.F6=120]="F6",n[n.F7=121]="F7",n[n.F8=122]="F8",n[n.F9=123]="F9",n[n.F10=124]="F10",n[n.F11=125]="F11",n[n.F12=126]="F12",n[n.F13=127]="F13",n[n.F14=128]="F14",n[n.F15=129]="F15",n[n.Fn=130]="Fn",n[n.FnLock=131]="FnLock",n[n.PrintScreen=132]="PrintScreen",n[n.ScrollLock=133]="ScrollLock",n[n.Pause=134]="Pause",n[n.BrowserBack=135]="BrowserBack",n[n.BrowserFavorites=136]="BrowserFavorites",n[n.BrowserForward=137]="BrowserForward",n[n.BrowserHome=138]="BrowserHome",n[n.BrowserRefresh=139]="BrowserRefresh",n[n.BrowserSearch=140]="BrowserSearch",n[n.BrowserStop=141]="BrowserStop",n[n.Eject=142]="Eject",n[n.LaunchApp1=143]="LaunchApp1",n[n.LaunchApp2=144]="LaunchApp2",n[n.LaunchMail=145]="LaunchMail",n[n.MediaPlayPause=146]="MediaPlayPause",n[n.MediaSelect=147]="MediaSelect",n[n.MediaStop=148]="MediaStop",n[n.MediaTrackNext=149]="MediaTrackNext",n[n.MediaTrackPrevious=150]="MediaTrackPrevious",n[n.Power=151]="Power",n[n.Sleep=152]="Sleep",n[n.AudioVolumeDown=153]="AudioVolumeDown",n[n.AudioVolumeMute=154]="AudioVolumeMute",n[n.AudioVolumeUp=155]="AudioVolumeUp",n[n.WakeUp=156]="WakeUp",n[n.Hyper=157]="Hyper",n[n.Super=158]="Super",n[n.Turbo=159]="Turbo",n[n.Abort=160]="Abort",n[n.Resume=161]="Resume",n[n.Suspend=162]="Suspend",n[n.Again=163]="Again",n[n.Copy=164]="Copy",n[n.Cut=165]="Cut",n[n.Find=166]="Find",n[n.Open=167]="Open",n[n.Paste=168]="Paste",n[n.Props=169]="Props",n[n.Select=170]="Select",n[n.Undo=171]="Undo",n[n.Hiragana=172]="Hiragana",n[n.Katakana=173]="Katakana",n[n.Unidentified=174]="Unidentified"})(na||(na={}));var nu=function(){function n(i,t){this._curHeldDownKeyToIndexMap=[],this._upKeyToFrameCountMap=[],this._downKeyToFrameCountMap=[],this._curFrameHeldDownList=new He,this._curFrameDownList=new He,this._curFrameUpList=new He,this._nativeEvents=[],this._engine=i,this._onBlur=this._onBlur.bind(this),this._onKeyEvent=this._onKeyEvent.bind(this),this._target=t,this._addEventListener()}var s=n.prototype;return s._update=function(){var t=this,e=t._nativeEvents,r=t._curFrameDownList,a=t._curFrameUpList;if(r.length=0,a.length=0,e.length>0){for(var o=this._engine.time.frameCount,c=this,l=c._curHeldDownKeyToIndexMap,_=c._curFrameHeldDownList,u=c._downKeyToFrameCountMap,h=c._upKeyToFrameCountMap,d=0,f=e.length;d=0;--e)t[e]._onUpdate()},s._callColliderOnLateUpdate=function(){for(var t=this._colliders._elements,e=this._colliders.length-1;e>=0;--e)t[e]._onLateUpdate()},s._gc=function(){this._colliders.garbageCollection()},s._setGravity=function(){this._nativePhysicsScene.setGravity(this._gravity)},j(n,[{key:"gravity",get:function(){return this._gravity},set:function(t){var e=this._gravity;e!==t&&e.copyFrom(t)}},{key:"fixedTimeStep",get:function(){return this._fixedTimeStep},set:function(t){this._fixedTimeStep=Math.max(t,k.zeroTolerance)}}]),n}();(function(){Gt._collision=new au})();var yi;(function(n){n[n.PreventClimbing=0]="PreventClimbing",n[n.PreventClimbingAndForceSliding=1]="PreventClimbingAndForceSliding"})(yi||(yi={}));var iu=function(n){W(s,n);function s(t){var e;return e=n.call(this,t)||this,e._stepOffset=.5,e._nonWalkableMode=yi.PreventClimbing,e._upDirection=new R(0,1,0),e._slopeLimit=.707,e._nativeCollider=Gt._nativePhysics.createCharacterController(),e._setUpDirection=e._setUpDirection.bind(ce(e)),e._upDirection._onValueChanged=e._setUpDirection,e}var i=s.prototype;return i.move=function(e,r,a){return this._nativeCollider.move(e,r,a)},i.addShape=function(e){if(this._shapes.length>0)throw"only allow single shape on controller!";n.prototype.addShape.call(this,e),this._updateFlag.flag=!0},i.clearShapes=function(){this._shapes.length>0&&n.prototype.removeShape.call(this,this._shapes[0])},i._onUpdate=function(){if(this._updateFlag.flag){var e=this.entity.transform,r=this.shapes;this._nativeCollider.setWorldPosition(e.worldPosition);for(var a=e.lossyWorldScale,o=0,c=r.length;o=0;g--)e[g].phase===ar.Leave&&e.splice(g,1);for(var y=0,m=r.length;yM);M++);b=(S=P)[w=M]||(S[w]=new Dc(M)),b._uniqueID=C,b._events.push(x),b.position.set((x.clientX-d)*v,(x.clientY-f)*p),e.splice(M,0,b)}}}r.length=0,this._upList.length=this._downList.length=0,this._buttons=ra.None;for(var D=this._engine.time.frameCount,L=0,V=e.length;L0){for(var f=0;f=0;a--)if(r[a]._uniqueID===t)return r[a];return null},s._updatePointerInfo=function(t,e,r,a,o,c){var l=e._events,_=e.position,u=l.length;if(u>0){var h=this,d=h._upList,f=h._upMap,v=h._downList,p=h._downMap,g=l[u-1],y=(g.clientX-r)*o,m=(g.clientY-a)*c;e.deltaPosition.set(y-_.x,m-_.y),_.set(y,m);for(var x=0;x=0;l--){var _=t[l];if(!(!_.isActive||_.destroyed))for(var u=_._componentsManager,h=u._activeCameras,d=h._elements,f=h.length-1;f>=0;f--){var v=d[f];if(!v.renderTarget){var p=v.viewport,g=p.x,y=p.y,m=p.z,x=p.w;if(e>=g&&r>=y&&e-g<=m&&r-y<=x){if(a.set((e-g)/m,(r-y)/x),_.physics.raycast(v.viewportPointToRay(a,o),Number.MAX_VALUE,v.cullingMask,c))return c.entity;if(v.clearFlags&zt.Color)return null}}}}return null},s._addEventListener=function(){var t=this,e=t._target,r=t._onPointerEvent;e.addEventListener("pointerdown",r),e.addEventListener("pointerup",r),e.addEventListener("pointerleave",r),e.addEventListener("pointermove",r),e.addEventListener("pointercancel",r)},s._removeEventListener=function(){var t=this,e=t._target,r=t._onPointerEvent;e.removeEventListener("pointerdown",r),e.removeEventListener("pointerup",r),e.removeEventListener("pointerleave",r),e.removeEventListener("pointermove",r),e.removeEventListener("pointercancel",r),this._nativeEvents.length=0,this._pointers.length=0,this._downList.length=0,this._upList.length=0},n}();(function(){Xi._tempRay=new ol})();(function(){Xi._tempPoint=new ee})();(function(){Xi._tempHitResult=new Lc})();var hu=function(){function n(i,t){this._delta=new R,this._nativeEvents=[],this._onWheelEvent=this._onWheelEvent.bind(this),this._target=t,this._addEventListener()}var s=n.prototype;return s._update=function(){var t=this,e=t._delta;e.set(0,0,0);var r=this,a=r._nativeEvents;if(a.length>0){for(var o=a.length-1;o>=0;o--){var c=a[o];e.x+=c.deltaX,e.y+=c.deltaY,e.z+=c.deltaZ}a.length=0}},s._addEventListener=function(){this._target.addEventListener("wheel",this._onWheelEvent)},s._removeEventListener=function(){this._target.removeEventListener("wheel",this._onWheelEvent),this._nativeEvents.length=0,this._delta.set(0,0,0)},s._destroy=function(){this._removeEventListener(),this._nativeEvents=null,this._delta=null},s._onWheelEvent=function(t){this._nativeEvents.push(t)},n}(),Ic=function(){function n(i,t){this._initialized=!1,this._engine=i;var e=i._canvas._webCanvas;if(typeof OffscreenCanvas>"u"||!lt(e,OffscreenCanvas)){var r,a,o,c;this._wheelManager=new hu(i,(c=(r=t)==null?void 0:r.wheelTarget)!=null?c:e);var l;this._pointerManager=new Xi(i,(l=(a=t)==null?void 0:a.pointerTarget)!=null?l:e);var _;this._keyboardManager=new nu(i,(_=(o=t)==null?void 0:o.keyboardTarget)!=null?_:window),this._initialized=!0}}var s=n.prototype;return s.isKeyHeldDown=function(t){return this._initialized?t===void 0?this._keyboardManager._curFrameHeldDownList.length>0:this._keyboardManager._curHeldDownKeyToIndexMap[t]!=null:!1},s.isKeyDown=function(t){return this._initialized?t===void 0?this._keyboardManager._curFrameDownList.length>0:this._keyboardManager._downKeyToFrameCountMap[t]===this._engine.time.frameCount:!1},s.isKeyUp=function(t){return this._initialized?t===void 0?this._keyboardManager._curFrameUpList.length>0:this._keyboardManager._upKeyToFrameCountMap[t]===this._engine.time.frameCount:!1},s.isPointerHeldDown=function(t){return this._initialized?t===void 0?this._pointerManager._buttons!==0:(this._pointerManager._buttons&t)!==0:!1},s.isPointerDown=function(t){return this._initialized?t===void 0?this._pointerManager._downList.length>0:this._pointerManager._downMap[as[t]]===this._engine.time.frameCount:!1},s.isPointerUp=function(t){return this._initialized?t===void 0?this._pointerManager._upList.length>0:this._pointerManager._upMap[as[t]]===this._engine.time.frameCount:!1},s._update=function(){this._initialized&&(this._wheelManager._update(),this._pointerManager._update(),this._keyboardManager._update())},s._firePointerScript=function(t){this._initialized&&this._pointerManager._firePointerScript(t)},s._destroy=function(){this._initialized&&(this._wheelManager._destroy(),this._wheelManager=null,this._pointerManager._destroy(),this._pointerManager=null,this._keyboardManager._destroy(),this._keyboardManager=null)},j(n,[{key:"pointers",get:function(){return this._initialized?this._pointerManager._pointers:[]}},{key:"multiPointerEnabled",get:function(){return this._initialized?this._pointerManager._multiPointerEnabled:!1},set:function(t){this._initialized&&(this._pointerManager._multiPointerEnabled=t)}},{key:"wheelDelta",get:function(){return this._initialized?this._wheelManager._delta:null}}]),n}(),_o;(function(n){n.cornerTextureCoordinate="a_CornerTextureCoordinate"})(_o||(_o={}));var nr;(function(n){n.ShapePositionStartLifeTime="a_ShapePositionStartLifeTime",n.DirectionTime="a_DirectionTime",n.StartColor="a_StartColor",n.StartSize="a_StartSize",n.StartRotation0="a_StartRotation0",n.StartSpeed="a_StartSpeed",n.Random0="a_Random0",n.Random1="a_Random1",n.SimulationWorldPosition="a_SimulationWorldPosition",n.SimulationWorldRotation="a_SimulationWorldRotation",n.SimulationUV="a_SimulationUV"})(nr||(nr={}));var du=function(s){this.billboardVertexElement=new Te(_o.cornerTextureCoordinate,0,$.Vector4,0),this.instanceVertexElements=[new Te(nr.ShapePositionStartLifeTime,0,$.Vector4,1,1),new Te(nr.DirectionTime,16,$.Vector4,1,1),new Te(nr.StartColor,32,$.Vector4,1,1),new Te(nr.StartSize,48,$.Vector3,1,1),new Te(nr.StartRotation0,60,$.Vector3,1,1),new Te(nr.StartSpeed,72,$.Float,1,1),new Te(nr.Random0,76,$.Vector4,1,1),new Te(nr.Random1,92,$.Vector4,1,1),new Te(nr.SimulationWorldPosition,108,$.Vector3,1,1),new Te(nr.SimulationWorldRotation,120,$.Vector4,1,1),new Te(nr.SimulationUV,136,$.Vector4,1,1)],this.instanceVertexStride=152,this.instanceVertexFloatStride=this.instanceVertexStride/4,this.startLifeTimeOffset=3,this.timeOffset=7,this.simulationUVOffset=34,this.billboardIndexCount=6;var i=16,t=new Jt(s,Mt.VertexBuffer,i*4,Je.Static,!1);t.isGCIgnored=!0,this.billboardVertexBufferBinding=new Wn(t,i);var e=new Jt(s,Mt.IndexBuffer,this.billboardIndexCount,Je.Static,!1);e.isGCIgnored=!0,this.billboardIndexBufferBinding=new Pa(e,St.UInt8);var r=new Float32Array([-.5,-.5,0,1,.5,-.5,1,1,.5,.5,1,0,-.5,.5,0,0]),a=new Uint8Array([0,2,3,0,1,2]);t.setData(r),e.setData(a),s.resourceManager.addContentRestorer(new(function(o){W(c,o);function c(){return o.call(this,t)}var l=c.prototype;return l.restoreContent=function(){t.setData(r)},c}(br))),s.resourceManager.addContentRestorer(new(function(o){W(c,o);function c(){return o.call(this,e)}var l=c.prototype;return l.restoreContent=function(){},c}(br)))},fu=`#define GLSLIFY 1 uniform mediump sampler2D renderer_BlitTexture; #ifdef HAS_TEX_LOD uniform float renderer_BlitMipLevel; @@ -1019,8 +1019,8 @@ gl_FragColor=texture2DLodEXT(renderer_BlitTexture,v_uv,renderer_BlitMipLevel); #else gl_FragColor=texture2D(renderer_BlitTexture,v_uv); #endif -}`,fu=`#define GLSLIFY 1 -attribute vec4 POSITION_UV;varying vec2 v_uv;void main(){gl_Position=vec4(POSITION_UV.xy,0.0,1.0);v_uv=POSITION_UV.zw;}`,vu=`#define GLSLIFY 1 +}`,vu=`#define GLSLIFY 1 +attribute vec4 POSITION_UV;varying vec2 v_uv;void main(){gl_Position=vec4(POSITION_UV.xy,0.0,1.0);v_uv=POSITION_UV.zw;}`,pu=`#define GLSLIFY 1 #include const float MIE_G=-0.990;const float MIE_G2=0.9801;const float SKY_GROUND_THRESHOLD=0.02;uniform float material_SunSize;uniform float material_SunSizeConvergence;uniform vec4 scene_SunlightColor;uniform vec3 scene_SunlightDirection;varying vec3 v_GroundColor;varying vec3 v_SkyColor; #ifdef MATERIAL_SUN_HIGH_QUALITY @@ -1061,7 +1061,7 @@ gl_FragColor=vec4(col,1.0); #ifndef ENGINE_IS_COLORSPACE_GAMMA gl_FragColor=linearToGamma(gl_FragColor); #endif -}`,pu=`#define GLSLIFY 1 +}`,gu=`#define GLSLIFY 1 #define OUTER_RADIUS 1.025 #define RAYLEIGH (mix(0.0, 0.0025, pow(material_AtmosphereThickness,2.5))) #define MIE 0.0010 @@ -1100,9 +1100,9 @@ v_SunColor=HDSundiskIntensityFactor*clamp(cOut,0.0,1.0)*scene_SunlightColor.xyz/ #elif defined(MATERIAL_SUN_SIMPLE) v_SunColor=simpleSundiskIntensityFactor*clamp(cOut*sunScale,0.0,1.0)*scene_SunlightColor.xyz/lightColorIntensity; #endif -}`,gu=`#define GLSLIFY 1 -uniform sampler2D material_BaseTexture;varying vec2 v_uv;void main(){gl_FragColor=texture2D(material_BaseTexture,v_uv);}`,mu=`#define GLSLIFY 1 -attribute vec3 POSITION;attribute vec2 TEXCOORD_0;varying vec2 v_uv;void main(){gl_Position=vec4(POSITION,1.0);v_uv=TEXCOORD_0;}`,yu=`#define GLSLIFY 1 +}`,mu=`#define GLSLIFY 1 +uniform sampler2D material_BaseTexture;varying vec2 v_uv;void main(){gl_FragColor=texture2D(material_BaseTexture,v_uv);}`,yu=`#define GLSLIFY 1 +attribute vec3 POSITION;attribute vec2 TEXCOORD_0;varying vec2 v_uv;void main(){gl_Position=vec4(POSITION,1.0);v_uv=TEXCOORD_0;}`,xu=`#define GLSLIFY 1 #include #include #include @@ -1128,7 +1128,7 @@ gl_FragColor.a=1.0; #ifndef ENGINE_IS_COLORSPACE_GAMMA gl_FragColor=linearToGamma(gl_FragColor); #endif -}`,xu=`#define GLSLIFY 1 +}`,bu=`#define GLSLIFY 1 #include #include #include @@ -1150,8 +1150,8 @@ void main(){ #include #include #include -}`,bu=`#define GLSLIFY 1 -void main(){}`,Su=`#define GLSLIFY 1 +}`,Su=`#define GLSLIFY 1 +void main(){}`,Cu=`#define GLSLIFY 1 #include #include #include @@ -1160,7 +1160,7 @@ uniform mat4 camera_VPMat;void main(){ #include #include #include -}`,Cu=`#define GLSLIFY 1 +}`,Au=`#define GLSLIFY 1 #include varying vec4 v_Color;varying vec2 v_TextureCoordinate;uniform sampler2D material_BaseTexture;uniform vec4 material_BaseColor; #ifdef RENDERER_MODE_MESH @@ -1181,7 +1181,7 @@ gl_FragColor=color; #ifndef ENGINE_IS_COLORSPACE_GAMMA gl_FragColor=linearToGamma(gl_FragColor); #endif -}`,Au=`#define GLSLIFY 1 +}`,Eu=`#define GLSLIFY 1 #if defined(RENDERER_MODE_SPHERE_BILLBOARD) || defined(RENDERER_MODE_STRETCHED_BILLBOARD) || defined(RENDERER_MODE_HORIZONTAL_BILLBOARD) || defined(RENDERER_MODE_VERTICAL_BILLBOARD) attribute vec4 a_CornerTextureCoordinate; #endif @@ -1227,7 +1227,7 @@ simulateUV=a_CornerTextureCoordinate.zw*a_SimulationUV.xy+a_SimulationUV.zw;v_Te simulateUV=a_SimulationUV.xy+a_MeshTextureCoordinate*a_SimulationUV.zw;v_TextureCoordinate=computeParticleUV(simulateUV,normalizedAge); #endif #endif -}else{gl_Position=vec4(2.0,2.0,2.0,1.0);}}`,Eu=`#define GLSLIFY 1 +}else{gl_Position=vec4(2.0,2.0,2.0,1.0);}}`,wu=`#define GLSLIFY 1 #include #include #include @@ -1244,7 +1244,7 @@ void main(){ #ifndef ENGINE_IS_COLORSPACE_GAMMA gl_FragColor=linearToGamma(gl_FragColor); #endif -}`,wu=`#define GLSLIFY 1 +}`,Tu=`#define GLSLIFY 1 #define IS_METALLIC_WORKFLOW #include #include @@ -1262,7 +1262,7 @@ void main(){ #ifndef ENGINE_IS_COLORSPACE_GAMMA gl_FragColor=linearToGamma(gl_FragColor); #endif -}`,as=`#define GLSLIFY 1 +}`,os=`#define GLSLIFY 1 #include #include #include @@ -1284,7 +1284,7 @@ void main(){ #include #include #include -}`,Tu=`#define GLSLIFY 1 +}`,Ru=`#define GLSLIFY 1 #ifdef ENGINE_NO_DEPTH_TEXTURE vec4 pack(float depth){const vec4 bitShift=vec4(1.0,256.0,256.0*256.0,256.0*256.0*256.0);const vec4 bitMask=vec4(1.0/256.0,1.0/256.0,1.0/256.0,0.0);vec4 rgbaDepth=fract(depth*bitShift);rgbaDepth-=rgbaDepth.gbaa*bitMask;return rgbaDepth;} #endif @@ -1294,7 +1294,7 @@ gl_FragColor=pack(gl_FragCoord.z); #else gl_FragColor=vec4(0.0,0.0,0.0,0.0); #endif -}`,Ru=`#define GLSLIFY 1 +}`,Mu=`#define GLSLIFY 1 #include #include #include @@ -1310,7 +1310,7 @@ vec4 positionWS=renderer_ModelMat*position;positionWS.xyz=applyShadowBias(positi vec3 normalWS=normalize(mat3(renderer_NormalMat)*normal);positionWS.xyz=applyShadowNormalBias(positionWS.xyz,normalWS); #endif #endif -vec4 positionCS=camera_VPMat*positionWS;positionCS.z=max(positionCS.z,-1.0);gl_Position=positionCS;}`,Mu=`#define GLSLIFY 1 +vec4 positionCS=camera_VPMat*positionWS;positionCS.z=max(positionCS.z,-1.0);gl_Position=positionCS;}`,Pu=`#define GLSLIFY 1 #include uniform samplerCube material_CubeTexture;varying vec3 v_cubeUV;uniform float material_Exposure;uniform vec4 material_TintColor;void main(){vec4 textureColor=textureCube(material_CubeTexture,v_cubeUV); #ifdef MATERIAL_IS_DECODE_SKY_RGBM @@ -1322,13 +1322,13 @@ textureColor.rgb*=material_Exposure*material_TintColor.rgb;gl_FragColor=textureC #if defined(MATERIAL_IS_DECODE_SKY_RGBM) || !defined(ENGINE_IS_COLORSPACE_GAMMA) gl_FragColor=linearToGamma(gl_FragColor); #endif -}`,Pu=`#define GLSLIFY 1 +}`,Bu=`#define GLSLIFY 1 #include -uniform mat4 camera_VPMat;varying vec3 v_cubeUV;uniform float material_Rotation;vec4 rotateY(vec4 v,float angle){const float deg2rad=3.1415926/180.0;float radian=angle*deg2rad;float sina=sin(radian);float cosa=cos(radian);mat2 m=mat2(cosa,-sina,sina,cosa);return vec4(m*v.xz,v.yw).xzyw;}void main(){v_cubeUV=vec3(-POSITION.x,POSITION.yz);gl_Position=camera_VPMat*rotateY(vec4(POSITION,1.0),material_Rotation);}`,Bu=`#define GLSLIFY 1 -uniform sampler2D renderer_MaskTexture;uniform float renderer_MaskAlphaCutoff;varying vec2 v_uv;void main(){vec4 color=texture2D(renderer_MaskTexture,v_uv);if(color.a #include #include @@ -1355,7 +1355,7 @@ gl_FragColor.a=1.0; #ifndef ENGINE_IS_COLORSPACE_GAMMA gl_FragColor=linearToGamma(gl_FragColor); #endif -}`,Nu=`#define GLSLIFY 1 +}`,Iu=`#define GLSLIFY 1 #include #include #include @@ -1368,16 +1368,16 @@ void main(){ #include #include #include -}`,Iu=function(){function n(){}return n.init=function(){var i=new vt("ShadowCaster",Ru,Tu,{pipelineStage:Ot.ShadowCaster}),t=new vt("DepthOnly",Su,bu,{pipelineStage:Ot.DepthOnly}),e=[i,t],r={pipelineStage:Ot.Forward};Se.create("blinn-phong",[].concat(new vt("Forward",xu,yu,r),e)),Se.create("pbr",[].concat(new vt("Forward",as,wu,r),e)),Se.create("pbr-specular",[].concat(new vt("Forward",as,Eu,r),e)),Se.create("unlit",[].concat(new vt("Forward",Nu,Fu,r),e)),Se.create("blit",[new vt("Forward",fu,du,r)]),Se.create("skybox",[new vt("Forward",Pu,Mu,r)]),Se.create("SkyProcedural",[new vt("Forward",pu,vu,r)]),Se.create("particle-shader",[new vt("Forward",Au,Cu,r)]),Se.create("SpriteMask",[new vt("Forward",Du,Bu,r)]),Se.create("Sprite",[new vt("Forward",Vu,Lu,r)]),Se.create("background-texture",[new vt("Forward",mu,gu,r)])},n}(),Ou=function(){function n(){this._cacheHierarchyDepth=1,this._cacheMap=Object.create(null)}var s=n.prototype;return s.get=function(t){var e=this._cacheMap,r=t._length,a=this._cacheHierarchyDepth;r>a&&(this._resizeCacheMapHierarchy(e,0,a,r-a),this._cacheHierarchyDepth=r);for(var o=t._mask,c=t._length-1,l=this._cacheHierarchyDepth-1,_=0;_a.length&&(a.length=c),a[r]=o=new Ou,e._shaderProgramPools.push(o)}return o},i._render=function(e){for(var r=function(d,f){var v=e[d];if(!v.isActive||v.destroyed)return"continue";var p=v._componentsManager._activeCameras;if(p.length===0)return ve.debug("No active camera in scene."),"continue";p.forEach(function(g){var y=v._componentsManager;y.callCameraOnBeginRender(g),g.render(),y.callCameraOnEndRender(g),a._hardwareRenderer._options._forceFlush&&a._hardwareRenderer.flush()},function(g,y){g._cameraIndex=y})},a=this,o=this.time.deltaTime,c=0,l=e.length;ca&&(this._resizeCacheMapHierarchy(e,0,a,r-a),this._cacheHierarchyDepth=r);for(var o=t._mask,c=t._length-1,l=this._cacheHierarchyDepth-1,_=0;_a.length&&(a.length=c),a[r]=o=new zu,e._shaderProgramPools.push(o)}return o},i._render=function(e){for(var r=function(d,f){var v=e[d];if(!v.isActive||v.destroyed)return"continue";var p=v._componentsManager._activeCameras;if(p.length===0)return ve.debug("No active camera in scene."),"continue";p.forEach(function(g){var y=v._componentsManager;y.callCameraOnBeginRender(g),g.render(),y.callCameraOnEndRender(g),a._hardwareRenderer._options._forceFlush&&a._hardwareRenderer.flush()},function(g,y){g._cameraIndex=y})},a=this,o=this.time.deltaTime,c=0,l=e.length;c0&&e.forEachAndClean(function(r){r._started=!0,t.removeOnStartScript(r),r.onStart()})},s.callScriptOnUpdate=function(t){this._onUpdateScripts.forEach(function(e){e._started&&e.onUpdate(t)},function(e,r){e._onUpdateIndex=r})},s.callScriptOnLateUpdate=function(t){this._onLateUpdateScripts.forEach(function(e){e._started&&e.onLateUpdate(t)},function(e,r){e._onLateUpdateIndex=r})},s.callScriptOnPhysicsUpdate=function(){this._onPhysicsUpdateScripts.forEach(function(t){t._started&&t.onPhysicsUpdate()},function(t,e){t._onPhysicsUpdateIndex=e})},s.callAnimationUpdate=function(t){this._onUpdateAnimations.forEach(function(e){e.engine.time.frameCount>e._playFrameCount&&e.update(t)},function(e,r){e._onUpdateIndex=r})},s.callRendererOnUpdate=function(t){this._onUpdateRenderers.forEach(function(e){e.update(t)},function(e,r){e._onUpdateIndex=r})},s.handlingInvalidScripts=function(){var t=this,e=t._disposeDestroyScripts,r=t._pendingDestroyScripts;this._disposeDestroyScripts=r,this._pendingDestroyScripts=e;var a=r.length;if(a>0){for(var o=a-1;o>=0;o--)r[o].onDestroy();r.length=0}},s.callCameraOnBeginRender=function(t){t.entity._scripts.forEach(function(e){e.onBeginRender(t)},function(e,r){e._entityScriptsIndex=r})},s.callCameraOnEndRender=function(t){t.entity._scripts.forEach(function(e){e.onEndRender(t)},function(e,r){e._entityScriptsIndex=r})},s.getActiveChangedTempList=function(){return this._componentsContainerPool.length?this._componentsContainerPool.pop():[]},s.putActiveChangedTempList=function(t){t.length=0,this._componentsContainerPool.push(t)},s._gc=function(){this._renderers.garbageCollection(),this._onStartScripts.garbageCollection(),this._onUpdateScripts.garbageCollection(),this._onLateUpdateScripts.garbageCollection(),this._onPhysicsUpdateScripts.garbageCollection(),this._onUpdateAnimations.garbageCollection(),this._onUpdateRenderers.garbageCollection(),this._activeCameras.garbageCollection()},n}(),yi;(function(n){n[n.None=0]="None",n[n.Linear=1]="Linear",n[n.Exponential=2]="Exponential",n[n.ExponentialSquared=3]="ExponentialSquared"})(yi||(yi={}));var Wn;(function(n){n[n.SolidColor=0]="SolidColor",n[n.SphericalHarmonics=1]="SphericalHarmonics"})(Wn||(Wn={}));var Er=function(n){W(s,n);function s(t){var e;return e=n.call(this,t)||this,e._diffuseSolidColor=new q(.212,.227,.259),e._diffuseIntensity=1,e._specularIntensity=1,e._diffuseMode=Wn.SolidColor,e._shArray=new Float32Array(27),e._scenes=[],e._specularTextureDecodeRGBM=!1,e}var i=s.prototype;return i._addToScene=function(e){this._addReferCount(1),this._scenes.push(e);var r=e.shaderData;r.setColor(s._diffuseColorProperty,this._diffuseSolidColor),r.setFloat(s._diffuseIntensityProperty,this._diffuseIntensity),r.setFloat(s._specularIntensityProperty,this._specularIntensity),r.setFloatArray(s._diffuseSHProperty,this._shArray),this._setDiffuseMode(r),this._setSpecularTextureDecodeRGBM(r),this._setSpecularTexture(r)},i._removeFromScene=function(e){this._addReferCount(-1);var r=this._scenes,a=r.indexOf(e);r.splice(a,1);var o=e.shaderData;o.setTexture(s._specularTextureProperty,null),o.disableMacro(s._specularMacro)},i._setDiffuseMode=function(e){this._diffuseMode===Wn.SphericalHarmonics?e.enableMacro(s._shMacro):e.disableMacro(s._shMacro)},i._setSpecularTexture=function(e){this._specularTexture?(e.setTexture(s._specularTextureProperty,this._specularTexture),e.setFloat(s._mipLevelProperty,this._specularTexture.mipmapCount-1),e.enableMacro(s._specularMacro)):e.disableMacro(s._specularMacro)},i._setSpecularTextureDecodeRGBM=function(e){this._specularTextureDecodeRGBM?e.enableMacro(s._decodeRGBMMacro):e.disableMacro(s._decodeRGBMMacro)},i._preComputeSH=function(e,r){var a=e.coefficients;r[0]=a[0]*.886227,r[1]=a[1]*.886227,r[2]=a[2]*.886227,r[3]=a[3]*-1.023327,r[4]=a[4]*-1.023327,r[5]=a[5]*-1.023327,r[6]=a[6]*1.023327,r[7]=a[7]*1.023327,r[8]=a[8]*1.023327,r[9]=a[9]*-1.023327,r[10]=a[10]*-1.023327,r[11]=a[11]*-1.023327,r[12]=a[12]*.858086,r[13]=a[13]*.858086,r[14]=a[14]*.858086,r[15]=a[15]*-.858086,r[16]=a[16]*-.858086,r[17]=a[17]*-.858086,r[18]=a[18]*.247708,r[19]=a[19]*.247708,r[20]=a[20]*.247708,r[21]=a[21]*-.858086,r[22]=a[22]*-.858086,r[23]=a[23]*-.858086,r[24]=a[24]*.429042,r[25]=a[25]*.429042,r[26]=a[26]*.429042},j(s,[{key:"specularTextureDecodeRGBM",get:function(){return this._specularTextureDecodeRGBM},set:function(e){this._specularTextureDecodeRGBM=e;for(var r=this._scenes,a=0,o=r.length;a>>16&65535,this.engine.settings.colorSpace===ir.Linear?(r.color[o]=q.gammaToLinearSpace(l.r),r.color[o+1]=q.gammaToLinearSpace(l.g),r.color[o+2]=q.gammaToLinearSpace(l.b)):(r.color[o]=l.r,r.color[o+1]=l.g,r.color[o+2]=l.b),r.direction[c]=_.x,r.direction[c+1]=_.y,r.direction[c+2]=_.z},i._onEnableInScene=function(){this.scene._lightManager._attachDirectLight(this)},i._onDisableInScene=function(){this.scene._lightManager._detachDirectLight(this)},s._updateShaderData=function(e,r){e.setIntArray(s._cullingMaskProperty,r.cullingMask),e.setFloatArray(s._colorProperty,r.color),e.setFloatArray(s._directionProperty,r.direction)},j(s,[{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return R.scale(this.direction,-1,this._reverseDirection),this._reverseDirection}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),s}(ka);(function(){Xn._cullingMaskProperty=O.getByName("scene_DirectLightCullingMask")})();(function(){Xn._colorProperty=O.getByName("scene_DirectLightColor")})();(function(){Xn._directionProperty=O.getByName("scene_DirectLightDirection")})();var qn=function(n){W(s,n);function s(){var t;return t=n.apply(this,arguments)||this,t.distance=100,t}var i=s.prototype;return i._appendData=function(e,r){var a=e*2,o=e*3,c=e*3,l=e,_=this._getLightIntensityColor(),u=this.position,h=this.cullingMask;r.cullingMask[a]=h&65535,r.cullingMask[a+1]=h>>>16&65535,this.engine.settings.colorSpace===ir.Linear?(r.color[o]=q.gammaToLinearSpace(_.r),r.color[o+1]=q.gammaToLinearSpace(_.g),r.color[o+2]=q.gammaToLinearSpace(_.b)):(r.color[o]=_.r,r.color[o+1]=_.g,r.color[o+2]=_.b),r.position[c]=u.x,r.position[c+1]=u.y,r.position[c+2]=u.z,r.distance[l]=this.distance},i._onEnableInScene=function(){this.scene._lightManager._attachPointLight(this)},i._onDisableInScene=function(){this.scene._lightManager._detachPointLight(this)},s._updateShaderData=function(e,r){e.setIntArray(s._cullingMaskProperty,r.cullingMask),e.setFloatArray(s._colorProperty,r.color),e.setFloatArray(s._positionProperty,r.position),e.setFloatArray(s._distanceProperty,r.distance)},j(s,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),s}(ka);(function(){qn._cullingMaskProperty=O.getByName("scene_PointLightCullingMask")})();(function(){qn._colorProperty=O.getByName("scene_PointLightColor")})();(function(){qn._positionProperty=O.getByName("scene_PointLightPosition")})();(function(){qn._distanceProperty=O.getByName("scene_PointLightDistance")})();var Vr=function(n){W(s,n);function s(){var t;return t=n.apply(this,arguments)||this,t.distance=100,t.angle=Math.PI/6,t.penumbra=Math.PI/12,t._inverseDirection=new R,t._projectMatrix=new Z,t}var i=s.prototype;return i._appendData=function(e,r){var a=e*2,o=e*3,c=e*3,l=e*3,_=e,u=e,h=e,d=this._getLightIntensityColor(),f=this.position,v=this.direction,p=this.cullingMask;r.cullingMask[a]=p&65535,r.cullingMask[a+1]=p>>>16&65535,this.engine.settings.colorSpace===ir.Linear?(r.color[o]=q.gammaToLinearSpace(d.r),r.color[o+1]=q.gammaToLinearSpace(d.g),r.color[o+2]=q.gammaToLinearSpace(d.b)):(r.color[o]=d.r,r.color[o+1]=d.g,r.color[o+2]=d.b),r.position[c]=f.x,r.position[c+1]=f.y,r.position[c+2]=f.z,r.direction[l]=v.x,r.direction[l+1]=v.y,r.direction[l+2]=v.z,r.distance[_]=this.distance,r.angleCos[h]=Math.cos(this.angle),r.penumbraCos[u]=Math.cos(this.angle+this.penumbra)},i._onEnableInScene=function(){this.scene._lightManager._attachSpotLight(this)},i._onDisableInScene=function(){this.scene._lightManager._detachSpotLight(this)},s._updateShaderData=function(e,r){e.setIntArray(s._cullingMaskProperty,r.cullingMask),e.setFloatArray(s._colorProperty,r.color),e.setFloatArray(s._positionProperty,r.position),e.setFloatArray(s._directionProperty,r.direction),e.setFloatArray(s._distanceProperty,r.distance),e.setFloatArray(s._angleCosProperty,r.angleCos),e.setFloatArray(s._penumbraCosProperty,r.penumbraCos)},j(s,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return R.scale(this.direction,-1,this._inverseDirection),this._inverseDirection}},{key:"_shadowProjectionMatrix",get:function(){var e=this._projectMatrix,r=Math.min(Math.PI/2,this.angle*2*Math.sqrt(2));return Z.perspective(r,1,this.shadowNearPlane,this.distance+this.shadowNearPlane,e),e}}]),s}(ka);(function(){Vr._cullingMaskProperty=O.getByName("scene_SpotLightCullingMask")})();(function(){Vr._colorProperty=O.getByName("scene_SpotLightColor")})();(function(){Vr._positionProperty=O.getByName("scene_SpotLightPosition")})();(function(){Vr._directionProperty=O.getByName("scene_SpotLightDirection")})();(function(){Vr._distanceProperty=O.getByName("scene_SpotLightDistance")})();(function(){Vr._angleCosProperty=O.getByName("scene_SpotLightAngleCos")})();(function(){Vr._penumbraCosProperty=O.getByName("scene_SpotLightPenumbraCos")})();var On=function(){function n(){this._spotLights=new He,this._pointLights=new He,this._directLights=new He,this._directData={cullingMask:new Int32Array(n._maxLight*2),color:new Float32Array(n._maxLight*3),direction:new Float32Array(n._maxLight*3)},this._pointData={cullingMask:new Int32Array(n._maxLight*2),color:new Float32Array(n._maxLight*3),position:new Float32Array(n._maxLight*3),distance:new Float32Array(n._maxLight)},this._spotData={cullingMask:new Int32Array(n._maxLight*2),color:new Float32Array(n._maxLight*3),position:new Float32Array(n._maxLight*3),direction:new Float32Array(n._maxLight*3),distance:new Float32Array(n._maxLight),angleCos:new Float32Array(n._maxLight),penumbraCos:new Float32Array(n._maxLight)}}var s=n.prototype;return s._attachSpotLight=function(t){t._lightIndex=this._spotLights.length,this._spotLights.add(t)},s._detachSpotLight=function(t){var e=this._spotLights.deleteByIndex(t._lightIndex);e&&(e._lightIndex=t._lightIndex),t._lightIndex=-1},s._attachPointLight=function(t){t._lightIndex=this._pointLights.length,this._pointLights.add(t)},s._detachPointLight=function(t){var e=this._pointLights.deleteByIndex(t._lightIndex);e&&(e._lightIndex=t._lightIndex),t._lightIndex=-1},s._attachDirectLight=function(t){t._lightIndex=this._directLights.length,this._directLights.add(t)},s._detachDirectLight=function(t){var e=this._directLights.deleteByIndex(t._lightIndex);e&&(e._lightIndex=t._lightIndex),t._lightIndex=-1},s._updateShaderData=function(t){for(var e=this,r=e._spotLights,a=e._pointLights,o=e._directLights,c=this,l=c._spotData,_=c._pointData,u=c._directData,h=n._maxLight,d=Math.min(r.length,h),f=Math.min(a.length,h),v=Math.min(o.length,h),p=0;p0){var a=e.get(0),o=e.get(r);e.set(0,o),e.set(r,a),o._lightIndex=0,a._lightIndex=r}},s._getMaxBrightestSunlight=function(){for(var t=this._directLights,e=null,r=Number.NEGATIVE_INFINITY,a=!1,o=0,c=t.length;o=0;a--){var o=r[a];o._isActive&&(e?o._processActive(ue.Hierarchy):o._processInActive(ue.Hierarchy))}},i._updateShaderData=function(){var e=this.shaderData,r=this._engine,a=this._lightManager;r.time._updateSceneShaderData(e),a._updateShaderData(this.shaderData);var o=this._lightManager._sunlight=this._getSunlight();o?(a._updateSunlightIndex(o),e.setColor(On._sunlightColorProperty,o._lightColor),e.setVector3(On._sunlightDirectionProperty,o.direction)):e.setVector3(On._sunlightDirectionProperty,R._zero),this.castShadows&&o&&o.shadowType!==dn.None?e.enableMacro("SCENE_SHADOW_TYPE",o.shadowType.toString()):e.disableMacro("SCENE_SHADOW_TYPE"),Qt.unionCollection(this.engine._macroCollection,e._macroCollection,this._globalShaderMacro)},i._removeFromEntityList=function(e){var r=this._rootEntities,a=e._siblingIndex;r.splice(a,1);for(var o=r.length;a0;)this._rootEntities[0].destroy();this.background.destroy(),this._ambientLight&&this._ambientLight._removeFromScene(this),this.shaderData._addReferCount(-1),this._componentsManager.handlingInvalidScripts();var r=e._allCreatedScenes;r.splice(r.indexOf(this),1)},i._addToRootEntityList=function(e,r){var a=this._rootEntities,o=a.length;if(e===void 0)r._siblingIndex=o,a.push(r);else{if(e<0||e>o)throw"The index "+e+" is out of child list bounds "+o;r._siblingIndex=e,a.splice(e,0,r);for(var c=e+1,l=o+1;c1!==o){t.destroy(!0);var c=new Rt(i,e,r,a,o);return c.isGCIgnored=!0,c}else return t;else{var l=new Rt(i,e,r,a,o);return l.isGCIgnored=!0,l}},n.recreateRenderTargetIfNeeded=function(i,t,e,r,a,o,c,l,_){var u,h=(u=t)==null?void 0:u.getColorTexture(0),d=a?n.recreateTextureIfNeeded(i,h,e,r,a,l):null;if(c){var f,v=(f=t)==null?void 0:f.depthTexture,p=o?n.recreateTextureIfNeeded(i,v,e,r,o,l):null;if(h!==d||v!==p){var g;(g=t)==null||g.destroy(!0),t=new Pa(i,e,r,d,p,_),t.isGCIgnored=!0}}else{var y,m=o;if(h!==d||((y=t)==null?void 0:y._depthFormat)!==m){var x;(x=t)==null||x.destroy(!0),t=new Pa(i,e,r,d,m,_),t.isGCIgnored=!0}}return t},n.blitTexture=function(i,t,e,r,a){r===void 0&&(r=0);var o=i._basicResources,c=e?o.flipYBlitMesh:o.blitMesh,l=o.blitMaterial,_=i._hardwareRenderer,u=i._renderContext;u.flipProjection=!!e,_.activeRenderTarget(e,a??n.defaultViewport,u.flipProjection,0);var h=n._rendererShaderData,d=l.shader.subShaders[0].passes[0],f=d._getShaderProgram(i,Se._compileMacros);h.setTexture(n._blitTextureProperty,t),h.setFloat(n._blitMipLevelProperty,r),f.bind(),f.groupingOtherUniformBlock(),f.uploadAll(f.rendererUniformBlock,h),f.uploadAll(f.materialUniformBlock,l.shaderData),f.uploadUnGroupTextures(),(d._renderState||l.renderState)._apply(i,!1,d._renderStateDataMap,l.shaderData),_.drawPrimitive(c._primitive,c.subMesh,f)},n}();(function(){sr._blitTextureProperty=O.getByName("renderer_BlitTexture")})();(function(){sr._blitMipLevelProperty=O.getByName("renderer_BlitMipLevel")})();(function(){sr._rendererShaderData=new Fr(yr.Renderer)})();(function(){sr.defaultViewport=new ie(0,0,1,1)})();var Uc=function(n){W(s,n);function s(){return n.apply(this,arguments)}var i=s.prototype;return i.createVertexElements=function(e){return e[0]=new Te("POSITION",0,$.Vector3,0),e[1]=new Te("TEXCOORD_0",12,$.Vector2,0),e[2]=new Te("COLOR_0",20,$.Vector4,0),36},i.canBatch=function(e,r){if(!this._engine._canSpriteBatch||r.shaderPasses[0].getTagValue(Br._disableBatchTag)===!0)return!1;var a=e.data,o=r.data,c=a.component,l=o.component;return!this.checkBatchWithMask(c,l)||a.texture!==o.texture?!1:a.material===o.material},i.checkBatchWithMask=function(e,r){var a=e.maskInteraction;return a!==r.maskInteraction?!1:a===ct.None?!0:e.maskLayer===r.maskLayer},i.updateVertices=function(e,r,a){for(var o=e.verticesData,c=o.positions,l=o.uvs,_=o.color,u=o.vertexCount,h=0;h=0?a.x:r.x)+l.y*(l.y>=0?a.y:r.y)+l.z*(l.z>=0?a.z:r.z)<-c.distance)return!1}return!0},n.shadowCullFrustum=function(i,t,e,r){var a=e._entity.layer;i.camera.cullingMask&a&&t.cullingMask&a&&e.castShadows&&n.cullingRenderBounds(e.bounds,r.cullPlaneCount,r.cullPlanes)&&(e._renderFrameCount=e.engine.time.frameCount,e._prepareRender(i))},n.getBoundSphereByFrustum=function(i,t,e,r,a){var o=e.aspectRatio,c=e.fieldOfView,l,_,u=Math.sqrt(1+o*o)*Math.tan(k.degreeToRadian(c)/2),h=u*u,d=t-i,f=t+i;h>d/f?(l=t,_=t*u):(l=.5*f*(1+h),_=.5*Math.sqrt(d*d+2*(t*t+i*i)*h+f*f*h*h));var v=a.splitBoundSphere.center;a.splitBoundSphere.radius=_,R.scale(r,l,v),R.add(e.entity.transform.worldPosition,v,v),a.sphereCenterZ=l},n.getDirectionLightShadowCullPlanes=function(i,t,e,r,a){var o=n._frustumCorners,c=n._backPlaneFaces,l=n._frustumPlaneNeighbors,_=n._frustumTwoPlaneCorners,u=n._edgePlanePoint2,h=a.cullPlanes,d=i.getPlane(me.Near),f=i.getPlane(me.Far),v=i.getPlane(me.Left),p=i.getPlane(me.Right),g=i.getPlane(me.Bottom),y=i.getPlane(me.Top),m=t-e,x=n._adjustNearPlane,C=n._adjustFarPlane;x.normal.copyFrom(d.normal),C.normal.copyFrom(f.normal),x.distance=d.distance-m,C.distance=Math.min(-d.distance+a.sphereCenterZ+a.splitBoundSphere.radius,f.distance),Tt.intersectionPointThreePlanes(x,g,p,o[7]),Tt.intersectionPointThreePlanes(x,y,p,o[6]),Tt.intersectionPointThreePlanes(x,y,v,o[5]),Tt.intersectionPointThreePlanes(x,g,v,o[4]),Tt.intersectionPointThreePlanes(C,g,p,o[3]),Tt.intersectionPointThreePlanes(C,y,p,o[2]),Tt.intersectionPointThreePlanes(C,y,v,o[1]),Tt.intersectionPointThreePlanes(C,g,v,o[0]);for(var b=0,A=0;A<6;A++){var S=void 0;switch(A){case me.Near:S=x;break;case me.Far:S=C;break;default:S=i.getPlane(A);break}R.dot(S.normal,r)<0&&(h[b].copyFrom(S),c[b]=A,b++)}for(var w=b,E=0;E>1),a=Math.floor(i/r)*Math.floor(t/r);return r},n.getShadowBias=function(i,t,e,r){var a=2/t.elements[0],o=a/e,c=-i.shadowBias*o,l=-i.shadowNormalBias*o;if(i.shadowType==dn.SoftHigh){var _=2.5;c*=_,l*=_}r.set(c,l)},n.applySliceTransform=function(i,t,e,r,a,o){var c=n._tempMatrix0,l=c.elements,_=1/t,u=1/e,h=i*_,d=i*u,f=a.x*_,v=a.y*u;l[0]=h,l[1]=0,l[2]=0,l[3]=0,l[4]=0,l[5]=d,l[6]=0,l[7]=0,l[8]=0,l[9]=0,l[10]=1,l[11]=0,l[12]=f,l[13]=v,l[14]=0,l[15]=1;var p=r*16;Ue._floatMatrixMultiply(c,o,p,o,p)},n.getScaleAndBiasForLinearDistanceFade=function(i,t,e){if(t<1e-4){var r=1e3;e.z=r,e.w=-i*r;return}t=1-t,t*=t;var a=t*i,o=i-a;e.z=1/o,e.w=-a/o},n}();(function(){st._tempMatrix0=new Z})();(function(){st._shadowMapCoordMatrix=new Z(.5,0,0,0,0,-.5,0,0,0,0,.5,0,.5,.5,.5,1)})();(function(){st._frustumCorners=[new R,new R,new R,new R,new R,new R,new R,new R]})();(function(){st._adjustNearPlane=new ht(new R)})();(function(){st._adjustFarPlane=new ht(new R)})();(function(){st._backPlaneFaces=new Array(5)})();(function(){st._edgePlanePoint2=new R})();(function(){st._frustumPlaneNeighbors=[[me.Left,me.Right,me.Top,me.Bottom],[me.Left,me.Right,me.Top,me.Bottom],[me.Near,me.Far,me.Top,me.Bottom],[me.Near,me.Far,me.Top,me.Bottom],[me.Near,me.Far,me.Left,me.Right],[me.Near,me.Far,me.Left,me.Right]]})();(function(){st._frustumTwoPlaneCorners=[[[8,8],[8,8],[4,5],[6,7],[7,4],[5,6]],[[8,8],[8,8],[1,0],[3,2],[0,3],[2,1]],[[5,4],[0,1],[8,8],[8,8],[4,0],[1,5]],[[7,6],[2,3],[8,8],[8,8],[3,7],[6,2]],[[4,7],[3,0],[0,4],[7,3],[8,8],[8,8]],[[6,5],[1,2],[5,1],[2,6],[8,8],[8,8]]]})();(function(){st.atlasBorderSize=4})();var Ut=function(n){W(s,n);function s(t){var e;return e=n.call(this,t.engine)||this,e._shadowMapSize=new ie,e._shadowBias=new ee,e._shadowSliceData=new Uu,e._lightUp=new R,e._lightSide=new R,e._splitBoundSpheres=new Float32Array(s._maxCascades*4),e._shadowMatrices=new Float32Array((s._maxCascades+1)*16),e._shadowInfos=new ie,e._viewportOffsets=[new ee,new ee,new ee,new ee],e._camera=t,e._supportDepthTexture=t.engine._hardwareRenderer.canIUse(K.depthTexture),e._shadowSliceData.virtualCamera.isOrthographic=!0,e}var i=s.prototype;return i.onRender=function(e){var r=this._camera.scene._lightManager._sunlight;this._updateShadowSettings(),this._renderDirectShadowMap(e,r),this._updateReceiversShaderData(r)},i._renderDirectShadowMap=function(e,r){var a=this,o=a._engine,c=a._camera,l=a._viewportOffsets,_=a._shadowSliceData,u=a._splitBoundSpheres,h=a._shadowMatrices,d=c._renderPipeline._cullingResults,f=d.opaqueQueue,v=d.alphaTestQueue,p=d.transparentQueue,g=c.scene,y=g._componentsManager,m=o._hardwareRenderer,x=g.shadowCascades,C=s._cascadesSplitDistance,b=_.splitBoundSphere,A=s._tempMatrix0,S=A.elements,w=this._lightUp,E=this._lightSide,B=_.virtualCamera.forward,M=this._shadowMapSize,D=M.z,L=M.w,V=this._shadowMapFormat,N,I;this._supportDepthTexture?(N=sr.recreateRenderTargetIfNeeded(o,this._renderTarget,D,L,null,V,!0,!1,1),I=N.depthTexture):(N=sr.recreateRenderTargetIfNeeded(o,this._renderTarget,D,L,V,null,!1,!1,1),I=N.getColorTexture(0)),I.wrapModeU=I.wrapModeV=gt.Clamp,o._hardwareRenderer._isWebGL2&&(I.depthCompareFunction=fr.Less),this._renderTarget=N,this._depthTexture=I,m.activeRenderTarget(N,s._viewport,e.flipProjection,0),this._supportDepthTexture?m.clearRenderTarget(o,zt.Depth,null):m.clearRenderTarget(o,zt.All,s._clearColor),Z.rotationQuaternion(r.entity.transform.worldRotationQuaternion,A),E.set(S[0],S[1],S[2]),w.set(S[4],S[5],S[6]),B.set(-S[8],-S[9],-S[10]);var P=s._tempVector;P.copyFrom(c.entity.transform.worldForward);for(var z=this._shadowTileResolution,U=0;U1&&st.applySliceTransform(z,D,L,U,this._viewportOffsets[U],h),this._updateSingleShadowCasterShaderData(r,_,e);var Y=b.center,Q=b.radius,H=U*4;u[H]=Y.x,u[H+1]=Y.y,u[H+2]=Y.z,u[H+3]=Q*Q,f.clear(),v.clear(),p.clear();for(var te=y._renderers,Ce=te._elements,de=te.length-1;de>=0;--de)st.shadowCullFrustum(e,r,Ce[de],_);if(f.elements.length||v.elements.length){f.sort(rn._compareFromNearToFar),v.sort(rn._compareFromNearToFar);var ae=l[U],Ae=ae.x,je=ae.y;m.setGlobalDepthBias(1,1),m.viewport(Ae,je,z,z),m.scissor(Ae+1,je+1,z-2,z-2),o._renderCount++,f.render(c,Ot.ShadowCaster),v.render(c,Ot.ShadowCaster),m.setGlobalDepthBias(0,0)}}},i._updateReceiversShaderData=function(e){var r=this._camera,a=r.scene,o=this._splitBoundSpheres,c=this._shadowMatrices,l=a.shadowCascades,_=Math.min(a.shadowDistance,r.farClipPlane);if(st.getScaleAndBiasForLinearDistanceFade(Math.pow(_,2),a.shadowFadeBorder,this._shadowInfos),this._shadowInfos.x=e.shadowStrength,l>1)for(var u=l*4,h=o.length;u=0;--c){var l=o[c];e.cullingMask&l._entity.layer&&(e.enableFrustumCulling&&!e._frustum.intersectsBox(l.bounds)||(l._renderFrameCount=r.time.frameCount,l._prepareRender(t)))}},s._updateMVPShaderData=function(t){for(var e=t.camera,r=e.scene._componentsManager._renderers,a=r._elements,o=r.length-1;o>=0;--o){var c=a[o];c._updateShaderData(t,!0)}},n}(),os;(function(n){n[n.None=0]="None",n[n.Opaque=1]="Opaque",n[n.AlphaTest=2]="AlphaTest",n[n.Transparent=4]="Transparent"})(os||(os={}));var La;(function(n){n[n.Normal=0]="Normal",n[n.XRCenterCamera=1]="XRCenterCamera",n[n.XRLeftCamera=2]="XRLeftCamera",n[n.XRRightCamera=4]="XRRightCamera"})(La||(La={}));var xi;(function(n){n[n.None=1]="None",n[n.TwoX=2]="TwoX",n[n.FourX=4]="FourX",n[n.EightX=8]="EightX"})(xi||(xi={}));var $r,zn=function(){};(function(){zn.tempVec4=new ie})();(function(){zn.tempVec3=new R})();(function(){zn.tempVec2=new ee})();var ze=($r=function(n){W(s,n);function s(t){var e;e=n.call(this,t)||this,e.enableFrustumCulling=!0,e.clearFlags=zt.All,e.cullingMask=An.Everything,e.depthTextureMode=Da.None,e.opaqueTextureDownsampling=ua.TwoX,e.msaaSamples=xi.None,e._cameraType=La.Normal,e._globalShaderMacro=new Qt,e._frustum=new al,e._virtualCamera=new kc,e._replacementShader=null,e._replacementSubShaderTag=null,e._cameraIndex=-1,e._priority=0,e._shaderData=new Fr(yr.Camera),e._isCustomViewMatrix=!1,e._isCustomProjectionMatrix=!1,e._fieldOfView=45,e._orthographicSize=10,e._isProjectionDirty=!0,e._isInvProjMatDirty=!0,e._customAspectRatio=void 0,e._renderTarget=null,e._depthBufferParams=new ie,e._opaqueTextureEnabled=!1,e._viewport=new ie(0,0,1,1),e._pixelViewport=new kr(0,0,0,0),e._inverseProjectionMatrix=new Z,e._invViewProjMat=new Z;var r=e.entity.transform;return e._transform=r,e._isViewMatrixDirty=r.registerWorldChangeFlag(),e._isInvViewProjDirty=r.registerWorldChangeFlag(),e._frustumChangeFlag=r.registerWorldChangeFlag(),e._renderPipeline=new Gc(_e(e)),e._addResourceReferCount(e.shaderData,1),e._updatePixelViewport(),e._onPixelViewportChanged=e._onPixelViewportChanged.bind(_e(e)),e._viewport._onValueChanged=e._onPixelViewportChanged,e.engine.canvas._sizeUpdateFlagManager.addListener(e._onPixelViewportChanged),e}var i=s.prototype;return i.resetViewMatrix=function(){this._isCustomViewMatrix=!1,this._viewMatrixChange()},i.resetProjectionMatrix=function(){this._isCustomProjectionMatrix=!1,this._projectionMatrixChange()},i.resetAspectRatio=function(){this._customAspectRatio=void 0,this._projectionMatrixChange()},i.worldToViewportPoint=function(e,r){var a=zn.tempVec3,o=zn.tempVec4;R.transformCoordinate(e,this.viewMatrix,a),R.transformToVec4(a,this.projectionMatrix,o);var c=o.w;return r.set((o.x/c+1)*.5,(1-o.y/c)*.5,-a.z),r},i.viewportToWorldPoint=function(e,r){var a=this,o=a.nearClipPlane,c=a.farClipPlane,l=1/(o-c),_;if(this.isOrthographic)_=-e.z*2*l,_+=(c+o)*l;else{var u=e.z;_=-u*(o+c)*l,_+=2*o*c*l,_=_/u}return this._innerViewportToWorldPoint(e.x,e.y,(_+1)/2,this._getInvViewProjMat(),r),r},i.viewportPointToRay=function(e,r){var a=this._getInvViewProjMat(),o=this._innerViewportToWorldPoint(e.x,e.y,0,a,r.origin),c=this._innerViewportToWorldPoint(e.x,e.y,1-k.zeroTolerance,a,r.direction);return R.subtract(c,o,c),c.normalize(),r},i.screenToViewportPoint=function(e,r){var a=this.engine.canvas,o=this.viewport;return r.x=(e.x/a.width-o.x)/o.z,r.y=(e.y/a.height-o.y)/o.w,e.z!==void 0&&(r.z=e.z),r},i.viewportToScreenPoint=function(e,r){var a=this.engine.canvas,o=this.viewport;return r.x=(o.x+e.x*o.z)*a.width,r.y=(o.y+e.y*o.w)*a.height,e.z!==void 0&&(r.z=e.z),r},i.worldToScreenPoint=function(e,r){return this.worldToViewportPoint(e,r),this.viewportToScreenPoint(r,r)},i.screenToWorldPoint=function(e,r){return this.screenToViewportPoint(e,r),this.viewportToWorldPoint(r,r)},i.screenPointToRay=function(e,r){var a=zn.tempVec2;return this.screenToViewportPoint(e,a),this.viewportPointToRay(a,r)},i.render=function(e,r){r===void 0&&(r=0);var a=this.engine._renderContext,o=this._virtualCamera,c=this.entity.transform;Z.multiply(this.projectionMatrix,this.viewMatrix,o.viewProjectionMatrix),o.position.copyFrom(c.worldPosition),o.isOrthographic&&o.forward.copyFrom(c.worldForward),a.camera=this,a.virtualCamera=o,a.replacementShader=this._replacementShader,a.replacementTag=this._replacementSubShaderTag,this.enableFrustumCulling&&this._frustumChangeFlag.flag&&(this._frustum.calculateFromMatrix(o.viewProjectionMatrix),this._frustumChangeFlag.flag=!1),this._updateShaderData(),Qt.unionCollection(this.scene._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro),r>0&&!this.engine._hardwareRenderer.isWebGL2&&(r=0,ve.error("mipLevel only take effect in WebGL2.0"));var l;this._cameraType!==La.Normal&&(l=this.engine.xrManager._getCameraClearFlagsMask(this._cameraType)),this._renderPipeline.render(a,e,r,l),this._engine._renderCount++},i.setReplacementShader=function(e,r){this._replacementShader=e,this._replacementSubShaderTag=typeof r=="string"?sn.getByName(r):r},i.resetReplacementShader=function(){this._replacementShader=null,this._replacementSubShaderTag=null},i._onEnableInScene=function(){this.scene._componentsManager.addCamera(this)},i._onDisableInScene=function(){this.scene._componentsManager.removeCamera(this)},i._onDestroy=function(){var e;n.prototype._onDestroy.call(this),(e=this._renderPipeline)==null||e.destroy(),this._isInvViewProjDirty.destroy(),this._isViewMatrixDirty.destroy(),this._addResourceReferCount(this.shaderData,-1),this._viewport._onValueChanged=null,this.engine.canvas._sizeUpdateFlagManager.removeListener(this._onPixelViewportChanged),this._entity=null,this._globalShaderMacro=null,this._frustum=null,this._renderPipeline=null,this._virtualCamera=null,this._shaderData=null,this._frustumChangeFlag=null,this._transform=null,this._isViewMatrixDirty=null,this._isInvViewProjDirty=null,this._viewport=null,this._inverseProjectionMatrix=null,this._invViewProjMat=null},i._updatePixelViewport=function(){var e,r,a=this._renderTarget;if(a)e=a.width,r=a.height;else{var o=this.engine.canvas;e=o.width,r=o.height}var c=this._viewport;this._pixelViewport.set(c.x*e,c.y*r,c.z*e,c.w*r)},i._viewMatrixChange=function(){this._isViewMatrixDirty.flag=!0,this._isInvViewProjDirty.flag=!0,this._frustumChangeFlag.flag=!0},i._projectionMatrixChange=function(){this._isProjectionDirty=!0,this._isInvProjMatDirty=!0,this._isInvViewProjDirty.flag=!0,this._frustumChangeFlag.flag=!0},i._innerViewportToWorldPoint=function(e,r,a,o,c){var l=zn.tempVec3;return l.set(e*2-1,1-r*2,a*2-1),R.transformCoordinate(l,o,c),c},i._updateShaderData=function(){var e=this.shaderData,r=this._transform;e.setMatrix(ze._inverseViewMatrixProperty,r.worldMatrix),e.setVector3(ze._cameraPositionProperty,r.worldPosition),e.setVector3(ze._cameraForwardProperty,r.worldForward),e.setVector3(ze._cameraUpProperty,r.worldUp);var a=this._depthBufferParams,o=this.farClipPlane/this.nearClipPlane;a.set(1-o,o,0,0),e.setVector4(ze._cameraDepthBufferParamsProperty,a)},i._getInvViewProjMat=function(){return this._isInvViewProjDirty.flag&&(this._isInvViewProjDirty.flag=!1,Z.multiply(this._transform.worldMatrix,this._getInverseProjectionMatrix(),this._invViewProjMat)),this._invViewProjMat},i._getInverseProjectionMatrix=function(){return this._isInvProjMatDirty&&(this._isInvProjMatDirty=!1,Z.invert(this.projectionMatrix,this._inverseProjectionMatrix)),this._inverseProjectionMatrix},i._forceUseInternalCanvas=function(){return this.opaqueTextureEnabled},i._onPixelViewportChanged=function(){this._updatePixelViewport();var e;(e=this._customAspectRatio)!=null||this._projectionMatrixChange(),this._checkMainCanvasAntialiasWaste()},i._checkMainCanvasAntialiasWaste=function(){this.independentCanvasEnabled&&ie.equals(this._viewport,sr.defaultViewport)&&console.warn("Camera use independent canvas and viewport cover the whole screen, it is recommended to disable antialias, depth and stencil to save memory when create engine.")},j(s,[{key:"opaqueTextureEnabled",get:function(){return this._opaqueTextureEnabled},set:function(e){this._opaqueTextureEnabled!==e&&(this._opaqueTextureEnabled=e,this._checkMainCanvasAntialiasWaste())}},{key:"independentCanvasEnabled",get:function(){return this._renderTarget?!1:this._forceUseInternalCanvas()}},{key:"shaderData",get:function(){return this._shaderData}},{key:"nearClipPlane",get:function(){return this._virtualCamera.nearClipPlane},set:function(e){this._virtualCamera.nearClipPlane=e,this._projectionMatrixChange()}},{key:"farClipPlane",get:function(){return this._virtualCamera.farClipPlane},set:function(e){this._virtualCamera.farClipPlane=e,this._projectionMatrixChange()}},{key:"fieldOfView",get:function(){return this._fieldOfView},set:function(e){this._fieldOfView=e,this._projectionMatrixChange()}},{key:"aspectRatio",get:function(){var e=this.pixelViewport,r;return(r=this._customAspectRatio)!=null?r:e.width/e.height},set:function(e){this._customAspectRatio=e,this._projectionMatrixChange()}},{key:"viewport",get:function(){return this._viewport},set:function(e){e!==this._viewport&&this._viewport.copyFrom(e)}},{key:"pixelViewport",get:function(){return this._pixelViewport}},{key:"priority",get:function(){return this._priority},set:function(e){this._priority!==e&&(this._phasedActiveInScene&&(this.scene._componentsManager._cameraNeedSorting=!0),this._priority=e)}},{key:"isOrthographic",get:function(){return this._virtualCamera.isOrthographic},set:function(e){this._virtualCamera.isOrthographic=e,this._projectionMatrixChange(),e?this.shaderData.enableMacro("CAMERA_ORTHOGRAPHIC"):this.shaderData.disableMacro("CAMERA_ORTHOGRAPHIC")}},{key:"orthographicSize",get:function(){return this._orthographicSize},set:function(e){this._orthographicSize=e,this._projectionMatrixChange()}},{key:"viewMatrix",get:function(){var e=this._virtualCamera.viewMatrix;if(!this._isViewMatrixDirty.flag||this._isCustomViewMatrix)return e;this._isViewMatrixDirty.flag=!1;var r=this._transform;return Z.rotationTranslation(r.worldRotationQuaternion,r.worldPosition,e),e.invert(),e},set:function(e){this._virtualCamera.viewMatrix.copyFrom(e),this._isCustomViewMatrix=!0,this._viewMatrixChange()}},{key:"projectionMatrix",get:function(){var e=this._virtualCamera,r=e.projectionMatrix;if(!this._isProjectionDirty||this._isCustomProjectionMatrix)return r;this._isProjectionDirty=!1;var a=this.aspectRatio;if(!e.isOrthographic)Z.perspective(k.degreeToRadian(this._fieldOfView),a,this.nearClipPlane,this.farClipPlane,r);else{var o=this._orthographicSize*a,c=this._orthographicSize;Z.ortho(-o,o,-c,c,this.nearClipPlane,this.farClipPlane,r)}return r},set:function(e){this._virtualCamera.projectionMatrix.copyFrom(e),this._isCustomProjectionMatrix=!0,this._projectionMatrixChange()}},{key:"enableHDR",get:function(){return console.log("not implementation"),!1},set:function(e){console.log("not implementation")}},{key:"renderTarget",get:function(){return this._renderTarget},set:function(e){this._renderTarget!==e&&(this._renderTarget&&this._addResourceReferCount(this._renderTarget,-1),e&&this._addResourceReferCount(e,1),this._renderTarget=e,this._onPixelViewportChanged(),this._checkMainCanvasAntialiasWaste())}}]),s}(Mt),function(){$r._cameraDepthTextureProperty=O.getByName("camera_DepthTexture")}(),function(){$r._cameraOpaqueTextureProperty=O.getByName("camera_OpaqueTexture")}(),function(){$r._inverseViewMatrixProperty=O.getByName("camera_ViewInvMat")}(),function(){$r._cameraPositionProperty=O.getByName("camera_Position")}(),function(){$r._cameraForwardProperty=O.getByName("camera_Forward")}(),function(){$r._cameraUpProperty=O.getByName("camera_Up")}(),function(){$r._cameraDepthBufferParamsProperty=O.getByName("camera_DepthBufferParams")}(),$r);T([J],ze.prototype,"_frustum",void 0);T([F],ze.prototype,"_renderPipeline",void 0);T([F],ze.prototype,"_virtualCamera",void 0);T([F],ze.prototype,"_cameraIndex",void 0);T([F],ze.prototype,"_frustumChangeFlag",void 0);T([F],ze.prototype,"_transform",void 0);T([F],ze.prototype,"_isViewMatrixDirty",void 0);T([F],ze.prototype,"_isInvViewProjDirty",void 0);T([J],ze.prototype,"_viewport",void 0);T([J],ze.prototype,"_pixelViewport",void 0);T([J],ze.prototype,"_inverseProjectionMatrix",void 0);T([J],ze.prototype,"_invViewProjMat",void 0);T([F],ze.prototype,"_onPixelViewportChanged",null);ze=T([za(ge,Gn.CheckOnly)],ze);var Wu={json:"json",gltf:"json",mtl:"json",prefab:"json",txt:"text",bin:"arraybuffer",png:"image",webp:"image",jpg:"image"},Xu=1,ju=1/0,qu=500;function Yn(n,s){return s===void 0&&(s={}),new Pe(function(i,t,e,r){var a,o=(a=s.retryCount)!=null?a:Xu,c,l=(c=s.retryInterval)!=null?c:qu,_;s.timeout=(_=s.timeout)!=null?_:ju;var u;s.type=(u=s.type)!=null?u:Qu(n);var h=new Ku(function(){return Yu(n,s).onProgress(e,r)},o,l);h.start().onError(t).onComplete(i)})}function Yu(n,s){return new Pe(function(i,t,e,r){var a=new XMLHttpRequest,o=s.type==="image";a.timeout=s.timeout;var c;s.method=(c=s.method)!=null?c:"get",a.onload=function(){if(a.status<200||a.status>=300){t(new Error("request failed from: "+n));return}var _,u=(_=a.response)!=null?_:a.responseText;if(o){var h=new Image;h.onload=function(){requestAnimationFrame(function(){e(1,1),i(h),h.onload=null,h.onerror=null,h.onabort=null,URL.revokeObjectURL(h.src)})},h.onerror=h.onabort=function(){t(new Error("request "+h.src+" fail")),URL.revokeObjectURL(h.src)},h.crossOrigin="anonymous",h.src=URL.createObjectURL(u)}else e(1,1),i(u)},a.onerror=function(){t(new Error("request failed from: "+n))},a.ontimeout=function(){t(new Error("request timeout from: "+n))},a.onprogress=function(_){_.lengthComputable&&r(n,_.loaded,_.total)},a.open(s.method,n,!0),a.withCredentials=s.credentials==="include",a.responseType=o?"blob":s.type;var l=s.headers;l&&Object.keys(l).forEach(function(_){a.setRequestHeader(_,l[_])}),a.send(s.body)})}function Qu(n){var s=n.substring(n.lastIndexOf(".")+1);return Wu[s]}var Ku=function(){function n(i,t,e){this.execFunc=i,this.totalCount=t,this.interval=e,this._timeoutId=-100,this._currentCount=0,this.exec=this.exec.bind(this)}var s=n.prototype;return s.start=function(){return this.exec(),this},s.onComplete=function(t){return this._onComplete=t,this},s.onError=function(t){return this._onError=t,this},s.cancel=function(){window.clearTimeout(this._timeoutId)},s.exec=function(){var t=this;if(this._currentCount>=this.totalCount){this._onError&&this._onError(this._error);return}this._currentCount++,this.execFunc(this._currentCount).then(function(e){return t._onComplete&&t._onComplete(e)}).catch(function(e){t._error=e,t._timeoutId=window.setTimeout(t.exec,t.interval)})},n}(),Be=function(){function n(s){this.useCache=s,this.request=Yn}return n.registerClass=function(i,t){this._engineObjects[i]=t,this._classNameMap.set(t,i)},n.getClass=function(i){return this._engineObjects[i]},n.getClassName=function(i){return this._classNameMap.get(i)},n}();(function(){Be._engineObjects={}})();(function(){Be._classNameMap=new Map})();var Ju=function(){function n(){}var s=n.prototype;return s.initialize=function(t){var e=t.component,r=t.property.split(".");if(t.getProperty){var a=t.getProperty.split(".");this._initializeMounted(e,a,1),this._initializeMounted(e,r,2)}else this._initializeMounted(e,r,3)},s.getTargetValue=function(){switch(this._getType){case 2:return this._getMounted[this._getArrayIndex];case 1:return this._getMounted[this._getValueName].apply(this._getMounted,this._getArgs);case 0:return this._getMounted[this._getValueName]}},s.setTargetValue=function(t){switch(this._setType){case 2:this._setMounted[this._setArrayIndex]=t;break;case 1:var e=this._setArgs;e[this._replaceValueIndex]=t,this._setMounted[this._setValueName].apply(this._setMounted,e);break;case 0:this._setMounted[this._setValueName]=t;break}},s._initializeMounted=function(t,e,r){for(var a=e.length-1,o=0;o-1){var l=c.indexOf("[");t=t[c.slice(0,l)],t=t[parseInt(c.slice(l+1,-1))]}else if(c.endsWith(")")){var _=c.slice(0,c.indexOf("(")),u=c.match(/\w+\(([^)]*)\)/)[1].split(",").map(function(m){return m.trim().replace(/['"]+/g,"")}).filter(function(m){return m!==""});t=t[_].apply(t,u)}else t=t[c]}var h=e[a],d,f,v,p;if(h.indexOf("[")>-1){var g=h.indexOf("[");d=2,t=t[h.slice(0,g)],f=parseInt(h.slice(g+1,-1))}else if(h.endsWith(")")){if(v=h.slice(0,h.indexOf("(")),p=h.match(/\w+\(([^)]*)\)/)[1].split(",").map(function(m){return m.trim().replace(/['"]+/g,"")}).filter(function(m){return m!==""}),d=1,r&2){var y=p.indexOf("$value");this._replaceValueIndex=y>-1?y:p.length}}else d=0;r&2&&(this._setMounted=t,this._setType=d,this._setArrayIndex=f,this._setValueName=h,v&&(this._setValueName=v),this._setArgs=p),r&1&&(this._getMounted=t,this._getType=d,this._getArrayIndex=f,this._getValueName=h,v&&(this._getValueName=v),this._getArgs=p)},n}(),ss;(function(n){n[n.Property=0]="Property",n[n.Method=1]="Method",n[n.Array=2]="Array"})(ss||(ss={}));var cs;(function(n){n[n.Get=1]="Get",n[n.Set=2]="Set",n[n.Both=3]="Both"})(cs||(cs={}));var fn=function(){function n(i,t,e,r,a,o){this.baseEvaluateData={curKeyframeIndex:0,value:null},this.crossEvaluateData={curKeyframeIndex:0,value:null},this.updateMark=0,this.target=i,this.property=r,this.getProperty=a,this.component=e,this.cureType=o;var c=n.getAssemblerType(t,r);this._assembler=new c,this._assembler.initialize(this),o._isCopyMode&&(this.referenceTargetValue=this._assembler.getTargetValue())}var s=n.prototype;return s.evaluateValue=function(t,e,r){return r?t._evaluateAdditive(e,this.baseEvaluateData):t._evaluate(e,this.baseEvaluateData)},s.evaluateCrossFadeValue=function(t,e,r,a,o,c){if(!this.cureType._supportInterpolationMode)return this.evaluateValue(e,a,!1);var l=t&&t.keys.length?c?t._evaluateAdditive(r,this.baseEvaluateData):t._evaluate(r,this.baseEvaluateData):c?this.cureType._getZeroValue(this.baseEvaluateData.value):this.defaultValue,_=e&&e.keys.length?c?e._evaluateAdditive(a,this.crossEvaluateData):e._evaluate(a,this.crossEvaluateData):c?this.cureType._getZeroValue(this.crossEvaluateData.value):this.defaultValue;return this._lerpValue(l,_,o)},s.crossFadeFromPoseAndApplyValue=function(t,e,r,a){if(!this.cureType._supportInterpolationMode)return this.evaluateValue(t,e,!1);var o=a?this.cureType._subtractValue(this.fixedPoseValue,this.defaultValue,this.baseEvaluateData.value):this.fixedPoseValue,c=t&&t.keys.length?a?t._evaluateAdditive(e,this.crossEvaluateData):t._evaluate(e,this.crossEvaluateData):a?this.cureType._getZeroValue(this.crossEvaluateData.value):this.defaultValue;return this._lerpValue(o,c,r)},s.revertDefaultValue=function(){this._assembler.setTargetValue(this.defaultValue)},s.getEvaluateValue=function(t){return this.cureType._isCopyMode?(this.cureType._setValue(this.baseEvaluateData.value,t),t):this.baseEvaluateData.value},s.saveDefaultValue=function(){this.cureType._isCopyMode?this.cureType._setValue(this.referenceTargetValue,this.defaultValue):this.defaultValue=this._assembler.getTargetValue()},s.saveFixedPoseValue=function(){this.cureType._isCopyMode?this.cureType._setValue(this.referenceTargetValue,this.fixedPoseValue):this.fixedPoseValue=this._assembler.getTargetValue()},s.applyValue=function(t,e,r){var a=this.cureType;if(r){var o=this._assembler;if(a._isCopyMode)a._additiveValue(t,e,this.referenceTargetValue);else{var c=o.getTargetValue(),l=a._additiveValue(t,e,c);o.setTargetValue(l)}}else if(e===1)a._isCopyMode?a._setValue(t,this.referenceTargetValue):this._assembler.setTargetValue(t);else if(a._isCopyMode){var _=this.referenceTargetValue;a._lerpValue(_,t,e,_)}else{var u=this._assembler.getTargetValue(),h=a._lerpValue(u,t,e);this._assembler.setTargetValue(h)}},s._lerpValue=function(t,e,r){return this.cureType._isCopyMode?this.cureType._lerpValue(t,e,r,this.baseEvaluateData.value):(this.baseEvaluateData.value=this.cureType._lerpValue(t,e,r),this.baseEvaluateData.value)},n.registerAssembler=function(t,e,r){var a=n._assemblerMap.get(t);a||(a={},n._assemblerMap.set(t,a)),a[e]=r},n.getAssemblerType=function(t,e){var r=n._assemblerMap.get(t),a=r?r[e]:void 0;return a??Ju},n}();(function(){fn._components=[]})();(function(){fn._assemblerMap=new Map})();var Zu=function(){function n(){}var s=n.prototype;return s.initialize=function(t){this._transform=t.target.transform},s.getTargetValue=function(){return this._transform.position},s.setTargetValue=function(t){this._transform.position=t},n}();fn.registerAssembler(ge,"position",Zu);var $u=function(){function n(){}var s=n.prototype;return s.initialize=function(t){this._transform=t.target.transform},s.getTargetValue=function(){return this._transform.rotationQuaternion},s.setTargetValue=function(t){this._transform.rotationQuaternion=t},n}();fn.registerAssembler(ge,"rotationQuaternion",$u);var eh=function(){function n(){}var s=n.prototype;return s.initialize=function(t){this._transform=t.target.transform},s.getTargetValue=function(){return this._transform.scale},s.setTargetValue=function(t){this._transform.scale=t},n}();fn.registerAssembler(ge,"scale",eh);var th=function(){function n(){}var s=n.prototype;return s.initialize=function(t){this._skinnedMeshRenderer=t.component},s.getTargetValue=function(){return this._skinnedMeshRenderer.blendShapeWeights},s.setTargetValue=function(t){this._skinnedMeshRenderer.blendShapeWeights=t},n}();fn.registerAssembler(Et,"blendShapeWeights",th);var rh=function(){function n(){this.crossCurveMark=0,this.isActive=!0}var s=n.prototype;return s.initFinalValue=function(){var t=this.curveOwner,e=t.cureType,r=t.defaultValue;e._isCopyMode?e._setValue(r,this.finalValue):this.finalValue=r},s.saveFinalValue=function(){this.finalValue=this.curveOwner.getEvaluateValue(this.finalValue)},n}(),Hc=function(){function n(){this.typeIndex=0,this._tempCurveOwner={}}var s=n.prototype;return s._createCurveOwner=function(t,e){var r=this.curve.constructor,a=new fn(t,this.type,e,this.property,this.getProperty,r);return r._initializeOwner(a),a.saveDefaultValue(),a},s._createCurveLayerOwner=function(t){var e=this.curve.constructor,r=new rh;return r.curveOwner=t,e._initializeLayerOwner(r),r.initFinalValue(),r},s._getTempCurveOwner=function(t,e){var r=t.instanceId;return this._tempCurveOwner[r]||(this._tempCurveOwner[r]=this._createCurveOwner(t,e)),this._tempCurveOwner[r]},n}(),Wi=function(){},Do=function(n){W(s,n);function s(t){var e;return e=n.call(this,null)||this,e.name=t,e._curveBindings=[],e._updateFlagManager=new Dr,e._length=0,e._events=[],e}var i=s.prototype;return i.addEvent=function(e,r,a){var o;if(typeof e=="string"){var c=new Wi;c.functionName=e,c.time=r,c.parameter=a,o=c}else o=e;var l=this._events,_=l.length,u=o.time,h=_?l[_-1].time:0;if(u>=h)l.push(o);else{for(var d=_;--d>=0&&u=0;c--){var l=o[c],_=e.findByPath(l.relativePath);if(_){var u=l.typeIndex>0?_.getComponents(l.type,fn._components)[l.typeIndex]:_.getComponent(l.type);if(!u)continue;var h=l._getTempCurveOwner(_,u);if(h&&l.curve.keys.length){var d=h.evaluateValue(l.curve,r,!1);h.applyValue(d,1,!1)}}}},j(s,[{key:"events",get:function(){return this._events}},{key:"curveBindings",get:function(){return this._curveBindings}},{key:"length",get:function(){return this._length}}]),s}(Yr),xt;(function(n){n[n.Linear=0]="Linear",n[n.CubicSpine=1]="CubicSpine",n[n.Step=2]="Step",n[n.Hermite=3]="Hermite"})(xt||(xt={}));var lr=function(){function n(){this.keys=[],this._evaluateData={curKeyframeIndex:0,value:null},this._length=0;var i=this.constructor;this._interpolation=i._supportInterpolationMode?xt.Linear:xt.Step,this._type=i}var s=n.prototype;return s.addKey=function(t){var e=t.time,r=this.keys;if(e>=this._length)r.push(t),this._length=e;else{for(var a=r.length;--a>=0&&e=0;a--){var o=e[a];o.time>this._length&&(r=o.time)}this._length=r},s._evaluate=function(t,e){var r=this.keys.length;if(!r){console.warn("This curve don't have any keyframes: ",this);return}var a=this,o=a.keys,c=a.interpolation,l=e.curKeyframeIndex;l!==-1&&(l>=r||ta&&(r=r<0?-a:a,this.playState=pt.Finished),t&&r===0?this.clipTime=e.clipEndTime*e.clip.length:(r<0&&(r+=a),this.clipTime=r+e.clipStartTime*e.clip.length)},n}(),ah=function(){function n(){this.curveOwnerPool=Object.create(null),this.animatorStateDataMap={},this.srcPlayData=new ls,this.destPlayData=new ls,this.layerState=Ye.Standby,this.crossCurveMark=0,this.manuallyTransition=new Lo,this.crossLayerOwnerCollection=[]}var s=n.prototype;return s.switchPlayData=function(){var t=this.destPlayData,e=this.srcPlayData;this.srcPlayData=t,this.destPlayData=e},n}(),ih=function(){this.curveLayerOwner=[],this.eventHandlers=[]},Kr=function(n){W(s,n);function s(t){var e;return e=n.call(this,t)||this,e.cullingMode=Na.None,e.speed=1,e._playFrameCount=-1,e._onUpdateIndex=-1,e._updateMark=0,e._animatorLayersData=[],e._curveOwnerPool=Object.create(null),e._animationEventHandlerPool=new Vn(nh),e._tempAnimatorStateInfo={layerIndex:-1,state:null},e._controlledRenderers=[],e}var i=s.prototype;return i.play=function(e,r,a){r===void 0&&(r=-1),a===void 0&&(a=0);var o;(o=this._controllerUpdateFlag)!=null&&o.flag&&this._reset(),this._playFrameCount=this.engine.time.frameCount;var c=this._getAnimatorStateInfo(e,r),l=c.state,_=c.layerIndex;if(l){if(!l.clip){ve.warn("The state named "+e+" has no AnimationClip data.");return}var u=this._getAnimatorLayerData(_),h=this._getAnimatorStateData(e,l,u,_);this._preparePlay(u,l),u.layerState=Ye.Playing,u.srcPlayData.reset(l,h,l._getDuration()*a),this.update(0)}},i.crossFade=function(e,r,a,o){a===void 0&&(a=-1),o===void 0&&(o=0);var c;(c=this._controllerUpdateFlag)!=null&&c.flag&&this._reset(),this._playFrameCount=this.engine.time.frameCount;var l=this._getAnimatorStateInfo(e,a),_=l.state,u=l.layerIndex,h=this._getAnimatorLayerData(u).manuallyTransition;h.duration=r,h.offset=o,h.destinationState=_,this._crossFadeByTransition(h,u)&&this.update(0)},i.update=function(e){var r,a;if(this.cullingMode===Na.Complete){a=!1;for(var o=this._controlledRenderers,c=0,l=o.length;c=0;p--){var g=f[p],y=g.relativePath,m=g.relativePath===""?l:l.findByPath(g.relativePath);if(m){var x,C,b,A,S,w,E,B,M=g.typeIndex>0?m.getComponents(g.type,fn._components)[g.typeIndex]:m.getComponent(g.type);if(!M)continue;var D=g.property,L=M.instanceId,V=(x=_)[C=L]||(x[C]=Object.create(null)),N=(b=V)[A=D]||(b[A]=g._createCurveOwner(m,M)),I=(S=v)[w=L]||(S[w]=Object.create(null)),P=(E=I)[B=D]||(E[B]=g._createCurveLayerOwner(N));if(u&&u.pathMasks.length){var z,U;P.isActive=(U=(z=u.getPathMask(y))==null?void 0:z.active)!=null?U:!0}h[p]=P}else h[p]=null,ve.warn("The entity don't have the child entity which path is "+g.relativePath+".")}},i._saveAnimatorEventHandlers=function(e,r){var a=this,o=this._animationEventHandlerPool,c=[],l=r.eventHandlers,_=function(){a._entity.getComponents(Or,c);var u=c.length,h=e.clip.events;l.length=0;for(var d=0,f=h.length;d=0;m--){var x=c[m][g];x&&y.push(x)}l.push(p)}};_(),e._updateFlagManager.addListener(_)},i._clearCrossData=function(e){e.crossCurveMark++,e.crossLayerOwnerCollection.length=0},i._addCrossOwner=function(e,r,a,o){r.crossSrcCurveIndex=a,r.crossDestCurveIndex=o,e.crossLayerOwnerCollection.push(r)},i._prepareCrossFading=function(e){this._prepareSrcCrossData(e,!1),this._prepareDestCrossData(e,!1)},i._prepareStandbyCrossFading=function(e){e.srcPlayData.state&&this._prepareSrcCrossData(e,!0),this._prepareDestCrossData(e,!0)},i._prepareFixedPoseCrossFading=function(e){for(var r=e.crossLayerOwnerCollection,a=r.length-1;a>=0;a--){var o=r[a];o&&(o.curveOwner.saveFixedPoseValue(),o.crossDestCurveIndex=-1)}this._prepareDestCrossData(e,!0)},i._prepareSrcCrossData=function(e,r){for(var a=e.srcPlayData.stateData.curveLayerOwner,o=a.length-1;o>=0;o--){var c=a[o];c&&(c.crossCurveMark=e.crossCurveMark,r&&c.curveOwner.saveFixedPoseValue(),this._addCrossOwner(e,c,o,-1))}},i._prepareDestCrossData=function(e,r){for(var a=e.destPlayData.stateData.curveLayerOwner,o=a.length-1;o>=0;o--){var c=a[o];if(c)if(c.crossCurveMark===e.crossCurveMark)c.crossDestCurveIndex=o;else{var l=c.curveOwner;r&&l.saveFixedPoseValue(),c.crossCurveMark=e.crossCurveMark,this._addCrossOwner(e,c,-1,o)}}},i._getAnimatorLayerData=function(e){var r=this._animatorLayersData[e];return r||(this._animatorLayersData[e]=r=new ah),r},i._updateLayer=function(e,r,a,o){var c=this._animatorController.layers[e],l=c.blendingMode,_=c.weight,u=this._animatorLayersData[e],h=u.srcPlayData,d=u.destPlayData,f=l===Ia.Additive;switch(r&&(_=1),u.layerState){case Ye.Playing:this._updatePlayingState(h,u,e,_,a,f,o);break;case Ye.FixedCrossFading:this._updateCrossFadeFromPose(d,u,e,_,a,f,o);break;case Ye.CrossFading:this._updateCrossFade(h,d,u,e,_,a,f,o);break;case Ye.Finished:this._updateFinishedState(h,_,f,o);break}},i._updatePlayingState=function(e,r,a,o,c,l,_){var u=e.stateData,h=u.curveLayerOwner,d=u.eventHandlers,f=e.state,v=e.playState,p=e.clipTime,g=f.transitions,y=f.clip,m=y._curveBindings,x=f.speed*this.speed;e.frameTime+=x*c,e.update(x<0);var C=e.clipTime,b=e.playState,A=b===pt.Finished;if(_||A)for(var S=m.length-1;S>=0;S--){var w,E=h[S],B=(w=E)==null?void 0:w.curveOwner;if(!(!B||!E.isActive)){var M=m[S].curve;if(M.keys.length){this._checkRevertOwner(B,l);var D=B.evaluateValue(M,C,l);_&&B.applyValue(D,o,l),A&&E.saveFinalValue()}}}if(b===pt.Finished&&(r.layerState=Ye.Finished),d.length&&this._fireAnimationEvents(e,d,p,C),v===pt.UnStarted&&this._callAnimatorScriptOnEnter(f,a),b===pt.Finished?this._callAnimatorScriptOnExit(f,a):this._callAnimatorScriptOnUpdate(f,a),g.length){var L=r.layerState;L!==Ye.CrossFading&&L!==Ye.FixedCrossFading&&this._checkTransition(e,g,a,p,C)}},i._updateCrossFade=function(e,r,a,o,c,l,_,u){var h=this.speed,d=a.crossLayerOwnerCollection,f=e.state.clip,v=f._curveBindings,p=e.state,g=e.stateData,y=e.playState,m=g.eventHandlers,x=r.state,C=r.stateData,b=r.playState,A=C.eventHandlers,S=x.clip,w=S._curveBindings,E=e.clipTime,B=r.clipTime,M=x._getDuration()*a.crossFadeTransition.duration,D=Math.abs(r.frameTime)/M;(D>=1||M===0)&&(D=1);var L=p.speed*h,V=x.speed*h;e.frameTime+=L*l,r.frameTime+=V*l,e.update(L<0),r.update(V<0);var N=e.clipTime,I=e.playState,P=r.clipTime,z=r.playState,U=r.playState===pt.Finished;if(u||U)for(var Y=d.length-1;Y>=0;Y--){var Q,H=d[Y],te=(Q=H)==null?void 0:Q.curveOwner;if(te){var Ce=H.crossSrcCurveIndex,de=H.crossDestCurveIndex;this._checkRevertOwner(te,_);var ae=te.evaluateCrossFadeValue(Ce>=0?v[Ce].curve:null,de>=0?w[de].curve:null,N,P,D,_);u&&te.applyValue(ae,c,_),U&&H.saveFinalValue()}}this._updateCrossFadeData(a,D),m.length&&this._fireAnimationEvents(e,m,E,N),A.length&&this._fireAnimationEvents(r,A,B,P),y===pt.UnStarted&&this._callAnimatorScriptOnEnter(p,o),D===1||I===pt.Finished?this._callAnimatorScriptOnExit(p,o):this._callAnimatorScriptOnUpdate(p,o),b===pt.UnStarted&&this._callAnimatorScriptOnEnter(x,o),z===pt.Finished?this._callAnimatorScriptOnExit(x,o):this._callAnimatorScriptOnUpdate(x,o)},i._updateCrossFadeFromPose=function(e,r,a,o,c,l,_){var u=r.crossLayerOwnerCollection,h=e.state,d=e.stateData,f=e.playState,v=d.eventHandlers,p=h.clip,g=p._curveBindings,y=e.clipTime,m=h._getDuration()*r.crossFadeTransition.duration,x=Math.abs(e.frameTime)/m;(x>=1||m===0)&&(x=1);var C=h.speed*this.speed;e.frameTime+=C*c,e.update(C<0);var b=e.clipTime,A=e.playState,S=A===pt.Finished;if(_||S)for(var w=u.length-1;w>=0;w--){var E,B=u[w],M=(E=B)==null?void 0:E.curveOwner;if(M){var D=B.crossDestCurveIndex;this._checkRevertOwner(M,l);var L=B.curveOwner.crossFadeFromPoseAndApplyValue(D>=0?g[D].curve:null,b,x,l);_&&M.applyValue(L,o,l),S&&B.saveFinalValue()}}this._updateCrossFadeData(r,x),v.length&&this._fireAnimationEvents(e,v,y,b),f===pt.UnStarted&&this._callAnimatorScriptOnEnter(h,a),A===pt.Finished?this._callAnimatorScriptOnExit(h,a):this._callAnimatorScriptOnUpdate(h,a)},i._updateFinishedState=function(e,r,a,o){if(o)for(var c=e.stateData.curveLayerOwner,l=e.state.clip,_=l._curveBindings,u=_.length-1;u>=0;u--){var h,d=c[u],f=(h=d)==null?void 0:h.curveOwner;f&&(this._checkRevertOwner(f,a),f.applyValue(d.finalValue,r,a))}},i._updateCrossFadeData=function(e,r){var a=e.destPlayData;r===1&&(a.playState===pt.Finished?e.layerState=Ye.Finished:e.layerState=Ye.Playing,e.switchPlayData(),e.crossFadeTransition=null)},i._preparePlay=function(e,r){if(e.layerState===Ye.Playing){var a=e.srcPlayData;if(a.state!==r)for(var o=a.stateData.curveLayerOwner,c=o.length-1;c>=0;c--){var l;(l=o[c])==null||l.curveOwner.revertDefaultValue()}}else for(var _=e.crossLayerOwnerCollection,u=_.length-1;u>=0;u--)_[u].curveOwner.revertDefaultValue()},i._checkTransition=function(e,r,a,o,c){var l=e.state,_=l.clip.length;this.speed*l.speed>=0?co?(this._checkBackwardsSubTransition(e,r,a,o,l.clipStartTime*_),e.currentTransitionIndex=r.length-1,this._checkBackwardsSubTransition(e,r,a,c,l.clipEndTime*_)):this._checkBackwardsSubTransition(e,r,a,o,c)},i._checkSubTransition=function(e,r,a,o,c){for(var l=e.currentTransitionIndex,_=e.state._getDuration(),u=r.length;lc)break;d>=o&&(this._crossFadeByTransition(h,a),e.currentTransitionIndex=Math.min(l+1,u-1))}},i._checkBackwardsSubTransition=function(e,r,a,o,c){for(var l=e.currentTransitionIndex,_=e.state._getDuration();l>=0;l--){var u=r[l],h=u.exitTime*_;if(h=0?oa?(this._fireBackwardSubAnimationEvents(e,r,a,c.clipStartTime*l),e.currentEventIndex=r.length-1,this._fireBackwardSubAnimationEvents(e,r,c.clipEndTime*l,o)):this._fireBackwardSubAnimationEvents(e,r,a,o)},i._fireSubAnimationEvents=function(e,r,a,o){for(var c=e.currentEventIndex,l=r.length;co)break;var f=_.handlers;if(h>=a){for(var v=f.length-1;v>=0;v--)f[v](d);e.currentEventIndex=Math.min(c+1,l-1)}}},i._fireBackwardSubAnimationEvents=function(e,r,a,o){for(var c=e.currentEventIndex;c>=0;c--){var l=r[c],_=l.event,u=_.time,h=_.parameter;if(u=0;f--)d[f](h);e.currentEventIndex=Math.max(c-1,0)}}},i._callAnimatorScriptOnEnter=function(e,r){for(var a=e._onStateEnterScripts,o=0,c=a.length;o=o)e.push(t);else{for(var c=r;--c>=0&&a-1&&this.states.splice(r,1),delete this._statesMap[e]},s.findStateByName=function(t){return this._statesMap[t]},s.makeUniqueStateName=function(t){for(var e=this._statesMap,r=t,a=0;e[t];)t=r+" "+a,a++;return t},n}(),uo;(function(n){n[n.If=0]="If",n[n.IfNot=1]="IfNot",n[n.Greater=2]="Greater",n[n.Less=3]="Less",n[n.Equals=4]="Equals",n[n.NotEquals=5]="NotEquals"})(uo||(uo={}));var Ft=function(){},oh=function(){},sh=function(){function n(){this._pathMasks=[],this._pathMaskMap={}}var s=n.prototype;return s.addPathMask=function(t){var e=this._pathMaskMap[t];if(e)return e;var r=new oh;return r.path=t,r.active=!0,this._pathMasks.push(r),this._pathMaskMap[t]=r,r},s.removePathMask=function(t){for(var e=this,r=e._pathMasks,a=0,o=this._pathMasks.length;a=o)t.push(e);else{for(var c=a;--c>=0&&r=0&&e.time0)for(var a=this._generator,o=1/r,c=e-this._frameRateTime;c>=o;)c-=o,this._frameRateTime+=o,a._emit(this._frameRateTime,1)},i._emitByBurst=function(e,r){var a=this._generator.main,o=a.duration,c=Math.floor((r-e)/o);if(a.isLoop&&(c>0||r%oh)break;if(p>=u){var g=v.count.evaluate(void 0,c.random());o._emit(_+p,g)}}this._currentBurstIndex=d},j(s,[{key:"bursts",get:function(){return this._bursts}}]),s}(Kn);T([J],Mn.prototype,"rateOverTime",void 0);T([J],Mn.prototype,"rateOverDistance",void 0);T([J],Mn.prototype,"shape",void 0);T([F],Mn.prototype,"_shapeRand",void 0);T([J],Mn.prototype,"_bursts",void 0);T([F],Mn.prototype,"_burstRand",void 0);var Ur;(function(n){n[n.Hierarchy=0]="Hierarchy",n[n.Local=1]="Local",n[n.World=2]="World"})(Ur||(Ur={}));var De=function(){function n(i){this.duration=5,this.isLoop=!0,this.startDelay=new Oe(0),this.startLifetime=new Oe(5),this.startSpeed=new Oe(5),this.startSize3D=!1,this.startSizeX=new Oe(1),this.startSizeY=new Oe(1),this.startSizeZ=new Oe(1),this.startRotation3D=!1,this.startRotationX=new Oe(0),this.startRotationY=new Oe(0),this.startRotationZ=new Oe(0),this.flipRotation=0,this.startColor=new Qn(new q(1,1,1,1)),this.gravityModifier=new Oe(0),this.simulationSpace=ln.Local,this.simulationSpeed=1,this.scalingMode=Ur.Local,this.playOnEnabled=!0,this._maxParticleBuffer=1e3,this._startSpeedRand=new gr(0,Ge.StartSpeed),this._startLifeTimeRand=new gr(0,Ge.StartLifetime),this._startColorRand=new gr(0,Ge.StartColor),this._startSizeRand=new gr(0,Ge.StartSize),this._startRotationRand=new gr(0,Ge.StartRotation),this._gravityModifierRand=new gr(0,Ge.GravityModifier),this._gravity=new R,this._generator=i}var s=n.prototype;return s._resetRandomSeed=function(t){this._startSpeedRand.reset(t,Ge.StartSpeed),this._startLifeTimeRand.reset(t,Ge.StartLifetime),this._startColorRand.reset(t,Ge.StartColor),this._startSizeRand.reset(t,Ge.StartSize),this._startRotationRand.reset(t,Ge.StartRotation)},s._getPositionScale=function(){var t=this._generator._renderer.entity.transform;switch(this.scalingMode){case Ur.Hierarchy:case Ur.World:return t.lossyWorldScale;case Ur.Local:return t.scale}},s._updateShaderData=function(t){var e=this._generator._renderer,r=e.entity.transform;switch(this.simulationSpace){case ln.Local:t.setVector3(n._worldPosition,r.worldPosition);var a=r.worldRotationQuaternion,o=n._tempVector40;o.copyFrom(a),t.setVector4(n._worldRotation,o);break;case ln.World:break;default:throw new Error("ParticleRenderer: SimulationSpace value is invalid.")}switch(this.scalingMode){case Ur.Hierarchy:var c=r.lossyWorldScale;t.setVector3(n._positionScale,c),t.setVector3(n._sizeScale,c);break;case Ur.Local:var c=r.scale;t.setVector3(n._positionScale,c),t.setVector3(n._sizeScale,c);break;case Ur.World:t.setVector3(n._positionScale,r.lossyWorldScale),t.setVector3(n._sizeScale,n._vector3One);break}var l=this._gravity,_=this.gravityModifier.evaluate(void 0,this._gravityModifierRand.random());R.scale(e.scene.physics.gravity,_,l),t.setVector3(n._gravity,l),t.setInt(n._simulationSpace,this.simulationSpace),t.setFloat(n._startRotation3D,+this.startRotation3D),t.setInt(n._scaleMode,this.scalingMode)},s._cloneTo=function(t){t.maxParticles=this.maxParticles},j(n,[{key:"maxParticles",get:function(){return this._maxParticleBuffer-1},set:function(t){this._maxParticleBuffer=t+1}},{key:"startSize",get:function(){return this.startSizeX},set:function(t){this.startSizeX=t}}]),n}();(function(){De._tempVector40=new ie})();(function(){De._vector3One=new R(1,1,1)})();(function(){De._positionScale=O.getByName("renderer_PositionScale")})();(function(){De._sizeScale=O.getByName("renderer_SizeScale")})();(function(){De._worldPosition=O.getByName("renderer_WorldPosition")})();(function(){De._worldRotation=O.getByName("renderer_WorldRotation")})();(function(){De._gravity=O.getByName("renderer_Gravity")})();(function(){De._simulationSpace=O.getByName("renderer_SimulationSpace")})();(function(){De._startRotation3D=O.getByName("renderer_ThreeDStartRotation")})();(function(){De._scaleMode=O.getByName("renderer_ScalingMode")})();T([J],De.prototype,"startDelay",void 0);T([J],De.prototype,"startLifetime",void 0);T([J],De.prototype,"startSpeed",void 0);T([J],De.prototype,"startSizeX",void 0);T([J],De.prototype,"startSizeY",void 0);T([J],De.prototype,"startSizeZ",void 0);T([J],De.prototype,"startRotationX",void 0);T([J],De.prototype,"startRotationY",void 0);T([J],De.prototype,"startRotationZ",void 0);T([J],De.prototype,"startColor",void 0);T([J],De.prototype,"gravityModifier",void 0);T([F],De.prototype,"_maxParticleBuffer",void 0);T([F],De.prototype,"_startSpeedRand",void 0);T([F],De.prototype,"_startLifeTimeRand",void 0);T([F],De.prototype,"_startColorRand",void 0);T([F],De.prototype,"_startSizeRand",void 0);T([F],De.prototype,"_startRotationRand",void 0);T([F],De.prototype,"_gravityModifierRand",void 0);T([F],De.prototype,"_generator",void 0);T([F],De.prototype,"_gravity",void 0);var Ze=function(n){W(s,n);function s(){var t;return t=n.apply(this,arguments)||this,t.separateAxes=!1,t.rotationX=new Oe(0),t.rotationY=new Oe(0),t.rotationZ=new Oe(45),t._rotationRand=new gr(0,Ge.RotationOverLifetime),t._rotationMinConstant=new R,t._rotationMaxConstant=new R,t}var i=s.prototype;return i._updateShaderData=function(e){var r=null,a=null,o=null;if(this.enabled){var c=this.rotationX,l=this.rotationY,_=this.rotationZ,u=this.separateAxes,h=u?c.mode===he.TwoCurves&&l.mode===he.TwoCurves&&_.mode===he.TwoCurves:_.mode===he.TwoCurves,d=h||u?c.mode===he.Curve&&l.mode===he.Curve&&_.mode===he.Curve:_.mode===he.Curve;if(d)e.setFloatArray(s._maxCurveZProperty,_.curveMax._getTypeArray()),u&&(e.setFloatArray(s._maxCurveXProperty,c.curveMax._getTypeArray()),e.setFloatArray(s._maxCurveYProperty,l.curveMax._getTypeArray())),h&&(e.setFloatArray(s._minCurveZProperty,_.curveMin._getTypeArray()),u&&(e.setFloatArray(s._minCurveXProperty,c.curveMin._getTypeArray()),e.setFloatArray(s._minCurveYProperty,l.curveMin._getTypeArray())),o=s._isRandomTwoMacro),a=s._curveModeMacro;else{var f=this._rotationMaxConstant;if(f.set(k.degreeToRadian(c.constantMax),k.degreeToRadian(l.constantMax),k.degreeToRadian(_.constantMax)),e.setVector3(s._maxConstantProperty,f),u?c.mode===he.TwoConstants&&l.mode===he.TwoConstants&&_.mode===he.TwoConstants:_.mode===he.TwoConstants){var v=this._rotationMinConstant;v.set(k.degreeToRadian(c.constantMin),k.degreeToRadian(l.constantMin),k.degreeToRadian(_.constantMin)),e.setVector3(s._minConstantProperty,v),o=s._isRandomTwoMacro}a=s._constantModeMacro}u&&(r=s._isSeparateMacro)}this._enableSeparateMacro=this._enableMacro(e,this._enableSeparateMacro,r),this._isCurveMacro=this._enableMacro(e,this._isCurveMacro,a),this._isRandomTwoMacro=this._enableMacro(e,this._isRandomTwoMacro,o)},i._resetRandomSeed=function(e){this._rotationRand.reset(e,Ge.RotationOverLifetime)},s}(Kn);(function(){Ze._constantModeMacro=oe.getByName("RENDERER_ROL_CONSTANT_MODE")})();(function(){Ze._curveModeMacro=oe.getByName("RENDERER_ROL_CURVE_MODE")})();(function(){Ze._isSeparateMacro=oe.getByName("RENDERER_ROL_IS_SEPARATE")})();(function(){Ze._isRandomTwoMacro=oe.getByName("RENDERER_ROL_IS_RANDOM_TWO")})();(function(){Ze._minConstantProperty=O.getByName("renderer_ROLMinConst")})();(function(){Ze._minCurveXProperty=O.getByName("renderer_ROLMinCurveX")})();(function(){Ze._minCurveYProperty=O.getByName("renderer_ROLMinCurveY")})();(function(){Ze._minCurveZProperty=O.getByName("renderer_ROLMinCurveZ")})();(function(){Ze._maxConstantProperty=O.getByName("renderer_ROLMaxConst")})();(function(){Ze._maxCurveXProperty=O.getByName("renderer_ROLMaxCurveX")})();(function(){Ze._maxCurveYProperty=O.getByName("renderer_ROLMaxCurveY")})();(function(){Ze._maxCurveZProperty=O.getByName("renderer_ROLMaxCurveZ")})();T([J],Ze.prototype,"rotationX",void 0);T([J],Ze.prototype,"rotationY",void 0);T([J],Ze.prototype,"rotationZ",void 0);T([F],Ze.prototype,"_rotationRand",void 0);T([F],Ze.prototype,"_rotationMinConstant",void 0);T([F],Ze.prototype,"_rotationMaxConstant",void 0);T([F],Ze.prototype,"_enableSeparateMacro",void 0);T([F],Ze.prototype,"_isCurveMacro",void 0);T([F],Ze.prototype,"_isRandomTwoMacro",void 0);var Un=function(){function n(){for(var i=arguments.length,t=new Array(i),e=0;e=o)t.push(e);else{for(var c=r;--c>=0&&ar._maxParticleBuffer){var l=this._getNotRetiredParticleCount();lo&&(this._isPlaying=!1)}if(!this.isAlive){var _=Math.min(a._frameRateTime,Math.floor(this._playTime/o)*o);this._playTime-=_,a._frameRateTime-=_}(this._firstNewElement!=this._firstFreeElement||this._waitProcessRetiredElementCount>0||this._instanceBufferResized||this._instanceVertexBufferBinding._buffer.isContentLost)&&this._addActiveParticlesToVertexBuffer()},s._reorganizeGeometryBuffers=function(){var t=this._renderer,e=t.engine._particleBufferUtils,r=this._primitive,a=this._vertexBufferBindings;if(r.clearVertexElements(),a.length=0,t.renderMode===pr.Mesh){var o=t.mesh;if(!o)return;var c=o.getVertexElement(X.Position),l=o.getVertexElement(X.Color),_=o.getVertexElement(X.UV),u=c?o.vertexBufferBindings[c.bindingIndex]:null,h=l?o.vertexBufferBindings[l.bindingIndex]:null,d=_?o.vertexBufferBindings[_.bindingIndex]:null;if(u){var f=this._addVertexBufferBindingsFilterDuplicate(u,a);r.addVertexElement(new Te(X.Position,c.offset,c.format,f))}if(h){var v=this._addVertexBufferBindingsFilterDuplicate(h,a);r.addVertexElement(new Te(X.Color,l.offset,l.format,v))}if(d){var p=this._addVertexBufferBindingsFilterDuplicate(d,a);r.addVertexElement(new Te(X.UV,_.offset,_.format,p))}var g=o._primitive.indexBufferBinding;r.setIndexBufferBinding(g),this._subPrimitive.count=g.buffer.byteLength/r._glIndexByteCount}else r.addVertexElement(e.billboardVertexElement),a.push(e.billboardVertexBufferBinding),r.setIndexBufferBinding(e.billboardIndexBufferBinding),this._subPrimitive.count=e.billboardIndexCount;r.setVertexBufferBindings(a);for(var y=e.instanceVertexElements,m=a.length,x=0,C=y.length;xg&&(this._firstNewElement+=e),this._firstActiveElement>g&&(this._firstActiveElement+=e),y>g&&(this._firstRetiredElement+=e)}else{var C,b;y<=g?(C=g-y,b=0,this._firstFreeElement-=y,this._firstNewElement-=y,this._firstActiveElement-=y,this._firstRetiredElement=0):(C=this._currentParticleCount-y,b=g,this._firstNewElement>g&&(this._firstNewElement-=g),this._firstActiveElement>g&&(this._firstActiveElement-=g),y>g&&(this._firstRetiredElement-=g)),f.set(new Float32Array(v.buffer,y*p*4,C*p),b*p)}this._instanceBufferResized=!0}this._primitive.setVertexBufferBinding(v?h.length-1:h.length,d),this._instanceVertices=f,this._instanceVertexBufferBinding=d,this._currentParticleCount=c},s._updateShaderData=function(t){this.main._updateShaderData(t),this.velocityOverLifetime._updateShaderData(t),this.textureSheetAnimation._updateShaderData(t),this.sizeOverLifetime._updateShaderData(t),this.rotationOverLifetime._updateShaderData(t),this.colorOverLifetime._updateShaderData(t)},s._resetGlobalRandSeed=function(t){this._randomSeed=t,this.main._resetRandomSeed(t),this.emission._resetRandomSeed(t),this.textureSheetAnimation._resetRandomSeed(t),this.velocityOverLifetime._resetRandomSeed(t),this.rotationOverLifetime._resetRandomSeed(t),this.colorOverLifetime._resetRandomSeed(t)},s._getAliveParticleCount=function(){if(this._firstActiveElement<=this._firstFreeElement)return this._firstFreeElement-this._firstActiveElement;var t=this._currentParticleCount-this._firstActiveElement;return this._firstFreeElement>0&&(t+=this._firstFreeElement),t},s._getNotRetiredParticleCount=function(){if(this._firstRetiredElement<=this._firstFreeElement)return this._firstFreeElement-this._firstRetiredElement;var t=this._currentParticleCount-this._firstRetiredElement;return this._firstFreeElement>0&&(t+=this._firstFreeElement),t},s._destroy=function(){this._instanceVertexBufferBinding.buffer.destroy(),this._primitive.destroy()},s._addNewParticle=function(t,e,r,a){var o=this._firstFreeElement,c=o+1;c>=this._currentParticleCount&&(c=0);var l=this.main;if(c===this._firstRetiredElement){var _=Math.min(n._particleIncreaseCount,l._maxParticleBuffer-this._currentParticleCount);if(_===0)return;this._resizeInstanceBuffer(!0,_),c=o+1}var u,h;l.simulationSpace===ln.World&&(u=r.worldPosition,h=r.worldRotationQuaternion);var d=this._renderer.engine._particleBufferUtils,f=l.startSpeed.evaluate(void 0,l._startSpeedRand.random()),v=this._instanceVertices,p=o*d.instanceVertexFloatStride;v[p]=t.x,v[p+1]=t.y,v[p+2]=t.z,v[p+d.startLifeTimeOffset]=l.startLifetime.evaluate(void 0,l._startLifeTimeRand.random()),v[p+4]=e.x,v[p+5]=e.y,v[p+6]=e.z,v[p+d.timeOffset]=a;var g=n._tempColor0;l.startColor.evaluate(void 0,l._startColorRand.random(),g),this._renderer.engine.settings.colorSpace===ir.Linear&&g.toLinear(g),v[p+8]=g.r,v[p+9]=g.g,v[p+10]=g.b,v[p+11]=g.a;var y=l._startSizeRand;if(l.startSize3D)v[p+12]=l.startSizeX.evaluate(void 0,y.random()),v[p+13]=l.startSizeY.evaluate(void 0,y.random()),v[p+14]=l.startSizeZ.evaluate(void 0,y.random());else{var m=l.startSize.evaluate(void 0,y.random());v[p+12]=m,v[p+13]=m,v[p+14]=m}var x=l._startRotationRand;l.startRotation3D?(v[p+15]=k.degreeToRadian(l.startRotationX.evaluate(void 0,x.random())),v[p+16]=k.degreeToRadian(l.startRotationY.evaluate(void 0,x.random())),v[p+17]=k.degreeToRadian(l.startRotationZ.evaluate(void 0,x.random()))):v[p+15]=k.degreeToRadian(l.startRotationZ.evaluate(void 0,x.random())),v[p+18]=f;var C=this.colorOverLifetime;C.enabled&&C.color.mode===Xt.TwoGradients&&(v[p+20]=C._colorGradientRand.random());var b=this.rotationOverLifetime;b.enabled&&b.rotationZ.mode===he.TwoConstants&&(v[p+22]=b._rotationRand.random());var A=this.textureSheetAnimation;A.enabled&&A.frameOverTime.mode===he.TwoCurves&&(v[p+23]=A._frameOverTimeRand.random());var S=this.velocityOverLifetime;if(S.enabled&&S.velocityX.mode===he.TwoConstants&&S.velocityY.mode===he.TwoConstants&&S.velocityZ.mode===he.TwoConstants){var w=S._velocityRand;v[p+24]=w.random(),v[p+25]=w.random(),v[p+26]=w.random()}if(this.main.simulationSpace===ln.World&&(v[p+27]=u.x,v[p+28]=u.y,v[p+29]=u.z,v[p+30]=h.x,v[p+31]=h.y,v[p+32]=h.z,v[p+33]=h.w),this.textureSheetAnimation.enabled){var E=this.textureSheetAnimation._tillingInfo;v[p+d.simulationUVOffset]=E.x,v[p+35]=E.y,v[p+36]=0,v[p+37]=0}else v[p+d.simulationUVOffset]=1,v[p+35]=1,v[p+36]=0,v[p+37]=0;this._firstFreeElement=c},s._retireActiveParticles=function(){for(var t=this._renderer.engine,e=t._particleBufferUtils,r=t.time.frameCount,a=this._instanceVertices;this._firstActiveElement!==this._firstNewElement;){var o=this._firstActiveElement*e.instanceVertexFloatStride,c=o+e.timeOffset,l=this._playTime-a[c];if(Math.fround(l)=this._currentParticleCount&&(this._firstActiveElement=0),this._waitProcessRetiredElementCount++}},s._freeRetiredParticles=function(){for(var t=this._renderer.engine._particleBufferUtils,e=this._renderer.engine.time.frameCount;this._firstRetiredElement!==this._firstActiveElement;){var r=this._firstRetiredElement*t.instanceVertexFloatStride+t.startLifeTimeOffset,a=e-this._instanceVertices[r];if(a<0)break;++this._firstRetiredElement>=this._currentParticleCount&&(this._firstRetiredElement=0)}},s._addActiveParticlesToVertexBuffer=function(){var t=this._firstActiveElement,e=this._firstFreeElement;if(t!==e){var r=this._renderer.engine._particleBufferUtils.instanceVertexStride,a=t*r,o=this._instanceVertexBufferBinding.buffer,c=this._instanceVertices.buffer;if(t0&&o.setData(c,l,0,e*r)}this._firstNewElement=e,this._waitProcessRetiredElementCount=0,this._instanceBufferResized=!1}},s._addVertexBufferBindingsFilterDuplicate=function(t,e){for(var r=0,a=e.length;r0&&(a.z=-c),Sr._randomPointUnitSphere(o,e),R.lerp(a,o,this.randomDirectionAmount,o)},s}(Ha),uh=function(n){W(s,n);function s(){var t;return t=n.apply(this,arguments)||this,t.shapeType=wn.Sphere,t.radius=1,t}var i=s.prototype;return i._generatePositionAndDirection=function(e,r,a,o){Sr._randomPointInsideUnitSphere(a,e),a.scale(this.radius),Sr._randomPointUnitSphere(o,e),R.lerp(a,o,this.randomDirectionAmount,o)},s}(Ha),hh=`#define GLSLIFY 1 -varying vec2 v_uv;uniform sampler2D u_texture;void main(void){gl_FragColor=texture2D(u_texture,v_uv);}`,dh=`#define GLSLIFY 1 -attribute vec3 POSITION;attribute vec2 TEXCOORD_0;varying vec2 v_uv;uniform mat4 camera_ProjMat;uniform mat4 camera_ViewMat;void main(){gl_Position=camera_ProjMat*camera_ViewMat*vec4(POSITION,1.0);v_uv=TEXCOORD_0;}`;Se.create("trail",dh,hh);var qc=function(n){W(s,n);function s(i){var t;t=n.call(this,i,Se.find("trail"))||this;var e=t.renderState.blendState.targetBlendState;return e.enabled=!0,e.sourceColorBlendFactor=e.sourceAlphaBlendFactor=be.SourceAlpha,e.destinationColorBlendFactor=e.destinationAlphaBlendFactor=be.One,t.renderState.depthState.writeEnabled=!1,t}return s}(br),us=new R,fh=function(n){W(s,n);function s(t,e){var r;r=n.call(this,t)||this,r._stroke=e.stroke||.2,r._minSeg=e.minSeg||.02,r._lifetime=e.lifetime||1e3,r._maxPointNum=r._lifetime/1e3*t.engine.targetFrameRate,r._points=[],r._pointStates=[],r._strapPoints=[];for(var a=0;a0&&(a=o-r,this._pointStates[a]=this._pointStates[o],this._points[a].copyFrom(this._points[o]));this._curPointNum-=r;var c=!0;if(this._curPointNum===this._maxPointNum)c=!1;else if(this._curPointNum>0){var l=this._points[this._points.length-1];R.distance(this.entity.transform.worldPosition,l)"u"||!ar(r,OffscreenCanvas)){var a=r.clientWidth*e,o=r.clientHeight*e;this.width=a,this.height=o}},i.setScale=function(e,r){this._scale.set(e,r),this.scale=this._scale},i._onWidthChanged=function(e){this._webCanvas.width=e},i._onHeightChange=function(e){this._webCanvas.height=e},Xa(s,[{key:"scale",get:function(){var e=this._webCanvas;return(typeof OffscreenCanvas>"u"||!ar(e,OffscreenCanvas))&&this._scale.set(e.clientWidth*devicePixelRatio/e.width,e.clientHeight*devicePixelRatio/e.height),this._scale},set:function(e){var r=this._webCanvas;(typeof OffscreenCanvas>"u"||!ar(r,OffscreenCanvas))&&(r.style.transformOrigin="left top",r.style.transform="scale("+e.x+", "+e.y+")")}}]),s}(Oc),id=function(n){ja(s,n);function s(){return n.apply(this,arguments)}return s.create=function(t){var e=t.canvas,r=new gh(typeof e=="string"?document.getElementById(e):e),a=new Th(t.graphicDeviceOptions),o=new s(r,a,t),c=o._initialize(t);return c.then(function(){return o.sceneManager.addScene(new Ga(o,"DefaultScene")),o})},Xa(s,[{key:"canvas",get:function(){return this._canvas}}]),s}(hn);function Bi(){return Bi=Object.assign||function(s){for(var i=1;i=e&&r<=r||t>=a&&t<=o?this.canIUse(K.astc):t===c?this.canIUse(K.etc1):t>=l&&t<=_?this.canIUse(K.etc):t>=u&&t<=h?this.canIUse(K.pvrtc):t>=d&&t<=f?this.canIUse(K.s3tc):t>=v&&t<=p?this.canIUse(K.bptc):!1},s._init=function(){var t=this.capabilityList,e=this.rhi.isWebGL2,r=this.rhi.requireExtension.bind(this.rhi),a=K.shaderVertexID,o=K.standardDerivatives,c=K.shaderTextureLod,l=K.elementIndexUint,_=K.depthTexture,u=K.vertexArrayObject,h=K.instancedArrays,d=K.multipleSample,f=K.drawBuffers,v=K.blendMinMax,p=K.astc,g=K.astc_webkit,y=K.etc,m=K.etc_webkit,x=K.etc1,C=K.etc1_webkit,b=K.pvrtc,A=K.pvrtc_webkit,S=K.s3tc,w=K.s3tc_webkit,E=K.bptc,B=K.textureFloat,M=K.textureHalfFloat,D=K.textureFloatLinear,L=K.textureHalfFloatLinear,V=K.WEBGL_colorBufferFloat,N=K.colorBufferFloat,I=K.colorBufferHalfFloat,P=K.textureFilterAnisotropic,z=K.fragDepth;t.set(a,e),t.set(o,e||!!r(o)),t.set(c,e||!!r(c)),t.set(l,e||!!r(l)),t.set(_,e||!!r(_)),t.set(u,e||!!r(u)),t.set(h,e||!!r(h)),t.set(d,e),t.set(f,e||!!r(f)),t.set(v,e||!!r(v)),t.set(B,e||!!r(B)),t.set(M,e||!!r(M)),t.set(D,!!r(D)),t.set(L,e||!!r(L)),t.set(N,e&&!!r(N)||!!r(V)),t.set(I,e&&!!r(N)||!!r(I)),t.set(P,!!r(P)),t.set(z,e||!!r(z)),t.set(p,!!(r(p)||r(g))),t.set(y,!!(r(y)||r(m))),t.set(x,!!(r(x)||r(C))),t.set(b,!!(r(b)||r(A))),t.set(S,!!(r(S)||r(w))),t.set(E,!!r(E))},s._compatibleInterface=function(t,e){var r=this.rhi,a=r.gl,o=null;if(o=r.requireExtension(t))for(var c in e){var l,_=e[c],u=o[_];(l=u)!=null&&l.bind?a[c]=u.bind(o):a[c]=u}},s._compatibleAllInterface=function(){var t=K.depthTexture,e=K.vertexArrayObject,r=K.instancedArrays,a=K.drawBuffers,o=K.textureFilterAnisotropic,c=K.textureHalfFloat,l=K.colorBufferHalfFloat,_=K.WEBGL_colorBufferFloat,u=K.blendMinMax,h=this.rhi.isWebGL2;if(!h){this._compatibleInterface(u,{MIN:"MIN_EXT",MAX:"MAX_EXT"}),this._compatibleInterface(t,{UNSIGNED_INT_24_8:"UNSIGNED_INT_24_8_WEBGL"}),this._compatibleInterface(e,{createVertexArray:"createVertexArrayOES",deleteVertexArray:"deleteVertexArrayOES",isVertexArray:"isVertexArrayOES",bindVertexArray:"bindVertexArrayOES"}),this._compatibleInterface(r,{drawArraysInstanced:"drawArraysInstancedANGLE",drawElementsInstanced:"drawElementsInstancedANGLE",vertexAttribDivisor:"vertexAttribDivisorANGLE"}),this._compatibleInterface(a,{MAX_DRAW_BUFFERS:"MAX_DRAW_BUFFERS_WEBGL"});var d={};if(this.canIUse(K.drawBuffers)){for(var f=this.maxDrawBuffers,v=0;v0}},{key:"canIUseMoreJoints",get:function(){return this.canIUse(K.textureFloat)&&this.rhi.renderStates.getParameter(this.rhi.gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}},{key:"maxDrawBuffers",get:function(){return this._maxDrawBuffers||(this.canIUse(K.drawBuffers)?this._maxDrawBuffers=this._rhi.gl.getParameter(this._rhi.gl.MAX_DRAW_BUFFERS):this._maxDrawBuffers=1),this._maxDrawBuffers}},{key:"maxAnisoLevel",get:function(){if(!this._maxAnisoLevel){var t=this._rhi.requireExtension(K.textureFilterAnisotropic);this._maxAnisoLevel=t?this._rhi.gl.getParameter(t.MAX_TEXTURE_MAX_ANISOTROPY_EXT):1}return this._maxAnisoLevel}},{key:"maxAntiAliasing",get:function(){if(!this._maxAntiAliasing){var t=this._rhi.gl,e=this.canIUse(K.multipleSample);this._maxAntiAliasing=e?t.getParameter(t.MAX_SAMPLES):1}return this._maxAntiAliasing}},{key:"rhi",get:function(){return this._rhi}}]),n}(),xh=function(){function n(i){this.rhi=i,this._requireResult={}}var s=n.prototype;return s.requireExtension=function(t){return this._requireResult[t]!==void 0?this._requireResult[t]:(this._requireResult[t]=this.rhi.gl.getExtension(t),this._requireResult[t])},n}(),bh=function(){function n(i,t){this._attribLocArray=[],this._vaoMap=new Map,this._primitive=t,this._canUseInstancedArrays=i.canIUse(K.instancedArrays),this._isSupportVAO=i.canIUse(K.vertexArrayObject),this._gl=i.gl}var s=n.prototype;return s.draw=function(t,e){var r=this._gl,a=this._primitive,o=this._isSupportVAO&&a.enableVAO;if(o){a._bufferStructChanged&&this._clearVAO(),this._vaoMap.has(t.id)||this._registerVAO(t);var c=this._vaoMap.get(t.id);r.bindVertexArray(c)}else this._bindBufferAndAttrib(t);var l=a.indexBufferBinding,_=a.instanceCount,u=a._glIndexType,h=a._glIndexByteCount,d=e.topology,f=e.start,v=e.count;if(_)if(this._canUseInstancedArrays)if(l)if(o)r.drawElementsInstanced(d,v,u,f*h,_);else{var g=l.buffer._platformBuffer._glBuffer;r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,g),r.drawElementsInstanced(d,v,u,f*h,_),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,null)}else r.drawArraysInstanced(d,f,v,_);else ve.error("ANGLE_instanced_arrays extension is not supported");else if(l)if(o)r.drawElements(d,v,u,f*h);else{var p=l.buffer._platformBuffer._glBuffer;r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,p),r.drawElements(d,v,u,f*h),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,null)}else r.drawArrays(d,f,v);o?r.bindVertexArray(null):this._disableAttrib()},s.destroy=function(){this._isSupportVAO&&this._clearVAO()},s._bindBufferAndAttrib=function(t){var e=this._gl,r=this._primitive,a=r.vertexBufferBindings;this._attribLocArray.length=0;var o=t.attributeLocation,c=r._vertexElementMap,l,_;for(var u in o){var h=o[u];if(h!==-1){var d=c[u];if(d){var f=a[d.bindingIndex],v=f.buffer,p=f.stride;l=v._platformBuffer._glBuffer,_!==l&&(_=l,e.bindBuffer(e.ARRAY_BUFFER,l)),e.enableVertexAttribArray(h);var g=d._formatMetaInfo;e.vertexAttribPointer(h,g.size,g.type,g.normalized,p,d.offset),this._canUseInstancedArrays&&e.vertexAttribDivisor(h,d.instanceStepRate),this._attribLocArray.push(h)}else ve.warn("vertex attribute not found: "+u)}}e.bindBuffer(e.ARRAY_BUFFER,null)},s._disableAttrib=function(){for(var t=this._gl,e=0,r=this._attribLocArray.length;e>m),C=0;C<6;C++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+C,m,o,x,x,0,c,l,null);else if(v)e.texImage2D(this._target,0,o,h,d,0,c,l,null);else for(var p=0;p>p),y=Math.max(1,d>>p);e.texImage2D(this._target,p,o,g,y,0,c,l,null)}},s._getPixelBuffer=function(t,e,r,a,o,c,l){var _=this._gl,u=this._formatDetail,h=u.baseFormat,d=u.dataType;_.bindFramebuffer(_.FRAMEBUFFER,this._getReadFrameBuffer()),c>0&&!this._isWebGL2&&(c=0,ve.error("mipLevel only take effect in WebGL2.0")),t!=null?_.framebufferTexture2D(_.FRAMEBUFFER,_.COLOR_ATTACHMENT0,_.TEXTURE_CUBE_MAP_POSITIVE_X+t,this._glTexture,c):_.framebufferTexture2D(_.FRAMEBUFFER,_.COLOR_ATTACHMENT0,_.TEXTURE_2D,this._glTexture,c),_.readPixels(e,r,a,o,h,d,l),_.bindFramebuffer(_.FRAMEBUFFER,null)},s._setWrapMode=function(t,e){var r=this._gl,a=this._isWebGL2,o=this._target,c=this._texture,l=c.width,_=c.height;switch(!a&&t!==gt.Clamp&&(!n._isPowerOf2(l)||!n._isPowerOf2(_))&&(ve.warn("non-power-2 texture is not supported for REPEAT or MIRRORED_REPEAT in WebGL1,and has automatically downgraded to CLAMP_TO_EDGE"),t=gt.Clamp),t){case gt.Clamp:r.texParameteri(o,e,r.CLAMP_TO_EDGE);break;case gt.Repeat:r.texParameteri(o,e,r.REPEAT);break;case gt.Mirror:r.texParameteri(o,e,r.MIRRORED_REPEAT);break}},s._getReadFrameBuffer=function(){var t=this._rhi._readFrameBuffer;return t||(this._rhi._readFrameBuffer=t=this._gl.createFramebuffer()),t},n._isPowerOf2=function(t){return(t&t-1)===0},n._getFormatDetail=function(t,e,r){switch(t){case G.R8G8B8:return{internalFormat:r?e.RGB8:e.RGB,baseFormat:e.RGB,dataType:e.UNSIGNED_BYTE,isCompressed:!1};case G.R8G8B8A8:return{internalFormat:r?e.RGBA8:e.RGBA,baseFormat:e.RGBA,dataType:e.UNSIGNED_BYTE,isCompressed:!1};case G.R4G4B4A4:return{internalFormat:r?e.RGBA4:e.RGBA,baseFormat:e.RGBA,dataType:e.UNSIGNED_SHORT_4_4_4_4,isCompressed:!1};case G.R5G5B5A1:return{internalFormat:r?e.RGB5_A1:e.RGBA,baseFormat:e.RGBA,dataType:e.UNSIGNED_SHORT_5_5_5_1,isCompressed:!1};case G.R5G6B5:return{internalFormat:r?e.RGB565:e.RGB,baseFormat:e.RGB,dataType:e.UNSIGNED_SHORT_5_6_5,isCompressed:!1};case G.Alpha8:return{internalFormat:e.ALPHA,baseFormat:e.ALPHA,dataType:e.UNSIGNED_BYTE,isCompressed:!1};case G.LuminanceAlpha:return{internalFormat:e.LUMINANCE_ALPHA,baseFormat:e.LUMINANCE_ALPHA,dataType:e.UNSIGNED_BYTE,isCompressed:!1};case G.R16G16B16A16:return{internalFormat:r?e.RGBA16F:e.RGBA,baseFormat:e.RGBA,dataType:e.HALF_FLOAT,isCompressed:!1};case G.R32G32B32A32:return{internalFormat:r?e.RGBA32F:e.RGBA,baseFormat:e.RGBA,dataType:e.FLOAT,isCompressed:!1};case G.R32G32B32A32_UInt:return{internalFormat:r?e.RGBA32UI:e.NONE,baseFormat:e.RGBA_INTEGER,dataType:e.UNSIGNED_INT,isCompressed:!1};case G.BC1:return{internalFormat:le.RGB_S3TC_DXT1_EXT,isCompressed:!0};case G.BC3:return{internalFormat:le.RGBA_S3TC_DXT5_EXT,isCompressed:!0};case G.BC7:return{internalFormat:le.RGBA_BPTC_UNORM_EXT,isCompressed:!0};case G.ETC1_RGB:return{internalFormat:le.RGB_ETC1_WEBGL,isCompressed:!0};case G.ETC2_RGB:return{internalFormat:le.RGB8_ETC2,isCompressed:!0};case G.ETC2_RGBA5:return{internalFormat:le.RGB8_PUNCHTHROUGH_ALPHA1_ETC2,isCompressed:!0};case G.ETC2_RGBA8:return{internalFormat:le.RGBA8_ETC2_EAC,isCompressed:!0};case G.PVRTC_RGB2:return{internalFormat:le.RGB_PVRTC_2BPPV1_IMG,isCompressed:!0};case G.PVRTC_RGBA2:return{internalFormat:le.RGBA_PVRTC_2BPPV1_IMG,isCompressed:!0};case G.PVRTC_RGB4:return{internalFormat:le.RGB_PVRTC_4BPPV1_IMG,isCompressed:!0};case G.PVRTC_RGBA4:return{internalFormat:le.RGBA_PVRTC_4BPPV1_IMG,isCompressed:!0};case G.ASTC_4x4:return{internalFormat:le.RGBA_ASTC_4X4_KHR,isCompressed:!0};case G.ASTC_5x5:return{internalFormat:le.RGBA_ASTC_5X5_KHR,isCompressed:!0};case G.ASTC_6x6:return{internalFormat:le.RGBA_ASTC_6X6_KHR,isCompressed:!0};case G.ASTC_8x8:return{internalFormat:le.RGBA_ASTC_8X8_KHR,isCompressed:!0};case G.ASTC_10x10:return{internalFormat:le.RGBA_ASTC_10X10_KHR,isCompressed:!0};case G.ASTC_12x12:return{internalFormat:le.RGBA_ASTC_12X12_KHR,isCompressed:!0};case G.Depth:return{internalFormat:r?e.DEPTH_COMPONENT32F:e.DEPTH_COMPONENT,baseFormat:e.DEPTH_COMPONENT,dataType:r?e.FLOAT:e.UNSIGNED_SHORT,isCompressed:!1,attachment:e.DEPTH_ATTACHMENT};case G.DepthStencil:return{internalFormat:r?e.DEPTH32F_STENCIL8:e.DEPTH_STENCIL,baseFormat:e.DEPTH_STENCIL,dataType:r?e.FLOAT_32_UNSIGNED_INT_24_8_REV:e.UNSIGNED_INT_24_8,isCompressed:!1,attachment:e.DEPTH_STENCIL_ATTACHMENT};case G.Depth16:return{internalFormat:r?e.DEPTH_COMPONENT16:e.DEPTH_COMPONENT,baseFormat:e.DEPTH_COMPONENT,dataType:e.UNSIGNED_SHORT,isCompressed:!1,attachment:e.DEPTH_ATTACHMENT};case G.Depth24Stencil8:return{internalFormat:r?e.DEPTH24_STENCIL8:e.DEPTH_STENCIL,baseFormat:e.DEPTH_STENCIL,dataType:e.UNSIGNED_INT_24_8,isCompressed:!1,attachment:e.DEPTH_STENCIL_ATTACHMENT};case G.Depth24:return{internalFormat:e.DEPTH_COMPONENT24,baseFormat:e.DEPTH_COMPONENT,dataType:e.UNSIGNED_INT,isCompressed:!1,attachment:e.DEPTH_ATTACHMENT};case G.Depth32:return{internalFormat:e.DEPTH_COMPONENT32F,baseFormat:e.DEPTH_COMPONENT,dataType:e.FLOAT,isCompressed:!1,attachment:e.DEPTH_ATTACHMENT};case G.Depth32Stencil8:return{internalFormat:e.DEPTH32F_STENCIL8,baseFormat:e.DEPTH_STENCIL,dataType:e.FLOAT_32_UNSIGNED_INT_24_8_REV,isCompressed:!1,attachment:e.DEPTH_STENCIL_ATTACHMENT};default:throw new Error("this TextureFormat is not supported in Galacean Engine: "+t)}},n._getRenderBufferDepthFormatDetail=function(t,e,r){switch(t){case G.Depth:return{internalFormat:r?e.DEPTH_COMPONENT32F:e.DEPTH_COMPONENT16,baseFormat:e.DEPTH_COMPONENT,dataType:r?e.FLOAT:e.UNSIGNED_SHORT,isCompressed:!1,attachment:e.DEPTH_ATTACHMENT};case G.DepthStencil:return{internalFormat:r?e.DEPTH32F_STENCIL8:e.DEPTH_STENCIL,baseFormat:e.DEPTH_STENCIL,dataType:r?e.FLOAT_32_UNSIGNED_INT_24_8_REV:e.UNSIGNED_INT_24_8,isCompressed:!1,attachment:e.DEPTH_STENCIL_ATTACHMENT};case G.Stencil:return{internalFormat:e.STENCIL_INDEX8,baseFormat:e.STENCIL_ATTACHMENT,dataType:e.UNSIGNED_BYTE,isCompressed:!1,attachment:e.STENCIL_ATTACHMENT};case G.Depth16:return{internalFormat:e.DEPTH_COMPONENT16,baseFormat:e.DEPTH_COMPONENT,dataType:e.UNSIGNED_SHORT,isCompressed:!1,attachment:e.DEPTH_ATTACHMENT};case G.Depth24Stencil8:return{internalFormat:r?e.DEPTH24_STENCIL8:e.DEPTH_STENCIL,baseFormat:e.DEPTH_STENCIL,dataType:e.UNSIGNED_INT_24_8,isCompressed:!1,attachment:e.DEPTH_STENCIL_ATTACHMENT};case G.Depth24:return{internalFormat:e.DEPTH_COMPONENT24,baseFormat:e.DEPTH_COMPONENT,dataType:e.UNSIGNED_INT,isCompressed:!1,attachment:e.DEPTH_ATTACHMENT};case G.Depth32:return{internalFormat:e.DEPTH_COMPONENT32F,baseFormat:e.DEPTH_COMPONENT,dataType:e.FLOAT,isCompressed:!1,attachment:e.DEPTH_ATTACHMENT};case G.Depth32Stencil8:return{internalFormat:e.DEPTH32F_STENCIL8,baseFormat:e.DEPTH_STENCIL,dataType:e.FLOAT_32_UNSIGNED_INT_24_8_REV,isCompressed:!1,attachment:e.DEPTH_STENCIL_ATTACHMENT};default:throw new Error("this TextureFormat is not supported in Galacean Engine: "+t)}},n._supportTextureFormat=function(t,e){switch(t){case G.R16G16B16A16:if(!e.canIUse(K.textureHalfFloat))return!1;break;case G.R32G32B32A32:if(!e.canIUse(K.textureFloat))return!1;break;case G.Depth16:case G.Depth24Stencil8:case G.Depth:case G.DepthStencil:if(!e.canIUse(K.depthTexture))return!1;break;case G.R32G32B32A32_UInt:case G.Depth24:case G.Depth32:case G.Depth32Stencil8:return e.isWebGL2}return!0},n._supportRenderBufferColorFormat=function(t,e){var r=!0;switch(t){case G.R16G16B16A16:(!e.canIUse(K.colorBufferHalfFloat)||!e.canIUse(K.textureHalfFloat))&&(r=!1);break;case G.R32G32B32A32:(!e.canIUse(K.colorBufferFloat)||!e.canIUse(K.textureFloat))&&(r=!1);break}return r},n._supportRenderBufferDepthFormat=function(t,e){if(!e.isWebGL2)switch(t){case G.Depth24:case G.Depth32:case G.Depth32Stencil8:return!1}return!0},Xa(n,[{key:"wrapModeU",set:function(t){this._bind(),this._setWrapMode(t,this._gl.TEXTURE_WRAP_S)}},{key:"wrapModeV",set:function(t){this._bind(),this._setWrapMode(t,this._gl.TEXTURE_WRAP_T)}},{key:"filterMode",set:function(t){var e=this._gl,r=this._target,a=this._texture._mipmap;switch(this._bind(),t){case tt.Point:e.texParameteri(r,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(r,e.TEXTURE_MIN_FILTER,a?e.NEAREST_MIPMAP_NEAREST:e.NEAREST);break;case tt.Bilinear:e.texParameteri(r,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(r,e.TEXTURE_MIN_FILTER,a?e.LINEAR_MIPMAP_NEAREST:e.LINEAR);break;case tt.Trilinear:e.texParameteri(r,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(r,e.TEXTURE_MIN_FILTER,a?e.LINEAR_MIPMAP_LINEAR:e.LINEAR);break}}},{key:"anisoLevel",set:function(t){var e=this._gl;this._bind(),e.texParameterf(this._target,e.TEXTURE_MAX_ANISOTROPY_EXT,t)}},{key:"depthCompareFunction",set:function(t){this._bind();var e=this._gl;switch(t){case fr.Never:e.texParameteri(this._target,e.TEXTURE_COMPARE_FUNC,e.NEVER);break;case fr.Less:e.texParameteri(this._target,e.TEXTURE_COMPARE_FUNC,e.LESS);break;case fr.Equal:e.texParameteri(this._target,e.TEXTURE_COMPARE_FUNC,e.EQUAL);break;case fr.LessEqual:e.texParameteri(this._target,e.TEXTURE_COMPARE_FUNC,e.LEQUAL);break;case fr.Greater:e.texParameteri(this._target,e.TEXTURE_COMPARE_FUNC,e.GREATER);break;case fr.NotEqual:e.texParameteri(this._target,e.TEXTURE_COMPARE_FUNC,e.NOTEQUAL);break;case fr.GreaterEqual:e.texParameteri(this._target,e.TEXTURE_COMPARE_FUNC,e.GEQUAL);break;case fr.Always:e.texParameteri(this._target,e.TEXTURE_COMPARE_FUNC,e.ALWAYS);break}}}]),n}(),Ch=function(){function n(i,t){this._MSAAColorRenderBuffers=[],this._curMipLevel=0,this._curFaceIndex=void 0,this._gl=i.gl,this._isWebGL2=i.isWebGL2,this._target=t;for(var e=t._colorTextures,r=t._depth,a=t.width,o=t.height,c=ar(r,Wr),l=0,_=e.length;l<_;l++){var u=e[l]._format;if(!Ct._supportRenderBufferColorFormat(u,i))throw new Error("TextureFormat is not supported:"+G[u]+" in RenderTarget")}if(!c&&!Ct._supportRenderBufferDepthFormat(r,i))throw new Error("TextureFormat is not supported:"+G[r]+" in RenderTarget");if(e.length>1&&!i.canIUse(K.drawBuffers))throw new Error("MRT is not supported");if(e.some(function(d){return d.width!==a||d.height!==o}))throw new Error("ColorTexture's size must as same as RenderTarget");if(c&&(r.width!==a||r.height!==o))throw new Error("DepthTexture's size must as same as RenderTarget");if(e.length>1&&e.some(function(d){return ar(d,jt)}))throw new Error("MRT+Cube+[,MSAA] is not supported");var h=i.capability.maxAntiAliasing;t.antiAliasing>h&&(ve.warn("MSAA antiAliasing exceeds the limit and is automatically downgraded to:"+h),t._antiAliasing=h),this._frameBuffer=this._gl.createFramebuffer(),this._bindMainFBO(),t.antiAliasing>1&&(this._MSAAFrameBuffer=this._gl.createFramebuffer(),this._bindMSAAFBO())}var s=n.prototype;return s.activeRenderTarget=function(t,e){var r=this,a=r._gl,o=r._target;a.bindFramebuffer(a.FRAMEBUFFER,this._frameBuffer);var c=t!==this._curMipLevel,l=e!==this._curFaceIndex,_=o.getColorTexture(0);if(_){var u=ar(_,jt);(c||u&&l)&&a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,u?a.TEXTURE_CUBE_MAP_POSITIVE_X+e:a.TEXTURE_2D,_._platformTexture._glTexture,t)}var h=o.depthTexture;if(h){var d=ar(h,jt);if(c||d){var f=h._platformTexture;a.framebufferTexture2D(a.FRAMEBUFFER,f._formatDetail.attachment,d?a.TEXTURE_CUBE_MAP_POSITIVE_X+e:a.TEXTURE_2D,f._glTexture,t)}}else if(c){var v=Ct._getRenderBufferDepthFormatDetail(o._depth,a,this._isWebGL2).internalFormat;a.bindRenderbuffer(a.RENDERBUFFER,this._depthRenderBuffer),a.renderbufferStorage(a.RENDERBUFFER,v,o.width>>t,o.height>>t)}this._curMipLevel=t,this._curFaceIndex=e,this._MSAAFrameBuffer&&a.bindFramebuffer(a.FRAMEBUFFER,this._MSAAFrameBuffer)},s.blitRenderTarget=function(){if(this._MSAAFrameBuffer){var t=this._gl,e=t.COLOR_BUFFER_BIT|(this._target.depthTexture?t.DEPTH_BUFFER_BIT:0),r=this._target,a=r.colorTextureCount,o=r.width,c=r.height;t.bindFramebuffer(t.READ_FRAMEBUFFER,this._MSAAFrameBuffer),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,this._frameBuffer);for(var l=0;l1&&t.drawBuffers(_),this._oriDrawBuffers=_,a!==null){if(ar(a,Wr)&&!ar(a,jt)){var f=a._platformTexture;t.framebufferTexture2D(t.FRAMEBUFFER,f._formatDetail.attachment,t.TEXTURE_2D,f._glTexture,0)}else if(this._target.antiAliasing<=1){var v=Ct._getRenderBufferDepthFormatDetail(a,t,e),p=v.internalFormat,g=v.attachment,y=t.createRenderbuffer();this._depthRenderBuffer=y,t.bindRenderbuffer(t.RENDERBUFFER,y),t.renderbufferStorage(t.RENDERBUFFER,p,c,l),t.framebufferRenderbuffer(t.FRAMEBUFFER,g,t.RENDERBUFFER,y)}}t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindRenderbuffer(t.RENDERBUFFER,null)},s._bindMSAAFBO=function(){var t=this._gl,e=this._isWebGL2,r=t.createRenderbuffer(),a=this._target,o=a._depth,c=a.colorTextureCount,l=a.antiAliasing,_=a.width,u=a.height;this._blitDrawBuffers=new Array(c),this._MSAADepthRenderBuffer=r,t.bindFramebuffer(t.FRAMEBUFFER,this._MSAAFrameBuffer);for(var h=0;h>r),y=Math.max(1,this._texture.height>>r);if(c=c||g-a,l=l||y-o,this._bind(),_.pixelStorei(_.UNPACK_FLIP_Y_WEBGL,0),_.pixelStorei(_.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),p){var m=1<>a)-o,_=_||Math.max(1,this._texture.height>>a)-c,u=u||this._texture.length,this._bind(),f.pixelStorei(f.UNPACK_FLIP_Y_WEBGL,0),f.pixelStorei(f.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),m?f.compressedTexSubImage3D(d,a,o,c,e,l,_,u,p,r):f.texSubImage3D(d,a,o,c,e,l,_,u,g,y,r)},i.setImageSource=function(e,r,a,o,c,l,_){var u=this._gl,h=this._formatDetail,d=h.baseFormat,f=h.dataType;this._bind(),u.pixelStorei(u.UNPACK_FLIP_Y_WEBGL,+o),u.pixelStorei(u.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+c);var v,p;u.texSubImage3D(this._target,a,l,_,e,(v=r.width)!=null?v:r.codedWidth,(p=r.height)!=null?p:r.codedHeight,1,d,f,r)},i.getPixelBuffer=function(e,r,a,o,c,l,_){var u=this,h=u._gl,d=u._formatDetail;if(d.isCompressed)throw new Error("Unable to read compressed texture");h.bindFramebuffer(h.FRAMEBUFFER,this._getReadFrameBuffer()),h.framebufferTextureLayer(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0,this._glTexture,l,e),h.readPixels(r,a,o,c,d.baseFormat,d.dataType,_),h.bindFramebuffer(h.FRAMEBUFFER,null)},s}(Ct),wh=function(n){ja(s,n);function s(t,e){var r;r=n.call(this,t,e,t.gl.TEXTURE_CUBE_MAP)||this,r._compressedFaceFilled=[0,0,0,0,0,0];var a=e.format,o=e._mipmap,c=e.width,l=r._isWebGL2;if(!Ct._supportTextureFormat(a,t))throw new Error("Texture format is not supported:"+G[a]);return o&&!l&&!Ct._isPowerOf2(c)&&(ve.warn("non-power-2 texture is not supported for mipmap in WebGL1,and has automatically downgraded to non-mipmap"),e._mipmap=!1,e._mipmapCount=e._getMipmapCount()),r._formatDetail=Ct._getFormatDetail(a,r._gl,l),r._formatDetail.isCompressed&&!l||r._init(!0),r}var i=s.prototype;return i.setPixelBuffer=function(e,r,a,o,c,l,_){var u=this._gl,h=this._isWebGL2,d=this._formatDetail,f=d.internalFormat,v=d.baseFormat,p=d.dataType,g=d.isCompressed,y=Math.max(1,this._texture.width>>a);if(l=l||y-o,_=_||y-c,this._bind(),u.pixelStorei(u.UNPACK_FLIP_Y_WEBGL,0),u.pixelStorei(u.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),g){var m=1<=0&&a<=4&&(t._forceFlush=!0)}}this._options=t,this._onWebGLContextLost=this._onWebGLContextLost.bind(this),this._onWebGLContextRestored=this._onWebGLContextRestored.bind(this)}var s=n.prototype;return s.init=function(t,e,r){var a=this._options,o=t._webCanvas,c=a.webGLMode;this._onDeviceLost=e,this._onDeviceRestored=r,o.addEventListener("webglcontextlost",this._onWebGLContextLost,!1),o.addEventListener("webglcontextrestored",this._onWebGLContextRestored,!1),o.addEventListener("webglcontextcreationerror",this._onContextCreationError,!1),this._webCanvas=o;var l;if((c==0||c==1)&&(l=o.getContext("webgl2",a),!l&&(typeof OffscreenCanvas>"u"||!ar(o,OffscreenCanvas))&&(l=o.getContext("experimental-webgl2",a)),this._isWebGL2=!0,l&&!l.deleteQuery&&(this._isWebGL2=!1)),l||(c==0||c==2)&&(l=o.getContext("webgl",a),!l&&(typeof OffscreenCanvas>"u"||!ar(o,OffscreenCanvas))&&(l=o.getContext("experimental-webgl",a)),this._isWebGL2=!1),!l)throw new Error("Get GL Context FAILED.");this._gl=l,this._initGLState(l)},s.createPlatformPrimitive=function(t){return new bh(this,t)},s.createPlatformTexture2D=function(t){return new Ah(this,t)},s.createPlatformTexture2DArray=function(t){return new Eh(this,t)},s.createPlatformTextureCube=function(t){return new wh(this,t)},s.createPlatformRenderTarget=function(t){return new Ch(this,t)},s.createPlatformBuffer=function(t,e,r,a){return r===void 0&&(r=Je.Static),new mh(this,t,e,r,a)},s.requireExtension=function(t){return this._extensions.requireExtension(t)},s.canIUse=function(t){return this.capability.canIUse(t)},s.canIUseCompressedTextureInternalFormat=function(t){return this.capability.canIUseCompressedTextureInternalFormat(t)},s.viewport=function(t,e,r,a){var o=this,c=o._gl,l=o._lastViewport;(t!==l.x||e!==l.y||r!==l.z||a!==l.w)&&(c.viewport(t,e,r,a),l.set(t,e,r,a))},s.scissor=function(t,e,r,a){var o=this,c=o._gl,l=o._lastScissor;if(t!==l.x||e!==l.y||r!==l.z||a!==l.w){var _=this,u=_._webCanvas;t===0&&e===0&&r===u.width&&a===u.height?this._scissorEnable&&(c.disable(c.SCISSOR_TEST),this._scissorEnable=!1):(this._scissorEnable||(c.enable(c.SCISSOR_TEST),this._scissorEnable=!0),c.scissor(t,e,r,a)),l.set(t,e,r,a)}},s.colorMask=function(t,e,r,a){this._gl.colorMask(t,e,r,a)},s.clearRenderTarget=function(t,e,r){var a=this._gl,o=t._lastRenderState,c=o.blendState.targetBlendState,l=o.depthState,_=o.stencilState,u=0;if(e&zt.Color){u|=a.COLOR_BUFFER_BIT;var h=this._lastClearColor,d=r.r,f=r.g,v=r.b,p=r.a;r&&(d!==h.r||f!==h.g||v!==h.b||p!==h.a)&&(a.clearColor(d,f,v,p),h.set(d,f,v,p)),c.colorWriteMask!==mr.All&&(a.colorMask(!0,!0,!0,!0),c.colorWriteMask=mr.All)}e&zt.Depth&&(u|=a.DEPTH_BUFFER_BIT,l.writeEnabled!==!0&&(a.depthMask(!0),l.writeEnabled=!0)),e&zt.Stencil&&(u|=a.STENCIL_BUFFER_BIT,_.writeMask!==255&&(a.stencilMask(255),_.writeMask=255)),a.clear(u)},s.drawPrimitive=function(t,e,r){t?t.draw(r,e):ve.error("draw primitive failed.")},s.getMainFrameBufferWidth=function(){return this._mainFrameWidth||this._gl.drawingBufferWidth},s.getMainFrameBufferHeight=function(){return this._mainFrameHeight||this._gl.drawingBufferHeight},s.activeRenderTarget=function(t,e,r,a,o){var c,l;if(t){t._isContentLost=!1;var _=t._platformRenderTarget;_.activeRenderTarget(a,o),c=t.width>>a,l=t.height>>a}else{var u=this._gl;u.bindFramebuffer(u.FRAMEBUFFER,this._mainFrameBuffer),c=this.getMainFrameBufferWidth(),l=this.getMainFrameBufferHeight()}var h=c*e.z,d=l*e.w,f=e.x*c,v=r?e.y*l:l-e.y*l-d;this.viewport(f,v,h,d),this.scissor(f,v,h,d)},s.activeTexture=function(t){this._activeTextureID!==t&&(this._gl.activeTexture(t),this._activeTextureID=t)},s.bindTexture=function(t){var e=this._activeTextureID-this._gl.TEXTURE0;this._activeTextures[e]!==t&&(this._gl.bindTexture(t._target,t._glTexture),this._activeTextures[e]=t)},s.setGlobalDepthBias=function(t,e){var r=this._gl,a=t!==0||e!==0;a?(r.enable(r.POLYGON_OFFSET_FILL),r.polygonOffset(e,t)):r.disable(r.POLYGON_OFFSET_FILL),this._enableGlobalDepthBias=a},s.flush=function(){this._gl.flush()},s.forceLoseDevice=function(){var t=this.requireExtension(K.WEBGL_lose_context);t.loseContext()},s.forceRestoreDevice=function(){var t=this.requireExtension(K.WEBGL_lose_context);t.restoreContext()},s.resetState=function(){this._readFrameBuffer=null,this._enableGlobalDepthBias=!1,this._currentBindShaderProgram=null;for(var t=this._activeTextures,e=0,r=t.length;e=0;o--)(a=n[o])&&(r=(e<3?a(r):e>3?a(s,i,r):a(s,i))||r);return e>3&&r&&Object.defineProperty(s,i,r),r}function Xi(n,s){var i={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},t,e,r,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(_){return c([l,_])}}function c(l){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(t=1,e&&(r=l[0]&2?e.return:l[0]?e.throw||((r=e.return)&&r.call(e),0):e.next)&&!(r=r.call(e,l[1])).done)return r;switch(e=0,r&&(l=[l[0]&2,r.value]),l[0]){case 0:case 1:r=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,e=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(r=i.trys,!(r=r.length>0&&r[r.length-1])&&(l[0]===6||l[0]===2)){i=0;continue}if(l[0]===3&&(!r||l[1]>r[0]&&l[1]=p&&e(y)};if(w(),o){var E=function(M){var D=new window.Blob([g[M]]),L=new Image;L.onload=function(){y.setImageSource(L,M),w()},L.src=URL.createObjectURL(D)};y.generateMipmaps();for(var B=1;B"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ui(n,s,i){return Bh()?ui=Reflect.construct:ui=function(e,r,a){var o=[null];o.push.apply(o,r);var c=Function.bind.apply(e,o),l=new c;return a&&Di(l,a.prototype),l},ui.apply(null,arguments)}var zo=function(){function n(i){this._context=i}var s=n.prototype;return s.parseEntity=function(t){return this._getEntityByConfig(t).then(function(e){var r;e.isActive=(r=t.isActive)!=null?r:!0;var a=t.position,o=t.rotation,c=t.scale;a&&e.transform.position.copyFrom(a),o&&e.transform.rotation.copyFrom(o),c&&e.transform.scale.copyFrom(c);var l;return e.layer=(l=t.layer)!=null?l:e.layer,e})},s.parseClassObject=function(t){var e=this,r=Be.getClass(t.class),a,o=(a=t.constructParams)!=null?a:[];return Promise.all(o.map(function(c){return e.parseBasicType(c)})).then(function(c){return ui(r,[].concat(c))}).then(function(c){return e.parsePropsAndMethods(c,t)})},s.parsePropsAndMethods=function(t,e){var r=[];if(e.methods)for(var a in e.methods)for(var o=e.methods[a],c=0,l=o.length;cn.length)&&(s=n.length);for(var i=0,t=new Array(s);i=n.length?{done:!0}:{done:!1,value:n[t++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var Lh=function(){function n(i){var t=this;this.context=i,this.prefabContextMap=new WeakMap,this.prefabPromiseMap=new Map,this._engine=this.context.engine,this._organizeEntities=this._organizeEntities.bind(this),this._parseComponents=this._parseComponents.bind(this),this._parsePrefabModification=this._parsePrefabModification.bind(this),this._parsePrefabRemovedEntities=this._parsePrefabRemovedEntities.bind(this),this._parsePrefabRemovedComponents=this._parsePrefabRemovedComponents.bind(this),this._clearAndResolve=this._clearAndResolve.bind(this),this.promise=new Promise(function(e,r){t._reject=r,t._resolve=e}),this._reflectionParser=new zo(i)}var s=n.prototype;return s.start=function(){this._parseEntities().then(this._organizeEntities).then(this._parseComponents).then(this._parsePrefabModification).then(this._parsePrefabRemovedEntities).then(this._parsePrefabRemovedComponents).then(this._clearAndResolve).then(this._resolve).catch(this._reject)},s._parseEntities=function(){var t=this,e=this.context.originalData.entities,r=this.context.entityConfigMap,a=this.context.entityMap,o=this._engine,c=e.map(function(l){var _,u=(_=l.strippedId)!=null?_:l.id;return l.id=u,r.set(u,l),t._getEntityByConfig(l,o)});return Promise.all(c).then(function(l){for(var _=0,u=l.length;_0)for(var c=a.get(t),l=0;l>y,x=0;x<6;x++){var C=m*m*4,b=new Uint8Array(l,g,C);g+=C,v.setPixelBuffer(Ar.PositiveX+x,b,y)}var A=new Er(f),S=new ol;A.diffuseMode=Wn.SphericalHarmonics,S.copyFromArray(u),A.diffuseSphericalHarmonics=S,A.specularTexture=v,A.specularTextureDecodeRGBM=!0,o(A)}).catch(function(l){c(l)})})},s}(Be);Es=ce([Xe(Ve.Env,["env"])],Es);function ws(n,s,i,t,e,r,a){try{var o=n[r](a),c=o.value}catch(l){i(l);return}o.done?s(c):Promise.resolve(c).then(t,e)}function Yi(n){return function(){var s=this,i=arguments;return new Promise(function(t,e){var r=n.apply(s,i);function a(c){ws(r,t,e,a,o,"next",c)}function o(c){ws(r,t,e,a,o,"throw",c)}a(void 0)})}}var Ts=function(n){ne(s,n);function s(){return n.apply(this,arguments)}var i=s.prototype;return i.load=function(e,r){var a=this;return new Pe(function(o,c){a.request(e.url,{type:"json"}).then(function(l){var _=l.fontName,u=l.fontUrl;if(u)a._registerFont(_,u).then(function(){var d=new ca(r.engine,_);o(d)}).catch(function(d){c("load font "+u+" fail")});else{var h=new ca(r.engine,_);o(h)}}).catch(function(l){c(l)})})},i._registerFont=function(e,r){return Yi(function(){var a;return Xi(this,function(o){switch(o.label){case 0:return a=new FontFace(e,"url("+r+")"),[4,a.load()];case 1:return o.sent(),document.fonts.add(a),[2]}})})()},s}(Be);Ts=ce([Xe(Ve.Font,["font"],!1)],Ts);var Ih=function(n){ne(s,n);function s(t,e){var r;return r=n.call(this,t)||this,r.url=e,r}var i=s.prototype;return i.instantiateSceneRoot=function(e){var r=e===void 0?this._defaultSceneRoot:this._sceneRoots[e];return r.clone()},i._onDestroy=function(){n.prototype._onDestroy.call(this);var e=this,r=e.textures,a=e.materials,o=e.meshes;if(r&&this._disassociationSuperResource(r),a&&this._disassociationSuperResource(a),o)for(var c=0,l=o.length;c=Vi.NEAREST_MIPMAP_NEAREST,e===go.NEAREST?o.filterMode=tt.Point:t<=Vi.LINEAR_MIPMAP_NEAREST?o.filterMode=tt.Bilinear:o.filterMode=tt.Trilinear),r&&(o.wrapModeU=Fi._wrapMap[r]),a&&(o.wrapModeV=Fi._wrapMap[a]),o},n}(),Ps;(function(n){n[n.linear=1]="linear",n[n.sRGB=2]="sRGB"})(Ps||(Ps={}));var Bs;(function(n){n[n.ETC1S=163]="ETC1S",n[n.UASTC=166]="UASTC"})(Bs||(Bs={}));var mo;(function(n){n[n.None=0]="None",n[n.BasisLZ=1]="BasisLZ",n[n.Zstd=2]="Zstd",n[n.ZLib=3]="ZLib"})(mo||(mo={}));var zh=function(){function n(i){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=0,this.levels=[],this.keyValue={},this.globalData=null,this.parse(i)}var s=n.prototype;return s.parse=function(t){var e=t.buffer,r=t.byteOffset,a=new Zn(t,12);this.vkFormat=a.nextUint32(),this.typeSize=a.nextUint32(),this.pixelWidth=a.nextUint32(),this.pixelHeight=a.nextUint32(),this.pixelDepth=a.nextUint32(),this.layerCount=a.nextUint32(),this.faceCount=a.nextUint32();var o=Math.max(1,a.nextUint32());this.supercompressionScheme=a.nextUint32();var c=a.nextUint32(),l=a.nextUint32(),_=a.nextUint32(),u=a.nextUint32(),h=a.nextUint64(),d=a.nextUint64(),f=new Array(o),v=o*3*8,p=new Zn(t,a.offset,v);this.levels=f;for(var g=0;g0&&e.forEachAndClean(function(r){r._started=!0,t.removeOnStartScript(r),r.onStart()})},s.callScriptOnUpdate=function(t){this._onUpdateScripts.forEach(function(e){e._started&&e.onUpdate(t)},function(e,r){e._onUpdateIndex=r})},s.callScriptOnLateUpdate=function(t){this._onLateUpdateScripts.forEach(function(e){e._started&&e.onLateUpdate(t)},function(e,r){e._onLateUpdateIndex=r})},s.callScriptOnPhysicsUpdate=function(){this._onPhysicsUpdateScripts.forEach(function(t){t._started&&t.onPhysicsUpdate()},function(t,e){t._onPhysicsUpdateIndex=e})},s.callAnimationUpdate=function(t){this._onUpdateAnimations.forEach(function(e){e.engine.time.frameCount>e._playFrameCount&&e.update(t)},function(e,r){e._onUpdateIndex=r})},s.callRendererOnUpdate=function(t){this._onUpdateRenderers.forEach(function(e){e.update(t)},function(e,r){e._onUpdateIndex=r})},s.handlingInvalidScripts=function(){var t=this,e=t._disposeDestroyScripts,r=t._pendingDestroyScripts;this._disposeDestroyScripts=r,this._pendingDestroyScripts=e;var a=r.length;if(a>0){for(var o=a-1;o>=0;o--)r[o].onDestroy();r.length=0}},s.callCameraOnBeginRender=function(t){t.entity._scripts.forEach(function(e){e.onBeginRender(t)},function(e,r){e._entityScriptsIndex=r})},s.callCameraOnEndRender=function(t){t.entity._scripts.forEach(function(e){e.onEndRender(t)},function(e,r){e._entityScriptsIndex=r})},s.getActiveChangedTempList=function(){return this._componentsContainerPool.length?this._componentsContainerPool.pop():[]},s.putActiveChangedTempList=function(t){t.length=0,this._componentsContainerPool.push(t)},s._gc=function(){this._renderers.garbageCollection(),this._onStartScripts.garbageCollection(),this._onUpdateScripts.garbageCollection(),this._onLateUpdateScripts.garbageCollection(),this._onPhysicsUpdateScripts.garbageCollection(),this._onUpdateAnimations.garbageCollection(),this._onUpdateRenderers.garbageCollection(),this._activeCameras.garbageCollection()},n}(),bi;(function(n){n[n.None=0]="None",n[n.Linear=1]="Linear",n[n.Exponential=2]="Exponential",n[n.ExponentialSquared=3]="ExponentialSquared"})(bi||(bi={}));var Xn;(function(n){n[n.SolidColor=0]="SolidColor",n[n.SphericalHarmonics=1]="SphericalHarmonics"})(Xn||(Xn={}));var Tr=function(n){W(s,n);function s(t){var e;return e=n.call(this,t)||this,e._diffuseSolidColor=new q(.212,.227,.259),e._diffuseIntensity=1,e._specularIntensity=1,e._diffuseMode=Xn.SolidColor,e._shArray=new Float32Array(27),e._scenes=[],e._specularTextureDecodeRGBM=!1,e}var i=s.prototype;return i._addToScene=function(e){this._addReferCount(1),this._scenes.push(e);var r=e.shaderData;r.setColor(s._diffuseColorProperty,this._diffuseSolidColor),r.setFloat(s._diffuseIntensityProperty,this._diffuseIntensity),r.setFloat(s._specularIntensityProperty,this._specularIntensity),r.setFloatArray(s._diffuseSHProperty,this._shArray),this._setDiffuseMode(r),this._setSpecularTextureDecodeRGBM(r),this._setSpecularTexture(r)},i._removeFromScene=function(e){this._addReferCount(-1);var r=this._scenes,a=r.indexOf(e);r.splice(a,1);var o=e.shaderData;o.setTexture(s._specularTextureProperty,null),o.disableMacro(s._specularMacro)},i._setDiffuseMode=function(e){this._diffuseMode===Xn.SphericalHarmonics?e.enableMacro(s._shMacro):e.disableMacro(s._shMacro)},i._setSpecularTexture=function(e){this._specularTexture?(e.setTexture(s._specularTextureProperty,this._specularTexture),e.setFloat(s._mipLevelProperty,this._specularTexture.mipmapCount-1),e.enableMacro(s._specularMacro)):e.disableMacro(s._specularMacro)},i._setSpecularTextureDecodeRGBM=function(e){this._specularTextureDecodeRGBM?e.enableMacro(s._decodeRGBMMacro):e.disableMacro(s._decodeRGBMMacro)},i._preComputeSH=function(e,r){var a=e.coefficients;r[0]=a[0]*.886227,r[1]=a[1]*.886227,r[2]=a[2]*.886227,r[3]=a[3]*-1.023327,r[4]=a[4]*-1.023327,r[5]=a[5]*-1.023327,r[6]=a[6]*1.023327,r[7]=a[7]*1.023327,r[8]=a[8]*1.023327,r[9]=a[9]*-1.023327,r[10]=a[10]*-1.023327,r[11]=a[11]*-1.023327,r[12]=a[12]*.858086,r[13]=a[13]*.858086,r[14]=a[14]*.858086,r[15]=a[15]*-.858086,r[16]=a[16]*-.858086,r[17]=a[17]*-.858086,r[18]=a[18]*.247708,r[19]=a[19]*.247708,r[20]=a[20]*.247708,r[21]=a[21]*-.858086,r[22]=a[22]*-.858086,r[23]=a[23]*-.858086,r[24]=a[24]*.429042,r[25]=a[25]*.429042,r[26]=a[26]*.429042},j(s,[{key:"specularTextureDecodeRGBM",get:function(){return this._specularTextureDecodeRGBM},set:function(e){this._specularTextureDecodeRGBM=e;for(var r=this._scenes,a=0,o=r.length;a>>16&65535,this.engine.settings.colorSpace===or.Linear?(r.color[o]=q.gammaToLinearSpace(l.r),r.color[o+1]=q.gammaToLinearSpace(l.g),r.color[o+2]=q.gammaToLinearSpace(l.b)):(r.color[o]=l.r,r.color[o+1]=l.g,r.color[o+2]=l.b),r.direction[c]=_.x,r.direction[c+1]=_.y,r.direction[c+2]=_.z},i._onEnableInScene=function(){this.scene._lightManager._attachDirectLight(this)},i._onDisableInScene=function(){this.scene._lightManager._detachDirectLight(this)},s._updateShaderData=function(e,r){e.setIntArray(s._cullingMaskProperty,r.cullingMask),e.setFloatArray(s._colorProperty,r.color),e.setFloatArray(s._directionProperty,r.direction)},j(s,[{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return R.scale(this.direction,-1,this._reverseDirection),this._reverseDirection}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),s}(Ha);(function(){jn._cullingMaskProperty=O.getByName("scene_DirectLightCullingMask")})();(function(){jn._colorProperty=O.getByName("scene_DirectLightColor")})();(function(){jn._directionProperty=O.getByName("scene_DirectLightDirection")})();var Yn=function(n){W(s,n);function s(){var t;return t=n.apply(this,arguments)||this,t.distance=100,t}var i=s.prototype;return i._appendData=function(e,r){var a=e*2,o=e*3,c=e*3,l=e,_=this._getLightIntensityColor(),u=this.position,h=this.cullingMask;r.cullingMask[a]=h&65535,r.cullingMask[a+1]=h>>>16&65535,this.engine.settings.colorSpace===or.Linear?(r.color[o]=q.gammaToLinearSpace(_.r),r.color[o+1]=q.gammaToLinearSpace(_.g),r.color[o+2]=q.gammaToLinearSpace(_.b)):(r.color[o]=_.r,r.color[o+1]=_.g,r.color[o+2]=_.b),r.position[c]=u.x,r.position[c+1]=u.y,r.position[c+2]=u.z,r.distance[l]=this.distance},i._onEnableInScene=function(){this.scene._lightManager._attachPointLight(this)},i._onDisableInScene=function(){this.scene._lightManager._detachPointLight(this)},s._updateShaderData=function(e,r){e.setIntArray(s._cullingMaskProperty,r.cullingMask),e.setFloatArray(s._colorProperty,r.color),e.setFloatArray(s._positionProperty,r.position),e.setFloatArray(s._distanceProperty,r.distance)},j(s,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),s}(Ha);(function(){Yn._cullingMaskProperty=O.getByName("scene_PointLightCullingMask")})();(function(){Yn._colorProperty=O.getByName("scene_PointLightColor")})();(function(){Yn._positionProperty=O.getByName("scene_PointLightPosition")})();(function(){Yn._distanceProperty=O.getByName("scene_PointLightDistance")})();var Fr=function(n){W(s,n);function s(){var t;return t=n.apply(this,arguments)||this,t.distance=100,t.angle=Math.PI/6,t.penumbra=Math.PI/12,t._inverseDirection=new R,t._projectMatrix=new Z,t}var i=s.prototype;return i._appendData=function(e,r){var a=e*2,o=e*3,c=e*3,l=e*3,_=e,u=e,h=e,d=this._getLightIntensityColor(),f=this.position,v=this.direction,p=this.cullingMask;r.cullingMask[a]=p&65535,r.cullingMask[a+1]=p>>>16&65535,this.engine.settings.colorSpace===or.Linear?(r.color[o]=q.gammaToLinearSpace(d.r),r.color[o+1]=q.gammaToLinearSpace(d.g),r.color[o+2]=q.gammaToLinearSpace(d.b)):(r.color[o]=d.r,r.color[o+1]=d.g,r.color[o+2]=d.b),r.position[c]=f.x,r.position[c+1]=f.y,r.position[c+2]=f.z,r.direction[l]=v.x,r.direction[l+1]=v.y,r.direction[l+2]=v.z,r.distance[_]=this.distance,r.angleCos[h]=Math.cos(this.angle),r.penumbraCos[u]=Math.cos(this.angle+this.penumbra)},i._onEnableInScene=function(){this.scene._lightManager._attachSpotLight(this)},i._onDisableInScene=function(){this.scene._lightManager._detachSpotLight(this)},s._updateShaderData=function(e,r){e.setIntArray(s._cullingMaskProperty,r.cullingMask),e.setFloatArray(s._colorProperty,r.color),e.setFloatArray(s._positionProperty,r.position),e.setFloatArray(s._directionProperty,r.direction),e.setFloatArray(s._distanceProperty,r.distance),e.setFloatArray(s._angleCosProperty,r.angleCos),e.setFloatArray(s._penumbraCosProperty,r.penumbraCos)},j(s,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return R.scale(this.direction,-1,this._inverseDirection),this._inverseDirection}},{key:"_shadowProjectionMatrix",get:function(){var e=this._projectMatrix,r=Math.min(Math.PI/2,this.angle*2*Math.sqrt(2));return Z.perspective(r,1,this.shadowNearPlane,this.distance+this.shadowNearPlane,e),e}}]),s}(Ha);(function(){Fr._cullingMaskProperty=O.getByName("scene_SpotLightCullingMask")})();(function(){Fr._colorProperty=O.getByName("scene_SpotLightColor")})();(function(){Fr._positionProperty=O.getByName("scene_SpotLightPosition")})();(function(){Fr._directionProperty=O.getByName("scene_SpotLightDirection")})();(function(){Fr._distanceProperty=O.getByName("scene_SpotLightDistance")})();(function(){Fr._angleCosProperty=O.getByName("scene_SpotLightAngleCos")})();(function(){Fr._penumbraCosProperty=O.getByName("scene_SpotLightPenumbraCos")})();var zn=function(){function n(){this._spotLights=new He,this._pointLights=new He,this._directLights=new He,this._directData={cullingMask:new Int32Array(n._maxLight*2),color:new Float32Array(n._maxLight*3),direction:new Float32Array(n._maxLight*3)},this._pointData={cullingMask:new Int32Array(n._maxLight*2),color:new Float32Array(n._maxLight*3),position:new Float32Array(n._maxLight*3),distance:new Float32Array(n._maxLight)},this._spotData={cullingMask:new Int32Array(n._maxLight*2),color:new Float32Array(n._maxLight*3),position:new Float32Array(n._maxLight*3),direction:new Float32Array(n._maxLight*3),distance:new Float32Array(n._maxLight),angleCos:new Float32Array(n._maxLight),penumbraCos:new Float32Array(n._maxLight)}}var s=n.prototype;return s._attachSpotLight=function(t){t._lightIndex=this._spotLights.length,this._spotLights.add(t)},s._detachSpotLight=function(t){var e=this._spotLights.deleteByIndex(t._lightIndex);e&&(e._lightIndex=t._lightIndex),t._lightIndex=-1},s._attachPointLight=function(t){t._lightIndex=this._pointLights.length,this._pointLights.add(t)},s._detachPointLight=function(t){var e=this._pointLights.deleteByIndex(t._lightIndex);e&&(e._lightIndex=t._lightIndex),t._lightIndex=-1},s._attachDirectLight=function(t){t._lightIndex=this._directLights.length,this._directLights.add(t)},s._detachDirectLight=function(t){var e=this._directLights.deleteByIndex(t._lightIndex);e&&(e._lightIndex=t._lightIndex),t._lightIndex=-1},s._updateShaderData=function(t){for(var e=this,r=e._spotLights,a=e._pointLights,o=e._directLights,c=this,l=c._spotData,_=c._pointData,u=c._directData,h=n._maxLight,d=Math.min(r.length,h),f=Math.min(a.length,h),v=Math.min(o.length,h),p=0;p0){var a=e.get(0),o=e.get(r);e.set(0,o),e.set(r,a),o._lightIndex=0,a._lightIndex=r}},s._getMaxBrightestSunlight=function(){for(var t=this._directLights,e=null,r=Number.NEGATIVE_INFINITY,a=!1,o=0,c=t.length;o=0;a--){var o=r[a];o._isActive&&(e?o._processActive(ue.Hierarchy):o._processInActive(ue.Hierarchy))}},i._updateShaderData=function(){var e=this.shaderData,r=this._engine,a=this._lightManager;r.time._updateSceneShaderData(e),a._updateShaderData(this.shaderData);var o=this._lightManager._sunlight=this._getSunlight();o?(a._updateSunlightIndex(o),e.setColor(zn._sunlightColorProperty,o._lightColor),e.setVector3(zn._sunlightDirectionProperty,o.direction)):e.setVector3(zn._sunlightDirectionProperty,R._zero),this.castShadows&&o&&o.shadowType!==dn.None?e.enableMacro("SCENE_SHADOW_TYPE",o.shadowType.toString()):e.disableMacro("SCENE_SHADOW_TYPE"),Kt.unionCollection(this.engine._macroCollection,e._macroCollection,this._globalShaderMacro)},i._removeFromEntityList=function(e){var r=this._rootEntities,a=e._siblingIndex;r.splice(a,1);for(var o=r.length;a0;)this._rootEntities[0].destroy();this.background.destroy(),this._ambientLight&&this._ambientLight._removeFromScene(this),this.shaderData._addReferCount(-1),this._componentsManager.handlingInvalidScripts();var r=e._allCreatedScenes;r.splice(r.indexOf(this),1)},i._addToRootEntityList=function(e,r){var a=this._rootEntities,o=a.length;if(e===void 0)r._siblingIndex=o,a.push(r);else{if(e<0||e>o)throw"The index "+e+" is out of child list bounds "+o;r._siblingIndex=e,a.splice(e,0,r);for(var c=e+1,l=o+1;c1!==o){t.destroy(!0);var c=new Tt(i,e,r,a,o);return c.isGCIgnored=!0,c}else return t;else{var l=new Tt(i,e,r,a,o);return l.isGCIgnored=!0,l}},n.recreateRenderTargetIfNeeded=function(i,t,e,r,a,o,c,l,_){var u,h=(u=t)==null?void 0:u.getColorTexture(0),d=a?n.recreateTextureIfNeeded(i,h,e,r,a,l):null;if(c){var f,v=(f=t)==null?void 0:f.depthTexture,p=o?n.recreateTextureIfNeeded(i,v,e,r,o,l):null;if(h!==d||v!==p){var g;(g=t)==null||g.destroy(!0),t=new Da(i,e,r,d,p,_),t.isGCIgnored=!0}}else{var y,m=o;if(h!==d||((y=t)==null?void 0:y._depthFormat)!==m){var x;(x=t)==null||x.destroy(!0),t=new Da(i,e,r,d,m,_),t.isGCIgnored=!0}}return t},n.blitTexture=function(i,t,e,r,a){r===void 0&&(r=0);var o=i._basicResources,c=e?o.flipYBlitMesh:o.blitMesh,l=o.blitMaterial,_=i._hardwareRenderer,u=i._renderContext;u.flipProjection=!!e,_.activeRenderTarget(e,a??n.defaultViewport,u.flipProjection,0);var h=n._rendererShaderData,d=l.shader.subShaders[0].passes[0],f=d._getShaderProgram(i,Se._compileMacros);h.setTexture(n._blitTextureProperty,t),h.setFloat(n._blitMipLevelProperty,r),f.bind(),f.groupingOtherUniformBlock(),f.uploadAll(f.rendererUniformBlock,h),f.uploadAll(f.materialUniformBlock,l.shaderData),f.uploadUnGroupTextures(),(d._renderState||l.renderState)._apply(i,!1,d._renderStateDataMap,l.shaderData),_.drawPrimitive(c._primitive,c.subMesh,f)},n}();(function(){cr._blitTextureProperty=O.getByName("renderer_BlitTexture")})();(function(){cr._blitMipLevelProperty=O.getByName("renderer_BlitMipLevel")})();(function(){cr._rendererShaderData=new Nr(xr.Renderer)})();(function(){cr.defaultViewport=new ie(0,0,1,1)})();var kc=function(n){W(s,n);function s(){return n.apply(this,arguments)}var i=s.prototype;return i.createVertexElements=function(e){return e[0]=new Te("POSITION",0,$.Vector3,0),e[1]=new Te("TEXCOORD_0",12,$.Vector2,0),e[2]=new Te("COLOR_0",20,$.Vector4,0),36},i.canBatch=function(e,r){if(!this._engine._canSpriteBatch||r.shaderPasses[0].getTagValue(Lr._disableBatchTag)===!0)return!1;var a=e.data,o=r.data,c=a.component,l=o.component;return!this.checkBatchWithMask(c,l)||a.texture!==o.texture?!1:a.material===o.material},i.checkBatchWithMask=function(e,r){var a=e.maskInteraction;return a!==r.maskInteraction?!1:a===ct.None?!0:e.maskLayer===r.maskLayer},i.updateVertices=function(e,r,a){for(var o=e.verticesData,c=o.positions,l=o.uvs,_=o.color,u=o.vertexCount,h=0;h=0?a.x:r.x)+l.y*(l.y>=0?a.y:r.y)+l.z*(l.z>=0?a.z:r.z)<-c.distance)return!1}return!0},n.shadowCullFrustum=function(i,t,e,r){var a=e._entity.layer;i.camera.cullingMask&a&&t.cullingMask&a&&e.castShadows&&n.cullingRenderBounds(e.bounds,r.cullPlaneCount,r.cullPlanes)&&(e._renderFrameCount=e.engine.time.frameCount,e._prepareRender(i))},n.getBoundSphereByFrustum=function(i,t,e,r,a){var o=e.aspectRatio,c=e.fieldOfView,l,_,u=Math.sqrt(1+o*o)*Math.tan(k.degreeToRadian(c)/2),h=u*u,d=t-i,f=t+i;h>d/f?(l=t,_=t*u):(l=.5*f*(1+h),_=.5*Math.sqrt(d*d+2*(t*t+i*i)*h+f*f*h*h));var v=a.splitBoundSphere.center;a.splitBoundSphere.radius=_,R.scale(r,l,v),R.add(e.entity.transform.worldPosition,v,v),a.sphereCenterZ=l},n.getDirectionLightShadowCullPlanes=function(i,t,e,r,a){var o=n._frustumCorners,c=n._backPlaneFaces,l=n._frustumPlaneNeighbors,_=n._frustumTwoPlaneCorners,u=n._edgePlanePoint2,h=a.cullPlanes,d=i.getPlane(me.Near),f=i.getPlane(me.Far),v=i.getPlane(me.Left),p=i.getPlane(me.Right),g=i.getPlane(me.Bottom),y=i.getPlane(me.Top),m=t-e,x=n._adjustNearPlane,C=n._adjustFarPlane;x.normal.copyFrom(d.normal),C.normal.copyFrom(f.normal),x.distance=d.distance-m,C.distance=Math.min(-d.distance+a.sphereCenterZ+a.splitBoundSphere.radius,f.distance),wt.intersectionPointThreePlanes(x,g,p,o[7]),wt.intersectionPointThreePlanes(x,y,p,o[6]),wt.intersectionPointThreePlanes(x,y,v,o[5]),wt.intersectionPointThreePlanes(x,g,v,o[4]),wt.intersectionPointThreePlanes(C,g,p,o[3]),wt.intersectionPointThreePlanes(C,y,p,o[2]),wt.intersectionPointThreePlanes(C,y,v,o[1]),wt.intersectionPointThreePlanes(C,g,v,o[0]);for(var b=0,A=0;A<6;A++){var S=void 0;switch(A){case me.Near:S=x;break;case me.Far:S=C;break;default:S=i.getPlane(A);break}R.dot(S.normal,r)<0&&(h[b].copyFrom(S),c[b]=A,b++)}for(var w=b,E=0;E>1),a=Math.floor(i/r)*Math.floor(t/r);return r},n.getShadowBias=function(i,t,e,r){var a=2/t.elements[0],o=a/e,c=-i.shadowBias*o,l=-i.shadowNormalBias*o;if(i.shadowType==dn.SoftHigh){var _=2.5;c*=_,l*=_}r.set(c,l)},n.applySliceTransform=function(i,t,e,r,a,o){var c=n._tempMatrix0,l=c.elements,_=1/t,u=1/e,h=i*_,d=i*u,f=a.x*_,v=a.y*u;l[0]=h,l[1]=0,l[2]=0,l[3]=0,l[4]=0,l[5]=d,l[6]=0,l[7]=0,l[8]=0,l[9]=0,l[10]=1,l[11]=0,l[12]=f,l[13]=v,l[14]=0,l[15]=1;var p=r*16;Ue._floatMatrixMultiply(c,o,p,o,p)},n.getScaleAndBiasForLinearDistanceFade=function(i,t,e){if(t<1e-4){var r=1e3;e.z=r,e.w=-i*r;return}t=1-t,t*=t;var a=t*i,o=i-a;e.z=1/o,e.w=-a/o},n}();(function(){st._tempMatrix0=new Z})();(function(){st._shadowMapCoordMatrix=new Z(.5,0,0,0,0,-.5,0,0,0,0,.5,0,.5,.5,.5,1)})();(function(){st._frustumCorners=[new R,new R,new R,new R,new R,new R,new R,new R]})();(function(){st._adjustNearPlane=new ht(new R)})();(function(){st._adjustFarPlane=new ht(new R)})();(function(){st._backPlaneFaces=new Array(5)})();(function(){st._edgePlanePoint2=new R})();(function(){st._frustumPlaneNeighbors=[[me.Left,me.Right,me.Top,me.Bottom],[me.Left,me.Right,me.Top,me.Bottom],[me.Near,me.Far,me.Top,me.Bottom],[me.Near,me.Far,me.Top,me.Bottom],[me.Near,me.Far,me.Left,me.Right],[me.Near,me.Far,me.Left,me.Right]]})();(function(){st._frustumTwoPlaneCorners=[[[8,8],[8,8],[4,5],[6,7],[7,4],[5,6]],[[8,8],[8,8],[1,0],[3,2],[0,3],[2,1]],[[5,4],[0,1],[8,8],[8,8],[4,0],[1,5]],[[7,6],[2,3],[8,8],[8,8],[3,7],[6,2]],[[4,7],[3,0],[0,4],[7,3],[8,8],[8,8]],[[6,5],[1,2],[5,1],[2,6],[8,8],[8,8]]]})();(function(){st.atlasBorderSize=4})();var Ut=function(n){W(s,n);function s(t){var e;return e=n.call(this,t.engine)||this,e._shadowMapSize=new ie,e._shadowBias=new ee,e._shadowSliceData=new ku,e._lightUp=new R,e._lightSide=new R,e._splitBoundSpheres=new Float32Array(s._maxCascades*4),e._shadowMatrices=new Float32Array((s._maxCascades+1)*16),e._shadowInfos=new ie,e._viewportOffsets=[new ee,new ee,new ee,new ee],e._camera=t,e._supportDepthTexture=t.engine._hardwareRenderer.canIUse(K.depthTexture),e._shadowSliceData.virtualCamera.isOrthographic=!0,e}var i=s.prototype;return i.onRender=function(e){var r=this._camera.scene._lightManager._sunlight;this._updateShadowSettings(),this._renderDirectShadowMap(e,r),this._updateReceiversShaderData(r)},i._renderDirectShadowMap=function(e,r){var a=this,o=a._engine,c=a._camera,l=a._viewportOffsets,_=a._shadowSliceData,u=a._splitBoundSpheres,h=a._shadowMatrices,d=c._renderPipeline._cullingResults,f=d.opaqueQueue,v=d.alphaTestQueue,p=d.transparentQueue,g=c.scene,y=g._componentsManager,m=o._hardwareRenderer,x=g.shadowCascades,C=s._cascadesSplitDistance,b=_.splitBoundSphere,A=s._tempMatrix0,S=A.elements,w=this._lightUp,E=this._lightSide,P=_.virtualCamera.forward,M=this._shadowMapSize,D=M.z,L=M.w,V=this._shadowMapFormat,N,I;this._supportDepthTexture?(N=cr.recreateRenderTargetIfNeeded(o,this._renderTarget,D,L,null,V,!0,!1,1),I=N.depthTexture):(N=cr.recreateRenderTargetIfNeeded(o,this._renderTarget,D,L,V,null,!1,!1,1),I=N.getColorTexture(0)),I.wrapModeU=I.wrapModeV=gt.Clamp,o._hardwareRenderer._isWebGL2&&(I.depthCompareFunction=vr.Less),this._renderTarget=N,this._depthTexture=I,m.activeRenderTarget(N,s._viewport,e.flipProjection,0),this._supportDepthTexture?m.clearRenderTarget(o,zt.Depth,null):m.clearRenderTarget(o,zt.All,s._clearColor),Z.rotationQuaternion(r.entity.transform.worldRotationQuaternion,A),E.set(S[0],S[1],S[2]),w.set(S[4],S[5],S[6]),P.set(-S[8],-S[9],-S[10]);var B=s._tempVector;B.copyFrom(c.entity.transform.worldForward);for(var z=this._shadowTileResolution,U=0;U1&&st.applySliceTransform(z,D,L,U,this._viewportOffsets[U],h),this._updateSingleShadowCasterShaderData(r,_,e);var Y=b.center,Q=b.radius,H=U*4;u[H]=Y.x,u[H+1]=Y.y,u[H+2]=Y.z,u[H+3]=Q*Q,f.clear(),v.clear(),p.clear();for(var te=y._renderers,Ce=te._elements,de=te.length-1;de>=0;--de)st.shadowCullFrustum(e,r,Ce[de],_);if(f.elements.length||v.elements.length){f.sort(rn._compareFromNearToFar),v.sort(rn._compareFromNearToFar);var ae=l[U],Ae=ae.x,je=ae.y;m.setGlobalDepthBias(1,1),m.viewport(Ae,je,z,z),m.scissor(Ae+1,je+1,z-2,z-2),o._renderCount++,f.render(c,Ot.ShadowCaster),v.render(c,Ot.ShadowCaster),m.setGlobalDepthBias(0,0)}}},i._updateReceiversShaderData=function(e){var r=this._camera,a=r.scene,o=this._splitBoundSpheres,c=this._shadowMatrices,l=a.shadowCascades,_=Math.min(a.shadowDistance,r.farClipPlane);if(st.getScaleAndBiasForLinearDistanceFade(Math.pow(_,2),a.shadowFadeBorder,this._shadowInfos),this._shadowInfos.x=e.shadowStrength,l>1)for(var u=l*4,h=o.length;u=0;--c){var l=o[c];e.cullingMask&l._entity.layer&&(e.enableFrustumCulling&&!e._frustum.intersectsBox(l.bounds)||(l._renderFrameCount=r.time.frameCount,l._prepareRender(t)))}},s._updateMVPShaderData=function(t){for(var e=t.camera,r=e.scene._componentsManager._renderers,a=r._elements,o=r.length-1;o>=0;--o){var c=a[o];c._updateShaderData(t,!0)}},n}(),cs;(function(n){n[n.None=0]="None",n[n.Opaque=1]="Opaque",n[n.AlphaTest=2]="AlphaTest",n[n.Transparent=4]="Transparent"})(cs||(cs={}));var Fa;(function(n){n[n.Normal=0]="Normal",n[n.XRCenterCamera=1]="XRCenterCamera",n[n.XRLeftCamera=2]="XRLeftCamera",n[n.XRRightCamera=4]="XRRightCamera"})(Fa||(Fa={}));var Si;(function(n){n[n.None=1]="None",n[n.TwoX=2]="TwoX",n[n.FourX=4]="FourX",n[n.EightX=8]="EightX"})(Si||(Si={}));var $r,Un=function(){};(function(){Un.tempVec4=new ie})();(function(){Un.tempVec3=new R})();(function(){Un.tempVec2=new ee})();var ze=($r=function(n){W(s,n);function s(t){var e;e=n.call(this,t)||this,e.enableFrustumCulling=!0,e.clearFlags=zt.All,e.cullingMask=An.Everything,e.depthTextureMode=Va.None,e.opaqueTextureDownsampling=da.TwoX,e.msaaSamples=Si.None,e._cameraType=Fa.Normal,e._globalShaderMacro=new Kt,e._frustum=new il,e._virtualCamera=new Gc,e._replacementShader=null,e._replacementSubShaderTag=null,e._cameraIndex=-1,e._priority=0,e._shaderData=new Nr(xr.Camera),e._isCustomViewMatrix=!1,e._isCustomProjectionMatrix=!1,e._fieldOfView=45,e._orthographicSize=10,e._isProjectionDirty=!0,e._isInvProjMatDirty=!0,e._customAspectRatio=void 0,e._renderTarget=null,e._depthBufferParams=new ie,e._opaqueTextureEnabled=!1,e._viewport=new ie(0,0,1,1),e._pixelViewport=new Gr(0,0,0,0),e._inverseProjectionMatrix=new Z,e._invViewProjMat=new Z;var r=e.entity.transform;return e._transform=r,e._isViewMatrixDirty=r.registerWorldChangeFlag(),e._isInvViewProjDirty=r.registerWorldChangeFlag(),e._frustumChangeFlag=r.registerWorldChangeFlag(),e._renderPipeline=new Hc(ce(e)),e._addResourceReferCount(e.shaderData,1),e._updatePixelViewport(),e._onPixelViewportChanged=e._onPixelViewportChanged.bind(ce(e)),e._viewport._onValueChanged=e._onPixelViewportChanged,e.engine.canvas._sizeUpdateFlagManager.addListener(e._onPixelViewportChanged),e}var i=s.prototype;return i.resetViewMatrix=function(){this._isCustomViewMatrix=!1,this._viewMatrixChange()},i.resetProjectionMatrix=function(){this._isCustomProjectionMatrix=!1,this._projectionMatrixChange()},i.resetAspectRatio=function(){this._customAspectRatio=void 0,this._projectionMatrixChange()},i.worldToViewportPoint=function(e,r){var a=Un.tempVec3,o=Un.tempVec4;R.transformCoordinate(e,this.viewMatrix,a),R.transformToVec4(a,this.projectionMatrix,o);var c=o.w;return r.set((o.x/c+1)*.5,(1-o.y/c)*.5,-a.z),r},i.viewportToWorldPoint=function(e,r){var a=this,o=a.nearClipPlane,c=a.farClipPlane,l=1/(o-c),_;if(this.isOrthographic)_=-e.z*2*l,_+=(c+o)*l;else{var u=e.z;_=-u*(o+c)*l,_+=2*o*c*l,_=_/u}return this._innerViewportToWorldPoint(e.x,e.y,(_+1)/2,this._getInvViewProjMat(),r),r},i.viewportPointToRay=function(e,r){var a=this._getInvViewProjMat(),o=this._innerViewportToWorldPoint(e.x,e.y,0,a,r.origin),c=this._innerViewportToWorldPoint(e.x,e.y,1-k.zeroTolerance,a,r.direction);return R.subtract(c,o,c),c.normalize(),r},i.screenToViewportPoint=function(e,r){var a=this.engine.canvas,o=this.viewport;return r.x=(e.x/a.width-o.x)/o.z,r.y=(e.y/a.height-o.y)/o.w,e.z!==void 0&&(r.z=e.z),r},i.viewportToScreenPoint=function(e,r){var a=this.engine.canvas,o=this.viewport;return r.x=(o.x+e.x*o.z)*a.width,r.y=(o.y+e.y*o.w)*a.height,e.z!==void 0&&(r.z=e.z),r},i.worldToScreenPoint=function(e,r){return this.worldToViewportPoint(e,r),this.viewportToScreenPoint(r,r)},i.screenToWorldPoint=function(e,r){return this.screenToViewportPoint(e,r),this.viewportToWorldPoint(r,r)},i.screenPointToRay=function(e,r){var a=Un.tempVec2;return this.screenToViewportPoint(e,a),this.viewportPointToRay(a,r)},i.render=function(e,r){r===void 0&&(r=0);var a=this.engine._renderContext,o=this._virtualCamera,c=this.entity.transform;Z.multiply(this.projectionMatrix,this.viewMatrix,o.viewProjectionMatrix),o.position.copyFrom(c.worldPosition),o.isOrthographic&&o.forward.copyFrom(c.worldForward),a.camera=this,a.virtualCamera=o,a.replacementShader=this._replacementShader,a.replacementTag=this._replacementSubShaderTag,this.enableFrustumCulling&&this._frustumChangeFlag.flag&&(this._frustum.calculateFromMatrix(o.viewProjectionMatrix),this._frustumChangeFlag.flag=!1),this._updateShaderData(),Kt.unionCollection(this.scene._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro),r>0&&!this.engine._hardwareRenderer.isWebGL2&&(r=0,ve.error("mipLevel only take effect in WebGL2.0"));var l;this._cameraType!==Fa.Normal&&(l=this.engine.xrManager._getCameraClearFlagsMask(this._cameraType)),this._renderPipeline.render(a,e,r,l),this._engine._renderCount++},i.setReplacementShader=function(e,r){this._replacementShader=e,this._replacementSubShaderTag=typeof r=="string"?sn.getByName(r):r},i.resetReplacementShader=function(){this._replacementShader=null,this._replacementSubShaderTag=null},i._onEnableInScene=function(){this.scene._componentsManager.addCamera(this)},i._onDisableInScene=function(){this.scene._componentsManager.removeCamera(this)},i._onDestroy=function(){var e;n.prototype._onDestroy.call(this),(e=this._renderPipeline)==null||e.destroy(),this._isInvViewProjDirty.destroy(),this._isViewMatrixDirty.destroy(),this._addResourceReferCount(this.shaderData,-1),this._viewport._onValueChanged=null,this.engine.canvas._sizeUpdateFlagManager.removeListener(this._onPixelViewportChanged),this._entity=null,this._globalShaderMacro=null,this._frustum=null,this._renderPipeline=null,this._virtualCamera=null,this._shaderData=null,this._frustumChangeFlag=null,this._transform=null,this._isViewMatrixDirty=null,this._isInvViewProjDirty=null,this._viewport=null,this._inverseProjectionMatrix=null,this._invViewProjMat=null},i._updatePixelViewport=function(){var e,r,a=this._renderTarget;if(a)e=a.width,r=a.height;else{var o=this.engine.canvas;e=o.width,r=o.height}var c=this._viewport;this._pixelViewport.set(c.x*e,c.y*r,c.z*e,c.w*r)},i._viewMatrixChange=function(){this._isViewMatrixDirty.flag=!0,this._isInvViewProjDirty.flag=!0,this._frustumChangeFlag.flag=!0},i._projectionMatrixChange=function(){this._isProjectionDirty=!0,this._isInvProjMatDirty=!0,this._isInvViewProjDirty.flag=!0,this._frustumChangeFlag.flag=!0},i._innerViewportToWorldPoint=function(e,r,a,o,c){var l=Un.tempVec3;return l.set(e*2-1,1-r*2,a*2-1),R.transformCoordinate(l,o,c),c},i._updateShaderData=function(){var e=this.shaderData,r=this._transform;e.setMatrix(ze._inverseViewMatrixProperty,r.worldMatrix),e.setVector3(ze._cameraPositionProperty,r.worldPosition),e.setVector3(ze._cameraForwardProperty,r.worldForward),e.setVector3(ze._cameraUpProperty,r.worldUp);var a=this._depthBufferParams,o=this.farClipPlane/this.nearClipPlane;a.set(1-o,o,0,0),e.setVector4(ze._cameraDepthBufferParamsProperty,a)},i._getInvViewProjMat=function(){return this._isInvViewProjDirty.flag&&(this._isInvViewProjDirty.flag=!1,Z.multiply(this._transform.worldMatrix,this._getInverseProjectionMatrix(),this._invViewProjMat)),this._invViewProjMat},i._getInverseProjectionMatrix=function(){return this._isInvProjMatDirty&&(this._isInvProjMatDirty=!1,Z.invert(this.projectionMatrix,this._inverseProjectionMatrix)),this._inverseProjectionMatrix},i._forceUseInternalCanvas=function(){return this.opaqueTextureEnabled},i._onPixelViewportChanged=function(){this._updatePixelViewport();var e;(e=this._customAspectRatio)!=null||this._projectionMatrixChange(),this._checkMainCanvasAntialiasWaste()},i._checkMainCanvasAntialiasWaste=function(){this.independentCanvasEnabled&&ie.equals(this._viewport,cr.defaultViewport)&&console.warn("Camera use independent canvas and viewport cover the whole screen, it is recommended to disable antialias, depth and stencil to save memory when create engine.")},j(s,[{key:"opaqueTextureEnabled",get:function(){return this._opaqueTextureEnabled},set:function(e){this._opaqueTextureEnabled!==e&&(this._opaqueTextureEnabled=e,this._checkMainCanvasAntialiasWaste())}},{key:"independentCanvasEnabled",get:function(){return this._renderTarget?!1:this._forceUseInternalCanvas()}},{key:"shaderData",get:function(){return this._shaderData}},{key:"nearClipPlane",get:function(){return this._virtualCamera.nearClipPlane},set:function(e){this._virtualCamera.nearClipPlane=e,this._projectionMatrixChange()}},{key:"farClipPlane",get:function(){return this._virtualCamera.farClipPlane},set:function(e){this._virtualCamera.farClipPlane=e,this._projectionMatrixChange()}},{key:"fieldOfView",get:function(){return this._fieldOfView},set:function(e){this._fieldOfView=e,this._projectionMatrixChange()}},{key:"aspectRatio",get:function(){var e=this.pixelViewport,r;return(r=this._customAspectRatio)!=null?r:e.width/e.height},set:function(e){this._customAspectRatio=e,this._projectionMatrixChange()}},{key:"viewport",get:function(){return this._viewport},set:function(e){e!==this._viewport&&this._viewport.copyFrom(e)}},{key:"pixelViewport",get:function(){return this._pixelViewport}},{key:"priority",get:function(){return this._priority},set:function(e){this._priority!==e&&(this._phasedActiveInScene&&(this.scene._componentsManager._cameraNeedSorting=!0),this._priority=e)}},{key:"isOrthographic",get:function(){return this._virtualCamera.isOrthographic},set:function(e){this._virtualCamera.isOrthographic=e,this._projectionMatrixChange(),e?this.shaderData.enableMacro("CAMERA_ORTHOGRAPHIC"):this.shaderData.disableMacro("CAMERA_ORTHOGRAPHIC")}},{key:"orthographicSize",get:function(){return this._orthographicSize},set:function(e){this._orthographicSize=e,this._projectionMatrixChange()}},{key:"viewMatrix",get:function(){var e=this._virtualCamera.viewMatrix;if(!this._isViewMatrixDirty.flag||this._isCustomViewMatrix)return e;this._isViewMatrixDirty.flag=!1;var r=this._transform;return Z.rotationTranslation(r.worldRotationQuaternion,r.worldPosition,e),e.invert(),e},set:function(e){this._virtualCamera.viewMatrix.copyFrom(e),this._isCustomViewMatrix=!0,this._viewMatrixChange()}},{key:"projectionMatrix",get:function(){var e=this._virtualCamera,r=e.projectionMatrix;if(!this._isProjectionDirty||this._isCustomProjectionMatrix)return r;this._isProjectionDirty=!1;var a=this.aspectRatio;if(!e.isOrthographic)Z.perspective(k.degreeToRadian(this._fieldOfView),a,this.nearClipPlane,this.farClipPlane,r);else{var o=this._orthographicSize*a,c=this._orthographicSize;Z.ortho(-o,o,-c,c,this.nearClipPlane,this.farClipPlane,r)}return r},set:function(e){this._virtualCamera.projectionMatrix.copyFrom(e),this._isCustomProjectionMatrix=!0,this._projectionMatrixChange()}},{key:"enableHDR",get:function(){return console.log("not implementation"),!1},set:function(e){console.log("not implementation")}},{key:"renderTarget",get:function(){return this._renderTarget},set:function(e){this._renderTarget!==e&&(this._renderTarget&&this._addResourceReferCount(this._renderTarget,-1),e&&this._addResourceReferCount(e,1),this._renderTarget=e,this._onPixelViewportChanged(),this._checkMainCanvasAntialiasWaste())}}]),s}(Rt),function(){$r._cameraDepthTextureProperty=O.getByName("camera_DepthTexture")}(),function(){$r._cameraOpaqueTextureProperty=O.getByName("camera_OpaqueTexture")}(),function(){$r._inverseViewMatrixProperty=O.getByName("camera_ViewInvMat")}(),function(){$r._cameraPositionProperty=O.getByName("camera_Position")}(),function(){$r._cameraForwardProperty=O.getByName("camera_Forward")}(),function(){$r._cameraUpProperty=O.getByName("camera_Up")}(),function(){$r._cameraDepthBufferParamsProperty=O.getByName("camera_DepthBufferParams")}(),$r);T([J],ze.prototype,"_frustum",void 0);T([F],ze.prototype,"_renderPipeline",void 0);T([F],ze.prototype,"_virtualCamera",void 0);T([F],ze.prototype,"_cameraIndex",void 0);T([F],ze.prototype,"_frustumChangeFlag",void 0);T([F],ze.prototype,"_transform",void 0);T([F],ze.prototype,"_isViewMatrixDirty",void 0);T([F],ze.prototype,"_isInvViewProjDirty",void 0);T([J],ze.prototype,"_viewport",void 0);T([J],ze.prototype,"_pixelViewport",void 0);T([J],ze.prototype,"_inverseProjectionMatrix",void 0);T([J],ze.prototype,"_invViewProjMat",void 0);T([F],ze.prototype,"_onPixelViewportChanged",null);ze=T([ka(ge,Hn.CheckOnly)],ze);var Xu={json:"json",gltf:"json",mtl:"json",prefab:"json",txt:"text",bin:"arraybuffer",png:"image",webp:"image",jpg:"image"},ju=1,qu=1/0,Yu=500;function Qn(n,s){return s===void 0&&(s={}),new Pe(function(i,t,e,r){var a,o=(a=s.retryCount)!=null?a:ju,c,l=(c=s.retryInterval)!=null?c:Yu,_;s.timeout=(_=s.timeout)!=null?_:qu;var u;s.type=(u=s.type)!=null?u:Ku(n);var h=new Ju(function(){return Qu(n,s).onProgress(e,r)},o,l);h.start().onError(t).onComplete(i)})}function Qu(n,s){return new Pe(function(i,t,e,r){var a=new XMLHttpRequest,o=s.type==="image";a.timeout=s.timeout;var c;s.method=(c=s.method)!=null?c:"get",a.onload=function(){if(a.status<200||a.status>=300){t(new Error("request failed from: "+n));return}var _,u=(_=a.response)!=null?_:a.responseText;if(o){var h=new Image;h.onload=function(){requestAnimationFrame(function(){e(1,1),i(h),h.onload=null,h.onerror=null,h.onabort=null,URL.revokeObjectURL(h.src)})},h.onerror=h.onabort=function(){t(new Error("request "+h.src+" fail")),URL.revokeObjectURL(h.src)},h.crossOrigin="anonymous",h.src=URL.createObjectURL(u)}else e(1,1),i(u)},a.onerror=function(){t(new Error("request failed from: "+n))},a.ontimeout=function(){t(new Error("request timeout from: "+n))},a.onprogress=function(_){_.lengthComputable&&r(n,_.loaded,_.total)},a.open(s.method,n,!0),a.withCredentials=s.credentials==="include",a.responseType=o?"blob":s.type;var l=s.headers;l&&Object.keys(l).forEach(function(_){a.setRequestHeader(_,l[_])}),a.send(s.body)})}function Ku(n){var s=n.substring(n.lastIndexOf(".")+1);return Xu[s]}var Ju=function(){function n(i,t,e){this.execFunc=i,this.totalCount=t,this.interval=e,this._timeoutId=-100,this._currentCount=0,this.exec=this.exec.bind(this)}var s=n.prototype;return s.start=function(){return this.exec(),this},s.onComplete=function(t){return this._onComplete=t,this},s.onError=function(t){return this._onError=t,this},s.cancel=function(){window.clearTimeout(this._timeoutId)},s.exec=function(){var t=this;if(this._currentCount>=this.totalCount){this._onError&&this._onError(this._error);return}this._currentCount++,this.execFunc(this._currentCount).then(function(e){return t._onComplete&&t._onComplete(e)}).catch(function(e){t._error=e,t._timeoutId=window.setTimeout(t.exec,t.interval)})},n}(),Be=function(){function n(s){this.useCache=s,this.request=Qn}return n.registerClass=function(i,t){this._engineObjects[i]=t,this._classNameMap.set(t,i)},n.getClass=function(i){return this._engineObjects[i]},n.getClassName=function(i){return this._classNameMap.get(i)},n}();(function(){Be._engineObjects={}})();(function(){Be._classNameMap=new Map})();var Zu=function(){function n(){}var s=n.prototype;return s.initialize=function(t){var e=t.component,r=t.property.split(".");if(t.getProperty){var a=t.getProperty.split(".");this._initializeMounted(e,a,1),this._initializeMounted(e,r,2)}else this._initializeMounted(e,r,3)},s.getTargetValue=function(){switch(this._getType){case 2:return this._getMounted[this._getArrayIndex];case 1:return this._getMounted[this._getValueName].apply(this._getMounted,this._getArgs);case 0:return this._getMounted[this._getValueName]}},s.setTargetValue=function(t){switch(this._setType){case 2:this._setMounted[this._setArrayIndex]=t;break;case 1:var e=this._setArgs;e[this._replaceValueIndex]=t,this._setMounted[this._setValueName].apply(this._setMounted,e);break;case 0:this._setMounted[this._setValueName]=t;break}},s._initializeMounted=function(t,e,r){for(var a=e.length-1,o=0;o-1){var l=c.indexOf("[");t=t[c.slice(0,l)],t=t[parseInt(c.slice(l+1,-1))]}else if(c.endsWith(")")){var _=c.slice(0,c.indexOf("(")),u=c.match(/\w+\(([^)]*)\)/)[1].split(",").map(function(m){return m.trim().replace(/['"]+/g,"")}).filter(function(m){return m!==""});t=t[_].apply(t,u)}else t=t[c]}var h=e[a],d,f,v,p;if(h.indexOf("[")>-1){var g=h.indexOf("[");d=2,t=t[h.slice(0,g)],f=parseInt(h.slice(g+1,-1))}else if(h.endsWith(")")){if(v=h.slice(0,h.indexOf("(")),p=h.match(/\w+\(([^)]*)\)/)[1].split(",").map(function(m){return m.trim().replace(/['"]+/g,"")}).filter(function(m){return m!==""}),d=1,r&2){var y=p.indexOf("$value");this._replaceValueIndex=y>-1?y:p.length}}else d=0;r&2&&(this._setMounted=t,this._setType=d,this._setArrayIndex=f,this._setValueName=h,v&&(this._setValueName=v),this._setArgs=p),r&1&&(this._getMounted=t,this._getType=d,this._getArrayIndex=f,this._getValueName=h,v&&(this._getValueName=v),this._getArgs=p)},n}(),ls;(function(n){n[n.Property=0]="Property",n[n.Method=1]="Method",n[n.Array=2]="Array"})(ls||(ls={}));var _s;(function(n){n[n.Get=1]="Get",n[n.Set=2]="Set",n[n.Both=3]="Both"})(_s||(_s={}));var fn=function(){function n(i,t,e,r,a,o){this.baseEvaluateData={curKeyframeIndex:0,value:null},this.crossEvaluateData={curKeyframeIndex:0,value:null},this.updateMark=0,this.target=i,this.property=r,this.getProperty=a,this.component=e,this.cureType=o;var c=n.getAssemblerType(t,r);this._assembler=new c,this._assembler.initialize(this),o._isCopyMode&&(this.referenceTargetValue=this._assembler.getTargetValue())}var s=n.prototype;return s.evaluateValue=function(t,e,r){return r?t._evaluateAdditive(e,this.baseEvaluateData):t._evaluate(e,this.baseEvaluateData)},s.evaluateCrossFadeValue=function(t,e,r,a,o,c){if(!this.cureType._supportInterpolationMode)return this.evaluateValue(e,a,!1);var l=t&&t.keys.length?c?t._evaluateAdditive(r,this.baseEvaluateData):t._evaluate(r,this.baseEvaluateData):c?this.cureType._getZeroValue(this.baseEvaluateData.value):this.defaultValue,_=e&&e.keys.length?c?e._evaluateAdditive(a,this.crossEvaluateData):e._evaluate(a,this.crossEvaluateData):c?this.cureType._getZeroValue(this.crossEvaluateData.value):this.defaultValue;return this._lerpValue(l,_,o)},s.crossFadeFromPoseAndApplyValue=function(t,e,r,a){if(!this.cureType._supportInterpolationMode)return this.evaluateValue(t,e,!1);var o=a?this.cureType._subtractValue(this.fixedPoseValue,this.defaultValue,this.baseEvaluateData.value):this.fixedPoseValue,c=t&&t.keys.length?a?t._evaluateAdditive(e,this.crossEvaluateData):t._evaluate(e,this.crossEvaluateData):a?this.cureType._getZeroValue(this.crossEvaluateData.value):this.defaultValue;return this._lerpValue(o,c,r)},s.revertDefaultValue=function(){this._assembler.setTargetValue(this.defaultValue)},s.getEvaluateValue=function(t){return this.cureType._isCopyMode?(this.cureType._setValue(this.baseEvaluateData.value,t),t):this.baseEvaluateData.value},s.saveDefaultValue=function(){this.cureType._isCopyMode?this.cureType._setValue(this.referenceTargetValue,this.defaultValue):this.defaultValue=this._assembler.getTargetValue()},s.saveFixedPoseValue=function(){this.cureType._isCopyMode?this.cureType._setValue(this.referenceTargetValue,this.fixedPoseValue):this.fixedPoseValue=this._assembler.getTargetValue()},s.applyValue=function(t,e,r){var a=this.cureType;if(r){var o=this._assembler;if(a._isCopyMode)a._additiveValue(t,e,this.referenceTargetValue);else{var c=o.getTargetValue(),l=a._additiveValue(t,e,c);o.setTargetValue(l)}}else if(e===1)a._isCopyMode?a._setValue(t,this.referenceTargetValue):this._assembler.setTargetValue(t);else if(a._isCopyMode){var _=this.referenceTargetValue;a._lerpValue(_,t,e,_)}else{var u=this._assembler.getTargetValue(),h=a._lerpValue(u,t,e);this._assembler.setTargetValue(h)}},s._lerpValue=function(t,e,r){return this.cureType._isCopyMode?this.cureType._lerpValue(t,e,r,this.baseEvaluateData.value):(this.baseEvaluateData.value=this.cureType._lerpValue(t,e,r),this.baseEvaluateData.value)},n.registerAssembler=function(t,e,r){var a=n._assemblerMap.get(t);a||(a={},n._assemblerMap.set(t,a)),a[e]=r},n.getAssemblerType=function(t,e){var r=n._assemblerMap.get(t),a=r?r[e]:void 0;return a??Zu},n}();(function(){fn._components=[]})();(function(){fn._assemblerMap=new Map})();var $u=function(){function n(){}var s=n.prototype;return s.initialize=function(t){this._transform=t.target.transform},s.getTargetValue=function(){return this._transform.position},s.setTargetValue=function(t){this._transform.position=t},n}();fn.registerAssembler(ge,"position",$u);var eh=function(){function n(){}var s=n.prototype;return s.initialize=function(t){this._transform=t.target.transform},s.getTargetValue=function(){return this._transform.rotationQuaternion},s.setTargetValue=function(t){this._transform.rotationQuaternion=t},n}();fn.registerAssembler(ge,"rotationQuaternion",eh);var th=function(){function n(){}var s=n.prototype;return s.initialize=function(t){this._transform=t.target.transform},s.getTargetValue=function(){return this._transform.scale},s.setTargetValue=function(t){this._transform.scale=t},n}();fn.registerAssembler(ge,"scale",th);var rh=function(){function n(){}var s=n.prototype;return s.initialize=function(t){this._skinnedMeshRenderer=t.component},s.getTargetValue=function(){return this._skinnedMeshRenderer.blendShapeWeights},s.setTargetValue=function(t){this._skinnedMeshRenderer.blendShapeWeights=t},n}();fn.registerAssembler(Dt,"blendShapeWeights",rh);var nh=function(){function n(){this.crossCurveMark=0,this.isActive=!0}var s=n.prototype;return s.initFinalValue=function(){var t=this.curveOwner,e=t.cureType,r=t.defaultValue;e._isCopyMode?e._setValue(r,this.finalValue):this.finalValue=r},s.saveFinalValue=function(){this.finalValue=this.curveOwner.getEvaluateValue(this.finalValue)},n}(),Wc=function(){function n(){this.typeIndex=0,this._tempCurveOwner={}}var s=n.prototype;return s._createCurveOwner=function(t,e){var r=this.curve.constructor,a=new fn(t,this.type,e,this.property,this.getProperty,r);return r._initializeOwner(a),a.saveDefaultValue(),a},s._createCurveLayerOwner=function(t){var e=this.curve.constructor,r=new nh;return r.curveOwner=t,e._initializeLayerOwner(r),r.initFinalValue(),r},s._getTempCurveOwner=function(t,e){var r=t.instanceId;return this._tempCurveOwner[r]||(this._tempCurveOwner[r]=this._createCurveOwner(t,e)),this._tempCurveOwner[r]},n}(),ji=function(){},Vo=function(n){W(s,n);function s(t){var e;return e=n.call(this,null)||this,e.name=t,e._curveBindings=[],e._updateFlagManager=new Er,e._length=0,e._events=[],e}var i=s.prototype;return i.addEvent=function(e,r,a){var o;if(typeof e=="string"){var c=new ji;c.functionName=e,c.time=r,c.parameter=a,o=c}else o=e;var l=this._events,_=l.length,u=o.time,h=_?l[_-1].time:0;if(u>=h)l.push(o);else{for(var d=_;--d>=0&&u=0;c--){var l=o[c],_=e.findByPath(l.relativePath);if(_){var u=l.typeIndex>0?_.getComponents(l.type,fn._components)[l.typeIndex]:_.getComponent(l.type);if(!u)continue;var h=l._getTempCurveOwner(_,u);if(h&&l.curve.keys.length){var d=h.evaluateValue(l.curve,r,!1);h.applyValue(d,1,!1)}}}},j(s,[{key:"events",get:function(){return this._events}},{key:"curveBindings",get:function(){return this._curveBindings}},{key:"length",get:function(){return this._length}}]),s}(Yr),xt;(function(n){n[n.Linear=0]="Linear",n[n.CubicSpine=1]="CubicSpine",n[n.Step=2]="Step",n[n.Hermite=3]="Hermite"})(xt||(xt={}));var _r=function(){function n(){this.keys=[],this._evaluateData={curKeyframeIndex:0,value:null},this._length=0;var i=this.constructor;this._interpolation=i._supportInterpolationMode?xt.Linear:xt.Step,this._type=i}var s=n.prototype;return s.addKey=function(t){var e=t.time,r=this.keys;if(e>=this._length)r.push(t),this._length=e;else{for(var a=r.length;--a>=0&&e=0;a--){var o=e[a];o.time>this._length&&(r=o.time)}this._length=r},s._evaluate=function(t,e){var r=this.keys.length;if(!r){console.warn("This curve don't have any keyframes: ",this);return}var a=this,o=a.keys,c=a.interpolation,l=e.curKeyframeIndex;l!==-1&&(l>=r||ta&&(r=r<0?-a:a,this.playState=pt.Finished),t&&r===0?this.clipTime=e.clipEndTime*e.clip.length:(r<0&&(r+=a),this.clipTime=r+e.clipStartTime*e.clip.length)},n}(),ih=function(){function n(){this.curveOwnerPool=Object.create(null),this.animatorStateDataMap={},this.srcPlayData=new us,this.destPlayData=new us,this.layerState=Ye.Standby,this.crossCurveMark=0,this.manuallyTransition=new Fo,this.crossLayerOwnerCollection=[]}var s=n.prototype;return s.switchPlayData=function(){var t=this.destPlayData,e=this.srcPlayData;this.srcPlayData=t,this.destPlayData=e},n}(),oh=function(){this.curveLayerOwner=[],this.eventHandlers=[]},Kr=function(n){W(s,n);function s(t){var e;return e=n.call(this,t)||this,e.cullingMode=Oa.None,e.speed=1,e._playFrameCount=-1,e._onUpdateIndex=-1,e._updateMark=0,e._animatorLayersData=[],e._curveOwnerPool=Object.create(null),e._animationEventHandlerPool=new Fn(ah),e._tempAnimatorStateInfo={layerIndex:-1,state:null},e._controlledRenderers=[],e}var i=s.prototype;return i.play=function(e,r,a){r===void 0&&(r=-1),a===void 0&&(a=0);var o;(o=this._controllerUpdateFlag)!=null&&o.flag&&this._reset(),this._playFrameCount=this.engine.time.frameCount;var c=this._getAnimatorStateInfo(e,r),l=c.state,_=c.layerIndex;if(l){if(!l.clip){ve.warn("The state named "+e+" has no AnimationClip data.");return}var u=this._getAnimatorLayerData(_),h=this._getAnimatorStateData(e,l,u,_);this._preparePlay(u,l),u.layerState=Ye.Playing,u.srcPlayData.reset(l,h,l._getDuration()*a),this.update(0)}},i.crossFade=function(e,r,a,o){a===void 0&&(a=-1),o===void 0&&(o=0);var c;(c=this._controllerUpdateFlag)!=null&&c.flag&&this._reset(),this._playFrameCount=this.engine.time.frameCount;var l=this._getAnimatorStateInfo(e,a),_=l.state,u=l.layerIndex,h=this._getAnimatorLayerData(u).manuallyTransition;h.duration=r,h.offset=o,h.destinationState=_,this._crossFadeByTransition(h,u)&&this.update(0)},i.update=function(e){var r,a;if(this.cullingMode===Oa.Complete){a=!1;for(var o=this._controlledRenderers,c=0,l=o.length;c=0;p--){var g=f[p],y=g.relativePath,m=g.relativePath===""?l:l.findByPath(g.relativePath);if(m){var x,C,b,A,S,w,E,P,M=g.typeIndex>0?m.getComponents(g.type,fn._components)[g.typeIndex]:m.getComponent(g.type);if(!M)continue;var D=g.property,L=M.instanceId,V=(x=_)[C=L]||(x[C]=Object.create(null)),N=(b=V)[A=D]||(b[A]=g._createCurveOwner(m,M)),I=(S=v)[w=L]||(S[w]=Object.create(null)),B=(E=I)[P=D]||(E[P]=g._createCurveLayerOwner(N));if(u&&u.pathMasks.length){var z,U;B.isActive=(U=(z=u.getPathMask(y))==null?void 0:z.active)!=null?U:!0}h[p]=B}else h[p]=null,ve.warn("The entity don't have the child entity which path is "+g.relativePath+".")}},i._saveAnimatorEventHandlers=function(e,r){var a=this,o=this._animationEventHandlerPool,c=[],l=r.eventHandlers,_=function(){a._entity.getComponents(zr,c);var u=c.length,h=e.clip.events;l.length=0;for(var d=0,f=h.length;d=0;m--){var x=c[m][g];x&&y.push(x)}l.push(p)}};_(),e._updateFlagManager.addListener(_)},i._clearCrossData=function(e){e.crossCurveMark++,e.crossLayerOwnerCollection.length=0},i._addCrossOwner=function(e,r,a,o){r.crossSrcCurveIndex=a,r.crossDestCurveIndex=o,e.crossLayerOwnerCollection.push(r)},i._prepareCrossFading=function(e){this._prepareSrcCrossData(e,!1),this._prepareDestCrossData(e,!1)},i._prepareStandbyCrossFading=function(e){e.srcPlayData.state&&this._prepareSrcCrossData(e,!0),this._prepareDestCrossData(e,!0)},i._prepareFixedPoseCrossFading=function(e){for(var r=e.crossLayerOwnerCollection,a=r.length-1;a>=0;a--){var o=r[a];o&&(o.curveOwner.saveFixedPoseValue(),o.crossDestCurveIndex=-1)}this._prepareDestCrossData(e,!0)},i._prepareSrcCrossData=function(e,r){for(var a=e.srcPlayData.stateData.curveLayerOwner,o=a.length-1;o>=0;o--){var c=a[o];c&&(c.crossCurveMark=e.crossCurveMark,r&&c.curveOwner.saveFixedPoseValue(),this._addCrossOwner(e,c,o,-1))}},i._prepareDestCrossData=function(e,r){for(var a=e.destPlayData.stateData.curveLayerOwner,o=a.length-1;o>=0;o--){var c=a[o];if(c)if(c.crossCurveMark===e.crossCurveMark)c.crossDestCurveIndex=o;else{var l=c.curveOwner;r&&l.saveFixedPoseValue(),c.crossCurveMark=e.crossCurveMark,this._addCrossOwner(e,c,-1,o)}}},i._getAnimatorLayerData=function(e){var r=this._animatorLayersData[e];return r||(this._animatorLayersData[e]=r=new ih),r},i._updateLayer=function(e,r,a,o){var c=this._animatorController.layers[e],l=c.blendingMode,_=c.weight,u=this._animatorLayersData[e],h=u.srcPlayData,d=u.destPlayData,f=l===za.Additive;switch(r&&(_=1),u.layerState){case Ye.Playing:this._updatePlayingState(h,u,e,_,a,f,o);break;case Ye.FixedCrossFading:this._updateCrossFadeFromPose(d,u,e,_,a,f,o);break;case Ye.CrossFading:this._updateCrossFade(h,d,u,e,_,a,f,o);break;case Ye.Finished:this._updateFinishedState(h,_,f,o);break}},i._updatePlayingState=function(e,r,a,o,c,l,_){var u=e.stateData,h=u.curveLayerOwner,d=u.eventHandlers,f=e.state,v=e.playState,p=e.clipTime,g=f.transitions,y=f.clip,m=y._curveBindings,x=f.speed*this.speed;e.frameTime+=x*c,e.update(x<0);var C=e.clipTime,b=e.playState,A=b===pt.Finished;if(_||A)for(var S=m.length-1;S>=0;S--){var w,E=h[S],P=(w=E)==null?void 0:w.curveOwner;if(!(!P||!E.isActive)){var M=m[S].curve;if(M.keys.length){this._checkRevertOwner(P,l);var D=P.evaluateValue(M,C,l);_&&P.applyValue(D,o,l),A&&E.saveFinalValue()}}}if(b===pt.Finished&&(r.layerState=Ye.Finished),d.length&&this._fireAnimationEvents(e,d,p,C),v===pt.UnStarted&&this._callAnimatorScriptOnEnter(f,a),b===pt.Finished?this._callAnimatorScriptOnExit(f,a):this._callAnimatorScriptOnUpdate(f,a),g.length){var L=r.layerState;L!==Ye.CrossFading&&L!==Ye.FixedCrossFading&&this._checkTransition(e,g,a,p,C)}},i._updateCrossFade=function(e,r,a,o,c,l,_,u){var h=this.speed,d=a.crossLayerOwnerCollection,f=e.state.clip,v=f._curveBindings,p=e.state,g=e.stateData,y=e.playState,m=g.eventHandlers,x=r.state,C=r.stateData,b=r.playState,A=C.eventHandlers,S=x.clip,w=S._curveBindings,E=e.clipTime,P=r.clipTime,M=x._getDuration()*a.crossFadeTransition.duration,D=Math.abs(r.frameTime)/M;(D>=1||M===0)&&(D=1);var L=p.speed*h,V=x.speed*h;e.frameTime+=L*l,r.frameTime+=V*l,e.update(L<0),r.update(V<0);var N=e.clipTime,I=e.playState,B=r.clipTime,z=r.playState,U=r.playState===pt.Finished;if(u||U)for(var Y=d.length-1;Y>=0;Y--){var Q,H=d[Y],te=(Q=H)==null?void 0:Q.curveOwner;if(te){var Ce=H.crossSrcCurveIndex,de=H.crossDestCurveIndex;this._checkRevertOwner(te,_);var ae=te.evaluateCrossFadeValue(Ce>=0?v[Ce].curve:null,de>=0?w[de].curve:null,N,B,D,_);u&&te.applyValue(ae,c,_),U&&H.saveFinalValue()}}this._updateCrossFadeData(a,D),m.length&&this._fireAnimationEvents(e,m,E,N),A.length&&this._fireAnimationEvents(r,A,P,B),y===pt.UnStarted&&this._callAnimatorScriptOnEnter(p,o),D===1||I===pt.Finished?this._callAnimatorScriptOnExit(p,o):this._callAnimatorScriptOnUpdate(p,o),b===pt.UnStarted&&this._callAnimatorScriptOnEnter(x,o),z===pt.Finished?this._callAnimatorScriptOnExit(x,o):this._callAnimatorScriptOnUpdate(x,o)},i._updateCrossFadeFromPose=function(e,r,a,o,c,l,_){var u=r.crossLayerOwnerCollection,h=e.state,d=e.stateData,f=e.playState,v=d.eventHandlers,p=h.clip,g=p._curveBindings,y=e.clipTime,m=h._getDuration()*r.crossFadeTransition.duration,x=Math.abs(e.frameTime)/m;(x>=1||m===0)&&(x=1);var C=h.speed*this.speed;e.frameTime+=C*c,e.update(C<0);var b=e.clipTime,A=e.playState,S=A===pt.Finished;if(_||S)for(var w=u.length-1;w>=0;w--){var E,P=u[w],M=(E=P)==null?void 0:E.curveOwner;if(M){var D=P.crossDestCurveIndex;this._checkRevertOwner(M,l);var L=P.curveOwner.crossFadeFromPoseAndApplyValue(D>=0?g[D].curve:null,b,x,l);_&&M.applyValue(L,o,l),S&&P.saveFinalValue()}}this._updateCrossFadeData(r,x),v.length&&this._fireAnimationEvents(e,v,y,b),f===pt.UnStarted&&this._callAnimatorScriptOnEnter(h,a),A===pt.Finished?this._callAnimatorScriptOnExit(h,a):this._callAnimatorScriptOnUpdate(h,a)},i._updateFinishedState=function(e,r,a,o){if(o)for(var c=e.stateData.curveLayerOwner,l=e.state.clip,_=l._curveBindings,u=_.length-1;u>=0;u--){var h,d=c[u],f=(h=d)==null?void 0:h.curveOwner;f&&(this._checkRevertOwner(f,a),f.applyValue(d.finalValue,r,a))}},i._updateCrossFadeData=function(e,r){var a=e.destPlayData;r===1&&(a.playState===pt.Finished?e.layerState=Ye.Finished:e.layerState=Ye.Playing,e.switchPlayData(),e.crossFadeTransition=null)},i._preparePlay=function(e,r){if(e.layerState===Ye.Playing){var a=e.srcPlayData;if(a.state!==r)for(var o=a.stateData.curveLayerOwner,c=o.length-1;c>=0;c--){var l;(l=o[c])==null||l.curveOwner.revertDefaultValue()}}else for(var _=e.crossLayerOwnerCollection,u=_.length-1;u>=0;u--)_[u].curveOwner.revertDefaultValue()},i._checkTransition=function(e,r,a,o,c){var l=e.state,_=l.clip.length;this.speed*l.speed>=0?co?(this._checkBackwardsSubTransition(e,r,a,o,l.clipStartTime*_),e.currentTransitionIndex=r.length-1,this._checkBackwardsSubTransition(e,r,a,c,l.clipEndTime*_)):this._checkBackwardsSubTransition(e,r,a,o,c)},i._checkSubTransition=function(e,r,a,o,c){for(var l=e.currentTransitionIndex,_=e.state._getDuration(),u=r.length;lc)break;d>=o&&(this._crossFadeByTransition(h,a),e.currentTransitionIndex=Math.min(l+1,u-1))}},i._checkBackwardsSubTransition=function(e,r,a,o,c){for(var l=e.currentTransitionIndex,_=e.state._getDuration();l>=0;l--){var u=r[l],h=u.exitTime*_;if(h=0?oa?(this._fireBackwardSubAnimationEvents(e,r,a,c.clipStartTime*l),e.currentEventIndex=r.length-1,this._fireBackwardSubAnimationEvents(e,r,c.clipEndTime*l,o)):this._fireBackwardSubAnimationEvents(e,r,a,o)},i._fireSubAnimationEvents=function(e,r,a,o){for(var c=e.currentEventIndex,l=r.length;co)break;var f=_.handlers;if(h>=a){for(var v=f.length-1;v>=0;v--)f[v](d);e.currentEventIndex=Math.min(c+1,l-1)}}},i._fireBackwardSubAnimationEvents=function(e,r,a,o){for(var c=e.currentEventIndex;c>=0;c--){var l=r[c],_=l.event,u=_.time,h=_.parameter;if(u=0;f--)d[f](h);e.currentEventIndex=Math.max(c-1,0)}}},i._callAnimatorScriptOnEnter=function(e,r){for(var a=e._onStateEnterScripts,o=0,c=a.length;o=o)e.push(t);else{for(var c=r;--c>=0&&a-1&&this.states.splice(r,1),delete this._statesMap[e]},s.findStateByName=function(t){return this._statesMap[t]},s.makeUniqueStateName=function(t){for(var e=this._statesMap,r=t,a=0;e[t];)t=r+" "+a,a++;return t},n}(),fo;(function(n){n[n.If=0]="If",n[n.IfNot=1]="IfNot",n[n.Greater=2]="Greater",n[n.Less=3]="Less",n[n.Equals=4]="Equals",n[n.NotEquals=5]="NotEquals"})(fo||(fo={}));var Ft=function(){},sh=function(){},ch=function(){function n(){this._pathMasks=[],this._pathMaskMap={}}var s=n.prototype;return s.addPathMask=function(t){var e=this._pathMaskMap[t];if(e)return e;var r=new sh;return r.path=t,r.active=!0,this._pathMasks.push(r),this._pathMaskMap[t]=r,r},s.removePathMask=function(t){for(var e=this,r=e._pathMasks,a=0,o=this._pathMasks.length;a=o)t.push(e);else{for(var c=a;--c>=0&&r=0&&e.time0)for(var a=this._generator,o=1/r,c=e-this._frameRateTime;c>=o;)c-=o,this._frameRateTime+=o,a._emit(this._frameRateTime,1)},i._emitByBurst=function(e,r){var a=this._generator.main,o=a.duration,c=Math.floor((r-e)/o);if(a.isLoop&&(c>0||r%oh)break;if(p>=u){var g=v.count.evaluate(void 0,c.random());o._emit(_+p,g)}}this._currentBurstIndex=d},j(s,[{key:"bursts",get:function(){return this._bursts}}]),s}(Jn);T([J],Pn.prototype,"rateOverTime",void 0);T([J],Pn.prototype,"rateOverDistance",void 0);T([J],Pn.prototype,"shape",void 0);T([F],Pn.prototype,"_shapeRand",void 0);T([J],Pn.prototype,"_bursts",void 0);T([F],Pn.prototype,"_burstRand",void 0);var kr;(function(n){n[n.Hierarchy=0]="Hierarchy",n[n.Local=1]="Local",n[n.World=2]="World"})(kr||(kr={}));var De=function(){function n(i){this.duration=5,this.isLoop=!0,this.startDelay=new Oe(0),this.startLifetime=new Oe(5),this.startSpeed=new Oe(5),this.startSize3D=!1,this.startSizeX=new Oe(1),this.startSizeY=new Oe(1),this.startSizeZ=new Oe(1),this.startRotation3D=!1,this.startRotationX=new Oe(0),this.startRotationY=new Oe(0),this.startRotationZ=new Oe(0),this.flipRotation=0,this.startColor=new Kn(new q(1,1,1,1)),this.gravityModifier=new Oe(0),this.simulationSpace=ln.Local,this.simulationSpeed=1,this.scalingMode=kr.Local,this.playOnEnabled=!0,this._maxParticleBuffer=1e3,this._startSpeedRand=new mr(0,Ge.StartSpeed),this._startLifeTimeRand=new mr(0,Ge.StartLifetime),this._startColorRand=new mr(0,Ge.StartColor),this._startSizeRand=new mr(0,Ge.StartSize),this._startRotationRand=new mr(0,Ge.StartRotation),this._gravityModifierRand=new mr(0,Ge.GravityModifier),this._gravity=new R,this._generator=i}var s=n.prototype;return s._resetRandomSeed=function(t){this._startSpeedRand.reset(t,Ge.StartSpeed),this._startLifeTimeRand.reset(t,Ge.StartLifetime),this._startColorRand.reset(t,Ge.StartColor),this._startSizeRand.reset(t,Ge.StartSize),this._startRotationRand.reset(t,Ge.StartRotation)},s._getPositionScale=function(){var t=this._generator._renderer.entity.transform;switch(this.scalingMode){case kr.Hierarchy:case kr.World:return t.lossyWorldScale;case kr.Local:return t.scale}},s._updateShaderData=function(t){var e=this._generator._renderer,r=e.entity.transform;switch(this.simulationSpace){case ln.Local:t.setVector3(n._worldPosition,r.worldPosition);var a=r.worldRotationQuaternion,o=n._tempVector40;o.copyFrom(a),t.setVector4(n._worldRotation,o);break;case ln.World:break;default:throw new Error("ParticleRenderer: SimulationSpace value is invalid.")}switch(this.scalingMode){case kr.Hierarchy:var c=r.lossyWorldScale;t.setVector3(n._positionScale,c),t.setVector3(n._sizeScale,c);break;case kr.Local:var c=r.scale;t.setVector3(n._positionScale,c),t.setVector3(n._sizeScale,c);break;case kr.World:t.setVector3(n._positionScale,r.lossyWorldScale),t.setVector3(n._sizeScale,n._vector3One);break}var l=this._gravity,_=this.gravityModifier.evaluate(void 0,this._gravityModifierRand.random());R.scale(e.scene.physics.gravity,_,l),t.setVector3(n._gravity,l),t.setInt(n._simulationSpace,this.simulationSpace),t.setFloat(n._startRotation3D,+this.startRotation3D),t.setInt(n._scaleMode,this.scalingMode)},s._cloneTo=function(t){t.maxParticles=this.maxParticles},j(n,[{key:"maxParticles",get:function(){return this._maxParticleBuffer-1},set:function(t){this._maxParticleBuffer=t+1}},{key:"startSize",get:function(){return this.startSizeX},set:function(t){this.startSizeX=t}}]),n}();(function(){De._tempVector40=new ie})();(function(){De._vector3One=new R(1,1,1)})();(function(){De._positionScale=O.getByName("renderer_PositionScale")})();(function(){De._sizeScale=O.getByName("renderer_SizeScale")})();(function(){De._worldPosition=O.getByName("renderer_WorldPosition")})();(function(){De._worldRotation=O.getByName("renderer_WorldRotation")})();(function(){De._gravity=O.getByName("renderer_Gravity")})();(function(){De._simulationSpace=O.getByName("renderer_SimulationSpace")})();(function(){De._startRotation3D=O.getByName("renderer_ThreeDStartRotation")})();(function(){De._scaleMode=O.getByName("renderer_ScalingMode")})();T([J],De.prototype,"startDelay",void 0);T([J],De.prototype,"startLifetime",void 0);T([J],De.prototype,"startSpeed",void 0);T([J],De.prototype,"startSizeX",void 0);T([J],De.prototype,"startSizeY",void 0);T([J],De.prototype,"startSizeZ",void 0);T([J],De.prototype,"startRotationX",void 0);T([J],De.prototype,"startRotationY",void 0);T([J],De.prototype,"startRotationZ",void 0);T([J],De.prototype,"startColor",void 0);T([J],De.prototype,"gravityModifier",void 0);T([F],De.prototype,"_maxParticleBuffer",void 0);T([F],De.prototype,"_startSpeedRand",void 0);T([F],De.prototype,"_startLifeTimeRand",void 0);T([F],De.prototype,"_startColorRand",void 0);T([F],De.prototype,"_startSizeRand",void 0);T([F],De.prototype,"_startRotationRand",void 0);T([F],De.prototype,"_gravityModifierRand",void 0);T([F],De.prototype,"_generator",void 0);T([F],De.prototype,"_gravity",void 0);var Ze=function(n){W(s,n);function s(){var t;return t=n.apply(this,arguments)||this,t.separateAxes=!1,t.rotationX=new Oe(0),t.rotationY=new Oe(0),t.rotationZ=new Oe(45),t._rotationRand=new mr(0,Ge.RotationOverLifetime),t._rotationMinConstant=new R,t._rotationMaxConstant=new R,t}var i=s.prototype;return i._updateShaderData=function(e){var r=null,a=null,o=null;if(this.enabled){var c=this.rotationX,l=this.rotationY,_=this.rotationZ,u=this.separateAxes,h=u?c.mode===he.TwoCurves&&l.mode===he.TwoCurves&&_.mode===he.TwoCurves:_.mode===he.TwoCurves,d=h||u?c.mode===he.Curve&&l.mode===he.Curve&&_.mode===he.Curve:_.mode===he.Curve;if(d)e.setFloatArray(s._maxCurveZProperty,_.curveMax._getTypeArray()),u&&(e.setFloatArray(s._maxCurveXProperty,c.curveMax._getTypeArray()),e.setFloatArray(s._maxCurveYProperty,l.curveMax._getTypeArray())),h&&(e.setFloatArray(s._minCurveZProperty,_.curveMin._getTypeArray()),u&&(e.setFloatArray(s._minCurveXProperty,c.curveMin._getTypeArray()),e.setFloatArray(s._minCurveYProperty,l.curveMin._getTypeArray())),o=s._isRandomTwoMacro),a=s._curveModeMacro;else{var f=this._rotationMaxConstant;if(f.set(k.degreeToRadian(c.constantMax),k.degreeToRadian(l.constantMax),k.degreeToRadian(_.constantMax)),e.setVector3(s._maxConstantProperty,f),u?c.mode===he.TwoConstants&&l.mode===he.TwoConstants&&_.mode===he.TwoConstants:_.mode===he.TwoConstants){var v=this._rotationMinConstant;v.set(k.degreeToRadian(c.constantMin),k.degreeToRadian(l.constantMin),k.degreeToRadian(_.constantMin)),e.setVector3(s._minConstantProperty,v),o=s._isRandomTwoMacro}a=s._constantModeMacro}u&&(r=s._isSeparateMacro)}this._enableSeparateMacro=this._enableMacro(e,this._enableSeparateMacro,r),this._isCurveMacro=this._enableMacro(e,this._isCurveMacro,a),this._isRandomTwoMacro=this._enableMacro(e,this._isRandomTwoMacro,o)},i._resetRandomSeed=function(e){this._rotationRand.reset(e,Ge.RotationOverLifetime)},s}(Jn);(function(){Ze._constantModeMacro=oe.getByName("RENDERER_ROL_CONSTANT_MODE")})();(function(){Ze._curveModeMacro=oe.getByName("RENDERER_ROL_CURVE_MODE")})();(function(){Ze._isSeparateMacro=oe.getByName("RENDERER_ROL_IS_SEPARATE")})();(function(){Ze._isRandomTwoMacro=oe.getByName("RENDERER_ROL_IS_RANDOM_TWO")})();(function(){Ze._minConstantProperty=O.getByName("renderer_ROLMinConst")})();(function(){Ze._minCurveXProperty=O.getByName("renderer_ROLMinCurveX")})();(function(){Ze._minCurveYProperty=O.getByName("renderer_ROLMinCurveY")})();(function(){Ze._minCurveZProperty=O.getByName("renderer_ROLMinCurveZ")})();(function(){Ze._maxConstantProperty=O.getByName("renderer_ROLMaxConst")})();(function(){Ze._maxCurveXProperty=O.getByName("renderer_ROLMaxCurveX")})();(function(){Ze._maxCurveYProperty=O.getByName("renderer_ROLMaxCurveY")})();(function(){Ze._maxCurveZProperty=O.getByName("renderer_ROLMaxCurveZ")})();T([J],Ze.prototype,"rotationX",void 0);T([J],Ze.prototype,"rotationY",void 0);T([J],Ze.prototype,"rotationZ",void 0);T([F],Ze.prototype,"_rotationRand",void 0);T([F],Ze.prototype,"_rotationMinConstant",void 0);T([F],Ze.prototype,"_rotationMaxConstant",void 0);T([F],Ze.prototype,"_enableSeparateMacro",void 0);T([F],Ze.prototype,"_isCurveMacro",void 0);T([F],Ze.prototype,"_isRandomTwoMacro",void 0);var kn=function(){function n(){for(var i=arguments.length,t=new Array(i),e=0;e=o)t.push(e);else{for(var c=r;--c>=0&&ar._maxParticleBuffer){var l=this._getNotRetiredParticleCount();lo&&(this._isPlaying=!1)}if(!this.isAlive){var _=Math.min(a._frameRateTime,Math.floor(this._playTime/o)*o);this._playTime-=_,a._frameRateTime-=_}(this._firstNewElement!=this._firstFreeElement||this._waitProcessRetiredElementCount>0||this._instanceBufferResized||this._instanceVertexBufferBinding._buffer.isContentLost)&&this._addActiveParticlesToVertexBuffer()},s._reorganizeGeometryBuffers=function(){var t=this._renderer,e=t.engine._particleBufferUtils,r=this._primitive,a=this._vertexBufferBindings;if(r.clearVertexElements(),a.length=0,t.renderMode===gr.Mesh){var o=t.mesh;if(!o)return;var c=o.getVertexElement(X.Position),l=o.getVertexElement(X.Color),_=o.getVertexElement(X.UV),u=c?o.vertexBufferBindings[c.bindingIndex]:null,h=l?o.vertexBufferBindings[l.bindingIndex]:null,d=_?o.vertexBufferBindings[_.bindingIndex]:null;if(u){var f=this._addVertexBufferBindingsFilterDuplicate(u,a);r.addVertexElement(new Te(X.Position,c.offset,c.format,f))}if(h){var v=this._addVertexBufferBindingsFilterDuplicate(h,a);r.addVertexElement(new Te(X.Color,l.offset,l.format,v))}if(d){var p=this._addVertexBufferBindingsFilterDuplicate(d,a);r.addVertexElement(new Te(X.UV,_.offset,_.format,p))}var g=o._primitive.indexBufferBinding;r.setIndexBufferBinding(g),this._subPrimitive.count=g.buffer.byteLength/r._glIndexByteCount}else r.addVertexElement(e.billboardVertexElement),a.push(e.billboardVertexBufferBinding),r.setIndexBufferBinding(e.billboardIndexBufferBinding),this._subPrimitive.count=e.billboardIndexCount;r.setVertexBufferBindings(a);for(var y=e.instanceVertexElements,m=a.length,x=0,C=y.length;xg&&(this._firstNewElement+=e),this._firstActiveElement>g&&(this._firstActiveElement+=e),y>g&&(this._firstRetiredElement+=e)}else{var C,b;y<=g?(C=g-y,b=0,this._firstFreeElement-=y,this._firstNewElement-=y,this._firstActiveElement-=y,this._firstRetiredElement=0):(C=this._currentParticleCount-y,b=g,this._firstNewElement>g&&(this._firstNewElement-=g),this._firstActiveElement>g&&(this._firstActiveElement-=g),y>g&&(this._firstRetiredElement-=g)),f.set(new Float32Array(v.buffer,y*p*4,C*p),b*p)}this._instanceBufferResized=!0}this._primitive.setVertexBufferBinding(v?h.length-1:h.length,d),this._instanceVertices=f,this._instanceVertexBufferBinding=d,this._currentParticleCount=c},s._updateShaderData=function(t){this.main._updateShaderData(t),this.velocityOverLifetime._updateShaderData(t),this.textureSheetAnimation._updateShaderData(t),this.sizeOverLifetime._updateShaderData(t),this.rotationOverLifetime._updateShaderData(t),this.colorOverLifetime._updateShaderData(t)},s._resetGlobalRandSeed=function(t){this._randomSeed=t,this.main._resetRandomSeed(t),this.emission._resetRandomSeed(t),this.textureSheetAnimation._resetRandomSeed(t),this.velocityOverLifetime._resetRandomSeed(t),this.rotationOverLifetime._resetRandomSeed(t),this.colorOverLifetime._resetRandomSeed(t)},s._getAliveParticleCount=function(){if(this._firstActiveElement<=this._firstFreeElement)return this._firstFreeElement-this._firstActiveElement;var t=this._currentParticleCount-this._firstActiveElement;return this._firstFreeElement>0&&(t+=this._firstFreeElement),t},s._getNotRetiredParticleCount=function(){if(this._firstRetiredElement<=this._firstFreeElement)return this._firstFreeElement-this._firstRetiredElement;var t=this._currentParticleCount-this._firstRetiredElement;return this._firstFreeElement>0&&(t+=this._firstFreeElement),t},s._destroy=function(){this._instanceVertexBufferBinding.buffer.destroy(),this._primitive.destroy()},s._addNewParticle=function(t,e,r,a){var o=this._firstFreeElement,c=o+1;c>=this._currentParticleCount&&(c=0);var l=this.main;if(c===this._firstRetiredElement){var _=Math.min(n._particleIncreaseCount,l._maxParticleBuffer-this._currentParticleCount);if(_===0)return;this._resizeInstanceBuffer(!0,_),c=o+1}var u,h;l.simulationSpace===ln.World&&(u=r.worldPosition,h=r.worldRotationQuaternion);var d=this._renderer.engine._particleBufferUtils,f=l.startSpeed.evaluate(void 0,l._startSpeedRand.random()),v=this._instanceVertices,p=o*d.instanceVertexFloatStride;v[p]=t.x,v[p+1]=t.y,v[p+2]=t.z,v[p+d.startLifeTimeOffset]=l.startLifetime.evaluate(void 0,l._startLifeTimeRand.random()),v[p+4]=e.x,v[p+5]=e.y,v[p+6]=e.z,v[p+d.timeOffset]=a;var g=n._tempColor0;l.startColor.evaluate(void 0,l._startColorRand.random(),g),this._renderer.engine.settings.colorSpace===or.Linear&&g.toLinear(g),v[p+8]=g.r,v[p+9]=g.g,v[p+10]=g.b,v[p+11]=g.a;var y=l._startSizeRand;if(l.startSize3D)v[p+12]=l.startSizeX.evaluate(void 0,y.random()),v[p+13]=l.startSizeY.evaluate(void 0,y.random()),v[p+14]=l.startSizeZ.evaluate(void 0,y.random());else{var m=l.startSize.evaluate(void 0,y.random());v[p+12]=m,v[p+13]=m,v[p+14]=m}var x=l._startRotationRand;l.startRotation3D?(v[p+15]=k.degreeToRadian(l.startRotationX.evaluate(void 0,x.random())),v[p+16]=k.degreeToRadian(l.startRotationY.evaluate(void 0,x.random())),v[p+17]=k.degreeToRadian(l.startRotationZ.evaluate(void 0,x.random()))):v[p+15]=k.degreeToRadian(l.startRotationZ.evaluate(void 0,x.random())),v[p+18]=f;var C=this.colorOverLifetime;C.enabled&&C.color.mode===Xt.TwoGradients&&(v[p+20]=C._colorGradientRand.random());var b=this.rotationOverLifetime;b.enabled&&b.rotationZ.mode===he.TwoConstants&&(v[p+22]=b._rotationRand.random());var A=this.textureSheetAnimation;A.enabled&&A.frameOverTime.mode===he.TwoCurves&&(v[p+23]=A._frameOverTimeRand.random());var S=this.velocityOverLifetime;if(S.enabled&&S.velocityX.mode===he.TwoConstants&&S.velocityY.mode===he.TwoConstants&&S.velocityZ.mode===he.TwoConstants){var w=S._velocityRand;v[p+24]=w.random(),v[p+25]=w.random(),v[p+26]=w.random()}if(this.main.simulationSpace===ln.World&&(v[p+27]=u.x,v[p+28]=u.y,v[p+29]=u.z,v[p+30]=h.x,v[p+31]=h.y,v[p+32]=h.z,v[p+33]=h.w),this.textureSheetAnimation.enabled){var E=this.textureSheetAnimation._tillingInfo;v[p+d.simulationUVOffset]=E.x,v[p+35]=E.y,v[p+36]=0,v[p+37]=0}else v[p+d.simulationUVOffset]=1,v[p+35]=1,v[p+36]=0,v[p+37]=0;this._firstFreeElement=c},s._retireActiveParticles=function(){for(var t=this._renderer.engine,e=t._particleBufferUtils,r=t.time.frameCount,a=this._instanceVertices;this._firstActiveElement!==this._firstNewElement;){var o=this._firstActiveElement*e.instanceVertexFloatStride,c=o+e.timeOffset,l=this._playTime-a[c];if(Math.fround(l)=this._currentParticleCount&&(this._firstActiveElement=0),this._waitProcessRetiredElementCount++}},s._freeRetiredParticles=function(){for(var t=this._renderer.engine._particleBufferUtils,e=this._renderer.engine.time.frameCount;this._firstRetiredElement!==this._firstActiveElement;){var r=this._firstRetiredElement*t.instanceVertexFloatStride+t.startLifeTimeOffset,a=e-this._instanceVertices[r];if(a<0)break;++this._firstRetiredElement>=this._currentParticleCount&&(this._firstRetiredElement=0)}},s._addActiveParticlesToVertexBuffer=function(){var t=this._firstActiveElement,e=this._firstFreeElement;if(t!==e){var r=this._renderer.engine._particleBufferUtils.instanceVertexStride,a=t*r,o=this._instanceVertexBufferBinding.buffer,c=this._instanceVertices.buffer;if(t0&&o.setData(c,l,0,e*r)}this._firstNewElement=e,this._waitProcessRetiredElementCount=0,this._instanceBufferResized=!1}},s._addVertexBufferBindingsFilterDuplicate=function(t,e){for(var r=0,a=e.length;r0&&(a.z=-c),Cr._randomPointUnitSphere(o,e),R.lerp(a,o,this.randomDirectionAmount,o)},s}(Xa),hh=function(n){W(s,n);function s(){var t;return t=n.apply(this,arguments)||this,t.shapeType=wn.Sphere,t.radius=1,t}var i=s.prototype;return i._generatePositionAndDirection=function(e,r,a,o){Cr._randomPointInsideUnitSphere(a,e),a.scale(this.radius),Cr._randomPointUnitSphere(o,e),R.lerp(a,o,this.randomDirectionAmount,o)},s}(Xa),dh=`#define GLSLIFY 1 +varying vec2 v_uv;uniform sampler2D u_texture;void main(void){gl_FragColor=texture2D(u_texture,v_uv);}`,fh=`#define GLSLIFY 1 +attribute vec3 POSITION;attribute vec2 TEXCOORD_0;varying vec2 v_uv;uniform mat4 camera_ProjMat;uniform mat4 camera_ViewMat;void main(){gl_Position=camera_ProjMat*camera_ViewMat*vec4(POSITION,1.0);v_uv=TEXCOORD_0;}`;Se.create("trail",fh,dh);var Yc=function(n){W(s,n);function s(i){var t;t=n.call(this,i,Se.find("trail"))||this;var e=t.renderState.blendState.targetBlendState;return e.enabled=!0,e.sourceColorBlendFactor=e.sourceAlphaBlendFactor=be.SourceAlpha,e.destinationColorBlendFactor=e.destinationAlphaBlendFactor=be.One,t.renderState.depthState.writeEnabled=!1,t}return s}(Sr),ds=new R,vh=function(n){W(s,n);function s(t,e){var r;r=n.call(this,t)||this,r._stroke=e.stroke||.2,r._minSeg=e.minSeg||.02,r._lifetime=e.lifetime||1e3,r._maxPointNum=r._lifetime/1e3*t.engine.targetFrameRate,r._points=[],r._pointStates=[],r._strapPoints=[];for(var a=0;a0&&(a=o-r,this._pointStates[a]=this._pointStates[o],this._points[a].copyFrom(this._points[o]));this._curPointNum-=r;var c=!0;if(this._curPointNum===this._maxPointNum)c=!1;else if(this._curPointNum>0){var l=this._points[this._points.length-1];R.distance(this.entity.transform.worldPosition,l)"u"||!ir(r,OffscreenCanvas)){var a=r.clientWidth*e,o=r.clientHeight*e;this.width=a,this.height=o}},i.setScale=function(e,r){this._scale.set(e,r),this.scale=this._scale},i._onWidthChanged=function(e){this._webCanvas.width=e},i._onHeightChange=function(e){this._webCanvas.height=e},qa(s,[{key:"scale",get:function(){var e=this._webCanvas;return(typeof OffscreenCanvas>"u"||!ir(e,OffscreenCanvas))&&this._scale.set(e.clientWidth*devicePixelRatio/e.width,e.clientHeight*devicePixelRatio/e.height),this._scale},set:function(e){var r=this._webCanvas;(typeof OffscreenCanvas>"u"||!ir(r,OffscreenCanvas))&&(r.style.transformOrigin="left top",r.style.transform="scale("+e.x+", "+e.y+")")}}]),s}(zc),od=function(n){Ya(s,n);function s(){return n.apply(this,arguments)}return s.create=function(t){var e=t.canvas,r=new mh(typeof e=="string"?document.getElementById(e):e),a=new Rh(t.graphicDeviceOptions),o=new s(r,a,t),c=o._initialize(t);return c.then(function(){return o.sceneManager.addScene(new Wa(o,"DefaultScene")),o})},qa(s,[{key:"canvas",get:function(){return this._canvas}}]),s}(hn);function Li(){return Li=Object.assign||function(s){for(var i=1;i=e&&r<=r||t>=a&&t<=o?this.canIUse(K.astc):t===c?this.canIUse(K.etc1):t>=l&&t<=_?this.canIUse(K.etc):t>=u&&t<=h?this.canIUse(K.pvrtc):t>=d&&t<=f?this.canIUse(K.s3tc):t>=v&&t<=p?this.canIUse(K.bptc):!1},s._init=function(){var t=this.capabilityList,e=this.rhi.isWebGL2,r=this.rhi.requireExtension.bind(this.rhi),a=K.shaderVertexID,o=K.standardDerivatives,c=K.shaderTextureLod,l=K.elementIndexUint,_=K.depthTexture,u=K.vertexArrayObject,h=K.instancedArrays,d=K.multipleSample,f=K.drawBuffers,v=K.blendMinMax,p=K.astc,g=K.astc_webkit,y=K.etc,m=K.etc_webkit,x=K.etc1,C=K.etc1_webkit,b=K.pvrtc,A=K.pvrtc_webkit,S=K.s3tc,w=K.s3tc_webkit,E=K.bptc,P=K.textureFloat,M=K.textureHalfFloat,D=K.textureFloatLinear,L=K.textureHalfFloatLinear,V=K.WEBGL_colorBufferFloat,N=K.colorBufferFloat,I=K.colorBufferHalfFloat,B=K.textureFilterAnisotropic,z=K.fragDepth;t.set(a,e),t.set(o,e||!!r(o)),t.set(c,e||!!r(c)),t.set(l,e||!!r(l)),t.set(_,e||!!r(_)),t.set(u,e||!!r(u)),t.set(h,e||!!r(h)),t.set(d,e),t.set(f,e||!!r(f)),t.set(v,e||!!r(v)),t.set(P,e||!!r(P)),t.set(M,e||!!r(M)),t.set(D,!!r(D)),t.set(L,e||!!r(L)),t.set(N,e&&!!r(N)||!!r(V)),t.set(I,e&&!!r(N)||!!r(I)),t.set(B,!!r(B)),t.set(z,e||!!r(z)),t.set(p,!!(r(p)||r(g))),t.set(y,!!(r(y)||r(m))),t.set(x,!!(r(x)||r(C))),t.set(b,!!(r(b)||r(A))),t.set(S,!!(r(S)||r(w))),t.set(E,!!r(E))},s._compatibleInterface=function(t,e){var r=this.rhi,a=r.gl,o=null;if(o=r.requireExtension(t))for(var c in e){var l,_=e[c],u=o[_];(l=u)!=null&&l.bind?a[c]=u.bind(o):a[c]=u}},s._compatibleAllInterface=function(){var t=K.depthTexture,e=K.vertexArrayObject,r=K.instancedArrays,a=K.drawBuffers,o=K.textureFilterAnisotropic,c=K.textureHalfFloat,l=K.colorBufferHalfFloat,_=K.WEBGL_colorBufferFloat,u=K.blendMinMax,h=this.rhi.isWebGL2;if(!h){this._compatibleInterface(u,{MIN:"MIN_EXT",MAX:"MAX_EXT"}),this._compatibleInterface(t,{UNSIGNED_INT_24_8:"UNSIGNED_INT_24_8_WEBGL"}),this._compatibleInterface(e,{createVertexArray:"createVertexArrayOES",deleteVertexArray:"deleteVertexArrayOES",isVertexArray:"isVertexArrayOES",bindVertexArray:"bindVertexArrayOES"}),this._compatibleInterface(r,{drawArraysInstanced:"drawArraysInstancedANGLE",drawElementsInstanced:"drawElementsInstancedANGLE",vertexAttribDivisor:"vertexAttribDivisorANGLE"}),this._compatibleInterface(a,{MAX_DRAW_BUFFERS:"MAX_DRAW_BUFFERS_WEBGL"});var d={};if(this.canIUse(K.drawBuffers)){for(var f=this.maxDrawBuffers,v=0;v0}},{key:"canIUseMoreJoints",get:function(){return this.canIUse(K.textureFloat)&&this.rhi.renderStates.getParameter(this.rhi.gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}},{key:"maxDrawBuffers",get:function(){return this._maxDrawBuffers||(this.canIUse(K.drawBuffers)?this._maxDrawBuffers=this._rhi.gl.getParameter(this._rhi.gl.MAX_DRAW_BUFFERS):this._maxDrawBuffers=1),this._maxDrawBuffers}},{key:"maxAnisoLevel",get:function(){if(!this._maxAnisoLevel){var t=this._rhi.requireExtension(K.textureFilterAnisotropic);this._maxAnisoLevel=t?this._rhi.gl.getParameter(t.MAX_TEXTURE_MAX_ANISOTROPY_EXT):1}return this._maxAnisoLevel}},{key:"maxAntiAliasing",get:function(){if(!this._maxAntiAliasing){var t=this._rhi.gl,e=this.canIUse(K.multipleSample);this._maxAntiAliasing=e?t.getParameter(t.MAX_SAMPLES):1}return this._maxAntiAliasing}},{key:"rhi",get:function(){return this._rhi}}]),n}(),bh=function(){function n(i){this.rhi=i,this._requireResult={}}var s=n.prototype;return s.requireExtension=function(t){return this._requireResult[t]!==void 0?this._requireResult[t]:(this._requireResult[t]=this.rhi.gl.getExtension(t),this._requireResult[t])},n}(),Sh=function(){function n(i,t){this._attribLocArray=[],this._vaoMap=new Map,this._primitive=t,this._canUseInstancedArrays=i.canIUse(K.instancedArrays),this._isSupportVAO=i.canIUse(K.vertexArrayObject),this._gl=i.gl}var s=n.prototype;return s.draw=function(t,e){var r=this._gl,a=this._primitive,o=this._isSupportVAO&&a.enableVAO;if(o){a._bufferStructChanged&&this._clearVAO(),this._vaoMap.has(t.id)||this._registerVAO(t);var c=this._vaoMap.get(t.id);r.bindVertexArray(c)}else this._bindBufferAndAttrib(t);var l=a.indexBufferBinding,_=a.instanceCount,u=a._glIndexType,h=a._glIndexByteCount,d=e.topology,f=e.start,v=e.count;if(_)if(this._canUseInstancedArrays)if(l)if(o)r.drawElementsInstanced(d,v,u,f*h,_);else{var g=l.buffer._platformBuffer._glBuffer;r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,g),r.drawElementsInstanced(d,v,u,f*h,_),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,null)}else r.drawArraysInstanced(d,f,v,_);else ve.error("ANGLE_instanced_arrays extension is not supported");else if(l)if(o)r.drawElements(d,v,u,f*h);else{var p=l.buffer._platformBuffer._glBuffer;r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,p),r.drawElements(d,v,u,f*h),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,null)}else r.drawArrays(d,f,v);o?r.bindVertexArray(null):this._disableAttrib()},s.destroy=function(){this._isSupportVAO&&this._clearVAO()},s._bindBufferAndAttrib=function(t){var e=this._gl,r=this._primitive,a=r.vertexBufferBindings;this._attribLocArray.length=0;var o=t.attributeLocation,c=r._vertexElementMap,l,_;for(var u in o){var h=o[u];if(h!==-1){var d=c[u];if(d){var f=a[d.bindingIndex],v=f.buffer,p=f.stride;l=v._platformBuffer._glBuffer,_!==l&&(_=l,e.bindBuffer(e.ARRAY_BUFFER,l)),e.enableVertexAttribArray(h);var g=d._formatMetaInfo;e.vertexAttribPointer(h,g.size,g.type,g.normalized,p,d.offset),this._canUseInstancedArrays&&e.vertexAttribDivisor(h,d.instanceStepRate),this._attribLocArray.push(h)}else ve.warn("vertex attribute not found: "+u)}}e.bindBuffer(e.ARRAY_BUFFER,null)},s._disableAttrib=function(){for(var t=this._gl,e=0,r=this._attribLocArray.length;e>m),C=0;C<6;C++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+C,m,o,x,x,0,c,l,null);else if(v)e.texImage2D(this._target,0,o,h,d,0,c,l,null);else for(var p=0;p>p),y=Math.max(1,d>>p);e.texImage2D(this._target,p,o,g,y,0,c,l,null)}},s._getPixelBuffer=function(t,e,r,a,o,c,l){var _=this._gl,u=this._formatDetail,h=u.baseFormat,d=u.dataType;_.bindFramebuffer(_.FRAMEBUFFER,this._getReadFrameBuffer()),c>0&&!this._isWebGL2&&(c=0,ve.error("mipLevel only take effect in WebGL2.0")),t!=null?_.framebufferTexture2D(_.FRAMEBUFFER,_.COLOR_ATTACHMENT0,_.TEXTURE_CUBE_MAP_POSITIVE_X+t,this._glTexture,c):_.framebufferTexture2D(_.FRAMEBUFFER,_.COLOR_ATTACHMENT0,_.TEXTURE_2D,this._glTexture,c),_.readPixels(e,r,a,o,h,d,l),_.bindFramebuffer(_.FRAMEBUFFER,null)},s._setWrapMode=function(t,e){var r=this._gl,a=this._isWebGL2,o=this._target,c=this._texture,l=c.width,_=c.height;switch(!a&&t!==gt.Clamp&&(!n._isPowerOf2(l)||!n._isPowerOf2(_))&&(ve.warn("non-power-2 texture is not supported for REPEAT or MIRRORED_REPEAT in WebGL1,and has automatically downgraded to CLAMP_TO_EDGE"),t=gt.Clamp),t){case gt.Clamp:r.texParameteri(o,e,r.CLAMP_TO_EDGE);break;case gt.Repeat:r.texParameteri(o,e,r.REPEAT);break;case gt.Mirror:r.texParameteri(o,e,r.MIRRORED_REPEAT);break}},s._getReadFrameBuffer=function(){var t=this._rhi._readFrameBuffer;return t||(this._rhi._readFrameBuffer=t=this._gl.createFramebuffer()),t},n._isPowerOf2=function(t){return(t&t-1)===0},n._getFormatDetail=function(t,e,r){switch(t){case G.R8G8B8:return{internalFormat:r?e.RGB8:e.RGB,baseFormat:e.RGB,dataType:e.UNSIGNED_BYTE,isCompressed:!1};case G.R8G8B8A8:return{internalFormat:r?e.RGBA8:e.RGBA,baseFormat:e.RGBA,dataType:e.UNSIGNED_BYTE,isCompressed:!1};case G.R4G4B4A4:return{internalFormat:r?e.RGBA4:e.RGBA,baseFormat:e.RGBA,dataType:e.UNSIGNED_SHORT_4_4_4_4,isCompressed:!1};case G.R5G5B5A1:return{internalFormat:r?e.RGB5_A1:e.RGBA,baseFormat:e.RGBA,dataType:e.UNSIGNED_SHORT_5_5_5_1,isCompressed:!1};case G.R5G6B5:return{internalFormat:r?e.RGB565:e.RGB,baseFormat:e.RGB,dataType:e.UNSIGNED_SHORT_5_6_5,isCompressed:!1};case G.Alpha8:return{internalFormat:e.ALPHA,baseFormat:e.ALPHA,dataType:e.UNSIGNED_BYTE,isCompressed:!1};case G.LuminanceAlpha:return{internalFormat:e.LUMINANCE_ALPHA,baseFormat:e.LUMINANCE_ALPHA,dataType:e.UNSIGNED_BYTE,isCompressed:!1};case G.R16G16B16A16:return{internalFormat:r?e.RGBA16F:e.RGBA,baseFormat:e.RGBA,dataType:e.HALF_FLOAT,isCompressed:!1};case G.R32G32B32A32:return{internalFormat:r?e.RGBA32F:e.RGBA,baseFormat:e.RGBA,dataType:e.FLOAT,isCompressed:!1};case G.R32G32B32A32_UInt:return{internalFormat:r?e.RGBA32UI:e.NONE,baseFormat:e.RGBA_INTEGER,dataType:e.UNSIGNED_INT,isCompressed:!1};case G.BC1:return{internalFormat:_e.RGB_S3TC_DXT1_EXT,isCompressed:!0};case G.BC3:return{internalFormat:_e.RGBA_S3TC_DXT5_EXT,isCompressed:!0};case G.BC7:return{internalFormat:_e.RGBA_BPTC_UNORM_EXT,isCompressed:!0};case G.ETC1_RGB:return{internalFormat:_e.RGB_ETC1_WEBGL,isCompressed:!0};case G.ETC2_RGB:return{internalFormat:_e.RGB8_ETC2,isCompressed:!0};case G.ETC2_RGBA5:return{internalFormat:_e.RGB8_PUNCHTHROUGH_ALPHA1_ETC2,isCompressed:!0};case G.ETC2_RGBA8:return{internalFormat:_e.RGBA8_ETC2_EAC,isCompressed:!0};case G.PVRTC_RGB2:return{internalFormat:_e.RGB_PVRTC_2BPPV1_IMG,isCompressed:!0};case G.PVRTC_RGBA2:return{internalFormat:_e.RGBA_PVRTC_2BPPV1_IMG,isCompressed:!0};case G.PVRTC_RGB4:return{internalFormat:_e.RGB_PVRTC_4BPPV1_IMG,isCompressed:!0};case G.PVRTC_RGBA4:return{internalFormat:_e.RGBA_PVRTC_4BPPV1_IMG,isCompressed:!0};case G.ASTC_4x4:return{internalFormat:_e.RGBA_ASTC_4X4_KHR,isCompressed:!0};case G.ASTC_5x5:return{internalFormat:_e.RGBA_ASTC_5X5_KHR,isCompressed:!0};case G.ASTC_6x6:return{internalFormat:_e.RGBA_ASTC_6X6_KHR,isCompressed:!0};case G.ASTC_8x8:return{internalFormat:_e.RGBA_ASTC_8X8_KHR,isCompressed:!0};case G.ASTC_10x10:return{internalFormat:_e.RGBA_ASTC_10X10_KHR,isCompressed:!0};case G.ASTC_12x12:return{internalFormat:_e.RGBA_ASTC_12X12_KHR,isCompressed:!0};case G.Depth:return{internalFormat:r?e.DEPTH_COMPONENT32F:e.DEPTH_COMPONENT,baseFormat:e.DEPTH_COMPONENT,dataType:r?e.FLOAT:e.UNSIGNED_SHORT,isCompressed:!1,attachment:e.DEPTH_ATTACHMENT};case G.DepthStencil:return{internalFormat:r?e.DEPTH32F_STENCIL8:e.DEPTH_STENCIL,baseFormat:e.DEPTH_STENCIL,dataType:r?e.FLOAT_32_UNSIGNED_INT_24_8_REV:e.UNSIGNED_INT_24_8,isCompressed:!1,attachment:e.DEPTH_STENCIL_ATTACHMENT};case G.Depth16:return{internalFormat:r?e.DEPTH_COMPONENT16:e.DEPTH_COMPONENT,baseFormat:e.DEPTH_COMPONENT,dataType:e.UNSIGNED_SHORT,isCompressed:!1,attachment:e.DEPTH_ATTACHMENT};case G.Depth24Stencil8:return{internalFormat:r?e.DEPTH24_STENCIL8:e.DEPTH_STENCIL,baseFormat:e.DEPTH_STENCIL,dataType:e.UNSIGNED_INT_24_8,isCompressed:!1,attachment:e.DEPTH_STENCIL_ATTACHMENT};case G.Depth24:return{internalFormat:e.DEPTH_COMPONENT24,baseFormat:e.DEPTH_COMPONENT,dataType:e.UNSIGNED_INT,isCompressed:!1,attachment:e.DEPTH_ATTACHMENT};case G.Depth32:return{internalFormat:e.DEPTH_COMPONENT32F,baseFormat:e.DEPTH_COMPONENT,dataType:e.FLOAT,isCompressed:!1,attachment:e.DEPTH_ATTACHMENT};case G.Depth32Stencil8:return{internalFormat:e.DEPTH32F_STENCIL8,baseFormat:e.DEPTH_STENCIL,dataType:e.FLOAT_32_UNSIGNED_INT_24_8_REV,isCompressed:!1,attachment:e.DEPTH_STENCIL_ATTACHMENT};default:throw new Error("this TextureFormat is not supported in Galacean Engine: "+t)}},n._getRenderBufferDepthFormatDetail=function(t,e,r){switch(t){case G.Depth:return{internalFormat:r?e.DEPTH_COMPONENT32F:e.DEPTH_COMPONENT16,baseFormat:e.DEPTH_COMPONENT,dataType:r?e.FLOAT:e.UNSIGNED_SHORT,isCompressed:!1,attachment:e.DEPTH_ATTACHMENT};case G.DepthStencil:return{internalFormat:r?e.DEPTH32F_STENCIL8:e.DEPTH_STENCIL,baseFormat:e.DEPTH_STENCIL,dataType:r?e.FLOAT_32_UNSIGNED_INT_24_8_REV:e.UNSIGNED_INT_24_8,isCompressed:!1,attachment:e.DEPTH_STENCIL_ATTACHMENT};case G.Stencil:return{internalFormat:e.STENCIL_INDEX8,baseFormat:e.STENCIL_ATTACHMENT,dataType:e.UNSIGNED_BYTE,isCompressed:!1,attachment:e.STENCIL_ATTACHMENT};case G.Depth16:return{internalFormat:e.DEPTH_COMPONENT16,baseFormat:e.DEPTH_COMPONENT,dataType:e.UNSIGNED_SHORT,isCompressed:!1,attachment:e.DEPTH_ATTACHMENT};case G.Depth24Stencil8:return{internalFormat:r?e.DEPTH24_STENCIL8:e.DEPTH_STENCIL,baseFormat:e.DEPTH_STENCIL,dataType:e.UNSIGNED_INT_24_8,isCompressed:!1,attachment:e.DEPTH_STENCIL_ATTACHMENT};case G.Depth24:return{internalFormat:e.DEPTH_COMPONENT24,baseFormat:e.DEPTH_COMPONENT,dataType:e.UNSIGNED_INT,isCompressed:!1,attachment:e.DEPTH_ATTACHMENT};case G.Depth32:return{internalFormat:e.DEPTH_COMPONENT32F,baseFormat:e.DEPTH_COMPONENT,dataType:e.FLOAT,isCompressed:!1,attachment:e.DEPTH_ATTACHMENT};case G.Depth32Stencil8:return{internalFormat:e.DEPTH32F_STENCIL8,baseFormat:e.DEPTH_STENCIL,dataType:e.FLOAT_32_UNSIGNED_INT_24_8_REV,isCompressed:!1,attachment:e.DEPTH_STENCIL_ATTACHMENT};default:throw new Error("this TextureFormat is not supported in Galacean Engine: "+t)}},n._supportTextureFormat=function(t,e){switch(t){case G.R16G16B16A16:if(!e.canIUse(K.textureHalfFloat))return!1;break;case G.R32G32B32A32:if(!e.canIUse(K.textureFloat))return!1;break;case G.Depth16:case G.Depth24Stencil8:case G.Depth:case G.DepthStencil:if(!e.canIUse(K.depthTexture))return!1;break;case G.R32G32B32A32_UInt:case G.Depth24:case G.Depth32:case G.Depth32Stencil8:return e.isWebGL2}return!0},n._supportRenderBufferColorFormat=function(t,e){var r=!0;switch(t){case G.R16G16B16A16:(!e.canIUse(K.colorBufferHalfFloat)||!e.canIUse(K.textureHalfFloat))&&(r=!1);break;case G.R32G32B32A32:(!e.canIUse(K.colorBufferFloat)||!e.canIUse(K.textureFloat))&&(r=!1);break}return r},n._supportRenderBufferDepthFormat=function(t,e){if(!e.isWebGL2)switch(t){case G.Depth24:case G.Depth32:case G.Depth32Stencil8:return!1}return!0},qa(n,[{key:"wrapModeU",set:function(t){this._bind(),this._setWrapMode(t,this._gl.TEXTURE_WRAP_S)}},{key:"wrapModeV",set:function(t){this._bind(),this._setWrapMode(t,this._gl.TEXTURE_WRAP_T)}},{key:"filterMode",set:function(t){var e=this._gl,r=this._target,a=this._texture._mipmap;switch(this._bind(),t){case tt.Point:e.texParameteri(r,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(r,e.TEXTURE_MIN_FILTER,a?e.NEAREST_MIPMAP_NEAREST:e.NEAREST);break;case tt.Bilinear:e.texParameteri(r,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(r,e.TEXTURE_MIN_FILTER,a?e.LINEAR_MIPMAP_NEAREST:e.LINEAR);break;case tt.Trilinear:e.texParameteri(r,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(r,e.TEXTURE_MIN_FILTER,a?e.LINEAR_MIPMAP_LINEAR:e.LINEAR);break}}},{key:"anisoLevel",set:function(t){var e=this._gl;this._bind(),e.texParameterf(this._target,e.TEXTURE_MAX_ANISOTROPY_EXT,t)}},{key:"depthCompareFunction",set:function(t){this._bind();var e=this._gl;switch(t){case vr.Never:e.texParameteri(this._target,e.TEXTURE_COMPARE_FUNC,e.NEVER);break;case vr.Less:e.texParameteri(this._target,e.TEXTURE_COMPARE_FUNC,e.LESS);break;case vr.Equal:e.texParameteri(this._target,e.TEXTURE_COMPARE_FUNC,e.EQUAL);break;case vr.LessEqual:e.texParameteri(this._target,e.TEXTURE_COMPARE_FUNC,e.LEQUAL);break;case vr.Greater:e.texParameteri(this._target,e.TEXTURE_COMPARE_FUNC,e.GREATER);break;case vr.NotEqual:e.texParameteri(this._target,e.TEXTURE_COMPARE_FUNC,e.NOTEQUAL);break;case vr.GreaterEqual:e.texParameteri(this._target,e.TEXTURE_COMPARE_FUNC,e.GEQUAL);break;case vr.Always:e.texParameteri(this._target,e.TEXTURE_COMPARE_FUNC,e.ALWAYS);break}}}]),n}(),Ah=function(){function n(i,t){this._MSAAColorRenderBuffers=[],this._curMipLevel=0,this._curFaceIndex=void 0,this._gl=i.gl,this._isWebGL2=i.isWebGL2,this._target=t;for(var e=t._colorTextures,r=t._depth,a=t.width,o=t.height,c=ir(r,Wr),l=0,_=e.length;l<_;l++){var u=e[l]._format;if(!Ct._supportRenderBufferColorFormat(u,i))throw new Error("TextureFormat is not supported:"+G[u]+" in RenderTarget")}if(!c&&!Ct._supportRenderBufferDepthFormat(r,i))throw new Error("TextureFormat is not supported:"+G[r]+" in RenderTarget");if(e.length>1&&!i.canIUse(K.drawBuffers))throw new Error("MRT is not supported");if(e.some(function(d){return d.width!==a||d.height!==o}))throw new Error("ColorTexture's size must as same as RenderTarget");if(c&&(r.width!==a||r.height!==o))throw new Error("DepthTexture's size must as same as RenderTarget");if(e.length>1&&e.some(function(d){return ir(d,jt)}))throw new Error("MRT+Cube+[,MSAA] is not supported");var h=i.capability.maxAntiAliasing;t.antiAliasing>h&&(ve.warn("MSAA antiAliasing exceeds the limit and is automatically downgraded to:"+h),t._antiAliasing=h),this._frameBuffer=this._gl.createFramebuffer(),this._bindMainFBO(),t.antiAliasing>1&&(this._MSAAFrameBuffer=this._gl.createFramebuffer(),this._bindMSAAFBO())}var s=n.prototype;return s.activeRenderTarget=function(t,e){var r=this,a=r._gl,o=r._target;a.bindFramebuffer(a.FRAMEBUFFER,this._frameBuffer);var c=t!==this._curMipLevel,l=e!==this._curFaceIndex,_=o.getColorTexture(0);if(_){var u=ir(_,jt);(c||u&&l)&&a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,u?a.TEXTURE_CUBE_MAP_POSITIVE_X+e:a.TEXTURE_2D,_._platformTexture._glTexture,t)}var h=o.depthTexture;if(h){var d=ir(h,jt);if(c||d){var f=h._platformTexture;a.framebufferTexture2D(a.FRAMEBUFFER,f._formatDetail.attachment,d?a.TEXTURE_CUBE_MAP_POSITIVE_X+e:a.TEXTURE_2D,f._glTexture,t)}}else if(c){var v=Ct._getRenderBufferDepthFormatDetail(o._depth,a,this._isWebGL2).internalFormat;a.bindRenderbuffer(a.RENDERBUFFER,this._depthRenderBuffer),a.renderbufferStorage(a.RENDERBUFFER,v,o.width>>t,o.height>>t)}this._curMipLevel=t,this._curFaceIndex=e,this._MSAAFrameBuffer&&a.bindFramebuffer(a.FRAMEBUFFER,this._MSAAFrameBuffer)},s.blitRenderTarget=function(){if(this._MSAAFrameBuffer){var t=this._gl,e=t.COLOR_BUFFER_BIT|(this._target.depthTexture?t.DEPTH_BUFFER_BIT:0),r=this._target,a=r.colorTextureCount,o=r.width,c=r.height;t.bindFramebuffer(t.READ_FRAMEBUFFER,this._MSAAFrameBuffer),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,this._frameBuffer);for(var l=0;l1&&t.drawBuffers(_),this._oriDrawBuffers=_,a!==null){if(ir(a,Wr)&&!ir(a,jt)){var f=a._platformTexture;t.framebufferTexture2D(t.FRAMEBUFFER,f._formatDetail.attachment,t.TEXTURE_2D,f._glTexture,0)}else if(this._target.antiAliasing<=1){var v=Ct._getRenderBufferDepthFormatDetail(a,t,e),p=v.internalFormat,g=v.attachment,y=t.createRenderbuffer();this._depthRenderBuffer=y,t.bindRenderbuffer(t.RENDERBUFFER,y),t.renderbufferStorage(t.RENDERBUFFER,p,c,l),t.framebufferRenderbuffer(t.FRAMEBUFFER,g,t.RENDERBUFFER,y)}}t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindRenderbuffer(t.RENDERBUFFER,null)},s._bindMSAAFBO=function(){var t=this._gl,e=this._isWebGL2,r=t.createRenderbuffer(),a=this._target,o=a._depth,c=a.colorTextureCount,l=a.antiAliasing,_=a.width,u=a.height;this._blitDrawBuffers=new Array(c),this._MSAADepthRenderBuffer=r,t.bindFramebuffer(t.FRAMEBUFFER,this._MSAAFrameBuffer);for(var h=0;h>r),y=Math.max(1,this._texture.height>>r);if(c=c||g-a,l=l||y-o,this._bind(),_.pixelStorei(_.UNPACK_FLIP_Y_WEBGL,0),_.pixelStorei(_.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),p){var m=1<>a)-o,_=_||Math.max(1,this._texture.height>>a)-c,u=u||this._texture.length,this._bind(),f.pixelStorei(f.UNPACK_FLIP_Y_WEBGL,0),f.pixelStorei(f.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),m?f.compressedTexSubImage3D(d,a,o,c,e,l,_,u,p,r):f.texSubImage3D(d,a,o,c,e,l,_,u,g,y,r)},i.setImageSource=function(e,r,a,o,c,l,_){var u=this._gl,h=this._formatDetail,d=h.baseFormat,f=h.dataType;this._bind(),u.pixelStorei(u.UNPACK_FLIP_Y_WEBGL,+o),u.pixelStorei(u.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+c);var v,p;u.texSubImage3D(this._target,a,l,_,e,(v=r.width)!=null?v:r.codedWidth,(p=r.height)!=null?p:r.codedHeight,1,d,f,r)},i.getPixelBuffer=function(e,r,a,o,c,l,_){var u=this,h=u._gl,d=u._formatDetail;if(d.isCompressed)throw new Error("Unable to read compressed texture");h.bindFramebuffer(h.FRAMEBUFFER,this._getReadFrameBuffer()),h.framebufferTextureLayer(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0,this._glTexture,l,e),h.readPixels(r,a,o,c,d.baseFormat,d.dataType,_),h.bindFramebuffer(h.FRAMEBUFFER,null)},s}(Ct),Th=function(n){Ya(s,n);function s(t,e){var r;r=n.call(this,t,e,t.gl.TEXTURE_CUBE_MAP)||this,r._compressedFaceFilled=[0,0,0,0,0,0];var a=e.format,o=e._mipmap,c=e.width,l=r._isWebGL2;if(!Ct._supportTextureFormat(a,t))throw new Error("Texture format is not supported:"+G[a]);return o&&!l&&!Ct._isPowerOf2(c)&&(ve.warn("non-power-2 texture is not supported for mipmap in WebGL1,and has automatically downgraded to non-mipmap"),e._mipmap=!1,e._mipmapCount=e._getMipmapCount()),r._formatDetail=Ct._getFormatDetail(a,r._gl,l),r._formatDetail.isCompressed&&!l||r._init(!0),r}var i=s.prototype;return i.setPixelBuffer=function(e,r,a,o,c,l,_){var u=this._gl,h=this._isWebGL2,d=this._formatDetail,f=d.internalFormat,v=d.baseFormat,p=d.dataType,g=d.isCompressed,y=Math.max(1,this._texture.width>>a);if(l=l||y-o,_=_||y-c,this._bind(),u.pixelStorei(u.UNPACK_FLIP_Y_WEBGL,0),u.pixelStorei(u.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),g){var m=1<=0&&a<=4&&(t._forceFlush=!0)}}this._options=t,this._onWebGLContextLost=this._onWebGLContextLost.bind(this),this._onWebGLContextRestored=this._onWebGLContextRestored.bind(this)}var s=n.prototype;return s.init=function(t,e,r){var a=this._options,o=t._webCanvas,c=a.webGLMode;this._onDeviceLost=e,this._onDeviceRestored=r,o.addEventListener("webglcontextlost",this._onWebGLContextLost,!1),o.addEventListener("webglcontextrestored",this._onWebGLContextRestored,!1),o.addEventListener("webglcontextcreationerror",this._onContextCreationError,!1),this._webCanvas=o;var l;if((c==0||c==1)&&(l=o.getContext("webgl2",a),!l&&(typeof OffscreenCanvas>"u"||!ir(o,OffscreenCanvas))&&(l=o.getContext("experimental-webgl2",a)),this._isWebGL2=!0,l&&!l.deleteQuery&&(this._isWebGL2=!1)),l||(c==0||c==2)&&(l=o.getContext("webgl",a),!l&&(typeof OffscreenCanvas>"u"||!ir(o,OffscreenCanvas))&&(l=o.getContext("experimental-webgl",a)),this._isWebGL2=!1),!l)throw new Error("Get GL Context FAILED.");this._gl=l,this._initGLState(l)},s.createPlatformPrimitive=function(t){return new Sh(this,t)},s.createPlatformTexture2D=function(t){return new Eh(this,t)},s.createPlatformTexture2DArray=function(t){return new wh(this,t)},s.createPlatformTextureCube=function(t){return new Th(this,t)},s.createPlatformRenderTarget=function(t){return new Ah(this,t)},s.createPlatformBuffer=function(t,e,r,a){return r===void 0&&(r=Je.Static),new yh(this,t,e,r,a)},s.requireExtension=function(t){return this._extensions.requireExtension(t)},s.canIUse=function(t){return this.capability.canIUse(t)},s.canIUseCompressedTextureInternalFormat=function(t){return this.capability.canIUseCompressedTextureInternalFormat(t)},s.viewport=function(t,e,r,a){var o=this,c=o._gl,l=o._lastViewport;(t!==l.x||e!==l.y||r!==l.z||a!==l.w)&&(c.viewport(t,e,r,a),l.set(t,e,r,a))},s.scissor=function(t,e,r,a){var o=this,c=o._gl,l=o._lastScissor;if(t!==l.x||e!==l.y||r!==l.z||a!==l.w){var _=this,u=_._webCanvas;t===0&&e===0&&r===u.width&&a===u.height?this._scissorEnable&&(c.disable(c.SCISSOR_TEST),this._scissorEnable=!1):(this._scissorEnable||(c.enable(c.SCISSOR_TEST),this._scissorEnable=!0),c.scissor(t,e,r,a)),l.set(t,e,r,a)}},s.colorMask=function(t,e,r,a){this._gl.colorMask(t,e,r,a)},s.clearRenderTarget=function(t,e,r){var a=this._gl,o=t._lastRenderState,c=o.blendState.targetBlendState,l=o.depthState,_=o.stencilState,u=0;if(e&zt.Color){u|=a.COLOR_BUFFER_BIT;var h=this._lastClearColor,d=r.r,f=r.g,v=r.b,p=r.a;r&&(d!==h.r||f!==h.g||v!==h.b||p!==h.a)&&(a.clearColor(d,f,v,p),h.set(d,f,v,p)),c.colorWriteMask!==yr.All&&(a.colorMask(!0,!0,!0,!0),c.colorWriteMask=yr.All)}e&zt.Depth&&(u|=a.DEPTH_BUFFER_BIT,l.writeEnabled!==!0&&(a.depthMask(!0),l.writeEnabled=!0)),e&zt.Stencil&&(u|=a.STENCIL_BUFFER_BIT,_.writeMask!==255&&(a.stencilMask(255),_.writeMask=255)),a.clear(u)},s.drawPrimitive=function(t,e,r){t?t.draw(r,e):ve.error("draw primitive failed.")},s.getMainFrameBufferWidth=function(){return this._mainFrameWidth||this._gl.drawingBufferWidth},s.getMainFrameBufferHeight=function(){return this._mainFrameHeight||this._gl.drawingBufferHeight},s.activeRenderTarget=function(t,e,r,a,o){var c,l;if(t){t._isContentLost=!1;var _=t._platformRenderTarget;_.activeRenderTarget(a,o),c=t.width>>a,l=t.height>>a}else{var u=this._gl;u.bindFramebuffer(u.FRAMEBUFFER,this._mainFrameBuffer),c=this.getMainFrameBufferWidth(),l=this.getMainFrameBufferHeight()}var h=c*e.z,d=l*e.w,f=e.x*c,v=r?e.y*l:l-e.y*l-d;this.viewport(f,v,h,d),this.scissor(f,v,h,d)},s.activeTexture=function(t){this._activeTextureID!==t&&(this._gl.activeTexture(t),this._activeTextureID=t)},s.bindTexture=function(t){var e=this._activeTextureID-this._gl.TEXTURE0;this._activeTextures[e]!==t&&(this._gl.bindTexture(t._target,t._glTexture),this._activeTextures[e]=t)},s.setGlobalDepthBias=function(t,e){var r=this._gl,a=t!==0||e!==0;a?(r.enable(r.POLYGON_OFFSET_FILL),r.polygonOffset(e,t)):r.disable(r.POLYGON_OFFSET_FILL),this._enableGlobalDepthBias=a},s.flush=function(){this._gl.flush()},s.forceLoseDevice=function(){var t=this.requireExtension(K.WEBGL_lose_context);t.loseContext()},s.forceRestoreDevice=function(){var t=this.requireExtension(K.WEBGL_lose_context);t.restoreContext()},s.resetState=function(){this._readFrameBuffer=null,this._enableGlobalDepthBias=!1,this._currentBindShaderProgram=null;for(var t=this._activeTextures,e=0,r=t.length;e=0;o--)(a=n[o])&&(r=(e<3?a(r):e>3?a(s,i,r):a(s,i))||r);return e>3&&r&&Object.defineProperty(s,i,r),r}function qi(n,s){var i={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},t,e,r,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(_){return c([l,_])}}function c(l){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(t=1,e&&(r=l[0]&2?e.return:l[0]?e.throw||((r=e.return)&&r.call(e),0):e.next)&&!(r=r.call(e,l[1])).done)return r;switch(e=0,r&&(l=[l[0]&2,r.value]),l[0]){case 0:case 1:r=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,e=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(r=i.trys,!(r=r.length>0&&r[r.length-1])&&(l[0]===6||l[0]===2)){i=0;continue}if(l[0]===3&&(!r||l[1]>r[0]&&l[1]=p&&e(y)};if(w(),o){var E=function(M){var D=new window.Blob([g[M]]),L=new Image;L.onload=function(){y.setImageSource(L,M),w()},L.src=URL.createObjectURL(D)};y.generateMipmaps();for(var P=1;P"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function di(n,s,i){return Dh()?di=Reflect.construct:di=function(e,r,a){var o=[null];o.push.apply(o,r);var c=Function.bind.apply(e,o),l=new c;return a&&Vi(l,a.prototype),l},di.apply(null,arguments)}var ko=function(){function n(i){this._context=i}var s=n.prototype;return s.parseEntity=function(t){return this._getEntityByConfig(t).then(function(e){var r;e.isActive=(r=t.isActive)!=null?r:!0;var a=t.position,o=t.rotation,c=t.scale;a&&e.transform.position.copyFrom(a),o&&e.transform.rotation.copyFrom(o),c&&e.transform.scale.copyFrom(c);var l;return e.layer=(l=t.layer)!=null?l:e.layer,e})},s.parseClassObject=function(t){var e=this,r=Be.getClass(t.class),a,o=(a=t.constructParams)!=null?a:[];return Promise.all(o.map(function(c){return e.parseBasicType(c)})).then(function(c){return di(r,[].concat(c))}).then(function(c){return e.parsePropsAndMethods(c,t)})},s.parsePropsAndMethods=function(t,e){var r=[];if(e.methods)for(var a in e.methods)for(var o=e.methods[a],c=0,l=o.length;cn.length)&&(s=n.length);for(var i=0,t=new Array(s);i=n.length?{done:!0}:{done:!1,value:n[t++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var Vh=function(){function n(i){var t=this;this.context=i,this.prefabContextMap=new WeakMap,this.prefabPromiseMap=new Map,this._engine=this.context.engine,this._organizeEntities=this._organizeEntities.bind(this),this._parseComponents=this._parseComponents.bind(this),this._parsePrefabModification=this._parsePrefabModification.bind(this),this._parsePrefabRemovedEntities=this._parsePrefabRemovedEntities.bind(this),this._parsePrefabRemovedComponents=this._parsePrefabRemovedComponents.bind(this),this._clearAndResolve=this._clearAndResolve.bind(this),this.promise=new Promise(function(e,r){t._reject=r,t._resolve=e}),this._reflectionParser=new ko(i)}var s=n.prototype;return s.start=function(){this._parseEntities().then(this._organizeEntities).then(this._parseComponents).then(this._parsePrefabModification).then(this._parsePrefabRemovedEntities).then(this._parsePrefabRemovedComponents).then(this._clearAndResolve).then(this._resolve).catch(this._reject)},s._parseEntities=function(){var t=this,e=this.context.originalData.entities,r=this.context.entityConfigMap,a=this.context.entityMap,o=this._engine,c=e.map(function(l){var _,u=(_=l.strippedId)!=null?_:l.id;return l.id=u,r.set(u,l),t._getEntityByConfig(l,o)});return Promise.all(c).then(function(l){for(var _=0,u=l.length;_0)for(var c=a.get(t),l=0;l>y,x=0;x<6;x++){var C=m*m*4,b=new Uint8Array(l,g,C);g+=C,v.setPixelBuffer(wr.PositiveX+x,b,y)}var A=new Tr(f),S=new sl;A.diffuseMode=Xn.SphericalHarmonics,S.copyFromArray(u),A.diffuseSphericalHarmonics=S,A.specularTexture=v,A.specularTextureDecodeRGBM=!0,o(A)}).catch(function(l){c(l)})})},s}(Be);Ts=le([Xe(Ve.Env,["env"])],Ts);function Rs(n,s,i,t,e,r,a){try{var o=n[r](a),c=o.value}catch(l){i(l);return}o.done?s(c):Promise.resolve(c).then(t,e)}function Ki(n){return function(){var s=this,i=arguments;return new Promise(function(t,e){var r=n.apply(s,i);function a(c){Rs(r,t,e,a,o,"next",c)}function o(c){Rs(r,t,e,a,o,"throw",c)}a(void 0)})}}var Ms=function(n){ne(s,n);function s(){return n.apply(this,arguments)}var i=s.prototype;return i.load=function(e,r){var a=this;return new Pe(function(o,c){a.request(e.url,{type:"json"}).then(function(l){var _=l.fontName,u=l.fontUrl;if(u)a._registerFont(_,u).then(function(){var d=new _a(r.engine,_);o(d)}).catch(function(d){c("load font "+u+" fail")});else{var h=new _a(r.engine,_);o(h)}}).catch(function(l){c(l)})})},i._registerFont=function(e,r){return Ki(function(){var a;return qi(this,function(o){switch(o.label){case 0:return a=new FontFace(e,"url("+r+")"),[4,a.load()];case 1:return o.sent(),document.fonts.add(a),[2]}})})()},s}(Be);Ms=le([Xe(Ve.Font,["font"],!1)],Ms);var Oh=function(n){ne(s,n);function s(t,e){var r;return r=n.call(this,t)||this,r.url=e,r}var i=s.prototype;return i.instantiateSceneRoot=function(e){var r=e===void 0?this._defaultSceneRoot:this._sceneRoots[e];return r.clone()},i._onDestroy=function(){n.prototype._onDestroy.call(this);var e=this,r=e.textures,a=e.materials,o=e.meshes;if(r&&this._disassociationSuperResource(r),a&&this._disassociationSuperResource(a),o)for(var c=0,l=o.length;c=Ni.NEAREST_MIPMAP_NEAREST,e===yo.NEAREST?o.filterMode=tt.Point:t<=Ni.LINEAR_MIPMAP_NEAREST?o.filterMode=tt.Bilinear:o.filterMode=tt.Trilinear),r&&(o.wrapModeU=Ii._wrapMap[r]),a&&(o.wrapModeV=Ii._wrapMap[a]),o},n}(),Ds;(function(n){n[n.linear=1]="linear",n[n.sRGB=2]="sRGB"})(Ds||(Ds={}));var Ls;(function(n){n[n.ETC1S=163]="ETC1S",n[n.UASTC=166]="UASTC"})(Ls||(Ls={}));var xo;(function(n){n[n.None=0]="None",n[n.BasisLZ=1]="BasisLZ",n[n.Zstd=2]="Zstd",n[n.ZLib=3]="ZLib"})(xo||(xo={}));var Uh=function(){function n(i){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=0,this.levels=[],this.keyValue={},this.globalData=null,this.parse(i)}var s=n.prototype;return s.parse=function(t){var e=t.buffer,r=t.byteOffset,a=new $n(t,12);this.vkFormat=a.nextUint32(),this.typeSize=a.nextUint32(),this.pixelWidth=a.nextUint32(),this.pixelHeight=a.nextUint32(),this.pixelDepth=a.nextUint32(),this.layerCount=a.nextUint32(),this.faceCount=a.nextUint32();var o=Math.max(1,a.nextUint32());this.supercompressionScheme=a.nextUint32();var c=a.nextUint32(),l=a.nextUint32(),_=a.nextUint32(),u=a.nextUint32(),h=a.nextUint64(),d=a.nextUint64(),f=new Array(o),v=o*3*8,p=new $n(t,a.offset,v);this.levels=f;for(var g=0;g>2)*(_+3>>2),h=u*16+65535>>16,d=o.memory,f=h+1-(d.buffer.byteLength>>16);f>0&&d.grow(f);var v=new Uint8Array(d.buffer,65536,u*16);return v.set(c),o.transcode(u)===0?v:null},s=function(o){return t=WebAssembly.instantiate(o,{env:{memory:new WebAssembly.Memory({initial:16})}}).then(function(c){return c.instance.exports}),t},i=function(o,c,l){var _=o.length,u=new Array(_),h=Promise.resolve();return c&&(r.init(),h=r._initPromise),h.then(function(){for(var d=0;d<_;d++){for(var f=o[d].length,v=new Array(f),p=0;p1,f=this._getEngineTextureFormat(a,r),v;if(u!==6){v=new Rt(e,c,l,f,d);for(var p=0;p3?a-3:0),c=3;c4?o-4:0),l=4;l3?r-3:0),o=3;o=0;--_){var u,h=l[_],d=i[h];if(c=(u=n)._createAndParse.apply(u,[].concat(h,t,d,e,a)),c)return c}},n.executeExtensionsAdditiveAndParse=function(i,t,e,r){for(var a=arguments.length,o=new Array(a>4?a-4:0),c=4;c=0;--o){var c=r[o];if(c._mode===t)return c}},n._addExtensionParser=function(i,t){n._extensionParsers[i]||(n._extensionParsers[i]=[]),n._extensionParsers[i].push(t)},n._createAndParse=function(i,t,e,r){for(var a=arguments.length,o=new Array(a>4?a-4:0),c=4;c5?o-5:0),l=5;lCn.UV1&&ve.warn("Occlusion texture uv coordinate must be UV0 or UV1.")}}switch(f?r.renderFace=an.Double:r.renderFace=an.Front,h){case Sa.OPAQUE:r.isTransparent=!1;break;case Sa.BLEND:r.isTransparent=!0;break;case Sa.MASK:r.alphaCutoff=d??.5;break}},s}(Fe);bt=ce([wr(pe.Material)],bt);function So(n,s){return s!=null&&typeof Symbol<"u"&&s[Symbol.hasInstance]?!!s[Symbol.hasInstance](n):n instanceof s}var eo,Aa=(eo=function(n){ne(s,n);function s(){return n.apply(this,arguments)}var i=s.prototype;return i.parse=function(e,r){for(var a=function(f,v){var p=o.primitives[f];u[f]=new Promise(function(g){var y=Fe.executeExtensionsCreateAndParse(p.extensions,e,p,o);if(y)So(y,dt)?(y._associationSuperResource(l),g(y)):y.then(function(C){C._associationSuperResource(l),g(C)});else{var m=new dt(_,o.name||f+"");m._associationSuperResource(l);var x=new jh;x.mesh=m,e.contentRestorer.meshes.push(x),Aa._parseMeshFromGLTFPrimitive(e,m,x,o,p,c,e.params.keepMeshData).then(g)}})},o=e.glTF.meshes[r],c=e.glTF,l=e.glTFResource,_=l.engine,u=new Array,h=0,d=o.primitives.length;h=f.length)return h;for(var v=f[d],p=1,g=e.length;p=f.length||v!==f[d])return h;h=v}},s}(Fe);zs=ce([wr(pe.Skin)],zs);var to,Fi=(to=function(n){ne(s,n);function s(){return n.apply(this,arguments)}var i=s.prototype;return i.parse=function(e,r){var a=e.glTF.textures[r],o=e.glTFResource,c=e.glTF,l=o.engine,_=o.url,u=a.sampler,h=a.source,d=h===void 0?0:h,f=a.name,v=a.extensions,p=c.images[d],g=p.uri,y=p.bufferView,m=p.mimeType,x=p.name,C=Fe.executeExtensionsCreateAndParse(v,e,a);if(!C){var b=u!==void 0,A=u!==void 0&&Ke.getSamplerInfo(c.samplers[u]);if(g){var S,w=g.lastIndexOf("."),E=g.substring(w+1),B=E.startsWith("ktx")?Ve.KTX:Ve.Texture2D;C=l.resourceManager.load({url:Ue.resolveAbsoluteUrl(_,g),type:B,params:{mipmap:(S=A)==null?void 0:S.mipmap}}).onProgress(void 0,e._onTaskDetail).then(function(D){return D.name=f||x||D.name||"texture_"+r,b&&Ke.parseSampler(D,A),D}),e._addTaskCompletePromise(C)}else{var M=c.bufferViews[y];C=e.get(pe.Buffer).then(function(D){var L=D[M.buffer],V=new Uint8Array(L,M.byteOffset,M.byteLength);return Ke.loadImageBuffer(V,m).then(function(N){var I,P=new Rt(l,N.width,N.height,void 0,(I=A)==null?void 0:I.mipmap);P.setImageSource(N),P.generateMipmaps(),P.name=f||x||"texture_"+r,b&&Ke.parseSampler(P,A);var z=new $c(P,M,m);return e.contentRestorer.bufferTextures.push(z),P})})}}return Promise.resolve(C).then(function(D){return Fe.executeExtensionsAdditiveAndParse(v,e,D,a),D._associationSuperResource(o),D})},s}(Fe),function(){var n;to._wrapMap=(n={},n[Ca.CLAMP_TO_EDGE]=gt.Clamp,n[Ca.MIRRORED_REPEAT]=gt.Mirror,n[Ca.REPEAT]=gt.Repeat,n)}(),to);Fi=ce([wr(pe.Texture)],Fi);var Us=function(n){ne(s,n);function s(){return n.apply(this,arguments)}var i=s.prototype;return i.parse=function(e){var r=e.glTF,a=r.asset.version,o=r.extensionsUsed,c=r.extensionsRequired,l=Number(a);if(!(l>=2&&l<3))throw"Only support glTF 2.x.";if(o){ve.info("extensionsUsed: ",o);for(var _=0;_96?m-97:m>64?m-39:m+4}for(var x=0,C=0;C>2)*(_+3>>2),h=u*16+65535>>16,d=o.memory,f=h+1-(d.buffer.byteLength>>16);f>0&&d.grow(f);var v=new Uint8Array(d.buffer,65536,u*16);return v.set(c),o.transcode(u)===0?v:null},s=function(o){return t=WebAssembly.instantiate(o,{env:{memory:new WebAssembly.Memory({initial:16})}}).then(function(c){return c.instance.exports}),t},i=function(o,c,l){var _=o.length,u=new Array(_),h=Promise.resolve();return c&&(r.init(),h=r._initPromise),h.then(function(){for(var d=0;d<_;d++){for(var f=o[d].length,v=new Array(f),p=0;p1,f=this._getEngineTextureFormat(a,r),v;if(u!==6){v=new Tt(e,c,l,f,d);for(var p=0;p3?a-3:0),c=3;c4?o-4:0),l=4;l3?r-3:0),o=3;o=0;--_){var u,h=l[_],d=i[h];if(c=(u=n)._createAndParse.apply(u,[].concat(h,t,d,e,a)),c)return c}},n.executeExtensionsAdditiveAndParse=function(i,t,e,r){for(var a=arguments.length,o=new Array(a>4?a-4:0),c=4;c=0;--o){var c=r[o];if(c._mode===t)return c}},n._addExtensionParser=function(i,t){n._extensionParsers[i]||(n._extensionParsers[i]=[]),n._extensionParsers[i].push(t)},n._createAndParse=function(i,t,e,r){for(var a=arguments.length,o=new Array(a>4?a-4:0),c=4;c5?o-5:0),l=5;lCn.UV1&&ve.warn("Occlusion texture uv coordinate must be UV0 or UV1.")}}switch(f?r.renderFace=an.Double:r.renderFace=an.Front,h){case Aa.OPAQUE:r.isTransparent=!1;break;case Aa.BLEND:r.isTransparent=!0;break;case Aa.MASK:r.alphaCutoff=d??.5;break}},s}(Fe);bt=le([Rr(pe.Material)],bt);function Ao(n,s){return s!=null&&typeof Symbol<"u"&&s[Symbol.hasInstance]?!!s[Symbol.hasInstance](n):n instanceof s}var ro,wa=(ro=function(n){ne(s,n);function s(){return n.apply(this,arguments)}var i=s.prototype;return i.parse=function(e,r){for(var a=function(f,v){var p=o.primitives[f];u[f]=new Promise(function(g){var y=Fe.executeExtensionsCreateAndParse(p.extensions,e,p,o);if(y)Ao(y,dt)?(y._associationSuperResource(l),g(y)):y.then(function(C){C._associationSuperResource(l),g(C)});else{var m=new dt(_,o.name||f+"");m._associationSuperResource(l);var x=new qh;x.mesh=m,e.contentRestorer.meshes.push(x),wa._parseMeshFromGLTFPrimitive(e,m,x,o,p,c,e.params.keepMeshData).then(g)}})},o=e.glTF.meshes[r],c=e.glTF,l=e.glTFResource,_=l.engine,u=new Array,h=0,d=o.primitives.length;h=f.length)return h;for(var v=f[d],p=1,g=e.length;p=f.length||v!==f[d])return h;h=v}},s}(Fe);ks=le([Rr(pe.Skin)],ks);var no,Ii=(no=function(n){ne(s,n);function s(){return n.apply(this,arguments)}var i=s.prototype;return i.parse=function(e,r){var a=e.glTF.textures[r],o=e.glTFResource,c=e.glTF,l=o.engine,_=o.url,u=a.sampler,h=a.source,d=h===void 0?0:h,f=a.name,v=a.extensions,p=c.images[d],g=p.uri,y=p.bufferView,m=p.mimeType,x=p.name,C=Fe.executeExtensionsCreateAndParse(v,e,a);if(!C){var b=u!==void 0,A=u!==void 0&&Ke.getSamplerInfo(c.samplers[u]);if(g){var S,w=g.lastIndexOf("."),E=g.substring(w+1),P=E.startsWith("ktx")?Ve.KTX:Ve.Texture2D;C=l.resourceManager.load({url:Ue.resolveAbsoluteUrl(_,g),type:P,params:{mipmap:(S=A)==null?void 0:S.mipmap}}).onProgress(void 0,e._onTaskDetail).then(function(D){return D.name=f||x||D.name||"texture_"+r,b&&Ke.parseSampler(D,A),D}),e._addTaskCompletePromise(C)}else{var M=c.bufferViews[y];C=e.get(pe.Buffer).then(function(D){var L=D[M.buffer],V=new Uint8Array(L,M.byteOffset,M.byteLength);return Ke.loadImageBuffer(V,m).then(function(N){var I,B=new Tt(l,N.width,N.height,void 0,(I=A)==null?void 0:I.mipmap);B.setImageSource(N),B.generateMipmaps(),B.name=f||x||"texture_"+r,b&&Ke.parseSampler(B,A);var z=new el(B,M,m);return e.contentRestorer.bufferTextures.push(z),B})})}}return Promise.resolve(C).then(function(D){return Fe.executeExtensionsAdditiveAndParse(v,e,D,a),D._associationSuperResource(o),D})},s}(Fe),function(){var n;no._wrapMap=(n={},n[Ea.CLAMP_TO_EDGE]=gt.Clamp,n[Ea.MIRRORED_REPEAT]=gt.Mirror,n[Ea.REPEAT]=gt.Repeat,n)}(),no);Ii=le([Rr(pe.Texture)],Ii);var Gs=function(n){ne(s,n);function s(){return n.apply(this,arguments)}var i=s.prototype;return i.parse=function(e){var r=e.glTF,a=r.asset.version,o=r.extensionsUsed,c=r.extensionsRequired,l=Number(a);if(!(l>=2&&l<3))throw"Only support glTF 2.x.";if(o){ve.info("extensionsUsed: ",o);for(var _=0;_96?m-97:m>64?m-39:m+4}for(var x=0,C=0;C0&&d.length===0&&this.useWorkers(),d.length>0?e(p,g,y,h[m],u[x]):_.then(function(){var C=new Uint8Array(p*g);return s(l.exports[h[m]],C,p,g,y,l.exports[u[x]]),C})},release:function(){for(var p=0;p>1,y=Ea._convertToCubemap(p,d,f,g),m=new jt(l,g),x=0;x<6;x++)m.setPixelBuffer(Ar.PositiveX+x,y[x],0);m.generateMipmaps(),o(m)}).catch(c)})},s._convertToCubemap=function(e,r,a,o){if(!e)throw"ConvertPanoramaToCubemap: input cannot be null";if(e.length!=r*a*4)throw"ConvertPanoramaToCubemap: input size is wrong";var c=this._createCubemapData(o,this._faceRight,e,r,a),l=this._createCubemapData(o,this._faceLeft,e,r,a),_=this._createCubemapData(o,this._faceUp,e,r,a),u=this._createCubemapData(o,this._faceBottom,e,r,a),h=this._createCubemapData(o,this._faceFront,e,r,a),d=this._createCubemapData(o,this._faceBack,e,r,a);return[c,l,_,u,h,d]},s._createCubemapData=function(e,r,a,o,c){for(var l=new Uint8ClampedArray(e*e*4),_=this._tempVector3.set(0,0,0).add(r[1]).subtract(r[0]).scale(1/e),u=this._temp2Vector3.set(0,0,0).add(r[3]).subtract(r[2]).scale(1/e),h=1/e,d=0,f=0;fJn;)c-=2*Jn;var _=c/Jn,u=l/Jn;_=_*.5+.5;var h=Math.round(_*a);h<0?h=0:h>=a&&(h=a-1);var d=Math.round(u*o);d<0?d=0:d>=o&&(d=o-1);var f=o-d-1,v=f*a*4+h*4,p=r[v],g=r[v+1],y=r[v+2],m=r[v+3];return new q(p,g,y,m)},s._readStringLine=function(e,r){for(var a="",o="",c=r;c32767)throw"HDR Bad header format, unsupported size";return _+=o.length+1,{height:r,width:a,dataPosition:_}},s._readPixels=function(e,r,a){for(var o=r,c=e.byteLength,l=new Uint8Array(4*r*a),_=0,u=0,h=4*o,d=new Uint8Array(h),f=a;f>0&&u32767)return e;if((g<<8|y)!=o)throw"HDR Bad header format, wrong scan line width";for(var m=0,x=void 0;m128;if(C&&(x-=128),x===0||m+x>h)throw"HDR Bad Format, bad scanline data (run)";if(C)for(var b=e[u++],A=0;A=12){var s=new Uint8Array(n,0,12);if(s[0]===171&&s[1]===75&&s[2]===84&&s[3]===88&&s[4]===32&&s[5]===49&&s[6]===49&&s[7]===187&&s[8]===13&&s[9]===10&&s[10]===26&&s[11]===10)return!0}return!1}function $h(n){switch(n){case le.RGB_S3TC_DXT1_EXT:return G.BC1;case le.RGBA_S3TC_DXT5_EXT:return G.BC3;case le.RGBA_BPTC_UNORM_EXT:return G.BC7;case le.RGB_ETC1_WEBGL:return G.ETC1_RGB;case le.RGB8_ETC2:return G.ETC2_RGB;case le.RGB8_PUNCHTHROUGH_ALPHA1_ETC2:return G.ETC2_RGBA5;case le.RGBA8_ETC2_EAC:return G.ETC2_RGBA8;case le.RGB_PVRTC_2BPPV1_IMG:return G.PVRTC_RGB2;case le.RGBA_PVRTC_2BPPV1_IMG:return G.PVRTC_RGBA2;case le.RGB_PVRTC_4BPPV1_IMG:return G.PVRTC_RGB4;case le.RGBA_PVRTC_4BPPV1_IMG:return G.PVRTC_RGBA4;case le.RGBA_ASTC_4X4_KHR:return G.ASTC_4x4;case le.RGBA_ASTC_5X5_KHR:return G.ASTC_5x5;case le.RGBA_ASTC_6X6_KHR:return G.ASTC_6x6;case le.RGBA_ASTC_8X8_KHR:return G.ASTC_8x8;case le.RGBA_ASTC_10X10_KHR:return G.ASTC_10x10;case le.RGBA_ASTC_12X12_KHR:return G.ASTC_12x12;default:var s=le[n];throw new Error("this format is not supported in Galacean Engine: "+s)}}var el={parse:function(s,i,t,e){if(e===void 0&&(e=!1),!Zh(s))throw new Error("khronosTextureContainerParser: invalid KTX file, texture missing KTX identifier");var r=Uint32Array.BYTES_PER_ELEMENT,a=new DataView(s,12,13*r),o=a.getUint32(0,!0),c=o===67305985,l={buffer:s,glType:a.getUint32(1*r,c),glTypeSize:a.getUint32(2*r,c),glFormat:a.getUint32(3*r,c),glInternalFormat:a.getUint32(4*r,c),glBaseInternalFormat:a.getUint32(5*r,c),pixelWidth:a.getUint32(6*r,c),pixelHeight:a.getUint32(7*r,c),pixelDepth:a.getUint32(8*r,c),numberOfArrayElements:a.getUint32(9*r,c),numberOfFaces:a.getUint32(10*r,c),numberOfMipmapLevels:a.getUint32(11*r,c),bytesOfKeyValueData:a.getUint32(12*r,c),loadType:Kh};if(l.glType!==0)throw new Error("only compressed formats currently supported");if(l.numberOfMipmapLevels=Math.max(1,l.numberOfMipmapLevels),l.pixelHeight===0||l.pixelDepth!==0)throw new Error("only 2D textures currently supported");if(l.numberOfArrayElements!==0)throw new Error("texture arrays not currently supported");if(l.numberOfFaces!==i)throw new Error("number of faces expected"+i+", but found "+l.numberOfFaces);return t&&(l.mipmaps=Jh(l)),e&&(l.engineFormat=$h(l.glInternalFormat)),l}};function ed(n){var s=el.parse(n,1,!0,!0);return{mipmaps:s.mipmaps,engineFormat:s.engineFormat,internalFormat:s.glInternalFormat,width:s.pixelWidth,height:s.pixelHeight}}function td(n){for(var s=[],i,t,e,r,a=0;a1,v=new jt(r.engine,u,d,f),p=0;p<6;p++)for(var g=h[p].length,y=0;y1,p=new Rt(r.engine,u,h,f,v),g=0;g0&&d.length===0&&this.useWorkers(),d.length>0?e(p,g,y,h[m],u[x]):_.then(function(){var C=new Uint8Array(p*g);return s(l.exports[h[m]],C,p,g,y,l.exports[u[x]]),C})},release:function(){for(var p=0;p>1,y=Ta._convertToCubemap(p,d,f,g),m=new jt(l,g),x=0;x<6;x++)m.setPixelBuffer(wr.PositiveX+x,y[x],0);m.generateMipmaps(),o(m)}).catch(c)})},s._convertToCubemap=function(e,r,a,o){if(!e)throw"ConvertPanoramaToCubemap: input cannot be null";if(e.length!=r*a*4)throw"ConvertPanoramaToCubemap: input size is wrong";var c=this._createCubemapData(o,this._faceRight,e,r,a),l=this._createCubemapData(o,this._faceLeft,e,r,a),_=this._createCubemapData(o,this._faceUp,e,r,a),u=this._createCubemapData(o,this._faceBottom,e,r,a),h=this._createCubemapData(o,this._faceFront,e,r,a),d=this._createCubemapData(o,this._faceBack,e,r,a);return[c,l,_,u,h,d]},s._createCubemapData=function(e,r,a,o,c){for(var l=new Uint8ClampedArray(e*e*4),_=this._tempVector3.set(0,0,0).add(r[1]).subtract(r[0]).scale(1/e),u=this._temp2Vector3.set(0,0,0).add(r[3]).subtract(r[2]).scale(1/e),h=1/e,d=0,f=0;fZn;)c-=2*Zn;var _=c/Zn,u=l/Zn;_=_*.5+.5;var h=Math.round(_*a);h<0?h=0:h>=a&&(h=a-1);var d=Math.round(u*o);d<0?d=0:d>=o&&(d=o-1);var f=o-d-1,v=f*a*4+h*4,p=r[v],g=r[v+1],y=r[v+2],m=r[v+3];return new q(p,g,y,m)},s._readStringLine=function(e,r){for(var a="",o="",c=r;c32767)throw"HDR Bad header format, unsupported size";return _+=o.length+1,{height:r,width:a,dataPosition:_}},s._readPixels=function(e,r,a){for(var o=r,c=e.byteLength,l=new Uint8Array(4*r*a),_=0,u=0,h=4*o,d=new Uint8Array(h),f=a;f>0&&u32767)return e;if((g<<8|y)!=o)throw"HDR Bad header format, wrong scan line width";for(var m=0,x=void 0;m128;if(C&&(x-=128),x===0||m+x>h)throw"HDR Bad Format, bad scanline data (run)";if(C)for(var b=e[u++],A=0;A=12){var s=new Uint8Array(n,0,12);if(s[0]===171&&s[1]===75&&s[2]===84&&s[3]===88&&s[4]===32&&s[5]===49&&s[6]===49&&s[7]===187&&s[8]===13&&s[9]===10&&s[10]===26&&s[11]===10)return!0}return!1}function ed(n){switch(n){case _e.RGB_S3TC_DXT1_EXT:return G.BC1;case _e.RGBA_S3TC_DXT5_EXT:return G.BC3;case _e.RGBA_BPTC_UNORM_EXT:return G.BC7;case _e.RGB_ETC1_WEBGL:return G.ETC1_RGB;case _e.RGB8_ETC2:return G.ETC2_RGB;case _e.RGB8_PUNCHTHROUGH_ALPHA1_ETC2:return G.ETC2_RGBA5;case _e.RGBA8_ETC2_EAC:return G.ETC2_RGBA8;case _e.RGB_PVRTC_2BPPV1_IMG:return G.PVRTC_RGB2;case _e.RGBA_PVRTC_2BPPV1_IMG:return G.PVRTC_RGBA2;case _e.RGB_PVRTC_4BPPV1_IMG:return G.PVRTC_RGB4;case _e.RGBA_PVRTC_4BPPV1_IMG:return G.PVRTC_RGBA4;case _e.RGBA_ASTC_4X4_KHR:return G.ASTC_4x4;case _e.RGBA_ASTC_5X5_KHR:return G.ASTC_5x5;case _e.RGBA_ASTC_6X6_KHR:return G.ASTC_6x6;case _e.RGBA_ASTC_8X8_KHR:return G.ASTC_8x8;case _e.RGBA_ASTC_10X10_KHR:return G.ASTC_10x10;case _e.RGBA_ASTC_12X12_KHR:return G.ASTC_12x12;default:var s=_e[n];throw new Error("this format is not supported in Galacean Engine: "+s)}}var tl={parse:function(s,i,t,e){if(e===void 0&&(e=!1),!$h(s))throw new Error("khronosTextureContainerParser: invalid KTX file, texture missing KTX identifier");var r=Uint32Array.BYTES_PER_ELEMENT,a=new DataView(s,12,13*r),o=a.getUint32(0,!0),c=o===67305985,l={buffer:s,glType:a.getUint32(1*r,c),glTypeSize:a.getUint32(2*r,c),glFormat:a.getUint32(3*r,c),glInternalFormat:a.getUint32(4*r,c),glBaseInternalFormat:a.getUint32(5*r,c),pixelWidth:a.getUint32(6*r,c),pixelHeight:a.getUint32(7*r,c),pixelDepth:a.getUint32(8*r,c),numberOfArrayElements:a.getUint32(9*r,c),numberOfFaces:a.getUint32(10*r,c),numberOfMipmapLevels:a.getUint32(11*r,c),bytesOfKeyValueData:a.getUint32(12*r,c),loadType:Jh};if(l.glType!==0)throw new Error("only compressed formats currently supported");if(l.numberOfMipmapLevels=Math.max(1,l.numberOfMipmapLevels),l.pixelHeight===0||l.pixelDepth!==0)throw new Error("only 2D textures currently supported");if(l.numberOfArrayElements!==0)throw new Error("texture arrays not currently supported");if(l.numberOfFaces!==i)throw new Error("number of faces expected"+i+", but found "+l.numberOfFaces);return t&&(l.mipmaps=Zh(l)),e&&(l.engineFormat=ed(l.glInternalFormat)),l}};function td(n){var s=tl.parse(n,1,!0,!0);return{mipmaps:s.mipmaps,engineFormat:s.engineFormat,internalFormat:s.glInternalFormat,width:s.pixelWidth,height:s.pixelHeight}}function rd(n){for(var s=[],i,t,e,r,a=0;a1,v=new jt(r.engine,u,d,f),p=0;p<6;p++)for(var g=h[p].length,y=0;y1,p=new Tt(r.engine,u,h,f,v),g=0;g - + - + diff --git a/mpa/galacean/collider-benchmark.html b/mpa/galacean/collider-benchmark.html index 417af3d..33fe4e6 100644 --- a/mpa/galacean/collider-benchmark.html +++ b/mpa/galacean/collider-benchmark.html @@ -22,9 +22,9 @@ overflow: initial; } - + - + diff --git a/mpa/galacean/particle-benchmark.html b/mpa/galacean/particle-benchmark.html index 8d9f883..bab795e 100644 --- a/mpa/galacean/particle-benchmark.html +++ b/mpa/galacean/particle-benchmark.html @@ -22,9 +22,9 @@ overflow: initial; } - + - + diff --git a/mpa/galacean/point-light.html b/mpa/galacean/point-light.html index 714305d..d7879d4 100644 --- a/mpa/galacean/point-light.html +++ b/mpa/galacean/point-light.html @@ -22,9 +22,9 @@ overflow: initial; } - + - +