zoukankan      html  css  js  c++  java
  • away3d4.0 基础demo一则

    学3d其实是一件简单的事情,通过一个星期的学习,我了解了下面的几个概念后,就可以上手做东西了,东西很简单,使用away3d做的。但是麻雀虽小五脏俱全。给大家展示一下。


    1.视口
    2.相机
    3.基础模型:立方体,球,圆锥
    4.光照:
    5.材质:

    package
    {
    import away3d.containers.ObjectContainer3D;
    import away3d.containers.View3D;
    import away3d.lights.DirectionalLight;
    import away3d.lights.PointLight;
    import away3d.materials.BitmapMaterial;
    import away3d.materials.ColorMaterial;
    import away3d.materials.DefaultMaterialBase;
    import away3d.materials.SegmentMaterial;
    import away3d.primitives.Cube;

    import flash.display.Sprite;
    import flash.events.Event;
    import flash.geom.Vector3D;

    [SWF(width='500',height='500',frameRate="60")]
    public class Main extends Sprite
    {
    private var view:View3D = new View3D();
    private var cube:Cube;
    [Embed(source='embeds/crossColor.jpg')]
    private var IImage:Class;

    public function Main()
    {
    this.addEventListener(Event.ADDED_TO_STAGE,init);
    }

    private function init(event:Event):void
    {
    this.removeEventListener(Event.ADDED_TO_STAGE,init);

    this.stage.scaleMode = 'noScale';
    this.stage.align = 'top_left';

    view.width = 300;
    view.height = 300;
    view.x = 100;
    view.y = 100;
    view.backgroundColor = 0xcccccc;
    this.addChild(view);

    var light:DirectionalLight = new DirectionalLight();
    light.x = -1000;
    light.y = 1000;
    light.z = -1000;
    var material:BitmapMaterial = new BitmapMaterial(new IImage().bitmapData);
    material.lights = [light];

    cube = new Cube(material,200,200,200);
    view.scene.addChild(cube);
    view.scene.addChild(light);

    this.addEventListener(Event.ENTER_FRAME, _handleEnterFrame);
    }

    private function _handleEnterFrame(ev : Event) : void
    {
    cube.rotationX += 0.5;
    cube.rotationY += 0.5;
    cube.rotationZ += 0.5;
    view.render();
    }
    }
    }



  • 相关阅读:
    并发编程-阻塞队列&JUC常用工具
    并发编程-Condition源码分析&基于Condition实现阻塞队列
    并发编程-ReentrantLock锁源码分析&Condition设计
    并发编程-JMM&ReentrantLock锁以及原理
    数据库操作支持函数
    python内置进制转换函数
    三目运算符
    数据库常见操作
    宏使用汇总
    sort: invalid comparator
  • 原文地址:https://www.cnblogs.com/crkay/p/2236271.html
Copyright © 2011-2022 走看看