Skip to content

Commit

Permalink
use fos utility function for parsing scene json (voxel51#4237)
Browse files Browse the repository at this point in the history
* use fos.read_json instead

* use fos.write_json too
  • Loading branch information
sashankaryal authored Apr 6, 2024
1 parent 4277d83 commit 5f271ca
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions fiftyone/core/threed/scene_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

from pydantic.dataclasses import dataclass

import fiftyone.core.storage as fos

from .camera import PerspectiveCamera
from .lights import Light
from .mesh import FbxMesh, GltfMesh, ObjMesh, PlyMesh, StlMesh
Expand Down Expand Up @@ -200,8 +202,7 @@ def write(self, fo3d_path: str, resolve_relative_paths=False):
fo3d_path_dir, node.ply_path
)

with open(fo3d_path, "w") as f:
json.dump(validated_scene.as_dict(), f, indent=4)
fos.write_json(validated_scene.as_dict(), fo3d_path, pretty_print=True)

def traverse(self, include_self=False):
"""Traverse the scene graph.
Expand Down Expand Up @@ -334,7 +335,6 @@ def from_fo3d(path: str):
if not path.endswith(".fo3d"):
raise ValueError("Scene must be loaded from a .fo3d file")

with open(path, "r") as f:
dict_data = json.load(f)
dict_data = fos.read_json(path)

return Scene._from_fo3d_dict(dict_data)

0 comments on commit 5f271ca

Please sign in to comment.