Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
f8965d46
T
three.js
项目概览
Ablesons
/
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,发现更多精彩内容 >>
提交
f8965d46
编写于
7月 08, 2018
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
KeyframeTrack: Removed circular dependencies.
上级
9dfca126
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
85 addition
and
101 deletion
+85
-101
src/animation/AnimationClip.js
src/animation/AnimationClip.js
+84
-4
src/animation/KeyframeTrack.js
src/animation/KeyframeTrack.js
+1
-84
test/unit/src/animation/KeyframeTrack.tests.js
test/unit/src/animation/KeyframeTrack.tests.js
+0
-13
未找到文件。
src/animation/AnimationClip.js
浏览文件 @
f8965d46
import
{
VectorKeyframeTrack
}
from
'
./tracks/VectorKeyframeTrack.js
'
;
import
{
QuaternionKeyframeTrack
}
from
'
./tracks/QuaternionKeyframeTrack.js
'
;
import
{
NumberKeyframeTrack
}
from
'
./tracks/NumberKeyframeTrack.js
'
;
import
{
AnimationUtils
}
from
'
./AnimationUtils.js
'
;
import
{
KeyframeTrack
}
from
'
./KeyframeTrack.js
'
;
import
{
BooleanKeyframeTrack
}
from
'
./tracks/BooleanKeyframeTrack.js
'
;
import
{
ColorKeyframeTrack
}
from
'
./tracks/ColorKeyframeTrack.js
'
;
import
{
NumberKeyframeTrack
}
from
'
./tracks/NumberKeyframeTrack.js
'
;
import
{
QuaternionKeyframeTrack
}
from
'
./tracks/QuaternionKeyframeTrack.js
'
;
import
{
StringKeyframeTrack
}
from
'
./tracks/StringKeyframeTrack.js
'
;
import
{
VectorKeyframeTrack
}
from
'
./tracks/VectorKeyframeTrack.js
'
;
import
{
_Math
}
from
'
../math/Math.js
'
;
/**
...
...
@@ -32,6 +35,83 @@ function AnimationClip( name, duration, tracks ) {
}
function
getTrackTypeForValueTypeName
(
typeName
)
{
switch
(
typeName
.
toLowerCase
()
)
{
case
'
scalar
'
:
case
'
double
'
:
case
'
float
'
:
case
'
number
'
:
case
'
integer
'
:
return
NumberKeyframeTrack
;
case
'
vector
'
:
case
'
vector2
'
:
case
'
vector3
'
:
case
'
vector4
'
:
return
VectorKeyframeTrack
;
case
'
color
'
:
return
ColorKeyframeTrack
;
case
'
quaternion
'
:
return
QuaternionKeyframeTrack
;
case
'
bool
'
:
case
'
boolean
'
:
return
BooleanKeyframeTrack
;
case
'
string
'
:
return
StringKeyframeTrack
;
}
throw
new
Error
(
'
THREE.KeyframeTrack: Unsupported typeName:
'
+
typeName
);
}
function
parseKeyframeTrack
(
json
)
{
if
(
json
.
type
===
undefined
)
{
throw
new
Error
(
'
THREE.KeyframeTrack: track type undefined, can not parse
'
);
}
var
trackType
=
getTrackTypeForValueTypeName
(
json
.
type
);
if
(
json
.
times
===
undefined
)
{
var
times
=
[],
values
=
[];
AnimationUtils
.
flattenJSON
(
json
.
keys
,
times
,
values
,
'
value
'
);
json
.
times
=
times
;
json
.
values
=
values
;
}
// derived classes can define a static parse method
if
(
trackType
.
parse
!==
undefined
)
{
return
trackType
.
parse
(
json
);
}
else
{
// by default, we assume a constructor compatible with the base
return
new
trackType
(
json
.
name
,
json
.
times
,
json
.
values
,
json
.
interpolation
);
}
}
Object
.
assign
(
AnimationClip
,
{
parse
:
function
(
json
)
{
...
...
@@ -42,7 +122,7 @@ Object.assign( AnimationClip, {
for
(
var
i
=
0
,
n
=
jsonTracks
.
length
;
i
!==
n
;
++
i
)
{
tracks
.
push
(
KeyframeTrack
.
parse
(
jsonTracks
[
i
]
).
scale
(
frameTime
)
);
tracks
.
push
(
parseKeyframeTrack
(
jsonTracks
[
i
]
).
scale
(
frameTime
)
);
}
...
...
src/animation/KeyframeTrack.js
浏览文件 @
f8965d46
import
{
StringKeyframeTrack
}
from
'
./tracks/StringKeyframeTrack.js
'
;
import
{
BooleanKeyframeTrack
}
from
'
./tracks/BooleanKeyframeTrack.js
'
;
import
{
QuaternionKeyframeTrack
}
from
'
./tracks/QuaternionKeyframeTrack.js
'
;
import
{
ColorKeyframeTrack
}
from
'
./tracks/ColorKeyframeTrack.js
'
;
import
{
VectorKeyframeTrack
}
from
'
./tracks/VectorKeyframeTrack.js
'
;
import
{
NumberKeyframeTrack
}
from
'
./tracks/NumberKeyframeTrack.js
'
;
import
{
InterpolateLinear
,
InterpolateSmooth
,
...
...
@@ -41,48 +35,13 @@ function KeyframeTrack( name, times, values, interpolation ) {
}
// Static methods
:
// Static methods
Object
.
assign
(
KeyframeTrack
,
{
// Serialization (in static context, because of constructor invocation
// and automatic invocation of .toJSON):
parse
:
function
(
json
)
{
if
(
json
.
type
===
undefined
)
{
throw
new
Error
(
'
THREE.KeyframeTrack: track type undefined, can not parse
'
);
}
var
trackType
=
KeyframeTrack
.
_getTrackTypeForValueTypeName
(
json
.
type
);
if
(
json
.
times
===
undefined
)
{
var
times
=
[],
values
=
[];
AnimationUtils
.
flattenJSON
(
json
.
keys
,
times
,
values
,
'
value
'
);
json
.
times
=
times
;
json
.
values
=
values
;
}
// derived classes can define a static parse method
if
(
trackType
.
parse
!==
undefined
)
{
return
trackType
.
parse
(
json
);
}
else
{
// by default, we assume a constructor compatible with the base
return
new
trackType
(
json
.
name
,
json
.
times
,
json
.
values
,
json
.
interpolation
);
}
},
toJSON
:
function
(
track
)
{
var
trackType
=
track
.
constructor
;
...
...
@@ -119,48 +78,6 @@ Object.assign( KeyframeTrack, {
return
json
;
},
_getTrackTypeForValueTypeName
:
function
(
typeName
)
{
switch
(
typeName
.
toLowerCase
()
)
{
case
'
scalar
'
:
case
'
double
'
:
case
'
float
'
:
case
'
number
'
:
case
'
integer
'
:
return
NumberKeyframeTrack
;
case
'
vector
'
:
case
'
vector2
'
:
case
'
vector3
'
:
case
'
vector4
'
:
return
VectorKeyframeTrack
;
case
'
color
'
:
return
ColorKeyframeTrack
;
case
'
quaternion
'
:
return
QuaternionKeyframeTrack
;
case
'
bool
'
:
case
'
boolean
'
:
return
BooleanKeyframeTrack
;
case
'
string
'
:
return
StringKeyframeTrack
;
}
throw
new
Error
(
'
THREE.KeyframeTrack: Unsupported typeName:
'
+
typeName
);
}
}
);
...
...
test/unit/src/animation/KeyframeTrack.tests.js
浏览文件 @
f8965d46
...
...
@@ -17,24 +17,12 @@ export default QUnit.module( 'Animation', () => {
}
);
// STATIC STUFF
QUnit
.
todo
(
"
parse
"
,
(
assert
)
=>
{
assert
.
ok
(
false
,
"
everything's gonna be alright
"
);
}
);
QUnit
.
todo
(
"
toJSON
"
,
(
assert
)
=>
{
assert
.
ok
(
false
,
"
everything's gonna be alright
"
);
}
);
QUnit
.
todo
(
"
_getTrackTypeForValueTypeName
"
,
(
assert
)
=>
{
assert
.
ok
(
false
,
"
everything's gonna be alright
"
);
}
);
// PUBLIC STUFF
QUnit
.
todo
(
"
TimeBufferType
"
,
(
assert
)
=>
{
...
...
@@ -123,4 +111,3 @@ export default QUnit.module( 'Animation', () => {
}
);
}
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录