From 3bd5205de9d922fdcacefab63d41fa90050388a6 Mon Sep 17 00:00:00 2001 From: efokschaner Date: Thu, 2 Mar 2017 20:58:59 -0800 Subject: [PATCH] three: noImplicitAny remaining fixes --- three/test/canvas/canvas_geometry_cube.ts | 12 +++---- .../canvas/canvas_interactive_cubes_tween.ts | 12 +++---- .../test/canvas/canvas_lights_pointlights.ts | 2 +- three/test/canvas/canvas_materials.ts | 10 +++--- three/test/canvas/canvas_particles_floor.ts | 6 ++-- three/test/css3d/css3d_periodictable.ts | 21 ++++++++---- three/test/css3d/css3d_sprites.ts | 8 ++--- three/test/math/test_unit_math.ts | 34 ++++++------------- three/test/webgl/webgl_animation_cloth.ts | 4 +-- .../webgl/webgl_animation_skinning_morph.ts | 6 ++-- three/test/webgl/webgl_camera.ts | 4 +-- three/test/webgl/webgl_custom_attributes.ts | 4 +-- three/test/webgl/webgl_interactive_cubes.ts | 2 +- .../webgl_interactive_raycasting_points.ts | 24 +++++-------- three/test/webgl/webgl_lensflares.ts | 6 ++-- three/test/webgl/webgl_lights_hemisphere.ts | 4 +-- three/test/webgl/webgl_lines_colors.ts | 6 ++-- three/test/webgl/webgl_loader_awd.ts | 22 ++++++------ three/test/webgl/webgl_materials.ts | 12 ++++--- three/test/webgl/webgl_morphtargets.ts | 2 +- three/test/webgl/webgl_points_billboards.ts | 6 ++-- three/test/webgl/webgl_sprites.ts | 2 +- three/three-canvasrenderer.d.ts | 4 +-- 23 files changed, 101 insertions(+), 112 deletions(-) diff --git a/three/test/canvas/canvas_geometry_cube.ts b/three/test/canvas/canvas_geometry_cube.ts index 08fac74392..46f26b10c5 100644 --- a/three/test/canvas/canvas_geometry_cube.ts +++ b/three/test/canvas/canvas_geometry_cube.ts @@ -104,7 +104,7 @@ // - function onDocumentMouseDown(event) { + function onDocumentMouseDown(event: MouseEvent) { event.preventDefault(); @@ -117,7 +117,7 @@ } - function onDocumentMouseMove(event) { + function onDocumentMouseMove(event: MouseEvent) { mouseX = event.clientX - windowHalfX; @@ -125,7 +125,7 @@ } - function onDocumentMouseUp(event) { + function onDocumentMouseUp(event: MouseEvent) { document.removeEventListener('mousemove', onDocumentMouseMove, false); document.removeEventListener('mouseup', onDocumentMouseUp, false); @@ -133,7 +133,7 @@ } - function onDocumentMouseOut(event) { + function onDocumentMouseOut(event: MouseEvent) { document.removeEventListener('mousemove', onDocumentMouseMove, false); document.removeEventListener('mouseup', onDocumentMouseUp, false); @@ -141,7 +141,7 @@ } - function onDocumentTouchStart(event) { + function onDocumentTouchStart(event: TouchEvent) { if (event.touches.length === 1) { @@ -154,7 +154,7 @@ } - function onDocumentTouchMove(event) { + function onDocumentTouchMove(event: TouchEvent) { if (event.touches.length === 1) { diff --git a/three/test/canvas/canvas_interactive_cubes_tween.ts b/three/test/canvas/canvas_interactive_cubes_tween.ts index 90ad4fc4b5..6d4cd3fce1 100644 --- a/three/test/canvas/canvas_interactive_cubes_tween.ts +++ b/three/test/canvas/canvas_interactive_cubes_tween.ts @@ -85,17 +85,17 @@ } - function onDocumentTouchStart(event) { + function onDocumentTouchStart(event: TouchEvent) { event.preventDefault(); - - event.clientX = event.touches[0].clientX; - event.clientY = event.touches[0].clientY; - onDocumentMouseDown(event); + let usurpedEvent = event as any; + usurpedEvent.clientX = event.touches[0].clientX; + usurpedEvent.clientY = event.touches[0].clientY; + onDocumentMouseDown(usurpedEvent); } - function onDocumentMouseDown(event) { + function onDocumentMouseDown(event: MouseEvent) { event.preventDefault(); diff --git a/three/test/canvas/canvas_lights_pointlights.ts b/three/test/canvas/canvas_lights_pointlights.ts index 648259b6a0..6c028abcf8 100644 --- a/three/test/canvas/canvas_lights_pointlights.ts +++ b/three/test/canvas/canvas_lights_pointlights.ts @@ -34,7 +34,7 @@ scene.add(light3); var PI2 = Math.PI * 2; - var program = function (context) { + var program = function (context: CanvasRenderingContext2D) { context.beginPath(); context.arc(0, 0, 0.5, 0, PI2, true); diff --git a/three/test/canvas/canvas_materials.ts b/three/test/canvas/canvas_materials.ts index 9b1bff3e45..21ca2b3ee1 100644 --- a/three/test/canvas/canvas_materials.ts +++ b/three/test/canvas/canvas_materials.ts @@ -90,7 +90,7 @@ } var PI2 = Math.PI * 2; - var program = function (context) { + var program = function (context: CanvasRenderingContext2D) { context.beginPath(); context.arc(0, 0, 0.5, 0, PI2, true); @@ -98,9 +98,9 @@ } - // Lights + // Lights - scene.add(new THREE.AmbientLight(Math.random() * 0x202020)); + scene.add(new THREE.AmbientLight(Math.random() * 0x202020)); var directionalLight = new THREE.DirectionalLight(Math.random() * 0xffffff); directionalLight.position.x = Math.random() - 0.5; @@ -154,12 +154,12 @@ } - function loadImage(path) { + function loadImage(path: string) { var image = document.createElement('img'); var texture = new THREE.Texture(image, THREE.UVMapping) - image.onload = function () { texture.needsUpdate = true; }; + image.onload = function () { texture.needsUpdate = true; }; image.src = path; return texture; diff --git a/three/test/canvas/canvas_particles_floor.ts b/three/test/canvas/canvas_particles_floor.ts index 803ba52896..71e121e8d0 100644 --- a/three/test/canvas/canvas_particles_floor.ts +++ b/three/test/canvas/canvas_particles_floor.ts @@ -80,13 +80,13 @@ // - function onDocumentMouseMove(event) { + function onDocumentMouseMove(event: MouseEvent) { mouseX = event.clientX - windowHalfX; mouseY = event.clientY - windowHalfY; } - function onDocumentTouchStart(event) { + function onDocumentTouchStart(event: TouchEvent) { if (event.touches.length > 1) { @@ -97,7 +97,7 @@ } } - function onDocumentTouchMove(event) { + function onDocumentTouchMove(event: TouchEvent) { if (event.touches.length == 1) { diff --git a/three/test/css3d/css3d_periodictable.ts b/three/test/css3d/css3d_periodictable.ts index 4e16fd1208..342455ff48 100644 --- a/three/test/css3d/css3d_periodictable.ts +++ b/three/test/css3d/css3d_periodictable.ts @@ -131,8 +131,15 @@ var camera: THREE.PerspectiveCamera, scene: THREE.Scene, renderer: THREE.CSS3DRenderer; var controls: THREE.TrackballControls; - var objects = []; - var targets = { table: [], sphere: [], helix: [], grid: [] }; + var objects: THREE.CSS3DObject[] = []; + class Targets { + constructor() {} + public table: THREE.Object3D[] = []; + public sphere: THREE.Object3D[] = []; + public helix: THREE.Object3D[] = []; + public grid: THREE.Object3D[] = []; + } + let targets = new Targets(); init(); animate(); @@ -262,28 +269,28 @@ controls.addEventListener('change', render); var button = document.getElementById('table'); - button.addEventListener('click', function (event) { + button.addEventListener('click', function (event: MouseEvent) { transform(targets.table, 2000); }, false); var button = document.getElementById('sphere'); - button.addEventListener('click', function (event) { + button.addEventListener('click', function (event: MouseEvent) { transform(targets.sphere, 2000); }, false); var button = document.getElementById('helix'); - button.addEventListener('click', function (event) { + button.addEventListener('click', function (event: MouseEvent) { transform(targets.helix, 2000); }, false); var button = document.getElementById('grid'); - button.addEventListener('click', function (event) { + button.addEventListener('click', function (event: MouseEvent) { transform(targets.grid, 2000); @@ -297,7 +304,7 @@ } - function transform(targets, duration) { + function transform(targets: THREE.Object3D[], duration: number) { TWEEN.removeAll(); diff --git a/three/test/css3d/css3d_sprites.ts b/three/test/css3d/css3d_sprites.ts index 09c9899e62..49177a9453 100644 --- a/three/test/css3d/css3d_sprites.ts +++ b/three/test/css3d/css3d_sprites.ts @@ -12,8 +12,8 @@ var controls: THREE.TrackballControls; var particlesTotal = 512; - var positions = []; - var objects = []; + var positions: number[] = []; + var objects: THREE.CSS3DSprite[] = []; var current = 0; init(); @@ -28,7 +28,7 @@ scene = new THREE.Scene(); var image = document.createElement('img'); - image.addEventListener('load', function (event) { + image.addEventListener('load', function (event: Event) { for (var i = 0; i < particlesTotal; i++) { @@ -36,7 +36,7 @@ object.position.x = Math.random() * 4000 - 2000, object.position.y = Math.random() * 4000 - 2000, object.position.z = Math.random() * 4000 - 2000 - scene.add(object); + scene.add(object); objects.push(object); diff --git a/three/test/math/test_unit_math.ts b/three/test/math/test_unit_math.ts index 91f656b8e5..2c13817782 100644 --- a/three/test/math/test_unit_math.ts +++ b/three/test/math/test_unit_math.ts @@ -524,7 +524,7 @@ declare function equal(a: T, b: T, desc?: string): void; ok( b.clone().union( c ).equals( c ), "Passed!" ); }); - var compareBox = function ( a, b, threshold? ) { + var compareBox = function ( a: THREE.Box3, b: THREE.Box3, threshold?: number ) { threshold = threshold || 0.0001; return ( a.min.distanceTo( b.min ) < threshold && a.max.distanceTo( b.max ) < threshold ); @@ -768,7 +768,7 @@ declare function equal(a: T, b: T, desc?: string): void; var eulerAxyz = new THREE.Euler( 1, 0, 0, "XYZ" ); var eulerAzyx = new THREE.Euler( 0, 1, 0, "ZYX" ); - var matrixEquals4 = function( a, b ) { + var matrixEquals4 = function( a: THREE.Matrix4, b: THREE.Matrix4 ) { var tolerance = 0.0001; if( a.elements.length != b.elements.length ) { return false; @@ -782,14 +782,14 @@ declare function equal(a: T, b: T, desc?: string): void; return true; }; - var eulerEquals = function (a, b, tolerance?: any) { + var eulerEquals = function (a: THREE.Euler, b: THREE.Euler, tolerance?: number) { tolerance = tolerance || 0.0001; var diff = Math.abs(a.x - b.x) + Math.abs(a.y - b.y) + Math.abs(a.z - b.z); return (diff < tolerance); }; - var quatEquals = function (a, b, tolerance?: any) { + var quatEquals = function (a: THREE.Quaternion, b: THREE.Quaternion, tolerance?: number) { tolerance = tolerance || 0.0001; var diff = Math.abs(a.x - b.x) + Math.abs(a.y - b.y) + Math.abs(a.z - b.z) + Math.abs(a.w - b.w); return (diff < tolerance); @@ -843,7 +843,7 @@ declare function equal(a: T, b: T, desc?: string): void; var v2 = new THREE.Euler().setFromQuaternion( q, v.order ); var q2 = new THREE.Quaternion().setFromEuler( v2 ); - ok(eulerEquals(q, q2), "Passed!"); + ok(quatEquals(q, q2), "Passed!"); } }); @@ -899,7 +899,7 @@ declare function equal(a: T, b: T, desc?: string): void; var unit3 = new THREE.Vector3( 1, 0, 0 ); - var planeEquals = function ( a, b, tolerance ) { + var planeEquals = function ( a: THREE.Plane, b: THREE.Plane, tolerance: number ) { tolerance = tolerance || 0.0001; if( a.normal.distanceTo( b.normal ) > tolerance ) { return false; @@ -1116,7 +1116,7 @@ declare function equal(a: T, b: T, desc?: string): void; // -------------------------------------------- Matrix3 - var matrixEquals3 = function( a, b, tolerance? ) { + var matrixEquals3 = function( a: THREE.Matrix, b: THREE.Matrix, tolerance?: number ) { tolerance = tolerance || 0.0001; if( a.elements.length != b.elements.length ) { return false; @@ -1131,7 +1131,7 @@ declare function equal(a: T, b: T, desc?: string): void; }; - var toMatrix4 = function( m3 ) { + var toMatrix4 = function( m3: THREE.Matrix3 ) { var result = new THREE.Matrix4(); var re = result.elements; var me = m3.elements; @@ -1330,20 +1330,6 @@ declare function equal(a: T, b: T, desc?: string): void; // -------------------------------------------- Matrix4 - var matrixEquals4 = function (a, b) { - var tolerance = 0.0001; - if( a.elements.length != b.elements.length ) { - return false; - } - for( var i = 0, il = a.elements.length; i < il; i ++ ) { - var delta = a.elements[i] - b.elements[i]; - if( delta > tolerance ) { - return false; - } - } - return true; - }; - test( "constructor", function() { var a = new THREE.Matrix4(); ok( a.determinant() == 1, "Passed!" ); @@ -1662,7 +1648,7 @@ declare function equal(a: T, b: T, desc?: string): void; // -------------------------------------------- Plane - var comparePlane = function ( a, b, threshold? ) { + var comparePlane = function ( a: THREE.Plane, b: THREE.Plane, threshold?: number ) { threshold = threshold || 0.0001; return ( a.normal.distanceTo( b.normal ) < threshold && Math.abs( a.constant - b.constant ) < threshold ); @@ -1861,7 +1847,7 @@ declare function equal(a: T, b: T, desc?: string): void; - var qSub = function ( a, b ) { + var qSub = function ( a: THREE.Quaternion, b: THREE.Quaternion ) { var result = new THREE.Quaternion(); result.copy( a ); diff --git a/three/test/webgl/webgl_animation_cloth.ts b/three/test/webgl/webgl_animation_cloth.ts index 52e36bb04b..8ea26f6114 100644 --- a/three/test/webgl/webgl_animation_cloth.ts +++ b/three/test/webgl/webgl_animation_cloth.ts @@ -15,8 +15,8 @@ // ------- /* testing cloth simulation */ - var pinsFormation = []; - var pins = [6]; + var pinsFormation: number[][] = []; + var pins: number[] = [6]; pinsFormation.push(pins); diff --git a/three/test/webgl/webgl_animation_skinning_morph.ts b/three/test/webgl/webgl_animation_skinning_morph.ts index 167a98d4d2..df085e9ac4 100644 --- a/three/test/webgl/webgl_animation_skinning_morph.ts +++ b/three/test/webgl/webgl_animation_skinning_morph.ts @@ -107,7 +107,7 @@ var loader = new THREE.JSONLoader(); loader.load( "models/skinned/knight.js", function ( geometry, materials ) { - createScene( geometry, materials, 0, FLOOR, -300, 60 ) + createScene( geometry, materials as THREE.MeshPhongMaterial[], 0, FLOOR, -300, 60 ) } ); @@ -133,7 +133,7 @@ } - function createScene( geometry, materials, x, y, z, s ) { + function createScene( geometry: THREE.Geometry, materials: THREE.MeshPhongMaterial[], x: number, y: number, z: number, s: number ) { //ensureLoop( geometry.animation ); @@ -203,7 +203,7 @@ } - function onDocumentMouseMove( event ) { + function onDocumentMouseMove( event: MouseEvent ) { mouseX = ( event.clientX - windowHalfX ); mouseY = ( event.clientY - windowHalfY ); diff --git a/three/test/webgl/webgl_camera.ts b/three/test/webgl/webgl_camera.ts index 861b7eebb5..66b60a7826 100644 --- a/three/test/webgl/webgl_camera.ts +++ b/three/test/webgl/webgl_camera.ts @@ -128,7 +128,7 @@ // - function onKeyDown ( event ) { + function onKeyDown ( event: KeyboardEvent ) { switch( event.keyCode ) { @@ -152,7 +152,7 @@ // - function onWindowResize( event ) { + function onWindowResize( event: Event ) { SCREEN_WIDTH = window.innerWidth; SCREEN_HEIGHT = window.innerHeight; diff --git a/three/test/webgl/webgl_custom_attributes.ts b/three/test/webgl/webgl_custom_attributes.ts index 884ae43144..89c25e62cf 100644 --- a/three/test/webgl/webgl_custom_attributes.ts +++ b/three/test/webgl/webgl_custom_attributes.ts @@ -45,8 +45,8 @@ var geometry = new THREE.SphereBufferGeometry( radius, segments, rings ); - displacement = new Float32Array( geometry.attributes["position"].count ); - noise = new Float32Array( geometry.attributes["position"].count ); + displacement = new Float32Array( geometry.getAttribute('position').count ); + noise = new Float32Array( geometry.getAttribute('position').count ); for ( var i = 0; i < displacement.length; i ++ ) { diff --git a/three/test/webgl/webgl_interactive_cubes.ts b/three/test/webgl/webgl_interactive_cubes.ts index 9d4c914aab..74493a5285 100644 --- a/three/test/webgl/webgl_interactive_cubes.ts +++ b/three/test/webgl/webgl_interactive_cubes.ts @@ -87,7 +87,7 @@ } - function onDocumentMouseMove(event) { + function onDocumentMouseMove(event: MouseEvent) { event.preventDefault(); diff --git a/three/test/webgl/webgl_interactive_raycasting_points.ts b/three/test/webgl/webgl_interactive_raycasting_points.ts index 089f8cef77..d7b114b8d2 100644 --- a/three/test/webgl/webgl_interactive_raycasting_points.ts +++ b/three/test/webgl/webgl_interactive_raycasting_points.ts @@ -18,7 +18,7 @@ var raycaster: THREE.Raycaster; var mouse = new THREE.Vector2(); var intersection = null; - var spheres = []; + var spheres: THREE.Mesh[] = []; var spheresIndex = 0; var clock: THREE.Clock; @@ -31,7 +31,7 @@ init(); animate(); - function generatePointCloudGeometry(color, width, length) { + function generatePointCloudGeometry(color: THREE.Color, width: number, length: number) { var geometry = new THREE.BufferGeometry(); var numPoints = width * length; @@ -74,7 +74,7 @@ } - function generatePointcloud(color, width, length) { + function generatePointcloud(color: THREE.Color, width: number, length: number) { var geometry = generatePointCloudGeometry(color, width, length); @@ -85,7 +85,7 @@ } - function generateIndexedPointcloud(color, width, length) { + function generateIndexedPointcloud(color: THREE.Color, width: number, length: number) { var geometry = generatePointCloudGeometry(color, width, length); var numPoints = width * length; @@ -113,7 +113,7 @@ } - function generateIndexedWithOffsetPointcloud(color, width, length) { + function generateIndexedWithOffsetPointcloud(color: THREE.Color, width: number, length: number) { var geometry = generatePointCloudGeometry(color, width, length); var numPoints = width * length; @@ -142,11 +142,11 @@ } - function generateRegularPointcloud(color, width, length) { + function generateRegularPointcloud(color: THREE.Color, width: number, length: number) { var geometry = new THREE.Geometry(); - var colors = []; + var colors: THREE.Color[] = []; var k = 0; @@ -160,15 +160,9 @@ var y = ( Math.cos(u * Math.PI * 8) + Math.sin(v * Math.PI * 8) ) / 20; var z = v - 0.5; var v2 = new THREE.Vector3(x, y, z); - - var intensity = ( y + 0.1 ) * 7; - colors[3 * k] = color.r * intensity; - colors[3 * k + 1] = color.g * intensity; - colors[3 * k + 2] = color.b * intensity; - geometry.vertices.push(v2); + var intensity = ( y + 0.1 ) * 7; colors[k] = ( color.clone().multiplyScalar(intensity) ); - k++; } @@ -260,7 +254,7 @@ } - function onDocumentMouseMove(event) { + function onDocumentMouseMove(event: MouseEvent) { event.preventDefault(); diff --git a/three/test/webgl/webgl_lensflares.ts b/three/test/webgl/webgl_lensflares.ts index 2e6be03866..c9b33cf25c 100644 --- a/three/test/webgl/webgl_lensflares.ts +++ b/three/test/webgl/webgl_lensflares.ts @@ -94,7 +94,7 @@ addLight(0.08, 0.8, 0.5, 0, 0, -1000); addLight(0.995, 0.5, 0.9, 5000, 5000, -1000); - function addLight(h, s, l, x, y, z) { + function addLight(h: number, s: number, l: number, x: number, y: number, z: number) { var light = new THREE.PointLight(0xffffff, 1.5, 4500); light.color.setHSL(h, s, l); @@ -148,7 +148,7 @@ // - function lensFlareUpdateCallback(object) { + function lensFlareUpdateCallback(object: THREE.LensFlare) { var f: number, fl = object.lensFlares.length; var flare; @@ -174,7 +174,7 @@ // - function onWindowResize(event) { + function onWindowResize(event: Event) { renderer.setSize(window.innerWidth, window.innerHeight); diff --git a/three/test/webgl/webgl_lights_hemisphere.ts b/three/test/webgl/webgl_lights_hemisphere.ts index 4f96fb9511..46dd9f7157 100644 --- a/three/test/webgl/webgl_lights_hemisphere.ts +++ b/three/test/webgl/webgl_lights_hemisphere.ts @@ -11,7 +11,7 @@ if ( ! Detector.webgl ) Detector.addGetWebGLMessage(); var camera: THREE.PerspectiveCamera, scene: THREE.Scene, renderer: THREE.WebGLRenderer, dirLight: THREE.DirectionalLight, hemiLight: THREE.HemisphereLight; - var mixers = []; + var mixers: THREE.AnimationMixer[] = []; var stats: Stats; var clock = new THREE.Clock(); @@ -169,7 +169,7 @@ } - function onKeyDown ( event ) { + function onKeyDown ( event: KeyboardEvent ) { switch ( event.keyCode ) { diff --git a/three/test/webgl/webgl_lines_colors.ts b/three/test/webgl/webgl_lines_colors.ts index 04fc10b618..a372a19e77 100644 --- a/three/test/webgl/webgl_lines_colors.ts +++ b/three/test/webgl/webgl_lines_colors.ts @@ -146,14 +146,14 @@ // - function onDocumentMouseMove(event) { + function onDocumentMouseMove(event: MouseEvent) { mouseX = event.clientX - windowHalfX; mouseY = event.clientY - windowHalfY; } - function onDocumentTouchStart(event) { + function onDocumentTouchStart(event: TouchEvent) { if (event.touches.length > 1) { @@ -166,7 +166,7 @@ } - function onDocumentTouchMove(event) { + function onDocumentTouchMove(event: TouchEvent) { if (event.touches.length == 1) { diff --git a/three/test/webgl/webgl_loader_awd.ts b/three/test/webgl/webgl_loader_awd.ts index 5407ae4360..0273af14dd 100644 --- a/three/test/webgl/webgl_loader_awd.ts +++ b/three/test/webgl/webgl_loader_awd.ts @@ -14,12 +14,12 @@ var camera: THREE.PerspectiveCamera, scene: THREE.Scene, renderer: THREE.WebGLRenderer, objects, controls: THREE.OrbitControls; var particleLight, pointLight: THREE.PointLight; - var trunk; + var trunk: THREE.Object3D; var loader = new THREE.AWDLoader(); loader.materialFactory = createMaterial; - loader.load('./models/awd/simple/simple.awd', function (_trunk) { + loader.load('./models/awd/simple/simple.awd', function (_trunk: THREE.Object3D) { trunk = _trunk; @@ -29,15 +29,13 @@ }); - function createMaterial(name) { - // console.log( name ); - // var mat = new THREE.MeshPhongMaterial({ - // color: 0xaaaaaa, - // shininess: 20 - - // }); - // return mat; - return null; + function createMaterial(name: string) { + console.log( name ); + var mat = new THREE.MeshPhongMaterial({ + color: 0xaaaaaa, + shininess: 20 + }); + return mat; } @@ -106,7 +104,7 @@ pointLight.position.x = Math.sin(timer * 4) * 3000; pointLight.position.y = 600 - pointLight.position.z = Math.cos(timer * 4) * 3000; + pointLight.position.z = Math.cos(timer * 4) * 3000; renderer.render(scene, camera); diff --git a/three/test/webgl/webgl_materials.ts b/three/test/webgl/webgl_materials.ts index 409bfa5eda..5a3538b17d 100644 --- a/three/test/webgl/webgl_materials.ts +++ b/three/test/webgl/webgl_materials.ts @@ -13,8 +13,12 @@ var camera: THREE.PerspectiveCamera, scene: THREE.Scene, renderer: THREE.WebGLRenderer, objects: THREE.Mesh[]; var particleLight: THREE.Mesh; - - var materials = []; + var materials: ( THREE.MeshBasicMaterial | + THREE.MeshPhongMaterial | + THREE.MeshNormalMaterial | + THREE.MeshLambertMaterial | + THREE.MeshFaceMaterial | + THREE.MeshDepthMaterial ) [] = []; init(); animate(); @@ -224,8 +228,8 @@ } - materials[materials.length - 3].emissive.setHSL(0.54, 1, 0.35 * (0.5 + 0.5 * Math.sin(35 * timer))); - materials[materials.length - 4].emissive.setHSL(0.04, 1, 0.35 * (0.5 + 0.5 * Math.cos(35 * timer))); + (materials[materials.length - 3] as THREE.MeshPhongMaterial).emissive.setHSL(0.54, 1, 0.35 * (0.5 + 0.5 * Math.sin(35 * timer))); + (materials[materials.length - 4] as THREE.MeshLambertMaterial).emissive.setHSL(0.04, 1, 0.35 * (0.5 + 0.5 * Math.cos(35 * timer))); particleLight.position.x = Math.sin(timer * 7) * 300; particleLight.position.y = Math.cos(timer * 5) * 400; diff --git a/three/test/webgl/webgl_morphtargets.ts b/three/test/webgl/webgl_morphtargets.ts index 7eb641d816..a76d4378d3 100644 --- a/three/test/webgl/webgl_morphtargets.ts +++ b/three/test/webgl/webgl_morphtargets.ts @@ -100,7 +100,7 @@ } - function onDocumentMouseMove(event) { + function onDocumentMouseMove(event: MouseEvent) { mouseX = (event.clientX - windowHalfX); mouseY = (event.clientY - windowHalfY) * 2; diff --git a/three/test/webgl/webgl_points_billboards.ts b/three/test/webgl/webgl_points_billboards.ts index 4ab898462a..c2a939456a 100644 --- a/three/test/webgl/webgl_points_billboards.ts +++ b/three/test/webgl/webgl_points_billboards.ts @@ -86,14 +86,14 @@ } - function onDocumentMouseMove( event ) { + function onDocumentMouseMove( event: MouseEvent ) { mouseX = event.clientX - windowHalfX; mouseY = event.clientY - windowHalfY; } - function onDocumentTouchStart( event ) { + function onDocumentTouchStart( event: TouchEvent ) { if ( event.touches.length == 1 ) { @@ -105,7 +105,7 @@ } } - function onDocumentTouchMove( event ) { + function onDocumentTouchMove( event: TouchEvent ) { if ( event.touches.length == 1 ) { diff --git a/three/test/webgl/webgl_sprites.ts b/three/test/webgl/webgl_sprites.ts index 5d5c6162d2..8e71285fac 100644 --- a/three/test/webgl/webgl_sprites.ts +++ b/three/test/webgl/webgl_sprites.ts @@ -96,7 +96,7 @@ } - function createHUDSprites ( texture ) { + function createHUDSprites ( texture: THREE.Texture ) { var material = new THREE.SpriteMaterial( { map: texture } ); diff --git a/three/three-canvasrenderer.d.ts b/three/three-canvasrenderer.d.ts index c37f223c56..3560963a47 100644 --- a/three/three-canvasrenderer.d.ts +++ b/three/three-canvasrenderer.d.ts @@ -6,7 +6,7 @@ declare namespace THREE { export interface SpriteCanvasMaterialParameters extends MaterialParameters { color?: number; - program?: (context: any, color: Color) => void; + program?: (context: CanvasRenderingContext2D, color: Color) => void; } export class SpriteCanvasMaterial extends Material { @@ -14,7 +14,7 @@ declare namespace THREE { color: Color; - program(context: any, color: Color): void; + program(context: CanvasRenderingContext2D, color: Color): void; } export interface CanvasRendererParameters {