fireball/lib/renderers/webgl/WebGLObjects.js

53 lines
694 B
JavaScript
Raw Normal View History

2018-12-25 13:59:22 +00:00
/**
* @author mrdoob / http://mrdoob.com/
*/
function WebGLObjects( geometries, info ) {
var updateList = {};
function update( object ) {
var frame = info.render.frame;
var geometry = object.geometry;
var buffergeometry = geometries.get( object, geometry );
// Update once per frame
if ( updateList[ buffergeometry.id ] !== frame ) {
if ( geometry.isGeometry ) {
buffergeometry.updateFromObject( object );
}
geometries.update( buffergeometry );
updateList[ buffergeometry.id ] = frame;
}
return buffergeometry;
}
function dispose() {
updateList = {};
}
return {
update: update,
dispose: dispose
};
}
export { WebGLObjects };