d7fb05d4d1585c1f1e23a2096255f266cf7535ddc3302701065d331159e61530.json 16 KB

1
  1. {"ast":null,"code":"import { backbufferColorTextureHandle, backbufferDepthStencilTextureHandle } from \"../../frameGraphTypes.js\";\nimport { FrameGraphTask } from \"../../frameGraphTask.js\";\nimport { ObjectRenderer } from \"../../../Rendering/objectRenderer.js\";\n/**\n * Task used to render objects to a texture.\n */\nexport class FrameGraphObjectRendererTask extends FrameGraphTask {\n /**\n * Gets or sets the camera used to render the objects.\n */\n get camera() {\n return this._camera;\n }\n set camera(camera) {\n this._camera = camera;\n this._renderer.activeCamera = this.camera;\n }\n /**\n * The object renderer used to render the objects.\n */\n get objectRenderer() {\n return this._renderer;\n }\n get name() {\n return this._name;\n }\n set name(value) {\n this._name = value;\n if (this._renderer) {\n this._renderer.name = value;\n }\n }\n /**\n * Constructs a new object renderer task.\n * @param name The name of the task.\n * @param frameGraph The frame graph the task belongs to.\n * @param scene The scene the frame graph is associated with.\n * @param options The options of the object renderer.\n */\n constructor(name, frameGraph, scene, options) {\n super(name, frameGraph);\n /**\n * The dependencies of the task (optional).\n */\n this.dependencies = [];\n /**\n * If depth testing should be enabled (default is true).\n */\n this.depthTest = true;\n /**\n * If depth writing should be enabled (default is true).\n */\n this.depthWrite = true;\n this._scene = scene;\n this._renderer = new ObjectRenderer(name, scene, options);\n this.name = name;\n this._renderer.onBeforeRenderingManagerRenderObservable.add(() => {\n if (!this._renderer.options.doNotChangeAspectRatio) {\n scene.updateTransformMatrix(true);\n }\n });\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\n this.outputDepthTexture = this._frameGraph.textureManager.createDanglingHandle();\n }\n isReady() {\n return this._renderer.isReadyForRendering(this._textureWidth, this._textureHeight);\n }\n record(skipCreationOfDisabledPasses = false, additionalExecute) {\n if (this.destinationTexture === undefined || this.objectList === undefined) {\n throw new Error(`FrameGraphObjectRendererTask ${this.name}: destinationTexture and objectList are required`);\n }\n const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.destinationTexture);\n let depthEnabled = false;\n if (this.depthTexture !== undefined) {\n if (this.depthTexture === backbufferDepthStencilTextureHandle && this.destinationTexture !== backbufferColorTextureHandle) {\n throw new Error(`FrameGraphObjectRendererTask ${this.name}: the back buffer color texture is the only color texture allowed when the depth is the back buffer depth/stencil`);\n }\n if (this.depthTexture !== backbufferDepthStencilTextureHandle && this.destinationTexture === backbufferColorTextureHandle) {\n throw new Error(`FrameGraphObjectRendererTask ${this.name}: the back buffer depth/stencil texture is the only depth texture allowed when the destination is the back buffer color`);\n }\n const depthTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.depthTexture);\n if (depthTextureDescription.options.samples !== outputTextureDescription.options.samples) {\n throw new Error(`FrameGraphObjectRendererTask ${this.name}: the depth texture and the output texture must have the same number of samples`);\n }\n depthEnabled = true;\n }\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture);\n if (this.depthTexture !== undefined) {\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\n }\n this._textureWidth = outputTextureDescription.size.width;\n this._textureHeight = outputTextureDescription.size.height;\n const pass = this._frameGraph.addRenderPass(this.name);\n pass.setRenderTarget(this.destinationTexture);\n pass.setRenderTargetDepth(this.depthTexture);\n pass.setExecuteFunc(context => {\n this._renderer.renderList = this.objectList.meshes;\n this._renderer.particleSystemList = this.objectList.particleSystems;\n context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);\n context.render(this._renderer, this._textureWidth, this._textureHeight);\n additionalExecute === null || additionalExecute === void 0 || additionalExecute(context);\n });\n if (this.dependencies !== undefined) {\n for (const handle of this.dependencies) {\n pass.useTexture(handle);\n }\n }\n if (!skipCreationOfDisabledPasses) {\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\n passDisabled.setRenderTarget(this.destinationTexture);\n passDisabled.setRenderTargetDepth(this.depthTexture);\n passDisabled.setExecuteFunc(_context => {});\n if (this.dependencies !== undefined) {\n for (const handle of this.dependencies) {\n passDisabled.useTexture(handle);\n }\n }\n }\n }\n dispose() {\n this._renderer.dispose();\n super.dispose();\n }\n}","map":{"version":3,"names":["backbufferColorTextureHandle","backbufferDepthStencilTextureHandle","FrameGraphTask","ObjectRenderer","FrameGraphObjectRendererTask","camera","_camera","_renderer","activeCamera","objectRenderer","name","_name","value","constructor","frameGraph","scene","options","dependencies","depthTest","depthWrite","_scene","onBeforeRenderingManagerRenderObservable","add","doNotChangeAspectRatio","updateTransformMatrix","outputTexture","_frameGraph","textureManager","createDanglingHandle","outputDepthTexture","isReady","isReadyForRendering","_textureWidth","_textureHeight","record","skipCreationOfDisabledPasses","additionalExecute","destinationTexture","undefined","objectList","Error","outputTextureDescription","getTextureDescription","depthEnabled","depthTexture","depthTextureDescription","samples","resolveDanglingHandle","size","width","height","pass","addRenderPass","setRenderTarget","setRenderTargetDepth","setExecuteFunc","context","renderList","meshes","particleSystemList","particleSystems","setDepthStates","render","handle","useTexture","passDisabled","_context","dispose"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/FrameGraph/Tasks/Rendering/objectRendererTask.js"],"sourcesContent":["import { backbufferColorTextureHandle, backbufferDepthStencilTextureHandle } from \"../../frameGraphTypes.js\";\nimport { FrameGraphTask } from \"../../frameGraphTask.js\";\nimport { ObjectRenderer } from \"../../../Rendering/objectRenderer.js\";\n/**\n * Task used to render objects to a texture.\n */\nexport class FrameGraphObjectRendererTask extends FrameGraphTask {\n /**\n * Gets or sets the camera used to render the objects.\n */\n get camera() {\n return this._camera;\n }\n set camera(camera) {\n this._camera = camera;\n this._renderer.activeCamera = this.camera;\n }\n /**\n * The object renderer used to render the objects.\n */\n get objectRenderer() {\n return this._renderer;\n }\n get name() {\n return this._name;\n }\n set name(value) {\n this._name = value;\n if (this._renderer) {\n this._renderer.name = value;\n }\n }\n /**\n * Constructs a new object renderer task.\n * @param name The name of the task.\n * @param frameGraph The frame graph the task belongs to.\n * @param scene The scene the frame graph is associated with.\n * @param options The options of the object renderer.\n */\n constructor(name, frameGraph, scene, options) {\n super(name, frameGraph);\n /**\n * The dependencies of the task (optional).\n */\n this.dependencies = [];\n /**\n * If depth testing should be enabled (default is true).\n */\n this.depthTest = true;\n /**\n * If depth writing should be enabled (default is true).\n */\n this.depthWrite = true;\n this._scene = scene;\n this._renderer = new ObjectRenderer(name, scene, options);\n this.name = name;\n this._renderer.onBeforeRenderingManagerRenderObservable.add(() => {\n if (!this._renderer.options.doNotChangeAspectRatio) {\n scene.updateTransformMatrix(true);\n }\n });\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\n this.outputDepthTexture = this._frameGraph.textureManager.createDanglingHandle();\n }\n isReady() {\n return this._renderer.isReadyForRendering(this._textureWidth, this._textureHeight);\n }\n record(skipCreationOfDisabledPasses = false, additionalExecute) {\n if (this.destinationTexture === undefined || this.objectList === undefined) {\n throw new Error(`FrameGraphObjectRendererTask ${this.name}: destinationTexture and objectList are required`);\n }\n const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.destinationTexture);\n let depthEnabled = false;\n if (this.depthTexture !== undefined) {\n if (this.depthTexture === backbufferDepthStencilTextureHandle && this.destinationTexture !== backbufferColorTextureHandle) {\n throw new Error(`FrameGraphObjectRendererTask ${this.name}: the back buffer color texture is the only color texture allowed when the depth is the back buffer depth/stencil`);\n }\n if (this.depthTexture !== backbufferDepthStencilTextureHandle && this.destinationTexture === backbufferColorTextureHandle) {\n throw new Error(`FrameGraphObjectRendererTask ${this.name}: the back buffer depth/stencil texture is the only depth texture allowed when the destination is the back buffer color`);\n }\n const depthTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.depthTexture);\n if (depthTextureDescription.options.samples !== outputTextureDescription.options.samples) {\n throw new Error(`FrameGraphObjectRendererTask ${this.name}: the depth texture and the output texture must have the same number of samples`);\n }\n depthEnabled = true;\n }\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture);\n if (this.depthTexture !== undefined) {\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\n }\n this._textureWidth = outputTextureDescription.size.width;\n this._textureHeight = outputTextureDescription.size.height;\n const pass = this._frameGraph.addRenderPass(this.name);\n pass.setRenderTarget(this.destinationTexture);\n pass.setRenderTargetDepth(this.depthTexture);\n pass.setExecuteFunc((context) => {\n this._renderer.renderList = this.objectList.meshes;\n this._renderer.particleSystemList = this.objectList.particleSystems;\n context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);\n context.render(this._renderer, this._textureWidth, this._textureHeight);\n additionalExecute?.(context);\n });\n if (this.dependencies !== undefined) {\n for (const handle of this.dependencies) {\n pass.useTexture(handle);\n }\n }\n if (!skipCreationOfDisabledPasses) {\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\n passDisabled.setRenderTarget(this.destinationTexture);\n passDisabled.setRenderTargetDepth(this.depthTexture);\n passDisabled.setExecuteFunc((_context) => { });\n if (this.dependencies !== undefined) {\n for (const handle of this.dependencies) {\n passDisabled.useTexture(handle);\n }\n }\n }\n }\n dispose() {\n this._renderer.dispose();\n super.dispose();\n }\n}\n"],"mappings":"AAAA,SAASA,4BAA4B,EAAEC,mCAAmC,QAAQ,0BAA0B;AAC5G,SAASC,cAAc,QAAQ,yBAAyB;AACxD,SAASC,cAAc,QAAQ,sCAAsC;AACrE;AACA;AACA;AACA,OAAO,MAAMC,4BAA4B,SAASF,cAAc,CAAC;EAC7D;AACJ;AACA;EACI,IAAIG,MAAMA,CAAA,EAAG;IACT,OAAO,IAAI,CAACC,OAAO;EACvB;EACA,IAAID,MAAMA,CAACA,MAAM,EAAE;IACf,IAAI,CAACC,OAAO,GAAGD,MAAM;IACrB,IAAI,CAACE,SAAS,CAACC,YAAY,GAAG,IAAI,CAACH,MAAM;EAC7C;EACA;AACJ;AACA;EACI,IAAII,cAAcA,CAAA,EAAG;IACjB,OAAO,IAAI,CAACF,SAAS;EACzB;EACA,IAAIG,IAAIA,CAA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