MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / EMSCRIPTEN_BINDINGS

Function EMSCRIPTEN_BINDINGS

source/MRWasmModule/MRWasmMeshProject.cpp:16–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14using namespace MR;
15
16EMSCRIPTEN_BINDINGS( meshlib_mesh_project )
17{
18 emscripten::function( "findProjection", +[]( const Vector3f& pt, std::shared_ptr<Mesh> m )
19 {
20 const MeshProjectionResult r = findProjection( pt, *m );
21
22 emscripten::val proj = emscripten::val::object();
23 proj.set( "face", (int)r.proj.face );
24 proj.set( "point", r.proj.point );
25
26 emscripten::val bary = emscripten::val::object();
27 bary.set( "a", r.mtp.bary.a );
28 bary.set( "b", r.mtp.bary.b );
29 emscripten::val mtp = emscripten::val::object();
30 mtp.set( "e", (int)r.mtp.e );
31 mtp.set( "bary", bary );
32
33 emscripten::val out = emscripten::val::object();
34 out.set( "proj", proj );
35 out.set( "mtp", mtp );
36 out.set( "distSq", r.distSq );
37 out.set( "valid", r.valid() );
38 return out;
39 } );
40
41 emscripten::function( "findSignedDistance", +[]( const Vector3f& pt, std::shared_ptr<Mesh> m )
42 {
43 const auto res = findSignedDistance( pt, *m );
44 if ( !res )
45 return emscripten::val::null();
46
47 emscripten::val proj = emscripten::val::object();
48 proj.set( "face", (int)res->proj.face );
49 proj.set( "point", res->proj.point );
50
51 emscripten::val bary = emscripten::val::object();
52 bary.set( "a", res->mtp.bary.a );
53 bary.set( "b", res->mtp.bary.b );
54 emscripten::val mtp = emscripten::val::object();
55 mtp.set( "e", (int)res->mtp.e );
56 mtp.set( "bary", bary );
57
58 emscripten::val out = emscripten::val::object();
59 out.set( "proj", proj );
60 out.set( "mtp", mtp );
61 out.set( "dist", res->dist );
62 return out;
63 } );
64}

Callers

nothing calls this directly

Calls 4

findProjectionFunction · 0.85
findSignedDistanceFunction · 0.50
setMethod · 0.45
validMethod · 0.45

Tested by

no test coverage detected