|
@@ -67005,6 +67005,9 @@ var BABYLON;
|
|
|
if (physicEngine) {
|
|
|
this._physicsEnginePlugin = physicEngine.getPhysicsPlugin();
|
|
|
}
|
|
|
+ this._utilityLayer = new BABYLON.UtilityLayerRenderer(this._scene, false);
|
|
|
+ this._utilityLayer.pickUtilitySceneFirst = false;
|
|
|
+ this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
|
|
|
}
|
|
|
/** @hidden */
|
|
|
PhysicsViewer.prototype._updateDebugMeshes = function () {
|
|
@@ -67039,7 +67042,7 @@ var BABYLON;
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
- var debugMesh = this._getDebugMesh(impostor, this._scene);
|
|
|
+ var debugMesh = this._getDebugMesh(impostor);
|
|
|
if (debugMesh) {
|
|
|
this._impostors[this._numMeshes] = impostor;
|
|
|
this._meshes[this._numMeshes] = debugMesh;
|
|
@@ -67056,17 +67059,18 @@ var BABYLON;
|
|
|
* @param impostor defines the impostor to hide
|
|
|
*/
|
|
|
PhysicsViewer.prototype.hideImpostor = function (impostor) {
|
|
|
- if (!impostor || !this._scene) {
|
|
|
+ if (!impostor || !this._scene || !this._utilityLayer) {
|
|
|
return;
|
|
|
}
|
|
|
var removed = false;
|
|
|
+ var utilityLayerScene = this._utilityLayer.utilityLayerScene;
|
|
|
for (var i = 0; i < this._numMeshes; i++) {
|
|
|
if (this._impostors[i] == impostor) {
|
|
|
var mesh = this._meshes[i];
|
|
|
if (!mesh) {
|
|
|
continue;
|
|
|
}
|
|
|
- this._scene.removeMesh(mesh);
|
|
|
+ utilityLayerScene.removeMesh(mesh);
|
|
|
mesh.dispose();
|
|
|
this._numMeshes--;
|
|
|
if (this._numMeshes > 0) {
|
|
@@ -67091,37 +67095,39 @@ var BABYLON;
|
|
|
if (!this._debugMaterial) {
|
|
|
this._debugMaterial = new BABYLON.StandardMaterial('', scene);
|
|
|
this._debugMaterial.wireframe = true;
|
|
|
+ this._debugMaterial.emissiveColor = BABYLON.Color3.White();
|
|
|
+ this._debugMaterial.disableLighting = true;
|
|
|
}
|
|
|
return this._debugMaterial;
|
|
|
};
|
|
|
PhysicsViewer.prototype._getDebugBoxMesh = function (scene) {
|
|
|
if (!this._debugBoxMesh) {
|
|
|
this._debugBoxMesh = BABYLON.MeshBuilder.CreateBox('physicsBodyBoxViewMesh', { size: 1 }, scene);
|
|
|
- this._debugBoxMesh.renderingGroupId = 1;
|
|
|
this._debugBoxMesh.rotationQuaternion = BABYLON.Quaternion.Identity();
|
|
|
this._debugBoxMesh.material = this._getDebugMaterial(scene);
|
|
|
- scene.removeMesh(this._debugBoxMesh);
|
|
|
}
|
|
|
return this._debugBoxMesh.createInstance('physicsBodyBoxViewInstance');
|
|
|
};
|
|
|
PhysicsViewer.prototype._getDebugSphereMesh = function (scene) {
|
|
|
if (!this._debugSphereMesh) {
|
|
|
this._debugSphereMesh = BABYLON.MeshBuilder.CreateSphere('physicsBodySphereViewMesh', { diameter: 1 }, scene);
|
|
|
- this._debugSphereMesh.renderingGroupId = 1;
|
|
|
this._debugSphereMesh.rotationQuaternion = BABYLON.Quaternion.Identity();
|
|
|
this._debugSphereMesh.material = this._getDebugMaterial(scene);
|
|
|
- scene.removeMesh(this._debugSphereMesh);
|
|
|
}
|
|
|
return this._debugSphereMesh.createInstance('physicsBodyBoxViewInstance');
|
|
|
};
|
|
|
- PhysicsViewer.prototype._getDebugMesh = function (impostor, scene) {
|
|
|
+ PhysicsViewer.prototype._getDebugMesh = function (impostor) {
|
|
|
+ if (!this._utilityLayer) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
var mesh = null;
|
|
|
+ var utilityLayerScene = this._utilityLayer.utilityLayerScene;
|
|
|
if (impostor.type == BABYLON.PhysicsImpostor.BoxImpostor) {
|
|
|
- mesh = this._getDebugBoxMesh(scene);
|
|
|
+ mesh = this._getDebugBoxMesh(utilityLayerScene);
|
|
|
impostor.getBoxSizeToRef(mesh.scaling);
|
|
|
}
|
|
|
else if (impostor.type == BABYLON.PhysicsImpostor.SphereImpostor) {
|
|
|
- mesh = this._getDebugSphereMesh(scene);
|
|
|
+ mesh = this._getDebugSphereMesh(utilityLayerScene);
|
|
|
var radius = impostor.getRadius();
|
|
|
mesh.scaling.x = radius * 2;
|
|
|
mesh.scaling.y = radius * 2;
|
|
@@ -67146,6 +67152,10 @@ var BABYLON;
|
|
|
this._impostors.length = 0;
|
|
|
this._scene = null;
|
|
|
this._physicsEnginePlugin = null;
|
|
|
+ if (this._utilityLayer) {
|
|
|
+ this._utilityLayer.dispose();
|
|
|
+ this._utilityLayer = null;
|
|
|
+ }
|
|
|
};
|
|
|
return PhysicsViewer;
|
|
|
}());
|
|
@@ -79883,9 +79893,11 @@ var BABYLON;
|
|
|
}
|
|
|
// Environment texture
|
|
|
if (parsedData.environmentTexture !== undefined && parsedData.environmentTexture !== null) {
|
|
|
+ // PBR needed for both HDR texture (gamma space) & a sky box
|
|
|
+ var isPBR = parsedData.isPBR !== undefined ? parsedData.isPBR : true;
|
|
|
if (parsedData.environmentTextureType && parsedData.environmentTextureType === "BABYLON.HDRCubeTexture") {
|
|
|
var hdrSize = (parsedData.environmentTextureSize) ? parsedData.environmentTextureSize : 128;
|
|
|
- var hdrTexture = new BABYLON.HDRCubeTexture(rootUrl + parsedData.environmentTexture, scene, hdrSize);
|
|
|
+ var hdrTexture = new BABYLON.HDRCubeTexture(rootUrl + parsedData.environmentTexture, scene, hdrSize, true, !isPBR);
|
|
|
if (parsedData.environmentTextureRotationY) {
|
|
|
hdrTexture.rotationY = parsedData.environmentTextureRotationY;
|
|
|
}
|
|
@@ -79901,8 +79913,7 @@ var BABYLON;
|
|
|
if (parsedData.createDefaultSkybox === true) {
|
|
|
var skyboxScale = (scene.activeCamera !== undefined && scene.activeCamera !== null) ? (scene.activeCamera.maxZ - scene.activeCamera.minZ) / 2 : 1000;
|
|
|
var skyboxBlurLevel = parsedData.skyboxBlurLevel || 0;
|
|
|
- var skyboxIsPBR = parsedData.skyboxIsPBR !== undefined ? parsedData.skyboxIsPBR : true;
|
|
|
- scene.createDefaultSkybox(scene.environmentTexture, skyboxIsPBR, skyboxScale, skyboxBlurLevel);
|
|
|
+ scene.createDefaultSkybox(scene.environmentTexture, isPBR, skyboxScale, skyboxBlurLevel);
|
|
|
}
|
|
|
}
|
|
|
// Finish
|
|
@@ -98926,6 +98937,7 @@ var BABYLON;
|
|
|
this._originDirection = this._origin.subtract(this._originTop).normalize();
|
|
|
}
|
|
|
this._tickCallback = this._tick.bind(this);
|
|
|
+ this._prepareCylinder();
|
|
|
}
|
|
|
/**
|
|
|
* Returns the data related to the updraft event (cylinder).
|
|
@@ -98957,6 +98969,9 @@ var BABYLON;
|
|
|
PhysicsUpdraftEvent.prototype.dispose = function (force) {
|
|
|
var _this = this;
|
|
|
if (force === void 0) { force = true; }
|
|
|
+ if (!this._cylinder) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (force) {
|
|
|
this._cylinder.dispose();
|
|
|
}
|
|
@@ -99008,7 +99023,6 @@ var BABYLON;
|
|
|
};
|
|
|
PhysicsUpdraftEvent.prototype._intersectsWithCylinder = function (impostor) {
|
|
|
var impostorObject = impostor.object;
|
|
|
- this._prepareCylinder();
|
|
|
this._cylinder.position = this._cylinderPosition;
|
|
|
return this._cylinder.intersectsMesh(impostorObject, true);
|
|
|
};
|
|
@@ -99043,6 +99057,7 @@ var BABYLON;
|
|
|
this._origin.addToRef(new BABYLON.Vector3(0, this._height / 2, 0), this._cylinderPosition);
|
|
|
this._origin.addToRef(new BABYLON.Vector3(0, this._height, 0), this._originTop);
|
|
|
this._tickCallback = this._tick.bind(this);
|
|
|
+ this._prepareCylinder();
|
|
|
}
|
|
|
/**
|
|
|
* Returns the data related to the vortex event (cylinder).
|
|
@@ -99147,7 +99162,6 @@ var BABYLON;
|
|
|
};
|
|
|
PhysicsVortexEvent.prototype._intersectsWithCylinder = function (impostor) {
|
|
|
var impostorObject = impostor.object;
|
|
|
- this._prepareCylinder();
|
|
|
this._cylinder.position = this._cylinderPosition;
|
|
|
return this._cylinder.intersectsMesh(impostorObject, true);
|
|
|
};
|
|
@@ -102136,10 +102150,12 @@ var BABYLON;
|
|
|
/**
|
|
|
* Instantiates a UtilityLayerRenderer
|
|
|
* @param originalScene the original scene that will be rendered on top of
|
|
|
+ * @param handleEvents boolean indicating if the utility layer should handle events
|
|
|
*/
|
|
|
function UtilityLayerRenderer(
|
|
|
/** the original scene that will be rendered on top of */
|
|
|
- originalScene) {
|
|
|
+ originalScene, handleEvents) {
|
|
|
+ if (handleEvents === void 0) { handleEvents = true; }
|
|
|
var _this = this;
|
|
|
this.originalScene = originalScene;
|
|
|
this._pointerCaptures = {};
|
|
@@ -102171,92 +102187,94 @@ var BABYLON;
|
|
|
originalScene.getEngine().scenes.pop();
|
|
|
// Detach controls on utility scene, events will be fired by logic below to handle picking priority
|
|
|
this.utilityLayerScene.detachControl();
|
|
|
- this._originalPointerObserver = originalScene.onPrePointerObservable.add(function (prePointerInfo, eventState) {
|
|
|
- if (!_this.processAllEvents) {
|
|
|
- if (prePointerInfo.type !== BABYLON.PointerEventTypes.POINTERMOVE
|
|
|
- && prePointerInfo.type !== BABYLON.PointerEventTypes.POINTERUP
|
|
|
- && prePointerInfo.type !== BABYLON.PointerEventTypes.POINTERDOWN) {
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- var pointerEvent = (prePointerInfo.event);
|
|
|
- if (originalScene.isPointerCaptured(pointerEvent.pointerId)) {
|
|
|
- _this._pointerCaptures[pointerEvent.pointerId] = false;
|
|
|
- return;
|
|
|
- }
|
|
|
- var utilityScenePick = prePointerInfo.ray ? _this.utilityLayerScene.pickWithRay(prePointerInfo.ray) : _this.utilityLayerScene.pick(originalScene.pointerX, originalScene.pointerY);
|
|
|
- if (!prePointerInfo.ray && utilityScenePick) {
|
|
|
- prePointerInfo.ray = utilityScenePick.ray;
|
|
|
- }
|
|
|
- // always fire the prepointer oversvable
|
|
|
- _this.utilityLayerScene.onPrePointerObservable.notifyObservers(prePointerInfo);
|
|
|
- // allow every non pointer down event to flow to the utility layer
|
|
|
- if (_this.onlyCheckPointerDownEvents && prePointerInfo.type != BABYLON.PointerEventTypes.POINTERDOWN) {
|
|
|
- if (!prePointerInfo.skipOnPointerObservable) {
|
|
|
- _this.utilityLayerScene.onPointerObservable.notifyObservers(new BABYLON.PointerInfo(prePointerInfo.type, prePointerInfo.event, utilityScenePick));
|
|
|
+ if (handleEvents) {
|
|
|
+ this._originalPointerObserver = originalScene.onPrePointerObservable.add(function (prePointerInfo, eventState) {
|
|
|
+ if (!_this.processAllEvents) {
|
|
|
+ if (prePointerInfo.type !== BABYLON.PointerEventTypes.POINTERMOVE
|
|
|
+ && prePointerInfo.type !== BABYLON.PointerEventTypes.POINTERUP
|
|
|
+ && prePointerInfo.type !== BABYLON.PointerEventTypes.POINTERDOWN) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
- if (prePointerInfo.type === BABYLON.PointerEventTypes.POINTERUP && _this._pointerCaptures[pointerEvent.pointerId]) {
|
|
|
+ var pointerEvent = (prePointerInfo.event);
|
|
|
+ if (originalScene.isPointerCaptured(pointerEvent.pointerId)) {
|
|
|
_this._pointerCaptures[pointerEvent.pointerId] = false;
|
|
|
+ return;
|
|
|
}
|
|
|
- return;
|
|
|
- }
|
|
|
- if (_this.utilityLayerScene.autoClearDepthAndStencil || _this.pickUtilitySceneFirst) {
|
|
|
- // If this layer is an overlay, check if this layer was hit and if so, skip pointer events for the main scene
|
|
|
- if (utilityScenePick && utilityScenePick.hit) {
|
|
|
+ var utilityScenePick = prePointerInfo.ray ? _this.utilityLayerScene.pickWithRay(prePointerInfo.ray) : _this.utilityLayerScene.pick(originalScene.pointerX, originalScene.pointerY);
|
|
|
+ if (!prePointerInfo.ray && utilityScenePick) {
|
|
|
+ prePointerInfo.ray = utilityScenePick.ray;
|
|
|
+ }
|
|
|
+ // always fire the prepointer oversvable
|
|
|
+ _this.utilityLayerScene.onPrePointerObservable.notifyObservers(prePointerInfo);
|
|
|
+ // allow every non pointer down event to flow to the utility layer
|
|
|
+ if (_this.onlyCheckPointerDownEvents && prePointerInfo.type != BABYLON.PointerEventTypes.POINTERDOWN) {
|
|
|
if (!prePointerInfo.skipOnPointerObservable) {
|
|
|
_this.utilityLayerScene.onPointerObservable.notifyObservers(new BABYLON.PointerInfo(prePointerInfo.type, prePointerInfo.event, utilityScenePick));
|
|
|
}
|
|
|
- prePointerInfo.skipOnPointerObservable = true;
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- var originalScenePick = prePointerInfo.ray ? originalScene.pickWithRay(prePointerInfo.ray) : originalScene.pick(originalScene.pointerX, originalScene.pointerY);
|
|
|
- var pointerEvent_1 = (prePointerInfo.event);
|
|
|
- // If the layer can be occluded by the original scene, only fire pointer events to the first layer that hit they ray
|
|
|
- if (originalScenePick && utilityScenePick) {
|
|
|
- // No pick in utility scene
|
|
|
- if (utilityScenePick.distance === 0 && originalScenePick.pickedMesh) {
|
|
|
- if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
|
|
|
- // We touched an utility mesh present in the main scene
|
|
|
- _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
|
|
|
- prePointerInfo.skipOnPointerObservable = true;
|
|
|
- }
|
|
|
- else if (prePointerInfo.type === BABYLON.PointerEventTypes.POINTERDOWN) {
|
|
|
- _this._pointerCaptures[pointerEvent_1.pointerId] = true;
|
|
|
- }
|
|
|
- else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
|
|
|
- // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
|
|
|
- _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
|
|
|
- delete _this._lastPointerEvents[pointerEvent_1.pointerId];
|
|
|
- }
|
|
|
+ if (prePointerInfo.type === BABYLON.PointerEventTypes.POINTERUP && _this._pointerCaptures[pointerEvent.pointerId]) {
|
|
|
+ _this._pointerCaptures[pointerEvent.pointerId] = false;
|
|
|
}
|
|
|
- else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance < originalScenePick.distance || originalScenePick.distance === 0)) {
|
|
|
- // We pick something in utility scene or the pick in utility is closer than the one in main scene
|
|
|
- _this._notifyObservers(prePointerInfo, utilityScenePick, pointerEvent_1);
|
|
|
- // If a previous utility layer set this, do not unset this
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (_this.utilityLayerScene.autoClearDepthAndStencil || _this.pickUtilitySceneFirst) {
|
|
|
+ // If this layer is an overlay, check if this layer was hit and if so, skip pointer events for the main scene
|
|
|
+ if (utilityScenePick && utilityScenePick.hit) {
|
|
|
if (!prePointerInfo.skipOnPointerObservable) {
|
|
|
- prePointerInfo.skipOnPointerObservable = utilityScenePick.distance > 0;
|
|
|
+ _this.utilityLayerScene.onPointerObservable.notifyObservers(new BABYLON.PointerInfo(prePointerInfo.type, prePointerInfo.event, utilityScenePick));
|
|
|
}
|
|
|
+ prePointerInfo.skipOnPointerObservable = true;
|
|
|
}
|
|
|
- else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance > originalScenePick.distance)) {
|
|
|
- // We have a pick in both scenes but main is closer than utility
|
|
|
- // We touched an utility mesh present in the main scene
|
|
|
- if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
|
|
|
- _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
|
|
|
- prePointerInfo.skipOnPointerObservable = true;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ var originalScenePick = prePointerInfo.ray ? originalScene.pickWithRay(prePointerInfo.ray) : originalScene.pick(originalScene.pointerX, originalScene.pointerY);
|
|
|
+ var pointerEvent_1 = (prePointerInfo.event);
|
|
|
+ // If the layer can be occluded by the original scene, only fire pointer events to the first layer that hit they ray
|
|
|
+ if (originalScenePick && utilityScenePick) {
|
|
|
+ // No pick in utility scene
|
|
|
+ if (utilityScenePick.distance === 0 && originalScenePick.pickedMesh) {
|
|
|
+ if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
|
|
|
+ // We touched an utility mesh present in the main scene
|
|
|
+ _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
|
|
|
+ prePointerInfo.skipOnPointerObservable = true;
|
|
|
+ }
|
|
|
+ else if (prePointerInfo.type === BABYLON.PointerEventTypes.POINTERDOWN) {
|
|
|
+ _this._pointerCaptures[pointerEvent_1.pointerId] = true;
|
|
|
+ }
|
|
|
+ else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
|
|
|
+ // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
|
|
|
+ _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
|
|
|
+ delete _this._lastPointerEvents[pointerEvent_1.pointerId];
|
|
|
+ }
|
|
|
}
|
|
|
- else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
|
|
|
- // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
|
|
|
- _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
|
|
|
- delete _this._lastPointerEvents[pointerEvent_1.pointerId];
|
|
|
+ else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance < originalScenePick.distance || originalScenePick.distance === 0)) {
|
|
|
+ // We pick something in utility scene or the pick in utility is closer than the one in main scene
|
|
|
+ _this._notifyObservers(prePointerInfo, utilityScenePick, pointerEvent_1);
|
|
|
+ // If a previous utility layer set this, do not unset this
|
|
|
+ if (!prePointerInfo.skipOnPointerObservable) {
|
|
|
+ prePointerInfo.skipOnPointerObservable = utilityScenePick.distance > 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance > originalScenePick.distance)) {
|
|
|
+ // We have a pick in both scenes but main is closer than utility
|
|
|
+ // We touched an utility mesh present in the main scene
|
|
|
+ if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
|
|
|
+ _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
|
|
|
+ prePointerInfo.skipOnPointerObservable = true;
|
|
|
+ }
|
|
|
+ else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
|
|
|
+ // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
|
|
|
+ _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
|
|
|
+ delete _this._lastPointerEvents[pointerEvent_1.pointerId];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (prePointerInfo.type === BABYLON.PointerEventTypes.POINTERUP && _this._pointerCaptures[pointerEvent_1.pointerId]) {
|
|
|
+ _this._pointerCaptures[pointerEvent_1.pointerId] = false;
|
|
|
}
|
|
|
- }
|
|
|
- if (prePointerInfo.type === BABYLON.PointerEventTypes.POINTERUP && _this._pointerCaptures[pointerEvent_1.pointerId]) {
|
|
|
- _this._pointerCaptures[pointerEvent_1.pointerId] = false;
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- });
|
|
|
+ });
|
|
|
+ }
|
|
|
// Render directly on top of existing scene without clearing
|
|
|
this.utilityLayerScene.autoClear = false;
|
|
|
this._afterRenderObserver = this.originalScene.onAfterRenderObservable.add(function () {
|