Basic canvas parallax
This commit is contained in:
parent
3bed56ed4b
commit
576d06e4bd
9 changed files with 260 additions and 172 deletions
23
src/page/background/vec3.ts
Normal file
23
src/page/background/vec3.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import { Vec2 } from "./vec2";
|
||||
|
||||
export class Vec3 {
|
||||
public static readonly Zero = new Vec3(0, 0, 0);
|
||||
|
||||
public static from(vec2: Vec2, z: number): Vec3 {
|
||||
return new Vec3(vec2.x, vec2.y, z);
|
||||
}
|
||||
|
||||
public constructor(
|
||||
public readonly x: number,
|
||||
public readonly y: number,
|
||||
public readonly z: number
|
||||
) {}
|
||||
|
||||
public add(other: Vec3): Vec3 {
|
||||
return new Vec3(this.x + other.x, this.y + other.y, this.z + other.z);
|
||||
}
|
||||
|
||||
public multiply(other: Vec3): Vec3 {
|
||||
return new Vec3(this.x * other.x, this.y * other.y, this.z * other.z);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue