@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
63 lines (47 loc) • 1.13 kB
JavaScript
import { BvhClient } from "../../../../core/bvh2/bvh3/BvhClient.js";
export class LightRenderMetadata {
/**
*
* @param {AbstractLight} light
*/
constructor(light) {
/**
*
* @type {AbstractLight}
*/
this.light = light;
/**
*
* @type {number}
*/
this.address = 0;
this.bvh_leaf = new BvhClient();
}
/**
*
* @param {LightRenderMetadata} other
* @returns {number}
*/
compare(other) {
return this.light.compare(other.light);
}
update() {
const leaf = this.bvh_leaf;
this.light.getAABB(leaf.bounds);
leaf.write_bounds();
}
/**
*
* @param {BVH} bvh
*/
link(bvh) {
this.bvh_leaf.link(bvh, this.light.id);
this.update();
this.light.onDimensionChanged(this.update, this);
}
unlink() {
this.light.offDimensionChanged(this.update, this);
// disconnect from bvh
this.bvh_leaf.unlink();
}
}