如何获得away3D中的顶级孩子?
我有一个关于away3D 的小问题。我有一些尺寸完全相同的立方体,它们位于同一位置。当我单击立方体堆栈时,我想注册对我最后添加的立方体的单击。与此相反,单击是在我首先添加的多维数据集上注册的。
我找到了一种改变容器中立方体位置的方法,并尝试将元素放在childrenArray的末尾(代码如下)和开头,但似乎没有任何效果。我真的被困在这里了,所以如果有人知道如何在单击堆栈时获取顶级元素,我会很高兴听到。
//We get the targetCube's childIndex.
for(var i:uint = 0; i < _3DContent.children.length; i++)
{
if(_targetCube == _3DContent.children[i])
break;
}
//Now we rearrange the array if the targetCube is different from
//the last cube in our list of children.
if(i != _3DContent.children.length-1)
{
//We reposition the children.
for(var j:uint = i; j < _3DContent.children.length-1; j++)
_3DContent.children[j] = _3DContent.children[j+1];
//Lastly, we push the child.
_3DContent.children[_3DContent.children.length-1] = _targetCube;
}
i have a small question concerning away3D. I have some cubes with the exact same dimensions that are positioned in the same place. When i click on the stack of cubes, i want to register a click on the cube i added last. Instead of doing this, the click is registered on the cube i added first.
I have found a way to alter the cubes position in the container and have tried putting the element at the end (code below) and start of the childrenArray, but nothing seems to work. I am kinda really stuck here, so if anyone knows how to get the top level element when clicking on the stack, i'd be happy to hear.
//We get the targetCube's childIndex.
for(var i:uint = 0; i < _3DContent.children.length; i++)
{
if(_targetCube == _3DContent.children[i])
break;
}
//Now we rearrange the array if the targetCube is different from
//the last cube in our list of children.
if(i != _3DContent.children.length-1)
{
//We reposition the children.
for(var j:uint = i; j < _3DContent.children.length-1; j++)
_3DContent.children[j] = _3DContent.children[j+1];
//Lastly, we push the child.
_3DContent.children[_3DContent.children.length-1] = _targetCube;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过使用不同的渲染器解决了这个问题。创建视图时,您应该将其作为参数传递,如下所示。
I solved the problem by using a different renderer. When creating your view, you should pass this as a parameter, as shown below.