From aedb70977dc6811deb632b93bc9bdde710edfbc9 Mon Sep 17 00:00:00 2001 From: liteng <930372551@qq.com> Date: Tue, 11 Sep 2018 20:50:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=83=8C=E6=99=AF=E9=9F=B3?= =?UTF-8?q?=E4=B9=90=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/editor/window/AudioWindow.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/ShadowEditor.Web/src/editor/window/AudioWindow.js b/ShadowEditor.Web/src/editor/window/AudioWindow.js index 7f192384..5148cedb 100644 --- a/ShadowEditor.Web/src/editor/window/AudioWindow.js +++ b/ShadowEditor.Web/src/editor/window/AudioWindow.js @@ -3,6 +3,8 @@ import Ajax from '../../utils/Ajax'; import AddObjectCommand from '../../command/AddObjectCommand'; import UploadUtils from '../../utils/UploadUtils'; +var ID = -1; + /** * 音频窗口 * @author tengge / https://github.com/tengge1 @@ -180,15 +182,26 @@ AudioWindow.prototype.onClickImage = function (imgs, index, btn) { return; } - this.onLoadModel(model); + this.onLoad(model); }; /** * 添加模型到场景 * @param {*} model */ -AudioWindow.prototype.onLoadModel = function (model) { - +AudioWindow.prototype.onLoad = function (model) { + var listener = this.app.editor.audioListener; + + var sound = new THREE.Audio(listener); + + var loader = new THREE.AudioLoader(); + + loader.load(this.app.options.server + model.Url, buffer => { + sound.setBuffer(buffer); + sound.setLoop(true); + sound.setVolume(1.0); + sound.play(); + }); }; /**