ソースを参照

Merge pull request #866 from julien-moreau/master

Improved terrain material demo
David Catuhe 9 年 前
コミット
e5c1b4a8e6

+ 14 - 0
materialsLibrary/test/add/addfire.js

@@ -0,0 +1,14 @@
+window.prepareFire = function() {
+    var fire = new BABYLON.FireMaterial("fire", scene);
+    fire.diffuseTexture = new BABYLON.Texture("textures/fire/diffuse.png", scene);
+    fire.distortionTexture = new BABYLON.Texture("textures/fire/distortion.png", scene);
+    fire.opacityTexture = new BABYLON.Texture("textures/fire/opacity.png", scene);
+    
+    registerRangeUI("fire", "speed", 0, 20, function(value) {
+		fire.speed = value;
+	}, function() {
+		return fire.speed;
+	});
+    
+    return fire;
+};

+ 19 - 0
materialsLibrary/test/add/addterrain.js

@@ -0,0 +1,19 @@
+window.prepareTerrain = function() {
+    var terrain = new BABYLON.TerrainMaterial("terrain", scene);
+    terrain.specularColor = new BABYLON.Color3(0.5, 0.5, 0.5);
+    terrain.specularPower = 64;
+    terrain.mixTexture = new BABYLON.Texture("textures/mixMap.png", scene);
+    terrain.diffuseTexture1 = new BABYLON.Texture("textures/floor.png", scene);
+    terrain.diffuseTexture2 = new BABYLON.Texture("textures/rock.png", scene);
+    terrain.diffuseTexture3 = new BABYLON.Texture("textures/grass.png", scene);
+    
+    terrain.bumpTexture1 = new BABYLON.Texture("textures/floor_bump.png", scene);
+    terrain.bumpTexture2 = new BABYLON.Texture("textures/rockn.png", scene);
+    terrain.bumpTexture3 = new BABYLON.Texture("textures/grassn.png", scene);
+    
+    terrain.diffuseTexture1.uScale = terrain.diffuseTexture1.vScale = 10;
+    terrain.diffuseTexture2.uScale = terrain.diffuseTexture2.vScale = 10;
+    terrain.diffuseTexture3.uScale = terrain.diffuseTexture3.vScale = 10;
+    
+    return terrain;
+};

+ 11 - 20
materialsLibrary/test/index.html

@@ -51,6 +51,8 @@
     <script src="add/addnormal.js"></script>
 	<script src="add/addwater.js"></script>
 	<script src="add/addfur.js"></script>
+	<script src="add/addterrain.js"></script>
+	<script src="add/addfire.js"></script>
 	
 	<script>
 		if (BABYLON.Engine.isSupported()) {
@@ -85,6 +87,9 @@
 			var knot = BABYLON.Mesh.CreateTorusKnot("knot", 10, 3, 128, 64, 2, 3, scene);
 			knot.setEnabled(false);
 			
+			var heightMap = BABYLON.Mesh.CreateGroundFromHeightMap("heightMap", "textures/heightMap.png", 100, 100, 100, 0, 10, scene, false);
+			heightMap.setEnabled(false);
+			
 			// Skybox
 			var skybox = BABYLON.Mesh.CreateBox("skyBox", 1000.0, scene);
 			var skyboxMaterial = new BABYLON.StandardMaterial("skyBox", scene);
@@ -180,26 +185,9 @@
 				water.addToRenderList(shadowCaster2);
 				water.addToRenderList(shadowCaster3);
 				
-				var fire = new BABYLON.FireMaterial("fire", scene);
-				fire.diffuseTexture = new BABYLON.Texture("textures/fire/diffuse.png", scene);
-				fire.distortionTexture = new BABYLON.Texture("textures/fire/distortion.png", scene);
-				fire.opacityTexture = new BABYLON.Texture("textures/fire/opacity.png", scene);
-				
-				var terrain = new BABYLON.TerrainMaterial("terrain", scene);
-				terrain.specularColor = new BABYLON.Color3(0.5, 0.5, 0.5);
-				terrain.specularPower = 64;
-				terrain.mixTexture = new BABYLON.Texture("textures/mixMap.png", scene);
-				terrain.diffuseTexture1 = new BABYLON.Texture("textures/grass.png", scene);
-				terrain.diffuseTexture2 = new BABYLON.Texture("textures/rock.png", scene);
-				terrain.diffuseTexture3 = new BABYLON.Texture("textures/floor.png", scene);
+				var fire = prepareFire();
 				
-				terrain.bumpTexture1 = new BABYLON.Texture("textures/grassn.png", scene);
-				terrain.bumpTexture2 = new BABYLON.Texture("textures/rockn.png", scene);
-				terrain.bumpTexture3 = new BABYLON.Texture("textures/floor_bump.png", scene);
-				
-				terrain.diffuseTexture1.uScale = terrain.diffuseTexture1.vScale = 10;
-				terrain.diffuseTexture2.uScale = terrain.diffuseTexture2.vScale = 10;
-				terrain.diffuseTexture3.uScale = terrain.diffuseTexture3.vScale = 10;
+				var terrain = prepareTerrain();
 				
 				var pbr = preparePBR();
 								
@@ -248,7 +236,7 @@
 					window.enableMaterial(options.material);
 				});
 
-				gui.add(options, 'mesh', ['sphere', 'knot', 'plane', 'ground', 'rabbit']).onFinishChange(function () {
+				gui.add(options, 'mesh', ['sphere', 'knot', 'plane', 'ground', 'heightMap', 'rabbit']).onFinishChange(function () {
 					currentMesh.setEnabled(false);
 					switch (options.mesh) {
 						case "sphere":
@@ -263,6 +251,9 @@
 						case "ground":
 							currentMesh = ground;
 							break;
+						case "heightMap":
+							currentMesh = heightMap;
+							break;
 						case "rabbit":
 							currentMesh = rabbit;
 							break;

BIN
materialsLibrary/test/textures/heightMap.png


BIN
materialsLibrary/test/textures/mixMap.png