diff --git a/src/framework/components/camera/component.js b/src/framework/components/camera/component.js index de6ac590dea..f7709de853e 100644 --- a/src/framework/components/camera/component.js +++ b/src/framework/components/camera/component.js @@ -184,6 +184,9 @@ class CameraComponent extends Component { // postprocessing management this._postEffects = new PostEffectQueue(system.app, this); + + this._sceneDepthMapRequested = false; + this._sceneColorMapRequested = false; } /** @@ -283,12 +286,23 @@ class CameraComponent extends Component { */ requestSceneColorMap(enabled) { this._renderSceneColorMap += enabled ? 1 : -1; + Debug.assert(this._renderSceneColorMap >= 0); const ok = this._enableDepthLayer(enabled); if (!ok) { Debug.warnOnce('CameraComponent.requestSceneColorMap was called, but the camera does not have a Depth layer, ignoring.'); } } + set renderSceneColorMap(value) { + if (value && !this._sceneColorMapRequested) { + this.requestSceneColorMap(true); + this._sceneColorMapRequested = true; + } else if (this._sceneColorMapRequested) { + this.requestSceneColorMap(false); + this._sceneColorMapRequested = false; + } + } + get renderSceneColorMap() { return this._renderSceneColorMap > 0; } @@ -301,12 +315,23 @@ class CameraComponent extends Component { */ requestSceneDepthMap(enabled) { this._renderSceneDepthMap += enabled ? 1 : -1; + Debug.assert(this._renderSceneDepthMap >= 0); const ok = this._enableDepthLayer(enabled); if (!ok) { Debug.warnOnce('CameraComponent.requestSceneDepthMap was called, but the camera does not have a Depth layer, ignoring.'); } } + set renderSceneDepthMap(value) { + if (value && !this._sceneDepthMapRequested) { + this.requestSceneDepthMap(true); + this._sceneDepthMapRequested = true; + } else if (this._sceneDepthMapRequested) { + this.requestSceneDepthMap(false); + this._sceneDepthMapRequested = false; + } + } + get renderSceneDepthMap() { return this._renderSceneDepthMap > 0; } diff --git a/src/framework/components/camera/system.js b/src/framework/components/camera/system.js index c77ab230b1b..da74a4c3b96 100644 --- a/src/framework/components/camera/system.js +++ b/src/framework/components/camera/system.js @@ -58,6 +58,8 @@ class CameraComponentSystem extends ComponentSystem { 'clearColorBuffer', 'clearDepthBuffer', 'clearStencilBuffer', + 'renderSceneColorMap', + 'renderSceneDepthMap', 'cullFaces', 'farClip', 'flipFaces', @@ -118,6 +120,8 @@ class CameraComponentSystem extends ComponentSystem { clearColorBuffer: c.clearColorBuffer, clearDepthBuffer: c.clearDepthBuffer, clearStencilBuffer: c.clearStencilBuffer, + renderSceneDepthMap: c.renderSceneDepthMap, + renderSceneColorMap: c.renderSceneColorMap, cullFaces: c.cullFaces, enabled: c.enabled, farClip: c.farClip,