From 21a9169b86dcaf316bef22ef26c7a214c8845195 Mon Sep 17 00:00:00 2001 From: Mugen87 Date: Fri, 24 Aug 2018 23:18:30 +0200 Subject: [PATCH] Examples: Removemore lgtm.com warnings --- examples/canvas_geometry_terrain.html | 3 +- examples/canvas_interactive_voxelpainter.html | 2 - examples/canvas_lines_sphere.html | 6 +- examples/js/postprocessing/SSAOPass.js | 81 +++++++++++++------ examples/webgl_buffergeometry_instancing.html | 1 - examples/webgl_geometries.html | 2 +- examples/webgl_geometry_minecraft_ao.html | 1 - examples/webgl_lights_pointlights2.html | 2 +- examples/webgl_lines_sphere.html | 2 +- examples/webgl_materials_curvature.html | 2 +- .../webgl_materials_texture_rotation.html | 2 - examples/webgl_octree.html | 19 +---- examples/webgl_points_sprites.html | 2 +- examples/webgl_postprocessing_nodes.html | 3 +- examples/webgl_shaders_tonemapping.html | 6 +- examples/webgl_shading_physical.html | 12 --- examples/webgl_terrain_dynamic.html | 2 - 17 files changed, 69 insertions(+), 79 deletions(-) diff --git a/examples/canvas_geometry_terrain.html b/examples/canvas_geometry_terrain.html index 430320db2c..63a12bef58 100644 --- a/examples/canvas_geometry_terrain.html +++ b/examples/canvas_geometry_terrain.html @@ -145,8 +145,7 @@ function generateTexture( data, width, height ) { - var canvas, context, image, imageData, - level, diff, vector3, sun, shade; + var canvas, context, image, imageData, vector3, sun, shade; vector3 = new THREE.Vector3( 0, 0, 0 ); diff --git a/examples/canvas_interactive_voxelpainter.html b/examples/canvas_interactive_voxelpainter.html index 480d5fbb4b..df862f6dac 100644 --- a/examples/canvas_interactive_voxelpainter.html +++ b/examples/canvas_interactive_voxelpainter.html @@ -74,8 +74,6 @@ objects.push( plane ); - var material = new THREE.MeshBasicMaterial( { color: 0xff0000, wireframe: true } ); - // Lights var ambientLight = new THREE.AmbientLight( 0x606060 ); diff --git a/examples/canvas_lines_sphere.html b/examples/canvas_lines_sphere.html index 865ff0450b..45ffe34ee6 100644 --- a/examples/canvas_lines_sphere.html +++ b/examples/canvas_lines_sphere.html @@ -33,10 +33,6 @@ windowHalfX = window.innerWidth / 2, windowHalfY = window.innerHeight / 2, - SEPARATION = 200, - AMOUNTX = 10, - AMOUNTY = 10, - camera, scene, renderer; init(); @@ -44,7 +40,7 @@ function init() { - var container, separation = 100, amountX = 50, amountY = 50, particles, particle; + var container, particle; container = document.createElement( 'div' ); document.body.appendChild( container ); diff --git a/examples/js/postprocessing/SSAOPass.js b/examples/js/postprocessing/SSAOPass.js index f0daefb582..e815f3f84a 100644 --- a/examples/js/postprocessing/SSAOPass.js +++ b/examples/js/postprocessing/SSAOPass.js @@ -12,7 +12,7 @@ * - Ambient occlusion clamp (numeric value). * - lumInfluence * - Pixel luminosity influence in AO calculation (numeric value). - * + * * To output to screen set renderToScreens true * * @author alteredq / http://alteredqualia.com/ @@ -21,7 +21,7 @@ */ THREE.SSAOPass = function ( scene, camera, width, height ) { - if ( THREE.SSAOShader === undefined) { + if ( THREE.SSAOShader === undefined ) { console.warn( 'THREE.SSAOPass depends on THREE.SSAOShader' ); return new THREE.ShaderPass(); @@ -46,7 +46,7 @@ THREE.SSAOPass = function ( scene, camera, width, height ) { //Depth render target this.depthRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter } ); //this.depthRenderTarget.texture.name = 'SSAOShader.rt'; - + //Shader uniforms this.uniforms[ 'tDepth' ].value = this.depthRenderTarget.texture; this.uniforms[ 'size' ].value.set( this.width, this.height ); @@ -59,37 +59,70 @@ THREE.SSAOPass = function ( scene, camera, width, height ) { this.uniforms[ 'lumInfluence' ].value = 0.7; //Setters and getters for uniforms - var self = this; - Object.defineProperties(this, { + + Object.defineProperties( this, { radius: { - get: function() { return this.uniforms[ 'radius' ].value; }, - set: function( value ) { this.uniforms[ 'radius' ].value = value; } + get: function () { + + return this.uniforms[ 'radius' ].value; + + }, + set: function ( value ) { + + this.uniforms[ 'radius' ].value = value; + + } }, onlyAO: { - get: function() { return this.uniforms[ 'onlyAO' ].value; }, - set: function( value ) { this.uniforms[ 'onlyAO' ].value = value; } + get: function () { + + return this.uniforms[ 'onlyAO' ].value; + + }, + set: function ( value ) { + + this.uniforms[ 'onlyAO' ].value = value; + + } }, aoClamp: { - get: function() { return this.uniforms[ 'aoClamp' ].value; }, - set: function( value ) { this.uniforms[ 'aoClamp' ].value = value; } + get: function () { + + return this.uniforms[ 'aoClamp' ].value; + + }, + set: function ( value ) { + + this.uniforms[ 'aoClamp' ].value = value; + + } }, lumInfluence: { - get: function() { return this.uniforms[ 'lumInfluence' ].value; }, - set: function( value ) { this.uniforms[ 'lumInfluence' ].value = value; } + get: function () { + + return this.uniforms[ 'lumInfluence' ].value; + + }, + set: function ( value ) { + + this.uniforms[ 'lumInfluence' ].value = value; + + } }, - }); -} + } ); + +}; THREE.SSAOPass.prototype = Object.create( THREE.ShaderPass.prototype ); /** * Render using this pass. - * + * * @method render * @param {WebGLRenderer} renderer * @param {WebGLRenderTarget} writeBuffer Buffer to write output. @@ -97,13 +130,13 @@ THREE.SSAOPass.prototype = Object.create( THREE.ShaderPass.prototype ); * @param {Number} delta Delta time in milliseconds. * @param {Boolean} maskActive Not used in this pass. */ -THREE.SSAOPass.prototype.render = function( renderer, writeBuffer, readBuffer, delta, maskActive ) { +THREE.SSAOPass.prototype.render = function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { //Render depth into depthRenderTarget this.scene2.overrideMaterial = this.depthMaterial; - + renderer.render( this.scene2, this.camera2, this.depthRenderTarget, true ); - + this.scene2.overrideMaterial = null; @@ -118,8 +151,8 @@ THREE.SSAOPass.prototype.render = function( renderer, writeBuffer, readBuffer, d * @method setScene * @param {Scene} scene */ -THREE.SSAOPass.prototype.setScene = function(scene) { - +THREE.SSAOPass.prototype.setScene = function ( scene ) { + this.scene2 = scene; }; @@ -130,7 +163,7 @@ THREE.SSAOPass.prototype.setScene = function(scene) { * @method setCamera * @param {Camera} camera */ -THREE.SSAOPass.prototype.setCamera = function( camera ) { +THREE.SSAOPass.prototype.setCamera = function ( camera ) { this.camera2 = camera; @@ -141,12 +174,12 @@ THREE.SSAOPass.prototype.setCamera = function( camera ) { /** * Set resolution of this render pass. - * + * * @method setSize * @param {Number} width * @param {Number} height */ -THREE.SSAOPass.prototype.setSize = function( width, height ) { +THREE.SSAOPass.prototype.setSize = function ( width, height ) { this.width = width; this.height = height; diff --git a/examples/webgl_buffergeometry_instancing.html b/examples/webgl_buffergeometry_instancing.html index 20644ea139..fec281d47a 100644 --- a/examples/webgl_buffergeometry_instancing.html +++ b/examples/webgl_buffergeometry_instancing.html @@ -129,7 +129,6 @@ var vector = new THREE.Vector4(); - var triangles = 1; var instances = 50000; var positions = []; diff --git a/examples/webgl_geometries.html b/examples/webgl_geometries.html index e995b96944..e0d3a6f7ee 100644 --- a/examples/webgl_geometries.html +++ b/examples/webgl_geometries.html @@ -53,7 +53,7 @@ scene = new THREE.Scene(); - var light, object; + var object; var ambientLight = new THREE.AmbientLight( 0xcccccc, 0.4 ); scene.add( ambientLight ); diff --git a/examples/webgl_geometry_minecraft_ao.html b/examples/webgl_geometry_minecraft_ao.html index 98d925db19..bcdb5c32ee 100644 --- a/examples/webgl_geometry_minecraft_ao.html +++ b/examples/webgl_geometry_minecraft_ao.html @@ -160,7 +160,6 @@ // var geometry = new THREE.Geometry(); - var dummy = new THREE.Mesh(); for ( var z = 0; z < worldDepth; z ++ ) { diff --git a/examples/webgl_lights_pointlights2.html b/examples/webgl_lights_pointlights2.html index 153bc1537e..27cbd9b45b 100644 --- a/examples/webgl_lights_pointlights2.html +++ b/examples/webgl_lights_pointlights2.html @@ -217,7 +217,7 @@ function render() { var time = Date.now() * 0.00025; - var z = 20, d = 150; + var d = 150; light1.position.x = Math.sin( time * 0.7 ) * d; light1.position.z = Math.cos( time * 0.3 ) * d; diff --git a/examples/webgl_lines_sphere.html b/examples/webgl_lines_sphere.html index 10ed52194f..6df549e99f 100644 --- a/examples/webgl_lines_sphere.html +++ b/examples/webgl_lines_sphere.html @@ -74,7 +74,7 @@ scene = new THREE.Scene(); - var i, line, vertex1, vertex2, material, p, + var i, line, material, p, parameters = [ [ 0.25, 0xff7700, 1, 2 ], [ 0.5, 0xff9900, 1, 1 ], [ 0.75, 0xffaa00, 0.75, 1 ], [ 1, 0xffaa00, 0.5, 1 ], [ 1.25, 0x000833, 0.8, 1 ], [ 3.0, 0xaaaaaa, 0.75, 2 ], [ 3.5, 0xffffff, 0.5, 1 ], [ 4.5, 0xffffff, 0.25, 1 ], [ 5.5, 0xffffff, 0.125, 1 ] ]; diff --git a/examples/webgl_materials_curvature.html b/examples/webgl_materials_curvature.html index 5d3302cd1a..84399da263 100644 --- a/examples/webgl_materials_curvature.html +++ b/examples/webgl_materials_curvature.html @@ -338,7 +338,7 @@ topologyFolder.add( params, 'filterConvex' ); topologyFolder.add( params, 'filterConcave' ); topologyFolder.add( params, 'filterBoth' ); - topologyFolder.open() + topologyFolder.open(); onWindowResize(); diff --git a/examples/webgl_materials_texture_rotation.html b/examples/webgl_materials_texture_rotation.html index 6da2dae850..40da3a84e1 100644 --- a/examples/webgl_materials_texture_rotation.html +++ b/examples/webgl_materials_texture_rotation.html @@ -154,8 +154,6 @@ function initGui() { - var drop; - gui = new dat.GUI(); gui.add( API, 'offsetX', 0.0, 1.0 ).name( 'offset.x' ).onChange( updateUvTransform ); diff --git a/examples/webgl_octree.html b/examples/webgl_octree.html index 2e0db3783e..78c45ade2b 100644 --- a/examples/webgl_octree.html +++ b/examples/webgl_octree.html @@ -216,10 +216,6 @@ Math.random() * radiusMax - radiusMaxHalf ); - // record start time - - var timeStart = Date.now(); - // search octree from search mesh position with search radius // optional third parameter: boolean, if should sort results by object when using faces in octree // optional fourth parameter: vector3, direction of search when using ray (assumes radius is distance/far of ray) @@ -228,11 +224,7 @@ direction.set( Math.random() * 2 - 1, Math.random() * 2 - 1, Math.random() * 2 - 1 ).normalize(); rayCaster.set( origin, direction ); meshesSearch = octree.search( rayCaster.ray.origin, radiusSearch, true, rayCaster.ray.direction ); - var intersections = rayCaster.intersectOctreeObjects( meshesSearch ); - - // record end time - - var timeEnd = Date.now(); + rayCaster.intersectOctreeObjects( meshesSearch ); // set color of all meshes found in search @@ -242,15 +234,6 @@ } - /* - - // results to console - - console.log( 'OCTREE: ', octree ); - console.log( '... searched ', meshes.length, ' and found ', meshesSearch.length, ' with intersections ', intersections.length, ' and took ', ( timeEnd - timeStart ), ' ms ' ); - - */ - } function render() { diff --git a/examples/webgl_points_sprites.html b/examples/webgl_points_sprites.html index d37329e77e..60151a92c6 100644 --- a/examples/webgl_points_sprites.html +++ b/examples/webgl_points_sprites.html @@ -132,7 +132,7 @@ var params = { texture: true - } + }; gui.add( params, 'texture' ).onChange( function( value ) { diff --git a/examples/webgl_postprocessing_nodes.html b/examples/webgl_postprocessing_nodes.html index 94e1a9c2bd..07bea6c3ca 100644 --- a/examples/webgl_postprocessing_nodes.html +++ b/examples/webgl_postprocessing_nodes.html @@ -65,7 +65,7 @@ gui = new dat.GUI(); - var example = gui.add( param, 'example', { + gui.add( param, 'example', { 'basic / color-adjustment': 'color-adjustment', 'basic / blends': 'blends', 'basic / fade': 'fade', @@ -312,7 +312,6 @@ var normal = new THREE.TextureNode( decalNormal ); var normalXY = new THREE.SwitchNode( normal, 'xy' ); var scale = new THREE.FloatNode( .5 ); - var flip = new THREE.Vector2Node( - 1, 1 ); var normalXYFlip = new THREE.Math1Node( normalXY, diff --git a/examples/webgl_shaders_tonemapping.html b/examples/webgl_shaders_tonemapping.html index fc07d2b214..de09af0429 100644 --- a/examples/webgl_shaders_tonemapping.html +++ b/examples/webgl_shaders_tonemapping.html @@ -202,11 +202,11 @@ var textureLoader = new THREE.TextureLoader(); - var earthDiffuse = textureLoader.load( 'textures/planets/earth_atmos_4096.jpg', function( tex ) { + textureLoader.load( 'textures/planets/earth_atmos_4096.jpg', function( tex ) { earthMat.map = tex; earthMat.needsUpdate = true; } ); - var earthSpecular = textureLoader.load( 'textures/planets/earth_specular_2048.jpg', function( tex ) { + textureLoader.load( 'textures/planets/earth_specular_2048.jpg', function( tex ) { earthMat.specularMap = tex; earthMat.needsUpdate = true; } ); @@ -235,7 +235,7 @@ depthTest: false } ); - var earthClouds = textureLoader.load( 'textures/planets/earth_clouds_2048.png', function( tex ) { + textureLoader.load( 'textures/planets/earth_clouds_2048.png', function( tex ) { earthCloudsMat.map = tex; earthCloudsMat.needsUpdate = true; } ); diff --git a/examples/webgl_shading_physical.html b/examples/webgl_shading_physical.html index 5555f100cf..a3e8e56be9 100644 --- a/examples/webgl_shading_physical.html +++ b/examples/webgl_shading_physical.html @@ -112,18 +112,6 @@ textureLava.wrapS = textureLava.wrapT = THREE.RepeatWrapping; textureLava.format = THREE.RGBFormat; - // - - var path = "textures/cube/SwedishRoyalCastle/"; - var format = '.jpg'; - var urls = [ - path + 'px' + format, path + 'nx' + format, - path + 'py' + format, path + 'ny' + format, - path + 'pz' + format, path + 'nz' + format - ]; - - var reflectionCube = new THREE.CubeTextureLoader().load( urls ); - // GROUND var groundMaterial = new THREE.MeshPhongMaterial( { diff --git a/examples/webgl_terrain_dynamic.html b/examples/webgl_terrain_dynamic.html index 3459205043..2b4e8fab7a 100644 --- a/examples/webgl_terrain_dynamic.html +++ b/examples/webgl_terrain_dynamic.html @@ -466,8 +466,6 @@ if ( terrain.visible ) { - var time = Date.now() * 0.001; - var fLow = 0.1, fHigh = 0.8; lightVal = THREE.Math.clamp( lightVal + 0.5 * delta * lightDir, fLow, fHigh ); -- GitLab