Jump to content

imported scene from babylon file export in blender, nothing appear


relikhunter
 Share

Recommended Posts

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..."

           });

       });

Link to comment
Share on other sites

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");

Link to comment
Share on other sites

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>
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...