jupyter-widgets / pythreejs

A Jupyter - Three.js bridge
https://pythreejs.readthedocs.io
Other
934 stars 185 forks source link

Sprite not visible with orthographic camera #393

Closed nvaytet closed 1 year ago

nvaytet commented 1 year ago

Adding a sprite to a scene with a PerspectiveCamera works as expected:

import pythreejs as p3

m = p3.SpriteMaterial(color='red')
s = p3.Sprite(material=m, position=(0, 0, 0))

width = 800
height = 500
camera = p3.PerspectiveCamera(position=[0.0, 0, 2], aspect=width / height)
# camera = p3.OrthographicCamera(-2, 2, -2, 2, near=-2, far=1000)
scene = p3.Scene(children=[camera, s], background="#f0f0f0")
controls = p3.OrbitControls(controlling=camera)
renderer = p3.Renderer(camera=camera,
                       scene=scene,
                       controls=[controls],
                       width=width,
                       height=height)

renderer

A red square is visible in the scene.

However, if I change the camera to the OrthographicCamera, no sprite is visible. After looking around the web, I tried playing with the scale parameter of the Sprite, making larger or smaller, but to no avail.

Thanks for any help.

nvaytet commented 1 year ago

Scratch that, the issue was that the top and bottom were flipped in the orthographic camera. Should have been camera = p3.OrthographicCamera(-2, 2, 2, -2, near=-2, far=1000)