Coder Social home page Coder Social logo

Comments (14)

kovacsv avatar kovacsv commented on July 30, 2024 1

Hi Hinko!

You can define a url or a file rleative location as browser hash.

Here is an example:
http://3dviewer.net#https://cdn.rawgit.com/kovacsv/Online3DViewer/9e9ca71d/website/testfiles/cube.3ds

Regards,
Viktor

from online3dviewer.

kovacsv avatar kovacsv commented on July 30, 2024 1

Local file access will never work because of browser security restrictions. Image how big security hole would be if a browser could access any file on your computer. Drag and drop and file open works because in these cases you explicitly stated you want to allow the website to access your file.

If you want to use the viewer for local files you can do this:

  • Download the repository.
  • Go to the website folder.
  • Copy 3D files into this folder, on in a subfolder.
  • Now it should work offline with a url like this: file:///C:/Online3DViewer/website/index.html#testfiles/cube.3ds

This solution works only in Firefox. If you would like to use Chrome, you have to install a web server on your computer.

from online3dviewer.

hinxx avatar hinxx commented on July 30, 2024

Works great .. thanks!

from online3dviewer.

wuyuzhang avatar wuyuzhang commented on July 30, 2024

Hi Viktor,

Really nice work.

Just one question:
how to use browser hash to open multiple files for obj format?

Thanks,
Yuzhang

from online3dviewer.

kovacsv avatar kovacsv commented on July 30, 2024

Unfortunately it is not possible at the moment to show multiple files.

from online3dviewer.

hg42 avatar hg42 commented on July 30, 2024

I would recommend to add this example or at least a hint to the README.
I also tried a lot of url schemes before even reading the README (e.g. the page contains an element <input id='file' ...> so I assumed a ?file=....
It's not very common to use a hash #.
I would also add a comment, why it is hash. I assume it's a hash because the page doesn't reload when switching to a relative url of the format #url.

from online3dviewer.

kovacsv avatar kovacsv commented on July 30, 2024

Thanks for the idea, I added an example in the dev branch, so it will be available soon. I've called it location hash because this is the name of it: https://www.w3schools.com/jsref/prop_loc_hash.asp :)

from online3dviewer.

hg42 avatar hg42 commented on July 30, 2024

it's also very difficult today, because of all those security related restrictions.
I couldn't convince Firefox or Chrome to load a local file://... URL after the hash.

I cannot really understand why, because drag and drop or file selection works. I assume the permissions are different in these cases?

I also tried everything from https://www.viewstl.com/local_url/
I guess you should add something like this to your docs or simply a reference to that page.
However, it didn't help me.

Note, I always use the most recent versions of these browsers (FF=nightly 66.0a1, chrome=stable 71.0.3578.98)
I also tried other browsers like Midori, Falkon etc., but they either use the same security model or they lack support for the necessary 3D features etc.

from online3dviewer.

hg42 avatar hg42 commented on July 30, 2024

there are a lot of tips to workaround this, I tried these:

google-chrome --disable-web-security "https://3dviewer.net#$url"
google-chrome --allow-file-access-from-files --allow-file-access --allow-cross-origin-auth-prompt "https://3dviewer.net#$url"
chromium --disable-web-security "https://3dviewer.net#$url"
chromium --disable-web-security "http://www.viewstl.com/viewstl.php?url=$url"
chromium --allow-file-access-from-files --allow-file-access --allow-cross-origin-auth-prompt "https://3dviewer.net#$url"
chromium --out-of-blink-cors "https://3dviewer.net#$url"

however with current browsers this didn't work. But I am sure it worked some time ago.

I created a little electron app and got it to load the file. But it's not completely ready yet...

from online3dviewer.

hg42 avatar hg42 commented on July 30, 2024

I once tried it with a local 3dviewer (loaded via file://) but it didn't work.
But that was before knowing the command line options mentioned above.

After testing several combinations of these options, I need only one to load local files from a viewer loaded from local files:

chromium --allow-file-access-from-files "file:///z/3D-print/Online3DViewer/website/index.html#file:///z/3D-print/things/test/test-jscad/output.stl"

So my first requirement is satisfied.

Now I need to figure out how to autoload the stl file while ideally keeping all view parameters like angles, zoom factor, etc.
In general this should work with a relative hash url. But how to set it on the existing tab?

from online3dviewer.

ApetweBc avatar ApetweBc commented on July 30, 2024

Does using the hash only works with .3ds file. I tried uploading Stl file from Amazon or from my local server but both failed. Error "No readable file found You can only open 3ds, obj, Stl and off files". The files work in drag and drop thou. What do you think?

from online3dviewer.

kovacsv avatar kovacsv commented on July 30, 2024

Seems working for me: http://3dviewer.net/#https://cdn.rawgit.com/kovacsv/Online3DViewer/9e9ca71d/website/testfiles/objects_ascii.stl

Can you send the link what doesn't work for you?

from online3dviewer.

ApetweBc avatar ApetweBc commented on July 30, 2024

Working will all the other formats locally but I can't get it to work from Amazon S3. Looking at your URL, there are no dashes. My amazon URL is ''https://stltestingw.s3-us-west-2.amazonaws.com/3Dimplantfilestl.stl''

from online3dviewer.

kovacsv avatar kovacsv commented on July 30, 2024

I think it is a cross origin request issue. You have to allow CORS on your server.

from online3dviewer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.