[ts] Port of commit cb48737 (partially - no copy constructor)

This commit is contained in:
Davide Tantillo 2024-04-30 09:33:43 +02:00
parent bab69e243a
commit 25acb4caf1
4 changed files with 18 additions and 11 deletions

View File

@ -69,11 +69,6 @@ export class IkConstraint implements Updatable {
if (!data) throw new Error("data cannot be null.");
if (!skeleton) throw new Error("skeleton cannot be null.");
this.data = data;
this.mix = data.mix;
this.softness = data.softness;
this.bendDirection = data.bendDirection;
this.compress = data.compress;
this.stretch = data.stretch;
this.bones = new Array<Bone>();
for (let i = 0; i < data.bones.length; i++) {
@ -83,7 +78,13 @@ export class IkConstraint implements Updatable {
}
let target = skeleton.findBone(data.target.name);
if (!target) throw new Error(`Couldn't find bone ${data.target.name}`);
this.target = target;
this.mix = data.mix;
this.softness = data.softness;
this.bendDirection = data.bendDirection;
this.compress = data.compress;
this.stretch = data.stretch;
}
isActive () {

View File

@ -75,6 +75,7 @@ export class PathConstraint implements Updatable {
if (!data) throw new Error("data cannot be null.");
if (!skeleton) throw new Error("skeleton cannot be null.");
this.data = data;
this.bones = new Array<Bone>();
for (let i = 0, n = data.bones.length; i < n; i++) {
let bone = skeleton.findBone(data.bones[i].name);
@ -84,6 +85,7 @@ export class PathConstraint implements Updatable {
let target = skeleton.findSlot(data.target.name);
if (!target) throw new Error(`Couldn't find target bone ${data.target.name}`);
this.target = target;
this.position = data.position;
this.spacing = data.spacing;
this.mixRotate = data.mixRotate;

View File

@ -79,7 +79,9 @@ export class PhysicsConstraint implements Updatable {
constructor (data: PhysicsConstraintData, skeleton: Skeleton) {
this.data = data;
this.skeleton = skeleton;
this.bone = skeleton.bones[data.bone.index];
this.inertia = data.inertia;
this.strength = data.strength;
this.damping = data.damping;

View File

@ -58,12 +58,7 @@ export class TransformConstraint implements Updatable {
if (!data) throw new Error("data cannot be null.");
if (!skeleton) throw new Error("skeleton cannot be null.");
this.data = data;
this.mixRotate = data.mixRotate;
this.mixX = data.mixX;
this.mixY = data.mixY;
this.mixScaleX = data.mixScaleX;
this.mixScaleY = data.mixScaleY;
this.mixShearY = data.mixShearY;
this.bones = new Array<Bone>();
for (let i = 0; i < data.bones.length; i++) {
let bone = skeleton.findBone(data.bones[i].name);
@ -73,6 +68,13 @@ export class TransformConstraint implements Updatable {
let target = skeleton.findBone(data.target.name);
if (!target) throw new Error(`Couldn't find target bone ${data.target.name}.`);
this.target = target;
this.mixRotate = data.mixRotate;
this.mixX = data.mixX;
this.mixY = data.mixY;
this.mixScaleX = data.mixScaleX;
this.mixScaleY = data.mixScaleY;
this.mixShearY = data.mixShearY;
}
isActive () {