mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
Inherit scale/rotation and additive blending for spine-js.
This commit is contained in:
parent
1caa8eaadd
commit
72f8f98a54
@ -41,7 +41,9 @@ spine.BoneData.prototype = {
|
|||||||
length: 0,
|
length: 0,
|
||||||
x: 0, y: 0,
|
x: 0, y: 0,
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
scaleX: 1, scaleY: 1
|
scaleX: 1, scaleY: 1,
|
||||||
|
inheritScale: true,
|
||||||
|
inheritRotation: true
|
||||||
};
|
};
|
||||||
|
|
||||||
spine.SlotData = function (name, boneData) {
|
spine.SlotData = function (name, boneData) {
|
||||||
@ -50,7 +52,8 @@ spine.SlotData = function (name, boneData) {
|
|||||||
};
|
};
|
||||||
spine.SlotData.prototype = {
|
spine.SlotData.prototype = {
|
||||||
r: 1, g: 1, b: 1, a: 1,
|
r: 1, g: 1, b: 1, a: 1,
|
||||||
attachmentName: null
|
attachmentName: null,
|
||||||
|
additiveBlending: false
|
||||||
};
|
};
|
||||||
|
|
||||||
spine.Bone = function (boneData, parent) {
|
spine.Bone = function (boneData, parent) {
|
||||||
@ -72,9 +75,14 @@ spine.Bone.prototype = {
|
|||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
this.worldX = this.x * parent.m00 + this.y * parent.m01 + parent.worldX;
|
this.worldX = this.x * parent.m00 + this.y * parent.m01 + parent.worldX;
|
||||||
this.worldY = this.x * parent.m10 + this.y * parent.m11 + parent.worldY;
|
this.worldY = this.x * parent.m10 + this.y * parent.m11 + parent.worldY;
|
||||||
this.worldScaleX = parent.worldScaleX * this.scaleX;
|
if (this.data.inheritScale) {
|
||||||
this.worldScaleY = parent.worldScaleY * this.scaleY;
|
this.worldScaleX = parent.worldScaleX * this.scaleX;
|
||||||
this.worldRotation = parent.worldRotation + this.rotation;
|
this.worldScaleY = parent.worldScaleY * this.scaleY;
|
||||||
|
} else {
|
||||||
|
this.worldScaleX = this.scaleX;
|
||||||
|
this.worldScaleY = this.scaleY;
|
||||||
|
}
|
||||||
|
this.worldRotation = this.data.inheritRotation ? parent.worldRotation + this.rotation : this.rotation;
|
||||||
} else {
|
} else {
|
||||||
this.worldX = this.x;
|
this.worldX = this.x;
|
||||||
this.worldY = this.y;
|
this.worldY = this.y;
|
||||||
@ -920,6 +928,8 @@ spine.SkeletonJson.prototype = {
|
|||||||
boneData.rotation = (boneMap["rotation"] || 0);
|
boneData.rotation = (boneMap["rotation"] || 0);
|
||||||
boneData.scaleX = boneMap["scaleX"] || 1;
|
boneData.scaleX = boneMap["scaleX"] || 1;
|
||||||
boneData.scaleY = boneMap["scaleY"] || 1;
|
boneData.scaleY = boneMap["scaleY"] || 1;
|
||||||
|
boneData.inheritScale = boneMap["inheritScale"] || true;
|
||||||
|
boneData.inheritRotation = boneMap["inheritRotation"] || true;
|
||||||
skeletonData.bones.push(boneData);
|
skeletonData.bones.push(boneData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -940,6 +950,7 @@ spine.SkeletonJson.prototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
slotData.attachmentName = slotMap["attachment"];
|
slotData.attachmentName = slotMap["attachment"];
|
||||||
|
slotData.additiveBlending = slotMap["additive"];
|
||||||
|
|
||||||
skeletonData.slots.push(slotData);
|
skeletonData.slots.push(slotData);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user