@esotericsoftware/spine-webgl 4.2.33 → 4.2.35

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.
@@ -8727,8 +8727,8 @@ var spine = (() => {
8727
8727
  data.strength = input.readFloat();
8728
8728
  data.damping = input.readFloat();
8729
8729
  data.massInverse = input.readFloat();
8730
- data.wind = input.readFloat();
8731
- data.gravity = input.readFloat();
8730
+ data.wind = input.readFloat() * scale;
8731
+ data.gravity = input.readFloat() * scale;
8732
8732
  data.mix = input.readFloat();
8733
8733
  flags = input.readByte();
8734
8734
  if ((flags & 1) != 0)
@@ -9429,10 +9429,10 @@ var spine = (() => {
9429
9429
  timelines.push(readTimeline1(input, new PhysicsConstraintMassTimeline(frameCount, bezierCount, index), 1));
9430
9430
  break;
9431
9431
  case PHYSICS_WIND:
9432
- timelines.push(readTimeline1(input, new PhysicsConstraintWindTimeline(frameCount, bezierCount, index), 1));
9432
+ timelines.push(readTimeline1(input, new PhysicsConstraintWindTimeline(frameCount, bezierCount, index), scale));
9433
9433
  break;
9434
9434
  case PHYSICS_GRAVITY:
9435
- timelines.push(readTimeline1(input, new PhysicsConstraintGravityTimeline(frameCount, bezierCount, index), 1));
9435
+ timelines.push(readTimeline1(input, new PhysicsConstraintGravityTimeline(frameCount, bezierCount, index), scale));
9436
9436
  break;
9437
9437
  case PHYSICS_MIX:
9438
9438
  timelines.push(readTimeline1(input, new PhysicsConstraintMixTimeline(frameCount, bezierCount, index), 1));
@@ -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) * scale;
10637
+ data.gravity = getValue(constraintMap, "gravity", 0) * scale;
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,53 @@ 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
+ let timelineScale = 1;
11254
+ if (timelineName == "inertia")
11255
+ timeline = new PhysicsConstraintInertiaTimeline(frames, frames, constraintIndex);
11256
+ else if (timelineName == "strength")
11257
+ timeline = new PhysicsConstraintStrengthTimeline(frames, frames, constraintIndex);
11258
+ else if (timelineName == "damping")
11259
+ timeline = new PhysicsConstraintDampingTimeline(frames, frames, constraintIndex);
11260
+ else if (timelineName == "mass")
11261
+ timeline = new PhysicsConstraintMassTimeline(frames, frames, constraintIndex);
11262
+ else if (timelineName == "wind") {
11263
+ timeline = new PhysicsConstraintWindTimeline(frames, frames, constraintIndex);
11264
+ timelineScale = scale;
11265
+ } else if (timelineName == "gravity") {
11266
+ timeline = new PhysicsConstraintGravityTimeline(frames, frames, constraintIndex);
11267
+ timelineScale = scale;
11268
+ } else if (timelineName == "mix")
11269
+ timeline = new PhysicsConstraintMixTimeline(frames, frames, constraintIndex);
11270
+ else
11271
+ continue;
11272
+ timelines.push(readTimeline12(timelineMap, timeline, 0, timelineScale));
11273
+ }
11274
+ }
11275
+ }
11186
11276
  if (map.attachments) {
11187
11277
  for (let attachmentsName in map.attachments) {
11188
11278
  let attachmentsMap = map.attachments[attachmentsName];