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 { GaussianSplattingMaterial } from \"../../../GaussianSplatting/gaussianSplattingMaterial.js\";\n/**\n * Block used for Reading components of the Gaussian Splatting\n */\nexport class SplatReaderBlock extends NodeMaterialBlock {\n /**\n * Create a new SplatReaderBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name, NodeMaterialBlockTargets.Vertex);\n this._isUnique = true;\n this.registerInput(\"splatIndex\", NodeMaterialBlockConnectionPointTypes.Float, false, NodeMaterialBlockTargets.Vertex);\n this.registerOutput(\"splatPosition\", NodeMaterialBlockConnectionPointTypes.Vector3, NodeMaterialBlockTargets.Vertex);\n this.registerOutput(\"splatColor\", NodeMaterialBlockConnectionPointTypes.Color4, NodeMaterialBlockTargets.Vertex);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"SplatReaderBlock\";\n }\n /**\n * Gets the splat index input component\n */\n get splatIndex() {\n return this._inputs[0];\n }\n /**\n * Gets the splatPosition output component\n */\n get splatPosition() {\n return this._outputs[0];\n }\n /**\n * Gets the splatColor output component\n */\n get splatColor() {\n return this._outputs[1];\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(\"covA\");\n state._excludeVariableName(\"covB\");\n state._excludeVariableName(\"vPosition\");\n state._excludeVariableName(\"covariancesATexture\");\n state._excludeVariableName(\"covariancesBTexture\");\n state._excludeVariableName(\"centersTexture\");\n state._excludeVariableName(\"colorsTexture\");\n state._excludeVariableName(\"dataTextureSize\");\n }\n bind(effect, nodeMaterial, mesh) {\n if (!mesh) {\n return;\n }\n const scene = mesh.getScene();\n GaussianSplattingMaterial.BindEffect(mesh, effect, scene);\n }\n _buildBlock(state) {\n super._buildBlock(state);\n if (state.target === NodeMaterialBlockTargets.Fragment) {\n return;\n }\n state.sharedData.bindableBlocks.push(this);\n // Emit code\n const comments = `//${this.name}`;\n state._emit2DSampler(\"covariancesATexture\");\n state._emit2DSampler(\"covariancesBTexture\");\n state._emit2DSampler(\"centersTexture\");\n state._emit2DSampler(\"colorsTexture\");\n state._emitFunctionFromInclude(\"gaussianSplattingVertexDeclaration\", comments);\n state._emitFunctionFromInclude(\"gaussianSplatting\", comments);\n state._emitVaryingFromString(\"vPosition\", NodeMaterialBlockConnectionPointTypes.Vector2);\n state._emitUniformFromString(\"dataTextureSize\", NodeMaterialBlockConnectionPointTypes.Vector2);\n const splatIndex = this.splatIndex;\n const splatPosition = this.splatPosition;\n const splatColor = this.splatColor;\n const splatVariablename = state._getFreeVariableName(\"splat\");\n if (state.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n state.compilationString += `var ${splatVariablename}: Splat = readSplat(${splatIndex.associatedVariableName}, uniforms.dataTextureSize);\\n`;\n state.compilationString += `var covA: vec3f = splat.covA.xyz; var covB: vec3f = vec3f(splat.covA.w, splat.covB.xy);\\n`;\n state.compilationString += \"vertexOutputs.vPosition = input.position;\\n\";\n } else {\n state.compilationString += `Splat ${splatVariablename} = readSplat(${splatIndex.associatedVariableName});\\n`;\n state.compilationString += `vec3 covA = splat.covA.xyz; vec3 covB = vec3(splat.covA.w, splat.covB.xy);\\n`;\n state.compilationString += \"vPosition = position;\\n\";\n }\n state.compilationString += `${state._declareOutput(splatPosition)} = ${splatVariablename}.center.xyz;\\n`;\n state.compilationString += `${state._declareOutput(splatColor)} = ${splatVariablename}.color;\\n`;\n return this;\n }\n}\nRegisterClass(\"BABYLON.SplatReaderBlock\", SplatReaderBlock);","map":{"version":3,"names":["NodeMaterialBlock","NodeMaterialBlockConnectionPointTypes","NodeMaterialBlockTargets","RegisterClass","GaussianSplattingMaterial","SplatReaderBlock","constructor","name","Vertex","_isUnique","registerInput","Float","registerOutput","Vector3","Color4","getClassName","splatIndex","_inputs","splatPosition","_outputs","splatColor","initialize","state","_excludeVariableName","bind","effect","nodeMaterial","mesh","scene","getScene","BindEffect","_buildBlock","target","Fragment","sharedData","bindableBlocks","push","comments","_emit2DSampler","_emitFunctionFromInclude","_emitVaryingFromString","Vector2","_emitUniformFromString","splatVariablename","_getFreeVariableName","shaderLanguage","compilationString","associatedVariableName","_declareOutput"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.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 { GaussianSplattingMaterial } from \"../../../GaussianSplatting/gaussianSplattingMaterial.js\";\n/**\n * Block used for Reading components of the Gaussian Splatting\n */\nexport class SplatReaderBlock extends NodeMaterialBlock {\n /**\n * Create a new SplatReaderBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name, NodeMaterialBlockTargets.Vertex);\n this._isUnique = true;\n this.registerInput(\"splatIndex\", NodeMaterialBlockConnectionPointTypes.Float, false, NodeMaterialBlockTargets.Vertex);\n this.registerOutput(\"splatPosition\", NodeMaterialBlockConnectionPointTypes.Vector3, NodeMaterialBlockTargets.Vertex);\n this.registerOutput(\"splatColor\", NodeMaterialBlockConnectionPointTypes.Color4, NodeMaterialBlockTargets.Vertex);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"SplatReaderBlock\";\n }\n /**\n * Gets the splat index input component\n */\n get splatIndex() {\n return this._inputs[0];\n }\n /**\n * Gets the splatPosition output component\n */\n get splatPosition() {\n return this._outputs[0];\n }\n /**\n * Gets the splatColor output component\n */\n get splatColor() {\n return this._outputs[1];\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(\"covA\");\n state._excludeVariableName(\"covB\");\n state._excludeVariableName(\"vPosition\");\n state._excludeVariableName(\"covariancesATexture\");\n state._excludeVariableName(\"covariancesBTexture\");\n state._excludeVariableName(\"centersTexture\");\n state._excludeVariableName(\"colorsTexture\");\n state._excludeVariableName(\"dataTextureSize\");\n }\n bind(effect, nodeMaterial, mesh) {\n if (!mesh) {\n return;\n }\n const scene = mesh.getScene();\n GaussianSplattingMaterial.BindEffect(mesh, effect, scene);\n }\n _buildBlock(state) {\n super._buildBlock(state);\n if (state.target === NodeMaterialBlockTargets.Fragment) {\n return;\n }\n state.sharedData.bindableBlocks.push(this);\n // Emit code\n const comments = `//${this.name}`;\n state._emit2DSampler(\"covariancesATexture\");\n state._emit2DSampler(\"covariancesBTexture\");\n state._emit2DSampler(\"centersTexture\");\n state._emit2DSampler(\"colorsTexture\");\n state._emitFunctionFromInclude(\"gaussianSplattingVertexDeclaration\", comments);\n state._emitFunctionFromInclude(\"gaussianSplatting\", comments);\n state._emitVaryingFromString(\"vPosition\", NodeMaterialBlockConnectionPointTypes.Vector2);\n state._emitUniformFromString(\"dataTextureSize\", NodeMaterialBlockConnectionPointTypes.Vector2);\n const splatIndex = this.splatIndex;\n const splatPosition = this.splatPosition;\n const splatColor = this.splatColor;\n const splatVariablename = state._getFreeVariableName(\"splat\");\n if (state.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n state.compilationString += `var ${splatVariablename}: Splat = readSplat(${splatIndex.associatedVariableName}, uniforms.dataTextureSize);\\n`;\n state.compilationString += `var covA: vec3f = splat.covA.xyz; var covB: vec3f = vec3f(splat.covA.w, splat.covB.xy);\\n`;\n state.compilationString += \"vertexOutputs.vPosition = input.position;\\n\";\n }\n else {\n state.compilationString += `Splat ${splatVariablename} = readSplat(${splatIndex.associatedVariableName});\\n`;\n state.compilationString += `vec3 covA = splat.covA.xyz; vec3 covB = vec3(splat.covA.w, splat.covB.xy);\\n`;\n state.compilationString += \"vPosition = position;\\n\";\n }\n state.compilationString += `${state._declareOutput(splatPosition)} = ${splatVariablename}.center.xyz;\\n`;\n state.compilationString += `${state._declareOutput(splatColor)} = ${splatVariablename}.color;\\n`;\n return this;\n }\n}\nRegisterClass(\"BABYLON.SplatReaderBlock\", SplatReaderBlock);\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,4BAA4B;AAC9D,SAASC,qCAAqC,QAAQ,sDAAsD;AAC5G,SAASC,wBAAwB,QAAQ,yCAAyC;AAClF,SAASC,aAAa,QAAQ,+BAA+B;AAC7D,SAASC,yBAAyB,QAAQ,yDAAyD;AACnG;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,SAASL,iBAAiB,CAAC;EACpD;AACJ;AACA;AACA;EACIM,WAAWA,CAACC,IAAI,EAAE;IACd,KAAK,CAACA,IAAI,EAAEL,wBAAwB,CAACM,MAAM,CAAC;IAC5C,IAAI,CAACC,SAAS,GAAG,IAAI;IACrB,IAAI,CAACC,aAAa,CAAC,YAAY,EAAET,qCAAqC,CAACU,KAAK,EAAE,KAAK,EAAET,wBAAwB,CAACM,MAAM,CAAC;IACrH,IAAI,CAACI,cAAc,CAAC,eAAe,EAAEX,qCAAqC,CAACY,OAAO,EAAEX,wBAAwB,CAACM,MAAM,CAAC;IACpH,IAAI,CAACI,cAAc,CAAC,YAAY,EAAEX,qCAAqC,CAACa,MAAM,EAAEZ,wBAAwB,CAACM,MAAM,CAAC;EACpH;EACA;AACJ;AACA;AACA;EACIO,YAAYA,CAAA,EAAG;IACX,OAAO,kBAAkB;EAC7B;EACA;AACJ;AACA;EACI,IAAIC,UAAUA,CAAA,EAAG;IACb,OAAO,IAAI,CAACC,OAAO,CAAC,CAAC,CAAC;EAC1B;EACA;AACJ;AACA;EACI,IAAIC,aAAaA,CAAA,EAAG;IAChB,OAAO,IAAI,CAACC,QAAQ,CAAC,CAA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