Skip to content
Snippets Groups Projects
Commit 1d0a9946 authored by Brian Peiris's avatar Brian Peiris
Browse files

AR tweaks

parent c768e3a7
No related branches found
No related tags found
No related merge requests found
import queryString from "query-string";
const qs = queryString.parse(location.search);
const CLAMP_VELOCITY = 0.01;
const MAX_DELTA = 0.2;
......@@ -8,7 +10,8 @@ AFRAME.registerComponent("character-controller", {
easing: { default: 10 },
pivot: { type: "selector" },
snapRotationDegrees: { default: THREE.Math.DEG2RAD * 45 },
rotationSpeed: { default: -3 }
rotationSpeed: { default: -3 },
arScale: { type: 'number' }
},
init: function() {
......@@ -23,6 +26,8 @@ AFRAME.registerComponent("character-controller", {
},
update: function() {
const qsArScale = parseInt(qs.arScale, 10);
this.arScale = {x: qsArScale || this.data.arScale, y: qsArScale || this.data.arScale, z: qsArScale || this.data.arScale};
this.leftRotationMatrix = new THREE.Matrix4().makeRotationY(
this.data.snapRotationDegrees
);
......@@ -131,6 +136,11 @@ AFRAME.registerComponent("character-controller", {
this.el.setAttribute("position", root.position);
// Apply AR scale
if (this.data.arScale && qs.arScale) {
this.el.setAttribute('scale', this.arScale);
}
this.pendingSnapRotationMatrix.identity(); // Revert to identity
};
})(),
......
function registerNetworkSchemas() {
NAF.schemas.add({
template: "#player-template",
components: ["position", 'rotation', 'scale']
});
NAF.schemas.add({
template: "#nametag-template",
components: [
......
......@@ -60,6 +60,10 @@
<img id="water-normal-map" src="{{asset "assets/waternormals.jpg"}}"></a-asset-item>
<!-- Templates -->
<script id="player-template" type="text/html">
<a-entity></a-entity>
</script>
<script id="head-template" type="text/html">
<a-entity
class="head"
......@@ -122,10 +126,10 @@
<!-- Player Rig -->
<a-entity
id="player-rig"
networked
networked="template: #player-template;"
spawn-controller="radius: 4;"
wasd-to-analog2d
character-controller="pivot: #head"
character-controller="pivot: #head; arScale: 4"
>
<a-entity
id="head"
......@@ -139,6 +143,7 @@
<a-entity
id="body"
body-controller="eyeNeckOffset: 0 -0.11 0.09; neckHeight: 0.05"
xr="ar: false"
networked="template: #body-template;"
></a-entity>
<a-entity
......@@ -181,7 +186,6 @@
id="meeting-space"
cached-gltf-model="#meeting-space1-mesh"
position="0 0 0"
xr="ar: false"
></a-entity>
<a-entity
......@@ -218,7 +222,7 @@
<a-entity
id="water"
water="normalMap:#water-normal-map"
water="forceMobile: true; normalMap:#water-normal-map"
rotation="-90 0 0"
position="0 -88.358 -332.424"
xr="ar: false"
......
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