@babylonjs/core 7.27.1 → 7.27.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babylonjs/core",
3
- "version": "7.27.1",
3
+ "version": "7.27.2",
4
4
  "main": "index.js",
5
5
  "module": "index.js",
6
6
  "types": "index.d.ts",
package/scene.d.ts CHANGED
@@ -2016,6 +2016,10 @@ export declare class Scene implements IAnimatable, IClipPlanesHolder, IAssetCont
2016
2016
  * @param passId If provided, releases only the draw wrapper corresponding to this render pass id
2017
2017
  */
2018
2018
  resetDrawCache(passId?: number): void;
2019
+ /**
2020
+ * If this function is defined it will take precedence over the standard render() function.
2021
+ */
2022
+ customRenderFunction?: () => void;
2019
2023
  /**
2020
2024
  * Render the scene
2021
2025
  * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
package/scene.js CHANGED
@@ -3825,59 +3825,67 @@ export class Scene {
3825
3825
  }
3826
3826
  // Before render
3827
3827
  this.onBeforeRenderObservable.notifyObservers(this);
3828
- const engine = this.getEngine();
3829
- // Customs render targets
3830
- this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
3831
- const currentActiveCamera = this.activeCameras?.length ? this.activeCameras[0] : this.activeCamera;
3832
- if (this.renderTargetsEnabled) {
3833
- Tools.StartPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
3834
- this._intermediateRendering = true;
3835
- for (let customIndex = 0; customIndex < this.customRenderTargets.length; customIndex++) {
3836
- const renderTarget = this.customRenderTargets[customIndex];
3837
- if (renderTarget._shouldRender()) {
3838
- this._renderId++;
3839
- this.activeCamera = renderTarget.activeCamera || this.activeCamera;
3840
- if (!this.activeCamera) {
3841
- throw new Error("Active camera not set");
3828
+ // Custom render function?
3829
+ if (this.customRenderFunction) {
3830
+ this._renderId++;
3831
+ this._engine.currentRenderPassId = 0;
3832
+ this.customRenderFunction();
3833
+ }
3834
+ else {
3835
+ const engine = this.getEngine();
3836
+ // Customs render targets
3837
+ this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
3838
+ const currentActiveCamera = this.activeCameras?.length ? this.activeCameras[0] : this.activeCamera;
3839
+ if (this.renderTargetsEnabled) {
3840
+ Tools.StartPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
3841
+ this._intermediateRendering = true;
3842
+ for (let customIndex = 0; customIndex < this.customRenderTargets.length; customIndex++) {
3843
+ const renderTarget = this.customRenderTargets[customIndex];
3844
+ if (renderTarget._shouldRender()) {
3845
+ this._renderId++;
3846
+ this.activeCamera = renderTarget.activeCamera || this.activeCamera;
3847
+ if (!this.activeCamera) {
3848
+ throw new Error("Active camera not set");
3849
+ }
3850
+ // Viewport
3851
+ engine.setViewport(this.activeCamera.viewport);
3852
+ // Camera
3853
+ this.updateTransformMatrix();
3854
+ renderTarget.render(currentActiveCamera !== this.activeCamera, this.dumpNextRenderTargets);
3842
3855
  }
3843
- // Viewport
3844
- engine.setViewport(this.activeCamera.viewport);
3845
- // Camera
3846
- this.updateTransformMatrix();
3847
- renderTarget.render(currentActiveCamera !== this.activeCamera, this.dumpNextRenderTargets);
3848
3856
  }
3857
+ Tools.EndPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
3858
+ this._intermediateRendering = false;
3859
+ this._renderId++;
3849
3860
  }
3850
- Tools.EndPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
3851
- this._intermediateRendering = false;
3852
- this._renderId++;
3853
- }
3854
- this._engine.currentRenderPassId = currentActiveCamera?.renderPassId ?? 0;
3855
- // Restore back buffer
3856
- this.activeCamera = currentActiveCamera;
3857
- if (this._activeCamera && this._activeCamera.cameraRigMode !== 22 && !this.prePass) {
3858
- this._bindFrameBuffer(this._activeCamera, false);
3859
- }
3860
- this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
3861
- for (const step of this._beforeClearStage) {
3862
- step.action();
3863
- }
3864
- // Clear
3865
- this._clearFrameBuffer(this.activeCamera);
3866
- // Collects render targets from external components.
3867
- for (const step of this._gatherRenderTargetsStage) {
3868
- step.action(this._renderTargets);
3869
- }
3870
- // Multi-cameras?
3871
- if (this.activeCameras && this.activeCameras.length > 0) {
3872
- for (let cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
3873
- this._processSubCameras(this.activeCameras[cameraIndex], cameraIndex > 0);
3861
+ this._engine.currentRenderPassId = currentActiveCamera?.renderPassId ?? 0;
3862
+ // Restore back buffer
3863
+ this.activeCamera = currentActiveCamera;
3864
+ if (this._activeCamera && this._activeCamera.cameraRigMode !== 22 && !this.prePass) {
3865
+ this._bindFrameBuffer(this._activeCamera, false);
3874
3866
  }
3875
- }
3876
- else {
3877
- if (!this.activeCamera) {
3878
- throw new Error("No camera defined");
3867
+ this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
3868
+ for (const step of this._beforeClearStage) {
3869
+ step.action();
3870
+ }
3871
+ // Clear
3872
+ this._clearFrameBuffer(this.activeCamera);
3873
+ // Collects render targets from external components.
3874
+ for (const step of this._gatherRenderTargetsStage) {
3875
+ step.action(this._renderTargets);
3876
+ }
3877
+ // Multi-cameras?
3878
+ if (this.activeCameras && this.activeCameras.length > 0) {
3879
+ for (let cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
3880
+ this._processSubCameras(this.activeCameras[cameraIndex], cameraIndex > 0);
3881
+ }
3882
+ }
3883
+ else {
3884
+ if (!this.activeCamera) {
3885
+ throw new Error("No camera defined");
3886
+ }
3887
+ this._processSubCameras(this.activeCamera, !!this.activeCamera.outputRenderTarget);
3879
3888
  }
3880
- this._processSubCameras(this.activeCamera, !!this.activeCamera.outputRenderTarget);
3881
3889
  }
3882
3890
  // Intersection checks
3883
3891
  this._checkIntersections();