You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The error handling for missing UV coordinates could be improved. Currently it just continues the loop on error, which could lead to incomplete or malformed meshes. Consider aggregating errors and handling them appropriately.
if(!uvCoords){errors.push(`Missing UV coordinates for face ${currentFace||'unknown'}`)continue}
The face direction lookup in the nested loops could be optimized. The current implementation searches through the faceToDirection mapping for each face iteration, which is inefficient.
The schema validation error handling could be more robust. Currently it logs errors but then throws the original error, losing the formatted error messages. Consider creating a custom error type with the formatted messages.
The error handling for UV coordinates should fail fast and throw meaningful errors instead of silently continuing, as invalid UVs can cause rendering artifacts.
if (!uvCoords) {
- errors.push(`Missing UV coordinates for face ${currentFace || 'unknown'}`)- continue+ throw new Error(`Missing UV coordinates for face ${currentFace || 'unknown'} in cube at origin [${cube.origin.join(', ')}]`);
}
Apply this suggestion
Suggestion importance[1-10]: 8
__
Why: The suggestion correctly identifies that silently continuing with invalid UV coordinates can lead to rendering issues. Throwing an error immediately with detailed cube information would help catch and debug UV mapping problems earlier.
Medium
General
Optimize face direction lookup performance
The face direction lookup in the loop is inefficient and error-prone. Extract the face direction mapping logic outside the loop and use a more direct mapping approach.
Why: The current implementation uses inefficient nested loops and complex object operations for face direction lookup. The suggested Map-based approach would significantly improve performance and code readability.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Type
Enhancement, Tests
Description
Added support for per-face UV mapping in Bedrock entities.
Introduced validation for entity data using Zod schemas.
Improved error handling for missing or invalid UV coordinates.
Added a new test file for validating entity schemas.
Changes walkthrough 📝
EntityMesh.ts
Add per-face UV mapping and error handlingrenderer/viewer/lib/entity/EntityMesh.ts
CubeFaces.getFaceUVfunction to handle UV retrieval.testEntities.ts
Add Zod-based entity schema validationrenderer/viewer/lib/entity/testEntities.ts
entities.jsonagainst defined schemas.