Forum

get ID value from javascript

27 March 2018 22:30
Hi!

The code: - Windturbine HTML & JS Code
Screenshot from app:
I want you to click on the small image - enter the ID in js code.
But… at the end of js code the function does not work. Why?
Console message: Uncaught ReferenceError: fv is not defined… I do not understand

    // place your code here
 
function fv(x) {
    alert(x.id);
}

Thank you for your answers
http://blender.hu Hungary Blender Community Site
28 March 2018 23:42
Your fv function is defined inside a scope of the specific callback, but in the html this function is called in global scope.
b4w.register("windturbine_app", function(exports, require) {
...
function fv(x) {
    alert(x.id);
}
...
});

You can solve this by moving the definition to the global scope:
b4w.register("windturbine_app", function(exports, require) {
...
});

function fv(x) {
    alert(x.id);
}

Or do not define events in html at all and use the approach from this example
var cont = m_cont.get_container();
cont.addEventListener("mousedown", mouse_cb, false);
Alexander (Blend4Web Team)
twitter
30 March 2018 21:35
Alexander!
Thank you very much for the answer. The second version is good, but … I want the camera to go to a position when the user clicks on the small icons. Then read information in a popup window. (So first camera motion, then popup) What would be the good solution? JSCallback or camera animation?

How can you control b4w (Camera move to Empty) with the result of a DOM event? (Click small image)
Thx!!!
http://blender.hu Hungary Blender Community Site
02 April 2018 11:34
JSCallback is the way to call JS from Logic Nodes. There is reverse method to call Logic Nodes from JS: run_entrypoint.

I think the simplest way is to use run_entrypoint. Don't forget to turn on "Run From Script" flag for your Entry Point node
Alexander (Blend4Web Team)
twitter
02 April 2018 20:00
Thx Alexander!
I have chosen a different solution. This source was the basis of:
Roman Sementsov - Source Files
Comment: - Roman -
The video shows a part of the operation:
Windturbine Presentation - WIP
I will present the final work soon

Thank you very much again
http://blender.hu Hungary Blender Community Site
08 April 2018 01:12
Alexander!!!!!
I would have another important question
I would like to limit the rotation (horizontal and vertical) of the camera when it comes to a new location. Where to enter the instructions?
Initial camera settings good work, but the in new position loses this feature.
- Camera Default Position (Show Limits - bottom right)
Video about the problem
(The camera rotation is limited after loading - It loses it in the new location (for example Blades))
I read the API. I know there is a function for this, but it does not work for me.
Horizontal Limits - Vertical Limits
Please help! THX!
…and I do not even know how to reverse play an animation with API (see js code at the end)
- My JS Code:
"use strict"

// register the application module
b4w.register("windturbine_app", function(exports, require) {

// import modules used by the app
var m_app       = require("app");
var m_cfg       = require("config");
var m_data      = require("data");
var m_preloader = require("preloader");
var m_ver       = require("version");
// my
var m_scenes    = require("scenes");
var m_cam       = require("camera");
var m_log_node  = require("logic_nodes");
var m_cam_anim  = require("camera_anim");
var m_trans     = require("transform");
var m_vec3      = require("vec3");
var m_anim      = require("animation");
var m_nla       = require("nla");

// detect application mode
var DEBUG = (m_ver.type() == "DEBUG");

// automatically detect assets path
var APP_ASSETS_PATH = m_cfg.get_assets_path("windturbine");
//my
var _vec3_tmp = new Float32Array(3);
var _vec3_tmp2 = new Float32Array(3);
var _vec3_tmp3 = new Float32Array(3);


/**
 * export the method to initialize the app (called at the bottom of this file)
 */
exports.init = function() {
    m_app.init({
        canvas_container_id: "main_canvas_container",
        callback: init_cb,
        show_fps: DEBUG,
        console_verbose: DEBUG,
        autoresize: true
    });
}

/**
 * callback executed when the app is initialized 
 */
function init_cb(canvas_elem, success) {

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

    //m_preloader.create_preloader();

    // ignore right-click on the canvas element
    canvas_elem.oncontextmenu = function(e) {
        e.preventDefault();
        e.stopPropagation();
        return false;
    };

    load();
}

/**
 * load the scene data
 */
function load() {
	var preloader_cont = document.getElementById("preloader_cont");
	preloader_cont.style.visibility = "visible";
	m_data.load(APP_ASSETS_PATH + "windturbine.json", load_cb, preloader_cb);
}

/**
 * update the app's preloader
 */
function preloader_cb(percentage) {
    var prelod_dynamic_path = document.getElementById("prelod_dynamic_path");
    var percantage_num      = prelod_dynamic_path.nextElementSibling;

    prelod_dynamic_path.style.width = percentage + "%";
    percantage_num.innerHTML = percentage + "%";	   
    if (percentage == 100) {
	var preloader_cont = document.getElementById("preloader_cont");
	preloader_cont.style.visibility = "hidden";
	//SIDE DIV HIDDEN
        document.getElementById('ldiv').style.display = 'block';
        document.getElementById('rdiv').style.display = 'block';
        return;
    }
}

/**
 * callback executed when the scene data is loaded
 */
function load_cb(data_id, success) {

	if (!success) {
        	console.log("b4w load failure");
        	return;
	}

	m_app.enable_camera_controls();

// place your code here
//————————————- POPUP ELEMENTS —————————--
var element = ['pblade', 'pbrk', 'pgear', 'pgen', 'pebox', 'plift', 'pgeart', 'pwsensor', 'pwssensor', 'pdfault'];

//—————-- TO BLADE MOVE ———————————-
	var blade_ico = document.getElementById("blade");
	blade_ico.addEventListener("click", function(e) {
		for (i = 0; i < element.length; i++) {
			document.getElementById(element[i]).style.display = 'none';
		}
		var cam_obj = m_scenes.get_active_camera();
		var final_cam_pos_obj = m_scenes.get_object_by_name("POS_blade");
		var final_target_obj = m_scenes.get_object_by_name("rotor");

		pos_to_blade(final_cam_pos_obj, final_target_obj);

		stop();
		show();

		m_cam.static_setup(cam_obj);
		var set_target_mode = function() {
			var target = m_trans.get_translation(final_target_obj, _vec3_tmp2);
			m_cam.target_setup(cam_obj, {pivot : target});
			
			document.getElementById('pblade').style.display = 'block';
       		}
        m_cam_anim.move_camera_to_point(cam_obj, final_cam_pos_obj, 5.0, 0.5, set_target_mode);
	}, false);
//&mdash;&mdash;&mdash;&mdash;&mdash;-- TO BLADE MOVE END &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
//&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
//&mdash;&mdash;&mdash;&mdash;&mdash;-- TO BREAK MOVE &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;--
	var break_ico = document.getElementById("brk");
	break_ico.addEventListener("click", function(e) {
		for (i = 0; i < element.length; i++) {
			document.getElementById(element[i]).style.display = 'none';
		}
		var cam_obj = m_scenes.get_active_camera();
		var final_cam_pos_obj = m_scenes.get_object_by_name("POS_brk");
		var final_target_obj = m_scenes.get_object_by_name("breakBox_");

		pos_to_break(final_cam_pos_obj, final_target_obj);

		stop();
		show();


		m_cam.static_setup(cam_obj);
		var set_target_mode = function() {
			var target = m_trans.get_translation(final_target_obj, _vec3_tmp2);
			m_cam.target_setup(cam_obj, {pivot : target});
			//&mdash; DELAY &mdash;
			setTimeout(function() {
				document.getElementById('pbrk').style.display = 'block';
			}, 2000);
       		}
        m_cam_anim.move_camera_to_point(cam_obj, final_cam_pos_obj, 5.0, 0.5, set_target_mode);
	}, false);
//&mdash;&mdash;&mdash;&mdash;&mdash;-- TO BREAK MOVE END &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
//&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
//&mdash;&mdash;&mdash;&mdash;&mdash;-- TO GEAR MOVE &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;--
	var gear_ico = document.getElementById("gear");
	gear_ico.addEventListener("click", function(e) {
		for (i = 0; i < element.length; i++) {
			document.getElementById(element[i]).style.display = 'none';
		}
		var cam_obj = m_scenes.get_active_camera();
		var final_cam_pos_obj = m_scenes.get_object_by_name("POS_gear");
		var final_target_obj = m_scenes.get_object_by_name("GearBox_B");

		pos_to_gear(final_cam_pos_obj, final_target_obj);

		stop();
		show();

		m_cam.static_setup(cam_obj);
		var set_target_mode = function() {
			var target = m_trans.get_translation(final_target_obj, _vec3_tmp2);
			m_cam.target_setup(cam_obj, {pivot : target});
			//&mdash; DELAY &mdash;
			setTimeout(function() {
				document.getElementById('pgear').style.display = 'block';
			}, 2000);
       		}
	
        m_cam_anim.move_camera_to_point(cam_obj, final_cam_pos_obj, 5.0, 0.5, set_target_mode);
	}, false);
//&mdash;&mdash;&mdash;&mdash;&mdash;-- TO GEAR MOVE END &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
//&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
//&mdash;&mdash;&mdash;&mdash;&mdash;-- TO GENERATOR MOVE &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;--
	var gen_ico = document.getElementById("gen");
	gen_ico.addEventListener("click", function(e) {
		for (i = 0; i < element.length; i++) {
			document.getElementById(element[i]).style.display = 'none';
		}
		var cam_obj = m_scenes.get_active_camera();
		var final_cam_pos_obj = m_scenes.get_object_by_name("POS_gen");
		var final_target_obj = m_scenes.get_object_by_name("generator");
	
		pos_to_gen(final_cam_pos_obj, final_target_obj);

		stop();
		show();

		m_cam.static_setup(cam_obj);
		var set_target_mode = function() {
			var target = m_trans.get_translation(final_target_obj, _vec3_tmp2);
			m_cam.target_setup(cam_obj, {pivot : target});
			//&mdash; DELAY &mdash;
			setTimeout(function() {
				document.getElementById('pgen').style.display = 'block';
			}, 2000);
       		}
        m_cam_anim.move_camera_to_point(cam_obj, final_cam_pos_obj, 5.0, 0.5, set_target_mode);
	}, false);
//&mdash;&mdash;&mdash;&mdash;&mdash;-- TO GENERATOR MOVE END &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
//&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
//&mdash;&mdash;&mdash;&mdash;&mdash;-- TO EBOX MOVE &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;--
	var ebox_ico = document.getElementById("ebox");
	ebox_ico.addEventListener("click", function(e) {
		for (i = 0; i < element.length; i++) {
			document.getElementById(element[i]).style.display = 'none';
		}
		var cam_obj = m_scenes.get_active_camera();
		var final_cam_pos_obj = m_scenes.get_object_by_name("POS_ebox");
		var final_target_obj = m_scenes.get_object_by_name("ebox5");
	
		pos_to_ebox(final_cam_pos_obj, final_target_obj);

		play();
		show();

		m_cam.static_setup(cam_obj);
		var set_target_mode = function() {
			var target = m_trans.get_translation(final_target_obj, _vec3_tmp2);
			m_cam.target_setup(cam_obj, {pivot : target});
			document.getElementById('pebox').style.display = 'block';
       		}
        m_cam_anim.move_camera_to_point(cam_obj, final_cam_pos_obj, 5.0, 0.5, set_target_mode);
	}, false);
//&mdash;&mdash;&mdash;&mdash;&mdash;-- TO EBOX MOVE END &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
//&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
//&mdash;&mdash;&mdash;&mdash;&mdash;-- TO LIFT MOVE &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;--
	var lift_ico = document.getElementById("lift");
	lift_ico.addEventListener("click", function(e) {
		for (i = 0; i < element.length; i++) {
			document.getElementById(element[i]).style.display = 'none';
		}
		var cam_obj = m_scenes.get_active_camera();
		var final_cam_pos_obj = m_scenes.get_object_by_name("POS_lift");
		var final_target_obj = m_scenes.get_object_by_name("lift");
	
		pos_to_lift(final_cam_pos_obj, final_target_obj);

		play();
		show();

		m_cam.static_setup(cam_obj);
		var set_target_mode = function() {
			var target = m_trans.get_translation(final_target_obj, _vec3_tmp2);
			m_cam.target_setup(cam_obj, {pivot : target});
			document.getElementById('plift').style.display = 'block';
       		}
        m_cam_anim.move_camera_to_point(cam_obj, final_cam_pos_obj, 5.0, 0.5, set_target_mode);
	}, false);
//&mdash;&mdash;&mdash;&mdash;&mdash;-- TO LIFT MOVE END &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
//&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
//&mdash;&mdash;&mdash;&mdash;&mdash;-- TO GEART MOVE &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;--
	var geart_ico = document.getElementById("geart");
	geart_ico.addEventListener("click", function(e) {
		for (i = 0; i < element.length; i++) {
			document.getElementById(element[i]).style.display = 'none';
		}
		var cam_obj = m_scenes.get_active_camera();
		var final_cam_pos_obj = m_scenes.get_object_by_name("POS_geart");
		var final_target_obj = m_scenes.get_object_by_name("towerGearEX");

		pos_to_geart(final_cam_pos_obj, final_target_obj);

		play();
		hide();

		m_cam.static_setup(cam_obj);
		var set_target_mode = function() {
			var target = m_trans.get_translation(final_target_obj, _vec3_tmp2);
			m_cam.target_setup(cam_obj, {pivot : target});
			document.getElementById('pgeart').style.display = 'block';
       		}
        m_cam_anim.move_camera_to_point(cam_obj, final_cam_pos_obj, 5.0, 0.5, set_target_mode);
	}, false);
//&mdash;&mdash;&mdash;&mdash;&mdash;-- TO LIFT MOVE END &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
//&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
//&mdash;&mdash;&mdash;&mdash;&mdash;-- TO WSENSOR MOVE &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;--
	var wsensor_ico = document.getElementById("wsensor");
	wsensor_ico.addEventListener("click", function(e) {
		for (i = 0; i < element.length; i++) {
			document.getElementById(element[i]).style.display = 'none';
		}
		var cam_obj = m_scenes.get_active_camera();
		var final_cam_pos_obj = m_scenes.get_object_by_name("POS_wsensor");
		var final_target_obj = m_scenes.get_object_by_name("sensors");
	
		pos_to_wsensor(final_cam_pos_obj, final_target_obj);

		play();
		show();

		m_cam.static_setup(cam_obj);
		var set_target_mode = function() {
			var target = m_trans.get_translation(final_target_obj, _vec3_tmp2);
			m_cam.target_setup(cam_obj, {pivot : target});
			document.getElementById('pwsensor').style.display = 'block';
       		}
        m_cam_anim.move_camera_to_point(cam_obj, final_cam_pos_obj, 5.0, 0.5, set_target_mode);
	}, false);
//&mdash;&mdash;&mdash;&mdash;&mdash;-- TO WSENSOR MOVE END &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
//&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
//&mdash;&mdash;&mdash;&mdash;&mdash;-- TO WSSENSOR MOVE &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;--
	var wssensor_ico = document.getElementById("wssensor");
	wssensor_ico.addEventListener("click", function(e) {
		for (i = 0; i < element.length; i++) {
			document.getElementById(element[i]).style.display = 'none';
		}
		var cam_obj = m_scenes.get_active_camera();
		var final_cam_pos_obj = m_scenes.get_object_by_name("POS_wssensor");
		var final_target_obj = m_scenes.get_object_by_name("sensorsWind");
	
		pos_to_wssensor(final_cam_pos_obj, final_target_obj);

		play();
		show();

		m_cam.static_setup(cam_obj);
		var set_target_mode = function() {
			var target = m_trans.get_translation(final_target_obj, _vec3_tmp2);
			m_cam.target_setup(cam_obj, {pivot : target});
			document.getElementById('pwssensor').style.display = 'block';
       		}
        m_cam_anim.move_camera_to_point(cam_obj, final_cam_pos_obj, 5.0, 0.5, set_target_mode);
	}, false);
//&mdash;&mdash;&mdash;&mdash;&mdash;-- TO WSSENOR MOVE END &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
//&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
//&mdash;&mdash;&mdash;&mdash;&mdash;-- TO DEFAULT MOVE &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;--
	var dfault_ico = document.getElementById("dfault");
	dfault_ico.addEventListener("click", function(e) {
		for (i = 0; i < element.length; i++) {
			document.getElementById(element[i]).style.display = 'none';
		}
		var cam_obj = m_scenes.get_active_camera();
		var final_cam_pos_obj = m_scenes.get_object_by_name("POS_default");
		var final_target_obj = m_scenes.get_object_by_name("rotor");

		pos_to_dfault(final_cam_pos_obj, final_target_obj);
		
		play();
		show();

		var towerGear = m_scenes.get_object_by_name("towerGear");
		m_scenes.show_object(towerGear);
		m_cam.static_setup(cam_obj);
		var set_target_mode = function() {
			var target = m_trans.get_translation(final_target_obj, _vec3_tmp2);
			m_cam.target_setup(cam_obj, {pivot : target});
			document.getElementById('pdfault').style.display = 'block';
       		}
        m_cam_anim.move_camera_to_point(cam_obj, final_cam_pos_obj, 5.0, 0.5, set_target_mode);
	}, false);
//&mdash;&mdash;&mdash;&mdash;&mdash;-- TO WSSENOR MOVE END &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
}

//&mdash;&mdash;&mdash;&mdash;&mdash;-- BLADE FUNCTION &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
function pos_to_blade(final_pos_obj, final_target_obj) {
    var final_pos = m_trans.get_translation(final_pos_obj, _vec3_tmp);
    var final_target = m_trans.get_translation(final_target_obj, _vec3_tmp2);
}
//&mdash;&mdash;&mdash;&mdash;&mdash;-- BREAK FUNCTION &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
function pos_to_break(final_pos_obj, final_target_obj) {
    var final_pos = m_trans.get_translation(final_pos_obj, _vec3_tmp);
    var final_target = m_trans.get_translation(final_target_obj, _vec3_tmp2);
    //&mdash;&mdash; OPEN DOOR
    dooropen();
}
//&mdash;&mdash;&mdash;&mdash;&mdash;-- GEAR FUNCTION &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
function pos_to_gear(final_pos_obj, final_target_obj) {
    var final_pos = m_trans.get_translation(final_pos_obj, _vec3_tmp);
    var final_target = m_trans.get_translation(final_target_obj, _vec3_tmp2);
}
//&mdash;&mdash;&mdash;&mdash;&mdash;-- GEN FUNCTION &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
function pos_to_gen(final_pos_obj, final_target_obj) {
    var final_pos = m_trans.get_translation(final_pos_obj, _vec3_tmp);
    var final_target = m_trans.get_translation(final_target_obj, _vec3_tmp2);
}
//&mdash;&mdash;&mdash;&mdash;&mdash;-- EBOX FUNCTION &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
function pos_to_ebox(final_pos_obj, final_target_obj) {
    var final_pos = m_trans.get_translation(final_pos_obj, _vec3_tmp);
    var final_target = m_trans.get_translation(final_target_obj, _vec3_tmp2);
}
//&mdash;&mdash;&mdash;&mdash;&mdash;-- LIFT FUNCTION &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
function pos_to_lift(final_pos_obj, final_target_obj) {
    var final_pos = m_trans.get_translation(final_pos_obj, _vec3_tmp);
    var final_target = m_trans.get_translation(final_target_obj, _vec3_tmp2);
}
//&mdash;&mdash;&mdash;&mdash;&mdash;-- GEART FUNCTION &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
function pos_to_geart(final_pos_obj, final_target_obj) {
    var final_pos = m_trans.get_translation(final_pos_obj, _vec3_tmp);
    var final_target = m_trans.get_translation(final_target_obj, _vec3_tmp2);
}
//&mdash;&mdash;&mdash;&mdash;&mdash;-- WSENSOR FUNCTION &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
function pos_to_wsensor(final_pos_obj, final_target_obj) {
    var final_pos = m_trans.get_translation(final_pos_obj, _vec3_tmp);
    var final_target = m_trans.get_translation(final_target_obj, _vec3_tmp2);
}
//&mdash;&mdash;&mdash;&mdash;&mdash;-- WSSENSOR FUNCTION &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
function pos_to_wssensor(final_pos_obj, final_target_obj) {
    var final_pos = m_trans.get_translation(final_pos_obj, _vec3_tmp);
    var final_target = m_trans.get_translation(final_target_obj, _vec3_tmp2);
}
//&mdash;&mdash;&mdash;&mdash;&mdash;-- DFAULT FUNCTION &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
function pos_to_dfault(final_pos_obj, final_target_obj) {
    var final_pos = m_trans.get_translation(final_pos_obj, _vec3_tmp);
    var final_target = m_trans.get_translation(final_target_obj, _vec3_tmp2);
}
//&mdash;&mdash;&mdash;- HIDE TOWER TOP MESH &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;--
function hide() {
	var towerGear = m_scenes.get_object_by_name("towerGear");
	m_scenes.hide_object(towerGear);
}
//&mdash;&mdash;&mdash; SHOW TOWER TOP MESH&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;--
function show() {
	var towerGear = m_scenes.get_object_by_name("towerGear");
	m_scenes.show_object(towerGear);
}
//&mdash;&mdash;&mdash;- BLADE ROT STOP&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
function stop() {
	var erotor = m_scenes.get_object_by_name("erotor");
	var startanim =  m_anim.get_anim_start_frame(erotor);
	m_anim.set_frame(erotor, startanim);
	m_anim.stop(erotor);
}
//&mdash;&mdash;&mdash;- BLADE ROT PLAY &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;-
function play() {
	var erotor = m_scenes.get_object_by_name("erotor");
	m_anim.play(erotor);
}
//&mdash;&mdash;- TOP DOORs OPEN &mdash;&mdash;&mdash;
function dooropen() {
	setTimeout(function(){
		var door1 = m_scenes.get_object_by_name("nacDoor_1");
		var door2 = m_scenes.get_object_by_name("nacDoor_2");
		m_anim.apply_def(door1);
		m_anim.apply_def(door2);
		m_anim.play(door1);
		m_anim.play(door2);
	}, 3000);
}
//&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;


});

// import the app module and start the app by calling the init method
b4w.require("windturbine_app").init();
http://blender.hu Hungary Blender Community Site
09 April 2018 20:44
Excuse me guys …
The above problem is partially solved, but … the dist_limit (zoom limit) affects the camera's final position. I now manually set it up. How to automatically solve it, but the starting position of the camera does not change
Example: A constant min / max distance limit (zoom) value for a given empty position. Can this be so?
http://blender.hu Hungary Blender Community Site
18 April 2018 13:00
Help me please!
I've solved a lot of things … but the animation does not work well.
How to play animation halfway? (I tried the NLA animation, but the playback did not start)
Parameters:
The total length of the animation is 120 frames
Opening length: 59 frames (1-59)
Closing length: 59 frames (61-120)
I want a door to open at an event to close to another event. How should this be done?
My function:
// OPEN DOORS
function dooropen() {
	setTimeout(function(){
		var door1 = m_scenes.get_object_by_name("nacDoor_1");
		var door2 = m_scenes.get_object_by_name("nacDoor_2");
		m_anim.apply(door1, "nacDoor_1Action");
		m_anim.apply(door2, "nacDoor_2Action");

		m_anim.set_frame(door1);
		m_anim.set_frame(door2);
		m_anim.play(door1);
		m_anim.play(door2);

/* a door animation - source: API documentation
(Set the last frame of the object's animation - version 16.12) - not good - play to the end (1 to 120)

		slot_num = m_anim.SLOT_4;
		var start = m_anim.get_anim_start_frame(door2, slot_num);
		var len = m_anim.get_anim_length(door2, slot_num);
		m_anim.set_frame(door2, start+len-m_anim.LAST_FRAME_EPSILON, slot_num);
		m_anim.play(door2);
*/
	}, 4000);
}

THX!!!



PS.
Sorry guys… everything [SOLVED]… but I still have a question
http://blender.hu Hungary Blender Community Site
 
Please register or log in to leave a reply.