Skip to content

Commit

Permalink
Add load and loadAsync methods back to Loader (#570)
Browse files Browse the repository at this point in the history
* Loader updates

* Add return types

* Get tests passing

* Fix
  • Loading branch information
Methuselah96 authored Jul 31, 2023
1 parent b804bd9 commit f8e5198
Show file tree
Hide file tree
Showing 57 changed files with 101 additions and 1,195 deletions.
1 change: 0 additions & 1 deletion types/three/OTHER_FILES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ examples/jsm/lines/WireframeGeometry2.d.ts
examples/jsm/loaders/3DMLoader.d.ts
examples/jsm/loaders/3MFLoader.d.ts
examples/jsm/loaders/AMFLoader.d.ts
examples/jsm/loaders/BasisTextureLoader.d.ts
examples/jsm/loaders/BVHLoader.d.ts
examples/jsm/loaders/ColladaLoader.d.ts
examples/jsm/loaders/EXRLoader.d.ts
Expand Down
9 changes: 1 addition & 8 deletions types/three/examples/jsm/loaders/3DMLoader.d.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import { Loader, LoadingManager, Object3D } from '../../../src/Three.js';

export class Rhino3dmLoader extends Loader {
export class Rhino3dmLoader extends Loader<Object3D> {
constructor(manager?: LoadingManager);

load(
url: string,
onLoad: (object: Object3D) => void,
onProgress?: (event: ProgressEvent) => void,
onError?: (event: ErrorEvent) => void,
): void;
loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<Object3D>;
parse(data: ArrayBufferLike, onLoad: (object: Object3D) => void, onError?: (event: ErrorEvent) => void): void;
setLibraryPath(path: string): Rhino3dmLoader;
setWorkerLimit(workerLimit: number): Rhino3dmLoader;
Expand Down
9 changes: 1 addition & 8 deletions types/three/examples/jsm/loaders/3MFLoader.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import { Loader, LoadingManager, Group } from '../../../src/Three.js';

export class ThreeMFLoader extends Loader {
export class ThreeMFLoader extends Loader<Group> {
constructor(manager?: LoadingManager);
availableExtensions: object[];

load(
url: string,
onLoad: (object: Group) => void,
onProgress?: (event: ProgressEvent) => void,
onError?: (event: ErrorEvent) => void,
): void;
loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<Group>;
parse(data: ArrayBuffer): Group;
addExtension(extension: object): void;
}
9 changes: 1 addition & 8 deletions types/three/examples/jsm/loaders/AMFLoader.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import { Loader, LoadingManager, Group } from '../../../src/Three.js';

export class AMFLoader extends Loader {
export class AMFLoader extends Loader<Group> {
constructor(manager?: LoadingManager);

load(
url: string,
onLoad: (object: Group) => void,
onProgress?: (event: ProgressEvent) => void,
onError?: (event: ErrorEvent) => void,
): void;
loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<Group>;
parse(data: ArrayBuffer): Group;
}
9 changes: 1 addition & 8 deletions types/three/examples/jsm/loaders/BVHLoader.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,10 @@ export interface BVH {
skeleton: Skeleton;
}

export class BVHLoader extends Loader {
export class BVHLoader extends Loader<BVH> {
constructor(manager?: LoadingManager);
animateBonePositions: boolean;
animateBoneRotations: boolean;

load(
url: string,
onLoad: (bvh: BVH) => void,
onProgress?: (event: ProgressEvent) => void,
onError?: (event: ErrorEvent) => void,
): void;
loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<BVH>;
parse(text: string): BVH;
}
32 changes: 0 additions & 32 deletions types/three/examples/jsm/loaders/BasisTextureLoader.d.ts

This file was deleted.

9 changes: 1 addition & 8 deletions types/three/examples/jsm/loaders/ColladaLoader.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,8 @@ export interface Collada {
scene: Scene;
}

export class ColladaLoader extends Loader {
export class ColladaLoader extends Loader<Collada> {
constructor(manager?: LoadingManager);

load(
url: string,
onLoad: (collada: Collada) => void,
onProgress?: (event: ProgressEvent) => void,
onError?: (event: ErrorEvent) => void,
): void;
loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<Collada>;
parse(text: string, path: string): Collada;
}
9 changes: 1 addition & 8 deletions types/three/examples/jsm/loaders/DRACOLoader.d.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import { Loader, LoadingManager, BufferGeometry } from '../../../src/Three.js';

export class DRACOLoader extends Loader {
export class DRACOLoader extends Loader<BufferGeometry> {
constructor(manager?: LoadingManager);

load(
url: string,
onLoad: (geometry: BufferGeometry) => void,
onProgress?: (event: ProgressEvent) => void,
onError?: (event: ErrorEvent) => void,
): void;
loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<BufferGeometry>;
setDecoderPath(path: string): DRACOLoader;
setDecoderConfig(config: object): DRACOLoader;
setWorkerLimit(workerLimit: number): DRACOLoader;
Expand Down
9 changes: 1 addition & 8 deletions types/three/examples/jsm/loaders/FBXLoader.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import { Group, Loader, LoadingManager } from '../../../src/Three.js';

export class FBXLoader extends Loader {
export class FBXLoader extends Loader<Group> {
constructor(manager?: LoadingManager);

load(
url: string,
onLoad: (object: Group) => void,
onProgress?: (event: ProgressEvent) => void,
onError?: (event: ErrorEvent) => void,
): void;
loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<Group>;
parse(FBXBuffer: ArrayBuffer | string, path: string): Group;
}
9 changes: 1 addition & 8 deletions types/three/examples/jsm/loaders/FontLoader.d.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import { Shape, Loader, LoadingManager } from '../../../src/Three.js';

export class FontLoader extends Loader {
export class FontLoader extends Loader<Font> {
constructor(manager?: LoadingManager);

load(
url: string,
onLoad?: (responseFont: Font) => void,
onProgress?: (event: ProgressEvent) => void,
onError?: (event: ErrorEvent) => void,
): void;
loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<Font>;
parse(json: any): Font;
}

Expand Down
9 changes: 1 addition & 8 deletions types/three/examples/jsm/loaders/GCodeLoader.d.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import { Group, Loader, LoadingManager } from '../../../src/Three.js';

export class GCodeLoader extends Loader {
export class GCodeLoader extends Loader<Group> {
constructor(manager?: LoadingManager);
splitLayer: boolean;

load(
url: string,
onLoad: (object: Group) => void,
onProgress?: (event: ProgressEvent) => void,
onError?: (event: ErrorEvent) => void,
): void;
loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<Group>;
parse(data: string): Group;
}
10 changes: 1 addition & 9 deletions types/three/examples/jsm/loaders/GLTFLoader.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,10 @@ export interface GLTF {
userData: any;
}

export class GLTFLoader extends Loader {
export class GLTFLoader extends Loader<GLTF> {
constructor(manager?: LoadingManager);
dracoLoader: DRACOLoader | null;

load(
url: string,
onLoad: (gltf: GLTF) => void,
onProgress?: (event: ProgressEvent) => void,
onError?: (event: ErrorEvent) => void,
): void;
loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<GLTF>;

setDRACOLoader(dracoLoader: DRACOLoader): GLTFLoader;

register(callback: (parser: GLTFParser) => GLTFLoaderPlugin): GLTFLoader;
Expand Down
10 changes: 5 additions & 5 deletions types/three/examples/jsm/loaders/HDRCubeTextureLoader.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import { CubeTexture, Loader, LoadingManager, TextureDataType } from '../../../s

import { RGBELoader } from './RGBELoader.js';

export class HDRCubeTextureLoader extends Loader {
export class HDRCubeTextureLoader extends Loader<CubeTexture, readonly string[]> {
constructor(manager?: LoadingManager);
hdrLoader: RGBELoader;
type: TextureDataType;

load(
urls: string[],
onLoad: (texture: CubeTexture) => void,
url: readonly string[],
onLoad?: (data: CubeTexture) => void,
onProgress?: (event: ProgressEvent) => void,
onError?: (event: ErrorEvent) => void,
onError?: (err: unknown) => void,
): CubeTexture;
loadAsync(urls: string[], onProgress?: (event: ProgressEvent) => void): Promise<CubeTexture>;

setDataType(type: TextureDataType): this;
}
Loading

0 comments on commit f8e5198

Please sign in to comment.