Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
0c51c828
T
three.js
项目概览
车家大少爷
/
three.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
three.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0c51c828
编写于
11月 13, 2015
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Audio code clean up.
上级
00551c6a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
74 addition
and
69 deletion
+74
-69
src/audio/Audio.js
src/audio/Audio.js
+34
-37
src/audio/AudioBuffer.js
src/audio/AudioBuffer.js
+15
-10
src/audio/AudioListener.js
src/audio/AudioListener.js
+22
-21
src/audio/PositionalAudio.js
src/audio/PositionalAudio.js
+3
-1
未找到文件。
src/audio/Audio.js
浏览文件 @
0c51c828
...
...
@@ -13,7 +13,7 @@ THREE.Audio = function ( listener ) {
this
.
source
.
onended
=
this
.
onEnded
.
bind
(
this
);
this
.
gain
=
this
.
context
.
createGain
();
this
.
gain
.
connect
(
listener
.
getOutputNode
());
this
.
gain
.
connect
(
listener
.
getOutputNode
()
);
this
.
autoplay
=
false
;
...
...
@@ -29,37 +29,38 @@ THREE.Audio = function ( listener ) {
THREE
.
Audio
.
prototype
=
Object
.
create
(
THREE
.
Object3D
.
prototype
);
THREE
.
Audio
.
prototype
.
constructor
=
THREE
.
Audio
;
THREE
.
Audio
.
prototype
.
getOutput
=
function
()
{
THREE
.
Audio
.
prototype
.
getOutput
=
function
()
{
return
this
.
gain
;
};
THREE
.
Audio
.
prototype
.
load
=
function
(
fileName
)
{
THREE
.
Audio
.
prototype
.
load
=
function
(
file
)
{
var
buffer
=
new
THREE
.
AudioBuffer
(
this
.
context
);
buffer
.
load
(
file
);
this
.
setBuffer
(
buffer
);
var
audioBuffer
=
new
THREE
.
AudioBuffer
(
this
.
context
);
audioBuffer
.
load
(
fileName
);
this
.
setBuffer
(
audioBuffer
);
return
this
;
};
THREE
.
Audio
.
prototype
.
setNodeSource
=
function
(
audioNode
)
{
this
.
hasPlaybackControl
=
false
;
this
.
sourceType
=
'
audioNode
'
;
this
.
source
=
audioNode
;
this
.
connect
();
return
this
;
};
THREE
.
Audio
.
prototype
.
setBuffer
=
function
(
audioBuffer
)
{
var
scope
=
this
;
audioBuffer
.
onReady
(
function
(
buffer
)
{
scope
.
source
.
buffer
=
buffer
;
scope
.
sourceType
=
'
buffer
'
;
...
...
@@ -70,8 +71,6 @@ THREE.Audio.prototype.setBuffer = function ( audioBuffer ) {
};
THREE
.
Audio
.
prototype
.
play
=
function
()
{
if
(
this
.
isPlaying
===
true
)
{
...
...
@@ -80,7 +79,7 @@ THREE.Audio.prototype.play = function () {
return
;
}
if
(
this
.
hasPlaybackControl
===
false
)
{
console
.
warn
(
'
THREE.Audio: this Audio has no playback control.
'
);
...
...
@@ -88,7 +87,6 @@ THREE.Audio.prototype.play = function () {
}
var
source
=
this
.
context
.
createBufferSource
();
source
.
buffer
=
this
.
source
.
buffer
;
...
...
@@ -107,13 +105,13 @@ THREE.Audio.prototype.play = function () {
THREE
.
Audio
.
prototype
.
pause
=
function
()
{
if
(
this
.
hasPlaybackControl
===
false
)
{
if
(
this
.
hasPlaybackControl
===
false
)
{
console
.
warn
(
'
THREE.Audio: this Audio has no playback control.
'
);
return
;
}
this
.
source
.
stop
();
this
.
startTime
=
this
.
context
.
currentTime
;
...
...
@@ -121,11 +119,11 @@ THREE.Audio.prototype.pause = function () {
THREE
.
Audio
.
prototype
.
stop
=
function
()
{
if
(
this
.
hasPlaybackControl
===
false
)
{
if
(
this
.
hasPlaybackControl
===
false
)
{
console
.
warn
(
'
THREE.Audio: this Audio has no playback control.
'
);
return
;
}
this
.
source
.
stop
();
...
...
@@ -138,11 +136,11 @@ THREE.Audio.prototype.connect = function () {
if
(
this
.
filter
!==
null
)
{
this
.
source
.
connect
(
this
.
filter
);
this
.
filter
.
connect
(
this
.
getOutput
());
this
.
filter
.
connect
(
this
.
getOutput
()
);
}
else
{
this
.
source
.
connect
(
this
.
getOutput
());
this
.
source
.
connect
(
this
.
getOutput
()
);
}
...
...
@@ -153,11 +151,11 @@ THREE.Audio.prototype.disconnect = function () {
if
(
this
.
filter
!==
null
)
{
this
.
source
.
disconnect
(
this
.
filter
);
this
.
filter
.
disconnect
(
this
.
getOutput
());
this
.
filter
.
disconnect
(
this
.
getOutput
()
);
}
else
{
this
.
source
.
disconnect
(
this
.
getOutput
());
this
.
source
.
disconnect
(
this
.
getOutput
()
);
}
...
...
@@ -187,11 +185,11 @@ THREE.Audio.prototype.getFilter = function () {
THREE
.
Audio
.
prototype
.
setPlaybackRate
=
function
(
value
)
{
if
(
this
.
hasPlaybackControl
===
false
)
{
if
(
this
.
hasPlaybackControl
===
false
)
{
console
.
warn
(
'
THREE.Audio: this Audio has no playback control.
'
);
return
;
}
this
.
playbackRate
=
value
;
...
...
@@ -218,11 +216,11 @@ THREE.Audio.prototype.onEnded = function() {
THREE
.
Audio
.
prototype
.
setLoop
=
function
(
value
)
{
if
(
this
.
hasPlaybackControl
===
false
)
{
if
(
this
.
hasPlaybackControl
===
false
)
{
console
.
warn
(
'
THREE.Audio: this Audio has no playback control.
'
);
return
;
}
this
.
source
.
loop
=
value
;
...
...
@@ -230,12 +228,12 @@ THREE.Audio.prototype.setLoop = function ( value ) {
};
THREE
.
Audio
.
prototype
.
getLoop
=
function
()
{
if
(
this
.
hasPlaybackControl
===
false
)
{
if
(
this
.
hasPlaybackControl
===
false
)
{
console
.
warn
(
'
THREE.Audio: this Audio has no playback control.
'
);
return
false
;
}
return
this
.
source
.
loop
;
...
...
@@ -254,4 +252,3 @@ THREE.Audio.prototype.getVolume = function () {
return
this
.
gain
.
gain
.
value
;
};
src/audio/AudioBuffer.js
浏览文件 @
0c51c828
...
...
@@ -23,12 +23,15 @@ THREE.AudioBuffer.prototype.load = function ( file ) {
scope
.
buffer
=
buffer
;
scope
.
ready
=
true
;
for
(
var
i
=
0
;
i
<
scope
.
readyCallbacks
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
scope
.
readyCallbacks
.
length
;
i
++
)
{
scope
.
readyCallbacks
[
i
](
scope
.
buffer
);
}
scope
.
readyCallbacks
=
[];
}
);
};
...
...
@@ -39,13 +42,15 @@ THREE.AudioBuffer.prototype.load = function ( file ) {
};
THREE
.
AudioBuffer
.
prototype
.
onReady
=
function
(
callback
)
{
if
(
this
.
ready
)
{
callback
(
this
.
buffer
);
}
else
{
this
.
readyCallbacks
.
push
(
callback
);
if
(
this
.
ready
)
{
callback
(
this
.
buffer
);
}
else
{
this
.
readyCallbacks
.
push
(
callback
);
}
};
src/audio/AudioListener.js
浏览文件 @
0c51c828
...
...
@@ -12,47 +12,48 @@ THREE.AudioListener = function () {
this
.
masterGain
=
this
.
context
.
createGain
();
this
.
masterGain
.
connect
(
this
.
context
.
destination
);
this
.
filter
=
null
;
};
THREE
.
AudioListener
.
prototype
=
Object
.
create
(
THREE
.
Object3D
.
prototype
);
THREE
.
AudioListener
.
prototype
.
constructor
=
THREE
.
AudioListener
;
THREE
.
AudioListener
.
prototype
.
getOutputNode
=
function
()
{
return
this
.
masterGain
;
};
THREE
.
AudioListener
.
prototype
.
removeFilter
=
function
(
)
{
if
(
this
.
filter
!==
null
)
{
this
.
masterGain
.
disconnect
(
this
.
filter
);
this
.
filter
.
disconnect
(
this
.
context
.
destination
);
this
.
masterGain
.
connect
(
this
.
context
.
destination
);
if
(
this
.
filter
!==
null
)
{
this
.
masterGain
.
disconnect
(
this
.
filter
);
this
.
filter
.
disconnect
(
this
.
context
.
destination
);
this
.
masterGain
.
connect
(
this
.
context
.
destination
);
this
.
filter
=
null
;
}
}
THREE
.
AudioListener
.
prototype
.
setFilter
=
function
(
value
)
{
if
(
this
.
filter
!==
null
)
{
this
.
masterGain
.
disconnect
(
this
.
filter
);
this
.
filter
.
disconnect
(
this
.
context
.
destination
);
if
(
this
.
filter
!==
null
)
{
this
.
masterGain
.
disconnect
(
this
.
filter
);
this
.
filter
.
disconnect
(
this
.
context
.
destination
);
}
else
{
this
.
masterGain
.
disconnect
(
this
.
context
.
destination
);
this
.
masterGain
.
disconnect
(
this
.
context
.
destination
);
}
this
.
filter
=
value
;
this
.
masterGain
.
connect
(
this
.
filter
);
this
.
filter
.
connect
(
this
.
context
.
destination
);
this
.
masterGain
.
connect
(
this
.
filter
);
this
.
filter
.
connect
(
this
.
context
.
destination
);
};
THREE
.
AudioListener
.
prototype
.
getFilter
=
function
()
{
...
...
src/audio/PositionalAudio.js
浏览文件 @
0c51c828
...
...
@@ -14,8 +14,10 @@ THREE.PositionalAudio = function ( listener ) {
THREE
.
PositionalAudio
.
prototype
=
Object
.
create
(
THREE
.
Audio
.
prototype
);
THREE
.
PositionalAudio
.
prototype
.
constructor
=
THREE
.
PositionalAudio
;
THREE
.
PositionalAudio
.
prototype
.
getOutput
=
function
()
{
THREE
.
PositionalAudio
.
prototype
.
getOutput
=
function
()
{
return
this
.
panner
;
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录