diff --git a/packages/engine/Source/Scene/Model/GeometryPipelineStage.js b/packages/engine/Source/Scene/Model/GeometryPipelineStage.js index 300b1c4669a..fd503f71dca 100644 --- a/packages/engine/Source/Scene/Model/GeometryPipelineStage.js +++ b/packages/engine/Source/Scene/Model/GeometryPipelineStage.js @@ -143,18 +143,27 @@ GeometryPipelineStage.process = function ( model?.style?.showGaussianSplatting ?? model.showGaussianSplatting; if (gaussianSplatsEnabled === true) { - primitive.attributes.find((a) => a.name === "POSITION").instanceDivisor = - showSplats ? 1 : 0; - primitive.attributes.find((a) => a.name === "_SCALE").instanceDivisor = - showSplats ? 1 : 0; - primitive.attributes.find((a) => a.name === "_ROTATION").instanceDivisor = - showSplats ? 1 : 0; - primitive.attributes.find((a) => a.name === "COLOR_0").instanceDivisor = - showSplats ? 1 : 0; + ModelUtility.getAttributeBySemantic( + primitive, + VertexAttributeSemantic.POSITION, + ).instanceDivisor = showSplats ? 1 : 0; + ModelUtility.getAttributeBySemantic( + primitive, + VertexAttributeSemantic.SCALE, + ).instanceDivisor = showSplats ? 1 : 0; + ModelUtility.getAttributeBySemantic( + primitive, + VertexAttributeSemantic.ROTATION, + ).instanceDivisor = showSplats ? 1 : 0; + ModelUtility.getAttributeBySemantic( + primitive, + VertexAttributeSemantic.COLOR, + ).instanceDivisor = showSplats ? 1 : 0; if (primitive.hasGaussianSplatTexture) { - primitive.attributes.find( - (a) => a.name === "_SPLAT_INDEXES", + ModelUtility.getAttributeBySemantic( + primitive, + VertexAttributeSemantic.SPLAT_INDEXES, ).instanceDivisor = showSplats ? 1 : 0; } diff --git a/packages/engine/Source/Scene/VertexAttributeSemantic.js b/packages/engine/Source/Scene/VertexAttributeSemantic.js index 0225bf5d3fb..db3cb3e3925 100644 --- a/packages/engine/Source/Scene/VertexAttributeSemantic.js +++ b/packages/engine/Source/Scene/VertexAttributeSemantic.js @@ -87,6 +87,13 @@ const VertexAttributeSemantic = { * @constant */ ROTATION: "_ROTATION", + /** + * Gaussian Splat Attribute Texture Index + * + * @type {string} + * @constant + */ + SPLAT_INDEXES: "_SPLAT_INDEXES", }; function semanticToVariableName(semantic) { @@ -111,6 +118,8 @@ function semanticToVariableName(semantic) { return "scale"; case VertexAttributeSemantic.ROTATION: return "rotation"; + case VertexAttributeSemantic.SPLAT_INDEXES: + return "splatIndex"; //>>includeStart('debug', pragmas.debug); default: throw new DeveloperError("semantic is not a valid value."); @@ -144,6 +153,7 @@ VertexAttributeSemantic.hasSetIndex = function (semantic) { case VertexAttributeSemantic.FEATURE_ID: case VertexAttributeSemantic.SCALE: case VertexAttributeSemantic.ROTATION: + case VertexAttributeSemantic.SPLAT_INDEXES: return true; //>>includeStart('debug', pragmas.debug); default: @@ -196,6 +206,8 @@ VertexAttributeSemantic.fromGltfSemantic = function (gltfSemantic) { return VertexAttributeSemantic.SCALE; case "_ROTATION": return VertexAttributeSemantic.ROTATION; + case "_SPLAT_INDEXES": + return VertexAttributeSemantic.SPLAT_INDEXES; } return undefined; @@ -269,6 +281,8 @@ VertexAttributeSemantic.getGlslType = function (semantic) { return "vec3"; case VertexAttributeSemantic.ROTATION: return "vec4"; + case VertexAttributeSemantic.SPLAT_INDEXES: + return "int"; //>>includeStart('debug', pragmas.debug); default: throw new DeveloperError("semantic is not a valid value.");