Skip to content

Commit

Permalink
Update webgl.esm-bundler.js
Browse files Browse the repository at this point in the history
  • Loading branch information
epreston committed Dec 1, 2023
1 parent 40b46ff commit 7afb4e2
Showing 1 changed file with 21 additions and 24 deletions.
45 changes: 21 additions & 24 deletions packages/webgl/dist/webgl.esm-bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,29 @@ class WebGLAttributes {
}
}

class BindingState {
constructor(maxVertexAttributes, vao) {
this.newAttributes = [];
this.enabledAttributes = [];
this.attributeDivisors = [];
for (let i = 0; i < maxVertexAttributes; i++) {
this.newAttributes[i] = 0;
this.enabledAttributes[i] = 0;
this.attributeDivisors[i] = 0;
}
this.geometry = null;
this.program = null;
this.wireframe = false;
this.object = vao;
this.attributes = {};
this.attributesNum = 0;
this.index = null;
}
}
function WebGLBindingStates(gl, extensions, attributes, capabilities) {
const maxVertexAttributes = gl.getParameter(gl.MAX_VERTEX_ATTRIBS);
const bindingStates = {};
const defaultState = createBindingState(null);
const defaultState = new BindingState(maxVertexAttributes, null);
let currentState = defaultState;
let forceUpdate = false;
function setup(object, material, program, geometry, index) {
Expand Down Expand Up @@ -192,33 +211,11 @@ function WebGLBindingStates(gl, extensions, attributes, capabilities) {
}
let state = stateMap[wireframe];
if (state === void 0) {
state = createBindingState(createVertexArrayObject());
state = new BindingState(maxVertexAttributes, createVertexArrayObject());
stateMap[wireframe] = state;
}
return state;
}
function createBindingState(vao) {
const newAttributes = [];
const enabledAttributes = [];
const attributeDivisors = [];
for (let i = 0; i < maxVertexAttributes; i++) {
newAttributes[i] = 0;
enabledAttributes[i] = 0;
attributeDivisors[i] = 0;
}
return {
// for backward compatibility on non-VAO support browser
geometry: null,
program: null,
wireframe: false,
newAttributes,
enabledAttributes,
attributeDivisors,
object: vao,
attributes: {},
index: null
};
}
function needsUpdate(object, geometry, program, index) {
const cachedAttributes = currentState.attributes;
const geometryAttributes = geometry.attributes;
Expand Down

0 comments on commit 7afb4e2

Please sign in to comment.