Rhino Compute javascript library

i started experimenting with Rhino.compute
The installation of the server was succesful; same for the first tests trought the “Hops” component in Grasshopper.
Now i’m trying to do some test with javascript and i started from this examples:


Both starts with the library import:

import rhino3dm from 'rhino3dm'
import { RhinoCompute } from 'rhinocompute'

I was able to install the first one with npm (npm install rhino3dm), but i can’t find how to install the second one.
The only library i found in the npm registry that seems to be related is “compute-rhino3d” (https://www.npmjs.com/package/compute-rhino3d).
I tried to use it, but the import command is different from the one used in the examples:

import { RhinoCompute } from 'compute-rhino3d'

and if i try the script i get the error:

TypeError: Cannot set properties of undefined (setting 'url')

for the code line (always taken from examples):

RhinoCompute.url = 'http://x.x.x.x:80/' (in the code there is the real IP)

I cant find much documentation on these topics, is there anyone who can point me in the right direction?

many thanks

Hi @Corrado ,

If you check the index file in the sample you mention…

You will see this syntax where you import the library compute-rhino3d through JavaScript Import Maps

 <script type="importmap">
                "imports": {
                    "three": "https://unpkg.com/three@0.144.0/build/three.module.js",
                    "three/examples/jsm/controls/OrbitControls": "https://unpkg.com/three@0.144.0/examples/jsm/controls/OrbitControls.js",
                    "three/examples/jsm/loaders/3DMLoader": "https://unpkg.com/three@0.144.0/examples/jsm/loaders/3DMLoader.js",
                    "rhinocompute": "https://www.unpkg.com/compute-rhino3d@0.13.0-beta/compute.rhino3d.module.js"

Essentially, it allows the mapping of import specifiers to a relative or absolute URL, which helps to control the resolution of the module without the application of a build step.

Please read this post about import maps if you need further information:

Kind regards,