language
stringclasses
1 value
owner
stringlengths
2
15
repo
stringlengths
2
21
sha
stringlengths
45
45
message
stringlengths
7
36.3k
path
stringlengths
1
199
patch
stringlengths
15
102k
is_multipart
bool
2 classes
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_panorama_cube.html
@@ -96,7 +96,7 @@ var imageObj = new Image(); - imageObj.onload = function() { + imageObj.onload = function () { var canvas, context; var tileWidth = imageObj.height; @@ -108,7 +108,7 @@ canvas.height = tileWidth; canvas.width = tileWidth; context.drawImage( imageObj, tileWidth * i, 0, tileWidth, tileWidth, 0, 0, tileWidth, tileWidth ); - textures[ i ].image = canvas + textures[ i ].image = canvas; textures[ i ].needsUpdate = true; }
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_panorama_dualfisheye.html
@@ -41,11 +41,14 @@ var camera, scene, renderer; var isUserInteracting = false, - onMouseDownMouseX = 0, onMouseDownMouseY = 0, - lon = 0, onMouseDownLon = 0, - lat = 0, onMouseDownLat = 0, - phi = 0, theta = 0, - distance = 500; + lon = 0, lat = 0, + phi = 0, theta = 0, + distance = 500, + onPointerDownPointerX = 0, + onPointerDownPointerY = 0, + + onPointerDownLon = 0, + onPointerDownLat = 0; init(); animate(); @@ -153,7 +156,7 @@ } - function onDocumentMouseUp( event ) { + function onDocumentMouseUp() { isUserInteracting = false;
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_panorama_equirectangular.html
@@ -43,10 +43,10 @@ var camera, scene, renderer; var isUserInteracting = false, - onMouseDownMouseX = 0, onMouseDownMouseY = 0, - lon = 0, onMouseDownLon = 0, - lat = 0, onMouseDownLat = 0, - phi = 0, theta = 0; + onMouseDownMouseX = 0, onMouseDownMouseY = 0, + lon = 0, onMouseDownLon = 0, + lat = 0, onMouseDownLat = 0, + phi = 0, theta = 0; init(); animate(); @@ -98,13 +98,13 @@ }, false ); - document.addEventListener( 'dragenter', function ( event ) { + document.addEventListener( 'dragenter', function () { document.body.style.opacity = 0.5; }, false ); - document.addEventListener( 'dragleave', function ( event ) { + document.addEventListener( 'dragleave', function () { document.body.style.opacity = 1; @@ -171,7 +171,7 @@ } - function onPointerUp( event ) { + function onPointerUp() { isUserInteracting = false;
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_performance.html
@@ -103,7 +103,7 @@ } - function onDocumentMouseMove(event) { + function onDocumentMouseMove( event ) { mouseX = ( event.clientX - windowHalfX ) * 10; mouseY = ( event.clientY - windowHalfY ) * 10;
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_performance_doublesided.html
@@ -33,8 +33,6 @@ var camera, scene, renderer; - var mesh, geometry; - var mouseX = 0, mouseY = 0; var SCREEN_WIDTH = window.innerWidth, @@ -65,7 +63,7 @@ scene.add( light ); var light = new THREE.PointLight( 0xff1100, 1, 5500 ); - light.position.set( -4000, 0, 0 ); + light.position.set( - 4000, 0, 0 ); scene.add( light ); var light = new THREE.PointLight( 0xffaa00, 2, 3000 ); @@ -75,10 +73,10 @@ var path = "textures/cube/SwedishRoyalCastle/"; var format = '.jpg'; var urls = [ - path + 'px' + format, path + 'nx' + format, - path + 'py' + format, path + 'ny' + format, - path + 'pz' + format, path + 'nz' + format - ]; + path + 'px' + format, path + 'nx' + format, + path + 'py' + format, path + 'ny' + format, + path + 'pz' + format, path + 'nz' + format + ]; var reflectionCube = new THREE.CubeTextureLoader().load( urls ); reflectionCube.format = THREE.RGBFormat; @@ -125,7 +123,7 @@ // - function onWindowResize( event ) { + function onWindowResize() { SCREEN_WIDTH = window.innerWidth; SCREEN_HEIGHT = window.innerHeight; @@ -140,7 +138,7 @@ } - function onDocumentMouseMove(event) { + function onDocumentMouseMove( event ) { mouseX = ( event.clientX - windowHalfX ) * 10; mouseY = ( event.clientY - windowHalfY ) * 10;
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_performance_static.html
@@ -25,8 +25,6 @@ var camera, scene, renderer; - var mesh, zmesh, lightMesh, geometry; - var mouseX = 0, mouseY = 0; var windowHalfX = window.innerWidth / 2; @@ -103,7 +101,7 @@ } - function onDocumentMouseMove(event) { + function onDocumentMouseMove( event ) { mouseX = ( event.clientX - windowHalfX ) * 10; mouseY = ( event.clientY - windowHalfY ) * 10;
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_physics_cloth.html
@@ -21,9 +21,7 @@ padding: 5px; } - a { - color: #a06851; - } + a { color: #a06851; } </style> </head> <body> @@ -47,34 +45,27 @@ } - // - Global variables - - // Graphics variables var container, stats; var camera, controls, scene, renderer; var textureLoader; var clock = new THREE.Clock(); // Physics variables - var gravityConstant = -9.8; + var gravityConstant = - 9.8; var physicsWorld; var rigidBodies = []; var margin = 0.05; var hinge; var cloth; var transformAux1 = new Ammo.btTransform(); - var time = 0; var armMovement = 0; - // - Main code - - init(); animate(); - // - Functions - - function init() { initGraphics(); @@ -96,7 +87,7 @@ scene = new THREE.Scene(); scene.background = new THREE.Color( 0xbfd1e5 ); - camera.position.set( -12, 7, 4 ); + camera.position.set( - 12, 7, 4 ); controls = new THREE.OrbitControls( camera ); controls.target.set( 0, 2, 0 ); @@ -113,21 +104,21 @@ scene.add( ambientLight ); var light = new THREE.DirectionalLight( 0xffffff, 1 ); - light.position.set( -7, 10, 15 ); + light.position.set( - 7, 10, 15 ); light.castShadow = true; var d = 10; - light.shadow.camera.left = -d; + light.shadow.camera.left = - d; light.shadow.camera.right = d; light.shadow.camera.top = d; - light.shadow.camera.bottom = -d; + light.shadow.camera.bottom = - d; light.shadow.camera.near = 2; light.shadow.camera.far = 50; light.shadow.mapSize.x = 1024; light.shadow.mapSize.y = 1024; - light.shadow.bias = -0.003; + light.shadow.bias = - 0.003; scene.add( light ); @@ -153,7 +144,7 @@ var broadphase = new Ammo.btDbvtBroadphase(); var solver = new Ammo.btSequentialImpulseConstraintSolver(); var softBodySolver = new Ammo.btDefaultSoftBodySolver(); - physicsWorld = new Ammo.btSoftRigidDynamicsWorld( dispatcher, broadphase, solver, collisionConfiguration, softBodySolver); + physicsWorld = new Ammo.btSoftRigidDynamicsWorld( dispatcher, broadphase, solver, collisionConfiguration, softBodySolver ); physicsWorld.setGravity( new Ammo.btVector3( 0, gravityConstant, 0 ) ); physicsWorld.getWorldInfo().set_m_gravity( new Ammo.btVector3( 0, gravityConstant, 0 ) ); @@ -170,13 +161,15 @@ var ground = createParalellepiped( 40, 1, 40, 0, pos, quat, new THREE.MeshPhongMaterial( { color: 0xFFFFFF } ) ); ground.castShadow = true; ground.receiveShadow = true; - textureLoader.load( "textures/grid.png", function( texture ) { + textureLoader.load( "textures/grid.png", function ( texture ) { + texture.wrapS = THREE.RepeatWrapping; texture.wrapT = THREE.RepeatWrapping; texture.repeat.set( 40, 40 ); ground.material.map = texture; ground.material.needsUpdate = true; - } ); + + } ); // Wall var brickMass = 0.5; @@ -195,32 +188,40 @@ pos.z = z0; if ( oddRow ) { + pos.z -= 0.25 * brickLength; - } - var nRow = oddRow? numBricksLength + 1 : numBricksLength; + } + + var nRow = oddRow ? numBricksLength + 1 : numBricksLength; for ( var i = 0; i < nRow; i ++ ) { var brickLengthCurrent = brickLength; var brickMassCurrent = brickMass; if ( oddRow && ( i == 0 || i == nRow - 1 ) ) { + brickLengthCurrent *= 0.5; brickMassCurrent *= 0.5; + } var brick = createParalellepiped( brickDepth, brickHeight, brickLengthCurrent, brickMassCurrent, pos, quat, createMaterial() ); brick.castShadow = true; brick.receiveShadow = true; if ( oddRow && ( i == 0 || i == nRow - 2 ) ) { + pos.z += 0.75 * brickLength; - } - else { + + } else { + pos.z += brickLength; + } } pos.y += brickHeight; + } // The cloth @@ -229,9 +230,7 @@ var clothHeight = 3; var clothNumSegmentsZ = clothWidth * 5; var clothNumSegmentsY = clothHeight * 5; - var clothSegmentLengthZ = clothWidth / clothNumSegmentsZ; - var clothSegmentLengthY = clothHeight / clothNumSegmentsY; - var clothPos = new THREE.Vector3( -3, 3, 2 ); + var clothPos = new THREE.Vector3( - 3, 3, 2 ); //var clothGeometry = new THREE.BufferGeometry(); var clothGeometry = new THREE.PlaneBufferGeometry( clothWidth, clothHeight, clothNumSegmentsZ, clothNumSegmentsY ); @@ -243,12 +242,14 @@ cloth.castShadow = true; cloth.receiveShadow = true; scene.add( cloth ); - textureLoader.load( "textures/grid.png", function( texture ) { + textureLoader.load( "textures/grid.png", function ( texture ) { + texture.wrapS = THREE.RepeatWrapping; texture.wrapT = THREE.RepeatWrapping; texture.repeat.set( clothNumSegmentsZ, clothNumSegmentsY ); cloth.material.map = texture; cloth.material.needsUpdate = true; + } ); // Cloth physic object @@ -264,7 +265,7 @@ clothSoftBody.setTotalMass( 0.9, false ); Ammo.castObject( clothSoftBody, Ammo.btCollisionObject ).getCollisionShape().setMargin( margin * 3 ); - physicsWorld.addSoftBody( clothSoftBody, 1, -1 ); + physicsWorld.addSoftBody( clothSoftBody, 1, - 1 ); cloth.userData.physicsBody = clothSoftBody; // Disable deactivation clothSoftBody.setActivationState( 4 ); @@ -295,7 +296,7 @@ // Hinge constraint to move the arm var pivotA = new Ammo.btVector3( 0, pylonHeight * 0.5, 0 ); - var pivotB = new Ammo.btVector3( 0, -0.2, - armLength * 0.5 ); + var pivotB = new Ammo.btVector3( 0, - 0.2, - armLength * 0.5 ); var axis = new Ammo.btVector3( 0, 1, 0 ); hinge = new Ammo.btHingeConstraint( pylon.userData.physicsBody, arm.userData.physicsBody, pivotA, pivotB, axis, axis, true ); physicsWorld.addConstraint( hinge, true ); @@ -336,47 +337,55 @@ scene.add( threeObject ); if ( mass > 0 ) { + rigidBodies.push( threeObject ); // Disable deactivation body.setActivationState( 4 ); + } physicsWorld.addRigidBody( body ); } function createRandomColor() { + return Math.floor( Math.random() * ( 1 << 24 ) ); + } function createMaterial() { - return new THREE.MeshPhongMaterial( { color: createRandomColor() } ); + + return new THREE.MeshPhongMaterial( { color: createRandomColor() } ); + } function initInput() { - window.addEventListener( 'keydown', function( event ) { + window.addEventListener( 'keydown', function ( event ) { + + switch ( event.keyCode ) { - switch ( event.keyCode ) { - // Q - case 81: - armMovement = 1; + // Q + case 81: + armMovement = 1; break; // A - case 65: - armMovement = - 1; + case 65: + armMovement = - 1; break; - } - }, false ); + } + + }, false ); - window.addEventListener( 'keyup', function( event ) { + window.addEventListener( 'keyup', function () { - armMovement = 0; + armMovement = 0; - }, false ); + }, false ); } @@ -406,8 +415,6 @@ renderer.render( scene, camera ); - time += deltaTime; - } function updatePhysics( deltaTime ) { @@ -428,17 +435,18 @@ var node = nodes.at( i ); var nodePos = node.get_m_x(); - clothPositions[ indexFloat++ ] = nodePos.x(); - clothPositions[ indexFloat++ ] = nodePos.y(); - clothPositions[ indexFloat++ ] = nodePos.z(); + clothPositions[ indexFloat ++ ] = nodePos.x(); + clothPositions[ indexFloat ++ ] = nodePos.y(); + clothPositions[ indexFloat ++ ] = nodePos.z(); } cloth.geometry.computeVertexNormals(); cloth.geometry.attributes.position.needsUpdate = true; cloth.geometry.attributes.normal.needsUpdate = true; // Update rigid bodies - for ( var i = 0, il = rigidBodies.length; i < il; i++ ) { + for ( var i = 0, il = rigidBodies.length; i < il; i ++ ) { + var objThree = rigidBodies[ i ]; var objPhys = objThree.userData.physicsBody; var ms = objPhys.getMotionState(); @@ -451,6 +459,7 @@ objThree.quaternion.set( q.x(), q.y(), q.z(), q.w() ); } + } }
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_physics_rope.html
@@ -21,9 +21,7 @@ padding: 5px; } - a { - color: #a06851; - } + a { color: #a06851; } </style> </head> @@ -48,16 +46,14 @@ } - // - Global variables - - // Graphics variables var container, stats; var camera, controls, scene, renderer; var textureLoader; var clock = new THREE.Clock(); // Physics variables - var gravityConstant = -9.8; + var gravityConstant = - 9.8; var collisionConfiguration; var dispatcher; var broadphase; @@ -70,17 +66,11 @@ var rope; var transformAux1 = new Ammo.btTransform(); - var time = 0; var armMovement = 0; - // - Main code - - init(); animate(); - - // - Functions - - function init() { initGraphics(); @@ -102,7 +92,7 @@ scene = new THREE.Scene(); scene.background = new THREE.Color( 0xbfd1e5 ); - camera.position.set( -7, 5, 8 ); + camera.position.set( - 7, 5, 8 ); controls = new THREE.OrbitControls( camera ); controls.target.set( 0, 2, 0 ); @@ -119,13 +109,13 @@ scene.add( ambientLight ); var light = new THREE.DirectionalLight( 0xffffff, 1 ); - light.position.set( -10, 10, 5 ); + light.position.set( - 10, 10, 5 ); light.castShadow = true; var d = 10; - light.shadow.camera.left = -d; + light.shadow.camera.left = - d; light.shadow.camera.right = d; light.shadow.camera.top = d; - light.shadow.camera.bottom = -d; + light.shadow.camera.bottom = - d; light.shadow.camera.near = 2; light.shadow.camera.far = 50; @@ -135,7 +125,6 @@ scene.add( light ); - container.innerHTML = ""; container.appendChild( renderer.domElement ); @@ -160,7 +149,7 @@ broadphase = new Ammo.btDbvtBroadphase(); solver = new Ammo.btSequentialImpulseConstraintSolver(); softBodySolver = new Ammo.btDefaultSoftBodySolver(); - physicsWorld = new Ammo.btSoftRigidDynamicsWorld( dispatcher, broadphase, solver, collisionConfiguration, softBodySolver); + physicsWorld = new Ammo.btSoftRigidDynamicsWorld( dispatcher, broadphase, solver, collisionConfiguration, softBodySolver ); physicsWorld.setGravity( new Ammo.btVector3( 0, gravityConstant, 0 ) ); physicsWorld.getWorldInfo().set_m_gravity( new Ammo.btVector3( 0, gravityConstant, 0 ) ); @@ -177,12 +166,14 @@ var ground = createParalellepiped( 40, 1, 40, 0, pos, quat, new THREE.MeshPhongMaterial( { color: 0xFFFFFF } ) ); ground.castShadow = true; ground.receiveShadow = true; - textureLoader.load( "textures/grid.png", function( texture ) { + textureLoader.load( "textures/grid.png", function ( texture ) { + texture.wrapS = THREE.RepeatWrapping; texture.wrapT = THREE.RepeatWrapping; texture.repeat.set( 40, 40 ); ground.material.map = texture; ground.material.needsUpdate = true; + } ); @@ -195,7 +186,7 @@ ball.receiveShadow = true; var ballShape = new Ammo.btSphereShape( ballRadius ); ballShape.setMargin( margin ); - pos.set( -3, 2, 0 ); + pos.set( - 3, 2, 0 ); quat.set( 0, 0, 0, 1 ); createRigidBody( ball, ballShape, ballMass, pos, quat ); ball.userData.physicsBody.setFriction( 0.5 ); @@ -217,32 +208,40 @@ pos.z = z0; if ( oddRow ) { + pos.z -= 0.25 * brickLength; + } - var nRow = oddRow? numBricksLength + 1 : numBricksLength; + var nRow = oddRow ? numBricksLength + 1 : numBricksLength; for ( var i = 0; i < nRow; i ++ ) { var brickLengthCurrent = brickLength; var brickMassCurrent = brickMass; if ( oddRow && ( i == 0 || i == nRow - 1 ) ) { + brickLengthCurrent *= 0.5; brickMassCurrent *= 0.5; + } var brick = createParalellepiped( brickDepth, brickHeight, brickLengthCurrent, brickMassCurrent, pos, quat, createMaterial() ); brick.castShadow = true; brick.receiveShadow = true; if ( oddRow && ( i == 0 || i == nRow - 2 ) ) { + pos.z += 0.75 * brickLength; - } - else { + + } else { + pos.z += brickLength; + } } pos.y += brickHeight; + } // The rope @@ -259,12 +258,16 @@ var ropePositions = []; var ropeIndices = []; - for ( var i = 0; i < ropeNumSegments + 1; i++ ) { + for ( var i = 0; i < ropeNumSegments + 1; i ++ ) { + ropePositions.push( ropePos.x, ropePos.y + i * segmentLength, ropePos.z ); + } - for ( var i = 0; i < ropeNumSegments; i++ ) { + for ( var i = 0; i < ropeNumSegments; i ++ ) { + ropeIndices.push( i, i + 1 ); + } ropeGeometry.setIndex( new THREE.BufferAttribute( new Uint16Array( ropeIndices ), 1 ) ); @@ -285,7 +288,7 @@ sbConfig.set_piterations( 10 ); ropeSoftBody.setTotalMass( ropeMass, false ); Ammo.castObject( ropeSoftBody, Ammo.btCollisionObject ).getCollisionShape().setMargin( margin * 3 ); - physicsWorld.addSoftBody( ropeSoftBody, 1, -1 ); + physicsWorld.addSoftBody( ropeSoftBody, 1, - 1 ); rope.userData.physicsBody = ropeSoftBody; // Disable deactivation ropeSoftBody.setActivationState( 4 ); @@ -316,7 +319,7 @@ // Hinge constraint to move the arm var pivotA = new Ammo.btVector3( 0, pylonHeight * 0.5, 0 ); - var pivotB = new Ammo.btVector3( 0, -0.2, - armLength * 0.5 ); + var pivotB = new Ammo.btVector3( 0, - 0.2, - armLength * 0.5 ); var axis = new Ammo.btVector3( 0, 1, 0 ); hinge = new Ammo.btHingeConstraint( pylon.userData.physicsBody, arm.userData.physicsBody, pivotA, pivotB, axis, axis, true ); physicsWorld.addConstraint( hinge, true ); @@ -358,43 +361,51 @@ scene.add( threeObject ); if ( mass > 0 ) { + rigidBodies.push( threeObject ); // Disable deactivation body.setActivationState( 4 ); + } physicsWorld.addRigidBody( body ); } function createRandomColor() { + return Math.floor( Math.random() * ( 1 << 24 ) ); + } function createMaterial() { + return new THREE.MeshPhongMaterial( { color: createRandomColor() } ); + } function initInput() { - window.addEventListener( 'keydown', function( event ) { + window.addEventListener( 'keydown', function ( event ) { switch ( event.keyCode ) { + // Q case 81: armMovement = 1; - break; + break; // A case 65: armMovement = - 1; - break; + break; + } }, false ); - window.addEventListener( 'keyup', function( event ) { + window.addEventListener( 'keyup', function () { armMovement = 0; @@ -428,8 +439,6 @@ renderer.render( scene, camera ); - time += deltaTime; - } function updatePhysics( deltaTime ) { @@ -450,15 +459,16 @@ var node = nodes.at( i ); var nodePos = node.get_m_x(); - ropePositions[ indexFloat++ ] = nodePos.x(); - ropePositions[ indexFloat++ ] = nodePos.y(); - ropePositions[ indexFloat++ ] = nodePos.z(); + ropePositions[ indexFloat ++ ] = nodePos.x(); + ropePositions[ indexFloat ++ ] = nodePos.y(); + ropePositions[ indexFloat ++ ] = nodePos.z(); } rope.geometry.attributes.position.needsUpdate = true; // Update rigid bodies - for ( var i = 0, il = rigidBodies.length; i < il; i++ ) { + for ( var i = 0, il = rigidBodies.length; i < il; i ++ ) { + var objThree = rigidBodies[ i ]; var objPhys = objThree.userData.physicsBody; var ms = objPhys.getMotionState(); @@ -471,6 +481,7 @@ objThree.quaternion.set( q.x(), q.y(), q.z(), q.w() ); } + } }
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_physics_terrain.html
@@ -1,439 +1,446 @@ <!DOCTYPE html> <html lang="en"> - <head> - <title>Ammo.js terrain heightfield demo</title> - <meta charset="utf-8"> - <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"> - <style> - body { - color: #61443e; - font-family:Monospace; - font-size:13px; - text-align:center; - - background-color: #bfd1e5; - margin: 0px; - overflow: hidden; - } - - #info { - position: absolute; - top: 0px; width: 100%; - padding: 5px; - } - - a { - - color: #a06851; - } - - </style> - </head> - <body> - <div id="container"><br /><br /><br /><br /><br />Loading...</div> - <div id="info">Ammo.js physics terrain heightfield demo</div> - - <script src="../build/three.js"></script> - <script src="js/libs/ammo.js"></script> - <script src="js/controls/OrbitControls.js"></script> - <script src="js/WebGL.js"></script> - <script src="js/libs/stats.min.js"></script> - - <script> - - // Detects webgl - - if ( WEBGL.isWebGLAvailable() === false ) { - - document.body.appendChild( WEBGL.getWebGLErrorMessage() ); - document.getElementById( 'container' ).innerHTML = ""; + <head> + <title>Ammo.js terrain heightfield demo</title> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"> + <style> + body { + color: #61443e; + font-family:Monospace; + font-size:13px; + text-align:center; - } + background-color: #bfd1e5; + margin: 0px; + overflow: hidden; + } - // - Global variables - + #info { + position: absolute; + top: 0px; width: 100%; + padding: 5px; + } - // Heightfield parameters - var terrainWidthExtents = 100; - var terrainDepthExtents = 100; - var terrainWidth = 128; - var terrainDepth = 128; - var terrainHalfWidth = terrainWidth / 2; - var terrainHalfDepth = terrainDepth / 2; - var terrainMaxHeight = 8; - var terrainMinHeight = -2; + a { color: #a06851; } - // Graphics variables - var container, stats; - var camera, controls, scene, renderer; - var terrainMesh, texture; - var clock = new THREE.Clock(); + </style> + </head> + <body> + <div id="container"><br /><br /><br /><br /><br />Loading...</div> + <div id="info">Ammo.js physics terrain heightfield demo</div> - // Physics variables - var collisionConfiguration; - var dispatcher; - var broadphase; - var solver; - var physicsWorld; - var terrainBody; - var dynamicObjects = []; - var transformAux1 = new Ammo.btTransform(); + <script src="../build/three.js"></script> + <script src="js/libs/ammo.js"></script> + <script src="js/controls/OrbitControls.js"></script> + <script src="js/WebGL.js"></script> + <script src="js/libs/stats.min.js"></script> - var heightData = null; - var ammoHeightData = null; + <script> - var time = 0; - var objectTimePeriod = 3; - var timeNextSpawn = time + objectTimePeriod; - var maxNumObjects = 30; + if ( WEBGL.isWebGLAvailable() === false ) { - // - Main code - - init(); - animate(); + document.body.appendChild( WEBGL.getWebGLErrorMessage() ); + document.getElementById( 'container' ).innerHTML = ""; - function init() { + } - heightData = generateHeight( terrainWidth, terrainDepth, terrainMinHeight, terrainMaxHeight ); + // Heightfield parameters + var terrainWidthExtents = 100; + var terrainDepthExtents = 100; + var terrainWidth = 128; + var terrainDepth = 128; + var terrainHalfWidth = terrainWidth / 2; + var terrainHalfDepth = terrainDepth / 2; + var terrainMaxHeight = 8; + var terrainMinHeight = - 2; - initGraphics(); + // Graphics variables + var container, stats; + var camera, scene, renderer; + var terrainMesh; + var clock = new THREE.Clock(); - initPhysics(); + // Physics variables + var collisionConfiguration; + var dispatcher; + var broadphase; + var solver; + var physicsWorld; + var dynamicObjects = []; + var transformAux1 = new Ammo.btTransform(); - } + var heightData = null; + var ammoHeightData = null; - function initGraphics() { + var time = 0; + var objectTimePeriod = 3; + var timeNextSpawn = time + objectTimePeriod; + var maxNumObjects = 30; - container = document.getElementById( 'container' ); + init(); + animate(); - renderer = new THREE.WebGLRenderer(); - renderer.setPixelRatio( window.devicePixelRatio ); - renderer.setSize( window.innerWidth, window.innerHeight ); - renderer.shadowMap.enabled = true; + function init() { - container.innerHTML = ""; + heightData = generateHeight( terrainWidth, terrainDepth, terrainMinHeight, terrainMaxHeight ); - container.appendChild( renderer.domElement ); + initGraphics(); - stats = new Stats(); - stats.domElement.style.position = 'absolute'; - stats.domElement.style.top = '0px'; - container.appendChild( stats.domElement ); + initPhysics(); + } - camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 0.2, 2000 ); + function initGraphics() { - scene = new THREE.Scene(); - scene.background = new THREE.Color( 0xbfd1e5 ); + container = document.getElementById( 'container' ); - camera.position.y = heightData[ terrainHalfWidth + terrainHalfDepth * terrainWidth ] * ( terrainMaxHeight - terrainMinHeight ) + 5; + renderer = new THREE.WebGLRenderer(); + renderer.setPixelRatio( window.devicePixelRatio ); + renderer.setSize( window.innerWidth, window.innerHeight ); + renderer.shadowMap.enabled = true; - camera.position.z = terrainDepthExtents / 2; - camera.lookAt( 0, 0, 0 ); + container.innerHTML = ""; - controls = new THREE.OrbitControls( camera ); + container.appendChild( renderer.domElement ); - var geometry = new THREE.PlaneBufferGeometry( terrainWidthExtents, terrainDepthExtents, terrainWidth - 1, terrainDepth - 1 ); - geometry.rotateX( -Math.PI / 2 ); + stats = new Stats(); + stats.domElement.style.position = 'absolute'; + stats.domElement.style.top = '0px'; + container.appendChild( stats.domElement ); - var vertices = geometry.attributes.position.array; - for ( var i = 0, j = 0, l = vertices.length; i < l; i++, j += 3 ) { + camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 0.2, 2000 ); - // j + 1 because it is the y component that we modify - vertices[ j + 1 ] = heightData[ i ]; + scene = new THREE.Scene(); + scene.background = new THREE.Color( 0xbfd1e5 ); - } + camera.position.y = heightData[ terrainHalfWidth + terrainHalfDepth * terrainWidth ] * ( terrainMaxHeight - terrainMinHeight ) + 5; - geometry.computeVertexNormals(); + camera.position.z = terrainDepthExtents / 2; + camera.lookAt( 0, 0, 0 ); - var groundMaterial = new THREE.MeshPhongMaterial( { color: 0xC7C7C7 } ); - terrainMesh = new THREE.Mesh( geometry, groundMaterial ); - terrainMesh.receiveShadow = true; - terrainMesh.castShadow = true; + var controls = new THREE.OrbitControls( camera ); - scene.add( terrainMesh ); + var geometry = new THREE.PlaneBufferGeometry( terrainWidthExtents, terrainDepthExtents, terrainWidth - 1, terrainDepth - 1 ); + geometry.rotateX( - Math.PI / 2 ); - var textureLoader = new THREE.TextureLoader(); - textureLoader.load("textures/grid.png", function ( texture ) { - texture.wrapS = THREE.RepeatWrapping; - texture.wrapT = THREE.RepeatWrapping; - texture.repeat.set( terrainWidth - 1, terrainDepth - 1 ); - groundMaterial.map = texture; - groundMaterial.needsUpdate = true; + var vertices = geometry.attributes.position.array; - }); + for ( var i = 0, j = 0, l = vertices.length; i < l; i ++, j += 3 ) { - var light = new THREE.DirectionalLight( 0xffffff, 1 ); - light.position.set( 100, 100, 50 ); - light.castShadow = true; - var dLight = 200; - var sLight = dLight * 0.25; - light.shadow.camera.left = -sLight; - light.shadow.camera.right = sLight; - light.shadow.camera.top = sLight; - light.shadow.camera.bottom = -sLight; + // j + 1 because it is the y component that we modify + vertices[ j + 1 ] = heightData[ i ]; - light.shadow.camera.near = dLight / 30; - light.shadow.camera.far = dLight; + } - light.shadow.mapSize.x = 1024 * 2; - light.shadow.mapSize.y = 1024 * 2; + geometry.computeVertexNormals(); - scene.add(light); + var groundMaterial = new THREE.MeshPhongMaterial( { color: 0xC7C7C7 } ); + terrainMesh = new THREE.Mesh( geometry, groundMaterial ); + terrainMesh.receiveShadow = true; + terrainMesh.castShadow = true; + scene.add( terrainMesh ); - window.addEventListener( 'resize', onWindowResize, false ); + var textureLoader = new THREE.TextureLoader(); + textureLoader.load( "textures/grid.png", function ( texture ) { - } + texture.wrapS = THREE.RepeatWrapping; + texture.wrapT = THREE.RepeatWrapping; + texture.repeat.set( terrainWidth - 1, terrainDepth - 1 ); + groundMaterial.map = texture; + groundMaterial.needsUpdate = true; - function onWindowResize() { + } ); - camera.aspect = window.innerWidth / window.innerHeight; - camera.updateProjectionMatrix(); + var light = new THREE.DirectionalLight( 0xffffff, 1 ); + light.position.set( 100, 100, 50 ); + light.castShadow = true; + var dLight = 200; + var sLight = dLight * 0.25; + light.shadow.camera.left = - sLight; + light.shadow.camera.right = sLight; + light.shadow.camera.top = sLight; + light.shadow.camera.bottom = - sLight; - renderer.setSize( window.innerWidth, window.innerHeight ); + light.shadow.camera.near = dLight / 30; + light.shadow.camera.far = dLight; - } + light.shadow.mapSize.x = 1024 * 2; + light.shadow.mapSize.y = 1024 * 2; - function initPhysics() { + scene.add( light ); - // Physics configuration - collisionConfiguration = new Ammo.btDefaultCollisionConfiguration(); - dispatcher = new Ammo.btCollisionDispatcher( collisionConfiguration ); - broadphase = new Ammo.btDbvtBroadphase(); - solver = new Ammo.btSequentialImpulseConstraintSolver(); - physicsWorld = new Ammo.btDiscreteDynamicsWorld( dispatcher, broadphase, solver, collisionConfiguration ); - physicsWorld.setGravity( new Ammo.btVector3( 0, -6, 0 ) ); + window.addEventListener( 'resize', onWindowResize, false ); - // Create the terrain body + } - var groundShape = createTerrainShape(); - var groundTransform = new Ammo.btTransform(); - groundTransform.setIdentity(); - // Shifts the terrain, since bullet re-centers it on its bounding box. - groundTransform.setOrigin( new Ammo.btVector3( 0, ( terrainMaxHeight + terrainMinHeight ) / 2, 0 ) ); - var groundMass = 0; - var groundLocalInertia = new Ammo.btVector3( 0, 0, 0 ); - var groundMotionState = new Ammo.btDefaultMotionState( groundTransform ); - var groundBody = new Ammo.btRigidBody( new Ammo.btRigidBodyConstructionInfo( groundMass, groundMotionState, groundShape, groundLocalInertia ) ); - physicsWorld.addRigidBody( groundBody ); + function onWindowResize() { - } + camera.aspect = window.innerWidth / window.innerHeight; + camera.updateProjectionMatrix(); + + renderer.setSize( window.innerWidth, window.innerHeight ); + + } + + function initPhysics() { + + // Physics configuration + + collisionConfiguration = new Ammo.btDefaultCollisionConfiguration(); + dispatcher = new Ammo.btCollisionDispatcher( collisionConfiguration ); + broadphase = new Ammo.btDbvtBroadphase(); + solver = new Ammo.btSequentialImpulseConstraintSolver(); + physicsWorld = new Ammo.btDiscreteDynamicsWorld( dispatcher, broadphase, solver, collisionConfiguration ); + physicsWorld.setGravity( new Ammo.btVector3( 0, - 6, 0 ) ); + + // Create the terrain body - function generateHeight( width, depth, minHeight, maxHeight ) { + var groundShape = createTerrainShape(); + var groundTransform = new Ammo.btTransform(); + groundTransform.setIdentity(); + // Shifts the terrain, since bullet re-centers it on its bounding box. + groundTransform.setOrigin( new Ammo.btVector3( 0, ( terrainMaxHeight + terrainMinHeight ) / 2, 0 ) ); + var groundMass = 0; + var groundLocalInertia = new Ammo.btVector3( 0, 0, 0 ); + var groundMotionState = new Ammo.btDefaultMotionState( groundTransform ); + var groundBody = new Ammo.btRigidBody( new Ammo.btRigidBodyConstructionInfo( groundMass, groundMotionState, groundShape, groundLocalInertia ) ); + physicsWorld.addRigidBody( groundBody ); - // Generates the height data (a sinus wave) + } - var size = width * depth; - var data = new Float32Array(size); + function generateHeight( width, depth, minHeight, maxHeight ) { - var hRange = maxHeight - minHeight; - var w2 = width / 2; - var d2 = depth / 2; - var phaseMult = 12; + // Generates the height data (a sinus wave) - var p = 0; - for ( var j = 0; j < depth; j++ ) { - for ( var i = 0; i < width; i++ ) { + var size = width * depth; + var data = new Float32Array( size ); - var radius = Math.sqrt( - Math.pow( ( i - w2 ) / w2, 2.0 ) + - Math.pow( ( j - d2 ) / d2, 2.0 ) ); + var hRange = maxHeight - minHeight; + var w2 = width / 2; + var d2 = depth / 2; + var phaseMult = 12; - var height = ( Math.sin( radius * phaseMult ) + 1 ) * 0.5 * hRange + minHeight; + var p = 0; + for ( var j = 0; j < depth; j ++ ) { - data[ p ] = height; + for ( var i = 0; i < width; i ++ ) { - p++; - } - } + var radius = Math.sqrt( + Math.pow( ( i - w2 ) / w2, 2.0 ) + + Math.pow( ( j - d2 ) / d2, 2.0 ) ); - return data; + var height = ( Math.sin( radius * phaseMult ) + 1 ) * 0.5 * hRange + minHeight; + + data[ p ] = height; + + p ++; } - function createTerrainShape() { + } - // This parameter is not really used, since we are using PHY_FLOAT height data type and hence it is ignored - var heightScale = 1; + return data; - // Up axis = 0 for X, 1 for Y, 2 for Z. Normally 1 = Y is used. - var upAxis = 1; + } - // hdt, height data type. "PHY_FLOAT" is used. Possible values are "PHY_FLOAT", "PHY_UCHAR", "PHY_SHORT" - var hdt = "PHY_FLOAT"; + function createTerrainShape() { - // Set this to your needs (inverts the triangles) - var flipQuadEdges = false; + // This parameter is not really used, since we are using PHY_FLOAT height data type and hence it is ignored + var heightScale = 1; - // Creates height data buffer in Ammo heap - ammoHeightData = Ammo._malloc(4 * terrainWidth * terrainDepth); + // Up axis = 0 for X, 1 for Y, 2 for Z. Normally 1 = Y is used. + var upAxis = 1; - // Copy the javascript height data array to the Ammo one. - var p = 0; - var p2 = 0; - for ( var j = 0; j < terrainDepth; j++ ) { - for ( var i = 0; i < terrainWidth; i++ ) { + // hdt, height data type. "PHY_FLOAT" is used. Possible values are "PHY_FLOAT", "PHY_UCHAR", "PHY_SHORT" + var hdt = "PHY_FLOAT"; - // write 32-bit float data to memory - Ammo.HEAPF32[ ammoHeightData + p2 >> 2 ] = heightData[ p ]; + // Set this to your needs (inverts the triangles) + var flipQuadEdges = false; - p++; + // Creates height data buffer in Ammo heap + ammoHeightData = Ammo._malloc( 4 * terrainWidth * terrainDepth ); - // 4 bytes/float - p2 += 4; - } - } + // Copy the javascript height data array to the Ammo one. + var p = 0; + var p2 = 0; + for ( var j = 0; j < terrainDepth; j ++ ) { - // Creates the heightfield physics shape - var heightFieldShape = new Ammo.btHeightfieldTerrainShape( - terrainWidth, - terrainDepth, - ammoHeightData, - heightScale, - terrainMinHeight, - terrainMaxHeight, - upAxis, - hdt, - flipQuadEdges - ); + for ( var i = 0; i < terrainWidth; i ++ ) { - // Set horizontal scale - var scaleX = terrainWidthExtents / ( terrainWidth - 1 ); - var scaleZ = terrainDepthExtents / ( terrainDepth - 1 ); - heightFieldShape.setLocalScaling( new Ammo.btVector3( scaleX, 1, scaleZ ) ); + // write 32-bit float data to memory + Ammo.HEAPF32[ ammoHeightData + p2 >> 2 ] = heightData[ p ]; - heightFieldShape.setMargin( 0.05 ); + p ++; - return heightFieldShape; + // 4 bytes/float + p2 += 4; } - function generateObject() { - - var numTypes = 4; - var objectType = Math.ceil( Math.random() * numTypes ); - - var threeObject = null; - var shape = null; - - var objectSize = 3; - var margin = 0.05; - - switch (objectType) { - case 1: - // Sphere - var radius = 1 + Math.random() * objectSize; - threeObject = new THREE.Mesh( new THREE.SphereBufferGeometry( radius, 20, 20 ), createObjectMaterial() ); - shape = new Ammo.btSphereShape( radius ); - shape.setMargin( margin ); - break; - case 2: - // Box - var sx = 1 + Math.random() * objectSize; - var sy = 1 + Math.random() * objectSize; - var sz = 1 + Math.random() * objectSize; - threeObject = new THREE.Mesh( new THREE.BoxBufferGeometry( sx, sy, sz, 1, 1, 1 ), createObjectMaterial() ); - shape = new Ammo.btBoxShape( new Ammo.btVector3( sx * 0.5, sy * 0.5, sz * 0.5 ) ); - shape.setMargin( margin ); - break; - case 3: - // Cylinder - var radius = 1 + Math.random() * objectSize; - var height = 1 + Math.random() * objectSize; - threeObject = new THREE.Mesh( new THREE.CylinderBufferGeometry( radius, radius, height, 20, 1 ), createObjectMaterial() ); - shape = new Ammo.btCylinderShape( new Ammo.btVector3( radius, height * 0.5, radius ) ); - shape.setMargin(margin); - break; - default: - // Cone - var radius = 1 + Math.random() * objectSize; - var height = 2 + Math.random() * objectSize; - threeObject = new THREE.Mesh( new THREE.ConeBufferGeometry( radius, height, 20, 2 ), createObjectMaterial() ); - shape = new Ammo.btConeShape( radius, height ); - break; - } - - threeObject.position.set( ( Math.random() - 0.5 ) * terrainWidth * 0.6, terrainMaxHeight + objectSize + 2, ( Math.random() - 0.5 ) * terrainDepth * 0.6 ); - - var mass = objectSize * 5; - var localInertia = new Ammo.btVector3( 0, 0, 0 ); - shape.calculateLocalInertia( mass, localInertia ); - var transform = new Ammo.btTransform(); - transform.setIdentity(); - var pos = threeObject.position; - transform.setOrigin( new Ammo.btVector3( pos.x, pos.y, pos.z ) ); - var motionState = new Ammo.btDefaultMotionState( transform ); - var rbInfo = new Ammo.btRigidBodyConstructionInfo( mass, motionState, shape, localInertia ); - var body = new Ammo.btRigidBody( rbInfo ); - - threeObject.userData.physicsBody = body; - - threeObject.receiveShadow = true; - threeObject.castShadow = true; - - scene.add( threeObject ); - dynamicObjects.push( threeObject ); - - physicsWorld.addRigidBody( body ); + } + + // Creates the heightfield physics shape + var heightFieldShape = new Ammo.btHeightfieldTerrainShape( + terrainWidth, + terrainDepth, + ammoHeightData, + heightScale, + terrainMinHeight, + terrainMaxHeight, + upAxis, + hdt, + flipQuadEdges + ); + // Set horizontal scale + var scaleX = terrainWidthExtents / ( terrainWidth - 1 ); + var scaleZ = terrainDepthExtents / ( terrainDepth - 1 ); + heightFieldShape.setLocalScaling( new Ammo.btVector3( scaleX, 1, scaleZ ) ); + heightFieldShape.setMargin( 0.05 ); - } + return heightFieldShape; - function createObjectMaterial() { - var c = Math.floor( Math.random() * ( 1 << 24 ) ); - return new THREE.MeshPhongMaterial( { color: c } ); - } + } - function animate() { + function generateObject() { - requestAnimationFrame(animate); + var numTypes = 4; + var objectType = Math.ceil( Math.random() * numTypes ); - render(); - stats.update(); + var threeObject = null; + var shape = null; - } + var objectSize = 3; + var margin = 0.05; - function render() { + switch ( objectType ) { - var deltaTime = clock.getDelta(); + case 1: + // Sphere + var radius = 1 + Math.random() * objectSize; + threeObject = new THREE.Mesh( new THREE.SphereBufferGeometry( radius, 20, 20 ), createObjectMaterial() ); + shape = new Ammo.btSphereShape( radius ); + shape.setMargin( margin ); + break; + case 2: + // Box + var sx = 1 + Math.random() * objectSize; + var sy = 1 + Math.random() * objectSize; + var sz = 1 + Math.random() * objectSize; + threeObject = new THREE.Mesh( new THREE.BoxBufferGeometry( sx, sy, sz, 1, 1, 1 ), createObjectMaterial() ); + shape = new Ammo.btBoxShape( new Ammo.btVector3( sx * 0.5, sy * 0.5, sz * 0.5 ) ); + shape.setMargin( margin ); + break; + case 3: + // Cylinder + var radius = 1 + Math.random() * objectSize; + var height = 1 + Math.random() * objectSize; + threeObject = new THREE.Mesh( new THREE.CylinderBufferGeometry( radius, radius, height, 20, 1 ), createObjectMaterial() ); + shape = new Ammo.btCylinderShape( new Ammo.btVector3( radius, height * 0.5, radius ) ); + shape.setMargin( margin ); + break; + default: + // Cone + var radius = 1 + Math.random() * objectSize; + var height = 2 + Math.random() * objectSize; + threeObject = new THREE.Mesh( new THREE.ConeBufferGeometry( radius, height, 20, 2 ), createObjectMaterial() ); + shape = new Ammo.btConeShape( radius, height ); + break; - if ( dynamicObjects.length < maxNumObjects && time > timeNextSpawn ) { - generateObject(); - timeNextSpawn = time + objectTimePeriod; - } + } - updatePhysics( deltaTime ); + threeObject.position.set( ( Math.random() - 0.5 ) * terrainWidth * 0.6, terrainMaxHeight + objectSize + 2, ( Math.random() - 0.5 ) * terrainDepth * 0.6 ); - renderer.render( scene, camera ); + var mass = objectSize * 5; + var localInertia = new Ammo.btVector3( 0, 0, 0 ); + shape.calculateLocalInertia( mass, localInertia ); + var transform = new Ammo.btTransform(); + transform.setIdentity(); + var pos = threeObject.position; + transform.setOrigin( new Ammo.btVector3( pos.x, pos.y, pos.z ) ); + var motionState = new Ammo.btDefaultMotionState( transform ); + var rbInfo = new Ammo.btRigidBodyConstructionInfo( mass, motionState, shape, localInertia ); + var body = new Ammo.btRigidBody( rbInfo ); + + threeObject.userData.physicsBody = body; + + threeObject.receiveShadow = true; + threeObject.castShadow = true; + + scene.add( threeObject ); + dynamicObjects.push( threeObject ); + + physicsWorld.addRigidBody( body ); - time += deltaTime; - } - function updatePhysics( deltaTime ) { + } - physicsWorld.stepSimulation( deltaTime, 10 ); + function createObjectMaterial() { - // Update objects - for ( var i = 0, il = dynamicObjects.length; i < il; i++ ) { - var objThree = dynamicObjects[ i ]; - var objPhys = objThree.userData.physicsBody; - var ms = objPhys.getMotionState(); - if ( ms ) { + var c = Math.floor( Math.random() * ( 1 << 24 ) ); + return new THREE.MeshPhongMaterial( { color: c } ); - ms.getWorldTransform( transformAux1 ); - var p = transformAux1.getOrigin(); - var q = transformAux1.getRotation(); - objThree.position.set( p.x(), p.y(), p.z() ); - objThree.quaternion.set( q.x(), q.y(), q.z(), q.w() ); + } + + function animate() { + + requestAnimationFrame( animate ); + + render(); + stats.update(); + + } + + function render() { + + var deltaTime = clock.getDelta(); + + if ( dynamicObjects.length < maxNumObjects && time > timeNextSpawn ) { + + generateObject(); + timeNextSpawn = time + objectTimePeriod; + + } + + updatePhysics( deltaTime ); + + renderer.render( scene, camera ); + + time += deltaTime; + + } + + function updatePhysics( deltaTime ) { + + physicsWorld.stepSimulation( deltaTime, 10 ); + + // Update objects + for ( var i = 0, il = dynamicObjects.length; i < il; i ++ ) { + + var objThree = dynamicObjects[ i ]; + var objPhys = objThree.userData.physicsBody; + var ms = objPhys.getMotionState(); + if ( ms ) { + + ms.getWorldTransform( transformAux1 ); + var p = transformAux1.getOrigin(); + var q = transformAux1.getRotation(); + objThree.position.set( p.x(), p.y(), p.z() ); + objThree.quaternion.set( q.x(), q.y(), q.z(), q.w() ); - } - } } - </script> + } + + } + + </script> - </body> + </body> </html>
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_physics_volume.html
@@ -21,9 +21,7 @@ padding: 5px; } - a { - color: #a06851; - } + a { color: #a06851; } </style> </head> <body> @@ -38,17 +36,13 @@ <script> - // Detects webgl - if ( WEBGL.isWebGLAvailable() === false ) { document.body.appendChild( WEBGL.getWebGLErrorMessage() ); document.getElementById( 'container' ).innerHTML = ""; } - // - Global variables - - // Graphics variables var container, stats; var camera, controls, scene, renderer; @@ -62,24 +56,17 @@ var quat = new THREE.Quaternion(); // Physics variables - var gravityConstant = -9.8; + var gravityConstant = - 9.8; var physicsWorld; var rigidBodies = []; var softBodies = []; var margin = 0.05; var transformAux1 = new Ammo.btTransform(); var softBodyHelpers = new Ammo.btSoftBodyHelpers(); - var armMovement = 0; - - // - Main code - - init(); animate(); - - // - Functions - - function init() { initGraphics(); @@ -101,7 +88,7 @@ scene = new THREE.Scene(); scene.background = new THREE.Color( 0xbfd1e5 ); - camera.position.set( -7, 5, 8 ); + camera.position.set( - 7, 5, 8 ); controls = new THREE.OrbitControls( camera ); controls.target.set( 0, 2, 0 ); @@ -118,13 +105,13 @@ scene.add( ambientLight ); var light = new THREE.DirectionalLight( 0xffffff, 1 ); - light.position.set( -10, 10, 5 ); + light.position.set( - 10, 10, 5 ); light.castShadow = true; var d = 20; - light.shadow.camera.left = -d; + light.shadow.camera.left = - d; light.shadow.camera.right = d; light.shadow.camera.top = d; - light.shadow.camera.bottom = -d; + light.shadow.camera.bottom = - d; light.shadow.camera.near = 2; light.shadow.camera.far = 50; @@ -134,7 +121,6 @@ scene.add( light ); - container.innerHTML = ''; container.appendChild( renderer.domElement ); @@ -158,7 +144,7 @@ var broadphase = new Ammo.btDbvtBroadphase(); var solver = new Ammo.btSequentialImpulseConstraintSolver(); var softBodySolver = new Ammo.btDefaultSoftBodySolver(); - physicsWorld = new Ammo.btSoftRigidDynamicsWorld( dispatcher, broadphase, solver, collisionConfiguration, softBodySolver); + physicsWorld = new Ammo.btSoftRigidDynamicsWorld( dispatcher, broadphase, solver, collisionConfiguration, softBodySolver ); physicsWorld.setGravity( new Ammo.btVector3( 0, gravityConstant, 0 ) ); physicsWorld.getWorldInfo().set_m_gravity( new Ammo.btVector3( 0, gravityConstant, 0 ) ); @@ -172,14 +158,15 @@ var ground = createParalellepiped( 40, 1, 40, 0, pos, quat, new THREE.MeshPhongMaterial( { color: 0xFFFFFF } ) ); ground.castShadow = true; ground.receiveShadow = true; - textureLoader.load( "textures/grid.png", function( texture ) { + textureLoader.load( "textures/grid.png", function ( texture ) { + texture.wrapS = THREE.RepeatWrapping; texture.wrapT = THREE.RepeatWrapping; texture.repeat.set( 40, 40 ); ground.material.map = texture; ground.material.needsUpdate = true; - } ); + } ); // Create soft volumes var volumeMass = 15; @@ -226,7 +213,7 @@ var vertices = new Float32Array( numVertices * 3 ); var indices = new ( numFaces * 3 > 65535 ? Uint32Array : Uint16Array )( numFaces * 3 ); - for ( var i = 0; i < numVertices; i++ ) { + for ( var i = 0; i < numVertices; i ++ ) { var p = geometry.vertices[ i ]; @@ -238,7 +225,7 @@ } - for ( var i = 0; i < numFaces; i++ ) { + for ( var i = 0; i < numFaces; i ++ ) { var f = geometry.faces[ i ]; @@ -254,6 +241,7 @@ bufferGeom.addAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) ); return bufferGeom; + } function isEqual( x1, y1, z1, x2, y2, z2 ) { @@ -280,19 +268,21 @@ bufGeometry.ammoIndices = indices; bufGeometry.ammoIndexAssociation = []; - for ( var i = 0; i < numIdxVertices; i++ ) { + for ( var i = 0; i < numIdxVertices; i ++ ) { var association = []; bufGeometry.ammoIndexAssociation.push( association ); var i3 = i * 3; - for ( var j = 0; j < numVertices; j++ ) { + for ( var j = 0; j < numVertices; j ++ ) { var j3 = j * 3; - if ( isEqual( idxVertices[ i3 ], idxVertices[ i3 + 1 ], idxVertices[ i3 + 2 ], - vertices[ j3 ], vertices[ j3 + 1 ], vertices[ j3 + 2 ] ) ) { - association.push( j3 ); + if ( isEqual( idxVertices[ i3 ], idxVertices[ i3 + 1 ], idxVertices[ i3 + 2 ], + vertices[ j3 ], vertices[ j3 + 1 ], vertices[ j3 + 2 ] ) ) { + + association.push( j3 ); + } } @@ -311,19 +301,21 @@ volume.frustumCulled = false; scene.add( volume ); - textureLoader.load( "textures/colors.png", function( texture ) { - volume.material.map = texture; - volume.material.needsUpdate = true; + textureLoader.load( "textures/colors.png", function ( texture ) { + + volume.material.map = texture; + volume.material.needsUpdate = true; + } ); // Volume physic object var volumeSoftBody = softBodyHelpers.CreateFromTriMesh( - physicsWorld.getWorldInfo(), - bufferGeom.ammoVertices, - bufferGeom.ammoIndices, - bufferGeom.ammoIndices.length / 3, - true ); + physicsWorld.getWorldInfo(), + bufferGeom.ammoVertices, + bufferGeom.ammoIndices, + bufferGeom.ammoIndices.length / 3, + true ); var sbConfig = volumeSoftBody.get_m_cfg(); sbConfig.set_viterations( 40 ); @@ -344,7 +336,7 @@ volumeSoftBody.setTotalMass( mass, false ); Ammo.castObject( volumeSoftBody, Ammo.btCollisionObject ).getCollisionShape().setMargin( margin ); - physicsWorld.addSoftBody( volumeSoftBody, 1, -1 ); + physicsWorld.addSoftBody( volumeSoftBody, 1, - 1 ); volume.userData.physicsBody = volumeSoftBody; // Disable deactivation volumeSoftBody.setActivationState( 4 ); @@ -397,12 +389,13 @@ physicsWorld.addRigidBody( body ); - return body; + return body; + } function initInput() { - window.addEventListener( 'mousedown', function( event ) { + window.addEventListener( 'mousedown', function ( event ) { if ( ! clickRequest ) { @@ -486,7 +479,8 @@ physicsWorld.stepSimulation( deltaTime, 10 ); // Update soft volumes - for ( var i = 0, il = softBodies.length; i < il; i++ ) { + for ( var i = 0, il = softBodies.length; i < il; i ++ ) { + var volume = softBodies[ i ]; var geometry = volume.geometry; var softBody = volume.userData.physicsBody; @@ -509,17 +503,20 @@ var assocVertex = association[ j ]; - for ( var k = 0, kl = assocVertex.length; k < kl; k++ ) { + for ( var k = 0, kl = assocVertex.length; k < kl; k ++ ) { + var indexVertex = assocVertex[ k ]; volumePositions[ indexVertex ] = x; volumeNormals[ indexVertex ] = nx; - indexVertex++; + indexVertex ++; volumePositions[ indexVertex ] = y; volumeNormals[ indexVertex ] = ny; - indexVertex++; + indexVertex ++; volumePositions[ indexVertex ] = z; volumeNormals[ indexVertex ] = nz; + } + } geometry.attributes.position.needsUpdate = true; @@ -528,7 +525,8 @@ } // Update rigid bodies - for ( var i = 0, il = rigidBodies.length; i < il; i++ ) { + for ( var i = 0, il = rigidBodies.length; i < il; i ++ ) { + var objThree = rigidBodies[ i ]; var objPhys = objThree.userData.physicsBody; var ms = objPhys.getMotionState(); @@ -541,6 +539,7 @@ objThree.quaternion.set( q.x(), q.y(), q.z(), q.w() ); } + } }
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_points_billboards.html
@@ -106,7 +106,7 @@ var gui = new dat.GUI(); - gui.add( material, 'sizeAttenuation' ).onChange( function() { + gui.add( material, 'sizeAttenuation' ).onChange( function () { material.needsUpdate = true; @@ -155,6 +155,7 @@ mouseY = event.touches[ 0 ].pageY - windowHalfY; } + } function onDocumentTouchMove( event ) {
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_points_dynamic.html
@@ -76,6 +76,8 @@ function init() { + var container = document.querySelector( '#container' ); + camera = new THREE.PerspectiveCamera( 20, window.innerWidth / window.innerHeight, 1, 50000 ); camera.position.set( 0, 700, 7000 ); @@ -91,37 +93,37 @@ var positions = combineBuffer( object, 'position' ); - createMesh( positions, scene, 4.05, -500, -350, 600, 0xff7744 ); - createMesh( positions, scene, 4.05, 500, -350, 0, 0xff5522 ); - createMesh( positions, scene, 4.05, -250, -350, 1500, 0xff9922 ); - createMesh( positions, scene, 4.05, -250, -350, -1500, 0xff99ff ); + createMesh( positions, scene, 4.05, - 500, - 350, 600, 0xff7744 ); + createMesh( positions, scene, 4.05, 500, - 350, 0, 0xff5522 ); + createMesh( positions, scene, 4.05, - 250, - 350, 1500, 0xff9922 ); + createMesh( positions, scene, 4.05, - 250, - 350, - 1500, 0xff99ff ); } ); loader.load( 'models/obj/female02/female02.obj', function ( object ) { var positions = combineBuffer( object, 'position' ); - createMesh( positions, scene, 4.05, -1000, -350, 0, 0xffdd44 ); - createMesh( positions, scene, 4.05, 0, -350, 0, 0xffffff ); - createMesh( positions, scene, 4.05, 1000, -350, 400, 0xff4422 ); - createMesh( positions, scene, 4.05, 250, -350, 1500, 0xff9955 ); - createMesh( positions, scene, 4.05, 250, -350, 2500, 0xff77dd ); + createMesh( positions, scene, 4.05, - 1000, - 350, 0, 0xffdd44 ); + createMesh( positions, scene, 4.05, 0, - 350, 0, 0xffffff ); + createMesh( positions, scene, 4.05, 1000, - 350, 400, 0xff4422 ); + createMesh( positions, scene, 4.05, 250, - 350, 1500, 0xff9955 ); + createMesh( positions, scene, 4.05, 250, - 350, 2500, 0xff77dd ); } ); renderer = new THREE.WebGLRenderer(); renderer.setPixelRatio( window.devicePixelRatio ); - renderer.setSize( window.innerWidth,window.innerHeight ); + renderer.setSize( window.innerWidth, window.innerHeight ); renderer.autoClear = false; container.appendChild( renderer.domElement ); parent = new THREE.Object3D(); scene.add( parent ); var grid = new THREE.Points( new THREE.PlaneBufferGeometry( 15000, 15000, 64, 64 ), new THREE.PointsMaterial( { color: 0xff0000, size: 10 } ) ); - grid.position.y = -400; + grid.position.y = - 400; grid.rotation.x = - Math.PI / 2; parent.add( grid ); @@ -154,7 +156,7 @@ } - function onWindowResize( event ) { + function onWindowResize() { renderer.setSize( window.innerWidth, window.innerHeight ); @@ -186,7 +188,7 @@ } ); - var combined = new Float32Array(count); + var combined = new Float32Array( count ); let offset = 0; @@ -217,21 +219,21 @@ var clones = [ - [ 6000, 0, -4000 ], - [ 5000, 0, 0 ], - [ 1000, 0, 5000 ], - [ 1000, 0, -5000 ], - [ 4000, 0, 2000 ], - [ -4000, 0, 1000 ], - [ -5000, 0, -5000 ], + [ 6000, 0, - 4000 ], + [ 5000, 0, 0 ], + [ 1000, 0, 5000 ], + [ 1000, 0, - 5000 ], + [ 4000, 0, 2000 ], + [ - 4000, 0, 1000 ], + [ - 5000, 0, - 5000 ], [ 0, 0, 0 ] ]; for ( var i = 0; i < clones.length; i ++ ) { - var c = ( i < clones.length -1 ) ? 0x252525 : color; + var c = ( i < clones.length - 1 ) ? 0x252525 : color; mesh = new THREE.Points( geometry, new THREE.PointsMaterial( { size: 30, color: c } ) ); mesh.scale.x = mesh.scale.y = mesh.scale.z = scale; @@ -253,30 +255,30 @@ } - function animate () { + function animate() { requestAnimationFrame( animate ); render(); stats.update(); } - function render () { + function render() { var delta = 10 * clock.getDelta(); delta = delta < 2 ? delta : 2; - parent.rotation.y += -0.02 * delta; + parent.rotation.y += - 0.02 * delta; - for( var j = 0; j < clonemeshes.length; j ++ ) { + for ( var j = 0; j < clonemeshes.length; j ++ ) { var cm = clonemeshes[ j ]; - cm.mesh.rotation.y += -0.1 * delta * cm.speed; + cm.mesh.rotation.y += - 0.1 * delta * cm.speed; } - for( var j = 0; j < meshes.length; j ++ ) { + for ( var j = 0; j < meshes.length; j ++ ) { var data = meshes[ j ]; var positions = data.mesh.geometry.attributes.position; @@ -292,7 +294,7 @@ if ( data.direction === 0 ) { - data.direction = -1; + data.direction = - 1; } @@ -343,7 +345,7 @@ i, px - ( px - ix ) / dx * data.speed * delta * ( 0.85 - Math.random() ), py - ( py - iy ) / dy * data.speed * delta * ( 1 + Math.random() ), - pz - ( pz - iz ) / dz * data.speed * delta * ( 0.85 - Math.random() ), + pz - ( pz - iz ) / dz * data.speed * delta * ( 0.85 - Math.random() ) ); } else { @@ -379,7 +381,7 @@ if ( data.delay <= 0 ) { - data.direction = -1; + data.direction = - 1; data.speed = 15; data.verticesUp = 0; data.delay = 120;
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_points_sprites.html
@@ -92,23 +92,23 @@ geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) ); parameters = [ - [ [ 1.0, 0.2, 0.5 ], sprite2, 20 ], - [ [ 0.95, 0.1, 0.5 ], sprite3, 15 ], - [ [ 0.90, 0.05, 0.5 ], sprite1, 10 ], - [ [ 0.85, 0, 0.5 ], sprite5, 8 ], - [ [ 0.80, 0, 0.5 ], sprite4, 5 ] + [[ 1.0, 0.2, 0.5 ], sprite2, 20 ], + [[ 0.95, 0.1, 0.5 ], sprite3, 15 ], + [[ 0.90, 0.05, 0.5 ], sprite1, 10 ], + [[ 0.85, 0, 0.5 ], sprite5, 8 ], + [[ 0.80, 0, 0.5 ], sprite4, 5 ] ]; for ( var i = 0; i < parameters.length; i ++ ) { - var color = parameters[ i ][ 0 ]; + var color = parameters[ i ][ 0 ]; var sprite = parameters[ i ][ 1 ]; - var size = parameters[ i ][ 2 ]; + var size = parameters[ i ][ 2 ]; - materials[ i ] = new THREE.PointsMaterial( { size: size, map: sprite, blending: THREE.AdditiveBlending, depthTest: false, transparent : true } ); + materials[ i ] = new THREE.PointsMaterial( { size: size, map: sprite, blending: THREE.AdditiveBlending, depthTest: false, transparent: true } ); materials[ i ].color.setHSL( color[ 0 ], color[ 1 ], color[ 2 ] ); - var particles = new THREE.Points( geometry, materials[i] ); + var particles = new THREE.Points( geometry, materials[ i ] ); particles.rotation.x = Math.random() * 6; particles.rotation.y = Math.random() * 6; @@ -138,7 +138,7 @@ texture: true }; - gui.add( params, 'texture' ).onChange( function( value ) { + gui.add( params, 'texture' ).onChange( function ( value ) { for ( var i = 0; i < materials.length; i ++ ) { @@ -251,7 +251,6 @@ } - </script> </body> </html>
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_postprocessing_advanced.html
@@ -87,7 +87,7 @@ var halfWidth = width / 2; var halfHeight = height / 2; - var materialColor, material2D, quadBG, quadMask, renderScene; + var quadBG, quadMask, renderScene; var delta = 0.01; @@ -100,7 +100,7 @@ // - cameraOrtho = new THREE.OrthographicCamera( -halfWidth, halfWidth, halfHeight, -halfHeight, -10000, 10000 ); + cameraOrtho = new THREE.OrthographicCamera( - halfWidth, halfWidth, halfHeight, - halfHeight, - 10000, 10000 ); cameraOrtho.position.z = 100; cameraPerspective = new THREE.PerspectiveCamera( 50, width / height, 1, 10000 ); @@ -114,11 +114,11 @@ // directionalLight = new THREE.DirectionalLight( 0xffffff ); - directionalLight.position.set( 0, -0.1, 1 ).normalize(); + directionalLight.position.set( 0, - 0.1, 1 ).normalize(); sceneModel.add( directionalLight ); var loader = new THREE.GLTFLoader(); - loader.load( "models/gltf/LeePerrySmith/LeePerrySmith.glb", function( gltf ) { + loader.load( "models/gltf/LeePerrySmith/LeePerrySmith.glb", function ( gltf ) { createMesh( gltf.scene.children[ 0 ].geometry, sceneModel, 100 ); @@ -127,21 +127,21 @@ // var materialColor = new THREE.MeshBasicMaterial( { - map: new THREE.TextureLoader().load( "textures/cube/SwedishRoyalCastle/pz.jpg" ), + map: new THREE.TextureLoader().load( "textures/cube/SwedishRoyalCastle/pz.jpg" ), depthTest: false } ); quadBG = new THREE.Mesh( new THREE.PlaneBufferGeometry( 1, 1 ), materialColor ); - quadBG.position.z = -500; + quadBG.position.z = - 500; quadBG.scale.set( width, height, 1 ); sceneBG.add( quadBG ); // var sceneMask = new THREE.Scene(); - quadMask = new THREE.Mesh( new THREE.PlaneBufferGeometry( 1, 1 ), new THREE.MeshBasicMaterial( { color: 0xffaa00 } ) ); - quadMask.position.z = -300; + quadMask = new THREE.Mesh( new THREE.PlaneBufferGeometry( 1, 1 ), new THREE.MeshBasicMaterial( { color: 0xffaa00 } ) ); + quadMask.position.z = - 300; quadMask.scale.set( width / 2, height / 2, 1 ); sceneMask.add( quadMask ); @@ -164,19 +164,19 @@ // stats = new Stats(); - //container.appendChild( stats.dom ); + container.appendChild( stats.dom ); // var shaderBleach = THREE.BleachBypassShader; var shaderSepia = THREE.SepiaShader; var shaderVignette = THREE.VignetteShader; - var shaderCopy = THREE.CopyShader; + // var shaderCopy = THREE.CopyShader; var effectBleach = new THREE.ShaderPass( shaderBleach ); var effectSepia = new THREE.ShaderPass( shaderSepia ); var effectVignette = new THREE.ShaderPass( shaderVignette ); - var effectCopy = new THREE.ShaderPass( shaderCopy ); + // var effectCopy = new THREE.ShaderPass( shaderCopy ); effectBleach.uniforms[ "opacity" ].value = 0.95; @@ -222,7 +222,7 @@ stencilBuffer: true }; - var rtWidth = width / 2; + var rtWidth = width / 2; var rtHeight = height / 2; // @@ -292,28 +292,24 @@ //composer4.addPass( clearMask ); composer4.addPass( effectVignette ); - // - - //onWindowResize(); - renderScene.uniforms[ "tDiffuse" ].value = composerScene.renderTarget2.texture; window.addEventListener( 'resize', onWindowResize, false ); } - function onWindowResize( event ) { + function onWindowResize() { halfWidth = window.innerWidth / 2; halfHeight = window.innerHeight / 2; cameraPerspective.aspect = window.innerWidth / window.innerHeight; cameraPerspective.updateProjectionMatrix(); - cameraOrtho.left = -halfWidth; + cameraOrtho.left = - halfWidth; cameraOrtho.right = halfWidth; cameraOrtho.top = halfHeight; - cameraOrtho.bottom = -halfHeight; + cameraOrtho.bottom = - halfHeight; cameraOrtho.updateProjectionMatrix(); @@ -333,12 +329,6 @@ } - function getText( id ) { - - return document.getElementById( id ).textContent; - - } - function createMesh( geometry, scene, scale ) { var mat2 = new THREE.MeshPhongMaterial( { @@ -347,13 +337,13 @@ specular: 0x080808, shininess: 20, map: new THREE.TextureLoader().load( "models/gltf/LeePerrySmith/Map-COL.jpg" ), - normalMap: new THREE.TextureLoader().load("models/gltf/LeePerrySmith/Infinite-Level_02_Tangent_SmoothUV.jpg" ), + normalMap: new THREE.TextureLoader().load( "models/gltf/LeePerrySmith/Infinite-Level_02_Tangent_SmoothUV.jpg" ), normalScale: new THREE.Vector2( 0.75, 0.75 ) } ); mesh = new THREE.Mesh( geometry, mat2 ); - mesh.position.set( 0, -50, 0 ); + mesh.position.set( 0, - 50, 0 ); mesh.scale.set( scale, scale, scale ); scene.add( mesh ); @@ -376,7 +366,7 @@ var time = Date.now() * 0.0004; - if ( mesh ) mesh.rotation.y = -time; + if ( mesh ) mesh.rotation.y = - time; renderer.setViewport( 0, 0, halfWidth, halfHeight ); composerScene.render( delta );
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_postprocessing_afterimage.html
@@ -30,7 +30,7 @@ <script> var camera, scene, renderer, composer; - var mesh, light; + var mesh; var afterimagePass; @@ -57,7 +57,7 @@ scene = new THREE.Scene(); scene.fog = new THREE.Fog( 0x000000, 1, 1000 ); - var geometry = new THREE.BoxBufferGeometry( 150, 150, 150, 2, 2, 2); + var geometry = new THREE.BoxBufferGeometry( 150, 150, 150, 2, 2, 2 ); var material = new THREE.MeshNormalMaterial(); mesh = new THREE.Mesh( geometry, material ); scene.add( mesh ); @@ -75,7 +75,7 @@ } - function createGUI(){ + function createGUI() { var gui = new dat.GUI( { name: 'Damp setting' } ); gui.add( afterimagePass.uniforms[ "damp" ], 'value', 0, 1 ).step( 0.001 ); @@ -100,7 +100,7 @@ mesh.rotation.x += 0.005; mesh.rotation.y += 0.01; - if( params.enable ){ + if ( params.enable ) { composer.render();
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_postprocessing_backgrounds.html
@@ -56,7 +56,7 @@ var clearPass, texturePass, renderPass; var cameraP, cubeTexturePassP; //var cameraO, cubeTexturePassO; - var gui, stats, texture; + var gui, stats; var params = { @@ -131,13 +131,13 @@ cameraP = new THREE.PerspectiveCamera( 65, aspect, 1, 10 ); cameraP.position.z = 7; - // cameraO = new THREE.OrthographicCamera( width / - 2, width / 2, height / 2, height / - 2, 3, 10 ); - // cameraO.position.z = 7; + // cameraO = new THREE.OrthographicCamera( width / - 2, width / 2, height / 2, height / - 2, 3, 10 ); + // cameraO.position.z = 7; - // var fov = THREE.Math.degToRad( cameraP.fov ); - // var hyperfocus = ( cameraP.near + cameraP.far ) / 2; - // var _height = 2 * Math.tan( fov / 2 ) * hyperfocus; - // cameraO.zoom = height / _height; + // var fov = THREE.Math.degToRad( cameraP.fov ); + // var hyperfocus = ( cameraP.near + cameraP.far ) / 2; + // var _height = 2 * Math.tan( fov / 2 ) * hyperfocus; + // cameraO.zoom = height / _height; scene = new THREE.Scene(); @@ -146,20 +146,20 @@ var light = new THREE.PointLight( 0xddffdd, 1.0 ); light.position.z = 70; - light.position.y = -70; - light.position.x = -70; + light.position.y = - 70; + light.position.x = - 70; scene.add( light ); var light2 = new THREE.PointLight( 0xffdddd, 1.0 ); light2.position.z = 70; - light2.position.x = -70; + light2.position.x = - 70; light2.position.y = 70; scene.add( light2 ); var light3 = new THREE.PointLight( 0xddddff, 1.0 ); light3.position.z = 70; light3.position.x = 70; - light3.position.y = -70; + light3.position.y = - 70; scene.add( light3 ); var geometry = new THREE.SphereBufferGeometry( 1, 48, 24 ); @@ -174,12 +174,14 @@ // postprocessing - var genCubeUrls = function( prefix, postfix ) { + var genCubeUrls = function ( prefix, postfix ) { + return [ prefix + 'px' + postfix, prefix + 'nx' + postfix, prefix + 'py' + postfix, prefix + 'ny' + postfix, prefix + 'pz' + postfix, prefix + 'nz' + postfix ]; + }; composer = new THREE.EffectComposer( renderer ); @@ -191,18 +193,22 @@ composer.addPass( texturePass ); var textureLoader = new THREE.TextureLoader(); - textureLoader.load( "textures/hardwood2_diffuse.jpg", function( map ) { + textureLoader.load( "textures/hardwood2_diffuse.jpg", function ( map ) { + texturePass.map = map; - }); + + } ); cubeTexturePassP = new THREE.CubeTexturePass( cameraP ); composer.addPass( cubeTexturePassP ); var ldrUrls = genCubeUrls( "textures/cube/pisa/", ".png" ); new THREE.CubeTextureLoader().load( ldrUrls, function ( ldrCubeMap ) { + cubeTexturePassP.envMap = ldrCubeMap; - console.log( "loaded envmap"); - }); + console.log( "loaded envmap" ); + + } ); renderPass = new THREE.RenderPass( scene, cameraP ); renderPass.clear = false; @@ -236,7 +242,7 @@ renderer.setSize( width, height ); var pixelRatio = renderer.getPixelRatio(); - var newWidth = Math.floor( width / pixelRatio ) || 1; + var newWidth = Math.floor( width / pixelRatio ) || 1; var newHeight = Math.floor( height / pixelRatio ) || 1; composer.setSize( newWidth, newHeight ); @@ -251,12 +257,14 @@ cameraP.updateMatrixWorld( true ); var newColor = clearPass.clearColor; - switch( params.clearColor ) { + switch ( params.clearColor ) { + case 'blue': newColor = 0x0000ff; break; case 'red': newColor = 0xff0000; break; case 'green': newColor = 0x00ff00; break; case 'white': newColor = 0xffffff; break; case 'black': newColor = 0x000000; break; + } clearPass.enabled = params.clearPass;
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_postprocessing_crossfade.html
@@ -22,9 +22,7 @@ width: 100%; } - .info a { - color: #00ffff; - } + a { color: #00ffff; } </style> </head> <body> @@ -68,10 +66,10 @@ stats = new Stats(); container.appendChild( stats.dom ); - var sceneA = new Scene( "cube", 5000, 1200, 120, new THREE.Vector3(0,-0.4,0), 0xffffff ); - var sceneB = new Scene( "sphere", 500, 2000, 50, new THREE.Vector3(0,0.2,0.1), 0x000000 ); + var sceneA = new Scene( "cube", 5000, 1200, 120, new THREE.Vector3( 0, - 0.4, 0 ), 0xffffff ); + var sceneB = new Scene( "sphere", 500, 2000, 50, new THREE.Vector3( 0, 0.2, 0.1 ), 0x000000 ); - transition = new Transition(sceneA,sceneB); + transition = new Transition( sceneA, sceneB ); }
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_postprocessing_dof.html
@@ -16,9 +16,7 @@ text-align: center; } - a { - color: #0078ff; - } + a { color: #0078ff; } #info { color: #fff; @@ -67,7 +65,7 @@ var camera, scene, renderer, materials = [], objects = [], singleMaterial, zmaterial = [], - parameters, i, j, k, h, color, x, y, z, s, n, nobjects, cubeMaterial; + parameters, i, j, k, h, x, y, z, nobjects, cubeMaterial; var mouseX = 0, mouseY = 0; @@ -100,10 +98,10 @@ var path = "textures/cube/SwedishRoyalCastle/"; var format = '.jpg'; var urls = [ - path + 'px' + format, path + 'nx' + format, - path + 'py' + format, path + 'ny' + format, - path + 'pz' + format, path + 'nz' + format - ]; + path + 'px' + format, path + 'nx' + format, + path + 'py' + format, path + 'ny' + format, + path + 'pz' + format, path + 'nz' + format + ]; var textureCube = new THREE.CubeTextureLoader().load( urls ); @@ -112,7 +110,7 @@ singleMaterial = false; - if( singleMaterial ) zmaterial = [ cubeMaterial ]; + if ( singleMaterial ) zmaterial = [ cubeMaterial ]; var geo = new THREE.SphereBufferGeometry( 1, 20, 10 ); @@ -126,38 +124,38 @@ var count = 0; for ( i = 0; i < xgrid; i ++ ) - for ( j = 0; j < ygrid; j ++ ) - for ( k = 0; k < zgrid; k ++ ) { + for ( j = 0; j < ygrid; j ++ ) + for ( k = 0; k < zgrid; k ++ ) { - var mesh; + var mesh; - if ( singleMaterial ) { + if ( singleMaterial ) { - mesh = new THREE.Mesh( geo, zmaterial ); + mesh = new THREE.Mesh( geo, zmaterial ); - } else { + } else { - mesh = new THREE.Mesh( geo, new THREE.MeshBasicMaterial( parameters ) ); - materials[ count ] = mesh.material; + mesh = new THREE.Mesh( geo, new THREE.MeshBasicMaterial( parameters ) ); + materials[ count ] = mesh.material; - } + } - x = 200 * ( i - xgrid/2 ); - y = 200 * ( j - ygrid/2 ); - z = 200 * ( k - zgrid/2 ); + x = 200 * ( i - xgrid / 2 ); + y = 200 * ( j - ygrid / 2 ); + z = 200 * ( k - zgrid / 2 ); - mesh.position.set( x, y, z ); - mesh.scale.set( s, s, s ); + mesh.position.set( x, y, z ); + mesh.scale.set( s, s, s ); - mesh.matrixAutoUpdate = false; - mesh.updateMatrix(); + mesh.matrixAutoUpdate = false; + mesh.updateMatrix(); - scene.add( mesh ); - objects.push( mesh ); + scene.add( mesh ); + objects.push( mesh ); - count ++; + count ++; - } + } scene.matrixAutoUpdate = false; @@ -174,15 +172,15 @@ window.addEventListener( 'resize', onWindowResize, false ); - var effectController = { + var effectController = { - focus: 500.0, + focus: 500.0, aperture: 5, maxblur: 1.0 }; - var matChanger = function( ) { + var matChanger = function ( ) { postprocessing.bokeh.uniforms[ "focus" ].value = effectController.focus; postprocessing.bokeh.uniforms[ "aperture" ].value = effectController.aperture * 0.00001; @@ -197,6 +195,7 @@ gui.close(); matChanger(); + } function onDocumentMouseMove( event ) { @@ -216,6 +215,7 @@ mouseY = event.touches[ 0 ].pageY - windowHalfY; } + } function onDocumentTouchMove( event ) { @@ -248,10 +248,11 @@ } function initPostprocessing() { + var renderPass = new THREE.RenderPass( scene, camera ); var bokehPass = new THREE.BokehPass( scene, camera, { - focus: 1.0, + focus: 1.0, aperture: 0.025, maxblur: 1.0, @@ -286,13 +287,13 @@ var time = Date.now() * 0.00005; camera.position.x += ( mouseX - camera.position.x ) * 0.036; - camera.position.y += ( - (mouseY) - camera.position.y ) * 0.036; + camera.position.y += ( - ( mouseY ) - camera.position.y ) * 0.036; camera.lookAt( scene.position ); - if ( !singleMaterial ) { + if ( ! singleMaterial ) { - for( i = 0; i < nobjects; i ++ ) { + for ( i = 0; i < nobjects; i ++ ) { h = ( 360 * ( i / nobjects + time ) % 360 ) / 360; materials[ i ].color.setHSL( h, 1, 0.5 );
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_postprocessing_dof2.html
@@ -16,9 +16,7 @@ text-align:center; } - a { - color:#0078ff; - } + a { color:#0078ff; } #info { color:#fff; @@ -31,10 +29,10 @@ } </style> </head> -<!-- TODO -Setup Number Focus Test Plates -Use WEBGL Depth buffer support? ---> + <!-- TODO + Setup Number Focus Test Plates + Use WEBGL Depth buffer support? + --> <body> <script src="../build/three.js"></script> <script src="js/shaders/BokehShader2.js"></script> @@ -62,14 +60,13 @@ var windowHalfX = window.innerWidth / 2; var windowHalfY = window.innerHeight / 2; - var postprocessing = { enabled : true }; + var postprocessing = { enabled: true }; var shaderSettings = { rings: 3, samples: 4 }; - var singleMaterial = false; var mouse = new THREE.Vector2(); var raycaster = new THREE.Raycaster(); var distance = 100; @@ -142,11 +139,11 @@ var planePiece = new THREE.PlaneBufferGeometry( 10, 10, 1, 1 ); var planeMat = new THREE.MeshPhongMaterial( { - color: 0xffffff * 0.4, - shininess: 0.5, - specular: 0xffffff, - envMap: textureCube, - side: THREE.DoubleSide + color: 0xffffff * 0.4, + shininess: 0.5, + specular: 0xffffff, + envMap: textureCube, + side: THREE.DoubleSide } ); var rand = Math.random; @@ -160,8 +157,8 @@ plane.rotation.dz = rand() * 0.1; plane.position.set( rand() * 150, 0 + rand() * 300, rand() * 150 ); - plane.position.dx = (rand() - 0.5 ); - plane.position.dz = (rand() - 0.5 ); + plane.position.dx = ( rand() - 0.5 ); + plane.position.dz = ( rand() - 0.5 ); scene.add( plane ); planes.push( plane ); @@ -180,7 +177,7 @@ shininess: 50, reflectivity: 1.0, flatShading: true - }); + } ); var monkeys = 20; @@ -211,14 +208,14 @@ var ballmaterial = new THREE.MeshPhongMaterial( { color: 0xffffff * Math.random(), shininess: 0.5, - specular: 0xffffff , + specular: 0xffffff, envMap: textureCube } ); var mesh = new THREE.Mesh( geometry, ballmaterial ); mesh.position.x = ( Math.random() - 0.5 ) * 200; mesh.position.y = Math.random() * 50; - mesh.position.z = ( Math.random() - 0.5 ) * 200; + mesh.position.z = ( Math.random() - 0.5 ) * 200; mesh.scale.multiplyScalar( 10 ); scene.add( mesh ); @@ -233,7 +230,7 @@ scene.add( directionalLight ); var directionalLight = new THREE.DirectionalLight( 0xffffff, 1 ); - directionalLight.position.set( - 2, 1.2, -10 ).normalize(); + directionalLight.position.set( - 2, 1.2, - 10 ).normalize(); scene.add( directionalLight ); initPostprocessing(); @@ -245,7 +242,7 @@ document.addEventListener( 'touchstart', onDocumentTouchStart, false ); document.addEventListener( 'touchmove', onDocumentTouchMove, false ); - effectController = { + effectController = { enabled: true, jsDepthCalculation: true, @@ -273,7 +270,7 @@ }; - var matChanger = function() { + var matChanger = function () { for ( var e in effectController ) { @@ -288,7 +285,7 @@ postprocessing.enabled = effectController.enabled; postprocessing.bokeh_uniforms[ 'znear' ].value = camera.near; postprocessing.bokeh_uniforms[ 'zfar' ].value = camera.far; - camera.setFocalLength(effectController.focalLength); + camera.setFocalLength( effectController.focalLength ); }; @@ -310,7 +307,7 @@ gui.add( effectController, 'threshold', 0, 1, 0.001 ).onChange( matChanger ); gui.add( effectController, 'gain', 0, 100, 0.001 ).onChange( matChanger ); - gui.add( effectController, 'bias', 0,3, 0.001 ).onChange( matChanger ); + gui.add( effectController, 'bias', 0, 3, 0.001 ).onChange( matChanger ); gui.add( effectController, 'fringe', 0, 5, 0.001 ).onChange( matChanger ); gui.add( effectController, 'focalLength', 16, 80, 0.001 ).onChange( matChanger ); @@ -321,8 +318,8 @@ gui.add( effectController, 'pentagon' ).onChange( matChanger ); - gui.add( shaderSettings, 'rings', 1, 8).step(1).onChange( shaderUpdate ); - gui.add( shaderSettings, 'samples', 1, 13).step(1).onChange( shaderUpdate ); + gui.add( shaderSettings, 'rings', 1, 8 ).step( 1 ).onChange( shaderUpdate ); + gui.add( shaderSettings, 'samples', 1, 13 ).step( 1 ).onChange( shaderUpdate ); matChanger(); @@ -358,6 +355,7 @@ mouse.y = - ( event.touches[ 0 ].pageY - windowHalfY ) / windowHalfY; } + } function onDocumentTouchMove( event ) { @@ -377,7 +375,7 @@ postprocessing.scene = new THREE.Scene(); - postprocessing.camera = new THREE.OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, -10000, 10000 ); + postprocessing.camera = new THREE.OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, - 10000, 10000 ); postprocessing.camera.position.z = 100; postprocessing.scene.add( postprocessing.camera ); @@ -438,7 +436,6 @@ } - function smoothstep( near, far, depth ) { var x = saturate( ( depth - near ) / ( far - near ) ); @@ -475,15 +472,15 @@ var targetDistance = intersects[ 0 ].distance; - distance += (targetDistance - distance) * 0.03; + distance += ( targetDistance - distance ) * 0.03; - var sdistance = smoothstep(camera.near, camera.far, distance); + var sdistance = smoothstep( camera.near, camera.far, distance ); - var ldistance = linearize(1 - sdistance); + var ldistance = linearize( 1 - sdistance ); postprocessing.bokeh_uniforms[ 'focalDepth' ].value = ldistance; - effectController['focalDepth'] = ldistance; + effectController[ 'focalDepth' ] = ldistance; } @@ -534,7 +531,6 @@ } - </script> </body> </html>
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_postprocessing_fxaa.html
@@ -55,6 +55,7 @@ var loader = new THREE.TextureLoader(); loader.load( "textures/fxaa_scene.png", function onLoad( texture ) { + var image = texture.image; texture.minFilter = THREE.LinearFilter; texture.magFilter = THREE.LinearFilter; @@ -75,7 +76,7 @@ scene1.add( quad1 ); scene2.add( quad2 ); - var camera = new THREE.OrthographicCamera( -0.5, 0.5, 0.5, -0.5, -0.5, 0.5 ); + var camera = new THREE.OrthographicCamera( - 0.5, 0.5, 0.5, - 0.5, - 0.5, 0.5 ); var container = document.getElementById( 'container' ); @@ -92,8 +93,10 @@ renderer1.render( scene1, camera ); renderer2.render( scene2, camera ); - }); - })(); + + } ); + + } )(); </script> </body>
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_postprocessing_glitch.html
@@ -21,9 +21,7 @@ width: 100%; } - label, input { - cursor: pointer; - } + input { cursor: pointer; } </style> </head> <body> @@ -54,8 +52,10 @@ animate(); function updateOptions() { - var wildGlitch = document.getElementById('wildGlitch'); - glitchPass.goWild=wildGlitch.checked; + + var wildGlitch = document.getElementById( 'wildGlitch' ); + glitchPass.goWild = wildGlitch.checked; + } function init() {
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_postprocessing_godrays.html
@@ -16,9 +16,7 @@ text-align:center; } - a { - color:#0078ff; - } + a { color:#0078ff; } #info { color:#fff; @@ -56,15 +54,15 @@ var sphereMesh; - var sunPosition = new THREE.Vector3( 0, 1000, -1000 ); + var sunPosition = new THREE.Vector3( 0, 1000, - 1000 ); var screenSpacePosition = new THREE.Vector3(); var mouseX = 0, mouseY = 0; var windowHalfX = window.innerWidth / 2; var windowHalfY = window.innerHeight / 2; - var postprocessing = { enabled : true }; + var postprocessing = { enabled: true }; var orbitRadius = 200; @@ -98,7 +96,7 @@ loader.load( 'models/obj/tree.obj', function ( object ) { object.material = materialScene; - object.position.set( 0, -150, -150 ); + object.position.set( 0, - 150, - 150 ); object.scale.multiplyScalar( 400 ); scene.add( object ); @@ -179,7 +177,7 @@ postprocessing.scene = new THREE.Scene(); - postprocessing.camera = new THREE.OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, -10000, 10000 ); + postprocessing.camera = new THREE.OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, - 10000, 10000 ); postprocessing.camera.position.z = 100; postprocessing.scene.add( postprocessing.camera ); @@ -255,7 +253,7 @@ new THREE.PlaneBufferGeometry( window.innerWidth, window.innerHeight ), postprocessing.materialGodraysGenerate ); - postprocessing.quad.position.z = -9900; + postprocessing.quad.position.z = - 9900; postprocessing.scene.add( postprocessing.quad ); } @@ -344,7 +342,7 @@ postprocessing.godrayMaskUniforms[ "tInput" ].value = postprocessing.rtTextureDepth.texture; postprocessing.scene.overrideMaterial = postprocessing.materialGodraysDepthMask; - renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTextureDepthMask ); + renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTextureDepthMask ); // -- Render god-rays -- @@ -364,7 +362,7 @@ // pass 1 - render into first ping-pong target var pass = 1.0; - var stepLen = filterLen * Math.pow( TAPS_PER_PASS, -pass ); + var stepLen = filterLen * Math.pow( TAPS_PER_PASS, - pass ); postprocessing.godrayGenUniforms[ "fStepSize" ].value = stepLen; postprocessing.godrayGenUniforms[ "tInput" ].value = postprocessing.rtTextureDepthMask.texture; @@ -376,27 +374,27 @@ // pass 2 - render into second ping-pong target pass = 2.0; - stepLen = filterLen * Math.pow( TAPS_PER_PASS, -pass ); + stepLen = filterLen * Math.pow( TAPS_PER_PASS, - pass ); postprocessing.godrayGenUniforms[ "fStepSize" ].value = stepLen; postprocessing.godrayGenUniforms[ "tInput" ].value = postprocessing.rtTextureGodRays2.texture; - renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTextureGodRays1 ); + renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTextureGodRays1 ); // pass 3 - 1st RT pass = 3.0; - stepLen = filterLen * Math.pow( TAPS_PER_PASS, -pass ); + stepLen = filterLen * Math.pow( TAPS_PER_PASS, - pass ); postprocessing.godrayGenUniforms[ "fStepSize" ].value = stepLen; postprocessing.godrayGenUniforms[ "tInput" ].value = postprocessing.rtTextureGodRays1.texture; - renderer.render( postprocessing.scene, postprocessing.camera , postprocessing.rtTextureGodRays2 ); + renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTextureGodRays2 ); // final pass - composite god-rays onto colors - postprocessing.godrayCombineUniforms["tColors"].value = postprocessing.rtTextureColors.texture; - postprocessing.godrayCombineUniforms["tGodRays"].value = postprocessing.rtTextureGodRays2.texture; + postprocessing.godrayCombineUniforms[ "tColors" ].value = postprocessing.rtTextureColors.texture; + postprocessing.godrayCombineUniforms[ "tGodRays" ].value = postprocessing.rtTextureGodRays2.texture; postprocessing.scene.overrideMaterial = postprocessing.materialGodraysCombine;
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_postprocessing_outline.html
@@ -126,13 +126,13 @@ var conf = new Configuration(); - var controllerVisible = gui.addColor( conf, 'visibleEdgeColor' ).onChange( function ( value ) { + gui.addColor( conf, 'visibleEdgeColor' ).onChange( function ( value ) { outlinePass.visibleEdgeColor.set( value ); } ); - var controllerHidden = gui.addColor( conf, 'hiddenEdgeColor' ).onChange( function ( value ) { + gui.addColor( conf, 'hiddenEdgeColor' ).onChange( function ( value ) { outlinePass.hiddenEdgeColor.set( value );
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_postprocessing_procedural.html
@@ -81,10 +81,9 @@ <script> - var camera, postCamera, postScene, renderer; + var postCamera, postScene, renderer; var postMaterial, noiseRandom1DMaterial, noiseRandom2DMaterial, noiseRandom3DMaterial, postQuad; - var gui, stats, texture; - var index = 0; + var stats; var params = { procedure: 'noiseRandom3D' }; @@ -114,24 +113,23 @@ // Setup post processing stage postCamera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); - noiseRandom1DMaterial = new THREE.ShaderMaterial({ + noiseRandom1DMaterial = new THREE.ShaderMaterial( { vertexShader: document.querySelector( '#procedural-vert' ).textContent.trim(), fragmentShader: document.querySelector( '#noiseRandom1D-frag' ).textContent.trim() - }); - noiseRandom2DMaterial = new THREE.ShaderMaterial({ + } ); + noiseRandom2DMaterial = new THREE.ShaderMaterial( { vertexShader: document.querySelector( '#procedural-vert' ).textContent.trim(), fragmentShader: document.querySelector( '#noiseRandom2D-frag' ).textContent.trim() - }); - noiseRandom3DMaterial = new THREE.ShaderMaterial({ + } ); + noiseRandom3DMaterial = new THREE.ShaderMaterial( { vertexShader: document.querySelector( '#procedural-vert' ).textContent.trim(), fragmentShader: document.querySelector( '#noiseRandom3D-frag' ).textContent.trim() - }); + } ); postMaterial = noiseRandom3DMaterial; var postPlane = new THREE.PlaneBufferGeometry( 2, 2 ); postQuad = new THREE.Mesh( postPlane, postMaterial ); postScene = new THREE.Scene(); - postScene.add(postQuad); - + postScene.add( postQuad ); window.addEventListener( 'resize', onWindowResize, false ); @@ -153,8 +151,6 @@ requestAnimationFrame( animate ); - index ++; - switch ( params.procedure ) { case 'noiseRandom1D': postMaterial = noiseRandom1DMaterial; break; @@ -165,7 +161,6 @@ postQuad.material = postMaterial; - // render post FX renderer.render( postScene, postCamera );
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_postprocessing_rgb_halftone.html
@@ -23,9 +23,7 @@ padding: 2px; } - .info a { - color: #00ffff; - } + a { color: #00ffff; } </style> </head> <body> @@ -103,24 +101,24 @@ "void main() {", - "vUV = uv;", - "vNormal = vec3( normal );", - "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + "vUV = uv;", + "vNormal = vec3( normal );", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", "}" - ].join("\n"), + ].join( "\n" ), fragmentShader: [ "varying vec2 vUV;", "varying vec3 vNormal;", "void main() {", - "vec4 c = vec4( abs( vNormal ) + vec3( vUV, 0.0 ), 0.0 );", - "gl_FragColor = c;", + "vec4 c = vec4( abs( vNormal ) + vec3( vUV, 0.0 ), 0.0 );", + "gl_FragColor = c;", "}" - ].join("\n") + ].join( "\n" ) } ); for ( var i = 0; i < 50; ++ i ) {
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_postprocessing_sao.html
@@ -15,9 +15,7 @@ font-weight: bold; } - a { - color:#00ff78; - } + a { color:#00ff78; } #info { color: #fff; @@ -62,24 +60,8 @@ var container, stats; var camera, scene, renderer; - var depthMaterial, saoMaterial, saoModulateMaterial, normalMaterial, vBlurMaterial, hBlurMaterial, copyMaterial; - var depthRenderTarget, normalRenderTarget, saoRenderTarget, beautyRenderTarget, blurIntermediateRenderTarget; - var composer, renderPass, saoPass, copyPass; + var composer, renderPass, saoPass; var group; - var params = { - output: 0, - saoBias: 0.5, - saoIntensity: 0.25, - saoScale: 1, - saoKernelRadius: 100, - saoMinResolution: 0, - saoBlur: true, - saoBlurRadius: 12, - saoBlurStdDev: 6, - saoBlurDepthCutoff: 0.01 - }; - var supportsDepthTextureExtension = false; - var isWebGL2 = false; init(); animate(); @@ -109,20 +91,20 @@ var light = new THREE.PointLight( 0xddffdd, 0.8 ); light.position.z = 70; - light.position.y = -70; - light.position.x = -70; + light.position.y = - 70; + light.position.x = - 70; scene.add( light ); var light2 = new THREE.PointLight( 0xffdddd, 0.8 ); light2.position.z = 70; - light2.position.x = -70; + light2.position.x = - 70; light2.position.y = 70; scene.add( light2 ); var light3 = new THREE.PointLight( 0xddddff, 0.8 ); light3.position.z = 70; light3.position.x = 70; - light3.position.y = -70; + light3.position.y = - 70; scene.add( light3 ); var light3 = new THREE.AmbientLight( 0xffffff, 0.05 ); @@ -168,7 +150,11 @@ 'SAO': THREE.SAOPass.OUTPUT.SAO, 'Depth': THREE.SAOPass.OUTPUT.Depth, 'Normal': THREE.SAOPass.OUTPUT.Normal - } ).onChange( function ( value ) { saoPass.params.output = parseInt( value ); } ); + } ).onChange( function ( value ) { + + saoPass.params.output = parseInt( value ); + + } ); gui.add( saoPass.params, 'saoBias', - 1, 1 ); gui.add( saoPass.params, 'saoIntensity', 0, 1 ); gui.add( saoPass.params, 'saoScale', 0, 10 );
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_postprocessing_smaa.html
@@ -36,7 +36,7 @@ init(); animate(); - function init( meshTexture ) { + function init() { var container = document.getElementById( "container" ); @@ -95,7 +95,7 @@ renderer.setSize( width, height ); var pixelRatio = renderer.getPixelRatio(); - var newWidth = Math.floor( width * pixelRatio ) || 1; + var newWidth = Math.floor( width * pixelRatio ) || 1; var newHeight = Math.floor( height * pixelRatio ) || 1; composer.setSize( newWidth, newHeight );
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_postprocessing_sobel.html
@@ -140,7 +140,7 @@ function onWindowResize() { - camera.aspect = window.innerWidth / window.innerHeight; + camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix(); renderer.setSize( window.innerWidth, window.innerHeight );
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_postprocessing_ssaa.html
@@ -53,7 +53,7 @@ <script> var camera, scene, renderer, composer, copyPass, ssaaRenderPass; - var gui, stats, texture; + var gui, stats; var param = { sampleLevel: 2 @@ -146,7 +146,7 @@ renderer.setSize( width, height ); var pixelRatio = renderer.getPixelRatio(); - var newWidth = Math.floor( width / pixelRatio ) || 1; + var newWidth = Math.floor( width / pixelRatio ) || 1; var newHeight = Math.floor( height / pixelRatio ) || 1; composer.setSize( newWidth, newHeight );
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_postprocessing_ssaa_unbiased.html
@@ -55,7 +55,7 @@ var scene, renderer, composer, copyPass; var cameraP, ssaaRenderPassP; var cameraO, ssaaRenderPassO; - var gui, stats, texture; + var gui, stats; var params = { sampleLevel: 4, @@ -134,20 +134,20 @@ var light = new THREE.PointLight( 0xddffdd, 1.0 ); light.position.z = 70; - light.position.y = -70; - light.position.x = -70; + light.position.y = - 70; + light.position.x = - 70; scene.add( light ); var light2 = new THREE.PointLight( 0xffdddd, 1.0 ); light2.position.z = 70; - light2.position.x = -70; + light2.position.x = - 70; light2.position.y = 70; scene.add( light2 ); var light3 = new THREE.PointLight( 0xddddff, 1.0 ); light3.position.z = 70; light3.position.x = 70; - light3.position.y = -70; + light3.position.y = - 70; scene.add( light3 ); var light3 = new THREE.AmbientLight( 0xffffff, 0.05 ); @@ -207,7 +207,7 @@ renderer.setSize( width, height ); var pixelRatio = renderer.getPixelRatio(); - var newWidth = Math.floor( width / pixelRatio ) || 1; + var newWidth = Math.floor( width / pixelRatio ) || 1; var newHeight = Math.floor( height / pixelRatio ) || 1; composer.setSize( newWidth, newHeight ); @@ -219,7 +219,8 @@ stats.begin(); - if( params.autoRotate ) { + if ( params.autoRotate ) { + for ( var i = 0; i < scene.children.length; i ++ ) { var child = scene.children[ i ]; @@ -228,15 +229,18 @@ child.rotation.y += 0.01; } + } var newColor = ssaaRenderPassP.clearColor; - switch( params.clearColor ) { + switch ( params.clearColor ) { + case 'blue': newColor = 0x0000ff; break; case 'red': newColor = 0xff0000; break; case 'green': newColor = 0x00ff00; break; case 'white': newColor = 0xffffff; break; case 'black': newColor = 0x000000; break; + } ssaaRenderPassP.clearColor = ssaaRenderPassO.clearColor = newColor; ssaaRenderPassP.clearAlpha = ssaaRenderPassO.clearAlpha = params.clearAlpha; @@ -248,7 +252,7 @@ ssaaRenderPassO.enabled = ( params.camera === 'orthographic' ); ssaaRenderPassP.renderToScreen = ssaaRenderPassO.renderToScreen = params.renderToScreen; - copyPass.enabled = !params.renderToScreen; + copyPass.enabled = ! params.renderToScreen; composer.render();
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_postprocessing_ssao.html
@@ -22,9 +22,7 @@ font-weight: bold; } - a { - color:#00ff78; - } + a { color:#00ff78; } #info { color: #fff; @@ -127,10 +125,26 @@ var gui = new dat.GUI(); gui.add( postprocessing, 'enabled' ); - gui.add( postprocessing, 'onlyAO', false ).onChange( function( value ) { ssaoPass.onlyAO = value; } ); - gui.add( postprocessing, 'radius' ).min( 0 ).max( 64 ).onChange( function( value ) { ssaoPass.radius = value; } ); - gui.add( postprocessing, 'aoClamp' ).min( 0 ).max( 1 ).onChange( function( value ) { ssaoPass.aoClamp = value; } ); - gui.add( postprocessing, 'lumInfluence' ).min( 0 ).max( 1 ).onChange( function( value ) { ssaoPass.lumInfluence = value; } ); + gui.add( postprocessing, 'onlyAO', false ).onChange( function ( value ) { + + ssaoPass.onlyAO = value; + + } ); + gui.add( postprocessing, 'radius' ).min( 0 ).max( 64 ).onChange( function ( value ) { + + ssaoPass.radius = value; + + } ); + gui.add( postprocessing, 'aoClamp' ).min( 0 ).max( 1 ).onChange( function ( value ) { + + ssaoPass.aoClamp = value; + + } ); + gui.add( postprocessing, 'lumInfluence' ).min( 0 ).max( 1 ).onChange( function ( value ) { + + ssaoPass.lumInfluence = value; + + } ); window.addEventListener( 'resize', onWindowResize, false ); @@ -152,7 +166,7 @@ ssaoPass.setSize( width, height ); var pixelRatio = renderer.getPixelRatio(); - var newWidth = Math.floor( width / pixelRatio ) || 1; + var newWidth = Math.floor( width / pixelRatio ) || 1; var newHeight = Math.floor( height / pixelRatio ) || 1; effectComposer.setSize( newWidth, newHeight );
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_postprocessing_taa.html
@@ -55,7 +55,7 @@ <script> var camera, scene, renderer, composer, copyPass, taaRenderPass, renderPass; - var gui, stats, texture; + var gui, stats; var index = 0; var param = { TAAEnabled: "1", TAASampleLevel: 0 }; @@ -74,9 +74,9 @@ gui.add( param, 'TAAEnabled', { 'Disabled': '0', 'Enabled': '1' - } ).onFinishChange( function() { + } ).onFinishChange( function () { - if( taaRenderPass ) { + if ( taaRenderPass ) { taaRenderPass.enabled = ( param.TAAEnabled === "1" ); renderPass.enabled = ( param.TAAEnabled !== "1" ); @@ -92,10 +92,12 @@ 'Level 3: 8 Samples': 3, 'Level 4: 16 Samples': 4, 'Level 5: 32 Samples': 5 - } ).onFinishChange( function() { + } ).onFinishChange( function () { + + if ( taaRenderPass ) { - if( taaRenderPass ) { taaRenderPass.sampleLevel = param.TAASampleLevel; + } } ); @@ -173,7 +175,7 @@ renderer.setSize( width, height ); var pixelRatio = renderer.getPixelRatio(); - var newWidth = Math.floor( width / pixelRatio ) || 1; + var newWidth = Math.floor( width / pixelRatio ) || 1; var newHeight = Math.floor( height / pixelRatio ) || 1; composer.setSize( newWidth, newHeight ); @@ -185,7 +187,8 @@ index ++; - if( Math.round( index / 200 ) % 2 === 0 ) { + if ( Math.round( index / 200 ) % 2 === 0 ) { + for ( var i = 0; i < scene.children.length; i ++ ) { var child = scene.children[ i ]; @@ -194,10 +197,12 @@ child.rotation.y += 0.01; } - if( taaRenderPass ) taaRenderPass.accumulate = false; - } - else { - if( taaRenderPass ) taaRenderPass.accumulate = true; + if ( taaRenderPass ) taaRenderPass.accumulate = false; + + } else { + + if ( taaRenderPass ) taaRenderPass.accumulate = true; + } composer.render();
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_raycast_texture.html
@@ -30,13 +30,9 @@ padding: 5px; } - .control { - margin-bottom: 3px; - } + .control { margin-bottom: 3px; } - input { - width: 50px; - } + input { width: 50px; } </style> </head> <body> @@ -88,7 +84,7 @@ var that = this; this._background = document.createElement( "img" ); - this._background.addEventListener( "load", function ( event ) { + this._background.addEventListener( "load", function () { that._canvas.width = that._background.naturalWidth; that._canvas.height = that._background.naturalHeight;
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_raymarching_reflect.html
@@ -266,6 +266,8 @@ var geometry, material, mesh; var stats; + var canvas = document.querySelector( '#canvas' ); + var config = { saveImage: function () {
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_rtt.html
@@ -22,9 +22,7 @@ padding: 5px; } - a { - color: #ffffff; - } + a { color: #ffffff; } </style> </head> @@ -114,7 +112,7 @@ camera = new THREE.PerspectiveCamera( 30, window.innerWidth / window.innerHeight, 1, 10000 ); camera.position.z = 100; - cameraRTT = new THREE.OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, -10000, 10000 ); + cameraRTT = new THREE.OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, - 10000, 10000 ); cameraRTT.position.z = 100; // @@ -128,7 +126,7 @@ sceneRTT.add( light ); light = new THREE.DirectionalLight( 0xffaaaa, 1.5 ); - light.position.set( 0, 0, -1 ).normalize(); + light.position.set( 0, 0, - 1 ).normalize(); sceneRTT.add( light ); rtTexture = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, { minFilter: THREE.LinearFilter, magFilter: THREE.NearestFilter, format: THREE.RGBFormat } ); @@ -154,7 +152,7 @@ var plane = new THREE.PlaneBufferGeometry( window.innerWidth, window.innerHeight ); quad = new THREE.Mesh( plane, material ); - quad.position.z = -100; + quad.position.z = - 100; sceneRTT.add( quad ); var geometry = new THREE.TorusBufferGeometry( 100, 25, 15, 30 ); @@ -173,16 +171,16 @@ sceneRTT.add( zmesh2 ); quad = new THREE.Mesh( plane, materialScreen ); - quad.position.z = -100; + quad.position.z = - 100; sceneScreen.add( quad ); var n = 5, geometry = new THREE.SphereBufferGeometry( 10, 64, 32 ), material2 = new THREE.MeshBasicMaterial( { color: 0xffffff, map: rtTexture.texture } ); - for( var j = 0; j < n; j ++ ) { + for ( var j = 0; j < n; j ++ ) { - for( var i = 0; i < n; i ++ ) { + for ( var i = 0; i < n; i ++ ) { var mesh = new THREE.Mesh( geometry, material2 ); @@ -248,7 +246,7 @@ if ( material.uniforms.time.value > 1 || material.uniforms.time.value < 0 ) { - delta *= -1; + delta *= - 1; }
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_sandbox.html
@@ -24,9 +24,7 @@ z-index:1000; } - a { - color: #ffffff; - } + a { color: #ffffff; } </style> </head> @@ -48,8 +46,6 @@ var camera, scene, renderer; - var mesh, zmesh, lightMesh, geometry; - var mouseX = 0, mouseY = 0; var windowHalfX = window.innerWidth / 2; @@ -123,7 +119,7 @@ } - renderer = new THREE.WebGLRenderer( { antialias : true } ); + renderer = new THREE.WebGLRenderer( { antialias: true } ); renderer.setPixelRatio( window.devicePixelRatio ); renderer.setSize( window.innerWidth, window.innerHeight ); container.appendChild( renderer.domElement ); @@ -172,9 +168,9 @@ y = x == 0 ? y + 1 : y; p = Math.floor( x ^ y ); - image.data[ i ] = ~~ p * r; - image.data[ i + 1 ] = ~~ p * g; - image.data[ i + 2 ] = ~~ p * b; + image.data[ i ] = ~ ~ p * r; + image.data[ i + 1 ] = ~ ~ p * g; + image.data[ i + 2 ] = ~ ~ p * b; image.data[ i + 3 ] = 255; } @@ -185,7 +181,7 @@ } - function onDocumentMouseMove(event) { + function onDocumentMouseMove( event ) { mouseX = ( event.clientX - windowHalfX ) * 10; mouseY = ( event.clientY - windowHalfY ) * 10;
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_shader.html
@@ -23,10 +23,7 @@ padding: 5px; } - a { - - color: #ffffff; - } + a { color: #ffffff; } </style> </head> @@ -143,7 +140,7 @@ } - function onWindowResize( event ) { + function onWindowResize() { renderer.setSize( window.innerWidth, window.innerHeight );
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_shader2.html
@@ -208,15 +208,15 @@ [ 'fragment_shader4', uniforms1 ] ]; - for( var i = 0; i < params.length; i++ ) { + for ( var i = 0; i < params.length; i ++ ) { var material = new THREE.ShaderMaterial( { uniforms: params[ i ][ 1 ], vertexShader: document.getElementById( 'vertexShader' ).textContent, fragmentShader: document.getElementById( params[ i ][ 0 ] ).textContent - } ); + } ); var mesh = new THREE.Mesh( geometry, material ); mesh.position.x = i - ( params.length - 1 ) / 2; @@ -238,7 +238,7 @@ } - function onWindowResize( event ) { + function onWindowResize() { camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix(); @@ -269,8 +269,8 @@ var object = scene.children[ i ]; - object.rotation.y += delta * 0.5 * ( i % 2 ? 1 : -1 ); - object.rotation.x += delta * 0.5 * ( i % 2 ? -1 : 1 ); + object.rotation.y += delta * 0.5 * ( i % 2 ? 1 : - 1 ); + object.rotation.x += delta * 0.5 * ( i % 2 ? - 1 : 1 ); }
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_shader_lava.html
@@ -23,10 +23,7 @@ padding: 5px; } - a { - - color: #ffffff; - } + a { color: #ffffff; } #webglmessage a { color:#da0 } </style> @@ -202,7 +199,7 @@ } - function onWindowResize( event ) { + function onWindowResize() { renderer.setSize( window.innerWidth, window.innerHeight );
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_shaders_ocean.html
@@ -90,13 +90,15 @@ textureWidth: 512, textureHeight: 512, waterNormals: new THREE.TextureLoader().load( 'textures/waternormals.jpg', function ( texture ) { + texture.wrapS = texture.wrapT = THREE.RepeatWrapping; - }), + + } ), alpha: 1.0, sunDirection: light.position.clone().normalize(), sunColor: 0xffffff, waterColor: 0x001e0f, - distortionScale: 3.7, + distortionScale: 3.7, fog: scene.fog !== undefined } );
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_shaders_ocean2.html
@@ -16,12 +16,11 @@ top: 10px; width: 100%; } - a { - color: #09f; - } - #type-status { - font-weight: bold; - } + + a { color: #09f; } + + #type-status { font-weight: bold; } + </style> </head> <body>
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_shaders_sky.html
@@ -27,9 +27,7 @@ } - a { - color: #fff; - } + a { color: #fff; } </style> </head> @@ -51,15 +49,12 @@ <script> - if ( WEBGL.isWebGLAvailable() === false ) { document.body.appendChild( WEBGL.getWebGLErrorMessage() ); } - var container; - var camera, controls, scene, renderer; var sky, sunSphere;
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_shaders_tonemapping.html
@@ -14,7 +14,6 @@ font-family:georgia; text-align:center; } - h1 { } a { color:skyblue; text-decoration:none } canvas { pointer-events:none; z-index:0; position:relative; } .label { background-color: black; position: absolute; z-index: 100; padding: 5px } @@ -72,7 +71,7 @@ var camera, scene, renderer, dynamicHdrEffectComposer, hdrEffectComposer, ldrEffectComposer; var cameraCube, sceneCube; var cameraBG, debugScene; - var adaptiveLuminanceMat, currentLuminanceRT, currentLuminanceMat, previousLuminanceMat; + var adaptiveLuminanceMat, currentLuminanceMat; var directionalLight; @@ -82,7 +81,6 @@ var windowHalfY = window.innerHeight / 2; var windowThirdX = window.innerWidth / 3; - var windowThirdY = window.innerHeight / 3; init(); animate(); @@ -112,7 +110,7 @@ camera.position.z = 800; cameraCube = new THREE.PerspectiveCamera( 70, windowThirdX / window.innerHeight, 1, 100000 ); - cameraBG = new THREE.OrthographicCamera( -windowHalfX, windowHalfX, windowHalfY, -windowHalfY, -10000, 10000 ); + cameraBG = new THREE.OrthographicCamera( - windowHalfX, windowHalfX, windowHalfY, - windowHalfY, - 10000, 10000 ); cameraBG.position.z = 100; orbitControls = new THREE.OrbitControls( camera, container ); @@ -149,16 +147,16 @@ "varying vec3 vViewPosition;", "varying vec3 vNormal;", "void main() {", - THREE.ShaderChunk[ "beginnormal_vertex" ], - THREE.ShaderChunk[ "defaultnormal_vertex" ], + THREE.ShaderChunk[ "beginnormal_vertex" ], + THREE.ShaderChunk[ "defaultnormal_vertex" ], - " vNormal = normalize( transformedNormal );", - "vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );", - "vViewPosition = -mvPosition.xyz;", - "gl_Position = projectionMatrix * mvPosition;", + " vNormal = normalize( transformedNormal );", + "vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );", + "vViewPosition = -mvPosition.xyz;", + "gl_Position = projectionMatrix * mvPosition;", "}" - ].join("\n"), + ].join( "\n" ), fragmentShader: [ @@ -168,33 +166,33 @@ THREE.ShaderChunk[ "lights_phong_pars_fragment" ], "void main() {", - "vec3 normal = normalize( -vNormal );", - "vec3 viewPosition = normalize( vViewPosition );", - "#if NUM_DIR_LIGHTS > 0", + "vec3 normal = normalize( -vNormal );", + "vec3 viewPosition = normalize( vViewPosition );", + "#if NUM_DIR_LIGHTS > 0", - "vec3 dirDiffuse = vec3( 0.0 );", + "vec3 dirDiffuse = vec3( 0.0 );", - "for( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {", + "for( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {", - "vec4 lDirection = viewMatrix * vec4( directionalLights[i].direction, 0.0 );", - "vec3 dirVector = normalize( lDirection.xyz );", - "float dotProduct = dot( viewPosition, dirVector );", - "dotProduct = 1.0 * max( dotProduct, 0.0 ) + (1.0 - max( -dot( normal, dirVector ), 0.0 ));", - "dotProduct *= dotProduct;", - "dirDiffuse += max( 0.5 * dotProduct, 0.0 ) * directionalLights[i].color;", - "}", - "#endif", + "vec4 lDirection = viewMatrix * vec4( directionalLights[i].direction, 0.0 );", + "vec3 dirVector = normalize( lDirection.xyz );", + "float dotProduct = dot( viewPosition, dirVector );", + "dotProduct = 1.0 * max( dotProduct, 0.0 ) + (1.0 - max( -dot( normal, dirVector ), 0.0 ));", + "dotProduct *= dotProduct;", + "dirDiffuse += max( 0.5 * dotProduct, 0.0 ) * directionalLights[i].color;", + "}", + "#endif", - //Fade out atmosphere at edge - "float viewDot = abs(dot( normal, viewPosition ));", - "viewDot = clamp( pow( viewDot + 0.6, 10.0 ), 0.0, 1.0);", + //Fade out atmosphere at edge + "float viewDot = abs(dot( normal, viewPosition ));", + "viewDot = clamp( pow( viewDot + 0.6, 10.0 ), 0.0, 1.0);", - "vec3 color = vec3( 0.05, 0.09, 0.13 ) * dirDiffuse;", - "gl_FragColor = vec4( color, viewDot );", + "vec3 color = vec3( 0.05, 0.09, 0.13 ) * dirDiffuse;", + "gl_FragColor = vec4( color, viewDot );", "}" - ].join("\n") + ].join( "\n" ) }; var earthAtmoMat = new THREE.ShaderMaterial( atmoShader ); @@ -206,43 +204,45 @@ var textureLoader = new THREE.TextureLoader(); - textureLoader.load( 'textures/planets/earth_atmos_4096.jpg', function( tex ) { + textureLoader.load( 'textures/planets/earth_atmos_4096.jpg', function ( tex ) { + earthMat.map = tex; earthMat.needsUpdate = true; - } ); - textureLoader.load( 'textures/planets/earth_specular_2048.jpg', function( tex ) { + + } ); + textureLoader.load( 'textures/planets/earth_specular_2048.jpg', function ( tex ) { + earthMat.specularMap = tex; earthMat.needsUpdate = true; - } ); + + } ); // var earthNormal = textureLoader.load( 'textures/planets/earth-new-normal-2048.jpg', function( tex ) { // earthMat.normalMap = tex; // earthMat.needsUpdate = true; // } ); + var earthLights = textureLoader.load( 'textures/planets/earth_lights_2048.png' ); + var earthLightsMat = new THREE.MeshBasicMaterial( { color: 0xffffff, blending: THREE.AdditiveBlending, transparent: true, - depthTest: false - } ); + depthTest: false, + map: earthLights, - var earthLights = textureLoader.load( 'textures/planets/earth_lights_2048.png', function( tex ) { - earthLightsMat.map = tex; - earthLightsMat.needsUpdate = true; } ); + var clouds = textureLoader.load( 'textures/planets/earth_clouds_2048.png' ); + var earthCloudsMat = new THREE.MeshLambertMaterial( { color: 0xffffff, blending: THREE.NormalBlending, transparent: true, - depthTest: false + depthTest: false, + map: clouds } ); - textureLoader.load( 'textures/planets/earth_clouds_2048.png', function( tex ) { - earthCloudsMat.map = tex; - earthCloudsMat.needsUpdate = true; - } ); var earthGeo = new THREE.SphereBufferGeometry( 600, 24, 24 ); var sphereMesh = new THREE.Mesh( earthGeo, earthMat ); @@ -262,11 +262,11 @@ // "attribute vec2 uv;", "varying vec2 vUv;", "void main() {", - "vUv = uv;", - "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", "}" - ].join("\n"); + ].join( "\n" ); var pBGShader = [ @@ -275,14 +275,14 @@ "void main() {", - "vec2 sampleUV = vUv;", - "vec4 color = texture2D( map, sampleUV, 0.0 );", + "vec2 sampleUV = vUv;", + "vec4 color = texture2D( map, sampleUV, 0.0 );", - "gl_FragColor = vec4( color.xyz, 1.0 );", + "gl_FragColor = vec4( color.xyz, 1.0 );", "}" - ].join("\n"); + ].join( "\n" ); // Skybox adaptiveLuminanceMat = new THREE.ShaderMaterial( { @@ -308,14 +308,14 @@ } ); var quadBG = new THREE.Mesh( new THREE.PlaneBufferGeometry( 0.1, 0.1 ), currentLuminanceMat ); - quadBG.position.z = -500; - quadBG.position.x = -window.innerWidth * 0.5 + window.innerWidth * 0.05; + quadBG.position.z = - 500; + quadBG.position.x = - window.innerWidth * 0.5 + window.innerWidth * 0.05; quadBG.scale.set( window.innerWidth, window.innerHeight, 1 ); debugScene.add( quadBG ); quadBG = new THREE.Mesh( new THREE.PlaneBufferGeometry( 0.1, 0.1 ), adaptiveLuminanceMat ); - quadBG.position.z = -500; - quadBG.position.x = -window.innerWidth * 0.5 + window.innerWidth * 0.15; + quadBG.position.z = - 500; + quadBG.position.x = - window.innerWidth * 0.5 + window.innerWidth * 0.15; quadBG.scale.set( window.innerWidth, window.innerHeight, 1 ); debugScene.add( quadBG ); @@ -346,9 +346,11 @@ var regularRenderTarget = new THREE.WebGLRenderTarget( windowThirdX, height, parameters ); ldrEffectComposer = new THREE.EffectComposer( renderer, regularRenderTarget ); - if ( renderer.extensions.get('OES_texture_half_float_linear') ) { + if ( renderer.extensions.get( 'OES_texture_half_float_linear' ) ) { + parameters.type = THREE.FloatType; - } + + } var hdrRenderTarget = new THREE.WebGLRenderTarget( windowThirdX, height, parameters ); dynamicHdrEffectComposer = new THREE.EffectComposer( renderer, hdrRenderTarget ); dynamicHdrEffectComposer.setSize( window.innerWidth, window.innerHeight ); @@ -391,7 +393,6 @@ // gammaPass.renderToScreen = true; // ldrEffectComposer.addPass( gammaPass ); - var gui = new dat.GUI(); // dynamicHdrGui.add( params, 'projection', { 'From cam to mesh': 'camera', 'Normal to mesh': 'normal' } ); @@ -421,7 +422,6 @@ windowHalfX = window.innerWidth / 2; windowHalfY = window.innerHeight / 2; windowThirdX = window.innerWidth / 3; - windowThirdY = window.innerHeight / 3; camera.aspect = windowThirdX / window.innerHeight; camera.updateProjectionMatrix(); @@ -437,10 +437,13 @@ requestAnimationFrame( animate ); if ( bloomPass ) { + bloomPass.copyUniforms[ "opacity" ].value = params.bloomAmount; + } if ( adaptToneMappingPass ) { + adaptToneMappingPass.setAdaptionRate( params.adaptionRate ); adaptiveLuminanceMat.uniforms.map.value = adaptToneMappingPass.luminanceRT; currentLuminanceMat.uniforms.map.value = adaptToneMappingPass.currentLuminanceRT; @@ -453,15 +456,20 @@ hdrToneMappingPass.setMaxLuminance( params.maxLuminance ); hdrToneMappingPass.setMiddleGrey( params.middleGrey ); if ( hdrToneMappingPass.setAverageLuminance ) { + hdrToneMappingPass.setAverageLuminance( params.avgLuminance ); + } ldrToneMappingPass.enabled = params.enabled; ldrToneMappingPass.setMaxLuminance( params.maxLuminance ); ldrToneMappingPass.setMiddleGrey( params.middleGrey ); if ( ldrToneMappingPass.setAverageLuminance ) { + ldrToneMappingPass.setAverageLuminance( params.avgLuminance ); + } + } directionalLight.intensity = params.sunLight;
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_shaders_vector.html
@@ -120,7 +120,7 @@ var vA = new THREE.Vector2(); var vB = new THREE.Vector2(); - function processShape( path, reverse ) { + function processShape( path ) { var pts = []; // bigger area (convex hull) var pts2 = []; // smaller area (full solid shapes) @@ -156,19 +156,19 @@ } else { - pts.push( curve.v2 ); - pts2.push( curve.v1 ); - pts2.push( curve.v2 ); + pts.push( curve.v2 ); + pts2.push( curve.v1 ); + pts2.push( curve.v2 ); } - var flip = wind ? 1 : - 1; - // if (reverse) flip *= -1; + var flip = wind ? 1 : - 1; + // if (reverse) flip *= -1; - invert.push( flip, flip, flip ); - beziers.push( curve.v0, curve.v1, curve.v2 ); + invert.push( flip, flip, flip ); + beziers.push( curve.v0, curve.v1, curve.v2 ); - } + } } @@ -239,7 +239,7 @@ for ( var i = 0; i < beziers.length; i += 3 ) { - uvs.push( 0, 0, 0.5, 0, 1, 1 ); + uvs.push( 0, 0, 0.5, 0, 1, 1 ); }
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_shading_physical.html
@@ -49,7 +49,7 @@ var camera, scene, renderer; - var mesh, geometry; + var mesh; var controls; @@ -67,7 +67,7 @@ shadowCameraNear: 750, shadowCameraFar: 4000, shadowCameraFov: 30, - shadowBias: -0.0002 + shadowBias: - 0.0002 }; @@ -145,7 +145,7 @@ addObject( torusGeometry, materialPhong, 0, 100, 0, 0 ); addObject( cubeGeometry, materialLambert, 350, 75, 300, 0 ); - mesh = addObject( sphereGeometry, materialPhongCube, 350, 100, -350, 0 ); + mesh = addObject( sphereGeometry, materialPhongCube, 350, 100, - 350, 0 ); mesh.add( cubeCamera ); function addObjectColor( geometry, color, x, y, z, ry ) { @@ -160,7 +160,7 @@ var tmpMesh = new THREE.Mesh( geometry, material ); - tmpMesh.material.color.offsetHSL( 0.1, -0.1, 0 ); + tmpMesh.material.color.offsetHSL( 0.1, - 0.1, 0 ); tmpMesh.position.set( x, y, z ); @@ -179,34 +179,34 @@ var midCube = new THREE.BoxBufferGeometry( 50, 200, 50 ); var smallCube = new THREE.BoxBufferGeometry( 100, 100, 100 ); - addObjectColor( bigCube, 0xff0000, -500, 250, 0, 0 ); - addObjectColor( smallCube, 0xff0000, -500, 50, -150, 0 ); + addObjectColor( bigCube, 0xff0000, - 500, 250, 0, 0 ); + addObjectColor( smallCube, 0xff0000, - 500, 50, - 150, 0 ); - addObjectColor( midCube, 0x00ff00, 500, 100, 0, 0 ); - addObjectColor( smallCube, 0x00ff00, 500, 50, -150, 0 ); + addObjectColor( midCube, 0x00ff00, 500, 100, 0, 0 ); + addObjectColor( smallCube, 0x00ff00, 500, 50, - 150, 0 ); - addObjectColor( midCube, 0x0000ff, 0, 100, -500, 0 ); - addObjectColor( smallCube, 0x0000ff, -150, 50, -500, 0 ); + addObjectColor( midCube, 0x0000ff, 0, 100, - 500, 0 ); + addObjectColor( smallCube, 0x0000ff, - 150, 50, - 500, 0 ); - addObjectColor( midCube, 0xff00ff, 0, 100, 500, 0 ); - addObjectColor( smallCube, 0xff00ff, -150, 50, 500, 0 ); + addObjectColor( midCube, 0xff00ff, 0, 100, 500, 0 ); + addObjectColor( smallCube, 0xff00ff, - 150, 50, 500, 0 ); - addObjectColor( new THREE.BoxBufferGeometry( 500, 10, 10 ), 0xffff00, 0, 600, 0, Math.PI/4 ); + addObjectColor( new THREE.BoxBufferGeometry( 500, 10, 10 ), 0xffff00, 0, 600, 0, Math.PI / 4 ); addObjectColor( new THREE.BoxBufferGeometry( 250, 10, 10 ), 0xffff00, 0, 600, 0, 0 ); - addObjectColor( new THREE.SphereBufferGeometry( 100, 32, 26 ), 0xffffff, -300, 100, 300, 0 ); + addObjectColor( new THREE.SphereBufferGeometry( 100, 32, 26 ), 0xffffff, - 300, 100, 300, 0 ); // MORPHS var loader = new THREE.GLTFLoader(); - loader.load( "models/gltf/SittingBox.glb", function( gltf ) { + loader.load( "models/gltf/SittingBox.glb", function ( gltf ) { var mesh = gltf.scene.children[ 0 ]; mixer = new THREE.AnimationMixer( mesh ); - mixer.clipAction( gltf.animations[0] ).setDuration( 10 ).play(); + mixer.clipAction( gltf.animations[ 0 ] ).setDuration( 10 ).play(); var s = 200; mesh.scale.set( s, s, s ); @@ -229,7 +229,7 @@ pointLight = new THREE.PointLight( 0xffaa00, 1, 5000 ); scene.add( pointLight ); - sunLight = new THREE.SpotLight( 0xffffff, 0.3, 0, Math.PI/2 ); + sunLight = new THREE.SpotLight( 0xffffff, 0.3, 0, Math.PI / 2 ); sunLight.position.set( 1000, 2000, 1000 ); sunLight.castShadow = true; @@ -297,49 +297,49 @@ var shadowGUI = gui.addFolder( "Shadow" ); - shadowGUI.add( shadowConfig, 'shadowCameraVisible' ).onChange( function() { + shadowGUI.add( shadowConfig, 'shadowCameraVisible' ).onChange( function () { shadowCameraHelper.visible = shadowConfig.shadowCameraVisible; - }); + } ); - shadowGUI.add( shadowConfig, 'shadowCameraNear', 1, 1500 ).onChange( function() { + shadowGUI.add( shadowConfig, 'shadowCameraNear', 1, 1500 ).onChange( function () { sunLight.shadow.camera.near = shadowConfig.shadowCameraNear; sunLight.shadow.camera.updateProjectionMatrix(); shadowCameraHelper.update(); - }); + } ); - shadowGUI.add( shadowConfig, 'shadowCameraFar', 1501, 5000 ).onChange( function() { + shadowGUI.add( shadowConfig, 'shadowCameraFar', 1501, 5000 ).onChange( function () { sunLight.shadow.camera.far = shadowConfig.shadowCameraFar; sunLight.shadow.camera.updateProjectionMatrix(); shadowCameraHelper.update(); - }); + } ); - shadowGUI.add( shadowConfig, 'shadowCameraFov', 1, 120 ).onChange( function() { + shadowGUI.add( shadowConfig, 'shadowCameraFov', 1, 120 ).onChange( function () { sunLight.shadow.camera.fov = shadowConfig.shadowCameraFov; sunLight.shadow.camera.updateProjectionMatrix(); shadowCameraHelper.update(); - }); + } ); - shadowGUI.add( shadowConfig, 'shadowBias', -0.01, 0.01 ).onChange( function() { + shadowGUI.add( shadowConfig, 'shadowBias', - 0.01, 0.01 ).onChange( function () { sunLight.shadow.bias = shadowConfig.shadowBias; - }); + } ); shadowGUI.open(); } // - function onWindowResize( event ) { + function onWindowResize() { camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix();
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_shadowmap.html
@@ -20,7 +20,12 @@ z-index: 100; display:block; } - #info a { color: #f00; font-weight: bold; text-decoration: underline; cursor: pointer } + a { + color: #f00; + font-weight: bold; + text-decoration: underline; + cursor: pointer + } </style> </head> @@ -53,8 +58,6 @@ var SHADOW_MAP_WIDTH = 2048, SHADOW_MAP_HEIGHT = 1024; - var HUD_MARGIN = 0.05; - var SCREEN_WIDTH = window.innerWidth; var SCREEN_HEIGHT = window.innerHeight; var FLOOR = - 250; @@ -168,7 +171,7 @@ } - function onKeyDown ( event ) { + function onKeyDown( event ) { switch ( event.keyCode ) { @@ -284,10 +287,10 @@ mesh.speed = speed; mixer.clipAction( clip, mesh ). - setDuration( duration ). - // to shift the playback out of phase: - startAt( - duration * Math.random() ). - play(); + setDuration( duration ). + // to shift the playback out of phase: + startAt( - duration * Math.random() ). + play(); mesh.position.set( x, y, z ); mesh.rotation.y = Math.PI / 2; @@ -303,7 +306,7 @@ var loader = new THREE.GLTFLoader(); - loader.load( "models/gltf/Horse.glb", function( gltf ) { + loader.load( "models/gltf/Horse.glb", function ( gltf ) { var mesh = gltf.scene.children[ 0 ]; @@ -319,7 +322,7 @@ } ); - loader.load( "models/gltf/Flamingo.glb", function( gltf ) { + loader.load( "models/gltf/Flamingo.glb", function ( gltf ) { var mesh = gltf.scene.children[ 0 ]; var clip = gltf.animations[ 0 ]; @@ -328,7 +331,7 @@ } ); - loader.load( "models/gltf/Stork.glb", function( gltf ) { + loader.load( "models/gltf/Stork.glb", function ( gltf ) { var mesh = gltf.scene.children[ 0 ]; var clip = gltf.animations[ 0 ]; @@ -337,7 +340,7 @@ } ); - loader.load( "models/gltf/Parrot.glb", function( gltf ) { + loader.load( "models/gltf/Parrot.glb", function ( gltf ) { var mesh = gltf.scene.children[ 0 ]; var clip = gltf.animations[ 0 ]; @@ -369,7 +372,7 @@ morph.position.x += morph.speed * delta; - if ( morph.position.x > 2000 ) { + if ( morph.position.x > 2000 ) { morph.position.x = - 1000 - Math.random() * 500;
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_shadowmap_performance.html
@@ -20,7 +20,11 @@ z-index: 100; display:block; } - #info a { color: #f00; font-weight: bold; text-decoration: underline; cursor: pointer } + a { color: #f00; + font-weight: bold; + text-decoration: underline; + cursor: pointer + } </style> </head> @@ -53,7 +57,7 @@ var SCREEN_WIDTH = window.innerWidth; var SCREEN_HEIGHT = window.innerHeight; - var FLOOR = -250; + var FLOOR = - 250; var ANIMATION_GROUPS = 25; @@ -106,7 +110,7 @@ var ambient = new THREE.AmbientLight( 0x444444 ); scene.add( ambient ); - light = new THREE.SpotLight( 0xffffff, 1, 0, Math.PI/2 ); + light = new THREE.SpotLight( 0xffffff, 1, 0, Math.PI / 2 ); light.position.set( 0, 1500, 1000 ); light.target.position.set( 0, 0, 0 ); @@ -197,10 +201,10 @@ bevelSize: 5, bevelEnabled: true - }); + } ); textGeo.computeBoundingBox(); - var centerOffset = -0.5 * ( textGeo.boundingBox.max.x - textGeo.boundingBox.min.x ); + var centerOffset = - 0.5 * ( textGeo.boundingBox.max.x - textGeo.boundingBox.min.x ); var textMaterial = new THREE.MeshPhongMaterial( { color: 0xff0000, specular: 0xffffff } ); @@ -274,23 +278,23 @@ var phase = ( index + randomness ) / ANIMATION_GROUPS; mixer.clipAction( clip, animGroup ). - setDuration( duration ). - startAt( - duration * phase ). - play(); + setDuration( duration ). + startAt( - duration * phase ). + play(); } } else { mixer.clipAction( clip, mesh ). - setDuration( duration ). - startAt( - duration * Math.random() ). - play(); + setDuration( duration ). + startAt( - duration * Math.random() ). + play(); } mesh.position.set( x, y, z ); - mesh.rotation.y = Math.PI/2; + mesh.rotation.y = Math.PI / 2; mesh.castShadow = true; mesh.receiveShadow = true; @@ -303,7 +307,7 @@ var loader = new THREE.GLTFLoader(); - loader.load( "models/gltf/Horse.glb", function( gltf ) { + loader.load( "models/gltf/Horse.glb", function ( gltf ) { var mesh = gltf.scene.children[ 0 ]; var clip = gltf.animations[ 0 ]; @@ -342,9 +346,9 @@ morph.position.x += morph.speed * delta; - if ( morph.position.x > 2000 ) { + if ( morph.position.x > 2000 ) { - morph.position.x = -1000 - Math.random() * 500; + morph.position.x = - 1000 - Math.random() * 500; }
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_shadowmap_pointlight.html
@@ -20,7 +20,7 @@ z-index: 100; display:block; } - #info a { + a { color: #f88; font-weight: bold; text-decoration: underline;
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_shadowmap_viewer.html
@@ -20,7 +20,12 @@ z-index: 100; display:block; } - #info a { color: #f00; font-weight: bold; text-decoration: underline; cursor: pointer } + a { + color: #f00; + font-weight: bold; + text-decoration: underline; + cursor: pointer + } </style> </head> <body>
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_shadowmesh.html
@@ -47,7 +47,6 @@ var lightSphere, lightHolder; var pyramid, pyramidShadow; var sphere, sphereShadow; - var box, boxShadow; var cube, cubeShadow; var cylinder, cylinderShadow; var torus, torusShadow; @@ -70,7 +69,7 @@ renderer.setPixelRatio( window.devicePixelRatio ); renderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT ); document.getElementById( "container" ).appendChild( renderer.domElement ); - window.addEventListener( 'resize' , onWindowResize, false ); + window.addEventListener( 'resize', onWindowResize, false ); camera.position.set( 0, 2.5, 10 ); scene.add( camera ); @@ -215,7 +214,6 @@ renderer.render( scene, camera ); - } function onWindowResize() { @@ -232,7 +230,7 @@ function lightButtonHandler() { - useDirectionalLight = !useDirectionalLight; + useDirectionalLight = ! useDirectionalLight; if ( useDirectionalLight ) { @@ -254,7 +252,7 @@ lightSphere.visible = false; lightHolder.visible = false; - document.getElementById( 'lightButton' ).value = "Switch to PointLight" ; + document.getElementById( 'lightButton' ).value = "Switch to PointLight"; } else { @@ -280,7 +278,7 @@ lightSphere.visible = true; lightHolder.visible = true; - document.getElementById( 'lightButton' ).value = "Switch to DirectionalLight" ; + document.getElementById( 'lightButton' ).value = "Switch to DirectionalLight"; }
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_simple_gi.html
@@ -11,9 +11,7 @@ overflow: hidden; } - a { - color: #0078ff; - } + a { color: #0078ff; } #info { position: absolute; @@ -159,11 +157,11 @@ requestAnimationFrame( compute ); - } + }; // - var camera, scene, renderer, controls; + var camera, scene, renderer; init(); animate(); @@ -179,7 +177,7 @@ var geometry = new THREE.TorusKnotBufferGeometry( 0.75, 0.3, 128, 32, 1 ); // var geometry = new THREE.BoxBufferGeometry( 1, 1, 1, 10, 10, 10 ) - var material = new THREE.MeshBasicMaterial( { vertexColors: THREE.VertexColors }); + var material = new THREE.MeshBasicMaterial( { vertexColors: THREE.VertexColors } ); var mesh = new THREE.Mesh( geometry, material ); // mesh.position.y = 1; @@ -226,7 +224,7 @@ new SimpleGI( renderer, scene ); - controls = new THREE.OrbitControls( camera ); + var controls = new THREE.OrbitControls( camera ); window.addEventListener( 'resize', onWindowResize, false );
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_sprites.html
@@ -79,7 +79,7 @@ material = materialC.clone(); material.color.setHSL( 0.5 * Math.random(), 0.75, 0.5 ); - material.map.offset.set( -0.5, -0.5 ); + material.map.offset.set( - 0.5, - 0.5 ); material.map.repeat.set( 2, 2 ); } @@ -111,7 +111,7 @@ } - function createHUDSprites ( texture ) { + function createHUDSprites( texture ) { var material = new THREE.SpriteMaterial( { map: texture } ); @@ -152,11 +152,11 @@ var width = window.innerWidth / 2; var height = window.innerHeight / 2; - spriteTL.position.set( - width, height, 1 ); // top left - spriteTR.position.set( width, height, 1 ); // top right + spriteTL.position.set( - width, height, 1 ); // top left + spriteTR.position.set( width, height, 1 ); // top right spriteBL.position.set( - width, - height, 1 ); // bottom left - spriteBR.position.set( width, - height, 1 ); // bottom right - spriteC.position.set( 0, 0, 1 ); // center + spriteBR.position.set( width, - height, 1 ); // bottom right + spriteC.position.set( 0, 0, 1 ); // center }
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_sprites_nodes.html
@@ -23,7 +23,7 @@ display:block; } - a { color: white } + a { color: white; } </style> </head> <body>
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_terrain_dynamic.html
@@ -226,17 +226,13 @@ var terrain; - var textureCounter = 0; - - var animDelta = 0, animDeltaDir = -1; + var animDelta = 0, animDeltaDir = - 1; var lightVal = 0, lightDir = 1; var clock = new THREE.Clock(); var updateNoise = true; - var animateTerrain = false; - var mlib = {}; init(); @@ -250,15 +246,15 @@ sceneRenderTarget = new THREE.Scene(); - cameraOrtho = new THREE.OrthographicCamera( SCREEN_WIDTH / - 2, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, SCREEN_HEIGHT / - 2, -10000, 10000 ); + cameraOrtho = new THREE.OrthographicCamera( SCREEN_WIDTH / - 2, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, SCREEN_HEIGHT / - 2, - 10000, 10000 ); cameraOrtho.position.z = 100; sceneRenderTarget.add( cameraOrtho ); // CAMERA camera = new THREE.PerspectiveCamera( 40, SCREEN_WIDTH / SCREEN_HEIGHT, 2, 4000 ); - camera.position.set( -1200, 800, 1200 ); + camera.position.set( - 1200, 800, 1200 ); controls = new THREE.OrbitControls( camera ); @@ -286,24 +282,23 @@ pointLight.position.set( 0, 0, 0 ); scene.add( pointLight ); - // HEIGHT + NORMAL MAPS var normalShader = THREE.NormalMapShader; var rx = 256, ry = 256; var pars = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat }; - heightMap = new THREE.WebGLRenderTarget( rx, ry, pars ); + heightMap = new THREE.WebGLRenderTarget( rx, ry, pars ); heightMap.texture.generateMipmaps = false; normalMap = new THREE.WebGLRenderTarget( rx, ry, pars ); normalMap.texture.generateMipmaps = false; uniformsNoise = { - time: { value: 1.0 }, - scale: { value: new THREE.Vector2( 1.5, 1.5 ) }, + time: { value: 1.0 }, + scale: { value: new THREE.Vector2( 1.5, 1.5 ) }, offset: { value: new THREE.Vector2( 0, 0 ) } }; @@ -318,15 +313,17 @@ // TEXTURES - var loadingManager = new THREE.LoadingManager( function(){ + var loadingManager = new THREE.LoadingManager( function () { + terrain.visible = true; - }); + + } ); var textureLoader = new THREE.TextureLoader( loadingManager ); var specularMap = new THREE.WebGLRenderTarget( 2048, 2048, pars ); specularMap.texture.generateMipmaps = false; - var diffuseTexture1 = textureLoader.load( "textures/terrain/grasslight-big.jpg"); + var diffuseTexture1 = textureLoader.load( "textures/terrain/grasslight-big.jpg" ); var diffuseTexture2 = textureLoader.load( "textures/terrain/backgrounddetailed6.jpg" ); var detailTexture = textureLoader.load( "textures/terrain/grasslight-big-nm.jpg" ); @@ -366,20 +363,20 @@ var params = [ [ 'heightmap', document.getElementById( 'fragmentShaderNoise' ).textContent, vertexShader, uniformsNoise, false ], - [ 'normal', normalShader.fragmentShader, normalShader.vertexShader, uniformsNormal, false ], + [ 'normal', normalShader.fragmentShader, normalShader.vertexShader, uniformsNormal, false ], [ 'terrain', terrainShader.fragmentShader, terrainShader.vertexShader, uniformsTerrain, true ] ]; - for( var i = 0; i < params.length; i ++ ) { + for ( var i = 0; i < params.length; i ++ ) { var material = new THREE.ShaderMaterial( { - uniforms: params[ i ][ 3 ], - vertexShader: params[ i ][ 2 ], + uniforms: params[ i ][ 3 ], + vertexShader: params[ i ][ 2 ], fragmentShader: params[ i ][ 1 ], - lights: params[ i ][ 4 ], - fog: true - } ); + lights: params[ i ][ 4 ], + fog: true + } ); mlib[ params[ i ][ 0 ] ] = material; @@ -389,7 +386,7 @@ var plane = new THREE.PlaneBufferGeometry( SCREEN_WIDTH, SCREEN_HEIGHT ); quadTarget = new THREE.Mesh( plane, new THREE.MeshBasicMaterial( { color: 0x000000 } ) ); - quadTarget.position.z = -500; + quadTarget.position.z = - 500; sceneRenderTarget.add( quadTarget ); // TERRAIN MESH @@ -399,8 +396,8 @@ THREE.BufferGeometryUtils.computeTangents( geometryTerrain ); terrain = new THREE.Mesh( geometryTerrain, mlib[ 'terrain' ] ); - terrain.position.set( 0, -125, 0 ); - terrain.rotation.x = -Math.PI / 2; + terrain.position.set( 0, - 125, 0 ); + terrain.rotation.x = - Math.PI / 2; terrain.visible = false; scene.add( terrain ); @@ -428,7 +425,7 @@ // - function onWindowResize( event ) { + function onWindowResize() { SCREEN_WIDTH = window.innerWidth; SCREEN_HEIGHT = window.innerHeight; @@ -442,12 +439,12 @@ // - function onKeyDown ( event ) { + function onKeyDown( event ) { - switch( event.keyCode ) { + switch ( event.keyCode ) { - case 78: /*N*/ lightDir *= -1; break; - case 77: /*M*/ animDeltaDir *= -1; break; + case 78: /*N*/ lightDir *= - 1; break; + case 77: /*M*/ animDeltaDir *= - 1; break; }
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_test_memory2.html
@@ -107,16 +107,6 @@ } - // - - function animate() { - - requestAnimationFrame( animate ); - - render(); - - } - function render() { for ( var i = 0; i < N; i ++ ) {
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_tiled_forward.html
@@ -12,9 +12,7 @@ margin: 0px; overflow: hidden; } - a { - color: #f00; - } + a { color: #f00; } #info { position: absolute; @@ -89,7 +87,7 @@ '#endif' ].join( '\n' ); - var lights = [], objects = []; + var lights = []; var State = { rows: 0, @@ -194,7 +192,7 @@ return [ minX, maxX, minY, maxY ]; - }; + }; }(); @@ -362,7 +360,7 @@ } - function postEffect( renderer, scene, camera ) { + function postEffect( renderer ) { bloom.render( renderer, null, renderTarget );
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_tonemapping.html
@@ -76,9 +76,9 @@ Cineon: THREE.CineonToneMapping }; - var camera, scene, renderer, controls, group; + var camera, scene, renderer, group; var composer; - var standardMaterial, standardMaterialPremultiplied, floorMaterial; + var standardMaterial, floorMaterial; init(); animate(); @@ -105,30 +105,36 @@ } ); var textureLoader = new THREE.TextureLoader(); - textureLoader.load( "textures/brick_diffuse.jpg", function( map ) { + textureLoader.load( "textures/brick_diffuse.jpg", function ( map ) { + map.wrapS = THREE.RepeatWrapping; map.wrapT = THREE.RepeatWrapping; map.anisotropy = 4; map.repeat.set( 9, 0.5 ); standardMaterial.map = map; standardMaterial.needsUpdate = true; - } ); - textureLoader.load( "textures/brick_bump.jpg", function( map ) { + + } ); + textureLoader.load( "textures/brick_bump.jpg", function ( map ) { + map.wrapS = THREE.RepeatWrapping; map.wrapT = THREE.RepeatWrapping; map.anisotropy = 4; map.repeat.set( 9, 0.5 ); standardMaterial.bumpMap = map; standardMaterial.needsUpdate = true; - } ); - textureLoader.load( "textures/brick_roughness.jpg", function( map ) { + + } ); + textureLoader.load( "textures/brick_roughness.jpg", function ( map ) { + map.wrapS = THREE.RepeatWrapping; map.wrapT = THREE.RepeatWrapping; map.anisotropy = 4; map.repeat.set( 9, 0.5 ); standardMaterial.roughnessMap = map; standardMaterial.needsUpdate = true; - } ); + + } ); group = new THREE.Group(); scene.add( group ); @@ -215,7 +221,7 @@ stats = new Stats(); container.appendChild( stats.dom ); - controls = new THREE.OrbitControls( camera, renderer.domElement ); + var controls = new THREE.OrbitControls( camera, renderer.domElement ); window.addEventListener( 'resize', onWindowResize, false ); @@ -261,7 +267,7 @@ standardMaterial.bumpScale = - 0.05 * params.bumpScale; standardMaterial.opacity = params.opacity; - if( renderer.toneMapping !== toneMappingOptions[ params.toneMapping ] ) { + if ( renderer.toneMapping !== toneMappingOptions[ params.toneMapping ] ) { renderer.toneMapping = toneMappingOptions[ params.toneMapping ]; standardMaterial.needsUpdate = true; @@ -281,7 +287,7 @@ } - if( params.renderMode === "Composer" ) { + if ( params.renderMode === "Composer" ) { composer.render();
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_trails.html
@@ -96,7 +96,7 @@ } - function onDocumentMouseMove(event) { + function onDocumentMouseMove( event ) { mouseX = ( event.clientX - windowHalfX ) * 10; mouseY = ( event.clientY - windowHalfY ) * 10;
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_video_panorama_equirectangular.html
@@ -22,9 +22,7 @@ text-align:center; } - a { - color: #ffffff; - } + a { color: #ffffff; } </style> </head> <body> @@ -37,17 +35,14 @@ var camera, scene, renderer; - var texture_placeholder, - isUserInteracting = false, - onMouseDownMouseX = 0, onMouseDownMouseY = 0, - lon = 0, onMouseDownLon = 0, - lat = 0, onMouseDownLat = 0, - phi = 0, theta = 0, - distance = 50, - onPointerDownPointerX = 0, - onPointerDownPointerY = 0, - onPointerDownLon = 0, - onPointerDownLat = 0; + var isUserInteracting = false, + lon = 0, lat = 0, + phi = 0, theta = 0, + distance = 50, + onPointerDownPointerX = 0, + onPointerDownPointerY = 0, + onPointerDownLon = 0, + onPointerDownLat = 0; init(); animate(); @@ -81,7 +76,7 @@ texture.minFilter = THREE.LinearFilter; texture.format = THREE.RGBFormat; - var material = new THREE.MeshBasicMaterial( { map : texture } ); + var material = new THREE.MeshBasicMaterial( { map: texture } ); mesh = new THREE.Mesh( geometry, material ); @@ -137,7 +132,7 @@ } - function onDocumentMouseUp( event ) { + function onDocumentMouseUp() { isUserInteracting = false;
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_water.html
@@ -24,9 +24,7 @@ text-align:center; } - a { - color: #ffffff; - } + a { color: #ffffff; } </style> <script src="../build/three.js"></script> @@ -53,7 +51,7 @@ } - var scene, camera, clock, renderer, controls, water; + var scene, camera, clock, renderer, water; var torusKnot; @@ -102,13 +100,15 @@ scene.add( ground ); var textureLoader = new THREE.TextureLoader(); - textureLoader.load( 'textures/hardwood2_diffuse.jpg', function( map ) { + textureLoader.load( 'textures/hardwood2_diffuse.jpg', function ( map ) { + map.wrapS = THREE.RepeatWrapping; map.wrapT = THREE.RepeatWrapping; map.anisotropy = 16; map.repeat.set( 4, 4 ); groundMaterial.map = map; groundMaterial.needsUpdate = true; + } ); // water @@ -171,23 +171,23 @@ var gui = new dat.GUI(); - gui.addColor( params, 'color' ).onChange( function( value ) { + gui.addColor( params, 'color' ).onChange( function ( value ) { water.material.uniforms.color.value.set( value ); } ); - gui.add( params, 'scale', 1, 10 ).onChange( function( value ) { + gui.add( params, 'scale', 1, 10 ).onChange( function ( value ) { water.material.uniforms.config.value.w = value; } ); - gui.add( params, 'flowX', - 1, 1 ).step( 0.01 ).onChange( function( value ) { + gui.add( params, 'flowX', - 1, 1 ).step( 0.01 ).onChange( function ( value ) { water.material.uniforms.flowDirection.value.x = value; water.material.uniforms.flowDirection.value.normalize(); } ); - gui.add( params, 'flowY', - 1, 1 ).step( 0.01 ).onChange( function( value ) { + gui.add( params, 'flowY', - 1, 1 ).step( 0.01 ).onChange( function ( value ) { water.material.uniforms.flowDirection.value.y = value; water.material.uniforms.flowDirection.value.normalize(); @@ -198,7 +198,7 @@ // - controls = new THREE.OrbitControls( camera, renderer.domElement ); + var controls = new THREE.OrbitControls( camera, renderer.domElement ); //
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_water_flowmap.html
@@ -24,9 +24,7 @@ text-align:center; } - a { - color: #ffffff; - } + a { color: #ffffff; } </style> <script src="../build/three.js"></script> @@ -53,7 +51,7 @@ } - var scene, camera, renderer, controls, water; + var scene, camera, renderer, water; init(); animate(); @@ -79,13 +77,15 @@ scene.add( ground ); var textureLoader = new THREE.TextureLoader(); - textureLoader.load( 'textures/floors/FloorsCheckerboard_S_Diffuse.jpg', function( map ) { + textureLoader.load( 'textures/floors/FloorsCheckerboard_S_Diffuse.jpg', function ( map ) { + map.wrapS = THREE.RepeatWrapping; map.wrapT = THREE.RepeatWrapping; map.anisotropy = 16; map.repeat.set( 4, 4 ); groundMaterial.map = map; groundMaterial.needsUpdate = true; + } ); // water @@ -124,12 +124,12 @@ // var gui = new dat.GUI(); - gui.add( helper, 'visible' ).name( 'Show Flow Map'); + gui.add( helper, 'visible' ).name( 'Show Flow Map' ); gui.open(); // - controls = new THREE.OrbitControls( camera, renderer.domElement ); + var controls = new THREE.OrbitControls( camera, renderer.domElement ); //
true
Other
mrdoob
three.js
a5b45d15ed3e18587fac1253aa96113549a22e3a.json
fix linter errors in webgl M to W
examples/webgl_worker_offscreencanvas.html
@@ -34,9 +34,7 @@ color: #ff0000; } - a { - color: #ffffff; - } + a { color: #ffffff; } </style> <script src="js/WebGL.js"></script> </head>
true
Other
mrdoob
three.js
0d33d726b7b6e6397e3c3c183c47b0a05bf444f7.json
translate helper folder
docs/api/zh/helpers/ArrowHelper.html
@@ -1,5 +1,5 @@ <!DOCTYPE html> -<html lang="en"> +<html lang="zh"> <head> <meta charset="utf-8" /> <base href="../../../" /> @@ -12,10 +12,10 @@ <h1>[name]</h1> - <p class="desc">An 3D arrow object for visualizing directions.</p> + <p class="desc">用于模拟方向的3维箭头对象.</p> - <h2>Example</h2> + <h2>例子</h2> <div>[example:webgl_geometries WebGL / geometries]</div> <div>[example:webgl_geometry_normals WebGL / geometry / normals]</div> @@ -37,61 +37,61 @@ <h2>Example</h2> - <h2>Constructor</h2> + <h2>构造函数</h2> <h3>[name]([param:Vector3 dir], [param:Vector3 origin], [param:Number length], [param:Number hex], [param:Number headLength], [param:Number headWidth] )</h3> <p> - [page:Vector3 dir] -- direction from origin. Must be a unit vector. <br /> - [page:Vector3 origin] -- Point at which the arrow starts.<br /> - [page:Number length] -- length of the arrow. Default is *1*.<br /> - [page:Number hex] -- hexadecimal value to define color. Default is 0xffff00.<br /> - [page:Number headLength] -- The length of the head of the arrow. Default is 0.2 * length.<br /> - [page:Number headWidth] -- The length of the width of the arrow. Default is 0.2 * headLength. + [page:Vector3 dir] -- 基于箭头原点的方向. 必须为单位向量. <br /> + [page:Vector3 origin] -- 箭头的原点.<br /> + [page:Number length] -- 箭头的长度. 默认为 *1*.<br /> + [page:Number hex] -- 定义的16进制颜色值. 默认为 0xffff00.<br /> + [page:Number headLength] -- 箭头头部(锥体)的长度. 默认为箭头长度的0.2倍(0.2 * length).<br /> + [page:Number headWidth] -- 箭头的宽度. 默认为箭头头部(锥体)长度的0.2倍(0.2 * headLength). </p> - <h2>Properties</h2> - <p>See the base [page:Object3D] class for common properties.</p> + <h2>属性</h2> + <p>请到基类 [page:Object3D] 页面查看公共属性.</p> <h3>[property:Line line]</h3> - <p>Contains the line part of the arrowHelper.</p> + <p>包含箭头辅助对象的线段部分.</p> <h3>[property:Mesh cone]</h3> - <p>Contains the cone part of the arrowHelper.</p> + <p>包含箭头辅助对象的锥体部分.</p> - <h2>Methods</h2> - <p>See the base [page:Object3D] class for common methods.</p> + <h2>方法</h2> + <p>请到基类 [page:Object3D] 页面查看公共方法.</p> <h3>[method:null setColor]([param:Number hex])</h3> <p> - hex -- The hexadecimal value of the color.<br /><br /> + hex -- 16进制颜色值.<br /><br /> - Sets the color of the arrowHelper. + 设置箭头辅助对象的颜色. </p> <h3>[method:null setLength]([param:Number length], [param:Number headLength], [param:Number headWidth])</h3> <p> - length -- The desired length.<br /> - headLength -- The length of the head of the arrow.<br /> - headWidth -- The length of the width of the arrow.<br /><br /> + length -- 要设置的长度.<br /> + headLength -- 要设置的箭头头部(锥体)的长度.<br /> + headWidth -- 要设置的箭头的宽度.<br /><br /> - Sets the length of the arrowhelper. + 设置箭头辅助对象的长度. </p> <h3>[method:null setDirection]([param:Vector3 dir])</h3> <p> - dir -- The desired direction. Must be a unit vector.<br /><br /> + dir -- 要设置的方向. 必须为单位向量.<br /><br /> - Sets the direction of the arrowhelper. + 设置箭头辅助对象的方向. </p> - <h2>Source</h2> + <h2>源码</h2> [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] </body>
true
Other
mrdoob
three.js
0d33d726b7b6e6397e3c3c183c47b0a05bf444f7.json
translate helper folder
docs/api/zh/helpers/AxesHelper.html
@@ -1,5 +1,5 @@ <!DOCTYPE html> -<html lang="en"> +<html lang="zh"> <head> <meta charset="utf-8" /> <base href="../../../" /> @@ -12,11 +12,11 @@ <h1>[name]</h1> - <p class="desc">An axis object to visualize the 3 axes in a simple way. <br /> - The X axis is red. The Y axis is green. The Z axis is blue.</p> + <p class="desc">用于简单模拟3个坐标轴的对象. <br /> + 红色代表 X 轴. 绿色代表 Y 轴. 蓝色代表 Z 轴.</p> - <h2>Example</h2> + <h2>例子</h2> <div>[example:webgl_geometries WebGL / geometries]</div> <div>[example:webgl_geometries2 WebGL / geometries2]</div> @@ -30,21 +30,21 @@ <h2>Example</h2> scene.add( axesHelper ); </code> - <h2>Constructor</h2> + <h2>构造函数</h2> <h3>[name]( [param:Number size] )</h3> <p> - [page:Number size] -- (optional) size of the lines representing the axes. Default is *1*. + [page:Number size] -- (可选的) 表示代表轴的线段长度. 默认为 *1*. </p> - <h2>Properties</h2> - <p>See the base [page:LineSegments] class for common properties.</p> + <h2>属性</h2> + <p>请到基类 [page:LineSegments] 页面查看公共属性.</p> - <h2>Methods</h2> - <p>See the base [page:LineSegments] class for common methods.</p> + <h2>方法</h2> + <p>请到基类 [page:LineSegments] 页面查看公共方法.</p> - <h2>Source</h2> + <h2>源码</h2> [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] </body>
true
Other
mrdoob
three.js
0d33d726b7b6e6397e3c3c183c47b0a05bf444f7.json
translate helper folder
docs/api/zh/helpers/Box3Helper.html
@@ -1,5 +1,5 @@ <!DOCTYPE html> -<html lang="en"> +<html lang="zh"> <head> <meta charset="utf-8" /> <base href="../../../" /> @@ -13,11 +13,11 @@ <h1>[name]</h1> <p class="desc"> - Helper object to visualize a [page:Box3]. + 模拟3维包围盒 [page:Box3] 的辅助对象. </p> - <h2>Example</h2> + <h2>例子</h2> <code> var box = new THREE.Box3(); @@ -28,36 +28,36 @@ <h2>Example</h2> </code> - <h2>Constructor</h2> + <h2>构造函数</h2> <h3>[name]( [param:Box3 box], [param:Color color] )</h3> <p> - [page:Box3 box] -- the Box3 to show.<br /> - [page:Color color] -- (optional) the box's color. Default is 0xffff00.<br /><br /> + [page:Box3 box] -- 被模拟的3维包围盒.<br /> + [page:Color color] -- (可选的) 线框盒子的颜色. 默认为 0xffff00.<br /><br /> - Creates a new wireframe box that represents the passed Box3. + 创建一个新的线框盒子用以表示指定的3维包围盒. </p> - <h2>Properties</h2> - <p>See the base [page:LineSegments] class for common properties.</p> + <h2>属性</h2> + <p>请到基类 [page:LineSegments] 页面查看公共属性.</p> <h3>[property:Box3 box]</h3> - <p>The Box3 being visualized.</p> + <p>被模拟的3维包围盒.</p> - <h2>Methods</h2> - <p>See the base [page:LineSegments] class for common methods.</p> + <h2>方法</h2> + <p>请到基类 [page:LineSegments] 页面查看公共方法.</p> <h3>[method:void updateMatrixWorld]( [param:Boolean force] )</h3> <p> - This overrides the method in the base [page:Object3D] class so that it - also updates the wireframe box to the extent of the [page:Box3Helper.box .box] - property. + 重写基类 [page:Object3D] 的该方法以便于 + 同时更新线框辅助对象与 [page:Box3Helper.box .box] + 属性保持一致. </p> - <h2>Source</h2> + <h2>源码</h2> [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] </body>
true
Other
mrdoob
three.js
0d33d726b7b6e6397e3c3c183c47b0a05bf444f7.json
translate helper folder
docs/api/zh/helpers/BoxHelper.html
@@ -1,5 +1,5 @@ <!DOCTYPE html> -<html lang="en"> +<html lang="zh"> <head> <meta charset="utf-8" /> <base href="../../../" /> @@ -13,14 +13,14 @@ <h1>[name]</h1> <p class="desc"> - Helper object to show the world-axis-aligned bounding box around an object. + 用于展示对象世界轴心对齐的包围盒的辅助对象. - Note that the object must have a [page:Geometry] or [page:BufferGeometry] for this to work, - so it won't work with [page:Sprite Sprites]. + 注意:要想能正常运行,目标对象必须包含 [page:Geometry] 或 [page:BufferGeometry] , + 所以当目标对象是精灵 [page:Sprite Sprites] 时将不能正常运行. </p> - <h2>Example</h2> + <h2>例子</h2> <div>[example:webgl_helpers WebGL / helpers]</div> <div>[example:webgl_loader_nrrd WebGL / loader / nrrd]</div> @@ -35,39 +35,39 @@ <h2>Example</h2> </code> - <h2>Constructor</h2> + <h2>构造函数</h2> <h3>[name]( [param:Object3D object], [param:Color color] )</h3> <p> - [page:Object3D object] -- (optional) the object3D to show the world-axis-aligned boundingbox.<br /> - [page:Color color] -- (optional) hexadecimal value that defines the box's color. Default is 0xffff00.<br /><br /> + [page:Object3D object] -- (可选的) 被展示世界轴心对齐的包围盒的对象.<br /> + [page:Color color] -- (可选的) 线框盒子的16进制颜色值. 默认为 0xffff00.<br /><br /> - Creates a new wireframe box that bounds the passed object. Internally this uses [page:Box3.setFromObject] - to calculate the dimensions. Note that this includes any children. + 创建一个新的线框盒子包围指定的对象. 内部使用 [page:Box3.setFromObject] + 方法来计算尺寸. 注意:此线框盒子将包围对象的所有子对象. </p> - <h2>Properties</h2> - <p>See the base [page:LineSegments] class for common properties.</p> + <h2>属性</h2> + <p>请到基类 [page:LineSegments] 页面查看公共属性.</p> - <h2>Methods</h2> - <p>See the base [page:LineSegments] class for common methods.</p> + <h2>方法</h2> + <p>请到基类 [page:LineSegments] 页面查看公共方法.</p> <h3>[method:null update]()</h3> <p> - Updates the helper's geometry to match the dimensions - of the object, including any children. See [page:Box3.setFromObject]. + 更新辅助对象的几何体,与目标对象尺寸 + 保持一致, 包围目标对象所有子对象. 请查看 [page:Box3.setFromObject]. </p> <h3>[method:BoxHelper setFromObject]( [param:Object3D object] )</h3> <p> - [page:Object3D object] - [page:Object3D] to create the helper of.<br /><br /> + [page:Object3D object] - 用于创建辅助对象的目标 [page:Object3D] 对象.<br /><br /> - Updates the wireframe box for the passed object. + 更新指定对象的线框盒子. </p> - <h2>Source</h2> + <h2>源码</h2> [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] </body>
true
Other
mrdoob
three.js
0d33d726b7b6e6397e3c3c183c47b0a05bf444f7.json
translate helper folder
docs/api/zh/helpers/CameraHelper.html
@@ -1,5 +1,5 @@ <!DOCTYPE html> -<html lang="en"> +<html lang="zh"> <head> <meta charset="utf-8" /> <base href="../../../" /> @@ -13,11 +13,11 @@ <h1>[name]</h1> <p class="desc"> - This helps with visualizing what a camera contains in its frustum.<br /> - It visualizes the frustum of a camera using a [page:LineSegments]. + 用于模拟相机视锥体的辅助对象.<br /> + 它使用 [page:LineSegments] 来模拟相机视锥体. </p> - <h2>Example</h2> + <h2>例子</h2> <div>[example:webgl_camera WebGL / camera]</div> <div>[example:webgl_geometry_extrude_splines WebGL / extrude / splines]</div> @@ -29,50 +29,50 @@ <h2>Example</h2> </code> - <h2>Constructor</h2> + <h2>构造函数</h2> <h3>[name]( [param:Camera camera] )</h3> <p> - [page:Camera camera] -- The camera to visualize.<br /><br /> + [page:Camera camera] -- 被模拟的相机.<br /><br /> - This create a new [Name] for the specified camera. + 为指定相机创建一个新的相机辅助对象 [Name] . </p> - <h2>Properties</h2> - <p>See the base [page:LineSegments] class for common properties.</p> + <h2>属性</h2> + <p>请到基类 [page:LineSegments] 页面查看公共属性.</p> <h3>[property:Camera camera]</h3> - <p>The camera being visualized.</p> + <p>被模拟的相机.</p> <h3>[property:object pointMap]</h3> - <p>This contains the points used to visualize the camera.</p> + <p>包含用于模拟相机的点.</p> <h3>[property:object matrix]</h3> - <p>Reference to the [page:Object3D.matrixWorld camera.matrixWorld].</p> + <p>请参考相机的世界矩阵 [page:Object3D.matrixWorld camera.matrixWorld].</p> <h3>[property:object matrixAutoUpdate]</h3> <p> - See [page:Object3D.matrixAutoUpdate]. Set to *false* here as the helper is using the - camera's [page:Object3D.matrixWorld matrixWorld]. + 请查看 [page:Object3D.matrixAutoUpdate]. 这里设置为 *false* 表示辅助对象 + 使用相机的 [page:Object3D.matrixWorld matrixWorld]. </p> - <h2>Methods</h2> - <p>See the base [page:LineSegments] class for common methods.</p> + <h2>方法</h2> + <p>请到基类 [page:LineSegments] 页面查看公共方法.</p> <h3>[method:null update]()</h3> - <p>Updates the helper based on the projectionMatrix of the camera.</p> + <p>基于相机的投影矩阵更新辅助对象.</p> - <h2>Source</h2> + <h2>源码</h2> [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] </body>
true
Other
mrdoob
three.js
0d33d726b7b6e6397e3c3c183c47b0a05bf444f7.json
translate helper folder
docs/api/zh/helpers/DirectionalLightHelper.html
@@ -1,5 +1,5 @@ <!DOCTYPE html> -<html lang="en"> +<html lang="zh"> <head> <meta charset="utf-8" /> <base href="../../../" /> @@ -13,12 +13,12 @@ <h1>[name]</h1> <p class="desc"> - Helper object to assist with visualizing a [page:DirectionalLight]'s effect on the scene. + 用于模拟场景中平行光 [page:DirectionalLight] 的辅助对象. - This consists of plane and a line representing the light's position and direction. + 其中包含了表示光位置的平面和表示光方向的线段. </p> - <h2>Example</h2> + <h2>例子</h2> <code> var light = new THREE.DirectionalLight( 0xFFFFFF ); @@ -29,56 +29,56 @@ <h2>Example</h2> </code> - <h2>Constructor</h2> + <h2>构造函数</h2> <h3>[name]( [param:DirectionalLight light], [param:Number size], [param:Hex color] )</h3> <p> - [page:DirectionalLight light]-- The light to be visualized. <br /><br /> + [page:DirectionalLight light]-- 被模拟的光源. <br /><br /> - [page:Number size] -- (optional) dimensions of the plane. Default is *1*.<br /><br /> + [page:Number size] -- (可选的) 平面的尺寸. 默认为 *1*.<br /><br /> - [page:Hex color] -- (optional) if this is not the set the helper will take the color of the light. + [page:Hex color] -- (可选的) 如果没有设置颜色将使用光源的颜色. </p> - <h2>Properties</h2> - <p>See the base [page:Object3D] class for common properties.</p> + <h2>属性</h2> + <p>请到基类 [page:Object3D] 页面查看公共属性.</p> <h3>[property:Line lightPlane]</h3> - <p>Contains the line mesh showing the location of the directional light.</p> + <p>包含表示平行光方向的线网格.</p> <h3>[property:DirectionalLight light]</h3> - <p>Reference to the [page:DirectionalLight directionalLight] being visualized.</p> + <p>被模拟的光源. 请参考 [page:DirectionalLight directionalLight] .</p> <h3>[property:object matrix]</h3> - <p>Reference to the light's [page:Object3D.matrixWorld matrixWorld].</p> + <p>请参考光源的世界矩阵 [page:Object3D.matrixWorld matrixWorld].</p> <h3>[property:object matrixAutoUpdate]</h3> <p> - See [page:Object3D.matrixAutoUpdate]. Set to *false* here as the helper is using the - light's [page:Object3D.matrixWorld matrixWorld]. + 请查看 [page:Object3D.matrixAutoUpdate] 页面. 这里设置为 *false* 表示辅助对象 + 使用光源的 [page:Object3D.matrixWorld matrixWorld]. </p> <h3>[property:hex color]</h3> <p> - The color parameter passed in the constructor. Default is *undefined*. If this is changed, - the helper's color will update the next time [page:.update update] is called. + 构造函数中传入的颜色值. 默认为 *undefined*. 如果改变该值, + 辅助对象的颜色将在下一次 [page:.update update] 被调用时更新. </p> - <h2>Methods</h2> - <p>See the base [page:Object3D] class for common properties.</p> + <h2>方法</h2> + <p>请到基类 [page:Object3D] 页面查看公共方法.</p> <h3>[method:null dispose]()</h3> - <p>Dispose of the directionalLightHelper.</p> + <p>销毁该平行光辅助对象.</p> <h3>[method:null update]()</h3> - <p>Updates the helper to match the position and direction of the [page:.light directionalLight] being visualized.</p> + <p>更新辅助对象,与模拟的 [page:.light directionalLight] 光源的位置和方向保持一致.</p> - <h2>Source</h2> + <h2>源码</h2> [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] </body>
true
Other
mrdoob
three.js
0d33d726b7b6e6397e3c3c183c47b0a05bf444f7.json
translate helper folder
docs/api/zh/helpers/FaceNormalsHelper.html
@@ -1,5 +1,5 @@ <!DOCTYPE html> -<html lang="en"> +<html lang="zh"> <head> <meta charset="utf-8" /> <base href="../../../" /> @@ -13,16 +13,16 @@ <h1>[name]</h1> <p class="desc"> - Renders [page:ArrowHelper arrows] to visualize an object's [page:Face3 face] normals. - Requires that face normals have been specified on all [page:Face3 faces] or calculated - with [page:Geometry.computeFaceNormals computeFaceNormals]. <br /><br /> + 渲染箭头辅助对象 [page:ArrowHelper arrows] 来模拟面 [page:Face3 face] 的法线. + 需要所有面 [page:Face3 faces] 都指定了法线 或 + 通过 [page:Geometry.computeFaceNormals computeFaceNormals] 方法计算面的法线. <br /><br /> - Note that this only works with the objects whose geometry is an instance of [page:Geometry]. - For [page:BufferGeometry] use a [page:VertexNormalsHelper] instead. + 注意:仅几何体为 [page:Geometry] 类型的对象能正常运行. + 对于 [page:BufferGeometry] 类型几何体的对象请使用 [page:VertexNormalsHelper] 代替. <p> - <h2>Example</h2> + <h2>例子</h2> <div>[example:webgl_helpers WebGL / helpers]</div> @@ -37,44 +37,44 @@ <h2>Example</h2> scene.add( helper ); </code> - <h2>Constructor</h2> + <h2>构造函数</h2> <h3>[name]( [param:Object3D object], [param:Number size], [param:Color color], [param:Number linewidth] )</h3> <p> - [page:Object3D object] -- object for which to render face normals.<br /> - [page:Number size] -- (optional) length of the arrows. Default is *1*.<br /> - [page:Hex color] -- (optional) hex color of the arrows. Default is *0xffff00*.<br /> - [page:Number linewidth] -- (optional) width of the arrow lines. Default is *1*. + [page:Object3D object] -- 要渲染面法线辅助的对象.<br /> + [page:Number size] -- (可选的) 箭头的长度. 默认为 *1*.<br /> + [page:Hex color] -- (可选的) 箭头的颜色. 默认为 *0xffff00*.<br /> + [page:Number linewidth] -- (可选的) 箭头线段的宽度. 默认为 *1*. </p> - <h2>Properties</h2> - <p>See the base [page:LineSegments] class for common properties.</p> + <h2>属性</h2> + <p>请到基类 [page:LineSegments] 页面查看公共属性.</p> <h3>[property:object matrixAutoUpdate]</h3> <p> - See [page:Object3D.matrixAutoUpdate]. Set to *false* here as the helper is using the - objects's [page:Object3D.matrixWorld matrixWorld]. + 请查看 [page:Object3D.matrixAutoUpdate]. 这里设置为 *false* 表示辅助对象 + 使用对象的世界矩阵 [page:Object3D.matrixWorld matrixWorld]. </p> <h3>[property:Object3D object]</h3> - <p>The object for which the face normals are being visualized.</p> + <p>被渲染面法线辅助的对象.</p> <h3>[property:Number size]</h3> - <p>Length of the arrows. Default is *1*.</p> + <p>箭头的长度. 默认为 *1*.</p> - <h2>Methods</h2> - <p>See the base [page:LineSegments] class for common methods.</p> + <h2>方法</h2> + <p>请到基类 [page:LineSegments] 页面查看公共方法.</p> <h3>[method:null update]()</h3> - <p>Updates the face normal preview based on movement of the object.</p> + <p>基于对象的运动更新面法线辅助对象.</p> - <h2>Source</h2> + <h2>源码</h2> [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] </body>
true
Other
mrdoob
three.js
0d33d726b7b6e6397e3c3c183c47b0a05bf444f7.json
translate helper folder
docs/api/zh/helpers/GridHelper.html
@@ -1,5 +1,5 @@ <!DOCTYPE html> -<html lang="en"> +<html lang="zh"> <head> <meta charset="utf-8" /> <base href="../../../" /> @@ -12,10 +12,10 @@ <h1>[name]</h1> - <p class="desc">The GridHelper is an object to define grids. Grids are two-dimensional arrays of lines.</p> + <p class="desc">坐标格辅助对象. 坐标格实际上是2维线数组.</p> - <h2>Example</h2> + <h2>例子</h2> <code>var size = 10; var divisions = 10; @@ -26,20 +26,20 @@ <h2>Example</h2> [example:webgl_helpers Example using various helpers] - <h2>Constructor</h2> + <h2>构造函数</h2> <h3>[name]( [param:number size], [param:Number divisions], [param:Color colorCenterLine], [param:Color colorGrid] )</h3> <p> - size -- The size of the grid. Default is 10. <br /> - divisions -- The number of divisions across the grid. Default is 10. <br /> - colorCenterLine -- The color of the centerline. This can be a [page:Color], a hexadecimal value and an CSS-Color name. Default is 0x444444 <br /> - colorGrid -- The color of the lines of the grid. This can be a [page:Color], a hexadecimal value and an CSS-Color name. Default is 0x888888 + size -- 坐标格尺寸. 默认为 10. <br /> + divisions -- 坐标格细分次数. 默认为 10. <br /> + colorCenterLine -- 中线颜色. 值可以为 [page:Color] 类型, 16进制 和 CSS 颜色名. 默认为 0x444444 <br /> + colorGrid -- 坐标格网格线颜色. 值可以为 [page:Color] 类型, 16进制 和 CSS 颜色名. 默认为 0x888888 </p> <p> - Creates a new [name] of size 'size' and divided into 'divisions' segments per side. Colors are optional. + 创建一个尺寸为 'size' 和 每个维度细分 'divisions' 次的坐标格. 颜色可选. </p> - <h2>Source</h2> + <h2>源码</h2> [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] </body>
true
Other
mrdoob
three.js
0d33d726b7b6e6397e3c3c183c47b0a05bf444f7.json
translate helper folder
docs/api/zh/helpers/HemisphereLightHelper.html
@@ -1,5 +1,5 @@ <!DOCTYPE html> -<html lang="en"> +<html lang="zh"> <head> <meta charset="utf-8" /> <base href="../../../" /> @@ -13,10 +13,11 @@ <h1>[name]</h1> <p class="desc"> - Creates a visual aid consisting of a spherical [page:Mesh] for a [page:HemisphereLight HemisphereLight]. + 创建一个虚拟的球形网格 [page:Mesh] 的辅助对象来模拟 + 半球形光源 [page:HemisphereLight HemisphereLight]. </p> - <h3>Example</h3> + <h3>例子</h3> <code> var light = new THREE.HemisphereLight( 0xffffbb, 0x080820, 1 ); @@ -27,51 +28,51 @@ <h3>Example</h3> </code> - <h2>Constructor</h2> + <h2>构造函数</h2> <h3>[name]( [param:HemisphereLight light], [param:Number sphereSize], [param:Hex color] )</h3> <p> - [page:HemisphereLight light] -- The light being visualized. <br /><br /> + [page:HemisphereLight light] -- 被模拟的光源. <br /><br /> - [page:Number size] -- The size of the mesh used to visualize the light.<br /><br /> + [page:Number size] -- 用于模拟光源的网格尺寸.<br /><br /> - [page:Hex color] -- (optional) if this is not the set the helper will take the color of the light. + [page:Hex color] -- (可选的) 如果没有赋值辅助对象将使用光源的颜色. </p> - <h2>Properties</h2> - <p>See the base [page:Object3D] class for common properties.</p> + <h2>属性</h2> + <p>请到基类 [page:Object3D] 页面查看公共属性.</p> <h3>[property:HemisphereLight light]</h3> - <p>Reference to the HemisphereLight being visualized.</p> + <p>被模拟的半球形光源.</p> <h3>[property:object matrix]</h3> - <p>Reference to the hemisphereLight's [page:Object3D.matrixWorld matrixWorld].</p> + <p>请参考半球形光源的世界矩阵 [page:Object3D.matrixWorld matrixWorld].</p> <h3>[property:object matrixAutoUpdate]</h3> <p> - See [page:Object3D.matrixAutoUpdate]. Set to *false* here as the helper is using the - hemisphereLight's [page:Object3D.matrixWorld matrixWorld]. + 请查看 [page:Object3D.matrixAutoUpdate]. 这里设置为 *false* 表示辅助对象 + 使用半球形光源的 [page:Object3D.matrixWorld matrixWorld]. </p> <h3>[property:hex color]</h3> <p> - The color parameter passed in the constructor. Default is *undefined*. If this is changed, the helper's color will update - the next time [page:.update update] is called. + 构造函数中传入的颜色值. 默认为 *undefined*. 如果改变该值, + 辅助对象的颜色将在下一次 [page:.update update] 被调用时更新. </p> - <h2>Methods</h2> - <p>See the base [page:Object3D] class for common methods.</p> + <h2>方法</h2> + <p>请到基类 [page:Object3D] 页面查看公共方法.</p> <h3>[method:null dispose]()</h3> - <p>Dispose of the hemisphereLightHelper.</p> + <p>销毁该半球形光源辅助对象.</p> <h3>[method:null update]()</h3> - <p>Updates the helper to match the position and direction of the [page:.light].</p> + <p>更新辅助对象,与 [page:.light] 属性的位置和方向保持一致.</p> - <h2>Source</h2> + <h2>源码</h2> [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] </body>
true
Other
mrdoob
three.js
0d33d726b7b6e6397e3c3c183c47b0a05bf444f7.json
translate helper folder
docs/api/zh/helpers/PlaneHelper.html
@@ -1,5 +1,5 @@ <!DOCTYPE html> -<html lang="en"> +<html lang="zh"> <head> <meta charset="utf-8" /> <base href="../../../" /> @@ -13,11 +13,11 @@ <h1>[name]</h1> <p class="desc"> - Helper object to visualize a [page:Plane]. + 用于模拟平面 [page:Plane] 的辅助对象. </p> - <h2>Example</h2> + <h2>例子</h2> <code> var plane = new THREE.Plane( new THREE.Vector3( 1, 1, 0.2 ), 3 ); @@ -26,39 +26,39 @@ <h2>Example</h2> </code> - <h2>Constructor</h2> + <h2>构造函数</h2> <h3>[name]( [param:Plane plane], [param:Float size], [param:Color hex] )</h3> <p> - [page:Plane plane] -- the plane to visualize.<br /> - [page:Float size] -- (optional) side length of plane helper. Default is 1.<br /> - [page:Color color] -- (optional) the color of the helper. Default is 0xffff00.<br /><br /> + [page:Plane plane] -- 被模拟的平面.<br /> + [page:Float size] -- (可选的) 辅助对象的单边长度. 默认为 1.<br /> + [page:Color color] -- (可选的) 辅助对象的颜色. 默认为 0xffff00.<br /><br /> - Creates a new wireframe representation of the passed plane. + 创建一个线框辅助对象来表示指定平面. </p> - <h2>Properties</h2> - <p>See the base [page:LineSegments] class for common properties.</p> + <h2>属性</h2> + <p>请到基类 [page:LineSegments] 页面查看公共属性.</p> <h3>[property:Plane plane]</h3> - <p>The [page:Plane plane] being visualized.</p> + <p>被模拟的平面 [page:Plane plane] .</p> <h3>[property:Float size]</h3> - <p>The side lengths of plane helper.</p> + <p>辅助对象的单边长度.</p> - <h2>Methods</h2> - <p>See the base [page:LineSegments] class for common methods.</p> + <h2>方法</h2> + <p>请到基类 [page:LineSegments] 页面查看公共方法.</p> <h3>[method:void updateMatrixWorld]( [param:Boolean force] )</h3> <p> - This overrides the method in the base [page:Object3D] class so that it also - updates the helper object according to the [page:PlaneHelper.plane .plane] and - [page:PlaneHelper.size .size] properties. + 重写基类 [page:Object3D] 的该方法以便于 + 同时更新线框辅助对象与 [page:PlaneHelper.plane .plane] 和 + [page:PlaneHelper.size .size] 属性保持一致. </p> - <h2>Source</h2> + <h2>源码</h2> [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] </body>
true
Other
mrdoob
three.js
0d33d726b7b6e6397e3c3c183c47b0a05bf444f7.json
translate helper folder
docs/api/zh/helpers/PointLightHelper.html
@@ -1,5 +1,5 @@ <!DOCTYPE html> -<html lang="en"> +<html lang="zh"> <head> <meta charset="utf-8" /> <base href="../../../" /> @@ -13,12 +13,12 @@ <h1>[name]</h1> <p class="desc"> - This displays a helper object consisting of a spherical [page:Mesh] for visualizing - a [page:PointLight]. + 创建一个虚拟的球形网格 [page:Mesh] 的辅助对象来模拟 + 点光源 [page:PointLight]. </p> - <h2>Example</h2> + <h2>例子</h2> [example:webgl_helpers WebGL / helpers] @@ -35,49 +35,49 @@ <h2>Example</h2> - <h2>Constructor</h2> + <h2>构造函数</h2> <h3>[name]( [param:PointLight light], [param:Float sphereSize], [param:Hex color] )</h3> <p> - [page:PointLight light] -- The light to be visualized. <br /><br /> + [page:PointLight light] -- 要模拟的光源. <br /><br /> - [page:Float sphereSize] -- (optional) The size of the sphere helper. Default is *1*.<br /><br /> + [page:Float sphereSize] -- (可选的) 球形辅助对象的尺寸. 默认为 *1*.<br /><br /> - [page:Hex color] -- (optional) if this is not the set the helper will take the color of the light. + [page:Hex color] -- (可选的) 如果没有赋值辅助对象将使用光源的颜色. </p> - <h2>Properties</h2> - <p>See the base [page:Mesh] class for common properties.</p> + <h2>属性</h2> + <p>请到基类 [page:Mesh] 页面查看公共属性.</p> <h3>[property:PointLight light]</h3> - <p>The [page:PointLight] that is being visualized.</p> + <p>被模拟的点光源 [page:PointLight] .</p> <h3>[property:object matrix]</h3> - <p>Reference to the pointLight's [page:Object3D.matrixWorld matrixWorld].</p> + <p>请参考点光源的世界矩阵 [page:Object3D.matrixWorld matrixWorld].</p> <h3>[property:object matrixAutoUpdate]</h3> <p> - See [page:Object3D.matrixAutoUpdate]. Set to *false* here as the helper is using the - pointLight's [page:Object3D.matrixWorld matrixWorld]. + 请查看 [page:Object3D.matrixAutoUpdate]. 这里设置为 *false* 表示辅助对象 + 使用点光源的 [page:Object3D.matrixWorld matrixWorld]. </p> <h3>[property:hex color]</h3> <p> - The color parameter passed in the constructor. Default is *undefined*. If this is changed, the helper's color will update - the next time [page:.update update] is called. + 构造函数中传入的颜色值. 默认为 *undefined*. 如果改变该值, + 辅助对象的颜色将在下一次 [page:.update update] 被调用时更新. </p> - <h2>Methods</h2> - <p>See the base [page:Mesh] class for common methods.</p> + <h2>方法</h2> + <p>请到基类 [page:Mesh] 页面查看公共方法.</p> <h3>[method:null dispose]()</h3> - <p>Dispose of the pointLightHelper.</p> + <p>销毁该点光源辅助对象.</p> <h3>[method:null update]()</h3> - <p>Updates the helper to match the position of the [page:.light].</p> + <p>更新辅助对象,与 [page:.light] 属性的位置保持一致.</p> - <h2>Source</h2> + <h2>源码</h2> [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] </body>
true
Other
mrdoob
three.js
0d33d726b7b6e6397e3c3c183c47b0a05bf444f7.json
translate helper folder
docs/api/zh/helpers/PolarGridHelper.html
@@ -1,5 +1,5 @@ <!DOCTYPE html> -<html lang="en"> +<html lang="zh"> <head> <meta charset="utf-8" /> <base href="../../../" /> @@ -12,10 +12,10 @@ <h1>[name]</h1> - <p class="desc">The PolarGridHelper is an object to define polar grids. Grids are two-dimensional arrays of lines.</p> + <p class="desc">极坐标格辅助对象. 坐标格实际上是2维线数组.</p> - <h2>Example</h2> + <h2>例子</h2> <code>var radius = 10; var radials = 16; @@ -28,22 +28,22 @@ <h2>Example</h2> [example:webgl_helpers Example using various helpers] - <h2>Constructor</h2> + <h2>构造函数</h2> <h3>[name]( [param:Number radius], [param:Number radials], [param:Number circles], [param:Number divisions], [param:Color color1], [param:Color color2] )</h3> <p> - radius -- The radius of the polar grid. This can be any positive number. Default is 10.<br /> - radials -- The number of radial lines. This can be any positive integer. Default is 16.<br /> - circles -- The number of circles. This can be any positive integer. Default is 8.<br /> - divisions -- The number of line segments used for each circle. This can be any positive integer that is 3 or greater. Default is 64.<br /> - color1 -- The first color used for grid elements. This can be a [page:Color], a hexadecimal value and an CSS-Color name. Default is 0x444444 <br /> - color2 -- The second color used for grid elements. This can be a [page:Color], a hexadecimal value and an CSS-Color name. Default is 0x888888 + radius -- 极坐标格半径. 可以为任何正数. 默认为 10.<br /> + radials -- 径向辐射线数量. 可以为任何正整数. 默认为 16.<br /> + circles -- 圆圈的数量. 可以为任何正整数. 默认为 8.<br /> + divisions -- 圆圈细分段数. 可以为任何大于或等于3的正整数. 默认为 64.<br /> + color1 -- 极坐标格使用的第一个颜色. 值可以为 [page:Color] 类型, 16进制 和 CSS 颜色名. 默认为 0x444444 <br /> + color2 -- 极坐标格使用的第二个颜色. 值可以为 [page:Color] 类型, 16进制 和 CSS 颜色名. 默认为 0x888888 </p> <p> - Creates a new [name] of radius 'radius' with 'radials' number of radials and 'circles' number of circles, where each circle is smoothed into 'divisions' number of line segments. Colors are optional. + 创建一个半径为'radius' 包含 'radials' 条径向辐射线 和 'circles' 个细分成 'divisions' 段的圆圈的极坐标格辅助对象. 颜色可选. </p> - <h2>Source</h2> + <h2>源码</h2> [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] </body>
true
Other
mrdoob
three.js
0d33d726b7b6e6397e3c3c183c47b0a05bf444f7.json
translate helper folder
docs/api/zh/helpers/RectAreaLightHelper.html
@@ -1,5 +1,5 @@ <!DOCTYPE html> -<html lang="en"> +<html lang="zh"> <head> <meta charset="utf-8" /> <base href="../../../" /> @@ -13,10 +13,10 @@ <h1>[name]</h1> <p class="desc"> - Creates a visual aid for a [page:RectAreaLight]. + 创建一个表示 [page:RectAreaLight] 的辅助对象. </p> - <h3>Example</h3> + <h3>例子</h3> <code> var light = new THREE.RectAreaLight( 0xffffbb, 1.0, 5, 5 ); @@ -27,40 +27,40 @@ <h3>Example</h3> </code> - <h2>Constructor</h2> + <h2>构造函数</h2> <h3>[name]( [param:RectAreaLight light], [param:Hex color] )</h3> <p> - [page:RectAreaLight light] -- The light being visualized.<br /><br /> + [page:RectAreaLight light] -- 被模拟的光源.<br /><br /> - [page:Hex color] -- (optional) if this is not the set the helper will take the color of the light. + [page:Hex color] -- (可选) 如果没有赋值辅助对象将使用光源的颜色. </p> - <h2>Properties</h2> - <p>See the base [page:Object3D] class for common properties.</p> + <h2>属性</h2> + <p>请到基类 [page:Object3D] 页面查看公共属性.</p> <h3>[property:RectAreaLight light]</h3> - <p>Reference to the RectAreaLight being visualized.</p> + <p>被模拟的区域光源.</p> <h3>[property:hex color]</h3> <p> - The color parameter passed in the constructor. Default is *undefined*. If this is changed, the helper's color will update - the next time [page:.update update] is called. + 构造函数中传入的颜色值. 默认为 *undefined*. 如果改变该值, + 辅助对象的颜色将在下一次 [page:.update update] 被调用时更新. </p> - <h2>Methods</h2> - <p>See the base [page:Object3D] class for common methods.</p> + <h2>方法</h2> + <p>请到基类 [page:Object3D] 页面查看公共方法.</p> <h3>[method:null dispose]()</h3> - <p>Dispose of the rectAreaLightHelper.</p> + <p>销毁该区域光源辅助对象.</p> <h3>[method:null update]()</h3> - <p>Updates the helper to match the position and direction of the [page:.light].</p> + <p>更新辅助对象,与 [page:.light] 属性的位置和方向保持一致.</p> - <h2>Source</h2> + <h2>源码</h2> [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] </body>
true
Other
mrdoob
three.js
0d33d726b7b6e6397e3c3c183c47b0a05bf444f7.json
translate helper folder
docs/api/zh/helpers/SkeletonHelper.html
@@ -1,5 +1,5 @@ <!DOCTYPE html> -<html lang="en"> +<html lang="zh"> <head> <meta charset="utf-8" /> <base href="../../../" /> @@ -13,12 +13,12 @@ <h1>[name]</h1> <p class="desc"> - A helper object to assist with visualizing a [page:Skeleton Skeleton]. - The helper is renderered using a [page:LineBasicMaterial LineBasicMaterial]. + 用来模拟骨骼 [page:Skeleton Skeleton] 的辅助对象. + 该辅助对象使用 [page:LineBasicMaterial LineBasicMaterial] 材质. </p> - <h2>Example</h2> + <h2>例子</h2> [example:webgl_animation_skinning_blending animation / skinning / blending]<br /> [example:webgl_animation_skinning_morph animation / skinning / morph]<br /> @@ -32,30 +32,30 @@ <h2>Example</h2> - <h2>Constructor</h2> + <h2>构造函数</h2> <h3>[name]( object )</h3> <p> - object -- can be any object that has an array of [page:Bone Bone]s as a sub object. <br /> - For example, a [page:Skeleton Skeleton] or a [page:SkinnedMesh SkinnedMesh]. + object -- 可以是任何拥有一组骨 [page:Bone Bone] 作为子对象的对象. <br /> + 比如, 一个骨骼 [page:Skeleton Skeleton] 或 一个蒙皮网格 [page:SkinnedMesh SkinnedMesh]. </p> - <h2>Properties</h2> + <h2>属性</h2> <h3>[property:Array bones]</h3> <p> - The list of bones that the helper renders as [page:Line Lines]. + 辅助对象使用 [page:Line Lines] 渲染的骨数组. </p> <h3>[property:Object root]</h3> <p> - The object passed in the constructor. + 构造函数传入的对象. </p> - <h2>Source</h2> + <h2>源码</h2> [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] </body>
true
Other
mrdoob
three.js
0d33d726b7b6e6397e3c3c183c47b0a05bf444f7.json
translate helper folder
docs/api/zh/helpers/SpotLightHelper.html
@@ -1,5 +1,5 @@ <!DOCTYPE html> -<html lang="en"> +<html lang="zh"> <head> <meta charset="utf-8" /> <base href="../../../" /> @@ -12,16 +12,16 @@ <h1>[name]</h1> - <p class="desc">This displays a cone shaped helper object for a [page:SpotLight].</p> + <p class="desc">用于模拟聚光灯 [page:SpotLight] 的锥形辅助对象.</p> - <h2>Example</h2> + <h2>例子</h2> <iframe src='../examples/webgl_lights_spotlight.html'></iframe> <a target="THREE_Examples" href="../examples/#webgl_lights_spotlight">View in Examples</a><br /> - <h2>Other Examples</h2> + <h2>其他例子</h2> <div>[example:webgl_lights_spotlights lights / spotlights ]</div> - <h2>Code Example</h2> + <h2>代码示例</h2> <code> var spotLight = new THREE.SpotLight( 0xffffff ); spotLight.position.set( 10, 10, 10 ); @@ -32,51 +32,51 @@ <h2>Code Example</h2> </code> - <h2>Constructor</h2> + <h2>构造函数</h2> <h3>[name]( [param:SpotLight light], [param:Hex color] )</h3> <p> - [page:SpotLight light] -- The [page:SpotLight] to be visualized. <br /><br/> + [page:SpotLight light] -- 被模拟的聚光灯 [page:SpotLight] . <br /><br/> - [page:Hex color] -- (optional) if this is not the set the helper will take the color of the light. + [page:Hex color] -- (可选的) 如果没有赋值辅助对象将使用光源的颜色. </p> - <h2>Properties</h2> - <p>See the base [page:Object3D] class for common properties.</p> + <h2>属性</h2> + <p>请到基类 [page:Object3D] 页面查看公共属性.</p> <h3>[property:LineSegments cone]</h3> - <p>[page:LineSegments] used to visualize the light.</p> + <p>用于模拟光源的 [page:LineSegments] 类型对象.</p> <h3>[property:SpotLight light]</h3> - <p>Reference to the [page:SpotLight] being visualized.</p> + <p>被模拟的聚光灯 [page:SpotLight] .</p> <h3>[property:object matrix]</h3> - <p>Reference to the spotLight's [page:Object3D.matrixWorld matrixWorld].</p> + <p>请参考聚光灯的世界矩阵 [page:Object3D.matrixWorld matrixWorld].</p> <h3>[property:object matrixAutoUpdate]</h3> <p> - See [page:Object3D.matrixAutoUpdate]. Set to *false* here as the helper is using the - spotLight's [page:Object3D.matrixWorld matrixWorld]. + 请查看 [page:Object3D.matrixAutoUpdate]. 这里设置为 *false* 表示辅助对象 + 使用聚光灯的 [page:Object3D.matrixWorld matrixWorld]. </p> <h3>[property:hex color]</h3> <p> - The color parameter passed in the constructor. Default is *undefined*. If this is changed, the helper's color will update - the next time [page:.update update] is called. + 构造函数中传入的颜色值. 默认为 *undefined*. 如果改变该值, + 辅助对象的颜色将在下一次 [page:.update update] 被调用时更新. </p> - <h2>Methods</h2> - <p>See the base [page:Object3D] class for common methods.</p> + <h2>方法</h2> + <p>请到基类 [page:Object3D] 页面查看公共属性.</p> <h3>[method:null dispose]()</h3> - <p>Disposes of the light helper.</p> + <p>销毁该聚光灯辅助对象.</p> <h3>[method:null update]()</h3> - <p>Updates the light helper.</p> + <p>更新聚光灯辅助对象.</p> - <h2>Source</h2> + <h2>源码</h2> [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] </body>
true
Other
mrdoob
three.js
0d33d726b7b6e6397e3c3c183c47b0a05bf444f7.json
translate helper folder
docs/api/zh/helpers/VertexNormalsHelper.html
@@ -1,5 +1,5 @@ <!DOCTYPE html> -<html lang="en"> +<html lang="zh"> <head> <meta charset="utf-8" /> <base href="../../../" /> @@ -13,14 +13,14 @@ <h1>[name]</h1> <p class="desc"> - Renders [page:ArrowHelper arrows] to visualize an object's vertex normal vectors. - Requires that normals have been specified in a [page:BufferAttribute custom attribute] or - have been calculated using [page:Geometry.computeVertexNormals computeVertexNormals].<br /><br /> + 渲染箭头辅助对象 [page:ArrowHelper arrows] 来模拟顶点的法线. + 需要定义了法线缓存属性 [page:BufferAttribute custom attribute] 或 + 使用了 [page:Geometry.computeVertexNormals computeVertexNormals] 方法计算了顶点法线.<br /><br /> - Unlike [page:FaceNormalsHelper], this works with [page:BufferGeometry]. + 不像面法线辅助对象 [page:FaceNormalsHelper], 该辅助对象在 [page:BufferGeometry] 上也能正常运行. </p> - <h2>Example</h2> + <h2>例子</h2> [example:webgl_helpers WebGL / helpers] @@ -36,43 +36,43 @@ <h2>Example</h2> </code> - <h2>Constructor</h2> + <h2>构造函数</h2> <h3>[name]( [param:Object3D object], [param:Number size], [param:Hex color], [param:Number linewidth] )</h3> <p> - [page:Object3D object] -- object for which to render vertex normals.<br /> - [page:Number size] -- (optional) length of the arrows. Default is 1.<br /> - [page:Hex color] -- hex color of the arrows. Default is 0xff0000.<br /> - [page:Number linewidth] -- (optional) width of the arrow lines. Default is 1. + [page:Object3D object] -- 要渲染顶点法线辅助的对象.<br /> + [page:Number size] -- (可选的) 箭头的长度. 默认为 1.<br /> + [page:Hex color] -- 16进制颜色值. 默认为 0xff0000.<br /> + [page:Number linewidth] -- (可选的) 箭头线段的宽度. 默认为 1. </p> - <h2>Properties</h2> - <p>See the base [page:LineSegments] class for common properties.</p> + <h2>属性</h2> + <p>请到基类 [page:LineSegments] 页面查看公共属性.</p> <h3>[property:object matrixAutoUpdate]</h3> <p> - See [page:Object3D.matrixAutoUpdate]. Set to *false* here as the helper is using the - objects's [page:Object3D.matrixWorld matrixWorld]. + 请查看 [page:Object3D.matrixAutoUpdate]. 这里设置为 *false* 表示辅助对象 + 使用对象的世界矩阵 [page:Object3D.matrixWorld matrixWorld]. </p> <h3>[property:Object3D object]</h3> - <p>The object for which the vertex normals are being visualized.</p> + <p>被渲染顶点法线辅助的对象.</p> <h3>[property:Number size]</h3> - <p>Length of the arrows. Default is *1*.</p> + <p>箭头的长度. 默认为 *1*.</p> - <h2>Methods</h2> - <p>See the base [page:LineSegments] class for common methods.</p> + <h2>方法</h2> + <p>请到基类 [page:LineSegments] 页面查看公共方法.</p> <h3>[method:null update]()</h3> - <p>Updates the vertex normal preview based on movement of the object.</p> + <p>基于对象的运动更新顶点法线辅助对象.</p> - <h2>Source</h2> + <h2>源码</h2> [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] </body>
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_animation_skinning_blending.html
@@ -183,23 +183,39 @@ var folder6 = panel.addFolder( 'General Speed' ); settings = { - 'show model': true, - 'show skeleton': false, - 'deactivate all': deactivateAllActions, - 'activate all': activateAllActions, - 'pause/continue': pauseContinue, - 'make single step': toSingleStepMode, - 'modify step size': 0.05, - 'from walk to idle': function () { prepareCrossFade( walkAction, idleAction, 1.0 ) }, - 'from idle to walk': function () { prepareCrossFade( idleAction, walkAction, 0.5 ) }, - 'from walk to run': function () { prepareCrossFade( walkAction, runAction, 2.5 ) }, - 'from run to walk': function () { prepareCrossFade( runAction, walkAction, 5.0 ) }, - 'use default duration': true, - 'set custom duration': 3.5, - 'modify idle weight': 0.0, - 'modify walk weight': 1.0, - 'modify run weight': 0.0, - 'modify time scale': 1.0 + 'show model': true, + 'show skeleton': false, + 'deactivate all': deactivateAllActions, + 'activate all': activateAllActions, + 'pause/continue': pauseContinue, + 'make single step': toSingleStepMode, + 'modify step size': 0.05, + 'from walk to idle': function () { + + prepareCrossFade( walkAction, idleAction, 1.0 ); + + }, + 'from idle to walk': function () { + + prepareCrossFade( idleAction, walkAction, 0.5 ); + + }, + 'from walk to run': function () { + + prepareCrossFade( walkAction, runAction, 2.5 ); + + }, + 'from run to walk': function () { + + prepareCrossFade( runAction, walkAction, 5.0 ); + + }, + 'use default duration': true, + 'set custom duration': 3.5, + 'modify idle weight': 0.0, + 'modify walk weight': 1.0, + 'modify run weight': 0.0, + 'modify time scale': 1.0 }; folder1.add( settings, 'show model' ).onChange( showModel ); @@ -215,9 +231,21 @@ crossFadeControls.push( folder4.add( settings, 'from run to walk' ) ); folder4.add( settings, 'use default duration' ); folder4.add( settings, 'set custom duration', 0, 10, 0.01 ); - folder5.add( settings, 'modify idle weight', 0.0, 1.0, 0.01 ).listen().onChange( function ( weight ) { setWeight( idleAction, weight ) } ); - folder5.add( settings, 'modify walk weight', 0.0, 1.0, 0.01 ).listen().onChange( function ( weight ) { setWeight( walkAction, weight ) } ); - folder5.add( settings, 'modify run weight', 0.0, 1.0, 0.01 ).listen().onChange( function ( weight ) { setWeight( runAction, weight ) } ); + folder5.add( settings, 'modify idle weight', 0.0, 1.0, 0.01 ).listen().onChange( function ( weight ) { + + setWeight( idleAction, weight ); + + } ); + folder5.add( settings, 'modify walk weight', 0.0, 1.0, 0.01 ).listen().onChange( function ( weight ) { + + setWeight( walkAction, weight ); + + } ); + folder5.add( settings, 'modify run weight', 0.0, 1.0, 0.01 ).listen().onChange( function ( weight ) { + + setWeight( runAction, weight ); + + } ); folder6.add( settings, 'modify time scale', 0.0, 1.5, 0.01 ).onChange( modifyTimeScale ); folder1.open(); @@ -380,7 +408,6 @@ } - function setCrossFadeDuration( defaultDuration ) { // Switch default crossfade duration <-> custom crossfade duration @@ -397,7 +424,6 @@ } - function synchronizeCrossFade( startAction, endAction, duration ) { mixer.addEventListener( 'loop', onLoopFinished ); @@ -416,7 +442,6 @@ } - function executeCrossFade( startAction, endAction, duration ) { // Not only the start action, but also the end action must get a weight of 1 before fading @@ -431,7 +456,6 @@ } - // This function is needed, since animationAction.crossFadeTo() disables its start action and sets // the start action's timeScale to ((start animation's duration) / (end animation's duration)) @@ -443,7 +467,6 @@ } - // Called by the render loop function updateWeightSliders() { @@ -454,7 +477,6 @@ } - // Called by the render loop function updateCrossFadeControls() { @@ -486,7 +508,6 @@ } - function onWindowResize() { camera.aspect = window.innerWidth / window.innerHeight; @@ -496,7 +517,6 @@ } - function animate() { // Render loop
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_animation_skinning_morph.html
@@ -53,9 +53,9 @@ var SCREEN_WIDTH = window.innerWidth; var SCREEN_HEIGHT = window.innerHeight; - var FLOOR = -250; + var FLOOR = - 250; - var container,stats; + var container, stats; var camera, scene; var renderer; @@ -99,7 +99,7 @@ var ground = new THREE.Mesh( geometry, material ); ground.position.set( 0, FLOOR, 0 ); - ground.rotation.x = -Math.PI/2; + ground.rotation.x = - Math.PI / 2; scene.add( ground ); ground.receiveShadow = true; @@ -120,10 +120,10 @@ var d = 390; - light.shadow.camera.left = -d; + light.shadow.camera.left = - d; light.shadow.camera.right = d; light.shadow.camera.top = d * 1.5; - light.shadow.camera.bottom = -d; + light.shadow.camera.bottom = - d; light.shadow.camera.far = 3500; @@ -152,7 +152,7 @@ var loader = new THREE.JSONLoader(); loader.load( "models/skinned/knight.js", function ( geometry, materials ) { - createScene( geometry, materials, 0, FLOOR, -300, 60 ); + createScene( geometry, materials, 0, FLOOR, - 300, 60 ); // GUI @@ -222,44 +222,50 @@ mixer = new THREE.AnimationMixer( mesh ); - bonesClip = geometry.animations[0]; + bonesClip = geometry.animations[ 0 ]; facesClip = THREE.AnimationClip.CreateFromMorphTargetSequence( 'facialExpressions', mesh.geometry.morphTargets, 3 ); } function initGUI() { var API = { - 'show model' : true, - 'show skeleton' : false, - 'show 2nd model' : false, - 'show mem. info' : false + 'show model': true, + 'show skeleton': false, + 'show 2nd model': false, + 'show mem. info': false }; var gui = new dat.GUI(); - gui.add( API, 'show model' ).onChange( function() { - mesh.visible = API[ 'show model' ]; + gui.add( API, 'show model' ).onChange( function () { + + mesh.visible = API[ 'show model' ]; + } ); - gui.add( API, 'show skeleton' ).onChange( function() { - helper.visible = API[ 'show skeleton' ]; + gui.add( API, 'show skeleton' ).onChange( function () { + + helper.visible = API[ 'show skeleton' ]; + } ); - gui.add( API, 'show 2nd model' ).onChange( function() { - mesh2.visible = API[ 'show 2nd model' ]; + gui.add( API, 'show 2nd model' ).onChange( function () { + + mesh2.visible = API[ 'show 2nd model' ]; + } ); - gui.add( API, 'show mem. info' ).onChange( function() { + gui.add( API, 'show mem. info' ).onChange( function () { showMemInfo = API[ 'show mem. info' ]; domMemInfo.style.display = showMemInfo ? 'block' : 'none'; } ); // utility function used for drop-down options lists in the GUI - var objectNames = function( objects ) { + var objectNames = function ( objects ) { var result = []; @@ -295,14 +301,14 @@ }, - 'stop()': function() { + 'stop()': function () { action = mixer.clipAction( clip, root ); action.stop(); }, - 'reset()': function() { + 'reset()': function () { action = mixer.clipAction( clip, root ); action.reset(); @@ -373,7 +379,7 @@ }, - 'play delayed': function() { + 'play delayed': function () { action = mixer.clipAction( clip, root ); action.startAt( mixer.time + 0.5 ).play(); @@ -406,14 +412,14 @@ }, - 'fade in': function() { + 'fade in': function () { action = mixer.clipAction( clip, root ); action.reset().fadeIn( 0.25 ).play(); }, - 'fade out': function() { + 'fade out': function () { action = mixer.clipAction( clip, root ); action.fadeOut( 0.25 ).play(); @@ -446,11 +452,11 @@ }, - 'time warp': function() { + 'time warp': function () { action = mixer.clipAction( clip, root ); var timeScaleNow = action.getEffectiveTimeScale(); - var destTimeScale = timeScaleNow > 0 ? -1 : 1; + var destTimeScale = timeScaleNow > 0 ? - 1 : 1; action.warp( timeScaleNow, destTimeScale, 4 ).play(); }, @@ -481,7 +487,11 @@ }, - get 'local root'() { return rootName; }, + get 'local root'() { + + return rootName; + + }, set 'local root'( value ) { @@ -500,14 +510,14 @@ folder.add( API, 'paused =' ).listen(); folder.add( API, 'enabled =' ).listen(); folder.add( API, 'clamp =' ); - folder.add( API, 'isRunning() =').listen(); + folder.add( API, 'isRunning() =' ).listen(); folder.add( API, 'play delayed' ); folder.add( API, 'weight =', 0, 1 ).listen(); folder.add( API, 'eff. weight', 0, 1 ).listen(); folder.add( API, 'fade in' ); folder.add( API, 'fade out' ); - folder.add( API, 'timeScale =', -2, 2).listen(); - folder.add( API, 'eff.T.Scale', -2, 2).listen(); + folder.add( API, 'timeScale =', - 2, 2 ).listen(); + folder.add( API, 'eff.T.Scale', - 2, 2 ).listen(); folder.add( API, 'time warp' ); folder.add( API, 'loop mode', { "LoopOnce": THREE.LoopOnce, @@ -525,7 +535,7 @@ clipControl( gui, mixer, bonesClip, [ null, mesh, mesh2 ] ); clipControl( gui, mixer, facesClip, [ null, mesh, mesh2 ] ); - var memoryControl = function( gui, mixer, clips, rootObjects ) { + var memoryControl = function ( gui, mixer, clips, rootObjects ) { var clipNames = objectNames( clips ), rootNames = objectNames( rootObjects ); @@ -540,7 +550,11 @@ API = { - get 'clip'() { return clipName; }, + get 'clip'() { + + return clipName; + + }, set 'clip'( value ) { @@ -549,7 +563,11 @@ }, - get 'root'() { return rootName; }, + get 'root'() { + + return rootName; + + }, set 'root'( value ) { @@ -558,19 +576,19 @@ }, - 'uncache clip': function() { + 'uncache clip': function () { mixer.uncacheClip( clip ); }, - 'uncache root': function() { + 'uncache root': function () { mixer.uncacheRoot( root ); }, - 'uncache action': function() { + 'uncache action': function () { mixer.uncacheAction( clip, root ); @@ -587,7 +605,7 @@ }; memoryControl( gui, mixer, - [ bonesClip, facesClip ], [ mesh, mesh2 ] ); + [ bonesClip, facesClip ], [ mesh, mesh2 ] ); } @@ -632,7 +650,7 @@ camera.lookAt( scene.position ); - if( mixer ) { + if ( mixer ) { mixer.update( delta );
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_buffergeometry.html
@@ -77,7 +77,7 @@ scene.add( light1 ); var light2 = new THREE.DirectionalLight( 0xffffff, 1.5 ); - light2.position.set( 0, -1, 0 ); + light2.position.set( 0, - 1, 0 ); scene.add( light2 ); // @@ -160,7 +160,11 @@ } - function disposeArray() { this.array = null; } + function disposeArray() { + + this.array = null; + + } geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( positions, 3 ).onUpload( disposeArray ) ); geometry.addAttribute( 'normal', new THREE.Float32BufferAttribute( normals, 3 ).onUpload( disposeArray ) );
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_buffergeometry_constructed_from_geometry.html
@@ -192,7 +192,7 @@ } - function animate( time ) { + function animate() { requestAnimationFrame( animate );
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_buffergeometry_custom_attributes_particles.html
@@ -99,22 +99,22 @@ uniforms = { - texture: { value: new THREE.TextureLoader().load( "textures/sprites/spark1.png" ) } + texture: { value: new THREE.TextureLoader().load( "textures/sprites/spark1.png" ) } }; var shaderMaterial = new THREE.ShaderMaterial( { - uniforms: uniforms, - vertexShader: document.getElementById( 'vertexshader' ).textContent, + uniforms: uniforms, + vertexShader: document.getElementById( 'vertexshader' ).textContent, fragmentShader: document.getElementById( 'fragmentshader' ).textContent, - blending: THREE.AdditiveBlending, - depthTest: false, - transparent: true, - vertexColors: true + blending: THREE.AdditiveBlending, + depthTest: false, + transparent: true, + vertexColors: true - }); + } ); var radius = 200; @@ -137,7 +137,7 @@ colors.push( color.r, color.g, color.b ); - sizes.push( 20 );; + sizes.push( 20 ); } @@ -191,7 +191,7 @@ var sizes = geometry.attributes.size.array; - for ( var i = 0; i < particles; i++ ) { + for ( var i = 0; i < particles; i ++ ) { sizes[ i ] = 10 * ( 1 + Math.sin( 0.1 * i + time ) );
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_buffergeometry_drawcalls.html
@@ -73,17 +73,25 @@ var gui = new dat.GUI(); - gui.add( effectController, "showDots" ).onChange( function( value ) { pointCloud.visible = value; } ); - gui.add( effectController, "showLines" ).onChange( function( value ) { linesMesh.visible = value; } ); + gui.add( effectController, "showDots" ).onChange( function ( value ) { + + pointCloud.visible = value; + + } ); + gui.add( effectController, "showLines" ).onChange( function ( value ) { + + linesMesh.visible = value; + + } ); gui.add( effectController, "minDistance", 10, 300 ); gui.add( effectController, "limitConnections" ); gui.add( effectController, "maxConnections", 0, 30, 1 ); - gui.add( effectController, "particleCount", 0, maxParticleCount, 1 ).onChange( function( value ) { + gui.add( effectController, "particleCount", 0, maxParticleCount, 1 ).onChange( function ( value ) { particleCount = parseInt( value ); particles.setDrawRange( 0, particleCount ); - }); + } ); } @@ -93,8 +101,6 @@ container = document.getElementById( 'container' ); - // - camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 4000 ); camera.position.z = 1750; @@ -128,19 +134,19 @@ particles = new THREE.BufferGeometry(); particlePositions = new Float32Array( maxParticleCount * 3 ); - for ( var i = 0; i < maxParticleCount; i++ ) { + for ( var i = 0; i < maxParticleCount; i ++ ) { var x = Math.random() * r - r / 2; var y = Math.random() * r - r / 2; var z = Math.random() * r - r / 2; - particlePositions[ i * 3 ] = x; + particlePositions[ i * 3 ] = x; particlePositions[ i * 3 + 1 ] = y; particlePositions[ i * 3 + 2 ] = z; // add it to the geometry particlesData.push( { - velocity: new THREE.Vector3( -1 + Math.random() * 2, -1 + Math.random() * 2, -1 + Math.random() * 2 ), + velocity: new THREE.Vector3( - 1 + Math.random() * 2, - 1 + Math.random() * 2, - 1 + Math.random() * 2 ), numConnections: 0 } ); @@ -206,68 +212,71 @@ var colorpos = 0; var numConnected = 0; - for ( var i = 0; i < particleCount; i++ ) + for ( var i = 0; i < particleCount; i ++ ) particlesData[ i ].numConnections = 0; - for ( var i = 0; i < particleCount; i++ ) { + for ( var i = 0; i < particleCount; i ++ ) { // get the particle - var particleData = particlesData[i]; + var particleData = particlesData[ i ]; - particlePositions[ i * 3 ] += particleData.velocity.x; + particlePositions[ i * 3 ] += particleData.velocity.x; particlePositions[ i * 3 + 1 ] += particleData.velocity.y; particlePositions[ i * 3 + 2 ] += particleData.velocity.z; - if ( particlePositions[ i * 3 + 1 ] < -rHalf || particlePositions[ i * 3 + 1 ] > rHalf ) - particleData.velocity.y = -particleData.velocity.y; + if ( particlePositions[ i * 3 + 1 ] < - rHalf || particlePositions[ i * 3 + 1 ] > rHalf ) + particleData.velocity.y = - particleData.velocity.y; - if ( particlePositions[ i * 3 ] < -rHalf || particlePositions[ i * 3 ] > rHalf ) - particleData.velocity.x = -particleData.velocity.x; + if ( particlePositions[ i * 3 ] < - rHalf || particlePositions[ i * 3 ] > rHalf ) + particleData.velocity.x = - particleData.velocity.x; - if ( particlePositions[ i * 3 + 2 ] < -rHalf || particlePositions[ i * 3 + 2 ] > rHalf ) - particleData.velocity.z = -particleData.velocity.z; + if ( particlePositions[ i * 3 + 2 ] < - rHalf || particlePositions[ i * 3 + 2 ] > rHalf ) + particleData.velocity.z = - particleData.velocity.z; if ( effectController.limitConnections && particleData.numConnections >= effectController.maxConnections ) continue; // Check collision - for ( var j = i + 1; j < particleCount; j++ ) { + for ( var j = i + 1; j < particleCount; j ++ ) { var particleDataB = particlesData[ j ]; if ( effectController.limitConnections && particleDataB.numConnections >= effectController.maxConnections ) continue; - var dx = particlePositions[ i * 3 ] - particlePositions[ j * 3 ]; + var dx = particlePositions[ i * 3 ] - particlePositions[ j * 3 ]; var dy = particlePositions[ i * 3 + 1 ] - particlePositions[ j * 3 + 1 ]; var dz = particlePositions[ i * 3 + 2 ] - particlePositions[ j * 3 + 2 ]; var dist = Math.sqrt( dx * dx + dy * dy + dz * dz ); if ( dist < effectController.minDistance ) { - particleData.numConnections++; - particleDataB.numConnections++; + particleData.numConnections ++; + particleDataB.numConnections ++; var alpha = 1.0 - dist / effectController.minDistance; - positions[ vertexpos++ ] = particlePositions[ i * 3 ]; - positions[ vertexpos++ ] = particlePositions[ i * 3 + 1 ]; - positions[ vertexpos++ ] = particlePositions[ i * 3 + 2 ]; + positions[ vertexpos ++ ] = particlePositions[ i * 3 ]; + positions[ vertexpos ++ ] = particlePositions[ i * 3 + 1 ]; + positions[ vertexpos ++ ] = particlePositions[ i * 3 + 2 ]; - positions[ vertexpos++ ] = particlePositions[ j * 3 ]; - positions[ vertexpos++ ] = particlePositions[ j * 3 + 1 ]; - positions[ vertexpos++ ] = particlePositions[ j * 3 + 2 ]; + positions[ vertexpos ++ ] = particlePositions[ j * 3 ]; + positions[ vertexpos ++ ] = particlePositions[ j * 3 + 1 ]; + positions[ vertexpos ++ ] = particlePositions[ j * 3 + 2 ]; - colors[ colorpos++ ] = alpha; - colors[ colorpos++ ] = alpha; - colors[ colorpos++ ] = alpha; + colors[ colorpos ++ ] = alpha; + colors[ colorpos ++ ] = alpha; + colors[ colorpos ++ ] = alpha; - colors[ colorpos++ ] = alpha; - colors[ colorpos++ ] = alpha; - colors[ colorpos++ ] = alpha; + colors[ colorpos ++ ] = alpha; + colors[ colorpos ++ ] = alpha; + colors[ colorpos ++ ] = alpha; + + numConnected ++; - numConnected++; } + } + }
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_buffergeometry_instancing.html
@@ -141,8 +141,8 @@ var orientationsStart = []; var orientationsEnd = []; - positions.push( 0.025, -0.025, 0 ); - positions.push( -0.025, 0.025, 0 ); + positions.push( 0.025, - 0.025, 0 ); + positions.push( - 0.025, 0.025, 0 ); positions.push( 0, 0, 0.025 ); // instanced attributes @@ -233,7 +233,7 @@ } - function onWindowResize( event ) { + function onWindowResize() { camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix();
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_buffergeometry_instancing2.html
@@ -222,7 +222,7 @@ } - function onWindowResize( event ) { + function onWindowResize() { camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix();
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_buffergeometry_instancing_billboards.html
@@ -126,8 +126,10 @@ renderer = new THREE.WebGLRenderer(); if ( renderer.extensions.get( 'ANGLE_instanced_arrays' ) === null ) { + document.getElementById( 'notSupported' ).style.display = ''; return false; + } container = document.createElement( 'div' );
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_buffergeometry_instancing_interleaved_dynamic.html
@@ -120,7 +120,6 @@ container = document.getElementById( 'container' ); camera = new THREE.PerspectiveCamera( 50, window.innerWidth / window.innerHeight, 1, 1000 ); - //camera.position.z = 20; scene = new THREE.Scene(); scene.background = new THREE.Color( 0x101010 ); @@ -137,35 +136,35 @@ // only use x,y,z and u,v; but x, y, z, nx, ny, nz, u, v would be a good layout var vertexBuffer = new THREE.InterleavedBuffer( new Float32Array( [ // Front - -1, 1, 1, 0, 0, 0, 0, 0, + - 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, - -1, -1, 1, 0, 0, 1, 0, 0, - 1, -1, 1, 0, 1, 1, 0, 0, + - 1, - 1, 1, 0, 0, 1, 0, 0, + 1, - 1, 1, 0, 1, 1, 0, 0, // Back - 1, 1, -1, 0, 1, 0, 0, 0, - -1, 1, -1, 0, 0, 0, 0, 0, - 1, -1, -1, 0, 1, 1, 0, 0, - -1, -1, -1, 0, 0, 1, 0, 0, + 1, 1, - 1, 0, 1, 0, 0, 0, + - 1, 1, - 1, 0, 0, 0, 0, 0, + 1, - 1, - 1, 0, 1, 1, 0, 0, + - 1, - 1, - 1, 0, 0, 1, 0, 0, // Left - -1, 1, -1, 0, 1, 1, 0, 0, - -1, 1, 1, 0, 1, 0, 0, 0, - -1, -1, -1, 0, 0, 1, 0, 0, - -1, -1, 1, 0, 0, 0, 0, 0, + - 1, 1, - 1, 0, 1, 1, 0, 0, + - 1, 1, 1, 0, 1, 0, 0, 0, + - 1, - 1, - 1, 0, 0, 1, 0, 0, + - 1, - 1, 1, 0, 0, 0, 0, 0, // Right 1, 1, 1, 0, 1, 0, 0, 0, - 1, 1, -1, 0, 1, 1, 0, 0, - 1, -1, 1, 0, 0, 0, 0, 0, - 1, -1, -1, 0, 0, 1, 0, 0, + 1, 1, - 1, 0, 1, 1, 0, 0, + 1, - 1, 1, 0, 0, 0, 0, 0, + 1, - 1, - 1, 0, 0, 1, 0, 0, // Top - -1, 1, 1, 0, 0, 0, 0, 0, + - 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, - -1, 1, -1, 0, 0, 1, 0, 0, - 1, 1, -1, 0, 1, 1, 0, 0, + - 1, 1, - 1, 0, 0, 1, 0, 0, + 1, 1, - 1, 0, 1, 1, 0, 0, // Bottom - 1, -1, 1, 0, 1, 0, 0, 0, - -1, -1, 1, 0, 0, 0, 0, 0, - 1, -1, -1, 0, 1, 1, 0, 0, - -1, -1, -1, 0, 0, 1, 0, 0 + 1, - 1, 1, 0, 1, 0, 0, 0, + - 1, - 1, 1, 0, 0, 0, 0, 0, + 1, - 1, - 1, 0, 1, 1, 0, 0, + - 1, - 1, - 1, 0, 0, 1, 0, 0 ] ), 8 ); // Use vertexBuffer, starting at offset 0, 3 items in position attribute @@ -197,7 +196,8 @@ var offsets = new THREE.InterleavedBufferAttribute( instanceBuffer, 3, 0 ); var vector = new THREE.Vector4(); - for ( var i = 0, ul = offsets.count; i < ul; i++ ) { + for ( var i = 0, ul = offsets.count; i < ul; i ++ ) { + var x = Math.random() * 100 - 50; var y = Math.random() * 100 - 50; var z = Math.random() * 100 - 50; @@ -211,7 +211,7 @@ orientations = new THREE.InterleavedBufferAttribute( instanceBuffer, 4, 4 ); - for ( var i = 0, ul = orientations.count; i < ul; i++ ) { + for ( var i = 0, ul = orientations.count; i < ul; i ++ ) { vector.set( Math.random() * 2 - 1, Math.random() * 2 - 1, Math.random() * 2 - 1, Math.random() * 2 - 1 ); vector.normalize(); @@ -244,8 +244,10 @@ if ( renderer.extensions.get( 'ANGLE_instanced_arrays' ) === null ) { + document.getElementById( "notSupported" ).style.display = ""; return; + } renderer.setPixelRatio( window.devicePixelRatio ); @@ -259,7 +261,7 @@ } - function onWindowResize( event ) { + function onWindowResize() { camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix(); @@ -289,7 +291,7 @@ var time = performance.now(); - var object = scene.children[0]; + var object = scene.children[ 0 ]; object.rotation.y = time * 0.00005; @@ -298,16 +300,18 @@ var delta = ( time - lastTime ) / 5000; tmpQ.set( moveQ.x * delta, moveQ.y * delta, moveQ.z * delta, 1 ).normalize(); - for ( var i = 0, ul = orientations.count; i < ul; i++ ) { + for ( var i = 0, ul = orientations.count; i < ul; i ++ ) { + var index = i * instanceBuffer.stride + orientations.offset; - currentQ.set( instanceBuffer.array[index], instanceBuffer.array[index + 1], instanceBuffer.array[index + 2], instanceBuffer.array[index + 3] ); + currentQ.set( instanceBuffer.array[ index ], instanceBuffer.array[ index + 1 ], instanceBuffer.array[ index + 2 ], instanceBuffer.array[ index + 3 ] ); currentQ.multiply( tmpQ ); orientations.setXYZW( i, currentQ.x, currentQ.y, currentQ.z, currentQ.w ); } instanceBuffer.needsUpdate = true; lastTime = time; + } init();
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_buffergeometry_instancing_lambert.html
@@ -319,7 +319,7 @@ } ); material.defines = material.defines || {}; - material.defines[ 'INSTANCED'] = ""; + material.defines[ 'INSTANCED' ] = ""; // custom depth material - required for instanced shadows @@ -373,7 +373,7 @@ } - function onWindowResize( event ) { + function onWindowResize() { renderer.setSize( window.innerWidth, window.innerHeight );
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_buffergeometry_lines_indexed.html
@@ -90,7 +90,7 @@ } // simple Koch curve - + function snowflake_iteration( p0, p4, depth ) { if ( -- depth < 0 ) { @@ -128,7 +128,7 @@ add_vertex( points[ 0 ] ); - for ( var p_index=0, p_count = points.length - 1; p_index != p_count; p_index ++ ) { + for ( var p_index = 0, p_count = points.length - 1; p_index != p_count; p_index ++ ) { snowflake_iteration( points[ p_index ], points[ p_index + 1 ], iteration ); @@ -140,7 +140,7 @@ for ( var p_index = 0, p_count = points.length; p_index != p_count; p_index ++ ) { - points[p_index].x += x_offset; + points[ p_index ].x += x_offset; } @@ -149,8 +149,7 @@ } var y = 0; - snowflake - ( + snowflake( [ new THREE.Vector3( 0, y, 0 ), new THREE.Vector3( 500, y, 0 ) @@ -159,19 +158,17 @@ ); y += 600; - snowflake - ( + snowflake( [ - new THREE.Vector3( 0, y, 0) , + new THREE.Vector3( 0, y, 0 ), new THREE.Vector3( 250, y + 400, 0 ), new THREE.Vector3( 500, y, 0 ) ], true, 600 ); y += 600; - snowflake - ( + snowflake( [ new THREE.Vector3( 0, y, 0 ), new THREE.Vector3( 500, y, 0 ), @@ -182,8 +179,7 @@ ); y += 1000; - snowflake - ( + snowflake( [ new THREE.Vector3( 250, y, 0 ), new THREE.Vector3( 500, y, 0 ),
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_buffergeometry_rawshader.html
@@ -170,7 +170,7 @@ } - function onWindowResize( event ) { + function onWindowResize() { camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix();
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_buffergeometry_uint.html
@@ -77,7 +77,7 @@ scene.add( light1 ); var light2 = new THREE.DirectionalLight( 0xffffff, 1.5 ); - light2.position.set( 0, -1, 0 ); + light2.position.set( 0, - 1, 0 ); scene.add( light2 ); //
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_camera.html
@@ -23,12 +23,9 @@ z-index: 100; } - a { - - color: #0080ff; - } - + a {color: #0080ff; } b { color: lightgreen } + </style> </head> <body> @@ -125,9 +122,9 @@ for ( var i = 0; i < 10000; i ++ ) { - vertices.push( THREE.Math.randFloatSpread( 2000 ) ); // x - vertices.push( THREE.Math.randFloatSpread( 2000 ) ); // y - vertices.push( THREE.Math.randFloatSpread( 2000 ) ); // z + vertices.push( THREE.Math.randFloatSpread( 2000 ) ); // x + vertices.push( THREE.Math.randFloatSpread( 2000 ) ); // y + vertices.push( THREE.Math.randFloatSpread( 2000 ) ); // z } @@ -138,7 +135,6 @@ // - renderer = new THREE.WebGLRenderer( { antialias: true } ); renderer.setPixelRatio( window.devicePixelRatio ); renderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT ); @@ -160,9 +156,9 @@ // - function onKeyDown ( event ) { + function onKeyDown( event ) { - switch( event.keyCode ) { + switch ( event.keyCode ) { case 79: /*O*/ @@ -184,7 +180,7 @@ // - function onWindowResize( event ) { + function onWindowResize() { SCREEN_WIDTH = window.innerWidth; SCREEN_HEIGHT = window.innerHeight; @@ -198,9 +194,9 @@ cameraPerspective.aspect = 0.5 * aspect; cameraPerspective.updateProjectionMatrix(); - cameraOrtho.left = - 0.5 * frustumSize * aspect / 2; - cameraOrtho.right = 0.5 * frustumSize * aspect / 2; - cameraOrtho.top = frustumSize / 2; + cameraOrtho.left = - 0.5 * frustumSize * aspect / 2; + cameraOrtho.right = 0.5 * frustumSize * aspect / 2; + cameraOrtho.top = frustumSize / 2; cameraOrtho.bottom = - frustumSize / 2; cameraOrtho.updateProjectionMatrix(); @@ -258,12 +254,12 @@ activeHelper.visible = false; - renderer.setViewport( 0, 0, SCREEN_WIDTH/2, SCREEN_HEIGHT ); + renderer.setViewport( 0, 0, SCREEN_WIDTH / 2, SCREEN_HEIGHT ); renderer.render( scene, activeCamera ); activeHelper.visible = true; - renderer.setViewport( SCREEN_WIDTH/2, 0, SCREEN_WIDTH/2, SCREEN_HEIGHT ); + renderer.setViewport( SCREEN_WIDTH / 2, 0, SCREEN_WIDTH / 2, SCREEN_HEIGHT ); renderer.render( scene, camera ); }
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_camera_cinematic.html
@@ -86,7 +86,7 @@ window.addEventListener( 'resize', onWindowResize, false ); - var effectController = { + var effectController = { focalLength: 15, // jsDepthCalculation: true, @@ -114,7 +114,7 @@ }; - var matChanger = function( ) { + var matChanger = function ( ) { for ( var e in effectController ) { @@ -197,7 +197,7 @@ var targetDistance = intersects[ 0 ].distance; - camera.focusAt( targetDistance ); // using Cinematic camera focusAt method + camera.focusAt( targetDistance ); // using Cinematic camera focusAt method if ( INTERSECTED != intersects[ 0 ].object ) { @@ -206,6 +206,7 @@ INTERSECTED = intersects[ 0 ].object; INTERSECTED.currentHex = INTERSECTED.material.emissive.getHex(); INTERSECTED.material.emissive.setHex( 0xff0000 ); + } } else {
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_camera_logarithmicdepthbuffer.html
@@ -40,10 +40,6 @@ display: block; text-align: center; } - .renderer_label.renderer_label_normal { - } - .renderer_label.renderer_label_logzbuf { - } #container { white-space: nowrap; } @@ -75,7 +71,7 @@ <body> <div id="container"> - <div id="container_normal"><h2 class="renderer_label renderer_label_normal">normal z-buffer</h2></div><div id="container_logzbuf"><h2 class="renderer_label renderer_label_logzbuf">logarithmic z-buffer</h2></div> + <div id="container_normal"><h2 class="renderer_label">normal z-buffer</h2></div><div id="container_logzbuf"><h2 class="renderer_label">logarithmic z-buffer</h2></div> <div id="renderer_border"></div> </div> @@ -96,8 +92,8 @@ var SCREEN_WIDTH = window.innerWidth; var SCREEN_HEIGHT = window.innerHeight; var screensplit = .25, screensplit_right = 0; - var mouse = [.5, .5]; - var zoompos = -100, minzoomspeed = .015; + var mouse = [ .5, .5 ]; + var zoompos = - 100, minzoomspeed = .015; var zoomspeed = minzoomspeed; var container, border, stats; @@ -107,23 +103,23 @@ // Try to use some descriptive real-world examples of objects at each scale var labeldata = [ - { size: .01, scale: 0.0001, label: "microscopic (1µm)" }, // FIXME - triangulating text fails at this size, so we scale instead - { size: .01, scale: 0.1, label: "minuscule (1mm)" }, - { size: .01, scale: 1.0, label: "tiny (1cm)" }, - { size: 1, scale: 1.0, label: "child-sized (1m)" }, - { size: 10, scale: 1.0, label: "tree-sized (10m)" }, - { size: 100, scale: 1.0, label: "building-sized (100m)" }, - { size: 1000, scale: 1.0, label: "medium (1km)" }, - { size: 10000, scale: 1.0, label: "city-sized (10km)" }, - { size: 3400000, scale: 1.0, label: "moon-sized (3,400 Km)" }, - { size: 12000000, scale: 1.0, label: "planet-sized (12,000 km)" }, - { size: 1400000000, scale: 1.0, label: "sun-sized (1,400,000 km)" }, - { size: 7.47e12, scale: 1.0, label: "solar system-sized (50Au)" }, - { size: 9.4605284e15, scale: 1.0, label: "gargantuan (1 light year)" }, - { size: 3.08567758e16, scale: 1.0, label: "ludicrous (1 parsec)" }, - { size: 1e19, scale: 1.0, label: "mind boggling (1000 light years)" }, - { size: 1.135e21, scale: 1.0, label: "galaxy-sized (120,000 light years)" }, - { size: 9.46e23, scale: 1.0, label: "... (100,000,000 light years)" } + { size: .01, scale: 0.0001, label: "microscopic (1µm)" }, // FIXME - triangulating text fails at this size, so we scale instead + { size: .01, scale: 0.1, label: "minuscule (1mm)" }, + { size: .01, scale: 1.0, label: "tiny (1cm)" }, + { size: 1, scale: 1.0, label: "child-sized (1m)" }, + { size: 10, scale: 1.0, label: "tree-sized (10m)" }, + { size: 100, scale: 1.0, label: "building-sized (100m)" }, + { size: 1000, scale: 1.0, label: "medium (1km)" }, + { size: 10000, scale: 1.0, label: "city-sized (10km)" }, + { size: 3400000, scale: 1.0, label: "moon-sized (3,400 Km)" }, + { size: 12000000, scale: 1.0, label: "planet-sized (12,000 km)" }, + { size: 1400000000, scale: 1.0, label: "sun-sized (1,400,000 km)" }, + { size: 7.47e12, scale: 1.0, label: "solar system-sized (50Au)" }, + { size: 9.4605284e15, scale: 1.0, label: "gargantuan (1 light year)" }, + { size: 3.08567758e16, scale: 1.0, label: "ludicrous (1 parsec)" }, + { size: 1e19, scale: 1.0, label: "mind boggling (1000 light years)" }, + { size: 1.135e21, scale: 1.0, label: "galaxy-sized (120,000 light years)" }, + { size: 9.46e23, scale: 1.0, label: "... (100,000,000 light years)" } ]; init(); @@ -146,7 +142,7 @@ } ); stats = new Stats(); - container.appendChild(stats.dom); + container.appendChild( stats.dom ); // Resize border allows the user to easily compare effects of logarithmic depth buffer over the whole scene border = document.getElementById( 'renderer_border' ); @@ -160,17 +156,17 @@ function initView( scene, name, logDepthBuf ) { - var framecontainer = document.getElementById('container_' + name); + var framecontainer = document.getElementById( 'container_' + name ); var camera = new THREE.PerspectiveCamera( 50, screensplit * SCREEN_WIDTH / SCREEN_HEIGHT, NEAR, FAR ); - scene.add(camera); + scene.add( camera ); - var renderer = new THREE.WebGLRenderer({ antialias: true, logarithmicDepthBuffer: logDepthBuf }); + var renderer = new THREE.WebGLRenderer( { antialias: true, logarithmicDepthBuffer: logDepthBuf } ); renderer.setPixelRatio( window.devicePixelRatio ); - renderer.setSize(SCREEN_WIDTH/2, SCREEN_HEIGHT); + renderer.setSize( SCREEN_WIDTH / 2, SCREEN_HEIGHT ); renderer.domElement.style.position = "relative"; renderer.domElement.id = 'renderer_' + name; - framecontainer.appendChild(renderer.domElement); + framecontainer.appendChild( renderer.domElement ); return { container: framecontainer, renderer: renderer, scene: scene, camera: camera }; @@ -182,9 +178,9 @@ scene.add( new THREE.AmbientLight( 0x222222 ) ); - var light = new THREE.DirectionalLight(0xffffff, 1); - light.position.set(100,100,100); - scene.add(light); + var light = new THREE.DirectionalLight( 0xffffff, 1 ); + light.position.set( 100, 100, 100 ); + scene.add( light ); var materialargs = { color: 0xffffff, @@ -193,16 +189,16 @@ emissive: 0x000000 }; - var geometry = new THREE.SphereBufferGeometry(0.5, 24, 12); + var geometry = new THREE.SphereBufferGeometry( 0.5, 24, 12 ); - for (var i = 0; i < labeldata.length; i++) { + for ( var i = 0; i < labeldata.length; i ++ ) { - var scale = labeldata[i].scale || 1; + var scale = labeldata[ i ].scale || 1; - var labelgeo = new THREE.TextBufferGeometry( labeldata[i].label, { + var labelgeo = new THREE.TextBufferGeometry( labeldata[ i ].label, { font: font, - size: labeldata[i].size, - height: labeldata[i].size / 2 + size: labeldata[ i ].size, + height: labeldata[ i ].size / 2 } ); labelgeo.computeBoundingSphere(); @@ -215,19 +211,19 @@ var material = new THREE.MeshPhongMaterial( materialargs ); var group = new THREE.Group(); - group.position.z = -labeldata[i].size * scale; - scene.add(group); + group.position.z = - labeldata[ i ].size * scale; + scene.add( group ); var textmesh = new THREE.Mesh( labelgeo, material ); - textmesh.scale.set(scale, scale, scale); - textmesh.position.z = -labeldata[i].size * scale; - textmesh.position.y = labeldata[i].size / 4 * scale; - group.add(textmesh); + textmesh.scale.set( scale, scale, scale ); + textmesh.position.z = - labeldata[ i ].size * scale; + textmesh.position.y = labeldata[ i ].size / 4 * scale; + group.add( textmesh ); - var dotmesh = new THREE.Mesh(geometry, material); - dotmesh.position.y = -labeldata[i].size / 4 * scale; - dotmesh.scale.multiplyScalar(labeldata[i].size * scale); - group.add(dotmesh); + var dotmesh = new THREE.Mesh( geometry, material ); + dotmesh.position.y = - labeldata[ i ].size / 4 * scale; + dotmesh.scale.multiplyScalar( labeldata[ i ].size * scale ); + group.add( dotmesh ); } @@ -248,15 +244,15 @@ objects.normal.camera.aspect = screensplit * SCREEN_WIDTH / SCREEN_HEIGHT; objects.normal.camera.updateProjectionMatrix(); objects.normal.camera.setViewOffset( SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, SCREEN_WIDTH * screensplit, SCREEN_HEIGHT ); - objects.normal.container.style.width = (screensplit * 100) + '%'; + objects.normal.container.style.width = ( screensplit * 100 ) + '%'; objects.logzbuf.renderer.setSize( screensplit_right * SCREEN_WIDTH, SCREEN_HEIGHT ); objects.logzbuf.camera.aspect = screensplit_right * SCREEN_WIDTH / SCREEN_HEIGHT; objects.logzbuf.camera.updateProjectionMatrix(); objects.logzbuf.camera.setViewOffset( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_WIDTH * screensplit, 0, SCREEN_WIDTH * screensplit_right, SCREEN_HEIGHT ); - objects.logzbuf.container.style.width = (screensplit_right * 100) + '%'; + objects.logzbuf.container.style.width = ( screensplit_right * 100 ) + '%'; - border.style.left = (screensplit * 100) + "%"; + border.style.left = ( screensplit * 100 ) + "%"; } @@ -270,74 +266,94 @@ function render() { // Put some limits on zooming - var minzoom = labeldata[0].size * labeldata[0].scale*1; - var maxzoom = labeldata[labeldata.length-1].size * labeldata[labeldata.length-1].scale * 100; - var damping = (Math.abs(zoomspeed) > minzoomspeed ? .95 : 1.0); + var minzoom = labeldata[ 0 ].size * labeldata[ 0 ].scale * 1; + var maxzoom = labeldata[ labeldata.length - 1 ].size * labeldata[ labeldata.length - 1 ].scale * 100; + var damping = ( Math.abs( zoomspeed ) > minzoomspeed ? .95 : 1.0 ); // Zoom out faster the further out you go - var zoom = THREE.Math.clamp(Math.pow(Math.E, zoompos), minzoom, maxzoom); - zoompos = Math.log(zoom); + var zoom = THREE.Math.clamp( Math.pow( Math.E, zoompos ), minzoom, maxzoom ); + zoompos = Math.log( zoom ); // Slow down quickly at the zoom limits - if ((zoom == minzoom && zoomspeed < 0) || (zoom == maxzoom && zoomspeed > 0)) { + if ( ( zoom == minzoom && zoomspeed < 0 ) || ( zoom == maxzoom && zoomspeed > 0 ) ) { + damping = .85; + } zoompos += zoomspeed; zoomspeed *= damping; - objects.normal.camera.position.x = Math.sin(.5 * Math.PI * (mouse[0] - .5)) * zoom; - objects.normal.camera.position.y = Math.sin(.25 * Math.PI * (mouse[1] - .5)) * zoom; - objects.normal.camera.position.z = Math.cos(.5 * Math.PI * (mouse[0] - .5)) * zoom; - objects.normal.camera.lookAt(objects.normal.scene.position); + objects.normal.camera.position.x = Math.sin( .5 * Math.PI * ( mouse[ 0 ] - .5 ) ) * zoom; + objects.normal.camera.position.y = Math.sin( .25 * Math.PI * ( mouse[ 1 ] - .5 ) ) * zoom; + objects.normal.camera.position.z = Math.cos( .5 * Math.PI * ( mouse[ 0 ] - .5 ) ) * zoom; + objects.normal.camera.lookAt( objects.normal.scene.position ); // Clone camera settings across both scenes - objects.logzbuf.camera.position.copy(objects.normal.camera.position); - objects.logzbuf.camera.quaternion.copy(objects.normal.camera.quaternion); + objects.logzbuf.camera.position.copy( objects.normal.camera.position ); + objects.logzbuf.camera.quaternion.copy( objects.normal.camera.quaternion ); // Update renderer sizes if the split has changed - if (screensplit_right != 1 - screensplit) { + if ( screensplit_right != 1 - screensplit ) { + updateRendererSizes(); + } - objects.normal.renderer.render(objects.normal.scene, objects.normal.camera); - objects.logzbuf.renderer.render(objects.logzbuf.scene, objects.logzbuf.camera); + objects.normal.renderer.render( objects.normal.scene, objects.normal.camera ); + objects.logzbuf.renderer.render( objects.logzbuf.scene, objects.logzbuf.camera ); stats.update(); } - function onWindowResize(event) { + function onWindowResize() { + updateRendererSizes(); + } - function onBorderMouseDown(ev) { + function onBorderMouseDown( ev ) { + // activate draggable window resizing bar - window.addEventListener("mousemove", onBorderMouseMove); - window.addEventListener("mouseup", onBorderMouseUp); + window.addEventListener( "mousemove", onBorderMouseMove ); + window.addEventListener( "mouseup", onBorderMouseUp ); ev.stopPropagation(); ev.preventDefault(); + } - function onBorderMouseMove(ev) { - screensplit = Math.max(0, Math.min(1, ev.clientX / window.innerWidth)); + + function onBorderMouseMove( ev ) { + + screensplit = Math.max( 0, Math.min( 1, ev.clientX / window.innerWidth ) ); ev.stopPropagation(); + } - function onBorderMouseUp(ev) { - window.removeEventListener("mousemove", onBorderMouseMove); - window.removeEventListener("mouseup", onBorderMouseUp); + + function onBorderMouseUp() { + + window.removeEventListener( "mousemove", onBorderMouseMove ); + window.removeEventListener( "mouseup", onBorderMouseUp ); + } - function onMouseMove(ev) { - mouse[0] = ev.clientX / window.innerWidth; - mouse[1] = ev.clientY / window.innerHeight; + + function onMouseMove( ev ) { + + mouse[ 0 ] = ev.clientX / window.innerWidth; + mouse[ 1 ] = ev.clientY / window.innerHeight; + } - function onMouseWheel(ev) { + + function onMouseWheel( ev ) { + var amount = ev.deltaY; if ( amount === 0 ) return; - var dir = amount / Math.abs(amount); - zoomspeed = dir/10; + var dir = amount / Math.abs( amount ); + zoomspeed = dir / 10; // Slow down default zoom speed after user starts zooming, to give them more control minzoomspeed = 0.001; + } </script> </body>
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_clipping.html
@@ -72,15 +72,15 @@ // Geometry var material = new THREE.MeshPhongMaterial( { - color: 0x80ee10, - shininess: 100, - side: THREE.DoubleSide, + color: 0x80ee10, + shininess: 100, + side: THREE.DoubleSide, - // ***** Clipping setup (material): ***** - clippingPlanes: [ localPlane ], - clipShadows: true + // ***** Clipping setup (material): ***** + clippingPlanes: [ localPlane ], + clipShadows: true - } ); + } ); var geometry = new THREE.TorusKnotBufferGeometry( 0.4, 0.08, 95, 20 ); @@ -89,9 +89,9 @@ scene.add( object ); var ground = new THREE.Mesh( - new THREE.PlaneBufferGeometry( 9, 9, 1, 1 ), - new THREE.MeshPhongMaterial( { color: 0xa0adaf, shininess: 150 } ) - ); + new THREE.PlaneBufferGeometry( 9, 9, 1, 1 ), + new THREE.MeshPhongMaterial( { color: 0xa0adaf, shininess: 150 } ) + ); ground.rotation.x = - Math.PI / 2; // rotates X/Y to X/Z ground.receiveShadow = true; @@ -129,26 +129,65 @@ folderLocal = gui.addFolder( 'Local Clipping' ), propsLocal = { - get 'Enabled'() { return renderer.localClippingEnabled; }, - set 'Enabled'( v ) { renderer.localClippingEnabled = v; }, + get 'Enabled'() { - get 'Shadows'() { return material.clipShadows; }, - set 'Shadows'( v ) { material.clipShadows = v; }, + return renderer.localClippingEnabled; - get 'Plane'() { return localPlane.constant; }, - set 'Plane'( v ) { localPlane.constant = v } + }, + set 'Enabled'( v ) { + + renderer.localClippingEnabled = v; + + }, + + get 'Shadows'() { + + return material.clipShadows; + + }, + set 'Shadows'( v ) { + + material.clipShadows = v; + + }, + + get 'Plane'() { + + return localPlane.constant; + + }, + set 'Plane'( v ) { + + localPlane.constant = v; + + } }, folderGlobal = gui.addFolder( 'Global Clipping' ), propsGlobal = { - get 'Enabled'() { return renderer.clippingPlanes !== Empty; }, - set 'Enabled'( v ) { - renderer.clippingPlanes = v ? globalPlanes : Empty; }, + get 'Enabled'() { + + return renderer.clippingPlanes !== Empty; + + }, + set 'Enabled'( v ) { + + renderer.clippingPlanes = v ? globalPlanes : Empty; + + }, + + get 'Plane'() { + + return globalPlane.constant; + + }, + set 'Plane'( v ) { + + globalPlane.constant = v; - get 'Plane'() { return globalPlane.constant; }, - set 'Plane'( v ) { globalPlane.constant = v; } + } }; @@ -157,7 +196,7 @@ folderLocal.add( propsLocal, 'Plane', 0.3, 1.25 ); folderGlobal.add( propsGlobal, 'Enabled' ); - folderGlobal.add( propsGlobal, 'Plane', -0.4, 3 ); + folderGlobal.add( propsGlobal, 'Plane', - 0.4, 3 ); // Start
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_clipping_advanced.html
@@ -23,6 +23,7 @@ <script> function planesFromMesh( vertices, indices ) { + // creates a clipping volume from a convex triangular mesh // specified by the arrays 'vertices' and 'indices' @@ -31,12 +32,12 @@ for ( var i = 0, j = 0; i < n; ++ i, j += 3 ) { - var a = vertices[ indices[ j ] ], + var a = vertices[ indices[ j ] ], b = vertices[ indices[ j + 1 ] ], c = vertices[ indices[ j + 2 ] ]; result[ i ] = new THREE.Plane(). - setFromCoplanarPoints( a, b, c ); + setFromCoplanarPoints( a, b, c ); } @@ -45,6 +46,7 @@ } function createPlanes( n ) { + // creates an array of n uninitialized plane objects var result = new Array( n ); @@ -57,6 +59,7 @@ } function assignTransformedPlanes( planesOut, planesIn, matrix ) { + // sets an array of existing planes to transformed 'planesIn' for ( var i = 0, n = planesIn.length; i !== n; ++ i ) @@ -74,7 +77,7 @@ angle = i * Math.PI * 2 / n; plane.normal.set( - Math.cos( angle ), 0, Math.sin( angle ) ); + Math.cos( angle ), 0, Math.sin( angle ) ); plane.constant = innerRadius; @@ -84,7 +87,8 @@ } - var planeToMatrix = ( function() { + var planeToMatrix = ( function () { + // creates a matrix that aligns X/Y to a given plane // temporaries: @@ -102,11 +106,11 @@ if ( Math.abs( zAxis.x ) > Math.abs( zAxis.z ) ) { - yAxis.set( -zAxis.y, zAxis.x, 0 ); + yAxis.set( - zAxis.y, zAxis.x, 0 ); } else { - yAxis.set( 0, -zAxis.z, zAxis.y ); + yAxis.set( 0, - zAxis.z, zAxis.y ); } @@ -117,7 +121,7 @@ xAxis.x, yAxis.x, zAxis.x, trans.x, xAxis.y, yAxis.y, zAxis.y, trans.y, xAxis.z, yAxis.z, zAxis.z, trans.z, - 0, 0, 0, 1 ); + 0, 0, 0, 1 ); }; @@ -127,10 +131,10 @@ // A regular tetrahedron for the clipping volume: var Vertices = [ - new THREE.Vector3( + 1, 0, + Math.SQRT1_2 ), - new THREE.Vector3( - 1, 0, + Math.SQRT1_2 ), - new THREE.Vector3( 0, + 1, - Math.SQRT1_2 ), - new THREE.Vector3( 0, - 1, - Math.SQRT1_2 ) + new THREE.Vector3( + 1, 0, + Math.SQRT1_2 ), + new THREE.Vector3( - 1, 0, + Math.SQRT1_2 ), + new THREE.Vector3( 0, + 1, - Math.SQRT1_2 ), + new THREE.Vector3( 0, - 1, - Math.SQRT1_2 ) ], Indices = [ @@ -154,7 +158,7 @@ function init() { camera = new THREE.PerspectiveCamera( - 36, window.innerWidth / window.innerHeight, 0.25, 16 ); + 36, window.innerWidth / window.innerHeight, 0.25, 16 ); camera.position.set( 0, 1.5, 3 ); @@ -205,16 +209,16 @@ var geometry = new THREE.BoxBufferGeometry( 0.18, 0.18, 0.18 ); - for ( var z = -2; z <= 2; ++ z ) - for ( var y = -2; y <= 2; ++ y ) - for ( var x = -2; x <= 2; ++ x ) { + for ( var z = - 2; z <= 2; ++ z ) + for ( var y = - 2; y <= 2; ++ y ) + for ( var x = - 2; x <= 2; ++ x ) { - var mesh = new THREE.Mesh( geometry, clipMaterial ); - mesh.position.set( x / 5, y / 5, z / 5 ); - mesh.castShadow = true; - object.add( mesh ); + var mesh = new THREE.Mesh( geometry, clipMaterial ); + mesh.position.set( x / 5, y / 5, z / 5 ); + mesh.castShadow = true; + object.add( mesh ); - } + } scene.add( object ); @@ -230,7 +234,7 @@ for ( var i = 0, n = Planes.length; i !== n; ++ i ) { var material = new THREE.MeshBasicMaterial( { - color: color.setHSL( i / n, 0.5, 0.5 ).getHex(), + color: color.setHSL( i / n, 0.5, 0.5 ).getHex(), side: THREE.DoubleSide, opacity: 0.2, @@ -239,24 +243,28 @@ // clip to the others to show the volume (wildly // intersecting transparent planes look bad) clippingPlanes: clipMaterial.clippingPlanes. - filter( function( _, j ) { return j !== i; } ) + filter( function ( _, j ) { + + return j !== i; + + } ) // no need to enable shadow clipping - the plane // visualization does not cast shadows } ); volumeVisualization.add( - new THREE.Mesh( planeGeometry, material ) ); + new THREE.Mesh( planeGeometry, material ) ); } scene.add( volumeVisualization ); var ground = new THREE.Mesh( planeGeometry, - new THREE.MeshPhongMaterial( { - color: 0xa0adaf, shininess: 150 } ) ); + new THREE.MeshPhongMaterial( { + color: 0xa0adaf, shininess: 150 } ) ); ground.rotation.x = - Math.PI / 2; ground.scale.multiplyScalar( 3 ); ground.receiveShadow = true; @@ -293,30 +301,60 @@ var gui = new dat.GUI(), folder = gui.addFolder( "Local Clipping" ), props = { - get 'Enabled'() { return renderer.localClippingEnabled; }, + get 'Enabled'() { + + return renderer.localClippingEnabled; + + }, set 'Enabled'( v ) { - renderer.localClippingEnabled = v; - if ( ! v ) volumeVisualization.visible = false; }, - get 'Shadows'() { return clipMaterial.clipShadows; }, - set 'Shadows'( v ) { clipMaterial.clipShadows = v; }, + renderer.localClippingEnabled = v; + if ( ! v ) volumeVisualization.visible = false; + + }, + + get 'Shadows'() { + + return clipMaterial.clipShadows; + + }, + set 'Shadows'( v ) { - get 'Visualize'() { return volumeVisualization.visible; }, + clipMaterial.clipShadows = v; + + }, + + get 'Visualize'() { + + return volumeVisualization.visible; + + }, set 'Visualize'( v ) { - if ( renderer.localClippingEnabled ) - volumeVisualization.visible = v; } + + if ( renderer.localClippingEnabled ) + volumeVisualization.visible = v; + + } }; folder.add( props, 'Enabled' ); folder.add( props, 'Shadows' ); folder.add( props, 'Visualize' ).listen(); gui.addFolder( "Global Clipping" ). - add( { - get 'Enabled'() { return renderer.clippingPlanes !== Empty; }, - set 'Enabled'( v ) { renderer.clippingPlanes = v ? - globalClippingPlanes : Empty; } - }, "Enabled" ); + add( { + get 'Enabled'() { + + return renderer.clippingPlanes !== Empty; + + }, + set 'Enabled'( v ) { + + renderer.clippingPlanes = v ? + globalClippingPlanes : Empty; + + } + }, "Enabled" ); // Start @@ -335,6 +373,7 @@ } function setObjectWorldMatrix( object, matrix ) { + // set the orientation of an object based on a world matrix var parent = object.parent; @@ -363,10 +402,10 @@ var bouncy = Math.cos( time * .5 ) * 0.5 + 0.7; transform.multiply( - tmpMatrix.makeScale( bouncy, bouncy, bouncy ) ); + tmpMatrix.makeScale( bouncy, bouncy, bouncy ) ); assignTransformedPlanes( - clipMaterial.clippingPlanes, Planes, transform ); + clipMaterial.clippingPlanes, Planes, transform ); var planeMeshes = volumeVisualization.children; @@ -380,7 +419,7 @@ transform.makeRotationY( time * 0.1 ); assignTransformedPlanes( - globalClippingPlanes, GlobalClippingPlanes, transform ); + globalClippingPlanes, GlobalClippingPlanes, transform ); stats.begin(); renderer.render( scene, camera );
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_custom_attributes.html
@@ -110,8 +110,8 @@ uniforms = { amplitude: { value: 1.0 }, - color: { value: new THREE.Color( 0xff2200 ) }, - texture: { value: new THREE.TextureLoader().load( "textures/water.jpg" ) } + color: { value: new THREE.Color( 0xff2200 ) }, + texture: { value: new THREE.TextureLoader().load( "textures/water.jpg" ) } }; @@ -120,10 +120,10 @@ var shaderMaterial = new THREE.ShaderMaterial( { uniforms: uniforms, - vertexShader:document.getElementById( 'vertexshader' ).textContent, + vertexShader: document.getElementById( 'vertexshader' ).textContent, fragmentShader: document.getElementById( 'fragmentshader' ).textContent - }); + } ); var radius = 50, segments = 128, rings = 64; @@ -192,7 +192,7 @@ displacement[ i ] = Math.sin( 0.1 * i + time ); noise[ i ] += 0.5 * ( 0.5 - Math.random() ); - noise[ i ] = THREE.Math.clamp( noise[ i ], -5, 5 ); + noise[ i ] = THREE.Math.clamp( noise[ i ], - 5, 5 ); displacement[ i ] += noise[ i ];
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_custom_attributes_lines.html
@@ -104,21 +104,21 @@ uniforms = { amplitude: { value: 5.0 }, - opacity: { value: 0.3 }, - color: { value: new THREE.Color( 0xffffff ) } + opacity: { value: 0.3 }, + color: { value: new THREE.Color( 0xffffff ) } }; var shaderMaterial = new THREE.ShaderMaterial( { - uniforms: uniforms, - vertexShader: document.getElementById( 'vertexshader' ).textContent, + uniforms: uniforms, + vertexShader: document.getElementById( 'vertexshader' ).textContent, fragmentShader: document.getElementById( 'fragmentshader' ).textContent, - blending: THREE.AdditiveBlending, - depthTest: false, - transparent: true + blending: THREE.AdditiveBlending, + depthTest: false, + transparent: true - }); + } ); var geometry = new THREE.TextBufferGeometry( 'three.js', { @@ -148,7 +148,7 @@ var color = new THREE.Color( 0xffffff ); - for( var i = 0, l = customColor.count; i < l; i ++ ) { + for ( var i = 0, l = customColor.count; i < l; i ++ ) { color.setHSL( i / l, 0.5, 0.5 ); color.toArray( customColor.array, i * customColor.itemSize ); @@ -207,7 +207,7 @@ for ( var i = 0, l = array.length; i < l; i += 3 ) { - array[ i ] += 0.3 * ( 0.5 - Math.random() ); + array[ i ] += 0.3 * ( 0.5 - Math.random() ); array[ i + 1 ] += 0.3 * ( 0.5 - Math.random() ); array[ i + 2 ] += 0.3 * ( 0.5 - Math.random() );
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_custom_attributes_points.html
@@ -87,8 +87,6 @@ var sphere; - var noise = []; - var WIDTH = window.innerWidth; var HEIGHT = window.innerHeight; @@ -146,17 +144,17 @@ uniforms: { amplitude: { value: 1.0 }, - color: { value: new THREE.Color( 0xffffff ) }, - texture: { value: new THREE.TextureLoader().load( "textures/sprites/spark1.png" ) } + color: { value: new THREE.Color( 0xffffff ) }, + texture: { value: new THREE.TextureLoader().load( "textures/sprites/spark1.png" ) } }, - vertexShader: document.getElementById( 'vertexshader' ).textContent, + vertexShader: document.getElementById( 'vertexshader' ).textContent, fragmentShader: document.getElementById( 'fragmentshader' ).textContent, - blending: THREE.AdditiveBlending, - depthTest: false, - transparent: true + blending: THREE.AdditiveBlending, + depthTest: false, + transparent: true - }); + } ); // @@ -208,7 +206,7 @@ var geometry = sphere.geometry; var attributes = geometry.attributes; - for ( var i = 0; i < attributes.size.array.length; i++ ) { + for ( var i = 0; i < attributes.size.array.length; i ++ ) { attributes.size.array[ i ] = 14 + 13 * Math.sin( 0.1 * i + time );
true