@babylonjs/core 7.34.0 → 7.34.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/Animations/animatable.core.d.ts +2 -1
- package/Animations/animatable.core.js +3 -2
- package/Animations/animatable.core.js.map +1 -1
- package/Animations/animationGroup.d.ts +2 -1
- package/Animations/animationGroup.js +4 -3
- package/Animations/animationGroup.js.map +1 -1
- package/Collisions/gpuPicker.d.ts +1 -1
- package/Collisions/gpuPicker.js +1 -1
- package/Collisions/gpuPicker.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.query.js +9 -9
- package/Engines/WebGPU/Extensions/engine.query.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/thinWebGPUEngine.d.ts +3 -0
- package/Engines/thinWebGPUEngine.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +1 -3
- package/Engines/webgpuEngine.js +1 -0
- package/Engines/webgpuEngine.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.d.ts +1 -2
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.d.ts +9 -1
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js +20 -2
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.d.ts +5 -1
- package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.js +18 -2
- package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/taaObjectRendererBlock.d.ts +5 -1
- package/FrameGraph/Node/Blocks/Rendering/taaObjectRendererBlock.js +16 -2
- package/FrameGraph/Node/Blocks/Rendering/taaObjectRendererBlock.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +9 -6
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +27 -25
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +9 -6
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +25 -23
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.d.ts +3 -2
- package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js +8 -8
- package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js.map +1 -1
- package/FrameGraph/frameGraphRenderContext.d.ts +7 -3
- package/FrameGraph/frameGraphRenderContext.js +23 -4
- package/FrameGraph/frameGraphRenderContext.js.map +1 -1
- package/Gizmos/boundingBoxGizmo.d.ts +52 -10
- package/Gizmos/boundingBoxGizmo.js +17 -0
- package/Gizmos/boundingBoxGizmo.js.map +1 -1
- package/Gizmos/positionGizmo.js +1 -0
- package/Gizmos/positionGizmo.js.map +1 -1
- package/Gizmos/rotationGizmo.js +1 -0
- package/Gizmos/rotationGizmo.js.map +1 -1
- package/Materials/PBR/pbrSubSurfaceConfiguration.js +1 -0
- package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
- package/Materials/Textures/baseTexture.d.ts +4 -0
- package/Materials/Textures/baseTexture.js +3 -0
- package/Materials/Textures/baseTexture.js.map +1 -1
- package/Materials/Textures/multiRenderTarget.js +1 -1
- package/Materials/Textures/multiRenderTarget.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.d.ts +46 -42
- package/Materials/Textures/renderTargetTexture.js +249 -435
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Meshes/abstractMesh.hotSpot.d.ts +4 -2
- package/Meshes/abstractMesh.hotSpot.js +34 -7
- package/Meshes/abstractMesh.hotSpot.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.d.ts +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +3 -10
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
- package/Rendering/index.d.ts +1 -0
- package/Rendering/index.js +1 -0
- package/Rendering/index.js.map +1 -1
- package/Rendering/objectRenderer.d.ts +228 -0
- package/Rendering/objectRenderer.js +517 -0
- package/Rendering/objectRenderer.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockPrePass.js +2 -3
- package/ShadersWGSL/ShadersInclude/pbrBlockPrePass.js.map +1 -1
- package/XR/features/WebXRControllerTeleportation.js +6 -0
- package/XR/features/WebXRControllerTeleportation.js.map +1 -1
- package/XR/features/WebXRDepthSensing.js +1 -0
- package/XR/features/WebXRDepthSensing.js.map +1 -1
- package/XR/features/WebXRHandTracking.js +1 -0
- package/XR/features/WebXRHandTracking.js.map +1 -1
- package/XR/motionController/webXRAbstractMotionController.js +1 -0
- package/XR/motionController/webXRAbstractMotionController.js.map +1 -1
- package/XR/webXRCamera.js +1 -0
- package/XR/webXRCamera.js.map +1 -1
- package/XR/webXRManagedOutputCanvas.js +1 -0
- package/XR/webXRManagedOutputCanvas.js.map +1 -1
- package/XR/webXRSessionManager.js +1 -0
- package/XR/webXRSessionManager.js.map +1 -1
- package/package.json +1 -1
|
@@ -8,11 +8,15 @@ import { backbufferColorTextureHandle, backbufferDepthStencilTextureHandle } fro
|
|
|
8
8
|
* @experimental
|
|
9
9
|
*/
|
|
10
10
|
export class FrameGraphRenderContext extends FrameGraphContext {
|
|
11
|
+
static _IsObjectRenderer(value) {
|
|
12
|
+
return value.initRender !== undefined;
|
|
13
|
+
}
|
|
11
14
|
/** @internal */
|
|
12
|
-
constructor(_engine, _textureManager) {
|
|
15
|
+
constructor(_engine, _textureManager, _scene) {
|
|
13
16
|
super();
|
|
14
17
|
this._engine = _engine;
|
|
15
18
|
this._textureManager = _textureManager;
|
|
19
|
+
this._scene = _scene;
|
|
16
20
|
this._debugMessageHasBeenPushed = false;
|
|
17
21
|
this._renderTargetIsBound = true;
|
|
18
22
|
this._effectRenderer = new EffectRenderer(this._engine);
|
|
@@ -162,10 +166,25 @@ export class FrameGraphRenderContext extends FrameGraphContext {
|
|
|
162
166
|
/**
|
|
163
167
|
* Renders a RenderTargetTexture or a layer
|
|
164
168
|
* @param object The RenderTargetTexture/Layer to render
|
|
169
|
+
* @param viewportWidth The width of the viewport (optional for Layer, but mandatory for ObjectRenderer)
|
|
170
|
+
* @param viewportHeight The height of the viewport (optional for Layer, but mandatory for ObjectRenderer)
|
|
165
171
|
*/
|
|
166
|
-
render(object) {
|
|
167
|
-
|
|
168
|
-
|
|
172
|
+
render(object, viewportWidth, viewportHeight) {
|
|
173
|
+
if (FrameGraphRenderContext._IsObjectRenderer(object)) {
|
|
174
|
+
if (object.shouldRender()) {
|
|
175
|
+
this._scene?.incrementRenderId();
|
|
176
|
+
this._scene?.resetCachedMaterial();
|
|
177
|
+
object.prepareRenderList();
|
|
178
|
+
object.initRender(viewportWidth, viewportHeight);
|
|
179
|
+
this._applyRenderTarget();
|
|
180
|
+
object.render();
|
|
181
|
+
object.finishRender();
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
this._applyRenderTarget();
|
|
186
|
+
object.render();
|
|
187
|
+
}
|
|
169
188
|
}
|
|
170
189
|
/**
|
|
171
190
|
* Binds a render target texture so that upcoming draw calls will render to it
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frameGraphRenderContext.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraphRenderContext.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,4BAA4B,EAAE,mCAAmC,EAAE,MAAM,mB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E;YACjD,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC,IAAI,CAAC,4BAA4B,EAAE,CAAC,CAAC,CAAC;YACrE,IAAI,CAAC,4BAA4B,GAAG,SAAS,CAAC;YAC9C,IAAI,CAAC,0BAA0B,GAAG,IAAI,CAAC;SAC1C;QAED,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;IACrC,CAAC;IAED,gBAAgB;IACT,QAAQ;QACX,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;IAChC,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { Nullable, AbstractEngine, DrawWrapper, IColor4Like, Layer, FrameGraphTextureHandle, Effect, FrameGraphTextureManager, RenderTargetTexture } from \"core/index\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { EffectRenderer } from \"../Materials/effectRenderer\";\r\nimport { CopyTextureToTexture } from \"../Misc/copyTextureToTexture\";\r\nimport { FrameGraphContext } from \"./frameGraphContext\";\r\nimport { backbufferColorTextureHandle, backbufferDepthStencilTextureHandle } from \"./frameGraphTypes\";\r\n\r\n/**\r\n * Frame graph context used render passes.\r\n * @experimental\r\n */\r\nexport class FrameGraphRenderContext extends FrameGraphContext {\r\n private readonly _effectRenderer: EffectRenderer;\r\n private _currentRenderTargetHandle: FrameGraphTextureHandle;\r\n private _debugMessageWhenTargetBound: string | undefined;\r\n private _debugMessageHasBeenPushed = false;\r\n private _renderTargetIsBound = true;\r\n private readonly _copyTexture: CopyTextureToTexture;\r\n\r\n /** @internal */\r\n constructor(\r\n private readonly _engine: AbstractEngine,\r\n private readonly _textureManager: FrameGraphTextureManager\r\n ) {\r\n super();\r\n this._effectRenderer = new EffectRenderer(this._engine);\r\n this._copyTexture = new CopyTextureToTexture(this._engine);\r\n this._currentRenderTargetHandle = backbufferColorTextureHandle;\r\n }\r\n\r\n /**\r\n * Checks whether a texture handle points to the backbuffer's color or depth texture\r\n * @param handle The handle to check\r\n * @returns True if the handle points to the backbuffer's color or depth texture, otherwise false\r\n */\r\n public isBackbuffer(handle: FrameGraphTextureHandle): boolean {\r\n return this._textureManager.isBackbuffer(handle);\r\n }\r\n\r\n /**\r\n * Checks whether a texture handle points to the backbuffer's color texture\r\n * @param handle The handle to check\r\n * @returns True if the handle points to the backbuffer's color texture, otherwise false\r\n */\r\n public isBackbufferColor(handle: FrameGraphTextureHandle): boolean {\r\n return this._textureManager.isBackbufferColor(handle);\r\n }\r\n\r\n /**\r\n * Checks whether a texture handle points to the backbuffer's depth texture\r\n * @param handle The handle to check\r\n * @returns True if the handle points to the backbuffer's depth texture, otherwise false\r\n */\r\n public isBackbufferDepthStencil(handle: FrameGraphTextureHandle): boolean {\r\n return this._textureManager.isBackbufferDepthStencil(handle);\r\n }\r\n\r\n /**\r\n * Clears the current render buffer or the current render target (if any is set up)\r\n * @param color Defines the color to use\r\n * @param backBuffer Defines if the back buffer must be cleared\r\n * @param depth Defines if the depth buffer must be cleared\r\n * @param stencil Defines if the stencil buffer must be cleared\r\n */\r\n public clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void {\r\n this._applyRenderTarget();\r\n this._engine.clear(color, backBuffer, depth, stencil);\r\n }\r\n\r\n /**\r\n * Clears the color attachments of the current render target\r\n * @param color Defines the color to use\r\n * @param attachments The attachments to clear\r\n */\r\n public clearColorAttachments(color: Nullable<IColor4Like>, attachments: number[]): void {\r\n this._applyRenderTarget();\r\n this._engine.bindAttachments(attachments);\r\n this._engine.clear(color, true, false, false);\r\n }\r\n\r\n /**\r\n * Binds the attachments to the current render target\r\n * @param attachments The attachments to bind\r\n */\r\n public bindAttachments(attachments: number[]): void {\r\n this._applyRenderTarget();\r\n this._engine.bindAttachments(attachments);\r\n }\r\n\r\n /**\r\n * Generates mipmaps for the current render target\r\n */\r\n public generateMipMaps(): void {\r\n const texture = this._textureManager.getTextureFromHandle(this._currentRenderTargetHandle);\r\n if (!texture) {\r\n // Texture is backbuffer, no need to generate mipmaps\r\n return;\r\n }\r\n if (this._renderTargetIsBound) {\r\n // we can't generate the mipmaps if the texture is bound as a render target\r\n this._flushDebugMessages();\r\n this._engine.unBindFramebuffer(texture);\r\n this._renderTargetIsBound = false;\r\n }\r\n this._engine.generateMipmaps(texture.texture!);\r\n }\r\n\r\n /**\r\n * Sets the texture sampling mode for a given texture handle\r\n * @param handle Handle of the texture to set the sampling mode for\r\n * @param samplingMode Sampling mode to set\r\n */\r\n public setTextureSamplingMode(handle: FrameGraphTextureHandle, samplingMode: number): void {\r\n const internalTexture = this._textureManager.getTextureFromHandle(handle)?.texture!;\r\n if (internalTexture && internalTexture.samplingMode !== samplingMode) {\r\n this._engine.updateTextureSamplingMode(samplingMode, internalTexture);\r\n }\r\n }\r\n\r\n /**\r\n * Binds a texture handle to a given effect (resolves the handle to a texture and binds it to the effect)\r\n * @param effect The effect to bind the texture to\r\n * @param name The name of the texture in the effect\r\n * @param handle The handle of the texture to bind\r\n */\r\n public bindTextureHandle(effect: Effect, name: string, handle: FrameGraphTextureHandle): void {\r\n const texture = this._textureManager.getTextureFromHandle(handle);\r\n if (texture) {\r\n effect._bindTexture(name, texture.texture!);\r\n }\r\n }\r\n\r\n /**\r\n * Sets the depth states for the current render target\r\n * @param depthTest If true, depth testing is enabled\r\n * @param depthWrite If true, depth writing is enabled\r\n */\r\n public setDepthStates(depthTest: boolean, depthWrite: boolean): void {\r\n this._engine.setDepthBuffer(depthTest);\r\n this._engine.setDepthWrite(depthWrite);\r\n }\r\n\r\n /**\r\n * Applies a full-screen effect to the current render target\r\n * @param drawWrapper The draw wrapper containing the effect to apply\r\n * @param customBindings The custom bindings to use when applying the effect (optional)\r\n * @returns True if the effect was applied, otherwise false (effect not ready)\r\n */\r\n public applyFullScreenEffect(drawWrapper: DrawWrapper, customBindings?: () => void): boolean {\r\n if (!drawWrapper.effect?.isReady()) {\r\n return false;\r\n }\r\n\r\n this._applyRenderTarget();\r\n\r\n const engineDepthMask = this._engine.getDepthWrite(); // for some reasons, depthWrite is not restored by EffectRenderer.restoreStates\r\n\r\n this._effectRenderer.saveStates();\r\n this._effectRenderer.setViewport();\r\n\r\n this._engine.enableEffect(drawWrapper);\r\n this._engine.setState(false);\r\n this._engine.setDepthBuffer(false);\r\n this._engine.setDepthWrite(false);\r\n\r\n this._effectRenderer.bindBuffers(drawWrapper.effect);\r\n customBindings?.();\r\n this._effectRenderer.draw();\r\n this._effectRenderer.restoreStates();\r\n this._engine.setDepthWrite(engineDepthMask);\r\n this._engine.setAlphaMode(Constants.ALPHA_DISABLE);\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Copies a texture to the current render target\r\n * @param sourceTexture The source texture to copy from\r\n * @param forceCopyToBackbuffer If true, the copy will be done to the back buffer regardless of the current render target\r\n */\r\n public copyTexture(sourceTexture: FrameGraphTextureHandle, forceCopyToBackbuffer = false): void {\r\n if (forceCopyToBackbuffer) {\r\n this.bindRenderTarget();\r\n }\r\n this._applyRenderTarget();\r\n this._copyTexture.copy(this._textureManager.getTextureFromHandle(sourceTexture)!.texture!);\r\n }\r\n\r\n /**\r\n * Renders a RenderTargetTexture or a layer\r\n * @param object The RenderTargetTexture/Layer to render\r\n */\r\n public render(object: Layer | RenderTargetTexture): void {\r\n this._applyRenderTarget();\r\n object.render();\r\n }\r\n\r\n /**\r\n * Binds a render target texture so that upcoming draw calls will render to it\r\n * Note: it is a lazy operation, so the render target will only be bound when needed. This way, it is possible to call\r\n * this method several times with different render targets without incurring the cost of binding if no draw calls are made\r\n * @param renderTargetHandle The handle of the render target texture to bind (default: backbufferColorTextureHandle)\r\n * @param debugMessage Optional debug message to display when the render target is bound (visible in PIX, for example)\r\n */\r\n public bindRenderTarget(renderTargetHandle: FrameGraphTextureHandle = backbufferColorTextureHandle, debugMessage?: string) {\r\n if (renderTargetHandle === this._currentRenderTargetHandle) {\r\n this._flushDebugMessages();\r\n if (debugMessage !== undefined) {\r\n this._engine._debugPushGroup?.(debugMessage, 2);\r\n this._debugMessageWhenTargetBound = undefined;\r\n this._debugMessageHasBeenPushed = true;\r\n }\r\n return;\r\n }\r\n this._currentRenderTargetHandle = renderTargetHandle;\r\n this._debugMessageWhenTargetBound = debugMessage;\r\n this._renderTargetIsBound = false;\r\n }\r\n\r\n /** @internal */\r\n public _flushDebugMessages() {\r\n if (this._debugMessageHasBeenPushed) {\r\n this._engine._debugPopGroup?.(2);\r\n this._debugMessageHasBeenPushed = false;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _shareDepth(srcRenderTargetHandle: FrameGraphTextureHandle, dstRenderTargetHandle: FrameGraphTextureHandle) {\r\n const srcTexture = this._textureManager.getTextureFromHandle(srcRenderTargetHandle);\r\n const dstTexture = this._textureManager.getTextureFromHandle(dstRenderTargetHandle);\r\n\r\n if (srcTexture && dstTexture) {\r\n srcTexture.shareDepth(dstTexture);\r\n }\r\n }\r\n\r\n private _applyRenderTarget() {\r\n if (this._renderTargetIsBound) {\r\n return;\r\n }\r\n\r\n const handle = this._currentRenderTargetHandle;\r\n const textureSlot = this._textureManager._textures.get(handle)!;\r\n\r\n let renderTarget = textureSlot.texture;\r\n\r\n if (textureSlot.creationOptions.isHistoryTexture) {\r\n const historyEntry = this._textureManager._historyTextures.get(textureSlot.refHandle ?? handle)!;\r\n renderTarget = historyEntry.textures[historyEntry.index];\r\n }\r\n\r\n this._flushDebugMessages();\r\n\r\n if (!renderTarget) {\r\n if (handle === backbufferColorTextureHandle || textureSlot.refHandle === backbufferColorTextureHandle) {\r\n this._engine.restoreDefaultFramebuffer();\r\n } else if (handle === backbufferDepthStencilTextureHandle || textureSlot.refHandle === backbufferDepthStencilTextureHandle) {\r\n this._engine.restoreDefaultFramebuffer();\r\n }\r\n } else {\r\n this._engine.bindFramebuffer(renderTarget);\r\n }\r\n\r\n if (this._debugMessageWhenTargetBound !== undefined) {\r\n this._engine._debugPushGroup?.(this._debugMessageWhenTargetBound, 2);\r\n this._debugMessageWhenTargetBound = undefined;\r\n this._debugMessageHasBeenPushed = true;\r\n }\r\n\r\n this._renderTargetIsBound = true;\r\n }\r\n\r\n /** @internal */\r\n public _dispose() {\r\n this._effectRenderer.dispose();\r\n this._copyTexture.dispose();\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"frameGraphRenderContext.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraphRenderContext.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,4BAA4B,EAAE,mCAAmC,EAAE,MAAM,mBAAmB,CAAC;AAEtG;;;GAGG;AACH,MAAM,OAAO,uBAAwB,SAAQ,iBAAiB;IAQlD,MAAM,CAAC,iBAAiB,CAAC,KAA6B;QAC1D,OAAQ,KAAwB,CAAC,UAAU,KAAK,SAAS,CAAC;IAC9D,CAAC;IAED,gBAAgB;IAChB,YACqB,OAAuB,EACvB,eAAyC,EACzC,MAAc;QAE/B,KAAK,EAAE,CAAC;QAJS,YAAO,GAAP,OAAO,CAAgB;QACvB,oBAAe,GAAf,eAAe,CAA0B;QACzC,WAAM,GAAN,MAAM,CAAQ;QAZ3B,+BAA0B,GAAG,KAAK,CAAC;QACnC,yBAAoB,GAAG,IAAI,CAAC;QAchC,IAAI,CAAC,eAAe,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACxD,IAAI,CAAC,YAAY,GAAG,IAAI,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC3D,IAAI,CAAC,0BAA0B,GAAG,4BAA4B,CAAC;IACnE,CAAC;IAED;;;;OAIG;IACI,YAAY,CAAC,MAA+B;QAC/C,OAAO,IA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EAAE,CAAC,CAAC,CAAC;YACrE,IAAI,CAAC,4BAA4B,GAAG,SAAS,CAAC;YAC9C,IAAI,CAAC,0BAA0B,GAAG,IAAI,CAAC;SAC1C;QAED,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;IACrC,CAAC;IAED,gBAAgB;IACT,QAAQ;QACX,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;IAChC,CAAC;CACJ","sourcesContent":["import type {\r\n Nullable,\r\n AbstractEngine,\r\n DrawWrapper,\r\n IColor4Like,\r\n Layer,\r\n FrameGraphTextureHandle,\r\n Effect,\r\n FrameGraphTextureManager,\r\n ObjectRenderer,\r\n Scene,\r\n // eslint-disable-next-line import/no-internal-modules\r\n} from \"core/index\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { EffectRenderer } from \"../Materials/effectRenderer\";\r\nimport { CopyTextureToTexture } from \"../Misc/copyTextureToTexture\";\r\nimport { FrameGraphContext } from \"./frameGraphContext\";\r\nimport { backbufferColorTextureHandle, backbufferDepthStencilTextureHandle } from \"./frameGraphTypes\";\r\n\r\n/**\r\n * Frame graph context used render passes.\r\n * @experimental\r\n */\r\nexport class FrameGraphRenderContext extends FrameGraphContext {\r\n private readonly _effectRenderer: EffectRenderer;\r\n private _currentRenderTargetHandle: FrameGraphTextureHandle;\r\n private _debugMessageWhenTargetBound: string | undefined;\r\n private _debugMessageHasBeenPushed = false;\r\n private _renderTargetIsBound = true;\r\n private readonly _copyTexture: CopyTextureToTexture;\r\n\r\n private static _IsObjectRenderer(value: Layer | ObjectRenderer): value is ObjectRenderer {\r\n return (value as ObjectRenderer).initRender !== undefined;\r\n }\r\n\r\n /** @internal */\r\n constructor(\r\n private readonly _engine: AbstractEngine,\r\n private readonly _textureManager: FrameGraphTextureManager,\r\n private readonly _scene?: Scene\r\n ) {\r\n super();\r\n this._effectRenderer = new EffectRenderer(this._engine);\r\n this._copyTexture = new CopyTextureToTexture(this._engine);\r\n this._currentRenderTargetHandle = backbufferColorTextureHandle;\r\n }\r\n\r\n /**\r\n * Checks whether a texture handle points to the backbuffer's color or depth texture\r\n * @param handle The handle to check\r\n * @returns True if the handle points to the backbuffer's color or depth texture, otherwise false\r\n */\r\n public isBackbuffer(handle: FrameGraphTextureHandle): boolean {\r\n return this._textureManager.isBackbuffer(handle);\r\n }\r\n\r\n /**\r\n * Checks whether a texture handle points to the backbuffer's color texture\r\n * @param handle The handle to check\r\n * @returns True if the handle points to the backbuffer's color texture, otherwise false\r\n */\r\n public isBackbufferColor(handle: FrameGraphTextureHandle): boolean {\r\n return this._textureManager.isBackbufferColor(handle);\r\n }\r\n\r\n /**\r\n * Checks whether a texture handle points to the backbuffer's depth texture\r\n * @param handle The handle to check\r\n * @returns True if the handle points to the backbuffer's depth texture, otherwise false\r\n */\r\n public isBackbufferDepthStencil(handle: FrameGraphTextureHandle): boolean {\r\n return this._textureManager.isBackbufferDepthStencil(handle);\r\n }\r\n\r\n /**\r\n * Clears the current render buffer or the current render target (if any is set up)\r\n * @param color Defines the color to use\r\n * @param backBuffer Defines if the back buffer must be cleared\r\n * @param depth Defines if the depth buffer must be cleared\r\n * @param stencil Defines if the stencil buffer must be cleared\r\n */\r\n public clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void {\r\n this._applyRenderTarget();\r\n this._engine.clear(color, backBuffer, depth, stencil);\r\n }\r\n\r\n /**\r\n * Clears the color attachments of the current render target\r\n * @param color Defines the color to use\r\n * @param attachments The attachments to clear\r\n */\r\n public clearColorAttachments(color: Nullable<IColor4Like>, attachments: number[]): void {\r\n this._applyRenderTarget();\r\n this._engine.bindAttachments(attachments);\r\n this._engine.clear(color, true, false, false);\r\n }\r\n\r\n /**\r\n * Binds the attachments to the current render target\r\n * @param attachments The attachments to bind\r\n */\r\n public bindAttachments(attachments: number[]): void {\r\n this._applyRenderTarget();\r\n this._engine.bindAttachments(attachments);\r\n }\r\n\r\n /**\r\n * Generates mipmaps for the current render target\r\n */\r\n public generateMipMaps(): void {\r\n const texture = this._textureManager.getTextureFromHandle(this._currentRenderTargetHandle);\r\n if (!texture) {\r\n // Texture is backbuffer, no need to generate mipmaps\r\n return;\r\n }\r\n if (this._renderTargetIsBound) {\r\n // we can't generate the mipmaps if the texture is bound as a render target\r\n this._flushDebugMessages();\r\n this._engine.unBindFramebuffer(texture);\r\n this._renderTargetIsBound = false;\r\n }\r\n this._engine.generateMipmaps(texture.texture!);\r\n }\r\n\r\n /**\r\n * Sets the texture sampling mode for a given texture handle\r\n * @param handle Handle of the texture to set the sampling mode for\r\n * @param samplingMode Sampling mode to set\r\n */\r\n public setTextureSamplingMode(handle: FrameGraphTextureHandle, samplingMode: number): void {\r\n const internalTexture = this._textureManager.getTextureFromHandle(handle)?.texture!;\r\n if (internalTexture && internalTexture.samplingMode !== samplingMode) {\r\n this._engine.updateTextureSamplingMode(samplingMode, internalTexture);\r\n }\r\n }\r\n\r\n /**\r\n * Binds a texture handle to a given effect (resolves the handle to a texture and binds it to the effect)\r\n * @param effect The effect to bind the texture to\r\n * @param name The name of the texture in the effect\r\n * @param handle The handle of the texture to bind\r\n */\r\n public bindTextureHandle(effect: Effect, name: string, handle: FrameGraphTextureHandle): void {\r\n const texture = this._textureManager.getTextureFromHandle(handle);\r\n if (texture) {\r\n effect._bindTexture(name, texture.texture!);\r\n }\r\n }\r\n\r\n /**\r\n * Sets the depth states for the current render target\r\n * @param depthTest If true, depth testing is enabled\r\n * @param depthWrite If true, depth writing is enabled\r\n */\r\n public setDepthStates(depthTest: boolean, depthWrite: boolean): void {\r\n this._engine.setDepthBuffer(depthTest);\r\n this._engine.setDepthWrite(depthWrite);\r\n }\r\n\r\n /**\r\n * Applies a full-screen effect to the current render target\r\n * @param drawWrapper The draw wrapper containing the effect to apply\r\n * @param customBindings The custom bindings to use when applying the effect (optional)\r\n * @returns True if the effect was applied, otherwise false (effect not ready)\r\n */\r\n public applyFullScreenEffect(drawWrapper: DrawWrapper, customBindings?: () => void): boolean {\r\n if (!drawWrapper.effect?.isReady()) {\r\n return false;\r\n }\r\n\r\n this._applyRenderTarget();\r\n\r\n const engineDepthMask = this._engine.getDepthWrite(); // for some reasons, depthWrite is not restored by EffectRenderer.restoreStates\r\n\r\n this._effectRenderer.saveStates();\r\n this._effectRenderer.setViewport();\r\n\r\n this._engine.enableEffect(drawWrapper);\r\n this._engine.setState(false);\r\n this._engine.setDepthBuffer(false);\r\n this._engine.setDepthWrite(false);\r\n\r\n this._effectRenderer.bindBuffers(drawWrapper.effect);\r\n customBindings?.();\r\n this._effectRenderer.draw();\r\n this._effectRenderer.restoreStates();\r\n this._engine.setDepthWrite(engineDepthMask);\r\n this._engine.setAlphaMode(Constants.ALPHA_DISABLE);\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Copies a texture to the current render target\r\n * @param sourceTexture The source texture to copy from\r\n * @param forceCopyToBackbuffer If true, the copy will be done to the back buffer regardless of the current render target\r\n */\r\n public copyTexture(sourceTexture: FrameGraphTextureHandle, forceCopyToBackbuffer = false): void {\r\n if (forceCopyToBackbuffer) {\r\n this.bindRenderTarget();\r\n }\r\n this._applyRenderTarget();\r\n this._copyTexture.copy(this._textureManager.getTextureFromHandle(sourceTexture)!.texture!);\r\n }\r\n\r\n /**\r\n * Renders a RenderTargetTexture or a layer\r\n * @param object The RenderTargetTexture/Layer to render\r\n * @param viewportWidth The width of the viewport (optional for Layer, but mandatory for ObjectRenderer)\r\n * @param viewportHeight The height of the viewport (optional for Layer, but mandatory for ObjectRenderer)\r\n */\r\n public render(object: Layer | ObjectRenderer, viewportWidth?: number, viewportHeight?: number): void {\r\n if (FrameGraphRenderContext._IsObjectRenderer(object)) {\r\n if (object.shouldRender()) {\r\n this._scene?.incrementRenderId();\r\n this._scene?.resetCachedMaterial();\r\n\r\n object.prepareRenderList();\r\n object.initRender(viewportWidth!, viewportHeight!);\r\n\r\n this._applyRenderTarget();\r\n object.render();\r\n\r\n object.finishRender();\r\n }\r\n } else {\r\n this._applyRenderTarget();\r\n object.render();\r\n }\r\n }\r\n\r\n /**\r\n * Binds a render target texture so that upcoming draw calls will render to it\r\n * Note: it is a lazy operation, so the render target will only be bound when needed. This way, it is possible to call\r\n * this method several times with different render targets without incurring the cost of binding if no draw calls are made\r\n * @param renderTargetHandle The handle of the render target texture to bind (default: backbufferColorTextureHandle)\r\n * @param debugMessage Optional debug message to display when the render target is bound (visible in PIX, for example)\r\n */\r\n public bindRenderTarget(renderTargetHandle: FrameGraphTextureHandle = backbufferColorTextureHandle, debugMessage?: string) {\r\n if (renderTargetHandle === this._currentRenderTargetHandle) {\r\n this._flushDebugMessages();\r\n if (debugMessage !== undefined) {\r\n this._engine._debugPushGroup?.(debugMessage, 2);\r\n this._debugMessageWhenTargetBound = undefined;\r\n this._debugMessageHasBeenPushed = true;\r\n }\r\n return;\r\n }\r\n this._currentRenderTargetHandle = renderTargetHandle;\r\n this._debugMessageWhenTargetBound = debugMessage;\r\n this._renderTargetIsBound = false;\r\n }\r\n\r\n /** @internal */\r\n public _flushDebugMessages() {\r\n if (this._debugMessageHasBeenPushed) {\r\n this._engine._debugPopGroup?.(2);\r\n this._debugMessageHasBeenPushed = false;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _shareDepth(srcRenderTargetHandle: FrameGraphTextureHandle, dstRenderTargetHandle: FrameGraphTextureHandle) {\r\n const srcTexture = this._textureManager.getTextureFromHandle(srcRenderTargetHandle);\r\n const dstTexture = this._textureManager.getTextureFromHandle(dstRenderTargetHandle);\r\n\r\n if (srcTexture && dstTexture) {\r\n srcTexture.shareDepth(dstTexture);\r\n }\r\n }\r\n\r\n private _applyRenderTarget() {\r\n if (this._renderTargetIsBound) {\r\n return;\r\n }\r\n\r\n const handle = this._currentRenderTargetHandle;\r\n const textureSlot = this._textureManager._textures.get(handle)!;\r\n\r\n let renderTarget = textureSlot.texture;\r\n\r\n if (textureSlot.creationOptions.isHistoryTexture) {\r\n const historyEntry = this._textureManager._historyTextures.get(textureSlot.refHandle ?? handle)!;\r\n renderTarget = historyEntry.textures[historyEntry.index];\r\n }\r\n\r\n this._flushDebugMessages();\r\n\r\n if (!renderTarget) {\r\n if (handle === backbufferColorTextureHandle || textureSlot.refHandle === backbufferColorTextureHandle) {\r\n this._engine.restoreDefaultFramebuffer();\r\n } else if (handle === backbufferDepthStencilTextureHandle || textureSlot.refHandle === backbufferDepthStencilTextureHandle) {\r\n this._engine.restoreDefaultFramebuffer();\r\n }\r\n } else {\r\n this._engine.bindFramebuffer(renderTarget);\r\n }\r\n\r\n if (this._debugMessageWhenTargetBound !== undefined) {\r\n this._engine._debugPushGroup?.(this._debugMessageWhenTargetBound, 2);\r\n this._debugMessageWhenTargetBound = undefined;\r\n this._debugMessageHasBeenPushed = true;\r\n }\r\n\r\n this._renderTargetIsBound = true;\r\n }\r\n\r\n /** @internal */\r\n public _dispose() {\r\n this._effectRenderer.dispose();\r\n this._copyTexture.dispose();\r\n }\r\n}\r\n"]}
|
|
@@ -46,15 +46,34 @@ export interface IBoundingBoxGizmo extends IGizmo {
|
|
|
46
46
|
/** True when a rotation anchor or scale box or a attached mesh is dragged */
|
|
47
47
|
readonly isDragging: boolean;
|
|
48
48
|
/** Fired when a rotation anchor or scale box is dragged */
|
|
49
|
-
onDragStartObservable: Observable<{
|
|
49
|
+
onDragStartObservable: Observable<{
|
|
50
|
+
dragOperation: DragOperation;
|
|
51
|
+
dragAxis: Vector3;
|
|
52
|
+
}>;
|
|
53
|
+
/** Fired when the gizmo mesh hovering starts*/
|
|
54
|
+
onHoverStartObservable: Observable<void>;
|
|
55
|
+
/** Fired when the gizmo mesh hovering ends*/
|
|
56
|
+
onHoverEndObservable: Observable<void>;
|
|
50
57
|
/** Fired when a scale box is dragged */
|
|
51
|
-
onScaleBoxDragObservable: Observable<{
|
|
58
|
+
onScaleBoxDragObservable: Observable<{
|
|
59
|
+
dragOperation: DragOperation;
|
|
60
|
+
dragAxis: Vector3;
|
|
61
|
+
}>;
|
|
52
62
|
/** Fired when a scale box drag is ended */
|
|
53
|
-
onScaleBoxDragEndObservable: Observable<{
|
|
63
|
+
onScaleBoxDragEndObservable: Observable<{
|
|
64
|
+
dragOperation: DragOperation;
|
|
65
|
+
dragAxis: Vector3;
|
|
66
|
+
}>;
|
|
54
67
|
/** Fired when a rotation anchor is dragged */
|
|
55
|
-
onRotationSphereDragObservable: Observable<{
|
|
68
|
+
onRotationSphereDragObservable: Observable<{
|
|
69
|
+
dragOperation: DragOperation;
|
|
70
|
+
dragAxis: Vector3;
|
|
71
|
+
}>;
|
|
56
72
|
/** Fired when a rotation anchor drag is ended */
|
|
57
|
-
onRotationSphereDragEndObservable: Observable<{
|
|
73
|
+
onRotationSphereDragEndObservable: Observable<{
|
|
74
|
+
dragOperation: DragOperation;
|
|
75
|
+
dragAxis: Vector3;
|
|
76
|
+
}>;
|
|
58
77
|
/** Relative bounding box pivot used when scaling the attached node. */
|
|
59
78
|
scalePivot: Nullable<Vector3>;
|
|
60
79
|
/** Scale factor vector used for masking some axis */
|
|
@@ -166,23 +185,46 @@ export declare class BoundingBoxGizmo extends Gizmo implements IBoundingBoxGizmo
|
|
|
166
185
|
/**
|
|
167
186
|
* Fired when a rotation anchor or scale box is dragged
|
|
168
187
|
*/
|
|
169
|
-
onDragStartObservable: Observable<{
|
|
188
|
+
onDragStartObservable: Observable<{
|
|
189
|
+
dragOperation: DragOperation;
|
|
190
|
+
dragAxis: Vector3;
|
|
191
|
+
}>;
|
|
192
|
+
/**
|
|
193
|
+
* Fired when the gizmo mesh hovering starts
|
|
194
|
+
*/
|
|
195
|
+
onHoverStartObservable: Observable<void>;
|
|
196
|
+
/**
|
|
197
|
+
* Fired when the gizmo mesh hovering ends
|
|
198
|
+
*/
|
|
199
|
+
onHoverEndObservable: Observable<void>;
|
|
170
200
|
/**
|
|
171
201
|
* Fired when a scale box is dragged
|
|
172
202
|
*/
|
|
173
|
-
onScaleBoxDragObservable: Observable<{
|
|
203
|
+
onScaleBoxDragObservable: Observable<{
|
|
204
|
+
dragOperation: DragOperation;
|
|
205
|
+
dragAxis: Vector3;
|
|
206
|
+
}>;
|
|
174
207
|
/**
|
|
175
208
|
* Fired when a scale box drag is ended
|
|
176
209
|
*/
|
|
177
|
-
onScaleBoxDragEndObservable: Observable<{
|
|
210
|
+
onScaleBoxDragEndObservable: Observable<{
|
|
211
|
+
dragOperation: DragOperation;
|
|
212
|
+
dragAxis: Vector3;
|
|
213
|
+
}>;
|
|
178
214
|
/**
|
|
179
215
|
* Fired when a rotation anchor is dragged
|
|
180
216
|
*/
|
|
181
|
-
onRotationSphereDragObservable: Observable<{
|
|
217
|
+
onRotationSphereDragObservable: Observable<{
|
|
218
|
+
dragOperation: DragOperation;
|
|
219
|
+
dragAxis: Vector3;
|
|
220
|
+
}>;
|
|
182
221
|
/**
|
|
183
222
|
* Fired when a rotation anchor drag is ended
|
|
184
223
|
*/
|
|
185
|
-
onRotationSphereDragEndObservable: Observable<{
|
|
224
|
+
onRotationSphereDragEndObservable: Observable<{
|
|
225
|
+
dragOperation: DragOperation;
|
|
226
|
+
dragAxis: Vector3;
|
|
227
|
+
}>;
|
|
186
228
|
/**
|
|
187
229
|
* Relative bounding box pivot used when scaling the attached node. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)
|
|
188
230
|
*/
|
|
@@ -166,6 +166,14 @@ export class BoundingBoxGizmo extends Gizmo {
|
|
|
166
166
|
* Fired when a rotation anchor or scale box is dragged
|
|
167
167
|
*/
|
|
168
168
|
this.onDragStartObservable = new Observable();
|
|
169
|
+
/**
|
|
170
|
+
* Fired when the gizmo mesh hovering starts
|
|
171
|
+
*/
|
|
172
|
+
this.onHoverStartObservable = new Observable();
|
|
173
|
+
/**
|
|
174
|
+
* Fired when the gizmo mesh hovering ends
|
|
175
|
+
*/
|
|
176
|
+
this.onHoverEndObservable = new Observable();
|
|
169
177
|
/**
|
|
170
178
|
* Fired when a scale box is dragged
|
|
171
179
|
*/
|
|
@@ -493,6 +501,7 @@ export class BoundingBoxGizmo extends Gizmo {
|
|
|
493
501
|
if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh == mesh) {
|
|
494
502
|
pointerIds[pointerInfo.event.pointerId] = mesh;
|
|
495
503
|
mesh.material = this._hoverColoredMaterial;
|
|
504
|
+
this.onHoverStartObservable.notifyObservers();
|
|
496
505
|
this._isHovered = true;
|
|
497
506
|
}
|
|
498
507
|
});
|
|
@@ -501,6 +510,7 @@ export class BoundingBoxGizmo extends Gizmo {
|
|
|
501
510
|
if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh != pointerIds[pointerInfo.event.pointerId]) {
|
|
502
511
|
pointerIds[pointerInfo.event.pointerId].material = this._coloredMaterial;
|
|
503
512
|
delete pointerIds[pointerInfo.event.pointerId];
|
|
513
|
+
this.onHoverEndObservable.notifyObservers();
|
|
504
514
|
this._isHovered = false;
|
|
505
515
|
}
|
|
506
516
|
}
|
|
@@ -769,6 +779,13 @@ export class BoundingBoxGizmo extends Gizmo {
|
|
|
769
779
|
}
|
|
770
780
|
this._scaleBoxesDragBehaviors.length = 0;
|
|
771
781
|
this._rotateAnchorsDragBehaviors.length = 0;
|
|
782
|
+
this.onDragStartObservable.clear();
|
|
783
|
+
this.onHoverStartObservable.clear();
|
|
784
|
+
this.onHoverEndObservable.clear();
|
|
785
|
+
this.onScaleBoxDragObservable.clear();
|
|
786
|
+
this.onScaleBoxDragEndObservable.clear();
|
|
787
|
+
this.onRotationSphereDragObservable.clear();
|
|
788
|
+
this.onRotationSphereDragEndObservable.clear();
|
|
772
789
|
super.dispose();
|
|
773
790
|
}
|
|
774
791
|
/**
|