|
@@ -3,7 +3,7 @@
|
|
|
var BABYLON = BABYLON || {};
|
|
|
|
|
|
(function () {
|
|
|
- BABYLON.Scene = function (engine) {
|
|
|
+ BABYLON.Scene = function(engine) {
|
|
|
this._engine = engine;
|
|
|
this.autoClear = true;
|
|
|
this.clearColor = new BABYLON.Color3(0.2, 0.2, 0.3);
|
|
@@ -106,9 +106,16 @@ var BABYLON = BABYLON || {};
|
|
|
|
|
|
// Multi-cameras
|
|
|
this.activeCameras = [];
|
|
|
+
|
|
|
+ // Render bounding boxes
|
|
|
+ this._boundingBoxRenderer = new BABYLON.BoundingBoxRenderer(this);
|
|
|
+ };
|
|
|
+
|
|
|
+ // Properties
|
|
|
+ BABYLON.Scene.prototype.getBoundingBoxRenderer = function () {
|
|
|
+ return this._boundingBoxRenderer;
|
|
|
};
|
|
|
|
|
|
- // Properties
|
|
|
BABYLON.Scene.prototype.getEngine = function () {
|
|
|
return this._engine;
|
|
|
};
|
|
@@ -409,7 +416,7 @@ var BABYLON = BABYLON || {};
|
|
|
};
|
|
|
|
|
|
BABYLON.Scene.prototype.getLastMeshByID = function (id) {
|
|
|
- for (var index = this.meshes.length - 1; index >= 0 ; index--) {
|
|
|
+ for (var index = this.meshes.length - 1; index >= 0; index--) {
|
|
|
if (this.meshes[index].id === id) {
|
|
|
return this.meshes[index];
|
|
|
}
|
|
@@ -419,19 +426,19 @@ var BABYLON = BABYLON || {};
|
|
|
};
|
|
|
|
|
|
BABYLON.Scene.prototype.getLastEntryByID = function (id) {
|
|
|
- for (var index = this.meshes.length - 1; index >= 0 ; index--) {
|
|
|
+ for (var index = this.meshes.length - 1; index >= 0; index--) {
|
|
|
if (this.meshes[index].id === id) {
|
|
|
return this.meshes[index];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- for (var index = this.cameras.length - 1; index >= 0 ; index--) {
|
|
|
+ for (var index = this.cameras.length - 1; index >= 0; index--) {
|
|
|
if (this.cameras[index].id === id) {
|
|
|
return this.cameras[index];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- for (var index = this.lights.length - 1; index >= 0 ; index--) {
|
|
|
+ for (var index = this.lights.length - 1; index >= 0; index--) {
|
|
|
if (this.lights[index].id === id) {
|
|
|
return this.lights[index];
|
|
|
}
|
|
@@ -451,7 +458,7 @@ var BABYLON = BABYLON || {};
|
|
|
};
|
|
|
|
|
|
BABYLON.Scene.prototype.getLastSkeletonByID = function (id) {
|
|
|
- for (var index = this.skeletons.length - 1; index >= 0 ; index--) {
|
|
|
+ for (var index = this.skeletons.length - 1; index >= 0; index--) {
|
|
|
if (this.skeletons[index].id === id) {
|
|
|
return this.skeletons[index];
|
|
|
}
|
|
@@ -511,6 +518,7 @@ var BABYLON = BABYLON || {};
|
|
|
this._processedMaterials.reset();
|
|
|
this._activeParticleSystems.reset();
|
|
|
this._activeSkeletons.reset();
|
|
|
+ this._boundingBoxRenderer.reset();
|
|
|
|
|
|
if (!this._frustumPlanes) {
|
|
|
this._frustumPlanes = BABYLON.Frustum.GetPlanes(this._transformMatrix);
|
|
@@ -545,6 +553,10 @@ var BABYLON = BABYLON || {};
|
|
|
}
|
|
|
mesh._renderId = this._renderId;
|
|
|
|
|
|
+ if (mesh.showBoundingBox) {
|
|
|
+ this._boundingBoxRenderer.renderList.push(mesh);
|
|
|
+ }
|
|
|
+
|
|
|
if (mesh.skeleton) {
|
|
|
this._activeSkeletons.pushNoDuplicate(mesh.skeleton);
|
|
|
}
|
|
@@ -584,6 +596,10 @@ var BABYLON = BABYLON || {};
|
|
|
this._activeSkeletons.pushNoDuplicate(mesh.skeleton);
|
|
|
}
|
|
|
|
|
|
+ if (mesh.showBoundingBox) {
|
|
|
+ this._boundingBoxRenderer.renderList.push(mesh);
|
|
|
+ }
|
|
|
+
|
|
|
for (var subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
|
|
|
var subMesh = mesh.subMeshes[subIndex];
|
|
|
|
|
@@ -676,6 +692,9 @@ var BABYLON = BABYLON || {};
|
|
|
// Render
|
|
|
this._renderingManager.render(null, null, true, true);
|
|
|
|
|
|
+ // Bounding boxes
|
|
|
+ this._boundingBoxRenderer.render();
|
|
|
+
|
|
|
// Lens flares
|
|
|
for (var lensFlareSystemIndex = 0; lensFlareSystemIndex < this.lensFlareSystems.length; lensFlareSystemIndex++) {
|
|
|
this.lensFlareSystems[lensFlareSystemIndex].render();
|
|
@@ -798,6 +817,8 @@ var BABYLON = BABYLON || {};
|
|
|
|
|
|
this.skeletons = [];
|
|
|
|
|
|
+ this._boundingBoxRenderer.dispose();
|
|
|
+
|
|
|
// Detach cameras
|
|
|
var canvas = this._engine.getRenderingCanvas();
|
|
|
var index;
|
|
@@ -1084,7 +1105,7 @@ var BABYLON = BABYLON || {};
|
|
|
};
|
|
|
|
|
|
// Tags
|
|
|
- BABYLON.Scene.prototype._getByTags = function(list, tagsQuery) {
|
|
|
+ BABYLON.Scene.prototype._getByTags = function (list, tagsQuery) {
|
|
|
if (tagsQuery === undefined) {
|
|
|
// returns the complete list (could be done with BABYLON.Tags.MatchesQuery but no need to have a for-loop here)
|
|
|
return list;
|