!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";var e,t;e=void 0,t=function(e,t){var i=t.ShaderChunk;function registerShaderChunks(){i.tile_pars_vertex="\n#ifdef UV_TILE\n attribute float uvTile;\n uniform vec2 tileCount;\n \n mat3 makeTileTransform(float uvTile) {\n float col = mod(uvTile, tileCount.x);\n float row = (tileCount.y - floor(uvTile / tileCount.x) - 1.0);\n \n return mat3(\n 1.0 / tileCount.x, 0.0, 0.0,\n 0.0, 1.0 / tileCount.y, 0.0, \n col / tileCount.x, row / tileCount.y, 1.0);\n }\n#else\n mat3 makeTileTransform(float uvTile) {\n return mat3(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0);\n }\n#endif\n\n#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\n\tvarying vec2 vUv;\n#ifdef TILE_BLEND\n varying vec2 vUvNext;\n varying float vUvBlend;\n#endif\n\n#endif\n#ifdef USE_MAP\n\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#ifdef TILE_BLEND\n varying vec2 vMapUvNext;\n#endif\n\n#endif\n#ifdef USE_ALPHAMAP\n\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n\n#endif\n#ifdef USE_LIGHTMAP\n\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n\n#endif\n#ifdef USE_AOMAP\n\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n\n#endif\n#ifdef USE_BUMPMAP\n\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n\n#endif\n#ifdef USE_NORMALMAP\n\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n\n#endif\n#ifdef USE_EMISSIVEMAP\n\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n\n#endif\n#ifdef USE_METALNESSMAP\n\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n\n#endif\n#ifdef USE_ROUGHNESSMAP\n\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n\n#endif\n#ifdef USE_ANISOTROPYMAP\n\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n\n#endif\n#ifdef USE_CLEARCOATMAP\n\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n\n#endif\n#ifdef USE_SPECULARMAP\n\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n\n#endif\n#ifdef USE_THICKNESSMAP\n\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n\n#endif\n",i.tile_vertex="\n#ifdef UV_TILE\n mat3 tileTransform = makeTileTransform(floor(uvTile));\n #ifdef TILE_BLEND\n mat3 nextTileTransform = makeTileTransform(ceil(uvTile));\n vUvBlend = fract(uvTile);\n #endif\n#else\n mat3 tileTransform = makeTileTransform(0.0);\n#endif\n\n#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\nvUv = (tileTransform *vec3( uv, 1 )).xy;\n#if defined( TILE_BLEND ) && defined( UV_TILE )\n vUvNext = (nextTileTransform *vec3( uv, 1 )).xy;\n#endif\n\n#endif\n#ifdef USE_MAP\n\nvMapUv = ( tileTransform * (mapTransform * vec3( MAP_UV, 1 ) )).xy;\n#if defined( TILE_BLEND ) && defined( UV_TILE )\n vMapUvNext = (nextTileTransform * (mapTransform * vec3( MAP_UV, 1 ))).xy;\n#endif\n\n#endif\n#ifdef USE_ALPHAMAP\n\nvAlphaMapUv = ( tileTransform * (alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) )).xy;\n \n#endif\n#ifdef USE_LIGHTMAP\n\nvLightMapUv = ( tileTransform * (lightMapTransform * vec3( LIGHTMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_AOMAP\n\nvAoMapUv = ( tileTransform * (aoMapTransform * vec3( AOMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_BUMPMAP\n\nvBumpMapUv = ( tileTransform * (bumpMapTransform * vec3( BUMPMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_NORMALMAP\n\nvNormalMapUv = ( tileTransform * (normalMapTransform * vec3( NORMALMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\nvDisplacementMapUv = ( tileTransform * (displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_EMISSIVEMAP\n\nvEmissiveMapUv = ( tileTransform * (emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_METALNESSMAP\n\nvMetalnessMapUv = ( tileTransform * (metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_ROUGHNESSMAP\n\nvRoughnessMapUv = ( tileTransform * (roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_ANISOTROPYMAP\n\nvAnisotropyMapUv = ( tileTransform * (anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_CLEARCOATMAP\n\nvClearcoatMapUv = ( tileTransform * (clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\nvClearcoatNormalMapUv = ( tileTransform * (clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\nvClearcoatRoughnessMapUv = ( tileTransform * (clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\nvIridescenceMapUv = ( tileTransform * (iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\nvIridescenceThicknessMapUv = ( tileTransform * (iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\nvSheenColorMapUv = ( tileTransform * (sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\nvSheenRoughnessMapUv = ( tileTransform * (sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_SPECULARMAP\n\nvSpecularMapUv = ( tileTransform * (specularMapTransform * vec3( SPECULARMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\nvSpecularColorMapUv = ( tileTransform * (specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\nvSpecularIntensityMapUv = ( tileTransform * (specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\nvTransmissionMapUv = ( tileTransform * transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_THICKNESSMAP\n\nvThicknessMapUv = ( tileTransform * thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) )).xy;\n\n#endif\n\n",i.tile_pars_fragment="\n#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\n\tvarying vec2 vUv;\n#ifdef TILE_BLEND\n varying vec2 vUvNext;\n varying float vUvBlend;\n#endif\n\n#endif\n#ifdef USE_MAP\n\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#ifdef TILE_BLEND\n varying vec2 vMapUvNext;\n#endif\n\n#endif\n#ifdef USE_ALPHAMAP\n\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n\n#endif\n#ifdef USE_LIGHTMAP\n\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n\n#endif\n#ifdef USE_AOMAP\n\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n\n#endif\n#ifdef USE_BUMPMAP\n\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n\n#endif\n#ifdef USE_NORMALMAP\n\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n\n#endif\n#ifdef USE_EMISSIVEMAP\n\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n\n#endif\n#ifdef USE_METALNESSMAP\n\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n\n#endif\n#ifdef USE_ROUGHNESSMAP\n\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n\n#endif\n#ifdef USE_ANISOTROPYMAP\n\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n\n#endif\n#ifdef USE_CLEARCOATMAP\n\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n\n#endif\n#ifdef USE_SPECULARMAP\n\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n\n#endif\n#ifdef USE_THICKNESSMAP\n\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n\n#endif\n",i.tile_fragment="\n#ifdef USE_MAP\n vec4 texelColor = texture2D( map, vUv);\n #ifdef TILE_BLEND\n texelColor = mix( texelColor, texture2D( map, vUvNext ), vUvBlend );\n #endif\n diffuseColor *= texelColor;\n#endif\n",i.soft_pars_vertex="\n#ifdef SOFT_PARTICLES\n varying vec4 projPosition;\n varying float linearDepth;\n#endif\n",i.soft_vertex="\n#ifdef SOFT_PARTICLES\n projPosition = gl_Position;\n linearDepth = -mvPosition.z;\n#endif\n",i.soft_pars_fragment="\n#ifdef SOFT_PARTICLES\n\n uniform sampler2D depthTexture;\n uniform vec4 projParams;\n uniform vec2 softParams;\n\n varying vec4 projPosition;\n varying float linearDepth;\n\n #define SOFT_NEAR_FADE softParams.x\n #define SOFT_INV_FADE_DISTANCE softParams.y\n\n #define zNear projParams.x\n #define zFar projParams.y\n\n float linearize_depth(float d)\n {\n return (zFar * zNear) / (zFar - d * (zFar - zNear));\n }\n\n#endif\n",i.soft_fragment="\n#ifdef SOFT_PARTICLES\n\n /* #ifdef LOGDEPTH\n float distSample = linearize_depth_log(sampleDepth, near, far);\n #else\n float distSample = ortho ? linearize_depth_ortho(sampleDepth, near, far) : linearize_depth(sampleDepth, near, far);\n #endif */\n\n vec2 p2 = projPosition.xy / projPosition.w;\n \n p2 = 0.5 * p2 + 0.5;\n\n float readDepth = texture2D(depthTexture, p2.xy).r;\n float viewDepth = linearize_depth(readDepth);\n\n float softParticlesFade = saturate(SOFT_INV_FADE_DISTANCE * ((viewDepth - SOFT_NEAR_FADE) - linearDepth));\n \n gl_FragColor *= softParticlesFade;\n\n //gl_FragColor = vec4(softParticlesFade , 0, 0, 1);\n#endif\n"}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=Array(t);i=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,s=!0,a=!1;return{s:function(){i=i.call(e)},n:function(){var e=i.next();return s=e.done,e},e:function(e){a=!0,n=e},f:function(){try{s||null==i.return||i.return()}finally{if(a)throw n}}}}function _defineProperty(e,t,i){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,i){var r=function _superPropBase(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=_getPrototypeOf(e)););return e}(e,t);if(r){var n=Object.getOwnPropertyDescriptor(r,t);return n.get?n.get.call(arguments.length<3?e:i):n.value}},_get.apply(null,arguments)}function _getPrototypeOf(e){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},_getPrototypeOf(e)}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_setPrototypeOf(e,t)}function _isNativeReflectConstruct(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_isNativeReflectConstruct=function(){return!!e})()}function _setPrototypeOf(e,t){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},_setPrototypeOf(e,t)}function _toPropertyKey(e){var t=function _toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var r=i.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}var r=function(e){function ParticleEmitter(e){var t;return _classCallCheck(this,ParticleEmitter),_defineProperty(t=_callSuper(this,ParticleEmitter),"type","ParticleEmitter"),_defineProperty(t,"system",void 0),t.system=e,t}return _inherits(ParticleEmitter,e),_createClass(ParticleEmitter,[{key:"clone",value:function clone(){var e=this.system.clone();return e.emitter.copy(this,!0),e.emitter}},{key:"dispose",value:function dispose(){}},{key:"extractFromCache",value:function extractFromCache(e){var t=[];for(var i in e){var r=e[i];delete r.metadata,t.push(r)}return t}},{key:"toJSON",value:function toJSON(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=this.children;this.children=this.children.filter((function(e){return"ParticleSystemPreview"!==e.type}));var r=_get(_getPrototypeOf(ParticleEmitter.prototype),"toJSON",this).call(this,e);return this.children=i,null!==this.system&&(r.object.ps=this.system.toJSON(e,t)),r}}])}(t.Object3D);const n=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let s=1234567;const a=Math.PI/180,o=180/Math.PI;function generateUUID(){const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,i=4294967295*Math.random()|0,r=4294967295*Math.random()|0;return(n[255&e]+n[e>>8&255]+n[e>>16&255]+n[e>>24&255]+"-"+n[255&t]+n[t>>8&255]+"-"+n[t>>16&15|64]+n[t>>24&255]+"-"+n[63&i|128]+n[i>>8&255]+"-"+n[i>>16&255]+n[i>>24&255]+n[255&r]+n[r>>8&255]+n[r>>16&255]+n[r>>24&255]).toLowerCase()}function clamp(e,t,i){return Math.max(t,Math.min(i,e))}function euclideanModulo(e,t){return(e%t+t)%t}function mapLinear(e,t,i,r,n){return r+(e-t)*(n-r)/(i-t)}function inverseLerp(e,t,i){return e!==t?(i-e)/(t-e):0}function lerp(e,t,i){return(1-i)*e+i*t}function damp(e,t,i,r){return lerp(e,t,1-Math.exp(-i*r))}function pingpong(e,t=1){return t-Math.abs(euclideanModulo(e,2*t)-t)}function smoothstep(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*(3-2*e)}function smootherstep(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*e*(e*(6*e-15)+10)}function randInt(e,t){return e+Math.floor(Math.random()*(t-e+1))}function randFloat(e,t){return e+Math.random()*(t-e)}function randFloatSpread(e){return e*(.5-Math.random())}function seededRandom(e){void 0!==e&&(s=e);let t=s+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}function degToRad(e){return e*a}function radToDeg(e){return e*o}function isPowerOfTwo(e){return!(e&e-1)&&0!==e}function ceilPowerOfTwo(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function floorPowerOfTwo(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function setQuaternionFromProperEuler(e,t,i,r,n){const s=Math.cos,a=Math.sin,o=s(i/2),h=a(i/2),l=s((t+r)/2),c=a((t+r)/2),u=s((t-r)/2),d=a((t-r)/2),m=s((r-t)/2),p=a((r-t)/2);switch(n){case"XYX":e.set(o*c,h*u,h*d,o*l);break;case"YZY":e.set(h*d,o*c,h*u,o*l);break;case"ZXZ":e.set(h*u,h*d,o*c,o*l);break;case"XZX":e.set(o*c,h*p,h*m,o*l);break;case"YXY":e.set(h*m,o*c,h*p,o*l);break;case"ZYZ":e.set(h*p,h*m,o*c,o*l);break;default:console.warn("../math.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}}function denormalize(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}function normalize(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(4294967295*e);case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int32Array:return Math.round(2147483647*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw new Error("Invalid component type.")}}const h={DEG2RAD:a,RAD2DEG:o,generateUUID:generateUUID,clamp:clamp,euclideanModulo:euclideanModulo,mapLinear:mapLinear,inverseLerp:inverseLerp,lerp:lerp,damp:damp,pingpong:pingpong,smoothstep:smoothstep,smootherstep:smootherstep,randInt:randInt,randFloat:randFloat,randFloatSpread:randFloatSpread,seededRandom:seededRandom,degToRad:degToRad,radToDeg:radToDeg,isPowerOfTwo:isPowerOfTwo,ceilPowerOfTwo:ceilPowerOfTwo,floorPowerOfTwo:floorPowerOfTwo,setQuaternionFromProperEuler:setQuaternionFromProperEuler,normalize:normalize,denormalize:denormalize};class Quaternion{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,n,s,a){let o=i[r+0],h=i[r+1],l=i[r+2],c=i[r+3];const u=n[s+0],d=n[s+1],m=n[s+2],p=n[s+3];if(0===a)return e[t+0]=o,e[t+1]=h,e[t+2]=l,void(e[t+3]=c);if(1===a)return e[t+0]=u,e[t+1]=d,e[t+2]=m,void(e[t+3]=p);if(c!==p||o!==u||h!==d||l!==m){let e=1-a;const t=o*u+h*d+l*m+c*p,i=t>=0?1:-1,r=1-t*t;if(r>Number.EPSILON){const n=Math.sqrt(r),s=Math.atan2(n,t*i);e=Math.sin(e*s)/n,a=Math.sin(a*s)/n}const n=a*i;if(o=o*e+u*n,h=h*e+d*n,l=l*e+m*n,c=c*e+p*n,e===1-a){const e=1/Math.sqrt(o*o+h*h+l*l+c*c);o*=e,h*=e,l*=e,c*=e}}e[t]=o,e[t+1]=h,e[t+2]=l,e[t+3]=c}static multiplyQuaternionsFlat(e,t,i,r,n,s){const a=i[r],o=i[r+1],h=i[r+2],l=i[r+3],c=n[s],u=n[s+1],d=n[s+2],m=n[s+3];return e[t]=a*m+l*c+o*d-h*u,e[t+1]=o*m+l*u+h*c-a*d,e[t+2]=h*m+l*d+a*u-o*c,e[t+3]=l*m-a*c-o*u-h*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new Quaternion(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,r=e._y,n=e._z,s=e._order,a=Math.cos,o=Math.sin,h=a(i/2),l=a(r/2),c=a(n/2),u=o(i/2),d=o(r/2),m=o(n/2);switch(s){case"XYZ":this._x=u*l*c+h*d*m,this._y=h*d*c-u*l*m,this._z=h*l*m+u*d*c,this._w=h*l*c-u*d*m;break;case"YXZ":this._x=u*l*c+h*d*m,this._y=h*d*c-u*l*m,this._z=h*l*m-u*d*c,this._w=h*l*c+u*d*m;break;case"ZXY":this._x=u*l*c-h*d*m,this._y=h*d*c+u*l*m,this._z=h*l*m+u*d*c,this._w=h*l*c-u*d*m;break;case"ZYX":this._x=u*l*c-h*d*m,this._y=h*d*c+u*l*m,this._z=h*l*m-u*d*c,this._w=h*l*c+u*d*m;break;case"YZX":this._x=u*l*c+h*d*m,this._y=h*d*c+u*l*m,this._z=h*l*m-u*d*c,this._w=h*l*c-u*d*m;break;case"XZY":this._x=u*l*c-h*d*m,this._y=h*d*c-u*l*m,this._z=h*l*m+u*d*c,this._w=h*l*c+u*d*m;break;default:console.warn("../math.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!0===t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],r=t[4],n=t[8],s=t[1],a=t[5],o=t[9],h=t[2],l=t[6],c=t[10],u=i+a+c;if(u>0){const e=.5/Math.sqrt(u+1);this._w=.25/e,this._x=(l-o)*e,this._y=(n-h)*e,this._z=(s-r)*e}else if(i>a&&i>c){const e=2*Math.sqrt(1+i-a-c);this._w=(l-o)/e,this._x=.25*e,this._y=(r+s)/e,this._z=(n+h)/e}else if(a>c){const e=2*Math.sqrt(1+a-i-c);this._w=(n-h)/e,this._x=(r+s)/e,this._y=.25*e,this._z=(o+l)/e}else{const e=2*Math.sqrt(1+c-i-a);this._w=(s-r)/e,this._x=(n+h)/e,this._y=(o+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return iMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(clamp(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(0===i)return this;const r=Math.min(1,t/i);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,r=e._y,n=e._z,s=e._w,a=t._x,o=t._y,h=t._z,l=t._w;return this._x=i*l+s*a+r*h-n*o,this._y=r*l+s*o+n*a-i*h,this._z=n*l+s*h+i*o-r*a,this._w=s*l-i*a-r*o-n*h,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const i=this._x,r=this._y,n=this._z,s=this._w;let a=s*e._w+i*e._x+r*e._y+n*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=s,this._x=i,this._y=r,this._z=n,this;const o=1-a*a;if(o<=Number.EPSILON){const e=1-t;return this._w=e*s+t*this._w,this._x=e*i+t*this._x,this._y=e*r+t*this._y,this._z=e*n+t*this._z,this.normalize(),this}const h=Math.sqrt(o),l=Math.atan2(h,a),c=Math.sin((1-t)*l)/h,u=Math.sin(t*l)/h;return this._w=s*c+this._w*u,this._x=i*c+this._x*u,this._y=r*c+this._y*u,this._z=n*c+this._z*u,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),n=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),n*Math.sin(t),n*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Vector3{constructor(e=0,t=0,i=0){this.isVector3=!0,Vector3.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return void 0===i&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new Vector3(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(c.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(c.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,r=this.z,n=e.elements;return this.x=n[0]*t+n[3]*i+n[6]*r,this.y=n[1]*t+n[4]*i+n[7]*r,this.z=n[2]*t+n[5]*i+n[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,n=e.elements,s=1/(n[3]*t+n[7]*i+n[11]*r+n[15]);return this.x=(n[0]*t+n[4]*i+n[8]*r+n[12])*s,this.y=(n[1]*t+n[5]*i+n[9]*r+n[13])*s,this.z=(n[2]*t+n[6]*i+n[10]*r+n[14])*s,this}applyQuaternion(e){const t=this.x,i=this.y,r=this.z,n=e.x,s=e.y,a=e.z,o=e.w,h=2*(s*r-a*i),l=2*(a*t-n*r),c=2*(n*i-s*t);return this.x=t+o*h+s*c-a*l,this.y=i+o*l+a*h-n*c,this.z=r+o*c+n*l-s*h,this}transformDirection(e){const t=this.x,i=this.y,r=this.z,n=e.elements;return this.x=n[0]*t+n[4]*i+n[8]*r,this.y=n[1]*t+n[5]*i+n[9]*r,this.z=n[2]*t+n[6]*i+n[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,r=e.y,n=e.z,s=t.x,a=t.y,o=t.z;return this.x=r*o-n*a,this.y=n*s-i*o,this.z=i*a-r*s,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return l.copy(this).projectOnVector(e),this.sub(l)}reflect(e){return this.sub(l.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(clamp(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSphericalCoords(e,t,i){const r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=2*Math.random()-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}abs(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this.z=Math.abs(this.z),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const l=new Vector3,c=new Quaternion,u=2e3,d=2001;class Matrix4{constructor(e,t,i,r,n,s,a,o,h,l,c,u,d,m,p,f){this.isMatrix4=!0,Matrix4.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==e&&this.set(e,t,i,r,n,s,a,o,h,l,c,u,d,m,p,f)}extractPosition(e){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(e)}multiplyToArray(e,t,i){return console.error("THREE.Matrix4: .multiplyToArray() has been removed."),this}setRotationFromQuaternion(e){return this.makeRotationFromQuaternion(e)}set(e,t,i,r,n,s,a,o,h,l,c,u,d,m,p,f){const y=this.elements;return y[0]=e,y[4]=t,y[8]=i,y[12]=r,y[1]=n,y[5]=s,y[9]=a,y[13]=o,y[2]=h,y[6]=l,y[10]=c,y[14]=u,y[3]=d,y[7]=m,y[11]=p,y[15]=f,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new Matrix4).fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,i=e.elements,r=1/m.setFromMatrixColumn(e,0).length(),n=1/m.setFromMatrixColumn(e,1).length(),s=1/m.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*n,t[5]=i[5]*n,t[6]=i[6]*n,t[7]=0,t[8]=i[8]*s,t[9]=i[9]*s,t[10]=i[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,r=e.y,n=e.z,s=Math.cos(i),a=Math.sin(i),o=Math.cos(r),h=Math.sin(r),l=Math.cos(n),c=Math.sin(n);if("XYZ"===e.order){const e=s*l,i=s*c,r=a*l,n=a*c;t[0]=o*l,t[4]=-o*c,t[8]=h,t[1]=i+r*h,t[5]=e-n*h,t[9]=-a*o,t[2]=n-e*h,t[6]=r+i*h,t[10]=s*o}else if("YXZ"===e.order){const e=o*l,i=o*c,r=h*l,n=h*c;t[0]=e+n*a,t[4]=r*a-i,t[8]=s*h,t[1]=s*c,t[5]=s*l,t[9]=-a,t[2]=i*a-r,t[6]=n+e*a,t[10]=s*o}else if("ZXY"===e.order){const e=o*l,i=o*c,r=h*l,n=h*c;t[0]=e-n*a,t[4]=-s*c,t[8]=r+i*a,t[1]=i+r*a,t[5]=s*l,t[9]=n-e*a,t[2]=-s*h,t[6]=a,t[10]=s*o}else if("ZYX"===e.order){const e=s*l,i=s*c,r=a*l,n=a*c;t[0]=o*l,t[4]=r*h-i,t[8]=e*h+n,t[1]=o*c,t[5]=n*h+e,t[9]=i*h-r,t[2]=-h,t[6]=a*o,t[10]=s*o}else if("YZX"===e.order){const e=s*o,i=s*h,r=a*o,n=a*h;t[0]=o*l,t[4]=n-e*c,t[8]=r*c+i,t[1]=c,t[5]=s*l,t[9]=-a*l,t[2]=-h*l,t[6]=i*c+r,t[10]=e-n*c}else if("XZY"===e.order){const e=s*o,i=s*h,r=a*o,n=a*h;t[0]=o*l,t[4]=-c,t[8]=h*l,t[1]=e*c+n,t[5]=s*l,t[9]=i*c-r,t[2]=r*c-i,t[6]=a*l,t[10]=n*c+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(f,e,y)}lookAt(e,t,i){const r=this.elements;return S.subVectors(e,t),0===S.lengthSq()&&(S.z=1),S.normalize(),v.crossVectors(i,S),0===v.lengthSq()&&(1===Math.abs(i.z)?S.x+=1e-4:S.z+=1e-4,S.normalize(),v.crossVectors(i,S)),v.normalize(),g.crossVectors(S,v),r[0]=v.x,r[4]=g.x,r[8]=S.x,r[1]=v.y,r[5]=g.y,r[9]=S.y,r[2]=v.z,r[6]=g.z,r[10]=S.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,n=this.elements,s=i[0],a=i[4],o=i[8],h=i[12],l=i[1],c=i[5],u=i[9],d=i[13],m=i[2],p=i[6],f=i[10],y=i[14],v=i[3],g=i[7],S=i[11],x=i[15],_=r[0],M=r[4],w=r[8],O=r[12],b=r[1],z=r[5],P=r[9],E=r[13],C=r[2],N=r[6],A=r[10],T=r[14],B=r[3],V=r[7],U=r[11],R=r[15];return n[0]=s*_+a*b+o*C+h*B,n[4]=s*M+a*z+o*N+h*V,n[8]=s*w+a*P+o*A+h*U,n[12]=s*O+a*E+o*T+h*R,n[1]=l*_+c*b+u*C+d*B,n[5]=l*M+c*z+u*N+d*V,n[9]=l*w+c*P+u*A+d*U,n[13]=l*O+c*E+u*T+d*R,n[2]=m*_+p*b+f*C+y*B,n[6]=m*M+p*z+f*N+y*V,n[10]=m*w+p*P+f*A+y*U,n[14]=m*O+p*E+f*T+y*R,n[3]=v*_+g*b+S*C+x*B,n[7]=v*M+g*z+S*N+x*V,n[11]=v*w+g*P+S*A+x*U,n[15]=v*O+g*E+S*T+x*R,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],r=e[8],n=e[12],s=e[1],a=e[5],o=e[9],h=e[13],l=e[2],c=e[6],u=e[10],d=e[14];return e[3]*(+n*o*c-r*h*c-n*a*u+i*h*u+r*a*d-i*o*d)+e[7]*(+t*o*d-t*h*u+n*s*u-r*s*d+r*h*l-n*o*l)+e[11]*(+t*h*c-t*a*d-n*s*c+i*s*d+n*a*l-i*h*l)+e[15]*(-r*a*l-t*o*c+t*a*u+r*s*c-i*s*u+i*o*l)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],n=e[3],s=e[4],a=e[5],o=e[6],h=e[7],l=e[8],c=e[9],u=e[10],d=e[11],m=e[12],p=e[13],f=e[14],y=e[15],v=c*f*h-p*u*h+p*o*d-a*f*d-c*o*y+a*u*y,g=m*u*h-l*f*h-m*o*d+s*f*d+l*o*y-s*u*y,S=l*p*h-m*c*h+m*a*d-s*p*d-l*a*y+s*c*y,x=m*c*o-l*p*o-m*a*u+s*p*u+l*a*f-s*c*f,_=t*v+i*g+r*S+n*x;if(0===_)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const M=1/_;return e[0]=v*M,e[1]=(p*u*n-c*f*n-p*r*d+i*f*d+c*r*y-i*u*y)*M,e[2]=(a*f*n-p*o*n+p*r*h-i*f*h-a*r*y+i*o*y)*M,e[3]=(c*o*n-a*u*n-c*r*h+i*u*h+a*r*d-i*o*d)*M,e[4]=g*M,e[5]=(l*f*n-m*u*n+m*r*d-t*f*d-l*r*y+t*u*y)*M,e[6]=(m*o*n-s*f*n-m*r*h+t*f*h+s*r*y-t*o*y)*M,e[7]=(s*u*n-l*o*n+l*r*h-t*u*h-s*r*d+t*o*d)*M,e[8]=S*M,e[9]=(m*c*n-l*p*n-m*i*d+t*p*d+l*i*y-t*c*y)*M,e[10]=(s*p*n-m*a*n+m*i*h-t*p*h-s*i*y+t*a*y)*M,e[11]=(l*a*n-s*c*n-l*i*h+t*c*h+s*i*d-t*a*d)*M,e[12]=x*M,e[13]=(l*p*r-m*c*r+m*i*u-t*p*u-l*i*f+t*c*f)*M,e[14]=(m*a*r-s*p*r-m*i*o+t*p*o+s*i*f-t*a*f)*M,e[15]=(s*c*r-l*a*r+l*i*o-t*c*o-s*i*u+t*a*u)*M,this}scale(e){const t=this.elements,i=e.x,r=e.y,n=e.z;return t[0]*=i,t[4]*=r,t[8]*=n,t[1]*=i,t[5]*=r,t[9]*=n,t[2]*=i,t[6]*=r,t[10]*=n,t[3]*=i,t[7]*=r,t[11]*=n,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),r=Math.sin(t),n=1-i,s=e.x,a=e.y,o=e.z,h=n*s,l=n*a;return this.set(h*s+i,h*a-r*o,h*o+r*a,0,h*a+r*o,l*a+i,l*o-r*s,0,h*o-r*a,l*o+r*s,n*o*o+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,n,s){return this.set(1,i,n,0,e,1,s,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){const r=this.elements,n=t._x,s=t._y,a=t._z,o=t._w,h=n+n,l=s+s,c=a+a,u=n*h,d=n*l,m=n*c,p=s*l,f=s*c,y=a*c,v=o*h,g=o*l,S=o*c,x=i.x,_=i.y,M=i.z;return r[0]=(1-(p+y))*x,r[1]=(d+S)*x,r[2]=(m-g)*x,r[3]=0,r[4]=(d-S)*_,r[5]=(1-(u+y))*_,r[6]=(f+v)*_,r[7]=0,r[8]=(m+g)*M,r[9]=(f-v)*M,r[10]=(1-(u+p))*M,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){const r=this.elements;let n=m.set(r[0],r[1],r[2]).length();const s=m.set(r[4],r[5],r[6]).length(),a=m.set(r[8],r[9],r[10]).length();this.determinant()<0&&(n=-n),e.x=r[12],e.y=r[13],e.z=r[14],p.copy(this);const o=1/n,h=1/s,l=1/a;return p.elements[0]*=o,p.elements[1]*=o,p.elements[2]*=o,p.elements[4]*=h,p.elements[5]*=h,p.elements[6]*=h,p.elements[8]*=l,p.elements[9]*=l,p.elements[10]*=l,t.setFromRotationMatrix(p),i.x=n,i.y=s,i.z=a,this}makePerspective(e,t,i,r,n,s,a=2e3){const o=this.elements,h=2*n/(t-e),l=2*n/(i-r),c=(t+e)/(t-e),m=(i+r)/(i-r);let p,f;if(a===u)p=-(s+n)/(s-n),f=-2*s*n/(s-n);else{if(a!==d)throw new Error("Matrix4.makePerspective(): Invalid coordinate system: "+a);p=-s/(s-n),f=-s*n/(s-n)}return o[0]=h,o[4]=0,o[8]=c,o[12]=0,o[1]=0,o[5]=l,o[9]=m,o[13]=0,o[2]=0,o[6]=0,o[10]=p,o[14]=f,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(e,t,i,r,n,s,a=2e3){const o=this.elements,h=1/(t-e),l=1/(i-r),c=1/(s-n),m=(t+e)*h,p=(i+r)*l;let f,y;if(a===u)f=(s+n)*c,y=-2*c;else{if(a!==d)throw new Error("../math.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);f=n*c,y=-1*c}return o[0]=2*h,o[4]=0,o[8]=0,o[12]=-m,o[1]=0,o[5]=2*l,o[9]=0,o[13]=-p,o[2]=0,o[6]=0,o[10]=y,o[14]=-f,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let e=0;e<16;e++)if(t[e]!==i[e])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const m=new Vector3,p=new Matrix4,f=new Vector3(0,0,0),y=new Vector3(1,1,1),v=new Vector3,g=new Vector3,S=new Vector3,x=new Matrix4,_=new Quaternion;class Euler{constructor(e=0,t=0,i=0,r=Euler.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new Euler(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const r=e.elements,n=r[0],s=r[4],a=r[8],o=r[1],h=r[5],l=r[9],c=r[2],u=r[6],d=r[10];switch(t){case"XYZ":this._y=Math.asin(clamp(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-l,d),this._z=Math.atan2(-s,n)):(this._x=Math.atan2(u,h),this._z=0);break;case"YXZ":this._x=Math.asin(-clamp(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,h)):(this._y=Math.atan2(-c,n),this._z=0);break;case"ZXY":this._x=Math.asin(clamp(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-s,h)):(this._y=0,this._z=Math.atan2(o,n));break;case"ZYX":this._y=Math.asin(-clamp(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(o,n)):(this._x=0,this._z=Math.atan2(-s,h));break;case"YZX":this._z=Math.asin(clamp(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,h),this._y=Math.atan2(-c,n)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-clamp(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(u,h),this._y=Math.atan2(a,n)):(this._x=Math.atan2(-l,d),this._y=0);break;default:console.warn("../math.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===i&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return x.makeRotationFromQuaternion(e),this.setFromRotationMatrix(x,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return _.setFromEuler(this),this.setFromQuaternion(_,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(e){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Euler.DEFAULT_ORDER="XYZ";class Vector2{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new Vector2(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(clamp(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}rotateAround(e,t){const i=Math.cos(t),r=Math.sin(t),n=this.x-e.x,s=this.y-e.y;return this.x=n*i-s*r+e.x,this.y=n*r+s*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}Vector2.isVector2=!0;class Vector4{constructor(e=0,t=0,i=0,r=1){Vector4.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new Vector4(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,n=this.w,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r+s[12]*n,this.y=s[1]*t+s[5]*i+s[9]*r+s[13]*n,this.z=s[2]*t+s[6]*i+s[10]*r+s[14]*n,this.w=s[3]*t+s[7]*i+s[11]*r+s[15]*n,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,n;const s=.01,a=.1,o=e.elements,h=o[0],l=o[4],c=o[8],u=o[1],d=o[5],m=o[9],p=o[2],f=o[6],y=o[10];if(Math.abs(l-u)o&&e>v?ev?o0?Math.floor(i/r)*r:i,t){case e.EmitterMode.Loop:s%=1;break;case e.EmitterMode.PingPong:s=Math.abs(s%2-1)}return s}e.EmitterMode=void 0,(w=e.EmitterMode||(e.EmitterMode={}))[w.Random=0]="Random",w[w.Loop=1]="Loop",w[w.PingPong=2]="PingPong",w[w.Burst=3]="Burst";class Bezier{constructor(e,t,i,r){this.p=[e,t,i,r]}genValue(e){const t=e*e,i=e*e*e,r=1-e,n=r*r,s=n*r;return this.p[0]*s+this.p[1]*n*e*3+this.p[2]*r*t*3+this.p[3]*i}derivativeCoefficients(e){const t=[];for(let i=e,r=i.length-1;r>0;r--){const e=[];for(let t=0;t1;){for(r=[],s=0,a=i.length-1;s({r:e.x,g:e.y,b:e.z,a:e.w}),JSONToColor=e=>new Vector4(e.r,e.g,e.b,e.a),JSONToValue=(e,t)=>{switch(t){case"Vector3":return new Vector3(e.x,e.y,e.z);case"Vector4":return new Vector4(e.x,e.y,e.z,e.w);case"Color":return new Vector3(e.r,e.g,e.b);default:return e}},ValueToJSON=(e,t)=>{switch(t){case"Vector3":return{x:e.x,y:e.y,z:e.z};case"Vector4":return{x:e.x,y:e.y,z:e.z,w:e.w};case"Color":return{r:e.x,g:e.y,b:e.z};default:return e}};class RandomColor{constructor(e,t){this.a=e,this.b=t,this.type="value"}startGen(e){}genColor(e,t){const i=Math.random();return t.copy(this.a).lerp(this.b,i)}toJSON(){return{type:"RandomColor",a:ColorToJSON(this.a),b:ColorToJSON(this.b)}}static fromJSON(e){return new RandomColor(JSONToColor(e.a),JSONToColor(e.b))}clone(){return new RandomColor(this.a.clone(),this.b.clone())}}class ColorRange{constructor(e,t){this.a=e,this.b=t,this.indexCount=-1,this.type="value"}startGen(e){this.indexCount=e.length,e.push(Math.random())}genColor(e,t){return-1===this.indexCount&&this.startGen(e),t.copy(this.a).lerp(this.b,e[this.indexCount])}toJSON(){return{type:"ColorRange",a:ColorToJSON(this.a),b:ColorToJSON(this.b)}}static fromJSON(e){return new ColorRange(JSONToColor(e.a),JSONToColor(e.b))}clone(){return new ColorRange(this.a.clone(),this.b.clone())}}class ContinuousLinearFunction{constructor(e,t){this.subType=t,this.type="function",this.keys=e}findKey(e){let t=0,i=0,r=this.keys.length-1;for(;i+1this.getEndX(t)))return t;i=t+1}for(let t=i;t<=r;t++)if(e>=this.getStartX(t)&&e<=this.getEndX(t))return t;return-1}getStartX(e){return this.keys[e][1]}getEndX(e){return e+1=this.keys.length?this.keys[this.keys.length-1][0]:(this.keys[i+1][0]-this.keys[i][0])*((t-this.getStartX(i))/(this.getEndX(i)-this.getStartX(i)))+this.keys[i][0]:-1===i?e.copy(this.keys[0][0]):i+1>=this.keys.length?e.copy(this.keys[this.keys.length-1][0]):e.copy(this.keys[i][0]).lerp(this.keys[i+1][0],(t-this.getStartX(i))/(this.getEndX(i)-this.getStartX(i)))}toJSON(){return this.keys[0][0].constructor.name,{type:"CLinearFunction",subType:this.subType,keys:this.keys.map((([e,t])=>({value:ValueToJSON(e,this.subType),pos:t})))}}static fromJSON(e){return new ContinuousLinearFunction(e.keys.map((t=>[JSONToValue(t.value,e.subType),t.pos])),e.subType)}clone(){return"Number"===this.subType?new ContinuousLinearFunction(this.keys.map((([e,t])=>[e,t])),this.subType):new ContinuousLinearFunction(this.keys.map((([e,t])=>[e.clone(),t])),this.subType)}}const O=new Vector3;class Gradient{constructor(e=[[new Vector3(0,0,0),0],[new Vector3(1,1,1),0]],t=[[1,0],[1,1]]){this.type="function",this.color=new ContinuousLinearFunction(e,"Color"),this.alpha=new ContinuousLinearFunction(t,"Number")}genColor(e,t,i){return this.color.genValue(O,i),t.set(O.x,O.y,O.z,this.alpha.genValue(1,i))}toJSON(){return{type:"Gradient",color:this.color.toJSON(),alpha:this.alpha.toJSON()}}static fromJSON(e){if(e.functions){const t=e.functions.map((e=>[ColorRange.fromJSON(e.function).a,e.start]));return e.functions.length>0&&t.push([ColorRange.fromJSON(e.functions[e.functions.length-1].function).b,1]),new Gradient(t.map((e=>[new Vector3(e[0].x,e[0].y,e[0].z),e[1]])),t.map((e=>[e[0].w,e[1]])))}{const t=new Gradient;return t.alpha=ContinuousLinearFunction.fromJSON(e.alpha),t.color=ContinuousLinearFunction.fromJSON(e.color),t}}clone(){const e=new Gradient;return e.alpha=this.alpha.clone(),e.color=this.color.clone(),e}startGen(e){}}const b=new Vector4;class RandomColorBetweenGradient{constructor(e,t){this.indexCount=0,this.type="function",this.gradient1=e,this.gradient2=t}startGen(e){this.indexCount=e.length,e.push(Math.random())}genColor(e,t,i){return this.gradient1.genColor(e,t,i),this.gradient2.genColor(e,b,i),e&&void 0!==e[this.indexCount]?t.lerp(b,e[this.indexCount]):t.lerp(b,Math.random()),t}toJSON(){return{type:"RandomColorBetweenGradient",gradient1:this.gradient1.toJSON(),gradient2:this.gradient2.toJSON()}}static fromJSON(e){return new RandomColorBetweenGradient(Gradient.fromJSON(e.gradient1),Gradient.fromJSON(e.gradient2))}clone(){return new RandomColorBetweenGradient(this.gradient1.clone(),this.gradient2.clone())}}class ConstantColor{constructor(e){this.color=e,this.type="value"}startGen(e){}genColor(e,t){return t.copy(this.color)}toJSON(){return{type:"ConstantColor",color:ColorToJSON(this.color)}}static fromJSON(e){return new ConstantColor(JSONToColor(e.color))}clone(){return new ConstantColor(this.color.clone())}}function ColorGeneratorFromJSON(e){switch(e.type){case"ConstantColor":return ConstantColor.fromJSON(e);case"ColorRange":return ColorRange.fromJSON(e);case"RandomColor":return RandomColor.fromJSON(e);case"Gradient":return Gradient.fromJSON(e);case"RandomColorBetweenGradient":return RandomColorBetweenGradient.fromJSON(e);default:return new ConstantColor(new Vector4(1,1,1,1))}}class ConstantValue{constructor(e){this.value=e,this.type="value"}startGen(e){}genValue(e){return this.value}toJSON(){return{type:"ConstantValue",value:this.value}}static fromJSON(e){return new ConstantValue(e.value)}clone(){return new ConstantValue(this.value)}}class IntervalValue{constructor(e,t){this.a=e,this.b=t,this.indexCount=-1,this.type="value"}startGen(e){this.indexCount=e.length,e.push(Math.random())}genValue(e){return-1===this.indexCount&&this.startGen(e),h.lerp(this.a,this.b,e[this.indexCount])}toJSON(){return{type:"IntervalValue",a:this.a,b:this.b}}static fromJSON(e){return new IntervalValue(e.a,e.b)}clone(){return new IntervalValue(this.a,this.b)}}class PiecewiseFunction{constructor(){this.functions=new Array}findFunction(e){let t=0,i=0,r=this.functions.length-1;for(;i+1this.getEndX(t)))return t;i=t+1}for(let t=i;t<=r;t++)if(e>=this.functions[t][1]&&e<=this.getEndX(t))return t;return-1}getStartX(e){return this.functions[e][1]}setStartX(e,t){e>0&&(this.functions[e][1]=t)}getEndX(e){return e+1({function:e.toJSON(),start:t})))}}static fromJSON(e){return new PiecewiseBezier(e.functions.map((e=>[Bezier.fromJSON(e.function),e.start])))}clone(){return new PiecewiseBezier(this.functions.map((([e,t])=>[e.clone(),t])))}startGen(e){}}function ValueGeneratorFromJSON(e){switch(e.type){case"ConstantValue":return ConstantValue.fromJSON(e);case"IntervalValue":return IntervalValue.fromJSON(e);case"PiecewiseBezier":return PiecewiseBezier.fromJSON(e);default:return new ConstantValue(0)}}class RandomQuatGenerator{constructor(){this.indexCount=0,this.type="rotation"}startGen(e){let t,i,r,n,s,a;this.indexCount=e.length,e.push(new Quaternion);do{t=2*Math.random()-1,i=2*Math.random()-1,r=t*t+i*i}while(r>1);do{n=2*Math.random()-1,s=2*Math.random()-1,a=n*n+s*s}while(a>1);const o=Math.sqrt((1-r)/a);e[this.indexCount].set(t,i,o*n,o*s)}genValue(e,t,i,r){return-1===this.indexCount&&this.startGen(e),t.copy(e[this.indexCount]),t}toJSON(){return{type:"RandomQuat"}}static fromJSON(e){return new RandomQuatGenerator}clone(){return new RandomQuatGenerator}}class AxisAngleGenerator{constructor(e,t){this.axis=e,this.angle=t,this.type="rotation"}startGen(e){this.angle.startGen(e)}genValue(e,t,i,r){return t.setFromAxisAngle(this.axis,this.angle.genValue(e,r)*i)}toJSON(){return{type:"AxisAngle",axis:{x:this.axis.x,y:this.axis.y,z:this.axis.z},angle:this.angle.toJSON()}}static fromJSON(e){return new AxisAngleGenerator(new Vector3(e.axis.x,e.axis.y,e.axis.z),ValueGeneratorFromJSON(e.angle))}clone(){return new AxisAngleGenerator(this.axis.clone(),this.angle.clone())}}class EulerGenerator{constructor(e,t,i,r){this.angleX=e,this.angleY=t,this.angleZ=i,this.type="rotation",this.eular=new Euler(0,0,0,r)}startGen(e){this.angleX.startGen(e),this.angleY.startGen(e),this.angleZ.startGen(e)}genValue(e,t,i,r){return this.eular.set(this.angleX.genValue(e,r)*i,this.angleY.genValue(e,r)*i,this.angleZ.genValue(e,r)*i),t.setFromEuler(this.eular)}toJSON(){return{type:"Euler",angleX:this.angleX.toJSON(),angleY:this.angleY.toJSON(),angleZ:this.angleZ.toJSON(),eulerOrder:this.eular.order}}static fromJSON(e){return new EulerGenerator(ValueGeneratorFromJSON(e.angleX),ValueGeneratorFromJSON(e.angleY),ValueGeneratorFromJSON(e.angleZ),e.eulerOrder)}clone(){return new EulerGenerator(this.angleX,this.angleY,this.angleZ,this.eular.order)}}function RotationGeneratorFromJSON(e){switch(e.type){case"AxisAngle":return AxisAngleGenerator.fromJSON(e);case"Euler":return EulerGenerator.fromJSON(e);case"RandomQuat":return RandomQuatGenerator.fromJSON(e);default:return new RandomQuatGenerator}}class Vector3Function{constructor(e,t,i){this.x=e,this.y=t,this.z=i,this.type="vec3function"}startGen(e){this.x.startGen(e),this.y.startGen(e),this.z.startGen(e)}genValue(e,t,i){return t.set(this.x.genValue(e,i),this.y.genValue(e,i),this.z.genValue(e,i))}toJSON(){return{type:"Vector3Function",x:this.x.toJSON(),y:this.y.toJSON(),z:this.z.toJSON()}}static fromJSON(e){return new Vector3Function(ValueGeneratorFromJSON(e.x),ValueGeneratorFromJSON(e.y),ValueGeneratorFromJSON(e.z))}clone(){return new Vector3Function(this.x,this.y,this.z)}}function Vector3GeneratorFromJSON(e){return"Vector3Function"===e.type?Vector3Function.fromJSON(e):new Vector3Function(new ConstantValue(0),new ConstantValue(0),new ConstantValue(0))}function GeneratorFromJSON(e){switch(e.type){case"ConstantValue":case"IntervalValue":case"PiecewiseBezier":return ValueGeneratorFromJSON(e);case"AxisAngle":case"RandomQuat":case"Euler":return RotationGeneratorFromJSON(e);case"Vector3Function":return Vector3GeneratorFromJSON(e);default:return new ConstantValue(0)}}class ConeEmitter{constructor(t={}){var i,r,n,s,a,o,h;this.type="cone",this.currentValue=0,this.radius=null!==(i=t.radius)&&void 0!==i?i:10,this.arc=null!==(r=t.arc)&&void 0!==r?r:2*Math.PI,this.thickness=null!==(n=t.thickness)&&void 0!==n?n:1,this.angle=null!==(s=t.angle)&&void 0!==s?s:Math.PI/6,this.mode=null!==(a=t.mode)&&void 0!==a?a:e.EmitterMode.Random,this.spread=null!==(o=t.spread)&&void 0!==o?o:0,this.speed=null!==(h=t.speed)&&void 0!==h?h:new ConstantValue(1),this.memory=[]}update(t,i){e.EmitterMode.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*i)}initialize(e,t){const i=getValueFromEmitterMode(this.mode,this.currentValue,this.spread,t),r=h.lerp(1-this.thickness,1,Math.random()),n=i*this.arc,s=Math.sqrt(r),a=Math.sin(n),o=Math.cos(n);e.position.x=s*o,e.position.y=s*a,e.position.z=0;const l=this.angle*s;e.velocity.set(0,0,Math.cos(l)).addScaledVector(e.position,Math.sin(l)).multiplyScalar(e.startSpeed),e.position.multiplyScalar(this.radius)}toJSON(){return{type:"cone",radius:this.radius,arc:this.arc,thickness:this.thickness,angle:this.angle,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(e){return new ConeEmitter({radius:e.radius,arc:e.arc,thickness:e.thickness,angle:e.angle,mode:e.mode,speed:e.speed?ValueGeneratorFromJSON(e.speed):void 0,spread:e.spread})}clone(){return new ConeEmitter({radius:this.radius,arc:this.arc,thickness:this.thickness,angle:this.angle,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class CircleEmitter{constructor(t={}){var i,r,n,s,a,o;this.type="circle",this.currentValue=0,this.radius=null!==(i=t.radius)&&void 0!==i?i:10,this.arc=null!==(r=t.arc)&&void 0!==r?r:2*Math.PI,this.thickness=null!==(n=t.thickness)&&void 0!==n?n:1,this.mode=null!==(s=t.mode)&&void 0!==s?s:e.EmitterMode.Random,this.spread=null!==(a=t.spread)&&void 0!==a?a:0,this.speed=null!==(o=t.speed)&&void 0!==o?o:new ConstantValue(1),this.memory=[]}update(e,t){this.currentValue+=this.speed.genValue(this.memory,e.emissionState.time/e.duration)*t}initialize(e,t){const i=getValueFromEmitterMode(this.mode,this.currentValue,this.spread,t),r=h.lerp(1-this.thickness,1,Math.random()),n=i*this.arc;e.position.x=Math.cos(n),e.position.y=Math.sin(n),e.position.z=0,e.velocity.copy(e.position).multiplyScalar(e.startSpeed),e.position.multiplyScalar(this.radius*r)}toJSON(){return{type:"circle",radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(e){return new CircleEmitter({radius:e.radius,arc:e.arc,thickness:e.thickness,mode:e.mode,speed:e.speed?ValueGeneratorFromJSON(e.speed):void 0,spread:e.spread})}clone(){return new CircleEmitter({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}function randomInt(e,t){return Math.floor(Math.random()*(t-e))+e}const z=new Vector3(0,1,0),P=new Vector3(0,0,0),E=new Vector3(1,1,1),C=new Vector3(0,0,1);class DonutEmitter{constructor(t={}){var i,r,n,s,a,o,h;this.type="donut",this.currentValue=0,this.radius=null!==(i=t.radius)&&void 0!==i?i:10,this.arc=null!==(r=t.arc)&&void 0!==r?r:2*Math.PI,this.thickness=null!==(n=t.thickness)&&void 0!==n?n:1,this.donutRadius=null!==(s=t.donutRadius)&&void 0!==s?s:.2*this.radius,this.mode=null!==(a=t.mode)&&void 0!==a?a:e.EmitterMode.Random,this.spread=null!==(o=t.spread)&&void 0!==o?o:0,this.speed=null!==(h=t.speed)&&void 0!==h?h:new ConstantValue(1),this.memory=[],this._m1=new Matrix4}update(t,i){e.EmitterMode.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*i)}initialize(e,t){const i=getValueFromEmitterMode(this.mode,this.currentValue,this.spread,t),r=Math.random(),n=h.lerp(1-this.thickness,1,Math.random()),s=i*this.arc,a=r*Math.PI*2,o=Math.sin(s),l=Math.cos(s);e.position.x=this.radius*l,e.position.y=this.radius*o,e.position.z=0,e.velocity.z=this.donutRadius*n*Math.sin(a),e.velocity.x=this.donutRadius*n*Math.cos(a)*l,e.velocity.y=this.donutRadius*n*Math.cos(a)*o,e.position.add(e.velocity),e.velocity.normalize().multiplyScalar(e.startSpeed),e.rotation instanceof Quaternion&&(this._m1.lookAt(P,e.velocity,z),e.rotation.setFromRotationMatrix(this._m1))}toJSON(){return{type:"donut",radius:this.radius,arc:this.arc,thickness:this.thickness,donutRadius:this.donutRadius,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(e){return new DonutEmitter({radius:e.radius,arc:e.arc,thickness:e.thickness,donutRadius:e.donutRadius,mode:e.mode,speed:e.speed?ValueGeneratorFromJSON(e.speed):void 0,spread:e.spread})}clone(){return new DonutEmitter({radius:this.radius,arc:this.arc,thickness:this.thickness,donutRadius:this.donutRadius,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class PointEmitter{constructor(){this.type="point",this._m1=new Matrix4}update(e,t){}initialize(e){const t=Math.random(),i=Math.random(),r=t*Math.PI*2,n=Math.acos(2*i-1),s=Math.cbrt(Math.random()),a=Math.sin(r),o=Math.cos(r),h=Math.sin(n),l=Math.cos(n);e.velocity.x=s*h*o,e.velocity.y=s*h*a,e.velocity.z=s*l,e.velocity.multiplyScalar(e.startSpeed),e.position.setScalar(0),e.rotation instanceof Quaternion&&(this._m1.lookAt(P,e.position,z),e.rotation.setFromRotationMatrix(this._m1))}toJSON(){return{type:"point"}}static fromJSON(e){return new PointEmitter}clone(){return new PointEmitter}}class SphereEmitter{constructor(t={}){var i,r,n,s,a,o;this.type="sphere",this.currentValue=0,this.radius=null!==(i=t.radius)&&void 0!==i?i:10,this.arc=null!==(r=t.arc)&&void 0!==r?r:2*Math.PI,this.thickness=null!==(n=t.thickness)&&void 0!==n?n:1,this.mode=null!==(s=t.mode)&&void 0!==s?s:e.EmitterMode.Random,this.spread=null!==(a=t.spread)&&void 0!==a?a:0,this.speed=null!==(o=t.speed)&&void 0!==o?o:new ConstantValue(1),this.memory=[],this._m1=new Matrix4}update(t,i){e.EmitterMode.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*i)}initialize(e,t){const i=getValueFromEmitterMode(this.mode,this.currentValue,this.spread,t),r=Math.random(),n=h.lerp(1-this.thickness,1,Math.random()),s=i*this.arc,a=Math.acos(2*r-1),o=Math.sin(s),l=Math.cos(s),c=Math.sin(a),u=Math.cos(a);e.position.x=c*l,e.position.y=c*o,e.position.z=u,e.velocity.copy(e.position).multiplyScalar(e.startSpeed),e.position.multiplyScalar(this.radius*n),e.rotation instanceof Quaternion&&(this._m1.lookAt(P,e.position,z),e.rotation.setFromRotationMatrix(this._m1))}toJSON(){return{type:"sphere",radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(e){return new SphereEmitter({radius:e.radius,arc:e.arc,thickness:e.thickness,mode:e.mode,speed:e.speed?ValueGeneratorFromJSON(e.speed):void 0,spread:e.spread})}clone(){return new SphereEmitter({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class HemisphereEmitter{constructor(t={}){var i,r,n,s,a,o;this.type="sphere",this.currentValue=0,this.radius=null!==(i=t.radius)&&void 0!==i?i:10,this.arc=null!==(r=t.arc)&&void 0!==r?r:2*Math.PI,this.thickness=null!==(n=t.thickness)&&void 0!==n?n:1,this.mode=null!==(s=t.mode)&&void 0!==s?s:e.EmitterMode.Random,this.spread=null!==(a=t.spread)&&void 0!==a?a:0,this.speed=null!==(o=t.speed)&&void 0!==o?o:new ConstantValue(1),this.memory=[],this._m1=new Matrix4}update(t,i){e.EmitterMode.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*i)}initialize(e,t){const i=getValueFromEmitterMode(this.mode,this.currentValue,this.spread,t),r=Math.random(),n=h.lerp(1-this.thickness,1,Math.random()),s=i*this.arc,a=Math.acos(r),o=Math.sin(s),l=Math.cos(s),c=Math.sin(a),u=Math.cos(a);e.position.x=c*l,e.position.y=c*o,e.position.z=u,e.velocity.copy(e.position).multiplyScalar(e.startSpeed),e.position.multiplyScalar(this.radius*n),e.rotation instanceof Quaternion&&(this._m1.lookAt(P,e.position,z),e.rotation.setFromRotationMatrix(this._m1))}toJSON(){return{type:"hemisphere",radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(e){return new HemisphereEmitter({radius:e.radius,arc:e.arc,thickness:e.thickness,mode:e.mode,speed:e.speed?ValueGeneratorFromJSON(e.speed):void 0,spread:e.spread})}clone(){return new HemisphereEmitter({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class GridEmitter{constructor(e={}){var t,i,r,n;this.type="grid",this.width=null!==(t=e.width)&&void 0!==t?t:1,this.height=null!==(i=e.height)&&void 0!==i?i:1,this.column=null!==(r=e.column)&&void 0!==r?r:10,this.row=null!==(n=e.row)&&void 0!==n?n:10}initialize(e){const t=Math.floor(Math.random()*this.row),i=Math.floor(Math.random()*this.column);e.position.x=i*this.width/this.column-this.width/2,e.position.y=t*this.height/this.row-this.height/2,e.position.z=0,e.velocity.set(0,0,e.startSpeed)}toJSON(){return{type:"grid",width:this.width,height:this.height,column:this.column,row:this.row}}static fromJSON(e){return new GridEmitter(e)}clone(){return new GridEmitter({width:this.width,height:this.height,column:this.column,row:this.row})}update(e,t){}}const N={circle:{type:"circle",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:CircleEmitter,loadJSON:CircleEmitter.fromJSON},cone:{type:"cone",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:ConeEmitter,loadJSON:ConeEmitter.fromJSON},donut:{type:"donut",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["donutRadius",["number"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:DonutEmitter,loadJSON:DonutEmitter.fromJSON},point:{type:"point",params:[],constructor:PointEmitter,loadJSON:PointEmitter.fromJSON},sphere:{type:"sphere",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:SphereEmitter,loadJSON:SphereEmitter.fromJSON},hemisphere:{type:"hemisphere",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:HemisphereEmitter,loadJSON:HemisphereEmitter.fromJSON},grid:{type:"grid",params:[["width",["number"]],["height",["number"]],["rows",["number"]],["column",["number"]]],constructor:GridEmitter,loadJSON:GridEmitter.fromJSON}};function EmitterFromJSON(e,t){return N[e.type].loadJSON(e,t)}class ColorOverLife{constructor(e){this.color=e,this.type="ColorOverLife"}initialize(e){this.color.startGen(e.memory)}update(e,t){this.color.genColor(e.memory,e.color,e.age/e.life),e.color.x*=e.startColor.x,e.color.y*=e.startColor.y,e.color.z*=e.startColor.z,e.color.w*=e.startColor.w}frameUpdate(e){}toJSON(){return{type:this.type,color:this.color.toJSON()}}static fromJSON(e){return new ColorOverLife(ColorGeneratorFromJSON(e.color))}clone(){return new ColorOverLife(this.color.clone())}reset(){}}class RotationOverLife{constructor(e){this.angularVelocity=e,this.type="RotationOverLife"}initialize(e){"number"==typeof e.rotation&&this.angularVelocity.startGen(e.memory)}update(e,t){"number"==typeof e.rotation&&(e.rotation+=t*this.angularVelocity.genValue(e.memory,e.age/e.life))}toJSON(){return{type:this.type,angularVelocity:this.angularVelocity.toJSON()}}static fromJSON(e){return new RotationOverLife(ValueGeneratorFromJSON(e.angularVelocity))}frameUpdate(e){}clone(){return new RotationOverLife(this.angularVelocity.clone())}reset(){}}class Rotation3DOverLife{constructor(e){this.angularVelocity=e,this.type="Rotation3DOverLife",this.tempQuat=new Quaternion,this.tempQuat2=new Quaternion}initialize(e){e.rotation instanceof Quaternion&&(e.angularVelocity=new Quaternion,this.angularVelocity.startGen(e.memory))}update(e,t){e.rotation instanceof Quaternion&&(this.angularVelocity.genValue(e.memory,this.tempQuat,t,e.age/e.life),e.rotation.multiply(this.tempQuat))}toJSON(){return{type:this.type,angularVelocity:this.angularVelocity.toJSON()}}static fromJSON(e){return new Rotation3DOverLife(RotationGeneratorFromJSON(e.angularVelocity))}frameUpdate(e){}clone(){return new Rotation3DOverLife(this.angularVelocity.clone())}reset(){}}class ForceOverLife{initialize(e,t){this.ps=t,this.x.startGen(e.memory),this.y.startGen(e.memory),this.z.startGen(e.memory)}constructor(e,t,i){this.x=e,this.y=t,this.z=i,this.type="ForceOverLife",this._temp=new Vector3,this._tempScale=new Vector3,this._tempQ=new Quaternion}update(e,t){this._temp.set(this.x.genValue(e.memory,e.age/e.life),this.y.genValue(e.memory,e.age/e.life),this.z.genValue(e.memory,e.age/e.life)),this.ps.worldSpace||this._temp.multiply(this._tempScale).applyQuaternion(this._tempQ),e.velocity.addScaledVector(this._temp,t)}toJSON(){return{type:this.type,x:this.x.toJSON(),y:this.y.toJSON(),z:this.z.toJSON()}}static fromJSON(e){return new ForceOverLife(ValueGeneratorFromJSON(e.x),ValueGeneratorFromJSON(e.y),ValueGeneratorFromJSON(e.z))}frameUpdate(e){if(this.ps&&!this.ps.worldSpace){const e=this._temp,t=this._tempQ,i=this._tempScale;this.ps.emitter.matrixWorld.decompose(e,t,i),t.invert(),i.set(1/i.x,1/i.y,1/i.z)}}clone(){return new ForceOverLife(this.x.clone(),this.y.clone(),this.z.clone())}reset(){}}class SizeOverLife{initialize(e){this.size.startGen(e.memory)}constructor(e){this.size=e,this.type="SizeOverLife"}update(e){this.size instanceof Vector3Function?this.size.genValue(e.memory,e.size,e.age/e.life).multiply(e.startSize):e.size.copy(e.startSize).multiplyScalar(this.size.genValue(e.memory,e.age/e.life))}toJSON(){return{type:this.type,size:this.size.toJSON()}}static fromJSON(e){return new SizeOverLife(GeneratorFromJSON(e.size))}frameUpdate(e){}clone(){return new SizeOverLife(this.size.clone())}reset(){}}class SpeedOverLife{initialize(e){this.speed.startGen(e.memory)}constructor(e){this.speed=e,this.type="SpeedOverLife"}update(e){e.speedModifier=this.speed.genValue(e.memory,e.age/e.life)}toJSON(){return{type:this.type,speed:this.speed.toJSON()}}static fromJSON(e){return new SpeedOverLife(ValueGeneratorFromJSON(e.speed))}frameUpdate(e){}clone(){return new SpeedOverLife(this.speed.clone())}reset(){}}class FrameOverLife{constructor(e){this.frame=e,this.type="FrameOverLife"}initialize(e){this.frame.startGen(e.memory)}update(e,t){this.frame instanceof PiecewiseBezier&&(e.uvTile=this.frame.genValue(e.memory,e.age/e.life))}frameUpdate(e){}toJSON(){return{type:this.type,frame:this.frame.toJSON()}}static fromJSON(e){return new FrameOverLife(ValueGeneratorFromJSON(e.frame))}clone(){return new FrameOverLife(this.frame.clone())}reset(){}}class OrbitOverLife{constructor(e,t=new Vector3(0,1,0)){this.orbitSpeed=e,this.axis=t,this.type="OrbitOverLife",this.temp=new Vector3,this.rotation=new Quaternion}initialize(e){this.orbitSpeed.startGen(e.memory)}update(e,t){this.temp.copy(e.position).projectOnVector(this.axis),this.rotation.setFromAxisAngle(this.axis,this.orbitSpeed.genValue(e.memory,e.age/e.life)*t),e.position.sub(this.temp),e.position.applyQuaternion(this.rotation),e.position.add(this.temp)}frameUpdate(e){}toJSON(){return{type:this.type,orbitSpeed:this.orbitSpeed.toJSON(),axis:[this.axis.x,this.axis.y,this.axis.z]}}static fromJSON(e){return new OrbitOverLife(ValueGeneratorFromJSON(e.orbitSpeed),e.axis?new Vector3(e.axis[0],e.axis[1],e.axis[2]):void 0)}clone(){return new OrbitOverLife(this.orbitSpeed.clone())}reset(){}}class LinkedListNode{constructor(e){this.data=e,this.next=null,this.prev=null}hasPrev(){return null!==this.prev}hasNext(){return null!==this.next}}class LinkedList{constructor(){this.length=0,this.head=this.tail=null}isEmpty(){return null===this.head}clear(){this.length=0,this.head=this.tail=null}front(){return null===this.head?null:this.head.data}back(){return null===this.tail?null:this.tail.data}dequeue(){if(this.head){const e=this.head.data;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,e}}pop(){if(this.tail){const e=this.tail.data;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,e}}queue(e){const t=new LinkedListNode(e);this.tail||(this.tail=t),this.head&&(this.head.prev=t,t.next=this.head),this.head=t,this.length++}push(e){const t=new LinkedListNode(e);this.head||(this.head=t),this.tail&&(this.tail.next=t,t.prev=this.tail),this.tail=t,this.length++}insertBefore(e,t){const i=new LinkedListNode(t);i.next=e,i.prev=e.prev,null!==i.prev&&(i.prev.next=i),i.next.prev=i,e==this.head&&(this.head=i),this.length++}remove(e){if(null===this.head||null===this.tail)return;let t=this.head;for(e===this.head.data&&(this.head=this.head.next),e===this.tail.data&&(this.tail=this.tail.prev);null!==t.next&&t.data!==e;)t=t.next;t.data===e&&(null!==t.prev&&(t.prev.next=t.next),null!==t.next&&(t.next.prev=t.prev),this.length--)}*values(){let e=this.head;for(;null!==e;)yield e.data,e=e.next}}class SpriteParticle{constructor(){this.startSpeed=0,this.startColor=new Vector4,this.startSize=new Vector3(1,1,1),this.position=new Vector3,this.velocity=new Vector3,this.age=0,this.life=1,this.size=new Vector3(1,1,1),this.speedModifier=1,this.rotation=0,this.color=new Vector4,this.uvTile=0,this.memory=[]}get died(){return this.age>=this.life}reset(){this.memory.length=0}}class RecordState{constructor(e,t,i){this.position=e,this.size=t,this.color=i}}class TrailParticle{constructor(){this.startSpeed=0,this.startColor=new Vector4,this.startSize=new Vector3(1,1,1),this.position=new Vector3,this.velocity=new Vector3,this.age=0,this.life=1,this.size=new Vector3(1,1,1),this.length=100,this.speedModifier=1,this.color=new Vector4,this.previous=new LinkedList,this.uvTile=0,this.memory=[]}update(){for(this.age<=this.life?this.previous.push(new RecordState(this.position.clone(),this.size.x,this.color.clone())):this.previous.length>0&&this.previous.dequeue();this.previous.length>this.length;)this.previous.dequeue()}get died(){return this.age>=this.life}reset(){this.memory.length=0,this.previous.clear()}}class WidthOverLength{initialize(e){this.width.startGen(e.memory)}constructor(e){this.width=e,this.type="WidthOverLength"}update(e){if(e instanceof TrailParticle){const t=e.previous.values();for(let i=0;i=t.life)&&this.emit(t,i)}emit(e,t){if(!this.subParticleSystem)return;if(Math.random()>this.emitProbability)return;const i=new Matrix4;this.setMatrixFromParticle(i,e),this.subEmissions.push({burstParticleCount:0,burstParticleIndex:0,isBursting:!1,burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0,matrix:i,travelDistance:0,particle:e})}frameUpdate(e){if(this.subParticleSystem)for(let t=0;t=this.subParticleSystem.system.duration)this.subEmissions[t]=this.subEmissions[this.subEmissions.length-1],this.subEmissions.length=this.subEmissions.length-1,t--;else{const i=this.subEmissions[t];i.particle&&i.particle.age>>0,r-=e,r*=e,e=r>>>0,r-=e,e+=4294967296*r}return 2.3283064365386963e-10*(e>>>0)}}();return t=s(" "),i=s(" "),r=s(" "),t-=s(e),t<0&&(t+=1),i-=s(e),i<0&&(i+=1),r-=s(e),r<0&&(r+=1),function(){const e=2091639*t+2.3283064365386963e-10*n;return t=i,i=r,r=e-(n=0|e)}}(e);this.p=function buildPermutationTable(e){const t=new Uint8Array(256);for(let e=0;e<256;e++)t[e]=e;for(let i=0;i<255;i++){const r=i+~~(e()*(256-i)),n=t[i];t[i]=t[r],t[r]=n}return t}(t),this.perm=new Uint8Array(512),this.permMod12=new Uint8Array(512);for(let e=0;e<512;e++)this.perm[e]=this.p[255&e],this.permMod12[e]=this.perm[e]%12}noise2D(e,t){const i=this.permMod12,r=this.perm;let n=0,s=0,a=0;const o=(e+t)*T,h=Math.floor(e+o),l=Math.floor(t+o),c=(h+l)*B,u=e-(h-c),d=t-(l-c);let m,p;u>d?(m=1,p=0):(m=0,p=1);const f=u-m+B,y=d-p+B,v=u-1+2*B,g=d-1+2*B,S=255&h,x=255&l;let _=.5-u*u-d*d;if(_>=0){const e=3*i[S+r[x]];_*=_,n=_*_*(k[e]*u+k[e+1]*d)}let M=.5-f*f-y*y;if(M>=0){const e=3*i[S+m+r[x+p]];M*=M,s=M*M*(k[e]*f+k[e+1]*y)}let w=.5-v*v-g*g;if(w>=0){const e=3*i[S+1+r[x+1]];w*=w,a=w*w*(k[e]*v+k[e+1]*g)}return 70*(n+s+a)}noise3D(e,t,i){const r=this.permMod12,n=this.perm;let s,a,o,h;const l=(e+t+i)*V,c=Math.floor(e+l),u=Math.floor(t+l),d=Math.floor(i+l),m=(c+u+d)*U,p=e-(c-m),f=t-(u-m),y=i-(d-m);let v,g,S,x,_,M;p>=f?f>=y?(v=1,g=0,S=0,x=1,_=1,M=0):p>=y?(v=1,g=0,S=0,x=1,_=0,M=1):(v=0,g=0,S=1,x=1,_=0,M=1):fv?x++:_++,y>g?x++:M++,y>S?x++:w++,v>g?_++:M++,v>S?_++:w++,g>S?M++:w++;const O=x>=3?1:0,b=_>=3?1:0,z=M>=3?1:0,P=w>=3?1:0,E=x>=2?1:0,C=_>=2?1:0,N=M>=2?1:0,A=w>=2?1:0,T=x>=1?1:0,B=_>=1?1:0,V=M>=1?1:0,U=w>=1?1:0,k=y-O+L,I=v-b+L,D=g-z+L,G=S-P+L,q=y-E+2*L,X=v-C+2*L,Q=g-N+2*L,H=S-A+2*L,Y=y-T+3*L,j=v-B+3*L,Z=g-V+3*L,W=S-U+3*L,K=y-1+4*L,$=v-1+4*L,ee=g-1+4*L,te=S-1+4*L,ie=255&u,re=255&d,ne=255&m,se=255&p;let ae=.6-y*y-v*v-g*g-S*S;if(ae<0)s=0;else{const e=n[ie+n[re+n[ne+n[se]]]]%32*4;ae*=ae,s=ae*ae*(J[e]*y+J[e+1]*v+J[e+2]*g+J[e+3]*S)}let oe=.6-k*k-I*I-D*D-G*G;if(oe<0)a=0;else{const e=n[ie+O+n[re+b+n[ne+z+n[se+P]]]]%32*4;oe*=oe,a=oe*oe*(J[e]*k+J[e+1]*I+J[e+2]*D+J[e+3]*G)}let he=.6-q*q-X*X-Q*Q-H*H;if(he<0)o=0;else{const e=n[ie+E+n[re+C+n[ne+N+n[se+A]]]]%32*4;he*=he,o=he*he*(J[e]*q+J[e+1]*X+J[e+2]*Q+J[e+3]*H)}let le=.6-Y*Y-j*j-Z*Z-W*W;if(le<0)h=0;else{const e=n[ie+T+n[re+B+n[ne+V+n[se+U]]]]%32*4;le*=le,h=le*le*(J[e]*Y+J[e+1]*j+J[e+2]*Z+J[e+3]*W)}let ce=.6-K*K-$*$-ee*ee-te*te;if(ce<0)l=0;else{const e=n[ie+1+n[re+1+n[ne+1+n[se+1]]]]%32*4;ce*=ce,l=ce*ce*(J[e]*K+J[e+1]*$+J[e+2]*ee+J[e+3]*te)}return 27*(s+a+o+h+l)}}class TurbulenceField{constructor(e,t,i,r){this.scale=e,this.octaves=t,this.velocityMultiplier=i,this.timeScale=r,this.type="TurbulenceField",this.generator=new SimplexNoise,this.timeOffset=new Vector3,this.temp=new Vector3,this.temp2=new Vector3,this.timeOffset.x=Math.random()/this.scale.x*this.timeScale.x,this.timeOffset.y=Math.random()/this.scale.y*this.timeScale.y,this.timeOffset.z=Math.random()/this.scale.z*this.timeScale.z}initialize(e){}update(e,t){const i=e.position.x/this.scale.x,r=e.position.y/this.scale.y,n=e.position.z/this.scale.z;this.temp.set(0,0,0);let s=1;for(let e=0;e0&&void 0!==e.lastPosNoise&&(e.position.sub(e.lastPosNoise),D.set(I[e.generatorIndex[0]].noise2D(0,e.age*i)*r*n,I[e.generatorIndex[1]].noise2D(0,e.age*i)*r*n,I[e.generatorIndex[2]].noise2D(0,e.age*i)*r*n),e.position.add(D),e.lastPosNoise.copy(D)),s>0&&void 0!==e.lastRotNoise&&("number"==typeof e.rotation?(e.rotation-=e.lastRotNoise,e.rotation+=I[e.generatorIndex[3]].noise2D(0,e.age*i)*Math.PI*r*s):(e.lastRotNoise.invert(),e.rotation.multiply(e.lastRotNoise),G.set(I[e.generatorIndex[0]].noise2D(0,e.age*i)*r*s,I[e.generatorIndex[1]].noise2D(0,e.age*i)*r*s,I[e.generatorIndex[2]].noise2D(0,e.age*i)*r*s,I[e.generatorIndex[3]].noise2D(0,e.age*i)*r*s).normalize(),e.rotation.multiply(G),e.lastRotNoise.copy(G)))}toJSON(){return{type:this.type,frequency:this.frequency.toJSON(),power:this.power.toJSON(),positionAmount:this.positionAmount.toJSON(),rotationAmount:this.rotationAmount.toJSON()}}frameUpdate(e){this.duration+=e}static fromJSON(e){return new Noise(ValueGeneratorFromJSON(e.frequency),ValueGeneratorFromJSON(e.power),ValueGeneratorFromJSON(e.positionAmount),ValueGeneratorFromJSON(e.rotationAmount))}clone(){return new Noise(this.frequency.clone(),this.power.clone(),this.positionAmount.clone(),this.rotationAmount.clone())}reset(){}}class TextureSequencer{constructor(e=0,t=0,i=new Vector3){this.scaleX=e,this.scaleY=t,this.position=i,this.locations=[]}transform(e,t){e.x=this.locations[t%this.locations.length].x*this.scaleX+this.position.x,e.y=this.locations[t%this.locations.length].y*this.scaleY+this.position.y,e.z=this.position.z}static fromJSON(e){const t=new TextureSequencer(e.scaleX,e.scaleY,new Vector3(e.position[0],e.position[1],e.position[2]));return t.locations=e.locations.map((e=>new Vector2(e.x,e.y))),t}clone(){const e=new TextureSequencer(this.scaleX,this.scaleY,this.position.clone());return e.locations=this.locations.map((e=>e.clone())),e}toJSON(){return{scaleX:this.scaleX,scaleY:this.scaleY,position:this.position,locations:this.locations.map((e=>({x:e.x,y:e.y})))}}fromImage(e,t){const i=document.createElement("canvas");i.width=e.width,i.height=e.height;const r=i.getContext("2d");if(!r)return;r.drawImage(e,0,0);const n=r.getImageData(0,0,i.width,i.height,{colorSpace:"srgb"});i.remove(),this.locations.length=0;for(let e=0;et&&this.locations.push(new Vector2(i,n.height-e))}}function SequencerFromJSON(e){return"TextureSequencer"===e.type?TextureSequencer.fromJSON(e):new TextureSequencer}class ApplySequences{constructor(e){this.type="ApplySequences",this.sequencers=[],this.time=0,this.index=0,this.pCount=0,this.tempV=new Vector3,this.delay=e}initialize(e){e.id=this.pCount,e.dst=new Vector3,e.begin=new Vector3,e.inMotion=!1,this.pCount++}reset(){this.time=0,this.index=0,this.pCount=0}update(e,t){const i=this.sequencers[this.index],r=e.id*this.delay;this.time>=i[0].a+r&&this.time<=i[0].b+r?(e.inMotion||(e.inMotion=!0,e.begin.copy(e.position),i[1].transform(e.dst,e.id)),e.position.lerpVectors(e.begin,e.dst,ApplySequences.BEZIER.genValue((this.time-i[0].a-r)/(i[0].b-i[0].a)))):this.time>i[0].b+r&&(e.inMotion=!1)}frameUpdate(e){for(;this.index+1=this.sequencers[this.index+1][0].a;)this.index++;this.time+=e}appendSequencer(e,t){this.sequencers.push([e,t])}toJSON(){return{type:this.type,delay:this.delay,sequencers:this.sequencers.map((([e,t])=>({range:e.toJSON(),sequencer:t.toJSON()})))}}static fromJSON(e){const t=new ApplySequences(e.delay);return e.sequencers.forEach((e=>{t.sequencers.push([ValueGeneratorFromJSON(e.range),SequencerFromJSON(e.sequencer)])})),t}clone(){const e=new ApplySequences(this.delay);return e.sequencers=this.sequencers.map((e=>[e[0].clone(),e[1].clone()])),e}}let q;function getPhysicsResolver(){return q}ApplySequences.BEZIER=new Bezier(0,0,1,1);class ApplyCollision{constructor(e,t){this.resolver=e,this.bounce=t,this.type="ApplyCollision",this.tempV=new Vector3}initialize(e){}update(e,t){this.resolver.resolve(e.position,this.tempV)&&e.velocity.reflect(this.tempV).multiplyScalar(this.bounce)}frameUpdate(e){}toJSON(){return{type:this.type,bounce:this.bounce}}static fromJSON(e){return new ApplyCollision(getPhysicsResolver(),e.bounce)}clone(){return new ApplyCollision(this.resolver,this.bounce)}reset(){}}class ColorBySpeed{constructor(e,t){this.color=e,this.speedRange=t,this.type="ColorBySpeed"}initialize(e){this.color.startGen(e.memory)}update(e,t){const i=(e.startSpeed-this.speedRange.a)/(this.speedRange.b-this.speedRange.a);this.color.genColor(e.memory,e.color,i),e.color.x*=e.startColor.x,e.color.y*=e.startColor.y,e.color.z*=e.startColor.z,e.color.w*=e.startColor.w}frameUpdate(e){}toJSON(){return{type:this.type,color:this.color.toJSON(),speedRange:this.speedRange.toJSON()}}static fromJSON(e){return new ColorBySpeed(ColorGeneratorFromJSON(e.color),IntervalValue.fromJSON(e.speedRange))}clone(){return new ColorBySpeed(this.color.clone(),this.speedRange.clone())}reset(){}}class SizeBySpeed{initialize(e){this.size.startGen(e.memory)}constructor(e,t){this.size=e,this.speedRange=t,this.type="SizeBySpeed"}update(e){const t=(e.startSpeed-this.speedRange.a)/(this.speedRange.b-this.speedRange.a);this.size instanceof Vector3Function?this.size.genValue(e.memory,e.size,t).multiply(e.startSize):e.size.copy(e.startSize).multiplyScalar(this.size.genValue(e.memory,t))}toJSON(){return{type:this.type,size:this.size.toJSON(),speedRange:this.speedRange.toJSON()}}static fromJSON(e){return new SizeBySpeed(GeneratorFromJSON(e.size),IntervalValue.fromJSON(e.speedRange))}frameUpdate(e){}clone(){return new SizeBySpeed(this.size.clone(),this.speedRange.clone())}reset(){}}class RotationBySpeed{constructor(e,t){this.angularVelocity=e,this.speedRange=t,this.type="RotationBySpeed",this.tempQuat=new Quaternion}initialize(e){"number"==typeof e.rotation&&this.angularVelocity.startGen(e.memory)}update(e,t){if("number"==typeof e.rotation){const i=(e.startSpeed-this.speedRange.a)/(this.speedRange.b-this.speedRange.a);e.rotation+=t*this.angularVelocity.genValue(e.memory,i)}}toJSON(){return{type:this.type,angularVelocity:this.angularVelocity.toJSON(),speedRange:this.speedRange.toJSON()}}static fromJSON(e){return new RotationBySpeed(ValueGeneratorFromJSON(e.angularVelocity),IntervalValue.fromJSON(e.speedRange))}frameUpdate(e){}clone(){return new RotationBySpeed(this.angularVelocity.clone(),this.speedRange.clone())}reset(){}}class LimitSpeedOverLife{initialize(e){this.speed.startGen(e.memory)}constructor(e,t){this.speed=e,this.dampen=t,this.type="LimitSpeedOverLife"}update(e,t){let i=e.velocity.length(),r=this.speed.genValue(e.memory,e.age/e.life);if(i>r){const n=(i-r)/i;e.velocity.multiplyScalar(1-n*this.dampen*t*20)}}toJSON(){return{type:this.type,speed:this.speed.toJSON(),dampen:this.dampen}}static fromJSON(e){return new LimitSpeedOverLife(ValueGeneratorFromJSON(e.speed),e.dampen)}frameUpdate(e){}clone(){return new LimitSpeedOverLife(this.speed.clone(),this.dampen)}reset(){}}const X={ApplyForce:{type:"ApplyForce",constructor:ApplyForce,params:[["direction",["vec3"]],["magnitude",["value"]]],loadJSON:ApplyForce.fromJSON},Noise:{type:"Noise",constructor:Noise,params:[["frequency",["value"]],["power",["value"]],["positionAmount",["value"]],["rotationAmount",["value"]]],loadJSON:Noise.fromJSON},TurbulenceField:{type:"TurbulenceField",constructor:TurbulenceField,params:[["scale",["vec3"]],["octaves",["number"]],["velocityMultiplier",["vec3"]],["timeScale",["vec3"]]],loadJSON:TurbulenceField.fromJSON},GravityForce:{type:"GravityForce",constructor:GravityForce,params:[["center",["vec3"]],["magnitude",["number"]]],loadJSON:GravityForce.fromJSON},ColorOverLife:{type:"ColorOverLife",constructor:ColorOverLife,params:[["color",["colorFunc"]]],loadJSON:ColorOverLife.fromJSON},RotationOverLife:{type:"RotationOverLife",constructor:RotationOverLife,params:[["angularVelocity",["value","valueFunc"]]],loadJSON:RotationOverLife.fromJSON},Rotation3DOverLife:{type:"Rotation3DOverLife",constructor:Rotation3DOverLife,params:[["angularVelocity",["rotationFunc"]]],loadJSON:Rotation3DOverLife.fromJSON},SizeOverLife:{type:"SizeOverLife",constructor:SizeOverLife,params:[["size",["value","valueFunc","vec3Func"]]],loadJSON:SizeOverLife.fromJSON},ColorBySpeed:{type:"ColorBySpeed",constructor:ColorBySpeed,params:[["color",["colorFunc"]],["speedRange",["range"]]],loadJSON:ColorBySpeed.fromJSON},RotationBySpeed:{type:"RotationBySpeed",constructor:RotationBySpeed,params:[["angularVelocity",["value","valueFunc"]],["speedRange",["range"]]],loadJSON:RotationBySpeed.fromJSON},SizeBySpeed:{type:"SizeBySpeed",constructor:SizeBySpeed,params:[["size",["value","valueFunc","vec3Func"]],["speedRange",["range"]]],loadJSON:SizeBySpeed.fromJSON},SpeedOverLife:{type:"SpeedOverLife",constructor:SpeedOverLife,params:[["speed",["value","valueFunc"]]],loadJSON:SpeedOverLife.fromJSON},FrameOverLife:{type:"FrameOverLife",constructor:FrameOverLife,params:[["frame",["value","valueFunc"]]],loadJSON:FrameOverLife.fromJSON},ForceOverLife:{type:"ForceOverLife",constructor:ForceOverLife,params:[["x",["value","valueFunc"]],["y",["value","valueFunc"]],["z",["value","valueFunc"]]],loadJSON:ForceOverLife.fromJSON},OrbitOverLife:{type:"OrbitOverLife",constructor:OrbitOverLife,params:[["orbitSpeed",["value","valueFunc"]],["axis",["vec3"]]],loadJSON:OrbitOverLife.fromJSON},WidthOverLength:{type:"WidthOverLength",constructor:WidthOverLength,params:[["width",["value","valueFunc"]]],loadJSON:WidthOverLength.fromJSON},ChangeEmitDirection:{type:"ChangeEmitDirection",constructor:ChangeEmitDirection,params:[["angle",["value"]]],loadJSON:ChangeEmitDirection.fromJSON},EmitSubParticleSystem:{type:"EmitSubParticleSystem",constructor:EmitSubParticleSystem,params:[["particleSystem",["self"]],["useVelocityAsBasis",["boolean"]],["subParticleSystem",["particleSystem"]],["mode",["number"]],["emitProbability",["number"]]],loadJSON:EmitSubParticleSystem.fromJSON},LimitSpeedOverLife:{type:"LimitSpeedOverLife",constructor:LimitSpeedOverLife,params:[["speed",["value","valueFunc"]],["dampen",["number"]]],loadJSON:LimitSpeedOverLife.fromJSON}};function BehaviorFromJSON(e,t){return X[e.type].loadJSON(e,t)}const Q=[];function loadPlugin(e){if(!Q.find((t=>t.id===e.id))){e.initialize();for(const t of e.emitterShapes)N[t.type]||(N[t.type]=t);for(const t of e.behaviors)X[t.type]||(X[t.type]=t)}}var H=function(e){return e[e.BillBoard=0]="BillBoard",e[e.StretchedBillBoard=1]="StretchedBillBoard",e[e.Mesh=2]="Mesh",e[e.Trail=3]="Trail",e[e.HorizontalBillBoard=4]="HorizontalBillBoard",e[e.VerticalBillBoard=5]="VerticalBillBoard",e}({}),Y=function(e){function VFXBatch(e){var i;_classCallCheck(this,VFXBatch),_defineProperty(i=_callSuper(this,VFXBatch),"type","VFXBatch"),_defineProperty(i,"systems",void 0),_defineProperty(i,"settings",void 0),_defineProperty(i,"maxParticles",void 0),i.maxParticles=1e3,i.systems=new Set;var r=new t.Layers;r.mask=e.layers.mask;var n=e.material.clone();return n.defines={},Object.assign(n.defines,e.material.defines),i.settings={instancingGeometry:e.instancingGeometry,renderMode:e.renderMode,renderOrder:e.renderOrder,material:n,uTileCount:e.uTileCount,vTileCount:e.vTileCount,blendTiles:e.blendTiles,softParticles:e.softParticles,softNearFade:e.softNearFade,softFarFade:e.softFarFade,layers:r},i.frustumCulled=!1,i.renderOrder=i.settings.renderOrder,i}return _inherits(VFXBatch,e),_createClass(VFXBatch,[{key:"addSystem",value:function addSystem(e){this.systems.add(e)}},{key:"removeSystem",value:function removeSystem(e){this.systems.delete(e)}},{key:"applyDepthTexture",value:function applyDepthTexture(e){var t=this.material.uniforms.depthTexture;t&&t.value!==e&&(t.value=e,this.material.needsUpdate=!0)}}])}(t.Mesh),j=new Vector3(0,0,1),Z=new Quaternion,W=new Vector3,K=new Vector3;new Vector3;var $=new t.PlaneGeometry(1,1,1,1),ee=function(){function ParticleSystem(e){var i,n,s,a,o,h,l,c,u,d,m,p,f,y,v,g,S,x,_,M,w,O,b,z,P=this;if(_classCallCheck(this,ParticleSystem),_defineProperty(this,"autoDestroy",void 0),_defineProperty(this,"prewarm",void 0),_defineProperty(this,"looping",void 0),_defineProperty(this,"duration",void 0),_defineProperty(this,"startLife",void 0),_defineProperty(this,"startSpeed",void 0),_defineProperty(this,"startRotation",void 0),_defineProperty(this,"startSize",void 0),_defineProperty(this,"startColor",void 0),_defineProperty(this,"startTileIndex",void 0),_defineProperty(this,"rendererEmitterSettings",void 0),_defineProperty(this,"emissionOverTime",void 0),_defineProperty(this,"emissionOverDistance",void 0),_defineProperty(this,"emissionBursts",void 0),_defineProperty(this,"onlyUsedByOther",void 0),_defineProperty(this,"worldSpace",void 0),_defineProperty(this,"particleNum",void 0),_defineProperty(this,"paused",void 0),_defineProperty(this,"particles",void 0),_defineProperty(this,"emitterShape",void 0),_defineProperty(this,"emitter",void 0),_defineProperty(this,"rendererSettings",void 0),_defineProperty(this,"neededToUpdateRender",void 0),_defineProperty(this,"behaviors",void 0),_defineProperty(this,"emissionState",void 0),_defineProperty(this,"prewarmed",void 0),_defineProperty(this,"emitEnded",void 0),_defineProperty(this,"markForDestroy",void 0),_defineProperty(this,"previousWorldPos",void 0),_defineProperty(this,"temp",new Vector3),_defineProperty(this,"travelDistance",0),_defineProperty(this,"normalMatrix",new Matrix3),_defineProperty(this,"memory",[]),_defineProperty(this,"listeners",{}),_defineProperty(this,"_renderer",void 0),_defineProperty(this,"firstTimeUpdate",!0),this.autoDestroy=void 0!==e.autoDestroy&&e.autoDestroy,this.duration=null!==(i=e.duration)&&void 0!==i?i:1,this.looping=void 0===e.looping||e.looping,this.prewarm=void 0!==e.prewarm&&e.prewarm,this.startLife=null!==(n=e.startLife)&&void 0!==n?n:new ConstantValue(5),this.startSpeed=null!==(s=e.startSpeed)&&void 0!==s?s:new ConstantValue(0),this.startRotation=null!==(a=e.startRotation)&&void 0!==a?a:new ConstantValue(0),this.startSize=null!==(o=e.startSize)&&void 0!==o?o:new ConstantValue(1),this.startColor=null!==(h=e.startColor)&&void 0!==h?h:new ConstantColor(new Vector4(1,1,1,1)),this.emissionOverTime=null!==(l=e.emissionOverTime)&&void 0!==l?l:new ConstantValue(10),this.emissionOverDistance=null!==(c=e.emissionOverDistance)&&void 0!==c?c:new ConstantValue(0),this.emissionBursts=null!==(u=e.emissionBursts)&&void 0!==u?u:[],this.onlyUsedByOther=null!==(d=e.onlyUsedByOther)&&void 0!==d&&d,this.emitterShape=null!==(m=e.shape)&&void 0!==m?m:new SphereEmitter,this.behaviors=null!==(p=e.behaviors)&&void 0!==p?p:new Array,this.worldSpace=null!==(f=e.worldSpace)&&void 0!==f&&f,this.rendererEmitterSettings=null!==(y=e.rendererEmitterSettings)&&void 0!==y?y:{},e.renderMode===H.StretchedBillBoard){var E,C,N=this.rendererEmitterSettings;void 0!==e.speedFactor&&(N.speedFactor=e.speedFactor),N.speedFactor=null!==(E=N.speedFactor)&&void 0!==E?E:0,N.lengthFactor=null!==(C=N.lengthFactor)&&void 0!==C?C:0}this.rendererSettings={instancingGeometry:null!==(v=e.instancingGeometry)&&void 0!==v?v:$,renderMode:null!==(g=e.renderMode)&&void 0!==g?g:H.BillBoard,renderOrder:null!==(S=e.renderOrder)&&void 0!==S?S:0,material:e.material,uTileCount:null!==(x=e.uTileCount)&&void 0!==x?x:1,vTileCount:null!==(_=e.vTileCount)&&void 0!==_?_:1,blendTiles:null!==(M=e.blendTiles)&&void 0!==M&&M,softParticles:null!==(w=e.softParticles)&&void 0!==w&&w,softNearFade:null!==(O=e.softNearFade)&&void 0!==O?O:0,softFarFade:null!==(b=e.softFarFade)&&void 0!==b?b:0,layers:null!==(z=e.layers)&&void 0!==z?z:new t.Layers},this.neededToUpdateRender=!0,this.particles=new Array,this.startTileIndex=e.startTileIndex||new ConstantValue(0),this.emitter=new r(this),this.paused=!1,this.particleNum=0,this.emissionState={isBursting:!1,burstParticleIndex:0,burstParticleCount:0,burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0,travelDistance:0},this.emissionBursts.forEach((function(e){return e.count.startGen(P.memory)})),this.emissionOverDistance.startGen(this.memory),this.emitEnded=!1,this.markForDestroy=!1,this.prewarmed=!1}return _createClass(ParticleSystem,[{key:"time",get:function get(){return this.emissionState.time},set:function set(e){this.emissionState.time=e}},{key:"layers",get:function get(){return this.rendererSettings.layers}},{key:"texture",get:function get(){return this.rendererSettings.material.map},set:function set(e){this.rendererSettings.material.map=e,this.neededToUpdateRender=!0}},{key:"material",get:function get(){return this.rendererSettings.material},set:function set(e){this.rendererSettings.material=e,this.neededToUpdateRender=!0}},{key:"uTileCount",get:function get(){return this.rendererSettings.uTileCount},set:function set(e){this.rendererSettings.uTileCount=e,this.neededToUpdateRender=!0}},{key:"vTileCount",get:function get(){return this.rendererSettings.vTileCount},set:function set(e){this.rendererSettings.vTileCount=e,this.neededToUpdateRender=!0}},{key:"blendTiles",get:function get(){return this.rendererSettings.blendTiles},set:function set(e){this.rendererSettings.blendTiles=e,this.neededToUpdateRender=!0}},{key:"softParticles",get:function get(){return this.rendererSettings.softParticles},set:function set(e){this.rendererSettings.softParticles=e,this.neededToUpdateRender=!0}},{key:"softNearFade",get:function get(){return this.rendererSettings.softNearFade},set:function set(e){this.rendererSettings.softNearFade=e,this.neededToUpdateRender=!0}},{key:"softFarFade",get:function get(){return this.rendererSettings.softFarFade},set:function set(e){this.rendererSettings.softFarFade=e,this.neededToUpdateRender=!0}},{key:"instancingGeometry",get:function get(){return this.rendererSettings.instancingGeometry},set:function set(e){this.restart(),this.particles.length=0,this.rendererSettings.instancingGeometry=e,this.neededToUpdateRender=!0}},{key:"renderMode",get:function get(){return this.rendererSettings.renderMode},set:function set(e){if((this.rendererSettings.renderMode!=H.Trail&&e===H.Trail||this.rendererSettings.renderMode==H.Trail&&e!==H.Trail)&&(this.restart(),this.particles.length=0),this.rendererSettings.renderMode!==e)switch(e){case H.Trail:this.rendererEmitterSettings={startLength:new ConstantValue(30),followLocalOrigin:!1};break;case H.Mesh:this.rendererEmitterSettings={geometry:new t.PlaneGeometry(1,1)},this.startRotation=new AxisAngleGenerator(new Vector3(0,1,0),new ConstantValue(0));break;case H.StretchedBillBoard:this.rendererEmitterSettings={speedFactor:0,lengthFactor:2},this.rendererSettings.renderMode===H.Mesh&&(this.startRotation=new ConstantValue(0));break;case H.BillBoard:case H.VerticalBillBoard:case H.HorizontalBillBoard:this.rendererEmitterSettings={},this.rendererSettings.renderMode===H.Mesh&&(this.startRotation=new ConstantValue(0))}this.rendererSettings.renderMode=e,this.neededToUpdateRender=!0}},{key:"renderOrder",get:function get(){return this.rendererSettings.renderOrder},set:function set(e){this.rendererSettings.renderOrder=e,this.neededToUpdateRender=!0}},{key:"blending",get:function get(){return this.rendererSettings.material.blending},set:function set(e){this.rendererSettings.material.blending=e,this.neededToUpdateRender=!0}},{key:"pause",value:function pause(){this.paused=!0}},{key:"play",value:function play(){this.paused=!1}},{key:"stop",value:function stop(){this.restart(),this.pause()}},{key:"spawn",value:function spawn(e,t,i){Z.setFromRotationMatrix(i);var r=W,n=Z,s=K;i.decompose(r,n,s);for(var a=0;a.1&&(e=.1),this.neededToUpdateRender&&(this._renderer&&this._renderer.updateSystem(this),this.neededToUpdateRender=!1),this.onlyUsedByOther||this.emit(e,this.emissionState,this.emitter.matrixWorld),this.emitterShape.update(this,e);for(var r=0;rthis.duration&&(this.looping?(t.time-=this.duration,t.burstIndex=0,this.behaviors.forEach((function(e){e.reset()}))):this.emitEnded||this.onlyUsedByOther||this.endEmit()),this.normalMatrix.getNormalMatrix(i);var r=Math.ceil(t.waitEmiting);for(this.spawn(r,t,i),t.waitEmiting-=r;t.burstIndex0){var a=Math.floor(t.travelDistance*s);t.travelDistance-=a/s,t.waitEmiting+=a}}void 0===t.previousWorldPos&&(t.previousWorldPos=new Vector3),t.previousWorldPos.set(i.elements[12],i.elements[13],i.elements[14]),t.time+=e}},{key:"toJSON",value:function toJSON(e){var t,i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if((void 0===e||"string"==typeof e)&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}}),e.materials[this.rendererSettings.material.uuid]=this.rendererSettings.material.toJSON(e),r.useUrlForImage&&void 0!==(null===(t=this.texture)||void 0===t?void 0:t.source)){var n=this.texture.source;e.images[n.uuid]={uuid:n.uuid,url:this.texture.image.url}}i=this.renderMode===H.Trail?{startLength:this.rendererEmitterSettings.startLength.toJSON(),followLocalOrigin:this.rendererEmitterSettings.followLocalOrigin}:this.renderMode===H.Mesh?{}:this.renderMode===H.StretchedBillBoard?{speedFactor:this.rendererEmitterSettings.speedFactor,lengthFactor:this.rendererEmitterSettings.lengthFactor}:{};var s=this.rendererSettings.instancingGeometry;return e.geometries&&!e.geometries[s.uuid]&&(e.geometries[s.uuid]=s.toJSON()),{version:"3.0",autoDestroy:this.autoDestroy,looping:this.looping,prewarm:this.prewarm,duration:this.duration,shape:this.emitterShape.toJSON(),startLife:this.startLife.toJSON(),startSpeed:this.startSpeed.toJSON(),startRotation:this.startRotation.toJSON(),startSize:this.startSize.toJSON(),startColor:this.startColor.toJSON(),emissionOverTime:this.emissionOverTime.toJSON(),emissionOverDistance:this.emissionOverDistance.toJSON(),emissionBursts:this.emissionBursts.map((function(e){return{time:e.time,count:e.count.toJSON(),probability:e.probability,interval:e.interval,cycle:e.cycle}})),onlyUsedByOther:this.onlyUsedByOther,instancingGeometry:this.rendererSettings.instancingGeometry.uuid,renderOrder:this.renderOrder,renderMode:this.renderMode,rendererEmitterSettings:i,material:this.rendererSettings.material.uuid,layers:this.layers.mask,startTileIndex:this.startTileIndex.toJSON(),uTileCount:this.uTileCount,vTileCount:this.vTileCount,blendTiles:this.blendTiles,softParticles:this.rendererSettings.softParticles,softFarFade:this.rendererSettings.softFarFade,softNearFade:this.rendererSettings.softNearFade,behaviors:this.behaviors.map((function(e){return e.toJSON()})),worldSpace:this.worldSpace}}},{key:"addBehavior",value:function addBehavior(e){this.behaviors.push(e)}},{key:"getRendererSettings",value:function getRendererSettings(){return this.rendererSettings}},{key:"addEventListener",value:function addEventListener(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)}},{key:"removeAllEventListeners",value:function removeAllEventListeners(e){this.listeners[e]&&(this.listeners[e]=[])}},{key:"removeEventListener",value:function removeEventListener(e,t){if(this.listeners[e]){var i=this.listeners[e].indexOf(t);-1!==i&&this.listeners[e].splice(i,1)}}},{key:"fire",value:function fire(e){this.listeners[e.type]&&this.listeners[e.type].forEach((function(t){return t(e)}))}},{key:"clone",value:function clone(){var e,i=[],r=_createForOfIteratorHelper(this.emissionBursts);try{for(r.s();!(e=r.n()).done;){var n=e.value,s={};Object.assign(s,n),i.push(s)}}catch(e){r.e(e)}finally{r.f()}var a,o,h=[],l=_createForOfIteratorHelper(this.behaviors);try{for(l.s();!(a=l.n()).done;){var c=a.value;h.push(c.clone())}}catch(e){l.e(e)}finally{l.f()}o=this.renderMode===H.Trail?{startLength:this.rendererEmitterSettings.startLength.clone(),followLocalOrigin:this.rendererEmitterSettings.followLocalOrigin}:this.renderMode===H.StretchedBillBoard?{lengthFactor:this.rendererEmitterSettings.lengthFactor,speedFactor:this.rendererEmitterSettings.speedFactor}:{};var u=new t.Layers;return u.mask=this.layers.mask,new ParticleSystem({autoDestroy:this.autoDestroy,looping:this.looping,duration:this.duration,shape:this.emitterShape.clone(),startLife:this.startLife.clone(),startSpeed:this.startSpeed.clone(),startRotation:this.startRotation.clone(),startSize:this.startSize.clone(),startColor:this.startColor.clone(),emissionOverTime:this.emissionOverTime.clone(),emissionOverDistance:this.emissionOverDistance.clone(),emissionBursts:i,onlyUsedByOther:this.onlyUsedByOther,instancingGeometry:this.rendererSettings.instancingGeometry,renderMode:this.renderMode,renderOrder:this.renderOrder,rendererEmitterSettings:o,material:this.rendererSettings.material,startTileIndex:this.startTileIndex,uTileCount:this.uTileCount,vTileCount:this.vTileCount,blendTiles:this.blendTiles,softParticles:this.softParticles,softFarFade:this.softFarFade,softNearFade:this.softNearFade,behaviors:h,worldSpace:this.worldSpace,layers:u})}}],[{key:"fromJSON",value:function fromJSON(e,i,r){var n,s,a,o=EmitterFromJSON(e.shape,i);if(e.renderMode===H.Trail){var h=e.rendererEmitterSettings;a={startLength:null!=h.startLength?ValueGeneratorFromJSON(h.startLength):new ConstantValue(30),followLocalOrigin:h.followLocalOrigin}}else e.renderMode===H.Mesh?a={}:e.renderMode===H.StretchedBillBoard?(a=e.rendererEmitterSettings,null!=e.speedFactor&&(a.speedFactor=e.speedFactor)):a={};var l=new t.Layers;e.layers&&(l.mask=e.layers);var c=new ParticleSystem({autoDestroy:e.autoDestroy,looping:e.looping,prewarm:e.prewarm,duration:e.duration,shape:o,startLife:ValueGeneratorFromJSON(e.startLife),startSpeed:ValueGeneratorFromJSON(e.startSpeed),startRotation:GeneratorFromJSON(e.startRotation),startSize:GeneratorFromJSON(e.startSize),startColor:ColorGeneratorFromJSON(e.startColor),emissionOverTime:ValueGeneratorFromJSON(e.emissionOverTime),emissionOverDistance:ValueGeneratorFromJSON(e.emissionOverDistance),emissionBursts:null===(n=e.emissionBursts)||void 0===n?void 0:n.map((function(e){var t,i,r;return{time:e.time,count:"number"==typeof e.count?new ConstantValue(e.count):ValueGeneratorFromJSON(e.count),probability:null!==(t=e.probability)&&void 0!==t?t:1,interval:null!==(i=e.interval)&&void 0!==i?i:.1,cycle:null!==(r=e.cycle)&&void 0!==r?r:1}})),onlyUsedByOther:e.onlyUsedByOther,instancingGeometry:i.geometries[e.instancingGeometry],renderMode:e.renderMode,rendererEmitterSettings:a,renderOrder:e.renderOrder,layers:l,material:e.material?i.materials[e.material]:e.texture?new t.MeshBasicMaterial({map:i.textures[e.texture],transparent:null===(s=e.transparent)||void 0===s||s,blending:e.blending,side:t.DoubleSide}):new t.MeshBasicMaterial({color:16777215,transparent:!0,blending:t.AdditiveBlending,side:t.DoubleSide}),startTileIndex:"number"==typeof e.startTileIndex?new ConstantValue(e.startTileIndex):ValueGeneratorFromJSON(e.startTileIndex),uTileCount:e.uTileCount,vTileCount:e.vTileCount,blendTiles:e.blendTiles,softParticles:e.softParticles,softFarFade:e.softFarFade,softNearFade:e.softNearFade,behaviors:[],worldSpace:e.worldSpace});return c.behaviors=e.behaviors.map((function(e){var t=BehaviorFromJSON(e,c);return"EmitSubParticleSystem"===t.type&&(r[e.subParticleSystem]=t),t})),c}}])}(),te="\n\n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n\nvoid main() {\n\n #include \n \n vec3 outgoingLight = vec3( 0.0 );\n vec4 diffuseColor = vColor;\n \n #include \n \n #include \n #include \n\n outgoingLight = diffuseColor.rgb;\n \n #ifdef USE_COLOR_AS_ALPHA\n gl_FragColor = vec4( outgoingLight, diffuseColor.r );\n #else\n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n #endif\n \n #include \n #include \n}\n",ie="\n#define STANDARD\n\n#ifdef PHYSICAL\n#define IOR\n#define USE_SPECULAR\n#endif\n\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n\n#ifdef IOR\nuniform float ior;\n#endif\n\n#ifdef USE_SPECULAR\nuniform float specularIntensity;\nuniform vec3 specularColor;\n\n#ifdef USE_SPECULAR_COLORMAP\nuniform sampler2D specularColorMap;\n#endif\n\n#ifdef USE_SPECULAR_INTENSITYMAP\nuniform sampler2D specularIntensityMap;\n#endif\n#endif\n\n#ifdef USE_CLEARCOAT\nuniform float clearcoat;\nuniform float clearcoatRoughness;\n#endif\n\n#ifdef USE_DISPERSION\nuniform float dispersion;\n#endif\n\n#ifdef USE_IRIDESCENCE\nuniform float iridescence;\nuniform float iridescenceIOR;\nuniform float iridescenceThicknessMinimum;\nuniform float iridescenceThicknessMaximum;\n#endif\n\n#ifdef USE_SHEEN\nuniform vec3 sheenColor;\nuniform float sheenRoughness;\n\n#ifdef USE_SHEEN_COLORMAP\nuniform sampler2D sheenColorMap;\n#endif\n\n#ifdef USE_SHEEN_ROUGHNESSMAP\nuniform sampler2D sheenRoughnessMap;\n#endif\n#endif\n\n#ifdef USE_ANISOTROPY\nuniform vec2 anisotropyVector;\n\n#ifdef USE_ANISOTROPYMAP\nuniform sampler2D anisotropyMap;\n#endif\n#endif\n\nvarying vec3 vViewPosition;\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\nvec4 diffuseColor = vec4( diffuse, opacity );\n#include \n\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveRadiance = emissive;\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n// accumulation\n#include \n#include \n#include \n#include \n\n// modulation\n#include \n\nvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\nvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\n#include \n\nvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\n#ifdef USE_SHEEN\n\n// Sheen energy compensation approximation calculation can be found at the end of\n// https://drive.google.com/file/d/1T0D1VSyR4AllqIJTQAraEIzjlb5h4FKH/view?usp=sharing\nfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\noutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\n\n#endif\n\n#ifdef USE_CLEARCOAT\n\nfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\nvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\noutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n}",re="\n#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include \n\nattribute vec3 offset;\nattribute vec4 rotation;\nattribute vec3 size;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n #include \n float x2 = rotation.x + rotation.x, y2 = rotation.y + rotation.y, z2 = rotation.z + rotation.z;\n float xx = rotation.x * x2, xy = rotation.x * y2, xz = rotation.x * z2;\n float yy = rotation.y * y2, yz = rotation.y * z2, zz = rotation.z * z2;\n float wx = rotation.w * x2, wy = rotation.w * y2, wz = rotation.w * z2;\n float sx = size.x, sy = size.y, sz = size.z;\n\n mat4 particleMatrix = mat4(( 1.0 - ( yy + zz ) ) * sx, ( xy + wz ) * sx, ( xz - wy ) * sx, 0.0, // 1. column\n ( xy - wz ) * sy, ( 1.0 - ( xx + zz ) ) * sy, ( yz + wx ) * sy, 0.0, // 2. column\n ( xz + wy ) * sz, ( yz - wx ) * sz, ( 1.0 - ( xx + yy ) ) * sz, 0.0, // 3. column\n offset.x, offset.y, offset.z, 1.0);\n\n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n\n\t// replace defaultnormal_vertex\n\tvec3 transformedNormal = objectNormal;\n mat3 m = mat3( particleMatrix );\n transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n transformedNormal = m * transformedNormal;\n transformedNormal = normalMatrix * transformedNormal;\n #ifdef FLIP_SIDED\n transformedNormal = - transformedNormal;\n #endif\n #ifdef USE_TANGENT\n vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n #ifdef FLIP_SIDED\n transformedTangent = - transformedTangent;\n #endif\n #endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// replace include \n vec4 mvPosition = vec4( transformed, 1.0 );\n mvPosition = modelViewMatrix * (particleMatrix * mvPosition);\n\tgl_Position = projectionMatrix * mvPosition;\n\n\t#include \n\t#include \n\t\n\tvViewPosition = - mvPosition.xyz;\n\t\n\t#include \n\t#include \n\t#include \n#ifdef USE_TRANSMISSION\n vWorldPosition = worldPosition.xyz;\n#endif\n}\n";function getMaterialUVChannelName(e){return 0===e?"uv":"uv".concat(e)}var ne=function(e){function ParticleMeshStandardMaterial(e){return _classCallCheck(this,ParticleMeshStandardMaterial),_callSuper(this,ParticleMeshStandardMaterial,[e])}return _inherits(ParticleMeshStandardMaterial,e),_createClass(ParticleMeshStandardMaterial,[{key:"onBeforeCompile",value:function onBeforeCompile(e,t){_get(_getPrototypeOf(ParticleMeshStandardMaterial.prototype),"onBeforeCompile",this).call(this,e,t),e.vertexShader=re,e.fragmentShader=ie}}])}(t.MeshStandardMaterial),se=function(e){function ParticleMeshPhysicsMaterial(e){return _classCallCheck(this,ParticleMeshPhysicsMaterial),_callSuper(this,ParticleMeshPhysicsMaterial,[e])}return _inherits(ParticleMeshPhysicsMaterial,e),_createClass(ParticleMeshPhysicsMaterial,[{key:"onBeforeCompile",value:function onBeforeCompile(e,t){_get(_getPrototypeOf(ParticleMeshPhysicsMaterial.prototype),"onBeforeCompile",this).call(this,e,t),e.vertexShader=re,e.fragmentShader=ie}}])}(t.MeshPhysicalMaterial),ae=function(e){function SpriteBatch(e){var t;return _classCallCheck(this,SpriteBatch),_defineProperty(t=_callSuper(this,SpriteBatch,[e]),"offsetBuffer",void 0),_defineProperty(t,"rotationBuffer",void 0),_defineProperty(t,"sizeBuffer",void 0),_defineProperty(t,"colorBuffer",void 0),_defineProperty(t,"uvTileBuffer",void 0),_defineProperty(t,"velocityBuffer",void 0),_defineProperty(t,"vector_",new Vector3),_defineProperty(t,"vector2_",new Vector3),_defineProperty(t,"vector3_",new Vector3),_defineProperty(t,"quaternion_",new Quaternion),_defineProperty(t,"quaternion2_",new Quaternion),_defineProperty(t,"quaternion3_",new Quaternion),_defineProperty(t,"rotationMat_",new Matrix3),_defineProperty(t,"rotationMat2_",new Matrix3),t.maxParticles=1e3,t.setupBuffers(),t.rebuildMaterial(),t}return _inherits(SpriteBatch,e),_createClass(SpriteBatch,[{key:"buildExpandableBuffers",value:function buildExpandableBuffers(){this.offsetBuffer=new t.InstancedBufferAttribute(new Float32Array(3*this.maxParticles),3),this.offsetBuffer.setUsage(t.DynamicDrawUsage),this.geometry.setAttribute("offset",this.offsetBuffer),this.colorBuffer=new t.InstancedBufferAttribute(new Float32Array(4*this.maxParticles),4),this.colorBuffer.setUsage(t.DynamicDrawUsage),this.geometry.setAttribute("color",this.colorBuffer),this.settings.renderMode===H.Mesh?(this.rotationBuffer=new t.InstancedBufferAttribute(new Float32Array(4*this.maxParticles),4),this.rotationBuffer.setUsage(t.DynamicDrawUsage),this.geometry.setAttribute("rotation",this.rotationBuffer)):this.settings.renderMode!==H.BillBoard&&this.settings.renderMode!==H.HorizontalBillBoard&&this.settings.renderMode!==H.VerticalBillBoard&&this.settings.renderMode!==H.StretchedBillBoard||(this.rotationBuffer=new t.InstancedBufferAttribute(new Float32Array(this.maxParticles),1),this.rotationBuffer.setUsage(t.DynamicDrawUsage),this.geometry.setAttribute("rotation",this.rotationBuffer)),this.sizeBuffer=new t.InstancedBufferAttribute(new Float32Array(3*this.maxParticles),3),this.sizeBuffer.setUsage(t.DynamicDrawUsage),this.geometry.setAttribute("size",this.sizeBuffer),this.uvTileBuffer=new t.InstancedBufferAttribute(new Float32Array(this.maxParticles),1),this.uvTileBuffer.setUsage(t.DynamicDrawUsage),this.geometry.setAttribute("uvTile",this.uvTileBuffer),this.settings.renderMode===H.StretchedBillBoard&&(this.velocityBuffer=new t.InstancedBufferAttribute(new Float32Array(4*this.maxParticles),4),this.velocityBuffer.setUsage(t.DynamicDrawUsage),this.geometry.setAttribute("velocity",this.velocityBuffer))}},{key:"setupBuffers",value:function setupBuffers(){this.geometry&&this.geometry.dispose(),this.geometry=new t.InstancedBufferGeometry,this.geometry.setIndex(this.settings.instancingGeometry.getIndex()),this.settings.instancingGeometry.hasAttribute("normal")&&this.geometry.setAttribute("normal",this.settings.instancingGeometry.getAttribute("normal")),this.geometry.setAttribute("position",this.settings.instancingGeometry.getAttribute("position")),this.geometry.setAttribute("uv",this.settings.instancingGeometry.getAttribute("uv")),this.buildExpandableBuffers()}},{key:"expandBuffers",value:function expandBuffers(e){for(;e>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}},{key:"rebuildMaterial",value:function rebuildMaterial(){this.layers.mask=this.settings.layers.mask;var e={},i={};"MeshStandardMaterial"!==this.settings.material.type&&"MeshPhysicalMaterial"!==this.settings.material.type&&(e.map=new t.Uniform(this.settings.material.map)),this.settings.material.alphaTest&&(i.USE_ALPHATEST="",e.alphaTest=new t.Uniform(this.settings.material.alphaTest)),i.USE_UV="";var r,n=this.settings.uTileCount,s=this.settings.vTileCount;if((n>1||s>1)&&(i.UV_TILE="",e.tileCount=new t.Uniform(new Vector2(n,s))),this.settings.material.defines&&void 0!==this.settings.material.defines.USE_COLOR_AS_ALPHA&&(i.USE_COLOR_AS_ALPHA=""),this.settings.material.normalMap&&(i.USE_NORMALMAP="",i.NORMALMAP_UV=getMaterialUVChannelName(this.settings.material.normalMap.channel),e.normalMapTransform=new t.Uniform((new Matrix3).copy(this.settings.material.normalMap.matrix))),this.settings.material.map&&(i.USE_MAP="",this.settings.blendTiles&&(i.TILE_BLEND=""),i.MAP_UV=getMaterialUVChannelName(this.settings.material.map.channel),e.mapTransform=new t.Uniform((new Matrix3).copy(this.settings.material.map.matrix))),i.USE_COLOR_ALPHA="",this.settings.softParticles){i.SOFT_PARTICLES="";var a=this.settings.softNearFade,o=1/(this.settings.softFarFade-this.settings.softNearFade);e.softParams=new t.Uniform(new Vector2(a,o)),e.depthTexture=new t.Uniform(null);var h=e.projParams=new t.Uniform(new Vector4);r=function onBeforeRender(e,t,i){h.value.set(i.near,i.far,0,0)}}var l=!1;if(this.settings.renderMode===H.BillBoard||this.settings.renderMode===H.VerticalBillBoard||this.settings.renderMode===H.HorizontalBillBoard||this.settings.renderMode===H.Mesh){var c,u;this.settings.renderMode===H.Mesh?"MeshStandardMaterial"===this.settings.material.type||"MeshPhysicalMaterial"===this.settings.material.type?(i.USE_COLOR="",c=re,u=ie,l=!0):(c="\n#include \n#include \n#include \n#include \n#include \n#include \n\nattribute vec3 offset;\nattribute vec4 rotation;\nattribute vec3 size;\n// attribute vec4 color;\n\nvoid main() {\n\n float x2 = rotation.x + rotation.x, y2 = rotation.y + rotation.y, z2 = rotation.z + rotation.z;\n float xx = rotation.x * x2, xy = rotation.x * y2, xz = rotation.x * z2;\n float yy = rotation.y * y2, yz = rotation.y * z2, zz = rotation.z * z2;\n float wx = rotation.w * x2, wy = rotation.w * y2, wz = rotation.w * z2;\n float sx = size.x, sy = size.y, sz = size.z;\n \n mat4 matrix = mat4(( 1.0 - ( yy + zz ) ) * sx, ( xy + wz ) * sx, ( xz - wy ) * sx, 0.0, // 1. column\n ( xy - wz ) * sy, ( 1.0 - ( xx + zz ) ) * sy, ( yz + wx ) * sy, 0.0, // 2. column\n ( xz + wy ) * sz, ( yz - wx ) * sz, ( 1.0 - ( xx + yy ) ) * sz, 0.0, // 3. column\n offset.x, offset.y, offset.z, 1.0);\n \n vec4 mvPosition = modelViewMatrix * (matrix * vec4( position, 1.0 ));\n\n\tvColor = color;\n\n\tgl_Position = projectionMatrix * mvPosition;\n\n\t#include \n\t#include \n #include \n #include \n}\n",u=te):(c="\n#include \n#include \n#include \n#include \n\n#include \n#include \n\nattribute vec3 offset;\nattribute float rotation;\nattribute vec3 size;\n\nvoid main() {\n\t\n vec2 alignedPosition = position.xy * size.xy;\n \n vec2 rotatedPosition;\n rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n#ifdef HORIZONTAL\n vec4 mvPosition = modelMatrix * vec4( offset, 1.0 );\n mvPosition.x += rotatedPosition.x;\n mvPosition.z -= rotatedPosition.y;\n mvPosition = viewMatrix * mvPosition;\n#elif defined(VERTICAL)\n vec4 mvPosition = modelMatrix * vec4( offset, 1.0 );\n mvPosition.y += rotatedPosition.y;\n mvPosition = viewMatrix * mvPosition;\n mvPosition.x += rotatedPosition.x;\n#else\n vec4 mvPosition = modelViewMatrix * vec4( offset, 1.0 );\n mvPosition.xy += rotatedPosition;\n#endif\n\n\tvColor = color;\n\n\tgl_Position = projectionMatrix * mvPosition;\n\n\t#include \n\n\t#include \n\n\t#include \n\t#include \n}\n",u=te),this.settings.renderMode===H.VerticalBillBoard?i.VERTICAL="":this.settings.renderMode===H.HorizontalBillBoard&&(i.HORIZONTAL="");var d=!1;this.settings.renderMode===H.Mesh&&("MeshStandardMaterial"===this.settings.material.type?(this.material=new ne({}),this.material.copy(this.settings.material),this.material.uniforms=e,this.material.defines=i,d=!0):"MeshPhysicalMaterial"===this.settings.material.type&&(this.material=new se({}),this.material.copy(this.settings.material),this.material.uniforms=e,this.material.defines=i,d=!0)),d||(this.material=new t.ShaderMaterial({uniforms:e,defines:i,vertexShader:c,fragmentShader:u,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,blending:this.settings.material.blending,blendDst:this.settings.material.blendDst,blendSrc:this.settings.material.blendSrc,blendEquation:this.settings.material.blendEquation,premultipliedAlpha:this.settings.material.premultipliedAlpha,side:this.settings.material.side,alphaTest:this.settings.material.alphaTest,depthTest:this.settings.material.depthTest,lights:l}))}else{if(this.settings.renderMode!==H.StretchedBillBoard)throw new Error("render mode unavailable");e.speedFactor=new t.Uniform(1),this.material=new t.ShaderMaterial({uniforms:e,defines:i,vertexShader:"\n#include \n#include \n#include \n#include \n\n#include \n#include \n\nattribute vec3 offset;\nattribute float rotation;\nattribute vec3 size;\nattribute vec4 velocity;\n\nuniform float speedFactor;\n\nvoid main() {\n float lengthFactor = velocity.w;\n float avgSize = (size.x + size.y) * 0.5;\n#ifdef USE_SKEW\n vec4 mvPosition = modelViewMatrix * vec4( offset, 1.0 );\n vec3 viewVelocity = normalMatrix * velocity.xyz;\n\n vec3 scaledPos = vec3(position.xy * size.xy, position.z);\n float vlength = length(viewVelocity);\n vec3 projVelocity = dot(scaledPos, viewVelocity) * viewVelocity / vlength;\n mvPosition.xyz += scaledPos + projVelocity * (speedFactor / avgSize + lengthFactor / vlength);\n#else\n vec4 mvPosition = modelViewMatrix * vec4( offset, 1.0 );\n vec3 viewVelocity = normalMatrix * velocity.xyz;\n float vlength = length(viewVelocity); \n mvPosition.xyz += position.y * normalize(cross(mvPosition.xyz, viewVelocity)) * avgSize; // switch the cross to match unity implementation\n mvPosition.xyz -= (position.x + 0.5) * viewVelocity * (1.0 + lengthFactor / vlength) * avgSize; // minus position.x to match unity implementation\n#endif\n\tvColor = color;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",fragmentShader:te,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,blending:this.settings.material.blending,blendDst:this.settings.material.blendDst,blendSrc:this.settings.material.blendSrc,blendEquation:this.settings.material.blendEquation,premultipliedAlpha:this.settings.material.premultipliedAlpha,side:this.settings.material.side,alphaTest:this.settings.material.alphaTest,depthTest:this.settings.material.depthTest})}this.material&&r&&(this.material.onBeforeRender=r)}},{key:"update",value:function update(){var e=this,t=0,i=0;this.systems.forEach((function(e){i+=e.particleNum})),i>this.maxParticles&&this.expandBuffers(i),this.systems.forEach((function(i){i.emitter.updateMatrixWorld&&(i.emitter.updateWorldMatrix(!0,!1),i.emitter.updateMatrixWorld(!0));var r=i.particles,n=i.particleNum,s=e.quaternion2_,a=e.vector2_,o=e.vector3_;i.emitter.matrixWorld.decompose(a,s,o),e.rotationMat_.setFromMatrix4(i.emitter.matrixWorld);for(var h=0;h0&&(this.offsetBuffer.clearUpdateRanges(),this.offsetBuffer.addUpdateRange(0,3*t),this.offsetBuffer.needsUpdate=!0,this.sizeBuffer.clearUpdateRanges(),this.sizeBuffer.addUpdateRange(0,3*t),this.sizeBuffer.needsUpdate=!0,this.colorBuffer.clearUpdateRanges(),this.colorBuffer.addUpdateRange(0,4*t),this.colorBuffer.needsUpdate=!0,this.uvTileBuffer.clearUpdateRanges(),this.uvTileBuffer.addUpdateRange(0,t),this.uvTileBuffer.needsUpdate=!0,this.settings.renderMode===H.StretchedBillBoard&&this.velocityBuffer&&(this.velocityBuffer.clearUpdateRanges(),this.velocityBuffer.addUpdateRange(0,4*t),this.velocityBuffer.needsUpdate=!0),this.settings.renderMode===H.Mesh?(this.rotationBuffer.clearUpdateRanges(),this.rotationBuffer.addUpdateRange(0,4*t),this.rotationBuffer.needsUpdate=!0):this.settings.renderMode!==H.StretchedBillBoard&&this.settings.renderMode!==H.HorizontalBillBoard&&this.settings.renderMode!==H.VerticalBillBoard&&this.settings.renderMode!==H.BillBoard||(this.rotationBuffer.clearUpdateRanges(),this.rotationBuffer.addUpdateRange(0,t),this.rotationBuffer.needsUpdate=!0))}},{key:"dispose",value:function dispose(){this.geometry.dispose()}}])}(Y),oe=function(e){function TrailBatch(e){var t;return _classCallCheck(this,TrailBatch),_defineProperty(t=_callSuper(this,TrailBatch,[e]),"positionBuffer",void 0),_defineProperty(t,"previousBuffer",void 0),_defineProperty(t,"nextBuffer",void 0),_defineProperty(t,"uvBuffer",void 0),_defineProperty(t,"sideBuffer",void 0),_defineProperty(t,"widthBuffer",void 0),_defineProperty(t,"colorBuffer",void 0),_defineProperty(t,"indexBuffer",void 0),_defineProperty(t,"vector_",new Vector3),_defineProperty(t,"vector2_",new Vector3),_defineProperty(t,"vector3_",new Vector3),_defineProperty(t,"quaternion_",new Quaternion),t.maxParticles=1e4,t.setupBuffers(),t.rebuildMaterial(),t}return _inherits(TrailBatch,e),_createClass(TrailBatch,[{key:"setupBuffers",value:function setupBuffers(){this.geometry&&this.geometry.dispose(),this.geometry=new t.BufferGeometry,this.indexBuffer=new t.BufferAttribute(new Uint32Array(6*this.maxParticles),1),this.indexBuffer.setUsage(t.DynamicDrawUsage),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new t.BufferAttribute(new Float32Array(6*this.maxParticles),3),this.positionBuffer.setUsage(t.DynamicDrawUsage),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new t.BufferAttribute(new Float32Array(6*this.maxParticles),3),this.previousBuffer.setUsage(t.DynamicDrawUsage),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new t.BufferAttribute(new Float32Array(6*this.maxParticles),3),this.nextBuffer.setUsage(t.DynamicDrawUsage),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new t.BufferAttribute(new Float32Array(2*this.maxParticles),1),this.widthBuffer.setUsage(t.DynamicDrawUsage),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new t.BufferAttribute(new Float32Array(2*this.maxParticles),1),this.sideBuffer.setUsage(t.DynamicDrawUsage),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new t.BufferAttribute(new Float32Array(4*this.maxParticles),2),this.uvBuffer.setUsage(t.DynamicDrawUsage),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new t.BufferAttribute(new Float32Array(8*this.maxParticles),4),this.colorBuffer.setUsage(t.DynamicDrawUsage),this.geometry.setAttribute("color",this.colorBuffer)}},{key:"expandBuffers",value:function expandBuffers(e){for(;e>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}},{key:"rebuildMaterial",value:function rebuildMaterial(){this.layers.mask=this.settings.layers.mask;var e={lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},resolution:{value:new Vector2(1,1)},sizeAttenuation:{value:1},visibility:{value:1},alphaTest:{value:0}},i={USE_UV:"",USE_COLOR_ALPHA:""};if(this.settings.material.map&&(i.USE_MAP="",i.MAP_UV=getMaterialUVChannelName(this.settings.material.map.channel),e.map=new t.Uniform(this.settings.material.map),e.mapTransform=new t.Uniform((new Matrix3).copy(this.settings.material.map.matrix))),this.settings.material.defines&&void 0!==this.settings.material.defines.USE_COLOR_AS_ALPHA&&(i.USE_COLOR_AS_ALPHA=""),this.settings.renderMode!==H.Trail)throw new Error("render mode unavailable");this.material=new t.ShaderMaterial({uniforms:e,defines:i,vertexShader:"\n#include \n#include \n#include \n#include \n#include \n#include \n\nattribute vec3 previous;\nattribute vec3 next;\nattribute float side;\nattribute float width;\n\nuniform vec2 resolution;\nuniform float lineWidth;\nuniform float sizeAttenuation;\n \nvec2 fix(vec4 i, float aspect) {\n vec2 res = i.xy / i.w;\n res.x *= aspect;\n return res;\n}\n \nvoid main() {\n\n #include \n \n float aspect = resolution.x / resolution.y;\n\n vColor = color;\n\n mat4 m = projectionMatrix * modelViewMatrix;\n vec4 finalPosition = m * vec4( position, 1.0 );\n vec4 prevPos = m * vec4( previous, 1.0 );\n vec4 nextPos = m * vec4( next, 1.0 );\n\n vec2 currentP = fix( finalPosition, aspect );\n vec2 prevP = fix( prevPos, aspect );\n vec2 nextP = fix( nextPos, aspect );\n\n float w = lineWidth * width;\n\n vec2 dir;\n if( nextP == currentP ) dir = normalize( currentP - prevP );\n else if( prevP == currentP ) dir = normalize( nextP - currentP );\n else {\n vec2 dir1 = normalize( currentP - prevP );\n vec2 dir2 = normalize( nextP - currentP );\n dir = normalize( dir1 + dir2 );\n\n vec2 perp = vec2( -dir1.y, dir1.x );\n vec2 miter = vec2( -dir.y, dir.x );\n //w = clamp( w / dot( miter, perp ), 0., 4., * lineWidth * width );\n\n }\n\n //vec2 normal = ( cross( vec3( dir, 0. ) vec3( 0., 0., 1. ) ) ).xy;\n vec4 normal = vec4( -dir.y, dir.x, 0., 1. );\n normal.xy *= .5 * w;\n normal *= projectionMatrix;\n if( sizeAttenuation == 0. ) {\n normal.xy *= finalPosition.w;\n normal.xy /= ( vec4( resolution, 0., 1. ) * projectionMatrix ).xy;\n }\n\n finalPosition.xy += normal.xy * side;\n\n gl_Position = finalPosition;\n\n\t#include \n\t#include \n\t\n vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n \n\t#include \n}",fragmentShader:"\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nuniform sampler2D alphaMap;\nuniform float useAlphaMap;\nuniform float visibility;\nuniform float alphaTest;\n\nvarying vec4 vColor;\n \nvoid main() {\n #include \n #include \n\n vec4 diffuseColor = vColor;\n \n #ifdef USE_MAP\n #include \n #ifndef USE_COLOR_AS_ALPHA\n #endif\n #endif\n if( useAlphaMap == 1. ) diffuseColor.a *= texture2D( alphaMap, vUv).a;\n if( diffuseColor.a < alphaTest ) discard;\n gl_FragColor = diffuseColor;\n\n #include \n #include \n}",transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||t.AdditiveBlending,blendDst:this.settings.material.blendDst,blendSrc:this.settings.material.blendSrc,blendEquation:this.settings.material.blendEquation,premultipliedAlpha:this.settings.material.premultipliedAlpha})}},{key:"update",value:function update(){var e=this,t=0,i=0,r=0;this.systems.forEach((function(e){for(var t=0;tthis.maxParticles&&this.expandBuffers(r),this.systems.forEach((function(r){r.emitter.updateMatrixWorld&&(r.emitter.updateWorldMatrix(!0,!1),r.emitter.updateMatrixWorld(!0));var n=e.quaternion_,s=e.vector2_,a=e.vector3_;r.emitter.matrixWorld.decompose(s,n,a);for(var o=r.particles,h=r.particleNum,l=e.settings.uTileCount,c=e.settings.vTileCount,u=1/l,d=1/c,m=0;m1&&(o=1-o,h=1-h);var l=t.getIndex().array[3*r],c=t.getIndex().array[3*r+1],u=t.getIndex().array[3*r+2],d=t.getAttribute("position");this._tempA.fromBufferAttribute(d,l),this._tempB.fromBufferAttribute(d,c),this._tempC.fromBufferAttribute(d,u),this._tempB.sub(this._tempA),this._tempC.sub(this._tempA),this._tempA.addScaledVector(this._tempB,o).addScaledVector(this._tempC,h),e.position.copy(this._tempA),this._tempA.copy(this._tempB).cross(this._tempC).normalize(),e.velocity.copy(this._tempA).normalize().multiplyScalar(e.startSpeed)}},{key:"toJSON",value:function toJSON(){return{type:"mesh_surface",mesh:this._geometry?this._geometry.uuid:""}}},{key:"clone",value:function clone(){return new MeshSurfaceEmitter(this._geometry)}},{key:"update",value:function update(e,t){}}],[{key:"fromJSON",value:function fromJSON(e,t){return new MeshSurfaceEmitter(t.geometries[e.geometry])}}])}();loadPlugin({id:"three.quarks",initialize:function initialize(){},emitterShapes:[{type:"mesh_surface",params:[["geometry",["geometry"]]],constructor:he,loadJSON:he.fromJSON}],behaviors:[]});var le=function(e){function BatchedRenderer(){var e;return _classCallCheck(this,BatchedRenderer),_defineProperty(e=_callSuper(this,BatchedRenderer),"batches",[]),_defineProperty(e,"systemToBatchIndex",new Map),_defineProperty(e,"type","BatchedRenderer"),_defineProperty(e,"depthTexture",null),e}return _inherits(BatchedRenderer,e),_createClass(BatchedRenderer,[{key:"addSystem",value:function addSystem(e){e._renderer=this;for(var t,i=e.getRendererSettings(),r=0;r=this.life}reset(){this.memory.length=0,this.position.set(0,0,0),this.velocity.set(0,0,0),this.age=0,this.life=1,this.size.set(1,1,1),this.rotation=0,this.color.set(1,1,1,1),this.uvTile=0}},e.Noise=Noise,e.OrbitOverLife=OrbitOverLife,e.ParticleEmitter=r,e.ParticleMeshPhysicsMaterial=se,e.ParticleMeshStandardMaterial=ne,e.ParticleSystem=ee,e.PiecewiseBezier=PiecewiseBezier,e.PiecewiseFunction=PiecewiseFunction,e.Plugins=Q,e.PointEmitter=PointEmitter,e.QuarksLoader=ue,e.QuarksUtil=de,e.Quaternion=Quaternion,e.RAD2DEG=o,e.RandomColor=RandomColor,e.RandomColorBetweenGradient=RandomColorBetweenGradient,e.RandomQuatGenerator=RandomQuatGenerator,e.RecordState=RecordState,e.RenderMode=H,e.Rotation3DOverLife=Rotation3DOverLife,e.RotationBySpeed=RotationBySpeed,e.RotationGeneratorFromJSON=RotationGeneratorFromJSON,e.RotationOverLife=RotationOverLife,e.SequencerFromJSON=SequencerFromJSON,e.SizeBySpeed=SizeBySpeed,e.SizeOverLife=SizeOverLife,e.SpeedOverLife=SpeedOverLife,e.SphereEmitter=SphereEmitter,e.SpriteBatch=ae,e.SpriteParticle=SpriteParticle,e.TextureSequencer=TextureSequencer,e.TrailBatch=oe,e.TrailParticle=TrailParticle,e.TurbulenceField=TurbulenceField,e.VFXBatch=Y,e.ValueGeneratorFromJSON=ValueGeneratorFromJSON,e.Vector2=Vector2,e.Vector3=Vector3,e.Vector3Function=Vector3Function,e.Vector3GeneratorFromJSON=Vector3GeneratorFromJSON,e.Vector4=Vector4,e.WebGLCoordinateSystem=u,e.WebGPUCoordinateSystem=d,e.WidthOverLength=WidthOverLength,e.ceilPowerOfTwo=ceilPowerOfTwo,e.clamp=clamp,e.damp=damp,e.degToRad=degToRad,e.denormalize=denormalize,e.euclideanModulo=euclideanModulo,e.floorPowerOfTwo=floorPowerOfTwo,e.generateUUID=generateUUID,e.getPhysicsResolver=getPhysicsResolver,e.getValueFromEmitterMode=getValueFromEmitterMode,e.inverseLerp=inverseLerp,e.isPowerOfTwo=isPowerOfTwo,e.lerp=lerp,e.loadPlugin=loadPlugin,e.mapLinear=mapLinear,e.normalize=normalize,e.pingpong=pingpong,e.radToDeg=radToDeg,e.randFloat=randFloat,e.randFloatSpread=randFloatSpread,e.randInt=randInt,e.registerShaderChunks=registerShaderChunks,e.seededRandom=seededRandom,e.setPhysicsResolver=function setPhysicsResolver(e){q=e},e.setQuaternionFromProperEuler=setQuaternionFromProperEuler,e.smootherstep=smootherstep,e.smoothstep=smoothstep,e.unloadPlugin=function unloadPlugin(e){const t=Q.find((t=>t.id===e));if(t){for(const e of t.emitterShapes)N[e.type]&&delete N[e.type];for(const e of t.behaviors)X[e.type]&&delete X[e.type]}}},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("three")):"function"==typeof define&&define.amd?define(["exports","three"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).THREE=e.THREE||{},e.THREE.QUARKS={}),e.THREE)}));