Jump to content

Can you reference the GUI using a CDN link?


Recommended Posts

Due to my setup I am using the CDN link for BabylonJS.  When I attempt to instantiate the GUI command I get a:

[Error] TypeError: undefined is not an object (evaluating 'new BABYLON.GUI.GUI3DManager')
	createScene (ui.js:12)
	(anonymous function) (ui.js:24)
<!DOCTYPE html>
        <meta charset="UTF-8">
        <title>GC3 UI POC</title>
        <script src="https://cdn.babylonjs.com/babylon.max.js"></script>
        <style>#canvas { width:100%; height:100%; }</style>
        <canvas id="canvas"><script src="js/ui.js"></script></canvas>

based on they following code:

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

    var createScene = function (){
        var scene = new BABYLON.Scene(engine);
        scene.clearColor = new BABYLON.Color3.White();
        var camera = new BABYLON.ArcRotateCamera('camera1', 0, 0, 10, new BABYLON.Vector3(0, 0, 0), scene);
        camera.setPosition(new BABYLON.Vector3(0,0,20));
        camera.attachControl(canvas, true);

        var manager = new BABYLON.GUI.GUI3DManager(scene);
        /* var manager = new BABYLON.GUI.GUI3DManager(scene);
        var button1 = new BABYLON.GUI.HolographicButton("down");
        button1.setPosition(new BABYLON.Vector3(10, 10, 0));
        button1.text = "X"; */

        var box = BABYLON.Mesh.CreateBox("Box", 4.0, scene);
        return scene;
    var scene = createScene();

Is there a different src file I should be including?  Can I not use the GUI object when using the CDN src?  Any help would be appreciated for this JS and Babylon newb.

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.

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.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...