Prechádzať zdrojové kódy

Examples: Remove THREE.Fire.

Mugen87 4 rokov pred
rodič
commit
626628c134

+ 0 - 2
examples/files.js

@@ -297,7 +297,6 @@ var files = {
 		"webgl_custom_attributes_points",
 		"webgl_custom_attributes_points2",
 		"webgl_custom_attributes_points3",
-		"webgl_fire",
 		"webgl_gpgpu_birds",
 		"webgl_gpgpu_birds_gltf",
 		"webgl_gpgpu_water",
@@ -494,7 +493,6 @@ var tags = {
 	"webgl_postprocessing_ssao": [ "ambient occlusion" ],
 	"webgl_postprocessing_unreal_bloom": [ "glow" ],
 	"webgl_postprocessing_unreal_bloom_selective": [ "glow" ],
-	"webgl_fire": [ "smoke" ],
 	"webgl_materials_modified": [ "onBeforeCompile" ],
 	"webgl_shadowmap_csm": [ "cascade" ],
 	"webgl_shadowmap_pcss": [ "soft" ],

+ 0 - 1044
examples/js/objects/Fire.js

@@ -1,1044 +0,0 @@
-console.warn( "THREE.Fire: As part of the transition to ES6 Modules, the files in 'examples/js' were deprecated in May 2020 (r117) and will be deleted in December 2020 (r124). You can find more information about developing using ES6 Modules in https://threejs.org/docs/#manual/en/introduction/Installation." );
-/**
- * Based on research paper "Real-Time Fluid Dynamics for Games" by Jos Stam
- * http://www.dgp.toronto.edu/people/stam/reality/Research/pdf/GDC03.pdf
- *
- */
-
-THREE.Fire = function ( geometry, options ) {
-
-	THREE.Mesh.call( this, geometry );
-
-	this.type = 'Fire';
-
-	this.clock = new THREE.Clock();
-
-	options = options || {};
-
-	var textureWidth = options.textureWidth || 512;
-	var textureHeight = options.textureHeight || 512;
-	var oneOverWidth = 1.0 / textureWidth;
-	var oneOverHeight = 1.0 / textureHeight;
-
-	var debug = ( options.debug === undefined ) ? false : options.debug;
-	this.color1 = options.color1 || new THREE.Color( 0xffffff );
-	this.color2 = options.color2 || new THREE.Color( 0xffa000 );
-	this.color3 = options.color3 || new THREE.Color( 0x000000 );
-	this.colorBias = ( options.colorBias === undefined ) ? 0.8 : options.colorBias;
-	this.diffuse = ( options.diffuse === undefined ) ? 1.33 : options.diffuse;
-	this.viscosity = ( options.viscosity === undefined ) ? 0.25 : options.viscosity;
-	this.expansion = ( options.expansion === undefined ) ? - 0.25 : options.expansion;
-	this.swirl = ( options.swirl === undefined ) ? 50.0 : options.swirl;
-	this.burnRate = ( options.burnRate === undefined ) ? 0.3 : options.burnRate;
-	this.drag = ( options.drag === undefined ) ? 0.35 : options.drag;
-	this.airSpeed = ( options.airSpeed === undefined ) ? 6.0 : options.airSpeed;
-	this.windVector = options.windVector || new THREE.Vector2( 0.0, 0.75 );
-	this.speed = ( options.speed === undefined ) ? 500.0 : options.speed;
-	this.massConservation = ( options.massConservation === undefined ) ? false : options.massConservation;
-
-	var size = textureWidth * textureHeight;
-	this.sourceData = new Uint8Array( 4 * size );
-
-	this.clearSources = function () {
-
-		for ( var y = 0; y < textureHeight; y ++ ) {
-
-			for ( var x = 0; x < textureWidth; x ++ ) {
-
-				var i = y * textureWidth + x;
-				var stride = i * 4;
-
-				this.sourceData[ stride ] = 0;
-				this.sourceData[ stride + 1 ] = 0;
-				this.sourceData[ stride + 2 ] = 0;
-				this.sourceData[ stride + 3 ] = 0;
-
-			}
-
-		}
-
-		this.sourceMaterial.uniforms[ "sourceMap" ].value = this.internalSource;
-		this.sourceMaterial.needsUpdate = true;
-
-		return this.sourceData;
-
-	};
-
-	this.addSource = function ( u, v, radius, density = null, windX = null, windY = null ) {
-
-		var startX = Math.max( Math.floor( ( u - radius ) * textureWidth ), 0 );
-		var startY = Math.max( Math.floor( ( v - radius ) * textureHeight ), 0 );
-		var endX = Math.min( Math.floor( ( u + radius ) * textureWidth ), textureWidth );
-		var endY = Math.min( Math.floor( ( v + radius ) * textureHeight ), textureHeight );
-
-		for ( var y = startY; y < endY; y ++ ) {
-
-			for ( var x = startX; x < endX; x ++ ) {
-
-				var diffX = x * oneOverWidth - u;
-				var diffY = y * oneOverHeight - v;
-
-				if ( diffX * diffX + diffY * diffY < radius * radius ) {
-
-					var i = y * textureWidth + x;
-					var stride = i * 4;
-
-					if ( density != null ) {
-
-						this.sourceData[ stride ] = Math.min( Math.max( density, 0.0 ), 1.0 ) * 255;
-
-					}
-
-					if ( windX != null ) {
-
-						var wind = Math.min( Math.max( windX, - 1.0 ), 1.0 );
-						wind = ( wind < 0.0 ) ? Math.floor( wind * 127 ) + 255 : Math.floor( wind * 127 );
-						this.sourceData[ stride + 1 ] = wind;
-
-					}
-
-					if ( windY != null ) {
-
-						var wind = Math.min( Math.max( windY, - 1.0 ), 1.0 );
-						wind = ( wind < 0.0 ) ? Math.floor( wind * 127 ) + 255 : Math.floor( wind * 127 );
-						this.sourceData[ stride + 2 ] = wind;
-
-					}
-
-				}
-
-			}
-
-		}
-
-		this.internalSource.needsUpdate = true;
-
-		return this.sourceData;
-
-	};
-
-	// When setting source map, red channel is density. Green and blue channels
-	// encode x and y velocity respectively as signed chars:
-	// (0 -> 127 = 0.0 -> 1.0, 128 -> 255 = -1.0 -> 0.0 )
-	this.setSourceMap = function ( texture ) {
-
-		this.sourceMaterial.uniforms[ "sourceMap" ].value = texture;
-
-	};
-
-	var parameters = {
-		minFilter: THREE.NearestFilter,
-		magFilter: THREE.NearestFilter,
-		depthBuffer: false
-	};
-
-
-	this.field0 = new THREE.WebGLRenderTarget( textureWidth, textureHeight, parameters );
-
-	this.field0.background = new THREE.Color( 0x000000 );
-
-	this.field1 = new THREE.WebGLRenderTarget( textureWidth, textureHeight, parameters );
-
-	this.field0.background = new THREE.Color( 0x000000 );
-
-	this.fieldProj = new THREE.WebGLRenderTarget( textureWidth, textureHeight, parameters );
-
-	this.field0.background = new THREE.Color( 0x000000 );
-
-	if ( ! THREE.MathUtils.isPowerOfTwo( textureWidth ) ||
-		 ! THREE.MathUtils.isPowerOfTwo( textureHeight ) ) {
-
-		this.field0.texture.generateMipmaps = false;
-		this.field1.texture.generateMipmaps = false;
-		this.fieldProj.texture.generateMipmaps = false;
-
-	}
-
-
-	this.fieldScene = new THREE.Scene();
-	this.fieldScene.background = new THREE.Color( 0x000000 );
-
-	this.orthoCamera = new THREE.OrthographicCamera( textureWidth / - 2, textureWidth / 2, textureHeight / 2, textureHeight / - 2, 1, 2 );
-	this.orthoCamera.position.z = 1;
-
-	this.fieldGeometry = new THREE.PlaneBufferGeometry( textureWidth, textureHeight );
-
-	this.internalSource = new THREE.DataTexture( this.sourceData, textureWidth, textureHeight, THREE.RGBAFormat );
-
-	// Source Shader
-
-	var shader = THREE.Fire.SourceShader;
-	this.sourceMaterial = new THREE.ShaderMaterial( {
-		uniforms: shader.uniforms,
-		vertexShader: shader.vertexShader,
-		fragmentShader: shader.fragmentShader,
-		transparent: false
-	} );
-
-	this.clearSources();
-
-	this.sourceMesh = new THREE.Mesh( this.fieldGeometry, this.sourceMaterial );
-	this.fieldScene.add( this.sourceMesh );
-
-	// Diffuse Shader
-
-	var shader = THREE.Fire.DiffuseShader;
-	this.diffuseMaterial = new THREE.ShaderMaterial( {
-		uniforms: shader.uniforms,
-		vertexShader: shader.vertexShader,
-		fragmentShader: shader.fragmentShader,
-		transparent: false
-	} );
-
-	this.diffuseMaterial.uniforms[ "oneOverWidth" ].value = oneOverWidth;
-	this.diffuseMaterial.uniforms[ "oneOverHeight" ].value = oneOverHeight;
-
-	this.diffuseMesh = new THREE.Mesh( this.fieldGeometry, this.diffuseMaterial );
-	this.fieldScene.add( this.diffuseMesh );
-
-	// Drift Shader
-
-	shader = THREE.Fire.DriftShader;
-	this.driftMaterial = new THREE.ShaderMaterial( {
-		uniforms: shader.uniforms,
-		vertexShader: shader.vertexShader,
-		fragmentShader: shader.fragmentShader,
-		transparent: false
-	} );
-
-	this.driftMaterial.uniforms[ "oneOverWidth" ].value = oneOverWidth;
-	this.driftMaterial.uniforms[ "oneOverHeight" ].value = oneOverHeight;
-
-	this.driftMesh = new THREE.Mesh( this.fieldGeometry, this.driftMaterial );
-	this.fieldScene.add( this.driftMesh );
-
-	// Projection Shader 1
-
-	shader = THREE.Fire.ProjectionShader1;
-	this.projMaterial1 = new THREE.ShaderMaterial( {
-		uniforms: shader.uniforms,
-		vertexShader: shader.vertexShader,
-		fragmentShader: shader.fragmentShader,
-		transparent: false
-	} );
-
-	this.projMaterial1.uniforms[ "oneOverWidth" ].value = oneOverWidth;
-	this.projMaterial1.uniforms[ "oneOverHeight" ].value = oneOverHeight;
-
-	this.projMesh1 = new THREE.Mesh( this.fieldGeometry, this.projMaterial1 );
-	this.fieldScene.add( this.projMesh1 );
-
-	// Projection Shader 2
-
-	shader = THREE.Fire.ProjectionShader2;
-	this.projMaterial2 = new THREE.ShaderMaterial( {
-		uniforms: shader.uniforms,
-		vertexShader: shader.vertexShader,
-		fragmentShader: shader.fragmentShader,
-		transparent: false
-	} );
-
-
-	this.projMaterial2.uniforms[ "oneOverWidth" ].value = oneOverWidth;
-	this.projMaterial2.uniforms[ "oneOverHeight" ].value = oneOverHeight;
-
-	this.projMesh2 = new THREE.Mesh( this.fieldGeometry, this.projMaterial2 );
-	this.fieldScene.add( this.projMesh2 );
-
-	// Projection Shader 3
-
-	shader = THREE.Fire.ProjectionShader3;
-	this.projMaterial3 = new THREE.ShaderMaterial( {
-		uniforms: shader.uniforms,
-		vertexShader: shader.vertexShader,
-		fragmentShader: shader.fragmentShader,
-		transparent: false
-	} );
-
-
-	this.projMaterial3.uniforms[ "oneOverWidth" ].value = oneOverWidth;
-	this.projMaterial3.uniforms[ "oneOverHeight" ].value = oneOverHeight;
-
-	this.projMesh3 = new THREE.Mesh( this.fieldGeometry, this.projMaterial3 );
-	this.fieldScene.add( this.projMesh3 );
-
-	// Color Shader
-
-	if ( debug ) {
-
-		shader = THREE.Fire.DebugShader;
-
-	} else {
-
-		shader = THREE.Fire.ColorShader;
-
-	}
-
-	this.material = new THREE.ShaderMaterial( {
-		uniforms: shader.uniforms,
-		vertexShader: shader.vertexShader,
-		fragmentShader: shader.fragmentShader,
-		transparent: true
-	} );
-
-	this.material.uniforms[ "densityMap" ].value = this.field1.texture;
-
-	this.configShaders = function ( dt ) {
-
-		this.diffuseMaterial.uniforms[ "diffuse" ].value = dt * 0.05 * this.diffuse;
-		this.diffuseMaterial.uniforms[ "viscosity" ].value = dt * 0.05 * this.viscosity;
-		this.diffuseMaterial.uniforms[ "expansion" ].value = Math.exp( this.expansion * - 1.0 );
-		this.diffuseMaterial.uniforms[ "swirl" ].value = Math.exp( this.swirl * - 0.1 );
-		this.diffuseMaterial.uniforms[ "drag" ].value = Math.exp( this.drag * - 0.1 );
-		this.diffuseMaterial.uniforms[ "burnRate" ].value = this.burnRate * dt * 0.01;
-		this.driftMaterial.uniforms[ "windVector" ].value = this.windVector;
-		this.driftMaterial.uniforms[ "airSpeed" ].value = dt * this.airSpeed * 0.001 * textureHeight;
-		this.material.uniforms[ "color1" ].value = this.color1;
-		this.material.uniforms[ "color2" ].value = this.color2;
-		this.material.uniforms[ "color3" ].value = this.color3;
-		this.material.uniforms[ "colorBias" ].value = this.colorBias;
-
-	};
-
-	this.clearDiffuse = function () {
-
-		this.diffuseMaterial.uniforms[ "expansion" ].value = 1.0;
-		this.diffuseMaterial.uniforms[ "swirl" ].value = 1.0;
-		this.diffuseMaterial.uniforms[ "drag" ].value = 1.0;
-		this.diffuseMaterial.uniforms[ "burnRate" ].value = 0.0;
-
-	};
-
-	this.swapTextures = function () {
-
-		var swap = this.field0;
-		this.field0 = this.field1;
-		this.field1 = swap;
-
-	};
-
-	this.saveRenderState = function ( renderer ) {
-
-		this.savedRenderTarget = renderer.getRenderTarget();
-		this.savedXrEnabled = renderer.xr.enabled;
-		this.savedShadowAutoUpdate = renderer.shadowMap.autoUpdate;
-		this.savedAntialias = renderer.antialias;
-		this.savedToneMapping = renderer.toneMapping;
-
-	};
-
-	this.restoreRenderState = function ( renderer ) {
-
-		renderer.xr.enabled = this.savedXrEnabled;
-		renderer.shadowMap.autoUpdate = this.savedShadowAutoUpdate;
-		renderer.setRenderTarget( this.savedRenderTarget );
-		renderer.antialias = this.savedAntialias;
-		renderer.toneMapping = this.savedToneMapping;
-
-	};
-
-	this.renderSource = function ( renderer ) {
-
-		this.sourceMesh.visible = true;
-
-		this.sourceMaterial.uniforms[ "densityMap" ].value = this.field0.texture;
-
-		renderer.setRenderTarget( this.field1 );
-		renderer.render( this.fieldScene, this.orthoCamera );
-
-		this.sourceMesh.visible = false;
-
-		this.swapTextures();
-
-	};
-
-	this.renderDiffuse = function ( renderer ) {
-
-		this.diffuseMesh.visible = true;
-
-		this.diffuseMaterial.uniforms[ "densityMap" ].value = this.field0.texture;
-
-		renderer.setRenderTarget( this.field1 );
-		renderer.render( this.fieldScene, this.orthoCamera );
-
-		this.diffuseMesh.visible = false;
-
-		this.swapTextures();
-
-	};
-
-	this.renderDrift = function ( renderer ) {
-
-		this.driftMesh.visible = true;
-
-		this.driftMaterial.uniforms[ "densityMap" ].value = this.field0.texture;
-
-		renderer.setRenderTarget( this.field1 );
-		renderer.render( this.fieldScene, this.orthoCamera );
-
-		this.driftMesh.visible = false;
-
-		this.swapTextures();
-
-	};
-
-	this.renderProject = function ( renderer ) {
-
-		// Projection pass 1
-
-		this.projMesh1.visible = true;
-
-		this.projMaterial1.uniforms[ "densityMap" ].value = this.field0.texture;
-
-		renderer.setRenderTarget( this.fieldProj );
-		renderer.render( this.fieldScene, this.orthoCamera );
-
-		this.projMesh1.visible = false;
-
-		this.projMaterial2.uniforms[ "densityMap" ].value = this.fieldProj.texture;
-
-		// Projection pass 2
-
-		this.projMesh2.visible = true;
-
-		for ( var i = 0; i < 20; i ++ ) {
-
-			renderer.setRenderTarget( this.field1 );
-			renderer.render( this.fieldScene, this.orthoCamera );
-
-			var temp = this.field1;
-			this.field1 = this.fieldProj;
-			this.fieldProj = temp;
-
-			this.projMaterial2.uniforms[ "densityMap" ].value = this.fieldProj.texture;
-
-		}
-
-		this.projMesh2.visible = false;
-
-		this.projMaterial3.uniforms[ "densityMap" ].value = this.field0.texture;
-		this.projMaterial3.uniforms[ "projMap" ].value = this.fieldProj.texture;
-
-		// Projection pass 3
-
-		this.projMesh3.visible = true;
-
-		renderer.setRenderTarget( this.field1 );
-		renderer.render( this.fieldScene, this.orthoCamera );
-
-		this.projMesh3.visible = false;
-
-		this.swapTextures();
-
-	};
-
-	this.onBeforeRender = function ( renderer ) {
-
-		var delta = this.clock.getDelta();
-
-		if ( delta > 0.1 ) {
-
-			delta = 0.1;
-
-		}
-
-		var dt = delta * ( this.speed * 0.1 );
-
-		this.configShaders( dt );
-
-		this.saveRenderState( renderer );
-
-		renderer.xr.enabled = false; // Avoid camera modification and recursion
-		renderer.shadowMap.autoUpdate = false; // Avoid re-computing shadows
-		renderer.antialias = false;
-		renderer.toneMapping = THREE.NoToneMapping;
-
-		this.sourceMesh.visible = false;
-		this.diffuseMesh.visible = false;
-		this.driftMesh.visible = false;
-		this.projMesh1.visible = false;
-		this.projMesh2.visible = false;
-		this.projMesh3.visible = false;
-
-		this.renderSource( renderer );
-
-		this.clearDiffuse();
-
-		for ( var i = 0; i < 21; i ++ ) {
-
-			this.renderDiffuse( renderer );
-
-		}
-
-		this.configShaders( dt );
-		this.renderDiffuse( renderer );
-
-		this.renderDrift( renderer );
-
-		if ( this.massConservation ) {
-
-			this.renderProject( renderer );
-			this.renderProject( renderer );
-
-		}
-
-		// Final result out for coloring
-
-		this.material.map = this.field1.texture;
-		this.material.transparent = true;
-		this.material.minFilter = THREE.LinearFilter,
-		this.material.magFilter = THREE.LinearFilter,
-
-		this.restoreRenderState( renderer );
-
-	};
-
-};
-
-
-THREE.Fire.prototype = Object.create( THREE.Mesh.prototype );
-THREE.Fire.prototype.constructor = THREE.Fire;
-
-THREE.Fire.SourceShader = {
-
-	uniforms: {
-		'sourceMap': {
-			value: null
-		},
-		'densityMap': {
-			value: null
-		}
-	},
-
-	vertexShader: [
-		'varying vec2 vUv;',
-
-		'void main() {',
-
-		' 	  vUv = uv;',
-
-		'     vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );',
-		'     gl_Position = projectionMatrix * mvPosition;',
-
-		'}'
-
-	].join( "\n" ),
-
-	fragmentShader: [
-		'uniform sampler2D sourceMap;',
-		'uniform sampler2D densityMap;',
-
-		'varying vec2 vUv;',
-
-		'void main() {',
-		'    vec4 source = texture2D( sourceMap, vUv );',
-		'    vec4 current = texture2D( densityMap, vUv );',
-
-		'    vec2 v0 = (current.gb - step(0.5, current.gb)) * 2.0;',
-		'    vec2 v1 = (source.gb - step(0.5, source.gb)) * 2.0;',
-
-		'    vec2 newVel = v0 + v1;',
-
-		'    newVel = clamp(newVel, -0.99, 0.99);',
-		'    newVel = newVel * 0.5 + step(0.0, -newVel);',
-
-		'    float newDensity = source.r + current.a;',
-		'    float newTemp = source.r + current.r;',
-
-		'    newDensity = clamp(newDensity, 0.0, 1.0);',
-		'    newTemp = clamp(newTemp, 0.0, 1.0);',
-
-		'    gl_FragColor = vec4(newTemp, newVel.xy, newDensity);',
-
-		'}'
-
-	].join( "\n" )
-};
-
-
-THREE.Fire.DiffuseShader = {
-
-	uniforms: {
-		'oneOverWidth': {
-			value: null
-		},
-		'oneOverHeight': {
-			value: null
-		},
-		'diffuse': {
-			value: null
-		},
-		'viscosity': {
-			value: null
-		},
-		'expansion': {
-			value: null
-		},
-		'swirl': {
-			value: null
-		},
-		'drag': {
-			value: null
-		},
-		'burnRate': {
-			value: null
-		},
-		'densityMap': {
-			value: null
-		}
-	},
-
-	vertexShader: [
-		'varying vec2 vUv;',
-
-		'void main() {',
-
-		' 	  vUv = uv;',
-
-		'     vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );',
-		'     gl_Position = projectionMatrix * mvPosition;',
-
-		'}'
-
-	].join( "\n" ),
-
-	fragmentShader: [
-		'uniform float oneOverWidth;',
-		'uniform float oneOverHeight;',
-		'uniform float diffuse;',
-		'uniform float viscosity;',
-		'uniform float expansion;',
-		'uniform float swirl;',
-		'uniform float burnRate;',
-		'uniform float drag;',
-		'uniform sampler2D densityMap;',
-
-		'varying vec2 vUv;',
-
-		'void main() {',
-
-		'    vec4 dC = texture2D( densityMap, vUv );',
-		'    vec4 dL = texture2D( densityMap, vec2(vUv.x - oneOverWidth, vUv.y) );',
-		'    vec4 dR = texture2D( densityMap, vec2(vUv.x + oneOverWidth, vUv.y) );',
-		'    vec4 dU = texture2D( densityMap, vec2(vUv.x, vUv.y - oneOverHeight) );',
-		'    vec4 dD = texture2D( densityMap, vec2(vUv.x, vUv.y + oneOverHeight) );',
-		'    vec4 dUL = texture2D( densityMap, vec2(vUv.x - oneOverWidth, vUv.y - oneOverHeight) );',
-		'    vec4 dUR = texture2D( densityMap, vec2(vUv.x + oneOverWidth, vUv.y - oneOverHeight) );',
-		'    vec4 dDL = texture2D( densityMap, vec2(vUv.x - oneOverWidth, vUv.y + oneOverHeight) );',
-		'    vec4 dDR = texture2D( densityMap, vec2(vUv.x + oneOverWidth, vUv.y + oneOverHeight) );',
-
-		'    dC.yz = (dC.yz - step(0.5, dC.yz)) * 2.0;',
-		'    dL.yz = (dL.yz - step(0.5, dL.yz)) * 2.0;',
-		'    dR.yz = (dR.yz - step(0.5, dR.yz)) * 2.0;',
-		'    dU.yz = (dU.yz - step(0.5, dU.yz)) * 2.0;',
-		'    dD.yz = (dD.yz - step(0.5, dD.yz)) * 2.0;',
-		'    dUL.yz = (dUL.yz - step(0.5, dUL.yz)) * 2.0;',
-		'    dUR.yz = (dUR.yz - step(0.5, dUR.yz)) * 2.0;',
-		'    dDL.yz = (dDL.yz - step(0.5, dDL.yz)) * 2.0;',
-		'    dDR.yz = (dDR.yz - step(0.5, dDR.yz)) * 2.0;',
-
-		'    vec4 result = (dC + vec4(diffuse, viscosity, viscosity, diffuse) * ( dL + dR + dU + dD + dUL + dUR + dDL + dDR )) / (1.0 + 8.0 * vec4(diffuse, viscosity, viscosity, diffuse)) - vec4(0.0, 0.0, 0.0, 0.001);',
-
-		'    float temperature = result.r;',
-		'    temperature = clamp(temperature - burnRate, 0.0, 1.0);',
-
-		'    vec2 velocity = result.yz;',
-
-		'    vec2 expansionVec = vec2(dL.w - dR.w, dU.w - dD.w);',
-
-		'    vec2 swirlVec = vec2((dL.z - dR.z) * 0.5, (dU.y - dD.y) * 0.5);',
-
-		'    velocity = velocity + (1.0 - expansion) * expansionVec + (1.0 - swirl) * swirlVec;',
-
-		'    velocity = velocity - (1.0 - drag) * velocity;',
-
-		'    gl_FragColor = vec4(temperature, velocity * 0.5 + step(0.0, -velocity), result.w);',
-
-		'    gl_FragColor = gl_FragColor * step(oneOverWidth, vUv.x);',
-		'    gl_FragColor = gl_FragColor * step(oneOverHeight, vUv.y);',
-		'    gl_FragColor = gl_FragColor * step(vUv.x, 1.0 - oneOverWidth);',
-		'    gl_FragColor = gl_FragColor * step(vUv.y, 1.0 - oneOverHeight);',
-
-		'}'
-
-	].join( "\n" )
-};
-
-THREE.Fire.DriftShader = {
-
-	uniforms: {
-		'oneOverWidth': {
-			value: null
-		},
-		'oneOverHeight': {
-			value: null
-		},
-		'windVector': {
-			value: new THREE.Vector2( 0.0, 0.0 )
-		},
-		'airSpeed': {
-			value: null
-		},
-		'densityMap': {
-			value: null
-		}
-	},
-
-	vertexShader: [
-		'varying vec2 vUv;',
-
-		'void main() {',
-
-		' 	  vUv = uv;',
-
-		'     vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );',
-		'     gl_Position = projectionMatrix * mvPosition;',
-
-		'}'
-
-	].join( "\n" ),
-
-	fragmentShader: [
-		'uniform float oneOverWidth;',
-		'uniform float oneOverHeight;',
-		'uniform vec2 windVector;',
-		'uniform float airSpeed;',
-		'uniform sampler2D densityMap;',
-
-		'varying vec2 vUv;',
-
-		'void main() {',
-		'    vec2 velocity = texture2D( densityMap, vUv ).gb;',
-		'    velocity = (velocity - step(0.5, velocity)) * 2.0;',
-
-		'    velocity = velocity + windVector;',
-
-		'    vec2 sourcePos = vUv - airSpeed * vec2(oneOverWidth, oneOverHeight) * velocity;',
-
-		'    vec2 units = sourcePos / vec2(oneOverWidth, oneOverHeight);',
-
-		'    vec2 intPos = floor(units);',
-		'    vec2 frac = units - intPos;',
-		'    intPos = intPos * vec2(oneOverWidth, oneOverHeight);',
-
-		'    vec4 dX0Y0 = texture2D( densityMap, intPos + vec2(0.0, -oneOverHeight) );',
-		'    vec4 dX1Y0 = texture2D( densityMap, intPos + vec2(oneOverWidth, 0.0) );',
-		'    vec4 dX0Y1 = texture2D( densityMap, intPos + vec2(0.0, oneOverHeight) );',
-		'    vec4 dX1Y1 = texture2D( densityMap, intPos + vec2(oneOverWidth, oneOverHeight) );',
-
-
-		'    dX0Y0.gb = (dX0Y0.gb - step(0.5, dX0Y0.gb)) * 2.0;',
-		'    dX1Y0.gb = (dX1Y0.gb - step(0.5, dX1Y0.gb)) * 2.0;',
-		'    dX0Y1.gb = (dX0Y1.gb - step(0.5, dX0Y1.gb)) * 2.0;',
-		'    dX1Y1.gb = (dX1Y1.gb - step(0.5, dX1Y1.gb)) * 2.0;',
-
-		'    vec4 source = mix(mix(dX0Y0, dX1Y0, frac.x), mix(dX0Y1, dX1Y1, frac.x), frac.y);',
-
-		'    source.gb = source.gb * 0.5 + step(0.0, -source.gb);',
-
-		'    gl_FragColor = source;',
-
-		'}'
-
-	].join( "\n" )
-};
-
-
-THREE.Fire.ProjectionShader1 = {
-
-	uniforms: {
-		'oneOverWidth': {
-			value: null
-		},
-		'oneOverHeight': {
-			value: null
-		},
-		'densityMap': {
-			value: null
-		}
-	},
-
-	vertexShader: [
-		'varying vec2 vUv;',
-
-		'void main() {',
-
-		' 	  vUv = uv;',
-
-		'     vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );',
-		'     gl_Position = projectionMatrix * mvPosition;',
-
-		'}'
-
-	].join( "\n" ),
-
-	fragmentShader: [
-		'uniform float oneOverWidth;',
-		'uniform float oneOverHeight;',
-		'uniform sampler2D densityMap;',
-
-		'varying vec2 vUv;',
-
-		'void main() {',
-		'    float dL = texture2D( densityMap, vec2(vUv.x - oneOverWidth, vUv.y) ).g;',
-		'    float dR = texture2D( densityMap, vec2(vUv.x + oneOverWidth, vUv.y) ).g;',
-		'    float dU = texture2D( densityMap, vec2(vUv.x, vUv.y - oneOverHeight) ).b;',
-		'    float dD = texture2D( densityMap, vec2(vUv.x, vUv.y + oneOverHeight) ).b;',
-
-		'    dL = (dL - step(0.5, dL)) * 2.0;',
-		'    dR = (dR - step(0.5, dR)) * 2.0;',
-		'    dU = (dU - step(0.5, dU)) * 2.0;',
-		'    dD = (dD - step(0.5, dD)) * 2.0;',
-
-		'    float h = (oneOverWidth + oneOverHeight) * 0.5;',
-		'    float div = -0.5 * h * (dR - dL + dD - dU);',
-
-		'    gl_FragColor = vec4( 0.0, 0.0, div * 0.5 + step(0.0, -div), 0.0);',
-
-		'}'
-
-	].join( "\n" )
-};
-
-
-THREE.Fire.ProjectionShader2 = {
-
-	uniforms: {
-		'oneOverWidth': {
-			value: null
-		},
-		'oneOverHeight': {
-			value: null
-		},
-		'densityMap': {
-			value: null
-		}
-	},
-
-	vertexShader: [
-		'varying vec2 vUv;',
-
-		'void main() {',
-
-		' 	  vUv = uv;',
-
-		'     vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );',
-		'     gl_Position = projectionMatrix * mvPosition;',
-
-		'}'
-
-	].join( "\n" ),
-
-	fragmentShader: [
-		'uniform float oneOverWidth;',
-		'uniform float oneOverHeight;',
-		'uniform sampler2D densityMap;',
-
-		'varying vec2 vUv;',
-
-		'void main() {',
-		'    float div = texture2D( densityMap, vUv ).b;',
-		'    float pL = texture2D( densityMap, vec2(vUv.x - oneOverWidth, vUv.y) ).g;',
-		'    float pR = texture2D( densityMap, vec2(vUv.x + oneOverWidth, vUv.y) ).g;',
-		'    float pU = texture2D( densityMap, vec2(vUv.x, vUv.y - oneOverHeight) ).g;',
-		'    float pD = texture2D( densityMap, vec2(vUv.x, vUv.y + oneOverHeight) ).g;',
-
-		'    float divNorm = (div - step(0.5, div)) * 2.0;',
-		'    pL = (pL - step(0.5, pL)) * 2.0;',
-		'    pR = (pR - step(0.5, pR)) * 2.0;',
-		'    pU = (pU - step(0.5, pU)) * 2.0;',
-		'    pD = (pD - step(0.5, pD)) * 2.0;',
-
-		'    float p = (divNorm + pR + pL + pD + pU) * 0.25;',
-
-		'    gl_FragColor = vec4( 0.0, p * 0.5 + step(0.0, -p), div, 0.0);',
-
-		'}'
-
-	].join( "\n" )
-};
-
-
-THREE.Fire.ProjectionShader3 = {
-
-	uniforms: {
-		'oneOverWidth': {
-			value: null
-		},
-		'oneOverHeight': {
-			value: null
-		},
-		'densityMap': {
-			value: null
-		},
-		'projMap': {
-			value: null
-		}
-	},
-
-	vertexShader: [
-		'varying vec2 vUv;',
-
-		'void main() {',
-
-		' 	  vUv = uv;',
-
-		'     vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );',
-		'     gl_Position = projectionMatrix * mvPosition;',
-
-		'}'
-
-	].join( "\n" ),
-
-	fragmentShader: [
-		'uniform float oneOverWidth;',
-		'uniform float oneOverHeight;',
-		'uniform sampler2D densityMap;',
-		'uniform sampler2D projMap;',
-
-		'varying vec2 vUv;',
-
-		'void main() {',
-		'    vec4 orig = texture2D(densityMap, vUv);',
-
-		'    float pL = texture2D( projMap, vec2(vUv.x - oneOverWidth, vUv.y) ).g;',
-		'    float pR = texture2D( projMap, vec2(vUv.x + oneOverWidth, vUv.y) ).g;',
-		'    float pU = texture2D( projMap, vec2(vUv.x, vUv.y - oneOverHeight) ).g;',
-		'    float pD = texture2D( projMap, vec2(vUv.x, vUv.y + oneOverHeight) ).g;',
-
-		'    float uNorm = (orig.g - step(0.5, orig.g)) * 2.0;',
-		'    float vNorm = (orig.b - step(0.5, orig.b)) * 2.0;',
-
-		'    pL = (pL - step(0.5, pL)) * 2.0;',
-		'    pR = (pR - step(0.5, pR)) * 2.0;',
-		'    pU = (pU - step(0.5, pU)) * 2.0;',
-		'    pD = (pD - step(0.5, pD)) * 2.0;',
-
-		'    float h = (oneOverWidth + oneOverHeight) * 0.5;',
-		'    float u = uNorm - (0.5 * (pR - pL) / h);',
-		'    float v = vNorm - (0.5 * (pD - pU) / h);',
-
-		'    gl_FragColor = vec4( orig.r, u * 0.5 + step(0.0, -u), v * 0.5 + step(0.0, -v), orig.a);',
-
-		'}'
-
-	].join( "\n" )
-};
-
-THREE.Fire.ColorShader = {
-
-	uniforms: {
-		'color1': {
-			value: null
-		},
-		'color2': {
-			value: null
-		},
-		'color3': {
-			value: null
-		},
-		'colorBias': {
-			value: null
-		},
-		'densityMap': {
-			value: null
-		}
-	},
-
-	vertexShader: [
-		'varying vec2 vUv;',
-
-		'void main() {',
-
-		' 	  vUv = uv;',
-
-		'     vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );',
-		'     gl_Position = projectionMatrix * mvPosition;',
-
-		'}'
-
-	].join( "\n" ),
-
-	fragmentShader: [
-		'uniform vec3 color1;',
-		'uniform vec3 color2;',
-		'uniform vec3 color3;',
-		'uniform float colorBias;',
-		'uniform sampler2D densityMap;',
-
-		'varying vec2 vUv;',
-
-		'void main() {',
-		'    float density = texture2D( densityMap, vUv ).a;',
-		'    float temperature = texture2D( densityMap, vUv ).r;',
-
-		'    float bias = clamp(colorBias, 0.0001, 0.9999);',
-
-		'    vec3 blend1 = mix(color3, color2, temperature / bias) * (1.0 - step(bias, temperature));',
-		'    vec3 blend2 = mix(color2, color1, (temperature - bias) / (1.0 - bias) ) * step(bias, temperature);',
-
-		'    gl_FragColor = vec4(blend1 + blend2, density);',
-		'}'
-
-	].join( "\n" )
-};
-
-
-THREE.Fire.DebugShader = {
-
-	uniforms: {
-		'color1': {
-			value: null
-		},
-		'color2': {
-			value: null
-		},
-		'color3': {
-			value: null
-		},
-		'colorBias': {
-			value: null
-		},
-		'densityMap': {
-			value: null
-		}
-	},
-
-	vertexShader: [
-		'varying vec2 vUv;',
-
-		'void main() {',
-
-		' 	  vUv = uv;',
-
-		'     vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );',
-		'     gl_Position = projectionMatrix * mvPosition;',
-
-		'}'
-
-	].join( "\n" ),
-
-	fragmentShader: [
-		'uniform sampler2D densityMap;',
-
-		'varying vec2 vUv;',
-
-		'void main() {',
-		'    float density;',
-		'    density = texture2D( densityMap, vUv ).a;',
-
-		'    vec2 vel = texture2D( densityMap, vUv ).gb;',
-
-		'    vel = (vel - step(0.5, vel)) * 2.0;',
-
-		'    float r = density;',
-		'    float g = max(abs(vel.x), density * 0.5);',
-		'    float b = max(abs(vel.y), density * 0.5);',
-		'    float a = max(density * 0.5, max(abs(vel.x), abs(vel.y)));',
-
-		'    gl_FragColor = vec4(r, g, b, a);',
-
-		'}'
-
-	].join( "\n" )
-};

+ 0 - 188
examples/jsm/objects/Fire.d.ts

@@ -1,188 +0,0 @@
-import {
-	BufferGeometry,
-	Color,
-	Clock,
-	DataTexture,
-	Mesh,
-	OrthographicCamera,
-	PlaneBufferGeometry,
-	Scene,
-	ShaderMaterial,
-	Texture,
-	Uniform,
-	WebGLRenderer,
-	WebGLRenderTarget
-} from '../../../src/Three';
-
-export interface FireOptions {
-	textureWidth?: number;
-	textureHeight?: number;
-	debug?: boolean;
-	color1?: Color;
-	color2?: Color;
-	color3?: Color;
-	colorBias?: number;
-	diffuse?: number;
-	viscosity?: number;
-	expansion?: number;
-	swirl?: number;
-	burnRate?: number;
-	drag?: number;
-	airSpeed?: number;
-	windVector?: number;
-	speed?: number;
-	massConservation?: boolean;
-}
-
-export class Fire extends Mesh {
-
-	constructor( geometry: BufferGeometry, options: FireOptions );
-	clock: Clock;
-	color1: Color;
-	color2: Color;
-	color3: Color;
-	colorBias: number;
-	diffuse: number;
-	viscosity: number;
-	expansion: number;
-	swirl: number;
-	burnRate: number;
-	drag: number;
-	airSpeed: number;
-	windVector: number;
-	speed: number;
-	massConservation: boolean;
-
-	sourceData: Uint8Array;
-
-	field0: WebGLRenderTarget;
-	field1: WebGLRenderTarget;
-	fieldProj: WebGLRenderTarget;
-	fieldScene: Scene;
-	orthoCamera: OrthographicCamera;
-	fieldGeometry: PlaneBufferGeometry;
-	internalSource: DataTexture;
-	sourceMaterial: ShaderMaterial;
-	sourceMesh: Mesh;
-	diffuseMaterial: ShaderMaterial;
-	driftMaterial: ShaderMaterial;
-	projMaterial1: ShaderMaterial;
-	projMaterial2: ShaderMaterial;
-	projMaterial3: ShaderMaterial;
-	material: ShaderMaterial;
-
-	addSource( u: number, v: number, radius: number, density?: number, windX?: number, windY?: number ): Uint8Array;
-	clearDiffuse(): void;
-	clearSources(): Uint8Array;
-	configShaders( dt: number ): void;
-	renderDiffuse( renderer: WebGLRenderer ): void;
-	renderDrift( renderer: WebGLRenderer ): void;
-	renderProject( renderer: WebGLRenderer ): void;
-	renderSource( renderer: WebGLRenderer ): void;
-	restoreRenderState( renderer: WebGLRenderer ): void;
-	saveRenderState( renderer: WebGLRenderer ): void;
-	setSourceMap( texture: Texture ): void;
-	swapTextures(): void;
-
-	static SourceShader: SourceShader;
-	static DiffuseShader: DiffuseShader;
-	static DriftShader: DriftShader;
-	static ProjectionShader1: ProjectionShader1;
-	static ProjectionShader2: ProjectionShader2;
-	static ProjectionShader3: ProjectionShader3;
-	static ColorShader: ColorShader;
-	static DebugShader: DebugShader;
-
-}
-
-declare interface SourceShader {
-	uniforms: {
-		sourceMap: Uniform;
-		densityMap: Uniform;
-	};
-	vertexShader: string;
-	fragmentShader: string;
-}
-
-declare interface DiffuseShader {
-	uniforms: {
-		oneOverWidth: Uniform;
-		oneOverHeight: Uniform;
-		diffuse: Uniform;
-		viscosity: Uniform;
-		expansion: Uniform;
-		swirl: Uniform;
-		drag: Uniform;
-		burnRate: Uniform;
-		densityMap: Uniform;
-	};
-	vertexShader: string;
-	fragmentShader: string;
-}
-
-declare interface DriftShader {
-	uniforms: {
-		oneOverWidth: Uniform;
-		oneOverHeight: Uniform;
-		windVector: Uniform;
-		airSpeed: Uniform;
-		densityMap: Uniform;
-	};
-	vertexShader: string;
-	fragmentShader: string;
-}
-
-declare interface ProjectionShader1 {
-	uniforms: {
-		oneOverWidth: Uniform;
-		oneOverHeight: Uniform;
-		densityMap: Uniform;
-	};
-	vertexShader: string;
-	fragmentShader: string;
-}
-
-declare interface ProjectionShader2 {
-	uniforms: {
-		oneOverWidth: Uniform;
-		oneOverHeight: Uniform;
-		densityMap: Uniform;
-	};
-	vertexShader: string;
-	fragmentShader: string;
-}
-
-declare interface ProjectionShader3 {
-	uniforms: {
-		oneOverWidth: Uniform;
-		oneOverHeight: Uniform;
-		densityMap: Uniform;
-		projMap: Uniform;
-	};
-	vertexShader: string;
-	fragmentShader: string;
-}
-
-declare interface ColorShader {
-	uniforms: {
-		color1: Uniform;
-		color2: Uniform;
-		color3: Uniform;
-		colorBias: Uniform;
-		densityMap: Uniform;
-	};
-	vertexShader: string;
-	fragmentShader: string;
-}
-
-declare interface DebugShader {
-	uniforms: {
-		color1: Uniform;
-		color2: Uniform;
-		color3: Uniform;
-		colorBias: Uniform;
-		densityMap: Uniform;
-	};
-	vertexShader: string;
-	fragmentShader: string;
-}

+ 0 - 1062
examples/jsm/objects/Fire.js

@@ -1,1062 +0,0 @@
-import {
-	Clock,
-	Color,
-	DataTexture,
-	LinearFilter,
-	MathUtils,
-	Mesh,
-	NearestFilter,
-	NoToneMapping,
-	OrthographicCamera,
-	PlaneBufferGeometry,
-	RGBAFormat,
-	Scene,
-	ShaderMaterial,
-	Vector2,
-	WebGLRenderTarget
-} from "../../../build/three.module.js";
-/**
- * Based on research paper "Real-Time Fluid Dynamics for Games" by Jos Stam
- * http://www.dgp.toronto.edu/people/stam/reality/Research/pdf/GDC03.pdf
- *
- */
-
-var Fire = function ( geometry, options ) {
-
-	Mesh.call( this, geometry );
-
-	this.type = 'Fire';
-
-	this.clock = new Clock();
-
-	options = options || {};
-
-	var textureWidth = options.textureWidth || 512;
-	var textureHeight = options.textureHeight || 512;
-	var oneOverWidth = 1.0 / textureWidth;
-	var oneOverHeight = 1.0 / textureHeight;
-
-	var debug = ( options.debug === undefined ) ? false : options.debug;
-	this.color1 = options.color1 || new Color( 0xffffff );
-	this.color2 = options.color2 || new Color( 0xffa000 );
-	this.color3 = options.color3 || new Color( 0x000000 );
-	this.colorBias = ( options.colorBias === undefined ) ? 0.8 : options.colorBias;
-	this.diffuse = ( options.diffuse === undefined ) ? 1.33 : options.diffuse;
-	this.viscosity = ( options.viscosity === undefined ) ? 0.25 : options.viscosity;
-	this.expansion = ( options.expansion === undefined ) ? - 0.25 : options.expansion;
-	this.swirl = ( options.swirl === undefined ) ? 50.0 : options.swirl;
-	this.burnRate = ( options.burnRate === undefined ) ? 0.3 : options.burnRate;
-	this.drag = ( options.drag === undefined ) ? 0.35 : options.drag;
-	this.airSpeed = ( options.airSpeed === undefined ) ? 6.0 : options.airSpeed;
-	this.windVector = options.windVector || new Vector2( 0.0, 0.75 );
-	this.speed = ( options.speed === undefined ) ? 500.0 : options.speed;
-	this.massConservation = ( options.massConservation === undefined ) ? false : options.massConservation;
-
-	var size = textureWidth * textureHeight;
-	this.sourceData = new Uint8Array( 4 * size );
-
-	this.clearSources = function () {
-
-		for ( var y = 0; y < textureHeight; y ++ ) {
-
-			for ( var x = 0; x < textureWidth; x ++ ) {
-
-				var i = y * textureWidth + x;
-				var stride = i * 4;
-
-				this.sourceData[ stride ] = 0;
-				this.sourceData[ stride + 1 ] = 0;
-				this.sourceData[ stride + 2 ] = 0;
-				this.sourceData[ stride + 3 ] = 0;
-
-			}
-
-		}
-
-		this.sourceMaterial.uniforms[ "sourceMap" ].value = this.internalSource;
-		this.sourceMaterial.needsUpdate = true;
-
-		return this.sourceData;
-
-	};
-
-	this.addSource = function ( u, v, radius, density = null, windX = null, windY = null ) {
-
-		var startX = Math.max( Math.floor( ( u - radius ) * textureWidth ), 0 );
-		var startY = Math.max( Math.floor( ( v - radius ) * textureHeight ), 0 );
-		var endX = Math.min( Math.floor( ( u + radius ) * textureWidth ), textureWidth );
-		var endY = Math.min( Math.floor( ( v + radius ) * textureHeight ), textureHeight );
-
-		for ( var y = startY; y < endY; y ++ ) {
-
-			for ( var x = startX; x < endX; x ++ ) {
-
-				var diffX = x * oneOverWidth - u;
-				var diffY = y * oneOverHeight - v;
-
-				if ( diffX * diffX + diffY * diffY < radius * radius ) {
-
-					var i = y * textureWidth + x;
-					var stride = i * 4;
-
-					if ( density != null ) {
-
-						this.sourceData[ stride ] = Math.min( Math.max( density, 0.0 ), 1.0 ) * 255;
-
-					}
-
-					if ( windX != null ) {
-
-						var wind = Math.min( Math.max( windX, - 1.0 ), 1.0 );
-						wind = ( wind < 0.0 ) ? Math.floor( wind * 127 ) + 255 : Math.floor( wind * 127 );
-						this.sourceData[ stride + 1 ] = wind;
-
-					}
-
-					if ( windY != null ) {
-
-						var wind = Math.min( Math.max( windY, - 1.0 ), 1.0 );
-						wind = ( wind < 0.0 ) ? Math.floor( wind * 127 ) + 255 : Math.floor( wind * 127 );
-						this.sourceData[ stride + 2 ] = wind;
-
-					}
-
-				}
-
-			}
-
-		}
-
-		this.internalSource.needsUpdate = true;
-
-		return this.sourceData;
-
-	};
-
-	// When setting source map, red channel is density. Green and blue channels
-	// encode x and y velocity respectively as signed chars:
-	// (0 -> 127 = 0.0 -> 1.0, 128 -> 255 = -1.0 -> 0.0 )
-	this.setSourceMap = function ( texture ) {
-
-		this.sourceMaterial.uniforms[ "sourceMap" ].value = texture;
-
-	};
-
-	var parameters = {
-		minFilter: NearestFilter,
-		magFilter: NearestFilter,
-		depthBuffer: false
-	};
-
-
-	this.field0 = new WebGLRenderTarget( textureWidth, textureHeight, parameters );
-
-	this.field0.background = new Color( 0x000000 );
-
-	this.field1 = new WebGLRenderTarget( textureWidth, textureHeight, parameters );
-
-	this.field0.background = new Color( 0x000000 );
-
-	this.fieldProj = new WebGLRenderTarget( textureWidth, textureHeight, parameters );
-
-	this.field0.background = new Color( 0x000000 );
-
-	if ( ! MathUtils.isPowerOfTwo( textureWidth ) ||
-		 ! MathUtils.isPowerOfTwo( textureHeight ) ) {
-
-		this.field0.texture.generateMipmaps = false;
-		this.field1.texture.generateMipmaps = false;
-		this.fieldProj.texture.generateMipmaps = false;
-
-	}
-
-
-	this.fieldScene = new Scene();
-	this.fieldScene.background = new Color( 0x000000 );
-
-	this.orthoCamera = new OrthographicCamera( textureWidth / - 2, textureWidth / 2, textureHeight / 2, textureHeight / - 2, 1, 2 );
-	this.orthoCamera.position.z = 1;
-
-	this.fieldGeometry = new PlaneBufferGeometry( textureWidth, textureHeight );
-
-	this.internalSource = new DataTexture( this.sourceData, textureWidth, textureHeight, RGBAFormat );
-
-	// Source Shader
-
-	var shader = Fire.SourceShader;
-	this.sourceMaterial = new ShaderMaterial( {
-		uniforms: shader.uniforms,
-		vertexShader: shader.vertexShader,
-		fragmentShader: shader.fragmentShader,
-		transparent: false
-	} );
-
-	this.clearSources();
-
-	this.sourceMesh = new Mesh( this.fieldGeometry, this.sourceMaterial );
-	this.fieldScene.add( this.sourceMesh );
-
-	// Diffuse Shader
-
-	var shader = Fire.DiffuseShader;
-	this.diffuseMaterial = new ShaderMaterial( {
-		uniforms: shader.uniforms,
-		vertexShader: shader.vertexShader,
-		fragmentShader: shader.fragmentShader,
-		transparent: false
-	} );
-
-	this.diffuseMaterial.uniforms[ "oneOverWidth" ].value = oneOverWidth;
-	this.diffuseMaterial.uniforms[ "oneOverHeight" ].value = oneOverHeight;
-
-	this.diffuseMesh = new Mesh( this.fieldGeometry, this.diffuseMaterial );
-	this.fieldScene.add( this.diffuseMesh );
-
-	// Drift Shader
-
-	shader = Fire.DriftShader;
-	this.driftMaterial = new ShaderMaterial( {
-		uniforms: shader.uniforms,
-		vertexShader: shader.vertexShader,
-		fragmentShader: shader.fragmentShader,
-		transparent: false
-	} );
-
-	this.driftMaterial.uniforms[ "oneOverWidth" ].value = oneOverWidth;
-	this.driftMaterial.uniforms[ "oneOverHeight" ].value = oneOverHeight;
-
-	this.driftMesh = new Mesh( this.fieldGeometry, this.driftMaterial );
-	this.fieldScene.add( this.driftMesh );
-
-	// Projection Shader 1
-
-	shader = Fire.ProjectionShader1;
-	this.projMaterial1 = new ShaderMaterial( {
-		uniforms: shader.uniforms,
-		vertexShader: shader.vertexShader,
-		fragmentShader: shader.fragmentShader,
-		transparent: false
-	} );
-
-	this.projMaterial1.uniforms[ "oneOverWidth" ].value = oneOverWidth;
-	this.projMaterial1.uniforms[ "oneOverHeight" ].value = oneOverHeight;
-
-	this.projMesh1 = new Mesh( this.fieldGeometry, this.projMaterial1 );
-	this.fieldScene.add( this.projMesh1 );
-
-	// Projection Shader 2
-
-	shader = Fire.ProjectionShader2;
-	this.projMaterial2 = new ShaderMaterial( {
-		uniforms: shader.uniforms,
-		vertexShader: shader.vertexShader,
-		fragmentShader: shader.fragmentShader,
-		transparent: false
-	} );
-
-
-	this.projMaterial2.uniforms[ "oneOverWidth" ].value = oneOverWidth;
-	this.projMaterial2.uniforms[ "oneOverHeight" ].value = oneOverHeight;
-
-	this.projMesh2 = new Mesh( this.fieldGeometry, this.projMaterial2 );
-	this.fieldScene.add( this.projMesh2 );
-
-	// Projection Shader 3
-
-	shader = Fire.ProjectionShader3;
-	this.projMaterial3 = new ShaderMaterial( {
-		uniforms: shader.uniforms,
-		vertexShader: shader.vertexShader,
-		fragmentShader: shader.fragmentShader,
-		transparent: false
-	} );
-
-
-	this.projMaterial3.uniforms[ "oneOverWidth" ].value = oneOverWidth;
-	this.projMaterial3.uniforms[ "oneOverHeight" ].value = oneOverHeight;
-
-	this.projMesh3 = new Mesh( this.fieldGeometry, this.projMaterial3 );
-	this.fieldScene.add( this.projMesh3 );
-
-	// Color Shader
-
-	if ( debug ) {
-
-		shader = Fire.DebugShader;
-
-	} else {
-
-		shader = Fire.ColorShader;
-
-	}
-
-	this.material = new ShaderMaterial( {
-		uniforms: shader.uniforms,
-		vertexShader: shader.vertexShader,
-		fragmentShader: shader.fragmentShader,
-		transparent: true
-	} );
-
-	this.material.uniforms[ "densityMap" ].value = this.field1.texture;
-
-	this.configShaders = function ( dt ) {
-
-		this.diffuseMaterial.uniforms[ "diffuse" ].value = dt * 0.05 * this.diffuse;
-		this.diffuseMaterial.uniforms[ "viscosity" ].value = dt * 0.05 * this.viscosity;
-		this.diffuseMaterial.uniforms[ "expansion" ].value = Math.exp( this.expansion * - 1.0 );
-		this.diffuseMaterial.uniforms[ "swirl" ].value = Math.exp( this.swirl * - 0.1 );
-		this.diffuseMaterial.uniforms[ "drag" ].value = Math.exp( this.drag * - 0.1 );
-		this.diffuseMaterial.uniforms[ "burnRate" ].value = this.burnRate * dt * 0.01;
-		this.driftMaterial.uniforms[ "windVector" ].value = this.windVector;
-		this.driftMaterial.uniforms[ "airSpeed" ].value = dt * this.airSpeed * 0.001 * textureHeight;
-		this.material.uniforms[ "color1" ].value = this.color1;
-		this.material.uniforms[ "color2" ].value = this.color2;
-		this.material.uniforms[ "color3" ].value = this.color3;
-		this.material.uniforms[ "colorBias" ].value = this.colorBias;
-
-	};
-
-	this.clearDiffuse = function () {
-
-		this.diffuseMaterial.uniforms[ "expansion" ].value = 1.0;
-		this.diffuseMaterial.uniforms[ "swirl" ].value = 1.0;
-		this.diffuseMaterial.uniforms[ "drag" ].value = 1.0;
-		this.diffuseMaterial.uniforms[ "burnRate" ].value = 0.0;
-
-	};
-
-	this.swapTextures = function () {
-
-		var swap = this.field0;
-		this.field0 = this.field1;
-		this.field1 = swap;
-
-	};
-
-	this.saveRenderState = function ( renderer ) {
-
-		this.savedRenderTarget = renderer.getRenderTarget();
-		this.savedXrEnabled = renderer.xr.enabled;
-		this.savedShadowAutoUpdate = renderer.shadowMap.autoUpdate;
-		this.savedAntialias = renderer.antialias;
-		this.savedToneMapping = renderer.toneMapping;
-
-	};
-
-	this.restoreRenderState = function ( renderer ) {
-
-		renderer.xr.enabled = this.savedXrEnabled;
-		renderer.shadowMap.autoUpdate = this.savedShadowAutoUpdate;
-		renderer.setRenderTarget( this.savedRenderTarget );
-		renderer.antialias = this.savedAntialias;
-		renderer.toneMapping = this.savedToneMapping;
-
-	};
-
-	this.renderSource = function ( renderer ) {
-
-		this.sourceMesh.visible = true;
-
-		this.sourceMaterial.uniforms[ "densityMap" ].value = this.field0.texture;
-
-		renderer.setRenderTarget( this.field1 );
-		renderer.render( this.fieldScene, this.orthoCamera );
-
-		this.sourceMesh.visible = false;
-
-		this.swapTextures();
-
-	};
-
-	this.renderDiffuse = function ( renderer ) {
-
-		this.diffuseMesh.visible = true;
-
-		this.diffuseMaterial.uniforms[ "densityMap" ].value = this.field0.texture;
-
-		renderer.setRenderTarget( this.field1 );
-		renderer.render( this.fieldScene, this.orthoCamera );
-
-		this.diffuseMesh.visible = false;
-
-		this.swapTextures();
-
-	};
-
-	this.renderDrift = function ( renderer ) {
-
-		this.driftMesh.visible = true;
-
-		this.driftMaterial.uniforms[ "densityMap" ].value = this.field0.texture;
-
-		renderer.setRenderTarget( this.field1 );
-		renderer.render( this.fieldScene, this.orthoCamera );
-
-		this.driftMesh.visible = false;
-
-		this.swapTextures();
-
-	};
-
-	this.renderProject = function ( renderer ) {
-
-		// Projection pass 1
-
-		this.projMesh1.visible = true;
-
-		this.projMaterial1.uniforms[ "densityMap" ].value = this.field0.texture;
-
-		renderer.setRenderTarget( this.fieldProj );
-		renderer.render( this.fieldScene, this.orthoCamera );
-
-		this.projMesh1.visible = false;
-
-		this.projMaterial2.uniforms[ "densityMap" ].value = this.fieldProj.texture;
-
-		// Projection pass 2
-
-		this.projMesh2.visible = true;
-
-		for ( var i = 0; i < 20; i ++ ) {
-
-			renderer.setRenderTarget( this.field1 );
-			renderer.render( this.fieldScene, this.orthoCamera );
-
-			var temp = this.field1;
-			this.field1 = this.fieldProj;
-			this.fieldProj = temp;
-
-			this.projMaterial2.uniforms[ "densityMap" ].value = this.fieldProj.texture;
-
-		}
-
-		this.projMesh2.visible = false;
-
-		this.projMaterial3.uniforms[ "densityMap" ].value = this.field0.texture;
-		this.projMaterial3.uniforms[ "projMap" ].value = this.fieldProj.texture;
-
-		// Projection pass 3
-
-		this.projMesh3.visible = true;
-
-		renderer.setRenderTarget( this.field1 );
-		renderer.render( this.fieldScene, this.orthoCamera );
-
-		this.projMesh3.visible = false;
-
-		this.swapTextures();
-
-	};
-
-	this.onBeforeRender = function ( renderer ) {
-
-		var delta = this.clock.getDelta();
-
-		if ( delta > 0.1 ) {
-
-			delta = 0.1;
-
-		}
-
-		var dt = delta * ( this.speed * 0.1 );
-
-		this.configShaders( dt );
-
-		this.saveRenderState( renderer );
-
-		renderer.xr.enabled = false; // Avoid camera modification and recursion
-		renderer.shadowMap.autoUpdate = false; // Avoid re-computing shadows
-		renderer.antialias = false;
-		renderer.toneMapping = NoToneMapping;
-
-		this.sourceMesh.visible = false;
-		this.diffuseMesh.visible = false;
-		this.driftMesh.visible = false;
-		this.projMesh1.visible = false;
-		this.projMesh2.visible = false;
-		this.projMesh3.visible = false;
-
-		this.renderSource( renderer );
-
-		this.clearDiffuse();
-
-		for ( var i = 0; i < 21; i ++ ) {
-
-			this.renderDiffuse( renderer );
-
-		}
-
-		this.configShaders( dt );
-		this.renderDiffuse( renderer );
-
-		this.renderDrift( renderer );
-
-		if ( this.massConservation ) {
-
-			this.renderProject( renderer );
-			this.renderProject( renderer );
-
-		}
-
-		// Final result out for coloring
-
-		this.material.map = this.field1.texture;
-		this.material.transparent = true;
-		this.material.minFilter = LinearFilter,
-		this.material.magFilter = LinearFilter,
-
-		this.restoreRenderState( renderer );
-
-	};
-
-};
-
-
-Fire.prototype = Object.create( Mesh.prototype );
-Fire.prototype.constructor = Fire;
-
-Fire.SourceShader = {
-
-	uniforms: {
-		'sourceMap': {
-			value: null
-		},
-		'densityMap': {
-			value: null
-		}
-	},
-
-	vertexShader: [
-		'varying vec2 vUv;',
-
-		'void main() {',
-
-		' 	  vUv = uv;',
-
-		'     vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );',
-		'     gl_Position = projectionMatrix * mvPosition;',
-
-		'}'
-
-	].join( "\n" ),
-
-	fragmentShader: [
-		'uniform sampler2D sourceMap;',
-		'uniform sampler2D densityMap;',
-
-		'varying vec2 vUv;',
-
-		'void main() {',
-		'    vec4 source = texture2D( sourceMap, vUv );',
-		'    vec4 current = texture2D( densityMap, vUv );',
-
-		'    vec2 v0 = (current.gb - step(0.5, current.gb)) * 2.0;',
-		'    vec2 v1 = (source.gb - step(0.5, source.gb)) * 2.0;',
-
-		'    vec2 newVel = v0 + v1;',
-
-		'    newVel = clamp(newVel, -0.99, 0.99);',
-		'    newVel = newVel * 0.5 + step(0.0, -newVel);',
-
-		'    float newDensity = source.r + current.a;',
-		'    float newTemp = source.r + current.r;',
-
-		'    newDensity = clamp(newDensity, 0.0, 1.0);',
-		'    newTemp = clamp(newTemp, 0.0, 1.0);',
-
-		'    gl_FragColor = vec4(newTemp, newVel.xy, newDensity);',
-
-		'}'
-
-	].join( "\n" )
-};
-
-
-Fire.DiffuseShader = {
-
-	uniforms: {
-		'oneOverWidth': {
-			value: null
-		},
-		'oneOverHeight': {
-			value: null
-		},
-		'diffuse': {
-			value: null
-		},
-		'viscosity': {
-			value: null
-		},
-		'expansion': {
-			value: null
-		},
-		'swirl': {
-			value: null
-		},
-		'drag': {
-			value: null
-		},
-		'burnRate': {
-			value: null
-		},
-		'densityMap': {
-			value: null
-		}
-	},
-
-	vertexShader: [
-		'varying vec2 vUv;',
-
-		'void main() {',
-
-		' 	  vUv = uv;',
-
-		'     vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );',
-		'     gl_Position = projectionMatrix * mvPosition;',
-
-		'}'
-
-	].join( "\n" ),
-
-	fragmentShader: [
-		'uniform float oneOverWidth;',
-		'uniform float oneOverHeight;',
-		'uniform float diffuse;',
-		'uniform float viscosity;',
-		'uniform float expansion;',
-		'uniform float swirl;',
-		'uniform float burnRate;',
-		'uniform float drag;',
-		'uniform sampler2D densityMap;',
-
-		'varying vec2 vUv;',
-
-		'void main() {',
-
-		'    vec4 dC = texture2D( densityMap, vUv );',
-		'    vec4 dL = texture2D( densityMap, vec2(vUv.x - oneOverWidth, vUv.y) );',
-		'    vec4 dR = texture2D( densityMap, vec2(vUv.x + oneOverWidth, vUv.y) );',
-		'    vec4 dU = texture2D( densityMap, vec2(vUv.x, vUv.y - oneOverHeight) );',
-		'    vec4 dD = texture2D( densityMap, vec2(vUv.x, vUv.y + oneOverHeight) );',
-		'    vec4 dUL = texture2D( densityMap, vec2(vUv.x - oneOverWidth, vUv.y - oneOverHeight) );',
-		'    vec4 dUR = texture2D( densityMap, vec2(vUv.x + oneOverWidth, vUv.y - oneOverHeight) );',
-		'    vec4 dDL = texture2D( densityMap, vec2(vUv.x - oneOverWidth, vUv.y + oneOverHeight) );',
-		'    vec4 dDR = texture2D( densityMap, vec2(vUv.x + oneOverWidth, vUv.y + oneOverHeight) );',
-
-		'    dC.yz = (dC.yz - step(0.5, dC.yz)) * 2.0;',
-		'    dL.yz = (dL.yz - step(0.5, dL.yz)) * 2.0;',
-		'    dR.yz = (dR.yz - step(0.5, dR.yz)) * 2.0;',
-		'    dU.yz = (dU.yz - step(0.5, dU.yz)) * 2.0;',
-		'    dD.yz = (dD.yz - step(0.5, dD.yz)) * 2.0;',
-		'    dUL.yz = (dUL.yz - step(0.5, dUL.yz)) * 2.0;',
-		'    dUR.yz = (dUR.yz - step(0.5, dUR.yz)) * 2.0;',
-		'    dDL.yz = (dDL.yz - step(0.5, dDL.yz)) * 2.0;',
-		'    dDR.yz = (dDR.yz - step(0.5, dDR.yz)) * 2.0;',
-
-		'    vec4 result = (dC + vec4(diffuse, viscosity, viscosity, diffuse) * ( dL + dR + dU + dD + dUL + dUR + dDL + dDR )) / (1.0 + 8.0 * vec4(diffuse, viscosity, viscosity, diffuse)) - vec4(0.0, 0.0, 0.0, 0.001);',
-
-		'    float temperature = result.r;',
-		'    temperature = clamp(temperature - burnRate, 0.0, 1.0);',
-
-		'    vec2 velocity = result.yz;',
-
-		'    vec2 expansionVec = vec2(dL.w - dR.w, dU.w - dD.w);',
-
-		'    vec2 swirlVec = vec2((dL.z - dR.z) * 0.5, (dU.y - dD.y) * 0.5);',
-
-		'    velocity = velocity + (1.0 - expansion) * expansionVec + (1.0 - swirl) * swirlVec;',
-
-		'    velocity = velocity - (1.0 - drag) * velocity;',
-
-		'    gl_FragColor = vec4(temperature, velocity * 0.5 + step(0.0, -velocity), result.w);',
-
-		'    gl_FragColor = gl_FragColor * step(oneOverWidth, vUv.x);',
-		'    gl_FragColor = gl_FragColor * step(oneOverHeight, vUv.y);',
-		'    gl_FragColor = gl_FragColor * step(vUv.x, 1.0 - oneOverWidth);',
-		'    gl_FragColor = gl_FragColor * step(vUv.y, 1.0 - oneOverHeight);',
-
-		'}'
-
-	].join( "\n" )
-};
-
-Fire.DriftShader = {
-
-	uniforms: {
-		'oneOverWidth': {
-			value: null
-		},
-		'oneOverHeight': {
-			value: null
-		},
-		'windVector': {
-			value: new Vector2( 0.0, 0.0 )
-		},
-		'airSpeed': {
-			value: null
-		},
-		'densityMap': {
-			value: null
-		}
-	},
-
-	vertexShader: [
-		'varying vec2 vUv;',
-
-		'void main() {',
-
-		' 	  vUv = uv;',
-
-		'     vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );',
-		'     gl_Position = projectionMatrix * mvPosition;',
-
-		'}'
-
-	].join( "\n" ),
-
-	fragmentShader: [
-		'uniform float oneOverWidth;',
-		'uniform float oneOverHeight;',
-		'uniform vec2 windVector;',
-		'uniform float airSpeed;',
-		'uniform sampler2D densityMap;',
-
-		'varying vec2 vUv;',
-
-		'void main() {',
-		'    vec2 velocity = texture2D( densityMap, vUv ).gb;',
-		'    velocity = (velocity - step(0.5, velocity)) * 2.0;',
-
-		'    velocity = velocity + windVector;',
-
-		'    vec2 sourcePos = vUv - airSpeed * vec2(oneOverWidth, oneOverHeight) * velocity;',
-
-		'    vec2 units = sourcePos / vec2(oneOverWidth, oneOverHeight);',
-
-		'    vec2 intPos = floor(units);',
-		'    vec2 frac = units - intPos;',
-		'    intPos = intPos * vec2(oneOverWidth, oneOverHeight);',
-
-		'    vec4 dX0Y0 = texture2D( densityMap, intPos + vec2(0.0, -oneOverHeight) );',
-		'    vec4 dX1Y0 = texture2D( densityMap, intPos + vec2(oneOverWidth, 0.0) );',
-		'    vec4 dX0Y1 = texture2D( densityMap, intPos + vec2(0.0, oneOverHeight) );',
-		'    vec4 dX1Y1 = texture2D( densityMap, intPos + vec2(oneOverWidth, oneOverHeight) );',
-
-
-		'    dX0Y0.gb = (dX0Y0.gb - step(0.5, dX0Y0.gb)) * 2.0;',
-		'    dX1Y0.gb = (dX1Y0.gb - step(0.5, dX1Y0.gb)) * 2.0;',
-		'    dX0Y1.gb = (dX0Y1.gb - step(0.5, dX0Y1.gb)) * 2.0;',
-		'    dX1Y1.gb = (dX1Y1.gb - step(0.5, dX1Y1.gb)) * 2.0;',
-
-		'    vec4 source = mix(mix(dX0Y0, dX1Y0, frac.x), mix(dX0Y1, dX1Y1, frac.x), frac.y);',
-
-		'    source.gb = source.gb * 0.5 + step(0.0, -source.gb);',
-
-		'    gl_FragColor = source;',
-
-		'}'
-
-	].join( "\n" )
-};
-
-
-Fire.ProjectionShader1 = {
-
-	uniforms: {
-		'oneOverWidth': {
-			value: null
-		},
-		'oneOverHeight': {
-			value: null
-		},
-		'densityMap': {
-			value: null
-		}
-	},
-
-	vertexShader: [
-		'varying vec2 vUv;',
-
-		'void main() {',
-
-		' 	  vUv = uv;',
-
-		'     vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );',
-		'     gl_Position = projectionMatrix * mvPosition;',
-
-		'}'
-
-	].join( "\n" ),
-
-	fragmentShader: [
-		'uniform float oneOverWidth;',
-		'uniform float oneOverHeight;',
-		'uniform sampler2D densityMap;',
-
-		'varying vec2 vUv;',
-
-		'void main() {',
-		'    float dL = texture2D( densityMap, vec2(vUv.x - oneOverWidth, vUv.y) ).g;',
-		'    float dR = texture2D( densityMap, vec2(vUv.x + oneOverWidth, vUv.y) ).g;',
-		'    float dU = texture2D( densityMap, vec2(vUv.x, vUv.y - oneOverHeight) ).b;',
-		'    float dD = texture2D( densityMap, vec2(vUv.x, vUv.y + oneOverHeight) ).b;',
-
-		'    dL = (dL - step(0.5, dL)) * 2.0;',
-		'    dR = (dR - step(0.5, dR)) * 2.0;',
-		'    dU = (dU - step(0.5, dU)) * 2.0;',
-		'    dD = (dD - step(0.5, dD)) * 2.0;',
-
-		'    float h = (oneOverWidth + oneOverHeight) * 0.5;',
-		'    float div = -0.5 * h * (dR - dL + dD - dU);',
-
-		'    gl_FragColor = vec4( 0.0, 0.0, div * 0.5 + step(0.0, -div), 0.0);',
-
-		'}'
-
-	].join( "\n" )
-};
-
-
-Fire.ProjectionShader2 = {
-
-	uniforms: {
-		'oneOverWidth': {
-			value: null
-		},
-		'oneOverHeight': {
-			value: null
-		},
-		'densityMap': {
-			value: null
-		}
-	},
-
-	vertexShader: [
-		'varying vec2 vUv;',
-
-		'void main() {',
-
-		' 	  vUv = uv;',
-
-		'     vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );',
-		'     gl_Position = projectionMatrix * mvPosition;',
-
-		'}'
-
-	].join( "\n" ),
-
-	fragmentShader: [
-		'uniform float oneOverWidth;',
-		'uniform float oneOverHeight;',
-		'uniform sampler2D densityMap;',
-
-		'varying vec2 vUv;',
-
-		'void main() {',
-		'    float div = texture2D( densityMap, vUv ).b;',
-		'    float pL = texture2D( densityMap, vec2(vUv.x - oneOverWidth, vUv.y) ).g;',
-		'    float pR = texture2D( densityMap, vec2(vUv.x + oneOverWidth, vUv.y) ).g;',
-		'    float pU = texture2D( densityMap, vec2(vUv.x, vUv.y - oneOverHeight) ).g;',
-		'    float pD = texture2D( densityMap, vec2(vUv.x, vUv.y + oneOverHeight) ).g;',
-
-		'    float divNorm = (div - step(0.5, div)) * 2.0;',
-		'    pL = (pL - step(0.5, pL)) * 2.0;',
-		'    pR = (pR - step(0.5, pR)) * 2.0;',
-		'    pU = (pU - step(0.5, pU)) * 2.0;',
-		'    pD = (pD - step(0.5, pD)) * 2.0;',
-
-		'    float p = (divNorm + pR + pL + pD + pU) * 0.25;',
-
-		'    gl_FragColor = vec4( 0.0, p * 0.5 + step(0.0, -p), div, 0.0);',
-
-		'}'
-
-	].join( "\n" )
-};
-
-
-Fire.ProjectionShader3 = {
-
-	uniforms: {
-		'oneOverWidth': {
-			value: null
-		},
-		'oneOverHeight': {
-			value: null
-		},
-		'densityMap': {
-			value: null
-		},
-		'projMap': {
-			value: null
-		}
-	},
-
-	vertexShader: [
-		'varying vec2 vUv;',
-
-		'void main() {',
-
-		' 	  vUv = uv;',
-
-		'     vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );',
-		'     gl_Position = projectionMatrix * mvPosition;',
-
-		'}'
-
-	].join( "\n" ),
-
-	fragmentShader: [
-		'uniform float oneOverWidth;',
-		'uniform float oneOverHeight;',
-		'uniform sampler2D densityMap;',
-		'uniform sampler2D projMap;',
-
-		'varying vec2 vUv;',
-
-		'void main() {',
-		'    vec4 orig = texture2D(densityMap, vUv);',
-
-		'    float pL = texture2D( projMap, vec2(vUv.x - oneOverWidth, vUv.y) ).g;',
-		'    float pR = texture2D( projMap, vec2(vUv.x + oneOverWidth, vUv.y) ).g;',
-		'    float pU = texture2D( projMap, vec2(vUv.x, vUv.y - oneOverHeight) ).g;',
-		'    float pD = texture2D( projMap, vec2(vUv.x, vUv.y + oneOverHeight) ).g;',
-
-		'    float uNorm = (orig.g - step(0.5, orig.g)) * 2.0;',
-		'    float vNorm = (orig.b - step(0.5, orig.b)) * 2.0;',
-
-		'    pL = (pL - step(0.5, pL)) * 2.0;',
-		'    pR = (pR - step(0.5, pR)) * 2.0;',
-		'    pU = (pU - step(0.5, pU)) * 2.0;',
-		'    pD = (pD - step(0.5, pD)) * 2.0;',
-
-		'    float h = (oneOverWidth + oneOverHeight) * 0.5;',
-		'    float u = uNorm - (0.5 * (pR - pL) / h);',
-		'    float v = vNorm - (0.5 * (pD - pU) / h);',
-
-		'    gl_FragColor = vec4( orig.r, u * 0.5 + step(0.0, -u), v * 0.5 + step(0.0, -v), orig.a);',
-
-		'}'
-
-	].join( "\n" )
-};
-
-Fire.ColorShader = {
-
-	uniforms: {
-		'color1': {
-			value: null
-		},
-		'color2': {
-			value: null
-		},
-		'color3': {
-			value: null
-		},
-		'colorBias': {
-			value: null
-		},
-		'densityMap': {
-			value: null
-		}
-	},
-
-	vertexShader: [
-		'varying vec2 vUv;',
-
-		'void main() {',
-
-		' 	  vUv = uv;',
-
-		'     vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );',
-		'     gl_Position = projectionMatrix * mvPosition;',
-
-		'}'
-
-	].join( "\n" ),
-
-	fragmentShader: [
-		'uniform vec3 color1;',
-		'uniform vec3 color2;',
-		'uniform vec3 color3;',
-		'uniform float colorBias;',
-		'uniform sampler2D densityMap;',
-
-		'varying vec2 vUv;',
-
-		'void main() {',
-		'    float density = texture2D( densityMap, vUv ).a;',
-		'    float temperature = texture2D( densityMap, vUv ).r;',
-
-		'    float bias = clamp(colorBias, 0.0001, 0.9999);',
-
-		'    vec3 blend1 = mix(color3, color2, temperature / bias) * (1.0 - step(bias, temperature));',
-		'    vec3 blend2 = mix(color2, color1, (temperature - bias) / (1.0 - bias) ) * step(bias, temperature);',
-
-		'    gl_FragColor = vec4(blend1 + blend2, density);',
-		'}'
-
-	].join( "\n" )
-};
-
-
-Fire.DebugShader = {
-
-	uniforms: {
-		'color1': {
-			value: null
-		},
-		'color2': {
-			value: null
-		},
-		'color3': {
-			value: null
-		},
-		'colorBias': {
-			value: null
-		},
-		'densityMap': {
-			value: null
-		}
-	},
-
-	vertexShader: [
-		'varying vec2 vUv;',
-
-		'void main() {',
-
-		' 	  vUv = uv;',
-
-		'     vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );',
-		'     gl_Position = projectionMatrix * mvPosition;',
-
-		'}'
-
-	].join( "\n" ),
-
-	fragmentShader: [
-		'uniform sampler2D densityMap;',
-
-		'varying vec2 vUv;',
-
-		'void main() {',
-		'    float density;',
-		'    density = texture2D( densityMap, vUv ).a;',
-
-		'    vec2 vel = texture2D( densityMap, vUv ).gb;',
-
-		'    vel = (vel - step(0.5, vel)) * 2.0;',
-
-		'    float r = density;',
-		'    float g = max(abs(vel.x), density * 0.5);',
-		'    float b = max(abs(vel.y), density * 0.5);',
-		'    float a = max(density * 0.5, max(abs(vel.x), abs(vel.y)));',
-
-		'    gl_FragColor = vec4(r, g, b, a);',
-
-		'}'
-
-	].join( "\n" )
-};
-
-export { Fire };

BIN
examples/screenshots/webgl_fire.jpg


+ 0 - 462
examples/webgl_fire.html

@@ -1,462 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-	<head>
-		<title>three.js webgl - fire</title>
-		<meta charset="utf-8">
-		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
-		<link type="text/css" rel="stylesheet" href="main.css">
-	</head>
-	<body>
-
-		<div id="info">
-			<a href="https://threejs.org" target="_blank" rel="noopener noreferrer">three.js</a> fire and smoke demo
-		</div>
-
-		<script type="module">
-
-			import * as THREE from '../build/three.module.js';
-
-			import Stats from './jsm/libs/stats.module.js';
-			import { GUI } from './jsm/libs/dat.gui.module.js';
-
-			import { Fire } from './jsm/objects/Fire.js';
-
-			var camera, scene, renderer, stats;
-			var fire;
-
-			var params = {
-				color1: '#ffffff',
-				color2: '#ffa000',
-				color3: '#000000',
-				colorBias: 0.8,
-				burnRate: 0.35,
-				diffuse: 1.33,
-				viscosity: 0.25,
-				expansion: - 0.25,
-				swirl: 50.0,
-				drag: 0.35,
-				airSpeed: 12.0,
-				windX: 0.0,
-				windY: 0.75,
-				speed: 500.0,
-				massConservation: false
-			};
-
-			init();
-			animate();
-
-			function init() {
-
-				var width = window.innerWidth;
-				var height = window.innerHeight;
-
-				camera = new THREE.PerspectiveCamera( 70, width / height, 1, 1000 );
-				camera.position.z = 25;
-
-				scene = new THREE.Scene();
-				scene.background = new THREE.Color( 0x000000 );
-
-				var ambientLight = new THREE.AmbientLight( 0xcccccc, 0.4 );
-				scene.add( ambientLight );
-
-				var pointLight = new THREE.PointLight( 0xffffff, 0.8 );
-				camera.add( pointLight );
-				scene.add( camera );
-
-				var plane = new THREE.PlaneBufferGeometry( 20, 20 );
-				fire = new Fire( plane, {
-					textureWidth: 512,
-					textureHeight: 512,
-					debug: false
-				} );
-				fire.position.z = - 2;
-				scene.add( fire );
-
-				renderer = new THREE.WebGLRenderer( { antialias: true } );
-				renderer.setPixelRatio( window.devicePixelRatio );
-				renderer.setSize( window.innerWidth, window.innerHeight );
-				renderer.autoClear = false;
-				document.body.appendChild( renderer.domElement );
-
-				function updateColor1( value ) {
-
-					fire.color1.set( value );
-
-				}
-
-				function updateColor2( value ) {
-
-					fire.color2.set( value );
-
-				}
-
-				function updateColor3( value ) {
-
-					fire.color3.set( value );
-
-				}
-
-				function updateColorBias( value ) {
-
-					fire.colorBias = value;
-
-				}
-
-				function updateBurnRate( value ) {
-
-					fire.burnRate = value;
-
-				}
-
-				function updateDiffuse( value ) {
-
-					fire.diffuse = value;
-
-				}
-
-				function updateViscosity( value ) {
-
-					fire.viscosity = value;
-
-				}
-
-				function updateExpansion( value ) {
-
-					fire.expansion = value;
-
-				}
-
-				function updateSwirl( value ) {
-
-					fire.swirl = value;
-
-				}
-
-				function updateDrag( value ) {
-
-					fire.drag = value;
-
-				}
-
-				function updateAirSpeed( value ) {
-
-					fire.airSpeed = value;
-
-				}
-
-				function updateWindX( value ) {
-
-					fire.windVector.x = value;
-
-				}
-
-				function updateWindY( value ) {
-
-					fire.windVector.y = value;
-
-				}
-
-				function updateSpeed( value ) {
-
-					fire.speed = value;
-
-				}
-
-				function updateMassConservation( value ) {
-
-					fire.massConservation = value;
-
-				}
-
-				params.Single = function () {
-
-					fire.clearSources();
-					fire.addSource( 0.5, 0.1, 0.1, 1.0, 0.0, 1.0 );
-
-				};
-
-				params.Multiple = function () {
-
-					fire.clearSources();
-					fire.addSource( 0.45, 0.1, 0.1, 0.5, 0.0, 1.0 );
-					fire.addSource( 0.55, 0.1, 0.1, 0.5, 0.0, 1.0 );
-
-				};
-
-				params.Text = function () {
-
-					var text = "Three JS";
-					var size = 180;
-					var color = "#FF0040";
-					var canvas = document.createElement( "canvas" );
-					canvas.width = 1024;
-					canvas.height = 1024;
-					var context = canvas.getContext( "2d" );
-					context.font = size + "pt Arial";
-
-					context.strokeStyle = "black";
-					context.strokeRect( 0, 0, canvas.width, canvas.height );
-					context.textAlign = "center";
-					context.textBaseline = "middle";
-					context.lineWidth = 5;
-					context.strokeStyle = color;
-					context.fillStyle = "black";
-
-					context.strokeText( text, canvas.width / 2, canvas.height * 0.75 );
-					var texture = new THREE.Texture( canvas );
-					texture.needsUpdate = true;
-
-					fire.setSourceMap( texture );
-
-				};
-
-				// dat.gui
-				var gui = new GUI();
-
-				gui.add( params, "Single" );
-				gui.add( params, "Multiple" );
-				gui.add( params, "Text" );
-
-				gui.addColor( params, 'color1' ).onChange( updateColor1 );
-				gui.addColor( params, 'color2' ).onChange( updateColor2 );
-				gui.addColor( params, 'color3' ).onChange( updateColor3 );
-				gui.add( params, 'colorBias', 0.0, 1.0 ).onChange( updateColorBias );
-				gui.add( params, 'burnRate', 0.0, 10.0 ).onChange( updateBurnRate );
-				gui.add( params, 'diffuse', 0.0, 5.0 ).step( 0.01 ).onChange( updateDiffuse );
-				gui.add( params, 'viscosity', 0.0, 5.0 ).step( 0.01 ).onChange( updateViscosity );
-				gui.add( params, 'expansion', - 1.0, 1.0 ).step( 0.01 ).onChange( updateExpansion );
-				gui.add( params, 'swirl', 0.0, 50.0 ).step( 0.01 ).onChange( updateSwirl );
-				gui.add( params, 'drag', 0.0, 1.0 ).onChange( updateDrag );
-				gui.add( params, 'airSpeed', 0.0, 50.0 ).onChange( updateAirSpeed );
-				gui.add( params, 'windX', - 5, 5 ).step( 0.01 ).onChange( updateWindX );
-				gui.add( params, 'windY', - 5, 5 ).step( 0.01 ).onChange( updateWindY );
-				gui.add( params, 'speed', 0, 1000 ).onChange( updateSpeed );
-				gui.add( params, 'massConservation' ).onChange( updateMassConservation );
-
-				function updateAll() {
-
-					updateColor1( params.color1 );
-					updateColor2( params.color2 );
-					updateColor3( params.color3 );
-					updateColorBias( params.colorBias );
-					updateBurnRate( params.burnRate );
-					updateDiffuse( params.diffuse );
-					updateViscosity( params.viscosity );
-					updateExpansion( params.expansion );
-					updateSwirl( params.swirl );
-					updateDrag( params.drag );
-					updateAirSpeed( params.airSpeed );
-					updateWindX( params.windX );
-					updateWindY( params.windY );
-					updateSpeed( params.speed );
-					updateMassConservation( params.massConservation );
-
-					for ( var i in gui.__controllers ) {
-
-						gui.__controllers[ i ].updateDisplay();
-
-					}
-
-				}
-
-				params.Candle = function () {
-
-					params.color1 = 0xffffff;
-					params.color2 = 0xffa000;
-					params.color3 = 0x000000;
-					params.windX = 0.0;
-					params.windY = 0.5;
-					params.colorBias = 0.3;
-					params.burnRate = 1.6;
-					params.diffuse = 1.33;
-					params.viscosity = 1.33;
-					params.expansion = 0.0;
-					params.swirl = 0.0;
-					params.drag = 0.0;
-					params.airSpeed = 8.0;
-					params.speed = 500.0;
-					params.massConservation = false;
-
-					updateAll();
-
-				};
-				gui.add( params, 'Candle' );
-
-				params.Torch = function () {
-
-					params.color1 = 0xffdcaa;
-					params.color2 = 0xffa000;
-					params.color3 = 0x000000;
-					params.windX = 0.0;
-					params.windY = 0.75;
-					params.colorBias = 0.9;
-					params.burnRate = 1.0;
-					params.diffuse = 1.33;
-					params.viscosity = 0.25;
-					params.expansion = 0.0;
-					params.swirl = 50.0;
-					params.drag = 0.35;
-					params.airSpeed = 10.0;
-					params.speed = 500.0;
-					params.massConservation = false;
-
-					updateAll();
-
-				};
-				gui.add( params, 'Torch' );
-
-				params.Campfire = function () {
-
-					params.color1 = 0xffffff;
-					params.color2 = 0xffa000;
-					params.color3 = 0x000000;
-					params.windX = 0.0;
-					params.windY = 0.75;
-					params.colorBias = 0.8;
-					params.burnRate = 0.3;
-					params.diffuse = 1.33;
-					params.viscosity = 0.25;
-					params.expansion = - 0.25;
-					params.swirl = 50.0;
-					params.drag = 0.35;
-					params.airSpeed = 12.0;
-					params.speed = 500.0;
-					params.massConservation = false;
-
-					updateAll();
-
-				};
-				gui.add( params, 'Campfire' );
-
-				params.Fireball = function () {
-
-					params.color1 = 0xffffff;
-					params.color2 = 0xffa000;
-					params.color3 = 0x000000;
-					params.windX = 0.0;
-					params.windY = 0.75;
-					params.colorBias = 0.8;
-					params.burnRate = 1.2;
-					params.diffuse = 3.0;
-					params.viscosity = 0.0;
-					params.expansion = 0.0;
-					params.swirl = 6.0;
-					params.drag = 0.0;
-					params.airSpeed = 20.0;
-					params.speed = 500.0;
-					params.massConservation = false;
-
-					updateAll();
-
-				};
-				gui.add( params, 'Fireball' );
-
-				params.Iceball = function () {
-
-					params.color1 = 0x00bdf7;
-					params.color2 = 0x1b3fb6;
-					params.color3 = 0x001869;
-					params.windX = 0.0;
-					params.windY = - 0.25;
-					params.colorBias = 0.25;
-					params.burnRate = 2.6;
-					params.diffuse = 5.0;
-					params.viscosity = 0.5;
-					params.expansion = 0.75;
-					params.swirl = 30.0;
-					params.drag = 0.0;
-					params.airSpeed = 40.0;
-					params.speed = 500.0;
-					params.massConservation = false;
-
-					updateAll();
-
-				};
-				gui.add( params, 'Iceball' );
-
-				params.Smoke = function () {
-
-					params.color1 = 0xd2d2d2;
-					params.color2 = 0xd7d7d7;
-					params.color3 = 0x000000;
-					params.windX = - 0.05;
-					params.windY = 0.15;
-					params.colorBias = 0.95;
-					params.burnRate = 0.0;
-					params.diffuse = 1.5;
-					params.viscosity = 0.25;
-					params.expansion = 0.2;
-					params.swirl = 3.75;
-					params.drag = 0.4;
-					params.airSpeed = 18.0;
-					params.speed = 500.0;
-					params.massConservation = false;
-
-					updateAll();
-
-				};
-				gui.add( params, 'Smoke' );
-
-				params.Cigar = function () {
-
-					params.color1 = 0xc5c5c5;
-					params.color2 = 0x787878;
-					params.color3 = 0x000000;
-					params.windX = 0.0;
-					params.windY = 0.3;
-					params.colorBias = 0.55;
-					params.burnRate = 0.0;
-					params.diffuse = 1.3;
-					params.viscosity = 0.05;
-					params.expansion = - 0.05;
-					params.swirl = 3.7;
-					params.drag = 0.6;
-					params.airSpeed = 6.0;
-					params.speed = 500.0;
-					params.massConservation = false;
-
-					updateAll();
-
-				};
-				gui.add( params, 'Cigar' );
-
-				gui.open();
-
-				params.Campfire();
-				params.Single();
-
-				stats = new Stats();
-				document.body.appendChild( stats.dom );
-
-				window.addEventListener( 'resize', onWindowResize, false );
-
-				if ( typeof TESTING !== 'undefined'  ) { for( var i = 0; i < 60; i ++ ) { renderer.render( scene, camera ); } };
-
-			}
-
-			function onWindowResize() {
-
-				var width = window.innerWidth;
-				var height = window.innerHeight;
-
-				camera.aspect = width / height;
-				camera.updateProjectionMatrix();
-
-				renderer.setSize( window.innerWidth, window.innerHeight );
-
-			}
-
-			function animate() {
-
-				requestAnimationFrame( animate );
-
-				renderer.clear();
-				renderer.render( scene, camera );
-				stats.update();
-
-			}
-
-		</script>
-
-	</body>
-</html>

+ 0 - 1
utils/modularize.js

@@ -121,7 +121,6 @@ var files = [
 	{ path: 'modifiers/SubdivisionModifier.js', dependencies: [], ignoreList: [] },
 	{ path: 'modifiers/TessellateModifier.js', dependencies: [], ignoreList: [] },
 
-	{ path: 'objects/Fire.js', dependencies: [], ignoreList: [] },
 	{ path: 'objects/Lensflare.js', dependencies: [], ignoreList: [] },
 	{ path: 'objects/LightningStorm.js', dependencies: [ { name: 'LightningStrike', path: 'geometries/LightningStrike.js' } ], ignoreList: [ 'Material' ] },
 	{ path: 'objects/MarchingCubes.js', dependencies: [], ignoreList: [] },