forked from mrdoob/three.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce FogExp with class, GLSL, docs and current applications
Also correct TS docstring and misspelled name in test file for FogExp2, and doc for standard Fog. Includes the change to distance-based depth, as well as corrections to better support mediump. Makes mrdoob#17316 and mrdoob#17324 obsolete.
- Loading branch information
1 parent
ab18028
commit 67a00eb
Showing
21 changed files
with
205 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<base href="../../../" /> | ||
<script src="list.js"></script> | ||
<script src="page.js"></script> | ||
<link type="text/css" rel="stylesheet" href="page.css" /> | ||
</head> | ||
<body> | ||
<h1>[name]</h1> | ||
|
||
<p class="desc">This class contains the parameters that define exponential fog, i.e., that grows exponentially denser with the distance.</p> | ||
|
||
|
||
<h2>Constructor</h2> | ||
|
||
|
||
<h3>[name]( [param:Integer color], [param:Float density] )</h3> | ||
|
||
<p>The color parameter is passed to the [page:Color] constructor to set the color property. Color can be a hexadecimal integer or a CSS-style string.</p> | ||
<h2>Properties</h2> | ||
|
||
<h3>[property:String name]</h3> | ||
<p>Optional name of the object (doesn't need to be unique). Default is an empty string.</p> | ||
|
||
<h3>[property:Color color]</h3> | ||
<p>Fog color. Example: If set to black, far away objects will be rendered black.</p> | ||
|
||
<h3>[property:Float density]</h3> | ||
<p>Defines how fast the fog will grow dense.</p> | ||
<p>Default is 0.015.</p> | ||
|
||
<h2>Methods</h2> | ||
|
||
<h3>[method:FogExp clone]()</h3> | ||
<p>Returns a new FogExp instance with the same parameters as this one.</p> | ||
|
||
<h3>[method:FogExp toJSON]()</h3> | ||
<p>Return FogExp data in JSON format.</p> | ||
|
||
<h2>Source</h2> | ||
|
||
<p> | ||
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] | ||
</p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
export default /* glsl */` | ||
#ifdef USE_FOG | ||
varying float fogDepth; | ||
varying vec3 fogPosition; | ||
#endif | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
export default /* glsl */` | ||
#ifdef USE_FOG | ||
fogDepth = -mvPosition.z; | ||
fogPosition = mvPosition.xyz; | ||
#endif | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Color } from './../math/Color'; | ||
import { IFog } from './Fog'; | ||
/** | ||
* This class contains the parameters that define exponential fog, i.e., that grows exponentially denser with the distance. | ||
*/ | ||
export class FogExp implements IFog { | ||
|
||
constructor( hex: number | string, density?: number ); | ||
|
||
name: string; | ||
color: Color; | ||
|
||
/** | ||
* Defines how fast the fog will grow dense. | ||
* Default is 0.015. | ||
*/ | ||
density: number; | ||
|
||
clone(): this; | ||
toJSON(): any; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* @author mrdoob / http://mrdoob.com/ | ||
* @author alteredq / http://alteredqualia.com/ | ||
* @author EliasHasle / http://eliashasle.github.io/ | ||
*/ | ||
|
||
import { Color } from '../math/Color.js'; | ||
|
||
function FogExp( color, density ) { | ||
|
||
this.name = ''; | ||
|
||
this.color = new Color( color ); | ||
this.density = ( density !== undefined ) ? density : 0.015; | ||
|
||
} | ||
|
||
Object.assign( FogExp.prototype, { | ||
|
||
isFogExp: true, | ||
|
||
clone: function () { | ||
|
||
return new FogExp( this.color, this.density ); | ||
|
||
}, | ||
|
||
toJSON: function ( /* meta */ ) { | ||
|
||
return { | ||
type: 'FogExp', | ||
color: this.color.getHex(), | ||
density: this.density | ||
}; | ||
|
||
} | ||
|
||
} ); | ||
|
||
export { FogExp }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* @author TristanVALCKE / https://github.com/Itee | ||
*/ | ||
/* global QUnit */ | ||
|
||
import { FogExp } from '../../../../src/scenes/FogExp'; | ||
|
||
export default QUnit.module( 'FogExp', () => { | ||
|
||
QUnit.module( 'Scene', () => { | ||
|
||
// INHERITANCE | ||
QUnit.todo( "Extending", ( assert ) => { | ||
|
||
assert.ok( false, "everything's gonna be alright" ); | ||
|
||
} ); | ||
|
||
// INSTANCING | ||
QUnit.todo( "Instancing", ( assert ) => { | ||
|
||
assert.ok( false, "everything's gonna be alright" ); | ||
|
||
} ); | ||
|
||
// PUBLIC STUFF | ||
QUnit.todo( "isFogExp", ( assert ) => { | ||
|
||
assert.ok( false, "everything's gonna be alright" ); | ||
|
||
} ); | ||
|
||
QUnit.todo( "clone", ( assert ) => { | ||
|
||
assert.ok( false, "everything's gonna be alright" ); | ||
|
||
} ); | ||
|
||
QUnit.todo( "toJSON", ( assert ) => { | ||
|
||
assert.ok( false, "everything's gonna be alright" ); | ||
|
||
} ); | ||
|
||
} ); | ||
|
||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters