Skip to content

Commit

Permalink
feat: solve math design circular dependency (galacean#488)
Browse files Browse the repository at this point in the history
* feat: solve math design cirular dependency
  • Loading branch information
yangfengzzz authored Sep 7, 2021
1 parent 977cc82 commit 05d7ebf
Show file tree
Hide file tree
Showing 16 changed files with 36 additions and 19 deletions.
5 changes: 4 additions & 1 deletion packages/design/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
"dist/**/*",
"types/**/*"
],
"types": "types/index.d.ts"
"types": "types/index.d.ts",
"dependencies": {
"@oasis-engine/math": "0.5.2"
}
}
5 changes: 1 addition & 4 deletions packages/math/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,5 @@
"files": [
"dist/**/*",
"types/**/*"
],
"devDependencies": {
"@oasis-engine/design": "0.5.2"
}
]
}
2 changes: 1 addition & 1 deletion packages/math/src/BoundingBox.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IClone } from "@oasis-engine/design";
import { IClone } from "./IClone";
import { BoundingSphere } from "./BoundingSphere";
import { Matrix } from "./Matrix";
import { Vector3 } from "./Vector3";
Expand Down
2 changes: 1 addition & 1 deletion packages/math/src/BoundingFrustum.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IClone } from "@oasis-engine/design";
import { IClone } from "./IClone";
import { BoundingBox } from "./BoundingBox";
import { BoundingSphere } from "./BoundingSphere";
import { CollisionUtil } from "./CollisionUtil";
Expand Down
2 changes: 1 addition & 1 deletion packages/math/src/BoundingSphere.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IClone } from "@oasis-engine/design";
import { IClone } from "./IClone";
import { BoundingBox } from "./BoundingBox";
import { Vector3 } from "./Vector3";

Expand Down
2 changes: 1 addition & 1 deletion packages/math/src/Color.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IClone } from "@oasis-engine/design";
import { IClone } from "./IClone";
import { MathUtil } from "./MathUtil";

/**
Expand Down
16 changes: 16 additions & 0 deletions packages/math/src/IClone.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Clone interface.
*/
export interface IClone {
/**
* Clone and return object.
* @returns Clone object
*/
clone(): Object;

/**
* Clone to the target object.
* @param target - Target object
*/
cloneTo(target: Object): Object;
}
2 changes: 1 addition & 1 deletion packages/math/src/Matrix.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IClone } from "@oasis-engine/design";
import { IClone } from "./IClone";
import { MathUtil } from "./MathUtil";
import { Matrix3x3 } from "./Matrix3x3";
import { Quaternion } from "./Quaternion";
Expand Down
2 changes: 1 addition & 1 deletion packages/math/src/Matrix3x3.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IClone } from "@oasis-engine/design";
import { IClone } from "./IClone";
import { MathUtil } from "./MathUtil";
import { Matrix } from "./Matrix";
import { Quaternion } from "./Quaternion";
Expand Down
2 changes: 1 addition & 1 deletion packages/math/src/Plane.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IClone } from "@oasis-engine/design";
import { IClone } from "./IClone";
import { Vector3 } from "./Vector3";

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/math/src/Quaternion.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IClone } from "@oasis-engine/design";
import { IClone } from "./IClone";
import { MathUtil } from "./MathUtil";
import { Matrix3x3 } from "./Matrix3x3";
import { Vector3 } from "./Vector3";
Expand Down
2 changes: 1 addition & 1 deletion packages/math/src/Rect.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IClone } from "@oasis-engine/design";
import { IClone } from "./IClone";

// A 2d rectangle defined by x and y position, width and height.
export class Rect implements IClone {
Expand Down
5 changes: 3 additions & 2 deletions packages/math/src/SphericalHarmonics3.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IClone } from "@oasis-engine/design";
import { IClone } from "./IClone";
import { Color } from "./Color";
import { Vector3 } from "./Vector3";

Expand Down Expand Up @@ -203,7 +203,8 @@ export class SphericalHarmonics3 implements IClone {
* @param out - The specified SphericalHarmonics3
* @returns The specified SphericalHarmonics3
*/
cloneTo(out: SphericalHarmonics3): void {
cloneTo(out: SphericalHarmonics3): SphericalHarmonics3 {
this.toArray(out.coefficients);
return out;
}
}
2 changes: 1 addition & 1 deletion packages/math/src/Vector2.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IClone } from "@oasis-engine/design";
import { IClone } from "./IClone";
import { MathUtil } from "./MathUtil";

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/math/src/Vector3.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IClone } from "@oasis-engine/design";
import { IClone } from "./IClone";
import { MathUtil } from "./MathUtil";
import { Matrix } from "./Matrix";
import { Quaternion } from "./Quaternion";
Expand Down
2 changes: 1 addition & 1 deletion packages/math/src/Vector4.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IClone } from "@oasis-engine/design";
import { IClone } from "./IClone";
import { MathUtil } from "./MathUtil";
import { Matrix } from "./Matrix";
import { Quaternion } from "./Quaternion";
Expand Down

0 comments on commit 05d7ebf

Please sign in to comment.