-
Notifications
You must be signed in to change notification settings - Fork 335
/
Copy pathapp.js
49 lines (35 loc) · 1.22 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const edge = require('edge-js')
const rhino3dm = require('rhino3dm')
// construct the path to the .NET dll
const namespace = 'SampleRhinoInsideJavascriptMethodsLib'
const baseAppPath = '../' + namespace + '/bin/Debug/'
const baseDll = baseAppPath + namespace + '.dll'
// console.log(baseDll)
const rhinoTypeName = namespace + '.RhinoMethods'
const startRhino = edge.func({
assemblyFile: baseDll,
typeName: rhinoTypeName,
methodName: 'StartRhino'
})
const makeSphere = edge.func({
assemblyFile: baseDll,
typeName: rhinoTypeName,
methodName: 'MakeSphere'
})
rhino3dm().then((rhino) => {
console.log('rhino3dm loaded.')
startRhino('', function (error, result) {
if (error) throw error
console.log(result)
// Try changing these parameters to get different results from the 'makeSphere' call.
let params = {radius: 10.00, countU: 10, countV:10 }
makeSphere(params, function (error, result) {
if (error) throw error
//convert this to object
const obj = JSON.parse(result)
const rhinoMesh = rhino.CommonObject.decode(obj)
console.log(`Mesh has ${rhinoMesh.vertices().count} vertices and ${rhinoMesh.faces().count} faces.`)
rhinoMesh.delete()
})
})
})