@loaders.gl/schema 5.0.0-alpha.6 → 5.0.0-alpha.8

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/dist/index.cjs CHANGED
@@ -30,13 +30,20 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // dist/index.js
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
+ convertColorArrayToFloat16: () => convertColorArrayToFloat16,
34
+ convertColorArrayToFloat32: () => convertColorArrayToFloat32,
35
+ createFloat16Array: () => createFloat16Array,
36
+ encodeFloat16: () => encodeFloat16,
37
+ getFloat16Storage: () => getFloat16Storage,
38
+ getFloat16Value: () => getFloat16Value,
33
39
  getGeoMetadata: () => getGeoMetadata,
34
40
  getMeshBoundingBox: () => getMeshBoundingBox,
35
- getMeshSize: () => getMeshSize,
36
41
  getMetadataValue: () => getMetadataValue,
37
42
  indexedMeshArrowSchema: () => indexedMeshArrowSchema,
43
+ isNativeFloat16Array: () => isNativeFloat16Array,
38
44
  meshArrowSchema: () => meshArrowSchema,
39
45
  parseJSONStringMetadata: () => parseJSONStringMetadata,
46
+ setFloat16Value: () => setFloat16Value,
40
47
  setGeoMetadata: () => setGeoMetadata,
41
48
  setMetadataValue: () => setMetadataValue,
42
49
  unpackGeoMetadata: () => unpackGeoMetadata,
@@ -44,6 +51,80 @@ __export(index_exports, {
44
51
  });
45
52
  module.exports = __toCommonJS(index_exports);
46
53
 
54
+ // dist/float16.js
55
+ var import_types = require("@math.gl/types");
56
+ function createFloat16Array(length) {
57
+ const ArrayConstructor = (0, import_types.getFloat16ArrayConstructor)();
58
+ return new ArrayConstructor(length);
59
+ }
60
+ function isNativeFloat16Array(value) {
61
+ return Boolean(import_types.NativeFloat16ArrayConstructor && value instanceof import_types.NativeFloat16ArrayConstructor);
62
+ }
63
+ function setFloat16Value(array, index, value) {
64
+ if (isNativeFloat16Array(array)) {
65
+ array[index] = value;
66
+ } else {
67
+ array[index] = encodeFloat16(value);
68
+ }
69
+ }
70
+ function getFloat16Value(array, index) {
71
+ if (isNativeFloat16Array(array)) {
72
+ return array[index];
73
+ }
74
+ return decodeFloat16(array[index]);
75
+ }
76
+ function getFloat16Storage(array) {
77
+ return isNativeFloat16Array(array) ? new Uint16Array(array.buffer, array.byteOffset, array.length) : array;
78
+ }
79
+ function convertColorArrayToFloat16(values, sourceScale) {
80
+ const result = createFloat16Array(values.length);
81
+ for (let index = 0; index < values.length; index++) {
82
+ setFloat16Value(result, index, values[index] / sourceScale);
83
+ }
84
+ return result;
85
+ }
86
+ function convertColorArrayToFloat32(values, sourceScale) {
87
+ return Float32Array.from(values, (value) => value / sourceScale);
88
+ }
89
+ function encodeFloat16(value) {
90
+ if (!Number.isFinite(value)) {
91
+ return value === Infinity ? 31744 : value === -Infinity ? 64512 : 32256;
92
+ }
93
+ const sign = value < 0 || Object.is(value, -0) ? 32768 : 0;
94
+ const absoluteValue = Math.abs(value);
95
+ if (absoluteValue === 0) {
96
+ return sign;
97
+ }
98
+ if (absoluteValue >= 65520) {
99
+ return sign | 31744;
100
+ }
101
+ if (absoluteValue >= 65504) {
102
+ return sign | 31743;
103
+ }
104
+ const exponent = Math.floor(Math.log2(absoluteValue));
105
+ if (exponent < -14) {
106
+ return sign | Math.round(absoluteValue / 2 ** -24);
107
+ }
108
+ const normalizedExponent = exponent + 15;
109
+ const mantissa = Math.round((absoluteValue / 2 ** exponent - 1) * 1024);
110
+ if (mantissa === 1024) {
111
+ return sign | normalizedExponent + 1 << 10;
112
+ }
113
+ return sign | normalizedExponent << 10 | mantissa;
114
+ }
115
+ function decodeFloat16(value) {
116
+ const sign = value & 32768 ? -1 : 1;
117
+ const exponent = value >> 10 & 31;
118
+ const mantissa = value & 1023;
119
+ if (exponent === 0) {
120
+ return sign * mantissa * 2 ** -24;
121
+ }
122
+ if (exponent === 31) {
123
+ return mantissa ? NaN : sign * Infinity;
124
+ }
125
+ return sign * (1 + mantissa / 1024) * 2 ** (exponent - 15);
126
+ }
127
+
47
128
  // dist/metadata.js
48
129
  function getMetadataValue(metadata, key) {
49
130
  return metadata instanceof Map ? metadata.get(key) || null : metadata[key] || null;
@@ -114,20 +195,10 @@ var meshArrowSchema = new arrow.Schema([
114
195
  ]);
115
196
  var indexedMeshArrowSchema = new arrow.Schema([
116
197
  ...meshArrowSchema.fields,
117
- new arrow.Field("indices", new arrow.List(new arrow.Field("item", new arrow.Int32(), false)), true)
198
+ new arrow.Field("indices", new arrow.List(new arrow.Field("item", new arrow.Uint32(), false)), true)
118
199
  ]);
119
200
 
120
201
  // dist/deprecated/mesh-utils.js
121
- function getMeshSize(attributes) {
122
- let size = 0;
123
- for (const attributeName in attributes) {
124
- const attribute = attributes[attributeName];
125
- if (ArrayBuffer.isView(attribute)) {
126
- size += attribute.byteLength * attribute.BYTES_PER_ELEMENT;
127
- }
128
- }
129
- return size;
130
- }
131
202
  function getMeshBoundingBox(attributes) {
132
203
  let minX = Infinity;
133
204
  let minY = Infinity;
@@ -136,11 +207,11 @@ function getMeshBoundingBox(attributes) {
136
207
  let maxY = -Infinity;
137
208
  let maxZ = -Infinity;
138
209
  const positions = attributes.POSITION ? attributes.POSITION.value : [];
139
- const len = positions && positions.length;
140
- for (let i = 0; i < len; i += 3) {
141
- const x = positions[i];
142
- const y = positions[i + 1];
143
- const z = positions[i + 2];
210
+ const length = positions && positions.length;
211
+ for (let index = 0; index < length; index += 3) {
212
+ const x = positions[index];
213
+ const y = positions[index + 1];
214
+ const z = positions[index + 2];
144
215
  minX = x < minX ? x : minX;
145
216
  minY = y < minY ? y : minY;
146
217
  minZ = z < minZ ? z : minZ;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/index.ts", "../src/metadata.ts", "../src/categories/category-mesh.ts", "../src/deprecated/mesh-utils.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;ACwBM,SAAU,iBAAiB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AAO,IAAI;AACtB,WAAO,IAAI,OAAO,IAAI;AACtB,WAAO,IAAI,OAAO,IAAI;AAEtB,WAAO,IAAI,OAAO,IAAI;AACtB,WAAO,IAAI,OAAO,IAAI;AACtB,WAAO,IAAI,OAAO,IAAI;EACxB;AACA,SAAO;IACL,CAAC,MAAM,MAAM,IAAI;IACjB,CAAC,MAAM,MAAM,IAAI;;AAErB;",
3
+ "sources": ["../src/index.ts", "../src/float16.ts", "../src/metadata.ts", "../src/categories/category-mesh.ts", "../src/deprecated/mesh-utils.ts"],
4
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;ACIA,mBAAwE;AAMlE,SAAU,mBAAmB,QAAc;AAC/C,QAAM,uBAAmB,yCAA0B;AACnD,SAAO,IAAI,iBAAiB,MAAM;AACpC;AAGM,SAAU,qBAAqB,OAAc;AACjD,SAAO,QAAQ,8CAAiC,iBAAiB,0CAA6B;AAChG;AAGM,SAAU,gBAAgB,OAA4B,OAAe,OAAa;AACtF,MAAI,qBAAqB,KAAK,GAAG;AAC/B,UAAM,KAAK,IAAI;EACjB,OAAO;AACL,UAAM,KAAK,IAAI,cAAc,KAAK;EACpC;AACF;AAGM,SAAU,gBAAgB,OAA4B,OAAa;AACvE,MAAI,qBAAqB,KAAK,GAAG;AAC/B,WAAO,MAAM,KAAK;EACpB;AACA,SAAO,cAAc,MAAM,KAAK,CAAC;AACnC;AAGM,SAAU,kBAAkB,OAA0B;AAC1D,SAAO,qBAAqB,KAAK,IAC7B,IAAI,YAAY,MAAM,QAAQ,MAAM,YAAY,MAAM,MAAM,IAC5D;AACN;AAGM,SAAU,2BACd,QACA,aAAmB;AAEnB,QAAM,SAAS,mBAAmB,OAAO,MAAM;AAC/C,WAAS,QAAQ,GAAG,QAAQ,OAAO,QAAQ,SAAS;AAClD,oBAAgB,QAAQ,OAAO,OAAO,KAAK,IAAI,WAAW;EAC5D;AACA,SAAO;AACT;AAGM,SA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ray, BigTypedArray, TypedArrayConstructor, BigTypedArrayConstructor, NumberArray, ArrayType, AnyArray } from "./types/types.js";
2
+ export { createFloat16Array, convertColorArrayToFloat16, convertColorArrayToFloat32, encodeFloat16, getFloat16Storage, getFloat16Value, isNativeFloat16Array, setFloat16Value } from "./float16.js";
2
3
  export type { Schema, Field, DataType, KeyType, SchemaMetadata, FieldMetadata } from "./types/schema.js";
3
4
  export type { Metadata, SchemaWithMetadata } from "./metadata.js";
4
5
  export { getGeoMetadata, getMetadataValue, parseJSONStringMetadata, setGeoMetadata, setMetadataValue, unpackGeoMetadata, unpackJSONStringMetadata } from "./metadata.js";
@@ -8,6 +9,8 @@ export type { Table, RowTable, ArrayRowTable, ObjectRowTable, GeoJSONTable, Colu
8
9
  export type { TableBatch, ArrayRowTableBatch, ObjectRowTableBatch, GeoJSONTableBatch, ColumnarTableBatch, ArrowTableBatch } from "./categories/category-table.js";
9
10
  export type { MeshTable, MeshArrowTable, MeshArrowColumns, IndexedMeshArrowColumns, MeshArrowTableData, IndexedMeshArrowTableData, Mesh, MeshGeometry, MeshAttribute, MeshAttributeOctahedronTransform, MeshAttributeQuantizationTransform, MeshAttributeTransform, MeshAttributes, MeshTopology } from "./categories/category-mesh.js";
10
11
  export { meshArrowSchema, indexedMeshArrowSchema } from "./categories/category-mesh.js";
12
+ /** @deprecated Import `getMeshBoundingBox` from `@loaders.gl/schema-utils`. */
13
+ export { getMeshBoundingBox } from "./deprecated/mesh-utils.js";
11
14
  export type { TextureMetadata, Texture, Texture1D, Texture2D, Texture3D, TextureCube, Texture2DArray, TextureCubeArray, TextureLevel, GPUTextureFormat, TextureFormat } from "./categories/category-texture.js";
12
15
  export type { ImageDataType, ImageType, ImageTypeEnum } from "./categories/category-image.js";
13
16
  export type { GeoJSON, Feature, FeatureCollection, Geometry, Position, GeoJsonProperties, Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon, GeometryCollection } from "./categories/category-gis.js";
@@ -15,5 +18,4 @@ export type { FlatFeature, FlatIndexedGeometry, FlatGeometry, FlatGeometryType,
15
18
  export type { BinaryGeometryType, BinaryGeometry, BinaryPointGeometry, BinaryLineGeometry, BinaryPolygonGeometry, BinaryAttribute } from "./categories/category-gis.js";
16
19
  export type { BinaryFeatureCollection, BinaryFeature, BinaryPointFeature, BinaryLineFeature, BinaryPolygonFeature } from "./categories/category-gis.js";
17
20
  export type { ArrowBinaryFeatureTable, ArrowBinaryPointFeature, ArrowBinaryLineFeature, ArrowBinaryPolygonFeature, ArrowBinaryFeatureCollection, BinaryFeatureCollectionLike } from "./categories/category-gis.js";
18
- export { getMeshSize, getMeshBoundingBox } from "./deprecated/mesh-utils.js";
19
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,YAAY,EACV,UAAU,EACV,aAAa,EACb,qBAAqB,EACrB,wBAAwB,EACxB,WAAW,EACX,SAAS,EACT,QAAQ,EACT,yBAAsB;AAIvB,YAAY,EAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAC,0BAAuB;AACpG,YAAY,EAAC,QAAQ,EAAE,kBAAkB,EAAC,sBAAmB;AAC7D,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,wBAAwB,EACzB,sBAAmB;AACpB,YAAY,EAAC,KAAK,EAAC,yBAAsB;AACzC,YAAY,EACV,gBAAgB,EAChB,0BAA0B,EAC1B,iBAAiB,EACjB,wBAAwB,EACxB,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,iBAAiB,EACjB,WAAW,EACZ,+BAA4B;AAG7B,YAAY,EACV,KAAK,EACL,QAAQ,EACR,aAAa,EACb,cAAc,EACd,YAA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qCAAkC;AAMnC,OAAO,EAAC,WAAW,EAAE,kBAAkB,EAAC,mCAAgC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,YAAY,EACV,UAAU,EACV,aAAa,EACb,qBAAqB,EACrB,wBAAwB,EACxB,WAAW,EACX,SAAS,EACT,QAAQ,EACT,yBAAsB;AACvB,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,0BAA0B,EAC1B,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,eAAe,EAChB,qBAAkB;AAInB,YAAY,EAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAC,0BAAuB;AACpG,YAAY,EAAC,QAAQ,EAAE,kBAAkB,EAAC,sBAAmB;AAC7D,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,wBAAwB,EACzB,sBAAmB;AACpB,YAAY,EAAC,KAAK,EAAC,yBAAsB;AACzC,YAAY,EACV,gBAAgB,EAChB,0BAA0B,EAC1B,iBAAiB,EACjB,wBAAwB,EACxB,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,iBAAiB,EACjB,WAAW,EACZ,+BAA4B;AAG7B,YAAY,EACV,KAAK,EACL,QAAQ,EACR,aAAa,EACb,cAAc,EACd,YAAY,EACZ,aAAa,EACb,UAAU,EACV,MAAM,EACP,uCAAoC;AACrC,YAAY,EACV,UAAU,EACV,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EAChB,uCAAoC;AAGrC,YAAY,EACV,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,yBAAyB,EACzB,IAAI,EACJ,YAAY,EACZ,aAAa,EACb,gCAAgC,EAChC,kCAAkC,EAClC,sBAAsB,EACtB,cAAc,EACd,YAAY,EACb,sCAAmC;AACpC,OAAO,EAAC,eAAe,EAAE,sBAAsB,EAAC,sCAAmC;AACnF,+EAA+E;AAC/E,OAAO,EAAC,kBAAkB,EAAC,mCAAgC;AAE3D,YAAY,EACV,eAAe,EACf,OAAO,EACP,SAAS,EACT,SAAS,EACT,SAAS,EACT,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACd,yCAAsC;AAGvC,YAAY,EAAC,aAAa,EAAE,SAAS,EAAE,aAAa,EAAC,uCAAoC;AAMzF,YAAY,EACV,OAAO,EACP,OAAO,EACP,iBAAiB,EACjB,QAAQ,EACR,QAAQ,EACR,iBAAiB,EACjB,KAAK,EACL,UAAU,EACV,UAAU,EACV,eAAe,EACf,OAAO,EACP,YAAY,EACZ,kBAAkB,EACnB,qCAAkC;AAGnC,YAAY,EACV,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,EAChB,SAAS,EACT,cAAc,EACd,WAAW,EACZ,qCAAkC;AAGnC,YAAY,EACV,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EAChB,qCAAkC;AACnC,YAAY,EACV,uBAAuB,EACvB,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACrB,qCAAkC;AACnC,YAAY,EACV,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,4BAA4B,EAC5B,2BAA2B,EAC5B,qCAAkC"}
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  // loaders.gl
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
+ export { createFloat16Array, convertColorArrayToFloat16, convertColorArrayToFloat32, encodeFloat16, getFloat16Storage, getFloat16Value, isNativeFloat16Array, setFloat16Value } from "./float16.js";
4
5
  export { getGeoMetadata, getMetadataValue, parseJSONStringMetadata, setGeoMetadata, setMetadataValue, unpackGeoMetadata, unpackJSONStringMetadata } from "./metadata.js";
5
6
  export { meshArrowSchema, indexedMeshArrowSchema } from "./categories/category-mesh.js";
6
- // DEPRECATED EXPORTS
7
- // MESH CATEGORY
8
- export { getMeshSize, getMeshBoundingBox } from "./deprecated/mesh-utils.js";
7
+ /** @deprecated Import `getMeshBoundingBox` from `@loaders.gl/schema-utils`. */
8
+ export { getMeshBoundingBox } from "./deprecated/mesh-utils.js";
9
9
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAiBpC,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,wBAAwB,EACzB,sBAAmB;AAwDpB,OAAO,EAAC,eAAe,EAAE,sBAAsB,EAAC,sCAAmC;AA4EnF,qBAAqB;AAErB,gBAAgB;AAEhB,OAAO,EAAC,WAAW,EAAE,kBAAkB,EAAC,mCAAgC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAYpC,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,0BAA0B,EAC1B,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,eAAe,EAChB,qBAAkB;AAMnB,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,wBAAwB,EACzB,sBAAmB;AAwDpB,OAAO,EAAC,eAAe,EAAE,sBAAsB,EAAC,sCAAmC;AACnF,+EAA+E;AAC/E,OAAO,EAAC,kBAAkB,EAAC,mCAAgC"}
@@ -1,7 +1,8 @@
1
+ /// <reference lib="es2025.float16" preserve="true" />
1
2
  /** Any typed array */
2
- export type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array;
3
+ export type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Uint8ClampedArray | Float16Array | Float32Array | Float64Array;
3
4
  export type BigTypedArray = TypedArray | BigInt64Array | BigUint64Array;
4
- export type TypedArrayConstructor = Int8ArrayConstructor | Uint8ArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor;
5
+ export type TypedArrayConstructor = Int8ArrayConstructor | Uint8ArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float16ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor;
5
6
  export type BigTypedArrayConstructor = TypedArrayConstructor | BigInt64ArrayConstructor | BigUint64ArrayConstructor;
6
7
  /** Any numeric array: typed array or `number[]` */
7
8
  export type NumberArray = number[] | TypedArray;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":"AAIA,sBAAsB;AACtB,MAAM,MAAM,UAAU,GAClB,SAAS,GACT,UAAU,GACV,UAAU,GACV,WAAW,GACX,UAAU,GACV,WAAW,GACX,iBAAiB,GACjB,YAAY,GACZ,YAAY,CAAC;AAEjB,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,aAAa,GAAG,cAAc,CAAC;AAExE,MAAM,MAAM,qBAAqB,GAC7B,oBAAoB,GACpB,qBAAqB,GACrB,qBAAqB,GACrB,sBAAsB,GACtB,qBAAqB,GACrB,sBAAsB,GACtB,uBAAuB,GACvB,uBAAuB,CAAC;AAE5B,MAAM,MAAM,wBAAwB,GA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mDAAmD;AACnD,MAAM,MAAM,QAAQ,GAAG,GAAG,EAAE,GAAG,UAAU,CAAC"}
@@ -1,5 +1,6 @@
1
1
  // loaders.gl
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
+ /// <reference lib="es2025.float16" preserve="true" />
4
5
  export {};
5
6
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAKpC,sDAAsD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/schema",
3
- "version": "5.0.0-alpha.6",
3
+ "version": "5.0.0-alpha.8",
4
4
  "description": "Table format APIs for JSON, CSV, etc...",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -41,8 +41,9 @@
41
41
  "build-bundle-dev": "ocular-bundle ./bundle.ts --env=dev --output=dist/dist.dev.js"
42
42
  },
43
43
  "dependencies": {
44
+ "@math.gl/types": "5.0.0-alpha.11",
44
45
  "@types/geojson": "^7946.0.7",
45
46
  "apache-arrow": ">= 17.0.0"
46
47
  },
47
- "gitHead": "9b9ea7738e0fe63e55c19c136283705f99e0b9bf"
48
+ "gitHead": "bdc4536ea5b7d074ea362e372704cbdb180126cc"
48
49
  }
@@ -45,8 +45,8 @@ export type MeshTopology =
45
45
 
46
46
  /** Apache Arrow columns for an indexed mesh vertex table. */
47
47
  export type IndexedMeshArrowColumns = MeshArrowColumns & {
48
- /** Primitive indices, stored in row 0 and null for remaining vertex rows. */
49
- indices: arrow.List<arrow.Int32>;
48
+ /** Unsigned 32-bit primitive indices, stored in row 0 and null for remaining vertex rows. */
49
+ indices: arrow.List<arrow.Uint32>;
50
50
  };
51
51
 
52
52
  /** Raw Apache Arrow table data for a mesh vertex table. */
@@ -69,7 +69,7 @@ export const indexedMeshArrowSchema = new arrow.Schema<IndexedMeshArrowColumns>(
69
69
  ...meshArrowSchema.fields,
70
70
  new arrow.Field(
71
71
  'indices',
72
- new arrow.List(new arrow.Field('item', new arrow.Int32(), false)),
72
+ new arrow.List(new arrow.Field('item', new arrow.Uint32(), false)),
73
73
  true
74
74
  )
75
75
  ]);
@@ -128,6 +128,8 @@ export type MeshAttribute = {
128
128
  byteOffset?: number;
129
129
  byteStride?: number;
130
130
  normalized?: boolean;
131
+ /** Logical component type when the storage array does not expose it directly. */
132
+ componentType?: 'float16';
131
133
  /** Transform required to reconstruct the logical attribute values. */
132
134
  transform?: MeshAttributeTransform;
133
135
  };
@@ -2,41 +2,16 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- // Mesh category utilities
6
- // TODO - move to mesh category module, or to math.gl/geometry module
7
5
  import {MeshAttributes} from '../categories/category-mesh';
8
- import {TypedArray} from '../types/types';
9
6
 
10
- type TypedArrays = {[key: string]: TypedArray};
11
-
12
- /**
13
- * Holds an axis aligned bounding box
14
- * TODO - make sure AxisAlignedBoundingBox in math.gl/culling understands this format (or change this format)
15
- */
16
7
  type BoundingBox = [[number, number, number], [number, number, number]];
17
8
 
18
9
  /**
19
- * Get number of vertices in mesh
20
- * @param attributes
21
- * @deprecated Import from shema-utils
22
- */
23
- export function getMeshSize(attributes: TypedArrays): number {
24
- let size = 0;
25
- for (const attributeName in attributes) {
26
- const attribute = attributes[attributeName];
27
- if (ArrayBuffer.isView(attribute)) {
28
- // @ts-ignore DataView doesn't have BYTES_PER_ELEMENT
29
- size += attribute.byteLength * attribute.BYTES_PER_ELEMENT;
30
- }
31
- }
32
- return size;
33
- }
34
-
35
- /**
36
- * Get the (axis aligned) bounding box of a mesh
37
- * @param attributes
38
- * @returns array of two vectors representing the axis aligned bounding box
39
- * @deprecated Import from shema-utils
10
+ * Get the (axis aligned) bounding box of a mesh.
11
+ * @param attributes Mesh attributes.
12
+ * @returns The axis aligned bounding box as minimum and maximum vectors.
13
+ * @deprecated Import `getMeshBoundingBox` from `@loaders.gl/schema-utils` instead. This root
14
+ * export remains temporarily for deck.gl 9.4 compatibility.
40
15
  */
41
16
  // eslint-disable-next-line complexity
42
17
  export function getMeshBoundingBox(attributes: MeshAttributes): BoundingBox {
@@ -48,12 +23,12 @@ export function getMeshBoundingBox(attributes: MeshAttributes): BoundingBox {
48
23
  let maxZ = -Infinity;
49
24
 
50
25
  const positions = attributes.POSITION ? attributes.POSITION.value : [];
51
- const len = positions && positions.length;
26
+ const length = positions && positions.length;
52
27
 
53
- for (let i = 0; i < len; i += 3) {
54
- const x = positions[i];
55
- const y = positions[i + 1];
56
- const z = positions[i + 2];
28
+ for (let index = 0; index < length; index += 3) {
29
+ const x = positions[index];
30
+ const y = positions[index + 1];
31
+ const z = positions[index + 2];
57
32
 
58
33
  minX = x < minX ? x : minX;
59
34
  minY = y < minY ? y : minY;
@@ -63,6 +38,7 @@ export function getMeshBoundingBox(attributes: MeshAttributes): BoundingBox {
63
38
  maxY = y > maxY ? y : maxY;
64
39
  maxZ = z > maxZ ? z : maxZ;
65
40
  }
41
+
66
42
  return [
67
43
  [minX, minY, minZ],
68
44
  [maxX, maxY, maxZ]
package/src/float16.ts ADDED
@@ -0,0 +1,111 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import {getFloat16ArrayConstructor, NativeFloat16ArrayConstructor} from '@math.gl/types';
6
+
7
+ /** Array storage used for logical Float16 values. */
8
+ export type Float16ArrayStorage = Float16Array | Uint16Array;
9
+
10
+ /** Create native Float16 storage when the runtime supports it. */
11
+ export function createFloat16Array(length: number): Float16ArrayStorage {
12
+ const ArrayConstructor = getFloat16ArrayConstructor();
13
+ return new ArrayConstructor(length) as Float16ArrayStorage;
14
+ }
15
+
16
+ /** Check whether an array is backed by the native Float16Array implementation. */
17
+ export function isNativeFloat16Array(value: unknown): value is Float16Array {
18
+ return Boolean(NativeFloat16ArrayConstructor && value instanceof NativeFloat16ArrayConstructor);
19
+ }
20
+
21
+ /** Write a numeric value into native or binary16 fallback storage. */
22
+ export function setFloat16Value(array: Float16ArrayStorage, index: number, value: number): void {
23
+ if (isNativeFloat16Array(array)) {
24
+ array[index] = value;
25
+ } else {
26
+ array[index] = encodeFloat16(value);
27
+ }
28
+ }
29
+
30
+ /** Read a numeric value from native or binary16 fallback storage. */
31
+ export function getFloat16Value(array: Float16ArrayStorage, index: number): number {
32
+ if (isNativeFloat16Array(array)) {
33
+ return array[index];
34
+ }
35
+ return decodeFloat16(array[index]);
36
+ }
37
+
38
+ /** Return the binary16 words used by Apache Arrow and GPU APIs. */
39
+ export function getFloat16Storage(array: Float16ArrayStorage): Uint16Array {
40
+ return isNativeFloat16Array(array)
41
+ ? new Uint16Array(array.buffer, array.byteOffset, array.length)
42
+ : array;
43
+ }
44
+
45
+ /** Convert byte- or word-scaled color components to logical Float16 values. */
46
+ export function convertColorArrayToFloat16(
47
+ values: ArrayLike<number>,
48
+ sourceScale: number
49
+ ): Float16ArrayStorage {
50
+ const result = createFloat16Array(values.length);
51
+ for (let index = 0; index < values.length; index++) {
52
+ setFloat16Value(result, index, values[index] / sourceScale);
53
+ }
54
+ return result;
55
+ }
56
+
57
+ /** Convert byte- or word-scaled color components to logical Float32 values. */
58
+ export function convertColorArrayToFloat32(
59
+ values: ArrayLike<number>,
60
+ sourceScale: number
61
+ ): Float32Array {
62
+ return Float32Array.from(values, value => value / sourceScale);
63
+ }
64
+
65
+ /** Encode a JavaScript number as an IEEE-754 binary16 bit pattern. */
66
+ export function encodeFloat16(value: number): number {
67
+ if (!Number.isFinite(value)) {
68
+ return value === Infinity ? 0x7c00 : value === -Infinity ? 0xfc00 : 0x7e00;
69
+ }
70
+
71
+ const sign = value < 0 || Object.is(value, -0) ? 0x8000 : 0;
72
+ const absoluteValue = Math.abs(value);
73
+ if (absoluteValue === 0) {
74
+ return sign;
75
+ }
76
+
77
+ // Values at or above the midpoint between the largest finite half and
78
+ // infinity round to infinity using IEEE-754 round-to-nearest-even.
79
+ if (absoluteValue >= 65520) {
80
+ return sign | 0x7c00;
81
+ }
82
+ if (absoluteValue >= 65504) {
83
+ return sign | 0x7bff;
84
+ }
85
+
86
+ const exponent = Math.floor(Math.log2(absoluteValue));
87
+ if (exponent < -14) {
88
+ return sign | Math.round(absoluteValue / 2 ** -24);
89
+ }
90
+
91
+ const normalizedExponent = exponent + 15;
92
+ const mantissa = Math.round((absoluteValue / 2 ** exponent - 1) * 1024);
93
+ if (mantissa === 1024) {
94
+ return sign | ((normalizedExponent + 1) << 10);
95
+ }
96
+ return sign | (normalizedExponent << 10) | mantissa;
97
+ }
98
+
99
+ /** Decode an IEEE-754 binary16 bit pattern. */
100
+ function decodeFloat16(value: number): number {
101
+ const sign = value & 0x8000 ? -1 : 1;
102
+ const exponent = (value >> 10) & 0x1f;
103
+ const mantissa = value & 0x3ff;
104
+ if (exponent === 0) {
105
+ return sign * mantissa * 2 ** -24;
106
+ }
107
+ if (exponent === 0x1f) {
108
+ return mantissa ? NaN : sign * Infinity;
109
+ }
110
+ return sign * (1 + mantissa / 1024) * 2 ** (exponent - 15);
111
+ }
package/src/index.ts CHANGED
@@ -12,6 +12,16 @@ export type {
12
12
  ArrayType,
13
13
  AnyArray
14
14
  } from './types/types';
15
+ export {
16
+ createFloat16Array,
17
+ convertColorArrayToFloat16,
18
+ convertColorArrayToFloat32,
19
+ encodeFloat16,
20
+ getFloat16Storage,
21
+ getFloat16Value,
22
+ isNativeFloat16Array,
23
+ setFloat16Value
24
+ } from './float16';
15
25
 
16
26
  // SCHEMAS AND DATA TYPES
17
27
 
@@ -82,7 +92,8 @@ export type {
82
92
  MeshTopology
83
93
  } from './categories/category-mesh';
84
94
  export {meshArrowSchema, indexedMeshArrowSchema} from './categories/category-mesh';
85
-
95
+ /** @deprecated Import `getMeshBoundingBox` from `@loaders.gl/schema-utils`. */
96
+ export {getMeshBoundingBox} from './deprecated/mesh-utils';
86
97
  // TEXTURES
87
98
  export type {
88
99
  TextureMetadata,
@@ -156,9 +167,3 @@ export type {
156
167
  ArrowBinaryFeatureCollection,
157
168
  BinaryFeatureCollectionLike
158
169
  } from './categories/category-gis';
159
-
160
- // DEPRECATED EXPORTS
161
-
162
- // MESH CATEGORY
163
-
164
- export {getMeshSize, getMeshBoundingBox} from './deprecated/mesh-utils';
@@ -2,6 +2,11 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
+ // Float16Array is declared in a separate TypeScript library. Preserve this reference so
6
+ // published declarations remain self-contained without changing the target or emitting runtime code.
7
+ // eslint-disable-next-line spaced-comment
8
+ /// <reference lib="es2025.float16" preserve="true" />
9
+
5
10
  /** Any typed array */
6
11
  export type TypedArray =
7
12
  | Int8Array
@@ -11,6 +16,7 @@ export type TypedArray =
11
16
  | Int32Array
12
17
  | Uint32Array
13
18
  | Uint8ClampedArray
19
+ | Float16Array
14
20
  | Float32Array
15
21
  | Float64Array;
16
22
 
@@ -23,6 +29,7 @@ export type TypedArrayConstructor =
23
29
  | Uint16ArrayConstructor
24
30
  | Int32ArrayConstructor
25
31
  | Uint32ArrayConstructor
32
+ | Float16ArrayConstructor
26
33
  | Float32ArrayConstructor
27
34
  | Float64ArrayConstructor;
28
35