Skip to content
Snippets Groups Projects
Commit 73659479 authored by Robert Long's avatar Robert Long
Browse files

Add rig-selector.

parent 5a0a6e7e
No related branches found
No related tags found
No related merge requests found
...@@ -24,14 +24,49 @@ ...@@ -24,14 +24,49 @@
<script id="hand-template" type="text/html"> <script id="hand-template" type="text/html">
<a-box scale="0.1 0.1 0.1"></a-box> <a-box scale="0.1 0.1 0.1"></a-box>
</script> </script>
</a-assets>
<a-entity id="player" networked="template:#player-template;showLocalTemplate:false;" wasd-controls> <script id="vive-rig" type="text/html">
<a-entity camera="userHeight: 1.6" look-controls networked="template:#head-template;showLocalTemplate:false;"></a-entity> <a-entity id="player" networked="template:#player-template;showLocalTemplate:false;" wasd-controls>
<a-entity camera="userHeight: 1.6" look-controls networked="template:#head-template;showLocalTemplate:false;"></a-entity>
<a-entity hand-controls="left" teleport-controls="cameraRig: #player" networked="template:#hand-template;showLocalTemplate:true;"></a-entity>
<a-entity hand-controls="right" teleport-controls="cameraRig: #player" networked="template:#hand-template;showLocalTemplate:true;"></a-entity>
</a-entity>
</script>
<script id="oculus-rig" type="text/html">
<a-entity id="player" networked="template:#player-template;showLocalTemplate:false;" wasd-controls>
<a-entity camera="userHeight: 1.6" look-controls networked="template:#head-template;showLocalTemplate:false;"></a-entity>
<a-entity oculus-touch-controls="left" teleport-controls="cameraRig:#player;button:trigger;" networked="template:#hand-template;showLocalTemplate:true;"></a-entity>
<a-entity oculus-touch-controls="right" teleport-controls="cameraRig:#player;button:trigger;" networked="template:#hand-template;showLocalTemplate:true;"></a-entity>
</a-entity>
</script>
<script id="daydream-rig" type="text/html">
<a-entity id="player" networked="template:#player-template;showLocalTemplate:false;" wasd-controls>
<a-entity camera="userHeight: 1.6" look-controls networked="template:#head-template;showLocalTemplate:false;"></a-entity>
<a-entity daydream-controls networked="template:#hand-template;showLocalTemplate:true;"></a-entity>
</a-entity>
</script>
<script id="gearvr-rig" type="text/html">
<a-entity id="player" networked="template:#player-template;showLocalTemplate:false;" wasd-controls>
<a-entity camera="userHeight: 1.6" look-controls networked="template:#head-template;showLocalTemplate:false;"></a-entity>
<a-entity gearvr-controls networked="template:#hand-template;showLocalTemplate:true;"></a-entity>
</a-entity>
</script>
<script id="dolly-rig" type="text/html">
<a-entity id="player" networked="template:#player-template;showLocalTemplate:false;" wasd-controls>
<a-entity camera="userHeight: 1.6" look-controls networked="template:#head-template;showLocalTemplate:false;"></a-entity>
</a-entity>
</script>
</a-assets>
<a-entity hand-controls="left" networked="template:#hand-template;showLocalTemplate:true;"></a-entity> <a-entity rig-selector="vive:#vive-rig;oculus:oculus-rig;daydream:#daydream-rig;desktop:#dolly-rig;mobile:dolly-rig;"></a-entity>
<a-entity hand-controls="right" networked="template:#hand-template;showLocalTemplate:true;"></a-entity>
</a-entity>
<a-plane src="#ground" color="#7BC8A4" height="100" width="100" rotation="-90 0 0"></a-plane> <a-plane src="#ground" color="#7BC8A4" height="100" width="100" rotation="-90 0 0"></a-plane>
<a-sky color="#ECECEC"></a-sky> <a-sky color="#ECECEC"></a-sky>
......
AFRAME.registerComponent("rig-selector", {
schema: {
vive: { default: "" },
oculus: { default: "" },
daydream: { default: "" },
gearvr: { default: "" },
mobile: { default: "" },
desktop: { default: "" }
},
init: function() {
var vrDevice = this.el.sceneEl.effect.getVRDisplay();
var rigEl = document.createElement("a-entity");
if (vrDevice !== undefined) {
var displayName = vrDevice.displayName;
if (displayName.indexOf("Oculus") !== -1) {
rigEl.setAttribute(
"template",
"src:" + this.data.oculus || this.data.desktop
);
} else if (displayName.indexOf("OpenVR") !== -1) {
rigEl.setAttribute(
"template",
"src:" + this.data.vive || this.data.desktop
);
} else if (displayName.indexOf("Daydream") !== -1) {
rigEl.setAttribute(
"template",
"src:" + this.data.daydream || this.data.mobile
);
} else {
rigEl.setAttribute(
"template",
"src:" + this.data.desktop || this.data.mobile
);
}
} else {
if (AFRAME.utils.device.isGearVR()) {
rigEl.setAttribute(
"template",
"src:" + this.data.gearvr || this.data.mobile
);
} else if (AFRAME.utils.device.isMobile()) {
rigEl.setAttribute(
"template",
"src:" + this.data.mobile || this.data.desktop
);
} else {
rigEl.setAttribute(
"template",
"src:" + this.data.desktop || this.data.mobile
);
}
}
this.el.appendChild(rigEl);
}
});
require("networked-aframe"); require("networked-aframe");
require("./components/rig-selector");
console.log("test2");
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment