Skip to content

Commit

Permalink
Merge fddb95d into 7e7ea78
Browse files Browse the repository at this point in the history
  • Loading branch information
tsherif committed Apr 4, 2019
2 parents 7e7ea78 + fddb95d commit f570833
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
18 changes: 12 additions & 6 deletions modules/core/src/core/model-utils.js
Expand Up @@ -16,14 +16,20 @@ export function getBuffersFromGeometry(gl, geometry, options) {
const buffers = {};

for (const name in geometry.attributes) {
const typedArray = geometry.attributes[name].value;
// Create accessor by copying the attribute and removing `value``
const attribute = {...geometry.attributes[name]};
delete attribute.value;
const attribute = geometry.attributes[name];
const remappedName = mapAttributeName(name, options);
buffers[remappedName] = [new Buffer(gl, typedArray), attribute];

inferAttributeAccessor(name, attribute);
if (attribute.constant) {
buffers[remappedName] = attribute.value;
} else {
const typedArray = attribute.value;
// Create accessor by copying the attribute and removing `value``
const accessor = {...attribute};
delete accessor.value;
buffers[remappedName] = [new Buffer(gl, typedArray), accessor];

inferAttributeAccessor(name, accessor);
}
}

if (geometry.indices) {
Expand Down
6 changes: 4 additions & 2 deletions modules/core/src/core/model.js
@@ -1,5 +1,5 @@
import GL from '@luma.gl/constants';
import {Query, TransformFeedback} from '@luma.gl/webgl';
import {Query, TransformFeedback, Buffer} from '@luma.gl/webgl';
import {getBuffersFromGeometry} from './model-utils';
import BaseModel from './base-model';
import {log, isObjectEmpty, uid, assert} from '../utils';
Expand Down Expand Up @@ -183,7 +183,9 @@ export default class Model extends BaseModel {
for (const name in this.geometryBuffers) {
// Buffer is raw value (for indices) or first element of [buffer, accessor] pair
const buffer = this.geometryBuffers[name][0] || this.geometryBuffers[name];
buffer.delete();
if (buffer instanceof Buffer) {
buffer.delete();
}
}
}

Expand Down

0 comments on commit f570833

Please sign in to comment.