src/systems/material.js
function (src, data, cb) {
    var self = this;

    // Canvas.
    if (src.tagName === 'CANVAS') {
      this.loadCanvas(src, data, cb);
      return;
    }

    // Video element.
    if (src.tagName === 'VIDEO') {
      if (!src.src && !src.srcObject && !src.childElementCount) {
        warn('Video element was defined with neither `source` elements nor `src` / `srcObject` attributes.');
      }
      this.loadVideo(src, data, cb);
      return;
    }

    utils.srcLoader.validateSrc(src, loadImageCb, loadVideoCb);
    function loadImageCb (src) { self.loadImage(src, data, cb); }
    function loadVideoCb (src) { self.loadVideo(src, data, cb); }
  }
function (src, data, cb) {
    var self = this;

    // Canvas.
    if (src.tagName === 'CANVAS') {
      this.loadCanvas(src, data, cb);
      return;
    }

    // Video element.
    if (src.tagName === 'VIDEO') {
      if (!src.src && !src.srcObject && !src.childElementCount) {
        warn('Video element was defined with neither `source` elements nor `src` / `srcObject` attributes.');
      }
      this.loadVideo(src, data, cb);
      return;
    }

    utils.srcLoader.validateSrc(src, loadImageCb, loadVideoCb);
    function loadImageCb (src) { self.loadImage(src, data, cb); }
    function loadVideoCb (src) { self.loadVideo(src, data, cb); }
  }
function ( src , data , cb ) { var self = this ; // Canvas. if ( src . tagName === 'CANVAS' ) { this . loadCanvas ( src , data , cb ) ; return ; } // Video element. if ( src . tagName === 'VIDEO' ) { if ( ! src . src && ! src . srcObject && ! src . childElementCount ) { warn ( 'Video element was defined with neither `source` elements nor `src` / `srcObject` attributes.' ) ; } this . loadVideo ( src , data , cb ) ; return ; } utils . srcLoader . validateSrc ( src , loadImageCb , loadVideoCb ) ; function loadImageCb ( src ) { self . loadImage ( src , data , cb ) ; } function loadVideoCb ( src ) { self . loadVideo ( src , data , cb ) ; } }
Determine whether `src` is a image or video. Then try to load the asset, then call back.

@param {string, or element} src - Texture URL or element.
@param {string} data - Relevant texture data used for caching.
@param {function} cb - Callback to pass texture to.
Determine whether src is a image or video . Then try to load the asset then call back .