blockbench-types 4.5.0 → 4.6.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.5.0",
3
+ "version": "4.6.0",
4
4
  "description": "Blockbench typescript types",
5
5
  "main": "",
6
6
  "types": "types/index.d.ts",
@@ -22,6 +22,6 @@
22
22
  "@types/tinycolor2": "^1.4.3",
23
23
  "three": "^0.129.0",
24
24
  "vue": "^2.6.14",
25
- "wintersky": "^1.1.0"
25
+ "wintersky": "^1.2.0"
26
26
  }
27
27
  }
package/types/action.d.ts CHANGED
@@ -68,6 +68,23 @@ declare class Action extends BarItem {
68
68
  */
69
69
  side_menu?: Menu
70
70
  }
71
+ interface ToggleOptions extends ActionOptions {
72
+ /**
73
+ * Default value of the toggle
74
+ */
75
+ default?: boolean
76
+ /**
77
+ * Method that gets called when the user changes the value of the toggle
78
+ */
79
+ onChange?(value: boolean): void
80
+ }
81
+ declare class Toggle extends Action {
82
+ constructor(id: string, options: ToggleOptions);
83
+ /**
84
+ * Updates the state of the toggle in the UI
85
+ */
86
+ updateEnabledState(): void
87
+ }
71
88
 
72
89
  type RGBAColor = {r: number, g: number, b: number, a: number}
73
90
  type ViewMode = 'textured' | 'solid' | 'wireframe' | 'uv' | 'normal'
@@ -272,4 +289,8 @@ declare namespace Keybinds {
272
289
  const structure: {};
273
290
  function save (): void;
274
291
  function reset (): void;
275
- }
292
+ }
293
+ declare class _ToolToolbar extends Toolbar {
294
+ selected: Tool
295
+ }
296
+ declare const Toolbox: _ToolToolbar;
@@ -1,3 +1,8 @@
1
+ declare class AnimationItem {
2
+ static all: AnimationItem[]
3
+ static selected: AnimationItem | null
4
+ }
5
+
1
6
  interface AnimationOptions {
2
7
  name?: string
3
8
  loop?: string
@@ -8,7 +13,7 @@ interface AnimationOptions {
8
13
  snapping?: number
9
14
  }
10
15
 
11
- declare class Animation {
16
+ declare class Animation extends AnimationItem {
12
17
  constructor(data: AnimationOptions);
13
18
  extend(data: AnimationOptions): this;
14
19
  getUndoCopy(options: any, save: any): {
@@ -37,9 +42,32 @@ declare class Animation {
37
42
  setLoop(value: any, undo: any): void;
38
43
  calculateSnappingFromKeyframes(): any;
39
44
  propertiesDialog(): void;
45
+
46
+ name: string
47
+ loop: string
48
+ override: boolean
49
+ anim_time_update: string
50
+ blend_weight: string
51
+ length: number
52
+ snapping: number
53
+ loop_delay: string
54
+ start_delay: string
55
+ path: string
56
+ playing: boolean
57
+ saved: boolean
58
+
59
+ markers: TimelineMarker[]
60
+ animators: {
61
+ [id: string]: GeneralAnimator
62
+ }
63
+ saved_name?: string
64
+ selected: boolean
65
+ type: string
66
+ uuid: string
40
67
  }
41
68
 
42
- namespace Animator {
69
+
70
+ declare namespace Animator {
43
71
  const open: boolean
44
72
  const MolangParser: object
45
73
  const motion_trail: THREE.Object3D
@@ -90,15 +118,14 @@ declare class BoneAnimator extends GeneralAnimator {
90
118
  position: Keyframe[]
91
119
  scale: Keyframe[]
92
120
  getGroup(): Group
93
- select
94
- fillValues
95
- pushKeyframe
96
- doRender
97
- displayRotation
98
- displayPosition
99
- displayScale
100
- interpolate
101
- displayFrame
121
+ fillValues: () => void
122
+ pushKeyframe: () => void
123
+ doRender: () => boolean
124
+ displayRotation: () => void
125
+ displayPosition: () => void
126
+ displayScale: () => void
127
+ interpolate: () => void
128
+ displayFrame: () => void
102
129
  }
103
130
  declare class NullObjectAnimator extends GeneralAnimator {
104
131
  name: string
@@ -107,11 +134,10 @@ declare class NullObjectAnimator extends GeneralAnimator {
107
134
  position: Keyframe[]
108
135
  scale: Keyframe[]
109
136
  getElement(): NullObject
110
- select
111
- doRender
112
- displayPosition
113
- displayIK
114
- displayFrame
137
+ doRender: () => void
138
+ displayPosition: () => void
139
+ displayIK: () => void
140
+ displayFrame: () => void
115
141
  }
116
142
  declare class EffectAnimator extends GeneralAnimator {
117
143
  name: string
@@ -121,6 +147,11 @@ declare class EffectAnimator extends GeneralAnimator {
121
147
  scale: Keyframe[]
122
148
  pushKeyframe(keyframe): this
123
149
  displayFrame(in_loop): this
124
- startPreviousSounds
150
+ startPreviousSounds: () => void
151
+ }
152
+
153
+ declare class TimelineMarker {
154
+ color: number
155
+ time: number
125
156
  }
126
157
 
@@ -0,0 +1,112 @@
1
+ type StateAnimationInput = string | {
2
+ [key: string]: string
3
+ } | {
4
+ uuid: string
5
+ key?: string
6
+ animation?: string
7
+ blend_value?: number
8
+ }
9
+ type StateAnimation = {
10
+ uuid: string
11
+ key: string
12
+ animation: string
13
+ blend_value: number
14
+ }
15
+
16
+ interface AnimationControllerStateOptions {
17
+ name?: string
18
+ animations?: StateAnimationInput[]
19
+ transitions?: object[]
20
+ sounds?: object[]
21
+ particles?: object[]
22
+ on_entry?: string
23
+ on_exit?: string
24
+ blend_transition?: number
25
+ blend_via_shortest_path?: boolean
26
+ }
27
+
28
+ declare class AnimationControllerState {
29
+ constructor(controller: AnimationController, options?: AnimationControllerStateOptions)
30
+ controller: AnimationController
31
+ uuid: string
32
+ name: string
33
+ fold: {
34
+ animations: boolean
35
+ particles: boolean
36
+ sounds: boolean
37
+ on_entry: boolean
38
+ on_exit: boolean
39
+ transitions: boolean
40
+ }
41
+ muted: {
42
+ sound: boolean
43
+ particle: boolean
44
+ }
45
+ playing_sounds: HTMLAudioElement[]
46
+ animations: StateAnimation[]
47
+ transitions: object[]
48
+ sounds: object[]
49
+ particles: object[]
50
+ on_entry: string
51
+ on_exit: string
52
+ blend_transition: number
53
+ blend_via_shortest_path: boolean
54
+
55
+ extend: (data: AnimationControllerStateOptions) => void
56
+ getUndoCopy: () => object
57
+ compileForBedrock: () => object
58
+ select: (force?: boolean) => void
59
+ unselect: () => void
60
+ playEffects: () => void
61
+ scrollTo: () => void
62
+ rename: () => void
63
+ remove: (undo?: boolean) => void
64
+ createUniqueName: () => void
65
+
66
+ addAnimation: (animation?: Animation) => void
67
+ addTransition: (target_uuid?: string) => void
68
+ addParticle: (options?: {effect: string}) => void
69
+ addSound: (options?: {effect: string, file: string}) => void
70
+ openMenu: (event: Event) => void
71
+ /**
72
+ * Returns the current animation time of the state in seconds
73
+ */
74
+ getStateTime: () => number
75
+ }
76
+
77
+ interface AnimationControllerOptions {
78
+ name?: string
79
+ path?: string
80
+ initial_state?: string
81
+ }
82
+
83
+
84
+ declare class AnimationController extends AnimationItem {
85
+ constructor(data: AnimationControllerOptions);
86
+ name: string
87
+ path: string
88
+ uuid: string
89
+ playing: boolean
90
+ saved: boolean
91
+ selected: boolean
92
+ saved_name: string
93
+ states: AnimationControllerState[]
94
+ initial_state: string
95
+ selected_state: null | AnimationControllerState
96
+ extend(data: AnimationControllerOptions): this;
97
+ getUndoCopy(): object;
98
+ compileForBedrock(): object;
99
+ save(): this | undefined;
100
+ select(): this | undefined;
101
+ createUniqueName(references: AnimationController[]): any;
102
+ rename(): this;
103
+ add(undo: any): this;
104
+ remove(undo: any, remove_from_file?: boolean): this;
105
+ propertiesDialog(): void;
106
+ /**
107
+ * Updates the preview of the controller, including updating the animations and switching states if preview mode is set to play
108
+ */
109
+ updatePreview: () => void
110
+ togglePlayingState: (state?: boolean) => boolean
111
+ showContextMenu: (event: Event | HTMLElement) => void
112
+ }
package/types/canvas.d.ts CHANGED
@@ -208,4 +208,40 @@ declare const TickUpdates: {
208
208
  keyframes: undefined | true
209
209
  keyframe_selection: undefined | true
210
210
  keybind_conflicts: undefined | true
211
+ }
212
+
213
+ interface NodePreviewControllerOptions {
214
+ setup?: (element: OutlinerNode) => void
215
+ remove?: (element: OutlinerNode) => void
216
+ updateAll?: (element: OutlinerNode) => void
217
+ updateTransform?: (element: OutlinerNode) => void
218
+ updateVisibility?: (element: OutlinerNode) => void
219
+ updateSelection?: (element: OutlinerNode) => void
220
+ updateGeometry?: (element: OutlinerNode) => void
221
+ updateUV?: (element: OutlinerNode) => void
222
+ updateFaces?: (element: OutlinerNode) => void
223
+ updatePaintingGrid?: (element: OutlinerNode) => void
224
+ updateHighlight?: (element: OutlinerNode) => void
225
+ }
226
+ declare class NodePreviewController {
227
+ constructor(type: typeof OutlinerNode, options: NodePreviewControllerOptions)
228
+ type: typeof OutlinerNode
229
+ events: {
230
+ [event_name: string]: ((data) => void)[]
231
+ }
232
+ dispatchEvent(event_name: string, data: object)
233
+ on(event_name: string, cb: (data) => void)
234
+ removeListener(event_name: string, cb: (data) => void)
235
+
236
+ setup(element: OutlinerNode): void
237
+ remove(element: OutlinerNode): void
238
+ updateAll(element: OutlinerNode): void
239
+ updateTransform(element: OutlinerNode): void
240
+ updateVisibility(element: OutlinerNode): void
241
+ updateSelection(element: OutlinerNode): void
242
+ updateGeometry(instance: OutlinerNode): void
243
+ updateUV(instance: OutlinerNode): void
244
+ updateFaces(instance: OutlinerNode): void
245
+ updatePaintingGrid(instance: OutlinerNode): void
246
+ updateHighlight(instance: OutlinerNode): void
211
247
  }
@@ -0,0 +1,109 @@
1
+ interface FaceOptions {
2
+ texture?: Texture
3
+
4
+ }
5
+ declare class Face {
6
+ constructor()
7
+ texture: string | false | null
8
+
9
+ getTexture: () => Texture | null
10
+ /**
11
+ * Returns a 2D rectangle around the UV face
12
+ */
13
+ getBoundingRect: () => object
14
+ reset: () => void
15
+ /**
16
+ * Returns a save copy of the face, ready for serialization. Set project to true to save for a bbmodel project file
17
+ */
18
+ getSaveCopy: (project?: boolean) => object
19
+ /**
20
+ * Get a copy for undo tracking
21
+ */
22
+ getUndoCopy: () => Face
23
+ }
24
+
25
+ type CubeFaceDirection = 'north' | 'south' | 'east' | 'west' | 'up' | 'down'
26
+ interface CubeFaceOptions extends FaceOptions {
27
+ uv?: [number, number, number, number]
28
+ rotation?: number
29
+ tint?: number
30
+ cullface?: CubeFaceDirection | ''
31
+ material_name?: string
32
+ enabled?: boolean
33
+ }
34
+ declare class CubeFace extends Face {
35
+ constructor(direction: CubeFaceDirection, data: CubeFaceOptions, cube: Cube)
36
+ cube: Cube
37
+ direction: CubeFaceDirection
38
+ uv: [number, number, number, number]
39
+ readonly uv_size: ArrayVector2
40
+ rotation: number
41
+ tint: number
42
+ cullface: CubeFaceDirection | ''
43
+ material_name: string
44
+ enabled: boolean
45
+
46
+ extend(data: CubeFaceOptions)
47
+ getVertexIndices: () => [number, number, number, number]
48
+ }
49
+
50
+ interface CubeOptions {
51
+ name: string
52
+ autouv: 1 | 2 | 3
53
+ shade: boolean
54
+ mirror_uv: boolean
55
+ inflate: number
56
+ color: number
57
+ visibility: boolean
58
+ from: ArrayVector3
59
+ to: ArrayVector3
60
+ rotation: ArrayVector3
61
+ origin: ArrayVector3
62
+ /**
63
+ * UV position for box UV mode
64
+ */
65
+ uv_offset: ArrayVector2
66
+ }
67
+ declare class Cube extends OutlinerElement {
68
+ constructor (options: Partial<CubeOptions>, uuid?: string)
69
+ autouv: 1 | 2 | 3
70
+ shade: boolean
71
+ mirror_uv: boolean
72
+ inflate: number
73
+ visibility: boolean
74
+ from: ArrayVector3
75
+ to: ArrayVector3
76
+ rotation: ArrayVector3
77
+ origin: ArrayVector3
78
+ faces: {
79
+ [fkey: string]: CubeFaces
80
+ }
81
+ /**
82
+ * UV position for box UV mode
83
+ */
84
+ uv_offset: ArrayVector2
85
+
86
+ extend(options: Partial<CubeOptions>): this
87
+ /**
88
+ * Calculates and returns the size of a cube across a certain axis. If the axis argument is omitted, it returns all sizes as an array vector.
89
+ */
90
+ size: (axis?: number, floored?: boolean) => number | ArrayVector3
91
+ rotationAxis: () => void
92
+ getUndoCopy: (aspects?: object) => void
93
+ getSaveCopy: (project?: boolean) => void
94
+ roll: (axis: number, steps: number, origin: ArrayVector3) => void
95
+ flip: (axis: number, center: number, skipUV?: boolean) => void
96
+ transferOrigin: (origin: ArrayVector3, update?: boolean) => void
97
+ getWorldCenter: () => THREE.Vector3
98
+ getGlobalVertexPositions: () => void
99
+ setUVMode: (box_uv: boolean) => void
100
+ setColor: (color: number) => void
101
+ applyTexture: (texture: Texture, faces: true | undefined | CubeFaceDirection[]) => void
102
+ mapAutoUV: () => void
103
+ moveVector: (offset: ArrayVector3, axis: number, update?: boolean) => void
104
+ resize: (value: number, axis: number, negative: boolean, allow_negative?: boolean, bidirectional?: boolean) => void
105
+
106
+ static all: Cube[]
107
+ static selected: Cube[]
108
+ }
109
+
package/types/dialog.d.ts CHANGED
@@ -1,19 +1,22 @@
1
1
  interface DialogFormElement {
2
2
  label: string
3
3
  description?: string
4
- type: 'text' | 'number' | 'range' | 'checkbox' | 'select' | 'radio' | 'textarea' | 'vector' | 'color' | 'file' | 'folder' | 'save' | 'info'
4
+ type: 'text' | 'number' | 'range' | 'checkbox' | 'select' | 'radio' | 'textarea' | 'vector' | 'color' | 'file' | 'folder' | 'save' | 'info' | 'buttons'
5
5
  nocolon?: boolean
6
6
  full_width?: boolean
7
7
  readonly?: boolean
8
8
  value?: any
9
9
  placeholder?: string
10
10
  text?: string
11
+ editable_range_label?: boolean
11
12
  colorpicker?: any
12
13
  min?: number
13
14
  max?: number
14
15
  step?: number
15
16
  height?: number
16
17
  options?: object
18
+ buttons?: string[]
19
+ click?: (button_index: number) => void
17
20
  }
18
21
 
19
22
  type FormResultValue = string|number|boolean|[]
@@ -23,7 +26,7 @@ interface ActionInterface {
23
26
  description?: string
24
27
  icon: string,
25
28
  click: (event: Event) => void
26
- condition: Condition
29
+ condition: ConditionResolvable
27
30
  }
28
31
  interface DialogOptions {
29
32
  title: string
@@ -116,11 +119,13 @@ declare class DialogSidebar {
116
119
  }
117
120
 
118
121
  declare class Dialog {
119
- constructor (options: DialogOptions)
122
+ constructor(id: string, options: DialogOptions)
123
+ constructor(options: DialogOptions)
120
124
 
121
125
  id: string
122
126
  component: Vue.Component
123
127
  sidebar: DialogSidebar | null
128
+ content_vue: Vue | null
124
129
 
125
130
 
126
131
  show: () => Dialog
@@ -156,4 +161,73 @@ declare class Dialog {
156
161
  * Currently opened dialog
157
162
  */
158
163
  static open: Dialog | null
164
+ static stack: Dialog[]
165
+ }
166
+
167
+ interface ShapelessDialogOptions {
168
+ title: string
169
+ /**
170
+ * Default button to press to confirm the dialog. Defaults to the first button.
171
+ */
172
+ confirmIndex?: number
173
+ /**
174
+ * Default button to press to cancel the dialog. Defaults to the last button.
175
+ */
176
+ cancelIndex?: number
177
+ /**
178
+ * Function to execute when the user confirms the dialog
179
+ */
180
+ onConfirm?: (formResult: object) => void
181
+ /**
182
+ * Function to execute when the user cancels the dialog
183
+ */
184
+ onCancel?: () => void
185
+ /**
186
+ * Triggered when the user presses a specific button
187
+ */
188
+ onClose?: (button_index: number, event?: Event) => void
189
+ /**
190
+ * Vue component
191
+ */
192
+ component?: Vue.Component
193
+ /**
194
+ * Unless set to false, clicking on the darkened area outside of the dialog will cancel the dialog.
195
+ */
196
+ cancel_on_click_outside?: boolean
197
+ }
198
+ declare class ShapelessDialog extends Dialog {
199
+ constructor (id: string, options: ShapelessDialogOptions)
200
+
201
+ id: string
202
+ component: Vue.Component
203
+
204
+
205
+ show: () => Dialog
206
+ hide: () => Dialog
207
+ /**
208
+ * Triggers the confirm event of the dialog.
209
+ */
210
+ confirm: (event?: Event) => void
211
+ /**
212
+ * Triggers the cancel event of the dialog.
213
+ */
214
+ cancel: (event?: Event) => void
215
+ /**
216
+ * Closes the dialog using the index of the pressed button
217
+ */
218
+ close: (button: number, event?: Event) => void
219
+ /**
220
+ * If the dialog contains a form, return the current values of the form
221
+ */
222
+ getFormResult(): {
223
+ [key: string]: FormResultValue
224
+ }
225
+ /**
226
+ * Set the values of the dialog form inputs
227
+ */
228
+ setFormValues(values: {[key: string]: FormResultValue}): void
229
+ /**
230
+ * Delete the dialog object, causing it to be re-build from scratch on next open
231
+ */
232
+ delete(): void
159
233
  }
@@ -0,0 +1,37 @@
1
+ interface DisplaySlotOptions {
2
+ rotation?: ArrayVector3
3
+ translation?: ArrayVector3
4
+ scale?: ArrayVector3
5
+ mirror?: [boolean, boolean, boolean]
6
+ }
7
+
8
+ declare class DisplaySlot {
9
+ constructor(id: string, data: DisplaySlotOptions)
10
+ rotation: ArrayVector3
11
+ translation: ArrayVector3
12
+ scale: ArrayVector3
13
+ mirror: [boolean, boolean, boolean]
14
+ /**
15
+ * Reset slot to default values
16
+ */
17
+ default: () => this
18
+ extend: (data: DisplaySlotOptions) => this
19
+ copy: () => {
20
+ rotation: ArrayVector3
21
+ translation: ArrayVector3
22
+ scale: ArrayVector3
23
+ mirror: [boolean, boolean, boolean]
24
+ }
25
+ /**
26
+ * Generate the values of the slot for export
27
+ */
28
+ export: () => {
29
+ rotation: ArrayVector3
30
+ translation: ArrayVector3
31
+ scale: ArrayVector3
32
+ } | undefined
33
+ /**
34
+ * Visually update the UI with the data from this slot if selected
35
+ */
36
+ update: () => this
37
+ }
@@ -129,7 +129,7 @@ declare namespace Blockbench {
129
129
  /**
130
130
  * Whether or not to enable the drag handler
131
131
  */
132
- condition?: Condition
132
+ condition?: ConditionResolvable
133
133
  /**
134
134
  * Drop target element
135
135
  */
package/types/format.d.ts CHANGED
@@ -40,7 +40,7 @@ interface FormatOptions {
40
40
  category?: string
41
41
  target?: string | string[]
42
42
  confidential?: boolean
43
- condition?: Condition
43
+ condition?: ConditionResolvable
44
44
  show_on_start_screen?: boolean
45
45
  format_page?: FormatPage
46
46
  onFormatPage?(): void
@@ -92,7 +92,7 @@ declare class ModelFormat extends Deletable {
92
92
  category: string
93
93
  target: string | string[]
94
94
  confidential: boolean
95
- condition?: Condition
95
+ condition?: ConditionResolvable
96
96
  show_on_start_screen: boolean
97
97
  format_page?: FormatPage
98
98
  onFormatPage?(): void
@@ -155,7 +155,7 @@ interface ModelLoaderOptions {
155
155
  category?: string
156
156
  target?: string | string[]
157
157
  confidential?: boolean
158
- condition?: Condition
158
+ condition?: ConditionResolvable
159
159
  format_page?: FormatPage
160
160
  onFormatPage?(): void
161
161
  onStart?(): void
@@ -172,7 +172,7 @@ declare class ModelLoader extends Deletable {
172
172
  category: string
173
173
  target: string | string[]
174
174
  confidential: boolean
175
- condition?: Condition
175
+ condition?: ConditionResolvable
176
176
  show_on_start_screen: boolean
177
177
  format_page?: FormatPage
178
178
  onFormatPage?(): void