mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Merge remote-tracking branch 'origin/3.6-beta' into 3.6-beta
This commit is contained in:
commit
2bf79e8519
19
CHANGELOG.md
19
CHANGELOG.md
@ -69,6 +69,25 @@
|
|||||||
* `AtasRegionAttacher` and `SpriteAttacher` are now part of `Example Modules`, to reflect that they are meant to be used as sample code rather than production.
|
* `AtasRegionAttacher` and `SpriteAttacher` are now part of `Example Modules`, to reflect that they are meant to be used as sample code rather than production.
|
||||||
* In the unitypackage, the "spine-csharp" and "spine-unity" folders are now inside a "Spine" folder. This change will only affect fresh imports. Importing the unitypackage to update Spine-Unity in your project will update the appropriate files wherever you have moved them.
|
* In the unitypackage, the "spine-csharp" and "spine-unity" folders are now inside a "Spine" folder. This change will only affect fresh imports. Importing the unitypackage to update Spine-Unity in your project will update the appropriate files wherever you have moved them.
|
||||||
|
|
||||||
|
## Java
|
||||||
|
* **Breaking changes**
|
||||||
|
* `Skeleton.getBounds` takes a scratch array as input so it doesn't have to allocate a new array on each invocation itself. Reduces GC activity.
|
||||||
|
* Removed `Bone.worldToLocalRotationX` and `Bone.worldToLocalRotationY`. Replaced by `Bone.worldToLocalRotation` (rotation given relative to x-axis, counter-clockwise, in degrees).
|
||||||
|
* Added `stride` parameter to `VertexAttachment.computeWorldVertices`.
|
||||||
|
* Removed `RegionAttachment.vertices` field. The vertices array is provided to `RegionAttachment.computeWorldVertices` by the API user now.
|
||||||
|
* Removed `RegionAttachment.updateWorldVertices`, added `RegionAttachment.computeWorldVertices`. The new method now computes the x/y positions of the 4 vertices of the corner and places them in the provided `worldVertices` array, starting at `offset`, then moving by `stride` array elements when advancing to the next vertex. This allows to directly compose the vertex buffer and avoids a copy. The computation of the full vertices, including vertex colors and texture coordinates, is now done by the backend's respective renderer.
|
||||||
|
* **Additions**
|
||||||
|
* Added support for local and relative transform constraint calculation, including additional fields in `TransformConstraintData`
|
||||||
|
* Added `Bone.localToWorldRotation`(rotation given relative to x-axis, counter-clockwise, in degrees).
|
||||||
|
* Added two color tinting support, including `TwoColorTimeline` and additional fields on `Slot` and `SlotData`.
|
||||||
|
* Added `PointAttachment`, additional method `newPointAttachment` in `AttachmentLoader` interface.
|
||||||
|
* Added `ClippingAttachment`, additional method `newClippingAttachment` in `AttachmentLoader` interface.
|
||||||
|
|
||||||
|
### libGDX
|
||||||
|
* Fixed renderer to work with 3.6 changes
|
||||||
|
* Added support for two color tinting. Use the new `TwoColorPolygonBatch` together with `SkeletonRenderer`
|
||||||
|
* Added support for clipping. See `SkeletonClipper`. Used automatically by `SkeletonRenderer`. Does not work when using a `SpriteBatch` with `SkeletonRenderer`. Use `PolygonSpriteBatch` or `TwoColorPolygonBatch` instead.
|
||||||
|
|
||||||
## Lua
|
## Lua
|
||||||
* **Breaking changes**
|
* **Breaking changes**
|
||||||
* Removed `Bone:worldToLocalRotationX` and `Bone:worldToLocalRotationY`. Replaced by `Bone:worldToLocalRotation` (rotation given relative to x-axis, counter-clockwise, in degrees).
|
* Removed `Bone:worldToLocalRotationX` and `Bone:worldToLocalRotationY`. Replaced by `Bone:worldToLocalRotation` (rotation given relative to x-axis, counter-clockwise, in degrees).
|
||||||
|
|||||||
Binary file not shown.
@ -27,7 +27,6 @@
|
|||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
package spine.animation {
|
package spine.animation {
|
||||||
import spine.MathUtils;
|
import spine.MathUtils;
|
||||||
import spine.Bone;
|
import spine.Bone;
|
||||||
@ -52,6 +51,7 @@ package spine.animation {
|
|||||||
internal var queue : EventQueue;
|
internal var queue : EventQueue;
|
||||||
internal var propertyIDs : Dictionary = new Dictionary();
|
internal var propertyIDs : Dictionary = new Dictionary();
|
||||||
internal var animationsChanged : Boolean;
|
internal var animationsChanged : Boolean;
|
||||||
|
public var multipleMixing : Boolean = false;
|
||||||
public var timeScale : Number = 1;
|
public var timeScale : Number = 1;
|
||||||
internal var trackEntryPool : Pool;
|
internal var trackEntryPool : Pool;
|
||||||
|
|
||||||
@ -198,7 +198,9 @@ package spine.animation {
|
|||||||
var timelineCount : int = from.animation.timelines.length;
|
var timelineCount : int = from.animation.timelines.length;
|
||||||
var timelines : Vector.<Timeline> = from.animation.timelines;
|
var timelines : Vector.<Timeline> = from.animation.timelines;
|
||||||
var timelinesFirst : Vector.<Boolean> = from.timelinesFirst;
|
var timelinesFirst : Vector.<Boolean> = from.timelinesFirst;
|
||||||
var alpha : Number = from.alpha * entry.mixAlpha * (1 - mix);
|
var timelinesLast : Vector.<Boolean> = multipleMixing ? null : from.timelinesLast;
|
||||||
|
var alphaBase : Number = from.alpha * entry.mixAlpha;
|
||||||
|
var alphaMix : Number = alphaBase * (1 - mix);
|
||||||
|
|
||||||
var firstFrame : Boolean = from.timelinesRotation.length == 0;
|
var firstFrame : Boolean = from.timelinesRotation.length == 0;
|
||||||
if (firstFrame) from.timelinesRotation.length = timelineCount << 1;
|
if (firstFrame) from.timelinesRotation.length = timelineCount << 1;
|
||||||
@ -207,6 +209,7 @@ package spine.animation {
|
|||||||
for (var i : int = 0; i < timelineCount; i++) {
|
for (var i : int = 0; i < timelineCount; i++) {
|
||||||
var timeline : Timeline = timelines[i];
|
var timeline : Timeline = timelines[i];
|
||||||
var setupPose : Boolean = timelinesFirst[i];
|
var setupPose : Boolean = timelinesFirst[i];
|
||||||
|
var alpha : Number = timelinesLast != null && setupPose && !timelinesLast[i] ? alphaBase : alphaMix;
|
||||||
if (timeline is RotateTimeline)
|
if (timeline is RotateTimeline)
|
||||||
applyRotateTimeline(timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame);
|
applyRotateTimeline(timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame);
|
||||||
else {
|
else {
|
||||||
@ -360,10 +363,30 @@ package spine.animation {
|
|||||||
current.mixingFrom = from;
|
current.mixingFrom = from;
|
||||||
current.mixTime = 0;
|
current.mixTime = 0;
|
||||||
|
|
||||||
from.timelinesRotation.length = 0;
|
var mixingFrom : TrackEntry = from.mixingFrom;
|
||||||
|
if (mixingFrom != null && from.mixDuration > 0) {
|
||||||
|
// A mix was interrupted, mix from the closest animation.
|
||||||
|
if (!multipleMixing && from.mixTime / from.mixDuration < 0.5 && mixingFrom.animation != AnimationState.emptyAnimation) {
|
||||||
|
current.mixingFrom = mixingFrom;
|
||||||
|
mixingFrom.mixingFrom = from;
|
||||||
|
mixingFrom.mixTime = from.mixDuration - from.mixTime;
|
||||||
|
mixingFrom.mixDuration = from.mixDuration;
|
||||||
|
from.mixingFrom = null;
|
||||||
|
from = mixingFrom;
|
||||||
|
}
|
||||||
|
|
||||||
// If not completely mixed in, set mixAlpha so mixing out happens from current mix to zero.
|
// The interrupted mix will mix out from its current percentage to zero.
|
||||||
if (from.mixingFrom != null && from.mixDuration > 0) current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
|
current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
|
||||||
|
|
||||||
|
// End the other animation after it is applied one last time.
|
||||||
|
if (!multipleMixing) {
|
||||||
|
from.mixAlpha = 0;
|
||||||
|
from.mixTime = 0;
|
||||||
|
from.mixDuration = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
from.timelinesRotation.length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
queue.start(current);
|
queue.start(current);
|
||||||
@ -524,6 +547,36 @@ package spine.animation {
|
|||||||
entry = tracks[i];
|
entry = tracks[i];
|
||||||
if (entry != null) checkTimelinesFirst(entry);
|
if (entry != null) checkTimelinesFirst(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (multipleMixing) return;
|
||||||
|
|
||||||
|
// Set timelinesLast for mixingFrom entries, from highest track to lowest that has mixingFrom.
|
||||||
|
for (var key2 : String in propertyIDs) {
|
||||||
|
delete propertyIDs[key2];
|
||||||
|
}
|
||||||
|
var lowestMixingFrom : int = n;
|
||||||
|
for (i = 0; i < n; i++) { // Find lowest track with a mixingFrom entry.
|
||||||
|
entry = tracks[i];
|
||||||
|
if (entry == null || entry.mixingFrom == null) continue;
|
||||||
|
lowestMixingFrom = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for (i = n - 1; i >= lowestMixingFrom; i--) { // Find first non-null entry.
|
||||||
|
entry = tracks[i];
|
||||||
|
if (entry == null) continue;
|
||||||
|
|
||||||
|
// Store properties for non-mixingFrom entry but don't set timelinesLast, which is only used for mixingFrom entries.
|
||||||
|
var timelines : Vector.<Timeline> = entry.animation.timelines;
|
||||||
|
for (var ii : int = 0, nn : int = entry.animation.timelines.length; ii < nn; ii++)
|
||||||
|
var id : String = timelines[ii].getPropertyId().toString();
|
||||||
|
propertyIDs[id] = id;
|
||||||
|
|
||||||
|
entry = entry.mixingFrom;
|
||||||
|
while (entry != null) {
|
||||||
|
checkTimelinesUsage(entry, entry.timelinesLast);
|
||||||
|
entry = entry.mixingFrom;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function setTimelinesFirst(entry : TrackEntry) : void {
|
private function setTimelinesFirst(entry : TrackEntry) : void {
|
||||||
|
|||||||
@ -47,6 +47,7 @@ package spine.animation {
|
|||||||
public var delay : Number, trackTime : Number, trackLast : Number, nextTrackLast : Number, trackEnd : Number, timeScale : Number;
|
public var delay : Number, trackTime : Number, trackLast : Number, nextTrackLast : Number, trackEnd : Number, timeScale : Number;
|
||||||
public var alpha : Number, mixTime : Number, mixDuration : Number, mixAlpha : Number;
|
public var alpha : Number, mixTime : Number, mixDuration : Number, mixAlpha : Number;
|
||||||
public var timelinesFirst : Vector.<Boolean> = new Vector.<Boolean>();
|
public var timelinesFirst : Vector.<Boolean> = new Vector.<Boolean>();
|
||||||
|
public var timelinesLast : Vector.<Boolean> = new Vector.<Boolean>();
|
||||||
public var timelinesRotation : Vector.<Number> = new Vector.<Number>();
|
public var timelinesRotation : Vector.<Number> = new Vector.<Number>();
|
||||||
|
|
||||||
public function TrackEntry() {
|
public function TrackEntry() {
|
||||||
@ -72,6 +73,7 @@ package spine.animation {
|
|||||||
onComplete.listeners.length = 0;
|
onComplete.listeners.length = 0;
|
||||||
onEvent.listeners.length = 0;
|
onEvent.listeners.length = 0;
|
||||||
timelinesFirst.length = 0;
|
timelinesFirst.length = 0;
|
||||||
|
timelinesLast.length = 0;
|
||||||
timelinesRotation.length = 0;
|
timelinesRotation.length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@ -45,7 +45,7 @@ package spine.examples {
|
|||||||
// example = TankExample;
|
// example = TankExample;
|
||||||
// example = VineExample;
|
// example = VineExample;
|
||||||
// example = StretchymanExample;
|
// example = StretchymanExample;
|
||||||
example = TwoColorExample;
|
// example = TwoColorExample;
|
||||||
|
|
||||||
_starling = new Starling(example, stage);
|
_starling = new Starling(example, stage);
|
||||||
_starling.enableErrorChecking = true;
|
_starling.enableErrorChecking = true;
|
||||||
|
|||||||
Binary file not shown.
2
spine-ts/build/spine-all.d.ts
vendored
2
spine-ts/build/spine-all.d.ts
vendored
@ -328,6 +328,7 @@ declare module spine {
|
|||||||
queue: EventQueue;
|
queue: EventQueue;
|
||||||
propertyIDs: IntSet;
|
propertyIDs: IntSet;
|
||||||
animationsChanged: boolean;
|
animationsChanged: boolean;
|
||||||
|
multipleMixing: boolean;
|
||||||
timeScale: number;
|
timeScale: number;
|
||||||
trackEntryPool: Pool<TrackEntry>;
|
trackEntryPool: Pool<TrackEntry>;
|
||||||
constructor(data: AnimationStateData);
|
constructor(data: AnimationStateData);
|
||||||
@ -385,6 +386,7 @@ declare module spine {
|
|||||||
mixDuration: number;
|
mixDuration: number;
|
||||||
mixAlpha: number;
|
mixAlpha: number;
|
||||||
timelinesFirst: boolean[];
|
timelinesFirst: boolean[];
|
||||||
|
timelinesLast: boolean[];
|
||||||
timelinesRotation: number[];
|
timelinesRotation: number[];
|
||||||
reset(): void;
|
reset(): void;
|
||||||
getAnimationTime(): number;
|
getAnimationTime(): number;
|
||||||
|
|||||||
@ -1461,6 +1461,7 @@ var spine;
|
|||||||
this.queue = new EventQueue(this);
|
this.queue = new EventQueue(this);
|
||||||
this.propertyIDs = new spine.IntSet();
|
this.propertyIDs = new spine.IntSet();
|
||||||
this.animationsChanged = false;
|
this.animationsChanged = false;
|
||||||
|
this.multipleMixing = false;
|
||||||
this.timeScale = 1;
|
this.timeScale = 1;
|
||||||
this.trackEntryPool = new spine.Pool(function () { return new TrackEntry(); });
|
this.trackEntryPool = new spine.Pool(function () { return new TrackEntry(); });
|
||||||
this.data = data;
|
this.data = data;
|
||||||
@ -1588,7 +1589,9 @@ var spine;
|
|||||||
var timelineCount = from.animation.timelines.length;
|
var timelineCount = from.animation.timelines.length;
|
||||||
var timelines = from.animation.timelines;
|
var timelines = from.animation.timelines;
|
||||||
var timelinesFirst = from.timelinesFirst;
|
var timelinesFirst = from.timelinesFirst;
|
||||||
var alpha = from.alpha * entry.mixAlpha * (1 - mix);
|
var timelinesLast = this.multipleMixing ? null : from.timelinesLast;
|
||||||
|
var alphaBase = from.alpha * entry.mixAlpha;
|
||||||
|
var alphaMix = alphaBase * (1 - mix);
|
||||||
var firstFrame = from.timelinesRotation.length == 0;
|
var firstFrame = from.timelinesRotation.length == 0;
|
||||||
if (firstFrame)
|
if (firstFrame)
|
||||||
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
|
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
|
||||||
@ -1596,6 +1599,7 @@ var spine;
|
|||||||
for (var i = 0; i < timelineCount; i++) {
|
for (var i = 0; i < timelineCount; i++) {
|
||||||
var timeline = timelines[i];
|
var timeline = timelines[i];
|
||||||
var setupPose = timelinesFirst[i];
|
var setupPose = timelinesFirst[i];
|
||||||
|
var alpha = timelinesLast != null && setupPose && !timelinesLast[i] ? alphaBase : alphaMix;
|
||||||
if (timeline instanceof spine.RotateTimeline)
|
if (timeline instanceof spine.RotateTimeline)
|
||||||
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame);
|
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame);
|
||||||
else {
|
else {
|
||||||
@ -1736,9 +1740,24 @@ var spine;
|
|||||||
this.queue.interrupt(from);
|
this.queue.interrupt(from);
|
||||||
current.mixingFrom = from;
|
current.mixingFrom = from;
|
||||||
current.mixTime = 0;
|
current.mixTime = 0;
|
||||||
from.timelinesRotation.length = 0;
|
var mixingFrom = from.mixingFrom;
|
||||||
if (from.mixingFrom != null && from.mixDuration > 0)
|
if (mixingFrom != null && from.mixDuration > 0) {
|
||||||
|
if (!this.multipleMixing && from.mixTime / from.mixDuration < 0.5 && mixingFrom.animation != AnimationState.emptyAnimation) {
|
||||||
|
current.mixingFrom = mixingFrom;
|
||||||
|
mixingFrom.mixingFrom = from;
|
||||||
|
mixingFrom.mixTime = from.mixDuration - from.mixTime;
|
||||||
|
mixingFrom.mixDuration = from.mixDuration;
|
||||||
|
from.mixingFrom = null;
|
||||||
|
from = mixingFrom;
|
||||||
|
}
|
||||||
current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
|
current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
|
||||||
|
if (!this.multipleMixing) {
|
||||||
|
from.mixAlpha = 0;
|
||||||
|
from.mixTime = 0;
|
||||||
|
from.mixDuration = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
from.timelinesRotation.length = 0;
|
||||||
}
|
}
|
||||||
this.queue.start(current);
|
this.queue.start(current);
|
||||||
};
|
};
|
||||||
@ -1884,6 +1903,30 @@ var spine;
|
|||||||
if (entry != null)
|
if (entry != null)
|
||||||
this.checkTimelinesFirst(entry);
|
this.checkTimelinesFirst(entry);
|
||||||
}
|
}
|
||||||
|
if (this.multipleMixing)
|
||||||
|
return;
|
||||||
|
propertyIDs.clear();
|
||||||
|
var lowestMixingFrom = n;
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
var entry = this.tracks[i];
|
||||||
|
if (entry == null || entry.mixingFrom == null)
|
||||||
|
continue;
|
||||||
|
lowestMixingFrom = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for (i = n - 1; i >= lowestMixingFrom; i--) {
|
||||||
|
var entry = this.tracks[i];
|
||||||
|
if (entry == null)
|
||||||
|
continue;
|
||||||
|
var timelines = entry.animation.timelines;
|
||||||
|
for (var ii = 0, nn = entry.animation.timelines.length; ii < nn; ii++)
|
||||||
|
propertyIDs.add(timelines[ii].getPropertyId());
|
||||||
|
entry = entry.mixingFrom;
|
||||||
|
while (entry != null) {
|
||||||
|
this.checkTimelinesUsage(entry, entry.timelinesLast);
|
||||||
|
entry = entry.mixingFrom;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
AnimationState.prototype.setTimelinesFirst = function (entry) {
|
AnimationState.prototype.setTimelinesFirst = function (entry) {
|
||||||
if (entry.mixingFrom != null) {
|
if (entry.mixingFrom != null) {
|
||||||
@ -1941,6 +1984,7 @@ var spine;
|
|||||||
var TrackEntry = (function () {
|
var TrackEntry = (function () {
|
||||||
function TrackEntry() {
|
function TrackEntry() {
|
||||||
this.timelinesFirst = new Array();
|
this.timelinesFirst = new Array();
|
||||||
|
this.timelinesLast = new Array();
|
||||||
this.timelinesRotation = new Array();
|
this.timelinesRotation = new Array();
|
||||||
}
|
}
|
||||||
TrackEntry.prototype.reset = function () {
|
TrackEntry.prototype.reset = function () {
|
||||||
@ -1949,6 +1993,7 @@ var spine;
|
|||||||
this.animation = null;
|
this.animation = null;
|
||||||
this.listener = null;
|
this.listener = null;
|
||||||
this.timelinesFirst.length = 0;
|
this.timelinesFirst.length = 0;
|
||||||
|
this.timelinesLast.length = 0;
|
||||||
this.timelinesRotation.length = 0;
|
this.timelinesRotation.length = 0;
|
||||||
};
|
};
|
||||||
TrackEntry.prototype.getAnimationTime = function () {
|
TrackEntry.prototype.getAnimationTime = function () {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
2
spine-ts/build/spine-canvas.d.ts
vendored
2
spine-ts/build/spine-canvas.d.ts
vendored
@ -328,6 +328,7 @@ declare module spine {
|
|||||||
queue: EventQueue;
|
queue: EventQueue;
|
||||||
propertyIDs: IntSet;
|
propertyIDs: IntSet;
|
||||||
animationsChanged: boolean;
|
animationsChanged: boolean;
|
||||||
|
multipleMixing: boolean;
|
||||||
timeScale: number;
|
timeScale: number;
|
||||||
trackEntryPool: Pool<TrackEntry>;
|
trackEntryPool: Pool<TrackEntry>;
|
||||||
constructor(data: AnimationStateData);
|
constructor(data: AnimationStateData);
|
||||||
@ -385,6 +386,7 @@ declare module spine {
|
|||||||
mixDuration: number;
|
mixDuration: number;
|
||||||
mixAlpha: number;
|
mixAlpha: number;
|
||||||
timelinesFirst: boolean[];
|
timelinesFirst: boolean[];
|
||||||
|
timelinesLast: boolean[];
|
||||||
timelinesRotation: number[];
|
timelinesRotation: number[];
|
||||||
reset(): void;
|
reset(): void;
|
||||||
getAnimationTime(): number;
|
getAnimationTime(): number;
|
||||||
|
|||||||
@ -1461,6 +1461,7 @@ var spine;
|
|||||||
this.queue = new EventQueue(this);
|
this.queue = new EventQueue(this);
|
||||||
this.propertyIDs = new spine.IntSet();
|
this.propertyIDs = new spine.IntSet();
|
||||||
this.animationsChanged = false;
|
this.animationsChanged = false;
|
||||||
|
this.multipleMixing = false;
|
||||||
this.timeScale = 1;
|
this.timeScale = 1;
|
||||||
this.trackEntryPool = new spine.Pool(function () { return new TrackEntry(); });
|
this.trackEntryPool = new spine.Pool(function () { return new TrackEntry(); });
|
||||||
this.data = data;
|
this.data = data;
|
||||||
@ -1588,7 +1589,9 @@ var spine;
|
|||||||
var timelineCount = from.animation.timelines.length;
|
var timelineCount = from.animation.timelines.length;
|
||||||
var timelines = from.animation.timelines;
|
var timelines = from.animation.timelines;
|
||||||
var timelinesFirst = from.timelinesFirst;
|
var timelinesFirst = from.timelinesFirst;
|
||||||
var alpha = from.alpha * entry.mixAlpha * (1 - mix);
|
var timelinesLast = this.multipleMixing ? null : from.timelinesLast;
|
||||||
|
var alphaBase = from.alpha * entry.mixAlpha;
|
||||||
|
var alphaMix = alphaBase * (1 - mix);
|
||||||
var firstFrame = from.timelinesRotation.length == 0;
|
var firstFrame = from.timelinesRotation.length == 0;
|
||||||
if (firstFrame)
|
if (firstFrame)
|
||||||
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
|
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
|
||||||
@ -1596,6 +1599,7 @@ var spine;
|
|||||||
for (var i = 0; i < timelineCount; i++) {
|
for (var i = 0; i < timelineCount; i++) {
|
||||||
var timeline = timelines[i];
|
var timeline = timelines[i];
|
||||||
var setupPose = timelinesFirst[i];
|
var setupPose = timelinesFirst[i];
|
||||||
|
var alpha = timelinesLast != null && setupPose && !timelinesLast[i] ? alphaBase : alphaMix;
|
||||||
if (timeline instanceof spine.RotateTimeline)
|
if (timeline instanceof spine.RotateTimeline)
|
||||||
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame);
|
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame);
|
||||||
else {
|
else {
|
||||||
@ -1736,9 +1740,24 @@ var spine;
|
|||||||
this.queue.interrupt(from);
|
this.queue.interrupt(from);
|
||||||
current.mixingFrom = from;
|
current.mixingFrom = from;
|
||||||
current.mixTime = 0;
|
current.mixTime = 0;
|
||||||
from.timelinesRotation.length = 0;
|
var mixingFrom = from.mixingFrom;
|
||||||
if (from.mixingFrom != null && from.mixDuration > 0)
|
if (mixingFrom != null && from.mixDuration > 0) {
|
||||||
|
if (!this.multipleMixing && from.mixTime / from.mixDuration < 0.5 && mixingFrom.animation != AnimationState.emptyAnimation) {
|
||||||
|
current.mixingFrom = mixingFrom;
|
||||||
|
mixingFrom.mixingFrom = from;
|
||||||
|
mixingFrom.mixTime = from.mixDuration - from.mixTime;
|
||||||
|
mixingFrom.mixDuration = from.mixDuration;
|
||||||
|
from.mixingFrom = null;
|
||||||
|
from = mixingFrom;
|
||||||
|
}
|
||||||
current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
|
current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
|
||||||
|
if (!this.multipleMixing) {
|
||||||
|
from.mixAlpha = 0;
|
||||||
|
from.mixTime = 0;
|
||||||
|
from.mixDuration = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
from.timelinesRotation.length = 0;
|
||||||
}
|
}
|
||||||
this.queue.start(current);
|
this.queue.start(current);
|
||||||
};
|
};
|
||||||
@ -1884,6 +1903,30 @@ var spine;
|
|||||||
if (entry != null)
|
if (entry != null)
|
||||||
this.checkTimelinesFirst(entry);
|
this.checkTimelinesFirst(entry);
|
||||||
}
|
}
|
||||||
|
if (this.multipleMixing)
|
||||||
|
return;
|
||||||
|
propertyIDs.clear();
|
||||||
|
var lowestMixingFrom = n;
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
var entry = this.tracks[i];
|
||||||
|
if (entry == null || entry.mixingFrom == null)
|
||||||
|
continue;
|
||||||
|
lowestMixingFrom = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for (i = n - 1; i >= lowestMixingFrom; i--) {
|
||||||
|
var entry = this.tracks[i];
|
||||||
|
if (entry == null)
|
||||||
|
continue;
|
||||||
|
var timelines = entry.animation.timelines;
|
||||||
|
for (var ii = 0, nn = entry.animation.timelines.length; ii < nn; ii++)
|
||||||
|
propertyIDs.add(timelines[ii].getPropertyId());
|
||||||
|
entry = entry.mixingFrom;
|
||||||
|
while (entry != null) {
|
||||||
|
this.checkTimelinesUsage(entry, entry.timelinesLast);
|
||||||
|
entry = entry.mixingFrom;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
AnimationState.prototype.setTimelinesFirst = function (entry) {
|
AnimationState.prototype.setTimelinesFirst = function (entry) {
|
||||||
if (entry.mixingFrom != null) {
|
if (entry.mixingFrom != null) {
|
||||||
@ -1941,6 +1984,7 @@ var spine;
|
|||||||
var TrackEntry = (function () {
|
var TrackEntry = (function () {
|
||||||
function TrackEntry() {
|
function TrackEntry() {
|
||||||
this.timelinesFirst = new Array();
|
this.timelinesFirst = new Array();
|
||||||
|
this.timelinesLast = new Array();
|
||||||
this.timelinesRotation = new Array();
|
this.timelinesRotation = new Array();
|
||||||
}
|
}
|
||||||
TrackEntry.prototype.reset = function () {
|
TrackEntry.prototype.reset = function () {
|
||||||
@ -1949,6 +1993,7 @@ var spine;
|
|||||||
this.animation = null;
|
this.animation = null;
|
||||||
this.listener = null;
|
this.listener = null;
|
||||||
this.timelinesFirst.length = 0;
|
this.timelinesFirst.length = 0;
|
||||||
|
this.timelinesLast.length = 0;
|
||||||
this.timelinesRotation.length = 0;
|
this.timelinesRotation.length = 0;
|
||||||
};
|
};
|
||||||
TrackEntry.prototype.getAnimationTime = function () {
|
TrackEntry.prototype.getAnimationTime = function () {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
2
spine-ts/build/spine-core.d.ts
vendored
2
spine-ts/build/spine-core.d.ts
vendored
@ -235,6 +235,7 @@ declare module spine {
|
|||||||
queue: EventQueue;
|
queue: EventQueue;
|
||||||
propertyIDs: IntSet;
|
propertyIDs: IntSet;
|
||||||
animationsChanged: boolean;
|
animationsChanged: boolean;
|
||||||
|
multipleMixing: boolean;
|
||||||
timeScale: number;
|
timeScale: number;
|
||||||
trackEntryPool: Pool<TrackEntry>;
|
trackEntryPool: Pool<TrackEntry>;
|
||||||
constructor(data: AnimationStateData);
|
constructor(data: AnimationStateData);
|
||||||
@ -292,6 +293,7 @@ declare module spine {
|
|||||||
mixDuration: number;
|
mixDuration: number;
|
||||||
mixAlpha: number;
|
mixAlpha: number;
|
||||||
timelinesFirst: boolean[];
|
timelinesFirst: boolean[];
|
||||||
|
timelinesLast: boolean[];
|
||||||
timelinesRotation: number[];
|
timelinesRotation: number[];
|
||||||
reset(): void;
|
reset(): void;
|
||||||
getAnimationTime(): number;
|
getAnimationTime(): number;
|
||||||
|
|||||||
@ -1043,6 +1043,7 @@ var spine;
|
|||||||
this.queue = new EventQueue(this);
|
this.queue = new EventQueue(this);
|
||||||
this.propertyIDs = new spine.IntSet();
|
this.propertyIDs = new spine.IntSet();
|
||||||
this.animationsChanged = false;
|
this.animationsChanged = false;
|
||||||
|
this.multipleMixing = false;
|
||||||
this.timeScale = 1;
|
this.timeScale = 1;
|
||||||
this.trackEntryPool = new spine.Pool(function () { return new TrackEntry(); });
|
this.trackEntryPool = new spine.Pool(function () { return new TrackEntry(); });
|
||||||
this.data = data;
|
this.data = data;
|
||||||
@ -1170,7 +1171,9 @@ var spine;
|
|||||||
var timelineCount = from.animation.timelines.length;
|
var timelineCount = from.animation.timelines.length;
|
||||||
var timelines = from.animation.timelines;
|
var timelines = from.animation.timelines;
|
||||||
var timelinesFirst = from.timelinesFirst;
|
var timelinesFirst = from.timelinesFirst;
|
||||||
var alpha = from.alpha * entry.mixAlpha * (1 - mix);
|
var timelinesLast = this.multipleMixing ? null : from.timelinesLast;
|
||||||
|
var alphaBase = from.alpha * entry.mixAlpha;
|
||||||
|
var alphaMix = alphaBase * (1 - mix);
|
||||||
var firstFrame = from.timelinesRotation.length == 0;
|
var firstFrame = from.timelinesRotation.length == 0;
|
||||||
if (firstFrame)
|
if (firstFrame)
|
||||||
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
|
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
|
||||||
@ -1178,6 +1181,7 @@ var spine;
|
|||||||
for (var i = 0; i < timelineCount; i++) {
|
for (var i = 0; i < timelineCount; i++) {
|
||||||
var timeline = timelines[i];
|
var timeline = timelines[i];
|
||||||
var setupPose = timelinesFirst[i];
|
var setupPose = timelinesFirst[i];
|
||||||
|
var alpha = timelinesLast != null && setupPose && !timelinesLast[i] ? alphaBase : alphaMix;
|
||||||
if (timeline instanceof spine.RotateTimeline)
|
if (timeline instanceof spine.RotateTimeline)
|
||||||
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame);
|
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame);
|
||||||
else {
|
else {
|
||||||
@ -1318,9 +1322,24 @@ var spine;
|
|||||||
this.queue.interrupt(from);
|
this.queue.interrupt(from);
|
||||||
current.mixingFrom = from;
|
current.mixingFrom = from;
|
||||||
current.mixTime = 0;
|
current.mixTime = 0;
|
||||||
from.timelinesRotation.length = 0;
|
var mixingFrom = from.mixingFrom;
|
||||||
if (from.mixingFrom != null && from.mixDuration > 0)
|
if (mixingFrom != null && from.mixDuration > 0) {
|
||||||
|
if (!this.multipleMixing && from.mixTime / from.mixDuration < 0.5 && mixingFrom.animation != AnimationState.emptyAnimation) {
|
||||||
|
current.mixingFrom = mixingFrom;
|
||||||
|
mixingFrom.mixingFrom = from;
|
||||||
|
mixingFrom.mixTime = from.mixDuration - from.mixTime;
|
||||||
|
mixingFrom.mixDuration = from.mixDuration;
|
||||||
|
from.mixingFrom = null;
|
||||||
|
from = mixingFrom;
|
||||||
|
}
|
||||||
current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
|
current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
|
||||||
|
if (!this.multipleMixing) {
|
||||||
|
from.mixAlpha = 0;
|
||||||
|
from.mixTime = 0;
|
||||||
|
from.mixDuration = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
from.timelinesRotation.length = 0;
|
||||||
}
|
}
|
||||||
this.queue.start(current);
|
this.queue.start(current);
|
||||||
};
|
};
|
||||||
@ -1466,6 +1485,30 @@ var spine;
|
|||||||
if (entry != null)
|
if (entry != null)
|
||||||
this.checkTimelinesFirst(entry);
|
this.checkTimelinesFirst(entry);
|
||||||
}
|
}
|
||||||
|
if (this.multipleMixing)
|
||||||
|
return;
|
||||||
|
propertyIDs.clear();
|
||||||
|
var lowestMixingFrom = n;
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
var entry = this.tracks[i];
|
||||||
|
if (entry == null || entry.mixingFrom == null)
|
||||||
|
continue;
|
||||||
|
lowestMixingFrom = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for (i = n - 1; i >= lowestMixingFrom; i--) {
|
||||||
|
var entry = this.tracks[i];
|
||||||
|
if (entry == null)
|
||||||
|
continue;
|
||||||
|
var timelines = entry.animation.timelines;
|
||||||
|
for (var ii = 0, nn = entry.animation.timelines.length; ii < nn; ii++)
|
||||||
|
propertyIDs.add(timelines[ii].getPropertyId());
|
||||||
|
entry = entry.mixingFrom;
|
||||||
|
while (entry != null) {
|
||||||
|
this.checkTimelinesUsage(entry, entry.timelinesLast);
|
||||||
|
entry = entry.mixingFrom;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
AnimationState.prototype.setTimelinesFirst = function (entry) {
|
AnimationState.prototype.setTimelinesFirst = function (entry) {
|
||||||
if (entry.mixingFrom != null) {
|
if (entry.mixingFrom != null) {
|
||||||
@ -1523,6 +1566,7 @@ var spine;
|
|||||||
var TrackEntry = (function () {
|
var TrackEntry = (function () {
|
||||||
function TrackEntry() {
|
function TrackEntry() {
|
||||||
this.timelinesFirst = new Array();
|
this.timelinesFirst = new Array();
|
||||||
|
this.timelinesLast = new Array();
|
||||||
this.timelinesRotation = new Array();
|
this.timelinesRotation = new Array();
|
||||||
}
|
}
|
||||||
TrackEntry.prototype.reset = function () {
|
TrackEntry.prototype.reset = function () {
|
||||||
@ -1531,6 +1575,7 @@ var spine;
|
|||||||
this.animation = null;
|
this.animation = null;
|
||||||
this.listener = null;
|
this.listener = null;
|
||||||
this.timelinesFirst.length = 0;
|
this.timelinesFirst.length = 0;
|
||||||
|
this.timelinesLast.length = 0;
|
||||||
this.timelinesRotation.length = 0;
|
this.timelinesRotation.length = 0;
|
||||||
};
|
};
|
||||||
TrackEntry.prototype.getAnimationTime = function () {
|
TrackEntry.prototype.getAnimationTime = function () {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
2
spine-ts/build/spine-threejs.d.ts
vendored
2
spine-ts/build/spine-threejs.d.ts
vendored
@ -235,6 +235,7 @@ declare module spine {
|
|||||||
queue: EventQueue;
|
queue: EventQueue;
|
||||||
propertyIDs: IntSet;
|
propertyIDs: IntSet;
|
||||||
animationsChanged: boolean;
|
animationsChanged: boolean;
|
||||||
|
multipleMixing: boolean;
|
||||||
timeScale: number;
|
timeScale: number;
|
||||||
trackEntryPool: Pool<TrackEntry>;
|
trackEntryPool: Pool<TrackEntry>;
|
||||||
constructor(data: AnimationStateData);
|
constructor(data: AnimationStateData);
|
||||||
@ -292,6 +293,7 @@ declare module spine {
|
|||||||
mixDuration: number;
|
mixDuration: number;
|
||||||
mixAlpha: number;
|
mixAlpha: number;
|
||||||
timelinesFirst: boolean[];
|
timelinesFirst: boolean[];
|
||||||
|
timelinesLast: boolean[];
|
||||||
timelinesRotation: number[];
|
timelinesRotation: number[];
|
||||||
reset(): void;
|
reset(): void;
|
||||||
getAnimationTime(): number;
|
getAnimationTime(): number;
|
||||||
|
|||||||
@ -1043,6 +1043,7 @@ var spine;
|
|||||||
this.queue = new EventQueue(this);
|
this.queue = new EventQueue(this);
|
||||||
this.propertyIDs = new spine.IntSet();
|
this.propertyIDs = new spine.IntSet();
|
||||||
this.animationsChanged = false;
|
this.animationsChanged = false;
|
||||||
|
this.multipleMixing = false;
|
||||||
this.timeScale = 1;
|
this.timeScale = 1;
|
||||||
this.trackEntryPool = new spine.Pool(function () { return new TrackEntry(); });
|
this.trackEntryPool = new spine.Pool(function () { return new TrackEntry(); });
|
||||||
this.data = data;
|
this.data = data;
|
||||||
@ -1170,7 +1171,9 @@ var spine;
|
|||||||
var timelineCount = from.animation.timelines.length;
|
var timelineCount = from.animation.timelines.length;
|
||||||
var timelines = from.animation.timelines;
|
var timelines = from.animation.timelines;
|
||||||
var timelinesFirst = from.timelinesFirst;
|
var timelinesFirst = from.timelinesFirst;
|
||||||
var alpha = from.alpha * entry.mixAlpha * (1 - mix);
|
var timelinesLast = this.multipleMixing ? null : from.timelinesLast;
|
||||||
|
var alphaBase = from.alpha * entry.mixAlpha;
|
||||||
|
var alphaMix = alphaBase * (1 - mix);
|
||||||
var firstFrame = from.timelinesRotation.length == 0;
|
var firstFrame = from.timelinesRotation.length == 0;
|
||||||
if (firstFrame)
|
if (firstFrame)
|
||||||
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
|
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
|
||||||
@ -1178,6 +1181,7 @@ var spine;
|
|||||||
for (var i = 0; i < timelineCount; i++) {
|
for (var i = 0; i < timelineCount; i++) {
|
||||||
var timeline = timelines[i];
|
var timeline = timelines[i];
|
||||||
var setupPose = timelinesFirst[i];
|
var setupPose = timelinesFirst[i];
|
||||||
|
var alpha = timelinesLast != null && setupPose && !timelinesLast[i] ? alphaBase : alphaMix;
|
||||||
if (timeline instanceof spine.RotateTimeline)
|
if (timeline instanceof spine.RotateTimeline)
|
||||||
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame);
|
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame);
|
||||||
else {
|
else {
|
||||||
@ -1318,9 +1322,24 @@ var spine;
|
|||||||
this.queue.interrupt(from);
|
this.queue.interrupt(from);
|
||||||
current.mixingFrom = from;
|
current.mixingFrom = from;
|
||||||
current.mixTime = 0;
|
current.mixTime = 0;
|
||||||
from.timelinesRotation.length = 0;
|
var mixingFrom = from.mixingFrom;
|
||||||
if (from.mixingFrom != null && from.mixDuration > 0)
|
if (mixingFrom != null && from.mixDuration > 0) {
|
||||||
|
if (!this.multipleMixing && from.mixTime / from.mixDuration < 0.5 && mixingFrom.animation != AnimationState.emptyAnimation) {
|
||||||
|
current.mixingFrom = mixingFrom;
|
||||||
|
mixingFrom.mixingFrom = from;
|
||||||
|
mixingFrom.mixTime = from.mixDuration - from.mixTime;
|
||||||
|
mixingFrom.mixDuration = from.mixDuration;
|
||||||
|
from.mixingFrom = null;
|
||||||
|
from = mixingFrom;
|
||||||
|
}
|
||||||
current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
|
current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
|
||||||
|
if (!this.multipleMixing) {
|
||||||
|
from.mixAlpha = 0;
|
||||||
|
from.mixTime = 0;
|
||||||
|
from.mixDuration = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
from.timelinesRotation.length = 0;
|
||||||
}
|
}
|
||||||
this.queue.start(current);
|
this.queue.start(current);
|
||||||
};
|
};
|
||||||
@ -1466,6 +1485,30 @@ var spine;
|
|||||||
if (entry != null)
|
if (entry != null)
|
||||||
this.checkTimelinesFirst(entry);
|
this.checkTimelinesFirst(entry);
|
||||||
}
|
}
|
||||||
|
if (this.multipleMixing)
|
||||||
|
return;
|
||||||
|
propertyIDs.clear();
|
||||||
|
var lowestMixingFrom = n;
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
var entry = this.tracks[i];
|
||||||
|
if (entry == null || entry.mixingFrom == null)
|
||||||
|
continue;
|
||||||
|
lowestMixingFrom = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for (i = n - 1; i >= lowestMixingFrom; i--) {
|
||||||
|
var entry = this.tracks[i];
|
||||||
|
if (entry == null)
|
||||||
|
continue;
|
||||||
|
var timelines = entry.animation.timelines;
|
||||||
|
for (var ii = 0, nn = entry.animation.timelines.length; ii < nn; ii++)
|
||||||
|
propertyIDs.add(timelines[ii].getPropertyId());
|
||||||
|
entry = entry.mixingFrom;
|
||||||
|
while (entry != null) {
|
||||||
|
this.checkTimelinesUsage(entry, entry.timelinesLast);
|
||||||
|
entry = entry.mixingFrom;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
AnimationState.prototype.setTimelinesFirst = function (entry) {
|
AnimationState.prototype.setTimelinesFirst = function (entry) {
|
||||||
if (entry.mixingFrom != null) {
|
if (entry.mixingFrom != null) {
|
||||||
@ -1523,6 +1566,7 @@ var spine;
|
|||||||
var TrackEntry = (function () {
|
var TrackEntry = (function () {
|
||||||
function TrackEntry() {
|
function TrackEntry() {
|
||||||
this.timelinesFirst = new Array();
|
this.timelinesFirst = new Array();
|
||||||
|
this.timelinesLast = new Array();
|
||||||
this.timelinesRotation = new Array();
|
this.timelinesRotation = new Array();
|
||||||
}
|
}
|
||||||
TrackEntry.prototype.reset = function () {
|
TrackEntry.prototype.reset = function () {
|
||||||
@ -1531,6 +1575,7 @@ var spine;
|
|||||||
this.animation = null;
|
this.animation = null;
|
||||||
this.listener = null;
|
this.listener = null;
|
||||||
this.timelinesFirst.length = 0;
|
this.timelinesFirst.length = 0;
|
||||||
|
this.timelinesLast.length = 0;
|
||||||
this.timelinesRotation.length = 0;
|
this.timelinesRotation.length = 0;
|
||||||
};
|
};
|
||||||
TrackEntry.prototype.getAnimationTime = function () {
|
TrackEntry.prototype.getAnimationTime = function () {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
2
spine-ts/build/spine-webgl.d.ts
vendored
2
spine-ts/build/spine-webgl.d.ts
vendored
@ -235,6 +235,7 @@ declare module spine {
|
|||||||
queue: EventQueue;
|
queue: EventQueue;
|
||||||
propertyIDs: IntSet;
|
propertyIDs: IntSet;
|
||||||
animationsChanged: boolean;
|
animationsChanged: boolean;
|
||||||
|
multipleMixing: boolean;
|
||||||
timeScale: number;
|
timeScale: number;
|
||||||
trackEntryPool: Pool<TrackEntry>;
|
trackEntryPool: Pool<TrackEntry>;
|
||||||
constructor(data: AnimationStateData);
|
constructor(data: AnimationStateData);
|
||||||
@ -292,6 +293,7 @@ declare module spine {
|
|||||||
mixDuration: number;
|
mixDuration: number;
|
||||||
mixAlpha: number;
|
mixAlpha: number;
|
||||||
timelinesFirst: boolean[];
|
timelinesFirst: boolean[];
|
||||||
|
timelinesLast: boolean[];
|
||||||
timelinesRotation: number[];
|
timelinesRotation: number[];
|
||||||
reset(): void;
|
reset(): void;
|
||||||
getAnimationTime(): number;
|
getAnimationTime(): number;
|
||||||
|
|||||||
@ -1043,6 +1043,7 @@ var spine;
|
|||||||
this.queue = new EventQueue(this);
|
this.queue = new EventQueue(this);
|
||||||
this.propertyIDs = new spine.IntSet();
|
this.propertyIDs = new spine.IntSet();
|
||||||
this.animationsChanged = false;
|
this.animationsChanged = false;
|
||||||
|
this.multipleMixing = false;
|
||||||
this.timeScale = 1;
|
this.timeScale = 1;
|
||||||
this.trackEntryPool = new spine.Pool(function () { return new TrackEntry(); });
|
this.trackEntryPool = new spine.Pool(function () { return new TrackEntry(); });
|
||||||
this.data = data;
|
this.data = data;
|
||||||
@ -1170,7 +1171,9 @@ var spine;
|
|||||||
var timelineCount = from.animation.timelines.length;
|
var timelineCount = from.animation.timelines.length;
|
||||||
var timelines = from.animation.timelines;
|
var timelines = from.animation.timelines;
|
||||||
var timelinesFirst = from.timelinesFirst;
|
var timelinesFirst = from.timelinesFirst;
|
||||||
var alpha = from.alpha * entry.mixAlpha * (1 - mix);
|
var timelinesLast = this.multipleMixing ? null : from.timelinesLast;
|
||||||
|
var alphaBase = from.alpha * entry.mixAlpha;
|
||||||
|
var alphaMix = alphaBase * (1 - mix);
|
||||||
var firstFrame = from.timelinesRotation.length == 0;
|
var firstFrame = from.timelinesRotation.length == 0;
|
||||||
if (firstFrame)
|
if (firstFrame)
|
||||||
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
|
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
|
||||||
@ -1178,6 +1181,7 @@ var spine;
|
|||||||
for (var i = 0; i < timelineCount; i++) {
|
for (var i = 0; i < timelineCount; i++) {
|
||||||
var timeline = timelines[i];
|
var timeline = timelines[i];
|
||||||
var setupPose = timelinesFirst[i];
|
var setupPose = timelinesFirst[i];
|
||||||
|
var alpha = timelinesLast != null && setupPose && !timelinesLast[i] ? alphaBase : alphaMix;
|
||||||
if (timeline instanceof spine.RotateTimeline)
|
if (timeline instanceof spine.RotateTimeline)
|
||||||
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame);
|
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame);
|
||||||
else {
|
else {
|
||||||
@ -1318,9 +1322,24 @@ var spine;
|
|||||||
this.queue.interrupt(from);
|
this.queue.interrupt(from);
|
||||||
current.mixingFrom = from;
|
current.mixingFrom = from;
|
||||||
current.mixTime = 0;
|
current.mixTime = 0;
|
||||||
from.timelinesRotation.length = 0;
|
var mixingFrom = from.mixingFrom;
|
||||||
if (from.mixingFrom != null && from.mixDuration > 0)
|
if (mixingFrom != null && from.mixDuration > 0) {
|
||||||
|
if (!this.multipleMixing && from.mixTime / from.mixDuration < 0.5 && mixingFrom.animation != AnimationState.emptyAnimation) {
|
||||||
|
current.mixingFrom = mixingFrom;
|
||||||
|
mixingFrom.mixingFrom = from;
|
||||||
|
mixingFrom.mixTime = from.mixDuration - from.mixTime;
|
||||||
|
mixingFrom.mixDuration = from.mixDuration;
|
||||||
|
from.mixingFrom = null;
|
||||||
|
from = mixingFrom;
|
||||||
|
}
|
||||||
current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
|
current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
|
||||||
|
if (!this.multipleMixing) {
|
||||||
|
from.mixAlpha = 0;
|
||||||
|
from.mixTime = 0;
|
||||||
|
from.mixDuration = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
from.timelinesRotation.length = 0;
|
||||||
}
|
}
|
||||||
this.queue.start(current);
|
this.queue.start(current);
|
||||||
};
|
};
|
||||||
@ -1466,6 +1485,30 @@ var spine;
|
|||||||
if (entry != null)
|
if (entry != null)
|
||||||
this.checkTimelinesFirst(entry);
|
this.checkTimelinesFirst(entry);
|
||||||
}
|
}
|
||||||
|
if (this.multipleMixing)
|
||||||
|
return;
|
||||||
|
propertyIDs.clear();
|
||||||
|
var lowestMixingFrom = n;
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
var entry = this.tracks[i];
|
||||||
|
if (entry == null || entry.mixingFrom == null)
|
||||||
|
continue;
|
||||||
|
lowestMixingFrom = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for (i = n - 1; i >= lowestMixingFrom; i--) {
|
||||||
|
var entry = this.tracks[i];
|
||||||
|
if (entry == null)
|
||||||
|
continue;
|
||||||
|
var timelines = entry.animation.timelines;
|
||||||
|
for (var ii = 0, nn = entry.animation.timelines.length; ii < nn; ii++)
|
||||||
|
propertyIDs.add(timelines[ii].getPropertyId());
|
||||||
|
entry = entry.mixingFrom;
|
||||||
|
while (entry != null) {
|
||||||
|
this.checkTimelinesUsage(entry, entry.timelinesLast);
|
||||||
|
entry = entry.mixingFrom;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
AnimationState.prototype.setTimelinesFirst = function (entry) {
|
AnimationState.prototype.setTimelinesFirst = function (entry) {
|
||||||
if (entry.mixingFrom != null) {
|
if (entry.mixingFrom != null) {
|
||||||
@ -1523,6 +1566,7 @@ var spine;
|
|||||||
var TrackEntry = (function () {
|
var TrackEntry = (function () {
|
||||||
function TrackEntry() {
|
function TrackEntry() {
|
||||||
this.timelinesFirst = new Array();
|
this.timelinesFirst = new Array();
|
||||||
|
this.timelinesLast = new Array();
|
||||||
this.timelinesRotation = new Array();
|
this.timelinesRotation = new Array();
|
||||||
}
|
}
|
||||||
TrackEntry.prototype.reset = function () {
|
TrackEntry.prototype.reset = function () {
|
||||||
@ -1531,6 +1575,7 @@ var spine;
|
|||||||
this.animation = null;
|
this.animation = null;
|
||||||
this.listener = null;
|
this.listener = null;
|
||||||
this.timelinesFirst.length = 0;
|
this.timelinesFirst.length = 0;
|
||||||
|
this.timelinesLast.length = 0;
|
||||||
this.timelinesRotation.length = 0;
|
this.timelinesRotation.length = 0;
|
||||||
};
|
};
|
||||||
TrackEntry.prototype.getAnimationTime = function () {
|
TrackEntry.prototype.getAnimationTime = function () {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
2
spine-ts/build/spine-widget.d.ts
vendored
2
spine-ts/build/spine-widget.d.ts
vendored
@ -235,6 +235,7 @@ declare module spine {
|
|||||||
queue: EventQueue;
|
queue: EventQueue;
|
||||||
propertyIDs: IntSet;
|
propertyIDs: IntSet;
|
||||||
animationsChanged: boolean;
|
animationsChanged: boolean;
|
||||||
|
multipleMixing: boolean;
|
||||||
timeScale: number;
|
timeScale: number;
|
||||||
trackEntryPool: Pool<TrackEntry>;
|
trackEntryPool: Pool<TrackEntry>;
|
||||||
constructor(data: AnimationStateData);
|
constructor(data: AnimationStateData);
|
||||||
@ -292,6 +293,7 @@ declare module spine {
|
|||||||
mixDuration: number;
|
mixDuration: number;
|
||||||
mixAlpha: number;
|
mixAlpha: number;
|
||||||
timelinesFirst: boolean[];
|
timelinesFirst: boolean[];
|
||||||
|
timelinesLast: boolean[];
|
||||||
timelinesRotation: number[];
|
timelinesRotation: number[];
|
||||||
reset(): void;
|
reset(): void;
|
||||||
getAnimationTime(): number;
|
getAnimationTime(): number;
|
||||||
|
|||||||
@ -1043,6 +1043,7 @@ var spine;
|
|||||||
this.queue = new EventQueue(this);
|
this.queue = new EventQueue(this);
|
||||||
this.propertyIDs = new spine.IntSet();
|
this.propertyIDs = new spine.IntSet();
|
||||||
this.animationsChanged = false;
|
this.animationsChanged = false;
|
||||||
|
this.multipleMixing = false;
|
||||||
this.timeScale = 1;
|
this.timeScale = 1;
|
||||||
this.trackEntryPool = new spine.Pool(function () { return new TrackEntry(); });
|
this.trackEntryPool = new spine.Pool(function () { return new TrackEntry(); });
|
||||||
this.data = data;
|
this.data = data;
|
||||||
@ -1170,7 +1171,9 @@ var spine;
|
|||||||
var timelineCount = from.animation.timelines.length;
|
var timelineCount = from.animation.timelines.length;
|
||||||
var timelines = from.animation.timelines;
|
var timelines = from.animation.timelines;
|
||||||
var timelinesFirst = from.timelinesFirst;
|
var timelinesFirst = from.timelinesFirst;
|
||||||
var alpha = from.alpha * entry.mixAlpha * (1 - mix);
|
var timelinesLast = this.multipleMixing ? null : from.timelinesLast;
|
||||||
|
var alphaBase = from.alpha * entry.mixAlpha;
|
||||||
|
var alphaMix = alphaBase * (1 - mix);
|
||||||
var firstFrame = from.timelinesRotation.length == 0;
|
var firstFrame = from.timelinesRotation.length == 0;
|
||||||
if (firstFrame)
|
if (firstFrame)
|
||||||
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
|
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
|
||||||
@ -1178,6 +1181,7 @@ var spine;
|
|||||||
for (var i = 0; i < timelineCount; i++) {
|
for (var i = 0; i < timelineCount; i++) {
|
||||||
var timeline = timelines[i];
|
var timeline = timelines[i];
|
||||||
var setupPose = timelinesFirst[i];
|
var setupPose = timelinesFirst[i];
|
||||||
|
var alpha = timelinesLast != null && setupPose && !timelinesLast[i] ? alphaBase : alphaMix;
|
||||||
if (timeline instanceof spine.RotateTimeline)
|
if (timeline instanceof spine.RotateTimeline)
|
||||||
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame);
|
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame);
|
||||||
else {
|
else {
|
||||||
@ -1318,9 +1322,24 @@ var spine;
|
|||||||
this.queue.interrupt(from);
|
this.queue.interrupt(from);
|
||||||
current.mixingFrom = from;
|
current.mixingFrom = from;
|
||||||
current.mixTime = 0;
|
current.mixTime = 0;
|
||||||
from.timelinesRotation.length = 0;
|
var mixingFrom = from.mixingFrom;
|
||||||
if (from.mixingFrom != null && from.mixDuration > 0)
|
if (mixingFrom != null && from.mixDuration > 0) {
|
||||||
|
if (!this.multipleMixing && from.mixTime / from.mixDuration < 0.5 && mixingFrom.animation != AnimationState.emptyAnimation) {
|
||||||
|
current.mixingFrom = mixingFrom;
|
||||||
|
mixingFrom.mixingFrom = from;
|
||||||
|
mixingFrom.mixTime = from.mixDuration - from.mixTime;
|
||||||
|
mixingFrom.mixDuration = from.mixDuration;
|
||||||
|
from.mixingFrom = null;
|
||||||
|
from = mixingFrom;
|
||||||
|
}
|
||||||
current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
|
current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
|
||||||
|
if (!this.multipleMixing) {
|
||||||
|
from.mixAlpha = 0;
|
||||||
|
from.mixTime = 0;
|
||||||
|
from.mixDuration = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
from.timelinesRotation.length = 0;
|
||||||
}
|
}
|
||||||
this.queue.start(current);
|
this.queue.start(current);
|
||||||
};
|
};
|
||||||
@ -1466,6 +1485,30 @@ var spine;
|
|||||||
if (entry != null)
|
if (entry != null)
|
||||||
this.checkTimelinesFirst(entry);
|
this.checkTimelinesFirst(entry);
|
||||||
}
|
}
|
||||||
|
if (this.multipleMixing)
|
||||||
|
return;
|
||||||
|
propertyIDs.clear();
|
||||||
|
var lowestMixingFrom = n;
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
var entry = this.tracks[i];
|
||||||
|
if (entry == null || entry.mixingFrom == null)
|
||||||
|
continue;
|
||||||
|
lowestMixingFrom = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for (i = n - 1; i >= lowestMixingFrom; i--) {
|
||||||
|
var entry = this.tracks[i];
|
||||||
|
if (entry == null)
|
||||||
|
continue;
|
||||||
|
var timelines = entry.animation.timelines;
|
||||||
|
for (var ii = 0, nn = entry.animation.timelines.length; ii < nn; ii++)
|
||||||
|
propertyIDs.add(timelines[ii].getPropertyId());
|
||||||
|
entry = entry.mixingFrom;
|
||||||
|
while (entry != null) {
|
||||||
|
this.checkTimelinesUsage(entry, entry.timelinesLast);
|
||||||
|
entry = entry.mixingFrom;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
AnimationState.prototype.setTimelinesFirst = function (entry) {
|
AnimationState.prototype.setTimelinesFirst = function (entry) {
|
||||||
if (entry.mixingFrom != null) {
|
if (entry.mixingFrom != null) {
|
||||||
@ -1523,6 +1566,7 @@ var spine;
|
|||||||
var TrackEntry = (function () {
|
var TrackEntry = (function () {
|
||||||
function TrackEntry() {
|
function TrackEntry() {
|
||||||
this.timelinesFirst = new Array();
|
this.timelinesFirst = new Array();
|
||||||
|
this.timelinesLast = new Array();
|
||||||
this.timelinesRotation = new Array();
|
this.timelinesRotation = new Array();
|
||||||
}
|
}
|
||||||
TrackEntry.prototype.reset = function () {
|
TrackEntry.prototype.reset = function () {
|
||||||
@ -1531,6 +1575,7 @@ var spine;
|
|||||||
this.animation = null;
|
this.animation = null;
|
||||||
this.listener = null;
|
this.listener = null;
|
||||||
this.timelinesFirst.length = 0;
|
this.timelinesFirst.length = 0;
|
||||||
|
this.timelinesLast.length = 0;
|
||||||
this.timelinesRotation.length = 0;
|
this.timelinesRotation.length = 0;
|
||||||
};
|
};
|
||||||
TrackEntry.prototype.getAnimationTime = function () {
|
TrackEntry.prototype.getAnimationTime = function () {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -39,6 +39,7 @@ module spine {
|
|||||||
queue = new EventQueue(this);
|
queue = new EventQueue(this);
|
||||||
propertyIDs = new IntSet();
|
propertyIDs = new IntSet();
|
||||||
animationsChanged = false;
|
animationsChanged = false;
|
||||||
|
multipleMixing = false;
|
||||||
timeScale = 1;
|
timeScale = 1;
|
||||||
|
|
||||||
trackEntryPool = new Pool<TrackEntry>(() => new TrackEntry());
|
trackEntryPool = new Pool<TrackEntry>(() => new TrackEntry());
|
||||||
@ -183,7 +184,9 @@ module spine {
|
|||||||
let timelineCount = from.animation.timelines.length;
|
let timelineCount = from.animation.timelines.length;
|
||||||
let timelines = from.animation.timelines;
|
let timelines = from.animation.timelines;
|
||||||
let timelinesFirst = from.timelinesFirst;
|
let timelinesFirst = from.timelinesFirst;
|
||||||
let alpha = from.alpha * entry.mixAlpha * (1 - mix);
|
let timelinesLast = this.multipleMixing ? null : from.timelinesLast;
|
||||||
|
let alphaBase = from.alpha * entry.mixAlpha;
|
||||||
|
let alphaMix = alphaBase * (1 - mix);
|
||||||
|
|
||||||
let firstFrame = from.timelinesRotation.length == 0;
|
let firstFrame = from.timelinesRotation.length == 0;
|
||||||
if (firstFrame) Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
|
if (firstFrame) Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
|
||||||
@ -192,6 +195,7 @@ module spine {
|
|||||||
for (let i = 0; i < timelineCount; i++) {
|
for (let i = 0; i < timelineCount; i++) {
|
||||||
let timeline = timelines[i];
|
let timeline = timelines[i];
|
||||||
let setupPose = timelinesFirst[i];
|
let setupPose = timelinesFirst[i];
|
||||||
|
let alpha = timelinesLast != null && setupPose && !timelinesLast[i] ? alphaBase : alphaMix;
|
||||||
if (timeline instanceof RotateTimeline)
|
if (timeline instanceof RotateTimeline)
|
||||||
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame);
|
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame);
|
||||||
else {
|
else {
|
||||||
@ -348,10 +352,30 @@ module spine {
|
|||||||
current.mixingFrom = from;
|
current.mixingFrom = from;
|
||||||
current.mixTime = 0;
|
current.mixTime = 0;
|
||||||
|
|
||||||
from.timelinesRotation.length = 0;
|
let mixingFrom = from.mixingFrom;
|
||||||
|
if (mixingFrom != null && from.mixDuration > 0) {
|
||||||
|
// A mix was interrupted, mix from the closest animation.
|
||||||
|
if (!this.multipleMixing && from.mixTime / from.mixDuration < 0.5 && mixingFrom.animation != AnimationState.emptyAnimation) {
|
||||||
|
current.mixingFrom = mixingFrom;
|
||||||
|
mixingFrom.mixingFrom = from;
|
||||||
|
mixingFrom.mixTime = from.mixDuration - from.mixTime;
|
||||||
|
mixingFrom.mixDuration = from.mixDuration;
|
||||||
|
from.mixingFrom = null;
|
||||||
|
from = mixingFrom;
|
||||||
|
}
|
||||||
|
|
||||||
// If not completely mixed in, set mixAlpha so mixing out happens from current mix to zero.
|
// The interrupted mix will mix out from its current percentage to zero.
|
||||||
if (from.mixingFrom != null && from.mixDuration > 0) current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
|
current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
|
||||||
|
|
||||||
|
// End the other animation after it is applied one last time.
|
||||||
|
if (!this.multipleMixing) {
|
||||||
|
from.mixAlpha = 0;
|
||||||
|
from.mixTime = 0;
|
||||||
|
from.mixDuration = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
from.timelinesRotation.length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.queue.start(current);
|
this.queue.start(current);
|
||||||
@ -510,6 +534,33 @@ module spine {
|
|||||||
let entry = this.tracks[i];
|
let entry = this.tracks[i];
|
||||||
if (entry != null) this.checkTimelinesFirst(entry);
|
if (entry != null) this.checkTimelinesFirst(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.multipleMixing) return;
|
||||||
|
|
||||||
|
// Set timelinesLast for mixingFrom entries, from highest track to lowest that has mixingFrom.
|
||||||
|
propertyIDs.clear();
|
||||||
|
let lowestMixingFrom = n;
|
||||||
|
for (i = 0; i < n; i++) { // Find lowest track with a mixingFrom entry.
|
||||||
|
let entry = this.tracks[i];
|
||||||
|
if (entry == null || entry.mixingFrom == null) continue;
|
||||||
|
lowestMixingFrom = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for (i = n - 1; i >= lowestMixingFrom; i--) { // Find first non-null entry.
|
||||||
|
let entry = this.tracks[i];
|
||||||
|
if (entry == null) continue;
|
||||||
|
|
||||||
|
// Store properties for non-mixingFrom entry but don't set timelinesLast, which is only used for mixingFrom entries.
|
||||||
|
let timelines = entry.animation.timelines;
|
||||||
|
for (let ii = 0, nn = entry.animation.timelines.length; ii < nn; ii++)
|
||||||
|
propertyIDs.add(timelines[ii].getPropertyId());
|
||||||
|
|
||||||
|
entry = entry.mixingFrom;
|
||||||
|
while (entry != null) {
|
||||||
|
this.checkTimelinesUsage(entry, entry.timelinesLast);
|
||||||
|
entry = entry.mixingFrom;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimelinesFirst (entry: TrackEntry) {
|
setTimelinesFirst (entry: TrackEntry) {
|
||||||
@ -578,6 +629,7 @@ module spine {
|
|||||||
delay: number; trackTime: number; trackLast: number; nextTrackLast: number; trackEnd: number; timeScale: number;
|
delay: number; trackTime: number; trackLast: number; nextTrackLast: number; trackEnd: number; timeScale: number;
|
||||||
alpha: number; mixTime: number; mixDuration: number; mixAlpha: number;
|
alpha: number; mixTime: number; mixDuration: number; mixAlpha: number;
|
||||||
timelinesFirst = new Array<boolean>();
|
timelinesFirst = new Array<boolean>();
|
||||||
|
timelinesLast = new Array<boolean>();
|
||||||
timelinesRotation = new Array<number>();
|
timelinesRotation = new Array<number>();
|
||||||
|
|
||||||
reset () {
|
reset () {
|
||||||
@ -586,6 +638,7 @@ module spine {
|
|||||||
this.animation = null;
|
this.animation = null;
|
||||||
this.listener = null;
|
this.listener = null;
|
||||||
this.timelinesFirst.length = 0;
|
this.timelinesFirst.length = 0;
|
||||||
|
this.timelinesLast.length = 0;
|
||||||
this.timelinesRotation.length = 0;
|
this.timelinesRotation.length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -50,7 +50,7 @@ var hoverboardDemo = function(loadingComplete, bgColor) {
|
|||||||
skeleton.updateWorldTransform();
|
skeleton.updateWorldTransform();
|
||||||
var offset = new spine.Vector2();
|
var offset = new spine.Vector2();
|
||||||
bounds = new spine.Vector2();
|
bounds = new spine.Vector2();
|
||||||
skeleton.getBounds(offset, bounds);
|
skeleton.getBounds(offset, bounds, []);
|
||||||
for (var i = 0; i < controlBones.length; i++) hoverTargets.push(null);
|
for (var i = 0; i < controlBones.length; i++) hoverTargets.push(null);
|
||||||
|
|
||||||
renderer.camera.position.x = offset.x + bounds.x / 2;
|
renderer.camera.position.x = offset.x + bounds.x / 2;
|
||||||
@ -139,15 +139,8 @@ var hoverboardDemo = function(loadingComplete, bgColor) {
|
|||||||
|
|
||||||
renderer.begin();
|
renderer.begin();
|
||||||
renderer.drawSkeleton(skeleton, true);
|
renderer.drawSkeleton(skeleton, true);
|
||||||
renderer.drawSkeletonDebug(skeleton, false, ["root"]);
|
// renderer.drawSkeletonDebug(skeleton, false, ["root"]);
|
||||||
gl.lineWidth(2);
|
|
||||||
for (var i = 0; i < controlBones.length; i++) {
|
|
||||||
var bone = skeleton.findBone(controlBones[i]);
|
|
||||||
var colorInner = hoverTargets[i] !== null ? spineDemos.HOVER_COLOR_INNER : spineDemos.NON_HOVER_COLOR_INNER;
|
|
||||||
var colorOuter = hoverTargets[i] !== null ? spineDemos.HOVER_COLOR_OUTER : spineDemos.NON_HOVER_COLOR_OUTER;
|
|
||||||
renderer.circle(true, bone.worldX, bone.worldY, 20, colorInner);
|
|
||||||
renderer.circle(false, bone.worldX, bone.worldY, 20, colorOuter);
|
|
||||||
}
|
|
||||||
renderer.end();
|
renderer.end();
|
||||||
gl.lineWidth(1);
|
gl.lineWidth(1);
|
||||||
|
|
||||||
|
|||||||
@ -102,7 +102,7 @@ var imageChangesDemo = function(loadingComplete, bgColor) {
|
|||||||
skeleton.updateWorldTransform();
|
skeleton.updateWorldTransform();
|
||||||
var offset = new spine.Vector2();
|
var offset = new spine.Vector2();
|
||||||
var size = new spine.Vector2();
|
var size = new spine.Vector2();
|
||||||
skeleton.getBounds(offset, size);
|
skeleton.getBounds(offset, size, []);
|
||||||
if (name === "alien") {
|
if (name === "alien") {
|
||||||
state.update(-anim.duration / 2.5);
|
state.update(-anim.duration / 2.5);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -110,7 +110,7 @@ var meshesDemo = function(loadingComplete, bgColor) {
|
|||||||
skeleton.updateWorldTransform();
|
skeleton.updateWorldTransform();
|
||||||
var offset = new spine.Vector2();
|
var offset = new spine.Vector2();
|
||||||
var size = new spine.Vector2();
|
var size = new spine.Vector2();
|
||||||
skeleton.getBounds(offset, size);
|
skeleton.getBounds(offset, size, []);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
atlas: atlas,
|
atlas: atlas,
|
||||||
|
|||||||
@ -47,7 +47,7 @@ var skinsDemo = function(loadingComplete, bgColor) {
|
|||||||
skeleton.updateWorldTransform();
|
skeleton.updateWorldTransform();
|
||||||
offset = new spine.Vector2();
|
offset = new spine.Vector2();
|
||||||
bounds = new spine.Vector2();
|
bounds = new spine.Vector2();
|
||||||
skeleton.getBounds(offset, bounds);
|
skeleton.getBounds(offset, bounds, []);
|
||||||
setupUI();
|
setupUI();
|
||||||
setupInput();
|
setupInput();
|
||||||
loadingComplete(canvas, render);
|
loadingComplete(canvas, render);
|
||||||
|
|||||||
@ -50,7 +50,7 @@ var spritesheetsDemo = function(loadingComplete, bgColor) {
|
|||||||
skeleton.updateWorldTransform();
|
skeleton.updateWorldTransform();
|
||||||
offset = new spine.Vector2();
|
offset = new spine.Vector2();
|
||||||
bounds = new spine.Vector2();
|
bounds = new spine.Vector2();
|
||||||
skeleton.getBounds(offset, bounds);
|
skeleton.getBounds(offset, bounds, []);
|
||||||
skeleton.x -= 60;
|
skeleton.x -= 60;
|
||||||
|
|
||||||
skeletonSeq = new spine.Skeleton(skeletonData);
|
skeletonSeq = new spine.Skeleton(skeletonData);
|
||||||
|
|||||||
@ -56,7 +56,7 @@ var stretchymanDemo = function(loadingComplete, bgColor) {
|
|||||||
skeleton.updateWorldTransform();
|
skeleton.updateWorldTransform();
|
||||||
var offset = new spine.Vector2();
|
var offset = new spine.Vector2();
|
||||||
bounds = new spine.Vector2();
|
bounds = new spine.Vector2();
|
||||||
skeleton.getBounds(offset, bounds);
|
skeleton.getBounds(offset, bounds, []);
|
||||||
for (var i = 0; i < controlBones.length; i++) hoverTargets.push(null);
|
for (var i = 0; i < controlBones.length; i++) hoverTargets.push(null);
|
||||||
state = new spine.AnimationState(new spine.AnimationStateData(skeleton.data));
|
state = new spine.AnimationState(new spine.AnimationStateData(skeleton.data));
|
||||||
state.setAnimation(0, "idle", true);
|
state.setAnimation(0, "idle", true);
|
||||||
|
|||||||
@ -50,7 +50,7 @@ var transformsDemo = function(loadingComplete, bgColor) {
|
|||||||
skeleton.updateWorldTransform();
|
skeleton.updateWorldTransform();
|
||||||
var offset = new spine.Vector2();
|
var offset = new spine.Vector2();
|
||||||
bounds = new spine.Vector2();
|
bounds = new spine.Vector2();
|
||||||
skeleton.getBounds(offset, bounds);
|
skeleton.getBounds(offset, bounds, []);
|
||||||
state = new spine.AnimationState(new spine.AnimationStateData(skeleton.data));
|
state = new spine.AnimationState(new spine.AnimationStateData(skeleton.data));
|
||||||
skeleton.setToSetupPose();
|
skeleton.setToSetupPose();
|
||||||
skeleton.updateWorldTransform();
|
skeleton.updateWorldTransform();
|
||||||
|
|||||||
@ -40,6 +40,7 @@ var transitionsDemo = function(loadingComplete, bgColor) {
|
|||||||
skeleton = loadSkeleton("spineboy");
|
skeleton = loadSkeleton("spineboy");
|
||||||
skeletonNoMix = new spine.Skeleton(skeleton.data);
|
skeletonNoMix = new spine.Skeleton(skeleton.data);
|
||||||
state = createState(0.25);
|
state = createState(0.25);
|
||||||
|
state.multipleMixing = true;
|
||||||
setAnimations(state, 0);
|
setAnimations(state, 0);
|
||||||
stateNoMix = createState(0);
|
stateNoMix = createState(0);
|
||||||
setAnimations(stateNoMix, -0.25);
|
setAnimations(stateNoMix, -0.25);
|
||||||
@ -47,7 +48,7 @@ var transitionsDemo = function(loadingComplete, bgColor) {
|
|||||||
state.apply(skeleton);
|
state.apply(skeleton);
|
||||||
skeleton.updateWorldTransform();
|
skeleton.updateWorldTransform();
|
||||||
bounds = { offset: new spine.Vector2(), size: new spine.Vector2() };
|
bounds = { offset: new spine.Vector2(), size: new spine.Vector2() };
|
||||||
skeleton.getBounds(bounds.offset, bounds.size);
|
skeleton.getBounds(bounds.offset, bounds.size, []);
|
||||||
setupInput();
|
setupInput();
|
||||||
$("#transitions-overlay").removeClass("overlay-hide");
|
$("#transitions-overlay").removeClass("overlay-hide");
|
||||||
$("#transitions-overlay").addClass("overlay");
|
$("#transitions-overlay").addClass("overlay");
|
||||||
|
|||||||
@ -48,7 +48,7 @@ var vineDemo = function(loadingComplete, bgColor) {
|
|||||||
skeleton.updateWorldTransform();
|
skeleton.updateWorldTransform();
|
||||||
var offset = new spine.Vector2();
|
var offset = new spine.Vector2();
|
||||||
bounds = new spine.Vector2();
|
bounds = new spine.Vector2();
|
||||||
skeleton.getBounds(offset, bounds);
|
skeleton.getBounds(offset, bounds, []);
|
||||||
state = new spine.AnimationState(new spine.AnimationStateData(skeleton.data));
|
state = new spine.AnimationState(new spine.AnimationStateData(skeleton.data));
|
||||||
state.setAnimation(0, "animation", true);
|
state.setAnimation(0, "animation", true);
|
||||||
state.apply(skeleton);
|
state.apply(skeleton);
|
||||||
|
|||||||
@ -29,11 +29,13 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.Collections;
|
using System.Collections.Generic;
|
||||||
using Spine;
|
using Spine;
|
||||||
using Spine.Unity.Modules.AttachmentTools;
|
using Spine.Unity.Modules.AttachmentTools;
|
||||||
|
|
||||||
namespace Spine.Unity.Modules {
|
namespace Spine.Unity.Modules {
|
||||||
|
/// <summary>
|
||||||
|
/// Example code for a component that replaces the default attachment of a slot with an image from a Spine atlas.</summary>
|
||||||
public class AtlasRegionAttacher : MonoBehaviour {
|
public class AtlasRegionAttacher : MonoBehaviour {
|
||||||
|
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
@ -45,8 +47,9 @@ namespace Spine.Unity.Modules {
|
|||||||
public string region;
|
public string region;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AtlasAsset atlasAsset;
|
[SerializeField] protected AtlasAsset atlasAsset;
|
||||||
public SlotRegionPair[] attachments;
|
[SerializeField] protected bool inheritProperties = true;
|
||||||
|
[SerializeField] protected List<SlotRegionPair> attachments = new List<SlotRegionPair>();
|
||||||
|
|
||||||
Atlas atlas;
|
Atlas atlas;
|
||||||
|
|
||||||
@ -58,15 +61,56 @@ namespace Spine.Unity.Modules {
|
|||||||
atlas = atlasAsset.GetAtlas();
|
atlas = atlasAsset.GetAtlas();
|
||||||
float scale = skeletonRenderer.skeletonDataAsset.scale;
|
float scale = skeletonRenderer.skeletonDataAsset.scale;
|
||||||
|
|
||||||
var enumerator = attachments.GetEnumerator();
|
foreach (var entry in attachments) {
|
||||||
while (enumerator.MoveNext()) {
|
var slot = skeletonRenderer.Skeleton.FindSlot(entry.slot);
|
||||||
var entry = (SlotRegionPair)enumerator.Current;
|
|
||||||
|
|
||||||
var slot = skeletonRenderer.skeleton.FindSlot(entry.slot);
|
|
||||||
var region = atlas.FindRegion(entry.region);
|
var region = atlas.FindRegion(entry.region);
|
||||||
slot.Attachment = region.ToRegionAttachment(entry.region, scale);
|
ReplaceAttachment(slot, region, scale, inheritProperties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ReplaceAttachment (Slot slot, AtlasRegion region, float scale, bool inheritProperties) {
|
||||||
|
var originalAttachment = slot.Attachment;
|
||||||
|
|
||||||
|
// Altas was empty
|
||||||
|
if (region == null) {
|
||||||
|
slot.Attachment = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Original was MeshAttachment
|
||||||
|
if (inheritProperties) {
|
||||||
|
var originalMeshAttachment = originalAttachment as MeshAttachment;
|
||||||
|
if (originalMeshAttachment != null) {
|
||||||
|
var newMeshAttachment = originalMeshAttachment.GetLinkedClone(); // Attach the region as a linked mesh to the original mesh.
|
||||||
|
newMeshAttachment.SetRegion(region);
|
||||||
|
slot.Attachment = newMeshAttachment;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Original was RegionAttachment or empty
|
||||||
|
{
|
||||||
|
var originalRegionAttachment = originalAttachment as RegionAttachment;
|
||||||
|
var newRegionAttachment = region.ToRegionAttachment(region.name, scale);
|
||||||
|
if (originalRegionAttachment != null && inheritProperties) {
|
||||||
|
newRegionAttachment.X = originalRegionAttachment.X;
|
||||||
|
newRegionAttachment.Y = originalRegionAttachment.Y;
|
||||||
|
newRegionAttachment.Rotation = originalRegionAttachment.Rotation;
|
||||||
|
newRegionAttachment.ScaleX = originalRegionAttachment.ScaleX;
|
||||||
|
newRegionAttachment.ScaleY = originalRegionAttachment.ScaleY;
|
||||||
|
newRegionAttachment.UpdateOffset();
|
||||||
|
|
||||||
|
newRegionAttachment.R = originalRegionAttachment.R;
|
||||||
|
newRegionAttachment.G = originalRegionAttachment.G;
|
||||||
|
newRegionAttachment.B = originalRegionAttachment.B;
|
||||||
|
newRegionAttachment.A = originalRegionAttachment.A;
|
||||||
|
}
|
||||||
|
|
||||||
|
slot.Attachment = newRegionAttachment;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user