pythreejs icon indicating copy to clipboard operation
pythreejs copied to clipboard

how to map texture to a box mesh?

Open duchaoyu opened this issue 5 years ago • 4 comments

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...

duchaoyu avatar Mar 19 '20 20:03 duchaoyu

"Loading widget...".

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

vidartf avatar Mar 20 '20 13:03 vidartf

"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

duchaoyu avatar Mar 20 '20 14:03 duchaoyu

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

vidartf avatar Mar 23 '20 10:03 vidartf

Annotation 2020-03-26 133108

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

duchaoyu avatar Mar 26 '20 12:03 duchaoyu