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

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.
@@ -42,17 +42,19 @@ export class TilingScheme {
42
42
  result = new TileCoordinate()
43
43
  ): TileCoordinate {
44
44
  const size = this.getSize(z, vectorScratch)
45
- const width = this.rectangle.width / size.x
46
- const height = this.rectangle.height / size.y
45
+ const { rectangle } = this
46
+ const width = rectangle.width / size.x
47
+ const height = rectangle.height / size.y
48
+ const { west, south, east } = rectangle
47
49
  let longitude = geodetic.longitude
48
- if (this.rectangle.east < this.rectangle.west) {
50
+ if (east < west) {
49
51
  longitude += Math.PI * 2
50
52
  }
51
- let x = Math.floor((longitude - this.rectangle.west) / width)
53
+ let x = Math.floor((longitude - west) / width)
52
54
  if (x >= size.x) {
53
55
  x = size.x - 1
54
56
  }
55
- let y = Math.floor((geodetic.latitude - this.rectangle.south) / height)
57
+ let y = Math.floor((geodetic.latitude - south) / height)
56
58
  if (y >= size.y) {
57
59
  y = size.y - 1
58
60
  }
@@ -65,12 +67,14 @@ export class TilingScheme {
65
67
  // Reference: https://github.com/CesiumGS/cesium/blob/1.122/packages/engine/Source/Core/GeographicTilingScheme.js#L169
66
68
  getRectangle(tile: TileCoordinateLike, result = new Rectangle()): Rectangle {
67
69
  const size = this.getSize(tile.z, vectorScratch)
68
- const width = this.rectangle.width / size.x
69
- const height = this.rectangle.height / size.y
70
- result.west = tile.x * width + this.rectangle.west
71
- result.east = (tile.x + 1) * width + this.rectangle.west
72
- result.north = this.rectangle.north - (size.y - tile.y - 1) * height
73
- result.south = this.rectangle.north - (size.y - tile.y) * height
70
+ const { rectangle } = this
71
+ const width = rectangle.width / size.x
72
+ const height = rectangle.height / size.y
73
+ const { west, north } = rectangle
74
+ result.west = tile.x * width + west
75
+ result.east = (tile.x + 1) * width + west
76
+ result.north = north - (size.y - tile.y - 1) * height
77
+ result.south = north - (size.y - tile.y) * height
74
78
  return result
75
79
  }
76
80
  }
@@ -1,7 +1,8 @@
1
- import { Loader, type TypedArray } from 'three'
1
+ import { Loader } from 'three'
2
2
  import { type Class } from 'type-fest'
3
3
 
4
4
  import { ArrayBufferLoader } from './ArrayBufferLoader'
5
+ import { type TypedArray } from './typedArray'
5
6
  import {
6
7
  parseFloat32Array,
7
8
  parseInt16Array,
@@ -1,9 +1,10 @@
1
1
  import { Box3, BufferAttribute, BufferGeometry, Sphere, Vector3 } from 'three'
2
2
 
3
- export type BufferGeometryLike = Pick<
4
- BufferGeometry,
5
- 'attributes' | 'index' | 'boundingBox' | 'boundingSphere'
6
- >
3
+ export interface BufferGeometryLike
4
+ extends Pick<
5
+ BufferGeometry,
6
+ 'attributes' | 'index' | 'boundingBox' | 'boundingSphere'
7
+ > {}
7
8
 
8
9
  export function toBufferGeometryLike(
9
10
  geometry: BufferGeometry
@@ -0,0 +1,207 @@
1
+ import { Material } from 'three'
2
+
3
+ import { clamp } from './math'
4
+
5
+ interface EffectLike {
6
+ defines: Map<string, string>
7
+ }
8
+
9
+ export function define(name: string) {
10
+ return <T extends Material | EffectLike, K extends keyof T>(
11
+ target: T[K] extends boolean ? T : never,
12
+ propertyKey: K
13
+ ) => {
14
+ if (target instanceof Material) {
15
+ Object.defineProperty(target, propertyKey, {
16
+ enumerable: true,
17
+ get(this: Extract<T, Material>): boolean {
18
+ return this.defines?.[name] != null
19
+ },
20
+ set(this: Extract<T, Material>, value: boolean) {
21
+ if (value !== this[propertyKey]) {
22
+ if (value) {
23
+ this.defines ??= {}
24
+ this.defines[name] = '1'
25
+ } else {
26
+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
27
+ delete this.defines?.[name]
28
+ }
29
+ this.needsUpdate = true
30
+ }
31
+ }
32
+ })
33
+ } else {
34
+ Object.defineProperty(target, propertyKey, {
35
+ enumerable: true,
36
+ get(this: Extract<T, EffectLike>): boolean {
37
+ return this.defines.has(name)
38
+ },
39
+ set(this: Extract<T, EffectLike>, value: boolean) {
40
+ if (value !== this[propertyKey]) {
41
+ if (value) {
42
+ this.defines.set(name, '1')
43
+ } else {
44
+ this.defines.delete(name)
45
+ }
46
+ ;(this as any).setChanged() // Bypass protected privilege
47
+ }
48
+ }
49
+ })
50
+ }
51
+ }
52
+ }
53
+
54
+ export interface DefineIntDecoratorOptions {
55
+ min?: number
56
+ max?: number
57
+ }
58
+
59
+ export function defineInt(
60
+ name: string,
61
+ {
62
+ min = Number.MIN_SAFE_INTEGER,
63
+ max = Number.MAX_SAFE_INTEGER
64
+ }: DefineIntDecoratorOptions = {}
65
+ ) {
66
+ return <T extends Material | EffectLike, K extends keyof T>(
67
+ target: T[K] extends number ? T : never,
68
+ propertyKey: K
69
+ ) => {
70
+ if (target instanceof Material) {
71
+ Object.defineProperty(target, propertyKey, {
72
+ enumerable: true,
73
+ get(this: Extract<T, Material>): number {
74
+ const value = this.defines?.[name]
75
+ return value != null ? parseInt(value) : 0
76
+ },
77
+ set(this: Extract<T, Material>, value: number) {
78
+ const prevValue = this[propertyKey]
79
+ if (value !== prevValue) {
80
+ this.defines ??= {}
81
+ this.defines[name] = clamp(value, min, max).toFixed(0)
82
+ this.needsUpdate = true
83
+ }
84
+ }
85
+ })
86
+ } else {
87
+ Object.defineProperty(target, propertyKey, {
88
+ enumerable: true,
89
+ get(this: Extract<T, EffectLike>): number {
90
+ const value = this.defines.get(name)
91
+ return value != null ? parseInt(value) : 0
92
+ },
93
+ set(this: Extract<T, EffectLike>, value: number) {
94
+ const prevValue = this[propertyKey]
95
+ if (value !== prevValue) {
96
+ this.defines.set(name, clamp(value, min, max).toFixed(0))
97
+ ;(this as any).setChanged() // Bypass protected privilege
98
+ }
99
+ }
100
+ })
101
+ }
102
+ }
103
+ }
104
+
105
+ export interface DefineFloatDecoratorOptions {
106
+ min?: number
107
+ max?: number
108
+ precision?: number
109
+ }
110
+
111
+ export function defineFloat(
112
+ name: string,
113
+ {
114
+ min = -Infinity,
115
+ max = Infinity,
116
+ precision = 7
117
+ }: DefineFloatDecoratorOptions = {}
118
+ ) {
119
+ return <T extends Material | EffectLike, K extends keyof T>(
120
+ target: T[K] extends number ? T : never,
121
+ propertyKey: K
122
+ ) => {
123
+ if (target instanceof Material) {
124
+ Object.defineProperty(target, propertyKey, {
125
+ enumerable: true,
126
+ get(this: Extract<T, Material>): number {
127
+ const value = this.defines?.[name]
128
+ return value != null ? parseFloat(value) : 0
129
+ },
130
+ set(this: Extract<T, Material>, value: number) {
131
+ const prevValue = this[propertyKey]
132
+ if (value !== prevValue) {
133
+ this.defines ??= {}
134
+ this.defines[name] = clamp(value, min, max).toFixed(precision)
135
+ this.needsUpdate = true
136
+ }
137
+ }
138
+ })
139
+ } else {
140
+ Object.defineProperty(target, propertyKey, {
141
+ enumerable: true,
142
+ get(this: Extract<T, EffectLike>): number {
143
+ const value = this.defines.get(name)
144
+ return value != null ? parseFloat(value) : 0
145
+ },
146
+ set(this: Extract<T, EffectLike>, value: number) {
147
+ const prevValue = this[propertyKey]
148
+ if (value !== prevValue) {
149
+ this.defines.set(name, clamp(value, min, max).toFixed(precision))
150
+ ;(this as any).setChanged() // Bypass protected privilege
151
+ }
152
+ }
153
+ })
154
+ }
155
+ }
156
+ }
157
+
158
+ export interface DefineExpressionDecoratorOptions {
159
+ validate?: (value: string) => boolean
160
+ }
161
+
162
+ export function defineExpression(
163
+ name: string,
164
+ { validate }: DefineExpressionDecoratorOptions = {}
165
+ ) {
166
+ return <T extends Material | EffectLike, K extends keyof T>(
167
+ target: T[K] extends string ? T : never,
168
+ propertyKey: K
169
+ ) => {
170
+ if (target instanceof Material) {
171
+ Object.defineProperty(target, propertyKey, {
172
+ enumerable: true,
173
+ get(this: Extract<T, Material>): string {
174
+ return this.defines?.[name] ?? ''
175
+ },
176
+ set(this: Extract<T, Material>, value: string) {
177
+ if (value !== this[propertyKey]) {
178
+ if (validate?.(value) === false) {
179
+ console.error(`Expression validation failed: ${value}`)
180
+ return
181
+ }
182
+ this.defines ??= {}
183
+ this.defines[name] = value
184
+ this.needsUpdate = true
185
+ }
186
+ }
187
+ })
188
+ } else {
189
+ Object.defineProperty(target, propertyKey, {
190
+ enumerable: true,
191
+ get(this: Extract<T, EffectLike>): string {
192
+ return this.defines.get(name) ?? ''
193
+ },
194
+ set(this: Extract<T, EffectLike>, value: string) {
195
+ if (value !== this[propertyKey]) {
196
+ if (validate?.(value) === false) {
197
+ console.error(`Expression validation failed: ${value}`)
198
+ return
199
+ }
200
+ this.defines.set(name, value)
201
+ ;(this as any).setChanged() // Bypass protected privilege
202
+ }
203
+ }
204
+ })
205
+ }
206
+ }
207
+ }
package/src/index.ts CHANGED
@@ -3,9 +3,11 @@ export * from './assertions'
3
3
  export * from './bufferGeometry'
4
4
  export * from './constants'
5
5
  export * from './DataLoader'
6
+ export * from './decorators'
6
7
  export * from './defineShorthand'
7
8
  export * from './Ellipsoid'
8
9
  export * from './EllipsoidGeometry'
10
+ export * from './EXR3DLoader'
9
11
  export * from './Geodetic'
10
12
  export * from './math'
11
13
  export * from './PointOfView'
package/src/r3f/types.ts CHANGED
@@ -59,5 +59,7 @@ export type PassThoughInstanceProps<
59
59
  >
60
60
 
61
61
  export type ExpandNestedProps<T, Prop extends keyof T & string> = {
62
- [K in keyof T[Prop] as K extends string ? `${Prop}-${K}` : never]: T[Prop][K]
62
+ [K in keyof NonNullable<T[Prop]> as K extends string
63
+ ? `${Prop}-${K}`
64
+ : 'never']: NonNullable<T[Prop]>[K]
63
65
  }
@@ -1,19 +1,21 @@
1
1
  import _cascadedShadowMaps from './cascadedShadowMaps.glsl?raw'
2
2
  import _depth from './depth.glsl?raw'
3
3
  import _generators from './generators.glsl?raw'
4
+ import _interleavedGradientNoise from './interleavedGradientNoise.glsl?raw'
4
5
  import _math from './math.glsl?raw'
5
6
  import _packing from './packing.glsl?raw'
6
- import _poissonDisk from './poissonDisk.glsl?raw'
7
7
  import _raySphereIntersection from './raySphereIntersection.glsl?raw'
8
8
  import _transform from './transform.glsl?raw'
9
9
  import _turbo from './turbo.glsl?raw'
10
+ import _vogelDisk from './vogelDisk.glsl?raw'
10
11
 
11
12
  export const cascadedShadowMaps: string = _cascadedShadowMaps
12
13
  export const depth: string = _depth
13
14
  export const generators: string = _generators
15
+ export const interleavedGradientNoise = _interleavedGradientNoise
14
16
  export const math: string = _math
15
17
  export const packing: string = _packing
16
- export const poissonDisk: string = _poissonDisk
17
18
  export const raySphereIntersection: string = _raySphereIntersection
18
19
  export const transform: string = _transform
19
20
  export const turbo: string = _turbo
21
+ export const vogelDisk = _vogelDisk
@@ -0,0 +1,6 @@
1
+ // Reference: https://advances.realtimerendering.com/s2014/index.html#_NEXT_GENERATION_POST
2
+
3
+ float interleavedGradientNoise(const vec2 coord) {
4
+ const vec3 magic = vec3(0.06711056, 0.00583715, 52.9829189);
5
+ return fract(magic.z * fract(dot(coord, magic.xy)));
6
+ }
@@ -0,0 +1,8 @@
1
+ // Reference: https://www.gamedev.net/tutorials/programming/graphics/contact-hardening-soft-shadows-made-fast-r4906/
2
+
3
+ vec2 vogelDisk(const int index, const int sampleCount, const float phi) {
4
+ const float goldenAngle = 2.39996322972865332;
5
+ float r = sqrt(float(index) + 0.5) / sqrt(float(sampleCount));
6
+ float theta = float(index) * goldenAngle + phi;
7
+ return r * vec2(cos(theta), sin(theta));
8
+ }
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 }
@@ -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 = keyof {
16
- [K in keyof DataView as DataView[K] extends (byteOffset: number) => number
17
- ? K
18
- : never]: DataView[K]
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
@@ -1,21 +1,22 @@
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, TypedArray } from 'three';
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];
9
10
  };
10
- export type DataTextureParameters = Omit<Partial<ParameterProperties<DataTexture>>, 'image'> & {
11
+ export interface DataTextureParameters extends Omit<Partial<ParameterProperties<DataTexture>>, 'image'> {
11
12
  width?: number;
12
13
  height?: number;
13
- };
14
- export type Data3DTextureParameters = Omit<Partial<ParameterProperties<Data3DTexture>>, 'image'> & {
14
+ }
15
+ export interface Data3DTextureParameters extends Omit<Partial<ParameterProperties<Data3DTexture>>, 'image'> {
15
16
  width?: number;
16
17
  height?: number;
17
18
  depth?: number;
18
- };
19
+ }
19
20
  export declare abstract class DataLoader<T extends DataTexture | Data3DTexture = DataTexture | Data3DTexture, U extends TypedArray = TypedArray> extends Loader<T> {
20
21
  abstract readonly Texture: Class<T>;
21
22
  abstract readonly TypedArrayLoader: Class<TypedArrayLoader<U>>;
@@ -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, TypedArray } from 'three';
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;
@@ -1,5 +1,6 @@
1
1
  import { BufferGeometry } from 'three';
2
2
 
3
- export type BufferGeometryLike = Pick<BufferGeometry, 'attributes' | 'index' | 'boundingBox' | 'boundingSphere'>;
3
+ export interface BufferGeometryLike extends Pick<BufferGeometry, 'attributes' | 'index' | 'boundingBox' | 'boundingSphere'> {
4
+ }
4
5
  export declare function toBufferGeometryLike(geometry: BufferGeometry): [BufferGeometryLike, ArrayBuffer[]];
5
6
  export declare function fromBufferGeometryLike(input: BufferGeometryLike, result?: BufferGeometry<import('three').NormalBufferAttributes>): BufferGeometry;
@@ -0,0 +1,22 @@
1
+ import { Material } from 'three';
2
+
3
+ interface EffectLike {
4
+ defines: Map<string, string>;
5
+ }
6
+ export declare function define(name: string): <T extends Material | EffectLike, K extends keyof T>(target: T[K] extends boolean ? T : never, propertyKey: K) => void;
7
+ export interface DefineIntDecoratorOptions {
8
+ min?: number;
9
+ max?: number;
10
+ }
11
+ export declare function defineInt(name: string, { min, max }?: DefineIntDecoratorOptions): <T extends Material | EffectLike, K extends keyof T>(target: T[K] extends number ? T : never, propertyKey: K) => void;
12
+ export interface DefineFloatDecoratorOptions {
13
+ min?: number;
14
+ max?: number;
15
+ precision?: number;
16
+ }
17
+ export declare function defineFloat(name: string, { min, max, precision }?: DefineFloatDecoratorOptions): <T extends Material | EffectLike, K extends keyof T>(target: T[K] extends number ? T : never, propertyKey: K) => void;
18
+ export interface DefineExpressionDecoratorOptions {
19
+ validate?: (value: string) => boolean;
20
+ }
21
+ export declare function defineExpression(name: string, { validate }?: DefineExpressionDecoratorOptions): <T extends Material | EffectLike, K extends keyof T>(target: T[K] extends string ? T : never, propertyKey: K) => void;
22
+ export {};
package/types/index.d.ts CHANGED
@@ -3,9 +3,11 @@ export * from './assertions';
3
3
  export * from './bufferGeometry';
4
4
  export * from './constants';
5
5
  export * from './DataLoader';
6
+ export * from './decorators';
6
7
  export * from './defineShorthand';
7
8
  export * from './Ellipsoid';
8
9
  export * from './EllipsoidGeometry';
10
+ export * from './EXR3DLoader';
9
11
  export * from './Geodetic';
10
12
  export * from './math';
11
13
  export * from './PointOfView';
@@ -16,6 +16,6 @@ export type PassThoughInstanceProps<RefType, Args extends readonly any[], Props>
16
16
  [K in NonFunctionKeys<Props> as K extends WritableNonExtendableKeysOf<Props> ? K : never]: Props[K];
17
17
  }>, NodeProps<RefType, Args>>;
18
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];
19
+ [K in keyof NonNullable<T[Prop]> as K extends string ? `${Prop}-${K}` : 'never']: NonNullable<T[Prop]>[K];
20
20
  };
21
21
  export {};
@@ -1,9 +1,10 @@
1
1
  export declare const cascadedShadowMaps: string;
2
2
  export declare const depth: string;
3
3
  export declare const generators: string;
4
+ export declare const interleavedGradientNoise: string;
4
5
  export declare const math: string;
5
6
  export declare const packing: string;
6
- export declare const poissonDisk: string;
7
7
  export declare const raySphereIntersection: string;
8
8
  export declare const transform: string;
9
9
  export declare const turbo: string;
10
+ export declare const vogelDisk: string;
@@ -1,4 +1,10 @@
1
- export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
2
- export type TypedArrayConstructor = Int8ArrayConstructor | Uint8ArrayConstructor | Uint8ClampedArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor;
3
- export type TypedArrayElementType = 'int8' | 'uint8' | 'int16' | 'uint16' | 'int32' | 'uint32' | 'float32' | 'float64';
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>;
@@ -1,23 +0,0 @@
1
- // TODO: Maybe switch to Vogel disk with IGN:
2
- // https://www.gamedev.net/tutorials/programming/graphics/contact-hardening-soft-shadows-made-fast-r4906/
3
- // Taken from: https://developer.download.nvidia.com/whitepapers/2008/PCSS_Integration.pdf
4
- const vec2 poissonDisk[16] = vec2[16](
5
- vec2(-0.94201624, -0.39906216),
6
- vec2(0.94558609, -0.76890725),
7
- vec2(-0.094184101, -0.9293887),
8
- vec2(0.34495938, 0.2938776),
9
- vec2(-0.91588581, 0.45771432),
10
- vec2(-0.81544232, -0.87912464),
11
- vec2(-0.38277543, 0.27676845),
12
- vec2(0.97484398, 0.75648379),
13
- vec2(0.44323325, -0.97511554),
14
- vec2(0.53742981, -0.4737342),
15
- vec2(-0.26496911, -0.41893023),
16
- vec2(0.79197514, 0.19090188),
17
- vec2(-0.2418884, 0.99706507),
18
- vec2(-0.81409955, 0.9143759),
19
- vec2(0.19984126, 0.78641367),
20
- vec2(0.14383161, -0.1410079)
21
- );
22
-
23
- #define POISSON_DISK_COUNT (16)