4c0f0df1262b35e56cf26087e8cee49addfff64fcb78681441f7ed531a77f54d.json 6.7 KB

1
  1. {"ast":null,"code":"import { FrameGraphTask } from \"../../frameGraphTask.js\";\n/**\n * Task used to cull objects that are not visible.\n */\nexport class FrameGraphCullObjectsTask extends FrameGraphTask {\n /**\n * Creates a new cull objects task.\n * @param name The name of the task.\n * @param frameGraph The frame graph the task belongs to.\n * @param scene The scene to cull objects from.\n */\n constructor(name, frameGraph, scene) {\n super(name, frameGraph);\n this._scene = scene;\n this.outputObjectList = {\n meshes: [],\n particleSystems: []\n };\n }\n record() {\n if (this.objectList === undefined || this.camera === undefined) {\n throw new Error(`FrameGraphCullObjectsTask ${this.name}: objectList and camera are required`);\n }\n const pass = this._frameGraph.addCullPass(this.name);\n pass.setObjectList(this.outputObjectList);\n pass.setExecuteFunc(_context => {\n this.outputObjectList.meshes = [];\n this.camera._updateFrustumPlanes();\n const frustumPlanes = this.camera._frustumPlanes;\n const meshes = this.objectList.meshes || this._scene.meshes;\n for (let i = 0; i < meshes.length; i++) {\n const mesh = meshes[i];\n if (mesh.isBlocked || !mesh.isReady() || !mesh.isEnabled() || mesh.scaling.hasAZeroComponent) {\n continue;\n }\n if (mesh.isVisible && mesh.visibility > 0 && (mesh.layerMask & this.camera.layerMask) !== 0 && (this._scene.skipFrustumClipping || mesh.alwaysSelectAsActiveMesh || mesh.isInFrustum(frustumPlanes))) {\n this.outputObjectList.meshes.push(mesh);\n }\n }\n });\n const passDisabled = this._frameGraph.addCullPass(this.name + \"_disabled\", true);\n passDisabled.setObjectList(this.outputObjectList);\n passDisabled.setExecuteFunc(_context => {\n this.outputObjectList.meshes = this.objectList.meshes;\n this.outputObjectList.particleSystems = this.objectList.particleSystems;\n });\n }\n}","map":{"version":3,"names":["FrameGraphTask","FrameGraphCullObjectsTask","constructor","name","frameGraph","scene","_scene","outputObjectList","meshes","particleSystems","record","objectList","undefined","camera","Error","pass","_frameGraph","addCullPass","setObjectList","setExecuteFunc","_context","_updateFrustumPlanes","frustumPlanes","_frustumPlanes","i","length","mesh","isBlocked","isReady","isEnabled","scaling","hasAZeroComponent","isVisible","visibility","layerMask","skipFrustumClipping","alwaysSelectAsActiveMesh","isInFrustum","push","passDisabled"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/FrameGraph/Tasks/Rendering/cullObjectsTask.js"],"sourcesContent":["import { FrameGraphTask } from \"../../frameGraphTask.js\";\n/**\n * Task used to cull objects that are not visible.\n */\nexport class FrameGraphCullObjectsTask extends FrameGraphTask {\n /**\n * Creates a new cull objects task.\n * @param name The name of the task.\n * @param frameGraph The frame graph the task belongs to.\n * @param scene The scene to cull objects from.\n */\n constructor(name, frameGraph, scene) {\n super(name, frameGraph);\n this._scene = scene;\n this.outputObjectList = {\n meshes: [],\n particleSystems: [],\n };\n }\n record() {\n if (this.objectList === undefined || this.camera === undefined) {\n throw new Error(`FrameGraphCullObjectsTask ${this.name}: objectList and camera are required`);\n }\n const pass = this._frameGraph.addCullPass(this.name);\n pass.setObjectList(this.outputObjectList);\n pass.setExecuteFunc((_context) => {\n this.outputObjectList.meshes = [];\n this.camera._updateFrustumPlanes();\n const frustumPlanes = this.camera._frustumPlanes;\n const meshes = this.objectList.meshes || this._scene.meshes;\n for (let i = 0; i < meshes.length; i++) {\n const mesh = meshes[i];\n if (mesh.isBlocked || !mesh.isReady() || !mesh.isEnabled() || mesh.scaling.hasAZeroComponent) {\n continue;\n }\n if (mesh.isVisible &&\n mesh.visibility > 0 &&\n (mesh.layerMask & this.camera.layerMask) !== 0 &&\n (this._scene.skipFrustumClipping || mesh.alwaysSelectAsActiveMesh || mesh.isInFrustum(frustumPlanes))) {\n this.outputObjectList.meshes.push(mesh);\n }\n }\n });\n const passDisabled = this._frameGraph.addCullPass(this.name + \"_disabled\", true);\n passDisabled.setObjectList(this.outputObjectList);\n passDisabled.setExecuteFunc((_context) => {\n this.outputObjectList.meshes = this.objectList.meshes;\n this.outputObjectList.particleSystems = this.objectList.particleSystems;\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