Skip to content

Commit

Permalink
Fix buffer warnings (#2999)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibgreen authored and jianhuang01 committed Apr 18, 2019
1 parent 13bf96d commit ec7fe2b
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions modules/core/src/lib/base-attribute.js
Expand Up @@ -62,18 +62,26 @@ export default class BaseAttribute {
this.externalBuffer = null;
this.value = value;

// Create buffer if needed
if (!constant && this.gl) {
// Create buffer if needed
this.buffer =
this.buffer ||
new Buffer(
this.gl,
Object.assign({}, opts, {
id: this.id,
target: this.target,
accessor: {type: this.type}
})
);
// Move accessor fields to accessor object
const props = {
...opts,
id: this.id,
target: this.target,
accessor: {
type: this.type
}
};
if (Number.isFinite(props.divisor)) {
props.accessor.divisor = props.divisor;
}
delete props.divisor;
if (Number.isFinite(props.size)) {
props.accessor.size = props.size;
}
delete props.size;
this.buffer = this.buffer || new Buffer(this.gl, props);
this.buffer.setData({data: value});
this.type = this.buffer.accessor.type;
}
Expand Down

0 comments on commit ec7fe2b

Please sign in to comment.