Skip to content

Commit 6ac28dc

Browse files
Merge pull request #11 from exokitxr/move-docs
Remove documentation
2 parents 19cffc8 + 523fc99 commit 6ac28dc

16 files changed

+1194
-26
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ node_modules/
99
npm-debug*.log
1010
public/
1111
src/_drafts
12-
src/docs
1312
debug.log

node_scripts/copyDocs.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,12 @@
3939
"version": "3.2.2"
4040
},
4141
"scripts": {
42-
"bumpdocs": "npm install exokitxr/exokit#master --ignore-scripts --no-optional && npm run installdocs",
43-
"copydocs": "node node_scripts/copyDocs.js",
4442
"copysrc": "cp -r COPYsrc/* public/",
4543
"clean": "hexo clean",
46-
"deploy": "npm run copydocs && npm run generate",
44+
"deploy": "npm run generate",
4745
"dev": "npm run clean && npm run generate:config && npm run server",
4846
"generate": "npm run clean && npm run generate:config && hexo generate && npm run copysrc",
4947
"generate:config": "yaml-cat _config.prod.yml _config.local.yml -n -m > _config.yml",
50-
"installdocs": "npm run copydocs",
5148
"server": "hexo server --debug",
5249
"start": "npm run dev",
5350
"test": "node script/checkLinks.js"

src/docs/api/iframeAPI.md

Lines changed: 250 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,250 @@
1+
---
2+
title: iframe Reality Layers
3+
type: api
4+
layout: docs
5+
order: 5
6+
parent_section: api
7+
---
8+
9+
Exokit implements normal [`<iframe>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe) functionality with the ability to do volumetric manipulation.
10+
11+
12+
## Create an iframe
13+
`const iframe = document.createElement('iframe');`
14+
15+
16+
- `iframe.src`
17+
- The URL or file path.
18+
- `iframe.positon`
19+
- The position vector as an array.
20+
- `iframe.scale`
21+
- The scale vector as an array.
22+
- `iframe.orientation`
23+
- The orientation quaternion as an array.
24+
- `iframe.d`
25+
- The dimensions of the iframe. `2` gives you DOM-to-texture. `3` gives you reality layers.
26+
27+
then the `iframe` needs to be put onto the session layers:
28+
`display.session.layers.push(iframe);`
29+
30+
## iframe Reality Layers example
31+
This section walks through the Reality Layers Exokit example. The `menumesh` refers to the GUI used in the example. See the full [realitytabs.html](https://github.com/exokitxr/exokit/blob/master/examples/realitytabs.html) example on GitHub.
32+
33+
34+
![Screenshot from 2019-03-05 18-45-14](https://user-images.githubusercontent.com/29695350/57206211-b0dd3300-6f89-11e9-8c45-63835f46f658.png)
35+
36+
### Create the iframe
37+
```js
38+
const iframe = document.createElement('iframe');
39+
iframe.onconsole = (jsString, scriptUrl, startLine) => {
40+
console.log('parent got console', {jsString, scriptUrl, startLine});
41+
};
42+
iframe.onload = function() {
43+
const contentDocument = (() => {
44+
try {
45+
if (this.contentDocument) { // this potentially throws
46+
return this.contentDocument;
47+
} else {
48+
return null;
49+
}
50+
} catch(err) {
51+
console.warn(err.stack);
52+
return null;
53+
}
54+
})();
55+
if (contentDocument) {
56+
_drawOk();
57+
// scene.background = null;
58+
} else {
59+
_drawFail();
60+
_closeTab(tab);
61+
if (focusedTab === tab) {
62+
focusedTab = rig.menuMesh.urlMesh;
63+
}
64+
rig.menuMesh.urlMesh.updateText();
65+
_updateRigLists();
66+
}
67+
};
68+
iframe.d = d;
69+
iframe.src = u;
70+
/* iframe.addEventListener('destroy', () => {
71+
// scene.background = _makeBackground();
72+
}); */
73+
const tab = _addTab(iframe, position, orientation, scale, d, local, id);
74+
};
75+
const _addTab = (iframe, position = new THREE.Vector3(), orientation = new THREE.Quaternion(), scale, d = 3, local = true, id = tabId++) => {
76+
if (scale === undefined) {
77+
scale = new THREE.Vector3(1, d === 3 ? 1 : window.innerHeight/window.innerWidth, 1);
78+
if (d !== 3) {
79+
scale.multiplyScalar(0.4);
80+
}
81+
}
82+
iframe.position = position.toArray();
83+
iframe.orientation = orientation.toArray();
84+
iframe.scale = scale.toArray();
85+
document.body.appendChild(iframe);
86+
const tab = {
87+
url: iframe.src,
88+
id,
89+
iframe,
90+
};
91+
tabs.push(tab);
92+
layers.push(iframe);
93+
focusedTab = tab;
94+
rig.menuMesh.urlMesh.updateText();
95+
rig.menuMesh.listMesh.updateList();
96+
return tab;
97+
};
98+
```
99+
100+
### Closing a tab
101+
```js
102+
const _closeTab = tab => {
103+
const {id, iframe} = tab;
104+
if (iframe.destroy) {
105+
iframe.destroy();
106+
}
107+
document.body.removeChild(iframe);
108+
tabs.splice(tabs.indexOf(tab), 1);
109+
layers.splice(layers.indexOf(iframe), 1);
110+
if (serverConnectedUrl) {
111+
const objectMesh = xrmp.getObjectMeshes().find(objectMesh => objectMesh.object.id === id);
112+
xrmp.removeObjectMesh(objectMesh);
113+
}
114+
};
115+
```
116+
117+
### Close all tabs
118+
```js
119+
const _closeAllTabs = () => { // XXX trigger this when switching servers
120+
for (let i = 0; i < tabs.length; i++) {
121+
const {iframe} = tab;
122+
if (iframe.destroy) {
123+
iframe.destroy();
124+
}
125+
document.body.removeChild(iframe);
126+
}
127+
tabs.length = 0;
128+
layers.length = 0;
129+
};
130+
```
131+
132+
### Send keys to iframe
133+
134+
```js
135+
window.addEventListener('keydown', e => {
136+
if (window.document.pointerLockElement) {
137+
switch (e.which) {
138+
case 87: { // W
139+
keys.up = true;
140+
/* if (!window.document.pointerLockElement) {
141+
renderer.domElement.requestPointerLock();
142+
} */
143+
break;
144+
}
145+
case 83: { // S
146+
keys.down = true;
147+
/* if (!window.document.pointerLockElement) {
148+
renderer.domElement.requestPointerLock();
149+
} */
150+
break;
151+
}
152+
case 65: { // A
153+
keys.left = true;
154+
/* if (!window.document.pointerLockElement) {
155+
renderer.domElement.requestPointerLock();
156+
} */
157+
break;
158+
}
159+
case 68: { // D
160+
keys.right = true;
161+
/* if (!window.document.pointerLockElement) {
162+
renderer.domElement.requestPointerLock();
163+
} */
164+
break;
165+
}
166+
case 69: { // E
167+
fakeDisplay.gamepads[1].buttons[2].pressed = true;
168+
break;
169+
}
170+
case 32: { // space
171+
keys.space = true;
172+
break;
173+
}
174+
case 17: { // ctrl
175+
keys.ctrl = true;
176+
break;
177+
}
178+
}
179+
} else {
180+
if (focusedTab) {
181+
if (focusedTab === rig.menuMesh.urlMesh) {
182+
rig.menuMesh.urlMesh.handleKey(e.keyCode, e.shiftKey);
183+
} else if (focusedTab.iframe) {
184+
focusedTab.iframe.sendKeyDown(e.which, {
185+
shiftKey: e.shiftKey,
186+
ctrlKey: e.ctrlKey,
187+
altKey: e.altKey,
188+
});
189+
}
190+
}
191+
}
192+
});
193+
window.addEventListener('keyup', e => {
194+
if (window.document.pointerLockElement) {
195+
switch (e.which) {
196+
case 87: { // W
197+
keys.up = false;
198+
break;
199+
}
200+
case 83: { // S
201+
keys.down = false;
202+
break;
203+
}
204+
case 65: { // A
205+
keys.left = false;
206+
break;
207+
}
208+
case 68: { // D
209+
keys.right = false;
210+
break;
211+
}
212+
case 69: { // E
213+
fakeDisplay.gamepads[1].buttons[2].pressed = false;
214+
break;
215+
}
216+
case 32: { // space
217+
keys.space = false;
218+
break;
219+
}
220+
case 17: { // ctrl
221+
keys.ctrl = false;
222+
break;
223+
}
224+
}
225+
} else {
226+
if (focusedTab && focusedTab.iframe) {
227+
focusedTab.iframe.sendKeyUp(e.which, {
228+
shiftKey: e.shiftKey,
229+
ctrlKey: e.ctrlKey,
230+
altKey: e.altKey,
231+
});
232+
}
233+
}
234+
});
235+
window.addEventListener('keypress', e => {
236+
if (!window.document.pointerLockElement) {
237+
if (focusedTab) {
238+
/* if (focusedTab === rig.menuMesh.urlMesh) {
239+
rig.menuMesh.urlMesh.handleKey(e.keyCode, e.shiftKey);
240+
} else */if (focusedTab.iframe) {
241+
focusedTab.iframe.sendKeyPress(e.which, {
242+
shiftKey: e.shiftKey,
243+
ctrlKey: e.ctrlKey,
244+
altKey: e.altKey,
245+
});
246+
}
247+
}
248+
}
249+
});
250+
```

src/docs/api/overview.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
title: Overview
3+
section_title: API
4+
type: api
5+
layout: docs
6+
order: 0
7+
parent_section: docs
8+
section_order: 5
9+
examples:
10+
---
11+
12+
Here are the main web specifications and third-party libraries implemented in Exokit.
13+
14+
## Web
15+
16+
| Tech | Type | Link | in Exokit |
17+
| ------------- |:-------------:|:-----:|-------:|
18+
| WebVR | Spec | [WebVR](https://developer.mozilla.org/en-US/docs/Web/API/WebVR_API) | [Source](https://github.com/exokitxr/exokit/blob/master/src/core.js) |
19+
| WebXR | Spec | [WebXR](https://github.com/immersive-web/webxr) | [Source](https://github.com/exokitxr/exokit/blob/master/src/XR.js ) |
20+
| React | Library | [React](https://reactjs.org/docs/getting-started.html) | [Source](https://github.com/exokitxr/exokit/blob/master/src/core.js) |
21+
| HTML5 | Spec | [HTML5](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5) | [Source](https://github.com/exokitxr/exokit/blob/master/src/core.js) |
22+
| CSS | Spec | [CSS](https://developer.mozilla.org/en-US/docs/Web/CSS) | [Source](https://github.com/exokitxr/exokit/blob/master/src/core.js) |
23+
| THREE.js | Library | [THREE.js](https://threejs.org/docs/) | [Source](https://github.com/exokitxr/exokit/blob/master/lib/three-min.js ) |
24+
| Express | Library | [Express](https://expressjs.com/en/api.html) | [Source](https://github.com/exokitxr/exokit/blob/master/src/core.js) |
25+
| WebSockets | Spec | [WebSockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) | [Source](https://github.com/exokitxr/exokit/blob/master/src/core.js) |
26+
| Fetch API | Spec | [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) | [Source](https://github.com/exokitxr/exokit/blob/master/src/core.js) |
27+
| Web Workers| Spec | [Web Workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) | [Source](https://github.com/exokitxr/exokit/blob/master/src/core.js) |
28+
| WebGL | Spec | [WebGL](https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API) | [Source](https://github.com/exokitxr/exokit/tree/master/deps/exokit-bindings/webglcontext ) |
29+
| Canvas API | Spec | [Canvas 2D](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API) | [Source]( https://github.com/exokitxr/exokit/tree/master/deps/exokit-bindings/canvas) |
30+
| WebAudio | Spec | [WebAudio](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API) | [Source](https://github.com/exokitxr/exokit/tree/master/deps/exokit-bindings/webaudiocontext ) |
31+
| WebRTC | Spec | [WebRTC](https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API) | [Source](https://github.com/exokitxr/exokit/tree/master/deps/exokit-bindings ) |
32+
33+
## Native
34+
35+
| Tech | Type | Link | in Exokit |
36+
| ------------- |:-------------:|:-----:|-------:|
37+
| OpenVR | SDK | [OpenVR](https://github.com/ValveSoftware/openvr/wiki/API-Documentation) | [Source]( https://github.com/exokitxr/exokit/tree/master/deps/openvr) |
38+
| OVR | SDK | [OVR from Oculus](https://developer.oculus.com/documentation/pcsdk/latest/concepts/pcsdk-intro/) | [Source]( https://github.com/exokitxr/exokit/tree/master/deps/oculus) |
39+
| Oculus Mobile| SDK | [Oculus Mobile SDK](https://developer.oculus.com/documentation/mobilesdk/latest/concepts/book-intro/) | [Source]( https://github.com/exokitxr/exokit/tree/master/deps/oculus-mobile) |
40+
| Google VR| SDK | [Google VR SDK](https://developers.google.com/vr/reference/) | [Source](https://github.com/exokitxr/exokit/tree/master/deps/exokit-bindings/ ) |
41+
| Magic Leap | SDK | [Magic Leap SDK](https://www.magicleap.com/creator) | [Source](https://github.com/exokitxr/exokit/tree/master/deps/exokit-bindings/magicleap ) |
42+
| Leap Motion| SDK | [Leap Motion Orion](https://developer.leapmotion.com/orion/) | [Source](https://github.com/exokitxr/exokit/tree/master/deps/exokit-bindings/leapmotion ) |
43+
| Zed| SDK | [Zed SDK](https://www.stereolabs.com/developers/) | [Source](https://github.com/exokitxr/exokit/tree/master/deps/exokit-bindings/ ) |
44+
45+
46+
## Platforms
47+
48+
| Tech | Type | Link | in Exokit |
49+
| ------------- |:-------------:|:-----:|-------:|
50+
| Node | Platform | [Node](https://nodejs.org/en/docs/) | [Source](https://github.com/modulesio/node-magicleap) |
51+
| Chromium | Platform | [Chromium](https://www.chromium.org/developers) | [Source](https://github.com/exokitxr/exokit/tree/master/deps/exokit-bindings ) |

0 commit comments

Comments
 (0)