Copy utils
This commit is contained in:
parent
d8a3ae7528
commit
a3f76f5c77
14 changed files with 141 additions and 3 deletions
21
src/utils/array.ts
Normal file
21
src/utils/array.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/** @internal */
|
||||
const setIndexAlias = (name: string, index: number, type: any) => {
|
||||
if (!Object.prototype.hasOwnProperty.call(type.prototype, name)) {
|
||||
Object.defineProperty(type.prototype, name, {
|
||||
get() {
|
||||
return this[index];
|
||||
},
|
||||
set(value) {
|
||||
this[index] = value;
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/** @internal */
|
||||
export const applyArrayPlugins = () => {
|
||||
setIndexAlias('x', 0, Array);
|
||||
setIndexAlias('y', 1, Array);
|
||||
setIndexAlias('x', 0, Float32Array);
|
||||
setIndexAlias('y', 1, Float32Array);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue