mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-02 00:18:17 +00:00
Feature/bugfix mmd (#655)
This commit is contained in:
1 parent
810cad5785
commit
e0b59a7b53
3 files changed
+16
-19
No files matched your search
@@ -667,6 +667,10 @@ class Scene {
|
||||
media_url: string,
|
||||
progress: (event: ProgressEvent) => void,
|
||||
): Promise<THREE.SkinnedMesh> {
|
||||
|
||||
// TODO: When converted to ts remove this and make ammo await instead.
|
||||
await this.delay_mmd(100);
|
||||
|
||||
console.log('Load MMD')
|
||||
const scriptModule = document.createElement('script');
|
||||
scriptModule.type = 'module';
|
||||
|
||||
@@ -835,11 +835,6 @@ export class TimeLine {
|
||||
this.is_playing,
|
||||
this.scrubber_frame_position, // Double FPS for best result.
|
||||
);
|
||||
let mmdDelta = delta_time;
|
||||
if(mmdDelta == 0){
|
||||
mmdDelta = 0.001;
|
||||
}
|
||||
this.scene.helper.update(mmdDelta);
|
||||
//this.animation_engine.clips[object.uuid + element.media_id].update_bones();
|
||||
}
|
||||
} else if (element.type === ClipType.EXPRESSION) {
|
||||
@@ -849,15 +844,11 @@ export class TimeLine {
|
||||
].step(this.scrubber_frame_position - element.offset, object);
|
||||
}
|
||||
}
|
||||
//this.timelineItems = this.timelineItems.filter(item => item !== element)
|
||||
}
|
||||
}
|
||||
|
||||
// if(isRendering === false){
|
||||
// for (const video_plane of this.scene.video_planes) {
|
||||
// video_plane.pause();
|
||||
// }
|
||||
// }
|
||||
|
||||
this.scene.helper.update(0.1);
|
||||
|
||||
if (
|
||||
this.scrubber_frame_position >= this.timeline_limit &&
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as THREE from "three";
|
||||
import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js";
|
||||
import { FBXLoader, MMDAnimationHelper } from "three/examples/jsm/Addons.js";
|
||||
import { FBXLoader, MMDAnimationHelper, MMDAnimationHelperMixer } from "three/examples/jsm/Addons.js";
|
||||
import { MMDLoader } from "three/addons/loaders/MMDLoader.js";
|
||||
|
||||
import { MoveAIResult, Retarget } from "../../Editor/retargeting";
|
||||
@@ -23,6 +23,7 @@ export class AnimationClip {
|
||||
last_frame: number;
|
||||
|
||||
private isMMD: boolean = false;
|
||||
private obj: MMDAnimationHelperMixer | undefined;
|
||||
|
||||
constructor(
|
||||
version: number,
|
||||
@@ -132,13 +133,6 @@ export class AnimationClip {
|
||||
this.clip_action = this.mixer?.clipAction(anim_clip);
|
||||
if (this.clip_action) {
|
||||
if (this.clip_action?.isRunning() == false) {
|
||||
if(this.isMMD) {
|
||||
const helper: MMDAnimationHelper = object.parent?.userData["helper"];
|
||||
const obj = helper.objects.get((object as THREE.SkinnedMesh));
|
||||
if(obj) {
|
||||
obj.mixer = this.mixer;
|
||||
}
|
||||
}
|
||||
this.clip_action.play();
|
||||
}
|
||||
}
|
||||
@@ -202,6 +196,14 @@ export class AnimationClip {
|
||||
}
|
||||
|
||||
animate(deltatime: number) {
|
||||
if(this.isMMD && this.mixer) {
|
||||
const helper: MMDAnimationHelper = this.mixer?.getRoot().parent?.userData["helper"];
|
||||
this.obj = helper.objects.get((this.mixer?.getRoot() as THREE.SkinnedMesh));
|
||||
if(this.obj && this.obj.mixer !== this.mixer) {
|
||||
this.obj.mixer = this.mixer;
|
||||
}
|
||||
}
|
||||
|
||||
this.mixer?.setTime(deltatime);
|
||||
this.update_bones();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user