13cdad856328a307dc122de6cd5051e241d6cc8dbcf8ca161f517e37e2dae727.json 15 KB

1
  1. {"ast":null,"code":"import _asyncToGenerator from \"F:/workspace/202226701027/huinongbao-app/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js\";\nimport { VertexBuffer } from \"../../Buffers/buffer.js\";\nimport { EffectWrapper } from \"../../Materials/effectRenderer.js\";\nimport { FluidRenderingObject } from \"./fluidRenderingObject.js\";\n/**\n * Defines a rendering object based on a list of custom buffers\n * The list must contain at least a \"position\" buffer!\n */\nexport class FluidRenderingObjectCustomParticles extends FluidRenderingObject {\n /**\n * @returns the name of the class\n */\n getClassName() {\n return \"FluidRenderingObjectCustomParticles\";\n }\n /**\n * Gets the vertex buffers\n */\n get vertexBuffers() {\n return this._vertexBuffers;\n }\n /**\n * Creates a new instance of the class\n * @param scene The scene the particles should be rendered into\n * @param buffers The list of buffers (must contain at least one \"position\" buffer!). Note that you don't have to pass all (or any!) buffers at once in the constructor, you can use the addBuffers method to add more later.\n * @param numParticles Number of vertices to take into account from the buffers\n * @param shaderLanguage The shader language to use\n */\n constructor(scene, buffers, numParticles, shaderLanguage) {\n super(scene, shaderLanguage);\n this._numParticles = numParticles;\n this._diffuseEffectWrapper = null;\n this._vertexBuffers = {};\n this.addBuffers(buffers);\n }\n /**\n * Add some new buffers\n * @param buffers List of buffers\n */\n addBuffers(buffers) {\n for (const name in buffers) {\n let stride;\n let instanced = true;\n switch (name) {\n case \"velocity\":\n stride = 3;\n break;\n case \"offset\":\n instanced = false;\n break;\n }\n this._vertexBuffers[name] = new VertexBuffer(this._engine, buffers[name], name, true, false, stride, instanced);\n }\n }\n _createEffects() {\n var _this = this;\n super._createEffects();\n const uniformNames = [\"view\", \"projection\", \"size\"];\n const attributeNames = [\"position\", \"offset\", \"color\"];\n this._diffuseEffectWrapper = new EffectWrapper({\n engine: this._engine,\n useShaderStore: true,\n vertexShader: \"fluidRenderingParticleDiffuse\",\n fragmentShader: \"fluidRenderingParticleDiffuse\",\n attributeNames,\n uniformNames,\n samplerNames: [],\n shaderLanguage: this._shaderLanguage,\n extraInitializationsAsync: function () {\n var _ref = _asyncToGenerator(function* () {\n if (_this._shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n yield import(\"../../ShadersWGSL/fluidRenderingParticleDiffuse.fragment.js\");\n } else {\n yield import(\"../../Shaders/fluidRenderingParticleDiffuse.fragment.js\");\n }\n });\n return function extraInitializationsAsync() {\n return _ref.apply(this, arguments);\n };\n }()\n });\n }\n /**\n * Indicates if the object is ready to be rendered\n * @returns True if everything is ready for the object to be rendered, otherwise false\n */\n isReady() {\n var _this$_diffuseEffectW, _this$_diffuseEffectW2;\n if (!this._vertexBuffers[\"offset\"]) {\n this._vertexBuffers[\"offset\"] = new VertexBuffer(this._engine, [0, 0, 1, 0, 0, 1, 1, 1], \"offset\", false, false, 2);\n }\n return super.isReady() && ((_this$_diffuseEffectW = (_this$_diffuseEffectW2 = this._diffuseEffectWrapper) === null || _this$_diffuseEffectW2 === void 0 ? void 0 : _this$_diffuseEffectW2.effect.isReady()) !== null && _this$_diffuseEffectW !== void 0 ? _this$_diffuseEffectW : false);\n }\n /**\n * Gets the number of particles in this object\n * @returns The number of particles\n */\n get numParticles() {\n return this._numParticles;\n }\n /**\n * Sets the number of particles in this object\n * @param num The number of particles to take into account\n */\n setNumParticles(num) {\n this._numParticles = num;\n }\n /**\n * Render the diffuse texture for this object\n */\n renderDiffuseTexture() {\n const numParticles = this.numParticles;\n if (!this._diffuseEffectWrapper || numParticles === 0) {\n return;\n }\n const diffuseDrawWrapper = this._diffuseEffectWrapper.drawWrapper;\n const diffuseEffect = diffuseDrawWrapper.effect;\n this._engine.enableEffect(diffuseDrawWrapper);\n this._engine.bindBuffers(this.vertexBuffers, this.indexBuffer, diffuseEffect);\n diffuseEffect.setMatrix(\"view\", this._scene.getViewMatrix());\n diffuseEffect.setMatrix(\"projection\", this._scene.getProjectionMatrix());\n if (this._particleSize !== null) {\n diffuseEffect.setFloat2(\"size\", this._particleSize, this._particleSize);\n }\n if (this.useInstancing) {\n this._engine.drawArraysType(7, 0, 4, numParticles);\n } else {\n this._engine.drawElementsType(0, 0, numParticles);\n }\n }\n /**\n * Releases the ressources used by the class\n */\n dispose() {\n var _this$_diffuseEffectW3;\n super.dispose();\n (_this$_diffuseEffectW3 = this._diffuseEffectWrapper) === null || _this$_diffuseEffectW3 === void 0 || _this$_diffuseEffectW3.dispose();\n for (const name in this._vertexBuffers) {\n this._vertexBuffers[name].dispose();\n }\n this._vertexBuffers = {};\n }\n}","map":{"version":3,"names":["VertexBuffer","EffectWrapper","FluidRenderingObject","FluidRenderingObjectCustomParticles","getClassName","vertexBuffers","_vertexBuffers","constructor","scene","buffers","numParticles","shaderLanguage","_numParticles","_diffuseEffectWrapper","addBuffers","name","stride","instanced","_engine","_createEffects","_this","uniformNames","attributeNames","engine","useShaderStore","vertexShader","fragmentShader","samplerNames","_shaderLanguage","extraInitializationsAsync","_ref","_asyncToGenerator","apply","arguments","isReady","_this$_diffuseEffectW","_this$_diffuseEffectW2","effect","setNumParticles","num","renderDiffuseTexture","diffuseDrawWrapper","drawWrapper","diffuseEffect","enableEffect","bindBuffers","indexBuffer","setMatrix","_scene","getViewMatrix","getProjectionMatrix","_particleSize","setFloat2","useInstancing","drawArraysType","drawElementsType","dispose","_this$_diffuseEffectW3"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.js"],"sourcesContent":["import { VertexBuffer } from \"../../Buffers/buffer.js\";\n\nimport { EffectWrapper } from \"../../Materials/effectRenderer.js\";\nimport { FluidRenderingObject } from \"./fluidRenderingObject.js\";\n/**\n * Defines a rendering object based on a list of custom buffers\n * The list must contain at least a \"position\" buffer!\n */\nexport class FluidRenderingObjectCustomParticles extends FluidRenderingObject {\n /**\n * @returns the name of the class\n */\n getClassName() {\n return \"FluidRenderingObjectCustomParticles\";\n }\n /**\n * Gets the vertex buffers\n */\n get vertexBuffers() {\n return this._vertexBuffers;\n }\n /**\n * Creates a new instance of the class\n * @param scene The scene the particles should be rendered into\n * @param buffers The list of buffers (must contain at least one \"position\" buffer!). Note that you don't have to pass all (or any!) buffers at once in the constructor, you can use the addBuffers method to add more later.\n * @param numParticles Number of vertices to take into account from the buffers\n * @param shaderLanguage The shader language to use\n */\n constructor(scene, buffers, numParticles, shaderLanguage) {\n super(scene, shaderLanguage);\n this._numParticles = numParticles;\n this._diffuseEffectWrapper = null;\n this._vertexBuffers = {};\n this.addBuffers(buffers);\n }\n /**\n * Add some new buffers\n * @param buffers List of buffers\n */\n addBuffers(buffers) {\n for (const name in buffers) {\n let stride;\n let instanced = true;\n switch (name) {\n case \"velocity\":\n stride = 3;\n break;\n case \"offset\":\n instanced = false;\n break;\n }\n this._vertexBuffers[name] = new VertexBuffer(this._engine, buffers[name], name, true, false, stride, instanced);\n }\n }\n _createEffects() {\n super._createEffects();\n const uniformNames = [\"view\", \"projection\", \"size\"];\n const attributeNames = [\"position\", \"offset\", \"color\"];\n this._diffuseEffectWrapper = new EffectWrapper({\n engine: this._engine,\n useShaderStore: true,\n vertexShader: \"fluidRenderingParticleDiffuse\",\n fragmentShader: \"fluidRenderingParticleDiffuse\",\n attributeNames,\n uniformNames,\n samplerNames: [],\n shaderLanguage: this._shaderLanguage,\n extraInitializationsAsync: async () => {\n if (this._shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n await import(\"../../ShadersWGSL/fluidRenderingParticleDiffuse.fragment.js\");\n }\n else {\n await import(\"../../Shaders/fluidRenderingParticleDiffuse.fragment.js\");\n }\n },\n });\n }\n /**\n * Indicates if the object is ready to be rendered\n * @returns True if everything is ready for the object to be rendered, otherwise false\n */\n isReady() {\n if (!this._vertexBuffers[\"offset\"]) {\n this._vertexBuffers[\"offset\"] = new VertexBuffer(this._engine, [0, 0, 1, 0, 0, 1, 1, 1], \"offset\", false, false, 2);\n }\n return super.isReady() && (this._diffuseEffectWrapper?.effect.isReady() ?? false);\n }\n /**\n * Gets the number of particles in this object\n * @returns The number of particles\n */\n get numParticles() {\n return this._numParticles;\n }\n /**\n * Sets the number of particles in this object\n * @param num The number of particles to take into account\n */\n setNumParticles(num) {\n this._numParticles = num;\n }\n /**\n * Render the diffuse texture for this object\n */\n renderDiffuseTexture() {\n const numParticles = this.numParticles;\n if (!this._diffuseEffectWrapper || numParticles === 0) {\n return;\n }\n const diffuseDrawWrapper = this._diffuseEffectWrapper.drawWrapper;\n const diffuseEffect = diffuseDrawWrapper.effect;\n this._engine.enableEffect(diffuseDrawWrapper);\n this._engine.bindBuffers(this.vertexBuffers, this.indexBuffer, diffuseEffect);\n diffuseEffect.setMatrix(\"view\", this._scene.getViewMatrix());\n diffuseEffect.setMatrix(\"projection\", this._scene.getProjectionMatrix());\n if (this._particleSize !== null) {\n diffuseEffect.setFloat2(\"size\", this._particleSize, this._particleSize);\n }\n if (this.useInstancing) {\n this._engine.drawArraysType(7, 0, 4, numParticles);\n }\n else {\n this._engine.drawElementsType(0, 0, numParticles);\n }\n }\n /**\n * Releases the ressources used by the class\n */\n dispose() {\n super.dispose();\n this._diffuseEffectWrapper?.dispose();\n for (const name in this._vertexBuffers) {\n this._vertexBuffers[name].dispose();\n }\n this._vertexBuffers = {};\n }\n}\n"],"mappings":";AAAA,SAASA,YAAY,QAAQ,yBAAyB;AAEtD,SAASC,aAAa,QAAQ,mCAAmC;AACjE,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE;AACA;AACA;AACA;AACA,OAAO,MAAMC,mCAAmC,SAASD,oBAAoB,CAAC;EAC1E;AACJ;AACA;EACIE,YAAYA,CAAA,EAAG;IACX,OAAO,qCAAqC;EAChD;EACA;AACJ;AACA;EACI,IAAIC,aAAaA,CAAA,EAAG;IAChB,OAAO,IAAI,CAACC,cAAc;EAC9B;EACA;AACJ;AACA;AACA;AACA;AACA;AACA;EACIC,WAAWA,CAACC,KAAK,EAAEC,OAAO,EAAEC,YAAY,EAAEC,cAAc,EAAE;IACtD,KAAK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