cnr-isti-vclab / meshlabjs

A javascript client based mesh processing tool. Built using vcg library, emscripten and webgl
http://www.meshlabjs.net
GNU Affero General Public License v3.0
231 stars 51 forks source link

Embedding MeshLabJS + Default mesh in a webpage #113

Open mankoff opened 8 years ago

mankoff commented 8 years ago

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.

cignoni commented 8 years ago

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...

mankoff commented 8 years ago

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/

mrweix commented 8 years ago

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

mankoff commented 8 years ago

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.

cignoni commented 8 years ago

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.

mankoff commented 8 years ago

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.

cignoni commented 8 years ago

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

mrweix commented 8 years ago

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

cignoni commented 8 years ago

Create Noisy Isosurface is a filter

mrweix commented 8 years ago

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

benellefi commented 6 years ago

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,