| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010, Google Inc. | 2 * Copyright 2010, Google Inc. |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 * 'WorldViewProjectionParamMatrix4' | 95 * 'WorldViewProjectionParamMatrix4' |
| 96 * 'WorldViewProjectionInverseParamMatrix4' | 96 * 'WorldViewProjectionInverseParamMatrix4' |
| 97 * 'WorldViewProjectionTransposeParamMatrix4' | 97 * 'WorldViewProjectionTransposeParamMatrix4' |
| 98 * 'WorldViewProjectionInverseTransposeParamMatrix4' | 98 * 'WorldViewProjectionInverseTransposeParamMatrix4' |
| 99 * @return {!o3d.Param} The newly created Param or null on failure. | 99 * @return {!o3d.Param} The newly created Param or null on failure. |
| 100 */ | 100 */ |
| 101 o3d.ParamObject.prototype.createParam = | 101 o3d.ParamObject.prototype.createParam = |
| 102 function(param_name, param_type_name) { | 102 function(param_name, param_type_name) { |
| 103 if (this.params_[param_name]) | 103 if (this.params_[param_name]) |
| 104 return null; | 104 return null; |
| 105 param_type_name = o3d.filterTypeName_(param_type_name); |
| 105 if (!o3d.global.o3d[param_type_name]) | 106 if (!o3d.global.o3d[param_type_name]) |
| 106 throw ('Invalid param type name: ' + param_type_name); | 107 throw ('Invalid param type name: ' + param_type_name); |
| 107 var param = new o3d.global.o3d[param_type_name]; | 108 var param = new o3d.global.o3d[param_type_name]; |
| 108 param.gl = this.gl; | 109 param.gl = this.gl; |
| 109 param.owner_ = this; | 110 param.owner_ = this; |
| 110 this.params_[param_name] = param; | 111 this.params_[param_name] = param; |
| 111 return this.params_[param_name]; | 112 return this.filterResult_(this.params_[param_name]); |
| 112 }; | 113 }; |
| 113 | 114 |
| 114 | 115 |
| 115 /** | 116 /** |
| 116 * Searches by name for a Param defined in the object. | 117 * Searches by name for a Param defined in the object. |
| 117 * | 118 * |
| 118 * @param {string} param_name Name to search for. | 119 * @param {string} param_name Name to search for. |
| 119 * @return {!o3d.Param} The Param with the given name, or null otherwise. | 120 * @return {!o3d.Param} The Param with the given name, or null otherwise. |
| 120 */ | 121 */ |
| 121 o3d.ParamObject.prototype.getParam = | 122 o3d.ParamObject.prototype.getParam = |
| 122 function(param_name) { | 123 function(param_name) { |
| 123 return this.params_[param_name]; | 124 return this.filterResult_(this.params_[param_name]); |
| 124 }; | 125 }; |
| 125 | 126 |
| 126 | 127 |
| 127 /** | 128 /** |
| 128 * Removes a Param from a ParamObject. | 129 * Removes a Param from a ParamObject. |
| 129 * | 130 * |
| 130 * This function will fail if the param does not exist on this ParamObject | 131 * This function will fail if the param does not exist on this ParamObject |
| 131 * or if the param is unremovable. | 132 * or if the param is unremovable. |
| 132 * | 133 * |
| 133 * @param {!o3d.Param} param param to remove. | 134 * @param {!o3d.Param} param param to remove. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 162 * object. Does not replace any currently existing params with the same name. | 163 * object. Does not replace any currently existing params with the same name. |
| 163 * | 164 * |
| 164 * @param {o3d.ParamObject} source_param_object param object to copy params | 165 * @param {o3d.ParamObject} source_param_object param object to copy params |
| 165 * from. | 166 * from. |
| 166 */ | 167 */ |
| 167 o3d.ParamObject.prototype.copyParams = | 168 o3d.ParamObject.prototype.copyParams = |
| 168 function(source_param_object) { | 169 function(source_param_object) { |
| 169 o3d.notImplemented(); | 170 o3d.notImplemented(); |
| 170 }; | 171 }; |
| 171 | 172 |
| 172 | 173 /** |
| 174 * Filters results, turning 'undefined' into 'null'. |
| 175 * @private |
| 176 */ |
| 177 o3d.ParamObject.prototype.filterResult_= function(result) { |
| 178 return (result ? result : null); |
| 179 }; |
| OLD | NEW |