1 tQuery.convert	= {};
  2 
  3 /**
  4  * Convert the value into a THREE.Color object
  5  * 
  6  * @return {THREE.Color} the resulting color
  7 */
  8 tQuery.convert.toThreeColor	= function(value){
  9 	if( arguments.length === 1 && typeof(value) === 'number'){
 10 		return new THREE.Color(value);
 11 	}else if( arguments.length === 1 && value instanceof THREE.Color ){
 12 		return value;
 13 	}else{
 14 		console.assert(false, "invalid parameter");
 15 	}
 16 	return undefined;	// never reached - just to workaround linter complaint
 17 };
 18 
 19 tQuery.convert.toNumber	= function(value){
 20 	if( arguments.length === 1 && typeof(value) === 'number'){
 21 		return value;
 22 	}else{
 23 		console.assert(false, "invalid parameter");
 24 	}
 25 	return undefined;	// never reached - just to workaround linter complaint
 26 };
 27 
 28 tQuery.convert.toNumberZeroToOne	= function(value){
 29 	if( arguments.length === 1 && typeof(value) === 'number'){
 30 		value	= Math.min(value, 1.0);
 31 		value	= Math.max(value, 0);
 32 		return value;
 33 	}else{
 34 		console.assert(false, "invalid parameter");
 35 	}
 36 	return undefined;	// never reached - just to workaround linter complaint
 37 };
 38 
 39 tQuery.convert.toInteger	= function(value){
 40 	if( arguments.length === 1 && typeof(value) === 'number'){
 41 		value	= Math.floor(value);
 42 		return value;
 43 	}else{
 44 		console.assert(false, "invalid parameter");
 45 	}
 46 	return undefined;	// never reached - just to workaround linter complaint
 47 };
 48 
 49 tQuery.convert.identity	= function(value){
 50 	return value;
 51 };
 52 
 53 tQuery.convert.toBoolean	= function(value){
 54 	if( arguments.length === 1 && typeof(value) === 'boolean'){
 55 		return value;
 56 	}else{
 57 		console.assert(false, "invalid parameter");
 58 	}
 59 	return undefined;	// never reached - just to workaround linter complaint
 60 };
 61 
 62 tQuery.convert.toString	= function(value){
 63 	if( arguments.length === 1 && typeof(value) === 'string'){
 64 		return value;
 65 	}else{
 66 		console.assert(false, "invalid parameter");
 67 	}
 68 	return undefined;	// never reached - just to workaround linter complaint
 69 };
 70 
 71 tQuery.convert.toTexture	= function(value){
 72 	if( arguments.length === 1 && value instanceof THREE.Texture ){
 73 		return value;
 74 	}else if( arguments.length === 1 && typeof(value) === 'string' ){
 75 		return THREE.ImageUtils.loadTexture(value);
 76 	}else if( arguments.length === 1 && (value instanceof Image || value instanceof HTMLCanvasElement) ){
 77 		var texture		= new THREE.Texture( value );
 78 		texture.needsUpdate	= true;
 79 		return texture;
 80 	}else{
 81 		console.assert(false, "invalid parameter");
 82 	}
 83 	return undefined;	// never reached - just to workaround linter complaint
 84 };
 85