@@ -402,7 +402,8 @@ export class SpineSkeletonRenderer extends SpineNormalRenderBase implements ISpi
402
402
attachmentColor = mesh . color ;
403
403
} else if ( attachment instanceof window . spine . ClippingAttachment ) {
404
404
let clip = < spine . ClippingAttachment > ( attachment ) ;
405
- clipper . clipStart ( slot , clip ) ;
405
+ // clipper.clipStart(slot, clip);
406
+ this . clipStart ( this . clipper , slot , clip , - skeleton . x , - skeleton . y ) ;
406
407
continue ;
407
408
} else {
408
409
clipper . clipEndWithSlot ( slot ) ;
@@ -480,6 +481,40 @@ export class SpineSkeletonRenderer extends SpineNormalRenderBase implements ISpi
480
481
virtualMesh && virtualMesh . draw ( ) ;
481
482
}
482
483
484
+ /**
485
+ * @link spine-ts/.../SkeletonClipping.ts
486
+ * @param clipper
487
+ * @param slot
488
+ * @param clip
489
+ * @param ofx
490
+ * @param ofy
491
+ * @returns
492
+ */
493
+ clipStart ( clipper :spine . SkeletonClipping , slot : spine . Slot , clip :spine . VertexAttachment , ofx : number , ofy : number ) {
494
+ //@ts -ignore
495
+ if ( clipper . clipAttachment )
496
+ return 0 ;
497
+ //@ts -ignore
498
+ clipper . clipAttachment = clip ;
499
+ let n = clip . worldVerticesLength ;
500
+ //@ts -ignore
501
+ let vertices :spine . NumberArrayLike = spine . Utils . setArraySize ( clipper . clippingPolygon , n ) ;
502
+ // clip.computeWorldVertices(slot, 0, n, vertices, 0, 2);
503
+ this . computeWorldVertices_MeshAttachment ( clip , slot , 0 , n , vertices , 0 , 2 , ofx , ofy ) ;
504
+ //@ts -ignore
505
+ let clippingPolygon = clipper . clippingPolygon ;
506
+ spine . SkeletonClipping . makeClockwise ( clippingPolygon ) ;
507
+ //@ts -ignore
508
+ let clippingPolygons = clipper . clippingPolygons = clipper . triangulator . decompose ( clippingPolygon , clipper . triangulator . triangulate ( clippingPolygon ) ) ;
509
+ for ( let i = 0 , n = clippingPolygons . length ; i < n ; i ++ ) {
510
+ let polygon = clippingPolygons [ i ] ;
511
+ spine . SkeletonClipping . makeClockwise ( polygon ) ;
512
+ polygon . push ( polygon [ 0 ] ) ;
513
+ polygon . push ( polygon [ 1 ] ) ;
514
+ }
515
+ return clippingPolygons . length ;
516
+ }
517
+
483
518
/**
484
519
* @link spine-ts/.../RegionAttachment.ts
485
520
* @param attachment
@@ -537,7 +572,7 @@ export class SpineSkeletonRenderer extends SpineNormalRenderBase implements ISpi
537
572
* @param ofy
538
573
* @returns
539
574
*/
540
- private computeWorldVertices_MeshAttachment ( attachment : spine . MeshAttachment , slot : spine . Slot , start : number , count : number , worldVertices : spine . NumberArrayLike , offset : number , stride : number , ofx : number , ofy : number ) {
575
+ private computeWorldVertices_MeshAttachment ( attachment : spine . VertexAttachment , slot : spine . Slot , start : number , count : number , worldVertices : spine . NumberArrayLike , offset : number , stride : number , ofx : number , ofy : number ) {
541
576
count = offset + ( count >> 1 ) * stride ;
542
577
let skeleton = slot . bone . skeleton ;
543
578
let deformArray = slot . deform ;
0 commit comments