Is this a bug or am I doing something wrong?

Software: Away3D 4.x

Avatar
Bob Klein, Newbie
Posted: 16 August 2012 04:27 PM   Total Posts: 17

The attached swf and source code illustrates a problem that I have with a Mesh object that is mouse enabled.  It seems that the entire rectangular area around this polygon Mesh triggers the MouseEvent3D and not just the actual area of the polygon.  The cursor should not change when over the whitespace but it does change in the white corner areas of this cross object.

Am I just doing something screwy here or is this a bug?

thanks,
...bob klein…

p.s. I am using the downloaded swc file for 4.0.7 gold (8/1/12)

Here is the complete source code:

package
{
 import away3d
.containers.View3D;
 
import away3d.materials.ColorMaterial;
 
import away3d.entities.Mesh;
 
import away3d.core.base.Geometry;
 
import away3d.core.base.SubGeometry;
 
import away3d.tools.helpers.FaceHelper;
 
import away3d.core.base.data.UV;
 
import away3d.core.base.data.Vertex;
 
import away3d.events.MouseEvent3D;

 
import flash.events.Event;
 
import flash.ui.Mouse;
 
import flash.ui.MouseCursor;
 
 
import flash.display.Sprite;
 
 
[SWF(width="500"height="400"backgroundColor="#FFFF00")]

 
public class bug extends Sprite
 {
  
private var view:View3D;

  public function 
bug()
  
{
   
var mesh:Mesh;

   var 
triangles_array:Array = new Array(
    
0,0,100,0,100,100,
    
0,0,100,100,0,100,
    
100,-100,200,-100,200,200,
    
100,-100,200,200,100,200,
    
200,0,300,0,300,100,
    
200,0,300,100,200,100
    
);

   
view = new View3D();
   
view.width 400;
   
view.height 300;

                 
view.50;
                 
view.50;
   
view.backgroundColor 0xffffff;

   
addChild(view);

   
mesh polygon_mesh(
                            new 
ColorMaterial(0xff0000,1.0),
                            
triangles_array,0);
   
mesh.= -150;
   
mesh.25;
   
   
mesh.mouseEnabled true;

   
mesh.addEventListener(MouseEvent3D.MOUSE_OVER,
                                                
mouse_over);
   
mesh.addEventListener(MouseEvent3D.MOUSE_OUT,
                                                
mouse_out);

   
view.scene.addChild(mesh);

   
addEventListener(Event.ENTER_FRAME,render);
  
}

  
private function render e:Event ):void
  {
   view
.render();
  
}

  
private function polygon_mesh matColorMaterial,
      
triangles:Array,
      
z:int ):Mesh
  {
   
var rval:Mesh;
   var 
i:int;
   var 
g:Geometry;
   var 
sg:SubGeometry;
   var 
uv:UV = new UV(); // don't care about UVs here...

   
sg = new SubGeometry();
   
sg.autoDeriveVertexTangents true;
   
sg.autoDeriveVertexNormals true;
   
sg.autoGenerateDummyUVs true;

   
= new Geometry();
   
g.addSubGeometry(sg);

   
rval = new Mesh(g,mat);

   
0;

   while (
triangles.length{
    
var v0:Vertex;
    var 
v1:Vertex;
    var 
v2:Vertex;

    
v0 = new Vertex(triangles[i],triangles[i+1],z);
    
v1 = new Vertex(triangles[i+2],triangles[i+3],z);
    
v2 = new Vertex(triangles[i+4],triangles[i+5],z);

    
FaceHelper.addFace(rval,v0,v1,v2,uv,uv,uv,0);

    
FaceHelper.addFace(rval,v0,v2,v1,uv,uv,uv,0);

    
+= 6;
    
};

   return 
rval;
  
}

  
private function mouse_over e:MouseEvent3D ):void
  {
   Mouse
.cursor MouseCursor.BUTTON;
  
}

  
private function mouse_out e:MouseEvent3D ):void
  {
   Mouse
.cursor MouseCursor.ARROW;
  
}
 }

 

 

File Attachments
bug.swf  (File Size: 92KB - Downloads: 239)
   

John Wilson, Member
Posted: 16 August 2012 04:39 PM   Total Posts: 62   [ # 1 ]

Hi,

If you are using the latest Gold release, you might solve it by adding:

import away3d.core.pick.*;
.
.
.
view.mousePicker PickingType.RAYCAST_BEST_HIT
   

Avatar
Bob Klein, Newbie
Posted: 16 August 2012 05:05 PM   Total Posts: 17   [ # 2 ]

Hi John!

Thanks for the help!  I tried all of the PickingType values and the only one that works is PickingType.SHADER.  I then went back to my real application code and tried that and it seems to work!

However, the comment on the documentation for PickingType.SHADER has me concerned if I am going to be causing a serious performance problem by doing this.  Does anyone have any opinions on whether or not this will be a problem?

thanks again,
...bob klein…

   

John Wilson, Member
Posted: 16 August 2012 07:14 PM   Total Posts: 62   [ # 3 ]

Hi,

It may have an impact on mobile applications, but it seems fine in a swf with 134 awd files imported (some of which are quite complex).

   

Avatar
Bob Klein, Newbie
Posted: 16 August 2012 09:00 PM   Total Posts: 17   [ # 4 ]

Unfortunately setting the view.mousePicker in my application code has caused other problems.  My application will destroy a view (and dispose of everything along with it) and create a new view later on.  Everytime I create a subsequent new view3d the mouse events never fire again for anything.  I will try to recreate this problem in my sample and will post a new thread…

sigh,
...bob klein…

   

Richard Olsson, Administrator
Posted: 17 August 2012 07:37 AM   Total Posts: 1192   [ # 5 ]

It’s not the View3D.mousePicker property that you should be changing. You might want to have it set to SHADER in some cases, but if the problem is just what you’re describing, the best way to “solve” it is to reconfigure the Mesh.pickingCollider property. Use one of the values from away3d.core.pick.RaycastPicker that is not BOUNDS_ONLY. This default value will only do a bounds check, which means that if your object is configured to use a bounding box (default, as opposed to bounding spheres) the behavior that you are describing is the expected.

   

Avatar
Bob Klein, Newbie
Posted: 17 August 2012 04:06 PM   Total Posts: 17   [ # 6 ]

Richard,

Thank you for your help!

Your suggestion solved my problem completely and the software is working as expected.  Your support is appreciated! grin

...bob klein…

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X