We are trying to write a connector to our buerli.io CAD system using speckle-py. Our data format for simple meshes is straight forward, a list of x/y/z vertices and a list of indices.
with open('model.scg') as json_data:
d = json.load(json_data)
json_data.close()
meshes = d["graphic"]["containers"][0]["meshes"]
firstmesh = meshes[0]
vertices = firstmesh["vertices"]
faces = firstmesh["indices"]
block = Mesh(vertices=vertices, faces=faces)
new_stream_id = client.stream.create(name="triangle")
new_stream = client.stream.get(id=new_stream_id)
transport = ServerTransport(client=client, stream_id=new_stream_id)
hash = operations.send(base=block, transports=[transport])
commid_id = client.commit.create(stream_id=new_stream_id, object_id=hash, message="block made in speckle-py")
In speckle it ends up like this:
We bring the same data to generic threejs like this:
protected createMesh(mesh: IGraphicMesh, container: IGraphicContainer, color?: number[]) {
const graphicId = mesh.id
const loops = mesh.loops
const type = mesh.properties.surface.type as GraphicType
const geometry = new THREE.BufferGeometry()
geometry.setIndex(mesh.indices)
geometry.setAttribute('position', new THREE.Float32BufferAttribute(mesh.vertices, 3))
mesh.normals && geometry.setAttribute('normal', new THREE.Float32BufferAttribute(mesh.normals, 3))
What are we doing wrong? And is there a more detailed description available that explains constructs like Mesh
in speckle? The source files don’t seem to go into much detail.