topical media & game development

talk show tell print

mobile-query-three-js-plugins-materials-tquery.meshphongmaterial.js / js



  
////////////////////////////////////////////////////////////////////////////

// //
////////////////////////////////////////////////////////////////////////////

tQuery.Mesh.registerInstance('setPhongMaterial', function(opts){ var material = tQuery.createMeshPhongMaterial(opts); this.material( material.get(0) ); return material.back(this); }) tQuery.registerStatic('createMeshPhongMaterial', function(opts){ var tMaterial = new THREE.MeshPhongMaterial(opts); var material = new tQuery.MeshPhongMaterial(tMaterial); return material; });
////////////////////////////////////////////////////////////////////////////

// //
////////////////////////////////////////////////////////////////////////////

Handle directional light @class include THREE.PhongMaterial. It inherit from {gray tQuery.Material} @borrows tQuery.Node#get as this.get @borrows tQuery.Node#each as this.each @borrows tQuery.Node#back as this.back
parameter: {THREE.PhongMaterial} element an instance or array of instance

  
  tQuery.MeshPhongMaterial        = function(elements)
  {
          // call parent ctor
          tQuery.MeshPhongMaterial.parent.constructor.call(this, elements)
  
          // sanity check - all items MUST be THREE.Material
          this._lists.forEach(function(item){ console.assert(item instanceof THREE.MeshPhongMaterial); });
  };
  
  
inherit from tQuery.Material

  
  tQuery.inherit(tQuery.MeshPhongMaterial, tQuery.Material);
  
  
define all acceptable attributes for this class

  
  tQuery.mixinAttributes(tQuery.MeshPhongMaterial, {
          map                : tQuery.convert.toTexture,
          
          color                : tQuery.convert.toThreeColor,
          ambient                : tQuery.convert.toThreeColor,
          emissive        : tQuery.convert.toThreeColor,
          specular        : tQuery.convert.toThreeColor,
  
          shininess        : tQuery.convert.toNumber,
  
          envMap                : tQuery.convert.toTexture,
          refractionRatio        : tQuery.convert.toNumber,
          reflectivity        : tQuery.convert.toNumber,
          
          bumpMap                : tQuery.convert.toTexture,
          bumpScale        : tQuery.convert.toNumber,
  
          metal                : tQuery.convert.toBoolean,
          perPixel        : tQuery.convert.toBoolean
  });
  
  


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.