@openhps/core
Version:
Open Hybrid Positioning System - Core component
67 lines (62 loc) • 1.64 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _ChainMap = _interopRequireDefault(require("./ChainMap.js"));
var _RenderList = _interopRequireDefault(require("./RenderList.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const _chainKeys = [];
/**
* This renderer module manages the render lists which are unique
* per scene and camera combination.
*
* @private
*/
class RenderLists {
/**
* Constructs a render lists management component.
*
* @param {Lighting} lighting - The lighting management component.
*/
constructor(lighting) {
/**
* The lighting management component.
*
* @type {Lighting}
*/
this.lighting = lighting;
/**
* The internal chain map which holds the render lists.
*
* @type {ChainMap}
*/
this.lists = new _ChainMap.default();
}
/**
* Returns a render list for the given scene and camera.
*
* @param {Scene} scene - The scene.
* @param {Camera} camera - The camera.
* @return {RenderList} The render list.
*/
get(scene, camera) {
const lists = this.lists;
_chainKeys[0] = scene;
_chainKeys[1] = camera;
let list = lists.get(_chainKeys);
if (list === undefined) {
list = new _RenderList.default(this.lighting, scene, camera);
lists.set(_chainKeys, list);
}
_chainKeys.length = 0;
return list;
}
/**
* Frees all internal resources.
*/
dispose() {
this.lists = new _ChainMap.default();
}
}
var _default = exports.default = RenderLists;