Activate the python environment conda activate pvtrace-env
Copy the modified hello_world.py script to your folder (see script below)
Make sure the zmq_url you found in step 3 is the same as in line 32 of the script
Run the script python hello_world.py
The visualiser should now open a browser window and work as expected.
# hello_world.py
import time
import sys
import functools
import numpy as np
from pvtrace import *
world = Node(
name="world (air)",
geometry=Sphere(
radius=10.0,
material=Material(refractive_index=1.0),
)
)
sphere = Node(
name="sphere (glass)",
geometry=Sphere(
radius=1.0,
material=Material(refractive_index=1.5),
),
parent=world
)
sphere.location = (0, 0, 2)
light = Node(
name="Light (555nm)",
light=Light(direction=functools.partial(cone, np.pi/8)),
parent=world
)
# Change the zmq_url in the line below to the URL of your server
renderer = MeshcatRenderer(zmq_url="tcp://127.0.0.1:6000", wireframe=True, open_browser=True)
scene = Scene(world)
renderer.render(scene)
for ray in scene.emit(100):
steps = photon_tracer.follow(scene, ray)
path, events = zip(*steps)
renderer.add_ray_path(path)
time.sleep(0.1)
# Wait for Ctrl-C to terminate the script; keep the window open
print("Ctrl-C to close")
while True:
try:
time.sleep(.3)
except KeyboardInterrupt:
sys.exit()
The Meshcat Visualiser no longer creates it's own ZMQ server on WIndows. This makes the hello_world.py script hang when run on Windows.
Workaround
conda activate pvtrace-env
meshcat-server
the terminal This will print the ZMQ url to the consoleconda activate pvtrace-env
hello_world.py
script to your folder (see script below)python hello_world.py