In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

flash on 2011-1-17

Alternativa3D "Hello world!" application. 
Создание простейшего трёхмерного приложения.
Get Adobe Flash player
by flymacmail 23 Oct 2012
    Embed
/**
 * Copyright flymacmail ( http://wonderfl.net/user/flymacmail )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/PxQ3
 */

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;
    /**
     * Alternativa3D "Hello world!" application. 
     * Создание простейшего трёхмерного приложения.
     */
    public class HelloAlternativa3D extends Sprite {

        private var rootContainer:Object3DContainer = new Object3DContainer();
                
        private var camera:Camera3D;        

        private var box:Box;
        
        public function HelloAlternativa3D() {
            stage.align = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE;            

            // Camera and view
            // Создание камеры и вьюпорта
            camera = new Camera3D();
            camera.view = new View(stage.stageWidth, stage.stageHeight);
            addChild(camera.view);
            addChild(camera.diagram);

            // Initial position
            // Установка положения камеры
            camera.rotationX = -120*Math.PI/180;
            camera.y = -800;
            camera.z = 400;
            rootContainer.addChild(camera);

            // Primitive box
            // Создание примитива
            box = new Box(500, 500, 500, 5, 5, 5);
            var material:FillMaterial = new FillMaterial(0xFF7700, 1, 1);
            box.setMaterialToAllFaces(material);
            rootContainer.addChild(box);
            
            // Listeners
            // Подписка на события
            stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
        }
        

        private function onEnterFrame(e:Event):void {

            // Width and height of view

            // Установка ширины и высоты вьюпорта

            camera.view.width = stage.stageWidth;

            camera.view.height = stage.stageHeight;

            

            // Rotation

            // Вращение примитива

            box.rotationZ -= 0.01;

            

            // Render

            // Отрисовка

            camera.render();

        }
    }
}