提交 e42e37ee 编写于 作者: M Mugen87

Examples: Clean up

上级 a6ad8c59
......@@ -431,7 +431,7 @@ THREE.Fire = function ( geometry, options ) {
};
this.onBeforeRender = function ( renderer, scene, camera ) {
this.onBeforeRender = function ( renderer ) {
var delta = this.clock.getDelta();
if ( delta > 0.1 ) {
......
......@@ -3,53 +3,53 @@
*
* @fileoverview Lightning strike object generator
*
*
*
* Usage
*
*
* var myStorm = new THREE.LightningStorm( paramsObject );
* myStorm.position.set( ... );
* scene.add( myStorm );
* ...
* myStorm.update( currentTime );
*
*
* The "currentTime" can only go forwards or be stopped.
*
*
*
*
* LightningStorm parameters:
*
* @param {double} size Size of the storm. If no 'onRayPosition' parameter is defined, it means the side of the rectangle the storm covers.
*
* @param {double} minHeight Minimum height a ray can start at. If no 'onRayPosition' parameter is defined, it means the height above plane y = 0.
*
*
* @param {double} maxHeight Maximum height a ray can start at. If no 'onRayPosition' parameter is defined, it means the height above plane y = 0.
*
*
* @param {double} maxSlope The maximum inclination slope of a ray. If no 'onRayPosition' parameter is defined, it means the slope relative to plane y = 0.
*
*
* @param {integer} maxLightnings Greater than 0. The maximum number of simultaneous rays.
*
*
* @param {double} lightningMinPeriod minimum time between two consecutive rays.
*
*
* @param {double} lightningMaxPeriod maximum time between two consecutive rays.
*
*
* @param {double} lightningMinDuration The minimum time a ray can last.
*
*
* @param {double} lightningMaxDuration The maximum time a ray can last.
*
*
* @param {Object} lightningParameters The parameters for created rays. See THREE.LightningStrike (geometry)
*
*
* @param {Material} lightningMaterial The THREE.Material used for the created rays.
*
*
* @param {function} onRayPosition Optional callback with two Vector3 parameters (source, dest). You can set here the start and end points for each created ray, using the standard size, minHeight, etc parameters and other values in your algorithm.
*
*
* @param {function} onLightningDown This optional callback is called with one parameter (lightningStrike) when a ray ends propagating, so it has hit the ground.
*
*
*
*/
THREE.LightningStorm = function ( stormParams ) {
THREE.Object3D.call( this );
// Parameters
stormParams = stormParams || {};
......@@ -71,21 +71,20 @@ THREE.LightningStorm = function ( stormParams ) {
this.lightningParameters = THREE.LightningStrike.copyParameters( stormParams.lightningParameters, stormParams.lightningParameters );
this.lightningParameters.isEternal = false;
this.lightningMaterial = stormParams.lightningMaterial !== undefined ? stormParams.lightningMaterial : new THREE.MeshBasicMaterial( { color: 0xB0FFFF } );
if ( stormParams.onRayPosition !== undefined ) {
this.onRayPosition = stormParams.onRayPosition;
}
else {
} else {
this.onRayPosition = function( source, dest ) {
this.onRayPosition = function ( source, dest ) {
dest.set( ( Math.random() - 0.5 ) * stormParams.size, 0, ( Math.random() - 0.5 ) * stormParams.size );
var height = THREE.Math.lerp( stormParams.minHeight, stormParams.maxHeight, Math.random() );;
var height = THREE.Math.lerp( stormParams.minHeight, stormParams.maxHeight, Math.random() );
source.set( stormParams.maxSlope * ( 2 * Math.random() - 1 ), 1, stormParams.maxSlope * ( 2 * Math.random() - 1 ) ).multiplyScalar( height ).add( dest );
......@@ -102,7 +101,7 @@ THREE.LightningStorm = function ( stormParams ) {
this.lightningsMeshes = [];
this.deadLightningsMeshes = [];
for ( var i = 0; i < this.stormParams.maxLightnings; i++ ) {
for ( var i = 0; i < this.stormParams.maxLightnings; i ++ ) {
var lightning = new THREE.LightningStrike( THREE.LightningStrike.copyParameters( {}, this.lightningParameters ) );
var mesh = new THREE.Mesh( lightning, this.lightningMaterial );
......@@ -155,9 +154,9 @@ THREE.LightningStorm.prototype.update = function ( time ) {
}
var i = 0; il = this.lightningsMeshes.length;
var i = 0, il = this.lightningsMeshes.length;
while ( i < il ){
while ( i < il ) {
var mesh = this.lightningsMeshes[ i ];
......@@ -181,18 +180,17 @@ THREE.LightningStorm.prototype.update = function ( time ) {
// Lightning is to be destroyed
this.lightningsMeshes.splice( this.lightningsMeshes.indexOf( mesh ), 1 );
this.lightningsMeshes.splice( this.lightningsMeshes.indexOf( mesh ), 1 );
this.deadLightningsMeshes.push( mesh );
this.remove( mesh );
il--;
il --;
}
else {
} else {
i++;
i ++;
}
......@@ -207,8 +205,8 @@ THREE.LightningStorm.prototype.getNextLightningTime = function ( currentTime ) {
};
THREE.LightningStorm.prototype.copy = function ( source ) {
Object3D.prototype.copy.call( this, source );
THREE.Object3D.prototype.copy.call( this, source );
this.stormParams.size = source.stormParams.size;
this.stormParams.minHeight = source.stormParams.minHeight;
......
......@@ -133,8 +133,7 @@ THREE.Sky.SkyShader = {
'const float pi = 3.141592653589793238462643383279502884197169;',
'const float n = 1.0003;', // refractive index of air
'const float N = 2.545E25;', // number of molecules per unit volume for air at
// 288.15K and 1013mb (sea level -45 celsius)
'const float N = 2.545E25;', // number of molecules per unit volume for air at 288.15K and 1013mb (sea level -45 celsius)
// optical length at zenith for molecules
'const float rayleighZenithLength = 8.4E3;',
......
......@@ -9,7 +9,7 @@ THREE.CSS2DObject = function ( element ) {
this.element = element;
this.element.style.position = 'absolute';
this.addEventListener( 'removed', function ( event ) {
this.addEventListener( 'removed', function () {
if ( this.element.parentNode !== null ) {
......
......@@ -322,7 +322,7 @@ THREE.Projector = function () {
_face.material = material;
if ( material.vertexColors === THREE.FaceColors || material.vertexColors === THREE.VertexColors ) {
if ( material.vertexColors === THREE.FaceColors || material.vertexColors === THREE.VertexColors ) {
_face.color.fromArray( colors, a * 3 );
......@@ -1038,8 +1038,8 @@ THREE.Projector = function () {
var alpha1 = 0, alpha2 = 1,
// Calculate the boundary coordinate of each vertex for the near and far clip planes,
// Z = -1 and Z = +1, respectively.
// Calculate the boundary coordinate of each vertex for the near and far clip planes,
// Z = -1 and Z = +1, respectively.
bc1near = s1.z + s1.w,
bc2near = s2.z + s2.w,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册