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

Change glTF vector resolution; use shorts when applicable #109

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions glue_ar/common/scatter_gltf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def add_vectors_gltf(builder: GLTFBuilder,
tip_height: float,
shaft_radius: float,
tip_radius: float,
tip_resolution: int = 10,
shaft_resolution: int = 10,
tip_resolution: int = 6,
shaft_resolution: int = 6,
materials: Optional[dict[int, int]] = None,
mask: Optional[ndarray] = None):

Expand All @@ -54,9 +54,10 @@ def add_vectors_gltf(builder: GLTFBuilder,
max_index = max(idx for tri in triangles for idx in tri)
add_triangles_to_bytearray(barr, triangles)

use_short = max_index <= SHORT_MAX
if layer_state.vector_arrowhead:
tip_triangles = cone_triangles(theta_resolution=tip_resolution, start_index=max_index + 1)
add_triangles_to_bytearray(barr, tip_triangles)
add_triangles_to_bytearray(barr, tip_triangles, short=use_short)
max_index = max(idx for tri in tip_triangles for idx in tri)
triangle_count += len(tip_triangles)

Expand All @@ -69,9 +70,10 @@ def add_vectors_gltf(builder: GLTFBuilder,
byte_offset=0,
target=BufferTarget.ELEMENT_ARRAY_BUFFER,
)
component_type = ComponentType.UNSIGNED_SHORT if use_short else ComponentType.UNSIGNED_INT
builder.add_accessor(
buffer_view=builder.buffer_view_count-1,
component_type=ComponentType.UNSIGNED_INT,
component_type=component_type,
count=triangle_count*3,
type=AccessorType.SCALAR,
mins=[0],
Expand Down
4 changes: 2 additions & 2 deletions glue_ar/common/scatter_usd.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def add_vectors_usd(builder: USDBuilder,
tip_height: float,
shaft_radius: float,
tip_radius: float,
tip_resolution: int = 10,
shaft_resolution: int = 10,
tip_resolution: int = 6,
shaft_resolution: int = 6,
colors: Optional[List[Tuple[int, int, int]]] = None,
mask: Optional[ndarray] = None):

Expand Down
Loading