Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
6eade098
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,体验更适合开发者的 AI 搜索 >>
提交
6eade098
编写于
11月 22, 2020
作者:
M
Mugen87
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Object3D: Add animations property.
上级
66e4d925
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
109 addition
and
87 deletion
+109
-87
docs/api/ar/animation/AnimationClip.html
docs/api/ar/animation/AnimationClip.html
+5
-0
docs/api/en/animation/AnimationClip.html
docs/api/en/animation/AnimationClip.html
+5
-0
docs/api/en/core/Object3D.html
docs/api/en/core/Object3D.html
+3
-0
docs/api/en/loaders/ObjectLoader.html
docs/api/en/loaders/ObjectLoader.html
+5
-2
docs/api/zh/animation/AnimationClip.html
docs/api/zh/animation/AnimationClip.html
+5
-0
docs/api/zh/core/Object3D.html
docs/api/zh/core/Object3D.html
+3
-0
docs/api/zh/loaders/ObjectLoader.html
docs/api/zh/loaders/ObjectLoader.html
+5
-2
editor/js/Editor.js
editor/js/Editor.js
+1
-53
editor/js/Loader.js
editor/js/Loader.js
+6
-7
editor/js/Sidebar.Animation.js
editor/js/Sidebar.Animation.js
+3
-5
src/animation/AnimationClip.d.ts
src/animation/AnimationClip.d.ts
+1
-0
src/animation/AnimationClip.js
src/animation/AnimationClip.js
+10
-1
src/core/Object3D.d.ts
src/core/Object3D.d.ts
+7
-0
src/core/Object3D.js
src/core/Object3D.js
+22
-1
src/loaders/ObjectLoader.d.ts
src/loaders/ObjectLoader.d.ts
+2
-1
src/loaders/ObjectLoader.js
src/loaders/ObjectLoader.js
+26
-15
未找到文件。
docs/api/ar/animation/AnimationClip.html
浏览文件 @
6eade098
...
...
@@ -72,6 +72,11 @@
يضبط [page:.duration duration] للمقطع على أطول مدة [page:KeyframeTrack] ممكنة.
</p>
<h3>
[method:Object toJSON]()
</h3>
<p>
Returns a JSON object representing the serialized animation clip.
</p>
<h3>
[method:this trim]()
</h3>
<p>
اقتطاع كل المسارات حسب مدة المقطع.
...
...
docs/api/en/animation/AnimationClip.html
浏览文件 @
6eade098
...
...
@@ -82,6 +82,11 @@
[page:KeyframeTrack].
</p>
<h3>
[method:Object toJSON]()
</h3>
<p>
Returns a JSON object representing the serialized animation clip.
</p>
<h3>
[method:this trim]()
</h3>
<p>
Trims all tracks to the clip's duration.
...
...
docs/api/en/core/Object3D.html
浏览文件 @
6eade098
...
...
@@ -29,6 +29,9 @@
<h2>
Properties
</h2>
<h3>
[property:AnimationClip animations]
</h3>
<p>
Array with object's animation clips.
</p>
<h3>
[property:Boolean castShadow]
</h3>
<p>
Whether the object gets rendered into shadow map. Default is *false*.
</p>
...
...
docs/api/en/loaders/ObjectLoader.html
浏览文件 @
6eade098
...
...
@@ -130,9 +130,12 @@
This is used [page:.parse] to parse any textures in the JSON structure.
</p>
<h3>
[method:Object3D parseObject]( [param:Object json] )
</h3>
<h3>
[method:Object3D parseObject]( [param:Object json]
, [param:BufferGeometry geometries], [param:Material materials], [param:AnimationClip animations]
)
</h3>
<p>
[page:Object json] — required. The JSON source to parse.
<br
/><br
/>
[page:Object json] — required. The JSON source to parse.
<br
/>
[page:BufferGeometry geometries] — required. The geometries of the JSON.
<br
/>
[page:Material materials] — required. The materials of the JSON.
<br
/>
[page:AnimationClip animations] — required. The animations of the JSON.
<br
/><br
/>
This is used [page:.parse] to parse any objects in the JSON structure.
Objects can be of the following types:
...
...
docs/api/zh/animation/AnimationClip.html
浏览文件 @
6eade098
...
...
@@ -74,6 +74,11 @@
将剪辑的持续时间([page:.duration duration])设为最长的关键帧轨道([page:KeyframeTrack])的持续时间。
</p>
<h3>
[method:Object toJSON]()
</h3>
<p>
Returns a JSON object representing the serialized animation clip.
</p>
<h3>
[method:this trim]()
</h3>
<p>
修剪所有的轨道到该剪辑的持续时间。
...
...
docs/api/zh/core/Object3D.html
浏览文件 @
6eade098
...
...
@@ -29,6 +29,9 @@
<h2>
属性
</h2>
<h3>
[property:AnimationClip animations]
</h3>
<p>
Array with object's animation clips.
</p>
<h3>
[property:Boolean castShadow]
</h3>
<p>
对象是否被渲染到阴影贴图中。默认值为*false*。
</p>
...
...
docs/api/zh/loaders/ObjectLoader.html
浏览文件 @
6eade098
...
...
@@ -128,9 +128,12 @@
此函数通过[page:.parse]来解析JSON结构中任意纹理。
</p>
<h3>
[method:Object3D parseObject]( [param:Object json] )
</h3>
<h3>
[method:Object3D parseObject]( [param:Object json]
, [param:BufferGeometry geometries], [param:Material materials], [param:AnimationClip animations]
)
</h3>
<p>
[page:Object json] — 必选参数,需要被解析的JSON源。
<br
/><br
/>
[page:Object json] — 必选参数,需要被解析的JSON源。
<br
/>
[page:BufferGeometry geometries] — required. The geometries of the JSON.
<br
/>
[page:Material materials] — required. The materials of the JSON.
<br
/>
[page:AnimationClip animations] — required. The animations of the JSON.
<br
/><br
/>
此函数通过[page:.parse]来解析JSON结构中任意对象。
对象可以为如下类型:
...
...
editor/js/Editor.js
浏览文件 @
6eade098
...
...
@@ -105,7 +105,6 @@ function Editor() {
this
.
materialsRefCounter
=
new
Map
();
// tracks how often is a material used by a 3D object
this
.
animations
=
{};
this
.
mixer
=
new
THREE
.
AnimationMixer
(
this
.
scene
);
this
.
selected
=
null
;
...
...
@@ -357,16 +356,6 @@ Editor.prototype = {
},
addAnimations
:
function
(
object
,
animations
)
{
if
(
animations
.
length
>
0
)
{
this
.
animations
[
object
.
uuid
]
=
animations
;
}
},
//
addCamera
:
function
(
camera
)
{
...
...
@@ -664,50 +653,10 @@ Editor.prototype = {
}
);
// animations
var
animationsJSON
=
json
.
animations
;
for
(
var
i
=
0
;
i
<
animationsJSON
.
length
;
i
++
)
{
var
objectJSON
=
animationsJSON
[
i
];
var
animations
=
[];
for
(
var
j
=
0
;
j
<
objectJSON
.
animations
.
length
;
j
++
)
{
animations
.
push
(
THREE
.
AnimationClip
.
parse
(
objectJSON
.
animations
[
j
]
)
);
}
this
.
animations
[
objectJSON
.
uuid
]
=
animations
;
}
},
toJSON
:
function
()
{
// animations
var
animations
=
this
.
animations
;
var
animationsJSON
=
[];
for
(
var
entry
in
animations
)
{
var
objectAnimations
=
animations
[
entry
];
var
objectJSON
=
{
uuid
:
entry
,
animations
:
[]
};
for
(
var
i
=
0
;
i
<
objectAnimations
.
length
;
i
++
)
{
var
objectAnimation
=
objectAnimations
[
i
];
objectJSON
.
animations
.
push
(
THREE
.
AnimationClip
.
toJSON
(
objectAnimation
)
);
}
animationsJSON
.
push
(
objectJSON
);
}
// scripts clean up
var
scene
=
this
.
scene
;
...
...
@@ -741,8 +690,7 @@ Editor.prototype = {
camera
:
this
.
camera
.
toJSON
(),
scene
:
this
.
scene
.
toJSON
(),
scripts
:
this
.
scripts
,
history
:
this
.
history
.
toJSON
(),
animations
:
animationsJSON
history
:
this
.
history
.
toJSON
()
};
...
...
editor/js/Loader.js
浏览文件 @
6eade098
...
...
@@ -170,7 +170,7 @@ function Loader( editor ) {
collada
.
scene
.
name
=
filename
;
editor
.
addAnimations
(
collada
.
scene
,
collada
.
animations
);
collada
.
scene
.
animations
.
push
(
...
collada
.
animations
);
editor
.
execute
(
new
AddObjectCommand
(
editor
,
collada
.
scene
)
);
},
false
);
...
...
@@ -226,7 +226,6 @@ function Loader( editor ) {
var
loader
=
new
FBXLoader
(
manager
);
var
object
=
loader
.
parse
(
contents
);
editor
.
addAnimations
(
object
,
object
.
animations
);
editor
.
execute
(
new
AddObjectCommand
(
editor
,
object
)
);
},
false
);
...
...
@@ -250,7 +249,7 @@ function Loader( editor ) {
var
scene
=
result
.
scene
;
scene
.
name
=
filename
;
editor
.
addAnimations
(
scene
,
result
.
animations
);
scene
.
animations
.
push
(
...
result
.
animations
);
editor
.
execute
(
new
AddObjectCommand
(
editor
,
scene
)
);
}
);
...
...
@@ -287,7 +286,7 @@ function Loader( editor ) {
var
scene
=
result
.
scene
;
scene
.
name
=
filename
;
editor
.
addAnimations
(
scene
,
result
.
animations
);
scene
.
animations
.
push
(
...
result
.
animations
);
editor
.
execute
(
new
AddObjectCommand
(
editor
,
scene
)
);
}
);
...
...
@@ -386,7 +385,7 @@ function Loader( editor ) {
mesh
.
mixer
=
new
THREE
.
AnimationMixer
(
mesh
);
mesh
.
name
=
filename
;
editor
.
addAnimations
(
mesh
,
geometry
.
animations
);
mesh
.
animations
.
push
(
...
geometry
.
animations
);
editor
.
execute
(
new
AddObjectCommand
(
editor
,
mesh
)
);
},
false
);
...
...
@@ -720,7 +719,7 @@ function Loader( editor ) {
var
scene
=
result
.
scene
;
editor
.
addAnimations
(
scene
,
result
.
animations
);
scene
.
animations
.
push
(
...
result
.
animations
);
editor
.
execute
(
new
AddObjectCommand
(
editor
,
scene
)
);
}
);
...
...
@@ -738,7 +737,7 @@ function Loader( editor ) {
var
scene
=
result
.
scene
;
editor
.
addAnimations
(
scene
,
result
.
animations
);
scene
.
animations
.
push
(
...
result
.
animations
);
editor
.
execute
(
new
AddObjectCommand
(
editor
,
scene
)
);
}
);
...
...
editor/js/Sidebar.Animation.js
浏览文件 @
6eade098
...
...
@@ -10,9 +10,9 @@ function SidebarAnimation( editor ) {
signals
.
objectSelected
.
add
(
function
(
object
)
{
var
animations
=
editor
.
animations
[
object
!==
null
?
object
.
uuid
:
''
];
if
(
object
!==
null
&&
object
.
animations
.
length
>
0
)
{
if
(
animations
!==
undefined
)
{
var
animations
=
object
.
animations
;
container
.
setDisplay
(
''
);
...
...
@@ -42,9 +42,7 @@ function SidebarAnimation( editor ) {
signals
.
objectRemoved
.
add
(
function
(
object
)
{
var
animations
=
editor
.
animations
[
object
!==
null
?
object
.
uuid
:
''
];
if
(
animations
!==
undefined
)
{
if
(
object
!==
null
&&
object
.
animations
.
length
>
0
)
{
mixer
.
uncacheRoot
(
object
);
...
...
src/animation/AnimationClip.d.ts
浏览文件 @
6eade098
...
...
@@ -27,6 +27,7 @@ export class AnimationClip {
validate
():
boolean
;
optimize
():
AnimationClip
;
clone
():
AnimationClip
;
toJSON
(
clip
:
AnimationClip
):
any
;
static
CreateFromMorphTargetSequence
(
name
:
string
,
...
...
src/animation/AnimationClip.js
浏览文件 @
6eade098
...
...
@@ -118,7 +118,10 @@ Object.assign( AnimationClip, {
}
return
new
AnimationClip
(
json
.
name
,
json
.
duration
,
tracks
,
json
.
blendMode
);
const
clip
=
new
AnimationClip
(
json
.
name
,
json
.
duration
,
tracks
,
json
.
blendMode
);
clip
.
uuid
=
json
.
uuid
;
return
clip
;
},
...
...
@@ -460,6 +463,12 @@ Object.assign( AnimationClip.prototype, {
return
new
AnimationClip
(
this
.
name
,
this
.
duration
,
tracks
,
this
.
blendMode
);
},
toJSON
:
function
()
{
return
AnimationClip
.
toJSON
(
this
);
}
}
);
...
...
src/core/Object3D.d.ts
浏览文件 @
6eade098
...
...
@@ -14,6 +14,7 @@ import { Raycaster } from './Raycaster';
import
{
EventDispatcher
}
from
'
./EventDispatcher
'
;
import
{
BufferGeometry
}
from
'
./BufferGeometry
'
;
import
{
Intersection
}
from
'
./Raycaster
'
;
import
{
AnimationClip
}
from
'
../animation/AnimationClip
'
;
/**
* Base class for scene graph objects
...
...
@@ -153,6 +154,12 @@ export class Object3D extends EventDispatcher {
*/
renderOrder
:
number
;
/**
* Array with animation clips.
* @default []
*/
animations
:
AnimationClip
[];
/**
* An object that can be used to store custom data about the Object3d. It should not hold references to functions as these will not be cloned.
* @default {}
...
...
src/core/Object3D.js
浏览文件 @
6eade098
...
...
@@ -103,6 +103,8 @@ function Object3D() {
this
.
frustumCulled
=
true
;
this
.
renderOrder
=
0
;
this
.
animations
=
[];
this
.
userData
=
{};
}
...
...
@@ -659,7 +661,8 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
textures
:
{},
images
:
{},
shapes
:
{},
skeletons
:
{}
skeletons
:
{},
animations
:
{}
};
output
.
metadata
=
{
...
...
@@ -795,6 +798,22 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
}
//
if
(
this
.
animations
.
length
>
0
)
{
object
.
animations
=
[];
for
(
let
i
=
0
;
i
<
this
.
animations
.
length
;
i
++
)
{
const
animation
=
this
.
animations
[
i
];
object
.
animations
.
push
(
serialize
(
meta
.
animations
,
animation
)
);
}
}
if
(
isRootObject
)
{
const
geometries
=
extractFromCache
(
meta
.
geometries
);
...
...
@@ -803,6 +822,7 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
const
images
=
extractFromCache
(
meta
.
images
);
const
shapes
=
extractFromCache
(
meta
.
shapes
);
const
skeletons
=
extractFromCache
(
meta
.
skeletons
);
const
animations
=
extractFromCache
(
meta
.
animations
);
if
(
geometries
.
length
>
0
)
output
.
geometries
=
geometries
;
if
(
materials
.
length
>
0
)
output
.
materials
=
materials
;
...
...
@@ -810,6 +830,7 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
if
(
images
.
length
>
0
)
output
.
images
=
images
;
if
(
shapes
.
length
>
0
)
output
.
shapes
=
shapes
;
if
(
skeletons
.
length
>
0
)
output
.
skeletons
=
skeletons
;
if
(
animations
.
length
>
0
)
output
.
animations
=
animations
;
}
...
...
src/loaders/ObjectLoader.d.ts
浏览文件 @
6eade098
...
...
@@ -27,7 +27,8 @@ export class ObjectLoader extends Loader {
parseObject
<
T
extends
Object3D
>
(
data
:
any
,
geometries
:
any
[],
materials
:
Material
[]
materials
:
Material
[],
animations
:
AnimationClip
[]
):
T
;
}
src/loaders/ObjectLoader.js
浏览文件 @
6eade098
...
...
@@ -115,6 +115,7 @@ class ObjectLoader extends Loader {
parse
(
json
,
onLoad
)
{
const
animations
=
this
.
parseAnimations
(
json
.
animations
);
const
shapes
=
this
.
parseShapes
(
json
.
shapes
);
const
geometries
=
this
.
parseGeometries
(
json
.
geometries
,
shapes
);
...
...
@@ -127,17 +128,11 @@ class ObjectLoader extends Loader {
const
textures
=
this
.
parseTextures
(
json
.
textures
,
images
);
const
materials
=
this
.
parseMaterials
(
json
.
materials
,
textures
);
const
object
=
this
.
parseObject
(
json
.
object
,
geometries
,
materials
);
const
object
=
this
.
parseObject
(
json
.
object
,
geometries
,
materials
,
animations
);
const
skeletons
=
this
.
parseSkeletons
(
json
.
skeletons
,
object
);
this
.
bindSkeletons
(
object
,
skeletons
);
if
(
json
.
animations
)
{
object
.
animations
=
this
.
parseAnimations
(
json
.
animations
);
}
//
if
(
onLoad
!==
undefined
)
{
...
...
@@ -554,17 +549,19 @@ class ObjectLoader extends Loader {
parseAnimations
(
json
)
{
const
animations
=
[]
;
const
animations
=
{}
;
for
(
let
i
=
0
;
i
<
json
.
length
;
i
++
)
{
if
(
json
!==
undefined
)
{
const
data
=
json
[
i
];
for
(
let
i
=
0
;
i
<
json
.
length
;
i
++
)
{
const
clip
=
AnimationClip
.
parse
(
data
);
const
data
=
json
[
i
];
const
clip
=
AnimationClip
.
parse
(
data
);
if
(
data
.
uuid
!==
undefined
)
clip
.
uuid
=
data
.
uuid
;
animations
[
clip
.
uuid
]
=
clip
;
animations
.
push
(
clip
);
}
}
...
...
@@ -788,7 +785,7 @@ class ObjectLoader extends Loader {
}
parseObject
(
data
,
geometries
,
materials
)
{
parseObject
(
data
,
geometries
,
materials
,
animations
)
{
let
object
;
...
...
@@ -1071,7 +1068,21 @@ class ObjectLoader extends Loader {
for
(
let
i
=
0
;
i
<
children
.
length
;
i
++
)
{
object
.
add
(
this
.
parseObject
(
children
[
i
],
geometries
,
materials
)
);
object
.
add
(
this
.
parseObject
(
children
[
i
],
geometries
,
materials
,
animations
)
);
}
}
if
(
data
.
animations
!==
undefined
)
{
const
objectAnimations
=
data
.
animations
;
for
(
let
i
=
0
;
i
<
objectAnimations
.
length
;
i
++
)
{
const
uuid
=
objectAnimations
[
i
];
object
.
animations
.
push
(
animations
[
uuid
]
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录