@takram/three-geospatial 0.0.1-alpha.5 → 0.0.1-alpha.7

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.
Files changed (47) hide show
  1. package/build/index.cjs +1 -43
  2. package/build/index.cjs.map +1 -1
  3. package/build/index.js +403 -787
  4. package/build/index.js.map +1 -1
  5. package/build/r3f.js +2 -2
  6. package/build/shaders.cjs +397 -0
  7. package/build/shaders.cjs.map +1 -0
  8. package/build/shaders.js +408 -0
  9. package/build/shaders.js.map +1 -0
  10. package/package.json +7 -3
  11. package/src/DataLoader.ts +1 -0
  12. package/src/STBNLoader.ts +21 -0
  13. package/src/Texture3DLoader.ts +81 -0
  14. package/src/bufferGeometry.ts +2 -2
  15. package/src/constants.ts +6 -0
  16. package/src/defineShorthand.ts +68 -0
  17. package/src/index.ts +5 -10
  18. package/src/math.ts +36 -1
  19. package/src/r3f/index.ts +1 -0
  20. package/src/r3f/types.ts +63 -0
  21. package/src/resolveIncludes.test.ts +21 -0
  22. package/src/resolveIncludes.ts +22 -0
  23. package/src/shaders/cascadedShadowMaps.glsl +79 -0
  24. package/src/shaders/depth.glsl +3 -1
  25. package/src/shaders/generators.glsl +9 -0
  26. package/src/shaders/index.ts +19 -0
  27. package/src/shaders/math.glsl +92 -0
  28. package/src/shaders/poissonDisk.glsl +23 -0
  29. package/src/shaders/raySphereIntersection.glsl +134 -0
  30. package/src/shaders/turbo.glsl +9 -0
  31. package/src/typedArrayParsers.ts +19 -8
  32. package/src/types.ts +5 -51
  33. package/src/unrollLoops.ts +23 -0
  34. package/types/DataLoader.d.ts +4 -4
  35. package/types/STBNLoader.d.ts +1 -0
  36. package/types/Texture3DLoader.d.ts +5 -0
  37. package/types/TypedArrayLoader.d.ts +3 -3
  38. package/types/constants.d.ts +4 -0
  39. package/types/defineShorthand.d.ts +16 -0
  40. package/types/index.d.ts +5 -3
  41. package/types/math.d.ts +4 -1
  42. package/types/r3f/index.d.ts +1 -0
  43. package/types/r3f/types.d.ts +21 -0
  44. package/types/resolveIncludes.d.ts +5 -0
  45. package/types/shaders/index.d.ts +9 -0
  46. package/types/types.d.ts +5 -20
  47. package/types/unrollLoops.d.ts +1 -0
@@ -27,11 +27,11 @@ export declare function createDataTextureLoaderClass<T extends TypedArray>(parse
27
27
  export declare function createData3DTextureLoader<T extends TypedArray>(parser: TypedArrayParser<T>, parameters?: Data3DTextureParameters): DataLoader<Data3DTexture, T>;
28
28
  export declare function createDataTextureLoader<T extends TypedArray>(parser: TypedArrayParser<T>, parameters?: DataTextureParameters): DataLoader<DataTexture, T>;
29
29
  /** @deprecated Use createDataTextureLoaderClass instead. */
30
- export declare const Int16Data2DLoader: Class<DataLoader<DataTexture, Int16Array>>;
30
+ export declare const Int16Data2DLoader: Class<DataLoader<DataTexture, Int16Array<ArrayBufferLike>>>;
31
31
  /** @deprecated Use createDataTextureLoaderClass instead. */
32
- export declare const Uint16Data2DLoader: Class<DataLoader<DataTexture, Uint16Array>>;
32
+ export declare const Uint16Data2DLoader: Class<DataLoader<DataTexture, Uint16Array<ArrayBufferLike>>>;
33
33
  /** @deprecated Use createDataTextureLoaderClass instead. */
34
- export declare const Float32Data2DLoader: Class<DataLoader<DataTexture, Float32Array>>;
34
+ export declare const Float32Data2DLoader: Class<DataLoader<DataTexture, Float32Array<ArrayBufferLike>>>;
35
35
  /** @deprecated Use createData3DTextureLoaderClass instead. */
36
- export declare const Float32Data3DLoader: Class<DataLoader<Data3DTexture, Float32Array>>;
36
+ export declare const Float32Data3DLoader: Class<DataLoader<Data3DTexture, Float32Array<ArrayBufferLike>>>;
37
37
  export {};
@@ -0,0 +1 @@
1
+ export declare const STBNLoader: import('type-fest').Class<import('./DataLoader').DataLoader<import('three').Data3DTexture, Uint8Array<ArrayBufferLike>>>;
@@ -0,0 +1,5 @@
1
+ import { Data3DTexture, Loader } from 'three';
2
+
3
+ export declare class Texture3DLoader extends Loader<Data3DTexture> {
4
+ load(url: string, onLoad: (data: Data3DTexture) => void, onProgress?: (event: ProgressEvent) => void, onError?: (error: unknown) => void): void;
5
+ }
@@ -9,8 +9,8 @@ export declare abstract class TypedArrayLoader<T extends TypedArray> extends Loa
9
9
  export declare function createTypedArrayLoaderClass<T extends TypedArray>(parser: TypedArrayParser<T>): Class<TypedArrayLoader<T>>;
10
10
  export declare function createTypedArrayLoader<T extends TypedArray>(parser: TypedArrayParser<T>): TypedArrayLoader<T>;
11
11
  /** @deprecated Use createTypedArrayLoaderClass instead. */
12
- export declare const Int16ArrayLoader: Class<TypedArrayLoader<Int16Array>>;
12
+ export declare const Int16ArrayLoader: Class<TypedArrayLoader<Int16Array<ArrayBufferLike>>>;
13
13
  /** @deprecated Use createTypedArrayLoaderClass instead. */
14
- export declare const Uint16ArrayLoader: Class<TypedArrayLoader<Uint16Array>>;
14
+ export declare const Uint16ArrayLoader: Class<TypedArrayLoader<Uint16Array<ArrayBufferLike>>>;
15
15
  /** @deprecated Use createTypedArrayLoaderClass instead. */
16
- export declare const Float32ArrayLoader: Class<TypedArrayLoader<Float32Array>>;
16
+ export declare const Float32ArrayLoader: Class<TypedArrayLoader<Float32Array<ArrayBufferLike>>>;
@@ -0,0 +1,4 @@
1
+ export declare const STBN_TEXTURE_WIDTH = 128;
2
+ export declare const STBN_TEXTURE_HEIGHT = 128;
3
+ export declare const STBN_TEXTURE_DEPTH = 64;
4
+ export declare const DEFAULT_STBN_URL = "https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/9627216cc50057994c98a2118f3c4a23765d43b9/packages/core/assets/stbn.bin";
@@ -0,0 +1,16 @@
1
+ import { Uniform } from 'three';
2
+
3
+ export type PropertyShorthand<Args extends readonly unknown[]> = Args extends readonly [infer T, infer K, ...infer Rest] ? K extends readonly string[] ? K[number] extends keyof T ? Rest extends readonly unknown[] ? {
4
+ [P in K[number]]: T[P];
5
+ } & PropertyShorthand<Rest> : {
6
+ [P in K[number]]: T[P];
7
+ } : never : never : {};
8
+ export declare function definePropertyShorthand<T, Args extends readonly unknown[]>(destination: T, ...sourceKeysArgs: [...Args]): T & PropertyShorthand<Args>;
9
+ export type UniformShorthand<T extends {
10
+ uniforms: Record<K, Uniform>;
11
+ }, K extends keyof T['uniforms']> = {
12
+ [P in K]: T['uniforms'][P] extends Uniform<infer U> ? U : never;
13
+ };
14
+ export declare function defineUniformShorthand<T, S extends {
15
+ uniforms: Record<K, Uniform>;
16
+ }, K extends keyof S['uniforms']>(destination: T, source: S, keys: readonly K[]): T & UniformShorthand<S, K>;
package/types/index.d.ts CHANGED
@@ -1,19 +1,21 @@
1
- export declare const depthShader: string;
2
- export declare const packingShader: string;
3
- export declare const transformShader: string;
4
1
  export * from './ArrayBufferLoader';
5
2
  export * from './assertions';
6
3
  export * from './bufferGeometry';
4
+ export * from './constants';
7
5
  export * from './DataLoader';
6
+ export * from './defineShorthand';
8
7
  export * from './Ellipsoid';
9
8
  export * from './EllipsoidGeometry';
10
9
  export * from './Geodetic';
11
10
  export * from './math';
12
11
  export * from './PointOfView';
13
12
  export * from './Rectangle';
13
+ export * from './resolveIncludes';
14
+ export * from './STBNLoader';
14
15
  export * from './TileCoordinate';
15
16
  export * from './TilingScheme';
16
17
  export * from './typedArray';
17
18
  export * from './TypedArrayLoader';
18
19
  export * from './typedArrayParsers';
19
20
  export * from './types';
21
+ export * from './unrollLoops';
package/types/math.d.ts CHANGED
@@ -8,7 +8,10 @@ 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
+ export declare function remap(x: number, min1: number, max1: number): number;
12
+ export declare function remap(x: number, min1: number, max1: number, min2: number, max2: number): number;
13
+ export declare function remapClamped(x: number, min1: number, max1: number): number;
14
+ export declare function remapClamped(x: number, min1: number, max1: number, min2: number, max2: number): number;
12
15
  export declare function smoothstep(min: number, max: number, x: number): number;
13
16
  export declare function saturate(x: number): number;
14
17
  export declare function closeTo(a: number, b: number, relativeEpsilon: number, absoluteEpsilon?: number): boolean;
@@ -1,2 +1,3 @@
1
1
  export * from './EastNorthUpFrame';
2
2
  export * from './EllipsoidMesh';
3
+ export * from './types';
@@ -0,0 +1,21 @@
1
+ import { Callable } from '../types';
2
+ import { WritableKeysOf } from 'type-fest';
3
+ import { Color as ColorImpl, Vector2 as Vector2Impl, Vector3 as Vector3Impl, Vector4 as Vector4Impl } from 'three';
4
+ import { NodeProps, Overwrite, Color as R3FColor, Vector2 as R3FVector2, Vector3 as R3FVector3, Vector4 as R3FVector4 } from '@react-three/fiber';
5
+
6
+ export type ExtendedProps<T> = {
7
+ [K in keyof T]: Vector2Impl extends T[K] ? R3FVector2 | T[K] : Vector3Impl extends T[K] ? R3FVector3 | T[K] : Vector4Impl extends T[K] ? R3FVector4 | T[K] : ColorImpl extends T[K] ? R3FColor | T[K] : T[K];
8
+ };
9
+ type NonFunctionKeys<T> = keyof {
10
+ [K in keyof T as Callable extends T[K] ? never : K]: any;
11
+ };
12
+ type WritableNonExtendableKeysOf<T> = WritableKeysOf<T> | keyof {
13
+ [K in keyof T as Vector2Impl extends T[K] ? K : Vector3Impl extends T[K] ? K : Vector4Impl extends T[K] ? K : ColorImpl extends T[K] ? K : never]: any;
14
+ };
15
+ export type PassThoughInstanceProps<RefType, Args extends readonly any[], Props> = Overwrite<ExtendedProps<{
16
+ [K in NonFunctionKeys<Props> as K extends WritableNonExtendableKeysOf<Props> ? K : never]: Props[K];
17
+ }>, NodeProps<RefType, Args>>;
18
+ export type ExpandNestedProps<T, Prop extends keyof T & string> = {
19
+ [K in keyof T[Prop] as K extends string ? `${Prop}-${K}` : never]: T[Prop][K];
20
+ };
21
+ export {};
@@ -0,0 +1,5 @@
1
+ interface Includes {
2
+ [key: string]: string | Includes;
3
+ }
4
+ export declare function resolveIncludes(source: string, includes: Includes): string;
5
+ export {};
@@ -0,0 +1,9 @@
1
+ export declare const cascadedShadowMaps: string;
2
+ export declare const depth: string;
3
+ export declare const generators: string;
4
+ export declare const math: string;
5
+ export declare const packing: string;
6
+ export declare const poissonDisk: string;
7
+ export declare const raySphereIntersection: string;
8
+ export declare const transform: string;
9
+ export declare const turbo: string;
package/types/types.d.ts CHANGED
@@ -1,22 +1,7 @@
1
- import { ReadonlyTuple } from 'type-fest';
2
- import { Matrix2, Matrix3, Matrix4, Vector2, Vector3, Vector4 } from 'three';
1
+ import { Uniform } from 'three';
3
2
 
4
3
  export type Callable = (...args: any) => any;
5
- export type ReadonlyTuple2<T = number> = ReadonlyTuple<T, 2>;
6
- export type ReadonlyTuple3<T = number> = ReadonlyTuple<T, 3>;
7
- export type ReadonlyTuple4<T = number> = ReadonlyTuple<T, 4>;
8
- type BuildTupleHelper<Element, Length extends number, Rest extends Element[]> = Rest['length'] extends Length ? [...Rest] : BuildTupleHelper<Element, Length, [Element, ...Rest]>;
9
- export type Tuple<T, Length extends number> = number extends Length ? readonly T[] : BuildTupleHelper<T, Length, []>;
10
- export type Tuple2<T = number> = BuildTupleHelper<T, 2, []>;
11
- export type Tuple3<T = number> = BuildTupleHelper<T, 3, []>;
12
- export type Tuple4<T = number> = BuildTupleHelper<T, 4, []>;
13
- type ReadonlyThreeInstance<T> = Readonly<{
14
- [K in keyof T as T[K] extends Callable ? ReturnType<T[K]> extends T ? K extends 'clone' ? K : never : K : K]: T[K];
15
- }>;
16
- export type ReadonlyVector2 = ReadonlyThreeInstance<Vector2>;
17
- export type ReadonlyVector3 = ReadonlyThreeInstance<Vector3>;
18
- export type ReadonlyVector4 = ReadonlyThreeInstance<Vector4>;
19
- export type ReadonlyMatrix2 = ReadonlyThreeInstance<Matrix2>;
20
- export type ReadonlyMatrix3 = ReadonlyThreeInstance<Matrix3>;
21
- export type ReadonlyMatrix4 = ReadonlyThreeInstance<Matrix4>;
22
- export {};
4
+ export type UniformMap<T> = Omit<Map<string, Uniform>, 'get'> & {
5
+ get: <K extends keyof T>(key: K) => T[K];
6
+ set: <K extends keyof T>(key: K, value: T[K]) => void;
7
+ };
@@ -0,0 +1 @@
1
+ export declare function unrollLoops(string: string): string;