@takram/three-geospatial 0.2.1 → 0.3.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 +22 -0
- package/build/index.cjs +1 -1
- package/build/index.cjs.map +1 -1
- package/build/index.js +1311 -1309
- package/build/index.js.map +1 -1
- package/build/r3f.cjs +1 -1
- package/build/r3f.cjs.map +1 -1
- package/build/r3f.js +33 -50
- package/build/r3f.js.map +1 -1
- package/build/shaders.cjs.map +1 -1
- package/build/shaders.js.map +1 -1
- package/build/shared.cjs +1 -1
- package/build/shared.cjs.map +1 -1
- package/build/shared.js +116 -97
- package/build/shared.js.map +1 -1
- package/package.json +2 -3
- package/src/DataTextureLoader.ts +134 -0
- package/src/EXR3DTextureLoader.ts +66 -0
- package/src/{EXR3DLoader.ts → EXRTextureLoader.ts} +25 -12
- package/src/Ellipsoid.ts +23 -4
- package/src/STBNLoader.ts +28 -13
- package/src/TilingScheme.ts +1 -1
- package/src/TypedArrayLoader.ts +11 -21
- package/src/capabilities.ts +5 -0
- package/src/constants.ts +1 -0
- package/src/decorators.ts +0 -1
- package/src/defineShorthand.ts +1 -1
- package/src/index.ts +5 -3
- package/src/r3f/EastNorthUpFrame.tsx +14 -11
- package/src/r3f/EllipsoidMesh.tsx +16 -15
- package/src/r3f/index.ts +1 -1
- package/src/r3f/types.ts +1 -1
- package/src/typedArrayParsers.ts +1 -1
- package/src/types.ts +3 -1
- package/types/DataTextureLoader.d.ts +27 -0
- package/types/EXR3DTextureLoader.d.ts +11 -0
- package/types/EXRTextureLoader.d.ts +10 -0
- package/types/Ellipsoid.d.ts +1 -0
- package/types/STBNLoader.d.ts +5 -1
- package/types/TypedArrayLoader.d.ts +4 -6
- package/types/capabilities.d.ts +2 -0
- package/types/index.d.ts +5 -3
- package/types/r3f/EastNorthUpFrame.d.ts +4 -3
- package/types/r3f/EllipsoidMesh.d.ts +2 -1
- package/types/r3f/index.d.ts +1 -1
- package/types/types.d.ts +2 -1
- package/src/DataLoader.ts +0 -164
- package/src/Texture3DLoader.ts +0 -81
- package/types/DataLoader.d.ts +0 -29
- package/types/EXR3DLoader.d.ts +0 -6
- package/types/Texture3DLoader.d.ts +0 -4
@@ -3,9 +3,8 @@ import {
|
|
3
3
|
type ElementProps,
|
4
4
|
type ThreeElement
|
5
5
|
} from '@react-three/fiber'
|
6
|
-
import {
|
7
|
-
import {
|
8
|
-
import { type Mesh } from 'three'
|
6
|
+
import type { FC } from 'react'
|
7
|
+
import type { Mesh } from 'three'
|
9
8
|
|
10
9
|
import { EllipsoidGeometry } from '../EllipsoidGeometry'
|
11
10
|
|
@@ -20,15 +19,17 @@ export interface EllipsoidMeshProps
|
|
20
19
|
args?: ConstructorParameters<typeof EllipsoidGeometry>
|
21
20
|
}
|
22
21
|
|
23
|
-
export const EllipsoidMesh
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
22
|
+
export const EllipsoidMesh: FC<EllipsoidMeshProps> = ({
|
23
|
+
ref: forwardedRef,
|
24
|
+
args,
|
25
|
+
children,
|
26
|
+
...props
|
27
|
+
}) => {
|
28
|
+
extend({ EllipsoidGeometry })
|
29
|
+
return (
|
30
|
+
<mesh ref={forwardedRef} {...props}>
|
31
|
+
<ellipsoidGeometry args={args} />
|
32
|
+
{children}
|
33
|
+
</mesh>
|
34
|
+
)
|
35
|
+
}
|
package/src/r3f/index.ts
CHANGED
package/src/r3f/types.ts
CHANGED
package/src/typedArrayParsers.ts
CHANGED
package/src/types.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import type { FloatType, HalfFloatType, Uniform } from 'three'
|
2
2
|
|
3
3
|
export type Callable = (...args: any) => any
|
4
4
|
|
@@ -6,3 +6,5 @@ export type UniformMap<T> = Omit<Map<string, Uniform>, 'get'> & {
|
|
6
6
|
get: <K extends keyof T>(key: K) => T[K]
|
7
7
|
set: <K extends keyof T>(key: K, value: T[K]) => void
|
8
8
|
}
|
9
|
+
|
10
|
+
export type AnyFloatType = typeof FloatType | typeof HalfFloatType
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { Loader, ColorSpace, Data3DTexture, DataTexture, LoadingManager, MagnificationTextureFilter, Mapping, MinificationTextureFilter, PixelFormat, TextureDataType, Wrapping } from 'three';
|
2
|
+
import { Class } from 'type-fest';
|
3
|
+
import { TypedArray } from './typedArray';
|
4
|
+
import { TypedArrayParser } from './typedArrayParsers';
|
5
|
+
export interface DataTextureLoaderOptions {
|
6
|
+
width?: number;
|
7
|
+
height?: number;
|
8
|
+
depth?: number;
|
9
|
+
mapping?: Mapping;
|
10
|
+
wrapS?: Wrapping;
|
11
|
+
wrapT?: Wrapping;
|
12
|
+
wrapR?: Wrapping;
|
13
|
+
magFilter?: MagnificationTextureFilter;
|
14
|
+
minFilter?: MinificationTextureFilter;
|
15
|
+
format?: PixelFormat;
|
16
|
+
type?: TextureDataType;
|
17
|
+
anisotropy?: number;
|
18
|
+
colorSpace?: ColorSpace;
|
19
|
+
manager?: LoadingManager;
|
20
|
+
}
|
21
|
+
export declare class DataTextureLoader<T extends DataTexture | Data3DTexture = DataTexture | Data3DTexture, U extends TypedArray = TypedArray> extends Loader<T> {
|
22
|
+
textureClass: Class<T>;
|
23
|
+
parser: TypedArrayParser<U>;
|
24
|
+
options: DataTextureLoaderOptions;
|
25
|
+
constructor(textureClass: Class<T>, parser: TypedArrayParser<U>, options?: DataTextureLoaderOptions, manager?: LoadingManager);
|
26
|
+
load(url: string, onLoad?: (data: T) => void, onProgress?: (event: ProgressEvent) => void, onError?: (error: unknown) => void): T;
|
27
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { Data3DTexture, Loader, LoadingManager } from 'three';
|
2
|
+
export interface EXR3DTextureLoaderOptions {
|
3
|
+
width?: number;
|
4
|
+
height?: number;
|
5
|
+
depth?: number;
|
6
|
+
}
|
7
|
+
export declare class EXR3DTextureLoader extends Loader<Data3DTexture> {
|
8
|
+
options: EXR3DTextureLoaderOptions;
|
9
|
+
constructor(options?: EXR3DTextureLoaderOptions, manager?: LoadingManager);
|
10
|
+
load(url: string, onLoad?: (data: Data3DTexture) => void, onProgress?: (event: ProgressEvent) => void, onError?: (error: unknown) => void): Data3DTexture;
|
11
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { DataTexture, Loader, LoadingManager } from 'three';
|
2
|
+
export interface EXRTextureLoaderOptions {
|
3
|
+
width?: number;
|
4
|
+
height?: number;
|
5
|
+
}
|
6
|
+
export declare class EXRTextureLoader extends Loader<DataTexture> {
|
7
|
+
options: EXRTextureLoaderOptions;
|
8
|
+
constructor(options?: EXRTextureLoaderOptions, manager?: LoadingManager);
|
9
|
+
load(url: string, onLoad?: (data: DataTexture) => void, onProgress?: (event: ProgressEvent) => void, onError?: (error: unknown) => void): DataTexture;
|
10
|
+
}
|
package/types/Ellipsoid.d.ts
CHANGED
@@ -14,4 +14,5 @@ export declare class Ellipsoid {
|
|
14
14
|
getEastNorthUpFrame(position: Vector3, result?: Matrix4): Matrix4;
|
15
15
|
getIntersection(ray: Ray, result?: Vector3): Vector3 | undefined;
|
16
16
|
getOsculatingSphereCenter(surfacePosition: Vector3, radius: number, result?: Vector3): Vector3;
|
17
|
+
getNormalAtHorizon(position: Vector3, direction: Vector3, result?: Vector3): Vector3;
|
17
18
|
}
|
package/types/STBNLoader.d.ts
CHANGED
@@ -1 +1,5 @@
|
|
1
|
-
|
1
|
+
import { Data3DTexture, LoadingManager } from 'three';
|
2
|
+
import { DataTextureLoader } from './DataTextureLoader';
|
3
|
+
export declare class STBNLoader extends DataTextureLoader<Data3DTexture> {
|
4
|
+
constructor(manager?: LoadingManager);
|
5
|
+
}
|
@@ -1,10 +1,8 @@
|
|
1
|
-
import { Loader } from 'three';
|
2
|
-
import { Class } from 'type-fest';
|
1
|
+
import { Loader, LoadingManager } from 'three';
|
3
2
|
import { TypedArray } from './typedArray';
|
4
3
|
import { TypedArrayParser } from './typedArrayParsers';
|
5
|
-
export declare
|
6
|
-
|
4
|
+
export declare class TypedArrayLoader<T extends TypedArray> extends Loader<T> {
|
5
|
+
parser: TypedArrayParser<T>;
|
6
|
+
constructor(parser: TypedArrayParser<T>, manager?: LoadingManager);
|
7
7
|
load(url: string, onLoad: (data: T) => void, onProgress?: (event: ProgressEvent) => void, onError?: (error: unknown) => void): void;
|
8
8
|
}
|
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>;
|
package/types/index.d.ts
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
export * from './ArrayBufferLoader';
|
2
2
|
export * from './assertions';
|
3
3
|
export * from './bufferGeometry';
|
4
|
+
export * from './capabilities';
|
4
5
|
export * from './constants';
|
5
|
-
export * from './
|
6
|
+
export * from './DataTextureLoader';
|
6
7
|
export * from './decorators';
|
7
8
|
export * from './defineShorthand';
|
8
9
|
export * from './Ellipsoid';
|
9
10
|
export * from './EllipsoidGeometry';
|
10
|
-
export * from './
|
11
|
+
export * from './EXR3DTextureLoader';
|
12
|
+
export * from './EXRTextureLoader';
|
11
13
|
export * from './Geodetic';
|
12
14
|
export * from './math';
|
13
15
|
export * from './PointOfView';
|
@@ -19,5 +21,5 @@ export * from './TilingScheme';
|
|
19
21
|
export * from './typedArray';
|
20
22
|
export * from './TypedArrayLoader';
|
21
23
|
export * from './typedArrayParsers';
|
22
|
-
export * from './types';
|
24
|
+
export type * from './types';
|
23
25
|
export * from './unrollLoops';
|
@@ -1,4 +1,5 @@
|
|
1
|
-
import {
|
1
|
+
import { ElementProps } from '@react-three/fiber';
|
2
|
+
import { FC, ReactNode } from 'react';
|
2
3
|
import { Group } from 'three';
|
3
4
|
import { SetOptional } from 'type-fest';
|
4
5
|
import { Ellipsoid } from '../Ellipsoid';
|
@@ -6,9 +7,9 @@ import { GeodeticLike } from '../Geodetic';
|
|
6
7
|
declare class EastNorthUpFrameGroup extends Group {
|
7
8
|
set(longitude: number, latitude: number, height: number, ellipsoid?: Ellipsoid): void;
|
8
9
|
}
|
9
|
-
export interface EastNorthUpFrameProps extends SetOptional<GeodeticLike, 'height'> {
|
10
|
+
export interface EastNorthUpFrameProps extends ElementProps<typeof EastNorthUpFrameGroup, EastNorthUpFrameGroup>, SetOptional<GeodeticLike, 'height'> {
|
10
11
|
ellipsoid?: Ellipsoid;
|
11
12
|
children?: ReactNode;
|
12
13
|
}
|
13
|
-
export declare const EastNorthUpFrame:
|
14
|
+
export declare const EastNorthUpFrame: FC<EastNorthUpFrameProps>;
|
14
15
|
export {};
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { ElementProps, ThreeElement } from '@react-three/fiber';
|
2
|
+
import { FC } from 'react';
|
2
3
|
import { Mesh } from 'three';
|
3
4
|
import { EllipsoidGeometry } from '../EllipsoidGeometry';
|
4
5
|
declare module '@react-three/fiber' {
|
@@ -9,4 +10,4 @@ declare module '@react-three/fiber' {
|
|
9
10
|
export interface EllipsoidMeshProps extends Omit<ElementProps<typeof Mesh>, 'args'> {
|
10
11
|
args?: ConstructorParameters<typeof EllipsoidGeometry>;
|
11
12
|
}
|
12
|
-
export declare const EllipsoidMesh:
|
13
|
+
export declare const EllipsoidMesh: FC<EllipsoidMeshProps>;
|
package/types/r3f/index.d.ts
CHANGED
package/types/types.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
import { Uniform } from 'three';
|
1
|
+
import { FloatType, HalfFloatType, Uniform } from 'three';
|
2
2
|
export type Callable = (...args: any) => any;
|
3
3
|
export type UniformMap<T> = Omit<Map<string, Uniform>, 'get'> & {
|
4
4
|
get: <K extends keyof T>(key: K) => T[K];
|
5
5
|
set: <K extends keyof T>(key: K, value: T[K]) => void;
|
6
6
|
};
|
7
|
+
export type AnyFloatType = typeof FloatType | typeof HalfFloatType;
|
package/src/DataLoader.ts
DELETED
@@ -1,164 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
ByteType,
|
3
|
-
Data3DTexture,
|
4
|
-
DataTexture,
|
5
|
-
FloatType,
|
6
|
-
HalfFloatType,
|
7
|
-
IntType,
|
8
|
-
LinearFilter,
|
9
|
-
Loader,
|
10
|
-
RGBAFormat,
|
11
|
-
ShortType,
|
12
|
-
UnsignedByteType,
|
13
|
-
UnsignedIntType,
|
14
|
-
UnsignedShortType,
|
15
|
-
type TextureDataType
|
16
|
-
} from 'three'
|
17
|
-
import invariant from 'tiny-invariant'
|
18
|
-
import { type Class, type WritableKeysOf } from 'type-fest'
|
19
|
-
|
20
|
-
import { Float16Array, type TypedArray } from './typedArray'
|
21
|
-
import {
|
22
|
-
createTypedArrayLoaderClass,
|
23
|
-
type TypedArrayLoader
|
24
|
-
} from './TypedArrayLoader'
|
25
|
-
import { type TypedArrayParser } from './typedArrayParsers'
|
26
|
-
import { type Callable } from './types'
|
27
|
-
|
28
|
-
// TODO: Move to types
|
29
|
-
type ParameterProperties<T> = {
|
30
|
-
[K in WritableKeysOf<T> as T[K] extends Callable ? never : K]: T[K]
|
31
|
-
}
|
32
|
-
|
33
|
-
function getTextureDataType(array: TypedArray): TextureDataType {
|
34
|
-
// prettier-ignore
|
35
|
-
const type = (
|
36
|
-
array instanceof Int8Array ? ByteType :
|
37
|
-
array instanceof Uint8Array ? UnsignedByteType :
|
38
|
-
array instanceof Uint8ClampedArray ? UnsignedByteType :
|
39
|
-
array instanceof Int16Array ? ShortType :
|
40
|
-
array instanceof Uint16Array ? UnsignedShortType :
|
41
|
-
array instanceof Int32Array ? IntType :
|
42
|
-
array instanceof Uint32Array ? UnsignedIntType :
|
43
|
-
array instanceof Float16Array ? HalfFloatType :
|
44
|
-
array instanceof Float32Array ? FloatType :
|
45
|
-
array instanceof Float64Array ? FloatType :
|
46
|
-
null
|
47
|
-
)
|
48
|
-
invariant(type != null)
|
49
|
-
return type
|
50
|
-
}
|
51
|
-
|
52
|
-
export interface DataTextureParameters
|
53
|
-
extends Omit<Partial<ParameterProperties<DataTexture>>, 'image'> {
|
54
|
-
width?: number
|
55
|
-
height?: number
|
56
|
-
}
|
57
|
-
|
58
|
-
export interface Data3DTextureParameters
|
59
|
-
extends Omit<Partial<ParameterProperties<Data3DTexture>>, 'image'> {
|
60
|
-
width?: number
|
61
|
-
height?: number
|
62
|
-
depth?: number
|
63
|
-
}
|
64
|
-
|
65
|
-
const defaultDataTextureParameter = {
|
66
|
-
format: RGBAFormat,
|
67
|
-
minFilter: LinearFilter,
|
68
|
-
magFilter: LinearFilter
|
69
|
-
} satisfies DataTextureParameters & Data3DTextureParameters
|
70
|
-
|
71
|
-
export abstract class DataLoader<
|
72
|
-
T extends DataTexture | Data3DTexture = DataTexture | Data3DTexture,
|
73
|
-
U extends TypedArray = TypedArray
|
74
|
-
> extends Loader<T> {
|
75
|
-
abstract readonly Texture: Class<T>
|
76
|
-
abstract readonly TypedArrayLoader: Class<TypedArrayLoader<U>>
|
77
|
-
|
78
|
-
readonly parameters: DataTextureParameters & Data3DTextureParameters = {}
|
79
|
-
|
80
|
-
override load(
|
81
|
-
url: string,
|
82
|
-
onLoad: (data: T) => void,
|
83
|
-
onProgress?: (event: ProgressEvent) => void,
|
84
|
-
onError?: (error: unknown) => void
|
85
|
-
): void {
|
86
|
-
const texture = new this.Texture()
|
87
|
-
const loader = new this.TypedArrayLoader(this.manager)
|
88
|
-
loader.setRequestHeader(this.requestHeader)
|
89
|
-
loader.setPath(this.path)
|
90
|
-
loader.setWithCredentials(this.withCredentials)
|
91
|
-
loader.load(
|
92
|
-
url,
|
93
|
-
array => {
|
94
|
-
texture.image.data =
|
95
|
-
array instanceof Float16Array ? new Uint16Array(array.buffer) : array
|
96
|
-
const { width, height, depth, ...params } = this.parameters
|
97
|
-
if (width != null) {
|
98
|
-
texture.image.width = width
|
99
|
-
}
|
100
|
-
if (height != null) {
|
101
|
-
texture.image.height = height
|
102
|
-
}
|
103
|
-
if ('depth' in texture.image && depth != null) {
|
104
|
-
texture.image.depth = depth
|
105
|
-
}
|
106
|
-
|
107
|
-
// Populate the default texture type for the array type.
|
108
|
-
texture.type = getTextureDataType(array)
|
109
|
-
|
110
|
-
Object.assign(texture, params)
|
111
|
-
texture.needsUpdate = true
|
112
|
-
onLoad(texture)
|
113
|
-
},
|
114
|
-
onProgress,
|
115
|
-
onError
|
116
|
-
)
|
117
|
-
}
|
118
|
-
}
|
119
|
-
|
120
|
-
function createDataLoaderClass<
|
121
|
-
T extends DataTexture | Data3DTexture,
|
122
|
-
U extends TypedArray
|
123
|
-
>(
|
124
|
-
Texture: Class<T>,
|
125
|
-
parser: TypedArrayParser<U>,
|
126
|
-
parameters?: DataTextureParameters
|
127
|
-
): Class<DataLoader<T, U>> {
|
128
|
-
return class extends DataLoader<T, U> {
|
129
|
-
readonly Texture = Texture
|
130
|
-
readonly TypedArrayLoader = createTypedArrayLoaderClass(parser)
|
131
|
-
readonly parameters = {
|
132
|
-
...defaultDataTextureParameter,
|
133
|
-
...parameters
|
134
|
-
}
|
135
|
-
}
|
136
|
-
}
|
137
|
-
|
138
|
-
export function createData3DTextureLoaderClass<T extends TypedArray>(
|
139
|
-
parser: TypedArrayParser<T>,
|
140
|
-
parameters?: Data3DTextureParameters
|
141
|
-
): Class<DataLoader<Data3DTexture, T>> {
|
142
|
-
return createDataLoaderClass(Data3DTexture, parser, parameters)
|
143
|
-
}
|
144
|
-
|
145
|
-
export function createDataTextureLoaderClass<T extends TypedArray>(
|
146
|
-
parser: TypedArrayParser<T>,
|
147
|
-
parameters?: DataTextureParameters
|
148
|
-
): Class<DataLoader<DataTexture, T>> {
|
149
|
-
return createDataLoaderClass(DataTexture, parser, parameters)
|
150
|
-
}
|
151
|
-
|
152
|
-
export function createData3DTextureLoader<T extends TypedArray>(
|
153
|
-
parser: TypedArrayParser<T>,
|
154
|
-
parameters?: Data3DTextureParameters
|
155
|
-
): DataLoader<Data3DTexture, T> {
|
156
|
-
return new (createData3DTextureLoaderClass(parser, parameters))()
|
157
|
-
}
|
158
|
-
|
159
|
-
export function createDataTextureLoader<T extends TypedArray>(
|
160
|
-
parser: TypedArrayParser<T>,
|
161
|
-
parameters?: DataTextureParameters
|
162
|
-
): DataLoader<DataTexture, T> {
|
163
|
-
return new (createDataTextureLoaderClass(parser, parameters))()
|
164
|
-
}
|
package/src/Texture3DLoader.ts
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
Data3DTexture,
|
3
|
-
ImageLoader,
|
4
|
-
LinearFilter,
|
5
|
-
Loader,
|
6
|
-
RepeatWrapping
|
7
|
-
} from 'three'
|
8
|
-
|
9
|
-
export class Texture3DLoader extends Loader<Data3DTexture> {
|
10
|
-
override load(
|
11
|
-
url: string,
|
12
|
-
onLoad: (data: Data3DTexture) => void,
|
13
|
-
onProgress?: (event: ProgressEvent) => void,
|
14
|
-
onError?: (error: unknown) => void
|
15
|
-
): void {
|
16
|
-
const loader = new ImageLoader(this.manager)
|
17
|
-
loader.setRequestHeader(this.requestHeader)
|
18
|
-
loader.setPath(this.path)
|
19
|
-
loader.setWithCredentials(this.withCredentials)
|
20
|
-
loader.load(
|
21
|
-
url,
|
22
|
-
image => {
|
23
|
-
const canvas = document.createElement('canvas')
|
24
|
-
const context = canvas.getContext('2d')
|
25
|
-
if (context == null) {
|
26
|
-
onError?.(new Error('Could not obtain canvas context.'))
|
27
|
-
return
|
28
|
-
}
|
29
|
-
|
30
|
-
// Assume cubic 3D texture.
|
31
|
-
const { width, height } = image
|
32
|
-
const size = Math.min(width, height)
|
33
|
-
canvas.width = width
|
34
|
-
canvas.height = height
|
35
|
-
context.drawImage(image, 0, 0)
|
36
|
-
const imageData = context.getImageData(0, 0, width, height).data
|
37
|
-
let data: Uint8Array
|
38
|
-
|
39
|
-
if (width < height) {
|
40
|
-
data = new Uint8Array(imageData.buffer)
|
41
|
-
} else {
|
42
|
-
data = new Uint8Array(imageData.length)
|
43
|
-
const sizeSq = size ** 2
|
44
|
-
for (let z = 0; z < size; ++z) {
|
45
|
-
for (let y = 0; y < size; ++y) {
|
46
|
-
for (let x = 0; x < size; ++x) {
|
47
|
-
const src = (x + z * size + y * sizeSq) * 4
|
48
|
-
const dest = (x + y * size + z * sizeSq) * 4
|
49
|
-
data[dest + 0] = imageData[src + 0]
|
50
|
-
data[dest + 1] = imageData[src + 1]
|
51
|
-
data[dest + 2] = imageData[src + 2]
|
52
|
-
data[dest + 3] = imageData[src + 3]
|
53
|
-
}
|
54
|
-
}
|
55
|
-
}
|
56
|
-
}
|
57
|
-
|
58
|
-
const texture = new Data3DTexture(data, size, size, size)
|
59
|
-
texture.minFilter = LinearFilter
|
60
|
-
texture.magFilter = LinearFilter
|
61
|
-
texture.wrapS = RepeatWrapping
|
62
|
-
texture.wrapT = RepeatWrapping
|
63
|
-
texture.wrapR = RepeatWrapping
|
64
|
-
texture.needsUpdate = true
|
65
|
-
|
66
|
-
try {
|
67
|
-
onLoad(texture)
|
68
|
-
} catch (error) {
|
69
|
-
if (onError != null) {
|
70
|
-
onError(error)
|
71
|
-
} else {
|
72
|
-
console.error(error)
|
73
|
-
}
|
74
|
-
this.manager.itemError(url)
|
75
|
-
}
|
76
|
-
},
|
77
|
-
onProgress,
|
78
|
-
onError
|
79
|
-
)
|
80
|
-
}
|
81
|
-
}
|
package/types/DataLoader.d.ts
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
import { Data3DTexture, DataTexture, Loader } from 'three';
|
2
|
-
import { Class, WritableKeysOf } from 'type-fest';
|
3
|
-
import { TypedArray } from './typedArray';
|
4
|
-
import { TypedArrayLoader } from './TypedArrayLoader';
|
5
|
-
import { TypedArrayParser } from './typedArrayParsers';
|
6
|
-
import { Callable } from './types';
|
7
|
-
type ParameterProperties<T> = {
|
8
|
-
[K in WritableKeysOf<T> as T[K] extends Callable ? never : K]: T[K];
|
9
|
-
};
|
10
|
-
export interface DataTextureParameters extends Omit<Partial<ParameterProperties<DataTexture>>, 'image'> {
|
11
|
-
width?: number;
|
12
|
-
height?: number;
|
13
|
-
}
|
14
|
-
export interface Data3DTextureParameters extends Omit<Partial<ParameterProperties<Data3DTexture>>, 'image'> {
|
15
|
-
width?: number;
|
16
|
-
height?: number;
|
17
|
-
depth?: number;
|
18
|
-
}
|
19
|
-
export declare abstract class DataLoader<T extends DataTexture | Data3DTexture = DataTexture | Data3DTexture, U extends TypedArray = TypedArray> extends Loader<T> {
|
20
|
-
abstract readonly Texture: Class<T>;
|
21
|
-
abstract readonly TypedArrayLoader: Class<TypedArrayLoader<U>>;
|
22
|
-
readonly parameters: DataTextureParameters & Data3DTextureParameters;
|
23
|
-
load(url: string, onLoad: (data: T) => void, onProgress?: (event: ProgressEvent) => void, onError?: (error: unknown) => void): void;
|
24
|
-
}
|
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
|
-
export {};
|
package/types/EXR3DLoader.d.ts
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
import { Data3DTexture, Loader } from 'three';
|
2
|
-
export declare class EXR3DLoader extends Loader<Data3DTexture> {
|
3
|
-
depth?: number;
|
4
|
-
setDepth(value: number): this;
|
5
|
-
load(url: string, onLoad: (data: Data3DTexture) => void, onProgress?: (event: ProgressEvent) => void, onError?: (error: unknown) => void): void;
|
6
|
-
}
|