"use strict"; const RailingMaterialGame = (function(){ const RailingMaterialGame = function(hollow_bond){ let material = null; this.get = () => { if(material) return material; const theme_def = (hollow_bond.theme && hollow_bond.theme.railing) ? hollow_bond.theme.railing : { vertex: ` varying vec3 vNormal; void main(){ vNormal = normalize(normalMatrix * normal); gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); } `, fragment: ` varying vec3 vNormal; void main(){ vec3 dark_metal = vec3(0.2, 0.19, 0.18); vec3 highlight = vec3(0.35, 0.33, 0.3); gl_FragColor = vec4(mix(dark_metal, highlight, abs(vNormal.y) * 0.3), 1.0); } ` }; material = new THREE.ShaderMaterial({ vertexShader: theme_def.vertex, fragmentShader: theme_def.fragment, side: THREE.DoubleSide }); return material; }; this.reset = () => { if(material){ material.dispose(); material = null; } }; }; return RailingMaterialGame; })();