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:1, focus:200, distance:50});
camera.panAngle = -180;
camera.tiltAngle = 15;
camera.hover(true);
camera.yfactor = 1;
var view:View3D = new View3D({scene:scene, camera:camera, renderer:Renderer.BASIC}); // CORRECT_Z_ORDER / BASIC
// add viewport to the stage
addChild(view);
// position camera and adjust view
view.x = 250;
view.y = 200;
var globe:Sphere = new Sphere({material:"blue#white",radius:150,segmentsH:34, segmentsW: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_FRAME, onEnterFrame);
stage.addEventListener(MouseEvent.MOUSE_DOWN, MouseDown);
stage.addEventListener(MouseEvent.MOUSE_UP, MouseUp);
// 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(0xFFFFFF, 0.4, 15, 15, 2, 1, false, false));
globe.ownCanvas=true;
globe.filters=myFilter2;
var locations =new Array();
locations.push(["Turkey", 38.963745, 35.243322]);
for(var i=0; i<locations.length; i++)
{
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:10, height:10, depth:10});
marker.x = (earthRadius + 5) * Math.sin(phi) * Math.cos(theta);
marker.z = (earthRadius + 5) * Math.sin(phi) * Math.sin(theta);
marker.y = (earthRadius + 5) * Math.cos(phi);
marker.lookAt(new Vector3D(0, 0, 0));
//marker.lookAt(new Number3D(0, 0, 0));
scene.addChild(marker);
}
view.render();