-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a7d6c6d
commit 57a736f
Showing
49 changed files
with
2,427 additions
and
1,278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
docs/_downloads/b7c1bbbd7762fe07d8b2749c6aaa3c53/patch_invalid_partitioning.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import argparse | ||
import json | ||
import sys | ||
from pathlib import Path | ||
|
||
|
||
def patch_gltf(gltf_path): | ||
extension_to_patch = "OPF_mesh_primitive_partitioning" | ||
bad_key = "nodeCoordinates" | ||
good_key = "nodeIndices" | ||
gltf_obj = json.load(open(gltf_path, "r")) | ||
|
||
for mesh in gltf_obj.get("meshes", []): | ||
for primitive in mesh.get("primitives", []): | ||
ext_obj = primitive.get("extensions", {}).get(extension_to_patch) | ||
if ext_obj is None: | ||
continue | ||
if bad_key in ext_obj: | ||
ext_obj[good_key] = ext_obj.get(bad_key) | ||
del ext_obj[bad_key] | ||
|
||
return gltf_obj | ||
|
||
|
||
def gltf_point_cloud_uris(opf_obj): | ||
for item in opf_obj.get("items", []): | ||
if item["type"] in ["calibration", "point_cloud"]: | ||
for resource in item.get("resources", []): | ||
if resource["format"] != "model/gltf+json": | ||
continue | ||
yield resource["uri"] | ||
|
||
|
||
parser = argparse.ArgumentParser( | ||
description="Patch OPF project with invalid OPF_mesh_primitive_partitioning extension" | ||
) | ||
parser.add_argument("opf_path", type=str, help="path to the opf project to patch") | ||
args = parser.parse_args() | ||
|
||
opf_obj = json.load(open(args.opf_path, "r")) | ||
for gltf_uri in gltf_point_cloud_uris(opf_obj): | ||
gltf_path = Path(args.opf_path).parent / gltf_uri | ||
gltf_obj = patch_gltf(gltf_path) | ||
json.dump(gltf_obj, open(gltf_path, "w"), indent=2) |
Oops, something went wrong.