0

My problem seems similar to Not able to visualize a loaded data , but I have no console errors and I have already added the '-allow-file-access-from-files' flag to my Chrome Browser. Here's my Java coding,

window.onload = function() {

var r = new X.renderer3D();
  r.init();

  pros = new X.mesh();
  pros.file = 'file:///C:/Users/Nathan/Downloads/JB Farmer STL ACII.stl';
  pros.caption = 'Prosthetic';

  r.add(pros);

  r.render();

};

Should I "play around" with with camera position, I know I have to do that in Three.js. Maybe the model needs normals? I'm not sure if it does or not. I haven't worked with 3D modeling, besides Three.js.

Update: Ummmm, I'm not sure what is going on with this, but I realized that XTK generated 2 canvases . I looked at the first two Lessons and they have one. ^ Now eliminated the extra canvas, must have copied a piece and that was in there.

Community
  • 1
  • 1
Karijuana
  • 314
  • 1
  • 2
  • 13

2 Answers2

0

What happens if you modify the filename with no space?

JB Farmer_STL_ACII.stl instead of JB Farmer STL ACII.stl

0

For the moment, the loader of xtk doesn't seem to be done for local. I mean : it uses an XMLHttpRequest (XHR) to get the file with a GET request. First of all the request must be sent to something that can handle it (a server or localhost emilated by Wamp or equivalent). Then let's imagine if one broswer, no matter what one, allows XHR on a file at client side by his url, and imagine I'm a pirate and you come on my website. I know Windows well, I know in C:/Windows/System32 there always is a file where I can find your personals data. What do I do ? An XHR ! You've been hacked. It's a story but you see the idea.

That's why the only ways allowed by browsers to access local files are HTML5 File API & HTML5 Drag&Drop API (unfortunately...). Actualy a way to go through that limitation is having binary code at the client side (flash, java applet). The client is the only one who can ask to open a file or drop a file, so the browser is sure there won't be any security failure because of him.

So you should test it with something like Wamp and access your file with an url like "http://localhost/.../myfile.stl" or the relative url "/.../myfile.stl", or do the following if you realy want local files.

A few weeks ago I wrote my own parser for a private format for xtk and from local file, it worked well, I just used HTML5 APIs to read the file and get a String or BinaryArray from it and then wrote a parser that transformed it in a X.mesh. So I think the best would be to extend the X.loader for HTML5 file APIs, or like me to manualy load the file.

The following jsFiddle from Haehn helps : here !

Ricola3D
  • 2,402
  • 17
  • 16
  • the X.loader now supports local files – haehn Jun 28 '12 at 17:32
  • Actualy it is not direct since it well needs the file API, it need a long piece of code (according to your jsFiddle). I just didn't see that the loader tested if filedata with empty or not before casting an xhr. – Ricola3D Jun 29 '12 at 07:16
  • @Ricola3D Your answer did seem the most logical and thought it had my problem. I created a localhost through IIS and put the HTML, CSS, JS, and STL file in the localhost directory. Though there is a problem loading any model I refer to in the JS file. I had even downloaded the porsche from Lesson 04 and tried using that. I believe you may not be able to access models from localhost, or at least STL files you may not. Another weird thing happens, the model appears to load but does not work. Then I refresh the page and it tries to get the file through the Cache. I can clear the cache then so on. – Karijuana Jul 09 '12 at 20:17
  • @user1483574 Very strange... I've already done some code with loading stl files (with HTML APIs) from Google App Engine's Eclipse plugin started in development mode (i.e. in http://localhost:8888) and everything did well. Could you plz try under a few web browsers (Chrome & Firefox at least) and tell us what their consoles say about your case ? – Ricola3D Jul 10 '12 at 08:20
  • The results in the console for Firefox and Chrome are the usual with no errors. Another issue I notice is that when i check the Networking with Chrome, in Lesson 04, the STL file is type "text/html" and in my localhost example it is type "application/vnd.ms-pki.stl" for any STL file I use. Also the comment with the cache loading was due to one of my files being fairly small and not observing the problem completely. – Karijuana Jul 11 '12 at 13:49
  • Where do your stl come from ?! This mime type seems to be the one of a C++ "Standard Template Library" but I've no more informations. It should be "application/sla" I think, or an application/octet-stream if it is binary. – Ricola3D Jul 11 '12 at 14:19
  • Well, the problem with the mime earlier was causing me to download the STL file instead of loading it so i just configured ISS to have it as the "text/html" mime just because it seemed to work on lesson 04, though same problem. There may be a probmlem I'm having with IIS so I'm going to switch over to an Apache server and tweak the files to hopefully work properly in there. – Karijuana Jul 11 '12 at 15:30