6ba9a216e8d23803140d950f952ff0e09c0e0d5534cfe31fe5525ce200188fb4.json 13 KB

1
  1. {"ast":null,"code":"import { NodeMaterialBlock } from \"../../nodeMaterialBlock.js\";\nimport { NodeMaterialBlockConnectionPointTypes } from \"../../Enums/nodeMaterialBlockConnectionPointTypes.js\";\nimport { NodeMaterialBlockTargets } from \"../../Enums/nodeMaterialBlockTargets.js\";\nimport { RegisterClass } from \"../../../../Misc/typeStore.js\";\nimport { VertexBuffer } from \"../../../../Meshes/buffer.js\";\n/**\n * Block used for the Gaussian Splatting\n */\nexport class GaussianSplattingBlock extends NodeMaterialBlock {\n /**\n * Create a new GaussianSplattingBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name, NodeMaterialBlockTargets.Vertex);\n this._isUnique = true;\n this.registerInput(\"splatPosition\", NodeMaterialBlockConnectionPointTypes.Vector3, false, NodeMaterialBlockTargets.Vertex);\n this.registerInput(\"splatScale\", NodeMaterialBlockConnectionPointTypes.Vector2, true, NodeMaterialBlockTargets.Vertex);\n this.registerInput(\"world\", NodeMaterialBlockConnectionPointTypes.Matrix, false, NodeMaterialBlockTargets.Vertex);\n this.registerInput(\"view\", NodeMaterialBlockConnectionPointTypes.Matrix, false, NodeMaterialBlockTargets.Vertex);\n this.registerInput(\"projection\", NodeMaterialBlockConnectionPointTypes.Matrix, false, NodeMaterialBlockTargets.Vertex);\n this.registerOutput(\"splatVertex\", NodeMaterialBlockConnectionPointTypes.Vector4, NodeMaterialBlockTargets.Vertex);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"GaussianSplattingBlock\";\n }\n /**\n * Gets the position input component\n */\n get splatPosition() {\n return this._inputs[0];\n }\n /**\n * Gets the scale input component\n */\n get splatScale() {\n return this._inputs[1];\n }\n /**\n * Gets the View matrix input component\n */\n get world() {\n return this._inputs[2];\n }\n /**\n * Gets the View matrix input component\n */\n get view() {\n return this._inputs[3];\n }\n /**\n * Gets the projection matrix input component\n */\n get projection() {\n return this._inputs[4];\n }\n /**\n * Gets the splatVertex output component\n */\n get splatVertex() {\n return this._outputs[0];\n }\n /**\n * Initialize the block and prepare the context for build\n * @param state defines the state that will be used for the build\n */\n initialize(state) {\n state._excludeVariableName(\"focal\");\n state._excludeVariableName(\"invViewport\");\n }\n _buildBlock(state) {\n super._buildBlock(state);\n if (state.target === NodeMaterialBlockTargets.Fragment) {\n return;\n }\n const comments = `//${this.name}`;\n state._emitFunctionFromInclude(\"gaussianSplattingVertexDeclaration\", comments);\n state._emitFunctionFromInclude(\"gaussianSplatting\", comments);\n state._emitUniformFromString(\"focal\", NodeMaterialBlockConnectionPointTypes.Vector2);\n state._emitUniformFromString(\"invViewport\", NodeMaterialBlockConnectionPointTypes.Vector2);\n state.attributes.push(VertexBuffer.PositionKind);\n state.sharedData.nodeMaterial.backFaceCulling = false;\n const splatPosition = this.splatPosition;\n const splatScale = this.splatScale;\n const world = this.world;\n const view = this.view;\n const projection = this.projection;\n const output = this.splatVertex;\n const addF = state.fSuffix;\n let splatScaleParameter = `vec2${addF}(1.,1.)`;\n if (splatScale.isConnected) {\n splatScaleParameter = splatScale.associatedVariableName;\n }\n let input = \"position\";\n let uniforms = \"\";\n if (state.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n input = \"input.position\";\n uniforms = \", uniforms.focal, uniforms.invViewport\";\n }\n state.compilationString += `${state._declareOutput(output)} = gaussianSplatting(${input}, ${splatPosition.associatedVariableName}, ${splatScaleParameter}, covA, covB, ${world.associatedVariableName}, ${view.associatedVariableName}, ${projection.associatedVariableName}${uniforms});\\n`;\n return this;\n }\n}\nRegisterClass(\"BABYLON.GaussianSplattingBlock\", GaussianSplattingBlock);","map":{"version":3,"names":["NodeMaterialBlock","NodeMaterialBlockConnectionPointTypes","NodeMaterialBlockTargets","RegisterClass","VertexBuffer","GaussianSplattingBlock","constructor","name","Vertex","_isUnique","registerInput","Vector3","Vector2","Matrix","registerOutput","Vector4","getClassName","splatPosition","_inputs","splatScale","world","view","projection","splatVertex","_outputs","initialize","state","_excludeVariableName","_buildBlock","target","Fragment","comments","_emitFunctionFromInclude","_emitUniformFromString","attributes","push","PositionKind","sharedData","nodeMaterial","backFaceCulling","output","addF","fSuffix","splatScaleParameter","isConnected","associatedVariableName","input","uniforms","shaderLanguage","compilationString","_declareOutput"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js"],"sourcesContent":["import { NodeMaterialBlock } from \"../../nodeMaterialBlock.js\";\nimport { NodeMaterialBlockConnectionPointTypes } from \"../../Enums/nodeMaterialBlockConnectionPointTypes.js\";\nimport { NodeMaterialBlockTargets } from \"../../Enums/nodeMaterialBlockTargets.js\";\nimport { RegisterClass } from \"../../../../Misc/typeStore.js\";\nimport { VertexBuffer } from \"../../../../Meshes/buffer.js\";\n/**\n * Block used for the Gaussian Splatting\n */\nexport class GaussianSplattingBlock extends NodeMaterialBlock {\n /**\n * Create a new GaussianSplattingBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name, NodeMaterialBlockTargets.Vertex);\n this._isUnique = true;\n this.registerInput(\"splatPosition\", NodeMaterialBlockConnectionPointTypes.Vector3, false, NodeMaterialBlockTargets.Vertex);\n this.registerInput(\"splatScale\", NodeMaterialBlockConnectionPointTypes.Vector2, true, NodeMaterialBlockTargets.Vertex);\n this.registerInput(\"world\", NodeMaterialBlockConnectionPointTypes.Matrix, false, NodeMaterialBlockTargets.Vertex);\n this.registerInput(\"view\", NodeMaterialBlockConnectionPointTypes.Matrix, false, NodeMaterialBlockTargets.Vertex);\n this.registerInput(\"projection\", NodeMaterialBlockConnectionPointTypes.Matrix, false, NodeMaterialBlockTargets.Vertex);\n this.registerOutput(\"splatVertex\", NodeMaterialBlockConnectionPointTypes.Vector4, NodeMaterialBlockTargets.Vertex);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"GaussianSplattingBlock\";\n }\n /**\n * Gets the position input component\n */\n get splatPosition() {\n return this._inputs[0];\n }\n /**\n * Gets the scale input component\n */\n get splatScale() {\n return this._inputs[1];\n }\n /**\n * Gets the View matrix input component\n */\n get world() {\n return this._inputs[2];\n }\n /**\n * Gets the View matrix input component\n */\n get view() {\n return this._inputs[3];\n }\n /**\n * Gets the projection matrix input component\n */\n get projection() {\n return this._inputs[4];\n }\n /**\n * Gets the splatVertex output component\n */\n get splatVertex() {\n return this._outputs[0];\n }\n /**\n * Initialize the block and prepare the context for build\n * @param state defines the state that will be used for the build\n */\n initialize(state) {\n state._excludeVariableName(\"focal\");\n state._excludeVariableName(\"invViewport\");\n }\n _buildBlock(state) {\n super._buildBlock(state);\n if (state.target === NodeMaterialBlockTargets.Fragment) {\n return;\n }\n const comments = `//${this.name}`;\n state._emitFunctionFromInclude(\"gaussianSplattingVertexDeclaration\", comments);\n state._emitFunctionFromInclude(\"gaussianSplatting\", comments);\n state._emitUniformFromString(\"focal\", NodeMaterialBlockConnectionPointTypes.Vector2);\n state._emitUniformFromString(\"invViewport\", NodeMaterialBlockConnectionPointTypes.Vector2);\n state.attributes.push(VertexBuffer.PositionKind);\n state.sharedData.nodeMaterial.backFaceCulling = false;\n const splatPosition = this.splatPosition;\n const splatScale = this.splatScale;\n const world = this.world;\n const view = this.view;\n const projection = this.projection;\n const output = this.splatVertex;\n const addF = state.fSuffix;\n let splatScaleParameter = `vec2${addF}(1.,1.)`;\n if (splatScale.isConnected) {\n splatScaleParameter = splatScale.associatedVariableName;\n }\n let input = \"position\";\n let uniforms = \"\";\n if (state.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n input = \"input.position\";\n uniforms = \", uniforms.focal, uniforms.invViewport\";\n }\n state.compilationString += `${state._declareOutput(output)} = gaussianSplatting(${input}, ${splatPosition.associatedVariableName}, ${splatScaleParameter}, covA, covB, ${world.associatedVariableName}, ${view.associatedVariableName}, ${projection.associatedVariableName}${uniforms});\\n`;\n return this;\n }\n}\nRegisterClass(\"BABYLON.GaussianSplattingBlock\", Ga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