flash on 2012-10-18
♥0 |
Line 41 |
Modified 2012-10-23 15:42:51 |
MIT License
archived:2017-03-20 05:31:46
ActionScript3 source code
/**
* Copyright chez_sugi ( http://wonderfl.net/user/chez_sugi )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/rdOz
*/
package {
import alternativ7.engine3d.core.Camera3D;
import alternativ7.engine3d.core.Object3DContainer;
import alternativ7.engine3d.core.View;
import alternativ7.engine3d.materials.FillMaterial;
import alternativ7.engine3d.primitives.Box;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
[SWF(backgroundColor=0, frameRate=60)]
public class Alternativa3D_01 extends Sprite {
private var rootContainer:Object3DContainer = new Object3DContainer();
private var camera:Camera3D;
private var box:Box;
public function Alternativa3D_01() {
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
camera = new Camera3D();
camera.view = new View(stage.stageWidth, stage.stageHeight);
addChild(camera.view);
//右上に出るやつ
addChild(camera.diagram);
camera.rotationX = -120*Math.PI/180;
camera.y = -1600;
camera.z = 800;
rootContainer.addChild(camera);
//Cubeの生成。大きさと分割数を指定
box = new Box(500, 500, 500, 3, 3, 3);
//テクスチャの生成。色、透明度、線の太さ、色を指定
var material:FillMaterial = new FillMaterial(0xFF, 0.5, 2, 0xFF00);
//Cubeの全面にテクスチャを張る。
box.setMaterialToAllFaces(material);
rootContainer.addChild(box);
stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(e:Event):void {
camera.view.width = stage.stageWidth;
camera.view.height = stage.stageHeight;
box.rotationZ -= 0.01;
box.rotationX += 0.01;
camera.render();
}
}
}