Files
2025-11-30 08:35:03 +02:00

2 lines
178 KiB
JavaScript

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<t;i++)r[i]=e[i];return r}function _callSuper(e,t,i){return t=_getPrototypeOf(t),function _possibleConstructorReturn(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,_isNativeReflectConstruct()?Reflect.construct(t,i||[],_getPrototypeOf(e).constructor):t.apply(e,i))}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,_toPropertyKey(r.key),r)}}function _createClass(e,t,i){return t&&_defineProperties(e.prototype,t),i&&_defineProperties(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}function _createForOfIteratorHelper(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!i){if(Array.isArray(e)||(i=function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?_arrayLikeToArray(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var r=0,F=function(){};return{s:F,n:function(){return r>=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 i<Number.EPSILON?(i=0,Math.abs(e.x)>Math.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)<s&&Math.abs(c-p)<s&&Math.abs(m-f)<s){if(Math.abs(l+u)<a&&Math.abs(c+p)<a&&Math.abs(m+f)<a&&Math.abs(h+d+y-3)<a)return this.set(1,0,0,0),this;t=Math.PI;const e=(h+1)/2,o=(d+1)/2,v=(y+1)/2,g=(l+u)/4,S=(c+p)/4,x=(m+f)/4;return e>o&&e>v?e<s?(i=0,r=.707106781,n=.707106781):(i=Math.sqrt(e),r=g/i,n=S/i):o>v?o<s?(i=.707106781,r=0,n=.707106781):(r=Math.sqrt(o),i=g/r,n=x/r):v<s?(i=.707106781,r=.707106781,n=0):(n=Math.sqrt(v),i=S/n,r=x/n),this.set(i,r,n,t),this}let v=Math.sqrt((f-m)*(f-m)+(c-p)*(c-p)+(u-l)*(u-l));return Math.abs(v)<.001&&(v=1),this.x=(f-m)/v,this.y=(c-p)/v,this.z=(u-l)/v,this.w=Math.acos((h+d+y-1)/2),this}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.w=Math.min(this.w,e.w),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.w=Math.max(this.w,e.w),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.w=Math.max(e.w,Math.min(t.w,this.w)),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.w=Math.max(e,Math.min(t,this.w)),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.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,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)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}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.w+=(e.w-this.w)*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.w=e.w+(t.w-e.w)*i,this}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}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}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Matrix3{constructor(e,t,i,r,n,s,a,o,h){Matrix3.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,i,r,n,s,a,o,h)}set(e,t,i,r,n,s,a,o,h){const l=this.elements;return l[0]=e,l[1]=r,l[2]=a,l[3]=t,l[4]=n,l[5]=o,l[6]=i,l[7]=s,l[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}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],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),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[3],o=i[6],h=i[1],l=i[4],c=i[7],u=i[2],d=i[5],m=i[8],p=r[0],f=r[3],y=r[6],v=r[1],g=r[4],S=r[7],x=r[2],_=r[5],M=r[8];return n[0]=s*p+a*v+o*x,n[3]=s*f+a*g+o*_,n[6]=s*y+a*S+o*M,n[1]=h*p+l*v+c*x,n[4]=h*f+l*g+c*_,n[7]=h*y+l*S+c*M,n[2]=u*p+d*v+m*x,n[5]=u*f+d*g+m*_,n[8]=u*y+d*S+m*M,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){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];return t*s*l-t*a*h-i*n*l+i*a*o+r*n*h-r*s*o}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=l*s-a*h,u=a*o-l*n,d=h*n-s*o,m=t*c+i*u+r*d;if(0===m)return this.set(0,0,0,0,0,0,0,0,0);const p=1/m;return e[0]=c*p,e[1]=(r*h-l*i)*p,e[2]=(a*i-r*s)*p,e[3]=u*p,e[4]=(l*t-r*o)*p,e[5]=(r*n-a*t)*p,e[6]=d*p,e[7]=(i*o-h*t)*p,e[8]=(s*t-i*n)*p,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,n,s,a){const o=Math.cos(n),h=Math.sin(n);return this.set(i*o,i*h,-i*(o*s+h*a)+s+e,-r*h,r*o,-r*(-h*s+o*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(M.makeScale(e,t)),this}rotate(e){return this.premultiply(M.makeRotation(-e)),this}translate(e,t){return this.premultiply(M.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let e=0;e<9;e++)if(t[e]!==i[e])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;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}clone(){return(new Matrix3).fromArray(this.elements)}}const M=new Matrix3;var w;function getValueFromEmitterMode(t,i,r,n){let s;switch(e.EmitterMode.Random===t?i=Math.random():e.EmitterMode.Burst===t&&n.isBursting&&(i=n.burstParticleIndex/n.burstParticleCount),s=r>0?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;t<r;t++){const n=r*(i[t+1]-i[t]);e.push(n)}t.push(e),i=e}return t}getSlope(e){const t=this.derivativeCoefficients(this.p)[0],i=1-e,r=i*e*2,n=e*e;return i*i*t[0]+r*t[1]+n*t[2]}controlCurve(e,t){this.p[1]=e/3+this.p[0],this.p[2]=this.p[3]-t/3}hull(e){let t,i=this.p,r=[],n=0,s=0,a=0;const o=[];for(o[n++]=i[0],o[n++]=i[1],o[n++]=i[2],o[n++]=i[3];i.length>1;){for(r=[],s=0,a=i.length-1;s<a;s++)t=e*i[s]+(1-e)*i[s+1],o[n++]=t,r.push(t);i=r}return o}split(e){const t=this.hull(e);return{left:new Bezier(t[0],t[4],t[7],t[9]),right:new Bezier(t[9],t[8],t[6],t[3]),span:t}}clone(){return new Bezier(this.p[0],this.p[1],this.p[2],this.p[3])}toJSON(){return{p0:this.p[0],p1:this.p[1],p2:this.p[2],p3:this.p[3]}}static fromJSON(e){return new Bezier(e.p0,e.p1,e.p2,e.p3)}}const ColorToJSON=e=>({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+1<r;)if(t=Math.floor((i+r)/2),e<this.getStartX(t))r=t-1;else{if(!(e>this.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[e+1][1]:1}genValue(e,t){const i=this.findKey(t);return"Number"===this.subType?-1===i?this.keys[0][0]:i+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+1<r;)if(t=Math.floor((i+r)/2),e<this.getStartX(t))r=t-1;else{if(!(e>this.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<this.functions.length?this.functions[e+1][1]:1}setEndX(e,t){e+1<this.functions.length&&(this.functions[e+1][1]=t)}insertFunction(e,t){const i=this.findFunction(e);this.functions.splice(i+1,0,[t,e])}removeFunction(e){return this.functions.splice(e,1)[0][0]}getFunction(e){return this.functions[e][0]}setFunction(e,t){this.functions[e][0]=t}get numOfFunctions(){return this.functions.length}}class PiecewiseBezier extends PiecewiseFunction{constructor(e=[[new Bezier(0,1/3,1/3*2,1),0]]){super(),this.type="function",this.functions=e}genValue(e,t=0){const i=this.findFunction(t);return-1===i?0:this.functions[i][0].genValue((t-this.getStartX(i))/(this.getEndX(i)-this.getStartX(i)))}toSVG(e,t){if(t<1)return"";let i=["M",0,this.functions[0][0].p[0]].join(" ");for(let r=1/t;r<=1;r+=1/t)i=[i,"L",r*e,this.genValue(void 0,r)].join(" ");return i}toJSON(){return{type:"PiecewiseBezier",functions:this.functions.map((([e,t])=>({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<e.previous.length;i++)t.next().value.size=this.width.genValue(e.memory,(e.previous.length-i)/e.length)}}frameUpdate(e){}toJSON(){return{type:this.type,width:this.width.toJSON()}}static fromJSON(e){return new WidthOverLength(ValueGeneratorFromJSON(e.width))}clone(){return new WidthOverLength(this.width.clone())}reset(){}}class ApplyForce{constructor(e,t){this.direction=e,this.magnitude=t,this.type="ApplyForce",this.memory={data:[],dataCount:0},this.magnitudeValue=this.magnitude.genValue(this.memory)}initialize(e){}update(e,t){e.velocity.addScaledVector(this.direction,this.magnitudeValue*t)}frameUpdate(e){this.magnitudeValue=this.magnitude.genValue(this.memory)}toJSON(){return{type:this.type,direction:[this.direction.x,this.direction.y,this.direction.z],magnitude:this.magnitude.toJSON()}}static fromJSON(e){var t;return new ApplyForce(new Vector3(e.direction[0],e.direction[1],e.direction[2]),ValueGeneratorFromJSON(null!==(t=e.magnitude)&&void 0!==t?t:e.force))}clone(){return new ApplyForce(this.direction.clone(),this.magnitude.clone())}reset(){}}class GravityForce{constructor(e,t){this.center=e,this.magnitude=t,this.type="GravityForce",this.temp=new Vector3}initialize(e){}update(e,t){this.temp.copy(this.center).sub(e.position).normalize(),e.velocity.addScaledVector(this.temp,this.magnitude/e.position.distanceToSquared(this.center)*t)}frameUpdate(e){}toJSON(){return{type:this.type,center:[this.center.x,this.center.y,this.center.z],magnitude:this.magnitude}}static fromJSON(e){return new GravityForce(new Vector3(e.center[0],e.center[1],e.center[2]),e.magnitude)}clone(){return new GravityForce(this.center.clone(),this.magnitude)}reset(){}}class ChangeEmitDirection{constructor(e){this.angle=e,this.type="ChangeEmitDirection",this._temp=new Vector3,this._q=new Quaternion,this.memory={data:[],dataCount:0}}initialize(e){const t=e.velocity.length();0!=t&&(e.velocity.normalize(),0===e.velocity.x&&0===e.velocity.y?this._temp.set(0,e.velocity.z,0):this._temp.set(-e.velocity.y,e.velocity.x,0),this.angle.startGen(this.memory),this._q.setFromAxisAngle(this._temp.normalize(),this.angle.genValue(this.memory)),this._temp.copy(e.velocity),e.velocity.applyQuaternion(this._q),this._q.setFromAxisAngle(this._temp,Math.random()*Math.PI*2),e.velocity.applyQuaternion(this._q),e.velocity.setLength(t))}update(e,t){}frameUpdate(e){}toJSON(){return{type:this.type,angle:this.angle.toJSON()}}static fromJSON(e){return new ChangeEmitDirection(ValueGeneratorFromJSON(e.angle))}clone(){return new ChangeEmitDirection(this.angle)}reset(){}}var A;e.SubParticleEmitMode=void 0,(A=e.SubParticleEmitMode||(e.SubParticleEmitMode={}))[A.Death=0]="Death",A[A.Birth=1]="Birth",A[A.Frame=2]="Frame";class EmitSubParticleSystem{constructor(t,i,r,n=e.SubParticleEmitMode.Frame,s=1){this.particleSystem=t,this.useVelocityAsBasis=i,this.subParticleSystem=r,this.mode=n,this.emitProbability=s,this.type="EmitSubParticleSystem",this.q_=new Quaternion,this.v_=new Vector3,this.v2_=new Vector3,this.subEmissions=new Array,this.subParticleSystem&&this.subParticleSystem.system&&(this.subParticleSystem.system.onlyUsedByOther=!0)}initialize(e){}update(t,i){(this.mode===e.SubParticleEmitMode.Frame||this.mode===e.SubParticleEmitMode.Birth&&0===t.age||this.mode===e.SubParticleEmitMode.Death&&t.age+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.subEmissions.length;t++)if(this.subEmissions[t].time>=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<i.particle.life?this.setMatrixFromParticle(i.matrix,i.particle):i.particle=void 0,this.subParticleSystem.system.emit(e,i,i.matrix)}}toJSON(){return{type:this.type,subParticleSystem:this.subParticleSystem?this.subParticleSystem.uuid:"",useVelocityAsBasis:this.useVelocityAsBasis,mode:this.mode,emitProbability:this.emitProbability}}static fromJSON(e,t){return new EmitSubParticleSystem(t,e.useVelocityAsBasis,e.subParticleSystem,e.mode,e.emitProbability)}clone(){return new EmitSubParticleSystem(this.particleSystem,this.useVelocityAsBasis,this.subParticleSystem,this.mode,this.emitProbability)}reset(){}setMatrixFromParticle(e,t){let i;if(void 0===t.rotation||this.useVelocityAsBasis)if(0!==t.velocity.x||0!==t.velocity.y||1!==t.velocity.z&&0!==t.velocity.z){this.v_.copy(C).cross(t.velocity),this.v2_.copy(t.velocity).cross(this.v_);const i=this.v_.length(),r=this.v2_.length();e.set(this.v_.x/i,this.v2_.x/r,t.velocity.x,t.position.x,this.v_.y/i,this.v2_.y/r,t.velocity.y,t.position.y,this.v_.z/i,this.v2_.z/r,t.velocity.z,t.position.z,0,0,0,1)}else e.set(1,0,0,t.position.x,0,1,0,t.position.y,0,0,1,t.position.z,0,0,0,1);else t.rotation instanceof Quaternion?i=t.rotation:(this.q_.setFromAxisAngle(C,t.rotation),i=this.q_),e.compose(t.position,i,E);this.particleSystem.worldSpace||e.multiplyMatrices(this.particleSystem.emitter.matrixWorld,e)}}const T=.5*(Math.sqrt(3)-1),B=(3-Math.sqrt(3))/6,V=1/3,U=1/6,R=(Math.sqrt(5)-1)/4,L=(5-Math.sqrt(5))/20,k=new Float32Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]),J=new Float32Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);class SimplexNoise{constructor(e=Math.random){const t="function"==typeof e?e:function alea(e){let t=0,i=0,r=0,n=1;const s=function masher(){let e=4022871197;return function(t){t=t.toString();for(let i=0;i<t.length;i++){e+=t.charCodeAt(i);let r=.02519603282416938*e;e=r>>>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):f<y?(v=0,g=0,S=1,x=0,_=1,M=1):p<y?(v=0,g=1,S=0,x=0,_=1,M=1):(v=0,g=1,S=0,x=1,_=1,M=0);const w=p-v+U,O=f-g+U,b=y-S+U,z=p-x+2*U,P=f-_+2*U,E=y-M+2*U,C=p-1+.5,N=f-1+.5,A=y-1+.5,T=255&c,B=255&u,R=255&d;let L=.6-p*p-f*f-y*y;if(L<0)s=0;else{const e=3*r[T+n[B+n[R]]];L*=L,s=L*L*(k[e]*p+k[e+1]*f+k[e+2]*y)}let J=.6-w*w-O*O-b*b;if(J<0)a=0;else{const e=3*r[T+v+n[B+g+n[R+S]]];J*=J,a=J*J*(k[e]*w+k[e+1]*O+k[e+2]*b)}let I=.6-z*z-P*P-E*E;if(I<0)o=0;else{const e=3*r[T+x+n[B+_+n[R+M]]];I*=I,o=I*I*(k[e]*z+k[e+1]*P+k[e+2]*E)}let D=.6-C*C-N*N-A*A;if(D<0)h=0;else{const e=3*r[T+1+n[B+1+n[R+1]]];D*=D,h=D*D*(k[e]*C+k[e+1]*N+k[e+2]*A)}return 32*(s+a+o+h)}noise4D(e,t,i,r){const n=this.perm;let s,a,o,h,l;const c=(e+t+i+r)*R,u=Math.floor(e+c),d=Math.floor(t+c),m=Math.floor(i+c),p=Math.floor(r+c),f=(u+d+m+p)*L,y=e-(u-f),v=t-(d-f),g=i-(m-f),S=r-(p-f);let x=0,_=0,M=0,w=0;y>v?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;e<this.octaves;e++)this.temp2.set(this.generator.noise4D(i*s,r*s,n*s,this.timeOffset.x*s)/s,this.generator.noise4D(i*s,r*s,n*s,this.timeOffset.y*s)/s,this.generator.noise4D(i*s,r*s,n*s,this.timeOffset.z*s)/s),this.temp.add(this.temp2),s*=2;this.temp.multiply(this.velocityMultiplier),e.velocity.addScaledVector(this.temp,t)}toJSON(){return{type:this.type,scale:[this.scale.x,this.scale.y,this.scale.z],octaves:this.octaves,velocityMultiplier:[this.velocityMultiplier.x,this.velocityMultiplier.y,this.velocityMultiplier.z],timeScale:[this.timeScale.x,this.timeScale.y,this.timeScale.z]}}frameUpdate(e){this.timeOffset.x+=e*this.timeScale.x,this.timeOffset.y+=e*this.timeScale.y,this.timeOffset.z+=e*this.timeScale.z}static fromJSON(e){return new TurbulenceField(new Vector3(e.scale[0],e.scale[1],e.scale[2]),e.octaves,new Vector3(e.velocityMultiplier[0],e.velocityMultiplier[1],e.velocityMultiplier[2]),new Vector3(e.timeScale[0],e.timeScale[1],e.timeScale[2]))}clone(){return new TurbulenceField(this.scale.clone(),this.octaves,this.velocityMultiplier.clone(),this.timeScale.clone())}reset(){}}const I=[],D=new Vector3,G=new Quaternion;class Noise{constructor(e,t,i=new ConstantValue(1),r=new ConstantValue(0)){if(this.frequency=e,this.power=t,this.positionAmount=i,this.rotationAmount=r,this.type="Noise",this.duration=0,0===I.length)for(let e=0;e<100;e++)I.push(new SimplexNoise)}initialize(e){e.lastPosNoise=new Vector3,"number"==typeof e.rotation?e.lastRotNoise=0:e.lastRotNoise=new Quaternion,e.generatorIndex=[randomInt(0,100),randomInt(0,100),randomInt(0,100),randomInt(0,100)],this.positionAmount.startGen(e.memory),this.rotationAmount.startGen(e.memory),this.frequency.startGen(e.memory),this.power.startGen(e.memory)}update(e,t){let i=this.frequency.genValue(e.memory,e.age/e.life),r=this.power.genValue(e.memory,e.age/e.life),n=this.positionAmount.genValue(e.memory,e.age/e.life),s=this.rotationAmount.genValue(e.memory,e.age/e.life);n>0&&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;e<n.height;e++)for(let i=0;i<n.width;i++)n.data[4*(e*n.width+i)+3]>t&&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.length&&this.time>=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<e;a++){for(t.burstParticleIndex=a,this.particleNum++;this.particles.length<this.particleNum;)this.rendererSettings.renderMode===H.Trail?this.particles.push(new TrailParticle):this.particles.push(new SpriteParticle);var o=this.particles[this.particleNum-1];if(o.reset(),o.speedModifier=1,this.startColor.startGen(o.memory),this.startColor.genColor(o.memory,o.startColor,this.emissionState.time),o.color.copy(o.startColor),this.startSpeed.startGen(o.memory),o.startSpeed=this.startSpeed.genValue(o.memory,t.time/this.duration),this.startLife.startGen(o.memory),o.life=this.startLife.genValue(o.memory,t.time/this.duration),o.age=0,this.startSize.startGen(o.memory),"vec3function"===this.startSize.type)this.startSize.genValue(o.memory,o.startSize,t.time/this.duration);else{var h=this.startSize.genValue(o.memory,t.time/this.duration);o.startSize.set(h,h,h)}if(this.startTileIndex.startGen(o.memory),o.uvTile=this.startTileIndex.genValue(o.memory),o.size.copy(o.startSize),this.rendererSettings.renderMode===H.Mesh||this.rendererSettings.renderMode===H.BillBoard||this.rendererSettings.renderMode===H.VerticalBillBoard||this.rendererSettings.renderMode===H.HorizontalBillBoard||this.rendererSettings.renderMode===H.StretchedBillBoard){var l=o;this.startRotation.startGen(o.memory),this.rendererSettings.renderMode===H.Mesh?(l.rotation instanceof Quaternion||(l.rotation=new Quaternion),"rotation"===this.startRotation.type?this.startRotation.genValue(o.memory,l.rotation,1,t.time/this.duration):l.rotation.setFromAxisAngle(j,this.startRotation.genValue(l.memory,t.time/this.duration))):"rotation"===this.startRotation.type?l.rotation=0:l.rotation=this.startRotation.genValue(l.memory,t.time/this.duration)}else if(this.rendererSettings.renderMode===H.Trail){var c=o;this.rendererEmitterSettings.startLength.startGen(c.memory),c.length=this.rendererEmitterSettings.startLength.genValue(c.memory,t.time/this.duration)}if(this.emitterShape.initialize(o,t),this.rendererSettings.renderMode===H.Trail&&this.rendererEmitterSettings.followLocalOrigin){var u=o;u.localPosition=(new Vector3).copy(u.position)}this.worldSpace?(o.position.applyMatrix4(i),o.startSize.multiply(s).abs(),o.size.copy(o.startSize),o.velocity.multiply(s).applyMatrix3(this.normalMatrix),o.rotation&&o.rotation instanceof Quaternion&&o.rotation.multiplyQuaternions(Z,o.rotation)):this.onlyUsedByOther&&(o.parentMatrix=i);for(var d=0;d<this.behaviors.length;d++)this.behaviors[d].initialize(o,this)}}},{key:"endEmit",value:function endEmit(){this.emitEnded=!0,this.autoDestroy&&(this.markForDestroy=!0),this.fire({type:"emitEnd",particleSystem:this})}},{key:"dispose",value:function dispose(){this._renderer&&this._renderer.deleteSystem(this),this.emitter.dispose(),this.emitter.parent&&this.emitter.parent.remove(this.emitter),this.fire({type:"destroy",particleSystem:this})}},{key:"restart",value:function restart(){var e=this;this.memory.length=0,this.paused=!1,this.particleNum=0,this.emissionState.isBursting=!1,this.emissionState.burstIndex=0,this.emissionState.burstWaveIndex=0,this.emissionState.time=0,this.emissionState.waitEmiting=0,this.behaviors.forEach((function(e){e.reset()})),this.emitEnded=!1,this.markForDestroy=!1,this.prewarmed=!1,this.emissionBursts.forEach((function(t){return t.count.startGen(e.memory)})),this.emissionOverDistance.startGen(this.memory)}},{key:"update",value:function update(e){if(!this.paused){for(var t=this.emitter;t.parent;)t=t.parent;if("Scene"===t.type)if(this.firstTimeUpdate&&(this.firstTimeUpdate=!1,this.emitter.updateWorldMatrix(!0,!1)),this.emitEnded&&0===this.particleNum)this.markForDestroy&&this.emitter.parent&&this.dispose();else{if(this.looping&&this.prewarm&&!this.prewarmed){this.prewarmed=!0;for(var i=0;i<60*this.duration;i++)this.update(1/60)}e>.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;r<this.behaviors.length;r++){this.behaviors[r].frameUpdate(e);for(var n=0;n<this.particleNum;n++)this.particles[n].died||this.behaviors[r].update(this.particles[n],e)}for(var s=0;s<this.particleNum;s++)this.rendererEmitterSettings.followLocalOrigin&&this.particles[s].localPosition?(this.particles[s].position.copy(this.particles[s].localPosition),this.particles[s].parentMatrix?this.particles[s].position.applyMatrix4(this.particles[s].parentMatrix):this.particles[s].position.applyMatrix4(this.emitter.matrixWorld)):this.particles[s].position.addScaledVector(this.particles[s].velocity,e*this.particles[s].speedModifier),this.particles[s].age+=e;if(this.rendererSettings.renderMode===H.Trail)for(var a=0;a<this.particleNum;a++)this.particles[a].update();for(var o=0;o<this.particleNum;o++){var h=this.particles[o];!h.died||h instanceof TrailParticle&&0!==h.previous.length||(this.particles[o]=this.particles[this.particleNum-1],this.particles[this.particleNum-1]=h,this.particleNum--,o--,this.fire({type:"particleDied",particleSystem:this,particle:h}))}}else this.dispose()}}},{key:"emit",value:function emit(e,t,i){t.time>this.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.burstIndex<this.emissionBursts.length&&this.emissionBursts[t.burstIndex].time<=t.time;){if(Math.random()<this.emissionBursts[t.burstIndex].probability){var n=this.emissionBursts[t.burstIndex].count.genValue(this.memory,this.time);t.isBursting=!0,t.burstParticleCount=n,this.spawn(n,t,i),t.isBursting=!1}t.burstIndex++}if(!this.emitEnded&&(t.waitEmiting+=e*this.emissionOverTime.genValue(this.memory,t.time/this.duration),null!=t.previousWorldPos)){this.temp.set(i.elements[12],i.elements[13],i.elements[14]),t.travelDistance+=t.previousWorldPos.distanceTo(this.temp);var s=this.emissionOverDistance.genValue(this.memory,t.time/this.duration);if(t.travelDistance*s>0){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 <common>\n#include <color_pars_fragment>\n#include <map_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n#include <alphatest_pars_fragment>\n\n#include <tile_pars_fragment>\n#include <soft_pars_fragment>\n\nvoid main() {\n\n #include <clipping_planes_fragment>\n \n vec3 outgoingLight = vec3( 0.0 );\n vec4 diffuseColor = vColor;\n \n #include <logdepthbuf_fragment>\n \n #include <tile_fragment>\n #include <alphatest_fragment>\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 <soft_fragment>\n #include <tonemapping_fragment>\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 <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nvoid main() {\n\nvec4 diffuseColor = vec4( diffuse, opacity );\n#include <clipping_planes_fragment>\n\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveRadiance = emissive;\n\n#include <logdepthbuf_fragment>\n#include <map_fragment>\n#include <color_fragment>\n#include <alphamap_fragment>\n#include <alphatest_fragment>\n#include <alphahash_fragment>\n#include <roughnessmap_fragment>\n#include <metalnessmap_fragment>\n#include <normal_fragment_begin>\n#include <normal_fragment_maps>\n#include <clearcoat_normal_fragment_begin>\n#include <clearcoat_normal_fragment_maps>\n#include <emissivemap_fragment>\n\n// accumulation\n#include <lights_physical_fragment>\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n\n// modulation\n#include <aomap_fragment>\n\nvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\nvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\n#include <transmission_fragment>\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 <opaque_fragment>\n#include <tonemapping_fragment>\n#include <colorspace_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\n#include <dithering_fragment>\n}",re="\n#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n\nattribute vec3 offset;\nattribute vec4 rotation;\nattribute vec3 size;\n#include <tile_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\nvoid main() {\n\n #include <tile_vertex>\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 <color_vertex>\n#include <morphinstance_vertex>\n#include <morphcolor_vertex>\n#include <batching_vertex>\n\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinbase_vertex>\n#include <skinnormal_vertex>\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 <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\n\t// replace include <project_vertex>\n vec4 mvPosition = vec4( transformed, 1.0 );\n mvPosition = modelViewMatrix * (particleMatrix * mvPosition);\n\tgl_Position = projectionMatrix * mvPosition;\n\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t\n\tvViewPosition = - mvPosition.xyz;\n\t\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\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 <common>\n#include <color_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#include <tile_pars_vertex>\n#include <soft_pars_vertex>\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 <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n #include <tile_vertex>\n #include <soft_vertex>\n}\n",u=te):(c="\n#include <common>\n#include <color_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\n#include <tile_pars_vertex>\n#include <soft_pars_vertex>\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 <logdepthbuf_vertex>\n\n\t#include <clipping_planes_vertex>\n\n\t#include <tile_vertex>\n\t#include <soft_vertex>\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 <common>\n#include <color_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\n#include <tile_pars_vertex>\n#include <soft_pars_vertex>\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 <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <tile_vertex>\n\t#include <soft_vertex>\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;h<n;h++,t++){var l=r[h];if(e.settings.renderMode===H.Mesh){var c=void 0;if(i.worldSpace)c=l.rotation;else{var u=void 0;u=l.parentMatrix?e.quaternion3_.setFromRotationMatrix(l.parentMatrix):s,(c=e.quaternion_).copy(u).multiply(l.rotation)}e.rotationBuffer.setXYZW(t,c.x,c.y,c.z,c.w)}else e.settings.renderMode!==H.StretchedBillBoard&&e.settings.renderMode!==H.VerticalBillBoard&&e.settings.renderMode!==H.HorizontalBillBoard&&e.settings.renderMode!==H.BillBoard||e.rotationBuffer.setX(t,l.rotation);var d=void 0;if(i.worldSpace?d=l.position:(d=e.vector_,l.parentMatrix?d.copy(l.position).applyMatrix4(l.parentMatrix):d.copy(l.position).applyMatrix4(i.emitter.matrixWorld)),e.offsetBuffer.setXYZ(t,d.x,d.y,d.z),e.colorBuffer.setXYZW(t,l.color.x,l.color.y,l.color.z,l.color.w),i.worldSpace||l.parentMatrix?e.sizeBuffer.setXYZ(t,l.size.x,l.size.y,l.size.z):e.sizeBuffer.setXYZ(t,l.size.x*Math.abs(o.x),l.size.y*Math.abs(o.y),l.size.z*Math.abs(o.z)),e.uvTileBuffer.setX(t,l.uvTile),e.settings.renderMode===H.StretchedBillBoard&&e.velocityBuffer){var m=i.rendererEmitterSettings.speedFactor;0===m&&(m=.001);var p=i.rendererEmitterSettings.lengthFactor,f=void 0;i.worldSpace?f=l.velocity:(f=e.vector_,l.parentMatrix?(e.rotationMat2_.setFromMatrix4(l.parentMatrix),f.copy(l.velocity).applyMatrix3(e.rotationMat2_)):f.copy(l.velocity).applyMatrix3(e.rotationMat_)),e.velocityBuffer.setXYZW(t,f.x*m,f.y*m,f.z*m,p)}}})),this.geometry.instanceCount=t,t>0&&(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 <common>\n#include <tile_pars_vertex>\n#include <color_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <fog_pars_vertex>\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 <tile_vertex>\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 <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t\n vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n \n\t#include <fog_vertex>\n}",fragmentShader:"\n\n#include <common>\n#include <tile_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nuniform sampler2D alphaMap;\nuniform float useAlphaMap;\nuniform float visibility;\nuniform float alphaTest;\n\nvarying vec4 vColor;\n \nvoid main() {\n #include <clipping_planes_fragment>\n #include <logdepthbuf_fragment>\n\n vec4 diffuseColor = vColor;\n \n #ifdef USE_MAP\n #include <tile_fragment>\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 <fog_fragment>\n #include <tonemapping_fragment>\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;t<e.particleNum;t++)r+=2*e.particles[t].previous.length})),r>this.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;m<h;m++){var p=o[m],f=p.uvTile%c,y=Math.floor(p.uvTile/c+.001),v=p.previous.values(),g=v.next(),S=g.value,x=S;g.done||(g=v.next());var _=void 0;_=void 0!==g.value?g.value:x;for(var M=0;M<p.previous.length;M++,t+=2){if(e.positionBuffer.setXYZ(t,x.position.x,x.position.y,x.position.z),e.positionBuffer.setXYZ(t+1,x.position.x,x.position.y,x.position.z),r.worldSpace?(e.positionBuffer.setXYZ(t,x.position.x,x.position.y,x.position.z),e.positionBuffer.setXYZ(t+1,x.position.x,x.position.y,x.position.z)):(p.parentMatrix?e.vector_.copy(x.position).applyMatrix4(p.parentMatrix):e.vector_.copy(x.position).applyMatrix4(r.emitter.matrixWorld),e.positionBuffer.setXYZ(t,e.vector_.x,e.vector_.y,e.vector_.z),e.positionBuffer.setXYZ(t+1,e.vector_.x,e.vector_.y,e.vector_.z)),r.worldSpace?(e.previousBuffer.setXYZ(t,S.position.x,S.position.y,S.position.z),e.previousBuffer.setXYZ(t+1,S.position.x,S.position.y,S.position.z)):(p.parentMatrix?e.vector_.copy(S.position).applyMatrix4(p.parentMatrix):e.vector_.copy(S.position).applyMatrix4(r.emitter.matrixWorld),e.previousBuffer.setXYZ(t,e.vector_.x,e.vector_.y,e.vector_.z),e.previousBuffer.setXYZ(t+1,e.vector_.x,e.vector_.y,e.vector_.z)),r.worldSpace?(e.nextBuffer.setXYZ(t,_.position.x,_.position.y,_.position.z),e.nextBuffer.setXYZ(t+1,_.position.x,_.position.y,_.position.z)):(p.parentMatrix?e.vector_.copy(_.position).applyMatrix4(p.parentMatrix):e.vector_.copy(_.position).applyMatrix4(r.emitter.matrixWorld),e.nextBuffer.setXYZ(t,e.vector_.x,e.vector_.y,e.vector_.z),e.nextBuffer.setXYZ(t+1,e.vector_.x,e.vector_.y,e.vector_.z)),e.sideBuffer.setX(t,-1),e.sideBuffer.setX(t+1,1),r.worldSpace)e.widthBuffer.setX(t,x.size),e.widthBuffer.setX(t+1,x.size);else if(p.parentMatrix)e.widthBuffer.setX(t,x.size),e.widthBuffer.setX(t+1,x.size);else{var w=(Math.abs(a.x)+Math.abs(a.y)+Math.abs(a.z))/3;e.widthBuffer.setX(t,x.size*w),e.widthBuffer.setX(t+1,x.size*w)}e.uvBuffer.setXY(t,(M/p.previous.length+f)*u,(c-y-1)*d),e.uvBuffer.setXY(t+1,(M/p.previous.length+f)*u,(c-y)*d),e.colorBuffer.setXYZW(t,x.color.x,x.color.y,x.color.z,x.color.w),e.colorBuffer.setXYZW(t+1,x.color.x,x.color.y,x.color.z,x.color.w),M+1<p.previous.length&&(e.indexBuffer.setX(3*i,t),e.indexBuffer.setX(3*i+1,t+1),e.indexBuffer.setX(3*i+2,t+2),i++,e.indexBuffer.setX(3*i,t+2),e.indexBuffer.setX(3*i+1,t+1),e.indexBuffer.setX(3*i+2,t+3),i++),S=x,x=_,g.done||void 0!==(g=v.next()).value&&(_=g.value)}}})),this.positionBuffer.clearUpdateRanges(),this.positionBuffer.addUpdateRange(0,3*t),this.positionBuffer.needsUpdate=!0,this.previousBuffer.clearUpdateRanges(),this.previousBuffer.addUpdateRange(0,3*t),this.previousBuffer.needsUpdate=!0,this.nextBuffer.clearUpdateRanges(),this.nextBuffer.addUpdateRange(0,3*t),this.nextBuffer.needsUpdate=!0,this.sideBuffer.clearUpdateRanges(),this.sideBuffer.addUpdateRange(0,t),this.sideBuffer.needsUpdate=!0,this.widthBuffer.clearUpdateRanges(),this.widthBuffer.addUpdateRange(0,t),this.widthBuffer.needsUpdate=!0,this.uvBuffer.clearUpdateRanges(),this.uvBuffer.addUpdateRange(0,2*t),this.uvBuffer.needsUpdate=!0,this.colorBuffer.clearUpdateRanges(),this.colorBuffer.addUpdateRange(0,4*t),this.colorBuffer.needsUpdate=!0,this.indexBuffer.clearUpdateRanges(),this.indexBuffer.addUpdateRange(0,3*i),this.indexBuffer.needsUpdate=!0,this.geometry.setDrawRange(0,3*i)}},{key:"dispose",value:function dispose(){this.geometry.dispose()}}])}(Y),he=function(){function MeshSurfaceEmitter(e){_classCallCheck(this,MeshSurfaceEmitter),_defineProperty(this,"type","mesh_surface"),_defineProperty(this,"_triangleIndexToArea",[]),_defineProperty(this,"_geometry",void 0),_defineProperty(this,"_tempA",new t.Vector3),_defineProperty(this,"_tempB",new t.Vector3),_defineProperty(this,"_tempC",new t.Vector3),e&&(this.geometry=e)}return _createClass(MeshSurfaceEmitter,[{key:"geometry",get:function get(){return this._geometry},set:function set(e){if(this._geometry=e,void 0!==e&&"string"!=typeof e){var i=new t.Triangle;this._triangleIndexToArea.length=0;var r=0;if(e.getIndex()){var n=e.getIndex().array,s=n.length/3;this._triangleIndexToArea.push(0);for(var a=0;a<s;a++)i.setFromAttributeAndIndices(e.getAttribute("position"),n[3*a],n[3*a+1],n[3*a+2]),r+=i.getArea(),this._triangleIndexToArea.push(r);e.userData.triangleIndexToArea=this._triangleIndexToArea}}}},{key:"initialize",value:function initialize(e){var t=this._geometry;if(!t||null===t.getIndex())return e.position.set(0,0,0),void e.velocity.set(0,0,1).multiplyScalar(e.startSpeed);for(var i=this._triangleIndexToArea.length-1,r=0,n=i,s=Math.random()*this._triangleIndexToArea[i];r+1<n;){var a=Math.floor((r+n)/2);s<this._triangleIndexToArea[a]?n=a:r=a}var o=Math.random(),h=Math.random();o+h>1&&(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.batches.length;r++)if(BatchedRenderer.equals(this.batches[r].settings,i))return this.batches[r].addSystem(e),void this.systemToBatchIndex.set(e,r);switch(i.renderMode){case H.Trail:t=new oe(i);break;case H.Mesh:case H.BillBoard:case H.VerticalBillBoard:case H.HorizontalBillBoard:case H.StretchedBillBoard:t=new ae(i)}this.depthTexture&&t.applyDepthTexture(this.depthTexture),t.addSystem(e),this.batches.push(t),this.systemToBatchIndex.set(e,this.batches.length-1),this.add(t)}},{key:"deleteSystem",value:function deleteSystem(e){var t=this.systemToBatchIndex.get(e);null!=t&&(this.batches[t].removeSystem(e),this.systemToBatchIndex.delete(e))}},{key:"setDepthTexture",value:function setDepthTexture(e){this.depthTexture=e;var t,i=_createForOfIteratorHelper(this.batches);try{for(i.s();!(t=i.n()).done;)t.value.applyDepthTexture(e)}catch(e){i.e(e)}finally{i.f()}}},{key:"updateSystem",value:function updateSystem(e){this.deleteSystem(e),this.addSystem(e)}},{key:"update",value:function update(e){this.systemToBatchIndex.forEach((function(t,i){i.update(e)}));for(var t=0;t<this.batches.length;t++)this.batches[t].update()}}],[{key:"equals",value:function equals(e,t){return e.material.side===t.material.side&&e.material.blending===t.material.blending&&e.material.blendSrc===t.material.blendSrc&&e.material.blendDst===t.material.blendDst&&e.material.blendEquation===t.material.blendEquation&&e.material.premultipliedAlpha===t.material.premultipliedAlpha&&e.material.transparent===t.material.transparent&&e.material.depthTest===t.material.depthTest&&e.material.type===t.material.type&&e.material.alphaTest===t.material.alphaTest&&e.material.map===t.material.map&&e.renderMode===t.renderMode&&e.blendTiles===t.blendTiles&&e.softParticles===t.softParticles&&e.softFarFade===t.softFarFade&&e.softNearFade===t.softNearFade&&e.uTileCount===t.uTileCount&&e.vTileCount===t.vTileCount&&e.instancingGeometry===t.instancingGeometry&&e.renderOrder===t.renderOrder&&e.layers.mask===t.layers.mask}}])}(t.Object3D),ce=le,ue=function(e){function QuarksLoader(e){return _classCallCheck(this,QuarksLoader),_callSuper(this,QuarksLoader,[e])}return _inherits(QuarksLoader,e),_createClass(QuarksLoader,[{key:"linkReference",value:function linkReference(e){var t={};e.traverse((function(e){t[e.uuid]=e})),e.traverse((function(e){if("ParticleEmitter"===e.type){var i=e.system;i.emitterShape;for(var r=0;r<i.behaviors.length;r++)i.behaviors[r]instanceof EmitSubParticleSystem&&(i.behaviors[r].subParticleSystem=t[i.behaviors[r].subParticleSystem])}}))}},{key:"parse",value:function parse(e,t){var i=_get(_getPrototypeOf(QuarksLoader.prototype),"parse",this).call(this,e,t);return this.linkReference(i),i}},{key:"parseObject",value:function parseObject(e,i,r,n,s){var a,o,h;function getGeometry(e){return void 0===i[e]&&console.warn("THREE.ObjectLoader: Undefined geometry",e),i[e]}function getMaterial(e){if(void 0!==e){if(Array.isArray(e)){for(var t=[],i=0,n=e.length;i<n;i++){var s=e[i];void 0===r[s]&&console.warn("THREE.ObjectLoader: Undefined material",s),t.push(r[s])}return t}return void 0===r[e]&&console.warn("THREE.ObjectLoader: Undefined material",e),r[e]}}function getTexture(e){return void 0===n[e]&&console.warn("THREE.ObjectLoader: Undefined texture",e),n[e]}var l={textures:n,geometries:i,materials:r};switch(e.type){case"ParticleEmitter":a=ee.fromJSON(e.ps,l,{}).emitter;break;case"Scene":a=new t.Scene,void 0!==e.background&&(Number.isInteger(e.background)?a.background=new t.Color(e.background):a.background=getTexture(e.background)),void 0!==e.environment&&(a.environment=getTexture(e.environment)),void 0!==e.fog&&("Fog"===e.fog.type?a.fog=new t.Fog(e.fog.color,e.fog.near,e.fog.far):"FogExp2"===e.fog.type&&(a.fog=new t.FogExp2(e.fog.color,e.fog.density)),""!==e.fog.name&&(a.fog.name=e.fog.name)),void 0!==e.backgroundBlurriness&&(a.backgroundBlurriness=e.backgroundBlurriness),void 0!==e.backgroundIntensity&&(a.backgroundIntensity=e.backgroundIntensity),void 0!==e.backgroundRotation&&a.backgroundRotation.fromArray(e.backgroundRotation),void 0!==e.environmentIntensity&&(a.environmentIntensity=e.environmentIntensity),void 0!==e.environmentRotation&&a.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":a=new t.PerspectiveCamera(e.fov,e.aspect,e.near,e.far),void 0!==e.focus&&(a.focus=e.focus),void 0!==e.zoom&&(a.zoom=e.zoom),void 0!==e.filmGauge&&(a.filmGauge=e.filmGauge),void 0!==e.filmOffset&&(a.filmOffset=e.filmOffset),void 0!==e.view&&(a.view=Object.assign({},e.view));break;case"OrthographicCamera":a=new t.OrthographicCamera(e.left,e.right,e.top,e.bottom,e.near,e.far),void 0!==e.zoom&&(a.zoom=e.zoom),void 0!==e.view&&(a.view=Object.assign({},e.view));break;case"AmbientLight":a=new t.AmbientLight(e.color,e.intensity);break;case"DirectionalLight":a=new t.DirectionalLight(e.color,e.intensity);break;case"PointLight":a=new t.PointLight(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new t.RectAreaLight(e.color,e.intensity,e.width,e.height);break;case"SpotLight":a=new t.SpotLight(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":a=new t.HemisphereLight(e.color,e.groundColor,e.intensity);break;case"LightProbe":a=(new t.LightProbe).fromJSON(e);break;case"SkinnedMesh":o=getGeometry(e.geometry),h=getMaterial(e.material),a=new t.SkinnedMesh(o,h),void 0!==e.bindMode&&(a.bindMode=e.bindMode),void 0!==e.bindMatrix&&a.bindMatrix.fromArray(e.bindMatrix),void 0!==e.skeleton&&(a.skeleton=e.skeleton);break;case"Mesh":o=getGeometry(e.geometry),h=getMaterial(e.material),a=new t.Mesh(o,h);break;case"InstancedMesh":o=getGeometry(e.geometry),h=getMaterial(e.material);var c=e.count,u=e.instanceMatrix,d=e.instanceColor;(a=new t.InstancedMesh(o,h,c)).instanceMatrix=new t.InstancedBufferAttribute(new Float32Array(u.array),16),void 0!==d&&(a.instanceColor=new t.InstancedBufferAttribute(new Float32Array(d.array),d.itemSize));break;case"BatchedMesh":o=getGeometry(e.geometry),h=getMaterial(e.material),(a=new t.BatchedMesh(e.maxGeometryCount,e.maxVertexCount,e.maxIndexCount,h)).geometry=o,a.perObjectFrustumCulled=e.perObjectFrustumCulled,a.sortObjects=e.sortObjects,a._drawRanges=e.drawRanges,a._reservedRanges=e.reservedRanges,a._visibility=e.visibility,a._active=e.active,a._bounds=e.bounds.map((function(e){var i=new t.Box3;i.min.fromArray(e.boxMin),i.max.fromArray(e.boxMax);var r=new t.Sphere;return r.radius=e.sphereRadius,r.center.fromArray(e.sphereCenter),{boxInitialized:e.boxInitialized,box:i,sphereInitialized:e.sphereInitialized,sphere:r}})),a._maxGeometryCount=e.maxGeometryCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._geometryCount=e.geometryCount,a._matricesTexture=getTexture(e.matricesTexture.uuid);break;case"LOD":a=new t.LOD;break;case"Line":a=new t.Line(getGeometry(e.geometry),getMaterial(e.material));break;case"LineLoop":a=new t.LineLoop(getGeometry(e.geometry),getMaterial(e.material));break;case"LineSegments":a=new t.LineSegments(getGeometry(e.geometry),getMaterial(e.material));break;case"PointCloud":case"Points":a=new t.Points(getGeometry(e.geometry),getMaterial(e.material));break;case"Sprite":a=new t.Sprite(getMaterial(e.material));break;case"Group":a=new t.Group;break;case"Bone":a=new t.Bone;break;default:a=new t.Object3D}if(a.uuid=e.uuid,void 0!==e.name&&(a.name=e.name),void 0!==e.matrix?(a.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&(a.matrix.decompose(a.position,a.quaternion,a.scale),isNaN(a.quaternion.x)&&a.quaternion.set(0,0,0,1))):(void 0!==e.position&&a.position.fromArray(e.position),void 0!==e.rotation&&a.rotation.fromArray(e.rotation),void 0!==e.quaternion&&a.quaternion.fromArray(e.quaternion),void 0!==e.scale&&a.scale.fromArray(e.scale)),void 0!==e.up&&a.up.fromArray(e.up),void 0!==e.castShadow&&(a.castShadow=e.castShadow),void 0!==e.receiveShadow&&(a.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(a.shadow.bias=e.shadow.bias),void 0!==e.shadow.normalBias&&(a.normalBias=e.shadow.normalBias),void 0!==e.shadow.radius&&(a.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&a.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(a.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(a.visible=e.visible),void 0!==e.frustumCulled&&(a.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(a.renderOrder=e.renderOrder),void 0!==e.userData&&(a.userData=e.userData),void 0!==e.layers&&(a.layers.mask=e.layers),void 0!==e.children)for(var m=e.children,p=0;p<m.length;p++)a.add(this.parseObject(m[p],i,r,n,s));if(void 0!==e.animations)for(var f=e.animations,y=0;y<f.length;y++){var v=f[y];a.animations.push(s[v])}if("LOD"===e.type){void 0!==e.autoUpdate&&(a.autoUpdate=e.autoUpdate);for(var g=e.levels,S=0;S<g.length;S++){var x=g[S],_=a.getObjectByProperty("uuid",x.object);void 0!==_&&a.addLevel(_,x.distance)}}return a}}])}(t.ObjectLoader),de=function(){function QuarksUtil(){_classCallCheck(this,QuarksUtil)}return _createClass(QuarksUtil,null,[{key:"runOnAllParticleEmitters",value:function runOnAllParticleEmitters(e,t){e.traverse((function(e){"ParticleEmitter"===e.type&&t(e)})),"ParticleEmitter"===e.type&&t(e)}},{key:"addToBatchRenderer",value:function addToBatchRenderer(e,t){QuarksUtil.runOnAllParticleEmitters(e,(function(e){t.addSystem(e.system)}))}},{key:"play",value:function play(e){QuarksUtil.runOnAllParticleEmitters(e,(function(e){e.system.play()}))}},{key:"stop",value:function stop(e){QuarksUtil.runOnAllParticleEmitters(e,(function(e){e.system.stop()}))}},{key:"setAutoDestroy",value:function setAutoDestroy(e,t){QuarksUtil.runOnAllParticleEmitters(e,(function(e){e.system.autoDestroy=t}))}},{key:"endEmit",value:function endEmit(e){QuarksUtil.runOnAllParticleEmitters(e,(function(e){e.system.endEmit()}))}},{key:"restart",value:function restart(e){QuarksUtil.runOnAllParticleEmitters(e,(function(e){e.system.restart()}))}},{key:"pause",value:function pause(e){QuarksUtil.runOnAllParticleEmitters(e,(function(e){e.system.pause()}))}}])}();registerShaderChunks(),console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 14px; font-weight: bold;"),e.ApplyCollision=ApplyCollision,e.ApplyForce=ApplyForce,e.ApplySequences=ApplySequences,e.AxisAngleGenerator=AxisAngleGenerator,e.BatchedParticleRenderer=ce,e.BatchedRenderer=le,e.BehaviorFromJSON=BehaviorFromJSON,e.BehaviorTypes=X,e.Bezier=Bezier,e.ChangeEmitDirection=ChangeEmitDirection,e.CircleEmitter=CircleEmitter,e.ColorBySpeed=ColorBySpeed,e.ColorGeneratorFromJSON=ColorGeneratorFromJSON,e.ColorOverLife=ColorOverLife,e.ColorRange=ColorRange,e.ConeEmitter=ConeEmitter,e.ConstantColor=ConstantColor,e.ConstantValue=ConstantValue,e.DEG2RAD=a,e.DonutEmitter=DonutEmitter,e.EmitSubParticleSystem=EmitSubParticleSystem,e.EmitterFromJSON=EmitterFromJSON,e.EmitterShapes=N,e.Euler=Euler,e.EulerGenerator=EulerGenerator,e.ForceOverLife=ForceOverLife,e.FrameOverLife=FrameOverLife,e.GeneratorFromJSON=GeneratorFromJSON,e.Gradient=Gradient,e.GravityForce=GravityForce,e.GridEmitter=GridEmitter,e.HemisphereEmitter=HemisphereEmitter,e.IntervalValue=IntervalValue,e.LimitSpeedOverLife=LimitSpeedOverLife,e.MathUtils=h,e.Matrix3=Matrix3,e.Matrix4=Matrix4,e.MeshSurfaceEmitter=he,e.NodeParticle=class NodeParticle{constructor(){this.position=new Vector3,this.velocity=new Vector3,this.age=0,this.life=1,this.size=new Vector3,this.rotation=0,this.color=new Vector4(1,1,1,1),this.uvTile=0,this.memory=[]}get died(){return this.age>=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);