Skip to content

Commit

Permalink
Naming consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
brentyi committed Jul 25, 2024
1 parent 2186653 commit b1acfc4
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/viser/client/src/Splatting/GaussianSplats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const GaussianSplatMaterial = /* @__PURE__ */ shaderMaterial(
attribute uint sortedIndex;
// Which group transform should be applied to each Gaussian.
attribute uint groupIndex;
attribute uint sortedGroupIndex;
// Buffers for splat data; each Gaussian gets 4 floats and 4 int32s. We just
// copy quadjr for this.
Expand Down Expand Up @@ -87,7 +87,7 @@ const GaussianSplatMaterial = /* @__PURE__ */ shaderMaterial(
// Fetch from textures.
uvec4 floatBufferData = texelFetch(textureBuffer, texPos0, 0);
mat4 T_camera_group = getGroupTransform(groupIndex);
mat4 T_camera_group = getGroupTransform(sortedGroupIndex);
// Any early return will discard the fragment.
gl_Position = vec4(0.0, 0.0, 2000.0, 1.0);
Expand Down Expand Up @@ -212,8 +212,8 @@ export default function GlobalGaussianSplats() {
// Update group indices if needed.
if (merged.numGroups >= 2) {
const sortedGroupIndices = e.data.sortedGroupIndices as Uint32Array;
meshProps.groupIndexAttribute.set(sortedGroupIndices);
meshProps.groupIndexAttribute.needsUpdate = true;
meshProps.sortedGroupIndexAttribute.set(sortedGroupIndices);
meshProps.sortedGroupIndexAttribute.needsUpdate = true;
}

// Trigger initial render.
Expand Down Expand Up @@ -274,7 +274,7 @@ export default function GlobalGaussianSplats() {

// Update group transforms.
const T_camera_world = state.camera.matrixWorldInverse;
for (const [groupIndex, name] of Object.keys(
for (const [sortedGroupIndex, name] of Object.keys(
groupBufferFromName,
).entries()) {
const node = viewer.nodeRefFromName.current[name];
Expand All @@ -288,12 +288,12 @@ export default function GlobalGaussianSplats() {
colMajorElements[10],
colMajorElements[14],
],
groupIndex * 4,
sortedGroupIndex * 4,
);
const rowMajorElements = tmpT_camera_group.transpose().elements;
meshProps.rowMajorT_camera_groups.set(
rowMajorElements.slice(0, 12),
groupIndex * 12,
sortedGroupIndex * 12,
);

// If a group is not visible, we'll throw it off the screen with some
Expand All @@ -305,9 +305,9 @@ export default function GlobalGaussianSplats() {
});
}
if (!visible) {
meshProps.rowMajorT_camera_groups[groupIndex * 12 + 3] = 1e10;
meshProps.rowMajorT_camera_groups[groupIndex * 12 + 7] = 1e10;
meshProps.rowMajorT_camera_groups[groupIndex * 12 + 11] = 1e10;
meshProps.rowMajorT_camera_groups[sortedGroupIndex * 12 + 3] = 1e10;
meshProps.rowMajorT_camera_groups[sortedGroupIndex * 12 + 7] = 1e10;
meshProps.rowMajorT_camera_groups[sortedGroupIndex * 12 + 11] = 1e10;
}
}

Expand Down Expand Up @@ -356,11 +356,11 @@ function mergeGaussianGroups(groupBufferFromName: {
const groupIndices = new Uint32Array(numGaussians);

let offset = 0;
for (const [groupIndex, groupBuffer] of Object.values(
for (const [sortedGroupIndex, groupBuffer] of Object.values(
groupBufferFromName,
).entries()) {
groupIndices.fill(
groupIndex,
sortedGroupIndex,
offset / 8,
(offset + groupBuffer.length) / 8,
);
Expand Down Expand Up @@ -405,12 +405,12 @@ function useGaussianMeshProps(
geometry.setAttribute("sortedIndex", sortedIndexAttribute);

// Which group is each Gaussian in?
const groupIndexAttribute = new THREE.InstancedBufferAttribute(
const sortedGroupIndexAttribute = new THREE.InstancedBufferAttribute(
groupIndices.slice(), // Copies the array.
1,
);
groupIndexAttribute.setUsage(THREE.StaticDrawUsage);
geometry.setAttribute("groupIndex", groupIndexAttribute);
sortedGroupIndexAttribute.setUsage(THREE.StaticDrawUsage);
geometry.setAttribute("sortedGroupIndex", sortedGroupIndexAttribute);

// Create texture buffers.
const textureWidth = Math.min(numGaussians * 2, maxTextureSize);
Expand Down Expand Up @@ -451,7 +451,7 @@ function useGaussianMeshProps(
material,
textureBuffer,
sortedIndexAttribute,
groupIndexAttribute,
sortedGroupIndexAttribute,
textureT_camera_groups,
rowMajorT_camera_groups,
};
Expand Down

0 comments on commit b1acfc4

Please sign in to comment.