Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose filter function instead of string list #5813

Merged
merged 2 commits into from Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion extras/splat/ply-parser.js
Expand Up @@ -10,6 +10,9 @@ const defaultElements = [
'scale_0', 'scale_1', 'scale_2'
];

const defaultElementsSet = new Set(defaultElements);
const defaultElementFilter = val => defaultElementsSet.has(val);

class PlyParser {
device;

Expand All @@ -25,7 +28,7 @@ class PlyParser {

async load(url, callback, asset) {
const response = await fetch(url.load);
readPly(response.body.getReader(), new Set(asset.data.elements ?? defaultElements))
readPly(response.body.getReader(), asset.data.elementFilter ?? defaultElementFilter)
.then((response) => {
callback(null, new SplatContainerResource(this.device, new SplatData(response)));
})
Expand Down
2 changes: 1 addition & 1 deletion extras/splat/ply-reader.js
Expand Up @@ -128,7 +128,7 @@ const readPly = async (reader, propertyFilter = null) => {
}
const element = elements[elements.length - 1];
const storageType = dataTypeMap.get(words[1]);
const storage = (!propertyFilter || propertyFilter.has(words[2])) ? new storageType(element.count) : null;
const storage = (!propertyFilter || propertyFilter(words[2])) ? new storageType(element.count) : null;
element.properties.push({
type: words[1],
name: words[2],
Expand Down