From 7a90be0b1a6468b128a2479f3069503a2b9ab944 Mon Sep 17 00:00:00 2001 From: Sylvain Leroux Date: Mon, 9 May 2016 22:36:30 +0200 Subject: [PATCH 1/2] Skip hidden frames in the presentation --- js/player/Player.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/js/player/Player.js b/js/player/Player.js index 2ee09bde..37c9ceff 100644 --- a/js/player/Player.js +++ b/js/player/Player.js @@ -177,14 +177,25 @@ Object.defineProperty(Player, "targetFrame", { Object.defineProperty(Player, "previousFrameIndex", { get() { var index = this.animator.running ? this.targetFrameIndex : this.currentFrameIndex; - return (index + this.presentation.frames.length - 1) % this.presentation.frames.length; + + var prevFrame = index; + while((prevFrame = (prevFrame + this.presentation.frames.length - 1) % this.presentation.frames.length) != index) { + if (this.presentation.frames[prevFrame].showInFrameList) + return prevFrame; + } } }); Object.defineProperty(Player, "nextFrameIndex", { get() { var index = this.animator.running ? this.targetFrameIndex : this.currentFrameIndex; - return (index + 1) % this.presentation.frames.length; + + var nextFrame = index; + while((nextFrame = (nextFrame + 1) % this.presentation.frames.length) != index) { + console.dir(this.presentation.frames[nextFrame]); + if (this.presentation.frames[nextFrame].showInFrameList) + return nextFrame; + } } }); From 5ccb7b0bd2dd51da2ad05e828c4a4740c1e54c9e Mon Sep 17 00:00:00 2001 From: Sylvain Leroux Date: Mon, 9 May 2016 23:44:28 +0200 Subject: [PATCH 2/2] Add hierarchical frames --- js/player/Player.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/js/player/Player.js b/js/player/Player.js index 37c9ceff..b0124c5c 100644 --- a/js/player/Player.js +++ b/js/player/Player.js @@ -178,6 +178,7 @@ Object.defineProperty(Player, "previousFrameIndex", { get() { var index = this.animator.running ? this.targetFrameIndex : this.currentFrameIndex; + // Returns the previous non-hidden frame var prevFrame = index; while((prevFrame = (prevFrame + this.presentation.frames.length - 1) % this.presentation.frames.length) != index) { if (this.presentation.frames[prevFrame].showInFrameList) @@ -189,7 +190,14 @@ Object.defineProperty(Player, "previousFrameIndex", { Object.defineProperty(Player, "nextFrameIndex", { get() { var index = this.animator.running ? this.targetFrameIndex : this.currentFrameIndex; - + + // Check first if this is a sub-frame. + // If it is, the next frame should be its parent + var parent = this.parentFrameIndex(index); + if (parent > -1) + return parent; + + // Not a sub-frame, returns the next non-hidden frame var nextFrame = index; while((nextFrame = (nextFrame + 1) % this.presentation.frames.length) != index) { console.dir(this.presentation.frames[nextFrame]); @@ -199,6 +207,24 @@ Object.defineProperty(Player, "nextFrameIndex", { } }); +/* + * Returns the parent frame of the frame at index if it is a sub-frame. + * Otherwise, returns -1. + * + * Sub-frames are identified by their id of the form parentFrameId/subFrameId + */ +Player.parentFrameIndex = function(index) { + var frameId = this.presentation.frames[index].frameId; + var pos = frameId.lastIndexOf("/"); + if (pos === -1) // Not a sub-frame + return -1; + + var parentFrameId = frameId.substring(0, pos); + return this.presentation.frames.findIndex(frame => { + return frame.frameId === parentFrameId; + }); +}; + Player.showCurrentFrame = function () { this.viewport.setAtStates(this.currentFrame.cameraStates).update(); this.emit("frameChange");