物管理前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.5 KiB

  1. (function () {
  2. class Pass {
  3. constructor() {
  4. // if set to true, the pass is processed by the composer
  5. this.enabled = true; // if set to true, the pass indicates to swap read and write buffer after rendering
  6. this.needsSwap = true; // if set to true, the pass clears its buffer before rendering
  7. this.clear = false; // if set to true, the result of the pass is rendered to screen. This is set automatically by EffectComposer.
  8. this.renderToScreen = false;
  9. }
  10. setSize() {}
  11. render() {
  12. console.error("THREE.Pass: .render() must be implemented in derived pass.");
  13. }
  14. } // Helper for passes that need to fill the viewport with a single quad.
  15. const _camera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1); // https://github.com/mrdoob/three.js/pull/21358
  16. const _geometry = new THREE.BufferGeometry();
  17. _geometry.setAttribute(
  18. "position",
  19. new THREE.Float32BufferAttribute([-1, 3, 0, -1, -1, 0, 3, -1, 0], 3)
  20. );
  21. _geometry.setAttribute("uv", new THREE.Float32BufferAttribute([0, 2, 0, 0, 2, 0], 2));
  22. class FullScreenQuad {
  23. constructor(material) {
  24. this._mesh = new THREE.Mesh(_geometry, material);
  25. }
  26. dispose() {
  27. this._mesh.geometry.dispose();
  28. }
  29. render(renderer) {
  30. renderer.render(this._mesh, _camera);
  31. }
  32. get material() {
  33. return this._mesh.material;
  34. }
  35. set material(value) {
  36. this._mesh.material = value;
  37. }
  38. }
  39. THREE.FullScreenQuad = FullScreenQuad;
  40. THREE.Pass = Pass;
  41. })();