由于下载不了源码,不过可以自行新建一fla(flash源文件)文件,然后按照下面方法加载图片:
1.把相应图片导入到库中
2.然后把图片转换成影片,并导出去。
3.用导出的名字替换掉(new MovieSkin("images1", false);)images1,就可以运行.
代码:
import sandy.core.data.*;
import sandy.core.group.*;
import sandy.primitive.*;
import sandy.core.*;
import sandy.skin.*;
import sandy.util.Ease;
import sandy.core.transform.*;
import sandy.events.InterpolationEvent;
import sandy.util.*;
import sandy.view.Camera3D;
import flash.display.BitmapData;
var tg:TransformGroup = new TransformGroup();
var rotation:Transform3D = new Transform3D();
var x:Number = 0;
var y:Number = 0;
var z:Number = 0;
var mouseX;
var mouseY;
//图片
var img_usb:BitmapData;
var img_tv:BitmapData;
var img_nav:BitmapData;
var img_dvd:BitmapData;
var img_sett:BitmapData;
var img_bg:BitmapData;
//3d引擎world3d
var world:World3D = World3D.getInstance();
//摄像头
var cam:Camera3D;
var g:Group;
function setUpControls(){
// Mouse controls
Mouse.addListener(this);
onMouseDown = function() {
mousedown = true;
mouseX = _xmouse;
mouseY = _ymouse;
};
onMouseUp = function() {
mousedown = false;
mouseX = _xmouse;
mouseY = _ymouse;
};
}
function camMove():Void
{
if ( mousedown ) {
x += ( _ymouse - mouseY )/10;
y += ( mouseX -_xmouse )/10;
rotation.rot(x, y, z);
tg.setTransform(rotation);
}
if(Key.isDown(Key.UP)) cam.moveUpwards(10);
if(Key.isDown(Key.DOWN)) cam.moveUpwards(-10);
if(Key.isDown(Key.LEFT)) cam.rotateY(3);
if(Key.isDown(Key.RIGHT)) cam.rotateY(-3);
//if(Key.isDown(Key.LEFT)) cam.moveSideways(10);
//if(Key.isDown(Key.RIGHT)) cam.moveSideways(-10);
if(Key.isDown(Key.HOME)) cam.moveForward(10);
if(Key.isDown(Key.END)) cam.moveForward(-10);
if(Key.isDown(Key.ENTER))
{
//trace(22);
}
cam.lookAt(0, 0, 0);
}
function init():Void
{
cam = new Camera3D( 800, 480 );
g = new Group();
cam.setPosition( -0,0, -1000 );
//cam.lookAt(0,0,0);
world.setCamera( cam );
//监听
world.addEventListener(World3d.onRenderEvent, this, camMove);
setUpControls();
createScene(g);
world.setRootGroup( g );
world.render();
}
function createCoord(bg:Group):Void
{
var xAxis:Object3D = new Line3D( new Vector(-150,0,0), new Vector(150,0,0) );
var yAxis:Object3D = new Line3D( new Vector(0,-150,0), new Vector(0,150,0) );
var zAxis:Object3D = new Line3D( new Vector(0,0,-150), new Vector(0,0,150) );
xAxis.setSkin( new SimpleLineSkin( 1, 0xff0000, 100 ) ); // red
yAxis.setSkin( new SimpleLineSkin( 1, 0x00ff00, 100 ) ); // green
zAxis.setSkin( new SimpleLineSkin( 1, 0x0000ff, 100 ) ); // blue
var coords:Group = new Group();
coords.addChild(xAxis);
coords.addChild(yAxis);
coords.addChild(zAxis);
bg.addChild( coords);
}
function createScene( bg:Group ):Void
{
createCoord(bg);
// 材质
var ts:MovieSkin;
// 平面
var cyl:CylSurface;
var plane_usb:Object3D;
var plane_tv:Object3D;
var plane_dvd:Object3D;
var plane_nav:Object3D;
var plane_set:Object3D;
var tsfor:Transform3D;
ts = new MovieSkin("com", false);
cyl = new CylSurface(100, 100, 360, 6);
//cyl.setSkin( new MixedSkin(0xFEFE4E, 40, 0xFE, 40, 1));
cyl.setSkin(ts);
cyl.setBackSkin(ts);
cyl.enableBackFaceCulling(false);
//cyl.setTransparency(50);
ts = new MovieSkin("images1", false);
plane_usb = new Plane3D(300,400,4,'quad');
plane_usb.setSkin(ts);
plane_usb.setTransparency(50);
plane_usb.enableBackFaceCulling(false);
plane_usb.setBackSkin(ts);
tsfor = new Transform3D();
tsfor.translate(0,100,0);
//tsfor.translateVector(new Vector(100,100,100));
//tsfor.scaleX(200);
//tsfor.rotX(90);
plane_usb.setTransform(tsfor);
ts = new MovieSkin("images2", false);
plane_tv = new Plane3D(300,400,4,'quad');
//ts = new TextureSkin(img_tv);
plane_tv.setSkin(ts);
plane_tv.setTransparency(50);
plane_tv.enableBackFaceCulling(false);
plane_tv.setBackSkin(ts);
tsfor = new Transform3D();
tsfor.translate(0,200,0);
//tsfor.rotY(-90);
plane_tv.setTransform(tsfor);
ts = new MovieSkin("images3", false);
plane_dvd = new Plane3D(300,400,4,'quad');
//ts = new TextureSkin(img_dvd);
plane_dvd.setSkin(ts);
plane_dvd.setTransparency(50);
plane_dvd.enableBackFaceCulling(false);
plane_dvd.setBackSkin(ts);
tsfor = new Transform3D();
tsfor.translate(0,-100,0);
plane_dvd.setTransform(tsfor);
ts = new MovieSkin("images4", false);
plane_nav = new Plane3D(300,400,4,'quad');
//ts = new TextureSkin(img_nav);
plane_nav.setSkin(ts);
plane_nav.setTransparency(50);
plane_nav.enableBackFaceCulling(false);
plane_nav.setBackSkin(ts);
tsfor = new Transform3D();
tsfor.translate(0,-200,0);
plane_nav.setTransform(tsfor);
ts = new MovieSkin("images5", false);
plane_set = new Plane3D(300,400,4,'quad');
//ts = new TextureSkin(img_set);
plane_set.setSkin(ts);
plane_set.setTransparency(50);
plane_set.enableBackFaceCulling(false);
plane_set.setBackSkin(ts);
/*
var tss = new Transform3D();
tsfor = new Transform3D();
var tgs = new TransformGroup();
tss.translate(0,0,100);
tgs.setTransform(tss);
tgs.addChild(plane_set);
tsfor.translate(0,0,100);
plane_set.setTransform(tsfor);
*/
tg.addChild(plane_usb);
tg.addChild(plane_tv);
tg.addChild(plane_dvd);
tg.addChild(plane_nav);
tg.addChild(plane_set);
//tg.addChild(tgs);
//tg.addChild(cyl);
bg.addChild(tg);
}
init();
源码地址:下载