function transformPoint(drawable, vec, dst) {
            dst = dst || twgl.v3.create();
            twgl.v3.copy(vec, dst);

            var uniforms = drawable.getUniforms();
            var effects = drawable.getEnabledEffects();

            if ((effects & ShaderManager.EFFECT_INFO.mosaic.mask) !== 0) {
                // texcoord0 = fract(u_mosaic * texcoord0);
                dst[0] = uniforms.u_mosaic * dst[0] % 1;
                dst[1] = uniforms.u_mosaic * dst[1] % 1;
            }
            if ((effects & ShaderManager.EFFECT_INFO.pixelate.mask) !== 0) {
                var skinUniforms = drawable.skin.getUniforms();
                // vec2 pixelTexelSize = u_skinSize / u_pixelate;
                var texelX = skinUniforms.u_skinSize[0] * uniforms.u_pixelate;
                var texelY = skinUniforms.u_skinSize[1] * uniforms.u_pixelate;
                // texcoord0 = (floor(texcoord0 * pixelTexelSize) + kCenter) /
                //   pixelTexelSize;
                dst[0] = (Math.floor(dst[0] * texelX) + CENTER_X) / texelX;
                dst[1] = (Math.floor(dst[1] * texelY) + CENTER_Y) / texelY;
            }
            if ((effects & ShaderManager.EFFECT_INFO.whirl.mask) !== 0) {
                // const float kRadius = 0.5;
                var RADIUS = 0.5;
                // vec2 offset = texcoord0 - kCenter;
                var offsetX = dst[0] - CENTER_X;
                var offsetY = dst[1] - CENTER_Y;
                // float offsetMagnitude = length(offset);
                var offsetMagnitude = twgl.v3.length(dst);
                // float whirlFactor = max(1.0 - (offsetMagnitude / kRadius), 0.0);
                var whirlFactor = Math.max(1.0 - offsetMagnitude / RADIUS, 0.0);
                // float whirlActual = u_whirl * whirlFactor * whirlFactor;
                var whirlActual = uniforms.u_whirl * whirlFactor * whirlFactor;
                // float sinWhirl = sin(whirlActual);
                var sinWhirl = Math.sin(whirlActual);
                // float cosWhirl = cos(whirlActual);
                var cosWhirl = Math.cos(whirlActual);
                // mat2 rotationMatrix = mat2(
                //     cosWhirl, -sinWhirl,
                //     sinWhirl, cosWhirl
                // );
                var rot00 = cosWhirl;
                var rot10 = -sinWhirl;
                var rot01 = sinWhirl;
                var rot11 = cosWhirl;

                // texcoord0 = rotationMatrix * offset + kCenter;
                dst[0] = rot00 * offsetX + rot10 * offsetY + CENTER_X;
                dst[1] = rot01 * offsetX + rot11 * offsetY + CENTER_Y;
            }
            if ((effects & ShaderManager.EFFECT_INFO.fisheye.mask) !== 0) {
                // vec2 vec = (texcoord0 - kCenter) / kCenter;
                var vX = (dst[0] - CENTER_X) / CENTER_X;
                var vY = (dst[1] - CENTER_Y) / CENTER_Y;
                // float vecLength = length(vec);
                var vLength = Math.sqrt(vX * vX + vY * vY);
                // float r = pow(min(vecLength, 1.0), u_fisheye) * max(1.0, vecLength);
                var r = Math.pow(Math.min(vLength, 1), uniforms.u_fisheye) * Math.max(1, vLength);
                // vec2 unit = vec / vecLength;
                var unitX = vX / vLength;
                var unitY = vY / vLength;
                // texcoord0 = kCenter + r * unit * kCenter;
                dst[0] = CENTER_X + r * unitX * CENTER_X;
                dst[1] = CENTER_Y + r * unitY * CENTER_Y;
            }

            return dst;
        }
/**
         * Transform a texture coordinate to one that would be select after applying shader effects.
         * @param {Drawable} drawable The drawable whose effects to emulate.
         * @param {twgl.v3} vec The texture coordinate to transform.
         * @param {?twgl.v3} dst A place to store the output coordinate.
         * @return {twgl.v3} The coordinate after being transform by effects.
         */
Transform a texture coordinate to one that would be select after applying shader effects.
@param {Drawable} drawable The drawable whose effects to emulate.
@param {twgl.v3} vec The texture coordinate to transform.
@param {?twgl.v3} dst A place to store the output coordinate.
@return {twgl.v3} The coordinate after being transform by effects.
Transform a texture coordinate to one that would be select after applying shader effects . @param { Drawable } drawable The drawable whose effects to emulate . @param { twgl . v3 } vec The texture coordinate to transform . @param { ?twgl . v3 } dst A place to store the output coordinate . @return { twgl . v3 } The coordinate after being transform by effects .
function transformPoint(drawable, vec, dst) {
            dst = dst || twgl.v3.create();
            twgl.v3.copy(vec, dst);
            var uniforms = drawable.getUniforms();
            var effects = drawable.getEnabledEffects();
            if ((effects & ShaderManager.EFFECT_INFO.mosaic.mask) !== 0) {
                dst[0] = uniforms.u_mosaic * dst[0] % 1;
                dst[1] = uniforms.u_mosaic * dst[1] % 1;
            }
            if ((effects & ShaderManager.EFFECT_INFO.pixelate.mask) !== 0) {
                var skinUniforms = drawable.skin.getUniforms();
                var texelX = skinUniforms.u_skinSize[0] * uniforms.u_pixelate;
                var texelY = skinUniforms.u_skinSize[1] * uniforms.u_pixelate;
                dst[0] = (Math.floor(dst[0] * texelX) + CENTER_X) / texelX;
                dst[1] = (Math.floor(dst[1] * texelY) + CENTER_Y) / texelY;
            }
            if ((effects & ShaderManager.EFFECT_INFO.whirl.mask) !== 0) {
                var RADIUS = 0.5;
                var offsetX = dst[0] - CENTER_X;
                var offsetY = dst[1] - CENTER_Y;
                var offsetMagnitude = twgl.v3.length(dst);
                var whirlFactor = Math.max(1.0 - offsetMagnitude / RADIUS, 0.0);
                var whirlActual = uniforms.u_whirl * whirlFactor * whirlFactor;
                var sinWhirl = Math.sin(whirlActual);
                var cosWhirl = Math.cos(whirlActual);
                var rot00 = cosWhirl;
                var rot10 = -sinWhirl;
                var rot01 = sinWhirl;
                var rot11 = cosWhirl;
                dst[0] = rot00 * offsetX + rot10 * offsetY + CENTER_X;
                dst[1] = rot01 * offsetX + rot11 * offsetY + CENTER_Y;
            }
            if ((effects & ShaderManager.EFFECT_INFO.fisheye.mask) !== 0) {
                var vX = (dst[0] - CENTER_X) / CENTER_X;
                var vY = (dst[1] - CENTER_Y) / CENTER_Y;
                var vLength = Math.sqrt(vX * vX + vY * vY);
                var r = Math.pow(Math.min(vLength, 1), uniforms.u_fisheye) * Math.max(1, vLength);
                var unitX = vX / vLength;
                var unitY = vY / vLength;
                dst[0] = CENTER_X + r * unitX * CENTER_X;
                dst[1] = CENTER_Y + r * unitY * CENTER_Y;
            }
            return dst;
        }
function transformPoint ( drawable , vec , dst ) { dst = dst || twgl . v3 . create ( ) ; twgl . v3 . copy ( vec , dst ) ; var uniforms = drawable . getUniforms ( ) ; var effects = drawable . getEnabledEffects ( ) ; if ( ( effects & ShaderManager . EFFECT_INFO . mosaic . mask ) !== 0 ) { dst [ 0 ] = uniforms . u_mosaic * dst [ 0 ] % 1 ; dst [ 1 ] = uniforms . u_mosaic * dst [ 1 ] % 1 ; } if ( ( effects & ShaderManager . EFFECT_INFO . pixelate . mask ) !== 0 ) { var skinUniforms = drawable . skin . getUniforms ( ) ; var texelX = skinUniforms . u_skinSize [ 0 ] * uniforms . u_pixelate ; var texelY = skinUniforms . u_skinSize [ 1 ] * uniforms . u_pixelate ; dst [ 0 ] = ( Math . floor ( dst [ 0 ] * texelX ) + CENTER_X ) / texelX ; dst [ 1 ] = ( Math . floor ( dst [ 1 ] * texelY ) + CENTER_Y ) / texelY ; } if ( ( effects & ShaderManager . EFFECT_INFO . whirl . mask ) !== 0 ) { var RADIUS = 0.5 ; var offsetX = dst [ 0 ] - CENTER_X ; var offsetY = dst [ 1 ] - CENTER_Y ; var offsetMagnitude = twgl . v3 . length ( dst ) ; var whirlFactor = Math . max ( 1.0 - offsetMagnitude / RADIUS , 0.0 ) ; var whirlActual = uniforms . u_whirl * whirlFactor * whirlFactor ; var sinWhirl = Math . sin ( whirlActual ) ; var cosWhirl = Math . cos ( whirlActual ) ; var rot00 = cosWhirl ; var rot10 = - sinWhirl ; var rot01 = sinWhirl ; var rot11 = cosWhirl ; dst [ 0 ] = rot00 * offsetX + rot10 * offsetY + CENTER_X ; dst [ 1 ] = rot01 * offsetX + rot11 * offsetY + CENTER_Y ; } if ( ( effects & ShaderManager . EFFECT_INFO . fisheye . mask ) !== 0 ) { var vX = ( dst [ 0 ] - CENTER_X ) / CENTER_X ; var vY = ( dst [ 1 ] - CENTER_Y ) / CENTER_Y ; var vLength = Math . sqrt ( vX * vX + vY * vY ) ; var r = Math . pow ( Math . min ( vLength , 1 ) , uniforms . u_fisheye ) * Math . max ( 1 , vLength ) ; var unitX = vX / vLength ; var unitY = vY / vLength ; dst [ 0 ] = CENTER_X + r * unitX * CENTER_X ; dst [ 1 ] = CENTER_Y + r * unitY * CENTER_Y ; } return dst ; }
Transform a texture coordinate to one that would be select after applying shader effects.
Transform a texture coordinate to one that would be select after applying shader effects .
// texcoord0 = fract(u_mosaic * texcoord0); // vec2 pixelTexelSize = u_skinSize / u_pixelate; // texcoord0 = (floor(texcoord0 * pixelTexelSize) + kCenter) / //   pixelTexelSize; // const float kRadius = 0.5; // vec2 offset = texcoord0 - kCenter; // float offsetMagnitude = length(offset); // float whirlFactor = max(1.0 - (offsetMagnitude / kRadius), 0.0); // float whirlActual = u_whirl * whirlFactor * whirlFactor; // float sinWhirl = sin(whirlActual); // float cosWhirl = cos(whirlActual); // mat2 rotationMatrix = mat2( //     cosWhirl, -sinWhirl, //     sinWhirl, cosWhirl // ); // texcoord0 = rotationMatrix * offset + kCenter; // vec2 vec = (texcoord0 - kCenter) / kCenter; // float vecLength = length(vec); // float r = pow(min(vecLength, 1.0), u_fisheye) * max(1.0, vecLength); // vec2 unit = vec / vecLength; // texcoord0 = kCenter + r * unit * kCenter;