@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
25 lines (24 loc) • 723 B
JavaScript
;
import { Vector2, Vector3, Vector4 } from "three";
export const COMPONENT_NAMES = ["x", "y", "z", "w"];
export function initArrayIfRequired(object, arraysByGeometryUuid, arrayLength) {
const currentArray = arraysByGeometryUuid.get(object);
if (currentArray) {
if (currentArray.length < arrayLength) {
arraysByGeometryUuid.set(object, new Array(arrayLength));
}
} else {
arraysByGeometryUuid.set(object, new Array(arrayLength));
}
return arraysByGeometryUuid.get(object);
}
export function vectorByAttribSize(size) {
switch (size) {
case 2:
return new Vector2(0, 0);
case 3:
return new Vector3(0, 0, 0);
case 4:
return new Vector4(0, 0, 0, 0);
}
}