diff --git a/types/three/index.d.ts b/types/three/index.d.ts index b8c5dfa961..2e4cad4929 100644 --- a/types/three/index.d.ts +++ b/types/three/index.d.ts @@ -23,6 +23,7 @@ // Dilip Ramirez // Julian Strecker // Zhang Hao +// Konstantin Lukaschenko // Definitions: https://github.com//DefinitelyTyped // TypeScript Version: 2.8 @@ -34,6 +35,7 @@ export * from "./three-copyshader"; export * from "./three-css3drenderer"; export * from "./three-ctmloader"; export * from "./three-ddsloader"; +export * from "./three-tdsloader"; export * from "./three-dragcontrols"; export * from "./three-editorcontrols"; export * from "./three-effectcomposer"; diff --git a/types/three/test/examples/loaders/tdsloader.ts b/types/three/test/examples/loaders/tdsloader.ts new file mode 100644 index 0000000000..72666d4003 --- /dev/null +++ b/types/three/test/examples/loaders/tdsloader.ts @@ -0,0 +1,14 @@ +import * as THREE from '../../../index' + +const onSuccess = (object3D: THREE.Object3D) => {}; +const onProgress = (progress: ProgressEvent) => {}; +const onError = (event: ErrorEvent) => {}; + +() => { + new THREE.TDSLoader(THREE).load( + 'folder/file.3ds', + onSuccess, + onProgress, + onError + ); +} \ No newline at end of file diff --git a/types/three/three-tdsloader.d.ts b/types/three/three-tdsloader.d.ts new file mode 100644 index 0000000000..3cd9df6443 --- /dev/null +++ b/types/three/three-tdsloader.d.ts @@ -0,0 +1,195 @@ +// https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/TDSLoader.js + +import * as THREE from "./index"; + +export class TDSLoader { + constructor(three: typeof THREE); + + /** + * Load 3ds file from url. + * + * @param url URL for the file. + * @param onLoad onLoad callback, receives group object3D as argument. + * @param onProgress onProgress callback. + * @param onError onError callback. + */ + load: (url: string, onLoad: (object3D: THREE.Object3D) => void, onProgress?: (progress: ProgressEvent) => void, onError?: (event: ErrorEvent) => void) => void; + + /** + * Parse arraybuffer data and load 3ds file. + * + * @param arraybuffer Arraybuffer data to be loaded. + * @param path Path for external resources. + * @return Group loaded from 3ds file. + */ + parse: (arraybuffer: ArrayBuffer, path: string) => THREE.Object3D; + + /** + * Decode file content to read 3ds data. + * + * @param arraybuffer Arraybuffer data to be loaded. + */ + readFile: (arraybuffer: ArrayBuffer, path: string) => void; + + /** + * Read mesh data chunk. + * + * @param data Dataview in use. + */ + readMeshData: (data: DataView, path: string) => void; + + /** + * Read named object chunk. + * + * @param data Dataview in use. + */ + readNamedobject: (data: DataView) => void; + + /** + * Read material data chunk and add it to the material list. + * + * @param data Dataview in use. + */ + readMaterialEntry: (data: DataView, path: string) => void; + + /** + * Read mesh data chunk. + * + * @param data Dataview in use. + */ + readMesh: (data: DataView) => void; + + /** + * Read face array data chunk. + * + * @param data Dataview in use. + * @param mesh Mesh to be filled with the data read. + */ + readFaceArray: (data: DataView, mesh: THREE.Mesh) => void; + + /** + * Read texture map data chunk. + * + * @param data Dataview in use. + * @return Texture read from this data chunk. + */ + readMap: (data: DataView, path: string) => THREE.Texture; + + /** + * Read material group data chunk. + * + * @param data Dataview in use. + * @return object with name and index of the object. + */ + readMaterialGroup: (data: DataView) => object; + + /** + * Read a color value. + * + * @param data Dataview. + * @return Color value read.. + */ + readColor: (data: DataView) => THREE.Color; + + /** + * Read next chunk of data. + * + * @param data Dataview. + * @return Chunk of data read. + */ + readChunk: (data: DataView) => object; + + /** + * Set position to the end of the current chunk of data. + * + * @param chunk Data chunk. + */ + endChunk: (chunk: object) => void; + + /** + * Move to the next data chunk. + * + * @param data Dataview. + * @param chunk Data chunk. + */ + nextChunk: (data: DataView, chunk: object) => number; + + /** + * Reset dataview position. + */ + resetPosition: () => void; + + /** + * Read byte value. + * + * @param data Dataview to read data from. + * @return Data read from the dataview. + */ + readByte: (data: DataView) => number; + + /** + * Read 32 bit float value. + * + * @param data Dataview to read data from. + * @return Data read from the dataview. + */ + readFloat: (data: DataView) => number; + + /** + * Read 32 bit signed integer value. + * + * @param data Dataview to read data from. + * @return Data read from the dataview. + */ + readInt: (data: DataView) => number; + + /** + * Read 16 bit signed integer value. + * + * @param data Dataview to read data from. + * @return Data read from the dataview. + */ + readShort: (data: DataView) => number; + + /** + * Read 64 bit unsigned integer value. + * + * @param data Dataview to read data from. + * @return Data read from the dataview. + */ + readDWord: (data: DataView) => number; + + /** + * Read 32 bit unsigned integer value. + * + * @param data Dataview to read data from. + * @return Data read from the dataview. + */ + readWord: (data: DataView) => number; + + /** + * Read string value. + * + * @param data Dataview to read data from. + * @param maxLength Max size of the string to be read. + * @return Data read from the dataview. + */ + readString: (data: DataView, maxLength: number) => string; + + /** + * Set resource path used to determine the file path to attached resources. + * + * @param path Path to resources. + * @return Self for chaining. + */ + setPath: (path: string) => TDSLoader; + + /** + * Print debug message to the console. + * + * Is controlled by a flag to show or hide debug messages. + * + * @param message Debug message to print to the console. + */ + debugMessage: (message: string) => void; +} \ No newline at end of file diff --git a/types/three/tsconfig.json b/types/three/tsconfig.json index a7a79e68f5..814dd8f824 100644 --- a/types/three/tsconfig.json +++ b/types/three/tsconfig.json @@ -57,6 +57,7 @@ "test/examples/ctm/ctmloader.ts", "test/examples/octree.ts", "test/examples/loaders/webgl_loader_obj_mtl.ts", + "test/examples/loaders/tdsloader.ts", "test/examples/exporters/gltf-exporter.ts", "test/webvr/webvr.ts" ]