diff --git a/.gitignore b/.gitignore index 84414fa..092264d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /node_modules NOTES.md -/tests \ No newline at end of file +/tests +/docs +notes.txt \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index 1fee25c..1e6eb8c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -2,8 +2,10 @@ module.exports = function( grunt ) { 'use strict'; var packageJSON = grunt.file.readJSON( 'package.json' ); + var addHeader = 'import * as THREE from "three";'; var licenseBanner = + addHeader + '\n' + '\n' + '/* ' + packageJSON.name + ' ' + packageJSON.version + '\n' + ' * ' + '\n' + ' * (c) 2015 Luke Moody (http://www.github.com/squarefeet)' + '\n' + @@ -37,7 +39,7 @@ module.exports = function( grunt ) { }, banner: licenseBanner, report: 'min', - maxLineLen: 1000, + maxLineLen: 1000 }, files: {} } @@ -54,6 +56,7 @@ module.exports = function( grunt ) { options: { separator: '\n\n', banner: licenseBanner, + footer: 'export default SPE;' }, dist: { src: files, @@ -61,31 +64,10 @@ module.exports = function( grunt ) { }, }, - jsdoc: { - dist: { - src: 'src/**/*.js', - options: { - destination: 'docs/api' - } - } - }, - - docco: { - options: { - dst: 'docs/source/', - layout: 'parallel' - }, - docs: { - src: 'build/SPE.js' - } - } } ); grunt.loadNpmTasks( 'grunt-contrib-concat' ); grunt.loadNpmTasks( 'grunt-contrib-uglify' ); - grunt.loadNpmTasks( 'grunt-jsdoc' ); - grunt.loadNpmTasks( 'grunt-docco2' ); grunt.registerTask( 'default', [ 'concat', 'uglify' ] ); - grunt.registerTask( 'docs', [ 'jsdoc', 'docco' ] ); }; \ No newline at end of file diff --git a/build/SPE.js b/build/SPE.js index f8f2169..83145f9 100644 --- a/build/SPE.js +++ b/build/SPE.js @@ -1,4 +1,6 @@ -/* shader-particle-engine 1.0.6 +import * as THREE from "three"; + +/* shader-particle-engine 1.1.0 * * (c) 2015 Luke Moody (http://www.github.com/squarefeet) * Originally based on Lee Stemkoski's original work (https://github.com/stemkoski/stemkoski.github.com/blob/master/Three.js/js/ParticleEngine.js). @@ -110,13 +112,13 @@ else if ( typeof exports !== 'undefined' && typeof module !== 'undefined' ) { * @param {Number} componentSize The number of components per-value (ie. 3 for a vec3, 9 for a Mat3, etc.) * @param {Number} indexOffset The index in the array from which to start assigning values. Default `0` if none provided */ -SPE.TypedArrayHelper = function( TypedArrayConstructor, size, componentSize, indexOffset ) { - 'use strict'; +SPE.TypedArrayHelper = function (TypedArrayConstructor, size, componentSize, indexOffset) { + "use strict"; this.componentSize = componentSize || 1; - this.size = ( size || 1 ); + this.size = size || 1; this.TypedArrayConstructor = TypedArrayConstructor || Float32Array; - this.array = new TypedArrayConstructor( size * this.componentSize ); + this.array = new TypedArrayConstructor(size * this.componentSize); this.indexOffset = indexOffset || 0; }; @@ -132,23 +134,21 @@ SPE.TypedArrayHelper.constructor = SPE.TypedArrayHelper; * * @param {Number} size The new size of the array. */ -SPE.TypedArrayHelper.prototype.setSize = function( size, noComponentMultiply ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.setSize = function (size, noComponentMultiply) { + "use strict"; - var currentArraySize = this.array.length; + let currentArraySize = this.array.length; - if ( !noComponentMultiply ) { + if (!noComponentMultiply) { size = size * this.componentSize; } - if ( size < currentArraySize ) { - return this.shrink( size ); - } - else if ( size > currentArraySize ) { - return this.grow( size ); - } - else { - console.info( 'TypedArray is already of size:', size + '.', 'Will not resize.' ); + if (size < currentArraySize) { + return this.shrink(size); + } else if (size > currentArraySize) { + return this.grow(size); + } else { + console.info("TypedArray is already of size:", size + ".", "Will not resize."); } }; @@ -158,10 +158,10 @@ SPE.TypedArrayHelper.prototype.setSize = function( size, noComponentMultiply ) { * @param {Number} size The new size of the typed array. Must be smaller than `this.array.length`. * @return {SPE.TypedArrayHelper} Instance of this class. */ -SPE.TypedArrayHelper.prototype.shrink = function( size ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.shrink = function (size) { + "use strict"; - this.array = this.array.subarray( 0, size ); + this.array = this.array.subarray(0, size); this.size = size; return this; }; @@ -171,48 +171,46 @@ SPE.TypedArrayHelper.prototype.shrink = function( size ) { * @param {Number} size The new size of the typed array. Must be larger than `this.array.length`. * @return {SPE.TypedArrayHelper} Instance of this class. */ -SPE.TypedArrayHelper.prototype.grow = function( size ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.grow = function (size) { + "use strict"; - var existingArray = this.array, - newArray = new this.TypedArrayConstructor( size ); + let existingArray = this.array; + let newArray = new this.TypedArrayConstructor(size); - newArray.set( existingArray ); + newArray.set(existingArray); this.array = newArray; this.size = size; return this; }; - /** * Perform a splice operation on this array's buffer. * @param {Number} start The start index of the splice. Will be multiplied by the number of components for this attribute. * @param {Number} end The end index of the splice. Will be multiplied by the number of components for this attribute. * @returns {Object} The SPE.TypedArrayHelper instance. */ -SPE.TypedArrayHelper.prototype.splice = function( start, end ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.splice = function (start, end) { + "use strict"; start *= this.componentSize; end *= this.componentSize; - var data = [], - array = this.array, - size = array.length; + let data = []; + let array = this.array; + let size = array.length; - for ( var i = 0; i < size; ++i ) { - if ( i < start || i >= end ) { - data.push( array[ i ] ); + for (let i = 0; i < size; ++i) { + if (i < start || i >= end) { + data.push(array[i]); } // array[ i ] = 0; } - this.setFromArray( 0, data ); + this.setFromArray(0, data); return this; }; - /** * Copies from the given TypedArray into this one, using the index argument * as the start position. Alias for `TypedArray.set`. Will automatically resize @@ -222,20 +220,19 @@ SPE.TypedArrayHelper.prototype.splice = function( start, end ) { * @param {TypedArray} array The array from which to copy; the source array. * @return {SPE.TypedArrayHelper} Instance of this class. */ -SPE.TypedArrayHelper.prototype.setFromArray = function( index, array ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.setFromArray = function (index, array) { + "use strict"; - var sourceArraySize = array.length, + let sourceArraySize = array.length, newSize = index + sourceArraySize; - if ( newSize > this.array.length ) { - this.grow( newSize ); - } - else if ( newSize < this.array.length ) { - this.shrink( newSize ); + if (newSize > this.array.length) { + this.grow(newSize); + } else if (newSize < this.array.length) { + this.shrink(newSize); } - this.array.set( array, this.indexOffset + index ); + this.array.set(array, this.indexOffset + index); return this; }; @@ -247,10 +244,10 @@ SPE.TypedArrayHelper.prototype.setFromArray = function( index, array ) { * @param {Vector2} vec2 Any object that has `x` and `y` properties. * @return {SPE.TypedArrayHelper} Instance of this class. */ -SPE.TypedArrayHelper.prototype.setVec2 = function( index, vec2 ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.setVec2 = function (index, vec2) { + "use strict"; - return this.setVec2Components( index, vec2.x, vec2.y ); + return this.setVec2Components(index, vec2.x, vec2.y); }; /** @@ -261,14 +258,14 @@ SPE.TypedArrayHelper.prototype.setVec2 = function( index, vec2 ) { * @param {Number} y The Vec2's `y` component. * @return {SPE.TypedArrayHelper} Instance of this class. */ -SPE.TypedArrayHelper.prototype.setVec2Components = function( index, x, y ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.setVec2Components = function (index, x, y) { + "use strict"; - var array = this.array, - i = this.indexOffset + ( index * this.componentSize ); + let array = this.array; + let i = this.indexOffset + index * this.componentSize; - array[ i ] = x; - array[ i + 1 ] = y; + array[i] = x; + array[i + 1] = y; return this; }; @@ -279,10 +276,10 @@ SPE.TypedArrayHelper.prototype.setVec2Components = function( index, x, y ) { * @param {Vector3} vec2 Any object that has `x`, `y`, and `z` properties. * @return {SPE.TypedArrayHelper} Instance of this class. */ -SPE.TypedArrayHelper.prototype.setVec3 = function( index, vec3 ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.setVec3 = function (index, vec3) { + "use strict"; - return this.setVec3Components( index, vec3.x, vec3.y, vec3.z ); + return this.setVec3Components(index, vec3.x, vec3.y, vec3.z); }; /** @@ -294,15 +291,15 @@ SPE.TypedArrayHelper.prototype.setVec3 = function( index, vec3 ) { * @param {Number} z The Vec3's `z` component. * @return {SPE.TypedArrayHelper} Instance of this class. */ -SPE.TypedArrayHelper.prototype.setVec3Components = function( index, x, y, z ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.setVec3Components = function (index, x, y, z) { + "use strict"; - var array = this.array, - i = this.indexOffset + ( index * this.componentSize ); + let array = this.array; + let i = this.indexOffset + index * this.componentSize; - array[ i ] = x; - array[ i + 1 ] = y; - array[ i + 2 ] = z; + array[i] = x; + array[i + 1] = y; + array[i + 2] = z; return this; }; @@ -313,10 +310,10 @@ SPE.TypedArrayHelper.prototype.setVec3Components = function( index, x, y, z ) { * @param {Vector4} vec2 Any object that has `x`, `y`, `z`, and `w` properties. * @return {SPE.TypedArrayHelper} Instance of this class. */ -SPE.TypedArrayHelper.prototype.setVec4 = function( index, vec4 ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.setVec4 = function (index, vec4) { + "use strict"; - return this.setVec4Components( index, vec4.x, vec4.y, vec4.z, vec4.w ); + return this.setVec4Components(index, vec4.x, vec4.y, vec4.z, vec4.w); }; /** @@ -329,16 +326,16 @@ SPE.TypedArrayHelper.prototype.setVec4 = function( index, vec4 ) { * @param {Number} w The Vec4's `w` component. * @return {SPE.TypedArrayHelper} Instance of this class. */ -SPE.TypedArrayHelper.prototype.setVec4Components = function( index, x, y, z, w ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.setVec4Components = function (index, x, y, z, w) { + "use strict"; - var array = this.array, - i = this.indexOffset + ( index * this.componentSize ); + let array = this.array; + let i = this.indexOffset + index * this.componentSize; - array[ i ] = x; - array[ i + 1 ] = y; - array[ i + 2 ] = z; - array[ i + 3 ] = w; + array[i] = x; + array[i + 1] = y; + array[i + 2] = z; + array[i + 3] = w; return this; }; @@ -349,10 +346,10 @@ SPE.TypedArrayHelper.prototype.setVec4Components = function( index, x, y, z, w ) * @param {Matrix3} mat3 The 3x3 matrix to set from. Must have a TypedArray property named `elements` to copy from. * @return {SPE.TypedArrayHelper} Instance of this class. */ -SPE.TypedArrayHelper.prototype.setMat3 = function( index, mat3 ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.setMat3 = function (index, mat3) { + "use strict"; - return this.setFromArray( this.indexOffset + ( index * this.componentSize ), mat3.elements ); + return this.setFromArray(this.indexOffset + index * this.componentSize, mat3.elements); }; /** @@ -362,10 +359,10 @@ SPE.TypedArrayHelper.prototype.setMat3 = function( index, mat3 ) { * @param {Matrix4} mat3 The 4x4 matrix to set from. Must have a TypedArray property named `elements` to copy from. * @return {SPE.TypedArrayHelper} Instance of this class. */ -SPE.TypedArrayHelper.prototype.setMat4 = function( index, mat4 ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.setMat4 = function (index, mat4) { + "use strict"; - return this.setFromArray( this.indexOffset + ( index * this.componentSize ), mat4.elements ); + return this.setFromArray(this.indexOffset + index * this.componentSize, mat4.elements); }; /** @@ -375,10 +372,10 @@ SPE.TypedArrayHelper.prototype.setMat4 = function( index, mat4 ) { * @param {Color} color Any object that has `r`, `g`, and `b` properties. * @return {SPE.TypedArrayHelper} Instance of this class. */ -SPE.TypedArrayHelper.prototype.setColor = function( index, color ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.setColor = function (index, color) { + "use strict"; - return this.setVec3Components( index, color.r, color.g, color.b ); + return this.setVec3Components(index, color.r, color.g, color.b); }; /** @@ -388,10 +385,10 @@ SPE.TypedArrayHelper.prototype.setColor = function( index, color ) { * @param {Number} numericValue The number to assign to this index in the array. * @return {SPE.TypedArrayHelper} Instance of this class. */ -SPE.TypedArrayHelper.prototype.setNumber = function( index, numericValue ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.setNumber = function (index, numericValue) { + "use strict"; - this.array[ this.indexOffset + ( index * this.componentSize ) ] = numericValue; + this.array[this.indexOffset + index * this.componentSize] = numericValue; return this; }; @@ -405,10 +402,10 @@ SPE.TypedArrayHelper.prototype.setNumber = function( index, numericValue ) { * @param {Number} index The index in the array to fetch. * @return {Number} The value at the given index. */ -SPE.TypedArrayHelper.prototype.getValueAtIndex = function( index ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.getValueAtIndex = function (index) { + "use strict"; - return this.array[ this.indexOffset + index ]; + return this.array[this.indexOffset + index]; }; /** @@ -421,12 +418,13 @@ SPE.TypedArrayHelper.prototype.getValueAtIndex = function( index ) { * @param {Number} index The index in the array to fetch. * @return {TypedArray} The component value at the given index. */ -SPE.TypedArrayHelper.prototype.getComponentValueAtIndex = function( index ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.getComponentValueAtIndex = function (index) { + "use strict"; - return this.array.subarray( this.indexOffset + ( index * this.componentSize ) ); + return this.array.subarray(this.indexOffset + index * this.componentSize); }; + /** * A helper to handle creating and updating a THREE.BufferAttribute instance. * @@ -436,20 +434,20 @@ SPE.TypedArrayHelper.prototype.getComponentValueAtIndex = function( index ) { * @param {Boolean=} dynamicBuffer Whether this buffer attribute should be marked as dynamic or not. * @param {Function=} arrayType A reference to a TypedArray constructor. Defaults to Float32Array if none provided. */ -SPE.ShaderAttribute = function( type, dynamicBuffer, arrayType ) { - 'use strict'; +SPE.ShaderAttribute = function (type, dynamicBuffer, arrayType) { + "use strict"; - var typeMap = SPE.ShaderAttribute.typeSizeMap; + let typeMap = SPE.ShaderAttribute.typeSizeMap; - this.type = typeof type === 'string' && typeMap.hasOwnProperty( type ) ? type : 'f'; - this.componentSize = typeMap[ this.type ]; - this.arrayType = arrayType || Float32Array; - this.typedArray = null; - this.bufferAttribute = null; - this.dynamicBuffer = !!dynamicBuffer; + this.type = typeof type === "string" && typeMap.hasOwnProperty(type) ? type : "f"; + this.componentSize = typeMap[this.type]; + this.arrayType = arrayType || Float32Array; + this.typedArray = null; + this.bufferAttribute = null; + this.dynamicBuffer = !!dynamicBuffer; - this.updateMin = 0; - this.updateMax = 0; + this.updateMin = 0; + this.updateMax = 0; }; SPE.ShaderAttribute.constructor = SPE.ShaderAttribute; @@ -459,47 +457,47 @@ SPE.ShaderAttribute.constructor = SPE.ShaderAttribute; * @enum {Number} */ SPE.ShaderAttribute.typeSizeMap = { - /** - * Float - * @type {Number} - */ - f: 1, - - /** - * Vec2 - * @type {Number} - */ - v2: 2, - - /** - * Vec3 - * @type {Number} - */ - v3: 3, - - /** - * Vec4 - * @type {Number} - */ - v4: 4, - - /** - * Color - * @type {Number} - */ - c: 3, - - /** - * Mat3 - * @type {Number} - */ - m3: 9, - - /** - * Mat4 - * @type {Number} - */ - m4: 16 + /** + * Float + * @type {Number} + */ + f: 1, + + /** + * Vec2 + * @type {Number} + */ + v2: 2, + + /** + * Vec3 + * @type {Number} + */ + v3: 3, + + /** + * Vec4 + * @type {Number} + */ + v4: 4, + + /** + * Color + * @type {Number} + */ + c: 3, + + /** + * Mat3 + * @type {Number} + */ + m3: 9, + + /** + * Mat4 + * @type {Number} + */ + m4: 16, }; /** @@ -509,47 +507,41 @@ SPE.ShaderAttribute.typeSizeMap = { * @param {Number} min The start of the range to mark as needing an update. * @param {Number} max The end of the range to mark as needing an update. */ -SPE.ShaderAttribute.prototype.setUpdateRange = function( min, max ) { - 'use strict'; +SPE.ShaderAttribute.prototype.setUpdateRange = function (min, max) { + "use strict"; - this.updateMin = Math.min( min * this.componentSize, this.updateMin * this.componentSize ); - this.updateMax = Math.max( max * this.componentSize, this.updateMax * this.componentSize ); + this.updateMin = Math.min(min * this.componentSize, this.updateMin * this.componentSize); + this.updateMax = Math.max(max * this.componentSize, this.updateMax * this.componentSize); }; /** * Calculate the number of indices that this attribute should mark as needing * updating. Also marks the attribute as needing an update. */ -SPE.ShaderAttribute.prototype.flagUpdate = function() { - 'use strict'; +SPE.ShaderAttribute.prototype.flagUpdate = function () { + "use strict"; - var attr = this.bufferAttribute, - range = attr.updateRange; + let attr = this.bufferAttribute; + let range = attr.addUpdateRange; - range.offset = this.updateMin; - range.count = Math.min( ( this.updateMax - this.updateMin ) + this.componentSize, this.typedArray.array.length ); - // console.log( range.offset, range.count, this.typedArray.array.length ); - // console.log( 'flagUpdate:', range.offset, range.count ); - attr.needsUpdate = true; + range.offset = this.updateMin; + range.count = Math.min(this.updateMax - this.updateMin + this.componentSize, this.typedArray.array.length); + attr.needsUpdate = true; }; - - /** * Reset the index update counts for this attribute */ -SPE.ShaderAttribute.prototype.resetUpdateRange = function() { - 'use strict'; +SPE.ShaderAttribute.prototype.resetUpdateRange = function () { + "use strict"; - this.updateMin = 0; - this.updateMax = 0; + this.updateMin = 0; + this.updateMax = 0; }; -SPE.ShaderAttribute.prototype.resetDynamic = function() { - 'use strict'; - this.bufferAttribute.usage = this.dynamicBuffer ? - THREE.DynamicDrawUsage : - THREE.StaticDrawUsage; +SPE.ShaderAttribute.prototype.resetDynamic = function () { + "use strict"; + this.bufferAttribute.usage = this.dynamicBuffer ? THREE.DynamicDrawUsage : THREE.StaticDrawUsage; }; /** @@ -557,29 +549,25 @@ SPE.ShaderAttribute.prototype.resetDynamic = function() { * @param {Number} start The start index of the splice. Will be multiplied by the number of components for this attribute. * @param {Number} end The end index of the splice. Will be multiplied by the number of components for this attribute. */ -SPE.ShaderAttribute.prototype.splice = function( start, end ) { - 'use strict'; +SPE.ShaderAttribute.prototype.splice = function (start, end) { + "use strict"; - this.typedArray.splice( start, end ); + this.typedArray.splice(start, end); - // Reset the reference to the attribute's typed array - // since it has probably changed. - this.forceUpdateAll(); + // Reset the reference to the attribute's typed array + // since it has probably changed. + this.forceUpdateAll(); }; -SPE.ShaderAttribute.prototype.forceUpdateAll = function() { - 'use strict'; +SPE.ShaderAttribute.prototype.forceUpdateAll = function () { + "use strict"; - this.bufferAttribute.array = this.typedArray.array; - this.bufferAttribute.updateRange.offset = 0; - this.bufferAttribute.updateRange.count = -1; - // this.bufferAttribute.dynamic = false; - // this.bufferAttribute.usage = this.dynamicBuffer ? - // THREE.DynamicDrawUsage : - // THREE.StaticDrawUsage; + this.bufferAttribute.array = this.typedArray.array; + this.bufferAttribute.addUpdateRange.offset = 0; + this.bufferAttribute.addUpdateRange.count = -1; - this.bufferAttribute.usage = THREE.StaticDrawUsage; - this.bufferAttribute.needsUpdate = true; + this.bufferAttribute.usage = THREE.StaticDrawUsage; + this.bufferAttribute.needsUpdate = true; }; /** @@ -591,27 +579,26 @@ SPE.ShaderAttribute.prototype.forceUpdateAll = function() { * * @param {Number} size The size of the typed array to create or update to. */ -SPE.ShaderAttribute.prototype._ensureTypedArray = function( size ) { - 'use strict'; +SPE.ShaderAttribute.prototype._ensureTypedArray = function (size) { + "use strict"; - // Condition that's most likely to be true at the top: no change. - if ( this.typedArray !== null && this.typedArray.size === size * this.componentSize ) { - return; - } + // Condition that's most likely to be true at the top: no change. + if (this.typedArray !== null && this.typedArray.size === size * this.componentSize) { + return; + } - // Resize the array if we need to, telling the TypedArrayHelper to - // ignore it's component size when evaluating size. - else if ( this.typedArray !== null && this.typedArray.size !== size ) { - this.typedArray.setSize( size ); - } + // Resize the array if we need to, telling the TypedArrayHelper to + // ignore it's component size when evaluating size. + else if (this.typedArray !== null && this.typedArray.size !== size) { + this.typedArray.setSize(size); + } - // This condition should only occur once in an attribute's lifecycle. - else if ( this.typedArray === null ) { - this.typedArray = new SPE.TypedArrayHelper( this.arrayType, size, this.componentSize ); - } + // This condition should only occur once in an attribute's lifecycle. + else if (this.typedArray === null) { + this.typedArray = new SPE.TypedArrayHelper(this.arrayType, size, this.componentSize); + } }; - /** * Creates a THREE.BufferAttribute instance if one doesn't exist already. * @@ -621,50 +608,48 @@ SPE.ShaderAttribute.prototype._ensureTypedArray = function( size ) { * * @param {Number} size The size of the typed array to create if one doesn't exist, or resize existing array to. */ -SPE.ShaderAttribute.prototype._createBufferAttribute = function( size ) { - 'use strict'; +SPE.ShaderAttribute.prototype._createBufferAttribute = function (size) { + "use strict"; - // Make sure the typedArray is present and correct. - this._ensureTypedArray( size ); + // Make sure the typedArray is present and correct. + this._ensureTypedArray(size); - // Don't create it if it already exists, but do - // flag that it needs updating on the next render - // cycle. - if ( this.bufferAttribute !== null ) { - this.bufferAttribute.array = this.typedArray.array; + // Don't create it if it already exists, but do + // flag that it needs updating on the next render + // cycle. + if (this.bufferAttribute !== null) { + this.bufferAttribute.array = this.typedArray.array; - // Since THREE.js version 81, dynamic count calculation was removed - // so I need to do it manually here. - // - // In the next minor release, I may well remove this check and force - // dependency on THREE r81+. - if ( parseFloat( THREE.REVISION ) >= 81 ) { - this.bufferAttribute.count = this.bufferAttribute.array.length / this.bufferAttribute.itemSize; - } + // Since THREE.js version 81, dynamic count calculation was removed + // so I need to do it manually here. + // + // In the next minor release, I may well remove this check and force + // dependency on THREE r81+. + if (parseFloat(THREE.REVISION) >= 81) { + this.bufferAttribute.count = this.bufferAttribute.array.length / this.bufferAttribute.itemSize; + } - this.bufferAttribute.needsUpdate = true; - return; - } + this.bufferAttribute.needsUpdate = true; + return; + } - this.bufferAttribute = new THREE.BufferAttribute( this.typedArray.array, this.componentSize ); - // this.bufferAttribute.dynamic = this.dynamicBuffer; - this.bufferAttribute.usage = this.dynamicBuffer ? - THREE.DynamicDrawUsage : - THREE.StaticDrawUsage; + this.bufferAttribute = new THREE.BufferAttribute(this.typedArray.array, this.componentSize); + + this.bufferAttribute.usage = this.dynamicBuffer ? THREE.DynamicDrawUsage : THREE.StaticDrawUsage; }; /** * Returns the length of the typed array associated with this attribute. * @return {Number} The length of the typed array. Will be 0 if no typed array has been created yet. */ -SPE.ShaderAttribute.prototype.getLength = function() { - 'use strict'; +SPE.ShaderAttribute.prototype.getLength = function () { + "use strict"; - if ( this.typedArray === null ) { - return 0; - } + if (this.typedArray === null) { + return 0; + } - return this.typedArray.array.length; + return this.typedArray.array.length; }; @@ -787,6 +772,9 @@ SPE.shaderChunks = { '}', ].join( '\n' ), + + // ORIGINAL floatOverLifetime + /* floatOverLifetime: [ 'float getFloatOverLifetime( in float positionInTime, in vec4 attr ) {', ' highp float value = 0.0;', @@ -813,6 +801,30 @@ SPE.shaderChunks = { ' return value;', '}', ].join( '\n' ), + */ + + + // MODIFIED floatOverLifetime + floatOverLifetime: [ + 'float getFloatOverLifetime( in float positionInTime, in vec4 attr ) {', + ' const int VEC4_SIZE = 4;', + ' float value = 0.0;', + ' float deltaAge = clamp(positionInTime * float(VEC4_SIZE - 2), 0.0, float(VEC4_SIZE - 2));', + '', + ' if (deltaAge == 0.0) return attr[0];', + ' if (deltaAge >= float(VEC4_SIZE - 1)) return attr[VEC4_SIZE - 1];', + '', + ' for( int i = 0; i < VEC4_SIZE - 1; ++i ) {', + ' float fIndex = float( i );', + ' float shouldApplyValue = and( when_gt( deltaAge, fIndex ), when_le( deltaAge, fIndex + 1.0 ) );', + ' if(i <= 3) {', + ' value += shouldApplyValue * mix( attr[ i ], attr[ i + 1 ], deltaAge - fIndex );', + ' }', + ' }', + '', + ' return value;', + '}', + ].join( '\n' ), colorOverLifetime: [ 'vec3 getColorOverLifetime( in float positionInTime, in vec3 color1, in vec3 color2, in vec3 color3, in vec3 color4 ) {', @@ -1124,27 +1136,37 @@ SPE.utils = { * Boolean type. * @type {String} */ - BOOLEAN: 'boolean', + BOOLEAN: "boolean", /** * String type. * @type {String} */ - STRING: 'string', + STRING: "string", /** * Number type. * @type {String} */ - NUMBER: 'number', + NUMBER: "number", /** * Object type. * @type {String} */ - OBJECT: 'object' + OBJECT: "object", }, + /** random 128-bit number in canonical uuid format. all bits are random. */ + generateUUID: function() { + function random16Hex() { return (0x10000 | Math.random() * 0x10000).toString(16).substr(1); } + return random16Hex() + random16Hex() + + "-" + random16Hex() + + "-" + random16Hex() + + "-" + random16Hex() + + "-" + random16Hex() + random16Hex() + random16Hex(); + }, + /** * Given a value, a type, and a default value to fallback to, * ensure the given argument adheres to the type requesting, @@ -1155,13 +1177,12 @@ SPE.utils = { * @param {(boolean|string|number|object)} defaultValue A default value to fallback on if the type check fails. * @return {(boolean|string|number|object)} The given value if type check passes, or the default value if it fails. */ - ensureTypedArg: function( arg, type, defaultValue ) { - 'use strict'; + ensureTypedArg: function (arg, type, defaultValue) { + "use strict"; - if ( typeof arg === type ) { + if (typeof arg === type) { return arg; - } - else { + } else { return defaultValue; } }, @@ -1178,15 +1199,15 @@ SPE.utils = { * @param {(boolean|string|number|object)} defaultValue A default fallback value. * @return {(boolean|string|number|object)} The given value if type check passes, or the default value if it fails. */ - ensureArrayTypedArg: function( arg, type, defaultValue ) { - 'use strict'; + ensureArrayTypedArg: function (arg, type, defaultValue) { + "use strict"; // If the argument being checked is an array, loop through // it and ensure all the values are of the correct type, // falling back to the defaultValue if any aren't. - if ( Array.isArray( arg ) ) { - for ( var i = arg.length - 1; i >= 0; --i ) { - if ( typeof arg[ i ] !== type ) { + if (Array.isArray(arg)) { + for (let i = arg.length - 1; i >= 0; --i) { + if (typeof arg[i] !== type) { return defaultValue; } } @@ -1196,7 +1217,7 @@ SPE.utils = { // If the arg isn't an array then just fallback to // checking the type. - return this.ensureTypedArg( arg, type, defaultValue ); + return this.ensureTypedArg(arg, type, defaultValue); }, /** @@ -1207,13 +1228,12 @@ SPE.utils = { * @param {Object} defaultValue A default fallback value if instance check fails * @return {Object} The given value if type check passes, or the default value if it fails. */ - ensureInstanceOf: function( arg, instance, defaultValue ) { - 'use strict'; + ensureInstanceOf: function (arg, instance, defaultValue) { + "use strict"; - if ( instance !== undefined && arg instanceof instance ) { + if (instance !== undefined && arg instanceof instance) { return arg; - } - else { + } else { return defaultValue; } }, @@ -1230,15 +1250,15 @@ SPE.utils = { * @param {Object} defaultValue A default fallback value if instance check fails * @return {Object} The given value if type check passes, or the default value if it fails. */ - ensureArrayInstanceOf: function( arg, instance, defaultValue ) { - 'use strict'; + ensureArrayInstanceOf: function (arg, instance, defaultValue) { + "use strict"; // If the argument being checked is an array, loop through // it and ensure all the values are of the correct type, // falling back to the defaultValue if any aren't. - if ( Array.isArray( arg ) ) { - for ( var i = arg.length - 1; i >= 0; --i ) { - if ( instance !== undefined && arg[ i ] instanceof instance === false ) { + if (Array.isArray(arg)) { + for (let i = arg.length - 1; i >= 0; --i) { + if (instance !== undefined && arg[i] instanceof instance === false) { return defaultValue; } } @@ -1248,7 +1268,7 @@ SPE.utils = { // If the arg isn't an array then just fallback to // checking the type. - return this.ensureInstanceOf( arg, instance, defaultValue ); + return this.ensureInstanceOf(arg, instance, defaultValue); }, /** @@ -1263,31 +1283,31 @@ SPE.utils = { * @param {Number} minLength The minimum length of the array to create. * @param {Number} maxLength The maximum length of the array to create. */ - ensureValueOverLifetimeCompliance: function( property, minLength, maxLength ) { - 'use strict'; + ensureValueOverLifetimeCompliance: function (property, minLength, maxLength) { + "use strict"; minLength = minLength || 3; maxLength = maxLength || 3; // First, ensure both properties are arrays. - if ( Array.isArray( property._value ) === false ) { - property._value = [ property._value ]; + if (Array.isArray(property._value) === false) { + property._value = [property._value]; } - if ( Array.isArray( property._spread ) === false ) { - property._spread = [ property._spread ]; + if (Array.isArray(property._spread) === false) { + property._spread = [property._spread]; } - var valueLength = this.clamp( property._value.length, minLength, maxLength ), - spreadLength = this.clamp( property._spread.length, minLength, maxLength ), - desiredLength = Math.max( valueLength, spreadLength ); + let valueLength = this.clamp(property._value.length, minLength, maxLength); + let spreadLength = this.clamp(property._spread.length, minLength, maxLength); + let desiredLength = Math.max(valueLength, spreadLength); - if ( property._value.length !== desiredLength ) { - property._value = this.interpolateArray( property._value, desiredLength ); + if (property._value.length !== desiredLength) { + property._value = this.interpolateArray(property._value, desiredLength); } - if ( property._spread.length !== desiredLength ) { - property._spread = this.interpolateArray( property._spread, desiredLength ); + if (property._spread.length !== desiredLength) { + property._spread = this.interpolateArray(property._spread, desiredLength); } }, @@ -1303,27 +1323,26 @@ SPE.utils = { * @param {Number} newLength The length the array should be interpolated to. * @return {Array} The interpolated array. */ - interpolateArray: function( srcArray, newLength ) { - 'use strict'; + interpolateArray: function (srcArray, newLength) { + "use strict"; - var sourceLength = srcArray.length, - newArray = [ typeof srcArray[ 0 ].clone === 'function' ? srcArray[ 0 ].clone() : srcArray[ 0 ] ], - factor = ( sourceLength - 1 ) / ( newLength - 1 ); + let sourceLength = srcArray.length; + let newArray = [typeof srcArray[0].clone === "function" ? srcArray[0].clone() : srcArray[0]]; + let factor = (sourceLength - 1) / (newLength - 1); + for (let i = 1; i < newLength - 1; ++i) { + let f = i * factor; + let before = Math.floor(f); + let after = Math.ceil(f); + let delta = f - before; - for ( var i = 1; i < newLength - 1; ++i ) { - var f = i * factor, - before = Math.floor( f ), - after = Math.ceil( f ), - delta = f - before; - - newArray[ i ] = this.lerpTypeAgnostic( srcArray[ before ], srcArray[ after ], delta ); + newArray[i] = this.lerpTypeAgnostic(srcArray[before], srcArray[after], delta); } newArray.push( - typeof srcArray[ sourceLength - 1 ].clone === 'function' ? - srcArray[ sourceLength - 1 ].clone() : - srcArray[ sourceLength - 1 ] + typeof srcArray[sourceLength - 1].clone === "function" + ? srcArray[sourceLength - 1].clone() + : srcArray[sourceLength - 1] ); return newArray; @@ -1336,10 +1355,10 @@ SPE.utils = { * @param {Number} max The maximum value. * @return {Number} The clamped number. */ - clamp: function( value, min, max ) { - 'use strict'; + clamp: function (value, min, max) { + "use strict"; - return Math.max( min, Math.min( value, max ) ); + return Math.max(min, Math.min(value, max)); }, /** @@ -1351,15 +1370,15 @@ SPE.utils = { * @param {Boolean} randomise Whether the value should be randomised. * @return {Number} The result of the operation. */ - zeroToEpsilon: function( value, randomise ) { - 'use strict'; + zeroToEpsilon: function (value, randomise) { + "use strict"; - var epsilon = 0.00001, - result = value; + let epsilon = 0.00001; + let result = value; result = randomise ? Math.random() * epsilon * 10 : epsilon; - if ( value < 0 && value > -epsilon ) { + if (value < 0 && value > -epsilon) { result = -result; } @@ -1386,45 +1405,40 @@ SPE.utils = { * the start and end arguments aren't a supported type, or * if their types do not match. */ - lerpTypeAgnostic: function( start, end, delta ) { - 'use strict'; + lerpTypeAgnostic: function (start, end, delta) { + "use strict"; - var types = this.types, - out; + let types = this.types; + let out; - if ( typeof start === types.NUMBER && typeof end === types.NUMBER ) { - return start + ( ( end - start ) * delta ); - } - else if ( start instanceof THREE.Vector2 && end instanceof THREE.Vector2 ) { + if (typeof start === types.NUMBER && typeof end === types.NUMBER) { + return start + (end - start) * delta; + } else if (start instanceof THREE.Vector2 && end instanceof THREE.Vector2) { out = start.clone(); - out.x = this.lerp( start.x, end.x, delta ); - out.y = this.lerp( start.y, end.y, delta ); + out.x = this.lerp(start.x, end.x, delta); + out.y = this.lerp(start.y, end.y, delta); return out; - } - else if ( start instanceof THREE.Vector3 && end instanceof THREE.Vector3 ) { + } else if (start instanceof THREE.Vector3 && end instanceof THREE.Vector3) { out = start.clone(); - out.x = this.lerp( start.x, end.x, delta ); - out.y = this.lerp( start.y, end.y, delta ); - out.z = this.lerp( start.z, end.z, delta ); + out.x = this.lerp(start.x, end.x, delta); + out.y = this.lerp(start.y, end.y, delta); + out.z = this.lerp(start.z, end.z, delta); return out; - } - else if ( start instanceof THREE.Vector4 && end instanceof THREE.Vector4 ) { + } else if (start instanceof THREE.Vector4 && end instanceof THREE.Vector4) { out = start.clone(); - out.x = this.lerp( start.x, end.x, delta ); - out.y = this.lerp( start.y, end.y, delta ); - out.z = this.lerp( start.z, end.z, delta ); - out.w = this.lerp( start.w, end.w, delta ); + out.x = this.lerp(start.x, end.x, delta); + out.y = this.lerp(start.y, end.y, delta); + out.z = this.lerp(start.z, end.z, delta); + out.w = this.lerp(start.w, end.w, delta); return out; - } - else if ( start instanceof THREE.Color && end instanceof THREE.Color ) { + } else if (start instanceof THREE.Color && end instanceof THREE.Color) { out = start.clone(); - out.r = this.lerp( start.r, end.r, delta ); - out.g = this.lerp( start.g, end.g, delta ); - out.b = this.lerp( start.b, end.b, delta ); + out.r = this.lerp(start.r, end.r, delta); + out.g = this.lerp(start.g, end.g, delta); + out.b = this.lerp(start.b, end.b, delta); return out; - } - else { - console.warn( 'Invalid argument types, or argument types do not match:', start, end ); + } else { + console.warn("Invalid argument types, or argument types do not match:", start, end); } }, @@ -1435,9 +1449,9 @@ SPE.utils = { * @param {Number} delta The position to interpolate to. * @return {Number} The result of the lerp operation. */ - lerp: function( start, end, delta ) { - 'use strict'; - return start + ( ( end - start ) * delta ); + lerp: function (start, end, delta) { + "use strict"; + return start + (end - start) * delta; }, /** @@ -1447,23 +1461,23 @@ SPE.utils = { * @param {Number} multiple The multiple to round to. * @return {Number} The result of the round operation. */ - roundToNearestMultiple: function( n, multiple ) { - 'use strict'; + roundToNearestMultiple: function (n, multiple) { + "use strict"; - var remainder = 0; + let remainder = 0; - if ( multiple === 0 ) { + if (multiple === 0) { return n; } - remainder = Math.abs( n ) % multiple; + remainder = Math.abs(n) % multiple; - if ( remainder === 0 ) { + if (remainder === 0) { return n; } - if ( n < 0 ) { - return -( Math.abs( n ) - remainder ); + if (n < 0) { + return -(Math.abs(n) - remainder); } return n + multiple - remainder; @@ -1475,11 +1489,11 @@ SPE.utils = { * @param {Array} array The array of values to check equality of. * @return {Boolean} Whether the array's values are all equal or not. */ - arrayValuesAreEqual: function( array ) { - 'use strict'; + arrayValuesAreEqual: function (array) { + "use strict"; - for ( var i = 0; i < array.length - 1; ++i ) { - if ( array[ i ] !== array[ i + 1 ] ) { + for (let i = 0; i < array.length - 1; ++i) { + if (array[i] !== array[i + 1]) { return false; } } @@ -1488,10 +1502,10 @@ SPE.utils = { }, // colorsAreEqual: function() { - // var colors = Array.prototype.slice.call( arguments ), + // let colors = Array.prototype.slice.call( arguments ), // numColors = colors.length; - // for ( var i = 0, color1, color2; i < numColors - 1; ++i ) { + // for ( let i = 0, color1, color2; i < numColors - 1; ++i ) { // color1 = colors[ i ]; // color2 = colors[ i + 1 ]; @@ -1507,7 +1521,6 @@ SPE.utils = { // return true; // }, - /** * Given a start value and a spread value, create and return a random * number. @@ -1515,13 +1528,11 @@ SPE.utils = { * @param {Number} spread The size of the random variance to apply. * @return {Number} A randomised number. */ - randomFloat: function( base, spread ) { - 'use strict'; - return base + spread * ( Math.random() - 0.5 ); + randomFloat: function (base, spread) { + "use strict"; + return base + spread * (Math.random() - 0.5); }, - - /** * Given an SPE.ShaderAttribute instance, and various other settings, * assign values to the attribute's array in a `vec3` format. @@ -1532,24 +1543,24 @@ SPE.utils = { * @param {Object} spread THREE.Vector3 instance describing the random variance to apply to the start value. * @param {Object} spreadClamp THREE.Vector3 instance describing the multiples to clamp the randomness to. */ - randomVector3: function( attribute, index, base, spread, spreadClamp ) { - 'use strict'; + randomVector3: function (attribute, index, base, spread, spreadClamp) { + "use strict"; - var x = base.x + ( Math.random() * spread.x - ( spread.x * 0.5 ) ), - y = base.y + ( Math.random() * spread.y - ( spread.y * 0.5 ) ), - z = base.z + ( Math.random() * spread.z - ( spread.z * 0.5 ) ); + let x = base.x + (Math.random() * spread.x - spread.x * 0.5); + let y = base.y + (Math.random() * spread.y - spread.y * 0.5); + let z = base.z + (Math.random() * spread.z - spread.z * 0.5); - // var x = this.randomFloat( base.x, spread.x ), + // let x = this.randomFloat( base.x, spread.x ), // y = this.randomFloat( base.y, spread.y ), // z = this.randomFloat( base.z, spread.z ); - if ( spreadClamp ) { - x = -spreadClamp.x * 0.5 + this.roundToNearestMultiple( x, spreadClamp.x ); - y = -spreadClamp.y * 0.5 + this.roundToNearestMultiple( y, spreadClamp.y ); - z = -spreadClamp.z * 0.5 + this.roundToNearestMultiple( z, spreadClamp.z ); + if (spreadClamp) { + x = -spreadClamp.x * 0.5 + this.roundToNearestMultiple(x, spreadClamp.x); + y = -spreadClamp.y * 0.5 + this.roundToNearestMultiple(y, spreadClamp.y); + z = -spreadClamp.z * 0.5 + this.roundToNearestMultiple(z, spreadClamp.z); } - attribute.typedArray.setVec3Components( index, x, y, z ); + attribute.typedArray.setVec3Components(index, x, y, z); }, /** @@ -1560,26 +1571,24 @@ SPE.utils = { * @param {Object} base THREE.Color instance describing the start color. * @param {Object} spread THREE.Vector3 instance describing the random variance to apply to the start color. */ - randomColor: function( attribute, index, base, spread ) { - 'use strict'; + randomColor: function (attribute, index, base, spread) { + "use strict"; - var r = base.r + ( Math.random() * spread.x ), - g = base.g + ( Math.random() * spread.y ), - b = base.b + ( Math.random() * spread.z ); + let r = base.r + Math.random() * spread.x; + let g = base.g + Math.random() * spread.y; + let b = base.b + Math.random() * spread.z; - r = this.clamp( r, 0, 1 ); - g = this.clamp( g, 0, 1 ); - b = this.clamp( b, 0, 1 ); + r = this.clamp(r, 0, 1); + g = this.clamp(g, 0, 1); + b = this.clamp(b, 0, 1); - - attribute.typedArray.setVec3Components( index, r, g, b ); + attribute.typedArray.setVec3Components(index, r, g, b); }, + randomColorAsHex: (function () { + "use strict"; - randomColorAsHex: ( function() { - 'use strict'; - - var workingColor = new THREE.Color(); + let workingColor = new THREE.Color(); /** * Assigns a random color value, encoded as a hex value in decimal @@ -1589,29 +1598,29 @@ SPE.utils = { * @param {Object} base THREE.Color instance describing the start color. * @param {Object} spread THREE.Vector3 instance describing the random variance to apply to the start color. */ - return function( attribute, index, base, spread ) { - var numItems = base.length, - colors = []; + return function (attribute, index, base, spread) { + let numItems = base.length; + let colors = []; - for ( var i = 0; i < numItems; ++i ) { - var spreadVector = spread[ i ]; + for (let i = 0; i < numItems; ++i) { + let spreadVector = spread[i]; - workingColor.copy( base[ i ] ); + workingColor.copy(base[i]); - workingColor.r += ( Math.random() * spreadVector.x ) - ( spreadVector.x * 0.5 ); - workingColor.g += ( Math.random() * spreadVector.y ) - ( spreadVector.y * 0.5 ); - workingColor.b += ( Math.random() * spreadVector.z ) - ( spreadVector.z * 0.5 ); + workingColor.r += Math.random() * spreadVector.x - spreadVector.x * 0.5; + workingColor.g += Math.random() * spreadVector.y - spreadVector.y * 0.5; + workingColor.b += Math.random() * spreadVector.z - spreadVector.z * 0.5; - workingColor.r = this.clamp( workingColor.r, 0, 1 ); - workingColor.g = this.clamp( workingColor.g, 0, 1 ); - workingColor.b = this.clamp( workingColor.b, 0, 1 ); + workingColor.r = this.clamp(workingColor.r, 0, 1); + workingColor.g = this.clamp(workingColor.g, 0, 1); + workingColor.b = this.clamp(workingColor.b, 0, 1); - colors.push( workingColor.getHex() ); + colors.push(workingColor.getHex()); } - attribute.typedArray.setVec4Components( index, colors[ 0 ], colors[ 1 ], colors[ 2 ], colors[ 3 ] ); + attribute.typedArray.setVec4Components(index, colors[0], colors[1], colors[2], colors[3]); }; - }() ), + })(), /** * Given an SPE.ShaderAttribute instance, and various other settings, @@ -1622,13 +1631,13 @@ SPE.utils = { * @param {Object} start THREE.Vector3 instance describing the start line position. * @param {Object} end THREE.Vector3 instance describing the end line position. */ - randomVector3OnLine: function( attribute, index, start, end ) { - 'use strict'; - var pos = start.clone(); + randomVector3OnLine: function (attribute, index, start, end) { + "use strict"; + let pos = start.clone(); - pos.lerp( end, Math.random() ); + pos.lerp(end, Math.random()); - attribute.typedArray.setVec3Components( index, pos.x, pos.y, pos.z ); + attribute.typedArray.setVec3Components(index, pos.x, pos.y, pos.z); }, /** @@ -1652,29 +1661,33 @@ SPE.utils = { * @param {Object} radiusScale THREE.Vector3 instance describing the scale of each axis of the sphere. * @param {Number} radiusSpreadClamp What numeric multiple the projected value should be clamped to. */ - randomVector3OnSphere: function( - attribute, index, base, radius, radiusSpread, radiusScale, radiusSpreadClamp, distributionClamp + randomVector3OnSphere: function ( + attribute, + index, + base, + radius, + radiusSpread, + radiusScale, + radiusSpreadClamp, + distributionClamp ) { - 'use strict'; - - var depth = 2 * Math.random() - 1, - t = 6.2832 * Math.random(), - r = Math.sqrt( 1 - depth * depth ), - rand = this.randomFloat( radius, radiusSpread ), - x = 0, - y = 0, - z = 0; - - - if ( radiusSpreadClamp ) { - rand = Math.round( rand / radiusSpreadClamp ) * radiusSpreadClamp; + "use strict"; + + let depth = 2 * Math.random() - 1; + let t = 6.2832 * Math.random(); + let r = Math.sqrt(1 - depth * depth); + let rand = this.randomFloat(radius, radiusSpread); + let x = 0; + let y = 0; + let z = 0; + + if (radiusSpreadClamp) { + rand = Math.round(rand / radiusSpreadClamp) * radiusSpreadClamp; } - - // Set position on sphere - x = r * Math.cos( t ) * rand; - y = r * Math.sin( t ) * rand; + x = r * Math.cos(t) * rand; + y = r * Math.sin(t) * rand; z = depth * rand; // Apply radius scale to this position @@ -1688,16 +1701,14 @@ SPE.utils = { z += base.z; // Set the values in the typed array. - attribute.typedArray.setVec3Components( index, x, y, z ); + attribute.typedArray.setVec3Components(index, x, y, z); }, - seededRandom: function( seed ) { - var x = Math.sin( seed ) * 10000; - return x - ( x | 0 ); + seededRandom: function (seed) { + let x = Math.sin(seed) * 10000; + return x - (x | 0); }, - - /** * Assigns a random vector 3 value to an SPE.ShaderAttribute instance, projecting the * given values onto a 2d-disc. @@ -1710,22 +1721,22 @@ SPE.utils = { * @param {Object} radiusScale THREE.Vector3 instance describing the scale of each axis of the disc. The z-component is ignored. * @param {Number} radiusSpreadClamp What numeric multiple the projected value should be clamped to. */ - randomVector3OnDisc: function( attribute, index, base, radius, radiusSpread, radiusScale, radiusSpreadClamp ) { - 'use strict'; + randomVector3OnDisc: function (attribute, index, base, radius, radiusSpread, radiusScale, radiusSpreadClamp) { + "use strict"; - var t = 6.2832 * Math.random(), - rand = Math.abs( this.randomFloat( radius, radiusSpread ) ), - x = 0, - y = 0, - z = 0; + let t = 6.2832 * Math.random(); + let rand = Math.abs(this.randomFloat(radius, radiusSpread)); + let x = 0; + let y = 0; + let z = 0; - if ( radiusSpreadClamp ) { - rand = Math.round( rand / radiusSpreadClamp ) * radiusSpreadClamp; + if (radiusSpreadClamp) { + rand = Math.round(rand / radiusSpreadClamp) * radiusSpreadClamp; } // Set position on sphere - x = Math.cos( t ) * rand; - y = Math.sin( t ) * rand; + x = Math.cos(t) * rand; + y = Math.sin(t) * rand; // Apply radius scale to this position x *= radiusScale.x; @@ -1737,13 +1748,13 @@ SPE.utils = { z += base.z; // Set the values in the typed array. - attribute.typedArray.setVec3Components( index, x, y, z ); + attribute.typedArray.setVec3Components(index, x, y, z); }, - randomDirectionVector3OnSphere: ( function() { - 'use strict'; + randomDirectionVector3OnSphere: (function () { + "use strict"; - var v = new THREE.Vector3(); + let v = new THREE.Vector3(); /** * Given an SPE.ShaderAttribute instance, create a direction vector from the given @@ -1758,24 +1769,23 @@ SPE.utils = { * @param {Number} speed The magnitude to apply to the vector. * @param {Number} speedSpread The amount of randomness to apply to the magnitude. */ - return function( attribute, index, posX, posY, posZ, emitterPosition, speed, speedSpread ) { - v.copy( emitterPosition ); + return function (attribute, index, posX, posY, posZ, emitterPosition, speed, speedSpread) { + v.copy(emitterPosition); v.x -= posX; v.y -= posY; v.z -= posZ; - v.normalize().multiplyScalar( -this.randomFloat( speed, speedSpread ) ); + v.normalize().multiplyScalar(-this.randomFloat(speed, speedSpread)); - attribute.typedArray.setVec3Components( index, v.x, v.y, v.z ); + attribute.typedArray.setVec3Components(index, v.x, v.y, v.z); }; - }() ), - + })(), - randomDirectionVector3OnDisc: ( function() { - 'use strict'; + randomDirectionVector3OnDisc: (function () { + "use strict"; - var v = new THREE.Vector3(); + let v = new THREE.Vector3(); /** * Given an SPE.ShaderAttribute instance, create a direction vector from the given @@ -1790,26 +1800,26 @@ SPE.utils = { * @param {Number} speed The magnitude to apply to the vector. * @param {Number} speedSpread The amount of randomness to apply to the magnitude. */ - return function( attribute, index, posX, posY, posZ, emitterPosition, speed, speedSpread ) { - v.copy( emitterPosition ); + return function (attribute, index, posX, posY, posZ, emitterPosition, speed, speedSpread) { + v.copy(emitterPosition); v.x -= posX; v.y -= posY; v.z -= posZ; - v.normalize().multiplyScalar( -this.randomFloat( speed, speedSpread ) ); + v.normalize().multiplyScalar(-this.randomFloat(speed, speedSpread)); - attribute.typedArray.setVec3Components( index, v.x, v.y, 0 ); + attribute.typedArray.setVec3Components(index, v.x, v.y, 0); }; - }() ), + })(), - getPackedRotationAxis: ( function() { - 'use strict'; + getPackedRotationAxis: (function () { + "use strict"; - var v = new THREE.Vector3(), - vSpread = new THREE.Vector3(), - c = new THREE.Color(), - addOne = new THREE.Vector3( 1, 1, 1 ); + let v = new THREE.Vector3(); + let vSpread = new THREE.Vector3(); + let c = new THREE.Color(); + let addOne = new THREE.Vector3(1, 1, 1); /** * Given a rotation axis, and a rotation axis spread vector, @@ -1819,25 +1829,25 @@ SPE.utils = { * @param {Object} axisSpread THREE.Vector3 instance describing the amount of randomness to apply to the rotation axis. * @return {Number} The packed rotation axis, with randomness. */ - return function( axis, axisSpread ) { - v.copy( axis ).normalize(); - vSpread.copy( axisSpread ).normalize(); + return function (axis, axisSpread) { + v.copy(axis).normalize(); + vSpread.copy(axisSpread).normalize(); - v.x += ( -axisSpread.x * 0.5 ) + ( Math.random() * axisSpread.x ); - v.y += ( -axisSpread.y * 0.5 ) + ( Math.random() * axisSpread.y ); - v.z += ( -axisSpread.z * 0.5 ) + ( Math.random() * axisSpread.z ); + v.x += -axisSpread.x * 0.5 + Math.random() * axisSpread.x; + v.y += -axisSpread.y * 0.5 + Math.random() * axisSpread.y; + v.z += -axisSpread.z * 0.5 + Math.random() * axisSpread.z; // v.x = Math.abs( v.x ); // v.y = Math.abs( v.y ); // v.z = Math.abs( v.z ); - v.normalize().add( addOne ).multiplyScalar( 0.5 ); + v.normalize().add(addOne).multiplyScalar(0.5); - c.setRGB( v.x, v.y, v.z ); + c.setRGB(v.x, v.y, v.z); return c.getHex(); }; - }() ) + })(), }; @@ -1893,52 +1903,54 @@ SPE.utils = { * setting particle sizes to be relative to renderer size. */ - /** * The SPE.Group class. Creates a new group, containing a material, geometry, and mesh. * * @constructor * @param {GroupOptions} options A map of options to configure the group instance. */ -SPE.Group = function( options ) { - 'use strict'; +SPE.Group = function (options) { + "use strict"; - var utils = SPE.utils, - types = utils.types; + let utils = SPE.utils; + let types = utils.types; // Ensure we have a map of options to play with - options = utils.ensureTypedArg( options, types.OBJECT, {} ); - options.texture = utils.ensureTypedArg( options.texture, types.OBJECT, {} ); + options = utils.ensureTypedArg(options, types.OBJECT, {}); + options.texture = utils.ensureTypedArg(options.texture, types.OBJECT, {}); // Assign a UUID to this instance - this.uuid = THREE.Math.generateUUID(); + this.uuid = SPE.utils.generateUUID(); // If no `deltaTime` value is passed to the `SPE.Group.tick` function, // the value of this property will be used to advance the simulation. - this.fixedTimeStep = utils.ensureTypedArg( options.fixedTimeStep, types.NUMBER, 0.016 ); + this.fixedTimeStep = utils.ensureTypedArg(options.fixedTimeStep, types.NUMBER, 0.016); // Set properties used in the uniforms map, starting with the // texture stuff. - this.texture = utils.ensureInstanceOf( options.texture.value, THREE.Texture, null ); - this.textureFrames = utils.ensureInstanceOf( options.texture.frames, THREE.Vector2, new THREE.Vector2( 1, 1 ) ); - this.textureFrameCount = utils.ensureTypedArg( options.texture.frameCount, types.NUMBER, this.textureFrames.x * this.textureFrames.y ); - this.textureLoop = utils.ensureTypedArg( options.texture.loop, types.NUMBER, 1 ); - this.textureFrames.max( new THREE.Vector2( 1, 1 ) ); - - this.hasPerspective = utils.ensureTypedArg( options.hasPerspective, types.BOOLEAN, true ); - this.colorize = utils.ensureTypedArg( options.colorize, types.BOOLEAN, true ); + this.texture = utils.ensureInstanceOf(options.texture.value, THREE.Texture, null); + this.textureFrames = utils.ensureInstanceOf(options.texture.frames, THREE.Vector2, new THREE.Vector2(1, 1)); + this.textureFrameCount = utils.ensureTypedArg( + options.texture.frameCount, + types.NUMBER, + this.textureFrames.x * this.textureFrames.y + ); + this.textureLoop = utils.ensureTypedArg(options.texture.loop, types.NUMBER, 1); + this.textureFrames.max(new THREE.Vector2(1, 1)); - this.maxParticleCount = utils.ensureTypedArg( options.maxParticleCount, types.NUMBER, null ); + this.hasPerspective = utils.ensureTypedArg(options.hasPerspective, types.BOOLEAN, true); + this.colorize = utils.ensureTypedArg(options.colorize, types.BOOLEAN, true); + this.maxParticleCount = utils.ensureTypedArg(options.maxParticleCount, types.NUMBER, null); // Set properties used to define the ShaderMaterial's appearance. - this.blending = utils.ensureTypedArg( options.blending, types.NUMBER, THREE.AdditiveBlending ); - this.transparent = utils.ensureTypedArg( options.transparent, types.BOOLEAN, true ); - this.alphaTest = parseFloat( utils.ensureTypedArg( options.alphaTest, types.NUMBER, 0.0 ) ); - this.depthWrite = utils.ensureTypedArg( options.depthWrite, types.BOOLEAN, false ); - this.depthTest = utils.ensureTypedArg( options.depthTest, types.BOOLEAN, true ); - this.fog = utils.ensureTypedArg( options.fog, types.BOOLEAN, true ); - this.scale = utils.ensureTypedArg( options.scale, types.NUMBER, 300 ); + this.blending = utils.ensureTypedArg(options.blending, types.NUMBER, THREE.AdditiveBlending); + this.transparent = utils.ensureTypedArg(options.transparent, types.BOOLEAN, true); + this.alphaTest = parseFloat(utils.ensureTypedArg(options.alphaTest, types.NUMBER, 0.0)); + this.depthWrite = utils.ensureTypedArg(options.depthWrite, types.BOOLEAN, false); + this.depthTest = utils.ensureTypedArg(options.depthTest, types.BOOLEAN, true); + this.fog = utils.ensureTypedArg(options.fog, types.BOOLEAN, true); + this.scale = utils.ensureTypedArg(options.scale, types.NUMBER, 300); // Where emitter's go to curl up in a warm blanket and live // out their days. @@ -1959,50 +1971,49 @@ SPE.Group = function( options ) { this.particleCount = 0; - // Map of uniforms to be applied to the ShaderMaterial instance. this.uniforms = { tex: { - type: 't', - value: this.texture + type: "t", + value: this.texture, }, textureAnimation: { - type: 'v4', + type: "v4", value: new THREE.Vector4( this.textureFrames.x, this.textureFrames.y, this.textureFrameCount, - Math.max( Math.abs( this.textureLoop ), 1.0 ) - ) + Math.max(Math.abs(this.textureLoop), 1.0) + ), }, fogColor: { - type: 'c', - value: this.fog ? new THREE.Color() : null + type: "c", + value: this.fog ? new THREE.Color() : null, }, fogNear: { - type: 'f', - value: 10 + type: "f", + value: 10, }, fogFar: { - type: 'f', - value: 200 + type: "f", + value: 200, }, fogDensity: { - type: 'f', - value: 0.5 + type: "f", + value: 0.5, }, deltaTime: { - type: 'f', - value: 0 + type: "f", + value: 0, }, runTime: { - type: 'f', - value: 0 + type: "f", + value: 0, }, scale: { - type: 'f', - value: this.scale - } + type: "f", + value: this.scale, + }, }; // Add some defines into the mix... @@ -2015,31 +2026,31 @@ SPE.Group = function( options ) { SHOULD_ROTATE_PARTICLES: false, SHOULD_WIGGLE_PARTICLES: false, - SHOULD_CALCULATE_SPRITE: this.textureFrames.x > 1 || this.textureFrames.y > 1 + SHOULD_CALCULATE_SPRITE: this.textureFrames.x > 1 || this.textureFrames.y > 1, }; // Map of all attributes to be applied to the particles. // // See SPE.ShaderAttribute for a bit more info on this bit. this.attributes = { - position: new SPE.ShaderAttribute( 'v3', true ), - acceleration: new SPE.ShaderAttribute( 'v4', true ), // w component is drag - velocity: new SPE.ShaderAttribute( 'v3', true ), - rotation: new SPE.ShaderAttribute( 'v4', true ), - rotationCenter: new SPE.ShaderAttribute( 'v3', true ), - params: new SPE.ShaderAttribute( 'v4', true ), // Holds (alive, age, delay, wiggle) - size: new SPE.ShaderAttribute( 'v4', true ), - angle: new SPE.ShaderAttribute( 'v4', true ), - color: new SPE.ShaderAttribute( 'v4', true ), - opacity: new SPE.ShaderAttribute( 'v4', true ) + position: new SPE.ShaderAttribute("v3", true), + acceleration: new SPE.ShaderAttribute("v4", true), // w component is drag + velocity: new SPE.ShaderAttribute("v3", true), + rotation: new SPE.ShaderAttribute("v4", true), + rotationCenter: new SPE.ShaderAttribute("v3", true), + params: new SPE.ShaderAttribute("v4", true), // Holds (alive, age, delay, wiggle) + size: new SPE.ShaderAttribute("v4", true), + angle: new SPE.ShaderAttribute("v4", true), + color: new SPE.ShaderAttribute("v4", true), + opacity: new SPE.ShaderAttribute("v4", true), }; - this.attributeKeys = Object.keys( this.attributes ); + this.attributeKeys = Object.keys(this.attributes); this.attributeCount = this.attributeKeys.length; // Create the ShaderMaterial instance that'll help render the // particles. - this.material = new THREE.ShaderMaterial( { + this.material = new THREE.ShaderMaterial({ uniforms: this.uniforms, vertexShader: SPE.shaders.vertex, fragmentShader: SPE.shaders.fragment, @@ -2049,85 +2060,81 @@ SPE.Group = function( options ) { depthWrite: this.depthWrite, depthTest: this.depthTest, defines: this.defines, - fog: this.fog - } ); + fog: this.fog, + }); // Create the BufferGeometry and Points instances, ensuring // the geometry and material are given to the latter. this.geometry = new THREE.BufferGeometry(); - this.mesh = new THREE.Points( this.geometry, this.material ); + this.mesh = new THREE.Points(this.geometry, this.material); - if ( this.maxParticleCount === null ) { - console.warn( 'SPE.Group: No maxParticleCount specified. Adding emitters after rendering will probably cause errors.' ); + if (this.maxParticleCount === null) { + console.warn( + "SPE.Group: No maxParticleCount specified. Adding emitters after rendering will probably cause errors." + ); } }; SPE.Group.constructor = SPE.Group; +SPE.Group.prototype._updateDefines = function () { + "use strict"; -SPE.Group.prototype._updateDefines = function() { - 'use strict'; - - var emitters = this.emitters, - i = emitters.length - 1, - emitter, - defines = this.defines; + let emitters = this.emitters; + let i = emitters.length - 1; + let emitter; + let defines = this.defines; - for ( i; i >= 0; --i ) { - emitter = emitters[ i ]; + for (i; i >= 0; --i) { + emitter = emitters[i]; // Only do angle calculation if there's no spritesheet defined. // // Saves calculations being done and then overwritten in the shaders. - if ( !defines.SHOULD_CALCULATE_SPRITE ) { - defines.SHOULD_ROTATE_TEXTURE = defines.SHOULD_ROTATE_TEXTURE || !!Math.max( - Math.max.apply( null, emitter.angle.value ), - Math.max.apply( null, emitter.angle.spread ) - ); + if (!defines.SHOULD_CALCULATE_SPRITE) { + defines.SHOULD_ROTATE_TEXTURE = + defines.SHOULD_ROTATE_TEXTURE || + !!Math.max(Math.max.apply(null, emitter.angle.value), Math.max.apply(null, emitter.angle.spread)); } - defines.SHOULD_ROTATE_PARTICLES = defines.SHOULD_ROTATE_PARTICLES || !!Math.max( - emitter.rotation.angle, - emitter.rotation.angleSpread - ); + defines.SHOULD_ROTATE_PARTICLES = + defines.SHOULD_ROTATE_PARTICLES || !!Math.max(emitter.rotation.angle, emitter.rotation.angleSpread); - defines.SHOULD_WIGGLE_PARTICLES = defines.SHOULD_WIGGLE_PARTICLES || !!Math.max( - emitter.wiggle.value, - emitter.wiggle.spread - ); + defines.SHOULD_WIGGLE_PARTICLES = + defines.SHOULD_WIGGLE_PARTICLES || !!Math.max(emitter.wiggle.value, emitter.wiggle.spread); } this.material.needsUpdate = true; }; -SPE.Group.prototype._applyAttributesToGeometry = function() { - 'use strict'; +SPE.Group.prototype._applyAttributesToGeometry = function () { + "use strict"; - var attributes = this.attributes, - geometry = this.geometry, - geometryAttributes = geometry.attributes, - attribute, - geometryAttribute; + let attributes = this.attributes; + let geometry = this.geometry; + let geometryAttributes = geometry.attributes; + let attribute; + let geometryAttribute; // Loop through all the shader attributes and assign (or re-assign) // typed array buffers to each one. - for ( var attr in attributes ) { - if ( attributes.hasOwnProperty( attr ) ) { - attribute = attributes[ attr ]; - geometryAttribute = geometryAttributes[ attr ]; + for (let attr in attributes) { + if (attributes.hasOwnProperty(attr)) { + attribute = attributes[attr]; + geometryAttribute = geometryAttributes[attr]; // Update the array if this attribute exists on the geometry. // // This needs to be done because the attribute's typed array might have // been resized and reinstantiated, and might now be looking at a // different ArrayBuffer, so reference needs updating. - if ( geometryAttribute ) { + if (geometryAttribute) { geometryAttribute.array = attribute.typedArray.array; } // // Add the attribute to the geometry if it doesn't already exist. else { - geometry.addAttribute( attr, attribute.bufferAttribute ); + geometry.setAttribute(attr, attribute.bufferAttribute); } // Mark the attribute as needing an update the next time a frame is rendered. @@ -2139,7 +2146,7 @@ SPE.Group.prototype._applyAttributesToGeometry = function() { // only the values in the attribute buffers that are // associated with a particle will be used in THREE's // render cycle. - this.geometry.setDrawRange( 0, this.particleCount ); + this.geometry.setDrawRange(0, this.particleCount); }; /** @@ -2148,54 +2155,58 @@ SPE.Group.prototype._applyAttributesToGeometry = function() { * * @param {Emitter} emitter The emitter to add to this group. */ -SPE.Group.prototype.addEmitter = function( emitter ) { - 'use strict'; +SPE.Group.prototype.addEmitter = function (emitter) { + "use strict"; // Ensure an actual emitter instance is passed here. // // Decided not to throw here, just in case a scene's // rendering would be paused. Logging an error instead // of stopping execution if exceptions aren't caught. - if ( emitter instanceof SPE.Emitter === false ) { - console.error( '`emitter` argument must be instance of SPE.Emitter. Was provided with:', emitter ); + if (emitter instanceof SPE.Emitter === false) { + console.error("`emitter` argument must be instance of SPE.Emitter. Was provided with:", emitter); return; } // If the emitter already exists as a member of this group, then // stop here, we don't want to add it again. - else if ( this.emitterIDs.indexOf( emitter.uuid ) > -1 ) { - console.error( 'Emitter already exists in this group. Will not add again.' ); + else if (this.emitterIDs.indexOf(emitter.uuid) > -1) { + console.error("Emitter already exists in this group. Will not add again."); return; } // And finally, if the emitter is a member of another group, // don't add it to this group. - else if ( emitter.group !== null ) { - console.error( 'Emitter already belongs to another group. Will not add to requested group.' ); + else if (emitter.group !== null) { + console.error("Emitter already belongs to another group. Will not add to requested group."); return; } - var attributes = this.attributes, - start = this.particleCount, - end = start + emitter.particleCount; + let attributes = this.attributes; + let start = this.particleCount; + let end = start + emitter.particleCount; // Update this group's particle count. this.particleCount = end; // Emit a warning if the emitter being added will exceed the buffer sizes specified. - if ( this.maxParticleCount !== null && this.particleCount > this.maxParticleCount ) { - console.warn( 'SPE.Group: maxParticleCount exceeded. Requesting', this.particleCount, 'particles, can support only', this.maxParticleCount ); + if (this.maxParticleCount !== null && this.particleCount > this.maxParticleCount) { + console.warn( + "SPE.Group: maxParticleCount exceeded. Requesting", + this.particleCount, + "particles, can support only", + this.maxParticleCount + ); } - // Set the `particlesPerSecond` value (PPS) on the emitter. // It's used to determine how many particles to release // on a per-frame basis. - emitter._calculatePPSValue( emitter.maxAge._value + emitter.maxAge._spread ); - emitter._setBufferUpdateRanges( this.attributeKeys ); + emitter._calculatePPSValue(emitter.maxAge._value + emitter.maxAge._spread); + emitter._setBufferUpdateRanges(this.attributeKeys); // Store the offset value in the TypedArray attributes for this emitter. - emitter._setAttributeOffset( start ); + emitter._setAttributeOffset(start); // Save a reference to this group on the emitter so it knows // where it belongs. @@ -2205,34 +2216,30 @@ SPE.Group.prototype.addEmitter = function( emitter ) { // easier access during the emitter's tick function. emitter.attributes = this.attributes; - - // Ensure the attributes and their BufferAttributes exist, and their // TypedArrays are of the correct size. - for ( var attr in attributes ) { - if ( attributes.hasOwnProperty( attr ) ) { + for (let attr in attributes) { + if (attributes.hasOwnProperty(attr)) { // When creating a buffer, pass through the maxParticle count // if one is specified. - attributes[ attr ]._createBufferAttribute( - this.maxParticleCount !== null ? - this.maxParticleCount : - this.particleCount + attributes[attr]._createBufferAttribute( + this.maxParticleCount !== null ? this.maxParticleCount : this.particleCount ); } } // Loop through each particle this emitter wants to have, and create the attributes values, // storing them in the TypedArrays that each attribute holds. - for ( var i = start; i < end; ++i ) { - emitter._assignPositionValue( i ); - emitter._assignForceValue( i, 'velocity' ); - emitter._assignForceValue( i, 'acceleration' ); - emitter._assignAbsLifetimeValue( i, 'opacity' ); - emitter._assignAbsLifetimeValue( i, 'size' ); - emitter._assignAngleValue( i ); - emitter._assignRotationValue( i ); - emitter._assignParamsValue( i ); - emitter._assignColorValue( i ); + for (let i = start; i < end; ++i) { + emitter._assignPositionValue(i); + emitter._assignForceValue(i, "velocity"); + emitter._assignForceValue(i, "acceleration"); + emitter._assignAbsLifetimeValue(i, "opacity"); + emitter._assignAbsLifetimeValue(i, "size"); + emitter._assignAngleValue(i); + emitter._assignRotationValue(i); + emitter._assignParamsValue(i); + emitter._assignColorValue(i); } // Update the geometry and make sure the attributes are referencing @@ -2240,11 +2247,11 @@ SPE.Group.prototype.addEmitter = function( emitter ) { this._applyAttributesToGeometry(); // Store this emitter in this group's emitter's store. - this.emitters.push( emitter ); - this.emitterIDs.push( emitter.uuid ); + this.emitters.push(emitter); + this.emitterIDs.push(emitter.uuid); // Update certain flags to enable shader calculations only if they're necessary. - this._updateDefines( emitter ); + this._updateDefines(emitter); // Update the material since defines might have changed this.material.needsUpdate = true; @@ -2262,49 +2269,49 @@ SPE.Group.prototype.addEmitter = function( emitter ) { * * @param {Emitter} emitter The emitter to add to this group. */ -SPE.Group.prototype.removeEmitter = function( emitter ) { - 'use strict'; +SPE.Group.prototype.removeEmitter = function (emitter) { + "use strict"; - var emitterIndex = this.emitterIDs.indexOf( emitter.uuid ); + let emitterIndex = this.emitterIDs.indexOf(emitter.uuid); // Ensure an actual emitter instance is passed here. // // Decided not to throw here, just in case a scene's // rendering would be paused. Logging an error instead // of stopping execution if exceptions aren't caught. - if ( emitter instanceof SPE.Emitter === false ) { - console.error( '`emitter` argument must be instance of SPE.Emitter. Was provided with:', emitter ); + if (emitter instanceof SPE.Emitter === false) { + console.error("`emitter` argument must be instance of SPE.Emitter. Was provided with:", emitter); return; } // Issue an error if the emitter isn't a member of this group. - else if ( emitterIndex === -1 ) { - console.error( 'Emitter does not exist in this group. Will not remove.' ); + else if (emitterIndex === -1) { + console.error("Emitter does not exist in this group. Will not remove."); return; } // Kill all particles by marking them as dead // and their age as 0. - var start = emitter.attributeOffset, - end = start + emitter.particleCount, - params = this.attributes.params.typedArray; + let start = emitter.attributeOffset; + let end = start + emitter.particleCount; + let params = this.attributes.params.typedArray; // Set alive and age to zero. - for ( var i = start; i < end; ++i ) { - params.array[ i * 4 ] = 0.0; - params.array[ i * 4 + 1 ] = 0.0; + for (let i = start; i < end; ++i) { + params.array[i * 4] = 0.0; + params.array[i * 4 + 1] = 0.0; } // Remove the emitter from this group's "store". - this.emitters.splice( emitterIndex, 1 ); - this.emitterIDs.splice( emitterIndex, 1 ); + this.emitters.splice(emitterIndex, 1); + this.emitterIDs.splice(emitterIndex, 1); // Remove this emitter's attribute values from all shader attributes. // The `.splice()` call here also marks each attribute's buffer // as needing to update it's entire contents. - for ( var attr in this.attributes ) { - if ( this.attributes.hasOwnProperty( attr ) ) { - this.attributes[ attr ].splice( start, end ); + for (let attr in this.attributes) { + if (this.attributes.hasOwnProperty(attr)) { + this.attributes[attr].splice(start, end); } } @@ -2319,7 +2326,6 @@ SPE.Group.prototype.removeEmitter = function( emitter ) { this._attributesNeedRefresh = true; }; - /** * Fetch a single emitter instance from the pool. * If there are no objects in the pool, a new emitter will be @@ -2327,19 +2333,18 @@ SPE.Group.prototype.removeEmitter = function( emitter ) { * * @return {Emitter|null} */ -SPE.Group.prototype.getFromPool = function() { - 'use strict'; +SPE.Group.prototype.getFromPool = function () { + "use strict"; - var pool = this._pool, - createNew = this._createNewWhenPoolEmpty; + let pool = this._pool; + let createNew = this._createNewWhenPoolEmpty; - if ( pool.length ) { + if (pool.length) { return pool.pop(); - } - else if ( createNew ) { - var emitter = new SPE.Emitter( this._poolCreationSettings ); + } else if (createNew) { + let emitter = new SPE.Emitter(this._poolCreationSettings); - this.addEmitter( emitter ); + this.addEmitter(emitter); return emitter; } @@ -2347,39 +2352,36 @@ SPE.Group.prototype.getFromPool = function() { return null; }; - /** * Release an emitter into the pool. * * @param {ShaderParticleEmitter} emitter * @return {Group} This group instance. */ -SPE.Group.prototype.releaseIntoPool = function( emitter ) { - 'use strict'; +SPE.Group.prototype.releaseIntoPool = function (emitter) { + "use strict"; - if ( emitter instanceof SPE.Emitter === false ) { - console.error( 'Argument is not instanceof SPE.Emitter:', emitter ); + if (emitter instanceof SPE.Emitter === false) { + console.error("Argument is not instanceof SPE.Emitter:", emitter); return; } emitter.reset(); - this._pool.unshift( emitter ); + this._pool.unshift(emitter); return this; }; - /** * Get the pool array * * @return {Array} */ -SPE.Group.prototype.getPool = function() { - 'use strict'; +SPE.Group.prototype.getPool = function () { + "use strict"; return this._pool; }; - /** * Add a pool of emitters to this particle group * @@ -2388,47 +2390,44 @@ SPE.Group.prototype.getPool = function() { * @param {Boolean} createNew Should a new emitter be created if the pool runs out? * @return {Group} This group instance. */ -SPE.Group.prototype.addPool = function( numEmitters, emitterOptions, createNew ) { - 'use strict'; +SPE.Group.prototype.addPool = function (numEmitters, emitterOptions, createNew) { + "use strict"; - var emitter; + let emitter; // Save relevant settings and flags. this._poolCreationSettings = emitterOptions; this._createNewWhenPoolEmpty = !!createNew; // Create the emitters, add them to this group and the pool. - for ( var i = 0; i < numEmitters; ++i ) { - if ( Array.isArray( emitterOptions ) ) { - emitter = new SPE.Emitter( emitterOptions[ i ] ); - } - else { - emitter = new SPE.Emitter( emitterOptions ); + for (let i = 0; i < numEmitters; ++i) { + if (Array.isArray(emitterOptions)) { + emitter = new SPE.Emitter(emitterOptions[i]); + } else { + emitter = new SPE.Emitter(emitterOptions); } - this.addEmitter( emitter ); - this.releaseIntoPool( emitter ); + this.addEmitter(emitter); + this.releaseIntoPool(emitter); } return this; }; +SPE.Group.prototype._triggerSingleEmitter = function (pos) { + "use strict"; - -SPE.Group.prototype._triggerSingleEmitter = function( pos ) { - 'use strict'; - - var emitter = this.getFromPool(), + let emitter = this.getFromPool(), self = this; - if ( emitter === null ) { - console.log( 'SPE.Group pool ran out.' ); + if (emitter === null) { + console.log("SPE.Group pool ran out."); return; } // TODO: // - Make sure buffers are update with thus new position. - if ( pos instanceof THREE.Vector3 ) { - emitter.position.value.copy( pos ); + if (pos instanceof THREE.Vector3) { + emitter.position.value.copy(pos); // Trigger the setter for this property to force an // update to the emitter's position attribute. @@ -2437,15 +2436,14 @@ SPE.Group.prototype._triggerSingleEmitter = function( pos ) { emitter.enable(); - setTimeout( function() { + setTimeout(function () { emitter.disable(); - self.releaseIntoPool( emitter ); - }, ( Math.max( emitter.duration, ( emitter.maxAge.value + emitter.maxAge.spread ) ) ) * 1000 ); + self.releaseIntoPool(emitter); + }, Math.max(emitter.duration, emitter.maxAge.value + emitter.maxAge.spread) * 1000); return this; }; - /** * Set a given number of emitters as alive, with an optional position * vector3 to move them to. @@ -2454,113 +2452,101 @@ SPE.Group.prototype._triggerSingleEmitter = function( pos ) { * @param {Object} [position=undefined] A THREE.Vector3 instance describing the position to activate the emitter(s) at. * @return {Group} This group instance. */ -SPE.Group.prototype.triggerPoolEmitter = function( numEmitters, position ) { - 'use strict'; +SPE.Group.prototype.triggerPoolEmitter = function (numEmitters, position) { + "use strict"; - if ( typeof numEmitters === 'number' && numEmitters > 1 ) { - for ( var i = 0; i < numEmitters; ++i ) { - this._triggerSingleEmitter( position ); + if (typeof numEmitters === "number" && numEmitters > 1) { + for (let i = 0; i < numEmitters; ++i) { + this._triggerSingleEmitter(position); } - } - else { - this._triggerSingleEmitter( position ); + } else { + this._triggerSingleEmitter(position); } return this; }; - - -SPE.Group.prototype._updateUniforms = function( dt ) { - 'use strict'; +SPE.Group.prototype._updateUniforms = function (dt) { + "use strict"; this.uniforms.runTime.value += dt; this.uniforms.deltaTime.value = dt; }; -SPE.Group.prototype._resetBufferRanges = function() { - 'use strict'; +SPE.Group.prototype._resetBufferRanges = function () { + "use strict"; - var keys = this.attributeKeys, - i = this.attributeCount - 1, - attrs = this.attributes; + let keys = this.attributeKeys; + let i = this.attributeCount - 1; + let attrs = this.attributes; - for ( i; i >= 0; --i ) { - attrs[ keys[ i ] ].resetUpdateRange(); + for (i; i >= 0; --i) { + attrs[keys[i]].resetUpdateRange(); } }; +SPE.Group.prototype._updateBuffers = function (emitter) { + "use strict"; -SPE.Group.prototype._updateBuffers = function( emitter ) { - 'use strict'; - - var keys = this.attributeKeys, - i = this.attributeCount - 1, - attrs = this.attributes, - emitterRanges = emitter.bufferUpdateRanges, - key, - emitterAttr, - attr; + let keys = this.attributeKeys; + let attrs = this.attributes; + let emitterRanges = emitter.bufferUpdateRanges; + let key; + let emitterAttr; + let attr; - for ( i; i >= 0; --i ) { - key = keys[ i ]; - emitterAttr = emitterRanges[ key ]; - attr = attrs[ key ]; - attr.setUpdateRange( emitterAttr.min, emitterAttr.max ); + for (let i = this.attributeCount - 1; i >= 0; --i) { + key = keys[i]; + emitterAttr = emitterRanges[key]; + attr = attrs[key]; + attr.setUpdateRange(emitterAttr.min, emitterAttr.max); attr.flagUpdate(); } }; - /** * Simulate all the emitter's belonging to this group, updating * attribute values along the way. * @param {Number} [dt=Group's `fixedTimeStep` value] The number of seconds to simulate the group's emitters for (deltaTime) */ -SPE.Group.prototype.tick = function( dt ) { - 'use strict'; +SPE.Group.prototype.tick = function (dt) { + "use strict"; - var emitters = this.emitters, - numEmitters = emitters.length, - deltaTime = dt || this.fixedTimeStep, - keys = this.attributeKeys, - i, - attrs = this.attributes; + let emitters = this.emitters; + let numEmitters = emitters.length; + let deltaTime = dt || this.fixedTimeStep; + let keys = this.attributeKeys; + let i; + let attrs = this.attributes; // Update uniform values. - this._updateUniforms( deltaTime ); + this._updateUniforms(deltaTime); // Reset buffer update ranges on the shader attributes. this._resetBufferRanges(); - // If nothing needs updating, then stop here. - if ( - numEmitters === 0 && - this._attributesNeedRefresh === false && - this._attributesNeedDynamicReset === false - ) { + if (numEmitters === 0 && this._attributesNeedRefresh === false && this._attributesNeedDynamicReset === false) { return; } // Loop through each emitter in this group and // simulate it, then update the shader attribute // buffers. - for ( var i = 0, emitter; i < numEmitters; ++i ) { - emitter = emitters[ i ]; - emitter.tick( deltaTime ); - this._updateBuffers( emitter ); + for (let i = 0, emitter; i < numEmitters; ++i) { + emitter = emitters[i]; + emitter.tick(deltaTime); + this._updateBuffers(emitter); } // If the shader attributes have been refreshed, // then the dynamic properties of each buffer // attribute will need to be reset back to // what they should be. - if ( this._attributesNeedDynamicReset === true ) { - i = this.attributeCount - 1; + if (this._attributesNeedDynamicReset === true) { - for ( i; i >= 0; --i ) { - attrs[ keys[ i ] ].resetDynamic(); + for (let i = this.attributeCount - 1; i >= 0; --i) { + attrs[keys[i]].resetDynamic(); } this._attributesNeedDynamicReset = false; @@ -2569,11 +2555,10 @@ SPE.Group.prototype.tick = function( dt ) { // If this group's shader attributes need a full refresh // then mark each attribute's buffer attribute as // needing so. - if ( this._attributesNeedRefresh === true ) { - i = this.attributeCount - 1; + if (this._attributesNeedRefresh === true) { - for ( i; i >= 0; --i ) { - attrs[ keys[ i ] ].forceUpdateAll(); + for (let i = this.attributeCount - 1; i >= 0; --i) { + attrs[keys[i]].forceUpdateAll(); } this._attributesNeedRefresh = false; @@ -2581,14 +2566,13 @@ SPE.Group.prototype.tick = function( dt ) { } }; - /** * Dipose the geometry and material for the group. * * @return {Group} Group instance. */ -SPE.Group.prototype.dispose = function() { - 'use strict'; +SPE.Group.prototype.dispose = function () { + "use strict"; this.geometry.dispose(); this.material.dispose(); return this; @@ -2746,132 +2730,127 @@ SPE.Group.prototype.dispose = function() { * * @param {EmitterOptions} options A map of options to configure the emitter. */ -SPE.Emitter = function( options ) { - 'use strict'; +SPE.Emitter = function (options) { + "use strict"; - var utils = SPE.utils, - types = utils.types, - lifetimeLength = SPE.valueOverLifetimeLength; + let utils = SPE.utils; + let types = utils.types; + let lifetimeLength = SPE.valueOverLifetimeLength; // Ensure we have a map of options to play with, // and that each option is in the correct format. - options = utils.ensureTypedArg( options, types.OBJECT, {} ); - options.position = utils.ensureTypedArg( options.position, types.OBJECT, {} ); - options.velocity = utils.ensureTypedArg( options.velocity, types.OBJECT, {} ); - options.acceleration = utils.ensureTypedArg( options.acceleration, types.OBJECT, {} ); - options.radius = utils.ensureTypedArg( options.radius, types.OBJECT, {} ); - options.drag = utils.ensureTypedArg( options.drag, types.OBJECT, {} ); - options.rotation = utils.ensureTypedArg( options.rotation, types.OBJECT, {} ); - options.color = utils.ensureTypedArg( options.color, types.OBJECT, {} ); - options.opacity = utils.ensureTypedArg( options.opacity, types.OBJECT, {} ); - options.size = utils.ensureTypedArg( options.size, types.OBJECT, {} ); - options.angle = utils.ensureTypedArg( options.angle, types.OBJECT, {} ); - options.wiggle = utils.ensureTypedArg( options.wiggle, types.OBJECT, {} ); - options.maxAge = utils.ensureTypedArg( options.maxAge, types.OBJECT, {} ); - - if ( options.onParticleSpawn ) { - console.warn( 'onParticleSpawn has been removed. Please set properties directly to alter values at runtime.' ); + options = utils.ensureTypedArg(options, types.OBJECT, {}); + options.position = utils.ensureTypedArg(options.position, types.OBJECT, {}); + options.velocity = utils.ensureTypedArg(options.velocity, types.OBJECT, {}); + options.acceleration = utils.ensureTypedArg(options.acceleration, types.OBJECT, {}); + options.radius = utils.ensureTypedArg(options.radius, types.OBJECT, {}); + options.drag = utils.ensureTypedArg(options.drag, types.OBJECT, {}); + options.rotation = utils.ensureTypedArg(options.rotation, types.OBJECT, {}); + options.color = utils.ensureTypedArg(options.color, types.OBJECT, {}); + options.opacity = utils.ensureTypedArg(options.opacity, types.OBJECT, {}); + options.size = utils.ensureTypedArg(options.size, types.OBJECT, {}); + options.angle = utils.ensureTypedArg(options.angle, types.OBJECT, {}); + options.wiggle = utils.ensureTypedArg(options.wiggle, types.OBJECT, {}); + options.maxAge = utils.ensureTypedArg(options.maxAge, types.OBJECT, {}); + + if (options.onParticleSpawn) { + console.warn("onParticleSpawn has been removed. Please set properties directly to alter values at runtime."); } - this.uuid = THREE.Math.generateUUID(); + this.uuid = SPE.utils.generateUUID(); - this.type = utils.ensureTypedArg( options.type, types.NUMBER, SPE.distributions.BOX ); + this.type = utils.ensureTypedArg(options.type, types.NUMBER, SPE.distributions.BOX); // Start assigning properties...kicking it off with props that DON'T support values over // lifetimes. // // Btw, values over lifetimes are just the new way of referring to *Start, *Middle, and *End. this.position = { - _value: utils.ensureInstanceOf( options.position.value, THREE.Vector3, new THREE.Vector3() ), - _spread: utils.ensureInstanceOf( options.position.spread, THREE.Vector3, new THREE.Vector3() ), - _spreadClamp: utils.ensureInstanceOf( options.position.spreadClamp, THREE.Vector3, new THREE.Vector3() ), - _distribution: utils.ensureTypedArg( options.position.distribution, types.NUMBER, this.type ), - _randomise: utils.ensureTypedArg( options.position.randomise, types.BOOLEAN, false ), - _radius: utils.ensureTypedArg( options.position.radius, types.NUMBER, 10 ), - _radiusScale: utils.ensureInstanceOf( options.position.radiusScale, THREE.Vector3, new THREE.Vector3( 1, 1, 1 ) ), - _distributionClamp: utils.ensureTypedArg( options.position.distributionClamp, types.NUMBER, 0 ), + _value: utils.ensureInstanceOf(options.position.value, THREE.Vector3, new THREE.Vector3()), + _spread: utils.ensureInstanceOf(options.position.spread, THREE.Vector3, new THREE.Vector3()), + _spreadClamp: utils.ensureInstanceOf(options.position.spreadClamp, THREE.Vector3, new THREE.Vector3()), + _distribution: utils.ensureTypedArg(options.position.distribution, types.NUMBER, this.type), + _randomise: utils.ensureTypedArg(options.position.randomise, types.BOOLEAN, false), + _radius: utils.ensureTypedArg(options.position.radius, types.NUMBER, 10), + _radiusScale: utils.ensureInstanceOf(options.position.radiusScale, THREE.Vector3, new THREE.Vector3(1, 1, 1)), + _distributionClamp: utils.ensureTypedArg(options.position.distributionClamp, types.NUMBER, 0), }; this.velocity = { - _value: utils.ensureInstanceOf( options.velocity.value, THREE.Vector3, new THREE.Vector3() ), - _spread: utils.ensureInstanceOf( options.velocity.spread, THREE.Vector3, new THREE.Vector3() ), - _distribution: utils.ensureTypedArg( options.velocity.distribution, types.NUMBER, this.type ), - _randomise: utils.ensureTypedArg( options.position.randomise, types.BOOLEAN, false ) + _value: utils.ensureInstanceOf(options.velocity.value, THREE.Vector3, new THREE.Vector3()), + _spread: utils.ensureInstanceOf(options.velocity.spread, THREE.Vector3, new THREE.Vector3()), + _distribution: utils.ensureTypedArg(options.velocity.distribution, types.NUMBER, this.type), + _randomise: utils.ensureTypedArg(options.position.randomise, types.BOOLEAN, false), }; this.acceleration = { - _value: utils.ensureInstanceOf( options.acceleration.value, THREE.Vector3, new THREE.Vector3() ), - _spread: utils.ensureInstanceOf( options.acceleration.spread, THREE.Vector3, new THREE.Vector3() ), - _distribution: utils.ensureTypedArg( options.acceleration.distribution, types.NUMBER, this.type ), - _randomise: utils.ensureTypedArg( options.position.randomise, types.BOOLEAN, false ) + _value: utils.ensureInstanceOf(options.acceleration.value, THREE.Vector3, new THREE.Vector3()), + _spread: utils.ensureInstanceOf(options.acceleration.spread, THREE.Vector3, new THREE.Vector3()), + _distribution: utils.ensureTypedArg(options.acceleration.distribution, types.NUMBER, this.type), + _randomise: utils.ensureTypedArg(options.position.randomise, types.BOOLEAN, false), }; this.drag = { - _value: utils.ensureTypedArg( options.drag.value, types.NUMBER, 0 ), - _spread: utils.ensureTypedArg( options.drag.spread, types.NUMBER, 0 ), - _randomise: utils.ensureTypedArg( options.position.randomise, types.BOOLEAN, false ) + _value: utils.ensureTypedArg(options.drag.value, types.NUMBER, 0), + _spread: utils.ensureTypedArg(options.drag.spread, types.NUMBER, 0), + _randomise: utils.ensureTypedArg(options.position.randomise, types.BOOLEAN, false), }; this.wiggle = { - _value: utils.ensureTypedArg( options.wiggle.value, types.NUMBER, 0 ), - _spread: utils.ensureTypedArg( options.wiggle.spread, types.NUMBER, 0 ) + _value: utils.ensureTypedArg(options.wiggle.value, types.NUMBER, 0), + _spread: utils.ensureTypedArg(options.wiggle.spread, types.NUMBER, 0), }; this.rotation = { - _axis: utils.ensureInstanceOf( options.rotation.axis, THREE.Vector3, new THREE.Vector3( 0.0, 1.0, 0.0 ) ), - _axisSpread: utils.ensureInstanceOf( options.rotation.axisSpread, THREE.Vector3, new THREE.Vector3() ), - _angle: utils.ensureTypedArg( options.rotation.angle, types.NUMBER, 0 ), - _angleSpread: utils.ensureTypedArg( options.rotation.angleSpread, types.NUMBER, 0 ), - _static: utils.ensureTypedArg( options.rotation.static, types.BOOLEAN, false ), - _center: utils.ensureInstanceOf( options.rotation.center, THREE.Vector3, this.position._value.clone() ), - _randomise: utils.ensureTypedArg( options.position.randomise, types.BOOLEAN, false ) + _axis: utils.ensureInstanceOf(options.rotation.axis, THREE.Vector3, new THREE.Vector3(0.0, 1.0, 0.0)), + _axisSpread: utils.ensureInstanceOf(options.rotation.axisSpread, THREE.Vector3, new THREE.Vector3()), + _angle: utils.ensureTypedArg(options.rotation.angle, types.NUMBER, 0), + _angleSpread: utils.ensureTypedArg(options.rotation.angleSpread, types.NUMBER, 0), + _static: utils.ensureTypedArg(options.rotation.static, types.BOOLEAN, false), + _center: utils.ensureInstanceOf(options.rotation.center, THREE.Vector3, this.position._value.clone()), + _randomise: utils.ensureTypedArg(options.position.randomise, types.BOOLEAN, false), }; - this.maxAge = { - _value: utils.ensureTypedArg( options.maxAge.value, types.NUMBER, 2 ), - _spread: utils.ensureTypedArg( options.maxAge.spread, types.NUMBER, 0 ) + _value: utils.ensureTypedArg(options.maxAge.value, types.NUMBER, 2), + _spread: utils.ensureTypedArg(options.maxAge.spread, types.NUMBER, 0), }; - - // The following properties can support either single values, or an array of values that change // the property over a particle's lifetime (value over lifetime). this.color = { - _value: utils.ensureArrayInstanceOf( options.color.value, THREE.Color, new THREE.Color() ), - _spread: utils.ensureArrayInstanceOf( options.color.spread, THREE.Vector3, new THREE.Vector3() ), - _randomise: utils.ensureTypedArg( options.position.randomise, types.BOOLEAN, false ) + _value: utils.ensureArrayInstanceOf(options.color.value, THREE.Color, new THREE.Color()), + _spread: utils.ensureArrayInstanceOf(options.color.spread, THREE.Vector3, new THREE.Vector3()), + _randomise: utils.ensureTypedArg(options.position.randomise, types.BOOLEAN, false), }; this.opacity = { - _value: utils.ensureArrayTypedArg( options.opacity.value, types.NUMBER, 1 ), - _spread: utils.ensureArrayTypedArg( options.opacity.spread, types.NUMBER, 0 ), - _randomise: utils.ensureTypedArg( options.position.randomise, types.BOOLEAN, false ) + _value: utils.ensureArrayTypedArg(options.opacity.value, types.NUMBER, 1), + _spread: utils.ensureArrayTypedArg(options.opacity.spread, types.NUMBER, 0), + _randomise: utils.ensureTypedArg(options.position.randomise, types.BOOLEAN, false), }; this.size = { - _value: utils.ensureArrayTypedArg( options.size.value, types.NUMBER, 1 ), - _spread: utils.ensureArrayTypedArg( options.size.spread, types.NUMBER, 0 ), - _randomise: utils.ensureTypedArg( options.position.randomise, types.BOOLEAN, false ) + _value: utils.ensureArrayTypedArg(options.size.value, types.NUMBER, 1), + _spread: utils.ensureArrayTypedArg(options.size.spread, types.NUMBER, 0), + _randomise: utils.ensureTypedArg(options.position.randomise, types.BOOLEAN, false), }; this.angle = { - _value: utils.ensureArrayTypedArg( options.angle.value, types.NUMBER, 0 ), - _spread: utils.ensureArrayTypedArg( options.angle.spread, types.NUMBER, 0 ), - _randomise: utils.ensureTypedArg( options.position.randomise, types.BOOLEAN, false ) + _value: utils.ensureArrayTypedArg(options.angle.value, types.NUMBER, 0), + _spread: utils.ensureArrayTypedArg(options.angle.spread, types.NUMBER, 0), + _randomise: utils.ensureTypedArg(options.position.randomise, types.BOOLEAN, false), }; - // Assign renaining option values. - this.particleCount = utils.ensureTypedArg( options.particleCount, types.NUMBER, 100 ); - this.duration = utils.ensureTypedArg( options.duration, types.NUMBER, null ); - this.isStatic = utils.ensureTypedArg( options.isStatic, types.BOOLEAN, false ); - this.activeMultiplier = utils.ensureTypedArg( options.activeMultiplier, types.NUMBER, 1 ); - this.direction = utils.ensureTypedArg( options.direction, types.NUMBER, 1 ); + this.particleCount = utils.ensureTypedArg(options.particleCount, types.NUMBER, 100); + this.duration = utils.ensureTypedArg(options.duration, types.NUMBER, null); + this.isStatic = utils.ensureTypedArg(options.isStatic, types.BOOLEAN, false); + this.activeMultiplier = utils.ensureTypedArg(options.activeMultiplier, types.NUMBER, 1); + this.direction = utils.ensureTypedArg(options.direction, types.NUMBER, 1); // Whether this emitter is alive or not. - this.alive = utils.ensureTypedArg( options.alive, types.BOOLEAN, true ); - + this.alive = utils.ensureTypedArg(options.alive, types.BOOLEAN, true); // The following properties are set internally and are not // user-controllable. @@ -2888,8 +2867,6 @@ SPE.Emitter = function( options ) { // The end of the range in the attribute buffers this.attributeEnd = 0; - - // Holds the time the emitter has been alive for. this.age = 0.0; @@ -2923,17 +2900,19 @@ SPE.Emitter = function( options ) { this.resetFlags = { // params: utils.ensureTypedArg( options.maxAge.randomise, types.BOOLEAN, !!options.maxAge.spread ) || // utils.ensureTypedArg( options.wiggle.randomise, types.BOOLEAN, !!options.wiggle.spread ), - position: utils.ensureTypedArg( options.position.randomise, types.BOOLEAN, false ) || - utils.ensureTypedArg( options.radius.randomise, types.BOOLEAN, false ), - velocity: utils.ensureTypedArg( options.velocity.randomise, types.BOOLEAN, false ), - acceleration: utils.ensureTypedArg( options.acceleration.randomise, types.BOOLEAN, false ) || - utils.ensureTypedArg( options.drag.randomise, types.BOOLEAN, false ), - rotation: utils.ensureTypedArg( options.rotation.randomise, types.BOOLEAN, false ), - rotationCenter: utils.ensureTypedArg( options.rotation.randomise, types.BOOLEAN, false ), - size: utils.ensureTypedArg( options.size.randomise, types.BOOLEAN, false ), - color: utils.ensureTypedArg( options.color.randomise, types.BOOLEAN, false ), - opacity: utils.ensureTypedArg( options.opacity.randomise, types.BOOLEAN, false ), - angle: utils.ensureTypedArg( options.angle.randomise, types.BOOLEAN, false ) + position: + utils.ensureTypedArg(options.position.randomise, types.BOOLEAN, false) || + utils.ensureTypedArg(options.radius.randomise, types.BOOLEAN, false), + velocity: utils.ensureTypedArg(options.velocity.randomise, types.BOOLEAN, false), + acceleration: + utils.ensureTypedArg(options.acceleration.randomise, types.BOOLEAN, false) || + utils.ensureTypedArg(options.drag.randomise, types.BOOLEAN, false), + rotation: utils.ensureTypedArg(options.rotation.randomise, types.BOOLEAN, false), + rotationCenter: utils.ensureTypedArg(options.rotation.randomise, types.BOOLEAN, false), + size: utils.ensureTypedArg(options.size.randomise, types.BOOLEAN, false), + color: utils.ensureTypedArg(options.color.randomise, types.BOOLEAN, false), + opacity: utils.ensureTypedArg(options.opacity.randomise, types.BOOLEAN, false), + angle: utils.ensureTypedArg(options.angle.randomise, types.BOOLEAN, false), }; this.updateFlags = {}; @@ -2942,24 +2921,24 @@ SPE.Emitter = function( options ) { // A map to indicate which emitter parameters should update // which attribute. this.updateMap = { - maxAge: 'params', - position: 'position', - velocity: 'velocity', - acceleration: 'acceleration', - drag: 'acceleration', - wiggle: 'params', - rotation: 'rotation', - size: 'size', - color: 'color', - opacity: 'opacity', - angle: 'angle' + maxAge: "params", + position: "position", + velocity: "velocity", + acceleration: "acceleration", + drag: "acceleration", + wiggle: "params", + rotation: "rotation", + size: "size", + color: "color", + opacity: "opacity", + angle: "angle", }; - for ( var i in this.updateMap ) { - if ( this.updateMap.hasOwnProperty( i ) ) { - this.updateCounts[ this.updateMap[ i ] ] = 0.0; - this.updateFlags[ this.updateMap[ i ] ] = false; - this._createGetterSetters( this[ i ], i ); + for (let i in this.updateMap) { + if (this.updateMap.hasOwnProperty(i)) { + this.updateCounts[this.updateMap[i]] = 0.0; + this.updateFlags[this.updateMap[i]] = false; + this._createGetterSetters(this[i], i); } } @@ -2967,148 +2946,141 @@ SPE.Emitter = function( options ) { this.attributeKeys = null; this.attributeCount = 0; - // Ensure that the value-over-lifetime property objects above // have value and spread properties that are of the same length. // // Also, for now, make sure they have a length of 3 (min/max arguments here). - utils.ensureValueOverLifetimeCompliance( this.color, lifetimeLength, lifetimeLength ); - utils.ensureValueOverLifetimeCompliance( this.opacity, lifetimeLength, lifetimeLength ); - utils.ensureValueOverLifetimeCompliance( this.size, lifetimeLength, lifetimeLength ); - utils.ensureValueOverLifetimeCompliance( this.angle, lifetimeLength, lifetimeLength ); + utils.ensureValueOverLifetimeCompliance(this.color, lifetimeLength, lifetimeLength); + utils.ensureValueOverLifetimeCompliance(this.opacity, lifetimeLength, lifetimeLength); + utils.ensureValueOverLifetimeCompliance(this.size, lifetimeLength, lifetimeLength); + utils.ensureValueOverLifetimeCompliance(this.angle, lifetimeLength, lifetimeLength); }; SPE.Emitter.constructor = SPE.Emitter; -SPE.Emitter.prototype._createGetterSetters = function( propObj, propName ) { - 'use strict'; +SPE.Emitter.prototype._createGetterSetters = function (propObj, propName) { + "use strict"; - var self = this; + let self = this; - for ( var i in propObj ) { - if ( propObj.hasOwnProperty( i ) ) { + for (let i in propObj) { + if (propObj.hasOwnProperty(i)) { + let name = i.replace("_", ""); - var name = i.replace( '_', '' ); - - Object.defineProperty( propObj, name, { - get: ( function( prop ) { - return function() { - return this[ prop ]; + Object.defineProperty(propObj, name, { + get: (function (prop) { + return function () { + return this[prop]; }; - }( i ) ), + })(i), - set: ( function( prop ) { - return function( value ) { - var mapName = self.updateMap[ propName ], - prevValue = this[ prop ], + set: (function (prop) { + return function (value) { + let mapName = self.updateMap[propName], + prevValue = this[prop], length = SPE.valueOverLifetimeLength; - if ( prop === '_rotationCenter' ) { + if (prop === "_rotationCenter") { self.updateFlags.rotationCenter = true; self.updateCounts.rotationCenter = 0.0; - } - else if ( prop === '_randomise' ) { - self.resetFlags[ mapName ] = value; - } - else { - self.updateFlags[ mapName ] = true; - self.updateCounts[ mapName ] = 0.0; + } else if (prop === "_randomise") { + self.resetFlags[mapName] = value; + } else { + self.updateFlags[mapName] = true; + self.updateCounts[mapName] = 0.0; } self.group._updateDefines(); - this[ prop ] = value; + this[prop] = value; // If the previous value was an array, then make // sure the provided value is interpolated correctly. - if ( Array.isArray( prevValue ) ) { - SPE.utils.ensureValueOverLifetimeCompliance( self[ propName ], length, length ); + if (Array.isArray(prevValue)) { + SPE.utils.ensureValueOverLifetimeCompliance(self[propName], length, length); } }; - }( i ) ) - } ); + })(i), + }); } } }; -SPE.Emitter.prototype._setBufferUpdateRanges = function( keys ) { - 'use strict'; +SPE.Emitter.prototype._setBufferUpdateRanges = function (keys) { + "use strict"; this.attributeKeys = keys; this.attributeCount = keys.length; - for ( var i = this.attributeCount - 1; i >= 0; --i ) { - this.bufferUpdateRanges[ keys[ i ] ] = { + for (let i = this.attributeCount - 1; i >= 0; --i) { + this.bufferUpdateRanges[keys[i]] = { min: Number.POSITIVE_INFINITY, - max: Number.NEGATIVE_INFINITY + max: Number.NEGATIVE_INFINITY, }; } }; -SPE.Emitter.prototype._calculatePPSValue = function( groupMaxAge ) { - 'use strict'; - - var particleCount = this.particleCount; +SPE.Emitter.prototype._calculatePPSValue = function (groupMaxAge) { + "use strict"; + let particleCount = this.particleCount; // Calculate the `particlesPerSecond` value for this emitter. It's used // when determining which particles should die and which should live to // see another day. Or be born, for that matter. The "God" property. - if ( this.duration ) { - this.particlesPerSecond = particleCount / ( groupMaxAge < this.duration ? groupMaxAge : this.duration ); - } - else { + if (this.duration) { + this.particlesPerSecond = particleCount / (groupMaxAge < this.duration ? groupMaxAge : this.duration); + } else { this.particlesPerSecond = particleCount / groupMaxAge; } }; -SPE.Emitter.prototype._setAttributeOffset = function( startIndex ) { +SPE.Emitter.prototype._setAttributeOffset = function (startIndex) { this.attributeOffset = startIndex; this.activationIndex = startIndex; this.activationEnd = startIndex + this.particleCount; }; +SPE.Emitter.prototype._assignValue = function (prop, index) { + "use strict"; -SPE.Emitter.prototype._assignValue = function( prop, index ) { - 'use strict'; - - switch ( prop ) { - case 'position': - this._assignPositionValue( index ); + switch (prop) { + case "position": + this._assignPositionValue(index); break; - case 'velocity': - case 'acceleration': - this._assignForceValue( index, prop ); + case "velocity": + case "acceleration": + this._assignForceValue(index, prop); break; - case 'size': - case 'opacity': - this._assignAbsLifetimeValue( index, prop ); + case "size": + case "opacity": + this._assignAbsLifetimeValue(index, prop); break; - case 'angle': - this._assignAngleValue( index ); + case "angle": + this._assignAngleValue(index); break; - case 'params': - this._assignParamsValue( index ); + case "params": + this._assignParamsValue(index); break; - case 'rotation': - this._assignRotationValue( index ); + case "rotation": + this._assignRotationValue(index); break; - case 'color': - this._assignColorValue( index ); + case "color": + this._assignColorValue(index); break; } }; -SPE.Emitter.prototype._assignPositionValue = function( index ) { - 'use strict'; +SPE.Emitter.prototype._assignPositionValue = function (index) { + "use strict"; - var distributions = SPE.distributions, + let distributions = SPE.distributions, utils = SPE.utils, prop = this.position, attr = this.attributes.position, @@ -3116,43 +3088,60 @@ SPE.Emitter.prototype._assignPositionValue = function( index ) { spread = prop._spread, distribution = prop._distribution; - switch ( distribution ) { + switch (distribution) { case distributions.BOX: - utils.randomVector3( attr, index, value, spread, prop._spreadClamp ); + utils.randomVector3(attr, index, value, spread, prop._spreadClamp); break; case distributions.SPHERE: - utils.randomVector3OnSphere( attr, index, value, prop._radius, prop._spread.x, prop._radiusScale, prop._spreadClamp.x, prop._distributionClamp || this.particleCount ); + utils.randomVector3OnSphere( + attr, + index, + value, + prop._radius, + prop._spread.x, + prop._radiusScale, + prop._spreadClamp.x, + prop._distributionClamp || this.particleCount + ); break; case distributions.DISC: - utils.randomVector3OnDisc( attr, index, value, prop._radius, prop._spread.x, prop._radiusScale, prop._spreadClamp.x ); + utils.randomVector3OnDisc( + attr, + index, + value, + prop._radius, + prop._spread.x, + prop._radiusScale, + prop._spreadClamp.x + ); break; case distributions.LINE: - utils.randomVector3OnLine( attr, index, value, spread ); + utils.randomVector3OnLine(attr, index, value, spread); break; } }; -SPE.Emitter.prototype._assignForceValue = function( index, attrName ) { - 'use strict'; +SPE.Emitter.prototype._assignForceValue = function (index, attrName) { + "use strict"; - var distributions = SPE.distributions, - utils = SPE.utils, - prop = this[ attrName ], - value = prop._value, - spread = prop._spread, - distribution = prop._distribution, - pos, - positionX, - positionY, - positionZ, - i; - - switch ( distribution ) { + let distributions = SPE.distributions; + let utils = SPE.utils; + let prop = this[attrName]; + let value = prop._value; + let spread = prop._spread; + let distribution = prop._distribution; + let pos; + let positionX; + let positionY; + let positionZ; + let i; + + switch (distribution) { case distributions.BOX: - utils.randomVector3( this.attributes[ attrName ], index, value, spread ); + utils.randomVector3(this.attributes[attrName], index, value, spread); break; case distributions.SPHERE: @@ -3164,13 +3153,16 @@ SPE.Emitter.prototype._assignForceValue = function( index, attrName ) { // positionX = utils.zeroToEpsilon( pos[ i ], true ); // positionY = utils.zeroToEpsilon( pos[ i + 1 ], true ); // positionZ = utils.zeroToEpsilon( pos[ i + 2 ], true ); - positionX = pos[ i ]; - positionY = pos[ i + 1 ]; - positionZ = pos[ i + 2 ]; + positionX = pos[i]; + positionY = pos[i + 1]; + positionZ = pos[i + 2]; utils.randomDirectionVector3OnSphere( - this.attributes[ attrName ], index, - positionX, positionY, positionZ, + this.attributes[attrName], + index, + positionX, + positionY, + positionZ, this.position._value, prop._value.x, prop._spread.x @@ -3186,13 +3178,16 @@ SPE.Emitter.prototype._assignForceValue = function( index, attrName ) { // positionX = utils.zeroToEpsilon( pos[ i ], true ); // positionY = utils.zeroToEpsilon( pos[ i + 1 ], true ); // positionZ = utils.zeroToEpsilon( pos[ i + 2 ], true ); - positionX = pos[ i ]; - positionY = pos[ i + 1 ]; - positionZ = pos[ i + 2 ]; + positionX = pos[i]; + positionY = pos[i + 1]; + positionZ = pos[i + 2]; utils.randomDirectionVector3OnDisc( - this.attributes[ attrName ], index, - positionX, positionY, positionZ, + this.attributes[attrName], + index, + positionX, + positionY, + positionZ, this.position._value, prop._value.x, prop._spread.x @@ -3200,143 +3195,144 @@ SPE.Emitter.prototype._assignForceValue = function( index, attrName ) { break; case distributions.LINE: - utils.randomVector3OnLine( this.attributes[ attrName ], index, value, spread ); + utils.randomVector3OnLine(this.attributes[attrName], index, value, spread); break; } - if ( attrName === 'acceleration' ) { - var drag = utils.clamp( utils.randomFloat( this.drag._value, this.drag._spread ), 0, 1 ); - this.attributes.acceleration.typedArray.array[ index * 4 + 3 ] = drag; + if (attrName === "acceleration") { + let drag = utils.clamp(utils.randomFloat(this.drag._value, this.drag._spread), 0, 1); + this.attributes.acceleration.typedArray.array[index * 4 + 3] = drag; } }; -SPE.Emitter.prototype._assignAbsLifetimeValue = function( index, propName ) { - 'use strict'; - - var array = this.attributes[ propName ].typedArray, - prop = this[ propName ], - utils = SPE.utils, - value; - - if ( utils.arrayValuesAreEqual( prop._value ) && utils.arrayValuesAreEqual( prop._spread ) ) { - value = Math.abs( utils.randomFloat( prop._value[ 0 ], prop._spread[ 0 ] ) ); - array.setVec4Components( index, value, value, value, value ); - } - else { - array.setVec4Components( index, - Math.abs( utils.randomFloat( prop._value[ 0 ], prop._spread[ 0 ] ) ), - Math.abs( utils.randomFloat( prop._value[ 1 ], prop._spread[ 1 ] ) ), - Math.abs( utils.randomFloat( prop._value[ 2 ], prop._spread[ 2 ] ) ), - Math.abs( utils.randomFloat( prop._value[ 3 ], prop._spread[ 3 ] ) ) +SPE.Emitter.prototype._assignAbsLifetimeValue = function (index, propName) { + "use strict"; + + let array = this.attributes[propName].typedArray; + let prop = this[propName]; + let utils = SPE.utils; + let value; + + if (utils.arrayValuesAreEqual(prop._value) && utils.arrayValuesAreEqual(prop._spread)) { + value = Math.abs(utils.randomFloat(prop._value[0], prop._spread[0])); + array.setVec4Components(index, value, value, value, value); + } else { + array.setVec4Components( + index, + Math.abs(utils.randomFloat(prop._value[0], prop._spread[0])), + Math.abs(utils.randomFloat(prop._value[1], prop._spread[1])), + Math.abs(utils.randomFloat(prop._value[2], prop._spread[2])), + Math.abs(utils.randomFloat(prop._value[3], prop._spread[3])) ); } }; -SPE.Emitter.prototype._assignAngleValue = function( index ) { - 'use strict'; - - var array = this.attributes.angle.typedArray, - prop = this.angle, - utils = SPE.utils, - value; - - if ( utils.arrayValuesAreEqual( prop._value ) && utils.arrayValuesAreEqual( prop._spread ) ) { - value = utils.randomFloat( prop._value[ 0 ], prop._spread[ 0 ] ); - array.setVec4Components( index, value, value, value, value ); - } - else { - array.setVec4Components( index, - utils.randomFloat( prop._value[ 0 ], prop._spread[ 0 ] ), - utils.randomFloat( prop._value[ 1 ], prop._spread[ 1 ] ), - utils.randomFloat( prop._value[ 2 ], prop._spread[ 2 ] ), - utils.randomFloat( prop._value[ 3 ], prop._spread[ 3 ] ) +SPE.Emitter.prototype._assignAngleValue = function (index) { + "use strict"; + + let array = this.attributes.angle.typedArray; + let prop = this.angle; + let utils = SPE.utils; + let value; + + if (utils.arrayValuesAreEqual(prop._value) && utils.arrayValuesAreEqual(prop._spread)) { + value = utils.randomFloat(prop._value[0], prop._spread[0]); + array.setVec4Components(index, value, value, value, value); + } else { + array.setVec4Components( + index, + utils.randomFloat(prop._value[0], prop._spread[0]), + utils.randomFloat(prop._value[1], prop._spread[1]), + utils.randomFloat(prop._value[2], prop._spread[2]), + utils.randomFloat(prop._value[3], prop._spread[3]) ); } }; -SPE.Emitter.prototype._assignParamsValue = function( index ) { - 'use strict'; +SPE.Emitter.prototype._assignParamsValue = function (index) { + "use strict"; - this.attributes.params.typedArray.setVec4Components( index, + this.attributes.params.typedArray.setVec4Components( + index, this.isStatic ? 1 : 0, 0.0, - Math.abs( SPE.utils.randomFloat( this.maxAge._value, this.maxAge._spread ) ), - SPE.utils.randomFloat( this.wiggle._value, this.wiggle._spread ) + Math.abs(SPE.utils.randomFloat(this.maxAge._value, this.maxAge._spread)), + SPE.utils.randomFloat(this.wiggle._value, this.wiggle._spread) ); }; -SPE.Emitter.prototype._assignRotationValue = function( index ) { - 'use strict'; +SPE.Emitter.prototype._assignRotationValue = function (index) { + "use strict"; - this.attributes.rotation.typedArray.setVec3Components( index, - SPE.utils.getPackedRotationAxis( this.rotation._axis, this.rotation._axisSpread ), - SPE.utils.randomFloat( this.rotation._angle, this.rotation._angleSpread ), + this.attributes.rotation.typedArray.setVec3Components( + index, + SPE.utils.getPackedRotationAxis(this.rotation._axis, this.rotation._axisSpread), + SPE.utils.randomFloat(this.rotation._angle, this.rotation._angleSpread), this.rotation._static ? 0 : 1 ); - this.attributes.rotationCenter.typedArray.setVec3( index, this.rotation._center ); + this.attributes.rotationCenter.typedArray.setVec3(index, this.rotation._center); }; -SPE.Emitter.prototype._assignColorValue = function( index ) { - 'use strict'; - SPE.utils.randomColorAsHex( this.attributes.color, index, this.color._value, this.color._spread ); +SPE.Emitter.prototype._assignColorValue = function (index) { + "use strict"; + SPE.utils.randomColorAsHex(this.attributes.color, index, this.color._value, this.color._spread); }; -SPE.Emitter.prototype._resetParticle = function( index ) { - 'use strict'; +SPE.Emitter.prototype._resetParticle = function (index) { + "use strict"; - var resetFlags = this.resetFlags, - updateFlags = this.updateFlags, - updateCounts = this.updateCounts, - keys = this.attributeKeys, - key, - updateFlag; + let resetFlags = this.resetFlags; + let updateFlags = this.updateFlags; + let updateCounts = this.updateCounts; + let keys = this.attributeKeys; + let key; + let updateFlag; - for ( var i = this.attributeCount - 1; i >= 0; --i ) { - key = keys[ i ]; - updateFlag = updateFlags[ key ]; + for (let i = this.attributeCount - 1; i >= 0; --i) { + key = keys[i]; + updateFlag = updateFlags[key]; - if ( resetFlags[ key ] === true || updateFlag === true ) { - this._assignValue( key, index ); - this._updateAttributeUpdateRange( key, index ); + if (resetFlags[key] === true || updateFlag === true) { + this._assignValue(key, index); + this._updateAttributeUpdateRange(key, index); - if ( updateFlag === true && updateCounts[ key ] === this.particleCount ) { - updateFlags[ key ] = false; - updateCounts[ key ] = 0.0; - } - else if ( updateFlag == true ) { - ++updateCounts[ key ]; + if (updateFlag === true && updateCounts[key] === this.particleCount) { + updateFlags[key] = false; + updateCounts[key] = 0.0; + } else if (updateFlag == true) { + ++updateCounts[key]; } } } }; -SPE.Emitter.prototype._updateAttributeUpdateRange = function( attr, i ) { - 'use strict'; +SPE.Emitter.prototype._updateAttributeUpdateRange = function (attr, i) { + "use strict"; - var ranges = this.bufferUpdateRanges[ attr ]; + let ranges = this.bufferUpdateRanges[attr]; - ranges.min = Math.min( i, ranges.min ); - ranges.max = Math.max( i, ranges.max ); + ranges.min = Math.min(i, ranges.min); + ranges.max = Math.max(i, ranges.max); }; -SPE.Emitter.prototype._resetBufferRanges = function() { - 'use strict'; +SPE.Emitter.prototype._resetBufferRanges = function () { + "use strict"; - var ranges = this.bufferUpdateRanges, - keys = this.bufferUpdateKeys, - i = this.bufferUpdateCount - 1, - key; + let ranges = this.bufferUpdateRanges; + let keys = this.bufferUpdateKeys; + let i = this.bufferUpdateCount - 1; + let key; - for ( i; i >= 0; --i ) { - key = keys[ i ]; - ranges[ key ].min = Number.POSITIVE_INFINITY; - ranges[ key ].max = Number.NEGATIVE_INFINITY; + for (let i; i >= 0; --i) { + key = keys[i]; + ranges[key].min = Number.POSITIVE_INFINITY; + ranges[key].max = Number.NEGATIVE_INFINITY; } }; -SPE.Emitter.prototype._onRemove = function() { - 'use strict'; +SPE.Emitter.prototype._onRemove = function () { + "use strict"; // Reset any properties of the emitter that were set by // a group when it was added. this.particlesPerSecond = 0; @@ -3349,68 +3345,75 @@ SPE.Emitter.prototype._onRemove = function() { this.age = 0.0; }; -SPE.Emitter.prototype._decrementParticleCount = function() { - 'use strict'; +SPE.Emitter.prototype._decrementParticleCount = function () { + "use strict"; --this.activeParticleCount; // TODO: // - Trigger event if count === 0. }; -SPE.Emitter.prototype._incrementParticleCount = function() { - 'use strict'; +SPE.Emitter.prototype._incrementParticleCount = function () { + "use strict"; ++this.activeParticleCount; // TODO: // - Trigger event if count === this.particleCount. }; -SPE.Emitter.prototype._checkParticleAges = function( start, end, params, dt ) { - 'use strict'; - for ( var i = end - 1, index, maxAge, age, alive; i >= start; --i ) { +SPE.Emitter.prototype._checkParticleAges = function (start, end, params, dt) { + "use strict"; + + let index; + let maxAge; + let age; + let alive; + + for (let i = end - 1; i >= start; --i) { index = i * 4; - alive = params[ index ]; + alive = params[index]; - if ( alive === 0.0 ) { + if (alive === 0.0) { continue; } // Increment age - age = params[ index + 1 ]; - maxAge = params[ index + 2 ]; + age = params[index + 1]; + maxAge = params[index + 2]; - if ( this.direction === 1 ) { + if (this.direction === 1) { age += dt; - if ( age >= maxAge ) { + if (age >= maxAge) { age = 0.0; alive = 0.0; this._decrementParticleCount(); } - } - else { + } else { age -= dt; - if ( age <= 0.0 ) { + if (age <= 0.0) { age = maxAge; alive = 0.0; this._decrementParticleCount(); } } - params[ index ] = alive; - params[ index + 1 ] = age; + params[index] = alive; + params[index + 1] = age; - this._updateAttributeUpdateRange( 'params', i ); + this._updateAttributeUpdateRange("params", i); } }; -SPE.Emitter.prototype._activateParticles = function( activationStart, activationEnd, params, dtPerParticle ) { - 'use strict'; - var direction = this.direction; +SPE.Emitter.prototype._activateParticles = function (activationStart, activationEnd, params, dtPerParticle) { + "use strict"; + let direction = this.direction; + let index; + let dtValue; - for ( var i = activationStart, index, dtValue; i < activationEnd; ++i ) { + for (let i = activationStart; i < activationEnd; ++i) { index = i * 4; // Don't re-activate particles that aren't dead yet. @@ -3418,7 +3421,7 @@ SPE.Emitter.prototype._activateParticles = function( activationStart, activation // continue; // } - if ( params[ index ] != 0.0 && this.particleCount !== 1 ) { + if (params[index] != 0.0 && this.particleCount !== 1) { continue; } @@ -3426,10 +3429,10 @@ SPE.Emitter.prototype._activateParticles = function( activationStart, activation this._incrementParticleCount(); // Mark the particle as alive. - params[ index ] = 1.0; + params[index] = 1.0; // Reset the particle - this._resetParticle( i ); + this._resetParticle(i); // Move each particle being activated to // it's actual position in time. @@ -3437,10 +3440,10 @@ SPE.Emitter.prototype._activateParticles = function( activationStart, activation // This stops particles being 'clumped' together // when frame rates are on the lower side of 60fps // or not constant (a very real possibility!) - dtValue = dtPerParticle * ( i - activationStart ) - params[ index + 1 ] = direction === -1 ? params[ index + 2 ] - dtValue : dtValue; + dtValue = dtPerParticle * (i - activationStart); + params[index + 1] = direction === -1 ? params[index + 2] - dtValue : dtValue; - this._updateAttributeUpdateRange( 'params', i ); + this._updateAttributeUpdateRange("params", i); } }; @@ -3453,61 +3456,59 @@ SPE.Emitter.prototype._activateParticles = function( activationStart, activation * * @param {Number} dt The number of seconds to simulate (deltaTime) */ -SPE.Emitter.prototype.tick = function( dt ) { - 'use strict'; +SPE.Emitter.prototype.tick = function (dt) { + "use strict"; - if ( this.isStatic ) { + if (this.isStatic) { return; } - if ( this.paramsArray === null ) { + if (this.paramsArray === null) { this.paramsArray = this.attributes.params.typedArray.array; } - var start = this.attributeOffset, - end = start + this.particleCount, - params = this.paramsArray, // vec3( alive, age, maxAge, wiggle ) - ppsDt = this.particlesPerSecond * this.activeMultiplier * dt, - activationIndex = this.activationIndex; + let start = this.attributeOffset; + let end = start + this.particleCount; + let params = this.paramsArray; + let ppsDt = this.particlesPerSecond * this.activeMultiplier * dt; + let activationIndex = this.activationIndex; // Reset the buffer update indices. this._resetBufferRanges(); // Increment age for those particles that are alive, // and kill off any particles whose age is over the limit. - this._checkParticleAges( start, end, params, dt ); + this._checkParticleAges(start, end, params, dt); // If the emitter is dead, reset the age of the emitter to zero, // ready to go again if required - if ( this.alive === false ) { + if (this.alive === false) { this.age = 0.0; return; } // If the emitter has a specified lifetime and we've exceeded it, // mark the emitter as dead. - if ( this.duration !== null && this.age > this.duration ) { + if (this.duration !== null && this.age > this.duration) { this.alive = false; this.age = 0.0; return; } + let activationStart = this.particleCount === 1 ? activationIndex : activationIndex | 0; + let activationEnd = Math.min(activationStart + ppsDt, this.activationEnd); + let activationCount = (activationEnd - this.activationIndex) | 0; + let dtPerParticle = activationCount > 0 ? dt / activationCount : 0; - var activationStart = this.particleCount === 1 ? activationIndex : ( activationIndex | 0 ), - activationEnd = Math.min( activationStart + ppsDt, this.activationEnd ), - activationCount = activationEnd - this.activationIndex | 0, - dtPerParticle = activationCount > 0 ? dt / activationCount : 0; - - this._activateParticles( activationStart, activationEnd, params, dtPerParticle ); + this._activateParticles(activationStart, activationEnd, params, dtPerParticle); // Move the activation window forward, soldier. this.activationIndex += ppsDt; - if ( this.activationIndex > end ) { + if (this.activationIndex > end) { this.activationIndex = start; } - // Increment the age of the emitter. this.age += dt; }; @@ -3520,27 +3521,28 @@ SPE.Emitter.prototype.tick = function( dt ) { * @param {Boolean} [force=undefined] If true, all particles will be marked as dead instantly. * @return {Emitter} This emitter instance. */ -SPE.Emitter.prototype.reset = function( force ) { - 'use strict'; +SPE.Emitter.prototype.reset = function (force) { + "use strict"; this.age = 0.0; this.alive = false; - if ( force === true ) { - var start = this.attributeOffset, - end = start + this.particleCount, - array = this.paramsArray, - attr = this.attributes.params.bufferAttribute; + if (force === true) { + let start = this.attributeOffset; + let end = start + this.particleCount; + let array = this.paramsArray; + let attr = this.attributes.params.bufferAttribute; + let index; - for ( var i = end - 1, index; i >= start; --i ) { + for (let i = end - 1; i >= start; --i) { index = i * 4; - array[ index ] = 0.0; - array[ index + 1 ] = 0.0; + array[index] = 0.0; + array[index + 1] = 0.0; } - attr.updateRange.offset = 0; - attr.updateRange.count = -1; + attr.addUpdateRange.offset = 0; + attr.addUpdateRange.count = -1; attr.needsUpdate = true; } @@ -3553,8 +3555,8 @@ SPE.Emitter.prototype.reset = function( force ) { * * @return {Emitter} This emitter instance. */ -SPE.Emitter.prototype.enable = function() { - 'use strict'; +SPE.Emitter.prototype.enable = function () { + "use strict"; this.alive = true; return this; }; @@ -3567,8 +3569,8 @@ SPE.Emitter.prototype.enable = function() { * * @return {Emitter} This emitter instance. */ -SPE.Emitter.prototype.disable = function() { - 'use strict'; +SPE.Emitter.prototype.disable = function () { + "use strict"; this.alive = false; return this; @@ -3585,14 +3587,14 @@ SPE.Emitter.prototype.disable = function() { * * @see SPE.Group.prototype.removeEmitter */ -SPE.Emitter.prototype.remove = function() { - 'use strict'; - if ( this.group !== null ) { - this.group.removeEmitter( this ); - } - else { - console.error( 'Emitter does not belong to a group, cannot remove.' ); +SPE.Emitter.prototype.remove = function () { + "use strict"; + if (this.group !== null) { + this.group.removeEmitter(this); + } else { + console.error("Emitter does not belong to a group, cannot remove."); } return this; }; +export default SPE; \ No newline at end of file diff --git a/build/SPE.min.js b/build/SPE.min.js index 6cfdcc8..da248be 100644 --- a/build/SPE.min.js +++ b/build/SPE.min.js @@ -1,52 +1,10 @@ -/* shader-particle-engine 1.0.6 +import * as THREE from "three"; + +/* shader-particle-engine 1.1.0 * * (c) 2015 Luke Moody (http://www.github.com/squarefeet) * Originally based on Lee Stemkoski's original work (https://github.com/stemkoski/stemkoski.github.com/blob/master/Three.js/js/ParticleEngine.js). * * shader-particle-engine may be freely distributed under the MIT license (See LICENSE at root of this repository.) */ -var SPE={distributions:{BOX:1,SPHERE:2,DISC:3,LINE:4},valueOverLifetimeLength:4};"function"==typeof define&&define.amd?define("spe",SPE):"undefined"!=typeof exports&&"undefined"!=typeof module&&(module.exports=SPE),SPE.TypedArrayHelper=function(a,b,c,d){"use strict";this.componentSize=c||1,this.size=b||1,this.TypedArrayConstructor=a||Float32Array,this.array=new a(b*this.componentSize),this.indexOffset=d||0},SPE.TypedArrayHelper.constructor=SPE.TypedArrayHelper,SPE.TypedArrayHelper.prototype.setSize=function(a,b){"use strict";var c=this.array.length;return b||(a*=this.componentSize),ac?this.grow(a):void console.info("TypedArray is already of size:",a+".","Will not resize.")},SPE.TypedArrayHelper.prototype.shrink=function(a){"use strict";return this.array=this.array.subarray(0,a),this.size=a,this},SPE.TypedArrayHelper.prototype.grow=function(a){"use strict";var b=this.array,c=new this.TypedArrayConstructor(a);return c.set(b),this.array=c,this.size=a,this}, -SPE.TypedArrayHelper.prototype.splice=function(a,b){"use strict";a*=this.componentSize,b*=this.componentSize;for(var c=[],d=this.array,e=d.length,f=0;f=b)&&c.push(d[f]);return this.setFromArray(0,c),this},SPE.TypedArrayHelper.prototype.setFromArray=function(a,b){"use strict";var c=b.length,d=a+c;return d>this.array.length?this.grow(d):d=81&&(this.bufferAttribute.count=this.bufferAttribute.array.length/this.bufferAttribute.itemSize),void(this.bufferAttribute.needsUpdate=!0);this.bufferAttribute=new THREE.BufferAttribute(this.typedArray.array,this.componentSize),this.bufferAttribute.usage=this.dynamicBuffer?THREE.DynamicDrawUsage:THREE.StaticDrawUsage},SPE.ShaderAttribute.prototype.getLength=function(){"use strict";return null===this.typedArray?0:this.typedArray.array.length},SPE.shaderChunks={ -defines:["#define PACKED_COLOR_SIZE 256.0","#define PACKED_COLOR_DIVISOR 255.0"].join("\n"),uniforms:["uniform float deltaTime;","uniform float runTime;","uniform sampler2D tex;","uniform vec4 textureAnimation;","uniform float scale;"].join("\n"),attributes:["attribute vec4 acceleration;","attribute vec3 velocity;","attribute vec4 rotation;","attribute vec3 rotationCenter;","attribute vec4 params;","attribute vec4 size;","attribute vec4 angle;","attribute vec4 color;","attribute vec4 opacity;"].join("\n"),varyings:["varying vec4 vColor;","#ifdef SHOULD_ROTATE_TEXTURE"," varying float vAngle;","#endif","#ifdef SHOULD_CALCULATE_SPRITE"," varying vec4 vSpriteSheet;","#endif"].join("\n"), -branchAvoidanceFunctions:["float when_gt(float x, float y) {"," return max(sign(x - y), 0.0);","}","float when_lt(float x, float y) {"," return min( max(1.0 - sign(x - y), 0.0), 1.0 );","}","float when_eq( float x, float y ) {"," return 1.0 - abs( sign( x - y ) );","}","float when_ge(float x, float y) {"," return 1.0 - when_lt(x, y);","}","float when_le(float x, float y) {"," return 1.0 - when_gt(x, y);","}","float and(float a, float b) {"," return a * b;","}","float or(float a, float b) {"," return min(a + b, 1.0);","}"].join("\n"),unpackColor:["vec3 unpackColor( in float hex ) {"," vec3 c = vec3( 0.0 );"," float r = mod( (hex / PACKED_COLOR_SIZE / PACKED_COLOR_SIZE), PACKED_COLOR_SIZE );"," float g = mod( (hex / PACKED_COLOR_SIZE), PACKED_COLOR_SIZE );"," float b = mod( hex, PACKED_COLOR_SIZE );"," c.r = r / PACKED_COLOR_DIVISOR;"," c.g = g / PACKED_COLOR_DIVISOR;"," c.b = b / PACKED_COLOR_DIVISOR;"," return c;","}"].join("\n"), -unpackRotationAxis:["vec3 unpackRotationAxis( in float hex ) {"," vec3 c = vec3( 0.0 );"," float r = mod( (hex / PACKED_COLOR_SIZE / PACKED_COLOR_SIZE), PACKED_COLOR_SIZE );"," float g = mod( (hex / PACKED_COLOR_SIZE), PACKED_COLOR_SIZE );"," float b = mod( hex, PACKED_COLOR_SIZE );"," c.r = r / PACKED_COLOR_DIVISOR;"," c.g = g / PACKED_COLOR_DIVISOR;"," c.b = b / PACKED_COLOR_DIVISOR;"," c *= vec3( 2.0 );"," c -= vec3( 1.0 );"," return c;","}"].join("\n"), -floatOverLifetime:["float getFloatOverLifetime( in float positionInTime, in vec4 attr ) {"," highp float value = 0.0;"," float deltaAge = positionInTime * float( VALUE_OVER_LIFETIME_LENGTH - 1 );"," float fIndex = 0.0;"," float shouldApplyValue = 0.0;"," value += attr[ 0 ] * when_eq( deltaAge, 0.0 );",""," for( int i = 0; i < VALUE_OVER_LIFETIME_LENGTH - 1; ++i ) {"," fIndex = float( i );"," shouldApplyValue = and( when_gt( deltaAge, fIndex ), when_le( deltaAge, fIndex + 1.0 ) );"," value += shouldApplyValue * mix( attr[ i ], attr[ i + 1 ], deltaAge - fIndex );"," }",""," return value;","}"].join("\n"), -colorOverLifetime:["vec3 getColorOverLifetime( in float positionInTime, in vec3 color1, in vec3 color2, in vec3 color3, in vec3 color4 ) {"," vec3 value = vec3( 0.0 );"," value.x = getFloatOverLifetime( positionInTime, vec4( color1.x, color2.x, color3.x, color4.x ) );"," value.y = getFloatOverLifetime( positionInTime, vec4( color1.y, color2.y, color3.y, color4.y ) );"," value.z = getFloatOverLifetime( positionInTime, vec4( color1.z, color2.z, color3.z, color4.z ) );"," return value;","}"].join("\n"),paramFetchingFunctions:["float getAlive() {"," return params.x;","}","float getAge() {"," return params.y;","}","float getMaxAge() {"," return params.z;","}","float getWiggle() {"," return params.w;","}"].join("\n"), -forceFetchingFunctions:["vec4 getPosition( in float age ) {"," return modelViewMatrix * vec4( position, 1.0 );","}","vec3 getVelocity( in float age ) {"," return velocity * age;","}","vec3 getAcceleration( in float age ) {"," return acceleration.xyz * age;","}"].join("\n"), -rotationFunctions:["#ifdef SHOULD_ROTATE_PARTICLES"," mat4 getRotationMatrix( in vec3 axis, in float angle) {"," axis = normalize(axis);"," float s = sin(angle);"," float c = cos(angle);"," float oc = 1.0 - c;",""," return mat4(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 0.0,"," oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 0.0,"," oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c, 0.0,"," 0.0, 0.0, 0.0, 1.0);"," }",""," vec3 getRotation( in vec3 pos, in float positionInTime ) {"," if( rotation.y == 0.0 ) {"," return pos;"," }",""," vec3 axis = unpackRotationAxis( rotation.x );"," vec3 center = rotationCenter;"," vec3 translated;"," mat4 rotationMatrix;"," float angle = 0.0;"," angle += when_eq( rotation.z, 0.0 ) * rotation.y;"," angle += when_gt( rotation.z, 0.0 ) * mix( 0.0, rotation.y, positionInTime );"," translated = rotationCenter - pos;"," rotationMatrix = getRotationMatrix( axis, angle );"," return center - vec3( rotationMatrix * vec4( translated, 0.0 ) );"," }","#endif"].join("\n"), -rotateTexture:[" vec2 vUv = vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y );",""," #ifdef SHOULD_ROTATE_TEXTURE"," float x = gl_PointCoord.x - 0.5;"," float y = 1.0 - gl_PointCoord.y - 0.5;"," float c = cos( -vAngle );"," float s = sin( -vAngle );"," vUv = vec2( c * x + s * y + 0.5, c * y - s * x + 0.5 );"," #endif",""," #ifdef SHOULD_CALCULATE_SPRITE"," float framesX = vSpriteSheet.x;"," float framesY = vSpriteSheet.y;"," float columnNorm = vSpriteSheet.z;"," float rowNorm = vSpriteSheet.w;"," vUv.x = gl_PointCoord.x * framesX + columnNorm;"," vUv.y = 1.0 - (gl_PointCoord.y * framesY + rowNorm);"," #endif",""," vec4 rotatedTexture = texture2D( tex, vUv );"].join("\n")},SPE.shaders={ -vertex:[SPE.shaderChunks.defines,SPE.shaderChunks.uniforms,SPE.shaderChunks.attributes,SPE.shaderChunks.varyings,THREE.ShaderChunk.common,THREE.ShaderChunk.logdepthbuf_pars_vertex,THREE.ShaderChunk.fog_pars_vertex,SPE.shaderChunks.branchAvoidanceFunctions,SPE.shaderChunks.unpackColor,SPE.shaderChunks.unpackRotationAxis,SPE.shaderChunks.floatOverLifetime,SPE.shaderChunks.colorOverLifetime,SPE.shaderChunks.paramFetchingFunctions,SPE.shaderChunks.forceFetchingFunctions,SPE.shaderChunks.rotationFunctions,"void main() {"," highp float age = getAge();"," highp float alive = getAlive();"," highp float maxAge = getMaxAge();"," highp float positionInTime = (age / maxAge);"," highp float isAlive = when_gt( alive, 0.0 );"," #ifdef SHOULD_WIGGLE_PARTICLES"," float wiggleAmount = positionInTime * getWiggle();"," float wiggleSin = isAlive * sin( wiggleAmount );"," float wiggleCos = isAlive * cos( wiggleAmount );"," #endif"," vec3 vel = getVelocity( age );"," vec3 accel = getAcceleration( age );"," vec3 force = vec3( 0.0 );"," vec3 pos = vec3( position );"," float drag = 1.0 - (positionInTime * 0.5) * acceleration.w;"," force += vel;"," force *= drag;"," force += accel * age;"," pos += force;"," #ifdef SHOULD_WIGGLE_PARTICLES"," pos.x += wiggleSin;"," pos.y += wiggleCos;"," pos.z += wiggleSin;"," #endif"," #ifdef SHOULD_ROTATE_PARTICLES"," pos = getRotation( pos, positionInTime );"," #endif"," vec4 mvPosition = modelViewMatrix * vec4( pos, 1.0 );"," highp float pointSize = getFloatOverLifetime( positionInTime, size ) * isAlive;"," #ifdef HAS_PERSPECTIVE"," float perspective = scale / length( mvPosition.xyz );"," #else"," float perspective = 1.0;"," #endif"," float pointSizePerspective = pointSize * perspective;"," #ifdef COLORIZE"," vec3 c = isAlive * getColorOverLifetime("," positionInTime,"," unpackColor( color.x ),"," unpackColor( color.y ),"," unpackColor( color.z ),"," unpackColor( color.w )"," );"," #else"," vec3 c = vec3(1.0);"," #endif"," float o = isAlive * getFloatOverLifetime( positionInTime, opacity );"," vColor = vec4( c, o );"," #ifdef SHOULD_ROTATE_TEXTURE"," vAngle = isAlive * getFloatOverLifetime( positionInTime, angle );"," #endif"," #ifdef SHOULD_CALCULATE_SPRITE"," float framesX = textureAnimation.x;"," float framesY = textureAnimation.y;"," float loopCount = textureAnimation.w;"," float totalFrames = textureAnimation.z;"," float frameNumber = mod( (positionInTime * loopCount) * totalFrames, totalFrames );"," float column = floor(mod( frameNumber, framesX ));"," float row = floor( (frameNumber - column) / framesX );"," float columnNorm = column / framesX;"," float rowNorm = row / framesY;"," vSpriteSheet.x = 1.0 / framesX;"," vSpriteSheet.y = 1.0 / framesY;"," vSpriteSheet.z = columnNorm;"," vSpriteSheet.w = rowNorm;"," #endif"," gl_PointSize = pointSizePerspective;"," gl_Position = projectionMatrix * mvPosition;",THREE.ShaderChunk.logdepthbuf_vertex,THREE.ShaderChunk.fog_vertex,"}"].join("\n"), -fragment:[SPE.shaderChunks.uniforms,THREE.ShaderChunk.common,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.logdepthbuf_pars_fragment,SPE.shaderChunks.varyings,SPE.shaderChunks.branchAvoidanceFunctions,"void main() {"," vec3 outgoingLight = vColor.xyz;"," "," #ifdef ALPHATEST"," if ( vColor.w < float(ALPHATEST) ) discard;"," #endif",SPE.shaderChunks.rotateTexture,THREE.ShaderChunk.logdepthbuf_fragment," outgoingLight = vColor.xyz * rotatedTexture.xyz;"," gl_FragColor = vec4( outgoingLight.xyz, rotatedTexture.w * vColor.w );",THREE.ShaderChunk.fog_fragment,"}"].join("\n")},SPE.utils={types:{BOOLEAN:"boolean",STRING:"string",NUMBER:"number",OBJECT:"object"},ensureTypedArg:function(a,b,c){"use strict";return typeof a===b?a:c},ensureArrayTypedArg:function(a,b,c){"use strict";if(Array.isArray(a)){for(var d=a.length-1;d>=0;--d)if(typeof a[d]!==b)return c;return a}return this.ensureTypedArg(a,b,c)},ensureInstanceOf:function(a,b,c){"use strict" -;return void 0!==b&&a instanceof b?a:c},ensureArrayInstanceOf:function(a,b,c){"use strict";if(Array.isArray(a)){for(var d=a.length-1;d>=0;--d)if(void 0!==b&&a[d]instanceof b==!1)return c;return a}return this.ensureInstanceOf(a,b,c)},ensureValueOverLifetimeCompliance:function(a,b,c){"use strict";b=b||3,c=c||3,!1===Array.isArray(a._value)&&(a._value=[a._value]),!1===Array.isArray(a._spread)&&(a._spread=[a._spread]);var d=this.clamp(a._value.length,b,c),e=this.clamp(a._spread.length,b,c),f=Math.max(d,e);a._value.length!==f&&(a._value=this.interpolateArray(a._value,f)),a._spread.length!==f&&(a._spread=this.interpolateArray(a._spread,f))},interpolateArray:function(a,b){"use strict";for(var c=a.length,d=["function"==typeof a[0].clone?a[0].clone():a[0]],e=(c-1)/(b-1),f=1;f-c&&(d=-d),d},lerpTypeAgnostic:function(a,b,c){"use strict";var d,e=this.types;return typeof a===e.NUMBER&&typeof b===e.NUMBER?a+(b-a)*c:a instanceof THREE.Vector2&&b instanceof THREE.Vector2?(d=a.clone(),d.x=this.lerp(a.x,b.x,c),d.y=this.lerp(a.y,b.y,c),d):a instanceof THREE.Vector3&&b instanceof THREE.Vector3?(d=a.clone(),d.x=this.lerp(a.x,b.x,c),d.y=this.lerp(a.y,b.y,c),d.z=this.lerp(a.z,b.z,c),d):a instanceof THREE.Vector4&&b instanceof THREE.Vector4?(d=a.clone(),d.x=this.lerp(a.x,b.x,c),d.y=this.lerp(a.y,b.y,c),d.z=this.lerp(a.z,b.z,c),d.w=this.lerp(a.w,b.w,c),d):a instanceof THREE.Color&&b instanceof THREE.Color?(d=a.clone(),d.r=this.lerp(a.r,b.r,c),d.g=this.lerp(a.g,b.g,c),d.b=this.lerp(a.b,b.b,c),d):void console.warn("Invalid argument types, or argument types do not match:",a,b)},lerp:function(a,b,c){"use strict";return a+(b-a)*c}, -roundToNearestMultiple:function(a,b){"use strict";var c=0;return 0===b?a:(c=Math.abs(a)%b,0===c?a:a<0?-(Math.abs(a)-c):a+b-c)},arrayValuesAreEqual:function(a){"use strict";for(var b=0;b1||this.textureFrames.y>1},this.attributes={position:new SPE.ShaderAttribute("v3",!0),acceleration:new SPE.ShaderAttribute("v4",!0),velocity:new SPE.ShaderAttribute("v3",!0),rotation:new SPE.ShaderAttribute("v4",!0),rotationCenter:new SPE.ShaderAttribute("v3",!0),params:new SPE.ShaderAttribute("v4",!0),size:new SPE.ShaderAttribute("v4",!0),angle:new SPE.ShaderAttribute("v4",!0),color:new SPE.ShaderAttribute("v4",!0),opacity:new SPE.ShaderAttribute("v4",!0)},this.attributeKeys=Object.keys(this.attributes),this.attributeCount=this.attributeKeys.length,this.material=new THREE.ShaderMaterial({uniforms:this.uniforms,vertexShader:SPE.shaders.vertex,fragmentShader:SPE.shaders.fragment,blending:this.blending,transparent:this.transparent,alphaTest:this.alphaTest,depthWrite:this.depthWrite,depthTest:this.depthTest,defines:this.defines,fog:this.fog}), -this.geometry=new THREE.BufferGeometry,this.mesh=new THREE.Points(this.geometry,this.material),null===this.maxParticleCount&&console.warn("SPE.Group: No maxParticleCount specified. Adding emitters after rendering will probably cause errors.")},SPE.Group.constructor=SPE.Group,SPE.Group.prototype._updateDefines=function(){"use strict";var a,b=this.emitters,c=b.length-1,d=this.defines;for(c;c>=0;--c)a=b[c],d.SHOULD_CALCULATE_SPRITE||(d.SHOULD_ROTATE_TEXTURE=d.SHOULD_ROTATE_TEXTURE||!!Math.max(Math.max.apply(null,a.angle.value),Math.max.apply(null,a.angle.spread))),d.SHOULD_ROTATE_PARTICLES=d.SHOULD_ROTATE_PARTICLES||!!Math.max(a.rotation.angle,a.rotation.angleSpread),d.SHOULD_WIGGLE_PARTICLES=d.SHOULD_WIGGLE_PARTICLES||!!Math.max(a.wiggle.value,a.wiggle.spread);this.material.needsUpdate=!0},SPE.Group.prototype._applyAttributesToGeometry=function(){"use strict";var a,b,c=this.attributes,d=this.geometry,e=d.attributes;for(var f in c)c.hasOwnProperty(f)&&(a=c[f],b=e[f], -b?b.array=a.typedArray.array:d.addAttribute(f,a.bufferAttribute),a.bufferAttribute.needsUpdate=!0);this.geometry.setDrawRange(0,this.particleCount)},SPE.Group.prototype.addEmitter=function(a){"use strict";if(a instanceof SPE.Emitter==!1)return void console.error("`emitter` argument must be instance of SPE.Emitter. Was provided with:",a);if(this.emitterIDs.indexOf(a.uuid)>-1)return void console.error("Emitter already exists in this group. Will not add again.");if(null!==a.group)return void console.error("Emitter already belongs to another group. Will not add to requested group.");var b=this.attributes,c=this.particleCount,d=c+a.particleCount;this.particleCount=d,null!==this.maxParticleCount&&this.particleCount>this.maxParticleCount&&console.warn("SPE.Group: maxParticleCount exceeded. Requesting",this.particleCount,"particles, can support only",this.maxParticleCount),a._calculatePPSValue(a.maxAge._value+a.maxAge._spread),a._setBufferUpdateRanges(this.attributeKeys), -a._setAttributeOffset(c),a.group=this,a.attributes=this.attributes;for(var e in b)b.hasOwnProperty(e)&&b[e]._createBufferAttribute(null!==this.maxParticleCount?this.maxParticleCount:this.particleCount);for(var f=c;f1)for(var c=0;c=0;--b)c[a[b]].resetUpdateRange()},SPE.Group.prototype._updateBuffers=function(a){"use strict";var b,c,d,e=this.attributeKeys,f=this.attributeCount-1,g=this.attributes,h=a.bufferUpdateRanges;for(f;f>=0;--f)b=e[f],c=h[b],d=g[b],d.setUpdateRange(c.min,c.max),d.flagUpdate()},SPE.Group.prototype.tick=function(a){"use strict";var b,c=this.emitters,d=c.length,e=a||this.fixedTimeStep,f=this.attributeKeys,g=this.attributes;if(this._updateUniforms(e),this._resetBufferRanges(),0!==d||!1!==this._attributesNeedRefresh||!1!==this._attributesNeedDynamicReset){for(var h,b=0;b=0;--b)g[f[b]].resetDynamic();this._attributesNeedDynamicReset=!1}if(!0===this._attributesNeedRefresh){for(b=this.attributeCount-1;b>=0;--b)g[f[b]].forceUpdateAll();this._attributesNeedRefresh=!1,this._attributesNeedDynamicReset=!0}}}, -SPE.Group.prototype.dispose=function(){"use strict";return this.geometry.dispose(),this.material.dispose(),this},SPE.Emitter=function(a){"use strict";var b=SPE.utils,c=b.types,d=SPE.valueOverLifetimeLength;a=b.ensureTypedArg(a,c.OBJECT,{}),a.position=b.ensureTypedArg(a.position,c.OBJECT,{}),a.velocity=b.ensureTypedArg(a.velocity,c.OBJECT,{}),a.acceleration=b.ensureTypedArg(a.acceleration,c.OBJECT,{}),a.radius=b.ensureTypedArg(a.radius,c.OBJECT,{}),a.drag=b.ensureTypedArg(a.drag,c.OBJECT,{}),a.rotation=b.ensureTypedArg(a.rotation,c.OBJECT,{}),a.color=b.ensureTypedArg(a.color,c.OBJECT,{}),a.opacity=b.ensureTypedArg(a.opacity,c.OBJECT,{}),a.size=b.ensureTypedArg(a.size,c.OBJECT,{}),a.angle=b.ensureTypedArg(a.angle,c.OBJECT,{}),a.wiggle=b.ensureTypedArg(a.wiggle,c.OBJECT,{}),a.maxAge=b.ensureTypedArg(a.maxAge,c.OBJECT,{}),a.onParticleSpawn&&console.warn("onParticleSpawn has been removed. Please set properties directly to alter values at runtime."),this.uuid=THREE.Math.generateUUID(), -this.type=b.ensureTypedArg(a.type,c.NUMBER,SPE.distributions.BOX),this.position={_value:b.ensureInstanceOf(a.position.value,THREE.Vector3,new THREE.Vector3),_spread:b.ensureInstanceOf(a.position.spread,THREE.Vector3,new THREE.Vector3),_spreadClamp:b.ensureInstanceOf(a.position.spreadClamp,THREE.Vector3,new THREE.Vector3),_distribution:b.ensureTypedArg(a.position.distribution,c.NUMBER,this.type),_randomise:b.ensureTypedArg(a.position.randomise,c.BOOLEAN,!1),_radius:b.ensureTypedArg(a.position.radius,c.NUMBER,10),_radiusScale:b.ensureInstanceOf(a.position.radiusScale,THREE.Vector3,new THREE.Vector3(1,1,1)),_distributionClamp:b.ensureTypedArg(a.position.distributionClamp,c.NUMBER,0)},this.velocity={_value:b.ensureInstanceOf(a.velocity.value,THREE.Vector3,new THREE.Vector3),_spread:b.ensureInstanceOf(a.velocity.spread,THREE.Vector3,new THREE.Vector3),_distribution:b.ensureTypedArg(a.velocity.distribution,c.NUMBER,this.type),_randomise:b.ensureTypedArg(a.position.randomise,c.BOOLEAN,!1)}, -this.acceleration={_value:b.ensureInstanceOf(a.acceleration.value,THREE.Vector3,new THREE.Vector3),_spread:b.ensureInstanceOf(a.acceleration.spread,THREE.Vector3,new THREE.Vector3),_distribution:b.ensureTypedArg(a.acceleration.distribution,c.NUMBER,this.type),_randomise:b.ensureTypedArg(a.position.randomise,c.BOOLEAN,!1)},this.drag={_value:b.ensureTypedArg(a.drag.value,c.NUMBER,0),_spread:b.ensureTypedArg(a.drag.spread,c.NUMBER,0),_randomise:b.ensureTypedArg(a.position.randomise,c.BOOLEAN,!1)},this.wiggle={_value:b.ensureTypedArg(a.wiggle.value,c.NUMBER,0),_spread:b.ensureTypedArg(a.wiggle.spread,c.NUMBER,0)},this.rotation={_axis:b.ensureInstanceOf(a.rotation.axis,THREE.Vector3,new THREE.Vector3(0,1,0)),_axisSpread:b.ensureInstanceOf(a.rotation.axisSpread,THREE.Vector3,new THREE.Vector3),_angle:b.ensureTypedArg(a.rotation.angle,c.NUMBER,0),_angleSpread:b.ensureTypedArg(a.rotation.angleSpread,c.NUMBER,0),_static:b.ensureTypedArg(a.rotation.static,c.BOOLEAN,!1), -_center:b.ensureInstanceOf(a.rotation.center,THREE.Vector3,this.position._value.clone()),_randomise:b.ensureTypedArg(a.position.randomise,c.BOOLEAN,!1)},this.maxAge={_value:b.ensureTypedArg(a.maxAge.value,c.NUMBER,2),_spread:b.ensureTypedArg(a.maxAge.spread,c.NUMBER,0)},this.color={_value:b.ensureArrayInstanceOf(a.color.value,THREE.Color,new THREE.Color),_spread:b.ensureArrayInstanceOf(a.color.spread,THREE.Vector3,new THREE.Vector3),_randomise:b.ensureTypedArg(a.position.randomise,c.BOOLEAN,!1)},this.opacity={_value:b.ensureArrayTypedArg(a.opacity.value,c.NUMBER,1),_spread:b.ensureArrayTypedArg(a.opacity.spread,c.NUMBER,0),_randomise:b.ensureTypedArg(a.position.randomise,c.BOOLEAN,!1)},this.size={_value:b.ensureArrayTypedArg(a.size.value,c.NUMBER,1),_spread:b.ensureArrayTypedArg(a.size.spread,c.NUMBER,0),_randomise:b.ensureTypedArg(a.position.randomise,c.BOOLEAN,!1)},this.angle={_value:b.ensureArrayTypedArg(a.angle.value,c.NUMBER,0), -_spread:b.ensureArrayTypedArg(a.angle.spread,c.NUMBER,0),_randomise:b.ensureTypedArg(a.position.randomise,c.BOOLEAN,!1)},this.particleCount=b.ensureTypedArg(a.particleCount,c.NUMBER,100),this.duration=b.ensureTypedArg(a.duration,c.NUMBER,null),this.isStatic=b.ensureTypedArg(a.isStatic,c.BOOLEAN,!1),this.activeMultiplier=b.ensureTypedArg(a.activeMultiplier,c.NUMBER,1),this.direction=b.ensureTypedArg(a.direction,c.NUMBER,1),this.alive=b.ensureTypedArg(a.alive,c.BOOLEAN,!0),this.particlesPerSecond=0,this.activationIndex=0,this.attributeOffset=0,this.attributeEnd=0,this.age=0,this.activeParticleCount=0,this.group=null,this.attributes=null,this.paramsArray=null,this.resetFlags={position:b.ensureTypedArg(a.position.randomise,c.BOOLEAN,!1)||b.ensureTypedArg(a.radius.randomise,c.BOOLEAN,!1),velocity:b.ensureTypedArg(a.velocity.randomise,c.BOOLEAN,!1),acceleration:b.ensureTypedArg(a.acceleration.randomise,c.BOOLEAN,!1)||b.ensureTypedArg(a.drag.randomise,c.BOOLEAN,!1), -rotation:b.ensureTypedArg(a.rotation.randomise,c.BOOLEAN,!1),rotationCenter:b.ensureTypedArg(a.rotation.randomise,c.BOOLEAN,!1),size:b.ensureTypedArg(a.size.randomise,c.BOOLEAN,!1),color:b.ensureTypedArg(a.color.randomise,c.BOOLEAN,!1),opacity:b.ensureTypedArg(a.opacity.randomise,c.BOOLEAN,!1),angle:b.ensureTypedArg(a.angle.randomise,c.BOOLEAN,!1)},this.updateFlags={},this.updateCounts={},this.updateMap={maxAge:"params",position:"position",velocity:"velocity",acceleration:"acceleration",drag:"acceleration",wiggle:"params",rotation:"rotation",size:"size",color:"color",opacity:"opacity",angle:"angle"};for(var e in this.updateMap)this.updateMap.hasOwnProperty(e)&&(this.updateCounts[this.updateMap[e]]=0,this.updateFlags[this.updateMap[e]]=!1,this._createGetterSetters(this[e],e));this.bufferUpdateRanges={},this.attributeKeys=null,this.attributeCount=0,b.ensureValueOverLifetimeCompliance(this.color,d,d),b.ensureValueOverLifetimeCompliance(this.opacity,d,d), -b.ensureValueOverLifetimeCompliance(this.size,d,d),b.ensureValueOverLifetimeCompliance(this.angle,d,d)},SPE.Emitter.constructor=SPE.Emitter,SPE.Emitter.prototype._createGetterSetters=function(a,b){"use strict";var c=this;for(var d in a)if(a.hasOwnProperty(d)){var e=d.replace("_","");Object.defineProperty(a,e,{get:function(a){return function(){return this[a]}}(d),set:function(a){return function(d){var e=c.updateMap[b],f=this[a],g=SPE.valueOverLifetimeLength;"_rotationCenter"===a?(c.updateFlags.rotationCenter=!0,c.updateCounts.rotationCenter=0):"_randomise"===a?c.resetFlags[e]=d:(c.updateFlags[e]=!0,c.updateCounts[e]=0),c.group._updateDefines(),this[a]=d,Array.isArray(f)&&SPE.utils.ensureValueOverLifetimeCompliance(c[b],g,g)}}(d)})}},SPE.Emitter.prototype._setBufferUpdateRanges=function(a){"use strict";this.attributeKeys=a,this.attributeCount=a.length;for(var b=this.attributeCount-1;b>=0;--b)this.bufferUpdateRanges[a[b]]={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY}}, -SPE.Emitter.prototype._calculatePPSValue=function(a){"use strict";var b=this.particleCount;this.duration?this.particlesPerSecond=b/(a=0;--h)b=g[h],c=e[b],!0!==d[b]&&!0!==c||(this._assignValue(b,a),this._updateAttributeUpdateRange(b,a),!0===c&&f[b]===this.particleCount?(e[b]=!1,f[b]=0):1==c&&++f[b])},SPE.Emitter.prototype._updateAttributeUpdateRange=function(a,b){"use strict";var c=this.bufferUpdateRanges[a];c.min=Math.min(b,c.min),c.max=Math.max(b,c.max)},SPE.Emitter.prototype._resetBufferRanges=function(){"use strict";var a,b=this.bufferUpdateRanges,c=this.bufferUpdateKeys,d=this.bufferUpdateCount-1;for(d;d>=0;--d)a=c[d],b[a].min=Number.POSITIVE_INFINITY,b[a].max=Number.NEGATIVE_INFINITY},SPE.Emitter.prototype._onRemove=function(){"use strict";this.particlesPerSecond=0,this.attributeOffset=0,this.activationIndex=0,this.activeParticleCount=0, -this.group=null,this.attributes=null,this.paramsArray=null,this.age=0},SPE.Emitter.prototype._decrementParticleCount=function(){"use strict";--this.activeParticleCount},SPE.Emitter.prototype._incrementParticleCount=function(){"use strict";++this.activeParticleCount},SPE.Emitter.prototype._checkParticleAges=function(a,b,c,d){"use strict";for(var e,f,g,h,i=b-1;i>=a;--i)e=4*i,0!==(h=c[e])&&(g=c[e+1],f=c[e+2],1===this.direction?(g+=d)>=f&&(g=0,h=0,this._decrementParticleCount()):(g-=d)<=0&&(g=f,h=0,this._decrementParticleCount()),c[e]=h,c[e+1]=g,this._updateAttributeUpdateRange("params",i))},SPE.Emitter.prototype._activateParticles=function(a,b,c,d){"use strict";for(var e,f,g=this.direction,h=a;hthis.duration)return this.alive=!1,void(this.age=0);var g=1===this.particleCount?f:0|f,h=Math.min(g+e,this.activationEnd),i=h-this.activationIndex|0,j=i>0?a/i:0;this._activateParticles(g,h,d,j),this.activationIndex+=e,this.activationIndex>c&&(this.activationIndex=b),this.age+=a}},SPE.Emitter.prototype.reset=function(a){"use strict";if(this.age=0,this.alive=!1,!0===a){for(var b,c=this.attributeOffset,d=c+this.particleCount,e=this.paramsArray,f=this.attributes.params.bufferAttribute,g=d-1;g>=c;--g)b=4*g,e[b]=0,e[b+1]=0;f.updateRange.offset=0,f.updateRange.count=-1,f.needsUpdate=!0}return this}, -SPE.Emitter.prototype.enable=function(){"use strict";return this.alive=!0,this},SPE.Emitter.prototype.disable=function(){"use strict";return this.alive=!1,this},SPE.Emitter.prototype.remove=function(){"use strict";return null!==this.group?this.group.removeEmitter(this):console.error("Emitter does not belong to a group, cannot remove."),this}; \ No newline at end of file +import*as THREE from"three";var SPE={distributions:{BOX:1,SPHERE:2,DISC:3,LINE:4},valueOverLifetimeLength:4};"function"==typeof define&&define.amd?define("spe",SPE):"undefined"!=typeof exports&&"undefined"!=typeof module&&(module.exports=SPE),SPE.TypedArrayHelper=function(e,t,r,i){this.componentSize=r||1,this.size=t||1,this.TypedArrayConstructor=e||Float32Array,this.array=new e(t*this.componentSize),this.indexOffset=i||0},SPE.TypedArrayHelper.constructor=SPE.TypedArrayHelper,SPE.TypedArrayHelper.prototype.setSize=function(e,t){var r=this.array.length;return t||(e*=this.componentSize),e=r)&&i.push(a[e]);return this.setFromArray(0,i),this},SPE.TypedArrayHelper.prototype.setFromArray=function(e,t){var r=e+t.length;return r>this.array.length?this.grow(r):r= float(VEC4_SIZE - 1)) return attr[VEC4_SIZE - 1];",""," for( int i = 0; i < VEC4_SIZE - 1; ++i ) {"," float fIndex = float( i );"," float shouldApplyValue = and( when_gt( deltaAge, fIndex ), when_le( deltaAge, fIndex + 1.0 ) );"," if(i <= 3) {"," value += shouldApplyValue * mix( attr[ i ], attr[ i + 1 ], deltaAge - fIndex );"," }"," }",""," return value;","}"].join("\n"),colorOverLifetime:["vec3 getColorOverLifetime( in float positionInTime, in vec3 color1, in vec3 color2, in vec3 color3, in vec3 color4 ) {"," vec3 value = vec3( 0.0 );"," value.x = getFloatOverLifetime( positionInTime, vec4( color1.x, color2.x, color3.x, color4.x ) );"," value.y = getFloatOverLifetime( positionInTime, vec4( color1.y, color2.y, color3.y, color4.y ) );"," value.z = getFloatOverLifetime( positionInTime, vec4( color1.z, color2.z, color3.z, color4.z ) );"," return value;","}"].join("\n"),paramFetchingFunctions:["float getAlive() {"," return params.x;","}","float getAge() {"," return params.y;","}","float getMaxAge() {"," return params.z;","}","float getWiggle() {"," return params.w;","}"].join("\n"),forceFetchingFunctions:["vec4 getPosition( in float age ) {"," return modelViewMatrix * vec4( position, 1.0 );","}","vec3 getVelocity( in float age ) {"," return velocity * age;","}","vec3 getAcceleration( in float age ) {"," return acceleration.xyz * age;","}"].join("\n"),rotationFunctions:["#ifdef SHOULD_ROTATE_PARTICLES"," mat4 getRotationMatrix( in vec3 axis, in float angle) {"," axis = normalize(axis);"," float s = sin(angle);"," float c = cos(angle);"," float oc = 1.0 - c;",""," return mat4(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 0.0,"," oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 0.0,"," oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c, 0.0,"," 0.0, 0.0, 0.0, 1.0);"," }",""," vec3 getRotation( in vec3 pos, in float positionInTime ) {"," if( rotation.y == 0.0 ) {"," return pos;"," }",""," vec3 axis = unpackRotationAxis( rotation.x );"," vec3 center = rotationCenter;"," vec3 translated;"," mat4 rotationMatrix;"," float angle = 0.0;"," angle += when_eq( rotation.z, 0.0 ) * rotation.y;"," angle += when_gt( rotation.z, 0.0 ) * mix( 0.0, rotation.y, positionInTime );"," translated = rotationCenter - pos;"," rotationMatrix = getRotationMatrix( axis, angle );"," return center - vec3( rotationMatrix * vec4( translated, 0.0 ) );"," }","#endif"].join("\n"),rotateTexture:[" vec2 vUv = vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y );",""," #ifdef SHOULD_ROTATE_TEXTURE"," float x = gl_PointCoord.x - 0.5;"," float y = 1.0 - gl_PointCoord.y - 0.5;"," float c = cos( -vAngle );"," float s = sin( -vAngle );"," vUv = vec2( c * x + s * y + 0.5, c * y - s * x + 0.5 );"," #endif",""," #ifdef SHOULD_CALCULATE_SPRITE"," float framesX = vSpriteSheet.x;"," float framesY = vSpriteSheet.y;"," float columnNorm = vSpriteSheet.z;"," float rowNorm = vSpriteSheet.w;"," vUv.x = gl_PointCoord.x * framesX + columnNorm;"," vUv.y = 1.0 - (gl_PointCoord.y * framesY + rowNorm);"," #endif",""," vec4 rotatedTexture = texture2D( tex, vUv );"].join("\n")},SPE.shaders={vertex:[SPE.shaderChunks.defines,SPE.shaderChunks.uniforms,SPE.shaderChunks.attributes,SPE.shaderChunks.varyings,THREE.ShaderChunk.common,THREE.ShaderChunk.logdepthbuf_pars_vertex,THREE.ShaderChunk.fog_pars_vertex,SPE.shaderChunks.branchAvoidanceFunctions,SPE.shaderChunks.unpackColor,SPE.shaderChunks.unpackRotationAxis,SPE.shaderChunks.floatOverLifetime,SPE.shaderChunks.colorOverLifetime,SPE.shaderChunks.paramFetchingFunctions,SPE.shaderChunks.forceFetchingFunctions,SPE.shaderChunks.rotationFunctions,"void main() {"," highp float age = getAge();"," highp float alive = getAlive();"," highp float maxAge = getMaxAge();"," highp float positionInTime = (age / maxAge);"," highp float isAlive = when_gt( alive, 0.0 );"," #ifdef SHOULD_WIGGLE_PARTICLES"," float wiggleAmount = positionInTime * getWiggle();"," float wiggleSin = isAlive * sin( wiggleAmount );"," float wiggleCos = isAlive * cos( wiggleAmount );"," #endif"," vec3 vel = getVelocity( age );"," vec3 accel = getAcceleration( age );"," vec3 force = vec3( 0.0 );"," vec3 pos = vec3( position );"," float drag = 1.0 - (positionInTime * 0.5) * acceleration.w;"," force += vel;"," force *= drag;"," force += accel * age;"," pos += force;"," #ifdef SHOULD_WIGGLE_PARTICLES"," pos.x += wiggleSin;"," pos.y += wiggleCos;"," pos.z += wiggleSin;"," #endif"," #ifdef SHOULD_ROTATE_PARTICLES"," pos = getRotation( pos, positionInTime );"," #endif"," vec4 mvPosition = modelViewMatrix * vec4( pos, 1.0 );"," highp float pointSize = getFloatOverLifetime( positionInTime, size ) * isAlive;"," #ifdef HAS_PERSPECTIVE"," float perspective = scale / length( mvPosition.xyz );"," #else"," float perspective = 1.0;"," #endif"," float pointSizePerspective = pointSize * perspective;"," #ifdef COLORIZE"," vec3 c = isAlive * getColorOverLifetime("," positionInTime,"," unpackColor( color.x ),"," unpackColor( color.y ),"," unpackColor( color.z ),"," unpackColor( color.w )"," );"," #else"," vec3 c = vec3(1.0);"," #endif"," float o = isAlive * getFloatOverLifetime( positionInTime, opacity );"," vColor = vec4( c, o );"," #ifdef SHOULD_ROTATE_TEXTURE"," vAngle = isAlive * getFloatOverLifetime( positionInTime, angle );"," #endif"," #ifdef SHOULD_CALCULATE_SPRITE"," float framesX = textureAnimation.x;"," float framesY = textureAnimation.y;"," float loopCount = textureAnimation.w;"," float totalFrames = textureAnimation.z;"," float frameNumber = mod( (positionInTime * loopCount) * totalFrames, totalFrames );"," float column = floor(mod( frameNumber, framesX ));"," float row = floor( (frameNumber - column) / framesX );"," float columnNorm = column / framesX;"," float rowNorm = row / framesY;"," vSpriteSheet.x = 1.0 / framesX;"," vSpriteSheet.y = 1.0 / framesY;"," vSpriteSheet.z = columnNorm;"," vSpriteSheet.w = rowNorm;"," #endif"," gl_PointSize = pointSizePerspective;"," gl_Position = projectionMatrix * mvPosition;",THREE.ShaderChunk.logdepthbuf_vertex,THREE.ShaderChunk.fog_vertex,"}"].join("\n"),fragment:[SPE.shaderChunks.uniforms,THREE.ShaderChunk.common,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.logdepthbuf_pars_fragment,SPE.shaderChunks.varyings,SPE.shaderChunks.branchAvoidanceFunctions,"void main() {"," vec3 outgoingLight = vColor.xyz;"," "," #ifdef ALPHATEST"," if ( vColor.w < float(ALPHATEST) ) discard;"," #endif",SPE.shaderChunks.rotateTexture,THREE.ShaderChunk.logdepthbuf_fragment," outgoingLight = vColor.xyz * rotatedTexture.xyz;"," gl_FragColor = vec4( outgoingLight.xyz, rotatedTexture.w * vColor.w );",THREE.ShaderChunk.fog_fragment,"}"].join("\n")},SPE.utils={types:{BOOLEAN:"boolean",STRING:"string",NUMBER:"number",OBJECT:"object"},generateUUID:function(){function e(){return(65536|65536*Math.random()).toString(16).substr(1)}return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()},ensureTypedArg:function(e,t,r){return typeof e===t?e:r},ensureArrayTypedArg:function(t,r,i){if(Array.isArray(t)){for(let e=t.length-1;0<=e;--e)if(typeof t[e]!==r)return i;return t}return this.ensureTypedArg(t,r,i)},ensureInstanceOf:function(e,t,r){return void 0!==t&&e instanceof t?e:r},ensureArrayInstanceOf:function(t,r,i){if(Array.isArray(t)){for(let e=t.length-1;0<=e;--e)if(void 0!==r&&t[e]instanceof r==!1)return i;return t}return this.ensureInstanceOf(t,r,i)},ensureValueOverLifetimeCompliance:function(e,t,r){t=t||3,r=r||3,!1===Array.isArray(e._value)&&(e._value=[e._value]),!1===Array.isArray(e._spread)&&(e._spread=[e._spread]);var i=this.clamp(e._value.length,t,r),t=this.clamp(e._spread.length,t,r),r=Math.max(i,t);e._value.length!==r&&(e._value=this.interpolateArray(e._value,r)),e._spread.length!==r&&(e._spread=this.interpolateArray(e._spread,r))},interpolateArray:function(t,r){var e=t.length,i=["function"==typeof t[0].clone?t[0].clone():t[0]],a=(e-1)/(r-1);for(let e=1;e{let s=new THREE.Color;return function(e,t,r,i){var a=r.length,o=[];for(let e=0;e{let u=new THREE.Vector3;return function(e,t,r,i,a,o,n,s){u.copy(o),u.x-=r,u.y-=i,u.z-=a,u.normalize().multiplyScalar(-this.randomFloat(n,s)),e.typedArray.setVec3Components(t,u.x,u.y,u.z)}})(),randomDirectionVector3OnDisc:(()=>{let u=new THREE.Vector3;return function(e,t,r,i,a,o,n,s){u.copy(o),u.x-=r,u.y-=i,u.z-=a,u.normalize().multiplyScalar(-this.randomFloat(n,s)),e.typedArray.setVec3Components(t,u.x,u.y,0)}})(),getPackedRotationAxis:(()=>{let r=new THREE.Vector3,i=new THREE.Vector3,a=new THREE.Color,o=new THREE.Vector3(1,1,1);return function(e,t){return r.copy(e).normalize(),i.copy(t).normalize(),r.x+=.5*-t.x+Math.random()*t.x,r.y+=.5*-t.y+Math.random()*t.y,r.z+=.5*-t.z+Math.random()*t.z,r.normalize().add(o).multiplyScalar(.5),a.setRGB(r.x,r.y,r.z),a.getHex()}})()},SPE.Group=function(e){var t=SPE.utils,r=t.types;(e=t.ensureTypedArg(e,r.OBJECT,{})).texture=t.ensureTypedArg(e.texture,r.OBJECT,{}),this.uuid=SPE.utils.generateUUID(),this.fixedTimeStep=t.ensureTypedArg(e.fixedTimeStep,r.NUMBER,.016),this.texture=t.ensureInstanceOf(e.texture.value,THREE.Texture,null),this.textureFrames=t.ensureInstanceOf(e.texture.frames,THREE.Vector2,new THREE.Vector2(1,1)),this.textureFrameCount=t.ensureTypedArg(e.texture.frameCount,r.NUMBER,this.textureFrames.x*this.textureFrames.y),this.textureLoop=t.ensureTypedArg(e.texture.loop,r.NUMBER,1),this.textureFrames.max(new THREE.Vector2(1,1)),this.hasPerspective=t.ensureTypedArg(e.hasPerspective,r.BOOLEAN,!0),this.colorize=t.ensureTypedArg(e.colorize,r.BOOLEAN,!0),this.maxParticleCount=t.ensureTypedArg(e.maxParticleCount,r.NUMBER,null),this.blending=t.ensureTypedArg(e.blending,r.NUMBER,THREE.AdditiveBlending),this.transparent=t.ensureTypedArg(e.transparent,r.BOOLEAN,!0),this.alphaTest=parseFloat(t.ensureTypedArg(e.alphaTest,r.NUMBER,0)),this.depthWrite=t.ensureTypedArg(e.depthWrite,r.BOOLEAN,!1),this.depthTest=t.ensureTypedArg(e.depthTest,r.BOOLEAN,!0),this.fog=t.ensureTypedArg(e.fog,r.BOOLEAN,!0),this.scale=t.ensureTypedArg(e.scale,r.NUMBER,300),this.emitters=[],this.emitterIDs=[],this._pool=[],this._poolCreationSettings=null,this._createNewWhenPoolEmpty=0,this._attributesNeedRefresh=!1,this._attributesNeedDynamicReset=!1,this.particleCount=0,this.uniforms={tex:{type:"t",value:this.texture},textureAnimation:{type:"v4",value:new THREE.Vector4(this.textureFrames.x,this.textureFrames.y,this.textureFrameCount,Math.max(Math.abs(this.textureLoop),1))},fogColor:{type:"c",value:this.fog?new THREE.Color:null},fogNear:{type:"f",value:10},fogFar:{type:"f",value:200},fogDensity:{type:"f",value:.5},deltaTime:{type:"f",value:0},runTime:{type:"f",value:0},scale:{type:"f",value:this.scale}},this.defines={HAS_PERSPECTIVE:this.hasPerspective,COLORIZE:this.colorize,VALUE_OVER_LIFETIME_LENGTH:SPE.valueOverLifetimeLength,SHOULD_ROTATE_TEXTURE:!1,SHOULD_ROTATE_PARTICLES:!1,SHOULD_WIGGLE_PARTICLES:!1,SHOULD_CALCULATE_SPRITE:1this.maxParticleCount&&console.warn("SPE.Group: maxParticleCount exceeded. Requesting",this.particleCount,"particles, can support only",this.maxParticleCount),t._calculatePPSValue(t.maxAge._value+t.maxAge._spread),t._setBufferUpdateRanges(this.attributeKeys),t._setAttributeOffset(i),t.group=this,t.attributes=this.attributes,r)r.hasOwnProperty(e)&&r[e]._createBufferAttribute(null!==this.maxParticleCount?this.maxParticleCount:this.particleCount);for(let e=i;efunction(){return this[e]})(t),set:(a=>function(e){var t=n.updateMap[o],r=this[a],i=SPE.valueOverLifetimeLength;"_rotationCenter"===a?(n.updateFlags.rotationCenter=!0,n.updateCounts.rotationCenter=0):"_randomise"===a?n.resetFlags[t]=e:(n.updateFlags[t]=!0,n.updateCounts[t]=0),n.group._updateDefines(),this[a]=e,Array.isArray(r)&&SPE.utils.ensureValueOverLifetimeCompliance(n[o],i,i)})(t)}))}},SPE.Emitter.prototype._setBufferUpdateRanges=function(t){this.attributeKeys=t,this.attributeCount=t.length;for(let e=this.attributeCount-1;0<=e;--e)this.bufferUpdateRanges[t[e]]={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY}},SPE.Emitter.prototype._calculatePPSValue=function(e){var t=this.particleCount;this.duration?this.particlesPerSecond=t/(e=t;--e)o=4*e,0!==(u=i[o])&&(s=i[1+o],n=i[2+o],1===this.direction?(s+=a)>=n&&(s=0,u=0,this._decrementParticleCount()):(s-=a)<=0&&(s=n,u=0,this._decrementParticleCount()),i[o]=u,i[1+o]=s,this._updateAttributeUpdateRange("params",e))},SPE.Emitter.prototype._activateParticles=function(t,r,i,a){var o,n,s=this.direction;for(let e=t;ethis.duration?(this.alive=!1,this.age=0):(o=1===this.particleCount?o:0|o,s=(n=Math.min(o+a,this.activationEnd))-this.activationIndex|0,this._activateParticles(o,n,i,0r&&(this.activationIndex=t),this.age+=e))},SPE.Emitter.prototype.reset=function(t){if(this.age=0,!(this.alive=!1)===t){var r,i=this.attributeOffset,t=i+this.particleCount,a=this.paramsArray,e=this.attributes.params.bufferAttribute;for(let e=t-1;e>=i;--e)a[r=4*e]=0,a[1+r]=0;e.addUpdateRange.offset=0,e.addUpdateRange.count=-1,e.needsUpdate=!0}return this},SPE.Emitter.prototype.enable=function(){return this.alive=!0,this},SPE.Emitter.prototype.disable=function(){return this.alive=!1,this},SPE.Emitter.prototype.remove=function(){return null!==this.group?this.group.removeEmitter(this):console.error("Emitter does not belong to a group, cannot remove."),this};export default SPE; \ No newline at end of file diff --git a/docs/MigrationLog.md b/docs/MigrationLog.md index 2bdaa01..9ffc1f4 100644 --- a/docs/MigrationLog.md +++ b/docs/MigrationLog.md @@ -51,7 +51,7 @@ The `texture` property of `SPE.Group` is in a slightly different format, but now ```javascript var group = new SPE.Group( { texture: { - value: THREE.ImageUtils.loadTexture( ... ), + value: THREE.TextureLoader().load( ... ), frames: new THREE.Vector2( 4, 4 ), // Optional. No. frames on x/y axis of texture frameCount: 16, // Optional. If whole texture isn't used, specify the total number of frames the texture has here loop: 2, // Optional. The number of loops the spritesheet should perform during a particle's lifetime. diff --git a/examples/ActiveMultiplier.js b/examples/ActiveMultiplier.js new file mode 100644 index 0000000..fc8aefb --- /dev/null +++ b/examples/ActiveMultiplier.js @@ -0,0 +1,118 @@ +import * as THREE from "three"; +import SPE from "../build/SPE.js"; +import { BasicScene } from "./js/BasicScene.js"; + +export class ActiveMultiplier { + + static init = function () { + let speScene = new BasicScene(75); + let allIn = function (loaded) { + ActiveMultiplier.initExample(loaded, speScene); + }; + speScene.textureLoad(["./img/smokeparticle.png"], allIn); + }; + + static initExample = function (textures, speScene) { + // Setup the scene + let emitter; + let particleGroup; + + function init() { + speScene.camera.position.z = 50; + speScene.camera.lookAt(speScene.scene.position); + + speScene.renderer.setSize(window.innerWidth, window.innerHeight); + speScene.renderer.setClearColor(0x000000); + + speScene.clock = new THREE.Clock(); + } + + // Create particle group and emitter + function initParticles() { + particleGroup = new SPE.Group({ + texture: { + value: textures["./img/smokeparticle.png"], + }, + maxParticleCount: 3000, + }); + + emitter = new SPE.Emitter({ + maxAge: { + value: 2, + }, + position: { + value: new THREE.Vector3(0, 0, 0), + spread: new THREE.Vector3(0, 0, 0), + }, + + acceleration: { + value: new THREE.Vector3(0, -10, 0), + spread: new THREE.Vector3(10, 0, 10), + }, + + velocity: { + value: new THREE.Vector3(0, 15, 0), + spread: new THREE.Vector3(10, 7.5, 10), + }, + + color: { + value: [new THREE.Color("green"), new THREE.Color("red")], + }, + + size: { + value: 1, + }, + + particleCount: 2000, + activeMultiplier: 1, + }); + + particleGroup.addEmitter(emitter); + speScene.scene.add(particleGroup.mesh); + + document.querySelector(".numParticles").textContent = "Total particles: " + emitter.particleCount; + + document.querySelector(".alive-value").addEventListener( + "change", + function (e) { + emitter.activeMultiplier = +this.value; + }, + false + ); + } + + function animate() { + requestAnimationFrame(animate); + + // Use a fixed time-step here to avoid gaps + render(speScene.clock.getDelta()); + + speScene.stats.update(); + } + + function render(dt) { + particleGroup.tick(dt); + speScene.render(); + } + + window.addEventListener( + "resize", + function () { + let w = window.innerWidth, + h = window.innerHeight; + + camera.aspect = w / h; + camera.updateProjectionMatrix(); + + renderer.setSize(w, h); + }, + false + ); + + init(); + initParticles(); + + animate(); + //setTimeout(animate, 0); + }; +} diff --git a/examples/Basic.js b/examples/Basic.js new file mode 100644 index 0000000..6fb0399 --- /dev/null +++ b/examples/Basic.js @@ -0,0 +1,85 @@ +import * as THREE from "three"; +import SPE from "../build/SPE.js"; +import { BasicScene } from "./js/BasicScene.js"; + +export class Basic { + static init = function () { + let speScene = new BasicScene(75); + let allIn = function (loaded) { + Basic.initExample(loaded, speScene); + }; + speScene.textureLoad(["./img/smokeparticle.png"], allIn); + }; + + static initExample(textures, speScene) { + let emitter; + let particleGroup; + // Setup the scene + function init() { + speScene.renderer.setSize(window.innerWidth, window.innerHeight); + speScene.renderer.setClearColor(0x000000); + } + + // Create particle group and emitter + function initParticles() { + particleGroup = new SPE.Group({ + texture: { + value: textures["./img/smokeparticle.png"], + }, + maxParticleCount: 3000, + }); + + emitter = new SPE.Emitter({ + maxAge: { + value: 2, + }, + position: { + value: new THREE.Vector3(0, 0, -50), + spread: new THREE.Vector3(0, 0, 0), + }, + + acceleration: { + value: new THREE.Vector3(0, -10, 0), + spread: new THREE.Vector3(10, 0, 10), + }, + + velocity: { + value: new THREE.Vector3(0, 25, 0), + spread: new THREE.Vector3(10, 7.5, 10), + }, + + color: { + value: [new THREE.Color("white"), new THREE.Color("red")], + }, + + size: { + value: 1, + }, + + particleCount: 2000, + }); + + particleGroup.addEmitter(emitter); + speScene.scene.add(particleGroup.mesh); + + document.querySelector(".numParticles").textContent = "Total particles: " + emitter.particleCount; + } + + function animate() { + requestAnimationFrame(animate); + render(speScene.clock.getDelta()); + speScene.stats.update(); + } + + function render(dt) { + particleGroup.tick(dt); + speScene.render(); + } + + init(); + initParticles(); + + animate(); + //setTimeout(animate, 0); + } +} diff --git a/examples/Clock.js b/examples/Clock.js new file mode 100644 index 0000000..ba5b438 --- /dev/null +++ b/examples/Clock.js @@ -0,0 +1,166 @@ +import * as THREE from "three"; +import SPE from "../build/SPE.js"; +import { BasicScene } from "./js/BasicScene.js"; + +export class Clock { + static init = function () { + let speScene = new BasicScene(75); + let allIn = function (loaded) { + Clock.initExample(loaded, speScene); + }; + speScene.textureLoad(["./img/smokeparticle.png"], allIn); + }; + + static initExample(textures, speScene) { + let group; + let fixedTimeStep = false; + let secondHand; + let minuteHand; + let hourHand; + + (group = new SPE.Group({ + texture: { + value: textures["./img/smokeparticle.png"], + }, + maxParticleCount: 2000, + })), + (secondHand = new SPE.Emitter({ + particleCount: 500, + maxAge: { + value: 2, + }, + position: { + value: new THREE.Vector3(0, 5, 0), + }, + size: { + value: [0, 1], + }, + color: { + value: [new THREE.Color(0, 0, 1), new THREE.Color(1, 1, 0), new THREE.Color(1, 0, 0)], + }, + opacity: { + value: 1, + }, + rotation: { + axis: new THREE.Vector3(0, 0, 1), + angle: 0, + static: false, + center: new THREE.Vector3(), + }, + direction: -1, + })), + (minuteHand = new SPE.Emitter({ + particleCount: 500, + maxAge: { + value: 2, + }, + position: { + value: new THREE.Vector3(0, 7.5, 0), + }, + size: { + value: [0, 2], + }, + color: { + value: [new THREE.Color(0, 0, 1), new THREE.Color(0, 1, 0), new THREE.Color(0, 1, 1)], + }, + opacity: { + value: 1, + }, + rotation: { + axis: new THREE.Vector3(0, 0, 1), + angle: 0, + static: false, + center: new THREE.Vector3(), + }, + direction: -1, + })), + (hourHand = new SPE.Emitter({ + particleCount: 500, + maxAge: { + value: 2, + }, + position: { + value: new THREE.Vector3(0, 10, 0), + }, + size: { + value: [0, 4], + }, + color: { + value: new THREE.Color(0.5, 0.25, 0.9), + }, + opacity: { + value: 1, + }, + rotation: { + axis: new THREE.Vector3(0, 0, 1), + angle: 0, + static: false, + center: new THREE.Vector3(), + }, + direction: -1, + })); + + group.addEmitter(secondHand); + group.addEmitter(minuteHand); + group.addEmitter(hourHand); + + speScene.scene.add(group.mesh); + speScene.camera.position.z = 40; + speScene.camera.lookAt(speScene.scene.position); + speScene.renderer.setSize(window.innerWidth, window.innerHeight); + + var date = new Date(Date.now()); + + function preRender() { + var catchUpSeconds = date.getSeconds(), + catchUpMinutes = date.getMinutes(), + catchUpHours = date.getHours() % 12; + + secondHand.rotation.angle = (catchUpSeconds / 60) * Math.PI * 2; + minuteHand.rotation.angle = (catchUpMinutes / 60) * Math.PI * 2; + hourHand.rotation.angle = (catchUpHours / 12) * Math.PI * 2; + } + + function onAnimate() { + group.tick(!fixedTimeStep ? speScene.clock.getDelta() : undefined); + + date.setTime(Date.now()); + + var seconds = date.getSeconds(), + minutes = date.getMinutes(), + hours = date.getHours() % 12, + fullRotation = Math.PI * 2, + secondAngle = (seconds / 60) * fullRotation, + minuteAngle = (minutes / 60) * fullRotation, + hourAngle = (hours / 12) * fullRotation; + + if (secondAngle !== secondHand.rotation.angle) { + secondHand.rotation.angle = secondAngle; + } + + if (minuteAngle !== minuteHand.rotation.angle) { + minuteHand.rotation.angle = minuteAngle; + } + + if (hourAngle !== hourHand.rotation.angle) { + hourHand.rotation.angle = hourAngle; + } + } + + function animate() { + requestAnimationFrame(animate); + speScene.stats.update(); + + if (typeof onAnimate === "function") { + onAnimate(); + } + speScene.render(); + } + + fixedTimeStep = true; + + preRender(); + animate(); + //setTimeout(animate, 0); + } +} diff --git a/examples/Clouds.js b/examples/Clouds.js new file mode 100644 index 0000000..b6d5958 --- /dev/null +++ b/examples/Clouds.js @@ -0,0 +1,91 @@ +import * as THREE from "three"; +import SPE from "../build/SPE.js"; +import { BasicScene } from "./js/BasicScene.js"; + +export class Clouds { + static init = function () { + let speScene = new BasicScene(75); + let allIn = function (loaded) { + Clouds.initExample(loaded, speScene); + }; + speScene.textureLoad(["./img/cloud.png"], allIn); + }; + + static initExample(textures, speScene) { + let emitter; + let particleGroup; + // Setup the scene + function init() { + speScene.renderer.setSize(window.innerWidth, window.innerHeight); + speScene.renderer.setClearColor(0x42c7ff); + + let color = new THREE.Color(); + speScene.scene.fog = new THREE.Fog(speScene.renderer.getClearColor(color), 20, 0); + } + + // Create particle group and emitter + function initParticles() { + particleGroup = new SPE.Group({ + texture: { + value: textures["./img/cloud.png"], + }, + maxParticleCount: 3000, + blending: THREE.NormalBlending, + fog: true, + }); + + emitter = new SPE.Emitter({ + particleCount: 750, + maxAge: { + value: 3, + }, + position: { + value: new THREE.Vector3(0, -15, -50), + spread: new THREE.Vector3(100, 30, 100), + }, + velocity: { + value: new THREE.Vector3(0, 0, 30), + }, + wiggle: { + spread: 10, + }, + size: { + value: 75, + spread: 50, + }, + opacity: { + value: [0, 1, 0], + }, + color: { + value: new THREE.Color(1, 1, 1), + spread: new THREE.Color(0.1, 0.1, 0.1), + }, + angle: { + value: [0, Math.PI * 0.125], + }, + }); + + particleGroup.addEmitter(emitter); + speScene.scene.add(particleGroup.mesh); + + document.querySelector(".numParticles").textContent = "Total particles: " + emitter.particleCount; + } + + function animate() { + requestAnimationFrame(animate); + render(speScene.clock.getDelta()); + speScene.stats.update(); + } + + function render(dt) { + particleGroup.tick(dt); + speScene.render(); + } + + init(); + initParticles(); + + animate(); + //setTimeout(animate, 0); + } +} diff --git a/examples/Distributions.js b/examples/Distributions.js new file mode 100644 index 0000000..0bcdaf2 --- /dev/null +++ b/examples/Distributions.js @@ -0,0 +1,211 @@ +import * as THREE from "three"; +import SPE from "../build/SPE.js"; +import { BasicScene } from "./js/BasicScene.js"; + +export class Distributions { + static init = function () { + let speScene = new BasicScene(75); + let allIn = function (loaded) { + Distributions.initExample(loaded, speScene); + }; + speScene.textureLoad(["./img/smokeparticle.png"], allIn); + }; + + static initExample(textures, speScene) { + let particleGroup; + // Setup the scene + function init() { + speScene.camera.lookAt(speScene.scene.position); + + speScene.renderer.setSize(window.innerWidth, window.innerHeight); + speScene.renderer.setClearColor(0x000000); + } + + // Create particle group and emitter + function initParticles() { + particleGroup = new SPE.Group({ + texture: { + value: textures["./img/smokeparticle.png"], + }, + maxParticleCount: 5000, + }); + + // General distributions. + for (let i = 1; i < 4; ++i) { + let emitter = new SPE.Emitter({ + type: i, + maxAge: { + value: 1, + }, + position: { + value: new THREE.Vector3(-50 + i * 25, 40, 0), + radius: 5, + spread: new THREE.Vector3(3, 3, 3), + }, + + color: { + value: [new THREE.Color("white"), new THREE.Color("red")], + }, + + size: { + value: 1, + }, + isStatic: true, + particleCount: 250, + }); + + particleGroup.addEmitter(emitter); + } + + // Spread clamping. + for (let i = 1; i < 4; ++i) { + let emitter = new SPE.Emitter({ + type: i, + maxAge: { + value: 1, + }, + position: { + value: new THREE.Vector3(-50 + i * 25, 20, 0), + radius: 4, + spread: new THREE.Vector3(5, 5, 5), + spreadClamp: new THREE.Vector3(2, 2, 2), + }, + + color: { + value: [new THREE.Color("white"), new THREE.Color("red")], + }, + + size: { + value: 1, + }, + isStatic: true, + + particleCount: 500, + }); + + particleGroup.addEmitter(emitter); + } + + // Spherical velocity distributions. + for (let i = 1; i < 4; ++i) { + let emitter = new SPE.Emitter({ + type: i, + maxAge: { + value: 1, + }, + position: { + value: new THREE.Vector3(-50 + i * 25, 0, 0), + radius: 5, + spread: i === 1 ? new THREE.Vector3(3, 3, 3) : undefined, + }, + + velocity: { + value: new THREE.Vector3(3, 3, 3), + distribution: SPE.distributions.SPHERE, + }, + + color: { + value: [new THREE.Color("white"), new THREE.Color("red")], + }, + + size: { + value: 1, + }, + + particleCount: 250, + }); + + particleGroup.addEmitter(emitter); + } + + // Disc velocity distributions. + for (let i = 1; i < 4; ++i) { + let emitter = new SPE.Emitter({ + type: i, + maxAge: { + value: 1, + }, + position: { + value: new THREE.Vector3(-50 + i * 25, -20, 0), + radius: 5, + spread: i === 1 ? new THREE.Vector3(3, 3, 3) : undefined, + }, + + velocity: { + value: new THREE.Vector3(3, 3, 3), + distribution: SPE.distributions.DISC, + }, + + color: { + value: [new THREE.Color("white"), new THREE.Color("red")], + }, + + size: { + value: 1, + }, + + particleCount: 250, + }); + + particleGroup.addEmitter(emitter); + } + + // Box velocity distributions. + for (let i = 1; i < 4; ++i) { + let emitter = new SPE.Emitter({ + type: i, + maxAge: { + value: 1, + }, + position: { + value: new THREE.Vector3(-50 + i * 25, -40, 0), + radius: 5, + spread: i === 1 ? new THREE.Vector3(3, 3, 3) : undefined, + }, + + velocity: { + value: new THREE.Vector3(3, 3, 3), + distribution: SPE.distributions.BOX, + }, + + color: { + value: [new THREE.Color("white"), new THREE.Color("red")], + }, + + size: { + value: 1, + }, + + particleCount: 250, + }); + + particleGroup.addEmitter(emitter); + } + + speScene.scene.add(particleGroup.mesh); + } + + function animate() { + requestAnimationFrame(animate); + + let now = Date.now() * 0.001; + speScene.camera.position.x = Math.sin(now) * 75; + speScene.camera.position.z = Math.cos(now) * 75; + speScene.camera.lookAt(speScene.scene.position); + + render(speScene.clock.getDelta()); + speScene.stats.update(); + } + + function render(dt) { + particleGroup.tick(dt); + speScene.render(); + } + + init(); + initParticles(); + + animate(); + //setTimeout(animate, 0); + } +} diff --git a/examples/Explosion.js b/examples/Explosion.js new file mode 100644 index 0000000..9fedf2c --- /dev/null +++ b/examples/Explosion.js @@ -0,0 +1,204 @@ +import * as THREE from "three"; +import SPE from "../build/SPE.js"; +import { BasicScene } from "./js/BasicScene.js"; + +export class Explosion { + static init = function () { + let speScene = new BasicScene(64); + let allIn = function (loaded) { + Explosion.initExample(loaded, speScene); + }; + speScene.textureLoad(["./img/sprite-explosion2.png", "./img/smokeparticle.png"], allIn); + }; + + static initExample(textures, speScene) { + function animate() { + requestAnimationFrame(animate); + speScene.stats.update(); + if (typeof onAnimate === "function") { + onAnimate(); + } + render(); + } + + function render() { + var dt = speScene.clock.getDelta(); + group.tick(); + shockwaveGroup.tick(); + speScene.render(); + } + + speScene.clock.getDelta(); + + var group = new SPE.Group({ + texture: { + value: textures["./img/sprite-explosion2.png"], + frames: new THREE.Vector2(5, 5), + loop: 1, + }, + depthTest: true, + depthWrite: false, + blending: THREE.AdditiveBlending, + scale: 600, + maxParticleCount: 5000, + }), + shockwaveGroup = new SPE.Group({ + texture: { + value: textures["./img/smokeparticle.png"], + }, + depthTest: false, + depthWrite: true, + blending: THREE.NormalBlending, + maxParticleCount: 5000, + }), + shockwave = new SPE.Emitter({ + particleCount: 200, + type: SPE.distributions.DISC, + position: { + radius: 5, + spread: new THREE.Vector3(5), + }, + maxAge: { + value: 2, + spread: 0, + }, + // duration: 1, + activeMultiplier: 2000, + + velocity: { + value: new THREE.Vector3(40), + }, + rotation: { + axis: new THREE.Vector3(1, 0, 0), + angle: Math.PI * 0.5, + static: true, + }, + size: { value: 2 }, + color: { + value: [new THREE.Color(0.4, 0.2, 0.1), new THREE.Color(0.2, 0.2, 0.2)], + }, + opacity: { value: [0.5, 0.2, 0] }, + }), + debris = new SPE.Emitter({ + particleCount: 100, + type: SPE.distributions.SPHERE, + position: { + radius: 0.1, + }, + maxAge: { + value: 2, + }, + // duration: 2, + activeMultiplier: 40, + + velocity: { + value: new THREE.Vector3(100), + }, + acceleration: { + value: new THREE.Vector3(0, -20, 0), + distribution: SPE.distributions.BOX, + }, + size: { value: 2 }, + drag: { + value: 1, + }, + color: { + value: [ + new THREE.Color(1, 1, 1), + new THREE.Color(1, 1, 0), + new THREE.Color(1, 0, 0), + new THREE.Color(0.4, 0.2, 0.1), + ], + }, + opacity: { value: [0.4, 0] }, + }), + fireball = new SPE.Emitter({ + particleCount: 20, + type: SPE.distributions.SPHERE, + position: { + radius: 1, + }, + maxAge: { value: 2 }, + // duration: 1, + activeMultiplier: 20, + velocity: { + value: new THREE.Vector3(10), + }, + size: { value: [20, 100] }, + color: { + value: [new THREE.Color(0.5, 0.1, 0.05), new THREE.Color(0.2, 0.2, 0.2)], + }, + opacity: { value: [0.5, 0.35, 0.1, 0] }, + }), + mist = new SPE.Emitter({ + particleCount: 50, + position: { + spread: new THREE.Vector3(10, 10, 10), + distribution: SPE.distributions.SPHERE, + }, + maxAge: { value: 2 }, + // duration: 1, + activeMultiplier: 2000, + velocity: { + value: new THREE.Vector3(8, 3, 10), + distribution: SPE.distributions.SPHERE, + }, + size: { value: 40 }, + color: { + value: new THREE.Color(0.2, 0.2, 0.2), + }, + opacity: { value: [0, 0, 0.2, 0] }, + }), + flash = new SPE.Emitter({ + particleCount: 50, + position: { spread: new THREE.Vector3(5, 5, 5) }, + velocity: { + spread: new THREE.Vector3(30), + distribution: SPE.distributions.SPHERE, + }, + size: { value: [2, 20, 20, 20] }, + maxAge: { value: 2 }, + activeMultiplier: 2000, + opacity: { value: [0.5, 0.25, 0, 0] }, + }); + + group.addEmitter(fireball).addEmitter(flash); + shockwaveGroup.addEmitter(debris).addEmitter(mist); + + speScene.scene.add(shockwaveGroup.mesh); + speScene.scene.add(group.mesh); + + speScene.camera.position.y = 40; + speScene.camera.position.z = 100; + speScene.camera.lookAt(speScene.scene.position); + + var floor = new THREE.Mesh( + new THREE.PlaneGeometry(1000, 1000, 1, 1), + new THREE.MeshPhongMaterial({ + color: 0x555555, + }) + ); + + floor.position.y = -10; + floor.rotation.x = Math.PI * -0.5; + speScene.scene.add(floor); + + var light = new THREE.PointLight(0xffffff, 1, 100); + light.position.set(0, 20, 0); + speScene.scene.add(light); + + // renderer.setClearColor( 0x333333, 1 ); + + function onAnimate() { + var now = Date.now() * 0.001; + speScene.camera.position.x = Math.sin(now) * 100; + speScene.camera.position.z = Math.cos(now) * 100; + speScene.camera.lookAt(speScene.scene.position); + } + + speScene.renderer.setSize(window.innerWidth, window.innerHeight); + + animate(); + //setTimeout(animate, 0); + } +} diff --git a/examples/Fog.js b/examples/Fog.js new file mode 100644 index 0000000..eeef0a3 --- /dev/null +++ b/examples/Fog.js @@ -0,0 +1,87 @@ +import * as THREE from "three"; +import SPE from "../build/SPE.js"; +import { BasicScene } from "./js/BasicScene.js"; + +export class Fog { + static init = function () { + let speScene = new BasicScene(64); + let allIn = function (loaded) { + Fog.initExample(loaded, speScene); + }; + speScene.textureLoad(["./img/smokeparticle.png"], allIn); + }; + + static initExample(textures, speScene) { + let emitter; + let particleGroup; + + // Setup the scene + function init() { + speScene.scene.fog = new THREE.Fog(0x000000, 40, 70); + // scene.fog = new THREE.FogExp2( 0x000000, 0.025 ); + + speScene.camera.position.z = 50; + speScene.camera.lookAt(speScene.scene.position); + + speScene.renderer.setSize(window.innerWidth, window.innerHeight); + speScene.renderer.setClearColor(speScene.scene.fog.color); + + let box = new THREE.Mesh( + new THREE.BoxGeometry(20, 20, 20), + new THREE.MeshBasicMaterial({ wireframe: true, color: 0xffffff }) + ); + speScene.scene.add(box); + } + + // Create particle group and emitter + function initParticles() { + particleGroup = new SPE.Group({ + texture: { + value: textures["./img/smokeparticle.png"], + }, + fog: true, + maxParticleCount: 25000, + }); + + emitter = new SPE.Emitter({ + type: SPE.distributions.BOX, + maxAge: 2, + position: { + value: new THREE.Vector3(0, 0, 0), + spread: new THREE.Vector3(20, 20, 20), + }, + particleCount: 20000, + isStatic: true, + }); + + particleGroup.addEmitter(emitter); + speScene.scene.add(particleGroup.mesh); + + document.querySelector(".numParticles").textContent = "Total particles: " + emitter.particleCount; + } + + function animate() { + let now = Date.now() * 0.0005; + requestAnimationFrame(animate); + + speScene.camera.position.x = Math.cos(now) * 50; + speScene.camera.position.y = Math.sin(now) * 45; + speScene.camera.position.z = Math.sin(now) * 50; + speScene.camera.lookAt(speScene.scene.position); + + render(speScene.clock.getDelta()); + speScene.stats.update(); + } + + function render(dt) { + particleGroup.tick(dt); + speScene.render(); + } + + init(); + initParticles(); + + animate(); + //setTimeout(animate, 0); + } +} diff --git a/examples/MouseFollow.js b/examples/MouseFollow.js new file mode 100644 index 0000000..ed565ee --- /dev/null +++ b/examples/MouseFollow.js @@ -0,0 +1,109 @@ +import * as THREE from "three"; +import SPE from "../build/SPE.js"; +import { BasicScene } from "./js/BasicScene.js"; + +export class MouseFollow { + static init = function () { + let speScene = new BasicScene(64); + let allIn = function (loaded) { + MouseFollow.initExample(loaded, speScene); + }; + speScene.textureLoad(["./img/smokeparticle.png"], allIn); + }; + + static initExample(textures, speScene) { + // Setup the scene + let emitter; + let particleGroup; + let mouseVector = new THREE.Vector3(); + + function init() { + speScene.camera.position.z = 50; + speScene.camera.lookAt(speScene.scene.position); + + speScene.renderer.setSize(window.innerWidth, window.innerHeight); + speScene.renderer.setClearColor(0x000000); + } + + // Create particle group and emitter + function initParticles() { + + particleGroup = new SPE.Group({ + texture: { + value: textures["./img/smokeparticle.png"], + }, + maxParticleCount: 3000, + }); + + emitter = new SPE.Emitter({ + maxAge: 3, + position: { + value: new THREE.Vector3(0, 0, 0), + }, + + acceleration: { + value: new THREE.Vector3(0, -5, 0), + spread: new THREE.Vector3(5, 0, 5), + }, + + velocity: { + value: new THREE.Vector3(0, 10, 0), + }, + + color: { + value: [new THREE.Color(0.5, 0.5, 0.5), new THREE.Color()], + spread: new THREE.Vector3(1, 1, 1), + }, + size: { + value: [5, 0], + }, + + particleCount: 1500, + }); + + particleGroup.addEmitter(emitter); + speScene.scene.add(particleGroup.mesh); + + document.querySelector(".numParticles").textContent = "Total particles: " + emitter.particleCount; + } + + function animate() { + requestAnimationFrame(animate); + + // Using a fixed time-step here to avoid pauses + render(0.016); + speScene.stats.update(); + } + + function render(dt) { + particleGroup.tick(dt); + speScene.render(); + } + + // Add mousemove listener to move the `emitter`. + document.addEventListener( + "mousemove", + function (e) { + mouseVector.set( + (e.clientX / window.innerWidth) * 2 - 1, + -(e.clientY / window.innerHeight) * 2 + 1, + 0.5 + ); + + mouseVector.unproject(speScene.camera); + emitter.position.value = emitter.position.value.set( + mouseVector.x * speScene.camera.fov, + mouseVector.y * speScene.camera.fov, + 0 + ); + }, + false + ); + + init(); + initParticles(); + + animate(); + //setTimeout(animate, 0); + } +} diff --git a/examples/MultipleEmitters.js b/examples/MultipleEmitters.js new file mode 100644 index 0000000..cda3e7d --- /dev/null +++ b/examples/MultipleEmitters.js @@ -0,0 +1,125 @@ +import * as THREE from "three"; +import SPE from "../build/SPE.js"; +import { BasicScene } from "./js/BasicScene.js"; + +export class MultipleEmitters { + static init = function () { + let speScene = new BasicScene(64); + let allIn = function (loaded) { + MultipleEmitters.initExample(loaded, speScene); + }; + speScene.textureLoad(["./img/smokeparticle.png"], allIn); + }; + + + static initExample(textures, speScene) { + let emitter; + let particleGroup; + let numEmitters = 120; + + // Setup the scene + function init() { + speScene.camera.position.z = 200; + speScene.camera.lookAt(speScene.scene.position); + + speScene.renderer.setSize(window.innerWidth, window.innerHeight); + speScene.renderer.setClearColor(0x000000); + } + + function getRandomNumber(base) { + return Math.random() * base - base / 2; + } + + function getRandomColor() { + let c = new THREE.Color(); + c.setRGB(Math.random(), Math.random(), Math.random()); + return c; + } + + // Create particle group and emitter + function initParticles() { + particleGroup = new SPE.Group({ + texture: { + value: textures["./img/smokeparticle.png"], + }, + maxParticleCount: 20000, + }); + + for (let i = 0; i < numEmitters; ++i) { + emitter = new SPE.Emitter({ + maxAge: 5, + type: (Math.random() * 4) | 0, + position: { + value: new THREE.Vector3(getRandomNumber(200), getRandomNumber(200), getRandomNumber(200)), + }, + + acceleration: { + value: new THREE.Vector3(getRandomNumber(-2), getRandomNumber(-2), getRandomNumber(-2)), + }, + + velocity: { + value: new THREE.Vector3(getRandomNumber(5), getRandomNumber(5), getRandomNumber(5)), + }, + + rotation: { + axis: new THREE.Vector3(getRandomNumber(1), getRandomNumber(1), getRandomNumber(1)), + angle: Math.random() * Math.PI, + center: new THREE.Vector3(getRandomNumber(100), getRandomNumber(100), getRandomNumber(100)), + }, + + wiggle: { + value: Math.random() * 20, + }, + + drag: { + value: Math.random(), + }, + + color: { + value: [getRandomColor(), getRandomColor()], + }, + size: { + value: [0, 2 + Math.random() * 10, 0], + }, + + particleCount: 100, + + opacity: [0, 1, 0], + }); + + particleGroup.addEmitter(emitter); + } + + speScene.scene.add(particleGroup.mesh); + + document.querySelector(".numParticles").textContent = "Total particles: " + particleGroup.particleCount; + } + + function animate() { + requestAnimationFrame(animate); + + // Using a fixed time-step here to avoid pauses + render(speScene.clock.getDelta()); + speScene.stats.update(); + } + + function updateCamera() { + let now = Date.now() * 0.0005; + speScene.camera.position.x = Math.sin(now) * 500; + speScene.camera.position.z = Math.cos(now) * 500; + speScene.camera.lookAt(speScene.scene.position); + } + + function render(dt) { + particleGroup.tick(dt); + updateCamera(); + speScene.render(); + } + + init(); + initParticles(); + + animate(); + //setTimeout(animate, 0); + } +} diff --git a/examples/Orbit.js b/examples/Orbit.js new file mode 100644 index 0000000..08d566b --- /dev/null +++ b/examples/Orbit.js @@ -0,0 +1,92 @@ +import * as THREE from "three"; +import SPE from "../build/SPE.js"; +import { BasicScene } from "./js/BasicScene.js"; + +export class Orbit { + static init = function () { + let speScene = new BasicScene(64); + let allIn = function (loaded) { + Orbit.initExample(loaded, speScene); + }; + speScene.textureLoad(["./img/smokeparticle.png"], allIn); + }; + + static initExample(textures, speScene) { + let particleGroup; + + // Setup the scene + function init() { + speScene.camera.position.z = 50; + speScene.camera.lookAt(speScene.scene.position); + + speScene.renderer.setSize(window.innerWidth, window.innerHeight); + speScene.renderer.setClearColor(0x000000); + } + + // Create particle group and emitter + function initParticles() { + particleGroup = new SPE.Group({ + texture: { + value: textures["./img/smokeparticle.png"], + }, + maxParticleCount: 3000, + }); + + // General distributions. + let emitter = new SPE.Emitter({ + maxAge: { + value: 5, + }, + position: { + value: new THREE.Vector3(5, -20, 0), + }, + + velocity: { + value: new THREE.Vector3(0, 5, 0), + }, + + acceleration: { + spread: new THREE.Vector3(1, 0, 0), + }, + + color: { + value: [new THREE.Color("white"), new THREE.Color("red")], + }, + + size: { + value: 1, + }, + + rotation: { + axis: new THREE.Vector3(0, 1, 0), + angle: Math.PI * 10, + center: new THREE.Vector3(0, 0, 0), + }, + particleCount: 1000, + direction: -1, + }); + + particleGroup.addEmitter(emitter); + + speScene.scene.add(particleGroup.mesh); + } + + function animate() { + requestAnimationFrame(animate); + + render(speScene.clock.getDelta()); + speScene.stats.update(); + } + + function render(dt) { + particleGroup.tick(dt); + speScene.render(); + } + + init(); + initParticles(); + + animate(); + //setTimeout(animate, 0); + } +} diff --git a/examples/Pool.js b/examples/Pool.js new file mode 100644 index 0000000..d0c61e8 --- /dev/null +++ b/examples/Pool.js @@ -0,0 +1,128 @@ +import * as THREE from "three"; +import SPE from "../build/SPE.js"; +import { BasicScene } from "./js/BasicScene.js"; + +export class Pool { + static init = function () { + document.querySelector(".numParticles").textContent = "Click mouse or press any key to trigger an explosion."; + + let speScene = new BasicScene(64); + let allIn = function (loaded) { + Pool.initExample(loaded, speScene); + }; + speScene.textureLoad(["./img/smokeparticle.png"], allIn); + }; + + static initExample(textures, speScene) { + // Used in initParticles() + let emitter; + let particleGroup; + let pool; + let pos = new THREE.Vector3(); + + let emitterSettings = { + type: SPE.distributions.SPHERE, + position: { + spread: new THREE.Vector3(10), + radius: 1, + }, + velocity: { + value: new THREE.Vector3(100), + }, + size: { + value: [30, 0], + }, + opacity: { + value: [1, 0], + }, + color: { + value: [new THREE.Color("yellow"), new THREE.Color("red")], + }, + particleCount: 100, + alive: true, + duration: 0.05, + maxAge: { + value: 0.5, + }, + }; + + // Setup the scene + function init() { + speScene.camera.position.z = 200; + speScene.camera.lookAt(speScene.scene.position); + + let referenceCube = new THREE.Mesh( + new THREE.BoxGeometry(300, 300, 300), + new THREE.MeshBasicMaterial({ + wireframe: true, + opacity: 0.1, + transparent: true, + color: 0xffffff, + }) + ); + speScene.scene.add(referenceCube); + + speScene.renderer.setSize(window.innerWidth, window.innerHeight); + speScene.renderer.setClearColor(0x000000); + } + + // Create particle group and emitter + function initParticles() { + particleGroup = new SPE.Group({ + texture: { + value: textures["./img/smokeparticle.png"], + }, + blending: THREE.AdditiveBlending, + maxParticleCount: 3000, + }); + + particleGroup.addPool(10, emitterSettings, false); + + // Add particle group to scene. + speScene.scene.add(particleGroup.mesh); + } + + // Generate a random number between -size/2 and +size/2 + function rand(size) { + return size * Math.random() - size / 2; + } + + // Trigger an explosion and random co-ords. + function createExplosion() { + let num = 150; + particleGroup.triggerPoolEmitter(1, pos.set(rand(num), rand(num), rand(num))); + } + + function animate() { + requestAnimationFrame(animate); + render(speScene.clock.getDelta()); + speScene.stats.update(); + } + + function updateCamera() { + let now = Date.now() * 0.0007; + + speScene.camera.position.set(Math.sin(now) * 500, 0, Math.cos(now) * 500); + speScene.camera.lookAt(speScene.scene.position); + } + + function render(dt) { + particleGroup.tick(dt); + updateCamera(); + speScene.render(); + } + + // Add a mousedown listener. When mouse is clicked, a new explosion will be created. + document.addEventListener("mousedown", createExplosion, false); + + // Do the same for a keydown event + document.addEventListener("keydown", createExplosion, false); + + // Kick it all off. + init(); + initParticles(); + + animate(); + //setTimeout(animate, 0); + } +} diff --git a/examples/Rotation.js b/examples/Rotation.js new file mode 100644 index 0000000..ff071f7 --- /dev/null +++ b/examples/Rotation.js @@ -0,0 +1,235 @@ +import * as THREE from "three"; +import SPE from "../build/SPE.js"; +import { BasicScene } from "./js/BasicScene.js"; + +export class Rotation { + static init = function () { + let speScene = new BasicScene(64); + let allIn = function (loaded) { + Rotation.initExample(loaded, speScene); + }; + speScene.textureLoad(["./img/smokeparticle.png"], allIn); + }; + + static initExample(textures, speScene) { + let particleGroup; + + // Setup the scene + function init() { + speScene.camera.lookAt(speScene.scene.position); + + speScene.renderer.setSize(window.innerWidth, window.innerHeight); + speScene.renderer.setClearColor(0x000000); + } + + // Create particle group and emitter + function initParticles() { + particleGroup = new SPE.Group({ + texture: { + value: textures["./img/smokeparticle.png"], + }, + maxParticleCount: 8000, + }); + + // General distributions. + for (let i = 1; i < 4; ++i) { + let emitter = new SPE.Emitter({ + type: i, + maxAge: { + value: 1, + }, + position: { + value: new THREE.Vector3(-50 + i * 25, 40, 0), + radius: 5, + spread: new THREE.Vector3(3, 3, 3), + }, + + color: { + value: [new THREE.Color("white"), new THREE.Color("red")], + }, + + size: { + value: 1, + }, + + rotation: { + axis: new THREE.Vector3(Math.random(), Math.random(), Math.random()), + angle: Math.random() * Math.PI, + }, + particleCount: 250, + }); + + particleGroup.addEmitter(emitter); + } + + // Spread clamping. + for (let i = 1; i < 4; ++i) { + let emitter = new SPE.Emitter({ + type: i, + maxAge: { + value: 1, + }, + position: { + value: new THREE.Vector3(-50 + i * 25, 20, 0), + radius: 4, + spread: new THREE.Vector3(5, 5, 5), + spreadClamp: new THREE.Vector3(2, 2, 2), + }, + + color: { + value: [new THREE.Color("white"), new THREE.Color("red")], + }, + + size: { + value: 1, + }, + + rotation: { + axis: new THREE.Vector3(Math.random(), Math.random(), Math.random()), + angle: Math.random() * Math.PI, + }, + + particleCount: 500, + }); + + particleGroup.addEmitter(emitter); + } + + // Spherical velocity distributions. + for (let i = 1; i < 4; ++i) { + let emitter = new SPE.Emitter({ + type: i, + maxAge: { + value: 1, + }, + position: { + value: new THREE.Vector3(-50 + i * 25, 0, 0), + radius: 5, + spread: i === 1 ? new THREE.Vector3(3, 3, 3) : undefined, + }, + + velocity: { + value: new THREE.Vector3(3, 3, 3), + distribution: SPE.distributions.SPHERE, + }, + + color: { + value: [new THREE.Color("white"), new THREE.Color("red")], + }, + + size: { + value: 1, + }, + + rotation: { + axis: new THREE.Vector3(Math.random(), Math.random(), Math.random()), + angle: Math.random() * Math.PI, + }, + + particleCount: 250, + }); + + particleGroup.addEmitter(emitter); + } + + // Disc velocity distributions. + for (let i = 1; i < 4; ++i) { + let emitter = new SPE.Emitter({ + type: i, + maxAge: { + value: 1, + }, + position: { + value: new THREE.Vector3(-50 + i * 25, -20, 0), + radius: 5, + spread: i === 1 ? new THREE.Vector3(3, 3, 3) : undefined, + }, + + velocity: { + value: new THREE.Vector3(3, 3, 3), + distribution: SPE.distributions.DISC, + }, + + color: { + value: [new THREE.Color("white"), new THREE.Color("red")], + }, + + size: { + value: 1, + }, + + rotation: { + axis: new THREE.Vector3(Math.random(), Math.random(), Math.random()), + angle: Math.random() * Math.PI, + }, + + particleCount: 250, + }); + + particleGroup.addEmitter(emitter); + } + + // Box velocity distributions. + for (let i = 1; i < 4; ++i) { + let emitter = new SPE.Emitter({ + type: i, + maxAge: { + value: 1, + }, + position: { + value: new THREE.Vector3(-50 + i * 25, -40, 0), + radius: 5, + spread: i === 1 ? new THREE.Vector3(3, 3, 3) : undefined, + }, + + velocity: { + value: new THREE.Vector3(3, 3, 3), + distribution: SPE.distributions.BOX, + }, + + color: { + value: [new THREE.Color("white"), new THREE.Color("red")], + }, + + size: { + value: 1, + }, + + rotation: { + axis: new THREE.Vector3(Math.random(), Math.random(), Math.random()), + angle: Math.random() * Math.PI, + }, + + particleCount: 250, + }); + + particleGroup.addEmitter(emitter); + } + + speScene.scene.add(particleGroup.mesh); + } + + function animate() { + requestAnimationFrame(animate); + + let now = Date.now() * 0.001; + speScene.camera.position.x = Math.sin(now) * 75; + speScene.camera.position.z = Math.cos(now) * 75; + speScene.camera.lookAt(speScene.scene.position); + + render(speScene.clock.getDelta()); + speScene.stats.update(); + } + + function render(dt) { + particleGroup.tick(dt); + speScene.render(); + } + + init(); + initParticles(); + + animate(); + //setTimeout(animate, 0); + } +} diff --git a/examples/RuntimeChanging.js b/examples/RuntimeChanging.js new file mode 100644 index 0000000..7bafeca --- /dev/null +++ b/examples/RuntimeChanging.js @@ -0,0 +1,323 @@ +import * as THREE from "three"; +import SPE from "../build/SPE.js"; +import { BasicScene } from "./js/BasicScene.js"; + +export class RuntimeChanging { + static init = function () { + document.querySelector(".numParticles").textContent = "Click mouse or press any key to trigger an explosion."; + + let speScene = new BasicScene(64); + let allIn = function (loaded) { + RuntimeChanging.initExample(loaded, speScene); + }; + speScene.textureLoad(["./img/sprite-flame2.jpg"], allIn); + }; + + static initExample(textures, speScene) { + let group = new SPE.Group({ + // Possible API for animated textures... + texture: { + value: textures["./img/sprite-flame2.jpg"], + frames: new THREE.Vector2(8, 4), + // frameCount: 8, + loop: 2, + }, + maxParticleCount: 8000, + depthTest: true, + scale: window.innerHeight / 2.0, + }); + let emitter = new SPE.Emitter({ + particleCount: 200, + maxAge: { + value: 2, + spread: 0, + }, + position: { + value: new THREE.Vector3(0, 0, 0), + spread: new THREE.Vector3(10, 0, 0), + spreadClamp: new THREE.Vector3(0, 0, 0), + distribution: SPE.distributions.BOX, + randomise: false, + }, + radius: { + value: 5, + spread: 0, + scale: new THREE.Vector3(1, 1, 1), + spreadClamp: new THREE.Vector3(2, 2, 2), + }, + velocity: { + value: new THREE.Vector3(0, 0, 0), + spread: new THREE.Vector3(0, 0, 0), + // distribution: SPE.distributions.BOX, + randomise: false, + }, + acceleration: { + value: new THREE.Vector3(0, 0, 0), + spread: new THREE.Vector3(0, 0, 0), + // distribution: SPE.distributions.BOX, + randomise: false, + }, + drag: { + value: 0.5, + spread: 0, + }, + wiggle: { + value: 0, + spread: 0, + }, + rotation: { + axis: new THREE.Vector3(0, 1, 0), + axisSpread: new THREE.Vector3(0, 0, 0), + angle: 0, // radians + angleSpread: 0, // radians + static: false, + center: new THREE.Vector3(0, 0, 0), + }, + size: { + value: 20, + spread: 0, + }, + opacity: { + value: 0.02, + }, + angle: { + value: 0, + spread: 0, + }, + }); + + group.addEmitter(emitter); + speScene.scene.add(group.mesh); + + speScene.camera.position.z = 50; + speScene.camera.position.y = 0; + speScene.camera.lookAt(speScene.scene.position); + + // scene.fog = new THREE.Fog( 0x000000, 30, 50 ); + // renderer.setClearColor(0x222222, 0.1); + speScene.renderer.setSize(window.innerWidth, window.innerHeight); + + function initDAT() { + let gui = new dat.GUI(); + gui.domElement.id = "DAT_GUI" + let keys = Object.keys(emitter); + let vec3Components = ["x", "y", "z"]; + let updateMaterial = function () { + group.material.needsUpdate = true; + }; + let i; + + let groupFolder = gui.addFolder("Group Settings"); + + groupFolder + .add(group, "textureLoop") + .min(1) + .max(10) + .step(1) + .onChange(function (value) { + group.uniforms.textureAnimation.value.w = value; + updateMaterial(); + }); + + groupFolder + .add(group, "blending") + .min(0) + .max(5) + .step(1) + .onChange(function (value) { + group.material.blending = value; + updateMaterial(); + }); + groupFolder.add(group, "colorize").onChange(function (value) { + group.defines.COLORIZE = value; + updateMaterial(); + }); + groupFolder.add(group, "hasPerspective").onChange(function (value) { + group.defines.HAS_PERSPECTIVE = value; + updateMaterial(); + }); + groupFolder.add(group, "transparent").onChange(function (value) { + group.material.transparent = value; + updateMaterial(); + }); + groupFolder + .add(group, "alphaTest") + .min(0) + .max(1) + .step(0.1) + .onChange(function (value) { + group.material.alphaTest = value; + updateMaterial(); + }); + groupFolder.add(group, "depthWrite").onChange(function (value) { + group.material.depthWrite = value; + updateMaterial(); + }); + groupFolder.add(group, "depthTest").onChange(function (value) { + group.material.depthTest = value; + updateMaterial(); + }); + + let positionFolder = gui.addFolder("Position"); + let positionValue = positionFolder.addFolder("Value"); + let positionSpread = positionFolder.addFolder("Spread"); + let positionSpreadClamp = positionFolder.addFolder("Spread Clamp"); + + for (i = 0; i < vec3Components.length; ++i) { + positionValue + .add(emitter.position.value, vec3Components[i], -100, 100) + .listen() + .onChange(function () { + emitter.position.value = emitter.position.value; + }); + positionSpread + .add(emitter.position.spread, vec3Components[i], -100, 100) + .listen() + .onChange(function () { + emitter.position.spread = emitter.position.spread; + }); + positionSpreadClamp + .add(emitter.position.spreadClamp, vec3Components[i], -50, 50) + .listen() + .onChange(function () { + emitter.position.spreadClamp = emitter.position.spreadClamp; + }); + } + + positionFolder.add(emitter.position, "radius", 0, 50).listen(); + positionFolder.add(emitter.position, "randomise").listen(); + + let velocityFolder = gui.addFolder("Velocity"); + let velocityValue = velocityFolder.addFolder("Value"); + let velocitySpread = velocityFolder.addFolder("Spread"); + + for (i = 0; i < vec3Components.length; ++i) { + velocityValue + .add(emitter.velocity.value, vec3Components[i], -50, 50) + .listen() + .onChange(function () { + emitter.velocity.value = emitter.velocity.value; + }); + velocitySpread + .add(emitter.velocity.spread, vec3Components[i], -50, 50) + .listen() + .onChange(function () { + emitter.velocity.spread = emitter.velocity.spread; + }); + } + velocityFolder.add(emitter.velocity, "randomise").listen(); + + let accelerationFolder = gui.addFolder("Acceleration"); + let accelerationValue = accelerationFolder.addFolder("Value"); + let accelerationSpread = accelerationFolder.addFolder("Spread"); + + for (i = 0; i < vec3Components.length; ++i) { + accelerationValue + .add(emitter.acceleration.value, vec3Components[i], -50, 50) + .listen() + .onChange(function () { + emitter.acceleration.value = emitter.acceleration.value; + }); + accelerationSpread + .add(emitter.acceleration.spread, vec3Components[i], -50, 50) + .listen() + .onChange(function () { + emitter.acceleration.spread = emitter.acceleration.spread; + }); + } + + accelerationFolder.add(emitter.acceleration, "randomise").listen(); + + let colors = { + "Step 1": "#ffffff", + "Step 2": "#ffffff", + "Step 3": "#ffffff", + "Step 4": "#ffffff", + }; + + let colorFolder = gui.addFolder("Color steps"); + colorFolder.addColor(colors, "Step 1").onChange(function (value) { + emitter.color.value[0].setStyle(value); + emitter.color.value = emitter.color.value; + }); + colorFolder.addColor(colors, "Step 2").onChange(function (value) { + emitter.color.value[1].setStyle(value); + emitter.color.value = emitter.color.value; + }); + colorFolder.addColor(colors, "Step 3").onChange(function (value) { + emitter.color.value[2].setStyle(value); + emitter.color.value = emitter.color.value; + }); + colorFolder.addColor(colors, "Step 4").onChange(function (value) { + emitter.color.value[3].setStyle(value); + emitter.color.value = emitter.color.value; + }); + + let opacities = { + "Step 1": emitter.opacity.value[0], + "Step 2": emitter.opacity.value[1], + "Step 3": emitter.opacity.value[2], + "Step 4": emitter.opacity.value[3], + }; + let opacityFolder = gui.addFolder("Opacity steps"); + opacityFolder + .add(opacities, "Step 1") + .min(0) + .max(1) + .step(0.01) + .listen() + .onChange(function (value) { + emitter.opacity.value[0] = value; + emitter.opacity.value = emitter.opacity.value; + }); + opacityFolder + .add(opacities, "Step 2") + .min(0) + .max(1) + .step(0.01) + .listen() + .onChange(function (value) { + emitter.opacity.value[1] = value; + emitter.opacity.value = emitter.opacity.value; + }); + opacityFolder + .add(opacities, "Step 3") + .min(0) + .max(1) + .step(0.01) + .listen() + .onChange(function (value) { + emitter.opacity.value[2] = value; + emitter.opacity.value = emitter.opacity.value; + }); + opacityFolder + .add(opacities, "Step 4") + .min(0) + .max(1) + .step(0.01) + .listen() + .onChange(function (value) { + emitter.opacity.value[3] = value; + emitter.opacity.value = emitter.opacity.value; + }); + } + + function animate() { + requestAnimationFrame(animate); + speScene.stats.update(); + render(); + } + + function render() { + let dt = speScene.clock.getDelta(); + group.tick(dt); + speScene.render(); + } + + console.log(group); + console.log(emitter); + + initDAT(); + animate(); + } +} diff --git a/examples/activeMultiplier.html b/examples/activeMultiplier.html deleted file mode 100644 index f0722b6..0000000 --- a/examples/activeMultiplier.html +++ /dev/null @@ -1,134 +0,0 @@ - - - SPE: ActiveMultiplier - - - - -

- -
-

Change value below to change number of particles

-

0 = No particles; 1 = 100% of emitter's particle count

- -
- - - - - - - - - diff --git a/examples/basic.html b/examples/basic.html deleted file mode 100644 index 50f0fb3..0000000 --- a/examples/basic.html +++ /dev/null @@ -1,120 +0,0 @@ - - - SPE: Basic - - - -

- - - - - - - - - - diff --git a/examples/clock.html b/examples/clock.html deleted file mode 100644 index 3124fcb..0000000 --- a/examples/clock.html +++ /dev/null @@ -1,152 +0,0 @@ - - - - SPE: Clock - - - - - - - - - - - - diff --git a/examples/clouds.html b/examples/clouds.html deleted file mode 100644 index 26bf62d..0000000 --- a/examples/clouds.html +++ /dev/null @@ -1,123 +0,0 @@ - - - SPE: Clouds - - - - -

- - - - - - - - - diff --git a/examples/css/style.css b/examples/css/style.css index b8151f0..528b58f 100644 --- a/examples/css/style.css +++ b/examples/css/style.css @@ -1,6 +1,6 @@ * { - margin: 0; - padding: 0; + margin: 0; + padding: 0; } body { @@ -8,6 +8,7 @@ body { font-family: sans-serif; overflow: hidden; margin: 0; + background-color: black; } p { @@ -18,12 +19,53 @@ p.small { font-size: 0.8em; } +#RENDER_CANVAS { + position: absolute; + left: 0px; + top: 0px; + z-index: -1; +} + + +.link_man { + position: absolute; + left: 0px; + top: 50%; + -ms-transform: translateY(-50%); + transform: translateY(-50%); + background-color: black; + padding: 15px; + border-top-right-radius: 6px; + border-bottom-right-radius: 6px; +} + +.link_man h4 { + padding-left: 6px; +} + +.link_man span { + display: block; + margin: 6px; + color: lightblue; /* Default color for unvisited links */ + text-decoration: none; /* Remove underline */ + cursor: pointer; +} + +.link_man span:hover { + color: lightgreen; /* Change color on hover */ +} + +.link_man span.activeItem { + color: lightgreen; /* Change color on hover */ +} + .numParticles { - position: absolute; - bottom: 10px; - left: 10px; - color: white; - text-shadow: 0 0 3px rgba(0, 0, 0, 0.8); + position: absolute; + bottom: 10px; + left: 10px; + color: white; + text-shadow: 0 0 3px rgba(0, 0, 0, 0.8); + display: none; } .alive-wrapper { @@ -34,13 +76,30 @@ p.small { margin-left: -12.5em; text-align: center; padding: 1em; - background-color: rgba( 255, 255, 255, 0.15 ); + background-color: rgba(255, 255, 255, 0.15); border-radius: 1em; - border: 1px solid rgba( 255, 255, 255, 0.3 ); + border: 1px solid rgba(255, 255, 255, 0.3); + display: none; } #stats { position: absolute; top: 0; z-index: 2; -} \ No newline at end of file +} + +body.Fog .numParticles, +body.Pool .numParticles, +body.Basic .numParticles, +body.Clouds .numParticles, +body.MouseFollow .numParticles, +body.ActiveMultiplier .numParticles, +body.MultipleEmitters .numParticles { + display: block; +} + +body.Basic .alive-wrapper, +body.ActiveMultiplier .alive-wrapper { + display: block; +} + diff --git a/examples/distributions.html b/examples/distributions.html deleted file mode 100644 index 196a50a..0000000 --- a/examples/distributions.html +++ /dev/null @@ -1,243 +0,0 @@ - - - SPE: Distribution types - - - - - - - - - - - - diff --git a/examples/examples.html b/examples/examples.html new file mode 100644 index 0000000..4852a53 --- /dev/null +++ b/examples/examples.html @@ -0,0 +1,112 @@ + + + SPE: ActiveMultiplier + + + + + + + + + + + +

+
+

Change value below to change number of particles

+

0 = No particles; 1 = 100% of emitter's particle count

+ +
+ + + + diff --git a/examples/explosion.html b/examples/explosion.html deleted file mode 100644 index a868549..0000000 --- a/examples/explosion.html +++ /dev/null @@ -1,220 +0,0 @@ - - - - SPE: Explosion - - - - - - - - - - - diff --git a/examples/fog.html b/examples/fog.html deleted file mode 100644 index 4175db3..0000000 --- a/examples/fog.html +++ /dev/null @@ -1,119 +0,0 @@ - - - SPE: Fog support - - - - -

- - - - - - - - - - diff --git a/examples/img/bullet.png b/examples/img/bullet.png index 8310ac5..22ccd2d 100644 Binary files a/examples/img/bullet.png and b/examples/img/bullet.png differ diff --git a/examples/img/bullet2.png b/examples/img/bullet2.png index 651fd98..44d9f2d 100644 Binary files a/examples/img/bullet2.png and b/examples/img/bullet2.png differ diff --git a/examples/img/cloud.png b/examples/img/cloud.png index c79d875..1cbb646 100644 Binary files a/examples/img/cloud.png and b/examples/img/cloud.png differ diff --git a/examples/img/cloudSml.png b/examples/img/cloudSml.png index 974e8ea..d59e5c7 100644 Binary files a/examples/img/cloudSml.png and b/examples/img/cloudSml.png differ diff --git a/examples/img/flames.jpg b/examples/img/flames.jpg index 5f36e64..e242c15 100644 Binary files a/examples/img/flames.jpg and b/examples/img/flames.jpg differ diff --git a/examples/img/shockwave.png b/examples/img/shockwave.png index a07a8c5..40a38df 100644 Binary files a/examples/img/shockwave.png and b/examples/img/shockwave.png differ diff --git a/examples/img/smokeparticle.png b/examples/img/smokeparticle.png index 7bad8c6..ef3f987 100644 Binary files a/examples/img/smokeparticle.png and b/examples/img/smokeparticle.png differ diff --git a/examples/img/smokeparticle_2.png b/examples/img/smokeparticle_2.png new file mode 100644 index 0000000..4688a22 Binary files /dev/null and b/examples/img/smokeparticle_2.png differ diff --git a/examples/img/sprite-1x4.jpg b/examples/img/sprite-1x4.jpg index 38e9dc3..a2d1247 100644 Binary files a/examples/img/sprite-1x4.jpg and b/examples/img/sprite-1x4.jpg differ diff --git a/examples/img/sprite-2x2.jpg b/examples/img/sprite-2x2.jpg index 6f4e6e1..44765d4 100644 Binary files a/examples/img/sprite-2x2.jpg and b/examples/img/sprite-2x2.jpg differ diff --git a/examples/img/sprite-3x3.jpg b/examples/img/sprite-3x3.jpg index ec23489..c71c9c9 100644 Binary files a/examples/img/sprite-3x3.jpg and b/examples/img/sprite-3x3.jpg differ diff --git a/examples/img/sprite-4x1.jpg b/examples/img/sprite-4x1.jpg index c30b196..cce5954 100644 Binary files a/examples/img/sprite-4x1.jpg and b/examples/img/sprite-4x1.jpg differ diff --git a/examples/img/sprite-explosion.png b/examples/img/sprite-explosion.png index f9fa1d6..7c7e1be 100644 Binary files a/examples/img/sprite-explosion.png and b/examples/img/sprite-explosion.png differ diff --git a/examples/img/sprite-explosion2.png b/examples/img/sprite-explosion2.png index 23c4b94..6e98d8d 100644 Binary files a/examples/img/sprite-explosion2.png and b/examples/img/sprite-explosion2.png differ diff --git a/examples/img/sprite-flame.jpg b/examples/img/sprite-flame.jpg index d357ce9..4ba57aa 100644 Binary files a/examples/img/sprite-flame.jpg and b/examples/img/sprite-flame.jpg differ diff --git a/examples/img/sprite-flame2.jpg b/examples/img/sprite-flame2.jpg index e682457..bad00ec 100644 Binary files a/examples/img/sprite-flame2.jpg and b/examples/img/sprite-flame2.jpg differ diff --git a/examples/img/sprite-smoke.jpg b/examples/img/sprite-smoke.jpg index e1fe603..645211a 100644 Binary files a/examples/img/sprite-smoke.jpg and b/examples/img/sprite-smoke.jpg differ diff --git a/examples/img/star.png b/examples/img/star.png index 8eeda12..0b7abd0 100644 Binary files a/examples/img/star.png and b/examples/img/star.png differ diff --git a/examples/js/Stats.min.js b/examples/js/Stats.min.js deleted file mode 100644 index 73744ef..0000000 --- a/examples/js/Stats.min.js +++ /dev/null @@ -1,6 +0,0 @@ -// stats.js - http://github.com/mrdoob/stats.js -var Stats=function(){var l=Date.now(),m=l,g=0,n=Infinity,o=0,h=0,p=Infinity,q=0,r=0,s=0,f=document.createElement("div");f.id="stats";f.addEventListener("mousedown",function(b){b.preventDefault();t(++s%2)},!1);f.style.cssText="width:80px;opacity:0.9;cursor:pointer";var a=document.createElement("div");a.id="fps";a.style.cssText="padding:0 0 3px 3px;text-align:left;background-color:#002";f.appendChild(a);var i=document.createElement("div");i.id="fpsText";i.style.cssText="color:#0ff;font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px"; -i.innerHTML="FPS";a.appendChild(i);var c=document.createElement("div");c.id="fpsGraph";c.style.cssText="position:relative;width:74px;height:30px;background-color:#0ff";for(a.appendChild(c);74>c.children.length;){var j=document.createElement("span");j.style.cssText="width:1px;height:30px;float:left;background-color:#113";c.appendChild(j)}var d=document.createElement("div");d.id="ms";d.style.cssText="padding:0 0 3px 3px;text-align:left;background-color:#020;display:none";f.appendChild(d);var k=document.createElement("div"); -k.id="msText";k.style.cssText="color:#0f0;font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px";k.innerHTML="MS";d.appendChild(k);var e=document.createElement("div");e.id="msGraph";e.style.cssText="position:relative;width:74px;height:30px;background-color:#0f0";for(d.appendChild(e);74>e.children.length;)j=document.createElement("span"),j.style.cssText="width:1px;height:30px;float:left;background-color:#131",e.appendChild(j);var t=function(b){s=b;switch(s){case 0:a.style.display= -"block";d.style.display="none";break;case 1:a.style.display="none",d.style.display="block"}};return{REVISION:11,domElement:f,setMode:t,begin:function(){l=Date.now()},end:function(){var b=Date.now();g=b-l;n=Math.min(n,g);o=Math.max(o,g);k.textContent=g+" MS ("+n+"-"+o+")";var a=Math.min(30,30-30*(g/200));e.appendChild(e.firstChild).style.height=a+"px";r++;b>m+1E3&&(h=Math.round(1E3*r/(b-m)),p=Math.min(p,h),q=Math.max(q,h),i.textContent=h+" FPS ("+p+"-"+q+")",a=Math.min(30,30-30*(h/100)),c.appendChild(c.firstChild).style.height= -a+"px",m=b,r=0);return b},update:function(){l=this.end()}}}; diff --git a/examples/js/THREE-r84.js b/examples/js/THREE-r84.js deleted file mode 100755 index 76310b5..0000000 --- a/examples/js/THREE-r84.js +++ /dev/null @@ -1,859 +0,0 @@ -// threejs.org/license -(function(l,pa){"object"===typeof exports&&"undefined"!==typeof module?pa(exports):"function"===typeof define&&define.amd?define(["exports"],pa):pa(l.THREE=l.THREE||{})})(this,function(l){function pa(){}function D(a,b){this.x=a||0;this.y=b||0}function ea(a,b,c,d,e,f,g,h,m,k){Object.defineProperty(this,"id",{value:Ze++});this.uuid=N.generateUUID();this.name="";this.image=void 0!==a?a:ea.DEFAULT_IMAGE;this.mipmaps=[];this.mapping=void 0!==b?b:ea.DEFAULT_MAPPING;this.wrapS=void 0!==c?c:1001;this.wrapT= -void 0!==d?d:1001;this.magFilter=void 0!==e?e:1006;this.minFilter=void 0!==f?f:1008;this.anisotropy=void 0!==m?m:1;this.format=void 0!==g?g:1023;this.type=void 0!==h?h:1009;this.offset=new D(0,0);this.repeat=new D(1,1);this.generateMipmaps=!0;this.premultiplyAlpha=!1;this.flipY=!0;this.unpackAlignment=4;this.encoding=void 0!==k?k:3E3;this.version=0;this.onUpdate=null}function fa(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1}function Ya(a,b,c){this.uuid=N.generateUUID();this.width= -a;this.height=b;this.scissor=new fa(0,0,a,b);this.scissorTest=!1;this.viewport=new fa(0,0,a,b);c=c||{};void 0===c.minFilter&&(c.minFilter=1006);this.texture=new ea(void 0,void 0,c.wrapS,c.wrapT,c.magFilter,c.minFilter,c.format,c.type,c.anisotropy,c.encoding);this.depthBuffer=void 0!==c.depthBuffer?c.depthBuffer:!0;this.stencilBuffer=void 0!==c.stencilBuffer?c.stencilBuffer:!0;this.depthTexture=void 0!==c.depthTexture?c.depthTexture:null}function Gb(a,b,c){Ya.call(this,a,b,c);this.activeMipMapLevel= -this.activeCubeFace=0}function ca(a,b,c,d){this._x=a||0;this._y=b||0;this._z=c||0;this._w=void 0!==d?d:1}function q(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0}function S(){this.elements=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);0= -d||0 0 ) {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = 0.0;\nif ( fogType == 1 ) {\nfogFactor = smoothstep( fogNear, fogFar, depth );\n} else {\nconst float LOG2 = 1.442695;\nfogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n}\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n}\n}"].join("\n")); -v.compileShader(M);v.compileShader(O);v.attachShader(Q,M);v.attachShader(Q,O);v.linkProgram(Q);F=Q;w=v.getAttribLocation(F,"position");y=v.getAttribLocation(F,"uv");c=v.getUniformLocation(F,"uvOffset");d=v.getUniformLocation(F,"uvScale");e=v.getUniformLocation(F,"rotation");f=v.getUniformLocation(F,"scale");g=v.getUniformLocation(F,"color");h=v.getUniformLocation(F,"map");m=v.getUniformLocation(F,"opacity");k=v.getUniformLocation(F,"modelViewMatrix");t=v.getUniformLocation(F,"projectionMatrix");p= -v.getUniformLocation(F,"fogType");n=v.getUniformLocation(F,"fogDensity");u=v.getUniformLocation(F,"fogNear");l=v.getUniformLocation(F,"fogFar");r=v.getUniformLocation(F,"fogColor");A=v.getUniformLocation(F,"alphaTest");Q=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");Q.width=8;Q.height=8;M=Q.getContext("2d");M.fillStyle="white";M.fillRect(0,0,8,8);da=new ea(Q);da.needsUpdate=!0}v.useProgram(F);E.initAttributes();E.enableAttribute(w);E.enableAttribute(y);E.disableUnusedAttributes(); -E.disable(v.CULL_FACE);E.enable(v.BLEND);v.bindBuffer(v.ARRAY_BUFFER,L);v.vertexAttribPointer(w,2,v.FLOAT,!1,16,0);v.vertexAttribPointer(y,2,v.FLOAT,!1,16,8);v.bindBuffer(v.ELEMENT_ARRAY_BUFFER,C);v.uniformMatrix4fv(t,!1,D.projectionMatrix.elements);E.activeTexture(v.TEXTURE0);v.uniform1i(h,0);M=Q=0;(O=q.fog)?(v.uniform3f(r,O.color.r,O.color.g,O.color.b),O.isFog?(v.uniform1f(u,O.near),v.uniform1f(l,O.far),v.uniform1i(p,1),M=Q=1):O.isFogExp2&&(v.uniform1f(n,O.density),v.uniform1i(p,2),M=Q=2)):(v.uniform1i(p, -0),M=Q=0);for(var O=0,P=b.length;O -c&&(c=a[b]);return c}function T(){Object.defineProperty(this,"id",{value:Vd++});this.uuid=N.generateUUID();this.name="";this.type="Geometry";this.vertices=[];this.colors=[];this.faces=[];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphNormals=[];this.skinWeights=[];this.skinIndices=[];this.lineDistances=[];this.boundingSphere=this.boundingBox=null;this.groupsNeedUpdate=this.lineDistancesNeedUpdate=this.colorsNeedUpdate=this.normalsNeedUpdate=this.uvsNeedUpdate=this.verticesNeedUpdate=this.elementsNeedUpdate= -!1}function I(){Object.defineProperty(this,"id",{value:Vd++});this.uuid=N.generateUUID();this.name="";this.type="BufferGeometry";this.index=null;this.attributes={};this.morphAttributes={};this.groups=[];this.boundingSphere=this.boundingBox=null;this.drawRange={start:0,count:Infinity}}function Aa(a,b){x.call(this);this.type="Mesh";this.geometry=void 0!==a?a:new I;this.material=void 0!==b?b:new Ka({color:16777215*Math.random()});this.drawMode=0;this.updateMorphTargets()}function Ib(a,b,c,d,e,f){T.call(this); -this.type="BoxGeometry";this.parameters={width:a,height:b,depth:c,widthSegments:d,heightSegments:e,depthSegments:f};this.fromBufferGeometry(new kb(a,b,c,d,e,f));this.mergeVertices()}function kb(a,b,c,d,e,f){function g(a,b,c,d,e,f,g,l,L,C,F){var da=f/L,H=g/C,aa=f/2,x=g/2,D=l/2;g=L+1;var z=C+1,Q=f=0,M,O,P=new q;for(O=0;O/g,function(a,c){var d=Z[c];if(void 0===d)throw Error("Can not resolve #include <"+c+">");return Xd(d)})}function Qe(a){return a.replace(/for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,function(a,c,d,e){a="";for(c=parseInt(c);cb||a.height>b){var c=b/Math.max(a.width,a.height),d=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");d.width=Math.floor(a.width*c);d.height=Math.floor(a.height*c);d.getContext("2d").drawImage(a,0,0,a.width,a.height,0,0,d.width,d.height);console.warn("THREE.WebGLRenderer: image is too big ("+a.width+"x"+a.height+"). Resized to "+ -d.width+"x"+d.height,a);return d}return a}function m(a){return N.isPowerOfTwo(a.width)&&N.isPowerOfTwo(a.height)}function k(b){return 1003===b||1004===b||1005===b?a.NEAREST:a.LINEAR}function t(b){b=b.target;b.removeEventListener("dispose",t);a:{var c=d.get(b);if(b.image&&c.__image__webglTextureCube)a.deleteTexture(c.__image__webglTextureCube);else{if(void 0===c.__webglInit)break a;a.deleteTexture(c.__webglTexture)}d["delete"](b)}q.textures--}function p(b){b=b.target;b.removeEventListener("dispose", -p);var c=d.get(b),e=d.get(b.texture);if(b){void 0!==e.__webglTexture&&a.deleteTexture(e.__webglTexture);b.depthTexture&&b.depthTexture.dispose();if(b.isWebGLRenderTargetCube)for(e=0;6>e;e++)a.deleteFramebuffer(c.__webglFramebuffer[e]),c.__webglDepthbuffer&&a.deleteRenderbuffer(c.__webglDepthbuffer[e]);else a.deleteFramebuffer(c.__webglFramebuffer),c.__webglDepthbuffer&&a.deleteRenderbuffer(c.__webglDepthbuffer);d["delete"](b.texture);d["delete"](b)}q.textures--}function n(b,g){var k=d.get(b);if(0< -b.version&&k.__version!==b.version){var n=b.image;if(void 0===n)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined",b);else if(!1===n.complete)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete",b);else{void 0===k.__webglInit&&(k.__webglInit=!0,b.addEventListener("dispose",t),k.__webglTexture=a.createTexture(),q.textures++);c.activeTexture(a.TEXTURE0+g);c.bindTexture(a.TEXTURE_2D,k.__webglTexture);a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL, -b.flipY);a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,b.premultiplyAlpha);a.pixelStorei(a.UNPACK_ALIGNMENT,b.unpackAlignment);var p=h(b.image,e.maxTextureSize);if((1001!==b.wrapS||1001!==b.wrapT||1003!==b.minFilter&&1006!==b.minFilter)&&!1===m(p))if(n=p,n instanceof HTMLImageElement||n instanceof HTMLCanvasElement){var l=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");l.width=N.nearestPowerOfTwo(n.width);l.height=N.nearestPowerOfTwo(n.height);l.getContext("2d").drawImage(n,0,0, -l.width,l.height);console.warn("THREE.WebGLRenderer: image is not power of two ("+n.width+"x"+n.height+"). Resized to "+l.width+"x"+l.height,n);p=l}else p=n;var n=m(p),l=f(b.format),G=f(b.type);u(a.TEXTURE_2D,b,n);var r=b.mipmaps;if(b.isDepthTexture){r=a.DEPTH_COMPONENT;if(1015===b.type){if(!w)throw Error("Float Depth Texture only supported in WebGL2.0");r=a.DEPTH_COMPONENT32F}else w&&(r=a.DEPTH_COMPONENT16);1026===b.format&&r===a.DEPTH_COMPONENT&&1012!==b.type&&1014!==b.type&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."), -b.type=1012,G=f(b.type));1027===b.format&&(r=a.DEPTH_STENCIL,1020!==b.type&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),b.type=1020,G=f(b.type)));c.texImage2D(a.TEXTURE_2D,0,r,p.width,p.height,0,l,G,null)}else if(b.isDataTexture)if(0r;r++)l[r]=n||p?p?b.image[r].image:b.image[r]:h(b.image[r],e.maxCubemapSize);var G=m(l[0]),w=f(b.format),aa=f(b.type);u(a.TEXTURE_CUBE_MAP,b,G);for(r=0;6>r;r++)if(n)for(var x,D=l[r].mipmaps,z=0,Q=D.length;zk;k++)e.__webglFramebuffer[k]=a.createFramebuffer()}else e.__webglFramebuffer= -a.createFramebuffer();if(g){c.bindTexture(a.TEXTURE_CUBE_MAP,f.__webglTexture);u(a.TEXTURE_CUBE_MAP,b.texture,h);for(k=0;6>k;k++)l(e.__webglFramebuffer[k],b,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+k);b.texture.generateMipmaps&&h&&a.generateMipmap(a.TEXTURE_CUBE_MAP);c.bindTexture(a.TEXTURE_CUBE_MAP,null)}else c.bindTexture(a.TEXTURE_2D,f.__webglTexture),u(a.TEXTURE_2D,b.texture,h),l(e.__webglFramebuffer,b,a.COLOR_ATTACHMENT0,a.TEXTURE_2D),b.texture.generateMipmaps&&h&&a.generateMipmap(a.TEXTURE_2D), -c.bindTexture(a.TEXTURE_2D,null);if(b.depthBuffer){e=d.get(b);f=!0===b.isWebGLRenderTargetCube;if(b.depthTexture){if(f)throw Error("target.depthTexture not supported in Cube render targets");if(b&&b.isWebGLRenderTargetCube)throw Error("Depth Texture with cube render targets is not supported!");a.bindFramebuffer(a.FRAMEBUFFER,e.__webglFramebuffer);if(!b.depthTexture||!b.depthTexture.isDepthTexture)throw Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");d.get(b.depthTexture).__webglTexture&& -b.depthTexture.image.width===b.width&&b.depthTexture.image.height===b.height||(b.depthTexture.image.width=b.width,b.depthTexture.image.height=b.height,b.depthTexture.needsUpdate=!0);n(b.depthTexture,0);e=d.get(b.depthTexture).__webglTexture;if(1026===b.depthTexture.format)a.framebufferTexture2D(a.FRAMEBUFFER,a.DEPTH_ATTACHMENT,a.TEXTURE_2D,e,0);else if(1027===b.depthTexture.format)a.framebufferTexture2D(a.FRAMEBUFFER,a.DEPTH_STENCIL_ATTACHMENT,a.TEXTURE_2D,e,0);else throw Error("Unknown depthTexture format"); -}else if(f)for(e.__webglDepthbuffer=[],f=0;6>f;f++)a.bindFramebuffer(a.FRAMEBUFFER,e.__webglFramebuffer[f]),e.__webglDepthbuffer[f]=a.createRenderbuffer(),r(e.__webglDepthbuffer[f],b);else a.bindFramebuffer(a.FRAMEBUFFER,e.__webglFramebuffer),e.__webglDepthbuffer=a.createRenderbuffer(),r(e.__webglDepthbuffer,b);a.bindFramebuffer(a.FRAMEBUFFER,null)}};this.updateRenderTargetMipmap=function(b){var e=b.texture;e.generateMipmaps&&m(b)&&1003!==e.minFilter&&1006!==e.minFilter&&(b=b&&b.isWebGLRenderTargetCube? -a.TEXTURE_CUBE_MAP:a.TEXTURE_2D,e=d.get(e).__webglTexture,c.bindTexture(b,e),a.generateMipmap(b),c.bindTexture(b,null))}}function Qf(){var a={};return{get:function(b){b=b.uuid;var c=a[b];void 0===c&&(c={},a[b]=c);return c},"delete":function(b){delete a[b.uuid]},clear:function(){a={}}}}function Rf(a,b,c){function d(b,c,d){var e=new Uint8Array(4),f=a.createTexture();a.bindTexture(b,f);a.texParameteri(b,a.TEXTURE_MIN_FILTER,a.NEAREST);a.texParameteri(b,a.TEXTURE_MAG_FILTER,a.NEAREST);for(b=0;b=la.maxTextures&&console.warn("WebGLRenderer: trying to use "+a+" texture units while this GPU supports only "+ -la.maxTextures);ea+=1;return a};this.setTexture2D=function(){var a=!1;return function(b,c){b&&b.isWebGLRenderTarget&&(a||(console.warn("THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead."),a=!0),b=b.texture);ta.setTexture2D(b,c)}}();this.setTexture=function(){var a=!1;return function(b,c){a||(console.warn("THREE.WebGLRenderer: .setTexture is deprecated, use setTexture2D instead."),a=!0);ta.setTexture2D(b,c)}}();this.setTextureCube=function(){var a= -!1;return function(b,c){b&&b.isWebGLRenderTargetCube&&(a||(console.warn("THREE.WebGLRenderer.setTextureCube: don't use cube render targets as textures. Use their .texture property instead."),a=!0),b=b.texture);b&&b.isCubeTexture||Array.isArray(b.image)&&6===b.image.length?ta.setTextureCube(b,c):ta.setTextureCubeDynamic(b,c)}}();this.getCurrentRenderTarget=function(){return W};this.setRenderTarget=function(a){(W=a)&&void 0===ha.get(a).__webglFramebuffer&&ta.setupRenderTarget(a);var b=a&&a.isWebGLRenderTargetCube, -c;a?(c=ha.get(a),c=b?c.__webglFramebuffer[a.activeCubeFace]:c.__webglFramebuffer,X.copy(a.scissor),Sa=a.scissorTest,Z.copy(a.viewport)):(c=null,X.copy(ga).multiplyScalar(Ra),Sa=ka,Z.copy(ia).multiplyScalar(Ra));N!==c&&(B.bindFramebuffer(B.FRAMEBUFFER,c),N=c);Y.scissor(X);Y.setScissorTest(Sa);Y.viewport(Z);b&&(b=ha.get(a.texture),B.framebufferTexture2D(B.FRAMEBUFFER,B.COLOR_ATTACHMENT0,B.TEXTURE_CUBE_MAP_POSITIVE_X+a.activeCubeFace,b.__webglTexture,a.activeMipMapLevel))};this.readRenderTargetPixels= -function(a,b,c,d,e,f){if(!1===(a&&a.isWebGLRenderTarget))console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");else{var g=ha.get(a).__webglFramebuffer;if(g){var h=!1;g!==N&&(B.bindFramebuffer(B.FRAMEBUFFER,g),h=!0);try{var k=a.texture,m=k.format,n=k.type;1023!==m&&w(m)!==B.getParameter(B.IMPLEMENTATION_COLOR_READ_FORMAT)?console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format."):1009=== -n||w(n)===B.getParameter(B.IMPLEMENTATION_COLOR_READ_TYPE)||1015===n&&(ja.get("OES_texture_float")||ja.get("WEBGL_color_buffer_float"))||1016===n&&ja.get("EXT_color_buffer_half_float")?B.checkFramebufferStatus(B.FRAMEBUFFER)===B.FRAMEBUFFER_COMPLETE?0<=b&&b<=a.width-d&&0<=c&&c<=a.height-e&&B.readPixels(b,c,d,e,w(m),w(n),f):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete."):console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.")}finally{h&& -B.bindFramebuffer(B.FRAMEBUFFER,N)}}}}}function Kb(a,b){this.name="";this.color=new J(a);this.density=void 0!==b?b:2.5E-4}function Lb(a,b,c){this.name="";this.color=new J(a);this.near=void 0!==b?b:1;this.far=void 0!==c?c:1E3}function mb(){x.call(this);this.type="Scene";this.overrideMaterial=this.fog=this.background=null;this.autoUpdate=!0}function Zd(a,b,c,d,e){x.call(this);this.lensFlares=[];this.positionScreen=new q;this.customUpdateCallback=void 0;void 0!==a&&this.add(a,b,c,d,e)}function nb(a){X.call(this); -this.type="SpriteMaterial";this.color=new J(16777215);this.map=null;this.rotation=0;this.lights=this.fog=!1;this.setValues(a)}function Dc(a){x.call(this);this.type="Sprite";this.material=void 0!==a?a:new nb}function Ec(){x.call(this);this.type="LOD";Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function od(a,b,c){this.useVertexTexture=void 0!==c?c:!0;this.identityMatrix=new S;a=a||[];this.bones=a.slice(0);this.useVertexTexture?(a=Math.sqrt(4*this.bones.length),a=N.nextPowerOfTwo(Math.ceil(a)), -this.boneTextureHeight=this.boneTextureWidth=a=Math.max(a,4),this.boneMatrices=new Float32Array(this.boneTextureWidth*this.boneTextureHeight*4),this.boneTexture=new eb(this.boneMatrices,this.boneTextureWidth,this.boneTextureHeight,1023,1015)):this.boneMatrices=new Float32Array(16*this.bones.length);if(void 0===b)this.calculateInverses();else if(this.bones.length===b.length)this.boneInverses=b.slice(0);else for(console.warn("THREE.Skeleton bonInverses is the wrong length."),this.boneInverses=[],b= -0,a=this.bones.length;b=a.HAVE_CURRENT_DATA&&(t.needsUpdate=!0)}ea.call(this,a,b,c,d,e,f,g,h,m);this.generateMipmaps=!1;var t=this;k()}function Nb(a,b,c,d,e,f,g,h,m,k,t,p){ea.call(this,null,f,g,h,m,k,d,e,t,p);this.image={width:b,height:c};this.mipmaps=a;this.generateMipmaps=this.flipY=!1}function sd(a,b,c,d,e,f,g,h,m){ea.call(this,a,b,c,d,e,f,g,h,m);this.needsUpdate=!0}function Gc(a,b,c,d,e,f,g, -h,m,k){k=void 0!==k?k:1026;if(1026!==k&&1027!==k)throw Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===c&&1026===k&&(c=1012);void 0===c&&1027===k&&(c=1020);ea.call(this,null,d,e,f,g,h,k,c,m);this.image={width:a,height:b};this.magFilter=void 0!==g?g:1003;this.minFilter=void 0!==h?h:1003;this.generateMipmaps=this.flipY=!1}function Ob(a){function b(a,b){return a-b}I.call(this);this.type="WireframeGeometry";var c=[],d,e,f,g,h=[0,0],m={},k,t=["a","b", -"c"];if(a&&a.isGeometry){var p=a.faces;d=0;for(f=p.length;de;e++)h[0]=n[t[e]],h[1]=n[t[(e+1)%3]],h.sort(b),k=h.toString(),void 0===m[k]&&(m[k]={index1:h[0],index2:h[1]})}for(k in m)d=m[k],t=a.vertices[d.index1],c.push(t.x,t.y,t.z),t=a.vertices[d.index2],c.push(t.x,t.y,t.z)}else if(a&&a.isBufferGeometry){var l,t=new q;if(null!==a.index){p=a.attributes.position;n=a.index;l=a.groups;0===l.length&&a.addGroup(0,n.count);a=0;for(g=l.length;ae;e++)h[0]=n.getX(d+e),h[1]=n.getX(d+(e+1)%3),h.sort(b),k=h.toString(),void 0===m[k]&&(m[k]={index1:h[0],index2:h[1]});for(k in m)d=m[k],t.fromBufferAttribute(p,d.index1),c.push(t.x,t.y,t.z),t.fromBufferAttribute(p,d.index2),c.push(t.x,t.y,t.z)}else for(p=a.attributes.position,d=0,f=p.count/3;de;e++)m=3*d+e,t.fromBufferAttribute(p,m),c.push(t.x,t.y,t.z),m=3*d+(e+1)%3,t.fromBufferAttribute(p,m),c.push(t.x,t.y,t.z)}this.addAttribute("position",new z(c,3))} -function Hc(a,b,c){T.call(this);this.type="ParametricGeometry";this.parameters={func:a,slices:b,stacks:c};this.fromBufferGeometry(new Pb(a,b,c));this.mergeVertices()}function Pb(a,b,c){I.call(this);this.type="ParametricBufferGeometry";this.parameters={func:a,slices:b,stacks:c};var d=[],e=[],f=[],g,h,m=b+1;for(g=0;g<=c;g++){var k=g/c;for(h=0;h<=b;h++){var t=h/b,p=a(t,k);e.push(p.x,p.y,p.z);f.push(t,k)}}for(g=0;gd&&1===a.x&&(m[b]=a.x-1);0===c.x&&0===c.z&&(m[b]=d/2/Math.PI+ -.5)}I.call(this);this.type="PolyhedronBufferGeometry";this.parameters={vertices:a,indices:b,radius:c,detail:d};c=c||1;var h=[],m=[];(function(a){for(var c=new q,d=new q,g=new q,h=0;he&&(.2>b&&(m[a+0]+=1),.2>c&&(m[a+2]+=1),.2>d&&(m[a+4]+=1))})();this.addAttribute("position",new z(h,3));this.addAttribute("normal",new z(h.slice(),3));this.addAttribute("uv", -new z(m,2));this.normalizeNormals()}function Jc(a,b){T.call(this);this.type="TetrahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Qb(a,b));this.mergeVertices()}function Qb(a,b){Ba.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],a,b);this.type="TetrahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Kc(a,b){T.call(this);this.type="OctahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new ob(a,b));this.mergeVertices()} -function ob(a,b){Ba.call(this,[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],a,b);this.type="OctahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Lc(a,b){T.call(this);this.type="IcosahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Rb(a,b));this.mergeVertices()}function Rb(a,b){var c=(1+Math.sqrt(5))/2;Ba.call(this,[-1,c,0,1,c,0,-1,-c,0,1,-c,0,0,-1,c,0,1,c,0,-1,-c,0,1,-c,c,0,-1,c,0,1,-c,0,-1,-c,0,1],[0,11, -5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a,b);this.type="IcosahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Mc(a,b){T.call(this);this.type="DodecahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Sb(a,b));this.mergeVertices()}function Sb(a,b){var c=(1+Math.sqrt(5))/2,d=1/c;Ba.call(this,[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-d,-c,0,-d,c,0, -d,-c,0,d,c,-d,-c,0,-d,c,0,d,-c,0,d,c,0,-c,0,-d,c,0,-d,-c,0,d,c,0,d],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],a,b);this.type="DodecahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Nc(a,b,c,d,e,f){T.call(this);this.type="TubeGeometry";this.parameters={path:a, -tubularSegments:b,radius:c,radialSegments:d,closed:e};void 0!==f&&console.warn("THREE.TubeGeometry: taper has been removed.");a=new Tb(a,b,c,d,e);this.tangents=a.tangents;this.normals=a.normals;this.binormals=a.binormals;this.fromBufferGeometry(a);this.mergeVertices()}function Tb(a,b,c,d,e){function f(e){var f=a.getPointAt(e/b),k=g.normals[e];e=g.binormals[e];for(p=0;p<=d;p++){var t=p/d*Math.PI*2,r=Math.sin(t),t=-Math.cos(t);m.x=t*k.x+r*e.x;m.y=t*k.y+r*e.y;m.z=t*k.z+r*e.z;m.normalize();l.push(m.x, -m.y,m.z);h.x=f.x+c*m.x;h.y=f.y+c*m.y;h.z=f.z+c*m.z;n.push(h.x,h.y,h.z)}}I.call(this);this.type="TubeBufferGeometry";this.parameters={path:a,tubularSegments:b,radius:c,radialSegments:d,closed:e};b=b||64;c=c||1;d=d||8;e=e||!1;var g=a.computeFrenetFrames(b,e);this.tangents=g.tangents;this.normals=g.normals;this.binormals=g.binormals;var h=new q,m=new q,k=new D,t,p,n=[],l=[],G=[],r=[];for(t=0;tq;q++)f[0]=l[m[q]],f[1]=l[m[(q+1)%3]],f.sort(c),h=f.toString(),void 0===g[h]?g[h]={index1:f[0],index2:f[1],face1:p,face2:void 0}:g[h].face2=p;for(h in g)if(f=g[h],void 0===f.face2||k[f.face1].normal.dot(k[f.face2].normal)<= -e)m=t[f.index1],d.push(m.x,m.y,m.z),m=t[f.index2],d.push(m.x,m.y,m.z);this.addAttribute("position",new z(d,3))}function qb(a,b,c,d,e,f,g,h){T.call(this);this.type="CylinderGeometry";this.parameters={radiusTop:a,radiusBottom:b,height:c,radialSegments:d,heightSegments:e,openEnded:f,thetaStart:g,thetaLength:h};this.fromBufferGeometry(new Va(a,b,c,d,e,f,g,h));this.mergeVertices()}function Va(a,b,c,d,e,f,g,h){function m(c){var e,f,m,r=new D,C=new q,F=0,x=!0===c?a:b,H=!0===c?1:-1;f=G;for(e=1;e<=d;e++)p.push(0, -A*H,0),n.push(0,H,0),l.push(.5,.5),G++;m=G;for(e=0;e<=d;e++){var aa=e/d*h+g,z=Math.cos(aa),aa=Math.sin(aa);C.x=x*aa;C.y=A*H;C.z=x*z;p.push(C.x,C.y,C.z);n.push(0,H,0);r.x=.5*z+.5;r.y=.5*aa*H+.5;l.push(r.x,r.y);G++}for(e=0;ethis.duration&&this.resetDuration();this.optimize()}function Hd(a){this.manager= -void 0!==a?a:ta;this.textures={}}function ce(a){this.manager=void 0!==a?a:ta}function zb(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}}function de(a){"boolean"===typeof a&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),a=void 0);this.manager=void 0!==a?a:ta;this.withCredentials=!1}function Se(a){this.manager=void 0!==a?a:ta;this.texturePath=""}function Te(a,b,c,d,e){b=.5*(d-b);e=.5*(e-c);var f=a*a;return(2* -c-2*d+b+e)*a*f+(-3*c+3*d-2*b-e)*f+b*a+c}function Ab(a,b,c,d){var e=1-a;return e*e*b+2*(1-a)*a*c+a*a*d}function Bb(a,b,c,d,e){var f=1-a,g=1-a;return f*f*f*b+3*g*g*a*c+3*(1-a)*a*a*d+a*a*a*e}function ua(){}function Ta(a,b){this.v1=a;this.v2=b}function ad(){this.curves=[];this.autoClose=!1}function Wa(a,b,c,d,e,f,g,h){this.aX=a;this.aY=b;this.xRadius=c;this.yRadius=d;this.aStartAngle=e;this.aEndAngle=f;this.aClockwise=g;this.aRotation=h||0}function Cb(a){this.points=void 0===a?[]:a}function fc(a,b,c, -d){this.v0=a;this.v1=b;this.v2=c;this.v3=d}function gc(a,b,c){this.v0=a;this.v1=b;this.v2=c}function bd(a){ad.call(this);this.currentPoint=new D;a&&this.fromPoints(a)}function Db(){bd.apply(this,arguments);this.holes=[]}function ee(){this.subPaths=[];this.currentPath=null}function fe(a){this.data=a}function Ue(a){this.manager=void 0!==a?a:ta}function ge(a){this.manager=void 0!==a?a:ta}function he(a,b,c,d){ma.call(this,a,b);this.type="RectAreaLight";this.position.set(0,1,0);this.updateMatrix();this.width= -void 0!==c?c:10;this.height=void 0!==d?d:10}function Ve(){this.type="StereoCamera";this.aspect=1;this.eyeSep=.064;this.cameraL=new Fa;this.cameraL.layers.enable(1);this.cameraL.matrixAutoUpdate=!1;this.cameraR=new Fa;this.cameraR.layers.enable(2);this.cameraR.matrixAutoUpdate=!1}function Id(a,b,c){x.call(this);this.type="CubeCamera";var d=new Fa(90,1,a,b);d.up.set(0,-1,0);d.lookAt(new q(1,0,0));this.add(d);var e=new Fa(90,1,a,b);e.up.set(0,-1,0);e.lookAt(new q(-1,0,0));this.add(e);var f=new Fa(90, -1,a,b);f.up.set(0,0,1);f.lookAt(new q(0,1,0));this.add(f);var g=new Fa(90,1,a,b);g.up.set(0,0,-1);g.lookAt(new q(0,-1,0));this.add(g);var h=new Fa(90,1,a,b);h.up.set(0,-1,0);h.lookAt(new q(0,0,1));this.add(h);var m=new Fa(90,1,a,b);m.up.set(0,-1,0);m.lookAt(new q(0,0,-1));this.add(m);this.renderTarget=new Gb(c,c,{format:1022,magFilter:1006,minFilter:1006});this.updateCubeMap=function(a,b){null===this.parent&&this.updateMatrixWorld();var c=this.renderTarget,n=c.texture.generateMipmaps;c.texture.generateMipmaps= -!1;c.activeCubeFace=0;a.render(b,d,c);c.activeCubeFace=1;a.render(b,e,c);c.activeCubeFace=2;a.render(b,f,c);c.activeCubeFace=3;a.render(b,g,c);c.activeCubeFace=4;a.render(b,h,c);c.texture.generateMipmaps=n;c.activeCubeFace=5;a.render(b,m,c);a.setRenderTarget(null)}}function ie(){x.call(this);this.type="AudioListener";this.context=je.getContext();this.gain=this.context.createGain();this.gain.connect(this.context.destination);this.filter=null}function hc(a){x.call(this);this.type="Audio";this.context= -a.context;this.gain=this.context.createGain();this.gain.connect(a.getInput());this.autoplay=!1;this.buffer=null;this.loop=!1;this.startTime=0;this.playbackRate=1;this.isPlaying=!1;this.hasPlaybackControl=!0;this.sourceType="empty";this.filters=[]}function ke(a){hc.call(this,a);this.panner=this.context.createPanner();this.panner.connect(this.gain)}function le(a,b){this.analyser=a.context.createAnalyser();this.analyser.fftSize=void 0!==b?b:2048;this.data=new Uint8Array(this.analyser.frequencyBinCount); -a.getOutput().connect(this.analyser)}function Jd(a,b,c){this.binding=a;this.valueSize=c;a=Float64Array;switch(b){case "quaternion":b=this._slerp;break;case "string":case "bool":a=Array;b=this._select;break;default:b=this._lerp}this.buffer=new a(4*c);this._mixBufferRegion=b;this.referenceCount=this.useCount=this.cumulativeWeight=0}function ka(a,b,c){this.path=b;this.parsedPath=c||ka.parseTrackName(b);this.node=ka.findNode(a,this.parsedPath.nodeName)||a;this.rootNode=a}function me(a){this.uuid=N.generateUUID(); -this._objects=Array.prototype.slice.call(arguments);this.nCachedObjects_=0;var b={};this._indicesByUUID=b;for(var c=0,d=arguments.length;c!==d;++c)b[arguments[c].uuid]=c;this._paths=[];this._parsedPaths=[];this._bindings=[];this._bindingsIndicesByPath={};var e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}function ne(a,b,c){this._mixer=a;this._clip=b;this._localRoot=c||null;a=b.tracks; -b=a.length;c=Array(b);for(var d={endingStart:2400,endingEnd:2400},e=0;e!==b;++e){var f=a[e].createInterpolant(null);c[e]=f;f.settings=d}this._interpolantSettings=d;this._interpolants=c;this._propertyBindings=Array(b);this._weightInterpolant=this._timeScaleInterpolant=this._byClipCacheIndex=this._cacheIndex=null;this.loop=2201;this._loopCount=-1;this._startTime=null;this.time=0;this._effectiveWeight=this.weight=this._effectiveTimeScale=this.timeScale=1;this.repetitions=Infinity;this.paused=!1;this.enabled= -!0;this.clampWhenFinished=!1;this.zeroSlopeAtEnd=this.zeroSlopeAtStart=!0}function cd(a){this._root=a;this._initMemoryManager();this.time=this._accuIndex=0;this.timeScale=1}function Kd(a,b){"string"===typeof a&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),a=b);this.value=a}function Eb(){I.call(this);this.type="InstancedBufferGeometry";this.maxInstancedCount=void 0}function oe(a,b,c,d){this.uuid=N.generateUUID();this.data=a;this.itemSize=b;this.offset=c;this.normalized=!0=== -d}function ic(a,b){this.uuid=N.generateUUID();this.array=a;this.stride=b;this.count=void 0!==a?a.length/b:0;this.dynamic=!1;this.updateRange={offset:0,count:-1};this.onUploadCallback=function(){};this.version=0}function jc(a,b,c){ic.call(this,a,b);this.meshPerAttribute=c||1}function kc(a,b,c){U.call(this,a,b);this.meshPerAttribute=c||1}function pe(a,b,c,d){this.ray=new cb(a,b);this.near=c||0;this.far=d||Infinity;this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}};Object.defineProperties(this.params, -{PointCloud:{get:function(){console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points.");return this.Points}}})}function We(a,b){return a.distance-b.distance}function qe(a,b,c,d){if(!1!==a.visible&&(a.raycast(b,c),!0===d)){a=a.children;d=0;for(var e=a.length;dc;c++,d++){var e=c/32*Math.PI*2,f=d/32* -Math.PI*2;b.push(Math.cos(e),Math.sin(e),1,Math.cos(f),Math.sin(f),1)}a.addAttribute("position",new z(b,3));b=new ia({fog:!1});this.cone=new ga(a,b);this.add(this.cone);this.update()}function mc(a){this.bones=this.getBoneList(a);for(var b=new I,c=[],d=[],e=new J(0,0,1),f=new J(0,1,0),g=0;ga?-1:0e;e++)8===e||13===e||18===e||23===e?b[e]="-":14===e?b[e]="4":(2>=c&&(c=33554432+16777216*Math.random()|0),d=c&15,c>>=4,b[e]=a[19===e?d&3|8:d]);return b.join("")}}(),clamp:function(a,b,c){return Math.max(b,Math.min(c,a))},euclideanModulo:function(a,b){return(a%b+b)%b},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},lerp:function(a,b,c){return(1-c)*a+c*b},smoothstep:function(a, -b,c){if(a<=b)return 0;if(a>=c)return 1;a=(a-b)/(c-b);return a*a*(3-2*a)},smootherstep:function(a,b,c){if(a<=b)return 0;if(a>=c)return 1;a=(a-b)/(c-b);return a*a*a*(a*(6*a-15)+10)},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*(.5-Math.random())},degToRad:function(a){return a*N.DEG2RAD},radToDeg:function(a){return a*N.RAD2DEG},isPowerOfTwo:function(a){return 0===(a&a-1)&&0!==a},nearestPowerOfTwo:function(a){return Math.pow(2, -Math.round(Math.log(a)/Math.LN2))},nextPowerOfTwo:function(a){a--;a|=a>>1;a|=a>>2;a|=a>>4;a|=a>>8;a|=a>>16;a++;return a}};D.prototype={constructor:D,isVector2:!0,get width(){return this.x},set width(a){this.x=a},get height(){return this.y},set height(a){this.y=a},set:function(a,b){this.x=a;this.y=b;return this},setScalar:function(a){this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break; -case 1:this.y=b;break;default:throw Error("index is out of range: "+a);}return this},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(a){this.x=a.x;this.y=a.y;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x; -this.y+=a.y;return this},addScalar:function(a){this.x+=a;this.y+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;return this},subScalar:function(a){this.x-=a;this.y-=a;return this},subVectors:function(a,b){this.x= -a.x-b.x;this.y=a.y-b.y;return this},multiply:function(a){this.x*=a.x;this.y*=a.y;return this},multiplyScalar:function(a){isFinite(a)?(this.x*=a,this.y*=a):this.y=this.x=0;return this},divide:function(a){this.x/=a.x;this.y/=a.y;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);return this},clamp:function(a,b){this.x=Math.max(a.x, -Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));return this},clampScalar:function(){var a,b;return function(c,d){void 0===a&&(a=new D,b=new D);a.set(c,c);b.set(d,d);return this.clamp(a,b)}}(),clampLength:function(a,b){var c=this.length();return this.multiplyScalar(Math.max(a,Math.min(b,c))/c)},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);return this},round:function(){this.x=Math.round(this.x); -this.y=Math.round(this.y);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);return this},negate:function(){this.x=-this.x;this.y=-this.y;return this},dot:function(a){return this.x*a.x+this.y*a.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length())}, -angle:function(){var a=Math.atan2(this.y,this.x);0>a&&(a+=2*Math.PI);return a},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x;a=this.y-a.y;return b*b+a*a},distanceToManhattan:function(a){return Math.abs(this.x-a.x)+Math.abs(this.y-a.y)},setLength:function(a){return this.multiplyScalar(a/this.length())},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b, -a).multiplyScalar(c).add(a)},equals:function(a){return a.x===this.x&&a.y===this.y},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;return a},fromBufferAttribute:function(a,b,c){void 0!==c&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute().");this.x=a.getX(b);this.y=a.getY(b);return this},rotateAround:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=this.x- -a.x,f=this.y-a.y;this.x=e*c-f*d+a.x;this.y=e*d+f*c+a.y;return this}};var Ze=0;ea.DEFAULT_IMAGE=void 0;ea.DEFAULT_MAPPING=300;ea.prototype={constructor:ea,isTexture:!0,set needsUpdate(a){!0===a&&this.version++},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.image=a.image;this.mipmaps=a.mipmaps.slice(0);this.mapping=a.mapping;this.wrapS=a.wrapS;this.wrapT=a.wrapT;this.magFilter=a.magFilter;this.minFilter=a.minFilter;this.anisotropy=a.anisotropy;this.format=a.format; -this.type=a.type;this.offset.copy(a.offset);this.repeat.copy(a.repeat);this.generateMipmaps=a.generateMipmaps;this.premultiplyAlpha=a.premultiplyAlpha;this.flipY=a.flipY;this.unpackAlignment=a.unpackAlignment;this.encoding=a.encoding;return this},toJSON:function(a){if(void 0!==a.textures[this.uuid])return a.textures[this.uuid];var b={metadata:{version:4.4,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x, -this.offset.y],wrap:[this.wrapS,this.wrapT],minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY};if(void 0!==this.image){var c=this.image;void 0===c.uuid&&(c.uuid=N.generateUUID());if(void 0===a.images[c.uuid]){var d=a.images,e=c.uuid,f=c.uuid,g;void 0!==c.toDataURL?g=c:(g=document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),g.width=c.width,g.height=c.height,g.getContext("2d").drawImage(c,0,0,c.width,c.height));g=2048a.x||1a.x?0:1;break;case 1002:a.x=1===Math.abs(Math.floor(a.x)%2)?Math.ceil(a.x)-a.x:a.x-Math.floor(a.x)}if(0>a.y||1a.y?0:1;break;case 1002:a.y=1===Math.abs(Math.floor(a.y)%2)?Math.ceil(a.y)-a.y:a.y-Math.floor(a.y)}this.flipY&&(a.y=1-a.y)}}};Object.assign(ea.prototype,pa.prototype);fa.prototype={constructor:fa,isVector4:!0,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},setScalar:function(a){this.w=this.z=this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},setW:function(a){this.w=a;return this}, -setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;case 3:this.w=b;break;default:throw Error("index is out of range: "+a);}return this},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=void 0!==a.w? -a.w:1;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;this.w+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;this.z+=a.z*b;this.w+=a.w*b; -return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},subScalar:function(a){this.x-=a;this.y-=a;this.z-=a;this.w-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},multiplyScalar:function(a){isFinite(a)?(this.x*=a,this.y*=a,this.z*=a,this.w*=a):this.w=this.z= -this.y=this.x=0;return this},applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z,e=this.w;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d+a[12]*e;this.y=a[1]*b+a[5]*c+a[9]*d+a[13]*e;this.z=a[2]*b+a[6]*c+a[10]*d+a[14]*e;this.w=a[3]*b+a[7]*c+a[11]*d+a[15]*e;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},setAxisAngleFromQuaternion:function(a){this.w=2*Math.acos(a.w);var b=Math.sqrt(1-a.w*a.w);1E-4>b?(this.x=1,this.z=this.y=0):(this.x=a.x/b,this.y=a.y/b,this.z=a.z/b);return this}, -setAxisAngleFromRotationMatrix:function(a){var b,c,d;a=a.elements;var e=a[0];d=a[4];var f=a[8],g=a[1],h=a[5],m=a[9];c=a[2];b=a[6];var k=a[10];if(.01>Math.abs(d-g)&&.01>Math.abs(f-c)&&.01>Math.abs(m-b)){if(.1>Math.abs(d+g)&&.1>Math.abs(f+c)&&.1>Math.abs(m+b)&&.1>Math.abs(e+h+k-3))return this.set(1,0,0,0),this;a=Math.PI;e=(e+1)/2;h=(h+1)/2;k=(k+1)/2;d=(d+g)/4;f=(f+c)/4;m=(m+b)/4;e>h&&e>k?.01>e?(b=0,d=c=.707106781):(b=Math.sqrt(e),c=d/b,d=f/b):h>k?.01>h?(b=.707106781,c=0,d=.707106781):(c=Math.sqrt(h), -b=d/c,d=m/c):.01>k?(c=b=.707106781,d=0):(d=Math.sqrt(k),b=f/d,c=m/d);this.set(b,c,d,a);return this}a=Math.sqrt((b-m)*(b-m)+(f-c)*(f-c)+(g-d)*(g-d));.001>Math.abs(a)&&(a=1);this.x=(b-m)/a;this.y=(f-c)/a;this.z=(g-d)/a;this.w=Math.acos((e+h+k-1)/2);return this},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);this.z=Math.min(this.z,a.z);this.w=Math.min(this.w,a.w);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);this.z=Math.max(this.z,a.z); -this.w=Math.max(this.w,a.w);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));this.z=Math.max(a.z,Math.min(b.z,this.z));this.w=Math.max(a.w,Math.min(b.w,this.w));return this},clampScalar:function(){var a,b;return function(c,d){void 0===a&&(a=new fa,b=new fa);a.set(c,c,c,c);b.set(d,d,d,d);return this.clamp(a,b)}}(),floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);this.z=Math.floor(this.z);this.w=Math.floor(this.w); -return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);this.w=Math.ceil(this.w);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);this.w=Math.round(this.w);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z);this.w=0>this.w?Math.ceil(this.w):Math.floor(this.w); -return this},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;this.w=-this.w;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length())}, -setLength:function(a){return this.multiplyScalar(a/this.length())},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z&&a.w===this.w},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];this.z=a[b+2];this.w=a[b+3];return this},toArray:function(a,b){void 0===a&&(a= -[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;a[b+3]=this.w;return a},fromBufferAttribute:function(a,b,c){void 0!==c&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute().");this.x=a.getX(b);this.y=a.getY(b);this.z=a.getZ(b);this.w=a.getW(b);return this}};Ya.prototype={constructor:Ya,isWebGLRenderTarget:!0,setSize:function(a,b){if(this.width!==a||this.height!==b)this.width=a,this.height=b,this.dispose();this.viewport.set(0,0,a,b);this.scissor.set(0,0,a, -b)},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.width=a.width;this.height=a.height;this.viewport.copy(a.viewport);this.texture=a.texture.clone();this.depthBuffer=a.depthBuffer;this.stencilBuffer=a.stencilBuffer;this.depthTexture=a.depthTexture;return this},dispose:function(){this.dispatchEvent({type:"dispose"})}};Object.assign(Ya.prototype,pa.prototype);Gb.prototype=Object.create(Ya.prototype);Gb.prototype.constructor=Gb;Gb.prototype.isWebGLRenderTargetCube=!0; -ca.prototype={constructor:ca,get x(){return this._x},set x(a){this._x=a;this.onChangeCallback()},get y(){return this._y},set y(a){this._y=a;this.onChangeCallback()},get z(){return this._z},set z(a){this._z=a;this.onChangeCallback()},get w(){return this._w},set w(a){this._w=a;this.onChangeCallback()},set:function(a,b,c,d){this._x=a;this._y=b;this._z=c;this._w=d;this.onChangeCallback();return this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(a){this._x= -a.x;this._y=a.y;this._z=a.z;this._w=a.w;this.onChangeCallback();return this},setFromEuler:function(a,b){if(!1===(a&&a.isEuler))throw Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var c=Math.cos(a._x/2),d=Math.cos(a._y/2),e=Math.cos(a._z/2),f=Math.sin(a._x/2),g=Math.sin(a._y/2),h=Math.sin(a._z/2),m=a.order;"XYZ"===m?(this._x=f*d*e+c*g*h,this._y=c*g*e-f*d*h,this._z=c*d*h+f*g*e,this._w=c*d*e-f*g*h):"YXZ"===m?(this._x=f*d*e+c*g*h,this._y=c*g* -e-f*d*h,this._z=c*d*h-f*g*e,this._w=c*d*e+f*g*h):"ZXY"===m?(this._x=f*d*e-c*g*h,this._y=c*g*e+f*d*h,this._z=c*d*h+f*g*e,this._w=c*d*e-f*g*h):"ZYX"===m?(this._x=f*d*e-c*g*h,this._y=c*g*e+f*d*h,this._z=c*d*h-f*g*e,this._w=c*d*e+f*g*h):"YZX"===m?(this._x=f*d*e+c*g*h,this._y=c*g*e+f*d*h,this._z=c*d*h-f*g*e,this._w=c*d*e-f*g*h):"XZY"===m&&(this._x=f*d*e-c*g*h,this._y=c*g*e-f*d*h,this._z=c*d*h+f*g*e,this._w=c*d*e+f*g*h);if(!1!==b)this.onChangeCallback();return this},setFromAxisAngle:function(a,b){var c= -b/2,d=Math.sin(c);this._x=a.x*d;this._y=a.y*d;this._z=a.z*d;this._w=Math.cos(c);this.onChangeCallback();return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0];a=b[4];var d=b[8],e=b[1],f=b[5],g=b[9],h=b[2],m=b[6],b=b[10],k=c+f+b;0f&&c>b?(c=2*Math.sqrt(1+c-f-b),this._w=(m-g)/c,this._x=.25*c,this._y=(a+e)/c,this._z=(d+h)/c):f>b?(c=2*Math.sqrt(1+f-c-b),this._w=(d-h)/c,this._x=(a+e)/c,this._y=.25*c, -this._z=(g+m)/c):(c=2*Math.sqrt(1+b-c-f),this._w=(e-a)/c,this._x=(d+h)/c,this._y=(g+m)/c,this._z=.25*c);this.onChangeCallback();return this},setFromUnitVectors:function(){var a,b;return function(c,d){void 0===a&&(a=new q);b=c.dot(d)+1;1E-6>b?(b=0,Math.abs(c.x)>Math.abs(c.z)?a.set(-c.y,c.x,0):a.set(0,-c.z,c.y)):a.crossVectors(c,d);this._x=a.x;this._y=a.y;this._z=a.z;this._w=b;return this.normalize()}}(),inverse:function(){return this.conjugate().normalize()},conjugate:function(){this._x*=-1;this._y*= --1;this._z*=-1;this.onChangeCallback();return this},dot:function(a){return this._x*a._x+this._y*a._y+this._z*a._z+this._w*a._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var a=this.length();0===a?(this._z=this._y=this._x=0,this._w=1):(a=1/a,this._x*=a,this._y*=a,this._z*=a,this._w*=a);this.onChangeCallback();return this},multiply:function(a, -b){return void 0!==b?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(a,b)):this.multiplyQuaternions(this,a)},premultiply:function(a){return this.multiplyQuaternions(a,this)},multiplyQuaternions:function(a,b){var c=a._x,d=a._y,e=a._z,f=a._w,g=b._x,h=b._y,m=b._z,k=b._w;this._x=c*k+f*g+d*m-e*h;this._y=d*k+f*h+e*g-c*m;this._z=e*k+f*m+c*h-d*g;this._w=f*k-c*g-d*h-e*m;this.onChangeCallback();return this},slerp:function(a, -b){if(0===b)return this;if(1===b)return this.copy(a);var c=this._x,d=this._y,e=this._z,f=this._w,g=f*a._w+c*a._x+d*a._y+e*a._z;0>g?(this._w=-a._w,this._x=-a._x,this._y=-a._y,this._z=-a._z,g=-g):this.copy(a);if(1<=g)return this._w=f,this._x=c,this._y=d,this._z=e,this;var h=Math.sqrt(1-g*g);if(.001>Math.abs(h))return this._w=.5*(f+this._w),this._x=.5*(c+this._x),this._y=.5*(d+this._y),this._z=.5*(e+this._z),this;var m=Math.atan2(h,g),g=Math.sin((1-b)*m)/h,h=Math.sin(b*m)/h;this._w=f*g+this._w*h;this._x= -c*g+this._x*h;this._y=d*g+this._y*h;this._z=e*g+this._z*h;this.onChangeCallback();return this},equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._w===this._w},fromArray:function(a,b){void 0===b&&(b=0);this._x=a[b];this._y=a[b+1];this._z=a[b+2];this._w=a[b+3];this.onChangeCallback();return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;a[b+3]=this._w;return a},onChange:function(a){this.onChangeCallback=a;return this}, -onChangeCallback:function(){}};Object.assign(ca,{slerp:function(a,b,c,d){return c.copy(a).slerp(b,d)},slerpFlat:function(a,b,c,d,e,f,g){var h=c[d+0],m=c[d+1],k=c[d+2];c=c[d+3];d=e[f+0];var l=e[f+1],p=e[f+2];e=e[f+3];if(c!==e||h!==d||m!==l||k!==p){f=1-g;var n=h*d+m*l+k*p+c*e,u=0<=n?1:-1,q=1-n*n;q>Number.EPSILON&&(q=Math.sqrt(q),n=Math.atan2(q,n*u),f=Math.sin(f*n)/q,g=Math.sin(g*n)/q);u*=g;h=h*f+d*u;m=m*f+l*u;k=k*f+p*u;c=c*f+e*u;f===1-g&&(g=1/Math.sqrt(h*h+m*m+k*k+c*c),h*=g,m*=g,k*=g,c*=g)}a[b]=h;a[b+ -1]=m;a[b+2]=k;a[b+3]=c}});q.prototype={constructor:q,isVector3:!0,set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},setScalar:function(a){this.z=this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;default:throw Error("index is out of range: "+a);}return this},getComponent:function(a){switch(a){case 0:return this.x; -case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this}, -addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;this.z+=a.z*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},subScalar:function(a){this.x-=a;this.y-=a;this.z-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z= -a.z-b.z;return this},multiply:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(a,b);this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){isFinite(a)?(this.x*=a,this.y*=a,this.z*=a):this.z=this.y=this.x=0;return this},multiplyVectors:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},applyEuler:function(){var a;return function(b){!1===(b&& -b.isEuler)&&console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.");void 0===a&&(a=new ca);return this.applyQuaternion(a.setFromEuler(b))}}(),applyAxisAngle:function(){var a;return function(b,c){void 0===a&&(a=new ca);return this.applyQuaternion(a.setFromAxisAngle(b,c))}}(),applyMatrix3:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[3]*c+a[6]*d;this.y=a[1]*b+a[4]*c+a[7]*d;this.z=a[2]*b+a[5]*c+a[8]*d;return this},applyMatrix4:function(a){var b= -this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d+a[12];this.y=a[1]*b+a[5]*c+a[9]*d+a[13];this.z=a[2]*b+a[6]*c+a[10]*d+a[14];return this.divideScalar(a[3]*b+a[7]*c+a[11]*d+a[15])},applyQuaternion:function(a){var b=this.x,c=this.y,d=this.z,e=a.x,f=a.y,g=a.z;a=a.w;var h=a*b+f*d-g*c,m=a*c+g*b-e*d,k=a*d+e*c-f*b,b=-e*b-f*c-g*d;this.x=h*a+b*-e+m*-g-k*-f;this.y=m*a+b*-f+k*-e-h*-g;this.z=k*a+b*-g+h*-f-m*-e;return this},project:function(){var a;return function(b){void 0===a&&(a=new S);a.multiplyMatrices(b.projectionMatrix, -a.getInverse(b.matrixWorld));return this.applyMatrix4(a)}}(),unproject:function(){var a;return function(b){void 0===a&&(a=new S);a.multiplyMatrices(b.matrixWorld,a.getInverse(b.projectionMatrix));return this.applyMatrix4(a)}}(),transformDirection:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d;this.y=a[1]*b+a[5]*c+a[9]*d;this.z=a[2]*b+a[6]*c+a[10]*d;return this.normalize()},divide:function(a){this.x/=a.x;this.y/=a.y;this.z/=a.z;return this},divideScalar:function(a){return this.multiplyScalar(1/ -a)},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);this.z=Math.min(this.z,a.z);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);this.z=Math.max(this.z,a.z);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));this.z=Math.max(a.z,Math.min(b.z,this.z));return this},clampScalar:function(){var a,b;return function(c,d){void 0===a&&(a=new q,b=new q);a.set(c,c,c);b.set(d,d,d);return this.clamp(a, -b)}}(),clampLength:function(a,b){var c=this.length();return this.multiplyScalar(Math.max(a,Math.min(b,c))/c)},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);this.z=Math.floor(this.z);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x); -this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z);return this},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())}, -setLength:function(a){return this.multiplyScalar(a/this.length())},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},cross:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(a,b);var c=this.x,d=this.y,e=this.z;this.x=d*a.z-e*a.y;this.y=e*a.x-c*a.z;this.z=c*a.y- -d*a.x;return this},crossVectors:function(a,b){var c=a.x,d=a.y,e=a.z,f=b.x,g=b.y,h=b.z;this.x=d*h-e*g;this.y=e*f-c*h;this.z=c*g-d*f;return this},projectOnVector:function(a){var b=a.dot(this)/a.lengthSq();return this.copy(a).multiplyScalar(b)},projectOnPlane:function(){var a;return function(b){void 0===a&&(a=new q);a.copy(this).projectOnVector(b);return this.sub(a)}}(),reflect:function(){var a;return function(b){void 0===a&&(a=new q);return this.sub(a.copy(b).multiplyScalar(2*this.dot(b)))}}(),angleTo:function(a){a= -this.dot(a)/Math.sqrt(this.lengthSq()*a.lengthSq());return Math.acos(N.clamp(a,-1,1))},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},distanceToManhattan:function(a){return Math.abs(this.x-a.x)+Math.abs(this.y-a.y)+Math.abs(this.z-a.z)},setFromSpherical:function(a){var b=Math.sin(a.phi)*a.radius;this.x=b*Math.sin(a.theta);this.y=Math.cos(a.phi)*a.radius;this.z=b*Math.cos(a.theta);return this}, -setFromCylindrical:function(a){this.x=a.radius*Math.sin(a.theta);this.y=a.y;this.z=a.radius*Math.cos(a.theta);return this},setFromMatrixPosition:function(a){return this.setFromMatrixColumn(a,3)},setFromMatrixScale:function(a){var b=this.setFromMatrixColumn(a,0).length(),c=this.setFromMatrixColumn(a,1).length();a=this.setFromMatrixColumn(a,2).length();this.x=b;this.y=c;this.z=a;return this},setFromMatrixColumn:function(a,b){if("number"===typeof a){console.warn("THREE.Vector3: setFromMatrixColumn now expects ( matrix, index )."); -var c=a;a=b;b=c}return this.fromArray(a.elements,4*b)},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];this.z=a[b+2];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;return a},fromBufferAttribute:function(a,b,c){void 0!==c&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute().");this.x=a.getX(b);this.y=a.getY(b);this.z=a.getZ(b); -return this}};S.prototype={constructor:S,isMatrix4:!0,set:function(a,b,c,d,e,f,g,h,m,k,l,p,n,u,q,r){var A=this.elements;A[0]=a;A[4]=b;A[8]=c;A[12]=d;A[1]=e;A[5]=f;A[9]=g;A[13]=h;A[2]=m;A[6]=k;A[10]=l;A[14]=p;A[3]=n;A[7]=u;A[11]=q;A[15]=r;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},clone:function(){return(new S).fromArray(this.elements)},copy:function(a){this.elements.set(a.elements);return this},copyPosition:function(a){var b=this.elements;a=a.elements; -b[12]=a[12];b[13]=a[13];b[14]=a[14];return this},extractBasis:function(a,b,c){a.setFromMatrixColumn(this,0);b.setFromMatrixColumn(this,1);c.setFromMatrixColumn(this,2);return this},makeBasis:function(a,b,c){this.set(a.x,b.x,c.x,0,a.y,b.y,c.y,0,a.z,b.z,c.z,0,0,0,0,1);return this},extractRotation:function(){var a;return function(b){void 0===a&&(a=new q);var c=this.elements,d=b.elements,e=1/a.setFromMatrixColumn(b,0).length(),f=1/a.setFromMatrixColumn(b,1).length();b=1/a.setFromMatrixColumn(b,2).length(); -c[0]=d[0]*e;c[1]=d[1]*e;c[2]=d[2]*e;c[4]=d[4]*f;c[5]=d[5]*f;c[6]=d[6]*f;c[8]=d[8]*b;c[9]=d[9]*b;c[10]=d[10]*b;return this}}(),makeRotationFromEuler:function(a){!1===(a&&a.isEuler)&&console.error("THREE.Matrix: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var b=this.elements,c=a.x,d=a.y,e=a.z,f=Math.cos(c),c=Math.sin(c),g=Math.cos(d),d=Math.sin(d),h=Math.cos(e),e=Math.sin(e);if("XYZ"===a.order){a=f*h;var m=f*e,k=c*h,l=c*e;b[0]=g*h;b[4]=-g*e;b[8]=d;b[1]=m+ -k*d;b[5]=a-l*d;b[9]=-c*g;b[2]=l-a*d;b[6]=k+m*d;b[10]=f*g}else"YXZ"===a.order?(a=g*h,m=g*e,k=d*h,l=d*e,b[0]=a+l*c,b[4]=k*c-m,b[8]=f*d,b[1]=f*e,b[5]=f*h,b[9]=-c,b[2]=m*c-k,b[6]=l+a*c,b[10]=f*g):"ZXY"===a.order?(a=g*h,m=g*e,k=d*h,l=d*e,b[0]=a-l*c,b[4]=-f*e,b[8]=k+m*c,b[1]=m+k*c,b[5]=f*h,b[9]=l-a*c,b[2]=-f*d,b[6]=c,b[10]=f*g):"ZYX"===a.order?(a=f*h,m=f*e,k=c*h,l=c*e,b[0]=g*h,b[4]=k*d-m,b[8]=a*d+l,b[1]=g*e,b[5]=l*d+a,b[9]=m*d-k,b[2]=-d,b[6]=c*g,b[10]=f*g):"YZX"===a.order?(a=f*g,m=f*d,k=c*g,l=c*d,b[0]= -g*h,b[4]=l-a*e,b[8]=k*e+m,b[1]=e,b[5]=f*h,b[9]=-c*h,b[2]=-d*h,b[6]=m*e+k,b[10]=a-l*e):"XZY"===a.order&&(a=f*g,m=f*d,k=c*g,l=c*d,b[0]=g*h,b[4]=-e,b[8]=d*h,b[1]=a*e+l,b[5]=f*h,b[9]=m*e-k,b[2]=k*e-m,b[6]=c*h,b[10]=l*e+a);b[3]=0;b[7]=0;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return this},makeRotationFromQuaternion:function(a){var b=this.elements,c=a.x,d=a.y,e=a.z,f=a.w,g=c+c,h=d+d,m=e+e;a=c*g;var k=c*h,c=c*m,l=d*h,d=d*m,e=e*m,g=f*g,h=f*h,f=f*m;b[0]=1-(l+e);b[4]=k-f;b[8]=c+h;b[1]=k+f;b[5]=1-(a+e);b[9]= -d-g;b[2]=c-h;b[6]=d+g;b[10]=1-(a+l);b[3]=0;b[7]=0;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return this},lookAt:function(){var a,b,c;return function(d,e,f){void 0===a&&(a=new q,b=new q,c=new q);var g=this.elements;c.subVectors(d,e).normalize();0===c.lengthSq()&&(c.z=1);a.crossVectors(f,c).normalize();0===a.lengthSq()&&(c.z+=1E-4,a.crossVectors(f,c).normalize());b.crossVectors(c,a);g[0]=a.x;g[4]=b.x;g[8]=c.x;g[1]=a.y;g[5]=b.y;g[9]=c.y;g[2]=a.z;g[6]=b.z;g[10]=c.z;return this}}(),multiply:function(a,b){return void 0!== -b?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(a,b)):this.multiplyMatrices(this,a)},premultiply:function(a){return this.multiplyMatrices(a,this)},multiplyMatrices:function(a,b){var c=a.elements,d=b.elements,e=this.elements,f=c[0],g=c[4],h=c[8],m=c[12],k=c[1],l=c[5],p=c[9],n=c[13],u=c[2],q=c[6],r=c[10],A=c[14],w=c[3],y=c[7],K=c[11],c=c[15],v=d[0],E=d[4],L=d[8],C=d[12],F=d[1],x=d[5],H=d[9],D=d[13],z=d[2],J=d[6], -I=d[10],Q=d[14],M=d[3],O=d[7],P=d[11],d=d[15];e[0]=f*v+g*F+h*z+m*M;e[4]=f*E+g*x+h*J+m*O;e[8]=f*L+g*H+h*I+m*P;e[12]=f*C+g*D+h*Q+m*d;e[1]=k*v+l*F+p*z+n*M;e[5]=k*E+l*x+p*J+n*O;e[9]=k*L+l*H+p*I+n*P;e[13]=k*C+l*D+p*Q+n*d;e[2]=u*v+q*F+r*z+A*M;e[6]=u*E+q*x+r*J+A*O;e[10]=u*L+q*H+r*I+A*P;e[14]=u*C+q*D+r*Q+A*d;e[3]=w*v+y*F+K*z+c*M;e[7]=w*E+y*x+K*J+c*O;e[11]=w*L+y*H+K*I+c*P;e[15]=w*C+y*D+K*Q+c*d;return this},multiplyToArray:function(a,b,c){var d=this.elements;this.multiplyMatrices(a,b);c[0]=d[0];c[1]=d[1];c[2]= -d[2];c[3]=d[3];c[4]=d[4];c[5]=d[5];c[6]=d[6];c[7]=d[7];c[8]=d[8];c[9]=d[9];c[10]=d[10];c[11]=d[11];c[12]=d[12];c[13]=d[13];c[14]=d[14];c[15]=d[15];return this},multiplyScalar:function(a){var b=this.elements;b[0]*=a;b[4]*=a;b[8]*=a;b[12]*=a;b[1]*=a;b[5]*=a;b[9]*=a;b[13]*=a;b[2]*=a;b[6]*=a;b[10]*=a;b[14]*=a;b[3]*=a;b[7]*=a;b[11]*=a;b[15]*=a;return this},applyToBufferAttribute:function(){var a;return function(b){void 0===a&&(a=new q);for(var c=0,d=b.count;cthis.determinant()&&(g=-g);c.x=f[12];c.y=f[13];c.z=f[14];b.elements.set(this.elements);c=1/g;var f=1/h,k=1/m;b.elements[0]*=c;b.elements[1]*=c;b.elements[2]*=c;b.elements[4]*=f;b.elements[5]*=f;b.elements[6]*=f;b.elements[8]*=k;b.elements[9]*=k;b.elements[10]*=k;d.setFromRotationMatrix(b); -e.x=g;e.y=h;e.z=m;return this}}(),makePerspective:function(a,b,c,d,e,f){void 0===f&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");var g=this.elements;g[0]=2*e/(b-a);g[4]=0;g[8]=(b+a)/(b-a);g[12]=0;g[1]=0;g[5]=2*e/(c-d);g[9]=(c+d)/(c-d);g[13]=0;g[2]=0;g[6]=0;g[10]=-(f+e)/(f-e);g[14]=-2*f*e/(f-e);g[3]=0;g[7]=0;g[11]=-1;g[15]=0;return this},makeOrthographic:function(a,b,c,d,e,f){var g=this.elements,h=1/(b-a),m=1/(c-d),k=1/(f-e);g[0]= -2*h;g[4]=0;g[8]=0;g[12]=-((b+a)*h);g[1]=0;g[5]=2*m;g[9]=0;g[13]=-((c+d)*m);g[2]=0;g[6]=0;g[10]=-2*k;g[14]=-((f+e)*k);g[3]=0;g[7]=0;g[11]=0;g[15]=1;return this},equals:function(a){var b=this.elements;a=a.elements;for(var c=0;16>c;c++)if(b[c]!==a[c])return!1;return!0},fromArray:function(a,b){void 0===b&&(b=0);for(var c=0;16>c;c++)this.elements[c]=a[c+b];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);var c=this.elements;a[b]=c[0];a[b+1]=c[1];a[b+2]=c[2];a[b+3]=c[3];a[b+4]=c[4]; -a[b+5]=c[5];a[b+6]=c[6];a[b+7]=c[7];a[b+8]=c[8];a[b+9]=c[9];a[b+10]=c[10];a[b+11]=c[11];a[b+12]=c[12];a[b+13]=c[13];a[b+14]=c[14];a[b+15]=c[15];return a}};Za.prototype=Object.create(ea.prototype);Za.prototype.constructor=Za;Za.prototype.isCubeTexture=!0;Object.defineProperty(Za.prototype,"images",{get:function(){return this.image},set:function(a){this.image=a}});var Ee=new ea,Fe=new Za,Be=[],De=[];Je.prototype.setValue=function(a,b){for(var c=this.seq,d=0,e=c.length;d!==e;++d){var f=c[d];f.setValue(a, -b[f.id])}};var Rd=/([\w\d_]+)(\])?(\[|\.)?/g;$a.prototype.setValue=function(a,b,c){b=this.map[b];void 0!==b&&b.setValue(a,c,this.renderer)};$a.prototype.set=function(a,b,c){var d=this.map[c];void 0!==d&&d.setValue(a,b[c],this.renderer)};$a.prototype.setOptional=function(a,b,c){b=b[c];void 0!==b&&this.setValue(a,c,b)};$a.upload=function(a,b,c,d){for(var e=0,f=b.length;e!==f;++e){var g=b[e],h=c[g.id];!1!==h.needsUpdate&&g.setValue(a,h.value,d)}};$a.seqWithValue=function(a,b){for(var c=[],d=0,e=a.length;d!== -e;++d){var f=a[d];f.id in b&&c.push(f)}return c};var Ja={merge:function(a){for(var b={},c=0;c 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t\t}\n\t\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 ltcTextureCoords( const in GeometricContext geometry, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = (LUT_SIZE - 1.0)/LUT_SIZE;\n\tconst float LUT_BIAS = 0.5/LUT_SIZE;\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 P = geometry.position;\n\tfloat theta = acos( dot( N, V ) );\n\tvec2 uv = vec2(\n\t\tsqrt( saturate( roughness ) ),\n\t\tsaturate( theta / ( 0.5 * PI ) ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nvoid clipQuadToHorizon( inout vec3 L[5], out int n ) {\n\tint config = 0;\n\tif ( L[0].z > 0.0 ) config += 1;\n\tif ( L[1].z > 0.0 ) config += 2;\n\tif ( L[2].z > 0.0 ) config += 4;\n\tif ( L[3].z > 0.0 ) config += 8;\n\tn = 0;\n\tif ( config == 0 ) {\n\t} else if ( config == 1 ) {\n\t\tn = 3;\n\t\tL[1] = -L[1].z * L[0] + L[0].z * L[1];\n\t\tL[2] = -L[3].z * L[0] + L[0].z * L[3];\n\t} else if ( config == 2 ) {\n\t\tn = 3;\n\t\tL[0] = -L[0].z * L[1] + L[1].z * L[0];\n\t\tL[2] = -L[2].z * L[1] + L[1].z * L[2];\n\t} else if ( config == 3 ) {\n\t\tn = 4;\n\t\tL[2] = -L[2].z * L[1] + L[1].z * L[2];\n\t\tL[3] = -L[3].z * L[0] + L[0].z * L[3];\n\t} else if ( config == 4 ) {\n\t\tn = 3;\n\t\tL[0] = -L[3].z * L[2] + L[2].z * L[3];\n\t\tL[1] = -L[1].z * L[2] + L[2].z * L[1];\n\t} else if ( config == 5 ) {\n\t\tn = 0;\n\t} else if ( config == 6 ) {\n\t\tn = 4;\n\t\tL[0] = -L[0].z * L[1] + L[1].z * L[0];\n\t\tL[3] = -L[3].z * L[2] + L[2].z * L[3];\n\t} else if ( config == 7 ) {\n\t\tn = 5;\n\t\tL[4] = -L[3].z * L[0] + L[0].z * L[3];\n\t\tL[3] = -L[3].z * L[2] + L[2].z * L[3];\n\t} else if ( config == 8 ) {\n\t\tn = 3;\n\t\tL[0] = -L[0].z * L[3] + L[3].z * L[0];\n\t\tL[1] = -L[2].z * L[3] + L[3].z * L[2];\n\t\tL[2] = L[3];\n\t} else if ( config == 9 ) {\n\t\tn = 4;\n\t\tL[1] = -L[1].z * L[0] + L[0].z * L[1];\n\t\tL[2] = -L[2].z * L[3] + L[3].z * L[2];\n\t} else if ( config == 10 ) {\n\t\tn = 0;\n\t} else if ( config == 11 ) {\n\t\tn = 5;\n\t\tL[4] = L[3];\n\t\tL[3] = -L[2].z * L[3] + L[3].z * L[2];\n\t\tL[2] = -L[2].z * L[1] + L[1].z * L[2];\n\t} else if ( config == 12 ) {\n\t\tn = 4;\n\t\tL[1] = -L[1].z * L[2] + L[2].z * L[1];\n\t\tL[0] = -L[0].z * L[3] + L[3].z * L[0];\n\t} else if ( config == 13 ) {\n\t\tn = 5;\n\t\tL[4] = L[3];\n\t\tL[3] = L[2];\n\t\tL[2] = -L[1].z * L[2] + L[2].z * L[1];\n\t\tL[1] = -L[1].z * L[0] + L[0].z * L[1];\n\t} else if ( config == 14 ) {\n\t\tn = 5;\n\t\tL[4] = -L[0].z * L[3] + L[3].z * L[0];\n\t\tL[0] = -L[0].z * L[1] + L[1].z * L[0];\n\t} else if ( config == 15 ) {\n\t\tn = 4;\n\t}\n\tif ( n == 3 )\n\t\tL[3] = L[0];\n\tif ( n == 4 )\n\t\tL[4] = L[0];\n}\nfloat integrateLtcBrdfOverRectEdge( vec3 v1, vec3 v2 ) {\n\tfloat cosTheta = dot( v1, v2 );\n\tfloat theta = acos( cosTheta );\n\tfloat res = cross( v1, v2 ).z * ( ( theta > 0.001 ) ? theta / sin( theta ) : 1.0 );\n\treturn res;\n}\nvoid initRectPoints( const in vec3 pos, const in vec3 halfWidth, const in vec3 halfHeight, out vec3 rectPoints[4] ) {\n\trectPoints[0] = pos - halfWidth - halfHeight;\n\trectPoints[1] = pos + halfWidth - halfHeight;\n\trectPoints[2] = pos + halfWidth + halfHeight;\n\trectPoints[3] = pos - halfWidth + halfHeight;\n}\nvec3 integrateLtcBrdfOverRect( const in GeometricContext geometry, const in mat3 brdfMat, const in vec3 rectPoints[4] ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 P = geometry.position;\n\tvec3 T1, T2;\n\tT1 = normalize(V - N * dot( V, N ));\n\tT2 = - cross( N, T1 );\n\tmat3 brdfWrtSurface = brdfMat * transpose( mat3( T1, T2, N ) );\n\tvec3 clippedRect[5];\n\tclippedRect[0] = brdfWrtSurface * ( rectPoints[0] - P );\n\tclippedRect[1] = brdfWrtSurface * ( rectPoints[1] - P );\n\tclippedRect[2] = brdfWrtSurface * ( rectPoints[2] - P );\n\tclippedRect[3] = brdfWrtSurface * ( rectPoints[3] - P );\n\tint n;\n\tclipQuadToHorizon(clippedRect, n);\n\tif ( n == 0 )\n\t\treturn vec3( 0, 0, 0 );\n\tclippedRect[0] = normalize( clippedRect[0] );\n\tclippedRect[1] = normalize( clippedRect[1] );\n\tclippedRect[2] = normalize( clippedRect[2] );\n\tclippedRect[3] = normalize( clippedRect[3] );\n\tclippedRect[4] = normalize( clippedRect[4] );\n\tfloat sum = 0.0;\n\tsum += integrateLtcBrdfOverRectEdge( clippedRect[0], clippedRect[1] );\n\tsum += integrateLtcBrdfOverRectEdge( clippedRect[1], clippedRect[2] );\n\tsum += integrateLtcBrdfOverRectEdge( clippedRect[2], clippedRect[3] );\n\tif (n >= 4)\n\t\tsum += integrateLtcBrdfOverRectEdge( clippedRect[3], clippedRect[4] );\n\tif (n == 5)\n\t\tsum += integrateLtcBrdfOverRectEdge( clippedRect[4], clippedRect[0] );\n\tsum = max( 0.0, sum );\n\tvec3 Lo_i = vec3( sum, sum, sum );\n\treturn Lo_i;\n}\nvec3 Rect_Area_Light_Specular_Reflectance(\n\t\tconst in GeometricContext geometry,\n\t\tconst in vec3 lightPos, const in vec3 lightHalfWidth, const in vec3 lightHalfHeight,\n\t\tconst in float roughness,\n\t\tconst in sampler2D ltcMat, const in sampler2D ltcMag ) {\n\tvec3 rectPoints[4];\n\tinitRectPoints( lightPos, lightHalfWidth, lightHalfHeight, rectPoints );\n\tvec2 uv = ltcTextureCoords( geometry, roughness );\n\tvec4 brdfLtcApproxParams, t;\n\tbrdfLtcApproxParams = texture2D( ltcMat, uv );\n\tt = texture2D( ltcMat, uv );\n\tfloat brdfLtcScalar = texture2D( ltcMag, uv ).a;\n\tmat3 brdfLtcApproxMat = mat3(\n\t\tvec3( 1, 0, t.y ),\n\t\tvec3( 0, t.z, 0 ),\n\t\tvec3( t.w, 0, t.x )\n\t);\n\tvec3 specularReflectance = integrateLtcBrdfOverRect( geometry, brdfLtcApproxMat, rectPoints );\n\tspecularReflectance *= brdfLtcScalar;\n\treturn specularReflectance;\n}\nvec3 Rect_Area_Light_Diffuse_Reflectance(\n\t\tconst in GeometricContext geometry,\n\t\tconst in vec3 lightPos, const in vec3 lightHalfWidth, const in vec3 lightHalfHeight ) {\n\tvec3 rectPoints[4];\n\tinitRectPoints( lightPos, lightHalfWidth, lightHalfHeight, rectPoints );\n\tmat3 diffuseBrdfMat = mat3(1);\n\tvec3 diffuseReflectance = integrateLtcBrdfOverRect( geometry, diffuseBrdfMat, rectPoints );\n\treturn diffuseReflectance;\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n", -bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = dFdx( surf_pos );\n\t\tvec3 vSigmaY = dFdy( surf_pos );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n", -clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; ++ i ) {\n\t\tvec4 plane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t\t\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; ++ i ) {\n\t\t\tvec4 plane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t\n\t#endif\n#endif\n", -clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvarying vec3 vViewPosition;\n#endif\n",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n", -color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transpose( const in mat3 v ) {\n\tmat3 tmp;\n\ttmp[0] = vec3(v[0].x, v[1].x, v[2].x);\n\ttmp[1] = vec3(v[0].y, v[1].y, v[2].y);\n\ttmp[2] = vec3(v[0].z, v[1].z, v[2].z);\n\treturn tmp;\n}\n", -cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n", -defaultnormal_vertex:"#ifdef FLIP_SIDED\n\tobjectNormal = -objectNormal;\n#endif\nvec3 transformedNormal = normalMatrix * objectNormal;\n",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normal * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n", -emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n",encodings_fragment:" gl_FragColor = linearToOutputTexel( gl_FragColor );\n",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract(Le);\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n", -envmap_fragment:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\tsampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n\t\tsampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\tvec3 reflectView = flipNormal * normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif\n", -envmap_pars_fragment:"#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntensity;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n", -envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif\n",envmap_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif\n", -fog_vertex:"\n#ifdef USE_FOG\nfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n varying float fogDepth;\n#endif\n",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif\n",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif\n", -gradientmap_pars_fragment:"#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif\n",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n", -lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n", -lights_pars:"uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltcMat;\tuniform sampler2D ltcMag;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = saturate( reflectVec.y * 0.5 + 0.5 );\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n", -lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_BlinnPhong( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 matDiffColor = material.diffuseColor;\n\t\tvec3 matSpecColor = material.specularColor;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = BlinnExponentToGGXRoughness( material.specularShininess );\n\t\tvec3 spec = Rect_Area_Light_Specular_Reflectance(\n\t\t\t\tgeometry,\n\t\t\t\trectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight,\n\t\t\t\troughness,\n\t\t\t\tltcMat, ltcMag );\n\t\tvec3 diff = Rect_Area_Light_Diffuse_Reflectance(\n\t\t\t\tgeometry,\n\t\t\t\trectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight );\n\t\treflectedLight.directSpecular += lightColor * matSpecColor * spec / PI2;\n\t\treflectedLight.directDiffuse += lightColor * matDiffColor * diff / PI2;\n\t}\n#endif\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifdef TOON\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#else\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\t#endif\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n", -lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif\n", -lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 matDiffColor = material.diffuseColor;\n\t\tvec3 matSpecColor = material.specularColor;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 spec = Rect_Area_Light_Specular_Reflectance(\n\t\t\t\tgeometry,\n\t\t\t\trectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight,\n\t\t\t\troughness,\n\t\t\t\tltcMat, ltcMag );\n\t\tvec3 diff = Rect_Area_Light_Diffuse_Reflectance(\n\t\t\t\tgeometry,\n\t\t\t\trectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight );\n\t\treflectedLight.directSpecular += lightColor * matSpecColor * spec;\n\t\treflectedLight.directDiffuse += lightColor * matDiffColor * diff;\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n", -lights_template:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, 8 );\n\t#endif\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tvec3 radiance = getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), 8 );\n\t#ifndef STANDARD\n\t\tvec3 clearCoatRadiance = getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), 8 );\n\t#else\n\t\tvec3 clearCoatRadiance = vec3( 0.0 );\n\t#endif\n\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif\n", -logdepthbuf_fragment:"#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\n\tgl_FragDepthEXT = log2(vFragDepth) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#ifdef USE_LOGDEPTHBUF\n\tuniform float logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n#endif\n",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n\tuniform float logDepthBufFC;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\tgl_Position.z = log2(max( EPSILON, gl_Position.w + 1.0 )) * logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = (gl_Position.z - 1.0) * gl_Position.w;\n\t#endif\n#endif\n", -map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n",map_particle_fragment:"#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) * offsetRepeat.zw + offsetRepeat.xy );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n",map_particle_pars_fragment:"#ifdef USE_MAP\n\tuniform vec4 offsetRepeat;\n\tuniform sampler2D map;\n#endif\n", -metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.r;\n#endif\n",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif\n", -morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif\n", -normal_flip:"#ifdef DOUBLE_SIDED\n\tfloat flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n#else\n\tfloat flipNormal = 1.0;\n#endif\n",normal_fragment:"#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal ) * flipNormal;\n#endif\n#ifdef USE_NORMALMAP\n\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n", -normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 S = normalize( q0 * st1.t - q1 * st0.t );\n\t\tvec3 T = normalize( -q0 * st1.s + q1 * st0.s );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif\n", -packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 1.0 - 2.0 * rgb.xyz;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n", -premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n",project_vertex:"#ifdef USE_SKINNING\n\tvec4 mvPosition = modelViewMatrix * skinned;\n#else\n\tvec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\n#endif\ngl_Position = projectionMatrix * mvPosition;\n",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.r;\n#endif\n", -roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\treturn (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn 1.0;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\tfloat dp = ( length( lightToPosition ) - shadowBias ) / 1000.0;\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif\n", -shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n#endif\n", -shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif\n", -shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}\n", -skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureWidth;\n\t\tuniform int boneTextureHeight;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureWidth ) );\n\t\t\tfloat y = floor( j / float( boneTextureWidth ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureWidth );\n\t\t\tfloat dy = 1.0 / float( boneTextureHeight );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif\n", -skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\tskinned = bindMatrixInverse * skinned;\n#endif\n",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n#endif\n", -specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif\n",tonemapping_pars_fragment:"#define saturate(a) clamp( a, 0.0, 1.0 )\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n", -uv_pars_fragment:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform vec4 offsetRepeat;\n#endif\n", -uv_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif", -uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( PHYSICAL ) || defined( LAMBERT ) || defined ( USE_SHADOWMAP )\n\t#ifdef USE_SKINNING\n\t\tvec4 worldPosition = modelMatrix * skinned;\n\t#else\n\t\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n\t#endif\n#endif\n",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldPosition;\n#include \nvoid main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n\tgl_FragColor.a *= opacity;\n}\n", -cube_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}\n", -depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n", -distanceRGBA_frag:"uniform vec3 lightPos;\nvarying vec4 vWorldPosition;\n#include \n#include \n#include \nvoid main () {\n\t#include \n\tgl_FragColor = packDepthToRGBA( length( vWorldPosition.xyz - lightPos.xyz ) / 1000.0 );\n}\n",distanceRGBA_vert:"varying vec4 vWorldPosition;\n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition;\n}\n", -equirect_frag:"uniform sampler2D tEquirect;\nuniform float tFlip;\nvarying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldPosition );\n\tvec2 sampleUV;\n\tsampleUV.y = saturate( tFlip * direction.y * -0.5 + 0.5 );\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n}\n",equirect_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n", -linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n", -linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}\n", -meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n", -meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n", -meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n", -meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n", -meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n", -meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}\n", -meshphysical_frag:"#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n", -meshphysical_vert:"#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}\n", -normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}\n", -normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}\n", -points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n", -points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#ifdef USE_SIZEATTENUATION\n\t\tgl_PointSize = size * ( scale / - mvPosition.z );\n\t#else\n\t\tgl_PointSize = size;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n", -shadow_frag:"uniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( 0.0, 0.0, 0.0, opacity * ( 1.0 - getShadowMask() ) );\n}\n",shadow_vert:"#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n}\n"};J.prototype={constructor:J, -isColor:!0,r:1,g:1,b:1,set:function(a){a&&a.isColor?this.copy(a):"number"===typeof a?this.setHex(a):"string"===typeof a&&this.setStyle(a);return this},setScalar:function(a){this.b=this.g=this.r=a;return this},setHex:function(a){a=Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSL:function(){function a(a,c,d){0>d&&(d+=1);1d?c:d<2/3?a+6*(c-a)*(2/3-d):a}return function(b, -c,d){b=N.euclideanModulo(b,1);c=N.clamp(c,0,1);d=N.clamp(d,0,1);0===c?this.r=this.g=this.b=d:(c=.5>=d?d*(1+c):d+c-d*c,d=2*d-c,this.r=a(d,c,b+1/3),this.g=a(d,c,b),this.b=a(d,c,b-1/3));return this}}(),setStyle:function(a){function b(b){void 0!==b&&1>parseFloat(b)&&console.warn("THREE.Color: Alpha component of "+a+" will be ignored.")}var c;if(c=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(a)){var d=c[2];switch(c[1]){case "rgb":case "rgba":if(c=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d))return this.r= -Math.min(255,parseInt(c[1],10))/255,this.g=Math.min(255,parseInt(c[2],10))/255,this.b=Math.min(255,parseInt(c[3],10))/255,b(c[5]),this;if(c=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d))return this.r=Math.min(100,parseInt(c[1],10))/100,this.g=Math.min(100,parseInt(c[2],10))/100,this.b=Math.min(100,parseInt(c[3],10))/100,b(c[5]),this;break;case "hsl":case "hsla":if(c=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d)){var d=parseFloat(c[1])/ -360,e=parseInt(c[2],10)/100,f=parseInt(c[3],10)/100;b(c[5]);return this.setHSL(d,e,f)}}}else if(c=/^\#([A-Fa-f0-9]+)$/.exec(a)){c=c[1];d=c.length;if(3===d)return this.r=parseInt(c.charAt(0)+c.charAt(0),16)/255,this.g=parseInt(c.charAt(1)+c.charAt(1),16)/255,this.b=parseInt(c.charAt(2)+c.charAt(2),16)/255,this;if(6===d)return this.r=parseInt(c.charAt(0)+c.charAt(1),16)/255,this.g=parseInt(c.charAt(2)+c.charAt(3),16)/255,this.b=parseInt(c.charAt(4)+c.charAt(5),16)/255,this}a&&0=h?m/(e+f): -m/(2-e-f);switch(e){case b:g=(c-d)/m+(cthis.max.x||a.ythis.max.y?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y},getParameter:function(a,b){return(b||new D).set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y- -this.min.y))},intersectsBox:function(a){return a.max.xthis.max.x||a.max.ythis.max.y?!1:!0},clampPoint:function(a,b){return(b||new D).copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a=new D;return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),intersect:function(a){this.min.max(a.min);this.max.min(a.max);return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},translate:function(a){this.min.add(a); -this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)}};var Af=0;X.prototype={constructor:X,isMaterial:!0,get needsUpdate(){return this._needsUpdate},set needsUpdate(a){!0===a&&this.update();this._needsUpdate=a},setValues:function(a){if(void 0!==a)for(var b in a){var c=a[b];if(void 0===c)console.warn("THREE.Material: '"+b+"' parameter is undefined.");else{var d=this[b];void 0===d?console.warn("THREE."+this.type+": '"+b+"' is not a property of this material."): -d&&d.isColor?d.set(c):d&&d.isVector3&&c&&c.isVector3?d.copy(c):this[b]="overdraw"===b?Number(c):c}}},toJSON:function(a){function b(a){var b=[],c;for(c in a){var d=a[c];delete d.metadata;b.push(d)}return b}var c=void 0===a;c&&(a={textures:{},images:{}});var d={metadata:{version:4.4,type:"Material",generator:"Material.toJSON"}};d.uuid=this.uuid;d.type=this.type;""!==this.name&&(d.name=this.name);this.color&&this.color.isColor&&(d.color=this.color.getHex());void 0!==this.roughness&&(d.roughness=this.roughness); -void 0!==this.metalness&&(d.metalness=this.metalness);this.emissive&&this.emissive.isColor&&(d.emissive=this.emissive.getHex());this.specular&&this.specular.isColor&&(d.specular=this.specular.getHex());void 0!==this.shininess&&(d.shininess=this.shininess);void 0!==this.clearCoat&&(d.clearCoat=this.clearCoat);void 0!==this.clearCoatRoughness&&(d.clearCoatRoughness=this.clearCoatRoughness);this.map&&this.map.isTexture&&(d.map=this.map.toJSON(a).uuid);this.alphaMap&&this.alphaMap.isTexture&&(d.alphaMap= -this.alphaMap.toJSON(a).uuid);this.lightMap&&this.lightMap.isTexture&&(d.lightMap=this.lightMap.toJSON(a).uuid);this.bumpMap&&this.bumpMap.isTexture&&(d.bumpMap=this.bumpMap.toJSON(a).uuid,d.bumpScale=this.bumpScale);this.normalMap&&this.normalMap.isTexture&&(d.normalMap=this.normalMap.toJSON(a).uuid,d.normalScale=this.normalScale.toArray());this.displacementMap&&this.displacementMap.isTexture&&(d.displacementMap=this.displacementMap.toJSON(a).uuid,d.displacementScale=this.displacementScale,d.displacementBias= -this.displacementBias);this.roughnessMap&&this.roughnessMap.isTexture&&(d.roughnessMap=this.roughnessMap.toJSON(a).uuid);this.metalnessMap&&this.metalnessMap.isTexture&&(d.metalnessMap=this.metalnessMap.toJSON(a).uuid);this.emissiveMap&&this.emissiveMap.isTexture&&(d.emissiveMap=this.emissiveMap.toJSON(a).uuid);this.specularMap&&this.specularMap.isTexture&&(d.specularMap=this.specularMap.toJSON(a).uuid);this.envMap&&this.envMap.isTexture&&(d.envMap=this.envMap.toJSON(a).uuid,d.reflectivity=this.reflectivity); -this.gradientMap&&this.gradientMap.isTexture&&(d.gradientMap=this.gradientMap.toJSON(a).uuid);void 0!==this.size&&(d.size=this.size);void 0!==this.sizeAttenuation&&(d.sizeAttenuation=this.sizeAttenuation);1!==this.blending&&(d.blending=this.blending);2!==this.shading&&(d.shading=this.shading);0!==this.side&&(d.side=this.side);0!==this.vertexColors&&(d.vertexColors=this.vertexColors);1>this.opacity&&(d.opacity=this.opacity);!0===this.transparent&&(d.transparent=this.transparent);d.depthFunc=this.depthFunc; -d.depthTest=this.depthTest;d.depthWrite=this.depthWrite;0e&&(e=k);l>f&&(f=l);p>g&&(g=p)}this.min.set(b,c,d);this.max.set(e,f,g);return this},setFromBufferAttribute:function(a){for(var b=Infinity,c=Infinity,d=Infinity,e=-Infinity,f=-Infinity,g=-Infinity,h=0,m=a.count;he&&(e=k);l>f&&(f=l);p>g&&(g=p)}this.min.set(b,c,d);this.max.set(e,f,g);return this},setFromPoints:function(a){this.makeEmpty();for(var b=0,c=a.length;bthis.max.x||a.ythis.max.y||a.zthis.max.z?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y&&this.min.z<=a.min.z&&a.max.z<=this.max.z},getParameter:function(a, -b){return(b||new q).set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y),(a.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(a){return a.max.xthis.max.x||a.max.ythis.max.y||a.max.zthis.max.z?!1:!0},intersectsSphere:function(){var a;return function(b){void 0===a&&(a=new q);this.clampPoint(b.center,a);return a.distanceToSquared(b.center)<=b.radius*b.radius}}(),intersectsPlane:function(a){var b, -c;0=a.constant},clampPoint:function(a,b){return(b||new q).copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a=new q; -return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),getBoundingSphere:function(){var a=new q;return function(b){b=b||new Na;this.getCenter(b.center);b.radius=.5*this.getSize(a).length();return b}}(),intersect:function(a){this.min.max(a.min);this.max.min(a.max);this.isEmpty()&&this.makeEmpty();return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},applyMatrix4:function(){var a=[new q,new q,new q,new q,new q,new q,new q,new q];return function(b){if(this.isEmpty())return this; -a[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(b);a[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(b);a[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(b);a[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(b);a[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(b);a[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(b);a[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(b);a[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(b);this.setFromPoints(a);return this}}(), -translate:function(a){this.min.add(a);this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)}};Na.prototype={constructor:Na,set:function(a,b){this.center.copy(a);this.radius=b;return this},setFromPoints:function(){var a;return function(b,c){void 0===a&&(a=new Pa);var d=this.center;void 0!==c?d.copy(c):a.setFromPoints(b).getCenter(d);for(var e=0,f=0,g=b.length;f=this.radius},containsPoint:function(a){return a.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(a){return a.distanceTo(this.center)-this.radius},intersectsSphere:function(a){var b=this.radius+a.radius;return a.center.distanceToSquared(this.center)<=b*b},intersectsBox:function(a){return a.intersectsSphere(this)},intersectsPlane:function(a){return Math.abs(this.center.dot(a.normal)- -a.constant)<=this.radius},clampPoint:function(a,b){var c=this.center.distanceToSquared(a),d=b||new q;d.copy(a);c>this.radius*this.radius&&(d.sub(this.center).normalize(),d.multiplyScalar(this.radius).add(this.center));return d},getBoundingBox:function(a){a=a||new Pa;a.set(this.center,this.center);a.expandByScalar(this.radius);return a},applyMatrix4:function(a){this.center.applyMatrix4(a);this.radius*=a.getMaxScaleOnAxis();return this},translate:function(a){this.center.add(a);return this},equals:function(a){return a.center.equals(this.center)&& -a.radius===this.radius}};ya.prototype={constructor:ya,isMatrix3:!0,set:function(a,b,c,d,e,f,g,h,m){var k=this.elements;k[0]=a;k[1]=d;k[2]=g;k[3]=b;k[4]=e;k[5]=h;k[6]=c;k[7]=f;k[8]=m;return this},identity:function(){this.set(1,0,0,0,1,0,0,0,1);return this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(a){a=a.elements;this.set(a[0],a[3],a[6],a[1],a[4],a[7],a[2],a[5],a[8]);return this},setFromMatrix4:function(a){a=a.elements;this.set(a[0],a[4],a[8],a[1],a[5],a[9], -a[2],a[6],a[10]);return this},applyToBufferAttribute:function(){var a;return function(b){void 0===a&&(a=new q);for(var c=0,d=b.count;cc;c++)this.elements[c]=a[c+b];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);var c=this.elements;a[b]=c[0];a[b+1]=c[1];a[b+2]=c[2];a[b+3]=c[3];a[b+4]=c[4];a[b+5]=c[5];a[b+6]=c[6];a[b+7]=c[7];a[b+8]=c[8];return a}};la.prototype={constructor:la,set:function(a,b){this.normal.copy(a);this.constant=b;return this},setComponents:function(a,b,c,d){this.normal.set(a,b,c);this.constant=d;return this},setFromNormalAndCoplanarPoint:function(a, -b){this.normal.copy(a);this.constant=-b.dot(this.normal);return this},setFromCoplanarPoints:function(){var a=new q,b=new q;return function(c,d,e){d=a.subVectors(e,d).cross(b.subVectors(c,d)).normalize();this.setFromNormalAndCoplanarPoint(d,c);return this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.normal.copy(a.normal);this.constant=a.constant;return this},normalize:function(){var a=1/this.normal.length();this.normal.multiplyScalar(a);this.constant*=a;return this}, -negate:function(){this.constant*=-1;this.normal.negate();return this},distanceToPoint:function(a){return this.normal.dot(a)+this.constant},distanceToSphere:function(a){return this.distanceToPoint(a.center)-a.radius},projectPoint:function(a,b){return this.orthoPoint(a,b).sub(a).negate()},orthoPoint:function(a,b){var c=this.distanceToPoint(a);return(b||new q).copy(this.normal).multiplyScalar(c)},intersectLine:function(){var a=new q;return function(b,c){var d=c||new q,e=b.delta(a),f=this.normal.dot(e); -if(0===f){if(0===this.distanceToPoint(b.start))return d.copy(b.start)}else return f=-(b.start.dot(this.normal)+this.constant)/f,0>f||1b&&0a&&0c;c++)b[c].copy(a.planes[c]);return this},setFromMatrix:function(a){var b=this.planes,c=a.elements;a=c[0];var d=c[1],e=c[2],f=c[3],g=c[4],h=c[5],m=c[6],k=c[7],l=c[8],p=c[9],n=c[10],u=c[11],q=c[12],r=c[13],A=c[14],c=c[15];b[0].setComponents(f-a,k-g,u-l,c-q).normalize();b[1].setComponents(f+a,k+g,u+l,c+q).normalize();b[2].setComponents(f+d,k+h,u+p,c+r).normalize();b[3].setComponents(f- -d,k-h,u-p,c-r).normalize();b[4].setComponents(f-e,k-m,u-n,c-A).normalize();b[5].setComponents(f+e,k+m,u+n,c+A).normalize();return this},intersectsObject:function(){var a=new Na;return function(b){var c=b.geometry;null===c.boundingSphere&&c.computeBoundingSphere();a.copy(c.boundingSphere).applyMatrix4(b.matrixWorld);return this.intersectsSphere(a)}}(),intersectsSprite:function(){var a=new Na;return function(b){a.center.set(0,0,0);a.radius=.7071067811865476;a.applyMatrix4(b.matrixWorld);return this.intersectsSphere(a)}}(), -intersectsSphere:function(a){var b=this.planes,c=a.center;a=-a.radius;for(var d=0;6>d;d++)if(b[d].distanceToPoint(c)e;e++){var f=d[e];a.x=0 -g&&0>f)return!1}return!0}}(),containsPoint:function(a){for(var b=this.planes,c=0;6>c;c++)if(0>b[c].distanceToPoint(a))return!1;return!0}};cb.prototype={constructor:cb,set:function(a,b){this.origin.copy(a);this.direction.copy(b);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.origin.copy(a.origin);this.direction.copy(a.direction);return this},at:function(a,b){return(b||new q).copy(this.direction).multiplyScalar(a).add(this.origin)},lookAt:function(a){this.direction.copy(a).sub(this.origin).normalize(); -return this},recast:function(){var a=new q;return function(b){this.origin.copy(this.at(b,a));return this}}(),closestPointToPoint:function(a,b){var c=b||new q;c.subVectors(a,this.origin);var d=c.dot(this.direction);return 0>d?c.copy(this.origin):c.copy(this.direction).multiplyScalar(d).add(this.origin)},distanceToPoint:function(a){return Math.sqrt(this.distanceSqToPoint(a))},distanceSqToPoint:function(){var a=new q;return function(b){var c=a.subVectors(b,this.origin).dot(this.direction);if(0>c)return this.origin.distanceToSquared(b); -a.copy(this.direction).multiplyScalar(c).add(this.origin);return a.distanceToSquared(b)}}(),distanceSqToSegment:function(){var a=new q,b=new q,c=new q;return function(d,e,f,g){a.copy(d).add(e).multiplyScalar(.5);b.copy(e).sub(d).normalize();c.copy(this.origin).sub(a);var h=.5*d.distanceTo(e),m=-this.direction.dot(b),k=c.dot(this.direction),l=-c.dot(b),p=c.lengthSq(),n=Math.abs(1-m*m),u;0=-u?e<=u?(h=1/n,d*=h,e*=h,m=d*(d+m*e+2*k)+e*(m*d+e+2*l)+p):(e=h,d=Math.max(0,-(m* -e+k)),m=-d*d+e*(e+2*l)+p):(e=-h,d=Math.max(0,-(m*e+k)),m=-d*d+e*(e+2*l)+p):e<=-u?(d=Math.max(0,-(-m*h+k)),e=0f)return null;f=Math.sqrt(f-e);e=d-f;d+=f;return 0>e&&0>d?null:0>e?this.at(d,c):this.at(e,c)}}(),intersectsSphere:function(a){return this.distanceToPoint(a.center)<=a.radius},distanceToPlane:function(a){var b=a.normal.dot(this.direction);if(0===b)return 0===a.distanceToPoint(this.origin)?0:null;a=-(this.origin.dot(a.normal)+a.constant)/b;return 0<=a?a:null},intersectPlane:function(a, -b){var c=this.distanceToPlane(a);return null===c?null:this.at(c,b)},intersectsPlane:function(a){var b=a.distanceToPoint(this.origin);return 0===b||0>a.normal.dot(this.direction)*b?!0:!1},intersectBox:function(a,b){var c,d,e,f,g;d=1/this.direction.x;f=1/this.direction.y;g=1/this.direction.z;var h=this.origin;0<=d?(c=(a.min.x-h.x)*d,d*=a.max.x-h.x):(c=(a.max.x-h.x)*d,d*=a.min.x-h.x);0<=f?(e=(a.min.y-h.y)*f,f*=a.max.y-h.y):(e=(a.max.y-h.y)*f,f*=a.min.y-h.y);if(c>f||e>d)return null;if(e>c||c!==c)c=e; -if(fg||e>d)return null;if(e>c||c!==c)c=e;if(gd?null:this.at(0<=c?c:d,b)},intersectsBox:function(){var a=new q;return function(b){return null!==this.intersectBox(b,a)}}(),intersectTriangle:function(){var a=new q,b=new q,c=new q,d=new q;return function(e,f,g,h,m){b.subVectors(f,e);c.subVectors(g,e);d.crossVectors(b,c);f=this.direction.dot(d);if(0f)h= --1,f=-f;else return null;a.subVectors(this.origin,e);e=h*this.direction.dot(c.crossVectors(a,c));if(0>e)return null;g=h*this.direction.dot(b.cross(a));if(0>g||e+g>f)return null;e=-h*a.dot(d);return 0>e?null:this.at(e/f,m)}}(),applyMatrix4:function(a){this.direction.add(this.origin).applyMatrix4(a);this.origin.applyMatrix4(a);this.direction.sub(this.origin);this.direction.normalize();return this},equals:function(a){return a.origin.equals(this.origin)&&a.direction.equals(this.direction)}};db.RotationOrders= -"XYZ YZX ZXY XZY YXZ ZYX".split(" ");db.DefaultOrder="XYZ";db.prototype={constructor:db,isEuler:!0,get x(){return this._x},set x(a){this._x=a;this.onChangeCallback()},get y(){return this._y},set y(a){this._y=a;this.onChangeCallback()},get z(){return this._z},set z(a){this._z=a;this.onChangeCallback()},get order(){return this._order},set order(a){this._order=a;this.onChangeCallback()},set:function(a,b,c,d){this._x=a;this._y=b;this._z=c;this._order=d||this._order;this.onChangeCallback();return this}, -clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(a){this._x=a._x;this._y=a._y;this._z=a._z;this._order=a._order;this.onChangeCallback();return this},setFromRotationMatrix:function(a,b,c){var d=N.clamp,e=a.elements;a=e[0];var f=e[4],g=e[8],h=e[1],m=e[5],k=e[9],l=e[2],p=e[6],e=e[10];b=b||this._order;"XYZ"===b?(this._y=Math.asin(d(g,-1,1)),.99999>Math.abs(g)?(this._x=Math.atan2(-k,e),this._z=Math.atan2(-f,a)):(this._x=Math.atan2(p,m),this._z=0)):"YXZ"=== -b?(this._x=Math.asin(-d(k,-1,1)),.99999>Math.abs(k)?(this._y=Math.atan2(g,e),this._z=Math.atan2(h,m)):(this._y=Math.atan2(-l,a),this._z=0)):"ZXY"===b?(this._x=Math.asin(d(p,-1,1)),.99999>Math.abs(p)?(this._y=Math.atan2(-l,e),this._z=Math.atan2(-f,m)):(this._y=0,this._z=Math.atan2(h,a))):"ZYX"===b?(this._y=Math.asin(-d(l,-1,1)),.99999>Math.abs(l)?(this._x=Math.atan2(p,e),this._z=Math.atan2(h,a)):(this._x=0,this._z=Math.atan2(-f,m))):"YZX"===b?(this._z=Math.asin(d(h,-1,1)),.99999>Math.abs(h)?(this._x= -Math.atan2(-k,m),this._y=Math.atan2(-l,a)):(this._x=0,this._y=Math.atan2(g,e))):"XZY"===b?(this._z=Math.asin(-d(f,-1,1)),.99999>Math.abs(f)?(this._x=Math.atan2(p,m),this._y=Math.atan2(g,a)):(this._x=Math.atan2(-k,e),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+b);this._order=b;if(!1!==c)this.onChangeCallback();return this},setFromQuaternion:function(){var a;return function(b,c,d){void 0===a&&(a=new S);a.makeRotationFromQuaternion(b);return this.setFromRotationMatrix(a, -c,d)}}(),setFromVector3:function(a,b){return this.set(a.x,a.y,a.z,b||this._order)},reorder:function(){var a=new ca;return function(b){a.setFromEuler(this);return this.setFromQuaternion(a,b)}}(),equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._order===this._order},fromArray:function(a){this._x=a[0];this._y=a[1];this._z=a[2];void 0!==a[3]&&(this._order=a[3]);this.onChangeCallback();return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this._x;a[b+1]= -this._y;a[b+2]=this._z;a[b+3]=this._order;return a},toVector3:function(a){return a?a.set(this._x,this._y,this._z):new q(this._x,this._y,this._z)},onChange:function(a){this.onChangeCallback=a;return this},onChangeCallback:function(){}};nd.prototype={constructor:nd,set:function(a){this.mask=1<=b.x+b.y}}();za.prototype={constructor:za,set:function(a,b,c){this.a.copy(a);this.b.copy(b);this.c.copy(c);return this},setFromPointsAndIndices:function(a,b,c,d){this.a.copy(a[b]);this.b.copy(a[c]);this.c.copy(a[d]);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.a.copy(a.a);this.b.copy(a.b);this.c.copy(a.c);return this}, -area:function(){var a=new q,b=new q;return function(){a.subVectors(this.c,this.b);b.subVectors(this.a,this.b);return.5*a.cross(b).length()}}(),midpoint:function(a){return(a||new q).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(a){return za.normal(this.a,this.b,this.c,a)},plane:function(a){return(a||new la).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(a,b){return za.barycoordFromPoint(a,this.a,this.b,this.c,b)},containsPoint:function(a){return za.containsPoint(a, -this.a,this.b,this.c)},closestPointToPoint:function(){var a,b,c,d;return function(e,f){void 0===a&&(a=new la,b=[new hb,new hb,new hb],c=new q,d=new q);var g=f||new q,h=Infinity;a.setFromCoplanarPoints(this.a,this.b,this.c);a.projectPoint(e,c);if(!0===this.containsPoint(c))g.copy(c);else{b[0].set(this.a,this.b);b[1].set(this.b,this.c);b[2].set(this.c,this.a);for(var m=0;md;d++)if(e[d]===e[(d+1)%3]){a.push(f);break}for(f=a.length-1;0<=f;f--)for(e=a[f],this.faces.splice(e,1),c=0,g=this.faceVertexUvs.length;cb.far?null:{distance:c,point:w.clone(),object:a}}function c(c,d,e,f,k,l,p,t){g.fromBufferAttribute(f,l);h.fromBufferAttribute(f,p);m.fromBufferAttribute(f,t);if(c=b(c,d,e,g,h,m,A))k&&(n.fromBufferAttribute(k,l),u.fromBufferAttribute(k,p),G.fromBufferAttribute(k,t),c.uv=a(A,g,h,m,n,u,G)),c.face= -new ha(l,p,t,za.normal(g,h,m)),c.faceIndex=l;return c}var d=new S,e=new cb,f=new Na,g=new q,h=new q,m=new q,k=new q,l=new q,p=new q,n=new D,u=new D,G=new D,r=new q,A=new q,w=new q;return function(q,r){var v=this.geometry,w=this.material,L=this.matrixWorld;if(void 0!==w&&(null===v.boundingSphere&&v.computeBoundingSphere(),f.copy(v.boundingSphere),f.applyMatrix4(L),!1!==q.ray.intersectsSphere(f)&&(d.getInverse(L),e.copy(q.ray).applyMatrix4(d),null===v.boundingBox||!1!==e.intersectsBox(v.boundingBox)))){var C; -if(v.isBufferGeometry){var F,x,w=v.index,H=v.attributes.position,L=v.attributes.uv,D,z;if(null!==w)for(D=0,z=w.count;Dthis.scale.x*this.scale.y/4||c.push({distance:Math.sqrt(d),point:this.position, -face:null,object:this})}}(),clone:function(){return(new this.constructor(this.material)).copy(this)}});Ec.prototype=Object.assign(Object.create(x.prototype),{constructor:Ec,copy:function(a){x.prototype.copy.call(this,a,!1);a=a.levels;for(var b=0,c=a.length;b=d[e].distance)d[e- -1].object.visible=!1,d[e].object.visible=!0;else break;for(;ef||(l.applyMatrix4(this.matrixWorld), -r=d.ray.origin.distanceTo(l),rd.far||e.push({distance:r,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}else for(g=0,G=u.length/3-1;gf||(l.applyMatrix4(this.matrixWorld),r=d.ray.origin.distanceTo(l),rd.far||e.push({distance:r,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}else if(g.isGeometry)for(m=g.vertices, -k=m.length,g=0;gf||(l.applyMatrix4(this.matrixWorld),r=d.ray.origin.distanceTo(l),rd.far||e.push({distance:r,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}}}(),clone:function(){return(new this.constructor(this.geometry,this.material)).copy(this)}});ga.prototype=Object.assign(Object.create(Ua.prototype),{constructor:ga,isLineSegments:!0});Oa.prototype=Object.create(X.prototype);Oa.prototype.constructor= -Oa;Oa.prototype.isPointsMaterial=!0;Oa.prototype.copy=function(a){X.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.size=a.size;this.sizeAttenuation=a.sizeAttenuation;return this};Mb.prototype=Object.assign(Object.create(x.prototype),{constructor:Mb,isPoints:!0,raycast:function(){var a=new S,b=new cb,c=new Na;return function(d,e){function f(a,c){var f=b.distanceSqToPoint(a);if(fd.far||e.push({distance:k,distanceToRay:Math.sqrt(f),point:h.clone(),index:c,face:null,object:g})}}var g=this,h=this.geometry,m=this.matrixWorld,k=d.params.Points.threshold;null===h.boundingSphere&&h.computeBoundingSphere();c.copy(h.boundingSphere);c.applyMatrix4(m);if(!1!==d.ray.intersectsSphere(c)){a.getInverse(m);b.copy(d.ray).applyMatrix4(a);var k=k/((this.scale.x+this.scale.y+this.scale.z)/3),l=k*k,k=new q;if(h.isBufferGeometry){var p=h.index,h=h.attributes.position.array;if(null!==p)for(var n= -p.array,p=0,u=n.length;pc)return null;var d=[],e=[],f=[],g,h,m;if(0=k--){console.warn("THREE.ShapeUtils: Unable to triangulate polygon! in triangulate()");break}g=h;c<=g&&(g=0);h=g+1;c<=h&&(h=0);m=h+1;c<=m&&(m=0);var l;a:{var p,n,q,G,r,A,w,y;p=a[e[g]].x;n=a[e[g]].y;q=a[e[h]].x;G=a[e[h]].y;r=a[e[m]].x;A=a[e[m]].y;if(0>=(q- -p)*(A-n)-(G-n)*(r-p))l=!1;else{var K,v,E,x,C,F,D,H,z,J;K=r-q;v=A-G;E=p-r;x=n-A;C=q-p;F=G-n;for(l=0;l=-Number.EPSILON&&H>=-Number.EPSILON&&D>=-Number.EPSILON)){l=!1;break a}l=!0}}if(l){d.push([a[e[g]],a[e[h]],a[e[m]]]);f.push([e[g],e[h],e[m]]);g=h;for(m=h+1;mNumber.EPSILON){if(0t||t>p)return[];k=m*l-k*n;if(0>k||k>p)return[]}else{if(0c?[]:k===c?f?[]:[g]:a<=c?[g,h]:[g,m]}function f(a,b,c,d){var e=b.x-a.x,f=b.y-a.y;b=c.x-a.x;c=c.y-a.y;var g=d.x-a.x;d=d.y-a.y;a=e*c-f*b;e=e*d-f*g;return Math.abs(a)>Number.EPSILON?(b=g*c-d*b,0e&&(e=d);var g=a+1;g>d&&(g=0);d=f(h[a],h[e],h[g],k[b]);if(!d)return!1;d=k.length-1;e=b-1;0>e&&(e=d);g=b+1;g>d&&(g=0);return(d=f(k[b],k[e],k[g],h[a]))?!0:!1}function d(a,b){var c,f;for(c=0;cQ){console.log("Infinite Loop! Holes left:"+m.length+", Probably Hole outside Shape!");break}for(n=D;nm;m++)l=k[m].x+":"+k[m].y,l=p[l],void 0!==l&&(k[m]=l);return n.concat()},isClockWise:function(a){return 0>Ia.area(a)}};La.prototype=Object.create(T.prototype);La.prototype.constructor=La;La.prototype.addShapeList=function(a,b){for(var c=a.length,d=0;dNumber.EPSILON){var k=Math.sqrt(h),m=Math.sqrt(d*d+g*g),h=b.x-f/k;b=b.y+e/k;g=((c.x-g/m-h)*g-(c.y+d/m-b)*d)/(e*g-f*d);d=h+e*g-a.x;e=b+f*g-a.y;f=d*d+e*e;if(2>=f)return new D(d,e);f=Math.sqrt(f/2)}else a=!1,e>Number.EPSILON?d>Number.EPSILON&&(a=!0):e<-Number.EPSILON?d<-Number.EPSILON&&(a=!0):Math.sign(f)===Math.sign(g)&&(a=!0),a?(d=-f,f=Math.sqrt(h)):(d=e,e=f,f=Math.sqrt(h/2));return new D(d/f,e/f)} -function e(a,b){var c,d;for(R=a.length;0<=--R;){c=R;d=R-1;0>d&&(d=a.length-1);var e,f=u+2*l;for(e=0;eMath.abs(b.y-c.y)?[new D(b.x,1-b.z),new D(c.x,1-c.z),new D(d.x,1-d.z),new D(e.x,1-e.z)]:[new D(b.y,1-b.z),new D(c.y,1-c.z),new D(d.y,1-d.z),new D(e.y,1-e.z)]}};Qc.prototype=Object.create(La.prototype);Qc.prototype.constructor=Qc;Rc.prototype=Object.create(T.prototype);Rc.prototype.constructor=Rc;pb.prototype=Object.create(I.prototype);pb.prototype.constructor=pb;Sc.prototype=Object.create(T.prototype);Sc.prototype.constructor= -Sc;Wb.prototype=Object.create(I.prototype);Wb.prototype.constructor=Wb;Tc.prototype=Object.create(T.prototype);Tc.prototype.constructor=Tc;Xb.prototype=Object.create(I.prototype);Xb.prototype.constructor=Xb;Yb.prototype=Object.create(T.prototype);Yb.prototype.constructor=Yb;Zb.prototype=Object.create(I.prototype);Zb.prototype.constructor=Zb;$b.prototype=Object.create(I.prototype);$b.prototype.constructor=$b;qb.prototype=Object.create(T.prototype);qb.prototype.constructor=qb;Va.prototype=Object.create(I.prototype); -Va.prototype.constructor=Va;Uc.prototype=Object.create(qb.prototype);Uc.prototype.constructor=Uc;Vc.prototype=Object.create(Va.prototype);Vc.prototype.constructor=Vc;Wc.prototype=Object.create(T.prototype);Wc.prototype.constructor=Wc;ac.prototype=Object.create(I.prototype);ac.prototype.constructor=ac;var Ma=Object.freeze({WireframeGeometry:Ob,ParametricGeometry:Hc,ParametricBufferGeometry:Pb,TetrahedronGeometry:Jc,TetrahedronBufferGeometry:Qb,OctahedronGeometry:Kc,OctahedronBufferGeometry:ob,IcosahedronGeometry:Lc, -IcosahedronBufferGeometry:Rb,DodecahedronGeometry:Mc,DodecahedronBufferGeometry:Sb,PolyhedronGeometry:Ic,PolyhedronBufferGeometry:Ba,TubeGeometry:Nc,TubeBufferGeometry:Tb,TorusKnotGeometry:Oc,TorusKnotBufferGeometry:Ub,TorusGeometry:Pc,TorusBufferGeometry:Vb,TextGeometry:Qc,SphereGeometry:Rc,SphereBufferGeometry:pb,RingGeometry:Sc,RingBufferGeometry:Wb,PlaneGeometry:Ac,PlaneBufferGeometry:lb,LatheGeometry:Tc,LatheBufferGeometry:Xb,ShapeGeometry:Yb,ShapeBufferGeometry:Zb,ExtrudeGeometry:La,EdgesGeometry:$b, -ConeGeometry:Uc,ConeBufferGeometry:Vc,CylinderGeometry:qb,CylinderBufferGeometry:Va,CircleGeometry:Wc,CircleBufferGeometry:ac,BoxGeometry:Ib,BoxBufferGeometry:kb});bc.prototype=Object.create(Ha.prototype);bc.prototype.constructor=bc;bc.prototype.isShadowMaterial=!0;cc.prototype=Object.create(Ha.prototype);cc.prototype.constructor=cc;cc.prototype.isRawShaderMaterial=!0;Xc.prototype={constructor:Xc,isMultiMaterial:!0,toJSON:function(a){for(var b={metadata:{version:4.2,type:"material",generator:"MaterialExporter"}, -uuid:this.uuid,type:this.type,materials:[]},c=this.materials,d=0,e=c.length;d=e)break a;else{f=b[1];a=e)break b}d=c;c=0}}for(;c>>1,ab;)--f;++f;if(0!==e||f!==d)e>=f&&(f=Math.max(f,1),e=f-1),d=this.getValueSize(),this.times=na.arraySlice(c,e,f),this.values=na.arraySlice(this.values,e*d,f*d);return this},validate:function(){var a=!0,b=this.getValueSize();0!==b-Math.floor(b)&&(console.error("invalid value size in track",this),a=!1);var c=this.times,b=this.values,d=c.length;0===d&&(console.error("track is empty", -this),a=!1);for(var e=null,f=0;f!==d;f++){var g=c[f];if("number"===typeof g&&isNaN(g)){console.error("time is not a valid number",this,f,g);a=!1;break}if(null!==e&&e>g){console.error("out of order keys",this,f,g,e);a=!1;break}e=g}if(void 0!==b&&na.isTypedArray(b))for(f=0,c=b.length;f!==c;++f)if(d=b[f],isNaN(d)){console.error("value is not a valid number",this,f,d);a=!1;break}return a},optimize:function(){for(var a=this.times,b=this.values,c=this.getValueSize(),d=2302===this.getInterpolation(),e=1, -f=a.length-1,g=1;gk.opacity&&(k.transparent=!0);d.setTextures(m);return d.parse(k)}}()};zb.Handlers={handlers:[],add:function(a,b){this.handlers.push(a,b)},get:function(a){for(var b=this.handlers,c=0,d=b.length;cg;g++)n=y[m++],w=A[2*n],n=A[2*n+1],w=new D(w,n),2!==g&&c.faceVertexUvs[d][h].push(w),0!==g&&c.faceVertexUvs[d][h+1].push(w);p&&(p=3*y[m++],u.normal.set(x[p++],x[p++],x[p]), -r.normal.copy(u.normal));if(G)for(d=0;4>d;d++)p=3*y[m++],G=new q(x[p++],x[p++],x[p]),2!==d&&u.vertexNormals.push(G),0!==d&&r.vertexNormals.push(G);l&&(l=y[m++],l=v[l],u.color.setHex(l),r.color.setHex(l));if(b)for(d=0;4>d;d++)l=y[m++],l=v[l],2!==d&&u.vertexColors.push(new J(l)),0!==d&&r.vertexColors.push(new J(l));c.faces.push(u);c.faces.push(r)}else{u=new ha;u.a=y[m++];u.b=y[m++];u.c=y[m++];h&&(h=y[m++],u.materialIndex=h);h=c.faces.length;if(d)for(d=0;dg;g++)n=y[m++],w=A[2*n],n=A[2*n+1],w=new D(w,n),c.faceVertexUvs[d][h].push(w);p&&(p=3*y[m++],u.normal.set(x[p++],x[p++],x[p]));if(G)for(d=0;3>d;d++)p=3*y[m++],G=new q(x[p++],x[p++],x[p]),u.vertexNormals.push(G);l&&(l=y[m++],u.color.setHex(v[l]));if(b)for(d=0;3>d;d++)l=y[m++],u.vertexColors.push(new J(v[l]));c.faces.push(u)}})(d);(function(){var b=void 0!==a.influencesPerVertex?a.influencesPerVertex:2;if(a.skinWeights)for(var d=0,g=a.skinWeights.length;dm)g=d+1;else if(0b&&(b=0);1Number.EPSILON&&(g.normalize(),c=Math.acos(N.clamp(d[m-1].dot(d[m]),-1,1)),e[m].applyMatrix4(h.makeRotationAxis(g,c))),f[m].crossVectors(d[m],e[m]);if(!0===b)for(c=Math.acos(N.clamp(e[0].dot(e[a]),-1,1)),c/=a,0=b)return b=c[a]-b,a=this.curves[a],c=a.getLength(),a.getPointAt(0===c?0:1-b/c);a++}return null},getLength:function(){var a=this.getCurveLengths();return a[a.length-1]},updateArcLengths:function(){this.needsUpdate= -!0;this.cacheLengths=null;this.getLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var a=[],b=0,c=0,d=this.curves.length;cc;)c+=b;for(;c>b;)c-=b;cb.length-2?b.length-1:a+1],b=b[a>b.length-3?b.length-1:a+2];return new D(Te(c,d.x,e.x,f.x,b.x),Te(c,d.y,e.y,f.y,b.y))};fc.prototype=Object.create(ua.prototype);fc.prototype.constructor= -fc;fc.prototype.getPoint=function(a){var b=this.v0,c=this.v1,d=this.v2,e=this.v3;return new D(Bb(a,b.x,c.x,d.x,e.x),Bb(a,b.y,c.y,d.y,e.y))};gc.prototype=Object.create(ua.prototype);gc.prototype.constructor=gc;gc.prototype.getPoint=function(a){var b=this.v0,c=this.v1,d=this.v2;return new D(Ab(a,b.x,c.x,d.x),Ab(a,b.y,c.y,d.y))};var xe=Object.assign(Object.create(ad.prototype),{fromPoints:function(a){this.moveTo(a[0].x,a[0].y);for(var b=1,c=a.length;bNumber.EPSILON){if(0>m&&(g=b[f],k=-k,h=b[e],m=-m),!(a.yh.y))if(a.y===g.y){if(a.x===g.x)return!0}else{e=m*(a.x-g.x)-k*(a.y-g.y);if(0===e)return!0;0>e||(d=!d)}}else if(a.y===g.y&&(h.x<=a.x&&a.x<=g.x||g.x<=a.x&&a.x<=h.x))return!0}return d}var e=Ia.isClockWise,f=this.subPaths;if(0===f.length)return[];if(!0===b)return c(f);var g,h,m,k=[];if(1===f.length)return h=f[0],m=new Db,m.curves=h.curves,k.push(m),k;var l=!e(f[0].getPoints()),l=a?!l:l;m=[];var p= -[],n=[],q=0,x;p[q]=void 0;n[q]=[];for(var r=0,A=f.length;rd&&this._mixBufferRegion(c,a,3*b,1-d,b);for(var d=b,f=b+b;d!==f;++d)if(c[d]!==c[d+b]){e.setValue(c,a);break}}, -saveOriginalState:function(){var a=this.buffer,b=this.valueSize,c=3*b;this.binding.getValue(a,c);for(var d=b;d!==c;++d)a[d]=a[c+d%b];this.cumulativeWeight=0},restoreOriginalState:function(){this.binding.setValue(this.buffer,3*this.valueSize)},_select:function(a,b,c,d,e){if(.5<=d)for(d=0;d!==e;++d)a[b+d]=a[c+d]},_slerp:function(a,b,c,d,e){ca.slerpFlat(a,b,a,b,a,c,d)},_lerp:function(a,b,c,d,e){for(var f=1-d,g=0;g!==e;++g){var h=b+g;a[h]=a[h]*f+a[c+g]*d}}};ka.prototype={constructor:ka,getValue:function(a, -b){this.bind();this.getValue(a,b)},setValue:function(a,b){this.bind();this.setValue(a,b)},bind:function(){var a=this.node,b=this.parsedPath,c=b.objectName,d=b.propertyName,e=b.propertyIndex;a||(this.node=a=ka.findNode(this.rootNode,b.nodeName)||this.rootNode);this.getValue=this._getValue_unavailable;this.setValue=this._setValue_unavailable;if(a){if(c){var f=b.objectIndex;switch(c){case "materials":if(!a.material){console.error(" can not bind to material as node does not have a material",this);return}if(!a.material.materials){console.error(" can not bind to material.materials as node.material does not have a materials array", -this);return}a=a.material.materials;break;case "bones":if(!a.skeleton){console.error(" can not bind to bones as node does not have a skeleton",this);return}a=a.skeleton.bones;for(c=0;c=c){var p=c++,n=b[p];d[n.uuid]=l;b[l]=n;d[k]=p;b[p]=m;m=0;for(k=f;m!==k;++m){var n=e[m],q=n[l];n[l]=n[p];n[p]=q}}}this.nCachedObjects_=c},uncache:function(a){for(var b=this._objects,c=b.length,d=this.nCachedObjects_,e=this._indicesByUUID,f=this._bindings,g=f.length,h=0,m=arguments.length;h!==m;++h){var k=arguments[h].uuid,l=e[k]; -if(void 0!==l)if(delete e[k],lb||0===c)return;this._startTime=null;b*=c}b*=this._updateTimeScale(a);c=this._updateTime(b);a=this._updateWeight(a);if(0c.parameterPositions[1]&& -(this.stopFading(),0===d&&(this.enabled=!1))}}return this._effectiveWeight=b},_updateTimeScale:function(a){var b=0;if(!this.paused){var b=this.timeScale,c=this._timeScaleInterpolant;if(null!==c){var d=c.evaluate(a)[0],b=b*d;a>c.parameterPositions[1]&&(this.stopWarping(),0===b?this.paused=!0:this.timeScale=b)}}return this._effectiveTimeScale=b},_updateTime:function(a){var b=this.time+a;if(0===a)return b;var c=this._clip.duration,d=this.loop,e=this._loopCount;if(2200===d)a:{if(-1===e&&(this._loopCount= -0,this._setEndings(!0,!0,!1)),b>=c)b=c;else if(0>b)b=0;else break a;this.clampWhenFinished?this.paused=!0:this.enabled=!1;this._mixer.dispatchEvent({type:"finished",action:this,direction:0>a?-1:1})}else{d=2202===d;-1===e&&(0<=a?(e=0,this._setEndings(!0,0===this.repetitions,d)):this._setEndings(0===this.repetitions,!0,d));if(b>=c||0>b){var f=Math.floor(b/c),b=b-c*f,e=e+Math.abs(f),g=this.repetitions-e;0>g?(this.clampWhenFinished?this.paused=!0:this.enabled=!1,b=0a,this._setEndings(a,!a,d)):this._setEndings(!1,!1,d),this._loopCount=e,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:f}))}if(d&&1===(e&1))return this.time=b,c-b}return this.time=b},_setEndings:function(a,b,c){var d=this._interpolantSettings;c?(d.endingStart=2401,d.endingEnd=2401):(d.endingStart=a?this.zeroSlopeAtStart?2401:2400:2402,d.endingEnd=b?this.zeroSlopeAtEnd?2401:2400:2402)},_scheduleFading:function(a,b,c){var d=this._mixer,e=d.time, -f=this._weightInterpolant;null===f&&(this._weightInterpolant=f=d._lendControlInterpolant());d=f.parameterPositions;f=f.sampleValues;d[0]=e;f[0]=b;d[1]=e+a;f[1]=c;return this}};cd.prototype={constructor:cd,clipAction:function(a,b){var c=b||this._root,d=c.uuid,e="string"===typeof a?qa.findByName(c,a):a,c=null!==e?e.uuid:a,f=this._actionsByClip[c],g=null;if(void 0!==f){g=f.actionByRoot[d];if(void 0!==g)return g;g=f.knownActions[0];null===e&&(e=g._clip)}if(null===e)return null;e=new ne(this,e,b);this._bindAction(e, -g);this._addInactiveAction(e,c,d);return e},existingAction:function(a,b){var c=b||this._root,d=c.uuid,c="string"===typeof a?qa.findByName(c,a):a,c=this._actionsByClip[c?c.uuid:a];return void 0!==c?c.actionByRoot[d]||null:null},stopAllAction:function(){for(var a=this._actions,b=this._nActiveActions,c=this._bindings,d=this._nActiveBindings,e=this._nActiveBindings=this._nActiveActions=0;e!==b;++e)a[e].reset();for(e=0;e!==d;++e)c[e].useCount=0;return this},update:function(a){a*=this.timeScale;for(var b= -this._actions,c=this._nActiveActions,d=this.time+=a,e=Math.sign(a),f=this._accuIndex^=1,g=0;g!==c;++g){var h=b[g];h.enabled&&h._update(d,a,e,f)}a=this._bindings;b=this._nActiveBindings;for(g=0;g!==b;++g)a[g].apply(f);return this},getRoot:function(){return this._root},uncacheClip:function(a){var b=this._actions;a=a.uuid;var c=this._actionsByClip,d=c[a];if(void 0!==d){for(var d=d.knownActions,e=0,f=d.length;e!==f;++e){var g=d[e];this._deactivateAction(g);var h=g._cacheIndex,l=b[b.length-1];g._cacheIndex= -null;g._byClipCacheIndex=null;l._cacheIndex=h;b[h]=l;b.pop();this._removeInactiveBindingsForAction(g)}delete c[a]}},uncacheRoot:function(a){a=a.uuid;var b=this._actionsByClip,c;for(c in b){var d=b[c].actionByRoot[a];void 0!==d&&(this._deactivateAction(d),this._removeInactiveAction(d))}c=this._bindingsByRootAndName[a];if(void 0!==c)for(var e in c)a=c[e],a.restoreOriginalState(),this._removeInactiveBinding(a)},uncacheAction:function(a,b){var c=this.existingAction(a,b);null!==c&&(this._deactivateAction(c), -this._removeInactiveAction(c))}};Object.assign(cd.prototype,{_bindAction:function(a,b){var c=a._localRoot||this._root,d=a._clip.tracks,e=d.length,f=a._propertyBindings,g=a._interpolants,h=c.uuid,l=this._bindingsByRootAndName,k=l[h];void 0===k&&(k={},l[h]=k);for(l=0;l!==e;++l){var q=d[l],p=q.name,n=k[p];if(void 0===n){n=f[l];if(void 0!==n){null===n._cacheIndex&&(++n.referenceCount,this._addInactiveBinding(n,h,p));continue}n=new Jd(ka.create(c,p,b&&b._propertyBindings[l].binding.parsedPath),q.ValueTypeName, -q.getValueSize());++n.referenceCount;this._addInactiveBinding(n,h,p)}f[l]=n;g[l].resultBuffer=n.buffer}},_activateAction:function(a){if(!this._isActiveAction(a)){if(null===a._cacheIndex){var b=(a._localRoot||this._root).uuid,c=a._clip.uuid,d=this._actionsByClip[c];this._bindAction(a,d&&d.knownActions[0]);this._addInactiveAction(a,c,b)}b=a._propertyBindings;c=0;for(d=b.length;c!==d;++c){var e=b[c];0===e.useCount++&&(this._lendBinding(e),e.saveOriginalState())}this._lendAction(a)}},_deactivateAction:function(a){if(this._isActiveAction(a)){for(var b= -a._propertyBindings,c=0,d=b.length;c!==d;++c){var e=b[c];0===--e.useCount&&(e.restoreOriginalState(),this._takeBackBinding(e))}this._takeBackAction(a)}},_initMemoryManager:function(){this._actions=[];this._nActiveActions=0;this._actionsByClip={};this._bindings=[];this._nActiveBindings=0;this._bindingsByRootAndName={};this._controlInterpolants=[];this._nActiveControlInterpolants=0;var a=this;this.stats={actions:{get total(){return a._actions.length},get inUse(){return a._nActiveActions}},bindings:{get total(){return a._bindings.length}, -get inUse(){return a._nActiveBindings}},controlInterpolants:{get total(){return a._controlInterpolants.length},get inUse(){return a._nActiveControlInterpolants}}}},_isActiveAction:function(a){a=a._cacheIndex;return null!==a&&ah.end&&(h.end=f);c||(c=l)}}for(l in d)h=d[l],this.createAnimation(l,h.start,h.end,a);this.firstAnimation=c};oa.prototype.setAnimationDirectionForward=function(a){if(a=this.animationsMap[a])a.direction=1,a.directionBackwards=!1};oa.prototype.setAnimationDirectionBackward=function(a){if(a=this.animationsMap[a])a.direction=-1,a.directionBackwards=!0};oa.prototype.setAnimationFPS= -function(a,b){var c=this.animationsMap[a];c&&(c.fps=b,c.duration=(c.end-c.start)/c.fps)};oa.prototype.setAnimationDuration=function(a,b){var c=this.animationsMap[a];c&&(c.duration=b,c.fps=(c.end-c.start)/c.duration)};oa.prototype.setAnimationWeight=function(a,b){var c=this.animationsMap[a];c&&(c.weight=b)};oa.prototype.setAnimationTime=function(a,b){var c=this.animationsMap[a];c&&(c.time=b)};oa.prototype.getAnimationTime=function(a){var b=0;if(a=this.animationsMap[a])b=a.time;return b};oa.prototype.getAnimationDuration= -function(a){var b=-1;if(a=this.animationsMap[a])b=a.duration;return b};oa.prototype.playAnimation=function(a){var b=this.animationsMap[a];b?(b.time=0,b.active=!0):console.warn("THREE.MorphBlendMesh: animation["+a+"] undefined in .playAnimation()")};oa.prototype.stopAnimation=function(a){if(a=this.animationsMap[a])a.active=!1};oa.prototype.update=function(a){for(var b=0,c=this.animationsList.length;b -d.duration||0>d.time)d.direction*=-1,d.time>d.duration&&(d.time=d.duration,d.directionBackwards=!0),0>d.time&&(d.time=0,d.directionBackwards=!1)}else d.time%=d.duration,0>d.time&&(d.time+=d.duration);var f=d.start+N.clamp(Math.floor(d.time/e),0,d.length-1),g=d.weight;f!==d.currentFrame&&(this.morphTargetInfluences[d.lastFrame]=0,this.morphTargetInfluences[d.currentFrame]=1*g,this.morphTargetInfluences[f]=0,d.lastFrame=d.currentFrame,d.currentFrame=f);e=d.time%e/e;d.directionBackwards&&(e=1-e);d.currentFrame!== -d.lastFrame?(this.morphTargetInfluences[d.currentFrame]=e*g,this.morphTargetInfluences[d.lastFrame]=(1-e)*g):this.morphTargetInfluences[d.currentFrame]=g}}};dd.prototype=Object.create(x.prototype);dd.prototype.constructor=dd;dd.prototype.isImmediateRenderObject=!0;ed.prototype=Object.create(ga.prototype);ed.prototype.constructor=ed;ed.prototype.update=function(){var a=new q,b=new q,c=new ya;return function(){var d=["a","b","c"];this.object.updateMatrixWorld(!0);c.getNormalMatrix(this.object.matrixWorld); -var e=this.object.matrixWorld,f=this.geometry.attributes.position,g=this.object.geometry;if(g&&g.isGeometry)for(var h=g.vertices,l=g.faces,k=g=0,q=l.length;kc.y?this.quaternion.set(1, -0,0,0):(a.set(c.z,0,-c.x).normalize(),b=Math.acos(c.y),this.quaternion.setFromAxisAngle(a,b))}}();Fb.prototype.setLength=function(a,b,c){void 0===b&&(b=.2*a);void 0===c&&(c=.2*b);this.line.scale.set(1,Math.max(0,a-b),1);this.line.updateMatrix();this.cone.scale.set(c,b,c);this.cone.position.y=a;this.cone.updateMatrix()};Fb.prototype.setColor=function(a){this.line.material.color.copy(a);this.cone.material.color.copy(a)};Nd.prototype=Object.create(ga.prototype);Nd.prototype.constructor=Nd;var Qd=new q, -ye=new ve,ze=new ve,Ae=new ve;va.prototype=Object.create(ua.prototype);va.prototype.constructor=va;va.prototype.getPoint=function(a){var b=this.points,c=b.length;2>c&&console.log("duh, you need at least 2 points");a*=c-(this.closed?0:1);var d=Math.floor(a);a-=d;this.closed?d+=0d&&(d=1);1E-4>c&&(c=d);1E-4>h&&(h=d);ye.initNonuniformCatmullRom(e.x,f.x,g.x,b.x,c,d,h);ze.initNonuniformCatmullRom(e.y,f.y,g.y,b.y,c,d,h);Ae.initNonuniformCatmullRom(e.z,f.z,g.z,b.z,c,d,h)}else"catmullrom"===this.type&&(c=void 0!==this.tension?this.tension: -.5,ye.initCatmullRom(e.x,f.x,g.x,b.x,c),ze.initCatmullRom(e.y,f.y,g.y,b.y,c),Ae.initCatmullRom(e.z,f.z,g.z,b.z,c));return new q(ye.calc(a),ze.calc(a),Ae.calc(a))};id.prototype=Object.create(ua.prototype);id.prototype.constructor=id;id.prototype.getPoint=function(a){var b=this.v0,c=this.v1,d=this.v2,e=this.v3;return new q(Bb(a,b.x,c.x,d.x,e.x),Bb(a,b.y,c.y,d.y,e.y),Bb(a,b.z,c.z,d.z,e.z))};jd.prototype=Object.create(ua.prototype);jd.prototype.constructor=jd;jd.prototype.getPoint=function(a){var b=this.v0, -c=this.v1,d=this.v2;return new q(Ab(a,b.x,c.x,d.x),Ab(a,b.y,c.y,d.y),Ab(a,b.z,c.z,d.z))};kd.prototype=Object.create(ua.prototype);kd.prototype.constructor=kd;kd.prototype.getPoint=function(a){if(1===a)return this.v2.clone();var b=new q;b.subVectors(this.v2,this.v1);b.multiplyScalar(a);b.add(this.v1);return b};Od.prototype=Object.create(Wa.prototype);Od.prototype.constructor=Od;ua.create=function(a,b){console.log("THREE.Curve.create() has been deprecated");a.prototype=Object.create(ua.prototype);a.prototype.constructor= -a;a.prototype.getPoint=b;return a};Xe.prototype=Object.create(va.prototype);Ye.prototype=Object.create(va.prototype);we.prototype=Object.create(va.prototype);Object.assign(we.prototype,{initFromArray:function(a){console.error("THREE.Spline: .initFromArray() has been removed.")},getControlPointsArray:function(a){console.error("THREE.Spline: .getControlPointsArray() has been removed.")},reparametrizeByArcLength:function(a){console.error("THREE.Spline: .reparametrizeByArcLength() has been removed.")}}); -fd.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")};Object.assign(sc.prototype,{center:function(a){console.warn("THREE.Box2: .center() has been renamed to .getCenter().");return this.getCenter(a)},empty:function(){console.warn("THREE.Box2: .empty() has been renamed to .isEmpty().");return this.isEmpty()},isIntersectionBox:function(a){console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."); -return this.intersectsBox(a)},size:function(a){console.warn("THREE.Box2: .size() has been renamed to .getSize().");return this.getSize(a)}});Object.assign(Pa.prototype,{center:function(a){console.warn("THREE.Box3: .center() has been renamed to .getCenter().");return this.getCenter(a)},empty:function(){console.warn("THREE.Box3: .empty() has been renamed to .isEmpty().");return this.isEmpty()},isIntersectionBox:function(a){console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."); -return this.intersectsBox(a)},isIntersectionSphere:function(a){console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere().");return this.intersectsSphere(a)},size:function(a){console.warn("THREE.Box3: .size() has been renamed to .getSize().");return this.getSize(a)}});hb.prototype.center=function(a){console.warn("THREE.Line3: .center() has been renamed to .getCenter().");return this.getCenter(a)};N.random16=function(){console.warn("THREE.Math.random16() has been deprecated. Use Math.random() instead."); -return Math.random()};Object.assign(ya.prototype,{flattenToArrayOffset:function(a,b){console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead.");return this.toArray(a,b)},multiplyVector3:function(a){console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead.");return a.applyMatrix3(this)},multiplyVector3Array:function(a){console.warn("THREE.Matrix3: .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead."); -return this.applyToVector3Array(a)},applyToBuffer:function(a,b,c){console.warn("THREE.Matrix3: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead.");return this.applyToBufferAttribute(a)},applyToVector3Array:function(a,b,c){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")}});Object.assign(S.prototype,{extractPosition:function(a){console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition().");return this.copyPosition(a)}, -flattenToArrayOffset:function(a,b){console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead.");return this.toArray(a,b)},getPosition:function(){var a;return function(){void 0===a&&(a=new q);console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.");return a.setFromMatrixColumn(this,3)}}(),setRotationFromQuaternion:function(a){console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."); -return this.makeRotationFromQuaternion(a)},multiplyVector3:function(a){console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead.");return a.applyMatrix4(this)},multiplyVector4:function(a){console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead.");return a.applyMatrix4(this)},multiplyVector3Array:function(a){console.warn("THREE.Matrix4: .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead."); -return this.applyToVector3Array(a)},rotateAxis:function(a){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead.");a.transformDirection(this)},crossVector:function(a){console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead.");return a.applyMatrix4(this)},translate:function(){console.error("THREE.Matrix4: .translate() has been removed.")},rotateX:function(){console.error("THREE.Matrix4: .rotateX() has been removed.")}, -rotateY:function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},rotateZ:function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},rotateByAxis:function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},applyToBuffer:function(a,b,c){console.warn("THREE.Matrix4: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead.");return this.applyToBufferAttribute(a)},applyToVector3Array:function(a,b,c){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")}, -makeFrustum:function(a,b,c,d,e,f){console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead.");return this.makePerspective(a,b,d,c,e,f)}});la.prototype.isIntersectionLine=function(a){console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine().");return this.intersectsLine(a)};ca.prototype.multiplyVector3=function(a){console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."); -return a.applyQuaternion(this)};Object.assign(cb.prototype,{isIntersectionBox:function(a){console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox().");return this.intersectsBox(a)},isIntersectionPlane:function(a){console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane().");return this.intersectsPlane(a)},isIntersectionSphere:function(a){console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere().");return this.intersectsSphere(a)}}); -Object.assign(Db.prototype,{extrude:function(a){console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead.");return new La(this,a)},makeGeometry:function(a){console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead.");return new Yb(this,a)}});Object.assign(D.prototype,{fromAttribute:function(a,b,c){console.error("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute().");return this.fromBufferAttribute(a,b,c)}});Object.assign(q.prototype, -{setEulerFromRotationMatrix:function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},setEulerFromQuaternion:function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},getPositionFromMatrix:function(a){console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition().");return this.setFromMatrixPosition(a)},getScaleFromMatrix:function(a){console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."); -return this.setFromMatrixScale(a)},getColumnFromMatrix:function(a,b){console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn().");return this.setFromMatrixColumn(b,a)},applyProjection:function(a){console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead.");return this.applyMatrix4(a)},fromAttribute:function(a,b,c){console.error("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute().");return this.fromBufferAttribute(a, -b,c)}});Object.assign(fa.prototype,{fromAttribute:function(a,b,c){console.error("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute().");return this.fromBufferAttribute(a,b,c)}});T.prototype.computeTangents=function(){console.warn("THREE.Geometry: .computeTangents() has been removed.")};Object.assign(x.prototype,{getChildByName:function(a){console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName().");return this.getObjectByName(a)},renderDepth:function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")}, -translate:function(a,b){console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead.");return this.translateOnAxis(b,a)}});Object.defineProperties(x.prototype,{eulerOrder:{get:function(){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order.");return this.rotation.order},set:function(a){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order.");this.rotation.order=a}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}, -set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}});Object.defineProperties(Ec.prototype,{objects:{get:function(){console.warn("THREE.LOD: .objects has been renamed to .levels.");return this.levels}}});Fa.prototype.setLens=function(a,b){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup.");void 0!==b&&(this.filmGauge=b);this.setFocalLength(a)};Object.defineProperties(ma.prototype, -{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(a){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov.");this.shadow.camera.fov=a}},shadowCameraLeft:{set:function(a){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left.");this.shadow.camera.left=a}},shadowCameraRight:{set:function(a){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right.");this.shadow.camera.right=a}},shadowCameraTop:{set:function(a){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."); -this.shadow.camera.top=a}},shadowCameraBottom:{set:function(a){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom.");this.shadow.camera.bottom=a}},shadowCameraNear:{set:function(a){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near.");this.shadow.camera.near=a}},shadowCameraFar:{set:function(a){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far.");this.shadow.camera.far=a}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}}, -shadowBias:{set:function(a){console.warn("THREE.Light: .shadowBias is now .shadow.bias.");this.shadow.bias=a}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(a){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width.");this.shadow.mapSize.width=a}},shadowMapHeight:{set:function(a){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height.");this.shadow.mapSize.height=a}}});Object.defineProperties(U.prototype, -{length:{get:function(){console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead.");return this.array.length}}});Object.assign(I.prototype,{addIndex:function(a){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex().");this.setIndex(a)},addDrawCall:function(a,b,c){void 0!==c&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset.");console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup().");this.addGroup(a, -b)},clearDrawCalls:function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups().");this.clearGroups()},computeTangents:function(){console.warn("THREE.BufferGeometry: .computeTangents() has been removed.")},computeOffsets:function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")}});Object.defineProperties(I.prototype,{drawcalls:{get:function(){console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups.");return this.groups}},offsets:{get:function(){console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."); -return this.groups}}});Object.defineProperties(Kd.prototype,{dynamic:{set:function(){console.warn("THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.")}},onUpdate:{value:function(){console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead.");return this}}});Object.defineProperties(X.prototype,{wrapAround:{get:function(){console.warn("THREE."+this.type+": .wrapAround has been removed.")},set:function(){console.warn("THREE."+this.type+ -": .wrapAround has been removed.")}},wrapRGB:{get:function(){console.warn("THREE."+this.type+": .wrapRGB has been removed.");return new J}}});Object.defineProperties(Ca.prototype,{metal:{get:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead.");return!1},set:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead")}}});Object.defineProperties(Ha.prototype,{derivatives:{get:function(){console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."); -return this.extensions.derivatives},set:function(a){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives.");this.extensions.derivatives=a}}});Object.assign(Yd.prototype,{supportsFloatTextures:function(){console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' ).");return this.extensions.get("OES_texture_float")},supportsHalfFloatTextures:function(){console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."); -return this.extensions.get("OES_texture_half_float")},supportsStandardDerivatives:function(){console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' ).");return this.extensions.get("OES_standard_derivatives")},supportsCompressedTextureS3TC:function(){console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' ).");return this.extensions.get("WEBGL_compressed_texture_s3tc")}, -supportsCompressedTexturePVRTC:function(){console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' ).");return this.extensions.get("WEBGL_compressed_texture_pvrtc")},supportsBlendMinMax:function(){console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' ).");return this.extensions.get("EXT_blend_minmax")},supportsVertexTextures:function(){console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."); -return this.capabilities.vertexTextures},supportsInstancedArrays:function(){console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' ).");return this.extensions.get("ANGLE_instanced_arrays")},enableScissorTest:function(a){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest().");this.setScissorTest(a)},initMaterial:function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},addPrePlugin:function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")}, -addPostPlugin:function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},updateShadowMap:function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")}});Object.defineProperties(Yd.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(a){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled.");this.shadowMap.enabled=a}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(a){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."); -this.shadowMap.type=a}},shadowMapCullFace:{get:function(){return this.shadowMap.cullFace},set:function(a){console.warn("THREE.WebGLRenderer: .shadowMapCullFace is now .shadowMap.cullFace.");this.shadowMap.cullFace=a}}});Object.defineProperties(Ke.prototype,{cullFace:{get:function(){return this.renderReverseSided?2:1},set:function(a){a=1!==a;console.warn("WebGLRenderer: .shadowMap.cullFace is deprecated. Set .shadowMap.renderReverseSided to "+a+".");this.renderReverseSided=a}}});Object.defineProperties(Ya.prototype, -{wrapS:{get:function(){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.");return this.texture.wrapS},set:function(a){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.");this.texture.wrapS=a}},wrapT:{get:function(){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.");return this.texture.wrapT},set:function(a){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.");this.texture.wrapT=a}},magFilter:{get:function(){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."); -return this.texture.magFilter},set:function(a){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.");this.texture.magFilter=a}},minFilter:{get:function(){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.");return this.texture.minFilter},set:function(a){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.");this.texture.minFilter=a}},anisotropy:{get:function(){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."); -return this.texture.anisotropy},set:function(a){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.");this.texture.anisotropy=a}},offset:{get:function(){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset.");return this.texture.offset},set:function(a){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset.");this.texture.offset=a}},repeat:{get:function(){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat.");return this.texture.repeat}, -set:function(a){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat.");this.texture.repeat=a}},format:{get:function(){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format.");return this.texture.format},set:function(a){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format.");this.texture.format=a}},type:{get:function(){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type.");return this.texture.type},set:function(a){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."); -this.texture.type=a}},generateMipmaps:{get:function(){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.");return this.texture.generateMipmaps},set:function(a){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.");this.texture.generateMipmaps=a}}});hc.prototype.load=function(a){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");var b=this;(new ge).load(a,function(a){b.setBuffer(a)});return this}; -le.prototype.getData=function(){console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData().");return this.getFrequencyData()};l.WebGLRenderTargetCube=Gb;l.WebGLRenderTarget=Ya;l.WebGLRenderer=Yd;l.ShaderLib=bb;l.UniformsLib=V;l.UniformsUtils=Ja;l.ShaderChunk=Z;l.FogExp2=Kb;l.Fog=Lb;l.Scene=mb;l.LensFlare=Zd;l.Sprite=Dc;l.LOD=Ec;l.SkinnedMesh=qd;l.Skeleton=od;l.Bone=pd;l.Mesh=Aa;l.LineSegments=ga;l.Line=Ua;l.Points=Mb;l.Group=Fc;l.VideoTexture=rd;l.DataTexture=eb;l.CompressedTexture= -Nb;l.CubeTexture=Za;l.CanvasTexture=sd;l.DepthTexture=Gc;l.Texture=ea;l.CompressedTextureLoader=Re;l.DataTextureLoader=ae;l.CubeTextureLoader=be;l.TextureLoader=td;l.ObjectLoader=Se;l.MaterialLoader=Hd;l.BufferGeometryLoader=ce;l.DefaultLoadingManager=ta;l.LoadingManager=$d;l.JSONLoader=de;l.ImageLoader=Yc;l.FontLoader=Ue;l.FileLoader=sa;l.Loader=zb;l.Cache=ld;l.AudioLoader=ge;l.SpotLightShadow=vd;l.SpotLight=wd;l.PointLight=xd;l.RectAreaLight=he;l.HemisphereLight=ud;l.DirectionalLightShadow=yd;l.DirectionalLight= -zd;l.AmbientLight=Ad;l.LightShadow=wb;l.Light=ma;l.StereoCamera=Ve;l.PerspectiveCamera=Fa;l.OrthographicCamera=Jb;l.CubeCamera=Id;l.Camera=ra;l.AudioListener=ie;l.PositionalAudio=ke;l.AudioContext=je;l.AudioAnalyser=le;l.Audio=hc;l.VectorKeyframeTrack=dc;l.StringKeyframeTrack=Ed;l.QuaternionKeyframeTrack=$c;l.NumberKeyframeTrack=ec;l.ColorKeyframeTrack=Gd;l.BooleanKeyframeTrack=Fd;l.PropertyMixer=Jd;l.PropertyBinding=ka;l.KeyframeTrack=yb;l.AnimationUtils=na;l.AnimationObjectGroup=me;l.AnimationMixer= -cd;l.AnimationClip=qa;l.Uniform=Kd;l.InstancedBufferGeometry=Eb;l.BufferGeometry=I;l.GeometryIdCount=function(){return Vd++};l.Geometry=T;l.InterleavedBufferAttribute=oe;l.InstancedInterleavedBuffer=jc;l.InterleavedBuffer=ic;l.InstancedBufferAttribute=kc;l.Face3=ha;l.Object3D=x;l.Raycaster=pe;l.Layers=nd;l.EventDispatcher=pa;l.Clock=re;l.QuaternionLinearInterpolant=Dd;l.LinearInterpolant=Zc;l.DiscreteInterpolant=Cd;l.CubicInterpolant=Bd;l.Interpolant=xa;l.Triangle=za;l.Math=N;l.Spherical=se;l.Cylindrical= -te;l.Plane=la;l.Frustum=tc;l.Sphere=Na;l.Ray=cb;l.Matrix4=S;l.Matrix3=ya;l.Box3=Pa;l.Box2=sc;l.Line3=hb;l.Euler=db;l.Vector4=fa;l.Vector3=q;l.Vector2=D;l.Quaternion=ca;l.Color=J;l.MorphBlendMesh=oa;l.ImmediateRenderObject=dd;l.VertexNormalsHelper=ed;l.SpotLightHelper=lc;l.SkeletonHelper=mc;l.PointLightHelper=nc;l.RectAreaLightHelper=oc;l.HemisphereLightHelper=pc;l.GridHelper=fd;l.PolarGridHelper=Ld;l.FaceNormalsHelper=gd;l.DirectionalLightHelper=qc;l.CameraHelper=hd;l.BoxHelper=rc;l.ArrowHelper=Fb; -l.AxisHelper=Nd;l.CatmullRomCurve3=va;l.CubicBezierCurve3=id;l.QuadraticBezierCurve3=jd;l.LineCurve3=kd;l.ArcCurve=Od;l.EllipseCurve=Wa;l.SplineCurve=Cb;l.CubicBezierCurve=fc;l.QuadraticBezierCurve=gc;l.LineCurve=Ta;l.Shape=Db;l.Path=bd;l.ShapePath=ee;l.Font=fe;l.CurvePath=ad;l.Curve=ua;l.ShapeUtils=Ia;l.SceneUtils={createMultiMaterialObject:function(a,b){for(var c=new Fc,d=0,e=b.length;d { + loadedTextures[url] = textureLoader.load( + url, + checkAllLoaded, + (xhr) => console.log(`${url}: ${(xhr.loaded / xhr.total) * 100}% loaded`), + (error) => { + hasError = true; + console.error(`Error loading texture ${url}:`, error); + } + ); + }); + } catch (error) { + hasError = true; + console.error("Texture loading failed:", error); + } + } + + shaderErrorLog(gl, program, glVertexShader, glFragmentShader) { + console.log("gl"); + console.log(gl); + console.log("program"); + console.log(program); + console.log("glVertexShader"); + console.log(glVertexShader); + console.log("glFragmentShader"); + console.log(glFragmentShader); + } +} diff --git a/examples/js/dat.gui.min.js b/examples/js/dat.gui.min.js deleted file mode 100644 index 17e4a3c..0000000 --- a/examples/js/dat.gui.min.js +++ /dev/null @@ -1,94 +0,0 @@ -/** - * dat-gui JavaScript Controller Library - * http://code.google.com/p/dat-gui - * - * Copyright 2011 Data Arts Team, Google Creative Lab - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - */ -var dat=dat||{};dat.gui=dat.gui||{};dat.utils=dat.utils||{};dat.controllers=dat.controllers||{};dat.dom=dat.dom||{};dat.color=dat.color||{};dat.utils.css=function(){return{load:function(e,a){var a=a||document,c=a.createElement("link");c.type="text/css";c.rel="stylesheet";c.href=e;a.getElementsByTagName("head")[0].appendChild(c)},inject:function(e,a){var a=a||document,c=document.createElement("style");c.type="text/css";c.innerHTML=e;a.getElementsByTagName("head")[0].appendChild(c)}}}(); -dat.utils.common=function(){var e=Array.prototype.forEach,a=Array.prototype.slice;return{BREAK:{},extend:function(c){this.each(a.call(arguments,1),function(a){for(var f in a)this.isUndefined(a[f])||(c[f]=a[f])},this);return c},defaults:function(c){this.each(a.call(arguments,1),function(a){for(var f in a)this.isUndefined(c[f])&&(c[f]=a[f])},this);return c},compose:function(){var c=a.call(arguments);return function(){for(var d=a.call(arguments),f=c.length-1;f>=0;f--)d=[c[f].apply(this,d)];return d[0]}}, -each:function(a,d,f){if(e&&a.forEach===e)a.forEach(d,f);else if(a.length===a.length+0)for(var b=0,n=a.length;b-1?d.length-d.indexOf(".")-1:0};c.superclass=e;a.extend(c.prototype,e.prototype,{setValue:function(a){if(this.__min!==void 0&&athis.__max)a=this.__max;this.__step!==void 0&&a%this.__step!=0&&(a=Math.round(a/this.__step)*this.__step);return c.superclass.prototype.setValue.call(this,a)},min:function(a){this.__min=a;return this},max:function(a){this.__max=a;return this},step:function(a){this.__step=a;return this}});return c}(dat.controllers.Controller,dat.utils.common); -dat.controllers.NumberControllerBox=function(e,a,c){var d=function(f,b,e){function h(){var a=parseFloat(l.__input.value);c.isNaN(a)||l.setValue(a)}function j(a){var b=o-a.clientY;l.setValue(l.getValue()+b*l.__impliedStep);o=a.clientY}function m(){a.unbind(window,"mousemove",j);a.unbind(window,"mouseup",m)}this.__truncationSuspended=false;d.superclass.call(this,f,b,e);var l=this,o;this.__input=document.createElement("input");this.__input.setAttribute("type","text");a.bind(this.__input,"change",h); -a.bind(this.__input,"blur",function(){h();l.__onFinishChange&&l.__onFinishChange.call(l,l.getValue())});a.bind(this.__input,"mousedown",function(b){a.bind(window,"mousemove",j);a.bind(window,"mouseup",m);o=b.clientY});a.bind(this.__input,"keydown",function(a){if(a.keyCode===13)l.__truncationSuspended=true,this.blur(),l.__truncationSuspended=false});this.updateDisplay();this.domElement.appendChild(this.__input)};d.superclass=e;c.extend(d.prototype,e.prototype,{updateDisplay:function(){var a=this.__input, -b;if(this.__truncationSuspended)b=this.getValue();else{b=this.getValue();var c=Math.pow(10,this.__precision);b=Math.round(b*c)/c}a.value=b;return d.superclass.prototype.updateDisplay.call(this)}});return d}(dat.controllers.NumberController,dat.dom.dom,dat.utils.common); -dat.controllers.NumberControllerSlider=function(e,a,c,d,f){var b=function(d,c,f,e,l){function o(b){b.preventDefault();var d=a.getOffset(g.__background),c=a.getWidth(g.__background);g.setValue(g.__min+(g.__max-g.__min)*((b.clientX-d.left)/(d.left+c-d.left)));return false}function y(){a.unbind(window,"mousemove",o);a.unbind(window,"mouseup",y);g.__onFinishChange&&g.__onFinishChange.call(g,g.getValue())}b.superclass.call(this,d,c,{min:f,max:e,step:l});var g=this;this.__background=document.createElement("div"); -this.__foreground=document.createElement("div");a.bind(this.__background,"mousedown",function(b){a.bind(window,"mousemove",o);a.bind(window,"mouseup",y);o(b)});a.addClass(this.__background,"slider");a.addClass(this.__foreground,"slider-fg");this.updateDisplay();this.__background.appendChild(this.__foreground);this.domElement.appendChild(this.__background)};b.superclass=e;b.useDefaultStyles=function(){c.inject(f)};d.extend(b.prototype,e.prototype,{updateDisplay:function(){this.__foreground.style.width= -(this.getValue()-this.__min)/(this.__max-this.__min)*100+"%";return b.superclass.prototype.updateDisplay.call(this)}});return b}(dat.controllers.NumberController,dat.dom.dom,dat.utils.css,dat.utils.common,".slider {\n box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);\n height: 1em;\n border-radius: 1em;\n background-color: #eee;\n padding: 0 0.5em;\n overflow: hidden;\n}\n\n.slider-fg {\n padding: 1px 0 2px 0;\n background-color: #aaa;\n height: 1em;\n margin-left: -0.5em;\n padding-right: 0.5em;\n border-radius: 1em 0 0 1em;\n}\n\n.slider-fg:after {\n display: inline-block;\n border-radius: 1em;\n background-color: #fff;\n border: 1px solid #aaa;\n content: '';\n float: right;\n margin-right: -1em;\n margin-top: -1px;\n height: 0.9em;\n width: 0.9em;\n}"); -dat.controllers.FunctionController=function(e,a,c){var d=function(c,b,e){d.superclass.call(this,c,b);var h=this;this.__button=document.createElement("div");this.__button.innerHTML=e===void 0?"Fire":e;a.bind(this.__button,"click",function(a){a.preventDefault();h.fire();return false});a.addClass(this.__button,"button");this.domElement.appendChild(this.__button)};d.superclass=e;c.extend(d.prototype,e.prototype,{fire:function(){this.__onChange&&this.__onChange.call(this);this.__onFinishChange&&this.__onFinishChange.call(this, -this.getValue());this.getValue().call(this.object)}});return d}(dat.controllers.Controller,dat.dom.dom,dat.utils.common); -dat.controllers.BooleanController=function(e,a,c){var d=function(c,b){d.superclass.call(this,c,b);var e=this;this.__prev=this.getValue();this.__checkbox=document.createElement("input");this.__checkbox.setAttribute("type","checkbox");a.bind(this.__checkbox,"change",function(){e.setValue(!e.__prev)},false);this.domElement.appendChild(this.__checkbox);this.updateDisplay()};d.superclass=e;c.extend(d.prototype,e.prototype,{setValue:function(a){a=d.superclass.prototype.setValue.call(this,a);this.__onFinishChange&& -this.__onFinishChange.call(this,this.getValue());this.__prev=this.getValue();return a},updateDisplay:function(){this.getValue()===true?(this.__checkbox.setAttribute("checked","checked"),this.__checkbox.checked=true):this.__checkbox.checked=false;return d.superclass.prototype.updateDisplay.call(this)}});return d}(dat.controllers.Controller,dat.dom.dom,dat.utils.common); -dat.color.toString=function(e){return function(a){if(a.a==1||e.isUndefined(a.a)){for(a=a.hex.toString(16);a.length<6;)a="0"+a;return"#"+a}else return"rgba("+Math.round(a.r)+","+Math.round(a.g)+","+Math.round(a.b)+","+a.a+")"}}(dat.utils.common); -dat.color.interpret=function(e,a){var c,d,f=[{litmus:a.isString,conversions:{THREE_CHAR_HEX:{read:function(a){a=a.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i);return a===null?false:{space:"HEX",hex:parseInt("0x"+a[1].toString()+a[1].toString()+a[2].toString()+a[2].toString()+a[3].toString()+a[3].toString())}},write:e},SIX_CHAR_HEX:{read:function(a){a=a.match(/^#([A-F0-9]{6})$/i);return a===null?false:{space:"HEX",hex:parseInt("0x"+a[1].toString())}},write:e},CSS_RGB:{read:function(a){a=a.match(/^rgb\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/); -return a===null?false:{space:"RGB",r:parseFloat(a[1]),g:parseFloat(a[2]),b:parseFloat(a[3])}},write:e},CSS_RGBA:{read:function(a){a=a.match(/^rgba\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\,\s*(.+)\s*\)/);return a===null?false:{space:"RGB",r:parseFloat(a[1]),g:parseFloat(a[2]),b:parseFloat(a[3]),a:parseFloat(a[4])}},write:e}}},{litmus:a.isNumber,conversions:{HEX:{read:function(a){return{space:"HEX",hex:a,conversionName:"HEX"}},write:function(a){return a.hex}}}},{litmus:a.isArray,conversions:{RGB_ARRAY:{read:function(a){return a.length!= -3?false:{space:"RGB",r:a[0],g:a[1],b:a[2]}},write:function(a){return[a.r,a.g,a.b]}},RGBA_ARRAY:{read:function(a){return a.length!=4?false:{space:"RGB",r:a[0],g:a[1],b:a[2],a:a[3]}},write:function(a){return[a.r,a.g,a.b,a.a]}}}},{litmus:a.isObject,conversions:{RGBA_OBJ:{read:function(b){return a.isNumber(b.r)&&a.isNumber(b.g)&&a.isNumber(b.b)&&a.isNumber(b.a)?{space:"RGB",r:b.r,g:b.g,b:b.b,a:b.a}:false},write:function(a){return{r:a.r,g:a.g,b:a.b,a:a.a}}},RGB_OBJ:{read:function(b){return a.isNumber(b.r)&& -a.isNumber(b.g)&&a.isNumber(b.b)?{space:"RGB",r:b.r,g:b.g,b:b.b}:false},write:function(a){return{r:a.r,g:a.g,b:a.b}}},HSVA_OBJ:{read:function(b){return a.isNumber(b.h)&&a.isNumber(b.s)&&a.isNumber(b.v)&&a.isNumber(b.a)?{space:"HSV",h:b.h,s:b.s,v:b.v,a:b.a}:false},write:function(a){return{h:a.h,s:a.s,v:a.v,a:a.a}}},HSV_OBJ:{read:function(b){return a.isNumber(b.h)&&a.isNumber(b.s)&&a.isNumber(b.v)?{space:"HSV",h:b.h,s:b.s,v:b.v}:false},write:function(a){return{h:a.h,s:a.s,v:a.v}}}}}];return function(){d= -false;var b=arguments.length>1?a.toArray(arguments):arguments[0];a.each(f,function(e){if(e.litmus(b))return a.each(e.conversions,function(e,f){c=e.read(b);if(d===false&&c!==false)return d=c,c.conversionName=f,c.conversion=e,a.BREAK}),a.BREAK});return d}}(dat.color.toString,dat.utils.common); -dat.GUI=dat.gui.GUI=function(e,a,c,d,f,b,n,h,j,m,l,o,y,g,i){function q(a,b,r,c){if(b[r]===void 0)throw Error("Object "+b+' has no property "'+r+'"');c.color?b=new l(b,r):(b=[b,r].concat(c.factoryArgs),b=d.apply(a,b));if(c.before instanceof f)c.before=c.before.__li;t(a,b);g.addClass(b.domElement,"c");r=document.createElement("span");g.addClass(r,"property-name");r.innerHTML=b.property;var e=document.createElement("div");e.appendChild(r);e.appendChild(b.domElement);c=s(a,e,c.before);g.addClass(c,k.CLASS_CONTROLLER_ROW); -g.addClass(c,typeof b.getValue());p(a,c,b);a.__controllers.push(b);return b}function s(a,b,d){var c=document.createElement("li");b&&c.appendChild(b);d?a.__ul.insertBefore(c,params.before):a.__ul.appendChild(c);a.onResize();return c}function p(a,d,c){c.__li=d;c.__gui=a;i.extend(c,{options:function(b){if(arguments.length>1)return c.remove(),q(a,c.object,c.property,{before:c.__li.nextElementSibling,factoryArgs:[i.toArray(arguments)]});if(i.isArray(b)||i.isObject(b))return c.remove(),q(a,c.object,c.property, -{before:c.__li.nextElementSibling,factoryArgs:[b]})},name:function(a){c.__li.firstElementChild.firstElementChild.innerHTML=a;return c},listen:function(){c.__gui.listen(c);return c},remove:function(){c.__gui.remove(c);return c}});if(c instanceof j){var e=new h(c.object,c.property,{min:c.__min,max:c.__max,step:c.__step});i.each(["updateDisplay","onChange","onFinishChange"],function(a){var b=c[a],H=e[a];c[a]=e[a]=function(){var a=Array.prototype.slice.call(arguments);b.apply(c,a);return H.apply(e,a)}}); -g.addClass(d,"has-slider");c.domElement.insertBefore(e.domElement,c.domElement.firstElementChild)}else if(c instanceof h){var f=function(b){return i.isNumber(c.__min)&&i.isNumber(c.__max)?(c.remove(),q(a,c.object,c.property,{before:c.__li.nextElementSibling,factoryArgs:[c.__min,c.__max,c.__step]})):b};c.min=i.compose(f,c.min);c.max=i.compose(f,c.max)}else if(c instanceof b)g.bind(d,"click",function(){g.fakeEvent(c.__checkbox,"click")}),g.bind(c.__checkbox,"click",function(a){a.stopPropagation()}); -else if(c instanceof n)g.bind(d,"click",function(){g.fakeEvent(c.__button,"click")}),g.bind(d,"mouseover",function(){g.addClass(c.__button,"hover")}),g.bind(d,"mouseout",function(){g.removeClass(c.__button,"hover")});else if(c instanceof l)g.addClass(d,"color"),c.updateDisplay=i.compose(function(a){d.style.borderLeftColor=c.__color.toString();return a},c.updateDisplay),c.updateDisplay();c.setValue=i.compose(function(b){a.getRoot().__preset_select&&c.isModified()&&B(a.getRoot(),true);return b},c.setValue)} -function t(a,b){var c=a.getRoot(),d=c.__rememberedObjects.indexOf(b.object);if(d!=-1){var e=c.__rememberedObjectIndecesToControllers[d];e===void 0&&(e={},c.__rememberedObjectIndecesToControllers[d]=e);e[b.property]=b;if(c.load&&c.load.remembered){c=c.load.remembered;if(c[a.preset])c=c[a.preset];else if(c[w])c=c[w];else return;if(c[d]&&c[d][b.property]!==void 0)d=c[d][b.property],b.initialValue=d,b.setValue(d)}}}function I(a){var b=a.__save_row=document.createElement("li");g.addClass(a.domElement, -"has-save");a.__ul.insertBefore(b,a.__ul.firstChild);g.addClass(b,"save-row");var c=document.createElement("span");c.innerHTML=" ";g.addClass(c,"button gears");var d=document.createElement("span");d.innerHTML="Save";g.addClass(d,"button");g.addClass(d,"save");var e=document.createElement("span");e.innerHTML="New";g.addClass(e,"button");g.addClass(e,"save-as");var f=document.createElement("span");f.innerHTML="Revert";g.addClass(f,"button");g.addClass(f,"revert");var m=a.__preset_select=document.createElement("select"); -a.load&&a.load.remembered?i.each(a.load.remembered,function(b,c){C(a,c,c==a.preset)}):C(a,w,false);g.bind(m,"change",function(){for(var b=0;b0){a.preset=this.preset;if(!a.remembered)a.remembered={};a.remembered[this.preset]=z(this)}a.folders={};i.each(this.__folders,function(b, -c){a.folders[c]=b.getSaveObject()});return a},save:function(){if(!this.load.remembered)this.load.remembered={};this.load.remembered[this.preset]=z(this);B(this,false)},saveAs:function(a){if(!this.load.remembered)this.load.remembered={},this.load.remembered[w]=z(this,true);this.load.remembered[a]=z(this);this.preset=a;C(this,a,true)},revert:function(a){i.each(this.__controllers,function(b){this.getRoot().load.remembered?t(a||this.getRoot(),b):b.setValue(b.initialValue)},this);i.each(this.__folders, -function(a){a.revert(a)});a||B(this.getRoot(),false)},listen:function(a){var b=this.__listening.length==0;this.__listening.push(a);b&&E(this.__listening)}});return k}(dat.utils.css,'
\n\n Here\'s the new load parameter for your GUI\'s constructor:\n\n \n\n
\n\n Automatically save\n values to localStorage on exit.\n\n
The values saved to localStorage will\n override those passed to dat.GUI\'s constructor. This makes it\n easier to work incrementally, but localStorage is fragile,\n and your friends may not see the same values you do.\n \n
\n \n
\n\n
', -".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity 0.1s linear;-o-transition:opacity 0.1s linear;-moz-transition:opacity 0.1s linear;transition:opacity 0.1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity 0.1s linear;-o-transition:opacity 0.1s linear;-moz-transition:opacity 0.1s linear;transition:opacity 0.1s linear;border:0;position:absolute;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-x:hidden}.dg.a.has-save ul{margin-top:27px}.dg.a.has-save ul.closed{margin-top:0}.dg.a .save-row{position:fixed;top:0;z-index:1002}.dg li{-webkit-transition:height 0.1s ease-out;-o-transition:height 0.1s ease-out;-moz-transition:height 0.1s ease-out;transition:height 0.1s ease-out}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;overflow:hidden;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li > *{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .c{float:left;width:60%}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:9px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2fa1d6}.dg .cr.number input[type=text]{color:#2fa1d6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2fa1d6}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n", -dat.controllers.factory=function(e,a,c,d,f,b,n){return function(h,j,m,l){var o=h[j];if(n.isArray(m)||n.isObject(m))return new e(h,j,m);if(n.isNumber(o))return n.isNumber(m)&&n.isNumber(l)?new c(h,j,m,l):new a(h,j,{min:m,max:l});if(n.isString(o))return new d(h,j);if(n.isFunction(o))return new f(h,j,"");if(n.isBoolean(o))return new b(h,j)}}(dat.controllers.OptionController,dat.controllers.NumberControllerBox,dat.controllers.NumberControllerSlider,dat.controllers.StringController=function(e,a,c){var d= -function(c,b){function e(){h.setValue(h.__input.value)}d.superclass.call(this,c,b);var h=this;this.__input=document.createElement("input");this.__input.setAttribute("type","text");a.bind(this.__input,"keyup",e);a.bind(this.__input,"change",e);a.bind(this.__input,"blur",function(){h.__onFinishChange&&h.__onFinishChange.call(h,h.getValue())});a.bind(this.__input,"keydown",function(a){a.keyCode===13&&this.blur()});this.updateDisplay();this.domElement.appendChild(this.__input)};d.superclass=e;c.extend(d.prototype, -e.prototype,{updateDisplay:function(){if(!a.isActive(this.__input))this.__input.value=this.getValue();return d.superclass.prototype.updateDisplay.call(this)}});return d}(dat.controllers.Controller,dat.dom.dom,dat.utils.common),dat.controllers.FunctionController,dat.controllers.BooleanController,dat.utils.common),dat.controllers.Controller,dat.controllers.BooleanController,dat.controllers.FunctionController,dat.controllers.NumberControllerBox,dat.controllers.NumberControllerSlider,dat.controllers.OptionController, -dat.controllers.ColorController=function(e,a,c,d,f){function b(a,b,c,d){a.style.background="";f.each(j,function(e){a.style.cssText+="background: "+e+"linear-gradient("+b+", "+c+" 0%, "+d+" 100%); "})}function n(a){a.style.background="";a.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);";a.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);"; -a.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);";a.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);";a.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);"}var h=function(e,l){function o(b){q(b);a.bind(window,"mousemove",q);a.bind(window, -"mouseup",j)}function j(){a.unbind(window,"mousemove",q);a.unbind(window,"mouseup",j)}function g(){var a=d(this.value);a!==false?(p.__color.__state=a,p.setValue(p.__color.toOriginal())):this.value=p.__color.toString()}function i(){a.unbind(window,"mousemove",s);a.unbind(window,"mouseup",i)}function q(b){b.preventDefault();var c=a.getWidth(p.__saturation_field),d=a.getOffset(p.__saturation_field),e=(b.clientX-d.left+document.body.scrollLeft)/c,b=1-(b.clientY-d.top+document.body.scrollTop)/c;b>1?b= -1:b<0&&(b=0);e>1?e=1:e<0&&(e=0);p.__color.v=b;p.__color.s=e;p.setValue(p.__color.toOriginal());return false}function s(b){b.preventDefault();var c=a.getHeight(p.__hue_field),d=a.getOffset(p.__hue_field),b=1-(b.clientY-d.top+document.body.scrollTop)/c;b>1?b=1:b<0&&(b=0);p.__color.h=b*360;p.setValue(p.__color.toOriginal());return false}h.superclass.call(this,e,l);this.__color=new c(this.getValue());this.__temp=new c(0);var p=this;this.domElement=document.createElement("div");a.makeSelectable(this.domElement, -false);this.__selector=document.createElement("div");this.__selector.className="selector";this.__saturation_field=document.createElement("div");this.__saturation_field.className="saturation-field";this.__field_knob=document.createElement("div");this.__field_knob.className="field-knob";this.__field_knob_border="2px solid ";this.__hue_knob=document.createElement("div");this.__hue_knob.className="hue-knob";this.__hue_field=document.createElement("div");this.__hue_field.className="hue-field";this.__input= -document.createElement("input");this.__input.type="text";this.__input_textShadow="0 1px 1px ";a.bind(this.__input,"keydown",function(a){a.keyCode===13&&g.call(this)});a.bind(this.__input,"blur",g);a.bind(this.__selector,"mousedown",function(){a.addClass(this,"drag").bind(window,"mouseup",function(){a.removeClass(p.__selector,"drag")})});var t=document.createElement("div");f.extend(this.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}); -f.extend(this.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:this.__field_knob_border+(this.__color.v<0.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1});f.extend(this.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1});f.extend(this.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"});f.extend(t.style, -{width:"100%",height:"100%",background:"none"});b(t,"top","rgba(0,0,0,0)","#000");f.extend(this.__hue_field.style,{width:"15px",height:"100px",display:"inline-block",border:"1px solid #555",cursor:"ns-resize"});n(this.__hue_field);f.extend(this.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:this.__input_textShadow+"rgba(0,0,0,0.7)"});a.bind(this.__saturation_field,"mousedown",o);a.bind(this.__field_knob,"mousedown",o);a.bind(this.__hue_field,"mousedown", -function(b){s(b);a.bind(window,"mousemove",s);a.bind(window,"mouseup",i)});this.__saturation_field.appendChild(t);this.__selector.appendChild(this.__field_knob);this.__selector.appendChild(this.__saturation_field);this.__selector.appendChild(this.__hue_field);this.__hue_field.appendChild(this.__hue_knob);this.domElement.appendChild(this.__input);this.domElement.appendChild(this.__selector);this.updateDisplay()};h.superclass=e;f.extend(h.prototype,e.prototype,{updateDisplay:function(){var a=d(this.getValue()); -if(a!==false){var e=false;f.each(c.COMPONENTS,function(b){if(!f.isUndefined(a[b])&&!f.isUndefined(this.__color.__state[b])&&a[b]!==this.__color.__state[b])return e=true,{}},this);e&&f.extend(this.__color.__state,a)}f.extend(this.__temp.__state,this.__color.__state);this.__temp.a=1;var h=this.__color.v<0.5||this.__color.s>0.5?255:0,j=255-h;f.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toString(),border:this.__field_knob_border+ -"rgb("+h+","+h+","+h+")"});this.__hue_knob.style.marginTop=(1-this.__color.h/360)*100+"px";this.__temp.s=1;this.__temp.v=1;b(this.__saturation_field,"left","#fff",this.__temp.toString());f.extend(this.__input.style,{backgroundColor:this.__input.value=this.__color.toString(),color:"rgb("+h+","+h+","+h+")",textShadow:this.__input_textShadow+"rgba("+j+","+j+","+j+",.7)"})}});var j=["-moz-","-o-","-webkit-","-ms-",""];return h}(dat.controllers.Controller,dat.dom.dom,dat.color.Color=function(e,a,c,d){function f(a, -b,c){Object.defineProperty(a,b,{get:function(){if(this.__state.space==="RGB")return this.__state[b];n(this,b,c);return this.__state[b]},set:function(a){if(this.__state.space!=="RGB")n(this,b,c),this.__state.space="RGB";this.__state[b]=a}})}function b(a,b){Object.defineProperty(a,b,{get:function(){if(this.__state.space==="HSV")return this.__state[b];h(this);return this.__state[b]},set:function(a){if(this.__state.space!=="HSV")h(this),this.__state.space="HSV";this.__state[b]=a}})}function n(b,c,e){if(b.__state.space=== -"HEX")b.__state[c]=a.component_from_hex(b.__state.hex,e);else if(b.__state.space==="HSV")d.extend(b.__state,a.hsv_to_rgb(b.__state.h,b.__state.s,b.__state.v));else throw"Corrupted color state";}function h(b){var c=a.rgb_to_hsv(b.r,b.g,b.b);d.extend(b.__state,{s:c.s,v:c.v});if(d.isNaN(c.h)){if(d.isUndefined(b.__state.h))b.__state.h=0}else b.__state.h=c.h}var j=function(){this.__state=e.apply(this,arguments);if(this.__state===false)throw"Failed to interpret color arguments";this.__state.a=this.__state.a|| -1};j.COMPONENTS="r,g,b,h,s,v,hex,a".split(",");d.extend(j.prototype,{toString:function(){return c(this)},toOriginal:function(){return this.__state.conversion.write(this)}});f(j.prototype,"r",2);f(j.prototype,"g",1);f(j.prototype,"b",0);b(j.prototype,"h");b(j.prototype,"s");b(j.prototype,"v");Object.defineProperty(j.prototype,"a",{get:function(){return this.__state.a},set:function(a){this.__state.a=a}});Object.defineProperty(j.prototype,"hex",{get:function(){if(!this.__state.space!=="HEX")this.__state.hex= -a.rgb_to_hex(this.r,this.g,this.b);return this.__state.hex},set:function(a){this.__state.space="HEX";this.__state.hex=a}});return j}(dat.color.interpret,dat.color.math=function(){var e;return{hsv_to_rgb:function(a,c,d){var e=a/60-Math.floor(a/60),b=d*(1-c),n=d*(1-e*c),c=d*(1-(1-e)*c),a=[[d,c,b],[n,d,b],[b,d,c],[b,n,d],[c,b,d],[d,b,n]][Math.floor(a/60)%6];return{r:a[0]*255,g:a[1]*255,b:a[2]*255}},rgb_to_hsv:function(a,c,d){var e=Math.min(a,c,d),b=Math.max(a,c,d),e=b-e;if(b==0)return{h:NaN,s:0,v:0}; -a=a==b?(c-d)/e:c==b?2+(d-a)/e:4+(a-c)/e;a/=6;a<0&&(a+=1);return{h:a*360,s:e/b,v:b/255}},rgb_to_hex:function(a,c,d){a=this.hex_with_component(0,2,a);a=this.hex_with_component(a,1,c);return a=this.hex_with_component(a,0,d)},component_from_hex:function(a,c){return a>>c*8&255},hex_with_component:function(a,c,d){return d<<(e=c*8)|a&~(255< - - SPE: Mouse follow - - - - -

- - - - - - - - - diff --git a/examples/multipleEmitters.html b/examples/multipleEmitters.html deleted file mode 100644 index 2c5d88d..0000000 --- a/examples/multipleEmitters.html +++ /dev/null @@ -1,175 +0,0 @@ - - - SPE: Multiple Emitters - - - - -

- - - - - - - - - diff --git a/examples/orbit.html b/examples/orbit.html deleted file mode 100644 index f814e67..0000000 --- a/examples/orbit.html +++ /dev/null @@ -1,120 +0,0 @@ - - - SPE: Distribution types - - - - - - - - - - - - diff --git a/examples/pool.html b/examples/pool.html deleted file mode 100644 index 8347411..0000000 --- a/examples/pool.html +++ /dev/null @@ -1,155 +0,0 @@ - - - SPE: Emitter pooling - - - - -

Click mouse or press any key to trigger an explosion.

- - - - - - - - - diff --git a/examples/rotation.html b/examples/rotation.html deleted file mode 100644 index 5e92fea..0000000 --- a/examples/rotation.html +++ /dev/null @@ -1,269 +0,0 @@ - - - SPE: Distribution types - - - - - - - - - - - - diff --git a/examples/runtimeChanging.html b/examples/runtimeChanging.html deleted file mode 100644 index e573a63..0000000 --- a/examples/runtimeChanging.html +++ /dev/null @@ -1,293 +0,0 @@ - - - - SPE: Dynamic properties - - - - - - - - - - - - diff --git a/package-lock.json b/package-lock.json index 6157e6b..fc9e733 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,1472 +1,1378 @@ { "name": "shader-particle-engine", - "version": "1.0.6", - "lockfileVersion": 1, + "version": "1.1.0", + "lockfileVersion": 3, "requires": true, - "dependencies": { - "@babel/parser": { - "version": "7.10.3", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.10.3.tgz", - "integrity": "sha512-oJtNJCMFdIMwXGmx+KxuaD7i3b8uS7TTFYW/FNG2BT8m+fmGHoiPYoH0Pe3gya07WuFmM5FCDIr1x0irkD/hyA==", - "dev": true - }, - "abbrev": { + "packages": { + "": { + "name": "shader-particle-engine", + "version": "1.1.0", + "license": "MIT", + "dependencies": { + "three": "^0.173.0" + }, + "devDependencies": { + "grunt": "^1.6.1", + "grunt-contrib-concat": "^2.1.0", + "grunt-contrib-uglify": "^5.2.1" + } + }, + "node_modules/abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", - "dev": true + "dev": true, + "license": "ISC" }, - "align-text": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", - "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, - "requires": { - "kind-of": "^3.0.2", - "longest": "^1.0.1", - "repeat-string": "^1.5.2" + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "amdefine": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", - "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", - "dev": true + "node_modules/argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "license": "MIT", + "dependencies": { + "sprintf-js": "~1.0.2" + } }, - "ansi-regex": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz", - "integrity": "sha1-DY6UaWej2BQ/k+JOKYUl/BsiNfk=", - "dev": true + "node_modules/array-each": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/array-each/-/array-each-1.0.1.tgz", + "integrity": "sha512-zHjL5SZa68hkKHBFBK6DJCTtr9sfTCPCaph/L7tMSLcTFgy+zX7E+6q5UArbtOtMBCtxdICpfTCspRse+ywyXA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } }, - "ansi-styles": { + "node_modules/array-slice": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-1.1.0.tgz", - "integrity": "sha1-6uy/Zs1waIJ2Cy9GkVgrj1XXp94=", - "dev": true + "resolved": "https://registry.npmjs.org/array-slice/-/array-slice-1.1.0.tgz", + "integrity": "sha512-B1qMD3RBP7O8o0H2KbrXDyB0IccejMF15+87Lvlor12ONPRHP6gTjXMNkt/d3ZuOGbAe66hFmaCfECI24Ufp6w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/async": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz", + "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==", + "dev": true, + "license": "MIT" + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } }, - "argparse": { - "version": "0.1.16", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-0.1.16.tgz", - "integrity": "sha1-z9AeD7uj1srtBJ+9dY1A9lGW9Xw=", + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dev": true, - "requires": { - "underscore": "~1.7.0", - "underscore.string": "~2.4.0" + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" }, + "engines": { + "node": ">=8" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", "dependencies": { - "underscore.string": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-2.4.0.tgz", - "integrity": "sha1-jN2PusTi0uoefi6Al8QvRCKA+Fs=", - "dev": true - } + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "array-find-index": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/array-find-index/-/array-find-index-1.0.2.tgz", - "integrity": "sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E=", - "dev": true + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } }, - "async": { - "version": "0.1.22", - "resolved": "https://registry.npmjs.org/async/-/async-0.1.22.tgz", - "integrity": "sha1-D8GqoIig4+8Ovi2IMbqw3PiEUGE=", - "dev": true + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" }, - "at-least-node": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", - "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==", - "dev": true + "node_modules/colors": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz", + "integrity": "sha512-ENwblkFQpqqia6b++zLD/KUWafYlVY/UNnAp7oz7LY7E924wmpye416wBOmvv/HMWzl8gL1kJlfvId/1Dg176w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.1.90" + } }, - "bluebird": { - "version": "3.7.2", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", - "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==", - "dev": true + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true, + "license": "MIT" }, - "browserify-zlib": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.1.4.tgz", - "integrity": "sha1-uzX4pRn2AOD6a4SFJByXnQFB+y0=", + "node_modules/dateformat": { + "version": "4.6.3", + "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-4.6.3.tgz", + "integrity": "sha512-2P0p0pFGzHS5EMnhdxQi7aJN+iMheud0UhG4dlE1DLAlvL8JHjJJTX/CSm4JXwV0Ka5nGk3zC5mcb5bUQUxxMA==", "dev": true, - "requires": { - "pako": "~0.2.0" + "license": "MIT", + "engines": { + "node": "*" } }, - "buffer-from": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", - "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", - "dev": true + "node_modules/detect-file": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-1.0.0.tgz", + "integrity": "sha512-DtCOLG98P007x7wiiOmfI0fi3eIKyWiLTGJ2MDnVi/E04lWGbf+JzrRHMm0rgIIZJGtHpKpbVgLWHrv8xXpc3Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } }, - "camelcase": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz", - "integrity": "sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8=", - "dev": true + "node_modules/duplexer": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.2.tgz", + "integrity": "sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg==", + "dev": true, + "license": "MIT" }, - "camelcase-keys": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", - "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=", + "node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", "dev": true, - "requires": { - "camelcase": "^2.0.0", - "map-obj": "^1.0.0" + "license": "MIT", + "engines": { + "node": ">=0.8.0" } }, - "catharsis": { - "version": "0.8.11", - "resolved": "https://registry.npmjs.org/catharsis/-/catharsis-0.8.11.tgz", - "integrity": "sha512-a+xUyMV7hD1BrDQA/3iPV7oc+6W26BgVJO05PGEoatMyIuPScQKsde6i3YorWX1qs+AZjnJ18NqdKoCtKiNh1g==", + "node_modules/esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", "dev": true, - "requires": { - "lodash": "^4.17.14" + "license": "BSD-2-Clause", + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" }, - "dependencies": { - "lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", - "dev": true - } + "engines": { + "node": ">=4" } }, - "center-align": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz", - "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=", + "node_modules/eventemitter2": { + "version": "0.4.14", + "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-0.4.14.tgz", + "integrity": "sha512-K7J4xq5xAD5jHsGM5ReWXRTFa3JRGofHiMcVgQ8PRwgWxzjHpMWCIzsmyf60+mh8KLsqYPcjUMa0AC4hd6lPyQ==", "dev": true, - "requires": { - "align-text": "^0.1.3", - "lazy-cache": "^1.0.3" + "license": "MIT" + }, + "node_modules/exit": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", + "integrity": "sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==", + "dev": true, + "engines": { + "node": ">= 0.8.0" } }, - "chalk": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-0.5.1.tgz", - "integrity": "sha1-Zjs6ZItotV0EaQ1JFnqoN4WPIXQ=", + "node_modules/expand-tilde": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz", + "integrity": "sha512-A5EmesHW6rfnZ9ysHQjPdJRni0SRar0tjtG5MNtm9n5TUvsYU8oozprtRD4AqHxcZWWlVuAmQo2nWKfN9oyjTw==", "dev": true, - "requires": { - "ansi-styles": "^1.1.0", - "escape-string-regexp": "^1.0.0", - "has-ansi": "^0.1.0", - "strip-ansi": "^0.3.0", - "supports-color": "^0.2.0" + "license": "MIT", + "dependencies": { + "homedir-polyfill": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" } }, - "cliui": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", - "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", - "dev": true, - "requires": { - "center-align": "^0.1.1", - "right-align": "^0.1.1", - "wordwrap": "0.0.2" - } - }, - "coffee-script": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.3.3.tgz", - "integrity": "sha1-FQ1rTLUiiUNp7+1qIQHCC8f0pPQ=", - "dev": true - }, - "colors": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/colors/-/colors-0.6.2.tgz", - "integrity": "sha1-JCP+ZnisDF2uiFLl0OW+CMmXq8w=", - "dev": true - }, - "commander": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz", - "integrity": "sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==", - "dev": true - }, - "concat-stream": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", - "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", - "dev": true, - "requires": { - "buffer-from": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^2.2.2", - "typedarray": "^0.0.6" - } - }, - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true + "node_modules/extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", + "dev": true, + "license": "MIT" }, - "currently-unhandled": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz", - "integrity": "sha1-mI3zP+qxke95mmE2nddsF635V+o=", + "node_modules/figures": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", + "integrity": "sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg==", "dev": true, - "requires": { - "array-find-index": "^1.0.1" + "license": "MIT", + "dependencies": { + "escape-string-regexp": "^1.0.5" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "dateformat": { - "version": "1.0.2-1.2.3", - "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-1.0.2-1.2.3.tgz", - "integrity": "sha1-sCIMAt6YYXQztyhRz0fePfLNvuk=", - "dev": true + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } }, - "decamelize": { + "node_modules/findup-sync": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-5.0.0.tgz", + "integrity": "sha512-MzwXju70AuyflbgeOhzvQWAvvQdo1XL0A9bVvlXsYcFEBM87WR4OakL4OfZq+QRmr+duJubio+UtNQCPsVESzQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "detect-file": "^1.0.0", + "is-glob": "^4.0.3", + "micromatch": "^4.0.4", + "resolve-dir": "^1.0.1" + }, + "engines": { + "node": ">= 10.13.0" + } + }, + "node_modules/fined": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", - "dev": true + "resolved": "https://registry.npmjs.org/fined/-/fined-1.2.0.tgz", + "integrity": "sha512-ZYDqPLGxDkDhDZBjZBb+oD1+j0rA4E0pXY50eplAAOPg2N/gUBSSk5IM1/QhPfyVo19lJ+CvXpqfvk+b2p/8Ng==", + "dev": true, + "license": "MIT", + "dependencies": { + "expand-tilde": "^2.0.2", + "is-plain-object": "^2.0.3", + "object.defaults": "^1.1.0", + "object.pick": "^1.2.0", + "parse-filepath": "^1.0.1" + }, + "engines": { + "node": ">= 0.10" + } }, - "docco": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/docco/-/docco-0.6.3.tgz", - "integrity": "sha1-xHtYI9eVY9b8Or1J895ImG5VIu4=", + "node_modules/flagged-respawn": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-1.0.1.tgz", + "integrity": "sha512-lNaHNVymajmk0OJMBn8fVUAU1BtDeKIqKoVhk4xAALB57aALg6b4W0MfJ/cUE0g9YBXy5XhSlPIpYIJ7HaY/3Q==", "dev": true, - "requires": { - "commander": ">= 0.5.2", - "fs-extra": ">= 0.6.0", - "highlight.js": ">= 8.0.x", - "marked": ">= 0.2.7", - "underscore": ">= 1.0.0" + "license": "MIT", + "engines": { + "node": ">= 0.10" } }, - "entities": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/entities/-/entities-2.0.3.tgz", - "integrity": "sha512-MyoZ0jgnLvB2X3Lg5HqpFmn1kybDiIfEQmKzTb5apr51Rb+T3KdmMiqa70T+bhGnyv7bQ6WMj2QMHpGMmlrUYQ==", - "dev": true + "node_modules/for-in": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", + "integrity": "sha512-7EwmXrOjyL+ChxMhmG5lnW9MPt1aIeZEwKhQzoBUdTV0N3zuwWDZYVJatDvZ2OyzPUvdIAZDsCetk3coyMfcnQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } }, - "error-ex": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", - "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "node_modules/for-own": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/for-own/-/for-own-1.0.0.tgz", + "integrity": "sha512-0OABksIGrxKK8K4kynWkQ7y1zounQxP+CWnyclVwj81KW3vlLlGUx57DKGcP/LH216GzqnstnPocF16Nxs0Ycg==", "dev": true, - "requires": { - "is-arrayish": "^0.2.1" + "license": "MIT", + "dependencies": { + "for-in": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" } }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true, + "license": "ISC" }, - "esprima": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.0.4.tgz", - "integrity": "sha1-n1V+CPw7TSbs6d00+Pv0drYlha0=", - "dev": true + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } }, - "eventemitter2": { - "version": "0.4.14", - "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-0.4.14.tgz", - "integrity": "sha1-j2G3XN4BKy6esoTUVFWDtWQ7Yas=", - "dev": true + "node_modules/getobject": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/getobject/-/getobject-1.0.2.tgz", + "integrity": "sha512-2zblDBaFcb3rB4rF77XVnuINOE2h2k/OnqXAiy0IrTxUfV1iFp3la33oAQVY9pCpWU268WFYVt2t71hlMuLsOg==", + "dev": true, + "engines": { + "node": ">=10" + } }, - "exit": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", - "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", - "dev": true + "node_modules/glob": { + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", + "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dev": true, + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } }, - "figures": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", - "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", + "node_modules/global-modules": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz", + "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==", "dev": true, - "requires": { - "escape-string-regexp": "^1.0.5", - "object-assign": "^4.1.0" + "license": "MIT", + "dependencies": { + "global-prefix": "^1.0.1", + "is-windows": "^1.0.1", + "resolve-dir": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "find-up": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", - "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", + "node_modules/global-prefix": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-1.0.2.tgz", + "integrity": "sha512-5lsx1NUDHtSjfg0eHlmYvZKv8/nVqX4ckFbM+FrGcQ+04KWcWFo9P5MxPZYSzUvyzmdTbI7Eix8Q4IbELDqzKg==", "dev": true, - "requires": { - "path-exists": "^2.0.0", - "pinkie-promise": "^2.0.0" + "license": "MIT", + "dependencies": { + "expand-tilde": "^2.0.2", + "homedir-polyfill": "^1.0.1", + "ini": "^1.3.4", + "is-windows": "^1.0.1", + "which": "^1.2.14" + }, + "engines": { + "node": ">=0.10.0" } }, - "findup-sync": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.1.3.tgz", - "integrity": "sha1-fz56l7gjksZTvwZYm9hRkOk8NoM=", + "node_modules/global-prefix/node_modules/which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", "dev": true, - "requires": { - "glob": "~3.2.9", - "lodash": "~2.4.1" + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" }, + "bin": { + "which": "bin/which" + } + }, + "node_modules/grunt": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/grunt/-/grunt-1.6.1.tgz", + "integrity": "sha512-/ABUy3gYWu5iBmrUSRBP97JLpQUm0GgVveDCp6t3yRNIoltIYw7rEj3g5y1o2PGPR2vfTRGa7WC/LZHLTXnEzA==", + "dev": true, + "license": "MIT", "dependencies": { - "glob": { - "version": "3.2.11", - "resolved": "https://registry.npmjs.org/glob/-/glob-3.2.11.tgz", - "integrity": "sha1-Spc/Y1uRkPcV0QmH1cAP0oFevj0=", - "dev": true, - "requires": { - "inherits": "2", - "minimatch": "0.3" - } - }, - "lodash": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-2.4.2.tgz", - "integrity": "sha1-+t2DS5aDBz2hebPq5tnA0VBT9z4=", - "dev": true - }, - "minimatch": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.3.0.tgz", - "integrity": "sha1-J12O2qxPG7MyZHIInnlJyDlGmd0=", - "dev": true, - "requires": { - "lru-cache": "2", - "sigmund": "~1.0.0" - } - } - } - }, - "fs-extra": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.0.1.tgz", - "integrity": "sha512-h2iAoN838FqAFJY2/qVpzFXy+EBxfVE220PalAqQLDVsFOHLJrZvut5puAbCdNv6WJk+B8ihI+k0c7JK5erwqQ==", - "dev": true, - "requires": { - "at-least-node": "^1.0.0", - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^1.0.0" + "dateformat": "~4.6.2", + "eventemitter2": "~0.4.13", + "exit": "~0.1.2", + "findup-sync": "~5.0.0", + "glob": "~7.1.6", + "grunt-cli": "~1.4.3", + "grunt-known-options": "~2.0.0", + "grunt-legacy-log": "~3.0.0", + "grunt-legacy-util": "~2.0.1", + "iconv-lite": "~0.6.3", + "js-yaml": "~3.14.0", + "minimatch": "~3.0.4", + "nopt": "~3.0.6" + }, + "bin": { + "grunt": "bin/grunt" }, + "engines": { + "node": ">=16" + } + }, + "node_modules/grunt-cli": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/grunt-cli/-/grunt-cli-1.4.3.tgz", + "integrity": "sha512-9Dtx/AhVeB4LYzsViCjUQkd0Kw0McN2gYpdmGYKtE2a5Yt7v1Q+HYZVWhqXc/kGnxlMtqKDxSwotiGeFmkrCoQ==", + "dev": true, + "license": "MIT", "dependencies": { - "graceful-fs": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz", - "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==", - "dev": true - } + "grunt-known-options": "~2.0.0", + "interpret": "~1.1.0", + "liftup": "~3.0.1", + "nopt": "~4.0.1", + "v8flags": "~3.2.0" + }, + "bin": { + "grunt": "bin/grunt" + }, + "engines": { + "node": ">=10" } }, - "get-stdin": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", - "integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=", - "dev": true - }, - "getobject": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/getobject/-/getobject-0.1.0.tgz", - "integrity": "sha1-BHpEl4n6Fg0Bj1SG7ZEyC27HiFw=", - "dev": true - }, - "glob": { - "version": "3.1.21", - "resolved": "https://registry.npmjs.org/glob/-/glob-3.1.21.tgz", - "integrity": "sha1-0p4KBV3qUTj00H7UDomC6DwgZs0=", - "dev": true, - "requires": { - "graceful-fs": "~1.2.0", - "inherits": "1", - "minimatch": "~0.2.11" + "node_modules/grunt-cli/node_modules/nopt": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.3.tgz", + "integrity": "sha512-CvaGwVMztSMJLOeXPrez7fyfObdZqNUK1cPAEzLHrTybIua9pMdmmPR5YwtfNftIOMv3DPUhFaxsZMNTQO20Kg==", + "dev": true, + "license": "ISC", + "dependencies": { + "abbrev": "1", + "osenv": "^0.1.4" }, + "bin": { + "nopt": "bin/nopt.js" + } + }, + "node_modules/grunt-contrib-concat": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/grunt-contrib-concat/-/grunt-contrib-concat-2.1.0.tgz", + "integrity": "sha512-Vnl95JIOxfhEN7bnYIlCgQz41kkbi7tsZ/9a4usZmxNxi1S2YAIOy8ysFmO8u4MN26Apal1O106BwARdaNxXQw==", + "dev": true, + "license": "MIT", "dependencies": { - "inherits": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-1.0.2.tgz", - "integrity": "sha1-ykMJ2t7mtUzAuNJH6NfHoJdb3Js=", - "dev": true - } - } - }, - "graceful-fs": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-1.2.3.tgz", - "integrity": "sha1-FaSAaldUfLLS2/J/QuiajDRRs2Q=", - "dev": true - }, - "grunt": { - "version": "0.4.5", - "resolved": "https://registry.npmjs.org/grunt/-/grunt-0.4.5.tgz", - "integrity": "sha1-VpN81RlDJK3/bSB2MYMqnWuk5/A=", - "dev": true, - "requires": { - "async": "~0.1.22", - "coffee-script": "~1.3.3", - "colors": "~0.6.2", - "dateformat": "1.0.2-1.2.3", - "eventemitter2": "~0.4.13", - "exit": "~0.1.1", - "findup-sync": "~0.1.2", - "getobject": "~0.1.0", - "glob": "~3.1.21", - "grunt-legacy-log": "~0.1.0", - "grunt-legacy-util": "~0.2.0", - "hooker": "~0.2.3", - "iconv-lite": "~0.2.11", - "js-yaml": "~2.0.5", - "lodash": "~0.9.2", - "minimatch": "~0.2.12", - "nopt": "~1.0.10", - "rimraf": "~2.2.8", - "underscore.string": "~2.2.1", - "which": "~1.0.5" - } - }, - "grunt-contrib-concat": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/grunt-contrib-concat/-/grunt-contrib-concat-0.5.1.tgz", - "integrity": "sha1-lTxu/f39LBB6uchQd/LUsk0xzUk=", - "dev": true, - "requires": { - "chalk": "^0.5.1", - "source-map": "^0.3.0" - } - }, - "grunt-contrib-uglify": { - "version": "0.9.2", - "resolved": "https://registry.npmjs.org/grunt-contrib-uglify/-/grunt-contrib-uglify-0.9.2.tgz", - "integrity": "sha1-GmHG8hJBDkq7T3yJFTcXsQFWAmA=", - "dev": true, - "requires": { - "chalk": "^1.0.0", - "lodash": "^3.2.0", - "maxmin": "^1.0.0", - "uglify-js": "^2.4.24", - "uri-path": "0.0.2" + "chalk": "^4.1.2", + "source-map": "^0.5.3" }, + "engines": { + "node": ">=0.12.0" + }, + "peerDependencies": { + "grunt": ">=1.4.1" + } + }, + "node_modules/grunt-contrib-uglify": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/grunt-contrib-uglify/-/grunt-contrib-uglify-5.2.2.tgz", + "integrity": "sha512-ITxiWxrjjP+RZu/aJ5GLvdele+sxlznh+6fK9Qckio5ma8f7Iv8woZjRkGfafvpuygxNefOJNc+hfjjBayRn2Q==", + "dev": true, + "license": "MIT", "dependencies": { - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true - }, - "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" - } - }, - "has-ansi": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - }, - "lodash": { - "version": "3.10.1", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", - "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=", - "dev": true - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - }, - "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - } - } - }, - "grunt-docco2": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/grunt-docco2/-/grunt-docco2-0.2.1.tgz", - "integrity": "sha1-ZghyYavBkcjofI77/LeIEr/krMs=", - "dev": true, - "requires": { - "docco": "~0.6.3" - } - }, - "grunt-jsdoc": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/grunt-jsdoc/-/grunt-jsdoc-1.1.0.tgz", - "integrity": "sha1-S87+YFh6ZGpbcg/pq/lMxIh/6FQ=", + "chalk": "^4.1.2", + "maxmin": "^3.0.0", + "uglify-js": "^3.16.1", + "uri-path": "^1.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/grunt-known-options": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/grunt-known-options/-/grunt-known-options-2.0.0.tgz", + "integrity": "sha512-GD7cTz0I4SAede1/+pAbmJRG44zFLPipVtdL9o3vqx9IEyb7b4/Y3s7r6ofI3CchR5GvYJ+8buCSioDv5dQLiA==", "dev": true, - "requires": { - "jsdoc": "^3.4.0" + "license": "MIT", + "engines": { + "node": ">=0.10.0" } }, - "grunt-legacy-log": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/grunt-legacy-log/-/grunt-legacy-log-0.1.3.tgz", - "integrity": "sha1-7ClCboAwIa9ZAp+H0vnNczWgVTE=", + "node_modules/grunt-legacy-log": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/grunt-legacy-log/-/grunt-legacy-log-3.0.0.tgz", + "integrity": "sha512-GHZQzZmhyq0u3hr7aHW4qUH0xDzwp2YXldLPZTCjlOeGscAOWWPftZG3XioW8MasGp+OBRIu39LFx14SLjXRcA==", "dev": true, - "requires": { - "colors": "~0.6.2", - "grunt-legacy-log-utils": "~0.1.1", + "license": "MIT", + "dependencies": { + "colors": "~1.1.2", + "grunt-legacy-log-utils": "~2.1.0", "hooker": "~0.2.3", - "lodash": "~2.4.1", - "underscore.string": "~2.3.3" + "lodash": "~4.17.19" }, - "dependencies": { - "lodash": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-2.4.2.tgz", - "integrity": "sha1-+t2DS5aDBz2hebPq5tnA0VBT9z4=", - "dev": true - }, - "underscore.string": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-2.3.3.tgz", - "integrity": "sha1-ccCL9rQosRM/N+ePo6Icgvcymw0=", - "dev": true - } - } - }, - "grunt-legacy-log-utils": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/grunt-legacy-log-utils/-/grunt-legacy-log-utils-0.1.1.tgz", - "integrity": "sha1-wHBrndkGThFvNvI/5OawSGcsD34=", + "engines": { + "node": ">= 0.10.0" + } + }, + "node_modules/grunt-legacy-log-utils": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/grunt-legacy-log-utils/-/grunt-legacy-log-utils-2.1.0.tgz", + "integrity": "sha512-lwquaPXJtKQk0rUM1IQAop5noEpwFqOXasVoedLeNzaibf/OPWjKYvvdqnEHNmU+0T0CaReAXIbGo747ZD+Aaw==", "dev": true, - "requires": { - "colors": "~0.6.2", - "lodash": "~2.4.1", - "underscore.string": "~2.3.3" + "license": "MIT", + "dependencies": { + "chalk": "~4.1.0", + "lodash": "~4.17.19" }, + "engines": { + "node": ">=10" + } + }, + "node_modules/grunt-legacy-util": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/grunt-legacy-util/-/grunt-legacy-util-2.0.1.tgz", + "integrity": "sha512-2bQiD4fzXqX8rhNdXkAywCadeqiPiay0oQny77wA2F3WF4grPJXCvAcyoWUJV+po/b15glGkxuSiQCK299UC2w==", + "dev": true, + "license": "MIT", "dependencies": { - "lodash": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-2.4.2.tgz", - "integrity": "sha1-+t2DS5aDBz2hebPq5tnA0VBT9z4=", - "dev": true - }, - "underscore.string": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-2.3.3.tgz", - "integrity": "sha1-ccCL9rQosRM/N+ePo6Icgvcymw0=", - "dev": true - } - } - }, - "grunt-legacy-util": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/grunt-legacy-util/-/grunt-legacy-util-0.2.0.tgz", - "integrity": "sha1-kzJIhNv343qf98Am3/RR2UqeVUs=", - "dev": true, - "requires": { - "async": "~0.1.22", - "exit": "~0.1.1", - "getobject": "~0.1.0", + "async": "~3.2.0", + "exit": "~0.1.2", + "getobject": "~1.0.0", "hooker": "~0.2.3", - "lodash": "~0.9.2", - "underscore.string": "~2.2.1", - "which": "~1.0.5" + "lodash": "~4.17.21", + "underscore.string": "~3.3.5", + "which": "~2.0.2" + }, + "engines": { + "node": ">=10" } }, - "gzip-size": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-1.0.0.tgz", - "integrity": "sha1-Zs+LEBBHInuVus5uodoMF37Vwi8=", + "node_modules/gzip-size": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-5.1.1.tgz", + "integrity": "sha512-FNHi6mmoHvs1mxZAds4PpdCS6QG8B4C1krxJsMutgxl5t3+GlRTzzI3NEkifXx2pVsOvJdOGSmIgDhQ55FwdPA==", "dev": true, - "requires": { - "browserify-zlib": "^0.1.4", - "concat-stream": "^1.4.1" + "license": "MIT", + "dependencies": { + "duplexer": "^0.1.1", + "pify": "^4.0.1" + }, + "engines": { + "node": ">=6" } }, - "has-ansi": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-0.1.0.tgz", - "integrity": "sha1-hPJlqujA5qiKEtcCKJS3VoiUxi4=", + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, - "requires": { - "ansi-regex": "^0.2.0" + "license": "MIT", + "engines": { + "node": ">=8" } }, - "highlight.js": { - "version": "10.1.1", - "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-10.1.1.tgz", - "integrity": "sha512-b4L09127uVa+9vkMgPpdUQP78ickGbHEQTWeBrQFTJZ4/n2aihWOGS0ZoUqAwjVmfjhq/C76HRzkqwZhK4sBbg==", - "dev": true + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/homedir-polyfill": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz", + "integrity": "sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==", + "dev": true, + "license": "MIT", + "dependencies": { + "parse-passwd": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } }, - "hooker": { + "node_modules/hooker": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/hooker/-/hooker-0.2.3.tgz", - "integrity": "sha1-uDT3I8xKJCqmWWNFnfbZhMXT2Vk=", - "dev": true - }, - "hosted-git-info": { - "version": "2.8.8", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz", - "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==", - "dev": true - }, - "iconv-lite": { - "version": "0.2.11", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.2.11.tgz", - "integrity": "sha1-HOYKOleGSiktEyH/RgnKS7llrcg=", - "dev": true - }, - "indent-string": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-2.1.0.tgz", - "integrity": "sha1-ji1INIdCEhtKghi3oTfppSBJ3IA=", + "integrity": "sha512-t+UerCsQviSymAInD01Pw+Dn/usmz1sRO+3Zk1+lx8eg+WKpD2ulcwWqHHL0+aseRBr+3+vIhiG1K1JTwaIcTA==", "dev": true, - "requires": { - "repeating": "^2.0.0" + "engines": { + "node": "*" + } + }, + "node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "inherits": { + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", + "dev": true, + "license": "ISC", + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true - }, - "is-arrayish": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", - "dev": true + "dev": true, + "license": "ISC" }, - "is-buffer": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", - "dev": true + "node_modules/ini": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", + "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", + "dev": true, + "license": "ISC" }, - "is-finite": { + "node_modules/interpret": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.1.0.tgz", - "integrity": "sha512-cdyMtqX/BOqqNBBiKlIVkytNHm49MtMlYyn1zxzvJKWmFMlGzm+ry5BBfYyeY9YmNKbRSo/o7OX9w9ale0wg3w==", - "dev": true - }, - "is-utf8": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", - "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", - "dev": true + "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.1.0.tgz", + "integrity": "sha512-CLM8SNMDu7C5psFCn6Wg/tgpj/bKAg7hc2gWqcuR9OD5Ft9PhBpIu8PLicPeis+xDd6YX2ncI8MCA64I9tftIA==", + "dev": true, + "license": "MIT" }, - "isarray": { + "node_modules/is-absolute": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "js-yaml": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-2.0.5.tgz", - "integrity": "sha1-olrmUJmZ6X3yeMZxnaEb0Gh3Q6g=", + "resolved": "https://registry.npmjs.org/is-absolute/-/is-absolute-1.0.0.tgz", + "integrity": "sha512-dOWoqflvcydARa360Gvv18DZ/gRuHKi2NU/wU5X1ZFzdYfH29nkiNZsF3mp4OJ3H4yo9Mx8A/uAGNzpzPN3yBA==", "dev": true, - "requires": { - "argparse": "~ 0.1.11", - "esprima": "~ 1.0.2" + "license": "MIT", + "dependencies": { + "is-relative": "^1.0.0", + "is-windows": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" } }, - "js2xmlparser": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-4.0.1.tgz", - "integrity": "sha512-KrPTolcw6RocpYjdC7pL7v62e55q7qOMHvLX1UCLc5AAS8qeJ6nukarEJAF2KL2PZxlbGueEbINqZR2bDe/gUw==", - "dev": true, - "requires": { - "xmlcreate": "^2.0.3" - } - }, - "jsdoc": { - "version": "3.6.4", - "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.6.4.tgz", - "integrity": "sha512-3G9d37VHv7MFdheviDCjUfQoIjdv4TC5zTTf5G9VODLtOnVS6La1eoYBDlbWfsRT3/Xo+j2MIqki2EV12BZfwA==", - "dev": true, - "requires": { - "@babel/parser": "^7.9.4", - "bluebird": "^3.7.2", - "catharsis": "^0.8.11", - "escape-string-regexp": "^2.0.0", - "js2xmlparser": "^4.0.1", - "klaw": "^3.0.0", - "markdown-it": "^10.0.0", - "markdown-it-anchor": "^5.2.7", - "marked": "^0.8.2", - "mkdirp": "^1.0.4", - "requizzle": "^0.2.3", - "strip-json-comments": "^3.1.0", - "taffydb": "2.6.2", - "underscore": "~1.10.2" - }, + "node_modules/is-core-module": { + "version": "2.16.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.1.tgz", + "integrity": "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==", + "dev": true, + "license": "MIT", "dependencies": { - "escape-string-regexp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", - "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", - "dev": true - }, - "marked": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/marked/-/marked-0.8.2.tgz", - "integrity": "sha512-EGwzEeCcLniFX51DhTpmTom+dSA/MG/OBUDjnWtHbEnjAH180VzUeAw+oE4+Zv+CoYBWyRlYOTR0N8SO9R1PVw==", - "dev": true - }, - "underscore": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.10.2.tgz", - "integrity": "sha512-N4P+Q/BuyuEKFJ43B9gYuOj4TQUHXX+j2FqguVOpjkssLUUrnJofCcBccJSCoeturDoZU6GorDTHSvUDlSQbTg==", - "dev": true - } - } - }, - "jsonfile": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.0.1.tgz", - "integrity": "sha512-jR2b5v7d2vIOust+w3wtFKZIfpC2pnRmFAhAC/BuweZFQR8qZzxH1OyrQ10HmdVYiXWkYUqPVsz91cG7EL2FBg==", - "dev": true, - "requires": { - "graceful-fs": "^4.1.6", - "universalify": "^1.0.0" + "hasown": "^2.0.2" }, - "dependencies": { - "graceful-fs": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz", - "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==", - "dev": true, - "optional": true - } + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", "dev": true, - "requires": { - "is-buffer": "^1.1.5" + "license": "MIT", + "engines": { + "node": ">=0.10.0" } }, - "klaw": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/klaw/-/klaw-3.0.0.tgz", - "integrity": "sha512-0Fo5oir+O9jnXu5EefYbVK+mHMBeEVEy2cmctR1O1NECcCkPRreJKrS6Qt/j3KC2C148Dfo9i3pCmCMsdqGr0g==", + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", "dev": true, - "requires": { - "graceful-fs": "^4.1.9" - }, + "license": "MIT", "dependencies": { - "graceful-fs": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz", - "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==", - "dev": true - } + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" } }, - "lazy-cache": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", - "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=", - "dev": true - }, - "linkify-it": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-2.2.0.tgz", - "integrity": "sha512-GnAl/knGn+i1U/wjBz3akz2stz+HrHLsxMwHQGofCDfPvlf+gDKN58UtfmUquTY4/MXeE2x7k19KQmeoZi94Iw==", + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "dev": true, - "requires": { - "uc.micro": "^1.0.1" + "license": "MIT", + "engines": { + "node": ">=0.12.0" } }, - "load-json-file": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", - "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", + "node_modules/is-plain-object": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", + "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^2.2.0", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0", - "strip-bom": "^2.0.0" - }, + "license": "MIT", "dependencies": { - "graceful-fs": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz", - "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==", - "dev": true - } + "isobject": "^3.0.1" + }, + "engines": { + "node": ">=0.10.0" } }, - "lodash": { - "version": "0.9.2", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-0.9.2.tgz", - "integrity": "sha1-jzSZxSRdNG1oLlsNO0B2fgnxqSw=", - "dev": true + "node_modules/is-relative": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-relative/-/is-relative-1.0.0.tgz", + "integrity": "sha512-Kw/ReK0iqwKeu0MITLFuj0jbPAmEiOsIwyIXvvbfa6QfmN9pkD1M+8pdk7Rl/dTKbH34/XBFMbgD4iMJhLQbGA==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-unc-path": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } }, - "longest": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", - "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", - "dev": true + "node_modules/is-unc-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-unc-path/-/is-unc-path-1.0.0.tgz", + "integrity": "sha512-mrGpVd0fs7WWLfVsStvgF6iEJnbjDFZh9/emhRDcGWTduTfNHd9CHeUwH3gYIjdbwo4On6hunkztwOaAw0yllQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "unc-path-regex": "^0.1.2" + }, + "engines": { + "node": ">=0.10.0" + } }, - "loud-rejection": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/loud-rejection/-/loud-rejection-1.6.0.tgz", - "integrity": "sha1-W0b4AUft7leIcPCG0Eghz5mOVR8=", + "node_modules/is-windows": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", + "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", "dev": true, - "requires": { - "currently-unhandled": "^0.4.1", - "signal-exit": "^3.0.0" + "license": "MIT", + "engines": { + "node": ">=0.10.0" } }, - "lru-cache": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", - "integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=", - "dev": true + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, + "license": "ISC" }, - "map-obj": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", - "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=", - "dev": true + "node_modules/isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } }, - "markdown-it": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-10.0.0.tgz", - "integrity": "sha512-YWOP1j7UbDNz+TumYP1kpwnP0aEa711cJjrAQrzd0UXlbJfc5aAq0F/PZHjiioqDC1NKgvIMX+o+9Bk7yuM2dg==", + "node_modules/js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", "dev": true, - "requires": { + "license": "MIT", + "dependencies": { "argparse": "^1.0.7", - "entities": "~2.0.0", - "linkify-it": "^2.0.0", - "mdurl": "^1.0.1", - "uc.micro": "^1.0.5" + "esprima": "^4.0.0" }, - "dependencies": { - "argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dev": true, - "requires": { - "sprintf-js": "~1.0.2" - } - } - } - }, - "markdown-it-anchor": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/markdown-it-anchor/-/markdown-it-anchor-5.3.0.tgz", - "integrity": "sha512-/V1MnLL/rgJ3jkMWo84UR+K+jF1cxNG1a+KwqeXqTIJ+jtA8aWSHuigx8lTzauiIjBDbwF3NcWQMotd0Dm39jA==", - "dev": true - }, - "marked": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/marked/-/marked-1.1.0.tgz", - "integrity": "sha512-EkE7RW6KcXfMHy2PA7Jg0YJE1l8UPEZE8k45tylzmZM30/r1M1MUXWQfJlrSbsTeh7m/XTwHbWUENvAJZpp1YA==", - "dev": true + "bin": { + "js-yaml": "bin/js-yaml.js" + } }, - "maxmin": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/maxmin/-/maxmin-1.1.0.tgz", - "integrity": "sha1-cTZehKmd2Piz99X94vANHn9zvmE=", - "dev": true, - "requires": { - "chalk": "^1.0.0", - "figures": "^1.0.1", - "gzip-size": "^1.0.0", - "pretty-bytes": "^1.0.0" - }, - "dependencies": { - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true - }, - "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" - } - }, - "has-ansi": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - }, - "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - } - } - }, - "mdurl": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz", - "integrity": "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=", - "dev": true - }, - "meow": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz", - "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=", - "dev": true, - "requires": { - "camelcase-keys": "^2.0.0", - "decamelize": "^1.1.2", - "loud-rejection": "^1.0.0", - "map-obj": "^1.0.1", - "minimist": "^1.1.3", - "normalize-package-data": "^2.3.4", - "object-assign": "^4.0.1", - "read-pkg-up": "^1.0.1", - "redent": "^1.0.0", - "trim-newlines": "^1.0.0" - } - }, - "minimatch": { - "version": "0.2.14", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.2.14.tgz", - "integrity": "sha1-x054BXT2PG+aCQ6Q775u9TpqdWo=", - "dev": true, - "requires": { - "lru-cache": "2", - "sigmund": "~1.0.0" - } - }, - "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "dev": true - }, - "mkdirp": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", - "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", - "dev": true - }, - "nopt": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", - "integrity": "sha1-bd0hvSoxQXuScn3Vhfim83YI6+4=", + "node_modules/kind-of": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", "dev": true, - "requires": { - "abbrev": "1" + "license": "MIT", + "engines": { + "node": ">=0.10.0" } }, - "normalize-package-data": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", - "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "node_modules/liftup": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/liftup/-/liftup-3.0.1.tgz", + "integrity": "sha512-yRHaiQDizWSzoXk3APcA71eOI/UuhEkNN9DiW2Tt44mhYzX4joFoCZlxsSOF7RyeLlfqzFLQI1ngFq3ggMPhOw==", "dev": true, - "requires": { - "hosted-git-info": "^2.1.4", - "resolve": "^1.10.0", - "semver": "2 || 3 || 4 || 5", - "validate-npm-package-license": "^3.0.1" + "license": "MIT", + "dependencies": { + "extend": "^3.0.2", + "findup-sync": "^4.0.0", + "fined": "^1.2.0", + "flagged-respawn": "^1.0.1", + "is-plain-object": "^2.0.4", + "object.map": "^1.0.1", + "rechoir": "^0.7.0", + "resolve": "^1.19.0" + }, + "engines": { + "node": ">=10" } }, - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true + "node_modules/liftup/node_modules/findup-sync": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-4.0.0.tgz", + "integrity": "sha512-6jvvn/12IC4quLBL1KNokxC7wWTvYncaVUYSoxWw7YykPLuRrnv4qdHcSOywOI5RpkOVGeQRtWM8/q+G6W6qfQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "detect-file": "^1.0.0", + "is-glob": "^4.0.0", + "micromatch": "^4.0.2", + "resolve-dir": "^1.0.1" + }, + "engines": { + "node": ">= 8" + } }, - "pako": { - "version": "0.2.9", - "resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz", - "integrity": "sha1-8/dSL073gjSNqBYbrZ7P1Rv4OnU=", - "dev": true + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true, + "license": "MIT" }, - "parse-json": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", - "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "node_modules/make-iterator": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/make-iterator/-/make-iterator-1.0.1.tgz", + "integrity": "sha512-pxiuXh0iVEq7VM7KMIhs5gxsfxCux2URptUQaXo4iZZJxBAzTPOLE2BumO5dbfVYq/hBJFBR/a1mFDmOx5AGmw==", "dev": true, - "requires": { - "error-ex": "^1.2.0" + "license": "MIT", + "dependencies": { + "kind-of": "^6.0.2" + }, + "engines": { + "node": ">=0.10.0" } }, - "path-exists": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", - "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", + "node_modules/map-cache": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", + "integrity": "sha512-8y/eV9QQZCiyn1SprXSrCmqJN0yNRATe+PO8ztwqrvrbdRLA3eYJF0yaR0YayLWkMbsQSKWS9N2gPcGEc4UsZg==", "dev": true, - "requires": { - "pinkie-promise": "^2.0.0" + "license": "MIT", + "engines": { + "node": ">=0.10.0" } }, - "path-parse": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", - "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", - "dev": true - }, - "path-type": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", - "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", + "node_modules/maxmin": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/maxmin/-/maxmin-3.0.0.tgz", + "integrity": "sha512-wcahMInmGtg/7c6a75fr21Ch/Ks1Tb+Jtoan5Ft4bAI0ZvJqyOw8kkM7e7p8hDSzY805vmxwHT50KcjGwKyJ0g==", "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0" - }, + "license": "MIT", "dependencies": { - "graceful-fs": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz", - "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==", - "dev": true - } + "chalk": "^4.1.0", + "figures": "^3.2.0", + "gzip-size": "^5.1.1", + "pretty-bytes": "^5.3.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true - }, - "pinkie": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", - "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", - "dev": true - }, - "pinkie-promise": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", - "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "node_modules/micromatch": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "dev": true, - "requires": { - "pinkie": "^2.0.0" + "license": "MIT", + "dependencies": { + "braces": "^3.0.3", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" } }, - "pretty-bytes": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-1.0.4.tgz", - "integrity": "sha1-CiLoIQYJrTVUL4yNXSFZr/B1HIQ=", + "node_modules/minimatch": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.8.tgz", + "integrity": "sha512-6FsRAQsxQ61mw+qP1ZzbL9Bc78x2p5OqNgNpnoAFLTrX8n5Kxph0CsnhmKKNXTWjXqU5L0pGPR7hYk+XWZr60Q==", "dev": true, - "requires": { - "get-stdin": "^4.0.1", - "meow": "^3.1.0" + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" } }, - "process-nextick-args": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", - "dev": true + "node_modules/nopt": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", + "integrity": "sha512-4GUt3kSEYmk4ITxzB/b9vaIDfUVWN/Ml1Fwl11IlnIG2iaJ9O6WXZ9SrYM9NLI8OCBieN2Y8SWC2oJV0RQ7qYg==", + "dev": true, + "license": "ISC", + "dependencies": { + "abbrev": "1" + }, + "bin": { + "nopt": "bin/nopt.js" + } }, - "read-pkg": { + "node_modules/object.defaults": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", - "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", + "resolved": "https://registry.npmjs.org/object.defaults/-/object.defaults-1.1.0.tgz", + "integrity": "sha512-c/K0mw/F11k4dEUBMW8naXUuBuhxRCfG7W+yFy8EcijU/rSmazOUd1XAEEe6bC0OuXY4HUKjTJv7xbxIMqdxrA==", "dev": true, - "requires": { - "load-json-file": "^1.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^1.0.0" + "license": "MIT", + "dependencies": { + "array-each": "^1.0.1", + "array-slice": "^1.0.0", + "for-own": "^1.0.0", + "isobject": "^3.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "read-pkg-up": { + "node_modules/object.map": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", - "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", + "resolved": "https://registry.npmjs.org/object.map/-/object.map-1.0.1.tgz", + "integrity": "sha512-3+mAJu2PLfnSVGHwIWubpOFLscJANBKuB/6A4CxBstc4aqwQY0FWcsppuy4jU5GSB95yES5JHSI+33AWuS4k6w==", "dev": true, - "requires": { - "find-up": "^1.0.0", - "read-pkg": "^1.0.0" + "license": "MIT", + "dependencies": { + "for-own": "^1.0.0", + "make-iterator": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "node_modules/object.pick": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", + "integrity": "sha512-tqa/UMy/CCoYmj+H5qc07qvSL9dqcs/WZENZ1JbtWBlATP+iVOe778gE6MSijnyCnORzDuX6hU+LA4SZ09YjFQ==", "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" + "license": "MIT", + "dependencies": { + "isobject": "^3.0.1" + }, + "engines": { + "node": ">=0.10.0" } }, - "redent": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/redent/-/redent-1.0.0.tgz", - "integrity": "sha1-z5Fqsf1fHxbfsggi3W7H9zDCr94=", + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", "dev": true, - "requires": { - "indent-string": "^2.1.0", - "strip-indent": "^1.0.1" + "license": "ISC", + "dependencies": { + "wrappy": "1" } }, - "repeat-string": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", - "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", - "dev": true + "node_modules/os-homedir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "integrity": "sha512-B5JU3cabzk8c67mRRd3ECmROafjYMXbuzlwtqdM8IbS8ktlTix8aFGb2bAGKrSRIlnfKwovGUUr72JUPyOb6kQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } }, - "repeating": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz", - "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", + "node_modules/os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==", "dev": true, - "requires": { - "is-finite": "^1.0.0" + "license": "MIT", + "engines": { + "node": ">=0.10.0" } }, - "requizzle": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/requizzle/-/requizzle-0.2.3.tgz", - "integrity": "sha512-YanoyJjykPxGHii0fZP0uUPEXpvqfBDxWV7s6GKAiiOsiqhX6vHNyW3Qzdmqp/iq/ExbhaGbVrjB4ruEVSM4GQ==", + "node_modules/osenv": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz", + "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", + "deprecated": "This package is no longer supported.", "dev": true, - "requires": { - "lodash": "^4.17.14" - }, + "license": "ISC", "dependencies": { - "lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", - "dev": true - } + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.0" } }, - "resolve": { - "version": "1.17.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", - "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", + "node_modules/parse-filepath": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/parse-filepath/-/parse-filepath-1.0.2.tgz", + "integrity": "sha512-FwdRXKCohSVeXqwtYonZTXtbGJKrn+HNyWDYVcp5yuJlesTwNH4rsmRZ+GrKAPJ5bLpRxESMeS+Rl0VCHRvB2Q==", "dev": true, - "requires": { - "path-parse": "^1.0.6" + "license": "MIT", + "dependencies": { + "is-absolute": "^1.0.0", + "map-cache": "^0.2.0", + "path-root": "^0.1.1" + }, + "engines": { + "node": ">=0.8" } }, - "right-align": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", - "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=", + "node_modules/parse-passwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", + "integrity": "sha512-1Y1A//QUXEZK7YKz+rD9WydcE1+EuPr6ZBgKecAB8tmoW6UFv0NREVJe1p+jRxtThkcbbKkfwIbWJe/IeE6m2Q==", "dev": true, - "requires": { - "align-text": "^0.1.1" + "license": "MIT", + "engines": { + "node": ">=0.10.0" } }, - "rimraf": { - "version": "2.2.8", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz", - "integrity": "sha1-5Dm+Kq7jJzIZUnMPmaiSnk/FBYI=", - "dev": true - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true - }, - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true - }, - "sigmund": { + "node_modules/path-is-absolute": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", - "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=", - "dev": true + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } }, - "signal-exit": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", - "integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==", - "dev": true + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true, + "license": "MIT" }, - "source-map": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.3.0.tgz", - "integrity": "sha1-hYb7mloAXltQHiHNGLbyG0V60fk=", + "node_modules/path-root": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/path-root/-/path-root-0.1.1.tgz", + "integrity": "sha512-QLcPegTHF11axjfojBIoDygmS2E3Lf+8+jI6wOVmNVenrKSo3mFdSGiIgdSHenczw3wPtlVMQaFVwGmM7BJdtg==", "dev": true, - "requires": { - "amdefine": ">=0.0.4" + "license": "MIT", + "dependencies": { + "path-root-regex": "^0.1.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "spdx-correct": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.1.tgz", - "integrity": "sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w==", + "node_modules/path-root-regex": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/path-root-regex/-/path-root-regex-0.1.2.tgz", + "integrity": "sha512-4GlJ6rZDhQZFE0DPVKh0e9jmZ5egZfxTkp7bcRDuPlJXbAwhxcl2dINPUAsjLdejqaLsCeg8axcLjIbvBjN4pQ==", "dev": true, - "requires": { - "spdx-expression-parse": "^3.0.0", - "spdx-license-ids": "^3.0.0" + "license": "MIT", + "engines": { + "node": ">=0.10.0" } }, - "spdx-exceptions": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz", - "integrity": "sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A==", - "dev": true - }, - "spdx-expression-parse": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz", - "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==", + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", "dev": true, - "requires": { - "spdx-exceptions": "^2.1.0", - "spdx-license-ids": "^3.0.0" + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" } }, - "spdx-license-ids": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.5.tgz", - "integrity": "sha512-J+FWzZoynJEXGphVIS+XEh3kFSjZX/1i9gFBaWQcB+/tmpe2qUsSBABpcxqxnAxFdiUFEgAX1bjYGQvIZmoz9Q==", - "dev": true - }, - "sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", - "dev": true + "node_modules/pify": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", + "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "node_modules/pretty-bytes": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.6.0.tgz", + "integrity": "sha512-FFw039TmrBqFK8ma/7OL3sDz/VytdtJr044/QUJtH0wK9lb9jLq9tJyIxUwtQJHwar2BqtiA4iCWSwo9JLkzFg==", "dev": true, - "requires": { - "safe-buffer": "~5.1.0" + "license": "MIT", + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "strip-ansi": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.3.0.tgz", - "integrity": "sha1-JfSOoiynkYfzF0pNuHWTR7sSYiA=", + "node_modules/rechoir": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.7.1.tgz", + "integrity": "sha512-/njmZ8s1wVeR6pjTZ+0nCnv8SpZNRMT2D1RLOJQESlYFDBvwpTA4KWJpZ+sBJ4+vhjILRcK7JIFdGCdxEAAitg==", "dev": true, - "requires": { - "ansi-regex": "^0.2.1" + "license": "MIT", + "dependencies": { + "resolve": "^1.9.0" + }, + "engines": { + "node": ">= 0.10" } }, - "strip-bom": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", - "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", + "node_modules/resolve": { + "version": "1.22.10", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.10.tgz", + "integrity": "sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w==", "dev": true, - "requires": { - "is-utf8": "^0.2.0" + "license": "MIT", + "dependencies": { + "is-core-module": "^2.16.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "strip-indent": { + "node_modules/resolve-dir": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-1.0.1.tgz", - "integrity": "sha1-DHlipq3vp7vUrDZkYKY4VSrhoKI=", + "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-1.0.1.tgz", + "integrity": "sha512-R7uiTjECzvOsWSfdM0QKFNBVFcK27aHOUwdvK53BcW8zqnGdYp0Fbj82cy54+2A4P2tFM22J5kRfe1R+lM/1yg==", "dev": true, - "requires": { - "get-stdin": "^4.0.1" + "license": "MIT", + "dependencies": { + "expand-tilde": "^2.0.0", + "global-modules": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "strip-json-comments": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.0.tgz", - "integrity": "sha512-e6/d0eBu7gHtdCqFt0xJr642LdToM5/cN4Qb9DbHjVx1CP5RyeM+zH7pbecEmDv/lBqb0QH+6Uqq75rxFPkM0w==", - "dev": true + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true, + "license": "MIT" }, - "supports-color": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-0.2.0.tgz", - "integrity": "sha1-2S3iaU6z9nMjlz1649i1W0wiGQo=", - "dev": true + "node_modules/source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } }, - "taffydb": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/taffydb/-/taffydb-2.6.2.tgz", - "integrity": "sha1-fLy2S1oUG2ou/CxdLGe04VCyomg=", - "dev": true + "node_modules/sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", + "dev": true, + "license": "BSD-3-Clause" }, - "three": { - "version": "0.118.3", - "resolved": "https://registry.npmjs.org/three/-/three-0.118.3.tgz", - "integrity": "sha512-ijECXrNzDkHieoeh2H69kgawTGH8DiamhR4uBN8jEM7VHSKvfTdEvOoHsA8Aq7dh7PHAxhlqBsN5arBI3KixSw==" + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } }, - "trim-newlines": { + "node_modules/supports-preserve-symlinks-flag": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz", - "integrity": "sha1-WIeWa7WCpFA6QetST301ARgVphM=", - "dev": true + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } }, - "typedarray": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", - "dev": true + "node_modules/three": { + "version": "0.173.0", + "resolved": "https://registry.npmjs.org/three/-/three-0.173.0.tgz", + "integrity": "sha512-AUwVmViIEUgBwxJJ7stnF0NkPpZxx1aZ6WiAbQ/Qq61h6I9UR4grXtZDmO8mnlaNORhHnIBlXJ1uBxILEKuVyw==", + "license": "MIT" }, - "uc.micro": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz", - "integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==", - "dev": true + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } }, - "uglify-js": { - "version": "2.8.29", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz", - "integrity": "sha1-KcVzMUgFe7Th913zW3qcty5qWd0=", + "node_modules/uglify-js": { + "version": "3.19.3", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.3.tgz", + "integrity": "sha512-v3Xu+yuwBXisp6QYTcH4UbH+xYJXqnq2m/LtQVWKWzYc1iehYnLixoQDN9FH6/j9/oybfd6W9Ghwkl8+UMKTKQ==", "dev": true, - "requires": { - "source-map": "~0.5.1", - "uglify-to-browserify": "~1.0.0", - "yargs": "~3.10.0" + "license": "BSD-2-Clause", + "bin": { + "uglifyjs": "bin/uglifyjs" }, - "dependencies": { - "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true - } + "engines": { + "node": ">=0.8.0" } }, - "uglify-to-browserify": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", - "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=", + "node_modules/unc-path-regex": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz", + "integrity": "sha512-eXL4nmJT7oCpkZsHZUOJo8hcX3GbsiDOa0Qu9F646fi8dT3XuSVopVqAcEiVzSKKH7UoDti23wNX3qGFxcW5Qg==", "dev": true, - "optional": true + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } }, - "underscore": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.7.0.tgz", - "integrity": "sha1-a7rwh3UA02vjTsqlhODbn+8DUgk=", - "dev": true + "node_modules/underscore.string": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-3.3.6.tgz", + "integrity": "sha512-VoC83HWXmCrF6rgkyxS9GHv8W9Q5nhMKho+OadDJGzL2oDYbYEppBaCMH6pFlwLeqj2QS+hhkw2kpXkSdD1JxQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "sprintf-js": "^1.1.1", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": "*" + } }, - "underscore.string": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-2.2.1.tgz", - "integrity": "sha1-18D6KvXVoaZ/QlPa7pgTLnM/Dxk=", - "dev": true + "node_modules/underscore.string/node_modules/sprintf-js": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz", + "integrity": "sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==", + "dev": true, + "license": "BSD-3-Clause" }, - "universalify": { + "node_modules/uri-path": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-1.0.0.tgz", - "integrity": "sha512-rb6X1W158d7pRQBg5gkR8uPaSfiids68LTJQYOtEUhoJUWBdaQHsuT/EUduxXYxcrt4r5PJ4fuHW1MHT6p0qug==", - "dev": true - }, - "uri-path": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/uri-path/-/uri-path-0.0.2.tgz", - "integrity": "sha1-gD6wHy/rF5J9zOD2GH5yt19T9VQ=", - "dev": true + "resolved": "https://registry.npmjs.org/uri-path/-/uri-path-1.0.0.tgz", + "integrity": "sha512-8pMuAn4KacYdGMkFaoQARicp4HSw24/DHOVKWqVRJ8LhhAwPPFpdGvdL9184JVmUwe7vz7Z9n6IqI6t5n2ELdg==", + "dev": true, + "license": "WTFPL OR MIT", + "engines": { + "node": ">= 0.10" + } }, - "util-deprecate": { + "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true - }, - "validate-npm-package-license": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", - "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", - "dev": true, - "requires": { - "spdx-correct": "^3.0.0", - "spdx-expression-parse": "^3.0.0" - } - }, - "which": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/which/-/which-1.0.9.tgz", - "integrity": "sha1-RgwdoPgQED0DIam2M6+eV15kSG8=", - "dev": true - }, - "window-size": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", - "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", - "dev": true - }, - "wordwrap": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", - "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", - "dev": true - }, - "xmlcreate": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-2.0.3.tgz", - "integrity": "sha512-HgS+X6zAztGa9zIK3Y3LXuJes33Lz9x+YyTxgrkIdabu2vqcGOWwdfCpf1hWLRrd553wd4QCDf6BBO6FfdsRiQ==", - "dev": true - }, - "yargs": { - "version": "3.10.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", - "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", - "dev": true, - "requires": { - "camelcase": "^1.0.2", - "cliui": "^2.1.0", - "decamelize": "^1.0.0", - "window-size": "0.1.0" + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true, + "license": "MIT" + }, + "node_modules/v8flags": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.2.0.tgz", + "integrity": "sha512-mH8etigqMfiGWdeXpaaqGfs6BndypxusHHcv2qSHyZkGEznCd/qAXCWWRzeowtL54147cktFOC4P5y+kl8d8Jg==", + "dev": true, + "license": "MIT", + "dependencies": { + "homedir-polyfill": "^1.0.1" }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "license": "ISC", "dependencies": { - "camelcase": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", - "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", - "dev": true - } + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true, + "license": "ISC" } } } diff --git a/package.json b/package.json index d065c5e..8b6e02d 100644 --- a/package.json +++ b/package.json @@ -22,11 +22,9 @@ "spe" ], "devDependencies": { - "grunt": "^0.4.5", - "grunt-contrib-concat": "^0.5.1", - "grunt-contrib-uglify": "^0.9.2", - "grunt-docco2": "^0.2.1", - "grunt-jsdoc": "^1.0.0" + "grunt": "^1.6.1", + "grunt-contrib-concat": "^2.1.0", + "grunt-contrib-uglify": "^5.2.1" }, "scripts": { "test": "grunt", @@ -38,6 +36,6 @@ "example": "examples" }, "dependencies": { - "three": "^0.118.3" + "three": "^0.173.0" } } diff --git a/src/core/SPE.Emitter.js b/src/core/SPE.Emitter.js index c9eba34..c843dd8 100644 --- a/src/core/SPE.Emitter.js +++ b/src/core/SPE.Emitter.js @@ -149,132 +149,127 @@ * * @param {EmitterOptions} options A map of options to configure the emitter. */ -SPE.Emitter = function( options ) { - 'use strict'; +SPE.Emitter = function (options) { + "use strict"; - var utils = SPE.utils, - types = utils.types, - lifetimeLength = SPE.valueOverLifetimeLength; + let utils = SPE.utils; + let types = utils.types; + let lifetimeLength = SPE.valueOverLifetimeLength; // Ensure we have a map of options to play with, // and that each option is in the correct format. - options = utils.ensureTypedArg( options, types.OBJECT, {} ); - options.position = utils.ensureTypedArg( options.position, types.OBJECT, {} ); - options.velocity = utils.ensureTypedArg( options.velocity, types.OBJECT, {} ); - options.acceleration = utils.ensureTypedArg( options.acceleration, types.OBJECT, {} ); - options.radius = utils.ensureTypedArg( options.radius, types.OBJECT, {} ); - options.drag = utils.ensureTypedArg( options.drag, types.OBJECT, {} ); - options.rotation = utils.ensureTypedArg( options.rotation, types.OBJECT, {} ); - options.color = utils.ensureTypedArg( options.color, types.OBJECT, {} ); - options.opacity = utils.ensureTypedArg( options.opacity, types.OBJECT, {} ); - options.size = utils.ensureTypedArg( options.size, types.OBJECT, {} ); - options.angle = utils.ensureTypedArg( options.angle, types.OBJECT, {} ); - options.wiggle = utils.ensureTypedArg( options.wiggle, types.OBJECT, {} ); - options.maxAge = utils.ensureTypedArg( options.maxAge, types.OBJECT, {} ); - - if ( options.onParticleSpawn ) { - console.warn( 'onParticleSpawn has been removed. Please set properties directly to alter values at runtime.' ); + options = utils.ensureTypedArg(options, types.OBJECT, {}); + options.position = utils.ensureTypedArg(options.position, types.OBJECT, {}); + options.velocity = utils.ensureTypedArg(options.velocity, types.OBJECT, {}); + options.acceleration = utils.ensureTypedArg(options.acceleration, types.OBJECT, {}); + options.radius = utils.ensureTypedArg(options.radius, types.OBJECT, {}); + options.drag = utils.ensureTypedArg(options.drag, types.OBJECT, {}); + options.rotation = utils.ensureTypedArg(options.rotation, types.OBJECT, {}); + options.color = utils.ensureTypedArg(options.color, types.OBJECT, {}); + options.opacity = utils.ensureTypedArg(options.opacity, types.OBJECT, {}); + options.size = utils.ensureTypedArg(options.size, types.OBJECT, {}); + options.angle = utils.ensureTypedArg(options.angle, types.OBJECT, {}); + options.wiggle = utils.ensureTypedArg(options.wiggle, types.OBJECT, {}); + options.maxAge = utils.ensureTypedArg(options.maxAge, types.OBJECT, {}); + + if (options.onParticleSpawn) { + console.warn("onParticleSpawn has been removed. Please set properties directly to alter values at runtime."); } - this.uuid = THREE.Math.generateUUID(); + this.uuid = SPE.utils.generateUUID(); - this.type = utils.ensureTypedArg( options.type, types.NUMBER, SPE.distributions.BOX ); + this.type = utils.ensureTypedArg(options.type, types.NUMBER, SPE.distributions.BOX); // Start assigning properties...kicking it off with props that DON'T support values over // lifetimes. // // Btw, values over lifetimes are just the new way of referring to *Start, *Middle, and *End. this.position = { - _value: utils.ensureInstanceOf( options.position.value, THREE.Vector3, new THREE.Vector3() ), - _spread: utils.ensureInstanceOf( options.position.spread, THREE.Vector3, new THREE.Vector3() ), - _spreadClamp: utils.ensureInstanceOf( options.position.spreadClamp, THREE.Vector3, new THREE.Vector3() ), - _distribution: utils.ensureTypedArg( options.position.distribution, types.NUMBER, this.type ), - _randomise: utils.ensureTypedArg( options.position.randomise, types.BOOLEAN, false ), - _radius: utils.ensureTypedArg( options.position.radius, types.NUMBER, 10 ), - _radiusScale: utils.ensureInstanceOf( options.position.radiusScale, THREE.Vector3, new THREE.Vector3( 1, 1, 1 ) ), - _distributionClamp: utils.ensureTypedArg( options.position.distributionClamp, types.NUMBER, 0 ), + _value: utils.ensureInstanceOf(options.position.value, THREE.Vector3, new THREE.Vector3()), + _spread: utils.ensureInstanceOf(options.position.spread, THREE.Vector3, new THREE.Vector3()), + _spreadClamp: utils.ensureInstanceOf(options.position.spreadClamp, THREE.Vector3, new THREE.Vector3()), + _distribution: utils.ensureTypedArg(options.position.distribution, types.NUMBER, this.type), + _randomise: utils.ensureTypedArg(options.position.randomise, types.BOOLEAN, false), + _radius: utils.ensureTypedArg(options.position.radius, types.NUMBER, 10), + _radiusScale: utils.ensureInstanceOf(options.position.radiusScale, THREE.Vector3, new THREE.Vector3(1, 1, 1)), + _distributionClamp: utils.ensureTypedArg(options.position.distributionClamp, types.NUMBER, 0), }; this.velocity = { - _value: utils.ensureInstanceOf( options.velocity.value, THREE.Vector3, new THREE.Vector3() ), - _spread: utils.ensureInstanceOf( options.velocity.spread, THREE.Vector3, new THREE.Vector3() ), - _distribution: utils.ensureTypedArg( options.velocity.distribution, types.NUMBER, this.type ), - _randomise: utils.ensureTypedArg( options.position.randomise, types.BOOLEAN, false ) + _value: utils.ensureInstanceOf(options.velocity.value, THREE.Vector3, new THREE.Vector3()), + _spread: utils.ensureInstanceOf(options.velocity.spread, THREE.Vector3, new THREE.Vector3()), + _distribution: utils.ensureTypedArg(options.velocity.distribution, types.NUMBER, this.type), + _randomise: utils.ensureTypedArg(options.position.randomise, types.BOOLEAN, false), }; this.acceleration = { - _value: utils.ensureInstanceOf( options.acceleration.value, THREE.Vector3, new THREE.Vector3() ), - _spread: utils.ensureInstanceOf( options.acceleration.spread, THREE.Vector3, new THREE.Vector3() ), - _distribution: utils.ensureTypedArg( options.acceleration.distribution, types.NUMBER, this.type ), - _randomise: utils.ensureTypedArg( options.position.randomise, types.BOOLEAN, false ) + _value: utils.ensureInstanceOf(options.acceleration.value, THREE.Vector3, new THREE.Vector3()), + _spread: utils.ensureInstanceOf(options.acceleration.spread, THREE.Vector3, new THREE.Vector3()), + _distribution: utils.ensureTypedArg(options.acceleration.distribution, types.NUMBER, this.type), + _randomise: utils.ensureTypedArg(options.position.randomise, types.BOOLEAN, false), }; this.drag = { - _value: utils.ensureTypedArg( options.drag.value, types.NUMBER, 0 ), - _spread: utils.ensureTypedArg( options.drag.spread, types.NUMBER, 0 ), - _randomise: utils.ensureTypedArg( options.position.randomise, types.BOOLEAN, false ) + _value: utils.ensureTypedArg(options.drag.value, types.NUMBER, 0), + _spread: utils.ensureTypedArg(options.drag.spread, types.NUMBER, 0), + _randomise: utils.ensureTypedArg(options.position.randomise, types.BOOLEAN, false), }; this.wiggle = { - _value: utils.ensureTypedArg( options.wiggle.value, types.NUMBER, 0 ), - _spread: utils.ensureTypedArg( options.wiggle.spread, types.NUMBER, 0 ) + _value: utils.ensureTypedArg(options.wiggle.value, types.NUMBER, 0), + _spread: utils.ensureTypedArg(options.wiggle.spread, types.NUMBER, 0), }; this.rotation = { - _axis: utils.ensureInstanceOf( options.rotation.axis, THREE.Vector3, new THREE.Vector3( 0.0, 1.0, 0.0 ) ), - _axisSpread: utils.ensureInstanceOf( options.rotation.axisSpread, THREE.Vector3, new THREE.Vector3() ), - _angle: utils.ensureTypedArg( options.rotation.angle, types.NUMBER, 0 ), - _angleSpread: utils.ensureTypedArg( options.rotation.angleSpread, types.NUMBER, 0 ), - _static: utils.ensureTypedArg( options.rotation.static, types.BOOLEAN, false ), - _center: utils.ensureInstanceOf( options.rotation.center, THREE.Vector3, this.position._value.clone() ), - _randomise: utils.ensureTypedArg( options.position.randomise, types.BOOLEAN, false ) + _axis: utils.ensureInstanceOf(options.rotation.axis, THREE.Vector3, new THREE.Vector3(0.0, 1.0, 0.0)), + _axisSpread: utils.ensureInstanceOf(options.rotation.axisSpread, THREE.Vector3, new THREE.Vector3()), + _angle: utils.ensureTypedArg(options.rotation.angle, types.NUMBER, 0), + _angleSpread: utils.ensureTypedArg(options.rotation.angleSpread, types.NUMBER, 0), + _static: utils.ensureTypedArg(options.rotation.static, types.BOOLEAN, false), + _center: utils.ensureInstanceOf(options.rotation.center, THREE.Vector3, this.position._value.clone()), + _randomise: utils.ensureTypedArg(options.position.randomise, types.BOOLEAN, false), }; - this.maxAge = { - _value: utils.ensureTypedArg( options.maxAge.value, types.NUMBER, 2 ), - _spread: utils.ensureTypedArg( options.maxAge.spread, types.NUMBER, 0 ) + _value: utils.ensureTypedArg(options.maxAge.value, types.NUMBER, 2), + _spread: utils.ensureTypedArg(options.maxAge.spread, types.NUMBER, 0), }; - - // The following properties can support either single values, or an array of values that change // the property over a particle's lifetime (value over lifetime). this.color = { - _value: utils.ensureArrayInstanceOf( options.color.value, THREE.Color, new THREE.Color() ), - _spread: utils.ensureArrayInstanceOf( options.color.spread, THREE.Vector3, new THREE.Vector3() ), - _randomise: utils.ensureTypedArg( options.position.randomise, types.BOOLEAN, false ) + _value: utils.ensureArrayInstanceOf(options.color.value, THREE.Color, new THREE.Color()), + _spread: utils.ensureArrayInstanceOf(options.color.spread, THREE.Vector3, new THREE.Vector3()), + _randomise: utils.ensureTypedArg(options.position.randomise, types.BOOLEAN, false), }; this.opacity = { - _value: utils.ensureArrayTypedArg( options.opacity.value, types.NUMBER, 1 ), - _spread: utils.ensureArrayTypedArg( options.opacity.spread, types.NUMBER, 0 ), - _randomise: utils.ensureTypedArg( options.position.randomise, types.BOOLEAN, false ) + _value: utils.ensureArrayTypedArg(options.opacity.value, types.NUMBER, 1), + _spread: utils.ensureArrayTypedArg(options.opacity.spread, types.NUMBER, 0), + _randomise: utils.ensureTypedArg(options.position.randomise, types.BOOLEAN, false), }; this.size = { - _value: utils.ensureArrayTypedArg( options.size.value, types.NUMBER, 1 ), - _spread: utils.ensureArrayTypedArg( options.size.spread, types.NUMBER, 0 ), - _randomise: utils.ensureTypedArg( options.position.randomise, types.BOOLEAN, false ) + _value: utils.ensureArrayTypedArg(options.size.value, types.NUMBER, 1), + _spread: utils.ensureArrayTypedArg(options.size.spread, types.NUMBER, 0), + _randomise: utils.ensureTypedArg(options.position.randomise, types.BOOLEAN, false), }; this.angle = { - _value: utils.ensureArrayTypedArg( options.angle.value, types.NUMBER, 0 ), - _spread: utils.ensureArrayTypedArg( options.angle.spread, types.NUMBER, 0 ), - _randomise: utils.ensureTypedArg( options.position.randomise, types.BOOLEAN, false ) + _value: utils.ensureArrayTypedArg(options.angle.value, types.NUMBER, 0), + _spread: utils.ensureArrayTypedArg(options.angle.spread, types.NUMBER, 0), + _randomise: utils.ensureTypedArg(options.position.randomise, types.BOOLEAN, false), }; - // Assign renaining option values. - this.particleCount = utils.ensureTypedArg( options.particleCount, types.NUMBER, 100 ); - this.duration = utils.ensureTypedArg( options.duration, types.NUMBER, null ); - this.isStatic = utils.ensureTypedArg( options.isStatic, types.BOOLEAN, false ); - this.activeMultiplier = utils.ensureTypedArg( options.activeMultiplier, types.NUMBER, 1 ); - this.direction = utils.ensureTypedArg( options.direction, types.NUMBER, 1 ); + this.particleCount = utils.ensureTypedArg(options.particleCount, types.NUMBER, 100); + this.duration = utils.ensureTypedArg(options.duration, types.NUMBER, null); + this.isStatic = utils.ensureTypedArg(options.isStatic, types.BOOLEAN, false); + this.activeMultiplier = utils.ensureTypedArg(options.activeMultiplier, types.NUMBER, 1); + this.direction = utils.ensureTypedArg(options.direction, types.NUMBER, 1); // Whether this emitter is alive or not. - this.alive = utils.ensureTypedArg( options.alive, types.BOOLEAN, true ); - + this.alive = utils.ensureTypedArg(options.alive, types.BOOLEAN, true); // The following properties are set internally and are not // user-controllable. @@ -291,8 +286,6 @@ SPE.Emitter = function( options ) { // The end of the range in the attribute buffers this.attributeEnd = 0; - - // Holds the time the emitter has been alive for. this.age = 0.0; @@ -326,17 +319,19 @@ SPE.Emitter = function( options ) { this.resetFlags = { // params: utils.ensureTypedArg( options.maxAge.randomise, types.BOOLEAN, !!options.maxAge.spread ) || // utils.ensureTypedArg( options.wiggle.randomise, types.BOOLEAN, !!options.wiggle.spread ), - position: utils.ensureTypedArg( options.position.randomise, types.BOOLEAN, false ) || - utils.ensureTypedArg( options.radius.randomise, types.BOOLEAN, false ), - velocity: utils.ensureTypedArg( options.velocity.randomise, types.BOOLEAN, false ), - acceleration: utils.ensureTypedArg( options.acceleration.randomise, types.BOOLEAN, false ) || - utils.ensureTypedArg( options.drag.randomise, types.BOOLEAN, false ), - rotation: utils.ensureTypedArg( options.rotation.randomise, types.BOOLEAN, false ), - rotationCenter: utils.ensureTypedArg( options.rotation.randomise, types.BOOLEAN, false ), - size: utils.ensureTypedArg( options.size.randomise, types.BOOLEAN, false ), - color: utils.ensureTypedArg( options.color.randomise, types.BOOLEAN, false ), - opacity: utils.ensureTypedArg( options.opacity.randomise, types.BOOLEAN, false ), - angle: utils.ensureTypedArg( options.angle.randomise, types.BOOLEAN, false ) + position: + utils.ensureTypedArg(options.position.randomise, types.BOOLEAN, false) || + utils.ensureTypedArg(options.radius.randomise, types.BOOLEAN, false), + velocity: utils.ensureTypedArg(options.velocity.randomise, types.BOOLEAN, false), + acceleration: + utils.ensureTypedArg(options.acceleration.randomise, types.BOOLEAN, false) || + utils.ensureTypedArg(options.drag.randomise, types.BOOLEAN, false), + rotation: utils.ensureTypedArg(options.rotation.randomise, types.BOOLEAN, false), + rotationCenter: utils.ensureTypedArg(options.rotation.randomise, types.BOOLEAN, false), + size: utils.ensureTypedArg(options.size.randomise, types.BOOLEAN, false), + color: utils.ensureTypedArg(options.color.randomise, types.BOOLEAN, false), + opacity: utils.ensureTypedArg(options.opacity.randomise, types.BOOLEAN, false), + angle: utils.ensureTypedArg(options.angle.randomise, types.BOOLEAN, false), }; this.updateFlags = {}; @@ -345,24 +340,24 @@ SPE.Emitter = function( options ) { // A map to indicate which emitter parameters should update // which attribute. this.updateMap = { - maxAge: 'params', - position: 'position', - velocity: 'velocity', - acceleration: 'acceleration', - drag: 'acceleration', - wiggle: 'params', - rotation: 'rotation', - size: 'size', - color: 'color', - opacity: 'opacity', - angle: 'angle' + maxAge: "params", + position: "position", + velocity: "velocity", + acceleration: "acceleration", + drag: "acceleration", + wiggle: "params", + rotation: "rotation", + size: "size", + color: "color", + opacity: "opacity", + angle: "angle", }; - for ( var i in this.updateMap ) { - if ( this.updateMap.hasOwnProperty( i ) ) { - this.updateCounts[ this.updateMap[ i ] ] = 0.0; - this.updateFlags[ this.updateMap[ i ] ] = false; - this._createGetterSetters( this[ i ], i ); + for (let i in this.updateMap) { + if (this.updateMap.hasOwnProperty(i)) { + this.updateCounts[this.updateMap[i]] = 0.0; + this.updateFlags[this.updateMap[i]] = false; + this._createGetterSetters(this[i], i); } } @@ -370,148 +365,141 @@ SPE.Emitter = function( options ) { this.attributeKeys = null; this.attributeCount = 0; - // Ensure that the value-over-lifetime property objects above // have value and spread properties that are of the same length. // // Also, for now, make sure they have a length of 3 (min/max arguments here). - utils.ensureValueOverLifetimeCompliance( this.color, lifetimeLength, lifetimeLength ); - utils.ensureValueOverLifetimeCompliance( this.opacity, lifetimeLength, lifetimeLength ); - utils.ensureValueOverLifetimeCompliance( this.size, lifetimeLength, lifetimeLength ); - utils.ensureValueOverLifetimeCompliance( this.angle, lifetimeLength, lifetimeLength ); + utils.ensureValueOverLifetimeCompliance(this.color, lifetimeLength, lifetimeLength); + utils.ensureValueOverLifetimeCompliance(this.opacity, lifetimeLength, lifetimeLength); + utils.ensureValueOverLifetimeCompliance(this.size, lifetimeLength, lifetimeLength); + utils.ensureValueOverLifetimeCompliance(this.angle, lifetimeLength, lifetimeLength); }; SPE.Emitter.constructor = SPE.Emitter; -SPE.Emitter.prototype._createGetterSetters = function( propObj, propName ) { - 'use strict'; +SPE.Emitter.prototype._createGetterSetters = function (propObj, propName) { + "use strict"; - var self = this; + let self = this; - for ( var i in propObj ) { - if ( propObj.hasOwnProperty( i ) ) { + for (let i in propObj) { + if (propObj.hasOwnProperty(i)) { + let name = i.replace("_", ""); - var name = i.replace( '_', '' ); - - Object.defineProperty( propObj, name, { - get: ( function( prop ) { - return function() { - return this[ prop ]; + Object.defineProperty(propObj, name, { + get: (function (prop) { + return function () { + return this[prop]; }; - }( i ) ), + })(i), - set: ( function( prop ) { - return function( value ) { - var mapName = self.updateMap[ propName ], - prevValue = this[ prop ], + set: (function (prop) { + return function (value) { + let mapName = self.updateMap[propName], + prevValue = this[prop], length = SPE.valueOverLifetimeLength; - if ( prop === '_rotationCenter' ) { + if (prop === "_rotationCenter") { self.updateFlags.rotationCenter = true; self.updateCounts.rotationCenter = 0.0; - } - else if ( prop === '_randomise' ) { - self.resetFlags[ mapName ] = value; - } - else { - self.updateFlags[ mapName ] = true; - self.updateCounts[ mapName ] = 0.0; + } else if (prop === "_randomise") { + self.resetFlags[mapName] = value; + } else { + self.updateFlags[mapName] = true; + self.updateCounts[mapName] = 0.0; } self.group._updateDefines(); - this[ prop ] = value; + this[prop] = value; // If the previous value was an array, then make // sure the provided value is interpolated correctly. - if ( Array.isArray( prevValue ) ) { - SPE.utils.ensureValueOverLifetimeCompliance( self[ propName ], length, length ); + if (Array.isArray(prevValue)) { + SPE.utils.ensureValueOverLifetimeCompliance(self[propName], length, length); } }; - }( i ) ) - } ); + })(i), + }); } } }; -SPE.Emitter.prototype._setBufferUpdateRanges = function( keys ) { - 'use strict'; +SPE.Emitter.prototype._setBufferUpdateRanges = function (keys) { + "use strict"; this.attributeKeys = keys; this.attributeCount = keys.length; - for ( var i = this.attributeCount - 1; i >= 0; --i ) { - this.bufferUpdateRanges[ keys[ i ] ] = { + for (let i = this.attributeCount - 1; i >= 0; --i) { + this.bufferUpdateRanges[keys[i]] = { min: Number.POSITIVE_INFINITY, - max: Number.NEGATIVE_INFINITY + max: Number.NEGATIVE_INFINITY, }; } }; -SPE.Emitter.prototype._calculatePPSValue = function( groupMaxAge ) { - 'use strict'; - - var particleCount = this.particleCount; +SPE.Emitter.prototype._calculatePPSValue = function (groupMaxAge) { + "use strict"; + let particleCount = this.particleCount; // Calculate the `particlesPerSecond` value for this emitter. It's used // when determining which particles should die and which should live to // see another day. Or be born, for that matter. The "God" property. - if ( this.duration ) { - this.particlesPerSecond = particleCount / ( groupMaxAge < this.duration ? groupMaxAge : this.duration ); - } - else { + if (this.duration) { + this.particlesPerSecond = particleCount / (groupMaxAge < this.duration ? groupMaxAge : this.duration); + } else { this.particlesPerSecond = particleCount / groupMaxAge; } }; -SPE.Emitter.prototype._setAttributeOffset = function( startIndex ) { +SPE.Emitter.prototype._setAttributeOffset = function (startIndex) { this.attributeOffset = startIndex; this.activationIndex = startIndex; this.activationEnd = startIndex + this.particleCount; }; +SPE.Emitter.prototype._assignValue = function (prop, index) { + "use strict"; -SPE.Emitter.prototype._assignValue = function( prop, index ) { - 'use strict'; - - switch ( prop ) { - case 'position': - this._assignPositionValue( index ); + switch (prop) { + case "position": + this._assignPositionValue(index); break; - case 'velocity': - case 'acceleration': - this._assignForceValue( index, prop ); + case "velocity": + case "acceleration": + this._assignForceValue(index, prop); break; - case 'size': - case 'opacity': - this._assignAbsLifetimeValue( index, prop ); + case "size": + case "opacity": + this._assignAbsLifetimeValue(index, prop); break; - case 'angle': - this._assignAngleValue( index ); + case "angle": + this._assignAngleValue(index); break; - case 'params': - this._assignParamsValue( index ); + case "params": + this._assignParamsValue(index); break; - case 'rotation': - this._assignRotationValue( index ); + case "rotation": + this._assignRotationValue(index); break; - case 'color': - this._assignColorValue( index ); + case "color": + this._assignColorValue(index); break; } }; -SPE.Emitter.prototype._assignPositionValue = function( index ) { - 'use strict'; +SPE.Emitter.prototype._assignPositionValue = function (index) { + "use strict"; - var distributions = SPE.distributions, + let distributions = SPE.distributions, utils = SPE.utils, prop = this.position, attr = this.attributes.position, @@ -519,43 +507,60 @@ SPE.Emitter.prototype._assignPositionValue = function( index ) { spread = prop._spread, distribution = prop._distribution; - switch ( distribution ) { + switch (distribution) { case distributions.BOX: - utils.randomVector3( attr, index, value, spread, prop._spreadClamp ); + utils.randomVector3(attr, index, value, spread, prop._spreadClamp); break; case distributions.SPHERE: - utils.randomVector3OnSphere( attr, index, value, prop._radius, prop._spread.x, prop._radiusScale, prop._spreadClamp.x, prop._distributionClamp || this.particleCount ); + utils.randomVector3OnSphere( + attr, + index, + value, + prop._radius, + prop._spread.x, + prop._radiusScale, + prop._spreadClamp.x, + prop._distributionClamp || this.particleCount + ); break; case distributions.DISC: - utils.randomVector3OnDisc( attr, index, value, prop._radius, prop._spread.x, prop._radiusScale, prop._spreadClamp.x ); + utils.randomVector3OnDisc( + attr, + index, + value, + prop._radius, + prop._spread.x, + prop._radiusScale, + prop._spreadClamp.x + ); break; case distributions.LINE: - utils.randomVector3OnLine( attr, index, value, spread ); + utils.randomVector3OnLine(attr, index, value, spread); break; } }; -SPE.Emitter.prototype._assignForceValue = function( index, attrName ) { - 'use strict'; - - var distributions = SPE.distributions, - utils = SPE.utils, - prop = this[ attrName ], - value = prop._value, - spread = prop._spread, - distribution = prop._distribution, - pos, - positionX, - positionY, - positionZ, - i; - - switch ( distribution ) { +SPE.Emitter.prototype._assignForceValue = function (index, attrName) { + "use strict"; + + let distributions = SPE.distributions; + let utils = SPE.utils; + let prop = this[attrName]; + let value = prop._value; + let spread = prop._spread; + let distribution = prop._distribution; + let pos; + let positionX; + let positionY; + let positionZ; + let i; + + switch (distribution) { case distributions.BOX: - utils.randomVector3( this.attributes[ attrName ], index, value, spread ); + utils.randomVector3(this.attributes[attrName], index, value, spread); break; case distributions.SPHERE: @@ -567,13 +572,16 @@ SPE.Emitter.prototype._assignForceValue = function( index, attrName ) { // positionX = utils.zeroToEpsilon( pos[ i ], true ); // positionY = utils.zeroToEpsilon( pos[ i + 1 ], true ); // positionZ = utils.zeroToEpsilon( pos[ i + 2 ], true ); - positionX = pos[ i ]; - positionY = pos[ i + 1 ]; - positionZ = pos[ i + 2 ]; + positionX = pos[i]; + positionY = pos[i + 1]; + positionZ = pos[i + 2]; utils.randomDirectionVector3OnSphere( - this.attributes[ attrName ], index, - positionX, positionY, positionZ, + this.attributes[attrName], + index, + positionX, + positionY, + positionZ, this.position._value, prop._value.x, prop._spread.x @@ -589,13 +597,16 @@ SPE.Emitter.prototype._assignForceValue = function( index, attrName ) { // positionX = utils.zeroToEpsilon( pos[ i ], true ); // positionY = utils.zeroToEpsilon( pos[ i + 1 ], true ); // positionZ = utils.zeroToEpsilon( pos[ i + 2 ], true ); - positionX = pos[ i ]; - positionY = pos[ i + 1 ]; - positionZ = pos[ i + 2 ]; + positionX = pos[i]; + positionY = pos[i + 1]; + positionZ = pos[i + 2]; utils.randomDirectionVector3OnDisc( - this.attributes[ attrName ], index, - positionX, positionY, positionZ, + this.attributes[attrName], + index, + positionX, + positionY, + positionZ, this.position._value, prop._value.x, prop._spread.x @@ -603,143 +614,144 @@ SPE.Emitter.prototype._assignForceValue = function( index, attrName ) { break; case distributions.LINE: - utils.randomVector3OnLine( this.attributes[ attrName ], index, value, spread ); + utils.randomVector3OnLine(this.attributes[attrName], index, value, spread); break; } - if ( attrName === 'acceleration' ) { - var drag = utils.clamp( utils.randomFloat( this.drag._value, this.drag._spread ), 0, 1 ); - this.attributes.acceleration.typedArray.array[ index * 4 + 3 ] = drag; + if (attrName === "acceleration") { + let drag = utils.clamp(utils.randomFloat(this.drag._value, this.drag._spread), 0, 1); + this.attributes.acceleration.typedArray.array[index * 4 + 3] = drag; } }; -SPE.Emitter.prototype._assignAbsLifetimeValue = function( index, propName ) { - 'use strict'; - - var array = this.attributes[ propName ].typedArray, - prop = this[ propName ], - utils = SPE.utils, - value; - - if ( utils.arrayValuesAreEqual( prop._value ) && utils.arrayValuesAreEqual( prop._spread ) ) { - value = Math.abs( utils.randomFloat( prop._value[ 0 ], prop._spread[ 0 ] ) ); - array.setVec4Components( index, value, value, value, value ); - } - else { - array.setVec4Components( index, - Math.abs( utils.randomFloat( prop._value[ 0 ], prop._spread[ 0 ] ) ), - Math.abs( utils.randomFloat( prop._value[ 1 ], prop._spread[ 1 ] ) ), - Math.abs( utils.randomFloat( prop._value[ 2 ], prop._spread[ 2 ] ) ), - Math.abs( utils.randomFloat( prop._value[ 3 ], prop._spread[ 3 ] ) ) +SPE.Emitter.prototype._assignAbsLifetimeValue = function (index, propName) { + "use strict"; + + let array = this.attributes[propName].typedArray; + let prop = this[propName]; + let utils = SPE.utils; + let value; + + if (utils.arrayValuesAreEqual(prop._value) && utils.arrayValuesAreEqual(prop._spread)) { + value = Math.abs(utils.randomFloat(prop._value[0], prop._spread[0])); + array.setVec4Components(index, value, value, value, value); + } else { + array.setVec4Components( + index, + Math.abs(utils.randomFloat(prop._value[0], prop._spread[0])), + Math.abs(utils.randomFloat(prop._value[1], prop._spread[1])), + Math.abs(utils.randomFloat(prop._value[2], prop._spread[2])), + Math.abs(utils.randomFloat(prop._value[3], prop._spread[3])) ); } }; -SPE.Emitter.prototype._assignAngleValue = function( index ) { - 'use strict'; - - var array = this.attributes.angle.typedArray, - prop = this.angle, - utils = SPE.utils, - value; - - if ( utils.arrayValuesAreEqual( prop._value ) && utils.arrayValuesAreEqual( prop._spread ) ) { - value = utils.randomFloat( prop._value[ 0 ], prop._spread[ 0 ] ); - array.setVec4Components( index, value, value, value, value ); - } - else { - array.setVec4Components( index, - utils.randomFloat( prop._value[ 0 ], prop._spread[ 0 ] ), - utils.randomFloat( prop._value[ 1 ], prop._spread[ 1 ] ), - utils.randomFloat( prop._value[ 2 ], prop._spread[ 2 ] ), - utils.randomFloat( prop._value[ 3 ], prop._spread[ 3 ] ) +SPE.Emitter.prototype._assignAngleValue = function (index) { + "use strict"; + + let array = this.attributes.angle.typedArray; + let prop = this.angle; + let utils = SPE.utils; + let value; + + if (utils.arrayValuesAreEqual(prop._value) && utils.arrayValuesAreEqual(prop._spread)) { + value = utils.randomFloat(prop._value[0], prop._spread[0]); + array.setVec4Components(index, value, value, value, value); + } else { + array.setVec4Components( + index, + utils.randomFloat(prop._value[0], prop._spread[0]), + utils.randomFloat(prop._value[1], prop._spread[1]), + utils.randomFloat(prop._value[2], prop._spread[2]), + utils.randomFloat(prop._value[3], prop._spread[3]) ); } }; -SPE.Emitter.prototype._assignParamsValue = function( index ) { - 'use strict'; +SPE.Emitter.prototype._assignParamsValue = function (index) { + "use strict"; - this.attributes.params.typedArray.setVec4Components( index, + this.attributes.params.typedArray.setVec4Components( + index, this.isStatic ? 1 : 0, 0.0, - Math.abs( SPE.utils.randomFloat( this.maxAge._value, this.maxAge._spread ) ), - SPE.utils.randomFloat( this.wiggle._value, this.wiggle._spread ) + Math.abs(SPE.utils.randomFloat(this.maxAge._value, this.maxAge._spread)), + SPE.utils.randomFloat(this.wiggle._value, this.wiggle._spread) ); }; -SPE.Emitter.prototype._assignRotationValue = function( index ) { - 'use strict'; +SPE.Emitter.prototype._assignRotationValue = function (index) { + "use strict"; - this.attributes.rotation.typedArray.setVec3Components( index, - SPE.utils.getPackedRotationAxis( this.rotation._axis, this.rotation._axisSpread ), - SPE.utils.randomFloat( this.rotation._angle, this.rotation._angleSpread ), + this.attributes.rotation.typedArray.setVec3Components( + index, + SPE.utils.getPackedRotationAxis(this.rotation._axis, this.rotation._axisSpread), + SPE.utils.randomFloat(this.rotation._angle, this.rotation._angleSpread), this.rotation._static ? 0 : 1 ); - this.attributes.rotationCenter.typedArray.setVec3( index, this.rotation._center ); + this.attributes.rotationCenter.typedArray.setVec3(index, this.rotation._center); }; -SPE.Emitter.prototype._assignColorValue = function( index ) { - 'use strict'; - SPE.utils.randomColorAsHex( this.attributes.color, index, this.color._value, this.color._spread ); +SPE.Emitter.prototype._assignColorValue = function (index) { + "use strict"; + SPE.utils.randomColorAsHex(this.attributes.color, index, this.color._value, this.color._spread); }; -SPE.Emitter.prototype._resetParticle = function( index ) { - 'use strict'; - - var resetFlags = this.resetFlags, - updateFlags = this.updateFlags, - updateCounts = this.updateCounts, - keys = this.attributeKeys, - key, - updateFlag; - - for ( var i = this.attributeCount - 1; i >= 0; --i ) { - key = keys[ i ]; - updateFlag = updateFlags[ key ]; - - if ( resetFlags[ key ] === true || updateFlag === true ) { - this._assignValue( key, index ); - this._updateAttributeUpdateRange( key, index ); - - if ( updateFlag === true && updateCounts[ key ] === this.particleCount ) { - updateFlags[ key ] = false; - updateCounts[ key ] = 0.0; - } - else if ( updateFlag == true ) { - ++updateCounts[ key ]; +SPE.Emitter.prototype._resetParticle = function (index) { + "use strict"; + + let resetFlags = this.resetFlags; + let updateFlags = this.updateFlags; + let updateCounts = this.updateCounts; + let keys = this.attributeKeys; + let key; + let updateFlag; + + for (let i = this.attributeCount - 1; i >= 0; --i) { + key = keys[i]; + updateFlag = updateFlags[key]; + + if (resetFlags[key] === true || updateFlag === true) { + this._assignValue(key, index); + this._updateAttributeUpdateRange(key, index); + + if (updateFlag === true && updateCounts[key] === this.particleCount) { + updateFlags[key] = false; + updateCounts[key] = 0.0; + } else if (updateFlag == true) { + ++updateCounts[key]; } } } }; -SPE.Emitter.prototype._updateAttributeUpdateRange = function( attr, i ) { - 'use strict'; +SPE.Emitter.prototype._updateAttributeUpdateRange = function (attr, i) { + "use strict"; - var ranges = this.bufferUpdateRanges[ attr ]; + let ranges = this.bufferUpdateRanges[attr]; - ranges.min = Math.min( i, ranges.min ); - ranges.max = Math.max( i, ranges.max ); + ranges.min = Math.min(i, ranges.min); + ranges.max = Math.max(i, ranges.max); }; -SPE.Emitter.prototype._resetBufferRanges = function() { - 'use strict'; +SPE.Emitter.prototype._resetBufferRanges = function () { + "use strict"; - var ranges = this.bufferUpdateRanges, - keys = this.bufferUpdateKeys, - i = this.bufferUpdateCount - 1, - key; + let ranges = this.bufferUpdateRanges; + let keys = this.bufferUpdateKeys; + let i = this.bufferUpdateCount - 1; + let key; - for ( i; i >= 0; --i ) { - key = keys[ i ]; - ranges[ key ].min = Number.POSITIVE_INFINITY; - ranges[ key ].max = Number.NEGATIVE_INFINITY; + for (let i; i >= 0; --i) { + key = keys[i]; + ranges[key].min = Number.POSITIVE_INFINITY; + ranges[key].max = Number.NEGATIVE_INFINITY; } }; -SPE.Emitter.prototype._onRemove = function() { - 'use strict'; +SPE.Emitter.prototype._onRemove = function () { + "use strict"; // Reset any properties of the emitter that were set by // a group when it was added. this.particlesPerSecond = 0; @@ -752,68 +764,75 @@ SPE.Emitter.prototype._onRemove = function() { this.age = 0.0; }; -SPE.Emitter.prototype._decrementParticleCount = function() { - 'use strict'; +SPE.Emitter.prototype._decrementParticleCount = function () { + "use strict"; --this.activeParticleCount; // TODO: // - Trigger event if count === 0. }; -SPE.Emitter.prototype._incrementParticleCount = function() { - 'use strict'; +SPE.Emitter.prototype._incrementParticleCount = function () { + "use strict"; ++this.activeParticleCount; // TODO: // - Trigger event if count === this.particleCount. }; -SPE.Emitter.prototype._checkParticleAges = function( start, end, params, dt ) { - 'use strict'; - for ( var i = end - 1, index, maxAge, age, alive; i >= start; --i ) { +SPE.Emitter.prototype._checkParticleAges = function (start, end, params, dt) { + "use strict"; + + let index; + let maxAge; + let age; + let alive; + + for (let i = end - 1; i >= start; --i) { index = i * 4; - alive = params[ index ]; + alive = params[index]; - if ( alive === 0.0 ) { + if (alive === 0.0) { continue; } // Increment age - age = params[ index + 1 ]; - maxAge = params[ index + 2 ]; + age = params[index + 1]; + maxAge = params[index + 2]; - if ( this.direction === 1 ) { + if (this.direction === 1) { age += dt; - if ( age >= maxAge ) { + if (age >= maxAge) { age = 0.0; alive = 0.0; this._decrementParticleCount(); } - } - else { + } else { age -= dt; - if ( age <= 0.0 ) { + if (age <= 0.0) { age = maxAge; alive = 0.0; this._decrementParticleCount(); } } - params[ index ] = alive; - params[ index + 1 ] = age; + params[index] = alive; + params[index + 1] = age; - this._updateAttributeUpdateRange( 'params', i ); + this._updateAttributeUpdateRange("params", i); } }; -SPE.Emitter.prototype._activateParticles = function( activationStart, activationEnd, params, dtPerParticle ) { - 'use strict'; - var direction = this.direction; +SPE.Emitter.prototype._activateParticles = function (activationStart, activationEnd, params, dtPerParticle) { + "use strict"; + let direction = this.direction; + let index; + let dtValue; - for ( var i = activationStart, index, dtValue; i < activationEnd; ++i ) { + for (let i = activationStart; i < activationEnd; ++i) { index = i * 4; // Don't re-activate particles that aren't dead yet. @@ -821,7 +840,7 @@ SPE.Emitter.prototype._activateParticles = function( activationStart, activation // continue; // } - if ( params[ index ] != 0.0 && this.particleCount !== 1 ) { + if (params[index] != 0.0 && this.particleCount !== 1) { continue; } @@ -829,10 +848,10 @@ SPE.Emitter.prototype._activateParticles = function( activationStart, activation this._incrementParticleCount(); // Mark the particle as alive. - params[ index ] = 1.0; + params[index] = 1.0; // Reset the particle - this._resetParticle( i ); + this._resetParticle(i); // Move each particle being activated to // it's actual position in time. @@ -840,10 +859,10 @@ SPE.Emitter.prototype._activateParticles = function( activationStart, activation // This stops particles being 'clumped' together // when frame rates are on the lower side of 60fps // or not constant (a very real possibility!) - dtValue = dtPerParticle * ( i - activationStart ) - params[ index + 1 ] = direction === -1 ? params[ index + 2 ] - dtValue : dtValue; + dtValue = dtPerParticle * (i - activationStart); + params[index + 1] = direction === -1 ? params[index + 2] - dtValue : dtValue; - this._updateAttributeUpdateRange( 'params', i ); + this._updateAttributeUpdateRange("params", i); } }; @@ -856,61 +875,59 @@ SPE.Emitter.prototype._activateParticles = function( activationStart, activation * * @param {Number} dt The number of seconds to simulate (deltaTime) */ -SPE.Emitter.prototype.tick = function( dt ) { - 'use strict'; +SPE.Emitter.prototype.tick = function (dt) { + "use strict"; - if ( this.isStatic ) { + if (this.isStatic) { return; } - if ( this.paramsArray === null ) { + if (this.paramsArray === null) { this.paramsArray = this.attributes.params.typedArray.array; } - var start = this.attributeOffset, - end = start + this.particleCount, - params = this.paramsArray, // vec3( alive, age, maxAge, wiggle ) - ppsDt = this.particlesPerSecond * this.activeMultiplier * dt, - activationIndex = this.activationIndex; + let start = this.attributeOffset; + let end = start + this.particleCount; + let params = this.paramsArray; + let ppsDt = this.particlesPerSecond * this.activeMultiplier * dt; + let activationIndex = this.activationIndex; // Reset the buffer update indices. this._resetBufferRanges(); // Increment age for those particles that are alive, // and kill off any particles whose age is over the limit. - this._checkParticleAges( start, end, params, dt ); + this._checkParticleAges(start, end, params, dt); // If the emitter is dead, reset the age of the emitter to zero, // ready to go again if required - if ( this.alive === false ) { + if (this.alive === false) { this.age = 0.0; return; } // If the emitter has a specified lifetime and we've exceeded it, // mark the emitter as dead. - if ( this.duration !== null && this.age > this.duration ) { + if (this.duration !== null && this.age > this.duration) { this.alive = false; this.age = 0.0; return; } + let activationStart = this.particleCount === 1 ? activationIndex : activationIndex | 0; + let activationEnd = Math.min(activationStart + ppsDt, this.activationEnd); + let activationCount = (activationEnd - this.activationIndex) | 0; + let dtPerParticle = activationCount > 0 ? dt / activationCount : 0; - var activationStart = this.particleCount === 1 ? activationIndex : ( activationIndex | 0 ), - activationEnd = Math.min( activationStart + ppsDt, this.activationEnd ), - activationCount = activationEnd - this.activationIndex | 0, - dtPerParticle = activationCount > 0 ? dt / activationCount : 0; - - this._activateParticles( activationStart, activationEnd, params, dtPerParticle ); + this._activateParticles(activationStart, activationEnd, params, dtPerParticle); // Move the activation window forward, soldier. this.activationIndex += ppsDt; - if ( this.activationIndex > end ) { + if (this.activationIndex > end) { this.activationIndex = start; } - // Increment the age of the emitter. this.age += dt; }; @@ -923,27 +940,28 @@ SPE.Emitter.prototype.tick = function( dt ) { * @param {Boolean} [force=undefined] If true, all particles will be marked as dead instantly. * @return {Emitter} This emitter instance. */ -SPE.Emitter.prototype.reset = function( force ) { - 'use strict'; +SPE.Emitter.prototype.reset = function (force) { + "use strict"; this.age = 0.0; this.alive = false; - if ( force === true ) { - var start = this.attributeOffset, - end = start + this.particleCount, - array = this.paramsArray, - attr = this.attributes.params.bufferAttribute; + if (force === true) { + let start = this.attributeOffset; + let end = start + this.particleCount; + let array = this.paramsArray; + let attr = this.attributes.params.bufferAttribute; + let index; - for ( var i = end - 1, index; i >= start; --i ) { + for (let i = end - 1; i >= start; --i) { index = i * 4; - array[ index ] = 0.0; - array[ index + 1 ] = 0.0; + array[index] = 0.0; + array[index + 1] = 0.0; } - attr.updateRange.offset = 0; - attr.updateRange.count = -1; + attr.addUpdateRange.offset = 0; + attr.addUpdateRange.count = -1; attr.needsUpdate = true; } @@ -956,8 +974,8 @@ SPE.Emitter.prototype.reset = function( force ) { * * @return {Emitter} This emitter instance. */ -SPE.Emitter.prototype.enable = function() { - 'use strict'; +SPE.Emitter.prototype.enable = function () { + "use strict"; this.alive = true; return this; }; @@ -970,8 +988,8 @@ SPE.Emitter.prototype.enable = function() { * * @return {Emitter} This emitter instance. */ -SPE.Emitter.prototype.disable = function() { - 'use strict'; +SPE.Emitter.prototype.disable = function () { + "use strict"; this.alive = false; return this; @@ -988,13 +1006,12 @@ SPE.Emitter.prototype.disable = function() { * * @see SPE.Group.prototype.removeEmitter */ -SPE.Emitter.prototype.remove = function() { - 'use strict'; - if ( this.group !== null ) { - this.group.removeEmitter( this ); - } - else { - console.error( 'Emitter does not belong to a group, cannot remove.' ); +SPE.Emitter.prototype.remove = function () { + "use strict"; + if (this.group !== null) { + this.group.removeEmitter(this); + } else { + console.error("Emitter does not belong to a group, cannot remove."); } return this; diff --git a/src/core/SPE.Group.js b/src/core/SPE.Group.js index 1e1d585..81abacf 100644 --- a/src/core/SPE.Group.js +++ b/src/core/SPE.Group.js @@ -50,52 +50,54 @@ * setting particle sizes to be relative to renderer size. */ - /** * The SPE.Group class. Creates a new group, containing a material, geometry, and mesh. * * @constructor * @param {GroupOptions} options A map of options to configure the group instance. */ -SPE.Group = function( options ) { - 'use strict'; +SPE.Group = function (options) { + "use strict"; - var utils = SPE.utils, - types = utils.types; + let utils = SPE.utils; + let types = utils.types; // Ensure we have a map of options to play with - options = utils.ensureTypedArg( options, types.OBJECT, {} ); - options.texture = utils.ensureTypedArg( options.texture, types.OBJECT, {} ); + options = utils.ensureTypedArg(options, types.OBJECT, {}); + options.texture = utils.ensureTypedArg(options.texture, types.OBJECT, {}); // Assign a UUID to this instance - this.uuid = THREE.Math.generateUUID(); + this.uuid = SPE.utils.generateUUID(); // If no `deltaTime` value is passed to the `SPE.Group.tick` function, // the value of this property will be used to advance the simulation. - this.fixedTimeStep = utils.ensureTypedArg( options.fixedTimeStep, types.NUMBER, 0.016 ); + this.fixedTimeStep = utils.ensureTypedArg(options.fixedTimeStep, types.NUMBER, 0.016); // Set properties used in the uniforms map, starting with the // texture stuff. - this.texture = utils.ensureInstanceOf( options.texture.value, THREE.Texture, null ); - this.textureFrames = utils.ensureInstanceOf( options.texture.frames, THREE.Vector2, new THREE.Vector2( 1, 1 ) ); - this.textureFrameCount = utils.ensureTypedArg( options.texture.frameCount, types.NUMBER, this.textureFrames.x * this.textureFrames.y ); - this.textureLoop = utils.ensureTypedArg( options.texture.loop, types.NUMBER, 1 ); - this.textureFrames.max( new THREE.Vector2( 1, 1 ) ); - - this.hasPerspective = utils.ensureTypedArg( options.hasPerspective, types.BOOLEAN, true ); - this.colorize = utils.ensureTypedArg( options.colorize, types.BOOLEAN, true ); + this.texture = utils.ensureInstanceOf(options.texture.value, THREE.Texture, null); + this.textureFrames = utils.ensureInstanceOf(options.texture.frames, THREE.Vector2, new THREE.Vector2(1, 1)); + this.textureFrameCount = utils.ensureTypedArg( + options.texture.frameCount, + types.NUMBER, + this.textureFrames.x * this.textureFrames.y + ); + this.textureLoop = utils.ensureTypedArg(options.texture.loop, types.NUMBER, 1); + this.textureFrames.max(new THREE.Vector2(1, 1)); - this.maxParticleCount = utils.ensureTypedArg( options.maxParticleCount, types.NUMBER, null ); + this.hasPerspective = utils.ensureTypedArg(options.hasPerspective, types.BOOLEAN, true); + this.colorize = utils.ensureTypedArg(options.colorize, types.BOOLEAN, true); + this.maxParticleCount = utils.ensureTypedArg(options.maxParticleCount, types.NUMBER, null); // Set properties used to define the ShaderMaterial's appearance. - this.blending = utils.ensureTypedArg( options.blending, types.NUMBER, THREE.AdditiveBlending ); - this.transparent = utils.ensureTypedArg( options.transparent, types.BOOLEAN, true ); - this.alphaTest = parseFloat( utils.ensureTypedArg( options.alphaTest, types.NUMBER, 0.0 ) ); - this.depthWrite = utils.ensureTypedArg( options.depthWrite, types.BOOLEAN, false ); - this.depthTest = utils.ensureTypedArg( options.depthTest, types.BOOLEAN, true ); - this.fog = utils.ensureTypedArg( options.fog, types.BOOLEAN, true ); - this.scale = utils.ensureTypedArg( options.scale, types.NUMBER, 300 ); + this.blending = utils.ensureTypedArg(options.blending, types.NUMBER, THREE.AdditiveBlending); + this.transparent = utils.ensureTypedArg(options.transparent, types.BOOLEAN, true); + this.alphaTest = parseFloat(utils.ensureTypedArg(options.alphaTest, types.NUMBER, 0.0)); + this.depthWrite = utils.ensureTypedArg(options.depthWrite, types.BOOLEAN, false); + this.depthTest = utils.ensureTypedArg(options.depthTest, types.BOOLEAN, true); + this.fog = utils.ensureTypedArg(options.fog, types.BOOLEAN, true); + this.scale = utils.ensureTypedArg(options.scale, types.NUMBER, 300); // Where emitter's go to curl up in a warm blanket and live // out their days. @@ -116,50 +118,49 @@ SPE.Group = function( options ) { this.particleCount = 0; - // Map of uniforms to be applied to the ShaderMaterial instance. this.uniforms = { tex: { - type: 't', - value: this.texture + type: "t", + value: this.texture, }, textureAnimation: { - type: 'v4', + type: "v4", value: new THREE.Vector4( this.textureFrames.x, this.textureFrames.y, this.textureFrameCount, - Math.max( Math.abs( this.textureLoop ), 1.0 ) - ) + Math.max(Math.abs(this.textureLoop), 1.0) + ), }, fogColor: { - type: 'c', - value: this.fog ? new THREE.Color() : null + type: "c", + value: this.fog ? new THREE.Color() : null, }, fogNear: { - type: 'f', - value: 10 + type: "f", + value: 10, }, fogFar: { - type: 'f', - value: 200 + type: "f", + value: 200, }, fogDensity: { - type: 'f', - value: 0.5 + type: "f", + value: 0.5, }, deltaTime: { - type: 'f', - value: 0 + type: "f", + value: 0, }, runTime: { - type: 'f', - value: 0 + type: "f", + value: 0, }, scale: { - type: 'f', - value: this.scale - } + type: "f", + value: this.scale, + }, }; // Add some defines into the mix... @@ -172,31 +173,31 @@ SPE.Group = function( options ) { SHOULD_ROTATE_PARTICLES: false, SHOULD_WIGGLE_PARTICLES: false, - SHOULD_CALCULATE_SPRITE: this.textureFrames.x > 1 || this.textureFrames.y > 1 + SHOULD_CALCULATE_SPRITE: this.textureFrames.x > 1 || this.textureFrames.y > 1, }; // Map of all attributes to be applied to the particles. // // See SPE.ShaderAttribute for a bit more info on this bit. this.attributes = { - position: new SPE.ShaderAttribute( 'v3', true ), - acceleration: new SPE.ShaderAttribute( 'v4', true ), // w component is drag - velocity: new SPE.ShaderAttribute( 'v3', true ), - rotation: new SPE.ShaderAttribute( 'v4', true ), - rotationCenter: new SPE.ShaderAttribute( 'v3', true ), - params: new SPE.ShaderAttribute( 'v4', true ), // Holds (alive, age, delay, wiggle) - size: new SPE.ShaderAttribute( 'v4', true ), - angle: new SPE.ShaderAttribute( 'v4', true ), - color: new SPE.ShaderAttribute( 'v4', true ), - opacity: new SPE.ShaderAttribute( 'v4', true ) + position: new SPE.ShaderAttribute("v3", true), + acceleration: new SPE.ShaderAttribute("v4", true), // w component is drag + velocity: new SPE.ShaderAttribute("v3", true), + rotation: new SPE.ShaderAttribute("v4", true), + rotationCenter: new SPE.ShaderAttribute("v3", true), + params: new SPE.ShaderAttribute("v4", true), // Holds (alive, age, delay, wiggle) + size: new SPE.ShaderAttribute("v4", true), + angle: new SPE.ShaderAttribute("v4", true), + color: new SPE.ShaderAttribute("v4", true), + opacity: new SPE.ShaderAttribute("v4", true), }; - this.attributeKeys = Object.keys( this.attributes ); + this.attributeKeys = Object.keys(this.attributes); this.attributeCount = this.attributeKeys.length; // Create the ShaderMaterial instance that'll help render the // particles. - this.material = new THREE.ShaderMaterial( { + this.material = new THREE.ShaderMaterial({ uniforms: this.uniforms, vertexShader: SPE.shaders.vertex, fragmentShader: SPE.shaders.fragment, @@ -206,85 +207,81 @@ SPE.Group = function( options ) { depthWrite: this.depthWrite, depthTest: this.depthTest, defines: this.defines, - fog: this.fog - } ); + fog: this.fog, + }); // Create the BufferGeometry and Points instances, ensuring // the geometry and material are given to the latter. this.geometry = new THREE.BufferGeometry(); - this.mesh = new THREE.Points( this.geometry, this.material ); + this.mesh = new THREE.Points(this.geometry, this.material); - if ( this.maxParticleCount === null ) { - console.warn( 'SPE.Group: No maxParticleCount specified. Adding emitters after rendering will probably cause errors.' ); + if (this.maxParticleCount === null) { + console.warn( + "SPE.Group: No maxParticleCount specified. Adding emitters after rendering will probably cause errors." + ); } }; SPE.Group.constructor = SPE.Group; +SPE.Group.prototype._updateDefines = function () { + "use strict"; -SPE.Group.prototype._updateDefines = function() { - 'use strict'; + let emitters = this.emitters; + let i = emitters.length - 1; + let emitter; + let defines = this.defines; - var emitters = this.emitters, - i = emitters.length - 1, - emitter, - defines = this.defines; - - for ( i; i >= 0; --i ) { - emitter = emitters[ i ]; + for (i; i >= 0; --i) { + emitter = emitters[i]; // Only do angle calculation if there's no spritesheet defined. // // Saves calculations being done and then overwritten in the shaders. - if ( !defines.SHOULD_CALCULATE_SPRITE ) { - defines.SHOULD_ROTATE_TEXTURE = defines.SHOULD_ROTATE_TEXTURE || !!Math.max( - Math.max.apply( null, emitter.angle.value ), - Math.max.apply( null, emitter.angle.spread ) - ); + if (!defines.SHOULD_CALCULATE_SPRITE) { + defines.SHOULD_ROTATE_TEXTURE = + defines.SHOULD_ROTATE_TEXTURE || + !!Math.max(Math.max.apply(null, emitter.angle.value), Math.max.apply(null, emitter.angle.spread)); } - defines.SHOULD_ROTATE_PARTICLES = defines.SHOULD_ROTATE_PARTICLES || !!Math.max( - emitter.rotation.angle, - emitter.rotation.angleSpread - ); + defines.SHOULD_ROTATE_PARTICLES = + defines.SHOULD_ROTATE_PARTICLES || !!Math.max(emitter.rotation.angle, emitter.rotation.angleSpread); - defines.SHOULD_WIGGLE_PARTICLES = defines.SHOULD_WIGGLE_PARTICLES || !!Math.max( - emitter.wiggle.value, - emitter.wiggle.spread - ); + defines.SHOULD_WIGGLE_PARTICLES = + defines.SHOULD_WIGGLE_PARTICLES || !!Math.max(emitter.wiggle.value, emitter.wiggle.spread); } this.material.needsUpdate = true; }; -SPE.Group.prototype._applyAttributesToGeometry = function() { - 'use strict'; +SPE.Group.prototype._applyAttributesToGeometry = function () { + "use strict"; - var attributes = this.attributes, - geometry = this.geometry, - geometryAttributes = geometry.attributes, - attribute, - geometryAttribute; + let attributes = this.attributes; + let geometry = this.geometry; + let geometryAttributes = geometry.attributes; + let attribute; + let geometryAttribute; // Loop through all the shader attributes and assign (or re-assign) // typed array buffers to each one. - for ( var attr in attributes ) { - if ( attributes.hasOwnProperty( attr ) ) { - attribute = attributes[ attr ]; - geometryAttribute = geometryAttributes[ attr ]; + for (let attr in attributes) { + if (attributes.hasOwnProperty(attr)) { + attribute = attributes[attr]; + geometryAttribute = geometryAttributes[attr]; // Update the array if this attribute exists on the geometry. // // This needs to be done because the attribute's typed array might have // been resized and reinstantiated, and might now be looking at a // different ArrayBuffer, so reference needs updating. - if ( geometryAttribute ) { + if (geometryAttribute) { geometryAttribute.array = attribute.typedArray.array; } // // Add the attribute to the geometry if it doesn't already exist. else { - geometry.addAttribute( attr, attribute.bufferAttribute ); + geometry.setAttribute(attr, attribute.bufferAttribute); } // Mark the attribute as needing an update the next time a frame is rendered. @@ -296,7 +293,7 @@ SPE.Group.prototype._applyAttributesToGeometry = function() { // only the values in the attribute buffers that are // associated with a particle will be used in THREE's // render cycle. - this.geometry.setDrawRange( 0, this.particleCount ); + this.geometry.setDrawRange(0, this.particleCount); }; /** @@ -305,54 +302,58 @@ SPE.Group.prototype._applyAttributesToGeometry = function() { * * @param {Emitter} emitter The emitter to add to this group. */ -SPE.Group.prototype.addEmitter = function( emitter ) { - 'use strict'; +SPE.Group.prototype.addEmitter = function (emitter) { + "use strict"; // Ensure an actual emitter instance is passed here. // // Decided not to throw here, just in case a scene's // rendering would be paused. Logging an error instead // of stopping execution if exceptions aren't caught. - if ( emitter instanceof SPE.Emitter === false ) { - console.error( '`emitter` argument must be instance of SPE.Emitter. Was provided with:', emitter ); + if (emitter instanceof SPE.Emitter === false) { + console.error("`emitter` argument must be instance of SPE.Emitter. Was provided with:", emitter); return; } // If the emitter already exists as a member of this group, then // stop here, we don't want to add it again. - else if ( this.emitterIDs.indexOf( emitter.uuid ) > -1 ) { - console.error( 'Emitter already exists in this group. Will not add again.' ); + else if (this.emitterIDs.indexOf(emitter.uuid) > -1) { + console.error("Emitter already exists in this group. Will not add again."); return; } // And finally, if the emitter is a member of another group, // don't add it to this group. - else if ( emitter.group !== null ) { - console.error( 'Emitter already belongs to another group. Will not add to requested group.' ); + else if (emitter.group !== null) { + console.error("Emitter already belongs to another group. Will not add to requested group."); return; } - var attributes = this.attributes, - start = this.particleCount, - end = start + emitter.particleCount; + let attributes = this.attributes; + let start = this.particleCount; + let end = start + emitter.particleCount; // Update this group's particle count. this.particleCount = end; // Emit a warning if the emitter being added will exceed the buffer sizes specified. - if ( this.maxParticleCount !== null && this.particleCount > this.maxParticleCount ) { - console.warn( 'SPE.Group: maxParticleCount exceeded. Requesting', this.particleCount, 'particles, can support only', this.maxParticleCount ); + if (this.maxParticleCount !== null && this.particleCount > this.maxParticleCount) { + console.warn( + "SPE.Group: maxParticleCount exceeded. Requesting", + this.particleCount, + "particles, can support only", + this.maxParticleCount + ); } - // Set the `particlesPerSecond` value (PPS) on the emitter. // It's used to determine how many particles to release // on a per-frame basis. - emitter._calculatePPSValue( emitter.maxAge._value + emitter.maxAge._spread ); - emitter._setBufferUpdateRanges( this.attributeKeys ); + emitter._calculatePPSValue(emitter.maxAge._value + emitter.maxAge._spread); + emitter._setBufferUpdateRanges(this.attributeKeys); // Store the offset value in the TypedArray attributes for this emitter. - emitter._setAttributeOffset( start ); + emitter._setAttributeOffset(start); // Save a reference to this group on the emitter so it knows // where it belongs. @@ -362,34 +363,30 @@ SPE.Group.prototype.addEmitter = function( emitter ) { // easier access during the emitter's tick function. emitter.attributes = this.attributes; - - // Ensure the attributes and their BufferAttributes exist, and their // TypedArrays are of the correct size. - for ( var attr in attributes ) { - if ( attributes.hasOwnProperty( attr ) ) { + for (let attr in attributes) { + if (attributes.hasOwnProperty(attr)) { // When creating a buffer, pass through the maxParticle count // if one is specified. - attributes[ attr ]._createBufferAttribute( - this.maxParticleCount !== null ? - this.maxParticleCount : - this.particleCount + attributes[attr]._createBufferAttribute( + this.maxParticleCount !== null ? this.maxParticleCount : this.particleCount ); } } // Loop through each particle this emitter wants to have, and create the attributes values, // storing them in the TypedArrays that each attribute holds. - for ( var i = start; i < end; ++i ) { - emitter._assignPositionValue( i ); - emitter._assignForceValue( i, 'velocity' ); - emitter._assignForceValue( i, 'acceleration' ); - emitter._assignAbsLifetimeValue( i, 'opacity' ); - emitter._assignAbsLifetimeValue( i, 'size' ); - emitter._assignAngleValue( i ); - emitter._assignRotationValue( i ); - emitter._assignParamsValue( i ); - emitter._assignColorValue( i ); + for (let i = start; i < end; ++i) { + emitter._assignPositionValue(i); + emitter._assignForceValue(i, "velocity"); + emitter._assignForceValue(i, "acceleration"); + emitter._assignAbsLifetimeValue(i, "opacity"); + emitter._assignAbsLifetimeValue(i, "size"); + emitter._assignAngleValue(i); + emitter._assignRotationValue(i); + emitter._assignParamsValue(i); + emitter._assignColorValue(i); } // Update the geometry and make sure the attributes are referencing @@ -397,11 +394,11 @@ SPE.Group.prototype.addEmitter = function( emitter ) { this._applyAttributesToGeometry(); // Store this emitter in this group's emitter's store. - this.emitters.push( emitter ); - this.emitterIDs.push( emitter.uuid ); + this.emitters.push(emitter); + this.emitterIDs.push(emitter.uuid); // Update certain flags to enable shader calculations only if they're necessary. - this._updateDefines( emitter ); + this._updateDefines(emitter); // Update the material since defines might have changed this.material.needsUpdate = true; @@ -419,49 +416,49 @@ SPE.Group.prototype.addEmitter = function( emitter ) { * * @param {Emitter} emitter The emitter to add to this group. */ -SPE.Group.prototype.removeEmitter = function( emitter ) { - 'use strict'; +SPE.Group.prototype.removeEmitter = function (emitter) { + "use strict"; - var emitterIndex = this.emitterIDs.indexOf( emitter.uuid ); + let emitterIndex = this.emitterIDs.indexOf(emitter.uuid); // Ensure an actual emitter instance is passed here. // // Decided not to throw here, just in case a scene's // rendering would be paused. Logging an error instead // of stopping execution if exceptions aren't caught. - if ( emitter instanceof SPE.Emitter === false ) { - console.error( '`emitter` argument must be instance of SPE.Emitter. Was provided with:', emitter ); + if (emitter instanceof SPE.Emitter === false) { + console.error("`emitter` argument must be instance of SPE.Emitter. Was provided with:", emitter); return; } // Issue an error if the emitter isn't a member of this group. - else if ( emitterIndex === -1 ) { - console.error( 'Emitter does not exist in this group. Will not remove.' ); + else if (emitterIndex === -1) { + console.error("Emitter does not exist in this group. Will not remove."); return; } // Kill all particles by marking them as dead // and their age as 0. - var start = emitter.attributeOffset, - end = start + emitter.particleCount, - params = this.attributes.params.typedArray; + let start = emitter.attributeOffset; + let end = start + emitter.particleCount; + let params = this.attributes.params.typedArray; // Set alive and age to zero. - for ( var i = start; i < end; ++i ) { - params.array[ i * 4 ] = 0.0; - params.array[ i * 4 + 1 ] = 0.0; + for (let i = start; i < end; ++i) { + params.array[i * 4] = 0.0; + params.array[i * 4 + 1] = 0.0; } // Remove the emitter from this group's "store". - this.emitters.splice( emitterIndex, 1 ); - this.emitterIDs.splice( emitterIndex, 1 ); + this.emitters.splice(emitterIndex, 1); + this.emitterIDs.splice(emitterIndex, 1); // Remove this emitter's attribute values from all shader attributes. // The `.splice()` call here also marks each attribute's buffer // as needing to update it's entire contents. - for ( var attr in this.attributes ) { - if ( this.attributes.hasOwnProperty( attr ) ) { - this.attributes[ attr ].splice( start, end ); + for (let attr in this.attributes) { + if (this.attributes.hasOwnProperty(attr)) { + this.attributes[attr].splice(start, end); } } @@ -476,7 +473,6 @@ SPE.Group.prototype.removeEmitter = function( emitter ) { this._attributesNeedRefresh = true; }; - /** * Fetch a single emitter instance from the pool. * If there are no objects in the pool, a new emitter will be @@ -484,19 +480,18 @@ SPE.Group.prototype.removeEmitter = function( emitter ) { * * @return {Emitter|null} */ -SPE.Group.prototype.getFromPool = function() { - 'use strict'; +SPE.Group.prototype.getFromPool = function () { + "use strict"; - var pool = this._pool, - createNew = this._createNewWhenPoolEmpty; + let pool = this._pool; + let createNew = this._createNewWhenPoolEmpty; - if ( pool.length ) { + if (pool.length) { return pool.pop(); - } - else if ( createNew ) { - var emitter = new SPE.Emitter( this._poolCreationSettings ); + } else if (createNew) { + let emitter = new SPE.Emitter(this._poolCreationSettings); - this.addEmitter( emitter ); + this.addEmitter(emitter); return emitter; } @@ -504,39 +499,36 @@ SPE.Group.prototype.getFromPool = function() { return null; }; - /** * Release an emitter into the pool. * * @param {ShaderParticleEmitter} emitter * @return {Group} This group instance. */ -SPE.Group.prototype.releaseIntoPool = function( emitter ) { - 'use strict'; +SPE.Group.prototype.releaseIntoPool = function (emitter) { + "use strict"; - if ( emitter instanceof SPE.Emitter === false ) { - console.error( 'Argument is not instanceof SPE.Emitter:', emitter ); + if (emitter instanceof SPE.Emitter === false) { + console.error("Argument is not instanceof SPE.Emitter:", emitter); return; } emitter.reset(); - this._pool.unshift( emitter ); + this._pool.unshift(emitter); return this; }; - /** * Get the pool array * * @return {Array} */ -SPE.Group.prototype.getPool = function() { - 'use strict'; +SPE.Group.prototype.getPool = function () { + "use strict"; return this._pool; }; - /** * Add a pool of emitters to this particle group * @@ -545,47 +537,44 @@ SPE.Group.prototype.getPool = function() { * @param {Boolean} createNew Should a new emitter be created if the pool runs out? * @return {Group} This group instance. */ -SPE.Group.prototype.addPool = function( numEmitters, emitterOptions, createNew ) { - 'use strict'; +SPE.Group.prototype.addPool = function (numEmitters, emitterOptions, createNew) { + "use strict"; - var emitter; + let emitter; // Save relevant settings and flags. this._poolCreationSettings = emitterOptions; this._createNewWhenPoolEmpty = !!createNew; // Create the emitters, add them to this group and the pool. - for ( var i = 0; i < numEmitters; ++i ) { - if ( Array.isArray( emitterOptions ) ) { - emitter = new SPE.Emitter( emitterOptions[ i ] ); - } - else { - emitter = new SPE.Emitter( emitterOptions ); + for (let i = 0; i < numEmitters; ++i) { + if (Array.isArray(emitterOptions)) { + emitter = new SPE.Emitter(emitterOptions[i]); + } else { + emitter = new SPE.Emitter(emitterOptions); } - this.addEmitter( emitter ); - this.releaseIntoPool( emitter ); + this.addEmitter(emitter); + this.releaseIntoPool(emitter); } return this; }; +SPE.Group.prototype._triggerSingleEmitter = function (pos) { + "use strict"; - -SPE.Group.prototype._triggerSingleEmitter = function( pos ) { - 'use strict'; - - var emitter = this.getFromPool(), + let emitter = this.getFromPool(), self = this; - if ( emitter === null ) { - console.log( 'SPE.Group pool ran out.' ); + if (emitter === null) { + console.log("SPE.Group pool ran out."); return; } // TODO: // - Make sure buffers are update with thus new position. - if ( pos instanceof THREE.Vector3 ) { - emitter.position.value.copy( pos ); + if (pos instanceof THREE.Vector3) { + emitter.position.value.copy(pos); // Trigger the setter for this property to force an // update to the emitter's position attribute. @@ -594,15 +583,14 @@ SPE.Group.prototype._triggerSingleEmitter = function( pos ) { emitter.enable(); - setTimeout( function() { + setTimeout(function () { emitter.disable(); - self.releaseIntoPool( emitter ); - }, ( Math.max( emitter.duration, ( emitter.maxAge.value + emitter.maxAge.spread ) ) ) * 1000 ); + self.releaseIntoPool(emitter); + }, Math.max(emitter.duration, emitter.maxAge.value + emitter.maxAge.spread) * 1000); return this; }; - /** * Set a given number of emitters as alive, with an optional position * vector3 to move them to. @@ -611,113 +599,101 @@ SPE.Group.prototype._triggerSingleEmitter = function( pos ) { * @param {Object} [position=undefined] A THREE.Vector3 instance describing the position to activate the emitter(s) at. * @return {Group} This group instance. */ -SPE.Group.prototype.triggerPoolEmitter = function( numEmitters, position ) { - 'use strict'; +SPE.Group.prototype.triggerPoolEmitter = function (numEmitters, position) { + "use strict"; - if ( typeof numEmitters === 'number' && numEmitters > 1 ) { - for ( var i = 0; i < numEmitters; ++i ) { - this._triggerSingleEmitter( position ); + if (typeof numEmitters === "number" && numEmitters > 1) { + for (let i = 0; i < numEmitters; ++i) { + this._triggerSingleEmitter(position); } - } - else { - this._triggerSingleEmitter( position ); + } else { + this._triggerSingleEmitter(position); } return this; }; - - -SPE.Group.prototype._updateUniforms = function( dt ) { - 'use strict'; +SPE.Group.prototype._updateUniforms = function (dt) { + "use strict"; this.uniforms.runTime.value += dt; this.uniforms.deltaTime.value = dt; }; -SPE.Group.prototype._resetBufferRanges = function() { - 'use strict'; +SPE.Group.prototype._resetBufferRanges = function () { + "use strict"; - var keys = this.attributeKeys, - i = this.attributeCount - 1, - attrs = this.attributes; + let keys = this.attributeKeys; + let i = this.attributeCount - 1; + let attrs = this.attributes; - for ( i; i >= 0; --i ) { - attrs[ keys[ i ] ].resetUpdateRange(); + for (i; i >= 0; --i) { + attrs[keys[i]].resetUpdateRange(); } }; - -SPE.Group.prototype._updateBuffers = function( emitter ) { - 'use strict'; - - var keys = this.attributeKeys, - i = this.attributeCount - 1, - attrs = this.attributes, - emitterRanges = emitter.bufferUpdateRanges, - key, - emitterAttr, - attr; - - for ( i; i >= 0; --i ) { - key = keys[ i ]; - emitterAttr = emitterRanges[ key ]; - attr = attrs[ key ]; - attr.setUpdateRange( emitterAttr.min, emitterAttr.max ); +SPE.Group.prototype._updateBuffers = function (emitter) { + "use strict"; + + let keys = this.attributeKeys; + let attrs = this.attributes; + let emitterRanges = emitter.bufferUpdateRanges; + let key; + let emitterAttr; + let attr; + + for (let i = this.attributeCount - 1; i >= 0; --i) { + key = keys[i]; + emitterAttr = emitterRanges[key]; + attr = attrs[key]; + attr.setUpdateRange(emitterAttr.min, emitterAttr.max); attr.flagUpdate(); } }; - /** * Simulate all the emitter's belonging to this group, updating * attribute values along the way. * @param {Number} [dt=Group's `fixedTimeStep` value] The number of seconds to simulate the group's emitters for (deltaTime) */ -SPE.Group.prototype.tick = function( dt ) { - 'use strict'; +SPE.Group.prototype.tick = function (dt) { + "use strict"; - var emitters = this.emitters, - numEmitters = emitters.length, - deltaTime = dt || this.fixedTimeStep, - keys = this.attributeKeys, - i, - attrs = this.attributes; + let emitters = this.emitters; + let numEmitters = emitters.length; + let deltaTime = dt || this.fixedTimeStep; + let keys = this.attributeKeys; + let i; + let attrs = this.attributes; // Update uniform values. - this._updateUniforms( deltaTime ); + this._updateUniforms(deltaTime); // Reset buffer update ranges on the shader attributes. this._resetBufferRanges(); - // If nothing needs updating, then stop here. - if ( - numEmitters === 0 && - this._attributesNeedRefresh === false && - this._attributesNeedDynamicReset === false - ) { + if (numEmitters === 0 && this._attributesNeedRefresh === false && this._attributesNeedDynamicReset === false) { return; } // Loop through each emitter in this group and // simulate it, then update the shader attribute // buffers. - for ( var i = 0, emitter; i < numEmitters; ++i ) { - emitter = emitters[ i ]; - emitter.tick( deltaTime ); - this._updateBuffers( emitter ); + for (let i = 0, emitter; i < numEmitters; ++i) { + emitter = emitters[i]; + emitter.tick(deltaTime); + this._updateBuffers(emitter); } // If the shader attributes have been refreshed, // then the dynamic properties of each buffer // attribute will need to be reset back to // what they should be. - if ( this._attributesNeedDynamicReset === true ) { - i = this.attributeCount - 1; + if (this._attributesNeedDynamicReset === true) { - for ( i; i >= 0; --i ) { - attrs[ keys[ i ] ].resetDynamic(); + for (let i = this.attributeCount - 1; i >= 0; --i) { + attrs[keys[i]].resetDynamic(); } this._attributesNeedDynamicReset = false; @@ -726,11 +702,10 @@ SPE.Group.prototype.tick = function( dt ) { // If this group's shader attributes need a full refresh // then mark each attribute's buffer attribute as // needing so. - if ( this._attributesNeedRefresh === true ) { - i = this.attributeCount - 1; + if (this._attributesNeedRefresh === true) { - for ( i; i >= 0; --i ) { - attrs[ keys[ i ] ].forceUpdateAll(); + for (let i = this.attributeCount - 1; i >= 0; --i) { + attrs[keys[i]].forceUpdateAll(); } this._attributesNeedRefresh = false; @@ -738,14 +713,13 @@ SPE.Group.prototype.tick = function( dt ) { } }; - /** * Dipose the geometry and material for the group. * * @return {Group} Group instance. */ -SPE.Group.prototype.dispose = function() { - 'use strict'; +SPE.Group.prototype.dispose = function () { + "use strict"; this.geometry.dispose(); this.material.dispose(); return this; diff --git a/src/core/SPE.utils.js b/src/core/SPE.utils.js index fff01ea..a006b5c 100644 --- a/src/core/SPE.utils.js +++ b/src/core/SPE.utils.js @@ -15,27 +15,37 @@ SPE.utils = { * Boolean type. * @type {String} */ - BOOLEAN: 'boolean', + BOOLEAN: "boolean", /** * String type. * @type {String} */ - STRING: 'string', + STRING: "string", /** * Number type. * @type {String} */ - NUMBER: 'number', + NUMBER: "number", /** * Object type. * @type {String} */ - OBJECT: 'object' + OBJECT: "object", }, + /** random 128-bit number in canonical uuid format. all bits are random. */ + generateUUID: function() { + function random16Hex() { return (0x10000 | Math.random() * 0x10000).toString(16).substr(1); } + return random16Hex() + random16Hex() + + "-" + random16Hex() + + "-" + random16Hex() + + "-" + random16Hex() + + "-" + random16Hex() + random16Hex() + random16Hex(); + }, + /** * Given a value, a type, and a default value to fallback to, * ensure the given argument adheres to the type requesting, @@ -46,13 +56,12 @@ SPE.utils = { * @param {(boolean|string|number|object)} defaultValue A default value to fallback on if the type check fails. * @return {(boolean|string|number|object)} The given value if type check passes, or the default value if it fails. */ - ensureTypedArg: function( arg, type, defaultValue ) { - 'use strict'; + ensureTypedArg: function (arg, type, defaultValue) { + "use strict"; - if ( typeof arg === type ) { + if (typeof arg === type) { return arg; - } - else { + } else { return defaultValue; } }, @@ -69,15 +78,15 @@ SPE.utils = { * @param {(boolean|string|number|object)} defaultValue A default fallback value. * @return {(boolean|string|number|object)} The given value if type check passes, or the default value if it fails. */ - ensureArrayTypedArg: function( arg, type, defaultValue ) { - 'use strict'; + ensureArrayTypedArg: function (arg, type, defaultValue) { + "use strict"; // If the argument being checked is an array, loop through // it and ensure all the values are of the correct type, // falling back to the defaultValue if any aren't. - if ( Array.isArray( arg ) ) { - for ( var i = arg.length - 1; i >= 0; --i ) { - if ( typeof arg[ i ] !== type ) { + if (Array.isArray(arg)) { + for (let i = arg.length - 1; i >= 0; --i) { + if (typeof arg[i] !== type) { return defaultValue; } } @@ -87,7 +96,7 @@ SPE.utils = { // If the arg isn't an array then just fallback to // checking the type. - return this.ensureTypedArg( arg, type, defaultValue ); + return this.ensureTypedArg(arg, type, defaultValue); }, /** @@ -98,13 +107,12 @@ SPE.utils = { * @param {Object} defaultValue A default fallback value if instance check fails * @return {Object} The given value if type check passes, or the default value if it fails. */ - ensureInstanceOf: function( arg, instance, defaultValue ) { - 'use strict'; + ensureInstanceOf: function (arg, instance, defaultValue) { + "use strict"; - if ( instance !== undefined && arg instanceof instance ) { + if (instance !== undefined && arg instanceof instance) { return arg; - } - else { + } else { return defaultValue; } }, @@ -121,15 +129,15 @@ SPE.utils = { * @param {Object} defaultValue A default fallback value if instance check fails * @return {Object} The given value if type check passes, or the default value if it fails. */ - ensureArrayInstanceOf: function( arg, instance, defaultValue ) { - 'use strict'; + ensureArrayInstanceOf: function (arg, instance, defaultValue) { + "use strict"; // If the argument being checked is an array, loop through // it and ensure all the values are of the correct type, // falling back to the defaultValue if any aren't. - if ( Array.isArray( arg ) ) { - for ( var i = arg.length - 1; i >= 0; --i ) { - if ( instance !== undefined && arg[ i ] instanceof instance === false ) { + if (Array.isArray(arg)) { + for (let i = arg.length - 1; i >= 0; --i) { + if (instance !== undefined && arg[i] instanceof instance === false) { return defaultValue; } } @@ -139,7 +147,7 @@ SPE.utils = { // If the arg isn't an array then just fallback to // checking the type. - return this.ensureInstanceOf( arg, instance, defaultValue ); + return this.ensureInstanceOf(arg, instance, defaultValue); }, /** @@ -154,31 +162,31 @@ SPE.utils = { * @param {Number} minLength The minimum length of the array to create. * @param {Number} maxLength The maximum length of the array to create. */ - ensureValueOverLifetimeCompliance: function( property, minLength, maxLength ) { - 'use strict'; + ensureValueOverLifetimeCompliance: function (property, minLength, maxLength) { + "use strict"; minLength = minLength || 3; maxLength = maxLength || 3; // First, ensure both properties are arrays. - if ( Array.isArray( property._value ) === false ) { - property._value = [ property._value ]; + if (Array.isArray(property._value) === false) { + property._value = [property._value]; } - if ( Array.isArray( property._spread ) === false ) { - property._spread = [ property._spread ]; + if (Array.isArray(property._spread) === false) { + property._spread = [property._spread]; } - var valueLength = this.clamp( property._value.length, minLength, maxLength ), - spreadLength = this.clamp( property._spread.length, minLength, maxLength ), - desiredLength = Math.max( valueLength, spreadLength ); + let valueLength = this.clamp(property._value.length, minLength, maxLength); + let spreadLength = this.clamp(property._spread.length, minLength, maxLength); + let desiredLength = Math.max(valueLength, spreadLength); - if ( property._value.length !== desiredLength ) { - property._value = this.interpolateArray( property._value, desiredLength ); + if (property._value.length !== desiredLength) { + property._value = this.interpolateArray(property._value, desiredLength); } - if ( property._spread.length !== desiredLength ) { - property._spread = this.interpolateArray( property._spread, desiredLength ); + if (property._spread.length !== desiredLength) { + property._spread = this.interpolateArray(property._spread, desiredLength); } }, @@ -194,27 +202,26 @@ SPE.utils = { * @param {Number} newLength The length the array should be interpolated to. * @return {Array} The interpolated array. */ - interpolateArray: function( srcArray, newLength ) { - 'use strict'; + interpolateArray: function (srcArray, newLength) { + "use strict"; - var sourceLength = srcArray.length, - newArray = [ typeof srcArray[ 0 ].clone === 'function' ? srcArray[ 0 ].clone() : srcArray[ 0 ] ], - factor = ( sourceLength - 1 ) / ( newLength - 1 ); + let sourceLength = srcArray.length; + let newArray = [typeof srcArray[0].clone === "function" ? srcArray[0].clone() : srcArray[0]]; + let factor = (sourceLength - 1) / (newLength - 1); + for (let i = 1; i < newLength - 1; ++i) { + let f = i * factor; + let before = Math.floor(f); + let after = Math.ceil(f); + let delta = f - before; - for ( var i = 1; i < newLength - 1; ++i ) { - var f = i * factor, - before = Math.floor( f ), - after = Math.ceil( f ), - delta = f - before; - - newArray[ i ] = this.lerpTypeAgnostic( srcArray[ before ], srcArray[ after ], delta ); + newArray[i] = this.lerpTypeAgnostic(srcArray[before], srcArray[after], delta); } newArray.push( - typeof srcArray[ sourceLength - 1 ].clone === 'function' ? - srcArray[ sourceLength - 1 ].clone() : - srcArray[ sourceLength - 1 ] + typeof srcArray[sourceLength - 1].clone === "function" + ? srcArray[sourceLength - 1].clone() + : srcArray[sourceLength - 1] ); return newArray; @@ -227,10 +234,10 @@ SPE.utils = { * @param {Number} max The maximum value. * @return {Number} The clamped number. */ - clamp: function( value, min, max ) { - 'use strict'; + clamp: function (value, min, max) { + "use strict"; - return Math.max( min, Math.min( value, max ) ); + return Math.max(min, Math.min(value, max)); }, /** @@ -242,15 +249,15 @@ SPE.utils = { * @param {Boolean} randomise Whether the value should be randomised. * @return {Number} The result of the operation. */ - zeroToEpsilon: function( value, randomise ) { - 'use strict'; + zeroToEpsilon: function (value, randomise) { + "use strict"; - var epsilon = 0.00001, - result = value; + let epsilon = 0.00001; + let result = value; result = randomise ? Math.random() * epsilon * 10 : epsilon; - if ( value < 0 && value > -epsilon ) { + if (value < 0 && value > -epsilon) { result = -result; } @@ -277,45 +284,40 @@ SPE.utils = { * the start and end arguments aren't a supported type, or * if their types do not match. */ - lerpTypeAgnostic: function( start, end, delta ) { - 'use strict'; + lerpTypeAgnostic: function (start, end, delta) { + "use strict"; - var types = this.types, - out; + let types = this.types; + let out; - if ( typeof start === types.NUMBER && typeof end === types.NUMBER ) { - return start + ( ( end - start ) * delta ); - } - else if ( start instanceof THREE.Vector2 && end instanceof THREE.Vector2 ) { + if (typeof start === types.NUMBER && typeof end === types.NUMBER) { + return start + (end - start) * delta; + } else if (start instanceof THREE.Vector2 && end instanceof THREE.Vector2) { out = start.clone(); - out.x = this.lerp( start.x, end.x, delta ); - out.y = this.lerp( start.y, end.y, delta ); + out.x = this.lerp(start.x, end.x, delta); + out.y = this.lerp(start.y, end.y, delta); return out; - } - else if ( start instanceof THREE.Vector3 && end instanceof THREE.Vector3 ) { + } else if (start instanceof THREE.Vector3 && end instanceof THREE.Vector3) { out = start.clone(); - out.x = this.lerp( start.x, end.x, delta ); - out.y = this.lerp( start.y, end.y, delta ); - out.z = this.lerp( start.z, end.z, delta ); + out.x = this.lerp(start.x, end.x, delta); + out.y = this.lerp(start.y, end.y, delta); + out.z = this.lerp(start.z, end.z, delta); return out; - } - else if ( start instanceof THREE.Vector4 && end instanceof THREE.Vector4 ) { + } else if (start instanceof THREE.Vector4 && end instanceof THREE.Vector4) { out = start.clone(); - out.x = this.lerp( start.x, end.x, delta ); - out.y = this.lerp( start.y, end.y, delta ); - out.z = this.lerp( start.z, end.z, delta ); - out.w = this.lerp( start.w, end.w, delta ); + out.x = this.lerp(start.x, end.x, delta); + out.y = this.lerp(start.y, end.y, delta); + out.z = this.lerp(start.z, end.z, delta); + out.w = this.lerp(start.w, end.w, delta); return out; - } - else if ( start instanceof THREE.Color && end instanceof THREE.Color ) { + } else if (start instanceof THREE.Color && end instanceof THREE.Color) { out = start.clone(); - out.r = this.lerp( start.r, end.r, delta ); - out.g = this.lerp( start.g, end.g, delta ); - out.b = this.lerp( start.b, end.b, delta ); + out.r = this.lerp(start.r, end.r, delta); + out.g = this.lerp(start.g, end.g, delta); + out.b = this.lerp(start.b, end.b, delta); return out; - } - else { - console.warn( 'Invalid argument types, or argument types do not match:', start, end ); + } else { + console.warn("Invalid argument types, or argument types do not match:", start, end); } }, @@ -326,9 +328,9 @@ SPE.utils = { * @param {Number} delta The position to interpolate to. * @return {Number} The result of the lerp operation. */ - lerp: function( start, end, delta ) { - 'use strict'; - return start + ( ( end - start ) * delta ); + lerp: function (start, end, delta) { + "use strict"; + return start + (end - start) * delta; }, /** @@ -338,23 +340,23 @@ SPE.utils = { * @param {Number} multiple The multiple to round to. * @return {Number} The result of the round operation. */ - roundToNearestMultiple: function( n, multiple ) { - 'use strict'; + roundToNearestMultiple: function (n, multiple) { + "use strict"; - var remainder = 0; + let remainder = 0; - if ( multiple === 0 ) { + if (multiple === 0) { return n; } - remainder = Math.abs( n ) % multiple; + remainder = Math.abs(n) % multiple; - if ( remainder === 0 ) { + if (remainder === 0) { return n; } - if ( n < 0 ) { - return -( Math.abs( n ) - remainder ); + if (n < 0) { + return -(Math.abs(n) - remainder); } return n + multiple - remainder; @@ -366,11 +368,11 @@ SPE.utils = { * @param {Array} array The array of values to check equality of. * @return {Boolean} Whether the array's values are all equal or not. */ - arrayValuesAreEqual: function( array ) { - 'use strict'; + arrayValuesAreEqual: function (array) { + "use strict"; - for ( var i = 0; i < array.length - 1; ++i ) { - if ( array[ i ] !== array[ i + 1 ] ) { + for (let i = 0; i < array.length - 1; ++i) { + if (array[i] !== array[i + 1]) { return false; } } @@ -379,10 +381,10 @@ SPE.utils = { }, // colorsAreEqual: function() { - // var colors = Array.prototype.slice.call( arguments ), + // let colors = Array.prototype.slice.call( arguments ), // numColors = colors.length; - // for ( var i = 0, color1, color2; i < numColors - 1; ++i ) { + // for ( let i = 0, color1, color2; i < numColors - 1; ++i ) { // color1 = colors[ i ]; // color2 = colors[ i + 1 ]; @@ -398,7 +400,6 @@ SPE.utils = { // return true; // }, - /** * Given a start value and a spread value, create and return a random * number. @@ -406,13 +407,11 @@ SPE.utils = { * @param {Number} spread The size of the random variance to apply. * @return {Number} A randomised number. */ - randomFloat: function( base, spread ) { - 'use strict'; - return base + spread * ( Math.random() - 0.5 ); + randomFloat: function (base, spread) { + "use strict"; + return base + spread * (Math.random() - 0.5); }, - - /** * Given an SPE.ShaderAttribute instance, and various other settings, * assign values to the attribute's array in a `vec3` format. @@ -423,24 +422,24 @@ SPE.utils = { * @param {Object} spread THREE.Vector3 instance describing the random variance to apply to the start value. * @param {Object} spreadClamp THREE.Vector3 instance describing the multiples to clamp the randomness to. */ - randomVector3: function( attribute, index, base, spread, spreadClamp ) { - 'use strict'; + randomVector3: function (attribute, index, base, spread, spreadClamp) { + "use strict"; - var x = base.x + ( Math.random() * spread.x - ( spread.x * 0.5 ) ), - y = base.y + ( Math.random() * spread.y - ( spread.y * 0.5 ) ), - z = base.z + ( Math.random() * spread.z - ( spread.z * 0.5 ) ); + let x = base.x + (Math.random() * spread.x - spread.x * 0.5); + let y = base.y + (Math.random() * spread.y - spread.y * 0.5); + let z = base.z + (Math.random() * spread.z - spread.z * 0.5); - // var x = this.randomFloat( base.x, spread.x ), + // let x = this.randomFloat( base.x, spread.x ), // y = this.randomFloat( base.y, spread.y ), // z = this.randomFloat( base.z, spread.z ); - if ( spreadClamp ) { - x = -spreadClamp.x * 0.5 + this.roundToNearestMultiple( x, spreadClamp.x ); - y = -spreadClamp.y * 0.5 + this.roundToNearestMultiple( y, spreadClamp.y ); - z = -spreadClamp.z * 0.5 + this.roundToNearestMultiple( z, spreadClamp.z ); + if (spreadClamp) { + x = -spreadClamp.x * 0.5 + this.roundToNearestMultiple(x, spreadClamp.x); + y = -spreadClamp.y * 0.5 + this.roundToNearestMultiple(y, spreadClamp.y); + z = -spreadClamp.z * 0.5 + this.roundToNearestMultiple(z, spreadClamp.z); } - attribute.typedArray.setVec3Components( index, x, y, z ); + attribute.typedArray.setVec3Components(index, x, y, z); }, /** @@ -451,26 +450,24 @@ SPE.utils = { * @param {Object} base THREE.Color instance describing the start color. * @param {Object} spread THREE.Vector3 instance describing the random variance to apply to the start color. */ - randomColor: function( attribute, index, base, spread ) { - 'use strict'; - - var r = base.r + ( Math.random() * spread.x ), - g = base.g + ( Math.random() * spread.y ), - b = base.b + ( Math.random() * spread.z ); + randomColor: function (attribute, index, base, spread) { + "use strict"; - r = this.clamp( r, 0, 1 ); - g = this.clamp( g, 0, 1 ); - b = this.clamp( b, 0, 1 ); + let r = base.r + Math.random() * spread.x; + let g = base.g + Math.random() * spread.y; + let b = base.b + Math.random() * spread.z; + r = this.clamp(r, 0, 1); + g = this.clamp(g, 0, 1); + b = this.clamp(b, 0, 1); - attribute.typedArray.setVec3Components( index, r, g, b ); + attribute.typedArray.setVec3Components(index, r, g, b); }, + randomColorAsHex: (function () { + "use strict"; - randomColorAsHex: ( function() { - 'use strict'; - - var workingColor = new THREE.Color(); + let workingColor = new THREE.Color(); /** * Assigns a random color value, encoded as a hex value in decimal @@ -480,29 +477,29 @@ SPE.utils = { * @param {Object} base THREE.Color instance describing the start color. * @param {Object} spread THREE.Vector3 instance describing the random variance to apply to the start color. */ - return function( attribute, index, base, spread ) { - var numItems = base.length, - colors = []; + return function (attribute, index, base, spread) { + let numItems = base.length; + let colors = []; - for ( var i = 0; i < numItems; ++i ) { - var spreadVector = spread[ i ]; + for (let i = 0; i < numItems; ++i) { + let spreadVector = spread[i]; - workingColor.copy( base[ i ] ); + workingColor.copy(base[i]); - workingColor.r += ( Math.random() * spreadVector.x ) - ( spreadVector.x * 0.5 ); - workingColor.g += ( Math.random() * spreadVector.y ) - ( spreadVector.y * 0.5 ); - workingColor.b += ( Math.random() * spreadVector.z ) - ( spreadVector.z * 0.5 ); + workingColor.r += Math.random() * spreadVector.x - spreadVector.x * 0.5; + workingColor.g += Math.random() * spreadVector.y - spreadVector.y * 0.5; + workingColor.b += Math.random() * spreadVector.z - spreadVector.z * 0.5; - workingColor.r = this.clamp( workingColor.r, 0, 1 ); - workingColor.g = this.clamp( workingColor.g, 0, 1 ); - workingColor.b = this.clamp( workingColor.b, 0, 1 ); + workingColor.r = this.clamp(workingColor.r, 0, 1); + workingColor.g = this.clamp(workingColor.g, 0, 1); + workingColor.b = this.clamp(workingColor.b, 0, 1); - colors.push( workingColor.getHex() ); + colors.push(workingColor.getHex()); } - attribute.typedArray.setVec4Components( index, colors[ 0 ], colors[ 1 ], colors[ 2 ], colors[ 3 ] ); + attribute.typedArray.setVec4Components(index, colors[0], colors[1], colors[2], colors[3]); }; - }() ), + })(), /** * Given an SPE.ShaderAttribute instance, and various other settings, @@ -513,13 +510,13 @@ SPE.utils = { * @param {Object} start THREE.Vector3 instance describing the start line position. * @param {Object} end THREE.Vector3 instance describing the end line position. */ - randomVector3OnLine: function( attribute, index, start, end ) { - 'use strict'; - var pos = start.clone(); + randomVector3OnLine: function (attribute, index, start, end) { + "use strict"; + let pos = start.clone(); - pos.lerp( end, Math.random() ); + pos.lerp(end, Math.random()); - attribute.typedArray.setVec3Components( index, pos.x, pos.y, pos.z ); + attribute.typedArray.setVec3Components(index, pos.x, pos.y, pos.z); }, /** @@ -543,29 +540,33 @@ SPE.utils = { * @param {Object} radiusScale THREE.Vector3 instance describing the scale of each axis of the sphere. * @param {Number} radiusSpreadClamp What numeric multiple the projected value should be clamped to. */ - randomVector3OnSphere: function( - attribute, index, base, radius, radiusSpread, radiusScale, radiusSpreadClamp, distributionClamp + randomVector3OnSphere: function ( + attribute, + index, + base, + radius, + radiusSpread, + radiusScale, + radiusSpreadClamp, + distributionClamp ) { - 'use strict'; - - var depth = 2 * Math.random() - 1, - t = 6.2832 * Math.random(), - r = Math.sqrt( 1 - depth * depth ), - rand = this.randomFloat( radius, radiusSpread ), - x = 0, - y = 0, - z = 0; - - - if ( radiusSpreadClamp ) { - rand = Math.round( rand / radiusSpreadClamp ) * radiusSpreadClamp; + "use strict"; + + let depth = 2 * Math.random() - 1; + let t = 6.2832 * Math.random(); + let r = Math.sqrt(1 - depth * depth); + let rand = this.randomFloat(radius, radiusSpread); + let x = 0; + let y = 0; + let z = 0; + + if (radiusSpreadClamp) { + rand = Math.round(rand / radiusSpreadClamp) * radiusSpreadClamp; } - - // Set position on sphere - x = r * Math.cos( t ) * rand; - y = r * Math.sin( t ) * rand; + x = r * Math.cos(t) * rand; + y = r * Math.sin(t) * rand; z = depth * rand; // Apply radius scale to this position @@ -579,16 +580,14 @@ SPE.utils = { z += base.z; // Set the values in the typed array. - attribute.typedArray.setVec3Components( index, x, y, z ); + attribute.typedArray.setVec3Components(index, x, y, z); }, - seededRandom: function( seed ) { - var x = Math.sin( seed ) * 10000; - return x - ( x | 0 ); + seededRandom: function (seed) { + let x = Math.sin(seed) * 10000; + return x - (x | 0); }, - - /** * Assigns a random vector 3 value to an SPE.ShaderAttribute instance, projecting the * given values onto a 2d-disc. @@ -601,22 +600,22 @@ SPE.utils = { * @param {Object} radiusScale THREE.Vector3 instance describing the scale of each axis of the disc. The z-component is ignored. * @param {Number} radiusSpreadClamp What numeric multiple the projected value should be clamped to. */ - randomVector3OnDisc: function( attribute, index, base, radius, radiusSpread, radiusScale, radiusSpreadClamp ) { - 'use strict'; + randomVector3OnDisc: function (attribute, index, base, radius, radiusSpread, radiusScale, radiusSpreadClamp) { + "use strict"; - var t = 6.2832 * Math.random(), - rand = Math.abs( this.randomFloat( radius, radiusSpread ) ), - x = 0, - y = 0, - z = 0; + let t = 6.2832 * Math.random(); + let rand = Math.abs(this.randomFloat(radius, radiusSpread)); + let x = 0; + let y = 0; + let z = 0; - if ( radiusSpreadClamp ) { - rand = Math.round( rand / radiusSpreadClamp ) * radiusSpreadClamp; + if (radiusSpreadClamp) { + rand = Math.round(rand / radiusSpreadClamp) * radiusSpreadClamp; } // Set position on sphere - x = Math.cos( t ) * rand; - y = Math.sin( t ) * rand; + x = Math.cos(t) * rand; + y = Math.sin(t) * rand; // Apply radius scale to this position x *= radiusScale.x; @@ -628,13 +627,13 @@ SPE.utils = { z += base.z; // Set the values in the typed array. - attribute.typedArray.setVec3Components( index, x, y, z ); + attribute.typedArray.setVec3Components(index, x, y, z); }, - randomDirectionVector3OnSphere: ( function() { - 'use strict'; + randomDirectionVector3OnSphere: (function () { + "use strict"; - var v = new THREE.Vector3(); + let v = new THREE.Vector3(); /** * Given an SPE.ShaderAttribute instance, create a direction vector from the given @@ -649,24 +648,23 @@ SPE.utils = { * @param {Number} speed The magnitude to apply to the vector. * @param {Number} speedSpread The amount of randomness to apply to the magnitude. */ - return function( attribute, index, posX, posY, posZ, emitterPosition, speed, speedSpread ) { - v.copy( emitterPosition ); + return function (attribute, index, posX, posY, posZ, emitterPosition, speed, speedSpread) { + v.copy(emitterPosition); v.x -= posX; v.y -= posY; v.z -= posZ; - v.normalize().multiplyScalar( -this.randomFloat( speed, speedSpread ) ); + v.normalize().multiplyScalar(-this.randomFloat(speed, speedSpread)); - attribute.typedArray.setVec3Components( index, v.x, v.y, v.z ); + attribute.typedArray.setVec3Components(index, v.x, v.y, v.z); }; - }() ), - + })(), - randomDirectionVector3OnDisc: ( function() { - 'use strict'; + randomDirectionVector3OnDisc: (function () { + "use strict"; - var v = new THREE.Vector3(); + let v = new THREE.Vector3(); /** * Given an SPE.ShaderAttribute instance, create a direction vector from the given @@ -681,26 +679,26 @@ SPE.utils = { * @param {Number} speed The magnitude to apply to the vector. * @param {Number} speedSpread The amount of randomness to apply to the magnitude. */ - return function( attribute, index, posX, posY, posZ, emitterPosition, speed, speedSpread ) { - v.copy( emitterPosition ); + return function (attribute, index, posX, posY, posZ, emitterPosition, speed, speedSpread) { + v.copy(emitterPosition); v.x -= posX; v.y -= posY; v.z -= posZ; - v.normalize().multiplyScalar( -this.randomFloat( speed, speedSpread ) ); + v.normalize().multiplyScalar(-this.randomFloat(speed, speedSpread)); - attribute.typedArray.setVec3Components( index, v.x, v.y, 0 ); + attribute.typedArray.setVec3Components(index, v.x, v.y, 0); }; - }() ), + })(), - getPackedRotationAxis: ( function() { - 'use strict'; + getPackedRotationAxis: (function () { + "use strict"; - var v = new THREE.Vector3(), - vSpread = new THREE.Vector3(), - c = new THREE.Color(), - addOne = new THREE.Vector3( 1, 1, 1 ); + let v = new THREE.Vector3(); + let vSpread = new THREE.Vector3(); + let c = new THREE.Color(); + let addOne = new THREE.Vector3(1, 1, 1); /** * Given a rotation axis, and a rotation axis spread vector, @@ -710,23 +708,23 @@ SPE.utils = { * @param {Object} axisSpread THREE.Vector3 instance describing the amount of randomness to apply to the rotation axis. * @return {Number} The packed rotation axis, with randomness. */ - return function( axis, axisSpread ) { - v.copy( axis ).normalize(); - vSpread.copy( axisSpread ).normalize(); + return function (axis, axisSpread) { + v.copy(axis).normalize(); + vSpread.copy(axisSpread).normalize(); - v.x += ( -axisSpread.x * 0.5 ) + ( Math.random() * axisSpread.x ); - v.y += ( -axisSpread.y * 0.5 ) + ( Math.random() * axisSpread.y ); - v.z += ( -axisSpread.z * 0.5 ) + ( Math.random() * axisSpread.z ); + v.x += -axisSpread.x * 0.5 + Math.random() * axisSpread.x; + v.y += -axisSpread.y * 0.5 + Math.random() * axisSpread.y; + v.z += -axisSpread.z * 0.5 + Math.random() * axisSpread.z; // v.x = Math.abs( v.x ); // v.y = Math.abs( v.y ); // v.z = Math.abs( v.z ); - v.normalize().add( addOne ).multiplyScalar( 0.5 ); + v.normalize().add(addOne).multiplyScalar(0.5); - c.setRGB( v.x, v.y, v.z ); + c.setRGB(v.x, v.y, v.z); return c.getHex(); }; - }() ) + })(), }; diff --git a/src/helpers/SPE.ShaderAttribute.js b/src/helpers/SPE.ShaderAttribute.js index 95e1deb..6c0ac77 100644 --- a/src/helpers/SPE.ShaderAttribute.js +++ b/src/helpers/SPE.ShaderAttribute.js @@ -7,20 +7,20 @@ * @param {Boolean=} dynamicBuffer Whether this buffer attribute should be marked as dynamic or not. * @param {Function=} arrayType A reference to a TypedArray constructor. Defaults to Float32Array if none provided. */ -SPE.ShaderAttribute = function( type, dynamicBuffer, arrayType ) { - 'use strict'; +SPE.ShaderAttribute = function (type, dynamicBuffer, arrayType) { + "use strict"; - var typeMap = SPE.ShaderAttribute.typeSizeMap; + let typeMap = SPE.ShaderAttribute.typeSizeMap; - this.type = typeof type === 'string' && typeMap.hasOwnProperty( type ) ? type : 'f'; - this.componentSize = typeMap[ this.type ]; - this.arrayType = arrayType || Float32Array; - this.typedArray = null; - this.bufferAttribute = null; - this.dynamicBuffer = !!dynamicBuffer; + this.type = typeof type === "string" && typeMap.hasOwnProperty(type) ? type : "f"; + this.componentSize = typeMap[this.type]; + this.arrayType = arrayType || Float32Array; + this.typedArray = null; + this.bufferAttribute = null; + this.dynamicBuffer = !!dynamicBuffer; - this.updateMin = 0; - this.updateMax = 0; + this.updateMin = 0; + this.updateMax = 0; }; SPE.ShaderAttribute.constructor = SPE.ShaderAttribute; @@ -30,47 +30,47 @@ SPE.ShaderAttribute.constructor = SPE.ShaderAttribute; * @enum {Number} */ SPE.ShaderAttribute.typeSizeMap = { - /** - * Float - * @type {Number} - */ - f: 1, - - /** - * Vec2 - * @type {Number} - */ - v2: 2, - - /** - * Vec3 - * @type {Number} - */ - v3: 3, - - /** - * Vec4 - * @type {Number} - */ - v4: 4, - - /** - * Color - * @type {Number} - */ - c: 3, - - /** - * Mat3 - * @type {Number} - */ - m3: 9, - - /** - * Mat4 - * @type {Number} - */ - m4: 16 + /** + * Float + * @type {Number} + */ + f: 1, + + /** + * Vec2 + * @type {Number} + */ + v2: 2, + + /** + * Vec3 + * @type {Number} + */ + v3: 3, + + /** + * Vec4 + * @type {Number} + */ + v4: 4, + + /** + * Color + * @type {Number} + */ + c: 3, + + /** + * Mat3 + * @type {Number} + */ + m3: 9, + + /** + * Mat4 + * @type {Number} + */ + m4: 16, }; /** @@ -80,45 +80,41 @@ SPE.ShaderAttribute.typeSizeMap = { * @param {Number} min The start of the range to mark as needing an update. * @param {Number} max The end of the range to mark as needing an update. */ -SPE.ShaderAttribute.prototype.setUpdateRange = function( min, max ) { - 'use strict'; +SPE.ShaderAttribute.prototype.setUpdateRange = function (min, max) { + "use strict"; - this.updateMin = Math.min( min * this.componentSize, this.updateMin * this.componentSize ); - this.updateMax = Math.max( max * this.componentSize, this.updateMax * this.componentSize ); + this.updateMin = Math.min(min * this.componentSize, this.updateMin * this.componentSize); + this.updateMax = Math.max(max * this.componentSize, this.updateMax * this.componentSize); }; /** * Calculate the number of indices that this attribute should mark as needing * updating. Also marks the attribute as needing an update. */ -SPE.ShaderAttribute.prototype.flagUpdate = function() { - 'use strict'; +SPE.ShaderAttribute.prototype.flagUpdate = function () { + "use strict"; - var attr = this.bufferAttribute, - range = attr.updateRange; + let attr = this.bufferAttribute; + let range = attr.addUpdateRange; - range.offset = this.updateMin; - range.count = Math.min( ( this.updateMax - this.updateMin ) + this.componentSize, this.typedArray.array.length ); - attr.needsUpdate = true; + range.offset = this.updateMin; + range.count = Math.min(this.updateMax - this.updateMin + this.componentSize, this.typedArray.array.length); + attr.needsUpdate = true; }; - - /** * Reset the index update counts for this attribute */ -SPE.ShaderAttribute.prototype.resetUpdateRange = function() { - 'use strict'; +SPE.ShaderAttribute.prototype.resetUpdateRange = function () { + "use strict"; - this.updateMin = 0; - this.updateMax = 0; + this.updateMin = 0; + this.updateMax = 0; }; -SPE.ShaderAttribute.prototype.resetDynamic = function() { - 'use strict'; - this.bufferAttribute.usage = this.dynamicBuffer ? - THREE.DynamicDrawUsage : - THREE.StaticDrawUsage; +SPE.ShaderAttribute.prototype.resetDynamic = function () { + "use strict"; + this.bufferAttribute.usage = this.dynamicBuffer ? THREE.DynamicDrawUsage : THREE.StaticDrawUsage; }; /** @@ -126,25 +122,25 @@ SPE.ShaderAttribute.prototype.resetDynamic = function() { * @param {Number} start The start index of the splice. Will be multiplied by the number of components for this attribute. * @param {Number} end The end index of the splice. Will be multiplied by the number of components for this attribute. */ -SPE.ShaderAttribute.prototype.splice = function( start, end ) { - 'use strict'; +SPE.ShaderAttribute.prototype.splice = function (start, end) { + "use strict"; - this.typedArray.splice( start, end ); + this.typedArray.splice(start, end); - // Reset the reference to the attribute's typed array - // since it has probably changed. - this.forceUpdateAll(); + // Reset the reference to the attribute's typed array + // since it has probably changed. + this.forceUpdateAll(); }; -SPE.ShaderAttribute.prototype.forceUpdateAll = function() { - 'use strict'; +SPE.ShaderAttribute.prototype.forceUpdateAll = function () { + "use strict"; - this.bufferAttribute.array = this.typedArray.array; - this.bufferAttribute.updateRange.offset = 0; - this.bufferAttribute.updateRange.count = -1; + this.bufferAttribute.array = this.typedArray.array; + this.bufferAttribute.addUpdateRange.offset = 0; + this.bufferAttribute.addUpdateRange.count = -1; - this.bufferAttribute.usage = THREE.StaticDrawUsage; - this.bufferAttribute.needsUpdate = true; + this.bufferAttribute.usage = THREE.StaticDrawUsage; + this.bufferAttribute.needsUpdate = true; }; /** @@ -156,27 +152,26 @@ SPE.ShaderAttribute.prototype.forceUpdateAll = function() { * * @param {Number} size The size of the typed array to create or update to. */ -SPE.ShaderAttribute.prototype._ensureTypedArray = function( size ) { - 'use strict'; - - // Condition that's most likely to be true at the top: no change. - if ( this.typedArray !== null && this.typedArray.size === size * this.componentSize ) { - return; - } - - // Resize the array if we need to, telling the TypedArrayHelper to - // ignore it's component size when evaluating size. - else if ( this.typedArray !== null && this.typedArray.size !== size ) { - this.typedArray.setSize( size ); - } - - // This condition should only occur once in an attribute's lifecycle. - else if ( this.typedArray === null ) { - this.typedArray = new SPE.TypedArrayHelper( this.arrayType, size, this.componentSize ); - } +SPE.ShaderAttribute.prototype._ensureTypedArray = function (size) { + "use strict"; + + // Condition that's most likely to be true at the top: no change. + if (this.typedArray !== null && this.typedArray.size === size * this.componentSize) { + return; + } + + // Resize the array if we need to, telling the TypedArrayHelper to + // ignore it's component size when evaluating size. + else if (this.typedArray !== null && this.typedArray.size !== size) { + this.typedArray.setSize(size); + } + + // This condition should only occur once in an attribute's lifecycle. + else if (this.typedArray === null) { + this.typedArray = new SPE.TypedArrayHelper(this.arrayType, size, this.componentSize); + } }; - /** * Creates a THREE.BufferAttribute instance if one doesn't exist already. * @@ -186,48 +181,46 @@ SPE.ShaderAttribute.prototype._ensureTypedArray = function( size ) { * * @param {Number} size The size of the typed array to create if one doesn't exist, or resize existing array to. */ -SPE.ShaderAttribute.prototype._createBufferAttribute = function( size ) { - 'use strict'; - - // Make sure the typedArray is present and correct. - this._ensureTypedArray( size ); - - // Don't create it if it already exists, but do - // flag that it needs updating on the next render - // cycle. - if ( this.bufferAttribute !== null ) { - this.bufferAttribute.array = this.typedArray.array; - - // Since THREE.js version 81, dynamic count calculation was removed - // so I need to do it manually here. - // - // In the next minor release, I may well remove this check and force - // dependency on THREE r81+. - if ( parseFloat( THREE.REVISION ) >= 81 ) { - this.bufferAttribute.count = this.bufferAttribute.array.length / this.bufferAttribute.itemSize; - } - - this.bufferAttribute.needsUpdate = true; - return; - } - - this.bufferAttribute = new THREE.BufferAttribute( this.typedArray.array, this.componentSize ); - - this.bufferAttribute.usage = this.dynamicBuffer ? - THREE.DynamicDrawUsage : - THREE.StaticDrawUsage; +SPE.ShaderAttribute.prototype._createBufferAttribute = function (size) { + "use strict"; + + // Make sure the typedArray is present and correct. + this._ensureTypedArray(size); + + // Don't create it if it already exists, but do + // flag that it needs updating on the next render + // cycle. + if (this.bufferAttribute !== null) { + this.bufferAttribute.array = this.typedArray.array; + + // Since THREE.js version 81, dynamic count calculation was removed + // so I need to do it manually here. + // + // In the next minor release, I may well remove this check and force + // dependency on THREE r81+. + if (parseFloat(THREE.REVISION) >= 81) { + this.bufferAttribute.count = this.bufferAttribute.array.length / this.bufferAttribute.itemSize; + } + + this.bufferAttribute.needsUpdate = true; + return; + } + + this.bufferAttribute = new THREE.BufferAttribute(this.typedArray.array, this.componentSize); + + this.bufferAttribute.usage = this.dynamicBuffer ? THREE.DynamicDrawUsage : THREE.StaticDrawUsage; }; /** * Returns the length of the typed array associated with this attribute. * @return {Number} The length of the typed array. Will be 0 if no typed array has been created yet. */ -SPE.ShaderAttribute.prototype.getLength = function() { - 'use strict'; +SPE.ShaderAttribute.prototype.getLength = function () { + "use strict"; - if ( this.typedArray === null ) { - return 0; - } + if (this.typedArray === null) { + return 0; + } - return this.typedArray.array.length; + return this.typedArray.array.length; }; diff --git a/src/helpers/SPE.TypedArrayHelper.js b/src/helpers/SPE.TypedArrayHelper.js index 8eb76fa..658f5db 100644 --- a/src/helpers/SPE.TypedArrayHelper.js +++ b/src/helpers/SPE.TypedArrayHelper.js @@ -13,13 +13,13 @@ * @param {Number} componentSize The number of components per-value (ie. 3 for a vec3, 9 for a Mat3, etc.) * @param {Number} indexOffset The index in the array from which to start assigning values. Default `0` if none provided */ -SPE.TypedArrayHelper = function( TypedArrayConstructor, size, componentSize, indexOffset ) { - 'use strict'; +SPE.TypedArrayHelper = function (TypedArrayConstructor, size, componentSize, indexOffset) { + "use strict"; this.componentSize = componentSize || 1; - this.size = ( size || 1 ); + this.size = size || 1; this.TypedArrayConstructor = TypedArrayConstructor || Float32Array; - this.array = new TypedArrayConstructor( size * this.componentSize ); + this.array = new TypedArrayConstructor(size * this.componentSize); this.indexOffset = indexOffset || 0; }; @@ -35,23 +35,21 @@ SPE.TypedArrayHelper.constructor = SPE.TypedArrayHelper; * * @param {Number} size The new size of the array. */ -SPE.TypedArrayHelper.prototype.setSize = function( size, noComponentMultiply ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.setSize = function (size, noComponentMultiply) { + "use strict"; - var currentArraySize = this.array.length; + let currentArraySize = this.array.length; - if ( !noComponentMultiply ) { + if (!noComponentMultiply) { size = size * this.componentSize; } - if ( size < currentArraySize ) { - return this.shrink( size ); - } - else if ( size > currentArraySize ) { - return this.grow( size ); - } - else { - console.info( 'TypedArray is already of size:', size + '.', 'Will not resize.' ); + if (size < currentArraySize) { + return this.shrink(size); + } else if (size > currentArraySize) { + return this.grow(size); + } else { + console.info("TypedArray is already of size:", size + ".", "Will not resize."); } }; @@ -61,10 +59,10 @@ SPE.TypedArrayHelper.prototype.setSize = function( size, noComponentMultiply ) { * @param {Number} size The new size of the typed array. Must be smaller than `this.array.length`. * @return {SPE.TypedArrayHelper} Instance of this class. */ -SPE.TypedArrayHelper.prototype.shrink = function( size ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.shrink = function (size) { + "use strict"; - this.array = this.array.subarray( 0, size ); + this.array = this.array.subarray(0, size); this.size = size; return this; }; @@ -74,48 +72,46 @@ SPE.TypedArrayHelper.prototype.shrink = function( size ) { * @param {Number} size The new size of the typed array. Must be larger than `this.array.length`. * @return {SPE.TypedArrayHelper} Instance of this class. */ -SPE.TypedArrayHelper.prototype.grow = function( size ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.grow = function (size) { + "use strict"; - var existingArray = this.array, - newArray = new this.TypedArrayConstructor( size ); + let existingArray = this.array; + let newArray = new this.TypedArrayConstructor(size); - newArray.set( existingArray ); + newArray.set(existingArray); this.array = newArray; this.size = size; return this; }; - /** * Perform a splice operation on this array's buffer. * @param {Number} start The start index of the splice. Will be multiplied by the number of components for this attribute. * @param {Number} end The end index of the splice. Will be multiplied by the number of components for this attribute. * @returns {Object} The SPE.TypedArrayHelper instance. */ -SPE.TypedArrayHelper.prototype.splice = function( start, end ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.splice = function (start, end) { + "use strict"; start *= this.componentSize; end *= this.componentSize; - var data = [], - array = this.array, - size = array.length; + let data = []; + let array = this.array; + let size = array.length; - for ( var i = 0; i < size; ++i ) { - if ( i < start || i >= end ) { - data.push( array[ i ] ); + for (let i = 0; i < size; ++i) { + if (i < start || i >= end) { + data.push(array[i]); } // array[ i ] = 0; } - this.setFromArray( 0, data ); + this.setFromArray(0, data); return this; }; - /** * Copies from the given TypedArray into this one, using the index argument * as the start position. Alias for `TypedArray.set`. Will automatically resize @@ -125,20 +121,19 @@ SPE.TypedArrayHelper.prototype.splice = function( start, end ) { * @param {TypedArray} array The array from which to copy; the source array. * @return {SPE.TypedArrayHelper} Instance of this class. */ -SPE.TypedArrayHelper.prototype.setFromArray = function( index, array ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.setFromArray = function (index, array) { + "use strict"; - var sourceArraySize = array.length, + let sourceArraySize = array.length, newSize = index + sourceArraySize; - if ( newSize > this.array.length ) { - this.grow( newSize ); - } - else if ( newSize < this.array.length ) { - this.shrink( newSize ); + if (newSize > this.array.length) { + this.grow(newSize); + } else if (newSize < this.array.length) { + this.shrink(newSize); } - this.array.set( array, this.indexOffset + index ); + this.array.set(array, this.indexOffset + index); return this; }; @@ -150,10 +145,10 @@ SPE.TypedArrayHelper.prototype.setFromArray = function( index, array ) { * @param {Vector2} vec2 Any object that has `x` and `y` properties. * @return {SPE.TypedArrayHelper} Instance of this class. */ -SPE.TypedArrayHelper.prototype.setVec2 = function( index, vec2 ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.setVec2 = function (index, vec2) { + "use strict"; - return this.setVec2Components( index, vec2.x, vec2.y ); + return this.setVec2Components(index, vec2.x, vec2.y); }; /** @@ -164,14 +159,14 @@ SPE.TypedArrayHelper.prototype.setVec2 = function( index, vec2 ) { * @param {Number} y The Vec2's `y` component. * @return {SPE.TypedArrayHelper} Instance of this class. */ -SPE.TypedArrayHelper.prototype.setVec2Components = function( index, x, y ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.setVec2Components = function (index, x, y) { + "use strict"; - var array = this.array, - i = this.indexOffset + ( index * this.componentSize ); + let array = this.array; + let i = this.indexOffset + index * this.componentSize; - array[ i ] = x; - array[ i + 1 ] = y; + array[i] = x; + array[i + 1] = y; return this; }; @@ -182,10 +177,10 @@ SPE.TypedArrayHelper.prototype.setVec2Components = function( index, x, y ) { * @param {Vector3} vec2 Any object that has `x`, `y`, and `z` properties. * @return {SPE.TypedArrayHelper} Instance of this class. */ -SPE.TypedArrayHelper.prototype.setVec3 = function( index, vec3 ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.setVec3 = function (index, vec3) { + "use strict"; - return this.setVec3Components( index, vec3.x, vec3.y, vec3.z ); + return this.setVec3Components(index, vec3.x, vec3.y, vec3.z); }; /** @@ -197,15 +192,15 @@ SPE.TypedArrayHelper.prototype.setVec3 = function( index, vec3 ) { * @param {Number} z The Vec3's `z` component. * @return {SPE.TypedArrayHelper} Instance of this class. */ -SPE.TypedArrayHelper.prototype.setVec3Components = function( index, x, y, z ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.setVec3Components = function (index, x, y, z) { + "use strict"; - var array = this.array, - i = this.indexOffset + ( index * this.componentSize ); + let array = this.array; + let i = this.indexOffset + index * this.componentSize; - array[ i ] = x; - array[ i + 1 ] = y; - array[ i + 2 ] = z; + array[i] = x; + array[i + 1] = y; + array[i + 2] = z; return this; }; @@ -216,10 +211,10 @@ SPE.TypedArrayHelper.prototype.setVec3Components = function( index, x, y, z ) { * @param {Vector4} vec2 Any object that has `x`, `y`, `z`, and `w` properties. * @return {SPE.TypedArrayHelper} Instance of this class. */ -SPE.TypedArrayHelper.prototype.setVec4 = function( index, vec4 ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.setVec4 = function (index, vec4) { + "use strict"; - return this.setVec4Components( index, vec4.x, vec4.y, vec4.z, vec4.w ); + return this.setVec4Components(index, vec4.x, vec4.y, vec4.z, vec4.w); }; /** @@ -232,16 +227,16 @@ SPE.TypedArrayHelper.prototype.setVec4 = function( index, vec4 ) { * @param {Number} w The Vec4's `w` component. * @return {SPE.TypedArrayHelper} Instance of this class. */ -SPE.TypedArrayHelper.prototype.setVec4Components = function( index, x, y, z, w ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.setVec4Components = function (index, x, y, z, w) { + "use strict"; - var array = this.array, - i = this.indexOffset + ( index * this.componentSize ); + let array = this.array; + let i = this.indexOffset + index * this.componentSize; - array[ i ] = x; - array[ i + 1 ] = y; - array[ i + 2 ] = z; - array[ i + 3 ] = w; + array[i] = x; + array[i + 1] = y; + array[i + 2] = z; + array[i + 3] = w; return this; }; @@ -252,10 +247,10 @@ SPE.TypedArrayHelper.prototype.setVec4Components = function( index, x, y, z, w ) * @param {Matrix3} mat3 The 3x3 matrix to set from. Must have a TypedArray property named `elements` to copy from. * @return {SPE.TypedArrayHelper} Instance of this class. */ -SPE.TypedArrayHelper.prototype.setMat3 = function( index, mat3 ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.setMat3 = function (index, mat3) { + "use strict"; - return this.setFromArray( this.indexOffset + ( index * this.componentSize ), mat3.elements ); + return this.setFromArray(this.indexOffset + index * this.componentSize, mat3.elements); }; /** @@ -265,10 +260,10 @@ SPE.TypedArrayHelper.prototype.setMat3 = function( index, mat3 ) { * @param {Matrix4} mat3 The 4x4 matrix to set from. Must have a TypedArray property named `elements` to copy from. * @return {SPE.TypedArrayHelper} Instance of this class. */ -SPE.TypedArrayHelper.prototype.setMat4 = function( index, mat4 ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.setMat4 = function (index, mat4) { + "use strict"; - return this.setFromArray( this.indexOffset + ( index * this.componentSize ), mat4.elements ); + return this.setFromArray(this.indexOffset + index * this.componentSize, mat4.elements); }; /** @@ -278,10 +273,10 @@ SPE.TypedArrayHelper.prototype.setMat4 = function( index, mat4 ) { * @param {Color} color Any object that has `r`, `g`, and `b` properties. * @return {SPE.TypedArrayHelper} Instance of this class. */ -SPE.TypedArrayHelper.prototype.setColor = function( index, color ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.setColor = function (index, color) { + "use strict"; - return this.setVec3Components( index, color.r, color.g, color.b ); + return this.setVec3Components(index, color.r, color.g, color.b); }; /** @@ -291,10 +286,10 @@ SPE.TypedArrayHelper.prototype.setColor = function( index, color ) { * @param {Number} numericValue The number to assign to this index in the array. * @return {SPE.TypedArrayHelper} Instance of this class. */ -SPE.TypedArrayHelper.prototype.setNumber = function( index, numericValue ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.setNumber = function (index, numericValue) { + "use strict"; - this.array[ this.indexOffset + ( index * this.componentSize ) ] = numericValue; + this.array[this.indexOffset + index * this.componentSize] = numericValue; return this; }; @@ -308,10 +303,10 @@ SPE.TypedArrayHelper.prototype.setNumber = function( index, numericValue ) { * @param {Number} index The index in the array to fetch. * @return {Number} The value at the given index. */ -SPE.TypedArrayHelper.prototype.getValueAtIndex = function( index ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.getValueAtIndex = function (index) { + "use strict"; - return this.array[ this.indexOffset + index ]; + return this.array[this.indexOffset + index]; }; /** @@ -324,8 +319,8 @@ SPE.TypedArrayHelper.prototype.getValueAtIndex = function( index ) { * @param {Number} index The index in the array to fetch. * @return {TypedArray} The component value at the given index. */ -SPE.TypedArrayHelper.prototype.getComponentValueAtIndex = function( index ) { - 'use strict'; +SPE.TypedArrayHelper.prototype.getComponentValueAtIndex = function (index) { + "use strict"; - return this.array.subarray( this.indexOffset + ( index * this.componentSize ) ); -}; \ No newline at end of file + return this.array.subarray(this.indexOffset + index * this.componentSize); +}; diff --git a/src/shaders/SPE.shaderChunks.js b/src/shaders/SPE.shaderChunks.js index 2860b75..92c443e 100644 --- a/src/shaders/SPE.shaderChunks.js +++ b/src/shaders/SPE.shaderChunks.js @@ -117,6 +117,9 @@ SPE.shaderChunks = { '}', ].join( '\n' ), + + // ORIGINAL floatOverLifetime + /* floatOverLifetime: [ 'float getFloatOverLifetime( in float positionInTime, in vec4 attr ) {', ' highp float value = 0.0;', @@ -143,6 +146,30 @@ SPE.shaderChunks = { ' return value;', '}', ].join( '\n' ), + */ + + + // MODIFIED floatOverLifetime + floatOverLifetime: [ + 'float getFloatOverLifetime( in float positionInTime, in vec4 attr ) {', + ' const int VEC4_SIZE = 4;', + ' float value = 0.0;', + ' float deltaAge = clamp(positionInTime * float(VEC4_SIZE - 2), 0.0, float(VEC4_SIZE - 2));', + '', + ' if (deltaAge == 0.0) return attr[0];', + ' if (deltaAge >= float(VEC4_SIZE - 1)) return attr[VEC4_SIZE - 1];', + '', + ' for( int i = 0; i < VEC4_SIZE - 1; ++i ) {', + ' float fIndex = float( i );', + ' float shouldApplyValue = and( when_gt( deltaAge, fIndex ), when_le( deltaAge, fIndex + 1.0 ) );', + ' if(i <= 3) {', + ' value += shouldApplyValue * mix( attr[ i ], attr[ i + 1 ], deltaAge - fIndex );', + ' }', + ' }', + '', + ' return value;', + '}', + ].join( '\n' ), colorOverLifetime: [ 'vec3 getColorOverLifetime( in float positionInTime, in vec3 color1, in vec3 color2, in vec3 color3, in vec3 color4 ) {',