Skip to content

Commit

Permalink
Merge branch 'mostieri/dvs_module' of https://github.com/ansys/pyensight
Browse files Browse the repository at this point in the history
 into mostieri/dvs_module
  • Loading branch information
mariostieriansys committed Dec 9, 2024
2 parents 5917387 + 5c6a6de commit 236392d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 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
2 changes: 1 addition & 1 deletion tests/example_tests/test_glb_usd.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
def test_glb_usd():
# Get the example files
base_uri = "https://s3.amazonaws.com/www3.ensight.com/PyEnSight/ExampleData"
filenames = ["fluent_elbow.glb", "rwing_bsl_1.glb", "rwing_bsl_2.glb"]
filenames = ["fluent_elbow.glb", "rwing_bsl_1.glb", "rwing_bsl_2.glb", "ens_car_exts.glb"]
with tempfile.TemporaryDirectory() as tmpdirname:
for filename in filenames:
outpath = os.path.join(tmpdirname, filename)
Expand Down

0 comments on commit 236392d

Please sign in to comment.