Forum

Where do I put my JS file?

19 September 2018 11:48
Hi,

Managed to create a project using the Project Manager. So far so good.
Now, I'd like to rotate my object continuously along z-axis.

Where do I put my JS file? How do I tell the Webplayer to find my JS files?

Thanks.

-ikel
19 September 2018 18:28
Hello,

As for combining Web Player and JS, read this: https://www.blend4web.com/en/forums/topic/3192/

Now, I'd like to rotate my object continuously along z-axis.
You don't need js for this. You can do it easily in Blender by putting animation keyframes on the z-axis. Then go to the object property panel and activate "Apply Default Animation -> Behavior: Loop".

But if you have a more complex project that requires JS, create a project of the Copy or Compile type. You will then get a .js file by the name of <projectname>.js.
19 September 2018 22:23
@Blend4Life,

Thanks for the reply and the link.

After creating a new project as Copy, I can now see a JS template to put additional code.

In Unity to put a continous rotation, I would normally put the code in update() function.
19 September 2018 23:51
In Blend4Web, you can add a frame callback - a custom function which will be called upon every frame update. Now, since the framerate is device-dependent, you would usually combine this with get_timeline() to ensure your code runs at the same speed on every machine. If you're interested in scripting object transformations, there is a pretty good tutorial on doing transformations with the API: Basic Manipulations in 3D Space


But again, usually you would do object transformation by animating objects in Blender and playing the animations in B4W. Of course, scripting (or Logic Nodes) may then be used to control the animations and offer interactivity. The piano scene is a good example of this. You can find the sources of this scene in Blend4Web Project Manager -> demos_interactivity -> piano.
 
Please register or log in to leave a reply.