Is this a bug or am I doing something wrong? - Chapter Two

Software: Away3D 4.x

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

Continuing from my last posting…

I set view.mousePicker to solve my original problem.  However whenever I dispose of that view and create a new view nothing ever gets a mouse event again.  Below is the complete source code that illustrates the problem.  Move the mouse over the cross in the first ten seconds and see the cursor change.  After ten seconds you will see a new view (with different colors) and note that the mouse never gets an event again….  Any ideas?

thanks,
...bob klein…

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 away3d.core.pick.PickingType;

 
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()
  
{
   initView
(0xffff00,0xff0000);

   
stage.frameRate = 50;

   
addEventListener(Event.ENTER_FRAME,render);
  
}

  
private function initView ( bg:uint, fg:uint ):void
  {
   
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.x = 50;
                 
view.y = 50;
   
view.backgroundColor = bg;

   
view.mousePicker = PickingType.SHADER;

   
addChild(view);

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

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

   
view.scene.addChild(mesh);
  
}

  
private var ctr:int = 0;

  private function 
render ( e:Event ):void
  {
   view
.render();
   if (++
ctr == 500) {
    removeChild
(view);
    
view.dispose();
    
initView(0x00ff00,0x0000ff);
    
};
  
}

  
private function polygon_mesh ( mat: ColorMaterial,
      
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;

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

   
rval = new Mesh(g,mat);

   
i = 0;

   while (
i < 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);

    
i += 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: 227)
   

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

Can you try to minimize the code even further (e.g. using a primitive instead of creating your own) and then file a bug at http://github.com/away3d/away3d-core-fp11/issues referencing this thread?

   

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

Done!

Problem example minimized to use a PlaneGeometry and posted to github:


Issue #390
Setting view.MousePicker disables MouseEvents on subsequent view creations

by rmklein a minute ago

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X