How can I load a three.js Blender 2.7 exported model without being on a HTTP server? - three.js

Hi I and currently doing all my THREE.js things on file:///.
When I follow tutorials to load models they do
var myLoader = new THREE.JSONLoader();
myLoader.load( url-path-to-file );
The error:
XMLHttpRequest cannot load file:///C:/.../.../.../testmodel.js. Cross origin requests are only supported for HTTP. three.js:11996
THREE.JSONLoader: "./testmodel.js" seems to be unreachable or the file is empty. three.js:11952
Uncaught NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'file:///C:/.../.../.../testmodel.js'.
Because of the limitations of using the file protocol I cannot load things like this. I am wondering how to skip this? I am thinking of storing the exported blender as a JavaScript object and then maybe there is already a piece of THREE.js that can do the rest for me?

Run a python web server from your root directory is what I have done to avoid XSS related errors. I have python installed in windows.
Python version 3 in windows from directory that has your HTML file etc:
c:\Python33\python.exe -m http.server
then point your browser to:
http://localhost:8000/yourhtmlfile.html
For more info on running the server for various versions of python / OS see here:
https://github.com/mrdoob/three.js/wiki/How-to-run-things-locally

Check out this little project. It is a 3D file viewer and has the ability to load STL and Collada files locally in the client. Works both locally and on a server:
https://github.com/yomboprime/Visor3D
Deriving from the code a local JSON loader function is trivial. Yoy can start modifying the loadDAEFile() function (main.js), which reads local file as text.

Related

How to load big scene from server in swift

I put art.scnassets in my local server and tried to use SCNScene(url: options:) to load the .scn
The assets are from fox2 Apple sample code.
Turns out: model is loaded successful but maps cannot be found, and options like "assetDirectoryUrls" did not help.
Any clue would be appreciated!

Bundling JSON data files with Aurelia CLI

I'm using the Aurelia CLI for a data visualization project and can successfully import .json data files from within my src/ directory with
d3.json('src/data/patient-data.json', (data:JSON) => { ... }
when running with "au run" and pointing the browser to localhost:9000.
However, if I open my index.html file statically within a browser, everything else on the page works just fine, except my data won't load and I get the error:
XMLHttpRequest cannot load file:///D:/Webstorm%20Projects/ag-grid-aurelia-example-master/src/data/patient-data.json. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
How can I fix this? And why is it a cross origin request when the file is coming from within my own src directory?
I don't understand why it works fine with 'au run' but not when opened directly from index.html. Does it have something to do with the json file not being included in the bundling process?
And while I'm already using d3 for other things, I'm not necessarily tied to using it to import json files specifically, if that has anything to do with the problem. I just need to load them in somehow.

Image not loading through node.js

I'm using the craftyjs library to load an image. Pretty basic.
Crafty.load(['TestGame/assets/16x16_forest.gif'], function () {
// do stuff after image loaded...
This works fine when I run it from my file system, but as soon as I try running it from node, things start going wrong. The image is still loading fine (from looking at network activity), but the crafty library is throwing an Uncaught TypeError: Type error at this line
context.drawImage(this.img, x, y, ...)
I noticed the this.img variable is listed as type img in Chrome when it works from the file system, but of type HTMLImageElement when it doesn't work through node. Otherwise the variables are identical (other than the URL). Is there some setting I need to change in how node serves up images?
Edit
I tried this using ASP.NET as a backend, and I still got the same error. I also tried using a different image. I'm starting to think it's a bug in the craftyjs library.

Can't get access to file on localhost under Windows

Periodically after branch downloading from github Yii shows such an issue:
copy(Z:\home\localhost\www\insur\insurance\assets\c75d288a\css\_notes\dwsync.xml) [<a href='function.copy'>function.copy</a>]: failed to open stream: Permission denied
(/_notes/dwsync.xml - is a file created by DreamWeaver automatically for developer's notes).
I can't figure out following:
Why Yii tries to implement copy($path,$dst.DIRECTORY_SEPARATOR.$file); for that file (it's here: [site_root]\yii\framework\utils\CFileHelper.php(130))?
Why an access error is possible on Windows localhost?
What exactly is an error source - Windows, Apache or Yii (or maybe DW)?
What is solution?
So a real Guru needed!
I believe that here is one!
Generally Yii Assets Manager will try to publish (or republish) copies of diffirent resources (img, css, js, ..etc) used by your app (made by you or nativly in the framework, e.g Gii module stuff)
An access error can happen in localhost if you didn't set needed permission to web-server process. But in this exact case i think the web-server can not find the folder from the begining.
It is a joint crime between Yii & Apache. Yii CAssestsManager expects an assets folder, Apache can't find it and complains
Proposed Solution:
Make sure you have a folder named assets in your App Root and make sure it's writable by the web server process!!
To understand more about Yii Assests check this wiki-post

My website is throwing "PHP Fatal error: Call to undefined method CI_Lang::lang()"

I created a website using CodeIgniter Framework 2.1.0 that was originally working well. Yesterday, I integrated this i18n code into the site for multi-language support.
Now, when I upload my site to cpanel and open it, I get this error in my log file:
[21-Nov-2011 10:19:04] PHP Fatal error: Call to undefined method CI_Lang::lang() in XXXX
However, the website is working well on my localhost server (xampp for Windows). What's wrong?
See the thread attached to the library: http://web.archive.org/web/20120112092127/http://codeigniter.com/forums/viewthread/179036. In the first post is attached a modified library that claims to alleviate the buggyness of the original.
There is also a post on the first page there referencing an error similar to yours:
After copying the files as described in the article I get the
following error: Fatal error: Call to undefined method
CI_Lang::CI_Lang() in
/www/websites/audio-machinery/application/core/MY_Lang.php on line 32
Though he seems to be calling CI_Lang, not Lang. His solution appears to have been to use the code attached to the forum thread.
Also, cpanel is a control panel for hosting, not a hosting provider. But your hosting provider may be causing issues (e.g. if using older versions of PHP which do not work with newer version of CI. Often hosting providers will give you the ability to choose which version of PHP you are using--usually found in cPanel).
have you uploaded ALL the new files to your live server? that error implies that the code is not found or available to the script.
I came accross the same problem.... it was working fine on localhost but when loaded on live server it gives me undefined error... the problem appears becuase I created file with name My_Lang.php and My_Config.php as on live server it is case sensitive.... so I changed it to MY_Config.php and MY_Lang.php .... it works fine now.... Hope it will work for you too

Resources