@@ -129,8 +129,9 @@ abstract class C3SkeletonRenderer<
129129 if ( ! bone . parent ) continue ;
130130 const boneApplied = bone . applied ;
131131 const { x : x1 , y : y1 } = matrix . skeletonToGame ( boneApplied . worldX , boneApplied . worldY ) ;
132- const x2 = bone . data . length * boneApplied . a + x1 ;
133- const y2 = bone . data . length * boneApplied . c + y1 ;
132+ const endX = boneApplied . worldX + bone . data . length * boneApplied . a ;
133+ const endY = boneApplied . worldY + bone . data . length * boneApplied . c ;
134+ const { x : x2 , y : y2 } = matrix . skeletonToGame ( endX , endY ) ;
134135
135136 this . setColor ( 1 , 0 , 0 , 1 ) ;
136137 this . setColorFillMode ( ) ;
@@ -163,10 +164,18 @@ abstract class C3SkeletonRenderer<
163164 if ( attachment instanceof RegionAttachment ) {
164165 const vertices = this . tempVertices ;
165166 attachment . computeWorldVertices ( slot , vertices , 0 , 2 ) ;
166- this . line ( vertices [ 0 ] , vertices [ 1 ] , vertices [ 2 ] , vertices [ 3 ] , x , y ) ;
167- this . line ( vertices [ 2 ] , vertices [ 3 ] , vertices [ 4 ] , vertices [ 5 ] , x , y ) ;
168- this . line ( vertices [ 4 ] , vertices [ 5 ] , vertices [ 6 ] , vertices [ 7 ] , x , y ) ;
169- this . line ( vertices [ 6 ] , vertices [ 7 ] , vertices [ 0 ] , vertices [ 1 ] , x , y ) ;
167+ let p = matrix . skeletonToGame ( vertices [ 0 ] , vertices [ 1 ] ) ;
168+ const x1 = p . x , y1 = p . y ;
169+ p = matrix . skeletonToGame ( vertices [ 2 ] , vertices [ 3 ] ) ;
170+ const x2 = p . x , y2 = p . y ;
171+ p = matrix . skeletonToGame ( vertices [ 4 ] , vertices [ 5 ] ) ;
172+ const x3 = p . x , y3 = p . y ;
173+ p = matrix . skeletonToGame ( vertices [ 6 ] , vertices [ 7 ] ) ;
174+ const x4 = p . x , y4 = p . y ;
175+ this . line ( x1 , y1 , x2 , y2 ) ;
176+ this . line ( x2 , y2 , x3 , y3 ) ;
177+ this . line ( x3 , y3 , x4 , y4 ) ;
178+ this . line ( x4 , y4 , x1 , y1 ) ;
170179 }
171180 }
172181
@@ -185,22 +194,25 @@ abstract class C3SkeletonRenderer<
185194 this . setColor ( 1 , 0.64 , 0 , 0.5 ) ;
186195 for ( let ii = 0 , nn = triangles . length ; ii < nn ; ii += 3 ) {
187196 const v1 = triangles [ ii ] * 2 , v2 = triangles [ ii + 1 ] * 2 , v3 = triangles [ ii + 2 ] * 2 ;
188- this . triangle (
189- vertices [ v1 ] , vertices [ v1 + 1 ] ,
190- vertices [ v2 ] , vertices [ v2 + 1 ] ,
191- vertices [ v3 ] , vertices [ v3 + 1 ] ,
192- x , y ,
193- ) ;
197+ let p = matrix . skeletonToGame ( vertices [ v1 ] , vertices [ v1 + 1 ] ) ;
198+ const x1 = p . x , y1 = p . y ;
199+ p = matrix . skeletonToGame ( vertices [ v2 ] , vertices [ v2 + 1 ] ) ;
200+ const x2 = p . x , y2 = p . y ;
201+ p = matrix . skeletonToGame ( vertices [ v3 ] , vertices [ v3 + 1 ] ) ;
202+ const x3 = p . x , y3 = p . y ;
203+ this . triangle ( x1 , y1 , x2 , y2 , x3 , y3 ) ;
194204 }
195205
196206 // mesh hulls
197207 if ( hullLength > 0 ) {
198208 this . setColor ( 0 , 0 , 1 , 0.5 ) ;
199209 hullLength = ( hullLength >> 1 ) * 2 ;
200- let lastX = vertices [ hullLength - 2 ] , lastY = vertices [ hullLength - 1 ] ;
210+ let p = matrix . skeletonToGame ( vertices [ hullLength - 2 ] , vertices [ hullLength - 1 ] ) ;
211+ let lastX = p . x , lastY = p . y ;
201212 for ( let ii = 0 , nn = hullLength ; ii < nn ; ii += 2 ) {
202- const x1 = vertices [ ii ] , y1 = vertices [ ii + 1 ] ;
203- this . line ( x1 , y1 , lastX , lastY , x , y ) ;
213+ p = matrix . skeletonToGame ( vertices [ ii ] , vertices [ ii + 1 ] ) ;
214+ const x1 = p . x , y1 = p . y ;
215+ this . line ( x1 , y1 , lastX , lastY ) ;
204216 lastX = x1 ;
205217 lastY = y1 ;
206218 }
@@ -216,27 +228,36 @@ abstract class C3SkeletonRenderer<
216228 let nn = attachment . worldVerticesLength ;
217229 const world = this . tempArray = Utils . setArraySize ( this . tempArray , nn , 0 ) ;
218230 attachment . computeWorldVertices ( skeleton , slot , 0 , nn , world , 0 , 2 ) ;
219- let x1 = world [ 2 ] , y1 = world [ 3 ] , x2 = 0 , y2 = 0 ;
231+ let p = matrix . skeletonToGame ( world [ 2 ] , world [ 3 ] ) ;
232+ let x1 = p . x , y1 = p . y , x2 = 0 , y2 = 0 ;
220233 if ( attachment . closed ) {
221234 this . setColor ( 1 , 0.5 , 0 , 1 ) ;
222- const cx1 = world [ 0 ] , cy1 = world [ 1 ] , cx2 = world [ nn - 2 ] , cy2 = world [ nn - 1 ] ;
223- x2 = world [ nn - 4 ] ;
224- y2 = world [ nn - 3 ] ;
225- this . curve ( x1 , y1 , cx1 , cy1 , cx2 , cy2 , x2 , y2 , 32 , x , y ) ;
235+ p = matrix . skeletonToGame ( world [ 0 ] , world [ 1 ] ) ;
236+ const cx1 = p . x , cy1 = p . y ;
237+ p = matrix . skeletonToGame ( world [ nn - 2 ] , world [ nn - 1 ] ) ;
238+ const cx2 = p . x , cy2 = p . y ;
239+ p = matrix . skeletonToGame ( world [ nn - 4 ] , world [ nn - 3 ] ) ;
240+ x2 = p . x ;
241+ y2 = p . y ;
242+ this . curve ( x1 , y1 , cx1 , cy1 , cx2 , cy2 , x2 , y2 , 32 ) ;
226243 this . setColor ( .75 , .75 , .75 , 1 ) ;
227- this . line ( x1 , y1 , cx1 , cy1 , x , y ) ;
228- this . line ( x2 , y2 , cx2 , cy2 , x , y ) ;
244+ this . line ( x1 , y1 , cx1 , cy1 ) ;
245+ this . line ( x2 , y2 , cx2 , cy2 ) ;
229246 }
230247 nn -= 4 ;
231248 for ( let ii = 4 ; ii < nn ; ii += 6 ) {
232- const cx1 = world [ ii ] , cy1 = world [ ii + 1 ] , cx2 = world [ ii + 2 ] , cy2 = world [ ii + 3 ] ;
233- x2 = world [ ii + 4 ] ;
234- y2 = world [ ii + 5 ] ;
249+ p = matrix . skeletonToGame ( world [ ii ] , world [ ii + 1 ] ) ;
250+ const cx1 = p . x , cy1 = p . y ;
251+ p = matrix . skeletonToGame ( world [ ii + 2 ] , world [ ii + 3 ] ) ;
252+ const cx2 = p . x , cy2 = p . y ;
253+ p = matrix . skeletonToGame ( world [ ii + 4 ] , world [ ii + 5 ] ) ;
254+ x2 = p . x ;
255+ y2 = p . y ;
235256 this . setColor ( 1 , 0.5 , 0 , 1 ) ;
236- this . curve ( x1 , y1 , cx1 , cy1 , cx2 , cy2 , x2 , y2 , 32 , x , y ) ;
257+ this . curve ( x1 , y1 , cx1 , cy1 , cx2 , cy2 , x2 , y2 , 32 ) ;
237258 this . setColor ( .75 , .75 , .75 , 1 ) ;
238- this . line ( x1 , y1 , cx1 , cy1 , x , y ) ;
239- this . line ( x2 , y2 , cx2 , cy2 , x , y ) ;
259+ this . line ( x1 , y1 , cx1 , cy1 ) ;
260+ this . line ( x2 , y2 , cx2 , cy2 ) ;
240261 x1 = x2 ;
241262 y1 = y2 ;
242263 }
@@ -253,11 +274,11 @@ abstract class C3SkeletonRenderer<
253274 const world = this . tempArray = Utils . setArraySize ( this . tempArray , nn , 0 ) ;
254275 attachment . computeWorldVertices ( skeleton , slot , 0 , nn , world , 0 , 2 ) ;
255276 for ( let i = 0 , n = world . length ; i < n ; i += 2 ) {
256- const x1 = world [ i ] ;
257- const y1 = world [ i + 1 ] ;
258- const x2 = world [ ( i + 2 ) % world . length ] ;
259- const y2 = world [ ( i + 3 ) % world . length ] ;
260- this . line ( x1 , y1 , x2 , y2 , x , y ) ;
277+ let p = matrix . skeletonToGame ( world [ i ] , world [ i + 1 ] ) ;
278+ const x1 = p . x , y1 = p . y ;
279+ p = matrix . skeletonToGame ( world [ ( i + 2 ) % world . length ] , world [ ( i + 3 ) % world . length ] ) ;
280+ const x2 = p . x , y2 = p . y ;
281+ this . line ( x1 , y1 , x2 , y2 ) ;
261282 }
262283 }
263284
0 commit comments