@esotericsoftware/spine-canvas 4.2.32 → 4.2.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -10572,6 +10572,40 @@ var spine = (() => {
|
|
|
10572
10572
|
skeletonData.pathConstraints.push(data);
|
|
10573
10573
|
}
|
|
10574
10574
|
}
|
|
10575
|
+
if (root.physics) {
|
|
10576
|
+
for (let i = 0; i < root.physics.length; i++) {
|
|
10577
|
+
const constraintMap = root.physics[i];
|
|
10578
|
+
const data = new PhysicsConstraintData(constraintMap.name);
|
|
10579
|
+
data.order = getValue(constraintMap, "order", 0);
|
|
10580
|
+
data.skinRequired = getValue(constraintMap, "skin", false);
|
|
10581
|
+
const boneName = constraintMap.bone;
|
|
10582
|
+
const bone = skeletonData.findBone(boneName);
|
|
10583
|
+
if (bone == null)
|
|
10584
|
+
throw new Error("Physics bone not found: " + boneName);
|
|
10585
|
+
data.bone = bone;
|
|
10586
|
+
data.x = getValue(constraintMap, "x", 0);
|
|
10587
|
+
data.y = getValue(constraintMap, "y", 0);
|
|
10588
|
+
data.rotate = getValue(constraintMap, "rotate", 0);
|
|
10589
|
+
data.scaleX = getValue(constraintMap, "scaleX", 0);
|
|
10590
|
+
data.shearX = getValue(constraintMap, "shearX", 0);
|
|
10591
|
+
data.step = 1 / getValue(constraintMap, "fps", 60);
|
|
10592
|
+
data.inertia = getValue(constraintMap, "inertia", 1);
|
|
10593
|
+
data.strength = getValue(constraintMap, "strength", 100);
|
|
10594
|
+
data.damping = getValue(constraintMap, "damping", 1);
|
|
10595
|
+
data.massInverse = 1 / getValue(constraintMap, "mass", 1);
|
|
10596
|
+
data.wind = getValue(constraintMap, "wind", 0);
|
|
10597
|
+
data.gravity = getValue(constraintMap, "gravity", 0);
|
|
10598
|
+
data.mix = getValue(constraintMap, "mix", 1);
|
|
10599
|
+
data.inertiaGlobal = getValue(constraintMap, "inertiaGlobal", false);
|
|
10600
|
+
data.strengthGlobal = getValue(constraintMap, "strengthGlobal", false);
|
|
10601
|
+
data.dampingGlobal = getValue(constraintMap, "dampingGlobal", false);
|
|
10602
|
+
data.massGlobal = getValue(constraintMap, "massGlobal", false);
|
|
10603
|
+
data.windGlobal = getValue(constraintMap, "windGlobal", false);
|
|
10604
|
+
data.gravityGlobal = getValue(constraintMap, "gravityGlobal", false);
|
|
10605
|
+
data.mixGlobal = getValue(constraintMap, "mixGlobal", false);
|
|
10606
|
+
skeletonData.physicsConstraints.push(data);
|
|
10607
|
+
}
|
|
10608
|
+
}
|
|
10575
10609
|
if (root.skins) {
|
|
10576
10610
|
for (let i = 0; i < root.skins.length; i++) {
|
|
10577
10611
|
let skinMap = root.skins[i];
|
|
@@ -10612,6 +10646,15 @@ var spine = (() => {
|
|
|
10612
10646
|
skin.constraints.push(constraint);
|
|
10613
10647
|
}
|
|
10614
10648
|
}
|
|
10649
|
+
if (skinMap.physics) {
|
|
10650
|
+
for (let ii = 0; ii < skinMap.physics.length; ii++) {
|
|
10651
|
+
let constraintName = skinMap.physics[ii];
|
|
10652
|
+
let constraint = skeletonData.findPhysicsConstraint(constraintName);
|
|
10653
|
+
if (!constraint)
|
|
10654
|
+
throw new Error(`Couldn't find physics constraint ${constraintName} for skin ${skinMap.name}.`);
|
|
10655
|
+
skin.constraints.push(constraint);
|
|
10656
|
+
}
|
|
10657
|
+
}
|
|
10615
10658
|
for (let slotName in skinMap.attachments) {
|
|
10616
10659
|
let slot = skeletonData.findSlot(slotName);
|
|
10617
10660
|
if (!slot)
|
|
@@ -11143,6 +11186,50 @@ var spine = (() => {
|
|
|
11143
11186
|
}
|
|
11144
11187
|
}
|
|
11145
11188
|
}
|
|
11189
|
+
if (map.physics) {
|
|
11190
|
+
for (let constraintName in map.physics) {
|
|
11191
|
+
let constraintMap = map.physics[constraintName];
|
|
11192
|
+
let constraintIndex = -1;
|
|
11193
|
+
if (constraintName.length > 0) {
|
|
11194
|
+
let constraint = skeletonData.findPhysicsConstraint(constraintName);
|
|
11195
|
+
if (!constraint)
|
|
11196
|
+
throw new Error("Physics constraint not found: " + constraintName);
|
|
11197
|
+
constraintIndex = skeletonData.physicsConstraints.indexOf(constraint);
|
|
11198
|
+
}
|
|
11199
|
+
for (let timelineName in constraintMap) {
|
|
11200
|
+
let timelineMap = constraintMap[timelineName];
|
|
11201
|
+
let keyMap = timelineMap[0];
|
|
11202
|
+
if (!keyMap)
|
|
11203
|
+
continue;
|
|
11204
|
+
let frames = timelineMap.length;
|
|
11205
|
+
if (timelineName == "reset") {
|
|
11206
|
+
const timeline2 = new PhysicsConstraintResetTimeline(timelineMap.size, constraintIndex);
|
|
11207
|
+
for (let frame = 0; keyMap != null; keyMap = timelineMap[frame + 1], frame++)
|
|
11208
|
+
timeline2.setFrame(frame, getValue(keyMap, "time", 0));
|
|
11209
|
+
timelines.push(timeline2);
|
|
11210
|
+
continue;
|
|
11211
|
+
}
|
|
11212
|
+
let timeline;
|
|
11213
|
+
if (timelineName == "inertia")
|
|
11214
|
+
timeline = new PhysicsConstraintInertiaTimeline(frames, frames, constraintIndex);
|
|
11215
|
+
else if (timelineName == "strength")
|
|
11216
|
+
timeline = new PhysicsConstraintStrengthTimeline(frames, frames, constraintIndex);
|
|
11217
|
+
else if (timelineName == "damping")
|
|
11218
|
+
timeline = new PhysicsConstraintDampingTimeline(frames, frames, constraintIndex);
|
|
11219
|
+
else if (timelineName == "mass")
|
|
11220
|
+
timeline = new PhysicsConstraintMassTimeline(frames, frames, constraintIndex);
|
|
11221
|
+
else if (timelineName == "wind")
|
|
11222
|
+
timeline = new PhysicsConstraintWindTimeline(frames, frames, constraintIndex);
|
|
11223
|
+
else if (timelineName == "gravity")
|
|
11224
|
+
timeline = new PhysicsConstraintGravityTimeline(frames, frames, constraintIndex);
|
|
11225
|
+
else if (timelineName == "mix")
|
|
11226
|
+
timeline = new PhysicsConstraintMixTimeline(frames, frames, constraintIndex);
|
|
11227
|
+
else
|
|
11228
|
+
continue;
|
|
11229
|
+
timelines.push(readTimeline12(timelineMap, timeline, 0, 1));
|
|
11230
|
+
}
|
|
11231
|
+
}
|
|
11232
|
+
}
|
|
11146
11233
|
if (map.attachments) {
|
|
11147
11234
|
for (let attachmentsName in map.attachments) {
|
|
11148
11235
|
let attachmentsMap = map.attachments[attachmentsName];
|