简体   繁体   English

单击按钮更改x3dom模型

[英]Change the x3dom model with a button click

I have two x3d files namely 1.x3d and 12.x3d and I want to use a button to load them onto the canvas but my code doesn't seem to work . 我有两个x3d文件,分别是1.x3d12.x3d ,我想使用一个按钮将它们加载到画布上,但是我的代码似乎不起作用。 I see the loading icon in the top left but the model doesn't change . 我在左上方看到加载图标,但是模型没有改变。

Here is my code : - 这是我的代码:-

<!DOCTYPE html>
  <html>
    <head>
      <meta http-equiv='Content-Type' content='text/html;charset=utf-8'></meta>
      <link rel='stylesheet' type='text/css' href='http://www.x3dom.org/x3dom/release/x3dom.css'></link>
      <script type='text/javascript' src='http://www.x3dom.org/x3dom/release/x3dom.js'></script>


      <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
      <script>
          $(document).ready(function(){
          $("button").click(function(){
           $("x3d > scene > inline").attr("url", "1.x3d");
          });
         });
      </script>

    </head>
   <body>

      <button> Click to Change Background </button>

      <x3d id='someUniqueId' showStat='false' showLog='false' x='0px' y='0px' width='400px' height='400px'>
       <scene>
          <inline id="myinline" url='12.x3d' ></inline>
       <scene>
      </x3d>
   </body>
 </html>

I tested it and it works as it should, but you can't test local. 我已经对其进行了测试,并且可以正常工作,但是您无法测试本地。

XMLHttpRequest cannot load file:///C:/Users/xxx/Desktop/12.x3d. XMLHttpRequest无法加载file:/// C:/Users/xxx/Desktop/12.x3d。 Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource. 跨源请求仅支持以下协议方案:http,数据,chrome,chrome扩展名,https,chrome-extension-resource。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM