-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de4a31b
commit fd35fda
Showing
485 changed files
with
252,617 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
|
||
AnimationClip = window.THREE.AnimationClip | ||
BooleanKeyframeTrack = window.THREE.AnimationClip | ||
ColorKeyframeTrack = window.THREE.AnimationClip | ||
NumberKeyframeTrack = window.THREE.AnimationClip | ||
Vector3 = window.THREE.AnimationClip | ||
VectorKeyframeTrack = window.THREE.AnimationClip | ||
|
||
|
||
class AnimationClipCreator { | ||
|
||
static CreateRotationAnimation( period, axis = 'x' ) { | ||
|
||
const times = [ 0, period ], values = [ 0, 360 ]; | ||
|
||
const trackName = '.rotation[' + axis + ']'; | ||
|
||
const track = new NumberKeyframeTrack( trackName, times, values ); | ||
|
||
return new AnimationClip( null, period, [ track ] ); | ||
|
||
} | ||
|
||
static CreateScaleAxisAnimation( period, axis = 'x' ) { | ||
|
||
const times = [ 0, period ], values = [ 0, 1 ]; | ||
|
||
const trackName = '.scale[' + axis + ']'; | ||
|
||
const track = new NumberKeyframeTrack( trackName, times, values ); | ||
|
||
return new AnimationClip( null, period, [ track ] ); | ||
|
||
} | ||
|
||
static CreateShakeAnimation( duration, shakeScale ) { | ||
|
||
const times = [], values = [], tmp = new Vector3(); | ||
|
||
for ( let i = 0; i < duration * 10; i ++ ) { | ||
|
||
times.push( i / 10 ); | ||
|
||
tmp.set( Math.random() * 2.0 - 1.0, Math.random() * 2.0 - 1.0, Math.random() * 2.0 - 1.0 ). | ||
multiply( shakeScale ). | ||
toArray( values, values.length ); | ||
|
||
} | ||
|
||
const trackName = '.position'; | ||
|
||
const track = new VectorKeyframeTrack( trackName, times, values ); | ||
|
||
return new AnimationClip( null, duration, [ track ] ); | ||
|
||
} | ||
|
||
static CreatePulsationAnimation( duration, pulseScale ) { | ||
|
||
const times = [], values = [], tmp = new Vector3(); | ||
|
||
for ( let i = 0; i < duration * 10; i ++ ) { | ||
|
||
times.push( i / 10 ); | ||
|
||
const scaleFactor = Math.random() * pulseScale; | ||
tmp.set( scaleFactor, scaleFactor, scaleFactor ). | ||
toArray( values, values.length ); | ||
|
||
} | ||
|
||
const trackName = '.scale'; | ||
|
||
const track = new VectorKeyframeTrack( trackName, times, values ); | ||
|
||
return new AnimationClip( null, duration, [ track ] ); | ||
|
||
} | ||
|
||
static CreateVisibilityAnimation( duration ) { | ||
|
||
const times = [ 0, duration / 2, duration ], values = [ true, false, true ]; | ||
|
||
const trackName = '.visible'; | ||
|
||
const track = new BooleanKeyframeTrack( trackName, times, values ); | ||
|
||
return new AnimationClip( null, duration, [ track ] ); | ||
|
||
} | ||
|
||
static CreateMaterialColorAnimation( duration, colors ) { | ||
|
||
const times = [], values = [], | ||
timeStep = duration / colors.length; | ||
|
||
for ( let i = 0; i <= colors.length; i ++ ) { | ||
|
||
times.push( i * timeStep ); | ||
values.push( colors[ i % colors.length ] ); | ||
|
||
} | ||
|
||
const trackName = '.material[0].color'; | ||
|
||
const track = new ColorKeyframeTrack( trackName, times, values ); | ||
|
||
return new AnimationClip( null, duration, [ track ] ); | ||
|
||
} | ||
|
||
} | ||
|
||
window.THREE.AnimationClipCreator = AnimationClipCreator |
Oops, something went wrong.