提交 e57b5d1e 编写于 作者: M Mr.doob

Merge branch 'codestyle' of https://github.com/gero3/three.js into dev

Conflicts:
	examples/js/loaders/ColladaLoader.js
......@@ -463,7 +463,7 @@ Sidebar.Material = function ( editor ) {
var mapEnabled = materialMapEnabled.getValue() === true;
if ( objectHasUvs ) {
if ( objectHasUvs ) {
material.map = mapEnabled ? materialMap.getValue() : null;
material.needsUpdate = true;
......@@ -480,7 +480,7 @@ Sidebar.Material = function ( editor ) {
var mapEnabled = materialAlphaMapEnabled.getValue() === true;
if ( objectHasUvs ) {
if ( objectHasUvs ) {
material.alphaMap = mapEnabled ? materialAlphaMap.getValue() : null;
material.needsUpdate = true;
......@@ -516,7 +516,7 @@ Sidebar.Material = function ( editor ) {
var bumpMapEnabled = materialBumpMapEnabled.getValue() === true;
if ( objectHasUvs ) {
if ( objectHasUvs ) {
material.bumpMap = bumpMapEnabled ? materialBumpMap.getValue() : null;
material.bumpScale = materialBumpScale.getValue();
......@@ -534,7 +534,7 @@ Sidebar.Material = function ( editor ) {
var normalMapEnabled = materialNormalMapEnabled.getValue() === true;
if ( objectHasUvs ) {
if ( objectHasUvs ) {
material.normalMap = normalMapEnabled ? materialNormalMap.getValue() : null;
material.needsUpdate = true;
......@@ -551,7 +551,7 @@ Sidebar.Material = function ( editor ) {
var specularMapEnabled = materialSpecularMapEnabled.getValue() === true;
if ( objectHasUvs ) {
if ( objectHasUvs ) {
material.specularMap = specularMapEnabled ? materialSpecularMap.getValue() : null;
material.needsUpdate = true;
......
......@@ -84,7 +84,7 @@ Sidebar.Object3D = function ( editor ) {
var objectNameRow = new UI.Panel();
var objectName = new UI.Input().setWidth( '150px' ).setFontSize( '12px' ).onChange( function () {
editor.nameObject( editor.selected, objectName.getValue() );
editor.nameObject( editor.selected, objectName.getValue() );
} );
......
......@@ -8,7 +8,7 @@ var Storage = function () {
if ( indexedDB === undefined ) {
console.warn( 'Storage: IndexedDB not available.' );
return { init: function (){}, get: function (){}, set: function (){}, clear: function (){} };
return { init: function () {}, get: function () {}, set: function () {}, clear: function () {} };
}
var name = 'threejs-editor';
......
......@@ -40,7 +40,7 @@ THREE.AudioObject = function ( url, volume, playbackRate, loop ) {
THREE.AudioObject.prototype.context = new webkitAudioContext();
} catch( error ) {
} catch ( error ) {
console.warn( "THREE.AudioObject: webkitAudioContext not found" );
return this;
......
......@@ -22,7 +22,7 @@ THREE.BlendCharacter = function () {
// Create the animations
for ( var i = 0; i < geometry.animations.length; ++i ) {
for ( var i = 0; i < geometry.animations.length; ++ i ) {
var animName = geometry.animations[ i ].name;
scope.animations[ animName ] = new THREE.Animation( scope, geometry.animations[ i ] );
......@@ -46,7 +46,7 @@ THREE.BlendCharacter = function () {
this.update = function( dt ) {
for ( var i = this.weightSchedule.length - 1; i >= 0; --i ) {
for ( var i = this.weightSchedule.length - 1; i >= 0; -- i ) {
var data = this.weightSchedule[ i ];
data.timeElapsed += dt;
......@@ -87,7 +87,7 @@ THREE.BlendCharacter = function () {
// lengths match. This is useful for smoothing out transitions that get out of
// phase such as between a walk and run cycle
for ( var i = this.warpSchedule.length - 1; i >= 0; --i ) {
for ( var i = this.warpSchedule.length - 1; i >= 0; -- i ) {
var data = this.warpSchedule[ i ];
data.timeElapsed += dt;
......@@ -203,17 +203,17 @@ THREE.BlendCharacter = function () {
this.unPauseAll = function() {
for ( var a in this.animations ) {
for ( var a in this.animations ) {
if ( this.animations[ a ].isPlaying && this.animations[ a ].isPaused ) {
if ( this.animations[ a ].isPlaying && this.animations[ a ].isPaused ) {
this.animations[ a ].pause();
this.animations[ a ].pause();
}
}
}
}
};
};
this.stopAll = function() {
......
......@@ -195,7 +195,7 @@ THREE.Car = function () {
var forwardDelta = this.speed * delta;
this.carOrientation += ( forwardDelta * this.STEERING_RADIUS_RATIO )* this.wheelOrientation;
this.carOrientation += ( forwardDelta * this.STEERING_RADIUS_RATIO ) * this.wheelOrientation;
// displacement
......@@ -363,8 +363,8 @@ THREE.Car = function () {
};
function quadraticEaseOut( k ) { return - k * ( k - 2 ); }
function cubicEaseOut( k ) { return --k * k * k + 1; }
function circularEaseOut( k ) { return Math.sqrt( 1 - --k * k ); }
function cubicEaseOut( k ) { return -- k * k * k + 1; }
function circularEaseOut( k ) { return Math.sqrt( 1 - -- k * k ); }
function sinusoidalEaseOut( k ) { return Math.sin( k * Math.PI / 2 ); }
function exponentialEaseOut( k ) { return k === 1 ? 1 : - Math.pow( 2, - 10 * k ) + 1; }
......
......@@ -48,8 +48,8 @@ var lastTime;
function plane(width, height) {
return function(u, v) {
var x = (u-0.5) * width;
var y = (v+0.5) * height;
var x = (u - 0.5) * width;
var y = (v + 0.5) * height;
var z = 0;
return new THREE.Vector3(x, y, z);
......@@ -94,8 +94,8 @@ var diff = new THREE.Vector3();
function satisifyConstrains(p1, p2, distance) {
diff.subVectors(p2.position, p1.position);
var currentDist = diff.length();
if (currentDist==0) return; // prevents division by 0
var correction = diff.multiplyScalar(1 - distance/currentDist);
if (currentDist == 0) return; // prevents division by 0
var correction = diff.multiplyScalar(1 - distance / currentDist);
var correctionHalf = correction.multiplyScalar(0.5);
p1.position.add(correctionHalf);
p2.position.sub(correctionHalf);
......@@ -114,47 +114,47 @@ function Cloth(w, h) {
var u, v;
// Create particles
for (v=0;v<=h;v++) {
for (u=0;u<=w;u++) {
for (v = 0; v <= h; v ++) {
for (u = 0; u <= w; u ++) {
particles.push(
new Particle(u/w, v/h, 0, MASS)
new Particle(u / w, v / h, 0, MASS)
);
}
}
// Structural
for (v=0;v<h;v++) {
for (u=0;u<w;u++) {
for (v = 0; v < h; v ++) {
for (u = 0; u < w; u ++) {
constrains.push([
particles[index(u, v)],
particles[index(u, v+1)],
particles[index(u, v + 1)],
restDistance
]);
constrains.push([
particles[index(u, v)],
particles[index(u+1, v)],
particles[index(u + 1, v)],
restDistance
]);
}
}
for (u=w, v=0;v<h;v++) {
for (u = w, v = 0; v < h; v ++) {
constrains.push([
particles[index(u, v)],
particles[index(u, v+1)],
particles[index(u, v + 1)],
restDistance
]);
}
for (v=h, u=0;u<w;u++) {
for (v = h, u = 0; u < w; u ++) {
constrains.push([
particles[index(u, v)],
particles[index(u+1, v)],
particles[index(u + 1, v)],
restDistance
]);
}
......@@ -211,7 +211,7 @@ function simulate(time) {
particles = cloth.particles;
for (i=0,il=faces.length;i<il;i++) {
for (i = 0,il = faces.length; i < il; i ++) {
face = faces[i];
normal = face.normal;
......@@ -222,8 +222,8 @@ function simulate(time) {
}
}
for (particles = cloth.particles, i=0, il = particles.length
;i<il;i++) {
for (particles = cloth.particles, i = 0, il = particles.length
; i < il; i ++) {
particle = particles[i];
particle.addForce(gravity);
......@@ -234,7 +234,7 @@ function simulate(time) {
constrains = cloth.constrains,
il = constrains.length;
for (i=0;i<il;i++) {
for (i = 0; i < il; i ++) {
constrain = constrains[i];
satisifyConstrains(constrain[0], constrain[1], constrain[2]);
}
......@@ -242,12 +242,12 @@ function simulate(time) {
// Ball Constrains
ballPosition.z = -Math.sin(Date.now()/600) * 90 ; //+ 40;
ballPosition.x = Math.cos(Date.now()/400) * 70
ballPosition.z = -Math.sin(Date.now() / 600) * 90 ; //+ 40;
ballPosition.x = Math.cos(Date.now() / 400) * 70
if (sphere.visible)
for (particles = cloth.particles, i=0, il = particles.length
;i<il;i++) {
for (particles = cloth.particles, i = 0, il = particles.length
; i < il; i ++) {
particle = particles[i];
pos = particle.position;
diff.subVectors(pos, ballPosition);
......@@ -259,8 +259,8 @@ function simulate(time) {
}
// Floor Constains
for (particles = cloth.particles, i=0, il = particles.length
;i<il;i++) {
for (particles = cloth.particles, i = 0, il = particles.length
; i < il; i ++) {
particle = particles[i];
pos = particle.position;
if (pos.y < -250) {
......@@ -269,7 +269,7 @@ function simulate(time) {
}
// Pin Constrains
for (i=0, il=pins.length;i<il;i++) {
for (i = 0, il = pins.length; i < il; i ++) {
var xy = pins[i];
var p = particles[xy];
p.position.copy(p.original);
......
......@@ -15,15 +15,15 @@
THREE.Curves = {};
THREE.Curves.GrannyKnot = THREE.Curve.create( function(){},
THREE.Curves.GrannyKnot = THREE.Curve.create( function() {},
function(t) {
t = 2 * Math.PI * t;
t = 2 * Math.PI * t;
var x = -0.22 * Math.cos(t) - 1.28 * Math.sin(t) - 0.44 * Math.cos(3 * t) - 0.78 * Math.sin(3 * t);
var y = -0.1 * Math.cos(2 * t) - 0.27 * Math.sin(2 * t) + 0.38 * Math.cos(4 * t) + 0.46 * Math.sin(4 * t);
var z = 0.7 * Math.cos(3 * t) - 0.4 * Math.sin(3 * t);
return new THREE.Vector3(x, y, z).multiplyScalar(20);
var x = -0.22 * Math.cos(t) - 1.28 * Math.sin(t) - 0.44 * Math.cos(3 * t) - 0.78 * Math.sin(3 * t);
var y = -0.1 * Math.cos(2 * t) - 0.27 * Math.sin(2 * t) + 0.38 * Math.cos(4 * t) + 0.46 * Math.sin(4 * t);
var z = 0.7 * Math.cos(3 * t) - 0.4 * Math.sin(3 * t);
return new THREE.Vector3(x, y, z).multiplyScalar(20);
}
);
......@@ -214,10 +214,10 @@ THREE.Curves.TrefoilPolynomialKnot = THREE.Curve.create(
// }
var scaleTo = function(x, y, t) {
var r = y - x;
return t * r + x;
var r = y - x;
return t * r + x;
}
}
THREE.Curves.FigureEightPolynomialKnot = THREE.Curve.create(
......
......@@ -6,7 +6,7 @@
var Detector = {
canvas: !! window.CanvasRenderingContext2D,
webgl: ( function () { try { var canvas = document.createElement( 'canvas' ); return !! ( window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ) ); } catch( e ) { return false; } } )(),
webgl: ( function () { try { var canvas = document.createElement( 'canvas' ); return !! ( window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ) ); } catch ( e ) { return false; } } )(),
workers: !! window.Worker,
fileapi: window.File && window.FileReader && window.FileList && window.Blob,
......
......@@ -2,7 +2,7 @@
var ImprovedNoise = function () {
var p = [151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,
var p = [ 151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,
23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,
174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,
133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,
......@@ -11,11 +11,11 @@ var ImprovedNoise = function () {
248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,
178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,
14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,
93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180];
93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180 ];
for (var i=0; i < 256 ; i++) {
for (var i = 0; i < 256 ; i ++) {
p[256+i] = p[i];
p[256 + i] = p[i];
}
......@@ -51,20 +51,20 @@ var ImprovedNoise = function () {
y -= floorY;
z -= floorZ;
var xMinus1 = x -1, yMinus1 = y - 1, zMinus1 = z - 1;
var xMinus1 = x - 1, yMinus1 = y - 1, zMinus1 = z - 1;
var u = fade(x), v = fade(y), w = fade(z);
var A = p[X]+Y, AA = p[A]+Z, AB = p[A+1]+Z, B = p[X+1]+Y, BA = p[B]+Z, BB = p[B+1]+Z;
var A = p[X] + Y, AA = p[A] + Z, AB = p[A + 1] + Z, B = p[X + 1] + Y, BA = p[B] + Z, BB = p[B + 1] + Z;
return lerp(w, lerp(v, lerp(u, grad(p[AA], x, y, z),
grad(p[BA], xMinus1, y, z)),
lerp(u, grad(p[AB], x, yMinus1, z),
grad(p[BB], xMinus1, yMinus1, z))),
lerp(v, lerp(u, grad(p[AA+1], x, y, zMinus1),
grad(p[BA+1], xMinus1, y, z-1)),
lerp(u, grad(p[AB+1], x, yMinus1, zMinus1),
grad(p[BB+1], xMinus1, yMinus1, zMinus1))));
lerp(v, lerp(u, grad(p[AA + 1], x, y, zMinus1),
grad(p[BA + 1], xMinus1, y, z - 1)),
lerp(u, grad(p[AB + 1], x, yMinus1, zMinus1),
grad(p[BB + 1], xMinus1, yMinus1, zMinus1))));
}
}
......
......@@ -210,7 +210,7 @@ THREE.MD2Character = function () {
//
var mesh = new THREE.MorphAnimMesh( geometry, materialTexture );
mesh.rotation.y = -Math.PI/2;
mesh.rotation.y = -Math.PI / 2;
mesh.castShadow = true;
mesh.receiveShadow = true;
......
......@@ -402,7 +402,7 @@ THREE.MD2CharacterComplex = function () {
if ( controls.moveForward ) {
if ( this.meshBody ) {
if ( this.meshBody ) {
this.meshBody.setAnimationDirectionForward( this.activeAnimation );
this.meshBody.setAnimationDirectionForward( this.oldAnimation );
......@@ -445,7 +445,7 @@ THREE.MD2CharacterComplex = function () {
// speed based on controls
if ( controls.crouch ) this.maxSpeed = this.crouchSpeed;
else this.maxSpeed = this.walkSpeed;
else this.maxSpeed = this.walkSpeed;
this.maxReverseSpeed = -this.maxSpeed;
......@@ -533,7 +533,7 @@ THREE.MD2CharacterComplex = function () {
//
var mesh = new THREE.MorphBlendMesh( geometry, materialTexture );
mesh.rotation.y = -Math.PI/2;
mesh.rotation.y = -Math.PI / 2;
//
......
......@@ -224,7 +224,7 @@ THREE.MarchingCubes = function ( resolution, material, enableUvs, enableColors )
// bottom of the cube
if ( bits & 16 ) {
if ( bits & 16 ) {
this.compNorm( qz );
this.compNorm( q1z );
......@@ -232,7 +232,7 @@ THREE.MarchingCubes = function ( resolution, material, enableUvs, enableColors )
};
if ( bits & 32 ) {
if ( bits & 32 ) {
this.compNorm( q1z );
this.compNorm( q1yz );
......@@ -485,22 +485,22 @@ THREE.MarchingCubes = function ( resolution, material, enableUvs, enableColors )
var x, y, z, y_offset, z_offset, fx, fy, fz, fz2, fy2, val;
for ( z = min_z; z < max_z; z++ ) {
for ( z = min_z; z < max_z; z ++ ) {
z_offset = this.size2 * z,
fz = z / this.size - ballz,
fz2 = fz * fz;
for ( y = min_y; y < max_y; y++ ) {
for ( y = min_y; y < max_y; y ++ ) {
y_offset = z_offset + this.size * y;
fy = y / this.size - bally;
fy2 = fy * fy;
for ( x = min_x; x < max_x; x++ ) {
for ( x = min_x; x < max_x; x ++ ) {
fx = x / this.size - ballx;
val = strength / ( 0.000001 + fx*fx + fy2 + fz2 ) - subtract;
val = strength / ( 0.000001 + fx * fx + fy2 + fz2 ) - subtract;
if ( val > 0.0 ) this.field[ y_offset + x ] += val;
}
......@@ -763,38 +763,38 @@ THREE.MarchingCubes.prototype.constructor = THREE.MarchingCubes;
// who in turn got them from Cory Gene Bloyd.
THREE.edgeTable = new Int32Array([
0x0 , 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c,
0x0, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c,
0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,
0x190, 0x99 , 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c,
0x190, 0x99, 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c,
0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90,
0x230, 0x339, 0x33 , 0x13a, 0x636, 0x73f, 0x435, 0x53c,
0x230, 0x339, 0x33, 0x13a, 0x636, 0x73f, 0x435, 0x53c,
0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30,
0x3a0, 0x2a9, 0x1a3, 0xaa , 0x7a6, 0x6af, 0x5a5, 0x4ac,
0x3a0, 0x2a9, 0x1a3, 0xaa, 0x7a6, 0x6af, 0x5a5, 0x4ac,
0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0,
0x460, 0x569, 0x663, 0x76a, 0x66 , 0x16f, 0x265, 0x36c,
0x460, 0x569, 0x663, 0x76a, 0x66, 0x16f, 0x265, 0x36c,
0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60,
0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff , 0x3f5, 0x2fc,
0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff, 0x3f5, 0x2fc,
0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0,
0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55 , 0x15c,
0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55, 0x15c,
0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950,
0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc ,
0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc,
0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0,
0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc,
0xcc , 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0,
0xcc, 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0,
0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c,
0x15c, 0x55 , 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650,
0x15c, 0x55, 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650,
0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc,
0x2fc, 0x3f5, 0xff , 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0,
0x2fc, 0x3f5, 0xff, 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0,
0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c,
0x36c, 0x265, 0x16f, 0x66 , 0x76a, 0x663, 0x569, 0x460,
0x36c, 0x265, 0x16f, 0x66, 0x76a, 0x663, 0x569, 0x460,
0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac,
0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa , 0x1a3, 0x2a9, 0x3a0,
0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa, 0x1a3, 0x2a9, 0x3a0,
0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c,
0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33 , 0x339, 0x230,
0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33, 0x339, 0x230,
0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c,
0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99 , 0x190,
0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99, 0x190,
0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c,
0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0])
0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0 ])
THREE.triTable = new Int32Array([
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
......@@ -1052,4 +1052,4 @@ THREE.triTable = new Int32Array([
1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]);
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ]);
......@@ -20,8 +20,8 @@
return value !== undefined ? value : defaultValue;
};
options = options || {};
this.clearColor = optionalParameter(options.CLEAR_COLOR, [1.0, 1.0, 1.0, 0.0]);
this.geometryOrigin = optionalParameter(options.GEOMETRY_ORIGIN, [-1000.0, -1000.0]);
this.clearColor = optionalParameter(options.CLEAR_COLOR, [ 1.0, 1.0, 1.0, 0.0 ]);
this.geometryOrigin = optionalParameter(options.GEOMETRY_ORIGIN, [ -1000.0, -1000.0 ]);
this.sunDirectionX = optionalParameter(options.SUN_DIRECTION[0], -1.0);
this.sunDirectionY = optionalParameter(options.SUN_DIRECTION[1], 1.0);
this.sunDirectionZ = optionalParameter(options.SUN_DIRECTION[2], 1.0);
......@@ -228,8 +228,8 @@ THREE.Ocean.prototype.generateSeedPhaseTexture = function() {
// Setup the seed texture
this.pingPhase = true;
var phaseArray = new window.Float32Array(this.resolution * this.resolution * 4);
for (var i = 0; i < this.resolution; i++) {
for (var j = 0; j < this.resolution; j++) {
for (var i = 0; i < this.resolution; i ++) {
for (var j = 0; j < this.resolution; j ++) {
phaseArray[i * this.resolution * 4 + j * 4] = Math.random() * 2.0 * Math.PI;
phaseArray[i * this.resolution * 4 + j * 4 + 1] = 0.0;
phaseArray[i * this.resolution * 4 + j * 4 + 2] = 0.0;
......@@ -283,7 +283,7 @@ THREE.Ocean.prototype.renderSpectrumFFT = function() {
this.scene.overrideMaterial = this.materialOceanHorizontal;
for (var i = 0; i < iterations; i++) {
for (var i = 0; i < iterations; i ++) {
if (i === 0) {
this.materialOceanHorizontal.uniforms.u_input.value = this.spectrumFramebuffer;
this.materialOceanHorizontal.uniforms.u_subtransformSize.value = Math.pow(2, (i % (iterations)) + 1);
......@@ -301,7 +301,7 @@ THREE.Ocean.prototype.renderSpectrumFFT = function() {
}
}
this.scene.overrideMaterial = this.materialOceanVertical;
for (var i = iterations; i < iterations*2; i++) {
for (var i = iterations; i < iterations * 2; i ++) {
if (i === iterations * 2 - 1) {
this.materialOceanVertical.uniforms.u_input.value = (iterations % 2 === 0) ? this.pingTransformFramebuffer : this.pongTransformFramebuffer;
this.materialOceanVertical.uniforms.u_subtransformSize.value = Math.pow(2, (i % (iterations)) + 1);
......
......@@ -29,7 +29,7 @@
function indexOfValue( array, value ) {
for ( var i = 0, il = array.length; i < il; i++ ) {
for ( var i = 0, il = array.length; i < il; i ++ ) {
if ( array[ i ] === value ) {
......@@ -45,7 +45,7 @@
function indexOfPropertyWithValue( array, property, value ) {
for ( var i = 0, il = array.length; i < il; i++ ) {
for ( var i = 0, il = array.length; i < il; i ++ ) {
if ( array[ i ][ property ] === value ) {
......@@ -140,7 +140,7 @@
if ( this.objectsDeferred.length > 0 ) {
for ( var i = 0, il = this.objectsDeferred.length; i < il; i++ ) {
for ( var i = 0, il = this.objectsDeferred.length; i < il; i ++ ) {
var deferred = this.objectsDeferred[ i ];
......@@ -221,7 +221,7 @@
geometry = object.geometry;
vertices = geometry.vertices;
for ( i = 0, l = vertices.length; i < l; i++ ) {
for ( i = 0, l = vertices.length; i < l; i ++ ) {
this.addObjectData( object, vertices[ i ] );
......@@ -232,7 +232,7 @@
geometry = object.geometry;
faces = geometry.faces;
for ( i = 0, l = faces.length; i < l; i++ ) {
for ( i = 0, l = faces.length; i < l; i ++ ) {
this.addObjectData( object, faces[ i ] );
......@@ -297,7 +297,7 @@
// remove from objects data list
for ( i = 0, l = objectsDataRemoved.length; i < l; i++ ) {
for ( i = 0, l = objectsDataRemoved.length; i < l; i ++ ) {
objectData = objectsDataRemoved[ i ];
......@@ -341,7 +341,7 @@
objectsData = octree.objectsData;
for ( i = 0, l = objectsData.length; i < l; i++ ) {
for ( i = 0, l = objectsData.length; i < l; i ++ ) {
objectData = objectsData[ i ];
......@@ -366,7 +366,7 @@
// check all object data for changes in position
// assumes all object matrices are up to date
for ( i = 0, l = this.objectsData.length; i < l; i++ ) {
for ( i = 0, l = this.objectsData.length; i < l; i ++ ) {
objectData = this.objectsData[ i ];
......@@ -402,7 +402,7 @@
// update changed objects
for ( i = 0, l = objectsUpdate.length; i < l; i++ ) {
for ( i = 0, l = objectsUpdate.length; i < l; i ++ ) {
objectData = objectsUpdate[ i ];
......@@ -429,14 +429,14 @@
parent = object.parent;
while( parent ) {
while ( parent ) {
parentCascade.push( parent );
parent = parent.parent;
}
for ( i = 0, l = parentCascade.length; i < l; i++ ) {
for ( i = 0, l = parentCascade.length; i < l; i ++ ) {
parent = parentCascade[ i ];
......@@ -494,7 +494,7 @@
// search each node of root
for ( i = 0, l = this.root.nodesIndices.length; i < l; i++ ) {
for ( i = 0, l = this.root.nodesIndices.length; i < l; i ++ ) {
node = this.root.nodesByIndex[ this.root.nodesIndices[ i ] ];
......@@ -511,7 +511,7 @@
// for each object data found
for ( i = 0, l = objects.length; i < l; i++ ) {
for ( i = 0, l = objects.length; i < l; i ++ ) {
objectData = objects[ i ];
object = objectData.object;
......@@ -739,7 +739,7 @@
// basic properties
this.id = this.tree.nodeCount++;
this.id = this.tree.nodeCount ++;
this.position = parameters.position instanceof THREE.Vector3 ? parameters.position : new THREE.Vector3();
this.radius = parameters.radius > 0 ? parameters.radius : 1;
this.indexOctant = parameters.indexOctant;
......@@ -811,7 +811,7 @@
// cascade
for ( i = 0, l = this.nodesIndices.length; i < l; i++ ) {
for ( i = 0, l = this.nodesIndices.length; i < l; i ++ ) {
this.nodesByIndex[ this.nodesIndices[ i ] ].updateProperties();
......@@ -832,7 +832,7 @@
// unset parent in nodes
for ( i = 0, l = nodesIndices.length; i < l; i++ ) {
for ( i = 0, l = nodesIndices.length; i < l; i ++ ) {
node = nodesByIndex[ nodesIndices[ i ] ];
......@@ -949,7 +949,7 @@
var i, l,
object;
for ( i = 0, l = objects.length; i < l; i++ ) {
for ( i = 0, l = objects.length; i < l; i ++ ) {
object = objects[ i ];
......@@ -977,7 +977,7 @@
if ( nodesRemovedFrom.length > 0 ) {
for ( i = 0, l = nodesRemovedFrom.length; i < l; i++ ) {
for ( i = 0, l = nodesRemovedFrom.length; i < l; i ++ ) {
nodesRemovedFrom[ i ].shrink();
......@@ -1021,7 +1021,7 @@
// search each object data for object and remove (slow)
for ( i = this.objects.length - 1; i >= 0; i-- ) {
for ( i = this.objects.length - 1; i >= 0; i -- ) {
objectData = this.objects[ i ];
......@@ -1059,7 +1059,7 @@
if ( removeData.searchComplete !== true ) {
for ( i = 0, l = this.nodesIndices.length; i < l; i++ ) {
for ( i = 0, l = this.nodesIndices.length; i < l; i ++ ) {
node = this.nodesByIndex[ this.nodesIndices[ i ] ];
......@@ -1106,7 +1106,7 @@
// for each object
for ( i = 0, l = this.objects.length; i < l; i++ ) {
for ( i = 0, l = this.objects.length; i < l; i ++ ) {
object = this.objects[ i ];
......@@ -1183,7 +1183,7 @@
// for each object
for ( i = 0, l = objects.length; i < l; i++ ) {
for ( i = 0, l = objects.length; i < l; i ++ ) {
object = objects[ i ];
......@@ -1314,7 +1314,7 @@
// reset counts
for ( i = 0, l = iom.length; i < l; i++ ) {
for ( i = 0, l = iom.length; i < l; i ++ ) {
iom[ i ].count = 0;
......@@ -1322,7 +1322,7 @@
// for all outside objects, find outside octants containing most objects
for ( i = 0, l = objects.length; i < l; i++ ) {
for ( i = 0, l = objects.length; i < l; i ++ ) {
object = objects[ i ];
......@@ -1344,11 +1344,11 @@
if ( flagsOutside & this.tree.FLAG_POS_X ) {
iom[ this.tree.INDEX_OUTSIDE_POS_X ].count++;
iom[ this.tree.INDEX_OUTSIDE_POS_X ].count ++;
} else if ( flagsOutside & this.tree.FLAG_NEG_X ) {
iom[ this.tree.INDEX_OUTSIDE_NEG_X ].count++;
iom[ this.tree.INDEX_OUTSIDE_NEG_X ].count ++;
}
......@@ -1356,11 +1356,11 @@
if ( flagsOutside & this.tree.FLAG_POS_Y ) {
iom[ this.tree.INDEX_OUTSIDE_POS_Y ].count++;
iom[ this.tree.INDEX_OUTSIDE_POS_Y ].count ++;
} else if ( flagsOutside & this.tree.FLAG_NEG_Y ) {
iom[ this.tree.INDEX_OUTSIDE_NEG_Y ].count++;
iom[ this.tree.INDEX_OUTSIDE_NEG_Y ].count ++;
}
......@@ -1368,11 +1368,11 @@
if ( flagsOutside & this.tree.FLAG_POS_Z ) {
iom[ this.tree.INDEX_OUTSIDE_POS_Z ].count++;
iom[ this.tree.INDEX_OUTSIDE_POS_Z ].count ++;
} else if ( flagsOutside & this.tree.FLAG_NEG_Z ) {
iom[ this.tree.INDEX_OUTSIDE_NEG_Z ].count++;
iom[ this.tree.INDEX_OUTSIDE_NEG_Z ].count ++;
}
......@@ -1474,7 +1474,7 @@
// add all expand objects to parent
for ( i = 0, l = objectsExpand.length; i < l; i++ ) {
for ( i = 0, l = objectsExpand.length; i < l; i ++ ) {
this.tree.root.addObject( objectsExpand[ i ] );
......@@ -1546,7 +1546,7 @@
nodes = toArray( nodes );
for ( i = 0, l = nodes.length; i < l; i++ ) {
for ( i = 0, l = nodes.length; i < l; i ++ ) {
node = nodes[ i ];
......@@ -1586,7 +1586,7 @@
nodeHeaviestObjectsCount = 0;
outsideHeaviestObjectsCount = this.objects.length;
for ( i = 0, l = this.nodesIndices.length; i < l; i++ ) {
for ( i = 0, l = this.nodesIndices.length; i < l; i ++ ) {
node = this.nodesByIndex[ this.nodesIndices[ i ] ];
......@@ -1625,7 +1625,7 @@
// handle all nodes
for ( i = 0, l = this.nodesIndices.length; i < l; i++ ) {
for ( i = 0, l = this.nodesIndices.length; i < l; i ++ ) {
node = this.nodesByIndex[ this.nodesIndices[ i ] ];
......@@ -1848,7 +1848,7 @@
// search subtree
for ( i = 0, l = this.nodesIndices.length; i < l; i++ ) {
for ( i = 0, l = this.nodesIndices.length; i < l; i ++ ) {
node = this.nodesByIndex[ this.nodesIndices[ i ] ];
......@@ -1917,7 +1917,7 @@
tmin = Math.max( Math.max( Math.min( t1, t2), Math.min( t3, t4)), Math.min( t5, t6));
// if tmin > tmax or tmin > ray distance, ray doesn't intersect AABB
if( tmin > tmax || tmin > distance ) {
if ( tmin > tmax || tmin > distance ) {
return false;
}
......@@ -1932,7 +1932,7 @@
if ( this.nodesIndices.length > 0 ) {
for ( i = 0, l = this.nodesIndices.length; i < l; i++ ) {
for ( i = 0, l = this.nodesIndices.length; i < l; i ++ ) {
node = this.nodesByIndex[ this.nodesIndices[ i ] ];
......@@ -1961,7 +1961,7 @@
var i, l,
count = this.nodesIndices.length;
for ( i = 0, l = this.nodesIndices.length; i < l; i++ ) {
for ( i = 0, l = this.nodesIndices.length; i < l; i ++ ) {
count += this.nodesByIndex[ this.nodesIndices[ i ] ].getNodeCountRecursive();
......@@ -1978,7 +1978,7 @@
objects = ( objects || [] ).concat( this.objects );
for ( i = 0, l = this.nodesIndices.length; i < l; i++ ) {
for ( i = 0, l = this.nodesIndices.length; i < l; i ++ ) {
node = this.nodesByIndex[ this.nodesIndices[ i ] ];
......@@ -1995,7 +1995,7 @@
var i, l,
count = this.objects.length;
for ( i = 0, l = this.nodesIndices.length; i < l; i++ ) {
for ( i = 0, l = this.nodesIndices.length; i < l; i ++ ) {
count += this.nodesByIndex[ this.nodesIndices[ i ] ].getObjectCountEnd();
......@@ -2010,7 +2010,7 @@
var count = this.objects.length,
parent = this.parent;
while( parent instanceof THREE.OctreeNode ) {
while ( parent instanceof THREE.OctreeNode ) {
count += parent.objects.length;
parent = parent.parent;
......@@ -2033,7 +2033,7 @@
console.log( ( this.parent ? space + ' ' : ' ' ), '+ objects ( ', this.objects.length, ' ) ', this.objects );
console.log( ( this.parent ? space + ' ' : ' ' ), '+ children ( ', this.nodesIndices.length, ' )', this.nodesIndices, this.nodesByIndex );
for ( i = 0, l = this.nodesIndices.length; i < l; i++ ) {
for ( i = 0, l = this.nodesIndices.length; i < l; i ++ ) {
node = this.nodesByIndex[ this.nodesIndices[ i ] ];
......@@ -2101,7 +2101,7 @@
var i, il,
intersects = [];
for ( i = 0, il = objects.length; i < il; i++ ) {
for ( i = 0, il = objects.length; i < il; i ++ ) {
intersects = intersects.concat( this.intersectOctreeObject( objects[ i ], recursive ) );
......
......@@ -48,9 +48,9 @@ THREE.ParametricGeometries = {
var x, y, z;
var a = 2;
x = Math.cos(v) * (a + u * Math.cos(v/2));
y = Math.sin(v) * (a + u * Math.cos(v/2));
z = u * Math.sin(v/2);
x = Math.cos(v) * (a + u * Math.cos(v / 2));
y = Math.sin(v) * (a + u * Math.cos(v / 2));
z = u * Math.sin(v / 2);
return new THREE.Vector3(x, y, z);
},
......@@ -108,9 +108,9 @@ THREE.ParametricGeometries.TubeGeometry = function(path, segments, radius, segme
binormals = frames.binormals;
// proxy internals
this.tangents = tangents;
this.normals = normals;
this.binormals = binormals;
this.tangents = tangents;
this.normals = normals;
this.binormals = binormals;
......
......@@ -217,7 +217,7 @@ THREE.ShaderTerrain = {
"#if MAX_HEMI_LIGHTS > 0",
"vec3 hemiDiffuse = vec3( 0.0 );",
"vec3 hemiSpecular = vec3( 0.0 );" ,
"vec3 hemiSpecular = vec3( 0.0 );",
"for( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {",
......
此差异已折叠。
......@@ -19,12 +19,12 @@ function SimulationRenderer(WIDTH, renderer) {
// Init RTT stuff
gl = renderer.getContext();
if( !gl.getExtension( "OES_texture_float" )) {
if ( !gl.getExtension( "OES_texture_float" )) {
alert( "No OES_texture_float support for float textures!" );
return;
}
if( gl.getParameter(gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS) == 0) {
if ( gl.getParameter(gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS) == 0) {
alert( "No support for vertex shader textures!" );
return;
}
......
......@@ -19,18 +19,18 @@ var SPARKS = {};
SPARKS.Emitter = function (counter) {
this._counter = counter ? counter : new SPARKS.SteadyCounter(10); // provides number of particles to produce
this._counter = counter ? counter : new SPARKS.SteadyCounter(10); // provides number of particles to produce
this._particles = [];
this._particles = [];
this._initializers = []; // use for creation of particles
this._actions = []; // uses action to update particles
this._activities = []; // not supported yet
this._initializers = []; // use for creation of particles
this._actions = []; // uses action to update particles
this._activities = []; // not supported yet
this._handlers = [];
this._handlers = [];
this.callbacks = {};
this.callbacks = {};
};
......@@ -77,14 +77,14 @@ SPARKS.Emitter.prototype = {
elapsed = maxBlock;
}
while(elapsed >= emitter._TIMESTEP) {
while (elapsed >= emitter._TIMESTEP) {
emitter.update(emitter._TIMESTEP / 1000);
elapsed -= emitter._TIMESTEP;
}
emitter._lastTime = time - elapsed;
} else {
emitter.update(elapsed/1000);
emitter.update(elapsed / 1000);
emitter._lastTime = time;
}
......@@ -99,108 +99,108 @@ SPARKS.Emitter.prototype = {
// Update particle engine in seconds, not milliseconds
update: function(time) {
var i, j;
var len = this._counter.updateEmitter( this, time );
var i, j;
var len = this._counter.updateEmitter( this, time );
// Create particles
for( i = 0; i < len; i++ ) {
this.createParticle();
}
for ( i = 0; i < len; i ++ ) {
this.createParticle();
}
// Update activities
len = this._activities.length;
for ( i = 0; i < len; i++ )
len = this._activities.length;
for ( i = 0; i < len; i ++ )
{
this._activities[i].update( this, time );
}
this._activities[i].update( this, time );
}
len = this._actions.length;
len = this._actions.length;
var particle;
var action;
var len2 = this._particles.length;
var particle;
var action;
var len2 = this._particles.length;
for( j = 0; j < len; j++ )
for ( j = 0; j < len; j ++ )
{
action = this._actions[j];
for ( i = 0; i < len2; ++i )
action = this._actions[j];
for ( i = 0; i < len2; ++ i )
{
particle = this._particles[i];
action.update( this, particle, time );
}
}
particle = this._particles[i];
action.update( this, particle, time );
}
}
// remove dead particles
for ( i = len2; i--; )
for ( i = len2; i --; )
{
particle = this._particles[i];
if ( particle.isDead )
particle = this._particles[i];
if ( particle.isDead )
{
//particle =
this._particles.splice( i, 1 );
this.dispatchEvent("dead", particle);
SPARKS.VectorPool.release(particle.position); //
SPARKS.VectorPool.release(particle.velocity);
this._particles.splice( i, 1 );
this.dispatchEvent("dead", particle);
SPARKS.VectorPool.release(particle.position); //
SPARKS.VectorPool.release(particle.velocity);
} else {
this.dispatchEvent("updated", particle);
}
}
} else {
this.dispatchEvent("updated", particle);
}
}
this.dispatchEvent("loopUpdated");
this.dispatchEvent("loopUpdated");
},
createParticle: function() {
var particle = new SPARKS.Particle();
var particle = new SPARKS.Particle();
// In future, use a Particle Factory
var len = this._initializers.length, i;
var len = this._initializers.length, i;
for ( i = 0; i < len; i++ ) {
this._initializers[i].initialize( this, particle );
}
for ( i = 0; i < len; i ++ ) {
this._initializers[i].initialize( this, particle );
}
this._particles.push( particle );
this._particles.push( particle );
this.dispatchEvent("created", particle); // ParticleCreated
this.dispatchEvent("created", particle); // ParticleCreated
return particle;
return particle;
},
addInitializer: function (initializer) {
this._initializers.push(initializer);
this._initializers.push(initializer);
},
addAction: function (action) {
this._actions.push(action);
this._actions.push(action);
},
removeInitializer: function (initializer) {
var index = this._initializers.indexOf(initializer);
if (index > -1) {
this._initializers.splice( index, 1 );
}
var index = this._initializers.indexOf(initializer);
if (index > -1) {
this._initializers.splice( index, 1 );
}
},
removeAction: function (action) {
var index = this._actions.indexOf(action);
if (index > -1) {
this._actions.splice( index, 1 );
}
var index = this._actions.indexOf(action);
if (index > -1) {
this._actions.splice( index, 1 );
}
//console.log('removeAction', index, this._actions);
},
addCallback: function(name, callback) {
this.callbacks[name] = callback;
this.callbacks[name] = callback;
},
dispatchEvent: function(name, args) {
var callback = this.callbacks[name];
if (callback) {
callback(args);
}
var callback = this.callbacks[name];
if (callback) {
callback(args);
}
}
......@@ -227,7 +227,7 @@ SPARKS.EVENT_LOOP_UPDATED = "loopUpdated";
// Number of particles per seconds
SPARKS.SteadyCounter = function(rate) {
this.rate = rate;
this.rate = rate;
// we use a shortfall counter to make up for slow emitters
this.leftover = 0;
......@@ -277,32 +277,32 @@ SPARKS.Particle = function() {
/**
* The lifetime of the particle, in seconds.
*/
this.lifetime = 0;
this.lifetime = 0;
/**
* The age of the particle, in seconds.
*/
this.age = 0;
this.age = 0;
/**
* The energy of the particle.
*/
this.energy = 1;
this.energy = 1;
/**
* Whether the particle is dead and should be removed from the stage.
*/
this.isDead = false;
this.isDead = false;
this.target = null; // tag
this.target = null; // tag
/**
* For 3D
*/
this.position = SPARKS.VectorPool.get().set(0,0,0); //new THREE.Vector3( 0, 0, 0 );
this.velocity = SPARKS.VectorPool.get().set(0,0,0); //new THREE.Vector3( 0, 0, 0 );
this._oldvelocity = SPARKS.VectorPool.get().set(0,0,0);
this.position = SPARKS.VectorPool.get().set(0, 0, 0); //new THREE.Vector3( 0, 0, 0 );
this.velocity = SPARKS.VectorPool.get().set(0, 0, 0); //new THREE.Vector3( 0, 0, 0 );
this._oldvelocity = SPARKS.VectorPool.get().set(0, 0, 0);
// rotation vec3
// angVelocity vec3
// faceAxis vec3
......@@ -317,26 +317,26 @@ SPARKS.Particle = function() {
* update function
*********************************/
SPARKS.Action = function() {
this._priority = 0;
this._priority = 0;
};
SPARKS.Age = function(easing) {
this._easing = (easing == null) ? TWEEN.Easing.Linear.None : easing;
this._easing = (easing == null) ? TWEEN.Easing.Linear.None : easing;
};
SPARKS.Age.prototype.update = function (emitter, particle, time) {
particle.age += time;
if( particle.age >= particle.lifetime )
particle.age += time;
if ( particle.age >= particle.lifetime )
{
particle.energy = 0;
particle.isDead = true;
}
particle.energy = 0;
particle.isDead = true;
}
else
{
var t = this._easing(particle.age / particle.lifetime);
particle.energy = -1 * t + 1;
}
{
var t = this._easing(particle.age / particle.lifetime);
particle.energy = -1 * t + 1;
}
};
/*
......@@ -360,9 +360,9 @@ SPARKS.Move = function() {
SPARKS.Move.prototype.update = function(emitter, particle, time) {
// attempt verlet velocity updating.
var p = particle.position;
var p = particle.position;
var v = particle.velocity;
var old = particle._oldvelocity;
var old = particle._oldvelocity;
if (this._velocityVerlet) {
p.x += (v.x + old.x) * 0.5 * time;
......@@ -384,12 +384,12 @@ SPARKS.Move.prototype.update = function(emitter, particle, time) {
/* Marks particles found in specified zone dead */
SPARKS.DeathZone = function(zone) {
this.zone = zone;
this.zone = zone;
};
SPARKS.DeathZone.prototype.update = function(emitter, particle, time) {
if (this.zone.contains(particle.position)) {
if (this.zone.contains(particle.position)) {
particle.isDead = true;
}
......@@ -400,12 +400,12 @@ SPARKS.DeathZone.prototype.update = function(emitter, particle, time) {
*/
SPARKS.ActionZone = function(action, zone) {
this.action = action;
this.zone = zone;
this.zone = zone;
};
SPARKS.ActionZone.prototype.update = function(emitter, particle, time) {
if (this.zone.contains(particle.position)) {
if (this.zone.contains(particle.position)) {
this.action.update( emitter, particle, time );
}
......@@ -421,20 +421,20 @@ SPARKS.Accelerate = function(x,y,z) {
return;
}
this.acceleration = new THREE.Vector3(x,y,z);
this.acceleration = new THREE.Vector3(x,y,z);
};
SPARKS.Accelerate.prototype.update = function(emitter, particle, time) {
var acc = this.acceleration;
var acc = this.acceleration;
var v = particle.velocity;
var v = particle.velocity;
particle._oldvelocity.set(v.x, v.y, v.z);
v.x += acc.x * time;
v.y += acc.y * time;
v.z += acc.z * time;
v.x += acc.x * time;
v.y += acc.y * time;
v.z += acc.z * time;
};
......@@ -442,16 +442,16 @@ SPARKS.Accelerate.prototype.update = function(emitter, particle, time) {
* Accelerate Factor accelerate based on a factor of particle's velocity.
*/
SPARKS.AccelerateFactor = function(factor) {
this.factor = factor;
this.factor = factor;
};
SPARKS.AccelerateFactor.prototype.update = function(emitter, particle, time) {
var factor = this.factor;
var factor = this.factor;
var v = particle.velocity;
var v = particle.velocity;
var len = v.length();
var adjFactor;
if (len>0) {
if (len > 0) {
adjFactor = factor * time / len;
adjFactor += 1;
......@@ -475,14 +475,14 @@ SPARKS.AccelerateVelocity = function(factor) {
};
SPARKS.AccelerateVelocity.prototype.update = function(emitter, particle, time) {
var factor = this.factor;
var factor = this.factor;
var v = particle.velocity;
var v = particle.velocity;
v.z += - v.x * factor;
v.y += v.z * factor;
v.x += v.y * factor;
v.z += - v.x * factor;
v.y += v.z * factor;
v.x += v.y * factor;
};
......@@ -494,18 +494,18 @@ SPARKS.RandomDrift = function(x,y,z) {
return;
}
this.drift = new THREE.Vector3(x,y,z);
this.drift = new THREE.Vector3(x,y,z);
}
SPARKS.RandomDrift.prototype.update = function(emitter, particle, time) {
var drift = this.drift;
var drift = this.drift;
var v = particle.velocity;
var v = particle.velocity;
v.x += ( Math.random() - 0.5 ) * drift.x * time;
v.y += ( Math.random() - 0.5 ) * drift.y * time;
v.z += ( Math.random() - 0.5 ) * drift.z * time;
v.x += ( Math.random() - 0.5 ) * drift.x * time;
v.y += ( Math.random() - 0.5 ) * drift.y * time;
v.z += ( Math.random() - 0.5 ) * drift.z * time;
};
......@@ -521,29 +521,29 @@ SPARKS.Zone = function() {
// TODO, contains() for Zone
SPARKS.PointZone = function(pos) {
this.pos = pos;
this.pos = pos;
};
SPARKS.PointZone.prototype.getLocation = function() {
return this.pos;
return this.pos;
};
SPARKS.PointZone = function(pos) {
this.pos = pos;
this.pos = pos;
};
SPARKS.PointZone.prototype.getLocation = function() {
return this.pos;
return this.pos;
};
SPARKS.LineZone = function(start, end) {
this.start = start;
this.start = start;
this.end = end;
this._length = end.clone().sub( start );
};
SPARKS.LineZone.prototype.getLocation = function() {
var len = this._length.clone();
var len = this._length.clone();
len.multiplyScalar( Math.random() );
return len.add( this.start );
......@@ -552,7 +552,7 @@ SPARKS.LineZone.prototype.getLocation = function() {
// Basically a RectangleZone
SPARKS.ParallelogramZone = function(corner, side1, side2) {
this.corner = corner;
this.corner = corner;
this.side1 = side1;
this.side2 = side2;
};
......@@ -567,7 +567,7 @@ SPARKS.ParallelogramZone.prototype.getLocation = function() {
};
SPARKS.CubeZone = function(position, x, y, z) {
this.position = position;
this.position = position;
this.x = x;
this.y = y;
this.z = z;
......@@ -595,17 +595,17 @@ SPARKS.CubeZone.prototype.contains = function(position) {
var y = this.y; // depth
var z = this.z; // height
if (x<0) {
if (x < 0) {
startX += x;
x = Math.abs(x);
}
if (y<0) {
if (y < 0) {
startY += y;
y = Math.abs(y);
}
if (z<0) {
if (z < 0) {
startZ += z;
z = Math.abs(z);
}
......@@ -674,29 +674,29 @@ SPARKS.DiscZone.prototype.getLocation = function() {
*/
SPARKS.SphereCapZone = function(x, y, z, minr, maxr, angle) {
this.x = x;
this.y = y;
this.z = z;
this.minr = minr;
this.maxr = maxr;
this.angle = angle;
this.x = x;
this.y = y;
this.z = z;
this.minr = minr;
this.maxr = maxr;
this.angle = angle;
};
SPARKS.SphereCapZone.prototype.getLocation = function() {
var theta = Math.PI *2 * SPARKS.Utils.random();
var r = SPARKS.Utils.random();
var theta = Math.PI * 2 * SPARKS.Utils.random();
var r = SPARKS.Utils.random();
//new THREE.Vector3
var v = SPARKS.VectorPool.get().set(r * Math.cos(theta), -1 / Math.tan(this.angle * SPARKS.Utils.DEGREE_TO_RADIAN), r * Math.sin(theta));
var v = SPARKS.VectorPool.get().set(r * Math.cos(theta), -1 / Math.tan(this.angle * SPARKS.Utils.DEGREE_TO_RADIAN), r * Math.sin(theta));
//v.length = StardustMath.interpolate(0, _minRadius, 1, _maxRadius, Math.random());
var i = this.minr - ((this.minr-this.maxr) * Math.random() );
v.multiplyScalar(i);
var i = this.minr - ((this.minr - this.maxr) * Math.random() );
v.multiplyScalar(i);
v.__markedForReleased = true;
return v;
return v;
};
......@@ -709,33 +709,33 @@ SPARKS.SphereCapZone.prototype.getLocation = function() {
// Specifies random life between max and min
SPARKS.Lifetime = function(min, max) {
this._min = min;
this._min = min;
this._max = max ? max : min;
this._max = max ? max : min;
};
SPARKS.Lifetime.prototype.initialize = function( emitter/*Emitter*/, particle/*Particle*/ ) {
particle.lifetime = this._min + SPARKS.Utils.random() * ( this._max - this._min );
particle.lifetime = this._min + SPARKS.Utils.random() * ( this._max - this._min );
};
SPARKS.Position = function(zone) {
this.zone = zone;
this.zone = zone;
};
SPARKS.Position.prototype.initialize = function( emitter/*Emitter*/, particle/*Particle*/ ) {
var pos = this.zone.getLocation();
particle.position.set(pos.x, pos.y, pos.z);
var pos = this.zone.getLocation();
particle.position.set(pos.x, pos.y, pos.z);
};
SPARKS.Velocity = function(zone) {
this.zone = zone;
this.zone = zone;
};
SPARKS.Velocity.prototype.initialize = function( emitter/*Emitter*/, particle/*Particle*/ ) {
var pos = this.zone.getLocation();
particle.velocity.set(pos.x, pos.y, pos.z);
var pos = this.zone.getLocation();
particle.velocity.set(pos.x, pos.y, pos.z);
if (pos.__markedForReleased) {
//console.log("release");
SPARKS.VectorPool.release(pos);
......@@ -744,17 +744,17 @@ SPARKS.Velocity.prototype.initialize = function( emitter/*Emitter*/, particle/*P
};
SPARKS.Target = function(target, callback) {
this.target = target;
this.callback = callback;
this.target = target;
this.callback = callback;
};
SPARKS.Target.prototype.initialize = function( emitter, particle ) {
if (this.callback) {
particle.target = this.callback();
} else {
particle.target = this.target;
}
if (this.callback) {
particle.target = this.callback();
} else {
particle.target = this.target;
}
};
......@@ -769,7 +769,7 @@ SPARKS.VectorPool = {
// Get a new Vector
get: function() {
if (this.__pools.length>0) {
if (this.__pools.length > 0) {
return this.__pools.pop();
}
......@@ -786,7 +786,7 @@ SPARKS.VectorPool = {
_addToPool: function() {
//console.log("creating some pools");
for (var i=0, size = 100; i < size; i++) {
for (var i = 0, size = 100; i < size; i ++) {
this.__pools.push(new THREE.Vector3());
}
......@@ -807,7 +807,7 @@ SPARKS.VectorPool = {
*********************************/
SPARKS.Utils = {
random: function() {
return Math.random();
return Math.random();
},
DEGREE_TO_RADIAN: Math.PI / 180,
TWOPI: Math.PI * 2,
......@@ -821,7 +821,7 @@ SPARKS.Utils = {
getPerpendicular: function( v )
{
if( v.x == 0 )
if ( v.x == 0 )
{
return new THREE.Vector3D( 1, 0, 0 );
}
......
......@@ -33,8 +33,8 @@ THREE.TypedArrayUtils.quicksortIP = function ( arr, eleSize, orderElement ) {
for ( y = 0; y < eleSize; y ++ ) {
tmp = arr[ a + y ];
arr[ a + y ]=arr[ b + y ];
arr[ b + y ]=tmp;
arr[ a + y ] = arr[ b + y ];
arr[ b + y ] = tmp;
}
......@@ -46,7 +46,7 @@ THREE.TypedArrayUtils.quicksortIP = function ( arr, eleSize, orderElement ) {
if ( right - left <= 25 ) {
for ( j= left + 1; j <= right; j ++ ) {
for ( j = left + 1; j <= right; j ++ ) {
for ( x = 0; x < eleSize; x ++ ) {
......@@ -214,7 +214,7 @@ THREE.TypedArrayUtils.quicksortIP = function ( arr, eleSize, orderElement ) {
median = Math.floor( plength / 2 );
node = new self.Node( getPointSet( points, median ) , depth, parent, median + pos );
node = new self.Node( getPointSet( points, median ), depth, parent, median + pos );
node.left = buildTree( points.subarray( 0, median * eleSize), depth + 1, node, pos );
node.right = buildTree( points.subarray( ( median + 1 ) * eleSize, points.length ), depth + 1, node, pos + median + 1 );
......@@ -226,7 +226,7 @@ THREE.TypedArrayUtils.quicksortIP = function ( arr, eleSize, orderElement ) {
this.getMaxDepth = function () { return maxDepth; };
this.nearest = function ( point, maxNodes , maxDistance ) {
this.nearest = function ( point, maxNodes, maxDistance ) {
/* point: array of size eleSize
maxNodes: max amount of nodes to return
......
......@@ -29,7 +29,7 @@ THREE.CombinedCamera = function ( width, height, fov, near, far, orthoNear, orth
this.toPerspective();
var aspect = width/height;
var aspect = width / height;
};
......
......@@ -262,7 +262,7 @@ THREE.EditorControls = function ( object, domElement ) {
case 1:
touches[ 0 ].set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY, 0 );
touches[ 1 ].set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY, 0 );
scope.rotate( touches[ 0 ].sub( getClosest( touches[ 0 ] ,prevTouches ) ).multiplyScalar( - 0.005 ) );
scope.rotate( touches[ 0 ].sub( getClosest( touches[ 0 ], prevTouches ) ).multiplyScalar( - 0.005 ) );
break;
case 2:
......@@ -273,8 +273,8 @@ THREE.EditorControls = function ( object, domElement ) {
prevDistance = distance;
var offset0 = touches[ 0 ].clone().sub( getClosest( touches[ 0 ] ,prevTouches ) );
var offset1 = touches[ 1 ].clone().sub( getClosest( touches[ 1 ] ,prevTouches ) );
var offset0 = touches[ 0 ].clone().sub( getClosest( touches[ 0 ], prevTouches ) );
var offset1 = touches[ 1 ].clone().sub( getClosest( touches[ 1 ], prevTouches ) );
offset0.x = -offset0.x;
offset1.x = -offset1.x;
......
......@@ -163,7 +163,7 @@ THREE.FirstPersonControls = function ( object, domElement ) {
this.onKeyUp = function ( event ) {
switch( event.keyCode ) {
switch ( event.keyCode ) {
case 38: /*up*/
case 87: /*W*/ this.moveForward = false; break;
......@@ -229,7 +229,7 @@ THREE.FirstPersonControls = function ( object, domElement ) {
}
this.lon += this.mouseX * actualLookSpeed;
if( this.lookVertical ) this.lat -= this.mouseY * actualLookSpeed * verticalLookRatio;
if ( this.lookVertical ) this.lat -= this.mouseY * actualLookSpeed * verticalLookRatio;
this.lat = Math.max( - 85, Math.min( 85, this.lat ) );
this.phi = THREE.Math.degToRad( 90 - this.lat );
......
......@@ -80,7 +80,7 @@ THREE.FlyControls = function ( object, domElement ) {
this.keyup = function( event ) {
switch( event.keyCode ) {
switch ( event.keyCode ) {
case 16: /* shift */ this.movementSpeedMultiplier = 1; break;
......
......@@ -6,50 +6,50 @@
THREE.MouseControls = function ( object ) {
var scope = this;
var PI_2 = Math.PI / 2;
var mouseQuat = {
var scope = this;
var PI_2 = Math.PI / 2;
var mouseQuat = {
x: new THREE.Quaternion(),
y: new THREE.Quaternion()
};
var object = object;
var xVector = new THREE.Vector3( 1, 0, 0 );
var yVector = new THREE.Vector3( 0, 1, 0 );
var object = object;
var xVector = new THREE.Vector3( 1, 0, 0 );
var yVector = new THREE.Vector3( 0, 1, 0 );
var onMouseMove = function ( event ) {
var onMouseMove = function ( event ) {
if ( scope.enabled === false ) return;
if ( scope.enabled === false ) return;
var orientation = scope.orientation;
var orientation = scope.orientation;
var movementX = event.movementX || event.mozMovementX || event.webkitMovementX || 0;
var movementY = event.movementY || event.mozMovementY || event.webkitMovementY || 0;
var movementX = event.movementX || event.mozMovementX || event.webkitMovementX || 0;
var movementY = event.movementY || event.mozMovementY || event.webkitMovementY || 0;
orientation.y += movementX * 0.0025;
orientation.x += movementY * 0.0025;
orientation.y += movementX * 0.0025;
orientation.x += movementY * 0.0025;
orientation.x = Math.max( - PI_2, Math.min( PI_2, orientation.x ) );
orientation.x = Math.max( - PI_2, Math.min( PI_2, orientation.x ) );
};
};
this.enabled = true;
this.enabled = true;
this.orientation = {
this.orientation = {
x: 0,
y: 0,
};
this.update = function() {
this.update = function() {
if ( this.enabled === false ) return;
if ( this.enabled === false ) return;
mouseQuat.x.setFromAxisAngle( xVector, this.orientation.x );
mouseQuat.y.setFromAxisAngle( yVector, this.orientation.y );
object.quaternion.copy(mouseQuat.y).multiply(mouseQuat.x)
return;
mouseQuat.x.setFromAxisAngle( xVector, this.orientation.x );
mouseQuat.y.setFromAxisAngle( yVector, this.orientation.y );
object.quaternion.copy(mouseQuat.y).multiply(mouseQuat.x)
return;
};
};
document.addEventListener( 'mousemove', onMouseMove, false );
document.addEventListener( 'mousemove', onMouseMove, false );
};
......@@ -121,8 +121,8 @@ THREE.OrbitControls = function ( object, domElement ) {
// events
var changeEvent = { type: 'change' };
var startEvent = { type: 'start'};
var endEvent = { type: 'end'};
var startEvent = { type: 'start' };
var endEvent = { type: 'end' };
this.rotateLeft = function ( angle ) {
......
......@@ -73,8 +73,8 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
// events
var changeEvent = { type: 'change' };
var startEvent = { type: 'start'};
var endEvent = { type: 'end'};
var startEvent = { type: 'start' };
var endEvent = { type: 'end' };
// methods
......@@ -156,7 +156,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
if ( length < Math.SQRT1_2 ) {
mouseOnBall.z = Math.sqrt( 1.0 - length*length );
mouseOnBall.z = Math.sqrt( 1.0 - length * length );
} else {
......@@ -186,7 +186,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
}() );
this.rotateCamera = (function(){
this.rotateCamera = (function() {
var axis = new THREE.Vector3(),
quaternion = new THREE.Quaternion();
......@@ -264,7 +264,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
};
this.panCamera = (function(){
this.panCamera = (function() {
var mouseChange = new THREE.Vector2(),
objectUp = new THREE.Vector3(),
......
......@@ -68,8 +68,8 @@ THREE.TrackballControls = function ( object, domElement ) {
// events
var changeEvent = { type: 'change' };
var startEvent = { type: 'start'};
var endEvent = { type: 'end'};
var startEvent = { type: 'start' };
var endEvent = { type: 'end' };
// methods
......@@ -133,8 +133,8 @@ THREE.TrackballControls = function ( object, domElement ) {
return function ( pageX, pageY ) {
mouseOnBall.set(
( pageX - _this.screen.width * 0.5 - _this.screen.left ) / (_this.screen.width*.5),
( _this.screen.height * 0.5 + _this.screen.top - pageY ) / (_this.screen.height*.5),
( pageX - _this.screen.width * 0.5 - _this.screen.left ) / (_this.screen.width * .5),
( _this.screen.height * 0.5 + _this.screen.top - pageY ) / (_this.screen.height * .5),
0.0
);
......@@ -144,7 +144,7 @@ THREE.TrackballControls = function ( object, domElement ) {
if ( length < Math.SQRT1_2 ) {
mouseOnBall.z = Math.sqrt( 1.0 - length*length );
mouseOnBall.z = Math.sqrt( 1.0 - length * length );
} else {
......@@ -174,7 +174,7 @@ THREE.TrackballControls = function ( object, domElement ) {
}() );
this.rotateCamera = (function(){
this.rotateCamera = (function() {
var axis = new THREE.Vector3(),
quaternion = new THREE.Quaternion();
......@@ -245,7 +245,7 @@ THREE.TrackballControls = function ( object, domElement ) {
};
this.panCamera = (function(){
this.panCamera = (function() {
var mouseChange = new THREE.Vector2(),
objectUp = new THREE.Vector3(),
......
......@@ -30,8 +30,8 @@
} else {
this.color.copy( this.oldColor );
this.opacity = this.oldOpacity;
this.color.copy( this.oldColor );
this.opacity = this.oldOpacity;
}
......@@ -65,8 +65,8 @@
} else {
this.color.copy( this.oldColor );
this.opacity = this.oldOpacity;
this.color.copy( this.oldColor );
this.opacity = this.oldOpacity;
}
......@@ -110,8 +110,8 @@
this.activePlane = planes["XYZE"];
planes["YZ"].rotation.set( 0, Math.PI/2, 0 );
planes["XZ"].rotation.set( -Math.PI/2, 0, 0 );
planes["YZ"].rotation.set( 0, Math.PI / 2, 0 );
planes["XZ"].rotation.set( -Math.PI / 2, 0, 0 );
for (var i in planes) {
planes[i].name = i;
......@@ -126,7 +126,7 @@
for ( var name in gizmoMap ) {
for ( i = gizmoMap[name].length; i--;) {
for ( i = gizmoMap[name].length; i --;) {
var object = gizmoMap[name][i][0];
var position = gizmoMap[name][i][1];
......@@ -183,7 +183,7 @@
this.highlight = function ( axis ) {
this.traverse(function( child ) {
if ( child.material && child.material.highlight ){
if ( child.material && child.material.highlight ) {
if ( child.name == axis ) {
child.material.highlight( true );
} else {
......@@ -236,7 +236,7 @@
this.handleGizmos = {
X: [
[ new THREE.Mesh( arrowGeometry, new GizmoMaterial( { color: 0xff0000 } ) ), [ 0.5, 0, 0 ], [ 0, 0, -Math.PI/2 ] ],
[ new THREE.Mesh( arrowGeometry, new GizmoMaterial( { color: 0xff0000 } ) ), [ 0.5, 0, 0 ], [ 0, 0, -Math.PI / 2 ] ],
[ new THREE.Line( lineXGeometry, new GizmoLineMaterial( { color: 0xff0000 } ) ) ]
],
Y: [
......@@ -244,7 +244,7 @@
[ new THREE.Line( lineYGeometry, new GizmoLineMaterial( { color: 0x00ff00 } ) ) ]
],
Z: [
[ new THREE.Mesh( arrowGeometry, new GizmoMaterial( { color: 0x0000ff } ) ), [ 0, 0, 0.5 ], [ Math.PI/2, 0, 0 ] ],
[ new THREE.Mesh( arrowGeometry, new GizmoMaterial( { color: 0x0000ff } ) ), [ 0, 0, 0.5 ], [ Math.PI / 2, 0, 0 ] ],
[ new THREE.Line( lineZGeometry, new GizmoLineMaterial( { color: 0x0000ff } ) ) ]
],
XYZ: [
......@@ -254,22 +254,22 @@
[ new THREE.Mesh( new THREE.PlaneBufferGeometry( 0.29, 0.29 ), new GizmoMaterial( { color: 0xffff00, opacity: 0.25 } ) ), [ 0.15, 0.15, 0 ] ]
],
YZ: [
[ new THREE.Mesh( new THREE.PlaneBufferGeometry( 0.29, 0.29 ), new GizmoMaterial( { color: 0x00ffff, opacity: 0.25 } ) ), [ 0, 0.15, 0.15 ], [ 0, Math.PI/2, 0 ] ]
[ new THREE.Mesh( new THREE.PlaneBufferGeometry( 0.29, 0.29 ), new GizmoMaterial( { color: 0x00ffff, opacity: 0.25 } ) ), [ 0, 0.15, 0.15 ], [ 0, Math.PI / 2, 0 ] ]
],
XZ: [
[ new THREE.Mesh( new THREE.PlaneBufferGeometry( 0.29, 0.29 ), new GizmoMaterial( { color: 0xff00ff, opacity: 0.25 } ) ), [ 0.15, 0, 0.15 ], [ -Math.PI/2, 0, 0 ] ]
[ new THREE.Mesh( new THREE.PlaneBufferGeometry( 0.29, 0.29 ), new GizmoMaterial( { color: 0xff00ff, opacity: 0.25 } ) ), [ 0.15, 0, 0.15 ], [ -Math.PI / 2, 0, 0 ] ]
]
};
this.pickerGizmos = {
X: [
[ new THREE.Mesh( new THREE.CylinderGeometry( 0.2, 0, 1, 4, 1, false ), new GizmoMaterial( { color: 0xff0000, opacity: 0.25 } ) ), [ 0.6, 0, 0 ], [ 0, 0, -Math.PI/2 ] ]
[ new THREE.Mesh( new THREE.CylinderGeometry( 0.2, 0, 1, 4, 1, false ), new GizmoMaterial( { color: 0xff0000, opacity: 0.25 } ) ), [ 0.6, 0, 0 ], [ 0, 0, -Math.PI / 2 ] ]
],
Y: [
[ new THREE.Mesh( new THREE.CylinderGeometry( 0.2, 0, 1, 4, 1, false ), new GizmoMaterial( { color: 0x00ff00, opacity: 0.25 } ) ), [ 0, 0.6, 0 ] ]
],
Z: [
[ new THREE.Mesh( new THREE.CylinderGeometry( 0.2, 0, 1, 4, 1, false ), new GizmoMaterial( { color: 0x0000ff, opacity: 0.25 } ) ), [ 0, 0, 0.6 ], [ Math.PI/2, 0, 0 ] ]
[ new THREE.Mesh( new THREE.CylinderGeometry( 0.2, 0, 1, 4, 1, false ), new GizmoMaterial( { color: 0x0000ff, opacity: 0.25 } ) ), [ 0, 0, 0.6 ], [ Math.PI / 2, 0, 0 ] ]
],
XYZ: [
[ new THREE.Mesh( new THREE.OctahedronGeometry( 0.2, 0 ), new GizmoMaterial( { color: 0xffffff, opacity: 0.25 } ) ) ]
......@@ -278,10 +278,10 @@
[ new THREE.Mesh( new THREE.PlaneBufferGeometry( 0.4, 0.4 ), new GizmoMaterial( { color: 0xffff00, opacity: 0.25 } ) ), [ 0.2, 0.2, 0 ] ]
],
YZ: [
[ new THREE.Mesh( new THREE.PlaneBufferGeometry( 0.4, 0.4 ), new GizmoMaterial( { color: 0x00ffff, opacity: 0.25 } ) ), [ 0, 0.2, 0.2 ], [ 0, Math.PI/2, 0 ] ]
[ new THREE.Mesh( new THREE.PlaneBufferGeometry( 0.4, 0.4 ), new GizmoMaterial( { color: 0x00ffff, opacity: 0.25 } ) ), [ 0, 0.2, 0.2 ], [ 0, Math.PI / 2, 0 ] ]
],
XZ: [
[ new THREE.Mesh( new THREE.PlaneBufferGeometry( 0.4, 0.4 ), new GizmoMaterial( { color: 0xff00ff, opacity: 0.25 } ) ), [ 0.2, 0, 0.2 ], [ -Math.PI/2, 0, 0 ] ]
[ new THREE.Mesh( new THREE.PlaneBufferGeometry( 0.4, 0.4 ), new GizmoMaterial( { color: 0xff00ff, opacity: 0.25 } ) ), [ 0.2, 0, 0.2 ], [ -Math.PI / 2, 0, 0 ] ]
]
};
......@@ -295,12 +295,12 @@
if ( Math.abs(eye.y) > Math.abs(eye.z) ) this.activePlane = this.planes[ "XZ" ];
}
if ( axis == "Y" ){
if ( axis == "Y" ) {
this.activePlane = this.planes[ "XY" ];
if ( Math.abs(eye.x) > Math.abs(eye.z) ) this.activePlane = this.planes[ "YZ" ];
}
if ( axis == "Z" ){
if ( axis == "Z" ) {
this.activePlane = this.planes[ "XZ" ];
if ( Math.abs(eye.x) > Math.abs(eye.y) ) this.activePlane = this.planes[ "YZ" ];
}
......@@ -331,15 +331,15 @@
var CircleGeometry = function ( radius, facing, arc ) {
var geometry = new THREE.Geometry();
arc = arc ? arc : 1;
for ( var i = 0; i <= 64 * arc; ++i ) {
if ( facing == 'x' ) geometry.vertices.push( new THREE.Vector3( 0, Math.cos( i / 32 * Math.PI ), Math.sin( i / 32 * Math.PI ) ).multiplyScalar(radius) );
if ( facing == 'y' ) geometry.vertices.push( new THREE.Vector3( Math.cos( i / 32 * Math.PI ), 0, Math.sin( i / 32 * Math.PI ) ).multiplyScalar(radius) );
if ( facing == 'z' ) geometry.vertices.push( new THREE.Vector3( Math.sin( i / 32 * Math.PI ), Math.cos( i / 32 * Math.PI ), 0 ).multiplyScalar(radius) );
}
var geometry = new THREE.Geometry();
arc = arc ? arc : 1;
for ( var i = 0; i <= 64 * arc; ++ i ) {
if ( facing == 'x' ) geometry.vertices.push( new THREE.Vector3( 0, Math.cos( i / 32 * Math.PI ), Math.sin( i / 32 * Math.PI ) ).multiplyScalar(radius) );
if ( facing == 'y' ) geometry.vertices.push( new THREE.Vector3( Math.cos( i / 32 * Math.PI ), 0, Math.sin( i / 32 * Math.PI ) ).multiplyScalar(radius) );
if ( facing == 'z' ) geometry.vertices.push( new THREE.Vector3( Math.sin( i / 32 * Math.PI ), Math.cos( i / 32 * Math.PI ), 0 ).multiplyScalar(radius) );
}
return geometry;
return geometry;
};
this.handleGizmos = {
......@@ -362,13 +362,13 @@
this.pickerGizmos = {
X: [
[ new THREE.Mesh( new THREE.TorusGeometry( 1, 0.12, 4, 12, Math.PI ), new GizmoMaterial( { color: 0xff0000, opacity: 0.25 } ) ), [ 0, 0, 0 ], [ 0, -Math.PI/2, -Math.PI/2 ] ]
[ new THREE.Mesh( new THREE.TorusGeometry( 1, 0.12, 4, 12, Math.PI ), new GizmoMaterial( { color: 0xff0000, opacity: 0.25 } ) ), [ 0, 0, 0 ], [ 0, -Math.PI / 2, -Math.PI / 2 ] ]
],
Y: [
[ new THREE.Mesh( new THREE.TorusGeometry( 1, 0.12, 4, 12, Math.PI ), new GizmoMaterial( { color: 0x00ff00, opacity: 0.25 } ) ), [ 0, 0, 0 ], [ Math.PI/2, 0, 0 ] ]
[ new THREE.Mesh( new THREE.TorusGeometry( 1, 0.12, 4, 12, Math.PI ), new GizmoMaterial( { color: 0x00ff00, opacity: 0.25 } ) ), [ 0, 0, 0 ], [ Math.PI / 2, 0, 0 ] ]
],
Z: [
[ new THREE.Mesh( new THREE.TorusGeometry( 1, 0.12, 4, 12, Math.PI ), new GizmoMaterial( { color: 0x0000ff, opacity: 0.25 } ) ), [ 0, 0, 0 ], [ 0, 0, -Math.PI/2 ] ]
[ new THREE.Mesh( new THREE.TorusGeometry( 1, 0.12, 4, 12, Math.PI ), new GizmoMaterial( { color: 0x0000ff, opacity: 0.25 } ) ), [ 0, 0, 0 ], [ 0, 0, -Math.PI / 2 ] ]
],
E: [
[ new THREE.Mesh( new THREE.TorusGeometry( 1.25, 0.12, 2, 24 ), new GizmoMaterial( { color: 0xffff00, opacity: 0.25 } ) ) ]
......@@ -474,7 +474,7 @@
this.handleGizmos = {
X: [
[ new THREE.Mesh( arrowGeometry, new GizmoMaterial( { color: 0xff0000 } ) ), [ 0.5, 0, 0 ], [ 0, 0, -Math.PI/2 ] ],
[ new THREE.Mesh( arrowGeometry, new GizmoMaterial( { color: 0xff0000 } ) ), [ 0.5, 0, 0 ], [ 0, 0, -Math.PI / 2 ] ],
[ new THREE.Line( lineXGeometry, new GizmoLineMaterial( { color: 0xff0000 } ) ) ]
],
Y: [
......@@ -482,7 +482,7 @@
[ new THREE.Line( lineYGeometry, new GizmoLineMaterial( { color: 0x00ff00 } ) ) ]
],
Z: [
[ new THREE.Mesh( arrowGeometry, new GizmoMaterial( { color: 0x0000ff } ) ), [ 0, 0, 0.5 ], [ Math.PI/2, 0, 0 ] ],
[ new THREE.Mesh( arrowGeometry, new GizmoMaterial( { color: 0x0000ff } ) ), [ 0, 0, 0.5 ], [ Math.PI / 2, 0, 0 ] ],
[ new THREE.Line( lineZGeometry, new GizmoLineMaterial( { color: 0x0000ff } ) ) ]
],
XYZ: [
......@@ -492,13 +492,13 @@
this.pickerGizmos = {
X: [
[ new THREE.Mesh( new THREE.CylinderGeometry( 0.2, 0, 1, 4, 1, false ), new GizmoMaterial( { color: 0xff0000, opacity: 0.25 } ) ), [ 0.6, 0, 0 ], [ 0, 0, -Math.PI/2 ] ]
[ new THREE.Mesh( new THREE.CylinderGeometry( 0.2, 0, 1, 4, 1, false ), new GizmoMaterial( { color: 0xff0000, opacity: 0.25 } ) ), [ 0.6, 0, 0 ], [ 0, 0, -Math.PI / 2 ] ]
],
Y: [
[ new THREE.Mesh( new THREE.CylinderGeometry( 0.2, 0, 1, 4, 1, false ), new GizmoMaterial( { color: 0x00ff00, opacity: 0.25 } ) ), [ 0, 0.6, 0 ] ]
],
Z: [
[ new THREE.Mesh( new THREE.CylinderGeometry( 0.2, 0, 1, 4, 1, false ), new GizmoMaterial( { color: 0x0000ff, opacity: 0.25 } ) ), [ 0, 0, 0.6 ], [ Math.PI/2, 0, 0 ] ]
[ new THREE.Mesh( new THREE.CylinderGeometry( 0.2, 0, 1, 4, 1, false ), new GizmoMaterial( { color: 0x0000ff, opacity: 0.25 } ) ), [ 0, 0, 0.6 ], [ Math.PI / 2, 0, 0 ] ]
],
XYZ: [
[ new THREE.Mesh( new THREE.BoxGeometry( 0.4, 0.4, 0.4 ), new GizmoMaterial( { color: 0xffffff, opacity: 0.25 } ) ) ]
......@@ -515,12 +515,12 @@
if ( Math.abs(eye.y) > Math.abs(eye.z) ) this.activePlane = this.planes[ "XZ" ];
}
if ( axis == "Y" ){
if ( axis == "Y" ) {
this.activePlane = this.planes[ "XY" ];
if ( Math.abs(eye.x) > Math.abs(eye.z) ) this.activePlane = this.planes[ "YZ" ];
}
if ( axis == "Z" ){
if ( axis == "Z" ) {
this.activePlane = this.planes[ "XZ" ];
if ( Math.abs(eye.x) > Math.abs(eye.y) ) this.activePlane = this.planes[ "YZ" ];
}
......@@ -775,7 +775,7 @@
scope.gizmo[_mode].setActivePlane( scope.axis, eye );
var planeIntersect = intersectObjects( pointer, [scope.gizmo[_mode].activePlane] );
var planeIntersect = intersectObjects( pointer, [ scope.gizmo[_mode].activePlane ] );
oldPosition.copy( scope.object.position );
oldScale.copy( scope.object.scale );
......@@ -803,9 +803,9 @@
event.preventDefault();
event.stopPropagation();
var pointer = event.changedTouches? event.changedTouches[0] : event;
var pointer = event.changedTouches ? event.changedTouches[0] : event;
var planeIntersect = intersectObjects( pointer, [scope.gizmo[_mode].activePlane] );
var planeIntersect = intersectObjects( pointer, [ scope.gizmo[_mode].activePlane ] );
point.copy( planeIntersect.point );
......
......@@ -8,7 +8,7 @@ function generateGeometry(objectType, numObjects) {
var n = ( f instanceof THREE.Face3 ) ? 3 : 4;
for( var j = 0; j < n; j ++ ) {
for ( var j = 0; j < n; j ++ ) {
f.vertexColors[ j ] = c;
......@@ -43,13 +43,13 @@ function generateGeometry(objectType, numObjects) {
geom = new THREE.BoxGeometry( 1, 1, 1 );
scale.y = Math.random() * 200 + 100;
scale.z = Math.random() * 200 + 100;
color.setRGB( 0, 0, Math.random()+0.1 );
color.setRGB( 0, 0, Math.random() + 0.1 );
}
else if ( objectType == "sphere" )
{
geom = new THREE.IcosahedronGeometry( 1, 1 )
scale.y = scale.z = scale.x;
color.setRGB( Math.random()+0.1, 0, 0 );
color.setRGB( Math.random() + 0.1, 0, 0 );
}
// give the geom's vertices a random color, to be displayed
......@@ -94,9 +94,9 @@ function Scene ( type, numObjects, cameraZ, fov, rotationSpeed, clearColor ) {
this.render = function( delta, rtt ) {
this.mesh.rotation.x += delta*this.rotationSpeed.x;
this.mesh.rotation.y += delta*this.rotationSpeed.y;
this.mesh.rotation.z += delta*this.rotationSpeed.z;
this.mesh.rotation.x += delta * this.rotationSpeed.x;
this.mesh.rotation.y += delta * this.rotationSpeed.y;
this.mesh.rotation.z += delta * this.rotationSpeed.z;
renderer.setClearColor( this.clearColor );
......
......@@ -5,8 +5,8 @@ function Transition ( sceneA, sceneB ) {
this.cameraOrtho = new THREE.OrthographicCamera(window.innerWidth / -2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / -2, -10, 10);
this.textures = [];
for (var i=0;i<6;i++)
this.textures[i]=new THREE.ImageUtils.loadTexture('textures/transition/transition'+(i+1)+'.png');
for (var i = 0; i < 6; i ++)
this.textures[i] = new THREE.ImageUtils.loadTexture('textures/transition/transition' + (i + 1) + '.png');
this.quadmaterial = new THREE.ShaderMaterial({
......@@ -101,13 +101,13 @@ function Transition ( sceneA, sceneB ) {
this.setTextureThreshold = function ( value ) {
this.quadmaterial.uniforms.threshold.value=value;
this.quadmaterial.uniforms.threshold.value = value;
}
this.useTexture = function ( value ) {
this.quadmaterial.uniforms.useTexture.value = value?1:0;
this.quadmaterial.uniforms.useTexture.value = value ? 1 : 0;
}
......@@ -122,32 +122,32 @@ function Transition ( sceneA, sceneB ) {
// Transition animation
if (transitionParams.animateTransition)
{
var t=(1+Math.sin(transitionParams.transitionSpeed*clock.getElapsedTime()/Math.PI))/2;
transitionParams.transition=THREE.Math.smoothstep(t,0.3,0.7);
var t = (1 + Math.sin(transitionParams.transitionSpeed * clock.getElapsedTime() / Math.PI)) / 2;
transitionParams.transition = THREE.Math.smoothstep(t, 0.3, 0.7);
// Change the current alpha texture after each transition
if (transitionParams.loopTexture && (transitionParams.transition==0 || transitionParams.transition==1))
if (transitionParams.loopTexture && (transitionParams.transition == 0 || transitionParams.transition == 1))
{
if (this.needChange)
{
transitionParams.texture=(transitionParams.texture+1)%this.textures.length;
transitionParams.texture = (transitionParams.texture + 1)%this.textures.length;
this.quadmaterial.uniforms.tMixTexture.value = this.textures[transitionParams.texture];
this.needChange=false;
this.needChange = false;
}
}
else
this.needChange=true;
this.needChange = true;
}
this.quadmaterial.uniforms.mixRatio.value = transitionParams.transition;
// Prevent render both scenes when it's not necessary
if (transitionParams.transition==0) {
if (transitionParams.transition == 0) {
this.sceneB.render( delta, false );
} else if (transitionParams.transition==1) {
} else if (transitionParams.transition == 1) {
this.sceneA.render( delta, false );
......
......@@ -18,7 +18,7 @@ THREE.NURBSCurve = function ( degree, knots /* array of reals */, controlPoints
this.degree = degree;
this.knots = knots;
this.controlPoints = [];
for (var i = 0; i < controlPoints.length; ++i) { // ensure Vector4 for control points
for (var i = 0; i < controlPoints.length; ++ i) { // ensure Vector4 for control points
var point = controlPoints[i];
this.controlPoints[i] = new THREE.Vector4(point.x, point.y, point.z, point.w);
}
......
......@@ -23,9 +23,9 @@ THREE.NURBSSurface = function ( degree1, degree2, knots1, knots2 /* arrays of re
var len2 = knots2.length - degree2 - 1;
// ensure Vector4 for control points
for (var i = 0; i < len1; ++i) {
for (var i = 0; i < len1; ++ i) {
this.controlPoints[i] = []
for (var j = 0; j < len2; ++j) {
for (var j = 0; j < len2; ++ j) {
var point = controlPoints[i][j];
this.controlPoints[i][j] = new THREE.Vector4(point.x, point.y, point.z, point.w);
}
......
......@@ -68,14 +68,14 @@ THREE.NURBSUtils = {
var right = [];
N[0] = 1.0;
for (var j = 1; j <= p; ++j) {
for (var j = 1; j <= p; ++ j) {
left[j] = u - U[span + 1 - j];
right[j] = U[span + j] - u;
var saved = 0.0;
for (var r = 0; r < j; ++r) {
for (var r = 0; r < j; ++ r) {
var rv = right[r + 1];
var lv = left[j - r];
......@@ -106,7 +106,7 @@ THREE.NURBSUtils = {
var N = this.calcBasisFunctions(span, u, p, U);
var C = new THREE.Vector4(0, 0, 0, 0);
for (var j = 0; j <= p; ++j) {
for (var j = 0; j <= p; ++ j) {
var point = P[span - p + j];
var Nj = N[j];
var wNj = point.w * Nj;
......@@ -134,15 +134,15 @@ THREE.NURBSUtils = {
calcBasisFunctionDerivatives: function( span, u, p, n, U ) {
var zeroArr = [];
for (var i = 0; i <= p; ++i)
for (var i = 0; i <= p; ++ i)
zeroArr[i] = 0.0;
var ders = [];
for (var i = 0; i <= n; ++i)
for (var i = 0; i <= n; ++ i)
ders[i] = zeroArr.slice(0);
var ndu = [];
for (var i = 0; i <= p; ++i)
for (var i = 0; i <= p; ++ i)
ndu[i] = zeroArr.slice(0);
ndu[0][0] = 1.0;
......@@ -150,13 +150,13 @@ THREE.NURBSUtils = {
var left = zeroArr.slice(0);
var right = zeroArr.slice(0);
for (var j = 1; j <= p; ++j) {
for (var j = 1; j <= p; ++ j) {
left[j] = u - U[span + 1 - j];
right[j] = U[span + j] - u;
var saved = 0.0;
for (var r = 0; r < j; ++r) {
for (var r = 0; r < j; ++ r) {
var rv = right[r + 1];
var lv = left[j - r];
ndu[j][r] = rv + lv;
......@@ -169,21 +169,21 @@ THREE.NURBSUtils = {
ndu[j][j] = saved;
}
for (var j = 0; j <= p; ++j) {
for (var j = 0; j <= p; ++ j) {
ders[0][j] = ndu[j][p];
}
for (var r = 0; r <= p; ++r) {
for (var r = 0; r <= p; ++ r) {
var s1 = 0;
var s2 = 1;
var a = [];
for (var i = 0; i <= p; ++i) {
for (var i = 0; i <= p; ++ i) {
a[i] = zeroArr.slice(0);
}
a[0][0] = 1.0;
for (var k = 1; k <= n; ++k) {
for (var k = 1; k <= n; ++ k) {
var d = 0.0;
var rk = r - k;
var pk = p - k;
......@@ -196,7 +196,7 @@ THREE.NURBSUtils = {
var j1 = (rk >= -1) ? 1 : -rk;
var j2 = (r - 1 <= pk) ? k - 1 : p - r;
for (var j = j1; j <= j2; ++j) {
for (var j = j1; j <= j2; ++ j) {
a[s2][j] = (a[s1][j] - a[s1][j - 1]) / ndu[pk + 1][rk + j];
d += a[s2][j] * ndu[rk + j][pk];
}
......@@ -216,8 +216,8 @@ THREE.NURBSUtils = {
var r = p;
for (var k = 1; k <= n; ++k) {
for (var j = 0; j <= p; ++j) {
for (var k = 1; k <= n; ++ k) {
for (var j = 0; j <= p; ++ j) {
ders[k][j] *= r;
}
r *= p - k;
......@@ -245,7 +245,7 @@ THREE.NURBSUtils = {
var nders = this.calcBasisFunctionDerivatives(span, u, p, du, U);
var Pw = [];
for (var i = 0; i < P.length; ++i) {
for (var i = 0; i < P.length; ++ i) {
var point = P[i].clone();
var w = point.w;
......@@ -255,17 +255,17 @@ THREE.NURBSUtils = {
Pw[i] = point;
}
for (var k = 0; k <= du; ++k) {
for (var k = 0; k <= du; ++ k) {
var point = Pw[span - p].clone().multiplyScalar(nders[k][0]);
for (var j = 1; j <= p; ++j) {
for (var j = 1; j <= p; ++ j) {
point.add(Pw[span - p + j].clone().multiplyScalar(nders[k][j]));
}
CK[k] = point;
}
for (var k = du + 1; k <= nd + 1; ++k) {
for (var k = du + 1; k <= nd + 1; ++ k) {
CK[k] = new THREE.Vector4(0, 0, 0);
}
......@@ -281,17 +281,17 @@ THREE.NURBSUtils = {
calcKoverI: function( k, i ) {
var nom = 1;
for (var j = 2; j <= k; ++j) {
for (var j = 2; j <= k; ++ j) {
nom *= j;
}
var denom = 1;
for (var j = 2; j <= i; ++j) {
for (var j = 2; j <= i; ++ j) {
denom *= j;
}
for (var j = 2; j <= k - i; ++j) {
for (var j = 2; j <= k - i; ++ j) {
denom *= j;
}
......@@ -311,7 +311,7 @@ THREE.NURBSUtils = {
var Aders = [];
var wders = [];
for (var i = 0; i < nd; ++i) {
for (var i = 0; i < nd; ++ i) {
var point = Pders[i];
Aders[i] = new THREE.Vector3(point.x, point.y, point.z);
wders[i] = point.w;
......@@ -319,11 +319,11 @@ THREE.NURBSUtils = {
var CK = [];
for (var k = 0; k < nd; ++k) {
for (var k = 0; k < nd; ++ k) {
var v = Aders[k].clone();
for (var i = 1; i <= k; ++i) {
v.sub(CK[k - i].clone().multiplyScalar(this.calcKoverI(k,i) * wders[i]));
for (var i = 1; i <= k; ++ i) {
v.sub(CK[k - i].clone().multiplyScalar(this.calcKoverI(k, i) * wders[i]));
}
CK[k] = v.divideScalar(wders[0]);
......@@ -367,9 +367,9 @@ THREE.NURBSUtils = {
var Nv = this.calcBasisFunctions(vspan, v, q, V);
var temp = [];
for (var l = 0; l <= q; ++l) {
for (var l = 0; l <= q; ++ l) {
temp[l] = new THREE.Vector4(0, 0, 0, 0);
for (var k = 0; k <= p; ++k) {
for (var k = 0; k <= p; ++ k) {
var point = P[uspan - p + k][vspan - q + l].clone();
var w = point.w;
point.x *= w;
......@@ -380,7 +380,7 @@ THREE.NURBSUtils = {
}
var Sw = new THREE.Vector4(0, 0, 0, 0);
for (var l = 0; l <= q; ++l) {
for (var l = 0; l <= q; ++ l) {
Sw.add(temp[l].multiplyScalar(Nv[l]));
}
......
......@@ -96,8 +96,8 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) {
var oStyle = oAscii.style;
oStyle.display = "inline";
oStyle.width = Math.round(iWidth/fResolution*iScale) + "px";
oStyle.height = Math.round(iHeight/fResolution*iScale) + "px";
oStyle.width = Math.round(iWidth / fResolution * iScale) + "px";
oStyle.height = Math.round(iHeight / fResolution * iScale) + "px";
oStyle.whiteSpace = "pre";
oStyle.margin = "0px";
oStyle.padding = "0px";
......@@ -144,8 +144,8 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) {
// Setup dom
var fFontSize = (2/fResolution)*iScale;
var fLineHeight = (2/fResolution)*iScale;
var fFontSize = (2 / fResolution) * iScale;
var fLineHeight = (2 / fResolution) * iScale;
// adjust letter-spacing for all combinations of scale and resolution to get it to fit the image width.
......@@ -204,9 +204,9 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) {
// console.time('rendering');
for (var y=0;y<iHeight;y+=2) {
for (var x=0;x<iWidth;x++) {
var iOffset = (y*iWidth + x) * 4;
for (var y = 0; y < iHeight; y+=2) {
for (var x = 0; x < iWidth; x ++) {
var iOffset = (y * iWidth + x) * 4;
var iRed = oImgData[iOffset];
var iGreen = oImgData[iOffset + 1];
......@@ -216,7 +216,7 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) {
var fBrightness;
fBrightness = (0.3*iRed + 0.59*iGreen + 0.11*iBlue) / 255;
fBrightness = (0.3 * iRed + 0.59 * iGreen + 0.11 * iBlue) / 255;
// fBrightness = (0.3*iRed + 0.5*iGreen + 0.3*iBlue) / 255;
if (iAlpha == 0) {
......@@ -226,7 +226,7 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) {
}
iCharIdx = Math.floor((1-fBrightness) * (aCharList.length-1));
iCharIdx = Math.floor((1 - fBrightness) * (aCharList.length - 1));
if (bInvert) {
iCharIdx = aCharList.length - iCharIdx - 1;
......@@ -238,14 +238,14 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) {
var strThisChar = aCharList[iCharIdx];
if (strThisChar===undefined || strThisChar == " ")
if (strThisChar === undefined || strThisChar == " ")
strThisChar = "&nbsp;";
if (bColor) {
strChars += "<span style='"
+ "color:rgb("+iRed+","+iGreen+","+iBlue+");"
+ (bBlock ? "background-color:rgb("+iRed+","+iGreen+","+iBlue+");" : "")
+ (bAlpha ? "opacity:" + (iAlpha/255) + ";" : "")
+ "color:rgb(" + iRed + "," + iGreen + "," + iBlue + ");"
+ (bBlock ? "background-color:rgb(" + iRed + "," + iGreen + "," + iBlue + ");" : "")
+ (bAlpha ? "opacity:" + (iAlpha / 255) + ";" : "")
+ "'>" + strThisChar + "</span>";
} else {
strChars += strThisChar;
......
......@@ -43,7 +43,7 @@ THREE.VREffect = function ( renderer, done ) {
function gotVRDevices( devices ) {
var vrHMD;
var error;
for ( var i = 0; i < devices.length; ++i ) {
for ( var i = 0; i < devices.length; ++ i ) {
if ( devices[i] instanceof HMDVRDevice ) {
vrHMD = devices[i];
self._vrHMD = vrHMD;
......@@ -56,7 +56,7 @@ THREE.VREffect = function ( renderer, done ) {
}
if ( done ) {
if ( !vrHMD ) {
error = 'HMD not available';
error = 'HMD not available';
}
done( error );
}
......@@ -155,7 +155,7 @@ THREE.VREffect = function ( renderer, done ) {
var vrHMD = this._vrHMD;
var canvas = renderer.domElement;
var fullScreenChange =
canvas.mozRequestFullScreen? 'mozfullscreenchange' : 'webkitfullscreenchange';
canvas.mozRequestFullScreen ? 'mozfullscreenchange' : 'webkitfullscreenchange';
document.addEventListener( fullScreenChange, onFullScreenChanged, false );
function onFullScreenChanged() {
......@@ -175,7 +175,7 @@ THREE.VREffect = function ( renderer, done ) {
var pxoffset = (fov.leftTan - fov.rightTan) * pxscale * 0.5;
var pyscale = 2.0 / (fov.upTan + fov.downTan);
var pyoffset = (fov.upTan - fov.downTan) * pyscale * 0.5;
return { scale: [pxscale, pyscale], offset: [pxoffset, pyoffset] };
return { scale: [ pxscale, pyscale ], offset: [ pxoffset, pyoffset ] };
};
this.FovPortToProjection = function( fov, rightHanded /* = true */, zNear /* = 0.01 */, zFar /* = 10000.0 */ )
......@@ -194,30 +194,30 @@ THREE.VREffect = function ( renderer, done ) {
var scaleAndOffset = this.FovToNDCScaleOffset(fov);
// X result, map clip edges to [-w,+w]
m[0*4+0] = scaleAndOffset.scale[0];
m[0*4+1] = 0.0;
m[0*4+2] = scaleAndOffset.offset[0] * handednessScale;
m[0*4+3] = 0.0;
m[0 * 4 + 0] = scaleAndOffset.scale[0];
m[0 * 4 + 1] = 0.0;
m[0 * 4 + 2] = scaleAndOffset.offset[0] * handednessScale;
m[0 * 4 + 3] = 0.0;
// Y result, map clip edges to [-w,+w]
// Y offset is negated because this proj matrix transforms from world coords with Y=up,
// but the NDC scaling has Y=down (thanks D3D?)
m[1*4+0] = 0.0;
m[1*4+1] = scaleAndOffset.scale[1];
m[1*4+2] = -scaleAndOffset.offset[1] * handednessScale;
m[1*4+3] = 0.0;
m[1 * 4 + 0] = 0.0;
m[1 * 4 + 1] = scaleAndOffset.scale[1];
m[1 * 4 + 2] = -scaleAndOffset.offset[1] * handednessScale;
m[1 * 4 + 3] = 0.0;
// Z result (up to the app)
m[2*4+0] = 0.0;
m[2*4+1] = 0.0;
m[2*4+2] = zFar / (zNear - zFar) * -handednessScale;
m[2*4+3] = (zFar * zNear) / (zNear - zFar);
m[2 * 4 + 0] = 0.0;
m[2 * 4 + 1] = 0.0;
m[2 * 4 + 2] = zFar / (zNear - zFar) * -handednessScale;
m[2 * 4 + 3] = (zFar * zNear) / (zNear - zFar);
// W result (= Z in)
m[3*4+0] = 0.0;
m[3*4+1] = 0.0;
m[3*4+2] = handednessScale;
m[3*4+3] = 0.0;
m[3 * 4 + 0] = 0.0;
m[3 * 4 + 1] = 0.0;
m[3 * 4 + 2] = handednessScale;
m[3 * 4 + 3] = 0.0;
mobj.transpose();
......
......@@ -182,7 +182,7 @@ THREE.SceneExporter.prototype = {
function NumConstantString( c ) {
var constants = [ "NearestFilter", "NearestMipMapNearestFilter" , "NearestMipMapLinearFilter",
var constants = [ "NearestFilter", "NearestMipMapNearestFilter", "NearestMipMapLinearFilter",
"LinearFilter", "LinearMipMapNearestFilter", "LinearMipMapLinearFilter" ];
for ( var i = 0; i < constants.length; i ++ ) {
......
......@@ -23,7 +23,7 @@ THREE.ConvexGeometry = function( vertices ) {
var faces = [ [ 0, 1, 2 ], [ 0, 2, 1 ] ];
for ( var i = 3; i < vertices.length; i++ ) {
for ( var i = 3; i < vertices.length; i ++ ) {
addPoint( i );
......@@ -49,13 +49,13 @@ THREE.ConvexGeometry = function( vertices ) {
// then we try to add the face's edges into the hole.
if ( visible( face, vertex ) ) {
for ( var e = 0; e < 3; e++ ) {
for ( var e = 0; e < 3; e ++ ) {
var edge = [ face[ e ], face[ ( e + 1 ) % 3 ] ];
var boundary = true;
// remove duplicated edges.
for ( var h = 0; h < hole.length; h++ ) {
for ( var h = 0; h < hole.length; h ++ ) {
if ( equalEdge( hole[ h ], edge ) ) {
......@@ -82,13 +82,13 @@ THREE.ConvexGeometry = function( vertices ) {
} else { // not visible
f++;
f ++;
}
}
// construct the new faces formed by the edges of the hole and the vertex
for ( var h = 0; h < hole.length; h++ ) {
for ( var h = 0; h < hole.length; h ++ ) {
faces.push( [
hole[ h ][ 0 ],
......@@ -170,27 +170,27 @@ THREE.ConvexGeometry = function( vertices ) {
var id = 0;
var newId = new Array( vertices.length ); // map from old vertex id to new id
for ( var i = 0; i < faces.length; i++ ) {
for ( var i = 0; i < faces.length; i ++ ) {
var face = faces[ i ];
for ( var j = 0; j < 3; j++ ) {
for ( var j = 0; j < 3; j ++ ) {
if ( newId[ face[ j ] ] === undefined ) {
if ( newId[ face[ j ] ] === undefined ) {
newId[ face[ j ] ] = id++;
this.vertices.push( vertices[ face[ j ] ] );
newId[ face[ j ] ] = id ++;
this.vertices.push( vertices[ face[ j ] ] );
}
}
face[ j ] = newId[ face[ j ] ];
face[ j ] = newId[ face[ j ] ];
}
}
// Convert faces into instances of THREE.Face3
for ( var i = 0; i < faces.length; i++ ) {
for ( var i = 0; i < faces.length; i ++ ) {
this.faces.push( new THREE.Face3(
faces[ i ][ 0 ],
......@@ -201,7 +201,7 @@ THREE.ConvexGeometry = function( vertices ) {
}
// Compute UVs
for ( var i = 0; i < this.faces.length; i++ ) {
for ( var i = 0; i < this.faces.length; i ++ ) {
var face = this.faces[ i ];
......
......@@ -15,7 +15,7 @@ THREE.DecalGeometry = function( mesh, position, rotation, dimensions, check ) {
THREE.Geometry.call( this );
if( check === undefined ) check = null;
if ( check === undefined ) check = null;
check = check || new THREE.Vector3( 1, 1, 1 );
this.uvs = [];
......@@ -60,10 +60,10 @@ THREE.DecalGeometry = function( mesh, position, rotation, dimensions, check ) {
}
if( inVertices.length === 0 ) return [];
if ( inVertices.length === 0 ) return [];
var outVertices = [];
for( var j = 0; j < inVertices.length; j += 3 ) {
for ( var j = 0; j < inVertices.length; j += 3 ) {
var v1Out, v2Out, v3Out, total = 0;
......@@ -75,24 +75,24 @@ THREE.DecalGeometry = function( mesh, position, rotation, dimensions, check ) {
v2Out = d2 > 0;
v3Out = d3 > 0;
total = ( v1Out?1:0 ) + ( v2Out?1:0 ) + ( v3Out?1:0 );
total = ( v1Out ? 1 : 0 ) + ( v2Out ? 1 : 0 ) + ( v3Out ? 1 : 0 );
switch( total ) {
case 0:{
switch ( total ) {
case 0: {
outVertices.push( inVertices[ j ] );
outVertices.push( inVertices[ j + 1 ] );
outVertices.push( inVertices[ j + 2 ] );
break;
}
case 1:{
case 1: {
var nV1, nV2, nV3;
if( v1Out ) {
if ( v1Out ) {
nV1 = inVertices[ j + 1 ];
nV2 = inVertices[ j + 2 ];
nV3 = clip( inVertices[ j ], nV1, plane );
nV4 = clip( inVertices[ j ], nV2, plane );
}
if( v2Out ) {
if ( v2Out ) {
nV1 = inVertices[ j ];
nV2 = inVertices[ j + 2 ];
nV3 = clip( inVertices[ j + 1 ], nV1, plane );
......@@ -107,7 +107,7 @@ THREE.DecalGeometry = function( mesh, position, rotation, dimensions, check ) {
outVertices.push( nV4 );
break;
}
if( v3Out ) {
if ( v3Out ) {
nV1 = inVertices[ j ];
nV2 = inVertices[ j + 1 ];
nV3 = clip( inVertices[ j + 2 ], nV1, plane );
......@@ -126,7 +126,7 @@ THREE.DecalGeometry = function( mesh, position, rotation, dimensions, check ) {
}
case 2: {
var nV1, nV2, nV3;
if( !v1Out ) {
if ( !v1Out ) {
nV1 = inVertices[ j ].clone();
nV2 = clip( nV1, inVertices[ j + 1 ], plane );
nV3 = clip( nV1, inVertices[ j + 2 ], plane );
......@@ -134,7 +134,7 @@ THREE.DecalGeometry = function( mesh, position, rotation, dimensions, check ) {
outVertices.push( nV2 );
outVertices.push( nV3 );
}
if( !v2Out ) {
if ( !v2Out ) {
nV1 = inVertices[ j + 1 ].clone();
nV2 = clip( nV1, inVertices[ j + 2 ], plane );
nV3 = clip( nV1, inVertices[ j ], plane );
......@@ -142,7 +142,7 @@ THREE.DecalGeometry = function( mesh, position, rotation, dimensions, check ) {
outVertices.push( nV2 );
outVertices.push( nV3 );
}
if( !v3Out ) {
if ( !v3Out ) {
nV1 = inVertices[ j + 2 ].clone();
nV2 = clip( nV1, inVertices[ j ], plane );
nV3 = clip( nV1, inVertices[ j + 1 ], plane );
......@@ -164,7 +164,7 @@ THREE.DecalGeometry = function( mesh, position, rotation, dimensions, check ) {
}
this.pushVertex = function( vertices, id, n ){
this.pushVertex = function( vertices, id, n ) {
var v = mesh.geometry.vertices[ id ].clone();
v.applyMatrix4( mesh.matrix );
......@@ -177,7 +177,7 @@ THREE.DecalGeometry = function( mesh, position, rotation, dimensions, check ) {
var finalVertices = [];
for( var i = 0; i < mesh.geometry.faces.length; i++ ) {
for ( var i = 0; i < mesh.geometry.faces.length; i ++ ) {
var f = mesh.geometry.faces[ i ];
var vertices = [];
......@@ -186,20 +186,20 @@ THREE.DecalGeometry = function( mesh, position, rotation, dimensions, check ) {
this.pushVertex( vertices, f[ this.faceIndices[ 1 ] ], f.vertexNormals[ 1 ] );
this.pushVertex( vertices, f[ this.faceIndices[ 2 ] ], f.vertexNormals[ 2 ] );
if( check.x ) {
if ( check.x ) {
vertices = this.clipFace( vertices, new THREE.Vector3( 1, 0, 0 ) );
vertices = this.clipFace( vertices, new THREE.Vector3( -1, 0, 0 ) );
}
if( check.y ) {
vertices = this.clipFace( vertices, new THREE.Vector3( 0, 1, 0 ) );
vertices = this.clipFace( vertices, new THREE.Vector3( 0, -1, 0 ) );
if ( check.y ) {
vertices = this.clipFace( vertices, new THREE.Vector3( 0, 1, 0 ) );
vertices = this.clipFace( vertices, new THREE.Vector3( 0, -1, 0 ) );
}
if( check.z ) {
if ( check.z ) {
vertices = this.clipFace( vertices, new THREE.Vector3( 0, 0, 1 ) );
vertices = this.clipFace( vertices, new THREE.Vector3( 0, 0, -1 ) );
}
for( var j = 0; j < vertices.length; j++ ) {
for ( var j = 0; j < vertices.length; j ++ ) {
var v = vertices[ j ];
......@@ -212,13 +212,13 @@ THREE.DecalGeometry = function( mesh, position, rotation, dimensions, check ) {
}
if( vertices.length === 0 ) continue;
if ( vertices.length === 0 ) continue;
finalVertices = finalVertices.concat( vertices );
}
for( var k = 0; k < finalVertices.length; k += 3 ) {
for ( var k = 0; k < finalVertices.length; k += 3 ) {
this.vertices.push(
finalVertices[ k ].vertex,
......
......@@ -42,7 +42,7 @@ function hilbert2D (center, size, iterations, v0, v1, v2, v3) {
];
// Recurse iterations
if (0 <= --iterations) {
if (0 <= -- iterations) {
var tmp = [];
Array.prototype.push.apply( tmp, hilbert2D ( vec[ 0 ], half, iterations, v0, v3, v2, v1 ) );
......
......@@ -63,7 +63,7 @@ function hilbert3D(center, size, iterations, v0, v1, v2, v3, v4, v5, v6, v7) {
];
// Recurse iterations
if( --iterations >= 0 ) {
if ( -- iterations >= 0 ) {
var tmp = [];
Array.prototype.push.apply( tmp, hilbert3D ( vec[ 0 ], half, iterations, v0, v3, v4, v7, v6, v5, v2, v1 ) );
......
此差异已折叠。
......@@ -74,7 +74,7 @@ THREE.AssimpJSONLoader.prototype = {
parseList : function(json, handler) {
var meshes = new Array(json.length);
for(var i = 0; i < json.length; ++i) {
for (var i = 0; i < json.length; ++ i) {
meshes[i] = handler.call(this, json[i]);
}
return meshes;
......@@ -87,13 +87,13 @@ THREE.AssimpJSONLoader.prototype = {
geometry = new THREE.Geometry();
// read vertex positions
for(in_data = json.vertices, i = 0, e = in_data.length; i < e; ) {
geometry.vertices.push( new THREE.Vector3( in_data[ i++ ], in_data[ i++ ], in_data[ i++ ] ) );
for (in_data = json.vertices, i = 0, e = in_data.length; i < e; ) {
geometry.vertices.push( new THREE.Vector3( in_data[ i ++ ], in_data[ i ++ ], in_data[ i ++ ] ) );
}
// read faces
var cnt = 0;
for(in_data = json.faces, i = 0, e = in_data.length; i < e; ++i) {
for (in_data = json.faces, i = 0, e = in_data.length; i < e; ++ i) {
face = new THREE.Face3();
src = in_data[i];
face.a = src[0];
......@@ -106,12 +106,12 @@ THREE.AssimpJSONLoader.prototype = {
// read texture coordinates - three.js attaches them to its faces
json.texturecoords = json.texturecoords || [];
for(i = 0, e = json.texturecoords.length; i < e; ++i) {
for (i = 0, e = json.texturecoords.length; i < e; ++ i) {
function convertTextureCoords(in_uv, out_faces, out_vertex_uvs) {
var i, e, face, a, b, c;
for(i = 0, e = out_faces.length; i < e; ++i) {
for (i = 0, e = out_faces.length; i < e; ++ i) {
face = out_faces[i];
a = face.a * 2;
b = face.b * 2;
......@@ -128,12 +128,12 @@ THREE.AssimpJSONLoader.prototype = {
}
// read normals - three.js also attaches them to its faces
if(json.normals) {
if (json.normals) {
function convertNormals(in_nor, out_faces) {
var i, e, face, a, b, c;
for(i = 0, e = out_faces.length; i < e; ++i) {
for (i = 0, e = out_faces.length; i < e; ++ i) {
face = out_faces[i];
a = face.a * 3;
b = face.b * 3;
......@@ -150,7 +150,7 @@ THREE.AssimpJSONLoader.prototype = {
}
// read vertex colors - three.js also attaches them to its faces
if(json.colors && json.colors[0]) {
if (json.colors && json.colors[0]) {
function convertColors(in_color, out_faces) {
var i, e, face, a, b, c;
......@@ -162,7 +162,7 @@ THREE.AssimpJSONLoader.prototype = {
return col;
}
for(i = 0, e = out_faces.length; i < e; ++i) {
for (i = 0, e = out_faces.length; i < e; ++ i) {
face = out_faces[i];
a = face.a * 4;
b = face.b * 4;
......@@ -198,7 +198,7 @@ THREE.AssimpJSONLoader.prototype = {
function toColor(value_arr) {
var col = new THREE.Color();
col.setRGB(value_arr[0],value_arr[1],value_arr[2]);
col.setRGB(value_arr[0], value_arr[1], value_arr[2]);
return col;
}
......@@ -212,28 +212,28 @@ THREE.AssimpJSONLoader.prototype = {
for (var i in json.properties) {
prop = json.properties[i];
if(prop.key === '$tex.file') {
if (prop.key === '$tex.file') {
// prop.semantic gives the type of the texture
// 1: diffuse
// 2: specular mao
// 5: height map (bumps)
// 6: normal map
// more values (i.e. emissive, environment) are known by assimp and may be relevant
if(prop.semantic === 1 || prop.semantic === 5 || prop.semantic === 6 || prop.semantic === 2) {
if (prop.semantic === 1 || prop.semantic === 5 || prop.semantic === 6 || prop.semantic === 2) {
(function(semantic) {
var loader = new THREE.TextureLoader(scope.manager),
keyname;
if(semantic === 1) {
if (semantic === 1) {
keyname = 'map';
}
else if(semantic === 5) {
else if (semantic === 5) {
keyname = 'bumpMap';
}
else if(semantic === 6) {
else if (semantic === 6) {
keyname = 'normalMap';
}
else if(semantic === 2) {
else if (semantic === 2) {
keyname = 'specularMap';
}
......@@ -243,7 +243,7 @@ THREE.AssimpJSONLoader.prototype = {
var material_url = scope.texturePath + '/' + prop.value
material_url = material_url.replace(/\\/g, '/');
loader.load(material_url, function(tex) {
if(tex) {
if (tex) {
// TODO: read texture settings from assimp.
// Wrapping is the default, though.
tex.wrapS = tex.wrapT = THREE.RepeatWrapping;
......@@ -255,19 +255,19 @@ THREE.AssimpJSONLoader.prototype = {
})(prop.semantic);
}
}
else if(prop.key === '?mat.name') {
else if (prop.key === '?mat.name') {
init_props.name = prop.value;
}
else if(prop.key === '$clr.diffuse') {
else if (prop.key === '$clr.diffuse') {
init_props.color = toColor(prop.value);
}
else if(prop.key === '$clr.specular') {
else if (prop.key === '$clr.specular') {
init_props.specular = toColor(prop.value);
}
else if(prop.key === '$clr.emissive') {
else if (prop.key === '$clr.emissive') {
init_props.emissive = toColor(prop.value);
}
else if(prop.key === '$mat.shadingm') {
else if (prop.key === '$mat.shadingm') {
// aiShadingMode_Flat
if (prop.value === 1) {
init_props.shading = THREE.FlatShading;
......@@ -281,8 +281,8 @@ THREE.AssimpJSONLoader.prototype = {
// note: three.js does not like it when a texture is added after the geometry
// has been rendered once, see http://stackoverflow.com/questions/16531759/.
// for this reason we fill all slots upfront with default textures
if(has_textures.length) {
for(i = has_textures.length-1; i >= 0; --i) {
if (has_textures.length) {
for (i = has_textures.length - 1; i >= 0; -- i) {
init_props[has_textures[i]] = defaultTexture();
}
}
......@@ -301,12 +301,12 @@ THREE.AssimpJSONLoader.prototype = {
obj.matrix = new THREE.Matrix4().fromArray(node.transformation).transpose();
obj.matrix.decompose( obj.position, obj.quaternion, obj.scale );
for(i = 0; node.meshes && i < node.meshes.length; ++i) {
for (i = 0; node.meshes && i < node.meshes.length; ++ i) {
idx = node.meshes[i];
obj.add(new THREE.Mesh( meshes[idx], materials[json.meshes[idx].materialindex] ));
}
for(i = 0; node.children && i < node.children.length; ++i) {
for (i = 0; node.children && i < node.children.length; ++ i) {
obj.add(this.parseObject(json, node.children[i], meshes, materials));
}
......
......@@ -192,7 +192,7 @@ THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texture
start_quad_flat = start_tri_smooth_uv + len_tri_smooth_uv + handlePadding( md.ntri_smooth_uv * 2 );
start_quad_smooth = start_quad_flat + len_quad_flat + handlePadding( md.nquad_flat * 2 );
start_quad_flat_uv = start_quad_smooth + len_quad_smooth + handlePadding( md.nquad_smooth * 2 );
start_quad_smooth_uv= start_quad_flat_uv + len_quad_flat_uv + handlePadding( md.nquad_flat_uv * 2 );
start_quad_smooth_uv = start_quad_flat_uv + len_quad_flat_uv + handlePadding( md.nquad_flat_uv * 2 );
// have to first process faces with uvs
// so that face and uv indices match
......@@ -236,18 +236,18 @@ THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texture
'material_index_bytes' :parseUChar8( data, offset + 19 ),
'nvertices' :parseUInt32( data, offset + 20 ),
'nnormals' :parseUInt32( data, offset + 20 + 4*1 ),
'nuvs' :parseUInt32( data, offset + 20 + 4*2 ),
'nnormals' :parseUInt32( data, offset + 20 + 4 * 1 ),
'nuvs' :parseUInt32( data, offset + 20 + 4 * 2 ),
'ntri_flat' :parseUInt32( data, offset + 20 + 4*3 ),
'ntri_smooth' :parseUInt32( data, offset + 20 + 4*4 ),
'ntri_flat_uv' :parseUInt32( data, offset + 20 + 4*5 ),
'ntri_smooth_uv' :parseUInt32( data, offset + 20 + 4*6 ),
'ntri_flat' :parseUInt32( data, offset + 20 + 4 * 3 ),
'ntri_smooth' :parseUInt32( data, offset + 20 + 4 * 4 ),
'ntri_flat_uv' :parseUInt32( data, offset + 20 + 4 * 5 ),
'ntri_smooth_uv' :parseUInt32( data, offset + 20 + 4 * 6 ),
'nquad_flat' :parseUInt32( data, offset + 20 + 4*7 ),
'nquad_smooth' :parseUInt32( data, offset + 20 + 4*8 ),
'nquad_flat_uv' :parseUInt32( data, offset + 20 + 4*9 ),
'nquad_smooth_uv' :parseUInt32( data, offset + 20 + 4*10 )
'nquad_flat' :parseUInt32( data, offset + 20 + 4 * 7 ),
'nquad_smooth' :parseUInt32( data, offset + 20 + 4 * 8 ),
'nquad_flat_uv' :parseUInt32( data, offset + 20 + 4 * 9 ),
'nquad_smooth_uv' :parseUInt32( data, offset + 20 + 4 * 10 )
};
/*
......@@ -336,7 +336,7 @@ THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texture
var i, x, y, z;
for( i = 0; i < nElements; i ++ ) {
for ( i = 0; i < nElements; i ++ ) {
x = coordArray[ i * 3 ];
y = coordArray[ i * 3 + 1 ];
......@@ -360,13 +360,13 @@ THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texture
var i, x, y, z;
for( i = 0; i < nElements; i ++ ) {
for ( i = 0; i < nElements; i ++ ) {
x = normalArray[ i * 3 ];
y = normalArray[ i * 3 + 1 ];
z = normalArray[ i * 3 + 2 ];
normals.push( x/127, y/127, z/127 );
normals.push( x / 127, y / 127, z / 127 );
}
......@@ -386,7 +386,7 @@ THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texture
var i, u, v;
for( i = 0; i < nElements; i ++ ) {
for ( i = 0; i < nElements; i ++ ) {
u = uvArray[ i * 2 ];
v = uvArray[ i * 2 + 1 ];
......@@ -407,20 +407,20 @@ THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texture
var uvIndexBuffer = new Uint32Array( data, offset, 3 * nElements );
for( i = 0; i < nElements; i ++ ) {
for ( i = 0; i < nElements; i ++ ) {
uva = uvIndexBuffer[ i * 3 ];
uvb = uvIndexBuffer[ i * 3 + 1 ];
uvc = uvIndexBuffer[ i * 3 + 2 ];
u1 = uvs[ uva*2 ];
v1 = uvs[ uva*2 + 1 ];
u1 = uvs[ uva * 2 ];
v1 = uvs[ uva * 2 + 1 ];
u2 = uvs[ uvb*2 ];
v2 = uvs[ uvb*2 + 1 ];
u2 = uvs[ uvb * 2 ];
v2 = uvs[ uvb * 2 + 1 ];
u3 = uvs[ uvc*2 ];
v3 = uvs[ uvc*2 + 1 ];
u3 = uvs[ uvc * 2 ];
v3 = uvs[ uvc * 2 + 1 ];
scope.faceVertexUvs[ 0 ].push( [
new THREE.Vector2( u1, v1 ),
......@@ -438,24 +438,24 @@ THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texture
var uvIndexBuffer = new Uint32Array( data, offset, 4 * nElements );
for( i = 0; i < nElements; i ++ ) {
for ( i = 0; i < nElements; i ++ ) {
uva = uvIndexBuffer[ i * 4 ];
uvb = uvIndexBuffer[ i * 4 + 1 ];
uvc = uvIndexBuffer[ i * 4 + 2 ];
uvd = uvIndexBuffer[ i * 4 + 3 ];
u1 = uvs[ uva*2 ];
v1 = uvs[ uva*2 + 1 ];
u1 = uvs[ uva * 2 ];
v1 = uvs[ uva * 2 + 1 ];
u2 = uvs[ uvb*2 ];
v2 = uvs[ uvb*2 + 1 ];
u2 = uvs[ uvb * 2 ];
v2 = uvs[ uvb * 2 + 1 ];
u3 = uvs[ uvc*2 ];
v3 = uvs[ uvc*2 + 1 ];
u3 = uvs[ uvc * 2 ];
v3 = uvs[ uvc * 2 + 1 ];
u4 = uvs[ uvd*2 ];
v4 = uvs[ uvd*2 + 1 ];
u4 = uvs[ uvd * 2 ];
v4 = uvs[ uvd * 2 + 1 ];
scope.faceVertexUvs[ 0 ].push( [
new THREE.Vector2( u1, v1 ),
......@@ -480,7 +480,7 @@ THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texture
var vertexIndexBuffer = new Uint32Array( data, offsetVertices, 3 * nElements );
var materialIndexBuffer = new Uint16Array( data, offsetMaterials, nElements );
for( i = 0; i < nElements; i ++ ) {
for ( i = 0; i < nElements; i ++ ) {
a = vertexIndexBuffer[ i * 3 ];
b = vertexIndexBuffer[ i * 3 + 1 ];
......@@ -501,7 +501,7 @@ THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texture
var vertexIndexBuffer = new Uint32Array( data, offsetVertices, 4 * nElements );
var materialIndexBuffer = new Uint16Array( data, offsetMaterials, nElements );
for( i = 0; i < nElements; i ++ ) {
for ( i = 0; i < nElements; i ++ ) {
a = vertexIndexBuffer[ i * 4 ];
b = vertexIndexBuffer[ i * 4 + 1 ];
......@@ -526,7 +526,7 @@ THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texture
var normalIndexBuffer = new Uint32Array( data, offsetNormals, 3 * nElements );
var materialIndexBuffer = new Uint16Array( data, offsetMaterials, nElements );
for( i = 0; i < nElements; i ++ ) {
for ( i = 0; i < nElements; i ++ ) {
a = vertexIndexBuffer[ i * 3 ];
b = vertexIndexBuffer[ i * 3 + 1 ];
......@@ -538,17 +538,17 @@ THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texture
m = materialIndexBuffer[ i ];
var nax = normals[ na*3 ],
nay = normals[ na*3 + 1 ],
naz = normals[ na*3 + 2 ],
var nax = normals[ na * 3 ],
nay = normals[ na * 3 + 1 ],
naz = normals[ na * 3 + 2 ],
nbx = normals[ nb*3 ],
nby = normals[ nb*3 + 1 ],
nbz = normals[ nb*3 + 2 ],
nbx = normals[ nb * 3 ],
nby = normals[ nb * 3 + 1 ],
nbz = normals[ nb * 3 + 2 ],
ncx = normals[ nc*3 ],
ncy = normals[ nc*3 + 1 ],
ncz = normals[ nc*3 + 2 ];
ncx = normals[ nc * 3 ],
ncy = normals[ nc * 3 + 1 ],
ncz = normals[ nc * 3 + 2 ];
scope.faces.push( new THREE.Face3( a, b, c, [
new THREE.Vector3( nax, nay, naz ),
......@@ -569,7 +569,7 @@ THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texture
var normalIndexBuffer = new Uint32Array( data, offsetNormals, 4 * nElements );
var materialIndexBuffer = new Uint16Array( data, offsetMaterials, nElements );
for( i = 0; i < nElements; i ++ ) {
for ( i = 0; i < nElements; i ++ ) {
a = vertexIndexBuffer[ i * 4 ];
b = vertexIndexBuffer[ i * 4 + 1 ];
......@@ -583,21 +583,21 @@ THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texture
m = materialIndexBuffer[ i ];
var nax = normals[ na*3 ],
nay = normals[ na*3 + 1 ],
naz = normals[ na*3 + 2 ],
var nax = normals[ na * 3 ],
nay = normals[ na * 3 + 1 ],
naz = normals[ na * 3 + 2 ],
nbx = normals[ nb*3 ],
nby = normals[ nb*3 + 1 ],
nbz = normals[ nb*3 + 2 ],
nbx = normals[ nb * 3 ],
nby = normals[ nb * 3 + 1 ],
nbz = normals[ nb * 3 + 2 ],
ncx = normals[ nc*3 ],
ncy = normals[ nc*3 + 1 ],
ncz = normals[ nc*3 + 2 ],
ncx = normals[ nc * 3 ],
ncy = normals[ nc * 3 + 1 ],
ncz = normals[ nc * 3 + 2 ],
ndx = normals[ nd*3 ],
ndy = normals[ nd*3 + 1 ],
ndz = normals[ nd*3 + 2 ];
ndx = normals[ nd * 3 ],
ndy = normals[ nd * 3 + 1 ],
ndz = normals[ nd * 3 + 2 ];
scope.faces.push( new THREE.Face3( a, b, d, [
new THREE.Vector3( nax, nay, naz ),
......
......@@ -70,21 +70,21 @@ THREE.DDSLoader.parse = function ( buffer, loadMipmaps ) {
}
function loadARGBMip( buffer, dataOffset, width, height ) {
var dataLength = width*height*4;
var dataLength = width * height * 4;
var srcBuffer = new Uint8Array( buffer, dataOffset, dataLength );
var byteArray = new Uint8Array( dataLength );
var dst = 0;
var src = 0;
for ( var y = 0; y < height; y++ ) {
for ( var x = 0; x < width; x++ ) {
var b = srcBuffer[src]; src++;
var g = srcBuffer[src]; src++;
var r = srcBuffer[src]; src++;
var a = srcBuffer[src]; src++;
byteArray[dst] = r; dst++; //r
byteArray[dst] = g; dst++; //g
byteArray[dst] = b; dst++; //b
byteArray[dst] = a; dst++; //a
for ( var y = 0; y < height; y ++ ) {
for ( var x = 0; x < width; x ++ ) {
var b = srcBuffer[src]; src ++;
var g = srcBuffer[src]; src ++;
var r = srcBuffer[src]; src ++;
var a = srcBuffer[src]; src ++;
byteArray[dst] = r; dst ++; //r
byteArray[dst] = g; dst ++; //g
byteArray[dst] = b; dst ++; //b
byteArray[dst] = a; dst ++; //a
}
}
return byteArray;
......@@ -166,7 +166,7 @@ THREE.DDSLoader.parse = function ( buffer, loadMipmaps ) {
default:
if( header[off_RGBBitCount] ==32
if ( header[off_RGBBitCount] == 32
&& header[off_RBitMask]&0xff0000
&& header[off_GBitMask]&0xff00
&& header[off_BBitMask]&0xff
......@@ -208,7 +208,7 @@ THREE.DDSLoader.parse = function ( buffer, loadMipmaps ) {
for ( var i = 0; i < dds.mipmapCount; i ++ ) {
if( isRGBAUncompressed ) {
if ( isRGBAUncompressed ) {
var byteArray = loadARGBMip( buffer, dataOffset, width, height );
var dataLength = byteArray.length;
} else {
......
......@@ -121,8 +121,8 @@ THREE.MTLLoader.MaterialCreator = function( baseUrl, options ) {
this.materialsArray = [];
this.nameLookup = {};
this.side = ( this.options && this.options.side )? this.options.side: THREE.FrontSide;
this.wrap = ( this.options && this.options.wrap )? this.options.wrap: THREE.RepeatWrapping;
this.side = ( this.options && this.options.side ) ? this.options.side : THREE.FrontSide;
this.wrap = ( this.options && this.options.wrap ) ? this.options.wrap : THREE.RepeatWrapping;
};
......@@ -426,7 +426,7 @@ THREE.MTLLoader.ensurePowerOfTwo_ = function ( image ) {
THREE.MTLLoader.nextHighestPowerOfTwo_ = function( x ) {
--x;
-- x;
for ( var i = 1; i < 32; i <<= 1 ) {
......
......@@ -53,7 +53,7 @@ THREE.PDBLoader.prototype = {
var eatom = parseInt( lines[ i ].substr( start, length ) );
if( eatom ) {
if ( eatom ) {
var h = hash( satom, eatom );
......@@ -75,8 +75,8 @@ THREE.PDBLoader.prototype = {
}
var CPK = {"h":[255,255,255],"he":[217,255,255],"li":[204,128,255],"be":[194,255,0],"b":[255,181,181],"c":[144,144,144],"n":[48,80,248],"o":[255,13,13],"f":[144,224,80],"ne":[179,227,245],"na":[171,92,242],"mg":[138,255,0],"al":[191,166,166],"si":[240,200,160],"p":[255,128,0],"s":[255,255,48],"cl":[31,240,31],"ar":[128,209,227],"k":[143,64,212],"ca":[61,255,0],"sc":[230,230,230],"ti":[191,194,199],"v":[166,166,171],"cr":[138,153,199],"mn":[156,122,199],"fe":[224,102,51],"co":[240,144,160],"ni":[80,208,80],"cu":[200,128,51],"zn":[125,128,176],"ga":[194,143,143],"ge":[102,143,143],"as":[189,128,227],"se":[255,161,0],"br":[166,41,41],"kr":[92,184,209],"rb":[112,46,176],"sr":[0,255,0],"y":[148,255,255],"zr":[148,224,224],"nb":[115,194,201],"mo":[84,181,181],"tc":[59,158,158],"ru":[36,143,143],"rh":[10,125,140],"pd":[0,105,133],"ag":[192,192,192],"cd":[255,217,143],"in":[166,117,115],"sn":[102,128,128],"sb":[158,99,181],"te":[212,122,0],"i":[148,0,148],"xe":[66,158,176],"cs":[87,23,143],"ba":[0,201,0],"la":[112,212,255],"ce":[255,255,199],"pr":[217,255,199],"nd":[199,255,199],"pm":[163,255,199],"sm":[143,255,199],"eu":[97,255,199],"gd":[69,255,199],"tb":[48,255,199],"dy":[31,255,199],"ho":[0,255,156],"er":[0,230,117],"tm":[0,212,82],"yb":[0,191,56],"lu":[0,171,36],"hf":[77,194,255],"ta":[77,166,255],"w":[33,148,214],"re":[38,125,171],"os":[38,102,150],"ir":[23,84,135],"pt":[208,208,224],"au":[255,209,35],"hg":[184,184,208],"tl":[166,84,77],"pb":[87,89,97],"bi":[158,79,181],"po":[171,92,0],"at":[117,79,69],"rn":[66,130,150],"fr":[66,0,102],"ra":[0,125,0],"ac":[112,171,250],"th":[0,186,255],"pa":[0,161,255],"u":[0,143,255],"np":[0,128,255],"pu":[0,107,255],"am":[84,92,242],"cm":[120,92,227],"bk":[138,79,227],"cf":[161,54,212],"es":[179,31,212],"fm":[179,31,186],"md":[179,13,166],"no":[189,13,135],"lr":[199,0,102],"rf":[204,0,89],"db":[209,0,79],"sg":[217,0,69],"bh":[224,0,56],"hs":[230,0,46],"mt":[235,0,38],
"ds":[235,0,38],"rg":[235,0,38],"cn":[235,0,38],"uut":[235,0,38],"uuq":[235,0,38],"uup":[235,0,38],"uuh":[235,0,38],"uus":[235,0,38],"uuo":[235,0,38]};
var CPK = { "h":[ 255,255,255 ],"he":[ 217,255,255 ],"li":[ 204,128,255 ],"be":[ 194,255,0 ],"b":[ 255,181,181 ],"c":[ 144,144,144 ],"n":[ 48,80,248 ],"o":[ 255,13,13 ],"f":[ 144,224,80 ],"ne":[ 179,227,245 ],"na":[ 171,92,242 ],"mg":[ 138,255,0 ],"al":[ 191,166,166 ],"si":[ 240,200,160 ],"p":[ 255,128,0 ],"s":[ 255,255,48 ],"cl":[ 31,240,31 ],"ar":[ 128,209,227 ],"k":[ 143,64,212 ],"ca":[ 61,255,0 ],"sc":[ 230,230,230 ],"ti":[ 191,194,199 ],"v":[ 166,166,171 ],"cr":[ 138,153,199 ],"mn":[ 156,122,199 ],"fe":[ 224,102,51 ],"co":[ 240,144,160 ],"ni":[ 80,208,80 ],"cu":[ 200,128,51 ],"zn":[ 125,128,176 ],"ga":[ 194,143,143 ],"ge":[ 102,143,143 ],"as":[ 189,128,227 ],"se":[ 255,161,0 ],"br":[ 166,41,41 ],"kr":[ 92,184,209 ],"rb":[ 112,46,176 ],"sr":[ 0,255,0 ],"y":[ 148,255,255 ],"zr":[ 148,224,224 ],"nb":[ 115,194,201 ],"mo":[ 84,181,181 ],"tc":[ 59,158,158 ],"ru":[ 36,143,143 ],"rh":[ 10,125,140 ],"pd":[ 0,105,133 ],"ag":[ 192,192,192 ],"cd":[ 255,217,143 ],"in":[ 166,117,115 ],"sn":[ 102,128,128 ],"sb":[ 158,99,181 ],"te":[ 212,122,0 ],"i":[ 148,0,148 ],"xe":[ 66,158,176 ],"cs":[ 87,23,143 ],"ba":[ 0,201,0 ],"la":[ 112,212,255 ],"ce":[ 255,255,199 ],"pr":[ 217,255,199 ],"nd":[ 199,255,199 ],"pm":[ 163,255,199 ],"sm":[ 143,255,199 ],"eu":[ 97,255,199 ],"gd":[ 69,255,199 ],"tb":[ 48,255,199 ],"dy":[ 31,255,199 ],"ho":[ 0,255,156 ],"er":[ 0,230,117 ],"tm":[ 0,212,82 ],"yb":[ 0,191,56 ],"lu":[ 0,171,36 ],"hf":[ 77,194,255 ],"ta":[ 77,166,255 ],"w":[ 33,148,214 ],"re":[ 38,125,171 ],"os":[ 38,102,150 ],"ir":[ 23,84,135 ],"pt":[ 208,208,224 ],"au":[ 255,209,35 ],"hg":[ 184,184,208 ],"tl":[ 166,84,77 ],"pb":[ 87,89,97 ],"bi":[ 158,79,181 ],"po":[ 171,92,0 ],"at":[ 117,79,69 ],"rn":[ 66,130,150 ],"fr":[ 66,0,102 ],"ra":[ 0,125,0 ],"ac":[ 112,171,250 ],"th":[ 0,186,255 ],"pa":[ 0,161,255 ],"u":[ 0,143,255 ],"np":[ 0,128,255 ],"pu":[ 0,107,255 ],"am":[ 84,92,242 ],"cm":[ 120,92,227 ],"bk":[ 138,79,227 ],"cf":[ 161,54,212 ],"es":[ 179,31,212 ],"fm":[ 179,31,186 ],"md":[ 179,13,166 ],"no":[ 189,13,135 ],"lr":[ 199,0,102 ],"rf":[ 204,0,89 ],"db":[ 209,0,79 ],"sg":[ 217,0,69 ],"bh":[ 224,0,56 ],"hs":[ 230,0,46 ],"mt":[ 235,0,38 ],
"ds":[ 235,0,38 ],"rg":[ 235,0,38 ],"cn":[ 235,0,38 ],"uut":[ 235,0,38 ],"uuq":[ 235,0,38 ],"uup":[ 235,0,38 ],"uuh":[ 235,0,38 ],"uus":[ 235,0,38 ],"uuo":[ 235,0,38 ] };
var atoms = [];
......@@ -89,30 +89,30 @@ THREE.PDBLoader.prototype = {
var x, y, z, e;
for( var i = 0, il = lines.length; i < il; ++ i ) {
for ( var i = 0, il = lines.length; i < il; ++ i ) {
if( lines[i].substr(0,4)=="ATOM" || lines[i].substr(0,6)=="HETATM" ) {
if ( lines[i].substr(0, 4) == "ATOM" || lines[i].substr(0, 6) == "HETATM" ) {
x = parseFloat( lines[i].substr(30,7) );
y = parseFloat( lines[i].substr(38,7) );
z = parseFloat( lines[i].substr(46,7) );
x = parseFloat( lines[i].substr(30, 7) );
y = parseFloat( lines[i].substr(38, 7) );
z = parseFloat( lines[i].substr(46, 7) );
e = trim( lines[i].substr(76,2) ).toLowerCase();
e = trim( lines[i].substr(76, 2) ).toLowerCase();
if ( e=="" ) e = trim(lines[i].substr(12,2)).toLowerCase();
if ( e == "" ) e = trim(lines[i].substr(12, 2)).toLowerCase();
atoms.push( [ x,y,z, CPK[e], capitalize(e) ] );
if (histogram[e]==undefined) histogram[e] = 1;
if (histogram[e] == undefined) histogram[e] = 1;
else histogram[e] += 1;
} else if(lines[i].substr(0,6)=="CONECT") {
} else if (lines[i].substr(0, 6) == "CONECT") {
var satom = parseInt( lines[i].substr(6,5) );
var satom = parseInt( lines[i].substr(6, 5) );
parseBond(11,5);
parseBond(16,5);
parseBond(21,5);
parseBond(26,5);
parseBond(11, 5);
parseBond(16, 5);
parseBond(21, 5);
parseBond(26, 5);
}
......
......@@ -80,7 +80,7 @@ THREE.PLYLoader.prototype = {
var array_buffer = new Uint8Array(buf);
var str = '';
for(var i = 0; i < buf.byteLength; i++) {
for (var i = 0; i < buf.byteLength; i ++) {
str += String.fromCharCode(array_buffer[i]); // implicitly assumes little-endian
}
......@@ -88,7 +88,7 @@ THREE.PLYLoader.prototype = {
},
isASCII: function( data ){
isASCII: function( data ) {
var header = this.parseHeader( this.bin2str( data ) );
......@@ -167,7 +167,7 @@ THREE.PLYLoader.prototype = {
lineType = lineValues.shift()
line = lineValues.join(" ")
switch( lineType ) {
switch ( lineType ) {
case "format":
......@@ -224,7 +224,7 @@ THREE.PLYLoader.prototype = {
parseASCIINumber: function ( n, type ) {
switch( type ) {
switch ( type ) {
case 'char': case 'uchar': case 'short': case 'ushort': case 'int': case 'uint':
case 'int8': case 'uint8': case 'int16': case 'uint16': case 'int32': case 'uint32':
......@@ -301,7 +301,7 @@ THREE.PLYLoader.prototype = {
if ( currentElementCount >= header.elements[currentElement].count ) {
currentElement++;
currentElement ++;
currentElementCount = 0;
}
......@@ -310,7 +310,7 @@ THREE.PLYLoader.prototype = {
this.handleElement( geometry, header.elements[currentElement].name, element );
currentElementCount++;
currentElementCount ++;
}
......@@ -385,7 +385,7 @@ THREE.PLYLoader.prototype = {
binaryRead: function ( dataview, at, type, little_endian ) {
switch( type ) {
switch ( type ) {
// corespondences for non-specific length types here match rply:
case 'int8': case 'char': return [ dataview.getInt8( at ), 1 ];
......@@ -419,13 +419,13 @@ THREE.PLYLoader.prototype = {
var list = [];
result = this.binaryRead( dataview, at+read, properties[i].countType, little_endian );
result = this.binaryRead( dataview, at + read, properties[i].countType, little_endian );
var n = result[0];
read += result[1];
for ( j = 0; j < n; j ++ ) {
result = this.binaryRead( dataview, at+read, properties[i].itemType, little_endian );
result = this.binaryRead( dataview, at + read, properties[i].itemType, little_endian );
list.push( result[0] );
read += result[1];
......@@ -435,7 +435,7 @@ THREE.PLYLoader.prototype = {
} else {
result = this.binaryRead( dataview, at+read, properties[i].type, little_endian );
result = this.binaryRead( dataview, at + read, properties[i].type, little_endian );
element[ properties[i].name ] = result[0];
read += result[1];
......
......@@ -28,11 +28,11 @@ THREE.PVRLoader.parse = function ( buffer, loadMipmaps ) {
};
// PVR v3
if( header[0] === 0x03525650 ) {
if ( header[0] === 0x03525650 ) {
return THREE.PVRLoader._parseV3( pvrDatas );
}
// PVR v2
else if( header[11] === 0x21525650) {
else if ( header[11] === 0x21525650) {
return THREE.PVRLoader._parseV2( pvrDatas );
} else {
......@@ -55,7 +55,7 @@ THREE.PVRLoader._parseV3 = function ( pvrDatas ) {
numFaces = header[10],
numMipmaps = header[11];
switch( pixelFormat ) {
switch ( pixelFormat ) {
case 0 : // PVRTC 2bpp RGB
bpp = 2;
format = THREE.RGB_PVRTC_2BPPV1_Format;
......@@ -73,20 +73,20 @@ THREE.PVRLoader._parseV3 = function ( pvrDatas ) {
format = THREE.RGBA_PVRTC_4BPPV1_Format;
break;
default :
throw new Error( "pvrtc - unsupported PVR format "+pixelFormat);
throw new Error( "pvrtc - unsupported PVR format " + pixelFormat);
}
pvrDatas.dataPtr = 52 + metaLen;
pvrDatas.bpp = bpp;
pvrDatas.format = format;
pvrDatas.width = width;
pvrDatas.height = height;
pvrDatas.numSurfaces = numFaces;
pvrDatas.numMipmaps = numMipmaps;
pvrDatas.bpp = bpp;
pvrDatas.format = format;
pvrDatas.width = width;
pvrDatas.height = height;
pvrDatas.numSurfaces = numFaces;
pvrDatas.numMipmaps = numMipmaps;
pvrDatas.isCubemap = (numFaces === 6);
pvrDatas.isCubemap = (numFaces === 6);
return THREE.PVRLoader._extract( pvrDatas );
return THREE.PVRLoader._extract( pvrDatas );
};
THREE.PVRLoader._parseV2 = function ( pvrDatas ) {
......@@ -123,28 +123,28 @@ THREE.PVRLoader._parseV2 = function ( pvrDatas ) {
format = _hasAlpha ? THREE.RGBA_PVRTC_4BPPV1_Format : THREE.RGB_PVRTC_4BPPV1_Format;
bpp = 4;
}
else if( formatFlags === PVRTC_2) {
else if ( formatFlags === PVRTC_2) {
format = _hasAlpha ? THREE.RGBA_PVRTC_2BPPV1_Format : THREE.RGB_PVRTC_2BPPV1_Format;
bpp = 2;
}
else
throw new Error( "pvrtc - unknown format "+formatFlags);
throw new Error( "pvrtc - unknown format " + formatFlags);
pvrDatas.dataPtr = headerLength;
pvrDatas.bpp = bpp;
pvrDatas.format = format;
pvrDatas.width = width;
pvrDatas.height = height;
pvrDatas.numSurfaces = numSurfs;
pvrDatas.numMipmaps = numMipmaps + 1;
pvrDatas.bpp = bpp;
pvrDatas.format = format;
pvrDatas.width = width;
pvrDatas.height = height;
pvrDatas.numSurfaces = numSurfs;
pvrDatas.numMipmaps = numMipmaps + 1;
// guess cubemap type seems tricky in v2
// it juste a pvr containing 6 surface (no explicit cubemap type)
pvrDatas.isCubemap = (numSurfs === 6);
pvrDatas.isCubemap = (numSurfs === 6);
return THREE.PVRLoader._extract( pvrDatas );
return THREE.PVRLoader._extract( pvrDatas );
};
......@@ -195,7 +195,7 @@ THREE.PVRLoader._extract = function ( pvrDatas ) {
if( bpp === 2 ){
if ( bpp === 2 ) {
blockWidth = 8;
blockHeight = 4;
} else {
......@@ -243,7 +243,7 @@ THREE.PVRLoader._extract = function ( pvrDatas ) {
}
mipLevel++;
mipLevel ++;
}
......
......@@ -30,11 +30,11 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
rgbe_error = function(rgbe_error_code, msg) {
switch (rgbe_error_code) {
case rgbe_read_error: console.error("THREE.RGBELoader Read Error: " + (msg||''));
break;
break;
case rgbe_write_error: console.error("THREE.RGBELoader Write Error: " + (msg||''));
break;
break;
case rgbe_format_error: console.error("THREE.RGBELoader Bad File Format: " + (msg||''));
break;
break;
default:
case rgbe_memory_error: console.error("THREE.RGBELoader: Error: " + (msg||''));
}
......@@ -60,13 +60,13 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
lineLimit = !lineLimit ? 1024 : lineLimit;
var p = buffer.pos,
i = -1, len = 0, s = '', chunkSize = 128,
chunk = String.fromCharCode.apply(null, new Uint16Array( buffer.subarray( p, p+chunkSize ) ) )
chunk = String.fromCharCode.apply(null, new Uint16Array( buffer.subarray( p, p + chunkSize ) ) )
;
while ( (0 > (i=chunk.indexOf( NEWLINE ))) && (len < lineLimit) && (p < buffer.byteLength) ) {
while ( (0 > (i = chunk.indexOf( NEWLINE ))) && (len < lineLimit) && (p < buffer.byteLength) ) {
s += chunk; len += chunk.length;
p += chunkSize;
chunk += String.fromCharCode.apply(null, new Uint16Array( buffer.subarray( p, p+chunkSize ) ) );
chunk += String.fromCharCode.apply(null, new Uint16Array( buffer.subarray( p, p + chunkSize ) ) );
}
......@@ -78,7 +78,7 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
else if (byteCode > 0x7ff && byteCode <= 0xffff) byteLen += 2;
if (byteCode >= 0xDC00 && byteCode <= 0xDFFF) i--; //trail surrogate
}*/
if ( false !== consume ) buffer.pos += len+i+1;
if ( false !== consume ) buffer.pos += len + i + 1;
return s + chunk.slice(0, i);
}
......@@ -122,11 +122,11 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
}
;
if ( buffer.pos >= buffer.byteLength || !( line=fgets( buffer ) ) ) {
if ( buffer.pos >= buffer.byteLength || !( line = fgets( buffer ) ) ) {
return rgbe_error( rgbe_read_error, "no header found" );
}
/* if you want to require the magic token then uncomment the next line */
if ( !(match=line.match(magic_token_re)) ) {
if ( !(match = line.match(magic_token_re)) ) {
return rgbe_error( rgbe_format_error, "bad initial token" );
}
header.valid |= RGBE_VALID_PROGRAMTYPE;
......@@ -144,17 +144,17 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
continue; // comment line
}
if ( match=line.match(gamma_re) ) {
if ( match = line.match(gamma_re) ) {
header.gamma = parseFloat(match[1], 10);
}
if ( match=line.match(exposure_re) ) {
if ( match = line.match(exposure_re) ) {
header.exposure = parseFloat(match[1], 10);
}
if ( match=line.match(format_re) ) {
if ( match = line.match(format_re) ) {
header.valid |= RGBE_VALID_FORMAT;
header.format = match[1];//'32-bit_rle_rgbe';
}
if ( match=line.match(dimensions_re) ) {
if ( match = line.match(dimensions_re) ) {
header.valid |= RGBE_VALID_DIMENSIONS;
header.height = parseInt(match[1], 10);
header.width = parseInt(match[2], 10);
......@@ -193,29 +193,29 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
return rgbe_error(rgbe_format_error, "wrong scanline width");
}
data_rgba = new Uint8Array( 4*w*h );
data_rgba = new Uint8Array( 4 * w * h );
if ( !data_rgba || !data_rgba.length ) {
return rgbe_error(rgbe_memory_error, "unable to allocate buffer space");
}
offset = 0; pos = 0; ptr_end = 4*scanline_width;
offset = 0; pos = 0; ptr_end = 4 * scanline_width;
rgbeStart = new Uint8Array( 4 );
scanline_buffer = new Uint8Array( ptr_end );
// read in each successive scanline
while( (num_scanlines > 0) && (pos < buffer.byteLength) ) {
while ( (num_scanlines > 0) && (pos < buffer.byteLength) ) {
if ( pos+4 > buffer.byteLength ) {
if ( pos + 4 > buffer.byteLength ) {
return rgbe_error( rgbe_read_error );
}
rgbeStart[0] = buffer[pos++];
rgbeStart[1] = buffer[pos++];
rgbeStart[2] = buffer[pos++];
rgbeStart[3] = buffer[pos++];
rgbeStart[0] = buffer[pos ++];
rgbeStart[1] = buffer[pos ++];
rgbeStart[2] = buffer[pos ++];
rgbeStart[3] = buffer[pos ++];
if ( (2 != rgbeStart[0]) || (2 != rgbeStart[1]) || (((rgbeStart[2]<<8) | rgbeStart[3]) != scanline_width) ) {
......@@ -228,11 +228,11 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
ptr = 0;
while ( (ptr < ptr_end) && (pos < buffer.byteLength) ) {
count = buffer[ pos++ ];
count = buffer[ pos ++ ];
isEncodedRun = count > 128;
if ( isEncodedRun ) count -= 128;
if ( (0 === count) || (ptr+count > ptr_end) ) {
if ( (0 === count) || (ptr + count > ptr_end) ) {
return rgbe_error(rgbe_format_error, "bad scanline data");
......@@ -240,15 +240,15 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
if ( isEncodedRun ) {
// a (encoded) run of the same value
byteValue = buffer[ pos++ ];
for (i=0; i<count; i++) {
scanline_buffer[ ptr++ ] = byteValue;
byteValue = buffer[ pos ++ ];
for (i = 0; i < count; i ++) {
scanline_buffer[ ptr ++ ] = byteValue;
}
//ptr += count;
} else {
// a literal-run
scanline_buffer.set( buffer.subarray(pos, pos+count), ptr );
scanline_buffer.set( buffer.subarray(pos, pos + count), ptr );
ptr += count; pos += count;
}
}
......@@ -257,19 +257,19 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
// now convert data from buffer into rgba
// first red, then green, then blue, then exponent (alpha)
l = scanline_width; //scanline_buffer.byteLength;
for (i=0; i<l; i++) {
for (i = 0; i < l; i ++) {
off = 0;
data_rgba[offset] = scanline_buffer[i+off];
data_rgba[offset] = scanline_buffer[i + off];
off += scanline_width; //1;
data_rgba[offset+1] = scanline_buffer[i+off];
data_rgba[offset + 1] = scanline_buffer[i + off];
off += scanline_width; //1;
data_rgba[offset+2] = scanline_buffer[i+off];
data_rgba[offset + 2] = scanline_buffer[i + off];
off += scanline_width; //1;
data_rgba[offset+3] = scanline_buffer[i+off];
data_rgba[offset + 3] = scanline_buffer[i + off];
offset += 4;
}
num_scanlines--;
num_scanlines --;
}
return data_rgba;
......
......@@ -59,7 +59,7 @@ THREE.STLLoader.prototype = {
var expect, face_size, n_faces, reader;
reader = new DataView( binData );
face_size = (32 / 8 * 3) + ((32 / 8 * 3) * 3) + (16 / 8);
n_faces = reader.getUint32(80,true);
n_faces = reader.getUint32(80, true);
expect = 80 + (32 / 8) + (n_faces * face_size);
if ( expect === reader.byteLength ) {
......@@ -110,15 +110,15 @@ THREE.STLLoader.prototype = {
(reader.getUint8(index + 4) == 0x52 /*'R'*/) &&
(reader.getUint8(index + 5) == 0x3D /*'='*/)) {
hasColors = true;
colors = new Float32Array( faces * 3 * 3);
hasColors = true;
colors = new Float32Array( faces * 3 * 3);
defaultR = reader.getUint8(index + 6) / 255;
defaultG = reader.getUint8(index + 7) / 255;
defaultB = reader.getUint8(index + 8) / 255;
alpha = reader.getUint8(index + 9) / 255;
}
defaultR = reader.getUint8(index + 6) / 255;
defaultG = reader.getUint8(index + 7) / 255;
defaultB = reader.getUint8(index + 8) / 255;
alpha = reader.getUint8(index + 9) / 255;
}
}
var dataOffset = 84;
var faceLength = 12 * 4 + 2;
......@@ -231,10 +231,10 @@ THREE.STLLoader.prototype = {
ensureString: function ( buf ) {
if (typeof buf !== "string"){
if (typeof buf !== "string") {
var array_buffer = new Uint8Array(buf);
var str = '';
for(var i = 0; i < buf.byteLength; i++) {
for (var i = 0; i < buf.byteLength; i ++) {
str += String.fromCharCode(array_buffer[i]); // implicitly assumes little-endian
}
return str;
......@@ -246,9 +246,9 @@ THREE.STLLoader.prototype = {
ensureBinary: function ( buf ) {
if (typeof buf === "string"){
if (typeof buf === "string") {
var array_buffer = new Uint8Array(buf.length);
for(var i = 0; i < buf.length; i++) {
for (var i = 0; i < buf.length; i ++) {
array_buffer[i] = buf.charCodeAt(i) & 0xff; // implicitly assumes little-endian
}
return array_buffer.buffer || array_buffer;
......@@ -260,9 +260,9 @@ THREE.STLLoader.prototype = {
};
if ( typeof DataView === 'undefined'){
if ( typeof DataView === 'undefined') {
DataView = function(buffer, byteOffset, byteLength){
DataView = function(buffer, byteOffset, byteLength) {
this.buffer = buffer;
this.byteOffset = byteOffset || 0;
......@@ -273,12 +273,12 @@ if ( typeof DataView === 'undefined'){
DataView.prototype = {
_getCharCodes:function(buffer,start,length){
_getCharCodes:function(buffer,start,length) {
start = start || 0;
length = length || buffer.length;
var end = start + length;
var codes = [];
for (var i = start; i < end; i++) {
for (var i = start; i < end; i ++) {
codes.push(buffer.charCodeAt(i) & 0xff);
}
return codes;
......@@ -325,7 +325,7 @@ if ( typeof DataView === 'undefined'){
}
if (this.isString){
if (this.isString) {
result = this._getCharCodes(this.buffer, byteOffset, byteOffset + length);
......
......@@ -57,7 +57,7 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
function tgaCheckHeader( header ) {
switch( header.image_type ) {
switch ( header.image_type ) {
// Check indexed type
case TGA_TYPE_INDEXED:
......@@ -83,12 +83,12 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
// Invalid type ?
default:
console.error('THREE.TGALoader.parse.tgaCheckHeader: Invalid type " '+ header.image_type + '"');
console.error('THREE.TGALoader.parse.tgaCheckHeader: Invalid type " ' + header.image_type + '"');
}
// Check image width and height
if ( header.width <= 0 || header.height <=0 ) {
if ( header.width <= 0 || header.height <= 0 ) {
console.error( 'THREE.TGALoader.parse.tgaCheckHeader: Invalid image size' );
}
......@@ -154,8 +154,8 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
pixel_total,
palettes;
pixel_size = header.pixel_size >> 3;
pixel_total = header.width * header.height * pixel_size;
pixel_size = header.pixel_size >> 3;
pixel_total = header.width * header.height * pixel_size;
// Read palettes
if ( use_pal ) {
......@@ -171,19 +171,19 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
var pixels = new Uint8Array(pixel_size);
while (shift < pixel_total) {
c = data[offset++];
c = data[offset ++];
count = (c & 0x7f) + 1;
// RLE pixels.
if (c & 0x80) {
// Bind pixel tmp array
for (i = 0; i < pixel_size; ++i) {
pixels[i] = data[offset++];
for (i = 0; i < pixel_size; ++ i) {
pixels[i] = data[offset ++];
}
// Copy pixel array
for (i = 0; i < count; ++i) {
pixel_data.set(pixels, shift + i * pixel_size);
for (i = 0; i < count; ++ i) {
pixel_data.set(pixels, shift + i * pixel_size);
}
shift += pixel_size * count;
......@@ -191,8 +191,8 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
} else {
// Raw pixels.
count *= pixel_size;
for (i = 0; i < count; ++i) {
pixel_data[shift + i] = data[offset++];
for (i = 0; i < count; ++ i) {
pixel_data[shift + i] = data[offset ++];
}
shift += count;
}
......@@ -214,10 +214,10 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
var colormap = palettes;
var color, i = 0, x, y;
var width = header.width;
var width = header.width;
for (y = y_start; y !== y_end; y += y_step) {
for (x = x_start; x !== x_end; x += x_step, i++) {
for (x = x_start; x !== x_end; x += x_step, i ++) {
color = image[i];
imageData[(x + width * y) * 4 + 3] = 255;
imageData[(x + width * y) * 4 + 2] = colormap[(color * 3) + 0];
......@@ -291,7 +291,7 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
var width = header.width;
for (y = y_start; y !== y_end; y += y_step) {
for (x = x_start; x !== x_end; x += x_step, i++) {
for (x = x_start; x !== x_end; x += x_step, i ++) {
color = image[i];
imageData[(x + width * y) * 4 + 0] = color;
imageData[(x + width * y) * 4 + 1] = color;
......@@ -332,7 +332,7 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
y_end,
data = new Uint8Array(width * height * 4);
switch( (header.flags & TGA_ORIGIN_MASK) >> TGA_ORIGIN_SHIFT ) {
switch ( (header.flags & TGA_ORIGIN_MASK) >> TGA_ORIGIN_SHIFT ) {
default:
case TGA_ORIGIN_UL:
x_start = 0;
......@@ -374,7 +374,7 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
if ( use_grey ) {
switch( header.pixel_size ) {
switch ( header.pixel_size ) {
case 8:
tgaGetImageDataGrey8bits( data, y_start, y_step, y_end, x_start, x_step, x_end, image );
break;
......@@ -388,7 +388,7 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
} else {
switch( header.pixel_size ) {
switch ( header.pixel_size ) {
case 8:
tgaGetImageData8bits( data, y_start, y_step, y_end, x_start, x_step, x_end, image, palette );
break;
......
此差异已折叠。
此差异已折叠。
......@@ -126,7 +126,7 @@ THREE.CTMLoader.prototype.load = function( url, callback, parameters ) {
scope.createModel( ctmFile, callback );
var e = Date.now();
console.log( "model load time [worker]: " + (e-e1) + " ms, total: " + (e-s));
console.log( "model load time [worker]: " + (e - e1) + " ms, total: " + (e - s));
}
......
此差异已折叠。
此差异已折叠。
......@@ -430,7 +430,7 @@ THREE.SceneLoader.prototype = {
} else if ( objJSON.target ) {
camera.lookAt( new THREE.Vector3().fromArray( objJSON.target ) );
camera.lookAt( new THREE.Vector3().fromArray( objJSON.target ) );
}
......@@ -891,7 +891,7 @@ THREE.SceneLoader.prototype = {
counter_textures += textureJSON.url.length;
for( var n = 0; n < textureJSON.url.length; n ++ ) {
for ( var n = 0; n < textureJSON.url.length; n ++ ) {
scope.onLoadStart();
......
......@@ -24,7 +24,7 @@ THREE.glTFAnimator = ( function () {
update : function()
{
for (i = 0; i < animators.length; i++)
for (i = 0; i < animators.length; i ++)
{
animators[i].update();
}
......@@ -50,7 +50,7 @@ THREE.glTFAnimation = function(interps)
THREE.glTFAnimation.prototype.createInterpolators = function(interps)
{
var i, len = interps.length;
for (i = 0; i < len; i++)
for (i = 0; i < len; i ++)
{
var interp = new THREE.glTFInterpolator(interps[i]);
this.interps.push(interp);
......@@ -90,7 +90,7 @@ THREE.glTFAnimation.prototype.update = function()
{
this.running = false;
var i, len = this.interps.length;
for (i = 0; i < len; i++)
for (i = 0; i < len; i ++)
{
this.interps[i].interp(this.duration);
}
......@@ -100,7 +100,7 @@ THREE.glTFAnimation.prototype.update = function()
else
{
var i, len = this.interps.length;
for (i = 0; i < len; i++)
for (i = 0; i < len; i ++)
{
this.interps[i].interp(t);
}
......@@ -202,7 +202,7 @@ THREE.glTFInterpolator.prototype.interp = function(t)
}
else
{
for (i = 0; i < this.count - 1; i++)
for (i = 0; i < this.count - 1; i ++)
{
var key1 = this.keys[i];
var key2 = this.keys[i + 1];
......
此差异已折叠。
......@@ -11,7 +11,7 @@ THREE.AdaptiveToneMappingPass = function ( adaptive, resolution ) {
this.resolution = ( resolution !== undefined ) ? resolution : 256;
this.needsInit = true;
this.adaptive = adaptive !== undefined? !!adaptive : true;
this.adaptive = adaptive !== undefined ? !!adaptive : true;
this.luminanceRT = null;
this.previousLuminanceRT = null;
......@@ -190,7 +190,7 @@ THREE.AdaptiveToneMappingPass.prototype = {
this.materialToneMap.uniforms.luminanceMap.value = this.luminanceRT;
}
//Put something in the adaptive luminance texture so that the scene can render initially
this.quad.material = new THREE.MeshBasicMaterial( {color: 0x777777 });
this.quad.material = new THREE.MeshBasicMaterial( { color: 0x777777 });
this.materialLuminance.needsUpdate = true;
this.materialAdaptiveLum.needsUpdate = true;
this.materialToneMap.needsUpdate = true;
......
......@@ -68,7 +68,7 @@ THREE.SVGRenderer = function () {
this.setQuality = function( quality ) {
switch(quality) {
switch (quality) {
case "high": _quality = 1; break;
case "low": _quality = 0; break;
......@@ -215,7 +215,7 @@ THREE.SVGRenderer = function () {
var x = _vector3.x * _svgWidthHalf;
var y = - _vector3.y * _svgHeightHalf;
var node = object.node;
var node = object.node;
node.setAttribute( 'transform', 'translate(' + x + ',' + y + ')' );
_svg.appendChild( node );
......@@ -232,7 +232,7 @@ THREE.SVGRenderer = function () {
_directionalLights.setRGB( 0, 0, 0 );
_pointLights.setRGB( 0, 0, 0 );
for ( var l = 0, ll = lights.length; l < ll; l++ ) {
for ( var l = 0, ll = lights.length; l < ll; l ++ ) {
var light = lights[ l ];
var lightColor = light.color;
......
......@@ -44,7 +44,7 @@ THREE.BokehShader = {
"pentagon": { type: "i", value: 0 },
"shaderFocus": { type: "i", value: 1 },
"focusCoords": { type: "v2", value: new THREE.Vector2()},
"focusCoords": { type: "v2", value: new THREE.Vector2() },
},
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册