| 28525 | }; |
| 28526 | |
| 28527 | function initAnimationPath( parent, spline, name, duration ) { |
| 28528 | |
| 28529 | var animationData = { |
| 28530 | |
| 28531 | name: name, |
| 28532 | fps: 0.6, |
| 28533 | length: duration, |
| 28534 | |
| 28535 | hierarchy: [] |
| 28536 | |
| 28537 | }; |
| 28538 | |
| 28539 | var i, |
| 28540 | parentAnimation, childAnimation, |
| 28541 | path = spline.getControlPointsArray(), |
| 28542 | sl = spline.getLength(), |
| 28543 | pl = path.length, |
| 28544 | t = 0, |
| 28545 | first = 0, |
| 28546 | last = pl - 1; |
| 28547 | |
| 28548 | parentAnimation = { parent: -1, keys: [] }; |
| 28549 | parentAnimation.keys[ first ] = { time: 0, pos: path[ first ], rot: [ 0, 0, 0, 1 ], scl: [ 1, 1, 1 ] }; |
| 28550 | parentAnimation.keys[ last ] = { time: duration, pos: path[ last ], rot: [ 0, 0, 0, 1 ], scl: [ 1, 1, 1 ] }; |
| 28551 | |
| 28552 | for ( i = 1; i < pl - 1; i++ ) { |
| 28553 | |
| 28554 | // real distance (approximation via linear segments) |
| 28555 | |
| 28556 | t = duration * sl.chunks[ i ] / sl.total; |
| 28557 | |
| 28558 | // equal distance |
| 28559 | |
| 28560 | //t = duration * ( i / pl ); |
| 28561 | |
| 28562 | // linear distance |
| 28563 | |
| 28564 | //t += duration * distance( path[ i ], path[ i - 1 ] ) / sl.total; |
| 28565 | |
| 28566 | parentAnimation.keys[ i ] = { time: t, pos: path[ i ] }; |
| 28567 | |
| 28568 | } |
| 28569 | |
| 28570 | animationData.hierarchy[ 0 ] = parentAnimation; |
| 28571 | |
| 28572 | THREE.AnimationHandler.add( animationData ); |
| 28573 | |
| 28574 | return new THREE.Animation( parent, name, THREE.AnimationHandler.CATMULLROM_FORWARD, false ); |
| 28575 | |
| 28576 | }; |
| 28577 | |
| 28578 | |
| 28579 | function createSplineGeometry( spline, n_sub ) { |