From 305f2df452f5e466e5efbfa11a5b3a71db160f58 Mon Sep 17 00:00:00 2001 From: Joshua Koo Date: Tue, 13 May 2014 10:00:05 +0800 Subject: [PATCH 1/4] First round at attempt to code transform codebase git reset --hard codepainter xform -j ../utils/codestyle/mrdoob_codepainter.json "*/*.js" find ./ -type f -exec sed -i -e 's/( )/()/g;s/\[ \]/[]/g;s#{[ ]}#\{\}#g' {} \; find . -name "*.js-e*" -print0 | xargs -0 rm git add -p --- src/cameras/Camera.js | 2 +- src/cameras/OrthographicCamera.js | 2 +- src/core/BufferGeometry.js | 108 +- src/core/EventDispatcher.js | 2 +- src/core/Face3.js | 12 +- src/core/Face4.js | 2 +- src/core/Geometry.js | 6 +- src/core/Object3D.js | 4 +- src/core/Projector.js | 12 +- src/extras/FontUtils.js | 64 +- src/extras/ImageUtils.js | 364 +++---- src/extras/curves/ArcCurve.js | 2 +- src/extras/curves/ClosedSplineCurve3.js | 2 +- src/extras/curves/CubicBezierCurve.js | 2 +- src/extras/curves/CubicBezierCurve3.js | 2 +- src/extras/curves/LineCurve.js | 2 +- src/extras/curves/QuadraticBezierCurve.js | 2 +- src/extras/curves/QuadraticBezierCurve3.js | 2 +- src/extras/curves/SplineCurve.js | 2 +- src/extras/curves/SplineCurve3.js | 2 +- src/lights/Light.js | 2 +- src/loaders/BufferGeometryLoader.js | 142 +-- src/loaders/Cache.js | 82 +- src/loaders/JSONLoader.js | 1082 ++++++++++---------- src/loaders/Loader.js | 888 ++++++++-------- src/loaders/MaterialLoader.js | 126 +-- src/loaders/SVGLoader.js | 56 +- src/materials/Material.js | 6 +- src/materials/ShaderMaterial.js | 10 +- src/materials/SpriteCanvasMaterial.js | 2 +- src/math/Box3.js | 30 +- src/math/Color.js | 48 +- src/math/Euler.js | 6 +- src/math/Frustum.js | 42 +- src/math/Math.js | 38 +- src/math/Matrix3.js | 88 +- src/math/Matrix4.js | 506 ++++----- src/math/Plane.js | 14 +- src/math/Quaternion.js | 24 +- src/math/Ray.js | 66 +- src/math/Spline.js | 4 +- src/math/Triangle.js | 18 +- src/math/Vector2.js | 8 +- src/math/Vector3.js | 40 +- src/math/Vector4.js | 26 +- src/objects/Bone.js | 2 +- src/objects/LOD.js | 6 +- src/objects/Line.js | 2 +- src/objects/Mesh.js | 4 +- src/objects/MorphAnimMesh.js | 2 +- src/objects/Skeleton.js | 10 +- src/renderers/CanvasRenderer.js | 4 +- src/renderers/WebGLRenderer.js | 10 +- src/renderers/shaders/UniformsLib.js | 2 +- src/renderers/shaders/UniformsUtils.js | 2 +- src/renderers/webgl/WebGLShader.js | 2 +- src/scenes/Scene.js | 2 +- src/textures/Texture.js | 2 +- 58 files changed, 2000 insertions(+), 2000 deletions(-) diff --git a/src/cameras/Camera.js b/src/cameras/Camera.js index e93d77ec4c3fb..488a5fc358a61 100644 --- a/src/cameras/Camera.js +++ b/src/cameras/Camera.js @@ -31,7 +31,7 @@ THREE.Camera.prototype.lookAt = function () { }(); -THREE.Camera.prototype.clone = function (camera) { +THREE.Camera.prototype.clone = function ( camera ) { if ( camera === undefined ) camera = new THREE.Camera(); diff --git a/src/cameras/OrthographicCamera.js b/src/cameras/OrthographicCamera.js index 0c9f3ebb72640..fc818dfa34681 100644 --- a/src/cameras/OrthographicCamera.js +++ b/src/cameras/OrthographicCamera.js @@ -36,7 +36,7 @@ THREE.OrthographicCamera.prototype.clone = function () { camera.right = this.right; camera.top = this.top; camera.bottom = this.bottom; - + camera.near = this.near; camera.far = this.far; diff --git a/src/core/BufferGeometry.js b/src/core/BufferGeometry.js index dd26f856504d6..367050634a911 100644 --- a/src/core/BufferGeometry.js +++ b/src/core/BufferGeometry.js @@ -88,13 +88,13 @@ THREE.BufferGeometry.prototype = { } - var positions = this.attributes[ "position" ].array; + var positions = this.attributes[ 'position' ].array; if ( positions ) { var bb = this.boundingBox; - if( positions.length >= 3 ) { + if ( positions.length >= 3 ) { bb.min.x = bb.max.x = positions[ 0 ]; bb.min.y = bb.max.y = positions[ 1 ]; bb.min.z = bb.max.z = positions[ 2 ]; @@ -571,19 +571,19 @@ THREE.BufferGeometry.prototype = { WARNING: This method will also expand the vertex count to prevent sprawled triangles across draw offsets. indexBufferSize - Defaults to 65535, but allows for larger or smaller chunks. */ - computeOffsets: function(indexBufferSize) { + computeOffsets: function ( indexBufferSize ) { var size = indexBufferSize; - if(indexBufferSize === undefined) + if ( indexBufferSize === undefined ) size = 65535; //WebGL limits type of index buffer values to 16-bit. var s = Date.now(); - var indices = this.attributes['index'].array; - var vertices = this.attributes['position'].array; + var indices = this.attributes[ 'index' ].array; + var vertices = this.attributes[ 'position' ].array; - var verticesCount = (vertices.length/3); - var facesCount = (indices.length/3); + var verticesCount = ( vertices.length / 3 ); + var facesCount = ( indices.length / 3 ); /* console.log("Computing buffers in offsets of "+size+" -> indices:"+indices.length+" vertices:"+vertices.length); @@ -596,72 +596,72 @@ THREE.BufferGeometry.prototype = { var vertexPtr = 0; var offsets = [ { start:0, count:0, index:0 } ]; - var offset = offsets[0]; + var offset = offsets[ 0 ]; var duplicatedVertices = 0; var newVerticeMaps = 0; - var faceVertices = new Int32Array(6); + var faceVertices = new Int32Array( 6 ); var vertexMap = new Int32Array( vertices.length ); var revVertexMap = new Int32Array( vertices.length ); - for(var j = 0; j < vertices.length; j++) { vertexMap[j] = -1; revVertexMap[j] = -1; } + for ( var j = 0; j < vertices.length; j++ ) { vertexMap[ j ] = -1; revVertexMap[ j ] = -1; } /* Traverse every face and reorder vertices in the proper offsets of 65k. We can have more than 65k entries in the index buffer per offset, but only reference 65k values. */ - for(var findex = 0; findex < facesCount; findex++) { + for ( var findex = 0; findex < facesCount; findex++ ) { newVerticeMaps = 0; - for(var vo = 0; vo < 3; vo++) { - var vid = indices[ findex*3 + vo ]; - if(vertexMap[vid] == -1) { + for ( var vo = 0; vo < 3; vo++ ) { + var vid = indices[ findex * 3 + vo ]; + if ( vertexMap[ vid ] == -1 ) { //Unmapped vertice - faceVertices[vo*2] = vid; - faceVertices[vo*2+1] = -1; + faceVertices[ vo * 2 ] = vid; + faceVertices[ vo * 2 + 1 ] = -1; newVerticeMaps++; - } else if(vertexMap[vid] < offset.index) { + } else if ( vertexMap[ vid ] < offset.index ) { //Reused vertices from previous block (duplicate) - faceVertices[vo*2] = vid; - faceVertices[vo*2+1] = -1; + faceVertices[ vo * 2 ] = vid; + faceVertices[ vo * 2 + 1 ] = -1; duplicatedVertices++; } else { //Reused vertice in the current block - faceVertices[vo*2] = vid; - faceVertices[vo*2+1] = vertexMap[vid]; + faceVertices[ vo * 2 ] = vid; + faceVertices[ vo * 2 + 1 ] = vertexMap[ vid ]; } } var faceMax = vertexPtr + newVerticeMaps; - if(faceMax > (offset.index + size)) { + if ( faceMax > ( offset.index + size ) ) { var new_offset = { start:indexPtr, count:0, index:vertexPtr }; - offsets.push(new_offset); + offsets.push( new_offset ); offset = new_offset; //Re-evaluate reused vertices in light of new offset. - for(var v = 0; v < 6; v+=2) { - var new_vid = faceVertices[v+1]; - if(new_vid > -1 && new_vid < offset.index) - faceVertices[v+1] = -1; + for ( var v = 0; v < 6; v += 2 ) { + var new_vid = faceVertices[ v + 1 ]; + if ( new_vid > -1 && new_vid < offset.index ) + faceVertices[ v + 1 ] = -1; } } //Reindex the face. - for(var v = 0; v < 6; v+=2) { - var vid = faceVertices[v]; - var new_vid = faceVertices[v+1]; + for ( var v = 0; v < 6; v += 2 ) { + var vid = faceVertices[ v ]; + var new_vid = faceVertices[ v + 1 ]; - if(new_vid === -1) + if ( new_vid === -1 ) new_vid = vertexPtr++; - vertexMap[vid] = new_vid; - revVertexMap[new_vid] = vid; - sortedIndices[indexPtr++] = new_vid - offset.index; //XXX overflows at 16bit + vertexMap[ vid ] = new_vid; + revVertexMap[ new_vid ] = vid; + sortedIndices[ indexPtr++ ] = new_vid - offset.index; //XXX overflows at 16bit offset.count++; } } /* Move all attribute values to map to the new computed indices , also expand the vertice stack to match our new vertexPtr. */ - this.reorderBuffers(sortedIndices, revVertexMap, vertexPtr); + this.reorderBuffers( sortedIndices, revVertexMap, vertexPtr ); this.offsets = offsets; /* @@ -710,45 +710,45 @@ THREE.BufferGeometry.prototype = { indexMap - Int32Array where the position is the new vertex ID and the value the old vertex ID for each vertex. vertexCount - Amount of total vertices considered in this reordering (in case you want to grow the vertice stack). */ - reorderBuffers: function(indexBuffer, indexMap, vertexCount) { + reorderBuffers: function ( indexBuffer, indexMap, vertexCount ) { /* Create a copy of all attributes for reordering. */ var sortedAttributes = {}; var types = [ Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array ]; - for( var attr in this.attributes ) { - if(attr == 'index') + for ( var attr in this.attributes ) { + if ( attr == 'index' ) continue; - var sourceArray = this.attributes[attr].array; + var sourceArray = this.attributes[ attr ].array; for ( var i = 0, il = types.length; i < il; i++ ) { - var type = types[i]; - if (sourceArray instanceof type) { - sortedAttributes[attr] = new type( this.attributes[attr].itemSize * vertexCount ); + var type = types[ i ]; + if ( sourceArray instanceof type ) { + sortedAttributes[ attr ] = new type( this.attributes[ attr ].itemSize * vertexCount ); break; } } } /* Move attribute positions based on the new index map */ - for(var new_vid = 0; new_vid < vertexCount; new_vid++) { - var vid = indexMap[new_vid]; + for ( var new_vid = 0; new_vid < vertexCount; new_vid++ ) { + var vid = indexMap[ new_vid ]; for ( var attr in this.attributes ) { - if(attr == 'index') + if ( attr == 'index' ) continue; - var attrArray = this.attributes[attr].array; - var attrSize = this.attributes[attr].itemSize; - var sortedAttr = sortedAttributes[attr]; - for(var k = 0; k < attrSize; k++) + var attrArray = this.attributes[ attr ].array; + var attrSize = this.attributes[ attr ].itemSize; + var sortedAttr = sortedAttributes[ attr ]; + for ( var k = 0; k < attrSize; k++ ) sortedAttr[ new_vid * attrSize + k ] = attrArray[ vid * attrSize + k ]; } } /* Carry the new sorted buffers locally */ - this.attributes['index'].array = indexBuffer; + this.attributes[ 'index' ].array = indexBuffer; for ( var attr in this.attributes ) { - if(attr == 'index') + if ( attr == 'index' ) continue; - this.attributes[attr].array = sortedAttributes[attr]; - this.attributes[attr].numItems = this.attributes[attr].itemSize * vertexCount; + this.attributes[ attr ].array = sortedAttributes[ attr ]; + this.attributes[ attr ].numItems = this.attributes[ attr ].itemSize * vertexCount; } }, diff --git a/src/core/EventDispatcher.js b/src/core/EventDispatcher.js index 128cc5a26646f..46829639d6f72 100644 --- a/src/core/EventDispatcher.js +++ b/src/core/EventDispatcher.js @@ -75,7 +75,7 @@ THREE.EventDispatcher.prototype = { }, dispatchEvent: function ( event ) { - + if ( this._listeners === undefined ) return; var listeners = this._listeners; diff --git a/src/core/Face3.js b/src/core/Face3.js index f063476c68875..bdf8bda329c9b 100644 --- a/src/core/Face3.js +++ b/src/core/Face3.js @@ -35,21 +35,21 @@ THREE.Face3.prototype = { face.materialIndex = this.materialIndex; for ( var i = 0, il = this.vertexNormals.length; i < il; i ++ ) { - + face.vertexNormals[ i ] = this.vertexNormals[ i ].clone(); - + } for ( var i = 0, il = this.vertexColors.length; i < il; i ++ ) { - + face.vertexColors[ i ] = this.vertexColors[ i ].clone(); - + } for ( var i = 0, il = this.vertexTangents.length; i < il; i ++ ) { - + face.vertexTangents[ i ] = this.vertexTangents[ i ].clone(); - + } return face; diff --git a/src/core/Face4.js b/src/core/Face4.js index cefbf8bc7007d..ee2b05556d48e 100644 --- a/src/core/Face4.js +++ b/src/core/Face4.js @@ -4,7 +4,7 @@ THREE.Face4 = function ( a, b, c, d, normal, color, materialIndex ) { - console.warn( 'THREE.Face4 has been removed. A THREE.Face3 will be created instead.') + console.warn( 'THREE.Face4 has been removed. A THREE.Face3 will be created instead.' ) return new THREE.Face3( a, b, c, normal, color, materialIndex ); }; diff --git a/src/core/Geometry.js b/src/core/Geometry.js index 16058f3af2a4a..8fc94592b6128 100644 --- a/src/core/Geometry.js +++ b/src/core/Geometry.js @@ -19,7 +19,7 @@ THREE.Geometry = function () { this.faces = []; - this.faceVertexUvs = [[]]; + this.faceVertexUvs = [ [] ]; this.morphTargets = []; this.morphColors = []; @@ -398,7 +398,7 @@ THREE.Geometry.prototype = { tmp2.crossVectors( face.vertexNormals[ i ], t ); test = tmp2.dot( tan2[ vertexIndex ] ); - w = (test < 0.0) ? -1.0 : 1.0; + w = ( test < 0.0 ) ? -1.0 : 1.0; face.vertexTangents[ i ] = new THREE.Vector4( tmp.x, tmp.y, tmp.z, w ); @@ -606,7 +606,7 @@ THREE.Geometry.prototype = { // have to remove them from the geometry. var faceIndicesToRemove = []; - for( i = 0, il = this.faces.length; i < il; i ++ ) { + for ( i = 0, il = this.faces.length; i < il; i ++ ) { face = this.faces[ i ]; diff --git a/src/core/Object3D.js b/src/core/Object3D.js index 4dc8fbe16735c..f6fa6810d3b5a 100644 --- a/src/core/Object3D.js +++ b/src/core/Object3D.js @@ -168,7 +168,7 @@ THREE.Object3D.prototype = { }, - rotateOnAxis: function() { + rotateOnAxis: function () { // rotate object on axis in object space // axis is assumed to be normalized @@ -325,7 +325,7 @@ THREE.Object3D.prototype = { if ( object === this ) { - console.warn( 'THREE.Object3D.add: An object can\'t be added as a child of itself.' ); + console.warn( "THREE.Object3D.add: An object can't be added as a child of itself." ); return; } diff --git a/src/core/Projector.js b/src/core/Projector.js index ae52777646eb1..ebcbc7151478f 100644 --- a/src/core/Projector.js +++ b/src/core/Projector.js @@ -657,7 +657,7 @@ THREE.Projector = function () { } else if ( object instanceof THREE.Sprite ) { - _vector4.set( _modelMatrix.elements[12], _modelMatrix.elements[13], _modelMatrix.elements[14], 1 ); + _vector4.set( _modelMatrix.elements[ 12 ], _modelMatrix.elements[ 13 ], _modelMatrix.elements[ 14 ], 1 ); _vector4.applyMatrix4( _viewProjectionMatrix ); var invW = 1 / _vector4.w; @@ -675,8 +675,8 @@ THREE.Projector = function () { _sprite.rotation = object.rotation; - _sprite.scale.x = object.scale.x * Math.abs( _sprite.x - ( _vector4.x + camera.projectionMatrix.elements[0] ) / ( _vector4.w + camera.projectionMatrix.elements[12] ) ); - _sprite.scale.y = object.scale.y * Math.abs( _sprite.y - ( _vector4.y + camera.projectionMatrix.elements[5] ) / ( _vector4.w + camera.projectionMatrix.elements[13] ) ); + _sprite.scale.x = object.scale.x * Math.abs( _sprite.x - ( _vector4.x + camera.projectionMatrix.elements[ 0 ] ) / ( _vector4.w + camera.projectionMatrix.elements[ 12 ] ) ); + _sprite.scale.y = object.scale.y * Math.abs( _sprite.y - ( _vector4.y + camera.projectionMatrix.elements[ 5 ] ) / ( _vector4.w + camera.projectionMatrix.elements[ 13 ] ) ); _sprite.material = object.material; @@ -805,15 +805,15 @@ THREE.Projector = function () { // Z = -1 and Z = +1, respectively. bc1near = s1.z + s1.w, bc2near = s2.z + s2.w, - bc1far = - s1.z + s1.w, - bc2far = - s2.z + s2.w; + bc1far = -s1.z + s1.w, + bc2far = -s2.z + s2.w; if ( bc1near >= 0 && bc2near >= 0 && bc1far >= 0 && bc2far >= 0 ) { // Both vertices lie entirely within all clip planes. return true; - } else if ( ( bc1near < 0 && bc2near < 0) || (bc1far < 0 && bc2far < 0 ) ) { + } else if ( ( bc1near < 0 && bc2near < 0 ) || ( bc1far < 0 && bc2far < 0 ) ) { // Both vertices lie entirely outside one of the clip planes. return false; diff --git a/src/extras/FontUtils.js b/src/extras/FontUtils.js index b57848b0e0107..aec97aab10089 100644 --- a/src/extras/FontUtils.js +++ b/src/extras/FontUtils.js @@ -21,23 +21,23 @@ THREE.FontUtils = { - faces : {}, + faces: {}, // Just for now. face[weight][style] - face : "helvetiker", - weight: "normal", - style : "normal", - size : 150, - divisions : 10, + face: 'helvetiker', + weight: 'normal', + style: 'normal', + size: 150, + divisions: 10, - getFace : function() { + getFace: function () { return this.faces[ this.face ][ this.weight ][ this.style ]; }, - loadFace : function( data ) { + loadFace: function ( data ) { var family = data.familyName.toLowerCase(); @@ -130,7 +130,7 @@ THREE.FontUtils = { //console.log( action ); - switch( action ) { + switch ( action ) { case 'm': @@ -148,7 +148,7 @@ THREE.FontUtils = { x = outline[ i++ ] * scaleX + offset; y = outline[ i++ ] * scaleY; - path.lineTo(x,y); + path.lineTo( x,y ); break; case 'q': @@ -160,7 +160,7 @@ THREE.FontUtils = { cpx1 = outline[ i++ ] * scaleX + offset; cpy1 = outline[ i++ ] * scaleY; - path.quadraticCurveTo(cpx1, cpy1, cpx, cpy); + path.quadraticCurveTo( cpx1, cpy1, cpx, cpy ); laste = pts[ pts.length - 1 ]; @@ -219,24 +219,24 @@ THREE.FontUtils = { - return { offset: glyph.ha*scale, path:path}; + return { offset: glyph.ha * scale, path:path }; } }; -THREE.FontUtils.generateShapes = function( text, parameters ) { +THREE.FontUtils.generateShapes = function ( text, parameters ) { // Parameters parameters = parameters || {}; var size = parameters.size !== undefined ? parameters.size : 100; - var curveSegments = parameters.curveSegments !== undefined ? parameters.curveSegments: 4; + var curveSegments = parameters.curveSegments !== undefined ? parameters.curveSegments : 4; - var font = parameters.font !== undefined ? parameters.font : "helvetiker"; - var weight = parameters.weight !== undefined ? parameters.weight : "normal"; - var style = parameters.style !== undefined ? parameters.style : "normal"; + var font = parameters.font !== undefined ? parameters.font : 'helvetiker'; + var weight = parameters.weight !== undefined ? parameters.weight : 'normal'; + var style = parameters.style !== undefined ? parameters.style : 'normal'; THREE.FontUtils.size = size; THREE.FontUtils.divisions = curveSegments; @@ -278,13 +278,13 @@ THREE.FontUtils.generateShapes = function( text, parameters ) { */ -( function( namespace ) { +( function ( namespace ) { var EPSILON = 0.0000000001; // takes in an contour array and returns - var process = function( contour, indices ) { + var process = function ( contour, indices ) { var n = contour.length; @@ -314,7 +314,7 @@ THREE.FontUtils.generateShapes = function( text, parameters ) { var count = 2 * nv; /* error detection */ - for( v = nv - 1; nv > 2; ) { + for ( v = nv - 1; nv > 2; ) { /* if we loop, it is probably a non-simple polygon */ @@ -325,7 +325,7 @@ THREE.FontUtils.generateShapes = function( text, parameters ) { //throw ( "Warning, unable to triangulate polygon!" ); //return null; // Sometimes warning is fine, especially polygons are triangulated in reverse. - console.log( "Warning, unable to triangulate polygon!" ); + console.log( 'Warning, unable to triangulate polygon!' ); if ( indices ) return vertIndices; return result; @@ -359,7 +359,7 @@ THREE.FontUtils.generateShapes = function( text, parameters ) { /* remove v from the remaining polygon */ - for( s = v, t = v + 1; t < nv; s++, t++ ) { + for ( s = v, t = v + 1; t < nv; s++, t++ ) { verts[ s ] = verts[ t ]; @@ -387,7 +387,7 @@ THREE.FontUtils.generateShapes = function( text, parameters ) { var n = contour.length; var a = 0.0; - for( var p = n - 1, q = 0; q < n; p = q++ ) { + for ( var p = n - 1, q = 0; q < n; p = q++ ) { a += contour[ p ].x * contour[ q ].y - contour[ q ].x * contour[ p ].y; @@ -412,7 +412,7 @@ THREE.FontUtils.generateShapes = function( text, parameters ) { cx = contour[ verts[ w ] ].x; cy = contour[ verts[ w ] ].y; - if ( EPSILON > (((bx-ax)*(cy-ay)) - ((by-ay)*(cx-ax))) ) return false; + if ( EPSILON > ( ( ( bx - ax ) * ( cy - ay ) ) - ( ( by - ay ) * ( cx - ax ) ) ) ) return false; var aX, aY, bX, bY, cX, cY; var apx, apy, bpx, bpy, cpx, cpy; @@ -427,9 +427,9 @@ THREE.FontUtils.generateShapes = function( text, parameters ) { px = contour[ verts[ p ] ].x py = contour[ verts[ p ] ].y - if ( ( (px === ax) && (py === ay) ) || - ( (px === bx) && (py === by) ) || - ( (px === cx) && (py === cy) ) ) continue; + if ( ( ( px === ax ) && ( py === ay ) ) || + ( ( px === bx ) && ( py === by ) ) || + ( ( px === cx ) && ( py === cy ) ) ) continue; apx = px - ax; apy = py - ay; bpx = px - bx; bpy = py - by; @@ -437,11 +437,11 @@ THREE.FontUtils.generateShapes = function( text, parameters ) { // see if p is inside triangle abc - aCROSSbp = aX*bpy - aY*bpx; - cCROSSap = cX*apy - cY*apx; - bCROSScp = bX*cpy - bY*cpx; + aCROSSbp = aX * bpy - aY * bpx; + cCROSSap = cX * apy - cY * apx; + bCROSScp = bX * cpy - bY * cpx; - if ( (aCROSSbp >= -EPSILON) && (bCROSScp >= -EPSILON) && (cCROSSap >= -EPSILON) ) return false; + if ( ( aCROSSbp >= -EPSILON ) && ( bCROSScp >= -EPSILON ) && ( cCROSSap >= -EPSILON ) ) return false; } @@ -455,7 +455,7 @@ THREE.FontUtils.generateShapes = function( text, parameters ) { return namespace; -})(THREE.FontUtils); +} )( THREE.FontUtils ); // To use the typeface.js face files, hook up the API self._typeface_js = { faces: THREE.FontUtils.faces, loadFace: THREE.FontUtils.loadFace }; diff --git a/src/extras/ImageUtils.js b/src/extras/ImageUtils.js index a9e1bdda81b8d..f15bbefa8e82a 100644 --- a/src/extras/ImageUtils.js +++ b/src/extras/ImageUtils.js @@ -67,7 +67,7 @@ THREE.ImageUtils = { request.onerror = onError; request.open( 'GET', url, true ); - request.responseType = "arraybuffer"; + request.responseType = 'arraybuffer'; request.send( null ); return texture; @@ -93,7 +93,7 @@ THREE.ImageUtils = { for ( var i = 0, il = array.length; i < il; ++ i ) { - var cubeImage = loader.load( array[i], function () { + var cubeImage = loader.load( array[ i ], function () { images.loadCount += 1; @@ -176,7 +176,7 @@ THREE.ImageUtils = { var url = array[ i ]; request.open( 'GET', url, true ); - request.responseType = "arraybuffer"; + request.responseType = 'arraybuffer'; request.send( null ); } @@ -188,7 +188,7 @@ THREE.ImageUtils = { var url = array; var request = new XMLHttpRequest(); - request.onload = function( ) { + request.onload = function () { var buffer = request.response; var dds = THREE.ImageUtils.parseDDS( buffer, true ); @@ -199,7 +199,7 @@ THREE.ImageUtils = { for ( var f = 0; f < faces; f ++ ) { - images[ f ] = { mipmaps : [] }; + images[ f ] = { mipmaps: [] }; for ( var i = 0; i < dds.mipmapCount; i ++ ) { @@ -223,7 +223,7 @@ THREE.ImageUtils = { request.onerror = onError; request.open( 'GET', url, true ); - request.responseType = "arraybuffer"; + request.responseType = 'arraybuffer'; request.send( null ); } @@ -231,11 +231,11 @@ THREE.ImageUtils = { return texture; }, - - + + // reference from vthibault, https://github.com/vthibault/roBrowser/blob/master/src/Loaders/Targa.js decodeTGA: function ( arrayBuffer ) { - + // TGA Constants var TGA_TYPE_NO_DATA = 0, TGA_TYPE_INDEXED = 1, @@ -251,38 +251,38 @@ THREE.ImageUtils = { TGA_ORIGIN_BR = 0x01, TGA_ORIGIN_UL = 0x02, TGA_ORIGIN_UR = 0x03; - - + + if ( arrayBuffer.length < 19 ) console.error( 'ImageUtils::decodeTGA()- Not enough data to contain header.' ); - + var content = new Uint8Array( arrayBuffer ), offset = 0, header = { - id_length: content[ offset++ ], + id_length: content[ offset++ ], colormap_type: content[ offset++ ], - image_type: content[offset++], - colormap_index: content[offset++] | content[offset++] << 8, - colormap_length: content[offset++] | content[offset++] << 8, - colormap_size: content[offset++], + image_type: content[ offset++ ], + colormap_index: content[ offset++ ] | content[ offset++ ] << 8, + colormap_length: content[ offset++ ] | content[ offset++ ] << 8, + colormap_size: content[ offset++ ], origin: [ - content[offset++] | content[offset++] << 8, - content[offset++] | content[offset++] << 8 + content[ offset++ ] | content[ offset++ ] << 8, + content[ offset++ ] | content[ offset++ ] << 8 ], - width: content[offset++] | content[offset++] << 8, - height: content[offset++] | content[offset++] << 8, - pixel_size: content[offset++], - flags: content[offset++] + width: content[ offset++ ] | content[ offset++ ] << 8, + height: content[ offset++ ] | content[ offset++ ] << 8, + pixel_size: content[ offset++ ], + flags: content[ offset++ ] }; - + function tgaCheckHeader( header ) { - switch( header.image_type ) { + switch ( header.image_type ) { // Check indexed type case TGA_TYPE_INDEXED: case TGA_TYPE_RLE_INDEXED: - if ( header.colormap_length > 256 || header.colormap_size !== 24 || header.colormap_type !== 1) { - console.error('Targa::tgaCheckHeader() - Invalid type colormap data for indexed type'); + if ( header.colormap_length > 256 || header.colormap_size !== 24 || header.colormap_type !== 1 ) { + console.error( 'Targa::tgaCheckHeader() - Invalid type colormap data for indexed type' ); } break; @@ -291,31 +291,31 @@ THREE.ImageUtils = { case TGA_TYPE_GREY: case TGA_TYPE_RLE_RGB: case TGA_TYPE_RLE_GREY: - if (header.colormap_type) { - console.error('ImageUtils::tgaCheckHeader() - Invalid type colormap data for colormap type'); + if ( header.colormap_type ) { + console.error( 'ImageUtils::tgaCheckHeader() - Invalid type colormap data for colormap type' ); } break; // What the need of a file without data ? case TGA_TYPE_NO_DATA: - console.error('ImageUtils::tgaCheckHeader() - No data'); + console.error( 'ImageUtils::tgaCheckHeader() - No data' ); // Invalid type ? default: - console.error('ImageUtils::tgaCheckHeader() - Invalid type " '+ header.image_type + '"'); + console.error( 'ImageUtils::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( 'ImageUtils::tgaCheckHeader() - Invalid image size' ); } // Check image pixel size - if (header.pixel_size !== 8 && + if ( header.pixel_size !== 8 && header.pixel_size !== 16 && header.pixel_size !== 24 && - header.pixel_size !== 32) { - console.error('ImageUtils::tgaCheckHeader() - Invalid pixel size "' + header.pixel_size + '"'); + header.pixel_size !== 32 ) { + console.error( 'ImageUtils::tgaCheckHeader() - Invalid pixel size "' + header.pixel_size + '"' ); } } @@ -323,17 +323,17 @@ THREE.ImageUtils = { tgaCheckHeader( header ); if ( header.id_length + offset > arrayBuffer.length ) { - console.error('ImageUtils::load() - No data'); + console.error( 'ImageUtils::load() - No data' ); } // Skip the needn't data offset += header.id_length; // Get targa information about RLE compression and palette - var use_rle = false, - use_pal = false, + var use_rle = false, + use_pal = false, use_grey = false; - + switch ( header.image_type ) { case TGA_TYPE_RLE_INDEXED: use_rle = true; @@ -343,7 +343,7 @@ THREE.ImageUtils = { case TGA_TYPE_INDEXED: use_pal = true; break; - + case TGA_TYPE_RLE_RGB: use_rle = true; break; @@ -360,45 +360,45 @@ THREE.ImageUtils = { use_grey = true; break; } - + // Parse tga image buffer function tgaParse( use_rle, use_pal, header, offset, data ) { - + var pixel_data, pixel_size, pixel_total, palettes; - + pixel_size = header.pixel_size >> 3; pixel_total = header.width * header.height * pixel_size; - + // Read palettes if ( use_pal ) { palettes = data.subarray( offset, offset += header.colormap_length * ( header.colormap_size >> 3 ) ); } - + // Read RLE if ( use_rle ) { - pixel_data = new Uint8Array(pixel_total); - + pixel_data = new Uint8Array( pixel_total ); + var c, count, i; var shift = 0; - var pixels = new Uint8Array(pixel_size); + var pixels = new Uint8Array( pixel_size ); - while (shift < pixel_total) { - c = data[offset++]; - count = (c & 0x7f) + 1; + while ( shift < pixel_total ) { + c = data[ offset++ ]; + count = ( c & 0x7f ) + 1; // RLE pixels. - if (c & 0x80) { + 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; @@ -407,8 +407,8 @@ THREE.ImageUtils = { // Raw pixels. else { 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; } @@ -417,79 +417,79 @@ THREE.ImageUtils = { // RAW Pixels else { pixel_data = data.subarray( - offset, offset += (use_pal ? header.width * header.height : pixel_total) + offset, offset += ( use_pal ? header.width * header.height : pixel_total ) ); } - - return { - pixel_data: pixel_data, - palettes: palettes + + return { + pixel_data: pixel_data, + palettes: palettes }; } - - function tgaGetImageData8bits(imageData, y_start, y_step, y_end, x_start, x_step, x_end + + function tgaGetImageData8bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end , image, palettes ) { - var colormap = palettes; + var colormap = palettes; var color, i = 0, x, y; 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++) { - color = image[i]; - imageData[(x + width * y) * 4 + 3] = 255; - imageData[(x + width * y) * 4 + 2] = colormap[(color * 3) + 0]; - imageData[(x + width * y) * 4 + 1] = colormap[(color * 3) + 1]; - imageData[(x + width * y) * 4 + 0] = colormap[(color * 3) + 2]; + + for ( y = y_start; y !== y_end; y += y_step ) { + 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 ]; + imageData[ ( x + width * y ) * 4 + 1 ] = colormap[ ( color * 3 ) + 1 ]; + imageData[ ( x + width * y ) * 4 + 0 ] = colormap[ ( color * 3 ) + 2 ]; } } return imageData; }; - function tgaGetImageData16bits(imageData, y_start, y_step, y_end, x_start, x_step, x_end - , image) { + function tgaGetImageData16bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end + , image ) { var color, i = 0, x, y; 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 += 2) { - color = image[i + 0] + (image[i + 1] << 8); // Inversed ? - imageData[(x + width * y) * 4 + 0] = (color & 0x7C00) >> 7; - imageData[(x + width * y) * 4 + 1] = (color & 0x03E0) >> 2; - imageData[(x + width * y) * 4 + 2] = (color & 0x001F) >> 3; - imageData[(x + width * y) * 4 + 3] = (color & 0x8000) ? 0 : 255; + for ( y = y_start; y !== y_end; y += y_step ) { + for ( x = x_start; x !== x_end; x += x_step, i += 2 ) { + color = image[ i + 0 ] + ( image[ i + 1 ] << 8 ); // Inversed ? + imageData[ ( x + width * y ) * 4 + 0 ] = ( color & 0x7C00 ) >> 7; + imageData[ ( x + width * y ) * 4 + 1 ] = ( color & 0x03E0 ) >> 2; + imageData[ ( x + width * y ) * 4 + 2 ] = ( color & 0x001F ) >> 3; + imageData[ ( x + width * y ) * 4 + 3 ] = ( color & 0x8000 ) ? 0 : 255; } } return imageData; }; - function tgaGetImageData24bits(imageData, y_start, y_step, y_end, x_start, x_step, x_end, image) { + function tgaGetImageData24bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image ) { var i = 0, x, y; 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 += 3) { - imageData[(x + width * y) * 4 + 3] = 255; - imageData[(x + width * y) * 4 + 2] = image[i + 0]; - imageData[(x + width * y) * 4 + 1] = image[i + 1]; - imageData[(x + width * y) * 4 + 0] = image[i + 2]; + for ( y = y_start; y !== y_end; y += y_step ) { + for ( x = x_start; x !== x_end; x += x_step, i += 3 ) { + imageData[ ( x + width * y ) * 4 + 3 ] = 255; + imageData[ ( x + width * y ) * 4 + 2 ] = image[ i + 0 ]; + imageData[ ( x + width * y ) * 4 + 1 ] = image[ i + 1 ]; + imageData[ ( x + width * y ) * 4 + 0 ] = image[ i + 2 ]; } } return imageData; }; - - function tgaGetImageData32bits(imageData, y_start, y_step, y_end, x_start, x_step, x_end, image) { + + function tgaGetImageData32bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image ) { var i = 0, x, y; 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 += 4) { - imageData[(x + width * y) * 4 + 2] = image[i + 0]; - imageData[(x + width * y) * 4 + 1] = image[i + 1]; - imageData[(x + width * y) * 4 + 0] = image[i + 2]; - imageData[(x + width * y) * 4 + 3] = image[i + 3]; + for ( y = y_start; y !== y_end; y += y_step ) { + for ( x = x_start; x !== x_end; x += x_step, i += 4 ) { + imageData[ ( x + width * y ) * 4 + 2 ] = image[ i + 0 ]; + imageData[ ( x + width * y ) * 4 + 1 ] = image[ i + 1 ]; + imageData[ ( x + width * y ) * 4 + 0 ] = image[ i + 2 ]; + imageData[ ( x + width * y ) * 4 + 3 ] = image[ i + 3 ]; } } @@ -500,45 +500,45 @@ THREE.ImageUtils = { var color, i = 0, x, y; 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++) { - color = image[i]; - imageData[(x + width * y) * 4 + 0] = color; - imageData[(x + width * y) * 4 + 1] = color; - imageData[(x + width * y) * 4 + 2] = color; - imageData[(x + width * y) * 4 + 3] = 255; + for ( y = y_start; y !== y_end; y += y_step ) { + 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; + imageData[ ( x + width * y ) * 4 + 2 ] = color; + imageData[ ( x + width * y ) * 4 + 3 ] = 255; } } return imageData; }; - function tgaGetImageDataGrey16bits(imageData, y_start, y_step, y_end, x_start, x_step, x_end, image) { + function tgaGetImageDataGrey16bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image ) { var i = 0, x, y; 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 += 2) { - imageData[(x + width * y) * 4 + 0] = image[i + 0]; - imageData[(x + width * y) * 4 + 1] = image[i + 0]; - imageData[(x + width * y) * 4 + 2] = image[i + 0]; - imageData[(x + width * y) * 4 + 3] = image[i + 1]; + for ( y = y_start; y !== y_end; y += y_step ) { + for ( x = x_start; x !== x_end; x += x_step, i += 2 ) { + imageData[ ( x + width * y ) * 4 + 0 ] = image[ i + 0 ]; + imageData[ ( x + width * y ) * 4 + 1 ] = image[ i + 0 ]; + imageData[ ( x + width * y ) * 4 + 2 ] = image[ i + 0 ]; + imageData[ ( x + width * y ) * 4 + 3 ] = image[ i + 1 ]; } } return imageData; }; - + function getTgaRGBA( width, height, image, palette ) { var x_start, y_start, x_step, y_step, x_end, - y_end, - data = new Uint8Array(width * height * 4); - - switch( (header.flags & TGA_ORIGIN_MASK) >> TGA_ORIGIN_SHIFT ) { + y_end, + data = new Uint8Array( width * height * 4 ); + + switch ( ( header.flags & TGA_ORIGIN_MASK ) >> TGA_ORIGIN_SHIFT ) { default: case TGA_ORIGIN_UL: x_start = 0; @@ -548,7 +548,7 @@ THREE.ImageUtils = { y_step = 1; y_end = height; break; - + case TGA_ORIGIN_BL: x_start = 0; x_step = 1; @@ -557,7 +557,7 @@ THREE.ImageUtils = { y_step = -1; y_end = -1; break; - + case TGA_ORIGIN_UR: x_start = width - 1; x_step = -1; @@ -566,7 +566,7 @@ THREE.ImageUtils = { y_step = 1; y_end = height; break; - + case TGA_ORIGIN_BR: x_start = width - 1; x_step = -1; @@ -576,11 +576,11 @@ THREE.ImageUtils = { y_end = -1; break; } - - + + 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 ); @@ -592,20 +592,20 @@ THREE.ImageUtils = { console.error( 'ImageUtils::getTgaRGBA() - not support this format' ); break; } - + } 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; - + case 16: tgaGetImageData16bits( data, y_start, y_step, y_end, x_start, x_step, x_end, image ); break; - + case 24: tgaGetImageData24bits( data, y_start, y_step, y_end, x_start, x_step, x_end, image ); break; @@ -613,10 +613,10 @@ THREE.ImageUtils = { case 32: tgaGetImageData32bits( data, y_start, y_step, y_end, x_start, x_step, x_end, image ); break; - + default: console.error( 'ImageUtils::getTgaRGBA() - not support this format' ); - break; + break; } } // Load image data according to specific method @@ -624,11 +624,11 @@ THREE.ImageUtils = { //func(data, y_start, y_step, y_end, x_start, x_step, x_end, width, image, palette ); return data; } - + var result = tgaParse( use_rle, use_pal, header, offset, content ); var rgbaData = getTgaRGBA( header.width, header.height, result.pixel_data, result.palettes ); - - + + return { width: header.width, height: header.height, @@ -637,14 +637,14 @@ THREE.ImageUtils = { }, loadTGATexture: function ( url, mapping, onLoad, onError ) { - - var texture = new THREE.DataTexture(); + + var texture = new THREE.DataTexture(); { var request = new XMLHttpRequest(); request.open( 'GET', url, true ); - request.responseType = "arraybuffer"; - + request.responseType = 'arraybuffer'; + request.addEventListener( 'load', function ( event ) { var imageData = THREE.ImageUtils.decodeTGA( this.response ); @@ -659,16 +659,16 @@ THREE.ImageUtils = { } }, false ); - + request.addEventListener( 'error', function ( event ) { if ( onError ) onError( event ); }, false ); - - request.send(null); + + request.send( null ); } - + texture.sourceFile = url; return texture; @@ -696,7 +696,7 @@ THREE.ImageUtils = { { var request = new XMLHttpRequest(); - request.onload = function( ) { + request.onload = function () { var buffer = request.response; var dds = THREE.ImageUtils.parseDDS( buffer, true ); @@ -707,7 +707,7 @@ THREE.ImageUtils = { for ( var f = 0; f < faces; f ++ ) { - images[ f ] = { mipmaps : [] }; + images[ f ] = { mipmaps: [] }; for ( var i = 0; i < dds.mipmapCount; i ++ ) { @@ -736,7 +736,7 @@ THREE.ImageUtils = { request.onerror = onError; request.open( 'GET', url, true ); - request.responseType = "arraybuffer"; + request.responseType = 'arraybuffer'; request.send( null ); } @@ -788,10 +788,10 @@ THREE.ImageUtils = { function fourCCToInt32( value ) { - return value.charCodeAt(0) + - (value.charCodeAt(1) << 8) + - (value.charCodeAt(2) << 16) + - (value.charCodeAt(3) << 24); + return value.charCodeAt( 0 ) + + ( value.charCodeAt( 1 ) << 8 ) + + ( value.charCodeAt( 2 ) << 16 ) + + ( value.charCodeAt( 3 ) << 24 ); } @@ -799,36 +799,36 @@ THREE.ImageUtils = { return String.fromCharCode( value & 0xff, - (value >> 8) & 0xff, - (value >> 16) & 0xff, - (value >> 24) & 0xff + ( value >> 8 ) & 0xff, + ( value >> 16 ) & 0xff, + ( value >> 24 ) & 0xff ); } 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 + 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; } - var FOURCC_DXT1 = fourCCToInt32("DXT1"); - var FOURCC_DXT3 = fourCCToInt32("DXT3"); - var FOURCC_DXT5 = fourCCToInt32("DXT5"); + var FOURCC_DXT1 = fourCCToInt32( 'DXT1' ); + var FOURCC_DXT3 = fourCCToInt32( 'DXT3' ); + var FOURCC_DXT5 = fourCCToInt32( 'DXT5' ); var headerLengthInt = 31; // The header length in 32 bit ints @@ -862,14 +862,14 @@ THREE.ImageUtils = { if ( header[ off_magic ] !== DDS_MAGIC ) { - console.error( "THREE.ImageUtils.parseDDS: Invalid magic number in DDS header" ); + console.error( 'THREE.ImageUtils.parseDDS: Invalid magic number in DDS header' ); return dds; } - if ( ! header[ off_pfFlags ] & DDPF_FOURCC ) { + if ( !header[ off_pfFlags ] & DDPF_FOURCC ) { - console.error( "THREE.ImageUtils.parseDDS: Unsupported format, must contain a FourCC code" ); + console.error( 'THREE.ImageUtils.parseDDS: Unsupported format, must contain a FourCC code' ); return dds; } @@ -902,16 +902,16 @@ THREE.ImageUtils = { default: - if( header[off_RGBBitCount] ==32 - && header[off_RBitMask]&0xff0000 - && header[off_GBitMask]&0xff00 - && header[off_BBitMask]&0xff - && header[off_ABitMask]&0xff000000 ) { + if ( header[ off_RGBBitCount ] == 32 + && header[ off_RBitMask ] & 0xff0000 + && header[ off_GBitMask ] & 0xff00 + && header[ off_BBitMask ] & 0xff + && header[ off_ABitMask ] & 0xff000000 ) { isRGBAUncompressed = true; blockBytes = 64; dds.format = THREE.RGBAFormat; } else { - console.error( "THREE.ImageUtils.parseDDS: Unsupported FourCC code: ", int32ToFourCC( fourCC ) ); + console.error( 'THREE.ImageUtils.parseDDS: Unsupported FourCC code: ', int32ToFourCC( fourCC ) ); return dds; } } @@ -944,15 +944,15 @@ THREE.ImageUtils = { for ( var i = 0; i < dds.mipmapCount; i ++ ) { - if( isRGBAUncompressed ) { + if ( isRGBAUncompressed ) { var byteArray = loadARGBMip( buffer, dataOffset, width, height ); var dataLength = byteArray.length; } else { var dataLength = Math.max( 4, width ) / 4 * Math.max( 4, height ) / 4 * blockBytes; var byteArray = new Uint8Array( buffer, dataOffset, dataLength ); } - - var mipmap = { "data": byteArray, "width": width, "height": height }; + + var mipmap = { 'data': byteArray, 'width': width, 'height': height }; dds.mipmaps.push( mipmap ); dataOffset += dataLength; @@ -1021,14 +1021,14 @@ THREE.ImageUtils = { var points = []; var origin = [ 0, 0, data[ ( y * width + x ) * 4 ] / 255 * depth ]; - points.push( [ - 1, 0, data[ ( y * width + lx ) * 4 ] / 255 * depth ] ); - points.push( [ - 1, - 1, data[ ( ly * width + lx ) * 4 ] / 255 * depth ] ); - points.push( [ 0, - 1, data[ ( ly * width + x ) * 4 ] / 255 * depth ] ); - points.push( [ 1, - 1, data[ ( ly * width + ux ) * 4 ] / 255 * depth ] ); + points.push( [ -1, 0, data[ ( y * width + lx ) * 4 ] / 255 * depth ] ); + points.push( [ -1, -1, data[ ( ly * width + lx ) * 4 ] / 255 * depth ] ); + points.push( [ 0, -1, data[ ( ly * width + x ) * 4 ] / 255 * depth ] ); + points.push( [ 1, -1, data[ ( ly * width + ux ) * 4 ] / 255 * depth ] ); points.push( [ 1, 0, data[ ( y * width + ux ) * 4 ] / 255 * depth ] ); points.push( [ 1, 1, data[ ( uy * width + ux ) * 4 ] / 255 * depth ] ); points.push( [ 0, 1, data[ ( uy * width + x ) * 4 ] / 255 * depth ] ); - points.push( [ - 1, 1, data[ ( uy * width + lx ) * 4 ] / 255 * depth ] ); + points.push( [ -1, 1, data[ ( uy * width + lx ) * 4 ] / 255 * depth ] ); var normals = []; var num_points = points.length; @@ -1085,7 +1085,7 @@ THREE.ImageUtils = { for ( var i = 0; i < size; i ++ ) { - data[ i * 3 ] = r; + data[ i * 3 ] = r; data[ i * 3 + 1 ] = g; data[ i * 3 + 2 ] = b; diff --git a/src/extras/curves/ArcCurve.js b/src/extras/curves/ArcCurve.js index 102a56a650048..a5f53f4729abc 100644 --- a/src/extras/curves/ArcCurve.js +++ b/src/extras/curves/ArcCurve.js @@ -7,4 +7,4 @@ THREE.ArcCurve = function ( aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise THREE.EllipseCurve.call( this, aX, aY, aRadius, aRadius, aStartAngle, aEndAngle, aClockwise ); }; -THREE.ArcCurve.prototype = Object.create( THREE.EllipseCurve.prototype ); \ No newline at end of file +THREE.ArcCurve.prototype = Object.create( THREE.EllipseCurve.prototype ); diff --git a/src/extras/curves/ClosedSplineCurve3.js b/src/extras/curves/ClosedSplineCurve3.js index 3e8e294722456..880712ee60db5 100644 --- a/src/extras/curves/ClosedSplineCurve3.js +++ b/src/extras/curves/ClosedSplineCurve3.js @@ -36,4 +36,4 @@ THREE.ClosedSplineCurve3 = THREE.Curve.create( } -); \ No newline at end of file +); diff --git a/src/extras/curves/CubicBezierCurve.js b/src/extras/curves/CubicBezierCurve.js index 70cd7f06e0e50..fcbc2210aded2 100644 --- a/src/extras/curves/CubicBezierCurve.js +++ b/src/extras/curves/CubicBezierCurve.js @@ -36,4 +36,4 @@ THREE.CubicBezierCurve.prototype.getTangent = function( t ) { return tangent; -}; \ No newline at end of file +}; diff --git a/src/extras/curves/CubicBezierCurve3.js b/src/extras/curves/CubicBezierCurve3.js index b2b4ed4ac4d21..9377d97f930ba 100644 --- a/src/extras/curves/CubicBezierCurve3.js +++ b/src/extras/curves/CubicBezierCurve3.js @@ -25,4 +25,4 @@ THREE.CubicBezierCurve3 = THREE.Curve.create( } -); \ No newline at end of file +); diff --git a/src/extras/curves/LineCurve.js b/src/extras/curves/LineCurve.js index cbb0a8fca18df..0017e2faef50b 100644 --- a/src/extras/curves/LineCurve.js +++ b/src/extras/curves/LineCurve.js @@ -34,4 +34,4 @@ THREE.LineCurve.prototype.getTangent = function( t ) { return tangent.normalize(); -}; \ No newline at end of file +}; diff --git a/src/extras/curves/QuadraticBezierCurve.js b/src/extras/curves/QuadraticBezierCurve.js index 88a93318d7e98..01904d011918e 100644 --- a/src/extras/curves/QuadraticBezierCurve.js +++ b/src/extras/curves/QuadraticBezierCurve.js @@ -40,4 +40,4 @@ THREE.QuadraticBezierCurve.prototype.getTangent = function( t ) { return tangent; -}; \ No newline at end of file +}; diff --git a/src/extras/curves/QuadraticBezierCurve3.js b/src/extras/curves/QuadraticBezierCurve3.js index 84d45af0385dc..70164f567e00c 100644 --- a/src/extras/curves/QuadraticBezierCurve3.js +++ b/src/extras/curves/QuadraticBezierCurve3.js @@ -24,4 +24,4 @@ THREE.QuadraticBezierCurve3 = THREE.Curve.create( } -); \ No newline at end of file +); diff --git a/src/extras/curves/SplineCurve.js b/src/extras/curves/SplineCurve.js index 7173bd99ede43..d8c2d58782bdd 100644 --- a/src/extras/curves/SplineCurve.js +++ b/src/extras/curves/SplineCurve.js @@ -30,4 +30,4 @@ THREE.SplineCurve.prototype.getPoint = function ( t ) { return v; -}; \ No newline at end of file +}; diff --git a/src/extras/curves/SplineCurve3.js b/src/extras/curves/SplineCurve3.js index ef5b2e020405f..22034850697a7 100644 --- a/src/extras/curves/SplineCurve3.js +++ b/src/extras/curves/SplineCurve3.js @@ -68,4 +68,4 @@ THREE.SplineCurve3 = THREE.Curve.create( // return v; -// } \ No newline at end of file +// } diff --git a/src/lights/Light.js b/src/lights/Light.js index ca34e2cff0b31..0f3db6b545298 100644 --- a/src/lights/Light.js +++ b/src/lights/Light.js @@ -2,7 +2,7 @@ * @author mrdoob / http://mrdoob.com/ * @author alteredq / http://alteredqualia.com/ */ - + THREE.Light = function ( color ) { THREE.Object3D.call( this ); diff --git a/src/loaders/BufferGeometryLoader.js b/src/loaders/BufferGeometryLoader.js index 08017bebe84ff..c423a759d0be7 100644 --- a/src/loaders/BufferGeometryLoader.js +++ b/src/loaders/BufferGeometryLoader.js @@ -1,73 +1,73 @@ /** * @author mrdoob / http://mrdoob.com/ - */ - -THREE.BufferGeometryLoader = function ( manager ) { - - this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; - -}; - -THREE.BufferGeometryLoader.prototype = { - - constructor: THREE.BufferGeometryLoader, - - load: function ( url, onLoad, onProgress, onError ) { - - var scope = this; - - var loader = new THREE.XHRLoader(); - loader.setCrossOrigin( this.crossOrigin ); - loader.load( url, function ( text ) { - - onLoad( scope.parse( JSON.parse( text ) ) ); - - } ); - - }, - - setCrossOrigin: function ( value ) { - - this.crossOrigin = value; - - }, - - parse: function ( json ) { - - var geometry = new THREE.BufferGeometry(); - - var attributes = json.attributes; - var offsets = json.offsets; - var boundingSphere = json.boundingSphere; - - for ( var key in attributes ) { - - var attribute = attributes[ key ]; - - geometry.attributes[ key ] = { - itemSize: attribute.itemSize, - array: new self[ attribute.type ]( attribute.array ) - } - - } - - if ( offsets !== undefined ) { - - geometry.offsets = JSON.parse( JSON.stringify( offsets ) ); - - } - - if ( boundingSphere !== undefined ) { - - geometry.boundingSphere = new THREE.Sphere( - new THREE.Vector3().fromArray( boundingSphere.center !== undefined ? boundingSphere.center : [ 0, 0, 0 ] ), - boundingSphere.radius - ); - - } - - return geometry; - - } - -}; + */ + +THREE.BufferGeometryLoader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + +}; + +THREE.BufferGeometryLoader.prototype = { + + constructor: THREE.BufferGeometryLoader, + + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + + var loader = new THREE.XHRLoader(); + loader.setCrossOrigin( this.crossOrigin ); + loader.load( url, function ( text ) { + + onLoad( scope.parse( JSON.parse( text ) ) ); + + } ); + + }, + + setCrossOrigin: function ( value ) { + + this.crossOrigin = value; + + }, + + parse: function ( json ) { + + var geometry = new THREE.BufferGeometry(); + + var attributes = json.attributes; + var offsets = json.offsets; + var boundingSphere = json.boundingSphere; + + for ( var key in attributes ) { + + var attribute = attributes[ key ]; + + geometry.attributes[ key ] = { + itemSize: attribute.itemSize, + array: new self[ attribute.type ]( attribute.array ) + } + + } + + if ( offsets !== undefined ) { + + geometry.offsets = JSON.parse( JSON.stringify( offsets ) ); + + } + + if ( boundingSphere !== undefined ) { + + geometry.boundingSphere = new THREE.Sphere( + new THREE.Vector3().fromArray( boundingSphere.center !== undefined ? boundingSphere.center : [ 0, 0, 0 ] ), + boundingSphere.radius + ); + + } + + return geometry; + + } + +}; diff --git a/src/loaders/Cache.js b/src/loaders/Cache.js index 0f3256b95f14a..cb20756999385 100644 --- a/src/loaders/Cache.js +++ b/src/loaders/Cache.js @@ -1,43 +1,43 @@ /** * @author mrdoob / http://mrdoob.com/ - */ - -THREE.Cache = function () { - - this.files = {}; - -}; - -THREE.Cache.prototype = { - - constructor: THREE.Cache, - - add: function ( key, file ) { - - // console.log( 'THREE.Cache', 'Adding key:', key ); - - this.files[ key ] = file; - - }, - - get: function ( key ) { - - // console.log( 'THREE.Cache', 'Checking key:', key ); - - return this.files[ key ]; - - }, - - remove: function ( key ) { - - delete this.files[ key ]; - - }, - - clear: function () { - - this.files = {} - - } - -}; \ No newline at end of file + */ + +THREE.Cache = function () { + + this.files = {}; + +}; + +THREE.Cache.prototype = { + + constructor: THREE.Cache, + + add: function ( key, file ) { + + // console.log( 'THREE.Cache', 'Adding key:', key ); + + this.files[ key ] = file; + + }, + + get: function ( key ) { + + // console.log( 'THREE.Cache', 'Checking key:', key ); + + return this.files[ key ]; + + }, + + remove: function ( key ) { + + delete this.files[ key ]; + + }, + + clear: function () { + + this.files = {} + + } + +}; diff --git a/src/loaders/JSONLoader.js b/src/loaders/JSONLoader.js index e6be0ed27503d..7d338d559d598 100644 --- a/src/loaders/JSONLoader.js +++ b/src/loaders/JSONLoader.js @@ -1,544 +1,544 @@ /** * @author mrdoob / http://mrdoob.com/ * @author alteredq / http://alteredqualia.com/ - */ - -THREE.JSONLoader = function ( showStatus ) { - - THREE.Loader.call( this, showStatus ); - - this.withCredentials = false; - -}; - -THREE.JSONLoader.prototype = Object.create( THREE.Loader.prototype ); - -THREE.JSONLoader.prototype.load = function ( url, callback, texturePath ) { - - var scope = this; - - // todo: unify load API to for easier SceneLoader use - - texturePath = texturePath && ( typeof texturePath === "string" ) ? texturePath : this.extractUrlBase( url ); - - this.onLoadStart(); - this.loadAjaxJSON( this, url, callback, texturePath ); - -}; - -THREE.JSONLoader.prototype.loadAjaxJSON = function ( context, url, callback, texturePath, callbackProgress ) { - - var xhr = new XMLHttpRequest(); - - var length = 0; - - xhr.onreadystatechange = function () { - - if ( xhr.readyState === xhr.DONE ) { - - if ( xhr.status === 200 || xhr.status === 0 ) { - - if ( xhr.responseText ) { - - var json = JSON.parse( xhr.responseText ); - - if ( json.metadata !== undefined && json.metadata.type === 'scene' ) { - - console.error( 'THREE.JSONLoader: "' + url + '" seems to be a Scene. Use THREE.SceneLoader instead.' ); - return; - - } - - var result = context.parse( json, texturePath ); - callback( result.geometry, result.materials ); - - } else { - - console.error( 'THREE.JSONLoader: "' + url + '" seems to be unreachable or the file is empty.' ); - - } - - // in context of more complex asset initialization - // do not block on single failed file - // maybe should go even one more level up - - context.onLoadComplete(); - - } else { - - console.error( 'THREE.JSONLoader: Couldn\'t load "' + url + '" (' + xhr.status + ')' ); - - } - - } else if ( xhr.readyState === xhr.LOADING ) { - - if ( callbackProgress ) { - - if ( length === 0 ) { - - length = xhr.getResponseHeader( 'Content-Length' ); - - } - - callbackProgress( { total: length, loaded: xhr.responseText.length } ); - - } - - } else if ( xhr.readyState === xhr.HEADERS_RECEIVED ) { - - if ( callbackProgress !== undefined ) { - - length = xhr.getResponseHeader( "Content-Length" ); - - } - - } - - }; - - xhr.open( "GET", url, true ); - xhr.withCredentials = this.withCredentials; - xhr.send( null ); - -}; - -THREE.JSONLoader.prototype.parse = function ( json, texturePath ) { - - var scope = this, - geometry = new THREE.Geometry(), - scale = ( json.scale !== undefined ) ? 1.0 / json.scale : 1.0; - - parseModel( scale ); - - parseSkin(); - parseMorphing( scale ); - - geometry.computeFaceNormals(); - geometry.computeBoundingSphere(); - - function parseModel( scale ) { - - function isBitSet( value, position ) { - - return value & ( 1 << position ); - - } - - var i, j, fi, - - offset, zLength, - - colorIndex, normalIndex, uvIndex, materialIndex, - - type, - isQuad, - hasMaterial, - hasFaceVertexUv, - hasFaceNormal, hasFaceVertexNormal, - hasFaceColor, hasFaceVertexColor, - - vertex, face, faceA, faceB, color, hex, normal, - - uvLayer, uv, u, v, - - faces = json.faces, - vertices = json.vertices, - normals = json.normals, - colors = json.colors, - - nUvLayers = 0; - - if ( json.uvs !== undefined ) { - - // disregard empty arrays - - for ( i = 0; i < json.uvs.length; i++ ) { - - if ( json.uvs[ i ].length ) nUvLayers ++; - - } - - for ( i = 0; i < nUvLayers; i++ ) { - - geometry.faceVertexUvs[ i ] = []; - - } - - } - - offset = 0; - zLength = vertices.length; - - while ( offset < zLength ) { - - vertex = new THREE.Vector3(); - - vertex.x = vertices[ offset ++ ] * scale; - vertex.y = vertices[ offset ++ ] * scale; - vertex.z = vertices[ offset ++ ] * scale; - - geometry.vertices.push( vertex ); - - } - - offset = 0; - zLength = faces.length; - - while ( offset < zLength ) { - - type = faces[ offset ++ ]; - - - isQuad = isBitSet( type, 0 ); - hasMaterial = isBitSet( type, 1 ); - hasFaceVertexUv = isBitSet( type, 3 ); - hasFaceNormal = isBitSet( type, 4 ); - hasFaceVertexNormal = isBitSet( type, 5 ); - hasFaceColor = isBitSet( type, 6 ); - hasFaceVertexColor = isBitSet( type, 7 ); - - // console.log("type", type, "bits", isQuad, hasMaterial, hasFaceVertexUv, hasFaceNormal, hasFaceVertexNormal, hasFaceColor, hasFaceVertexColor); - - if ( isQuad ) { - - faceA = new THREE.Face3(); - faceA.a = faces[ offset ]; - faceA.b = faces[ offset + 1 ]; - faceA.c = faces[ offset + 3 ]; - - faceB = new THREE.Face3(); - faceB.a = faces[ offset + 1 ]; - faceB.b = faces[ offset + 2 ]; - faceB.c = faces[ offset + 3 ]; - - offset += 4; - - if ( hasMaterial ) { - - materialIndex = faces[ offset ++ ]; - faceA.materialIndex = materialIndex; - faceB.materialIndex = materialIndex; - - } - - // to get face <=> uv index correspondence - - fi = geometry.faces.length; - - if ( hasFaceVertexUv ) { - - for ( i = 0; i < nUvLayers; i++ ) { - - uvLayer = json.uvs[ i ]; - - geometry.faceVertexUvs[ i ][ fi ] = []; - geometry.faceVertexUvs[ i ][ fi + 1 ] = [] - - for ( j = 0; j < 4; j ++ ) { - - uvIndex = faces[ offset ++ ]; - - u = uvLayer[ uvIndex * 2 ]; - v = uvLayer[ uvIndex * 2 + 1 ]; - - uv = new THREE.Vector2( u, v ); - - if ( j !== 2 ) geometry.faceVertexUvs[ i ][ fi ].push( uv ); - if ( j !== 0 ) geometry.faceVertexUvs[ i ][ fi + 1 ].push( uv ); - - } - - } - - } - - if ( hasFaceNormal ) { - - normalIndex = faces[ offset ++ ] * 3; - - faceA.normal.set( - normals[ normalIndex ++ ], - normals[ normalIndex ++ ], - normals[ normalIndex ] - ); - - faceB.normal.copy( faceA.normal ); - - } - - if ( hasFaceVertexNormal ) { - - for ( i = 0; i < 4; i++ ) { - - normalIndex = faces[ offset ++ ] * 3; - - normal = new THREE.Vector3( - normals[ normalIndex ++ ], - normals[ normalIndex ++ ], - normals[ normalIndex ] - ); - - - if ( i !== 2 ) faceA.vertexNormals.push( normal ); - if ( i !== 0 ) faceB.vertexNormals.push( normal ); - - } - - } - - - if ( hasFaceColor ) { - - colorIndex = faces[ offset ++ ]; - hex = colors[ colorIndex ]; - - faceA.color.setHex( hex ); - faceB.color.setHex( hex ); - - } - - - if ( hasFaceVertexColor ) { - - for ( i = 0; i < 4; i++ ) { - - colorIndex = faces[ offset ++ ]; - hex = colors[ colorIndex ]; - - if ( i !== 2 ) faceA.vertexColors.push( new THREE.Color( hex ) ); - if ( i !== 0 ) faceB.vertexColors.push( new THREE.Color( hex ) ); - - } - - } - - geometry.faces.push( faceA ); - geometry.faces.push( faceB ); - - } else { - - face = new THREE.Face3(); - face.a = faces[ offset ++ ]; - face.b = faces[ offset ++ ]; - face.c = faces[ offset ++ ]; - - if ( hasMaterial ) { - - materialIndex = faces[ offset ++ ]; - face.materialIndex = materialIndex; - - } - - // to get face <=> uv index correspondence - - fi = geometry.faces.length; - - if ( hasFaceVertexUv ) { - - for ( i = 0; i < nUvLayers; i++ ) { - - uvLayer = json.uvs[ i ]; - - geometry.faceVertexUvs[ i ][ fi ] = []; - - for ( j = 0; j < 3; j ++ ) { - - uvIndex = faces[ offset ++ ]; - - u = uvLayer[ uvIndex * 2 ]; - v = uvLayer[ uvIndex * 2 + 1 ]; - - uv = new THREE.Vector2( u, v ); - - geometry.faceVertexUvs[ i ][ fi ].push( uv ); - - } - - } - - } - - if ( hasFaceNormal ) { - - normalIndex = faces[ offset ++ ] * 3; - - face.normal.set( - normals[ normalIndex ++ ], - normals[ normalIndex ++ ], - normals[ normalIndex ] - ); - - } - - if ( hasFaceVertexNormal ) { - - for ( i = 0; i < 3; i++ ) { - - normalIndex = faces[ offset ++ ] * 3; - - normal = new THREE.Vector3( - normals[ normalIndex ++ ], - normals[ normalIndex ++ ], - normals[ normalIndex ] - ); - - face.vertexNormals.push( normal ); - - } - - } - - - if ( hasFaceColor ) { - - colorIndex = faces[ offset ++ ]; - face.color.setHex( colors[ colorIndex ] ); - - } - - - if ( hasFaceVertexColor ) { - - for ( i = 0; i < 3; i++ ) { - - colorIndex = faces[ offset ++ ]; - face.vertexColors.push( new THREE.Color( colors[ colorIndex ] ) ); - - } - - } - - geometry.faces.push( face ); - - } - - } - - }; - - function parseSkin() { - var influencesPerVertex = ( json.influencesPerVertex !== undefined ) ? json.influencesPerVertex : 2; - - if ( json.skinWeights ) { - - for ( var i = 0, l = json.skinWeights.length; i < l; i += influencesPerVertex ) { - - var x = json.skinWeights[ i ]; - var y = ( influencesPerVertex > 1 ) ? json.skinWeights[ i + 1 ] : 0; - var z = ( influencesPerVertex > 2 ) ? json.skinWeights[ i + 2 ] : 0; - var w = ( influencesPerVertex > 3 ) ? json.skinWeights[ i + 3 ] : 0; - - geometry.skinWeights.push( new THREE.Vector4( x, y, z, w ) ); - - } - - } - - if ( json.skinIndices ) { - - for ( var i = 0, l = json.skinIndices.length; i < l; i += influencesPerVertex ) { - - var a = json.skinIndices[ i ]; - var b = ( influencesPerVertex > 1 ) ? json.skinIndices[ i + 1 ] : 0; - var c = ( influencesPerVertex > 2 ) ? json.skinIndices[ i + 2 ] : 0; - var d = ( influencesPerVertex > 3 ) ? json.skinIndices[ i + 3 ] : 0; - - geometry.skinIndices.push( new THREE.Vector4( a, b, c, d ) ); - - } - - } - - geometry.bones = json.bones; - - if ( geometry.bones && geometry.bones.length > 0 && ( geometry.skinWeights.length !== geometry.skinIndices.length || geometry.skinIndices.length !== geometry.vertices.length ) ) { - - console.warn( 'When skinning, number of vertices (' + geometry.vertices.length + '), skinIndices (' + - geometry.skinIndices.length + '), and skinWeights (' + geometry.skinWeights.length + ') should match.' ); - - } - - - // could change this to json.animations[0] or remove completely - - geometry.animation = json.animation; - geometry.animations = json.animations; - - }; - - function parseMorphing( scale ) { - - if ( json.morphTargets !== undefined ) { - - var i, l, v, vl, dstVertices, srcVertices; - - for ( i = 0, l = json.morphTargets.length; i < l; i ++ ) { - - geometry.morphTargets[ i ] = {}; - geometry.morphTargets[ i ].name = json.morphTargets[ i ].name; - geometry.morphTargets[ i ].vertices = []; - - dstVertices = geometry.morphTargets[ i ].vertices; - srcVertices = json.morphTargets [ i ].vertices; - - for( v = 0, vl = srcVertices.length; v < vl; v += 3 ) { - - var vertex = new THREE.Vector3(); - vertex.x = srcVertices[ v ] * scale; - vertex.y = srcVertices[ v + 1 ] * scale; - vertex.z = srcVertices[ v + 2 ] * scale; - - dstVertices.push( vertex ); - - } - - } - - } - - if ( json.morphColors !== undefined ) { - - var i, l, c, cl, dstColors, srcColors, color; - - for ( i = 0, l = json.morphColors.length; i < l; i++ ) { - - geometry.morphColors[ i ] = {}; - geometry.morphColors[ i ].name = json.morphColors[ i ].name; - geometry.morphColors[ i ].colors = []; - - dstColors = geometry.morphColors[ i ].colors; - srcColors = json.morphColors [ i ].colors; - - for ( c = 0, cl = srcColors.length; c < cl; c += 3 ) { - - color = new THREE.Color( 0xffaa00 ); - color.setRGB( srcColors[ c ], srcColors[ c + 1 ], srcColors[ c + 2 ] ); - dstColors.push( color ); - - } - - } - - } - - }; - - if ( json.materials === undefined || json.materials.length === 0 ) { - - return { geometry: geometry }; - - } else { - - var materials = this.initMaterials( json.materials, texturePath ); - - if ( this.needsTangents( materials ) ) { - - geometry.computeTangents(); - - } - - return { geometry: geometry, materials: materials }; - - } - -}; + */ + +THREE.JSONLoader = function ( showStatus ) { + + THREE.Loader.call( this, showStatus ); + + this.withCredentials = false; + +}; + +THREE.JSONLoader.prototype = Object.create( THREE.Loader.prototype ); + +THREE.JSONLoader.prototype.load = function ( url, callback, texturePath ) { + + var scope = this; + + // todo: unify load API to for easier SceneLoader use + + texturePath = texturePath && ( typeof texturePath === 'string' ) ? texturePath : this.extractUrlBase( url ); + + this.onLoadStart(); + this.loadAjaxJSON( this, url, callback, texturePath ); + +}; + +THREE.JSONLoader.prototype.loadAjaxJSON = function ( context, url, callback, texturePath, callbackProgress ) { + + var xhr = new XMLHttpRequest(); + + var length = 0; + + xhr.onreadystatechange = function () { + + if ( xhr.readyState === xhr.DONE ) { + + if ( xhr.status === 200 || xhr.status === 0 ) { + + if ( xhr.responseText ) { + + var json = JSON.parse( xhr.responseText ); + + if ( json.metadata !== undefined && json.metadata.type === 'scene' ) { + + console.error( 'THREE.JSONLoader: "' + url + '" seems to be a Scene. Use THREE.SceneLoader instead.' ); + return; + + } + + var result = context.parse( json, texturePath ); + callback( result.geometry, result.materials ); + + } else { + + console.error( 'THREE.JSONLoader: "' + url + '" seems to be unreachable or the file is empty.' ); + + } + + // in context of more complex asset initialization + // do not block on single failed file + // maybe should go even one more level up + + context.onLoadComplete(); + + } else { + + console.error( 'THREE.JSONLoader: Couldn\'t load "' + url + '" (' + xhr.status + ')' ); + + } + + } else if ( xhr.readyState === xhr.LOADING ) { + + if ( callbackProgress ) { + + if ( length === 0 ) { + + length = xhr.getResponseHeader( 'Content-Length' ); + + } + + callbackProgress( { total: length, loaded: xhr.responseText.length } ); + + } + + } else if ( xhr.readyState === xhr.HEADERS_RECEIVED ) { + + if ( callbackProgress !== undefined ) { + + length = xhr.getResponseHeader( 'Content-Length' ); + + } + + } + + }; + + xhr.open( 'GET', url, true ); + xhr.withCredentials = this.withCredentials; + xhr.send( null ); + +}; + +THREE.JSONLoader.prototype.parse = function ( json, texturePath ) { + + var scope = this, + geometry = new THREE.Geometry(), + scale = ( json.scale !== undefined ) ? 1.0 / json.scale : 1.0; + + parseModel( scale ); + + parseSkin(); + parseMorphing( scale ); + + geometry.computeFaceNormals(); + geometry.computeBoundingSphere(); + + function parseModel( scale ) { + + function isBitSet( value, position ) { + + return value & ( 1 << position ); + + } + + var i, j, fi, + + offset, zLength, + + colorIndex, normalIndex, uvIndex, materialIndex, + + type, + isQuad, + hasMaterial, + hasFaceVertexUv, + hasFaceNormal, hasFaceVertexNormal, + hasFaceColor, hasFaceVertexColor, + + vertex, face, faceA, faceB, color, hex, normal, + + uvLayer, uv, u, v, + + faces = json.faces, + vertices = json.vertices, + normals = json.normals, + colors = json.colors, + + nUvLayers = 0; + + if ( json.uvs !== undefined ) { + + // disregard empty arrays + + for ( i = 0; i < json.uvs.length; i++ ) { + + if ( json.uvs[ i ].length ) nUvLayers ++; + + } + + for ( i = 0; i < nUvLayers; i++ ) { + + geometry.faceVertexUvs[ i ] = []; + + } + + } + + offset = 0; + zLength = vertices.length; + + while ( offset < zLength ) { + + vertex = new THREE.Vector3(); + + vertex.x = vertices[ offset ++ ] * scale; + vertex.y = vertices[ offset ++ ] * scale; + vertex.z = vertices[ offset ++ ] * scale; + + geometry.vertices.push( vertex ); + + } + + offset = 0; + zLength = faces.length; + + while ( offset < zLength ) { + + type = faces[ offset ++ ]; + + + isQuad = isBitSet( type, 0 ); + hasMaterial = isBitSet( type, 1 ); + hasFaceVertexUv = isBitSet( type, 3 ); + hasFaceNormal = isBitSet( type, 4 ); + hasFaceVertexNormal = isBitSet( type, 5 ); + hasFaceColor = isBitSet( type, 6 ); + hasFaceVertexColor = isBitSet( type, 7 ); + + // console.log("type", type, "bits", isQuad, hasMaterial, hasFaceVertexUv, hasFaceNormal, hasFaceVertexNormal, hasFaceColor, hasFaceVertexColor); + + if ( isQuad ) { + + faceA = new THREE.Face3(); + faceA.a = faces[ offset ]; + faceA.b = faces[ offset + 1 ]; + faceA.c = faces[ offset + 3 ]; + + faceB = new THREE.Face3(); + faceB.a = faces[ offset + 1 ]; + faceB.b = faces[ offset + 2 ]; + faceB.c = faces[ offset + 3 ]; + + offset += 4; + + if ( hasMaterial ) { + + materialIndex = faces[ offset ++ ]; + faceA.materialIndex = materialIndex; + faceB.materialIndex = materialIndex; + + } + + // to get face <=> uv index correspondence + + fi = geometry.faces.length; + + if ( hasFaceVertexUv ) { + + for ( i = 0; i < nUvLayers; i++ ) { + + uvLayer = json.uvs[ i ]; + + geometry.faceVertexUvs[ i ][ fi ] = []; + geometry.faceVertexUvs[ i ][ fi + 1 ] = [] + + for ( j = 0; j < 4; j ++ ) { + + uvIndex = faces[ offset ++ ]; + + u = uvLayer[ uvIndex * 2 ]; + v = uvLayer[ uvIndex * 2 + 1 ]; + + uv = new THREE.Vector2( u, v ); + + if ( j !== 2 ) geometry.faceVertexUvs[ i ][ fi ].push( uv ); + if ( j !== 0 ) geometry.faceVertexUvs[ i ][ fi + 1 ].push( uv ); + + } + + } + + } + + if ( hasFaceNormal ) { + + normalIndex = faces[ offset ++ ] * 3; + + faceA.normal.set( + normals[ normalIndex ++ ], + normals[ normalIndex ++ ], + normals[ normalIndex ] + ); + + faceB.normal.copy( faceA.normal ); + + } + + if ( hasFaceVertexNormal ) { + + for ( i = 0; i < 4; i++ ) { + + normalIndex = faces[ offset ++ ] * 3; + + normal = new THREE.Vector3( + normals[ normalIndex ++ ], + normals[ normalIndex ++ ], + normals[ normalIndex ] + ); + + + if ( i !== 2 ) faceA.vertexNormals.push( normal ); + if ( i !== 0 ) faceB.vertexNormals.push( normal ); + + } + + } + + + if ( hasFaceColor ) { + + colorIndex = faces[ offset ++ ]; + hex = colors[ colorIndex ]; + + faceA.color.setHex( hex ); + faceB.color.setHex( hex ); + + } + + + if ( hasFaceVertexColor ) { + + for ( i = 0; i < 4; i++ ) { + + colorIndex = faces[ offset ++ ]; + hex = colors[ colorIndex ]; + + if ( i !== 2 ) faceA.vertexColors.push( new THREE.Color( hex ) ); + if ( i !== 0 ) faceB.vertexColors.push( new THREE.Color( hex ) ); + + } + + } + + geometry.faces.push( faceA ); + geometry.faces.push( faceB ); + + } else { + + face = new THREE.Face3(); + face.a = faces[ offset ++ ]; + face.b = faces[ offset ++ ]; + face.c = faces[ offset ++ ]; + + if ( hasMaterial ) { + + materialIndex = faces[ offset ++ ]; + face.materialIndex = materialIndex; + + } + + // to get face <=> uv index correspondence + + fi = geometry.faces.length; + + if ( hasFaceVertexUv ) { + + for ( i = 0; i < nUvLayers; i++ ) { + + uvLayer = json.uvs[ i ]; + + geometry.faceVertexUvs[ i ][ fi ] = []; + + for ( j = 0; j < 3; j ++ ) { + + uvIndex = faces[ offset ++ ]; + + u = uvLayer[ uvIndex * 2 ]; + v = uvLayer[ uvIndex * 2 + 1 ]; + + uv = new THREE.Vector2( u, v ); + + geometry.faceVertexUvs[ i ][ fi ].push( uv ); + + } + + } + + } + + if ( hasFaceNormal ) { + + normalIndex = faces[ offset ++ ] * 3; + + face.normal.set( + normals[ normalIndex ++ ], + normals[ normalIndex ++ ], + normals[ normalIndex ] + ); + + } + + if ( hasFaceVertexNormal ) { + + for ( i = 0; i < 3; i++ ) { + + normalIndex = faces[ offset ++ ] * 3; + + normal = new THREE.Vector3( + normals[ normalIndex ++ ], + normals[ normalIndex ++ ], + normals[ normalIndex ] + ); + + face.vertexNormals.push( normal ); + + } + + } + + + if ( hasFaceColor ) { + + colorIndex = faces[ offset ++ ]; + face.color.setHex( colors[ colorIndex ] ); + + } + + + if ( hasFaceVertexColor ) { + + for ( i = 0; i < 3; i++ ) { + + colorIndex = faces[ offset ++ ]; + face.vertexColors.push( new THREE.Color( colors[ colorIndex ] ) ); + + } + + } + + geometry.faces.push( face ); + + } + + } + + }; + + function parseSkin() { + var influencesPerVertex = ( json.influencesPerVertex !== undefined ) ? json.influencesPerVertex : 2; + + if ( json.skinWeights ) { + + for ( var i = 0, l = json.skinWeights.length; i < l; i += influencesPerVertex ) { + + var x = json.skinWeights[ i ]; + var y = ( influencesPerVertex > 1 ) ? json.skinWeights[ i + 1 ] : 0; + var z = ( influencesPerVertex > 2 ) ? json.skinWeights[ i + 2 ] : 0; + var w = ( influencesPerVertex > 3 ) ? json.skinWeights[ i + 3 ] : 0; + + geometry.skinWeights.push( new THREE.Vector4( x, y, z, w ) ); + + } + + } + + if ( json.skinIndices ) { + + for ( var i = 0, l = json.skinIndices.length; i < l; i += influencesPerVertex ) { + + var a = json.skinIndices[ i ]; + var b = ( influencesPerVertex > 1 ) ? json.skinIndices[ i + 1 ] : 0; + var c = ( influencesPerVertex > 2 ) ? json.skinIndices[ i + 2 ] : 0; + var d = ( influencesPerVertex > 3 ) ? json.skinIndices[ i + 3 ] : 0; + + geometry.skinIndices.push( new THREE.Vector4( a, b, c, d ) ); + + } + + } + + geometry.bones = json.bones; + + if ( geometry.bones && geometry.bones.length > 0 && ( geometry.skinWeights.length !== geometry.skinIndices.length || geometry.skinIndices.length !== geometry.vertices.length ) ) { + + console.warn( 'When skinning, number of vertices (' + geometry.vertices.length + '), skinIndices (' + + geometry.skinIndices.length + '), and skinWeights (' + geometry.skinWeights.length + ') should match.' ); + + } + + + // could change this to json.animations[0] or remove completely + + geometry.animation = json.animation; + geometry.animations = json.animations; + + }; + + function parseMorphing( scale ) { + + if ( json.morphTargets !== undefined ) { + + var i, l, v, vl, dstVertices, srcVertices; + + for ( i = 0, l = json.morphTargets.length; i < l; i ++ ) { + + geometry.morphTargets[ i ] = {}; + geometry.morphTargets[ i ].name = json.morphTargets[ i ].name; + geometry.morphTargets[ i ].vertices = []; + + dstVertices = geometry.morphTargets[ i ].vertices; + srcVertices = json.morphTargets [ i ].vertices; + + for ( v = 0, vl = srcVertices.length; v < vl; v += 3 ) { + + var vertex = new THREE.Vector3(); + vertex.x = srcVertices[ v ] * scale; + vertex.y = srcVertices[ v + 1 ] * scale; + vertex.z = srcVertices[ v + 2 ] * scale; + + dstVertices.push( vertex ); + + } + + } + + } + + if ( json.morphColors !== undefined ) { + + var i, l, c, cl, dstColors, srcColors, color; + + for ( i = 0, l = json.morphColors.length; i < l; i++ ) { + + geometry.morphColors[ i ] = {}; + geometry.morphColors[ i ].name = json.morphColors[ i ].name; + geometry.morphColors[ i ].colors = []; + + dstColors = geometry.morphColors[ i ].colors; + srcColors = json.morphColors [ i ].colors; + + for ( c = 0, cl = srcColors.length; c < cl; c += 3 ) { + + color = new THREE.Color( 0xffaa00 ); + color.setRGB( srcColors[ c ], srcColors[ c + 1 ], srcColors[ c + 2 ] ); + dstColors.push( color ); + + } + + } + + } + + }; + + if ( json.materials === undefined || json.materials.length === 0 ) { + + return { geometry: geometry }; + + } else { + + var materials = this.initMaterials( json.materials, texturePath ); + + if ( this.needsTangents( materials ) ) { + + geometry.computeTangents(); + + } + + return { geometry: geometry, materials: materials }; + + } + +}; diff --git a/src/loaders/Loader.js b/src/loaders/Loader.js index 47df6903fe6c0..076b48bab9c67 100644 --- a/src/loaders/Loader.js +++ b/src/loaders/Loader.js @@ -1,446 +1,446 @@ /** * @author alteredq / http://alteredqualia.com/ - */ - -THREE.Loader = function ( showStatus ) { - - this.showStatus = showStatus; - this.statusDomElement = showStatus ? THREE.Loader.prototype.addStatusElement() : null; - - this.imageLoader = new THREE.ImageLoader(); - - this.onLoadStart = function () {}; - this.onLoadProgress = function () {}; - this.onLoadComplete = function () {}; - -}; - -THREE.Loader.prototype = { - - constructor: THREE.Loader, - - crossOrigin: undefined, - - addStatusElement: function () { - - var e = document.createElement( "div" ); - - e.style.position = "absolute"; - e.style.right = "0px"; - e.style.top = "0px"; - e.style.fontSize = "0.8em"; - e.style.textAlign = "left"; - e.style.background = "rgba(0,0,0,0.25)"; - e.style.color = "#fff"; - e.style.width = "120px"; - e.style.padding = "0.5em 0.5em 0.5em 0.5em"; - e.style.zIndex = 1000; - - e.innerHTML = "Loading ..."; - - return e; - - }, - - updateProgress: function ( progress ) { - - var message = "Loaded "; - - if ( progress.total ) { - - message += ( 100 * progress.loaded / progress.total ).toFixed(0) + "%"; - - - } else { - - message += ( progress.loaded / 1024 ).toFixed(2) + " KB"; - - } - - this.statusDomElement.innerHTML = message; - - }, - - extractUrlBase: function ( url ) { - - var parts = url.split( '/' ); - - if ( parts.length === 1 ) return './'; - - parts.pop(); - - return parts.join( '/' ) + '/'; - - }, - - initMaterials: function ( materials, texturePath ) { - - var array = []; - - for ( var i = 0; i < materials.length; ++ i ) { - - array[ i ] = this.createMaterial( materials[ i ], texturePath ); - - } - - return array; - - }, - - needsTangents: function ( materials ) { - - for( var i = 0, il = materials.length; i < il; i ++ ) { - - var m = materials[ i ]; - - if ( m instanceof THREE.ShaderMaterial ) return true; - - } - - return false; - - }, - - createMaterial: function ( m, texturePath ) { - - var scope = this; - - function nearest_pow2( n ) { - - var l = Math.log( n ) / Math.LN2; - return Math.pow( 2, Math.round( l ) ); - - } - - function create_texture( where, name, sourceFile, repeat, offset, wrap, anisotropy ) { - - var isCompressed = /\.dds$/i.test( sourceFile ); - var isTGA = /\.tga$/i.test( sourceFile ); - - var fullPath = texturePath + sourceFile; - - if ( isCompressed ) { - - var texture = THREE.ImageUtils.loadCompressedTexture( fullPath ); - - where[ name ] = texture; - - } else if ( isTGA ) { - - var texture = THREE.ImageUtils.loadTGATexture( fullPath ); - - where[ name ] = texture; - } else { - - var texture = document.createElement( 'canvas' ); - - where[ name ] = new THREE.Texture( texture ); - - } - - where[ name ].sourceFile = sourceFile; - - if( repeat ) { - - where[ name ].repeat.set( repeat[ 0 ], repeat[ 1 ] ); - - if ( repeat[ 0 ] !== 1 ) where[ name ].wrapS = THREE.RepeatWrapping; - if ( repeat[ 1 ] !== 1 ) where[ name ].wrapT = THREE.RepeatWrapping; - - } - - if ( offset ) { - - where[ name ].offset.set( offset[ 0 ], offset[ 1 ] ); - - } - - if ( wrap ) { - - var wrapMap = { - "repeat": THREE.RepeatWrapping, - "mirror": THREE.MirroredRepeatWrapping - } - - if ( wrapMap[ wrap[ 0 ] ] !== undefined ) where[ name ].wrapS = wrapMap[ wrap[ 0 ] ]; - if ( wrapMap[ wrap[ 1 ] ] !== undefined ) where[ name ].wrapT = wrapMap[ wrap[ 1 ] ]; - - } - - if ( anisotropy ) { - - where[ name ].anisotropy = anisotropy; - - } - - if ( ! isCompressed ) { - - var texture = where[ name ]; - - scope.imageLoader.crossOrigin = scope.crossOrigin; - scope.imageLoader.load( fullPath, function ( image ) { - - if ( THREE.Math.isPowerOfTwo( image.width ) === false || - THREE.Math.isPowerOfTwo( image.height ) === false ) { - - var width = nearest_pow2( image.width ); - var height = nearest_pow2( image.height ); - - texture.image.width = width; - texture.image.height = height; - texture.image.getContext( '2d' ).drawImage( image, 0, 0, width, height ); - - } else { - - texture.image = image; - - } - - texture.needsUpdate = true; - - } ); - - } - - } - - function rgb2hex( rgb ) { - - return ( rgb[ 0 ] * 255 << 16 ) + ( rgb[ 1 ] * 255 << 8 ) + rgb[ 2 ] * 255; - - } - - // defaults - - var mtype = "MeshLambertMaterial"; - var mpars = { color: 0xeeeeee, opacity: 1.0, map: null, lightMap: null, normalMap: null, bumpMap: null, wireframe: false }; - - // parameters from model file - - if ( m.shading ) { - - var shading = m.shading.toLowerCase(); - - if ( shading === "phong" ) mtype = "MeshPhongMaterial"; - else if ( shading === "basic" ) mtype = "MeshBasicMaterial"; - - } - - if ( m.blending !== undefined && THREE[ m.blending ] !== undefined ) { - - mpars.blending = THREE[ m.blending ]; - - } - - if ( m.transparent !== undefined || m.opacity < 1.0 ) { - - mpars.transparent = m.transparent; - - } - - if ( m.depthTest !== undefined ) { - - mpars.depthTest = m.depthTest; - - } - - if ( m.depthWrite !== undefined ) { - - mpars.depthWrite = m.depthWrite; - - } - - if ( m.visible !== undefined ) { - - mpars.visible = m.visible; - - } - - if ( m.flipSided !== undefined ) { - - mpars.side = THREE.BackSide; - - } - - if ( m.doubleSided !== undefined ) { - - mpars.side = THREE.DoubleSide; - - } - - if ( m.wireframe !== undefined ) { - - mpars.wireframe = m.wireframe; - - } - - if ( m.vertexColors !== undefined ) { - - if ( m.vertexColors === "face" ) { - - mpars.vertexColors = THREE.FaceColors; - - } else if ( m.vertexColors ) { - - mpars.vertexColors = THREE.VertexColors; - - } - - } - - // colors - - if ( m.colorDiffuse ) { - - mpars.color = rgb2hex( m.colorDiffuse ); - - } else if ( m.DbgColor ) { - - mpars.color = m.DbgColor; - - } - - if ( m.colorSpecular ) { - - mpars.specular = rgb2hex( m.colorSpecular ); - - } - - if ( m.colorAmbient ) { - - mpars.ambient = rgb2hex( m.colorAmbient ); - - } - - if ( m.colorEmissive ) { - - mpars.emissive = rgb2hex( m.colorEmissive ); - - } - - // modifiers - - if ( m.transparency ) { - - mpars.opacity = m.transparency; - - } - - if ( m.specularCoef ) { - - mpars.shininess = m.specularCoef; - - } - - // textures - - if ( m.mapDiffuse && texturePath ) { - - create_texture( mpars, "map", m.mapDiffuse, m.mapDiffuseRepeat, m.mapDiffuseOffset, m.mapDiffuseWrap, m.mapDiffuseAnisotropy ); - - } - - if ( m.mapLight && texturePath ) { - - create_texture( mpars, "lightMap", m.mapLight, m.mapLightRepeat, m.mapLightOffset, m.mapLightWrap, m.mapLightAnisotropy ); - - } - - if ( m.mapBump && texturePath ) { - - create_texture( mpars, "bumpMap", m.mapBump, m.mapBumpRepeat, m.mapBumpOffset, m.mapBumpWrap, m.mapBumpAnisotropy ); - - } - - if ( m.mapNormal && texturePath ) { - - create_texture( mpars, "normalMap", m.mapNormal, m.mapNormalRepeat, m.mapNormalOffset, m.mapNormalWrap, m.mapNormalAnisotropy ); - - } - - if ( m.mapSpecular && texturePath ) { - - create_texture( mpars, "specularMap", m.mapSpecular, m.mapSpecularRepeat, m.mapSpecularOffset, m.mapSpecularWrap, m.mapSpecularAnisotropy ); - - } - - // - - if ( m.mapBumpScale ) { - - mpars.bumpScale = m.mapBumpScale; - - } - - // special case for normal mapped material - - if ( m.mapNormal ) { - - var shader = THREE.ShaderLib[ "normalmap" ]; - var uniforms = THREE.UniformsUtils.clone( shader.uniforms ); - - uniforms[ "tNormal" ].value = mpars.normalMap; - - if ( m.mapNormalFactor ) { - - uniforms[ "uNormalScale" ].value.set( m.mapNormalFactor, m.mapNormalFactor ); - - } - - if ( mpars.map ) { - - uniforms[ "tDiffuse" ].value = mpars.map; - uniforms[ "enableDiffuse" ].value = true; - - } - - if ( mpars.specularMap ) { - - uniforms[ "tSpecular" ].value = mpars.specularMap; - uniforms[ "enableSpecular" ].value = true; - - } - - if ( mpars.lightMap ) { - - uniforms[ "tAO" ].value = mpars.lightMap; - uniforms[ "enableAO" ].value = true; - - } - - // for the moment don't handle displacement texture - - uniforms[ "diffuse" ].value.setHex( mpars.color ); - uniforms[ "specular" ].value.setHex( mpars.specular ); - uniforms[ "ambient" ].value.setHex( mpars.ambient ); - - uniforms[ "shininess" ].value = mpars.shininess; - - if ( mpars.opacity !== undefined ) { - - uniforms[ "opacity" ].value = mpars.opacity; - - } - - var parameters = { fragmentShader: shader.fragmentShader, vertexShader: shader.vertexShader, uniforms: uniforms, lights: true, fog: true }; - var material = new THREE.ShaderMaterial( parameters ); - - if ( mpars.transparent ) { - - material.transparent = true; - - } - - } else { - - var material = new THREE[ mtype ]( mpars ); - - } - - if ( m.DbgName !== undefined ) material.name = m.DbgName; - - return material; - - } - -}; + */ + +THREE.Loader = function ( showStatus ) { + + this.showStatus = showStatus; + this.statusDomElement = showStatus ? THREE.Loader.prototype.addStatusElement() : null; + + this.imageLoader = new THREE.ImageLoader(); + + this.onLoadStart = function () {}; + this.onLoadProgress = function () {}; + this.onLoadComplete = function () {}; + +}; + +THREE.Loader.prototype = { + + constructor: THREE.Loader, + + crossOrigin: undefined, + + addStatusElement: function () { + + var e = document.createElement( 'div' ); + + e.style.position = 'absolute'; + e.style.right = '0px'; + e.style.top = '0px'; + e.style.fontSize = '0.8em'; + e.style.textAlign = 'left'; + e.style.background = 'rgba(0,0,0,0.25)'; + e.style.color = '#fff'; + e.style.width = '120px'; + e.style.padding = '0.5em 0.5em 0.5em 0.5em'; + e.style.zIndex = 1000; + + e.innerHTML = 'Loading ...'; + + return e; + + }, + + updateProgress: function ( progress ) { + + var message = 'Loaded '; + + if ( progress.total ) { + + message += ( 100 * progress.loaded / progress.total ).toFixed( 0 ) + '%'; + + + } else { + + message += ( progress.loaded / 1024 ).toFixed( 2 ) + ' KB'; + + } + + this.statusDomElement.innerHTML = message; + + }, + + extractUrlBase: function ( url ) { + + var parts = url.split( '/' ); + + if ( parts.length === 1 ) return './'; + + parts.pop(); + + return parts.join( '/' ) + '/'; + + }, + + initMaterials: function ( materials, texturePath ) { + + var array = []; + + for ( var i = 0; i < materials.length; ++ i ) { + + array[ i ] = this.createMaterial( materials[ i ], texturePath ); + + } + + return array; + + }, + + needsTangents: function ( materials ) { + + for ( var i = 0, il = materials.length; i < il; i ++ ) { + + var m = materials[ i ]; + + if ( m instanceof THREE.ShaderMaterial ) return true; + + } + + return false; + + }, + + createMaterial: function ( m, texturePath ) { + + var scope = this; + + function nearest_pow2( n ) { + + var l = Math.log( n ) / Math.LN2; + return Math.pow( 2, Math.round( l ) ); + + } + + function create_texture( where, name, sourceFile, repeat, offset, wrap, anisotropy ) { + + var isCompressed = /\.dds$/i.test( sourceFile ); + var isTGA = /\.tga$/i.test( sourceFile ); + + var fullPath = texturePath + sourceFile; + + if ( isCompressed ) { + + var texture = THREE.ImageUtils.loadCompressedTexture( fullPath ); + + where[ name ] = texture; + + } else if ( isTGA ) { + + var texture = THREE.ImageUtils.loadTGATexture( fullPath ); + + where[ name ] = texture; + } else { + + var texture = document.createElement( 'canvas' ); + + where[ name ] = new THREE.Texture( texture ); + + } + + where[ name ].sourceFile = sourceFile; + + if ( repeat ) { + + where[ name ].repeat.set( repeat[ 0 ], repeat[ 1 ] ); + + if ( repeat[ 0 ] !== 1 ) where[ name ].wrapS = THREE.RepeatWrapping; + if ( repeat[ 1 ] !== 1 ) where[ name ].wrapT = THREE.RepeatWrapping; + + } + + if ( offset ) { + + where[ name ].offset.set( offset[ 0 ], offset[ 1 ] ); + + } + + if ( wrap ) { + + var wrapMap = { + 'repeat': THREE.RepeatWrapping, + 'mirror': THREE.MirroredRepeatWrapping + } + + if ( wrapMap[ wrap[ 0 ] ] !== undefined ) where[ name ].wrapS = wrapMap[ wrap[ 0 ] ]; + if ( wrapMap[ wrap[ 1 ] ] !== undefined ) where[ name ].wrapT = wrapMap[ wrap[ 1 ] ]; + + } + + if ( anisotropy ) { + + where[ name ].anisotropy = anisotropy; + + } + + if ( !isCompressed ) { + + var texture = where[ name ]; + + scope.imageLoader.crossOrigin = scope.crossOrigin; + scope.imageLoader.load( fullPath, function ( image ) { + + if ( THREE.Math.isPowerOfTwo( image.width ) === false || + THREE.Math.isPowerOfTwo( image.height ) === false ) { + + var width = nearest_pow2( image.width ); + var height = nearest_pow2( image.height ); + + texture.image.width = width; + texture.image.height = height; + texture.image.getContext( '2d' ).drawImage( image, 0, 0, width, height ); + + } else { + + texture.image = image; + + } + + texture.needsUpdate = true; + + } ); + + } + + } + + function rgb2hex( rgb ) { + + return ( rgb[ 0 ] * 255 << 16 ) + ( rgb[ 1 ] * 255 << 8 ) + rgb[ 2 ] * 255; + + } + + // defaults + + var mtype = 'MeshLambertMaterial'; + var mpars = { color: 0xeeeeee, opacity: 1.0, map: null, lightMap: null, normalMap: null, bumpMap: null, wireframe: false }; + + // parameters from model file + + if ( m.shading ) { + + var shading = m.shading.toLowerCase(); + + if ( shading === 'phong' ) mtype = 'MeshPhongMaterial'; + else if ( shading === 'basic' ) mtype = 'MeshBasicMaterial'; + + } + + if ( m.blending !== undefined && THREE[ m.blending ] !== undefined ) { + + mpars.blending = THREE[ m.blending ]; + + } + + if ( m.transparent !== undefined || m.opacity < 1.0 ) { + + mpars.transparent = m.transparent; + + } + + if ( m.depthTest !== undefined ) { + + mpars.depthTest = m.depthTest; + + } + + if ( m.depthWrite !== undefined ) { + + mpars.depthWrite = m.depthWrite; + + } + + if ( m.visible !== undefined ) { + + mpars.visible = m.visible; + + } + + if ( m.flipSided !== undefined ) { + + mpars.side = THREE.BackSide; + + } + + if ( m.doubleSided !== undefined ) { + + mpars.side = THREE.DoubleSide; + + } + + if ( m.wireframe !== undefined ) { + + mpars.wireframe = m.wireframe; + + } + + if ( m.vertexColors !== undefined ) { + + if ( m.vertexColors === 'face' ) { + + mpars.vertexColors = THREE.FaceColors; + + } else if ( m.vertexColors ) { + + mpars.vertexColors = THREE.VertexColors; + + } + + } + + // colors + + if ( m.colorDiffuse ) { + + mpars.color = rgb2hex( m.colorDiffuse ); + + } else if ( m.DbgColor ) { + + mpars.color = m.DbgColor; + + } + + if ( m.colorSpecular ) { + + mpars.specular = rgb2hex( m.colorSpecular ); + + } + + if ( m.colorAmbient ) { + + mpars.ambient = rgb2hex( m.colorAmbient ); + + } + + if ( m.colorEmissive ) { + + mpars.emissive = rgb2hex( m.colorEmissive ); + + } + + // modifiers + + if ( m.transparency ) { + + mpars.opacity = m.transparency; + + } + + if ( m.specularCoef ) { + + mpars.shininess = m.specularCoef; + + } + + // textures + + if ( m.mapDiffuse && texturePath ) { + + create_texture( mpars, 'map', m.mapDiffuse, m.mapDiffuseRepeat, m.mapDiffuseOffset, m.mapDiffuseWrap, m.mapDiffuseAnisotropy ); + + } + + if ( m.mapLight && texturePath ) { + + create_texture( mpars, 'lightMap', m.mapLight, m.mapLightRepeat, m.mapLightOffset, m.mapLightWrap, m.mapLightAnisotropy ); + + } + + if ( m.mapBump && texturePath ) { + + create_texture( mpars, 'bumpMap', m.mapBump, m.mapBumpRepeat, m.mapBumpOffset, m.mapBumpWrap, m.mapBumpAnisotropy ); + + } + + if ( m.mapNormal && texturePath ) { + + create_texture( mpars, 'normalMap', m.mapNormal, m.mapNormalRepeat, m.mapNormalOffset, m.mapNormalWrap, m.mapNormalAnisotropy ); + + } + + if ( m.mapSpecular && texturePath ) { + + create_texture( mpars, 'specularMap', m.mapSpecular, m.mapSpecularRepeat, m.mapSpecularOffset, m.mapSpecularWrap, m.mapSpecularAnisotropy ); + + } + + // + + if ( m.mapBumpScale ) { + + mpars.bumpScale = m.mapBumpScale; + + } + + // special case for normal mapped material + + if ( m.mapNormal ) { + + var shader = THREE.ShaderLib[ 'normalmap' ]; + var uniforms = THREE.UniformsUtils.clone( shader.uniforms ); + + uniforms[ 'tNormal' ].value = mpars.normalMap; + + if ( m.mapNormalFactor ) { + + uniforms[ 'uNormalScale' ].value.set( m.mapNormalFactor, m.mapNormalFactor ); + + } + + if ( mpars.map ) { + + uniforms[ 'tDiffuse' ].value = mpars.map; + uniforms[ 'enableDiffuse' ].value = true; + + } + + if ( mpars.specularMap ) { + + uniforms[ 'tSpecular' ].value = mpars.specularMap; + uniforms[ 'enableSpecular' ].value = true; + + } + + if ( mpars.lightMap ) { + + uniforms[ 'tAO' ].value = mpars.lightMap; + uniforms[ 'enableAO' ].value = true; + + } + + // for the moment don't handle displacement texture + + uniforms[ 'diffuse' ].value.setHex( mpars.color ); + uniforms[ 'specular' ].value.setHex( mpars.specular ); + uniforms[ 'ambient' ].value.setHex( mpars.ambient ); + + uniforms[ 'shininess' ].value = mpars.shininess; + + if ( mpars.opacity !== undefined ) { + + uniforms[ 'opacity' ].value = mpars.opacity; + + } + + var parameters = { fragmentShader: shader.fragmentShader, vertexShader: shader.vertexShader, uniforms: uniforms, lights: true, fog: true }; + var material = new THREE.ShaderMaterial( parameters ); + + if ( mpars.transparent ) { + + material.transparent = true; + + } + + } else { + + var material = new THREE[ mtype ]( mpars ); + + } + + if ( m.DbgName !== undefined ) material.name = m.DbgName; + + return material; + + } + +}; diff --git a/src/loaders/MaterialLoader.js b/src/loaders/MaterialLoader.js index 036dec9ca0aa0..49c257b23e045 100644 --- a/src/loaders/MaterialLoader.js +++ b/src/loaders/MaterialLoader.js @@ -1,65 +1,65 @@ /** * @author mrdoob / http://mrdoob.com/ - */ - -THREE.MaterialLoader = function ( manager ) { - - this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; - -}; - -THREE.MaterialLoader.prototype = { - - constructor: THREE.MaterialLoader, - - load: function ( url, onLoad, onProgress, onError ) { - - var scope = this; - - var loader = new THREE.XHRLoader(); - loader.setCrossOrigin( this.crossOrigin ); - loader.load( url, function ( text ) { - - onLoad( scope.parse( JSON.parse( text ) ) ); - - } ); - - }, - - setCrossOrigin: function ( value ) { - - this.crossOrigin = value; - - }, - - parse: function ( json ) { - - var material = new THREE[ json.type ]; - - if ( json.color !== undefined ) material.color.setHex( json.color ); - if ( json.ambient !== undefined ) material.ambient.setHex( json.ambient ); - if ( json.emissive !== undefined ) material.emissive.setHex( json.emissive ); - if ( json.specular !== undefined ) material.specular.setHex( json.specular ); - if ( json.shininess !== undefined ) material.shininess = json.shininess; - if ( json.vertexColors !== undefined ) material.vertexColors = json.vertexColors; - if ( json.blending !== undefined ) material.blending = json.blending; - if ( json.side !== undefined ) material.side = json.side; - if ( json.opacity !== undefined ) material.opacity = json.opacity; - if ( json.transparent !== undefined ) material.transparent = json.transparent; - if ( json.wireframe !== undefined ) material.wireframe = json.wireframe; - - if ( json.materials !== undefined ) { - - for ( var i = 0, l = json.materials.length; i < l; i ++ ) { - - material.materials.push( this.parse( json.materials[ i ] ) ); - - } - - } - - return material; - - } - -}; + */ + +THREE.MaterialLoader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + +}; + +THREE.MaterialLoader.prototype = { + + constructor: THREE.MaterialLoader, + + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + + var loader = new THREE.XHRLoader(); + loader.setCrossOrigin( this.crossOrigin ); + loader.load( url, function ( text ) { + + onLoad( scope.parse( JSON.parse( text ) ) ); + + } ); + + }, + + setCrossOrigin: function ( value ) { + + this.crossOrigin = value; + + }, + + parse: function ( json ) { + + var material = new THREE[ json.type ]; + + if ( json.color !== undefined ) material.color.setHex( json.color ); + if ( json.ambient !== undefined ) material.ambient.setHex( json.ambient ); + if ( json.emissive !== undefined ) material.emissive.setHex( json.emissive ); + if ( json.specular !== undefined ) material.specular.setHex( json.specular ); + if ( json.shininess !== undefined ) material.shininess = json.shininess; + if ( json.vertexColors !== undefined ) material.vertexColors = json.vertexColors; + if ( json.blending !== undefined ) material.blending = json.blending; + if ( json.side !== undefined ) material.side = json.side; + if ( json.opacity !== undefined ) material.opacity = json.opacity; + if ( json.transparent !== undefined ) material.transparent = json.transparent; + if ( json.wireframe !== undefined ) material.wireframe = json.wireframe; + + if ( json.materials !== undefined ) { + + for ( var i = 0, l = json.materials.length; i < l; i ++ ) { + + material.materials.push( this.parse( json.materials[ i ] ) ); + + } + + } + + return material; + + } + +}; diff --git a/src/loaders/SVGLoader.js b/src/loaders/SVGLoader.js index 83b45b5b08da7..a9cce65c17788 100644 --- a/src/loaders/SVGLoader.js +++ b/src/loaders/SVGLoader.js @@ -1,31 +1,31 @@ /** * @author mrdoob / http://mrdoob.com/ * @author zz85 / http://joshuakoo.com/ - */ - -THREE.SVGLoader = function ( manager ) { - - this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; - -}; - -THREE.SVGLoader.prototype = { - - constructor: THREE.MaterialLoader, - - load: function ( url, onLoad, onProgress, onError ) { - - var parser = new DOMParser(); - - var loader = new THREE.XHRLoader(); - loader.setCrossOrigin( this.crossOrigin ); - loader.load( url, function ( svgString ) { - - var doc = parser.parseFromString( svgString, 'image/svg+xml' ); // application/xml - - onLoad( doc.firstChild ); - - } ); - - } -}; \ No newline at end of file + */ + +THREE.SVGLoader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + +}; + +THREE.SVGLoader.prototype = { + + constructor: THREE.MaterialLoader, + + load: function ( url, onLoad, onProgress, onError ) { + + var parser = new DOMParser(); + + var loader = new THREE.XHRLoader(); + loader.setCrossOrigin( this.crossOrigin ); + loader.load( url, function ( svgString ) { + + var doc = parser.parseFromString( svgString, 'image/svg+xml' ); // application/xml + + onLoad( doc.firstChild ); + + } ); + + } +}; diff --git a/src/materials/Material.js b/src/materials/Material.js index 004ead106933e..936cf0a60a0e8 100644 --- a/src/materials/Material.js +++ b/src/materials/Material.js @@ -52,7 +52,7 @@ THREE.Material.prototype = { if ( newValue === undefined ) { - console.warn( 'THREE.Material: \'' + key + '\' parameter is undefined.' ); + console.warn( "THREE.Material: '" + key + "' parameter is undefined." ); continue; } @@ -69,10 +69,10 @@ THREE.Material.prototype = { currentValue.copy( newValue ); - } else if ( key == 'overdraw') { + } else if ( key == 'overdraw' ) { // ensure overdraw is backwards-compatable with legacy boolean type - this[ key ] = Number(newValue); + this[ key ] = Number( newValue ); } else { diff --git a/src/materials/ShaderMaterial.js b/src/materials/ShaderMaterial.js index 6b9429a741e89..c6471aaef7024 100644 --- a/src/materials/ShaderMaterial.js +++ b/src/materials/ShaderMaterial.js @@ -33,8 +33,8 @@ THREE.ShaderMaterial = function ( parameters ) { THREE.Material.call( this ); - this.fragmentShader = "void main() {}"; - this.vertexShader = "void main() {}"; + this.fragmentShader = 'void main() {}'; + this.vertexShader = 'void main() {}'; this.uniforms = {}; this.defines = {}; this.attributes = null; @@ -60,9 +60,9 @@ THREE.ShaderMaterial = function ( parameters ) { // When rendered geometry doesn't include these attributes but the material does, // use these default values in WebGL. This avoids errors when buffer data is missing. this.defaultAttributeValues = { - "color" : [ 1, 1, 1 ], - "uv" : [ 0, 0 ], - "uv2" : [ 0, 0 ] + 'color': [ 1, 1, 1 ], + 'uv': [ 0, 0 ], + 'uv2': [ 0, 0 ] }; this.index0AttributeName = undefined; diff --git a/src/materials/SpriteCanvasMaterial.js b/src/materials/SpriteCanvasMaterial.js index 9da3c873caf9d..b71202e8b79e7 100644 --- a/src/materials/SpriteCanvasMaterial.js +++ b/src/materials/SpriteCanvasMaterial.js @@ -37,4 +37,4 @@ THREE.SpriteCanvasMaterial.prototype.clone = function () { // backwards compatibility -THREE.ParticleCanvasMaterial = THREE.SpriteCanvasMaterial; \ No newline at end of file +THREE.ParticleCanvasMaterial = THREE.SpriteCanvasMaterial; diff --git a/src/math/Box3.js b/src/math/Box3.js index bad1fc30f3508..c78418e46f390 100644 --- a/src/math/Box3.js +++ b/src/math/Box3.js @@ -54,7 +54,7 @@ THREE.Box3.prototype = { this.max.z = point.z; } - + return this; }, @@ -84,7 +84,7 @@ THREE.Box3.prototype = { }, - setFromCenterAndSize: function() { + setFromCenterAndSize: function () { var v1 = new THREE.Vector3(); @@ -101,14 +101,14 @@ THREE.Box3.prototype = { }(), - setFromObject: function() { + setFromObject: function () { // Computes the world-axis-aligned bounding box of an object (including its children), // accounting for both the object's, and childrens', world transforms var v1 = new THREE.Vector3(); - return function( object ) { + return function ( object ) { var scope = this; @@ -275,7 +275,7 @@ THREE.Box3.prototype = { }, - distanceToPoint: function() { + distanceToPoint: function () { var v1 = new THREE.Vector3(); @@ -288,7 +288,7 @@ THREE.Box3.prototype = { }(), - getBoundingSphere: function() { + getBoundingSphere: function () { var v1 = new THREE.Vector3(); @@ -323,7 +323,7 @@ THREE.Box3.prototype = { }, - applyMatrix4: function() { + applyMatrix4: function () { var points = [ new THREE.Vector3(), @@ -339,14 +339,14 @@ THREE.Box3.prototype = { return function ( matrix ) { // NOTE: I am using a binary pattern to specify all 2^3 combinations below - points[0].set( this.min.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 000 - points[1].set( this.min.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 001 - points[2].set( this.min.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 010 - points[3].set( this.min.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 011 - points[4].set( this.max.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 100 - points[5].set( this.max.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 101 - points[6].set( this.max.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 110 - points[7].set( this.max.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 111 + points[ 0 ].set( this.min.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 000 + points[ 1 ].set( this.min.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 001 + points[ 2 ].set( this.min.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 010 + points[ 3 ].set( this.min.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 011 + points[ 4 ].set( this.max.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 100 + points[ 5 ].set( this.max.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 101 + points[ 6 ].set( this.max.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 110 + points[ 7 ].set( this.max.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 111 this.makeEmpty(); this.setFromPoints( points ); diff --git a/src/math/Color.js b/src/math/Color.js index f98c0a599c98d..d00573d1908cf 100644 --- a/src/math/Color.js +++ b/src/math/Color.js @@ -380,27 +380,27 @@ THREE.Color.prototype = { }; -THREE.ColorKeywords = { "aliceblue": 0xF0F8FF, "antiquewhite": 0xFAEBD7, "aqua": 0x00FFFF, "aquamarine": 0x7FFFD4, "azure": 0xF0FFFF, -"beige": 0xF5F5DC, "bisque": 0xFFE4C4, "black": 0x000000, "blanchedalmond": 0xFFEBCD, "blue": 0x0000FF, "blueviolet": 0x8A2BE2, -"brown": 0xA52A2A, "burlywood": 0xDEB887, "cadetblue": 0x5F9EA0, "chartreuse": 0x7FFF00, "chocolate": 0xD2691E, "coral": 0xFF7F50, -"cornflowerblue": 0x6495ED, "cornsilk": 0xFFF8DC, "crimson": 0xDC143C, "cyan": 0x00FFFF, "darkblue": 0x00008B, "darkcyan": 0x008B8B, -"darkgoldenrod": 0xB8860B, "darkgray": 0xA9A9A9, "darkgreen": 0x006400, "darkgrey": 0xA9A9A9, "darkkhaki": 0xBDB76B, "darkmagenta": 0x8B008B, -"darkolivegreen": 0x556B2F, "darkorange": 0xFF8C00, "darkorchid": 0x9932CC, "darkred": 0x8B0000, "darksalmon": 0xE9967A, "darkseagreen": 0x8FBC8F, -"darkslateblue": 0x483D8B, "darkslategray": 0x2F4F4F, "darkslategrey": 0x2F4F4F, "darkturquoise": 0x00CED1, "darkviolet": 0x9400D3, -"deeppink": 0xFF1493, "deepskyblue": 0x00BFFF, "dimgray": 0x696969, "dimgrey": 0x696969, "dodgerblue": 0x1E90FF, "firebrick": 0xB22222, -"floralwhite": 0xFFFAF0, "forestgreen": 0x228B22, "fuchsia": 0xFF00FF, "gainsboro": 0xDCDCDC, "ghostwhite": 0xF8F8FF, "gold": 0xFFD700, -"goldenrod": 0xDAA520, "gray": 0x808080, "green": 0x008000, "greenyellow": 0xADFF2F, "grey": 0x808080, "honeydew": 0xF0FFF0, "hotpink": 0xFF69B4, -"indianred": 0xCD5C5C, "indigo": 0x4B0082, "ivory": 0xFFFFF0, "khaki": 0xF0E68C, "lavender": 0xE6E6FA, "lavenderblush": 0xFFF0F5, "lawngreen": 0x7CFC00, -"lemonchiffon": 0xFFFACD, "lightblue": 0xADD8E6, "lightcoral": 0xF08080, "lightcyan": 0xE0FFFF, "lightgoldenrodyellow": 0xFAFAD2, "lightgray": 0xD3D3D3, -"lightgreen": 0x90EE90, "lightgrey": 0xD3D3D3, "lightpink": 0xFFB6C1, "lightsalmon": 0xFFA07A, "lightseagreen": 0x20B2AA, "lightskyblue": 0x87CEFA, -"lightslategray": 0x778899, "lightslategrey": 0x778899, "lightsteelblue": 0xB0C4DE, "lightyellow": 0xFFFFE0, "lime": 0x00FF00, "limegreen": 0x32CD32, -"linen": 0xFAF0E6, "magenta": 0xFF00FF, "maroon": 0x800000, "mediumaquamarine": 0x66CDAA, "mediumblue": 0x0000CD, "mediumorchid": 0xBA55D3, -"mediumpurple": 0x9370DB, "mediumseagreen": 0x3CB371, "mediumslateblue": 0x7B68EE, "mediumspringgreen": 0x00FA9A, "mediumturquoise": 0x48D1CC, -"mediumvioletred": 0xC71585, "midnightblue": 0x191970, "mintcream": 0xF5FFFA, "mistyrose": 0xFFE4E1, "moccasin": 0xFFE4B5, "navajowhite": 0xFFDEAD, -"navy": 0x000080, "oldlace": 0xFDF5E6, "olive": 0x808000, "olivedrab": 0x6B8E23, "orange": 0xFFA500, "orangered": 0xFF4500, "orchid": 0xDA70D6, -"palegoldenrod": 0xEEE8AA, "palegreen": 0x98FB98, "paleturquoise": 0xAFEEEE, "palevioletred": 0xDB7093, "papayawhip": 0xFFEFD5, "peachpuff": 0xFFDAB9, -"peru": 0xCD853F, "pink": 0xFFC0CB, "plum": 0xDDA0DD, "powderblue": 0xB0E0E6, "purple": 0x800080, "red": 0xFF0000, "rosybrown": 0xBC8F8F, -"royalblue": 0x4169E1, "saddlebrown": 0x8B4513, "salmon": 0xFA8072, "sandybrown": 0xF4A460, "seagreen": 0x2E8B57, "seashell": 0xFFF5EE, -"sienna": 0xA0522D, "silver": 0xC0C0C0, "skyblue": 0x87CEEB, "slateblue": 0x6A5ACD, "slategray": 0x708090, "slategrey": 0x708090, "snow": 0xFFFAFA, -"springgreen": 0x00FF7F, "steelblue": 0x4682B4, "tan": 0xD2B48C, "teal": 0x008080, "thistle": 0xD8BFD8, "tomato": 0xFF6347, "turquoise": 0x40E0D0, -"violet": 0xEE82EE, "wheat": 0xF5DEB3, "white": 0xFFFFFF, "whitesmoke": 0xF5F5F5, "yellow": 0xFFFF00, "yellowgreen": 0x9ACD32 }; +THREE.ColorKeywords = { 'aliceblue': 0xF0F8FF, 'antiquewhite': 0xFAEBD7, 'aqua': 0x00FFFF, 'aquamarine': 0x7FFFD4, 'azure': 0xF0FFFF, +'beige': 0xF5F5DC, 'bisque': 0xFFE4C4, 'black': 0x000000, 'blanchedalmond': 0xFFEBCD, 'blue': 0x0000FF, 'blueviolet': 0x8A2BE2, +'brown': 0xA52A2A, 'burlywood': 0xDEB887, 'cadetblue': 0x5F9EA0, 'chartreuse': 0x7FFF00, 'chocolate': 0xD2691E, 'coral': 0xFF7F50, +'cornflowerblue': 0x6495ED, 'cornsilk': 0xFFF8DC, 'crimson': 0xDC143C, 'cyan': 0x00FFFF, 'darkblue': 0x00008B, 'darkcyan': 0x008B8B, +'darkgoldenrod': 0xB8860B, 'darkgray': 0xA9A9A9, 'darkgreen': 0x006400, 'darkgrey': 0xA9A9A9, 'darkkhaki': 0xBDB76B, 'darkmagenta': 0x8B008B, +'darkolivegreen': 0x556B2F, 'darkorange': 0xFF8C00, 'darkorchid': 0x9932CC, 'darkred': 0x8B0000, 'darksalmon': 0xE9967A, 'darkseagreen': 0x8FBC8F, +'darkslateblue': 0x483D8B, 'darkslategray': 0x2F4F4F, 'darkslategrey': 0x2F4F4F, 'darkturquoise': 0x00CED1, 'darkviolet': 0x9400D3, +'deeppink': 0xFF1493, 'deepskyblue': 0x00BFFF, 'dimgray': 0x696969, 'dimgrey': 0x696969, 'dodgerblue': 0x1E90FF, 'firebrick': 0xB22222, +'floralwhite': 0xFFFAF0, 'forestgreen': 0x228B22, 'fuchsia': 0xFF00FF, 'gainsboro': 0xDCDCDC, 'ghostwhite': 0xF8F8FF, 'gold': 0xFFD700, +'goldenrod': 0xDAA520, 'gray': 0x808080, 'green': 0x008000, 'greenyellow': 0xADFF2F, 'grey': 0x808080, 'honeydew': 0xF0FFF0, 'hotpink': 0xFF69B4, +'indianred': 0xCD5C5C, 'indigo': 0x4B0082, 'ivory': 0xFFFFF0, 'khaki': 0xF0E68C, 'lavender': 0xE6E6FA, 'lavenderblush': 0xFFF0F5, 'lawngreen': 0x7CFC00, +'lemonchiffon': 0xFFFACD, 'lightblue': 0xADD8E6, 'lightcoral': 0xF08080, 'lightcyan': 0xE0FFFF, 'lightgoldenrodyellow': 0xFAFAD2, 'lightgray': 0xD3D3D3, +'lightgreen': 0x90EE90, 'lightgrey': 0xD3D3D3, 'lightpink': 0xFFB6C1, 'lightsalmon': 0xFFA07A, 'lightseagreen': 0x20B2AA, 'lightskyblue': 0x87CEFA, +'lightslategray': 0x778899, 'lightslategrey': 0x778899, 'lightsteelblue': 0xB0C4DE, 'lightyellow': 0xFFFFE0, 'lime': 0x00FF00, 'limegreen': 0x32CD32, +'linen': 0xFAF0E6, 'magenta': 0xFF00FF, 'maroon': 0x800000, 'mediumaquamarine': 0x66CDAA, 'mediumblue': 0x0000CD, 'mediumorchid': 0xBA55D3, +'mediumpurple': 0x9370DB, 'mediumseagreen': 0x3CB371, 'mediumslateblue': 0x7B68EE, 'mediumspringgreen': 0x00FA9A, 'mediumturquoise': 0x48D1CC, +'mediumvioletred': 0xC71585, 'midnightblue': 0x191970, 'mintcream': 0xF5FFFA, 'mistyrose': 0xFFE4E1, 'moccasin': 0xFFE4B5, 'navajowhite': 0xFFDEAD, +'navy': 0x000080, 'oldlace': 0xFDF5E6, 'olive': 0x808000, 'olivedrab': 0x6B8E23, 'orange': 0xFFA500, 'orangered': 0xFF4500, 'orchid': 0xDA70D6, +'palegoldenrod': 0xEEE8AA, 'palegreen': 0x98FB98, 'paleturquoise': 0xAFEEEE, 'palevioletred': 0xDB7093, 'papayawhip': 0xFFEFD5, 'peachpuff': 0xFFDAB9, +'peru': 0xCD853F, 'pink': 0xFFC0CB, 'plum': 0xDDA0DD, 'powderblue': 0xB0E0E6, 'purple': 0x800080, 'red': 0xFF0000, 'rosybrown': 0xBC8F8F, +'royalblue': 0x4169E1, 'saddlebrown': 0x8B4513, 'salmon': 0xFA8072, 'sandybrown': 0xF4A460, 'seagreen': 0x2E8B57, 'seashell': 0xFFF5EE, +'sienna': 0xA0522D, 'silver': 0xC0C0C0, 'skyblue': 0x87CEEB, 'slateblue': 0x6A5ACD, 'slategray': 0x708090, 'slategrey': 0x708090, 'snow': 0xFFFAFA, +'springgreen': 0x00FF7F, 'steelblue': 0x4682B4, 'tan': 0xD2B48C, 'teal': 0x008080, 'thistle': 0xD8BFD8, 'tomato': 0xFF6347, 'turquoise': 0x40E0D0, +'violet': 0xEE82EE, 'wheat': 0xF5DEB3, 'white': 0xFFFFFF, 'whitesmoke': 0xF5F5F5, 'yellow': 0xFFFF00, 'yellowgreen': 0x9ACD32 }; diff --git a/src/math/Euler.js b/src/math/Euler.js index 41c532a5de862..39538d88e832a 100644 --- a/src/math/Euler.js +++ b/src/math/Euler.js @@ -108,9 +108,9 @@ THREE.Euler.prototype = { // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) var te = m.elements; - var m11 = te[0], m12 = te[4], m13 = te[8]; - var m21 = te[1], m22 = te[5], m23 = te[9]; - var m31 = te[2], m32 = te[6], m33 = te[10]; + var m11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ]; + var m21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ]; + var m31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ]; order = order || this._order; diff --git a/src/math/Frustum.js b/src/math/Frustum.js index a376dfa3ab677..4a2698d72cf26 100644 --- a/src/math/Frustum.js +++ b/src/math/Frustum.js @@ -27,12 +27,12 @@ THREE.Frustum.prototype = { var planes = this.planes; - planes[0].copy( p0 ); - planes[1].copy( p1 ); - planes[2].copy( p2 ); - planes[3].copy( p3 ); - planes[4].copy( p4 ); - planes[5].copy( p5 ); + planes[ 0 ].copy( p0 ); + planes[ 1 ].copy( p1 ); + planes[ 2 ].copy( p2 ); + planes[ 3 ].copy( p3 ); + planes[ 4 ].copy( p4 ); + planes[ 5 ].copy( p5 ); return this; @@ -42,9 +42,9 @@ THREE.Frustum.prototype = { var planes = this.planes; - for( var i = 0; i < 6; i ++ ) { + for ( var i = 0; i < 6; i ++ ) { - planes[i].copy( frustum.planes[i] ); + planes[ i ].copy( frustum.planes[ i ] ); } @@ -56,10 +56,10 @@ THREE.Frustum.prototype = { var planes = this.planes; var me = m.elements; - var me0 = me[0], me1 = me[1], me2 = me[2], me3 = me[3]; - var me4 = me[4], me5 = me[5], me6 = me[6], me7 = me[7]; - var me8 = me[8], me9 = me[9], me10 = me[10], me11 = me[11]; - var me12 = me[12], me13 = me[13], me14 = me[14], me15 = me[15]; + var me0 = me[ 0 ], me1 = me[ 1 ], me2 = me[ 2 ], me3 = me[ 3 ]; + var me4 = me[ 4 ], me5 = me[ 5 ], me6 = me[ 6 ], me7 = me[ 7 ]; + var me8 = me[ 8 ], me9 = me[ 9 ], me10 = me[ 10 ], me11 = me[ 11 ]; + var me12 = me[ 12 ], me13 = me[ 13 ], me14 = me[ 14 ], me15 = me[ 15 ]; planes[ 0 ].setComponents( me3 - me0, me7 - me4, me11 - me8, me15 - me12 ).normalize(); planes[ 1 ].setComponents( me3 + me0, me7 + me4, me11 + me8, me15 + me12 ).normalize(); @@ -113,19 +113,19 @@ THREE.Frustum.prototype = { }, - intersectsBox : function() { + intersectsBox: function () { var p1 = new THREE.Vector3(), p2 = new THREE.Vector3(); - return function( box ) { + return function ( box ) { var planes = this.planes; - + for ( var i = 0; i < 6 ; i ++ ) { - - var plane = planes[i]; - + + var plane = planes[ i ]; + p1.x = plane.normal.x > 0 ? box.min.x : box.max.x; p2.x = plane.normal.x > 0 ? box.max.x : box.min.x; p1.y = plane.normal.y > 0 ? box.min.y : box.max.y; @@ -135,13 +135,13 @@ THREE.Frustum.prototype = { var d1 = plane.distanceToPoint( p1 ); var d2 = plane.distanceToPoint( p2 ); - + // if both outside plane, no intersection if ( d1 < 0 && d2 < 0 ) { - + return false; - + } } diff --git a/src/math/Math.js b/src/math/Math.js index 30c77c0410c9c..3dcfb93e55f76 100644 --- a/src/math/Math.js +++ b/src/math/Math.js @@ -8,9 +8,9 @@ THREE.Math = { generateUUID: function () { // http://www.broofa.com/Tools/Math.uuid.htm - - var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''); - var uuid = new Array(36); + + var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split( '' ); + var uuid = new Array( 36 ); var rnd = 0, r; return function () { @@ -18,24 +18,24 @@ THREE.Math = { for ( var i = 0; i < 36; i ++ ) { if ( i == 8 || i == 13 || i == 18 || i == 23 ) { - + uuid[ i ] = '-'; - + } else if ( i == 14 ) { - + uuid[ i ] = '4'; - + } else { - - if (rnd <= 0x02) rnd = 0x2000000 + (Math.random()*0x1000000)|0; + + if ( rnd <= 0x02 ) rnd = 0x2000000 + ( Math.random() * 0x1000000 ) | 0; r = rnd & 0xf; rnd = rnd >> 4; - uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r]; + uuid[ i ] = chars[ ( i == 19 ) ? ( r & 0x3 ) | 0x8 : r ]; } } - - return uuid.join(''); + + return uuid.join( '' ); }; @@ -72,9 +72,9 @@ THREE.Math = { if ( x <= min ) return 0; if ( x >= max ) return 1; - x = ( x - min )/( max - min ); + x = ( x - min ) / ( max - min ); - return x*x*(3 - 2*x); + return x * x * ( 3 - 2 * x ); }, @@ -83,9 +83,9 @@ THREE.Math = { if ( x <= min ) return 0; if ( x >= max ) return 1; - x = ( x - min )/( max - min ); + x = ( x - min ) / ( max - min ); - return x*x*x*(x*(x*6 - 15) + 10); + return x * x * x * ( x * ( x * 6 - 15 ) + 10 ); }, @@ -124,11 +124,11 @@ THREE.Math = { sign: function ( x ) { - return ( x < 0 ) ? - 1 : ( x > 0 ) ? 1 : 0; + return ( x < 0 ) ? -1 : ( x > 0 ) ? 1 : 0; }, - degToRad: function() { + degToRad: function () { var degreeToRadiansFactor = Math.PI / 180; @@ -140,7 +140,7 @@ THREE.Math = { }(), - radToDeg: function() { + radToDeg: function () { var radianToDegreesFactor = 180 / Math.PI; diff --git a/src/math/Matrix3.js b/src/math/Matrix3.js index 14c05d362c173..7bd54b491a843 100644 --- a/src/math/Matrix3.js +++ b/src/math/Matrix3.js @@ -10,9 +10,9 @@ THREE.Matrix3 = function ( n11, n12, n13, n21, n22, n23, n31, n32, n33 ) { var te = this.elements; - te[0] = ( n11 !== undefined ) ? n11 : 1; te[3] = n12 || 0; te[6] = n13 || 0; - te[1] = n21 || 0; te[4] = ( n22 !== undefined ) ? n22 : 1; te[7] = n23 || 0; - te[2] = n31 || 0; te[5] = n32 || 0; te[8] = ( n33 !== undefined ) ? n33 : 1; + te[ 0 ] = ( n11 !== undefined ) ? n11 : 1; te[ 3 ] = n12 || 0; te[ 6 ] = n13 || 0; + te[ 1 ] = n21 || 0; te[ 4 ] = ( n22 !== undefined ) ? n22 : 1; te[ 7 ] = n23 || 0; + te[ 2 ] = n31 || 0; te[ 5 ] = n32 || 0; te[ 8 ] = ( n33 !== undefined ) ? n33 : 1; }; @@ -24,9 +24,9 @@ THREE.Matrix3.prototype = { var te = this.elements; - te[0] = n11; te[3] = n12; te[6] = n13; - te[1] = n21; te[4] = n22; te[7] = n23; - te[2] = n31; te[5] = n32; te[8] = n33; + te[ 0 ] = n11; te[ 3 ] = n12; te[ 6 ] = n13; + te[ 1 ] = n21; te[ 4 ] = n22; te[ 7 ] = n23; + te[ 2 ] = n31; te[ 5 ] = n32; te[ 8 ] = n33; return this; @@ -52,9 +52,9 @@ THREE.Matrix3.prototype = { this.set( - me[0], me[3], me[6], - me[1], me[4], me[7], - me[2], me[5], me[8] + me[ 0 ], me[ 3 ], me[ 6 ], + me[ 1 ], me[ 4 ], me[ 7 ], + me[ 2 ], me[ 5 ], me[ 8 ] ); @@ -76,7 +76,7 @@ THREE.Matrix3.prototype = { }, - applyToVector3Array: function() { + applyToVector3Array: function () { var v1 = new THREE.Vector3(); @@ -109,9 +109,9 @@ THREE.Matrix3.prototype = { var te = this.elements; - te[0] *= s; te[3] *= s; te[6] *= s; - te[1] *= s; te[4] *= s; te[7] *= s; - te[2] *= s; te[5] *= s; te[8] *= s; + te[ 0 ] *= s; te[ 3 ] *= s; te[ 6 ] *= s; + te[ 1 ] *= s; te[ 4 ] *= s; te[ 7 ] *= s; + te[ 2 ] *= s; te[ 5 ] *= s; te[ 8 ] *= s; return this; @@ -121,11 +121,11 @@ THREE.Matrix3.prototype = { var te = this.elements; - var a = te[0], b = te[1], c = te[2], - d = te[3], e = te[4], f = te[5], - g = te[6], h = te[7], i = te[8]; + var a = te[ 0 ], b = te[ 1 ], c = te[ 2 ], + d = te[ 3 ], e = te[ 4 ], f = te[ 5 ], + g = te[ 6 ], h = te[ 7 ], i = te[ 8 ]; - return a*e*i - a*f*h - b*d*i + b*f*g + c*d*h - c*e*g; + return a * e * i - a * f * h - b * d * i + b * f * g + c * d * h - c * e * g; }, @@ -137,15 +137,15 @@ THREE.Matrix3.prototype = { var me = matrix.elements; var te = this.elements; - te[ 0 ] = me[10] * me[5] - me[6] * me[9]; - te[ 1 ] = - me[10] * me[1] + me[2] * me[9]; - te[ 2 ] = me[6] * me[1] - me[2] * me[5]; - te[ 3 ] = - me[10] * me[4] + me[6] * me[8]; - te[ 4 ] = me[10] * me[0] - me[2] * me[8]; - te[ 5 ] = - me[6] * me[0] + me[2] * me[4]; - te[ 6 ] = me[9] * me[4] - me[5] * me[8]; - te[ 7 ] = - me[9] * me[0] + me[1] * me[8]; - te[ 8 ] = me[5] * me[0] - me[1] * me[4]; + te[ 0 ] = me[ 10 ] * me[ 5 ] - me[ 6 ] * me[ 9 ]; + te[ 1 ] = -me[ 10 ] * me[ 1 ] + me[ 2 ] * me[ 9 ]; + te[ 2 ] = me[ 6 ] * me[ 1 ] - me[ 2 ] * me[ 5 ]; + te[ 3 ] = -me[ 10 ] * me[ 4 ] + me[ 6 ] * me[ 8 ]; + te[ 4 ] = me[ 10 ] * me[ 0 ] - me[ 2 ] * me[ 8 ]; + te[ 5 ] = -me[ 6 ] * me[ 0 ] + me[ 2 ] * me[ 4 ]; + te[ 6 ] = me[ 9 ] * me[ 4 ] - me[ 5 ] * me[ 8 ]; + te[ 7 ] = -me[ 9 ] * me[ 0 ] + me[ 1 ] * me[ 8 ]; + te[ 8 ] = me[ 5 ] * me[ 0 ] - me[ 1 ] * me[ 4 ]; var det = me[ 0 ] * te[ 0 ] + me[ 1 ] * te[ 3 ] + me[ 2 ] * te[ 6 ]; @@ -181,29 +181,29 @@ THREE.Matrix3.prototype = { var tmp, m = this.elements; - tmp = m[1]; m[1] = m[3]; m[3] = tmp; - tmp = m[2]; m[2] = m[6]; m[6] = tmp; - tmp = m[5]; m[5] = m[7]; m[7] = tmp; + tmp = m[ 1 ]; m[ 1 ] = m[ 3 ]; m[ 3 ] = tmp; + tmp = m[ 2 ]; m[ 2 ] = m[ 6 ]; m[ 6 ] = tmp; + tmp = m[ 5 ]; m[ 5 ] = m[ 7 ]; m[ 7 ] = tmp; return this; }, - flattenToArrayOffset: function( array, offset ) { + flattenToArrayOffset: function ( array, offset ) { var te = this.elements; - array[ offset ] = te[0]; - array[ offset + 1 ] = te[1]; - array[ offset + 2 ] = te[2]; - - array[ offset + 3 ] = te[3]; - array[ offset + 4 ] = te[4]; - array[ offset + 5 ] = te[5]; - - array[ offset + 6 ] = te[6]; - array[ offset + 7 ] = te[7]; - array[ offset + 8 ] = te[8]; + array[ offset ] = te[ 0 ]; + array[ offset + 1 ] = te[ 1 ]; + array[ offset + 2 ] = te[ 2 ]; + + array[ offset + 3 ] = te[ 3 ]; + array[ offset + 4 ] = te[ 4 ]; + array[ offset + 5 ] = te[ 5 ]; + + array[ offset + 6 ] = te[ 6 ]; + array[ offset + 7 ] = te[ 7 ]; + array[ offset + 8 ] = te[ 8 ]; return array; @@ -263,9 +263,9 @@ THREE.Matrix3.prototype = { return new THREE.Matrix3( - te[0], te[3], te[6], - te[1], te[4], te[7], - te[2], te[5], te[8] + te[ 0 ], te[ 3 ], te[ 6 ], + te[ 1 ], te[ 4 ], te[ 7 ], + te[ 2 ], te[ 5 ], te[ 8 ] ); diff --git a/src/math/Matrix4.js b/src/math/Matrix4.js index ce5295641167e..005fe9d94abaa 100644 --- a/src/math/Matrix4.js +++ b/src/math/Matrix4.js @@ -21,10 +21,10 @@ THREE.Matrix4 = function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33 var te = this.elements; - te[0] = ( n11 !== undefined ) ? n11 : 1; te[4] = n12 || 0; te[8] = n13 || 0; te[12] = n14 || 0; - te[1] = n21 || 0; te[5] = ( n22 !== undefined ) ? n22 : 1; te[9] = n23 || 0; te[13] = n24 || 0; - te[2] = n31 || 0; te[6] = n32 || 0; te[10] = ( n33 !== undefined ) ? n33 : 1; te[14] = n34 || 0; - te[3] = n41 || 0; te[7] = n42 || 0; te[11] = n43 || 0; te[15] = ( n44 !== undefined ) ? n44 : 1; + te[ 0 ] = ( n11 !== undefined ) ? n11 : 1; te[ 4 ] = n12 || 0; te[ 8 ] = n13 || 0; te[ 12 ] = n14 || 0; + te[ 1 ] = n21 || 0; te[ 5 ] = ( n22 !== undefined ) ? n22 : 1; te[ 9 ] = n23 || 0; te[ 13 ] = n24 || 0; + te[ 2 ] = n31 || 0; te[ 6 ] = n32 || 0; te[ 10 ] = ( n33 !== undefined ) ? n33 : 1; te[ 14 ] = n34 || 0; + te[ 3 ] = n41 || 0; te[ 7 ] = n42 || 0; te[ 11 ] = n43 || 0; te[ 15 ] = ( n44 !== undefined ) ? n44 : 1; }; @@ -36,10 +36,10 @@ THREE.Matrix4.prototype = { var te = this.elements; - te[0] = n11; te[4] = n12; te[8] = n13; te[12] = n14; - te[1] = n21; te[5] = n22; te[9] = n23; te[13] = n24; - te[2] = n31; te[6] = n32; te[10] = n33; te[14] = n34; - te[3] = n41; te[7] = n42; te[11] = n43; te[15] = n44; + te[ 0 ] = n11; te[ 4 ] = n12; te[ 8 ] = n13; te[ 12 ] = n14; + te[ 1 ] = n21; te[ 5 ] = n22; te[ 9 ] = n23; te[ 13 ] = n24; + te[ 2 ] = n31; te[ 6 ] = n32; te[ 10 ] = n33; te[ 14 ] = n34; + te[ 3 ] = n41; te[ 7 ] = n42; te[ 11 ] = n43; te[ 15 ] = n44; return this; @@ -80,9 +80,9 @@ THREE.Matrix4.prototype = { var te = this.elements; var me = m.elements; - te[12] = me[12]; - te[13] = me[13]; - te[14] = me[14]; + te[ 12 ] = me[ 12 ]; + te[ 13 ] = me[ 13 ]; + te[ 14 ] = me[ 14 ]; return this; @@ -97,21 +97,21 @@ THREE.Matrix4.prototype = { var te = this.elements; var me = m.elements; - var scaleX = 1 / v1.set( me[0], me[1], me[2] ).length(); - var scaleY = 1 / v1.set( me[4], me[5], me[6] ).length(); - var scaleZ = 1 / v1.set( me[8], me[9], me[10] ).length(); + var scaleX = 1 / v1.set( me[ 0 ], me[ 1 ], me[ 2 ] ).length(); + var scaleY = 1 / v1.set( me[ 4 ], me[ 5 ], me[ 6 ] ).length(); + var scaleZ = 1 / v1.set( me[ 8 ], me[ 9 ], me[ 10 ] ).length(); - te[0] = me[0] * scaleX; - te[1] = me[1] * scaleX; - te[2] = me[2] * scaleX; + te[ 0 ] = me[ 0 ] * scaleX; + te[ 1 ] = me[ 1 ] * scaleX; + te[ 2 ] = me[ 2 ] * scaleX; - te[4] = me[4] * scaleY; - te[5] = me[5] * scaleY; - te[6] = me[6] * scaleY; + te[ 4 ] = me[ 4 ] * scaleY; + te[ 5 ] = me[ 5 ] * scaleY; + te[ 6 ] = me[ 6 ] * scaleY; - te[8] = me[8] * scaleZ; - te[9] = me[9] * scaleZ; - te[10] = me[10] * scaleZ; + te[ 8 ] = me[ 8 ] * scaleZ; + te[ 9 ] = me[ 9 ] * scaleZ; + te[ 10 ] = me[ 10 ] * scaleZ; return this; @@ -138,110 +138,110 @@ THREE.Matrix4.prototype = { var ae = a * e, af = a * f, be = b * e, bf = b * f; - te[0] = c * e; - te[4] = - c * f; - te[8] = d; + te[ 0 ] = c * e; + te[ 4 ] = -c * f; + te[ 8 ] = d; - te[1] = af + be * d; - te[5] = ae - bf * d; - te[9] = - b * c; + te[ 1 ] = af + be * d; + te[ 5 ] = ae - bf * d; + te[ 9 ] = -b * c; - te[2] = bf - ae * d; - te[6] = be + af * d; - te[10] = a * c; + te[ 2 ] = bf - ae * d; + te[ 6 ] = be + af * d; + te[ 10 ] = a * c; } else if ( euler.order === 'YXZ' ) { var ce = c * e, cf = c * f, de = d * e, df = d * f; - te[0] = ce + df * b; - te[4] = de * b - cf; - te[8] = a * d; + te[ 0 ] = ce + df * b; + te[ 4 ] = de * b - cf; + te[ 8 ] = a * d; - te[1] = a * f; - te[5] = a * e; - te[9] = - b; + te[ 1 ] = a * f; + te[ 5 ] = a * e; + te[ 9 ] = -b; - te[2] = cf * b - de; - te[6] = df + ce * b; - te[10] = a * c; + te[ 2 ] = cf * b - de; + te[ 6 ] = df + ce * b; + te[ 10 ] = a * c; } else if ( euler.order === 'ZXY' ) { var ce = c * e, cf = c * f, de = d * e, df = d * f; - te[0] = ce - df * b; - te[4] = - a * f; - te[8] = de + cf * b; + te[ 0 ] = ce - df * b; + te[ 4 ] = -a * f; + te[ 8 ] = de + cf * b; - te[1] = cf + de * b; - te[5] = a * e; - te[9] = df - ce * b; + te[ 1 ] = cf + de * b; + te[ 5 ] = a * e; + te[ 9 ] = df - ce * b; - te[2] = - a * d; - te[6] = b; - te[10] = a * c; + te[ 2 ] = -a * d; + te[ 6 ] = b; + te[ 10 ] = a * c; } else if ( euler.order === 'ZYX' ) { var ae = a * e, af = a * f, be = b * e, bf = b * f; - te[0] = c * e; - te[4] = be * d - af; - te[8] = ae * d + bf; + te[ 0 ] = c * e; + te[ 4 ] = be * d - af; + te[ 8 ] = ae * d + bf; - te[1] = c * f; - te[5] = bf * d + ae; - te[9] = af * d - be; + te[ 1 ] = c * f; + te[ 5 ] = bf * d + ae; + te[ 9 ] = af * d - be; - te[2] = - d; - te[6] = b * c; - te[10] = a * c; + te[ 2 ] = -d; + te[ 6 ] = b * c; + te[ 10 ] = a * c; } else if ( euler.order === 'YZX' ) { var ac = a * c, ad = a * d, bc = b * c, bd = b * d; - te[0] = c * e; - te[4] = bd - ac * f; - te[8] = bc * f + ad; + te[ 0 ] = c * e; + te[ 4 ] = bd - ac * f; + te[ 8 ] = bc * f + ad; - te[1] = f; - te[5] = a * e; - te[9] = - b * e; + te[ 1 ] = f; + te[ 5 ] = a * e; + te[ 9 ] = -b * e; - te[2] = - d * e; - te[6] = ad * f + bc; - te[10] = ac - bd * f; + te[ 2 ] = -d * e; + te[ 6 ] = ad * f + bc; + te[ 10 ] = ac - bd * f; } else if ( euler.order === 'XZY' ) { var ac = a * c, ad = a * d, bc = b * c, bd = b * d; - te[0] = c * e; - te[4] = - f; - te[8] = d * e; + te[ 0 ] = c * e; + te[ 4 ] = -f; + te[ 8 ] = d * e; - te[1] = ac * f + bd; - te[5] = a * e; - te[9] = ad * f - bc; + te[ 1 ] = ac * f + bd; + te[ 5 ] = a * e; + te[ 9 ] = ad * f - bc; - te[2] = bc * f - ad; - te[6] = b * e; - te[10] = bd * f + ac; + te[ 2 ] = bc * f - ad; + te[ 6 ] = b * e; + te[ 10 ] = bd * f + ac; } // last column - te[3] = 0; - te[7] = 0; - te[11] = 0; + te[ 3 ] = 0; + te[ 7 ] = 0; + te[ 11 ] = 0; // bottom row - te[12] = 0; - te[13] = 0; - te[14] = 0; - te[15] = 1; + te[ 12 ] = 0; + te[ 13 ] = 0; + te[ 14 ] = 0; + te[ 15 ] = 1; return this; @@ -265,34 +265,34 @@ THREE.Matrix4.prototype = { var yy = y * y2, yz = y * z2, zz = z * z2; var wx = w * x2, wy = w * y2, wz = w * z2; - te[0] = 1 - ( yy + zz ); - te[4] = xy - wz; - te[8] = xz + wy; + te[ 0 ] = 1 - ( yy + zz ); + te[ 4 ] = xy - wz; + te[ 8 ] = xz + wy; - te[1] = xy + wz; - te[5] = 1 - ( xx + zz ); - te[9] = yz - wx; + te[ 1 ] = xy + wz; + te[ 5 ] = 1 - ( xx + zz ); + te[ 9 ] = yz - wx; - te[2] = xz - wy; - te[6] = yz + wx; - te[10] = 1 - ( xx + yy ); + te[ 2 ] = xz - wy; + te[ 6 ] = yz + wx; + te[ 10 ] = 1 - ( xx + yy ); // last column - te[3] = 0; - te[7] = 0; - te[11] = 0; + te[ 3 ] = 0; + te[ 7 ] = 0; + te[ 11 ] = 0; // bottom row - te[12] = 0; - te[13] = 0; - te[14] = 0; - te[15] = 1; + te[ 12 ] = 0; + te[ 13 ] = 0; + te[ 14 ] = 0; + te[ 15 ] = 1; return this; }, - lookAt: function() { + lookAt: function () { var x = new THREE.Vector3(); var y = new THREE.Vector3(); @@ -322,9 +322,9 @@ THREE.Matrix4.prototype = { y.crossVectors( z, x ); - te[0] = x.x; te[4] = y.x; te[8] = z.x; - te[1] = x.y; te[5] = y.y; te[9] = z.y; - te[2] = x.z; te[6] = y.z; te[10] = z.z; + te[ 0 ] = x.x; te[ 4 ] = y.x; te[ 8 ] = z.x; + te[ 1 ] = x.y; te[ 5 ] = y.y; te[ 9 ] = z.y; + te[ 2 ] = x.z; te[ 6 ] = y.z; te[ 10 ] = z.z; return this; @@ -351,35 +351,35 @@ THREE.Matrix4.prototype = { var be = b.elements; var te = this.elements; - var a11 = ae[0], a12 = ae[4], a13 = ae[8], a14 = ae[12]; - var a21 = ae[1], a22 = ae[5], a23 = ae[9], a24 = ae[13]; - var a31 = ae[2], a32 = ae[6], a33 = ae[10], a34 = ae[14]; - var a41 = ae[3], a42 = ae[7], a43 = ae[11], a44 = ae[15]; + var a11 = ae[ 0 ], a12 = ae[ 4 ], a13 = ae[ 8 ], a14 = ae[ 12 ]; + var a21 = ae[ 1 ], a22 = ae[ 5 ], a23 = ae[ 9 ], a24 = ae[ 13 ]; + var a31 = ae[ 2 ], a32 = ae[ 6 ], a33 = ae[ 10 ], a34 = ae[ 14 ]; + var a41 = ae[ 3 ], a42 = ae[ 7 ], a43 = ae[ 11 ], a44 = ae[ 15 ]; - var b11 = be[0], b12 = be[4], b13 = be[8], b14 = be[12]; - var b21 = be[1], b22 = be[5], b23 = be[9], b24 = be[13]; - var b31 = be[2], b32 = be[6], b33 = be[10], b34 = be[14]; - var b41 = be[3], b42 = be[7], b43 = be[11], b44 = be[15]; + var b11 = be[ 0 ], b12 = be[ 4 ], b13 = be[ 8 ], b14 = be[ 12 ]; + var b21 = be[ 1 ], b22 = be[ 5 ], b23 = be[ 9 ], b24 = be[ 13 ]; + var b31 = be[ 2 ], b32 = be[ 6 ], b33 = be[ 10 ], b34 = be[ 14 ]; + var b41 = be[ 3 ], b42 = be[ 7 ], b43 = be[ 11 ], b44 = be[ 15 ]; - te[0] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41; - te[4] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42; - te[8] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43; - te[12] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44; + te[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41; + te[ 4 ] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42; + te[ 8 ] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43; + te[ 12 ] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44; - te[1] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41; - te[5] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42; - te[9] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43; - te[13] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44; + te[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41; + te[ 5 ] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42; + te[ 9 ] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43; + te[ 13 ] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44; - te[2] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41; - te[6] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42; - te[10] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43; - te[14] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44; + te[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41; + te[ 6 ] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42; + te[ 10 ] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43; + te[ 14 ] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44; - te[3] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41; - te[7] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42; - te[11] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43; - te[15] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44; + te[ 3 ] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41; + te[ 7 ] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42; + te[ 11 ] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43; + te[ 15 ] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44; return this; @@ -391,10 +391,10 @@ THREE.Matrix4.prototype = { this.multiplyMatrices( a, b ); - r[ 0 ] = te[0]; r[ 1 ] = te[1]; r[ 2 ] = te[2]; r[ 3 ] = te[3]; - r[ 4 ] = te[4]; r[ 5 ] = te[5]; r[ 6 ] = te[6]; r[ 7 ] = te[7]; - r[ 8 ] = te[8]; r[ 9 ] = te[9]; r[ 10 ] = te[10]; r[ 11 ] = te[11]; - r[ 12 ] = te[12]; r[ 13 ] = te[13]; r[ 14 ] = te[14]; r[ 15 ] = te[15]; + r[ 0 ] = te[ 0 ]; r[ 1 ] = te[ 1 ]; r[ 2 ] = te[ 2 ]; r[ 3 ] = te[ 3 ]; + r[ 4 ] = te[ 4 ]; r[ 5 ] = te[ 5 ]; r[ 6 ] = te[ 6 ]; r[ 7 ] = te[ 7 ]; + r[ 8 ] = te[ 8 ]; r[ 9 ] = te[ 9 ]; r[ 10 ] = te[ 10 ]; r[ 11 ] = te[ 11 ]; + r[ 12 ] = te[ 12 ]; r[ 13 ] = te[ 13 ]; r[ 14 ] = te[ 14 ]; r[ 15 ] = te[ 15 ]; return this; @@ -404,10 +404,10 @@ THREE.Matrix4.prototype = { var te = this.elements; - te[0] *= s; te[4] *= s; te[8] *= s; te[12] *= s; - te[1] *= s; te[5] *= s; te[9] *= s; te[13] *= s; - te[2] *= s; te[6] *= s; te[10] *= s; te[14] *= s; - te[3] *= s; te[7] *= s; te[11] *= s; te[15] *= s; + te[ 0 ] *= s; te[ 4 ] *= s; te[ 8 ] *= s; te[ 12 ] *= s; + te[ 1 ] *= s; te[ 5 ] *= s; te[ 9 ] *= s; te[ 13 ] *= s; + te[ 2 ] *= s; te[ 6 ] *= s; te[ 10 ] *= s; te[ 14 ] *= s; + te[ 3 ] *= s; te[ 7 ] *= s; te[ 11 ] *= s; te[ 15 ] *= s; return this; @@ -434,7 +434,7 @@ THREE.Matrix4.prototype = { }, - applyToVector3Array: function() { + applyToVector3Array: function () { var v1 = new THREE.Vector3(); @@ -482,10 +482,10 @@ THREE.Matrix4.prototype = { var te = this.elements; - var n11 = te[0], n12 = te[4], n13 = te[8], n14 = te[12]; - var n21 = te[1], n22 = te[5], n23 = te[9], n24 = te[13]; - var n31 = te[2], n32 = te[6], n33 = te[10], n34 = te[14]; - var n41 = te[3], n42 = te[7], n43 = te[11], n44 = te[15]; + var n11 = te[ 0 ], n12 = te[ 4 ], n13 = te[ 8 ], n14 = te[ 12 ]; + var n21 = te[ 1 ], n22 = te[ 5 ], n23 = te[ 9 ], n24 = te[ 13 ]; + var n31 = te[ 2 ], n32 = te[ 6 ], n33 = te[ 10 ], n34 = te[ 14 ]; + var n41 = te[ 3 ], n42 = te[ 7 ], n43 = te[ 11 ], n44 = te[ 15 ]; //TODO: make this more efficient //( based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm ) @@ -493,35 +493,35 @@ THREE.Matrix4.prototype = { return ( n41 * ( +n14 * n23 * n32 - -n13 * n24 * n32 - -n14 * n22 * n33 - +n12 * n24 * n33 - +n13 * n22 * n34 - -n12 * n23 * n34 + - n13 * n24 * n32 + - n14 * n22 * n33 + + n12 * n24 * n33 + + n13 * n22 * n34 + - n12 * n23 * n34 ) + n42 * ( +n11 * n23 * n34 - -n11 * n24 * n33 - +n14 * n21 * n33 - -n13 * n21 * n34 - +n13 * n24 * n31 - -n14 * n23 * n31 + - n11 * n24 * n33 + + n14 * n21 * n33 + - n13 * n21 * n34 + + n13 * n24 * n31 + - n14 * n23 * n31 ) + n43 * ( +n11 * n24 * n32 - -n11 * n22 * n34 - -n14 * n21 * n32 - +n12 * n21 * n34 - +n14 * n22 * n31 - -n12 * n24 * n31 + - n11 * n22 * n34 + - n14 * n21 * n32 + + n12 * n21 * n34 + + n14 * n22 * n31 + - n12 * n24 * n31 ) + n44 * ( -n13 * n22 * n31 - -n11 * n23 * n32 - +n11 * n22 * n33 - +n13 * n21 * n32 - -n12 * n21 * n33 - +n12 * n23 * n31 + - n11 * n23 * n32 + + n11 * n22 * n33 + + n13 * n21 * n32 + - n12 * n21 * n33 + + n12 * n23 * n31 ) ); @@ -533,47 +533,47 @@ THREE.Matrix4.prototype = { var te = this.elements; var tmp; - tmp = te[1]; te[1] = te[4]; te[4] = tmp; - tmp = te[2]; te[2] = te[8]; te[8] = tmp; - tmp = te[6]; te[6] = te[9]; te[9] = tmp; + tmp = te[ 1 ]; te[ 1 ] = te[ 4 ]; te[ 4 ] = tmp; + tmp = te[ 2 ]; te[ 2 ] = te[ 8 ]; te[ 8 ] = tmp; + tmp = te[ 6 ]; te[ 6 ] = te[ 9 ]; te[ 9 ] = tmp; - tmp = te[3]; te[3] = te[12]; te[12] = tmp; - tmp = te[7]; te[7] = te[13]; te[13] = tmp; - tmp = te[11]; te[11] = te[14]; te[14] = tmp; + tmp = te[ 3 ]; te[ 3 ] = te[ 12 ]; te[ 12 ] = tmp; + tmp = te[ 7 ]; te[ 7 ] = te[ 13 ]; te[ 13 ] = tmp; + tmp = te[ 11 ]; te[ 11 ] = te[ 14 ]; te[ 14 ] = tmp; return this; }, - flattenToArrayOffset: function( array, offset ) { + flattenToArrayOffset: function ( array, offset ) { var te = this.elements; - array[ offset ] = te[0]; - array[ offset + 1 ] = te[1]; - array[ offset + 2 ] = te[2]; - array[ offset + 3 ] = te[3]; + array[ offset ] = te[ 0 ]; + array[ offset + 1 ] = te[ 1 ]; + array[ offset + 2 ] = te[ 2 ]; + array[ offset + 3 ] = te[ 3 ]; - array[ offset + 4 ] = te[4]; - array[ offset + 5 ] = te[5]; - array[ offset + 6 ] = te[6]; - array[ offset + 7 ] = te[7]; + array[ offset + 4 ] = te[ 4 ]; + array[ offset + 5 ] = te[ 5 ]; + array[ offset + 6 ] = te[ 6 ]; + array[ offset + 7 ] = te[ 7 ]; - array[ offset + 8 ] = te[8]; - array[ offset + 9 ] = te[9]; - array[ offset + 10 ] = te[10]; - array[ offset + 11 ] = te[11]; + array[ offset + 8 ] = te[ 8 ]; + array[ offset + 9 ] = te[ 9 ]; + array[ offset + 10 ] = te[ 10 ]; + array[ offset + 11 ] = te[ 11 ]; - array[ offset + 12 ] = te[12]; - array[ offset + 13 ] = te[13]; - array[ offset + 14 ] = te[14]; - array[ offset + 15 ] = te[15]; + array[ offset + 12 ] = te[ 12 ]; + array[ offset + 13 ] = te[ 13 ]; + array[ offset + 14 ] = te[ 14 ]; + array[ offset + 15 ] = te[ 15 ]; return array; }, - getPosition: function() { + getPosition: function () { var v1 = new THREE.Vector3(); @@ -582,7 +582,7 @@ THREE.Matrix4.prototype = { console.warn( 'THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.' ); var te = this.elements; - return v1.set( te[12], te[13], te[14] ); + return v1.set( te[ 12 ], te[ 13 ], te[ 14 ] ); }; @@ -592,9 +592,9 @@ THREE.Matrix4.prototype = { var te = this.elements; - te[12] = v.x; - te[13] = v.y; - te[14] = v.z; + te[ 12 ] = v.x; + te[ 13 ] = v.y; + te[ 14 ] = v.z; return this; @@ -606,27 +606,27 @@ THREE.Matrix4.prototype = { var te = this.elements; var me = m.elements; - var n11 = me[0], n12 = me[4], n13 = me[8], n14 = me[12]; - var n21 = me[1], n22 = me[5], n23 = me[9], n24 = me[13]; - var n31 = me[2], n32 = me[6], n33 = me[10], n34 = me[14]; - var n41 = me[3], n42 = me[7], n43 = me[11], n44 = me[15]; - - te[0] = n23*n34*n42 - n24*n33*n42 + n24*n32*n43 - n22*n34*n43 - n23*n32*n44 + n22*n33*n44; - te[4] = n14*n33*n42 - n13*n34*n42 - n14*n32*n43 + n12*n34*n43 + n13*n32*n44 - n12*n33*n44; - te[8] = n13*n24*n42 - n14*n23*n42 + n14*n22*n43 - n12*n24*n43 - n13*n22*n44 + n12*n23*n44; - te[12] = n14*n23*n32 - n13*n24*n32 - n14*n22*n33 + n12*n24*n33 + n13*n22*n34 - n12*n23*n34; - te[1] = n24*n33*n41 - n23*n34*n41 - n24*n31*n43 + n21*n34*n43 + n23*n31*n44 - n21*n33*n44; - te[5] = n13*n34*n41 - n14*n33*n41 + n14*n31*n43 - n11*n34*n43 - n13*n31*n44 + n11*n33*n44; - te[9] = n14*n23*n41 - n13*n24*n41 - n14*n21*n43 + n11*n24*n43 + n13*n21*n44 - n11*n23*n44; - te[13] = n13*n24*n31 - n14*n23*n31 + n14*n21*n33 - n11*n24*n33 - n13*n21*n34 + n11*n23*n34; - te[2] = n22*n34*n41 - n24*n32*n41 + n24*n31*n42 - n21*n34*n42 - n22*n31*n44 + n21*n32*n44; - te[6] = n14*n32*n41 - n12*n34*n41 - n14*n31*n42 + n11*n34*n42 + n12*n31*n44 - n11*n32*n44; - te[10] = n12*n24*n41 - n14*n22*n41 + n14*n21*n42 - n11*n24*n42 - n12*n21*n44 + n11*n22*n44; - te[14] = n14*n22*n31 - n12*n24*n31 - n14*n21*n32 + n11*n24*n32 + n12*n21*n34 - n11*n22*n34; - te[3] = n23*n32*n41 - n22*n33*n41 - n23*n31*n42 + n21*n33*n42 + n22*n31*n43 - n21*n32*n43; - te[7] = n12*n33*n41 - n13*n32*n41 + n13*n31*n42 - n11*n33*n42 - n12*n31*n43 + n11*n32*n43; - te[11] = n13*n22*n41 - n12*n23*n41 - n13*n21*n42 + n11*n23*n42 + n12*n21*n43 - n11*n22*n43; - te[15] = n12*n23*n31 - n13*n22*n31 + n13*n21*n32 - n11*n23*n32 - n12*n21*n33 + n11*n22*n33; + var n11 = me[ 0 ], n12 = me[ 4 ], n13 = me[ 8 ], n14 = me[ 12 ]; + var n21 = me[ 1 ], n22 = me[ 5 ], n23 = me[ 9 ], n24 = me[ 13 ]; + var n31 = me[ 2 ], n32 = me[ 6 ], n33 = me[ 10 ], n34 = me[ 14 ]; + var n41 = me[ 3 ], n42 = me[ 7 ], n43 = me[ 11 ], n44 = me[ 15 ]; + + te[ 0 ] = n23 * n34 * n42 - n24 * n33 * n42 + n24 * n32 * n43 - n22 * n34 * n43 - n23 * n32 * n44 + n22 * n33 * n44; + te[ 4 ] = n14 * n33 * n42 - n13 * n34 * n42 - n14 * n32 * n43 + n12 * n34 * n43 + n13 * n32 * n44 - n12 * n33 * n44; + te[ 8 ] = n13 * n24 * n42 - n14 * n23 * n42 + n14 * n22 * n43 - n12 * n24 * n43 - n13 * n22 * n44 + n12 * n23 * n44; + te[ 12 ] = n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34; + te[ 1 ] = n24 * n33 * n41 - n23 * n34 * n41 - n24 * n31 * n43 + n21 * n34 * n43 + n23 * n31 * n44 - n21 * n33 * n44; + te[ 5 ] = n13 * n34 * n41 - n14 * n33 * n41 + n14 * n31 * n43 - n11 * n34 * n43 - n13 * n31 * n44 + n11 * n33 * n44; + te[ 9 ] = n14 * n23 * n41 - n13 * n24 * n41 - n14 * n21 * n43 + n11 * n24 * n43 + n13 * n21 * n44 - n11 * n23 * n44; + te[ 13 ] = n13 * n24 * n31 - n14 * n23 * n31 + n14 * n21 * n33 - n11 * n24 * n33 - n13 * n21 * n34 + n11 * n23 * n34; + te[ 2 ] = n22 * n34 * n41 - n24 * n32 * n41 + n24 * n31 * n42 - n21 * n34 * n42 - n22 * n31 * n44 + n21 * n32 * n44; + te[ 6 ] = n14 * n32 * n41 - n12 * n34 * n41 - n14 * n31 * n42 + n11 * n34 * n42 + n12 * n31 * n44 - n11 * n32 * n44; + te[ 10 ] = n12 * n24 * n41 - n14 * n22 * n41 + n14 * n21 * n42 - n11 * n24 * n42 - n12 * n21 * n44 + n11 * n22 * n44; + te[ 14 ] = n14 * n22 * n31 - n12 * n24 * n31 - n14 * n21 * n32 + n11 * n24 * n32 + n12 * n21 * n34 - n11 * n22 * n34; + te[ 3 ] = n23 * n32 * n41 - n22 * n33 * n41 - n23 * n31 * n42 + n21 * n33 * n42 + n22 * n31 * n43 - n21 * n32 * n43; + te[ 7 ] = n12 * n33 * n41 - n13 * n32 * n41 + n13 * n31 * n42 - n11 * n33 * n42 - n12 * n31 * n43 + n11 * n32 * n43; + te[ 11 ] = n13 * n22 * n41 - n12 * n23 * n41 - n13 * n21 * n42 + n11 * n23 * n42 + n12 * n21 * n43 - n11 * n22 * n43; + te[ 15 ] = n12 * n23 * n31 - n13 * n22 * n31 + n13 * n21 * n32 - n11 * n23 * n32 - n12 * n21 * n33 + n11 * n22 * n33; var det = n11 * te[ 0 ] + n21 * te[ 4 ] + n31 * te[ 8 ] + n41 * te[ 12 ]; @@ -636,7 +636,7 @@ THREE.Matrix4.prototype = { if ( throwOnInvertible || false ) { - throw new Error( msg ); + throw new Error( msg ); } else { @@ -657,31 +657,31 @@ THREE.Matrix4.prototype = { translate: function ( v ) { - console.warn( 'THREE.Matrix4: .translate() has been removed.'); + console.warn( 'THREE.Matrix4: .translate() has been removed.' ); }, rotateX: function ( angle ) { - console.warn( 'THREE.Matrix4: .rotateX() has been removed.'); + console.warn( 'THREE.Matrix4: .rotateX() has been removed.' ); }, rotateY: function ( angle ) { - console.warn( 'THREE.Matrix4: .rotateY() has been removed.'); + console.warn( 'THREE.Matrix4: .rotateY() has been removed.' ); }, rotateZ: function ( angle ) { - console.warn( 'THREE.Matrix4: .rotateZ() has been removed.'); + console.warn( 'THREE.Matrix4: .rotateZ() has been removed.' ); }, rotateByAxis: function ( axis, angle ) { - console.warn( 'THREE.Matrix4: .rotateByAxis() has been removed.'); + console.warn( 'THREE.Matrix4: .rotateByAxis() has been removed.' ); }, @@ -690,10 +690,10 @@ THREE.Matrix4.prototype = { var te = this.elements; var x = v.x, y = v.y, z = v.z; - te[0] *= x; te[4] *= y; te[8] *= z; - te[1] *= x; te[5] *= y; te[9] *= z; - te[2] *= x; te[6] *= y; te[10] *= z; - te[3] *= x; te[7] *= y; te[11] *= z; + te[ 0 ] *= x; te[ 4 ] *= y; te[ 8 ] *= z; + te[ 1 ] *= x; te[ 5 ] *= y; te[ 9 ] *= z; + te[ 2 ] *= x; te[ 6 ] *= y; te[ 10 ] *= z; + te[ 3 ] *= x; te[ 7 ] *= y; te[ 11 ] *= z; return this; @@ -703,9 +703,9 @@ THREE.Matrix4.prototype = { var te = this.elements; - var scaleXSq = te[0] * te[0] + te[1] * te[1] + te[2] * te[2]; - var scaleYSq = te[4] * te[4] + te[5] * te[5] + te[6] * te[6]; - var scaleZSq = te[8] * te[8] + te[9] * te[9] + te[10] * te[10]; + var scaleXSq = te[ 0 ] * te[ 0 ] + te[ 1 ] * te[ 1 ] + te[ 2 ] * te[ 2 ]; + var scaleYSq = te[ 4 ] * te[ 4 ] + te[ 5 ] * te[ 5 ] + te[ 6 ] * te[ 6 ]; + var scaleZSq = te[ 8 ] * te[ 8 ] + te[ 9 ] * te[ 9 ] + te[ 10 ] * te[ 10 ]; return Math.sqrt( Math.max( scaleXSq, Math.max( scaleYSq, scaleZSq ) ) ); @@ -834,19 +834,19 @@ THREE.Matrix4.prototype = { var te = this.elements; - var sx = vector.set( te[0], te[1], te[2] ).length(); - var sy = vector.set( te[4], te[5], te[6] ).length(); - var sz = vector.set( te[8], te[9], te[10] ).length(); + var sx = vector.set( te[ 0 ], te[ 1 ], te[ 2 ] ).length(); + var sy = vector.set( te[ 4 ], te[ 5 ], te[ 6 ] ).length(); + var sz = vector.set( te[ 8 ], te[ 9 ], te[ 10 ] ).length(); // if determine is negative, we need to invert one scale var det = this.determinant(); - if( det < 0 ) { + if ( det < 0 ) { sx = -sx; } - position.x = te[12]; - position.y = te[13]; - position.z = te[14]; + position.x = te[ 12 ]; + position.y = te[ 13 ]; + position.z = te[ 14 ]; // scale the rotation part @@ -856,17 +856,17 @@ THREE.Matrix4.prototype = { var invSY = 1 / sy; var invSZ = 1 / sz; - matrix.elements[0] *= invSX; - matrix.elements[1] *= invSX; - matrix.elements[2] *= invSX; + matrix.elements[ 0 ] *= invSX; + matrix.elements[ 1 ] *= invSX; + matrix.elements[ 2 ] *= invSX; - matrix.elements[4] *= invSY; - matrix.elements[5] *= invSY; - matrix.elements[6] *= invSY; + matrix.elements[ 4 ] *= invSY; + matrix.elements[ 5 ] *= invSY; + matrix.elements[ 6 ] *= invSY; - matrix.elements[8] *= invSZ; - matrix.elements[9] *= invSZ; - matrix.elements[10] *= invSZ; + matrix.elements[ 8 ] *= invSZ; + matrix.elements[ 9 ] *= invSZ; + matrix.elements[ 10 ] *= invSZ; quaternion.setFromRotationMatrix( matrix ); @@ -888,13 +888,13 @@ THREE.Matrix4.prototype = { var a = ( right + left ) / ( right - left ); var b = ( top + bottom ) / ( top - bottom ); - var c = - ( far + near ) / ( far - near ); - var d = - 2 * far * near / ( far - near ); + var c = -( far + near ) / ( far - near ); + var d = -2 * far * near / ( far - near ); - te[0] = x; te[4] = 0; te[8] = a; te[12] = 0; - te[1] = 0; te[5] = y; te[9] = b; te[13] = 0; - te[2] = 0; te[6] = 0; te[10] = c; te[14] = d; - te[3] = 0; te[7] = 0; te[11] = - 1; te[15] = 0; + te[ 0 ] = x; te[ 4 ] = 0; te[ 8 ] = a; te[ 12 ] = 0; + te[ 1 ] = 0; te[ 5 ] = y; te[ 9 ] = b; te[ 13 ] = 0; + te[ 2 ] = 0; te[ 6 ] = 0; te[ 10 ] = c; te[ 14 ] = d; + te[ 3 ] = 0; te[ 7 ] = 0; te[ 11 ] = -1; te[ 15 ] = 0; return this; @@ -922,10 +922,10 @@ THREE.Matrix4.prototype = { var y = ( top + bottom ) / h; var z = ( far + near ) / p; - te[0] = 2 / w; te[4] = 0; te[8] = 0; te[12] = -x; - te[1] = 0; te[5] = 2 / h; te[9] = 0; te[13] = -y; - te[2] = 0; te[6] = 0; te[10] = -2/p; te[14] = -z; - te[3] = 0; te[7] = 0; te[11] = 0; te[15] = 1; + te[ 0 ] = 2 / w; te[ 4 ] = 0; te[ 8 ] = 0; te[ 12 ] = -x; + te[ 1 ] = 0; te[ 5 ] = 2 / h; te[ 9 ] = 0; te[ 13 ] = -y; + te[ 2 ] = 0; te[ 6 ] = 0; te[ 10 ] = -2 / p; te[ 14 ] = -z; + te[ 3 ] = 0; te[ 7 ] = 0; te[ 11 ] = 0; te[ 15 ] = 1; return this; @@ -958,10 +958,10 @@ THREE.Matrix4.prototype = { return new THREE.Matrix4( - te[0], te[4], te[8], te[12], - te[1], te[5], te[9], te[13], - te[2], te[6], te[10], te[14], - te[3], te[7], te[11], te[15] + te[ 0 ], te[ 4 ], te[ 8 ], te[ 12 ], + te[ 1 ], te[ 5 ], te[ 9 ], te[ 13 ], + te[ 2 ], te[ 6 ], te[ 10 ], te[ 14 ], + te[ 3 ], te[ 7 ], te[ 11 ], te[ 15 ] ); diff --git a/src/math/Plane.js b/src/math/Plane.js index daf94cea54c76..a99c1e37858d5 100644 --- a/src/math/Plane.js +++ b/src/math/Plane.js @@ -128,7 +128,7 @@ THREE.Plane.prototype = { }, - intersectLine: function() { + intersectLine: function () { var v1 = new THREE.Vector3(); @@ -143,7 +143,7 @@ THREE.Plane.prototype = { if ( denominator == 0 ) { // line is coplanar, return origin - if( this.distanceToPoint( line.start ) == 0 ) { + if ( this.distanceToPoint( line.start ) == 0 ) { return result.copy( line.start ); @@ -154,9 +154,9 @@ THREE.Plane.prototype = { } - var t = - ( line.start.dot( this.normal ) + this.constant ) / denominator; + var t = -( line.start.dot( this.normal ) + this.constant ) / denominator; - if( t < 0 || t > 1 ) { + if ( t < 0 || t > 1 ) { return undefined; @@ -172,11 +172,11 @@ THREE.Plane.prototype = { coplanarPoint: function ( optionalTarget ) { var result = optionalTarget || new THREE.Vector3(); - return result.copy( this.normal ).multiplyScalar( - this.constant ); + return result.copy( this.normal ).multiplyScalar( -this.constant ); }, - applyMatrix4: function() { + applyMatrix4: function () { var v1 = new THREE.Vector3(); var v2 = new THREE.Vector3(); @@ -188,7 +188,7 @@ THREE.Plane.prototype = { // http://www.songho.ca/opengl/gl_normaltransform.html var normalMatrix = optionalNormalMatrix || m1.getNormalMatrix( matrix ); var newNormal = v1.copy( this.normal ).applyMatrix3( normalMatrix ); - + var newCoplanarPoint = this.coplanarPoint( v2 ); newCoplanarPoint.applyMatrix4( matrix ); diff --git a/src/math/Quaternion.js b/src/math/Quaternion.js index 5028ac76c6520..5e9493ae8b506 100644 --- a/src/math/Quaternion.js +++ b/src/math/Quaternion.js @@ -193,9 +193,9 @@ THREE.Quaternion.prototype = { var te = m.elements, - m11 = te[0], m12 = te[4], m13 = te[8], - m21 = te[1], m22 = te[5], m23 = te[9], - m31 = te[2], m32 = te[6], m33 = te[10], + m11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ], + m21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ], + m31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ], trace = m11 + m22 + m33, s; @@ -213,19 +213,19 @@ THREE.Quaternion.prototype = { s = 2.0 * Math.sqrt( 1.0 + m11 - m22 - m33 ); - this._w = (m32 - m23 ) / s; + this._w = ( m32 - m23 ) / s; this._x = 0.25 * s; - this._y = (m12 + m21 ) / s; - this._z = (m13 + m31 ) / s; + this._y = ( m12 + m21 ) / s; + this._z = ( m13 + m31 ) / s; } else if ( m22 > m33 ) { s = 2.0 * Math.sqrt( 1.0 + m22 - m11 - m33 ); - this._w = (m13 - m31 ) / s; - this._x = (m12 + m21 ) / s; + this._w = ( m13 - m31 ) / s; + this._x = ( m12 + m21 ) / s; this._y = 0.25 * s; - this._z = (m23 + m32 ) / s; + this._z = ( m23 + m32 ) / s; } else { @@ -254,7 +254,7 @@ THREE.Quaternion.prototype = { var EPS = 0.000001; - return function( vFrom, vTo ) { + return function ( vFrom, vTo ) { if ( v1 === undefined ) v1 = new THREE.Vector3(); @@ -266,11 +266,11 @@ THREE.Quaternion.prototype = { if ( Math.abs( vFrom.x ) > Math.abs( vFrom.z ) ) { - v1.set( - vFrom.y, vFrom.x, 0 ); + v1.set( -vFrom.y, vFrom.x, 0 ); } else { - v1.set( 0, - vFrom.z, vFrom.y ); + v1.set( 0, -vFrom.z, vFrom.y ); } diff --git a/src/math/Ray.js b/src/math/Ray.js index c853bee341196..ab0a48a566d29 100644 --- a/src/math/Ray.js +++ b/src/math/Ray.js @@ -93,7 +93,7 @@ THREE.Ray.prototype = { }(), - distanceSqToSegment: function( v0, v1, optionalPointOnRay, optionalPointOnSegment ) { + distanceSqToSegment: function ( v0, v1, optionalPointOnRay, optionalPointOnSegment ) { // from http://www.geometrictools.com/LibMathematics/Distance/Wm5DistRay3Segment3.cpp // It returns the min distance between the ray and the segment @@ -249,7 +249,7 @@ THREE.Ray.prototype = { if ( denominator == 0 ) { // line is coplanar, return origin - if( plane.distanceToPoint( this.origin ) == 0 ) { + if ( plane.distanceToPoint( this.origin ) == 0 ) { return 0; @@ -300,59 +300,59 @@ THREE.Ray.prototype = { var tmin,tmax,tymin,tymax,tzmin,tzmax; - var invdirx = 1/this.direction.x, - invdiry = 1/this.direction.y, - invdirz = 1/this.direction.z; + var invdirx = 1 / this.direction.x, + invdiry = 1 / this.direction.y, + invdirz = 1 / this.direction.z; var origin = this.origin; - if (invdirx >= 0) { - - tmin = (box.min.x - origin.x) * invdirx; - tmax = (box.max.x - origin.x) * invdirx; + if ( invdirx >= 0 ) { - } else { + tmin = ( box.min.x - origin.x ) * invdirx; + tmax = ( box.max.x - origin.x ) * invdirx; - tmin = (box.max.x - origin.x) * invdirx; - tmax = (box.min.x - origin.x) * invdirx; - } + } else { - if (invdiry >= 0) { - - tymin = (box.min.y - origin.y) * invdiry; - tymax = (box.max.y - origin.y) * invdiry; + tmin = ( box.max.x - origin.x ) * invdirx; + tmax = ( box.min.x - origin.x ) * invdirx; + } + + if ( invdiry >= 0 ) { + + tymin = ( box.min.y - origin.y ) * invdiry; + tymax = ( box.max.y - origin.y ) * invdiry; } else { - tymin = (box.max.y - origin.y) * invdiry; - tymax = (box.min.y - origin.y) * invdiry; + tymin = ( box.max.y - origin.y ) * invdiry; + tymax = ( box.min.y - origin.y ) * invdiry; } - if ((tmin > tymax) || (tymin > tmax)) return null; + if ( ( tmin > tymax ) || ( tymin > tmax ) ) return null; // These lines also handle the case where tmin or tmax is NaN // (result of 0 * Infinity). x !== x returns true if x is NaN - - if (tymin > tmin || tmin !== tmin ) tmin = tymin; - if (tymax < tmax || tmax !== tmax ) tmax = tymax; + if ( tymin > tmin || tmin !== tmin ) tmin = tymin; - if (invdirz >= 0) { - - tzmin = (box.min.z - origin.z) * invdirz; - tzmax = (box.max.z - origin.z) * invdirz; + if ( tymax < tmax || tmax !== tmax ) tmax = tymax; + + if ( invdirz >= 0 ) { + + tzmin = ( box.min.z - origin.z ) * invdirz; + tzmax = ( box.max.z - origin.z ) * invdirz; } else { - tzmin = (box.max.z - origin.z) * invdirz; - tzmax = (box.min.z - origin.z) * invdirz; + tzmin = ( box.max.z - origin.z ) * invdirz; + tzmax = ( box.min.z - origin.z ) * invdirz; } - if ((tmin > tzmax) || (tzmin > tmax)) return null; + if ( ( tmin > tzmax ) || ( tzmin > tmax ) ) return null; - if (tzmin > tmin || tmin !== tmin ) tmin = tzmin; + if ( tzmin > tmin || tmin !== tmin ) tmin = tzmin; - if (tzmax < tmax || tmax !== tmax ) tmax = tzmax; + if ( tzmax < tmax || tmax !== tmax ) tmax = tzmax; //return point closest to the ray (positive side) @@ -362,7 +362,7 @@ THREE.Ray.prototype = { }, - intersectTriangle: function() { + intersectTriangle: function () { // Compute the offset origin, edges, and normal. var diff = new THREE.Vector3(); diff --git a/src/math/Spline.js b/src/math/Spline.js index fe4d7e8589271..b1e749930aac9 100644 --- a/src/math/Spline.js +++ b/src/math/Spline.js @@ -14,7 +14,7 @@ THREE.Spline = function ( points ) { point, intPoint, weight, w2, w3, pa, pb, pc, pd; - this.initFromArray = function( a ) { + this.initFromArray = function ( a ) { this.points = []; @@ -169,7 +169,7 @@ THREE.Spline = function ( points ) { var v0 = ( p2 - p0 ) * 0.5, v1 = ( p3 - p1 ) * 0.5; - return ( 2 * ( p1 - p2 ) + v0 + v1 ) * t3 + ( - 3 * ( p1 - p2 ) - 2 * v0 - v1 ) * t2 + v0 * t + p1; + return ( 2 * ( p1 - p2 ) + v0 + v1 ) * t3 + ( -3 * ( p1 - p2 ) - 2 * v0 - v1 ) * t2 + v0 * t + p1; }; diff --git a/src/math/Triangle.js b/src/math/Triangle.js index a4298dbdc5636..a0d9f60b3516e 100644 --- a/src/math/Triangle.js +++ b/src/math/Triangle.js @@ -11,7 +11,7 @@ THREE.Triangle = function ( a, b, c ) { }; -THREE.Triangle.normal = function() { +THREE.Triangle.normal = function () { var v0 = new THREE.Vector3(); @@ -24,7 +24,7 @@ THREE.Triangle.normal = function() { result.cross( v0 ); var resultLengthSq = result.lengthSq(); - if( resultLengthSq > 0 ) { + if ( resultLengthSq > 0 ) { return result.multiplyScalar( 1 / Math.sqrt( resultLengthSq ) ); @@ -38,7 +38,7 @@ THREE.Triangle.normal = function() { // static/instance method to calculate barycoordinates // based on: http://www.blackpawn.com/texts/pointinpoly/default.html -THREE.Triangle.barycoordFromPoint = function() { +THREE.Triangle.barycoordFromPoint = function () { var v0 = new THREE.Vector3(); var v1 = new THREE.Vector3(); @@ -61,7 +61,7 @@ THREE.Triangle.barycoordFromPoint = function() { var result = optionalTarget || new THREE.Vector3(); // colinear or singular triangle - if( denom == 0 ) { + if ( denom == 0 ) { // arbitrary location outside of triangle? // not sure if this is the best idea, maybe should be returning undefined return result.set( -2, -1, -1 ); @@ -78,7 +78,7 @@ THREE.Triangle.barycoordFromPoint = function() { }(); -THREE.Triangle.containsPoint = function() { +THREE.Triangle.containsPoint = function () { var v1 = new THREE.Vector3(); @@ -108,9 +108,9 @@ THREE.Triangle.prototype = { setFromPointsAndIndices: function ( points, i0, i1, i2 ) { - this.a.copy( points[i0] ); - this.b.copy( points[i1] ); - this.c.copy( points[i2] ); + this.a.copy( points[ i0 ] ); + this.b.copy( points[ i1 ] ); + this.c.copy( points[ i2 ] ); return this; @@ -126,7 +126,7 @@ THREE.Triangle.prototype = { }, - area: function() { + area: function () { var v0 = new THREE.Vector3(); var v1 = new THREE.Vector3(); diff --git a/src/math/Vector2.js b/src/math/Vector2.js index d9dbfa1ea9626..be1c445ee7fd2 100644 --- a/src/math/Vector2.js +++ b/src/math/Vector2.js @@ -47,7 +47,7 @@ THREE.Vector2.prototype = { case 0: this.x = value; break; case 1: this.y = value; break; - default: throw new Error( "index is out of range: " + index ); + default: throw new Error( 'index is out of range: ' + index ); } @@ -59,7 +59,7 @@ THREE.Vector2.prototype = { case 0: return this.x; case 1: return this.y; - default: throw new Error( "index is out of range: " + index ); + default: throw new Error( 'index is out of range: ' + index ); } @@ -132,7 +132,7 @@ THREE.Vector2.prototype = { return this; }, - + multiply: function ( v ) { this.x *= v.x; @@ -366,7 +366,7 @@ THREE.Vector2.prototype = { }, - equals: function( v ) { + equals: function ( v ) { return ( ( v.x === this.x ) && ( v.y === this.y ) ); diff --git a/src/math/Vector3.js b/src/math/Vector3.js index b9591bdbdfb6e..a45c818b9493e 100644 --- a/src/math/Vector3.js +++ b/src/math/Vector3.js @@ -60,7 +60,7 @@ THREE.Vector3.prototype = { case 0: this.x = value; break; case 1: this.y = value; break; case 2: this.z = value; break; - default: throw new Error( "index is out of range: " + index ); + default: throw new Error( 'index is out of range: ' + index ); } @@ -73,7 +73,7 @@ THREE.Vector3.prototype = { case 0: return this.x; case 1: return this.y; case 2: return this.z; - default: throw new Error( "index is out of range: " + index ); + default: throw new Error( 'index is out of range: ' + index ); } @@ -236,9 +236,9 @@ THREE.Vector3.prototype = { var e = m.elements; - this.x = e[0] * x + e[3] * y + e[6] * z; - this.y = e[1] * x + e[4] * y + e[7] * z; - this.z = e[2] * x + e[5] * y + e[8] * z; + this.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ] * z; + this.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ] * z; + this.z = e[ 2 ] * x + e[ 5 ] * y + e[ 8 ] * z; return this; @@ -252,9 +252,9 @@ THREE.Vector3.prototype = { var e = m.elements; - this.x = e[0] * x + e[4] * y + e[8] * z + e[12]; - this.y = e[1] * x + e[5] * y + e[9] * z + e[13]; - this.z = e[2] * x + e[6] * y + e[10] * z + e[14]; + this.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ]; + this.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ]; + this.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ]; return this; @@ -267,11 +267,11 @@ THREE.Vector3.prototype = { var x = this.x, y = this.y, z = this.z; var e = m.elements; - var d = 1 / ( e[3] * x + e[7] * y + e[11] * z + e[15] ); // perspective divide + var d = 1 / ( e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] ); // perspective divide - this.x = ( e[0] * x + e[4] * y + e[8] * z + e[12] ) * d; - this.y = ( e[1] * x + e[5] * y + e[9] * z + e[13] ) * d; - this.z = ( e[2] * x + e[6] * y + e[10] * z + e[14] ) * d; + this.x = ( e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] ) * d; + this.y = ( e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] ) * d; + this.z = ( e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] ) * d; return this; @@ -314,9 +314,9 @@ THREE.Vector3.prototype = { var e = m.elements; - this.x = e[0] * x + e[4] * y + e[8] * z; - this.y = e[1] * x + e[5] * y + e[9] * z; - this.z = e[2] * x + e[6] * y + e[10] * z; + this.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z; + this.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z; + this.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z; this.normalize(); @@ -674,19 +674,19 @@ THREE.Vector3.prototype = { setEulerFromRotationMatrix: function ( m, order ) { - console.error( "THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead."); + console.error( 'THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.' ); }, setEulerFromQuaternion: function ( q, order ) { - console.error( "THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead."); + console.error( 'THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.' ); }, getPositionFromMatrix: function ( m ) { - console.warn( "THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()." ); + console.warn( 'THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition().' ); return this.setFromMatrixPosition( m ); @@ -694,14 +694,14 @@ THREE.Vector3.prototype = { getScaleFromMatrix: function ( m ) { - console.warn( "THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()." ); + console.warn( 'THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale().' ); return this.setFromMatrixScale( m ); }, getColumnFromMatrix: function ( index, matrix ) { - console.warn( "THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()." ); + console.warn( 'THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn().' ); return this.setFromMatrixColumn( index, matrix ); diff --git a/src/math/Vector4.js b/src/math/Vector4.js index 70a269aca6ceb..4727ec4737fbd 100644 --- a/src/math/Vector4.js +++ b/src/math/Vector4.js @@ -70,7 +70,7 @@ THREE.Vector4.prototype = { case 1: this.y = value; break; case 2: this.z = value; break; case 3: this.w = value; break; - default: throw new Error( "index is out of range: " + index ); + default: throw new Error( 'index is out of range: ' + index ); } @@ -190,10 +190,10 @@ THREE.Vector4.prototype = { var e = m.elements; - this.x = e[0] * x + e[4] * y + e[8] * z + e[12] * w; - this.y = e[1] * x + e[5] * y + e[9] * z + e[13] * w; - this.z = e[2] * x + e[6] * y + e[10] * z + e[14] * w; - this.w = e[3] * x + e[7] * y + e[11] * z + e[15] * w; + this.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] * w; + this.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] * w; + this.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] * w; + this.w = e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] * w; return this; @@ -263,22 +263,22 @@ THREE.Vector4.prototype = { te = m.elements, - m11 = te[0], m12 = te[4], m13 = te[8], - m21 = te[1], m22 = te[5], m23 = te[9], - m31 = te[2], m32 = te[6], m33 = te[10]; + m11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ], + m21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ], + m31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ]; if ( ( Math.abs( m12 - m21 ) < epsilon ) - && ( Math.abs( m13 - m31 ) < epsilon ) - && ( Math.abs( m23 - m32 ) < epsilon ) ) { + && ( Math.abs( m13 - m31 ) < epsilon ) + && ( Math.abs( m23 - m32 ) < epsilon ) ) { // singularity found // first check for identity matrix which must have +1 for all terms // in leading diagonal and zero in other terms if ( ( Math.abs( m12 + m21 ) < epsilon2 ) - && ( Math.abs( m13 + m31 ) < epsilon2 ) - && ( Math.abs( m23 + m32 ) < epsilon2 ) - && ( Math.abs( m11 + m22 + m33 - 3 ) < epsilon2 ) ) { + && ( Math.abs( m13 + m31 ) < epsilon2 ) + && ( Math.abs( m23 + m32 ) < epsilon2 ) + && ( Math.abs( m11 + m22 + m33 - 3 ) < epsilon2 ) ) { // this singularity is identity matrix so angle = 0 diff --git a/src/objects/Bone.js b/src/objects/Bone.js index 270330cbcffdb..9ffef03da3e98 100644 --- a/src/objects/Bone.js +++ b/src/objects/Bone.js @@ -3,7 +3,7 @@ * @author alteredq / http://alteredqualia.com/ */ -THREE.Bone = function( belongsToSkin ) { +THREE.Bone = function ( belongsToSkin ) { THREE.Object3D.call( this ); diff --git a/src/objects/LOD.js b/src/objects/LOD.js index 72fd8c300a30b..a5f8a5a72be09 100644 --- a/src/objects/LOD.js +++ b/src/objects/LOD.js @@ -99,7 +99,7 @@ THREE.LOD.prototype.update = function () { } - for( ; i < l; i ++ ) { + for ( ; i < l; i ++ ) { this.objects[ i ].object.visible = false; @@ -118,9 +118,9 @@ THREE.LOD.prototype.clone = function ( object ) { THREE.Object3D.prototype.clone.call( this, object ); for ( var i = 0, l = this.objects.length; i < l; i ++ ) { - var x = this.objects[i].object.clone(); + var x = this.objects[ i ].object.clone(); x.visible = i === 0; - object.addLevel( x, this.objects[i].distance ); + object.addLevel( x, this.objects[ i ].distance ); } return object; diff --git a/src/objects/Line.js b/src/objects/Line.js index 7850f7b1f5271..3f806618cda47 100644 --- a/src/objects/Line.js +++ b/src/objects/Line.js @@ -25,7 +25,7 @@ THREE.Line.prototype.raycast = ( function () { var sphere = new THREE.Sphere(); return function ( raycaster, intersects ) { - + var precision = raycaster.linePrecision; var precisionSq = precision * precision; diff --git a/src/objects/Mesh.js b/src/objects/Mesh.js index 3c1069ef4e628..3faf59d2a7775 100644 --- a/src/objects/Mesh.js +++ b/src/objects/Mesh.js @@ -46,7 +46,7 @@ THREE.Mesh.prototype.getMorphTargetIndexByName = function ( name ) { } - console.log( "THREE.Mesh.getMorphTargetIndexByName: morph target " + name + " does not exist. Returning 0." ); + console.log( 'THREE.Mesh.getMorphTargetIndexByName: morph target ' + name + ' does not exist. Returning 0.' ); return 0; @@ -169,7 +169,7 @@ THREE.Mesh.prototype.raycast = ( function () { distance: distance, point: intersectionPoint, - indices: [a, b, c], + indices: [ a, b, c ], face: null, faceIndex: null, object: this diff --git a/src/objects/MorphAnimMesh.js b/src/objects/MorphAnimMesh.js index 657e1a33155f7..1ee7abf932eab 100644 --- a/src/objects/MorphAnimMesh.js +++ b/src/objects/MorphAnimMesh.js @@ -106,7 +106,7 @@ THREE.MorphAnimMesh.prototype.playAnimation = function ( label, fps ) { } else { - console.warn( "animation[" + label + "] undefined" ); + console.warn( 'animation[' + label + '] undefined' ); } diff --git a/src/objects/Skeleton.js b/src/objects/Skeleton.js index f8c36c515e9c5..2036e0588a62e 100644 --- a/src/objects/Skeleton.js +++ b/src/objects/Skeleton.js @@ -28,12 +28,12 @@ THREE.Skeleton = function ( boneList, useVertexTexture ) { bone = this.addBone(); bone.name = gbone.name; - bone.position.set( p[0], p[1], p[2] ); - bone.quaternion.set( q[0], q[1], q[2], q[3] ); + bone.position.set( p[ 0 ], p[ 1 ], p[ 2 ] ); + bone.quaternion.set( q[ 0 ], q[ 1 ], q[ 2 ], q[ 3 ] ); if ( s !== undefined ) { - bone.scale.set( s[0], s[1], s[2] ); + bone.scale.set( s[ 0 ], s[ 1 ], s[ 2 ] ); } else { @@ -103,7 +103,7 @@ THREE.Skeleton = function ( boneList, useVertexTexture ) { THREE.Skeleton.prototype = Object.create( THREE.Mesh.prototype ); -THREE.Skeleton.prototype.addBone = function( bone ) { +THREE.Skeleton.prototype.addBone = function ( bone ) { if ( bone === undefined ) { @@ -118,7 +118,7 @@ THREE.Skeleton.prototype.addBone = function( bone ) { }; -THREE.Skeleton.prototype.calculateInverses = function( bone ) { +THREE.Skeleton.prototype.calculateInverses = function ( bone ) { this.boneInverses = []; diff --git a/src/renderers/CanvasRenderer.js b/src/renderers/CanvasRenderer.js index edf3e2a954449..115f2164bc2af 100644 --- a/src/renderers/CanvasRenderer.js +++ b/src/renderers/CanvasRenderer.js @@ -557,8 +557,8 @@ THREE.CanvasRenderer = function ( parameters ) { } else { - var colorStyle1 = element.vertexColors[0].getStyle(); - var colorStyle2 = element.vertexColors[1].getStyle(); + var colorStyle1 = element.vertexColors[ 0 ].getStyle(); + var colorStyle2 = element.vertexColors[ 1 ].getStyle(); if ( colorStyle1 === colorStyle2 ) { diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 9a8cd82fa5415..58e159d6b0849 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -1129,7 +1129,7 @@ THREE.WebGLRenderer = function ( parameters ) { for ( v = 0; v < vl; v ++ ) { - vertex = vertices[ sortArray[v][1] ]; + vertex = vertices[ sortArray[ v ][ 1 ] ]; offset = v * 3; @@ -1143,7 +1143,7 @@ THREE.WebGLRenderer = function ( parameters ) { offset = c * 3; - color = colors[ sortArray[c][1] ]; + color = colors[ sortArray[ c ][ 1 ] ]; colorArray[ offset ] = color.r; colorArray[ offset + 1 ] = color.g; @@ -2906,7 +2906,7 @@ THREE.WebGLRenderer = function ( parameters ) { if ( attributes.uv >= 0 ) { - if ( object.geometry.faceVertexUvs[0] ) { + if ( object.geometry.faceVertexUvs[ 0 ] ) { _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglUVBuffer ); enableAttribute( attributes.uv ); @@ -2923,7 +2923,7 @@ THREE.WebGLRenderer = function ( parameters ) { if ( attributes.uv2 >= 0 ) { - if ( object.geometry.faceVertexUvs[1] ) { + if ( object.geometry.faceVertexUvs[ 1 ] ) { _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglUV2Buffer ); enableAttribute( attributes.uv2 ); @@ -3560,7 +3560,7 @@ THREE.WebGLRenderer = function ( parameters ) { } else { - object.render( function( object ) { _this.renderBufferImmediate( object, program, material ); } ); + object.render( function ( object ) { _this.renderBufferImmediate( object, program, material ); } ); } diff --git a/src/renderers/shaders/UniformsLib.js b/src/renderers/shaders/UniformsLib.js index 8e0597172f5a7..c68a297dac0fc 100644 --- a/src/renderers/shaders/UniformsLib.js +++ b/src/renderers/shaders/UniformsLib.js @@ -99,4 +99,4 @@ THREE.UniformsLib = { } -}; \ No newline at end of file +}; diff --git a/src/renderers/shaders/UniformsUtils.js b/src/renderers/shaders/UniformsUtils.js index 2c3cff56885ac..280015ba581a5 100644 --- a/src/renderers/shaders/UniformsUtils.js +++ b/src/renderers/shaders/UniformsUtils.js @@ -63,4 +63,4 @@ THREE.UniformsUtils = { } -}; \ No newline at end of file +}; diff --git a/src/renderers/webgl/WebGLShader.js b/src/renderers/webgl/WebGLShader.js index e0dae0a9a647d..a4db1bc6ab363 100644 --- a/src/renderers/webgl/WebGLShader.js +++ b/src/renderers/webgl/WebGLShader.js @@ -41,4 +41,4 @@ THREE.WebGLShader = ( function () { }; -} )(); \ No newline at end of file +} )(); diff --git a/src/scenes/Scene.js b/src/scenes/Scene.js index 84919072e9cd2..90da33fc7764c 100644 --- a/src/scenes/Scene.js +++ b/src/scenes/Scene.js @@ -117,7 +117,7 @@ THREE.Scene.prototype.clone = function ( object ) { if ( object === undefined ) object = new THREE.Scene(); - THREE.Object3D.prototype.clone.call(this, object); + THREE.Object3D.prototype.clone.call( this, object ); if ( this.fog !== null ) object.fog = this.fog.clone(); if ( this.overrideMaterial !== null ) object.overrideMaterial = this.overrideMaterial.clone(); diff --git a/src/textures/Texture.js b/src/textures/Texture.js index 8e180dc0f5b3c..d27901402f86a 100644 --- a/src/textures/Texture.js +++ b/src/textures/Texture.js @@ -63,7 +63,7 @@ THREE.Texture.prototype = { if ( texture === undefined ) texture = new THREE.Texture(); texture.image = this.image; - texture.mipmaps = this.mipmaps.slice(0); + texture.mipmaps = this.mipmaps.slice( 0 ); texture.mapping = this.mapping; From 89efa27c9c946f6a8dc9d4db25d9daf75f9150b9 Mon Sep 17 00:00:00 2001 From: Joshua Koo Date: Tue, 13 May 2014 10:09:30 +0800 Subject: [PATCH 2/4] Add codepainter script --- utils/codestyle/mrdoob_codepainter.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 utils/codestyle/mrdoob_codepainter.json diff --git a/utils/codestyle/mrdoob_codepainter.json b/utils/codestyle/mrdoob_codepainter.json new file mode 100644 index 0000000000000..7380ffbbb114d --- /dev/null +++ b/utils/codestyle/mrdoob_codepainter.json @@ -0,0 +1,12 @@ +{ + "indent_style": "tab", + "indent_size": "tab", + "insert_final_newline": true, + "quote_type": "auto", + "space_after_anonymous_functions": true, + "space_after_control_statements": true, + "spaces_around_operators": true, + "trim_trailing_whitespace": true, + "spaces_in_brackets": true, + "end_of_line": "lf" +} \ No newline at end of file From fa3007887c7009d7de18189ce81418b847ce0407 Mon Sep 17 00:00:00 2001 From: Joshua Koo Date: Tue, 20 May 2014 00:08:00 +0800 Subject: [PATCH 3/4] Fix code styles for prefixed unary operators JSCS rules: { "requireSpaceAfterPrefixUnaryOperators": [ "+", "-", "++", "--" ] } --- src/cameras/CubeCamera.js | 16 ++--- src/cameras/PerspectiveCamera.js | 2 +- src/core/BufferGeometry.js | 16 ++--- src/core/Geometry.js | 4 +- src/core/Projector.js | 16 ++--- src/extras/FontUtils.js | 6 +- src/extras/GeometryUtils.js | 2 +- src/extras/ImageUtils.js | 32 ++++----- src/extras/animation/AnimationHandler.js | 6 +- src/extras/core/Curve.js | 4 +- src/extras/core/CurvePath.js | 2 +- src/extras/core/Path.js | 4 +- src/extras/core/Shape.js | 2 +- src/extras/geometries/ExtrudeGeometry.js | 10 +-- src/extras/geometries/IcosahedronGeometry.js | 6 +- src/extras/geometries/OctahedronGeometry.js | 2 +- src/extras/geometries/PolyhedronGeometry.js | 4 +- src/extras/geometries/TetrahedronGeometry.js | 2 +- src/extras/geometries/TubeGeometry.js | 8 +-- src/extras/helpers/CameraHelper.js | 34 ++++----- src/extras/helpers/SpotLightHelper.js | 2 +- src/extras/objects/LensFlare.js | 6 +- src/extras/objects/MorphBlendMesh.js | 8 +-- .../renderers/plugins/LensFlarePlugin.js | 6 +- .../renderers/plugins/ShadowMapPlugin.js | 14 ++-- src/lights/AreaLight.js | 2 +- src/lights/DirectionalLight.js | 8 +-- src/math/Box2.js | 6 +- src/math/Box3.js | 6 +- src/math/Euler.js | 24 +++---- src/math/Frustum.js | 2 +- src/math/Math.js | 2 +- src/math/Matrix3.js | 8 +-- src/math/Matrix4.js | 46 ++++++------ src/math/Plane.js | 6 +- src/math/Quaternion.js | 20 +++--- src/math/Spline.js | 2 +- src/math/Triangle.js | 2 +- src/math/Vector3.js | 10 +-- src/math/Vector4.js | 2 +- src/objects/Mesh.js | 4 +- src/objects/MorphAnimMesh.js | 6 +- src/objects/PointCloud.js | 2 +- src/objects/Skeleton.js | 8 +-- src/objects/SkinnedMesh.js | 2 +- src/renderers/CanvasRenderer.js | 6 +- src/renderers/WebGLRenderer.js | 72 +++++++++---------- src/renderers/shaders/ShaderLib.js | 2 +- src/renderers/shaders/UniformsLib.js | 2 +- src/scenes/Scene.js | 6 +- 50 files changed, 235 insertions(+), 235 deletions(-) diff --git a/src/cameras/CubeCamera.js b/src/cameras/CubeCamera.js index 637b87f7d94c1..2192c16358f07 100644 --- a/src/cameras/CubeCamera.js +++ b/src/cameras/CubeCamera.js @@ -12,13 +12,13 @@ THREE.CubeCamera = function ( near, far, cubeResolution ) { var fov = 90, aspect = 1; var cameraPX = new THREE.PerspectiveCamera( fov, aspect, near, far ); - cameraPX.up.set( 0, -1, 0 ); + cameraPX.up.set( 0, - 1, 0 ); cameraPX.lookAt( new THREE.Vector3( 1, 0, 0 ) ); this.add( cameraPX ); var cameraNX = new THREE.PerspectiveCamera( fov, aspect, near, far ); - cameraNX.up.set( 0, -1, 0 ); - cameraNX.lookAt( new THREE.Vector3( -1, 0, 0 ) ); + cameraNX.up.set( 0, - 1, 0 ); + cameraNX.lookAt( new THREE.Vector3( - 1, 0, 0 ) ); this.add( cameraNX ); var cameraPY = new THREE.PerspectiveCamera( fov, aspect, near, far ); @@ -27,18 +27,18 @@ THREE.CubeCamera = function ( near, far, cubeResolution ) { this.add( cameraPY ); var cameraNY = new THREE.PerspectiveCamera( fov, aspect, near, far ); - cameraNY.up.set( 0, 0, -1 ); - cameraNY.lookAt( new THREE.Vector3( 0, -1, 0 ) ); + cameraNY.up.set( 0, 0, - 1 ); + cameraNY.lookAt( new THREE.Vector3( 0, - 1, 0 ) ); this.add( cameraNY ); var cameraPZ = new THREE.PerspectiveCamera( fov, aspect, near, far ); - cameraPZ.up.set( 0, -1, 0 ); + cameraPZ.up.set( 0, - 1, 0 ); cameraPZ.lookAt( new THREE.Vector3( 0, 0, 1 ) ); this.add( cameraPZ ); var cameraNZ = new THREE.PerspectiveCamera( fov, aspect, near, far ); - cameraNZ.up.set( 0, -1, 0 ); - cameraNZ.lookAt( new THREE.Vector3( 0, 0, -1 ) ); + cameraNZ.up.set( 0, - 1, 0 ); + cameraNZ.lookAt( new THREE.Vector3( 0, 0, - 1 ) ); this.add( cameraNZ ); this.renderTarget = new THREE.WebGLRenderTargetCube( cubeResolution, cubeResolution, { format: THREE.RGBFormat, magFilter: THREE.LinearFilter, minFilter: THREE.LinearFilter } ); diff --git a/src/cameras/PerspectiveCamera.js b/src/cameras/PerspectiveCamera.js index 73c21e7abff86..0fdbc687ea3ba 100644 --- a/src/cameras/PerspectiveCamera.js +++ b/src/cameras/PerspectiveCamera.js @@ -92,7 +92,7 @@ THREE.PerspectiveCamera.prototype.updateProjectionMatrix = function () { var aspect = this.fullWidth / this.fullHeight; var top = Math.tan( THREE.Math.degToRad( this.fov * 0.5 ) ) * this.near; - var bottom = -top; + var bottom = - top; var left = aspect * bottom; var right = aspect * top; var width = Math.abs( right - left ); diff --git a/src/core/BufferGeometry.js b/src/core/BufferGeometry.js index 367050634a911..996a20a21f262 100644 --- a/src/core/BufferGeometry.js +++ b/src/core/BufferGeometry.js @@ -533,7 +533,7 @@ THREE.BufferGeometry.prototype = { tmp2.crossVectors( n2, t ); test = tmp2.dot( tan2[ v ] ); - w = ( test < 0.0 ) ? -1.0 : 1.0; + w = ( test < 0.0 ) ? - 1.0 : 1.0; tangents[ v * 4 ] = tmp.x; tangents[ v * 4 + 1 ] = tmp.y; @@ -603,7 +603,7 @@ THREE.BufferGeometry.prototype = { var faceVertices = new Int32Array( 6 ); var vertexMap = new Int32Array( vertices.length ); var revVertexMap = new Int32Array( vertices.length ); - for ( var j = 0; j < vertices.length; j++ ) { vertexMap[ j ] = -1; revVertexMap[ j ] = -1; } + for ( var j = 0; j < vertices.length; j++ ) { vertexMap[ j ] = - 1; revVertexMap[ j ] = - 1; } /* Traverse every face and reorder vertices in the proper offsets of 65k. @@ -614,15 +614,15 @@ THREE.BufferGeometry.prototype = { for ( var vo = 0; vo < 3; vo++ ) { var vid = indices[ findex * 3 + vo ]; - if ( vertexMap[ vid ] == -1 ) { + if ( vertexMap[ vid ] == - 1 ) { //Unmapped vertice faceVertices[ vo * 2 ] = vid; - faceVertices[ vo * 2 + 1 ] = -1; + faceVertices[ vo * 2 + 1 ] = - 1; newVerticeMaps++; } else if ( vertexMap[ vid ] < offset.index ) { //Reused vertices from previous block (duplicate) faceVertices[ vo * 2 ] = vid; - faceVertices[ vo * 2 + 1 ] = -1; + faceVertices[ vo * 2 + 1 ] = - 1; duplicatedVertices++; } else { //Reused vertice in the current block @@ -640,8 +640,8 @@ THREE.BufferGeometry.prototype = { //Re-evaluate reused vertices in light of new offset. for ( var v = 0; v < 6; v += 2 ) { var new_vid = faceVertices[ v + 1 ]; - if ( new_vid > -1 && new_vid < offset.index ) - faceVertices[ v + 1 ] = -1; + if ( new_vid > - 1 && new_vid < offset.index ) + faceVertices[ v + 1 ] = - 1; } } @@ -650,7 +650,7 @@ THREE.BufferGeometry.prototype = { var vid = faceVertices[ v ]; var new_vid = faceVertices[ v + 1 ]; - if ( new_vid === -1 ) + if ( new_vid === - 1 ) new_vid = vertexPtr++; vertexMap[ vid ] = new_vid; diff --git a/src/core/Geometry.js b/src/core/Geometry.js index 8fc94592b6128..f3723369d95e0 100644 --- a/src/core/Geometry.js +++ b/src/core/Geometry.js @@ -398,7 +398,7 @@ THREE.Geometry.prototype = { tmp2.crossVectors( face.vertexNormals[ i ], t ); test = tmp2.dot( tan2[ vertexIndex ] ); - w = ( test < 0.0 ) ? -1.0 : 1.0; + w = ( test < 0.0 ) ? - 1.0 : 1.0; face.vertexTangents[ i ] = new THREE.Vector4( tmp.x, tmp.y, tmp.z, w ); @@ -616,7 +616,7 @@ THREE.Geometry.prototype = { indices = [ face.a, face.b, face.c ]; - var dupIndex = -1; + var dupIndex = - 1; // if any duplicate vertices are found in a Face3 // we have to remove the face as nothing can be saved diff --git a/src/core/Projector.js b/src/core/Projector.js index ebcbc7151478f..b57d4be641924 100644 --- a/src/core/Projector.js +++ b/src/core/Projector.js @@ -21,7 +21,7 @@ THREE.Projector = function () { _vector3 = new THREE.Vector3(), _vector4 = new THREE.Vector4(), - _clipBox = new THREE.Box3( new THREE.Vector3( -1, -1, -1 ), new THREE.Vector3( 1, 1, 1 ) ), + _clipBox = new THREE.Box3( new THREE.Vector3( - 1, - 1, - 1 ), new THREE.Vector3( 1, 1, 1 ) ), _boundingBox = new THREE.Box3(), _points3 = new Array( 3 ), _points4 = new Array( 4 ), @@ -67,7 +67,7 @@ THREE.Projector = function () { this.pickingRay = function ( vector, camera ) { // set two vectors with opposing z values - vector.z = -1.0; + vector.z = - 1.0; var end = new THREE.Vector3( vector.x, vector.y, 1.0 ); this.unprojectVector( vector, camera ); @@ -176,9 +176,9 @@ THREE.Projector = function () { positionScreen.y *= invW; positionScreen.z *= invW; - vertex.visible = positionScreen.x >= -1 && positionScreen.x <= 1 && - positionScreen.y >= -1 && positionScreen.y <= 1 && - positionScreen.z >= -1 && positionScreen.z <= 1; + vertex.visible = positionScreen.x >= - 1 && positionScreen.x <= 1 && + positionScreen.y >= - 1 && positionScreen.y <= 1 && + positionScreen.z >= - 1 && positionScreen.z <= 1; }; @@ -664,7 +664,7 @@ THREE.Projector = function () { _vector4.z *= invW; - if ( _vector4.z >= -1 && _vector4.z <= 1 ) { + if ( _vector4.z >= - 1 && _vector4.z <= 1 ) { _sprite = getNextSpriteInPool(); _sprite.id = object.id; @@ -805,8 +805,8 @@ THREE.Projector = function () { // Z = -1 and Z = +1, respectively. bc1near = s1.z + s1.w, bc2near = s2.z + s2.w, - bc1far = -s1.z + s1.w, - bc2far = -s2.z + s2.w; + bc1far = - s1.z + s1.w, + bc2far = - s2.z + s2.w; if ( bc1near >= 0 && bc2near >= 0 && bc1far >= 0 && bc2far >= 0 ) { diff --git a/src/extras/FontUtils.js b/src/extras/FontUtils.js index aec97aab10089..7dfe00023fc7f 100644 --- a/src/extras/FontUtils.js +++ b/src/extras/FontUtils.js @@ -187,9 +187,9 @@ THREE.FontUtils = { cpx = outline[ i++ ] * scaleX + offset; cpy = outline[ i++ ] * scaleY; cpx1 = outline[ i++ ] * scaleX + offset; - cpy1 = outline[ i++ ] * -scaleY; + cpy1 = outline[ i++ ] * - scaleY; cpx2 = outline[ i++ ] * scaleX + offset; - cpy2 = outline[ i++ ] * -scaleY; + cpy2 = outline[ i++ ] * - scaleY; path.bezierCurveTo( cpx, cpy, cpx1, cpy1, cpx2, cpy2 ); @@ -441,7 +441,7 @@ THREE.FontUtils.generateShapes = function ( text, parameters ) { cCROSSap = cX * apy - cY * apx; bCROSScp = bX * cpy - bY * cpx; - if ( ( aCROSSbp >= -EPSILON ) && ( bCROSScp >= -EPSILON ) && ( cCROSSap >= -EPSILON ) ) return false; + if ( ( aCROSSbp >= - EPSILON ) && ( bCROSScp >= - EPSILON ) && ( cCROSSap >= - EPSILON ) ) return false; } diff --git a/src/extras/GeometryUtils.js b/src/extras/GeometryUtils.js index c5836a2749ab3..0a9dee6819566 100644 --- a/src/extras/GeometryUtils.js +++ b/src/extras/GeometryUtils.js @@ -215,7 +215,7 @@ THREE.GeometryUtils = { var offset = new THREE.Vector3(); offset.addVectors( bb.min, bb.max ); - offset.multiplyScalar( -0.5 ); + offset.multiplyScalar( - 0.5 ); geometry.applyMatrix( new THREE.Matrix4().makeTranslation( offset.x, offset.y, offset.z ) ); geometry.computeBoundingBox(); diff --git a/src/extras/ImageUtils.js b/src/extras/ImageUtils.js index f15bbefa8e82a..4c4d6dedadb8c 100644 --- a/src/extras/ImageUtils.js +++ b/src/extras/ImageUtils.js @@ -392,12 +392,12 @@ THREE.ImageUtils = { // RLE pixels. if ( c & 0x80 ) { // Bind pixel tmp array - for ( i = 0; i < pixel_size; ++i ) { + for ( i = 0; i < pixel_size; ++ i ) { pixels[ i ] = data[ offset++ ]; } // Copy pixel array - for ( i = 0; i < count; ++i ) { + for ( i = 0; i < count; ++ i ) { pixel_data.set( pixels, shift + i * pixel_size ); } @@ -407,7 +407,7 @@ THREE.ImageUtils = { // Raw pixels. else { count *= pixel_size; - for ( i = 0; i < count; ++i ) { + for ( i = 0; i < count; ++ i ) { pixel_data[ shift + i ] = data[ offset++ ]; } shift += count; @@ -554,14 +554,14 @@ THREE.ImageUtils = { x_step = 1; x_end = width; y_start = height - 1; - y_step = -1; - y_end = -1; + y_step = - 1; + y_end = - 1; break; case TGA_ORIGIN_UR: x_start = width - 1; - x_step = -1; - x_end = -1; + x_step = - 1; + x_end = - 1; y_start = 0; y_step = 1; y_end = height; @@ -569,11 +569,11 @@ THREE.ImageUtils = { case TGA_ORIGIN_BR: x_start = width - 1; - x_step = -1; - x_end = -1; + x_step = - 1; + x_end = - 1; y_start = height - 1; - y_step = -1; - y_end = -1; + y_step = - 1; + y_end = - 1; break; } @@ -1021,14 +1021,14 @@ THREE.ImageUtils = { var points = []; var origin = [ 0, 0, data[ ( y * width + x ) * 4 ] / 255 * depth ]; - points.push( [ -1, 0, data[ ( y * width + lx ) * 4 ] / 255 * depth ] ); - points.push( [ -1, -1, data[ ( ly * width + lx ) * 4 ] / 255 * depth ] ); - points.push( [ 0, -1, data[ ( ly * width + x ) * 4 ] / 255 * depth ] ); - points.push( [ 1, -1, data[ ( ly * width + ux ) * 4 ] / 255 * depth ] ); + points.push( [ - 1, 0, data[ ( y * width + lx ) * 4 ] / 255 * depth ] ); + points.push( [ - 1, - 1, data[ ( ly * width + lx ) * 4 ] / 255 * depth ] ); + points.push( [ 0, - 1, data[ ( ly * width + x ) * 4 ] / 255 * depth ] ); + points.push( [ 1, - 1, data[ ( ly * width + ux ) * 4 ] / 255 * depth ] ); points.push( [ 1, 0, data[ ( y * width + ux ) * 4 ] / 255 * depth ] ); points.push( [ 1, 1, data[ ( uy * width + ux ) * 4 ] / 255 * depth ] ); points.push( [ 0, 1, data[ ( uy * width + x ) * 4 ] / 255 * depth ] ); - points.push( [ -1, 1, data[ ( uy * width + lx ) * 4 ] / 255 * depth ] ); + points.push( [ - 1, 1, data[ ( uy * width + lx ) * 4 ] / 255 * depth ] ); var normals = []; var num_points = points.length; diff --git a/src/extras/animation/AnimationHandler.js b/src/extras/animation/AnimationHandler.js index 97d48f54bf0d4..242eaa4cf1c6f 100644 --- a/src/extras/animation/AnimationHandler.js +++ b/src/extras/animation/AnimationHandler.js @@ -61,7 +61,7 @@ THREE.AnimationHandler = { for ( var m = 0; m < data.hierarchy[ h ].keys[ k ].morphTargets.length; m ++ ) { var morphTargetName = data.hierarchy[ h ].keys[ k ].morphTargets[ m ]; - usedMorphTargets[ morphTargetName ] = -1; + usedMorphTargets[ morphTargetName ] = - 1; } @@ -169,7 +169,7 @@ THREE.AnimationHandler = { play: function ( animation ) { - if ( this.animations.indexOf( animation ) === -1 ) { + if ( this.animations.indexOf( animation ) === - 1 ) { this.animations.push( animation ); @@ -181,7 +181,7 @@ THREE.AnimationHandler = { var index = this.animations.indexOf( animation ); - if ( index !== -1 ) { + if ( index !== - 1 ) { this.animations.splice( index, 1 ); diff --git a/src/extras/core/Curve.js b/src/extras/core/Curve.js index f967e42e4834a..300a660fadf23 100644 --- a/src/extras/core/Curve.js +++ b/src/extras/core/Curve.js @@ -282,7 +282,7 @@ THREE.Curve.Utils = { tangentCubicBezier: function (t, p0, p1, p2, p3 ) { - return -3 * p0 * (1 - t) * (1 - t) + + return - 3 * p0 * (1 - t) * (1 - t) + 3 * p1 * (1 - t) * (1-t) - 6 *t *p1 * (1-t) + 6 * t * p2 * (1-t) - 3 * t * t * p2 + 3 * t * t * p3; @@ -295,7 +295,7 @@ THREE.Curve.Utils = { var h00 = 6 * t * t - 6 * t; // derived from 2t^3 − 3t^2 + 1 var h10 = 3 * t * t - 4 * t + 1; // t^3 − 2t^2 + t - var h01 = -6 * t * t + 6 * t; // − 2t3 + 3t2 + var h01 = - 6 * t * t + 6 * t; // − 2t3 + 3t2 var h11 = 3 * t * t - 2 * t; // t3 − t2 return h00 + h10 + h01 + h11; diff --git a/src/extras/core/CurvePath.js b/src/extras/core/CurvePath.js index 6d74d1e816513..44096125155bc 100644 --- a/src/extras/core/CurvePath.js +++ b/src/extras/core/CurvePath.js @@ -312,7 +312,7 @@ THREE.CurvePath.prototype.getWrapPoints = function ( oldPts, path ) { var pathPt = path.getPoint( xNorm ); var normal = path.getTangent( xNorm ); - normal.set( -normal.y, normal.x ).multiplyScalar( oldY ); + normal.set( - normal.y, normal.x ).multiplyScalar( oldY ); p.x = pathPt.x + normal.x; p.y = pathPt.y + normal.y; diff --git a/src/extras/core/Path.js b/src/extras/core/Path.js index be6d753b96cba..505aa52cb66b0 100644 --- a/src/extras/core/Path.js +++ b/src/extras/core/Path.js @@ -528,8 +528,8 @@ THREE.Path.prototype.toShapes = function( isCCW, noHoles ) { if ( Math.abs(edgeDy) > EPSILON ) { // not parallel if ( edgeDy < 0 ) { - edgeLowPt = inPolygon[ q ]; edgeDx = -edgeDx; - edgeHighPt = inPolygon[ p ]; edgeDy = -edgeDy; + edgeLowPt = inPolygon[ q ]; edgeDx = - edgeDx; + edgeHighPt = inPolygon[ p ]; edgeDy = - edgeDy; } if ( ( inPt.y < edgeLowPt.y ) || ( inPt.y > edgeHighPt.y ) ) continue; diff --git a/src/extras/core/Shape.js b/src/extras/core/Shape.js index ef899b56c7b78..c1f3a7171cf71 100644 --- a/src/extras/core/Shape.js +++ b/src/extras/core/Shape.js @@ -391,7 +391,7 @@ THREE.Shape.Utils = { for ( shapeIndex = minShapeIndex; shapeIndex < shape.length; shapeIndex++ ) { shapePt = shape[ shapeIndex ]; - holeIndex = -1; + holeIndex = - 1; // search for hole which can be reached without intersections for ( var h = 0; h < indepHoles.length; h ++ ) { diff --git a/src/extras/geometries/ExtrudeGeometry.js b/src/extras/geometries/ExtrudeGeometry.js index 3d505240f48ec..d82abea1066c3 100644 --- a/src/extras/geometries/ExtrudeGeometry.js +++ b/src/extras/geometries/ExtrudeGeometry.js @@ -261,8 +261,8 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) { if ( v_prev_x > EPSILON ) { if ( v_next_x > EPSILON ) { direction_eq = true; } } else { - if ( v_prev_x < -EPSILON ) { - if ( v_next_x < -EPSILON ) { direction_eq = true; } + if ( v_prev_x < - EPSILON ) { + if ( v_next_x < - EPSILON ) { direction_eq = true; } } else { if ( sign(v_prev_y) == sign(v_next_y) ) { direction_eq = true; } } @@ -270,7 +270,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) { if ( direction_eq ) { // console.log("Warning: lines are a straight sequence"); - v_trans_x = -v_prev_y; + v_trans_x = - v_prev_y; v_trans_y = v_prev_x; shrink_by = Math.sqrt( v_prev_lensq ); } else { @@ -362,7 +362,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) { vert = scalePt2( ahole[ i ], oneHoleMovements[ i ], bs ); - v( vert.x, vert.y, -z ); + v( vert.x, vert.y, - z ); } @@ -565,7 +565,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) { var j, k; i = contour.length; - while ( --i >= 0 ) { + while ( -- i >= 0 ) { j = i; k = i - 1; diff --git a/src/extras/geometries/IcosahedronGeometry.js b/src/extras/geometries/IcosahedronGeometry.js index 62430b2f064b9..c0d2fd97518ec 100644 --- a/src/extras/geometries/IcosahedronGeometry.js +++ b/src/extras/geometries/IcosahedronGeometry.js @@ -12,9 +12,9 @@ THREE.IcosahedronGeometry = function ( radius, detail ) { var t = ( 1 + Math.sqrt( 5 ) ) / 2; var vertices = [ - -1, t, 0, 1, t, 0, -1, -t, 0, 1, -t, 0, - 0, -1, t, 0, 1, t, 0, -1, -t, 0, 1, -t, - t, 0, -1, t, 0, 1, -t, 0, -1, -t, 0, 1 + - 1, t, 0, 1, t, 0, - 1, - t, 0, 1, - t, 0, + 0, - 1, t, 0, 1, t, 0, - 1, - t, 0, 1, - t, + t, 0, - 1, t, 0, 1, - t, 0, - 1, - t, 0, 1 ]; var indices = [ diff --git a/src/extras/geometries/OctahedronGeometry.js b/src/extras/geometries/OctahedronGeometry.js index 9e1a9ca483905..2f5db8245cb24 100644 --- a/src/extras/geometries/OctahedronGeometry.js +++ b/src/extras/geometries/OctahedronGeometry.js @@ -10,7 +10,7 @@ THREE.OctahedronGeometry = function ( radius, detail ) { }; var vertices = [ - 1, 0, 0, -1, 0, 0, 0, 1, 0, 0,-1, 0, 0, 0, 1, 0, 0,-1 + 1, 0, 0, - 1, 0, 0, 0, 1, 0, 0,- 1, 0, 0, 0, 1, 0, 0,- 1 ]; var indices = [ diff --git a/src/extras/geometries/PolyhedronGeometry.js b/src/extras/geometries/PolyhedronGeometry.js index a010620fadf0e..25b2510797315 100644 --- a/src/extras/geometries/PolyhedronGeometry.js +++ b/src/extras/geometries/PolyhedronGeometry.js @@ -196,7 +196,7 @@ THREE.PolyhedronGeometry = function ( vertices, indices, radius, detail ) { function azimuth( vector ) { - return Math.atan2( vector.z, -vector.x ); + return Math.atan2( vector.z, - vector.x ); } @@ -205,7 +205,7 @@ THREE.PolyhedronGeometry = function ( vertices, indices, radius, detail ) { function inclination( vector ) { - return Math.atan2( -vector.y, Math.sqrt( ( vector.x * vector.x ) + ( vector.z * vector.z ) ) ); + return Math.atan2( - vector.y, Math.sqrt( ( vector.x * vector.x ) + ( vector.z * vector.z ) ) ); } diff --git a/src/extras/geometries/TetrahedronGeometry.js b/src/extras/geometries/TetrahedronGeometry.js index 055afb59dda75..f79833572d39e 100644 --- a/src/extras/geometries/TetrahedronGeometry.js +++ b/src/extras/geometries/TetrahedronGeometry.js @@ -5,7 +5,7 @@ THREE.TetrahedronGeometry = function ( radius, detail ) { var vertices = [ - 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1 + 1, 1, 1, - 1, - 1, 1, - 1, 1, - 1, 1, - 1, - 1 ]; var indices = [ diff --git a/src/extras/geometries/TubeGeometry.js b/src/extras/geometries/TubeGeometry.js index 88efb5a2ae3cf..7c023e8254355 100644 --- a/src/extras/geometries/TubeGeometry.js +++ b/src/extras/geometries/TubeGeometry.js @@ -83,7 +83,7 @@ THREE.TubeGeometry = function ( path, segments, radius, radialSegments, closed ) v = j / radialSegments * 2 * Math.PI; - cx = -radius * Math.cos( v ); // TODO: Hack: Negating it so it faces outside. + cx = - radius * Math.cos( v ); // TODO: Hack: Negating it so it faces outside. cy = radius * Math.sin( v ); pos2.copy( pos ); @@ -242,7 +242,7 @@ THREE.TubeGeometry.FrenetFrames = function ( path, segments, closed ) { vec.normalize(); - theta = Math.acos( THREE.Math.clamp( tangents[ i-1 ].dot( tangents[ i ] ), -1, 1 ) ); // clamp for floating pt errors + theta = Math.acos( THREE.Math.clamp( tangents[ i-1 ].dot( tangents[ i ] ), - 1, 1 ) ); // clamp for floating pt errors normals[ i ].applyMatrix4( mat.makeRotationAxis( vec, theta ) ); @@ -257,12 +257,12 @@ THREE.TubeGeometry.FrenetFrames = function ( path, segments, closed ) { if ( closed ) { - theta = Math.acos( THREE.Math.clamp( normals[ 0 ].dot( normals[ numpoints-1 ] ), -1, 1 ) ); + theta = Math.acos( THREE.Math.clamp( normals[ 0 ].dot( normals[ numpoints-1 ] ), - 1, 1 ) ); theta /= ( numpoints - 1 ); if ( tangents[ 0 ].dot( vec.crossVectors( normals[ 0 ], normals[ numpoints-1 ] ) ) > 0 ) { - theta = -theta; + theta = - theta; } diff --git a/src/extras/helpers/CameraHelper.js b/src/extras/helpers/CameraHelper.js index b6f997fc3af83..ba9f24a06b25e 100644 --- a/src/extras/helpers/CameraHelper.js +++ b/src/extras/helpers/CameraHelper.js @@ -124,40 +124,40 @@ THREE.CameraHelper.prototype.update = function () { // center / target - setPoint( "c", 0, 0, -1 ); + setPoint( "c", 0, 0, - 1 ); setPoint( "t", 0, 0, 1 ); // near - setPoint( "n1", -w, -h, -1 ); - setPoint( "n2", w, -h, -1 ); - setPoint( "n3", -w, h, -1 ); - setPoint( "n4", w, h, -1 ); + setPoint( "n1", - w, - h, - 1 ); + setPoint( "n2", w, - h, - 1 ); + setPoint( "n3", - w, h, - 1 ); + setPoint( "n4", w, h, - 1 ); // far - setPoint( "f1", -w, -h, 1 ); - setPoint( "f2", w, -h, 1 ); - setPoint( "f3", -w, h, 1 ); + setPoint( "f1", - w, - h, 1 ); + setPoint( "f2", w, - h, 1 ); + setPoint( "f3", - w, h, 1 ); setPoint( "f4", w, h, 1 ); // up - setPoint( "u1", w * 0.7, h * 1.1, -1 ); - setPoint( "u2", -w * 0.7, h * 1.1, -1 ); - setPoint( "u3", 0, h * 2, -1 ); + setPoint( "u1", w * 0.7, h * 1.1, - 1 ); + setPoint( "u2", - w * 0.7, h * 1.1, - 1 ); + setPoint( "u3", 0, h * 2, - 1 ); // cross - setPoint( "cf1", -w, 0, 1 ); + setPoint( "cf1", - w, 0, 1 ); setPoint( "cf2", w, 0, 1 ); - setPoint( "cf3", 0, -h, 1 ); + setPoint( "cf3", 0, - h, 1 ); setPoint( "cf4", 0, h, 1 ); - setPoint( "cn1", -w, 0, -1 ); - setPoint( "cn2", w, 0, -1 ); - setPoint( "cn3", 0, -h, -1 ); - setPoint( "cn4", 0, h, -1 ); + setPoint( "cn1", - w, 0, - 1 ); + setPoint( "cn2", w, 0, - 1 ); + setPoint( "cn3", 0, - h, - 1 ); + setPoint( "cn4", 0, h, - 1 ); function setPoint( point, x, y, z ) { diff --git a/src/extras/helpers/SpotLightHelper.js b/src/extras/helpers/SpotLightHelper.js index 1b233f1d2c3a7..8cfc75f513db1 100644 --- a/src/extras/helpers/SpotLightHelper.js +++ b/src/extras/helpers/SpotLightHelper.js @@ -16,7 +16,7 @@ THREE.SpotLightHelper = function ( light ) { var geometry = new THREE.CylinderGeometry( 0, 1, 1, 8, 1, true ); - geometry.applyMatrix( new THREE.Matrix4().makeTranslation( 0, -0.5, 0 ) ); + geometry.applyMatrix( new THREE.Matrix4().makeTranslation( 0, - 0.5, 0 ) ); geometry.applyMatrix( new THREE.Matrix4().makeRotationX( - Math.PI / 2 ) ); var material = new THREE.MeshBasicMaterial( { wireframe: true, fog: false } ); diff --git a/src/extras/objects/LensFlare.js b/src/extras/objects/LensFlare.js index 23c9f00657bdd..e89c174889b0c 100644 --- a/src/extras/objects/LensFlare.js +++ b/src/extras/objects/LensFlare.js @@ -29,7 +29,7 @@ THREE.LensFlare.prototype = Object.create( THREE.Object3D.prototype ); THREE.LensFlare.prototype.add = function ( texture, size, distance, blending, color, opacity ) { - if( size === undefined ) size = -1; + if( size === undefined ) size = - 1; if( distance === undefined ) distance = 0; if( opacity === undefined ) opacity = 1; if( color === undefined ) color = new THREE.Color( 0xffffff ); @@ -59,8 +59,8 @@ THREE.LensFlare.prototype.updateLensFlares = function () { var f, fl = this.lensFlares.length; var flare; - var vecX = -this.positionScreen.x * 2; - var vecY = -this.positionScreen.y * 2; + var vecX = - this.positionScreen.x * 2; + var vecY = - this.positionScreen.y * 2; for( f = 0; f < fl; f ++ ) { diff --git a/src/extras/objects/MorphBlendMesh.js b/src/extras/objects/MorphBlendMesh.js index e26a9d1085b91..1e396407eb64c 100644 --- a/src/extras/objects/MorphBlendMesh.js +++ b/src/extras/objects/MorphBlendMesh.js @@ -77,7 +77,7 @@ THREE.MorphBlendMesh.prototype.autoCreateAnimations = function ( fps ) { var name = chunks[ 1 ]; var num = chunks[ 2 ]; - if ( ! frameRanges[ name ] ) frameRanges[ name ] = { start: Infinity, end: -Infinity }; + if ( ! frameRanges[ name ] ) frameRanges[ name ] = { start: Infinity, end: - Infinity }; var range = frameRanges[ name ]; @@ -120,7 +120,7 @@ THREE.MorphBlendMesh.prototype.setAnimationDirectionBackward = function ( name ) if ( animation ) { - animation.direction = -1; + animation.direction = - 1; animation.directionBackwards = true; } @@ -195,7 +195,7 @@ THREE.MorphBlendMesh.prototype.getAnimationTime = function ( name ) { THREE.MorphBlendMesh.prototype.getAnimationDuration = function ( name ) { - var duration = -1; + var duration = - 1; var animation = this.animationsMap[ name ]; @@ -254,7 +254,7 @@ THREE.MorphBlendMesh.prototype.update = function ( delta ) { if ( animation.time > animation.duration || animation.time < 0 ) { - animation.direction *= -1; + animation.direction *= - 1; if ( animation.time > animation.duration ) { diff --git a/src/extras/renderers/plugins/LensFlarePlugin.js b/src/extras/renderers/plugins/LensFlarePlugin.js index ab901929d0f78..8c80710ac42ce 100644 --- a/src/extras/renderers/plugins/LensFlarePlugin.js +++ b/src/extras/renderers/plugins/LensFlarePlugin.js @@ -18,16 +18,16 @@ THREE.LensFlarePlugin = function () { _lensFlare.faces = new Uint16Array( 6 ); var i = 0; - _lensFlare.vertices[ i++ ] = -1; _lensFlare.vertices[ i++ ] = -1; // vertex + _lensFlare.vertices[ i++ ] = - 1; _lensFlare.vertices[ i++ ] = - 1; // vertex _lensFlare.vertices[ i++ ] = 0; _lensFlare.vertices[ i++ ] = 0; // uv... etc. - _lensFlare.vertices[ i++ ] = 1; _lensFlare.vertices[ i++ ] = -1; + _lensFlare.vertices[ i++ ] = 1; _lensFlare.vertices[ i++ ] = - 1; _lensFlare.vertices[ i++ ] = 1; _lensFlare.vertices[ i++ ] = 0; _lensFlare.vertices[ i++ ] = 1; _lensFlare.vertices[ i++ ] = 1; _lensFlare.vertices[ i++ ] = 1; _lensFlare.vertices[ i++ ] = 1; - _lensFlare.vertices[ i++ ] = -1; _lensFlare.vertices[ i++ ] = 1; + _lensFlare.vertices[ i++ ] = - 1; _lensFlare.vertices[ i++ ] = 1; _lensFlare.vertices[ i++ ] = 0; _lensFlare.vertices[ i++ ] = 1; i = 0; diff --git a/src/extras/renderers/plugins/ShadowMapPlugin.js b/src/extras/renderers/plugins/ShadowMapPlugin.js index 1937c120eb72a..3353252509256 100644 --- a/src/extras/renderers/plugins/ShadowMapPlugin.js +++ b/src/extras/renderers/plugins/ShadowMapPlugin.js @@ -392,14 +392,14 @@ THREE.ShadowMapPlugin = function () { var nearZ = light.shadowCascadeNearZ[ cascade ]; var farZ = light.shadowCascadeFarZ[ cascade ]; - pointsFrustum[ 0 ].set( -1, -1, nearZ ); - pointsFrustum[ 1 ].set( 1, -1, nearZ ); - pointsFrustum[ 2 ].set( -1, 1, nearZ ); + pointsFrustum[ 0 ].set( - 1, - 1, nearZ ); + pointsFrustum[ 1 ].set( 1, - 1, nearZ ); + pointsFrustum[ 2 ].set( - 1, 1, nearZ ); pointsFrustum[ 3 ].set( 1, 1, nearZ ); - pointsFrustum[ 4 ].set( -1, -1, farZ ); - pointsFrustum[ 5 ].set( 1, -1, farZ ); - pointsFrustum[ 6 ].set( -1, 1, farZ ); + pointsFrustum[ 4 ].set( - 1, - 1, farZ ); + pointsFrustum[ 5 ].set( 1, - 1, farZ ); + pointsFrustum[ 6 ].set( - 1, 1, farZ ); pointsFrustum[ 7 ].set( 1, 1, farZ ); return virtualLight; @@ -447,7 +447,7 @@ THREE.ShadowMapPlugin = function () { pointsWorld = light.pointsWorld; _min.set( Infinity, Infinity, Infinity ); - _max.set( -Infinity, -Infinity, -Infinity ); + _max.set( - Infinity, - Infinity, - Infinity ); for ( var i = 0; i < 8; i ++ ) { diff --git a/src/lights/AreaLight.js b/src/lights/AreaLight.js index 970f428003c04..bdd3be1e4f882 100644 --- a/src/lights/AreaLight.js +++ b/src/lights/AreaLight.js @@ -7,7 +7,7 @@ THREE.AreaLight = function ( color, intensity ) { THREE.Light.call( this, color ); - this.normal = new THREE.Vector3( 0, -1, 0 ); + this.normal = new THREE.Vector3( 0, - 1, 0 ); this.right = new THREE.Vector3( 1, 0, 0 ); this.intensity = ( intensity !== undefined ) ? intensity : 1; diff --git a/src/lights/DirectionalLight.js b/src/lights/DirectionalLight.js index c929f0bb7fe45..5ca62895c68f5 100644 --- a/src/lights/DirectionalLight.js +++ b/src/lights/DirectionalLight.js @@ -20,10 +20,10 @@ THREE.DirectionalLight = function ( color, intensity ) { this.shadowCameraNear = 50; this.shadowCameraFar = 5000; - this.shadowCameraLeft = -500; + this.shadowCameraLeft = - 500; this.shadowCameraRight = 500; this.shadowCameraTop = 500; - this.shadowCameraBottom = -500; + this.shadowCameraBottom = - 500; this.shadowCameraVisible = false; @@ -37,14 +37,14 @@ THREE.DirectionalLight = function ( color, intensity ) { this.shadowCascade = false; - this.shadowCascadeOffset = new THREE.Vector3( 0, 0, -1000 ); + this.shadowCascadeOffset = new THREE.Vector3( 0, 0, - 1000 ); this.shadowCascadeCount = 2; this.shadowCascadeBias = [ 0, 0, 0 ]; this.shadowCascadeWidth = [ 512, 512, 512 ]; this.shadowCascadeHeight = [ 512, 512, 512 ]; - this.shadowCascadeNearZ = [ -1.000, 0.990, 0.998 ]; + this.shadowCascadeNearZ = [ - 1.000, 0.990, 0.998 ]; this.shadowCascadeFarZ = [ 0.990, 0.998, 1.000 ]; this.shadowCascadeArray = []; diff --git a/src/math/Box2.js b/src/math/Box2.js index 721f2705982f2..baad0955699f7 100644 --- a/src/math/Box2.js +++ b/src/math/Box2.js @@ -5,7 +5,7 @@ THREE.Box2 = function ( min, max ) { this.min = ( min !== undefined ) ? min : new THREE.Vector2( Infinity, Infinity ); - this.max = ( max !== undefined ) ? max : new THREE.Vector2( -Infinity, -Infinity ); + this.max = ( max !== undefined ) ? max : new THREE.Vector2( - Infinity, - Infinity ); }; @@ -95,7 +95,7 @@ THREE.Box2.prototype = { makeEmpty: function () { this.min.x = this.min.y = Infinity; - this.max.x = this.max.y = -Infinity; + this.max.x = this.max.y = - Infinity; return this; @@ -141,7 +141,7 @@ THREE.Box2.prototype = { expandByScalar: function ( scalar ) { - this.min.addScalar( -scalar ); + this.min.addScalar( - scalar ); this.max.addScalar( scalar ); return this; diff --git a/src/math/Box3.js b/src/math/Box3.js index c78418e46f390..a0504c5bbef05 100644 --- a/src/math/Box3.js +++ b/src/math/Box3.js @@ -6,7 +6,7 @@ THREE.Box3 = function ( min, max ) { this.min = ( min !== undefined ) ? min : new THREE.Vector3( Infinity, Infinity, Infinity ); - this.max = ( max !== undefined ) ? max : new THREE.Vector3( -Infinity, -Infinity, -Infinity ); + this.max = ( max !== undefined ) ? max : new THREE.Vector3( - Infinity, - Infinity, - Infinity ); }; @@ -154,7 +154,7 @@ THREE.Box3.prototype = { makeEmpty: function () { this.min.x = this.min.y = this.min.z = Infinity; - this.max.x = this.max.y = this.max.z = -Infinity; + this.max.x = this.max.y = this.max.z = - Infinity; return this; @@ -202,7 +202,7 @@ THREE.Box3.prototype = { expandByScalar: function ( scalar ) { - this.min.addScalar( -scalar ); + this.min.addScalar( - scalar ); this.max.addScalar( scalar ); return this; diff --git a/src/math/Euler.js b/src/math/Euler.js index 39538d88e832a..9e087f15fb1e6 100644 --- a/src/math/Euler.js +++ b/src/math/Euler.js @@ -116,7 +116,7 @@ THREE.Euler.prototype = { if ( order === 'XYZ' ) { - this._y = Math.asin( clamp( m13, -1, 1 ) ); + this._y = Math.asin( clamp( m13, - 1, 1 ) ); if ( Math.abs( m13 ) < 0.99999 ) { @@ -132,7 +132,7 @@ THREE.Euler.prototype = { } else if ( order === 'YXZ' ) { - this._x = Math.asin( - clamp( m23, -1, 1 ) ); + this._x = Math.asin( - clamp( m23, - 1, 1 ) ); if ( Math.abs( m23 ) < 0.99999 ) { @@ -148,7 +148,7 @@ THREE.Euler.prototype = { } else if ( order === 'ZXY' ) { - this._x = Math.asin( clamp( m32, -1, 1 ) ); + this._x = Math.asin( clamp( m32, - 1, 1 ) ); if ( Math.abs( m32 ) < 0.99999 ) { @@ -164,7 +164,7 @@ THREE.Euler.prototype = { } else if ( order === 'ZYX' ) { - this._y = Math.asin( - clamp( m31, -1, 1 ) ); + this._y = Math.asin( - clamp( m31, - 1, 1 ) ); if ( Math.abs( m31 ) < 0.99999 ) { @@ -180,7 +180,7 @@ THREE.Euler.prototype = { } else if ( order === 'YZX' ) { - this._z = Math.asin( clamp( m21, -1, 1 ) ); + this._z = Math.asin( clamp( m21, - 1, 1 ) ); if ( Math.abs( m21 ) < 0.99999 ) { @@ -196,7 +196,7 @@ THREE.Euler.prototype = { } else if ( order === 'XZY' ) { - this._z = Math.asin( - clamp( m12, -1, 1 ) ); + this._z = Math.asin( - clamp( m12, - 1, 1 ) ); if ( Math.abs( m12 ) < 0.99999 ) { @@ -242,38 +242,38 @@ THREE.Euler.prototype = { if ( order === 'XYZ' ) { this._x = Math.atan2( 2 * ( q.x * q.w - q.y * q.z ), ( sqw - sqx - sqy + sqz ) ); - this._y = Math.asin( clamp( 2 * ( q.x * q.z + q.y * q.w ), -1, 1 ) ); + this._y = Math.asin( clamp( 2 * ( q.x * q.z + q.y * q.w ), - 1, 1 ) ); this._z = Math.atan2( 2 * ( q.z * q.w - q.x * q.y ), ( sqw + sqx - sqy - sqz ) ); } else if ( order === 'YXZ' ) { - this._x = Math.asin( clamp( 2 * ( q.x * q.w - q.y * q.z ), -1, 1 ) ); + this._x = Math.asin( clamp( 2 * ( q.x * q.w - q.y * q.z ), - 1, 1 ) ); this._y = Math.atan2( 2 * ( q.x * q.z + q.y * q.w ), ( sqw - sqx - sqy + sqz ) ); this._z = Math.atan2( 2 * ( q.x * q.y + q.z * q.w ), ( sqw - sqx + sqy - sqz ) ); } else if ( order === 'ZXY' ) { - this._x = Math.asin( clamp( 2 * ( q.x * q.w + q.y * q.z ), -1, 1 ) ); + this._x = Math.asin( clamp( 2 * ( q.x * q.w + q.y * q.z ), - 1, 1 ) ); this._y = Math.atan2( 2 * ( q.y * q.w - q.z * q.x ), ( sqw - sqx - sqy + sqz ) ); this._z = Math.atan2( 2 * ( q.z * q.w - q.x * q.y ), ( sqw - sqx + sqy - sqz ) ); } else if ( order === 'ZYX' ) { this._x = Math.atan2( 2 * ( q.x * q.w + q.z * q.y ), ( sqw - sqx - sqy + sqz ) ); - this._y = Math.asin( clamp( 2 * ( q.y * q.w - q.x * q.z ), -1, 1 ) ); + this._y = Math.asin( clamp( 2 * ( q.y * q.w - q.x * q.z ), - 1, 1 ) ); this._z = Math.atan2( 2 * ( q.x * q.y + q.z * q.w ), ( sqw + sqx - sqy - sqz ) ); } else if ( order === 'YZX' ) { this._x = Math.atan2( 2 * ( q.x * q.w - q.z * q.y ), ( sqw - sqx + sqy - sqz ) ); this._y = Math.atan2( 2 * ( q.y * q.w - q.x * q.z ), ( sqw + sqx - sqy - sqz ) ); - this._z = Math.asin( clamp( 2 * ( q.x * q.y + q.z * q.w ), -1, 1 ) ); + this._z = Math.asin( clamp( 2 * ( q.x * q.y + q.z * q.w ), - 1, 1 ) ); } else if ( order === 'XZY' ) { this._x = Math.atan2( 2 * ( q.x * q.w + q.y * q.z ), ( sqw - sqx + sqy - sqz ) ); this._y = Math.atan2( 2 * ( q.x * q.z + q.y * q.w ), ( sqw + sqx - sqy - sqz ) ); - this._z = Math.asin( clamp( 2 * ( q.z * q.w - q.x * q.y ), -1, 1 ) ); + this._z = Math.asin( clamp( 2 * ( q.z * q.w - q.x * q.y ), - 1, 1 ) ); } else { diff --git a/src/math/Frustum.js b/src/math/Frustum.js index 4a2698d72cf26..9ba481a534797 100644 --- a/src/math/Frustum.js +++ b/src/math/Frustum.js @@ -95,7 +95,7 @@ THREE.Frustum.prototype = { var planes = this.planes; var center = sphere.center; - var negRadius = -sphere.radius; + var negRadius = - sphere.radius; for ( var i = 0; i < 6; i ++ ) { diff --git a/src/math/Math.js b/src/math/Math.js index 3dcfb93e55f76..fbbaf633117a1 100644 --- a/src/math/Math.js +++ b/src/math/Math.js @@ -124,7 +124,7 @@ THREE.Math = { sign: function ( x ) { - return ( x < 0 ) ? -1 : ( x > 0 ) ? 1 : 0; + return ( x < 0 ) ? - 1 : ( x > 0 ) ? 1 : 0; }, diff --git a/src/math/Matrix3.js b/src/math/Matrix3.js index 7bd54b491a843..2f90ddf734cd0 100644 --- a/src/math/Matrix3.js +++ b/src/math/Matrix3.js @@ -138,13 +138,13 @@ THREE.Matrix3.prototype = { var te = this.elements; te[ 0 ] = me[ 10 ] * me[ 5 ] - me[ 6 ] * me[ 9 ]; - te[ 1 ] = -me[ 10 ] * me[ 1 ] + me[ 2 ] * me[ 9 ]; + te[ 1 ] = - me[ 10 ] * me[ 1 ] + me[ 2 ] * me[ 9 ]; te[ 2 ] = me[ 6 ] * me[ 1 ] - me[ 2 ] * me[ 5 ]; - te[ 3 ] = -me[ 10 ] * me[ 4 ] + me[ 6 ] * me[ 8 ]; + te[ 3 ] = - me[ 10 ] * me[ 4 ] + me[ 6 ] * me[ 8 ]; te[ 4 ] = me[ 10 ] * me[ 0 ] - me[ 2 ] * me[ 8 ]; - te[ 5 ] = -me[ 6 ] * me[ 0 ] + me[ 2 ] * me[ 4 ]; + te[ 5 ] = - me[ 6 ] * me[ 0 ] + me[ 2 ] * me[ 4 ]; te[ 6 ] = me[ 9 ] * me[ 4 ] - me[ 5 ] * me[ 8 ]; - te[ 7 ] = -me[ 9 ] * me[ 0 ] + me[ 1 ] * me[ 8 ]; + te[ 7 ] = - me[ 9 ] * me[ 0 ] + me[ 1 ] * me[ 8 ]; te[ 8 ] = me[ 5 ] * me[ 0 ] - me[ 1 ] * me[ 4 ]; var det = me[ 0 ] * te[ 0 ] + me[ 1 ] * te[ 3 ] + me[ 2 ] * te[ 6 ]; diff --git a/src/math/Matrix4.js b/src/math/Matrix4.js index 005fe9d94abaa..e95ccf3d2a284 100644 --- a/src/math/Matrix4.js +++ b/src/math/Matrix4.js @@ -139,12 +139,12 @@ THREE.Matrix4.prototype = { var ae = a * e, af = a * f, be = b * e, bf = b * f; te[ 0 ] = c * e; - te[ 4 ] = -c * f; + te[ 4 ] = - c * f; te[ 8 ] = d; te[ 1 ] = af + be * d; te[ 5 ] = ae - bf * d; - te[ 9 ] = -b * c; + te[ 9 ] = - b * c; te[ 2 ] = bf - ae * d; te[ 6 ] = be + af * d; @@ -160,7 +160,7 @@ THREE.Matrix4.prototype = { te[ 1 ] = a * f; te[ 5 ] = a * e; - te[ 9 ] = -b; + te[ 9 ] = - b; te[ 2 ] = cf * b - de; te[ 6 ] = df + ce * b; @@ -171,14 +171,14 @@ THREE.Matrix4.prototype = { var ce = c * e, cf = c * f, de = d * e, df = d * f; te[ 0 ] = ce - df * b; - te[ 4 ] = -a * f; + te[ 4 ] = - a * f; te[ 8 ] = de + cf * b; te[ 1 ] = cf + de * b; te[ 5 ] = a * e; te[ 9 ] = df - ce * b; - te[ 2 ] = -a * d; + te[ 2 ] = - a * d; te[ 6 ] = b; te[ 10 ] = a * c; @@ -194,7 +194,7 @@ THREE.Matrix4.prototype = { te[ 5 ] = bf * d + ae; te[ 9 ] = af * d - be; - te[ 2 ] = -d; + te[ 2 ] = - d; te[ 6 ] = b * c; te[ 10 ] = a * c; @@ -208,9 +208,9 @@ THREE.Matrix4.prototype = { te[ 1 ] = f; te[ 5 ] = a * e; - te[ 9 ] = -b * e; + te[ 9 ] = - b * e; - te[ 2 ] = -d * e; + te[ 2 ] = - d * e; te[ 6 ] = ad * f + bc; te[ 10 ] = ac - bd * f; @@ -219,7 +219,7 @@ THREE.Matrix4.prototype = { var ac = a * c, ad = a * d, bc = b * c, bd = b * d; te[ 0 ] = c * e; - te[ 4 ] = -f; + te[ 4 ] = - f; te[ 8 ] = d * e; te[ 1 ] = ac * f + bd; @@ -492,7 +492,7 @@ THREE.Matrix4.prototype = { return ( n41 * ( - +n14 * n23 * n32 + + n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 @@ -500,7 +500,7 @@ THREE.Matrix4.prototype = { - n12 * n23 * n34 ) + n42 * ( - +n11 * n23 * n34 + + n11 * n23 * n34 - n11 * n24 * n33 + n14 * n21 * n33 - n13 * n21 * n34 @@ -508,7 +508,7 @@ THREE.Matrix4.prototype = { - n14 * n23 * n31 ) + n43 * ( - +n11 * n24 * n32 + + n11 * n24 * n32 - n11 * n22 * n34 - n14 * n21 * n32 + n12 * n21 * n34 @@ -516,7 +516,7 @@ THREE.Matrix4.prototype = { - n12 * n24 * n31 ) + n44 * ( - -n13 * n22 * n31 + - n13 * n22 * n31 - n11 * n23 * n32 + n11 * n22 * n33 + n13 * n21 * n32 @@ -733,7 +733,7 @@ THREE.Matrix4.prototype = { this.set( 1, 0, 0, 0, - 0, c, -s, 0, + 0, c, - s, 0, 0, s, c, 0, 0, 0, 0, 1 @@ -751,7 +751,7 @@ THREE.Matrix4.prototype = { c, 0, s, 0, 0, 1, 0, 0, - -s, 0, c, 0, + - s, 0, c, 0, 0, 0, 0, 1 ); @@ -766,7 +766,7 @@ THREE.Matrix4.prototype = { this.set( - c, -s, 0, 0, + c, - s, 0, 0, s, c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 @@ -841,7 +841,7 @@ THREE.Matrix4.prototype = { // if determine is negative, we need to invert one scale var det = this.determinant(); if ( det < 0 ) { - sx = -sx; + sx = - sx; } position.x = te[ 12 ]; @@ -888,13 +888,13 @@ THREE.Matrix4.prototype = { var a = ( right + left ) / ( right - left ); var b = ( top + bottom ) / ( top - bottom ); - var c = -( far + near ) / ( far - near ); - var d = -2 * far * near / ( far - near ); + var c = - ( far + near ) / ( far - near ); + var d = - 2 * far * near / ( far - near ); te[ 0 ] = x; te[ 4 ] = 0; te[ 8 ] = a; te[ 12 ] = 0; te[ 1 ] = 0; te[ 5 ] = y; te[ 9 ] = b; te[ 13 ] = 0; te[ 2 ] = 0; te[ 6 ] = 0; te[ 10 ] = c; te[ 14 ] = d; - te[ 3 ] = 0; te[ 7 ] = 0; te[ 11 ] = -1; te[ 15 ] = 0; + te[ 3 ] = 0; te[ 7 ] = 0; te[ 11 ] = - 1; te[ 15 ] = 0; return this; @@ -922,9 +922,9 @@ THREE.Matrix4.prototype = { var y = ( top + bottom ) / h; var z = ( far + near ) / p; - te[ 0 ] = 2 / w; te[ 4 ] = 0; te[ 8 ] = 0; te[ 12 ] = -x; - te[ 1 ] = 0; te[ 5 ] = 2 / h; te[ 9 ] = 0; te[ 13 ] = -y; - te[ 2 ] = 0; te[ 6 ] = 0; te[ 10 ] = -2 / p; te[ 14 ] = -z; + te[ 0 ] = 2 / w; te[ 4 ] = 0; te[ 8 ] = 0; te[ 12 ] = - x; + te[ 1 ] = 0; te[ 5 ] = 2 / h; te[ 9 ] = 0; te[ 13 ] = - y; + te[ 2 ] = 0; te[ 6 ] = 0; te[ 10 ] = - 2 / p; te[ 14 ] = - z; te[ 3 ] = 0; te[ 7 ] = 0; te[ 11 ] = 0; te[ 15 ] = 1; return this; diff --git a/src/math/Plane.js b/src/math/Plane.js index a99c1e37858d5..71cdea546417e 100644 --- a/src/math/Plane.js +++ b/src/math/Plane.js @@ -83,7 +83,7 @@ THREE.Plane.prototype = { negate: function () { - this.constant *= -1; + this.constant *= - 1; this.normal.negate(); return this; @@ -154,7 +154,7 @@ THREE.Plane.prototype = { } - var t = -( line.start.dot( this.normal ) + this.constant ) / denominator; + var t = - ( line.start.dot( this.normal ) + this.constant ) / denominator; if ( t < 0 || t > 1 ) { @@ -172,7 +172,7 @@ THREE.Plane.prototype = { coplanarPoint: function ( optionalTarget ) { var result = optionalTarget || new THREE.Vector3(); - return result.copy( this.normal ).multiplyScalar( -this.constant ); + return result.copy( this.normal ).multiplyScalar( - this.constant ); }, diff --git a/src/math/Quaternion.js b/src/math/Quaternion.js index 5e9493ae8b506..c50f55b0c0cb8 100644 --- a/src/math/Quaternion.js +++ b/src/math/Quaternion.js @@ -266,11 +266,11 @@ THREE.Quaternion.prototype = { if ( Math.abs( vFrom.x ) > Math.abs( vFrom.z ) ) { - v1.set( -vFrom.y, vFrom.x, 0 ); + v1.set( - vFrom.y, vFrom.x, 0 ); } else { - v1.set( 0, -vFrom.z, vFrom.y ); + v1.set( 0, - vFrom.z, vFrom.y ); } @@ -303,9 +303,9 @@ THREE.Quaternion.prototype = { conjugate: function () { - this._x *= -1; - this._y *= -1; - this._z *= -1; + this._x *= - 1; + this._y *= - 1; + this._z *= - 1; this.onChangeCallback(); @@ -401,12 +401,12 @@ THREE.Quaternion.prototype = { if ( cosHalfTheta < 0 ) { - this._w = -qb._w; - this._x = -qb._x; - this._y = -qb._y; - this._z = -qb._z; + this._w = - qb._w; + this._x = - qb._x; + this._y = - qb._y; + this._z = - qb._z; - cosHalfTheta = -cosHalfTheta; + cosHalfTheta = - cosHalfTheta; } else { diff --git a/src/math/Spline.js b/src/math/Spline.js index b1e749930aac9..d54039a226e7a 100644 --- a/src/math/Spline.js +++ b/src/math/Spline.js @@ -169,7 +169,7 @@ THREE.Spline = function ( points ) { var v0 = ( p2 - p0 ) * 0.5, v1 = ( p3 - p1 ) * 0.5; - return ( 2 * ( p1 - p2 ) + v0 + v1 ) * t3 + ( -3 * ( p1 - p2 ) - 2 * v0 - v1 ) * t2 + v0 * t + p1; + return ( 2 * ( p1 - p2 ) + v0 + v1 ) * t3 + ( - 3 * ( p1 - p2 ) - 2 * v0 - v1 ) * t2 + v0 * t + p1; }; diff --git a/src/math/Triangle.js b/src/math/Triangle.js index a0d9f60b3516e..a329cfb3979cb 100644 --- a/src/math/Triangle.js +++ b/src/math/Triangle.js @@ -64,7 +64,7 @@ THREE.Triangle.barycoordFromPoint = function () { if ( denom == 0 ) { // arbitrary location outside of triangle? // not sure if this is the best idea, maybe should be returning undefined - return result.set( -2, -1, -1 ); + return result.set( - 2, - 1, - 1 ); } var invDenom = 1 / denom; diff --git a/src/math/Vector3.js b/src/math/Vector3.js index a45c818b9493e..fdc8160369317 100644 --- a/src/math/Vector3.js +++ b/src/math/Vector3.js @@ -293,13 +293,13 @@ THREE.Vector3.prototype = { var ix = qw * x + qy * z - qz * y; var iy = qw * y + qz * x - qx * z; var iz = qw * z + qx * y - qy * x; - var iw = -qx * x - qy * y - qz * z; + var iw = - qx * x - qy * y - qz * z; // calculate result * inverse quat - this.x = ix * qw + iw * -qx + iy * -qz - iz * -qy; - this.y = iy * qw + iw * -qy + iz * -qx - ix * -qz; - this.z = iz * qw + iw * -qz + ix * -qy - iy * -qx; + this.x = ix * qw + iw * - qx + iy * - qz - iz * - qy; + this.y = iy * qw + iw * - qy + iz * - qx - ix * - qz; + this.z = iz * qw + iw * - qz + ix * - qy - iy * - qx; return this; @@ -652,7 +652,7 @@ THREE.Vector3.prototype = { // clamp, to handle numerical problems - return Math.acos( THREE.Math.clamp( theta, -1, 1 ) ); + return Math.acos( THREE.Math.clamp( theta, - 1, 1 ) ); }, diff --git a/src/math/Vector4.js b/src/math/Vector4.js index 4727ec4737fbd..3ee19242a8b24 100644 --- a/src/math/Vector4.js +++ b/src/math/Vector4.js @@ -551,7 +551,7 @@ THREE.Vector4.prototype = { negate: function () { - return this.multiplyScalar( -1 ); + return this.multiplyScalar( - 1 ); }, diff --git a/src/objects/Mesh.js b/src/objects/Mesh.js index 3faf59d2a7775..66c4f1116094e 100644 --- a/src/objects/Mesh.js +++ b/src/objects/Mesh.js @@ -22,7 +22,7 @@ THREE.Mesh.prototype.updateMorphTargets = function () { if ( this.geometry.morphTargets !== undefined && this.geometry.morphTargets.length > 0 ) { - this.morphTargetBase = -1; + this.morphTargetBase = - 1; this.morphTargetForcedOrder = []; this.morphTargetInfluences = []; this.morphTargetDictionary = {}; @@ -118,7 +118,7 @@ THREE.Mesh.prototype.raycast = ( function () { } - for ( var oi = 0, ol = offsets.length; oi < ol; ++oi ) { + for ( var oi = 0, ol = offsets.length; oi < ol; ++ oi ) { var start = offsets[ oi ].start; var count = offsets[ oi ].count; diff --git a/src/objects/MorphAnimMesh.js b/src/objects/MorphAnimMesh.js index 1ee7abf932eab..fc06d49a648c6 100644 --- a/src/objects/MorphAnimMesh.js +++ b/src/objects/MorphAnimMesh.js @@ -44,7 +44,7 @@ THREE.MorphAnimMesh.prototype.setDirectionForward = function () { THREE.MorphAnimMesh.prototype.setDirectionBackward = function () { - this.direction = -1; + this.direction = - 1; this.directionBackwards = true; }; @@ -69,7 +69,7 @@ THREE.MorphAnimMesh.prototype.parseAnimations = function () { var label = parts[ 1 ]; var num = parts[ 2 ]; - if ( ! animations[ label ] ) animations[ label ] = { start: Infinity, end: -Infinity }; + if ( ! animations[ label ] ) animations[ label ] = { start: Infinity, end: - Infinity }; var animation = animations[ label ]; @@ -122,7 +122,7 @@ THREE.MorphAnimMesh.prototype.updateAnimation = function ( delta ) { if ( this.time > this.duration || this.time < 0 ) { - this.direction *= -1; + this.direction *= - 1; if ( this.time > this.duration ) { diff --git a/src/objects/PointCloud.js b/src/objects/PointCloud.js index a673a6020ec51..7759b26ecffce 100644 --- a/src/objects/PointCloud.js +++ b/src/objects/PointCloud.js @@ -90,7 +90,7 @@ THREE.PointCloud.prototype.raycast = ( function () { } - for ( var oi = 0, ol = offsets.length; oi < ol; ++oi ) { + for ( var oi = 0, ol = offsets.length; oi < ol; ++ oi ) { var start = offsets[ oi ].start; var count = offsets[ oi ].count; diff --git a/src/objects/Skeleton.js b/src/objects/Skeleton.js index 2036e0588a62e..9738b84848013 100644 --- a/src/objects/Skeleton.js +++ b/src/objects/Skeleton.js @@ -17,7 +17,7 @@ THREE.Skeleton = function ( boneList, useVertexTexture ) { if ( boneList !== undefined ) { - for ( var b = 0; b < boneList.length; ++b ) { + for ( var b = 0; b < boneList.length; ++ b ) { gbone = boneList[ b ]; @@ -43,11 +43,11 @@ THREE.Skeleton = function ( boneList, useVertexTexture ) { } - for ( var b = 0; b < boneList.length; ++b ) { + for ( var b = 0; b < boneList.length; ++ b ) { gbone = boneList[ b ]; - if ( gbone.parent !== -1 ) { + if ( gbone.parent !== - 1 ) { this.bones[ gbone.parent ].add( this.bones[ b ] ); @@ -122,7 +122,7 @@ THREE.Skeleton.prototype.calculateInverses = function ( bone ) { this.boneInverses = []; - for ( var b = 0, bl = this.bones.length; b < bl; ++b ) { + for ( var b = 0, bl = this.bones.length; b < bl; ++ b ) { var inverse = new THREE.Matrix4(); diff --git a/src/objects/SkinnedMesh.js b/src/objects/SkinnedMesh.js index 77ecfcf6eee21..aca3a1aefe8b9 100644 --- a/src/objects/SkinnedMesh.js +++ b/src/objects/SkinnedMesh.js @@ -11,7 +11,7 @@ THREE.SkinnedMesh = function ( geometry, material, useVertexTexture ) { // Add root level bones as children of the mesh - for ( var b = 0; b < this.skeleton.bones.length; ++b ) { + for ( var b = 0; b < this.skeleton.bones.length; ++ b ) { var bone = this.skeleton.bones[ b ]; diff --git a/src/renderers/CanvasRenderer.js b/src/renderers/CanvasRenderer.js index 115f2164bc2af..c00786e540b8a 100644 --- a/src/renderers/CanvasRenderer.js +++ b/src/renderers/CanvasRenderer.js @@ -302,9 +302,9 @@ THREE.CanvasRenderer = function ( parameters ) { _v1 = element.v1; _v2 = element.v2; _v3 = element.v3; - if ( _v1.positionScreen.z < -1 || _v1.positionScreen.z > 1 ) continue; - if ( _v2.positionScreen.z < -1 || _v2.positionScreen.z > 1 ) continue; - if ( _v3.positionScreen.z < -1 || _v3.positionScreen.z > 1 ) continue; + if ( _v1.positionScreen.z < - 1 || _v1.positionScreen.z > 1 ) continue; + if ( _v2.positionScreen.z < - 1 || _v2.positionScreen.z > 1 ) continue; + if ( _v3.positionScreen.z < - 1 || _v3.positionScreen.z > 1 ) continue; _v1.positionScreen.x *= _canvasWidthHalf; _v1.positionScreen.y *= _canvasHeightHalf; _v2.positionScreen.x *= _canvasWidthHalf; _v2.positionScreen.y *= _canvasHeightHalf; diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 58e159d6b0849..023e1f9b227f3 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -112,7 +112,7 @@ THREE.WebGLRenderer = function ( parameters ) { _currentProgram = null, _currentFramebuffer = null, - _currentMaterialId = -1, + _currentMaterialId = - 1, _currentGeometryGroupHash = null, _currentCamera = null, @@ -120,17 +120,17 @@ THREE.WebGLRenderer = function ( parameters ) { // GL state cache - _oldDoubleSided = -1, - _oldFlipSided = -1, + _oldDoubleSided = - 1, + _oldFlipSided = - 1, - _oldBlending = -1, + _oldBlending = - 1, - _oldBlendEquation = -1, - _oldBlendSrc = -1, - _oldBlendDst = -1, + _oldBlendEquation = - 1, + _oldBlendSrc = - 1, + _oldBlendDst = - 1, - _oldDepthTest = -1, - _oldDepthWrite = -1, + _oldDepthTest = - 1, + _oldDepthWrite = - 1, _oldPolygonOffset = null, _oldPolygonOffsetFactor = null, @@ -433,14 +433,14 @@ THREE.WebGLRenderer = function ( parameters ) { this.updateShadowMap = function ( scene, camera ) { _currentProgram = null; - _oldBlending = -1; - _oldDepthTest = -1; - _oldDepthWrite = -1; - _currentGeometryGroupHash = -1; - _currentMaterialId = -1; + _oldBlending = - 1; + _oldDepthTest = - 1; + _oldDepthWrite = - 1; + _currentGeometryGroupHash = - 1; + _currentMaterialId = - 1; _lightsNeedUpdate = true; - _oldDoubleSided = -1; - _oldFlipSided = -1; + _oldDoubleSided = - 1; + _oldFlipSided = - 1; this.shadowMapPlugin.update( scene, camera ); @@ -3061,7 +3061,7 @@ THREE.WebGLRenderer = function ( parameters ) { var attributes = material.program.attributes; - if ( object.morphTargetBase !== -1 && attributes.position >= 0 ) { + if ( object.morphTargetBase !== - 1 && attributes.position >= 0 ) { _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglMorphTargetsBuffers[ object.morphTargetBase ] ); enableAttribute( attributes.position ); @@ -3244,7 +3244,7 @@ THREE.WebGLRenderer = function ( parameters ) { // reset caching for this frame - _currentMaterialId = -1; + _currentMaterialId = - 1; _lightsNeedUpdate = true; // update scene graph @@ -3416,13 +3416,13 @@ THREE.WebGLRenderer = function ( parameters ) { _currentProgram = null; _currentCamera = null; - _oldBlending = -1; - _oldDepthTest = -1; - _oldDepthWrite = -1; - _oldDoubleSided = -1; - _oldFlipSided = -1; - _currentGeometryGroupHash = -1; - _currentMaterialId = -1; + _oldBlending = - 1; + _oldDepthTest = - 1; + _oldDepthWrite = - 1; + _oldDoubleSided = - 1; + _oldFlipSided = - 1; + _currentGeometryGroupHash = - 1; + _currentMaterialId = - 1; _lightsNeedUpdate = true; @@ -3433,13 +3433,13 @@ THREE.WebGLRenderer = function ( parameters ) { _currentProgram = null; _currentCamera = null; - _oldBlending = -1; - _oldDepthTest = -1; - _oldDepthWrite = -1; - _oldDoubleSided = -1; - _oldFlipSided = -1; - _currentGeometryGroupHash = -1; - _currentMaterialId = -1; + _oldBlending = - 1; + _oldDepthTest = - 1; + _oldDepthWrite = - 1; + _oldDoubleSided = - 1; + _oldFlipSided = - 1; + _currentGeometryGroupHash = - 1; + _currentMaterialId = - 1; _lightsNeedUpdate = true; @@ -3454,8 +3454,8 @@ THREE.WebGLRenderer = function ( parameters ) { if ( reverse ) { start = renderList.length - 1; - end = -1; - delta = -1; + end = - 1; + delta = - 1; } else { @@ -3550,7 +3550,7 @@ THREE.WebGLRenderer = function ( parameters ) { var program = setProgram( camera, lights, fog, material, object ); - _currentGeometryGroupHash = -1; + _currentGeometryGroupHash = - 1; _this.setMaterialFaces( material ); @@ -4547,7 +4547,7 @@ THREE.WebGLRenderer = function ( parameters ) { } uniforms.envMap.value = material.envMap; - uniforms.flipEnvMap.value = ( material.envMap instanceof THREE.WebGLRenderTargetCube ) ? 1 : -1; + uniforms.flipEnvMap.value = ( material.envMap instanceof THREE.WebGLRenderTargetCube ) ? 1 : - 1; if ( _this.gammaInput ) { diff --git a/src/renderers/shaders/ShaderLib.js b/src/renderers/shaders/ShaderLib.js index 34bc5223a4e41..ae3b3b8d0f93f 100644 --- a/src/renderers/shaders/ShaderLib.js +++ b/src/renderers/shaders/ShaderLib.js @@ -1200,7 +1200,7 @@ THREE.ShaderLib = { 'cube': { uniforms: { "tCube": { type: "t", value: null }, - "tFlip": { type: "f", value: -1 } }, + "tFlip": { type: "f", value: - 1 } }, vertexShader: [ diff --git a/src/renderers/shaders/UniformsLib.js b/src/renderers/shaders/UniformsLib.js index c68a297dac0fc..2e9812eb4211d 100644 --- a/src/renderers/shaders/UniformsLib.js +++ b/src/renderers/shaders/UniformsLib.js @@ -16,7 +16,7 @@ THREE.UniformsLib = { "specularMap" : { type: "t", value: null }, "envMap" : { type: "t", value: null }, - "flipEnvMap" : { type: "f", value: -1 }, + "flipEnvMap" : { type: "f", value: - 1 }, "useRefract" : { type: "i", value: 0 }, "reflectivity" : { type: "f", value: 1.0 }, "refractionRatio" : { type: "f", value: 0.98 }, diff --git a/src/scenes/Scene.js b/src/scenes/Scene.js index 90da33fc7764c..e053ae18f0afe 100644 --- a/src/scenes/Scene.js +++ b/src/scenes/Scene.js @@ -45,7 +45,7 @@ THREE.Scene.prototype.__addObject = function ( object ) { var i = this.__objectsRemoved.indexOf( object ); - if ( i !== -1 ) { + if ( i !== - 1 ) { this.__objectsRemoved.splice( i, 1 ); @@ -70,7 +70,7 @@ THREE.Scene.prototype.__removeObject = function ( object ) { var i = this.__lights.indexOf( object ); - if ( i !== -1 ) { + if ( i !== - 1 ) { this.__lights.splice( i, 1 ); @@ -94,7 +94,7 @@ THREE.Scene.prototype.__removeObject = function ( object ) { var i = this.__objectsAdded.indexOf( object ); - if ( i !== -1 ) { + if ( i !== - 1 ) { this.__objectsAdded.splice( i, 1 ); From 69e6d9ac89b1a82f95231b5f229f6a6ba4f01de3 Mon Sep 17 00:00:00 2001 From: Joshua Koo Date: Tue, 20 May 2014 00:14:59 +0800 Subject: [PATCH 4/4] Fix code style spaces before postfix unary operators JSCS rules: { "requireSpaceBeforePostfixUnaryOperators": ["++", "--"] } --- src/core/BufferGeometry.js | 22 ++++---- src/core/Geometry.js | 2 +- src/extras/FontUtils.js | 40 +++++++-------- src/extras/ImageUtils.js | 50 +++++++++---------- src/extras/animation/Animation.js | 2 +- src/extras/animation/AnimationHandler.js | 4 +- src/extras/animation/KeyFrameAnimation.js | 12 ++--- src/extras/core/Path.js | 14 +++--- src/extras/core/Shape.js | 8 +-- src/extras/geometries/BoxGeometry.js | 4 +- src/extras/geometries/ExtrudeGeometry.js | 6 +-- src/extras/geometries/ShapeGeometry.js | 10 ++-- src/extras/geometries/TubeGeometry.js | 14 +++--- .../renderers/plugins/LensFlarePlugin.js | 20 ++++---- src/loaders/JSONLoader.js | 18 +++---- src/math/Box3.js | 2 +- src/math/Spline.js | 6 +-- src/objects/PointCloud.js | 2 +- 18 files changed, 118 insertions(+), 118 deletions(-) diff --git a/src/core/BufferGeometry.js b/src/core/BufferGeometry.js index 996a20a21f262..5438883075bb6 100644 --- a/src/core/BufferGeometry.js +++ b/src/core/BufferGeometry.js @@ -603,27 +603,27 @@ THREE.BufferGeometry.prototype = { var faceVertices = new Int32Array( 6 ); var vertexMap = new Int32Array( vertices.length ); var revVertexMap = new Int32Array( vertices.length ); - for ( var j = 0; j < vertices.length; j++ ) { vertexMap[ j ] = - 1; revVertexMap[ j ] = - 1; } + for ( var j = 0; j < vertices.length; j ++ ) { vertexMap[ j ] = - 1; revVertexMap[ j ] = - 1; } /* Traverse every face and reorder vertices in the proper offsets of 65k. We can have more than 65k entries in the index buffer per offset, but only reference 65k values. */ - for ( var findex = 0; findex < facesCount; findex++ ) { + for ( var findex = 0; findex < facesCount; findex ++ ) { newVerticeMaps = 0; - for ( var vo = 0; vo < 3; vo++ ) { + for ( var vo = 0; vo < 3; vo ++ ) { var vid = indices[ findex * 3 + vo ]; if ( vertexMap[ vid ] == - 1 ) { //Unmapped vertice faceVertices[ vo * 2 ] = vid; faceVertices[ vo * 2 + 1 ] = - 1; - newVerticeMaps++; + newVerticeMaps ++; } else if ( vertexMap[ vid ] < offset.index ) { //Reused vertices from previous block (duplicate) faceVertices[ vo * 2 ] = vid; faceVertices[ vo * 2 + 1 ] = - 1; - duplicatedVertices++; + duplicatedVertices ++; } else { //Reused vertice in the current block faceVertices[ vo * 2 ] = vid; @@ -651,12 +651,12 @@ THREE.BufferGeometry.prototype = { var new_vid = faceVertices[ v + 1 ]; if ( new_vid === - 1 ) - new_vid = vertexPtr++; + new_vid = vertexPtr ++; vertexMap[ vid ] = new_vid; revVertexMap[ new_vid ] = vid; - sortedIndices[ indexPtr++ ] = new_vid - offset.index; //XXX overflows at 16bit - offset.count++; + sortedIndices[ indexPtr ++ ] = new_vid - offset.index; //XXX overflows at 16bit + offset.count ++; } } @@ -719,7 +719,7 @@ THREE.BufferGeometry.prototype = { if ( attr == 'index' ) continue; var sourceArray = this.attributes[ attr ].array; - for ( var i = 0, il = types.length; i < il; i++ ) { + for ( var i = 0, il = types.length; i < il; i ++ ) { var type = types[ i ]; if ( sourceArray instanceof type ) { sortedAttributes[ attr ] = new type( this.attributes[ attr ].itemSize * vertexCount ); @@ -729,7 +729,7 @@ THREE.BufferGeometry.prototype = { } /* Move attribute positions based on the new index map */ - for ( var new_vid = 0; new_vid < vertexCount; new_vid++ ) { + for ( var new_vid = 0; new_vid < vertexCount; new_vid ++ ) { var vid = indexMap[ new_vid ]; for ( var attr in this.attributes ) { if ( attr == 'index' ) @@ -737,7 +737,7 @@ THREE.BufferGeometry.prototype = { var attrArray = this.attributes[ attr ].array; var attrSize = this.attributes[ attr ].itemSize; var sortedAttr = sortedAttributes[ attr ]; - for ( var k = 0; k < attrSize; k++ ) + for ( var k = 0; k < attrSize; k ++ ) sortedAttr[ new_vid * attrSize + k ] = attrArray[ vid * attrSize + k ]; } } diff --git a/src/core/Geometry.js b/src/core/Geometry.js index f3723369d95e0..c1ee8697d54fe 100644 --- a/src/core/Geometry.js +++ b/src/core/Geometry.js @@ -381,7 +381,7 @@ THREE.Geometry.prototype = { face = this.faces[ f ]; - for ( i = 0; i < Math.min( face.vertexNormals.length, 3 ); i++ ) { + for ( i = 0; i < Math.min( face.vertexNormals.length, 3 ); i ++ ) { n.copy( face.vertexNormals[ i ] ); diff --git a/src/extras/FontUtils.js b/src/extras/FontUtils.js index 7dfe00023fc7f..269d4c9188862 100644 --- a/src/extras/FontUtils.js +++ b/src/extras/FontUtils.js @@ -136,8 +136,8 @@ THREE.FontUtils = { // Move To - x = outline[ i++ ] * scaleX + offset; - y = outline[ i++ ] * scaleY; + x = outline[ i ++ ] * scaleX + offset; + y = outline[ i ++ ] * scaleY; path.moveTo( x, y ); break; @@ -146,8 +146,8 @@ THREE.FontUtils = { // Line To - x = outline[ i++ ] * scaleX + offset; - y = outline[ i++ ] * scaleY; + x = outline[ i ++ ] * scaleX + offset; + y = outline[ i ++ ] * scaleY; path.lineTo( x,y ); break; @@ -155,10 +155,10 @@ THREE.FontUtils = { // QuadraticCurveTo - cpx = outline[ i++ ] * scaleX + offset; - cpy = outline[ i++ ] * scaleY; - cpx1 = outline[ i++ ] * scaleX + offset; - cpy1 = outline[ i++ ] * scaleY; + cpx = outline[ i ++ ] * scaleX + offset; + cpy = outline[ i ++ ] * scaleY; + cpx1 = outline[ i ++ ] * scaleX + offset; + cpy1 = outline[ i ++ ] * scaleY; path.quadraticCurveTo( cpx1, cpy1, cpx, cpy ); @@ -184,12 +184,12 @@ THREE.FontUtils = { // Cubic Bezier Curve - cpx = outline[ i++ ] * scaleX + offset; - cpy = outline[ i++ ] * scaleY; - cpx1 = outline[ i++ ] * scaleX + offset; - cpy1 = outline[ i++ ] * - scaleY; - cpx2 = outline[ i++ ] * scaleX + offset; - cpy2 = outline[ i++ ] * - scaleY; + cpx = outline[ i ++ ] * scaleX + offset; + cpy = outline[ i ++ ] * scaleY; + cpx1 = outline[ i ++ ] * scaleX + offset; + cpy1 = outline[ i ++ ] * - scaleY; + cpx2 = outline[ i ++ ] * scaleX + offset; + cpy2 = outline[ i ++ ] * - scaleY; path.bezierCurveTo( cpx, cpy, cpx1, cpy1, cpx2, cpy2 ); @@ -300,11 +300,11 @@ THREE.FontUtils.generateShapes = function ( text, parameters ) { if ( area( contour ) > 0.0 ) { - for ( v = 0; v < n; v++ ) verts[ v ] = v; + for ( v = 0; v < n; v ++ ) verts[ v ] = v; } else { - for ( v = 0; v < n; v++ ) verts[ v ] = ( n - 1 ) - v; + for ( v = 0; v < n; v ++ ) verts[ v ] = ( n - 1 ) - v; } @@ -318,7 +318,7 @@ THREE.FontUtils.generateShapes = function ( text, parameters ) { /* if we loop, it is probably a non-simple polygon */ - if ( ( count-- ) <= 0 ) { + if ( ( count -- ) <= 0 ) { //** Triangulate: ERROR - probable bad polygon! @@ -365,7 +365,7 @@ THREE.FontUtils.generateShapes = function ( text, parameters ) { } - nv--; + nv --; /* reset error detection counter */ @@ -387,7 +387,7 @@ THREE.FontUtils.generateShapes = function ( text, parameters ) { var n = contour.length; var a = 0.0; - for ( var p = n - 1, q = 0; q < n; p = q++ ) { + for ( var p = n - 1, q = 0; q < n; p = q ++ ) { a += contour[ p ].x * contour[ q ].y - contour[ q ].x * contour[ p ].y; @@ -422,7 +422,7 @@ THREE.FontUtils.generateShapes = function ( text, parameters ) { bX = ax - cx; bY = ay - cy; cX = bx - ax; cY = by - ay; - for ( p = 0; p < n; p++ ) { + for ( p = 0; p < n; p ++ ) { px = contour[ verts[ p ] ].x py = contour[ verts[ p ] ].y diff --git a/src/extras/ImageUtils.js b/src/extras/ImageUtils.js index 4c4d6dedadb8c..0d278b1be365e 100644 --- a/src/extras/ImageUtils.js +++ b/src/extras/ImageUtils.js @@ -259,21 +259,21 @@ THREE.ImageUtils = { var content = new Uint8Array( arrayBuffer ), offset = 0, header = { - id_length: content[ offset++ ], - colormap_type: content[ offset++ ], - image_type: content[ offset++ ], - colormap_index: content[ offset++ ] | content[ offset++ ] << 8, - colormap_length: content[ offset++ ] | content[ offset++ ] << 8, - colormap_size: content[ offset++ ], + id_length: content[ offset ++ ], + colormap_type: content[ offset ++ ], + image_type: content[ offset ++ ], + colormap_index: content[ offset ++ ] | content[ offset ++ ] << 8, + colormap_length: content[ offset ++ ] | content[ offset ++ ] << 8, + colormap_size: content[ offset ++ ], origin: [ - content[ offset++ ] | content[ offset++ ] << 8, - content[ offset++ ] | content[ offset++ ] << 8 + content[ offset ++ ] | content[ offset ++ ] << 8, + content[ offset ++ ] | content[ offset ++ ] << 8 ], - width: content[ offset++ ] | content[ offset++ ] << 8, - height: content[ offset++ ] | content[ offset++ ] << 8, - pixel_size: content[ offset++ ], - flags: content[ offset++ ] + width: content[ offset ++ ] | content[ offset ++ ] << 8, + height: content[ offset ++ ] | content[ offset ++ ] << 8, + pixel_size: content[ offset ++ ], + flags: content[ offset ++ ] }; function tgaCheckHeader( header ) { @@ -386,14 +386,14 @@ THREE.ImageUtils = { 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++ ]; + pixels[ i ] = data[ offset ++ ]; } // Copy pixel array @@ -408,7 +408,7 @@ THREE.ImageUtils = { else { count *= pixel_size; for ( i = 0; i < count; ++ i ) { - pixel_data[ shift + i ] = data[ offset++ ]; + pixel_data[ shift + i ] = data[ offset ++ ]; } shift += count; } @@ -811,16 +811,16 @@ THREE.ImageUtils = { 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; diff --git a/src/extras/animation/Animation.js b/src/extras/animation/Animation.js index ba68f8ac97dd3..e7b9116616344 100644 --- a/src/extras/animation/Animation.js +++ b/src/extras/animation/Animation.js @@ -353,7 +353,7 @@ THREE.Animation.prototype.getNextKeyWith = function ( type, h, key ) { } - for ( ; key < keys.length; key++ ) { + for ( ; key < keys.length; key ++ ) { if ( keys[ key ][ type ] !== undefined ) { diff --git a/src/extras/animation/AnimationHandler.js b/src/extras/animation/AnimationHandler.js index 242eaa4cf1c6f..93fba0bc1e73e 100644 --- a/src/extras/animation/AnimationHandler.js +++ b/src/extras/animation/AnimationHandler.js @@ -140,7 +140,7 @@ THREE.AnimationHandler = { hierarchy.push( root ); - for ( var c = 0; c < root.children.length; c++ ) + for ( var c = 0; c < root.children.length; c ++ ) parseRecurseHierarchy( root.children[ c ], hierarchy ); }; @@ -151,7 +151,7 @@ THREE.AnimationHandler = { if ( root instanceof THREE.SkinnedMesh ) { - for ( var b = 0; b < root.skeleton.bones.length; b++ ) { + for ( var b = 0; b < root.skeleton.bones.length; b ++ ) { hierarchy.push( root.skeleton.bones[ b ] ); diff --git a/src/extras/animation/KeyFrameAnimation.js b/src/extras/animation/KeyFrameAnimation.js index 753e498ad5765..1fb87b4124a14 100644 --- a/src/extras/animation/KeyFrameAnimation.js +++ b/src/extras/animation/KeyFrameAnimation.js @@ -27,7 +27,7 @@ THREE.KeyFrameAnimation = function ( data ) { if ( keys.length && sids ) { - for ( var s = 0; s < sids.length; s++ ) { + for ( var s = 0; s < sids.length; s ++ ) { var sid = sids[ s ], next = this.getNextKeyWith( sid, h, 0 ); @@ -65,7 +65,7 @@ THREE.KeyFrameAnimation.prototype.play = function ( startTime ) { object, node; - for ( h = 0; h < hl; h++ ) { + for ( h = 0; h < hl; h ++ ) { object = this.hierarchy[ h ]; node = this.data.hierarchy[ h ]; @@ -113,7 +113,7 @@ THREE.KeyFrameAnimation.prototype.stop = function() { // reset JIT matrix and remove cache - for ( var h = 0; h < this.data.hierarchy.length; h++ ) { + for ( var h = 0; h < this.data.hierarchy.length; h ++ ) { var obj = this.hierarchy[ h ]; var node = this.data.hierarchy[ h ]; @@ -163,7 +163,7 @@ THREE.KeyFrameAnimation.prototype.update = function ( delta ) { this.currentTime = Math.min( this.currentTime, duration ); - for ( var h = 0, hl = this.hierarchy.length; h < hl; h++ ) { + for ( var h = 0, hl = this.hierarchy.length; h < hl; h ++ ) { var object = this.hierarchy[ h ]; var node = this.data.hierarchy[ h ]; @@ -217,7 +217,7 @@ THREE.KeyFrameAnimation.prototype.getNextKeyWith = function( sid, h, key ) { var keys = this.data.hierarchy[ h ].keys; key = key % keys.length; - for ( ; key < keys.length; key++ ) { + for ( ; key < keys.length; key ++ ) { if ( keys[ key ].hasTarget( sid ) ) { @@ -238,7 +238,7 @@ THREE.KeyFrameAnimation.prototype.getPrevKeyWith = function( sid, h, key ) { var keys = this.data.hierarchy[ h ].keys; key = key >= 0 ? key : key + keys.length; - for ( ; key >= 0; key-- ) { + for ( ; key >= 0; key -- ) { if ( keys[ key ].hasTarget( sid ) ) { diff --git a/src/extras/core/Path.js b/src/extras/core/Path.js index 505aa52cb66b0..33923925a9e3f 100644 --- a/src/extras/core/Path.js +++ b/src/extras/core/Path.js @@ -519,7 +519,7 @@ THREE.Path.prototype.toShapes = function( isCCW, noHoles ) { // with the horizontal line through inPt, left of inPt // not counting lowerY endpoints of edges and whole edges on that line var inside = false; - for( var p = polyLen - 1, q = 0; q < polyLen; p = q++ ) { + for( var p = polyLen - 1, q = 0; q < polyLen; p = q ++ ) { var edgeLowPt = inPolygon[ p ]; var edgeHighPt = inPolygon[ q ]; @@ -599,13 +599,13 @@ THREE.Path.prototype.toShapes = function( isCCW, noHoles ) { if ( solid ) { - if ( (! holesFirst ) && ( newShapes[mainIdx] ) ) mainIdx++; + if ( (! holesFirst ) && ( newShapes[mainIdx] ) ) mainIdx ++; newShapes[mainIdx] = { s: new THREE.Shape(), p: tmpPoints }; newShapes[mainIdx].s.actions = tmpPath.actions; newShapes[mainIdx].s.curves = tmpPath.curves; - if ( holesFirst ) mainIdx++; + if ( holesFirst ) mainIdx ++; newShapeHoles[mainIdx] = []; //console.log('cw', i); @@ -628,16 +628,16 @@ THREE.Path.prototype.toShapes = function( isCCW, noHoles ) { var ambigious = false; var toChange = []; - for (var sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx++ ) { + for (var sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx ++ ) { betterShapeHoles[sIdx] = []; } - for (var sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx++ ) { + for (var sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx ++ ) { var sh = newShapes[sIdx]; var sho = newShapeHoles[sIdx]; - for (var hIdx = 0; hIdx < sho.length; hIdx++ ) { + for (var hIdx = 0; hIdx < sho.length; hIdx ++ ) { var ho = sho[hIdx]; var hole_unassigned = true; - for (var s2Idx = 0; s2Idx < newShapes.length; s2Idx++ ) { + for (var s2Idx = 0; s2Idx < newShapes.length; s2Idx ++ ) { if ( isPointInsidePolygon( ho.p, newShapes[s2Idx].p ) ) { if ( sIdx != s2Idx ) toChange.push( { froms: sIdx, tos: s2Idx, hole: hIdx } ); if ( hole_unassigned ) { diff --git a/src/extras/core/Shape.js b/src/extras/core/Shape.js index c1f3a7171cf71..745e7c524a3ac 100644 --- a/src/extras/core/Shape.js +++ b/src/extras/core/Shape.js @@ -339,7 +339,7 @@ THREE.Shape.Utils = { function intersectsShapeEdge( inShapePt, inHolePt ) { // checks for intersections with shape edges var sIdx, nextIdx, intersection; - for ( sIdx = 0; sIdx < shape.length; sIdx++ ) { + for ( sIdx = 0; sIdx < shape.length; sIdx ++ ) { nextIdx = sIdx+1; nextIdx %= shape.length; intersection = intersect_segments_2D( inShapePt, inHolePt, shape[sIdx], shape[nextIdx], true ); if ( intersection.length > 0 ) return true; @@ -354,9 +354,9 @@ THREE.Shape.Utils = { // checks for intersections with hole edges var ihIdx, chkHole, hIdx, nextIdx, intersection; - for ( ihIdx = 0; ihIdx < indepHoles.length; ihIdx++ ) { + for ( ihIdx = 0; ihIdx < indepHoles.length; ihIdx ++ ) { chkHole = holes[indepHoles[ihIdx]]; - for ( hIdx = 0; hIdx < chkHole.length; hIdx++ ) { + for ( hIdx = 0; hIdx < chkHole.length; hIdx ++ ) { nextIdx = hIdx+1; nextIdx %= chkHole.length; intersection = intersect_segments_2D( inShapePt, inHolePt, chkHole[hIdx], chkHole[nextIdx], true ); if ( intersection.length > 0 ) return true; @@ -388,7 +388,7 @@ THREE.Shape.Utils = { // search for shape-vertex and hole-vertex, // which can be connected without intersections - for ( shapeIndex = minShapeIndex; shapeIndex < shape.length; shapeIndex++ ) { + for ( shapeIndex = minShapeIndex; shapeIndex < shape.length; shapeIndex ++ ) { shapePt = shape[ shapeIndex ]; holeIndex = - 1; diff --git a/src/extras/geometries/BoxGeometry.js b/src/extras/geometries/BoxGeometry.js index f186858dcb996..d11883cea76d1 100644 --- a/src/extras/geometries/BoxGeometry.js +++ b/src/extras/geometries/BoxGeometry.js @@ -81,9 +81,9 @@ THREE.BoxGeometry = function ( width, height, depth, widthSegments, heightSegmen } - for ( iy = 0; iy < gridY; iy++ ) { + for ( iy = 0; iy < gridY; iy ++ ) { - for ( ix = 0; ix < gridX; ix++ ) { + for ( ix = 0; ix < gridX; ix ++ ) { var a = ix + gridX1 * iy; var b = ix + gridX1 * ( iy + 1 ); diff --git a/src/extras/geometries/ExtrudeGeometry.js b/src/extras/geometries/ExtrudeGeometry.js index d82abea1066c3..5e8d5d7e73de1 100644 --- a/src/extras/geometries/ExtrudeGeometry.js +++ b/src/extras/geometries/ExtrudeGeometry.js @@ -353,12 +353,12 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) { // expand holes - for ( h = 0, hl = holes.length; h < hl; h++ ) { + for ( h = 0, hl = holes.length; h < hl; h ++ ) { ahole = holes[ h ]; oneHoleMovements = holesMovements[ h ]; - for ( i = 0, il = ahole.length; i < il; i++ ) { + for ( i = 0, il = ahole.length; i < il; i ++ ) { vert = scalePt2( ahole[ i ], oneHoleMovements[ i ], bs ); @@ -521,7 +521,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) { // Bottom faces - for ( i = 0; i < flen; i++ ) { + for ( i = 0; i < flen; i ++ ) { face = faces[ i ]; f3( face[ 2 ], face[ 1 ], face[ 0 ], true ); diff --git a/src/extras/geometries/ShapeGeometry.js b/src/extras/geometries/ShapeGeometry.js index 2800c794f4198..a706b4ac102bc 100644 --- a/src/extras/geometries/ShapeGeometry.js +++ b/src/extras/geometries/ShapeGeometry.js @@ -35,7 +35,7 @@ THREE.ShapeGeometry.prototype = Object.create( THREE.Geometry.prototype ); */ THREE.ShapeGeometry.prototype.addShapeList = function ( shapes, options ) { - for ( var i = 0, l = shapes.length; i < l; i++ ) { + for ( var i = 0, l = shapes.length; i < l; i ++ ) { this.addShape( shapes[ i ], options ); @@ -76,7 +76,7 @@ THREE.ShapeGeometry.prototype.addShape = function ( shape, options ) { // Maybe we should also check if holes are in the opposite direction, just to be safe... - for ( i = 0, l = holes.length; i < l; i++ ) { + for ( i = 0, l = holes.length; i < l; i ++ ) { hole = holes[ i ]; @@ -98,7 +98,7 @@ THREE.ShapeGeometry.prototype.addShape = function ( shape, options ) { var contour = vertices; - for ( i = 0, l = holes.length; i < l; i++ ) { + for ( i = 0, l = holes.length; i < l; i ++ ) { hole = holes[ i ]; vertices = vertices.concat( hole ); @@ -111,7 +111,7 @@ THREE.ShapeGeometry.prototype.addShape = function ( shape, options ) { var face, flen = faces.length; var cont, clen = contour.length; - for ( i = 0; i < vlen; i++ ) { + for ( i = 0; i < vlen; i ++ ) { vert = vertices[ i ]; @@ -119,7 +119,7 @@ THREE.ShapeGeometry.prototype.addShape = function ( shape, options ) { } - for ( i = 0; i < flen; i++ ) { + for ( i = 0; i < flen; i ++ ) { face = faces[ i ]; diff --git a/src/extras/geometries/TubeGeometry.js b/src/extras/geometries/TubeGeometry.js index 7c023e8254355..06c337c8870dc 100644 --- a/src/extras/geometries/TubeGeometry.js +++ b/src/extras/geometries/TubeGeometry.js @@ -67,7 +67,7 @@ THREE.TubeGeometry = function ( path, segments, radius, radialSegments, closed ) // consruct the grid - for ( i = 0; i < numpoints; i++ ) { + for ( i = 0; i < numpoints; i ++ ) { grid[ i ] = []; @@ -79,7 +79,7 @@ THREE.TubeGeometry = function ( path, segments, radius, radialSegments, closed ) normal = normals[ i ]; binormal = binormals[ i ]; - for ( j = 0; j < radialSegments; j++ ) { + for ( j = 0; j < radialSegments; j ++ ) { v = j / radialSegments * 2 * Math.PI; @@ -99,9 +99,9 @@ THREE.TubeGeometry = function ( path, segments, radius, radialSegments, closed ) // construct the mesh - for ( i = 0; i < segments; i++ ) { + for ( i = 0; i < segments; i ++ ) { - for ( j = 0; j < radialSegments; j++ ) { + for ( j = 0; j < radialSegments; j ++ ) { ip = ( closed ) ? (i + 1) % segments : i + 1; jp = (j + 1) % radialSegments; @@ -163,7 +163,7 @@ THREE.TubeGeometry.FrenetFrames = function ( path, segments, closed ) { // compute the tangent vectors for each segment on the path - for ( i = 0; i < numpoints; i++ ) { + for ( i = 0; i < numpoints; i ++ ) { u = i / ( numpoints - 1 ); @@ -230,7 +230,7 @@ THREE.TubeGeometry.FrenetFrames = function ( path, segments, closed ) { // compute the slowly-varying normal and binormal vectors for each segment on the path - for ( i = 1; i < numpoints; i++ ) { + for ( i = 1; i < numpoints; i ++ ) { normals[ i ] = normals[ i-1 ].clone(); @@ -266,7 +266,7 @@ THREE.TubeGeometry.FrenetFrames = function ( path, segments, closed ) { } - for ( i = 1; i < numpoints; i++ ) { + for ( i = 1; i < numpoints; i ++ ) { // twist a little... normals[ i ].applyMatrix4( mat.makeRotationAxis( tangents[ i ], theta * i ) ); diff --git a/src/extras/renderers/plugins/LensFlarePlugin.js b/src/extras/renderers/plugins/LensFlarePlugin.js index 8c80710ac42ce..4b2eb5d32df4f 100644 --- a/src/extras/renderers/plugins/LensFlarePlugin.js +++ b/src/extras/renderers/plugins/LensFlarePlugin.js @@ -18,21 +18,21 @@ THREE.LensFlarePlugin = function () { _lensFlare.faces = new Uint16Array( 6 ); var i = 0; - _lensFlare.vertices[ i++ ] = - 1; _lensFlare.vertices[ i++ ] = - 1; // vertex - _lensFlare.vertices[ i++ ] = 0; _lensFlare.vertices[ i++ ] = 0; // uv... etc. + _lensFlare.vertices[ i ++ ] = - 1; _lensFlare.vertices[ i ++ ] = - 1; // vertex + _lensFlare.vertices[ i ++ ] = 0; _lensFlare.vertices[ i ++ ] = 0; // uv... etc. - _lensFlare.vertices[ i++ ] = 1; _lensFlare.vertices[ i++ ] = - 1; - _lensFlare.vertices[ i++ ] = 1; _lensFlare.vertices[ i++ ] = 0; + _lensFlare.vertices[ i ++ ] = 1; _lensFlare.vertices[ i ++ ] = - 1; + _lensFlare.vertices[ i ++ ] = 1; _lensFlare.vertices[ i ++ ] = 0; - _lensFlare.vertices[ i++ ] = 1; _lensFlare.vertices[ i++ ] = 1; - _lensFlare.vertices[ i++ ] = 1; _lensFlare.vertices[ i++ ] = 1; + _lensFlare.vertices[ i ++ ] = 1; _lensFlare.vertices[ i ++ ] = 1; + _lensFlare.vertices[ i ++ ] = 1; _lensFlare.vertices[ i ++ ] = 1; - _lensFlare.vertices[ i++ ] = - 1; _lensFlare.vertices[ i++ ] = 1; - _lensFlare.vertices[ i++ ] = 0; _lensFlare.vertices[ i++ ] = 1; + _lensFlare.vertices[ i ++ ] = - 1; _lensFlare.vertices[ i ++ ] = 1; + _lensFlare.vertices[ i ++ ] = 0; _lensFlare.vertices[ i ++ ] = 1; i = 0; - _lensFlare.faces[ i++ ] = 0; _lensFlare.faces[ i++ ] = 1; _lensFlare.faces[ i++ ] = 2; - _lensFlare.faces[ i++ ] = 0; _lensFlare.faces[ i++ ] = 2; _lensFlare.faces[ i++ ] = 3; + _lensFlare.faces[ i ++ ] = 0; _lensFlare.faces[ i ++ ] = 1; _lensFlare.faces[ i ++ ] = 2; + _lensFlare.faces[ i ++ ] = 0; _lensFlare.faces[ i ++ ] = 2; _lensFlare.faces[ i ++ ] = 3; // buffers diff --git a/src/loaders/JSONLoader.js b/src/loaders/JSONLoader.js index 7d338d559d598..418f8431b9535 100644 --- a/src/loaders/JSONLoader.js +++ b/src/loaders/JSONLoader.js @@ -152,13 +152,13 @@ THREE.JSONLoader.prototype.parse = function ( json, texturePath ) { // disregard empty arrays - for ( i = 0; i < json.uvs.length; i++ ) { + for ( i = 0; i < json.uvs.length; i ++ ) { if ( json.uvs[ i ].length ) nUvLayers ++; } - for ( i = 0; i < nUvLayers; i++ ) { + for ( i = 0; i < nUvLayers; i ++ ) { geometry.faceVertexUvs[ i ] = []; @@ -227,7 +227,7 @@ THREE.JSONLoader.prototype.parse = function ( json, texturePath ) { if ( hasFaceVertexUv ) { - for ( i = 0; i < nUvLayers; i++ ) { + for ( i = 0; i < nUvLayers; i ++ ) { uvLayer = json.uvs[ i ]; @@ -268,7 +268,7 @@ THREE.JSONLoader.prototype.parse = function ( json, texturePath ) { if ( hasFaceVertexNormal ) { - for ( i = 0; i < 4; i++ ) { + for ( i = 0; i < 4; i ++ ) { normalIndex = faces[ offset ++ ] * 3; @@ -300,7 +300,7 @@ THREE.JSONLoader.prototype.parse = function ( json, texturePath ) { if ( hasFaceVertexColor ) { - for ( i = 0; i < 4; i++ ) { + for ( i = 0; i < 4; i ++ ) { colorIndex = faces[ offset ++ ]; hex = colors[ colorIndex ]; @@ -335,7 +335,7 @@ THREE.JSONLoader.prototype.parse = function ( json, texturePath ) { if ( hasFaceVertexUv ) { - for ( i = 0; i < nUvLayers; i++ ) { + for ( i = 0; i < nUvLayers; i ++ ) { uvLayer = json.uvs[ i ]; @@ -372,7 +372,7 @@ THREE.JSONLoader.prototype.parse = function ( json, texturePath ) { if ( hasFaceVertexNormal ) { - for ( i = 0; i < 3; i++ ) { + for ( i = 0; i < 3; i ++ ) { normalIndex = faces[ offset ++ ] * 3; @@ -399,7 +399,7 @@ THREE.JSONLoader.prototype.parse = function ( json, texturePath ) { if ( hasFaceVertexColor ) { - for ( i = 0; i < 3; i++ ) { + for ( i = 0; i < 3; i ++ ) { colorIndex = faces[ offset ++ ]; face.vertexColors.push( new THREE.Color( colors[ colorIndex ] ) ); @@ -500,7 +500,7 @@ THREE.JSONLoader.prototype.parse = function ( json, texturePath ) { var i, l, c, cl, dstColors, srcColors, color; - for ( i = 0, l = json.morphColors.length; i < l; i++ ) { + for ( i = 0, l = json.morphColors.length; i < l; i ++ ) { geometry.morphColors[ i ] = {}; geometry.morphColors[ i ].name = json.morphColors[ i ].name; diff --git a/src/math/Box3.js b/src/math/Box3.js index a0504c5bbef05..f00db58a620c6 100644 --- a/src/math/Box3.js +++ b/src/math/Box3.js @@ -122,7 +122,7 @@ THREE.Box3.prototype = { var vertices = node.geometry.vertices; - for ( var i = 0, il = vertices.length; i < il; i++ ) { + for ( var i = 0, il = vertices.length; i < il; i ++ ) { v1.copy( vertices[ i ] ); diff --git a/src/math/Spline.js b/src/math/Spline.js index d54039a226e7a..b5c3cb1957b66 100644 --- a/src/math/Spline.js +++ b/src/math/Spline.js @@ -18,7 +18,7 @@ THREE.Spline = function ( points ) { this.points = []; - for ( var i = 0; i < a.length; i++ ) { + for ( var i = 0; i < a.length; i ++ ) { this.points[ i ] = { x: a[ i ][ 0 ], y: a[ i ][ 1 ], z: a[ i ][ 2 ] }; @@ -133,7 +133,7 @@ THREE.Spline = function ( points ) { newpoints.push( tmpVec.copy( this.points[ 0 ] ).clone() ); - for ( i = 1; i < this.points.length; i++ ) { + for ( i = 1; i < this.points.length; i ++ ) { //tmpVec.copy( this.points[ i - 1 ] ); //linearDistance = tmpVec.distanceTo( this.points[ i ] ); @@ -145,7 +145,7 @@ THREE.Spline = function ( points ) { indexCurrent = ( i - 1 ) / ( this.points.length - 1 ); indexNext = i / ( this.points.length - 1 ); - for ( j = 1; j < sampling - 1; j++ ) { + for ( j = 1; j < sampling - 1; j ++ ) { index = indexCurrent + j * ( 1 / sampling ) * ( indexNext - indexCurrent ); diff --git a/src/objects/PointCloud.js b/src/objects/PointCloud.js index 7759b26ecffce..793f9d668673a 100644 --- a/src/objects/PointCloud.js +++ b/src/objects/PointCloud.js @@ -96,7 +96,7 @@ THREE.PointCloud.prototype.raycast = ( function () { var count = offsets[ oi ].count; var index = offsets[ oi ].index; - for ( var i = start, il = start + count; i < il; i++ ) { + for ( var i = start, il = start + count; i < il; i ++ ) { var a = index + indices[ i ];