문제

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.

도움이 되었습니까?

해결책

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 !

다른 팁

What happens if you modify the filename with no space?

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top