relikhunter Posted October 10, 2014 Share Posted October 10, 2014 hi,first of all , sorry if my english is bad as a low grade student. As a user told me out from here, i publish my source code in this forum, probably is the right place to discuss. I'm a beginner in blender and babylonJS so I created first to test Babylon an hand-coded dynamic generated scene, veeery very basic.It generate walls, floor, roof and rectangles representing paintings. Next I think it's better to use blender to complete the scene by making a decent environment and Sirs that arise a problem. When i want to export a scene from blender and get it from the following code , it report me into the Chrome web consolle "WebGL not supported" . var canvas =document.getElementById("canvas");var engine = new BABYLON.Engine(canvas, true);var scene = new BABYLON.Scene(engine); BABYLON.SceneLoader.Load("", "testSceneFromBlender.babylon", engine, function (newScene) { newScene.executeWhenReady(function () { newScene.activeCamera.attachControl(canvas); engine.runRenderLoop(function() { newScene.render(); }); window.addEventListener("resize", function () { engine.resize(); }); // sezione per codice caricamento scena... "please wait... loading..." }); }); Quote Link to comment Share on other sites More sharing options...
Dad72 Posted October 11, 2014 Share Posted October 11, 2014 Try: <!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>BABYLON - Look Cameras</title> <script src="../hand.js"></script> <style> html, body, canvas { width: 100%; height: 100%; padding: 0; margin: 0; overflow: hidden; } </style></head><body> <canvas id="canvas"></canvas><script src="./../babylon.js"></script><script>var canvas =document.getElementById("canvas");var engine = new BABYLON.Engine(canvas, true);var scene = new BABYLON.Scene(engine); BABYLON.SceneLoader.Load("", "testSceneFromBlender.babylon", engine, function (newScene) { newScene.executeWhenReady(function () { newScene.activeCamera.attachControl(canvas); engine.runRenderLoop(function() { newScene.render(); }); window.addEventListener("resize", function () { engine.resize(); }); // sezione per codice caricamento scena... "please wait... loading..." }); });</script></body></html>This should be used after the canvas tag :var canvas = document.getElementById("canvas"); Quote Link to comment Share on other sites More sharing options...
relikhunter Posted October 11, 2014 Author Share Posted October 11, 2014 This now works!!!! thanks very mucchhh. but it's a strange behaviour.... why put outside the head tag all the scene code? bah. Quote Link to comment Share on other sites More sharing options...
joshcamas Posted October 11, 2014 Share Posted October 11, 2014 If you put script imports and stuff after everything else, it loads the webpage faster. It's not required for your code to run. I would also say to be safe put the script inside a "window.onload" function. Then the script code will only run when the page is fully loaded, to allow the canvas and inputs and everything to fully load.<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>BABYLON - Look Cameras</title> <script src="../hand.js"></script> <style> html, body, canvas { width: 100%; height: 100%; padding: 0; margin: 0; overflow: hidden; } </style></head><body> <canvas id="canvas"></canvas><script src="./../babylon.js"></script><script> window.onload = function() { var canvas =document.getElementById("canvas"); var engine = new BABYLON.Engine(canvas, true); var scene = new BABYLON.Scene(engine); BABYLON.SceneLoader.Load("", "testSceneFromBlender.babylon", engine, function (newScene) { newScene.executeWhenReady(function () { newScene.activeCamera.attachControl(canvas); engine.runRenderLoop(function() { newScene.render(); }); window.addEventListener("resize", function () { engine.resize(); }); // sezione per codice caricamento scena... "please wait... loading..." }); }); }</script></body></html> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.