Skip to content
Browse files

Amended EnvMapTest to work with new load framework

  • Loading branch information...
1 parent 8d941b6 commit 88c0f7be88042f7240f58a95506e1c614b092237 @rob-bateman rob-bateman committed
Showing with 17 additions and 16 deletions.
  1. +17 −16 src/EnvMapTest.as
View
33 src/EnvMapTest.as
@@ -1,16 +1,14 @@
package
{
- import away3d.containers.ObjectContainer3D;
import away3d.containers.View3D;
import away3d.debug.AwayStats;
import away3d.entities.Mesh;
- import away3d.events.ResourceEvent;
+ import away3d.events.LoadingEvent;
import away3d.lights.PointLight;
- import away3d.loading.ResourceManager;
+ import away3d.loaders.Loader3D;
+ import away3d.loaders.misc.AssetLoaderContext;
+ import away3d.loaders.parsers.OBJParser;
import away3d.materials.BitmapMaterial;
- import away3d.materials.ColorMaterial;
- import away3d.materials.methods.EnvMapAmbientMethod;
- import away3d.materials.methods.EnvMapDiffuseMethod;
import away3d.materials.methods.EnvMapMethod;
import away3d.materials.methods.FresnelSpecularMethod;
import away3d.materials.utils.CubeMap;
@@ -30,12 +28,12 @@ package
{
private var _view : View3D;
- private var _container : ObjectContainer3D;
+ private var _loader : Loader3D;
private var _yellowLight : PointLight;
private var _blueLight : PointLight;
[Embed(source="/../embeds/head/head.obj", mimeType="application/octet-stream")]
- private var OBJ : Class;
+ private var OBJData : Class;
[Embed(source="/../embeds/head/Images/Map-COL.jpg")]
private var Albedo : Class;
@@ -134,11 +132,14 @@ package
_camController = new HoverDragController(_view.camera, stage);
addChild(new AwayStats(_view));
- ResourceManager.instance.addEventListener(ResourceEvent.RESOURCE_RETRIEVED, onResourceRetrieved);
- _container = ObjectContainer3D(ResourceManager.instance.parseData(new OBJ(), "head", true));
- _container.scale(100);
+ Loader3D.enableParser(OBJParser);
+
+ _loader = new Loader3D();
+ _loader.addEventListener(LoadingEvent.RESOURCE_COMPLETE, onResourceComplete);
+ _loader.parseData(OBJData, null, new AssetLoaderContext(false));
+ _loader.scale(100);
- _view.scene.addChild(_container);
+ _view.scene.addChild(_loader);
_view.scene.addChild(_yellowLight);
_view.scene.addChild(_blueLight);
_view.scene.addChild(new SkyBox(_envMap));
@@ -178,10 +179,10 @@ package
Signature.y = stage.stageHeight - Signature.height;
}
- private function onResourceRetrieved(ev : ResourceEvent) : void
+ private function onResourceComplete(ev : LoadingEvent) : void
{
var mesh : Mesh;
- var len : uint = _container.numChildren;
+ var len : uint = _loader.numChildren;
var material : BitmapMaterial = new BitmapMaterial(new Albedo().bitmapData);
// var material : ColorMaterial = new ColorMaterial(0xffffff);
// material.normalMap = new Normals().bitmapData;
@@ -196,7 +197,7 @@ package
material.specularMap = new Specular().bitmapData;
for (var i : uint = 0; i < len; ++i) {
- mesh = Mesh(_container.getChildAt(i));
+ mesh = Mesh(_loader.getChildAt(i));
mesh.material = material;
}
initControls();
@@ -205,7 +206,7 @@ package
private function _handleEnterFrame(ev : Event) : void
{
- _container.rotationY += .5;
+ _loader.rotationY += .5;
//_ctr.rotationX = 20 * Math.sin(getTimer() * 0.002);
_view.render();
}

0 comments on commit 88c0f7b

Please sign in to comment.
Something went wrong with that request. Please try again.