BooleanKeyframeTrack.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /**
  2. *
  3. * A Track that interpolates Boolean
  4. *
  5. * @author Ben Houston / http://clara.io/
  6. * @author David Sarno / http://lighthaus.us/
  7. */
  8. THREE.BooleanKeyframeTrack = function ( name, keys ) {
  9. THREE.KeyframeTrack.call( this, name, keys );
  10. // local cache of value type to avoid allocations during runtime.
  11. this.result = this.keys[0].value;
  12. };
  13. THREE.BooleanKeyframeTrack.prototype = Object.create( THREE.KeyframeTrack.prototype );
  14. THREE.BooleanKeyframeTrack.prototype.constructor = THREE.BooleanKeyframeTrack;
  15. THREE.BooleanKeyframeTrack.prototype.setResult = function( value ) {
  16. this.result = value;
  17. };
  18. // memoization of the lerp function for speed.
  19. // NOTE: Do not optimize as a prototype initialization closure, as value0 will be different on a per class basis.
  20. THREE.BooleanKeyframeTrack.prototype.lerpValues = function( value0, value1, alpha ) {
  21. return ( alpha < 1.0 ) ? value0 : value1;
  22. };
  23. THREE.BooleanKeyframeTrack.prototype.compareValues = function( value0, value1 ) {
  24. return ( value0 === value1 );
  25. };
  26. THREE.BooleanKeyframeTrack.parse = function( name, jsonKeys ) {
  27. return new THREE.BooleanKeyframeTrack( name, jsonKeys );
  28. };