New controller scripting system, scripts, modes


Hey everyone! As I talked about in the alpha meeting today, I’ve been working on a lot of controller stuff and I’ve got some stuff to share with you.

First up, the old “Joystick” interface in javascript has been removed and every input device (keyboard, xbox controllers, playstation controllers, hydras) has been moved over to a new system that can be accessed via “Controller”. The basic idea is that there are a set group of actions (directional movement, pitch, yaw, zoom, which have default effects, and shift, action1, and action2, which are for use in scripting). All devices have default configurations that I picked because I thought they made sense, but the brilliance of the new system is that you can change them around however you want. As a result of these changes, certain scripts might stop working or not be needed anymore (notably, gamepad.js and hydraMove.js, let me know about any others). But as a trade off, most devices should just work when you plug them in.

Check out examples/example/script/controllerScriptingExamples.js for some examples of how stuff works. Beware, it’ll switch your forward and backward controls, but you can reset them with Controller.resetAllDeviceBindings(). A known issue is that the acceleration curve is hardcoded, so the sensitivities of directional movements won’t actually work, but you could take advantage of the sensitivities in some script if you wanted!

Eventually, it would be really nice to have some menu you could bring up to see all the mappings for all the devices and modify them via some dropdown menus or something. Someone more design-minded than me should look into that and maybe put up a worklist job!

Second, zooming! You can zoom now. That’s pretty much it. Shift+w to zoom in, shift+s to zoom out. If you zoom in enough, it’ll snap to first person mode, and snap back to third person when you zoom out. Cool.

Next up, center player in view mode. View->Center Player In View will keep your avatar’s head in the center of the screen as you move the camera around.

Next, examples/mouseLook.js. This was a requested mode and we might be making it the default at some point. While the script is running, you can toggle it with CTRL+M (which is different from the command for muting). Mouse movement (with or without right clicking) will move the camera, ‘a’, ‘d’, left arrow, and right arrow become strafing, and shift+those keys will rotate the camera. There are lots of updates for this script planned, so definitely tell us what you’d like to see.

And lastly, examples/hmdControls.js, which is included in this PR: All the details and stuff are up over there. I think it’ll also work as a pretty good template for any custom movement scripts.

…I think that’s everything I’ve been working on. I’ll continue updating these scripts to fix some of the issues I mentioned, but I wanted to get them out to you guys so you could play around with them.

Let me know what you guys think! Thanks for reading this wall of text.


Is the mouse scrollwheel also supported ?
So Shift+w to zoom in, shift+s to zoom out can be assigned to the mousewheel.


Yep, mouse wheel scrolling is supported. Using one of the new javascript functions you can actually get a list of all the available inputs for a device, which for the keyboard and mouse include a bunch of keys, touchpad events, mouse events, and mouse wheel events. Unfortunately, on Macs, wheel events conflict with the touchpad events, but on other systems you should already be able to zoom with the mouse wheel as part of the default configuration.


@SamGondelman A few issues …

Zooming in/out with Shift-W/S
Shift-Fwd/Bck arrow keys rotate the view up/down. I expect that Shift-W/S used to do the same.
Perhaps zooming in/out would be better controlled via Ctrl-W/S/Fwd/Bck.
Best to keep WASD and the arrow key controls doing the same as eachother.

Mouse scroll wheel
To me, the direction seems to be back to front.

MouseLook doesn’t work on Windows
Ctrl-M mutes/unmutes the microphone on Windows.

inspect.js no longer works
You used to be able to left-click-and-hold on an object then move your mouse and use Alt/Ctrl/Shift keys to zoom and rotate your camera view, akin to Second Life’s camera controls.


Right now, shift+e and shift+c adjust pitch, like shift+up and shift+down, but I agree that it would be nice if WASD and arrow keys behaved the same. How about shift+w/s/up/down for pitch, and shift+e/c for zooming?

I tested the wheel zooming on two machines and saw opposite results. I think it depends on how the mouse is configured. I can change the default configuration if most people feel that it’s backwards.

Would shift+m work for mouselook?

And I’ll take a look at inspect.js.


Correct noticed that strange action myself. if you want to zoom in tou need to scroll back ?!!?
ALso, i where hoping you can zoom closer to object, it seems for now you can only zoom away from the avatar so you see it from behind. can be usefull and nice too.


The mouse wheel is backwards for me too and not very useful either because the total zoom range seems to be only a few meters.

To be able to quickly zoom, orbit and pan around is a must for anyone who will spend any time positioning things, taking snapshots, or even just looking at objects and avatars.

I know that a goal here is to be able to use VR 3d sensor based input to control all aspects of the experience but until that is possible and even when it is, I think the design goal should have keyboard, mouse and sensor equivalents for all functions.

For camera control, using a mouse (or 3d sensor) plus a modifier button (Alt, MMB etc.), will always be faster and easier than any single key (arrow, wsad, pgup/down) scheme.

Before the Alt key was broken last week, ctrlaltdavid’s modified inspect.js almost worked well except for the problem that it used the center of the entity detected with the cast ray for the rotation origin rather than the actual detected position on the entity.

Having the rotation origin be at the center of the object causes problems when you have large objects near small ones.

For example it becomes impossible to orbit and zoom to see the base of a tree at the edge of a field because if you click on the field your center is the center of the field, and if you click on the tree, your center is the tree but half way up the tree and not at the base.

Sorry about the rant but, as Judas pointed out, even hanging a picture on a wall here can become a challenge.


inspect.js is working again … both the “official” one and my customized one.