From 10b6f68d3b07c604103b361695c3ff85ce764d95 Mon Sep 17 00:00:00 2001 From: Tarek Sherif Date: Mon, 4 May 2015 14:28:44 -0400 Subject: [PATCH 1/4] Added method getCurrentFrame() and event frameUpdate to morphGeometry node Provide information about the current 'frame' (target pair) that is currently being interpolated by the morph. --- src/core/scene/morphGeometry.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/core/scene/morphGeometry.js b/src/core/scene/morphGeometry.js index f3cba6b6..d55299f3 100644 --- a/src/core/scene/morphGeometry.js +++ b/src/core/scene/morphGeometry.js @@ -313,12 +313,18 @@ new (function () { } } + var frameUpdate = key1 != core.key1; + /* Normalise factor to range [0.0..1.0] for the target frame */ core.factor = (factor - keys[key1]) / (keys[key2] - keys[key1]); core.key1 = key1; core.key2 = key2; + if (frameUpdate) { + this.publish("frameUpdate", this.getCurrentFrame()); + } + this._engine.display.imageDirty = true; }; @@ -334,6 +340,18 @@ new (function () { return this._core.targets; }; + SceneJS.MorphGeometry.prototype.getCurrentFrame = function () { + var key1 = this._core.key1; + var key2 = this._core.key2; + return { + key1: key1, + key2: key2, + factor: this._core.factor, + target1: this._core.targets[key1], + target2: this._core.targets[key2] + } + }; + SceneJS.MorphGeometry.prototype._compile = function (ctx) { if (!this._core.hash) { From 60e6a06a2b9da109ad6e77e05ee6c21be7db444a Mon Sep 17 00:00:00 2001 From: Tarek Sherif Date: Mon, 4 May 2015 15:00:17 -0400 Subject: [PATCH 2/4] Minor optimization + example update --- examples/geometry_morphTargets.html | 12 +++++++++++- src/core/scene/morphGeometry.js | 11 ++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/examples/geometry_morphTargets.html b/examples/geometry_morphTargets.html index 71096f36..1634c262 100644 --- a/examples/geometry_morphTargets.html +++ b/examples/geometry_morphTargets.html @@ -12,6 +12,10 @@ -khtml-user-select: none; -webkit-user-select: none; } + + #morph-target-pair { + font-size: 16px; + } @@ -20,7 +24,8 @@
- SceneJS - geometry morph targets - trivial demo + SceneJS - geometry morph targets - trivial demo
+ Current target pair: 0-1