Jump to content

Loaded meshes in assets manager not working with fog


rogerst
 Share

Recommended Posts

			var canvas = document.getElementById("renderCanvas");
			var engine = new BABYLON.Engine(canvas, true);
			
			var createScene = function () {
			var scene = new BABYLON.Scene(engine);
			
			var assetsManager = new BABYLON.AssetsManager(scene);
			
			var camera = new BABYLON.ArcRotateCamera("Camera", 6.3, Math.PI / 2, 0.1, new BABYLON.Vector3(5, 1, 0), scene);
			
			camera.attachControl(canvas, false);

			var light0 = new BABYLON.PointLight("Omni0", new BABYLON.Vector3(0, 10, 0), scene);
			light0.diffuse = new BABYLON.Color3(1, 1, 1);
			light0.specular = new BABYLON.Color3(0.55, 0.55, 0.55);
			light0.range = 20;

	        var skybox = BABYLON.Mesh.CreateBox("skyBox", 100.0, scene);
			var skybox0Material = new BABYLON.StandardMaterial("skyBox", scene);
        	skybox0Material.backFaceCulling = false;
			skybox0Material.reflectionTexture = new BABYLON.CubeTexture("skyboxes/stars01/skybox", scene);
        	skybox0Material.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;

			skybox.material = skybox0Material;
			
			scene.fogMode = BABYLON.Scene.FOGMODE_LINEAR;
			scene.fogColor = new BABYLON.Color3(0.9, 0.9, 0.85);
			scene.fogStart = 0.0;
			scene.fogEnd = 100.0;
	
			var projector1material = new BABYLON.StandardMaterial("projector1texture", scene);
			var projector1emissive = assetsManager.addTextureTask("image task", "models/planetarium1b.jpg");
				
			projector1emissive.onSuccess = function(task) {			
			projector1material.emissiveTexture = task.texture;
			}
			
			var green1material = new BABYLON.StandardMaterial("green1texture", scene);
			var green1emissive = assetsManager.addTextureTask("image task", "models/green.png");
			
			green1emissive.onSuccess = function(task) {			
			green1material.emissiveTexture = task.texture;
			}
			
			var gold1material = new BABYLON.StandardMaterial("gold1texture", scene);
			var gold1diffuse = assetsManager.addTextureTask("image task", "models/gold2.jpg");
				
			gold1diffuse.onSuccess = function(task) {			
			gold1material.diffuseTexture = task.texture;
			gold1material.diffuseTexture.uScale = 6.0;
			gold1material.diffuseTexture.vScale = 6.0;
			}
			
			var base2material = new BABYLON.StandardMaterial("base2texture", scene);
			var base2diffuse = assetsManager.addTextureTask("image task", "models/tower5c.jpg");
				
			base2diffuse.onSuccess = function(task) {			
			base2material.diffuseTexture = task.texture;
			base2material.diffuseTexture.uScale = 3.0;
			base2material.diffuseTexture.vScale = 3.0;
			}
			
			var floor1material = new BABYLON.StandardMaterial("floor1texture", scene);
			var floor1diffuse = assetsManager.addTextureTask("image task", "models/tiles3.png");
				
			floor1diffuse.onSuccess = function(task) {			
			floor1material.diffuseTexture = task.texture;
			floor1material.diffuseTexture.uScale = 300.0;
			floor1material.diffuseTexture.vScale = 300.0;
			}
	
			var scene1mesh = assetsManager.addMeshTask("scene1 task", "", "models/", "planett.babylon");
			
			scene1mesh.onSuccess = function (task) {
			
			var projectorBase1 = task.loadedMeshes[2];
			projectorBase1.material = gold1material;
		
			var projector = task.loadedMeshes[6];
			projector.material = projector1material;
			
			var projectorBase2 = task.loadedMeshes[7];
			projectorBase2.material = base2material;
			
			var floor = task.loadedMeshes[9];
			floor.material = floor1material;

			}
			
			var scene2mesh = assetsManager.addMeshTask("scene2 task", "", "models/", "planett1.babylon");
			
			scene2mesh.onSuccess = function (task) {
			
			var control = task.loadedMeshes[0];
			control.material = green1material;
			
			var button1 = task.loadedMeshes[1];
			button1.material = base2material;
			
			}

			engine.runRenderLoop(function () {
            scene.render();
			});
			
			assetsManager.useDefaultLoadingScreen = true;
        	assetsManager.load();
			engine.loadingUIText = "LOADING..."
			
            return scene;
			}
        
			var scene = createScene();

			window.addEventListener("resize", function () {
            engine.resize();
			
			});

Here is a sample and a screenshot.

Thanks.

screens1.jpg

Link to comment
Share on other sites

So I figured out the problem. It looks like an issue with the Unity exporter. I've been using it to convert all my models. But when I export the same models using Blendar, the meshes are affected by fog. I'm using Unity 5.3.1. Is there a different version that works better with the exporter?

Thanks.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...