Initial commit

This commit is contained in:
2025-11-17 15:06:39 +01:00
parent 2015516eca
commit 4d2432a1c2
91 changed files with 5074894 additions and 2 deletions

60
framework/Vector3.js Normal file
View File

@@ -0,0 +1,60 @@
export default class Vector3 {
x = 0;
y = 0;
z = 0;
constructor( x = 0, y = 0, z = 0 ) {
this.x = x;
this.y = y;
this.z = z;
}
static subtract( a, b ) {
return new Vector3( a.x - b.x, a.y - b.y, a.z - b.z );
}
length() {
return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z );
}
static cross( a, b ) {
return new Vector3(
a.y * b.z - a.z * b.y,
a.z * b.x - a.x * b.z,
a.x * b.y - a.y * b.x
);
}
static dot( a, b ) {
return a.x * b.x + a.y * b.y + a.z * b.z;
}
static normalize( v ) {
const length = Math.sqrt( v.x * v.x + v.y * v.y + v.z * v.z );
if ( length > 0.00001 ) {
return new Vector3( v.x / length, v.y / length, v.z / length );
} else {
return new Vector3( 0, 0, 0 );
}
}
}