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