Add files

This commit is contained in:
schmelczerandras 2020-09-15 10:08:16 +02:00
commit 77bde04db3

49
src/helper/array.ts Normal file
View 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() {
return this[0];
},
set(value) {
this[0] = value;
},
});
Object.defineProperty(Array.prototype, 'y', {
get() {
return this[1];
},
set(value) {
this[1] = value;
},
});
Object.defineProperty(Float32Array.prototype, 'x', {
get() {
return this[0];
},
set(value) {
this[0] = value;
},
});
Object.defineProperty(Float32Array.prototype, 'y', {
get() {
return this[1];
},
set(value) {
this[1] = value;
},
});
};