|
@@ -10,6 +10,7 @@ import { _DevTools } from './Misc/devTools';
|
|
|
import { AbstractActionManager } from './Actions/abstractActionManager';
|
|
|
import { IInspectable } from './Misc/iInspectable';
|
|
|
import { Tools } from './Misc/tools';
|
|
|
+import { BoundingInfo } from './Culling/boundingInfo';
|
|
|
|
|
|
declare type Animatable = import("./Animations/animatable").Animatable;
|
|
|
declare type AnimationPropertiesOverride = import("./Animations/animationPropertiesOverride").AnimationPropertiesOverride;
|
|
@@ -766,13 +767,6 @@ export class Node implements IBehaviorAware<Node> {
|
|
|
this._behaviors = [];
|
|
|
}
|
|
|
|
|
|
- protected _getBoudingInfoMin() {
|
|
|
- return new Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
|
|
|
- }
|
|
|
- protected _getBoudingInfoMax() {
|
|
|
- return new Vector3(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Parse animation range data from a serialization object and store them into a given node
|
|
|
* @param node defines where to store the animation ranges
|
|
@@ -788,6 +782,22 @@ export class Node implements IBehaviorAware<Node> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /** @hidden */
|
|
|
+ public _boundingInfo: Nullable<BoundingInfo>;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
|
|
|
+ * @returns a BoundingInfo
|
|
|
+ */
|
|
|
+ public getBoundingInfo(): BoundingInfo {
|
|
|
+
|
|
|
+ if (!this._boundingInfo) {
|
|
|
+ this._boundingInfo = new BoundingInfo(new Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), new Vector3(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE), this._worldMatrix);
|
|
|
+ }
|
|
|
+
|
|
|
+ return this._boundingInfo!;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Return the minimum and maximum world vectors of the entire hierarchy under current mesh
|
|
|
* @param includeDescendants Include bounding info from descendants as well (true by default)
|
|
@@ -800,8 +810,17 @@ export class Node implements IBehaviorAware<Node> {
|
|
|
|
|
|
this.computeWorldMatrix(true);
|
|
|
|
|
|
- let min = this._getBoudingInfoMin();
|
|
|
- let max = this._getBoudingInfoMax();
|
|
|
+ let min: Vector3;
|
|
|
+ let max: Vector3;
|
|
|
+ let boundingInfo = this.getBoundingInfo();
|
|
|
+
|
|
|
+ if (!(this as any).subMeshes) {
|
|
|
+ min = new Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
|
|
|
+ max = new Vector3(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
|
|
|
+ } else {
|
|
|
+ min = boundingInfo.boundingBox.minimumWorld;
|
|
|
+ max = boundingInfo.boundingBox.maximumWorld;
|
|
|
+ }
|
|
|
|
|
|
if (includeDescendants) {
|
|
|
let descendants = this.getDescendants(false);
|
|
@@ -816,7 +835,7 @@ export class Node implements IBehaviorAware<Node> {
|
|
|
}
|
|
|
|
|
|
//make sure we have the needed params to get mix and max
|
|
|
- if (!childMesh.getBoundingInfo || childMesh.getTotalVertices() === 0) {
|
|
|
+ if (!childMesh.getTotalVertices || childMesh.getTotalVertices() === 0) {
|
|
|
continue;
|
|
|
}
|
|
|
|