浏览代码

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

Davide Tantillo 1 年之前
父节点
当前提交
25acb4caf1

+ 6 - 5
spine-ts/spine-core/src/IkConstraint.ts

@@ -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 () {

+ 2 - 0
spine-ts/spine-core/src/PathConstraint.ts

@@ -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;

+ 2 - 0
spine-ts/spine-core/src/PhysicsConstraint.ts

@@ -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;

+ 8 - 6
spine-ts/spine-core/src/TransformConstraint.ts

@@ -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 () {