Browse Source

Added handling of texture filtering parameters to scene loader.

alteredq 14 years ago
parent
commit
b13f7efafd
3 changed files with 105 additions and 53 deletions
  1. 48 48
      build/ThreeExtras.js
  2. 51 5
      examples/scenes/test_scene.js
  3. 6 0
      src/extras/SceneUtils.js

File diff suppressed because it is too large
+ 48 - 48
build/ThreeExtras.js


+ 51 - 5
examples/scenes/test_scene.js

@@ -20,6 +20,15 @@ var scene = {
 		"visible"  : true
 		"visible"  : true
 	},
 	},
 
 
+	"cube3" : {
+		"geometry" : "cube",
+		"materials": [ "minecraft" ],
+		"position" : [ -30, -5, 25 ],
+		"rotation" : [ 0, 0.8, 0 ],
+		"scale"	   : [ 1, 1, 1 ],
+		"visible"  : true
+	},
+
 	"sphere" : {
 	"sphere" : {
 		"geometry" : "sphere",
 		"geometry" : "sphere",
 		"materials": [ "lambert_green" ],
 		"materials": [ "lambert_green" ],
@@ -83,6 +92,15 @@ var scene = {
 		"scale"	   : [ 0.5, 0.5, 0.5 ],
 		"scale"	   : [ 0.5, 0.5, 0.5 ],
 		"visible"  : true
 		"visible"  : true
 	},
 	},
+
+	"quad_bg" : {
+		"geometry" : "quad",
+		"materials": [ "textured_bg" ],
+		"position" : [ 0, 15, -90 ],
+		"rotation" : [ 0, 0, 0 ],
+		"scale"	   : [ 20, 20, 20 ],
+		"visible"  : true
+	},
 	
 	
 	"ground" : {
 	"ground" : {
 		"geometry" : "plane",
 		"geometry" : "plane",
@@ -116,6 +134,14 @@ var scene = {
 		"segments_height" : 50
 		"segments_height" : 50
 	},	
 	},	
 
 
+	"quad": {
+		"type"   : "plane",
+		"width"  : 10, 
+		"height" : 10,
+		"segments_width"  : 1, 
+		"segments_height" : 1
+	},	
+
 	"sphere": {
 	"sphere": {
 		"type"    : "sphere",
 		"type"    : "sphere",
 		"radius"  : 5, 
 		"radius"  : 5, 
@@ -233,17 +259,17 @@ var scene = {
 	
 	
 	"chrome": {
 	"chrome": {
 		"type": "MeshLambertMaterial",
 		"type": "MeshLambertMaterial",
-		"parameters": { color: 0xffffff, env_map: "textureCube" }
+		"parameters": { color: 0xffffff, env_map: "texture_cube" }
 	},
 	},
 
 
 	"darkerchrome": {
 	"darkerchrome": {
 		"type": "MeshLambertMaterial",
 		"type": "MeshLambertMaterial",
-		"parameters": { color: 0x222222, env_map: "textureCube" }
+		"parameters": { color: 0x222222, env_map: "texture_cube" }
 	},
 	},
 	
 	
 	"glass": {
 	"glass": {
 		"type": "MeshLambertMaterial",
 		"type": "MeshLambertMaterial",
-		"parameters": { color: 0x101046, env_map: "textureCube", opacity: 0.25 }
+		"parameters": { color: 0x101046, env_map: "texture_cube", opacity: 0.25 }
 	},
 	},
 
 
 	"interior": {
 	"interior": {
@@ -251,6 +277,16 @@ var scene = {
 		"parameters": { color: 0x050505 }
 		"parameters": { color: 0x050505 }
 	},
 	},
 	
 	
+	"textured_bg": {
+		"type": "MeshBasicMaterial",
+		"parameters": { color: 0xffffff, map: "texture_bg" } 
+	},
+
+	"minecraft": {
+		"type": "MeshBasicMaterial",
+		"parameters": { color: 0xffffff, map: "texture_minecraft" } 
+	},
+	
 	"face": {
 	"face": {
 		"type": "MeshFaceMaterial",
 		"type": "MeshFaceMaterial",
 		"parameters": {}
 		"parameters": {}
@@ -261,14 +297,24 @@ var scene = {
 "textures": 
 "textures": 
 {
 {
 	
 	
-	"textureCube": {
+	"texture_cube": {
 		"url": [ "textures/cube/SwedishRoyalCastle/px.jpg",
 		"url": [ "textures/cube/SwedishRoyalCastle/px.jpg",
-				 "textures/cube/SwedishRoyalCastle/nx.jpg",		
+				 "textures/cube/SwedishRoyalCastle/nx.jpg",
 				 "textures/cube/SwedishRoyalCastle/py.jpg",
 				 "textures/cube/SwedishRoyalCastle/py.jpg",
 				 "textures/cube/SwedishRoyalCastle/ny.jpg",
 				 "textures/cube/SwedishRoyalCastle/ny.jpg",
 				 "textures/cube/SwedishRoyalCastle/pz.jpg",
 				 "textures/cube/SwedishRoyalCastle/pz.jpg",
 				 "textures/cube/SwedishRoyalCastle/nz.jpg"
 				 "textures/cube/SwedishRoyalCastle/nz.jpg"
 				]
 				]
+	},
+
+	"texture_bg": {
+		"url": "textures/cube/SwedishRoyalCastle/pz.jpg"
+	},
+
+	"texture_minecraft": {
+		"url": "textures/minecraft/grass.png",
+		"mag_filter": "NearestFilter",
+		"min_filter": "LinearMipMapLinearFilter"
 	}
 	}
 	
 	
 },
 },

+ 6 - 0
src/extras/SceneUtils.js

@@ -175,6 +175,12 @@ var SceneUtils = {
 					
 					
 					texture = ImageUtils.loadTexture( tt.url );
 					texture = ImageUtils.loadTexture( tt.url );
 					
 					
+					if ( THREE[ tt.min_filter ] != undefined )
+						texture.min_filter = THREE[ tt.min_filter ];
+					
+					if ( THREE[ tt.mag_filter ] != undefined )
+						texture.mag_filter = THREE[ tt.mag_filter ];
+					
 				}
 				}
 				
 				
 				result.textures[ dt ] = texture;
 				result.textures[ dt ] = texture;

Some files were not shown because too many files changed in this diff