mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-02 21:59:09 +08:00
[ts] Port to 4.3 fixes (WIP)
This commit is contained in:
parent
43a3176db2
commit
b74ba4cab2
@ -123,7 +123,6 @@ export class SkeletonRenderer {
|
|||||||
let attachment = pose.attachment;
|
let attachment = pose.attachment;
|
||||||
|
|
||||||
let texture: HTMLImageElement;
|
let texture: HTMLImageElement;
|
||||||
let region: TextureAtlasRegion;
|
|
||||||
if (attachment instanceof RegionAttachment) {
|
if (attachment instanceof RegionAttachment) {
|
||||||
let regionAttachment = <RegionAttachment>attachment;
|
let regionAttachment = <RegionAttachment>attachment;
|
||||||
vertices = this.computeRegionVertices(slot, regionAttachment, false);
|
vertices = this.computeRegionVertices(slot, regionAttachment, false);
|
||||||
|
|||||||
@ -669,13 +669,11 @@ export class TranslateYTimeline extends BoneTimeline1 {
|
|||||||
|
|
||||||
/** Changes a bone's local {@link BoneLocal.scaleX} and {@link BoneLocal.scaleY}. */
|
/** Changes a bone's local {@link BoneLocal.scaleX} and {@link BoneLocal.scaleY}. */
|
||||||
export class ScaleTimeline extends BoneTimeline2 {
|
export class ScaleTimeline extends BoneTimeline2 {
|
||||||
boneIndex = 0;
|
|
||||||
|
|
||||||
constructor (frameCount: number, bezierCount: number, boneIndex: number) {
|
constructor (frameCount: number, bezierCount: number, boneIndex: number) {
|
||||||
super(frameCount, bezierCount, boneIndex, Property.scaleX, Property.scaleY);
|
super(frameCount, bezierCount, boneIndex, Property.scaleX, Property.scaleY);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected apply1 (pose: BoneLocal, setup: BoneLocal, time: number, alpha:number, blend: MixBlend,direction: MixDirection) {
|
protected apply1 (pose: BoneLocal, setup: BoneLocal, time: number, alpha:number, blend: MixBlend, direction: MixDirection) {
|
||||||
let frames = this.frames;
|
let frames = this.frames;
|
||||||
if (time < frames[0]) {
|
if (time < frames[0]) {
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
|
|||||||
@ -63,7 +63,7 @@ export class BonePose extends BoneLocal implements Update {
|
|||||||
|
|
||||||
/** Called by {@link Skeleton#updateCache()} to compute the world transform, if needed. */
|
/** Called by {@link Skeleton#updateCache()} to compute the world transform, if needed. */
|
||||||
public update (skeleton: Skeleton, physics: Physics): void {
|
public update (skeleton: Skeleton, physics: Physics): void {
|
||||||
if (this.world != skeleton._update) this.updateWorldTransform(skeleton);
|
if (this.world !== skeleton._update) this.updateWorldTransform(skeleton);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Computes the world transform using the parent bone's applied pose and this pose. Child bones are not updated.
|
/** Computes the world transform using the parent bone's applied pose and this pose. Child bones are not updated.
|
||||||
@ -71,17 +71,17 @@ export class BonePose extends BoneLocal implements Update {
|
|||||||
* See <a href="https://esotericsoftware.com/spine-runtime-skeletons#World-transforms">World transforms</a> in the Spine
|
* See <a href="https://esotericsoftware.com/spine-runtime-skeletons#World-transforms">World transforms</a> in the Spine
|
||||||
* Runtimes Guide. */
|
* Runtimes Guide. */
|
||||||
updateWorldTransform (skeleton: Skeleton): void {
|
updateWorldTransform (skeleton: Skeleton): void {
|
||||||
if (this.local == skeleton._update)
|
if (this.local === skeleton._update)
|
||||||
this.updateLocalTransform(skeleton);
|
this.updateLocalTransform(skeleton);
|
||||||
else
|
else
|
||||||
this.world = skeleton._update;
|
this.world = skeleton._update;
|
||||||
|
|
||||||
const rotation = this.rotation;
|
let rotation = this.rotation;
|
||||||
const scaleX = this.scaleX;
|
const scaleX = this.scaleX;
|
||||||
const scaleY = this.scaleY;
|
const scaleY = this.scaleY;
|
||||||
const shearX = this.shearX;
|
const shearX = this.shearX;
|
||||||
const shearY = this.shearY;
|
const shearY = this.shearY;
|
||||||
if (this.bone.parent == null) { // Root bone.
|
if (!this.bone.parent) { // Root bone.
|
||||||
const sx = skeleton.scaleX, sy = skeleton.scaleY;
|
const sx = skeleton.scaleX, sy = skeleton.scaleY;
|
||||||
const rx = (rotation + shearX) * MathUtils.degRad;
|
const rx = (rotation + shearX) * MathUtils.degRad;
|
||||||
const ry = (rotation + 90 + shearY) * MathUtils.degRad;
|
const ry = (rotation + 90 + shearY) * MathUtils.degRad;
|
||||||
@ -152,7 +152,7 @@ export class BonePose extends BoneLocal implements Update {
|
|||||||
}
|
}
|
||||||
case Inherit.NoScale:
|
case Inherit.NoScale:
|
||||||
case Inherit.NoScaleOrReflection: {
|
case Inherit.NoScaleOrReflection: {
|
||||||
this.rotation *= MathUtils.degRad;
|
rotation *= MathUtils.degRad;
|
||||||
const cos = Math.cos(rotation), sin = Math.sin(rotation);
|
const cos = Math.cos(rotation), sin = Math.sin(rotation);
|
||||||
let za = (pa * cos + pb * sin) / skeleton.scaleX;
|
let za = (pa * cos + pb * sin) / skeleton.scaleX;
|
||||||
let zc = (pc * cos + pd * sin) / skeleton.scaleY;
|
let zc = (pc * cos + pd * sin) / skeleton.scaleY;
|
||||||
|
|||||||
@ -68,8 +68,8 @@ export class IkConstraint extends Constraint<IkConstraint, IkConstraintData, IkC
|
|||||||
update (skeleton: Skeleton, physics: Physics) {
|
update (skeleton: Skeleton, physics: Physics) {
|
||||||
const p = this.applied;
|
const p = this.applied;
|
||||||
if (p.mix === 0) return;
|
if (p.mix === 0) return;
|
||||||
let target = this.target.applied;
|
const target = this.target.applied;
|
||||||
let bones = this.bones;
|
const bones = this.bones;
|
||||||
switch (bones.length) {
|
switch (bones.length) {
|
||||||
case 1:
|
case 1:
|
||||||
IkConstraint.apply(skeleton, bones[0], target.worldX, target.worldY, p.compress, p.stretch, this.data.uniform, p.mix);
|
IkConstraint.apply(skeleton, bones[0], target.worldX, target.worldY, p.compress, p.stretch, this.data.uniform, p.mix);
|
||||||
@ -177,7 +177,7 @@ export class IkConstraint extends Constraint<IkConstraint, IkConstraintData, IkC
|
|||||||
if (parent.inherit != Inherit.Normal || child.inherit != Inherit.Normal) return;
|
if (parent.inherit != Inherit.Normal || child.inherit != Inherit.Normal) return;
|
||||||
parent.modifyLocal(skeleton);
|
parent.modifyLocal(skeleton);
|
||||||
child.modifyLocal(skeleton);
|
child.modifyLocal(skeleton);
|
||||||
let px = parent.x, py = parent.y, psx = parent.scaleX, psy = parent.scaleY, sx = psx, sy = psy, csx = child.scaleX;
|
let px = parent.x, py = parent.y, psx = parent.scaleX, psy = parent.scaleY, csx = child.scaleX;
|
||||||
let os1 = 0, os2 = 0, s2 = 0;
|
let os1 = 0, os2 = 0, s2 = 0;
|
||||||
if (psx < 0) {
|
if (psx < 0) {
|
||||||
psx = -psx;
|
psx = -psx;
|
||||||
|
|||||||
@ -140,7 +140,7 @@ export class SkeletonJson {
|
|||||||
// Constraints.
|
// Constraints.
|
||||||
if (root.constraints) {
|
if (root.constraints) {
|
||||||
for (const constraintMap of root.constraints) {
|
for (const constraintMap of root.constraints) {
|
||||||
const name = constraintMap.getString("name");
|
const name = constraintMap.name;
|
||||||
const skinRequired = getValue(constraintMap, "skin", false);
|
const skinRequired = getValue(constraintMap, "skin", false);
|
||||||
switch (getValue(constraintMap, "type", false)) {
|
switch (getValue(constraintMap, "type", false)) {
|
||||||
case "ik": {
|
case "ik": {
|
||||||
@ -259,6 +259,7 @@ export class SkeletonJson {
|
|||||||
if (shearY) setup.mixShearY = getValue(constraintMap, "mixShearY", 1);
|
if (shearY) setup.mixShearY = getValue(constraintMap, "mixShearY", 1);
|
||||||
|
|
||||||
skeletonData.constraints.push(data);
|
skeletonData.constraints.push(data);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case "path": {
|
case "path": {
|
||||||
const data = new PathConstraintData(name);
|
const data = new PathConstraintData(name);
|
||||||
|
|||||||
@ -50,7 +50,7 @@ export class TransformConstraintData extends ConstraintData<TransformConstraint,
|
|||||||
}
|
}
|
||||||
private _source: BoneData | null = null;
|
private _source: BoneData | null = null;
|
||||||
|
|
||||||
offsets = new Array<number>();
|
offsets = [0, 0, 0, 0, 0, 0];
|
||||||
|
|
||||||
/** An offset added to the constrained bone X translation. */
|
/** An offset added to the constrained bone X translation. */
|
||||||
offsetX = 0;
|
offsetX = 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user