INNER CODE UNIT · JavaScript
B
hyperfy-xyz/hyperfy · src/core/libs/three-custom-shader-material/index.js:409
class B extends T.Material {
constructor({ baseMaterial: n, vertexShader: S, fragmentShader: h, uniforms: m, patchMap: I, cacheKey: f, ...r }) {
if (!n) throw new Error('CustomShaderMaterial: baseMaterial is required.')
let i
if (k(n)) {
const _ = Object.keys(r).length === 0
i = new n(_ ? void 0 : r)
} else (i = n), Object.assign(i, r)
if (['ShaderMaterial', 'RawShaderMaterial'].includes(i.type))
throw new Error(`CustomShaderMaterial does not support ${i.type} as a base material.`)
super(), (this.uniforms = {}), (this.vertexShader = ''), (this.fragmentShader = '')
const t = i
;(t.name = `CustomShaderMaterial<${i.name}>`),
(t.update = this.update.bind(t)),
(t.__csm = { prevOnBeforeCompile: i.onBeforeCompile })
const o = { ...(t.uniforms || {}), ...(m || {}) }
return (
(t.uniforms = this.uniforms = o),