Just looking for some advice or suggestion related to using this library.
I managed to create a STEP viewer but when adding group of meshes then positioning is off and some meshes don't seem to be added as it is in your example when viewing it in Online 3D Viewer.
This is the short version of the code:
occtimportjs().then ( async function( occt ) {
response = await fetch( URL.createObjectURL( selected_step_file ) );
URL.revokeObjectURL( selected_step_file );
buffer = await response.arrayBuffer ();
fileBuffer = new Uint8Array( buffer );
result = await occt.ReadStepFile( fileBuffer );
if (result.success) {
let mesh_count = 1;
result.meshes.forEach( msh => {
let geometry = new THREE.BufferGeometry();
indices = Uint16Array.from( msh.index.array );
geometry.setIndex( new THREE.BufferAttribute( indices, 1 ) );
geometry.setDrawRange( 0, indices.length );
vertices = Float32Array.from( msh.attributes.position.array );
geometry.setAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
normals = Float32Array.from( msh.attributes.normal.array );
geometry.setAttribute( 'normal', new THREE.BufferAttribute( normals, 3 ) );
geometry.normalizeNormals();
geometry.center();
let new_mesh = new THREE.Mesh( geometry, material );
new_mesh.name = 'mesh_' + mesh_count;
edges[ new_mesh.name ] = new THREE.LineSegments( new THREE.EdgesGeometry( new_mesh.geometry, 30 ), new THREE.LineBasicMaterial( { color: 0xA52A2A } ) );
mesh_count += 1;
mesh.add( new_mesh );
geometry.dispose();
new_mesh.geometry.dispose();
new_mesh.material.dispose();
});
await addFileInScene();
}
});
Hi Viktor.
Just looking for some advice or suggestion related to using this library.
I managed to create a STEP viewer but when adding group of meshes then positioning is off and some meshes don't seem to be added as it is in your example when viewing it in Online 3D Viewer.
This is the short version of the code: