由用户创建的信息 Blend4Life
24 December 2019 21:27
You don't need to make your own "load_wait" because m_data.load() has a built-in callback for load completion, so you can use that to set up any load order you want:
function load_first() {
var id_of_first = m_data.load("first_file_to_be_loaded", load_second);
}
function load_second() {
var id_of_second = m_data.load("second_file_to_be_loaded", load_third);
}
function load_third() {
var id_of_third = m_data.load("third_file_to_be_loaded");
}
// start load sequence:
load_first();
16 November 2017 20:28
There seem to be no callbacks fired by sfx.play(), and no sensors for sound in general. Maybe I'm missing something because almost every other event in B4W has a callback upon termination.
I only found sfx.is_playing(obj), so I would have to hook that into a frame callback if there is nothing else.
Is there a better/simpler/more convenient way to do it?
I only found sfx.is_playing(obj), so I would have to hook that into a frame callback if there is nothing else.
Is there a better/simpler/more convenient way to do it?
10 October 2017 20:35
Thanks Konstantin,
I have done exactly that for the time being. Do I take it from your wording "…for now to export…" that a future version will handle this issue properly in runtime?
I think it would be very important considering the ubiquitous use of these modifiers, and the great potential of reducing filesize etc (50% for the Mirror Modifier).
I have done exactly that for the time being. Do I take it from your wording "…for now to export…" that a future version will handle this issue properly in runtime?
I think it would be very important considering the ubiquitous use of these modifiers, and the great potential of reducing filesize etc (50% for the Mirror Modifier).
08 October 2017 22:47
Take the start-up scene and cut the cube in half, then use the Mirror Modifier to restore the full cube shape. I get the same result in Blender Viewport / B4W Fast Preview:
However, if I apply an additional Array Modifier to the cube, I get cubes in Blender but only half-cubes in B4W:
Of course, I can still get the right result by checking "apply modifiers" (before export) to pre-apply the Mirror Modifier, but that means the Array Modifier gets pre-applied too and if you have large arrays or complex objects (or both), you'll end up with unacceptably large polygon counts/file sizes.
I could swear this combo of modifiers still worked in my scenes up to B4W 17.02, but no longer in 17.08. (I cannot test it though because I no longer have 17.02 installed.)
However, if I apply an additional Array Modifier to the cube, I get cubes in Blender but only half-cubes in B4W:
Of course, I can still get the right result by checking "apply modifiers" (before export) to pre-apply the Mirror Modifier, but that means the Array Modifier gets pre-applied too and if you have large arrays or complex objects (or both), you'll end up with unacceptably large polygon counts/file sizes.
I could swear this combo of modifiers still worked in my scenes up to B4W 17.02, but no longer in 17.08. (I cannot test it though because I no longer have 17.02 installed.)
04 October 2017 00:24
02 October 2017 22:46
30 September 2017 20:14
I have a (custom element) anchor that must follow the movements of a bone in an armature. (The anchor div with a descriptive text is supposed to follow the bone.)
I tried the "Copy Location" constraint and set the correct bone, but in B4W the anchor only follows the armature (origin) itself, not the specified bone, so I guess this is not supported yet? But maybe somebody knows a way (or a hack) to achieve this effect?
I tried the "Copy Location" constraint and set the correct bone, but in B4W the anchor only follows the armature (origin) itself, not the specified bone, so I guess this is not supported yet? But maybe somebody knows a way (or a hack) to achieve this effect?
29 August 2017 18:08
You attach an "elapsed" sensor to the object, then move the object by speed * elapsed with m_trans.move_local in the sensor's callback function.
Here's a code example:
There is a nice tutorial about this: Basic Manipulations in 3D Space
Here's a code example:
var m_ctl = require("control");
var m_trans = require("transform");
var m_scs = require("scenes");
// Define your movement parameters:
var name_of_my_object = "my_objects_name"; // Fill in the (Blender) name of your object.
var x_speed = 1; // Set your desired speed along X axis (0 for no movement in this axis).
var y_speed = -0.5; // Set your desired speed along Y axis (0 for no movement in this axis).
var z_speed = 0; // Set your desired speed along Z axis (0 for no movement in this axis).
// Set up sensor:
var elapsed_sensor = m_ctl.create_elapsed_sensor();
m_ctl.create_sensor_manifold(m_scs.get_object_by_name(name_of_my_object), "MOVE", m_ctl.CT_CONTINUOUS, [elapsed_sensor], null, move_cb);
// Callback function:
function move_cb (obj, id) {
var elapsed = m_ctl.get_sensor_value(obj, id, 0);
m_trans.move_local(obj, x_speed*elapsed, y_speed*elapsed, z_speed*elapsed);
}
There is a nice tutorial about this: Basic Manipulations in 3D Space
03 August 2017 08:20
I tried transform.set_scale, but it does not work on physics objects.
I also tried shape keys, and they work, but only on the object mesh - the object's collision bounds do not change along with the mesh, and therefore it's insufficient for my purpose (I need correct collision detection of the object after its size or shape change). Using update_boundings() did not help.
I also tried shape keys, and they work, but only on the object mesh - the object's collision bounds do not change along with the mesh, and therefore it's insufficient for my purpose (I need correct collision detection of the object after its size or shape change). Using update_boundings() did not help.