completed audiomanager and timeline save.

This commit is contained in:
Quicksticks-oss committed 2024-03-21 19:05:14 -04:00
1 parent 073d2084c1
commit 062558d8f2
3 files changed
+14 -7

No files matched your search

+3 -1
View File
@@ -38,4 +38,6 @@ class AudioManager {
console.warn(`AudioManager: AudioClip with id "${id}" not found.`);
}
}
}
}
export default AudioManager;
+6 -1
View File
@@ -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();
}
+5 -5
View File
@@ -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;