Skip to content

Commit df15022

Browse files
committed
🧼 Name reworks, and pluginJson schema updates
- Renamed `IAnimationNode` -> `INodeTransform`. - Renamed `IRenderedFrame`'s `nodes` -> `node_transforms`. - Renamed `ExportedAnimationNode` -> `ExportedNodeTransform` - Removed unused settings from plugin JSON export. - Renamed `IRenderedRig`'s `defaultPose` -> `defaultTransform`
1 parent 12440d2 commit df15022

File tree

8 files changed

+181
-92
lines changed

8 files changed

+181
-92
lines changed

schemas/pluginJson.schema.json

Lines changed: 118 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -13,73 +13,91 @@
1313
"show_bounding_box",
1414
"auto_bounding_box",
1515
"bounding_box",
16-
"enable_plugin_mode",
1716
"resource_pack_export_mode",
18-
"data_pack_export_mode",
1917
"display_item",
2018
"custom_model_data_offset",
2119
"enable_advanced_resource_pack_settings",
2220
"resource_pack",
2321
"display_item_path",
2422
"model_folder",
2523
"texture_folder",
26-
"enable_advanced_data_pack_settings",
27-
"data_pack",
28-
"summon_commands",
29-
"interpolation_duration",
30-
"teleportation_duration",
31-
"use_storage_for_animation",
3224
"baked_animations",
33-
"json_file",
34-
"custom_summon_commands"
25+
"json_file"
3526
],
3627
"properties": {
37-
"export_namespace": { "type": "string", "default": "armor_stand" },
38-
"show_bounding_box": { "type": "boolean", "default": false },
39-
"auto_bounding_box": { "type": "boolean", "default": true },
28+
"export_namespace": {
29+
"type": "string",
30+
"default": "armor_stand",
31+
"description": "The namespace to export the project to. This is the namespace that will be used in the exported Resource Pack and Data Pack."
32+
},
33+
"show_bounding_box": {
34+
"type": "boolean",
35+
"default": false,
36+
"description": "Whether or not to show the bounding box in the editor."
37+
},
38+
"auto_bounding_box": {
39+
"type": "boolean",
40+
"default": true,
41+
"description": "Whether or not to automatically calculate the bounding box based on the model's geometry. \n\nNOTE: The auto bounding box will NOT take bone offsets from animations into account, so the bounding box may be smaller than needed in some cases."
42+
},
4043
"bounding_box": {
4144
"type": "array",
4245
"default": [48, 48],
46+
"description": "Determines the culling box of the model. The model will stop rendering when this box is off-screen.",
4347
"items": {
4448
"type": "integer",
4549
"minimum": 0
4650
},
4751
"minItems": 2,
4852
"maxItems": 2
4953
},
50-
"enable_plugin_mode": { "type": "boolean", "default": false },
5154
"resource_pack_export_mode": {
5255
"type": "string",
5356
"default": "raw",
57+
"description": "Determines how the Resource Pack should be exported.\n\nRaw - Exports the Resource Pack as a folder.\n\nZip - Exports the Resource Pack as a .zip file.\n\nNone - Disables Resource Pack exporting.",
5458
"enum": ["raw", "zip", "none"]
5559
},
56-
"data_pack_export_mode": {
60+
"display_item": {
5761
"type": "string",
58-
"default": "raw",
59-
"enum": ["raw", "zip", "none"]
62+
"default": "minecraft:white_dye",
63+
"description": "The item to display the Blueprints models in-game. Multiple Blueprints can be placed on the same item and they will be merged automatically."
64+
},
65+
"custom_model_data_offset": {
66+
"type": "integer",
67+
"default": 0,
68+
"description": "The offset to use for the Custom Model Data of the Display Item. Allows multiple Blueprints on the same item, but in separate, unaffiliated Resource Packs."
6069
},
61-
"display_item": { "type": "string", "default": "minecraft:white_dye" },
62-
"custom_model_data_offset": { "type": "integer", "default": 0 },
6370
"enable_advanced_resource_pack_settings": {
6471
"type": "boolean",
65-
"default": false
72+
"default": false,
73+
"description": "Whether or not to enable the advanced Resource Pack settings. (Individual RP Folder Selection)"
74+
},
75+
"resource_pack": {
76+
"type": "string",
77+
"default": "",
78+
"description": "The root folder of the Resource Pack to export the project into."
79+
},
80+
"display_item_path": {
81+
"type": "string",
82+
"default": "",
83+
"description": "Where to place the Display Item. This should be a path to a .json file in a Resource Pack."
84+
},
85+
"model_folder": {
86+
"type": "string",
87+
"default": "",
88+
"description": "Where to place all of the exported models. This should be a path to a folder in a Resource Pack."
89+
},
90+
"texture_folder": {
91+
"type": "string",
92+
"default": "",
93+
"description": "Where to place all of the exported textures. This should be a path to a folder in a Resource Pack."
6694
},
67-
"resource_pack": { "type": "string", "default": "" },
68-
"display_item_path": { "type": "string", "default": "" },
69-
"model_folder": { "type": "string", "default": "" },
70-
"texture_folder": { "type": "string", "default": "" },
71-
"enable_advanced_data_pack_settings": {
95+
"baked_animations": {
7296
"type": "boolean",
73-
"default": false
97+
"default": true,
98+
"description": "Whether or not to bake the exported animations.\n\nBaked animations have their frames pre-calculated and stored in the exported JSON file, reducing the complexity of rendering the model in-game.\n\nSome Plugins may require this to be enabled to function correctly."
7499
},
75-
"data_pack": { "type": "string", "default": "" },
76-
"summon_commands": { "type": "string", "default": "" },
77-
"interpolation_duration": { "type": "number", "default": 1 },
78-
"teleportation_duration": { "type": "number", "default": 1 },
79-
"use_storage_for_animation": { "type": "boolean", "default": false },
80-
"baked_animations": { "type": "boolean", "default": true },
81-
"json_file": { "type": "string", "default": "" },
82-
"custom_summon_commands": { "type": "string", "default": "" }
100+
"json_file": { "type": "string", "default": "", "description": "" }
83101
}
84102
},
85103
"resources": {
@@ -98,6 +116,7 @@
98116
"displayItemPath": { "type": "string", "default": "" },
99117
"models": {
100118
"type": "object",
119+
"description": "A map of bone UUIDs to custom bone models. This will be empty if no custom models are used.",
101120
"additionalProperties": false,
102121
"patternProperties": {
103122
"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$": {
@@ -107,7 +126,7 @@
107126
},
108127
"variant_models": {
109128
"type": "object",
110-
"description": "A map of variant names to maps of models to use for each bone when that variant is applied. Note that this map only contains included, and modified bones.",
129+
"description": "A map of variant UUIDS to maps of models to use for each bone when that variant is applied. Note that this map only contains bones modified and not excluded by the variant.",
111130
"additionalProperties": false,
112131
"patternProperties": {
113132
"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$": {
@@ -125,31 +144,31 @@
125144
"type": "object",
126145
"additionalProperties": false,
127146
"patternProperties": {
128-
".+": {
147+
"animated_java:transparent_texture": {
129148
"type": "object",
130-
"required": ["name", "expectedPath", "src"],
149+
"description": "The internal transparent texture used to hide parts of the Rig.",
131150
"properties": {
132-
"name": { "type": "string" },
151+
"name": { "const": "Transparent" },
133152
"expectedPath": {
134-
"type": "string",
135-
"description": "The path in the resource pack that the models that reference this texture expect the texture to be at."
153+
"const": "assets\\animated_java\\textures\\item\\armor_stand\\Transparent.png"
136154
},
137155
"src": {
138-
"type": "string",
139-
"description": "A data URL containing the texture image."
156+
"const": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABgWlDQ1BJQ0MgcHJvZmlsZQAAKJF9kTtIA0EURY+JokjEwhQiFltEK21UxFKiKIKBkETwV7i7MVHIrmE3YmMp2AYs/DRGLWystbWwFQTBD4i1hZWijcj6ZhNIEOPAMIc7cy9v3oNAKWdabuMoWHbBSUxGtdm5ea35hSaCQIAR3XTzseREirrr844Gdd72q6z67/5cbell14QGTXjUzDsF4SXh4Y1CXvGecNhc0dPCZ8J9jhQo/KB0o8yvirM+B1Rm2EklxoTDwlq2ho0aNlccS3hIOJK2bMkPzJY5rXhTsZVbNyt1qh+Glu2ZpNJldzPJFDHiaBiss0qOAv1y2qK4JOQ+Wsff5fvj4jLEtYopjnHWsNB9P2oGv3vrZgYHykmhKDQ9e957DzTvwHfR876OPO/7GIJPcGlX/WslGPkQvVjVIofQvgXnV1XN2IWLbeh8zOuO7kv+/DMZeDuVMc1Bxw20LpT7Vrnn5B5S0qvpa9g/gN6sZC/W+XdLbd/+fVPp3w9iNHKgdXImZAAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAuIwAALiMBeKU/dgAAAAd0SU1FB+gFAwAFKkpaLkIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAEklEQVQ4y2NgGAWjYBSMAggAAAQQAAGFP6pyAAAAAElFTkSuQmCC"
140157
}
141158
}
142159
},
143-
"animated_java:transparent_texture": {
160+
".+": {
144161
"type": "object",
145-
"description": "The internal transparent texture used to hide parts of the Rig.",
162+
"required": ["name", "expectedPath", "src"],
146163
"properties": {
147-
"name": { "const": "Transparent" },
164+
"name": { "type": "string" },
148165
"expectedPath": {
149-
"const": "assets\\animated_java\\textures\\item\\armor_stand\\Transparent.png"
166+
"type": "string",
167+
"description": "The path in the resource pack that the models that reference this texture expect the texture to be at."
150168
},
151169
"src": {
152-
"const": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABgWlDQ1BJQ0MgcHJvZmlsZQAAKJF9kTtIA0EURY+JokjEwhQiFltEK21UxFKiKIKBkETwV7i7MVHIrmE3YmMp2AYs/DRGLWystbWwFQTBD4i1hZWijcj6ZhNIEOPAMIc7cy9v3oNAKWdabuMoWHbBSUxGtdm5ea35hSaCQIAR3XTzseREirrr844Gdd72q6z67/5cbell14QGTXjUzDsF4SXh4Y1CXvGecNhc0dPCZ8J9jhQo/KB0o8yvirM+B1Rm2EklxoTDwlq2ho0aNlccS3hIOJK2bMkPzJY5rXhTsZVbNyt1qh+Glu2ZpNJldzPJFDHiaBiss0qOAv1y2qK4JOQ+Wsff5fvj4jLEtYopjnHWsNB9P2oGv3vrZgYHykmhKDQ9e957DzTvwHfR876OPO/7GIJPcGlX/WslGPkQvVjVIofQvgXnV1XN2IWLbeh8zOuO7kv+/DMZeDuVMc1Bxw20LpT7Vrnn5B5S0qvpa9g/gN6sZC/W+XdLbd/+fVPp3w9iNHKgdXImZAAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAuIwAALiMBeKU/dgAAAAd0SU1FB+gFAwAFKkpaLkIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAEklEQVQ4y2NgGAWjYBSMAggAAAQQAAGFP6pyAAAAAElFTkSuQmCC"
170+
"type": "string",
171+
"description": "A data URL containing the texture image."
153172
}
154173
}
155174
}
@@ -159,11 +178,11 @@
159178
},
160179
"rig": {
161180
"type": "object",
162-
"required": ["default_pose", "node_map"],
181+
"required": ["default_transforms", "node_map"],
163182
"properties": {
164-
"default_pose": {
183+
"default_transforms": {
165184
"type": "array",
166-
"items": { "$ref": "#/definitions/animationNode" }
185+
"items": { "$ref": "#/definitions/nodeTransform" }
167186
},
168187
"node_map": {
169188
"type": "object",
@@ -214,6 +233,7 @@
214233
}
215234
}
216235
},
236+
"vec2": { "type": "array", "items": { "type": "number" }, "minItems": 2, "maxItems": 2 },
217237
"vec3": { "type": "array", "items": { "type": "number" }, "minItems": 3, "maxItems": 3 },
218238
"vec4": { "type": "array", "items": { "type": "number" }, "minItems": 4, "maxItems": 4 },
219239
"vanillaModel": {
@@ -301,9 +321,9 @@
301321
"resourceLocation": { "type": "string" }
302322
}
303323
},
304-
"animationNode": {
324+
"nodeTransform": {
305325
"type": "object",
306-
"description": "The transformation of a node.",
326+
"description": "The transformation of a node. Includes several different storage methods for the transformation. All of these methods contain the same data, it's up to the plugin developer to choose which method to use.",
307327
"required": ["type", "name", "uuid", "matrix", "pos", "rot", "scale"],
308328
"properties": {
309329
"type": {
@@ -321,20 +341,46 @@
321341
"uuid": { "type": "string" },
322342
"matrix": {
323343
"type": "array",
344+
"description": "The transformation matrix of the node. The matrix is a 4x4 matrix in row-major order.",
324345
"items": { "type": "number" },
325346
"minItems": 16,
326347
"maxItems": 16
327348
},
328349
"transformation": {
329-
"translation": { "$ref": "#/definitions/vec3" },
330-
"left_rotation": { "$ref": "#/definitions/vec4" },
331-
"scale": { "$ref": "#/definitions/vec3" }
350+
"type": "object",
351+
"description": "The decomposed matrix transformation of the node.",
352+
"translation": {
353+
"$ref": "#/definitions/vec3",
354+
"description": "A vector3 representing the translation of the node."
355+
},
356+
"left_rotation": {
357+
"$ref": "#/definitions/vec4",
358+
"description": "A quaternion representing the left rotation of the node."
359+
},
360+
"scale": {
361+
"$ref": "#/definitions/vec3",
362+
"description": "A vector3 representing the scale of the node."
363+
}
364+
},
365+
"pos": {
366+
"$ref": "#/definitions/vec3",
367+
"description": "A vector3 representing the position of the node."
368+
},
369+
"rot": {
370+
"$ref": "#/definitions/vec3",
371+
"description": "A vector3 representing the rotation of the node."
372+
},
373+
"head_rot": {
374+
"$ref": "#/definitions/vec2",
375+
"description": "A vector2 representing the head rotation of the node.\n\nUsed for correctly rotating located entities, and cameras, as they don't have access to a Z axis."
376+
},
377+
"scale": {
378+
"$ref": "#/definitions/vec3",
379+
"description": "A vector3 representing the scale of the node."
332380
},
333-
"pos": { "$ref": "#/definitions/vec3" },
334-
"rot": { "$ref": "#/definitions/vec3" },
335-
"scale": { "$ref": "#/definitions/vec3" },
336381
"interpolation": {
337382
"type": "string",
383+
"description": "The instant-interpolation mode of the node.\n\n- `pre-post`",
338384
"enum": ["pre-post", "step"]
339385
},
340386
"commands": { "type": "string" },
@@ -564,11 +610,23 @@
564610
"type": "array",
565611
"items": {
566612
"type": "object",
613+
"required": ["time", "node_transforms"],
567614
"properties": {
568615
"time": { "type": "number" },
569-
"nodes": {
616+
"node_transforms": {
570617
"type": "array",
571-
"items": { "$ref": "#/definitions/animationNode" }
618+
"items": { "$ref": "#/definitions/nodeTransform" }
619+
},
620+
"variant": {
621+
"type": "object",
622+
"description": "If included, this frame should change the variant of the model to the specified variant.",
623+
"properties": {
624+
"uuid": {
625+
"type": "string",
626+
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
627+
},
628+
"execute_condition": { "type": "string" }
629+
}
572630
}
573631
}
574632
}

src/systems/animationRenderer.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function threeAxisRotationToTwoAxisRotation(rot: THREE.Quaternion): ArrayVector2
5555
return [Math.radToDeg(yaw), Math.radToDeg(pitch)]
5656
}
5757

58-
export interface IAnimationNode {
58+
export interface INodeTransform {
5959
type: 'bone' | 'camera' | 'locator' | 'text_display' | 'item_display' | 'block_display'
6060
name: string
6161
uuid: string
@@ -84,7 +84,7 @@ export interface IAnimationNode {
8484

8585
export interface IRenderedFrame {
8686
time: number
87-
nodes: IAnimationNode[]
87+
node_transforms: INodeTransform[]
8888
variant?: {
8989
uuid: string
9090
executeCondition?: string
@@ -135,7 +135,7 @@ export function getAnimationNodes(
135135
animation.excluded_nodes ? animation.excluded_nodes.map(b => b.value) : []
136136
)
137137
}
138-
const nodes: IAnimationNode[] = []
138+
const nodes: INodeTransform[] = []
139139

140140
for (const [uuid, node] of Object.entries(nodeMap)) {
141141
if (!node.node.export) continue
@@ -147,7 +147,7 @@ export function getAnimationNodes(
147147
const lastFrame = lastFrameCache.get(uuid)
148148

149149
let matrix: THREE.Matrix4
150-
let interpolation: IAnimationNode['interpolation']
150+
let interpolation: INodeTransform['interpolation']
151151
let commands,
152152
executeCondition: string | undefined,
153153
repeat: boolean | undefined,
@@ -290,12 +290,12 @@ export function renderAnimation(animation: _Animation, rig: IRenderedRig) {
290290

291291
for (let time = 0; time <= animation.length; time = roundToNth(time + 0.05, 20)) {
292292
updatePreview(animation, time)
293-
const frame = {
293+
const frame: IRenderedFrame = {
294294
time,
295-
nodes: getAnimationNodes(animation, rig.nodeMap, time),
295+
node_transforms: getAnimationNodes(animation, rig.nodeMap, time),
296296
variant: getVariantKeyframe(animation, time),
297297
}
298-
frame.nodes.forEach(n => includedNodes.add(n.uuid))
298+
frame.node_transforms.forEach(n => includedNodes.add(n.uuid))
299299
rendered.frames.push(frame)
300300
}
301301
rendered.duration = rendered.frames.length
@@ -314,7 +314,7 @@ export function hashAnimations(animations: IRenderedAnimation[]) {
314314
hash.update(';' + animation.includedNodes.map(n => n.uuid).join(';'))
315315
for (const frame of animation.frames) {
316316
hash.update(';' + frame.time.toString())
317-
for (const node of frame.nodes) {
317+
for (const node of frame.node_transforms) {
318318
hash.update(';' + node.uuid)
319319
hash.update(';' + node.pos.join(';'))
320320
hash.update(';' + node.rot.join(';'))

src/systems/datapackCompiler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ async function createAnimationStorage(animations: IRenderedAnimation[]) {
444444
const frame = animation.frames[i]
445445
const thisFrame = new NbtCompound()
446446
frames.set(i.toString(), thisFrame)
447-
for (const node of frame.nodes) {
447+
for (const node of frame.node_transforms) {
448448
if (BONE_TYPES.includes(node.type)) {
449449
thisFrame.set(
450450
node.type + '_' + node.name,
@@ -484,7 +484,7 @@ function createPassengerStorage(rig: IRenderedRig) {
484484
const cameras = new NbtCompound()
485485
// Data entity
486486
bones.set('data_data', new NbtString(''))
487-
for (const node of Object.values(rig.defaultPose)) {
487+
for (const node of Object.values(rig.defaultTransforms)) {
488488
switch (node.type) {
489489
case 'locator':
490490
case 'camera': {

0 commit comments

Comments
 (0)