Forum

User posts serge
22 September 2015 17:29
Thank you very much for your response.

Setting cameras to STATIC solved the problem
21 September 2015 22:00
Situation:

We are trying to implement blend4web into our project. A scene with multiple cameras positioned in various places is loaded into our app. We want to be able to read position and rotation of a chosen camera that exists in loaded scene and then tween the active camera to that position by changing its position and rotation every frame for a duration of tween.

(Please note that all of the code presented here is a pseudo-code.)

We are using “transform” module to retrieve target camera’s position:

var camTrans:Vec3 = request(“transform”).get_translation( myTargetCamera );

and set the target camera’s position by using:

request(“transform”).set_translation( myActiveCamera, newPositionX, newPositionY, newPositionZ );

This part works as expected.

When we are retrieving target camera’s rotation using “transform” module:

var camRotation:Quad = require(“transform”).get_rotation( myTargetCamera );

we get rotation values that seem to be incorrect.


For example when we export Blend4Web file from Blender I can see that “camera_01” is set to position of
x= 1.854, y= 3.409, z= -3.953
and its rotation to (in quat)
x=0.558, y=0.224, z=0.286 and w=0.746


After loading the file in our app and reading “camera_01” position and translation, translation numbers (x,y,z) are identical to what we see in Blender at export but the rotation values are incorrect:
x=0.428, y=0.195, z=-0.095 and w=0.877.


Questions:

How can we get correct camera rotation that is the same as it was in Blender at export?
How can we tween camera position and rotation from on-enter-frame-render approach.


Example of what we are trying to do (in pseudo-code):

var targetPosition:Vec3 = require(“transform”).get_translation( targetCamera );
var targetRotation:Quat = require(“transform”).get_rotation( targetCamera );

this.addEventListener( “onEnterFrame”, render );
Tween.To( currentPosition, tweenDurationTime, {x:targetPosition.x, y:targetPosition.y, z:targetPosition.z } );
Tween.To( currentRotation, tweenDurationTime, {x:targetRotation.x, y:targetRotation.y, z:targetRotation.z, w:targetRotation.w } );


function render() {
require(“transform”).set_translation( myActiveCamera, curentPosition.x, curentPosition.y, curentPosition.z );
require(“transform”).set_rotation( myActiveCamera, curentRotationQuat.x, curentRotationQuat.y, curentRotationQuat.z, curentRotationQuat.w );
}




Thank you.
16 September 2015 01:36
Hello.

I am new to blend4web.

In my project I have a new point in space generated on every frame in form of X, Y and Z coordinates. How can I move my active camera to that new point?

Pseudo code:

cameraX = 0;
cameraY = 0;
cameraZ = 0;

function onEnterFrame(){ // <- this function called every frame
cameraX += random(1…10);
cameraY += random(1…10);
cameraZ += random(1…10);
MoveActiveCameraTo( cameraX, cameraY, cameraZ );
}