UNPKG

2.36 kBTypeScriptView Raw
1export type SerializedImage =
2 | string
3 | {
4 data: number[];
5 width: number;
6 height: number;
7 type: string;
8 };
9
10export class SourceJSON {
11 uuid: string;
12 url: SerializedImage | SerializedImage[];
13}
14
15/**
16 * Represents the data {@link Source} of a texture.
17 * @see {@link https://threejs.org/docs/index.html#api/en/textures/Source | Official Documentation}
18 * @see {@link https://github.com/mrdoob/three.js/blob/master/src/textures/Source.js | Source}
19 */
20export class Source {
21 /**
22 * Create a new instance of {@link Source}
23 * @param data The data definition of a texture. Default `null`
24 */
25 constructor(data: any);
26
27 /**
28 * Flag to check if a given object is of type {@link Source}.
29 * @remarks This is a _constant_ value
30 * @defaultValue `true`
31 */
32 readonly isSource: true;
33
34 readonly id: number;
35
36 /**
37 * The actual data of a texture.
38 * @remarks The type of this property depends on the texture that uses this instance.
39 */
40 data: any;
41
42 /**
43 * This property is only relevant when {@link .needsUpdate} is set to `true` and provides more control on how
44 * texture data should be processed.
45 * When `dataReady` is set to `false`, the engine performs the memory allocation (if necessary) but does not
46 * transfer the data into the GPU memory.
47 * @default true
48 */
49 dataReady: boolean;
50
51 /**
52 * When the property is set to `true`, the engine allocates the memory for the texture (if necessary) and triggers
53 * the actual texture upload to the GPU next time the source is used.
54 */
55 set needsUpdate(value: boolean);
56
57 /**
58 * {@link http://en.wikipedia.org/wiki/Universally_unique_identifier | UUID} of this object instance.
59 * @remarks This gets automatically assigned and shouldn't be edited.
60 */
61 uuid: string;
62
63 /**
64 * This starts at `0` and counts how many times {@link needsUpdate | .needsUpdate} is set to `true`.
65 * @remarks Expects a `Integer`
66 * @defaultValue `0`
67 */
68 version: number;
69
70 /**
71 * Convert the data {@link Source} to three.js {@link https://github.com/mrdoob/three.js/wiki/JSON-Object-Scene-format-4 | JSON Object/Scene format}.
72 * @param meta Optional object containing metadata.
73 */
74 toJSON(meta?: string | {}): SourceJSON;
75}