diff --git a/app/pages/PageEnigma/datastructures/clips/transform_track_clip.ts b/app/pages/PageEnigma/datastructures/clips/transform_track_clip.ts index 95dfd30599..1b552c7acf 100644 --- a/app/pages/PageEnigma/datastructures/clips/transform_track_clip.ts +++ b/app/pages/PageEnigma/datastructures/clips/transform_track_clip.ts @@ -44,15 +44,28 @@ export class TransformTrackClip implements TransformTrackClip { if (this.step_frame >= 60/this.length && this.looping == false) { return; } // Reached max frames. if(this.positions.length < 2) { return; } // If there are enough points in the scene. this.step_frame += 1; - const curve = new THREE.CatmullRomCurve3(this.positions); - const point = curve.getPoint((this.step_frame/60)*this.length); + let curve = new THREE.CatmullRomCurve3(this.positions); + let point = curve.getPoint((this.step_frame/60)*this.length); object.position.copy(point); + + let curve_rot = new THREE.CatmullRomCurve3(this.rotations); + let point_rot = curve.getPoint((this.step_frame/60)*this.length); + object.rotation.set(point_rot.x, point_rot.y, point_rot.z); + + let curve_scale = new THREE.CatmullRomCurve3(this.scales); + let point_scale = curve.getPoint((this.step_frame/60)*this.length); + object.position.copy(point_scale); } reset(object: THREE.Object3D) { if (this.positions.length > 0) { let first_pos = this.positions[0]; + let first_rot = this.rotations[0]; + let first_scl = this.scales[0]; object.position.copy(first_pos); + object.rotation.set(first_rot.x, first_rot.y, first_rot.z); + object.scale.copy(first_scl); + this.step_frame = 0; } } @@ -67,6 +80,26 @@ export class TransformTrackClip implements TransformTrackClip { }); } + add_rotation(rotation: THREE.Vector3) { + this.rotations.push(new THREE.Vector3(rotation.x, rotation.y, rotation.z)); + } + + remove_rotation(rotation: THREE.Vector3) { + this.rotations = this.rotations.filter(rotations => { + return !rotation.equals(rotation); + }); + } + + add_scale(scale: THREE.Vector3) { + this.scales.push(new THREE.Vector3(scale.x, scale.y, scale.z)); + } + + remove_scale(scale: THREE.Vector3) { + this.scales = this.scales.filter(scales => { + return !scale.equals(scale); + }); + } + toJSON(): string { return JSON.stringify({ version: this.version, diff --git a/app/pages/PageEnigma/js/transform_engine.ts b/app/pages/PageEnigma/js/transform_engine.ts index 28c32b6ead..c5eeb170b0 100644 --- a/app/pages/PageEnigma/js/transform_engine.ts +++ b/app/pages/PageEnigma/js/transform_engine.ts @@ -22,6 +22,8 @@ class TransformEngine { this.clips[object.uuid] = new TransformTrackClip(this.version, object.uuid, clip_length); } this.clips[object.uuid].add_position(object.position); + this.clips[object.uuid].add_rotation(new THREE.Vector3(object.rotation.x, object.rotation.y, object.rotation.z)); + this.clips[object.uuid].add_scale(object.scale); } }