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
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_loader_sea3d_skinning.html
@@ -86,7 +86,7 @@ } ); - loader.onComplete = function ( e ) { + loader.onComplete = function () { // Get the first camera from SEA3D Studio // use loader.get... to get others objects @@ -95,7 +95,7 @@ camera.position.copy( cam.position ); camera.rotation.copy( cam.rotation ); - controls = new THREE.OrbitControls( camera ); + var controls = new THREE.OrbitControls( camera ); // get meshes player = loader.getMesh( "Player" );
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_loader_sea3d_sound.html
@@ -135,7 +135,7 @@ } ); - loader.onComplete = function ( e ) { + loader.onComplete = function () { audioListener = loader.audioListener; @@ -183,11 +183,10 @@ var element = document.body; - var pointerlockchange = function ( event ) { + var pointerlockchange = function () { if ( document.pointerLockElement === element || document.mozPointerLockElement === element || document.webkitPointerLockElement === element ) { - controlsEnabled = true; controls.enabled = true; blocker.style.display = 'none'; @@ -206,7 +205,7 @@ }; - var pointerlockerror = function ( event ) { + var pointerlockerror = function () { instructions.style.display = ''; @@ -221,7 +220,7 @@ document.addEventListener( 'mozpointerlockerror', pointerlockerror, false ); document.addEventListener( 'webkitpointerlockerror', pointerlockerror, false ); - instructions.addEventListener( 'click', function ( event ) { + instructions.addEventListener( 'click', function () { instructions.style.display = 'none';
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_loader_stl.html
@@ -30,7 +30,6 @@ span { display: inline-block; width: 60px; - float: left; text-align: center; } @@ -72,7 +71,7 @@ camera = new THREE.PerspectiveCamera( 35, window.innerWidth / window.innerHeight, 1, 15 ); camera.position.set( 3, 0.15, 3 ); - cameraTarget = new THREE.Vector3( 0, -0.25, 0 ); + cameraTarget = new THREE.Vector3( 0, - 0.25, 0 ); scene = new THREE.Scene(); scene.background = new THREE.Color( 0x72645b ); @@ -85,8 +84,8 @@ new THREE.PlaneBufferGeometry( 40, 40 ), new THREE.MeshPhongMaterial( { color: 0x999999, specular: 0x101010 } ) ); - plane.rotation.x = -Math.PI/2; - plane.position.y = -0.5; + plane.rotation.x = - Math.PI / 2; + plane.position.y = - 0.5; scene.add( plane ); plane.receiveShadow = true; @@ -150,8 +149,10 @@ loader.load( './models/stl/binary/colored.stl', function ( geometry ) { var meshMaterial = material; - if (geometry.hasColors) { - meshMaterial = new THREE.MeshPhongMaterial({ opacity: geometry.alpha, vertexColors: THREE.VertexColors }); + if ( geometry.hasColors ) { + + meshMaterial = new THREE.MeshPhongMaterial( { opacity: geometry.alpha, vertexColors: THREE.VertexColors } ); + } var mesh = new THREE.Mesh( geometry, meshMaterial ); @@ -173,7 +174,7 @@ scene.add( new THREE.HemisphereLight( 0x443333, 0x111122 ) ); addShadowedLight( 1, 1, 1, 0xffffff, 1.35 ); - addShadowedLight( 0.5, 1, -1, 0xffaa00, 1 ); + addShadowedLight( 0.5, 1, - 1, 0xffaa00, 1 ); // renderer renderer = new THREE.WebGLRenderer( { antialias: true } ); @@ -207,18 +208,18 @@ directionalLight.castShadow = true; var d = 1; - directionalLight.shadow.camera.left = -d; + directionalLight.shadow.camera.left = - d; directionalLight.shadow.camera.right = d; directionalLight.shadow.camera.top = d; - directionalLight.shadow.camera.bottom = -d; + directionalLight.shadow.camera.bottom = - d; directionalLight.shadow.camera.near = 1; directionalLight.shadow.camera.far = 4; directionalLight.shadow.mapSize.width = 1024; directionalLight.shadow.mapSize.height = 1024; - directionalLight.shadow.bias = -0.002; + directionalLight.shadow.bias = - 0.002; }
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_loader_svg.html
@@ -79,7 +79,7 @@ group.scale.multiplyScalar( 0.25 ); group.position.x = - 70; group.position.y = 70; - group.scale.y *= -1; + group.scale.y *= - 1; for ( var i = 0; i < paths.length; i ++ ) { @@ -136,7 +136,7 @@ var group = scene.children[ 1 ]; group.traverse( function ( child ) { - if ( child.material ) child.material.wireframe = !child.material.wireframe; + if ( child.material ) child.material.wireframe = ! child.material.wireframe; } );
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_loader_texture_dds.html
@@ -92,24 +92,30 @@ map6.anisotropy = 4; var cubemap1 = loader.load( 'textures/compressed/Mountains.dds', function ( texture ) { + texture.magFilter = THREE.LinearFilter; texture.minFilter = THREE.LinearFilter; texture.mapping = THREE.CubeReflectionMapping; material1.needsUpdate = true; + } ); var cubemap2 = loader.load( 'textures/compressed/Mountains_argb_mip.dds', function ( texture ) { + texture.magFilter = THREE.LinearFilter; texture.minFilter = THREE.LinearFilter; texture.mapping = THREE.CubeReflectionMapping; material5.needsUpdate = true; + } ); var cubemap3 = loader.load( 'textures/compressed/Mountains_argb_nomip.dds', function ( texture ) { + texture.magFilter = THREE.LinearFilter; texture.minFilter = THREE.LinearFilter; texture.mapping = THREE.CubeReflectionMapping; material6.needsUpdate = true; + } ); var material1 = new THREE.MeshBasicMaterial( { map: map1, envMap: cubemap1 } ); @@ -123,25 +129,25 @@ var mesh = new THREE.Mesh( new THREE.TorusBufferGeometry( 100, 50, 32, 16 ), material1 ); - mesh.position.x = -600; - mesh.position.y = -200; + mesh.position.x = - 600; + mesh.position.y = - 200; scene.add( mesh ); meshes.push( mesh ); mesh = new THREE.Mesh( geometry, material2 ); - mesh.position.x = -200; - mesh.position.y = -200; + mesh.position.x = - 200; + mesh.position.y = - 200; scene.add( mesh ); meshes.push( mesh ); mesh = new THREE.Mesh( geometry, material3 ); - mesh.position.x = -200; + mesh.position.x = - 200; mesh.position.y = 200; scene.add( mesh ); meshes.push( mesh ); mesh = new THREE.Mesh( geometry, material4 ); - mesh.position.x = -600; + mesh.position.x = - 600; mesh.position.y = 200; scene.add( mesh ); meshes.push( mesh ); @@ -154,13 +160,13 @@ mesh = new THREE.Mesh( geometry, material6 ); mesh.position.x = 200; - mesh.position.y = -200; + mesh.position.y = - 200; scene.add( mesh ); meshes.push( mesh ); mesh = new THREE.Mesh( geometry, material7 ); mesh.position.x = 600; - mesh.position.y = -200; + mesh.position.y = - 200; scene.add( mesh ); meshes.push( mesh ); @@ -170,7 +176,6 @@ scene.add( mesh ); meshes.push( mesh ); - renderer = new THREE.WebGLRenderer( { antialias: true } ); renderer.setPixelRatio( window.devicePixelRatio ); renderer.setSize( window.innerWidth, window.innerHeight );
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_loader_texture_exr.html
@@ -100,7 +100,7 @@ var container, stats; var camera, scene, renderer; - var materialHDR, quad, gamma, exposure; + var materialHDR, quad; init(); @@ -115,7 +115,7 @@ var loader = new THREE.EXRLoader(); - loader.load( "textures/piz_compressed.exr", function( texture, textureData ) { + loader.load( "textures/piz_compressed.exr", function ( texture, textureData ) { console.log( textureData.header ); // exr header @@ -125,17 +125,17 @@ materialHDR = new THREE.ShaderMaterial( { uniforms: { - tDiffuse: { value: texture }, - exposure: { value: 1.0 }, + tDiffuse: { value: texture }, + exposure: { value: 1.0 }, brightMax: { value: 18.0 } - }, + }, vertexShader: getText( 'vs-hdr' ), fragmentShader: getText( 'fs-hdr' ) } ); quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( textureData.width, textureData.height ), materialHDR ); - quad.position.z = -100; + quad.position.z = - 100; scene.add( quad ); animate();
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_loader_texture_hdr.html
@@ -76,7 +76,7 @@ camera = new THREE.OrthographicCamera( - aspect, aspect, 1, - 1, 0, 1 ); - new THREE.RGBELoader().load( 'textures/miranda_uncropped.hdr', function( texture, textureData ) { + new THREE.RGBELoader().load( 'textures/miranda_uncropped.hdr', function ( texture, textureData ) { //console.log( textureData ); //console.log( texture );
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_loader_texture_pvrtc.html
@@ -62,7 +62,7 @@ // - var onCube1Loaded = function( texture ){ + var onCube1Loaded = function ( texture ) { texture.magFilter = THREE.LinearFilter; texture.minFilter = THREE.LinearFilter; @@ -71,7 +71,7 @@ }; - var onCube2Loaded = function( texture ){ + var onCube2Loaded = function ( texture ) { texture.magFilter = THREE.LinearFilter; // texture.minFilter = THREE.LinearMipMapNearestFilter; @@ -85,25 +85,25 @@ var loader = new THREE.PVRLoader(); - var disturb_4bpp_rgb = loader.load( 'textures/compressed/disturb_4bpp_rgb.pvr'); - var disturb_4bpp_rgb_v3 = loader.load( 'textures/compressed/disturb_4bpp_rgb_v3.pvr'); - var disturb_4bpp_rgb_mips = loader.load( 'textures/compressed/disturb_4bpp_rgb_mips.pvr'); - var disturb_2bpp_rgb = loader.load( 'textures/compressed/disturb_2bpp_rgb.pvr'); - var flare_4bpp_rgba = loader.load( 'textures/compressed/flare_4bpp_rgba.pvr'); - var flare_2bpp_rgba = loader.load( 'textures/compressed/flare_2bpp_rgba.pvr'); - var park3_cube_nomip_4bpp_rgb = loader.load( 'textures/compressed/park3_cube_nomip_4bpp_rgb.pvr', onCube1Loaded ); - var park3_cube_mip_2bpp_rgb_v3 = loader.load( 'textures/compressed/park3_cube_mip_2bpp_rgb_v3.pvr', onCube2Loaded ); + var disturb_4bpp_rgb = loader.load( 'textures/compressed/disturb_4bpp_rgb.pvr' ); + var disturb_4bpp_rgb_v3 = loader.load( 'textures/compressed/disturb_4bpp_rgb_v3.pvr' ); + var disturb_4bpp_rgb_mips = loader.load( 'textures/compressed/disturb_4bpp_rgb_mips.pvr' ); + var disturb_2bpp_rgb = loader.load( 'textures/compressed/disturb_2bpp_rgb.pvr' ); + var flare_4bpp_rgba = loader.load( 'textures/compressed/flare_4bpp_rgba.pvr' ); + var flare_2bpp_rgba = loader.load( 'textures/compressed/flare_2bpp_rgba.pvr' ); + var park3_cube_nomip_4bpp_rgb = loader.load( 'textures/compressed/park3_cube_nomip_4bpp_rgb.pvr', onCube1Loaded ); + var park3_cube_mip_2bpp_rgb_v3 = loader.load( 'textures/compressed/park3_cube_mip_2bpp_rgb_v3.pvr', onCube2Loaded ); disturb_2bpp_rgb.minFilter = disturb_2bpp_rgb.magFilter = - flare_4bpp_rgba.minFilter = - flare_4bpp_rgba.magFilter = + flare_4bpp_rgba.minFilter = + flare_4bpp_rgba.magFilter = disturb_4bpp_rgb.minFilter = disturb_4bpp_rgb.magFilter = disturb_4bpp_rgb_v3.minFilter = disturb_4bpp_rgb_v3.magFilter = - flare_2bpp_rgba.minFilter = - flare_2bpp_rgba.magFilter = THREE.LinearFilter; + flare_2bpp_rgba.minFilter = + flare_2bpp_rgba.magFilter = THREE.LinearFilter; var material1 = new THREE.MeshBasicMaterial( { map: disturb_4bpp_rgb } ); var material2 = new THREE.MeshBasicMaterial( { map: disturb_4bpp_rgb_mips } ); @@ -118,13 +118,13 @@ // var mesh = new THREE.Mesh( geometry, material1 ); - mesh.position.x = -500; + mesh.position.x = - 500; mesh.position.y = 200; scene.add( mesh ); meshes.push( mesh ); mesh = new THREE.Mesh( geometry, material2 ); - mesh.position.x = -166; + mesh.position.x = - 166; mesh.position.y = 200; scene.add( mesh ); meshes.push( mesh ); @@ -142,28 +142,28 @@ meshes.push( mesh ); mesh = new THREE.Mesh( geometry, material4 ); - mesh.position.x = -500; - mesh.position.y = -200; + mesh.position.x = - 500; + mesh.position.y = - 200; scene.add( mesh ); meshes.push( mesh ); mesh = new THREE.Mesh( geometry, material5 ); - mesh.position.x = -166; - mesh.position.y = -200; + mesh.position.x = - 166; + mesh.position.y = - 200; scene.add( mesh ); meshes.push( mesh ); - var torus = new THREE.TorusBufferGeometry( 100, 50, 32, 24 ); + var torus = new THREE.TorusBufferGeometry( 100, 50, 32, 24 ); mesh = new THREE.Mesh( torus, material6 ); mesh.position.x = 166; - mesh.position.y = -200; + mesh.position.y = - 200; scene.add( mesh ); meshes.push( mesh ); mesh = new THREE.Mesh( torus, material8 ); mesh.position.x = 500; - mesh.position.y = -200; + mesh.position.y = - 200; scene.add( mesh ); meshes.push( mesh );
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_loader_ttf.html
@@ -47,7 +47,7 @@ } - var container, color; + var container; var camera, cameraTarget, scene, renderer; var group, textMesh1, textMesh2, textGeo, material; var firstLetter = true; @@ -58,8 +58,7 @@ hover = 30, curveSegments = 4, bevelThickness = 2, - bevelSize = 1.5, - bevelSegments = 3; + bevelSize = 1.5; var font = null; var mirror = true; @@ -71,7 +70,6 @@ var mouseXOnMouseDown = 0; var windowHalfX = window.innerWidth / 2; - var windowHalfY = window.innerHeight / 2; init(); animate(); @@ -115,8 +113,10 @@ var loader = new THREE.TTFLoader(); loader.load( 'fonts/ttf/kenpixel.ttf', function ( json ) { + font = new THREE.Font( json ); createText(); + } ); var plane = new THREE.Mesh( @@ -149,7 +149,6 @@ function onWindowResize() { windowHalfX = window.innerWidth / 2; - windowHalfY = window.innerHeight / 2; camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix(); @@ -219,7 +218,7 @@ bevelSize: bevelSize, bevelEnabled: true - }); + } ); textGeo.computeBoundingBox(); textGeo.computeVertexNormals(); @@ -242,7 +241,7 @@ textMesh2 = new THREE.Mesh( textGeo, material ); textMesh2.position.x = centerOffset; - textMesh2.position.y = -hover; + textMesh2.position.y = - hover; textMesh2.position.z = height; textMesh2.rotation.x = Math.PI; @@ -259,7 +258,7 @@ group.remove( textMesh1 ); if ( mirror ) group.remove( textMesh2 ); - if ( !text ) return; + if ( ! text ) return; createText(); @@ -286,15 +285,15 @@ } - function onDocumentMouseUp( event ) { + function onDocumentMouseUp() { document.removeEventListener( 'mousemove', onDocumentMouseMove, false ); document.removeEventListener( 'mouseup', onDocumentMouseUp, false ); document.removeEventListener( 'mouseout', onDocumentMouseOut, false ); } - function onDocumentMouseOut( event ) { + function onDocumentMouseOut() { document.removeEventListener( 'mousemove', onDocumentMouseMove, false ); document.removeEventListener( 'mouseup', onDocumentMouseUp, false );
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_loader_vtk.html
@@ -54,8 +54,6 @@ var camera, controls, scene, renderer; - var cross; - init(); animate();
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_loader_x.html
@@ -53,7 +53,7 @@ <td>mech 1</td> <td><select id="mech1_anime" onchange="mech1_changeAnime(this.value)"> <option value="stand">stand</option> - <option value="wark">wark</option> + <option value="wark">walk</option> <option value="attack">attack</option> </select> </td> @@ -81,7 +81,6 @@ var container, stats, controls; var camera, scene, renderer; var clock = new THREE.Clock(); - var mixers = []; var manager = null; var skeletonHelper = null; @@ -102,7 +101,7 @@ }; - var onError = function ( xhr ) {}; + var onError = function () {}; function init() { @@ -214,7 +213,7 @@ for ( var i = 0; i < animates.length; i ++ ) { - animates[ i ].update( delta * 1000 ); + animates[ i ].update( delta * 1000 ); }
true
Other
mrdoob
three.js
4894f4e44448fdf18ea5f4181e4eba252e276a88.json
Fix linter errors in examples WebGL A-L
examples/webgl_lod.html
@@ -51,12 +51,10 @@ } - var container, stats; + var container; var camera, scene, renderer; - var geometry, objects; - var controls, clock = new THREE.Clock(); init(); @@ -115,7 +113,7 @@ } lod.position.x = 10000 * ( 0.5 - Math.random() ); - lod.position.y = 7500 * ( 0.5 - Math.random() ); + lod.position.y = 7500 * ( 0.5 - Math.random() ); lod.position.z = 10000 * ( 0.5 - Math.random() ); lod.updateMatrix(); lod.matrixAutoUpdate = false;
true
Other
mrdoob
three.js
9a9d5906c99062e9193fae526b8790b2f31484c6.json
improve some wording in animation docs
docs/manual/en/introduction/Animation-system.html
@@ -52,13 +52,13 @@ <h3>Keyframe Tracks</h3> <p class="desc"> Inside of such an *AnimationClip* the data for each animated property are stored in a - separate [page:KeyframeTrack]. Assumed a character object has a [page:Skeleton skeleton], + separate [page:KeyframeTrack]. Assuming a character object has a [page:Skeleton skeleton], one keyframe track could store the data for the position changes of the lower arm bone over time, a different track the data for the rotation changes of the same bone, a third the track position, rotation or scaling of another bone, and so on. It should be clear, that an AnimationClip can be composed of lots of such tracks.<br /><br /> - Assumed the model has [page:Geometry.morphTargets morph targets] (for example one morph + Assuming the model has [page:Geometry.morphTargets morph targets] (for example one morph target showing a friendly face and another showing an angry face), each track holds the information as to how the [page:Mesh.morphTargetInfluences influence] of a certain morph target changes during the performance of the clip. @@ -69,7 +69,7 @@ <h3>Animation Mixer</h3> <p class="desc"> - The stored data form only the basis for the animations - actual playback is controlled by + The stored data forms only the basis for the animations - actual playback is controlled by the [page:AnimationMixer]. You can imagine this not only as a player for animations, but as a simulation of a hardware like a real mixer console, which can control several animations simultaneously, blending and merging them.
false
Other
mrdoob
three.js
a872fbd32ff390a10933b66ca972dbd10dfabafd.json
extend shadow far
examples/webgl_materials_cars.html
@@ -127,7 +127,7 @@ shadowLight.shadow.camera.bottom = -2; shadowLight.shadow.camera.left = -2.5; shadowLight.shadow.camera.right = 2.5; - shadowLight.shadow.camera.far = 5.5; + shadowLight.shadow.camera.far = 5.75; shadowLight.shadow.bias = -0.025; lightHolder.add( shadowLight, shadowLight.target );
false
Other
mrdoob
three.js
099d5a377188bf3597de69a0327d179b8d751f89.json
Move statements to individual lines
examples/css3d_molecules.html
@@ -494,9 +494,15 @@ switch ( visualizationType ) { - case 0: showAtoms(); break; - case 1: showBonds(); break; - case 2: showAtomsBonds(); break; + case 0: + showAtoms(); + break; + case 1: + showBonds(); + break; + case 2: + showAtomsBonds(); + break; }
false
Other
mrdoob
three.js
89db424a342ae0eb339636c64b079deb30d6246e.json
Move statements to seperate lines
examples/canvas_interactive_voxelpainter.html
@@ -165,7 +165,8 @@ switch ( event.keyCode ) { - case 16: isShiftDown = true; break; + case 16: isShiftDown = true; + break; } @@ -175,7 +176,8 @@ switch ( event.keyCode ) { - case 16: isShiftDown = false; break; + case 16: isShiftDown = false; + break; }
true
Other
mrdoob
three.js
89db424a342ae0eb339636c64b079deb30d6246e.json
Move statements to seperate lines
examples/misc_controls_pointerlock.html
@@ -145,7 +145,8 @@ case 37: // left case 65: // a - moveLeft = true; break; + moveLeft = true; + break; case 40: // down case 83: // s
true
Other
mrdoob
three.js
89db424a342ae0eb339636c64b079deb30d6246e.json
Move statements to seperate lines
examples/misc_fps.html
@@ -140,7 +140,8 @@ // calculate velocity towards another side of platform from jump pad position temp.copy( pads[ j ] ); - temp.y = 0; temp.setLength( - 0.8 ); + temp.y = 0; + temp.setLength( - 0.8 ); temp.y = 0.7; motion.airborne = true; @@ -227,7 +228,8 @@ // wrap horizontal rotation to 0...2π - motion.rotation.y += tau; motion.rotation.y %= tau; + motion.rotation.y += tau; + motion.rotation.y %= tau; timeLeft -= dt; @@ -331,7 +333,8 @@ var lastTimeStamp; var render = function ( timeStamp ) { - var timeElapsed = lastTimeStamp ? timeStamp - lastTimeStamp : 0; lastTimeStamp = timeStamp; + var timeElapsed = lastTimeStamp ? timeStamp - lastTimeStamp : 0; + lastTimeStamp = timeStamp; // call our game loop with the time elapsed since last rendering, in ms gameLoop( timeElapsed );
true
Other
mrdoob
three.js
0f14339f82ece6cd2a15e303b61ae268e94d7812.json
Move statements onto seperate lines
examples/misc_fps.html
@@ -74,7 +74,8 @@ var index = watchedKeyCodes.indexOf( e.keyCode ); if ( index >= 0 ) { - keysPressed[ watchedKeyCodes[ index ] ] = down; e.preventDefault(); + keysPressed[ watchedKeyCodes[ index ] ] = down; + e.preventDefault(); } @@ -138,9 +139,13 @@ if ( pads[ j ].distanceToSquared( motion.position ) < 2.3 ) { // calculate velocity towards another side of platform from jump pad position - temp.copy( pads[ j ] ); temp.y = 0; temp.setLength( - 0.8 ); temp.y = 0.7; + temp.copy( pads[ j ] ); + temp.y = 0; temp.setLength( - 0.8 ); + temp.y = 0.7; - motion.airborne = true; motion.velocity.copy( temp ); break; + motion.airborne = true; + motion.velocity.copy( temp ); + break; }
false
Other
mrdoob
three.js
c1f6878d23b0401e718776e9e80b77fa7e25832c.json
Fix linter errors
examples/misc_animation_authoring.html
@@ -119,7 +119,7 @@ } - }); + } ); window.addEventListener( 'keyup', function ( event ) { @@ -132,7 +132,7 @@ } - }); + } ); var trackInfo = [
true
Other
mrdoob
three.js
c1f6878d23b0401e718776e9e80b77fa7e25832c.json
Fix linter errors
examples/misc_controls_fly.html
@@ -74,11 +74,11 @@ var MARGIN = 0; var SCREEN_HEIGHT = window.innerHeight - MARGIN * 2; - var SCREEN_WIDTH = window.innerWidth; + var SCREEN_WIDTH = window.innerWidth; var camera, controls, scene, renderer, stats; var geometry, meshPlanet, meshClouds, meshMoon; - var dirLight, pointLight, ambientLight; + var dirLight; var composer; @@ -100,7 +100,7 @@ scene.fog = new THREE.FogExp2( 0x000000, 0.00000025 ); dirLight = new THREE.DirectionalLight( 0xffffff ); - dirLight.position.set( -1, 0, 1 ).normalize(); + dirLight.position.set( - 1, 0, 1 ).normalize(); scene.add( dirLight ); var materialNormalMap = new THREE.MeshPhongMaterial( { @@ -246,10 +246,10 @@ } - function onWindowResize( event ) { + function onWindowResize() { SCREEN_HEIGHT = window.innerHeight; - SCREEN_WIDTH = window.innerWidth; + SCREEN_WIDTH = window.innerWidth; renderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
true
Other
mrdoob
three.js
c1f6878d23b0401e718776e9e80b77fa7e25832c.json
Fix linter errors
examples/misc_controls_map.html
@@ -125,9 +125,10 @@ window.addEventListener( 'resize', onWindowResize, false ); - var gui = new dat.GUI(); + var gui = new dat.GUI(); + + gui.add( controls, 'screenSpacePanning' ); - gui.add(controls, 'screenSpacePanning'); } function onWindowResize() {
true
Other
mrdoob
three.js
c1f6878d23b0401e718776e9e80b77fa7e25832c.json
Fix linter errors
examples/misc_controls_pointerlock.html
@@ -112,20 +112,20 @@ var blocker = document.getElementById( 'blocker' ); var instructions = document.getElementById( 'instructions' ); - instructions.addEventListener( 'click', function ( event ) { + instructions.addEventListener( 'click', function () { controls.lock(); }, false ); - controls.addEventListener( 'lock', function() { + controls.addEventListener( 'lock', function () { instructions.style.display = 'none'; blocker.style.display = 'none'; } ); - controls.addEventListener( 'unlock', function() { + controls.addEventListener( 'unlock', function () { blocker.style.display = 'block'; instructions.style.display = ''; @@ -168,7 +168,7 @@ var onKeyUp = function ( event ) { - switch( event.keyCode ) { + switch ( event.keyCode ) { case 38: // up case 87: // w
true
Other
mrdoob
three.js
c1f6878d23b0401e718776e9e80b77fa7e25832c.json
Fix linter errors
examples/misc_controls_trackball.html
@@ -107,7 +107,7 @@ scene.add( light ); var light = new THREE.DirectionalLight( 0x002288 ); - light.position.set( -1, -1, -1 ); + light.position.set( - 1, - 1, - 1 ); scene.add( light ); var light = new THREE.AmbientLight( 0x222222 );
true
Other
mrdoob
three.js
c1f6878d23b0401e718776e9e80b77fa7e25832c.json
Fix linter errors
examples/misc_controls_transform.html
@@ -78,15 +78,17 @@ var geometry = new THREE.BoxBufferGeometry( 200, 200, 200 ); var material = new THREE.MeshLambertMaterial( { map: texture } ); - orbit = new THREE.OrbitControls(camera, renderer.domElement); + orbit = new THREE.OrbitControls( camera, renderer.domElement ); orbit.update(); orbit.addEventListener( 'change', render ); control = new THREE.TransformControls( camera, renderer.domElement ); control.addEventListener( 'change', render ); control.addEventListener( 'dragging-changed', function ( event ) { - orbit.enabled = !event.value; + + orbit.enabled = ! event.value; + } ); var mesh = new THREE.Mesh( geometry, material ); @@ -133,24 +135,24 @@ break; case 88: // X - control.showX = !control.showX; + control.showX = ! control.showX; break; case 89: // Y - control.showY = !control.showY; + control.showY = ! control.showY; break; case 90: // Z - control.showZ = !control.showZ; + control.showZ = ! control.showZ; break; case 32: // Spacebar - control.enabled = !control.enabled; + control.enabled = ! control.enabled; break; } - }); + } ); window.addEventListener( 'keyup', function ( event ) { @@ -163,7 +165,7 @@ } - }); + } ); }
true
Other
mrdoob
three.js
c1f6878d23b0401e718776e9e80b77fa7e25832c.json
Fix linter errors
examples/misc_exporter_gltf.html
@@ -51,14 +51,14 @@ var gltfExporter = new THREE.GLTFExporter(); var options = { - trs: document.getElementById('option_trs').checked, - onlyVisible: document.getElementById('option_visible').checked, - truncateDrawRange: document.getElementById('option_drawrange').checked, - binary: document.getElementById('option_binary').checked, - forceIndices: document.getElementById('option_forceindices').checked, - forcePowerOfTwoTextures: document.getElementById('option_forcepot').checked + trs: document.getElementById( 'option_trs' ).checked, + onlyVisible: document.getElementById( 'option_visible' ).checked, + truncateDrawRange: document.getElementById( 'option_drawrange' ).checked, + binary: document.getElementById( 'option_binary' ).checked, + forceIndices: document.getElementById( 'option_forceindices' ).checked, + forcePowerOfTwoTextures: document.getElementById( 'option_forcepot' ).checked }; - gltfExporter.parse( input, function( result ) { + gltfExporter.parse( input, function ( result ) { if ( result instanceof ArrayBuffer ) { @@ -166,7 +166,7 @@ // Perspective Camera // --------------------------------------------------------------------- camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 2000 ); - camera.position.set(600, 400, 0); + camera.position.set( 600, 400, 0 ); camera.name = "PerspectiveCamera"; scene1.add( camera ); @@ -190,7 +190,7 @@ // Grid // --------------------------------------------------------------------- gridHelper = new THREE.GridHelper( 2000, 20 ); - gridHelper.position.y = -50; + gridHelper.position.y = - 50; gridHelper.name = "Grid"; scene1.add( gridHelper ); @@ -213,7 +213,7 @@ } ); object = new THREE.Mesh( new THREE.IcosahedronGeometry( 75, 0 ), material ); - object.position.set( -200, 0, 200 ); + object.position.set( - 200, 0, 200 ); object.name = 'Icosahedron'; scene1.add( object ); @@ -270,7 +270,7 @@ roughness: 1 } ); object = new THREE.Mesh( new THREE.TorusKnotGeometry( 50, 15, 40, 10 ), material ); - object.position.set( -200, 0, 0 ); + object.position.set( - 200, 0, 0 ); object.name = "Cylinder"; scene1.add( object ); @@ -282,7 +282,7 @@ material = new THREE.MeshStandardMaterial( { map: mapWood, side: THREE.DoubleSide } ); object = new THREE.Mesh( new THREE.BoxBufferGeometry( 40, 100, 100 ), material ); - object.position.set( -200, 0, 400 ); + object.position.set( - 200, 0, 400 ); object.name = "Cube"; scene1.add( object ); @@ -302,7 +302,7 @@ var group2 = new THREE.Group(); group2.name = "subGroup"; - group2.position.set( 0, 50, 0); + group2.position.set( 0, 50, 0 ); group1.add( group2 ); object2 = new THREE.Mesh( new THREE.BoxBufferGeometry( 30, 30, 30 ), material ); @@ -314,31 +314,31 @@ // Triangle Strip // --------------------------------------------------------------------- var geometry = new THREE.BufferGeometry(); - var positions = new Float32Array([ + var positions = new Float32Array( [ 0, 0, 0, 0, 80, 0, 80, 0, 0, 80, 80, 0, 80, 0, 80, 80, 80, 80, - ]); + ] ); - var colors = new Float32Array([ + var colors = new Float32Array( [ 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, - ]); + ] ); geometry.addAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) ); geometry.addAttribute( 'color', new THREE.BufferAttribute( colors, 3 ) ); object = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { side: THREE.DoubleSide, vertexColors: THREE.VertexColors } ) ); - object.position.set( 140, -40, -250); + object.position.set( 140, - 40, - 250 ); object.setDrawMode( THREE.TriangleStripDrawMode ); object.name = 'Custom buffered'; - object.userData = { data: 'customdata', list: [ 1,2,3,4 ] }; + object.userData = { data: 'customdata', list: [ 1, 2, 3, 4 ] }; scene1.add( object ); @@ -350,15 +350,17 @@ var numPoints = 100; var positions = new Float32Array( numPoints * 3 ); - for (var i = 0; i < numPoints; i++ ) { + for ( var i = 0; i < numPoints; i ++ ) { + positions[ i * 3 ] = i; positions[ i * 3 + 1 ] = Math.sin( i / 2 ) * 20; positions[ i * 3 + 2 ] = 0; + } geometry.addAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) ); object = new THREE.Line( geometry, new THREE.LineBasicMaterial( { color: 0xffff00 } ) ); - object.position.set(-50, 0, -200); + object.position.set( - 50, 0, - 200 ); scene1.add( object ); @@ -370,16 +372,18 @@ var radius = 70; var positions = new Float32Array( numPoints * 3 ); - for (var i = 0; i < numPoints; i++ ) { + for ( var i = 0; i < numPoints; i ++ ) { + var s = i * Math.PI * 2 / numPoints; - positions[ i * 3 ] = radius * Math.sin ( s ); - positions[ i * 3 + 1 ] = radius * Math.cos ( s ); + positions[ i * 3 ] = radius * Math.sin( s ); + positions[ i * 3 + 1 ] = radius * Math.cos( s ); positions[ i * 3 + 2 ] = 0; + } geometry.addAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) ); object = new THREE.LineLoop( geometry, new THREE.LineBasicMaterial( { color: 0xffff00 } ) ); - object.position.set(0, 0, -200); + object.position.set( 0, 0, - 200 ); scene1.add( object ); @@ -393,31 +397,31 @@ var positions = new Float32Array( ( numElements + outOfRange ) * 3 ); var colors = new Float32Array( ( numElements + outOfRange ) * 3 ); - positions.set([ + positions.set( [ 0, 0, 0, 0, 80, 0, 80, 0, 0, 80, 0, 0, 0, 80, 0, 80, 80, 0 - ]); + ] ); - colors.set([ + colors.set( [ 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, - ]); + ] ); geometry.addAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) ); geometry.addAttribute( 'color', new THREE.BufferAttribute( colors, 3 ) ); geometry.setDrawRange( 0, numElements ); object = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { side: THREE.DoubleSide, vertexColors: THREE.VertexColors } ) ); object.name = 'Custom buffered truncated'; - object.position.set( 340, -40, -200 ); + object.position.set( 340, - 40, - 200 ); scene1.add( object ); @@ -426,10 +430,12 @@ // --------------------------------------------------------------------- var numPoints = 100; var pointsArray = new Float32Array( numPoints * 3 ); - for ( var i = 0; i < numPoints; i++ ) { - pointsArray[ 3 * i ] = -50 + Math.random() * 100; + for ( var i = 0; i < numPoints; i ++ ) { + + pointsArray[ 3 * i ] = - 50 + Math.random() * 100; pointsArray[ 3 * i + 1 ] = Math.random() * 100; - pointsArray[ 3 * i + 2 ] = -50 + Math.random() * 100; + pointsArray[ 3 * i + 2 ] = - 50 + Math.random() * 100; + } var pointsGeo = new THREE.BufferGeometry(); @@ -438,7 +444,7 @@ var pointsMaterial = new THREE.PointsMaterial( { color: 0xffff00, size: 5 } ); var points = new THREE.Points( pointsGeo, pointsMaterial ); points.name = "Points"; - points.position.set( -200, 0, -200); + points.position.set( - 200, 0, - 200 ); scene1.add( points ); // --------------------------------------------------------------------- @@ -454,15 +460,15 @@ } ); object = new THREE.Mesh( new THREE.CircleGeometry( 50, 20, 0, Math.PI * 2 ), material ); - object.position.set( 200, 0, -400 ); + object.position.set( 200, 0, - 400 ); scene1.add( object ); object = new THREE.Mesh( new THREE.RingGeometry( 10, 50, 20, 5, 0, Math.PI * 2 ), material ); - object.position.set( 0, 0, -400 ); + object.position.set( 0, 0, - 400 ); scene1.add( object ); object = new THREE.Mesh( new THREE.CylinderGeometry( 25, 75, 100, 40, 5 ), material ); - object.position.set( -200, 0, -400 ); + object.position.set( - 200, 0, - 400 ); scene1.add( object ); // @@ -498,7 +504,7 @@ waltHead = obj; waltHead.scale.multiplyScalar( 1.5 ); - waltHead.position.set(400, 0, 0); + waltHead.position.set( 400, 0, 0 ); scene1.add( waltHead ); } ); @@ -512,7 +518,7 @@ object.position.set( 0, 0, 0 ); object.name = "Cube2ndScene"; scene2.name = 'Scene2'; - scene2.add(object); + scene2.add( object ); //
true
Other
mrdoob
three.js
c1f6878d23b0401e718776e9e80b77fa7e25832c.json
Fix linter errors
examples/misc_exporter_obj.html
@@ -75,17 +75,17 @@ var exporter = new THREE.OBJExporter(); var result = exporter.parse( scene ); floatingDiv.style.display = 'block'; - floatingDiv.innerHTML = result.split( '\n' ).join ( '<br />' ); + floatingDiv.innerHTML = result.split( '\n' ).join( '<br />' ); } function addGeometry( type ) { - for( var i = 0; i < scene.children.length; i ++ ) { + for ( var i = 0; i < scene.children.length; i ++ ) { var child = scene.children[ i ]; - if( child.isMesh ) { + if ( child.isMesh ) { child.geometry.dispose(); scene.remove( child ); @@ -97,31 +97,31 @@ if ( type === 1 ) { - var material = new THREE.MeshLambertMaterial( { color : 0x00cc00 } ); + var material = new THREE.MeshLambertMaterial( { color: 0x00cc00 } ); var geometry = generateTriangleGeometry(); scene.add( new THREE.Mesh( geometry, material ) ); } else if ( type === 2 ) { - var material = new THREE.MeshLambertMaterial( { color : 0x00cc00 } ); + var material = new THREE.MeshLambertMaterial( { color: 0x00cc00 } ); var geometry = new THREE.BoxBufferGeometry( 100, 100, 100 ); scene.add( new THREE.Mesh( geometry, material ) ); } else if ( type === 3 ) { - var material = new THREE.MeshLambertMaterial( { color : 0x00cc00 } ); + var material = new THREE.MeshLambertMaterial( { color: 0x00cc00 } ); var geometry = new THREE.CylinderBufferGeometry( 50, 50, 100, 30, 1 ); scene.add( new THREE.Mesh( geometry, material ) ); } else if ( type === 4 || type === 5 ) { - var material = new THREE.MeshLambertMaterial( { color : 0x00cc00 } ); + var material = new THREE.MeshLambertMaterial( { color: 0x00cc00 } ); var geometry = generateTriangleGeometry(); var mesh = new THREE.Mesh( geometry, material ); - mesh.position.x = -200; + mesh.position.x = - 200; scene.add( mesh ); var geometry2 = new THREE.BoxBufferGeometry( 100, 100, 100 ); @@ -167,14 +167,38 @@ document.addEventListener( 'mousemove', onDocumentMouseMove, false ); document.addEventListener( 'mouseover', onDocumentMouseMove, false ); - document.getElementById( 'triangle' ).addEventListener( 'click', function() { addGeometry( 1 ); } ); - document.getElementById( 'cube' ).addEventListener( 'click', function() { addGeometry( 2 ); } ); - document.getElementById( 'cylinder' ).addEventListener( 'click', function() { addGeometry( 3 ); } ); - document.getElementById( 'both' ).addEventListener( 'click', function() { addGeometry( 4 ); } ); - document.getElementById( 'transformed' ).addEventListener( 'click', function() { addGeometry( 5 ); } ); + document.getElementById( 'triangle' ).addEventListener( 'click', function () { + + addGeometry( 1 ); + + } ); + document.getElementById( 'cube' ).addEventListener( 'click', function () { + + addGeometry( 2 ); + + } ); + document.getElementById( 'cylinder' ).addEventListener( 'click', function () { + + addGeometry( 3 ); + + } ); + document.getElementById( 'both' ).addEventListener( 'click', function () { + + addGeometry( 4 ); + + } ); + document.getElementById( 'transformed' ).addEventListener( 'click', function () { + + addGeometry( 5 ); + + } ); exportButton = document.getElementById( 'export' ); - exportButton.addEventListener( 'click', function() { exportToObj(); }); + exportButton.addEventListener( 'click', function () { + + exportToObj(); + + } ); floatingDiv = document.createElement( 'div' ); floatingDiv.className = 'floating'; @@ -187,7 +211,7 @@ var needToClose = true; var target = event.target; - while( target !== null ) { + while ( target !== null ) { if ( target === floatingDiv || target === exportButton ) {
true
Other
mrdoob
three.js
c1f6878d23b0401e718776e9e80b77fa7e25832c.json
Fix linter errors
examples/misc_exporter_stl.html
@@ -116,11 +116,15 @@ // var params = { - ASCII: function() { + ASCII: function () { + exportASCII(); + }, - Binary: function() { + Binary: function () { + exportBinary(); + } };
true
Other
mrdoob
three.js
c1f6878d23b0401e718776e9e80b77fa7e25832c.json
Fix linter errors
examples/misc_fps.html
@@ -38,118 +38,145 @@ // player motion parameters var motion = { - airborne : false, - position : new THREE.Vector3(), velocity : new THREE.Vector3(), - rotation : new THREE.Vector2(), spinning : new THREE.Vector2() + airborne: false, + position: new THREE.Vector3(), velocity: new THREE.Vector3(), + rotation: new THREE.Vector2(), spinning: new THREE.Vector2() }; - motion.position.y = -150; + motion.position.y = - 150; // game systems code - var resetPlayer = function() { - if( motion.position.y < -123 ) { - motion.position.set( -2, 7.7, 25 ); + var resetPlayer = function () { + + if ( motion.position.y < - 123 ) { + + motion.position.set( - 2, 7.7, 25 ); motion.velocity.multiplyScalar( 0 ); + } + }; - var keyboardControls = (function() { + var keyboardControls = ( function () { - var keys = { SP : 32, W : 87, A : 65, S : 83, D : 68, UP : 38, LT : 37, DN : 40, RT : 39 }; + var keys = { SP: 32, W: 87, A: 65, S: 83, D: 68, UP: 38, LT: 37, DN: 40, RT: 39 }; var keysPressed = {}; - (function( watchedKeyCodes ) { - var handler = function( down ) { - return function( e ) { + ( function ( watchedKeyCodes ) { + + var handler = function ( down ) { + + return function ( e ) { + var index = watchedKeyCodes.indexOf( e.keyCode ); - if( index >= 0 ) { - keysPressed[watchedKeyCodes[index]] = down; e.preventDefault(); + if ( index >= 0 ) { + + keysPressed[ watchedKeyCodes[ index ] ] = down; e.preventDefault(); + } + }; + }; window.addEventListener( "keydown", handler( true ), false ); window.addEventListener( "keyup", handler( false ), false ); - })([ + + } )( [ keys.SP, keys.W, keys.A, keys.S, keys.D, keys.UP, keys.LT, keys.DN, keys.RT - ]); + ] ); var forward = new THREE.Vector3(); var sideways = new THREE.Vector3(); - return function() { - if( !motion.airborne ) { + return function () { + + if ( ! motion.airborne ) { // look around - var sx = keysPressed[keys.UP] ? 0.03 : ( keysPressed[keys.DN] ? -0.03 : 0 ); - var sy = keysPressed[keys.LT] ? 0.03 : ( keysPressed[keys.RT] ? -0.03 : 0 ); + var sx = keysPressed[ keys.UP ] ? 0.03 : ( keysPressed[ keys.DN ] ? - 0.03 : 0 ); + var sy = keysPressed[ keys.LT ] ? 0.03 : ( keysPressed[ keys.RT ] ? - 0.03 : 0 ); - if( Math.abs( sx ) >= Math.abs( motion.spinning.x ) ) motion.spinning.x = sx; - if( Math.abs( sy ) >= Math.abs( motion.spinning.y ) ) motion.spinning.y = sy; + if ( Math.abs( sx ) >= Math.abs( motion.spinning.x ) ) motion.spinning.x = sx; + if ( Math.abs( sy ) >= Math.abs( motion.spinning.y ) ) motion.spinning.y = sy; // move around forward.set( Math.sin( motion.rotation.y ), 0, Math.cos( motion.rotation.y ) ); - sideways.set( forward.z, 0, -forward.x ); + sideways.set( forward.z, 0, - forward.x ); - forward.multiplyScalar( keysPressed[keys.W] ? -0.1 : (keysPressed[keys.S] ? 0.1 : 0)); - sideways.multiplyScalar( keysPressed[keys.A] ? -0.1 : (keysPressed[keys.D] ? 0.1 : 0)); + forward.multiplyScalar( keysPressed[ keys.W ] ? - 0.1 : ( keysPressed[ keys.S ] ? 0.1 : 0 ) ); + sideways.multiplyScalar( keysPressed[ keys.A ] ? - 0.1 : ( keysPressed[ keys.D ] ? 0.1 : 0 ) ); var combined = forward.add( sideways ); - if( Math.abs( combined.x ) >= Math.abs( motion.velocity.x ) ) motion.velocity.x = combined.x; - if( Math.abs( combined.y ) >= Math.abs( motion.velocity.y ) ) motion.velocity.y = combined.y; - if( Math.abs( combined.z ) >= Math.abs( motion.velocity.z ) ) motion.velocity.z = combined.z; + if ( Math.abs( combined.x ) >= Math.abs( motion.velocity.x ) ) motion.velocity.x = combined.x; + if ( Math.abs( combined.y ) >= Math.abs( motion.velocity.y ) ) motion.velocity.y = combined.y; + if ( Math.abs( combined.z ) >= Math.abs( motion.velocity.z ) ) motion.velocity.z = combined.z; //jump - var vy = keysPressed[keys.SP] ? 0.7 : 0; + var vy = keysPressed[ keys.SP ] ? 0.7 : 0; motion.velocity.y += vy; + } + }; - })(); - var jumpPads = (function() { - var pads = [ new THREE.Vector3( -17.5, 8, -10 ), new THREE.Vector3( 17.5, 8, -10 ), new THREE.Vector3( 0, 8, 21 ) ]; + } )(); + + var jumpPads = ( function () { + + var pads = [ new THREE.Vector3( - 17.5, 8, - 10 ), new THREE.Vector3( 17.5, 8, - 10 ), new THREE.Vector3( 0, 8, 21 ) ]; var temp = new THREE.Vector3(); - return function() { - if( !motion.airborne ) { - for( var j = 0, n = pads.length; j < n; j++ ) { - if ( pads[j].distanceToSquared( motion.position ) < 2.3 ) { + return function () { + + if ( ! motion.airborne ) { + + for ( var j = 0, n = pads.length; j < n; j ++ ) { + + if ( pads[ j ].distanceToSquared( motion.position ) < 2.3 ) { // calculate velocity towards another side of platform from jump pad position - temp.copy( pads[j] ); temp.y = 0; temp.setLength( -0.8 ); temp.y = 0.7; + temp.copy( pads[ j ] ); temp.y = 0; temp.setLength( - 0.8 ); temp.y = 0.7; motion.airborne = true; motion.velocity.copy( temp ); break; + } + } + } + }; - })(); - var applyPhysics = (function() { + } )(); + + var applyPhysics = ( function () { + var timeStep = 5; var timeLeft = timeStep + 1; var birdsEye = 100; var kneeDeep = 0.4; var raycaster = new THREE.Raycaster(); - raycaster.ray.direction.set( 0, -1, 0 ); + raycaster.ray.direction.set( 0, - 1, 0 ); var angles = new THREE.Vector2(); var displacement = new THREE.Vector3(); - return function( dt ) { + return function ( dt ) { + var platform = scene.getObjectByName( "platform", true ); - if( platform ) { + if ( platform ) { timeLeft += dt; // run several fixed-step iterations to approximate varying-step dt = 5; - while( timeLeft >= dt ) { + while ( timeLeft >= dt ) { var time = 0.3, damping = 0.93, gravity = 0.01, tau = 2 * Math.PI; @@ -162,83 +189,98 @@ // are we above, or at most knee deep in, the platform? - if( ( hits.length > 0 ) && ( hits[0].face.normal.y > 0 ) ) { - var actualHeight = hits[0].distance - birdsEye; + if ( ( hits.length > 0 ) && ( hits[ 0 ].face.normal.y > 0 ) ) { + + var actualHeight = hits[ 0 ].distance - birdsEye; // collision: stick to the surface if landing on it - if( ( motion.velocity.y <= 0 ) && ( Math.abs( actualHeight ) < kneeDeep ) ) { + if ( ( motion.velocity.y <= 0 ) && ( Math.abs( actualHeight ) < kneeDeep ) ) { + motion.position.y -= actualHeight; motion.velocity.y = 0; motion.airborne = false; + } + } - if( motion.airborne ) motion.velocity.y -= gravity; + if ( motion.airborne ) motion.velocity.y -= gravity; angles.copy( motion.spinning ).multiplyScalar( time ); - if( !motion.airborne ) motion.spinning.multiplyScalar( damping ); + if ( ! motion.airborne ) motion.spinning.multiplyScalar( damping ); displacement.copy( motion.velocity ).multiplyScalar( time ); - if( !motion.airborne ) motion.velocity.multiplyScalar( damping ); + if ( ! motion.airborne ) motion.velocity.multiplyScalar( damping ); motion.rotation.add( angles ); motion.position.add( displacement ); // limit the tilt at ±0.4 radians - motion.rotation.x = Math.max( -0.4, Math.min ( +0.4, motion.rotation.x ) ); + motion.rotation.x = Math.max( - 0.4, Math.min( + 0.4, motion.rotation.x ) ); // wrap horizontal rotation to 0...2π motion.rotation.y += tau; motion.rotation.y %= tau; timeLeft -= dt; + } + } + }; - })(); - var updateCamera = (function() { + } )(); + + var updateCamera = ( function () { + var euler = new THREE.Euler( 0, 0, 0, 'YXZ' ); - return function() { + return function () { + euler.x = motion.rotation.x; euler.y = motion.rotation.y; camera.quaternion.setFromEuler( euler ); camera.position.copy( motion.position ); camera.position.y += 3.0; + }; - })(); + + } )(); // init 3D stuff function makePlatform( jsonUrl, textureUrl, textureQuality ) { + var placeholder = new THREE.Object3D(); var texture = new THREE.TextureLoader().load( textureUrl ); texture.minFilter = THREE.LinearFilter; texture.anisotropy = textureQuality; var loader = new THREE.JSONLoader(); - loader.load( jsonUrl, function( geometry ) { + loader.load( jsonUrl, function ( geometry ) { geometry.computeFaceNormals(); - var platform = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial({ map : texture }) ); + var platform = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { map: texture } ) ); platform.name = "platform"; placeholder.add( platform ); - }); + + } ); return placeholder; + } - var renderer = new THREE.WebGLRenderer( { antialias : true } ); + var renderer = new THREE.WebGLRenderer( { antialias: true } ); renderer.setPixelRatio( window.devicePixelRatio ); document.body.appendChild( renderer.domElement ); @@ -252,7 +294,7 @@ 'textures/cube/skybox/py.jpg', // top 'textures/cube/skybox/ny.jpg', // bottom 'textures/cube/skybox/pz.jpg', // back - 'textures/cube/skybox/nz.jpg' // front + 'textures/cube/skybox/nz.jpg' // front ] ); envMap.format = THREE.RGBFormat; @@ -262,48 +304,62 @@ 'models/platform/platform.json', 'models/platform/platform.jpg', renderer.capabilities.getMaxAnisotropy() - )); + ) ); // start the game - var start = function( gameLoop, gameViewportSize ) { - var resize = function() { + var start = function ( gameLoop, gameViewportSize ) { + + var resize = function () { + var viewport = gameViewportSize(); renderer.setSize( viewport.width, viewport.height ); camera.aspect = viewport.width / viewport.height; camera.updateProjectionMatrix(); + }; window.addEventListener( 'resize', resize, false ); resize(); var lastTimeStamp; - var render = function( timeStamp ) { + var render = function ( timeStamp ) { + var timeElapsed = lastTimeStamp ? timeStamp - lastTimeStamp : 0; lastTimeStamp = timeStamp; // call our game loop with the time elapsed since last rendering, in ms gameLoop( timeElapsed ); renderer.render( scene, camera ); requestAnimationFrame( render ); + }; requestAnimationFrame( render ); + }; - var gameLoop = function( dt ) { + var gameLoop = function ( dt ) { + resetPlayer(); keyboardControls(); jumpPads(); applyPhysics( dt ); updateCamera(); + }; - var gameViewportSize = function() { return { - width: window.innerWidth, height: window.innerHeight - }}; + var gameViewportSize = function () { + + return { + + width: window.innerWidth, height: window.innerHeight + + }; + + }; start( gameLoop, gameViewportSize ); </script>
true
Other
mrdoob
three.js
c1f6878d23b0401e718776e9e80b77fa7e25832c.json
Fix linter errors
examples/misc_lights_test.html
@@ -13,7 +13,6 @@ font-family:georgia; text-align:center; } - h1 { } a { color:skyblue } canvas { pointer-events:none; z-index:10; } @@ -36,13 +35,12 @@ var SCREEN_WIDTH = window.innerWidth / 2; var SCREEN_HEIGHT = window.innerHeight; - var FLOOR = -250; var container, stats; var camera, scene, canvasRenderer, webglRenderer; - var mesh, zmesh, geometry, material; + var mesh, geometry, material; var directionalLight, pointLight; @@ -60,8 +58,8 @@ function init() { - container = document.createElement('div'); - document.body.appendChild(container); + container = document.createElement( 'div' ); + document.body.appendChild( container ); camera = new THREE.PerspectiveCamera( 75, SCREEN_WIDTH / SCREEN_HEIGHT, 1, 100000 ); camera.position.z = 500; @@ -97,7 +95,7 @@ scene.add( ambient ); directionalLight = new THREE.DirectionalLight( 0xffffff ); - directionalLight.position.set( 0, -70, 100 ).normalize(); + directionalLight.position.set( 0, - 70, 100 ).normalize(); setTimeout( function () {
true
Other
mrdoob
three.js
c1f6878d23b0401e718776e9e80b77fa7e25832c.json
Fix linter errors
examples/misc_lookat.html
@@ -39,7 +39,7 @@ var camera, scene, renderer, stats; - var mesh, geometry, sphere; + var sphere; var mouseX = 0, mouseY = 0; @@ -107,7 +107,7 @@ } - function onDocumentMouseMove(event) { + function onDocumentMouseMove( event ) { mouseX = ( event.clientX - windowHalfX ) * 10; mouseY = ( event.clientY - windowHalfY ) * 10;
true
Other
mrdoob
three.js
c1f6878d23b0401e718776e9e80b77fa7e25832c.json
Fix linter errors
examples/misc_ubiquity_test.html
@@ -25,8 +25,6 @@ <script> - var AMOUNT = 100; - var stats; var camera, scene; @@ -52,7 +50,7 @@ // QRCODE var loader = new THREE.JSONLoader(); - loader.load( 'models/json/QRCode.json', function ( geometry) { + loader.load( 'models/json/QRCode.json', function ( geometry ) { mesh = new THREE.Mesh( geometry, new THREE.MeshLambertMaterial( { vertexColors: THREE.FaceColors } ) ); mesh.scale.x = mesh.scale.y = mesh.scale.z = 2; @@ -82,14 +80,14 @@ // PLANE mesh = new THREE.Mesh( new THREE.PlaneBufferGeometry( 100, 100 ), new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff, side: THREE.DoubleSide } ) ); - mesh.position.y = -500; + mesh.position.y = - 500; mesh.scale.x = mesh.scale.y = mesh.scale.z = 2; scene.add( mesh ); // CYLINDER mesh = new THREE.Mesh( new THREE.CylinderBufferGeometry( 20, 100, 200, 10 ), new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff } ) ); - mesh.position.x = -500; + mesh.position.x = - 500; mesh.rotation.x = - Math.PI / 2; mesh.scale.x = mesh.scale.y = mesh.scale.z = 2; scene.add( mesh );
true
Other
mrdoob
three.js
c1f6878d23b0401e718776e9e80b77fa7e25832c.json
Fix linter errors
examples/misc_ubiquity_test2.html
@@ -65,7 +65,7 @@ // SPRITES - from Sprite Sheet - texture1 = textureLoader.load( 'textures/UV_Grid_Sm.jpg', function() { + texture1 = textureLoader.load( 'textures/UV_Grid_Sm.jpg', function () { texture1.wrapS = THREE.ClampToEdgeWrapping; texture1.wrapT = THREE.ClampToEdgeWrapping;
true
Other
mrdoob
three.js
c1f6878d23b0401e718776e9e80b77fa7e25832c.json
Fix linter errors
examples/misc_uv_tests.html
@@ -18,7 +18,7 @@ * as well as allow a new user to visualize what UVs are about. */ - function test(name, geometry) { + function test( name, geometry ) { var d = document.createElement( 'div' ); @@ -34,29 +34,29 @@ for ( var i = 0; i < 10; i ++ ) { - points.push( new THREE.Vector2( Math.sin( i * 0.2 ) * 15 + 50, ( i - 5 ) * 2 ) ); + points.push( new THREE.Vector2( Math.sin( i * 0.2 ) * 15 + 50, ( i - 5 ) * 2 ) ); } // - test('new THREE.PlaneBufferGeometry( 100, 100, 4, 4 )', new THREE.PlaneBufferGeometry( 100, 100, 4, 4 )); + test( 'new THREE.PlaneBufferGeometry( 100, 100, 4, 4 )', new THREE.PlaneBufferGeometry( 100, 100, 4, 4 ) ); - test('new THREE.SphereBufferGeometry( 75, 12, 6 )', new THREE.SphereBufferGeometry( 75, 12, 6 )); + test( 'new THREE.SphereBufferGeometry( 75, 12, 6 )', new THREE.SphereBufferGeometry( 75, 12, 6 ) ); - test('new THREE.IcosahedronBufferGeometry( 30, 1 )', new THREE.IcosahedronBufferGeometry( 30, 1 )); + test( 'new THREE.IcosahedronBufferGeometry( 30, 1 )', new THREE.IcosahedronBufferGeometry( 30, 1 ) ); - test('new THREE.OctahedronBufferGeometry( 30, 2 )', new THREE.OctahedronBufferGeometry( 30, 2 )); + test( 'new THREE.OctahedronBufferGeometry( 30, 2 )', new THREE.OctahedronBufferGeometry( 30, 2 ) ); - test('new THREE.CylinderBufferGeometry( 25, 75, 100, 10, 5 )', new THREE.CylinderBufferGeometry( 25, 75, 100, 10, 5 )); + test( 'new THREE.CylinderBufferGeometry( 25, 75, 100, 10, 5 )', new THREE.CylinderBufferGeometry( 25, 75, 100, 10, 5 ) ); - test('new THREE.BoxBufferGeometry( 100, 100, 100, 4, 4, 4 )', new THREE.BoxBufferGeometry( 100, 100, 100, 4, 4, 4 )); + test( 'new THREE.BoxBufferGeometry( 100, 100, 100, 4, 4, 4 )', new THREE.BoxBufferGeometry( 100, 100, 100, 4, 4, 4 ) ); - test('new THREE.LatheBufferGeometry( points, 8 )', new THREE.LatheBufferGeometry( points, 8 )); + test( 'new THREE.LatheBufferGeometry( points, 8 )', new THREE.LatheBufferGeometry( points, 8 ) ); - test('new THREE.TorusBufferGeometry( 50, 20, 8, 8 )', new THREE.TorusBufferGeometry( 50, 20, 8, 8 )); + test( 'new THREE.TorusBufferGeometry( 50, 20, 8, 8 )', new THREE.TorusBufferGeometry( 50, 20, 8, 8 ) ); - test('new THREE.TorusKnotBufferGeometry( 50, 10, 12, 6 )', new THREE.TorusKnotBufferGeometry( 50, 10, 12, 6 )); + test( 'new THREE.TorusKnotBufferGeometry( 50, 10, 12, 6 )', new THREE.TorusKnotBufferGeometry( 50, 10, 12, 6 ) ); </script>
true
Other
mrdoob
three.js
c1f6878d23b0401e718776e9e80b77fa7e25832c.json
Fix linter errors
examples/webvr_cubes.html
@@ -153,19 +153,26 @@ } function onPointerRestricted() { + var pointerLockElement = renderer.domElement; - if ( pointerLockElement && typeof(pointerLockElement.requestPointerLock) === 'function' ) { + if ( pointerLockElement && typeof ( pointerLockElement.requestPointerLock ) === 'function' ) { + pointerLockElement.requestPointerLock(); } + } function onPointerUnrestricted() { + var currentPointerLockElement = document.pointerLockElement; var expectedPointerLockElement = renderer.domElement; - if ( currentPointerLockElement && currentPointerLockElement === expectedPointerLockElement && typeof(document.exitPointerLock) === 'function' ) { + if ( currentPointerLockElement && currentPointerLockElement === expectedPointerLockElement && typeof ( document.exitPointerLock ) === 'function' ) { + document.exitPointerLock(); + } + } function onWindowResize() {
true
Other
mrdoob
three.js
c1f6878d23b0401e718776e9e80b77fa7e25832c.json
Fix linter errors
examples/webvr_dragging.html
@@ -77,9 +77,9 @@ light.position.set( 0, 6, 0 ); light.castShadow = true; light.shadow.camera.top = 2; - light.shadow.camera.bottom = -2; + light.shadow.camera.bottom = - 2; light.shadow.camera.right = 2; - light.shadow.camera.left = -2; + light.shadow.camera.left = - 2; light.shadow.mapSize.set( 4096, 4096 ); scene.add( light ); @@ -223,7 +223,7 @@ tempMatrix.identity().extractRotation( controller.matrixWorld ); raycaster.ray.origin.setFromMatrixPosition( controller.matrixWorld ); - raycaster.ray.direction.set( 0, 0, -1 ).applyMatrix4( tempMatrix ); + raycaster.ray.direction.set( 0, 0, - 1 ).applyMatrix4( tempMatrix ); return raycaster.intersectObjects( group.children );
true
Other
mrdoob
three.js
c1f6878d23b0401e718776e9e80b77fa7e25832c.json
Fix linter errors
examples/webvr_paint.html
@@ -40,16 +40,12 @@ var shapes = {}; var up = new THREE.Vector3( 0, 1, 0 ); - var vector = new THREE.Vector3(); var vector1 = new THREE.Vector3(); var vector2 = new THREE.Vector3(); var vector3 = new THREE.Vector3(); var vector4 = new THREE.Vector3(); - var point4 = new THREE.Vector3(); - var point5 = new THREE.Vector3(); - init(); initGeometry(); animate(); @@ -113,9 +109,9 @@ light.position.set( 0, 6, 0 ); light.castShadow = true; light.shadow.camera.top = 2; - light.shadow.camera.bottom = -2; + light.shadow.camera.bottom = - 2; light.shadow.camera.right = 2; - light.shadow.camera.left = -2; + light.shadow.camera.left = - 2; light.shadow.mapSize.set( 4096, 4096 ); scene.add( light ); @@ -180,8 +176,8 @@ // var pivot = new THREE.Mesh( new THREE.BoxBufferGeometry( 0.01, 0.01, 0.01 ) ); var pivot = new THREE.Mesh( new THREE.IcosahedronBufferGeometry( 0.01, 2 ) ); pivot.name = 'pivot'; - pivot.position.y = -0.016; - pivot.position.z = -0.043; + pivot.position.y = - 0.016; + pivot.position.z = - 0.043; pivot.rotation.x = Math.PI / 5.5; controller.add( pivot ); @@ -246,6 +242,7 @@ // Shapes shapes[ 'tube' ] = getTubeShapes( 1.0 ); + } function getTubeShapes( size ) { @@ -256,16 +253,16 @@ var array = []; var radius = 0.01 * size; - for( var i = 0; i < sides; i ++ ) { + for ( var i = 0; i < sides; i ++ ) { var angle = ( i / sides ) * PI2; array.push( new THREE.Vector3( Math.sin( angle ) * radius, Math.cos( angle ) * radius, 0 ) ); } return array; - } + } function stroke( controller, point1, point2, matrix1, matrix2 ) {
true
Other
mrdoob
three.js
c1f6878d23b0401e718776e9e80b77fa7e25832c.json
Fix linter errors
examples/webvr_panorama.html
@@ -107,7 +107,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
c1f6878d23b0401e718776e9e80b77fa7e25832c.json
Fix linter errors
examples/webvr_rollercoaster.html
@@ -128,7 +128,7 @@ var t1 = Math.max( 0, t - delta ); var t2 = Math.min( 1, t + delta ); - return vector2.copy( this.getPointAt ( t2 ) ) + return vector2.copy( this.getPointAt( t2 ) ) .sub( this.getPointAt( t1 ) ).normalize(); }
true
Other
mrdoob
three.js
c1f6878d23b0401e718776e9e80b77fa7e25832c.json
Fix linter errors
examples/webvr_sandbox.html
@@ -93,7 +93,7 @@ var texture3 = loader.load( "textures/lensflare/lensflare3.png" ); var lensflare = new THREE.Lensflare(); - lensflare.position.set( 0, 5, -5 ); + lensflare.position.set( 0, 5, - 5 ); lensflare.addElement( new THREE.LensflareElement( texture0, 700, 0 ) ); lensflare.addElement( new THREE.LensflareElement( texture3, 60, 0.6 ) ); lensflare.addElement( new THREE.LensflareElement( texture3, 70, 0.7 ) ); @@ -110,7 +110,7 @@ } ); reflector.position.x = 1; reflector.position.y = 0.5; - reflector.position.z = -3; + reflector.position.z = - 3; reflector.rotation.y = - Math.PI / 4; scene.add( reflector );
true
Other
mrdoob
three.js
c1f6878d23b0401e718776e9e80b77fa7e25832c.json
Fix linter errors
examples/webvr_sculpt.html
@@ -37,7 +37,7 @@ var camera, scene, renderer; var controller1, controller2; - var blob, vector; + var blob; var points = []; @@ -95,9 +95,9 @@ light.position.set( 0, 6, 0 ); light.castShadow = true; light.shadow.camera.top = 2; - light.shadow.camera.bottom = -2; + light.shadow.camera.bottom = - 2; light.shadow.camera.right = 2; - light.shadow.camera.left = -2; + light.shadow.camera.left = - 2; light.shadow.mapSize.set( 4096, 4096 ); scene.add( light ); @@ -160,8 +160,8 @@ // var pivot = new THREE.Mesh( new THREE.BoxBufferGeometry( 0.01, 0.01, 0.01 ) ); var pivot = new THREE.Mesh( new THREE.IcosahedronBufferGeometry( 0.002, 2 ), blob.material ); pivot.name = 'pivot'; - pivot.position.y = -0.016; - pivot.position.z = -0.043; + pivot.position.y = - 0.016; + pivot.position.z = - 0.043; pivot.rotation.x = Math.PI / 5.5; controller.add( pivot ); @@ -212,7 +212,7 @@ function initPoints() { points = [ - { position: new THREE.Vector3(), strength: 0.04, subtract: 10 }, + { position: new THREE.Vector3(), strength: 0.04, subtract: 10 }, { position: new THREE.Vector3(), strength: - 0.08, subtract: 10 } ];
true
Other
mrdoob
three.js
c1f6878d23b0401e718776e9e80b77fa7e25832c.json
Fix linter errors
examples/webvr_vive_paint.html
@@ -43,16 +43,12 @@ var shapes = {}; var up = new THREE.Vector3( 0, 1, 0 ); - var vector = new THREE.Vector3(); var vector1 = new THREE.Vector3(); var vector2 = new THREE.Vector3(); var vector3 = new THREE.Vector3(); var vector4 = new THREE.Vector3(); - var point4 = new THREE.Vector3(); - var point5 = new THREE.Vector3(); - init(); initGeometry(); animate(); @@ -116,9 +112,9 @@ light.position.set( 0, 6, 0 ); light.castShadow = true; light.shadow.camera.top = 2; - light.shadow.camera.bottom = -2; + light.shadow.camera.bottom = - 2; light.shadow.camera.right = 2; - light.shadow.camera.left = -2; + light.shadow.camera.left = - 2; light.shadow.mapSize.set( 4096, 4096 ); scene.add( light ); @@ -169,8 +165,8 @@ // var pivot = new THREE.Mesh( new THREE.BoxBufferGeometry( 0.01, 0.01, 0.01 ) ); var pivot = new THREE.Mesh( new THREE.IcosahedronBufferGeometry( 0.01, 2 ) ); pivot.name = 'pivot'; - pivot.position.y = -0.016; - pivot.position.z = -0.043; + pivot.position.y = - 0.016; + pivot.position.z = - 0.043; pivot.rotation.x = Math.PI / 5.5; controller.add( pivot ); @@ -235,6 +231,7 @@ // Shapes shapes[ 'tube' ] = getTubeShapes( 1.0 ); + } function getTubeShapes( size ) { @@ -245,14 +242,15 @@ var array = []; var radius = 0.01 * size; - for( var i = 0; i < sides; i ++ ) { + for ( var i = 0; i < sides; i ++ ) { var angle = ( i / sides ) * PI2; array.push( new THREE.Vector3( Math.sin( angle ) * radius, Math.cos( angle ) * radius, 0 ) ); } return array; + } @@ -389,7 +387,7 @@ if ( pivot ) { pivot.material.color.copy( controller.getColor() ); - pivot.scale.setScalar(controller.getSize()); + pivot.scale.setScalar( controller.getSize() ); var matrix = pivot.matrixWorld;
true
Other
mrdoob
three.js
c1f6878d23b0401e718776e9e80b77fa7e25832c.json
Fix linter errors
examples/webvr_vive_sculpt.html
@@ -39,7 +39,7 @@ var camera, scene, renderer; var controller1, controller2; - var blob, vector; + var blob; var points = []; @@ -97,9 +97,9 @@ light.position.set( 0, 6, 0 ); light.castShadow = true; light.shadow.camera.top = 2; - light.shadow.camera.bottom = -2; + light.shadow.camera.bottom = - 2; light.shadow.camera.right = 2; - light.shadow.camera.left = -2; + light.shadow.camera.left = - 2; light.shadow.mapSize.set( 4096, 4096 ); scene.add( light ); @@ -146,8 +146,8 @@ // var pivot = new THREE.Mesh( new THREE.BoxBufferGeometry( 0.01, 0.01, 0.01 ) ); var pivot = new THREE.Mesh( new THREE.IcosahedronBufferGeometry( 0.002, 2 ), blob.material ); pivot.name = 'pivot'; - pivot.position.y = -0.016; - pivot.position.z = -0.043; + pivot.position.y = - 0.016; + pivot.position.z = - 0.043; pivot.rotation.x = Math.PI / 5.5; controller.add( pivot ); @@ -198,7 +198,7 @@ points = [ { position: new THREE.Vector3(), strength: - 0.08, subtract: 10 }, - { position: new THREE.Vector3(), strength: 0.04, subtract: 10 } + { position: new THREE.Vector3(), strength: 0.04, subtract: 10 } ]; }
true
Other
mrdoob
three.js
baa7bec6fd58d7b0baef2cf79847a91fca495bca.json
remove unnecessary checks
examples/js/loaders/VTKLoader.js
@@ -777,37 +777,10 @@ Object.assign( THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, { delete ele[ '#text' ]; - // Get the content and optimize it - if ( ele.attributes.type === 'Float32' ) { - - if ( ele.attributes.format === 'binary' ) { - - if ( ! compressed ) { - - txt = txt.filter( function ( el, idx ) { - - if ( idx !== 0 ) return true; - - } ); - - } - - } - - } else if ( ele.attributes.type === 'Int64' ) { + if ( ele.attributes.type === 'Int64' ) { if ( ele.attributes.format === 'binary' ) { - if ( ! compressed ) { - - txt = txt.filter( function ( el, idx ) { - - if ( idx !== 0 ) return true; - - } ); - - } - txt = txt.filter( function ( el, idx ) { if ( idx % 2 !== 1 ) return true;
false
Other
mrdoob
three.js
1e2dcbd8a38475aebabae38785372131cf24159f.json
Use image.src if HTMLCanvasElement is undefined
src/extras/ImageUtils.js
@@ -10,7 +10,11 @@ var ImageUtils = { var canvas; - if ( image instanceof HTMLCanvasElement ) { + if ( typeof HTMLCanvasElement == 'undefined' ) { + + return image.src; + + } if ( image instanceof HTMLCanvasElement ) { canvas = image;
false
Other
mrdoob
three.js
269ff3d7dfb2679dcf30c3ff0a15d2ba8dc79766.json
Remove gl variable
examples/webgl_gpgpu_water.html
@@ -633,7 +633,6 @@ var currentRenderTarget = gpuCompute.getCurrentRenderTarget( heightmapVariable ); readWaterLevelShader.uniforms[ "texture" ].value = currentRenderTarget.texture; - var gl = renderer.context; for ( var i = 0; i < NUM_SPHERES; i ++ ) {
false
Other
mrdoob
three.js
684eb5ed3910b2b7da5099ece1d5f34f119be070.json
Update code style
editor/js/Sidebar.Geometry.ExtrudeGeometry.js
@@ -12,20 +12,20 @@ Sidebar.Geometry.ExtrudeGeometry = function ( editor, object ) { var geometry = object.geometry; var parameters = geometry.parameters; - var options = parameters.options; - options.curveSegments = options.curveSegments != undefined ? options.curveSegments : 12; + var options = parameters.options; + options.curveSegments = options.curveSegments != undefined ? options.curveSegments : 12; options.steps = options.steps != undefined ? options.steps : 1; options.depth = options.depth != undefined ? options.depth : 100; - options.bevelThickness =options.bevelThickness !== undefined ? options.bevelThickness : 6; - options.bevelSize = options.bevelSize !== undefined ? options.bevelSize : 4; - options.bevelOffset = options.bevelOffset !== undefined ? options.bevelOffset : 0; - options.bevelSegments = options.bevelSegments !== undefined ? options.bevelSegments : 3 - + options.bevelThickness = options.bevelThickness !== undefined ? options.bevelThickness : 6; + options.bevelSize = options.bevelSize !== undefined ? options.bevelSize : 4; + options.bevelOffset = options.bevelOffset !== undefined ? options.bevelOffset : 0; + options.bevelSegments = options.bevelSegments !== undefined ? options.bevelSegments : 3; + // curveSegments var curveSegmentsRow = new UI.Row(); - var curveSegments = new UI.Integer( options.curveSegments ).onChange( update ).setRange(1, Infinity); + var curveSegments = new UI.Integer( options.curveSegments ).onChange( update ).setRange( 1, Infinity ); curveSegmentsRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/curveSegments' ) ).setWidth( '90px' ) ); curveSegmentsRow.add( curveSegments ); @@ -35,7 +35,7 @@ Sidebar.Geometry.ExtrudeGeometry = function ( editor, object ) { // steps var stepsRow = new UI.Row(); - var steps = new UI.Integer( options.steps ).onChange( update ).setRange(1, Infinity); + var steps = new UI.Integer( options.steps ).onChange( update ).setRange( 1, Infinity ); stepsRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/steps' ) ).setWidth( '90px' ) ); stepsRow.add( steps ); @@ -45,7 +45,7 @@ Sidebar.Geometry.ExtrudeGeometry = function ( editor, object ) { // depth var depthRow = new UI.Row(); - var depth = new UI.Number( options.depth ).onChange( update ).setRange(1, Infinity); + var depth = new UI.Number( options.depth ).onChange( update ).setRange( 1, Infinity ); depthRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/depth' ) ).setWidth( '90px' ) ); depthRow.add( depth ); @@ -55,19 +55,19 @@ Sidebar.Geometry.ExtrudeGeometry = function ( editor, object ) { // enabled var enabledRow = new UI.Row(); - var enabled = new UI.Checkbox( options.bevelEnabled ).onChange( update ); + var enabled = new UI.Checkbox( options.bevelEnabled ).onChange( update ); enabledRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelEnabled' ) ).setWidth( '90px' ) ); enabledRow.add( enabled ); container.add( enabledRow ); - if(options.bevelEnabled === true){ + if ( options.bevelEnabled === true ) { // thickness var thicknessRow = new UI.Row(); - var thickness = new UI.Number( options.bevelThickness ).onChange( update ); + var thickness = new UI.Number( options.bevelThickness ).onChange( update ); thicknessRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelThickness' ) ).setWidth( '90px' ) ); thicknessRow.add( thickness ); @@ -77,7 +77,7 @@ Sidebar.Geometry.ExtrudeGeometry = function ( editor, object ) { // size var sizeRow = new UI.Row(); - var size = new UI.Number( options.bevelSize ).onChange( update ); + var size = new UI.Number( options.bevelSize ).onChange( update ); sizeRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelSize' ) ).setWidth( '90px' ) ); sizeRow.add( size ); @@ -87,7 +87,7 @@ Sidebar.Geometry.ExtrudeGeometry = function ( editor, object ) { // offset var offsetRow = new UI.Row(); - var offset = new UI.Number( options.bevelOffset ).onChange( update ); + var offset = new UI.Number( options.bevelOffset ).onChange( update ); offsetRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelOffset' ) ).setWidth( '90px' ) ); offsetRow.add( offset ); @@ -97,16 +97,17 @@ Sidebar.Geometry.ExtrudeGeometry = function ( editor, object ) { // segments var segmentsRow = new UI.Row(); - var segments = new UI.Integer( options.bevelSegments ).onChange( update ).setRange(0, Infinity); + var segments = new UI.Integer( options.bevelSegments ).onChange( update ).setRange( 0, Infinity ); segmentsRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelSegments' ) ).setWidth( '90px' ) ); segmentsRow.add( segments ); container.add( segmentsRow ); + } - var button = new UI.Button(strings.getKey( 'sidebar/geometry/extrude_geometry/shape' )).onClick(toShape).setWidth('90px').setMarginLeft('90px'); - container.add(button); + var button = new UI.Button( strings.getKey( 'sidebar/geometry/extrude_geometry/shape' ) ).onClick( toShape ).setWidth( '90px' ).setMarginLeft( '90px' ); + container.add( button ); // @@ -115,24 +116,26 @@ Sidebar.Geometry.ExtrudeGeometry = function ( editor, object ) { editor.execute( new SetGeometryCommand( object, new THREE[ geometry.type ]( parameters.shapes, { - curveSegments : curveSegments.getValue(), - steps : steps.getValue(), + curveSegments: curveSegments.getValue(), + steps: steps.getValue(), depth: depth.getValue(), - bevelEnabled : enabled.getValue(), - bevelThickness : thickness !== undefined ? thickness.getValue() : options.bevelThickness, - bevelSize : size !== undefined ? size.getValue() : options.bevelSize, - bevelOffset : offset !== undefined ? offset.getValue() : options.bevelOffset, - bevelSegments : segments !== undefined ? segments.getValue() : options.bevelSegments + bevelEnabled: enabled.getValue(), + bevelThickness: thickness !== undefined ? thickness.getValue() : options.bevelThickness, + bevelSize: size !== undefined ? size.getValue() : options.bevelSize, + bevelOffset: offset !== undefined ? offset.getValue() : options.bevelOffset, + bevelSegments: segments !== undefined ? segments.getValue() : options.bevelSegments } ) ) ); } function toShape() { + editor.execute( new SetGeometryCommand( object, new THREE.ShapeBufferGeometry( parameters.shapes, options.curveSegments - ))); + ) ) ); + } return container;
false
Other
mrdoob
three.js
f04b450af203ecd829516c45ad5cc43b20f9cd96.json
Add all extrude parameters
editor/js/Sidebar.Geometry.ExtrudeGeometry.js
@@ -2,7 +2,7 @@ * @author Temdog007 / http://github.com/Temdog007 */ -Sidebar.Geometry.BoxGeometry = function ( editor, object ) { +Sidebar.Geometry.ExtrudeGeometry = function ( editor, object ) { var strings = editor.strings; @@ -12,21 +12,20 @@ Sidebar.Geometry.BoxGeometry = function ( editor, object ) { var geometry = object.geometry; var parameters = geometry.parameters; - var options = parameters.options || { - curveSegments : 12, - steps : 1, - depth : 100, - bevelEnabled : true, - bevelThickness : 6, - bevelSize : 4, - bevelOffset : 0, - bevelSegments : 3 - }; + var options = parameters.options; + options.curveSegments = options.curveSegments != undefined ? options.curveSegments : 12; + options.steps = options.steps != undefined ? options.steps : 1; + options.depth = options.depth != undefined ? options.depth : 100; + options.bevelThickness =options.bevelThickness !== undefined ? options.bevelThickness : 6; + options.bevelSize = options.bevelSize !== undefined ? options.bevelSize : 4; + options.bevelOffset = options.bevelOffset !== undefined ? options.bevelOffset : 0; + options.bevelSegments = options.bevelSegments !== undefined ? options.bevelSegments : 3 + // curveSegments var curveSegmentsRow = new UI.Row(); - var curveSegments = new UI.Number( options.curveSegments ).onChange( update ).setRange(1, Infinity); + var curveSegments = new UI.Integer( options.curveSegments ).onChange( update ).setRange(1, Infinity); curveSegmentsRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/curveSegments' ) ).setWidth( '90px' ) ); curveSegmentsRow.add( curveSegments ); @@ -36,13 +35,79 @@ Sidebar.Geometry.BoxGeometry = function ( editor, object ) { // steps var stepsRow = new UI.Row(); - var steps = new UI.Number( options.steps ).onChange( update ).setRange(1, Infinity); + var steps = new UI.Integer( options.steps ).onChange( update ).setRange(1, Infinity); stepsRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/steps' ) ).setWidth( '90px' ) ); stepsRow.add( steps ); container.add( stepsRow ); + // depth + + var depthRow = new UI.Row(); + var depth = new UI.Number( options.depth ).onChange( update ).setRange(1, Infinity); + + depthRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/depth' ) ).setWidth( '90px' ) ); + depthRow.add( depth ); + + container.add( depthRow ); + + // enabled + + var enabledRow = new UI.Row(); + var enabled = new UI.Checkbox( options.bevelEnabled ).onChange( update ); + + enabledRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelEnabled' ) ).setWidth( '90px' ) ); + enabledRow.add( enabled ); + + container.add( enabledRow ); + + if(options.bevelEnabled === true){ + + // thickness + + var thicknessRow = new UI.Row(); + var thickness = new UI.Number( options.bevelThickness ).onChange( update ); + + thicknessRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelThickness' ) ).setWidth( '90px' ) ); + thicknessRow.add( thickness ); + + container.add( thicknessRow ); + + // size + + var sizeRow = new UI.Row(); + var size = new UI.Number( options.bevelSize ).onChange( update ); + + sizeRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelSize' ) ).setWidth( '90px' ) ); + sizeRow.add( size ); + + container.add( sizeRow ); + + // offset + + var offsetRow = new UI.Row(); + var offset = new UI.Number( options.bevelOffset ).onChange( update ); + + offsetRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelOffset' ) ).setWidth( '90px' ) ); + offsetRow.add( offset ); + + container.add( offsetRow ); + + // segments + + var segmentsRow = new UI.Row(); + var segments = new UI.Integer( options.bevelSegments ).onChange( update ).setRange(0, Infinity); + + segmentsRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelSegments' ) ).setWidth( '90px' ) ); + segmentsRow.add( segments ); + + container.add( segmentsRow ); + } + + var button = new UI.Button(strings.getKey( 'sidebar/geometry/extrude_geometry/shape' )).onClick(toShape).setWidth('90px').setMarginLeft('90px'); + container.add(button); + // function update() { @@ -51,14 +116,27 @@ Sidebar.Geometry.BoxGeometry = function ( editor, object ) { parameters.shapes, { curveSegments : curveSegments.getValue(), - steps : steps.getValue() + steps : steps.getValue(), + depth: depth.getValue(), + bevelEnabled : enabled.getValue(), + bevelThickness : thickness !== undefined ? thickness.getValue() : options.bevelThickness, + bevelSize : size !== undefined ? size.getValue() : options.bevelSize, + bevelOffset : offset !== undefined ? offset.getValue() : options.bevelOffset, + bevelSegments : segments !== undefined ? segments.getValue() : options.bevelSegments } ) ) ); } + function toShape() { + editor.execute( new SetGeometryCommand( object, new THREE.ShapeBufferGeometry( + parameters.shapes, + options.curveSegments + ))); + } + return container; }; -Sidebar.Geometry.BoxBufferGeometry = Sidebar.Geometry.BoxGeometry; +Sidebar.Geometry.ExtrudeBufferGeometry = Sidebar.Geometry.ExtrudeGeometry;
true
Other
mrdoob
three.js
f04b450af203ecd829516c45ad5cc43b20f9cd96.json
Add all extrude parameters
editor/js/Strings.js
@@ -143,6 +143,7 @@ var Strings = function ( config ) { 'sidebar/geometry/extrude_geometry/bevelSize': 'Size', 'sidebar/geometry/extrude_geometry/bevelOffset': 'Offset', 'sidebar/geometry/extrude_geometry/bevelSegments': 'Segments', + 'sidebar/geometry/extrude_geometry/shape': 'Convert to Shape', 'sidebar/geometry/geometry/vertices': 'Vertices', 'sidebar/geometry/geometry/faces': 'Faces',
true
Other
mrdoob
three.js
f9b0ba6fd2654861536f89ae0c936d92b901effa.json
Add curve segments to extrude options
editor/js/Sidebar.Geometry.ShapeGeometry.js
@@ -32,7 +32,7 @@ Sidebar.Geometry.ShapeGeometry = function ( editor, object ) { function changeShape() { editor.execute( new SetGeometryCommand( object, new THREE[ geometry.type ]( - geometry.parameters.shapes, + parameters.shapes, curveSegments.getValue() ) ) ); @@ -41,7 +41,9 @@ Sidebar.Geometry.ShapeGeometry = function ( editor, object ) { function toExtrude() { editor.execute( new SetGeometryCommand( object, new THREE.ExtrudeBufferGeometry( - geometry.parameters.shapes, {} + parameters.shapes, { + curveSegments: curveSegments.getValue() + } ) ) ); }
false
Other
mrdoob
three.js
350a8de17783b0272dabce1efc612df1824f8829.json
Add options to ShapeGeometry
editor/index.html
@@ -131,6 +131,7 @@ <script src="js/Sidebar.Geometry.PlaneGeometry.js"></script> <script src="js/Sidebar.Geometry.RingGeometry.js"></script> <script src="js/Sidebar.Geometry.SphereGeometry.js"></script> + <script src="js/Sidebar.Geometry.ShapeGeometry.js"></script> <script src="js/Sidebar.Geometry.TetrahedronGeometry.js"></script> <script src="js/Sidebar.Geometry.TorusGeometry.js"></script> <script src="js/Sidebar.Geometry.TorusKnotGeometry.js"></script>
true
Other
mrdoob
three.js
350a8de17783b0272dabce1efc612df1824f8829.json
Add options to ShapeGeometry
editor/js/Sidebar.Geometry.ShapeGeometry.js
@@ -0,0 +1,53 @@ +/** + * @author Temdog007 / http://github.com/Temdog007 + */ + +Sidebar.Geometry.ShapeGeometry = function ( editor, object ) { + + var strings = editor.strings; + + var signals = editor.signals; + + var container = new UI.Row(); + + var geometry = object.geometry; + var parameters = geometry.parameters; + + // curveSegments + + var curveSegmentsRow = new UI.Row(); + var curveSegments = new UI.Number( parameters.curveSegments || 12 ).onChange( changeShape ); + + curveSegmentsRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/shape_geometry/curveSegments' ) ).setWidth( '90px' ) ); + curveSegmentsRow.add( curveSegments ); + + container.add( curveSegmentsRow ); + + // to extrude + var button = new UI.Button( strings.getKey( 'sidebar/geometry/shape_geometry/extrude' ) ).onClick( toExtrude ).setWidth( '90px' ).setMarginLeft( '90px' ); + container.add( button ); + + // + + function changeShape() { + + editor.execute( new SetGeometryCommand( object, new THREE[ geometry.type ]( + geometry.parameters.shapes, + curveSegments.getValue() + ) ) ); + + } + + function toExtrude() { + + editor.execute( new SetGeometryCommand( object, new THREE.ExtrudeBufferGeometry( + geometry.parameters.shapes, {} + ) ) ); + + } + + return container; + +}; + +Sidebar.Geometry.ShapeBufferGeometry = Sidebar.Geometry.ShapeGeometry;
true
Other
mrdoob
three.js
350a8de17783b0272dabce1efc612df1824f8829.json
Add options to ShapeGeometry
editor/js/Strings.js
@@ -164,6 +164,9 @@ var Strings = function ( config ) { 'sidebar/geometry/ring_geometry/thetastart': 'Theta start', 'sidebar/geometry/ring_geometry/thetalength': 'Theta length', + 'sidebar/geometry/shape_geometry/curveSegments': 'Curve Segments', + 'sidebar/geometry/shape_geometry/extrude': 'Extrude', + 'sidebar/geometry/sphere_geometry/radius': 'Radius', 'sidebar/geometry/sphere_geometry/widthsegments': 'Width segments', 'sidebar/geometry/sphere_geometry/heightsegments': 'Height segments',
true
Other
mrdoob
three.js
15ee4cf3b3cb6c8bbec642c22b3645e98f1511c8.json
Remove redefinition of fog chunk
examples/js/effects/OutlineEffect.js
@@ -108,8 +108,6 @@ THREE.OutlineEffect = function ( renderer, parameters ) { var vertexShaderChunk = [ - "#include <fog_pars_vertex>", - "uniform float outlineThickness;", "vec4 calculateOutline( vec4 pos, vec3 objectNormal, vec4 skinned ) {",
false
Other
mrdoob
three.js
f70703ac764751aef3086a29d02af3c17b073301.json
Add error log if Collada file can't be parsed
examples/js/loaders/ColladaLoader.js
@@ -3824,6 +3824,14 @@ THREE.ColladaLoader.prototype = { var collada = getElementsByTagName( xml, 'COLLADA' )[ 0 ]; + var parserError = xml.getElementsByTagName( 'parsererror' )[ 0 ]; + if ( parserError !== undefined ) { + + console.error( 'ColladaLoader: Failed to parse collada file.', parserError ); + return null; + + } + // metadata var version = collada.getAttribute( 'version' );
false
Other
mrdoob
three.js
345f9cc287c2a5d5e3c4ac96a4f3cebc6779dfa4.json
Remove unneeded closure
src/loaders/ObjectLoader.js
@@ -580,284 +580,280 @@ Object.assign( ObjectLoader.prototype, { }, - parseObject: function () { + parseObject: function ( data, geometries, materials ) { - return function parseObject( data, geometries, materials ) { + var object; - var object; + function getGeometry( name ) { - function getGeometry( name ) { + if ( geometries[ name ] === undefined ) { - if ( geometries[ name ] === undefined ) { - - console.warn( 'THREE.ObjectLoader: Undefined geometry', name ); - - } - - return geometries[ name ]; + console.warn( 'THREE.ObjectLoader: Undefined geometry', name ); } - function getMaterial( name ) { + return geometries[ name ]; - if ( name === undefined ) return undefined; + } - if ( Array.isArray( name ) ) { + function getMaterial( name ) { - var array = []; + if ( name === undefined ) return undefined; - for ( var i = 0, l = name.length; i < l; i ++ ) { + if ( Array.isArray( name ) ) { - var uuid = name[ i ]; + var array = []; - if ( materials[ uuid ] === undefined ) { + for ( var i = 0, l = name.length; i < l; i ++ ) { - console.warn( 'THREE.ObjectLoader: Undefined material', uuid ); + var uuid = name[ i ]; - } + if ( materials[ uuid ] === undefined ) { - array.push( materials[ uuid ] ); + console.warn( 'THREE.ObjectLoader: Undefined material', uuid ); } - return array; + array.push( materials[ uuid ] ); } - if ( materials[ name ] === undefined ) { + return array; - console.warn( 'THREE.ObjectLoader: Undefined material', name ); + } - } + if ( materials[ name ] === undefined ) { - return materials[ name ]; + console.warn( 'THREE.ObjectLoader: Undefined material', name ); } - switch ( data.type ) { + return materials[ name ]; + + } - case 'Scene': + switch ( data.type ) { - object = new Scene(); + case 'Scene': - if ( data.background !== undefined ) { + object = new Scene(); - if ( Number.isInteger( data.background ) ) { + if ( data.background !== undefined ) { - object.background = new Color( data.background ); + if ( Number.isInteger( data.background ) ) { - } + object.background = new Color( data.background ); } - if ( data.fog !== undefined ) { + } - if ( data.fog.type === 'Fog' ) { + if ( data.fog !== undefined ) { - object.fog = new Fog( data.fog.color, data.fog.near, data.fog.far ); + if ( data.fog.type === 'Fog' ) { - } else if ( data.fog.type === 'FogExp2' ) { + object.fog = new Fog( data.fog.color, data.fog.near, data.fog.far ); - object.fog = new FogExp2( data.fog.color, data.fog.density ); + } else if ( data.fog.type === 'FogExp2' ) { - } + object.fog = new FogExp2( data.fog.color, data.fog.density ); } - break; + } - case 'PerspectiveCamera': + break; - object = new PerspectiveCamera( data.fov, data.aspect, data.near, data.far ); + case 'PerspectiveCamera': - if ( data.focus !== undefined ) object.focus = data.focus; - if ( data.zoom !== undefined ) object.zoom = data.zoom; - if ( data.filmGauge !== undefined ) object.filmGauge = data.filmGauge; - if ( data.filmOffset !== undefined ) object.filmOffset = data.filmOffset; - if ( data.view !== undefined ) object.view = Object.assign( {}, data.view ); + object = new PerspectiveCamera( data.fov, data.aspect, data.near, data.far ); - break; + if ( data.focus !== undefined ) object.focus = data.focus; + if ( data.zoom !== undefined ) object.zoom = data.zoom; + if ( data.filmGauge !== undefined ) object.filmGauge = data.filmGauge; + if ( data.filmOffset !== undefined ) object.filmOffset = data.filmOffset; + if ( data.view !== undefined ) object.view = Object.assign( {}, data.view ); - case 'OrthographicCamera': + break; - object = new OrthographicCamera( data.left, data.right, data.top, data.bottom, data.near, data.far ); + case 'OrthographicCamera': - break; + object = new OrthographicCamera( data.left, data.right, data.top, data.bottom, data.near, data.far ); - case 'AmbientLight': + break; - object = new AmbientLight( data.color, data.intensity ); + case 'AmbientLight': - break; + object = new AmbientLight( data.color, data.intensity ); - case 'DirectionalLight': + break; - object = new DirectionalLight( data.color, data.intensity ); + case 'DirectionalLight': - break; + object = new DirectionalLight( data.color, data.intensity ); - case 'PointLight': + break; - object = new PointLight( data.color, data.intensity, data.distance, data.decay ); + case 'PointLight': - break; + object = new PointLight( data.color, data.intensity, data.distance, data.decay ); - case 'RectAreaLight': + break; - object = new RectAreaLight( data.color, data.intensity, data.width, data.height ); + case 'RectAreaLight': - break; + object = new RectAreaLight( data.color, data.intensity, data.width, data.height ); - case 'SpotLight': + break; - object = new SpotLight( data.color, data.intensity, data.distance, data.angle, data.penumbra, data.decay ); + case 'SpotLight': - break; + object = new SpotLight( data.color, data.intensity, data.distance, data.angle, data.penumbra, data.decay ); - case 'HemisphereLight': + break; - object = new HemisphereLight( data.color, data.groundColor, data.intensity ); + case 'HemisphereLight': - break; + object = new HemisphereLight( data.color, data.groundColor, data.intensity ); - case 'SkinnedMesh': + break; - console.warn( 'THREE.ObjectLoader.parseObject() does not support SkinnedMesh yet.' ); + case 'SkinnedMesh': - case 'Mesh': + console.warn( 'THREE.ObjectLoader.parseObject() does not support SkinnedMesh yet.' ); - var geometry = getGeometry( data.geometry ); - var material = getMaterial( data.material ); + case 'Mesh': - if ( geometry.bones && geometry.bones.length > 0 ) { + var geometry = getGeometry( data.geometry ); + var material = getMaterial( data.material ); - object = new SkinnedMesh( geometry, material ); + if ( geometry.bones && geometry.bones.length > 0 ) { - } else { + object = new SkinnedMesh( geometry, material ); - object = new Mesh( geometry, material ); + } else { - } + object = new Mesh( geometry, material ); - break; + } - case 'LOD': + break; - object = new LOD(); + case 'LOD': - break; + object = new LOD(); - case 'Line': + break; - object = new Line( getGeometry( data.geometry ), getMaterial( data.material ), data.mode ); + case 'Line': - break; + object = new Line( getGeometry( data.geometry ), getMaterial( data.material ), data.mode ); - case 'LineLoop': + break; - object = new LineLoop( getGeometry( data.geometry ), getMaterial( data.material ) ); + case 'LineLoop': - break; + object = new LineLoop( getGeometry( data.geometry ), getMaterial( data.material ) ); - case 'LineSegments': + break; - object = new LineSegments( getGeometry( data.geometry ), getMaterial( data.material ) ); + case 'LineSegments': - break; + object = new LineSegments( getGeometry( data.geometry ), getMaterial( data.material ) ); - case 'PointCloud': - case 'Points': + break; - object = new Points( getGeometry( data.geometry ), getMaterial( data.material ) ); + case 'PointCloud': + case 'Points': - break; + object = new Points( getGeometry( data.geometry ), getMaterial( data.material ) ); - case 'Sprite': + break; - object = new Sprite( getMaterial( data.material ) ); + case 'Sprite': - break; + object = new Sprite( getMaterial( data.material ) ); - case 'Group': + break; - object = new Group(); + case 'Group': - break; + object = new Group(); - default: + break; - object = new Object3D(); + default: - } + object = new Object3D(); - object.uuid = data.uuid; + } - if ( data.name !== undefined ) object.name = data.name; - if ( data.matrix !== undefined ) { + object.uuid = data.uuid; - object.matrix.fromArray( data.matrix ); - object.matrix.decompose( object.position, object.quaternion, object.scale ); + if ( data.name !== undefined ) object.name = data.name; + if ( data.matrix !== undefined ) { - } else { + object.matrix.fromArray( data.matrix ); + object.matrix.decompose( object.position, object.quaternion, object.scale ); - if ( data.position !== undefined ) object.position.fromArray( data.position ); - if ( data.rotation !== undefined ) object.rotation.fromArray( data.rotation ); - if ( data.quaternion !== undefined ) object.quaternion.fromArray( data.quaternion ); - if ( data.scale !== undefined ) object.scale.fromArray( data.scale ); + } else { - } + if ( data.position !== undefined ) object.position.fromArray( data.position ); + if ( data.rotation !== undefined ) object.rotation.fromArray( data.rotation ); + if ( data.quaternion !== undefined ) object.quaternion.fromArray( data.quaternion ); + if ( data.scale !== undefined ) object.scale.fromArray( data.scale ); - if ( data.castShadow !== undefined ) object.castShadow = data.castShadow; - if ( data.receiveShadow !== undefined ) object.receiveShadow = data.receiveShadow; + } - if ( data.shadow ) { + if ( data.castShadow !== undefined ) object.castShadow = data.castShadow; + if ( data.receiveShadow !== undefined ) object.receiveShadow = data.receiveShadow; - if ( data.shadow.bias !== undefined ) object.shadow.bias = data.shadow.bias; - if ( data.shadow.radius !== undefined ) object.shadow.radius = data.shadow.radius; - if ( data.shadow.mapSize !== undefined ) object.shadow.mapSize.fromArray( data.shadow.mapSize ); - if ( data.shadow.camera !== undefined ) object.shadow.camera = this.parseObject( data.shadow.camera ); + if ( data.shadow ) { - } + if ( data.shadow.bias !== undefined ) object.shadow.bias = data.shadow.bias; + if ( data.shadow.radius !== undefined ) object.shadow.radius = data.shadow.radius; + if ( data.shadow.mapSize !== undefined ) object.shadow.mapSize.fromArray( data.shadow.mapSize ); + if ( data.shadow.camera !== undefined ) object.shadow.camera = this.parseObject( data.shadow.camera ); - if ( data.visible !== undefined ) object.visible = data.visible; - if ( data.userData !== undefined ) object.userData = data.userData; + } - if ( data.children !== undefined ) { + if ( data.visible !== undefined ) object.visible = data.visible; + if ( data.userData !== undefined ) object.userData = data.userData; - var children = data.children; + if ( data.children !== undefined ) { - for ( var i = 0; i < children.length; i ++ ) { + var children = data.children; - object.add( this.parseObject( children[ i ], geometries, materials ) ); + for ( var i = 0; i < children.length; i ++ ) { - } + object.add( this.parseObject( children[ i ], geometries, materials ) ); } - if ( data.type === 'LOD' ) { + } - var levels = data.levels; + if ( data.type === 'LOD' ) { - for ( var l = 0; l < levels.length; l ++ ) { + var levels = data.levels; - var level = levels[ l ]; - var child = object.getObjectByProperty( 'uuid', level.object ); + for ( var l = 0; l < levels.length; l ++ ) { - if ( child !== undefined ) { + var level = levels[ l ]; + var child = object.getObjectByProperty( 'uuid', level.object ); - object.addLevel( child, level.distance ); + if ( child !== undefined ) { - } + object.addLevel( child, level.distance ); } } - return object; + } - }; + return object; - }() + } } );
false
Other
mrdoob
three.js
3d3343d9c147816c6f17814befb81e7a3d27691a.json
Update object matrix
src/loaders/ObjectLoader.js
@@ -582,8 +582,6 @@ Object.assign( ObjectLoader.prototype, { parseObject: function () { - var matrix = new Matrix4(); - return function parseObject( data, geometries, materials ) { var object; @@ -797,8 +795,8 @@ Object.assign( ObjectLoader.prototype, { if ( data.name !== undefined ) object.name = data.name; if ( data.matrix !== undefined ) { - matrix.fromArray( data.matrix ); - matrix.decompose( object.position, object.quaternion, object.scale ); + object.matrix.fromArray( data.matrix ); + object.matrix.decompose( object.position, object.quaternion, object.scale ); } else {
false
Other
mrdoob
three.js
20527db3b58a27a9c0119152ce9840cbbd2c04f6.json
add points to obj loader
examples/js/loaders/OBJLoader.js
@@ -216,6 +216,15 @@ THREE.OBJLoader = ( function () { }, + addVertexPoint: function ( a ) { + + var src = this.vertices; + var dst = this.object.geometry.vertices; + + dst.push( src[ a + 0 ], src[ a + 1 ], src[ a + 2 ] ); + + }, + addVertexLine: function ( a ) { var src = this.vertices; @@ -310,6 +319,20 @@ THREE.OBJLoader = ( function () { }, + addPointGeometry: function ( vertices ) { + + this.object.geometry.type = 'Points'; + + var vLen = this.vertices.length; + + for ( var vi = 0, l = vertices.length; vi < l; vi ++ ) { + + this.addVertexPoint( this.parseVertexIndex( vertices[ vi ], vLen ) ); + + } + + }, + addLineGeometry: function ( vertices, uvs ) { this.object.geometry.type = 'Line'; @@ -524,6 +547,13 @@ THREE.OBJLoader = ( function () { } state.addLineGeometry( lineVertices, lineUVs ); + } else if ( lineFirstChar === 'p' ) { + + var lineData = line.substr( 1 ).trim(); + var pointData = lineData.split( " " ); + + state.addPointGeometry( pointData ); + } else if ( ( result = object_pattern.exec( line ) ) !== null ) { // o object_name @@ -608,6 +638,7 @@ THREE.OBJLoader = ( function () { var geometry = object.geometry; var materials = object.materials; var isLine = ( geometry.type === 'Line' ); + var isPoints = ( geometry.type === 'Points' ); var hasVertexColors = false; // Skip o/g line declarations that did not follow with any faces @@ -661,13 +692,32 @@ THREE.OBJLoader = ( function () { materialLine.lights = false; // TOFIX material = materialLine; + } else if ( isPoints && material && ! ( material instanceof THREE.PointsMaterial ) ) { + + var materialPoints = new THREE.PointsMaterial( { size: 10, sizeAttenuation: false } ); + materialLine.copy( material ); + material = materialPoints; + } } if ( ! material ) { - material = ( ! isLine ? new THREE.MeshPhongMaterial() : new THREE.LineBasicMaterial() ); + if ( isLine ) { + + material = new THREE.LineBasicMaterial(); + + } else if ( isPoints ) { + + material = new THREE.PointsMaterial( { size: 1, sizeAttenuation: false } ); + + } else { + + material = new THREE.MeshPhongMaterial(); + + } + material.name = sourceMaterial.name; } @@ -692,11 +742,35 @@ THREE.OBJLoader = ( function () { } - mesh = ( ! isLine ? new THREE.Mesh( buffergeometry, createdMaterials ) : new THREE.LineSegments( buffergeometry, createdMaterials ) ); + if ( isLine ) { + + mesh = new THREE.LineSegments( buffergeometry, createdMaterials ); + + } else if ( isPoints ) { + + mesh = new THREE.Points( buffergeometry, createdMaterials ); + + } else { + + mesh = new THREE.Mesh( buffergeometry, createdMaterials ); + + } } else { - mesh = ( ! isLine ? new THREE.Mesh( buffergeometry, createdMaterials[ 0 ] ) : new THREE.LineSegments( buffergeometry, createdMaterials[ 0 ] ) ); + if ( isLine ) { + + mesh = new THREE.LineSegments( buffergeometry, createdMaterials[ 0 ] ); + + } else if ( isPoints ) { + + mesh = new THREE.Points( buffergeometry, createdMaterials[ 0 ] ); + + } else { + + mesh = new THREE.Mesh( buffergeometry, createdMaterials[ 0 ] ); + + } }
true
Other
mrdoob
three.js
20527db3b58a27a9c0119152ce9840cbbd2c04f6.json
add points to obj loader
examples/obj/pointCloudBox/pointCloudBox.obj
@@ -0,0 +1,26 @@ +# Vertices: 8 +# Points: 0 +# Lines: 0 +# Faces: 6 +# Materials: 1 + +o 1 + +# Vertex list + +v -0.5 -0.5 0.5 +v -0.5 -0.5 -0.5 +v -0.5 0.5 -0.5 +v -0.5 0.5 0.5 +v 0.5 -0.5 0.5 +v 0.5 -0.5 -0.5 +v 0.5 0.5 -0.5 +v 0.5 0.5 0.5 + +# Point/Line/Face list + +usemtl Default + +p 1 2 3 4 5 6 7 8 + +# End of file
true
Other
mrdoob
three.js
f960bf42a5b6c1accae46557dbdf4084debc032c.json
fix minification bug
examples/js/loaders/FBXLoader.js
@@ -2893,7 +2893,7 @@ }, - parseSubNode( name, node, subNode ) { + parseSubNode: function ( name, node, subNode ) { // special case: child node is single property if ( subNode.singleProperty === true ) {
false
Other
mrdoob
three.js
8e56415cc65d0e0d061e559e94b07006f8a2eaa0.json
Add GLTFLoader PointsMaterial support
examples/js/loaders/GLTFLoader.js
@@ -2120,6 +2120,24 @@ THREE.GLTFLoader = ( function () { } else if ( primitive.mode === WEBGL_CONSTANTS.POINTS ) { + var cacheKey = 'PointsMaterial:' + material.uuid; + + var pointsMaterial = scope.cache.get( cacheKey ); + + if ( ! pointsMaterial ) { + + pointsMaterial = new THREE.PointsMaterial(); + THREE.Material.prototype.copy.call( pointsMaterial, material ); + pointsMaterial.color.copy( material.color ); + pointsMaterial.map = material.map; + pointsMaterial.lights = false; // PointsMaterial doesn't support lights yet + + scope.cache.add( cacheKey, pointsMaterial ); + + } + + material = pointsMaterial; + mesh = new THREE.Points( geometry, material ); } else {
false
Other
mrdoob
three.js
86d299d368eb75cf37abcc911e2d2ad04ac2dca8.json
use Scene.onBeforeRender and .onAfterRender
examples/webgl_tiled_forward.html
@@ -0,0 +1,343 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <title>three.js webgl - tiled forward lighting</title> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> + <style> + body { + font-family: Monospace; + background-color: #101010; + color: #fff; + margin: 0px; + overflow: hidden; + } + a { + color: #f00; + } + + #info { + position: absolute; + left: 0; + top: 0px; width: 100%; + padding: 5px; + display: inline-block; + text-align:center; + } + </style> + </head> + <body> + <div id="info"> + <a href="http://threejs.org" target="_blank" rel="noopener">threejs</a> - Tiled forward lighting<br/> + Created by <a href="https://github.com/wizgrav" target="_blank" rel="noopener">wizgrav</a>. + </div> + <script src="../build/three.js"></script> + <script src="js/controls/OrbitControls.js"></script> + <script src="js/postprocessing/EffectComposer.js"></script> + <script src="js/postprocessing/RenderPass.js"></script> + <script src="js/postprocessing/MaskPass.js"></script> + <script src="js/postprocessing/ShaderPass.js"></script> + <script src="js/shaders/CopyShader.js"></script> + <script src="js/shaders/ConvolutionShader.js"></script> + <script src="js/shaders/LuminosityHighPassShader.js"></script> + <script src="js/postprocessing/UnrealBloomPass.js"></script> + <script src="js/Detector.js"></script> + <script src="js/libs/stats.min.js"></script> + + <script> + + // Simple form of tiled forward lighting + // using texels as bitmasks of 32 lights + + var RADIUS = 75; + + THREE.ShaderChunk["lights_pars"] += [ + "#if defined TILED_FORWARD", + "uniform vec4 tileData;", + "uniform sampler2D tileTexture;", + "uniform sampler2D lightTexture;", + "#endif" + ].join("\n"); + + THREE.ShaderChunk["lights_template"] += [ + "", + "#if defined TILED_FORWARD", + "vec2 tUv = floor(gl_FragCoord.xy / tileData.xy * 32.) / 32. + tileData.zw;", + "vec4 tile = texture2D(tileTexture, tUv);", + "for (int i=0; i < 4; i++) {", + " float tileVal = tile.x * 255.;", + " tile.xyzw = tile.yzwx;", + " if(tileVal == 0.){ continue; }", + " float tileDiv = 128.;", + " for (int j=0; j < 8; j++) {", + " if (tileVal < tileDiv) { tileDiv *= 0.5; continue; }", + " tileVal -= tileDiv;", + " tileDiv *= 0.5;", + " PointLight pointlight;", + " float uvx = (float(8 * i + j) + 0.5) / 32.;", + " vec4 lightData = texture2D(lightTexture, vec2(uvx, 0.));", + " vec4 lightColor = texture2D(lightTexture, vec2(uvx, 1.));", + " pointlight.position = lightData.xyz;", + " pointlight.distance = lightData.w;", + " pointlight.color = lightColor.rgb;", + " pointlight.decay = lightColor.a;", + " getPointDirectLightIrradiance( pointlight, geometry, directLight );", + " RE_Direct( directLight, geometry, material, reflectedLight );", + " }", + "}", + "#endif" + ].join("\n"); + + var lights = [], objects = []; + + var State = { + rows:0, + cols:0, + width: 0, + height: 0, + tileData : { type: "v4", value: null }, + tileTexture: { type: "t", value: null }, + lightTexture: { + type: "t", + value: new THREE.DataTexture(new Float32Array(32 * 2 * 4), 32, 2, THREE.RGBAFormat, THREE.FloatType) + }, + }; + + function resizeTiles() { + var width = window.innerWidth; + var height = window.innerHeight; + + State.width = width; + State.height = height; + State.cols = Math.ceil(width / 32); + State.rows = Math.ceil(height / 32); + State.tileData.value = [ width, height, 0.5 / Math.ceil( width / 32), 0.5 / Math.ceil( height / 32) ]; + State.tileTexture.value = new THREE.DataTexture( new Uint8Array(State.cols * State.rows * 4), State.cols, State.rows); + } + + // Generate the light bitmasks and store them in the tile texture + function tileLights(renderer, scene, camera) { + if(!camera.projectionMatrix) return; + + var d = State.tileTexture.value.image.data; + var ld = State.lightTexture.value.image.data; + + var viewMatrix = camera.matrixWorldInverse; + + d.fill(0); + + var vector = new THREE.Vector3(); + + lights.forEach(function (light, index) { + + vector.setFromMatrixPosition( light.matrixWorld ); + + var bs = lightBounds(camera, vector, light._light.radius); + + vector.applyMatrix4( viewMatrix ); + vector.toArray(ld, 4 * index); + ld[4 * index + 3] = light._light.radius; + light._light.color.toArray(ld,32 * 4 + 4 * index); + ld[32 * 4 + 4 * index + 3] = light._light.decay; + + if(bs[1] < 0 || bs[0] > State.width || bs[3] < 0 || bs[2] > State.height) return; + if(bs[0] < 0) bs[0] = 0; + if(bs[1] > State.width) bs[1] = State.width; + if(bs[2] < 0) bs[2] = 0; + if(bs[3] > State.height) bs[3] = State.height; + + var i4 = Math.floor(index / 8), i8 = 7 - (index % 8); + for (var i = Math.floor(bs[2] / 32); i <= Math.ceil(bs[3]/32); i++) { + for(var j = Math.floor(bs[0]/32); j <= Math.ceil(bs[1]/32); j++) { + d[(State.cols * i + j) * 4 + i4] |= 1 << i8; + } + } + }); + + State.tileTexture.value.needsUpdate = true; + State.lightTexture.value.needsUpdate = true; + } + + // Screen rectangle bounds from light sphere's world AABB + var lightBounds = function (){ + v = new THREE.Vector3(); + return function (camera, pos, r) { + var minX = State.width, maxX = 0, minY = State.height, maxY = 0, hw = State.width / 2, hh = State.height / 2; + for(var i = 0; i < 8; i++){ + v.copy(pos); + v.x += i & 1 ? r : -r; + v.y += i & 2 ? r : -r; + v.z += i & 4 ? r : -r; + var vector = v.project(camera); + var x = (vector.x * hw) + hw; + var y = (vector.y * hh) + hh; + minX = Math.min(minX, x); + maxX = Math.max(maxX, x); + minY = Math.min(minY, y); + maxY = Math.max(maxY, y); + } + return [minX, maxX, minY, maxY]; + } + }(); + + + // Rendering + + var container = document.createElement( 'div' ); + document.body.appendChild( container ); + var camera = new THREE.PerspectiveCamera( 40, window.innerWidth / window.innerHeight, 1, 2000 ); + camera.position.set( 0.0, 0.0, 240.0 ); + var scene = new THREE.Scene(); + scene.background = new THREE.Color( 0x111111 ); + + var renderer = new THREE.WebGLRenderer( { antialias: false } ); + renderer.toneMapping = THREE.LinearToneMapping; + container.appendChild( renderer.domElement ); + + var renderTarget = new THREE.WebGLRenderTarget(); + + scene.add( new THREE.AmbientLight( 0xffffff, 0.33 ) ); + // At least one regular Pointlight is needed to activate light support + scene.add(new THREE.PointLight( 0xff0000, 0.1, 0.1 )); + + var bloom = new THREE.UnrealBloomPass( new THREE.Vector2(), 0.8, 0.6, 0.8 ); + bloom.renderToScreen = true; + + var stats = new Stats(); + container.appendChild( stats.dom ); + + controls = new THREE.OrbitControls( camera, renderer.domElement ); + controls.minDistance = 120; + controls.maxDistance = 320; + + var materials = []; + + var Heads = [ + { type: "physical", uniforms: { diffuse: 0x888888, metalness: 1.0, roughness: 0.66}, defines: {} }, + { type: "standard", uniforms: { diffuse: 0x666666, metalness: 0.1, roughness: 0.33}, defines: {} }, + { type: "phong", uniforms: { diffuse: 0x777777, shininess: 20}, defines: {} }, + { type: "phong", uniforms: { diffuse: 0x555555, shininess: 10}, defines: { TOON: 1} } + ]; + + function init (geom) { + var sphereGeom = new THREE.SphereBufferGeometry( 0.5, 32, 32 ); + var tIndex = Math.round(Math.random() * 3); + Object.keys(Heads).forEach(function(t, index) { + var g = new THREE.Group(); + var conf = Heads[t]; + var ml = THREE.ShaderLib[conf.type]; + var mtl = new THREE.ShaderMaterial({ + lights: true, + fragmentShader: ml.fragmentShader, + vertexShader: ml.vertexShader, + uniforms: THREE.UniformsUtils.clone(ml.uniforms), + defines: conf.defines, + transparent: tIndex === index ? true : false, + + }); + mtl.uniforms.opacity.value = tIndex === index ? 0.9 : 1; + mtl.uniforms.tileData = State.tileData; + mtl.uniforms.tileTexture = State.tileTexture; + mtl.uniforms.lightTexture = State.lightTexture; + for( var u in conf.uniforms ) { + var vu = conf.uniforms[u]; + if(mtl.uniforms[u].value.set) { + mtl.uniforms[u].value.set(vu); + } else { + mtl.uniforms[u].value = vu; + } + } + mtl.defines["TILED_FORWARD"] = 1; + materials.push(mtl); + var obj = new THREE.Mesh(geom, mtl); + mtl.side = tIndex === index ? THREE.FrontSide : THREE.DoubleSide; + + g.rotation.y = index * Math.PI / 2; + g.position.x = Math.sin(index * Math.PI / 2) * RADIUS; + g.position.z = Math.cos(index * Math.PI / 2) * RADIUS; + g.add(obj); + + for(var i=0; i < 8; i++) { + var sat = Math.floor(33 + 33 * Math.random()); + var chroma = Math.random() * 100; + var l = new THREE.Group(); + + l.add(new THREE.Mesh( + sphereGeom, + new THREE.MeshBasicMaterial( { color: new THREE.Color("hsl(" + chroma + ", " + sat + "%, 50%)") } ) + )); + l.add(new THREE.Mesh( + sphereGeom, + new THREE.MeshBasicMaterial( { + color: new THREE.Color("hsl(" + chroma + ", " + sat + "%, 50%)"), + transparent: true, + opacity: 0.033 + } ) + )); + l.children[1].scale.set(6.66,6.66,6.66); + + l._light = { + color: new THREE.Color("hsl(" + chroma + ", " + sat + "%, 50%)"), + radius: RADIUS, + decay: 1, + sy: Math.random(), + sr: Math.random(), + sc: Math.random() , + py: Math.random() * Math.PI , + pr: Math.random() * Math.PI , + pc: Math.random() * Math.PI , + dir: Math.random() > 0.5 ? 1:-1 + }; + + lights.push(l); + g.add(l); + } + scene.add(g); + }); + } + + function update(now) { + lights.forEach(function (l) { + var ld = l._light; + var radius = 0.8 + 0.2 * Math.sin(ld.pr + (0.6 + 0.3 * ld.sr) * now); + l.position.x =(Math.sin(ld.pc + (0.8 + 0.2 * ld.sc) * now * ld.dir)) * radius * RADIUS; + l.position.z =(Math.cos(ld.pc + (0.8 + 0.2 * ld.sc) * now * ld.dir)) * radius * RADIUS; + l.position.y = Math.sin(ld.py + (0.8 + 0.2 * ld.sy) * now) * radius * 32; + }); + } + + function resize() { + renderer.setPixelRatio( window.devicePixelRatio ); + renderer.setSize( window.innerWidth, window.innerHeight ); + renderTarget.setSize( window.innerWidth, window.innerHeight ); + bloom.setSize( window.innerWidth, window.innerHeight ); + camera.aspect = window.innerWidth / window.innerHeight; + camera.updateProjectionMatrix(); + resizeTiles(); + } + + function postEffect(renderer, camera, scene, renderTarget) { + bloom.render(renderer, null, renderTarget); + } + + scene.onBeforeRender = tileLights; + + scene.onAfterRender = postEffect; + + var loader = new THREE.JSONLoader(); + + loader.load('./obj/walt/WaltHead_slim.js', function(geometry) { + window.addEventListener("resize", resize); + init(geometry); + resize(); + + renderer.animate( function(time) { + update(time/1000); + stats.begin(); + renderer.render(scene, camera, renderTarget); + stats.end(); + }); + }); + </script> + </body> +</html> \ No newline at end of file
true
Other
mrdoob
three.js
86d299d368eb75cf37abcc911e2d2ad04ac2dca8.json
use Scene.onBeforeRender and .onAfterRender
src/renderers/WebGLRenderer.js
@@ -1105,6 +1105,8 @@ function WebGLRenderer( parameters ) { } + scene.onBeforeRender( _this, scene, camera, renderTarget ); + _projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse ); _frustum.setFromMatrix( _projScreenMatrix ); @@ -1207,6 +1209,8 @@ function WebGLRenderer( parameters ) { state.setPolygonOffset( false ); + scene.onAfterRender( _this, scene, camera, renderTarget ); + if ( vr.enabled ) { vr.submitFrame();
true
Other
mrdoob
three.js
b9ea7e900b1f861f47dd62ffacf330414c594f1b.json
Improve FB2Tex example one more time
examples/webgl_framebuffer_texture.html
@@ -116,10 +116,14 @@ // - texture = new THREE.Texture(); - texture.image = new Image( imageWidth, imageHeight ); + var canvas = document.createElement( 'canvas' ); + canvas.width = imageWidth; + canvas.height = imageHeight; + + texture = new THREE.CanvasTexture( canvas ); texture.format = THREE.RGBFormat; texture.minFilter = texture.magFilter = THREE.NearestFilter; + texture.needsUpdate = true; //
false
Other
mrdoob
three.js
7376beb63a46bd2d068626a646a8a7e12ed14a04.json
Improve FB2Tex example
examples/files.js
@@ -18,6 +18,7 @@ var files = { "webgl_effects_parallaxbarrier", "webgl_effects_peppersghost", "webgl_effects_stereo", + "webgl_framebuffer_texture", "webgl_geometries", "webgl_geometries_parametric", "webgl_geometry_colors",
true
Other
mrdoob
three.js
7376beb63a46bd2d068626a646a8a7e12ed14a04.json
Improve FB2Tex example
examples/webgl_framebuffer_texture.html
@@ -40,8 +40,8 @@ } #overlay > div { - height: 256px; - width: 256px; + height: 128px; + width: 128px; border: 1px solid white; } </style> @@ -75,8 +75,8 @@ var dpr = window.devicePixelRatio; - var imageWidth = 256 * dpr; - var imageHeight = 256 * dpr; + var imageWidth = 128 * dpr; + var imageHeight = 128 * dpr; init(); animate(); @@ -142,6 +142,7 @@ var overlay = document.getElementById( 'overlay' ); var controls = new THREE.OrbitControls( camera, overlay ); + controls.enablePan = false; //
true
Other
mrdoob
three.js
8485ffd4815b506f876b18f8676a50aee13d7a29.json
Add crossFadeFrom & crossFadeTo
test/unit/src/animation/AnimationAction.tests.js
@@ -29,6 +29,32 @@ function createAnimation(){ } +function createTwoAnimations(){ + + var root = new Object3D(); + var mixer = new AnimationMixer(root); + var track = new NumberKeyframeTrack( ".rotation[x]", [ 0, 1000 ], [ 0, 360 ] ); + var clip = new AnimationClip( "clip1", 1000, [track] ); + var animationAction = mixer.clipAction( clip ); + + var track2 = new NumberKeyframeTrack( ".rotation[y]", [ 0, 1000 ], [ 0, 360 ] ); + var clip2 = new AnimationClip( "clip2", 1000, [track] ); + var animationAction2 = mixer.clipAction( clip2 ); + + return { + root: root, + mixer: mixer, + track: track, + clip: clip, + animationAction: animationAction, + track2: track2, + clip2: clip2, + animationAction2: animationAction2 + }; + +} + + export default QUnit.module( 'Animation', () => { QUnit.module( 'AnimationAction', () => { @@ -233,20 +259,20 @@ export default QUnit.module( 'Animation', () => { QUnit.test( "setEffectiveWeight", ( assert ) => { var {animationAction} = createAnimation(); - assert.equal( animationAction.getEffectiveWeight(), 1 , "When an animation is created, EffectiveWeight is 1." ); - animationAction.setEffectiveWeight(0.3); + assert.equal( animationAction.getEffectiveWeight(), 1 , "When an animation is created, EffectiveWeight is 1." ); + animationAction.setEffectiveWeight(0.3); assert.equal( animationAction.getEffectiveWeight(), 0.3 , "When EffectiveWeight is set to 0.3 , EffectiveWeight is 0.3." ); var {animationAction} = createAnimation(); - assert.equal( animationAction.getEffectiveWeight(), 1 , "When an animation is created, EffectiveWeight is 1." ); - animationAction.enabled = false; - animationAction.setEffectiveWeight(0.3); + assert.equal( animationAction.getEffectiveWeight(), 1 , "When an animation is created, EffectiveWeight is 1." ); + animationAction.enabled = false; + animationAction.setEffectiveWeight(0.3); assert.equal( animationAction.getEffectiveWeight(), 0 , "When EffectiveWeight is set to 0.3 when disabled , EffectiveWeight is 0." ); var { root, mixer,animationAction } = createAnimation(); - animationAction.setEffectiveWeight(0.5); + animationAction.setEffectiveWeight(0.5); animationAction.play(); mixer.update(500); assert.equal( root.rotation.x, 90 , "When an animation has weight 0.5 and runs half through the animation, it has changed to 1/4." ); @@ -259,26 +285,26 @@ export default QUnit.module( 'Animation', () => { QUnit.test( "getEffectiveWeight", ( assert ) => { - var {animationAction} = createAnimation(); - assert.equal( animationAction.getEffectiveWeight(), 1 , "When an animation is created, EffectiveWeight is 1." ); - animationAction.setEffectiveWeight(0.3); + var {animationAction} = createAnimation(); + assert.equal( animationAction.getEffectiveWeight(), 1 , "When an animation is created, EffectiveWeight is 1." ); + animationAction.setEffectiveWeight(0.3); assert.equal( animationAction.getEffectiveWeight(), 0.3 , "When EffectiveWeight is set to 0.3 , EffectiveWeight is 0.3." ); var {animationAction} = createAnimation(); - assert.equal( animationAction.getEffectiveWeight(), 1 , "When an animation is created, EffectiveWeight is 1." ); - animationAction.enabled = false; - animationAction.setEffectiveWeight(0.3); + assert.equal( animationAction.getEffectiveWeight(), 1 , "When an animation is created, EffectiveWeight is 1." ); + animationAction.enabled = false; + animationAction.setEffectiveWeight(0.3); assert.equal( animationAction.getEffectiveWeight(), 0 , "When EffectiveWeight is set to 0.3 when disabled , EffectiveWeight is 0." ); } ); QUnit.test( "fadeIn", ( assert ) => { - var {mixer, animationAction} = createAnimation(); - animationAction.fadeIn(1000); + var {mixer, animationAction} = createAnimation(); + animationAction.fadeIn(1000); animationAction.play(); - assert.equal( animationAction.getEffectiveWeight(), 1 , "When an animation fadeIn is started, EffectiveWeight is 1." ); + assert.equal( animationAction.getEffectiveWeight(), 1 , "When an animation fadeIn is started, EffectiveWeight is 1." ); mixer.update(250); assert.equal( animationAction.getEffectiveWeight(), 0.25, "When an animation fadeIn happened 1/4, EffectiveWeight is 0.25." ); mixer.update(250); @@ -293,9 +319,9 @@ export default QUnit.module( 'Animation', () => { QUnit.test( "fadeOut", ( assert ) => { var {mixer, animationAction} = createAnimation(); - animationAction.fadeOut(1000); + animationAction.fadeOut(1000); animationAction.play(); - assert.equal( animationAction.getEffectiveWeight(), 1 , "When an animation fadeOut is started, EffectiveWeight is 1." ); + assert.equal( animationAction.getEffectiveWeight(), 1 , "When an animation fadeOut is started, EffectiveWeight is 1." ); mixer.update(250); assert.equal( animationAction.getEffectiveWeight(), 0.75, "When an animation fadeOut happened 1/4, EffectiveWeight is 0.75." ); mixer.update(250); @@ -307,15 +333,49 @@ export default QUnit.module( 'Animation', () => { } ); - QUnit.todo( "crossFadeFrom", ( assert ) => { + QUnit.test( "crossFadeFrom", ( assert ) => { - assert.ok( false, "everything's gonna be alright" ); + var {mixer, animationAction, animationAction2} = createTwoAnimations(); + animationAction.crossFadeFrom(animationAction2, 1000, false); + animationAction.play(); + animationAction2.play(); + assert.equal( animationAction.getEffectiveWeight(), 1 , "When an animation crossFadeFrom is started, EffectiveWeight is 1." ); + assert.equal( animationAction2.getEffectiveWeight(), 1 , "When an animation crossFadeFrom is started, EffectiveWeight is 1." ); + mixer.update(250); + assert.equal( animationAction.getEffectiveWeight(), 0.25, "When an animation fadeOut happened 1/4, EffectiveWeight is 0.75." ); + assert.equal( animationAction2.getEffectiveWeight(), 0.75, "When an animation fadeOut happened 1/4, EffectiveWeight is 0.75." ); + mixer.update(250); + assert.equal( animationAction.getEffectiveWeight(), 0.5, "When an animation fadeOut happened 1/4, EffectiveWeight is 0.75." ); + assert.equal( animationAction2.getEffectiveWeight(), 0.5, "When an animation fadeOut is halfway , EffectiveWeight is 0.5." ); + mixer.update(250); + assert.equal( animationAction.getEffectiveWeight(), 0.75, "When an animation fadeOut happened 1/4, EffectiveWeight is 0.75." ); + assert.equal( animationAction2.getEffectiveWeight(), 0.25, "When an animation fadeOut is happened 3/4 , EffectiveWeight is 0.25." ); + mixer.update(500); + assert.equal( animationAction.getEffectiveWeight(), 1, "When an animation fadeOut happened 1/4, EffectiveWeight is 0.75." ); + assert.equal( animationAction2.getEffectiveWeight(), 0, "When an animation fadeOut is ended , EffectiveWeight is 0." ); } ); - QUnit.todo( "crossFadeTo", ( assert ) => { + QUnit.test( "crossFadeTo", ( assert ) => { - assert.ok( false, "everything's gonna be alright" ); + var {mixer, animationAction, animationAction2} = createTwoAnimations(); + animationAction2.crossFadeTo(animationAction, 1000, false); + animationAction.play(); + animationAction2.play(); + assert.equal( animationAction.getEffectiveWeight(), 1 , "When an animation crossFadeFrom is started, EffectiveWeight is 1." ); + assert.equal( animationAction2.getEffectiveWeight(), 1 , "When an animation crossFadeFrom is started, EffectiveWeight is 1." ); + mixer.update(250); + assert.equal( animationAction.getEffectiveWeight(), 0.25, "When an animation fadeOut happened 1/4, EffectiveWeight is 0.75." ); + assert.equal( animationAction2.getEffectiveWeight(), 0.75, "When an animation fadeOut happened 1/4, EffectiveWeight is 0.75." ); + mixer.update(250); + assert.equal( animationAction.getEffectiveWeight(), 0.5, "When an animation fadeOut happened 1/4, EffectiveWeight is 0.75." ); + assert.equal( animationAction2.getEffectiveWeight(), 0.5, "When an animation fadeOut is halfway , EffectiveWeight is 0.5." ); + mixer.update(250); + assert.equal( animationAction.getEffectiveWeight(), 0.75, "When an animation fadeOut happened 1/4, EffectiveWeight is 0.75." ); + assert.equal( animationAction2.getEffectiveWeight(), 0.25, "When an animation fadeOut is happened 3/4 , EffectiveWeight is 0.25." ); + mixer.update(500); + assert.equal( animationAction.getEffectiveWeight(), 1, "When an animation fadeOut happened 1/4, EffectiveWeight is 0.75." ); + assert.equal( animationAction2.getEffectiveWeight(), 0, "When an animation fadeOut is ended , EffectiveWeight is 0." ); } );
false
Other
mrdoob
three.js
9e4849ace7b9e8ebfbda022f9f32e3bf18e68dee.json
simplify skeleton building
examples/js/loaders/FBXLoader.js
@@ -2008,67 +2008,16 @@ function bindSkeleton( FBXTree, skeletons, geometryMap, modelMap, connections, sceneGraph ) { - // Now with the bones created, we can update the skeletons and bind them to the skinned meshes. - sceneGraph.updateMatrixWorld( true ); - - var worldMatrices = new Map(); - - // Put skeleton into bind pose. - if ( 'Pose' in FBXTree.Objects ) { - - var BindPoseNode = FBXTree.Objects.Pose; - - for ( var nodeID in BindPoseNode ) { - - if ( BindPoseNode[ nodeID ].attrType === 'BindPose' ) { - - var poseNodes = BindPoseNode[ nodeID ].PoseNode; - - if ( Array.isArray( poseNodes ) ) { - - poseNodes.forEach( function ( node ) { - - var rawMatWrd = new THREE.Matrix4().fromArray( node.Matrix.a ); - worldMatrices.set( parseInt( node.Node ), rawMatWrd ); - - } ); - - } else { - - var rawMatWrd = new THREE.Matrix4().fromArray( poseNodes.Matrix.a ); - worldMatrices.set( parseInt( poseNodes.Node ), rawMatWrd ); - - } - - } - - } - - } - for ( var ID in skeletons ) { var skeleton = skeletons[ ID ]; skeleton.bones.forEach( function ( bone, i ) { - // if the bone's initial transform is set in a poseNode, copy that - if ( worldMatrices.has( bone.ID ) ) { - - var mat = worldMatrices.get( bone.ID ); - bone.matrixWorld.copy( mat ); - - } - // otherwise use the transform from the rawBone - else { - - bone.matrixWorld.copy( skeleton.rawBones[ i ].transformLink ); - - } + bone.matrixWorld.copy( skeleton.rawBones[ i ].transformLink ); } ); - // Now that skeleton is in bind pose, bind to model. var parents = connections.get( parseInt( skeleton.ID ) ).parents; parents.forEach( function ( parent ) { @@ -2096,9 +2045,6 @@ } - //Skeleton is now bound, return objects to starting world positions. - sceneGraph.updateMatrixWorld( true ); - } function parseAnimations( FBXTree, connections ) { @@ -2633,12 +2579,7 @@ // if the subnode already exists, append it if ( nodeName in currentNode ) { - // special case Pose needs PoseNodes as an array - if ( nodeName === 'PoseNode' ) { - - currentNode.PoseNode.push( node ); - - } else if ( currentNode[ nodeName ].id !== undefined ) { + if ( currentNode[ nodeName ].id !== undefined ) { currentNode[ nodeName ] = {}; currentNode[ nodeName ][ currentNode[ nodeName ].id ] = currentNode[ nodeName ]; @@ -2654,8 +2595,7 @@ } else if ( nodeName !== 'Properties70' ) { - if ( nodeName === 'PoseNode' ) currentNode[ nodeName ] = [ node ]; - else currentNode[ nodeName ] = node; + currentNode[ nodeName ] = node; } @@ -3049,23 +2989,9 @@ } - } else { + } else if ( node[ subNode.name ][ subNode.id ] === undefined ) { - if ( subNode.name === 'PoseNode' ) { - - if ( ! Array.isArray( node[ subNode.name ] ) ) { - - node[ subNode.name ] = [ node[ subNode.name ] ]; - - } - - node[ subNode.name ].push( subNode ); - - } else if ( node[ subNode.name ][ subNode.id ] === undefined ) { - - node[ subNode.name ][ subNode.id ] = subNode; - - } + node[ subNode.name ][ subNode.id ] = subNode; }
false
Other
mrdoob
three.js
afe2eec9376ec28685cbafec4685917d6c74f359.json
Add tests for fadeIn & fadeOut
test/unit/src/animation/AnimationAction.tests.js
@@ -273,15 +273,37 @@ export default QUnit.module( 'Animation', () => { } ); - QUnit.todo( "fadeIn", ( assert ) => { + QUnit.test( "fadeIn", ( assert ) => { - assert.ok( false, "everything's gonna be alright" ); + var {mixer, animationAction} = createAnimation(); + animationAction.fadeIn(1000); + animationAction.play(); + assert.equal( animationAction.getEffectiveWeight(), 1 , "When an animation fadeIn is started, EffectiveWeight is 1." ); + mixer.update(250); + assert.equal( animationAction.getEffectiveWeight(), 0.25, "When an animation fadeIn happened 1/4, EffectiveWeight is 0.25." ); + mixer.update(250); + assert.equal( animationAction.getEffectiveWeight(), 0.5, "When an animation fadeIn is halfway , EffectiveWeight is 0.5." ); + mixer.update(250); + assert.equal( animationAction.getEffectiveWeight(), 0.75, "When an animation fadeIn is halfway , EffectiveWeight is 0.75." ); + mixer.update(500); + assert.equal( animationAction.getEffectiveWeight(), 1, "When an animation fadeIn is ended , EffectiveWeight is 1." ); } ); - QUnit.todo( "fadeOut", ( assert ) => { + QUnit.test( "fadeOut", ( assert ) => { - assert.ok( false, "everything's gonna be alright" ); + var {mixer, animationAction} = createAnimation(); + animationAction.fadeOut(1000); + animationAction.play(); + assert.equal( animationAction.getEffectiveWeight(), 1 , "When an animation fadeOut is started, EffectiveWeight is 1." ); + mixer.update(250); + assert.equal( animationAction.getEffectiveWeight(), 0.75, "When an animation fadeOut happened 1/4, EffectiveWeight is 0.75." ); + mixer.update(250); + assert.equal( animationAction.getEffectiveWeight(), 0.5, "When an animation fadeOut is halfway , EffectiveWeight is 0.5." ); + mixer.update(250); + assert.equal( animationAction.getEffectiveWeight(), 0.25, "When an animation fadeOut is happened 3/4 , EffectiveWeight is 0.25." ); + mixer.update(500); + assert.equal( animationAction.getEffectiveWeight(), 0, "When an animation fadeOut is ended , EffectiveWeight is 0." ); } );
false
Other
mrdoob
three.js
c7df4e9fef4107bc580848744ecf7391e545ee6c.json
add real tests
test/unit/src/animation/AnimationAction.tests.js
@@ -1,333 +1,343 @@ -/** - * @author TristanVALCKE / https://github.com/Itee - */ -/* global QUnit */ - -import { AnimationAction } from '../../../../src/animation/AnimationAction'; -import { AnimationMixer } from '../../../../src/animation/AnimationMixer'; -import { AnimationClip } from '../../../../src/animation/AnimationClip'; -import { NumberKeyframeTrack } from '../../../../src/animation/tracks/NumberKeyframeTrack'; -import { Object3D } from '../../../../src/core/Object3D'; -import { LoopOnce, LoopRepeat, LoopPingPong } from '../../../../src/constants'; - - -function createAnimation(){ - - var root = new Object3D(); - var mixer = new AnimationMixer(root); - var track = new NumberKeyframeTrack( ".rotation[x]", [ 0, 1000 ], [ 0, 360 ] ); - var clip = new AnimationClip( "clip1", 1000, [track] ); - - var animationAction = mixer.clipAction( clip ); +/** + * @author TristanVALCKE / https://github.com/Itee + */ +/* global QUnit */ + +import { AnimationAction } from '../../../../src/animation/AnimationAction'; +import { AnimationMixer } from '../../../../src/animation/AnimationMixer'; +import { AnimationClip } from '../../../../src/animation/AnimationClip'; +import { NumberKeyframeTrack } from '../../../../src/animation/tracks/NumberKeyframeTrack'; +import { Object3D } from '../../../../src/core/Object3D'; +import { LoopOnce, LoopRepeat, LoopPingPong } from '../../../../src/constants'; + + +function createAnimation(){ + + var root = new Object3D(); + var mixer = new AnimationMixer(root); + var track = new NumberKeyframeTrack( ".rotation[x]", [ 0, 1000 ], [ 0, 360 ] ); + var clip = new AnimationClip( "clip1", 1000, [track] ); + + var animationAction = mixer.clipAction( clip ); return { root: root, - mixer: mixer, + mixer: mixer, track: track, clip: clip, animationAction: animationAction - }; - -} - -export default QUnit.module( 'Animation', () => { - - QUnit.module( 'AnimationAction', () => { - - // INSTANCING - QUnit.test( "Instancing", ( assert ) => { - - var mixer = new AnimationMixer(); - var clip = new AnimationClip( "nonname", - 1, [] ); - - var animationAction = new AnimationAction( mixer, clip ); - assert.ok( animationAction, "animationAction instanciated" ); - - } ); - - // PUBLIC STUFF - QUnit.test( "play", ( assert ) => { - - var {mixer,animationAction} = createAnimation(); - var animationAction2 = animationAction.play(); - assert.equal( animationAction, animationAction2, "AnimationAction.play can be chained." ); - - var UserException = function () { - - this.message = "AnimationMixer must activate AnimationAction on play."; - - }; - mixer._activateAction = function ( action ) { - - if ( action === animationAction ) { - - throw new UserException(); - - } - - }; - assert.throws( () => { - - animationAction.play(); - - }, new UserException() ); - - } ); - - QUnit.test( "stop", ( assert ) => { - - var {mixer,animationAction} = createAnimation(); - var animationAction2 = animationAction.stop(); - assert.equal( animationAction, animationAction2, "AnimationAction.stop can be chained." ); - - var UserException = function () { - - this.message = "AnimationMixer must deactivate AnimationAction on stop."; - - }; - mixer._deactivateAction = function ( action ) { - - if ( action === animationAction ) { - - throw new UserException(); - - } - - }; - assert.throws( () => { - - animationAction.stop(); - - }, new UserException() ); - - } ); - - QUnit.test( "reset", ( assert ) => { - - var {mixer,animationAction} = createAnimation(); - var animationAction2 = animationAction.stop(); - assert.equal( animationAction, animationAction2, "AnimationAction.reset can be chained." ); - assert.equal( animationAction2.paused, false, "AnimationAction.reset() sets paused false" ); - assert.equal( animationAction2.enabled, true, "AnimationAction.reset() sets enabled true" ); - assert.equal( animationAction2.time, 0, "AnimationAction.reset() resets time." ); - assert.equal( animationAction2._loopCount, - 1, "AnimationAction.reset() resets loopcount." ); - assert.equal( animationAction2._startTime, null, "AnimationAction.reset() removes starttime." ); - - } ); - - QUnit.test( "isRunning", ( assert ) => { - - var {mixer,animationAction} = createAnimation(); - assert.notOk( animationAction.isRunning(), "When an animation is just made, it is not running." ); - animationAction.play(); - assert.ok( animationAction.isRunning(), "When an animation is started, it is running." ); - animationAction.stop(); - assert.notOk( animationAction.isRunning(), "When an animation is stopped, it is not running." ); - animationAction.play(); - animationAction.paused = true; - assert.notOk( animationAction.isRunning(), "When an animation is paused, it is not running." ); - animationAction.paused = false; - animationAction.enabled = false; - assert.notOk( animationAction.isRunning(), "When an animation is not enabled, it is not running." ); - animationAction.enabled = true; - assert.ok( animationAction.isRunning(), "When an animation is enabled, it is running." ); - - } ); - - QUnit.test( "isScheduled", ( assert ) => { - - var {mixer,animationAction} = createAnimation(); - assert.notOk( animationAction.isScheduled(), "When an animation is just made, it is not scheduled." ); - animationAction.play(); - assert.ok( animationAction.isScheduled(), "When an animation is started, it is scheduled." ); - mixer.update(1); - assert.ok( animationAction.isScheduled(), "When an animation is updated, it is scheduled." ); - animationAction.stop(); - assert.notOk( animationAction.isScheduled(), "When an animation is stopped, it isn't scheduled anymore." ); - - - } ); - - QUnit.test( "startAt", ( assert ) => { - - var {mixer,animationAction} = createAnimation(); - animationAction.startAt(2); - animationAction.play(); - assert.notOk( animationAction.isRunning(), "When an animation is started at a specific time, it is not running." ); - assert.ok( animationAction.isScheduled(), "When an animation is started at a specific time, it is scheduled." ); - mixer.update(1); - assert.notOk( animationAction.isRunning(), "When an animation is started at a specific time and the interval is not passed, it is not running." ); - assert.ok( animationAction.isScheduled(), "When an animation is started at a specific time and the interval is not passed, it is scheduled." ); - mixer.update(1); - assert.ok( animationAction.isRunning(), "When an animation is started at a specific time and the interval is passed, it is running." ); - assert.ok( animationAction.isScheduled(), "When an animation is started at a specific time and the interval is passed, it is scheduled." ); - animationAction.stop(); - assert.notOk( animationAction.isRunning(), "When an animation is stopped, it is not running." ); - assert.notOk( animationAction.isScheduled(), "When an animation is stopped, it is not scheduled." ); - - - } ); - - QUnit.test( "setLoop LoopOnce", ( assert ) => { - - var {mixer,animationAction} = createAnimation(); - animationAction.setLoop(LoopOnce); - animationAction.play(); - assert.ok( animationAction.isRunning(), "When an animation is started, it is running." ); - mixer.update(500); - assert.ok( animationAction.isRunning(), "When an animation is in the first loop, it is running." ); - mixer.update(500); - assert.notOk( animationAction.isRunning(), "When an animation is ended, it is not running." ); - mixer.update(500); - assert.notOk( animationAction.isRunning(), "When an animation is ended, it is not running." ); - - } ); - - QUnit.test( "setLoop LoopRepeat", ( assert ) => { - - var {mixer,animationAction} = createAnimation(); - animationAction.setLoop(LoopRepeat,3); - animationAction.play(); - assert.ok( animationAction.isRunning(), "When an animation is started, it is running." ); - mixer.update(500); - assert.ok( animationAction.isRunning(), "When an animation is in the first loop, it is running." ); - mixer.update(1000); - assert.ok( animationAction.isRunning(), "When an animation is in second loop when in looprepeat 3 times, it is running." ); - mixer.update(1000); - assert.ok( animationAction.isRunning(), "When an animation is in third loop when in looprepeat 3 times, it is running." ); - mixer.update(1000); - assert.ok( animationAction.isRunning(), "When an animation is in fourth loop when in looprepeat 3 times, it is running." ); - mixer.update(1000); - assert.notOk( animationAction.isRunning(), "When an animation ended his third loop when in looprepeat 3 times, it stays not running anymore." ); - - } ); - - QUnit.test( "setLoop LoopPingPong", ( assert ) => { - - var {mixer,animationAction} = createAnimation(); - animationAction.setLoop(LoopPingPong,3); - animationAction.play(); - assert.ok( animationAction.isRunning(), "When an animation is started, it is running." ); - mixer.update(500); - assert.ok( animationAction.isRunning(), "When an animation is in the first loop, it is running." ); - mixer.update(1000); - assert.ok( animationAction.isRunning(), "When an animation is in second loop when in looprepeat 3 times, it is running." ); - mixer.update(1000); - assert.ok( animationAction.isRunning(), "When an animation is in third loop when in looprepeat 3 times, it is running." ); - mixer.update(1000); - assert.ok( animationAction.isRunning(), "When an animation is in fourth loop when in looprepeat 3 times, it is running." ); - mixer.update(1000); - assert.notOk( animationAction.isRunning(), "When an animation ended his third loop when in looprepeat 3 times, it stays not running anymore." ); - - } ); - - QUnit.todo( "setEffectiveWeight", ( assert ) => { - - assert.ok( false, "everything's gonna be alright" ); - - } ); - - QUnit.todo( "getEffectiveWeight", ( assert ) => { - - assert.ok( false, "everything's gonna be alright" ); - - } ); - - QUnit.todo( "fadeIn", ( assert ) => { - - assert.ok( false, "everything's gonna be alright" ); - - } ); - - QUnit.todo( "fadeOut", ( assert ) => { - - assert.ok( false, "everything's gonna be alright" ); - - } ); - - QUnit.todo( "crossFadeFrom", ( assert ) => { - - assert.ok( false, "everything's gonna be alright" ); - - } ); - - QUnit.todo( "crossFadeTo", ( assert ) => { - - assert.ok( false, "everything's gonna be alright" ); - - } ); - - QUnit.todo( "stopFading", ( assert ) => { - - assert.ok( false, "everything's gonna be alright" ); - - } ); - - QUnit.todo( "setEffectiveTimeScale", ( assert ) => { - - assert.ok( false, "everything's gonna be alright" ); - - } ); - - QUnit.todo( "getEffectiveTimeScale", ( assert ) => { - - assert.ok( false, "everything's gonna be alright" ); - - } ); - - QUnit.todo( "setDuration", ( assert ) => { - - assert.ok( false, "everything's gonna be alright" ); - - } ); - - QUnit.todo( "syncWith", ( assert ) => { - - assert.ok( false, "everything's gonna be alright" ); - - } ); - - QUnit.todo( "halt", ( assert ) => { - - assert.ok( false, "everything's gonna be alright" ); - - } ); - - QUnit.todo( "warp", ( assert ) => { - - assert.ok( false, "everything's gonna be alright" ); - - } ); - - QUnit.todo( "stopWarping", ( assert ) => { - - assert.ok( false, "everything's gonna be alright" ); - - } ); - - QUnit.test( "getMixer", ( assert ) => { - - var { mixer, animationAction } = createAnimation(); - var mixer2 = animationAction.getMixer(); - assert.equal( mixer, mixer2, "mixer should be returned by getMixer." ); - - } ); - - QUnit.test("getClip", (assert) => { - - var { clip, animationAction } = createAnimation(); - var clip2 = animationAction.getClip(); - assert.equal( clip, clip2, "clip should be returned by getClip." ); - - } ); - - QUnit.test( "getRoot", ( assert ) => { - - var { root, animationAction } = createAnimation(); - var root2 = animationAction.getRoot(); - assert.equal(root, root2, "root should be returned by getRoot." ); - - } ); - - } ); - -} ); + }; + +} + +export default QUnit.module( 'Animation', () => { + + QUnit.module( 'AnimationAction', () => { + + // INSTANCING + QUnit.test( "Instancing", ( assert ) => { + + var mixer = new AnimationMixer(); + var clip = new AnimationClip( "nonname", - 1, [] ); + + var animationAction = new AnimationAction( mixer, clip ); + assert.ok( animationAction, "animationAction instanciated" ); + + } ); + + // PUBLIC STUFF + QUnit.test( "play", ( assert ) => { + + var {mixer,animationAction} = createAnimation(); + var animationAction2 = animationAction.play(); + assert.equal( animationAction, animationAction2, "AnimationAction.play can be chained." ); + + var UserException = function () { + + this.message = "AnimationMixer must activate AnimationAction on play."; + + }; + mixer._activateAction = function ( action ) { + + if ( action === animationAction ) { + + throw new UserException(); + + } + + }; + assert.throws( () => { + + animationAction.play(); + + }, new UserException() ); + + } ); + + QUnit.test( "stop", ( assert ) => { + + var {mixer,animationAction} = createAnimation(); + var animationAction2 = animationAction.stop(); + assert.equal( animationAction, animationAction2, "AnimationAction.stop can be chained." ); + + var UserException = function () { + + this.message = "AnimationMixer must deactivate AnimationAction on stop."; + + }; + mixer._deactivateAction = function ( action ) { + + if ( action === animationAction ) { + + throw new UserException(); + + } + + }; + assert.throws( () => { + + animationAction.stop(); + + }, new UserException() ); + + } ); + + QUnit.test( "reset", ( assert ) => { + + var {mixer,animationAction} = createAnimation(); + var animationAction2 = animationAction.stop(); + assert.equal( animationAction, animationAction2, "AnimationAction.reset can be chained." ); + assert.equal( animationAction2.paused, false, "AnimationAction.reset() sets paused false" ); + assert.equal( animationAction2.enabled, true, "AnimationAction.reset() sets enabled true" ); + assert.equal( animationAction2.time, 0, "AnimationAction.reset() resets time." ); + assert.equal( animationAction2._loopCount, - 1, "AnimationAction.reset() resets loopcount." ); + assert.equal( animationAction2._startTime, null, "AnimationAction.reset() removes starttime." ); + + } ); + + QUnit.test( "isRunning", ( assert ) => { + + var {mixer,animationAction} = createAnimation(); + assert.notOk( animationAction.isRunning(), "When an animation is just made, it is not running." ); + animationAction.play(); + assert.ok( animationAction.isRunning(), "When an animation is started, it is running." ); + animationAction.stop(); + assert.notOk( animationAction.isRunning(), "When an animation is stopped, it is not running." ); + animationAction.play(); + animationAction.paused = true; + assert.notOk( animationAction.isRunning(), "When an animation is paused, it is not running." ); + animationAction.paused = false; + animationAction.enabled = false; + assert.notOk( animationAction.isRunning(), "When an animation is not enabled, it is not running." ); + animationAction.enabled = true; + assert.ok( animationAction.isRunning(), "When an animation is enabled, it is running." ); + + } ); + + QUnit.test( "isScheduled", ( assert ) => { + + var {mixer,animationAction} = createAnimation(); + assert.notOk( animationAction.isScheduled(), "When an animation is just made, it is not scheduled." ); + animationAction.play(); + assert.ok( animationAction.isScheduled(), "When an animation is started, it is scheduled." ); + mixer.update(1); + assert.ok( animationAction.isScheduled(), "When an animation is updated, it is scheduled." ); + animationAction.stop(); + assert.notOk( animationAction.isScheduled(), "When an animation is stopped, it isn't scheduled anymore." ); + + + } ); + + QUnit.test( "startAt", ( assert ) => { + + var {mixer,animationAction} = createAnimation(); + animationAction.startAt(2); + animationAction.play(); + assert.notOk( animationAction.isRunning(), "When an animation is started at a specific time, it is not running." ); + assert.ok( animationAction.isScheduled(), "When an animation is started at a specific time, it is scheduled." ); + mixer.update(1); + assert.notOk( animationAction.isRunning(), "When an animation is started at a specific time and the interval is not passed, it is not running." ); + assert.ok( animationAction.isScheduled(), "When an animation is started at a specific time and the interval is not passed, it is scheduled." ); + mixer.update(1); + assert.ok( animationAction.isRunning(), "When an animation is started at a specific time and the interval is passed, it is running." ); + assert.ok( animationAction.isScheduled(), "When an animation is started at a specific time and the interval is passed, it is scheduled." ); + animationAction.stop(); + assert.notOk( animationAction.isRunning(), "When an animation is stopped, it is not running." ); + assert.notOk( animationAction.isScheduled(), "When an animation is stopped, it is not scheduled." ); + + + } ); + + QUnit.test( "setLoop LoopOnce", ( assert ) => { + + var {mixer,animationAction} = createAnimation(); + animationAction.setLoop(LoopOnce); + animationAction.play(); + assert.ok( animationAction.isRunning(), "When an animation is started, it is running." ); + mixer.update(500); + assert.ok( animationAction.isRunning(), "When an animation is in the first loop, it is running." ); + mixer.update(500); + assert.notOk( animationAction.isRunning(), "When an animation is ended, it is not running." ); + mixer.update(500); + assert.notOk( animationAction.isRunning(), "When an animation is ended, it is not running." ); + + } ); + + QUnit.test( "setLoop LoopRepeat", ( assert ) => { + + var { root, mixer,animationAction } = createAnimation(); + animationAction.setLoop(LoopRepeat,3); + animationAction.play(); + assert.ok( animationAction.isRunning(), "When an animation is started, it is running." ); + mixer.update(750); + assert.equal( root.rotation.x, 270 , "When an animation is 3/4 in the first loop, it has changed to 3/4 when LoopRepeat." ); + assert.ok( animationAction.isRunning(), "When an animation is in the first loop, it is running." ); + mixer.update(1000); + assert.equal( root.rotation.x, 270 , "When an animation is 3/4 in the second loop, it has changed to 3/4 when LoopRepeat." ); + assert.ok( animationAction.isRunning(), "When an animation is in second loop when in looprepeat 3 times, it is running." ); + mixer.update(1000); + assert.equal( root.rotation.x, 270 , "When an animation is 3/4 in the third loop, it has changed to 3/4 when LoopRepeat." ); + assert.ok( animationAction.isRunning(), "When an animation is in third loop when in looprepeat 3 times, it is running." ); + mixer.update(1000); + assert.equal( root.rotation.x, 270 , "When an animation is 3/4 in the fourth loop, it has changed to 3/4 when LoopRepeat." ); + assert.ok( animationAction.isRunning(), "When an animation is in fourth loop when in looprepeat 3 times, it is running." ); + mixer.update(1000); + assert.equal( root.rotation.x, 0 , "When an animation ended his third loop when in looprepeat 3 times, it stays on the end result." ); + assert.notOk( animationAction.isRunning(), "When an animation ended his third loop when in looprepeat 3 times, it stays not running anymore." ); + + } ); + + QUnit.test( "setLoop LoopPingPong", ( assert ) => { + + var {root, mixer,animationAction} = createAnimation(); + animationAction.setLoop(LoopPingPong,3); + animationAction.play(); + assert.ok( animationAction.isRunning(), "When an animation is started, it is running." ); + mixer.update(750); + assert.equal( root.rotation.x, 270 , "When an animation is 3/4 in the first loop, it has changed to 3/4 when LoopPingPong." ); + assert.ok( animationAction.isRunning(), "When an animation is in the first loop, it is running." ); + mixer.update(1000); + assert.equal( root.rotation.x, 90 , "When an animation is 3/4 in the second loop, it has changed to 1/4 when LoopPingPong." ); + assert.ok( animationAction.isRunning(), "When an animation is in second loop when in looprepeat 3 times, it is running." ); + mixer.update(1000); + assert.equal( root.rotation.x, 270 , "When an animation is 3/4 in the third loop, it has changed to 3/4 when LoopPingPong." ); + assert.ok( animationAction.isRunning(), "When an animation is in third loop when in looprepeat 3 times, it is running." ); + mixer.update(1000); + assert.equal( root.rotation.x, 90 , "When an animation is 3/4 in the fourth loop, it has changed to 1/4 when LoopPingPong." ); + assert.ok( animationAction.isRunning(), "When an animation is in fourth loop when in looprepeat 3 times, it is running." ); + mixer.update(1000); + assert.equal( root.rotation.x, 0 , "When an animation ended his fourth loop when in looprepeat 3 times, it stays on the end result." ); + assert.notOk( animationAction.isRunning(), "When an animation ended his fourth loop when in looprepeat 3 times, it stays not running anymore." ); + + } ); + + QUnit.todo( "setEffectiveWeight", ( assert ) => { + + assert.ok( false, "everything's gonna be alright" ); + + } ); + + QUnit.todo( "getEffectiveWeight", ( assert ) => { + + assert.ok( false, "everything's gonna be alright" ); + + } ); + + QUnit.todo( "fadeIn", ( assert ) => { + + assert.ok( false, "everything's gonna be alright" ); + + } ); + + QUnit.todo( "fadeOut", ( assert ) => { + + assert.ok( false, "everything's gonna be alright" ); + + } ); + + QUnit.todo( "crossFadeFrom", ( assert ) => { + + assert.ok( false, "everything's gonna be alright" ); + + } ); + + QUnit.todo( "crossFadeTo", ( assert ) => { + + assert.ok( false, "everything's gonna be alright" ); + + } ); + + QUnit.todo( "stopFading", ( assert ) => { + + assert.ok( false, "everything's gonna be alright" ); + + } ); + + QUnit.todo( "setEffectiveTimeScale", ( assert ) => { + + assert.ok( false, "everything's gonna be alright" ); + + } ); + + QUnit.todo( "getEffectiveTimeScale", ( assert ) => { + + assert.ok( false, "everything's gonna be alright" ); + + } ); + + QUnit.todo( "setDuration", ( assert ) => { + + assert.ok( false, "everything's gonna be alright" ); + + } ); + + QUnit.todo( "syncWith", ( assert ) => { + + assert.ok( false, "everything's gonna be alright" ); + + } ); + + QUnit.todo( "halt", ( assert ) => { + + assert.ok( false, "everything's gonna be alright" ); + + } ); + + QUnit.todo( "warp", ( assert ) => { + + assert.ok( false, "everything's gonna be alright" ); + + } ); + + QUnit.todo( "stopWarping", ( assert ) => { + + assert.ok( false, "everything's gonna be alright" ); + + } ); + + QUnit.test( "getMixer", ( assert ) => { + + var { mixer, animationAction } = createAnimation(); + var mixer2 = animationAction.getMixer(); + assert.equal( mixer, mixer2, "mixer should be returned by getMixer." ); + + } ); + + QUnit.test("getClip", (assert) => { + + var { clip, animationAction } = createAnimation(); + var clip2 = animationAction.getClip(); + assert.equal( clip, clip2, "clip should be returned by getClip." ); + + } ); + + QUnit.test( "getRoot", ( assert ) => { + + var { root, animationAction } = createAnimation(); + var root2 = animationAction.getRoot(); + assert.equal(root, root2, "root should be returned by getRoot." ); + + } ); + + } ); + +} );
false
Other
mrdoob
three.js
26a4288b01e45d0ba61dc59bb0588642d587db49.json
Restore previous renderTarget after update()
examples/js/pmrem/PMREMGenerator.js
@@ -90,6 +90,7 @@ THREE.PMREMGenerator.prototype = { var gammaOutput = renderer.gammaOutput; var toneMapping = renderer.toneMapping; var toneMappingExposure = renderer.toneMappingExposure; + var renderTarget = renderer.getCurrentRenderTarget(); renderer.toneMapping = THREE.LinearToneMapping; renderer.toneMappingExposure = 1.0; @@ -109,6 +110,7 @@ THREE.PMREMGenerator.prototype = { } + renderer.setRenderTarget(renderTarget); renderer.toneMapping = toneMapping; renderer.toneMappingExposure = toneMappingExposure; renderer.gammaInput = gammaInput;
false
Other
mrdoob
three.js
8ecba818d500f6b8b4453043e08932232e74e3ed.json
Fix markup typos in WebGLRenderTargetCube.html
docs/api/renderers/WebGLRenderTargetCube.html
@@ -1,71 +1,71 @@ -<!DOCTYPE html> -<html lang="en"> - <head> +<!DOCTYPE html> +<html lang="en"> + <head> <meta charset="utf-8" /> - <base href="../../" /> - <script src="list.js"></script> - <script src="page.js"></script> - <link type="text/css" rel="stylesheet" href="page.css" /> - </head> - <body> - [page:WebGLRenderTarget] &rarr; - - <h1>[name]</h1> - - <div class="desc"> - Used by the [page:CubeCamera] as its [page:WebGLRenderTarget]. - </div> - - <h2>Examples</h2> - - <div>See [page:CubeCamera] for examples.</div> - - - <h2>Constructor</h2> - - - <h3>[name]([page:Number width], [page:Number height], [page:Object options])</h3> - <div> - [page:Float width] - The width of the renderTarget. <br /> - [page:Float height] - The height of the renderTarget. <br /> - options - (optional0 object that holds texture parameters for an auto-generated target - texture and depthBuffer/stencilBuffer booleans. - - For an explanation of the texture parameters see [page:Texture Texture]. The following are - valid options:<br /><br /> - - [page:Constant wrapS] - default is [page:Textures ClampToEdgeWrapping]. <br /> - [page:Constant wrapT] - default is [page:Textures ClampToEdgeWrapping]. <br /> - [page:Constant magFilter] - default is [page:Textures .LinearFilter]. <br /> - [page:Constant minFilter] - default is [page:Textures LinearFilter]. <br /> - [page:Constant format] - default is [page:Textures RGBAFormat]. <br /> - [page:Constant type] - default is [page:Textures UnsignedByteType]. <br /> - [page:Number anisotropy] - default is *1*. See [page:Texture.anistropy]<br /> - [page:Constant encoding] - default is [page:Textures LinearEncoding]. <br /> - [page:Boolean depthBuffer] - default is *true*. Set this to false if you don't need it. <br /> - [page:Boolean stencilBuffer] - default is *true*. Set this to false if you don't need it.<br /><br /> - - Creates a new [name]] - </div> - - <h2>Properties</h2> - - <h3>[property:integer activeCubeFace]</h3> - <div> - The activeCubeFace property corresponds to a cube side (PX 0, NX 1, PY 2, NY 3, PZ 4, NZ 5) and is - used and set internally by the [page:CubeCamera]. - </div> - - <h3>See [page:WebGLRenderTarget] for inherited properties</h3> - - - <h2>Methods</h2> - - <h3>See [page:WebGLRenderTarget] for inherited methods</h3> - - - <h2>Source</h2> - - [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] - </body> -</html> + <base href="../../" /> + <script src="list.js"></script> + <script src="page.js"></script> + <link type="text/css" rel="stylesheet" href="page.css" /> + </head> + <body> + [page:WebGLRenderTarget] &rarr; + + <h1>[name]</h1> + + <div class="desc"> + Used by the [page:CubeCamera] as its [page:WebGLRenderTarget]. + </div> + + <h2>Examples</h2> + + <div>See [page:CubeCamera] for examples.</div> + + + <h2>Constructor</h2> + + + <h3>[name]([page:Number width], [page:Number height], [page:Object options])</h3> + <div> + [page:Float width] - The width of the renderTarget. <br /> + [page:Float height] - The height of the renderTarget. <br /> + options - (optional object that holds texture parameters for an auto-generated target + texture and depthBuffer/stencilBuffer booleans. + + For an explanation of the texture parameters see [page:Texture Texture]. The following are + valid options:<br /><br /> + + [page:Constant wrapS] - default is [page:Textures ClampToEdgeWrapping]. <br /> + [page:Constant wrapT] - default is [page:Textures ClampToEdgeWrapping]. <br /> + [page:Constant magFilter] - default is [page:Textures .LinearFilter]. <br /> + [page:Constant minFilter] - default is [page:Textures LinearFilter]. <br /> + [page:Constant format] - default is [page:Textures RGBAFormat]. <br /> + [page:Constant type] - default is [page:Textures UnsignedByteType]. <br /> + [page:Number anisotropy] - default is *1*. See [page:Texture.anistropy]<br /> + [page:Constant encoding] - default is [page:Textures LinearEncoding]. <br /> + [page:Boolean depthBuffer] - default is *true*. Set this to false if you don't need it. <br /> + [page:Boolean stencilBuffer] - default is *true*. Set this to false if you don't need it.<br /><br /> + + Creates a new [name] + </div> + + <h2>Properties</h2> + + <h3>[property:integer activeCubeFace]</h3> + <div> + The activeCubeFace property corresponds to a cube side (PX 0, NX 1, PY 2, NY 3, PZ 4, NZ 5) and is + used and set internally by the [page:CubeCamera]. + </div> + + <h3>See [page:WebGLRenderTarget] for inherited properties</h3> + + + <h2>Methods</h2> + + <h3>See [page:WebGLRenderTarget] for inherited methods</h3> + + + <h2>Source</h2> + + [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] + </body> +</html>
false
Other
mrdoob
three.js
3e91cc25eb0d8e8070681a87b0a0e48c5454fda2.json
translate the rest of audio api page.
docs/api/zh/audio/AudioAnalyser.html
@@ -11,15 +11,15 @@ <h1>[name]</h1> <p class="desc"> - Create a AudioAnalyser object, which uses an [link:https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode AnalyserNode] - to analyse audio data.<br /><br /> + 创建AudioAnalyser对象, 使用[link:https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode AnalyserNode] + 去分析音频数据.<br /><br /> - This uses the [link:https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API Web Audio API]. + 使用了 [link:https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API Web Audio API]. </p> - <h2>Example</h2> + <h2>示例</h2> <p> [example:webaudio_sandbox webaudio / sandbox ]</br> @@ -51,48 +51,48 @@ <h2>Example</h2> </code> - <h2>Constructor</h2> + <h2>构造函数</h2> <h3>[name]( audio, [link:https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/fftSize fftSize] )</h3> <p> - Create a new [page:AudioAnalyser AudioAnalyser]. + 创建[page:AudioAnalyser AudioAnalyser]. </p> - <h2>Properties</h2> + <h2>属性</h2> <h3>[property:AnalyserNode analyser]</h3> - <p>An [link:https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode AnalyserNode] used to analyze audio.</p> + <p>[link:https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode AnalyserNode]用来分析音频数据.</p> <h3>[property:Integer fftSize]</h3> <p> - A non-zero power of two up to 2048, representing the size of the FFT (Fast Fourier Transform) to be used to determine the frequency domain. - See [link:https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/fftSize this page] for details. + 2的幂次方最高为2048, 用来表示确定频域的FFT (傅立叶变换)大小. + 这个[link:https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/fftSize page]有详细信息. </p> <h3>[property:Uint8Array data]</h3> <p> - A Uint8Array with size determined by [link:https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount analyser.frequencyBinCount] - used to hold analysis data. + 用来分析数据的Uint8Array的大小由[link:https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount analyser.frequencyBinCount] + 确定. </p> - <h2>Methods</h2> + <h2>方法</h2> <h3>[method:Uint8Array getFrequencyData]()</h3> <p> - Uses the Web Audio's [link:https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData getByteFrequencyData] method. - See that page. + 使用网络音频的[link:https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData getByteFrequencyData] 方法. + 看这个页面. </p> <h3>[method:Number getAverageFrequency]()</h3> <p> - Get the average of the frequencies returned by the [page:AudioAnalyser.getFrequencyData getFrequencyData] method. + 通过方法[page:AudioAnalyser.getFrequencyData getFrequencyData]获取平均频率. </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
3e91cc25eb0d8e8070681a87b0a0e48c5454fda2.json
translate the rest of audio api page.
docs/api/zh/audio/AudioContext.html
@@ -12,30 +12,30 @@ <h1>[name]</h1> <p class="desc"> - This contains methods for setting up an [link:https://developer.mozilla.org/en-US/docs/Web/API/AudioContext AudioContext].<br /><br /> + 包含用来设置[link:https://developer.mozilla.org/en-US/docs/Web/API/AudioContext AudioContext]的方法.<br /><br /> - Used internally by the [page:AudioListener AudioListener] and [page:AudioLoader AudioLoader] classes.<br /><br /> + 在[page:AudioListener AudioListener]和[page:AudioLoader AudioLoader] 类中被使用.<br /><br /> - This uses the [link:https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API Web Audio API]. + 使用了 [link:https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API Web Audio API]. </p> - <h2>Methods</h2> + <h2>方法</h2> <h3>[method:AudioContext getContext]()</h3> <p> - Return the value of the variable *context* in the outer scope, if defined, - otherwise set it to a new [link:https://developer.mozilla.org/en-US/docs/Web/API/AudioContext AudioContext]. + 如果定义了,返回给外部*context*的值, + 否则创建一个新的[link:https://developer.mozilla.org/en-US/docs/Web/API/AudioContext AudioContext]. </p> <h3>[method:AudioContext setContext]( [param:AudioConetxt value] )</h3> <p> - Set the variable *context* in the outer scope to *value*. + 外部用来设置 *context* 的值. </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
3e91cc25eb0d8e8070681a87b0a0e48c5454fda2.json
translate the rest of audio api page.
docs/api/zh/audio/AudioListener.html
@@ -13,13 +13,13 @@ <h1>[name]</h1> <p class="desc"> - The [name] represents a virtual [link:https://developer.mozilla.org/de/docs/Web/API/AudioListener listener] of the all positional and non-positional audio effects in the scene.</br> - A three.js application usually creates a single instance of [name]. It is a mandatory construtor parameter for audios entities like [page:Audio Audio] and [page:PositionalAudio PositionalAudio].</br> - In most cases, the listener object is a child of the camera. So the 3D transformation of the camera represents the 3D transformation of the listener. + [name] 用一个虚拟的[link:https://developer.mozilla.org/de/docs/Web/API/AudioListener listener]表示在场景中所有的位置和非位置相关的音效.</br> + 一个three.js程序通常创建一个[name]. 它是音频实体构造函数的必须参数,比如 [page:Audio Audio] and [page:PositionalAudio PositionalAudio].</br> + 大多数情况下, listener对象是camera的子对象. Camera的3D变换表示了listener的3D变换. </p> - <h2>Example</h2> + <h2>示例</h2> <p> [example:webaudio_sandbox webaudio / sandbox ]</br> @@ -46,63 +46,62 @@ <h2>Example</h2> </code> - <h2>Constructor</h2> + <h2>构造函数</h2> <h3>[name]( )</h3> <p> - Create a new AudioListener. + 创建一个新的AudioListener. </p> - <h2>Properties</h2> + <h2>属性</h2> <h3>[property:AudioContext context]</h3> - <p>The [link:https://developer.mozilla.org/en-US/docs/Web/API/AudioContext AudioContext] of the [page:AudioListener listener] given in the constructor.</p> + <p>[page:AudioListener listener]构造函数中的[link:https://developer.mozilla.org/en-US/docs/Web/API/AudioContext AudioContext].</p> <h3>[property:GainNode gain]</h3> - <p>A [link:https://developer.mozilla.org/en-US/docs/Web/API/GainNode GainNode] created - using [link:https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createGain AudioContext.createGain]().</p> + <p>使用[link:https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createGain AudioContext.createGain]()创建 [link:https://developer.mozilla.org/en-US/docs/Web/API/GainNode GainNode].</p> <h3>[property:AudioNode filter]</h3> - <p>Default is *null*.</p> + <p>默认为*null*.</p> - <h2>Methods</h2> + <h2>方法</h2> <h3>[method:GainNode getInput]()</h3> <p> - Return the [page:AudioListener.gain gainNode]. + 返回[page:AudioListener.gain gainNode]. </p> <h3>[method:AudioListener removeFilter]()</h3> <p> - Set the [page:AudioListener.filter filter] property to *null*. + 设置[page:AudioListener.filter filter]属性为*null*. </p> <h3>[method:AudioNode getFilter]()</h3> <p> - Returns the value of the [page:AudioListener.filter filter] property. + 返回[page:AudioListener.filter filter]属性的值. </p> <h3>[method:AudioListener setFilter]( [param:AudioNode value] )</h3> <p> - Set the [page:AudioListener.filter filter] property to *value*. + 设置[page:AudioListener.filter filter] 属性的值. </p> <h3>[method:Float getMasterVolume]()</h3> <p> - Return the volume. + 返回音量. </p> <h3>[method:AudioListener setMasterVolume]( [param:Number value] )</h3> <p> - Set the volume. + 设置音量. </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
3e91cc25eb0d8e8070681a87b0a0e48c5454fda2.json
translate the rest of audio api page.
docs/api/zh/audio/PositionalAudio.html
@@ -13,13 +13,13 @@ <h1>[name]</h1> <p class="desc"> - Create a positional audio object.<br /><br /> + 创建一个位置相关的音频对象.<br /><br /> - This uses the [link:https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API Web Audio API]. + 使用了[link:https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API Web Audio API]. </p> - <h2>Example</h2> + <h2>示例</h2> <p> [example:webaudio_orientation webaudio / orientation ]</br> @@ -54,78 +54,78 @@ <h2>Example</h2> </code> - <h2>Constructor</h2> + <h2>构造函数</h2> <h3>[name]( [param:AudioListener listener] )</h3> <p> - listener — (required) [page:AudioListener AudioListener] instance. + listener — (必须) [page:AudioListener AudioListener] 实例. </p> - <h2>Properties</h2> + <h2>属性</h2> <p> - See the [page:Audio Audio] class for inherited properties. + [page:Audio Audio]类的继承属性. </p> <h3>[property:PannerNode panner]</h3> - <p>The PositionalAudio's [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode PannerNode].</p> + <p>位置相关音频的[link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode PannerNode].</p> - <h2>Methods</h2> + <h2>方法</h2> <p> - See the [page:Audio Audio] class for inherited methods. + [page:Audio Audio]类的继承方法. </p> <h3>[method:PannerNode getOutput]()</h3> <p> - Returns the [page:PositionalAudio.panner panner]. + 返回[page:PositionalAudio.panner panner]. </p> <h3>[method:Float getRefDistance]()</h3> <p> - Returns the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/refDistance panner.refDistance]. + 返回[link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/refDistance panner.refDistance]的值. </p> <h3>[method:PositionalAudio setRefDistance]( [param:Float value] )</h3> <p> - Sets the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/refDistance panner.refDistance]. + 设置[link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/refDistance panner.refDistance]的值. </p> <h3>[method:Float getRolloffFactor]()</h3> <p> - Returns the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/rolloffFactor panner.rolloffFactor]. + 返回[link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/rolloffFactor panner.rolloffFactor]的值. </p> <h3>[method:PositionalAudio setRolloffFactor]( [param:Float value] )</h3> <p> - Sets the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/rolloffFactor panner.rolloffFactor]. + 设置[link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/rolloffFactor panner.rolloffFactor]的值. </p> <h3>[method:String getDistanceModel]()</h3> <p> - Returns the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/distanceModel panner.distanceModel]. + 返回[link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/distanceModel panner.distanceModel]的值. </p> <h3>[method:PositionalAudio setDistanceModel]( [param:String value] )</h3> <p> - Sets the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/distanceModel panner.distanceModel]. + 设置[link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/distanceModel panner.distanceModel]的值. </p> <h3>[method:Float getMaxDistance]()</h3> <p> - Returns the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/maxDistance panner.maxDistance]. + 返回[link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/maxDistance panner.maxDistance]的值. </p> <h3>[method:PositionalAudio setMaxDistance]( [param:Float value] )</h3> <p> - Sets the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/maxDistance panner.maxDistance]. + 设置[link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/maxDistance panner.maxDistance]的值. </p> <h3>[method:PositionalAudio setDirectionalCone]( [param:Float coneInnerAngle], [param:Float coneOuterAngle], [param:Float coneOuterGain] )</h3> <p> - This method can be used in order to transform an omnidirectional sound into a [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode directional sound]. + 这个方法用来把环绕声音转换为定向声音[link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode directional sound]. </p> <h2>Source</h2>
true
Other
mrdoob
three.js
fb0eb7799f247193b286c5ea42020aba0eb6d08c.json
add readme for nrrd model source/license
examples/models/nrrd/README.txt
@@ -0,0 +1,14 @@ +# Source and license of the files in this directory + + +## stent.nrrd + +A 3D volume converted from stent.npz from the imageio project. +https://imageio.readthedocs.io/en/latest/standardimages.html + +It is in the public domain. + + +## l.nrrd + +Unknown
false
Other
mrdoob
three.js
96c1f744eef6498e3c9dd15cc41a2235a070da40.json
Update VRMLLoader to import vertex colors. #14814 Updates the VRML loader so that it imports vertex colors properly. Also implements parsing of `colorIndex`, `normalIndex` & `creaseAngle`, which still needs to be properly implemented.
examples/js/loaders/VRMLLoader.js
@@ -210,6 +210,7 @@ THREE.VRMLLoader.prototype = { scope.angles = []; break; + case 'color': case 'skyColor': case 'groundColor': scope.recordingFieldname = fieldName; @@ -224,7 +225,9 @@ THREE.VRMLLoader.prototype = { scope.points = []; break; + case 'colorIndex': case 'coordIndex': + case 'normalIndex': case 'texCoordIndex': scope.recordingFieldname = fieldName; scope.isRecordingFaces = true; @@ -446,6 +449,7 @@ THREE.VRMLLoader.prototype = { case 'transparency': case 'shininess': case 'ambientIntensity': + case 'creaseAngle': if ( parts.length !== 2 ) { console.warn( 'THREE.VRMLLoader: Invalid single float value specification detected for %s.', fieldName ); @@ -810,10 +814,11 @@ THREE.VRMLLoader.prototype = { var geometry = new THREE.BufferGeometry(); var positions = []; + var colors = []; var normals = []; var uvs = []; - var position, normal, uv; + var position, color, normal, uv; var i, il, j, jl; @@ -855,6 +860,23 @@ THREE.VRMLLoader.prototype = { } + // colors + + if ( child.nodeType === 'Color' ) { + + if ( child.color ) { + + for ( j = 0, jl = child.color.length; j < jl; j ++ ) { + + color = child.color[ j ]; + colors.push( color.r, color.g, color.b ); + + } + + } + + } + // positions if ( child.nodeType === 'Coordinate' ) { @@ -897,10 +919,12 @@ THREE.VRMLLoader.prototype = { if ( data.coordIndex ) { var newPositions = []; + var newColors = []; var newNormals = []; var newUvs = []; position = new THREE.Vector3(); + color = new THREE.Color(); normal = new THREE.Vector3(); uv = new THREE.Vector2(); @@ -929,6 +953,17 @@ THREE.VRMLLoader.prototype = { position.fromArray( positions, i3 * 3 ); newPositions.push( position.x, position.y, position.z ); + if ( colors.length > 0 ) { + + color.fromArray( colors, i1 * 3 ); + newColors.push( color.r, color.g, color.b ); + color.fromArray( colors, i2 * 3 ); + newColors.push( color.r, color.g, color.b ); + color.fromArray( colors, i3 * 3 ); + newColors.push( color.r, color.g, color.b ); + + } + if ( uvs.length > 0 ) { uv.fromArray( uvs, i1 * 2 ); @@ -958,6 +993,7 @@ THREE.VRMLLoader.prototype = { } positions = newPositions; + colors = newColors; normals = newNormals; uvs = newUvs; @@ -980,6 +1016,12 @@ THREE.VRMLLoader.prototype = { geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( positions, 3 ) ); + if ( colors.length > 0 ) { + + geometry.addAttribute( 'color', new THREE.Float32BufferAttribute( colors, 3 ) ); + + } + if ( uvs.length > 0 ) { geometry.addAttribute( 'uv', new THREE.Float32BufferAttribute( uvs, 2 ) );
false
Other
mrdoob
three.js
7b0c2f2f54f10febf81ada1d4b1774276665cc61.json
translate audio api page.
docs/api/zh/audio/Audio.html
@@ -13,13 +13,13 @@ <h1>[name]</h1> <p class="desc"> - Create a non-positional ( global ) audio object.<br /><br /> + 创建一个( 全局 ) audio对象.<br /><br /> - This uses the [link:https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API Web Audio API]. + 使用 [link:https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API Web Audio API]. </p> - <h2>Example</h2> + <h2>例子</h2> <p> [example:webaudio_sandbox webaudio / sandbox ]</br> @@ -45,171 +45,167 @@ <h2>Example</h2> </code> - <h2>Constructor</h2> + <h2>构造函数</h2> <h3>[name]( [param:AudioListener listener] )</h3> <p> - listener — (required) [page:AudioListener AudioListener] instance. + listener — (必须) [page:AudioListener AudioListener] 的实例. </p> - <h2>Properties</h2> + <h2>属性</h2> <h3>[property:Boolean autoplay]</h3> - <p>Whether to start playback automatically. Default is *false*.</p> + <p>是否自动开始播放. 默认为 *false*.</p> <h3>[property:AudioContext context]</h3> - <p>The [link:https://developer.mozilla.org/en-US/docs/Web/API/AudioContext AudioContext] of the [page:AudioListener listener] given in the constructor.</p> + <p>构造函数中传入[page:AudioListener listener]的[link:https://developer.mozilla.org/en-US/docs/Web/API/AudioContext AudioContext].</p> <h3>[property:Array filters]</h3> - <p>Represents an array of [link:https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode BiquadFilterNodes]. Can be used to apply a variety of low-order filters to create more complex sound effects. Filters are set via [page:Audio.setFilter] or [page:Audio.setFilters].</p> + <p>表示[link:https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode BiquadFilterNodes]的数组. 可以使用多种不同的低阶filters去创建复杂的音效. filters可以通过 [page:Audio.setFilter] 或者 [page:Audio.setFilters]设置.</p> <h3>[property:GainNode gain]</h3> - <p>A [link:https://developer.mozilla.org/en-US/docs/Web/API/GainNode GainNode] created - using [link:https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createGain AudioContext.createGain]().</p> + <p>使用[link:https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createGain AudioContext.createGain]()创建的[link:https://developer.mozilla.org/en-US/docs/Web/API/GainNode GainNode].</p> <h3>[property:Boolean hasPlaybackControl]</h3> - <p>Whether playback can be controlled using the [page:Audio.play play](), - [page:Audio.pause pause]() etc. methods. Default is *true*.</p> + <p>是否可以使用 [page:Audio.play play](), + [page:Audio.pause pause]()等方法控制播放. 默认为 *true*.</p> <h3>[property:Number playbackRate]</h3> - <p>Speed of playback. Default is *1*.</p> + <p>播放速率. 默认为 *1*.</p> <h3>[property:Boolean isPlaying]</h3> - <p>Whether the audio is currently playing.</p> + <p>是否正在播放</p> <h3>[property:Number startTime]</h3> - <p>The time at which the sound should begin to play. Same as the *when* paramter of [link:https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/start AudioBufferSourceNode.start](). Default is *0*.</p> + <p>开始播放的时间. 和[link:https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/start AudioBufferSourceNode.start]()的*when*参数一样. 默认为 *0*.</p> <h3>[property:Number offset]</h3> - <p>An offset to the time within the audio buffer that playback should begin. Same as the *offset* paramter of [link:https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/start AudioBufferSourceNode.start](). Default is *0*.</p> + <p>音频开始播放的偏移时间. 和[link:https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/start AudioBufferSourceNode.start]()的*offset*参数一样. 默认为 *0*.</p> <h3>[property:String source]</h3> - <p>An [link:https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode AudioBufferSourceNode] created - using [link:https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createBufferSource AudioContext.createBufferSource]().</p> + <p>使用 [link:https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createBufferSource AudioContext.createBufferSource]()创建的[link:https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode AudioBufferSourceNode].</p> <h3>[property:String sourceType]</h3> - <p>Type of the audio source. Default is string 'empty'.</p> + <p>音源的类型. 默认为 'empty'.</p> <h3>[property:String type]</h3> - <p>String denoting the type, set to 'Audio'.</p> + <p>表示类型的字符串, 设置为'Audio'.</p> - <h2>Methods</h2> + <h2>方法</h2> <h3>[method:Audio connect]()</h3> <p> - Connect to the [page:Audio.source]. This is used internally on initialisation and when - setting / removing filters. + 连接[page:Audio.source]. 在初始化和设置/删除filters时使用. </p> <h3>[method:Audio disconnect]()</h3> <p> - Disconnect from the [page:Audio.source]. This is used internally when - setting / removing filters. + 断开连接[page:Audio.source]. 在设置/删除filters时使用. </p> <h3>[method:BiquadFilterNode getFilter]()</h3> <p> - Returns the first element of the [page:Audio.filters filters] array. + 返回 [page:Audio.filters filters] 数组的第一个元素. </p> <h3>[method:Array getFilters]()</h3> <p> - Returns the [page:Audio.filters filters] array. + 返回[page:Audio.filters filters] 数组. </p> <h3>[method:Boolean getLoop]()</h3> <p> - Return the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/loop source.loop] - (whether playback should loop). + 返回[link:https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/loop source.loop] + (是否循环播放)的值. </p> <h3>[method:GainNode getOutput]()</h3> <p> - Return the [page:Audio.gain gainNode]. + 返回[page:Audio.gain gainNode]. </p> <h3>[method:Float getPlaybackRate]()</h3> <p> - Return the value of [page:Audio.playbackRate playbackRate]. + 返回[page:Audio.playbackRate playbackRate]的值. </p> <h3>[method:Float getVolume]( value )</h3> <p> - Return the current volume. + 返回音量. </p> <h3>[method:Audio play]()</h3> <p> - If [page:Audio.hasPlaybackControl hasPlaybackControl] is true, starts playback. + 如果[page:Audio.hasPlaybackControl hasPlaybackControl]是true, 开始播放. </p> <h3>[method:Audio pause]()</h3> <p> - If [page:Audio.hasPlaybackControl hasPlaybackControl] is true, pauses playback. + 如果[page:Audio.hasPlaybackControl hasPlaybackControl]是true, 暂停播放. </p> <h3>[method:null onEnded]()</h3> <p> - Called automatically when playback finished. Sets If [page:Audio.isPlaying isPlaying] to false. + 播放完成后自动调用. 如果[page:Audio.isPlaying isPlaying]设置为false. </p> <h3>[method:Audio setBuffer]( audioBuffer )</h3> <p> - Setup the [page:Audio.source source] to the audioBuffer, and sets [page:Audio.sourceType sourceType] to 'buffer'.<br /> - If [page:Audio.autoplay autoplay], also starts playback. + 设置[page:Audio.source source]给audioBuffer, 和设置[page:Audio.sourceType sourceType]给'buffer'.<br /> + 如果[page:Audio.autoplay autoplay]为true, 也开始播放. </p> <h3>[method:Audio setFilter]( filter )</h3> <p> - Applies a single [link:https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode BiquadFilterNode] to the audio. + 设置一个[link:https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode BiquadFilterNode]给Audio. </p> <h3>[method:Audio setFilters]( [param:Array value] )</h3> <p> - value - arrays of filters.<br /> - Applies an array of [link:https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode BiquadFilterNodes] to the audio. + value--filters数组.<br /> + 应用[link:https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode BiquadFilterNodes]数组给Audio. </p> <h3>[method:Audio setLoop]( [param:Boolean value] )</h3> <p> - Set [link:https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/loop source.loop] to *value* - (whether playback should loop). + 设置[link:https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/loop source.loop] 的值 + (是否循环播放). </p> <h3>[method:Audio setMediaElementSource]( mediaElement )</h3> <p> - Applies the given object of type [link:https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement HTMLMediaElement] as the source of this audio.<br /> - Also sets [page:Audio.hasPlaybackControl hasPlaybackControl] to false. + 应用[link:https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement HTMLMediaElement]类型对象作为音源.<br /> + 并且设置[page:Audio.hasPlaybackControl hasPlaybackControl]为false. </p> <h3>[method:Audio setNodeSource]( audioNode )</h3> <p> - Setup the [page:Audio.source source] to the audioBuffer, and sets [page:Audio.sourceType sourceType] to 'audioNode'.<br /> - Also sets [page:Audio.hasPlaybackControl hasPlaybackControl] to false. + 设置[page:Audio.source source]给audioBuffer, 和设置[page:Audio.sourceType sourceType]给 'audioNode'.<br /> + 并且设置[page:Audio.hasPlaybackControl hasPlaybackControl]为false. </p> <h3>[method:Audio setPlaybackRate]( [param:Float value] )</h3> <p> - If [page:Audio.hasPlaybackControl hasPlaybackControl] is enabled, set the [page:Audio.playbackRate playbackRate] to *value*. + 如果[page:Audio.hasPlaybackControl hasPlaybackControl]是true, 设置[page:Audio.playbackRate playbackRate](播放速率) 的值. </p> <h3>[method:Audio setVolume]( [param:Float value] )</h3> <p> - Set the volume. + 设置音量. </p> <h3>[method:Audio stop]()</h3> <p> - If [page:Audio.hasPlaybackControl hasPlaybackControl] is enabled, stops playback, - resets [page:Audio.startTime startTime] to *0* and sets [page:Audio.isPlaying isPlaying] to false. + 如果[page:Audio.hasPlaybackControl hasPlaybackControl]是true, 停止播放, + 重新设置[page:Audio.startTime startTime]为 *0* 和 设置 [page:Audio.isPlaying isPlaying]为false. </p> - <h2>Source</h2> + <h2>源码</h2> [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] </body>
false
Other
mrdoob
three.js
eaa0c6d491d2646ebf719f25a1d50638e246fb39.json
Add volume rendering example
examples/js/shaders/VolumeShader.js
@@ -0,0 +1,320 @@ +// Author: Almar Klein +// Description: Shaders to render 3D volumes using raycasting. +// The applied techniques are based on similar implementations in the Visvis and Vispy projects. +// This is not the only approach, therefore it's marked 1. + + +THREE.ShaderLib[ 'volumerender1' ] = { + uniforms: { + "u_size": { value: [1, 1, 1] }, + "u_renderstyle": { value: 0 }, + "u_renderthreshold": { value: 0.5 }, + "u_clim": { value: [0.0, 1.0] } + }, + vertexShader: [ + 'varying vec4 v_nearpos;', + 'varying vec4 v_farpos;', + 'varying vec3 v_position;', + + 'mat4 inversemat(mat4 m) {', + // Taken from https://github.com/stackgl/glsl-inverse/blob/master/index.glsl + // This function is licenced by the MIT license to Mikola Lysenko + 'float', + 'a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],', + 'a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],', + 'a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],', + 'a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],', + + 'b00 = a00 * a11 - a01 * a10,', + 'b01 = a00 * a12 - a02 * a10,', + 'b02 = a00 * a13 - a03 * a10,', + 'b03 = a01 * a12 - a02 * a11,', + 'b04 = a01 * a13 - a03 * a11,', + 'b05 = a02 * a13 - a03 * a12,', + 'b06 = a20 * a31 - a21 * a30,', + 'b07 = a20 * a32 - a22 * a30,', + 'b08 = a20 * a33 - a23 * a30,', + 'b09 = a21 * a32 - a22 * a31,', + 'b10 = a21 * a33 - a23 * a31,', + 'b11 = a22 * a33 - a23 * a32,', + + 'det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;', + + 'return mat4(', + 'a11 * b11 - a12 * b10 + a13 * b09,', + 'a02 * b10 - a01 * b11 - a03 * b09,', + 'a31 * b05 - a32 * b04 + a33 * b03,', + 'a22 * b04 - a21 * b05 - a23 * b03,', + 'a12 * b08 - a10 * b11 - a13 * b07,', + 'a00 * b11 - a02 * b08 + a03 * b07,', + 'a32 * b02 - a30 * b05 - a33 * b01,', + 'a20 * b05 - a22 * b02 + a23 * b01,', + 'a10 * b10 - a11 * b08 + a13 * b06,', + 'a01 * b08 - a00 * b10 - a03 * b06,', + 'a30 * b04 - a31 * b02 + a33 * b00,', + 'a21 * b02 - a20 * b04 - a23 * b00,', + 'a11 * b07 - a10 * b09 - a12 * b06,', + 'a00 * b09 - a01 * b07 + a02 * b06,', + 'a31 * b01 - a30 * b03 - a32 * b00,', + 'a20 * b03 - a21 * b01 + a22 * b00) / det;', + '}', + + + 'void main() {', + // Prepare transforms to map to "camera view". See also: + // https://threejs.org/docs/#api/renderers/webgl/WebGLProgram + 'mat4 viewtransformf = viewMatrix;', + 'mat4 viewtransformi = inversemat(viewMatrix);', + + // Project local vertex coordinate to camera position. Then do a step + // backward (in cam coords) to the near clipping plane, and project back. Do + // the same for the far clipping plane. This gives us all the information we + // need to calculate the ray and truncate it to the viewing cone. + 'vec4 position4 = vec4(position, 1.0);', + 'vec4 pos_in_cam = viewtransformf * position4;', + + // Intersection of ray and near clipping plane (z = -1 in clip coords) + 'pos_in_cam.z = -pos_in_cam.w;', + 'v_nearpos = viewtransformi * pos_in_cam;', + + // Intersection of ray and far clipping plane (z = +1 in clip coords) + 'pos_in_cam.z = pos_in_cam.w;', + 'v_farpos = viewtransformi * pos_in_cam;', + + // Set varyings and output pos + 'v_position = position;', + 'gl_Position = projectionMatrix * viewMatrix * modelMatrix * position4;', + '}', + ].join( '\n' ), + fragmentShader: [ + 'precision highp float;', + 'precision mediump sampler3D;', + + 'uniform vec3 u_size;', + 'uniform int u_renderstyle;', + 'uniform float u_renderthreshold;', + 'uniform vec2 u_clim;', + + 'uniform sampler3D u_data;', + 'uniform sampler2D u_cmdata;', + + 'varying vec3 v_position;', + 'varying vec4 v_nearpos;', + 'varying vec4 v_farpos;', + + // The maximum distance through our rendering volume is sqrt(3). + 'const int MAX_STEPS = 887; // 887 for 512^3, 1774 for 1024^3', + 'const int REFINEMENT_STEPS = 4;', + 'const float relative_step_size = 1.0;', + 'const vec4 ambient_color = vec4(0.2, 0.4, 0.2, 1.0);', + 'const vec4 diffuse_color = vec4(0.8, 0.2, 0.2, 1.0);', + 'const vec4 specular_color = vec4(1.0, 1.0, 1.0, 1.0);', + 'const float shininess = 40.0;', + + 'void cast_mip(vec3 start_loc, vec3 step, int nsteps, vec3 view_ray);', + 'void cast_iso(vec3 start_loc, vec3 step, int nsteps, vec3 view_ray);', + + 'float sample1(vec3 texcoords);', + 'vec4 apply_colormap(float val);', + 'vec4 add_lighting(float val, vec3 loc, vec3 step, vec3 view_ray);', + + + 'void main() {', + // Normalize clipping plane info + 'vec3 farpos = v_farpos.xyz / v_farpos.w;', + 'vec3 nearpos = v_nearpos.xyz / v_nearpos.w;', + + // Calculate unit vector pointing in the view direction through this fragment. + 'vec3 view_ray = normalize(nearpos.xyz - farpos.xyz);', + + // Compute the (negative) distance to the front surface or near clipping plane. + // v_position is the back face of the cuboid, so the initial distance calculated in the dot + // product below is the distance from near clip plane to the back of the cuboid + 'float distance = dot(nearpos - v_position, view_ray);', + 'distance = max(distance, min((-0.5 - v_position.x) / view_ray.x,', + '(u_size.x - 0.5 - v_position.x) / view_ray.x));', + 'distance = max(distance, min((-0.5 - v_position.y) / view_ray.y,', + '(u_size.y - 0.5 - v_position.y) / view_ray.y));', + 'distance = max(distance, min((-0.5 - v_position.z) / view_ray.z,', + '(u_size.z - 0.5 - v_position.z) / view_ray.z));', + + // Now we have the starting position on the front surface + 'vec3 front = v_position + view_ray * distance;', + + // Decide how many steps to take + 'int nsteps = int(-distance / relative_step_size + 0.5);', + 'if ( nsteps < 1 )', + 'discard;', + + // Get starting location and step vector in texture coordinates + 'vec3 step = ((v_position - front) / u_size) / float(nsteps);', + 'vec3 start_loc = front / u_size;', + + // For testing: show the number of steps. This helps to establish + // whether the rays are correctly oriented + //'gl_FragColor = vec4(0.0, float(nsteps) / 1.0 / u_size.x, 1.0, 1.0);', + //'return;', + + 'if (u_renderstyle == 0)', + 'cast_mip(start_loc, step, nsteps, view_ray);', + 'else if (u_renderstyle == 1)', + 'cast_iso(start_loc, step, nsteps, view_ray);', + + 'if (gl_FragColor.a < 0.05)', + 'discard;', + '}', + + + 'float sample1(vec3 texcoords) {', + '/* Sample float value from a 3D texture. Assumes intensity data. */', + 'return texture(u_data, texcoords.xyz).r;', + '}', + + + 'vec4 apply_colormap(float val) {', + 'val = (val - u_clim[0]) / (u_clim[1] - u_clim[0]);', + 'return texture2D(u_cmdata, vec2(val, 0.5));', + '}', + + + 'void cast_mip(vec3 start_loc, vec3 step, int nsteps, vec3 view_ray) {', + + 'float max_val = -1e6;', + 'int max_i = 100;', + 'vec3 loc = start_loc;', + + // Enter the raycasting loop. In WebGL 1 the loop index cannot be compared with + // non-constant expression. So we use a hard-coded max, and an additional condition + // inside the loop. + 'for (int iter=0; iter<MAX_STEPS; iter++) {', + 'if (iter >= nsteps)', + 'break;', + // Sample from the 3D texture + 'float val = sample1(loc);', + // Apply MIP operation + 'if (val > max_val) {', + 'max_val = val;', + 'max_i = iter;', + '}', + // Advance location deeper into the volume + 'loc += step;', + '}', + + // Refine location, gives crispier images + 'vec3 iloc = start_loc + step * (float(max_i) - 0.5);', + 'vec3 istep = step / float(REFINEMENT_STEPS);', + 'for (int i=0; i<REFINEMENT_STEPS; i++) {', + 'max_val = max(max_val, sample1(iloc));', + 'iloc += istep;', + '}', + + // Resolve final color + 'gl_FragColor = apply_colormap(max_val);', + '}', + + + 'void cast_iso(vec3 start_loc, vec3 step, int nsteps, vec3 view_ray) {', + + 'gl_FragColor = vec4(0.0); // init transparent', + 'vec4 color3 = vec4(0.0); // final color', + 'vec3 dstep = 1.5 / u_size; // step to sample derivative', + 'vec3 loc = start_loc;', + + 'float low_threshold = u_renderthreshold - 0.02 * (u_clim[1] - u_clim[0]);', + + // Enter the raycasting loop. In WebGL 1 the loop index cannot be compared with + // non-constant expression. So we use a hard-coded max, and an additional condition + // inside the loop. + 'for (int iter=0; iter<MAX_STEPS; iter++) {', + 'if (iter >= nsteps)', + 'break;', + + // Sample from the 3D texture + 'float val = sample1(loc);', + + 'if (val > low_threshold) {', + // Take the last interval in smaller steps + 'vec3 iloc = loc - 0.5 * step;', + 'vec3 istep = step / float(REFINEMENT_STEPS);', + 'for (int i=0; i<REFINEMENT_STEPS; i++) {', + 'val = sample1(iloc);', + 'if (val > u_renderthreshold) {', + 'gl_FragColor = add_lighting(val, iloc, dstep, view_ray);', + 'return;', + '}', + 'iloc += istep;', + '}', + '}', + + // Advance location deeper into the volume + 'loc += step;', + '}', + '}', + + + 'vec4 add_lighting(float val, vec3 loc, vec3 step, vec3 view_ray)', + '{', + // Calculate color by incorporating lighting + + // View direction + 'vec3 V = normalize(view_ray);', + + // calculate normal vector from gradient + 'vec3 N;', + 'float val1, val2;', + 'val1 = sample1(loc + vec3(-step[0], 0.0, 0.0));', + 'val2 = sample1(loc + vec3(+step[0], 0.0, 0.0));', + 'N[0] = val1 - val2;', + 'val = max(max(val1, val2), val);', + 'val1 = sample1(loc + vec3(0.0, -step[1], 0.0));', + 'val2 = sample1(loc + vec3(0.0, +step[1], 0.0));', + 'N[1] = val1 - val2;', + 'val = max(max(val1, val2), val);', + 'val1 = sample1(loc + vec3(0.0, 0.0, -step[2]));', + 'val2 = sample1(loc + vec3(0.0, 0.0, +step[2]));', + 'N[2] = val1 - val2;', + 'val = max(max(val1, val2), val);', + + 'float gm = length(N); // gradient magnitude', + 'N = normalize(N);', + + // Flip normal so it points towards viewer + 'float Nselect = float(dot(N, V) > 0.0);', + 'N = (2.0 * Nselect - 1.0) * N; // == Nselect * N - (1.0-Nselect)*N;', + + // Init colors + 'vec4 ambient_color = vec4(0.0, 0.0, 0.0, 0.0);', + 'vec4 diffuse_color = vec4(0.0, 0.0, 0.0, 0.0);', + 'vec4 specular_color = vec4(0.0, 0.0, 0.0, 0.0);', + + // note: could allow multiple lights + 'for (int i=0; i<1; i++)', + '{', + // Get light direction (make sure to prevent zero devision) + 'vec3 L = normalize(view_ray); //lightDirs[i];', + 'float lightEnabled = float( length(L) > 0.0 );', + 'L = normalize(L + (1.0 - lightEnabled));', + + // Calculate lighting properties + 'float lambertTerm = clamp(dot(N, L), 0.0, 1.0);', + 'vec3 H = normalize(L+V); // Halfway vector', + 'float specularTerm = pow(max(dot(H, N), 0.0), shininess);', + + // Calculate mask + 'float mask1 = lightEnabled;', + + // Calculate colors + 'ambient_color += mask1 * ambient_color; // * gl_LightSource[i].ambient;', + 'diffuse_color += mask1 * lambertTerm;', + 'specular_color += mask1 * specularTerm * specular_color;', + '}', + + // Calculate final color by componing different components + 'vec4 final_color;', + 'vec4 color = apply_colormap(val);', + 'final_color = color * (ambient_color + diffuse_color) + specular_color;', + 'final_color.a = color.a;', + 'return final_color;', + '}', + ].join( '\n' ) +};
true
Other
mrdoob
three.js
eaa0c6d491d2646ebf719f25a1d50638e246fb39.json
Add volume rendering example
examples/webgl_materials_texture3d_volume1.html
@@ -0,0 +1,294 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <title>three.js webgl - loaders - vtk loader</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 { + font-family: Monospace; + background-color: #000; + color: #fff; + margin: 0px; + overflow: hidden; + } + #info { + color: #fff; + position: absolute; + top: 10px; + width: 100%; + text-align: center; + z-index: 5; + display:block; + } + .dg { + z-index: 10 !important; + } + #info a, .button { color: #f00; font-weight: bold; text-decoration: underline; cursor: pointer } + #inset { + width: 150px; + height: 150px; + background-color: transparent; /* or transparent; will show through only if renderer alpha: true */ + border: none; /* or none; */ + margin: 0; + padding: 0px; + position: absolute; + left: 20px; + bottom: 20px; + z-index: 100; + } + </style> + </head> + + <body> + <div id="info"> + <a href="http://threejs.org" target="_blank" rel="noopener">three.js</a> - + Float volume render test (mip / isosurface) + </div> + <div id="inset"></div> + + <script src="../build/three.js"></script> + + <script src="js/controls/TrackballControls.js"></script> + + <script src="js/Volume.js"></script> + <script src="js/VolumeSlice.js"></script> + <script src="js/loaders/NRRDLoader.js"></script> + <script src="js/shaders/VolumeShader.js"></script> + + <script src="js/Detector.js"></script> + <script src="js/libs/stats.min.js"></script> + <script src="js/libs/gunzip.min.js"></script> + <script src="js/libs/dat.gui.min.js"></script> + + <script> + + if ( ! Detector.webgl ) Detector.addGetWebGLMessage(); + + var container, + stats, + camera, + controls, + scene, + renderer, + gui, + container2, + renderer2, + camera2, + axes2, + scene2; + + init(); + animate(); + + function init() { + + // The volume renderer does not work very well with perspective yet + //camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 0.01, 1e10 ); + camera = new THREE.OrthographicCamera() + camera.position.z = 1000; + this.camera.right = window.innerWidth / 5.0; + this.camera.left = -this.camera.right; + this.camera.top = window.innerHeight / 5.0; + this.camera.bottom = -this.camera.top; + this.camera.near = 0.1; + this.camera.far = 5000; + this.camera.updateProjectionMatrix(); + + scene = new THREE.Scene(); + + scene.add( camera ); + + // light + + var dirLight = new THREE.DirectionalLight( 0xffffff ); + dirLight.position.set( 200, 200, 1000 ).normalize(); + + camera.add( dirLight ); + camera.add( dirLight.target ); + + var loader = new THREE.NRRDLoader(); + loader.load( "models/nrrd/stent.nrrd", function ( volume ) { + window.volume = volume; + if (false) { + // Box helper to see the extend of the volume + var geometry = new THREE.BoxBufferGeometry( volume.xLength, volume.yLength, volume.zLength ); + geometry = geometry.translate(+volume.xLength / 2, -volume.yLength / 2, -volume.zLength / 2); + var material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } ); + var cube = new THREE.Mesh( geometry, material ); + cube.visible = false; + var box = new THREE.BoxHelper( cube ); + scene.add( box ); + box.applyMatrix(volume.matrix); + scene.add( cube ); + } + + // Texture to hold the volume. We have scalars, so we put our data in the red channel. + // THREEJS will select R32F (33326) based on the RedFormat and FloatType. + // Also see https://www.khronos.org/registry/webgl/specs/latest/2.0/#TEXTURE_TYPES_FORMATS_FROM_DOM_ELEMENTS_TABLE + // TODO: look the dtype up in the volume metadata + var texture = new THREE.Texture3D(volume.data, volume.xLength, volume.yLength, volume.zLength, THREE.RedFormat, THREE.FloatType); + texture.minFilter = texture.magFilter = THREE.LinearFilter; + texture.unpackAlignment = 1; + texture.needsUpdate = true; + + // Colormap texture + var cmtexture = new THREE.TextureLoader().load( 'textures/cm_viridis.png' ); // e.g. cm_gray or cm_viridis + + // Material (shaders) to render the volume using raycasting + var volmaterial = new THREE.ShaderMaterial( THREE.ShaderLib['volumerender1'] ); + volmaterial.side = THREE.BackSide; // The volume shader uses the backface as its "reference point" + + // Apply volume material uniform info + volmaterial.uniforms.u_data = { type: 't', value: texture }; + volmaterial.uniforms.u_cmdata = { type: 't', value: cmtexture }; + volmaterial.uniforms.u_size = { type: 'v3', value: [volume.xLength, volume.yLength, volume.zLength] }; + volmaterial.uniforms.u_renderstyle = {type: 'int', value: 0}; // 0: MIP, 1: ISO + volmaterial.uniforms.u_renderthreshold = {type: 'f', value: 0.3}; // For ISO renderstyle + volmaterial.uniforms.u_clim = {type: 'v2', value: [0, 1]}; + volmaterial.needsUpdate = true; + + // Geometry for the volume + var volgeometry = new THREE.BoxGeometry( volume.xLength, volume.yLength, volume.zLength ); + volgeometry = volgeometry.translate(volume.xLength / 2 - 0.5, volume.yLength / 2 - 0.5, volume.zLength / 2 - 0.5); + var volcube = new THREE.Mesh(volgeometry, volmaterial); + scene.add( volcube ); + + // TODO: the texture coordinates currently map directly to world coordinates. That's why we translate + // the geometry above. But the extractSlice() below assume that the volume is centered at the origin. + // We need to add a material attribute with texture coordinates to fix this. + return; + + //z plane + var indexZ = 0; + var sliceZ = volume.extractSlice('z',Math.floor(volume.RASDimensions[2]/4)); + scene.add( sliceZ.mesh ); + + //y plane + var indexY = 0; + var sliceY = volume.extractSlice('y',Math.floor(volume.RASDimensions[1]/2)); + scene.add( sliceY.mesh ); + + //x plane + var indexX = 0; + var sliceX = volume.extractSlice('x',Math.floor(volume.RASDimensions[0]/2)); + scene.add( sliceX.mesh ); + + gui.add( sliceX, "index", 0, volume.RASDimensions[0], 1 ).name( "indexX" ).onChange( function () {sliceX.repaint.call(sliceX);} ); + gui.add( sliceY, "index", 0, volume.RASDimensions[1], 1 ).name( "indexY" ).onChange( function () {sliceY.repaint.call(sliceY);} ); + gui.add( sliceZ, "index", 0, volume.RASDimensions[2], 1 ).name( "indexZ" ).onChange( function () {sliceZ.repaint.call(sliceZ);} ); + + gui.add( volume, "lowerThreshold", volume.min, volume.max, 1).name( "Lower Threshold").onChange( function () { + volume.repaintAllSlices(); + }); + gui.add( volume, "upperThreshold", volume.min, volume.max, 1).name( "Upper Threshold").onChange( function () { + volume.repaintAllSlices(); + }); + gui.add( volume, "windowLow", volume.min, volume.max, 1).name( "Window Low").onChange( function () { + volume.repaintAllSlices(); + }); + gui.add( volume, "windowHigh", volume.min, volume.max, 1).name( "Window High").onChange( function () { + volume.repaintAllSlices(); + }); + + } ); + + // renderer + var canvas = document.createElement( 'canvas' ); + var context = canvas.getContext( 'webgl2' ); + renderer = new THREE.WebGLRenderer( { canvas: canvas, context: context } ); + renderer.setPixelRatio( window.devicePixelRatio ); + renderer.setSize( window.innerWidth, window.innerHeight ); + + container = document.createElement( 'div' ); + document.body.appendChild( container ); + container.appendChild( renderer.domElement ); + + controls = new THREE.TrackballControls( camera, renderer.domElement ); + controls.rotateSpeed = 5.0; + controls.zoomSpeed = 5; + controls.panSpeed = 2; + controls.noZoom = false; + controls.noPan = false; + controls.staticMoving = true; + controls.dynamicDampingFactor = 0.3; + + stats = new Stats(); + container.appendChild( stats.dom ); + + var gui = new dat.GUI(); + + setupInset(); + + window.addEventListener( 'resize', onWindowResize, false ); + + } + + function onWindowResize() { + + camera.aspect = window.innerWidth / window.innerHeight; + camera.updateProjectionMatrix(); + + renderer.setSize( window.innerWidth, window.innerHeight ); + + controls.handleResize(); + + } + + function animate() { + + requestAnimationFrame( animate ); + + controls.update(); + + //copy position of the camera into inset + camera2.position.copy( camera.position ); + camera2.position.sub( controls.target ); + camera2.position.setLength( 300 ); + camera2.lookAt( scene2.position ); + + renderer.render( scene, camera ); + renderer2.render( scene2, camera2); + + stats.update(); + + } + + function rotateAroundWorldAxis(object, axis, radians) { + var rotWorldMatrix = new THREE.Matrix4(); + rotWorldMatrix.makeRotationAxis(axis.normalize(), radians); + + object.applyMatrix(rotWorldMatrix); + + } + + function setupInset () { + var insetWidth = 150, + insetHeight = 150; + container2 = document.getElementById('inset'); + container2.width = insetWidth; + container2.height = insetHeight; + + // renderer + renderer2 = new THREE.WebGLRenderer({alpha : true}); + renderer2.setClearColor( 0x000000, 0 ); + renderer2.setSize( insetWidth, insetHeight ); + container2.appendChild( renderer2.domElement ); + + // scene + scene2 = new THREE.Scene(); + + // camera + camera2 = new THREE.PerspectiveCamera( 50, insetWidth / insetHeight, 1, 1000 ); + camera2.up = camera.up; // important! + + // axes + axes2 = new THREE.AxesHelper( 100 ); + scene2.add( axes2 ); + } + + + </script> + + </body> +</html>
true
Other
mrdoob
three.js
39f09176735e00ceba688722c6fc2843a919d5c4.json
Update VRMLLoader to support normals. #14814 Allows the VRMLLoader to import normals that are defined in the file. Also fixes a bug where uvs would be an array filled with `undefined` values if model contained no UV coordinates.
examples/js/loaders/VRMLLoader.js
@@ -218,6 +218,7 @@ THREE.VRMLLoader.prototype = { break; case 'point': + case 'vector': scope.recordingFieldname = fieldName; scope.isRecordingPoints = true; scope.points = []; @@ -303,6 +304,22 @@ THREE.VRMLLoader.prototype = { } + if ( node.nodeType == 'Normal' ) { + + while ( null !== ( parts = float3_pattern.exec( line ) ) ) { + + point = { + x: parseFloat( parts[ 1 ] ), + y: parseFloat( parts[ 2 ] ), + z: parseFloat( parts[ 3 ] ) + }; + + scope.points.push( point ); + + } + + } + if ( node.nodeType == 'TextureCoordinate' ) { while ( null !== ( parts = float2_pattern.exec( line ) ) ) { @@ -793,9 +810,10 @@ THREE.VRMLLoader.prototype = { var geometry = new THREE.BufferGeometry(); var positions = []; + var normals = []; var uvs = []; - var position, uv; + var position, normal, uv; var i, il, j, jl; @@ -820,6 +838,23 @@ THREE.VRMLLoader.prototype = { } + // normals + + if ( child.nodeType === 'Normal' ) { + + if ( child.points ) { + + for ( j = 0, jl = child.points.length; j < jl; j ++ ) { + + normal = child.points[ j ]; + normals.push( normal.x, normal.y, normal.z ); + + } + + } + + } + // positions if ( child.nodeType === 'Coordinate' ) { @@ -862,9 +897,11 @@ THREE.VRMLLoader.prototype = { if ( data.coordIndex ) { var newPositions = []; + var newNormals = []; var newUvs = []; position = new THREE.Vector3(); + normal = new THREE.Vector3(); uv = new THREE.Vector2(); for ( i = 0, il = data.coordIndex.length; i < il; i ++ ) { @@ -886,19 +923,33 @@ THREE.VRMLLoader.prototype = { // create non indexed geometry, necessary for face normal generation position.fromArray( positions, i1 * 3 ); - uv.fromArray( uvs, i1 * 2 ); newPositions.push( position.x, position.y, position.z ); - newUvs.push( uv.x, uv.y ); - position.fromArray( positions, i2 * 3 ); - uv.fromArray( uvs, i2 * 2 ); newPositions.push( position.x, position.y, position.z ); - newUvs.push( uv.x, uv.y ); - position.fromArray( positions, i3 * 3 ); - uv.fromArray( uvs, i3 * 2 ); newPositions.push( position.x, position.y, position.z ); - newUvs.push( uv.x, uv.y ); + + if ( uvs.length > 0 ) { + + uv.fromArray( uvs, i1 * 2 ); + newUvs.push( uv.x, uv.y ); + uv.fromArray( uvs, i2 * 2 ); + newUvs.push( uv.x, uv.y ); + uv.fromArray( uvs, i3 * 2 ); + newUvs.push( uv.x, uv.y ); + + } + + if ( normals.length > 0 ) { + + normal.fromArray( normals, i1 * 3 ); + newNormals.push( normal.x, normal.y, normal.z ); + normal.fromArray( normals, i2 * 3 ); + newNormals.push( normal.x, normal.y, normal.z ); + normal.fromArray( normals, i3 * 3 ); + newNormals.push( normal.x, normal.y, normal.z ); + + } skip ++; @@ -907,6 +958,7 @@ THREE.VRMLLoader.prototype = { } positions = newPositions; + normals = newNormals; uvs = newUvs; } else { @@ -934,7 +986,16 @@ THREE.VRMLLoader.prototype = { } - geometry.computeVertexNormals(); + if (normals.length > 0) { + + geometry.addAttribute( 'normal', new THREE.Float32BufferAttribute( normals, 3 ) ); + + } else { + + geometry.computeVertexNormals(); + + } + geometry.computeBoundingSphere(); // see if it's a define
false
Other
mrdoob
three.js
22a52dc81217260d5d97efdda68bc597eac2029f.json
remove unused variables, correct formatting
examples/webgl_materials_cars.html
@@ -305,10 +305,6 @@ // set materials to the current values of the selection menus function updateMaterials() { - var bodyMatName = bodyMatSelect.options[ bodyMatSelect.selectedIndex ].value; - var rimMatName = rimMatSelect.options[ rimMatSelect.selectedIndex ].value; - var glassMatName = glassMatSelect.options[ glassMatSelect.selectedIndex ].value; - var bodyMat = materialsLib.main[ bodyMatSelect.selectedIndex ]; var rimMat = materialsLib.main[ rimMatSelect.selectedIndex ]; var glassMat = materialsLib.glass[ glassMatSelect.selectedIndex ]; @@ -367,10 +363,10 @@ carModel.getWorldPosition( cameraTarget ); cameraTarget.y = 2.5; - cameraTarget.z += distance; + cameraTarget.z += distance; camera.position.lerp( cameraTarget, delta * damping ); - camera.lookAt( carModel.position ); + camera.lookAt( carModel.position ); }
false
Other
mrdoob
three.js
f169f50b2e23ee6df276bbc47648cc5fe0ab81d0.json
add eof newline
examples/webgl_materials_cars.html
@@ -397,4 +397,4 @@ </script> </body> -</html> \ No newline at end of file +</html>
false
Other
mrdoob
three.js
1f86be32ff4f1634f187637ae273a7313b99014c.json
switch rotation axes
examples/js/Car.js
@@ -3,9 +3,9 @@ * @author Lewy Blue https://github.com/looeee * * The model is expected to follow real world car proportions. You can try unusual car types - * but your results may be unexpected. Scaled models are also not supported + * but your results may be unexpected. Scaled models are also not supported. * - * Defaults below are for a Ferrari F50, taken from https://en.wikipedia.org/wiki/Ferrari_F50 + * Defaults are rough estimates for a real world scale car model * */ @@ -56,23 +56,23 @@ THREE.Car = ( function ( ) { this.enabled = true; this.elemNames = { - flWheel: 'wheelFrontLeft', - frWheel: 'wheelFrontRight', - rlWheel: 'wheelBackLeft', - rrWheel: 'wheelBackRight', - steeringWheel: null, // disabled by default + flWheel: 'wheel_fl', + frWheel: 'wheel_fr', + rlWheel: 'wheel_rl', + rrWheel: 'wheel_rr', + steeringWheel: 'steering_wheel', // set to null to disable }; // km/hr this.maxSpeed = maxSpeed || 180; maxSpeedReverse = - this.maxSpeed * 0.25; // m/s - this.acceleration = acceleration || 12; + this.acceleration = acceleration || 10; accelerationReverse = this.acceleration * 0.5; // metres - this.turningRadius = turningRadius || 24; + this.turningRadius = turningRadius || 6; // m/s deceleration = this.acceleration * 2; @@ -81,16 +81,15 @@ THREE.Car = ( function ( ) { this.brakePower = brakePower || 10; // exposed so that a user can use this for various effect, e.g blur - // km / hr this.speed = 0; // keys used to control car - by default the arrow keys and space to brake controlKeys = keys || controlKeys; - // local axes of rotation + // local axes of rotation - these are likely to vary between models this.wheelRotationAxis = 'x'; this.wheelTurnAxis = 'z'; - this.steeringWheelTurnAxis = 'z'; + this.steeringWheelTurnAxis = 'y'; document.addEventListener( 'keydown', this.onKeyDown, false ); document.addEventListener( 'keyup', this.onKeyUp, false );
false
Other
mrdoob
three.js
3c9c090fedcbf6761df7d940cfd2ba3b0ecd4990.json
fix bug 2
src/math/Box3.js
@@ -384,7 +384,7 @@ Object.assign( Box3.prototype, { } - return ( min <= -plane.constant && max >= -plane.constant ); + return ( min <= - plane.constant && max >= - plane.constant ); },
false
Other
mrdoob
three.js
9b7f7851d9be264cad25b4982d768b186e0f8fa7.json
Update Useful-links.html to sync with en doc.
docs/manual/zh/introduction/Useful-links.html
@@ -109,7 +109,7 @@ <h2>示例</h2> <h2>工具</h2> <ul> <li> - [link:http://www.physgl.org/ physgl.org] - javascript front-end with wrappers to three.js, to bring WebGL + [link:http://www.physgl.org/ physgl.org] - JavaScript front-end with wrappers to three.js, to bring WebGL graphics to students learning physics and math. </li> <li> @@ -127,7 +127,7 @@ <h2>工具</h2> <h2>WebGL参考</h2> <ul> <li> - [link:https://www.khronos.org/files/webgl/webgl-reference-card-1_0.pdf] - Reference of all WebGL and GLSL keywords, terminology, syntex and definations. + [link:https://www.khronos.org/files/webgl/webgl-reference-card-1_0.pdf] - Reference of all WebGL and GLSL keywords, terminology, syntax and definitions. </li> </ul>
false
Other
mrdoob
three.js
096bcd9c43cf0fd1ca1c4cda27cd4449d774e8f2.json
translate spherical page.
docs/api/zh/math/Spherical.html
@@ -8,26 +8,26 @@ <link type="text/css" rel="stylesheet" href="page.css" /> </head> <body> - <h1>[name]</h1> + <h1>球坐标([name])</h1> - <p class="desc">A point's [link:https://en.wikipedia.org/wiki/Spherical_coordinate_system spherical coordinates].</p> + <p class="desc">一个点的[link:https://en.wikipedia.org/wiki/Spherical_coordinate_system spherical coordinates](球坐标)。</p> - <h2>Constructor</h2> + <h2>构造函数</h2> <h3>[name]( [param:Float radius], [param:Float phi], [param:Float theta] )</h3> <p> - [page:Float radius] - the radius, or the [link:https://en.wikipedia.org/wiki/Euclidean_distance Euclidean distance] - (straight-line distance) from the point to the origin. Default is *1.0*.<br /> + [page:Float radius] - 半径值,或者说从该点到原点的 + [link:https://en.wikipedia.org/wiki/Euclidean_distance Euclidean distance](欧几里得距离,即直线距离)。默认值为*1.0*。<br /> [page:Float phi] - polar angle from the y (up) axis. Default is *0*.<br /> [page:Float theta] - equator angle around the y (up) axis. Default is *0*.<br /><br /> The poles (phi) are at the positive and negative y axis. The equator (theta) starts at positive z. </p> - <h2>Properties</h2> + <h2>属性</h2> <h3>[property:Float radius]</h3> @@ -36,42 +36,39 @@ <h3>[property:Float phi]</h3> <h3>[property:Float theta]</h3> - <h2>Methods</h2> + <h2>方法</h2> <h3>[method:Spherical clone]()</h3> <p> - Returns a new plane with the same [page:.radius radius], [page:.phi phi] - and [page:.theta theta] properties as this one. + 返回一个新的球坐标,新的球坐标与该球坐标具有相同的 + [page:.radius radius]、[page:.phi phi]和[page:.theta theta]。 </p> <h3>[method:Spherical copy]( [param:Spherical s] )</h3> <p> - Copies the values of the passed Spherical's [page:.radius radius], [page:.phi phi] - and [page:.theta theta] properties to this spherical. + 复制所传入的球坐标的[page:.radius radius]、 + [page:.phi phi] 和[page:.theta theta]属性到该球坐标中。 </p> <h3>[method:Spherical makeSafe]()</h3> <p> - Restricts the polar angle [page:.phi phi] to be between 0.000001 and pi - 0.000001. + 将极角 [page:.phi phi] 的值限制在0.000001 和 pi - 0.000001 之间。 </p> <h3>[method:Spherical set]( [param:Float radius], [param:Float phi], [param:Float theta] )</h3> - <p>Sets values of this spherical's [page:.radius radius], [page:.phi phi] - and [page:.theta theta] properties.</p> + <p>设置球坐标中[page:.radius radius]、[page:.phi phi] 和 [page:.theta theta] 属性的值。</p> <h3>[method:Spherical setFromVector3]( [param:Vector3 vec3] )</h3> <p> - Sets values of this spherical's [page:.radius radius], [page:.phi phi] - and [page:.theta theta] properties from the [page:Vector3 Vector3]. + 从[page:Vector3 Vector3]中设置球坐标的[page:.radius radius]、[page:.phi phi]和[page:.theta theta]值。 </p> <h3>[method:Spherical setFromCartesianCoords]( [param:Float x], [param:Float y], [param:Float z] )</h3> <p> - Sets values of this spherical's [page:.radius radius], [page:.phi phi] - and [page:.theta theta] properties from Cartesian coordinates. + 从笛卡尔坐标系中设置球坐标的[page:.radius radius]、[page:.phi phi]和[page:.theta theta]值。 </p> - <h2>Source</h2> + <h2>源代码</h2> [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] </body>
false
Other
mrdoob
three.js
46ef152cf371b14da18a215ad378cc54659b8e1f.json
Pull request comments
examples/js/loaders/GLTFLoader.js
@@ -1528,7 +1528,7 @@ THREE.GLTFLoader = ( function () { } - function createGeometryKey( primitiveDef ) { + function createPrimitiveKey( primitiveDef ) { var dracoExtension = primitiveDef.extensions && primitiveDef.extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ]; var geometryKey; @@ -1585,7 +1585,7 @@ THREE.GLTFLoader = ( function () { for ( var i = 0, il = a.length; i < il; i ++ ) { - arrayKey += i + createGeometryKey( a[ i ] ); + arrayKey += i + createPrimitiveKey( a[ i ] ); } @@ -1595,7 +1595,15 @@ THREE.GLTFLoader = ( function () { function createMultiPassGeometryKey( geometry, primitives ) { - return createGeometryKey( geometry ) + createArrayKeyGLTFPrimitive( primitives ); + var key = createPrimitiveKey( geometry ); + + for ( var i = 0, il = primitives.length; i < il; i ++ ) { + + key += i + primitives[ i ].uuid; + + } + + return key; } @@ -2520,7 +2528,7 @@ THREE.GLTFLoader = ( function () { for ( var i = 0, il = primitives.length; i < il; i ++ ) { var primitive = primitives[ i ]; - var cacheKey = createGeometryKey( primitive ); + var cacheKey = createPrimitiveKey( primitive ); // See if we've already created this geometry var cached = cache[ cacheKey ];
false
Other
mrdoob
three.js
9be5d8affd61d600ce5b1790b23a9caf28d5fc40.json
Prevent cursor up and cursor down from scrolling
examples/js/controls/OrbitControls.js
@@ -539,6 +539,10 @@ THREE.OrbitControls = function ( object, domElement ) { //console.log( 'handleKeyDown' ); + // prevent the browser from scrolling on cursor up/down + + event.preventDefault(); + switch ( event.keyCode ) { case scope.keys.UP:
false
Other
mrdoob
three.js
4ef4b6d878060fab2705d3da8e18c3d3bae215d6.json
Add stencil parameter and constants
src/constants.js
@@ -142,3 +142,23 @@ export var BasicDepthPacking = 3200; export var RGBADepthPacking = 3201; export var TangentSpaceNormalMap = 0; export var ObjectSpaceNormalMap = 1; + +// StencilOp +export var ZERO = 0; +export var KEEP = 7680; +export var REPLACE = 7681; +export var INCR = 7682; +export var DECR = 7683; +export var INCR_WRAP = 34055; +export var DECR_WRAP = 34056; +export var INVERT = 5386; + +// StencilFunc +export var NEVER = 512; +export var LESS = 513; +export var EQUAL = 514; +export var LEQUAL = 515; +export var GREATER = 516; +export var NOTEQUAL = 517; +export var GEQUAL = 518; +export var ALWAYS = 519;
true
Other
mrdoob
three.js
4ef4b6d878060fab2705d3da8e18c3d3bae215d6.json
Add stencil parameter and constants
src/materials/Material.js
@@ -40,6 +40,8 @@ function Material() { this.depthTest = true; this.depthWrite = true; + this.stencil = null; + this.clippingPlanes = null; this.clipIntersection = false; this.clipShadows = false;
true
Other
mrdoob
three.js
4ef4b6d878060fab2705d3da8e18c3d3bae215d6.json
Add stencil parameter and constants
src/renderers/webgl/WebGLState.js
@@ -677,6 +677,16 @@ function WebGLState( gl, extensions, utils, capabilities ) { depthBuffer.setMask( material.depthWrite ); colorBuffer.setMask( material.colorWrite ); + var stencil = material.stencil; + var useStencil = stencil !== null; + stencilBuffer.setTest( useStencil ); + if ( useStencil ) { + + stencilBuffer.setFunc( stencil.func, stencil.ref, stencil.mask ); + stencilBuffer.setOp( stencil.fail, stencil.zfail, stencil.zpass ); + + } + setPolygonOffset( material.polygonOffset, material.polygonOffsetFactor, material.polygonOffsetUnits ); }
true
Other
mrdoob
three.js
c57b480e7b7f93c8808bfcd0bd9735e0cb774e26.json
Add newline at end of file
utils/modularize.js
@@ -83,7 +83,7 @@ function convert( path, ignoreList ) { var keys = Object.keys( dependencies ).sort().map( value => '\n\t' + value ).toString(); var imports = `import {${keys}\n} from "../../../build/three.module.js";`; - var exports = `export { ${className} };`; + var exports = `export { ${className} };\n`; var output = contents.replace( '_IMPORTS_', imports ) + '\n' + exports;
false
Other
mrdoob
three.js
533ff0ec9caa98639de8bb3f2c9b9a639ff428b8.json
Skip non-POT texture fallback on WebGL2
src/renderers/webgl/WebGLTextures.js
@@ -83,9 +83,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, } - function textureNeedsGenerateMipmaps( texture, isPowerOfTwo ) { + function textureNeedsGenerateMipmaps( texture, supportsMips ) { - return texture.generateMipmaps && isPowerOfTwo && + return texture.generateMipmaps && supportsMips && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter; } @@ -355,12 +355,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, } var image = cubeImage[ 0 ], - isPowerOfTwoImage = isPowerOfTwo( image ), + supportsMips = isPowerOfTwo( image ) || capabilities.isWebGL2, glFormat = utils.convert( texture.format ), glType = utils.convert( texture.type ), glInternalFormat = getInternalFormat( glFormat, glType ); - setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture, isPowerOfTwoImage ); + setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture, supportsMips ); for ( var i = 0; i < 6; i ++ ) { @@ -418,7 +418,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, } - if ( textureNeedsGenerateMipmaps( texture, isPowerOfTwoImage ) ) { + if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) { // We assume images for cube map have the same size. generateMipmap( _gl.TEXTURE_CUBE_MAP, texture, image.width, image.height ); @@ -447,11 +447,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, } - function setTextureParameters( textureType, texture, isPowerOfTwoImage ) { + function setTextureParameters( textureType, texture, supportsMips ) { var extension; - if ( isPowerOfTwoImage ) { + if ( supportsMips ) { _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, utils.convert( texture.wrapS ) ); _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, utils.convert( texture.wrapT ) ); @@ -539,12 +539,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, var needsPowerOfTwo = textureNeedsPowerOfTwo( texture ) && isPowerOfTwo( texture.image ) === false; var image = resizeImage( texture.image, needsPowerOfTwo, false, capabilities.maxTextureSize ); - var isPowerOfTwoImage = isPowerOfTwo( image ), + var supportsMips = isPowerOfTwo( image ) || capabilities.isWebGL2, glFormat = utils.convert( texture.format ), glType = utils.convert( texture.type ), glInternalFormat = getInternalFormat( glFormat, glType ); - setTextureParameters( textureType, texture, isPowerOfTwoImage ); + setTextureParameters( textureType, texture, supportsMips ); var mipmap, mipmaps = texture.mipmaps; @@ -610,7 +610,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, // if there are no manual mipmaps // set 0 level mipmap and then use GL to generate other mipmap levels - if ( mipmaps.length > 0 && isPowerOfTwoImage ) { + if ( mipmaps.length > 0 && supportsMips ) { for ( var i = 0, il = mipmaps.length; i < il; i ++ ) { @@ -670,7 +670,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, // if there are no manual mipmaps // set 0 level mipmap and then use GL to generate other mipmap levels - if ( mipmaps.length > 0 && isPowerOfTwoImage ) { + if ( mipmaps.length > 0 && supportsMips ) { for ( var i = 0, il = mipmaps.length; i < il; i ++ ) { @@ -691,7 +691,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, } - if ( textureNeedsGenerateMipmaps( texture, isPowerOfTwoImage ) ) { + if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) { generateMipmap( _gl.TEXTURE_2D, texture, image.width, image.height ); @@ -880,7 +880,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, var isCube = ( renderTarget.isWebGLRenderTargetCube === true ); var isMultisample = ( renderTarget.isWebGLMultisampleRenderTarget === true ); - var isTargetPowerOfTwo = isPowerOfTwo( renderTarget ); + var supportsMips = isPowerOfTwo( renderTarget ) || capabilities.isWebGL2; // Setup framebuffer @@ -941,15 +941,15 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, if ( isCube ) { state.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture ); - setTextureParameters( _gl.TEXTURE_CUBE_MAP, renderTarget.texture, isTargetPowerOfTwo ); + setTextureParameters( _gl.TEXTURE_CUBE_MAP, renderTarget.texture, supportsMips ); for ( var i = 0; i < 6; i ++ ) { setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer[ i ], renderTarget, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i ); } - if ( textureNeedsGenerateMipmaps( renderTarget.texture, isTargetPowerOfTwo ) ) { + if ( textureNeedsGenerateMipmaps( renderTarget.texture, supportsMips ) ) { generateMipmap( _gl.TEXTURE_CUBE_MAP, renderTarget.texture, renderTarget.width, renderTarget.height ); @@ -960,10 +960,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, } else { state.bindTexture( _gl.TEXTURE_2D, textureProperties.__webglTexture ); - setTextureParameters( _gl.TEXTURE_2D, renderTarget.texture, isTargetPowerOfTwo ); + setTextureParameters( _gl.TEXTURE_2D, renderTarget.texture, supportsMips ); setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D ); - if ( textureNeedsGenerateMipmaps( renderTarget.texture, isTargetPowerOfTwo ) ) { + if ( textureNeedsGenerateMipmaps( renderTarget.texture, supportsMips ) ) { generateMipmap( _gl.TEXTURE_2D, renderTarget.texture, renderTarget.width, renderTarget.height ); @@ -986,9 +986,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, function updateRenderTargetMipmap( renderTarget ) { var texture = renderTarget.texture; - var isTargetPowerOfTwo = isPowerOfTwo( renderTarget ); + var supportsMips = isPowerOfTwo( renderTarget ) || capabilities.isWebGL2; - if ( textureNeedsGenerateMipmaps( texture, isTargetPowerOfTwo ) ) { + if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) { var target = renderTarget.isWebGLRenderTargetCube ? _gl.TEXTURE_CUBE_MAP : _gl.TEXTURE_2D; var webglTexture = properties.get( texture ).__webglTexture;
false
Other
mrdoob
three.js
cdf0bba21a8b3a264f21dcea59dbca28b39905a5.json
Remove reference to THREE in modules
examples/jsm/controls/MapControls.js
@@ -1036,7 +1036,7 @@ var MapControls = function ( object, domElement ) { }; MapControls.prototype = Object.create( EventDispatcher.prototype ); -MapControls.prototype.constructor = THREE.MapControls; +MapControls.prototype.constructor = MapControls; Object.defineProperties( MapControls.prototype, {
true
Other
mrdoob
three.js
cdf0bba21a8b3a264f21dcea59dbca28b39905a5.json
Remove reference to THREE in modules
examples/jsm/controls/OrbitControls.js
@@ -932,7 +932,7 @@ var OrbitControls = function ( object, domElement ) { }; OrbitControls.prototype = Object.create( EventDispatcher.prototype ); -OrbitControls.prototype.constructor = THREE.OrbitControls; +OrbitControls.prototype.constructor = OrbitControls; Object.defineProperties( OrbitControls.prototype, {
true
Other
mrdoob
three.js
cdf0bba21a8b3a264f21dcea59dbca28b39905a5.json
Remove reference to THREE in modules
examples/jsm/controls/TrackballControls.js
@@ -623,6 +623,6 @@ var TrackballControls = function ( object, domElement ) { }; TrackballControls.prototype = Object.create( EventDispatcher.prototype ); -TrackballControls.prototype.constructor = THREE.TrackballControls; +TrackballControls.prototype.constructor = TrackballControls; export { TrackballControls };
true
Other
mrdoob
three.js
ae9bc8ced64c6343ebb6f6344049ece81e115d68.json
add comments to example
examples/webgl_physics_volume.html
@@ -191,11 +191,15 @@ function processGeometry( bufGeometry ) { + // Ony consider the position values when merging the vertices var posOnlyBufGeometry = new THREE.BufferGeometry(); posOnlyBufGeometry.addAttribute( 'position', bufGeometry.getAttribute( 'position' ) ); posOnlyBufGeometry.setIndex( bufGeometry.getIndex() ); + // Merge the vertices so the triangle soup is converted to indexed triangles var indexedBufferGeom = THREE.BufferGeometryUtils.mergeVertices( posOnlyBufGeometry ); + + // Create index arrays mapping the indexed vertices to bufGeometry vertices mapIndices( bufGeometry, indexedBufferGeom ); }
false
Other
mrdoob
three.js
bd989c1df792b6bd565f7e7038606d5b5d7315a9.json
Use mergeVertices in physics volume example
examples/webgl_physics_volume.html
@@ -31,6 +31,7 @@ <script src="../build/three.js"></script> <script src="js/libs/ammo.js"></script> <script src="js/controls/OrbitControls.js"></script> + <script src="js/utils/BufferGeometryUtils.js"></script> <script src="js/WebGL.js"></script> <script src="js/libs/stats.min.js"></script> @@ -190,60 +191,15 @@ function processGeometry( bufGeometry ) { - // Obtain a Geometry - var geometry = new THREE.Geometry().fromBufferGeometry( bufGeometry ); + var posOnlyBufGeometry = new THREE.BufferGeometry(); + posOnlyBufGeometry.addAttribute( 'position', bufGeometry.getAttribute( 'position' ) ); + posOnlyBufGeometry.setIndex( bufGeometry.getIndex() ); - // Merge the vertices so the triangle soup is converted to indexed triangles - geometry.mergeVertices(); - - // Convert again to BufferGeometry, indexed - var indexedBufferGeom = createIndexedBufferGeometryFromGeometry( geometry ); - - // Create index arrays mapping the indexed vertices to bufGeometry vertices + var indexedBufferGeom = THREE.BufferGeometryUtils.mergeVertices( posOnlyBufGeometry ); mapIndices( bufGeometry, indexedBufferGeom ); } - function createIndexedBufferGeometryFromGeometry( geometry ) { - - var numVertices = geometry.vertices.length; - var numFaces = geometry.faces.length; - - var bufferGeom = new THREE.BufferGeometry(); - var vertices = new Float32Array( numVertices * 3 ); - var indices = new ( numFaces * 3 > 65535 ? Uint32Array : Uint16Array )( numFaces * 3 ); - - for ( var i = 0; i < numVertices; i ++ ) { - - var p = geometry.vertices[ i ]; - - var i3 = i * 3; - - vertices[ i3 ] = p.x; - vertices[ i3 + 1 ] = p.y; - vertices[ i3 + 2 ] = p.z; - - } - - for ( var i = 0; i < numFaces; i ++ ) { - - var f = geometry.faces[ i ]; - - var i3 = i * 3; - - indices[ i3 ] = f.a; - indices[ i3 + 1 ] = f.b; - indices[ i3 + 2 ] = f.c; - - } - - bufferGeom.setIndex( new THREE.BufferAttribute( indices, 1 ) ); - bufferGeom.addAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) ); - - return bufferGeom; - - } - function isEqual( x1, y1, z1, x2, y2, z2 ) { var delta = 0.000001;
false