Home Reference Source

cables_dev/cables/src/libs/cgl/wireframes/cgl_wireframerect.js

  1. export { WireframeRect };
  2.  
  3. class WireframeRect
  4. {
  5. constructor(_cgl)
  6. {
  7. this.cgl = _cgl;
  8. this.geom = new CGL.Geometry("marker");
  9.  
  10. const fr = -1.0;
  11. const to = 1.0;
  12.  
  13. this.geom.setPointVertices(
  14. [
  15. fr, fr, 0,
  16. to, fr, 0,
  17.  
  18. to, fr, 0,
  19. to, to, 0,
  20.  
  21. to, to, 0,
  22. fr, to, 0,
  23.  
  24. fr, to, 0,
  25. fr, fr, 0,
  26. ]
  27. );
  28.  
  29. this.mesh = new CGL.Mesh(this.cgl, this.geom, this.cgl.gl.LINES);
  30. this.mesh.setGeom(this.geom);
  31.  
  32. this.colorShader = new CGL.UniColorShader(this.cgl);
  33. this.colorShader.setColor([0, 1, 1, 1]);
  34.  
  35. this._vScale = vec3.create();
  36. }
  37.  
  38. render(_scaleX, _scaleY, _scaleZ)
  39. {
  40. this.cgl.pushModelMatrix();
  41. this.cgl.pushShader(this.colorShader.shader);
  42. this.cgl.pushDepthTest(false);
  43.  
  44. vec3.set(this._vScale, _scaleX || 1, _scaleY || _scaleX || 1, _scaleZ || _scaleX || 1);
  45. mat4.scale(this.cgl.mvMatrix, this.cgl.mvMatrix, this._vScale);
  46.  
  47. this.mesh.render(this.cgl.getShader());
  48.  
  49. this.cgl.popDepthTest();
  50. this.cgl.popShader();
  51. this.cgl.popModelMatrix();
  52. }
  53. }