Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * What do we need to do in the render function?
- */
- export default class MyRenderable implements EIGHT.Renderable {
- name: string;
- transparent: boolean;
- /**
- * facets are the uniform values specific to this Renderable.
- */
- private facets: { [name: string]: EIGHT.Facet } = {};
- constructor(private geometry: EIGHT.Geometry, private material: EIGHT.Material, contextManager: EIGHT.ContextManager) {
- }
- render(ambients: EIGHT.Facet[]): void {
- this.material.use()
- this.geometry.bind(this.material)
- // This gets us the camera, light etc.
- const iL = ambients.length;
- for (let i = 0; i < iL; i++) {
- const facet = ambients[i]
- facet.setUniforms(this.material)
- }
- // What are the local facets? Color, Model, ...
- // We need to set the model and normal matrix
- const keys = Object.keys(this.facets)
- const keysLength = keys.length
- for (let i = 0; i < keysLength; i++) {
- const key = keys[i]
- const facet = this.facets[key]
- facet.setUniforms(this.material)
- }
- // This is the drawArrays or drawElements.
- this.geometry.draw(this.material)
- //
- this.geometry.unbind(this.material)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement