Skip to content

Commit

Permalink
Handle missing batch ID attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
javagl committed Aug 17, 2024
1 parent b9ce25a commit 09d7c7a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/tools/migration/TileFormatsMigrationB3dm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class TileFormatsMigrationB3dm {
primitive,
batchIdToFeatureIdAccessor
);
if (propertyTable) {
if (featureId && propertyTable) {
featureId.setPropertyTable(propertyTable);
}
}
Expand Down
13 changes: 9 additions & 4 deletions src/tools/migration/TileTableDataToMeshFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ export class TileTableDataToMeshFeatures {
* extension that is associated with this primitive, storing
* the former batch ID attribute as a new `_FEATURE_ID_0` attribute.
*
* Note that this will remove the former batch ID attributes
* Note that this will set the former batch ID attributes
* in the given primitive to `null`, but it will not dispose
* the corresponding accessors. These have to be disposed
* after all primitives have been processed.
*
* If the given primitive does not contain a batch ID attribute,
* then a warning will be printed, and `undefined` will be
* returned.
*
* @param document - The glTF-Transform document
* @param primitive - The glTF-Transform primitive
* @param batchIdToFeatureIdAccessor - A mapping from former
Expand All @@ -42,7 +46,7 @@ export class TileTableDataToMeshFeatures {
document: Document,
primitive: Primitive,
batchIdToFeatureIdAccessor: Map<Accessor, Accessor>
): FeatureId {
): FeatureId | undefined {
let batchIdAttribute = primitive.getAttribute("_BATCHID");
if (!batchIdAttribute) {
batchIdAttribute = primitive.getAttribute("BATCHID");
Expand All @@ -52,9 +56,10 @@ export class TileTableDataToMeshFeatures {
"should be _BATCHID, starting with an underscore"
);
} else {
throw new TileFormatError(
"The primitive did not contain a _BATCHID attribute"
logger.warn(
"The primitive did not contain a _BATCHID or BATCHID attribute"
);
return undefined;
}
}

Expand Down

0 comments on commit 09d7c7a

Please sign in to comment.