Is the .json scene supposed to be interactive?
16 October 2015 16:40
Hello
I've been trying to load a .json scene instead of using the direct html export and I can scene my 3D model but it's really small and there is no interactivity.
Is there something I have to do to enable the same basic functionalities in the .json file as I have in the direct html export? (rotation, zoom, etc..)
Thanks!
JD
I've been trying to load a .json scene instead of using the direct html export and I can scene my 3D model but it's really small and there is no interactivity.
Is there something I have to do to enable the same basic functionalities in the .json file as I have in the direct html export? (rotation, zoom, etc..)
Thanks!
JD
16 October 2015 17:04
16 October 2015 17:49
Hmmm I have no idea haha. Here's what I did:
Exported the default Blender scene (the cube) using B4W Export JSON
Copied the .json and .bin files in the root folder of my project besides the html file.
Copied b4w_min.js, uranium.js and uranium.js.mem in the same folder (I had an error when not copying uranium.js)
The code in the html is:
And I get this when I load the page
Exported the default Blender scene (the cube) using B4W Export JSON
Copied the .json and .bin files in the root folder of my project besides the html file.
Copied b4w_min.js, uranium.js and uranium.js.mem in the same folder (I had an error when not copying uranium.js)
The code in the html is:
<!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("myCanvas");
m_main.init(canvas_elem);
m_data.load("test.json");
}
</script>
</head>
<body onload="hello()"><canvas id="myCanvas"></canvas></body>
</html>
And I get this when I load the page
16 October 2015 18:14
Hello JD,
I suppose, you are following our short applicaition developer's guide because your code looks similar to the code from there. The next code snippet on this page is just what you need as it adds camera controls. Copied it for convenience:
I suppose, you are following our short applicaition developer's guide because your code looks similar to the code from there. The next code snippet on this page is just what you need as it adds camera controls. Copied it for convenience:
<!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("some_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>
16 October 2015 18:18