Papervision 3d hitTestObject 不起作用?
我是 papervision 3d 的新手,我在基本视图中创建了两个显示对象。
这是代码的一部分:
...
_stick = new Cube(materials, 50, 5, 500);
_ball = new Sphere(new ColorMaterial(0xfc0000), 80);
在 onRenderTick 方法中,我尝试检查两个对象是否被击中,
override protected function onRenderTick(event:Event=null):void {
super.onRenderTick(event);
_stick.rotationY = stage.mouseX / stage.width * 360;
_stick.rotationX = stage.mouseY / stage.height * 360;
if (stick.hitTestObject(this.ball)) {
trace ("hit");
}
}
但是,即使棍子确实击中了物体,stick.hitTestObject 也始终返回 false正如我在闪光中看到的球。
任何帮助表示赞赏〜 谢谢!
I'm new to papervision 3d and I created two display objects in basic view.
Here's a part of the code :
...
_stick = new Cube(materials, 50, 5, 500);
_ball = new Sphere(new ColorMaterial(0xfc0000), 80);
In the onRenderTick
method, I tried to check whether two objects are hitted
override protected function onRenderTick(event:Event=null):void {
super.onRenderTick(event);
_stick.rotationY = stage.mouseX / stage.width * 360;
_stick.rotationX = stage.mouseY / stage.height * 360;
if (stick.hitTestObject(this.ball)) {
trace ("hit");
}
}
However, stick.hitTestObject
always returns false even if the stick really hits the ball as I see in the flash.
Any help is appreciated ~
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
很久以前,我通过使用在 P3D 中某处找到的 API 解决了类似的问题,该 API 可将 3D 坐标转换为 2D(屏幕)坐标。因此,我在 3D 视觉效果顶部添加了一个常规按钮,并且每一帧我都将该按钮移动到 3D 命中区域的屏幕位置中心。但这之所以有效,是因为我不需要变换命中区域 - 我从未在 Papervision3D 中获得“真正的”3D 命中区域。由于该项目显然是孤立的,因此如果您可以帮助的话,我不建议您花费大量时间。
A long while back I worked around a similar issue by using an API I found somewhere in P3D that transforms from 3D to 2D (screen) coords. So I added a regular button on top of the 3D visuals, and each frame I moved the button to center on the screen location of the 3D hit area. But this only worked because I didn't need the hit area to transform - I never got "real" 3D hit areas to work in Papervision3D. And since that project is apparently orphaned, I wouldn't suggest spending a great deal of time on it if you can help it.