blockbench-types 4.6.1 → 4.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/scripts/generate_docs.js +9 -7
- package/types/action.d.ts +42 -2
- package/types/animation.d.ts +37 -17
- package/types/animation_controller.d.ts +8 -2
- package/types/blockbench.d.ts +45 -5
- package/types/canvas.d.ts +13 -0
- package/types/canvas_frame.d.ts +21 -0
- package/types/codec.d.ts +31 -0
- package/types/cube.d.ts +4 -1
- package/types/dialog.d.ts +23 -1
- package/types/display_mode.d.ts +7 -0
- package/types/format.d.ts +2 -0
- package/types/global.d.ts +28 -0
- package/types/group.d.ts +2 -0
- package/types/io.d.ts +2 -0
- package/types/keyframe.d.ts +29 -4
- package/types/math_util.d.ts +1 -0
- package/types/menu.d.ts +5 -2
- package/types/mesh.d.ts +6 -1
- package/types/misc.d.ts +25 -4
- package/types/mode.d.ts +1 -0
- package/types/outliner.d.ts +13 -0
- package/types/painter.d.ts +3 -1
- package/types/panel.d.ts +19 -4
- package/types/plugin.d.ts +5 -1
- package/types/preview.d.ts +4 -1
- package/types/project.d.ts +16 -2
- package/types/screencam.d.ts +3 -0
- package/types/settings.d.ts +53 -5
- package/types/shared_actions.d.ts +78 -0
- package/types/texture_layers.d.ts +118 -0
- package/types/textures.d.ts +246 -1
- package/types/timeline.d.ts +2 -2
- package/types/undo.d.ts +5 -5
- package/types/util.d.ts +32 -0
- package/types/validator.d.ts +35 -0
package/types/keyframe.d.ts
CHANGED
|
@@ -1,11 +1,26 @@
|
|
|
1
|
+
interface KeyframeDataPointData {
|
|
2
|
+
[key: string]: any
|
|
3
|
+
}
|
|
1
4
|
declare class KeyframeDataPoint {
|
|
2
5
|
constructor(keyframe: _Keyframe);
|
|
3
|
-
extend(data:
|
|
4
|
-
getUndoCopy(): {
|
|
6
|
+
extend(data: KeyframeDataPointData): void;
|
|
7
|
+
getUndoCopy(): {
|
|
8
|
+
[key: string]: any
|
|
9
|
+
};
|
|
5
10
|
}
|
|
6
11
|
|
|
7
12
|
interface KeyframeOptions {
|
|
8
|
-
|
|
13
|
+
channel?: string
|
|
14
|
+
data_points: {}[]
|
|
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
|
|
9
24
|
}
|
|
10
25
|
type axisLetter = 'x' | 'y' | 'z'
|
|
11
26
|
|
|
@@ -13,6 +28,14 @@ declare class _Keyframe {
|
|
|
13
28
|
constructor(options: KeyframeOptions, uuid: any);
|
|
14
29
|
|
|
15
30
|
animator: GeneralAnimator;
|
|
31
|
+
|
|
32
|
+
channel: string
|
|
33
|
+
data_points: KeyframeDataPoint[]
|
|
34
|
+
time: number
|
|
35
|
+
color: number
|
|
36
|
+
uniform: boolean
|
|
37
|
+
interpolation: 'linear' | 'catmullrom' | 'bezier' | 'step' | string
|
|
38
|
+
bezier_linked: boolean
|
|
16
39
|
bezier_left_time: ArrayVector3;
|
|
17
40
|
bezier_right_time: ArrayVector3;
|
|
18
41
|
bezier_left_value: ArrayVector3;
|
|
@@ -42,4 +65,6 @@ declare class _Keyframe {
|
|
|
42
65
|
channel?: string | null;
|
|
43
66
|
data_points: object[];
|
|
44
67
|
};
|
|
45
|
-
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
declare function updateKeyframeSelection(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare function guid(): string;
|
package/types/menu.d.ts
CHANGED
|
@@ -22,6 +22,9 @@ interface MenuOptions {
|
|
|
22
22
|
keep_open?: boolean
|
|
23
23
|
searchable?: boolean
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Use the Menu class to create a context menu. Menus can contain custom entries and hierarchy, or existing actions and tools.
|
|
27
|
+
*/
|
|
25
28
|
declare class Menu extends Deletable {
|
|
26
29
|
constructor(id: string, template: MenuItem[] | ((context?: any) => MenuItem[]), options?: MenuOptions)
|
|
27
30
|
constructor(template: MenuItem[] | ((context?: any) => MenuItem[]), options?: MenuOptions)
|
|
@@ -78,12 +81,12 @@ declare namespace MenuBar {
|
|
|
78
81
|
/**
|
|
79
82
|
* Adds an action to the menu structure
|
|
80
83
|
* @param action Action to add
|
|
81
|
-
* @param path Path pointing to the location. Use the ID of each level of the menu, or index within a level, separated by a point. For example, `file.export.0` places the action at the top position of the Export submenu in the File menu.
|
|
84
|
+
* @param path Path pointing to the location. Use the ID of each level of the menu, or index or group within a level, separated by a point. For example, `file.export.0` places the action at the top position of the Export submenu in the File menu.
|
|
82
85
|
*/
|
|
83
86
|
function addAction(action: Action, path?: string): void
|
|
84
87
|
/**
|
|
85
88
|
*
|
|
86
|
-
* @param path Path pointing to the location. Use the ID of each level of the menu, or index within a level, or item ID, separated by a point. For example, `export.export_special_format` removes the action "Export Special Format" from the Export submenu.
|
|
89
|
+
* @param path Path pointing to the location. Use the ID of each level of the menu, or index or group within a level, or item ID, separated by a point. For example, `export.export_special_format` removes the action "Export Special Format" from the Export submenu.
|
|
87
90
|
*/
|
|
88
91
|
function removeAction(path: string)
|
|
89
92
|
/**
|
package/types/mesh.d.ts
CHANGED
|
@@ -71,10 +71,15 @@ declare class Mesh extends OutlinerElement {
|
|
|
71
71
|
|
|
72
72
|
static all: Mesh[]
|
|
73
73
|
static selected: Mesh[]
|
|
74
|
+
/**Check if any elements of the type are in the project */
|
|
75
|
+
static hasAny: () => boolean
|
|
76
|
+
/**Check if any elements of the type are currently selected */
|
|
77
|
+
static hasSelected: () => boolean
|
|
74
78
|
}
|
|
75
79
|
|
|
76
80
|
interface MeshFaceOptions extends FaceOptions {
|
|
77
|
-
|
|
81
|
+
vertices: string[]
|
|
82
|
+
uv: {[vkey: string]: ArrayVector2}
|
|
78
83
|
}
|
|
79
84
|
declare class MeshFace extends Face {
|
|
80
85
|
constructor(mesh: Mesh, data: MeshFaceOptions)
|
package/types/misc.d.ts
CHANGED
|
@@ -29,12 +29,16 @@ type EventName = 'remove_animation'
|
|
|
29
29
|
| 'reset_project'
|
|
30
30
|
| 'close_project'
|
|
31
31
|
| 'saved_state_changed'
|
|
32
|
+
| 'save_model_action'
|
|
32
33
|
| 'add_cube'
|
|
33
34
|
| 'add_mesh'
|
|
34
35
|
| 'add_group'
|
|
35
36
|
| 'add_texture_mesh'
|
|
36
37
|
| 'group_elements'
|
|
37
38
|
| 'update_selection'
|
|
39
|
+
| 'compile_bedrock_animations'
|
|
40
|
+
| 'load_animation'
|
|
41
|
+
| 'load_animation_controller'
|
|
38
42
|
| 'update_keyframe_selection'
|
|
39
43
|
| 'select_all'
|
|
40
44
|
| 'added_to_selection'
|
|
@@ -96,12 +100,22 @@ interface MessageBoxOptions {
|
|
|
96
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.
|
|
97
101
|
*/
|
|
98
102
|
commands?: {
|
|
99
|
-
[id: string]: string | {text: string}
|
|
103
|
+
[id: string]: string | {text: string, icon?: IconString, condition?: ConditionResolvable}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Adds checkboxes to the bottom of the message box
|
|
107
|
+
*/
|
|
108
|
+
checkboxes: {
|
|
109
|
+
[id: string]: string | {
|
|
110
|
+
value?: boolean
|
|
111
|
+
condition: ConditionResolvable
|
|
112
|
+
text: string
|
|
113
|
+
}
|
|
100
114
|
}
|
|
101
115
|
}
|
|
102
116
|
|
|
103
117
|
|
|
104
|
-
|
|
118
|
+
type PropertyType = 'string' | 'number' | 'enum' | 'molang' | 'boolean' | 'array' | 'instance' | 'vector' | 'vector2'
|
|
105
119
|
interface PropertyOptions {
|
|
106
120
|
default?: any
|
|
107
121
|
condition?: ConditionResolvable
|
|
@@ -111,6 +125,10 @@ interface PropertyOptions {
|
|
|
111
125
|
* Options used for select types
|
|
112
126
|
*/
|
|
113
127
|
options?: object
|
|
128
|
+
/**
|
|
129
|
+
* Enum possible values
|
|
130
|
+
*/
|
|
131
|
+
values: string[]
|
|
114
132
|
merge?: (instance: any, data: object) => void
|
|
115
133
|
reset?: (instance: any) => void
|
|
116
134
|
merge_validation?: (value: any) => boolean
|
|
@@ -119,20 +137,23 @@ interface PropertyOptions {
|
|
|
119
137
|
* Creates a new property on the specified target class
|
|
120
138
|
*/
|
|
121
139
|
declare class Property extends Deletable {
|
|
122
|
-
constructor(target_class: any, type:
|
|
140
|
+
constructor(target_class: any, type: PropertyType, name: string, options?: PropertyOptions);
|
|
123
141
|
class: any;
|
|
124
142
|
name: string;
|
|
125
|
-
type:
|
|
143
|
+
type: PropertyType;
|
|
126
144
|
default: any;
|
|
127
145
|
|
|
128
146
|
isString: boolean;
|
|
147
|
+
isEnum: boolean;
|
|
129
148
|
isMolang: boolean;
|
|
130
149
|
isNumber: boolean;
|
|
131
150
|
isBoolean: boolean;
|
|
132
151
|
isArray: boolean;
|
|
133
152
|
isVector: boolean;
|
|
134
153
|
isVector2: boolean;
|
|
154
|
+
isInstance: boolean;
|
|
135
155
|
|
|
156
|
+
enum_values?: string[]
|
|
136
157
|
merge_validation: undefined | ((value: any) => boolean);
|
|
137
158
|
condition: ConditionResolvable;
|
|
138
159
|
exposed: boolean;
|
package/types/mode.d.ts
CHANGED
package/types/outliner.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ type ArrayVector2 = [number, number]
|
|
|
9
9
|
declare class OutlinerNode {
|
|
10
10
|
constructor ()
|
|
11
11
|
uuid: UUID
|
|
12
|
+
name: string
|
|
12
13
|
export: boolean
|
|
13
14
|
locked: boolean
|
|
14
15
|
parent: Group | 'root'
|
|
@@ -53,6 +54,10 @@ declare class OutlinerNode {
|
|
|
53
54
|
* @param event Mouse event, determines where the context menu spawns.
|
|
54
55
|
*/
|
|
55
56
|
showContexnu(event: Event | HTMLElement): this
|
|
57
|
+
|
|
58
|
+
static uuids: {
|
|
59
|
+
[uuid: UUID]: OutlinerNode
|
|
60
|
+
}
|
|
56
61
|
}
|
|
57
62
|
|
|
58
63
|
/**
|
|
@@ -81,6 +86,10 @@ declare class Locator extends OutlinerElement {
|
|
|
81
86
|
|
|
82
87
|
static all: Locator[]
|
|
83
88
|
static selected: Locator[]
|
|
89
|
+
/**Check if any elements of the type are in the project */
|
|
90
|
+
static hasAny: () => boolean
|
|
91
|
+
/**Check if any elements of the type are currently selected */
|
|
92
|
+
static hasSelected: () => boolean
|
|
84
93
|
}
|
|
85
94
|
|
|
86
95
|
|
|
@@ -103,6 +112,10 @@ declare class NullObject extends OutlinerElement {
|
|
|
103
112
|
|
|
104
113
|
static all: NullObject[]
|
|
105
114
|
static selected: NullObject[]
|
|
115
|
+
/**Check if any elements of the type are in the project */
|
|
116
|
+
static hasAny: () => boolean
|
|
117
|
+
/**Check if any elements of the type are currently selected */
|
|
118
|
+
static hasSelected: () => boolean
|
|
106
119
|
}
|
|
107
120
|
|
|
108
121
|
|
package/types/painter.d.ts
CHANGED
package/types/panel.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
type PanelSlot = 'left_bar' | 'right_bar' | 'top' | 'bottom' | 'float'
|
|
2
|
+
|
|
1
3
|
interface PanelOptions {
|
|
2
4
|
id: string
|
|
3
5
|
name: string
|
|
@@ -10,9 +12,9 @@ interface PanelOptions {
|
|
|
10
12
|
expand_button: boolean
|
|
11
13
|
toolbars: {
|
|
12
14
|
[id: string]: Toolbar
|
|
13
|
-
}
|
|
15
|
+
} | Toolbar[]
|
|
14
16
|
default_position: {
|
|
15
|
-
slot:
|
|
17
|
+
slot: PanelSlot
|
|
16
18
|
float_position: [number, number]
|
|
17
19
|
float_size: [number, number]
|
|
18
20
|
height: number
|
|
@@ -27,25 +29,38 @@ interface PanelOptions {
|
|
|
27
29
|
}
|
|
28
30
|
type PanelEvent = 'drag' | 'fold' | 'change_zindex' | 'move_to' | 'moved_to' | 'update'
|
|
29
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Panels are interface sections in Blockbench, that are always visible (in a specific format and mode), and can be added to the sidebars, above or below the 3D viewport, or used as free floating above the UI. Examples are the Outliner or the UV editor.
|
|
34
|
+
*/
|
|
30
35
|
declare class Panel {
|
|
31
36
|
constructor (id: string, options: PanelOptions)
|
|
32
37
|
constructor (options: PanelOptions)
|
|
33
38
|
isVisible(): boolean
|
|
34
39
|
isInSidebar(): boolean
|
|
35
|
-
slot:
|
|
40
|
+
slot: PanelSlot
|
|
36
41
|
folded: boolean
|
|
42
|
+
inside_vue: Vue
|
|
43
|
+
|
|
44
|
+
|
|
37
45
|
fold(state?: boolean): this
|
|
38
46
|
/**
|
|
39
47
|
* If the panel is floating, move it up to the front
|
|
40
48
|
*/
|
|
41
49
|
moveToFront(): this
|
|
42
|
-
moveTo(slot:
|
|
50
|
+
moveTo(slot: PanelSlot, ref_panel?: Panel, before?: boolean): this
|
|
43
51
|
update(dragging?: boolean): this
|
|
44
52
|
dispatchEvent(event_name: PanelEvent, data?: any): void
|
|
45
53
|
/**
|
|
46
54
|
* Add an event listener
|
|
47
55
|
*/
|
|
48
56
|
on(event_name: PanelEvent, callback: (data?) => void): void
|
|
57
|
+
/**
|
|
58
|
+
* Adds a single-use event listener
|
|
59
|
+
*/
|
|
60
|
+
once(event_name: PanelEvent, callback: (data?) => void): void
|
|
61
|
+
/**
|
|
62
|
+
* Removes an event listener
|
|
63
|
+
*/
|
|
49
64
|
removeListener(event_name: PanelEvent, callback: (data?) => void): void
|
|
50
65
|
delete(): void
|
|
51
66
|
}
|
package/types/plugin.d.ts
CHANGED
|
@@ -29,7 +29,11 @@ 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?:
|
|
32
|
+
await_loading?: boolean
|
|
33
|
+
/**
|
|
34
|
+
* Use the new repository format where plugin, iron, and about are stored in a separate folder
|
|
35
|
+
*/
|
|
36
|
+
new_repository_format?: boolean
|
|
33
37
|
/**
|
|
34
38
|
* Runs when the plugin loads
|
|
35
39
|
*/
|
package/types/preview.d.ts
CHANGED
|
@@ -20,9 +20,12 @@ type RaycastResult = {
|
|
|
20
20
|
intersects?: object[]
|
|
21
21
|
face?: string
|
|
22
22
|
vertex: any
|
|
23
|
-
keyframe:
|
|
23
|
+
keyframe: _Keyframe
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Previews are 3D viewports, that can either be used as a viewport for the user, or as an offscreen view to record media.
|
|
28
|
+
*/
|
|
26
29
|
declare class Preview extends Deletable {
|
|
27
30
|
constructor(options: PreviewOptions)
|
|
28
31
|
|
package/types/project.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ interface ModelProjectOptions {
|
|
|
2
2
|
format: ModelFormat
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* A project instance. The tab bar can be used to switch between projects.
|
|
7
|
+
*/
|
|
5
8
|
declare class ModelProject {
|
|
6
9
|
constructor(options: ModelProjectOptions)
|
|
7
10
|
|
|
@@ -12,6 +15,7 @@ declare class ModelProject {
|
|
|
12
15
|
uuid: UUID
|
|
13
16
|
selected: boolean
|
|
14
17
|
model_identifier: string
|
|
18
|
+
parent: string
|
|
15
19
|
/**
|
|
16
20
|
* When set to true, the project tab can no longer be selected or unselected
|
|
17
21
|
*/
|
|
@@ -53,7 +57,7 @@ declare class ModelProject {
|
|
|
53
57
|
textures: Texture[]
|
|
54
58
|
selected_texture: Texture | null;
|
|
55
59
|
outliner: OutlinerNode[]
|
|
56
|
-
animations:
|
|
60
|
+
animations: _Animation[]
|
|
57
61
|
timeline_animators: []
|
|
58
62
|
display_settings: {
|
|
59
63
|
[slot: string]: {
|
|
@@ -61,8 +65,12 @@ declare class ModelProject {
|
|
|
61
65
|
rotation: [number, number, number]
|
|
62
66
|
scale: [number, number, number]
|
|
63
67
|
mirror: [boolean, boolean, boolean]
|
|
68
|
+
export(): void;
|
|
64
69
|
}
|
|
65
70
|
};
|
|
71
|
+
ambientocclusion: boolean;
|
|
72
|
+
front_gui_light: boolean;
|
|
73
|
+
overrides: any;
|
|
66
74
|
|
|
67
75
|
get model_3d(): THREE.Object3D;
|
|
68
76
|
get materials(): {
|
|
@@ -82,13 +90,19 @@ declare class ModelProject {
|
|
|
82
90
|
static all: ModelProject[]
|
|
83
91
|
}
|
|
84
92
|
|
|
85
|
-
|
|
93
|
+
/**
|
|
94
|
+
* Global variable and shortcut to get the currently opened project. If no project is open, or the New Tab is open, this value is falsy.
|
|
95
|
+
*/
|
|
96
|
+
declare const Project: ModelProject | 0
|
|
86
97
|
|
|
87
98
|
declare function setupProject(format: ModelFormat | string): boolean;
|
|
88
99
|
declare function newProject(format: ModelFormat | string): boolean;
|
|
89
100
|
declare function setProjectResolution(width: number, height: number, modify_uv?: boolean): void;
|
|
90
101
|
declare function updateProjectResolution(): void;
|
|
91
102
|
|
|
103
|
+
/**
|
|
104
|
+
* An edit session instance. Edit sessions can be attached to a project to collaborate on it with multiple users via P2P connections.
|
|
105
|
+
*/
|
|
92
106
|
declare class EditSession {
|
|
93
107
|
constructor()
|
|
94
108
|
|
package/types/screencam.d.ts
CHANGED
|
@@ -28,6 +28,9 @@ interface RecordTimelapseOptions {
|
|
|
28
28
|
}
|
|
29
29
|
type ScreenshotReturn = (dataURL: string) => void
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* A global namespace handling screenshot and GIF recording utilities.
|
|
33
|
+
*/
|
|
31
34
|
declare namespace Screencam {
|
|
32
35
|
/**
|
|
33
36
|
* Provided preview with anti aliasing disabled that can be used for screenshots
|
package/types/settings.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
declare const settings: {
|
|
2
|
-
[id: string]: Setting
|
|
3
|
-
};
|
|
4
|
-
|
|
5
1
|
interface SettingOptions {
|
|
6
2
|
name: string
|
|
7
3
|
type?: 'number' | 'string' | 'boolean' | 'password' | 'select' | 'click'
|
|
@@ -21,10 +17,58 @@ interface SettingOptions {
|
|
|
21
17
|
onChange?: (value: any) => void
|
|
22
18
|
}
|
|
23
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Settings can be used to add global configuration options to Blockbench. All settings are listed under File > Preferences > Settings.
|
|
22
|
+
*/
|
|
24
23
|
declare class Setting extends Deletable {
|
|
25
24
|
constructor(id: string, options: SettingOptions);
|
|
26
25
|
|
|
26
|
+
id: string
|
|
27
|
+
type: string
|
|
28
|
+
condition: any
|
|
29
|
+
/**
|
|
30
|
+
* The master value, not affected by profiles
|
|
31
|
+
*/
|
|
32
|
+
master_value: any
|
|
33
|
+
/**
|
|
34
|
+
* The active value
|
|
35
|
+
*/
|
|
36
|
+
value: any
|
|
37
|
+
/**
|
|
38
|
+
* The value that is displayed in the settings dialog
|
|
39
|
+
*/
|
|
40
|
+
ui_value: any
|
|
41
|
+
name: string
|
|
42
|
+
description: string
|
|
43
|
+
category: string
|
|
44
|
+
/**
|
|
45
|
+
* If true, the setting can be used by the main process before initializing the Blockbench window. This is not available to custom settings created by plugins.
|
|
46
|
+
*/
|
|
47
|
+
launch_setting: boolean
|
|
48
|
+
min?: number
|
|
49
|
+
max?: number
|
|
50
|
+
step?: number
|
|
51
|
+
icon?: string
|
|
52
|
+
options?: {
|
|
53
|
+
[id: string]: string
|
|
54
|
+
}
|
|
55
|
+
hidden?: boolean
|
|
56
|
+
onChange?: () => {}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Sets the value of the setting, while triggering the onChange function if available, and saving the change.
|
|
60
|
+
*/
|
|
61
|
+
set(value): void
|
|
62
|
+
/**
|
|
63
|
+
* Triggers the setting, as if selected in action control. This toggles boolean settings, opens a dialog for string or numeric settings, etc.
|
|
64
|
+
*/
|
|
65
|
+
trigger(event?: Event): void
|
|
66
|
+
|
|
67
|
+
|
|
27
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Global namespace handling data and functionality related to settings.
|
|
71
|
+
*/
|
|
28
72
|
declare namespace Settings {
|
|
29
73
|
const structure: {};
|
|
30
74
|
const stored: {};
|
|
@@ -48,4 +92,8 @@ declare namespace Settings {
|
|
|
48
92
|
* Returns the value of the specified setting
|
|
49
93
|
*/
|
|
50
94
|
function get(setting_id: string): any;
|
|
51
|
-
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
declare const settings: {
|
|
98
|
+
[id: string]: Setting
|
|
99
|
+
};
|
|
@@ -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
|
+
}
|