A new lesson on object transformation programming

02 August 2016 16:29
Andrey Prakhov has written a new tutorial which certainly will help beginners in Blend4Web applications scripting. If it is not completely obvious to you how to give life to objects and move them with the help of programming code, you definitely have to pay attention to it.

Link to the article.
28 October 2016 15:15
I needed the scene or world to have zero gravity (the objects, or the balls I created from Blender should not fall).
If I set the objects as static in Blender, the set_translation does not work because the object should be dynamic.
But if I use dynamic/rigid, the objects fall (with gravity). I followed the example here.
28 October 2016 15:44
In order to use translation methods you should enable the Force Dynamic Object flag. You don't need to change physics settings.
Actually, Andrey has pointed this in the following screenshot:
01 November 2016 11:13
thank you. I'll try this.
04 November 2016 16:52
Hello, I tried again, but the yellowball (in the attached json file) does not collide with red ball, because they are static and I used "move local". And if I use rigid, they fall.
The balls should not fall since they are planets.
And then I decided to push up the blueball by 9.8 to achieve equilibrium but it looks like the engine is not working as it should be. There is a push going forward (y), I do not know where did it come from. I guess it is an engine bug.
Here is my code and it is also in the attachment.
"use strict"

b4w.register("gravity_simulation", function(exports, require) {

var m_app = require("app");
var m_data = require("data");
var m_scs = require("scenes");
var m_obj = require("objects");
var m_trans = require("transform");
var m_phy = require("physics");
var m_ctl = require("controls");
var m_cfg = require("config");
var m_version = require("version");

var DEBUG = (m_version.type() === "DEBUG");

var obj;
var yellowplanet;
var blueplanet;
var elapsed_sensor;

exports.init = function() {
canvas_container_id: "canvas_cont",
callback: init_cb,
physics_enabled: true,
show_fps: true,
alpha: false,
autoresize: true,
assets_dds_available: !DEBUG,
assets_min50_available: !DEBUG,
console_verbose: true

function init_cb(canvas_elem, success) {

if (!success) {
console.log("b4w init failure");

function load() {
m_data.load("gravity_simulation.json", load_cb);


var speed = 1;

function main_cb (obj, id) {
var elapsed = m_ctl.get_sensor_value(obj, id, 0); 
//m_trans.set_translation(planet,2, 0, 0);
m_trans.move_local(yellowplanet, speed*elapsed, 0, 0);	

function load_cb(data_id) {
elapsed_sensor = m_ctl.create_elapsed_sensor();
m_ctl.create_sensor_manifold(null, "MAIN", m_ctl.CT_CONTINUOUS, [elapsed_sensor], null, main_cb);
yellowplanet = m_scs.get_object_by_name("Yellow");
blueplanet = m_scs.get_object_by_name("Blue");
//m_phy.apply_force_world(obj, 5, -1, 0)
//m_trans.set_translation(obj,5, 0, 0);

//var loop = function () {
//	requestAnimationFrame(loop);
//m_trans.set_translation(obj,2, 0, 0);

//	requestAnimationFrame(loop);


04 November 2016 16:54
I forgot to tell, the "force dynamic object" did not solve the problem. Because I need an object that moves and at the same time collides (with physics), and does not fall.
04 November 2016 17:07
how to delete a comment?
07 November 2016 11:31
Change it to something like "delete this comment"
14 November 2016 11:52
Thank you. But I decided to just use Threejs. I will just use Blend4Web in my later projects.
01 August 2017 12:06
Hi, there.

Why quaternions not work, how you expect. This is my file, where I wrote the code, where quaternions work not properly.

Zip file:

Thank you every one, who help me.
Please register or log in to leave a reply.