Skip to content
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

Better error message when creating a VertexState with invalid arrayStride #818

Open
jespertheend opened this issue Nov 21, 2023 · 0 comments
Labels
effort: Moderate Will take a good amount of time and experience with the codebase, but feasible.
Milestone

Comments

@jespertheend
Copy link
Collaborator

I just created the following VertexState:

new VertexState({
	buffers: [
		{
			stepMode: "vertex",
			arrayStride: 12,
			attributes: [
				{
					attributeType: Mesh.AttributeType.POSITION,
					componentCount: 3,
					format: Mesh.AttributeFormat.FLOAT32,
					unsigned: false,
				},
			],
		},
		{
			stepMode: "vertex",
			arrayStride: 12,
			attributes: [
				{
					attributeType: Mesh.AttributeType.COLOR,
					componentCount: 4,
					format: Mesh.AttributeFormat.FLOAT32,
					unsigned: false,
				},
			],
		},
	],
});

The second buffer has an array stride of 12, but a componentCount of 4. When applying it to an existing mesh using Mesh.setVertexState(), it threw the following error:

RangeError: Offset is outside the bounds of the DataView

This isn't very helpful, it should make it clear that the provided component count and format doesn't fit in the provided arrayStride.

@jespertheend jespertheend added the effort: Moderate Will take a good amount of time and experience with the codebase, but feasible. label Nov 21, 2023
@jespertheend jespertheend added this to the backlog milestone Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort: Moderate Will take a good amount of time and experience with the codebase, but feasible.
Projects
None yet
Development

No branches or pull requests

1 participant