blockbench-types 4.2.0 → 4.3.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.2.0",
3
+ "version": "4.3.0",
4
4
  "description": "Blockbench typescript types",
5
5
  "main": "",
6
6
  "types": "types/index.d.ts",
package/types/canvas.d.ts CHANGED
@@ -48,18 +48,37 @@ declare const Canvas: {
48
48
  bones: {
49
49
  [uuid: UUID]: THREE.Object3D
50
50
  };
51
+ /**
52
+ * Main scene, shared across all tabs
53
+ */
54
+ scene: THREE.Scene
55
+ /**
56
+ * List of the gizmos (control and UI elements) in the 3D scene
57
+ */
58
+ gizmos: []
51
59
  /**
52
60
  * The material used for all selection outlines
53
61
  */
54
62
  outlineMaterial: THREE.LineBasicMaterial;
63
+ meshOutlineMaterial: THREE.LineBasicMaterial;
55
64
  /**
56
65
  * The material used for the wireframe view
57
66
  */
58
67
  wireframeMaterial: THREE.MeshBasicMaterial;
68
+ solidMaterial: THREE.ShaderMaterial;
69
+ normalHelperMaterial: THREE.ShaderMaterial;
70
+ uvHelperMaterial: THREE.ShaderMaterial;
71
+ meshVertexMaterial: THREE.PointsMaterial;
59
72
  /**
60
73
  * The material used for the grids
61
74
  */
62
75
  gridMaterial: THREE.LineBasicMaterial;
76
+
77
+ pivot_marker: THREE.Object3D
78
+
79
+ global_light_color: THREE.Color
80
+ global_light_side: number
81
+
63
82
  face_order: string[];
64
83
 
65
84
  /**
@@ -74,6 +93,8 @@ declare const Canvas: {
74
93
  * Clear all elements from the scene
75
94
  */
76
95
  clear(): void;
96
+ buildGrid(): void;
97
+ updateShading(): void;
77
98
  /**
78
99
  * Updates selected aspects of the preview
79
100
  * @param options
@@ -161,6 +182,10 @@ declare const Canvas: {
161
182
  * @param animation Whether to display the current animated texture frame
162
183
  */
163
184
  updateUV(cube: Cube, animation?: boolean): any;
185
+ /**
186
+ * Update the materials of marker colors if new colors were added
187
+ */
188
+ updateMarkerColorMaterials(): void;
164
189
  /**
165
190
  * Create an additional outline around the specified cubes
166
191
  * @param arr List of cubes to outline
@@ -0,0 +1,154 @@
1
+ interface DialogFormElement {
2
+ label: string
3
+ description?: string
4
+ type: 'text' | 'number' | 'checkbox' | 'select' | 'radio' | 'textarea' | 'vector' | 'color' | 'file' | 'folder' | 'save' | 'info'
5
+ nocolon?: boolean
6
+ readonly?: boolean
7
+ value?: any
8
+ placeholder?: string
9
+ text?: string
10
+ colorpicker?: any
11
+ min?: number
12
+ max?: number
13
+ step?: number
14
+ height?: number
15
+ options?: object
16
+ }
17
+
18
+ type FormResultValue = string|number|boolean|[]
19
+
20
+ interface ActionInterface {
21
+ name: string
22
+ description?: string
23
+ icon: string,
24
+ click: (event: Event) => void
25
+ condition: Condition
26
+ }
27
+ interface DialogOptions {
28
+ title: string
29
+ id: string
30
+ /**
31
+ * Default button to press to confirm the dialog. Defaults to the first button.
32
+ */
33
+ confirmIndex?: number
34
+ /**
35
+ * Default button to press to cancel the dialog. Defaults to the last button.
36
+ */
37
+ cancelIndex?: number
38
+ /**
39
+ * Function to execute when the user confirms the dialog
40
+ */
41
+ onConfirm?: (formResult: object) => void
42
+ /**
43
+ * Function to execute when the user cancels the dialog
44
+ */
45
+ onCancel?: () => void
46
+ /**
47
+ * Triggered when the user presses a specific button
48
+ */
49
+ onButton?: (button_index: number, event?: Event) => void
50
+ /**
51
+ * Function to run when anything in the form is changed
52
+ */
53
+ onFormChange?: (form_result: {[key: string]: FormResultValue}) => void
54
+ /**
55
+ * Array of HTML object strings for each line of content in the dialog.
56
+ */
57
+ lines?: (string|HTMLElement)[]
58
+ /**
59
+ * Creates a form in the dialog
60
+ */
61
+ form?: {
62
+ [formElement: string]: '_' | DialogFormElement
63
+ }
64
+ /**
65
+ * Vue component
66
+ */
67
+ component?: Vue.Component
68
+ /**
69
+ * Order that the different interface types appear in the dialog. Default is 'form', 'lines', 'component'.
70
+ */
71
+ part_order?: string[]
72
+ form_first?: boolean
73
+ /**
74
+ * Creates a dialog sidebar
75
+ */
76
+ sidebar?: DialogSidebarOptions
77
+ /**
78
+ * Menu in the handle bar
79
+ */
80
+ title_menu?: Menu
81
+ /**
82
+ * If true, the dialog will only have one button to close it
83
+ */
84
+ singleButton?: boolean
85
+ /**
86
+ * List of buttons
87
+ */
88
+ buttons?: string[]
89
+ }
90
+
91
+ interface DialogSidebarOptions {
92
+ pages?: {
93
+ [key: string]: string | {label: string, icon: IconString, color?: string}
94
+ }
95
+ page?: string
96
+ actions?: (Action|ActionInterface|string)[],
97
+ onPageSwitch?: (page: string) => void
98
+ }
99
+ declare class DialogSidebar {
100
+ constructor(options: DialogSidebarOptions)
101
+
102
+ pages: {
103
+ [key: string]: string
104
+ }
105
+ page: string
106
+ actions: (Action|string)[]
107
+ onPageSwitch(page: string): void
108
+ build(): void
109
+ toggle(state?: boolean): void
110
+ setPage(page: string): void
111
+ }
112
+
113
+ declare class Dialog {
114
+ constructor (options: DialogOptions)
115
+
116
+ id: string
117
+ component: Vue.Component
118
+ sidebar: DialogSidebar | null
119
+
120
+
121
+ show: () => Dialog
122
+ hide: () => Dialog
123
+ /**
124
+ * Triggers the confirm event of the dialog.
125
+ */
126
+ confirm: (event?: Event) => void
127
+ /**
128
+ * Triggers the cancel event of the dialog.
129
+ */
130
+ cancel: (event?: Event) => void
131
+ /**
132
+ * Closes the dialog using the index of the pressed button
133
+ */
134
+ close: (button: number, event?: Event) => void
135
+ /**
136
+ * If the dialog contains a form, return the current values of the form
137
+ */
138
+ getFormResult(): {
139
+ [key: string]: FormResultValue
140
+ }
141
+ /**
142
+ * Set the values of the dialog form inputs
143
+ */
144
+ setFormValues(values: {[key: string]: FormResultValue}): void
145
+ /**
146
+ * Delete the dialog object, causing it to be re-build from scratch on next open
147
+ */
148
+ delete(): void
149
+
150
+ /**
151
+ * Currently opened dialog
152
+ */
153
+ static open: Dialog | null
154
+ }
@@ -135,7 +135,7 @@ declare namespace Blockbench {
135
135
  */
136
136
  propagate?: boolean
137
137
  }
138
- export function addDragHandler(id: string, options: DragHandlerOptions, callback?: () => void): void
138
+ export function addDragHandler(id: string, options: DragHandlerOptions, callback?: () => void): Deletable
139
139
  export function removeDragHandler(id: string): void
140
140
 
141
141
  }
package/types/format.d.ts CHANGED
@@ -1,9 +1,28 @@
1
+ interface FormatPage {
2
+ component?: Vue.Component
3
+ content?: ({
4
+ type: 'image' | 'h2' | 'h3' | 'h4' | 'text' | 'label' | 'image' | ''
5
+ text?: string
6
+ source?: string
7
+ width?: number
8
+ height?: number
9
+ } | string)[]
10
+ button_text?: string
11
+ }
12
+
1
13
  interface FormatOptions {
2
14
  id: string
3
15
  icon: string
4
16
  name?: string
5
17
  description?: string
18
+ category?: string
19
+ target?: string | string[]
20
+ confidential?: boolean
21
+ condition?: Condition
6
22
  show_on_start_screen?: boolean
23
+ format_page?: FormatPage
24
+ onFormatPage?(): void
25
+ onStart?(): void
7
26
 
8
27
  box_uv?: boolean
9
28
  optional_box_uv?: boolean
@@ -31,28 +50,47 @@ interface FormatOptions {
31
50
  }
32
51
 
33
52
  declare class ModelFormat extends Deletable {
53
+ constructor(id: string, options: FormatOptions)
34
54
  constructor(options: FormatOptions)
35
55
 
36
56
  id: string
37
57
  icon: string
38
- name?: string
39
- description?: string
40
- show_on_start_screen?: boolean
58
+ name: string
59
+ description: string
60
+ category: string
61
+ target: string | string[]
62
+ confidential: boolean
63
+ condition?: Condition
64
+ show_on_start_screen: boolean
65
+ format_page?: FormatPage
66
+ onFormatPage?(): void
67
+ onStart?(): void
41
68
 
42
69
  box_uv: boolean
43
70
  optional_box_uv: boolean
44
71
  single_texture: boolean
72
+ model_identifier: boolean
73
+ parent_model_id: boolean
74
+ vertex_color_ambient_occlusion: boolean
45
75
  animated_textures: boolean
46
76
  bone_rig: boolean
47
77
  centered_grid: boolean
48
78
  rotate_cubes: boolean
49
79
  integer_size: boolean
80
+ meshes: boolean
81
+ texture_meshes: boolean
50
82
  locators: boolean
51
83
  canvas_limit: boolean
52
84
  rotation_limit: boolean
53
85
  uv_rotation: boolean
86
+ java_face_properties: boolean
87
+ select_texture_for_particles: boolean
88
+ bone_binding_expression: boolean
89
+ animation_files: boolean
90
+ pose_mode: boolean
54
91
  display_mode: boolean
55
92
  animation_mode: boolean
93
+ texture_folder: boolean
56
94
 
57
95
  /**
58
96
  * Selects the format
@@ -72,3 +110,36 @@ declare class ModelFormat extends Deletable {
72
110
  * The current format
73
111
  */
74
112
  declare const Format: ModelFormat
113
+
114
+
115
+ interface ModelLoaderOptions {
116
+ id?: string
117
+ icon: string
118
+ name?: string
119
+ description?: string
120
+ category?: string
121
+ target?: string | string[]
122
+ confidential?: boolean
123
+ condition?: Condition
124
+ format_page?: FormatPage
125
+ onFormatPage?(): void
126
+ onStart?(): void
127
+ }
128
+
129
+ declare class ModelLoader extends Deletable {
130
+ constructor(id: string, options: ModelLoaderOptions)
131
+ constructor(options: ModelLoaderOptions)
132
+
133
+ id: string
134
+ icon: string
135
+ name: string
136
+ description: string
137
+ category: string
138
+ target: string | string[]
139
+ confidential: boolean
140
+ condition?: Condition
141
+ show_on_start_screen: boolean
142
+ format_page?: FormatPage
143
+ onFormatPage?(): void
144
+ onStart?(): void
145
+ }
package/types/index.d.ts CHANGED
@@ -11,6 +11,7 @@
11
11
  /// <reference types="./format" />
12
12
  /// <reference types="./global" />
13
13
  /// <reference types="./interface" />
14
+ /// <reference types="./dialog" />
14
15
  /// <reference types="./panel" />
15
16
  /// <reference types="./keyframe" />
16
17
  /// <reference types="./legacy" />
@@ -55,7 +56,10 @@ type EventName = 'remove_animation'
55
56
  | 'reset_project'
56
57
  | 'close_project'
57
58
  | 'add_cube'
59
+ | 'add_mesh'
58
60
  | 'add_group'
61
+ | 'add_texture_mesh'
62
+ | 'group_elements'
59
63
  | 'update_selection'
60
64
  | 'update_keyframe_selection'
61
65
  | 'select_all'
@@ -72,6 +76,19 @@ type EventName = 'remove_animation'
72
76
  | 'load_undo_save'
73
77
  | 'select_mode'
74
78
  | 'unselect_mode'
79
+ | 'change_active_panel'
80
+ | 'resize_window'
81
+ | 'press_key'
82
+ | 'convert_format'
83
+ | 'select_project'
84
+ | 'unselect_project'
85
+ | 'setup_project'
86
+ | 'update_project_resolution'
87
+ | 'update_project_settings'
88
+ | 'merge_project'
89
+ | 'update_view'
90
+ | 'update_camera_position'
91
+ | 'render_frame'
75
92
 
76
93
  type IconString = string;
77
94
 
@@ -1,154 +1,81 @@
1
- interface DialogFormElement {
2
- label: string
3
- description?: string
4
- type: 'text' | 'number' | 'checkbox' | 'select' | 'radio' | 'textarea' | 'vector' | 'color' | 'file' | 'folder' | 'save' | 'info'
5
- nocolon?: boolean
6
- readonly?: boolean
7
- value?: any
8
- placeholder?: string
9
- text?: string
10
- colorpicker?: any
11
- min?: number
12
- max?: number
13
- step?: number
14
- height?: number
15
- options?: object
1
+ interface ResizeLineOptions {
2
+ condition?: Condition
3
+ horizontal?: boolean
4
+ position(): void
5
+ get(): void
6
+ set(): void
16
7
  }
8
+ declare class ResizeLine {
9
+ constructor(id: string, options: ResizeLineOptions)
17
10
 
18
- type FormResultValue = string|number|boolean|[]
19
-
20
- interface ActionInterface {
21
- name: string
22
- description?: string
23
- icon: string,
24
- click: (event: Event) => void
25
- condition: Condition
26
- }
27
- interface DialogOptions {
28
- title: string
29
11
  id: string
30
- /**
31
- * Default button to press to confirm the dialog. Defaults to the first button.
32
- */
33
- confirmIndex?: number
34
- /**
35
- * Default button to press to cancel the dialog. Defaults to the last button.
36
- */
37
- cancelIndex?: number
38
- /**
39
- * Function to execute when the user confirms the dialog
40
- */
41
- onConfirm?: (formResult: object) => void
42
- /**
43
- * Function to execute when the user cancels the dialog
44
- */
45
- onCancel?: () => void
46
- /**
47
- * Triggered when the user presses a specific button
48
- */
49
- onButton?: (button_index: number, event?: Event) => void
50
- /**
51
- * Function to run when anything in the form is changed
52
- */
53
- onFormChange?: (form_result: {[key: string]: FormResultValue}) => void
54
- /**
55
- * Array of HTML object strings for each line of content in the dialog.
56
- */
57
- lines?: (string|HTMLElement)[]
58
- /**
59
- * Creates a form in the dialog
60
- */
61
- form?: {
62
- [formElement: string]: '_' | DialogFormElement
63
- }
64
- /**
65
- * Vue component
66
- */
67
- component?: Vue.Component
68
- /**
69
- * Order that the different interface types appear in the dialog. Default is 'form', 'lines', 'component'.
70
- */
71
- part_order?: string[]
72
- form_first?: boolean
73
- /**
74
- * Creates a dialog sidebar
75
- */
76
- sidebar?: DialogSidebarOptions
77
- /**
78
- * Menu in the handle bar
79
- */
80
- title_menu?: Menu
81
- /**
82
- * If true, the dialog will only have one button to close it
83
- */
84
- singleButton?: boolean
85
- /**
86
- * List of buttons
87
- */
88
- buttons?: string[]
12
+ horizontal: boolean
13
+ condition?: Condition
14
+ width: number
15
+ get(): void
16
+ set(): void
17
+ node: HTMLElement
18
+ update(): void
19
+ setPosition(data: {top?: number, bottom?: number, left?: number, right?: number}): void
89
20
  }
90
21
 
91
- interface DialogSidebarOptions {
92
- pages?: {
93
- [key: string]: string | {label: string, icon: IconString, color?: string}
94
- }
95
- page?: string
96
- actions?: (Action|ActionInterface|string)[],
97
- onPageSwitch?: (page: string) => void
98
- }
99
- declare class DialogSidebar {
100
- constructor(options: DialogSidebarOptions)
22
+ declare namespace Interface {
23
+ function createElement(type: keyof HTMLElementTagNameMap, attributes?: {}, content?: string | HTMLElement | HTMLElement[]): HTMLElement
101
24
 
102
- pages: {
103
- [key: string]: string
25
+ const data: {
26
+ left_bar_width: number
27
+ right_bar_width: number
28
+ quad_view_x: number
29
+ quad_view_y: number
30
+ timeline_head: number
31
+ left_bar: string[]
32
+ right_bar: string[]
104
33
  }
105
- page: string
106
- actions: (Action|string)[]
107
- onPageSwitch(page: string): void
108
- build(): void
109
- toggle(state?: boolean): void
110
- setPage(page: string): void
111
- }
34
+ let left_bar_width: number
35
+ let right_bar_width: number
36
+ let top_panel_height: number
37
+ let bottom_panel_height: number
38
+ function getTopPanel(): Panel[]
39
+ function getBottomPanel(): Panel[]
40
+ function getLeftPanels(): Panel[]
41
+ function getRightPanels(): Panel[]
42
+ const Resizers: {
43
+ left: ResizeLine
44
+ right: ResizeLine
45
+ quad_view_x: ResizeLine
46
+ quad_view_y: ResizeLine
47
+ top: ResizeLine
48
+ bottom: ResizeLine
49
+ timeline_head: ResizeLine
50
+ }
51
+ const status_bar: {
52
+ menu: Menu
53
+ vue: Vue
54
+ }
55
+ const Panels: {
56
+ (key: string): Panel
57
+ }
58
+ function toggleSidebar(side, status): void
112
59
 
113
- declare class Dialog {
114
- constructor (options: DialogOptions)
60
+ const text_edit_menu: Menu
115
61
 
116
- id: string
117
- component: Vue.Component
118
- sidebar: DialogSidebar | null
62
+ function addSuggestedModifierKey(key: 'ctrl' | 'shift' | 'alt', text: string): void
63
+ function removeSuggestedModifierKey(key: 'ctrl' | 'shift' | 'alt', text: string): void
119
64
 
65
+ const center_screen: HTMLElement
66
+ const page_wrapper: HTMLElement
67
+ const preview: HTMLElement
68
+ const work_screen: HTMLElement
69
+ const right_bar: HTMLElement
70
+ const left_bar: HTMLElement
120
71
 
121
- show: () => Dialog
122
- hide: () => Dialog
123
- /**
124
- * Triggers the confirm event of the dialog.
125
- */
126
- confirm: (event?: Event) => void
127
- /**
128
- * Triggers the cancel event of the dialog.
129
- */
130
- cancel: (event?: Event) => void
131
- /**
132
- * Closes the dialog using the index of the pressed button
133
- */
134
- close: (button: number, event?: Event) => void
135
- /**
136
- * If the dialog contains a form, return the current values of the form
137
- */
138
- getFormResult(): {
139
- [key: string]: FormResultValue
72
+ namespace CustomElements {
73
+ function SelectInput(id: string, options: {
74
+ value?: string
75
+ default?: string
76
+ options: {key: string, value: string}
77
+ onChange?(): void
78
+ }): HTMLElement
79
+ const ResizeLine;
140
80
  }
141
- /**
142
- * Set the values of the dialog form inputs
143
- */
144
- setFormValues(values: {[key: string]: FormResultValue}): void
145
- /**
146
- * Delete the dialog object, causing it to be re-build from scratch on next open
147
- */
148
- delete(): void
149
-
150
- /**
151
- * Currently opened dialog
152
- */
153
- static open: Dialog | null
154
81
  }
package/types/menu.d.ts CHANGED
@@ -62,9 +62,12 @@ declare namespace MenuBar {
62
62
  file: Menu
63
63
  edit: Menu
64
64
  transform: Menu
65
- display: Menu
66
- filter: Menu
65
+ uv: Menu
66
+ texture: Menu
67
67
  animation: Menu
68
+ keyframe: Menu
69
+ display: Menu
70
+ tools: Menu
68
71
  view: Menu
69
72
  help: Menu
70
73
  [id: string]: Menu
@@ -1,3 +1,4 @@
1
+ type ArrayVector4 = [number, number, number, number]
1
2
  type ArrayVector3 = [number, number, number]
2
3
  type ArrayVector2 = [number, number]
3
4
 
@@ -0,0 +1,109 @@
1
+ interface PreviewModelCubeTemplate {
2
+ position: ArrayVector3
3
+ size: ArrayVector3
4
+ origin?: ArrayVector3
5
+ rotation?: ArrayVector3
6
+ faces: {
7
+ north?: {uv: ArrayVector4}
8
+ east?: {uv: ArrayVector4}
9
+ west?: {uv: ArrayVector4}
10
+ south?: {uv: ArrayVector4}
11
+ up?: {uv: ArrayVector4}
12
+ down?: {uv: ArrayVector4}
13
+ }
14
+ }
15
+
16
+ interface PreviewModelOptions {
17
+ condition?: Condition
18
+ cubes: PreviewModelCubeTemplate[]
19
+ /**
20
+ * Source of the model's texture
21
+ */
22
+ texture?: string
23
+ /**
24
+ * Model tint color
25
+ */
26
+ color?: string
27
+ /**
28
+ * Enable shading on the material
29
+ */
30
+ shading?: boolean
31
+ /**
32
+ * THREE.JS material render side
33
+ */
34
+ render_side?: number
35
+ texture_size?: [number, number]
36
+ onUpdate?(): void
37
+ }
38
+
39
+ declare class PreviewModel extends Deletable {
40
+ constructor(id: string, options: PreviewModelOptions)
41
+
42
+ static models: {
43
+ (id: string): PreviewModel
44
+ }
45
+ static getActiveModels(): PreviewModel[]
46
+
47
+ id: string
48
+ model_3d: THREE.Object3D
49
+ cubes: PreviewModelCubeTemplate[]
50
+ texture?: string
51
+ color?: string
52
+ shading: boolean
53
+ render_side: number
54
+ texture_size: [number, number]
55
+ onUpdate?:() => void
56
+ /**
57
+ * Enables the model in the preview
58
+ */
59
+ enable(): void
60
+ /**
61
+ * Disables the model in the preview
62
+ */
63
+ disable(): boolean
64
+ /**
65
+ * Update the appearance and visibility of the model
66
+ */
67
+ update(): void
68
+ buildModel(): void
69
+ }
70
+
71
+
72
+
73
+ interface PreviewSceneOptions {
74
+ name?: string
75
+ description?: string
76
+ light_color?: string
77
+ light_side?: number
78
+ condition?: Condition
79
+ preview_models?: string[]
80
+ }
81
+
82
+ declare class PreviewScene extends Deletable {
83
+ constructor(id: string, options: PreviewSceneOptions)
84
+
85
+ static scenes: {
86
+ (id: string): PreviewScene
87
+ }
88
+ static active: PreviewScene | null
89
+ select_options: {
90
+ (id: string): string
91
+ }
92
+
93
+ id: string
94
+ name: string
95
+ description: string
96
+ light_color: string
97
+ light_side: number
98
+ condition?: Condition
99
+ preview_models: string[]
100
+
101
+ /**
102
+ * Selects this preview scene
103
+ */
104
+ select(): void
105
+ /**
106
+ * Unselects this preview scene
107
+ */
108
+ unselect(): void
109
+ }
@@ -11,6 +11,7 @@ declare class ModelProject {
11
11
  name: string
12
12
  uuid: UUID
13
13
  selected: boolean
14
+ model_identifier: string
14
15
  /**
15
16
  * When set to true, the project tab can no longer be selected or unselected
16
17
  */