【发布时间】:2020-03-31 07:32:01
【问题描述】:
我在 ember cli 框架中使用 x3d。在旧版本的 ember 框架中,一切运行良好。我最近更新了 ember.js。在 ember.js 更新之后,从 ember 应用程序开始在 x3d 场景中显示 idexedfaceset 或 indexedlineset 是没有问题的。但是现在在应用程序完全加载后,在场景中添加 idexedfaceset 或 indexedlineset 存在问题。例如看下面的代码。如果通过单击按钮将显示值设置为 true,则应用程序会抛出错误:
未捕获的 TypeError: Cannot read property 'getPoints' of null at
x3dom.registerNodeType.defineClass.nodeChanged.nodeChanged (x3dom-full.js:4596)
我了解错误表明在 x3d 检测到添加节点并尝试渲染它的那一刻缺少坐标标记。之后我检查了 html 代码,坐标标记在它应该在的位置。但是该元素不会显示在 x3d 场景中。添加坐标标签似乎有短暂的延迟。
我知道可以使用 $("#scene").append("...") 之类的 jquery 逗号来显示元素。但我想使用 ember 行为,因为我更喜欢计算位置和尺寸。
如果有人可以帮助解决问题,我会很高兴。非常感谢。
//application.hbs
{{#if this.display}}
<transform>
<shape def="" ispickable="0" bboxsize="-1,-1,-1" bboxcenter="0,0,0" render="true">
<appearance sorttype="auto" alphaclipthreshold="0.1">
<material specularcolor="0,0,0" shininess="0.2" emissivecolor="0,0,0" ambientintensity="0.2" transparency="0.5" diffusecolor="0 0 1">
</material>
</appearance>
<indexedfaceset ccw="true" colorpervertex="false" colorindex=" 0 0 0 0" coordindex="0 3 2 1 0" solid="true" usegeocache="true" lit="true" normalpervertex="true" normalupdatemode="fast" convex="true" >
<coordinate point="-1 0 0, -1 1 0, 1 1 0, 1 0 0"></coordinate>
<color color="0 0 1"></color>
</indexedfaceset>
</shape>
</transform>
{{/if}} ```
【问题讨论】:
-
您认为您可以制作一个 ember-twiddle 或一个小型 github 存储库来重现此特定问题吗?我认为目前共享的内容不足以回答您的问题。不过,我的下意识反应是,在
if块在this.display更改后呈现它的内部块之后,您可能想要运行与dom 交互的代码(即,无论您做什么来初始化x3d)。您可以通过特定的运行循环队列 @987654321@ 安排要执行的函数afterRender来实现此目的@ -
我创建了一个 gitlab 存储库,其中包含应该显示问题的最小 ember 应用程序:link
-
我运行了项目,但没有看到任何错误。您能否更新自述文件并解释应该发生的事情以及如何重现问题:)
-
自述文件已更新。我希望解释足够详细。否则就再问。非常感谢!
-
为了让 x3d 实际渲染形状,我需要做些什么特别的事情吗?我下载项目,运行
npm install或yarn install->ember serve-> 导航到http:127.0.0.1:4200/。我在最新的 chrome 中看不到任何形状,也没有错误。 x3d 元素呈现为.
标签: javascript ember.js x3d