Skip to content

Commit

Permalink
skip_materials now works for obj/ply/glb
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedh committed Dec 14, 2023
1 parent 00e63e3 commit e1b0ad8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion tests/test_ply.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def test_skip_texturefile(self):
m_tex = g.get_mesh("fuze.ply")
m_tex_size = m_tex.visual.material.image.size

m_notex = g.get_mesh("fuze.ply", skip_texture=True)
m_notex = g.get_mesh("fuze.ply", skip_materials=True)
m_notex_size = m_notex.visual.material.image.size

assert m_tex_size != m_notex_size
Expand Down
28 changes: 18 additions & 10 deletions trimesh/exchange/ply.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from .. import grouping, resources, util, visual
from ..constants import log
from ..geometry import triangulate_quads
from ..resolvers import Resolver
from ..typed import Optional

# from ply specification, and additional dtypes found in the wild
_dtypes = {
Expand Down Expand Up @@ -65,10 +67,10 @@ def _numpy_type_to_ply_type(_numpy_type):

def load_ply(
file_obj,
resolver=None,
fix_texture=True,
prefer_color=None,
skip_texture=False,
resolver: Optional[Resolver] = None,
fix_texture: bool = True,
prefer_color: Optional[str] = None,
skip_materials: bool = False,
*args,
**kwargs,
):
Expand All @@ -79,15 +81,16 @@ def load_ply(
---------
file_obj : an open file- like object
Source data, ASCII or binary PLY
resolver : trimesh.visual.resolvers.Resolver
resolver
Object which can resolve assets
fix_texture : bool
fix_texture
If True, will re- index vertices and faces
so vertices with different UV coordinates
are disconnected.
skip_texture : bool
skip_materials
If True, will not load texture (if present).
prefer_color : None, 'vertex', or 'face'
prefer_color
None, 'vertex', or 'face'
Which kind of color to prefer if both defined
Returns
Expand All @@ -108,7 +111,7 @@ def load_ply(

# try to load the referenced image
image = None
if not skip_texture:
if not skip_materials:
try:
# soft dependency
import PIL.Image
Expand Down Expand Up @@ -227,7 +230,12 @@ def _assert_attributes_valid(attributes):
raise ValueError("PLY attributes must be of a single datatype")


def export_ply(mesh, encoding="binary", vertex_normal=None, include_attributes=True):
def export_ply(
mesh,
encoding="binary",
vertex_normal: Optional[bool] = None,
include_attributes: bool = True,
):
"""
Export a mesh in the PLY format.
Expand Down

0 comments on commit e1b0ad8

Please sign in to comment.