UNPKG

primitive-geometry

Version:

Geometries for 3D rendering, including normals, UVs and cell indices (faces). Perfect if you want to supercharge your dependency folder... with 30KB of geometries.

49 lines (43 loc) 868 B
/** @module quad */ import { checkArguments, getCellsTypedArray } from "./utils.js"; /** * @typedef {object} QuadOptions * @property {number} [scale=0.5] */ /** * @alias module:quad * @param {QuadOptions} [options={}] * @returns {import("../types.js").SimplicialComplex} */ function quad({ scale = 0.5 } = {}) { checkArguments(arguments); return { // prettier-ignore positions: Float32Array.of( -scale, -scale, 0, scale, -scale, 0, scale, scale, 0, -scale, scale, 0, ), // prettier-ignore normals: Int8Array.of( 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, ), // prettier-ignore uvs: Uint8Array.of( 0, 0, 1, 0, 1, 1, 0, 1 ), // prettier-ignore cells: (getCellsTypedArray(12)).of( 0, 1, 2, 2, 3, 0 ), }; } export default quad;