TypeError: Object doesn't support property or method 'bufferSubData'.
swomack opened this issue · comments
I have a vertex attribute which is dynamic. In need to update parts of the data of that vertex attribute. gl.bufferSubData
is needed for me.
In Threejs, we can make a BufferAttribute
dynamic and update parts of the buffer using update range and offset.
While doing this i am getting this error message -
TypeError: Object doesn't support property or method 'bufferSubData'.
Here is the log -
TypeError: Object doesn't support property or method 'bufferSubData'
at updateBuffer (three.js:9720:5)
at update (three.js:9767:5)
at update (three.js:16955:5)
at update (three.js:17391:5)
at projectObject (three.js:22160:7)
at projectObject (three.js:22196:5)
at projectObject (three.js:22196:5)
at projectObject (three.js:22196:5)
at projectObject (three.js:22196:5)
at projectObject (three.js:22196:5)
Could this be related to the version of the ANGLE?
Fixed in develop/buffer-subdata
Hello Cristi,
I am getting error while using buffersubdata in this line -
RETURN_INVALID_REF_IF_JS_ERROR(JsGetArrayBufferStorage(arguments[4], &data, &dataLength));
Here is the log -
Failure in file d:\works\holojs\holojs\holojshost\webglprojections.cpp, line 817
Please let me know if you need any information from me.
Can you provide a minimum script repro? I'm not getting this error.
Hello Cristi
Sorry for the late. let me describe what i am doing -
First, i create a custom vertex attribute alphaValue
like this -
let alpha_array_length = volumeFaceGeometry.attributes.position.array.length / 3;
let __alpha_values = new Float32Array(alpha_array_length);
for (let i = 0; i < alpha_array_length; i++) {
__alpha_values[i] = 1.0;
}
volumeFaceGeometry.addAttribute('alphaValue', new THREE.BufferAttribute(__alpha_values, 1));
volumeFaceGeometry.attributes.alphaValue.dynamic = true;
console.log("Position attribute length: " + volumeFaceGeometry.attributes.position.array.length);
console.log("Alpha attribute length: " + volumeFaceGeometry.attributes.alphaValue.array.length);
For a test .step model, i get the following output from the two console logs (which is correct output) -
log: Position attribute length: 2814
log: Alpha attribute length: 938
This is how i update my custom vertex attribute alphaValue
-
// This is for testing, this range is valid for my test model
let startVertex = 0;
let endVertex = 500;
let alphaArray = volumeFaceGeometry.attributes.alphaValue.array;
// update the value in the array
for (let i = startVertex; i < endVertex; i++) {
alphaArray[i] = 0.5;
}
volumeFaceGeometry.attributes.alphaValue.needsUpdate = true;
volumeFaceGeometry.attributes.alphaValue.updateRange.offset = startVertex;
volumeFaceGeometry.attributes.alphaValue.updateRange.count = endVertex - startVertex;
// This we have to do because of a threejs bug
// At this point, the glBufferSubdata is called and the error is shown
renderer.render(scene, camera, dummyRenderTexture);
Please let me know if you need more info.
I merged in a fix for this.
Thank you! I am unable to test it right now. Previously i was loading a step model in my app. But now i cant see the model (its the same solution without any modification)! I only updated my Visual Studio 17 to a new update.
I will check more on this and get back to you shortly.
The bug is fixed. Now the buffersubdata
is working properly.
I will create a separate bug for "mesh is not rendering if i build with Visual Studio Community 2017 version 15.5.6".