mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-19 08:05:20 +00:00
15 files changed
+350
-148
No files matched your search
@@ -22,12 +22,8 @@ export const PageEnigma = () => {
|
||||
useSignals();
|
||||
useEffect(() => {
|
||||
function setPage() {
|
||||
const pxRatioWidth =
|
||||
window.screen.availWidth / document.documentElement.clientWidth;
|
||||
const pxRatioHeight =
|
||||
window.screen.availHeight / document.documentElement.clientHeight;
|
||||
pageHeight.value = window.outerHeight / pxRatioHeight;
|
||||
pageWidth.value = window.outerWidth / pxRatioWidth;
|
||||
pageHeight.value = window.innerHeight / window.devicePixelRatio;
|
||||
pageWidth.value = window.outerWidth / window.devicePixelRatio;
|
||||
}
|
||||
timelineHeight.value = window.innerHeight * 0.25;
|
||||
sidePanelWidth.value = 443;
|
||||
|
||||
@@ -53,7 +53,6 @@ export const PageEnigmaComponent = () => {
|
||||
const width = sidePanelVisible.value
|
||||
? pageWidth.value - dndWidth - 66
|
||||
: pageWidth.value - 66;
|
||||
|
||||
const height =
|
||||
dndTimelineHeight.value > -1
|
||||
? pageHeight.value - dndTimelineHeight.value - 68
|
||||
|
||||
@@ -7,19 +7,20 @@ import {
|
||||
} from "~/pages/PageEnigma/models";
|
||||
import { toTimelineActions } from "./toTimelineActions";
|
||||
import { ClipUI } from "../datastructures/clips/clip_ui";
|
||||
import { MediaItem } from "~/pages/PageEnigma/models";
|
||||
class Queue {
|
||||
private _queue: Record<
|
||||
string,
|
||||
{
|
||||
action: fromEngineActions | toEngineActions | toTimelineActions;
|
||||
data: QueueClip | UpdateTime | QueueKeyframe | ClipUI[];
|
||||
data: QueueClip | UpdateTime | QueueKeyframe | ClipUI[] | MediaItem;
|
||||
}[]
|
||||
> = {};
|
||||
private _subscribers: Record<
|
||||
string,
|
||||
(entry: {
|
||||
action: fromEngineActions | toEngineActions | toTimelineActions;
|
||||
data: QueueClip | UpdateTime | QueueKeyframe | ClipUI[];
|
||||
data: QueueClip | UpdateTime | QueueKeyframe | ClipUI[] | MediaItem;
|
||||
}) => void
|
||||
> = {};
|
||||
|
||||
@@ -30,7 +31,7 @@ class Queue {
|
||||
}: {
|
||||
queueName: string;
|
||||
action: fromEngineActions | toEngineActions | toTimelineActions;
|
||||
data: QueueClip | UpdateTime | QueueKeyframe | ClipUI[] ;
|
||||
data: QueueClip | UpdateTime | QueueKeyframe | ClipUI[] | MediaItem ;
|
||||
}) {
|
||||
if (!this._queue[queueName]) {
|
||||
this._queue[queueName] = [];
|
||||
@@ -47,7 +48,7 @@ class Queue {
|
||||
queueName: string,
|
||||
onMessage: (entry: {
|
||||
action: fromEngineActions | toEngineActions | toTimelineActions;
|
||||
data: QueueClip | UpdateTime | QueueKeyframe | ClipUI[];
|
||||
data: QueueClip | UpdateTime | QueueKeyframe | ClipUI[] | MediaItem;
|
||||
}) => void,
|
||||
) {
|
||||
this._subscribers[queueName] = onMessage;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
export enum fromEngineActions {
|
||||
UPDATE_TIME = "update_time",
|
||||
UPDATE_TIME_LINE = "update_timeline",
|
||||
UPDATE_CHARACTER_ID = "update_character_id",
|
||||
// data={currentTime: number}
|
||||
}
|
||||
@@ -2,6 +2,11 @@ export enum toEngineActions {
|
||||
ADD_CLIP = "add_clip",
|
||||
// data=QueueClip
|
||||
ADD_KEYFRAME = "add_keyframe",
|
||||
|
||||
ADD_CHARACTER = "add_character",
|
||||
|
||||
ADD_OBJECT = "add_object",
|
||||
|
||||
// data= QueueKeyframe
|
||||
DELETE_CLIP = "delete_clip",
|
||||
// data=QueueClip
|
||||
|
||||
@@ -1,21 +1,95 @@
|
||||
import { fromEngineActions } from "~/pages/PageEnigma/Queue/fromEngineActions";
|
||||
import { useSignals } from "@preact/signals-react/runtime";
|
||||
import { useCallback, useContext, useEffect } from "react";
|
||||
import { currentTime } from "~/pages/PageEnigma/store";
|
||||
import {
|
||||
audioGroup,
|
||||
cameraGroup,
|
||||
characterGroups,
|
||||
currentTime,
|
||||
objectGroup,
|
||||
} from "~/pages/PageEnigma/store";
|
||||
import Queue from "~/pages/PageEnigma/Queue/Queue";
|
||||
import { QueueNames } from "~/pages/PageEnigma/Queue/QueueNames";
|
||||
import { toEngineActions } from "~/pages/PageEnigma/Queue/toEngineActions";
|
||||
import {
|
||||
CharacterGroup,
|
||||
Clip,
|
||||
ClipGroup,
|
||||
ClipType,
|
||||
Keyframe,
|
||||
MediaItem,
|
||||
ObjectTrack,
|
||||
QueueClip,
|
||||
QueueKeyframe,
|
||||
UpdateTime,
|
||||
} from "~/pages/PageEnigma/models";
|
||||
import { TrackContext } from "~/pages/PageEnigma/contexts/TrackContext/TrackContext";
|
||||
import { toTimelineActions } from "~/pages/PageEnigma/Queue/toTimelineActions";
|
||||
import { ClipUI } from "~/pages/PageEnigma/datastructures/clips/clip_ui";
|
||||
|
||||
interface Arguments {
|
||||
action: fromEngineActions | toEngineActions | toTimelineActions;
|
||||
data: QueueClip | UpdateTime | QueueKeyframe;
|
||||
data: QueueClip | UpdateTime | QueueKeyframe | ClipUI[] | MediaItem;
|
||||
}
|
||||
|
||||
function addCharacter(item: ClipUI) {
|
||||
const existingCharacter = characterGroups.value.find(
|
||||
(character) => character.id === item.object_uuid,
|
||||
);
|
||||
|
||||
if (existingCharacter) {
|
||||
return existingCharacter;
|
||||
}
|
||||
|
||||
const newCharacter = {
|
||||
id: item.object_uuid,
|
||||
name: item.object_name,
|
||||
muted: false,
|
||||
animationClips: [],
|
||||
positionKeyframes: [],
|
||||
lipSyncClips: [],
|
||||
} as CharacterGroup;
|
||||
|
||||
characterGroups.value = [
|
||||
...characterGroups.value.filter(
|
||||
(character) => character.id !== item.object_uuid,
|
||||
),
|
||||
newCharacter,
|
||||
].sort((charA, charB) => (charA.id < charB.id ? -1 : 1));
|
||||
|
||||
return characterGroups.value.find(
|
||||
(character) => character.id === item.object_uuid,
|
||||
) as CharacterGroup;
|
||||
}
|
||||
|
||||
function addObject(item: ClipUI) {
|
||||
const existingObject = objectGroup.value.objects.find(
|
||||
(obj) => obj.object_uuid === item.object_uuid,
|
||||
);
|
||||
|
||||
if (existingObject) {
|
||||
return existingObject;
|
||||
}
|
||||
|
||||
const newObject = {
|
||||
object_uuid: item.object_uuid,
|
||||
name: item.object_name,
|
||||
keyframes: [] as Keyframe[],
|
||||
} as ObjectTrack;
|
||||
|
||||
objectGroup.value = {
|
||||
id: "OB1",
|
||||
objects: [
|
||||
...objectGroup.value.objects.filter(
|
||||
(obj) => obj.object_uuid !== item.object_uuid,
|
||||
),
|
||||
newObject,
|
||||
].sort((objA, objB) => (objA.object_uuid < objB.object_uuid ? -1 : 1)),
|
||||
};
|
||||
|
||||
return objectGroup.value.objects.find(
|
||||
(obj) => obj.object_uuid === item.object_uuid,
|
||||
) as ObjectTrack;
|
||||
}
|
||||
|
||||
export function useQueueHandler() {
|
||||
@@ -29,7 +103,122 @@ export function useQueueHandler() {
|
||||
currentTime.value = (data as UpdateTime).currentTime;
|
||||
break;
|
||||
case fromEngineActions.UPDATE_TIME_LINE:
|
||||
console.log(action)
|
||||
console.log(data);
|
||||
(data as ClipUI[]).forEach((item) => {
|
||||
if (item.group === ClipGroup.CHARACTER) {
|
||||
const existingCharacter = addCharacter(item);
|
||||
if (item.type === ClipType.ANIMATION) {
|
||||
const newItem = {
|
||||
version: item.version,
|
||||
clip_uuid: item.clip_uuid,
|
||||
type: item.type,
|
||||
group: item.group,
|
||||
object_uuid: item.object_uuid,
|
||||
media_id: item.media_id,
|
||||
name: item.name,
|
||||
offset: item.offset,
|
||||
length: item.length,
|
||||
} as Clip;
|
||||
existingCharacter.animationClips.push(newItem);
|
||||
existingCharacter.animationClips.sort(
|
||||
(clipA, clipB) => clipA.offset - clipB.offset,
|
||||
);
|
||||
}
|
||||
if (item.type === ClipType.TRANSFORM) {
|
||||
const newKeyframe = {
|
||||
version: item.version,
|
||||
keyframe_uuid: item.clip_uuid,
|
||||
group: item.group,
|
||||
object_uuid: item.object_uuid,
|
||||
offset: item.keyframe_offset,
|
||||
} as Keyframe;
|
||||
existingCharacter.positionKeyframes.push(newKeyframe);
|
||||
existingCharacter.positionKeyframes.sort(
|
||||
(keyframeA, keyframeB) => keyframeA.offset - keyframeB.offset,
|
||||
);
|
||||
}
|
||||
if (item.type === ClipType.AUDIO) {
|
||||
const newItem = {
|
||||
version: item.version,
|
||||
clip_uuid: item.clip_uuid,
|
||||
type: item.type,
|
||||
group: item.group,
|
||||
object_uuid: item.object_uuid,
|
||||
media_id: item.media_id,
|
||||
name: item.name,
|
||||
offset: item.offset,
|
||||
length: item.length,
|
||||
} as Clip;
|
||||
existingCharacter.lipSyncClips.push(newItem);
|
||||
existingCharacter.lipSyncClips.sort(
|
||||
(clipA, clipB) => clipA.offset - clipB.offset,
|
||||
);
|
||||
}
|
||||
}
|
||||
if (item.group === ClipGroup.OBJECT) {
|
||||
const existingObject = addObject(item);
|
||||
const newKeyframe = {
|
||||
version: item.version,
|
||||
keyframe_uuid: item.clip_uuid,
|
||||
group: item.group,
|
||||
object_uuid: item.object_uuid,
|
||||
offset: item.keyframe_offset,
|
||||
} as Keyframe;
|
||||
existingObject.keyframes.push(newKeyframe);
|
||||
existingObject.keyframes.sort(
|
||||
(keyframeA, keyframeB) => keyframeA.offset - keyframeB.offset,
|
||||
);
|
||||
}
|
||||
if (item.group === ClipGroup.CAMERA) {
|
||||
const existingCamera = cameraGroup.value;
|
||||
const newKeyframe = {
|
||||
version: item.version,
|
||||
keyframe_uuid: item.clip_uuid,
|
||||
group: item.group,
|
||||
object_uuid: item.object_uuid,
|
||||
offset: item.keyframe_offset,
|
||||
} as Keyframe;
|
||||
existingCamera.keyframes.push(newKeyframe);
|
||||
existingCamera.keyframes.sort(
|
||||
(keyframeA, keyframeB) => keyframeA.offset - keyframeB.offset,
|
||||
);
|
||||
// cameraGroup.value = { ...cameraGroup.value };
|
||||
}
|
||||
if (item.group === ClipGroup.GLOBAL_AUDIO) {
|
||||
const existingAudio = audioGroup.value;
|
||||
const newItem = {
|
||||
version: item.version,
|
||||
clip_uuid: item.clip_uuid,
|
||||
type: item.type,
|
||||
group: item.group,
|
||||
object_uuid: item.object_uuid,
|
||||
media_id: item.media_id,
|
||||
name: item.name,
|
||||
offset: item.offset,
|
||||
length: item.length,
|
||||
} as Clip;
|
||||
existingAudio.clips.push(newItem);
|
||||
existingAudio.clips.sort(
|
||||
(clipA, clipB) => clipA.offset - clipB.offset,
|
||||
);
|
||||
}
|
||||
});
|
||||
break;
|
||||
case fromEngineActions.UPDATE_CHARACTER_ID: {
|
||||
const newCharacter = {
|
||||
id: (data as MediaItem).object_uuid,
|
||||
name: (data as MediaItem).name,
|
||||
muted: false,
|
||||
animationClips: [],
|
||||
positionKeyframes: [],
|
||||
lipSyncClips: [],
|
||||
} as CharacterGroup;
|
||||
|
||||
characterGroups.value = [...characterGroups.value, newCharacter].sort(
|
||||
(charA, charB) => (charA.id < charB.id ? -1 : 1),
|
||||
);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new Error(`Unknown action ${action}`);
|
||||
}
|
||||
|
||||
@@ -6,10 +6,12 @@ import {
|
||||
addCharacterAnimation,
|
||||
addCharacterAudio,
|
||||
addGlobalAudio,
|
||||
addCharacter,
|
||||
canDrop,
|
||||
dragItem,
|
||||
dropId,
|
||||
dropOffset,
|
||||
addObject,
|
||||
} from "~/pages/PageEnigma/store";
|
||||
import useUpdateKeyframe from "~/pages/PageEnigma/contexts/TrackContext/utils/useUpdateKeyframe";
|
||||
|
||||
@@ -24,8 +26,25 @@ export const TrackProvider = ({ children }: Props) => {
|
||||
|
||||
// cross group functions
|
||||
const dropClip = useCallback(() => {
|
||||
console.log(`${JSON.stringify(dragItem)}`);
|
||||
|
||||
if (dragItem.value != null && dragItem != null) {
|
||||
// should be able to drag into the timeline ... TODO FIX?
|
||||
|
||||
if (dragItem.value.type === AssetType.CHARACTER) {
|
||||
addCharacter(dragItem.value);
|
||||
}
|
||||
// if (dragItem.value.type === AssetType.CAMERA) {
|
||||
// console.log("Dragged In Camera Type")
|
||||
// }
|
||||
if (dragItem.value.type === AssetType.OBJECT) {
|
||||
addObject(dragItem.value);
|
||||
}
|
||||
}
|
||||
// if (dragItem.value.type === AssetType.SHAPE) {
|
||||
// console.log("Dragged In Shape Type")
|
||||
// }
|
||||
|
||||
console.log(`${canDrop.value} ${dragItem.value} ${dragItem.value.type}`)
|
||||
if (canDrop.value && dragItem.value) {
|
||||
if (dragItem.value.type === AssetType.ANIMATION) {
|
||||
addCharacterAnimation({
|
||||
@@ -35,6 +54,7 @@ export const TrackProvider = ({ children }: Props) => {
|
||||
});
|
||||
}
|
||||
if (dragItem.value.type === AssetType.AUDIO) {
|
||||
console.log("add audio", dropId.value);
|
||||
addCharacterAudio({
|
||||
dragItem: dragItem.value!,
|
||||
characterId: dropId.value,
|
||||
@@ -46,18 +66,6 @@ export const TrackProvider = ({ children }: Props) => {
|
||||
offset: dropOffset.value,
|
||||
});
|
||||
}
|
||||
if (dragItem.value.type === AssetType.CHARACTER) {
|
||||
console.log("Dragged In Character Type")
|
||||
}
|
||||
if (dragItem.value.type === AssetType.CAMERA) {
|
||||
console.log("Dragged In Camera Type")
|
||||
}
|
||||
if (dragItem.value.type === AssetType.OBJECT) {
|
||||
console.log("Dragged In Object Type")
|
||||
}
|
||||
if (dragItem.value.type === AssetType.SHAPE) {
|
||||
console.log("Dragged In Shape Type")
|
||||
}
|
||||
}
|
||||
endDrag();
|
||||
}, [endDrag]);
|
||||
|
||||
@@ -9,9 +9,12 @@ export class ClipUI {
|
||||
name: string;
|
||||
media_id: string;
|
||||
object_uuid: string;
|
||||
object_name: string;
|
||||
offset: number; // in frames
|
||||
length: number; // in frames
|
||||
should_play: boolean;
|
||||
clip_uuid: string;
|
||||
keyframe_offset: number;
|
||||
|
||||
constructor(
|
||||
version: number,
|
||||
@@ -19,21 +22,28 @@ export class ClipUI {
|
||||
group: ClipGroup,
|
||||
name: string,
|
||||
media_id: string,
|
||||
clip_uuid: string,
|
||||
object_uuid: string,
|
||||
object_name: string,
|
||||
offset: number,
|
||||
length: number,
|
||||
keyframe_offset: number = 0,
|
||||
) {
|
||||
this.version = version;
|
||||
this.group = group; // Only needed for UI
|
||||
|
||||
this.clip_uuid = clip_uuid;
|
||||
|
||||
this.name = name; // UI
|
||||
this.type = type; // UI and Animation / Audio / Lipsync / : Engine
|
||||
|
||||
this.object_uuid = object_uuid; // Animation / Audio / Lipsync / : Engine
|
||||
this.object_name = object_name;
|
||||
this.media_id = media_id; // Animation / Audio / Lipsync / : Engine
|
||||
this.offset = offset;
|
||||
this.length = length;
|
||||
this.should_play = true;
|
||||
this.keyframe_offset = keyframe_offset;
|
||||
}
|
||||
|
||||
toJSON(): any {
|
||||
@@ -42,10 +52,13 @@ export class ClipUI {
|
||||
group: this.group,
|
||||
name: this.name,
|
||||
type: this.type,
|
||||
clip_uuid: this.clip_uuid,
|
||||
object_uuid: this.object_uuid,
|
||||
object_name: this.object_name,
|
||||
media_id: this.media_id,
|
||||
start_offset: this.offset,
|
||||
ending_offset: this.length,
|
||||
keyframe_offset: this.keyframe_offset,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -311,7 +311,7 @@ class Editor {
|
||||
|
||||
this.timeline.scene = this.activeScene;
|
||||
|
||||
this._test_demo();
|
||||
//this._test_demo();
|
||||
|
||||
this.renderer.domElement.addEventListener(
|
||||
"mousedown",
|
||||
@@ -1076,7 +1076,6 @@ class Editor {
|
||||
this.raycaster.setFromCamera(this.mouse, this.camera);
|
||||
const interactable: any[] = [];
|
||||
this.activeScene.scene.children.forEach((child: THREE.Object3D) => {
|
||||
// console.log(child);
|
||||
if (child.name != "") {
|
||||
if (child.type == "Mesh" || child.type == "Object3D" || child.type == "Group") {
|
||||
interactable.push(child);
|
||||
|
||||
@@ -42,6 +42,7 @@ export class TimeLine {
|
||||
animation_engine: AnimationEngine;
|
||||
// lip sync engine
|
||||
lipSync_engine: LipSyncEngine;
|
||||
characters: {[key: string]: string};
|
||||
|
||||
scene: Scene;
|
||||
|
||||
@@ -55,6 +56,7 @@ export class TimeLine {
|
||||
scene: Scene,
|
||||
) {
|
||||
this.timeline_items = [];
|
||||
this.characters = {};
|
||||
this.absolute_end = 60 * 12;
|
||||
this.timeline_limit = 0; // 5 seconds
|
||||
|
||||
@@ -124,11 +126,47 @@ export class TimeLine {
|
||||
case toEngineActions.UNMUTE:
|
||||
await this.mute(data, true);
|
||||
break;
|
||||
case toEngineActions.ADD_CHARACTER:
|
||||
await this.addCharacter(data);
|
||||
break;
|
||||
case toEngineActions.ADD_OBJECT:
|
||||
await this.addObject(data);
|
||||
break;
|
||||
default:
|
||||
console.log("Action Not Wired", action);
|
||||
}
|
||||
}
|
||||
|
||||
public async addCharacter(data: any) {
|
||||
let media_id = data.data['media_id'];
|
||||
let name = data.data['name'];
|
||||
let type = data.data['type'];
|
||||
|
||||
let obj = await this.scene.load_glb(media_id);
|
||||
obj.userData['name'] = name;
|
||||
obj.name = name;
|
||||
let object_uuid = obj.uuid;
|
||||
|
||||
console.log("data.data", data.data)
|
||||
|
||||
this.characters[object_uuid] = type;
|
||||
|
||||
data.data['object_uuid'] = object_uuid;
|
||||
Queue.publish({
|
||||
queueName: QueueNames.FROM_ENGINE,
|
||||
action: fromEngineActions.UPDATE_CHARACTER_ID,
|
||||
data: data.data,
|
||||
});
|
||||
}
|
||||
|
||||
public async addObject(data: any) {
|
||||
let media_id = data.data['media_id'];
|
||||
let name = data.data['name'];
|
||||
let obj = await this.scene.load_glb(media_id);
|
||||
obj.userData['name'] = name;
|
||||
obj.name = name;
|
||||
}
|
||||
|
||||
public async addKeyFrame(data: any) {
|
||||
// KeyFrame Object
|
||||
// version: number;
|
||||
@@ -142,12 +180,21 @@ export class TimeLine {
|
||||
// selected?: boolean;
|
||||
let data_json = data['data'];
|
||||
let uuid = data_json['object_uuid'];
|
||||
let keyframe_uuid = data_json['keyframe_uuid'];
|
||||
|
||||
let object_name = this.scene.get_object_by_uuid(uuid)?.name;
|
||||
if (object_name == undefined) {
|
||||
object_name = "undefined"
|
||||
}
|
||||
|
||||
for (let key in this.characters) {
|
||||
let element = this.characters[key];
|
||||
if (key == uuid) {
|
||||
data_json['group'] = element;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let new_item = this.transform_engine.addFrame(uuid,
|
||||
this.absolute_end,
|
||||
data_json['position'],
|
||||
@@ -162,9 +209,12 @@ export class TimeLine {
|
||||
data_json['group'],
|
||||
object_name,
|
||||
"",
|
||||
keyframe_uuid,
|
||||
uuid,
|
||||
object_name,
|
||||
0,
|
||||
this.absolute_end))
|
||||
this.absolute_end,
|
||||
data_json['offset']))
|
||||
}
|
||||
|
||||
this.scene.createPoint(data_json['position'], data_json['keyframe_uuid']);
|
||||
@@ -184,6 +234,13 @@ export class TimeLine {
|
||||
const type = data["data"]["type"];
|
||||
const offset = data["data"]["offset"];
|
||||
const end_offset = data["data"]["length"] + offset;
|
||||
let object_name = this.scene.get_object_by_uuid(object_uuid)?.name;
|
||||
const clip_uuid = data["data"]['clip_uuid'];
|
||||
console.log(data);
|
||||
|
||||
if(object_name == undefined) {
|
||||
object_name = "Undefined."
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case "animation":
|
||||
@@ -199,11 +256,13 @@ export class TimeLine {
|
||||
this.addPlayableClip(
|
||||
new ClipUI(
|
||||
version,
|
||||
"lipsync",// TODO potiential bug ..
|
||||
"lipsync", // TODO potiential bug ..
|
||||
group,
|
||||
name,
|
||||
media_id,
|
||||
clip_uuid,
|
||||
object_uuid,
|
||||
object_name,
|
||||
offset,
|
||||
end_offset));
|
||||
return;
|
||||
@@ -221,7 +280,9 @@ export class TimeLine {
|
||||
group,
|
||||
name,
|
||||
media_id,
|
||||
clip_uuid,
|
||||
object_uuid,
|
||||
object_name,
|
||||
offset,
|
||||
end_offset,
|
||||
),
|
||||
@@ -286,6 +347,7 @@ export class TimeLine {
|
||||
}
|
||||
|
||||
public async addPlayableClip(clip: ClipUI): Promise<void> {
|
||||
console.log("clip", clip)
|
||||
this.timeline_items.push(clip);
|
||||
}
|
||||
|
||||
@@ -449,96 +511,3 @@ export class TimeLine {
|
||||
}
|
||||
}
|
||||
|
||||
// How much timeline precision we have
|
||||
//const percision = 100 // using a fake update loop mock
|
||||
//
|
||||
//class AudioEngineMock {
|
||||
// async play(media_id:string) {
|
||||
// console.log("Audio Playing {media_id}")
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//// Visual verification tests.
|
||||
//function CheckIfBasicAudioClipWorks() {
|
||||
// const timeline = new TimeLine()
|
||||
// timeline.addPlayableClip(new ClipUI(1.0,'audio',1,0))
|
||||
// timeline.play()
|
||||
//}
|
||||
//
|
||||
//function CheckIfBasicTransformClipWorks() {
|
||||
// const timeline = new TimeLine()
|
||||
// timeline.addPlayableClip(new ClipUI(1.0,'transform',2,0))
|
||||
// timeline.play()
|
||||
//}
|
||||
//
|
||||
//function CheckIfBasicClipWorks() {
|
||||
// const timeline = new TimeLine()
|
||||
// timeline.addPlayableClip(new ClipUI(1.0,'animation',3,0))
|
||||
// timeline.play()
|
||||
//}
|
||||
|
||||
// function CheckIfBasicClipWorks3SecondsAfterTimelineStops() {
|
||||
// const timeline = new TimeLine()
|
||||
// timeline.addPlayableClip(new ClipUI("clip1", 0, 10000))
|
||||
// timeline.play()
|
||||
// }
|
||||
|
||||
// function CheckIfTwoClipsAtTheSameTimeWorks() {
|
||||
// const timeline = new TimeLine()
|
||||
// timeline.addPlayableClip(new ClipUI("clip1", 0, 1000))
|
||||
// timeline.play()
|
||||
// }
|
||||
|
||||
// function CheckIfTwoClipsOneAfterAnotherWorks() {
|
||||
// const timeline = new TimeLine()
|
||||
// timeline.addPlayableClip(new ClipUI("clip1", 0, 1000))
|
||||
// timeline.addPlayableClip(new ClipUI("clip2", 0, 2000))
|
||||
// timeline.play()
|
||||
// }
|
||||
|
||||
// function CheckIfTimeLineStopBeforeClipPlays() {
|
||||
// const timeline = new TimeLine()
|
||||
// timeline.addPlayableClip(new ClipUI("clip3",0,1000))
|
||||
// timeline.play()
|
||||
// setInterval(async ()=> {
|
||||
// timeline.stop()
|
||||
// },1100)
|
||||
// console.log("Stopped")
|
||||
// }
|
||||
|
||||
// function CheckIfTimeLineStartAfterClipPlays() {
|
||||
// const timeline = new TimeLine()
|
||||
// timeline.addPlayableClip(new ClipUI("clip3",0,1000))
|
||||
// timeline.play()
|
||||
// setInterval(async ()=> {
|
||||
// timeline.stop()
|
||||
// },500)
|
||||
// console.log("Stopped")
|
||||
// }
|
||||
|
||||
// function CheckIfClipsPlayAllTogetherConcurrently() {
|
||||
// const timeline = new TimeLine()
|
||||
// timeline.addPlayableClip(new ClipUI("clip1",0,1000))
|
||||
// timeline.addPlayableClip(new ClipUI("clip2",0,1000))
|
||||
// timeline.addPlayableClip(new ClipUI("clip3",0,1000))
|
||||
// timeline.addPlayableClip(new ClipUI("clip4",0,1000))
|
||||
// timeline.play()
|
||||
// }
|
||||
|
||||
// function CheckIfClipsPlayAllTogether() {
|
||||
// const timeline = new TimeLine()
|
||||
// timeline.addPlayableClip(new TrackClip("clip1",0,1000))
|
||||
// timeline.addPlayableClip(new TrackClip("clip2",0,1000))
|
||||
// timeline.addPlayableClip(new TrackClip("clip3",0,1000))
|
||||
// timeline.addPlayableClip(new TrackClip("clip4",0,1000))
|
||||
// timeline.play()
|
||||
// }
|
||||
|
||||
//CheckIfBasicClipWorks()
|
||||
//CheckIfTwoClipsAtTheSameTimeWorks()
|
||||
// CheckIfTwoClipsOneAfterAnotherWorks()
|
||||
// CheckIfTimeLineStopBeforeClipPlays()
|
||||
// CheckIfTimeLineStartAfterClipPlays()
|
||||
// CheckIfClipsPlayAllTogetherConcurrently()
|
||||
|
||||
// CheckIfClipsPlayAllTogether()
|
||||
@@ -2,9 +2,10 @@ export interface MediaItem {
|
||||
version: number;
|
||||
type: AssetType;
|
||||
media_id: string;
|
||||
object_uuid?: string;
|
||||
name: string;
|
||||
length?: number;
|
||||
thumbnail: string;
|
||||
thumbnail?: string;
|
||||
isMine?: boolean;
|
||||
isBookmarked?: boolean;
|
||||
}
|
||||
@@ -16,7 +17,7 @@ export enum AssetType {
|
||||
ANIMATION = "animation",
|
||||
CAMERA = "camera",
|
||||
SHAPE = "shape",
|
||||
STYLE = "style" // TODO Remove
|
||||
STYLE = "style", // TODO Remove
|
||||
}
|
||||
|
||||
export enum AssetFilterOption {
|
||||
|
||||
@@ -17,7 +17,6 @@ export enum ClipType {
|
||||
TRANSFORM = "transform",
|
||||
AUDIO = "audio",
|
||||
ANIMATION = "animation",
|
||||
LIPSYNC = "lipsync"
|
||||
}
|
||||
|
||||
export enum ClipGroup {
|
||||
@@ -41,6 +40,7 @@ export interface Keyframe {
|
||||
|
||||
export interface CharacterGroup {
|
||||
id: string;
|
||||
name: string;
|
||||
muted: boolean;
|
||||
animationClips: Clip[];
|
||||
positionKeyframes: Keyframe[];
|
||||
|
||||
@@ -53,6 +53,8 @@ export class StoryTellerProxyTimeline {
|
||||
audio: await this.getItemsDict(this.audio_engine.clips),
|
||||
lipsync: await this.getItemsDict(this.lipsync_engine.clips),
|
||||
}
|
||||
console.log(timeline_json)
|
||||
|
||||
return timeline_json;
|
||||
}
|
||||
|
||||
@@ -64,8 +66,11 @@ export class StoryTellerProxyTimeline {
|
||||
let clip = new ClipUI(
|
||||
element.version, element.type,
|
||||
element.group, element.name,
|
||||
element.media_id, element.object_uuid,
|
||||
element.start_offset, element.ending_offset);
|
||||
element.media_id, element.clip_uuid,
|
||||
element.object_uuid,
|
||||
element.object_name,
|
||||
element.start_offset, element.ending_offset,
|
||||
element.keyframe_offset);
|
||||
new_clips.push(clip);
|
||||
}
|
||||
}
|
||||
@@ -124,6 +129,7 @@ export class StoryTellerProxyTimeline {
|
||||
this.lipsync_engine.clips = await this.loadLipsyncClips(timeline['lipsync']);
|
||||
this.animation_engine.clips = await this.loadAnimationClips(timeline['animation']);
|
||||
|
||||
console.log(this.timeline.timeline_items)
|
||||
|
||||
this.timeline.updateUI()
|
||||
}
|
||||
|
||||
@@ -13,15 +13,7 @@ import { QueueNames } from "~/pages/PageEnigma/Queue/QueueNames";
|
||||
import { toEngineActions } from "~/pages/PageEnigma/Queue/toEngineActions";
|
||||
import * as uuid from "uuid";
|
||||
|
||||
export const characterGroups = signal<CharacterGroup[]>([
|
||||
{
|
||||
id: "CH1",
|
||||
muted: false,
|
||||
animationClips: [],
|
||||
positionKeyframes: [],
|
||||
lipSyncClips: [],
|
||||
},
|
||||
]);
|
||||
export const characterGroups = signal<CharacterGroup[]>([]);
|
||||
|
||||
export function updateCharacters({
|
||||
type,
|
||||
@@ -181,6 +173,13 @@ export function addCharacterAudio({
|
||||
if (character.id !== characterId) {
|
||||
return { ...character };
|
||||
}
|
||||
|
||||
Queue.publish({
|
||||
queueName: QueueNames.TO_ENGINE,
|
||||
action: toEngineActions.ADD_CLIP,
|
||||
data: newClip,
|
||||
});
|
||||
|
||||
return {
|
||||
...character,
|
||||
lipSyncClips: [...character.lipSyncClips, newClip].sort(
|
||||
@@ -188,12 +187,6 @@ export function addCharacterAudio({
|
||||
),
|
||||
};
|
||||
});
|
||||
|
||||
Queue.publish({
|
||||
queueName: QueueNames.TO_ENGINE,
|
||||
action: toEngineActions.ADD_CLIP,
|
||||
data: newClip,
|
||||
});
|
||||
}
|
||||
|
||||
export function addCharacterKeyframe(keyframe: QueueKeyframe, offset: number) {
|
||||
@@ -333,3 +326,25 @@ export function deleteCharacterKeyframe(keyframe: Keyframe) {
|
||||
}),
|
||||
}));
|
||||
}
|
||||
|
||||
// probably not to much to send imo
|
||||
export function addCharacter(character: MediaItem) {
|
||||
//{"version":1,"media_id":"m_r7w1tmkx2jg8nznr3hyzj4k6zhfh7d ",
|
||||
// "type":"character","name":"Female Doll",
|
||||
// "thumbnail":"resources/characters/img03.png"}
|
||||
Queue.publish({
|
||||
queueName: QueueNames.TO_ENGINE,
|
||||
action: toEngineActions.ADD_CHARACTER,
|
||||
data: character,
|
||||
});
|
||||
}
|
||||
export function addObject(object: MediaItem) {
|
||||
//{"version":1,"media_id":"m_r7w1tmkx2jg8nznr3hyzj4k6zhfh7d ",
|
||||
// "type":"character","name":"Female Doll",
|
||||
// "thumbnail":"resources/characters/img03.png"}
|
||||
Queue.publish({
|
||||
queueName: QueueNames.TO_ENGINE,
|
||||
action: toEngineActions.ADD_OBJECT,
|
||||
data: object,
|
||||
});
|
||||
}
|
||||
@@ -94,7 +94,7 @@ export const cameraItems = signal<MediaItem[]>([
|
||||
export const characterItems = signal<MediaItem[]>([
|
||||
{
|
||||
version: 1,
|
||||
media_id: "",
|
||||
media_id: "m_fmxy8wjnep1hdaz7qdg4n7y15d2bsp",
|
||||
type: AssetType.CHARACTER,
|
||||
name: "Shrek",
|
||||
thumbnail: "resources/placeholders/placeholder.png",
|
||||
@@ -122,7 +122,7 @@ export const characterItems = signal<MediaItem[]>([
|
||||
},
|
||||
{
|
||||
version: 1,
|
||||
media_id: "m_fmxy8wjnep1hdaz7qdg4n7y15d2bsp ",
|
||||
media_id: "m_4wva09qznapzk5rcvbxy671d1qx2pr ",
|
||||
type: AssetType.CHARACTER,
|
||||
name: "Story Girl",
|
||||
thumbnail: "resources/characters/img13.png",
|
||||
@@ -132,9 +132,9 @@ export const characterItems = signal<MediaItem[]>([
|
||||
export const objectItems = signal<MediaItem[]>([
|
||||
{
|
||||
version: 1,
|
||||
media_id: "m_w5nn3kjh1fbkmjrdac5b2qaba0pmyt",
|
||||
media_id: "m_0xfrmekc56satjxn66wt6c9dkw7dxe",
|
||||
type: AssetType.OBJECT,
|
||||
name: "Item ( Place Holder D.N.W )",
|
||||
name: "Pikachu Statue",
|
||||
thumbnail: "resources/placeholders/placeholder.png",
|
||||
},
|
||||
]);
|
||||
|
||||
Reference in new issue
Block a user