You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’m attempting to load and convert an OBJ file to 3DM format using the rhino3dm library. Here’s the relevant code snippet:
import rhino3dm from 'rhino3dm';
import * as fs from 'fs';
import * as THREE from 'three';
import { OBJLoader } from 'three/addons/loaders/OBJLoader.js';
const rhino = await rhino3dm();
console.log('Loaded rhino3dm.');
const fileContent = fs.readFileSync('public/models/test.obj').toString();
const loader = new OBJLoader();
const obj = loader.parse(fileContent);
let exportGeometry = null;
if (obj.children) {
obj.children.forEach((mesh) => {
if (!exportGeometry) {
console.log('here');
exportGeometry = mesh.geometry;
} else {
exportGeometry = THREE.BufferGeometryUtils.mergeBufferGeometries([exportGeometry, mesh.geometry], false);
}
});
}
const rhinoMesh = rhino.Mesh.createFromThreejsJSON({data: exportGeometry})
const doc = new rhino.File3dm()
doc.objects().add(rhinoMesh, null)
let opts = new rhino.File3dmWriteOptions()
opts.version = 6;
let buffer = doc.toByteArrayOptions(opts);
fs.writeFileSync('public/models/test.3dm', buffer);
console.log('3DM file saved successfully.');
The code successfully generates a 3DM file, but unfortunately, the resulting file is not valid. When re-uploaded to a 3D viewer, it fails to load properly. I’ve followed the example from the repository, but I’m encountering this issue.
Any insights on why the generated 3DM file isn’t valid, and how I can address this problem?
The text was updated successfully, but these errors were encountered:
I’m attempting to load and convert an OBJ file to 3DM format using the
rhino3dm
library. Here’s the relevant code snippet:The code successfully generates a 3DM file, but unfortunately, the resulting file is not valid. When re-uploaded to a 3D viewer, it fails to load properly. I’ve followed the example from the repository, but I’m encountering this issue.
Any insights on why the generated 3DM file isn’t valid, and how I can address this problem?
The text was updated successfully, but these errors were encountered: