Mouse mode: locked or hovering

How the mouse drives your app. Hovering: the pointer moves freely over the stream, as on a web page, for menus and buttons. Locked: the pointer is captured and moving the mouse turns the camera, as in a game. All three routes can switch it.

At a glance

Triggered fromWhat you callWorks on the production player today
iframepost {"cmd":"switchMouseControlSchemeTo","value":"LockedMouse"} to the frame, as a JSON stringYes
Web SDKe3ds_controller.switchMouseControlSchemeTo("LockedMouse")Yes
Unrealthe plugin's E3DS Change Mouse Control Scheme node, or the same command with Send Pixel Streaming ResponseYes

How the calls travel

All three routes reach the same function in the player. Locked only takes hold on the viewer's next click, because the browser captures the pointer only from a click.

Demos

iframe

iframe demo: Mouse: Hovering / Locked. Demo manual.

Web SDK

A Web SDK page with the two buttons.

Demo coming soon

Unreal

A sample project that switches when the viewer enters a menu.

Demo coming soon

How to do it

iframe

Post the command to the frame. It must be a JSON string: the player parses what it receives, and a plain object is ignored.

var frame = document.getElementById("e3ds");
frame.contentWindow.postMessage(
  JSON.stringify({ cmd: "switchMouseControlSchemeTo", value: "LockedMouse" }), "*");

// back to a free pointer
frame.contentWindow.postMessage(
  JSON.stringify({ cmd: "switchMouseControlSchemeTo", value: "HoveringMouse" }), "*");

Web SDK

e3ds_controller.switchMouseControlSchemeTo("LockedMouse");
e3ds_controller.switchMouseControlSchemeTo("HoveringMouse");

Unreal

With the E3DS Features plugin: add BP_E3DS_PS_Actor to your level and call E3DS Change Mouse Control Scheme, choosing HoveringMouse or LockedMouse.

Without the plugin: add a PixelStreamingInput component to an actor and send this with Send Pixel Streaming Response:

{"cmd":"switchMouseControlSchemeTo","value":"LockedMouse"}
{"cmd":"switchMouseControlSchemeTo","value":"HoveringMouse"}

Apps that have both menus and a free camera usually switch as the viewer moves between them.

Troubleshooting

What you seeWhyWhat to do
Switched to locked, but the pointer is still freeLocked takes hold on the viewer's next click; the browser only captures the pointer from a click.Expected. Tell the viewer to click into the stream.
Nothing happens from the iframeThe message was posted as an object, not a JSON string.Wrap it in JSON.stringify(...).
Nothing happens at allThe value is not exactly HoveringMouse or LockedMouse; anything else is ignored without a message.Use one of the two exact values.
The viewer is stuck in locked modeLocked keeps the pointer until the page releases it.The viewer presses Esc, or switch to HoveringMouse.

Last updated