From 40b41c27c7f64270fa5873e771ff3987de1a89c2 Mon Sep 17 00:00:00 2001 From: joni <johnfshaughnessy@gmail.com> Date: Thu, 3 May 2018 16:17:49 -0700 Subject: [PATCH] Add dirty predicates --- src/components/character-controller.js | 3 - src/network-schemas.js | 84 +++++++++++++++++++++++--- 2 files changed, 75 insertions(+), 12 deletions(-) diff --git a/src/components/character-controller.js b/src/components/character-controller.js index d294172f5..e6db4c82b 100644 --- a/src/components/character-controller.js +++ b/src/components/character-controller.js @@ -114,9 +114,6 @@ AFRAME.registerComponent("character-controller", { pivotRotationMatrix.makeRotationAxis(rotationAxis, pivot.rotation.y); pivotRotationInvMatrix.makeRotationAxis(rotationAxis, -pivot.rotation.y); this.updateVelocity(deltaSeconds); - if (this.velocity.x === 0 && this.velocity.y === 0 && this.velocity.z === 0) { - return; - } move.makeTranslation(this.velocity.x * distance, this.velocity.y * distance, this.velocity.z * distance); yawMatrix.makeRotationAxis(rotationAxis, rotationDelta); diff --git a/src/network-schemas.js b/src/network-schemas.js index d30176a29..92d31cca7 100644 --- a/src/network-schemas.js +++ b/src/network-schemas.js @@ -2,9 +2,19 @@ function registerNetworkSchemas() { NAF.schemas.add({ template: "#remote-avatar-template", components: [ - "position", + { + component: "position", + dirtyPredicate: { + type: NAF.PREDICATE_XYZ_ALMOST_EQUALS, + epsilon: 0.01 + } + }, { component: "rotation", + dirtyPredicate: { + type: NAF.PREDICATE_XYZ_ALMOST_EQUALS, + epsilon: 1 + }, lerp: false }, "scale", @@ -12,19 +22,35 @@ function registerNetworkSchemas() { "networked-avatar", { selector: ".camera", - component: "position" + component: "position", + dirtyPredicate: { + type: NAF.PREDICATE_XYZ_ALMOST_EQUALS, + epsilon: 0.01 + } }, { selector: ".camera", - component: "rotation" + component: "rotation", + dirtyPredicate: { + type: NAF.PREDICATE_XYZ_ALMOST_EQUALS, + epsilon: 1 + } }, { selector: ".left-controller", - component: "position" + component: "position", + dirtyPredicate: { + type: NAF.PREDICATE_XYZ_ALMOST_EQUALS, + epsilon: 0.01 + } }, { selector: ".left-controller", - component: "rotation" + component: "rotation", + dirtyPredicate: { + type: NAF.PREDICATE_XYZ_ALMOST_EQUALS, + epsilon: 1 + } }, { selector: ".left-controller", @@ -32,11 +58,19 @@ function registerNetworkSchemas() { }, { selector: ".right-controller", - component: "position" + component: "position", + dirtyPredicate: { + type: NAF.PREDICATE_XYZ_ALMOST_EQUALS, + epsilon: 0.01 + } }, { selector: ".right-controller", - component: "rotation" + component: "rotation", + dirtyPredicate: { + type: NAF.PREDICATE_XYZ_ALMOST_EQUALS, + epsilon: 1 + } }, { selector: ".right-controller", @@ -47,12 +81,44 @@ function registerNetworkSchemas() { NAF.schemas.add({ template: "#video-template", - components: ["position", "rotation", "visible"] + components: [ + { + component: "position", + dirtyPredicate: { + type: NAF.PREDICATE_XYZ_ALMOST_EQUALS, + epsilon: 0.01 + } + }, + { + component: "rotation", + dirtyPredicate: { + type: NAF.PREDICATE_XYZ_ALMOST_EQUALS, + epsilon: 1 + } + }, + "visible" + ] }); NAF.schemas.add({ template: "#interactable-template", - components: ["position", "rotation", "scale"] + components: [ + { + component: "position", + dirtyPredicate: { + type: NAF.PREDICATE_XYZ_ALMOST_EQUALS, + epsilon: 0.01 + } + }, + { + component: "rotation", + dirtyPredicate: { + type: NAF.PREDICATE_XYZ_ALMOST_EQUALS, + epsilon: 1 + } + }, + "scale" + ] }); } -- GitLab