Skip to content

Instantly share code, notes, and snippets.

@luruke
Last active October 25, 2019 12:23
Show Gist options
  • Save luruke/5f0ca56a8a749784215320e4c1133b04 to your computer and use it in GitHub Desktop.
Save luruke/5f0ca56a8a749784215320e4c1133b04 to your computer and use it in GitHub Desktop.
import {
Mesh,
PlaneBufferGeometry,
RawShaderMaterial,
} from 'three';
import dom3D from '../dom3D';
import scene from '../scene';
import textures from 'gl/utils/textures';
const geometry = new PlaneBufferGeometry(1, 1, 1, 1);
const material = new RawShaderMaterial({
transparent: true,
fragmentShader: require('./button.frag'),
vertexShader: require('./button.vert'),
});
export default class extends dom3D {
init() {
super.init();
this.geometry = geometry;
this.material = material.clone();
this.material.uniforms = {
uTime: { value: 0 },
uProgress: { value: 0 },
uWind: { value: textures.fromAsset('wind') },
uShow: { value: 0 },
uClipping: { value: 1.0 }
};
this.mesh = new Mesh(this.geometry, this.material);
this.add(this.mesh);
scene.add(this);
// Handle hovers...
}
onRaf({ delta }) {
super.onRaf();
this.material.uniforms.uTime.value += delta * 0.1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment