ownCanvas issue

Software: Away3D 3.x

Fergal, Newbie
Posted: 29 August 2011 02:57 PM   Total Posts: 1

I have a sphere / globe with markers placed at various lat/lon points.

If I add a glow to the sphere, the markers appear behind the edges of the globe when rotated.

Using away3d 3.6.

I’ve pieced together the below using various tutorials. First attempt at 3D in flash.

// import the required parts of Away3D
import away3d.containers.*;
import away3d.core.base.*;
import away3d.primitives.*;
import away3d.materials.*;
import away3d.core.utils.Cast;
import away3d.cameras.*;
import away3d.core.render.*;
import away3d.core.math.*;

// import some filters we'll use later
import flash.filters.BitmapFilter;
import flash.filters.BitmapFilterQuality;
import flash.filters.BitmapFilterType;
import flash.filters.GlowFilter;

//navigation variables
var move:Boolean false;
var 
lastPanAngle:Number;
var 
lastTiltAngle:Number;
var 
lastMouseX:Number;
var 
lastMouseY:Number;
var 
skies:Sphere;
var 
earthRadius:Number =  150

// Step 3: Create a view, a Scene, Camera and a sphere

var scene:Scene3D = new Scene3D();
var 
camera:HoverCamera3D = new HoverCamera3D({zoom:1focus:200distance:50});
camera.panAngle = -180;
camera.tiltAngle 15;
camera.hover(true);
camera.yfactor 1;
var 
view:View3D = new View3D({scene:scenecamera:camerarenderer:Renderer.BASIC}); // CORRECT_Z_ORDER / BASIC
// add viewport to the stage
addChild(view);
// position camera and adjust view
view.250;
view.200;


var 
globe:Sphere = new Sphere({material:"blue#white",radius:150,segmentsH:34segmentsW:34});
scene.addChild(globe);


// Step 4: rotate it using the HoverCam
function onEnterFrame(e:Event):void
{
 
// rerender viewport
 
var cameraSpeed:Number 0.3// Approximately same speed as mouse movement.
 
if (move{
  camera
.panAngle cameraSpeed*(stage.mouseX lastMouseX) + lastPanAngle;
  
camera.tiltAngle cameraSpeed*(stage.mouseY lastMouseY) + lastTiltAngle;
 
}
 camera
.hover();  
 
view.render();
 if(
skies)
  
skies.rotationY += .015;
}

function MouseDown(event:MouseEvent):void
{
 lastPanAngle 
camera.panAngle;
 
lastTiltAngle camera.tiltAngle;
 
lastMouseX stage.mouseX;
 
lastMouseY stage.mouseY;
 
move true;
}

function MouseUp(event:MouseEvent):void
{
 move 
false;
}

addEventListener
(Event.ENTER_FRAMEonEnterFrame);
stage.addEventListener(MouseEvent.MOUSE_DOWNMouseDown);
stage.addEventListener(MouseEvent.MOUSE_UPMouseUp);

// Step 5: apply the earth texture
//globe.material = new BitmapMaterial(Cast.bitmap("earthmap2k.jpg"));


// Step 11: add some atmoshphere
var myFilter2:Array = new Array()
myFilter2.push(new GlowFilter(0xFFFFFF0.4151521falsefalse));
globe.ownCanvas=true;
globe.filters=myFilter2;


var 
locations =new Array();
locations.push(["Turkey"38.96374535.243322]);

for(var 
i=0i<locations.lengthi++)
{
 
var phi:Number = (90 locations[i][1]) * Math.PI/180;
 var 
theta:Number = (locations[i][2] 180) * Math.PI/180;
 
//var marker:Cone = new Cone({material:"red#red",heigth:10,radius:10});
 
var marker:Cube = new Cube({width:10height:10depth:10}); 
 
marker.= (earthRadius 5) * Math.sin(phi) * Math.cos(theta); 
 
marker.= (earthRadius 5) * Math.sin(phi) * Math.sin(theta);
 
marker.= (earthRadius 5) * Math.cos(phi);
 
 
marker.lookAt(new Vector3D(000));
 
//marker.lookAt(new Number3D(0, 0, 0));
 
scene.addChild(marker);
}


view
.render(); 
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X