mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-15 06:12:18 +00:00
completed audiomanager and timeline save.
This commit is contained in:
1 parent
073d2084c1
commit
062558d8f2
3 files changed
+14
-7
No files matched your search
@@ -38,4 +38,6 @@ class AudioManager {
|
||||
console.warn(`AudioManager: AudioClip with id "${id}" not found.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default AudioManager;
|
||||
@@ -6,6 +6,7 @@ import Stats from 'three/addons/libs/stats.module.js';
|
||||
import Scene from './scene.js';
|
||||
import SaveManager from './serialization.js';
|
||||
import MediaUploadManager from './api_manager.js';
|
||||
import AudioManager from './audio_manager.js';
|
||||
|
||||
import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js';
|
||||
import { RenderPass } from 'three/addons/postprocessing/RenderPass.js';
|
||||
@@ -79,9 +80,13 @@ class Editor {
|
||||
this.playback = false;
|
||||
this.playback_location = 0;
|
||||
this.max_length = 10;
|
||||
this.timeline = null;
|
||||
|
||||
// Save & Load.
|
||||
this.save_manager = new SaveManager(this.version);
|
||||
|
||||
// Audio Engine.
|
||||
this.audio_manager = new AudioManager();
|
||||
}
|
||||
|
||||
// Initializes the main scene and ThreeJS essentials.
|
||||
@@ -300,7 +305,7 @@ class Editor {
|
||||
this.control.detach(this.selected);
|
||||
this.activeScene.scene.remove(this.control);
|
||||
this.activeScene.scene.remove(this.activeScene.gridHelper);
|
||||
this.save_manager.save(this.activeScene.scene, this._save_to_cloud.bind(this));
|
||||
this.save_manager.save(this.activeScene.scene, this._save_to_cloud.bind(this), this.audio_manager, this.timeline);
|
||||
this.activeScene._createGrid();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,14 +8,14 @@ class SaveManager {
|
||||
this.scene = null;
|
||||
}
|
||||
|
||||
save(scene, scene_callback) {
|
||||
save(scene, scene_callback, audio_manager, timeline) {
|
||||
let gltfExporter = new GLTFExporter();
|
||||
gltfExporter.parse(
|
||||
scene,
|
||||
function (gltfJson) {
|
||||
const jsonString = JSON.stringify(gltfJson);
|
||||
function (gltf) {
|
||||
console.log(scene);
|
||||
let blob = new Blob([jsonString], {type: 'application/json'})
|
||||
let save_json = {"glb": gltf, "audio": audio_manager.clips, "timeline": timeline}
|
||||
let blob = new Blob([JSON.stringify(save_json)], {type: 'application/json'})
|
||||
let blobUrl = URL.createObjectURL(blob);
|
||||
|
||||
scene_callback(blob);
|
||||
@@ -30,7 +30,7 @@ class SaveManager {
|
||||
const minutes = String(now.getMinutes()).padStart(2, '0');
|
||||
const seconds = String(now.getSeconds()).padStart(2, '0');
|
||||
const randomNumber = Math.floor(Math.random() * 1000);
|
||||
let save_name = `save_${randomNumber}_${year}${month}${day}_${hours}${minutes}${seconds}.glb`;
|
||||
let save_name = `save_${randomNumber}_${year}${month}${day}_${hours}${minutes}${seconds}.sav`;
|
||||
|
||||
a.href = blobUrl;
|
||||
a.download = save_name;
|
||||
|
||||
Reference in new issue
Block a user