Open leconcepteur opened 12 years ago
Examples :
tQuery('cube').not('.excludeClass').scale(2).translate(1,0,0); // Do not affect objects with class 'excludeClass'
tQuery('cube').not('#excludeId').scale(2).translate(1,0,0); // Do not affect object with id 'excludeId'
tQuery('*').not('cube').scale(2).translate(1,0,0); // Do not affect cubes
what is this ?
tQuery.Object3D.parent.constructor.call(this, lists);
Sorry I'm just being lazy there. I didn't quite understood this part of the code, all I know is that it doesn't work and this._list is not populated if I don't use this line. I took it from the constructor of tQuery.Object3D.
That's kind of the reason I didn't do a Pull Request, as I'm not sure myself of what I was doing ;)
what about
this._lists = lists;
Hahaha! It works perfect :P Sorry, laziness is a big flaw when coding.
I have corrected the code. My loop was buggy.
/**
* Exclude specified Object3D
*
* @param {} object
* @param {THREE.Object3D} rootnode
* @returns {tQuery.Object3D} chained API
*/
tQuery.Object3D.prototype.not = function(object, root){
if( typeof object === "string" ) object = tQuery.Object3D._select(object, root);
else if( !object ) object = [];
else if ( !(object instanceof Array) ) object = [object];
var lists = [];
object.forEach(function(objectChild){
if (this._lists.indexOf(objectChild) !== -1) {
this._lists.splice(this._lists.indexOf(objectChild), 1);
}
}.bind(this));
return this;
}
.not() seems a good idea. what are the other call() similar in jQuery ? while at it, we may do that too.
i know of .filter(). any other ?
Functional mimic of the jQuery .not() functionality. It's ugly and not efficient, but you get the idea.