@itwin/core-common 3.0.0-dev.156 → 3.0.0-dev.161

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.
@@ -17,84 +17,6 @@ export declare enum GltfV2ChunkTypes {
17
17
  JSON = 1313821514,
18
18
  Binary = 5130562
19
19
  }
20
- /** @internal */
21
- export declare enum GltfMeshMode {
22
- Points = 0,
23
- Lines = 1,
24
- LineStrip = 3,
25
- Triangles = 4
26
- }
27
- /** @internal */
28
- export declare enum GltfDataType {
29
- SignedByte = 5120,
30
- UnsignedByte = 5121,
31
- SignedShort = 5122,
32
- UnsignedShort = 5123,
33
- UInt32 = 5125,
34
- Float = 5126,
35
- Rgb = 6407,
36
- Rgba = 6408,
37
- IntVec2 = 35667,
38
- IntVec3 = 35668,
39
- FloatVec2 = 35664,
40
- FloatVec3 = 35665,
41
- FloatVec4 = 35666,
42
- FloatMat3 = 35675,
43
- FloatMat4 = 35676,
44
- Sampler2d = 35678
45
- }
46
- /** @internal */
47
- export declare enum GltfConstants {
48
- CullFace = 2884,
49
- DepthTest = 2929,
50
- Nearest = 9728,
51
- Linear = 9729,
52
- LinearMipmapLinear = 9987,
53
- ClampToEdge = 33071,
54
- ArrayBuffer = 34962,
55
- ElementArrayBuffer = 34963,
56
- FragmentShader = 35632,
57
- VertexShader = 35633
58
- }
59
- /** @internal */
60
- export declare type GltfDataBuffer = Uint8Array | Uint16Array | Uint32Array | Float32Array;
61
- /**
62
- * A chunk of binary data exposed as a typed array.
63
- * The count member indicates how many elements exist. This may be less than this.buffer.length due to padding added to the
64
- * binary stream to ensure correct alignment.
65
- * @internal
66
- */
67
- export declare class GltfBufferData {
68
- readonly buffer: GltfDataBuffer;
69
- readonly count: number;
70
- constructor(buffer: GltfDataBuffer, count: number);
71
- /**
72
- * Create a GltfBufferData of the desired type. The actual type may differ from the desired type - for example, small 32-bit integers
73
- * may be represented as 8-bit or 16-bit integers instead.
74
- * If the actual data type is not convertible to the desired type, this function returns undefined.
75
- */
76
- static create(bytes: Uint8Array, actualType: GltfDataType, expectedType: GltfDataType, count: number): GltfBufferData | undefined;
77
- private static createDataBuffer;
78
- }
79
- /**
80
- * A view of a chunk of glTF binary data containing an array of elements of a specific data type.
81
- * The count member indicates how many elements exist; this may be smaller than this.data.length.
82
- * The count member may also indicate the number of elements of a type containing more than one value of the
83
- * underlying type. For example, a buffer of 4 32-bit floating point 'vec2' elements will have a count of 4,
84
- * but its data member will contain 8 32-bit floating point values (2 per vec2).
85
- * The accessor member may contain additional JSON data specific to a particular buffer.
86
- * @internal
87
- */
88
- export declare class GltfBufferView {
89
- readonly data: Uint8Array;
90
- readonly count: number;
91
- readonly type: GltfDataType;
92
- readonly accessor: any;
93
- readonly stride: number;
94
- get byteLength(): number;
95
- constructor(data: Uint8Array, count: number, type: GltfDataType, accessor: any, stride: number);
96
- toBufferData(desiredType: GltfDataType): GltfBufferData | undefined;
97
- }
98
20
  /** Header preceding glTF data.
99
21
  * @internal
100
22
  */
@@ -1 +1 @@
1
- {"version":3,"file":"GltfTileIO.d.ts","sourceRoot":"","sources":["../../../src/tile/GltfTileIO.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAc,UAAU,EAAE,MAAM,UAAU,CAAC;AAElD;;GAEG;AACH,oBAAY,YAAY;IACtB,QAAQ,IAAI;IACZ,QAAQ,IAAI;IACZ,cAAc,IAAW;IACzB,gBAAgB,IAAI;CACrB;AAED,gBAAgB;AAChB,oBAAY,gBAAgB;IAC1B,IAAI,aAAa;IACjB,MAAM,UAAa;CACpB;AAED,gBAAgB;AAChB,oBAAY,YAAY;IACtB,MAAM,IAAI;IACV,KAAK,IAAI;IACT,SAAS,IAAI;IACb,SAAS,IAAI;CACd;AAED,gBAAgB;AAChB,oBAAY,YAAY;IACtB,UAAU,OAAS;IACnB,YAAY,OAAS;IACrB,WAAW,OAAO;IAClB,aAAa,O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,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM;IAQ9F,YAAY,CAAC,WAAW,EAAE,YAAY,GAAG,cAAc,GAAG,SAAS;CAG3E;AAED;;GAEG;AACH,qBAAa,UAAW,SAAQ,UAAU;IACxC,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,aAAa,EAAE,MAAM,CAAK;IAC1C,SAAgB,cAAc,EAAE,MAAM,CAAK;IAC3C,SAAgB,cAAc,EAAE,MAAM,CAAK;IAC3C,IAAW,OAAO,IAAI,OAAO,CAA4C;gBAEtD,MAAM,EAAE,UAAU;CAoCtC"}
1
+ {"version":3,"file":"GltfTileIO.d.ts","sourceRoot":"","sources":["../../../src/tile/GltfTileIO.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAc,UAAU,EAAE,MAAM,UAAU,CAAC;AAElD;;GAEG;AACH,oBAAY,YAAY;IACtB,QAAQ,IAAI;IACZ,QAAQ,IAAI;IACZ,cAAc,IAAW;IACzB,gBAAgB,IAAI;CACrB;AAED,gBAAgB;AAChB,oBAAY,gBAAgB;IAC1B,IAAI,aAAa;IACjB,MAAM,UAAa;CACpB;AAED;;GAEG;AACH,qBAAa,UAAW,SAAQ,UAAU;IACxC,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,aAAa,EAAE,MAAM,CAAK;IAC1C,SAAgB,cAAc,EAAE,MAAM,CAAK;IAC3C,SAAgB,cAAc,EAAE,MAAM,CAAK;IAC3C,IAAW,OAAO,IAAI,OAAO,CAA4C;gBAEtD,MAAM,EAAE,UAAU;CAoCtC"}
@@ -7,7 +7,7 @@
7
7
  * @module Tile
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.GltfHeader = exports.GltfBufferView = exports.GltfBufferData = exports.GltfConstants = exports.GltfDataType = exports.GltfMeshMode = exports.GltfV2ChunkTypes = exports.GltfVersions = void 0;
10
+ exports.GltfHeader = exports.GltfV2ChunkTypes = exports.GltfVersions = void 0;
11
11
  const TileIO_1 = require("./TileIO");
12
12
  /** Known version of the [glTF format](https://www.khronos.org/gltf/).
13
13
  * @internal
@@ -25,125 +25,6 @@ var GltfV2ChunkTypes;
25
25
  GltfV2ChunkTypes[GltfV2ChunkTypes["JSON"] = 1313821514] = "JSON";
26
26
  GltfV2ChunkTypes[GltfV2ChunkTypes["Binary"] = 5130562] = "Binary";
27
27
  })(GltfV2ChunkTypes = exports.GltfV2ChunkTypes || (exports.GltfV2ChunkTypes = {}));
28
- /** @internal */
29
- var GltfMeshMode;
30
- (function (GltfMeshMode) {
31
- GltfMeshMode[GltfMeshMode["Points"] = 0] = "Points";
32
- GltfMeshMode[GltfMeshMode["Lines"] = 1] = "Lines";
33
- GltfMeshMode[GltfMeshMode["LineStrip"] = 3] = "LineStrip";
34
- GltfMeshMode[GltfMeshMode["Triangles"] = 4] = "Triangles";
35
- })(GltfMeshMode = exports.GltfMeshMode || (exports.GltfMeshMode = {}));
36
- /** @internal */
37
- var GltfDataType;
38
- (function (GltfDataType) {
39
- GltfDataType[GltfDataType["SignedByte"] = 5120] = "SignedByte";
40
- GltfDataType[GltfDataType["UnsignedByte"] = 5121] = "UnsignedByte";
41
- GltfDataType[GltfDataType["SignedShort"] = 5122] = "SignedShort";
42
- GltfDataType[GltfDataType["UnsignedShort"] = 5123] = "UnsignedShort";
43
- GltfDataType[GltfDataType["UInt32"] = 5125] = "UInt32";
44
- GltfDataType[GltfDataType["Float"] = 5126] = "Float";
45
- GltfDataType[GltfDataType["Rgb"] = 6407] = "Rgb";
46
- GltfDataType[GltfDataType["Rgba"] = 6408] = "Rgba";
47
- GltfDataType[GltfDataType["IntVec2"] = 35667] = "IntVec2";
48
- GltfDataType[GltfDataType["IntVec3"] = 35668] = "IntVec3";
49
- GltfDataType[GltfDataType["FloatVec2"] = 35664] = "FloatVec2";
50
- GltfDataType[GltfDataType["FloatVec3"] = 35665] = "FloatVec3";
51
- GltfDataType[GltfDataType["FloatVec4"] = 35666] = "FloatVec4";
52
- GltfDataType[GltfDataType["FloatMat3"] = 35675] = "FloatMat3";
53
- GltfDataType[GltfDataType["FloatMat4"] = 35676] = "FloatMat4";
54
- GltfDataType[GltfDataType["Sampler2d"] = 35678] = "Sampler2d";
55
- })(GltfDataType = exports.GltfDataType || (exports.GltfDataType = {}));
56
- /** @internal */
57
- var GltfConstants;
58
- (function (GltfConstants) {
59
- GltfConstants[GltfConstants["CullFace"] = 2884] = "CullFace";
60
- GltfConstants[GltfConstants["DepthTest"] = 2929] = "DepthTest";
61
- GltfConstants[GltfConstants["Nearest"] = 9728] = "Nearest";
62
- GltfConstants[GltfConstants["Linear"] = 9729] = "Linear";
63
- GltfConstants[GltfConstants["LinearMipmapLinear"] = 9987] = "LinearMipmapLinear";
64
- GltfConstants[GltfConstants["ClampToEdge"] = 33071] = "ClampToEdge";
65
- GltfConstants[GltfConstants["ArrayBuffer"] = 34962] = "ArrayBuffer";
66
- GltfConstants[GltfConstants["ElementArrayBuffer"] = 34963] = "ElementArrayBuffer";
67
- GltfConstants[GltfConstants["FragmentShader"] = 35632] = "FragmentShader";
68
- GltfConstants[GltfConstants["VertexShader"] = 35633] = "VertexShader";
69
- })(GltfConstants = exports.GltfConstants || (exports.GltfConstants = {}));
70
- /**
71
- * A chunk of binary data exposed as a typed array.
72
- * The count member indicates how many elements exist. This may be less than this.buffer.length due to padding added to the
73
- * binary stream to ensure correct alignment.
74
- * @internal
75
- */
76
- class GltfBufferData {
77
- constructor(buffer, count) {
78
- this.buffer = buffer;
79
- this.count = count;
80
- }
81
- /**
82
- * Create a GltfBufferData of the desired type. The actual type may differ from the desired type - for example, small 32-bit integers
83
- * may be represented as 8-bit or 16-bit integers instead.
84
- * If the actual data type is not convertible to the desired type, this function returns undefined.
85
- */
86
- static create(bytes, actualType, expectedType, count) {
87
- if (expectedType !== actualType) {
88
- // Some data is stored in smaller data types to save space if no values exceed the maximum of the smaller type.
89
- switch (expectedType) {
90
- case GltfDataType.Float:
91
- case GltfDataType.UnsignedByte:
92
- return undefined;
93
- case GltfDataType.UnsignedShort:
94
- if (GltfDataType.UnsignedByte !== actualType)
95
- return undefined;
96
- break;
97
- case GltfDataType.UInt32:
98
- if (GltfDataType.UnsignedByte !== actualType && GltfDataType.UnsignedShort !== actualType)
99
- return undefined;
100
- break;
101
- }
102
- }
103
- const data = this.createDataBuffer(bytes, actualType);
104
- return undefined !== data ? new GltfBufferData(data, count) : undefined;
105
- }
106
- static createDataBuffer(bytes, actualType) {
107
- // NB: Endianness of typed array data is determined by the 'platform byte order'. Actual data is always little-endian.
108
- // We are assuming little-endian platform. If we find a big-endian platform, we'll need to use a DataView instead.
109
- switch (actualType) {
110
- case GltfDataType.UnsignedByte:
111
- return bytes;
112
- case GltfDataType.UnsignedShort:
113
- return new Uint16Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 2);
114
- case GltfDataType.UInt32:
115
- return new Uint32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4);
116
- case GltfDataType.Float:
117
- return new Float32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4);
118
- default:
119
- return undefined;
120
- }
121
- }
122
- }
123
- exports.GltfBufferData = GltfBufferData;
124
- /**
125
- * A view of a chunk of glTF binary data containing an array of elements of a specific data type.
126
- * The count member indicates how many elements exist; this may be smaller than this.data.length.
127
- * The count member may also indicate the number of elements of a type containing more than one value of the
128
- * underlying type. For example, a buffer of 4 32-bit floating point 'vec2' elements will have a count of 4,
129
- * but its data member will contain 8 32-bit floating point values (2 per vec2).
130
- * The accessor member may contain additional JSON data specific to a particular buffer.
131
- * @internal
132
- */
133
- class GltfBufferView {
134
- constructor(data, count, type, accessor, stride) {
135
- this.data = data;
136
- this.count = count;
137
- this.type = type;
138
- this.accessor = accessor;
139
- this.stride = stride;
140
- }
141
- get byteLength() { return this.data.length; }
142
- toBufferData(desiredType) {
143
- return GltfBufferData.create(this.data, this.type, desiredType, this.count);
144
- }
145
- }
146
- exports.GltfBufferView = GltfBufferView;
147
28
  /** Header preceding glTF data.
148
29
  * @internal
149
30
  */
@@ -1 +1 @@
1
- {"version":3,"file":"GltfTileIO.js","sourceRoot":"","sources":["../../../src/tile/GltfTileIO.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,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;AAED,gBAAgB;AAChB,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,mDAAU,CAAA;IACV,iDAAS,CAAA;IACT,yDAAa,CAAA;IACb,yDAAa,CAAA;AACf,CAAC,EALW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAKvB;AAED,gBAAgB;AAChB,IAAY,YAiBX;AAjBD,WAAY,YAAY;IACtB,8DAAmB,CAAA;IACnB,kEAAqB,CAAA;IACrB,gEAAkB,CAAA;IAClB,oEAAoB,CAAA;IACpB,sDAAa,CAAA;IACb,oDAAY,CAAA;IACZ,gDAAU,CAAA;IACV,kDAAW,CAAA;IACX,yDAAgB,CAAA;IAChB,yDAAgB,CAAA;IAChB,6DAAiB,CAAA;IACjB,6DAAiB,CAAA;IACjB,6DAAiB,CAAA;IACjB,6DAAiB,CAAA;IACjB,6DAAiB,CAAA;IACjB,6DAAiB,CAAA;AACnB,CAAC,EAjBW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAiBvB;AAED,gBAAgB;AAChB,IAAY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,gBAAgB,CAAC,IAAI,KAAK,cAAc,IAAI,gBAAgB,CAAC,MAAM,KAAK,eAAe,IAAI,CAAC,KAAK,YAAY,EAAE;gBACjH,IAAI,CAAC,UAAU,EAAE,CAAC;gBAClB,OAAO;aACR;YAED,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;SACrC;aAAM;YACL,IAAI,CAAC,UAAU,EAAE,CAAC;SACnB;IACH,CAAC;IArCD,IAAW,OAAO,KAAc,OAAO,mBAAU,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;CAsC1E;AA3CD,gCA2CC","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/** 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/** @internal */\r\nexport enum GltfMeshMode {\r\n Points = 0,\r\n Lines = 1,\r\n LineStrip = 3,\r\n Triangles = 4,\r\n}\r\n\r\n/** @internal */\r\nexport enum GltfDataType {\r\n SignedByte = 0x1400,\r\n UnsignedByte = 0x1401,\r\n SignedShort = 5122,\r\n UnsignedShort = 5123,\r\n UInt32 = 5125,\r\n Float = 5126,\r\n Rgb = 6407,\r\n Rgba = 6408,\r\n IntVec2 = 0x8b53,\r\n IntVec3 = 0x8b54,\r\n FloatVec2 = 35664,\r\n FloatVec3 = 35665,\r\n FloatVec4 = 35666,\r\n FloatMat3 = 35675,\r\n FloatMat4 = 35676,\r\n Sampler2d = 35678,\r\n}\r\n\r\n/** @internal */\r\nexport enum GltfConstants {\r\n CullFace = 2884,\r\n DepthTest = 2929,\r\n Nearest = 0x2600,\r\n Linear = 9729,\r\n LinearMipmapLinear = 9987,\r\n ClampToEdge = 33071,\r\n ArrayBuffer = 34962,\r\n ElementArrayBuffer = 34963,\r\n FragmentShader = 35632,\r\n VertexShader = 35633,\r\n}\r\n\r\n/** @internal */\r\nexport type GltfDataBuffer = Uint8Array | Uint16Array | Uint32Array | Float32Array;\r\n\r\n/**\r\n * A chunk of binary data exposed as a typed array.\r\n * The count member indicates how many elements exist. This may be less than this.buffer.length due to padding added to the\r\n * binary stream to ensure correct alignment.\r\n * @internal\r\n */\r\nexport class GltfBufferData {\r\n public readonly buffer: GltfDataBuffer;\r\n public readonly count: number;\r\n\r\n public constructor(buffer: GltfDataBuffer, count: number) {\r\n this.buffer = buffer;\r\n this.count = count;\r\n }\r\n\r\n /**\r\n * Create a GltfBufferData of the desired type. The actual type may differ from the desired type - for example, small 32-bit integers\r\n * may be represented as 8-bit or 16-bit integers instead.\r\n * If the actual data type is not convertible to the desired type, this function returns undefined.\r\n */\r\n public static create(bytes: Uint8Array, actualType: GltfDataType, expectedType: GltfDataType, count: number): GltfBufferData | undefined {\r\n if (expectedType !== actualType) {\r\n // Some data is stored in smaller data types to save space if no values exceed the maximum of the smaller type.\r\n switch (expectedType) {\r\n case GltfDataType.Float:\r\n case GltfDataType.UnsignedByte:\r\n return undefined;\r\n case GltfDataType.UnsignedShort:\r\n if (GltfDataType.UnsignedByte !== actualType)\r\n return undefined;\r\n break;\r\n case GltfDataType.UInt32:\r\n if (GltfDataType.UnsignedByte !== actualType && GltfDataType.UnsignedShort !== actualType)\r\n return undefined;\r\n break;\r\n }\r\n }\r\n\r\n const data = this.createDataBuffer(bytes, actualType);\r\n return undefined !== data ? new GltfBufferData(data, count) : undefined;\r\n }\r\n\r\n private static createDataBuffer(bytes: Uint8Array, actualType: GltfDataType): GltfDataBuffer | undefined {\r\n // NB: Endianness of typed array data is determined by the 'platform byte order'. Actual data is always little-endian.\r\n // We are assuming little-endian platform. If we find a big-endian platform, we'll need to use a DataView instead.\r\n switch (actualType) {\r\n case GltfDataType.UnsignedByte:\r\n return bytes;\r\n case GltfDataType.UnsignedShort:\r\n return new Uint16Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 2);\r\n case GltfDataType.UInt32:\r\n return new Uint32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4);\r\n case GltfDataType.Float:\r\n return new Float32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4);\r\n default:\r\n return undefined;\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * A view of a chunk of glTF binary data containing an array of elements of a specific data type.\r\n * The count member indicates how many elements exist; this may be smaller than this.data.length.\r\n * The count member may also indicate the number of elements of a type containing more than one value of the\r\n * underlying type. For example, a buffer of 4 32-bit floating point 'vec2' elements will have a count of 4,\r\n * but its data member will contain 8 32-bit floating point values (2 per vec2).\r\n * The accessor member may contain additional JSON data specific to a particular buffer.\r\n * @internal\r\n */\r\nexport class GltfBufferView {\r\n public readonly data: Uint8Array;\r\n public readonly count: number;\r\n public readonly type: GltfDataType;\r\n public readonly accessor: any;\r\n public readonly stride: number;\r\n\r\n public get byteLength(): number { return this.data.length; }\r\n\r\n public constructor(data: Uint8Array, count: number, type: GltfDataType, accessor: any, stride: number) {\r\n this.data = data;\r\n this.count = count;\r\n this.type = type;\r\n this.accessor = accessor;\r\n this.stride = stride;\r\n }\r\n\r\n public toBufferData(desiredType: GltfDataType): GltfBufferData | undefined {\r\n return GltfBufferData.create(this.data, this.type, desiredType, this.count);\r\n }\r\n}\r\n\r\n/** Header preceding glTF data.\r\n * @internal\r\n */\r\nexport class GltfHeader extends TileHeader {\r\n public readonly gltfLength: number;\r\n public readonly scenePosition: number = 0;\r\n public readonly sceneStrLength: number = 0;\r\n public readonly binaryPosition: number = 0;\r\n public get isValid(): boolean { return TileFormat.Gltf === this.format; }\r\n\r\n public constructor(stream: ByteStream) {\r\n super(stream);\r\n this.gltfLength = stream.nextUint32;\r\n this.sceneStrLength = stream.nextUint32;\r\n const value5 = stream.nextUint32;\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 && value5 === GltfVersions.Gltf1SceneFormat)\r\n this.version = GltfVersions.Version1;\r\n\r\n if (this.version === GltfVersions.Version1) {\r\n const gltfSceneFormat = value5;\r\n if (GltfVersions.Gltf1SceneFormat !== gltfSceneFormat) {\r\n this.invalidate();\r\n return;\r\n }\r\n\r\n this.scenePosition = stream.curPos;\r\n this.binaryPosition = stream.curPos + this.sceneStrLength;\r\n } else if (this.version === GltfVersions.Version2) {\r\n const sceneChunkType = value5;\r\n this.scenePosition = stream.curPos;\r\n stream.curPos = stream.curPos + this.sceneStrLength;\r\n const binaryLength = stream.nextUint32;\r\n const binaryChunkType = stream.nextUint32;\r\n if (GltfV2ChunkTypes.JSON !== sceneChunkType || GltfV2ChunkTypes.Binary !== binaryChunkType || 0 === binaryLength) {\r\n this.invalidate();\r\n return;\r\n }\r\n\r\n this.binaryPosition = stream.curPos;\r\n } else {\r\n this.invalidate();\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"GltfTileIO.js","sourceRoot":"","sources":["../../../src/tile/GltfTileIO.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,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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,UAAU,CAAC;YACvC,MAAM,eAAe,GAAG,MAAM,CAAC,UAAU,CAAC;YAC1C,IAAI,gBAAgB,CAAC,IAAI,KAAK,cAAc,IAAI,gBAAgB,CAAC,MAAM,KAAK,eAAe,IAAI,CAAC,KAAK,YAAY,EAAE;gBACjH,IAAI,CAAC,UAAU,EAAE,CAAC;gBAClB,OAAO;aACR;YAED,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;SACrC;aAAM;YACL,IAAI,CAAC,UAAU,EAAE,CAAC;SACnB;IACH,CAAC;IArCD,IAAW,OAAO,KAAc,OAAO,mBAAU,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;CAsC1E;AA3CD,gCA2CC","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/** 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/** Header preceding glTF data.\r\n * @internal\r\n */\r\nexport class GltfHeader extends TileHeader {\r\n public readonly gltfLength: number;\r\n public readonly scenePosition: number = 0;\r\n public readonly sceneStrLength: number = 0;\r\n public readonly binaryPosition: number = 0;\r\n public get isValid(): boolean { return TileFormat.Gltf === this.format; }\r\n\r\n public constructor(stream: ByteStream) {\r\n super(stream);\r\n this.gltfLength = stream.nextUint32;\r\n this.sceneStrLength = stream.nextUint32;\r\n const value5 = stream.nextUint32;\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 && value5 === GltfVersions.Gltf1SceneFormat)\r\n this.version = GltfVersions.Version1;\r\n\r\n if (this.version === GltfVersions.Version1) {\r\n const gltfSceneFormat = value5;\r\n if (GltfVersions.Gltf1SceneFormat !== gltfSceneFormat) {\r\n this.invalidate();\r\n return;\r\n }\r\n\r\n this.scenePosition = stream.curPos;\r\n this.binaryPosition = stream.curPos + this.sceneStrLength;\r\n } else if (this.version === GltfVersions.Version2) {\r\n const sceneChunkType = value5;\r\n this.scenePosition = stream.curPos;\r\n stream.curPos = stream.curPos + this.sceneStrLength;\r\n const binaryLength = stream.nextUint32;\r\n const binaryChunkType = stream.nextUint32;\r\n if (GltfV2ChunkTypes.JSON !== sceneChunkType || GltfV2ChunkTypes.Binary !== binaryChunkType || 0 === binaryLength) {\r\n this.invalidate();\r\n return;\r\n }\r\n\r\n this.binaryPosition = stream.curPos;\r\n } else {\r\n this.invalidate();\r\n }\r\n }\r\n}\r\n"]}
@@ -17,84 +17,6 @@ export declare enum GltfV2ChunkTypes {
17
17
  JSON = 1313821514,
18
18
  Binary = 5130562
19
19
  }
20
- /** @internal */
21
- export declare enum GltfMeshMode {
22
- Points = 0,
23
- Lines = 1,
24
- LineStrip = 3,
25
- Triangles = 4
26
- }
27
- /** @internal */
28
- export declare enum GltfDataType {
29
- SignedByte = 5120,
30
- UnsignedByte = 5121,
31
- SignedShort = 5122,
32
- UnsignedShort = 5123,
33
- UInt32 = 5125,
34
- Float = 5126,
35
- Rgb = 6407,
36
- Rgba = 6408,
37
- IntVec2 = 35667,
38
- IntVec3 = 35668,
39
- FloatVec2 = 35664,
40
- FloatVec3 = 35665,
41
- FloatVec4 = 35666,
42
- FloatMat3 = 35675,
43
- FloatMat4 = 35676,
44
- Sampler2d = 35678
45
- }
46
- /** @internal */
47
- export declare enum GltfConstants {
48
- CullFace = 2884,
49
- DepthTest = 2929,
50
- Nearest = 9728,
51
- Linear = 9729,
52
- LinearMipmapLinear = 9987,
53
- ClampToEdge = 33071,
54
- ArrayBuffer = 34962,
55
- ElementArrayBuffer = 34963,
56
- FragmentShader = 35632,
57
- VertexShader = 35633
58
- }
59
- /** @internal */
60
- export declare type GltfDataBuffer = Uint8Array | Uint16Array | Uint32Array | Float32Array;
61
- /**
62
- * A chunk of binary data exposed as a typed array.
63
- * The count member indicates how many elements exist. This may be less than this.buffer.length due to padding added to the
64
- * binary stream to ensure correct alignment.
65
- * @internal
66
- */
67
- export declare class GltfBufferData {
68
- readonly buffer: GltfDataBuffer;
69
- readonly count: number;
70
- constructor(buffer: GltfDataBuffer, count: number);
71
- /**
72
- * Create a GltfBufferData of the desired type. The actual type may differ from the desired type - for example, small 32-bit integers
73
- * may be represented as 8-bit or 16-bit integers instead.
74
- * If the actual data type is not convertible to the desired type, this function returns undefined.
75
- */
76
- static create(bytes: Uint8Array, actualType: GltfDataType, expectedType: GltfDataType, count: number): GltfBufferData | undefined;
77
- private static createDataBuffer;
78
- }
79
- /**
80
- * A view of a chunk of glTF binary data containing an array of elements of a specific data type.
81
- * The count member indicates how many elements exist; this may be smaller than this.data.length.
82
- * The count member may also indicate the number of elements of a type containing more than one value of the
83
- * underlying type. For example, a buffer of 4 32-bit floating point 'vec2' elements will have a count of 4,
84
- * but its data member will contain 8 32-bit floating point values (2 per vec2).
85
- * The accessor member may contain additional JSON data specific to a particular buffer.
86
- * @internal
87
- */
88
- export declare class GltfBufferView {
89
- readonly data: Uint8Array;
90
- readonly count: number;
91
- readonly type: GltfDataType;
92
- readonly accessor: any;
93
- readonly stride: number;
94
- get byteLength(): number;
95
- constructor(data: Uint8Array, count: number, type: GltfDataType, accessor: any, stride: number);
96
- toBufferData(desiredType: GltfDataType): GltfBufferData | undefined;
97
- }
98
20
  /** Header preceding glTF data.
99
21
  * @internal
100
22
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Glt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,QAAQ,IAAI;IACZ,cAAc,IAAW;IACzB,gBAAgB,IAAI;CACrB;AAED,gBAAgB;AAChB,oBAAY,gBAAgB;IAC1B,IAAI,aAAa;IACjB,MAAM,UAAa;CACpB;AAED;;GAEG;AACH,qBAAa,UAAW,SAAQ,UAAU;IACxC,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,aAAa,EAAE,MAAM,CAAK;IAC1C,SAAgB,cAAc,EAAE,MAAM,CAAK;IAC3C,SAAgB,cAAc,EAAE,MAAM,CAAK;IAC3C,IAAW,OAAO,IAAI,OAAO,CAA4C;gBAEtD,MAAM,EAAE,UAAU;CAoCtC"}
@@ -22,123 +22,6 @@ export var GltfV2ChunkTypes;
22
22
  GltfV2ChunkTypes[GltfV2ChunkTypes["JSON"] = 1313821514] = "JSON";
23
23
  GltfV2ChunkTypes[GltfV2ChunkTypes["Binary"] = 5130562] = "Binary";
24
24
  })(GltfV2ChunkTypes || (GltfV2ChunkTypes = {}));
25
- /** @internal */
26
- export var GltfMeshMode;
27
- (function (GltfMeshMode) {
28
- GltfMeshMode[GltfMeshMode["Points"] = 0] = "Points";
29
- GltfMeshMode[GltfMeshMode["Lines"] = 1] = "Lines";
30
- GltfMeshMode[GltfMeshMode["LineStrip"] = 3] = "LineStrip";
31
- GltfMeshMode[GltfMeshMode["Triangles"] = 4] = "Triangles";
32
- })(GltfMeshMode || (GltfMeshMode = {}));
33
- /** @internal */
34
- export var GltfDataType;
35
- (function (GltfDataType) {
36
- GltfDataType[GltfDataType["SignedByte"] = 5120] = "SignedByte";
37
- GltfDataType[GltfDataType["UnsignedByte"] = 5121] = "UnsignedByte";
38
- GltfDataType[GltfDataType["SignedShort"] = 5122] = "SignedShort";
39
- GltfDataType[GltfDataType["UnsignedShort"] = 5123] = "UnsignedShort";
40
- GltfDataType[GltfDataType["UInt32"] = 5125] = "UInt32";
41
- GltfDataType[GltfDataType["Float"] = 5126] = "Float";
42
- GltfDataType[GltfDataType["Rgb"] = 6407] = "Rgb";
43
- GltfDataType[GltfDataType["Rgba"] = 6408] = "Rgba";
44
- GltfDataType[GltfDataType["IntVec2"] = 35667] = "IntVec2";
45
- GltfDataType[GltfDataType["IntVec3"] = 35668] = "IntVec3";
46
- GltfDataType[GltfDataType["FloatVec2"] = 35664] = "FloatVec2";
47
- GltfDataType[GltfDataType["FloatVec3"] = 35665] = "FloatVec3";
48
- GltfDataType[GltfDataType["FloatVec4"] = 35666] = "FloatVec4";
49
- GltfDataType[GltfDataType["FloatMat3"] = 35675] = "FloatMat3";
50
- GltfDataType[GltfDataType["FloatMat4"] = 35676] = "FloatMat4";
51
- GltfDataType[GltfDataType["Sampler2d"] = 35678] = "Sampler2d";
52
- })(GltfDataType || (GltfDataType = {}));
53
- /** @internal */
54
- export var GltfConstants;
55
- (function (GltfConstants) {
56
- GltfConstants[GltfConstants["CullFace"] = 2884] = "CullFace";
57
- GltfConstants[GltfConstants["DepthTest"] = 2929] = "DepthTest";
58
- GltfConstants[GltfConstants["Nearest"] = 9728] = "Nearest";
59
- GltfConstants[GltfConstants["Linear"] = 9729] = "Linear";
60
- GltfConstants[GltfConstants["LinearMipmapLinear"] = 9987] = "LinearMipmapLinear";
61
- GltfConstants[GltfConstants["ClampToEdge"] = 33071] = "ClampToEdge";
62
- GltfConstants[GltfConstants["ArrayBuffer"] = 34962] = "ArrayBuffer";
63
- GltfConstants[GltfConstants["ElementArrayBuffer"] = 34963] = "ElementArrayBuffer";
64
- GltfConstants[GltfConstants["FragmentShader"] = 35632] = "FragmentShader";
65
- GltfConstants[GltfConstants["VertexShader"] = 35633] = "VertexShader";
66
- })(GltfConstants || (GltfConstants = {}));
67
- /**
68
- * A chunk of binary data exposed as a typed array.
69
- * The count member indicates how many elements exist. This may be less than this.buffer.length due to padding added to the
70
- * binary stream to ensure correct alignment.
71
- * @internal
72
- */
73
- export class GltfBufferData {
74
- constructor(buffer, count) {
75
- this.buffer = buffer;
76
- this.count = count;
77
- }
78
- /**
79
- * Create a GltfBufferData of the desired type. The actual type may differ from the desired type - for example, small 32-bit integers
80
- * may be represented as 8-bit or 16-bit integers instead.
81
- * If the actual data type is not convertible to the desired type, this function returns undefined.
82
- */
83
- static create(bytes, actualType, expectedType, count) {
84
- if (expectedType !== actualType) {
85
- // Some data is stored in smaller data types to save space if no values exceed the maximum of the smaller type.
86
- switch (expectedType) {
87
- case GltfDataType.Float:
88
- case GltfDataType.UnsignedByte:
89
- return undefined;
90
- case GltfDataType.UnsignedShort:
91
- if (GltfDataType.UnsignedByte !== actualType)
92
- return undefined;
93
- break;
94
- case GltfDataType.UInt32:
95
- if (GltfDataType.UnsignedByte !== actualType && GltfDataType.UnsignedShort !== actualType)
96
- return undefined;
97
- break;
98
- }
99
- }
100
- const data = this.createDataBuffer(bytes, actualType);
101
- return undefined !== data ? new GltfBufferData(data, count) : undefined;
102
- }
103
- static createDataBuffer(bytes, actualType) {
104
- // NB: Endianness of typed array data is determined by the 'platform byte order'. Actual data is always little-endian.
105
- // We are assuming little-endian platform. If we find a big-endian platform, we'll need to use a DataView instead.
106
- switch (actualType) {
107
- case GltfDataType.UnsignedByte:
108
- return bytes;
109
- case GltfDataType.UnsignedShort:
110
- return new Uint16Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 2);
111
- case GltfDataType.UInt32:
112
- return new Uint32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4);
113
- case GltfDataType.Float:
114
- return new Float32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4);
115
- default:
116
- return undefined;
117
- }
118
- }
119
- }
120
- /**
121
- * A view of a chunk of glTF binary data containing an array of elements of a specific data type.
122
- * The count member indicates how many elements exist; this may be smaller than this.data.length.
123
- * The count member may also indicate the number of elements of a type containing more than one value of the
124
- * underlying type. For example, a buffer of 4 32-bit floating point 'vec2' elements will have a count of 4,
125
- * but its data member will contain 8 32-bit floating point values (2 per vec2).
126
- * The accessor member may contain additional JSON data specific to a particular buffer.
127
- * @internal
128
- */
129
- export class GltfBufferView {
130
- constructor(data, count, type, accessor, stride) {
131
- this.data = data;
132
- this.count = count;
133
- this.type = type;
134
- this.accessor = accessor;
135
- this.stride = stride;
136
- }
137
- get byteLength() { return this.data.length; }
138
- toBufferData(desiredType) {
139
- return GltfBufferData.create(this.data, this.type, desiredType, this.count);
140
- }
141
- }
142
25
  /** Header preceding glTF data.
143
26
  * @internal
144
27
  */
@@ -1 +1 @@
1
- {"version":3,"file":"GltfTileIO.js","sourceRoot":"","sources":["../../../src/tile/GltfTileIO.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAElD;;GAEG;AACH,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,uDAAY,CAAA;IACZ,uDAAY,CAAA;IACZ,mEAAyB,CAAA;IACzB,uEAAoB,CAAA;AACtB,CAAC,EALW,YAAY,KAAZ,YAAY,QAKvB;AAED,gBAAgB;AAChB,MAAM,CAAN,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,gEAAiB,CAAA;IACjB,iEAAmB,CAAA;AACrB,CAAC,EAHW,gBAAgB,KAAhB,gBAAgB,QAG3B;AAED,gBAAgB;AAChB,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,mDAAU,CAAA;IACV,iDAAS,CAAA;IACT,yDAAa,CAAA;IACb,yDAAa,CAAA;AACf,CAAC,EALW,YAAY,KAAZ,YAAY,QAKvB;AAED,gBAAgB;AAChB,MAAM,CAAN,IAAY,YAiBX;AAjBD,WAAY,YAAY;IACtB,8DAAmB,CAAA;IACnB,kEAAqB,CAAA;IACrB,gEAAkB,CAAA;IAClB,oEAAoB,CAAA;IACpB,sDAAa,CAAA;IACb,oDAAY,CAAA;IACZ,gDAAU,CAAA;IACV,kDAAW,CAAA;IACX,yDAAgB,CAAA;IAChB,yDAAgB,CAAA;IAChB,6DAAiB,CAAA;IACjB,6DAAiB,CAA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M,GAAG,IAAI,CAAC,cAAc,CAAC;YACpD,MAAM,YAAY,GAAG,MAAM,CAAC,UAAU,CAAC;YACvC,MAAM,eAAe,GAAG,MAAM,CAAC,UAAU,CAAC;YAC1C,IAAI,gBAAgB,CAAC,IAAI,KAAK,cAAc,IAAI,gBAAgB,CAAC,MAAM,KAAK,eAAe,IAAI,CAAC,KAAK,YAAY,EAAE;gBACjH,IAAI,CAAC,UAAU,EAAE,CAAC;gBAClB,OAAO;aACR;YAED,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;SACrC;aAAM;YACL,IAAI,CAAC,UAAU,EAAE,CAAC;SACnB;IACH,CAAC;IArCD,IAAW,OAAO,KAAc,OAAO,UAAU,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;CAsC1E","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/** 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/** @internal */\r\nexport enum GltfMeshMode {\r\n Points = 0,\r\n Lines = 1,\r\n LineStrip = 3,\r\n Triangles = 4,\r\n}\r\n\r\n/** @internal */\r\nexport enum GltfDataType {\r\n SignedByte = 0x1400,\r\n UnsignedByte = 0x1401,\r\n SignedShort = 5122,\r\n UnsignedShort = 5123,\r\n UInt32 = 5125,\r\n Float = 5126,\r\n Rgb = 6407,\r\n Rgba = 6408,\r\n IntVec2 = 0x8b53,\r\n IntVec3 = 0x8b54,\r\n FloatVec2 = 35664,\r\n FloatVec3 = 35665,\r\n FloatVec4 = 35666,\r\n FloatMat3 = 35675,\r\n FloatMat4 = 35676,\r\n Sampler2d = 35678,\r\n}\r\n\r\n/** @internal */\r\nexport enum GltfConstants {\r\n CullFace = 2884,\r\n DepthTest = 2929,\r\n Nearest = 0x2600,\r\n Linear = 9729,\r\n LinearMipmapLinear = 9987,\r\n ClampToEdge = 33071,\r\n ArrayBuffer = 34962,\r\n ElementArrayBuffer = 34963,\r\n FragmentShader = 35632,\r\n VertexShader = 35633,\r\n}\r\n\r\n/** @internal */\r\nexport type GltfDataBuffer = Uint8Array | Uint16Array | Uint32Array | Float32Array;\r\n\r\n/**\r\n * A chunk of binary data exposed as a typed array.\r\n * The count member indicates how many elements exist. This may be less than this.buffer.length due to padding added to the\r\n * binary stream to ensure correct alignment.\r\n * @internal\r\n */\r\nexport class GltfBufferData {\r\n public readonly buffer: GltfDataBuffer;\r\n public readonly count: number;\r\n\r\n public constructor(buffer: GltfDataBuffer, count: number) {\r\n this.buffer = buffer;\r\n this.count = count;\r\n }\r\n\r\n /**\r\n * Create a GltfBufferData of the desired type. The actual type may differ from the desired type - for example, small 32-bit integers\r\n * may be represented as 8-bit or 16-bit integers instead.\r\n * If the actual data type is not convertible to the desired type, this function returns undefined.\r\n */\r\n public static create(bytes: Uint8Array, actualType: GltfDataType, expectedType: GltfDataType, count: number): GltfBufferData | undefined {\r\n if (expectedType !== actualType) {\r\n // Some data is stored in smaller data types to save space if no values exceed the maximum of the smaller type.\r\n switch (expectedType) {\r\n case GltfDataType.Float:\r\n case GltfDataType.UnsignedByte:\r\n return undefined;\r\n case GltfDataType.UnsignedShort:\r\n if (GltfDataType.UnsignedByte !== actualType)\r\n return undefined;\r\n break;\r\n case GltfDataType.UInt32:\r\n if (GltfDataType.UnsignedByte !== actualType && GltfDataType.UnsignedShort !== actualType)\r\n return undefined;\r\n break;\r\n }\r\n }\r\n\r\n const data = this.createDataBuffer(bytes, actualType);\r\n return undefined !== data ? new GltfBufferData(data, count) : undefined;\r\n }\r\n\r\n private static createDataBuffer(bytes: Uint8Array, actualType: GltfDataType): GltfDataBuffer | undefined {\r\n // NB: Endianness of typed array data is determined by the 'platform byte order'. Actual data is always little-endian.\r\n // We are assuming little-endian platform. If we find a big-endian platform, we'll need to use a DataView instead.\r\n switch (actualType) {\r\n case GltfDataType.UnsignedByte:\r\n return bytes;\r\n case GltfDataType.UnsignedShort:\r\n return new Uint16Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 2);\r\n case GltfDataType.UInt32:\r\n return new Uint32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4);\r\n case GltfDataType.Float:\r\n return new Float32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4);\r\n default:\r\n return undefined;\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * A view of a chunk of glTF binary data containing an array of elements of a specific data type.\r\n * The count member indicates how many elements exist; this may be smaller than this.data.length.\r\n * The count member may also indicate the number of elements of a type containing more than one value of the\r\n * underlying type. For example, a buffer of 4 32-bit floating point 'vec2' elements will have a count of 4,\r\n * but its data member will contain 8 32-bit floating point values (2 per vec2).\r\n * The accessor member may contain additional JSON data specific to a particular buffer.\r\n * @internal\r\n */\r\nexport class GltfBufferView {\r\n public readonly data: Uint8Array;\r\n public readonly count: number;\r\n public readonly type: GltfDataType;\r\n public readonly accessor: any;\r\n public readonly stride: number;\r\n\r\n public get byteLength(): number { return this.data.length; }\r\n\r\n public constructor(data: Uint8Array, count: number, type: GltfDataType, accessor: any, stride: number) {\r\n this.data = data;\r\n this.count = count;\r\n this.type = type;\r\n this.accessor = accessor;\r\n this.stride = stride;\r\n }\r\n\r\n public toBufferData(desiredType: GltfDataType): GltfBufferData | undefined {\r\n return GltfBufferData.create(this.data, this.type, desiredType, this.count);\r\n }\r\n}\r\n\r\n/** Header preceding glTF data.\r\n * @internal\r\n */\r\nexport class GltfHeader extends TileHeader {\r\n public readonly gltfLength: number;\r\n public readonly scenePosition: number = 0;\r\n public readonly sceneStrLength: number = 0;\r\n public readonly binaryPosition: number = 0;\r\n public get isValid(): boolean { return TileFormat.Gltf === this.format; }\r\n\r\n public constructor(stream: ByteStream) {\r\n super(stream);\r\n this.gltfLength = stream.nextUint32;\r\n this.sceneStrLength = stream.nextUint32;\r\n const value5 = stream.nextUint32;\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 && value5 === GltfVersions.Gltf1SceneFormat)\r\n this.version = GltfVersions.Version1;\r\n\r\n if (this.version === GltfVersions.Version1) {\r\n const gltfSceneFormat = value5;\r\n if (GltfVersions.Gltf1SceneFormat !== gltfSceneFormat) {\r\n this.invalidate();\r\n return;\r\n }\r\n\r\n this.scenePosition = stream.curPos;\r\n this.binaryPosition = stream.curPos + this.sceneStrLength;\r\n } else if (this.version === GltfVersions.Version2) {\r\n const sceneChunkType = value5;\r\n this.scenePosition = stream.curPos;\r\n stream.curPos = stream.curPos + this.sceneStrLength;\r\n const binaryLength = stream.nextUint32;\r\n const binaryChunkType = stream.nextUint32;\r\n if (GltfV2ChunkTypes.JSON !== sceneChunkType || GltfV2ChunkTypes.Binary !== binaryChunkType || 0 === binaryLength) {\r\n this.invalidate();\r\n return;\r\n }\r\n\r\n this.binaryPosition = stream.curPos;\r\n } else {\r\n this.invalidate();\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"GltfTileIO.js","sourceRoot":"","sources":["../../../src/tile/GltfTileIO.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAElD;;GAEG;AACH,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,uDAAY,CAAA;IACZ,uDAAY,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9B,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC;YACnC,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC;YACpD,MAAM,YAAY,GAAG,MAAM,CAAC,UAAU,CAAC;YACvC,MAAM,eAAe,GAAG,MAAM,CAAC,UAAU,CAAC;YAC1C,IAAI,gBAAgB,CAAC,IAAI,KAAK,cAAc,IAAI,gBAAgB,CAAC,MAAM,KAAK,eAAe,IAAI,CAAC,KAAK,YAAY,EAAE;gBACjH,IAAI,CAAC,UAAU,EAAE,CAAC;gBAClB,OAAO;aACR;YAED,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;SACrC;aAAM;YACL,IAAI,CAAC,UAAU,EAAE,CAAC;SACnB;IACH,CAAC;IArCD,IAAW,OAAO,KAAc,OAAO,UAAU,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;CAsC1E","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/** 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/** Header preceding glTF data.\r\n * @internal\r\n */\r\nexport class GltfHeader extends TileHeader {\r\n public readonly gltfLength: number;\r\n public readonly scenePosition: number = 0;\r\n public readonly sceneStrLength: number = 0;\r\n public readonly binaryPosition: number = 0;\r\n public get isValid(): boolean { return TileFormat.Gltf === this.format; }\r\n\r\n public constructor(stream: ByteStream) {\r\n super(stream);\r\n this.gltfLength = stream.nextUint32;\r\n this.sceneStrLength = stream.nextUint32;\r\n const value5 = stream.nextUint32;\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 && value5 === GltfVersions.Gltf1SceneFormat)\r\n this.version = GltfVersions.Version1;\r\n\r\n if (this.version === GltfVersions.Version1) {\r\n const gltfSceneFormat = value5;\r\n if (GltfVersions.Gltf1SceneFormat !== gltfSceneFormat) {\r\n this.invalidate();\r\n return;\r\n }\r\n\r\n this.scenePosition = stream.curPos;\r\n this.binaryPosition = stream.curPos + this.sceneStrLength;\r\n } else if (this.version === GltfVersions.Version2) {\r\n const sceneChunkType = value5;\r\n this.scenePosition = stream.curPos;\r\n stream.curPos = stream.curPos + this.sceneStrLength;\r\n const binaryLength = stream.nextUint32;\r\n const binaryChunkType = stream.nextUint32;\r\n if (GltfV2ChunkTypes.JSON !== sceneChunkType || GltfV2ChunkTypes.Binary !== binaryChunkType || 0 === binaryLength) {\r\n this.invalidate();\r\n return;\r\n }\r\n\r\n this.binaryPosition = stream.curPos;\r\n } else {\r\n this.invalidate();\r\n }\r\n }\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/core-common",
3
- "version": "3.0.0-dev.156",
3
+ "version": "3.0.0-dev.161",
4
4
  "description": "iTwin.js components common to frontend and backend",
5
5
  "main": "lib/cjs/core-common.js",
6
6
  "module": "lib/esm/core-common.js",
@@ -29,14 +29,14 @@
29
29
  "js-base64": "^3.6.1"
30
30
  },
31
31
  "peerDependencies": {
32
- "@itwin/core-bentley": "^3.0.0-dev.156",
33
- "@itwin/core-geometry": "^3.0.0-dev.156"
32
+ "@itwin/core-bentley": "^3.0.0-dev.161",
33
+ "@itwin/core-geometry": "^3.0.0-dev.161"
34
34
  },
35
35
  "devDependencies": {
36
- "@itwin/build-tools": "3.0.0-dev.156",
37
- "@itwin/core-bentley": "3.0.0-dev.156",
38
- "@itwin/core-geometry": "3.0.0-dev.156",
39
- "@itwin/eslint-plugin": "3.0.0-dev.156",
36
+ "@itwin/build-tools": "3.0.0-dev.161",
37
+ "@itwin/core-bentley": "3.0.0-dev.161",
38
+ "@itwin/core-geometry": "3.0.0-dev.161",
39
+ "@itwin/eslint-plugin": "3.0.0-dev.161",
40
40
  "@types/chai": "^4.1.4",
41
41
  "@types/flatbuffers": "~1.10.0",
42
42
  "@types/mocha": "^8.2.2",