I have this codes in jupyter notebook on pythreejs in chrome:
the github address: https://github.com/jovyan/pythreejs/blob/master/examples/Examples.ipynb
the source said : Buffer Geometries The PlainBufferGeometry object uses several tricks to speed up both the transfer of data and the rendering of the data.
from pythreejs import *
import numpy as np
from IPython.display import display
vertices = np.asarray([
[0, 0, 0],
[0, 0, 1],
[0, 1, 0],
[0, 1, 1],
[1, 0, 0],
[1, 0, 1],
[1, 1, 0],
[1, 1, 1]
], dtype='float32')
faces = np.asarray([
[0, 1, 3],
[0, 2, 3],
[0, 2, 4],
[2, 4, 6],
[0, 1, 4],
[1, 4, 5],
[2, 3, 6],
[3, 6, 7],
[1, 3, 5],
[3, 5, 7],
[4, 5, 6],
[5, 6, 7]
])
vertexcolors = np.asarray([(0,0,0), (0,0,1), (0,1,0), (1,0,0), (0,1,1), (1,0,1), (1,1,0), (1,1,1)])
cubeGeometry = PlainBufferGeometry(vertices=vertices, faces=faces, colors = vertexcolors)
myobjectCube = Mesh(geometry=cubeGeometry, material = LambertMaterial(vertexColors = 'VertexColors'))
cCube = PerspectiveCamera(position=[3, 3, 3], fov=20,
children=[DirectionalLight(color='#ffffff', position=[-3, 5, 1], intensity=0.5)])
sceneCube = Scene(children=[myobjectCube, AmbientLight(color='#dddddd')])
rendererCube = Renderer(camera=cCube, background='black', background_opacity=1,
scene = sceneCube, controls=[OrbitControls(controlling=cCube)])
display(rendererCube)
but when running I got this error:
NameError Traceback (most recent call last)
<ipython-input-14-f2777808a126> in <module>()
31 vertexcolors = np.asarray([(0,0,0), (0,0,1), (0,1,0), (1,0,0), (0,1,1), (1,0,1), (1,1,0), (1,1,1)])
32
---> 33 cubeGeometry = PlainBufferGeometry(vertices=vertices, faces=faces, colors = vertexcolors)
34
35 myobjectCube = Mesh(geometry=cubeGeometry, material = LambertMaterial(vertexColors = 'VertexColors'))
NameError: name 'PlainBufferGeometry' is not defined
so what should I do? best regards
via hasanbaghal
No comments:
Post a Comment