It seems only mesh type of geometry in 3dm file can be read by the rhino3dm.js library, using code like the following, though a bit cumbersome…
But, how do we read the keys and values stored in attribute user text assigned to the geometries in the original 3dm file, using methods in rhino3dm.js?
var rhino_file_path = "../3dm/b01_mesh.3dm";
let fetchPromise = fetch(rhino_file_path);
rhino3dm().then(async (m) => {
console.log("Loaded rhino3dm.");
let rhino = m;
let res = await fetchPromise;
let buffer = await res.arrayBuffer();
let arr = new Uint8Array(buffer);
let doc = rhino.File3dm.fromByteArray(arr);
THREE.Object3D.DefaultUp = new THREE.Vector3(0, 0, 1);
init();
let material = new THREE.MeshNormalMaterial();
let objects = doc.objects();
for (let i = 0; i < objects.count; i++) {
let mesh = objects.get(i).geometry();
if (mesh instanceof rhino.Mesh) {
// convert all meshes in 3dm model into threejs objects
let threeMesh = meshToThreejs(mesh, material);
scene.add(threeMesh);
}
}
});