fireball/lib/renderers/webgl/WebGLProperties.js

53 lines
614 B
JavaScript
Raw Permalink Normal View History

2018-12-25 13:59:22 +00:00
/**
* @author fordacious / fordacious.github.io
*/
function WebGLProperties() {
var properties = new WeakMap();
function get( object ) {
var map = properties.get( object );
if ( map === undefined ) {
map = {};
properties.set( object, map );
}
return map;
}
function remove( object ) {
properties.delete( object );
}
function update( object, key, value ) {
properties.get( object )[ key ] = value;
}
function dispose() {
properties = new WeakMap();
}
return {
get: get,
remove: remove,
update: update,
dispose: dispose
};
}
export { WebGLProperties };