1 /** 2 * Handle mesh 3 * 4 * @class include THREE.Mesh. It inherit from {@link tQuery.Node} 5 * 6 * @borrows tQuery.Node#get as this.get 7 * @borrows tQuery.Node#each as this.each 8 * @borrows tQuery.Node#back as this.back 9 * 10 * @param {THREE.Mesh} object an instance or array of instance 11 */ 12 tQuery.Mesh = function(elements) 13 { 14 // call parent ctor 15 var parent = tQuery.Mesh.parent; 16 parent.constructor.call(this, elements) 17 18 // sanity check - all items MUST be THREE.Mesh 19 this._lists.forEach(function(item){ console.assert(item instanceof THREE.Mesh); }); 20 }; 21 22 /** 23 * inherit from tQuery.Object3D 24 */ 25 tQuery.inherit(tQuery.Mesh, tQuery.Object3D); 26 27 /** 28 * Make it pluginable 29 */ 30 tQuery.pluginsInstanceOn(tQuery.Mesh); 31 32 ////////////////////////////////////////////////////////////////////////////////// 33 // // 34 ////////////////////////////////////////////////////////////////////////////////// 35 36 /** 37 * TODO to remove. this function is crap 38 */ 39 tQuery.Mesh.prototype.material = function(value){ 40 var parent = tQuery.Mesh.parent; 41 // handle the getter case 42 if( value == undefined ) return parent.material.call(this); 43 // handle parameter polymorphism 44 if( value instanceof tQuery.Material ) value = value.get(0) 45 // sanity check 46 console.assert( value instanceof THREE.Material ) 47 // handle the setter case 48 this.each(function(tMesh){ 49 tMesh.material = value; 50 }); 51 return this; // for the chained API 52 } 53 54