Forum

Add a stopwatch / timer

20 March 2018 12:14
Hello,

I'm a beginner in Blend4Web, and I don't know much about coding…
I would like to add a stopwatch and extract the position data of the HMD i'm using (Oculus rift) for a university experiment (so I can get the position of the HMD according to the time).

I've been trying to copy/paste the following code (from the API Guide):
"import register from "first_person_character/util/register.js";

import m_time_fact from "first_person_charatcer/intern/time.js";

/**

* Time API.

* @module time

*/

function Time(ns, exports) {

var m_time = m_time_fact(ns);

/**

* Set a new timeout.

* this method has the same behavior as window.setTimeout(), except it uses

* engine's timeline.

* @method module:time.set_timeout

* @param {timeout_callback} callback Timeout callback

* @param {number} time Timeout

* @returns {number} Timeout ID

*/"

I've also been trying to put this code that I found here:
http://blender.freemovies.co.uk/blend4web/game/my_simple_game.js
with the corresponding nodes on the node editor.
I also modified it so it would fit my file, but nothing happened…

I guess I miswrite some code, or didn't do a right path with the nodes.

I hope I've been clear enought, if not, ask me
Thank you for your time,

Marie-Philippine
22 March 2018 01:30
Hello! And welcome to our forum!

Have you seen the VR code snippet?
Alexander (Blend4Web Team)
twitter
22 March 2018 12:06
Hello!

Thank you for your answer!
I am going to try creating a new project starting with the VR code snippet
22 March 2018 14:42
When I try to make a new project based on the VR code snippet, this message appears "The requested resource is not available, please return to the home page." (erreur 404). Is there a special way to name the file for it to be created?

And when I copy/paste the html and javascript code in a simple project, the project stops loading at 78%.
Do you have any idea of what I should do?
22 March 2018 14:50
When I try to make a new project based on the VR code snippet, this message appears "The requested resource is not available, please return to the home page." (erreur 404)

You should click this button when you open code snippets from your local server (use direct link, or open Project manager and find code snippets project there).


And when I copy/paste the html and javascript code in a simple project, the project stops loading at 78%.
Do you have any idea of what I should do?

See the web-browser console (F12).
Alexander (Blend4Web Team)
twitter
22 March 2018 16:13
It worked! Thank you
 
Please register or log in to leave a reply.