mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-09 16:48:43 +08:00
[ts] 4.3 porting WIP - latest updates.
This commit is contained in:
parent
425f3d5776
commit
8d046cbbf4
@ -139,8 +139,8 @@ export class PhysicsConstraint extends Constraint<PhysicsConstraint, PhysicsCons
|
||||
this.ux = bx;
|
||||
this.uy = by;
|
||||
} else {
|
||||
let a = this.remaining, i = p.inertia, f = skeleton.data.referenceScale, d = -1, m = 0, e = 0, qx = this.data.limit * delta,
|
||||
qy = qx * Math.abs(skeleton.scaleY);
|
||||
let a = this.remaining, i = p.inertia, f = skeleton.data.referenceScale, d = -1, m = 0, e = 0, ax = 0, ay = 0,
|
||||
qx = this.data.limit * delta, qy = qx * Math.abs(skeleton.scaleY);
|
||||
qx *= Math.abs(skeleton.scaleX);
|
||||
if (x || y) {
|
||||
if (x) {
|
||||
@ -158,8 +158,9 @@ export class PhysicsConstraint extends Constraint<PhysicsConstraint, PhysicsCons
|
||||
d = Math.pow(p.damping, 60 * t);
|
||||
m = t * p.massInverse;
|
||||
e = p.strength;
|
||||
let w = f * p.wind * skeleton.scaleX, g = f * p.gravity * skeleton.scaleY,
|
||||
ax = w * skeleton.windX + g * skeleton.gravityX, ay = w * skeleton.windY + g * skeleton.gravityY;
|
||||
let w = f * p.wind, g = f * p.gravity;
|
||||
ax = (w * skeleton.windX + g * skeleton.gravityX) * skeleton.scaleX;
|
||||
ay = (w * skeleton.windY + g * skeleton.gravityY) * skeleton.scaleY;
|
||||
do {
|
||||
if (x) {
|
||||
this.xVelocity += (ax - this.xOffset * e) * m;
|
||||
@ -214,11 +215,11 @@ export class PhysicsConstraint extends Constraint<PhysicsConstraint, PhysicsCons
|
||||
d = Math.pow(p.damping, 60 * t);
|
||||
m = t * p.massInverse;
|
||||
e = p.strength;
|
||||
const w = f * p.wind, g = f * (Skeleton.yDown ? -p.gravity : p.gravity);
|
||||
ax = (w * skeleton.windX + g * skeleton.gravityX) * skeleton.scaleX;
|
||||
ay = (w * skeleton.windY + g * skeleton.gravityY) * skeleton.scaleY;
|
||||
}
|
||||
var g = Skeleton.yDown ? -p.gravity : p.gravity;
|
||||
let rs = this.rotateOffset, ss = this.scaleOffset, h = l / f,
|
||||
ax = p.wind * skeleton.windX + g * skeleton.gravityX,
|
||||
ay = p.wind * skeleton.windY + g * skeleton.gravityY;
|
||||
let rs = this.rotateOffset, ss = this.scaleOffset, h = l / f
|
||||
while (true) {
|
||||
a -= t;
|
||||
if (scaleX) {
|
||||
|
||||
@ -37,19 +37,45 @@ export abstract class Posed<
|
||||
|
||||
/** The constraint's setup pose data. */
|
||||
readonly data: D;
|
||||
readonly pose: P;
|
||||
readonly pose: A;
|
||||
readonly constrained: A;
|
||||
applied: A;
|
||||
|
||||
constructor (data: D, pose: P, constrained: A) {
|
||||
constructor (data: D, pose: A, constrained: A) {
|
||||
if (data == null) throw new Error("data cannot be null.");
|
||||
this.data = data;
|
||||
this.pose = pose;
|
||||
this.constrained = constrained;
|
||||
this.applied = pose as A;
|
||||
this.applied = pose;
|
||||
}
|
||||
|
||||
public setupPose (): void {
|
||||
this.pose.set(this.data.setup);
|
||||
}
|
||||
|
||||
/** The constraint's setup pose data. */
|
||||
public getData (): D {
|
||||
return this.data;
|
||||
}
|
||||
|
||||
public getPose (): P {
|
||||
return this.pose;
|
||||
}
|
||||
|
||||
public getAppliedPose (): A {
|
||||
return this.applied;
|
||||
}
|
||||
|
||||
usePose () { // Port: usePose - reference runtime: pose()
|
||||
this.applied = this.pose;
|
||||
}
|
||||
|
||||
useConstrained () { // Port: useConstrained - reference runtime: constrained()
|
||||
this.applied = this.constrained;
|
||||
}
|
||||
|
||||
resetConstrained () { // Port: resetConstrained - reference runtime: reset()
|
||||
this.constrained.set(this.pose);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ export abstract class PosedActive<
|
||||
|
||||
active = false;
|
||||
|
||||
constructor (data: D, pose: P, constrained: A) {
|
||||
constructor (data: D, pose: A, constrained: A) {
|
||||
super(data, pose, constrained);
|
||||
this.setupPose();
|
||||
}
|
||||
|
||||
@ -165,10 +165,8 @@ export class Skeleton {
|
||||
this.resetCache.length = 0;
|
||||
|
||||
let slots = this.slots;
|
||||
for (let i = 0, n = slots.length; i < n; i++) {
|
||||
const slot = slots[i];
|
||||
slot.applied = slot.pose;
|
||||
}
|
||||
for (let i = 0, n = slots.length; i < n; i++)
|
||||
slots[i].usePose();
|
||||
|
||||
let bones = this.bones;
|
||||
const boneCount = bones.length;
|
||||
@ -176,7 +174,7 @@ export class Skeleton {
|
||||
let bone = bones[i];
|
||||
bone.sorted = bone.data.skinRequired;
|
||||
bone.active = !bone.sorted;
|
||||
bone.applied = bone.pose as BonePose;
|
||||
bone.usePose();
|
||||
}
|
||||
if (this.skin) {
|
||||
let skinBones = this.skin.bones;
|
||||
@ -192,10 +190,8 @@ export class Skeleton {
|
||||
|
||||
let constraints = this.constraints;
|
||||
let n = this.constraints.length;
|
||||
for (let i = 0; i < n; i++) {
|
||||
const constraint = constraints[i];
|
||||
constraint.applied = constraint.pose;
|
||||
}
|
||||
for (let i = 0; i < n; i++)
|
||||
constraints[i].usePose();
|
||||
for (let i = 0; i < n; i++) {
|
||||
const constraint = constraints[i];
|
||||
constraint.active = constraint.isSourceActive()
|
||||
@ -216,7 +212,7 @@ export class Skeleton {
|
||||
|
||||
constrained (object: Posed<any, any, any>) {
|
||||
if (object.pose === object.applied) {
|
||||
object.applied = object.constrained;
|
||||
object.useConstrained();
|
||||
this.resetCache.push(object);
|
||||
}
|
||||
}
|
||||
@ -247,10 +243,8 @@ export class Skeleton {
|
||||
this._update++;
|
||||
|
||||
const resetCache = this.resetCache;
|
||||
for (let i = 0, n = this.resetCache.length; i < n; i++) {
|
||||
const object = resetCache[i];
|
||||
object.applied.set(object.pose);
|
||||
}
|
||||
for (let i = 0, n = this.resetCache.length; i < n; i++)
|
||||
resetCache[i].resetConstrained();
|
||||
|
||||
const updateCache = this._updateCache;
|
||||
for (let i = 0, n = this._updateCache.length; i < n; i++)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user