Away3D練習1 Plane表示

by siouxcitizen forked from forked from: Away3Dの練習 (diff: 19)
Away3DでPlane表示してみました
♥0 | Line 35 | Modified 2012-01-26 23:54:38 | MIT License
play

ActionScript3 source code

/**
 * Copyright siouxcitizen ( http://wonderfl.net/user/siouxcitizen )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/nyq1
 */

// forked from siouxcitizen's forked from: Away3Dの練習
// forked from ser1zw's Away3Dの練習

package {
  import flash.display.Sprite;
  import flash.events.Event;
  import flash.events.MouseEvent;
  
  import away3d.containers.View3D;
  import away3d.primitives.Plane;
  import away3d.materials.WireColorMaterial;

  [SWF(backgroundColor="#337777")]
  public class HelloAway3D extends Sprite {
    private var view:View3D;
    private var plane:Plane;

    public function HelloAway3D() {
      view = new View3D();
      view.x = stage.stageWidth >> 1;
      view.y = stage.stageHeight >> 1;
      addChild(view);

      var material:WireColorMaterial = new WireColorMaterial();
      material.color = 0xff0000;
      material.wireColor = 0x000000;
      plane = new Plane({width: 150, height: 150});
      plane.material = material;
      plane.bothsides = true;
      plane.rotationX = -90;
      view.scene.addChild(plane);

      addEventListener(Event.ENTER_FRAME, onEnterFrame);
    }

    private function onEnterFrame(e:Event):void {
      view.scene.rotationX = -(stage.mouseY - (stage.stageHeight >> 1));
      view.scene.rotationY = stage.mouseX - (stage.stageWidth >> 1);
      plane.rotationX += 2;
      plane.rotationY += 2;
      view.render();
    }
  }
}

Forked