blockbench-types 5.1.0 → 5.2.0-beta.0-next.1

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.
Files changed (72) hide show
  1. package/README.md +30 -30
  2. package/custom/animation.d.ts +256 -256
  3. package/custom/animation_controller.d.ts +124 -124
  4. package/custom/blockbench.d.ts +71 -73
  5. package/custom/canvas.d.ts +307 -307
  6. package/custom/codec.d.ts +182 -182
  7. package/custom/copy_paste.d.ts +43 -42
  8. package/custom/cube.d.ts +151 -151
  9. package/custom/desktop.d.ts +61 -73
  10. package/custom/display_mode.d.ts +137 -137
  11. package/custom/edit_session.d.ts +38 -37
  12. package/custom/global.d.ts +182 -168
  13. package/custom/group.d.ts +113 -113
  14. package/custom/interface.d.ts +83 -78
  15. package/custom/io.d.ts +12 -12
  16. package/custom/keyframe.d.ts +94 -94
  17. package/custom/libs.d.ts +13 -13
  18. package/custom/menu.d.ts +137 -136
  19. package/custom/mesh.d.ts +196 -196
  20. package/custom/misc.d.ts +188 -199
  21. package/custom/molang.d.ts +159 -159
  22. package/custom/outliner.d.ts +158 -158
  23. package/custom/painter.d.ts +70 -69
  24. package/custom/preview.d.ts +147 -137
  25. package/custom/preview_scene.d.ts +120 -120
  26. package/custom/screencam.d.ts +71 -71
  27. package/custom/spline_mesh.d.ts +189 -189
  28. package/custom/texture_group.d.ts +68 -68
  29. package/custom/textures.d.ts +524 -515
  30. package/custom/timeline.d.ts +66 -66
  31. package/custom/toolbars.d.ts +222 -221
  32. package/custom/undo.d.ts +209 -208
  33. package/custom/util/version_util.d.ts +32 -32
  34. package/custom/util.d.ts +235 -235
  35. package/custom/uveditor.d.ts +3 -3
  36. package/custom/validator.d.ts +99 -99
  37. package/documentation.md +12 -12
  38. package/generated/animations/mirror_animating.d.ts +7 -0
  39. package/generated/api.d.ts +6 -0
  40. package/generated/file_system.d.ts +1 -1
  41. package/generated/formats/standards/obj.d.ts +9 -11
  42. package/generated/interface/actions.d.ts +6 -3
  43. package/generated/interface/form.d.ts +2 -1
  44. package/generated/interface/resize_lines.d.ts +2 -0
  45. package/generated/interface/settings.d.ts +6 -2
  46. package/generated/interface/start_screen.d.ts +62 -42
  47. package/generated/io/project.d.ts +9 -1
  48. package/generated/lib/CanvasFrame.d.ts +1 -0
  49. package/generated/main.d.ts +1 -1
  50. package/generated/modeling/mesh/proportional_edit.d.ts +15 -13
  51. package/generated/modeling/mirror_modeling.d.ts +4 -0
  52. package/generated/modeling/weight_paint.d.ts +11 -0
  53. package/generated/texturing/layers.d.ts +140 -0
  54. package/generated/util/state_memory.d.ts +1 -1
  55. package/index.d.ts +2 -2
  56. package/package.json +39 -39
  57. package/tsconfig.json +19 -19
  58. package/type_config.json +45 -46
  59. package/custom/start_screen.d.ts +0 -15
  60. package/custom/texture_layers.d.ts +0 -117
  61. package/generated/global_types.d.ts +0 -47
  62. package/generated/io/formats/bedrock.d.ts +0 -4
  63. package/generated/io/formats/bedrock_old.d.ts +0 -4
  64. package/generated/io/formats/collada.d.ts +0 -4
  65. package/generated/io/formats/fbx.d.ts +0 -17
  66. package/generated/io/formats/gltf.d.ts +0 -6
  67. package/generated/io/formats/java_block.d.ts +0 -4
  68. package/generated/io/formats/modded_entity.d.ts +0 -139
  69. package/generated/io/formats/obj.d.ts +0 -12
  70. package/generated/io/formats/optifine_jem.d.ts +0 -3
  71. package/generated/io/formats/optifine_jpm.d.ts +0 -3
  72. package/generated/io/formats/skin.d.ts +0 -22
@@ -1,515 +1,524 @@
1
- /// <reference types="./blockbench"/>
2
-
3
- import type { FSWatcher } from 'fs'
4
- import type { ShaderMaterial } from 'three'
5
-
6
- declare global {
7
- interface TextureData {
8
- path?: string
9
- uuid?: string
10
- name?: string
11
- /**
12
- * Relative path to the file's directory, used by some formats such as Java Block/Item
13
- * */
14
- folder?: string
15
- namespace?: string
16
- /**
17
- * Texture ID or key, used by some formats. By default this is a number that increases with every texture that is added
18
- * */
19
- id?: string
20
- /**
21
- * Whether the texture is used for the models particle system. Used by some formats such as Java Block/Item
22
- * */
23
- particle?: boolean
24
- visible?: boolean
25
- render_mode?: 'default' | 'emissive' | 'additive' | 'layered' | string
26
- render_sides?: 'auto' | 'front' | 'double' | string
27
- wrap_mode?: 'limited' | 'repeat' | 'clamp'
28
- pbr_channel?: 'color' | 'normal' | 'height' | 'mer'
29
- /**
30
- * UUID of the texture group that the texture is in
31
- */
32
- group?: string
33
- scope?: number
34
-
35
- /**
36
- * Texture animation frame time
37
- * */
38
- frame_time?: number
39
- frame_order_type?: 'custom' | 'loop' | 'backwards' | 'back_and_forth'
40
- /**
41
- * Custom frame order
42
- * */
43
- frame_order?: string
44
- /**
45
- * Interpolate between frames
46
- * */
47
- frame_interpolate?: boolean
48
- /**
49
- * Whether the texture is saved
50
- */
51
- saved?: boolean
52
- /**
53
- * If true, the texture is loaded internally. If false, the texture is loaded directly from a file
54
- */
55
- internal?: boolean
56
- /**
57
- * Flag to indicate that the texture was manually resized, and on load it should not try to automatically adjust UV size
58
- */
59
- keep_size?: boolean
60
- source?: string
61
- width?: number
62
- height?: number
63
- standalone?: boolean
64
- relative_path?: string
65
- }
66
- interface TextureEditOptions {
67
- /**
68
- * Edit method. 'canvas' is default
69
- */
70
- method?: 'canvas' | 'jimp'
71
- /**
72
- * Name of the undo entry that is created
73
- */
74
- edit_name?: string
75
- /**
76
- * Whether to use the cached canvas/jimp instance
77
- */
78
- use_cache?: boolean
79
- /**
80
- * If true, no undo point is created. Default is false
81
- */
82
- no_undo?: boolean
83
- /**
84
- * If true, the texture is not updated visually
85
- */
86
- no_update?: boolean
87
- no_undo_init?: boolean
88
- no_undo_finish?: boolean
89
- }
90
-
91
- /**
92
- * A texture combines the functionality of material, texture, and image, in one. Textures can be linked to files on the local hard drive, or hold the information in RAM.
93
- */
94
- class Texture {
95
- constructor(data?: TextureData, uuid?: string)
96
- readonly frameCount: number | undefined
97
- readonly display_height: number
98
- readonly ratio: number
99
- static selected?: Texture
100
-
101
- uuid: UUID
102
- path?: string
103
- name: string
104
- /** Relative path to the file's directory, used by some formats such as Java Block/Item*/
105
- folder: string
106
- namespace: string
107
- /** Texture ID or key, used by some formats. By default this is a number that increases with every texture that is added */
108
- id: string
109
- /** Whether the texture is used for the models particle system. Used by some formats such as Java Block/Item */
110
- particle: boolean
111
- render_mode: 'default' | 'emissive' | 'additive' | 'layered' | string
112
- render_sides: 'auto' | 'front' | 'double' | string
113
- wrap_mode: 'limited' | 'repeat' | 'clamp'
114
- pbr_channel: 'color' | 'normal' | 'height' | 'mer'
115
- use_as_default: boolean
116
- /** UUID of the TextureGroup that this texture is in, if set */
117
- group: string
118
- scope: number
119
-
120
- /** Texture animation frame time */
121
- frame_time: number
122
- frame_order_type: 'custom' | 'loop' | 'backwards' | 'back_and_forth'
123
- /** Custom frame order */
124
- frame_order: string
125
- /** Interpolate between frames */
126
- frame_interpolate: boolean
127
-
128
- /** HTML-style source of the texture's displayed data. Can be a path (desktop app only), or a base64 data URL */
129
- source: string
130
- /**
131
- * Whether the texture is directly selected
132
- */
133
- selected: boolean
134
- /**
135
- * Whether the texture is multi selected
136
- */
137
- multi_selected: boolean
138
- selected_layer: TextureLayer | null
139
- show_icon: boolean
140
- error: number
141
- /** Whether the texture is visible. Used for layered textures mode */
142
- visible: boolean
143
-
144
- width: number
145
- height: number
146
- uv_width: number
147
- uv_height: number
148
- currentFrame: number
149
- saved: boolean
150
- /**
151
- * Whether the latest version of the texture is currently loaded from and linked to a file on disk, or held in memory as bitmap data
152
- * @deprecated Use {@link Texture.internal} instead
153
- */
154
- mode: never
155
- /**
156
- * If true, the texture is loaded internally. If false, the texture is loaded directly from a file
157
- */
158
- internal: boolean
159
- /**
160
- * Set a function that will run once the next time the texture is loaded
161
- */
162
- load_callback?: null | ((texture: Texture) => void)
163
- /**
164
- * Custom texture flags
165
- */
166
- flags: Set
167
-
168
- /**
169
- * Texture selection in paint mode
170
- */
171
- selection: IntMatrix
172
- layers: TextureLayer[]
173
- layers_enabled: boolean
174
- /**
175
- * The UUID of the project to sync the texture to
176
- */
177
- sync_to_project: UUID | ''
178
-
179
- /**
180
- * The texture's associated canvas. Since 4.9, this is the main source of truth for textures in internal mode.
181
- */
182
- canvas: HTMLCanvasElement
183
- /**
184
- * The 2D context of the texture's associated canvas.
185
- */
186
- ctx: CanvasRenderingContext2D
187
- /**
188
- * Texture image element
189
- */
190
- img: HTMLImageElement
191
- readonly offset: ArrayVector2
192
-
193
- relative_path?: string
194
- get material(): THREE.ShaderMaterial
195
- set material(value: THREE.ShaderMaterial)
196
-
197
- getErrorMessage(): string
198
- extend(data: TextureData): this
199
-
200
- /**
201
- * Get the UV width of the texture if the format uses per texture UV size, otherwise get the project texture width
202
- */
203
- getUVWidth(): number
204
- /**
205
- * Get the UV height of the texture if the format uses per texture UV size, otherwise get the project texture height
206
- */
207
- getUVHeight(): number
208
- getUndoCopy(bitmap?: boolean): any
209
- getSaveCopy(bitmap?: boolean): any
210
- /**
211
- * Start listening for changes to the linked file. Desktop only
212
- */
213
- startWatcher(): void
214
- /**
215
- * Stop listening for changes to the linked file. Desktop only
216
- */
217
- stopWatcher(): void
218
- /**
219
- * Generate the Java Block/Item folder property from the file path
220
- */
221
- generateFolder(): void
222
- /**
223
- * Loads the texture from it's current source
224
- * @param cb Callback function
225
- */
226
- load(cb?: () => {}): this
227
- fromJavaLink(link: string, path_array: string[]): this
228
- fromFile(file: { name: string; content?: string; path: string }): this
229
- fromPath(path: string): this
230
- /**
231
- * Loads file content **only**.
232
- *
233
- * Does not read `png.mcmeta`, or attempt to overwrite an existing texture in the project with the same name.
234
- *
235
- * Used internally when loading `.bbmodel` files
236
- * @param path
237
- */
238
- loadContentFromPath(path: string): this
239
- fromDataURL(data_url: string): this
240
- fromDefaultPack(): true | undefined
241
- /**
242
- * Loads the default white error texture
243
- * @param error_id Sets the error ID of the texture
244
- */
245
- loadEmpty(error_id?: number): this
246
-
247
- updateSource(dataUrl: string): this
248
- updateMaterial(): this
249
-
250
- /**
251
- * Opens a dialog to replace the texture with another file
252
- * @param force If true, no warning appears of the texture has unsaved changes
253
- */
254
- reopen(force: boolean): void
255
- /**
256
- * Reloads the texture. Only works in the desktop app
257
- */
258
- reloadTexture(): void
259
- /**
260
- * Get the material that the texture displays. When previewing PBR, this will return the shared PBR material
261
- */
262
- getMaterial(): THREE.ShaderMaterial | THREE.MeshStandardMaterial
263
- /**
264
- * Get the texture's own material
265
- */
266
- getOwnMaterial(): THREE.ShaderMaterial
267
- /**
268
- * Selects the texture
269
- * @param event Click event during selection
270
- */
271
- select(event?: Event): this
272
- /**
273
- * Adds texture to the textures list and initializes it
274
- * @param undo If true, an undo point is created
275
- */
276
- add(undo?: boolean, uv_size_from_resolution?: boolean): Texture
277
- /**
278
- * Removes the texture
279
- * @param no_update If true, the texture is silently removed. The interface is not updated, no undo point is created
280
- */
281
- remove(no_update?: boolean): void
282
- toggleVisibility(): this
283
- enableParticle(): this
284
- /**
285
- * Enables 'particle' on this texture if it is not enabled on any other texture
286
- */
287
- fillParticle(): this
288
- /**
289
- * Select this as the default texture in supported formats
290
- */
291
- setAsDefaultTexture()
292
- /**
293
- * Applies the texture to the selected elements
294
- * @param all If true, the texture is applied to all faces of the elements. If 'blank', the texture is only applied to blank faces
295
- */
296
- apply(all?: true | false | 'blank'): this
297
- /**
298
- * Shows the texture file in the file explorer
299
- */
300
- openFolder(): this
301
- /**
302
- * Opens the texture in the configured image editor
303
- */
304
- openEditor(): this
305
- showContextMenu(event: MouseEvent): void
306
- openMenu(): void
307
- resizeDialog(): this
308
- /**
309
- * Scroll the texture list to this texture
310
- */
311
- scrollTo(): void
312
- save(as?: any): this
313
- /**
314
- * Returns the content of the texture as PNG as a base64 encoded string
315
- */
316
- getBase64(): string
317
- /**
318
- * Returns the content of the texture as PNG as a base64 encoded data URL
319
- */
320
- getDataURL(): string
321
- /**
322
- * Wrapper to do edits to the texture.
323
- * @param callback
324
- * @param options Editing options
325
- */
326
- edit(
327
- callback?: (instance: HTMLCanvasElement | any) => void | HTMLCanvasElement,
328
- options?: TextureEditOptions
329
- ): void
330
- menu: Menu
331
- /**
332
- * Get the selected layer. If no layer is selected, returns the bottom layer
333
- */
334
- getActiveLayer(): TextureLayer
335
- activateLayers(undo?: boolean): void
336
- /**
337
- * Turns the texture selection into a layer
338
- * @param undo Whether to create an undo entry
339
- * @param clone When true, the selection is copied into the new layer and also left on the original layer
340
- */
341
- selectionToLayer(undo?: boolean, clone?: boolean): void
342
- javaTextureLink(): string
343
-
344
- getMCMetaContent(): {
345
- animation?: {
346
- frametime: number
347
- width?: number
348
- height?: number
349
- interpolate?: boolean
350
- frames?: number[]
351
- }
352
- }
353
- getAnimationFrameIndices(): number[]
354
-
355
- exportEmissionMap(): void
356
-
357
- convertToInternal(data_url?: string): this
358
- /**
359
- * Redraws the texture content from the layers
360
- * @param update_data_url If true, the texture source gets updated as well. This is slower, but is necessary at the end of an edit. During an edit, to preview changes, this can be false
361
- */
362
- updateLayerChanges(update_data_url?: boolean): void
363
- /**
364
- * Update everything after a content edit to the texture or one of the layers. Updates the material, the layers, marks the texture as unsaved, syncs changes to other projects
365
- */
366
- updateChangesAfterEdit(): void
367
- /**
368
- * Update the attached img element with the content from the texture's canvas
369
- */
370
- updateImageFromCanvas(): void
371
- /**
372
- * If layers are enabled, returns the active layer, otherwise returns the texture. Either way, the 'canvas', 'ctx', and 'offset' properties can be used from the returned object
373
- */
374
- getActiveCanvas(): Texture | TextureLayer
375
- /**
376
- * When editing the same texture in different tabs (via Edit In Blockbench option), sync changes that were made to the texture to other projects
377
- */
378
- syncToOtherProject(): this
379
-
380
- getUndoCopy(): Texture
381
- /**
382
- * Return the texture group that the texture is attached to
383
- */
384
- getGroup(): TextureGroup | undefined
385
-
386
- static all: Texture[]
387
- static getDefault(): Texture
388
- static properties: Record<string, Property<any>>
389
- }
390
- /**
391
- * Saves all textures
392
- * @param lazy If true, the texture isn't saved if it doesn't have a local file to save to
393
- */
394
- function saveTextures(lazy?: boolean): Promise<void>
395
- /**
396
- * Update the draggable/sortable functionality of the texture list
397
- */
398
- function loadTextureDraggable(): void
399
- /**
400
- * Unselect all textures
401
- */
402
- function unselectTextures(): void
403
-
404
- /**
405
- * An Int Matrix holds an int (unsigned 8 bit) for each pixel in a matrix, via array. The override property can be used to set an override value for the entire area. This is used for texture selections.
406
- */
407
- class IntMatrix {
408
- constructor(width: number, height: number)
409
- width: number
410
- height: number
411
- array: null | Int8Array
412
- /**
413
- * The override can be set to true to indicate that the whole texture is selected, or false, which indicates that nothing is selected. Null indicates a custom selection
414
- */
415
- override: boolean | null
416
- /**
417
- * True if there is a custom selection
418
- */
419
- readonly is_custom: boolean
420
- /**
421
- * The array does not exist by default to save memory, this activates it.
422
- */
423
- activate(): void
424
- /**
425
- * Get the value at the specified pixel
426
- * @param x X coordinate
427
- * @param y Y coordinate
428
- * @returns The value of the targeted pixel
429
- */
430
- get(x: number, y: number): number | boolean
431
- /**
432
- * Test whether painting is allowed at a specific pixel
433
- * @param x X coordinate
434
- * @param y Y coordinate
435
- * @returns Boolean or value of the pixel
436
- */
437
- allow(x: number, y: number): number | boolean
438
- /**
439
- * Get the value at the specified pixel directly without override and bounds check
440
- * @param x X coordinate
441
- * @param y Y coordinate
442
- * @returns
443
- */
444
- getDirect(x: number, y: number): number
445
- /**
446
- * Return the smallest possible rectangle that contains all of the selection
447
- * @param respect_empty If true, if there is no selection, the bounding box will still cover the entire area
448
- */
449
- getBoundingRect(respect_empty: boolean = false): Rectangle
450
- /**
451
- * Checks whether a selection is present and contains selected pixels
452
- */
453
- hasSelection(): boolean
454
- /**
455
- * Set the value at a specified pixel
456
- * @param {*} x X coordinate
457
- * @param {*} y Y coordinate
458
- * @param {number} value
459
- */
460
- set(x: number, y: number, value: number): void
461
- /**
462
- * If there was a selection, whether override or not, clear it
463
- */
464
- clear(): void
465
- /**
466
- * Change override mode
467
- * @param {true|false|null} value
468
- * @returns
469
- */
470
- setOverride(value: boolean | null): void
471
- /**
472
- * Change the size of the matrix. Unless using overrides, the selection gets lost.
473
- * @param {number} width
474
- * @param {number} height
475
- * @returns {boolean} Whether the size had to be changed
476
- */
477
- changeSize(width: number, height: number): void
478
- /**
479
- * Run a method on each pixel, whether selected or not
480
- * @param callback Function to run per pixel
481
- */
482
- forEachPixel(callback: (x: number, y: number, value: number, index: number) => void): void
483
- /**
484
- * Shift custom selections by a specified offset
485
- * @param offset_x
486
- * @param offset_y
487
- */
488
- translate(offset_x: number, offset_y: number): void
489
- /**
490
- * Return the selection simplified into non-overlapping boxes. Boxes are [x, y, width, height].
491
- */
492
- toBoxes(): [number, number, number, number][]
493
- /**
494
- * Mask the provided canvas using the selection
495
- * @param ctx Canvas 2D context
496
- * @param offset Position offset of the canvas, e. g. when using a layer
497
- */
498
- maskCanvas(ctx: CanvasRenderingContext2D, offset: ArrayVector2): void
499
- }
500
-
501
- /**
502
- * Handles playback of animated textures
503
- */
504
- namespace TextureAnimator {
505
- const isPlaying: boolean
506
- const interval: any
507
- function start(): void
508
- function stop(): void
509
- function toggle(): void
510
- function updateSpeed(): void
511
- function nextFrame(): void
512
- function reset(): void
513
- function updateButton(): void
514
- }
515
- }
1
+ /// <reference types="./blockbench"/>
2
+
3
+ import type { FSWatcher } from 'fs'
4
+ import type { ShaderMaterial } from 'three'
5
+
6
+ interface FileFormatOptions {
7
+ name: string
8
+ extensions: string[],
9
+ async encode?(texture: Texture): Uint8Array
10
+ async decode?(data: Uint8Array, texture: Texture): void
11
+ }
12
+
13
+ declare global {
14
+ interface TextureData {
15
+ path?: string
16
+ uuid?: string
17
+ name?: string
18
+ /**
19
+ * Relative path to the file's directory, used by some formats such as Java Block/Item
20
+ * */
21
+ folder?: string
22
+ namespace?: string
23
+ /**
24
+ * Texture ID or key, used by some formats. By default this is a number that increases with every texture that is added
25
+ * */
26
+ id?: string
27
+ /**
28
+ * Whether the texture is used for the models particle system. Used by some formats such as Java Block/Item
29
+ * */
30
+ particle?: boolean
31
+ visible?: boolean
32
+ render_mode?: 'default' | 'emissive' | 'additive' | 'layered' | string
33
+ render_sides?: 'auto' | 'front' | 'double' | string
34
+ wrap_mode?: 'limited' | 'repeat' | 'clamp'
35
+ pbr_channel?: 'color' | 'normal' | 'height' | 'mer'
36
+ /**
37
+ * UUID of the texture group that the texture is in
38
+ */
39
+ group?: string
40
+ scope?: number
41
+
42
+ /**
43
+ * Texture animation frame time
44
+ * */
45
+ frame_time?: number
46
+ frame_order_type?: 'custom' | 'loop' | 'backwards' | 'back_and_forth'
47
+ /**
48
+ * Custom frame order
49
+ * */
50
+ frame_order?: string
51
+ /**
52
+ * Interpolate between frames
53
+ * */
54
+ frame_interpolate?: boolean
55
+ /**
56
+ * Whether the texture is saved
57
+ */
58
+ saved?: boolean
59
+ /**
60
+ * If true, the texture is loaded internally. If false, the texture is loaded directly from a file
61
+ */
62
+ internal?: boolean
63
+ /**
64
+ * Flag to indicate that the texture was manually resized, and on load it should not try to automatically adjust UV size
65
+ */
66
+ keep_size?: boolean
67
+ source?: string
68
+ width?: number
69
+ height?: number
70
+ standalone?: boolean
71
+ relative_path?: string
72
+ }
73
+ interface TextureEditOptions {
74
+ /**
75
+ * Edit method. 'canvas' is default
76
+ */
77
+ method?: 'canvas' | 'jimp'
78
+ /**
79
+ * Name of the undo entry that is created
80
+ */
81
+ edit_name?: string
82
+ /**
83
+ * Whether to use the cached canvas/jimp instance
84
+ */
85
+ use_cache?: boolean
86
+ /**
87
+ * If true, no undo point is created. Default is false
88
+ */
89
+ no_undo?: boolean
90
+ /**
91
+ * If true, the texture is not updated visually
92
+ */
93
+ no_update?: boolean
94
+ no_undo_init?: boolean
95
+ no_undo_finish?: boolean
96
+ }
97
+
98
+ /**
99
+ * A texture combines the functionality of material, texture, and image, in one. Textures can be linked to files on the local hard drive, or hold the information in RAM.
100
+ */
101
+ class Texture {
102
+ constructor(data?: TextureData, uuid?: string)
103
+ readonly frameCount: number | undefined
104
+ readonly display_height: number
105
+ readonly ratio: number
106
+ static selected?: Texture
107
+
108
+ uuid: UUID
109
+ path?: string
110
+ name: string
111
+ /** Relative path to the file's directory, used by some formats such as Java Block/Item*/
112
+ folder: string
113
+ namespace: string
114
+ /** Texture ID or key, used by some formats. By default this is a number that increases with every texture that is added */
115
+ id: string
116
+ /** Whether the texture is used for the models particle system. Used by some formats such as Java Block/Item */
117
+ particle: boolean
118
+ render_mode: 'default' | 'emissive' | 'additive' | 'layered' | string
119
+ render_sides: 'auto' | 'front' | 'double' | string
120
+ wrap_mode: 'limited' | 'repeat' | 'clamp'
121
+ pbr_channel: 'color' | 'normal' | 'height' | 'mer'
122
+ use_as_default: boolean
123
+ /** UUID of the TextureGroup that this texture is in, if set */
124
+ group: string
125
+ scope: number
126
+
127
+ /** Texture animation frame time */
128
+ frame_time: number
129
+ frame_order_type: 'custom' | 'loop' | 'backwards' | 'back_and_forth'
130
+ /** Custom frame order */
131
+ frame_order: string
132
+ /** Interpolate between frames */
133
+ frame_interpolate: boolean
134
+
135
+ /** HTML-style source of the texture's displayed data. Can be a path (desktop app only), or a base64 data URL */
136
+ source: string
137
+ /**
138
+ * Whether the texture is directly selected
139
+ */
140
+ selected: boolean
141
+ /**
142
+ * Whether the texture is multi selected
143
+ */
144
+ multi_selected: boolean
145
+ selected_layer: TextureLayer | null
146
+ show_icon: boolean
147
+ error: number
148
+ /** Whether the texture is visible. Used for layered textures mode */
149
+ visible: boolean
150
+
151
+ width: number
152
+ height: number
153
+ uv_width: number
154
+ uv_height: number
155
+ currentFrame: number
156
+ saved: boolean
157
+ /**
158
+ * Whether the latest version of the texture is currently loaded from and linked to a file on disk, or held in memory as bitmap data
159
+ * @deprecated Use {@link Texture.internal} instead
160
+ */
161
+ mode: never
162
+ /**
163
+ * If true, the texture is loaded internally. If false, the texture is loaded directly from a file
164
+ */
165
+ internal: boolean
166
+ /**
167
+ * Set a function that will run once the next time the texture is loaded
168
+ */
169
+ load_callback?: null | ((texture: Texture) => void)
170
+ /**
171
+ * Custom texture flags
172
+ */
173
+ flags: Set
174
+
175
+ /**
176
+ * Texture selection in paint mode
177
+ */
178
+ selection: IntMatrix
179
+ layers: TextureLayer[]
180
+ layers_enabled: boolean
181
+ /**
182
+ * The UUID of the project to sync the texture to
183
+ */
184
+ sync_to_project: UUID | ''
185
+
186
+ /**
187
+ * The texture's associated canvas. Since 4.9, this is the main source of truth for textures in internal mode.
188
+ */
189
+ canvas: HTMLCanvasElement
190
+ /**
191
+ * The 2D context of the texture's associated canvas.
192
+ */
193
+ ctx: CanvasRenderingContext2D
194
+ /**
195
+ * Texture image element
196
+ */
197
+ img: HTMLImageElement
198
+ readonly offset: ArrayVector2
199
+
200
+ relative_path?: string
201
+ get material(): THREE.ShaderMaterial
202
+ set material(value: THREE.ShaderMaterial)
203
+
204
+ getErrorMessage(): string
205
+ extend(data: TextureData): this
206
+
207
+ /**
208
+ * Get the UV width of the texture if the format uses per texture UV size, otherwise get the project texture width
209
+ */
210
+ getUVWidth(): number
211
+ /**
212
+ * Get the UV height of the texture if the format uses per texture UV size, otherwise get the project texture height
213
+ */
214
+ getUVHeight(): number
215
+ getUndoCopy(bitmap?: boolean): any
216
+ getSaveCopy(bitmap?: boolean): any
217
+ /**
218
+ * Start listening for changes to the linked file. Desktop only
219
+ */
220
+ startWatcher(): void
221
+ /**
222
+ * Stop listening for changes to the linked file. Desktop only
223
+ */
224
+ stopWatcher(): void
225
+ /**
226
+ * Generate the Java Block/Item folder property from the file path
227
+ */
228
+ generateFolder(): void
229
+ /**
230
+ * Loads the texture from it's current source
231
+ * @param cb Callback function
232
+ */
233
+ load(cb?: () => {}): this
234
+ fromJavaLink(link: string, path_array: string[]): this
235
+ fromFile(file: { name: string; content?: string; path: string } | FileSystem.FileResult): this
236
+ fromPath(path: string): this
237
+ /**
238
+ * Loads file content **only**.
239
+ *
240
+ * Does not read `png.mcmeta`, or attempt to overwrite an existing texture in the project with the same name.
241
+ *
242
+ * Used internally when loading `.bbmodel` files
243
+ * @param path
244
+ */
245
+ loadContentFromPath(path: string): this
246
+ fromDataURL(data_url: string): this
247
+ fromDefaultPack(): true | undefined
248
+ /**
249
+ * Loads the default white error texture
250
+ * @param error_id Sets the error ID of the texture
251
+ */
252
+ loadEmpty(error_id?: number): this
253
+
254
+ updateSource(dataUrl: string): this
255
+ updateMaterial(): this
256
+
257
+ /**
258
+ * Opens a dialog to replace the texture with another file
259
+ * @param force If true, no warning appears of the texture has unsaved changes
260
+ */
261
+ reopen(force: boolean): void
262
+ /**
263
+ * Reloads the texture. Only works in the desktop app
264
+ */
265
+ reloadTexture(): void
266
+ /**
267
+ * Get the material that the texture displays. When previewing PBR, this will return the shared PBR material
268
+ */
269
+ getMaterial(): THREE.ShaderMaterial | THREE.MeshStandardMaterial
270
+ /**
271
+ * Get the texture's own material
272
+ */
273
+ getOwnMaterial(): THREE.ShaderMaterial
274
+ /**
275
+ * Selects the texture
276
+ * @param event Click event during selection
277
+ */
278
+ select(event?: Event): this
279
+ /**
280
+ * Adds texture to the textures list and initializes it
281
+ * @param undo If true, an undo point is created
282
+ */
283
+ add(undo?: boolean, uv_size_from_resolution?: boolean): Texture
284
+ /**
285
+ * Removes the texture
286
+ * @param no_update If true, the texture is silently removed. The interface is not updated, no undo point is created
287
+ */
288
+ remove(no_update?: boolean): void
289
+ toggleVisibility(): this
290
+ enableParticle(): this
291
+ /**
292
+ * Enables 'particle' on this texture if it is not enabled on any other texture
293
+ */
294
+ fillParticle(): this
295
+ /**
296
+ * Select this as the default texture in supported formats
297
+ */
298
+ setAsDefaultTexture()
299
+ /**
300
+ * Applies the texture to the selected elements
301
+ * @param all If true, the texture is applied to all faces of the elements. If 'blank', the texture is only applied to blank faces
302
+ */
303
+ apply(all?: true | false | 'blank'): this
304
+ /**
305
+ * Shows the texture file in the file explorer
306
+ */
307
+ openFolder(): this
308
+ /**
309
+ * Opens the texture in the configured image editor
310
+ */
311
+ openEditor(): this
312
+ showContextMenu(event: MouseEvent): void
313
+ openMenu(): void
314
+ resizeDialog(): this
315
+ /**
316
+ * Scroll the texture list to this texture
317
+ */
318
+ scrollTo(): void
319
+ save(as?: any): this
320
+ /**
321
+ * Returns the content of the texture as PNG as a base64 encoded string
322
+ */
323
+ getBase64(): string
324
+ /**
325
+ * Returns the content of the texture as PNG as a base64 encoded data URL
326
+ */
327
+ getDataURL(): string
328
+ /**
329
+ * Wrapper to do edits to the texture.
330
+ * @param callback
331
+ * @param options Editing options
332
+ */
333
+ edit(
334
+ callback?: (instance: HTMLCanvasElement | any) => void | HTMLCanvasElement,
335
+ options?: TextureEditOptions
336
+ ): void
337
+ menu: Menu
338
+ /**
339
+ * Get the selected layer. If no layer is selected, returns the bottom layer
340
+ */
341
+ getActiveLayer(): TextureLayer
342
+ activateLayers(undo?: boolean): void
343
+ /**
344
+ * Turns the texture selection into a layer
345
+ * @param undo Whether to create an undo entry
346
+ * @param clone When true, the selection is copied into the new layer and also left on the original layer
347
+ */
348
+ selectionToLayer(undo?: boolean, clone?: boolean): void
349
+ javaTextureLink(): string
350
+
351
+ getMCMetaContent(): {
352
+ animation?: {
353
+ frametime: number
354
+ width?: number
355
+ height?: number
356
+ interpolate?: boolean
357
+ frames?: number[]
358
+ }
359
+ }
360
+ getAnimationFrameIndices(): number[]
361
+
362
+ exportEmissionMap(): void
363
+
364
+ convertToInternal(data_url?: string): this
365
+ /**
366
+ * Redraws the texture content from the layers
367
+ * @param update_data_url If true, the texture source gets updated as well. This is slower, but is necessary at the end of an edit. During an edit, to preview changes, this can be false
368
+ */
369
+ updateLayerChanges(update_data_url?: boolean): void
370
+ /**
371
+ * Update everything after a content edit to the texture or one of the layers. Updates the material, the layers, marks the texture as unsaved, syncs changes to other projects
372
+ */
373
+ updateChangesAfterEdit(): void
374
+ /**
375
+ * Update the attached img element with the content from the texture's canvas
376
+ */
377
+ updateImageFromCanvas(): void
378
+ /**
379
+ * If layers are enabled, returns the active layer, otherwise returns the texture. Either way, the 'canvas', 'ctx', and 'offset' properties can be used from the returned object
380
+ */
381
+ getActiveCanvas(): Texture | TextureLayer
382
+ /**
383
+ * When editing the same texture in different tabs (via Edit In Blockbench option), sync changes that were made to the texture to other projects
384
+ */
385
+ syncToOtherProject(): this
386
+
387
+ getUndoCopy(): Texture
388
+ /**
389
+ * Return the texture group that the texture is attached to
390
+ */
391
+ getGroup(): TextureGroup | undefined
392
+
393
+ static all: Texture[]
394
+ static getDefault(): Texture
395
+ static properties: Record<string, Property<any>>
396
+
397
+ static file_formats: Record<string, FileFormatOptions>
398
+ }
399
+ /**
400
+ * Saves all textures
401
+ * @param lazy If true, the texture isn't saved if it doesn't have a local file to save to
402
+ */
403
+ function saveTextures(lazy?: boolean): Promise<void>
404
+ /**
405
+ * Update the draggable/sortable functionality of the texture list
406
+ */
407
+ function loadTextureDraggable(): void
408
+ /**
409
+ * Unselect all textures
410
+ */
411
+ function unselectTextures(): void
412
+
413
+ /**
414
+ * An Int Matrix holds an int (unsigned 8 bit) for each pixel in a matrix, via array. The override property can be used to set an override value for the entire area. This is used for texture selections.
415
+ */
416
+ class IntMatrix {
417
+ constructor(width: number, height: number)
418
+ width: number
419
+ height: number
420
+ array: null | Int8Array
421
+ /**
422
+ * The override can be set to true to indicate that the whole texture is selected, or false, which indicates that nothing is selected. Null indicates a custom selection
423
+ */
424
+ override: boolean | null
425
+ /**
426
+ * True if there is a custom selection
427
+ */
428
+ readonly is_custom: boolean
429
+ /**
430
+ * The array does not exist by default to save memory, this activates it.
431
+ */
432
+ activate(): void
433
+ /**
434
+ * Get the value at the specified pixel
435
+ * @param x X coordinate
436
+ * @param y Y coordinate
437
+ * @returns The value of the targeted pixel
438
+ */
439
+ get(x: number, y: number): number | boolean
440
+ /**
441
+ * Test whether painting is allowed at a specific pixel
442
+ * @param x X coordinate
443
+ * @param y Y coordinate
444
+ * @returns Boolean or value of the pixel
445
+ */
446
+ allow(x: number, y: number): number | boolean
447
+ /**
448
+ * Get the value at the specified pixel directly without override and bounds check
449
+ * @param x X coordinate
450
+ * @param y Y coordinate
451
+ * @returns
452
+ */
453
+ getDirect(x: number, y: number): number
454
+ /**
455
+ * Return the smallest possible rectangle that contains all of the selection
456
+ * @param respect_empty If true, if there is no selection, the bounding box will still cover the entire area
457
+ */
458
+ getBoundingRect(respect_empty: boolean = false): Rectangle
459
+ /**
460
+ * Checks whether a selection is present and contains selected pixels
461
+ */
462
+ hasSelection(): boolean
463
+ /**
464
+ * Set the value at a specified pixel
465
+ * @param {*} x X coordinate
466
+ * @param {*} y Y coordinate
467
+ * @param {number} value
468
+ */
469
+ set(x: number, y: number, value: number): void
470
+ /**
471
+ * If there was a selection, whether override or not, clear it
472
+ */
473
+ clear(): void
474
+ /**
475
+ * Change override mode
476
+ * @param {true|false|null} value
477
+ * @returns
478
+ */
479
+ setOverride(value: boolean | null): void
480
+ /**
481
+ * Change the size of the matrix. Unless using overrides, the selection gets lost.
482
+ * @param {number} width
483
+ * @param {number} height
484
+ * @returns {boolean} Whether the size had to be changed
485
+ */
486
+ changeSize(width: number, height: number): void
487
+ /**
488
+ * Run a method on each pixel, whether selected or not
489
+ * @param callback Function to run per pixel
490
+ */
491
+ forEachPixel(callback: (x: number, y: number, value: number, index: number) => void): void
492
+ /**
493
+ * Shift custom selections by a specified offset
494
+ * @param offset_x
495
+ * @param offset_y
496
+ */
497
+ translate(offset_x: number, offset_y: number): void
498
+ /**
499
+ * Return the selection simplified into non-overlapping boxes. Boxes are [x, y, width, height].
500
+ */
501
+ toBoxes(): [number, number, number, number][]
502
+ /**
503
+ * Mask the provided canvas using the selection
504
+ * @param ctx Canvas 2D context
505
+ * @param offset Position offset of the canvas, e. g. when using a layer
506
+ */
507
+ maskCanvas(ctx: CanvasRenderingContext2D, offset: ArrayVector2): void
508
+ }
509
+
510
+ /**
511
+ * Handles playback of animated textures
512
+ */
513
+ namespace TextureAnimator {
514
+ const isPlaying: boolean
515
+ const interval: any
516
+ function start(): void
517
+ function stop(): void
518
+ function toggle(): void
519
+ function updateSpeed(): void
520
+ function nextFrame(): void
521
+ function reset(): void
522
+ function updateButton(): void
523
+ }
524
+ }