@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
72 lines (62 loc) • 1.34 kB
JavaScript
import { DrawMode } from "../../DrawMode.js";
export class SGCacheKey {
/**
* ID of geometry
* @type {number}
*/
geometry = -1;
/**
* ID of material
* @type {number}
*/
material = -1;
/**
*
* @type {DrawMode}
*/
mode = DrawMode.Triangles;
/**
*
* @type {number}
*/
flags = 0;
hash() {
return this.geometry ^ this.material;
}
/**
*
* @param {SGCacheKey} other
* @returns {boolean}
*/
equals(other) {
return this.geometry === other.geometry
&& this.material === other.material
&& this.mode === other.mode
&& this.flags === other.flags;
}
/**
*
* @param {SGCacheKey} other
*/
copy(other) {
this.geometry = other.geometry;
this.material = other.material;
this.mode = other.mode;
this.flags = other.flags;
}
clone() {
const r = new SGCacheKey();
r.copy(this);
return r;
}
/**
*
* @param {ShadedGeometry} sg
*/
fromSG(sg) {
this.geometry = sg.geometry.id;
this.material = sg.material.id;
this.mode = sg.mode;
this.flags = sg.flags;
}
}