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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 * Returns all the transforms under this transform including this one. | 128 * Returns all the transforms under this transform including this one. |
129 * | 129 * |
130 * Note that modifications to this array [e.g. additions to it] will not affect | 130 * Note that modifications to this array [e.g. additions to it] will not affect |
131 * the underlying Transform, while modifications to the members of the array | 131 * the underlying Transform, while modifications to the members of the array |
132 * will affect them. | 132 * will affect them. |
133 * | 133 * |
134 * An array containing the transforms of the subtree. | 134 * An array containing the transforms of the subtree. |
135 */ | 135 */ |
136 o3d.Transform.prototype.getTransformsInTree = | 136 o3d.Transform.prototype.getTransformsInTree = |
137 function() { | 137 function() { |
138 | 138 var result = []; |
| 139 o3d.Transform.getTransformInTreeRecursive_(this, result); |
| 140 return result; |
139 }; | 141 }; |
140 | 142 |
141 | 143 |
| 144 /** |
| 145 * Recursive helper function for getTransformInTree. |
| 146 * @private |
| 147 */ |
| 148 o3d.Transform.getTransformInTreeRecursive_ = |
| 149 function(treeRoot, children) { |
| 150 children.push(treeRoot); |
| 151 var childrenArray = treeRoot.children; |
| 152 for (var ii = 0; ii < childrenArray.length; ++ii) { |
| 153 o3d.Transform.getTransformInTreeRecursive_(childrenArray[ii], children); |
| 154 } |
| 155 }; |
| 156 |
142 | 157 |
143 /** | 158 /** |
144 * Searches for transforms that match the given name in the hierarchy under and | 159 * Searches for transforms that match the given name in the hierarchy under and |
145 * including this transform. Since there can be more than one transform with a | 160 * including this transform. Since there can be more than one transform with a |
146 * given name, results are returned in an array. | 161 * given name, results are returned in an array. |
147 * | 162 * |
148 * Note that modifications to this array [e.g. additions to it] will not affect | 163 * Note that modifications to this array [e.g. additions to it] will not affect |
149 * the underlying Transform, while modifications to the members of the array | 164 * the underlying Transform, while modifications to the members of the array |
150 * will affect them. | 165 * will affect them. |
151 * | 166 * |
152 * @param {string} name Transform name to look for. | 167 * @param {string} name Transform name to look for. |
153 * @return {Array.<o3d.Transform>} An array containing the transforms of the | 168 * @return {Array.<o3d.Transform>} An array containing the transforms of the |
154 * under and including this transform matching the given name. | 169 * under and including this transform matching the given name. |
155 */ | 170 */ |
156 o3d.Transform.prototype.getTransformsByNameInTree = | 171 o3d.Transform.prototype.getTransformsByNameInTree = |
157 function(name) { | 172 function(name) { |
158 | 173 o3d.notImplemented(); |
159 }; | 174 }; |
160 | 175 |
161 | |
162 /** | 176 /** |
163 * Evaluates and returns the current world matrix. | 177 * Evaluates and returns the current world matrix. |
164 * | 178 * |
165 * The updated world matrix. | 179 * The updated world matrix. |
166 */ | 180 */ |
167 o3d.Transform.prototype.getUpdatedWorldMatrix = | 181 o3d.Transform.prototype.getUpdatedWorldMatrix = |
168 function() { | 182 function() { |
169 | 183 o3d.notImplemented(); |
170 }; | 184 }; |
171 | 185 |
172 | 186 |
173 /** | 187 /** |
174 * Adds a shape do this transform. | 188 * Adds a shape do this transform. |
175 * @param {o3d.Shape} shape Shape to add. | 189 * @param {o3d.Shape} shape Shape to add. |
176 */ | 190 */ |
177 o3d.Transform.prototype.addShape = | 191 o3d.Transform.prototype.addShape = |
178 function(shape) { | 192 function(shape) { |
179 this.shapes.push(shape); | 193 this.shapes.push(shape); |
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 for (var i = 0; i < shapes.length; ++i) { | 952 for (var i = 0; i < shapes.length; ++i) { |
939 shapes[i].writeToDrawLists(drawListInfos, this.worldMatrix, this); | 953 shapes[i].writeToDrawLists(drawListInfos, this.worldMatrix, this); |
940 } | 954 } |
941 | 955 |
942 for (var i = 0; i < children.length; ++i) { | 956 for (var i = 0; i < children.length; ++i) { |
943 children[i].traverse(drawListInfos, this.worldMatrix); | 957 children[i].traverse(drawListInfos, this.worldMatrix); |
944 } | 958 } |
945 }; | 959 }; |
946 | 960 |
947 | 961 |
OLD | NEW |