meshlabjs icon indicating copy to clipboard operation
meshlabjs copied to clipboard

Embedding MeshLabJS + Default mesh in a webpage

Open mankoff opened this issue 8 years ago • 11 comments

I'd like to have a web-page where visitors see a mesh when they arrive. It isn't clear if MeshLabeJS supports this. For example, could the Bunny mesh be loaded by default when visiting http://www.meshlabjs.net/ ?

I've skimmed the docs but I don't see mention of this feature mentioned there.

mankoff avatar Apr 18 '16 16:04 mankoff

Initially we planned to include a "open from web feature" but actually it is not possible in a pure client based solution due to Same-origin_policy; in short a web browser permits scripts contained in a first web page to access data in a second web page, but only if both web pages have the same origin, so it is not possible for a script on www.meshlabjs.net to load a mesh that reside on https://graphics.stanford.edu/data/3Dscanrep/.

There are workarounds, but they are a bit cumbersome: either they require non pure-client solutions or they need that the servers providing the files to open implements certain protocols...

cignoni avatar Apr 18 '16 19:04 cignoni

But... could I host the MeshLabJS code on http://example.com/ and the data on http://example.com/ ? In my example above, I assumed the bunny would be hosted on http://meshlabjs.net/

mankoff avatar Apr 18 '16 20:04 mankoff

Did you find a solution to load a mesh directly at startup?

mrweix avatar Apr 22 '16 09:04 mrweix

No. I think it has this ability, but may not be answered now that this ticket was marked as "closed". I'll re-open a new ticket where I phrase the question better if there is no reply here.

mankoff avatar Apr 22 '16 13:04 mankoff

I re-opened the issue given the interest in the topic. Give a look at these commits:

https://github.com/cnr-isti-vclab/meshlabjs/commit/fd9245dbd2f026ef5357dbd55e78294d0d2d6253 https://github.com/cnr-isti-vclab/meshlabjs/commit/7b87ccaab4b0607fd2755275db45dca3b54b207f

Re adding this load-from-web support should be not too complicated. I am willing to add it again if you are able to find some public servers (at least one :) ) that support cross site download of meshes.

cignoni avatar Apr 23 '16 14:04 cignoni

Hi. Perhaps a misunderstanding. I'm not trying to do cross-site loading, which seems to be a security issue. I'd just like to have a default mesh, hosted on the same server as MeshLabeJS, loaded when the users accesses the site. The docs are fairly low-level and technical, and I couldn't find an example of how to set up this type of installation, hence this ticket.

mankoff avatar Apr 24 '16 12:04 mankoff

Ok, that can be done. We already have a rudimental "run at startup" api that will hopefully expanded. The following url show an example of this api. http://www.meshlabjs.net/?filterName=Create%20Noisy%20Isosurface

cignoni avatar Apr 29 '16 09:04 cignoni

Thats very interesting. Is the Noisy Isosurface stored as stl file somewhere or is it generated? How to access it with this API?

mrweix avatar Apr 29 '16 09:04 mrweix

Create Noisy Isosurface is a filter

cignoni avatar Apr 29 '16 09:04 cignoni

Hello folks,

has there been any solution to this? Meaning could I host the MeshLabJS code on http://example.com/ and an mesh.stl file on http://example.com/ and could this mesh.stl file be loaded on startup of the page? Please let me know if anybody has managed to implement this

mrweix avatar Nov 25 '16 14:11 mrweix

Hi all,

Any solutions yet for the startup loading file API ?

Since in the current index.html, the following code allows only to create filter by filterName : Module['onRuntimeInitialized'] = function() { filterName = MLJ.util.getURLParam("filterName"); if(filterName) MLJ.core.plugin.Manager.executeCreateFilter(filterName);*/ };

I tried the following:

Module['onRuntimeInitialized'] = function() { var filePath= MLJ.util.getURLParam("filePath"); if(filePath)
{ fileName = new File(filePath); if (fileName instanceof File) { MLJ.core.file.openMeshFile(fileName); //MLJ.util.loadFile(fileName); //MLJ.load(fileName); } }
};

Any HELPS ? :)

Thanks,

benellefi avatar Oct 01 '18 08:10 benellefi