LineSegment sometimes disappear?

Software: Away3D 4.x

eric.lin, Newbie
Posted: 28 March 2012 08:20 AM   Total Posts: 2

Hi,

I’m using the latest version at git.
I add some lines and a cube in the scene, the hover camera looking at the cube. The cube is moving, the camera is panning. 5 seconds later, all line segments disappear, including the lines in Trident object. How did that happen? Any ideas to fix it?

Thanks.

btw, sorry for my poor english.

The code:

package
{
 import away3d
.cameras.Camera3D;
 
import away3d.containers.Scene3D;
 
import away3d.containers.View3D;
 
import away3d.controllers.HoverController;
 
import away3d.debug.AwayStats;
 
import away3d.debug.Trident;
 
import away3d.entities.Mesh;
 
import away3d.entities.SegmentSet;
 
import away3d.materials.ColorMaterial;
 
import away3d.primitives.CubeGeometry;
 
import away3d.primitives.LineSegment;
 
 
import flash.display.Sprite;
 
import flash.display.StageAlign;
 
import flash.display.StageScaleMode;
 
import flash.events.Event;
 
import flash.geom.Vector3D;
 
 
[SWF(backgroundColor="#000000"frameRate="30"width="1000"height="500")]
 
public class CurveTest extends Sprite
 {
  
protected var __scene:Scene3D;
  protected var 
__camera:Camera3D;
  protected var 
__view:View3D;
  protected var 
__cameraController:HoverController;
  
  private var 
__cube:Mesh;
  
  public function 
CurveTest()
  
{
   stage
.align StageAlign.TOP_LEFT;
   
stage.scaleMode StageScaleMode.NO_SCALE
   
   
initEngine();
   
initObjects();
   
initListeners();
  
}
  
private function initEngine():void
  {
   __scene
=new Scene3D();
   
   
__camera=new Camera3D();
   
__camera.lens.far=20000;
   
   
__view=new View3D();
   
__view.antiAlias=4;
   
__view.scene=__scene;
   
__view.camera=__camera;
   
   
__cameraController = new HoverController(__cameranull0151000090);
   
this.addChild(__view);
   
   
this.addChild(new AwayStats(__view));
  
}
  
private function initListeners():void
  {
   this
.addEventListener(Event.ENTER_FRAMEenterFrameHandler);
  
}
  
private function initObjects():void
  {
   __scene
.addChild(new Trident());
   
   
__cube=new Mesh(new CubeGeometry, new ColorMaterial(0xFF0000.8));
   
__scene.addChild(__cube);
   
__cameraController.lookAtObject=__cube;
   
   var 
lineSet:SegmentSet=new SegmentSet();
   
__scene.addChild(lineSet);
   var 
i:int=50;
   while(
i--)
   
{
    
var color:uint=uint("0x"+(Math.random()*0xffffff).toString(16));
    
lineSet.addSegment(new LineSegment(getRandomVector3D(), getRandomVector3D(), colorcolor));
   
}
  }
  
private function enterFrameHandler(event:Event):void
  {
   __view
.render();
   
__cameraController.panAngle++;
   
   
__cube.x+=3;
   
__cube.z+=3;
  
}
  
private function getRandomVector3D():Vector3D
  {
   
return new Vector3D(Math.random()*5000-2500Math.random()*5000-2500Math.random()*5000-2500);
  
}
 }
   

laurent, Newbie
Posted: 30 March 2012 09:46 AM   Total Posts: 29   [ # 1 ]

Hi Eric,

I had a similar issue because SegmentSet doesn’t compute its bound.

override protected function updateBounds():void {
   
// todo: fix bounds
   
_bounds.fromExtremes( -100, -1000100100);
   
_boundsInvalid false;
  

Thus the segments get culled if these bounds is out of the camera view.
Try to hardcode bigger values or compute actual bounds to see if it solve your issue.

 

   

eric.lin, Newbie
Posted: 30 March 2012 11:31 AM   Total Posts: 2   [ # 2 ]

@ laurent

Awesome! Issue solved! Thank you so much, Laurent.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X