Sign in to follow this  
dbawel

[Solved] Scene won't load

Recommended Posts

Hello All,

I have a very serious problem right now, and hope it can be solved. I have 2 scenes; one loads incorrectly, but the model does load. The 2nd scene however does not load, and in both scenes I'm setting a ClearColor for the background just as a test to see what is working, and neither scene loads the skybox or ClearColor background.

The 2 links are:

http://qedsoft.com/DEMOS2017/bjs_loader/index5.html

http://qedsoft.com/DEMOS2017/bjs_loader/index6.html

The model in the first link loads, but the skybox does not, nor does the ClearColor background color.

In the second link however, which is index6.html, the code is virtually the same as in index5.html, yet the model does not load and the skybox and ClearColor background won't load in either. I have a presentation at 12pm PST time which is in California, and must get both models to load to keep the project going. Otherwise, it will be put to a stop, and I don't then know the future of WegGL at Sony - as this should work.

The way the code is written is not what I would normally write, however, I wanted to keep it as simple as possible - so the index.html contains all scripting, and most all assets are in the root directory. However, I placed the skybox images in a separate folder to see if this might provide me with additional information to use to troubleshoot. So again, this is not how I would ever actually write a scene, but I needed to keep it extremely simple. I've tried many different methods to format this, but the results are the same.

If anyone out there can help, this is a win or lose situation for me. If I don't demonstrate the models in the browser tomorrow, then the future is unknown, and I will have lost all faith in my guarantee that babylon.js is the solution for Sony. So please help if you are able and have time, and I'm always grateful for any help.

@Deltakosh, @davrous, and your teams might be able to see what's happening right away. I know there are issues with the way I'm loading assets, but again, this is just for testing. If I can get this working, then I'll re-write it before the presentation tomorrow. I just hope that I hve the opportunity to solve this one, as everything rides on this - especially after I lost my house to the fires - so I have to make this work. There's nothing more important for me personally right now. Again, thank you all for taking a look.

Thanks,

DB

I've attached some additional files so perhaps @JCPalmer might be able to see what the problem is - or anyone who has time to look at the Blender and the .babylon.js files. Unfortunately, the files are too large and past the limit, so all there is to look at currently are the files you can download from the site and console. I've never needed help as much as I do right now. Everything is riding on this, unfortunately.

By the way, both scenes were built quickly in Maya, and exported exactly the same from Blender.

Thanks - as always. I can provide any files anyone might request in the morning as I'll be up really early to see if anyone has found any issues other than the obvious. I'll also keep working until the last minute, as I can't fail on this one. That is not an option.

Cheers...

DB

Share this post


Link to post
Share on other sites

Hi @dbawel 

Using "BABYLON.SceneLoader.Load" instead of "importMesh"( or "Append" to existing scene) seems to be your issue, 

For index5 & index6;
The scene is 'overwritten' with a newScene;
http://playground.babylonjs.com/#DQR2KQ

Fix; using importMesh; http://playground.babylonjs.com/#DQR2KQ#1
Or append //take note of the extra light//; http://playground.babylonjs.com/#DQR2KQ#2 

Furthermore, index6 says is it missing(404) a bump texture; http://qedsoft.com/DEMOS2017/bjs_loader/rough_bump.png


Alternatively, move things inside the SceneLoader.Load func and apply to the newScene object;
PG Example; http://playground.babylonjs.com/#DQR2KQ#4 (just ignore the PG pop-up errors, shouldn't matter outside PG)
Example for index6; 

window.addEventListener('DOMContentLoaded', function(){
    var canvas = document.getElementById('renderCanvas');
    var engine = new BABYLON.Engine(canvas, true);
    var createScene = function(){
		var scene;

		BABYLON.SceneLoader.Load("", "blimp_4.babylon", engine, function (newScene) {
			newScene.executeWhenReady(function () {
				
				var camera = new BABYLON.ArcRotateCamera("camera1", 0,  Math.PI / 2, 10, BABYLON.Vector3.Zero(), newScene);
				    camera.setTarget(BABYLON.Vector3.Zero());
				    camera.attachControl(canvas, true);
					
				var light = new BABYLON.HemisphericLight('light1', new BABYLON.Vector3(0,1,0), newScene);
				
				var skyboxMaterial = new BABYLON.StandardMaterial("skyBox", newScene);
				    skyboxMaterial.backFaceCulling = false;
				    skyboxMaterial.reflectionTexture = new BABYLON.CubeTexture("skybox/snow", newScene);
				    skyboxMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
				    skyboxMaterial.diffuseColor = new BABYLON.Color3(0, 0, 0);
				    skyboxMaterial.specularColor = new BABYLON.Color3(0, 0, 0);
					
				var skybox = BABYLON.MeshBuilder.CreateBox("skyBox", {size:1000.0}, newScene);
				    skybox.material = skyboxMaterial;
					
				newScene.clearColor = new BABYLON.Color3(1, 0, 0);
				newScene.activeCamera.attachControl(canvas);

				engine.runRenderLoop(function() {
					newScene.render();
				});
				
				scene = newScene;
			});
		}, function (progress) {
			
		});
		
	return scene;
	};

    var scene = createScene();

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

 

Share this post


Link to post
Share on other sites

Hi @aWeirdo-

I'm only using ".Load" as it is the only method which allows me to import a mesh. I'd prefer to use "importMesh", however this will not load any mesh - .babylon or .obj - into my scene. However, it works on the playground. This is why I posted the question in the first place. I definitely found a problem with some of my geometry exported from Blender, which is why you see only partial geometry from the model in index5.html which is actually is a blimp - whereas the "blimp" part of the geometry will not load.

Thank you for taking a look at the scene, but my issue is only partially what you outlined - and my preference is not to use '.Load", but to use ".ImportMesh".  And as I've mentioned, I have many scenes from years past where I've used ".ImportMesh" and been able to access various meshes from an array, however, no matter what I currently do on my server, the camera, mesh, skybox, and all other assets are created and/or imported with the same parameters - and I'm unable to modify any attribute of them at all - that is, if they even load. So even if I change my camera position, this is NEVER reflected in my scene - nor will a skybox load.

Tomorrow, I'll look at importing meshes using different versions of babylon.js, as this is the only reason I can find that might have an effect on all of the various problems I currently have. Again, thanks for looking at this, as I always appriciate the time. However, my problem is much deeper than appears, as I've been importing meshes into BJS for several years now, and although I missed calling my function to create the scene recently, there is nothing else I might be missing at this stage, as I've tried everything  - even methods I know will fail just to be certain as everyone does at some point when they can't complete a scene.

Fortunately, as I had an important presentation this past Thursday, there were enough devs there who knew WebGL to see that the issue is in the framework,, browser, or other element of the scene - and mot in my code - as I've kept this as simple as possible.

So again, I'm only using ".Load" in my examples on the forum, as it's the ONLY function I'm currently able to use to import ANY geometry into my scene at this time. Hopefully I'll find the issue tomorrow as I'll begin debugging the latest babylon.js Master file to try and find out what the heck is happening. I'll report whatever I find, as I've wated almost a week debugging this - as it's one of those problems which has taken far more time than necessary as we don't expect what we know works to suddenly stop working with no changes to our code. But that's the world we live in as WebGL and babylon.js are still in their youth. Though, it's a really painful process at times.

Thanks,

DB

Share this post


Link to post
Share on other sites

Hi @dbawel 

I've downloaded your scene (index5)

Any chance you have a screenshot of exactly how it is supposed to look, or can you make one?

So far I've found;

The baloon isn't showing up properly as the mesh "Blimp_body" seems to have some parenting issues.

not sure why or what is causing it, it should be possible to fix in your 3d editor, but as a temporary quick-fix, just reset scaling & rotation.

mesh.scaling = new BABYLON.Vector3(1,1,1);
mesh.rotation = new BABYLON.Zero();

Result;

baloon.thumb.png.6024077f6ae9aab84a4a8ad71c67c2c4.png

Share this post


Link to post
Share on other sites

Hi @aWeirdo -

Thank you for looking further at this. I haven't had time due to still cleaning up after the blaze at my house, but will be able to spend time tomorrow as I will no longer be sleeping in my car, and staying with a friend who has a good internet connection.

I had frozen all transforms - as I am a pain for many developers since I always remind them to freeze transforms. However, I hadn't considered resetting the transforms in the scene code. So my hat is off to you as this helps me out in a big way. I personally didn't do any of the modelling on this project, and it's crap anyway due to it being completely conceptual at this stage. But your approach to resetting transforms in the code is a terrific approach. 

So thank you for looking further at this, and spending time to help me get this moving forward; when I'm buried in sorting through my burned out house - with loads of ashes and little left to salvage. I definitely owe you one, and hope I can return the favor one day.

Please have a great holiday, and I hope your new year is the very best ever!

Cheers,

DB

Share this post


Link to post
Share on other sites

Hi @aWeirdo-

I attached a zipped version of the blender file. How did you get the clearcolor for the scene to work? Also, I can't get the skybox to show either.

Thanks,

DB

I made the changes you recommended, but the results are quite different. Here's the updated scene.

http://qedsoft.com/DEMOS2017/bjs_loader/index5.html

blimp_4.7z

Share this post


Link to post
Share on other sites
1 hour ago, dbawel said:

I made the changes you recommended, but the results are quite different. Here's the updated scene.

http://qedsoft.com/DEMOS2017/bjs_loader/index5.html

 

Hi @dbawel 
The scene won't load for me, error because scene.clearColor is attempted set before the scene variable :) 
 

var createScene = function(){

scene.clearColor = new BABYLON.Color3(1, 1, 1);


var scene = new BABYLON.Scene(engine);



I cleaned it up a bit, and found an "engine" mesh that needed transform resets aswell.

note that only the "Blimp_body" & "engine" meshes seem to have this error.
I moved everything inside the SceneLoader.Load function,
Skybox wasn't showing because of camera.maxZ being too low.


<script>
var canvas = document.getElementById('renderCanvas');
var engine = new BABYLON.Engine(canvas, true);

var createScene = function(){

	var scene;  

	BABYLON.SceneLoader.Load("", "baloon.babylon", engine, function (newScene) {

		newScene.executeWhenReady(function () {
		
			for(var i = 0; i < newScene.meshes.length; i++){
				let mesh = newScene.meshes[i];
				mesh.isVisible = true;
				
				switch(mesh.name){
					case "Blimp_body":
					case "engine":
						mesh.scaling = new BABYLON.Vector3(1,1,1);
						mesh.rotation = new BABYLON.Vector3.Zero();
					break;
					
					default:
					break;
				}
			}
			
			newScene.clearColor = new BABYLON.Color3(1, 1, 1);
			
			newScene.activeCamera.attachControl(canvas);
			newScene.activeCamera.minZ = 0.001;
			newScene.activeCamera.maxZ = 10000;
				
			var light = new BABYLON.HemisphericLight('light1', new BABYLON.Vector3(0,1,0), newScene);
			
			var skyboxMaterial = new BABYLON.StandardMaterial("skyBox", newScene);
				skyboxMaterial.backFaceCulling = false;
				skyboxMaterial.reflectionTexture = new BABYLON.CubeTexture("skybox/snow", newScene);
				skyboxMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
				skyboxMaterial.diffuseColor = new BABYLON.Color3(0, 0, 0);
				skyboxMaterial.specularColor = new BABYLON.Color3(0, 0, 0);
		
			var skybox = BABYLON.MeshBuilder.CreateBox("skyBox", {size:1000.0}, newScene);
				skybox.material = skyboxMaterial;
				
			engine.runRenderLoop(function() {
				newScene.render();
			});
	
			scene = newScene;
		});
	});

	
		
  return scene;
};


var scene = createScene();

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

</script>

 

Share this post


Link to post
Share on other sites

@aWeirdo-

I knew it was a transform issue, but didn't think to set my transforms in the mesh array:wacko: Thank you for taking the time to help, as you solved most of my issues - even the skybox which I can't get to load itself. But I'll work it out now. I hate getting models from other people, even though I un-parented everything, reset every transform, and froze each transform. So I assumed all would be fine. You're on the top of my list right now, and I really appreciate the help.

Here is the "crappy model" in the scene.

Cheers,

DB

blimp.jpg.af2d1269ab2036680e9b7e8cdbc1497c.jpg

Share this post


Link to post
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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.