@itwin/core-common 3.6.0-dev.3 → 3.6.0-dev.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -1
- package/lib/cjs/ElementMesh.js +2 -2
- package/lib/cjs/ElementMesh.js.map +1 -1
- package/lib/cjs/IModelError.d.ts +10 -4
- package/lib/cjs/IModelError.d.ts.map +1 -1
- package/lib/cjs/IModelError.js +3 -4
- package/lib/cjs/IModelError.js.map +1 -1
- package/lib/cjs/Localization.d.ts.map +1 -1
- package/lib/cjs/Localization.js +8 -1
- package/lib/cjs/Localization.js.map +1 -1
- package/lib/cjs/RealityModelDisplaySettings.d.ts +65 -0
- package/lib/cjs/RealityModelDisplaySettings.d.ts.map +1 -1
- package/lib/cjs/RealityModelDisplaySettings.js +30 -2
- package/lib/cjs/RealityModelDisplaySettings.js.map +1 -1
- package/lib/cjs/core-common.d.ts +0 -1
- package/lib/cjs/core-common.d.ts.map +1 -1
- package/lib/cjs/core-common.js +0 -1
- package/lib/cjs/core-common.js.map +1 -1
- package/lib/cjs/tile/B3dmTileIO.js +5 -5
- package/lib/cjs/tile/B3dmTileIO.js.map +1 -1
- package/lib/cjs/tile/CompositeTileIO.js +2 -2
- package/lib/cjs/tile/CompositeTileIO.js.map +1 -1
- package/lib/cjs/tile/GltfTileIO.js +5 -5
- package/lib/cjs/tile/GltfTileIO.js.map +1 -1
- package/lib/cjs/tile/I3dmTileIO.js +6 -6
- package/lib/cjs/tile/I3dmTileIO.js.map +1 -1
- package/lib/cjs/tile/IModelTileIO.js +10 -10
- package/lib/cjs/tile/IModelTileIO.js.map +1 -1
- package/lib/cjs/tile/PntsTileIO.js +5 -5
- package/lib/cjs/tile/PntsTileIO.js.map +1 -1
- package/lib/cjs/tile/TileIO.js +3 -3
- package/lib/cjs/tile/TileIO.js.map +1 -1
- package/lib/esm/ElementMesh.js +2 -2
- package/lib/esm/ElementMesh.js.map +1 -1
- package/lib/esm/IModelError.d.ts +10 -4
- package/lib/esm/IModelError.d.ts.map +1 -1
- package/lib/esm/IModelError.js +3 -2
- package/lib/esm/IModelError.js.map +1 -1
- package/lib/esm/Localization.d.ts.map +1 -1
- package/lib/esm/Localization.js +8 -1
- package/lib/esm/Localization.js.map +1 -1
- package/lib/esm/RealityModelDisplaySettings.d.ts +65 -0
- package/lib/esm/RealityModelDisplaySettings.d.ts.map +1 -1
- package/lib/esm/RealityModelDisplaySettings.js +30 -2
- package/lib/esm/RealityModelDisplaySettings.js.map +1 -1
- package/lib/esm/core-common.d.ts +0 -1
- package/lib/esm/core-common.d.ts.map +1 -1
- package/lib/esm/core-common.js +0 -1
- package/lib/esm/core-common.js.map +1 -1
- package/lib/esm/tile/B3dmTileIO.js +5 -5
- package/lib/esm/tile/B3dmTileIO.js.map +1 -1
- package/lib/esm/tile/CompositeTileIO.js +2 -2
- package/lib/esm/tile/CompositeTileIO.js.map +1 -1
- package/lib/esm/tile/GltfTileIO.js +5 -5
- package/lib/esm/tile/GltfTileIO.js.map +1 -1
- package/lib/esm/tile/I3dmTileIO.js +6 -6
- package/lib/esm/tile/I3dmTileIO.js.map +1 -1
- package/lib/esm/tile/IModelTileIO.js +10 -10
- package/lib/esm/tile/IModelTileIO.js.map +1 -1
- package/lib/esm/tile/PntsTileIO.js +5 -5
- package/lib/esm/tile/PntsTileIO.js.map +1 -1
- package/lib/esm/tile/TileIO.js +3 -3
- package/lib/esm/tile/TileIO.js.map +1 -1
- package/package.json +7 -7
- package/lib/cjs/FeatureGates.d.ts +0 -32
- package/lib/cjs/FeatureGates.d.ts.map +0 -1
- package/lib/cjs/FeatureGates.js +0 -56
- package/lib/cjs/FeatureGates.js.map +0 -1
- package/lib/esm/FeatureGates.d.ts +0 -32
- package/lib/esm/FeatureGates.d.ts.map +0 -1
- package/lib/esm/FeatureGates.js +0 -52
- package/lib/esm/FeatureGates.js.map +0 -1
|
@@ -16,11 +16,11 @@ const TileIO_1 = require("./TileIO");
|
|
|
16
16
|
class B3dmHeader extends TileIO_1.TileHeader {
|
|
17
17
|
constructor(stream) {
|
|
18
18
|
super(stream);
|
|
19
|
-
this.length = stream.
|
|
20
|
-
this.featureTableJsonLength = stream.
|
|
21
|
-
this.featureTableBinaryLength = stream.
|
|
22
|
-
this.batchTableJsonLength = stream.
|
|
23
|
-
this.batchTableBinaryLength = stream.
|
|
19
|
+
this.length = stream.readUint32();
|
|
20
|
+
this.featureTableJsonLength = stream.readUint32();
|
|
21
|
+
this.featureTableBinaryLength = stream.readUint32();
|
|
22
|
+
this.batchTableJsonLength = stream.readUint32();
|
|
23
|
+
this.batchTableBinaryLength = stream.readUint32();
|
|
24
24
|
// Keep this legacy check in for now since a lot of tilesets are still using the old header.
|
|
25
25
|
// Legacy header #1: [batchLength] [batchTableByteLength]
|
|
26
26
|
// Legacy header #2: [batchTableJsonByteLength] [batchTableBinaryByteLength] [batchLength]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"B3dmTileIO.js","sourceRoot":"","sources":["../../../src/tile/B3dmTileIO.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA+D;AAC/D,qCAAkD;AAElD;;GAEG;AACH,MAAa,UAAW,SAAQ,mBAAU;IAUxC,YAAmB,MAAkB;QACnC,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"B3dmTileIO.js","sourceRoot":"","sources":["../../../src/tile/B3dmTileIO.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA+D;AAC/D,qCAAkD;AAElD;;GAEG;AACH,MAAa,UAAW,SAAQ,mBAAU;IAUxC,YAAmB,MAAkB;QACnC,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QAClC,IAAI,CAAC,sBAA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,QAAQ,CAAC,CAAC;SAChD;QAED,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;QAC9C,IAAI,CAAC,KAAK,IAAI,CAAC,oBAAoB,EAAE;YACnC,MAAM,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;YACjE,MAAM,QAAQ,GAAG,IAAA,2BAAY,EAAC,YAAY,CAAC,CAAC;YAC5C,IAAI,QAAQ;gBACV,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;SAC9C;QAED,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QAE5C,IAAI,MAAM,CAAC,YAAY;YACrB,IAAI,CAAC,UAAU,EAAE,CAAC;IACtB,CAAC;IApDD,IAAW,OAAO,KAAc,OAAO,mBAAU,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;CAqD1E;AA7DD,gCA6DC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tile\r\n */\r\n\r\nimport { ByteStream, utf8ToString } from \"@itwin/core-bentley\";\r\nimport { TileFormat, TileHeader } from \"./TileIO\";\r\n\r\n/** Header preceding tile content in [b3dm](https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification/TileFormats/Batched3DModel) format.\r\n * @internal\r\n */\r\nexport class B3dmHeader extends TileHeader {\r\n public readonly length: number;\r\n public readonly featureTableJsonLength: number;\r\n public readonly featureTableBinaryLength: number;\r\n public readonly batchTableJsonLength: number;\r\n public readonly batchTableBinaryLength: number;\r\n public readonly featureTableJson: any;\r\n public readonly batchTableJson: any;\r\n public get isValid(): boolean { return TileFormat.B3dm === this.format; }\r\n\r\n public constructor(stream: ByteStream) {\r\n super(stream);\r\n this.length = stream.readUint32();\r\n this.featureTableJsonLength = stream.readUint32();\r\n this.featureTableBinaryLength = stream.readUint32();\r\n this.batchTableJsonLength = stream.readUint32();\r\n this.batchTableBinaryLength = stream.readUint32();\r\n\r\n // Keep this legacy check in for now since a lot of tilesets are still using the old header.\r\n // Legacy header #1: [batchLength] [batchTableByteLength]\r\n // Legacy header #2: [batchTableJsonByteLength] [batchTableBinaryByteLength] [batchLength]\r\n // Current header: [featureTableJsonByteLength] [featureTableBinaryByteLength] [batchTableJsonByteLength] [batchTableBinaryByteLength]\r\n // If the header is in the first legacy format 'batchTableJsonByteLength' will be the start of the JSON string (a quotation mark) or the glTF magic.\r\n // Accordingly its first byte will be either 0x22 or 0x67, and so the minimum uint32 expected is 0x22000000 = 570425344 = 570MB. It is unlikely that the feature table Json will exceed this length.\r\n // The check for the second legacy format is similar, except it checks 'batchTableBinaryByteLength' instead\r\n if (this.batchTableJsonLength >= 570425344) {\r\n // First legacy check\r\n stream.curPos = 20;\r\n this.batchTableJsonLength = this.featureTableBinaryLength;\r\n this.batchTableBinaryLength = 0;\r\n this.featureTableJsonLength = 0;\r\n this.featureTableBinaryLength = 0;\r\n } else if (this.batchTableBinaryLength >= 570425344) {\r\n // Second legacy check\r\n stream.curPos = 24;\r\n this.batchTableJsonLength = this.featureTableJsonLength;\r\n this.batchTableBinaryLength = this.featureTableBinaryLength;\r\n this.featureTableJsonLength = 0;\r\n this.featureTableBinaryLength = 0;\r\n }\r\n\r\n if (0 !== this.featureTableJsonLength) {\r\n const sceneStrData = stream.nextBytes(this.featureTableJsonLength);\r\n const sceneStr = utf8ToString(sceneStrData);\r\n if (sceneStr)\r\n this.featureTableJson = JSON.parse(sceneStr);\r\n }\r\n\r\n stream.advance(this.featureTableBinaryLength);\r\n if (0 !== this.batchTableJsonLength) {\r\n const batchStrData = stream.nextBytes(this.batchTableJsonLength);\r\n const batchStr = utf8ToString(batchStrData);\r\n if (batchStr)\r\n this.batchTableJson = JSON.parse(batchStr);\r\n }\r\n\r\n stream.advance(this.batchTableBinaryLength);\r\n\r\n if (stream.isPastTheEnd)\r\n this.invalidate();\r\n }\r\n}\r\n"]}
|
|
@@ -15,8 +15,8 @@ const TileIO_1 = require("./TileIO");
|
|
|
15
15
|
class CompositeTileHeader extends TileIO_1.TileHeader {
|
|
16
16
|
constructor(stream) {
|
|
17
17
|
super(stream);
|
|
18
|
-
this.length = stream.
|
|
19
|
-
this.tileCount = stream.
|
|
18
|
+
this.length = stream.readUint32();
|
|
19
|
+
this.tileCount = stream.readUint32();
|
|
20
20
|
this.tilePosition = stream.curPos;
|
|
21
21
|
if (stream.isPastTheEnd)
|
|
22
22
|
this.invalidate();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompositeTileIO.js","sourceRoot":"","sources":["../../../src/tile/CompositeTileIO.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,qCAAkD;AAElD;;GAEG;AACH,MAAa,mBAAoB,SAAQ,mBAAU;IAOjD,YAAmB,MAAkB;QACnC,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"CompositeTileIO.js","sourceRoot":"","sources":["../../../src/tile/CompositeTileIO.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,qCAAkD;AAElD;;GAEG;AACH,MAAa,mBAAoB,SAAQ,mBAAU;IAOjD,YAAmB,MAAkB;QACnC,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QAClC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QACrC,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC;QAElC,IAAI,MAAM,CAAC,YAAY;YACrB,IAAI,CAAC,UAAU,EAAE,CAAC;IACtB,CAAC;IAVD,IAAW,OAAO,KAAc,OAAO,mBAAU,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;CAW1E;AAhBD,kDAgBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tile\r\n */\r\n\r\nimport { ByteStream } from \"@itwin/core-bentley\";\r\nimport { TileFormat, TileHeader } from \"./TileIO\";\r\n\r\n/** Header preceding tile content in [composite](https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification/TileFormats/Composite) format, containing any number of tiles in other standard 3D tile formats.\r\n * @internal\r\n */\r\nexport class CompositeTileHeader extends TileHeader {\r\n public readonly length: number;\r\n public readonly tileCount: number;\r\n public readonly tilePosition: number;\r\n\r\n public get isValid(): boolean { return TileFormat.Cmpt === this.format; }\r\n\r\n public constructor(stream: ByteStream) {\r\n super(stream);\r\n this.length = stream.readUint32();\r\n this.tileCount = stream.readUint32();\r\n this.tilePosition = stream.curPos;\r\n\r\n if (stream.isPastTheEnd)\r\n this.invalidate();\r\n }\r\n}\r\n"]}
|
|
@@ -30,8 +30,8 @@ function consumeNextChunk(stream) {
|
|
|
30
30
|
if (stream.isAtTheEnd)
|
|
31
31
|
return undefined;
|
|
32
32
|
const offset = stream.curPos + 8;
|
|
33
|
-
const length = stream.
|
|
34
|
-
const type = stream.
|
|
33
|
+
const length = stream.readUint32();
|
|
34
|
+
const type = stream.readUint32();
|
|
35
35
|
stream.advance(length);
|
|
36
36
|
return stream.isPastTheEnd ? false : { offset, length, type };
|
|
37
37
|
}
|
|
@@ -42,9 +42,9 @@ class GlbHeader extends TileIO_1.TileHeader {
|
|
|
42
42
|
this.gltfLength = 0;
|
|
43
43
|
this.jsonChunk = { offset: 0, length: 0 };
|
|
44
44
|
this.additionalChunks = [];
|
|
45
|
-
this.gltfLength = stream.
|
|
46
|
-
const jsonLength = stream.
|
|
47
|
-
const word5 = stream.
|
|
45
|
+
this.gltfLength = stream.readUint32();
|
|
46
|
+
const jsonLength = stream.readUint32();
|
|
47
|
+
const word5 = stream.readUint32();
|
|
48
48
|
// Early versions of the reality data tile publisher incorrectly put version 2 into header - handle these old tiles
|
|
49
49
|
// validating the chunk type.
|
|
50
50
|
if (this.version === GltfVersions.Version2 && word5 === GltfVersions.Gltf1SceneFormat)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GltfTileIO.js","sourceRoot":"","sources":["../../../src/tile/GltfTileIO.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAyD;AACzD,qCAAkD;AAElD;;GAEG;AACH,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,uDAAY,CAAA;IACZ,uDAAY,CAAA;IACZ,mEAAyB,CAAA;IACzB,uEAAoB,CAAA;AACtB,CAAC,EALW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAKvB;AAED,gBAAgB;AAChB,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,gEAAiB,CAAA;IACjB,iEAAmB,CAAA;AACrB,CAAC,EAHW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAG3B;AAmBD,SAAS,gBAAgB,CAAC,MAAkB;IAC1C,IAAI,MAAM,CAAC,UAAU;QACnB,OAAO,SAAS,CAAC;IAEnB,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"GltfTileIO.js","sourceRoot":"","sources":["../../../src/tile/GltfTileIO.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAyD;AACzD,qCAAkD;AAElD;;GAEG;AACH,IAAY,YAKX;AALD,WAAY,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U,EAAE,CAAC;gCAClB,OAAO;6BACR;4BAED,IAAI,CAAC,WAAW,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;4BAClE,MAAM;wBACR;4BACE,kEAAkE;4BAClE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;4BAClC,MAAM;qBACT;iBACF;gBAED,IAAI,KAAK,KAAK,KAAK,EAAE;oBACnB,IAAI,CAAC,UAAU,EAAE,CAAC;oBAClB,OAAO;iBACR;gBAED,IAAA,qBAAM,EAAC,SAAS,KAAK,KAAK,CAAC,CAAC;gBAC5B,IAAA,qBAAM,EAAC,MAAM,CAAC,UAAU,CAAC,CAAC;gBAC1B,MAAM;YACR;gBACE,IAAI,CAAC,UAAU,EAAE,CAAC;gBAClB,MAAM;SACT;IACH,CAAC;IA1ED,IAAW,OAAO;QAChB,OAAO,mBAAU,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM,CAAC;IACzC,CAAC;CAyEF;AAjFD,8BAiFC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tile\r\n */\r\n\r\nimport { assert, ByteStream } from \"@itwin/core-bentley\";\r\nimport { TileFormat, TileHeader } from \"./TileIO\";\r\n\r\n/** Known version of the [glTF format](https://www.khronos.org/gltf/).\r\n * @internal\r\n */\r\nexport enum GltfVersions {\r\n Version1 = 1,\r\n Version2 = 2,\r\n CurrentVersion = Version1,\r\n Gltf1SceneFormat = 0,\r\n}\r\n\r\n/** @internal */\r\nexport enum GltfV2ChunkTypes {\r\n JSON = 0x4E4F534a,\r\n Binary = 0x004E4942,\r\n}\r\n\r\n/** A chunk of a glb file.\r\n * @internal\r\n */\r\nexport interface GltfChunk {\r\n /** Offset of the first byte of the chunk's data relative to the beginning of the glb data.\r\n * This excludes the 8-byte chunk header containing the length and type fields.\r\n */\r\n offset: number;\r\n /** The number of bytes in the chunk's data. */\r\n length: number;\r\n}\r\n\r\n/** Describes a glTF chunk's data along with its type.\r\n * @internal\r\n */\r\nexport type TypedGltfChunk = GltfChunk & { type: number };\r\n\r\nfunction consumeNextChunk(stream: ByteStream): TypedGltfChunk | undefined | false {\r\n if (stream.isAtTheEnd)\r\n return undefined;\r\n\r\n const offset = stream.curPos + 8;\r\n const length = stream.readUint32();\r\n const type = stream.readUint32();\r\n stream.advance(length);\r\n return stream.isPastTheEnd ? false : { offset, length, type };\r\n}\r\n\r\n/** @internal */\r\nexport class GlbHeader extends TileHeader {\r\n public readonly gltfLength: number = 0;\r\n public readonly jsonChunk: GltfChunk = { offset: 0, length: 0 };\r\n public readonly binaryChunk?: GltfChunk;\r\n public readonly additionalChunks: TypedGltfChunk[] = [];\r\n\r\n public get isValid(): boolean {\r\n return TileFormat.Gltf === this.format;\r\n }\r\n\r\n public constructor(stream: ByteStream) {\r\n super(stream);\r\n this.gltfLength = stream.readUint32();\r\n\r\n const jsonLength = stream.readUint32();\r\n const word5 = stream.readUint32();\r\n\r\n // Early versions of the reality data tile publisher incorrectly put version 2 into header - handle these old tiles\r\n // validating the chunk type.\r\n if (this.version === GltfVersions.Version2 && word5 === GltfVersions.Gltf1SceneFormat)\r\n this.version = GltfVersions.Version1;\r\n\r\n this.jsonChunk = { offset: stream.curPos, length: jsonLength };\r\n switch (this.version) {\r\n case GltfVersions.Version1:\r\n if (GltfVersions.Gltf1SceneFormat !== word5) {\r\n this.invalidate();\r\n return;\r\n }\r\n\r\n const binaryOffset = stream.curPos + jsonLength;\r\n this.binaryChunk = { offset: binaryOffset, length: this.gltfLength - binaryOffset };\r\n break;\r\n case GltfVersions.Version2:\r\n if (word5 !== GltfV2ChunkTypes.JSON) {\r\n this.invalidate();\r\n return;\r\n }\r\n\r\n stream.advance(jsonLength);\r\n if (stream.isPastTheEnd) {\r\n this.invalidate();\r\n return;\r\n }\r\n\r\n let chunk;\r\n while (chunk = consumeNextChunk(stream)) {\r\n switch (chunk.type) {\r\n case GltfV2ChunkTypes.JSON:\r\n // Only one JSON chunk permitted and it must be the first.\r\n this.invalidate();\r\n return;\r\n case GltfV2ChunkTypes.Binary:\r\n // At most one binary chunk permitted and it must be the second if present.\r\n if (this.binaryChunk || this.additionalChunks.length) {\r\n this.invalidate();\r\n return;\r\n }\r\n\r\n this.binaryChunk = { offset: chunk.offset, length: chunk.length };\r\n break;\r\n default:\r\n // Any other chunk type should be ignored - for use by extensions.\r\n this.additionalChunks.push(chunk);\r\n break;\r\n }\r\n }\r\n\r\n if (false === chunk) {\r\n this.invalidate();\r\n return;\r\n }\r\n\r\n assert(undefined === chunk);\r\n assert(stream.isAtTheEnd);\r\n break;\r\n default:\r\n this.invalidate();\r\n break;\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -16,12 +16,12 @@ const TileIO_1 = require("./TileIO");
|
|
|
16
16
|
class I3dmHeader extends TileIO_1.TileHeader {
|
|
17
17
|
constructor(stream) {
|
|
18
18
|
super(stream);
|
|
19
|
-
this.length = stream.
|
|
20
|
-
this.featureTableJsonLength = stream.
|
|
21
|
-
this.featureTableBinaryLength = stream.
|
|
22
|
-
this.batchTableJsonLength = stream.
|
|
23
|
-
this.batchTableBinaryLength = stream.
|
|
24
|
-
this.gltfVersion = stream.
|
|
19
|
+
this.length = stream.readUint32();
|
|
20
|
+
this.featureTableJsonLength = stream.readUint32();
|
|
21
|
+
this.featureTableBinaryLength = stream.readUint32();
|
|
22
|
+
this.batchTableJsonLength = stream.readUint32();
|
|
23
|
+
this.batchTableBinaryLength = stream.readUint32();
|
|
24
|
+
this.gltfVersion = stream.readUint32();
|
|
25
25
|
this.featureTableJsonPosition = stream.curPos;
|
|
26
26
|
stream.advance(this.featureTableJsonLength);
|
|
27
27
|
stream.advance(this.featureTableBinaryLength);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"I3dmTileIO.js","sourceRoot":"","sources":["../../../src/tile/I3dmTileIO.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA+D;AAC/D,qCAAkD;AAElD;;GAEG;AACH,MAAa,UAAW,SAAQ,mBAAU;IAWxC,YAAmB,MAAkB;QACnC,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"I3dmTileIO.js","sourceRoot":"","sources":["../../../src/tile/I3dmTileIO.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA+D;AAC/D,qCAAkD;AAElD;;GAEG;AACH,MAAa,UAAW,SAAQ,mBAAU;IAWxC,YAAmB,MAAkB;QACnC,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QAClC,IAAI,CAAC,sBAAsB,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QAClD,IAAI,CAAC,wBAAwB,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QACpD,IAAI,CAAC,oBAAoB,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QAChD,IAAI,CAAC,sBAAsB,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QAClD,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QACvC,IAAI,CAAC,wBAAwB,GAAG,MAAM,CAAC,MAAM,CAAC;QAC9C,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QAC5C,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;QAC9C,IAAI,CAAC,KAAK,IAAI,CAAC,oBAAoB,EAAE;YACnC,MAAM,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;YACjE,MAAM,QAAQ,GAAG,IAAA,2BAAY,EAAC,YAAY,CAAC,CAAC;YAC5C,IAAI,QAAQ;gBACV,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;SAC9C;QACD,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QAE5C,IAAI,MAAM,CAAC,YAAY;YACrB,IAAI,CAAC,UAAU,EAAE,CAAC;IACtB,CAAC;IAvBD,IAAW,OAAO,KAAc,OAAO,mBAAU,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;CAwB1E;AAjCD,gCAiCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tile\r\n */\r\n\r\nimport { ByteStream, utf8ToString } from \"@itwin/core-bentley\";\r\nimport { TileFormat, TileHeader } from \"./TileIO\";\r\n\r\n/** Header preceding tile content in [i3dm](https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification/TileFormats/Instanced3DModel) format.\r\n * @internal\r\n */\r\nexport class I3dmHeader extends TileHeader {\r\n public readonly length: number;\r\n public readonly featureTableJsonPosition: number;\r\n public readonly featureTableJsonLength: number;\r\n public readonly featureTableBinaryLength: number;\r\n public readonly batchTableJsonLength: number;\r\n public readonly batchTableBinaryLength: number;\r\n public readonly gltfVersion: number;\r\n public readonly batchTableJson: any;\r\n public get isValid(): boolean { return TileFormat.I3dm === this.format; }\r\n\r\n public constructor(stream: ByteStream) {\r\n super(stream);\r\n this.length = stream.readUint32();\r\n this.featureTableJsonLength = stream.readUint32();\r\n this.featureTableBinaryLength = stream.readUint32();\r\n this.batchTableJsonLength = stream.readUint32();\r\n this.batchTableBinaryLength = stream.readUint32();\r\n this.gltfVersion = stream.readUint32();\r\n this.featureTableJsonPosition = stream.curPos;\r\n stream.advance(this.featureTableJsonLength);\r\n stream.advance(this.featureTableBinaryLength);\r\n if (0 !== this.batchTableJsonLength) {\r\n const batchStrData = stream.nextBytes(this.batchTableJsonLength);\r\n const batchStr = utf8ToString(batchStrData);\r\n if (batchStr)\r\n this.batchTableJson = JSON.parse(batchStr);\r\n }\r\n stream.advance(this.batchTableBinaryLength);\r\n\r\n if (stream.isPastTheEnd)\r\n this.invalidate();\r\n }\r\n}\r\n"]}
|
|
@@ -51,17 +51,17 @@ class ImdlHeader extends TileIO_1.TileHeader {
|
|
|
51
51
|
*/
|
|
52
52
|
constructor(stream) {
|
|
53
53
|
super(stream);
|
|
54
|
-
this.headerLength = stream.
|
|
55
|
-
this.flags = stream.
|
|
54
|
+
this.headerLength = stream.readUint32();
|
|
55
|
+
this.flags = stream.readUint32();
|
|
56
56
|
this.contentRange = new core_geometry_1.Range3d();
|
|
57
57
|
(0, TileIO_1.nextPoint3d64FromByteStream)(stream, this.contentRange.low);
|
|
58
58
|
(0, TileIO_1.nextPoint3d64FromByteStream)(stream, this.contentRange.high);
|
|
59
|
-
this.tolerance = stream.
|
|
60
|
-
this.numElementsIncluded = stream.
|
|
61
|
-
this.numElementsExcluded = stream.
|
|
62
|
-
this.tileLength = stream.
|
|
59
|
+
this.tolerance = stream.readFloat64();
|
|
60
|
+
this.numElementsIncluded = stream.readUint32();
|
|
61
|
+
this.numElementsExcluded = stream.readUint32();
|
|
62
|
+
this.tileLength = stream.readUint32();
|
|
63
63
|
// empty sub-volume bit field introduced in format v02.00
|
|
64
|
-
this.emptySubRanges = this.versionMajor >= 2 ? stream.
|
|
64
|
+
this.emptySubRanges = this.versionMajor >= 2 ? stream.readUint32() : 0;
|
|
65
65
|
// Skip any unprocessed bytes in header
|
|
66
66
|
const remainingHeaderBytes = this.headerLength - stream.curPos;
|
|
67
67
|
(0, core_bentley_1.assert)(remainingHeaderBytes >= 0);
|
|
@@ -85,9 +85,9 @@ class FeatureTableHeader {
|
|
|
85
85
|
this.count = count;
|
|
86
86
|
}
|
|
87
87
|
static readFrom(stream) {
|
|
88
|
-
const length = stream.
|
|
89
|
-
const maxFeatures = stream.
|
|
90
|
-
const count = stream.
|
|
88
|
+
const length = stream.readUint32();
|
|
89
|
+
const maxFeatures = stream.readUint32();
|
|
90
|
+
const count = stream.readUint32();
|
|
91
91
|
return stream.isPastTheEnd ? undefined : new FeatureTableHeader(length, maxFeatures, count);
|
|
92
92
|
}
|
|
93
93
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelTileIO.js","sourceRoot":"","sources":["../../../src/tile/IModelTileIO.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAyD;AACzD,wDAA+C;AAE/C,qCAA+E;AAE/E;;GAEG;AACH,IAAY,SASX;AATD,WAAY,SAAS;IACnB,uBAAuB;IACvB,yCAAQ,CAAA;IACR,6CAA6C;IAC7C,6DAAuB,CAAA;IACvB,wEAAwE;IACxE,qDAAmB,CAAA;IACnB,mEAAmE;IACnE,2EAA8B,CAAA;AAChC,CAAC,EATW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QASpB;AAED;;GAEG;AACH,IAAY,kBAYX;AAZD,WAAY,kBAAkB;IAC5B;;;OAGG;IACH,8DAAU,CAAA;IACV;;OAEG;IACH,6DAAS,CAAA;IACT,kGAAkG;IAClG,yEAAkC,CAAA;AACpC,CAAC,EAZW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAY7B;AAED;;GAEG;AACH,MAAa,UAAW,SAAQ,mBAAU;IAwBxC;;OAEG;IACH,YAAmB,MAAkB;QACnC,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"IModelTileIO.js","sourceRoot":"","sources":["../../../src/tile/IModelTileIO.ts"],"names":[],"mappings":";AA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AY,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,kBAAkB,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;IAC9F,CAAC;;AANH,gDAaC;AALe,8BAAW,GAAG,EAAE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tile\r\n */\r\n\r\nimport { assert, ByteStream } from \"@itwin/core-bentley\";\r\nimport { Range3d } from \"@itwin/core-geometry\";\r\nimport { ElementAlignedBox3d } from \"../geometry/Placement\";\r\nimport { nextPoint3d64FromByteStream, TileFormat, TileHeader } from \"./TileIO\";\r\n\r\n/** Flags describing the geometry contained within a tile in iMdl format.\r\n * @internal\r\n */\r\nexport enum ImdlFlags {\r\n /** No special flags */\r\n None = 0,\r\n /** The tile contains some curved geometry */\r\n ContainsCurves = 1 << 0,\r\n /** Some geometry within the tile range was omitted based on its size */\r\n Incomplete = 1 << 2,\r\n /** The tile must be refined by sub-division, not magnification. */\r\n DisallowMagnification = 1 << 3,\r\n}\r\n\r\n/** Describes the maximum major and minor version of the iMdl tile format supported by this version of this package.\r\n * @internal\r\n */\r\nexport enum CurrentImdlVersion {\r\n /** The unsigned 16-bit major version number. If the major version specified in the tile header is greater than this value, then this\r\n * front-end is not capable of reading the tile content. Otherwise, this front-end can read the tile content even if the header specifies a\r\n * greater minor version than CurrentVersion.Minor, although some data may be skipped.\r\n */\r\n Major = 29,\r\n /** The unsigned 16-bit minor version number. If the major version in the tile header is equal to CurrentVersion.Major, then this package can\r\n * read the tile content even if the minor version in the tile header is greater than this value, although some data may be skipped.\r\n */\r\n Minor = 0,\r\n /** The unsigned 32-bit version number derived from the 16-bit major and minor version numbers. */\r\n Combined = (Major << 0x10) | Minor,\r\n}\r\n\r\n/** Header embedded at the beginning of binary tile data in iMdl format describing its contents.\r\n * @internal\r\n */\r\nexport class ImdlHeader extends TileHeader {\r\n /** The size of this header in bytes. */\r\n public readonly headerLength: number;\r\n /** Flags describing the geometry contained within the tile */\r\n public readonly flags: ImdlFlags;\r\n /** A bounding box no larger than the tile's range, tightly enclosing the tile's geometry; or a null range if the tile is empty */\r\n public readonly contentRange: ElementAlignedBox3d;\r\n /** The chord tolerance in meters at which the tile's geometry was faceted */\r\n public readonly tolerance: number;\r\n /** The number of elements which contributed at least some geometry to the tile content */\r\n public readonly numElementsIncluded: number;\r\n /** The number of elements within the tile range which contributed no geometry to the tile content */\r\n public readonly numElementsExcluded: number;\r\n /** The total number of bytes in the binary tile data, including this header */\r\n public readonly tileLength: number;\r\n /** A bitfield wherein each set bit indicates an empty sub-volume. */\r\n public readonly emptySubRanges: number;\r\n\r\n public get versionMajor(): number { return this.version >>> 0x10; }\r\n public get versionMinor(): number { return (this.version & 0xffff) >>> 0; }\r\n\r\n public get isValid(): boolean { return TileFormat.IModel === this.format; }\r\n public get isReadableVersion(): boolean { return this.versionMajor <= CurrentImdlVersion.Major; }\r\n\r\n /** Deserialize a header from the binary data at the stream's current position.\r\n * If the binary data does not contain a valid header, the Header will be marked 'invalid'.\r\n */\r\n public constructor(stream: ByteStream) {\r\n super(stream);\r\n this.headerLength = stream.readUint32();\r\n this.flags = stream.readUint32();\r\n\r\n this.contentRange = new Range3d();\r\n nextPoint3d64FromByteStream(stream, this.contentRange.low);\r\n nextPoint3d64FromByteStream(stream, this.contentRange.high);\r\n\r\n this.tolerance = stream.readFloat64();\r\n this.numElementsIncluded = stream.readUint32();\r\n this.numElementsExcluded = stream.readUint32();\r\n this.tileLength = stream.readUint32();\r\n\r\n // empty sub-volume bit field introduced in format v02.00\r\n this.emptySubRanges = this.versionMajor >= 2 ? stream.readUint32() : 0;\r\n\r\n // Skip any unprocessed bytes in header\r\n const remainingHeaderBytes = this.headerLength - stream.curPos;\r\n assert(remainingHeaderBytes >= 0);\r\n stream.advance(remainingHeaderBytes);\r\n\r\n if (stream.isPastTheEnd)\r\n this.invalidate();\r\n }\r\n}\r\n\r\n/** Header preceding the feature table embedded in an iMdl tile's content.\r\n * @internal\r\n */\r\nexport class FeatureTableHeader {\r\n public static readFrom(stream: ByteStream) {\r\n const length = stream.readUint32();\r\n const maxFeatures = stream.readUint32();\r\n const count = stream.readUint32();\r\n return stream.isPastTheEnd ? undefined : new FeatureTableHeader(length, maxFeatures, count);\r\n }\r\n\r\n public static sizeInBytes = 12;\r\n\r\n private constructor(public readonly length: number,\r\n public readonly maxFeatures: number,\r\n public readonly count: number) { }\r\n}\r\n"]}
|
|
@@ -15,11 +15,11 @@ const TileIO_1 = require("./TileIO");
|
|
|
15
15
|
class PntsHeader extends TileIO_1.TileHeader {
|
|
16
16
|
constructor(stream) {
|
|
17
17
|
super(stream);
|
|
18
|
-
this.length = stream.
|
|
19
|
-
this.featureTableJsonLength = stream.
|
|
20
|
-
this.featureTableBinaryLength = stream.
|
|
21
|
-
this.batchTableJsonLength = stream.
|
|
22
|
-
this.batchTableBinaryLength = stream.
|
|
18
|
+
this.length = stream.readUint32();
|
|
19
|
+
this.featureTableJsonLength = stream.readUint32();
|
|
20
|
+
this.featureTableBinaryLength = stream.readUint32();
|
|
21
|
+
this.batchTableJsonLength = stream.readUint32();
|
|
22
|
+
this.batchTableBinaryLength = stream.readUint32();
|
|
23
23
|
}
|
|
24
24
|
get isValid() { return TileIO_1.TileFormat.Pnts === this.format; }
|
|
25
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PntsTileIO.js","sourceRoot":"","sources":["../../../src/tile/PntsTileIO.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,qCAAkD;AAElD;;GAEG;AACH,MAAa,UAAW,SAAQ,mBAAU;IAQxC,YAAmB,MAAkB;QACnC,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"PntsTileIO.js","sourceRoot":"","sources":["../../../src/tile/PntsTileIO.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,qCAAkD;AAElD;;GAEG;AACH,MAAa,UAAW,SAAQ,mBAAU;IAQxC,YAAmB,MAAkB;QACnC,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QAClC,IAAI,CAAC,sBAAsB,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QAClD,IAAI,CAAC,wBAAwB,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QACpD,IAAI,CAAC,oBAAoB,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QAChD,IAAI,CAAC,sBAAsB,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;IACpD,CAAC;IATD,IAAW,OAAO,KAAc,OAAO,mBAAU,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;CAU1E;AAhBD,gCAgBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tile\r\n */\r\n\r\nimport { ByteStream } from \"@itwin/core-bentley\";\r\nimport { TileFormat, TileHeader } from \"./TileIO\";\r\n\r\n/** Header preceding tile content in [pnts](https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification/TileFormats/PointCloud) format.\r\n * @internal\r\n */\r\nexport class PntsHeader extends TileHeader {\r\n public readonly length: number;\r\n public readonly featureTableJsonLength: number;\r\n public readonly featureTableBinaryLength: number;\r\n public readonly batchTableJsonLength: number;\r\n public readonly batchTableBinaryLength: number;\r\n public get isValid(): boolean { return TileFormat.Pnts === this.format; }\r\n\r\n public constructor(stream: ByteStream) {\r\n super(stream);\r\n this.length = stream.readUint32();\r\n this.featureTableJsonLength = stream.readUint32();\r\n this.featureTableBinaryLength = stream.readUint32();\r\n this.batchTableJsonLength = stream.readUint32();\r\n this.batchTableBinaryLength = stream.readUint32();\r\n }\r\n}\r\n"]}
|
package/lib/cjs/tile/TileIO.js
CHANGED
|
@@ -95,8 +95,8 @@ exports.TileReadError = TileReadError;
|
|
|
95
95
|
class TileHeader {
|
|
96
96
|
/** Construct a Header from the binary data at the supplied stream's current read position */
|
|
97
97
|
constructor(stream) {
|
|
98
|
-
this._format = tileFormatFromNumber(stream.
|
|
99
|
-
this.version = stream.
|
|
98
|
+
this._format = tileFormatFromNumber(stream.readUint32());
|
|
99
|
+
this.version = stream.readUint32();
|
|
100
100
|
}
|
|
101
101
|
get format() { return this._format; }
|
|
102
102
|
/** Mark the header as representing invalid data */
|
|
@@ -109,7 +109,7 @@ exports.TileHeader = TileHeader;
|
|
|
109
109
|
* @internal
|
|
110
110
|
*/
|
|
111
111
|
function nextPoint3d64FromByteStream(stream, result) {
|
|
112
|
-
const x = stream.
|
|
112
|
+
const x = stream.readFloat64(), y = stream.readFloat64(), z = stream.readFloat64();
|
|
113
113
|
if (undefined === result)
|
|
114
114
|
return new core_geometry_1.Point3d(x, y, z);
|
|
115
115
|
result.set(x, y, z);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileIO.js","sourceRoot":"","sources":["../../../src/tile/TileIO.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA+D;AAC/D,wDAA+C;AAE/C;;GAEG;AACH,IAAY,UASX;AATD,WAAY,UAAU;IACpB,iDAAW,CAAA;IACX,oDAAiB,CAAA;IACjB,oDAAiB,CAAA;IACjB,oDAAiB,CAAA;IACjB,wDAAmB,CAAA;IACnB,oDAAiB,CAAA;IACjB,oDAAiB,CAAA;IACjB,+CAAc,CAAA;AAChB,CAAC,EATW,UAAU,GAAV,kBAAU,KAAV,kBAAU,Q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nBD,gCAmBC;AAED;;GAEG;AACH,SAAgB,2BAA2B,CAAC,MAAkB,EAAE,MAAgB;IAC9E,MAAM,CAAC,GAAG,MAAM,CAAC,WAAW,EAAE,EAC5B,CAAC,GAAG,MAAM,CAAC,WAAW,EAAE,EACxB,CAAC,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;IAE3B,IAAI,SAAS,KAAK,MAAM;QACtB,OAAO,IAAI,uBAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAE9B,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACpB,OAAO,MAAM,CAAC;AAChB,CAAC;AAVD,kEAUC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tile\r\n */\r\n\r\nimport { BentleyError, ByteStream } from \"@itwin/core-bentley\";\r\nimport { Point3d } from \"@itwin/core-geometry\";\r\n\r\n/** Type codes for various tile formats. Often these are embedded as 32-bit 'magic numbers' in a binary stream to indicate the format.\r\n * @internal\r\n */\r\nexport enum TileFormat {\r\n Unknown = 0,\r\n B3dm = 0x6d643362, // \"b3dm\"\r\n Gltf = 0x46546c67, // \"glTF\"\r\n Pnts = 0x73746e70, // \"pnts\"\r\n IModel = 0x6c644d69, // \"iMdl\"\r\n Cmpt = 0x74706d63, // cmpt\r\n I3dm = 0x6d643369, // i3dm\r\n A3x = 0x583341, // A3X0 (numeric 0 not char '0')\r\n}\r\n\r\n/** Given a magic number, return whether it identifies a known tile format.\r\n * @internal\r\n */\r\nexport function isKnownTileFormat(format: number) {\r\n switch (format) {\r\n case TileFormat.Unknown:\r\n case TileFormat.B3dm:\r\n case TileFormat.Gltf:\r\n case TileFormat.IModel:\r\n case TileFormat.Pnts:\r\n case TileFormat.Cmpt:\r\n case TileFormat.I3dm:\r\n case TileFormat.A3x:\r\n return true;\r\n default:\r\n return false;\r\n }\r\n}\r\n\r\n/** Given a magic number, attempt to convert it to a known TileFormat.\r\n * @internal\r\n */\r\nexport function tileFormatFromNumber(formatNumber: number): TileFormat {\r\n const format = formatNumber as TileFormat;\r\n return isKnownTileFormat(format) ? format : TileFormat.Unknown;\r\n}\r\n\r\n/** Status codes for tile reading operations\r\n * @internal\r\n */\r\nexport enum TileReadStatus {\r\n Success = 0,\r\n InvalidTileData,\r\n InvalidHeader,\r\n InvalidBatchTable,\r\n InvalidScene,\r\n InvalidFeatureTable,\r\n NewerMajorVersion,\r\n Canceled,\r\n}\r\n\r\nconst readStatusMessages = [\r\n \"Success\",\r\n \"Invalid tile data\",\r\n \"Invalid tile header\",\r\n \"Invalid batch table\",\r\n \"Invalid scene\",\r\n \"Invalid feature table\",\r\n \"Major version too new\",\r\n \"Canceled\",\r\n];\r\n\r\n/** Exception thrown by functions that deserialize tiles.\r\n * @internal\r\n */\r\nexport class TileReadError extends BentleyError {\r\n public constructor(status: TileReadStatus, message?: string) {\r\n if (undefined === message)\r\n message = readStatusMessages[status];\r\n\r\n super(status, message);\r\n }\r\n\r\n public get wasCanceled(): boolean { return TileReadStatus.Canceled === this.errorNumber; }\r\n}\r\n\r\n/** The base header preceding tile data of most formats, identifying the tile format and version of that format.\r\n * Specific tile formats may define their own headers as sub-types of this Header, appending\r\n * additional format-specific data.\r\n * @internal\r\n */\r\nexport abstract class TileHeader {\r\n private _format: TileFormat;\r\n public version: number;\r\n\r\n /** Construct a Header from the binary data at the supplied stream's current read position */\r\n public constructor(stream: ByteStream) {\r\n this._format = tileFormatFromNumber(stream.readUint32());\r\n this.version = stream.readUint32();\r\n }\r\n\r\n public get format(): TileFormat { return this._format; }\r\n\r\n /** Returns whether the header represents valid data */\r\n public abstract get isValid(): boolean;\r\n\r\n /** Mark the header as representing invalid data */\r\n protected invalidate(): void {\r\n this._format = TileFormat.Unknown;\r\n }\r\n}\r\n\r\n/** Read 3 64-bit floating point numbers at the byte stream's current read position, advance by 24 bytes, and return a Point3d constructed from the 3 numbers.\r\n * @internal\r\n */\r\nexport function nextPoint3d64FromByteStream(stream: ByteStream, result?: Point3d): Point3d {\r\n const x = stream.readFloat64(),\r\n y = stream.readFloat64(),\r\n z = stream.readFloat64();\r\n\r\n if (undefined === result)\r\n return new Point3d(x, y, z);\r\n\r\n result.set(x, y, z);\r\n return result;\r\n}\r\n"]}
|
package/lib/esm/ElementMesh.js
CHANGED
|
@@ -14,10 +14,10 @@ function nextChunk(stream) {
|
|
|
14
14
|
return undefined;
|
|
15
15
|
}
|
|
16
16
|
// Type codes are a sequence of four uppercase ASCII letters.
|
|
17
|
-
const chars = [stream.
|
|
17
|
+
const chars = [stream.readUint8(), stream.readUint8(), stream.readUint8(), stream.readUint8()];
|
|
18
18
|
if (chars.some((c) => c < 65 || c > 90))
|
|
19
19
|
return undefined;
|
|
20
|
-
const dataLength = stream.
|
|
20
|
+
const dataLength = stream.readUint32();
|
|
21
21
|
const data = dataLength > 0 ? stream.nextBytes(dataLength) : undefined;
|
|
22
22
|
return {
|
|
23
23
|
type: String.fromCharCode(...chars),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementMesh.js","sourceRoot":"","sources":["../../src/ElementMesh.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAc,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAsClF,SAAS,SAAS,CAAC,MAAkB;IACnC,IAAI,MAAM,CAAC,eAAe,GAAG,CAAC,EAAE;QAC9B,2BAA2B;QAC3B,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC9B,OAAO,SAAS,CAAC;KAClB;IAED,6DAA6D;IAC7D,MAAM,KAAK,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,M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,CAAC,CAAC;IAC/C,MAAM,UAAU,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;IACrC,IAAI,CAAC,UAAU,IAAI,MAAM,KAAK,UAAU,CAAC,IAAI;QAC3C,OAAO,SAAS,CAAC;IAEnB,OAAO,MAAM,CAAC,eAAe,GAAG,CAAC,EAAE;QACjC,MAAM,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;QAChC,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI;YAChD,SAAS;QAEX,IAAI;YACF,MAAM,IAAI,GAAG,yBAAyB,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACzE,IAAI,IAAI,YAAY,eAAe;gBACjC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACxB;QAAC,OAAO,CAAC,EAAE;YACV,EAAE;SACH;KACF;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Geometry\r\n */\r\n\r\nimport { ByteStream, Id64String } from \"@itwin/core-bentley\";\r\nimport { BentleyGeometryFlatBuffer, IndexedPolyface } from \"@itwin/core-geometry\";\r\n\r\n/** Options used to control how [Polyface]($core-geometry)s are produced from elements by [IModelConnection.generateElementMeshes]($frontend).\r\n * @beta\r\n */\r\nexport interface ElementMeshOptions {\r\n /** Maximum distance from a face to the original geometry.\r\n * If not supplied, defaults to zero and [[angleTolerance]] will control the quality of the resulting mesh instead.\r\n * @see [StrokeOptions.chordTol]($core-geometry).\r\n */\r\n chordTolerance?: number;\r\n /** Maximum angle difference in radians for an approximated face.\r\n * If not supplied, defaults to PI/12 (15 degrees).\r\n * @see [StrokeOptions.angleTol]($core-geometry).\r\n */\r\n angleTolerance?: number;\r\n /** BRep features with bounding boxes smaller than this size will not generate graphics.\r\n * This option can be used to ignore expensive details from [BRepEntity.DataProps]($core-common)\r\n * like screws and screw holes.\r\n */\r\n minBRepFeatureSize?: number;\r\n // ###TODO? decimationTolerance?: number;\r\n}\r\n\r\n/** Describes a request to generate [Polyface]($core-geometry)s from an element.\r\n * @see [IModelConnection.generateElementMeshes]($frontend).\r\n * @beta\r\n */\r\nexport interface ElementMeshRequestProps extends ElementMeshOptions {\r\n /** The Id of the [GeometricElement]($backend) from which to obtain meshes. */\r\n source: Id64String;\r\n}\r\n\r\ninterface Chunk {\r\n type: string;\r\n data?: Uint8Array;\r\n}\r\n\r\nfunction nextChunk(stream: ByteStream): Chunk | undefined {\r\n if (stream.remainingLength < 8) {\r\n // Consume remaining bytes.\r\n stream.curPos = stream.length;\r\n return undefined;\r\n }\r\n\r\n // Type codes are a sequence of four uppercase ASCII letters.\r\n const chars = [stream.readUint8(), stream.readUint8(), stream.readUint8(), stream.readUint8()];\r\n if (chars.some((c) => c < 65 || c > 90))\r\n return undefined;\r\n\r\n const dataLength = stream.readUint32();\r\n const data = dataLength > 0 ? stream.nextBytes(dataLength) : undefined;\r\n return {\r\n type: String.fromCharCode(...chars),\r\n data,\r\n };\r\n}\r\n\r\n/** Convert the output of [IModelConnection.generateElementMeshes]($frontend) into an array of [Polyface]($core-geometry)s.\r\n * @param data Encoded polyfaces obtained from [IModelConnection.generateElementMeshes]($frontend).\r\n * @returns a list of decoded polyfaces.\r\n * @beta\r\n */\r\nexport function readElementMeshes(data: Uint8Array): IndexedPolyface[] {\r\n const polyfaces: IndexedPolyface[] = [];\r\n\r\n const stream = ByteStream.fromUint8Array(data);\r\n const firstChunk = nextChunk(stream);\r\n if (!firstChunk || \"LMSH\" !== firstChunk.type)\r\n return polyfaces;\r\n\r\n while (stream.remainingLength > 0) {\r\n const chunk = nextChunk(stream);\r\n if (!chunk || chunk.type !== \"PLFC\" || !chunk.data)\r\n continue;\r\n\r\n try {\r\n const geom = BentleyGeometryFlatBuffer.bytesToGeometry(chunk.data, true);\r\n if (geom instanceof IndexedPolyface)\r\n polyfaces.push(geom);\r\n } catch (_) {\r\n //\r\n }\r\n }\r\n\r\n return polyfaces;\r\n}\r\n"]}
|
package/lib/esm/IModelError.d.ts
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module iModels
|
|
3
3
|
*/
|
|
4
|
-
import { BentleyError, BentleyStatus, BriefcaseStatus, ChangeSetStatus, DbResult, GetMetaDataFunction, IModelStatus
|
|
5
|
-
export { BentleyStatus, BentleyError, IModelStatus, BriefcaseStatus, GetMetaDataFunction, LogFunction, DbResult,
|
|
6
|
-
/**
|
|
4
|
+
import { BentleyError, BentleyStatus, BriefcaseStatus, ChangeSetStatus, DbResult, GetMetaDataFunction, IModelStatus } from "@itwin/core-bentley";
|
|
5
|
+
export { BentleyStatus, BentleyError, IModelStatus, BriefcaseStatus, GetMetaDataFunction, LogFunction, DbResult, ChangeSetStatus, } from "@itwin/core-bentley";
|
|
6
|
+
/** Numeric values for common errors produced by iTwin.js APIs, typically provided by [[IModelError]].
|
|
7
|
+
* The values within each of these `enum`s are guaranteed not to conflict with one another.
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export declare type IModelErrorNumber = IModelStatus | DbResult | BentleyStatus | BriefcaseStatus | ChangeSetStatus;
|
|
11
|
+
/** The error type thrown by this module.
|
|
12
|
+
* @see [[IModelErrorNumber]] for commonly-used error codes.
|
|
7
13
|
* @public
|
|
8
14
|
*/
|
|
9
15
|
export declare class IModelError extends BentleyError {
|
|
10
|
-
constructor(errorNumber:
|
|
16
|
+
constructor(errorNumber: IModelErrorNumber | number, message: string, getMetaData?: GetMetaDataFunction);
|
|
11
17
|
}
|
|
12
18
|
/** @public */
|
|
13
19
|
export declare class ServerError extends IModelError {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelError.d.ts","sourceRoot":"","sources":["../../src/IModelError.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACL,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,QAAQ,EAAE,mBAAmB,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"IModelError.d.ts","sourceRoot":"","sources":["../../src/IModelError.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACL,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,QAAQ,EAAE,mBAAmB,EAAE,YAAY,EAC3G,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,WAAW,EAAE,QAAQ,EAAE,eAAe,GACxH,MAAM,qBAAqB,CAAC;AAE7B;;;GAGG;AACH,oBAAY,iBAAiB,GAAG,YAAY,GAAG,QAAQ,GAAG,aAAa,GAAG,eAAe,GAAG,eAAe,CAAC;AAE5G;;;GAGG;AACH,qBAAa,WAAY,SAAQ,YAAY;gBACxB,WAAW,EAAE,iBAAiB,GAAG,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,mBAAmB;CAG/G;AAED,cAAc;AACd,qBAAa,WAAY,SAAQ,WAAW;gBACvB,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAIxD;AAED,cAAc;AACd,qBAAa,kBAAmB,SAAQ,WAAW;gBAC9B,OAAO,EAAE,MAAM;CAInC;AAED,cAAc;AACd,qBAAa,YAAa,SAAQ,WAAW;gBACxB,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,mBAAmB;CAIzG;AAED;;;GAGG;AACH,qBAAa,sBAAuB,SAAQ,WAAW;gBAClC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,mBAAmB;CAGtE;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,WAAW;;CAI9C"}
|
package/lib/esm/IModelError.js
CHANGED
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
* @module iModels
|
|
7
7
|
*/
|
|
8
8
|
import { BentleyError, IModelStatus, RepositoryStatus, } from "@itwin/core-bentley";
|
|
9
|
-
export { BentleyStatus, BentleyError, IModelStatus, BriefcaseStatus, DbResult,
|
|
10
|
-
/** The error type thrown by this module.
|
|
9
|
+
export { BentleyStatus, BentleyError, IModelStatus, BriefcaseStatus, DbResult, ChangeSetStatus, } from "@itwin/core-bentley";
|
|
10
|
+
/** The error type thrown by this module.
|
|
11
|
+
* @see [[IModelErrorNumber]] for commonly-used error codes.
|
|
11
12
|
* @public
|
|
12
13
|
*/
|
|
13
14
|
export class IModelError extends BentleyError {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelError.js","sourceRoot":"","sources":["../../src/IModelError.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EACL,YAAY,EAAkF,YAAY,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"IModelError.js","sourceRoot":"","sources":["../../src/IModelError.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EACL,YAAY,EAAkF,YAAY,EAAE,gBAAgB,GAC7H,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAoC,QAAQ,EAAE,eAAe,GACxH,MAAM,qBAAqB,CAAC;AAQ7B;;;GAGG;AACH,MAAM,OAAO,WAAY,SAAQ,YAAY;IAC3C,YAAmB,WAAuC,EAAE,OAAe,EAAE,WAAiC;QAC5G,KAAK,CAAC,WAAW,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;IAC3C,CAAC;CACF;AAED,cAAc;AACd,MAAM,OAAO,WAAY,SAAQ,WAAW;IAC1C,YAAmB,WAAmB,EAAE,OAAe;QACrD,KAAK,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,iBAAiB,WAAW,GAAG,CAAC;IAC9C,CAAC;CACF;AAED,cAAc;AACd,MAAM,OAAO,kBAAmB,SAAQ,WAAW;IACjD,YAAmB,OAAe;QAChC,KAAK,CAAC,YAAY,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QAC3C,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAED,cAAc;AACd,MAAM,OAAO,YAAa,SAAQ,WAAW;IAC3C,YAAmB,WAAmB,EAAE,IAAY,EAAE,OAAe,EAAE,WAAiC;QACtG,KAAK,CAAC,WAAW,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,sBAAuB,SAAQ,WAAW;IACrD,YAAmB,OAAe,EAAE,WAAiC;QACnE,KAAK,CAAC,gBAAgB,CAAC,0BAA0B,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;IAC3E,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,WAAW;IAC7C;QACE,KAAK,CAAC,YAAY,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IAC9C,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module iModels\r\n */\r\n\r\nimport {\r\n BentleyError, BentleyStatus, BriefcaseStatus, ChangeSetStatus, DbResult, GetMetaDataFunction, IModelStatus, RepositoryStatus,\r\n} from \"@itwin/core-bentley\";\r\n\r\nexport {\r\n BentleyStatus, BentleyError, IModelStatus, BriefcaseStatus, GetMetaDataFunction, LogFunction, DbResult, ChangeSetStatus,\r\n} from \"@itwin/core-bentley\";\r\n\r\n/** Numeric values for common errors produced by iTwin.js APIs, typically provided by [[IModelError]].\r\n * The values within each of these `enum`s are guaranteed not to conflict with one another.\r\n * @public\r\n */\r\nexport type IModelErrorNumber = IModelStatus | DbResult | BentleyStatus | BriefcaseStatus | ChangeSetStatus;\r\n\r\n/** The error type thrown by this module.\r\n * @see [[IModelErrorNumber]] for commonly-used error codes.\r\n * @public\r\n */\r\nexport class IModelError extends BentleyError {\r\n public constructor(errorNumber: IModelErrorNumber | number, message: string, getMetaData?: GetMetaDataFunction) {\r\n super(errorNumber, message, getMetaData);\r\n }\r\n}\r\n\r\n/** @public */\r\nexport class ServerError extends IModelError {\r\n public constructor(errorNumber: number, message: string) {\r\n super(errorNumber, message);\r\n this.name = `Server error (${errorNumber})`;\r\n }\r\n}\r\n\r\n/** @public */\r\nexport class ServerTimeoutError extends ServerError {\r\n public constructor(message: string) {\r\n super(IModelStatus.ServerTimeout, message);\r\n this.name = \"Server timeout error\";\r\n }\r\n}\r\n\r\n/** @public */\r\nexport class BackendError extends IModelError {\r\n public constructor(errorNumber: number, name: string, message: string, getMetaData?: GetMetaDataFunction) {\r\n super(errorNumber, message, getMetaData);\r\n this.name = name;\r\n }\r\n}\r\n\r\n/**\r\n * Channel constraint error\r\n * @alpha\r\n */\r\nexport class ChannelConstraintError extends IModelError {\r\n public constructor(message: string, getMetaData?: GetMetaDataFunction) {\r\n super(RepositoryStatus.ChannelConstraintViolation, message, getMetaData);\r\n }\r\n}\r\n\r\n/** Intended for API \"no content\" semantics where the error case should not trigger application failure monitoring systems.\r\n * @public\r\n */\r\nexport class NoContentError extends IModelError {\r\n public constructor() {\r\n super(IModelStatus.NoContent, \"No Content\");\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Localization.d.ts","sourceRoot":"","sources":["../../src/Localization.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;GAEG;A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*/
|
|
11
11
|
export class EmptyLocalization {
|
|
12
12
|
async initialize() { }
|
|
13
|
-
getLocalizedString(key) {
|
|
13
|
+
getLocalizedString(key) {
|
|
14
|
+
if (typeof (key) !== "string") {
|
|
15
|
+
key = key[0];
|
|
16
|
+
}
|
|
17
|
+
// Simulate correct and simple usage of i18next's translation function
|
|
18
|
+
// Namely, remove the leading namespace substring if there is one
|
|
19
|
+
return key.split(":", 2).pop();
|
|
20
|
+
}
|
|
14
21
|
getLocalizedStringWithNamespace(_namespace, key) { return this.getLocalizedString(key); }
|
|
15
22
|
getEnglishString(_namespace, key) { return this.getLocalizedString(key); }
|
|
16
23
|
getLocalizedKeys(inputString) { return inputString; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Localization.js","sourceRoot":"","sources":["../../src/Localization.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAqGH;;GAEG;AACH,MAAM,OAAO,iBAAiB;IACrB,KAAK,CAAC,UAAU,KAAoB,CAAC;IACrC,kBAAkB,CAAC,GAAsB,
|
|
1
|
+
{"version":3,"file":"Localization.js","sourceRoot":"","sources":["../../src/Localization.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAqGH;;GAEG;AACH,MAAM,OAAO,iBAAiB;IACrB,KAAK,CAAC,UAAU,KAAoB,CAAC;IACrC,kBAAkB,CAAC,GAAsB;QAC9C,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE;YAC7B,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;SACd;QACD,sEAAsE;QACtE,iEAAiE;QACjE,OAAO,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,EAAG,CAAC;IAClC,CAAC;IACM,+BAA+B,CAAC,UAAkB,EAAE,GAAsB,IAAY,OAAO,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC5H,gBAAgB,CAAC,UAAkB,EAAE,GAAsB,IAAY,OAAO,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC7G,gBAAgB,CAAC,WAAmB,IAAY,OAAO,WAAW,CAAC,CAAC,CAAC;IACrE,KAAK,CAAC,iBAAiB,KAAoB,CAAC;IAC5C,mBAAmB,KAAW,CAAC;IAC/B,mBAAmB,KAAgC,OAAO,SAAS,CAAC,CAAC,CAAC;IACtE,eAAe,KAAwB,OAAO,EAAE,CAAC,CAAC,CAAC;IACnD,KAAK,CAAC,cAAc,KAAK,CAAC;CAClC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Localization\r\n */\r\n\r\n/** Options for Localization\r\n * @public\r\n */\r\nexport interface TranslationOptions {\r\n /** for interpolation values */\r\n [key: string]: any;\r\n /**\r\n * defaultValue to return if a translation was not found\r\n */\r\n defaultValue?: any;\r\n /**\r\n * count value used for plurals\r\n */\r\n count?: number;\r\n /**\r\n * used for contexts (eg. male\\female)\r\n */\r\n context?: any;\r\n /**\r\n * override languages to use\r\n */\r\n lngs?: string[];\r\n /**\r\n * override language to lookup key if not found see fallbacks for details\r\n */\r\n fallbackLng?: string;\r\n}\r\n\r\n/** The interface defining the localization requirements of [IModelApp]($frontend).\r\n * @public\r\n * @extensions\r\n */\r\nexport interface Localization {\r\n /** This method must be called and awaited before using an instance of Localization.\r\n * @param namespaces an array of namespaces to load. There must be at least one namespace, and it\r\n * becomes the default namespace.\r\n * @note IModelApp.startup calls this internally, so you should not call this method directly\r\n * except for Localization instances outside of IModelApp (e.g., for tests.)\r\n */\r\n initialize(namespaces: string[]): Promise<void>;\r\n\r\n /** Return the translated value of a key.\r\n * @param key - the key that matches a property in the JSON localization file.\r\n * @note The key includes the namespace, which identifies the particular localization file that contains the property,\r\n * followed by a colon, followed by the property in the JSON file.\r\n * For example:\r\n * ``` ts\r\n * const dataString: string = IModelApp.localization.getLocalizedString(\"iModelJs:BackgroundMap.BingDataAttribution\");\r\n * ```\r\n * assigns to dataString the string with property BackgroundMap.BingDataAttribution from the iModelJs.json localization file.\r\n * @returns The string corresponding to the first key that resolves.\r\n * @throws Error if no keys resolve to a string.\r\n */\r\n getLocalizedString(key: string | string[], options?: TranslationOptions): string;\r\n /** Similar to `getLocalizedString` but the namespace is a separate param and the key does not include the namespace.\r\n * @param namespace - the namespace that identifies the particular localization file that contains the property.\r\n * @param key - the key that matches a property in the JSON localization file.\r\n * @returns The string corresponding to the first key that resolves.\r\n * @throws Error if no keys resolve to a string.\r\n * @deprecated Use `getLocalizedString` instead; providing either a key with a namespace `<namespace>:<key>` or\r\n * including `{ ns: <namespace> }` in the options.\r\n */\r\n getLocalizedStringWithNamespace(namespace: string, key: string | string[], options?: TranslationOptions): string;\r\n /** get the English string for a key. */\r\n getEnglishString(namespace: string, key: string | string[], options?: TranslationOptions): string;\r\n /** Replace all instances of `%{key}` within a string with the translations of those keys.\r\n * For example:\r\n * ``` ts\r\n * \"MyKeys\": {\r\n * \"Key1\": \"First value\",\r\n * \"Key2\": \"Second value\"\r\n * }\r\n * ```\r\n *\r\n * ``` ts\r\n * getLocalizedKeys(\"string with %{MyKeys.Key1} followed by %{MyKeys.Key2}!\"\") // returns \"string with First Value followed by Second Value!\"\r\n * ```\r\n */\r\n getLocalizedKeys(inputString: string): string;\r\n\r\n /** Register a new Namespace and return a Promise that is fulfilled when the content is loaded.\r\n * If the namespace is already registered, its Promise will be returned.\r\n * @param name - the name of the namespace.\r\n * @note - The registerNamespace method starts fetching the appropriate version of the JSON localization file from the server,\r\n * based on the current locale. To make sure that fetch is complete before performing translations from this namespace, await\r\n * fulfillment of returned Promise.\r\n * @see [Localization in iTwin.js]($docs/learning/frontend/Localization.md)\r\n */\r\n registerNamespace(namespace: string): Promise<void>;\r\n /** @internal */\r\n unregisterNamespace(namespace: string): void;\r\n /** @internal */\r\n getNamespacePromise(name: string): Promise<void> | undefined;\r\n /** Get the list of available languages for translations */\r\n getLanguageList(): readonly string[];\r\n /** Change the language for translations. This overrides the language from the browser, for tests. */\r\n changeLanguage(language: string): Promise<void>;\r\n}\r\n\r\n/** An empty [[Localization]] used if one is not provided to [IModelApp]($frontend). Does not perform localizations (merely returns the key.)\r\n * @public\r\n */\r\nexport class EmptyLocalization implements Localization {\r\n public async initialize(): Promise<void> { }\r\n public getLocalizedString(key: string | string[]): string {\r\n if (typeof (key) !== \"string\") {\r\n key = key[0];\r\n }\r\n // Simulate correct and simple usage of i18next's translation function\r\n // Namely, remove the leading namespace substring if there is one\r\n return key.split(\":\", 2).pop()!;\r\n }\r\n public getLocalizedStringWithNamespace(_namespace: string, key: string | string[]): string { return this.getLocalizedString(key); }\r\n public getEnglishString(_namespace: string, key: string | string[]): string { return this.getLocalizedString(key); }\r\n public getLocalizedKeys(inputString: string): string { return inputString; }\r\n public async registerNamespace(): Promise<void> { }\r\n public unregisterNamespace(): void { }\r\n public getNamespacePromise(): Promise<void> | undefined { return undefined; }\r\n public getLanguageList(): readonly string[] { return []; }\r\n public async changeLanguage() { }\r\n}\r\n"]}
|