@takram/three-geospatial 0.0.1-alpha.4 → 0.0.1-alpha.5
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/build/index.cjs +4 -4
- package/build/index.cjs.map +1 -1
- package/build/index.js +555 -569
- package/build/index.js.map +1 -1
- package/package.json +2 -2
- package/src/DataLoader.ts +106 -49
- package/src/TypedArrayLoader.ts +25 -9
- package/src/index.ts +1 -0
- package/src/math.ts +1 -0
- package/src/typedArray.ts +29 -52
- package/src/typedArrayParsers.ts +77 -0
- package/types/DataLoader.d.ts +30 -60
- package/types/TypedArrayLoader.d.ts +10 -10
- package/types/index.d.ts +1 -0
- package/types/math.d.ts +1 -0
- package/types/typedArray.d.ts +2 -8
- package/types/typedArrayParsers.d.ts +11 -0
@@ -0,0 +1,77 @@
|
|
1
|
+
import { type TypedArray, type TypedArrayConstructor } from './typedArray'
|
2
|
+
|
3
|
+
type GetValue = keyof {
|
4
|
+
[K in keyof DataView as DataView[K] extends (byteOffset: number) => number
|
5
|
+
? K
|
6
|
+
: never]: DataView[K]
|
7
|
+
}
|
8
|
+
|
9
|
+
function parseTypedArray<T extends TypedArrayConstructor, K extends GetValue>(
|
10
|
+
buffer: ArrayBuffer,
|
11
|
+
TypedArray: T,
|
12
|
+
getValue: K,
|
13
|
+
littleEndian?: boolean
|
14
|
+
): InstanceType<T>
|
15
|
+
|
16
|
+
function parseTypedArray<K extends GetValue>(
|
17
|
+
buffer: ArrayBuffer,
|
18
|
+
TypedArray: TypedArrayConstructor,
|
19
|
+
getValue: K,
|
20
|
+
littleEndian = true
|
21
|
+
): TypedArray {
|
22
|
+
const data = new DataView(buffer)
|
23
|
+
const array = new TypedArray(data.byteLength / TypedArray.BYTES_PER_ELEMENT)
|
24
|
+
for (
|
25
|
+
let index = 0, byteIndex = 0;
|
26
|
+
index < array.length;
|
27
|
+
++index, byteIndex += TypedArray.BYTES_PER_ELEMENT
|
28
|
+
) {
|
29
|
+
array[index] = data[getValue](byteIndex, littleEndian)
|
30
|
+
}
|
31
|
+
return array
|
32
|
+
}
|
33
|
+
|
34
|
+
export type TypedArrayParser<T extends TypedArray> = (
|
35
|
+
buffer: ArrayBuffer,
|
36
|
+
littleEndian?: boolean
|
37
|
+
) => T
|
38
|
+
|
39
|
+
export const parseUint8Array: TypedArrayParser<Uint8Array> = (
|
40
|
+
buffer,
|
41
|
+
littleEndian
|
42
|
+
) => parseTypedArray(buffer, Uint8Array, 'getUint8', littleEndian)
|
43
|
+
|
44
|
+
export const parseInt8Array: TypedArrayParser<Int8Array> = (
|
45
|
+
buffer,
|
46
|
+
littleEndian
|
47
|
+
) => parseTypedArray(buffer, Int8Array, 'getInt8', littleEndian)
|
48
|
+
|
49
|
+
export const parseUint16Array: TypedArrayParser<Uint16Array> = (
|
50
|
+
buffer,
|
51
|
+
littleEndian
|
52
|
+
) => parseTypedArray(buffer, Uint16Array, 'getUint16', littleEndian)
|
53
|
+
|
54
|
+
export const parseInt16Array: TypedArrayParser<Int16Array> = (
|
55
|
+
buffer,
|
56
|
+
littleEndian
|
57
|
+
) => parseTypedArray(buffer, Int16Array, 'getInt16', littleEndian)
|
58
|
+
|
59
|
+
export const parseInt32Array: TypedArrayParser<Int32Array> = (
|
60
|
+
buffer,
|
61
|
+
littleEndian
|
62
|
+
) => parseTypedArray(buffer, Int32Array, 'getInt32', littleEndian)
|
63
|
+
|
64
|
+
export const parseUint32Array: TypedArrayParser<Uint32Array> = (
|
65
|
+
buffer,
|
66
|
+
littleEndian
|
67
|
+
) => parseTypedArray(buffer, Uint32Array, 'getUint32', littleEndian)
|
68
|
+
|
69
|
+
export const parseFloat32Array: TypedArrayParser<Float32Array> = (
|
70
|
+
buffer,
|
71
|
+
littleEndian
|
72
|
+
) => parseTypedArray(buffer, Float32Array, 'getFloat32', littleEndian)
|
73
|
+
|
74
|
+
export const parseFloat64Array: TypedArrayParser<Float64Array> = (
|
75
|
+
buffer,
|
76
|
+
littleEndian
|
77
|
+
) => parseTypedArray(buffer, Float64Array, 'getFloat64', littleEndian)
|
package/types/DataLoader.d.ts
CHANGED
@@ -1,67 +1,37 @@
|
|
1
1
|
import { Callable } from './types';
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import {
|
2
|
+
import { TypedArrayParser } from './typedArrayParsers';
|
3
|
+
import { TypedArrayLoader } from './TypedArrayLoader';
|
4
|
+
import { Class, WritableKeysOf } from 'type-fest';
|
5
|
+
import { Data3DTexture, DataTexture, Loader, TypedArray } from 'three';
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
type ParameterProperties<T> = {
|
8
|
+
[K in WritableKeysOf<T> as T[K] extends Callable ? never : K]: T[K];
|
9
|
+
};
|
10
|
+
export type DataTextureParameters = Omit<Partial<ParameterProperties<DataTexture>>, 'image'> & {
|
11
|
+
width?: number;
|
12
|
+
height?: number;
|
13
|
+
};
|
14
|
+
export type Data3DTextureParameters = Omit<Partial<ParameterProperties<Data3DTexture>>, 'image'> & {
|
15
|
+
width?: number;
|
16
|
+
height?: number;
|
9
17
|
depth?: number;
|
10
|
-
}
|
11
|
-
export
|
12
|
-
[K in keyof Texture as Texture[K] extends Callable ? never : K]: Texture[K];
|
13
|
-
}>, 'image'>;
|
14
|
-
export declare abstract class DataLoader<T extends DataTexture | Data3DTexture, U extends TypedArray> extends Loader<T> {
|
18
|
+
};
|
19
|
+
export declare abstract class DataLoader<T extends DataTexture | Data3DTexture = DataTexture | Data3DTexture, U extends TypedArray = TypedArray> extends Loader<T> {
|
15
20
|
abstract readonly Texture: Class<T>;
|
16
21
|
abstract readonly TypedArrayLoader: Class<TypedArrayLoader<U>>;
|
17
|
-
readonly parameters
|
22
|
+
readonly parameters: DataTextureParameters & Data3DTextureParameters;
|
18
23
|
load(url: string, onLoad: (data: T) => void, onProgress?: (event: ProgressEvent) => void, onError?: (error: unknown) => void): void;
|
19
24
|
}
|
20
|
-
export declare
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
export
|
33
|
-
readonly Texture: typeof DataTexture;
|
34
|
-
readonly TypedArrayLoader: typeof Uint16ArrayLoader;
|
35
|
-
readonly parameters: {
|
36
|
-
type: 1015;
|
37
|
-
format: 1023;
|
38
|
-
wrapS: 1001;
|
39
|
-
wrapT: 1001;
|
40
|
-
minFilter: 1006;
|
41
|
-
magFilter: 1006;
|
42
|
-
};
|
43
|
-
}
|
44
|
-
export declare class Float32Data2DLoader extends DataLoader<DataTexture, Float32Array> {
|
45
|
-
readonly Texture: typeof DataTexture;
|
46
|
-
readonly TypedArrayLoader: typeof Float32ArrayLoader;
|
47
|
-
readonly parameters: {
|
48
|
-
type: 1015;
|
49
|
-
format: 1023;
|
50
|
-
wrapS: 1001;
|
51
|
-
wrapT: 1001;
|
52
|
-
minFilter: 1006;
|
53
|
-
magFilter: 1006;
|
54
|
-
};
|
55
|
-
}
|
56
|
-
export declare class Float32Data3DLoader extends DataLoader<Data3DTexture, Float32Array> {
|
57
|
-
readonly Texture: typeof Data3DTexture;
|
58
|
-
readonly TypedArrayLoader: typeof Float32ArrayLoader;
|
59
|
-
readonly parameters: {
|
60
|
-
type: 1015;
|
61
|
-
format: 1023;
|
62
|
-
wrapS: 1001;
|
63
|
-
wrapT: 1001;
|
64
|
-
minFilter: 1006;
|
65
|
-
magFilter: 1006;
|
66
|
-
};
|
67
|
-
}
|
25
|
+
export declare function createData3DTextureLoaderClass<T extends TypedArray>(parser: TypedArrayParser<T>, parameters?: Data3DTextureParameters): Class<DataLoader<Data3DTexture, T>>;
|
26
|
+
export declare function createDataTextureLoaderClass<T extends TypedArray>(parser: TypedArrayParser<T>, parameters?: DataTextureParameters): Class<DataLoader<DataTexture, T>>;
|
27
|
+
export declare function createData3DTextureLoader<T extends TypedArray>(parser: TypedArrayParser<T>, parameters?: Data3DTextureParameters): DataLoader<Data3DTexture, T>;
|
28
|
+
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>>;
|
31
|
+
/** @deprecated Use createDataTextureLoaderClass instead. */
|
32
|
+
export declare const Uint16Data2DLoader: Class<DataLoader<DataTexture, Uint16Array>>;
|
33
|
+
/** @deprecated Use createDataTextureLoaderClass instead. */
|
34
|
+
export declare const Float32Data2DLoader: Class<DataLoader<DataTexture, Float32Array>>;
|
35
|
+
/** @deprecated Use createData3DTextureLoaderClass instead. */
|
36
|
+
export declare const Float32Data3DLoader: Class<DataLoader<Data3DTexture, Float32Array>>;
|
37
|
+
export {};
|
@@ -1,16 +1,16 @@
|
|
1
|
-
import {
|
1
|
+
import { TypedArrayParser } from './typedArrayParsers';
|
2
|
+
import { Class } from 'type-fest';
|
2
3
|
import { Loader, TypedArray } from 'three';
|
3
4
|
|
4
5
|
export declare abstract class TypedArrayLoader<T extends TypedArray> extends Loader<T> {
|
5
6
|
abstract parseTypedArray(buffer: ArrayBuffer): T;
|
6
7
|
load(url: string, onLoad: (data: T) => void, onProgress?: (event: ProgressEvent) => void, onError?: (error: unknown) => void): void;
|
7
8
|
}
|
8
|
-
export declare
|
9
|
-
|
10
|
-
|
11
|
-
export declare
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
}
|
9
|
+
export declare function createTypedArrayLoaderClass<T extends TypedArray>(parser: TypedArrayParser<T>): Class<TypedArrayLoader<T>>;
|
10
|
+
export declare function createTypedArrayLoader<T extends TypedArray>(parser: TypedArrayParser<T>): TypedArrayLoader<T>;
|
11
|
+
/** @deprecated Use createTypedArrayLoaderClass instead. */
|
12
|
+
export declare const Int16ArrayLoader: Class<TypedArrayLoader<Int16Array>>;
|
13
|
+
/** @deprecated Use createTypedArrayLoaderClass instead. */
|
14
|
+
export declare const Uint16ArrayLoader: Class<TypedArrayLoader<Uint16Array>>;
|
15
|
+
/** @deprecated Use createTypedArrayLoaderClass instead. */
|
16
|
+
export declare const Float32ArrayLoader: Class<TypedArrayLoader<Float32Array>>;
|
package/types/index.d.ts
CHANGED
package/types/math.d.ts
CHANGED
@@ -8,6 +8,7 @@ export declare const isPowerOfTwo: typeof import('three/src/math/MathUtils.js').
|
|
8
8
|
export declare const ceilPowerOfTwo: typeof import('three/src/math/MathUtils.js').ceilPowerOfTwo;
|
9
9
|
export declare const floorPowerOfTwo: typeof import('three/src/math/MathUtils.js').floorPowerOfTwo;
|
10
10
|
export declare const normalize: typeof import('three/src/math/MathUtils.js').normalize;
|
11
|
+
export declare const remap: typeof import('three/src/math/MathUtils.js').mapLinear;
|
11
12
|
export declare function smoothstep(min: number, max: number, x: number): number;
|
12
13
|
export declare function saturate(x: number): number;
|
13
14
|
export declare function closeTo(a: number, b: number, relativeEpsilon: number, absoluteEpsilon?: number): boolean;
|
package/types/typedArray.d.ts
CHANGED
@@ -1,10 +1,4 @@
|
|
1
1
|
export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
|
2
2
|
export type TypedArrayConstructor = Int8ArrayConstructor | Uint8ArrayConstructor | Uint8ClampedArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor;
|
3
|
-
type
|
4
|
-
|
5
|
-
};
|
6
|
-
export declare function parseTypedArray<T extends TypedArrayConstructor, K extends GetValue>(buffer: ArrayBuffer, TypedArray: T, getValue: K, littleEndian?: boolean): InstanceType<T>;
|
7
|
-
export declare function parseInt16Array(buffer: ArrayBuffer, littleEndian?: boolean): Int16Array;
|
8
|
-
export declare function parseUint16Array(buffer: ArrayBuffer, littleEndian?: boolean): Uint16Array;
|
9
|
-
export declare function parseFloat32Array(buffer: ArrayBuffer, littleEndian?: boolean): Float32Array;
|
10
|
-
export {};
|
3
|
+
export type TypedArrayElementType = 'int8' | 'uint8' | 'int16' | 'uint16' | 'int32' | 'uint32' | 'float32' | 'float64';
|
4
|
+
export declare function getTypedArrayElementType(array: TypedArray): TypedArrayElementType;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { TypedArray } from './typedArray';
|
2
|
+
|
3
|
+
export type TypedArrayParser<T extends TypedArray> = (buffer: ArrayBuffer, littleEndian?: boolean) => T;
|
4
|
+
export declare const parseUint8Array: TypedArrayParser<Uint8Array>;
|
5
|
+
export declare const parseInt8Array: TypedArrayParser<Int8Array>;
|
6
|
+
export declare const parseUint16Array: TypedArrayParser<Uint16Array>;
|
7
|
+
export declare const parseInt16Array: TypedArrayParser<Int16Array>;
|
8
|
+
export declare const parseInt32Array: TypedArrayParser<Int32Array>;
|
9
|
+
export declare const parseUint32Array: TypedArrayParser<Uint32Array>;
|
10
|
+
export declare const parseFloat32Array: TypedArrayParser<Float32Array>;
|
11
|
+
export declare const parseFloat64Array: TypedArrayParser<Float64Array>;
|