I'm looking to start selling my textures online from my web site. I
had the notion to include an away3d based texture viewer in to the web
site so potential customers could view the textures with normal and
specular maps applied to the models. I wanted to use Away3d for this
since most people have flash, I figured it would be an easy task.
The long and short of it is that I can successfully load the textures
into the viewer with this code here. The cube will show, but the
directional light does nothing at all.
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.display.Bitmap;
import away3d.cameras.*;
import away3d.core.math.Number3D;
import away3d.core.render.Renderer;
import away3d.core.utils.Cast;
import away3d.lights.DirectionalLight3D;
import away3d.containers.View3D;
import away3d.primitives.Cube;
import away3d.materials.BitmapMaterial;
import away3d.materials.BitmapFileMaterial;
//import away3d.core.utils.Cast;
public class ExBitmapFileMaterial extends Sprite
{
private var viewport:View3D;
private var cube:Cube;
public var diffuseMaterial:BitmapFileMaterial;
public var light:DirectionalLight3D;
public function ExBitmapFileMaterial()
{
viewport = new View3D({x:512, y:512});
addChild(viewport);
diffuseMaterial = new BitmapFileMaterial("http://www.binxalot.com/
Texturama/lichen-and-stone.jpg");
cube = new Cube({x:-150, y:+150, z:0, width:150, height:150, depth:
150, material:diffuseMaterial});
viewport.scene.addChild(cube);
light = new DirectionalLight3D({color:0xFFFFFF, ambient:0.25,
diffuse:0.75, specular:0.85});
light.direction = new Number3D(40000,-40000,40000);
viewport.scene.addLight(light);
// viewport.scene.addChild(light);
this.addEventListener(Event.ENTER_FRAME, renderThis);
}
private function renderThis(e:Event):void {
cube.rotationX +=1;
cube.rotationY -=1;
cube.rotationZ +=1;
viewport.camera.z = -400;
viewport.render();
}
}
}
I thought I could do this to get the normal mapped material (I
declared the vars ahead of time):
---
diffuseMaterial = new BitmapFileMaterial("http://www.binxalot.com/
Texturama/lichen-and-stone.jpg");
normalMaterial = new BitmapFileMaterial("http://www.binxalot.com/
Texturama/lichen-and-stone_bump.jpg");
cubeNormalMaterial = new
Dot3BitmapMaterial(Cast.bitmap(diffuseMaterial),
Cast.bitmap(normalMaterial));
cube.material = cubeNormalMaterial;
---
But this does nothing, all I get is a blank screen. Is it possible to
apply a dot3 material to an away3d object using textures from a URL?
If so how can it be done, in addition, is it possible to apply a
directional 3d light to the object once the texture is applied? I
tried looking through the tutorials on the flash magazine tutorial
site but there is nothing about this particular method of loading
textures involved.
I would like the ability to load the urls via flashvars and have the
3d cube automatically show up with the texture when the user clicks on
a web link. Does anyone have any solutions for this? Is it even
supported?