Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clip starting frame #301

Open
wants to merge 3 commits into
base: 1.19
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 21 additions & 33 deletions engine/dist/emptyproject.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<!-- The Wick Engine build is injected here during the engine build step (see gulpfile.js) -->
<script>
/*Wick Engine https://github.com/Wicklets/wick-engine*/
var WICK_ENGINE_BUILD_VERSION = "2020.12.11.15.25.29";
var WICK_ENGINE_BUILD_VERSION = "2020.12.13.19.34.4";
/*!
* Paper.js v0.12.4 - The Swiss Army Knife of Vector Graphics Scripting.
* http://paperjs.org/
Expand Down Expand Up @@ -54400,16 +54400,16 @@
*/


getInstances() {// Implemented by subclasses
}
getInstances() {} // Implemented by subclasses

/**
* Check if there are any objects in the project that use this asset.
* @returns {boolean}
*/


hasInstances() {// Implemented by sublasses
}
hasInstances() {} // Implemented by sublasses

/**
* Remove all instances of this asset from the project. (Implemented by ClipAsset, ImageAsset, and SoundAsset)
*/
Expand Down Expand Up @@ -55463,8 +55463,8 @@
*/


removeAllInstances() {// TODO
}
removeAllInstances() {} // TODO

/**
* Load data in the asset
*/
Expand Down Expand Up @@ -57084,8 +57084,7 @@
this.timeline.activeLayer.addFrame(new Wick.Frame());
this._animationType = 'loop'; // Can be one of loop, oneFrame, single

this._singleFrameNumber = 1; // Default to 1, this value is only used if the animation type is single

this._singleFrameNumber = 1;
this._playedOnce = false;
this._isSynced = false;
this._removed = false;
Expand Down Expand Up @@ -57174,7 +57173,7 @@
if (bool) {
this.applySyncPosition();
} else {
this.timeline.playheadPosition = 1;
this.timeline.playheadPosition = this._singleFrameNumber;
}
}
/**
Expand Down Expand Up @@ -57283,11 +57282,7 @@


get singleFrameNumber() {
if (this.animationType !== 'single') {
return null;
} else {
return this._singleFrameNumber;
}
return this._singleFrameNumber;
}

set singleFrameNumber(frame) {
Expand All @@ -57310,12 +57305,12 @@
get syncFrame() {
let timelineOffset = this.parentClip.timeline.playheadPosition - this.parentFrame.start; // Show the last frame if we're past it on a playOnce Clip.

if (this.animationType === 'playOnce' && timelineOffset >= this.timeline.length) {
if (this.animationType === 'playOnce' && timelineOffset + this._singleFrameNumber >= this.timeline.length) {
return this.timeline.length;
} // Otherwise, show the correct frame.


return timelineOffset % this.timeline.length + 1;
return (timelineOffset + this._singleFrameNumber - 1) % this.timeline.length + 1;
}
/**
* Returns true if the clip has been played through fully once.
Expand Down Expand Up @@ -57393,22 +57388,15 @@


resetTimelinePosition() {
if (this.animationType === 'single') {
this.applySingleFramePosition();
} else {
this.timeline.playheadPosition = 1; // Reset timeline position if we are not on single frame.
}
this.applySingleFramePosition();
}
/**
* Updates the frame's single frame positions if necessary. Only works if the clip's animationType is 'single'.
*/


applySingleFramePosition() {
if (this.animationType === 'single') {
// Ensure that the single frame we've chosen is reflected no matter what.
this.timeline.playheadPosition = this.singleFrameNumber;
}
this.timeline.playheadPosition = this.singleFrameNumber;
}
/**
* Updates the clip's playhead position if the Clip is in sync mode
Expand Down Expand Up @@ -58360,7 +58348,7 @@

if (this.animationType === 'playOnce') {
this.playedOnce = false;
this.timeline.playheadPosition = 1;
this.timeline.playheadPosition = this._singleFrameNumber;
}
}

Expand Down Expand Up @@ -64362,22 +64350,22 @@
*/


onMouseDown(e) {// Implemeneted by subclasses.
}
onMouseDown(e) {} // Implemeneted by subclasses.

/**
* The function to call when the mouse drags this element.
*/


onMouseDrag(e) {// Implemeneted by subclasses.
}
onMouseDrag(e) {} // Implemeneted by subclasses.

/**
* The function to call when the mouse finishes a click on this element.
*/


onMouseUp(e) {// Implemeneted by subclasses.
}
onMouseUp(e) {} // Implemeneted by subclasses.

/**
* Causes the project to call it's onProjectModified function. Call this after modifying the project.
*/
Expand Down
54 changes: 21 additions & 33 deletions engine/dist/wickengine.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*Wick Engine https://github.com/Wicklets/wick-engine*/
var WICK_ENGINE_BUILD_VERSION = "2020.12.11.15.25.29";
var WICK_ENGINE_BUILD_VERSION = "2020.12.13.19.34.4";
/*!
* Paper.js v0.12.4 - The Swiss Army Knife of Vector Graphics Scripting.
* http://paperjs.org/
Expand Down Expand Up @@ -54385,16 +54385,16 @@ Wick.Asset = class extends Wick.Base {
*/


getInstances() {// Implemented by subclasses
}
getInstances() {} // Implemented by subclasses

/**
* Check if there are any objects in the project that use this asset.
* @returns {boolean}
*/


hasInstances() {// Implemented by sublasses
}
hasInstances() {} // Implemented by sublasses

/**
* Remove all instances of this asset from the project. (Implemented by ClipAsset, ImageAsset, and SoundAsset)
*/
Expand Down Expand Up @@ -55448,8 +55448,8 @@ Wick.SVGAsset = class extends Wick.FileAsset {
*/


removeAllInstances() {// TODO
}
removeAllInstances() {} // TODO

/**
* Load data in the asset
*/
Expand Down Expand Up @@ -57069,8 +57069,7 @@ Wick.Clip = class extends Wick.Tickable {
this.timeline.activeLayer.addFrame(new Wick.Frame());
this._animationType = 'loop'; // Can be one of loop, oneFrame, single

this._singleFrameNumber = 1; // Default to 1, this value is only used if the animation type is single

this._singleFrameNumber = 1;
this._playedOnce = false;
this._isSynced = false;
this._removed = false;
Expand Down Expand Up @@ -57159,7 +57158,7 @@ Wick.Clip = class extends Wick.Tickable {
if (bool) {
this.applySyncPosition();
} else {
this.timeline.playheadPosition = 1;
this.timeline.playheadPosition = this._singleFrameNumber;
}
}
/**
Expand Down Expand Up @@ -57268,11 +57267,7 @@ Wick.Clip = class extends Wick.Tickable {


get singleFrameNumber() {
if (this.animationType !== 'single') {
return null;
} else {
return this._singleFrameNumber;
}
return this._singleFrameNumber;
}

set singleFrameNumber(frame) {
Expand All @@ -57295,12 +57290,12 @@ Wick.Clip = class extends Wick.Tickable {
get syncFrame() {
let timelineOffset = this.parentClip.timeline.playheadPosition - this.parentFrame.start; // Show the last frame if we're past it on a playOnce Clip.

if (this.animationType === 'playOnce' && timelineOffset >= this.timeline.length) {
if (this.animationType === 'playOnce' && timelineOffset + this._singleFrameNumber >= this.timeline.length) {
return this.timeline.length;
} // Otherwise, show the correct frame.


return timelineOffset % this.timeline.length + 1;
return (timelineOffset + this._singleFrameNumber - 1) % this.timeline.length + 1;
}
/**
* Returns true if the clip has been played through fully once.
Expand Down Expand Up @@ -57378,22 +57373,15 @@ Wick.Clip = class extends Wick.Tickable {


resetTimelinePosition() {
if (this.animationType === 'single') {
this.applySingleFramePosition();
} else {
this.timeline.playheadPosition = 1; // Reset timeline position if we are not on single frame.
}
this.applySingleFramePosition();
}
/**
* Updates the frame's single frame positions if necessary. Only works if the clip's animationType is 'single'.
*/


applySingleFramePosition() {
if (this.animationType === 'single') {
// Ensure that the single frame we've chosen is reflected no matter what.
this.timeline.playheadPosition = this.singleFrameNumber;
}
this.timeline.playheadPosition = this.singleFrameNumber;
}
/**
* Updates the clip's playhead position if the Clip is in sync mode
Expand Down Expand Up @@ -58345,7 +58333,7 @@ Wick.Clip = class extends Wick.Tickable {

if (this.animationType === 'playOnce') {
this.playedOnce = false;
this.timeline.playheadPosition = 1;
this.timeline.playheadPosition = this._singleFrameNumber;
}
}

Expand Down Expand Up @@ -64347,22 +64335,22 @@ Wick.GUIElement = class {
*/


onMouseDown(e) {// Implemeneted by subclasses.
}
onMouseDown(e) {} // Implemeneted by subclasses.

/**
* The function to call when the mouse drags this element.
*/


onMouseDrag(e) {// Implemeneted by subclasses.
}
onMouseDrag(e) {} // Implemeneted by subclasses.

/**
* The function to call when the mouse finishes a click on this element.
*/


onMouseUp(e) {// Implemeneted by subclasses.
}
onMouseUp(e) {} // Implemeneted by subclasses.

/**
* Causes the project to call it's onProjectModified function. Call this after modifying the project.
*/
Expand Down
29 changes: 9 additions & 20 deletions engine/src/base/Clip.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Wick.Clip = class extends Wick.Tickable {
this.timeline.addLayer(new Wick.Layer());
this.timeline.activeLayer.addFrame(new Wick.Frame());
this._animationType = 'loop'; // Can be one of loop, oneFrame, single
this._singleFrameNumber = 1; // Default to 1, this value is only used if the animation type is single
this._singleFrameNumber = 1;
this._playedOnce = false;
this._isSynced = false;
this._removed = false;
Expand Down Expand Up @@ -141,7 +141,7 @@ Wick.Clip = class extends Wick.Tickable {
if (bool) {
this.applySyncPosition();
} else {
this.timeline.playheadPosition = 1;
this.timeline.playheadPosition = this._singleFrameNumber;
}
}

Expand Down Expand Up @@ -242,11 +242,7 @@ Wick.Clip = class extends Wick.Tickable {
* @type {number}
*/
get singleFrameNumber () {
if (this.animationType !== 'single') {
return null;
} else {
return this._singleFrameNumber;
}
return this._singleFrameNumber;
}

set singleFrameNumber (frame) {
Expand All @@ -269,12 +265,13 @@ Wick.Clip = class extends Wick.Tickable {
let timelineOffset = this.parentClip.timeline.playheadPosition - this.parentFrame.start;

// Show the last frame if we're past it on a playOnce Clip.
if (this.animationType === 'playOnce' && (timelineOffset >= this.timeline.length)) {
if (this.animationType === 'playOnce' &&
(timelineOffset + this._singleFrameNumber >= this.timeline.length)) {
return this.timeline.length;
}

// Otherwise, show the correct frame.
return (timelineOffset % this.timeline.length) + 1;
return ((timelineOffset + this._singleFrameNumber - 1) % this.timeline.length) + 1;
}

/**
Expand Down Expand Up @@ -348,21 +345,14 @@ Wick.Clip = class extends Wick.Tickable {
* Resets the clip's timeline position.
*/
resetTimelinePosition () {
if (this.animationType === 'single') {
this.applySingleFramePosition();
} else {
this.timeline.playheadPosition = 1; // Reset timeline position if we are not on single frame.
}
this.applySingleFramePosition();
}

/**
* Updates the frame's single frame positions if necessary. Only works if the clip's animationType is 'single'.
*/
applySingleFramePosition () {
if (this.animationType === 'single') {
// Ensure that the single frame we've chosen is reflected no matter what.
this.timeline.playheadPosition = this.singleFrameNumber;
}
this.timeline.playheadPosition = this.singleFrameNumber;
}

/**
Expand Down Expand Up @@ -1258,9 +1248,8 @@ Wick.Clip = class extends Wick.Tickable {

if (this.animationType === 'playOnce') {
this.playedOnce = false;
this.timeline.playheadPosition = 1;
this.timeline.playheadPosition = this._singleFrameNumber;
}

}

_onActive() {
Expand Down
Loading