r/janusVR • u/dizzket Dot Matrix and Wikiverse • Nov 05 '14
JavaScript Behavioral System
I've already discussed this with a lot of people, but I wanted to write it down and put it up for discussion.
The beauty of Janus is that it's a canvas, and it allows for extreme flexibility. Instead of doing movement and animation for the player, why not have Javascript that handles it all?
This way, people can specify animation triggers, code themselves to act like different objects (aeroplanes,trains,cars,animals,bikes,etc.).
Animations would be assigned a js_id, and be referenced from an animations array.
if (player.speed > 3)
{
player.animation_speed = player.speed;
playAnimation("ani_run");
}
else
{
playAnimation(room.animations["ani_stand"]);
}Rooms could also force a behavioral scripts on users via the JanusVR markup for rooms with specific purposes.
3
Upvotes
2
u/codenamesrcl Gallivanting Developer Nov 05 '14 edited Nov 05 '14
pretty sure animations can be done as is, maybe not on the user, but definitely on objects. For users we'd have to have access to the individual avatar components (and a lot of other things for that matter now that I think about it...). Part of me wants to see if full blown animation rigging will be possible with the inclusion of collada, but in the context of the JS question, i'll share my thoughts on a fleshed out library.
I imagine loops would be fairly straightforward to code, would have to be tailor made to every single target though so a general animations library would be more like a template for what kind of animations to do and probably a helper for basic manipulations like rotations and translations so that sequence loops can be constructed instead of hard coding every single animation (tween sequences).
I'd say just go for it and make a quick sequencer library and global manager/handler to handle stuff on a per object basis. Could start small and just do translations, construct sequences of translations for a group of objects to act in tandem, then run it on an object group (grouping can be done by the managing library onload). If that looks good and works well from an fps standpoint, then can build out the respective libraries from there. Sounds like a fun weekend project or a project to practice medium-high level javascript. Could exclude some elements to make it a decent way to learn basic javascript in the context of Janus.