Jump to content

Error babylon not defined help!


</style>
 Share

Recommended Posts

I am very new to Babylon, I am designing an app with visual studio using html5, css3, and JavaScript. I am trying to use the code from the Babylon.js website, I copy pasted the code to a html doc and it sees the doc but won't load the image. I keep getting the error ''Babylon not defined'' in this line:

var engine = new babylon.engine(canvas, true);

 

Any help would be appreciated! ​

 

 

Link to comment
Share on other sites

Welcome on the BJS forum  :D

 

 I copy pasted the code to a html doc

 

I don't think you understood what BabylonJS is.

Basically, it's a Javascript library, that help you handle pure WebGL code, and offering you functions to create and design a 3D game in HTML page.

As a library, BabylonJS has to be loaded in your HTML page, as other JS files.

<script src="http://cdn.babylonjs.com/2-1/babylon.js"></script>

So, Babylon is a library, and all Babylon functions are in the BABYLON block.

When you want to call something related to BabylonJS, you must write "BABYLON.yourThingToCall", in upper case (it's important!).

 

In your case :

var engine = new BABYLON.engine(canvas, true);

To introduce you gently in BabylonJS, you can follow tutorials on the offical doc here .

If you want to go further, you can follow these tutorials. If you prefer to have book in your hands, you can try the official e-book .

 

If you have any questions, feel free to ask on this forum.

 

 

Hope I was clear and helped correctly.  :)

Link to comment
Share on other sites

Look at this extract your code:
 

<head>    <meta http-equiv="Content-Type" content="text/html" charset="utf-8"/>    <title>BABYLON - Getting Started</title>    <!--- link to the last version of BABYLON --->    <script src="BABYLON.2.1.debug.js"></script>    <style>        html, body {            overflow: hidden;            width   : 100%;            height  : 100%;            margin  : 0;            padding : 0;        }        #renderCanvas {            width   : 100%;            height  : 100%;            touch-action: none;        }    </style></head><body>    <script src="http://cdn.babylonjs.com/2-1/babylon.js"></script>

Line 5 and 23 you call twice Babylon.js. This could be the problem. Keep the line 23

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