Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. /**
  2. * What do we need to do in the render function?
  3. */
  4. export default class MyRenderable implements EIGHT.Renderable {
  5. name: string;
  6. transparent: boolean;
  7. /**
  8. * facets are the uniform values specific to this Renderable.
  9. */
  10. private facets: { [name: string]: EIGHT.Facet } = {};
  11. constructor(private geometry: EIGHT.Geometry, private material: EIGHT.Material, contextManager: EIGHT.ContextManager) {
  12. }
  13. render(ambients: EIGHT.Facet[]): void {
  14.  
  15. this.material.use()
  16.  
  17. this.geometry.bind(this.material)
  18.  
  19. // This gets us the camera, light etc.
  20. const iL = ambients.length;
  21. for (let i = 0; i < iL; i++) {
  22. const facet = ambients[i]
  23. facet.setUniforms(this.material)
  24. }
  25.  
  26. // What are the local facets? Color, Model, ...
  27. // We need to set the model and normal matrix
  28. const keys = Object.keys(this.facets)
  29. const keysLength = keys.length
  30. for (let i = 0; i < keysLength; i++) {
  31. const key = keys[i]
  32. const facet = this.facets[key]
  33. facet.setUniforms(this.material)
  34. }
  35.  
  36. // This is the drawArrays or drawElements.
  37. this.geometry.draw(this.material)
  38.  
  39. //
  40. this.geometry.unbind(this.material)
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement