topical media & game development
mobile-query-three-js-tquery.mesh.js / js
Handle mesh
@class include THREE.Mesh. It inherit from {gray tQuery.Node}
@borrows tQuery.Node#get as this.get
@borrows tQuery.Node#each as this.each
@borrows tQuery.Node#back as this.back
parameter: {THREE.Mesh} object an instance or array of instance
tQuery.Mesh = function(elements)
{
// call parent ctor
var parent = tQuery.Mesh.parent;
parent.constructor.call(this, elements)
// sanity check - all items MUST be THREE.Mesh
this._lists.forEach(function(item){ console.assert(item instanceof THREE.Mesh); });
};
inherit from tQuery.Object3D
tQuery.inherit(tQuery.Mesh, tQuery.Object3D);
Make it pluginable
tQuery.pluginsInstanceOn(tQuery.Mesh);
////////////////////////////////////////////////////////////////////////////
// //
////////////////////////////////////////////////////////////////////////////
TODO to remove. this function is crap
tQuery.Mesh.prototype.material = function(value){
var parent = tQuery.Mesh.parent;
// handle the getter case
if( value === undefined ) return parent.material.call(this);
// handle parameter polymorphism
if( value instanceof tQuery.Material ) value = value.get(0)
// sanity check
console.assert( value instanceof THREE.Material )
// handle the setter case
this.each(function(tMesh){
tMesh.material = value;
});
return this; // for the chained API
}
(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.