UNPKG

@martinpham/react-360-mouse-lock-camera-controller

Version:

Provide Pointer Lock Camera Controller for your React 360 project. Now you can rotate camera inside 3D world freely using your mouse moves.

32 lines (29 loc) 1.29 kB
<html> <head> <title>r360</title> <style>body { margin: 0; }</style> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> </head> <body> <!-- Attachment point for your app --> <div id="container"></div> <div id="controller" style="z-index: 999;position: absolute;bottom: 0px;right:0px;"> <button onClick="window.postMessage({ type: 'KEYBOARD_CAMERA_CONTROLLER_MESSAGE', direction: 'UP'})"></button> <button onClick="window.postMessage({ type: 'KEYBOARD_CAMERA_CONTROLLER_MESSAGE', direction: 'UP'})"></button> <button onClick="window.postMessage({ type: 'KEYBOARD_CAMERA_CONTROLLER_MESSAGE', direction: 'DOWN'})"></button> <button onClick="window.postMessage({ type: 'KEYBOARD_CAMERA_CONTROLLER_MESSAGE', direction: 'RIGHT'})"></button> <button onClick="window.postMessage({ type: 'MOUSE_LOCK_CAMERA_CONTROLLER_MESSAGE', lock: true})">M</button> </div> <script src="./client.bundle?platform=vr"></script> <script> // Initialize the React 360 application React360.init( 'index.bundle?platform=vr&dev=true', document.getElementById('container'), { assetRoot: 'static_assets/', } ); </script> </body> </html>