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/types/index.d.ts CHANGED
@@ -7,6 +7,7 @@
7
7
  /// <reference types="./textures" />
8
8
  /// <reference types="./action" />
9
9
  /// <reference types="./animation" />
10
+ /// <reference types="./animation_controller" />
10
11
  /// <reference types="./canvas" />
11
12
  /// <reference types="./codec" />
12
13
  /// <reference types="./file_system" />
@@ -19,117 +20,32 @@
19
20
  /// <reference types="./legacy" />
20
21
  /// <reference types="./menu" />
21
22
  /// <reference types="./outliner" />
23
+ /// <reference types="./cube" />
22
24
  /// <reference types="./plugin" />
23
25
  /// <reference types="./preview" />
24
26
  /// <reference types="./project" />
27
+ /// <reference types="./mode" />
25
28
  /// <reference types="./settings" />
26
29
  /// <reference types="./timeline" />
27
30
  /// <reference types="./undo" />
31
+ /// <reference types="./painter" />
32
+ /// <reference types="./screencam" />
28
33
  /// <reference types="./validator" />
34
+ /// <reference types="./display_mode" />
35
+ /// <reference types="./misc" />
29
36
  /// <reference types="./util" />
30
37
 
31
38
 
32
- declare class Deletable {
33
- delete: () => void
34
- }
35
- type UUID = string
36
-
37
- /**
38
- * True if Blockbench runs as a native app
39
- */
40
- declare const isApp: boolean
41
-
42
- type EventName = 'remove_animation'
43
- | 'display_animation_frame'
44
- | 'before_closing'
45
- | 'create_session'
46
- | 'join_session'
47
- | 'quit_session'
48
- | 'send_session_data'
49
- | 'receive_session_data'
50
- | 'user_joins_session'
51
- | 'user_leaves_session'
52
- | 'process_chat_message'
53
- | 'update_settings'
54
- | 'update_project_settings'
55
- | 'save_project'
56
- | 'load_project'
57
- | 'new_project'
58
- | 'reset_project'
59
- | 'close_project'
60
- | 'add_cube'
61
- | 'add_mesh'
62
- | 'add_group'
63
- | 'add_texture_mesh'
64
- | 'group_elements'
65
- | 'update_selection'
66
- | 'update_keyframe_selection'
67
- | 'select_all'
68
- | 'added_to_selection'
69
- | 'invert_selection'
70
- | 'canvas_select'
71
- | 'canvas_click'
72
- | 'change_texture_path'
73
- | 'add_texture'
74
- | 'finish_edit'
75
- | 'finished_edit'
76
- | 'undo'
77
- | 'redo'
78
- | 'load_undo_save'
79
- | 'select_mode'
80
- | 'unselect_mode'
81
- | 'change_active_panel'
82
- | 'resize_window'
83
- | 'press_key'
84
- | 'select_format'
85
- | 'convert_format'
86
- | 'construct_format'
87
- | 'delete_format'
88
- | 'select_project'
89
- | 'unselect_project'
90
- | 'setup_project'
91
- | 'update_project_resolution'
92
- | 'merge_project'
93
- | 'update_view'
94
- | 'update_camera_position'
95
- | 'render_frame'
96
- | 'construct_model_loader'
97
- | 'delete_model_loader'
98
- | 'update_recent_project_data'
99
- | 'update_recent_project_thumbnail'
100
- | 'load_from_recent_project_data'
101
- | 'edit_animation_properties'
102
- | 'select_preview_scene'
103
- | 'unselect_preview_scene'
104
-
105
- type IconString = string;
106
-
107
- interface MessageBoxOptions {
108
- /**
109
- * Index of the confirm button within the buttons array
110
- */
111
- confirm: number
39
+ declare namespace Blockbench {
40
+ const platform: 'web' | 'win32' | 'darwin' | 'linux'
112
41
  /**
113
- * Index of the cancel button within the buttons array
42
+ * Blockbench version number
114
43
  */
115
- cancel: number
116
- buttons: string[]
117
- translateKey?: string
118
- title?: string
119
- message?: string
120
- icon?: string
121
- width: number
44
+ const version: string
122
45
  /**
123
- * 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.
46
+ * URL queries when opened as web app using a link that contained queries
124
47
  */
125
- commands?: {
126
- [id: string]: string | {text: string}
127
- }
128
- }
129
-
130
- declare namespace Blockbench {
131
- const platform: 'web' | 'win32' | 'darwin' | 'linux'
132
- const version: string
48
+ const queries: {[key: string]: string} | undefined
133
49
  /**
134
50
  * Time when Blockbench was opened
135
51
  */
@@ -218,95 +134,123 @@ declare namespace Blockbench {
218
134
  function removeListener(event_names: EventName): void
219
135
  }
220
136
 
221
-
222
- interface PluginData {
223
- title: string
224
- author: string
225
- description: string
226
- icon: string
227
- variant: 'desktop' | 'web' | 'both'
228
- about?: string
229
- min_version: string
230
- max_version: string
231
- onload: () => void
232
- onunload: () => void
233
- oninstall: () => void
234
- onuninstall: () => void
235
- }
236
-
237
- declare class Plugin {
238
- static register(id: string, data: PluginData): Plugin
239
- constructor()
240
- }
241
-
242
- type Condition = any
243
-
244
-
245
- interface PropertyOptions {
246
- default?: any
247
- condition?: any
248
- exposed?: boolean
249
- label?: string
250
- /**
251
- * Options used for select types
252
- */
253
- options?: object
254
- merge?: (instance: any, data: object) => void
255
- reset?: (instance: any) => void
256
- merge_validation?: (value: any) => boolean
257
- }
258
- /**
259
- * Creates a new property on the specified target class
260
- */
261
- declare class Property extends Deletable {
262
- constructor(target_class: any, type: string, name: string, options?: PropertyOptions);
263
- class: any;
264
- name: string;
265
- type: string;
266
- default: any;
267
-
268
- isString: boolean;
269
- isMolang: boolean;
270
- isNumber: boolean;
271
- isBoolean: boolean;
272
- isArray: boolean;
273
- isVector: boolean;
274
- isVector2: boolean;
275
-
276
- merge_validation: undefined | ((value: any) => boolean);
277
- condition: any;
278
- exposed: boolean;
279
- label: any;
280
- merge: (instance: any, data: object) => void
281
- reset: (instance: any) => void
282
- getDefault(instance: any): any;
283
- copy(instance: any, target: any): void;
284
- }
285
-
286
- declare function updateSelection(): void
287
-
288
- /**
289
- * Returns a translated string in the current language
290
- * @param key Translation key
291
- * @param arguments Array of arguments that replace anchors (%0, etc.) in the translation. Items can be strings or anything that can be converted to strings
292
- */
293
- declare function tl(key: string, arguments?: any[]): string
294
-
295
- declare namespace Language {
296
- /**
297
- * Translation data for the current language
298
- */
299
- const data: {
300
- [key: string]: string
301
- }
302
- /**
303
- * Two letter code indicating the currently selected language
304
- */
305
- const code: string
306
- /**
307
- * Add translations for custom translation strings
308
- * @param language Two letter language code, e. G. 'en'
309
- * @param strings Object listing the translation keys and values
310
- */
311
- function addTranslations(language: string, strings: {[key: string]: string})
137
+ type BlockbenchTypeOutliner = typeof Outliner
138
+ type BlockbenchTypeOutlinerNode = typeof OutlinerNode
139
+ type BlockbenchTypeOutlinerElement = typeof OutlinerElement
140
+ type BlockbenchTypeGroup = typeof Group
141
+ type BlockbenchTypeCube = typeof Cube
142
+ type BlockbenchTypeMesh = typeof Mesh
143
+ type BlockbenchTypeLocator = typeof Locator
144
+ type BlockbenchTypeNullObject = typeof NullObject
145
+ type BlockbenchTypeTextureMesh = typeof TextureMesh
146
+ type BlockbenchTypeFace = typeof Face
147
+ type BlockbenchTypeCubeFace = typeof CubeFace
148
+ type BlockbenchTypeMeshFace = typeof MeshFace
149
+ type BlockbenchTypeNodePreviewController = typeof NodePreviewController
150
+ type BlockbenchTypeAnimator = typeof Animator
151
+ type BlockbenchTypeTimeline = typeof Timeline
152
+ type BlockbenchTypeAnimationItem = typeof AnimationItem
153
+ type BlockbenchTypeAnimation = typeof Animation
154
+ type BlockbenchTypeAnimationController = typeof AnimationController
155
+ type BlockbenchTypeKeyframe = typeof Keyframe
156
+ type BlockbenchTypeKeyframeDataPoint = typeof KeyframeDataPoint
157
+ type BlockbenchTypeBoneAnimator = typeof BoneAnimator
158
+ type BlockbenchTypeNullObjectAnimator = typeof NullObjectAnimator
159
+ type BlockbenchTypeEffectAnimator = typeof EffectAnimator
160
+ type BlockbenchTypeTimelineMarker = typeof TimelineMarker
161
+ type BlockbenchTypePanel = typeof Panel
162
+ type BlockbenchTypeMode = typeof Mode
163
+ type BlockbenchTypeDialog = typeof Dialog
164
+ type BlockbenchTypeSetting = typeof Setting
165
+ type BlockbenchTypePlugin = typeof Plugin
166
+ type BlockbenchTypePreview = typeof Preview
167
+ type BlockbenchTypeToolbar = typeof Toolbar
168
+ type BlockbenchTypeLanguage = typeof Language
169
+ type BlockbenchTypePainter = typeof Painter
170
+ type BlockbenchTypeScreencam = typeof Screencam
171
+ type BlockbenchTypeSettings = typeof Settings
172
+ type BlockbenchTypeTextureAnimator = typeof TextureAnimator
173
+ type BlockbenchTypeToolbox = typeof Toolbox
174
+ type BlockbenchTypeBarItems = typeof BarItems
175
+ type BlockbenchTypeBarItem = typeof BarItem
176
+ type BlockbenchTypeAction = typeof Action
177
+ type BlockbenchTypeTool = typeof Tool
178
+ type BlockbenchTypeToggle = typeof Toggle
179
+ type BlockbenchTypeWidget = typeof Widget
180
+ type BlockbenchTypeBarSelect = typeof BarSelect
181
+ type BlockbenchTypeBarSlider = typeof BarSlider
182
+ type BlockbenchTypeBarText = typeof BarText
183
+ type BlockbenchTypeNumSlider = typeof NumSlider
184
+ type BlockbenchTypeColorPicker = typeof ColorPicker
185
+ type BlockbenchTypeKeybind = typeof Keybind
186
+ type BlockbenchTypeKeybindItem = typeof KeybindItem
187
+ type BlockbenchTypeMenu = typeof Menu
188
+ type BlockbenchTypeBarMenu = typeof BarMenu
189
+ type BlockbenchTypeResizeLine = typeof ResizeLine
190
+ type BlockbenchTypeModelProject = typeof ModelProject
191
+ type BlockbenchTypeModelFormat = typeof ModelFormat
192
+ type BlockbenchTypeCodec = typeof Codec
193
+ type BlockbenchTypeDisplaySlot = typeof DisplaySlot
194
+ type BlockbenchTypeReusable = typeof Reusable
195
+ type BlockbenchTypeTexture = typeof Texture
196
+ declare namespace Blockbench {
197
+ const Outliner: BlockbenchTypeOutliner
198
+ const OutlinerNode: BlockbenchTypeOutlinerNode
199
+ const OutlinerElement: BlockbenchTypeOutlinerElement
200
+ const Group: BlockbenchTypeGroup
201
+ const Cube: BlockbenchTypeCube
202
+ const Mesh: BlockbenchTypeMesh
203
+ const Locator: BlockbenchTypeLocator
204
+ const NullObject: BlockbenchTypeNullObject
205
+ const TextureMesh: BlockbenchTypeTextureMesh
206
+ const Face: BlockbenchTypeFace
207
+ const CubeFace: BlockbenchTypeCubeFace
208
+ const MeshFace: BlockbenchTypeMeshFace
209
+ const NodePreviewController: BlockbenchTypeNodePreviewController
210
+ const Animator: BlockbenchTypeAnimator
211
+ const Timeline: BlockbenchTypeTimeline
212
+ const AnimationItem: BlockbenchTypeAnimationItem
213
+ const Animation: BlockbenchTypeAnimation
214
+ const AnimationController: BlockbenchTypeAnimationController
215
+ const Keyframe: BlockbenchTypeKeyframe
216
+ const KeyframeDataPoint: BlockbenchTypeKeyframeDataPoint
217
+ const BoneAnimator: BlockbenchTypeBoneAnimator
218
+ const NullObjectAnimator: BlockbenchTypeNullObjectAnimator
219
+ const EffectAnimator: BlockbenchTypeEffectAnimator
220
+ const TimelineMarker: BlockbenchTypeTimelineMarker
221
+ const Panel: BlockbenchTypePanel
222
+ const Mode: BlockbenchTypeMode
223
+ const Dialog: BlockbenchTypeDialog
224
+ const Setting: BlockbenchTypeSetting
225
+ const Plugin: BlockbenchTypePlugin
226
+ const Preview: BlockbenchTypePreview
227
+ const Toolbar: BlockbenchTypeToolbar
228
+ const Language: BlockbenchTypeLanguage
229
+ const Painter: BlockbenchTypePainter
230
+ const Screencam: BlockbenchTypeScreencam
231
+ const Settings: BlockbenchTypeSettings
232
+ const TextureAnimator: BlockbenchTypeTextureAnimator
233
+ const Toolbox: BlockbenchTypeToolbox
234
+ const BarItems: BlockbenchTypeBarItems
235
+ const BarItem: BlockbenchTypeBarItem
236
+ const Action: BlockbenchTypeAction
237
+ const Tool: BlockbenchTypeTool
238
+ const Toggle: BlockbenchTypeToggle
239
+ const Widget: BlockbenchTypeWidget
240
+ const BarSelect: BlockbenchTypeBarSelect
241
+ const BarSlider: BlockbenchTypeBarSlider
242
+ const BarText: BlockbenchTypeBarText
243
+ const NumSlider: BlockbenchTypeNumSlider
244
+ const ColorPicker: BlockbenchTypeColorPicker
245
+ const Keybind: BlockbenchTypeKeybind
246
+ const KeybindItem: BlockbenchTypeKeybindItem
247
+ const Menu: BlockbenchTypeMenu
248
+ const BarMenu: BlockbenchTypeBarMenu
249
+ const ResizeLine: BlockbenchTypeResizeLine
250
+ const ModelProject: BlockbenchTypeModelProject
251
+ const ModelFormat: BlockbenchTypeModelFormat
252
+ const Codec: BlockbenchTypeCodec
253
+ const DisplaySlot: BlockbenchTypeDisplaySlot
254
+ const Reusable: BlockbenchTypeReusable
255
+ const Texture: BlockbenchTypeTexture
312
256
  }
@@ -1,5 +1,5 @@
1
1
  interface ResizeLineOptions {
2
- condition?: Condition
2
+ condition?: ConditionResolvable
3
3
  horizontal?: boolean
4
4
  position(): void
5
5
  get(): void
@@ -10,7 +10,7 @@ declare class ResizeLine {
10
10
 
11
11
  id: string
12
12
  horizontal: boolean
13
- condition?: Condition
13
+ condition?: ConditionResolvable
14
14
  width: number
15
15
  get(): void
16
16
  set(): void
@@ -12,6 +12,14 @@ type axisLetter = 'x' | 'y' | 'z'
12
12
 
13
13
  declare class Keyframe {
14
14
  constructor(options: KeyframeOptions, uuid: any);
15
+
16
+ animator: GeneralAnimator;
17
+ bezier_left_time: ArrayVector3;
18
+ bezier_right_time: ArrayVector3;
19
+ bezier_left_value: ArrayVector3;
20
+ bezier_right_value: ArrayVector3;
21
+
22
+
15
23
  extend(data: KeyframeOptions): this;
16
24
  get(axis: axisLetter, data_point?: number): any;
17
25
  calc(axis: axisLetter, data_point?: number): any;
@@ -0,0 +1,137 @@
1
+ type OccupationMatrix = {
2
+ [x: number]: {
3
+ [y: number]: boolean
4
+ }
5
+ }
6
+ type MeshEdge = [string, string]
7
+ interface MeshFaceOptions extends FaceOptions {
8
+
9
+ }
10
+ declare class MeshFace extends Face {
11
+ constructor(mesh: Mesh, data: MeshFaceOptions)
12
+ /**
13
+ * The vertices that make up the face, as vertex keys. The vertices go around the face counter-clockwise when looking at the front side of the face. That also means that reversing the vertex order reverses the face direction.
14
+ */
15
+ vertices: string[]
16
+ mesh: Mesh
17
+ uv: {
18
+ [vertex: string]: ArrayVector2
19
+ }
20
+ extend: (data: MeshFaceOptions) => void
21
+ /**
22
+ * Returns the face normal in mesh space as calculated from the vertex positions
23
+ */
24
+ getNormal: (normalize) => ArrayVector3
25
+ /**
26
+ * Calculates which pixels the UV face occupies, and returns them as a map
27
+ */
28
+ getOccupationMatrix: (texture_space?: boolean, start_offset?: ArrayVector2, matrix?: OccupationMatrix) => OccupationMatrix
29
+ /**
30
+ * Get the keys of this face and all faces that are connected with it on the UV map
31
+ */
32
+ getUVIsland: () => string[]
33
+ /**
34
+ * Returns the angle between two faces in degrees
35
+ */
36
+ getAngleTo: (other_face: MeshFace) => number
37
+ /**
38
+ * Inverts the direction of the face
39
+ */
40
+ invert: () => void
41
+ /**
42
+ * Returns whether the face is selected
43
+ */
44
+ isSelected: () => boolean
45
+ /**
46
+ * Returns the vertices of a quad in an order that creates a convex quad shape if possible. If the face has less than 4 vertices, it just returns the vertices in original order.
47
+ */
48
+ getSortedVertices: () => string[]
49
+ /**
50
+ * Get the adjacent face in the specified side
51
+ */
52
+ getAdjacentFace: (side_index: number) => {face: MeshFace, key: string, edge: MeshEdge, index: number} | null
53
+ /**
54
+ * Returns the face key
55
+ */
56
+ getFaceKey: () => string
57
+ /**
58
+ * Takes a UV coordinate and turns it into a 3D space coordinate in local space of the mesh. On quads, the first triangle is used for calculation, so the coordinates on warped quads may be inaccurate.
59
+ */
60
+ UVToLocal: (uv: ArrayVector2) => THREE.Vector3
61
+ /**
62
+ * Takes a 3D coordinate in local space of the mesh, and turns it into a coordinate on the UV map using barycentric coordinates. On quads, the first triangle is used for calculation, so the coordinates on warped quads may be inaccurate.
63
+ */
64
+ localToUV: (vector: THREE.Vector3) => ArrayVector2
65
+ /**
66
+ * Get the face center by weight in local space
67
+ */
68
+ getCenter: () => ArrayVector3
69
+ }
70
+
71
+ type MeshSeamValue = 'auto' | 'divide' | 'join'
72
+ interface MeshOptions {
73
+ name?: string
74
+ color?: number
75
+ visibility?: boolean
76
+ rotation?: ArrayVector3
77
+ origin?: ArrayVector3
78
+ vertices?: {
79
+ [vkey: string]: ArrayVector3
80
+ }
81
+ }
82
+ declare class Mesh extends OutlinerElement {
83
+ constructor (options: Partial<MeshOptions>, uuid?: string)
84
+
85
+ visibility: boolean
86
+ color: number
87
+
88
+ vertices: {
89
+ [vkey: string]: ArrayVector3
90
+ }
91
+ faces: {
92
+ [fkey: string]: MeshFace
93
+ }
94
+ seams: {
95
+ [vkey: string]: MeshSeamValue
96
+ }
97
+
98
+ extend(options: Partial<MeshOptions>): this
99
+
100
+ /**
101
+ * Get selected vertices as vertex keys
102
+ * @param can_write If true, the array can safely be modified to update the selection
103
+ */
104
+ getSelectedVertices(can_write: boolean): string[]
105
+ /**
106
+ * Get selected edges as vertex key pairs
107
+ * @param can_write If true, the array can safely be modified to update the selection
108
+ */
109
+ getSelectedEdges(can_write: boolean): ([string, string])[]
110
+ /**
111
+ * Get selected faces as face keys
112
+ * @param can_write If true, the array can safely be modified to update the selection
113
+ */
114
+ getSelectedVertices(can_write: boolean): string[]
115
+
116
+ setSeam(edge: MeshEdge, value)
117
+ getSeam(edge: MeshEdge): MeshSeamValue
118
+ getWorldCenter(ignore_mesh_selection?: boolean): THREE.Vector3
119
+ addVertices(...ArrayVector3): string[]
120
+ addFaces(...MeshFace): string[]
121
+ extend(data: MeshOptions): void
122
+ getUndoCopy(aspects?: object): object
123
+ getSaveCopy(project?: boolean): object
124
+ getSelectionRotation(): THREE.Euler
125
+ getCenter(global: boolean): THREE.Vector3
126
+ forAllFaces(callback: (face: MeshFace, key: string) => void): void
127
+ transferOrigin(origin: ArrayVector3, update?: boolean): void
128
+ setColor(color: number): void
129
+ roll(axis: number, steps: number, origin?: ArrayVector3): void
130
+ flip(axis: number): void
131
+ moveVector(offset: ArrayVector3, axis: number, update?: boolean): void
132
+ resize(val: number, axis: number, negative: boolean, allow_negative: boolean, bidirectional?: boolean): void
133
+ applyTexture(texture: Texture, faces?: true | undefined | string[]): void
134
+
135
+ static all: Mesh[]
136
+ static selected: Mesh[]
137
+ }