You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用AggregatedView选择自定义几何体时出现container未定义错误

自定义几何体在AggregatedView中选中时循环抛出Uncaught TypeError: container is undefined错误

问题场景

  • 基于官方自定义几何体示例创建模型,使用AggregatedView时,选中自定义几何体就会循环抛出Uncaught TypeError: container is undefined错误
  • 直接实例化GuiViewer3D时无此问题
  • 使用版本:Forge Viewer 7.80

错误栈信息

Uncaught TypeError: container is undefined
  getFragmentConsolidationType ConsolidationIterator.js:398
    updateRenderProxy ConsolidationIterator.js:416
    updateRenderProxy RenderModel.js:973
    updateSelectionProxies Viewer3DImpl.js:2145
    renderOverlays Viewer3DImpl.js:2152
    cmdRenderOverlays Viewer3DImpl.js:1330
    executeCommandList Viewer3DImpl.js:913
    tick Viewer3DImpl.js:1908
    animloop Viewer3DImpl.js:1939

原因与解决方案

这是Forge Viewer 7.x版本中AggregatedView与自定义几何体交互的已知问题,核心是自定义模型的渲染代理在AggregatedView环境下未正确关联容器上下文。

可通过以下方式解决:

  1. 升级Viewer版本:建议升级到7.81及以上版本,Autodesk在后续版本中修复了该AggregatedView的容器上下文绑定问题
  2. 手动补全容器上下文:如果暂时无法升级,可在自定义几何体模型初始化后,手动为模型的container属性赋值为Viewer的容器元素:
// 示例代码
customModel.container = viewer.container;
  1. 规避选择逻辑:若无需选中自定义几何体,可通过viewer.select([])清空选中状态,或在自定义模型初始化时添加noSelect: true属性,跳过选择代理更新流程

内容的提问来源于stack exchange,提问作者Adrian

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.13 01:45:34