Away3D 中鼠标与嵌套影片剪辑的交互
我正在与各国一起建造一个地球仪。我已经构建了所有球体并且一切正常。问题是为了让地球仪看起来正确,我必须将所有影片剪辑放入一个大的移动剪辑中,然后从那里分解。问题是我无法让 Away3D 识别辅助影片剪辑。如果我将侦听器应用于整个球体,它可以正常工作(但这不起作用)。有没有办法在away3d中使用嵌套的影片剪辑?
//what works
var materialMovie:MovieClip = new causticsMovie() as MovieClip;
var causticsMaterial:MovieMaterial = new MovieMaterial( materialMovie);
var sphere:Sphere = new Sphere({material:causticsMaterial, radius:300,segmentsH:18,segmentsW:26, interactive:true});
causticsMaterial.interactive = true;
view.scene.addChild(sphere);
sphere.addEventListener(MouseEvent3D.MOUSE_DOWN, NA);
//what doesn't
world_map.northAfrica_mc.addEventListener(MouseEvent3D.MOUSE_DOWN, NA);
这个问题有解决办法吗?
I am building a globe with the countries. I have all of the spheres built and everything works fine. The problem is to get the globe to look right I had to put all of the movieclips into one big moveclip then broke down from there. The problem is I cannot get Away3D to recognize the secondary movieclips. If I apply the listener to the whole sphere it works fine (but that isn't functional). Is there a way to use nested movieclips in away3d?
//what works
var materialMovie:MovieClip = new causticsMovie() as MovieClip;
var causticsMaterial:MovieMaterial = new MovieMaterial( materialMovie);
var sphere:Sphere = new Sphere({material:causticsMaterial, radius:300,segmentsH:18,segmentsW:26, interactive:true});
causticsMaterial.interactive = true;
view.scene.addChild(sphere);
sphere.addEventListener(MouseEvent3D.MOUSE_DOWN, NA);
//what doesn't
world_map.northAfrica_mc.addEventListener(MouseEvent3D.MOUSE_DOWN, NA);
Is there a solution to this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我了解 Flash 中的 3D 引擎通常如何工作,这将是不可能的。他们从原始影片剪辑创建纹理,然后对其进行转换。因此没有可供点击的影片剪辑。
我认为有几种方法可以解决这个问题。您可以将点击位置转换为极坐标(我不确定那里的数学,但谷歌应该会有所帮助),并找出以这种方式点击的位置。
或者,你可以(可能)有第二个看不见的球体(在舞台外或小时候没有添加,不确定哪个会起作用),你可以在其中创建不同的纹理,其中每个国家都有不同的颜色。您可以将其旋转到与可见球体相同的角度。然后,单击时,将其渲染为 BitmapData 并检查单击点的像素值(进行转换,以便可见球体和不可见球体上的点相同)。我认为这种方式是两种方式中比较容易的一种,并且会得到更好的结果。
If I understand how 3d engines in flash generally work, this won't be possible. They create a texture from the original movieclip(s) which they then transform. So there are no movieclips left to click on.
There is a couple of ways around this I think. You could transform the click location into polar coordinates (I'm not sure about the maths there, but google should be helpful), and figure out which location was clicked that way.
Or, you could (probably) have a second, invisible sphere (off stage or not added as a child, not sure which will work), where you create a different texture where each country has a different color. You would rotate this to the same angles as the visible sphere. Then, on click, render that to a BitmapData and check the pixel value of the point you clicked (translated so the point on the visible sphere and the invisible sphere are the same). I think this way is the easier of the two, and will have better results.