three.js AnimationClip

2023-02-16 17:25 更新

動畫剪輯(AnimationClip)是一個可重用的關(guān)鍵幀軌道集,它代表動畫。

在使用手冊的“下一步”章節(jié)中,“動畫系統(tǒng)”一文對three.js動畫系統(tǒng)中的不同元素作出了概述

構(gòu)造器

AnimationClip( name : String, duration : Number, tracks : Array )

name - 此剪輯的名稱

duration - 持續(xù)時間 (單位秒). 如果傳入負數(shù), 持續(xù)時間將會從傳入的數(shù)組中計算得到。

tracks - 一個由關(guān)鍵幀軌道(KeyframeTracks)組成的數(shù)組。

說明: 與其直接調(diào)用構(gòu)造函數(shù)實例化一個動畫剪輯, 不如使用其靜態(tài)方法中的一個來創(chuàng)建: 用JSON (parse), 用變形目標(biāo)序列(CreateFromMorphTargetSequence, CreateClipsFromMorphTargetSequences)或者用動畫層級 (parseAnimation)來創(chuàng)建 - 如果你的模型中幾何體的動畫數(shù)組中還沒有保存動畫剪輯的話。

屬性

.duration : Number

剪輯的持續(xù)時間 (單位秒). 可以通過resetDuration從軌道數(shù)組(tracks)計算出來。

.name : String

剪輯的名稱. 調(diào)用findByName根據(jù)名稱搜索某個剪輯

.tracks : Array

一個包含該剪輯中有動畫的所有屬性的關(guān)鍵幀軌道(KeyframeTrack)的數(shù)組。

.uuid : String

剪輯實例的UUID,自動分配且不可編輯。

方法

.clone () : AnimationClip

.optimize () : this

通過移除等效的順序鍵(在變形目標(biāo)序列中很常見)來優(yōu)化每一個軌道

.resetDuration () : this

將剪輯的持續(xù)時間(duration)設(shè)為最長的關(guān)鍵幀軌道(KeyframeTrack)的持續(xù)時間。

.toJSON () : Object

Returns a JSON object representing the serialized animation clip.

.trim () : this

修剪所有的軌道到該剪輯的持續(xù)時間。

.validate () : Boolean

對剪輯中的每個軌道執(zhí)行最小驗證。如果所有軌道都有效,返回true。

靜態(tài)方法

.CreateClipsFromMorphTargetSequences ( name : String, morphTargetSequence : Array, fps : Number, noLoop : Boolean ) : Array

返回從幾何體的變形目標(biāo)序列(morph target sequences)創(chuàng)建的新動畫剪輯(AnimationClip)數(shù)組,并嘗試將變形目標(biāo)名稱分類為基于動畫組的模式,如“Walk_001、Walk_002、Run_001、Run_002……”。

.CreateFromMorphTargetSequence ( name : String, morphTargetSequence : Array, fps : Number, noLoop : Boolean ) : AnimationClip

返回一個由幾何體變形目標(biāo)數(shù)組(morph targets array)得到的新動畫剪輯,接收名稱和幀率參數(shù)。說明: 幀率是必須參數(shù), 但是動畫速度可能會在AnimationAction中被animationAction.setDuration方法重寫。

.findByName ( objectOrClipArray : Object, name : String ) : AnimationClip

根據(jù)名稱搜索動畫剪輯(AnimationClip), 接收一個動畫剪輯數(shù)組或者一個包含名為"animation"的數(shù)組的網(wǎng)格(或幾何體)作為第一個參數(shù)。

.parse ( json : Object ) : AnimationClip

解析剪輯的JSON表示,并返回一個動畫剪輯(AnimationClip)。

.parseAnimation ( animation : Object, bones : Array ) : AnimationClip

解析動畫層級格式并返回動畫剪輯。

.toJSON ( clip : AnimationClip ) : Object

接收一個動畫剪輯為參數(shù)并返回一個JSON對象.

源碼

src/animation/AnimationClip.js


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號