src/components/text.js
function () {
    var data = this.data;
    var hasChangedShader;
    var material = this.material;
    var NewShader;
    var shaderData = this.shaderData;
    var shaderName;

    // Infer shader if using a stock font (or from `-msdf` filename convention).
    shaderName = data.shader;
    if (MSDF_FONTS.indexOf(data.font) !== -1 || data.font.indexOf('-msdf.') >= 0) {
      shaderName = 'msdf';
    } else if (data.font in FONTS && MSDF_FONTS.indexOf(data.font) === -1) {
      shaderName = 'sdf';
    }

    hasChangedShader = (this.shaderObject && this.shaderObject.name) !== shaderName;

    shaderData.alphaTest = data.alphaTest;
    shaderData.color = data.color;
    shaderData.map = this.texture;
    shaderData.opacity = data.opacity;
    shaderData.side = parseSide(data.side);
    shaderData.transparent = data.transparent;
    shaderData.negate = data.negate;

    // Shader has not changed, do an update.
    if (!hasChangedShader) {
      // Update shader material.
      this.shaderObject.update(shaderData);
      // Apparently, was not set on `init` nor `update`.
      material.transparent = shaderData.transparent;
      material.side = shaderData.side;
      return;
    }

    // Shader has changed. Create a shader material.
    NewShader = createShader(this.el, shaderName, shaderData);
    this.material = NewShader.material;
    this.shaderObject = NewShader.shader;

    // Set new shader material.
    this.material.side = shaderData.side;
    if (this.mesh) { this.mesh.material = this.material; }
  }
function () {
    var data = this.data;
    var hasChangedShader;
    var material = this.material;
    var NewShader;
    var shaderData = this.shaderData;
    var shaderName;

    // Infer shader if using a stock font (or from `-msdf` filename convention).
    shaderName = data.shader;
    if (MSDF_FONTS.indexOf(data.font) !== -1 || data.font.indexOf('-msdf.') >= 0) {
      shaderName = 'msdf';
    } else if (data.font in FONTS && MSDF_FONTS.indexOf(data.font) === -1) {
      shaderName = 'sdf';
    }

    hasChangedShader = (this.shaderObject && this.shaderObject.name) !== shaderName;

    shaderData.alphaTest = data.alphaTest;
    shaderData.color = data.color;
    shaderData.map = this.texture;
    shaderData.opacity = data.opacity;
    shaderData.side = parseSide(data.side);
    shaderData.transparent = data.transparent;
    shaderData.negate = data.negate;

    // Shader has not changed, do an update.
    if (!hasChangedShader) {
      // Update shader material.
      this.shaderObject.update(shaderData);
      // Apparently, was not set on `init` nor `update`.
      material.transparent = shaderData.transparent;
      material.side = shaderData.side;
      return;
    }

    // Shader has changed. Create a shader material.
    NewShader = createShader(this.el, shaderName, shaderData);
    this.material = NewShader.material;
    this.shaderObject = NewShader.shader;

    // Set new shader material.
    this.material.side = shaderData.side;
    if (this.mesh) { this.mesh.material = this.material; }
  }
function ( ) { var data = this . data ; var hasChangedShader ; var material = this . material ; var NewShader ; var shaderData = this . shaderData ; var shaderName ; // Infer shader if using a stock font (or from `-msdf` filename convention). shaderName = data . shader ; if ( MSDF_FONTS . indexOf ( data . font ) !== - 1 || data . font . indexOf ( '-msdf.' ) >= 0 ) { shaderName = 'msdf' ; } else if ( data . font in FONTS && MSDF_FONTS . indexOf ( data . font ) === - 1 ) { shaderName = 'sdf' ; } hasChangedShader = ( this . shaderObject && this . shaderObject . name ) !== shaderName ; shaderData . alphaTest = data . alphaTest ; shaderData . color = data . color ; shaderData . map = this . texture ; shaderData . opacity = data . opacity ; shaderData . side = parseSide ( data . side ) ; shaderData . transparent = data . transparent ; shaderData . negate = data . negate ; // Shader has not changed, do an update. if ( ! hasChangedShader ) { // Update shader material. this . shaderObject . update ( shaderData ) ; // Apparently, was not set on `init` nor `update`. material . transparent = shaderData . transparent ; material . side = shaderData . side ; return ; } // Shader has changed. Create a shader material. NewShader = createShader ( this . el , shaderName , shaderData ) ; this . material = NewShader . material ; this . shaderObject = NewShader . shader ; // Set new shader material. this . material . side = shaderData . side ; if ( this . mesh ) { this . mesh . material = this . material ; } }
Update the shader of the material.
Update the shader of the material .