Skip to content

Commit

Permalink
GLB timeline and material fixes (#491)
Browse files Browse the repository at this point in the history
Co-authored-by: David J. Bremer <[email protected]>
  • Loading branch information
randallfrank and david-bremer authored Dec 6, 2024
1 parent 90d1e89 commit 9034674
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/ansys/pyensight/core/utils/omniverse_glb_server.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import io
import json
import logging
import os
import sys
Expand Down Expand Up @@ -108,6 +109,8 @@ def _map_material(self, glb_materialid: int, part_pb: Any) -> None:
part_pb.ambient = 1.0
part_pb.diffuse = 1.0
part_pb.specular_intensity = 1.0
if "ANSYS_material_details" in mat.extensions:
part_pb.material_name = json.dumps(mat.extensions["ANSYS_material_details"])
# if the material maps to a variable, set the variable id for coloring
glb_varid = self._find_variable_from_glb_mat(glb_materialid)
if glb_varid:
Expand Down Expand Up @@ -662,8 +665,7 @@ def _build_scene_timeline(self, scene_idx: int, input_timeline: List[float]) ->
try:
t0 = self._gltf.scenes[scene_idx].extensions["ANSYS_scene_timevalue"]["timevalue"]
idx = scene_idx + 1
if idx >= num_scenes:
idx = scene_idx
if idx < num_scenes:
t1 = self._gltf.scenes[idx].extensions["ANSYS_scene_timevalue"]["timevalue"]
else:
t1 = t0
Expand All @@ -680,10 +682,13 @@ def _build_scene_timeline(self, scene_idx: int, input_timeline: List[float]) ->
if timeline[1] - timeline[0] <= 0.0:
timeline = [0.0, float(num_scenes - 1)]
# carve time into the input timeline.
delta = (timeline[1] - timeline[0]) / float(num_scenes)
delta = (timeline[1] - timeline[0]) / float(num_scenes - 1)
output: List[float] = []
output.append(float(scene_idx) * delta + timeline[0])
output.append(output[0] + delta)
if scene_idx < num_scenes - 1:
output.append(output[0] + delta)
else:
output.append(output[0])
return output

@staticmethod
Expand Down

0 comments on commit 9034674

Please sign in to comment.