|
@@ -582,7 +582,14 @@
|
|
// Postprocesses
|
|
// Postprocesses
|
|
public postProcessesEnabled = true;
|
|
public postProcessesEnabled = true;
|
|
public postProcessManager: PostProcessManager;
|
|
public postProcessManager: PostProcessManager;
|
|
- public postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
|
|
|
|
|
|
+ private _postProcessRenderPipelineManager: PostProcessRenderPipelineManager
|
|
|
|
+ public get postProcessRenderPipelineManager(): PostProcessRenderPipelineManager {
|
|
|
|
+ if (!this._postProcessRenderPipelineManager) {
|
|
|
|
+ this._postProcessRenderPipelineManager = new PostProcessRenderPipelineManager();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return this._postProcessRenderPipelineManager;
|
|
|
|
+ }
|
|
|
|
|
|
// Customs render targets
|
|
// Customs render targets
|
|
public renderTargetsEnabled = true;
|
|
public renderTargetsEnabled = true;
|
|
@@ -714,18 +721,12 @@
|
|
this._engine = engine || Engine.LastCreatedEngine;
|
|
this._engine = engine || Engine.LastCreatedEngine;
|
|
|
|
|
|
this._engine.scenes.push(this);
|
|
this._engine.scenes.push(this);
|
|
-
|
|
|
|
- this._externalData = new StringDictionary<Object>();
|
|
|
|
this._uid = null;
|
|
this._uid = null;
|
|
|
|
|
|
this._renderingManager = new RenderingManager(this);
|
|
this._renderingManager = new RenderingManager(this);
|
|
|
|
|
|
this.postProcessManager = new PostProcessManager(this);
|
|
this.postProcessManager = new PostProcessManager(this);
|
|
|
|
|
|
- this.postProcessRenderPipelineManager = new PostProcessRenderPipelineManager();
|
|
|
|
-
|
|
|
|
- this._boundingBoxRenderer = new BoundingBoxRenderer(this);
|
|
|
|
-
|
|
|
|
if (OutlineRenderer) {
|
|
if (OutlineRenderer) {
|
|
this._outlineRenderer = new OutlineRenderer(this);
|
|
this._outlineRenderer = new OutlineRenderer(this);
|
|
}
|
|
}
|
|
@@ -754,6 +755,9 @@
|
|
}
|
|
}
|
|
|
|
|
|
public set workerCollisions(enabled: boolean) {
|
|
public set workerCollisions(enabled: boolean) {
|
|
|
|
+ if (!BABYLON.CollisionCoordinatorLegacy) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
|
|
enabled = (enabled && !!Worker);
|
|
enabled = (enabled && !!Worker);
|
|
|
|
|
|
@@ -808,6 +812,10 @@
|
|
}
|
|
}
|
|
|
|
|
|
public getBoundingBoxRenderer(): BoundingBoxRenderer {
|
|
public getBoundingBoxRenderer(): BoundingBoxRenderer {
|
|
|
|
+ if (!this._boundingBoxRenderer) {
|
|
|
|
+ this._boundingBoxRenderer = new BoundingBoxRenderer(this);
|
|
|
|
+ }
|
|
|
|
+
|
|
return this._boundingBoxRenderer;
|
|
return this._boundingBoxRenderer;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -940,7 +948,9 @@
|
|
if (!this._meshPickProceed) {
|
|
if (!this._meshPickProceed) {
|
|
let pickResult = this.pick(this._unTranslatedPointerX, this._unTranslatedPointerY, this.pointerDownPredicate, false, this.cameraToUseForPointers);
|
|
let pickResult = this.pick(this._unTranslatedPointerX, this._unTranslatedPointerY, this.pointerDownPredicate, false, this.cameraToUseForPointers);
|
|
this._currentPickResult = pickResult;
|
|
this._currentPickResult = pickResult;
|
|
- act = (pickResult.hit && pickResult.pickedMesh) ? pickResult.pickedMesh.actionManager : null;
|
|
|
|
|
|
+ if (pickResult) {
|
|
|
|
+ act = (pickResult.hit && pickResult.pickedMesh) ? pickResult.pickedMesh.actionManager : null;
|
|
|
|
+ }
|
|
this._meshPickProceed = true;
|
|
this._meshPickProceed = true;
|
|
}
|
|
}
|
|
return act;
|
|
return act;
|
|
@@ -965,7 +975,7 @@
|
|
let checkPicking = obs1.hasSpecificMask(PointerEventTypes.POINTERPICK) || obs2.hasSpecificMask(PointerEventTypes.POINTERPICK)
|
|
let checkPicking = obs1.hasSpecificMask(PointerEventTypes.POINTERPICK) || obs2.hasSpecificMask(PointerEventTypes.POINTERPICK)
|
|
|| obs1.hasSpecificMask(PointerEventTypes.POINTERTAP) || obs2.hasSpecificMask(PointerEventTypes.POINTERTAP)
|
|
|| obs1.hasSpecificMask(PointerEventTypes.POINTERTAP) || obs2.hasSpecificMask(PointerEventTypes.POINTERTAP)
|
|
|| obs1.hasSpecificMask(PointerEventTypes.POINTERDOUBLETAP) || obs2.hasSpecificMask(PointerEventTypes.POINTERDOUBLETAP);
|
|
|| obs1.hasSpecificMask(PointerEventTypes.POINTERDOUBLETAP) || obs2.hasSpecificMask(PointerEventTypes.POINTERDOUBLETAP);
|
|
- if (!checkPicking && ActionManager.HasPickTriggers) {
|
|
|
|
|
|
+ if (!checkPicking && BABYLON.ActionManager && ActionManager.HasPickTriggers) {
|
|
act = this._initActionManager(act, clickInfo);
|
|
act = this._initActionManager(act, clickInfo);
|
|
if (act)
|
|
if (act)
|
|
checkPicking = act.hasPickTriggers;
|
|
checkPicking = act.hasPickTriggers;
|
|
@@ -1097,7 +1107,7 @@
|
|
// Meshes
|
|
// Meshes
|
|
var pickResult = this.pick(this._unTranslatedPointerX, this._unTranslatedPointerY, this.pointerMovePredicate, false, this.cameraToUseForPointers);
|
|
var pickResult = this.pick(this._unTranslatedPointerX, this._unTranslatedPointerY, this.pointerMovePredicate, false, this.cameraToUseForPointers);
|
|
|
|
|
|
- if (pickResult.hit && pickResult.pickedMesh) {
|
|
|
|
|
|
+ if (pickResult && pickResult.hit && pickResult.pickedMesh) {
|
|
this.setPointerOverSprite(null);
|
|
this.setPointerOverSprite(null);
|
|
|
|
|
|
this.setPointerOverMesh(pickResult.pickedMesh);
|
|
this.setPointerOverMesh(pickResult.pickedMesh);
|
|
@@ -1116,7 +1126,7 @@
|
|
// Sprites
|
|
// Sprites
|
|
pickResult = this.pickSprite(this._unTranslatedPointerX, this._unTranslatedPointerY, spritePredicate, false, this.cameraToUseForPointers);
|
|
pickResult = this.pickSprite(this._unTranslatedPointerX, this._unTranslatedPointerY, spritePredicate, false, this.cameraToUseForPointers);
|
|
|
|
|
|
- if (pickResult.hit && pickResult.pickedSprite) {
|
|
|
|
|
|
+ if (pickResult && pickResult.hit && pickResult.pickedSprite) {
|
|
this.setPointerOverSprite(pickResult.pickedSprite);
|
|
this.setPointerOverSprite(pickResult.pickedSprite);
|
|
if (this._pointerOverSprite.actionManager && this._pointerOverSprite.actionManager.hoverCursor) {
|
|
if (this._pointerOverSprite.actionManager && this._pointerOverSprite.actionManager.hoverCursor) {
|
|
canvas.style.cursor = this._pointerOverSprite.actionManager.hoverCursor;
|
|
canvas.style.cursor = this._pointerOverSprite.actionManager.hoverCursor;
|
|
@@ -1176,7 +1186,7 @@
|
|
this._pickedDownMesh = null;
|
|
this._pickedDownMesh = null;
|
|
var pickResult = this.pick(this._unTranslatedPointerX, this._unTranslatedPointerY, this.pointerDownPredicate, false, this.cameraToUseForPointers);
|
|
var pickResult = this.pick(this._unTranslatedPointerX, this._unTranslatedPointerY, this.pointerDownPredicate, false, this.cameraToUseForPointers);
|
|
|
|
|
|
- if (pickResult.hit && pickResult.pickedMesh) {
|
|
|
|
|
|
+ if (pickResult && pickResult.hit && pickResult.pickedMesh) {
|
|
this._pickedDownMesh = pickResult.pickedMesh;
|
|
this._pickedDownMesh = pickResult.pickedMesh;
|
|
var actionManager = pickResult.pickedMesh.actionManager;
|
|
var actionManager = pickResult.pickedMesh.actionManager;
|
|
if (actionManager) {
|
|
if (actionManager) {
|
|
@@ -1201,7 +1211,7 @@
|
|
(mesh: AbstractMesh): boolean => mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.actionManager && mesh.actionManager.hasSpecificTrigger(ActionManager.OnLongPressTrigger) && mesh == this._pickedDownMesh,
|
|
(mesh: AbstractMesh): boolean => mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.actionManager && mesh.actionManager.hasSpecificTrigger(ActionManager.OnLongPressTrigger) && mesh == this._pickedDownMesh,
|
|
false, this.cameraToUseForPointers);
|
|
false, this.cameraToUseForPointers);
|
|
|
|
|
|
- if (pickResult.hit && pickResult.pickedMesh) {
|
|
|
|
|
|
+ if (pickResult && pickResult.hit && pickResult.pickedMesh) {
|
|
if (this._isButtonPressed &&
|
|
if (this._isButtonPressed &&
|
|
((new Date().getTime() - this._startingPointerTime) > Scene.LongPressDelay) &&
|
|
((new Date().getTime() - this._startingPointerTime) > Scene.LongPressDelay) &&
|
|
(Math.abs(this._startingPointerPosition.x - this._pointerX) < Scene.DragMovementThreshold &&
|
|
(Math.abs(this._startingPointerPosition.x - this._pointerX) < Scene.DragMovementThreshold &&
|
|
@@ -1230,7 +1240,7 @@
|
|
if (this.spriteManagers.length > 0) {
|
|
if (this.spriteManagers.length > 0) {
|
|
pickResult = this.pickSprite(this._unTranslatedPointerX, this._unTranslatedPointerY, spritePredicate, false, this.cameraToUseForPointers);
|
|
pickResult = this.pickSprite(this._unTranslatedPointerX, this._unTranslatedPointerY, spritePredicate, false, this.cameraToUseForPointers);
|
|
|
|
|
|
- if (pickResult.hit && pickResult.pickedSprite) {
|
|
|
|
|
|
+ if (pickResult && pickResult.hit && pickResult.pickedSprite) {
|
|
if (pickResult.pickedSprite.actionManager) {
|
|
if (pickResult.pickedSprite.actionManager) {
|
|
this._pickedDownSprite = pickResult.pickedSprite;
|
|
this._pickedDownSprite = pickResult.pickedSprite;
|
|
switch (evt.button) {
|
|
switch (evt.button) {
|
|
@@ -1303,14 +1313,14 @@
|
|
}
|
|
}
|
|
|
|
|
|
// Meshes
|
|
// Meshes
|
|
- if (!this._meshPickProceed && (ActionManager.HasTriggers || this.onPointerObservable.hasObservers())) {
|
|
|
|
|
|
+ if (!this._meshPickProceed && (BABYLON.ActionManager && ActionManager.HasTriggers || this.onPointerObservable.hasObservers())) {
|
|
this._initActionManager(null, clickInfo);
|
|
this._initActionManager(null, clickInfo);
|
|
}
|
|
}
|
|
if (!pickResult) {
|
|
if (!pickResult) {
|
|
pickResult = this._currentPickResult;
|
|
pickResult = this._currentPickResult;
|
|
}
|
|
}
|
|
|
|
|
|
- if (pickResult && pickResult.pickedMesh) {
|
|
|
|
|
|
+ if (pickResult && pickResult && pickResult.pickedMesh) {
|
|
this._pickedUpMesh = pickResult.pickedMesh;
|
|
this._pickedUpMesh = pickResult.pickedMesh;
|
|
if (this._pickedDownMesh === this._pickedUpMesh) {
|
|
if (this._pickedDownMesh === this._pickedUpMesh) {
|
|
if (this.onPointerPick) {
|
|
if (this.onPointerPick) {
|
|
@@ -1696,7 +1706,9 @@
|
|
var position = this.meshes.push(newMesh);
|
|
var position = this.meshes.push(newMesh);
|
|
|
|
|
|
//notify the collision coordinator
|
|
//notify the collision coordinator
|
|
- this.collisionCoordinator.onMeshAdded(newMesh);
|
|
|
|
|
|
+ if (this.collisionCoordinator) {
|
|
|
|
+ this.collisionCoordinator.onMeshAdded(newMesh);
|
|
|
|
+ }
|
|
|
|
|
|
this.onNewMeshAddedObservable.notifyObservers(newMesh);
|
|
this.onNewMeshAddedObservable.notifyObservers(newMesh);
|
|
}
|
|
}
|
|
@@ -1708,7 +1720,9 @@
|
|
this.meshes.splice(index, 1);
|
|
this.meshes.splice(index, 1);
|
|
}
|
|
}
|
|
//notify the collision coordinator
|
|
//notify the collision coordinator
|
|
- this.collisionCoordinator.onMeshRemoved(toRemove);
|
|
|
|
|
|
+ if (this.collisionCoordinator) {
|
|
|
|
+ this.collisionCoordinator.onMeshRemoved(toRemove);
|
|
|
|
+ }
|
|
|
|
|
|
this.onMeshRemovedObservable.notifyObservers(toRemove);
|
|
this.onMeshRemovedObservable.notifyObservers(toRemove);
|
|
|
|
|
|
@@ -2040,7 +2054,9 @@
|
|
this._geometries.push(geometry);
|
|
this._geometries.push(geometry);
|
|
|
|
|
|
//notify the collision coordinator
|
|
//notify the collision coordinator
|
|
- this.collisionCoordinator.onGeometryAdded(geometry);
|
|
|
|
|
|
+ if (this.collisionCoordinator) {
|
|
|
|
+ this.collisionCoordinator.onGeometryAdded(geometry);
|
|
|
|
+ }
|
|
|
|
|
|
this.onNewGeometryAddedObservable.notifyObservers(geometry);
|
|
this.onNewGeometryAddedObservable.notifyObservers(geometry);
|
|
|
|
|
|
@@ -2059,7 +2075,9 @@
|
|
this._geometries.splice(index, 1);
|
|
this._geometries.splice(index, 1);
|
|
|
|
|
|
//notify the collision coordinator
|
|
//notify the collision coordinator
|
|
- this.collisionCoordinator.onGeometryDeleted(geometry);
|
|
|
|
|
|
+ if (this.collisionCoordinator) {
|
|
|
|
+ this.collisionCoordinator.onGeometryDeleted(geometry);
|
|
|
|
+ }
|
|
|
|
|
|
this.onGeometryRemovedObservable.notifyObservers(geometry);
|
|
this.onGeometryRemovedObservable.notifyObservers(geometry);
|
|
return true;
|
|
return true;
|
|
@@ -2343,7 +2361,7 @@
|
|
var material = subMesh.getMaterial();
|
|
var material = subMesh.getMaterial();
|
|
|
|
|
|
if (mesh.showSubMeshesBoundingBox) {
|
|
if (mesh.showSubMeshesBoundingBox) {
|
|
- this._boundingBoxRenderer.renderList.push(subMesh.getBoundingInfo().boundingBox);
|
|
|
|
|
|
+ this.getBoundingBoxRenderer().renderList.push(subMesh.getBoundingInfo().boundingBox);
|
|
}
|
|
}
|
|
|
|
|
|
if (material) {
|
|
if (material) {
|
|
@@ -2375,7 +2393,9 @@
|
|
this._activeParticleSystems.reset();
|
|
this._activeParticleSystems.reset();
|
|
this._activeSkeletons.reset();
|
|
this._activeSkeletons.reset();
|
|
this._softwareSkinnedMeshes.reset();
|
|
this._softwareSkinnedMeshes.reset();
|
|
- this._boundingBoxRenderer.reset();
|
|
|
|
|
|
+ if (this._boundingBoxRenderer) {
|
|
|
|
+ this._boundingBoxRenderer.reset();
|
|
|
|
+ }
|
|
this._edgesRenderers.reset();
|
|
this._edgesRenderers.reset();
|
|
|
|
|
|
// Meshes
|
|
// Meshes
|
|
@@ -2464,7 +2484,7 @@
|
|
}
|
|
}
|
|
|
|
|
|
if (sourceMesh.showBoundingBox || this.forceShowBoundingBoxes) {
|
|
if (sourceMesh.showBoundingBox || this.forceShowBoundingBoxes) {
|
|
- this._boundingBoxRenderer.renderList.push(sourceMesh.getBoundingInfo().boundingBox);
|
|
|
|
|
|
+ this.getBoundingBoxRenderer().renderList.push(sourceMesh.getBoundingInfo().boundingBox);
|
|
}
|
|
}
|
|
|
|
|
|
if (sourceMesh._edgesRenderer) {
|
|
if (sourceMesh._edgesRenderer) {
|
|
@@ -2628,7 +2648,9 @@
|
|
Tools.EndPerformanceCounter("Main render");
|
|
Tools.EndPerformanceCounter("Main render");
|
|
|
|
|
|
// Bounding boxes
|
|
// Bounding boxes
|
|
- this._boundingBoxRenderer.render();
|
|
|
|
|
|
+ if (this._boundingBoxRenderer) {
|
|
|
|
+ this._boundingBoxRenderer.render();
|
|
|
|
+ }
|
|
|
|
|
|
// Edges
|
|
// Edges
|
|
for (var edgesRendererIndex = 0; edgesRendererIndex < this._edgesRenderers.length; edgesRendererIndex++) {
|
|
for (var edgesRendererIndex = 0; edgesRendererIndex < this._edgesRenderers.length; edgesRendererIndex++) {
|
|
@@ -2860,7 +2882,9 @@
|
|
}
|
|
}
|
|
|
|
|
|
// RenderPipeline
|
|
// RenderPipeline
|
|
- this.postProcessRenderPipelineManager.update();
|
|
|
|
|
|
+ if (this._postProcessRenderPipelineManager) {
|
|
|
|
+ this._postProcessRenderPipelineManager.update();
|
|
|
|
+ }
|
|
|
|
|
|
// Multi-cameras?
|
|
// Multi-cameras?
|
|
if (this.activeCameras.length > 0) {
|
|
if (this.activeCameras.length > 0) {
|
|
@@ -3070,8 +3094,6 @@
|
|
this.skeletons = [];
|
|
this.skeletons = [];
|
|
this.morphTargetManagers = [];
|
|
this.morphTargetManagers = [];
|
|
|
|
|
|
- this._boundingBoxRenderer.dispose();
|
|
|
|
-
|
|
|
|
if (this._depthRenderer) {
|
|
if (this._depthRenderer) {
|
|
this._depthRenderer.dispose();
|
|
this._depthRenderer.dispose();
|
|
}
|
|
}
|
|
@@ -3087,7 +3109,9 @@
|
|
this._activeParticleSystems.dispose();
|
|
this._activeParticleSystems.dispose();
|
|
this._activeSkeletons.dispose();
|
|
this._activeSkeletons.dispose();
|
|
this._softwareSkinnedMeshes.dispose();
|
|
this._softwareSkinnedMeshes.dispose();
|
|
- this._boundingBoxRenderer.dispose();
|
|
|
|
|
|
+ if (this._boundingBoxRenderer) {
|
|
|
|
+ this._boundingBoxRenderer.dispose();
|
|
|
|
+ }
|
|
this._edgesRenderers.dispose();
|
|
this._edgesRenderers.dispose();
|
|
this._meshesForIntersections.dispose();
|
|
this._meshesForIntersections.dispose();
|
|
this._toBeDisposed.dispose();
|
|
this._toBeDisposed.dispose();
|
|
@@ -3249,6 +3273,10 @@
|
|
}
|
|
}
|
|
|
|
|
|
public createPickingRayInCameraSpace(x: number, y: number, camera: Camera): Ray {
|
|
public createPickingRayInCameraSpace(x: number, y: number, camera: Camera): Ray {
|
|
|
|
+ if (!BABYLON.PickingInfo) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
var engine = this._engine;
|
|
var engine = this._engine;
|
|
|
|
|
|
if (!camera) {
|
|
if (!camera) {
|
|
@@ -3269,6 +3297,10 @@
|
|
}
|
|
}
|
|
|
|
|
|
private _internalPick(rayFunction: (world: Matrix) => Ray, predicate: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): PickingInfo {
|
|
private _internalPick(rayFunction: (world: Matrix) => Ray, predicate: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): PickingInfo {
|
|
|
|
+ if (!BABYLON.PickingInfo) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
var pickingInfo = null;
|
|
var pickingInfo = null;
|
|
|
|
|
|
for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
|
|
for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
|
|
@@ -3303,6 +3335,9 @@
|
|
}
|
|
}
|
|
|
|
|
|
private _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate: (mesh: AbstractMesh) => boolean): PickingInfo[] {
|
|
private _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate: (mesh: AbstractMesh) => boolean): PickingInfo[] {
|
|
|
|
+ if (!BABYLON.PickingInfo) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
var pickingInfos = new Array<PickingInfo>();
|
|
var pickingInfos = new Array<PickingInfo>();
|
|
|
|
|
|
for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
|
|
for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
|
|
@@ -3331,6 +3366,10 @@
|
|
|
|
|
|
|
|
|
|
private _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): PickingInfo {
|
|
private _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): PickingInfo {
|
|
|
|
+ if (!BABYLON.PickingInfo) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
var pickingInfo = null;
|
|
var pickingInfo = null;
|
|
|
|
|
|
camera = camera || this.activeCamera;
|
|
camera = camera || this.activeCamera;
|