HollowBond/Public/ecma/Materials/Game/StairMaterialGame.ecma.js

47 lines
1.3 KiB
JavaScript

"use strict";
const StairMaterialGame = (function(){
const StairMaterialGame = function(hollow_bond){
let material = null;
this.get = () => {
if(material) return material;
const theme_def = (hollow_bond.theme && hollow_bond.theme.stair) ? hollow_bond.theme.stair : {
vertex: `
varying vec3 vNormal;
void main(){
vNormal = normalize(normalMatrix * normal);
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
`,
fragment: `
varying vec3 vNormal;
void main(){
gl_FragColor = vec4(vec3(0.25) + abs(vNormal.y) * 0.1, 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 StairMaterialGame;
})();