Add glMatrix
This commit is contained in:
parent
582979d3ed
commit
e88b4589d2
26 changed files with 211 additions and 358 deletions
49
frontend/src/scripts/helper/array.ts
Normal file
49
frontend/src/scripts/helper/array.ts
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
declare global {
|
||||
interface Array<T> {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
|
||||
interface Float32Array {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
}
|
||||
|
||||
export const applyArrayPlugins = () => {
|
||||
Object.defineProperty(Array.prototype, 'x', {
|
||||
get: function () {
|
||||
return this[0];
|
||||
},
|
||||
set: function (value) {
|
||||
this[0] = value;
|
||||
},
|
||||
});
|
||||
|
||||
Object.defineProperty(Array.prototype, 'y', {
|
||||
get: function () {
|
||||
return this[1];
|
||||
},
|
||||
set: function (value) {
|
||||
this[1] = value;
|
||||
},
|
||||
});
|
||||
|
||||
Object.defineProperty(Float32Array.prototype, 'x', {
|
||||
get: function () {
|
||||
return this[0];
|
||||
},
|
||||
set: function (value) {
|
||||
this[0] = value;
|
||||
},
|
||||
});
|
||||
|
||||
Object.defineProperty(Float32Array.prototype, 'y', {
|
||||
get: function () {
|
||||
return this[1];
|
||||
},
|
||||
set: function (value) {
|
||||
this[1] = value;
|
||||
},
|
||||
});
|
||||
};
|
||||
4
frontend/src/scripts/helper/clamp.ts
Normal file
4
frontend/src/scripts/helper/clamp.ts
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
export const clamp = (value: number, min: number, max: number): number =>
|
||||
Math.min(max, Math.max(min, value));
|
||||
|
||||
export const clamp01 = (value: number): number => clamp(value, 0, 1);
|
||||
Loading…
Add table
Add a link
Reference in a new issue