jupyter-widgets / pythreejs

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

how to map texture to a box mesh? #316

Open duchaoyu opened 4 years ago

duchaoyu commented 4 years ago

I'm trying to map texture to a box mesh in jupyter lab, however I failed. It doesn't show the render but "Loading widget...". If I don't map the texture, and just gives the box a color, then it can be rendered. I'm not sure what's the problem and how to add texture to a mesh object properly. Thanks for all your help in advance!

Here's my code:

texture_path = 'C:\\Users\\duch\\Desktop\\jupyter_vis\\stl\\t_0007_0.jpg'
textureloader = ImageTexture(texture_path)

panel = Mesh(
    BoxBufferGeometry(585, 585, 20),
    MeshStandardMaterial(map=textureloader),
    position=[fresnel_frame.point[0] + (585/2), fresnel_frame.point[1] + (585/2) -301, fresnel_frame.point[2]-10-685]
)

camera0 = PerspectiveCamera(fov = 50, aspect=1, near = 0.1, far=2000)
key_light = DirectionalLight(position=[0, 0, 100])
ambient_light = AmbientLight()

scene0 = Scene(children=[micpts, lines, panel, ambient_light, key_light, camera0])

camera0.position= [0,0,1000]
camera0.lookAt([micpts])
camera0.up = [0,1,0]

controller0 = OrbitControls(controlling=camera0)
renderer0 = Renderer(camera=camera0, scene=scene0, controls=[controller0], width=view_width, height=view_height)

renderer0

Loading widget...

vidartf commented 4 years ago

"Loading widget...".

This typically means something has gone wrong with an extension install somewhere. What does jupyter labextension list show?

duchaoyu commented 4 years ago

"Loading widget...".

This typically means something has gone wrong with an extension install somewhere. What does jupyter labextension list show?

JupyterLab v1.2.6 Known labextensions: app dir: C:\Users\duch\Anaconda3\envs\ddad\share\jupyter\lab @jupyter-widgets/jupyterlab-manager v1.1.0 enabled ok jupyter-threejs v2.1.1 enabled ok jupyterlab-datawidgets v6.2.0 enabled ok k3d v2.7.2 enabled ok

vidartf commented 4 years ago

Are there any errors in the browser console when running this (typically available via Ctrl + Shift + J, or alternatively F12)?

duchaoyu commented 4 years ago

Annotation 2020-03-26 133108

Hi, vidartf, thanks for your reply. I'm still not very sure whether there's something wrong....