@@ -38,9 +38,6 @@ const getLocalPosition = (drawable, vec) => {
38
38
localPosition [ 0 ] = 0.5 - ( ( ( v0 * m [ 0 ] ) + ( v1 * m [ 4 ] ) + m [ 12 ] ) / d ) ;
39
39
localPosition [ 1 ] = ( ( ( v0 * m [ 1 ] ) + ( v1 * m [ 5 ] ) + m [ 13 ] ) / d ) + 0.5 ;
40
40
// Fix floating point issues near 0.
41
- // TODO: Check if this can be removed after render pull 479 is merged
42
- if ( Math . abs ( localPosition [ 0 ] < 1e-8 ) ) localPosition [ 0 ] = 0 ;
43
- if ( Math . abs ( localPosition [ 1 ] < 1e-8 ) ) localPosition [ 1 ] = 0 ;
44
41
// Apply texture effect transform if the localPosition is within the drawable's space,
45
42
// and any effects are currently active.
46
43
if ( drawable . enabledEffects !== 0 &&
@@ -716,21 +713,25 @@ class Drawable {
716
713
* Sample a color from a drawable's texture.
717
714
* The caller is responsible for ensuring this drawable's inverse matrix & its skin's silhouette are up-to-date.
718
715
* @see updateCPURenderAttributes
719
- * @param {twgl.v3 } vec The scratch space [x,y] vector
716
+ * @param {twgl.v3 } vec The scratch space [x,y] vector. This will be clamped to the texture space, to match the
717
+ * GL code (See https://github.com/LLK/scratch-render/blob/develop/src/BitmapSkin.js#L88)
720
718
* @param {Drawable } drawable The drawable to sample the texture from
721
719
* @param {Uint8ClampedArray } dst The "color4b" representation of the texture at point.
722
720
* @param {number } [effectMask] A bitmask for which effects to use. Optional.
723
721
* @returns {Uint8ClampedArray } The dst object filled with the color4b
724
722
*/
725
723
static sampleColor4b ( vec , drawable , dst , effectMask ) {
726
724
const localPosition = getLocalPosition ( drawable , vec ) ;
727
- if ( localPosition [ 0 ] < 0 || localPosition [ 1 ] < 0 ||
728
- localPosition [ 0 ] > 1 || localPosition [ 1 ] > 1 ) {
729
- dst [ 0 ] = 0 ;
730
- dst [ 1 ] = 0 ;
731
- dst [ 2 ] = 0 ;
732
- dst [ 3 ] = 0 ;
733
- return dst ;
725
+ if ( localPosition [ 0 ] < 0 ) {
726
+ localPosition [ 0 ] = 0 ;
727
+ } else if ( localPosition [ 0 ] > 1 ) {
728
+ localPosition [ 0 ] = 1 ;
729
+ }
730
+
731
+ if ( localPosition [ 1 ] < 0 ) {
732
+ localPosition [ 1 ] = 0 ;
733
+ } else if ( localPosition [ 1 ] > 1 ) {
734
+ localPosition [ 1 ] = 1 ;
734
735
}
735
736
const textColor =
736
737
// commenting out to only use nearest for now
0 commit comments