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

use fos utility function for parsing scene json #4237

Merged
merged 2 commits into from
Apr 6, 2024
Merged
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
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)
Loading