Issue with Ammo?

Hi! I transformed a cart game but failed to embed it using the attached code. Am I missing something in the html portion? I suspect there is something that it didn’t like with the Ammo.js.

FYI, The portion from /******* Add the create scene function / to /* End of the create scene function ******/ loads fine inside Babylon.js.

Thanks

So what is the problem you are having ???

I get a blank screen. I want to upload the entire code here, so you can take a look at it in detail. But how?

Try uploading your source to Github and then post the link here.

https://raw.githubusercontent.com/lucastwong/nanocart/master/demo

Here it is! Any ideas why it would give me a blank white screen would be much appreciated. Thanks everyone.

I’m not sure if you checked the console at all, but there are a couple of issues.

  • You made your createScene async so at the end where you call var scene = createScene() you’re actually defining scene as a Promise. So you actually have to do this:
		createScene().then(scene => {
			// Register a render loop to repeatedly render the scene
			engine.runRenderLoop(function () {
				scene.render();
			});

			// Watch for browser/canvas resize events
			window.addEventListener("resize", function () {
				engine.resize();
			});
		});
  • keydown and keyup are not defined when you are adding the window event listeners, either define those functions or remove those lines.

After those are fixed it renders.

1 Like

Thank you, this is extremely helpful!!!

No problem, good luck!

Sorry to bother you again, but I have another example that has a similar situation. The screen is blank. Maybe you can take a quick look. The code is copied from one of BabylonJS examples:

What’s the error in the console?

When I load it in jsfiddle, I get a blank white screen.

JSFiddle should still have console errors, from what I can tell it looks like something to do with the GUI instantiation which I’m not terribly familiar with.

You are absolutely correct. I deleted the dat.gui part and it loads okay. Thanks for the clue!