From 635326a49aee963251e9daea3d3f6524caa7ad93 Mon Sep 17 00:00:00 2001 From: Marco Hutter Date: Sun, 11 Jun 2023 14:21:48 +0200 Subject: [PATCH 1/3] Handle URI with spaces in I3DM --- specs/TilesetValidationSpec.ts | 7 +++++++ .../tilesets/tiles/i3dm/i3dmWithUri/Box.glb | Bin 0 -> 1664 bytes .../tilesets/tiles/i3dm/i3dmWithUri/README.md | 13 ++++++++++++ .../tiles/i3dm/i3dmWithUri/i3dmWithUri.i3dm | Bin 0 -> 120 bytes .../tiles/i3dm/i3dmWithUri/tileset.json | 19 ++++++++++++++++++ src/tileFormats/I3dmValidator.ts | 5 +++-- 6 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 specs/data/tilesets/tiles/i3dm/i3dmWithUri/Box.glb create mode 100644 specs/data/tilesets/tiles/i3dm/i3dmWithUri/README.md create mode 100644 specs/data/tilesets/tiles/i3dm/i3dmWithUri/i3dmWithUri.i3dm create mode 100644 specs/data/tilesets/tiles/i3dm/i3dmWithUri/tileset.json diff --git a/specs/TilesetValidationSpec.ts b/specs/TilesetValidationSpec.ts index edf6a5c4..efb84cec 100644 --- a/specs/TilesetValidationSpec.ts +++ b/specs/TilesetValidationSpec.ts @@ -951,4 +951,11 @@ describe("Tileset validation", function () { ); expect(result.length).toEqual(0); }); + + it("detects no issues in tilesets/tiles/i3dm/i3dmWithUri/tileset.json", async function () { + const result = await Validators.validateTilesetFile( + "specs/data/tilesets/tiles/i3dm/i3dmWithUri/tileset.json" + ); + expect(result.length).toEqual(0); + }); }); diff --git a/specs/data/tilesets/tiles/i3dm/i3dmWithUri/Box.glb b/specs/data/tilesets/tiles/i3dm/i3dmWithUri/Box.glb new file mode 100644 index 0000000000000000000000000000000000000000..95ec886b6b92b134291fd41d34ac9d5349306e0a GIT binary patch literal 1664 zcmb7EOK;jh5S}DW+O$p6v`u^8GeNd_1bm4oEftl43Q#VHgE0$OGB&bJ+Q_oRvHz-n zq(7!Jix*Y|3Dweg=e6_A%bt4u#xVe_&H(fXY|f(@CPIkBiUbn22;I3GyAPRY#|SxE#v~@J z-RZV!7Blr6`_bt&`^`?9nFdzn`eWB2AFOMR#W1rd(&eFRdl`st&r#1>1WTZ{gEyie zT(@AfoJ@Fl@A97_$mlWVoykNr7-KrYd=dEEkNb}c3{ujK0x6e1_PSp7z%Cj)?0>TUa1Jlw h71BAph6{KDmq-`z7OvnOyhpl%4{!}1;Soz!9OCHb>>3>JF=jx nRjrg%S(56XmR6ivqGV-ITdM#D$Yy}pPWcsj={ZRtIj|G}^%E6K literal 0 HcmV?d00001 diff --git a/specs/data/tilesets/tiles/i3dm/i3dmWithUri/tileset.json b/specs/data/tilesets/tiles/i3dm/i3dmWithUri/tileset.json new file mode 100644 index 00000000..878b164c --- /dev/null +++ b/specs/data/tilesets/tiles/i3dm/i3dmWithUri/tileset.json @@ -0,0 +1,19 @@ +{ + "asset" : { + "version" : "1.1" + }, + "geometricError" : 2.0, + "root" : { + "boundingVolume" : { + "box" : [ + 0.0, 0.0, 0.0, + 0.5, 0.0, 0.0, + 0.0, 0.5, 0.0, + 0.0, 0.0, 0.5 ] + }, + "geometricError" : 1.0, + "content": { + "uri": "i3dmWithUri.i3dm" + } + } +} \ No newline at end of file diff --git a/src/tileFormats/I3dmValidator.ts b/src/tileFormats/I3dmValidator.ts index 2a506568..582c80d6 100644 --- a/src/tileFormats/I3dmValidator.ts +++ b/src/tileFormats/I3dmValidator.ts @@ -266,8 +266,9 @@ export class I3dmValidator implements Validator { } } else { // The GLB data was a URI. Create the URI from the buffer, and remove - // any zero-bytes from the string that may be introduced by padding - const glbUri = glbData.toString().replace(/\0/g, ""); + // any zero-bytes and spaces from the string that may be introduced + // by padding + const glbUri = glbData.toString().replace(/\0/g, "").trim(); const resourceResolver = context.getResourceResolver(); const resolvedGlbData = await resourceResolver.resolveData(glbUri); if (!defined(resolvedGlbData)) { From ac451bf446d962f3955a2d67cb0c48a2638301b0 Mon Sep 17 00:00:00 2001 From: Marco Hutter Date: Mon, 12 Jun 2023 18:59:41 +0200 Subject: [PATCH 2/3] Report zero-bytes for URI padding with a warning --- specs/TilesetValidationSpec.ts | 3 ++- .../tilesets/tiles/i3dm/i3dmWithUri/README.md | 10 +++++++--- src/tileFormats/I3dmValidator.ts | 18 +++++++++++++++--- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/specs/TilesetValidationSpec.ts b/specs/TilesetValidationSpec.ts index efb84cec..1969c4f0 100644 --- a/specs/TilesetValidationSpec.ts +++ b/specs/TilesetValidationSpec.ts @@ -956,6 +956,7 @@ describe("Tileset validation", function () { const result = await Validators.validateTilesetFile( "specs/data/tilesets/tiles/i3dm/i3dmWithUri/tileset.json" ); - expect(result.length).toEqual(0); + expect(result.length).toEqual(1); + expect(result.get(0).type).toEqual("CONTENT_VALIDATION_WARNING"); }); }); diff --git a/specs/data/tilesets/tiles/i3dm/i3dmWithUri/README.md b/specs/data/tilesets/tiles/i3dm/i3dmWithUri/README.md index 03d678cd..128bc62a 100644 --- a/specs/data/tilesets/tiles/i3dm/i3dmWithUri/README.md +++ b/specs/data/tilesets/tiles/i3dm/i3dmWithUri/README.md @@ -8,6 +8,10 @@ GLB inside the GLB. The URI is `"Box.glb "`: It includes spaces, as a regression test for https://github.com/CesiumGS/3d-tiles-validator/issues/276 . -The string (including spaces) consists of 11 characters. In order -to achieve the alignment requirement, the payload data is padded -with _additional_ `0x00`s to achieve a payload length of 16 bytes. + +The string (including spaces) consists of 11 characters. + +In order to achieve the alignment requirement, the payload data is +padded with _additional_ `0x00` bytes to achieve a payload length +of 16 bytes. This is not allowed by the specification, and should +cause a WARNING during the validation. diff --git a/src/tileFormats/I3dmValidator.ts b/src/tileFormats/I3dmValidator.ts index 582c80d6..dd853a84 100644 --- a/src/tileFormats/I3dmValidator.ts +++ b/src/tileFormats/I3dmValidator.ts @@ -265,9 +265,21 @@ export class I3dmValidator implements Validator { result = false; } } else { - // The GLB data was a URI. Create the URI from the buffer, and remove - // any zero-bytes and spaces from the string that may be introduced - // by padding + // The GLB data was a URI, as indicated by `gltfFormat === 0`. + // The padding bytes in this case should be 0x20 (space) bytes, + // so issue a warning if the buffer contais 0x00 (zero) bytes. + if (glbData.includes("\0")) { + const message = + `The field containing the URI of the glTF asset contained ` + + `0x00 (zero)-bytes, but should only be padded with 0x20 (space) bytes`; + const issue = ContentValidationIssues.CONTENT_VALIDATION_WARNING( + uri, + message + ); + context.addIssue(issue); + } + // Create the URI from the buffer, and remove any bytes (zeros + // or trailing) that may be introduced by padding. const glbUri = glbData.toString().replace(/\0/g, "").trim(); const resourceResolver = context.getResourceResolver(); const resolvedGlbData = await resourceResolver.resolveData(glbUri); From 5c5d2af208bae7d1a31b702f8972832217a2a812 Mon Sep 17 00:00:00 2001 From: Marco Hutter Date: Mon, 12 Jun 2023 19:06:07 +0200 Subject: [PATCH 3/3] Updated CHANGES.md --- CHANGES.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 80f4d46d..3a03f855 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,8 @@ +Version ?.?.? - 2023-mm-dd + +- When an I3DM refers to an external glTF asset with a URI, then the URI has to be padded with `0x20` (space) bytes if necessary to satisfy the alignment requirements. The validator only accepted `0x00` (zero) bytes as padding bytes. Now the validator properly handles trailing spaces, and reports the presence of zero-bytes with a validation warning ([#276](https://github.com/CesiumGS/3d-tiles-validator/issues/276)) + Version 0.4.1 - 2023-05-02 - Moved most of the internal implementation into the `3d-tiles-tools`, and replaced it with a dependency to `3d-tiles-tools`