UNPKG

@thi.ng/webgl

Version:

WebGL & GLSL abstraction layer

20 lines (19 loc) 491 B
import { V3 } from "@thi.ng/shader-ast/api/types"; const DEFAULT_MATERIAL = { ambientCol: [0.1, 0.1, 0.1], diffuseCol: [0.8, 0.8, 0.8], specularCol: [1, 1, 1] }; const TYPES = { ambientCol: V3, diffuseCol: V3, specularCol: V3 }; const defMaterial = (mat = {}, flags = {}, base = DEFAULT_MATERIAL) => Object.keys(base).reduce((acc, id) => { flags[id] !== false && (acc[id] = [TYPES[id], mat[id] || base[id]]); return acc; }, {}); export { DEFAULT_MATERIAL, defMaterial };