gpt4 book ai didi

javascript - XML3D getLocalBoundingBox 给出 "this.renderNode.getObjectSpaceBoundingBox is not a function"错误

转载 作者:行者123 更新时间:2023-11-30 15:41:45 26 4
gpt4 key购买 nike

这很难理解,我正在使用当前的 xml3D.js 5.2 版。

我正在使用 *BoundingBox() 函数来简化 Assets 和相机的定位。内容已正确加载,错误出现在未加载 xml3D Assets 文件 时。有什么特定于 xml3D Assets 的吗?

xml3D 内容

以下内容来自https://github.com/xml3d/xml3d.js/wiki/Using-Assets-and-Models

<body>
<xml3d class="xml3d" view="#defaultView">
<defs>
<!-- camera position -->
<transform id="t_camera" translation="0 0 40" rotation="0 1 0 0"></transform>
<transform id="m_transform" scale="0.1 0.1 0.1"></transform>
<transform id="t_Lamp" translation="0 0 -400"></transform>
<transform id="r_Lamp" rotation="1 0 0 -0.2"></transform>

<!-- permanent light -->
<lightshader id="ls_directional" script="urn:xml3d:lightshader:directional">
<float3 name="intensity">0.6 0.6 0.6</float3>
</lightshader>
<transform id="t_directional" rotation="1 0 0 -0.2" />
<!-- //permanent light -->
</defs>

<!-- Our viewpoint from where we see the 3D content -->
<group id="viewGroup" transform="#t_camera">
<view id="defaultView"></view>
</group>

<!-- permanent light -->
<group transform="#t_directional">
<light shader="#ls_directional"></light>
</group>
<!-- //permanent light -->

<!-- our model include -->
<group transform="#m_transform">
<model id="xmlmodel" src="ciccio.xml#ciccio"></model>
</group>
</xml3d>
</body>
<script>
// attach event to the mesh
document.querySelector("#xmlmodel").addEventListener("click", function() {
var model = document.getElementById("xmlmodel");
alert("my center is " + model.getLocalBoundingBox().center().toDOMString());
});
</script>

所以当我点击模型时,它会运行对 getLocalBoundingBox() 的指定调用并抛出错误:

getLocalBoundingBox — xml3d.js:15685TypeError: this.renderNode.getObjectSpaceBoundingBox is not a function. (In 'this.renderNode.getObjectSpaceBoundingBox(bbox)', 'this.renderNode.getObjectSpaceBoundingBox' is undefined)

最佳答案

抱歉,您在这方面遇到了麻烦,最近的一次更新中似乎出现了错误。我已经对即将发布的 5.2.2 补丁进行了修复,并上传了一个预览版本供您试用:xml3d-5.2.2-min.js

如果您打算使用它来定位相机,尽管您可能想使用 getWorldBoundingBox相反,由于本地边界框没有考虑来自层次结构中更高层的任何转换(例如您的 <group transform="#m_transform"> 。因此您会得到模型本身的边界框,但它可能不相同场景中的位置。

关于javascript - XML3D getLocalBoundingBox 给出 "this.renderNode.getObjectSpaceBoundingBox is not a function"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40698190/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com