Javascript: Make a Mesh from Rhino.Compute

Hi, I’m new to Rhino.Compute and JS in general and have come across a probably simple question when getting started. I’m trying to basically create a mesh sphere via Rhino.Compute, and then to extract vertices.

I could easily do this in C# as the following:

Rhino.Geometry.Sphere S1 = new Rhino.Geometry.Sphere(new Rhino.Geometry.Point3d(0, 0, 0), 10);
Rhino.Geometry.Mesh M1 = Rhino.Compute.MeshCompute.CreateQuadSphere(S1, 7);
var A = M1.Vertices;

But I get errors when trying to replicate the same thing in JS, Rhino3dmjs, RhinoCompute:

let sphere = new rhino.Sphere([0, 0, 0], 4)
let sphereMesh = RhinoCompute.Mesh.createFromSphere(sphere, 5, 5, false)
//This next line is where it breaks, basically I can't extract members from sphereMesh, it returns a promise
let vertices = sphereMesh.vertices()

I haven’t found much infomation regarding this, apart from the following sample of Clash Detection of Rhino Compute JS Repo which returns a list of array of 2 meshes:
RhinoCompute.computeFetch(‘rhino/geometry/intersect/meshclash/search’, [model.sphere, model.spheres, 0.1, 5])

But what exactly is computeFetch, haven’t found it in API, and by the structure of the url it looks like Rhinocommon. And how to decode the “sphereMesh” into a rhino3dm.Mesh? (Althought the Rhino Compute Js API page suggests that this will return a rhino3dm.Mesh but looks like it does not).

Any help would be appreciated, thanks!

Check out this codepen for a working example.

Calls to compute return a promise, so you need to work with the geometry after the promise has resolved:

let sphere = new rhino.Sphere([0, 0, 0], 4);
RhinoCompute.Mesh.createFromSphere(sphere, 15, 15, false)
    let mesh = rhino.CommonObject.decode(result);
    //... continue ...

computeFetch is the main Rhino.Compute api call. You can see it here near the top, and if you look further down, you’ll see that all of the library methods eventually call computeFetch.

You can do this after the Compute call has resolved:
let mesh = rhino.CommonObject.decode(result);