* An alternative version of Object3D#updateMatrixWorld with more control over the * update of ancestor and descendant nodes. * * @param {boolean} [updateParents=false] Whether ancestor nodes should be updated or not. * @param {boolean} [updateChildren=false] Whether descendant nodes
( updateParents, updateChildren, force = false )
| 1212 | * when {@link Object3D#matrixWorldNeedsUpdate} is `false`. |
| 1213 | */ |
| 1214 | updateWorldMatrix( updateParents, updateChildren, force = false ) { |
| 1215 | |
| 1216 | const parent = this.parent; |
| 1217 | |
| 1218 | if ( updateParents === true && parent !== null ) { |
| 1219 | |
| 1220 | parent.updateWorldMatrix( true, false ); |
| 1221 | |
| 1222 | } |
| 1223 | |
| 1224 | if ( this.matrixAutoUpdate ) this.updateMatrix(); |
| 1225 | |
| 1226 | if ( this.matrixWorldNeedsUpdate || force ) { |
| 1227 | |
| 1228 | if ( this.matrixWorldAutoUpdate === true ) { |
| 1229 | |
| 1230 | if ( this.parent === null ) { |
| 1231 | |
| 1232 | this.matrixWorld.copy( this.matrix ); |
| 1233 | |
| 1234 | } else { |
| 1235 | |
| 1236 | this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix ); |
| 1237 | |
| 1238 | } |
| 1239 | |
| 1240 | } |
| 1241 | |
| 1242 | this.matrixWorldNeedsUpdate = false; |
| 1243 | |
| 1244 | force = true; |
| 1245 | |
| 1246 | } |
| 1247 | |
| 1248 | // make sure descendants are updated |
| 1249 | |
| 1250 | if ( updateChildren === true ) { |
| 1251 | |
| 1252 | const children = this.children; |
| 1253 | |
| 1254 | for ( let i = 0, l = children.length; i < l; i ++ ) { |
| 1255 | |
| 1256 | const child = children[ i ]; |
| 1257 | |
| 1258 | child.updateWorldMatrix( false, true, force ); |
| 1259 | |
| 1260 | } |
| 1261 | |
| 1262 | } |
| 1263 | |
| 1264 | } |
| 1265 | |
| 1266 | /** |
| 1267 | * Serializes the 3D object into JSON. |
no test coverage detected