@esotericsoftware/spine-core 4.2.38 → 4.2.40

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.
@@ -3926,7 +3926,7 @@ var spine = (() => {
3926
3926
  complete = true;
3927
3927
  else {
3928
3928
  const cycles = Math.floor(entry.trackTime / duration);
3929
- complete = cycles > 0 && cycles > Math.floor(entry.trackTime / duration);
3929
+ complete = cycles > 0 && cycles > Math.floor(entry.trackLast / duration);
3930
3930
  }
3931
3931
  } else
3932
3932
  complete = animationTime >= animationEnd && entry.animationLast < animationEnd;
@@ -4382,8 +4382,11 @@ var spine = (() => {
4382
4382
  }
4383
4383
  set mixDuration(mixDuration) {
4384
4384
  this._mixDuration = mixDuration;
4385
+ }
4386
+ setMixDurationWithDelta(mixDuration, delay) {
4387
+ this._mixDuration = mixDuration;
4385
4388
  if (this.previous != null && this.delay <= 0)
4386
- this.delay += this.previous.getTrackComplete() - mixDuration;
4389
+ this.delay += this.previous.getTrackComplete() - delay;
4387
4390
  this.delay = this.delay;
4388
4391
  }
4389
4392
  /** Controls how properties keyed in the animation are mixed with lower tracks. Defaults to {@link MixBlend#replace}, which
@@ -6190,11 +6193,6 @@ var spine = (() => {
6190
6193
  if (!skeleton)
6191
6194
  throw new Error("skeleton cannot be null.");
6192
6195
  this.data = data;
6193
- this.mix = data.mix;
6194
- this.softness = data.softness;
6195
- this.bendDirection = data.bendDirection;
6196
- this.compress = data.compress;
6197
- this.stretch = data.stretch;
6198
6196
  this.bones = new Array();
6199
6197
  for (let i = 0; i < data.bones.length; i++) {
6200
6198
  let bone = skeleton.findBone(data.bones[i].name);
@@ -6206,6 +6204,11 @@ var spine = (() => {
6206
6204
  if (!target)
6207
6205
  throw new Error(`Couldn't find bone ${data.target.name}`);
6208
6206
  this.target = target;
6207
+ this.mix = data.mix;
6208
+ this.softness = data.softness;
6209
+ this.bendDirection = data.bendDirection;
6210
+ this.compress = data.compress;
6211
+ this.stretch = data.stretch;
6209
6212
  }
6210
6213
  isActive() {
6211
6214
  return this.active;
@@ -7340,12 +7343,6 @@ var spine = (() => {
7340
7343
  if (!skeleton)
7341
7344
  throw new Error("skeleton cannot be null.");
7342
7345
  this.data = data;
7343
- this.mixRotate = data.mixRotate;
7344
- this.mixX = data.mixX;
7345
- this.mixY = data.mixY;
7346
- this.mixScaleX = data.mixScaleX;
7347
- this.mixScaleY = data.mixScaleY;
7348
- this.mixShearY = data.mixShearY;
7349
7346
  this.bones = new Array();
7350
7347
  for (let i = 0; i < data.bones.length; i++) {
7351
7348
  let bone = skeleton.findBone(data.bones[i].name);
@@ -7357,6 +7354,12 @@ var spine = (() => {
7357
7354
  if (!target)
7358
7355
  throw new Error(`Couldn't find target bone ${data.target.name}.`);
7359
7356
  this.target = target;
7357
+ this.mixRotate = data.mixRotate;
7358
+ this.mixX = data.mixX;
7359
+ this.mixY = data.mixY;
7360
+ this.mixScaleX = data.mixScaleX;
7361
+ this.mixScaleY = data.mixScaleY;
7362
+ this.mixShearY = data.mixShearY;
7360
7363
  }
7361
7364
  isActive() {
7362
7365
  return this.active;
@@ -8057,8 +8060,9 @@ var spine = (() => {
8057
8060
  /** Returns the axis aligned bounding box (AABB) of the region and mesh attachments for the current pose.
8058
8061
  * @param offset An output value, the distance from the skeleton origin to the bottom left corner of the AABB.
8059
8062
  * @param size An output value, the width and height of the AABB.
8060
- * @param temp Working memory to temporarily store attachments' computed world vertices. */
8061
- getBounds(offset, size, temp = new Array(2)) {
8063
+ * @param temp Working memory to temporarily store attachments' computed world vertices.
8064
+ * @param clipper {@link SkeletonClipping} to use. If <code>null</code>, no clipping is applied. */
8065
+ getBounds(offset, size, temp = new Array(2), clipper = null) {
8062
8066
  if (!offset)
8063
8067
  throw new Error("offset cannot be null.");
8064
8068
  if (!size)
@@ -8071,18 +8075,29 @@ var spine = (() => {
8071
8075
  continue;
8072
8076
  let verticesLength = 0;
8073
8077
  let vertices = null;
8078
+ let triangles = null;
8074
8079
  let attachment = slot.getAttachment();
8075
8080
  if (attachment instanceof RegionAttachment) {
8076
8081
  verticesLength = 8;
8077
8082
  vertices = Utils.setArraySize(temp, verticesLength, 0);
8078
8083
  attachment.computeWorldVertices(slot, vertices, 0, 2);
8084
+ triangles = _Skeleton.quadTriangles;
8079
8085
  } else if (attachment instanceof MeshAttachment) {
8080
8086
  let mesh = attachment;
8081
8087
  verticesLength = mesh.worldVerticesLength;
8082
8088
  vertices = Utils.setArraySize(temp, verticesLength, 0);
8083
8089
  mesh.computeWorldVertices(slot, 0, verticesLength, vertices, 0, 2);
8090
+ triangles = mesh.triangles;
8091
+ } else if (attachment instanceof ClippingAttachment && clipper != null) {
8092
+ clipper.clipStart(slot, attachment);
8093
+ continue;
8084
8094
  }
8085
- if (vertices) {
8095
+ if (vertices && triangles) {
8096
+ if (clipper != null && clipper.isClipping()) {
8097
+ clipper.clipTriangles(vertices, verticesLength, triangles, triangles.length);
8098
+ vertices = clipper.clippedVertices;
8099
+ verticesLength = clipper.clippedVertices.length;
8100
+ }
8086
8101
  for (let ii = 0, nn = vertices.length; ii < nn; ii += 2) {
8087
8102
  let x = vertices[ii], y = vertices[ii + 1];
8088
8103
  minX = Math.min(minX, x);
@@ -8091,7 +8106,11 @@ var spine = (() => {
8091
8106
  maxY = Math.max(maxY, y);
8092
8107
  }
8093
8108
  }
8109
+ if (clipper != null)
8110
+ clipper.clipEndWithSlot(slot);
8094
8111
  }
8112
+ if (clipper != null)
8113
+ clipper.clipEnd();
8095
8114
  offset.set(minX, minY);
8096
8115
  size.set(maxX - minX, maxY - minY);
8097
8116
  }
@@ -8112,6 +8131,7 @@ var spine = (() => {
8112
8131
  }
8113
8132
  };
8114
8133
  var Skeleton = _Skeleton;
8134
+ __publicField(Skeleton, "quadTriangles", [0, 1, 2, 2, 3, 0]);
8115
8135
  __publicField(Skeleton, "yDown", false);
8116
8136
  var Physics = /* @__PURE__ */ ((Physics2) => {
8117
8137
  Physics2[Physics2["none"] = 0] = "none";
@@ -10292,6 +10312,73 @@ var spine = (() => {
10292
10312
  return this.clipAttachment != null;
10293
10313
  }
10294
10314
  clipTriangles(vertices, verticesLength, triangles, trianglesLength, uvs, light, dark, twoColor) {
10315
+ if (uvs && light && dark && typeof twoColor === "boolean")
10316
+ this.clipTrianglesRender(vertices, verticesLength, triangles, trianglesLength, uvs, light, dark, twoColor);
10317
+ else
10318
+ this.clipTrianglesNoRender(vertices, verticesLength, triangles, trianglesLength);
10319
+ }
10320
+ clipTrianglesNoRender(vertices, verticesLength, triangles, trianglesLength) {
10321
+ let clipOutput = this.clipOutput, clippedVertices = this.clippedVertices;
10322
+ let clippedTriangles = this.clippedTriangles;
10323
+ let polygons = this.clippingPolygons;
10324
+ let polygonsCount = polygons.length;
10325
+ let vertexSize = 2;
10326
+ let index = 0;
10327
+ clippedVertices.length = 0;
10328
+ clippedTriangles.length = 0;
10329
+ outer:
10330
+ for (let i = 0; i < trianglesLength; i += 3) {
10331
+ let vertexOffset = triangles[i] << 1;
10332
+ let x1 = vertices[vertexOffset], y1 = vertices[vertexOffset + 1];
10333
+ vertexOffset = triangles[i + 1] << 1;
10334
+ let x2 = vertices[vertexOffset], y2 = vertices[vertexOffset + 1];
10335
+ vertexOffset = triangles[i + 2] << 1;
10336
+ let x3 = vertices[vertexOffset], y3 = vertices[vertexOffset + 1];
10337
+ for (let p = 0; p < polygonsCount; p++) {
10338
+ let s = clippedVertices.length;
10339
+ if (this.clip(x1, y1, x2, y2, x3, y3, polygons[p], clipOutput)) {
10340
+ let clipOutputLength = clipOutput.length;
10341
+ if (clipOutputLength == 0)
10342
+ continue;
10343
+ let clipOutputCount = clipOutputLength >> 1;
10344
+ let clipOutputItems = this.clipOutput;
10345
+ let clippedVerticesItems = Utils.setArraySize(clippedVertices, s + clipOutputCount * vertexSize);
10346
+ for (let ii = 0; ii < clipOutputLength; ii += 2) {
10347
+ let x = clipOutputItems[ii], y = clipOutputItems[ii + 1];
10348
+ clippedVerticesItems[s] = x;
10349
+ clippedVerticesItems[s + 1] = y;
10350
+ s += 2;
10351
+ }
10352
+ s = clippedTriangles.length;
10353
+ let clippedTrianglesItems = Utils.setArraySize(clippedTriangles, s + 3 * (clipOutputCount - 2));
10354
+ clipOutputCount--;
10355
+ for (let ii = 1; ii < clipOutputCount; ii++) {
10356
+ clippedTrianglesItems[s] = index;
10357
+ clippedTrianglesItems[s + 1] = index + ii;
10358
+ clippedTrianglesItems[s + 2] = index + ii + 1;
10359
+ s += 3;
10360
+ }
10361
+ index += clipOutputCount + 1;
10362
+ } else {
10363
+ let clippedVerticesItems = Utils.setArraySize(clippedVertices, s + 3 * vertexSize);
10364
+ clippedVerticesItems[s] = x1;
10365
+ clippedVerticesItems[s + 1] = y1;
10366
+ clippedVerticesItems[s + 2] = x2;
10367
+ clippedVerticesItems[s + 3] = y2;
10368
+ clippedVerticesItems[s + 4] = x3;
10369
+ clippedVerticesItems[s + 5] = y3;
10370
+ s = clippedTriangles.length;
10371
+ let clippedTrianglesItems = Utils.setArraySize(clippedTriangles, s + 3);
10372
+ clippedTrianglesItems[s] = index;
10373
+ clippedTrianglesItems[s + 1] = index + 1;
10374
+ clippedTrianglesItems[s + 2] = index + 2;
10375
+ index += 3;
10376
+ continue outer;
10377
+ }
10378
+ }
10379
+ }
10380
+ }
10381
+ clipTrianglesRender(vertices, verticesLength, triangles, trianglesLength, uvs, light, dark, twoColor) {
10295
10382
  let clipOutput = this.clipOutput, clippedVertices = this.clippedVertices;
10296
10383
  let clippedTriangles = this.clippedTriangles;
10297
10384
  let polygons = this.clippingPolygons;