blockbench-types 4.8.0 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blockbench-types",
3
- "version": "4.8.0",
3
+ "version": "4.9.0",
4
4
  "description": "Blockbench typescript types",
5
5
  "main": "",
6
6
  "types": "types/blockbench.d.ts",
@@ -16,6 +16,7 @@ async function main() {
16
16
  entryPoints: [
17
17
  "./types/blockbench.d.ts",
18
18
  "./types/textures.d.ts",
19
+ "./types/texture_layers.d.ts",
19
20
  "./types/action.d.ts",
20
21
  "./types/animation.d.ts",
21
22
  "./types/animation_controller.d.ts",
@@ -43,6 +44,7 @@ async function main() {
43
44
  "./types/painter.d.ts",
44
45
  "./types/screencam.d.ts",
45
46
  "./types/validator.d.ts",
47
+ "./types/shared_actions.d.ts",
46
48
  "./types/display_mode.d.ts",
47
49
  "./types/misc.d.ts",
48
50
  "./types/util.d.ts"
@@ -5,6 +5,7 @@ declare class AnimationItem {
5
5
 
6
6
  interface AnimationOptions {
7
7
  name?: string
8
+ path?: string
8
9
  loop?: 'once' | 'hold' | 'loop'
9
10
  override?: boolean
10
11
  anim_time_update?: string
@@ -34,7 +35,7 @@ declare class _Animation extends AnimationItem {
34
35
  save(): this | undefined;
35
36
  select(): this | undefined;
36
37
  setLength(length: number): void;
37
- createUniqueName(references: Animation[]): any;
38
+ createUniqueName(references: _Animation[]): any;
38
39
  rename(): this;
39
40
  togglePlayingState(state: any): any;
40
41
  showContextMenu(event: any): this;
@@ -46,7 +47,7 @@ declare class _Animation extends AnimationItem {
46
47
  * Adds the animation to the current project and to the interface
47
48
  * @param undo If true, the addition of the animation will be registered as an edit
48
49
  */
49
- add(undo: any): this;
50
+ add(undo?: any): this;
50
51
  remove(undo: any, remove_from_file?: boolean): this;
51
52
  getMaxLength(): number;
52
53
  setLoop(value: any, undo: any): void;
@@ -86,6 +87,7 @@ declare class _Animation extends AnimationItem {
86
87
  declare namespace Animator {
87
88
  const open: boolean
88
89
  const MolangParser: object
90
+ const possible_channels: unknown[];
89
91
  const motion_trail: THREE.Object3D
90
92
  const motion_trail_lock: boolean
91
93
  const particle_effects: object
@@ -114,13 +116,14 @@ interface AddChannelOptions {
114
116
  max_data_points?: number
115
117
  }
116
118
  declare class GeneralAnimator {
117
- constructor(uuid: string, animation: Animation)
118
- keyframes: Keyframe[]
119
+ constructor(uuid: string, animation: _Animation, name: string)
120
+ uuid: string
121
+ keyframes: _Keyframe[]
119
122
  select(): this
120
123
  addToTimeline(): this
121
- addKeyframe(data: KeyframeOptions, uuid: string): Keyframe
122
- createKeyframe(): Keyframe
123
- getOrMakeKeyframe(): {before: Keyframe, result: Keyframe}
124
+ addKeyframe(data: KeyframeOptions, uuid?: string): _Keyframe
125
+ createKeyframe(): _Keyframe
126
+ getOrMakeKeyframe(): {before: _Keyframe, result: _Keyframe}
124
127
  toggleMuted(channel: string): this
125
128
  scrollTo(): this
126
129
 
@@ -130,9 +133,9 @@ declare class GeneralAnimator {
130
133
  declare class BoneAnimator extends GeneralAnimator {
131
134
  name: string
132
135
  uuid: string
133
- rotations: Keyframe[]
134
- position: Keyframe[]
135
- scale: Keyframe[]
136
+ rotations: _Keyframe[]
137
+ position: _Keyframe[]
138
+ scale: _Keyframe[]
136
139
  getGroup(): Group
137
140
  fillValues(): void
138
141
  pushKeyframe(): void
@@ -146,9 +149,9 @@ declare class BoneAnimator extends GeneralAnimator {
146
149
  declare class NullObjectAnimator extends GeneralAnimator {
147
150
  name: string
148
151
  uuid: string
149
- rotations: Keyframe[]
150
- position: Keyframe[]
151
- scale: Keyframe[]
152
+ rotations: _Keyframe[]
153
+ position: _Keyframe[]
154
+ scale: _Keyframe[]
152
155
  getElement(): NullObject
153
156
  doRender(): void
154
157
  displayPosition(): void
@@ -156,11 +159,12 @@ declare class NullObjectAnimator extends GeneralAnimator {
156
159
  displayFrame(): void
157
160
  }
158
161
  declare class EffectAnimator extends GeneralAnimator {
162
+ constructor(animation: _Animation)
159
163
  name: string
160
164
  uuid: string
161
- particle: Keyframe[]
162
- sound: Keyframe[]
163
- timeline: Keyframe[]
165
+ particle: _Keyframe[]
166
+ sound: _Keyframe[]
167
+ timeline: _Keyframe[]
164
168
  pushKeyframe(keyframe): this
165
169
  displayFrame(in_loop): this
166
170
  startPreviousSounds(): void
@@ -63,7 +63,7 @@ declare class AnimationControllerState {
63
63
  remove(undo?: boolean): void
64
64
  createUniqueName(): void
65
65
 
66
- addAnimation(animation?: Animation): void
66
+ addAnimation(animation?: _Animation): void
67
67
  addTransition(target_uuid?: string): void
68
68
  addParticle(options?: {effect: string}): void
69
69
  addSound(options?: {effect: string, file: string}): void
@@ -5,6 +5,7 @@
5
5
  /// <reference types="wintersky" />
6
6
 
7
7
  /// <reference types="./textures" />
8
+ /// <reference types="./texture_layers" />
8
9
  /// <reference types="./action" />
9
10
  /// <reference types="./animation" />
10
11
  /// <reference types="./animation_controller" />
@@ -32,10 +33,13 @@
32
33
  /// <reference types="./painter" />
33
34
  /// <reference types="./screencam" />
34
35
  /// <reference types="./validator" />
36
+ /// <reference types="./shared_actions" />
35
37
  /// <reference types="./display_mode" />
36
38
  /// <reference types="./misc" />
37
39
  /// <reference types="./util" />
40
+ /// <reference types="./math_util" />
38
41
  /// <reference types="./canvas_frame" />
42
+ /// <reference types="./io" />
39
43
 
40
44
 
41
45
 
@@ -190,6 +194,12 @@ declare namespace Blockbench {
190
194
  export function showStatusMessage(message: string, time?: number): void
191
195
 
192
196
  export function setStatusBarText(text?: string): void
197
+
198
+ /**
199
+ * Display a tooltip displaying a custom text that appears next to and follows the mouse cursor
200
+ * @param text The text to display. Line breaks are supported. Leave empty to hide the tooltip.
201
+ */
202
+ export function setCursorTooltip(text?: string): void
193
203
  /**
194
204
  * Set the value of a progress bar
195
205
  *
@@ -248,7 +258,7 @@ declare namespace Blockbench {
248
258
  /**
249
259
  * Removes an event listener
250
260
  */
251
- export function removeListener(event_names: EventName): void
261
+ export function removeListener(event_names: EventName, callback: (data: object) => void): void
252
262
 
253
263
 
254
264
 
package/types/dialog.d.ts CHANGED
@@ -8,9 +8,22 @@ interface DialogFormElement {
8
8
  readonly?: boolean
9
9
  /** Add buttons to allow copying and sharing the text or link */
10
10
  share_text?: boolean
11
+ /**
12
+ * The default value
13
+ */
11
14
  value?: any
15
+ /**
16
+ * The default selected option for 'select', 'inline_select' and 'radio' types. Alias for 'value'
17
+ */
18
+ default?: any
12
19
  placeholder?: string
20
+ /**
21
+ * When using 'text' type, the text to display. Markdown is supported
22
+ */
13
23
  text?: string
24
+ /**
25
+ * When using 'range' type, allow users to modify the numeric input
26
+ */
14
27
  editable_range_label?: boolean
15
28
  colorpicker?: any
16
29
  min?: number
@@ -19,6 +32,14 @@ interface DialogFormElement {
19
32
  height?: number
20
33
  options?: object
21
34
  buttons?: string[]
35
+ /**
36
+ * Allow users to toggle the entire option on or off
37
+ */
38
+ toggle_enabled?: boolean
39
+ /**
40
+ * Set whether the setting is toggled on or off by default. Requires 'toggle_enabled' field to be set to true
41
+ */
42
+ toggle_default?: boolean
22
43
  click?: (button_index: number) => void
23
44
  }
24
45
 
@@ -97,6 +118,7 @@ interface DialogOptions {
97
118
  * Unless set to false, clicking on the darkened area outside of the dialog will cancel the dialog.
98
119
  */
99
120
  cancel_on_click_outside?: boolean
121
+ width?: number
100
122
  }
101
123
 
102
124
  declare class Dialog {
@@ -1,3 +1,7 @@
1
+ declare const DisplayMode: {
2
+ slots: string[]
3
+ }
4
+
1
5
  interface DisplaySlotOptions {
2
6
  rotation?: ArrayVector3
3
7
  translation?: ArrayVector3
package/types/io.d.ts ADDED
@@ -0,0 +1,2 @@
1
+
2
+ declare function autoParseJSON(data: string, feedback?: boolean);
@@ -13,14 +13,14 @@ interface KeyframeOptions {
13
13
  channel?: string
14
14
  data_points: {}[]
15
15
  time: number
16
- color: number
17
- uniform: boolean
18
- interpolation: 'linear' | 'catmullrom' | 'bezier' | 'step' | string
19
- bezier_linked: boolean
20
- bezier_left_time: ArrayVector3
21
- bezier_left_value: ArrayVector3
22
- bezier_right_time: ArrayVector3
23
- bezier_right_value: ArrayVector3
16
+ color?: number
17
+ uniform?: boolean
18
+ interpolation?: 'linear' | 'catmullrom' | 'bezier' | 'step' | string
19
+ bezier_linked?: boolean
20
+ bezier_left_time?: ArrayVector3
21
+ bezier_left_value?: ArrayVector3
22
+ bezier_right_time?: ArrayVector3
23
+ bezier_right_value?: ArrayVector3
24
24
  }
25
25
  type axisLetter = 'x' | 'y' | 'z'
26
26
 
@@ -65,4 +65,6 @@ declare class _Keyframe {
65
65
  channel?: string | null;
66
66
  data_points: object[];
67
67
  };
68
- }
68
+ }
69
+
70
+ declare function updateKeyframeSelection(): void;
@@ -0,0 +1 @@
1
+ declare function guid(): string;
package/types/misc.d.ts CHANGED
@@ -100,7 +100,7 @@ interface MessageBoxOptions {
100
100
  * Display a list of actions to do in the dialog. When clicked, the message box closes with the string ID of the command as first argument.
101
101
  */
102
102
  commands?: {
103
- [id: string]: string | {text: string}
103
+ [id: string]: string | {text: string, icon?: IconString, condition?: ConditionResolvable}
104
104
  }
105
105
  /**
106
106
  * Adds checkboxes to the bottom of the message box
package/types/mode.d.ts CHANGED
@@ -31,4 +31,5 @@ declare namespace Modes {
31
31
  const options: {
32
32
  [id: string]: Mode
33
33
  }
34
+ const selected: Mode;
34
35
  }
package/types/plugin.d.ts CHANGED
@@ -29,7 +29,7 @@ interface PluginOptions {
29
29
  /**
30
30
  * Set to true if the plugin must finish loading before a project is opened, i. e. because it adds a format
31
31
  */
32
- await_loading?: string
32
+ await_loading?: boolean
33
33
  /**
34
34
  * Use the new repository format where plugin, iron, and about are stored in a separate folder
35
35
  */
@@ -20,7 +20,7 @@ type RaycastResult = {
20
20
  intersects?: object[]
21
21
  face?: string
22
22
  vertex: any
23
- keyframe: Keyframe
23
+ keyframe: _Keyframe
24
24
  }
25
25
 
26
26
  /**
@@ -15,6 +15,7 @@ declare class ModelProject {
15
15
  uuid: UUID
16
16
  selected: boolean
17
17
  model_identifier: string
18
+ parent: string
18
19
  /**
19
20
  * When set to true, the project tab can no longer be selected or unselected
20
21
  */
@@ -56,7 +57,7 @@ declare class ModelProject {
56
57
  textures: Texture[]
57
58
  selected_texture: Texture | null;
58
59
  outliner: OutlinerNode[]
59
- animations: Animation[]
60
+ animations: _Animation[]
60
61
  timeline_animators: []
61
62
  display_settings: {
62
63
  [slot: string]: {
@@ -64,8 +65,12 @@ declare class ModelProject {
64
65
  rotation: [number, number, number]
65
66
  scale: [number, number, number]
66
67
  mirror: [boolean, boolean, boolean]
68
+ export(): void;
67
69
  }
68
70
  };
71
+ ambientocclusion: boolean;
72
+ front_gui_light: boolean;
73
+ overrides: any;
69
74
 
70
75
  get model_3d(): THREE.Object3D;
71
76
  get materials(): {
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Shared Actions is a system in Blockbench to allow actions (including in toolbars, menus, via action control, or keybinding) to run different code in different cases, such as in different modes or different panels.
3
+ * As an example, the "Duplicate" action runs code to duplicate elements when used in the outliner, and duplicates textures when used in the textures panel.
4
+ *
5
+ *
6
+ * Handlers can be added for existing actions like this:
7
+
8
+ ### Example:
9
+
10
+ ```javascript
11
+ // Duplicate layers when using "Duplicate" in the layers panel
12
+ SharedActions.add('duplicate', {
13
+ subject: 'layer',
14
+ condition: () => Prop.active_panel == 'layers' && TextureLayer.selected,
15
+ run() {
16
+ let texture = Texture.selected;
17
+ let original = texture.getActiveLayer();
18
+ let copy = original.getUndoCopy(true);
19
+ copy.name += '-copy';
20
+ Undo.initEdit({textures: [texture]});
21
+ let layer = new TextureLayer(copy, texture);
22
+ layer.addForEditing();
23
+ Undo.finishEdit('Duplicate layer');
24
+ }
25
+ })
26
+ ```
27
+ *
28
+ */
29
+ declare namespace SharedActions {
30
+ const checks: {
31
+ [id: SharedActionID]: SharedActionHandler
32
+ }
33
+
34
+ /**
35
+ * Add a new handler to a shared action
36
+ * @param action_id Action ID
37
+ * @param handler Handler options
38
+ */
39
+ function add(action_id: SharedActionID, handler: SharedActionHandler): Deletable
40
+ /**
41
+ * Run the active handler for a specific subject manually
42
+ * @param action_id Action ID
43
+ * @param event Event that triggered the interaction
44
+ * @param context Optional context variable
45
+ */
46
+ function run(action_id: SharedActionID, event?: Event, context?: any): boolean
47
+ /**
48
+ * Run a specific handler manually
49
+ * @param action_id Action ID
50
+ * @param subject Subject to run on
51
+ * @param event Event that triggered the interaction
52
+ * @param context Optional context variable
53
+ * @param force Force the specified handler to run and ignore its condition
54
+ */
55
+ function runSpecific(action_id: SharedActionID, subject: string, event?: Event, context?: any, force?: boolean): boolean
56
+ /**
57
+ * Check if there is an active and available handler in the current situation for a shared action
58
+ * @param action_id
59
+ */
60
+ function condition(action_id: SharedActionID): boolean
61
+ /**
62
+ * Find the active handler in the current situation for a shared action
63
+ * @param action_id
64
+ * @param event
65
+ * @param context
66
+ */
67
+ function find(action_id: SharedActionID, event?: Event, context?: any): SharedActionHandler | null
68
+ }
69
+
70
+ interface SharedActionHandler {
71
+ priority: number
72
+ subject: string
73
+ condition: ConditionResolvable
74
+ run: (event?: Event, context?: any) => void
75
+ }
76
+
77
+ type SharedActionID = string | 'rename' | 'delete' | 'duplicate' | 'select_all' | 'unselect_all' | 'invert_selection'
78
+
@@ -0,0 +1,118 @@
1
+ /// <reference types="three" />
2
+
3
+ interface TextureLayerData {
4
+ name?: string
5
+ in_limbo?: boolean
6
+ offset?: ArrayVector2
7
+ scale?: ArrayVector2
8
+ opacity?: number
9
+ visible?: boolean
10
+ blend_mode?: 'default' | 'set_opacity' | 'color' | 'multiply' | 'add' | 'screen' | 'difference'
11
+ image_data?: ImageData
12
+ data_url?: string
13
+ }
14
+
15
+ /**
16
+ * Texture layers always belong to a texture and represent the layers of the texture. Each layer has its own HTML canvas and canvas context
17
+ */
18
+ declare class TextureLayer {
19
+ constructor(data: TextureLayerData, texture: Texture, uuid?: string);
20
+
21
+ name: string
22
+ uuid: UUID
23
+ texture: Texture
24
+ canvas: HTMLCanvasElement
25
+ ctx: CanvasRenderingContext2D
26
+ in_limbo: boolean
27
+ img: HTMLImageElement
28
+ /**
29
+ * Layer offset from the top left corner of the texture to the top left corner of the layer
30
+ */
31
+ offset: ArrayVector2
32
+ /**
33
+ * Layer scale. This is only used by the layer transform tool and should be applied and reset to 1x1 before doing further changes
34
+ */
35
+ scale: ArrayVector2
36
+ opacity: number
37
+ visible: boolean
38
+ blend_mode: 'default' | 'set_opacity' | 'color' | 'multiply' | 'add' | 'screen' | 'difference'
39
+
40
+ extend(data: TextureLayerData): void
41
+ /**
42
+ * Selects the layer
43
+ */
44
+ select(): void
45
+ showContextMenu(event: Event): void
46
+ /**
47
+ * Remove the layer
48
+ * @param undo Create an undo point and update the texture
49
+ */
50
+ remove(undo: boolean): void
51
+ getUndoCopy(image_data: boolean): object
52
+ getSaveCopy(): object
53
+ /**
54
+ * Set the layer into a limbo state, where clicking Place or clicking next to the layer will place it on the layer below
55
+ */
56
+ setLimbo(): void
57
+ /**
58
+ * Resolves the limbo state by turning the limbo layer into a full layer, or merging it into the layer below
59
+ * @param keep_separate If true, the layer is kept as a separate layer
60
+ */
61
+ resolveLimbo(keep_separate): void
62
+ /**
63
+ * Set the layer size. This resizes the canvas, which discards the layer content
64
+ */
65
+ setSize(width: number, height: number): void
66
+ /**
67
+ * Toggle layer visibility. This creates an undo point
68
+ */
69
+ toggleVisibility(): void
70
+ /**
71
+ * Scroll the layer panel list to
72
+ */
73
+ scrollTo(): void
74
+ /**
75
+ * Add the layer to the associated texture above the previously selected layer, select this layer, and scroll the layer panel list to it
76
+ */
77
+ addForEditing(): void
78
+ /**
79
+ * Merge this texture onto the texture below
80
+ * @param undo Create an undo entry
81
+ */
82
+ mergeDown(undo: boolean): void
83
+ /**
84
+ * Expand the layer to include the listed pixels
85
+ * @param points
86
+ */
87
+ expandTo(...points: ArrayVector2): void
88
+ /**
89
+ * Flip the texture along an axis
90
+ * @param axis Flip axis, where 0 is X and 1 is Y
91
+ * @param undo Create an undo entry
92
+ */
93
+ flip(axis: number, undo): void
94
+ /**
95
+ * Rotate the layer around itself in 90 degree steps
96
+ * @param angle Angle in degrees
97
+ * @param undo Create an undo entry
98
+ */
99
+ rotate(angle: number, undo: boolean): void
100
+ /**
101
+ * Centers the layer on the texture
102
+ */
103
+ center(): void
104
+ /**
105
+ * Open the properties dialog
106
+ */
107
+ propertiesDialog(): void
108
+
109
+
110
+ /**
111
+ * Get all layers of the active texture
112
+ */
113
+ static all: TextureLayer[]
114
+ /**
115
+ * Get the selected layer
116
+ */
117
+ static selected: TextureLayer
118
+ }
@@ -74,20 +74,43 @@ declare class Texture {
74
74
  error: number
75
75
  /** Whether the texture is visible. Used for layered textures mode */
76
76
  visible: boolean
77
- /** Whether the texture canvas is displayed in the UV/2D editor, for live feedback */
78
- display_canvas: boolean
77
+
79
78
  width: number
80
79
  height: number
80
+ uv_width: number
81
+ uv_height: number
81
82
  currentFrame: number
82
83
  saved: boolean
83
- /** 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 */
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
+ */
84
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
85
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 | ''
86
105
 
87
106
  /**
88
- * The texture's associated canvas. Note: This may not always be up to date with the texture data
107
+ * The texture's associated canvas. Since 4.9, this is the main source of truth for textures in internal mode.
89
108
  */
90
109
  canvas: HTMLCanvasElement
110
+ /**
111
+ * The 2D context of the texture's associated canvas.
112
+ */
113
+ ctx: CanvasRenderingContext2D
91
114
  /**
92
115
  * Texture image element
93
116
  */
@@ -95,6 +118,29 @@ declare class Texture {
95
118
 
96
119
  getErrorMessage(): string;
97
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()
98
144
  /**
99
145
  * Loads the texture from it's current source
100
146
  * @param cb Callback function
@@ -163,9 +209,13 @@ declare class Texture {
163
209
  scrollTo(): void;
164
210
  save(as: any): this;
165
211
  /**
166
- * 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
167
213
  */
168
214
  getBase64(): string;
215
+ /**
216
+ * Returns the content of the texture as PNG as a base64 encoded data URL
217
+ */
218
+ getDataURL(): string;
169
219
  /**
170
220
  * Wrapper to do edits to the texture.
171
221
  * @param callback
@@ -173,6 +223,54 @@ declare class Texture {
173
223
  */
174
224
  edit(callback: (instance: HTMLCanvasElement | object) => void | HTMLCanvasElement, options: TextureEditOptions): void;
175
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
176
274
 
177
275
  static all: Texture[]
178
276
  static getDefault(): Texture
@@ -191,6 +289,104 @@ declare function loadTextureDraggable(): void;
191
289
  */
192
290
  declare function unselectTextures(): void;
193
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
+
194
390
  /**
195
391
  * Handles playback of animated textures
196
392
  */
@@ -1,6 +1,6 @@
1
1
  declare namespace Timeline {
2
2
  const animators: GeneralAnimator[]
3
- const selected: Keyframe[]
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: Keyframe[]
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?: Animation[]
23
+ animations?: _Animation[]
24
24
  animation_controllers?: AnimationController[]
25
- keyframes?: Keyframe[]
25
+ keyframes?: _Keyframe[]
26
26
  display_slots?: string[]
27
27
  exploded_view?: boolean
28
28
  }
@@ -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: Keyframe[]): void;
88
+ addKeyframeCasualties(keyframes: _Keyframe[]): void;
89
89
  /**
90
90
  * Undoes the latest edit
91
91
  */
package/types/util.d.ts CHANGED
@@ -83,3 +83,20 @@ declare namespace Merge {
83
83
  function arrayVector(target: object, source: object, key: string|number, validate?: ((value) => boolean)): void
84
84
  function arrayVector2(target: object, source: object, key: string|number, validate?: ((value) => boolean)): void
85
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
+ }