blockbench-types 4.6.1 → 4.9.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/package.json +2 -1
- package/scripts/generate_docs.js +9 -7
- package/types/action.d.ts +42 -2
- package/types/animation.d.ts +37 -17
- package/types/animation_controller.d.ts +8 -2
- package/types/blockbench.d.ts +45 -5
- package/types/canvas.d.ts +13 -0
- package/types/canvas_frame.d.ts +21 -0
- package/types/codec.d.ts +31 -0
- package/types/cube.d.ts +4 -1
- package/types/dialog.d.ts +23 -1
- package/types/display_mode.d.ts +7 -0
- package/types/format.d.ts +2 -0
- package/types/global.d.ts +28 -0
- package/types/group.d.ts +2 -0
- package/types/io.d.ts +2 -0
- package/types/keyframe.d.ts +29 -4
- package/types/math_util.d.ts +1 -0
- package/types/menu.d.ts +5 -2
- package/types/mesh.d.ts +6 -1
- package/types/misc.d.ts +25 -4
- package/types/mode.d.ts +1 -0
- package/types/outliner.d.ts +13 -0
- package/types/painter.d.ts +3 -1
- package/types/panel.d.ts +19 -4
- package/types/plugin.d.ts +5 -1
- package/types/preview.d.ts +4 -1
- package/types/project.d.ts +16 -2
- package/types/screencam.d.ts +3 -0
- package/types/settings.d.ts +53 -5
- package/types/shared_actions.d.ts +78 -0
- package/types/texture_layers.d.ts +118 -0
- package/types/textures.d.ts +246 -1
- package/types/timeline.d.ts +2 -2
- package/types/undo.d.ts +5 -5
- package/types/util.d.ts +32 -0
- package/types/validator.d.ts +35 -0
package/types/textures.d.ts
CHANGED
|
@@ -38,14 +38,109 @@ interface TextureEditOptions {
|
|
|
38
38
|
no_undo_finish?: boolean
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* 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.
|
|
43
|
+
*/
|
|
41
44
|
declare class Texture {
|
|
42
45
|
constructor(data: TextureData, uuid?: string);
|
|
43
46
|
readonly frameCount: number | undefined;
|
|
44
47
|
readonly display_height: number;
|
|
45
48
|
readonly ratio: number;
|
|
46
49
|
|
|
50
|
+
path: string
|
|
51
|
+
name: string
|
|
52
|
+
/** Relative path to the file's directory, used by some formats such as Java Block/Item*/
|
|
53
|
+
folder: string
|
|
54
|
+
namespace: string
|
|
55
|
+
/** Texture ID or key, used by some formats. By default this is a number that increases with every texture that is added */
|
|
56
|
+
id: string
|
|
57
|
+
/** Whether the texture is used for the models particle system. Used by some formats such as Java Block/Item */
|
|
58
|
+
particle: boolean
|
|
59
|
+
render_mode: 'default' | 'emissive' | 'additive' | 'layered' | string
|
|
60
|
+
render_sides: 'auto' | 'front' | 'double' | string
|
|
61
|
+
|
|
62
|
+
/** Texture animation frame time */
|
|
63
|
+
frame_time: number
|
|
64
|
+
frame_order_type: 'custom' | 'loop' | 'backwards' | 'back_and_forth'
|
|
65
|
+
/** Custom frame order */
|
|
66
|
+
frame_order: string
|
|
67
|
+
/** Interpolate between frames */
|
|
68
|
+
frame_interpolate: boolean
|
|
69
|
+
|
|
70
|
+
/** HTML-style source of the texture's displayed data. Can be a path (desktop app only), or a base64 data URL */
|
|
71
|
+
source: string
|
|
72
|
+
selected: boolean
|
|
73
|
+
show_icon: boolean
|
|
74
|
+
error: number
|
|
75
|
+
/** Whether the texture is visible. Used for layered textures mode */
|
|
76
|
+
visible: boolean
|
|
77
|
+
|
|
78
|
+
width: number
|
|
79
|
+
height: number
|
|
80
|
+
uv_width: number
|
|
81
|
+
uv_height: number
|
|
82
|
+
currentFrame: number
|
|
83
|
+
saved: boolean
|
|
84
|
+
/**
|
|
85
|
+
* 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
|
|
86
|
+
* @deprecated Use texture.internal instead
|
|
87
|
+
*/
|
|
88
|
+
mode: 'link' | 'bitmap'
|
|
89
|
+
/**
|
|
90
|
+
* If true, the texture is loaded internally. If false, the texture is loaded directly from a file
|
|
91
|
+
*/
|
|
92
|
+
internal: boolean
|
|
93
|
+
uuid: UUID
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Texture selection in paint mode
|
|
97
|
+
*/
|
|
98
|
+
selection: IntMatrix
|
|
99
|
+
layers: TextureLayer[]
|
|
100
|
+
layers_enabled: boolean
|
|
101
|
+
/**
|
|
102
|
+
* The UUID of the project to sync the texture to
|
|
103
|
+
*/
|
|
104
|
+
sync_to_project: UUID | ''
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The texture's associated canvas. Since 4.9, this is the main source of truth for textures in internal mode.
|
|
108
|
+
*/
|
|
109
|
+
canvas: HTMLCanvasElement
|
|
110
|
+
/**
|
|
111
|
+
* The 2D context of the texture's associated canvas.
|
|
112
|
+
*/
|
|
113
|
+
ctx: CanvasRenderingContext2D
|
|
114
|
+
/**
|
|
115
|
+
* Texture image element
|
|
116
|
+
*/
|
|
117
|
+
img: HTMLImageElement
|
|
118
|
+
|
|
47
119
|
getErrorMessage(): string;
|
|
48
120
|
extend(data: TextureData): this;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Get the UV width of the texture if the format uses per texture UV size, otherwise get the project texture width
|
|
124
|
+
*/
|
|
125
|
+
getUVWidth(): number
|
|
126
|
+
/**
|
|
127
|
+
* Get the UV height of the texture if the format uses per texture UV size, otherwise get the project texture height
|
|
128
|
+
*/
|
|
129
|
+
getUVHeight(): number
|
|
130
|
+
getUndoCopy(bitmap?: boolean): object
|
|
131
|
+
getSaveCopy(bitmap?: boolean): object
|
|
132
|
+
/**
|
|
133
|
+
* Start listening for changes to the linked file. Desktop only
|
|
134
|
+
*/
|
|
135
|
+
startWatcher()
|
|
136
|
+
/**
|
|
137
|
+
* Stop listening for changes to the linked file. Desktop only
|
|
138
|
+
*/
|
|
139
|
+
stopWatcher()
|
|
140
|
+
/**
|
|
141
|
+
* Generate the Java Block/Item folder property from the file path
|
|
142
|
+
*/
|
|
143
|
+
generateFolder()
|
|
49
144
|
/**
|
|
50
145
|
* Loads the texture from it's current source
|
|
51
146
|
* @param cb Callback function
|
|
@@ -114,9 +209,13 @@ declare class Texture {
|
|
|
114
209
|
scrollTo(): void;
|
|
115
210
|
save(as: any): this;
|
|
116
211
|
/**
|
|
117
|
-
* Returns the content of the texture as a base64 encoded string
|
|
212
|
+
* Returns the content of the texture as PNG as a base64 encoded string
|
|
118
213
|
*/
|
|
119
214
|
getBase64(): string;
|
|
215
|
+
/**
|
|
216
|
+
* Returns the content of the texture as PNG as a base64 encoded data URL
|
|
217
|
+
*/
|
|
218
|
+
getDataURL(): string;
|
|
120
219
|
/**
|
|
121
220
|
* Wrapper to do edits to the texture.
|
|
122
221
|
* @param callback
|
|
@@ -124,6 +223,54 @@ declare class Texture {
|
|
|
124
223
|
*/
|
|
125
224
|
edit(callback: (instance: HTMLCanvasElement | object) => void | HTMLCanvasElement, options: TextureEditOptions): void;
|
|
126
225
|
menu: Menu
|
|
226
|
+
/**
|
|
227
|
+
* Get the selected layer. If no layer is selected, returns the bottom layer
|
|
228
|
+
*/
|
|
229
|
+
getActiveLayer(): TextureLayer
|
|
230
|
+
activateLayers(undo?: boolean): void
|
|
231
|
+
/**
|
|
232
|
+
* Turns the texture selection into a layer
|
|
233
|
+
* @param undo Whether to create an undo entry
|
|
234
|
+
* @param clone When true, the selection is copied into the new layer and also left on the original layer
|
|
235
|
+
*/
|
|
236
|
+
selectionToLayer(undo?: boolean, clone?: boolean): void
|
|
237
|
+
javaTextureLink(): string
|
|
238
|
+
|
|
239
|
+
getMCMetaContent(): {
|
|
240
|
+
animation?: {
|
|
241
|
+
frametime: number
|
|
242
|
+
width?: number
|
|
243
|
+
height?: number
|
|
244
|
+
interpolate?: boolean
|
|
245
|
+
frames?: number[]
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
getAnimationFrameIndices(): number[]
|
|
249
|
+
|
|
250
|
+
exportEmissionMap(): void
|
|
251
|
+
|
|
252
|
+
convertToInternal(data_url?: string): this
|
|
253
|
+
/**
|
|
254
|
+
* Redraws the texture content from the layers
|
|
255
|
+
* @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
|
|
256
|
+
*/
|
|
257
|
+
updateLayerChanges(update_data_url?: boolean): void
|
|
258
|
+
/**
|
|
259
|
+
* 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
|
|
260
|
+
*/
|
|
261
|
+
updateChangesAfterEdit(): void
|
|
262
|
+
/**
|
|
263
|
+
* Update the attached img element with the content from the texture's canvas
|
|
264
|
+
*/
|
|
265
|
+
updateImageFromCanvas(): void
|
|
266
|
+
/**
|
|
267
|
+
* 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
|
|
268
|
+
*/
|
|
269
|
+
getActiveCanvas(): Texture | TextureLayer
|
|
270
|
+
/**
|
|
271
|
+
* When editing the same texture in different tabs (via Edit In Blockbench option), sync changes that were made to the texture to other projects
|
|
272
|
+
*/
|
|
273
|
+
syncToOtherProject(): this
|
|
127
274
|
|
|
128
275
|
static all: Texture[]
|
|
129
276
|
static getDefault(): Texture
|
|
@@ -142,6 +289,104 @@ declare function loadTextureDraggable(): void;
|
|
|
142
289
|
*/
|
|
143
290
|
declare function unselectTextures(): void;
|
|
144
291
|
|
|
292
|
+
/**
|
|
293
|
+
* 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.
|
|
294
|
+
*/
|
|
295
|
+
declare class IntMatrix {
|
|
296
|
+
constructor(width: number, height: number)
|
|
297
|
+
width: number
|
|
298
|
+
height: number
|
|
299
|
+
array: null | Int8Array
|
|
300
|
+
/**
|
|
301
|
+
* 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
|
|
302
|
+
*/
|
|
303
|
+
override: boolean | null
|
|
304
|
+
/**
|
|
305
|
+
* True if there is a custom selection
|
|
306
|
+
*/
|
|
307
|
+
readonly is_custom: boolean
|
|
308
|
+
/**
|
|
309
|
+
* The array does not exist by default to save memory, this activates it.
|
|
310
|
+
*/
|
|
311
|
+
activate(): void
|
|
312
|
+
/**
|
|
313
|
+
* Get the value at the specified pixel
|
|
314
|
+
* @param {*} x X coordinate
|
|
315
|
+
* @param {*} y Y coordinate
|
|
316
|
+
* @returns The value of the targeted pixel
|
|
317
|
+
*/
|
|
318
|
+
get(x, y): number | boolean
|
|
319
|
+
/**
|
|
320
|
+
* Test whether painting is allowed at a specific pixel
|
|
321
|
+
* @param {*} x X coordinate
|
|
322
|
+
* @param {*} y Y coordinate
|
|
323
|
+
* @returns Boolean or value of the pixel
|
|
324
|
+
*/
|
|
325
|
+
allow(x, y): number | boolean
|
|
326
|
+
/**
|
|
327
|
+
* Get the value at the specified pixel directly without override and bounds check
|
|
328
|
+
* @param {*} x X coordinate
|
|
329
|
+
* @param {*} y Y coordinate
|
|
330
|
+
* @returns
|
|
331
|
+
*/
|
|
332
|
+
getDirect(x: number, y: number): number
|
|
333
|
+
/**
|
|
334
|
+
* Return the smallest possible rectangle that contains all of the selection
|
|
335
|
+
* @param respect_empty If true, if there is no selection, the bounding box will still cover the entire area
|
|
336
|
+
*/
|
|
337
|
+
getBoundingRect(respect_empty): Rectangle
|
|
338
|
+
/**
|
|
339
|
+
* Checks whether a selection is present and contains selected pixels
|
|
340
|
+
*/
|
|
341
|
+
hasSelection(): boolean
|
|
342
|
+
/**
|
|
343
|
+
* Set the value at a specified pixel
|
|
344
|
+
* @param {*} x X coordinate
|
|
345
|
+
* @param {*} y Y coordinate
|
|
346
|
+
* @param {number} value
|
|
347
|
+
*/
|
|
348
|
+
set(x: number, y: number, value: number)
|
|
349
|
+
/**
|
|
350
|
+
* If there was a selection, whether override or not, clear it
|
|
351
|
+
*/
|
|
352
|
+
clear(): void
|
|
353
|
+
/**
|
|
354
|
+
* Change override mode
|
|
355
|
+
* @param {true|false|null} value
|
|
356
|
+
* @returns
|
|
357
|
+
*/
|
|
358
|
+
setOverride(value: boolean | null): void
|
|
359
|
+
/**
|
|
360
|
+
* Change the size of the matrix. Unless using overrides, the selection gets lost.
|
|
361
|
+
* @param {number} width
|
|
362
|
+
* @param {number} height
|
|
363
|
+
* @returns {boolean} Whether the size had to be changed
|
|
364
|
+
*/
|
|
365
|
+
changeSize(width: number, height: number): void
|
|
366
|
+
/**
|
|
367
|
+
* Run a method on each pixel, whether selected or not
|
|
368
|
+
* @param callback Function to run per pixel
|
|
369
|
+
*/
|
|
370
|
+
forEachPixel(callback: ((x: number, y: number, value: number, index: number) => void))
|
|
371
|
+
/**
|
|
372
|
+
* Shift custom selections by a specified offset
|
|
373
|
+
* @param offset_x
|
|
374
|
+
* @param offset_y
|
|
375
|
+
*/
|
|
376
|
+
translate(offset_x: number, offset_y: number): void
|
|
377
|
+
/**
|
|
378
|
+
* Return the selection simplified into non-overlapping boxes. Boxes are [x, y, width, height].
|
|
379
|
+
*/
|
|
380
|
+
toBoxes(): [number, number, number, number][]
|
|
381
|
+
/**
|
|
382
|
+
* Mask the provided canvas using the selection
|
|
383
|
+
* @param ctx Canvas 2D context
|
|
384
|
+
* @param offset Position offset of the canvas, e. g. when using a layer
|
|
385
|
+
*/
|
|
386
|
+
maskCanvas(ctx: CanvasRenderingContext2D, offset: ArrayVector2): void
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
|
|
145
390
|
/**
|
|
146
391
|
* Handles playback of animated textures
|
|
147
392
|
*/
|
package/types/timeline.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
declare namespace Timeline {
|
|
2
2
|
const animators: GeneralAnimator[]
|
|
3
|
-
const selected:
|
|
3
|
+
const selected: _Keyframe[]
|
|
4
4
|
const playing_sounds: any[]
|
|
5
5
|
let playback_speed: number
|
|
6
6
|
/**
|
|
@@ -58,7 +58,7 @@ declare namespace Timeline {
|
|
|
58
58
|
*/
|
|
59
59
|
function pause(): void
|
|
60
60
|
|
|
61
|
-
let keyframes:
|
|
61
|
+
let keyframes: _Keyframe[]
|
|
62
62
|
let menu: Menu
|
|
63
63
|
function showMenu(event: Event): void
|
|
64
64
|
|
package/types/undo.d.ts
CHANGED
|
@@ -20,9 +20,9 @@ interface UndoAspects {
|
|
|
20
20
|
selected_texture?: boolean
|
|
21
21
|
settings?: {}
|
|
22
22
|
uv_mode?: boolean
|
|
23
|
-
animations?:
|
|
23
|
+
animations?: _Animation[]
|
|
24
24
|
animation_controllers?: AnimationController[]
|
|
25
|
-
keyframes?:
|
|
25
|
+
keyframes?: _Keyframe[]
|
|
26
26
|
display_slots?: string[]
|
|
27
27
|
exploded_view?: boolean
|
|
28
28
|
}
|
|
@@ -55,11 +55,11 @@ type UndoEntry = {
|
|
|
55
55
|
}
|
|
56
56
|
interface AmendEditForm {
|
|
57
57
|
condition?: ConditionResolvable
|
|
58
|
-
type?: 'number'
|
|
58
|
+
type?: 'number' | 'checkbox'
|
|
59
59
|
label: string
|
|
60
60
|
interval_type: 'position' | 'rotation'
|
|
61
61
|
getInterval?: (Event) => number
|
|
62
|
-
value?: number | string,
|
|
62
|
+
value?: number | string | 'boolean',
|
|
63
63
|
min?: number,
|
|
64
64
|
max?: number,
|
|
65
65
|
step?: number,
|
|
@@ -85,7 +85,7 @@ declare class UndoSystem {
|
|
|
85
85
|
* Add keyframes to the current edit that were indirectly removed by moving other keyframes to their position
|
|
86
86
|
* @param keyframes
|
|
87
87
|
*/
|
|
88
|
-
addKeyframeCasualties(keyframes:
|
|
88
|
+
addKeyframeCasualties(keyframes: _Keyframe[]): void;
|
|
89
89
|
/**
|
|
90
90
|
* Undoes the latest edit
|
|
91
91
|
*/
|
package/types/util.d.ts
CHANGED
|
@@ -54,6 +54,9 @@ declare function getAxisLetter(axisNumber: number): string
|
|
|
54
54
|
declare function getAxisNumber(axisLetter: string): number
|
|
55
55
|
|
|
56
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Reusable data types that can be used by anything, but should not be used to store data between function calls. Can be used to save memory on frequent function calls.
|
|
59
|
+
*/
|
|
57
60
|
declare namespace Reusable {
|
|
58
61
|
const vec1: THREE.Vector3
|
|
59
62
|
const vec2: THREE.Vector3
|
|
@@ -68,3 +71,32 @@ declare namespace Reusable {
|
|
|
68
71
|
const euler1: THREE.Euler
|
|
69
72
|
const euler2: THREE.Euler
|
|
70
73
|
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Merge the value under a certain key from one object into another
|
|
77
|
+
*/
|
|
78
|
+
declare namespace Merge {
|
|
79
|
+
function number(target: object, source: object, key: string|number): void
|
|
80
|
+
function string(target: object, source: object, key: string|number, validate?: ((value) => boolean)): void
|
|
81
|
+
function molang(target: object, source: object, key: string|number): void
|
|
82
|
+
function boolean(target: object, source: object, key: string|number, validate?: ((value) => boolean)): void
|
|
83
|
+
function arrayVector(target: object, source: object, key: string|number, validate?: ((value) => boolean)): void
|
|
84
|
+
function arrayVector2(target: object, source: object, key: string|number, validate?: ((value) => boolean)): void
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
declare class Rectangle {
|
|
88
|
+
constructor(start_x: number, start_y: number, width: number, height: number)
|
|
89
|
+
start_x: number
|
|
90
|
+
start_y: number
|
|
91
|
+
width: number
|
|
92
|
+
height: number
|
|
93
|
+
readonly start: ArrayVector2
|
|
94
|
+
readonly w: number
|
|
95
|
+
readonly h: number
|
|
96
|
+
end_x: number
|
|
97
|
+
end_y: number
|
|
98
|
+
readonly area: number
|
|
99
|
+
fromCoords(x1: number, y1: number, x2: number, y2: number): void
|
|
100
|
+
fromUnorderedCoords(x1: number, y1: number, x2: number, y2: number): void
|
|
101
|
+
expandTo(x: number, y: number): void
|
|
102
|
+
}
|
package/types/validator.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The validator in Blockbench provides feedback about the model and can detect issues in real time, based on a list of checks that can be added. This is a good way to ensure model files are valid, and to teach users about best practices.
|
|
3
|
+
*/
|
|
1
4
|
declare namespace Validator {
|
|
2
5
|
const checks: ValidatorCheck[]
|
|
3
6
|
|
|
@@ -42,6 +45,38 @@ interface WarningOrError {
|
|
|
42
45
|
click(): void
|
|
43
46
|
}[]
|
|
44
47
|
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* A check for the validator. A check can be triggered by certain things, and updates the list of warnings and errors that can be displayed in the status bar.
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
### Example:
|
|
54
|
+
|
|
55
|
+
```javascript
|
|
56
|
+
new ValidatorCheck('special_cube_name_rule', {
|
|
57
|
+
update_triggers: ['update_selection'],
|
|
58
|
+
run() {
|
|
59
|
+
Cube.all.forEach(cube => {
|
|
60
|
+
if (cube.name == 'sphere') {
|
|
61
|
+
this.warn({
|
|
62
|
+
message: `The cube "${cube.name}" has an invalid names. Cubes may not be called "sphere".`,
|
|
63
|
+
buttons: [
|
|
64
|
+
{
|
|
65
|
+
name: 'Select Cube',
|
|
66
|
+
icon: 'fa-cube',
|
|
67
|
+
click() {
|
|
68
|
+
Validator.dialog.hide();
|
|
69
|
+
cube.select();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
```
|
|
79
|
+
*/
|
|
45
80
|
declare class ValidatorCheck extends Deletable {
|
|
46
81
|
constructor(id: string, options: ValidatorCheckOptions)
|
|
47
82
|
|