Forráskód Böngészése

Updated examples to the new *Mapping API.

Mr.doob 10 éve
szülő
commit
0d872b4fc7

+ 1 - 3
editor/js/libs/ui.three.js

@@ -189,9 +189,7 @@ UI.CubeTexture = function () {
 				var image = document.createElement( 'img' );
 				image.addEventListener( 'load', function( event ) {
 
-					var array = [ this, this, this, this, this, this ];
-
-					var texture = new THREE.Texture( array, new THREE.CubeReflectionMapping() );
+					var texture = new THREE.Texture( this, THREE.SphericalReflectionMapping );
 					texture.sourceFile = file.name;
 					texture.needsUpdate = true;
 

+ 2 - 2
examples/canvas_materials.html

@@ -76,8 +76,8 @@
 					new THREE.MeshDepthMaterial( { overdraw: 0.5 } ),
 					new THREE.MeshNormalMaterial( { overdraw: 0.5 } ),
 					new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ),
-					new THREE.MeshBasicMaterial( { envMap: THREE.ImageUtils.loadTexture( 'textures/envmap.png', new THREE.SphericalReflectionMapping() ), overdraw: 0.5 } ),
-					new THREE.MeshBasicMaterial( { envMap: THREE.ImageUtils.loadTexture( 'textures/envmap.png', new THREE.SphericalRefractionMapping() ), overdraw: 0.5 } )
+					new THREE.MeshBasicMaterial( { envMap: THREE.ImageUtils.loadTexture( 'textures/envmap.png', THREE.SphericalReflectionMapping ), overdraw: 0.5 } ),
+					new THREE.MeshBasicMaterial( { envMap: THREE.ImageUtils.loadTexture( 'textures/envmap.png', THREE.SphericalRefractionMapping ), overdraw: 0.5 } )
 
 				];
 

+ 1 - 1
examples/canvas_materials_reflection.html

@@ -67,7 +67,7 @@
 
 					geometry.computeVertexNormals();
 
-					mesh = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { envMap: THREE.ImageUtils.loadTexture( 'textures/metal.jpg', new THREE.SphericalReflectionMapping() ), overdraw: 0.5 } ) );
+					mesh = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { envMap: THREE.ImageUtils.loadTexture( 'textures/metal.jpg', THREE.SphericalReflectionMapping ), overdraw: 0.5 } ) );
 					scene.add( mesh );
 
 				} );

+ 1 - 1
examples/canvas_sandbox.html

@@ -94,7 +94,7 @@
 
 				geometry = new THREE.IcosahedronGeometry( 100, 1 );
 
-				material = new THREE.MeshBasicMaterial( { envMap: THREE.ImageUtils.loadTexture( 'textures/metal.jpg', new THREE.SphericalReflectionMapping() ), overdraw: 0.5 } );
+				material = new THREE.MeshBasicMaterial( { envMap: THREE.ImageUtils.loadTexture( 'textures/metal.jpg', THREE.SphericalReflectionMapping ), overdraw: 0.5 } );
 
 				for ( var i = 0; i < 10; i ++ ) {
 

+ 1 - 1
examples/js/MD2Character.js

@@ -183,7 +183,7 @@ THREE.MD2Character = function () {
 
 	function loadTextures( baseUrl, textureUrls ) {
 
-		var mapping = new THREE.UVMapping();
+		var mapping = THREE.UVMapping;
 		var textures = [];
 
 		for ( var i = 0; i < textureUrls.length; i ++ ) {

+ 1 - 1
examples/js/MD2CharacterComplex.js

@@ -506,7 +506,7 @@ THREE.MD2CharacterComplex = function () {
 
 	function loadTextures( baseUrl, textureUrls ) {
 
-		var mapping = new THREE.UVMapping();
+		var mapping = THREE.UVMapping;
 		var textures = [];
 
 		for ( var i = 0; i < textureUrls.length; i ++ ) {

+ 1 - 1
examples/js/UCSCharacter.js

@@ -78,7 +78,7 @@ THREE.UCSCharacter = function() {
 	}
 	
 	function loadTextures( baseUrl, textureUrls ) {
-		var mapping = new THREE.UVMapping();
+		var mapping = THREE.UVMapping;
 		var textures = [];
 
 		for ( var i = 0; i < textureUrls.length; i ++ ) {

+ 5 - 3
examples/js/renderers/CanvasRenderer.js

@@ -700,8 +700,10 @@ THREE.CanvasRenderer = function ( parameters ) {
 				    material instanceof THREE.MeshPhongMaterial ) {
 
 			if ( material.map !== null ) {
+			
+				var mapping = material.map.mapping;
 
-				if ( material.map.mapping instanceof THREE.UVMapping ) {
+				if ( mapping === THREE.UVMapping ) {
 
 					_uvs = element.uvs;
 					patternPath( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _uvs[ uv1 ].x, _uvs[ uv1 ].y, _uvs[ uv2 ].x, _uvs[ uv2 ].y, _uvs[ uv3 ].x, _uvs[ uv3 ].y, material.map );
@@ -710,7 +712,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 			} else if ( material.envMap !== null ) {
 
-				if ( material.envMap.mapping instanceof THREE.SphericalReflectionMapping ) {
+				if ( mapping === THREE.SphericalReflectionMapping ) {
 
 					_normal.copy( element.vertexNormalsModel[ uv1 ] ).applyMatrix3( _normalViewMatrix );
 					_uv1x = 0.5 * _normal.x + 0.5;
@@ -726,7 +728,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 					patternPath( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _uv1x, _uv1y, _uv2x, _uv2y, _uv3x, _uv3y, material.envMap );
 
-				} else if ( material.envMap.mapping instanceof THREE.SphericalRefractionMapping ) {
+				} else if ( mapping === THREE.SphericalRefractionMapping ) {
 
 					_normal.copy( element.vertexNormalsModel[ uv1 ] ).applyMatrix3( _normalViewMatrix );
 					_uv1x = - 0.5 * _normal.x + 0.5;

+ 1 - 1
examples/misc_controls_transform.html

@@ -60,7 +60,7 @@
 				scene.add( light );
 
 
-				var texture = THREE.ImageUtils.loadTexture( 'textures/crate.gif', new THREE.UVMapping(), render );
+				var texture = THREE.ImageUtils.loadTexture( 'textures/crate.gif', THREE.UVMapping, render );
 				texture.anisotropy = renderer.getMaxAnisotropy();
 
 				var geometry = new THREE.BoxGeometry( 200, 200, 200 );

+ 1 - 1
examples/webgl_effects_stereo.html

@@ -86,7 +86,7 @@
 					path + 'pz' + format, path + 'nz' + format
 				];
 
-				var textureCube = THREE.ImageUtils.loadTextureCube( urls, new THREE.CubeRefractionMapping() );
+				var textureCube = THREE.ImageUtils.loadTextureCube( urls, THREE.CubeRefractionMapping );
 				var material = new THREE.MeshBasicMaterial( { color: 0xffffff, envMap: textureCube, refractionRatio: 0.95 } );
 
 				for ( var i = 0; i < 500; i ++ ) {

+ 1 - 1
examples/webgl_geometry_terrain.html

@@ -92,7 +92,7 @@
 
 				}
 
-				texture = new THREE.Texture( generateTexture( data, worldWidth, worldDepth ), new THREE.UVMapping(), THREE.ClampToEdgeWrapping, THREE.ClampToEdgeWrapping );
+				texture = new THREE.Texture( generateTexture( data, worldWidth, worldDepth ), THREE.UVMapping, THREE.ClampToEdgeWrapping, THREE.ClampToEdgeWrapping );
 				texture.needsUpdate = true;
 
 				mesh = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { map: texture } ) );

+ 1 - 1
examples/webgl_geometry_terrain_fog.html

@@ -94,7 +94,7 @@
 
 				}
 
-				texture = new THREE.Texture( generateTexture( data, worldWidth, worldDepth ), new THREE.UVMapping(), THREE.ClampToEdgeWrapping, THREE.ClampToEdgeWrapping );
+				texture = new THREE.Texture( generateTexture( data, worldWidth, worldDepth ), THREE.UVMapping, THREE.ClampToEdgeWrapping, THREE.ClampToEdgeWrapping );
 				texture.needsUpdate = true;
 
 				mesh = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { map: texture } ) );

+ 1 - 1
examples/webgl_geometry_terrain_raycast.html

@@ -98,7 +98,7 @@
 
 				geometry.computeFaceNormals();
 
-				texture = new THREE.Texture( generateTexture( data, worldWidth, worldDepth ), new THREE.UVMapping(), THREE.ClampToEdgeWrapping, THREE.ClampToEdgeWrapping );
+				texture = new THREE.Texture( generateTexture( data, worldWidth, worldDepth ), THREE.UVMapping, THREE.ClampToEdgeWrapping, THREE.ClampToEdgeWrapping );
 				texture.needsUpdate = true;
 
 				mesh = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { map: texture } ) );

+ 1 - 1
examples/webgl_loader_json_objconverter.html

@@ -101,7 +101,7 @@
 				xc.fillStyle = "#555";
 				xc.fillRect(96, 96, 32, 32);
 
-				var xm = new THREE.MeshBasicMaterial( { map: new THREE.Texture( x, new THREE.UVMapping(), THREE.RepeatWrapping, THREE.RepeatWrapping ) } );
+				var xm = new THREE.MeshBasicMaterial( { map: new THREE.Texture( x, THREE.UVMapping, THREE.RepeatWrapping, THREE.RepeatWrapping ) } );
 				xm.map.needsUpdate = true;
 				xm.map.repeat.set( 10, 10 );
 

+ 1 - 1
examples/webgl_marchingcubes.html

@@ -263,7 +263,7 @@
 			var reflectionCube = THREE.ImageUtils.loadTextureCube( urls );
 			reflectionCube.format = THREE.RGBFormat;
 
-			var refractionCube = new THREE.Texture( reflectionCube.image, new THREE.CubeRefractionMapping() );
+			var refractionCube = new THREE.Texture( reflectionCube.image, THREE.CubeRefractionMapping );
 			reflectionCube.format = THREE.RGBFormat;
 
 			// toons

+ 1 - 1
examples/webgl_materials_cubemap.html

@@ -108,7 +108,7 @@
 				var reflectionCube = THREE.ImageUtils.loadTextureCube( urls );
 				reflectionCube.format = THREE.RGBFormat;
 
-				var refractionCube = new THREE.CubeTexture( reflectionCube.image, new THREE.CubeRefractionMapping() );
+				var refractionCube = new THREE.CubeTexture( reflectionCube.image, THREE.CubeRefractionMapping );
 				refractionCube.format = THREE.RGBFormat;
 
 				//var cubeMaterial3 = new THREE.MeshPhongMaterial( { color: 0x000000, specular:0xaa0000, envMap: reflectionCube, combine: THREE.MixOperation, reflectivity: 0.25 } );

+ 1 - 1
examples/webgl_materials_cubemap_balls_refraction.html

@@ -86,7 +86,7 @@
 					path + 'pz' + format, path + 'nz' + format
 				];
 
-				var textureCube = THREE.ImageUtils.loadTextureCube( urls, new THREE.CubeRefractionMapping() );
+				var textureCube = THREE.ImageUtils.loadTextureCube( urls, THREE.CubeRefractionMapping );
 				var material = new THREE.MeshBasicMaterial( { color: 0xffffff, envMap: textureCube, refractionRatio: 0.95 } );
 
 				for ( var i = 0; i < 500; i ++ ) {

+ 1 - 1
examples/webgl_materials_cubemap_dynamic2.html

@@ -45,7 +45,7 @@
 			lat = 0, onMouseDownLat = 0,
 			phi = 0, theta = 0;
 
-			var texture = THREE.ImageUtils.loadTexture( 'textures/2294472375_24a3b8ef46_o.jpg', new THREE.UVMapping(), function () {
+			var texture = THREE.ImageUtils.loadTexture( 'textures/2294472375_24a3b8ef46_o.jpg', THREE.UVMapping, function () {
 
 				init();
 				animate();

+ 1 - 1
examples/webgl_materials_cubemap_refraction.html

@@ -103,7 +103,7 @@
 							 r + "py.jpg", r + "ny.jpg",
 							 r + "pz.jpg", r + "nz.jpg" ];
 
-				var textureCube = THREE.ImageUtils.loadTextureCube( urls, new THREE.CubeRefractionMapping() );
+				var textureCube = THREE.ImageUtils.loadTextureCube( urls, THREE.CubeRefractionMapping );
 
 				var cubeMaterial3 = new THREE.MeshBasicMaterial( { color: 0xccddff, envMap: textureCube, refractionRatio: 0.98, reflectivity:0.9 } );
 				var cubeMaterial2 = new THREE.MeshBasicMaterial( { color: 0xccfffd, envMap: textureCube, refractionRatio: 0.985 } );

+ 3 - 3
examples/webgl_materials_texture_compressed.html

@@ -95,21 +95,21 @@
 				var cubemap1 = loader.load( 'textures/compressed/Mountains.dds', function ( texture ) {
 					texture.magFilter = THREE.LinearFilter
 					texture.minFilter = THREE.LinearFilter;
-					texture.mapping = new THREE.CubeReflectionMapping();
+					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 = new THREE.CubeReflectionMapping();
+					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 = new THREE.CubeReflectionMapping();
+					texture.mapping = THREE.CubeReflectionMapping;
 					material6.needsUpdate = true;
 				} );
 

+ 2 - 2
examples/webgl_materials_texture_pvrtc.html

@@ -73,14 +73,14 @@
     			var onCube1Loaded = function(texture){
 					texture.magFilter = THREE.LinearFilter;
 					texture.minFilter = THREE.LinearFilter;
-					texture.mapping = new THREE.CubeReflectionMapping();
+					texture.mapping = THREE.CubeReflectionMapping;
 					material6.needsUpdate = true;
     			};
     			var onCube2Loaded = function(texture){
 					texture.magFilter = THREE.LinearFilter;
 					// texture.minFilter = THREE.LinearMipMapNearestFilter;
 					texture.minFilter = THREE.LinearFilter;
-					texture.mapping = new THREE.CubeReflectionMapping();
+					texture.mapping = THREE.CubeReflectionMapping;
 					material8.needsUpdate = true;
     			};
      

+ 2 - 2
examples/webgl_sandbox.html

@@ -77,8 +77,8 @@
 				var vertexShader = shader.vertexShader;
 				var fragmentShader = shader.fragmentShader;
 
-				var texture1 = new THREE.Texture( generateTexture( 0, 0.5, 1 ), new THREE.UVMapping() );
-				var texture2 = new THREE.Texture( generateTexture( 0, 1, 0 ), new THREE.SphericalReflectionMapping() );
+				var texture1 = new THREE.Texture( generateTexture( 0, 0.5, 1 ), THREE.UVMapping );
+				var texture2 = new THREE.Texture( generateTexture( 0, 1, 0 ), THREE.SphericalReflectionMapping );
 				var texture3 = THREE.ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' )
 
 				texture1.needsUpdate = true;

+ 1 - 1
examples/webgl_shading_physical.html

@@ -146,7 +146,7 @@
 				xc.fillStyle = "#555";
 				xc.fillRect(96, 96, 32, 32);
 
-				var texturePattern = new THREE.Texture( x, new THREE.UVMapping(), THREE.RepeatWrapping, THREE.RepeatWrapping );
+				var texturePattern = new THREE.Texture( x, THREE.UVMapping, THREE.RepeatWrapping, THREE.RepeatWrapping );
 				texturePattern.needsUpdate = true;
 				texturePattern.repeat.set( 1000, 1000 );
 				texturePattern.format = THREE.RGBFormat;