提交 b67cca36 编写于 作者: B Ben Houston

more minor bug fixing with Animation.

上级 1e219a67
......@@ -258,9 +258,13 @@
mixer = new THREE.AnimationMixer( mesh );
var rotateClip = THREE.AnimationClip.CreateRotationAnimation( 10 );
//var clip = THREE.AnimationClip.CreateShakeAnimation( 10, new THREE.Vector3( 10, 10, 10 ) );
//var clip = THREE.AnimationClip.CreatePulsationAnimation( 10, 100 );
//var clip = THREE.AnimationClip.CreateRotationAnimation( 10, 'x' );
var clip = THREE.AnimationClip.CreateScaleAxisAnimation( 10, 'x' );
mixer.addAction( new THREE.AnimationAction( rotateClip, 0, 1, 1, true ) );
mixer.addAction( new THREE.AnimationAction( clip, 0, 1, 1, true ) );
}
......
......@@ -211,6 +211,23 @@ THREE.AnimationClip.CreateRotationAnimation = function( period, axis ) {
return clip;
};
THREE.AnimationClip.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.KeyframeTrack( trackName, keys );
var clip = new THREE.AnimationClip( 'scale.x', 10, [ track ] );
console.log( 'scaleClip', clip );
return clip;
};
THREE.AnimationClip.CreateShakeAnimation = function( duration, shakeScale ) {
var keys = [];
......@@ -228,14 +245,14 @@ THREE.AnimationClip.CreateShakeAnimation = function( duration, shakeScale ) {
var track = new THREE.KeyframeTrack( trackName, keys );
var clip = new THREE.AnimationClip( 'shake' + duration, trackName, [ track ] );
var clip = new THREE.AnimationClip( 'shake' + duration, duration, [ track ] );
console.log( 'shakeClip', clip );
return clip;
};
THREE.AnimationClip.CreatePulsationAnimation = function( node, duration, pulseScale ) {
THREE.AnimationClip.CreatePulsationAnimation = function( duration, pulseScale ) {
var keys = [];
......@@ -249,11 +266,11 @@ THREE.AnimationClip.CreatePulsationAnimation = function( node, duration, pulseSc
}
var trackName = node.name + '.scale';
var trackName = '.scale';
var track = new THREE.KeyframeTrack( trackName, keys );
var clip = new THREE.AnimationClip( 'scale' + duration, trackName, [ track ] );
var clip = new THREE.AnimationClip( 'scale' + duration, duration, [ track ] );
console.log( 'scaleClip', clip );
return clip;
......
......@@ -14,7 +14,7 @@ THREE.KeyframeTrack = function ( name, keys ) {
this.keys = keys || []; // time in seconds, value as value
// TODO: sort keys via their times
this.keys.sort( function( a, b ) { return a.time < b.time; } );
//this.keys.sort( function( a, b ) { return a.time < b.time; } );
};
......@@ -27,6 +27,7 @@ THREE.KeyframeTrack.prototype = {
if( this.keys.length == 0 ) throw new Error( "no keys in track named " + this.name );
console.log( "keys", this.keys );
// before the start of the track, return the first key value
if( this.keys[0].time >= time ) {
......
......@@ -17,7 +17,7 @@ THREE.PropertyBinding = function ( rootNode, trackName ) {
this.nodeName = parseResults.nodeName;
this.material = parseResults.material;
this.propertyName = parseResults.propertyName || null;
this.propertyArrayIndex = parseResults.propertyArrayIndex || -1;
this.propertySubElement = parseResults.propertySubElement || -1;
this.node = THREE.PropertyBinding.findNode( rootNode, this.nodeName );
......@@ -51,9 +51,9 @@ THREE.PropertyBinding.prototype = {
}
// access a sub element of the property array (only primitives are supported right now)
if( this.propertyArrayIndex >= 0 ) {
console.log( ' update property array ' + this.propertyName + '[' + this.propertyArrayIndex + '] via assignment.' );
nodeProperty[ this.propertyArrayIndex ] = value;
if( ( this.propertySubElement.length && this.propertySubElement.length > 0 ) || this.propertySubElement >= 0 ) {
console.log( ' update property array ' + this.propertyName + '[' + this.propertySubElement + '] via assignment.' );
nodeProperty[ this.propertySubElement ] = value;
}
// must use copy for Object3D.Euler/Quaternion
else if( nodeProperty.copy ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册