diff --git a/examples/canvas_geometry_birds.html b/examples/canvas_geometry_birds.html index 3893b8a3ea02f7..bd3b8fe3aa02bb 100644 --- a/examples/canvas_geometry_birds.html +++ b/examples/canvas_geometry_birds.html @@ -1,8 +1,8 @@ - + three.js canvas - geometry - birds - - - + + - - + - +
- + - + diff --git a/examples/webgl_collisions_normal.html b/examples/webgl_collisions_normal.html index a6ea935d4d8b6a..4a017f6d7705b0 100644 --- a/examples/webgl_collisions_normal.html +++ b/examples/webgl_collisions_normal.html @@ -1,10 +1,10 @@ - - - -three.js webgl - intersection: ray/mesh readinf normal - - - - + + - - + - +
- + - + diff --git a/examples/webgl_collisions_reaction.html b/examples/webgl_collisions_reaction.html index 319b91bd37ccf5..a7c9735bc86c86 100644 --- a/examples/webgl_collisions_reaction.html +++ b/examples/webgl_collisions_reaction.html @@ -106,7 +106,7 @@ } function createCube(sx, sy, sz, p, ry){ - + var cube = new THREE.Mesh( new THREE.CubeGeometry( sx, sy, sz ), new THREE.MeshLambertMaterial( { color: 0x003300 } ) ); cube.position = p; cube.rotation.y = ry; diff --git a/examples/webgl_geometry_blenderexport_colors.html b/examples/webgl_geometry_blenderexport_colors.html index f115edfcd4c30d..75ced11a75e611 100644 --- a/examples/webgl_geometry_blenderexport_colors.html +++ b/examples/webgl_geometry_blenderexport_colors.html @@ -145,7 +145,7 @@ mesh.rotation.x += 0.01; mesh.rotation.y += 0.01; } - + if ( mesh2 ) { mesh2.rotation.x += 0.01; mesh2.rotation.y += 0.01; diff --git a/examples/webgl_geometry_minecraft_ao.html b/examples/webgl_geometry_minecraft_ao.html index c9676700579604..8b43fe6918c101 100644 --- a/examples/webgl_geometry_minecraft_ao.html +++ b/examples/webgl_geometry_minecraft_ao.html @@ -521,7 +521,7 @@ canvas.width = canvas.height = size; var texture = new THREE.Texture( canvas, new THREE.UVMapping(), THREE.ClampToEdgeWrapping, THREE.ClampToEdgeWrapping, THREE.NearestFilter, THREE.LinearMipMapLinearFilter ); - + function generateTexture() { if( count == 3 ) { @@ -578,7 +578,7 @@ var texture = new THREE.Texture( canvas, new THREE.UVMapping(), THREE.ClampToEdgeWrapping, THREE.ClampToEdgeWrapping, THREE.NearestFilter, THREE.LinearMipMapLinearFilter ); texture.needsUpdate = true; - + return new THREE.MeshLambertMaterial( { map: texture } ); } diff --git a/examples/webgl_geometry_text.html b/examples/webgl_geometry_text.html index e8def5ae701083..470406b420e1a4 100644 --- a/examples/webgl_geometry_text.html +++ b/examples/webgl_geometry_text.html @@ -26,14 +26,14 @@
- three.js - procedural 3D text by zz85 & alteredq + three.js - procedural 3D text by zz85 & alteredq (fonts from typeface.js and Droid)
type to enter new text, drag to spin the text -
change color, - change font, +
change color, + change font, change weight, change bezel, - change postprocessing, + change postprocessing,
@@ -43,12 +43,12 @@ - + @@ -60,7 +60,7 @@ - + - + @@ -211,10 +211,10 @@ function onKeyDown ( event ) { switch( event.keyCode ) { - + /* O */ case 79: webglRenderer.separation -= 0.5; break; - + /* P */ case 80: webglRenderer.separation += 0.5; break; @@ -224,7 +224,7 @@ }; - // + // function animate() { diff --git a/examples/webgl_materials_cubemap_balls_reflection.html b/examples/webgl_materials_cubemap_balls_reflection.html index 593ee4fcfa3024..a7a517d545a85c 100644 --- a/examples/webgl_materials_cubemap_balls_reflection.html +++ b/examples/webgl_materials_cubemap_balls_reflection.html @@ -20,7 +20,7 @@ font-family:Monospace; font-size:13px; text-align:center; - z-index:1000; + z-index:1000; } a { diff --git a/examples/webgl_materials_cubemap_balls_reflection_anaglyph.html b/examples/webgl_materials_cubemap_balls_reflection_anaglyph.html index 70654537fcedfd..86b900c6a4df29 100644 --- a/examples/webgl_materials_cubemap_balls_reflection_anaglyph.html +++ b/examples/webgl_materials_cubemap_balls_reflection_anaglyph.html @@ -20,7 +20,7 @@ font-family:Monospace; font-size:13px; text-align:center; - z-index:1000; + z-index:1000; } a { diff --git a/examples/webgl_materials_cubemap_balls_refraction.html b/examples/webgl_materials_cubemap_balls_refraction.html index 21da2bbc4c075d..e7729e3ad3790d 100644 --- a/examples/webgl_materials_cubemap_balls_refraction.html +++ b/examples/webgl_materials_cubemap_balls_refraction.html @@ -20,7 +20,7 @@ font-family:Monospace; font-size:13px; text-align:center; - z-index:1000; + z-index:1000; } a { diff --git a/examples/webgl_materials_cubemap_balls_refraction_crosseyed.html b/examples/webgl_materials_cubemap_balls_refraction_crosseyed.html index b462212c4c230f..eaf31c8a6f6c1b 100644 --- a/examples/webgl_materials_cubemap_balls_refraction_crosseyed.html +++ b/examples/webgl_materials_cubemap_balls_refraction_crosseyed.html @@ -20,7 +20,7 @@ font-family:Monospace; font-size:13px; text-align:center; - z-index:1000; + z-index:1000; } a { @@ -122,7 +122,7 @@ webglRenderer = new THREE.CrosseyedWebGLRenderer( { separation: 90 } ); webglRenderer.setSize( window.innerWidth, window.innerHeight ); container.appendChild( webglRenderer.domElement ); - + document.addEventListener( 'keydown', onKeyDown, false ); } @@ -137,10 +137,10 @@ function onKeyDown ( event ) { switch( event.keyCode ) { - + /* O */ case 79: webglRenderer.separation -= 0.5; break; - + /* P */ case 80: webglRenderer.separation += 0.5; break; diff --git a/examples/webgl_materials_cubemap_escher.html b/examples/webgl_materials_cubemap_escher.html index 49d57561cabced..4c3a9eb9627087 100644 --- a/examples/webgl_materials_cubemap_escher.html +++ b/examples/webgl_materials_cubemap_escher.html @@ -16,7 +16,7 @@ a { color: #ff0080; text-decoration: none; } a:hover { color: #0080ff; } #log { position:absolute; top:50px; text-align:left; display:block; z-index:100; pointer-events:none; } - #d { text-align:center; margin:1em auto -9.0em; z-index:1000; position:relative; display:block; + #d { text-align:center; margin:1em auto -9.0em; z-index:1000; position:relative; display:block; background:rgba(0,0,0,0.75); padding:0.25em; width:300px; border-radius:10px; -webkit-box-shadow: 0px 0px 10px rgba(0,0,0,0.5) } #oldie { margin-top:15em !important } @@ -75,8 +75,8 @@ var r = "textures/cube/Escher/"; - var urls = [ r + "px.jpg", r + "nx.jpg", - r + "py.jpg", r + "ny.jpg", + var urls = [ r + "px.jpg", r + "nx.jpg", + r + "py.jpg", r + "ny.jpg", r + "pz.jpg", r + "nz.jpg" ]; var textureCube = THREE.ImageUtils.loadTextureCube( urls ); diff --git a/examples/webgl_materials_cubemap_refraction.html b/examples/webgl_materials_cubemap_refraction.html index 1401454b6ede9b..92c305fd1271fa 100644 --- a/examples/webgl_materials_cubemap_refraction.html +++ b/examples/webgl_materials_cubemap_refraction.html @@ -18,7 +18,7 @@ canvas { pointer-events:none; z-index:10; } #log { position:absolute; top:50px; text-align:left; display:block; z-index:100; pointer-events:none; } - #d { text-align:center; margin:1em auto -9.5em; z-index:200; position:relative; display:block; + #d { text-align:center; margin:1em auto -9.5em; z-index:200; position:relative; display:block; background:rgba(0,0,0,0.5); padding:0.5em; width:400px; border-radius:15px; -webkit-box-shadow: 0px 0px 10px rgba(0,0,0,0.5) } #oldie { margin-top:15em !important } @@ -99,8 +99,8 @@ var r = "textures/cube/Park3Med/"; - var urls = [ r + "px.jpg", r + "nx.jpg", - r + "py.jpg", r + "ny.jpg", + var urls = [ r + "px.jpg", r + "nx.jpg", + r + "py.jpg", r + "ny.jpg", r + "pz.jpg", r + "nz.jpg" ]; var textureCube = THREE.ImageUtils.loadTextureCube( urls, new THREE.CubeRefractionMapping() ); diff --git a/examples/webgl_materials_normalmap.html b/examples/webgl_materials_normalmap.html index d0132edda2c845..564b52d2e592be 100644 --- a/examples/webgl_materials_normalmap.html +++ b/examples/webgl_materials_normalmap.html @@ -140,7 +140,7 @@ uniforms[ "tDisplacement" ].texture = THREE.ImageUtils.loadTexture( "textures/normal/ninja/displacement.jpg" ); uniforms[ "uDisplacementBias" ].value = - 0.428408 * scale; uniforms[ "uDisplacementScale" ].value = 2.436143 * scale; - + uniforms[ "uDiffuseColor" ].value.setHex( diffuse ); uniforms[ "uSpecularColor" ].value.setHex( specular ); uniforms[ "uAmbientColor" ].value.setHex( ambient ); diff --git a/examples/webgl_materials_normalmap2.html b/examples/webgl_materials_normalmap2.html index 67f54f6df2b724..d24be7d9137a05 100644 --- a/examples/webgl_materials_normalmap2.html +++ b/examples/webgl_materials_normalmap2.html @@ -115,7 +115,7 @@ var shader = THREE.ShaderUtils.lib[ "normal" ]; var uniforms = THREE.UniformsUtils.clone( shader.uniforms ); - + uniforms[ "tNormal" ].texture = THREE.ImageUtils.loadTexture( "obj/leeperrysmith/Infinite-Level_02_Tangent_SmoothUV.jpg" ); uniforms[ "uNormalScale" ].value = - 0.75; diff --git a/examples/webgl_materials_shaders.html b/examples/webgl_materials_shaders.html index aac018be4cab92..44094bedb0edab 100644 --- a/examples/webgl_materials_shaders.html +++ b/examples/webgl_materials_shaders.html @@ -193,7 +193,7 @@

Blinn-Phong / Lambert materials

var loader = new THREE.JSONLoader(); loader.load( { model: "obj/torus/Torus_slim.js", callback: function( geometry ) { createScene( geometry ) } } ); - + //var loader = new THREE.BinaryLoader(); //loader.load( { model: "obj/torus/Torus_bin.js", callback: function( geometry ) { createScene( geometry ) } } ); diff --git a/examples/webgl_materials_shaders_fresnel.html b/examples/webgl_materials_shaders_fresnel.html index d02ecd3d549472..2711f3236b2fa5 100644 --- a/examples/webgl_materials_shaders_fresnel.html +++ b/examples/webgl_materials_shaders_fresnel.html @@ -20,7 +20,7 @@ font-family:Monospace; font-size:13px; text-align:center; - z-index:1000; + z-index:1000; } a { diff --git a/examples/webgl_objconvert_test.html b/examples/webgl_objconvert_test.html index f77979a31074b9..1777175f69735a 100644 --- a/examples/webgl_objconvert_test.html +++ b/examples/webgl_objconvert_test.html @@ -107,7 +107,7 @@

OBJ to Three.js converter test

xm.map.repeat.set( 10, 10 ); geometry = new THREE.PlaneGeometry( 100, 100, 15, 10 ); - + mesh = new THREE.Mesh( geometry, xm ); mesh.position.x = 0; mesh.position.y = FLOOR; diff --git a/examples/webgl_panorama_equirectangular.html b/examples/webgl_panorama_equirectangular.html index 6b8e7e2fa67987..267e413592e901 100644 --- a/examples/webgl_panorama_equirectangular.html +++ b/examples/webgl_panorama_equirectangular.html @@ -28,7 +28,7 @@ -
+
three.js webgl - equirectangular panorama demo. photo by Jón Ragnarsson.
diff --git a/examples/webgl_particles_dynamic.html b/examples/webgl_particles_dynamic.html index db3c512ddbebc0..675f609604f224 100644 --- a/examples/webgl_particles_dynamic.html +++ b/examples/webgl_particles_dynamic.html @@ -21,7 +21,7 @@ position: absolute; top: 0px; width: 100%; padding: 5px; - + } a { color: red; } @@ -40,13 +40,13 @@ - + diff --git a/src/core/Face3.js b/src/core/Face3.js index d215afed6a4283..d61a502cc38661 100644 --- a/src/core/Face3.js +++ b/src/core/Face3.js @@ -5,7 +5,7 @@ THREE.Face3 = function ( a, b, c, normal, color, materials ) { - this.a = a; + this.a = a; this.b = b; this.c = c; diff --git a/src/core/Face4.js b/src/core/Face4.js index b5e4bc2b89e5f5..d5e7ac72d09b24 100644 --- a/src/core/Face4.js +++ b/src/core/Face4.js @@ -5,7 +5,7 @@ THREE.Face4 = function ( a, b, c, d, normal, color, materials ) { - this.a = a; + this.a = a; this.b = b; this.c = c; this.d = d; diff --git a/src/core/Geometry.js b/src/core/Geometry.js index 544f1419e68e38..8ee1346ce5a566 100644 --- a/src/core/Geometry.js +++ b/src/core/Geometry.js @@ -463,7 +463,7 @@ THREE.Geometry.prototype = { // should shared edge be included? // comment out if not - hash = edge_hash( face.b, face.d ); + hash = edge_hash( face.b, face.d ); addToMap( vfMap, hash, i ); hash = edge_hash( face.a, face.b ); diff --git a/src/core/Object3D.js b/src/core/Object3D.js index f26508238d6ed8..4d3510d0cf0e60 100644 --- a/src/core/Object3D.js +++ b/src/core/Object3D.js @@ -17,7 +17,7 @@ THREE.Object3D = function() { this.scale = new THREE.Vector3( 1, 1, 1 ); this.dynamic = false; // when true it retains arrays so they can be updated with __dirty* - + this.doubleSided = false; this.flipSided = false; diff --git a/src/core/Quaternion.js b/src/core/Quaternion.js index 98627eed67cd0c..48888920aaba28 100644 --- a/src/core/Quaternion.js +++ b/src/core/Quaternion.js @@ -82,7 +82,7 @@ THREE.Quaternion.prototype = { return this; }, - + calculateW : function () { this.w = - Math.sqrt( Math.abs( 1.0 - this.x * this.x - this.y * this.y - this.z * this.z ) ); @@ -155,7 +155,7 @@ THREE.Quaternion.prototype = { this.y = -q1.x * q2.z + q1.y * q2.w + q1.z * q2.x + q1.w * q2.y; this.z = q1.x * q2.y - q1.y * q2.x + q1.z * q2.w + q1.w * q2.z; this.w = -q1.x * q2.x - q1.y * q2.y - q1.z * q2.z + q1.w * q2.w; - + return this; }, @@ -200,7 +200,7 @@ THREE.Quaternion.slerp = function ( qa, qb, qm, t ) { var halfTheta = Math.acos( cosHalfTheta ), sinHalfTheta = Math.sqrt( 1.0 - cosHalfTheta * cosHalfTheta ); - if ( Math.abs( sinHalfTheta ) < 0.001 ) { + if ( Math.abs( sinHalfTheta ) < 0.001 ) { qm.w = 0.5 * ( qa.w + qb.w ); qm.x = 0.5 * ( qa.x + qb.x ); @@ -212,7 +212,7 @@ THREE.Quaternion.slerp = function ( qa, qb, qm, t ) { } var ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta, - ratioB = Math.sin( t * halfTheta ) / sinHalfTheta; + ratioB = Math.sin( t * halfTheta ) / sinHalfTheta; qm.w = ( qa.w * ratioA + qb.w * ratioB ); qm.x = ( qa.x * ratioA + qb.x * ratioB ); diff --git a/src/core/Ray.js b/src/core/Ray.js index 45b33505a14e56..515beb737f634d 100644 --- a/src/core/Ray.js +++ b/src/core/Ray.js @@ -159,8 +159,8 @@ THREE.Ray.prototype = { intersect = origin.clone().addSelf( direction.clone().multiplyScalar( dot ) ); distance = position.distanceTo( intersect ); - // TODO: Check if distance is negative (object behind camera). - + // TODO: Check if distance is negative (object behind camera). + return distance; } diff --git a/src/core/Vector2.js b/src/core/Vector2.js index 07e4ad9a837f40..30a99b1494ecc7 100644 --- a/src/core/Vector2.js +++ b/src/core/Vector2.js @@ -135,7 +135,7 @@ THREE.Vector2.prototype = { return this.divideScalar( this.length() ); }, - + distanceTo : function ( v ) { return Math.sqrt( this.distanceToSquared( v ) ); @@ -163,11 +163,11 @@ THREE.Vector2.prototype = { return this.normalize(); }, - + // danger, works only on numbers which are exactly the same // (which may be not what is expected thanks to floating point precision) // (should be probably using some tiny epsilon instead of equality) - + equals : function( v ) { return ( ( v.x == this.x ) && ( v.y == this.y ) ); diff --git a/src/extras/ColorUtils.js b/src/extras/ColorUtils.js index 1114f48d7e16c4..26bf1c3529009c 100644 --- a/src/extras/ColorUtils.js +++ b/src/extras/ColorUtils.js @@ -3,21 +3,21 @@ */ THREE.ColorUtils = { - + adjustHSV : function ( color, h, s, v ) { var hsv = THREE.ColorUtils.__hsv; - + THREE.ColorUtils.rgbToHsv( color, hsv ); hsv.h = THREE.ColorUtils.clamp( hsv.h + h, 0, 1 ); hsv.s = THREE.ColorUtils.clamp( hsv.s + s, 0, 1 ); hsv.v = THREE.ColorUtils.clamp( hsv.v + v, 0, 1 ); - + color.setHSV( hsv.h, hsv.s, hsv.v ); }, - + // based on MochiKit implementation by Bob Ippolito rgbToHsv : function ( color, hsv ) { @@ -25,7 +25,7 @@ THREE.ColorUtils = { var r = color.r; var g = color.g; var b = color.b; - + var max = Math.max( Math.max( r, g ), b ); var min = Math.min( Math.min( r, g ), b ); @@ -63,7 +63,7 @@ THREE.ColorUtils = { hue += 1; } - + if ( hue > 1 ) { hue -= 1; @@ -71,24 +71,24 @@ THREE.ColorUtils = { } } - + if ( hsv === undefined ) { - + hsv = { h: 0, s: 0, v: 0 }; } - + hsv.h = hue; hsv.s = saturation; hsv.v = value; - + return hsv; }, - - clamp: function ( x, a, b ) { - - return x < a ? a : ( x > b ? b : x ); + + clamp: function ( x, a, b ) { + + return x < a ? a : ( x > b ? b : x ); } diff --git a/src/extras/ImageUtils.js b/src/extras/ImageUtils.js index 516cc4f3e8b3b7..5a0ff19bef09fc 100644 --- a/src/extras/ImageUtils.js +++ b/src/extras/ImageUtils.js @@ -18,7 +18,7 @@ THREE.ImageUtils = { loadTextureCube: function ( array, mapping, callback ) { - var i, l, + var i, l, images = [], texture = new THREE.Texture( images, mapping ); @@ -29,8 +29,8 @@ THREE.ImageUtils = { images[ i ] = new Image(); images[ i ].onload = function () { - images.loadCount += 1; - if ( images.loadCount == 6 ) texture.needsUpdate = true; + images.loadCount += 1; + if ( images.loadCount == 6 ) texture.needsUpdate = true; if ( callback ) callback( this ); }; diff --git a/src/extras/animation/Animation.js b/src/extras/animation/Animation.js index 16f456bbb5be81..0fa4714f22aa52 100644 --- a/src/extras/animation/Animation.js +++ b/src/extras/animation/Animation.js @@ -37,17 +37,17 @@ THREE.Animation.prototype.play = function( loop, startTimeMS ) { var h, hl = this.hierarchy.length, object; - + for ( h = 0; h < hl; h++ ) { object = this.hierarchy[ h ]; - + if ( this.interpolationType !== THREE.AnimationHandler.CATMULLROM_FORWARD ) { object.useQuaternion = true; } - + object.matrixAutoUpdate = true; if ( object.animationCache === undefined ) { @@ -89,15 +89,15 @@ THREE.Animation.prototype.play = function( loop, startTimeMS ) { THREE.Animation.prototype.pause = function() { if( this.isPaused ) { - + THREE.AnimationHandler.addToUpdate( this ); - + } else { - + THREE.AnimationHandler.removeFromUpdate( this ); - + } - + this.isPaused = !this.isPaused; }; @@ -110,31 +110,31 @@ THREE.Animation.prototype.stop = function() { this.isPlaying = false; this.isPaused = false; THREE.AnimationHandler.removeFromUpdate( this ); - - + + // reset JIT matrix and remove cache - + for ( var h = 0; h < this.hierarchy.length; h++ ) { - + if ( this.hierarchy[ h ].animationCache !== undefined ) { - + if( this.hierarchy[ h ] instanceof THREE.Bone ) { - + this.hierarchy[ h ].skinMatrix = this.hierarchy[ h ].animationCache.originalMatrix; - + } else { - + this.hierarchy[ h ].matrix = this.hierarchy[ h ].animationCache.originalMatrix; } - - + + delete this.hierarchy[ h ].animationCache; } } - + }; @@ -161,10 +161,10 @@ THREE.Animation.prototype.update = function( deltaTimeMS ) { var JIThierarchy = this.data.JIT.hierarchy; var currentTime, unloopedCurrentTime; var currentPoint, forwardPoint, angle; - + // update - + this.currentTime += deltaTimeMS * this.timeScale; unloopedCurrentTime = this.currentTime; @@ -178,43 +178,43 @@ THREE.Animation.prototype.update = function( deltaTimeMS ) { object = this.hierarchy[ h ]; animationCache = object.animationCache; - + // use JIT? - + if ( this.JITCompile && JIThierarchy[ h ][ frame ] !== undefined ) { if( object instanceof THREE.Bone ) { - + object.skinMatrix = JIThierarchy[ h ][ frame ]; - + object.matrixAutoUpdate = false; object.matrixWorldNeedsUpdate = false; } else { - + object.matrix = JIThierarchy[ h ][ frame ]; - + object.matrixAutoUpdate = false; object.matrixWorldNeedsUpdate = true; } - + // use interpolation - + } else { // make sure so original matrix and not JIT matrix is set if ( this.JITCompile ) { - + if( object instanceof THREE.Bone ) { - + object.skinMatrix = object.animationCache.originalMatrix; - + } else { - + object.matrix = object.animationCache.originalMatrix; - + } } @@ -244,10 +244,10 @@ THREE.Animation.prototype.update = function( deltaTimeMS ) { nextKey = this.getNextKeyWith( type, h, 1 ); while( nextKey.time < currentTime ) { - + prevKey = nextKey; nextKey = this.getNextKeyWith( type, h, nextKey.index + 1 ); - + } } else { @@ -286,7 +286,7 @@ THREE.Animation.prototype.update = function( deltaTimeMS ) { if ( scale < 0 || scale > 1 ) { - console.log( "THREE.Animation.update: Warning! Scale out of bounds:" + scale + " on bone " + h ); + console.log( "THREE.Animation.update: Warning! Scale out of bounds:" + scale + " on bone " + h ); scale = scale < 0 ? 0 : 1; } @@ -295,17 +295,17 @@ THREE.Animation.prototype.update = function( deltaTimeMS ) { if ( type === "pos" ) { - vector = object.position; + vector = object.position; if( this.interpolationType === THREE.AnimationHandler.LINEAR ) { - + vector.x = prevXYZ[ 0 ] + ( nextXYZ[ 0 ] - prevXYZ[ 0 ] ) * scale; vector.y = prevXYZ[ 1 ] + ( nextXYZ[ 1 ] - prevXYZ[ 1 ] ) * scale; vector.z = prevXYZ[ 2 ] + ( nextXYZ[ 2 ] - prevXYZ[ 2 ] ) * scale; } else if ( this.interpolationType === THREE.AnimationHandler.CATMULLROM || - this.interpolationType === THREE.AnimationHandler.CATMULLROM_FORWARD ) { - + this.interpolationType === THREE.AnimationHandler.CATMULLROM_FORWARD ) { + this.points[ 0 ] = this.getPrevKeyWith( "pos", h, prevKey.index - 1 )[ "pos" ]; this.points[ 1 ] = prevXYZ; this.points[ 2 ] = nextXYZ; @@ -314,23 +314,23 @@ THREE.Animation.prototype.update = function( deltaTimeMS ) { scale = scale * 0.33 + 0.33; currentPoint = this.interpolateCatmullRom( this.points, scale ); - + vector.x = currentPoint[ 0 ]; vector.y = currentPoint[ 1 ]; vector.z = currentPoint[ 2 ]; - + if( this.interpolationType === THREE.AnimationHandler.CATMULLROM_FORWARD ) { - - forwardPoint = this.interpolateCatmullRom( this.points, scale * 1.01 ); - + + forwardPoint = this.interpolateCatmullRom( this.points, scale * 1.01 ); + this.target.set( forwardPoint[ 0 ], forwardPoint[ 1 ], forwardPoint[ 2 ] ); this.target.subSelf( vector ); this.target.y = 0; this.target.normalize(); - + angle = Math.atan2( this.target.x, this.target.z ); object.rotation.set( 0, angle, 0 ); - + } } @@ -342,7 +342,7 @@ THREE.Animation.prototype.update = function( deltaTimeMS ) { } else if( type === "scl" ) { vector = object.scale; - + vector.x = prevXYZ[ 0 ] + ( nextXYZ[ 0 ] - prevXYZ[ 0 ] ) * scale; vector.y = prevXYZ[ 1 ] + ( nextXYZ[ 1 ] - prevXYZ[ 1 ] ) * scale; vector.z = prevXYZ[ 2 ] + ( nextXYZ[ 2 ] - prevXYZ[ 2 ] ) * scale; @@ -358,25 +358,25 @@ THREE.Animation.prototype.update = function( deltaTimeMS ) { // update JIT? if ( this.JITCompile ) { - + if ( JIThierarchy[ 0 ][ frame ] === undefined ) { - + this.hierarchy[ 0 ].update( undefined, true ); - + for ( var h = 0; h < this.hierarchy.length; h++ ) { - + if( this.hierarchy[ h ] instanceof THREE.Bone ) { - + JIThierarchy[ h ][ frame ] = this.hierarchy[ h ].skinMatrix.clone(); - + } else { - + JIThierarchy[ h ][ frame ] = this.hierarchy[ h ].matrix.clone(); - + } - + } - + } } @@ -384,13 +384,13 @@ THREE.Animation.prototype.update = function( deltaTimeMS ) { }; // Catmull-Rom spline - + THREE.Animation.prototype.interpolateCatmullRom = function ( points, scale ) { var c = [], v3 = [], point, intPoint, weight, w2, w3, pa, pb, pc, pd; - + point = ( points.length - 1 ) * scale; intPoint = Math.floor( point ); weight = point - intPoint; @@ -407,11 +407,11 @@ THREE.Animation.prototype.interpolateCatmullRom = function ( points, scale ) { w2 = weight * weight; w3 = weight * w2; - + v3[ 0 ] = this.interpolate( pa[ 0 ], pb[ 0 ], pc[ 0 ], pd[ 0 ], weight, w2, w3 ); v3[ 1 ] = this.interpolate( pa[ 1 ], pb[ 1 ], pc[ 1 ], pd[ 1 ], weight, w2, w3 ); v3[ 2 ] = this.interpolate( pa[ 2 ], pb[ 2 ], pc[ 2 ], pd[ 2 ], weight, w2, w3 ); - + return v3; }; @@ -430,16 +430,16 @@ THREE.Animation.prototype.interpolate = function( p0, p1, p2, p3, t, t2, t3 ) { // Get next key with THREE.Animation.prototype.getNextKeyWith = function( type, h, key ) { - + var keys = this.data.hierarchy[ h ].keys; - + if ( this.interpolationType === THREE.AnimationHandler.CATMULLROM || this.interpolationType === THREE.AnimationHandler.CATMULLROM_FORWARD ) { - + key = key < keys.length - 1 ? key : keys.length - 1; } else { - + key = key % keys.length; } @@ -461,16 +461,16 @@ THREE.Animation.prototype.getNextKeyWith = function( type, h, key ) { // Get previous key with THREE.Animation.prototype.getPrevKeyWith = function( type, h, key ) { - + var keys = this.data.hierarchy[ h ].keys; - + if ( this.interpolationType === THREE.AnimationHandler.CATMULLROM || this.interpolationType === THREE.AnimationHandler.CATMULLROM_FORWARD ) { - + key = key > 0 ? key : 0; } else { - + key = key >= 0 ? key : key + keys.length; } diff --git a/src/extras/animation/AnimationHandler.js b/src/extras/animation/AnimationHandler.js index edeac3f8c9870d..2d18e6cd22869a 100644 --- a/src/extras/animation/AnimationHandler.js +++ b/src/extras/animation/AnimationHandler.js @@ -42,7 +42,7 @@ THREE.AnimationHandler = (function() { //--- add --- - + that.add = function( data ) { if( library[ data.name ] !== undefined ) @@ -55,61 +55,61 @@ THREE.AnimationHandler = (function() { //--- get --- - + that.get = function( name ) { - + if( typeof name === "string" ) { - + if( library[ name ] ) { - + return library[ name ]; - + } else { - + console.log( "THREE.AnimationHandler.get: Couldn't find animation " + name ); return null; } } else { - + // todo: add simple tween library } - + }; //--- parse --- - + that.parse = function( root ) { - + // setup hierarchy var hierarchy = []; - + if ( root instanceof THREE.SkinnedMesh ) { - + for( var b = 0; b < root.bones.length; b++ ) { - + hierarchy.push( root.bones[ b ] ); - + } - + } else { - + parseRecurseHierarchy( root, hierarchy ); - + } - + return hierarchy; }; var parseRecurseHierarchy = function( root, hierarchy ) { - + 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 ); } @@ -118,10 +118,10 @@ THREE.AnimationHandler = (function() { //--- init data --- var initData = function( data ) { - + if( data.initialized === true ) return; - + // loop through all keys @@ -148,77 +148,77 @@ THREE.AnimationHandler = (function() { // prepare morph target keys - + if( data.hierarchy[ h ].keys[ 0 ].morphTargets !== undefined ) { // get all used var usedMorphTargets = {}; - + for( var k = 0; k < data.hierarchy[ h ].keys.length; k++ ) { - + 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; - } - + } + } - + data.hierarchy[ h ].usedMorphTargets = usedMorphTargets; - - + + // set all used on all frames - + for( var k = 0; k < data.hierarchy[ h ].keys.length; k++ ) { - + var influences = {}; - + for( var morphTargetName in usedMorphTargets ) { - + for( var m = 0; m < data.hierarchy[ h ].keys[ k ].morphTargets.length; m++ ) { - + if( data.hierarchy[ h ].keys[ k ].morphTargets[ m ] === morphTargetName ) { - + influences[ morphTargetName ] = data.hierarchy[ h ].keys[ k ].morphTargetsInfluences[ m ]; - break; + break; } - + } - + if( m === data.hierarchy[ h ].keys[ k ].morphTargets.length ) { - + influences[ morphTargetName ] = 0; } - + } - + data.hierarchy[ h ].keys[ k ].morphTargetsInfluences = influences; } - + } - - + + // remove all keys that are on the same time - + for( var k = 1; k < data.hierarchy[ h ].keys.length; k++ ) { - + if( data.hierarchy[ h ].keys[ k ].time === data.hierarchy[ h ].keys[ k - 1 ].time ) { - + data.hierarchy[ h ].keys.splice( k, 1 ); k--; - + } - + } // set index - + for( var k = 1; k < data.hierarchy[ h ].keys.length; k++ ) { - + data.hierarchy[ h ].keys[ k ].index = k; - + } } diff --git a/src/extras/animation/AnimationMorphTarget.js b/src/extras/animation/AnimationMorphTarget.js index 6aa082739d2b9e..cedc402aac138e 100644 --- a/src/extras/animation/AnimationMorphTarget.js +++ b/src/extras/animation/AnimationMorphTarget.js @@ -58,15 +58,15 @@ THREE.AnimationMorphTarget.prototype.play = function( loop, startTimeMS ) { THREE.AnimationMorphTarget.prototype.pause = function() { if( this.isPaused ) { - + THREE.AnimationHandler.addToUpdate( this ); - + } else { - + THREE.AnimationHandler.removeFromUpdate( this ); - + } - + this.isPaused = !this.isPaused; } @@ -79,17 +79,17 @@ THREE.AnimationMorphTarget.prototype.stop = function() { this.isPlaying = false; this.isPaused = false; - + THREE.AnimationHandler.removeFromUpdate( this ); - - + + // reset JIT matrix and remove cache - + for ( var h = 0; h < this.hierarchy.length; h++ ) { - + if ( this.hierarchy[ h ].animationCache !== undefined ) { - - delete this.hierarchy[ h ].animationCache; + + delete this.hierarchy[ h ].animationCache; } } @@ -117,10 +117,10 @@ THREE.AnimationMorphTarget.prototype.update = function( deltaTimeMS ) { var object; var animationCache; var currentTime, unloopedCurrentTime; - + // update time - + this.currentTime += deltaTimeMS * this.timeScale; unloopedCurrentTime = this.currentTime; @@ -191,24 +191,24 @@ THREE.AnimationMorphTarget.prototype.update = function( deltaTimeMS ) { if ( scale < 0 || scale > 1 ) { - console.log( "THREE.AnimationMorphTarget.update: Warning! Scale out of bounds:" + scale ); + console.log( "THREE.AnimationMorphTarget.update: Warning! Scale out of bounds:" + scale ); scale = scale < 0 ? 0 : 1; } // interpolate - + var pi, pmti = prevKey.morphTargetsInfluences; var ni, nmti = nextKey.morphTargetsInfluences; var mt, i; - + for( mt in pmti ) { - + pi = pmti[ mt ]; ni = nmti[ mt ]; i = this.root.getMorphTargetIndexByName( mt ); - + this.root.morphTargetInfluences[ i ] = ( pi + ( ni - pi ) * scale ) * this.influence; } diff --git a/src/extras/cameras/FirstPersonCamera.js b/src/extras/cameras/FirstPersonCamera.js index e3c153f9c2a0ef..ddaced377db8d6 100644 --- a/src/extras/cameras/FirstPersonCamera.js +++ b/src/extras/cameras/FirstPersonCamera.js @@ -195,7 +195,7 @@ THREE.FirstPersonCamera = function ( parameters ) { var now = new Date().getTime(); this.tdiff = ( now - this.lastUpdate ) / 1000; this.lastUpdate = now; - + if ( !this.freeze ) { diff --git a/src/extras/cameras/FlyCamera.js b/src/extras/cameras/FlyCamera.js index 0f4da4832574b1..ea674bf63c947c 100644 --- a/src/extras/cameras/FlyCamera.js +++ b/src/extras/cameras/FlyCamera.js @@ -29,13 +29,13 @@ THREE.FlyCamera = function ( parameters ) { THREE.Camera.call( this, parameters.fov, parameters.aspect, parameters.near, parameters.far, parameters.target ); this.tmpQuaternion = new THREE.Quaternion(); - + this.movementSpeed = 1.0; this.rollSpeed = 0.005; this.dragToLook = false; this.autoForward = false; - + this.domElement = document; if ( parameters ) { @@ -169,7 +169,7 @@ THREE.FlyCamera = function ( parameters ) { var container = this.getContainerDimensions(); var halfWidth = container.size[ 0 ] / 2; var halfHeight = container.size[ 1 ] / 2; - + this.moveState.yawLeft = - ( ( event.clientX - container.offset[ 0 ] ) - halfWidth ) / halfWidth; this.moveState.pitchDown = ( ( event.clientY - container.offset[ 1 ] ) - halfHeight ) / halfHeight; this.updateRotationVector(); @@ -204,13 +204,13 @@ THREE.FlyCamera = function ( parameters ) { this.updateRotationVector(); }; - + this.update = function( parentMatrixWorld, forceUpdate, camera ) { var now = new Date().getTime(); - + if ( this.lastUpdate == -1 ) this.lastUpdate = now; - + this.tdiff = ( now - this.lastUpdate ) / 1000; this.lastUpdate = now; @@ -224,7 +224,7 @@ THREE.FlyCamera = function ( parameters ) { this.tmpQuaternion.set( this.rotationVector.x * rotMult, this.rotationVector.y * rotMult, this.rotationVector.z * rotMult, 1 ).normalize(); this.quaternion.multiplySelf( this.tmpQuaternion ); - + this.matrix.setPosition( this.position ); this.matrix.setRotationFromQuaternion( this.quaternion ); this.matrixWorldNeedsUpdate = true; @@ -236,7 +236,7 @@ THREE.FlyCamera = function ( parameters ) { this.updateMovementVector = function() { var forward = ( this.moveState.forward || ( this.autoForward && !this.moveState.back ) ) ? 1 : 0; - + this.moveVector.x = ( -this.moveState.left + this.moveState.right ); this.moveVector.y = ( -this.moveState.down + this.moveState.up ); this.moveVector.z = ( -forward + this.moveState.back ); @@ -258,17 +258,17 @@ THREE.FlyCamera = function ( parameters ) { this.getContainerDimensions = function() { if ( this.domElement != document ) { - + return { size : [ this.domElement.offsetWidth, this.domElement.offsetHeight ], - offset : [ this.domElement.offsetLeft, this.domElement.offsetTop ] + offset : [ this.domElement.offsetLeft, this.domElement.offsetTop ] }; } else { return { size : [ window.innerWidth, window.innerHeight ], - offset : [ 0, 0 ] + offset : [ 0, 0 ] }; } @@ -284,16 +284,16 @@ THREE.FlyCamera = function ( parameters ) { }; }; - + this.domElement.addEventListener( 'mousemove', bind( this, this.mousemove ), false ); this.domElement.addEventListener( 'mousedown', bind( this, this.mousedown ), false ); this.domElement.addEventListener( 'mouseup', bind( this, this.mouseup ), false ); window.addEventListener( 'keydown', bind( this, this.keydown ), false ); window.addEventListener( 'keyup', bind( this, this.keyup ), false ); - + this.updateMovementVector(); - this.updateRotationVector(); + this.updateRotationVector(); }; diff --git a/src/extras/cameras/PathCamera.js b/src/extras/cameras/PathCamera.js index 3f555845773930..7d2d9bd6c74834 100644 --- a/src/extras/cameras/PathCamera.js +++ b/src/extras/cameras/PathCamera.js @@ -111,24 +111,24 @@ THREE.PathCamera = function ( parameters ) { dstRange = this.verticalAngleMap.dstRange; //this.phi = map_linear( this.phi, srcRange[ 0 ], srcRange[ 1 ], dstRange[ 0 ], dstRange[ 1 ] ); - + var tmpPhi = map_linear( this.phi, srcRange[ 0 ], srcRange[ 1 ], dstRange[ 0 ], dstRange[ 1 ] ); var tmpPhiFullRange = dstRange[ 1 ] - dstRange[ 0 ]; var tmpPhiNormalized = ( tmpPhi - dstRange[ 0 ] ) / tmpPhiFullRange; - + this.phi = TWEEN.Easing.Quadratic.EaseInOut( tmpPhiNormalized ) * tmpPhiFullRange + dstRange[ 0 ]; - + // constrain horizontal look angle srcRange = this.horizontalAngleMap.srcRange; dstRange = this.horizontalAngleMap.dstRange; //this.theta = map_linear( this.theta, srcRange[ 0 ], srcRange[ 1 ], dstRange[ 0 ], dstRange[ 1 ] ); - + var tmpTheta = map_linear( this.theta, srcRange[ 0 ], srcRange[ 1 ], dstRange[ 0 ], dstRange[ 1 ] ); var tmpThetaFullRange = dstRange[ 1 ] - dstRange[ 0 ]; var tmpThetaNormalized = ( tmpTheta - dstRange[ 0 ] ) / tmpThetaFullRange; - + this.theta = TWEEN.Easing.Quadratic.EaseInOut( tmpThetaNormalized ) * tmpThetaFullRange + dstRange[ 0 ]; var targetPosition = this.target.position, diff --git a/src/extras/cameras/RollCamera.js b/src/extras/cameras/RollCamera.js index 248c5e4551fecd..be756b06b20cd8 100644 --- a/src/extras/cameras/RollCamera.js +++ b/src/extras/cameras/RollCamera.js @@ -48,7 +48,7 @@ THREE.RollCamera = function ( fov, aspect, near, far ) { this.lastUpdate = -1; this.delta = 0; - + var xTemp = new THREE.Vector3(); var yTemp = new THREE.Vector3(); var zTemp = new THREE.Vector3(); @@ -57,7 +57,7 @@ THREE.RollCamera = function ( fov, aspect, near, far ) { var doRoll = false, rollDirection = 1, forwardSpeed = 0, sideSpeed = 0, upSpeed = 0; var mouseX = 0, mouseY = 0; - + var windowHalfX = window.innerWidth / 2; var windowHalfY = window.innerHeight / 2; @@ -68,14 +68,14 @@ THREE.RollCamera = function ( fov, aspect, near, far ) { var now = new Date().getTime(); if ( this.lastUpdate == -1 ) this.lastUpdate = now; - + this.delta = ( now - this.lastUpdate ) / 1000; this.lastUpdate = now; if ( this.mouseLook ) { - + var actualLookSpeed = this.delta * this.lookSpeed; - + this.rotateHorizontally( actualLookSpeed * mouseX ); this.rotateVertically( actualLookSpeed * mouseY ); @@ -83,118 +83,118 @@ THREE.RollCamera = function ( fov, aspect, near, far ) { var actualSpeed = this.delta * this.movementSpeed; var forwardOrAuto = ( forwardSpeed > 0 || ( this.autoForward && ! ( forwardSpeed < 0 ) ) ) ? 1 : forwardSpeed; - + this.translateZ( actualSpeed * forwardOrAuto ); this.translateX( actualSpeed * sideSpeed ); this.translateY( actualSpeed * upSpeed ); if( doRoll ) { - + this.roll += this.rollSpeed * this.delta * rollDirection; } - + // cap forward up / down - + if( this.forward.y > this.constrainVertical[ 1 ] ) { - + this.forward.y = this.constrainVertical[ 1 ]; this.forward.normalize(); - + } else if( this.forward.y < this.constrainVertical[ 0 ] ) { - + this.forward.y = this.constrainVertical[ 0 ]; this.forward.normalize(); - + } // construct unrolled camera matrix - + zTemp.copy( this.forward ); yTemp.set( 0, 1, 0 ); - + xTemp.cross( yTemp, zTemp ).normalize(); yTemp.cross( zTemp, xTemp ).normalize(); - + this.matrix.n11 = xTemp.x; this.matrix.n12 = yTemp.x; this.matrix.n13 = zTemp.x; this.matrix.n21 = xTemp.y; this.matrix.n22 = yTemp.y; this.matrix.n23 = zTemp.y; this.matrix.n31 = xTemp.z; this.matrix.n32 = yTemp.z; this.matrix.n33 = zTemp.z; - - + + // calculate roll matrix - + rollMatrix.identity(); rollMatrix.n11 = Math.cos( this.roll ); rollMatrix.n12 = -Math.sin( this.roll ); rollMatrix.n21 = Math.sin( this.roll ); rollMatrix.n22 = Math.cos( this.roll ); - - + + // multiply camera with roll - + this.matrix.multiplySelf( rollMatrix ); this.matrixWorldNeedsUpdate = true; - - + + // set position - + this.matrix.n14 = this.position.x; this.matrix.n24 = this.position.y; this.matrix.n34 = this.position.z; - - + + // call supr this.supr.update.call( this ); }; - + this.translateX = function ( distance ) { - + this.position.x += this.matrix.n11 * distance; this.position.y += this.matrix.n21 * distance; this.position.z += this.matrix.n31 * distance; - + }; - + this.translateY = function ( distance ) { - + this.position.x += this.matrix.n12 * distance; this.position.y += this.matrix.n22 * distance; this.position.z += this.matrix.n32 * distance; - + }; this.translateZ = function ( distance ) { - + this.position.x -= this.matrix.n13 * distance; this.position.y -= this.matrix.n23 * distance; this.position.z -= this.matrix.n33 * distance; - + }; - + this.rotateHorizontally = function ( amount ) { - + // please note that the amount is NOT degrees, but a scale value - + xTemp.set( this.matrix.n11, this.matrix.n21, this.matrix.n31 ); xTemp.multiplyScalar( amount ); this.forward.subSelf( xTemp ); this.forward.normalize(); - + }; - + this.rotateVertically = function ( amount ) { - + // please note that the amount is NOT degrees, but a scale value - + yTemp.set( this.matrix.n12, this.matrix.n22, this.matrix.n32 ); yTemp.multiplyScalar( amount ); - + this.forward.addSelf( yTemp ); this.forward.normalize(); - + }; function onKeyDown( event ) { @@ -255,7 +255,7 @@ THREE.RollCamera = function ( fov, aspect, near, far ) { mouseY = ( event.clientY - windowHalfY ) / window.innerHeight; }; - + function onMouseDown ( event ) { event.preventDefault(); @@ -283,14 +283,14 @@ THREE.RollCamera = function ( fov, aspect, near, far ) { } }; - + this.domElement.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false ); this.domElement.addEventListener( 'mousemove', onMouseMove, false ); this.domElement.addEventListener( 'mousedown', onMouseDown, false ); this.domElement.addEventListener( 'mouseup', onMouseUp, false ); this.domElement.addEventListener( 'keydown', onKeyDown, false ); - this.domElement.addEventListener( 'keyup', onKeyUp, false ); + this.domElement.addEventListener( 'keyup', onKeyUp, false ); }; diff --git a/src/extras/cameras/TrackballCamera.js b/src/extras/cameras/TrackballCamera.js index 2c9f34959f6627..1e5aa4ebcc40c7 100644 --- a/src/extras/cameras/TrackballCamera.js +++ b/src/extras/cameras/TrackballCamera.js @@ -366,7 +366,7 @@ THREE.TrackballCamera = function ( parameters ) { _state = this.STATE.NONE; }; - + function bind( scope, fn ) { return function () { diff --git a/src/extras/geometries/TextGeometry.js b/src/extras/geometries/TextGeometry.js index a0b7de3122c2b1..967530bf74f9cf 100644 --- a/src/extras/geometries/TextGeometry.js +++ b/src/extras/geometries/TextGeometry.js @@ -19,22 +19,22 @@ * bezelThickness: , // how deep into text bezel goes * bezelSize: , // how far from text outline is bezel * } - * + * * It uses techniques used in - * + * * typeface.js and canvastext - * For converting fonts and rendering with javascript + * For converting fonts and rendering with javascript * http://typeface.neocracy.org - * + * * Triangulation ported from AS3 * Simple Polygon Triangulation * http://actionsnippet.com/?p=1462 * - * A Method to triangulate shapes with holes + * A Method to triangulate shapes with holes * http://www.sakri.net/blog/2009/06/12/an-approach-to-triangulating-polygons-with-holes/ * */ - + THREE.TextGeometry = function ( text, parameters ) { THREE.Geometry.call( this ); @@ -87,8 +87,8 @@ THREE.TextGeometry.prototype.set = function ( text, parameters ) { scope.vertices = []; scope.faces = []; - var i, - vert, vlen = vertices.length, + var i, + vert, vlen = vertices.length, face, flen = faces.length, bezelPt, blen = bezelPoints.length; @@ -104,7 +104,7 @@ THREE.TextGeometry.prototype.set = function ( text, parameters ) { // Front facing vertices for ( i = 0; i < vlen; i++ ) { - + vert = vertices[ i ]; v( vert.x, vert.y, height ); @@ -285,7 +285,7 @@ THREE.FontUtils = { var ThreeFont = this; ThreeFont.faces[ family ] = ThreeFont.faces[ family ] || {}; - + ThreeFont.faces[ family ][ data.cssFontWeight ] = ThreeFont.faces[ family ][ data.cssFontWeight ] || {}; ThreeFont.faces[ family ][ data.cssFontWeight ][ data.cssFontStyle ] = data; @@ -358,7 +358,7 @@ THREE.FontUtils = { firstPt = all[ firstIndex ]; endPt = all.slice( firstIndex + 1 ).indexOf( firstPt ) + firstIndex; - if ( endPt <= firstIndex ) break; + if ( endPt <= firstIndex ) break; var contours = singleCharPoints.slice( firstIndex, endPt + 1 ); @@ -472,7 +472,7 @@ THREE.FontUtils = { prevShapeVert = ( shapeIndex - 1 ) >= 0 ? shapeIndex - 1 : shape.length - 1; nextShapeVert = ( shapeIndex + 1 ) < shape.length ? shapeIndex + 1 : 0; - prevHoleVert = ( holeIndex - 1 ) >= 0 ? holeIndex - 1 : hole.length - 1; + prevHoleVert = ( holeIndex - 1 ) >= 0 ? holeIndex - 1 : hole.length - 1; nextHoleVert = ( holeIndex + 1 ) < hole.length ? holeIndex + 1 : 0 ; var areaapts = []; @@ -495,7 +495,7 @@ THREE.FontUtils = { var oldShapeIndex = shapeIndex, oldHoleIndex = holeIndex; shapeIndex += shapeOffset; holeIndex += holeOffset; - + if ( shapeIndex < 0 ) { shapeIndex += shape.length; } shapeIndex %= shape.length; @@ -505,7 +505,7 @@ THREE.FontUtils = { prevShapeVert = ( shapeIndex - 1 ) >= 0 ? shapeIndex - 1 : shape.length - 1; nextShapeVert = ( shapeIndex + 1 ) < shape.length ? shapeIndex + 1 : 0; - prevHoleVert = ( holeIndex - 1 ) >= 0 ? holeIndex - 1 : hole.length - 1; + prevHoleVert = ( holeIndex - 1 ) >= 0 ? holeIndex - 1 : hole.length - 1; nextHoleVert = ( holeIndex + 1 ) < hole.length ? holeIndex + 1 : 0 ; @@ -538,7 +538,7 @@ THREE.FontUtils = { prevShapeVert = ( shapeIndex - 1 ) >= 0 ? shapeIndex - 1 : shape.length - 1; nextShapeVert = ( shapeIndex + 1 ) < shape.length ? shapeIndex + 1 : 0; - prevHoleVert = ( holeIndex - 1 ) >= 0 ? holeIndex - 1 : hole.length - 1; + prevHoleVert = ( holeIndex - 1 ) >= 0 ? holeIndex - 1 : hole.length - 1; nextHoleVert = ( holeIndex + 1 ) < hole.length ? holeIndex + 1 : 0 ; } @@ -563,7 +563,7 @@ THREE.FontUtils = { shapeGroup.shape = shape; } - + var triangulatedPoints = []; var triangulatedFaces = []; var lastTriangles = 0; @@ -593,7 +593,7 @@ THREE.FontUtils = { lastTriangles += shape.length; } - + // Now we push the "cut" vertices back to the triangulated indices. @@ -660,8 +660,8 @@ THREE.FontUtils = { var i, p, face = this.getFace(), scale = this.size / face.resolution, - offset = 0, - chars = String( text ).split( '' ), + offset = 0, + chars = String( text ).split( '' ), length = chars.length; for ( i = 0; i < length; i++ ) { @@ -673,7 +673,7 @@ THREE.FontUtils = { } - // get the width + // get the width var width = offset / 2; @@ -856,21 +856,21 @@ THREE.FontUtils = { x, y, cpx, cpy, cpx0, cpy0, cpx1, cpy1, cpx2, cpy2, laste, glyph = face.glyphs[ c ] || face.glyphs[ ctxt.options.fallbackCharacter ]; - + if ( !glyph ) return; - + if ( glyph.o ) { - + outline = glyph._cachedOutline || ( glyph._cachedOutline = glyph.o.split( ' ' ) ); length = outline.length; - + scaleX = scale; scaleY = scale; - + for ( i = 0; i < length; ) { action = outline[ i++ ]; - + switch( action ) { case 'm': @@ -890,23 +890,23 @@ THREE.FontUtils = { y = outline[ i++ ] * scaleY; pts.push( new THREE.Vector2( x, y ) ); break; - + case 'q': // QuadraticCurveTo - + cpx = outline[ i++ ] * scaleX + offset; cpy = outline[ i++ ] * scaleY; cpx1 = outline[ i++ ] * scaleX + offset; cpy1 = outline[ i++ ] * scaleY; - + laste = pts[ pts.length - 1 ]; - + if ( laste ) { cpx0 = laste.x; cpy0 = laste.y; - + for ( i2 = 1, divisions = this.divisions; i2 <= divisions; i2++ ) { var t = i2 / divisions; @@ -916,28 +916,28 @@ THREE.FontUtils = { } - } - + } + break; case 'b': // 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; - + laste = pts[ pts.length - 1 ]; - + if ( laste ) { cpx0 = laste.x; cpy0 = laste.y; - + for ( i2 = 1, divisions = this.divisions; i2 <= divisions; i2++ ) { var t = i2 / divisions; @@ -964,17 +964,17 @@ THREE.FontUtils = { /** - * This code is a quick port of code written in C++ which was submitted to - * flipcode.com by John W. Ratcliff // July 22, 2000 + * This code is a quick port of code written in C++ which was submitted to + * flipcode.com by John W. Ratcliff // July 22, 2000 * See original code and more information here: * http://www.flipcode.com/archives/Efficient_Polygon_Triangulation.shtml - * + * * ported to actionscript by Zevan Rosser * www.actionsnippet.com - * + * * ported to javascript by Joshua Koo * http://www.lab4games.net/zz85/blog - * + * */ @@ -982,7 +982,7 @@ THREE.FontUtils = { var EPSILON = 0.0000000001; - // takes in an contour array and returns + // takes in an contour array and returns var process = function( contour, indices ) { @@ -991,7 +991,7 @@ THREE.FontUtils = { if ( n < 3 ) return null; var result = [], - verts = [], + verts = [], vertIndices = []; /* we want a counter-clockwise polygon in verts */ @@ -1033,19 +1033,19 @@ THREE.FontUtils = { } /* three consecutive vertices in current polygon, */ - + u = v; if ( nv <= u ) u = 0; /* previous */ v = u + 1; if ( nv <= v ) v = 0; /* new v */ w = v + 1; if ( nv <= w ) w = 0; /* next */ - + if ( snip( contour, u, v, w, nv, verts ) ) { var a, b, c, s, t; - + /* true names of the vertices */ - a = verts[ u ]; - b = verts[ v ]; + a = verts[ u ]; + b = verts[ v ]; c = verts[ w ]; /* output Triangle */ @@ -1055,17 +1055,17 @@ THREE.FontUtils = { result.push( contour[ c ] ); vertIndices.push( [ verts[ u ], verts[ v ], verts[ w ] ] ); - + /* remove v from the remaining polygon */ for( s = v, t = v + 1; t < nv; s++, t++ ) { - - verts[ s ] = verts[ t ]; + + verts[ s ] = verts[ t ]; } nv--; - + /* reset error detection counter */ count = 2 * nv; @@ -1073,19 +1073,19 @@ THREE.FontUtils = { } } - + if ( indices ) return vertIndices; return result; }; - + // calculate area of the contour polygon var area = function ( contour ) { var n = contour.length; var a = 0.0; - + for( var p = n - 1, q = 0; q < n; p = q++ ) { a += contour[ p ].x * contour[ q ].y - contour[ q ].x * contour[ p ].y; @@ -1095,7 +1095,7 @@ THREE.FontUtils = { return a * 0.5; }; - + // see if p is inside triangle abc var insideTriangle = function( ax, ay, @@ -1107,23 +1107,23 @@ THREE.FontUtils = { var cX, cY, apx, apy; var bpx, bpy, cpx, cpy; var cCROSSap, bCROSScp, aCROSSbp; - + aX = cx - bx; aY = cy - by; bX = ax - cx; bY = ay - cy; cX = bx - ax; cY = by - ay; apx= px -ax; apy= py - ay; bpx= px - bx; bpy= py - by; cpx= px - cx; cpy= py - cy; - + aCROSSbp = aX*bpy - aY*bpx; cCROSSap = cX*apy - cY*apx; bCROSScp = bX*cpy - bY*cpx; - + return ( (aCROSSbp >= 0.0) && (bCROSScp >= 0.0) && (cCROSSap >= 0.0) ); }; - - + + var snip = function ( contour, u, v, w, n, verts ) { var p; @@ -1138,13 +1138,13 @@ THREE.FontUtils = { cx = contour[ verts[ w ] ].x; cy = contour[ verts[ w ] ].y; - + if ( EPSILON > (((bx-ax)*(cy-ay)) - ((by-ay)*(cx-ax))) ) return false; - + for ( p = 0; p < n; p++ ) { if( (p == u) || (p == v) || (p == w) ) continue; - + px = contour[ verts[ p ] ].x py = contour[ verts[ p ] ].y @@ -1155,11 +1155,11 @@ THREE.FontUtils = { return true; }; - - + + namespace.Triangulate = process; namespace.Triangulate.area = area; - + return namespace; })(THREE.FontUtils); diff --git a/src/extras/geometries/TorusKnotGeometry.js b/src/extras/geometries/TorusKnotGeometry.js index 4c26a3e7278e70..d66fcd7bf8fde3 100644 --- a/src/extras/geometries/TorusKnotGeometry.js +++ b/src/extras/geometries/TorusKnotGeometry.js @@ -35,7 +35,7 @@ THREE.TorusKnotGeometry = function ( radius, tube, segmentsR, segmentsT, p, q, h var cx, cy; tang.x = p2.x - p.x; tang.y = p2.y - p.y; tang.z = p2.z - p.z; - n.x = p2.x + p.x; n.y = p2.y + p.y; n.z = p2.z + p.z; + n.x = p2.x + p.x; n.y = p2.y + p.y; n.z = p2.z + p.z; bitan.cross( tang, n ); n.cross( bitan, tang ); bitan.normalize(); @@ -60,10 +60,10 @@ THREE.TorusKnotGeometry = function ( radius, tube, segmentsR, segmentsT, p, q, h var ip = ( i + 1 ) % this.segmentsR; var jp = ( j + 1 ) % this.segmentsT; - var a = this.grid[ i ][ j ]; + var a = this.grid[ i ][ j ]; var b = this.grid[ ip ][ j ]; var c = this.grid[ ip ][ jp ]; - var d = this.grid[ i ][ jp ]; + var d = this.grid[ i ][ jp ]; var uva = new THREE.UV( i / this.segmentsR, j / this.segmentsT ); var uvb = new THREE.UV( ( i + 1 ) / this.segmentsR, j / this.segmentsT ); diff --git a/src/extras/objects/Trident.js b/src/extras/objects/Trident.js index 6dfcf6529a3d10..d5408b47aa44ae 100644 --- a/src/extras/objects/Trident.js +++ b/src/extras/objects/Trident.js @@ -11,17 +11,17 @@ * @param showArrows {Boolean} * @param length {number} * @param scale {number} - * + * * @see THREE.Trident.defaultParams */ THREE.Trident = function ( params /** Object */) { THREE.Object3D.call( this ); - + var hPi = Math.PI / 2, cone; - + params = params || THREE.Trident.defaultParams; - + if(params !== THREE.Trident.defaultParams){ for ( var key in THREE.Trident.defaultParams) { if(!params.hasOwnProperty(key)){ @@ -29,23 +29,23 @@ THREE.Trident = function ( params /** Object */) { } } } - + this.scale = new THREE.Vector3( params.scale, params.scale, params.scale ); this.addChild( getSegment( new THREE.Vector3(params.length,0,0), params.xAxisColor ) ); this.addChild( getSegment( new THREE.Vector3(0,params.length,0), params.yAxisColor ) ); this.addChild( getSegment( new THREE.Vector3(0,0,params.length), params.zAxisColor ) ); - + if(params.showArrows){ cone = getCone(params.xAxisColor); cone.rotation.y = - hPi; cone.position.x = params.length; this.addChild( cone ); - + cone = getCone(params.yAxisColor); cone.rotation.x = hPi; cone.position.y = params.length; this.addChild( cone ); - + cone = getCone(params.zAxisColor); cone.rotation.y = Math.PI; cone.position.z = params.length; diff --git a/src/extras/physics/Collisions.js b/src/extras/physics/Collisions.js index 4d93232d281263..3182ac1ff9b2bf 100644 --- a/src/extras/physics/Collisions.js +++ b/src/extras/physics/Collisions.js @@ -162,13 +162,13 @@ THREE.CollisionSystem.prototype.rayMesh = function( r, me ) { me.normal.normalize(); } - + } - + else if (face instanceof THREE.Face4) { - + var nd = this.rayTriangle( rt, p0, p1, p3, d, this.collisionNormal, me.mesh ); - + if( nd < d ) { d = nd; @@ -177,9 +177,9 @@ THREE.CollisionSystem.prototype.rayMesh = function( r, me ) { me.normal.normalize(); } - + nd = this.rayTriangle( rt, p1, p2, p3, d, this.collisionNormal, me.mesh ); - + if( nd < d ) { d = nd; @@ -188,7 +188,7 @@ THREE.CollisionSystem.prototype.rayMesh = function( r, me ) { me.normal.normalize(); } - + } } @@ -201,7 +201,7 @@ THREE.CollisionSystem.prototype.rayTriangle = function( ray, p0, p1, p2, mind, n var e1 = THREE.CollisionSystem.__v1, e2 = THREE.CollisionSystem.__v2; - + n.set( 0, 0, 0 ); // do not crash on quads, fail instead @@ -212,18 +212,18 @@ THREE.CollisionSystem.prototype.rayTriangle = function( ray, p0, p1, p2, mind, n var dot = n.dot( ray.direction ); if ( !( dot < 0 ) ) { - + if ( mesh.doubleSided || mesh.flipSided ) { - + n.multiplyScalar (-1.0); dot *= -1.0; - + } else { - + return Number.MAX_VALUE; - + } - + } var d = n.dot( p0 ); diff --git a/src/extras/renderers/AnaglyphWebGLRenderer.js b/src/extras/renderers/AnaglyphWebGLRenderer.js index 77b6bb6283fc4e..a8fa1bf65a15fa 100644 --- a/src/extras/renderers/AnaglyphWebGLRenderer.js +++ b/src/extras/renderers/AnaglyphWebGLRenderer.js @@ -5,7 +5,7 @@ if ( THREE.WebGLRenderer ) { - THREE.AnaglyphWebGLRenderer = function ( parameters ) { + THREE.AnaglyphWebGLRenderer = function ( parameters ) { THREE.WebGLRenderer.call( this, parameters ); @@ -15,7 +15,7 @@ if ( THREE.WebGLRenderer ) { eyeLeft = new THREE.Matrix4(), focalLength = 125, aspect, near, fov; - + _cameraL.useTarget = _cameraR.useTarget = false; _cameraL.matrixAutoUpdate = _cameraR.matrixAutoUpdate = false; @@ -85,23 +85,23 @@ if ( THREE.WebGLRenderer ) { }; /* - * Renderer now uses an asymmetric perspective projection (http://paulbourke.net/miscellaneous/stereographics/stereorender/). + * Renderer now uses an asymmetric perspective projection (http://paulbourke.net/miscellaneous/stereographics/stereorender/). * Each camera is offset by the eye seperation and its projection matrix is also skewed asymetrically back to converge on the same - * projection plane. Added a focal length parameter to, this is where the parallax is equal to 0. + * projection plane. Added a focal length parameter to, this is where the parallax is equal to 0. */ - this.render = function ( scene, camera, renderTarget, forceClear ) { - - + this.render = function ( scene, camera, renderTarget, forceClear ) { + + camera.update( null, true ); - + var hasCameraChanged = aspect !== camera.aspect || near !== camera.near || fov !== camera.fov; - + if( hasCameraChanged ) { - + aspect = camera.aspect; near = camera.near; - fov = camera.fov; - + fov = camera.fov; + var projectionMatrix = camera.projectionMatrix.clone(), eyeSep = focalLength / 30 * 0.5, eyeSepOnProjection = eyeSep * near / focalLength, @@ -111,23 +111,23 @@ if ( THREE.WebGLRenderer ) { //translate xOffset eyeRight.n14 = eyeSep; eyeLeft.n14 = -eyeSep; - + //For left eye xmin = -ymax * aspect + eyeSepOnProjection; xmax = ymax * aspect + eyeSepOnProjection; projectionMatrix.n11 = 2 * near / ( xmax - xmin ); projectionMatrix.n13 = ( xmax + xmin ) / ( xmax - xmin ); _cameraL.projectionMatrix = projectionMatrix.clone(); - - //for right eye + + //for right eye xmin = -ymax * aspect - eyeSepOnProjection; xmax = ymax * aspect - eyeSepOnProjection; projectionMatrix.n11 = 2 * near / ( xmax - xmin ); projectionMatrix.n13 = ( xmax + xmin ) / ( xmax - xmin ); _cameraR.projectionMatrix = projectionMatrix.clone(); - - } - + + } + _cameraL.matrix = camera.matrixWorld.clone().multiplySelf( eyeLeft ); _cameraL.update(null, true); _cameraL.position.copy( camera.position ); @@ -141,11 +141,11 @@ if ( THREE.WebGLRenderer ) { _cameraR.near = near; _cameraR.far = camera.far; _render.call( _this, scene, _cameraR, _renderTargetR, true ); - + _render.call( _this, _scene, _camera ); }; }; - + } diff --git a/src/extras/renderers/CrosseyedWebGLRenderer.js b/src/extras/renderers/CrosseyedWebGLRenderer.js index aa1c21335bf83a..42052e7e9139db 100644 --- a/src/extras/renderers/CrosseyedWebGLRenderer.js +++ b/src/extras/renderers/CrosseyedWebGLRenderer.js @@ -13,8 +13,8 @@ if ( THREE.WebGLRenderer ) { var _this = this, _setSize = this.setSize, _render = this.render; var _width, _height; - - var _cameraL = new THREE.Camera(), + + var _cameraL = new THREE.Camera(), _cameraR = new THREE.Camera(); _this.separation = 10; @@ -23,10 +23,10 @@ if ( THREE.WebGLRenderer ) { var SCREEN_WIDTH = window.innerWidth; var SCREEN_HEIGHT = window.innerHeight; var HALF_WIDTH = SCREEN_WIDTH / 2; - + var _camera = new THREE.Camera( 53, HALF_WIDTH / SCREEN_HEIGHT, 1, 10000 ); _camera.position.z = -10; - + this.setSize = function ( width, height ) { @@ -38,7 +38,7 @@ if ( THREE.WebGLRenderer ) { }; this.render = function ( scene, camera, renderTarget, forceClear ) { - + this.clear(); _cameraL.fov = camera.fov; @@ -46,7 +46,7 @@ if ( THREE.WebGLRenderer ) { _cameraL.near = camera.near; _cameraL.far = camera.far; _cameraL.updateProjectionMatrix(); - + _cameraL.position.copy( camera.position ); _cameraL.target.position.copy( camera.target.position ); _cameraL.translateX( _this.separation ); @@ -59,12 +59,12 @@ if ( THREE.WebGLRenderer ) { this.setViewport( 0, 0, _width, _height ); _render.call( _this, scene, _cameraL ); - + this.setViewport( _width, 0, _width, _height ); _render.call( _this, scene, _cameraR, false ); }; }; - + } diff --git a/src/lights/AmbientLight.js b/src/lights/AmbientLight.js index ad2e644ca15518..0e56261bdf71a2 100644 --- a/src/lights/AmbientLight.js +++ b/src/lights/AmbientLight.js @@ -9,4 +9,4 @@ THREE.AmbientLight = function ( hex ) { }; THREE.AmbientLight.prototype = new THREE.Light(); -THREE.AmbientLight.prototype.constructor = THREE.AmbientLight; +THREE.AmbientLight.prototype.constructor = THREE.AmbientLight; diff --git a/src/lights/DirectionalLight.js b/src/lights/DirectionalLight.js index 526daf76d099bf..8111c52f611d9e 100644 --- a/src/lights/DirectionalLight.js +++ b/src/lights/DirectionalLight.js @@ -14,4 +14,4 @@ THREE.DirectionalLight = function ( hex, intensity, distance, castShadow ) { }; THREE.DirectionalLight.prototype = new THREE.Light(); -THREE.DirectionalLight.prototype.constructor = THREE.DirectionalLight; +THREE.DirectionalLight.prototype.constructor = THREE.DirectionalLight; diff --git a/src/lights/LensFlare.js b/src/lights/LensFlare.js index 606ec3290c6a4f..a3e243e129f54d 100644 --- a/src/lights/LensFlare.js +++ b/src/lights/LensFlare.js @@ -1,7 +1,7 @@ /** * @author Mikael Emtinger */ - + THREE.LensFlare = function ( texture, size, distance, blending ) { THREE.Object3D.call( this ); @@ -11,9 +11,9 @@ THREE.LensFlare = function ( texture, size, distance, blending ) { this.customUpdateCallback = undefined; if( texture !== undefined ) { - + this.add( texture, size, distance, blending ); - + } }; @@ -24,21 +24,21 @@ THREE.LensFlare.prototype.supr = THREE.Object3D.prototype; /* - * Add: adds another flare + * Add: adds another flare */ THREE.LensFlare.prototype.add = function( texture, size, distance, blending ) { - + if( size === undefined ) size = -1; if( distance === undefined ) distance = 0; if( blending === undefined ) blending = THREE.BillboardBlending; - + distance = Math.min( distance, Math.max( 0, distance )); this.lensFlares.push( { texture: texture, // THREE.Texture size: size, // size in pixels (-1 = use texture.width) distance: distance, // distance (0-1) from light source (0=at light source) - x: 0, y: 0, z: 0, // screen position (-1 => 1) z = 0 is ontop z = 1 is back + x: 0, y: 0, z: 0, // screen position (-1 => 1) z = 0 is ontop z = 1 is back scale: 1, // scale rotation: 1, // rotation opacity: 1, // opacity @@ -53,17 +53,17 @@ THREE.LensFlare.prototype.add = function( texture, size, distance, blending ) { */ 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 vecY = -this.positionScreen.y * 2; + + for( f = 0; f < fl; f++ ) { - + flare = this.lensFlares[ f ]; - + flare.x = this.positionScreen.x + vecX * flare.distance; flare.y = this.positionScreen.y + vecY * flare.distance; diff --git a/src/lights/Light.js b/src/lights/Light.js index b6db323d2fe181..edbcb4b121fe49 100644 --- a/src/lights/Light.js +++ b/src/lights/Light.js @@ -2,7 +2,7 @@ * @author mr.doob / http://mrdoob.com/ * @author alteredq / http://alteredqualia.com/ */ - + THREE.Light = function ( hex ) { THREE.Object3D.call( this ); diff --git a/src/lights/PointLight.js b/src/lights/PointLight.js index b7b67062893e9c..490484e8b7a713 100644 --- a/src/lights/PointLight.js +++ b/src/lights/PointLight.js @@ -13,4 +13,4 @@ THREE.PointLight = function ( hex, intensity, distance ) { }; THREE.PointLight.prototype = new THREE.Light(); -THREE.PointLight.prototype.constructor = THREE.PointLight; +THREE.PointLight.prototype.constructor = THREE.PointLight; diff --git a/src/materials/LineBasicMaterial.js b/src/materials/LineBasicMaterial.js index 073c951ea0663e..f0e9aa08aecdd2 100644 --- a/src/materials/LineBasicMaterial.js +++ b/src/materials/LineBasicMaterial.js @@ -5,14 +5,14 @@ * parameters = { * color: , * opacity: , - + * blending: THREE.NormalBlending, * depthTest: , - + * linewidth: , - * linecap: "round", + * linecap: "round", * linejoin: "round", - + * vertexColors: * } */ diff --git a/src/materials/MeshDepthMaterial.js b/src/materials/MeshDepthMaterial.js index 3aae3be850a9f2..f85d82715c0da5 100644 --- a/src/materials/MeshDepthMaterial.js +++ b/src/materials/MeshDepthMaterial.js @@ -4,13 +4,13 @@ * * parameters = { * opacity: , - + * blending: THREE.NormalBlending, * depthTest: , - + * wireframe: , * wireframeLinewidth: - * } + * } */ THREE.MeshDepthMaterial = function ( parameters ) { diff --git a/src/materials/MeshNormalMaterial.js b/src/materials/MeshNormalMaterial.js index 7f88007012035b..8e6f02e499e0a1 100644 --- a/src/materials/MeshNormalMaterial.js +++ b/src/materials/MeshNormalMaterial.js @@ -3,11 +3,11 @@ * * parameters = { * opacity: , - + * shading: THREE.FlatShading, * blending: THREE.NormalBlending, * depthTest: , - + * wireframe: , * wireframeLinewidth: * } diff --git a/src/materials/MeshShaderMaterial.js b/src/materials/MeshShaderMaterial.js index a4f396b65f4e5c..8db7698c32d58c 100644 --- a/src/materials/MeshShaderMaterial.js +++ b/src/materials/MeshShaderMaterial.js @@ -4,16 +4,16 @@ * parameters = { * fragmentShader: , * vertexShader: , - + * uniforms: { "parameter1": { type: "f", value: 1.0 }, "parameter2": { type: "i" value2: 2 } }, - + * shading: THREE.SmoothShading, * blending: THREE.NormalBlending, * depthTest: , - + * wireframe: , * wireframeLinewidth: , - + * lights: , * vertexColors: , * skinning: , diff --git a/src/materials/ParticleBasicMaterial.js b/src/materials/ParticleBasicMaterial.js index 455e3d98c2db67..5194f89d5984e5 100644 --- a/src/materials/ParticleBasicMaterial.js +++ b/src/materials/ParticleBasicMaterial.js @@ -6,12 +6,12 @@ * color: , * opacity: , * map: new THREE.Texture( ), - + * size: , - + * blending: THREE.NormalBlending, * depthTest: , - + * vertexColors: * } */ diff --git a/src/materials/ShadowVolumeDynamicMaterial.js b/src/materials/ShadowVolumeDynamicMaterial.js index a5e24a31874cfe..dc911f3b23df6e 100644 --- a/src/materials/ShadowVolumeDynamicMaterial.js +++ b/src/materials/ShadowVolumeDynamicMaterial.js @@ -6,21 +6,21 @@ * color: , * opacity: , * map: new THREE.Texture( ), - + * lightMap: new THREE.Texture( ), - + * envMap: new THREE.TextureCube( [posx, negx, posy, negy, posz, negz] ), * combine: THREE.Multiply, * reflectivity: , * refractionRatio: , - + * shading: THREE.SmoothShading, * blending: THREE.NormalBlending, * depthTest: , - + * wireframe: , * wireframeLinewidth: , - + * vertexColors: , * skinning: * } diff --git a/src/objects/Mesh.js b/src/objects/Mesh.js index c8c3b0c4da4b1e..d1eb72299a6e94 100644 --- a/src/objects/Mesh.js +++ b/src/objects/Mesh.js @@ -65,6 +65,6 @@ THREE.Mesh.prototype.getMorphTargetIndexByName = function( name ) { return this.morphTargetDictionary[ 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; } diff --git a/src/objects/SkinnedMesh.js b/src/objects/SkinnedMesh.js index 17f9b83f75606f..16246448b55619 100644 --- a/src/objects/SkinnedMesh.js +++ b/src/objects/SkinnedMesh.js @@ -27,7 +27,7 @@ THREE.SkinnedMesh = function( geometry, materials ) { bone = this.addBone(); bone.name = gbone.name; - bone.position.set( p[0], p[1], p[2] ); + bone.position.set( p[0], p[1], p[2] ); bone.quaternion.set( q[0], q[1], q[2], q[3] ); bone.useQuaternion = true; @@ -150,7 +150,7 @@ THREE.SkinnedMesh.prototype.update = function ( parentMatrixWorld, forceUpdate, /* - * Add + * Add */ THREE.SkinnedMesh.prototype.addBone = function( bone ) { @@ -187,7 +187,7 @@ THREE.SkinnedMesh.prototype.pose = function() { } - // project vertices to local + // project vertices to local if ( this.geometry.skinVerticesA === undefined ) { diff --git a/src/renderers/CanvasRenderer.js b/src/renderers/CanvasRenderer.js index dee96819d002e3..8f5bd3d53c25be 100644 --- a/src/renderers/CanvasRenderer.js +++ b/src/renderers/CanvasRenderer.js @@ -596,7 +596,7 @@ THREE.CanvasRenderer = function ( parameters ) { }/* else if ( material.envMap.mapping == THREE.SphericalRefractionMapping ) { - + }*/ diff --git a/utils/exporters/max/ThreeJSExporter.ms b/utils/exporters/max/ThreeJSExporter.ms index b07282b873d0be..d9bfd8a1292b98 100644 --- a/utils/exporters/max/ThreeJSExporter.ms +++ b/utils/exporters/max/ThreeJSExporter.ms @@ -47,21 +47,21 @@ rollout ThreeJSExporter "ThreeJSExporter" hyperLink lab1 "Original source at GitHub" address:"https://github.com/alteredq/three.js/blob/master/utils/exporters/max/ThreeJSExporter.ms" color:(color 255 120 0) align:#left label dummy1 "--------------------------------------------------------" align:#left - + checkbox exportColor "Export vertex colors" checked:false enabled:true checkbox exportUv "Export uvs" checked:true enabled:true checkbox exportNormal "Export normals" checked:true enabled:true checkbox smoothNormal "Use vertex normals" checked:false enabled:true - + label dummy2 "--------------------------------------------------------" align:#left - + checkbox flipYZ "Flip YZ" checked:true enabled:true checkbox flipUV "Flip UV" checked:true enabled:true checkbox flipFace "Flip all faces" checked:false enabled:true checkbox autoflipFace "Try fixing flipped faces" checked:false enabled:true label dummy3 "--------------------------------------------------------" align:#left - + button btn_export "Export selected objects" ) @@ -70,7 +70,7 @@ rollout ThreeJSExporter "ThreeJSExporter" ------------------------------------------------------------------------------------- -- Dump vertices - function DumpVertices src = + function DumpVertices src = ( Format "\"vertices\": [" to:ostream @@ -102,9 +102,9 @@ rollout ThreeJSExporter "ThreeJSExporter" z = vert.z ) - + Format vertexFormat x y z to:ostream - + if i < num then Format "," to:ostream ) @@ -114,11 +114,11 @@ rollout ThreeJSExporter "ThreeJSExporter" Format "],\n\n" to:ostream ) - + ------------------------------------------------------------------------------------- -- Dump colors - function DumpColors src useColors = + function DumpColors src useColors = ( Format "\"colors\": [" to:ostream @@ -132,19 +132,19 @@ rollout ThreeJSExporter "ThreeJSExporter" ( col = src[i] - + r = col.r as Integer g = col.g as Integer b = col.b as Integer - + hexNum = ( bit.shift r 16 ) + ( bit.shift g 8 ) + b - + -- hexColor = formattedPrint hexNum format:"#x" -- Format "%" hexColor to:ostream decColor = formattedPrint hexNum format:"#d" Format "%" decColor to:ostream - + if i < num then Format "," to:ostream ) @@ -153,12 +153,12 @@ rollout ThreeJSExporter "ThreeJSExporter" Format "],\n\n" to:ostream - ) + ) ------------------------------------------------------------------------------------- -- Dump normals - function DumpNormals src = + function DumpNormals src = ( Format "\"normals\": [" to:ostream @@ -180,9 +180,9 @@ rollout ThreeJSExporter "ThreeJSExporter" x = normal.x y = normal.z z = normal.y - + z *= -1 - + ) else ( @@ -208,7 +208,7 @@ rollout ThreeJSExporter "ThreeJSExporter" ------------------------------------------------------------------------------------- -- Dump uvs - function DumpUvs src = + function DumpUvs src = ( Format "\"uvs\": [[" to:ostream @@ -225,7 +225,7 @@ rollout ThreeJSExporter "ThreeJSExporter" u = uvw.x - if flipUV.checked then + if flipUV.checked then ( v = 1 - uvw.y ) @@ -249,11 +249,11 @@ rollout ThreeJSExporter "ThreeJSExporter" ------------------------------------------------------------------------------------- -- Dump faces - function DumpFaces src useColors = + function DumpFaces src useColors = ( Format "\"faces\": [" to:ostream - + num = src.count if num > 0 then @@ -268,9 +268,9 @@ rollout ThreeJSExporter "ThreeJSExporter" fuv = zface[2] m = zface[3] - 1 fc = zface[4] - + needsFlip = zface[5] - + isTriangle = true hasMaterial = true hasFaceUvs = false @@ -289,12 +289,12 @@ rollout ThreeJSExporter "ThreeJSExporter" faceType = bit.set faceType 6 hasFaceVertexNormals faceType = bit.set faceType 7 hasFaceColors faceType = bit.set faceType 8 hasFaceVertexColors - + if i > 1 then ( Format "," faceType to:ostream ) - + Format "%" faceType to:ostream if isTriangle then @@ -303,8 +303,8 @@ rollout ThreeJSExporter "ThreeJSExporter" va = (fv.x - 1) as Integer vb = (fv.y - 1) as Integer vc = (fv.z - 1) as Integer - - if flipFace.checked or needsFlip then + + if flipFace.checked or needsFlip then ( tmp = vb @@ -312,26 +312,26 @@ rollout ThreeJSExporter "ThreeJSExporter" vc = tmp ) - - + + Format ",%,%,%" va vb vc to:ostream - - if hasMaterial then + + if hasMaterial then ( Format ",%" m to:ostream ) - + if hasFaceVertexUvs then ( ua = (fuv.x - 1) as Integer ub = (fuv.y - 1) as Integer uc = (fuv.z - 1) as Integer - - if flipFace.checked or needsFlip then + + if flipFace.checked or needsFlip then ( tmp = ub @@ -339,15 +339,15 @@ rollout ThreeJSExporter "ThreeJSExporter" uc = tmp ) - + Format ",%,%,%" ua ub uc to:ostream ) - + if hasFaceVertexNormals then ( - if smoothNormal.checked then + if smoothNormal.checked then ( -- normals have the same indices as vertices @@ -357,7 +357,7 @@ rollout ThreeJSExporter "ThreeJSExporter" nc = vc ) - else + else ( -- normals have the same indices as face @@ -366,8 +366,8 @@ rollout ThreeJSExporter "ThreeJSExporter" nc = na ) - - if flipFace.checked or needsFlip then + + if flipFace.checked or needsFlip then ( tmp = nb @@ -375,20 +375,20 @@ rollout ThreeJSExporter "ThreeJSExporter" nc = tmp ) - + Format ",%,%,%" na nb nc to:ostream ) - + if hasFaceVertexColors then ( ca = (fc.x - 1) as Integer cb = (fc.y - 1) as Integer cc = (fc.z - 1) as Integer - - if flipFace.checked or needsFlip then + + if flipFace.checked or needsFlip then ( tmp = cb @@ -396,13 +396,13 @@ rollout ThreeJSExporter "ThreeJSExporter" cc = tmp ) - + Format ",%,%,%" ca cb cc to:ostream ) ) - + ) ) @@ -414,7 +414,7 @@ rollout ThreeJSExporter "ThreeJSExporter" ------------------------------------------------------------------------------------- -- Dump color - function DumpColor pcolor label = + function DumpColor pcolor label = ( r = pcolor.r / 255 g = pcolor.g / 255 @@ -426,19 +426,19 @@ rollout ThreeJSExporter "ThreeJSExporter" Format "\"%\" : [%, %, %],\n" label fr fg fb to:ostream - ) + ) ------------------------------------------------------------------------------------- -- Dump map - function DumpMap pmap label = + function DumpMap pmap label = ( if classof pmap == BitmapTexture then ( bm = pmap.bitmap - if bm != undefined then + if bm != undefined then ( fname = filenameFromPath bm.filename @@ -453,7 +453,7 @@ rollout ThreeJSExporter "ThreeJSExporter" ------------------------------------------------------------------------------------- -- Export materials - function ExportMaterials zmaterials zcolors = + function ExportMaterials zmaterials zcolors = ( Format "\"materials\": [\n" to:ostream @@ -474,9 +474,9 @@ rollout ThreeJSExporter "ThreeJSExporter" ( useVertexColors = zcolors[i] - + Format "\"DbgName\" : \"%\",\n" mat.name to:ostream - + -- colors DumpColor mat.diffuse "colorDiffuse" @@ -485,7 +485,7 @@ rollout ThreeJSExporter "ThreeJSExporter" t = mat.opacity / 100 s = mat.glossiness - + Format "\"transparency\" : %,\n" t to:ostream Format "\"specularCoef\" : %,\n" s to:ostream @@ -498,24 +498,24 @@ rollout ThreeJSExporter "ThreeJSExporter" DumpMap mat.opacityMap "mapAlpha" ) - else + else ( - + useVertexColors = false - + Format "\"DbgName\" : \"%\",\n" "dummy" to:ostream - + DumpColor red "colorDiffuse" - + ) - + Format "\"vertexColors\" : %\n" useVertexColors to:ostream Format "}" to:ostream if ( i < totalMaterials ) then Format "," to:ostream Format "\n\n" to:ostream - ) + ) Format "],\n\n" to:ostream @@ -546,7 +546,7 @@ rollout ThreeJSExporter "ThreeJSExporter" ( nColors = GetNumCPVVerts obj - + if nColors > 0 then ( @@ -573,8 +573,8 @@ rollout ThreeJSExporter "ThreeJSExporter" ( num = obj.numVerts - - for i = 1 to num do + + for i = 1 to num do ( n = GetNormal obj i @@ -596,7 +596,7 @@ rollout ThreeJSExporter "ThreeJSExporter" num = obj.numFaces - for i = 1 to num do + for i = 1 to num do ( n = GetFaceNormal obj i @@ -622,8 +622,8 @@ rollout ThreeJSExporter "ThreeJSExporter" function ExtractUvs obj whereto = ( n = obj.numTVerts - - for i = 1 to n do + + for i = 1 to n do ( v = GetTVert obj i @@ -643,10 +643,10 @@ rollout ThreeJSExporter "ThreeJSExporter" useMultiMaterial = false materialIDList = #() - + materialClass = classof objMaterial - - if materialClass == StandardMaterial then + + if materialClass == StandardMaterial then ( fm = findItem allMaterials objMaterial @@ -657,12 +657,12 @@ rollout ThreeJSExporter "ThreeJSExporter" useMultiMaterial = true - for i = 1 to n do + for i = 1 to n do ( mID = GetFaceMatID objMesh i materialIndex = findItem objMaterial.materialIDList mID - + if materialIndex > 0 then ( @@ -670,7 +670,7 @@ rollout ThreeJSExporter "ThreeJSExporter" mMergedIndex = findItem allMaterials subMaterial - if mMergedIndex > 0 then + if mMergedIndex > 0 then ( materialIDList[mID] = mMergedIndex @@ -696,29 +696,29 @@ rollout ThreeJSExporter "ThreeJSExporter" ) else ( - + -- undefined material - + fm = findItem allMaterials false - + ) - - for i = 1 to n do + + for i = 1 to n do ( zface = #() - + fv = GetFace objMesh i fv.x += offsetVert fv.y += offsetVert fv.z += offsetVert - if useMultiMaterial then + if useMultiMaterial then ( mID = GetFaceMatID objMesh i - fm = materialIDList[mID] + fm = materialIDList[mID] ) @@ -726,7 +726,7 @@ rollout ThreeJSExporter "ThreeJSExporter" ( fuv = GetTVFace objMesh i - + fuv.x += offsetUv fuv.y += offsetUv fuv.z += offsetUv @@ -738,12 +738,12 @@ rollout ThreeJSExporter "ThreeJSExporter" fuv = false ) - + if hasVColors then ( fc = GetVCFace objMesh i - + fc.x += offsetColor fc.y += offsetColor fc.z += offsetColor @@ -756,7 +756,7 @@ rollout ThreeJSExporter "ThreeJSExporter" ) - append zface fv + append zface fv append zface fuv append zface fm append zface fc @@ -770,10 +770,10 @@ rollout ThreeJSExporter "ThreeJSExporter" ------------------------------------------------------------------------------------- -- Extract materials from eventual multi-material - + function ExtractMaterials objMesh objMaterial whereto wheretoColors zname hasVColors = ( - + materialClass = classof objMaterial if materialClass == StandardMaterial then @@ -792,13 +792,13 @@ rollout ThreeJSExporter "ThreeJSExporter" ( n = objMesh.numFaces - - for i = 1 to n do + + for i = 1 to n do ( - + mID = getFaceMatId objMesh i materialIndex = findItem objMaterial.materialIDList mID - + if materialIndex > 0 then ( @@ -812,16 +812,16 @@ rollout ThreeJSExporter "ThreeJSExporter" ) - ) + ) ) ) else ( - + -- unknown or undefined material - + append whereto false append wheretoColors false @@ -831,8 +831,8 @@ rollout ThreeJSExporter "ThreeJSExporter" ------------------------------------------------------------------------------------- -- Hack to figure out if normals are messed up - - function NeedsFaceFlip node = + + function NeedsFaceFlip node = ( needsFlip = false @@ -865,29 +865,29 @@ rollout ThreeJSExporter "ThreeJSExporter" ( needsFlip = false hasVColors = false - + zmesh = SnapshotAsMesh node - + if autoflipFace.checked then ( needsFlip = NeedsFaceFlip node ) - + if exportColor.checked and ( getNumCPVVerts zmesh ) > 0 then ( hasVColors = true ) - + return #( zmesh, node.name, node.material, needsFlip, hasVColors ) ) -- Not geometry ... could be a camera, light, etc. - + return #( false, node.name, 0, false, false ) ) @@ -905,31 +905,31 @@ rollout ThreeJSExporter "ThreeJSExporter" mergedVertices = #() mergedNormals = #() mergedColors = #() - + mergedUvs = #() mergedFaces = #() - + mergedMaterials = #() mergedMaterialsColors = #() - + sceneHasVColors = false - - for obj in selection do + + for obj in selection do ( result = ExtractMesh obj meshObj = result[1] - if ClassOf meshObj == TriMesh then + if ClassOf meshObj == TriMesh then ( meshName = result[2] meshMaterial = result[3] needsFlip = result[4] hasVColors = result[5] - + sceneHasVColors = sceneHasVColors or hasVColors - + append meshObjects result vertexOffset = mergedVertices.count @@ -941,7 +941,7 @@ rollout ThreeJSExporter "ThreeJSExporter" ExtractVertices meshObj mergedVertices ExtractNormals meshObj mergedNormals needsFlip ExtractColors meshObj mergedColors - + ExtractUvs meshObj mergedUvs ExtractFaces meshObj meshMaterial mergedFaces mergedMaterials needsFlip hasVColors vertexOffset uvOffset colorOffset @@ -953,13 +953,13 @@ rollout ThreeJSExporter "ThreeJSExporter" totalVertices = mergedVertices.count totalFaces = mergedFaces.count totalMaterials = mergedMaterials.count - + totalColors = 0 totalNormals = 0 totalUvs = 0 - + useColors = false - + if sceneHasVColors and exportColor.checked then ( @@ -968,7 +968,7 @@ rollout ThreeJSExporter "ThreeJSExporter" ) - if exportNormal.checked then + if exportNormal.checked then ( totalNormals = mergedNormals.count @@ -993,7 +993,7 @@ rollout ThreeJSExporter "ThreeJSExporter" i = 0 - for obj in meshObjects do + for obj in meshObjects do ( meshName = obj[2] @@ -1070,5 +1070,5 @@ rollout ThreeJSExporter "ThreeJSExporter" ) -) +) createDialog ThreeJSExporter width:300 \ No newline at end of file