From fbec93d9ce6be4fad234e18d628f19830e193de6 Mon Sep 17 00:00:00 2001 From: Francesco Gallo Date: Mon, 24 Jan 2022 12:17:18 +0100 Subject: [PATCH 1/3] Fix "callByType" returning only undefined values --- viewer/viewer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/viewer/viewer.js b/viewer/viewer.js index 1134a73..a9427ea 100644 --- a/viewer/viewer.js +++ b/viewer/viewer.js @@ -204,7 +204,7 @@ export class Viewer { callByType(method, types, ...args) { let elems = types.map((i) => this.viewObjectsByType.get(i) || []) .reduce((a, b) => a.concat(b), []) - .map((o) => o.oid); + .map((o) => o.uniqueId); // Assuming all passed methods return a promise return method.call(this, elems, ...args); } From 18862b0862147999888e4b2b728c3cfa4bc285ea Mon Sep 17 00:00:00 2001 From: Francesco Gallo Date: Tue, 19 Apr 2022 17:39:43 +0200 Subject: [PATCH 2/3] Update vec3.js --- viewer/glmatrix/vec3.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/viewer/glmatrix/vec3.js b/viewer/glmatrix/vec3.js index 21b423e..f8a0e05 100644 --- a/viewer/glmatrix/vec3.js +++ b/viewer/glmatrix/vec3.js @@ -399,6 +399,27 @@ export function lerp(out, a, b, t) { return out; } +/** + * Performs a cosine interpolation between two vec3's + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {vec3} out + */ +export function cerp(out, a, b, t) { + let ax = a[0]; + let ay = a[1]; + let az = a[2]; + + let delta = (1-Math.cos(t*Math.PI))/2; + out[0] = ax + delta * (b[0] - ax); + out[1] = ay + delta * (b[1] - ay); + out[2] = az + delta * (b[2] - az); + return out; +} + /** * Performs a hermite interpolation with two control points * From aaa7abfa3cf8362cac0ff80bc5e0a1ce21c4a2e3 Mon Sep 17 00:00:00 2001 From: Francesco Gallo Date: Tue, 19 Apr 2022 17:40:21 +0200 Subject: [PATCH 3/3] Update animatedvec3.js --- viewer/animatedvec3.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/viewer/animatedvec3.js b/viewer/animatedvec3.js index cdb1d10..22d6749 100644 --- a/viewer/animatedvec3.js +++ b/viewer/animatedvec3.js @@ -28,7 +28,7 @@ export class AnimatedVec3 { t = 1; b = true; } - vec3.lerp(this.tmp, this.a, this.b, t); + vec3.cerp(this.tmp, this.a, this.b, t); if (b) { if (this.t2) { this.t0 = this.t1; @@ -73,4 +73,4 @@ export class AnimatedVec3 { } } -AnimatedVec3.ACTIVE_ANIMATIONS = 0; \ No newline at end of file +AnimatedVec3.ACTIVE_ANIMATIONS = 0;