diff --git a/src/components/character-controller.js b/src/components/character-controller.js index bd0a6617abaaaed5fdda9fc2e0c0811d97021a4c..3631c2a1eec0fb3c8e3515e699b97637a7eec6e7 100644 --- a/src/components/character-controller.js +++ b/src/components/character-controller.js @@ -1,3 +1,5 @@ +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 }; })(), diff --git a/src/network-schemas.js b/src/network-schemas.js index d93c552cb6b90a68ee158c66cd93475338c60408..ddb1538de2fae0644393f1ed777762aa96aa45dc 100644 --- a/src/network-schemas.js +++ b/src/network-schemas.js @@ -1,4 +1,8 @@ function registerNetworkSchemas() { + NAF.schemas.add({ + template: "#player-template", + components: ["position", 'rotation', 'scale'] + }); NAF.schemas.add({ template: "#nametag-template", components: [ diff --git a/templates/room.hbs b/templates/room.hbs index 8635f66560691c3caf2366c90bc19c2c1b7d82bc..7c45add06989a4b4f94ff0c1ff4dca14972f48f9 100644 --- a/templates/room.hbs +++ b/templates/room.hbs @@ -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"