blockbench-types 4.11.1 → 4.12.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.11.1",
3
+ "version": "4.12.0",
4
4
  "description": "Blockbench typescript types",
5
5
  "main": "",
6
6
  "types": "types/index.d.ts",
@@ -30,7 +30,7 @@
30
30
  "@types/three": "^0.129.2",
31
31
  "@types/tinycolor2": "^1.4.6",
32
32
  "dompurify": "^3.0.1",
33
- "electron": "^31.4.0",
33
+ "electron": "^33.3.1",
34
34
  "prismjs": "^1.29.0",
35
35
  "tinycolor2": "^1.6.0",
36
36
  "typescript": "^4.9.5",
@@ -25,6 +25,7 @@ async function main() {
25
25
  './types/blockbench.d.ts',
26
26
  './types/textures.d.ts',
27
27
  './types/texture_layers.d.ts',
28
+ './types/texture_group.d.ts',
28
29
  './types/action.d.ts',
29
30
  './types/animation.d.ts',
30
31
  './types/animation_controller.d.ts',
@@ -39,6 +40,7 @@ async function main() {
39
40
  './types/legacy.d.ts',
40
41
  './types/menu.d.ts',
41
42
  './types/outliner.d.ts',
43
+ './types/collection.d.ts',
42
44
  './types/group.d.ts',
43
45
  './types/cube.d.ts',
44
46
  './types/mesh.d.ts',
package/types/action.d.ts CHANGED
@@ -11,31 +11,114 @@ declare interface KeybindKeys {
11
11
  * Main key, can be a numeric keycode or a lower case character
12
12
  */
13
13
  key: number | string
14
- ctrl?: boolean | null
15
- shift?: boolean | null
16
- alt?: boolean | null
17
- meta?: boolean | null
14
+ ctrl?: boolean
15
+ shift?: boolean
16
+ alt?: boolean
17
+ meta?: boolean
18
18
  }
19
+ type VariationModifier = 'always' | 'ctrl' | 'shift' | 'alt' | 'meta' | 'unless_ctrl' | 'unless_shift' | 'unless_alt'
20
+ type ModifierKey = 'ctrl' | 'shift' | 'alt' | 'meta'
19
21
  /**
20
22
  * A customizable keybind
21
23
  */
22
24
  declare class Keybind {
23
- constructor(keys: KeybindKeys)
25
+ /**
26
+ * Create a keybind
27
+ * @param {object} keys Set up the default keys that need to be pressed
28
+ * @param {number|string} keys.key Main key. Check keycode.info to find out the numeric value, or simply use letters for letter keys
29
+ * @param {boolean} keys.ctrl Control key. On MacOS this automatically works for Cmd
30
+ * @param {boolean} keys.shift Shift key
31
+ * @param {boolean} keys.alt Alt key
32
+ * @param {boolean} keys.meta Meta key
33
+ */
34
+ constructor(keys: KeybindKeys, variations?: Record<string, VariationModifier>)
24
35
  key: number
25
36
  ctrl?: boolean
26
37
  shift?: boolean
27
38
  alt?: boolean
39
+ variations?: {
40
+ [key: string]: {name: string, description?: string}
41
+ }
42
+ set(keys: KeybindKeys): this;
43
+ /**
44
+ * Unassign the assigned key
45
+ */
46
+ clear(): this;
47
+ /**
48
+ * Save any changes to local storage
49
+ * @param save Save all keybinding changes to local storage. Set to fales if updating multiple at once
50
+ */
51
+ save(save?: false): this;
52
+ /**
53
+ * Assign an action to the keybind
54
+ * @param id ID of the action
55
+ * @param sub_id sub keybind ID
56
+ */
57
+ setAction(id: string, sub_id?: string): this | undefined;
58
+ /**
59
+ * Get display text showing the keybind
60
+ * @param formatted If true, the return string will include HTML formatting
61
+ */
62
+ getText(formatted?: boolean): string;
28
63
  /**
29
64
  * Get the name of the bound key
30
65
  */
31
- getCode(): string
66
+ getCode(key: string): string
67
+ /**
68
+ * Check if a key is assigned
69
+ */
70
+ hasKey(): boolean;
71
+ /**
72
+ * Test if the keybind would be triggered by the event
73
+ */
74
+ isTriggered(event: Event): boolean;
75
+ /**
76
+ * Test which variation would be triggered by the event. Returns the ID of the variation if triggered
77
+ * @param event The event to test
78
+ */
79
+ additionalModifierTriggered(event: Event): string | undefined;
80
+ /**
81
+ * Test if a variation would be triggered by the event
82
+ * @param event The event to test
83
+ * @param variation The variation to test againts
84
+ */
85
+ additionalModifierTriggered(event: Event, variation: string): boolean;
86
+ /**
87
+ * Open a UI to let the user record a new key combination
88
+ */
89
+ record(): this;
90
+ /**
91
+ * Stop recording a new key combination
92
+ */
93
+ stopRecording(): this;
94
+ /**
95
+ * Returns the label of the keybinding
96
+ */
97
+ toString(): string;
98
+
99
+ /**
100
+ * Load an included keymap by ID
101
+ * @param id
102
+ * @param from_start_screen
103
+ */
104
+ static loadKeymap(id: string, from_start_screen?: boolean): void | true
105
+ /**
106
+ * Check if two KeybindItems are mutually exclusive, so only one can be available at the time. This is only the case if they each have a ConditionResolvable that is structured to support this
107
+ */
108
+ static no_overlap(k1: KeybindItem, k2: KeybindItem): boolean
32
109
  }
33
110
  interface KeybindItemOptions {
34
111
  keybind?: Keybind
112
+ variations?: {
113
+ [key: string]: {name: string, description?: string}
114
+ }
35
115
  }
36
116
  declare class KeybindItem extends Deletable {
37
117
  constructor(id: string, options: KeybindItemOptions)
38
118
  keybind: Keybind
119
+ variations?: {
120
+ [key: string]: {name: string, description?: string}
121
+ }
39
122
  }
40
123
 
41
124
  declare class MenuSeparator {
@@ -142,6 +225,14 @@ interface ActionOptions extends BarItemOptions {
142
225
  * Show the full label in toolbars
143
226
  */
144
227
  label?: boolean
228
+ /**
229
+ * Provide a menu that belongs to the action, and gets displayed as a small arrow next to it in toolbars.
230
+ */
231
+ side_menu?: Menu
232
+ /**
233
+ * Provide a window with additional configutation related to the action
234
+ */
235
+ tool_config?: ToolConfig
145
236
  }
146
237
  /**
147
238
  * Actions can be triggered to run something, they can be added to menus, toolbars, assigned a keybinding, or run via Action Control
@@ -152,7 +243,11 @@ declare class Action extends BarItem {
152
243
  /**
153
244
  * Provide a menu that belongs to the action, and gets displayed as a small arrow next to it in toolbars.
154
245
  */
155
- side_menu?: Menu
246
+ side_menu?: Menu | ToolConfig
247
+ /**
248
+ * Provide a window with additional configutation related to the action
249
+ */
250
+ tool_config?: ToolConfig
156
251
  click: ActionOptions['click']
157
252
 
158
253
  condition?(): boolean
@@ -5,6 +5,7 @@
5
5
  /// <reference types="wintersky" />
6
6
 
7
7
  /// <reference types="./texture_layers" />
8
+ /// <reference types="./texture_group" />
8
9
  /// <reference types="./action" />
9
10
  /// <reference types="./animation" />
10
11
  /// <reference types="./animation_controller" />
@@ -29,6 +30,7 @@
29
30
  /// <reference types="./mode" />
30
31
  /// <reference types="./molang" />
31
32
  /// <reference types="./outliner" />
33
+ /// <reference types="./collection" />
32
34
  /// <reference types="./painter" />
33
35
  /// <reference types="./panel" />
34
36
  /// <reference types="./plugin" />
@@ -392,6 +394,7 @@ type BlockbenchTypeFace = typeof Face
392
394
  type BlockbenchTypeCubeFace = typeof CubeFace
393
395
  type BlockbenchTypeMeshFace = typeof MeshFace
394
396
  type BlockbenchTypeNodePreviewController = typeof NodePreviewController
397
+ type BlockbenchTypeCollection = typeof Collection
395
398
  type BlockbenchTypeAnimator = typeof Animator
396
399
  type BlockbenchTypeTimeline = typeof Timeline
397
400
  type BlockbenchTypeAnimationItem = typeof AnimationItem
@@ -452,6 +455,7 @@ declare namespace Blockbench {
452
455
  const CubeFace: BlockbenchTypeCubeFace
453
456
  const MeshFace: BlockbenchTypeMeshFace
454
457
  const NodePreviewController: BlockbenchTypeNodePreviewController
458
+ const Collection: BlockbenchTypeCollection
455
459
  const Animator: BlockbenchTypeAnimator
456
460
  const Timeline: BlockbenchTypeTimeline
457
461
  const AnimationItem: BlockbenchTypeAnimationItem
package/types/codec.d.ts CHANGED
@@ -14,6 +14,8 @@ interface CodecOptions {
14
14
  overwrite?(content: any, path: string, callback: (path: any) => void): void
15
15
  afterDownload?(path: any): void
16
16
  afterSave?(path: any): void
17
+ exportCollection?(collection: Collection): void
18
+ writeCollection?(collection: Collection): void
17
19
 
18
20
  dispatchEvent?(event_name: string, data: any): void
19
21
 
@@ -31,7 +33,7 @@ interface CodecOptions {
31
33
  * List of export option inputs, based on the Dialog form API
32
34
  */
33
35
  export_options?: {
34
- [key: string]: DialogFormElement
36
+ [key: string]: FormElement
35
37
  }
36
38
  /**
37
39
  * Default action that is used to export to the codec
@@ -89,6 +91,8 @@ declare class Codec extends Deletable {
89
91
  overwrite(content: any, path: string, callback: (path: string) => void): void
90
92
  afterDownload(path: string): void
91
93
  afterSave(path: string): void
94
+ exportCollection(collection: Collection): void
95
+ writeCollection(collection: Collection): void
92
96
 
93
97
  /**
94
98
  * Return the stored export option values of the current project
@@ -140,7 +144,7 @@ declare class Codec extends Deletable {
140
144
  * List of export option inputs
141
145
  */
142
146
  export_options: {
143
- [key: string]: DialogFormElement
147
+ [key: string]: FormElement
144
148
  }
145
149
 
146
150
  format: ModelFormat
@@ -0,0 +1,76 @@
1
+ interface CollectionOptions {
2
+ children?: string[]
3
+ name?: string
4
+ export_codec?: string
5
+ export_path?: string
6
+ visibility?: boolean
7
+ }
8
+
9
+ /**
10
+ * Collections are "selection presets" for a set of groups and elements in your project, independent from outliner hierarchy
11
+ */
12
+ declare class Collection {
13
+ constructor(data?: CollectionOptions, uuid?: string);
14
+
15
+ selected: boolean
16
+ /**
17
+ * List of direct children, referenced by UUIDs
18
+ */
19
+ children: string[]
20
+ name: string
21
+ export_codec: string
22
+ export_path: string
23
+ visibility: boolean
24
+
25
+ extend(data: CollectionOptions): this;
26
+ select(event?: Event): this;
27
+ clickSelect(event: Event): void;
28
+ /**
29
+ * Get all direct children
30
+ */
31
+ getChildren(): OutlinerNode[];
32
+ add(): this;
33
+ /**
34
+ * Adds the current outliner selection to this collection
35
+ */
36
+ addSelection(): this;
37
+ /**
38
+ * Returns the visibility of the first contained node that supports visibility. Otherwise returns true.
39
+ */
40
+ getVisibility(): boolean;
41
+ /**
42
+ * Get all children, including indirect ones
43
+ */
44
+ getAllChildren(): any[];
45
+ /**
46
+ * Toggle visibility of everything in the collection
47
+ * @param event If the alt key is pressed, the result is inverted and the visibility of everything but the collection will be toggled
48
+ */
49
+ toggleVisibility(event: Event): void;
50
+ /**
51
+ * Opens the context menu
52
+ */
53
+ showContextMenu(event: Event): this;
54
+ getUndoCopy(): {
55
+ uuid: string;
56
+ index: number;
57
+ [key: string]: any;
58
+ };
59
+ getSaveCopy(): {
60
+ uuid: string;
61
+ [key: string]: any;
62
+ };
63
+ /**
64
+ * Opens the properties dialog
65
+ */
66
+ propertiesDialog(): void;
67
+
68
+ /**
69
+ * Get all collections
70
+ */
71
+ static all(): Collection[]
72
+ /**
73
+ * Get selected collections
74
+ */
75
+ static selected(): Collection[]
76
+ }
package/types/dialog.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- interface DialogFormElement {
1
+ interface FormElement {
2
2
  label?: string
3
3
  /**
4
4
  * Detailed description of the field, available behind the questionmark icon or on mouse hover
@@ -17,7 +17,10 @@ interface DialogFormElement {
17
17
  | 'file'
18
18
  | 'folder'
19
19
  | 'save'
20
+ | 'inline_select'
21
+ | 'inline_multi_select'
20
22
  | 'info'
23
+ | 'num_slider'
21
24
  | 'buttons'
22
25
  /**
23
26
  * If true, the label will be displayed without colon at the end
@@ -73,7 +76,20 @@ interface DialogFormElement {
73
76
  * Available options on select or inline_select inputs
74
77
  */
75
78
  options?: { [key: string]: string | { name: string } }
79
+ /**
80
+ * List of buttons for the button type
81
+ */
76
82
  buttons?: string[]
83
+
84
+ /**
85
+ * Function to get the interval value for a num_slider based on the input event
86
+ * @returns Interval value
87
+ */
88
+ getInterval?: (event: Event) => number
89
+ /**
90
+ * For num_sliders, the sliding interval mode
91
+ */
92
+ interval_type?: 'position' | 'rotation'
77
93
  /**
78
94
  * Allow users to toggle the entire option on or off
79
95
  */
@@ -91,6 +107,44 @@ interface DialogFormElement {
91
107
 
92
108
  type FormResultValue = string | number | boolean | []
93
109
 
110
+ type InputFormConfig = {
111
+ [formElement: string]: '_' | FormElement
112
+ }
113
+
114
+ declare class InputForm {
115
+ constructor(form_config: InputFormConfig)
116
+ form_config: InputFormConfig
117
+ form_data: {[formElement: string]: {}}
118
+ node: HTMLDivElement
119
+ max_label_width: number
120
+ uses_wide_inputs: boolean
121
+ /**
122
+ * Set the values of some or all form inputs
123
+ * @param values The values to set
124
+ * @param update Set to false to prevent triggering an update
125
+ */
126
+ setValues(values: Record<string, FormResultValue>, update?: boolean): void
127
+ /**
128
+ * Set the values of some or all form input toggles
129
+ * @param values The toggle values to set
130
+ * @param update Set to false to prevent triggering an update
131
+ */
132
+ setToggles(values: Record<string, boolean>, update?: boolean): void
133
+ /**
134
+ * Get the form result values
135
+ */
136
+ getResult(): Record<string, FormResultValue>
137
+ /**
138
+ * Register that the values have been changed. This should generally only be used internally
139
+ * @param initial Indicate that the change is for the initial setup of the form, prevents dispatching a change event
140
+ */
141
+ updateValues(initial: boolean): Record<string, FormResultValue>
142
+ /**
143
+ * Returns the default value of a given form input
144
+ */
145
+ static getDefaultValue(input_config: FormElement): FormResultValue
146
+ }
147
+
94
148
  interface ActionInterface {
95
149
  name: string
96
150
  description?: string
@@ -150,9 +204,7 @@ interface DialogOptions {
150
204
  /**
151
205
  * Creates a form in the dialog
152
206
  */
153
- form?: {
154
- [formElement: string]: '_' | DialogFormElement
155
- }
207
+ form?: InputFormConfig
156
208
  /**
157
209
  * Vue component
158
210
  */
@@ -234,6 +286,7 @@ declare class Dialog {
234
286
  component: Vue.Component
235
287
  sidebar: DialogSidebar | null
236
288
  content_vue: Vue | null
289
+ form: InputForm | null
237
290
  progress_bar?: {
238
291
  /**
239
292
  * The current progress
@@ -386,6 +439,30 @@ declare class ShapelessDialog extends Dialog {
386
439
  delete(): void
387
440
  }
388
441
 
442
+ interface ToolConfigOptions extends DialogOptions {}
443
+
444
+ declare class ToolConfig extends Dialog {
445
+ constructor(id: string, options: ToolConfigOptions)
446
+
447
+ options: {
448
+ [key: string]: FormResultValue
449
+ }
450
+ /**
451
+ * Change and save a number of options in the config
452
+ * @param options Options to set
453
+ */
454
+ changeOptions(options: Record<string, FormResultValue>): void
455
+ /**
456
+ * Save any changes in local storage
457
+ */
458
+ save(): void
459
+ /**
460
+ * Open the config menu
461
+ * @param anchor Optional element to anchor the menu to
462
+ */
463
+ show(anchor?: HTMLElement): this
464
+ }
465
+
389
466
  interface DialogSidebarOptions {
390
467
  pages?: {
391
468
  [key: string]: string | { label: string; icon: IconString; color?: string }
package/types/format.d.ts CHANGED
@@ -61,110 +61,196 @@ interface FormatOptions {
61
61
  onSetup?(project: ModelProject, newModel?: boolean): void
62
62
  convertTo?(): void
63
63
 
64
- box_uv?: boolean
65
- optional_box_uv?: boolean
66
- single_texture?: boolean
67
- single_texture_default?: boolean
68
- per_group_texture?: boolean
69
- per_texture_uv_size?: boolean
70
- model_identifier?: boolean
71
- legacy_editable_file_name?: boolean
72
- parent_model_id?: boolean
73
- vertex_color_ambient_occlusion?: boolean
74
- animated_textures?: boolean
75
- bone_rig?: boolean
76
- centered_grid?: boolean
77
- rotate_cubes?: boolean
78
- stretch_cubes?: boolean
79
- integer_size?: boolean
80
- meshes?: boolean
81
- texture_meshes?: boolean
82
- locators?: boolean
83
- rotation_limit?: boolean
84
- rotation_snap?: boolean
85
- uv_rotation?: boolean
86
- java_face_properties?: boolean
87
- select_texture_for_particles?: boolean
88
- texture_mcmeta?: boolean
89
- bone_binding_expression?: boolean
90
- animation_files?: boolean
91
- texture_folder?: boolean
92
- image_editor?: boolean
93
- edit_mode?: boolean
94
- paint_mode?: boolean
95
- display_mode?: boolean
96
- animation_mode?: boolean
97
- pose_mode?: boolean
98
- animation_controllers?: boolean
99
- box_uv_float_size?: boolean
100
- java_cube_shading_properties?: boolean
101
- cullfaces?: boolean
102
- render_sides?: 'front' | 'double' | 'back' | (() => ('front' | 'double' | 'back'))
103
-
104
- cube_size_limiter?: CubeSizeLimiter
105
-
106
- codec?: Codec
107
- onActivation?(): void
108
- onDeactivation?(): void
109
- }
110
-
111
- declare class ModelFormat extends Deletable {
112
- constructor(id: string, options: FormatOptions)
113
- constructor(options: FormatOptions)
114
-
115
- id: string
116
- icon: string
117
- name: string
118
- description: string
119
- category: string
120
- target: string | string[]
121
- confidential: boolean
122
- condition?: ConditionResolvable
123
- show_on_start_screen: boolean
124
- format_page?: FormatPage
125
- onFormatPage?(): void
126
- onStart?(): void
127
- onSetup?(): void
128
-
64
+ /**
65
+ * Enables Box UV on cubes by default
66
+ */
129
67
  box_uv: boolean
68
+ /**
69
+ * If true, box UV is optional and can be toggled on the project or per cube
70
+ */
130
71
  optional_box_uv: boolean
72
+ /**
73
+ * If true, only one texture can be assigned to the model at a time, instead of textures being assigned per face
74
+ */
131
75
  single_texture: boolean
132
- single_texture_default?: boolean
133
- per_group_texture?: boolean
134
- per_texture_uv_size?: boolean
76
+ /**
77
+ * If true, a single texture is used as default, but textures can still be assigned to faces
78
+ */
79
+ single_texture_default: boolean
80
+ /**
81
+ * If true, textures can be assigned per group instead of per face
82
+ */
83
+ per_group_texture: boolean
84
+ /**
85
+ * If true, UV size (the size of the texture in UV space) will be defined per texture and not per project
86
+ */
87
+ per_texture_uv_size: boolean
88
+ /**
89
+ * Enable a model identifier field in the project settings. Default is true
90
+ */
135
91
  model_identifier: boolean
136
- legacy_editable_file_name?: boolean
92
+ /**
93
+ * If true, the file name of a project will be editable in the project settings
94
+ */
95
+ legacy_editable_file_name: boolean
96
+ /**
97
+ * If true, enables a field in the project settings to set a parent model ID
98
+ */
137
99
  parent_model_id: boolean
100
+ /**
101
+ * Adds a toggle in the project settings to enable project wide vertex color ambient occlusion
102
+ */
138
103
  vertex_color_ambient_occlusion: boolean
104
+ /**
105
+ * Enable flipbook animated textures
106
+ */
139
107
  animated_textures: boolean
108
+ /**
109
+ * Enable groups to work as bones and rig the model
110
+ */
140
111
  bone_rig: boolean
112
+ /**
113
+ * Align the grid center with the model origin, instead of the grid corner
114
+ */
141
115
  centered_grid: boolean
116
+ /**
117
+ * Add the ability to rotate cubes
118
+ */
142
119
  rotate_cubes: boolean
120
+ /**
121
+ * Add the ability to stretch cubes. Stretch scales cubes from the center without affecting UV
122
+ */
143
123
  stretch_cubes: boolean
124
+ /**
125
+ * If true, cube sizes are limited to integer values
126
+ */
144
127
  integer_size: boolean
128
+ /**
129
+ * Enable mesh elements
130
+ */
145
131
  meshes: boolean
132
+ /**
133
+ * Enable texture meshes
134
+ */
146
135
  texture_meshes: boolean
136
+ /**
137
+ * Enable locators
138
+ */
147
139
  locators: boolean
140
+ /**
141
+ * Enforces a rotation limit for cubes of up to 45 degrees in either direction and one axis at a time
142
+ */
148
143
  rotation_limit: boolean
144
+ /**
145
+ * Forces cube rotations to snap to 22.5 degree increments
146
+ */
149
147
  rotation_snap: boolean
148
+ /**
149
+ * Allows cube UVs to be rotated
150
+ */
150
151
  uv_rotation: boolean
152
+ /**
153
+ * Enables Minecraft Java block/item model specific cube face features (tint and export)
154
+ */
151
155
  java_face_properties: boolean
156
+ /**
157
+ * Allows assigning one texture to be used as a texture for particles related to the model
158
+ */
152
159
  select_texture_for_particles: boolean
160
+ /**
161
+ * Enable mcmeta files for animated texture files
162
+ */
153
163
  texture_mcmeta: boolean
164
+ /**
165
+ * Enables an option to set an expression for bone bindings
166
+ */
154
167
  bone_binding_expression: boolean
168
+ /**
169
+ * If true, animations will be saved into files
170
+ */
155
171
  animation_files: boolean
172
+ /**
173
+ * Enables a folder path per texture that can be set in the texture properties window
174
+ */
156
175
  texture_folder: boolean
176
+ /**
177
+ * Enables the 2D image editor
178
+ */
157
179
  image_editor: boolean
180
+ /**
181
+ * Enables edit mode. Default is true
182
+ */
158
183
  edit_mode: boolean
184
+ /**
185
+ * Enables paint mode. Default is true
186
+ */
159
187
  paint_mode: boolean
188
+ /**
189
+ * Enables display mode
190
+ */
160
191
  display_mode: boolean
192
+ /**
193
+ * Emaböes animation mode
194
+ */
161
195
  animation_mode: boolean
196
+ /**
197
+ * Enables pose mode
198
+ */
162
199
  pose_mode: boolean
200
+ /**
201
+ * Enables animation controllers
202
+ */
203
+ animation_controllers: boolean
204
+ /**
205
+ * If true, cube sizes will not be floored to calculate UV sizes with box UV. This can result in UVs not aligning with pixel edges
206
+ */
163
207
  box_uv_float_size: boolean
208
+ /**
209
+ * Enables properties for Minecraft Java block/item models related to block shading (shading option and light emission value)
210
+ */
164
211
  java_cube_shading_properties: boolean
212
+ /**
213
+ * Enables cullfaces, the ability on faces in Minecraft block models to set a direction, that, if covered by another block, will cause the face to unrender
214
+ */
165
215
  cullfaces: boolean
166
- animation_controllers: boolean
216
+ /**
217
+ * A set of characters that is allowed in node names (names of elements and groups that can be referenced externally, this does not apply to cubes or meshes)
218
+ */
219
+ node_name_regex: string
220
+ /**
221
+ * Set the default render sides for textures
222
+ */
167
223
  render_sides: 'front' | 'double' | 'back' | (() => ('front' | 'double' | 'back'))
224
+
225
+ /**
226
+ * Options to limit the size of cubes
227
+ */
228
+ cube_size_limiter?: CubeSizeLimiter
229
+
230
+ codec?: Codec
231
+ onActivation?(): void
232
+ onDeactivation?(): void
233
+ }
234
+ interface ModelFormat extends FormatOptions {}
235
+
236
+ declare class ModelFormat extends Deletable implements FormatOptions {
237
+ constructor(id: string, options: Partial<FormatOptions>)
238
+ constructor(options: Partial<FormatOptions>)
239
+
240
+ id: string
241
+ icon: string
242
+ name: string
243
+ description: string
244
+ category: string
245
+ target: string | string[]
246
+ confidential: boolean
247
+ condition?: ConditionResolvable
248
+ show_on_start_screen: boolean
249
+ format_page?: FormatPage
250
+ onFormatPage?(): void
251
+ onStart?(): void
252
+ onSetup?(): void
253
+
168
254
 
169
255
 
170
256
  codec?: Codec
package/types/global.d.ts CHANGED
@@ -4,7 +4,6 @@ declare global {
4
4
  const Prism: typeof import('prismjs')
5
5
  const scene: THREE.Scene
6
6
  const Transformer: any
7
- const DOMPurify: typeof import('dompurify')
8
7
  const electron: typeof import('electron')
9
8
  const { clipboard, shell, nativeImage, ipcRenderer, dialog }: typeof electron
10
9
 
@@ -17,6 +16,7 @@ declare global {
17
16
  const fs: typeof import('fs')
18
17
 
19
18
  const tinycolor: typeof import('tinycolor2')
19
+ const DOMPurify: typeof import('dompurify')
20
20
 
21
21
  let selected: OutlinerElement[]
22
22
  const Toolbars: Record<string, Toolbar>
package/types/group.d.ts CHANGED
@@ -21,7 +21,22 @@ interface GroupOptions {
21
21
 
22
22
  declare class Group extends OutlinerNode {
23
23
  constructor(options: Partial<GroupOptions> | string)
24
+ /**
25
+ * Returns the first selected group. Depretated, use Group.multi_selected. In the future this will return an array of selected groups instead.
26
+ * @deprecated
27
+ */
24
28
  static selected: Group
29
+ /**
30
+ * The group that's the first in the list of selected groups
31
+ */
32
+ static first_selected: Group
33
+ /**
34
+ * The list of selected groups. Note that this only includes directly selected groups, not groups that are selected because the parent is selected
35
+ */
36
+ static multi_selected: Group
37
+ /**
38
+ * All groups in the current project
39
+ */
25
40
  static all: Group[]
26
41
  static animator: BoneAnimator
27
42
  /**Check if any groups are in the project */
package/types/menu.d.ts CHANGED
@@ -16,7 +16,7 @@ interface CustomMenuItem {
16
16
  children?: MenuItem[] | (() => MenuItem[])
17
17
  click?(context?: any, event?: Event): void
18
18
  }
19
- type MenuItem = CustomMenuItem | Action | BarSelect | MenuSeparator | string
19
+ type MenuItem = CustomMenuItem | Action | BarSelect<string> | MenuSeparator | string
20
20
  interface MenuOptions {
21
21
  onOpen?(position: MouseEvent | HTMLElement, context?: any): void
22
22
  onClose?(): void
package/types/mesh.d.ts CHANGED
@@ -35,8 +35,10 @@ declare class MeshFace extends Face {
35
35
  extend(data: MeshFaceOptions): void
36
36
  /**
37
37
  * Returns the face normal in mesh space as calculated from the vertex positions
38
+ * @param normalize If true, the values will be normalized.
39
+ * @param alt_tri On quads, if true, this will return the normal of the second tri instead of the first
38
40
  */
39
- getNormal(normalize: boolean): ArrayVector3
41
+ getNormal(normalize: boolean, alt_tri?: boolean): ArrayVector3
40
42
  /**
41
43
  * Calculates which pixels the UV face occupies, and returns them as a map
42
44
  */
@@ -152,18 +152,43 @@ declare class TextureMesh extends OutlinerElement {
152
152
  static selected: TextureMesh[]
153
153
  }
154
154
 
155
+ /**
156
+ * Toggle in the outliner
157
+ */
158
+ interface OutlinerToggle {
159
+ id: string
160
+ title: string
161
+ icon: IconString
162
+ icon_off?: IconString
163
+ icon_alt?: IconString
164
+ condition?: ConditionResolvable
165
+ /**
166
+ * If true, the toggle will only be visible when "Toggle More Options" is enabled
167
+ */
168
+ advanced_option?: boolean
169
+ /**
170
+ * Override the visibility and still show the toggle under certain conditions, even if more options are disabled
171
+ */
172
+ visibilityException?: (node: OutlinerNode) => boolean
173
+ /**
174
+ * It's complicated, check the source code
175
+ */
176
+ getState?: (node: OutlinerNode) => boolean | 'alt'
177
+ }
178
+
155
179
  declare namespace Outliner {
156
180
  const root: OutlinerNode[]
157
181
  const elements: OutlinerElement[]
158
182
  const selected: OutlinerElement[]
159
183
  let control_menu_group: MenuItem[]
160
184
  const buttons: {
161
- autouv: any
162
- export: any
163
- locked: any
164
- mirror_uv: any
165
- shade: any
166
- visibility: any
185
+ autouv: OutlinerToggle
186
+ export: OutlinerToggle
187
+ locked: OutlinerToggle
188
+ mirror_uv: OutlinerToggle
189
+ shade: OutlinerToggle
190
+ visibility: OutlinerToggle
191
+ [id: string]: OutlinerToggle
167
192
  }
168
193
  }
169
194
 
package/types/panel.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference path="./blockbench.d.ts"/>
2
2
 
3
- type PanelSlot = 'left_bar' | 'right_bar' | 'top' | 'bottom' | 'float'
3
+ type PanelSlot = 'left_bar' | 'right_bar' | 'top' | 'bottom' | 'float' | 'hidden'
4
4
 
5
5
  interface PanelOptions {
6
6
  id: string
package/types/plugin.d.ts CHANGED
@@ -62,6 +62,10 @@ interface PluginOptions {
62
62
  * Link to where users can report issues with the plugin
63
63
  */
64
64
  bug_tracker?: string
65
+ /*
66
+ * List of secondary contributors to the plugin, excluding the main author(s)
67
+ */
68
+ contributors?: string[]
65
69
  /**
66
70
  * Runs when the plugin loads
67
71
  */
@@ -89,7 +93,8 @@ declare class BBPlugin {
89
93
  extend(options: PluginOptions): this
90
94
 
91
95
  installed: boolean
92
- expanded: boolean
96
+ id: string
97
+ disabled: boolean
93
98
  title: string
94
99
  author: string
95
100
  /**
@@ -117,18 +122,22 @@ declare class BBPlugin {
117
122
  * In combination with a "Deprecated" tag, this can be used to provide context on why a plugin is deprecated
118
123
  */
119
124
  deprecation_note?: string
120
- website?: string
121
125
  /*
122
126
  * Link to the plugin's website
123
127
  */
124
- repository?: string
128
+ website?: string
125
129
  /*
126
130
  * Link to the repository that contains the source for the plugin
127
131
  */
128
- bug_tracker?: string
132
+ repository?: string
129
133
  /*
130
134
  * Link to where users can report issues with the plugin
131
135
  */
136
+ bug_tracker?: string
137
+ /*
138
+ * List of secondary contributors to the plugin, excluding the main author(s)
139
+ */
140
+ contributors: string[]
132
141
  onload(): void
133
142
  onunload(): void
134
143
  oninstall(): void
@@ -136,3 +145,33 @@ declare class BBPlugin {
136
145
 
137
146
  static register(id: string, options: PluginOptions): BBPlugin
138
147
  }
148
+
149
+ type PluginInstalledData = {
150
+ id: string
151
+ version: string
152
+ source: 'store' | 'file' | 'url'
153
+ path?: string
154
+ disabled?: boolean
155
+ }
156
+ declare namespace Plugins {
157
+ /**
158
+ * All loaded plugins, including plugins from the store that are not installed
159
+ */
160
+ const all: BBPlugin[]
161
+ /**
162
+ * Data about which plugins are installed
163
+ */
164
+ const installed: PluginInstalledData[]
165
+ /**
166
+ * The plugins window
167
+ */
168
+ const dialog: Dialog
169
+ /**
170
+ * The currently used path to the plugin API
171
+ */
172
+ const api_path: string
173
+ /**
174
+ * Dev reload all side-loaded plugins
175
+ */
176
+ function devReload(): void
177
+ }
@@ -88,9 +88,6 @@ declare class ModelProject {
88
88
  front_gui_light: boolean
89
89
 
90
90
  get model_3d(): THREE.Object3D
91
- get materials(): {
92
- [uuid: UUID]: THREE.ShaderMaterial
93
- }
94
91
  get nodes_3d(): {
95
92
  [uuid: UUID]: THREE.Object3D
96
93
  }
@@ -0,0 +1,73 @@
1
+ /// <reference path="./blockbench.d.ts"/>
2
+
3
+
4
+ interface TextureGroupData {
5
+ name?: string
6
+ is_material?: boolean
7
+ material_config?: TextureGroupMaterialConfigData
8
+ }
9
+
10
+ /**
11
+ * A way to group textures. Texture groups can also be used to represent materials in enabled formats
12
+ */
13
+ declare class TextureGroup {
14
+ constructor(data?: TextureGroupData, uuid?: string);
15
+ uuid: string
16
+ name: string
17
+ folded: boolean
18
+ /**
19
+ * If true, the texture group works as a material
20
+ */
21
+ is_material: boolean
22
+ /**
23
+ * Material configuration
24
+ */
25
+ material_config: TextureGroupMaterialConfig
26
+ get material(): THREE.MeshStandardMaterial;
27
+ extend(data: TextureGroupData): this;
28
+ add(): this;
29
+ select(): this;
30
+ remove(): void;
31
+ showContextMenu(event: Event): void;
32
+ rename(): this;
33
+ getTextures(): Texture[];
34
+ getUndoCopy(): {
35
+ uuid: string;
36
+ index: number;
37
+ material_config: {};
38
+ };
39
+ getSaveCopy(): {
40
+ uuid: string;
41
+ material_config: {};
42
+ };
43
+ updateMaterial(): void;
44
+ getMaterial(): THREE.MeshStandardMaterial;
45
+ }
46
+
47
+ interface TextureGroupMaterialConfigData {
48
+ color_value?: [number, number, number, number]
49
+ mer_value?: [number, number, number]
50
+ saved?: boolean
51
+ }
52
+ declare class TextureGroupMaterialConfig {
53
+ constructor(texture_group: TextureGroup, data: TextureGroupMaterialConfigData);
54
+ color_value: [number, number, number, number]
55
+ mer_value: [number, number, number]
56
+ saved: boolean
57
+ menu: Menu
58
+ texture_group: TextureGroup
59
+
60
+ extend(data: TextureGroupMaterialConfigData): this;
61
+ getUndoCopy(): {};
62
+ getSaveCopy(): {};
63
+ compileForBedrock(): {
64
+ format_version: string;
65
+ "minecraft:texture_set": {};
66
+ };
67
+ getFilePath(): string;
68
+ getFileName(extension?: boolean): string;
69
+ save(): void;
70
+ showContextMenu(event: Event): void;
71
+ propertiesDialog(): void;
72
+ }
73
+ declare function importTextureSet(file: any): void;
@@ -3,13 +3,44 @@
3
3
  interface TextureData {
4
4
  path?: string
5
5
  name?: string
6
+ /**
7
+ * Relative path to the file's directory, used by some formats such as Java Block/Item
8
+ * */
6
9
  folder?: string
7
10
  namespace?: string
11
+ /**
12
+ * Texture ID or key, used by some formats. By default this is a number that increases with every texture that is added
13
+ * */
8
14
  id?: string
15
+ /**
16
+ * Whether the texture is used for the models particle system. Used by some formats such as Java Block/Item
17
+ * */
9
18
  particle?: boolean
10
19
  visible?: boolean
11
- mode?: string
20
+ render_mode?: 'default' | 'emissive' | 'additive' | 'layered' | string
21
+ render_sides?: 'auto' | 'front' | 'double' | string
22
+ pbr_channel?: 'color' | 'normal' | 'height' | 'mer'
23
+
24
+ /**
25
+ * Texture animation frame time
26
+ * */
27
+ frame_time?: number
28
+ frame_order_type?: 'custom' | 'loop' | 'backwards' | 'back_and_forth'
29
+ /**
30
+ * Custom frame order
31
+ * */
32
+ frame_order?: string
33
+ /**
34
+ * Interpolate between frames
35
+ * */
36
+ frame_interpolate?: boolean
37
+ /**
38
+ * Whether the texture is saved
39
+ */
12
40
  saved?: boolean
41
+ /**
42
+ * Flag to indicate that the texture was manually resized, and on load it should not try to automatically adjust UV size
43
+ */
13
44
  keep_size?: boolean
14
45
  source?: string
15
46
  width?: number
@@ -61,6 +92,7 @@ declare class Texture {
61
92
  particle: boolean
62
93
  render_mode: 'default' | 'emissive' | 'additive' | 'layered' | string
63
94
  render_sides: 'auto' | 'front' | 'double' | string
95
+ pbr_channel: 'color' | 'normal' | 'height' | 'mer'
64
96
 
65
97
  /** Texture animation frame time */
66
98
  frame_time: number
@@ -120,6 +152,7 @@ declare class Texture {
120
152
  img: HTMLImageElement
121
153
 
122
154
  relative_path?: string
155
+ readonly material: THREE.ShaderMaterial
123
156
 
124
157
  getErrorMessage(): string
125
158
  extend(data: TextureData): this
@@ -174,7 +207,18 @@ declare class Texture {
174
207
  * Reloads the texture. Only works in the desktop app
175
208
  */
176
209
  reloadTexture(): void
177
- getMaterial(): THREE.MeshLambertMaterial
210
+ /**
211
+ * Get the material that the texture displays. When previewing PBR, this will return the shared PBR material
212
+ */
213
+ getMaterial(): THREE.ShaderMaterial | THREE.MeshStandardMaterial
214
+ /**
215
+ * Get the texture's own material
216
+ */
217
+ getOwnMaterial(): THREE.ShaderMaterial
218
+ /**
219
+ * Selects the texture
220
+ * @param event Click event during selection
221
+ */
178
222
  select(event?: Event): this
179
223
  /**
180
224
  * Adds texture to the textures list and initializes it
package/types/undo.d.ts CHANGED
@@ -27,6 +27,9 @@ interface UndoAspects {
27
27
  display_slots?: string[]
28
28
  exploded_view?: boolean
29
29
  }
30
+ interface UndoSelectionAspects {
31
+ texture_selection?: boolean
32
+ }
30
33
  type UndoSave = {
31
34
  aspects: UndoAspects
32
35
  selection?: []
@@ -47,24 +50,63 @@ type UndoSave = {
47
50
  keyframes?: {}
48
51
  display_slots?: {}
49
52
  exploded_views?: boolean
53
+ /**
54
+ * Load the undo save
55
+ */
56
+ load(reference: UndoSave, mode?: 'session'): void
57
+ /**
58
+ * Add a texture to an undo edit during the edit
59
+ */
60
+ addTexture(texture: Texture): void
61
+ /**
62
+ * Add a texture to an undo edit during the edit
63
+ */
64
+ addTextureOrLayer(texture: Texture): void
65
+ /**
66
+ * Add elements to an undo edit during the edit
67
+ */
68
+ addElements(elements: OutlinerElement[], aspects?: UndoAspects): void
69
+ }
70
+ type UndoSelectionSave = {
71
+ aspects: UndoSelectionAspects
72
+ elements: string[]
73
+ groups: string[]
74
+ geometry: {
75
+ [uuid: string]: {
76
+ faces: string[]
77
+ edges: string[]
78
+ vertices: string[]
79
+ }
80
+ }
81
+ mode: string
82
+ mesh_selection_mode: string
83
+ texture: string
84
+ texture_selection?: Int8Array | boolean
85
+ animation_item?: string
86
+ timeline?: {}
87
+ graph_editor_channel?: string
88
+ graph_editor_axis?: string
89
+ graph_editor_open?: boolean
90
+ /**
91
+ * Load the selection save
92
+ */
93
+ load(): void
94
+ /**
95
+ * Test whether the selection save matches another selection
96
+ * @param other Selection save to test against
97
+ */
98
+ matches(other: UndoSelectionSave): boolean
50
99
  }
51
100
  type UndoEntry = {
52
- before: UndoSave
53
- post: UndoSave
101
+ before?: UndoSave
102
+ post?: UndoSave
103
+ selection_before?: UndoSelectionSave
104
+ selection_post?: UndoSelectionSave
54
105
  action: string
106
+ type: 'original' | 'edit' | 'selection'
55
107
  time: number
56
108
  }
57
- interface AmendEditForm {
58
- condition?: ConditionResolvable
59
- type?: 'number' | 'checkbox'
60
- label: string
61
- interval_type: 'position' | 'rotation'
62
- getInterval?(event: Event): number
63
- value?: number | string | 'boolean'
64
- min?: number
65
- max?: number
66
- step?: number
67
- }
109
+
68
110
 
69
111
  declare class UndoSystem {
70
112
  constructor()
@@ -90,6 +132,24 @@ declare class UndoSystem {
90
132
  /**
91
133
  * Undoes the latest edit
92
134
  */
135
+ /**
136
+ * Starts a selection change in the current project
137
+ * @param aspects Aspects to save
138
+ */
139
+ initSelection(aspects?: UndoSelectionAspects): UndoEntry
140
+ /**
141
+ * Finishes a selection change in the current project
142
+ * @param action Description of the edit
143
+ */
144
+ finishSelection(action: string, aspects?: UndoSelectionAspects): UndoEntry
145
+ /**
146
+ * Cancel the selection changes
147
+ * @param revert_changes If true, the already tracked selection changes will be reverted to the state before initSelection
148
+ */
149
+ cancelSelection(revert_changes?: boolean): void
150
+ /**
151
+ * Cancels an event before it was finished and reset the project to the state before
152
+ */
93
153
  undo(remote?: boolean): void
94
154
  /**
95
155
  * Redoes the latest edit
@@ -98,7 +158,11 @@ declare class UndoSystem {
98
158
  /**
99
159
  * Provides a menu to amend the latest edit with slightly changed values
100
160
  */
101
- amendEdit(form: AmendEditForm, callback: (values: any, form: any) => void): void
161
+ amendEdit(form: InputFormConfig, callback: (values: any, form: any) => void): void
162
+ /**
163
+ * Closes the amend edit menu
164
+ */
165
+ closeAmendEditMenu(): void
102
166
 
103
167
  /**
104
168
  * Loads a specific undo save
@@ -123,11 +187,8 @@ Undo.initEdit({elements: []});
123
187
  let new_cube = new Cube({name: 'kevin'}).init();
124
188
  let other_cube = new Cube({name: 'lars'}).init();
125
189
 
126
- Undo.finishEdit('add new cubes', {elements: [new_cube, other_cube]});
190
+ Undo.finishEdit('Add new cubes', {elements: [new_cube, other_cube]});
127
191
  ```
128
192
  */
129
193
  declare let Undo: UndoSystem
130
- interface CompileJSONOptions {
131
- small?: boolean
132
- }
133
- declare function compileJSON(json: any, options?: CompileJSONOptions): string | ArrayBuffer
194
+
package/types/util.d.ts CHANGED
@@ -215,3 +215,18 @@ declare class Rectangle {
215
215
  fromUnorderedCoords(x1: number, y1: number, x2: number, y2: number): void
216
216
  expandTo(x: number, y: number): void
217
217
  }
218
+
219
+ interface CompileJSONOptions {
220
+ /**
221
+ * Character or string used for indentation
222
+ */
223
+ indentation?: string
224
+ /**
225
+ * If true, compile everything in one line and without spaces
226
+ */
227
+ small?: boolean
228
+ }
229
+ /**
230
+ * Blockbench's JSON compilation / stringify implementation
231
+ */
232
+ declare function compileJSON(json: any, options?: CompileJSONOptions): string