Skip to content
Snippets Groups Projects
Commit 9736bbcf authored by Greg Fodor's avatar Greg Fodor
Browse files

Merge branch 'master' of github.com:mozilla/hubs

parents ed623772 d62d4f0e
No related branches found
No related tags found
No related merge requests found
...@@ -89,7 +89,8 @@ AFRAME.registerComponent("character-controller", { ...@@ -89,7 +89,8 @@ AFRAME.registerComponent("character-controller", {
const rotationInvMatrix = new THREE.Matrix4(); const rotationInvMatrix = new THREE.Matrix4();
const pivotRotationMatrix = new THREE.Matrix4(); const pivotRotationMatrix = new THREE.Matrix4();
const pivotRotationInvMatrix = new THREE.Matrix4(); const pivotRotationInvMatrix = new THREE.Matrix4();
const start = new THREE.Vector3(); const startPos = new THREE.Vector3();
const startScale = new THREE.Vector3();
return function(t, dt) { return function(t, dt) {
const deltaSeconds = dt / 1000; const deltaSeconds = dt / 1000;
...@@ -98,7 +99,8 @@ AFRAME.registerComponent("character-controller", { ...@@ -98,7 +99,8 @@ AFRAME.registerComponent("character-controller", {
const distance = this.data.groundAcc * deltaSeconds; const distance = this.data.groundAcc * deltaSeconds;
const rotationDelta = this.data.rotationSpeed * this.angularVelocity * deltaSeconds; const rotationDelta = this.data.rotationSpeed * this.angularVelocity * deltaSeconds;
start.copy(root.position); startScale.copy(root.scale);
startPos.copy(root.position);
// Other aframe components like teleport-controls set position/rotation/scale, not the matrix, so we need to make sure to compose them back into the matrix // Other aframe components like teleport-controls set position/rotation/scale, not the matrix, so we need to make sure to compose them back into the matrix
root.updateMatrix(); root.updateMatrix();
...@@ -134,19 +136,13 @@ AFRAME.registerComponent("character-controller", { ...@@ -134,19 +136,13 @@ AFRAME.registerComponent("character-controller", {
// Reapply playspace (player rig) translation // Reapply playspace (player rig) translation
root.applyMatrix(trans); root.applyMatrix(trans);
// @TODO this is really ugly, can't just set the position/rotation directly or they wont network // TODO: the above matrix trnsfomraitons introduce some floating point erros in scale, this reverts them to avoid spamming network with fake scale updates
this.el.setAttribute("rotation", { root.scale.copy(startScale);
x: root.rotation.x * THREE.Math.RAD2DEG,
y: root.rotation.y * THREE.Math.RAD2DEG,
z: root.rotation.z * THREE.Math.RAD2DEG
});
this.pendingSnapRotationMatrix.identity(); // Revert to identity this.pendingSnapRotationMatrix.identity(); // Revert to identity
if (this.velocity.lengthSq() > EPS) { if (this.velocity.lengthSq() > EPS) {
this.setPositionOnNavMesh(start, root); this.setPositionOnNavMesh(startPos, root);
} else {
this.el.setAttribute("position", root.position);
} }
}; };
})(), })(),
......
...@@ -11,9 +11,11 @@ AFRAME.registerComponent("wasd-to-analog2d", { ...@@ -11,9 +11,11 @@ AFRAME.registerComponent("wasd-to-analog2d", {
s: [0, -1], s: [0, -1],
d: [1, 0] d: [1, 0]
}; };
this.onWasd = this.onWasd.bind(this);
this.keys = {}; this.keys = {};
this.onWasd = this.onWasd.bind(this);
this.move = this.move.bind(this); this.move = this.move.bind(this);
this.onBlur = this.onBlur.bind(this);
}, },
play: function() { play: function() {
...@@ -25,18 +27,24 @@ AFRAME.registerComponent("wasd-to-analog2d", { ...@@ -25,18 +27,24 @@ AFRAME.registerComponent("wasd-to-analog2d", {
// directly because ideally this would live as an input mapping, but the events // directly because ideally this would live as an input mapping, but the events
// generated by this component won't actually get mapped. // generated by this component won't actually get mapped.
this.el.sceneEl.addEventListener(this.data.analog2dOutputAction, this.move); this.el.sceneEl.addEventListener(this.data.analog2dOutputAction, this.move);
}, window.addEventListener("blur", this.onBlur);
move: function(event) {
this.el.emit("move", { axis: event.detail.axis });
}, },
pause: function() { pause: function() {
this.el.sceneEl.removeEventListener("wasd", this.onWasd); this.el.sceneEl.removeEventListener("wasd", this.onWasd);
this.el.sceneEl.removeEventListener(this.data.analog2dOutputAction, this.move); this.el.sceneEl.removeEventListener(this.data.analog2dOutputAction, this.move);
window.removeEventListener("blur", this.onBlur);
this.keys = {}; this.keys = {};
}, },
onBlur: function() {
this.keys = {};
},
move: function(event) {
this.el.emit("move", { axis: event.detail.axis });
},
onWasd: function(event) { onWasd: function(event) {
const keyEvent = event.type; const keyEvent = event.type;
const down = keyEvent.indexOf("down") !== -1; const down = keyEvent.indexOf("down") !== -1;
......
import "./assets/stylesheets/index.scss"; import "./assets/stylesheets/index.scss";
import React from "react"; import React from "react";
import ReactDOM from "react-dom"; import ReactDOM from "react-dom";
import HomeRoot from "./react-components/home-root";
import registerTelemetry from "./telemetry"; import registerTelemetry from "./telemetry";
import HomeRoot from "./react-components/home-root";
import InfoDialog from "./react-components/info-dialog.js";
import queryString from "query-string";
const qs = queryString.parse(location.search);
registerTelemetry(); registerTelemetry();
ReactDOM.render(<HomeRoot />, document.getElementById("home-root"));
ReactDOM.render(
<HomeRoot dialogType={qs.list_signup ? InfoDialog.dialogTypes.updates : null} />,
document.getElementById("home-root")
);
...@@ -27,7 +27,8 @@ const ENVIRONMENT_URLS = [ ...@@ -27,7 +27,8 @@ const ENVIRONMENT_URLS = [
class HomeRoot extends Component { class HomeRoot extends Component {
static propTypes = { static propTypes = {
intl: PropTypes.object intl: PropTypes.object,
dialogType: PropTypes.symbol
}; };
state = { state = {
...@@ -39,6 +40,7 @@ class HomeRoot extends Component { ...@@ -39,6 +40,7 @@ class HomeRoot extends Component {
componentDidMount() { componentDidMount() {
this.loadEnvironments(); this.loadEnvironments();
this.setState({ dialogType: this.props.dialogType });
document.querySelector("#background-video").playbackRate = 0.75; document.querySelector("#background-video").playbackRate = 0.75;
} }
......
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