mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-05 09:48:44 +00:00
fixed some animation engine stuff,.
This commit is contained in:
1 parent
c626676310
commit
467ecc122d
4 files changed
+27
-41
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import { AnimationTrackClip } from "../datastructures/clips/animation_track_clip";
|
||||
import * as THREE from 'three';
|
||||
|
||||
export class AnimationEngine {
|
||||
clips: { [key: string]: AnimationTrackClip } = {};
|
||||
@@ -11,17 +12,18 @@ export class AnimationEngine {
|
||||
this.length = length;
|
||||
}
|
||||
|
||||
load_object(object_uuid: string, clip_name: string) {
|
||||
load_object(object_uuid: string, media_id:string, clip_name: string) {
|
||||
this.clips[object_uuid] = new AnimationTrackClip(
|
||||
this.version,
|
||||
media_id,
|
||||
"glb",
|
||||
object_uuid,
|
||||
1.0, 1.0,
|
||||
clip_name);
|
||||
}
|
||||
|
||||
play(media_id: string) {
|
||||
this.clips[object_uuid].play(media_id);
|
||||
play(object: THREE.Object3D) {
|
||||
this.clips[object.uuid].play(object);
|
||||
}
|
||||
|
||||
stop(media_id: string) {
|
||||
|
||||
@@ -160,15 +160,16 @@ class Editor {
|
||||
this._test_demo()
|
||||
}
|
||||
|
||||
_test_demo() {
|
||||
async _test_demo() {
|
||||
// Test code here
|
||||
// this.test_box_uuid = this.activeScene.instantiate("Box");
|
||||
// let object = this.transform_engine.loadObject(this.test_box_uuid);
|
||||
// this.timeline.addPlayableClip(new ClipUI(1.0, "transform", object.object_uuid, object.media_id, 50, 300));
|
||||
// this.timeline.addPlayableClip(new ClipUI(1.0, "audio", "m_f7jnwt3d1ddchatdk5vaqt0n4mb1hg", null, 50, 50));
|
||||
|
||||
this.activeScene.load_glb("./resources/models/fox/fox.glb")
|
||||
|
||||
let object = await this.activeScene.load_glb("./resources/models/fox/fox.glb")
|
||||
this.lipsync_engine.load_object(object.uuid, "m_f1jxx4zwy4da2zn0cvdqhha7kqkj72");
|
||||
this.timeline.addPlayableClip(new ClipUI(1.0, "lipsync", object.object_uuid, object.media_id, 0, 100));
|
||||
}
|
||||
|
||||
// Configure post processing.
|
||||
|
||||
@@ -20,7 +20,7 @@ export class LipSyncEngine {
|
||||
this.lipsync = new LipSync()
|
||||
}
|
||||
|
||||
loadClip(audio_media_id: string) {
|
||||
load_object(object_uuid: string, audio_media_id: string) {
|
||||
this.clips[audio_media_id] = new LipSyncTrackClip(this.version, audio_media_id, 1.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -76,42 +76,25 @@ class Scene {
|
||||
this.accept_animation_clip(this.animated_items[character_uuid].anims[0]._clip);
|
||||
}
|
||||
|
||||
load_glb(filepath, object_name = null, callback = null) {
|
||||
let glbLoader = new GLTFLoader();
|
||||
glbLoader.load(filepath, (glb) => {
|
||||
glb.scene.children.forEach(child => {
|
||||
child.traverse(c => {
|
||||
if (c.isMesh) {
|
||||
c.material.metalness = 0.0;
|
||||
c.material.specular = 0.5;
|
||||
c.castShadow = true;
|
||||
c.receiveShadow = true;
|
||||
c.material.transparent = false;
|
||||
//if (c.morphTargetInfluences && c.morphTargetDictionary) {
|
||||
// const blendShapeIndexI = c.morphTargetDictionary["vrc.v_e"];
|
||||
// if (blendShapeIndexI != null){
|
||||
// c.morphTargetInfluences[blendShapeIndexI] = 1.0;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
async load_glb(filepath) { //: Promise<THREE.Object3D> {
|
||||
return new Promise((resolve) => {
|
||||
let glbLoader = new GLTFLoader();
|
||||
glbLoader.load(filepath, (glb) => {
|
||||
glb.scene.children.forEach(child => {
|
||||
child.traverse(c => {
|
||||
if (c.isMesh) {
|
||||
c.material.metalness = 0.0;
|
||||
c.material.specular = 0.5;
|
||||
c.castShadow = true;
|
||||
c.receiveShadow = true;
|
||||
c.material.transparent = false;
|
||||
}
|
||||
});
|
||||
this.scene.add(child);
|
||||
resolve(child);
|
||||
});
|
||||
if (object_name == null) {
|
||||
child.name = filepath;
|
||||
} else {
|
||||
child.name = object_name;
|
||||
}
|
||||
child.type = "Mesh";
|
||||
this.scene.add(child);
|
||||
});
|
||||
if (callback != null) {
|
||||
callback();
|
||||
}
|
||||
},
|
||||
(xhr) => {
|
||||
},
|
||||
(error) => {
|
||||
console.log(error)
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// default skybox.
|
||||
|
||||
Reference in new issue
Block a user