From 990d18910101fa60f431b4fe985503944cd9c842 Mon Sep 17 00:00:00 2001 From: WestLangley Date: Tue, 15 Mar 2016 23:47:51 -0400 Subject: [PATCH] Set flipY to true on loaded tga textures --- examples/webgl_materials_texture_tga.html | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/examples/webgl_materials_texture_tga.html b/examples/webgl_materials_texture_tga.html index 84017971ec..911754824d 100644 --- a/examples/webgl_materials_texture_tga.html +++ b/examples/webgl_materials_texture_tga.html @@ -43,7 +43,7 @@ var SCREEN_WIDTH = window.innerWidth; var SCREEN_HEIGHT = window.innerHeight; - var container,stats; + var container, stats; var camera, scene, renderer; @@ -62,12 +62,14 @@ renderer = new THREE.WebGLRenderer( { antialias: true } ); - camera = new THREE.PerspectiveCamera( 35, SCREEN_WIDTH / SCREEN_HEIGHT, 1, 25000 ); + camera = new THREE.PerspectiveCamera( 35, SCREEN_WIDTH / SCREEN_HEIGHT, 10, 2000 ); camera.position.z = 200; scene = new THREE.Scene(); - var light = new THREE.DirectionalLight( 0xffffff, 2 ); + scene.add( new THREE.AmbientLight( 0xffffff, 0.4 ) ); + + var light = new THREE.DirectionalLight( 0xffffff, 1 ); light.position.set( 1, 1, 1 ); scene.add( light ); @@ -75,21 +77,23 @@ // add box 1 - grey8 texture var texture1 = loader.load( 'textures/crate_grey8.tga' ); + texture1.flipY = true; + var material1 = new THREE.MeshPhongMaterial( { color: 0xffffff, map: texture1 } ); var geometry = new THREE.BoxGeometry( 50, 50, 50 ); var mesh1 = new THREE.Mesh( geometry, material1 ); - mesh1.rotation.x = -Math.PI / 2; mesh1.position.x = - 50; scene.add( mesh1 ); // add box 2 - tga texture var texture2 = loader.load( 'textures/crate_color8.tga' ); + texture2.flipY = true; + var material2 = new THREE.MeshPhongMaterial( { color: 0xffffff, map: texture2 } ); var mesh2 = new THREE.Mesh( geometry, material2 ); - mesh2.rotation.x = -Math.PI / 2; mesh2.position.x = 50; scene.add( mesh2 ); @@ -110,7 +114,7 @@ } - function onDocumentMouseMove(event) { + function onDocumentMouseMove( event ) { mouseX = ( event.clientX - windowHalfX ); mouseY = ( event.clientY - windowHalfY ); -- GitLab