这很难理解,我正在使用当前的 xml3D.js 版本 5.2。
我使用 *BoundingBox() 函数来简化资产和相机的定位。内容已正确加载,错误出现在取消xml3D 资产文件。它有什么特定于 xml3D 资产的吗?
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 不是函数。(在 'this.renderNode.getObjectSpaceBoundingBox(bbox)' 中,'this.renderNode.getObjectSpaceBoundingBox' 未定义)