Skip to content

Commit 5e34252

Browse files
committed
fix transparent args and disentangle font size with face (for resizing)
1 parent 672e2ad commit 5e34252

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/meshcat/commands.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ def __init__(self, text, geometry_or_object, material=None, path=[]):
4545
self.object = geometry_or_object
4646
else:
4747
if geometry_or_object is None:
48-
geometry_or_object = Plane()
48+
geometry_or_object = Plane(width=10, height=5)
4949
# if writing onto the scene, default material is transparent
5050
material = MeshPhongMaterial(map=self.text_texture,
51-
needsUpdate=True, opacity = 0.0)
51+
needsUpdate=True, transparent=True)
5252
if material is None:
5353
material = MeshPhongMaterial(map=self.text_texture,
54-
needsUpdate=True)
54+
needsUpdate=True)
5555
if isinstance(material, PointsMaterial):
5656
raise(ArgumentError(
5757
"Cannot write text onto points; please supply a mesh material"))

src/meshcat/geometry.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,12 @@ def lower(self, object_data):
221221
class MeshMaterial(Material):
222222

223223
def __init__(self, color=0xffffff, reflectivity=0.5, map=None,
224-
opacity = 1.0, **kwargs):
224+
transparent = False, **kwargs):
225225
super(MeshMaterial, self).__init__()
226226
self.color = color
227227
self.reflectivity = reflectivity
228228
self.map = map
229-
self.opacity = opacity
229+
self.transparent = transparent
230230
self.properties = kwargs
231231

232232
def lower(self, object_data):
@@ -235,7 +235,7 @@ def lower(self, object_data):
235235
u"type": self._type,
236236
u"color": self.color,
237237
u"reflectivity": self.reflectivity,
238-
u"opacity": self.opacity
238+
u"transparent": self.transparent
239239
}
240240
data.update(self.properties)
241241
if self.map is not None:
@@ -281,23 +281,24 @@ class CanvasImage(Image):
281281

282282
def __init__(self, alpha):
283283
super(CanvasImage, self).__init__()
284-
self.alpha = alpha
285284

286285
def lower(self, object_data):
287286
return {
288287
u"uuid": self.uuid,
289-
u"url": u'place_holder',
290-
u"alpha": self.alpha
291288
}
292289

293290

294291
class TextTexture(Texture):
295292

296-
def __init__(self, text, font='96px sans-serif', width=200, height=100,
293+
def __init__(self, text, font_size = 96, font_face='sans-serif',
294+
width=200, height=100,
297295
position=[10, 10],alpha=True):
298296
super(TextTexture, self).__init__()
299297
self.text = text
300-
self.font = font
298+
# font_size will be passed to the JS side as is; however if the text
299+
# width exceeds canvas width, font_size will be reduced.
300+
self.font_size = font_size
301+
self.font_face = font_face
301302
self.width = width
302303
self.height = height
303304
self.position = position
@@ -308,7 +309,8 @@ def lower(self, object_data):
308309
u"uuid": self.uuid,
309310
u"type": u"TextTexture",
310311
u"text": unicode(self.text),
311-
u"font": self.font,
312+
u"font_size": self.font_size,
313+
u"font_face": self.font_face,
312314
u"width": self.width,
313315
u"height": self.height,
314316
u"position": self.position,

0 commit comments

Comments
 (0)