似乎是Taichi和taichi_three版本不兼容问题

import taichi as ti
import taichi_three as t3

ti.init(arch=ti.cuda)

# 加载 STL 模型
mesh = t3.read_stl('output_vessel.stl')
# 创建场景并将模型添加到场景中
scene = t3.Scene()
model = t3.Model(mesh)
scene.add_model(model)

# 创建渲染器并显示场景
renderer = t3.Renderer()
gui = ti.GUI()
while gui.running:
    renderer.render(scene)
    gui.set_image(renderer.img)
    gui.show()

报错如下:

D:\envs\taichi\python.exe C:/Users/86159/Desktop/export/simulate.py
[Taichi] version 1.4.1, llvm 15.0.1, commit e67c674e, win, python 3.8.13
[TaiGLSL] version 0.0.12
[Tai3D] version 0.0.9
[Tai3D] Documentation: https://t3.142857.red
[Tai3D] GitHub: https://github.com/taichi-dev/taichi_three
[Tai3D] Camera control hints: LMB to orbit, MMB to move, RMB to scale
Traceback (most recent call last):
  File "C:/Users/86159/Desktop/export/simulate.py", line 2, in <module>
    import taichi_three as t3
  File "D:\envs\taichi\lib\site-packages\taichi_three\__init__.py", line 39, in <module>
    @ti.python_scope
  File "D:\envs\taichi\lib\site-packages\taichi\__init__.py", line 89, in __getattr__
    raise AttributeError(f"module '{__name__}' has no attribute '{attr}'")
AttributeError: module 'taichi' has no attribute 'python_scope'

Process finished with exit code 1

之前看了一下代码,发现很多 API 已经变更了。 taichi-three 也两年没有维护了,代码可以参考一下,但是不经过改动用不了

1 个赞

好的,谢谢

taichi_three 这个库已经不在更新了,所以已经跑不起来了,如果你想使用它的什么功能,但是 taichi 本身没有的,可以给我们提出来,我们考虑加进去?