-
-
Notifications
You must be signed in to change notification settings - Fork 287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ModelMesh
support custom vertex element
and vertex buffer binding
#1588
ModelMesh
support custom vertex element
and vertex buffer binding
#1588
Conversation
tests/src/core/ModelMesh.test.ts
Outdated
|
||
// Test reset vertex elements if internal buffer is destroyed | ||
modelMesh.setVertexElements([ | ||
new VertexElement("POSITION", 0, VertexElementFormat.Vector3, 0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a enum refer to "POSITION", make it easy to use
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
* Buffer must be readable. | ||
* If the data you get is modified, must call `setData()` to update buffer to GPU. | ||
*/ | ||
get data(): Uint8Array { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will better to be writable, If user modify data in GPU and read back
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
User use setData()
to write data, data
will automatically sync
|
||
const vertexBufferInfos = this._vertexBufferInfos; | ||
const vertexBufferBindings = this._vertexBufferBindings; | ||
for (let i = 0, n = vertexBufferBindings.length; i < n; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused buffers are not destroyed.
// Repro code
modelMesh.setVertexBufferBinding(posBuffer, 12, 0);
modelMesh.setVertexBufferBinding(norBuffer, 12, 2);
modelMesh.setVertexBufferBinding(uvBuffer, 8, 3);
modelMesh.setNormals(null);
modelMesh.uploadData(false);
console.log(“buffers”, modelMesh._vertexBufferBindings);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VertexBufferBindings shouldn't clear( user-custom-set and even interleaved buffer), but vertexElements not remove normal vertexElement, this is a bug and has been fixed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
vertex element
and vertex buffer binding
vertex element
and vertex buffer binding
vertex element
and vertex buffer binding
vertex element
and vertex buffer binding
ModelMesh
support custom vertex element
and vertex buffer binding
* dev/1.1: Support ktx2 loader (galacean#1625) feat: add texture plugin to support ktx loader (galacean#1640) Fix blend shape bug due to buffer index errors (galacean#1632) Model Mesh supports two-way data synchronization (galacean#1588)
Please check if the PR fulfills these requirements
Featutres:
Additional supplement:
This is a function implementation for reading Mesh low-level data, considering the most complex vertex structure (interleaved and normalized), maybe the physical MeshCollider needs it!