Hi,
Here is my problem:
I have 3 class: Main.as, Class3dEngine.as, Class3dLight.as.
Main () calls the two other class.
Class3dEngine () generates the scene, the camera view and
Class3dLight () generates the lights
I want to insert the light in my scene.
In Class3dLight () I wanted to make a scene.addChild (light) but I can not do it.
Here are my files
Main.as
package
{
import flash.display.*;
import flash.events.Event;
public class Main extends Sprite
{
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
//Engine
var InClass3dEngine : Class3dEngine = new Class3dEngine();
addChild(InClass3dEngine);
//Light
var InClass3dLight : Class3dLight = new Class3dLight();
addChild(InClass3dLight);
}
}
}
Class3dEngine.as
package
{
import flash.display.*;
import flash.events.*;
import away3d.library.*;
import away3d.library.assets.*;
import away3d.cameras.Camera3D;
import away3d.containers.Scene3D;
import away3d.containers.View3D;
import away3d.controllers.HoverController;
import away3d.loaders.parsers.*;
import away3d.debug.*;
public class Class3dEngine extends Sprite
{
//engine variables
public var scene:Scene3D;
public var camera:Camera3D;
public var view:View3D;
public var cameraController:HoverController;
public function Class3dEngine()
{
//Base
Parsers.enableAllBundled();
//Creation d'une nouvelle scene
scene = new Scene3D();
//Initialisation de la camera
camera = new Camera3D();
camera.lens.far = 2100;
//Initialisation de la vue
view = new View3D();
view.scene = scene;
view.camera = camera;
//setup controller to be used on the camera
cameraController = new HoverController(camera, null, 45, 20, 1000, 10);
//on affiche la vue
addChild(view);
//Affichage des stats
addChild(new AwayStats(view));
}
}
}
Class3dLight.as
package
{
import flash.display.Sprite;
import flash.geom.Vector3D;
import away3d.lights.DirectionalLight;
import away3d.materials.lightpickers.StaticLightPicker;
public class Class3dLight extends Sprite
{
public var light:DirectionalLight;
public var lightPicker:StaticLightPicker;
public var direction:Vector3D;
public function Class3dLight()
{
light = new DirectionalLight(-1, -1, 1);
direction = new Vector3D(-1, -1, 1);
lightPicker = new StaticLightPicker([light]);
addChild(light);
}
}
}
Thank you,
Kevin