-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modern Mixer-based Animation System #6934
Merged
Merged
Changes from all commits
Commits
Show all changes
161 commits
Select commit
Hold shift + click to select a range
24998be
Track/Clip/Action/Mixer implementation in progress.
bhouston 9ad046d
create the files for the individual animation components.
bhouston 0962f90
implement some of the TODOs. add lots of verbose debug info.
bhouston 69a3556
descriptions of the classes.
bhouston cb2d50b
more TODOs.
bhouston c88066f
Clip,Action,Mixer -> Animation*
bhouston 8e94b36
introduce the TrackBinding class for better organization.
bhouston c873ac8
remove ConstantTrack and Track classes, not needed.
bhouston 516dce8
place holders for test animations.
bhouston bbe37cc
TrackBinding -> PropertyBinding. Add example clips.
bhouston 70f58ec
improve nodeName parsing and resolving to support uuids.
bhouston 99e08d4
support node.uuid as identifies in trackNames.
bhouston dadc0a1
add example of how to specify a morph target animation.
bhouston 87b5f7e
remove three-math from npm build, never used.
bhouston aa5ed5d
begin track/clip/mixer example.
bhouston 907c698
Merge branch 'dev' of git@github.com:mrdoob/three.js.git into modernA…
bhouston 70b6e13
only build three.js and three.min.js for npm module.
bhouston 0be1e5f
fixing compile errors.
bhouston 633e071
add new animation classes to common includes.
bhouston d74c89c
debugging new animation system along with example.
bhouston b396969
more bug fixing.
bhouston 1e219a6
add support for binding to materials.
bhouston b67cca3
more minor bug fixing with Animation.
bhouston ea152c1
add support for propertybindings to sub materials, and it works.
bhouston 77612e4
optimization - stage one. Reduce temp memory allocations, cache Prop…
bhouston 56e20cb
minor optimization.
bhouston 6311e13
add support for morphTarget name resolution - untested.
bhouston dc0ab1e
resolving bone names (two ways now to specify bones), allow for discr…
bhouston 39bedda
move towards delta time.
bhouston e6aad57
visibility track works.
bhouston 74c2898
make morph target animation clips work.
bhouston e5857aa
minor error.
bhouston d0dc293
mention optimization technique.
bhouston 0e5c35f
first pass at parsing JSONLoader hierarchy animations (keyframe + mor…
bhouston 1be1d05
memeoization of lerp. add optimize, trim, validate, sort to Keyframe…
bhouston 4657a76
fix bugs in KeyframeTrack.optimize/validate. Expand capabilities of …
bhouston 85d8a7a
optimize Action.toAnimationClipTime().
bhouston 876eda7
only update scene graph values if actually different, only call trigg…
bhouston 9eb5ca1
bones work! various optimizations.
bhouston 281f510
avoid clones while interpolating values.
bhouston 728c305
create Mixer recreation of classic ThreeJS examples.
bhouston cf34318
optimizations and added USCCharacterMixer (mixer-based USCCharacter).
bhouston 2bd48d5
start to replace the internals of MorphAnimMesh.
bhouston 8705887
begin fadeIn, fadeOut commands - not tested.
bhouston 8590ad5
allow for PropertyBindings to bind/unbind. PropertyBindings are refe…
bhouston eec2153
add wrap scheduling. updates to MD2Character, USCCharacter.
bhouston e3b2c75
introduce time awareness in AnimationAction.
bhouston dff0e17
cleaning up time handling in AnimationAction - moving to relative time.
bhouston 996879a
minor bug fixes.
bhouston 08f03bb
more minor bugs.
bhouston 9947cdc
minor bone bugs. webgl_animation_skinning_morph.html works.
bhouston cc3684a
faster KeyframeTrack.getAt - local walk from last value.
bhouston a95ec4d
debugging lack of morphTargets working.
bhouston a044dc9
fix bug where the keyframe track couldn't get back to the first key.
bhouston 9583d29
fix skeleton in example, better comments.
bhouston 002c313
begin conversion of BlendCharacter to new animation system.
bhouston bfee311
BlendCharacter example mostly working with new animation system.
bhouston eb64f9e
add optimization for consecutive keys that are identical -- no linear…
bhouston 055dc34
BlendCharacter example works great.
bhouston 16ee794
get UCSCharacter working again.
bhouston 4985ed0
update morphanimmesh to work with the new mixer.
bhouston e9cd1a2
memorize the KeyframeTrack.setResult()
bhouston ac5802c
get webgl_shader_physical animation working again.
bhouston 5022f4f
fix issues brought up by @liammagee
bhouston 4143536
fix bug.
bhouston 8652335
remove debugging output.
bhouston 759ca9c
fix comments.
bhouston 4acb726
fix comments.
bhouston 5b41c70
allow for events to be send on Action loop and finish.
bhouston 3d2b5eb
name all anonymous functions for better results when profiling.
bhouston 30c9d9b
pull out functions into class members.
bhouston a335247
reduce use of maps where possible in favor of arrays.
bhouston 8da58ca
get rid of another map used in a tight inner loop.
bhouston 31bd3bf
remove old propertyBindings map and replace it with an array.
bhouston e3604c6
fix obvious bugs.
bhouston 4b884a3
address @mrdoob comment: https://github.com/mrdoob/three.js/pull/6934…
bhouston ef5fc2e
initial attempt at implementing @mrdoob's suggestion here: https://gi…
bhouston 73a55e9
complete creation of type-specific KeyframeTrack classes.
bhouston fa92cf1
Merge branch 'dev' of git@github.com:mrdoob/three.js into modernAnima…
bhouston 4c7962b
allow for automatic detection of AnimationClip lengths.
bhouston 75b996a
allow for tracks to parse themselves via static memebers.
bhouston cce8794
object loader can now parse tracks on individual objects for scene an…
bhouston 0de4a55
fix name bug in scene object tracks.
bhouston 6564cc8
combine all tracks on a subhierarchy into one animation clip on the t…
bhouston de83df1
upgrade webgl_morphnormals.html to use new Mixer animation framework.
bhouston 355434e
allow for automatic detection of AnimationClip lengths.
bhouston fe6b0b3
allow for tracks to parse themselves via static memebers.
bhouston a15ffe8
fix bug in ObjectLoader.
bhouston ac12e43
add KeyframeTrack.shift function to move keyframes around in time.
bhouston 40a952e
allow for cloning of boolean keyframe tracks.
bhouston d69840c
KeyframeTrack.trim( start, end ). Return this if possible. Use fps …
bhouston a185475
add *KeyframeTrack.clone().
bhouston fc212a3
add first example for loading node animations from ObjectLoader.
bhouston 1cefeae
fix potential null reference.
bhouston 8b071b9
add ability to multiple QuaternionKeyframeTracks with quaternions.
bhouston 8b5f0d5
fix off by one bugs in KeyframeTrack.shift/scale - was skipping first…
bhouston 3905008
cleaning up example for node animations.
bhouston d76c4fc
playing around with getting node animations oriented the right way.
bhouston 7634394
comment out hack to try and get quaternions to match.
bhouston e39745f
add json scene file.
bhouston bb72081
Merge remote-tracking branch 'origin/sceneAnimations'
jackcaron 84a9423
improve keyframe track parsing to be more flexible.
bhouston b29835c
Merge remote-tracking branch 'origin/dev'
jackcaron 0feb6bd
Merge remote-tracking branch 'origin/sceneAnimations'
jackcaron aa44449
missing equal sign
jackcaron 3b894ac
forgot the 'function'
jackcaron 2d1745d
new track system, plus blend shapes
jackcaron 333b3e0
Merge pull request #3 from jackcaron/sceneAnimations
bhouston 0e66ebc
messing around with 'animations' compatibility with ThreeJS JSON expo…
bhouston 0fd51ae
Merge branch 'sceneAnimations' of git@github.com:bhouston/three.js.gi…
bhouston 7e60f3a
add new .clips support on Nodes and Geometries for simple/fast Animat…
bhouston 1f858e1
Merge branch 'dev' of git@github.com:mrdoob/three.js into sceneAnimat…
bhouston 454847c
manual merge of blender Clip (blend shape + node animation) support.
bhouston 4456091
update format version to 4.4
bhouston 4e37704
fix double used variable nb_curves
bhouston 4cc6755
add more authors.
bhouston 9c0dc9b
webgl_animation_scene.html
bhouston aa176dc
white background helps everything standout better.
bhouston eeb750b
remove dat GUI, not needed.
bhouston d37a239
better scene title.
bhouston f5a1820
cleanup json models.
bhouston babd98d
restore part of Blender JSON exporter missed in merge.
bhouston 9ac106f
do not export Blender's distance parameter as it isn't a cutoff dista…
bhouston 71480f0
adapt webgl_animation_skinning_morph to the new clip design.
bhouston 43f821d
remove console.log.
bhouston 801124d
simplifying code in the clip-based animation system.
bhouston 10364f8
bugs.
bhouston a1a88eb
updating examples to new Clip parsing inside of JSONLoader/ObjectLoader.
bhouston ce70dc6
refactor JSONLoader's loading of clips. Load morph sequences into cl…
bhouston e6795ff
removing MorphAnimMesh from various examples.
bhouston 03269bf
remove MorphAnimMesh were possible from examples and just use the Mixer.
bhouston 9ae28c8
rotate blender tracks by 90 degrees around x-axis.
bhouston f30db85
improved webgl_animation_blend example.
bhouston f32440c
remove unused animation clip creator.
bhouston e0fdbbd
allow for setting per action local roots.
bhouston 3cf8527
allow for local roots on actions.
bhouston 2f0287e
simplify physical_shading example with new Animation clip support.
bhouston 3a24fca
use a single mixer for shadow map performance.
bhouston 8f79ee4
Merge branch 'nnn' into temp
bhouston f89af19
remove MorphAnimMesh from MD2Character and MD2Loader while retaining …
bhouston a1fb6c3
fix bug, not calling AnimationAction.init.
bhouston 6179248
Merge branch 'dev' into temp
bhouston a73bd43
Convert canvas horse morph to Mixer.
bhouston 5dad759
demote MorphAnimMesh.js and MorphAnimation.js
bhouston 8f2e0f6
webgl_loader_md2 should start with an initial animation.
bhouston a9dbaa9
demote Animation, AnimationHandler, KeyFrameAnimation.
bhouston 399458c
move examples/js/Animation* to example/js/loaders/collada/Animation*
bhouston e9d593b
fix two broken examples.
bhouston 922a9dc
optimize Mixer (lazy updates to cache, use map instead of linear sear…
bhouston 6310c50
add Action loop styles, LoopOnce, LoopRepeat and LoopPingPong
bhouston 5b30934
loopStyle --> loop. remove left over debugging console.error
bhouston 3bfc0b1
remvoe debug comments, and a forgotten reset of propertyBindingNamesT…
bhouston 94478be
simplify Action propertyBinding caches.
bhouston 63414e3
remove debug comment.
bhouston 8a0053f
fix bug in AnimationAction introduced in rewrite for LoopPingPong.
bhouston ef42280
simplify AnimationMixer to prevent bugs.
bhouston 32befcc
make it easy to synchronize to actions together.
bhouston 8ee9c98
write animations at the root
jackcaron cedf004
put blend shape first, more stable approach
jackcaron 036147e
geometry/object.clips -> geometry/object.animation
bhouston 94d8f1a
remove some left over console.log statements.
bhouston File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,139 @@ | ||
/** | ||
* | ||
* Creator of typical test AnimationClips / KeyframeTracks | ||
* | ||
* @author Ben Houston / http://clara.io/ | ||
* @author David Sarno / http://lighthaus.us/ | ||
*/ | ||
|
||
THREE.AnimationClipCreator = function() { | ||
}; | ||
|
||
THREE.AnimationClipCreator.CreateRotationAnimation = function( period, axis ) { | ||
|
||
var keys = []; | ||
keys.push( { time: 0, value: 0 } ); | ||
keys.push( { time: period, value: 360 } ); | ||
|
||
axis = axis || 'x'; | ||
var trackName = '.rotation[' + axis + ']'; | ||
|
||
var track = new THREE.NumberKeyframeTrack( trackName, keys ); | ||
|
||
var clip = new THREE.AnimationClip( 'rotate.x', 10, [ track ] ); | ||
//console.log( 'rotateClip', clip ); | ||
|
||
return clip; | ||
}; | ||
|
||
THREE.AnimationClipCreator.CreateScaleAxisAnimation = function( period, axis ) { | ||
|
||
var keys = []; | ||
keys.push( { time: 0, value: 0 } ); | ||
keys.push( { time: period, value: 360 } ); | ||
|
||
axis = axis || 'x'; | ||
var trackName = '.scale[' + axis + ']'; | ||
|
||
var track = new THREE.NumberKeyframeTrack( trackName, keys ); | ||
|
||
var clip = new THREE.AnimationClip( 'scale.x', 10, [ track ] ); | ||
//console.log( 'scaleClip', clip ); | ||
|
||
return clip; | ||
}; | ||
|
||
THREE.AnimationClipCreator.CreateShakeAnimation = function( duration, shakeScale ) { | ||
|
||
var keys = []; | ||
|
||
for( var i = 0; i < duration * 10; i ++ ) { | ||
|
||
keys.push( { | ||
time: ( i / 10.0 ), | ||
value: new THREE.Vector3( Math.random() * 2.0 - 1.0, Math.random() * 2.0 - 1.0, Math.random() * 2.0 - 1.0 ).multiply( shakeScale ) | ||
} ); | ||
|
||
} | ||
|
||
var trackName = '.position'; | ||
|
||
var track = new THREE.VectorKeyframeTrack( trackName, keys ); | ||
|
||
var clip = new THREE.AnimationClip( 'shake' + duration, duration, [ track ] ); | ||
//console.log( 'shakeClip', clip ); | ||
|
||
return clip; | ||
}; | ||
|
||
|
||
THREE.AnimationClipCreator.CreatePulsationAnimation = function( duration, pulseScale ) { | ||
|
||
var keys = []; | ||
|
||
for( var i = 0; i < duration * 10; i ++ ) { | ||
|
||
var scaleFactor = Math.random() * pulseScale; | ||
keys.push( { | ||
time: ( i / 10.0 ), | ||
value: new THREE.Vector3( scaleFactor, scaleFactor, scaleFactor ) | ||
} ); | ||
|
||
} | ||
|
||
var trackName = '.scale'; | ||
|
||
var track = new THREE.VectorKeyframeTrack( trackName, keys ); | ||
|
||
var clip = new THREE.AnimationClip( 'scale' + duration, duration, [ track ] ); | ||
//console.log( 'scaleClip', clip ); | ||
|
||
return clip; | ||
}; | ||
|
||
|
||
THREE.AnimationClipCreator.CreateVisibilityAnimation = function( duration ) { | ||
|
||
var keys = []; | ||
keys.push( { | ||
time: 0, | ||
value: true | ||
} ); | ||
keys.push( { | ||
time: duration - 1, | ||
value: false | ||
} ); | ||
keys.push( { | ||
time: duration, | ||
value: true | ||
} ); | ||
|
||
var trackName = '.visible'; | ||
|
||
var track = new THREE.BooleanKeyframeTrack( trackName, keys ); | ||
|
||
var clip = new THREE.AnimationClip( 'visible' + duration, duration, [ track ] ); | ||
//console.log( 'scaleClip', clip ); | ||
|
||
return clip; | ||
}; | ||
|
||
|
||
THREE.AnimationClipCreator.CreateMaterialColorAnimation = function( duration, colors, loop ) { | ||
|
||
var timeStep = duration / colors.length; | ||
var keys = []; | ||
for( var i = 0; i <= colors.length; i ++ ) { | ||
keys.push( { time: i * timeStep, value: colors[ i % colors.length ] } ); | ||
} | ||
|
||
var trackName = '.material[0].color'; | ||
|
||
var track = new THREE.ColorKeyframeTrack( trackName, keys ); | ||
|
||
var clip = new THREE.AnimationClip( 'colorDiffuse', 10, [ track ] ); | ||
//console.log( 'diffuseClip', clip ); | ||
|
||
return clip; | ||
}; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about doing something more like
value: new THREE.BooleanAnimationValue( true )
and remove all thePropertyBinding
stuff?I did something like that for frame.js:
https://github.com/mrdoob/frame.js/blob/master/src/Frame.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not quite understand.
I've made a quick stab at create types for the KeyframeTracks, but I am not sure that is what you mean.
There are three complexities in this PR that I am not sure the best way to solve:
The first is how to have polymorphic interpolate/accumulate/set operators. This functionality is required both by KeyframeTrack (interpolate/set), and AnimationMixer (accumulate/set). Interpolating quaternions (.slerp) is different than interpolating vectors (.lerp) and is different than interpolating numbers (just use math directly.) Also setting objects like Quaternion/Vector is different than setting primitives like number.
The second problem is how to handle setting properties on the scene graph. It is more complex than the set operation described above. When setting things on the scene graph one still needs to be aware of whether one is setting an object or a primitive, but one also needs to be aware of whether one is setting an array element (see my functions setValue_propertyIndexed/getValue_propertyIndexed).
Lastly, a lot of the complexity of PropertyBinding is because it uses flexible path definitions to identity nodes. It supports the following types of paths:
The last two are virtual properties because I am allowing for bone names and morph names to be used as an accessor when binding, and then automatically resolved to the numbered indices for run-time efficiency.
I believe that allowing for these types of paths for tracks allows just about anything in ThreeJS to be animated easily as part of one animation clip.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW the classes I added are:
BooleanKeyframeTrack
StringKeyframeTrack
VectorKeyframeTrack
QuaternionKeyframeTrack
NumberKeyframeTrack
https://github.com/mrdoob/three.js/pull/6934/files#diff-9ed93c77fab8c29ff951e4c81708dfd7R1
I haven't tested them as I am unsure if this is the right direction -- I think that this change isn't what you want as it seems to be very verbose and not that useful.
I do think that PropertyBinding may not be the prettiest class, it is actually pretty compact and fast and it can be refactored in the future by someone smarter than me while retaining its functionality. I do not expose PropertyBinding really through the API for the Mixer or Keyframe Tracks, it is really an internal use class - that is why I am okay with it not being super pretty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These classes are what I meant yes. As you know, I prefer things to be as explicit so the code is easy to follow/understand.