Forum

Is code in "Creating Apps Quickly" still valid?

21 September 2015 00:29 #3956
I'm hoping to get a bit of time to spend with the SDK, and was going through the webpage here…

http://localhost:6687/deploy/doc/en/developers.html#developers

The code under "Loading Scenes In Apps" works OK…

<!DOCTYPE html>
<html>
<head>
<script src="b4w.min.js"></script>
<script>
function hello() {
    var m_main = b4w.require("main");
    var m_data = b4w.require("data");

    var canvas_elem = document.getElementById("canvas_id");
    m_main.init(canvas_elem);
    m_data.load("test_scene.json");
}
</script>
</head>

<body onload="hello()"><canvas id="canvas_id"></canvas></body>

</html>


However, the code under "Creating Apps Quickly" doesn't work…

<!DOCTYPE html>
<html>
<head>
<script src="b4w.full.min.js"></script>
<script>

var m_app = b4w.require("app");
var m_data = b4w.require("data");

m_app.init({
    canvas_container_id: "container_id",
    callback: load_cb
});

function load_cb()
    m_data.load("test_scene.json", loaded_cb);
}

function loaded_cb() {
    m_app.enable_controls();
    m_app.enable_camera_controls();
}

</script>
</head>

<body>
    <div id="container_id" style="width: 350px; height: 200px;"></div>
</body>

</html>


I've copied bw4.full.min.js and bw4.min.js into the folder OK, and as I mentioned above, the "Loading Scenes In Apps" works fine, so I'm not sure if the API has changed since the example code was put on that page.

21 September 2015 10:47 #3964
Hi! Thanks for testing. The code contains a minor bug - missing bracket here:
function load_cb()
    m_data.load("test_scene.json", loaded_cb);
}


We'll fix it soon.
Blend4Web Team
21 September 2015 14:44 #3978
Hi Ivan,

Ah, I was doing quick testing too late at night, I should have noticed that when I cut and pasted the code! :)
 
Please register or log in to leave a reply.