@openhps/core
Version:
Open Hybrid Positioning System - Core component
94 lines (87 loc) • 2.66 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _BufferGeometry = require("../../core/BufferGeometry.js");
var _BufferAttribute = require("../../core/BufferAttribute.js");
var _Mesh = require("../../objects/Mesh.js");
var _OrthographicCamera = require("../../cameras/OrthographicCamera.js");
const _camera = /*@__PURE__*/new _OrthographicCamera.OrthographicCamera(-1, 1, 1, -1, 0, 1);
/**
* The purpose of this special geometry is to fill the entire viewport with a single triangle.
*
* Reference: {@link https://github.com/mrdoob/three.js/pull/21358}
*
* @private
* @augments BufferGeometry
*/
class QuadGeometry extends _BufferGeometry.BufferGeometry {
/**
* Constructs a new quad geometry.
*
* @param {boolean} [flipY=false] - Whether the uv coordinates should be flipped along the vertical axis or not.
*/
constructor(flipY = false) {
super();
const uv = flipY === false ? [0, -1, 0, 1, 2, 1] : [0, 2, 0, 0, 2, 0];
this.setAttribute('position', new _BufferAttribute.Float32BufferAttribute([-1, 3, 0, -1, -1, 0, 3, -1, 0], 3));
this.setAttribute('uv', new _BufferAttribute.Float32BufferAttribute(uv, 2));
}
}
const _geometry = /*@__PURE__*/new QuadGeometry();
/**
* This module is a helper for passes which need to render a full
* screen effect which is quite common in context of post processing.
*
* The intended usage is to reuse a single quad mesh for rendering
* subsequent passes by just reassigning the `material` reference.
*
* Note: This module can only be used with `WebGPURenderer`.
*
* @augments Mesh
*/
class QuadMesh extends _Mesh.Mesh {
/**
* Constructs a new quad mesh.
*
* @param {?Material} [material=null] - The material to render the quad mesh with.
*/
constructor(material = null) {
super(_geometry, material);
/**
* The camera to render the quad mesh with.
*
* @type {OrthographicCamera}
* @readonly
*/
this.camera = _camera;
/**
* This flag can be used for type testing.
*
* @type {boolean}
* @readonly
* @default true
*/
this.isQuadMesh = true;
}
/**
* Async version of `render()`.
*
* @async
* @param {Renderer} renderer - The renderer.
* @return {Promise} A Promise that resolves when the render has been finished.
*/
async renderAsync(renderer) {
return renderer.renderAsync(this, _camera);
}
/**
* Renders the quad mesh
*
* @param {Renderer} renderer - The renderer.
*/
render(renderer) {
renderer.render(this, _camera);
}
}
var _default = exports.default = QuadMesh;