@@ -1792,33 +1792,38 @@ function primitives3D(p5, fn){
17921792 const prevMode = this . states . textureMode ;
17931793 this . states . setValue ( 'textureMode' , constants . NORMAL ) ;
17941794 const prevOrder = this . bezierOrder ( ) ;
1795- this . bezierOrder ( 2 ) ;
1795+ this . bezierOrder ( 3 ) ;
17961796 this . beginShape ( ) ;
17971797 const addUVs = ( x , y ) => [ x , y , 0 , ( x - x1 ) / width , ( y - y1 ) / height ] ;
1798+ const rr = 0.5523 ; // kappa: 4*(sqrt(2)-1)/3, handle ratio for cubic bezier circle approximation
17981799 if ( tr !== 0 ) {
17991800 this . vertex ( ...addUVs ( x2 - tr , y1 ) ) ;
1800- this . bezierVertex ( ...addUVs ( x2 , y1 ) ) ;
1801+ this . bezierVertex ( ...addUVs ( x2 - tr + tr * rr , y1 ) ) ;
1802+ this . bezierVertex ( ...addUVs ( x2 , y1 + tr - tr * rr ) ) ;
18011803 this . bezierVertex ( ...addUVs ( x2 , y1 + tr ) ) ;
18021804 } else {
18031805 this . vertex ( ...addUVs ( x2 , y1 ) ) ;
18041806 }
18051807 if ( br !== 0 ) {
18061808 this . vertex ( ...addUVs ( x2 , y2 - br ) ) ;
1807- this . bezierVertex ( ...addUVs ( x2 , y2 ) ) ;
1809+ this . bezierVertex ( ...addUVs ( x2 , y2 - br + br * rr ) ) ;
1810+ this . bezierVertex ( ...addUVs ( x2 - br + rr * br , y2 ) ) ;
18081811 this . bezierVertex ( ...addUVs ( x2 - br , y2 ) ) ;
18091812 } else {
18101813 this . vertex ( ...addUVs ( x2 , y2 ) ) ;
18111814 }
18121815 if ( bl !== 0 ) {
18131816 this . vertex ( ...addUVs ( x1 + bl , y2 ) ) ;
1814- this . bezierVertex ( ...addUVs ( x1 , y2 ) ) ;
1817+ this . bezierVertex ( ...addUVs ( x1 + bl - bl * rr , y2 ) ) ;
1818+ this . bezierVertex ( ...addUVs ( x1 , y2 - bl + bl * rr ) ) ;
18151819 this . bezierVertex ( ...addUVs ( x1 , y2 - bl ) ) ;
18161820 } else {
18171821 this . vertex ( ...addUVs ( x1 , y2 ) ) ;
18181822 }
18191823 if ( tl !== 0 ) {
18201824 this . vertex ( ...addUVs ( x1 , y1 + tl ) ) ;
1821- this . bezierVertex ( ...addUVs ( x1 , y1 ) ) ;
1825+ this . bezierVertex ( ...addUVs ( x1 , y1 + tl - tl * rr ) ) ;
1826+ this . bezierVertex ( ...addUVs ( x1 + tl - tl * rr , y1 ) ) ;
18221827 this . bezierVertex ( ...addUVs ( x1 + tl , y1 ) ) ;
18231828 } else {
18241829 this . vertex ( ...addUVs ( x1 , y1 ) ) ;
0 commit comments