@takram/three-geospatial 0.0.1-alpha.8 → 0.1.0
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 +5 -0
- package/build/index.cjs +1 -1
- package/build/index.cjs.map +1 -1
- package/build/index.js +2396 -437
- package/build/index.js.map +1 -1
- package/build/r3f.cjs +1 -1
- package/build/shared.cjs +1 -1
- package/package.json +4 -1
- package/src/DataLoader.ts +31 -35
- package/src/EXR3DLoader.ts +48 -0
- package/src/Texture3DLoader.ts +1 -1
- package/src/TilingScheme.ts +15 -11
- package/src/TypedArrayLoader.ts +2 -1
- package/src/index.ts +1 -0
- package/src/typedArray.ts +27 -0
- package/src/typedArrayParsers.ts +21 -6
- package/types/DataLoader.d.ts +2 -9
- package/types/EXR3DLoader.d.ts +7 -0
- package/types/TypedArrayLoader.d.ts +2 -1
- package/types/index.d.ts +1 -0
- package/types/typedArray.d.ts +9 -3
- package/types/typedArrayParsers.d.ts +2 -0
package/src/index.ts
CHANGED
package/src/typedArray.ts
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
import {
|
2
|
+
Float16Array,
|
3
|
+
type Float16ArrayConstructor
|
4
|
+
} from '@petamoriken/float16'
|
1
5
|
import invariant from 'tiny-invariant'
|
2
6
|
|
3
7
|
export type TypedArray =
|
@@ -8,6 +12,7 @@ export type TypedArray =
|
|
8
12
|
| Uint16Array
|
9
13
|
| Int32Array
|
10
14
|
| Uint32Array
|
15
|
+
| Float16Array
|
11
16
|
| Float32Array
|
12
17
|
| Float64Array
|
13
18
|
|
@@ -19,9 +24,11 @@ export type TypedArrayConstructor =
|
|
19
24
|
| Uint16ArrayConstructor
|
20
25
|
| Int32ArrayConstructor
|
21
26
|
| Uint32ArrayConstructor
|
27
|
+
| Float16ArrayConstructor
|
22
28
|
| Float32ArrayConstructor
|
23
29
|
| Float64ArrayConstructor
|
24
30
|
|
31
|
+
/** @deprecated */
|
25
32
|
export type TypedArrayElementType =
|
26
33
|
| 'int8'
|
27
34
|
| 'uint8'
|
@@ -29,9 +36,11 @@ export type TypedArrayElementType =
|
|
29
36
|
| 'uint16'
|
30
37
|
| 'int32'
|
31
38
|
| 'uint32'
|
39
|
+
| 'float16'
|
32
40
|
| 'float32'
|
33
41
|
| 'float64'
|
34
42
|
|
43
|
+
/** @deprecated Use getTypedArrayTextureDataType instead */
|
35
44
|
export function getTypedArrayElementType(
|
36
45
|
array: TypedArray
|
37
46
|
): TypedArrayElementType {
|
@@ -44,6 +53,7 @@ export function getTypedArrayElementType(
|
|
44
53
|
array instanceof Uint16Array ? 'uint16' :
|
45
54
|
array instanceof Int32Array ? 'int32' :
|
46
55
|
array instanceof Uint32Array ? 'uint32' :
|
56
|
+
array instanceof Float16Array ? 'float16' :
|
47
57
|
array instanceof Float32Array ? 'float32' :
|
48
58
|
array instanceof Float64Array ? 'float64' :
|
49
59
|
null
|
@@ -51,3 +61,20 @@ export function getTypedArrayElementType(
|
|
51
61
|
invariant(type != null)
|
52
62
|
return type
|
53
63
|
}
|
64
|
+
|
65
|
+
export function isTypedArray(value: unknown): value is TypedArray {
|
66
|
+
return (
|
67
|
+
value instanceof Int8Array ||
|
68
|
+
value instanceof Uint8Array ||
|
69
|
+
value instanceof Uint8ClampedArray ||
|
70
|
+
value instanceof Int16Array ||
|
71
|
+
value instanceof Uint16Array ||
|
72
|
+
value instanceof Int32Array ||
|
73
|
+
value instanceof Uint32Array ||
|
74
|
+
value instanceof Float16Array ||
|
75
|
+
value instanceof Float32Array ||
|
76
|
+
value instanceof Float64Array
|
77
|
+
)
|
78
|
+
}
|
79
|
+
|
80
|
+
export { Float16Array }
|
package/src/typedArrayParsers.ts
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
import { Float16Array, getFloat16 } from '@petamoriken/float16'
|
2
|
+
|
1
3
|
import { type TypedArray, type TypedArrayConstructor } from './typedArray'
|
2
4
|
|
3
5
|
let hostLittleEndian: boolean | undefined
|
@@ -12,11 +14,13 @@ function isHostLittleEndian(): boolean {
|
|
12
14
|
return hostLittleEndian
|
13
15
|
}
|
14
16
|
|
15
|
-
type GetValue =
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
type GetValue =
|
18
|
+
| keyof {
|
19
|
+
[K in keyof DataView as DataView[K] extends (byteOffset: number) => number
|
20
|
+
? K
|
21
|
+
: never]: DataView[K]
|
22
|
+
}
|
23
|
+
| 'getFloat16'
|
20
24
|
|
21
25
|
function parseTypedArray<T extends TypedArrayConstructor, K extends GetValue>(
|
22
26
|
buffer: ArrayBuffer,
|
@@ -32,9 +36,15 @@ function parseTypedArray<K extends GetValue>(
|
|
32
36
|
littleEndian = true
|
33
37
|
): TypedArray {
|
34
38
|
if (littleEndian === isHostLittleEndian()) {
|
39
|
+
// eslint-disable-next-line
|
40
|
+
// @ts-ignore False positive type error in Node.js
|
35
41
|
return new TypedArray(buffer)
|
36
42
|
}
|
37
|
-
const data = new DataView(buffer)
|
43
|
+
const data = Object.assign(new DataView(buffer), {
|
44
|
+
getFloat16(this: DataView, byteOffset: number, littleEndian?: boolean) {
|
45
|
+
return getFloat16(this, byteOffset, littleEndian)
|
46
|
+
}
|
47
|
+
})
|
38
48
|
const array = new TypedArray(data.byteLength / TypedArray.BYTES_PER_ELEMENT)
|
39
49
|
for (
|
40
50
|
let index = 0, byteIndex = 0;
|
@@ -77,6 +87,11 @@ export const parseUint32Array: TypedArrayParser<Uint32Array> = (
|
|
77
87
|
littleEndian
|
78
88
|
) => parseTypedArray(buffer, Uint32Array, 'getUint32', littleEndian)
|
79
89
|
|
90
|
+
export const parseFloat16Array: TypedArrayParser<Float16Array> = (
|
91
|
+
buffer,
|
92
|
+
littleEndian
|
93
|
+
) => parseTypedArray(buffer, Float16Array, 'getFloat16', littleEndian)
|
94
|
+
|
80
95
|
export const parseFloat32Array: TypedArrayParser<Float32Array> = (
|
81
96
|
buffer,
|
82
97
|
littleEndian
|
package/types/DataLoader.d.ts
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
import { Callable } from './types';
|
2
2
|
import { TypedArrayParser } from './typedArrayParsers';
|
3
3
|
import { TypedArrayLoader } from './TypedArrayLoader';
|
4
|
+
import { TypedArray } from './typedArray';
|
4
5
|
import { Class, WritableKeysOf } from 'type-fest';
|
5
|
-
import { Data3DTexture, DataTexture, Loader
|
6
|
+
import { Data3DTexture, DataTexture, Loader } from 'three';
|
6
7
|
|
7
8
|
type ParameterProperties<T> = {
|
8
9
|
[K in WritableKeysOf<T> as T[K] extends Callable ? never : K]: T[K];
|
@@ -26,12 +27,4 @@ export declare function createData3DTextureLoaderClass<T extends TypedArray>(par
|
|
26
27
|
export declare function createDataTextureLoaderClass<T extends TypedArray>(parser: TypedArrayParser<T>, parameters?: DataTextureParameters): Class<DataLoader<DataTexture, T>>;
|
27
28
|
export declare function createData3DTextureLoader<T extends TypedArray>(parser: TypedArrayParser<T>, parameters?: Data3DTextureParameters): DataLoader<Data3DTexture, T>;
|
28
29
|
export declare function createDataTextureLoader<T extends TypedArray>(parser: TypedArrayParser<T>, parameters?: DataTextureParameters): DataLoader<DataTexture, T>;
|
29
|
-
/** @deprecated Use createDataTextureLoaderClass instead. */
|
30
|
-
export declare const Int16Data2DLoader: Class<DataLoader<DataTexture, Int16Array<ArrayBufferLike>>>;
|
31
|
-
/** @deprecated Use createDataTextureLoaderClass instead. */
|
32
|
-
export declare const Uint16Data2DLoader: Class<DataLoader<DataTexture, Uint16Array<ArrayBufferLike>>>;
|
33
|
-
/** @deprecated Use createDataTextureLoaderClass instead. */
|
34
|
-
export declare const Float32Data2DLoader: Class<DataLoader<DataTexture, Float32Array<ArrayBufferLike>>>;
|
35
|
-
/** @deprecated Use createData3DTextureLoaderClass instead. */
|
36
|
-
export declare const Float32Data3DLoader: Class<DataLoader<Data3DTexture, Float32Array<ArrayBufferLike>>>;
|
37
30
|
export {};
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { Data3DTexture, Loader } from 'three';
|
2
|
+
|
3
|
+
export declare class EXR3DLoader extends Loader<Data3DTexture> {
|
4
|
+
depth?: number;
|
5
|
+
setDepth(value: number): this;
|
6
|
+
load(url: string, onLoad: (data: Data3DTexture) => void, onProgress?: (event: ProgressEvent) => void, onError?: (error: unknown) => void): void;
|
7
|
+
}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { TypedArrayParser } from './typedArrayParsers';
|
2
|
+
import { TypedArray } from './typedArray';
|
2
3
|
import { Class } from 'type-fest';
|
3
|
-
import { Loader
|
4
|
+
import { Loader } from 'three';
|
4
5
|
|
5
6
|
export declare abstract class TypedArrayLoader<T extends TypedArray> extends Loader<T> {
|
6
7
|
abstract parseTypedArray(buffer: ArrayBuffer): T;
|
package/types/index.d.ts
CHANGED
package/types/typedArray.d.ts
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
export type
|
1
|
+
import { Float16Array, Float16ArrayConstructor } from '@petamoriken/float16';
|
2
|
+
|
3
|
+
export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float16Array | Float32Array | Float64Array;
|
4
|
+
export type TypedArrayConstructor = Int8ArrayConstructor | Uint8ArrayConstructor | Uint8ClampedArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float16ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor;
|
5
|
+
/** @deprecated */
|
6
|
+
export type TypedArrayElementType = 'int8' | 'uint8' | 'int16' | 'uint16' | 'int32' | 'uint32' | 'float16' | 'float32' | 'float64';
|
7
|
+
/** @deprecated Use getTypedArrayTextureDataType instead */
|
4
8
|
export declare function getTypedArrayElementType(array: TypedArray): TypedArrayElementType;
|
9
|
+
export declare function isTypedArray(value: unknown): value is TypedArray;
|
10
|
+
export { Float16Array };
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { TypedArray } from './typedArray';
|
2
|
+
import { Float16Array } from '@petamoriken/float16';
|
2
3
|
|
3
4
|
export type TypedArrayParser<T extends TypedArray> = (buffer: ArrayBuffer, littleEndian?: boolean) => T;
|
4
5
|
export declare const parseUint8Array: TypedArrayParser<Uint8Array>;
|
@@ -7,5 +8,6 @@ export declare const parseUint16Array: TypedArrayParser<Uint16Array>;
|
|
7
8
|
export declare const parseInt16Array: TypedArrayParser<Int16Array>;
|
8
9
|
export declare const parseInt32Array: TypedArrayParser<Int32Array>;
|
9
10
|
export declare const parseUint32Array: TypedArrayParser<Uint32Array>;
|
11
|
+
export declare const parseFloat16Array: TypedArrayParser<Float16Array>;
|
10
12
|
export declare const parseFloat32Array: TypedArrayParser<Float32Array>;
|
11
13
|
export declare const parseFloat64Array: TypedArrayParser<Float64Array>;
|