Closed leifriksheim closed 1 year ago
points
is not currently available on a NurbsSurface in javascript
https://github.com/mcneel/rhino3dm/blob/main/src/bindings/bnd_nurbssurface.cpp#L273
The technique for exposing this to javascript is much more complicated and delicate than what is required for python. I haven't figured out a good approach for this yet.
Thank you for the quick response! I am working on a proof of concept mixing rhino3dm.js, Three.js and Y.js to create a p2p collaborative Grasshopper-like application in the browser (you can play with two open browser windows to see them interact):
https://grasshopper-web.netlify.app/
I will probably end up using Rhino Compute for the more advanced stuff, but I am also a bit worried about how calling a server async would affect the real-time collaboration experience.
I noticed that Threejs has support for NURBS surfaces. And so being able to get the control points would hopefully make it easier to convert faces of a Brep to a Threejs representation, instead of the manual way I'm doing it now – By getting the points of a surface and making a ConvexGeometry:
export function faceToPoints(face) {
const points = [];
const loops = 20;
face.setDomain(0, [0, 1]);
face.setDomain(1, [0, 1]);
for (let u = 0; u <= loops; u++) {
for (let v = 0; v <= loops; v++) {
const point = face.pointAt(u / loops, v / loops);
points.push(new THREE.Vector3(point[0], point[1], point[2]));
}
}
return points;
}
Until then, do you think there are any better ways to represent a face using rhino3dm.js and Three.js?
control points are now available in the latest rhino3dm 8.0.0 beta. You can get the js build from here (available for the next 15 days): https://github.com/mcneel/rhino3dm/suites/12952159278/artifacts/700266513
Please see this discourse post for more information: https://discourse.mcneel.com/t/getting-control-points-and-knots-on-a-nurbssurface-in-javascript/141744/3
I'm trying to get the control points of a NurbsSurface in rhino3dm.js. In the python documentation, the NurbsSurface seems to have different properties and methods than the javascript version. NurbsSuface in the javascript module seems to be the same object as Surface. Could this be a bug?
https://mcneel.github.io/rhino3dm/javascript/api/NurbsSurface.html