@esotericsoftware/spine-webgl 4.2.33 → 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.
@@ -10612,6 +10612,40 @@ var spine = (() => {
10612
10612
  skeletonData.pathConstraints.push(data);
10613
10613
  }
10614
10614
  }
10615
+ if (root.physics) {
10616
+ for (let i = 0; i < root.physics.length; i++) {
10617
+ const constraintMap = root.physics[i];
10618
+ const data = new PhysicsConstraintData(constraintMap.name);
10619
+ data.order = getValue(constraintMap, "order", 0);
10620
+ data.skinRequired = getValue(constraintMap, "skin", false);
10621
+ const boneName = constraintMap.bone;
10622
+ const bone = skeletonData.findBone(boneName);
10623
+ if (bone == null)
10624
+ throw new Error("Physics bone not found: " + boneName);
10625
+ data.bone = bone;
10626
+ data.x = getValue(constraintMap, "x", 0);
10627
+ data.y = getValue(constraintMap, "y", 0);
10628
+ data.rotate = getValue(constraintMap, "rotate", 0);
10629
+ data.scaleX = getValue(constraintMap, "scaleX", 0);
10630
+ data.shearX = getValue(constraintMap, "shearX", 0);
10631
+ data.step = 1 / getValue(constraintMap, "fps", 60);
10632
+ data.inertia = getValue(constraintMap, "inertia", 1);
10633
+ data.strength = getValue(constraintMap, "strength", 100);
10634
+ data.damping = getValue(constraintMap, "damping", 1);
10635
+ data.massInverse = 1 / getValue(constraintMap, "mass", 1);
10636
+ data.wind = getValue(constraintMap, "wind", 0);
10637
+ data.gravity = getValue(constraintMap, "gravity", 0);
10638
+ data.mix = getValue(constraintMap, "mix", 1);
10639
+ data.inertiaGlobal = getValue(constraintMap, "inertiaGlobal", false);
10640
+ data.strengthGlobal = getValue(constraintMap, "strengthGlobal", false);
10641
+ data.dampingGlobal = getValue(constraintMap, "dampingGlobal", false);
10642
+ data.massGlobal = getValue(constraintMap, "massGlobal", false);
10643
+ data.windGlobal = getValue(constraintMap, "windGlobal", false);
10644
+ data.gravityGlobal = getValue(constraintMap, "gravityGlobal", false);
10645
+ data.mixGlobal = getValue(constraintMap, "mixGlobal", false);
10646
+ skeletonData.physicsConstraints.push(data);
10647
+ }
10648
+ }
10615
10649
  if (root.skins) {
10616
10650
  for (let i = 0; i < root.skins.length; i++) {
10617
10651
  let skinMap = root.skins[i];
@@ -10652,6 +10686,15 @@ var spine = (() => {
10652
10686
  skin.constraints.push(constraint);
10653
10687
  }
10654
10688
  }
10689
+ if (skinMap.physics) {
10690
+ for (let ii = 0; ii < skinMap.physics.length; ii++) {
10691
+ let constraintName = skinMap.physics[ii];
10692
+ let constraint = skeletonData.findPhysicsConstraint(constraintName);
10693
+ if (!constraint)
10694
+ throw new Error(`Couldn't find physics constraint ${constraintName} for skin ${skinMap.name}.`);
10695
+ skin.constraints.push(constraint);
10696
+ }
10697
+ }
10655
10698
  for (let slotName in skinMap.attachments) {
10656
10699
  let slot = skeletonData.findSlot(slotName);
10657
10700
  if (!slot)
@@ -11183,6 +11226,50 @@ var spine = (() => {
11183
11226
  }
11184
11227
  }
11185
11228
  }
11229
+ if (map.physics) {
11230
+ for (let constraintName in map.physics) {
11231
+ let constraintMap = map.physics[constraintName];
11232
+ let constraintIndex = -1;
11233
+ if (constraintName.length > 0) {
11234
+ let constraint = skeletonData.findPhysicsConstraint(constraintName);
11235
+ if (!constraint)
11236
+ throw new Error("Physics constraint not found: " + constraintName);
11237
+ constraintIndex = skeletonData.physicsConstraints.indexOf(constraint);
11238
+ }
11239
+ for (let timelineName in constraintMap) {
11240
+ let timelineMap = constraintMap[timelineName];
11241
+ let keyMap = timelineMap[0];
11242
+ if (!keyMap)
11243
+ continue;
11244
+ let frames = timelineMap.length;
11245
+ if (timelineName == "reset") {
11246
+ const timeline2 = new PhysicsConstraintResetTimeline(timelineMap.size, constraintIndex);
11247
+ for (let frame = 0; keyMap != null; keyMap = timelineMap[frame + 1], frame++)
11248
+ timeline2.setFrame(frame, getValue(keyMap, "time", 0));
11249
+ timelines.push(timeline2);
11250
+ continue;
11251
+ }
11252
+ let timeline;
11253
+ if (timelineName == "inertia")
11254
+ timeline = new PhysicsConstraintInertiaTimeline(frames, frames, constraintIndex);
11255
+ else if (timelineName == "strength")
11256
+ timeline = new PhysicsConstraintStrengthTimeline(frames, frames, constraintIndex);
11257
+ else if (timelineName == "damping")
11258
+ timeline = new PhysicsConstraintDampingTimeline(frames, frames, constraintIndex);
11259
+ else if (timelineName == "mass")
11260
+ timeline = new PhysicsConstraintMassTimeline(frames, frames, constraintIndex);
11261
+ else if (timelineName == "wind")
11262
+ timeline = new PhysicsConstraintWindTimeline(frames, frames, constraintIndex);
11263
+ else if (timelineName == "gravity")
11264
+ timeline = new PhysicsConstraintGravityTimeline(frames, frames, constraintIndex);
11265
+ else if (timelineName == "mix")
11266
+ timeline = new PhysicsConstraintMixTimeline(frames, frames, constraintIndex);
11267
+ else
11268
+ continue;
11269
+ timelines.push(readTimeline12(timelineMap, timeline, 0, 1));
11270
+ }
11271
+ }
11272
+ }
11186
11273
  if (map.attachments) {
11187
11274
  for (let attachmentsName in map.attachments) {
11188
11275
  let attachmentsMap = map.attachments[attachmentsName];