mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-05 17:58:55 +00:00
updated transform with scale and rotation.
This commit is contained in:
1 parent
a389b35374
commit
4a3806294e
2 files changed
+37
-2
No files matched your search
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user