Skip to content

Commit

Permalink
Add mesh class.
Browse files Browse the repository at this point in the history
  • Loading branch information
francisengelmann committed Jul 12, 2021
1 parent 2bd45c9 commit f68abcb
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions pyviz3d/mesh.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""Polygon mesh."""
from shutil import copyfile
import os

class Mesh:
"""Polygon mesh defined by .obj file and some solid color."""

def __init__(self, filename, translation=None, rotation=None, scale=None, color=None, visible=True):
self.filename = filename
self.translation = translation
self.rotation = rotation
self.scale = scale
self.color = color
self.visible = visible

def get_properties(self, filename):
"""
:return: A dict conteining object properties. They are written into json and interpreted by javascript.
"""
json_dict = {
'type': 'obj',
'filename': os.path.split(self.filename)[-1],
'translation': self.translation,
'rotation': self.rotation,
'scale': self.scale,
'color': self.color,
'visible': self.visible,
}
return json_dict

def write_binary(self, path):
obj_file = os.path.split(self.filename)[-1]
destination_dir = os.path.dirname(path)
destination_path = os.path.join(destination_dir, obj_file)
if not os.path.exists(destination_path):
copyfile(self.filename, destination_path)

0 comments on commit f68abcb

Please sign in to comment.