Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
package {
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Point;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.view.Viewport3D;
import org.papervision3d.cameras.Camera3D;
import org.papervision3d.render.BasicRenderEngine;
import org.papervision3d.objects.primitives.*;
import org.papervision3d.materials.*;
import org.papervision3d.materials.special.CompositeMaterial;
import org.papervision3d.core.math.Matrix3D;
import org.papervision3d.materials.utils.MaterialsList;
public class Papervision3DImage extends Sprite {
private var scene:Scene3D;
private var viewport:Viewport3D;
private var camera:Camera3D;
private var renderer:BasicRenderEngine;
private var cube:Cube;
public function Papervision3DImage() {
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.frameRate = 30;
init();
}
private function init():void {
// viewport
viewport = new Viewport3D(0,0,true);
viewport.opaqueBackground = 0xFFFFFF;
addChild(viewport);
// renderer
renderer = new BasicRenderEngine();
// camera
camera = new Camera3D();
camera.focus = 500;
camera.zoom = 1;
// scene
scene = new Scene3D();
// object
cube = new Cube(getMaterialsList(), 350, 350, 350, 1, 1, 1);
scene.addChild(cube);
// event
addEventListener(Event.ENTER_FRAME, onEnerFrameHandler);
}
private function getMaterialsList():MaterialsList {
// BitmapFileMaterial
var material1:BitmapMaterial = new BitmapMaterial(new Mario(100, 100));
//var material1:BitmapFileMaterial = new BitmapFileMaterial("./mario1.gif");
return new MaterialsList({
front :material1
,back :material1
,right :material1
,left :material1
,top :material1
,bottom:material1
});
}
private function onEnerFrameHandler(evt:Event):void{
// 普通に回転
cube.rotationX += 1;
cube.rotationY += 2;
renderer.renderScene(scene,camera,viewport);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment