diff --git a/aframe.exokit.scene.html b/aframe.exokit.scene.html
new file mode 100644
index 0000000..b69e8da
--- /dev/null
+++ b/aframe.exokit.scene.html
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/aframe-exokit-v2.js b/src/aframe-exokit-v2.js
new file mode 100644
index 0000000..f1aeb15
--- /dev/null
+++ b/src/aframe-exokit-v2.js
@@ -0,0 +1,67 @@
+var axrengine = document.createElement("script"); // create a script DOM node
+axrengine.src = "http://localhost:6969/local-exokit-web/exokit-web/src/a-xr-engine.js"; // set its src to the provided URL
+
+document.head.appendChild(axrengine);
+
+window.mainCanvas = null;
+
+AFRAME.registerSystem('bind-exokit-aframe-canvas', {
+ init: function() {
+ console.info('AFRAME.system.init')
+ var sceneEl = this.sceneEl;
+
+ console.info(document.getElementsByClassName("a-canvas")[0]);
+ window.mainCanvas = document.getElementsByClassName("a-canvas")[0];
+ // if(0) setTimeout(function() {
+ try {
+ navigator.xr.requestSession('immersive-vr').then((session)=> {
+ console.info('got session', session)
+ console.info('exiting VR')
+ sceneEl.exitVR();
+ }).catch((err)=>console.error('crashless-vrless error:' + err));
+ } catch(e) { console.warn('navigator.xr error:'+e); }
+ // }, 500);
+ },
+ tick: function() {
+ // this.sceneEl.camera.rotation.y+=.01;
+ },
+ });
+
+ AFRAME.registerComponent('wireframe', {
+ dependencies: ['material'],
+ init: function () {
+ this.el.components.material.material.wireframe = true;
+ }
+ });
+
+ function generateXREngine(context) {
+
+ const xrEngine = new XREngine();
+ top.xrEngine = xrEngine;
+ xrEngine.canvas = window.mainCanvas;
+ xrEngine.context = window.mainCanvas.$webgl;
+ // alert(xrEngine.canvas);
+ xrEngine.innerHTML = '';
+ context.appendChild(xrEngine);
+ xrEngine.addEventListener('load', function() { console.log("XR ENGINE LOADED : : : ---")});
+ xrEngine.enterXr();
+
+ }
+
+ AFRAME.registerComponent('xr-engine', {
+ init: function() {
+ var context = this.el;
+ console.info('a-xr-engine', this.data)
+
+ setTimeout(function() {
+ generateXREngine(context);
+ }, 1000);
+ },
+ tick: function() {
+ //this.el.object3D.rotation.y+=.05;
+ },
+ });
+
+ AFRAME.registerElement("a-xr-engine", { prototype: AFRAME.AEntity.prototype });
+ AFRAME.registerElement("a-xr-site", { prototype: AFRAME.AEntity.prototype });
+ AFRAME.registerElement("a-xr-iframe", { prototype: AFRAME.AEntity.prototype });
\ No newline at end of file
diff --git a/src/xr-engine.js b/src/xr-engine.js
index 955955e..a786f1c 100644
--- a/src/xr-engine.js
+++ b/src/xr-engine.js
@@ -73,14 +73,20 @@ const XREngineProto = {
win.baseLayer = null;
win.install = () => {
if (!win.canvas) {
- win.canvas = document.createElement('canvas');
- win.canvas.width = GlobalContext.xrState.renderWidth[0] * 2;
- win.canvas.height = GlobalContext.xrState.renderHeight[0];
- win.canvas.style.width = '100%';
- win.canvas.style.height = '100%';
- win.canvas.addEventListener('mousedown', e => {
- e.preventDefault();
- });
+ // win.canvas = document.createElement('canvas');
+ if(document.getElementsByClassName("a-canvas")[0]) {
+ win.canvas = document.getElementsByClassName("a-canvas")[0];
+ } else {
+ win.canvas = document.createElement('canvas');
+ alert("Made new one.");
+ }
+ // win.canvas.width = GlobalContext.xrState.renderWidth[0] * 2;
+ // win.canvas.height = GlobalContext.xrState.renderHeight[0];
+ // win.canvas.style.width = '100%';
+ // win.canvas.style.height = '100%';
+ // win.canvas.addEventListener('mousedown', e => {
+ // e.preventDefault();
+ // });
win.canvas.addEventListener('mouseenter', e => {
const {x, y, width, height} = win.canvas.getBoundingClientRect();
GlobalContext.xrState.canvasViewport[0] = x;
@@ -88,11 +94,13 @@ const XREngineProto = {
GlobalContext.xrState.canvasViewport[2] = width;
GlobalContext.xrState.canvasViewport[3] = height;
});
- win.ctx = win.canvas.getContext(window.WebGL2RenderingContext ? 'webgl2' : 'webgl', {
+ win.ctx = win.canvas.$webgl2; if(0) getContext(window.WebGL2RenderingContext ? 'webgl2' : 'webgl', {
antialias: true,
alpha: true,
xrCompatible: true,
});
+ console.info("win.ctx: ", win.ctx);
+
win.ctx.bindFramebuffer = (_bindFramebuffer => function bindFramebuffer(target, fbo) { // XXX return the correct undone binding in gl.getParameter
if (!fbo) {
fbo = win.ctx.xrFramebuffer;
@@ -108,11 +116,11 @@ const XREngineProto = {
if (this._canShadow) {
if (!this.shadow) {
- this.shadow = this.attachShadow({mode: 'closed'});
+ // this.shadow = this.attachShadow({mode: 'closed'});
}
- this.shadow.appendChild(win.canvas);
+ // this.shadow.appendChild(win.canvas);
} else {
- this.insertAdjacentElement('afterend', win.canvas);
+ // this.insertAdjacentElement('afterend', win.canvas);
}
this.dispatchEvent(new MessageEvent('canvas', {