Skip to content
This repository has been archived by the owner on Dec 15, 2020. It is now read-only.

fix: head locked surfaces sample #800

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Samples/HeadlockedSurfaces/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# HeadLockedSurfaces Sample

## How to use?

1. Create a new react-360 project with the following comand

```bat

$ npx react-360 init myProjectName

```

2. Replace the **client.js**, **index.html**, and the **index.js** files with the respective files in this directory

3. Run `yarn add webgl-ui` to install the [webgl-ui library](https://www.npmjs.com/package/webgl-ui)

4. Run `yarn start` to start up the application.
6 changes: 4 additions & 2 deletions Samples/HeadlockedSurfaces/client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Math as VRMath, ReactInstance, Surface} from 'react-360-web';
import {ReactInstance, Surface} from 'react-360-web';
import { Math as GLMath } from "webgl-ui";

function init(bundle, parent, options = {}) {
const horizontalPanel = new Surface(300, 300, Surface.SurfaceShape.Flat);
Expand All @@ -7,6 +8,7 @@ function init(bundle, parent, options = {}) {
horizontalPanel.setAngle(0, -0.5);

const cameraDirection = [0, 0, -1];
const { rotateByQuaternion } = GLMath;

const r360 = new ReactInstance(bundle, parent, {
fullScreen: true,
Expand All @@ -17,7 +19,7 @@ function init(bundle, parent, options = {}) {
cameraDirection[2] = -1;
// cameraDirection will point out from the view of the camera,
// we can use it to compute surface angles
VRMath.rotateByQuaternion(cameraDirection, cameraQuat);
rotateByQuaternion(cameraDirection, cameraQuat);
const cx = cameraDirection[0];
const cy = cameraDirection[1];
const cz = cameraDirection[2];
Expand Down
Loading