Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
8485ffd4
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,发现更多精彩内容 >>
提交
8485ffd4
编写于
1月 05, 2018
作者:
G
gero3
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add crossFadeFrom & crossFadeTo
上级
afe2eec9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
81 addition
and
21 deletion
+81
-21
test/unit/src/animation/AnimationAction.tests.js
test/unit/src/animation/AnimationAction.tests.js
+81
-21
未找到文件。
test/unit/src/animation/AnimationAction.tests.js
浏览文件 @
8485ffd4
...
...
@@ -29,6 +29,32 @@ function createAnimation(){
}
function
createTwoAnimations
(){
var
root
=
new
Object3D
();
var
mixer
=
new
AnimationMixer
(
root
);
var
track
=
new
NumberKeyframeTrack
(
"
.rotation[x]
"
,
[
0
,
1000
],
[
0
,
360
]
);
var
clip
=
new
AnimationClip
(
"
clip1
"
,
1000
,
[
track
]
);
var
animationAction
=
mixer
.
clipAction
(
clip
);
var
track2
=
new
NumberKeyframeTrack
(
"
.rotation[y]
"
,
[
0
,
1000
],
[
0
,
360
]
);
var
clip2
=
new
AnimationClip
(
"
clip2
"
,
1000
,
[
track
]
);
var
animationAction2
=
mixer
.
clipAction
(
clip2
);
return
{
root
:
root
,
mixer
:
mixer
,
track
:
track
,
clip
:
clip
,
animationAction
:
animationAction
,
track2
:
track2
,
clip2
:
clip2
,
animationAction2
:
animationAction2
};
}
export
default
QUnit
.
module
(
'
Animation
'
,
()
=>
{
QUnit
.
module
(
'
AnimationAction
'
,
()
=>
{
...
...
@@ -233,20 +259,20 @@ export default QUnit.module( 'Animation', () => {
QUnit
.
test
(
"
setEffectiveWeight
"
,
(
assert
)
=>
{
var
{
animationAction
}
=
createAnimation
();
assert
.
equal
(
animationAction
.
getEffectiveWeight
(),
1
,
"
When an animation is created, EffectiveWeight is 1.
"
);
animationAction
.
setEffectiveWeight
(
0.3
);
assert
.
equal
(
animationAction
.
getEffectiveWeight
(),
1
,
"
When an animation is created, EffectiveWeight is 1.
"
);
animationAction
.
setEffectiveWeight
(
0.3
);
assert
.
equal
(
animationAction
.
getEffectiveWeight
(),
0.3
,
"
When EffectiveWeight is set to 0.3 , EffectiveWeight is 0.3.
"
);
var
{
animationAction
}
=
createAnimation
();
assert
.
equal
(
animationAction
.
getEffectiveWeight
(),
1
,
"
When an animation is created, EffectiveWeight is 1.
"
);
animationAction
.
enabled
=
false
;
animationAction
.
setEffectiveWeight
(
0.3
);
assert
.
equal
(
animationAction
.
getEffectiveWeight
(),
1
,
"
When an animation is created, EffectiveWeight is 1.
"
);
animationAction
.
enabled
=
false
;
animationAction
.
setEffectiveWeight
(
0.3
);
assert
.
equal
(
animationAction
.
getEffectiveWeight
(),
0
,
"
When EffectiveWeight is set to 0.3 when disabled , EffectiveWeight is 0.
"
);
var
{
root
,
mixer
,
animationAction
}
=
createAnimation
();
animationAction
.
setEffectiveWeight
(
0.5
);
animationAction
.
setEffectiveWeight
(
0.5
);
animationAction
.
play
();
mixer
.
update
(
500
);
assert
.
equal
(
root
.
rotation
.
x
,
90
,
"
When an animation has weight 0.5 and runs half through the animation, it has changed to 1/4.
"
);
...
...
@@ -259,26 +285,26 @@ export default QUnit.module( 'Animation', () => {
QUnit
.
test
(
"
getEffectiveWeight
"
,
(
assert
)
=>
{
var
{
animationAction
}
=
createAnimation
();
assert
.
equal
(
animationAction
.
getEffectiveWeight
(),
1
,
"
When an animation is created, EffectiveWeight is 1.
"
);
animationAction
.
setEffectiveWeight
(
0.3
);
var
{
animationAction
}
=
createAnimation
();
assert
.
equal
(
animationAction
.
getEffectiveWeight
(),
1
,
"
When an animation is created, EffectiveWeight is 1.
"
);
animationAction
.
setEffectiveWeight
(
0.3
);
assert
.
equal
(
animationAction
.
getEffectiveWeight
(),
0.3
,
"
When EffectiveWeight is set to 0.3 , EffectiveWeight is 0.3.
"
);
var
{
animationAction
}
=
createAnimation
();
assert
.
equal
(
animationAction
.
getEffectiveWeight
(),
1
,
"
When an animation is created, EffectiveWeight is 1.
"
);
animationAction
.
enabled
=
false
;
animationAction
.
setEffectiveWeight
(
0.3
);
assert
.
equal
(
animationAction
.
getEffectiveWeight
(),
1
,
"
When an animation is created, EffectiveWeight is 1.
"
);
animationAction
.
enabled
=
false
;
animationAction
.
setEffectiveWeight
(
0.3
);
assert
.
equal
(
animationAction
.
getEffectiveWeight
(),
0
,
"
When EffectiveWeight is set to 0.3 when disabled , EffectiveWeight is 0.
"
);
}
);
QUnit
.
test
(
"
fadeIn
"
,
(
assert
)
=>
{
var
{
mixer
,
animationAction
}
=
createAnimation
();
animationAction
.
fadeIn
(
1000
);
var
{
mixer
,
animationAction
}
=
createAnimation
();
animationAction
.
fadeIn
(
1000
);
animationAction
.
play
();
assert
.
equal
(
animationAction
.
getEffectiveWeight
(),
1
,
"
When an animation fadeIn is started, EffectiveWeight is 1.
"
);
assert
.
equal
(
animationAction
.
getEffectiveWeight
(),
1
,
"
When an animation fadeIn is started, EffectiveWeight is 1.
"
);
mixer
.
update
(
250
);
assert
.
equal
(
animationAction
.
getEffectiveWeight
(),
0.25
,
"
When an animation fadeIn happened 1/4, EffectiveWeight is 0.25.
"
);
mixer
.
update
(
250
);
...
...
@@ -293,9 +319,9 @@ export default QUnit.module( 'Animation', () => {
QUnit
.
test
(
"
fadeOut
"
,
(
assert
)
=>
{
var
{
mixer
,
animationAction
}
=
createAnimation
();
animationAction
.
fadeOut
(
1000
);
animationAction
.
fadeOut
(
1000
);
animationAction
.
play
();
assert
.
equal
(
animationAction
.
getEffectiveWeight
(),
1
,
"
When an animation fadeOut is started, EffectiveWeight is 1.
"
);
assert
.
equal
(
animationAction
.
getEffectiveWeight
(),
1
,
"
When an animation fadeOut is started, EffectiveWeight is 1.
"
);
mixer
.
update
(
250
);
assert
.
equal
(
animationAction
.
getEffectiveWeight
(),
0.75
,
"
When an animation fadeOut happened 1/4, EffectiveWeight is 0.75.
"
);
mixer
.
update
(
250
);
...
...
@@ -307,15 +333,49 @@ export default QUnit.module( 'Animation', () => {
}
);
QUnit
.
t
odo
(
"
crossFadeFrom
"
,
(
assert
)
=>
{
QUnit
.
t
est
(
"
crossFadeFrom
"
,
(
assert
)
=>
{
assert
.
ok
(
false
,
"
everything's gonna be alright
"
);
var
{
mixer
,
animationAction
,
animationAction2
}
=
createTwoAnimations
();
animationAction
.
crossFadeFrom
(
animationAction2
,
1000
,
false
);
animationAction
.
play
();
animationAction2
.
play
();
assert
.
equal
(
animationAction
.
getEffectiveWeight
(),
1
,
"
When an animation crossFadeFrom is started, EffectiveWeight is 1.
"
);
assert
.
equal
(
animationAction2
.
getEffectiveWeight
(),
1
,
"
When an animation crossFadeFrom is started, EffectiveWeight is 1.
"
);
mixer
.
update
(
250
);
assert
.
equal
(
animationAction
.
getEffectiveWeight
(),
0.25
,
"
When an animation fadeOut happened 1/4, EffectiveWeight is 0.75.
"
);
assert
.
equal
(
animationAction2
.
getEffectiveWeight
(),
0.75
,
"
When an animation fadeOut happened 1/4, EffectiveWeight is 0.75.
"
);
mixer
.
update
(
250
);
assert
.
equal
(
animationAction
.
getEffectiveWeight
(),
0.5
,
"
When an animation fadeOut happened 1/4, EffectiveWeight is 0.75.
"
);
assert
.
equal
(
animationAction2
.
getEffectiveWeight
(),
0.5
,
"
When an animation fadeOut is halfway , EffectiveWeight is 0.5.
"
);
mixer
.
update
(
250
);
assert
.
equal
(
animationAction
.
getEffectiveWeight
(),
0.75
,
"
When an animation fadeOut happened 1/4, EffectiveWeight is 0.75.
"
);
assert
.
equal
(
animationAction2
.
getEffectiveWeight
(),
0.25
,
"
When an animation fadeOut is happened 3/4 , EffectiveWeight is 0.25.
"
);
mixer
.
update
(
500
);
assert
.
equal
(
animationAction
.
getEffectiveWeight
(),
1
,
"
When an animation fadeOut happened 1/4, EffectiveWeight is 0.75.
"
);
assert
.
equal
(
animationAction2
.
getEffectiveWeight
(),
0
,
"
When an animation fadeOut is ended , EffectiveWeight is 0.
"
);
}
);
QUnit
.
t
odo
(
"
crossFadeTo
"
,
(
assert
)
=>
{
QUnit
.
t
est
(
"
crossFadeTo
"
,
(
assert
)
=>
{
assert
.
ok
(
false
,
"
everything's gonna be alright
"
);
var
{
mixer
,
animationAction
,
animationAction2
}
=
createTwoAnimations
();
animationAction2
.
crossFadeTo
(
animationAction
,
1000
,
false
);
animationAction
.
play
();
animationAction2
.
play
();
assert
.
equal
(
animationAction
.
getEffectiveWeight
(),
1
,
"
When an animation crossFadeFrom is started, EffectiveWeight is 1.
"
);
assert
.
equal
(
animationAction2
.
getEffectiveWeight
(),
1
,
"
When an animation crossFadeFrom is started, EffectiveWeight is 1.
"
);
mixer
.
update
(
250
);
assert
.
equal
(
animationAction
.
getEffectiveWeight
(),
0.25
,
"
When an animation fadeOut happened 1/4, EffectiveWeight is 0.75.
"
);
assert
.
equal
(
animationAction2
.
getEffectiveWeight
(),
0.75
,
"
When an animation fadeOut happened 1/4, EffectiveWeight is 0.75.
"
);
mixer
.
update
(
250
);
assert
.
equal
(
animationAction
.
getEffectiveWeight
(),
0.5
,
"
When an animation fadeOut happened 1/4, EffectiveWeight is 0.75.
"
);
assert
.
equal
(
animationAction2
.
getEffectiveWeight
(),
0.5
,
"
When an animation fadeOut is halfway , EffectiveWeight is 0.5.
"
);
mixer
.
update
(
250
);
assert
.
equal
(
animationAction
.
getEffectiveWeight
(),
0.75
,
"
When an animation fadeOut happened 1/4, EffectiveWeight is 0.75.
"
);
assert
.
equal
(
animationAction2
.
getEffectiveWeight
(),
0.25
,
"
When an animation fadeOut is happened 3/4 , EffectiveWeight is 0.25.
"
);
mixer
.
update
(
500
);
assert
.
equal
(
animationAction
.
getEffectiveWeight
(),
1
,
"
When an animation fadeOut happened 1/4, EffectiveWeight is 0.75.
"
);
assert
.
equal
(
animationAction2
.
getEffectiveWeight
(),
0
,
"
When an animation fadeOut is ended , EffectiveWeight is 0.
"
);
}
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录