jQuery 选项卡菜单和 WebGL

发布于 2024-12-27 06:06:33 字数 1513 浏览 2 评论 0原文

我想使用 jQuery UI 中的选项卡(来源:http://jqueryui.com/demos/tabs/) 使用 WebGL GLGE 在每个选项卡上显示 COLLADA dae 文件(来源:http://www.glge.org/)。选项卡应根据 xml 文件动态生成。一切都按计划进行,只是 3D 对象的渲染不起作用。

我现在尝试了不同的方法,但没有一个有效。结果每次都一样。 3D COLLADA 对象仅在第一个选项卡上呈现。 即使我使用基本和静态的 document.write 语句而不从 xml 中检索数据,也只会显示第一页上的建筑物。

例如:

<div id="tabs">
  <div id="tabs-1">
     //ONLY THIS OBJECT IS RENDERED
     <iframe src="glge/index_1.html" height="400" width="400"></iframe>
  </div>
  <div id="tabs-2">
     <iframe src="glge/index_1.html" height="400" width="400"></iframe>
  </div>
  <div id="tabs-3">
     <iframe src="glge/index_1.html" height="400" width="400"></iframe>
  </div>

如果我使用 jQuery 选项卡中的 iframe,则会呈现多个 iframe。因此

<iframe src="glge/index_1.html" height="400" width="400"></iframe>
<iframe src="glge/index_1.html" height="400" width="400"></iframe>
<iframe src="glge/index_1.html" height="400" width="400"></iframe>
<div id="tabs">
     //codehere
</div>

,在选项卡上方带来了三个渲染的 3D 对象。

希望您能理解我的问题并帮助我。

编辑: 我刚刚上传了上面的“简单”示例。您可以在下面看到它: http://korb.cwsurf.de/tmp/buildingdetail_simple.html

问候, 法伊科

I want to use the tabs from jQuery UI (Source: http://jqueryui.com/demos/tabs/) to display on each tab a COLLADA dae file using WebGL GLGE (Source: http://www.glge.org/). The Tabs should be generated dynamically depending on an xml file. Everything works as planed, only the rendering of the 3D Objects does not work.

I tried now different approaches but none of them works. The result is everytime the same. The 3D COLLADA Object is only rendered on the first tab.
Even if I use basic and static document.write statements without retrieving data from my xml only the building on the first page is displayed.

For Example:

<div id="tabs">
  <div id="tabs-1">
     //ONLY THIS OBJECT IS RENDERED
     <iframe src="glge/index_1.html" height="400" width="400"></iframe>
  </div>
  <div id="tabs-2">
     <iframe src="glge/index_1.html" height="400" width="400"></iframe>
  </div>
  <div id="tabs-3">
     <iframe src="glge/index_1.html" height="400" width="400"></iframe>
  </div>

If i use the iframes out of the jQuery Tabs more than one iframe is rendered. So

<iframe src="glge/index_1.html" height="400" width="400"></iframe>
<iframe src="glge/index_1.html" height="400" width="400"></iframe>
<iframe src="glge/index_1.html" height="400" width="400"></iframe>
<div id="tabs">
     //codehere
</div>

brings three rendered 3D Objects above the Tabs.

Hope you can understand my problem and help me out.

EDIT:
I just uploaded the above "simple" example. You can see it under:
http://korb.cwsurf.de/tmp/buildingdetail_simple.html

greetings,
faiko

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

↙温凉少女 2025-01-03 06:06:33

iframe 加载了一个初始隐藏状态,代码基本上从隐藏状态获取 0x0 尺寸。您可以选择在选项卡单击时加载或刷新框架。如果您转到 http://korb.cwsurf.de/ tmp/buildingdetail_simple.html#tabs-2 只有可见的部分才能正确渲染。

我将推迟到这里 重新加载的最佳方式是什么/ 使用 JavaScript 刷新 iframe? 了解如何重新加载 iframe。

您可以从空白 href 开始,然后仅在单击选项卡时填充它。或者渲染全部,然后在帧加载后调用选项卡。

The iframe is loaded with an initially hidden state, the code basically gets a 0x0 dimensions from the hidden ones. You can choose to load on tab click or refresh the frame. You can see that if you go to http://korb.cwsurf.de/tmp/buildingdetail_simple.html#tabs-2 that only the visible one gets rendered properly.

I'll defer to here What's the best way to reload / refresh an iframe using JavaScript? for how to reload an iframe.

You could start out with a blank href and then only populate it when the tab is clicked. Or render it all then call tabs after the frames load.

℉服软 2025-01-03 06:06:33

难道 需要可见(或者至少有非隐藏的父级)才能知道如何处理自己?我以前见过不可见选项卡的奇怪大小和定位问题,也许您也看到了类似的问题。

您可以尝试在显示选项卡之后添加。像这样的事情:

$('#tabs').tabs();
$('#tabs a:not(:first)').one('click', function() {
    var tab = this.href.replace(/.*#/, '#');
    setTimeout(function() {
        // Add the appropriate <iframe> here.
        $(tab).append('<iframe src="..."></iframe>');
    }, 0);
});

假设第一个已经打开(因此 :not(:first))。使用 one 绑定点击处理程序将在第一次激活后取消绑定处理程序因此您不必不必要地重新添加 。 “timeout 0”技巧只是一种延迟某些事情的方法,直到浏览器再次获得控制权之后,并且应该添加 after > 显示面板。

该技术的快速演示:http://jsfiddle.net/ambigously/FMBcE/

Could it be that the <iframe>s need to be visible (or at least have non-hidden parents) before they know what to do with themselves? I have seen strange sizing and positioning issues with non-visible tabs before, perhaps you're seeing a similar issue.

You could try adding the <iframe>s after showing the tab. Something like this:

$('#tabs').tabs();
$('#tabs a:not(:first)').one('click', function() {
    var tab = this.href.replace(/.*#/, '#');
    setTimeout(function() {
        // Add the appropriate <iframe> here.
        $(tab).append('<iframe src="..."></iframe>');
    }, 0);
});

That assumes that the first will already be open (hence the :not(:first)). Using one to bind the click handler will unbind the handler after its first activation so you don't needlessly re-add the <iframe>s. The "timeout 0" trick is just a way of delaying something until after the browser has control again and that should add the <iframe> after the panel is displayed.

Quick demo of the technique: http://jsfiddle.net/ambiguous/FMBcE/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文