问题
I am running Linux Mint 17.1 (Rebecca) on my Dell 4x Intel(R) Core(TM) i3-5005U CPU.
I have done X3D in a viewer in the past, but am now try to do X3DOM in a Google Chrome v42 browser.
I can, for example display examples.x3dom.org/example/x3dom_helloWorld.xhtml from x3dom.org website. But when I copy locally to my machine and try to view I get "XMLHttpRequest cannot load file:///home/andrewmneiderer/src/Web3D/X3DOM/x3dom.swf. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource."
Has anyone seen this error and have suggestions on what to do?
回答1:
I wonder why this is not stated in the current documentation, but I remembered that I read it. You can find it in the documentation of previous versions http://x3dom.org/download/1.5.1/docs/html/notes/platforms.html#chrome
Recent releases of Chrome require you to enable WebGL. Please use the following command parameters when launching chrome:
--enable-webgl
--use-gl=desktop
--log-level=0
--allow-file-access-from-files
--allow-file-access
The last two options enable the browser to load textures from disk. You will need this if you are developing your site locally.
Furthermore there is an option --disable-web-security
which has been mentioned here: http://x3dom.org/docs-old/notes/cors.html#chrome
Besides from that, I think you should try to get a machine with native WebGL support since this Flash version of X3DOM is just a fallback method which might lack the performance features of the native version.
回答2:
Chrome on all systems (by default) does not enable loading of resources from the local disk - even when the parent HTML comes from the local disk. Firefox, IE, and (I think) Safari all allow local file loading. If you need to load X3D files using X3D from your local disk, then you need to implement a local web server. It is not necessary to run a full-blown Apache server. Google 'local web server' for various options.
来源:https://stackoverflow.com/questions/30661761/viewing-a-x3dom-file-locally