X3DOM not picking up external x3d file

2.4k views Asked by At

I am new to the world of 3D graphics. I have a x3d file that i want to display in a web browser. I am trying to use the following code.

<Shape>
   <Appearance>
   <Material diffuseColor='0.6 0.0 0.6' specularColor='0.8 0.8 0.8' shininess='0.145'/>
   </Appearance>
   <inline url="full.x3d"> </inline> 
</Shape>

This is written in a local html file and the "full.x3d" file is in the same directory as the html file. When I open the html file, the x3d box just shows loading... and nothing loads even after a long time.

The x3d file itself is fine. If i copy its contents manually to the html file, i get a good output.

I am not sure why x3dom is not picking up the data from the file. I am not using any local server, directly opening the html in the browser.

And this problem is not just limited to my file. When i downloaded and ran an example file from the x3d tutorial website, it also failed to load the attached x3d file.

2

There are 2 answers

1
Traian On

Inline is not a field of a Shape.
Take that node outside the shape and it will work.
The inlined node should be a children of a grouping node (read specs).
There also an example here.

0
Ethan On

Part of your issue is related to your security settings on your browser. By default browsers are not allowed to access files locally on your system. You need to launch your browser in a way that allows it to access these local files. See this answer on launching Chrome to allow file access from files:

How to launch html using Chrome at "--allow-file-access-from-files" mode?

Do note that you must close out of Chrome entirely for this to work (including drive, hangouts, or any other chrome related software running on your computer.) I had this issue before; took me a while to finally figure it out.

And for your reference, here is the HTML that i used to display the x3d file (Note: I have the js files locally on my machine)

 <html>
  <head>
    <title>My first X3DOM page</title>
    <link rel="stylesheet" type="text/css" href="x3dom-1.6.1/x3dom.css"></link>
    <script type="text/javascript" src="x3dom-1.6.1/x3dom-full.js"></script>
    <script type="text/javascript" src="x3dom-1.6.1/ammo.js"></script>
    <script type="text/javascript" src="x3dom-1.6.1/dash.all.js"></script>
  </head>
  <body>
    <h1>My X3DOM world</h1>
    <p>
      This is my first html page with some 3d objects!
    </p>
    <x3d width="500px" height="400px">
      <scene>
        <transform scale="15,15,15">
        <transform rotation="0,1,0,-.785">
        <transform rotation="1,0,-1,.785">
        <transform translation="0,0,.2">
        <inline url="foo.x3d" render="true" bboxcenter="0,0,0" bboxsize="-1,-1,-1" load="true" namespacename=""></inline>
      </scene>
    </x3d>
  </body>
</html>