Skip to content

Commit

Permalink
fix axis angle serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
Alchemist0823 committed Oct 23, 2023
1 parent ad3852e commit 3770840
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/functions/AxisAngleGenerator.ts
@@ -1,13 +1,15 @@
import {FunctionValueGenerator, ValueGenerator, ValueGeneratorFromJSON} from "./ValueGenerator";
import { Quaternion, Vector3} from "three";
import {FunctionJSON} from "./FunctionJSON";
import {RotationGenerator} from "./RotationGenerator";
import {FunctionValueGenerator, ValueGenerator, ValueGeneratorFromJSON} from './ValueGenerator';
import {Quaternion, Vector3} from 'three';
import {FunctionJSON} from './FunctionJSON';
import {RotationGenerator} from './RotationGenerator';

export class AxisAngleGenerator implements RotationGenerator {

type: "rotation";
constructor(public axis: Vector3, public angle: FunctionValueGenerator | ValueGenerator) {
this.type = "rotation";
type: 'rotation';
constructor(
public axis: Vector3,
public angle: FunctionValueGenerator | ValueGenerator
) {
this.type = 'rotation';
}

genValue(quat: Quaternion, t?: number): Quaternion {
Expand All @@ -17,14 +19,17 @@ export class AxisAngleGenerator implements RotationGenerator {

toJSON(): FunctionJSON {
return {
type: "AxisAngle",
type: 'AxisAngle',
axis: {x: this.axis.x, y: this.axis.y, z: this.axis.z},
angle: this.angle.toJSON(),
};
}

static fromJSON(json: FunctionJSON): AxisAngleGenerator {
return new AxisAngleGenerator(json.axis, ValueGeneratorFromJSON(json.angle) as FunctionValueGenerator);
return new AxisAngleGenerator(
new Vector3(json.axis.x, json.axis.y, json.axis.z),
ValueGeneratorFromJSON(json.angle) as FunctionValueGenerator
);
}

clone(): RotationGenerator {
Expand Down

0 comments on commit 3770840

Please sign in to comment.