This commit is contained in:
Edwin Wong
2023-09-26 15:54:14 +08:00
parent db6ea0ab0c
commit fd35d2873f
5 changed files with 32 additions and 27 deletions
+3 -3
View File
@@ -45,13 +45,13 @@ class AvatarMainOutput(blender_node.ObjectOps):
"model_type": (["GLB", "GLTF_EMBEDDED"],),
"write_mode": (["Overwrite", "Increment"],),
"blendshapes": ("blendshapes",),
"SHAPE_FLOW": ("SHAPE_FLOW",),
}
OUTPUT_NODE = True
RETURN_TYPES = ()
def blender_process(self, bpy, BPY_OBJ, BPY_OBJS=None, open_in_blender=False, blender_path_override='', filename='', model_type='', write_mode='', blendshapes=''):
def blender_process(self, bpy, BPY_OBJ=None, BPY_OBJS=None, open_in_blender=False, blender_path_override='', filename='', model_type='', write_mode='', SHAPE_FLOW=''):
if open_in_blender:
p = blender_path_override if blender_path_override else global_blender_path
output_file = self.output_dir + '/tmp.blend'
@@ -66,4 +66,4 @@ class AvatarMainOutput(blender_node.ObjectOps):
self.output_dir, objs, filename, model_type, write_mode, blendshapes
)
return {"ui": {"gltfFilename": {filepath.replace(f"{self.output_dir}/", "")}, "blendshapes": {blendshapes}}}
return {"ui": {"gltfFilename": {filepath.replace(f"{self.output_dir}/", "")}, "SHAPE_FLOW": {SHAPE_FLOW}}}
+5 -6
View File
@@ -4,21 +4,20 @@ class CreateShapeFlow():
def INPUT_TYPES(s):
return {
"required": {
"blendshapes": ("STRING", {
"shape_flow": ("STRING", {
"multiline": False,
"default": "{node: ''}"
"default": '{"nodes": ""}'
}),
},
}
RETURN_TYPES = ("blendshapes",)
RETURN_NAMES = ("blendshapes",)
RETURN_TYPES = ("SHAPE_FLOW",)
FUNCTION = "process"
CATEGORY = "mesh"
def process(self, blendshapes):
return (blendshapes,)
def process(self, shape_flow):
return (shape_flow,)
# A dictionary that contains all nodes you want to export with their names
# NOTE: names should be globally unique
+18 -13
View File
@@ -1,32 +1,37 @@
import { iframeSrc, showEditor } from './state.js';
import { van } from './van.js';
const { button, iframe, div, img } = van.tags;
import { iframeSrc, showEditor } from "./state.js";
import { van } from "./van.js";
const { button, iframe, div, img, span } = van.tags;
export function AvatarEditor() {
return div(
{
class: 'w-full h-full',
class: "w-full h-full relative",
},
button(
{
class: () =>
'px-4 py-2 rounded-md absolute left-0 top-0 z-[100] bg-gray-800 pointer-events-auto ' +
(showEditor.val ? '' : 'hidden'),
"btn btn-circle flex flex-row btn-ghost normal-case absolute p-0 rounded-md left-0 top-0 z-[200] w-fit pointer-events-auto bg-black " +
(showEditor.val ? "" : "hidden"),
onclick: () => {
console.log('close');
console.log("close");
showEditor.val = false;
},
},
'back',
span({
class: "iconify text-lg",
"data-icon": "ic:baseline-arrow-back",
"data-inline": "false",
}),
div("Back")
),
iframe({
id: 'avatech-editor-iframe',
title: 'avatech-editor-iframe',
name: 'avatech-editor-iframe',
id: "avatech-editor-iframe",
title: "avatech-editor-iframe",
name: "avatech-editor-iframe",
allow: "cross-origin-isolated",
class: () =>
'w-full h-full pointer-events-auto ' + (showEditor.val ? '' : 'hidden'),
"w-full h-full pointer-events-auto " + (showEditor.val ? "" : "hidden"),
src: iframeSrc,
}),
})
);
}
+5 -4
View File
@@ -199,7 +199,7 @@ function openInAvatechEditor(url, fileName) {
key: "key",
value: fileName,
method: "store",
blendshapes: targetNode.val.widgets.find((x) => x.name === "blendshapes")
blendshapes: targetNode.val.widgets.find((x) => x.name === "shape_flow")
.value,
},
"*"
@@ -207,7 +207,7 @@ function openInAvatechEditor(url, fileName) {
}
function updateBlendshapesPrompts(value) {
targetNode.val.widgets.find((x) => x.name === "blendshapes").value = value;
targetNode.val.widgets.find((x) => x.name === "shape_flow").value = value;
targetNode.val.graph.change();
}
@@ -324,7 +324,7 @@ const ext = {
};
},
BLENDSHAPES_CONFIG(node, inputName, inputData, app) {
const btn = node.addWidget("button", "Edit blendshapes", "", () => {
const btn = node.addWidget("button", "Edit Shape Flow", "", () => {
targetNode.val = node;
openInAvatechEditor(
"https://editor.avatech.ai?comfyui=true",
@@ -405,7 +405,7 @@ const ext = {
viewer.postMessage(
JSON.stringify({
avatarURL: gltfFilename,
blendshapes: evt.detail?.output.blendshapes[0],
blendshapes: evt.detail?.output.SHAPE_FLOW[0],
}),
"*"
);
@@ -418,6 +418,7 @@ const ext = {
if (event.key === "Escape") {
event.preventDefault();
showImageEditor.val = false;
showEditor.val = false;
}
},
{
+1 -1
View File
File diff suppressed because one or more lines are too long