Skip to content

Commit 979bc01

Browse files
committed
throw in numeric prop support
1 parent ef3ec7c commit 979bc01

File tree

1 file changed

+27
-19
lines changed

1 file changed

+27
-19
lines changed

src/mesh/frontend.ts

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ export class MeshShaderManager {
481481
`highp ${getShaderOutputType(property.dataType)}`,
482482
property.id.replaceAll(" ", "_"),
483483
);
484+
console.log("added numeric uniform", property.id);
484485
}
485486
if (tags) {
486487
console.log("tags", tags);
@@ -573,9 +574,34 @@ const addPropertyUniforms = (
573574
// );
574575
// console.log("segmentPropertyMap.numerical", segmentPropertyMap.tags);
575576

577+
const getShaderUniformValueSetter = (gl: GL, ioType: DataType) => {
578+
switch (ioType) {
579+
case DataType.UINT8:
580+
case DataType.UINT16:
581+
case DataType.UINT32:
582+
return gl.uniform1ui;
583+
case DataType.INT8:
584+
case DataType.INT16:
585+
case DataType.INT32:
586+
return gl.uniform1i;
587+
case DataType.FLOAT32:
588+
return gl.uniform1f;
589+
case DataType.UINT64:
590+
throw new Error("nope");
591+
// return gl.uniform
592+
};
593+
};
594+
576595
if (index !== -1) {
577-
const { labels, tags: tagsProperty } = segmentPropertyMap;
596+
const { labels, tags: tagsProperty, numericalProperties } = segmentPropertyMap;
578597
labels;
598+
599+
for (const property of numericalProperties) {
600+
const value = property.values[index];
601+
const uniformSetter = getShaderUniformValueSetter(gl, property.dataType);
602+
uniformSetter.call(gl, shader.uniform(property.id.replaceAll(" ", "_")), value);
603+
}
604+
579605
// let label = "";
580606
// if (labels !== undefined) {
581607
// label = labels.values[index];
@@ -592,24 +618,6 @@ const addPropertyUniforms = (
592618
gl.uniform1ui(shader.uniform(`uTag${tagIdx}`), 1);
593619
}
594620
}
595-
596-
function getShaderUniformValueSetter(gl: GL, ioType: DataType) {
597-
switch (ioType) {
598-
case DataType.UINT8:
599-
case DataType.UINT16:
600-
case DataType.UINT32:
601-
return gl.uniform1ui;
602-
case DataType.INT8:
603-
case DataType.INT16:
604-
case DataType.INT32:
605-
return gl.uniform1i;
606-
case DataType.FLOAT32:
607-
return gl.uniform1f;
608-
case DataType.UINT64:
609-
throw new Error("nope");
610-
// return gl.uniform
611-
}
612-
}
613621
// if (label.length === 0) return undefined;
614622

615623
// if (tags) {

0 commit comments

Comments
 (0)