Skip to content

Commit 54b46aa

Browse files
committed
🚧 Reduced redundant data in the Plugin JSON
- `nodeTransform` no longer stores bone `name`, `type`, or `uuid`. - Moved `defaultTransforms` into `node` as `defaultTransform`. - `animators` for dynamic animations have been reduced to a list of keyframes. - `dynamicAnimation` had it's `uuid` field removed. - `keyframeDataPoints`'s `xyz` fields are now always strings when they're defined. - Removed `xyz` fields from a `commands` channel `keyframes`'s datapoints. - `animators` that don't have any keyframes are now excluded.
1 parent be1b904 commit 54b46aa

File tree

4 files changed

+179
-167
lines changed

4 files changed

+179
-167
lines changed

schemas/pluginJson.schema.json

Lines changed: 78 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,8 @@
169169
},
170170
"rig": {
171171
"type": "object",
172-
"required": ["default_transforms", "node_map"],
172+
"required": ["node_map", "node_structure", "variants"],
173173
"properties": {
174-
"default_transforms": {
175-
"type": "array",
176-
"items": { "$ref": "#/definitions/nodeTransform" }
177-
},
178174
"node_map": {
179175
"type": "object",
180176
"additionalProperties": false,
@@ -315,22 +311,8 @@
315311
"nodeTransform": {
316312
"type": "object",
317313
"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.",
318-
"required": ["type", "name", "uuid", "matrix", "pos", "rot", "scale"],
314+
"required": ["matrix", "pos", "rot", "scale"],
319315
"properties": {
320-
"type": {
321-
"type": "string",
322-
"enum": [
323-
"bone",
324-
"struct",
325-
"camera",
326-
"locator",
327-
"text_display",
328-
"item_display",
329-
"block_display"
330-
]
331-
},
332-
"name": { "type": "string" },
333-
"uuid": { "type": "string" },
334316
"matrix": {
335317
"type": "array",
336318
"description": "The transformation matrix of the node. The matrix is a 4x4 matrix in row-major order.",
@@ -397,7 +379,11 @@
397379
},
398380
"name": { "type": "string" },
399381
"uuid": { "type": "string" },
400-
"parent": { "type": "string" }
382+
"parent": { "type": "string" },
383+
"defaultTransform": {
384+
"$ref": "#/definitions/nodeTransform",
385+
"description": "The default transformation of the node."
386+
}
401387
},
402388
"allOf": [
403389
{
@@ -580,46 +566,52 @@
580566
}
581567
},
582568
"bakedAnimations": {
583-
"type": "array",
584-
"items": {
585-
"type": "object",
586-
"required": [
587-
"name",
588-
"storageSafeName",
589-
"duration",
590-
"loopDelay",
591-
"loopMode",
592-
"frames",
593-
"includedNodes"
594-
],
595-
"additionalProperties": false,
596-
"properties": {
597-
"name": { "type": "string" },
598-
"storageSafeName": { "type": "string" },
599-
"duration": { "type": "number" },
600-
"loopDelay": { "type": "number" },
601-
"loopMode": { "type": "string", "enum": ["none", "loop", "ping-pong"] },
602-
"includedNodes": { "type": "array", "items": { "type": "string" } },
603-
"frames": {
604-
"type": "array",
605-
"items": {
606-
"type": "object",
607-
"required": ["time", "node_transforms"],
608-
"properties": {
609-
"time": { "type": "number" },
610-
"node_transforms": {
611-
"type": "array",
612-
"items": { "$ref": "#/definitions/nodeTransform" }
613-
},
614-
"variant": {
615-
"type": "object",
616-
"description": "If included, this frame should change the variant of the model to the specified variant.",
617-
"properties": {
618-
"uuid": {
619-
"type": "string",
620-
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
621-
},
622-
"execute_condition": { "type": "string" }
569+
"type": "object",
570+
"patternProperties": {
571+
"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$": {
572+
"type": "object",
573+
"required": [
574+
"name",
575+
"safeName",
576+
"duration",
577+
"loopDelay",
578+
"loopMode",
579+
"frames",
580+
"includedNodes"
581+
],
582+
"additionalProperties": false,
583+
"properties": {
584+
"name": { "type": "string" },
585+
"safeName": { "type": "string" },
586+
"duration": { "type": "number" },
587+
"loopDelay": { "type": "number" },
588+
"loopMode": { "type": "string", "enum": ["none", "loop", "ping-pong"] },
589+
"includedNodes": { "type": "array", "items": { "type": "string" } },
590+
"frames": {
591+
"type": "array",
592+
"items": {
593+
"type": "object",
594+
"required": ["time", "node_transforms"],
595+
"properties": {
596+
"time": { "type": "number" },
597+
"node_transforms": {
598+
"type": "object",
599+
"patternProperties": {
600+
"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$": {
601+
"$ref": "#/definitions/nodeTransform"
602+
}
603+
}
604+
},
605+
"variant": {
606+
"type": "object",
607+
"description": "If included, this frame should change the variant of the model to the specified variant.",
608+
"properties": {
609+
"uuid": {
610+
"type": "string",
611+
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
612+
},
613+
"execute_condition": { "type": "string" }
614+
}
623615
}
624616
}
625617
}
@@ -629,41 +621,28 @@
629621
}
630622
},
631623
"dynamicAnimations": {
632-
"type": "array",
633-
"items": {
634-
"type": "object",
635-
"required": [
636-
"uuid",
637-
"name",
638-
"loop_mode",
639-
"duration",
640-
"excluded_nodes",
641-
"animators"
642-
],
643-
"additionalProperties": true,
644-
"properties": {
645-
"uuid": { "type": "string" },
646-
"name": { "type": "string" },
647-
"loop_mode": { "type": "string", "enum": ["loop", "once", "hold"] },
648-
"duration": { "type": "number" },
649-
"loop_delay": { "type": "number" },
650-
"excluded_nodes": {
651-
"type": "array",
652-
"items": { "type": "string" }
653-
},
654-
"animators": {
655-
"type": "object",
656-
"patternProperties": {
657-
"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$": {
658-
"type": "object",
659-
"required": ["name", "type", "keyframes"],
660-
"properties": {
661-
"name": { "type": "string" },
662-
"type": { "type": "string" },
663-
"keyframes": {
664-
"type": "array",
665-
"items": { "$ref": "#/definitions/keyframe" }
666-
}
624+
"type": "object",
625+
"patternProperties": {
626+
"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$": {
627+
"type": "object",
628+
"required": ["name", "loop_mode", "duration", "excluded_nodes", "animators"],
629+
"additionalProperties": true,
630+
"properties": {
631+
"uuid": { "type": "string" },
632+
"name": { "type": "string" },
633+
"loop_mode": { "type": "string", "enum": ["loop", "once", "hold"] },
634+
"duration": { "type": "number" },
635+
"loop_delay": { "type": "number" },
636+
"excluded_nodes": {
637+
"type": "array",
638+
"items": { "type": "string" }
639+
},
640+
"animators": {
641+
"type": "object",
642+
"patternProperties": {
643+
"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$": {
644+
"type": "array",
645+
"items": { "$ref": "#/definitions/keyframe" }
667646
}
668647
}
669648
}
@@ -732,9 +711,9 @@
732711
"keyframeDataPoint": {
733712
"type": "object",
734713
"properties": {
735-
"x": { "oneOf": [{ "type": "number" }, { "type": "string" }] },
736-
"y": { "oneOf": [{ "type": "number" }, { "type": "string" }] },
737-
"z": { "oneOf": [{ "type": "number" }, { "type": "string" }] },
714+
"x": { "type": "string" },
715+
"y": { "type": "string" },
716+
"z": { "type": "string" },
738717
"commands": { "type": "string" },
739718
"execute_condition": { "type": "string" },
740719
"repeat": { "type": "boolean" },

src/systems/animationRenderer.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export interface IRenderedFrame {
9898

9999
export interface IRenderedAnimation {
100100
name: string
101+
uuid: string
101102
safeName: string
102103
loopDelay: number
103104
frames: IRenderedFrame[]
@@ -286,6 +287,7 @@ export function updatePreview(animation: _Animation, time: number) {
286287
export function renderAnimation(animation: _Animation, rig: IRenderedRig) {
287288
const rendered = {
288289
name: animation.name,
290+
uuid: animation.uuid,
289291
safeName: toSafeFuntionName(animation.name).replaceAll('.', '_'),
290292
loopDelay: Number(animation.loop_delay) || 0,
291293
frames: [],

0 commit comments

Comments
 (0)