1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Away3D_複数のカメラ

Posted at

package
{

import away3d.cameras.Camera3D;
import away3d.containers.View3D;
import away3d.entities.Mesh;
import away3d.materials.ColorMaterial;
import away3d.primitives.PlaneGeometry;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.geom.Vector3D;
/**
 * ...
 * @author umhr
 */
public class Canvas extends Sprite 
{
	private var _view:View3D;
	private var _view2:View3D;
	private var _mesh:Mesh;
	private var _secondCamera:Camera3D;
	public function Canvas() 
	{
		init();
	}
	private function init():void 
	{
		if (stage) onInit();
		else addEventListener(Event.ADDED_TO_STAGE, onInit);
	}

	private function onInit(event:Event = null):void 
	{
		removeEventListener(Event.ADDED_TO_STAGE, onInit);
		// entry point
		
		stage.scaleMode = StageScaleMode.NO_SCALE;
		stage.align = StageAlign.TOP_LEFT;

		_view = new View3D();
		_view.antiAlias = 2;
		_view.backgroundColor = 0x000000;
		_view.width = stage.stageWidth;
		_view.height = stage.stageHeight;
		addChild(_view);

		_view.camera.z = -1000;
		_view.camera.y = 0;
		_view.camera.lookAt(new Vector3D());
		
		_view2 = new View3D(_view.scene);
		_view2.backgroundColor = 0xFF0000;
		_view2.width = 200;
		_view2.height = 200;
		addChild(_view2);
		
		_view2.camera.z = -1000;
		_view2.camera.y = -1000;
		_view2.camera.lookAt(new Vector3D());
		//_secondCamera = new Camera3D();
		
		
		
		//var material:BitmapViwport
		
		
		// BitmapDataでテクスチャを作る場合
		//var texture:Texture2DBase = Cast.bitmapTexture(new BitmapData(256, 256, true, 0xFFFF0000));
		//var textureMaterial:TextureMaterial = new TextureMaterial(texture);

		var colorMaterial:ColorMaterial = new ColorMaterial(0x00FF00, 1);
		_mesh = new Mesh(new PlaneGeometry(640, 480, 1, 1,false, true), colorMaterial);
		_mesh.x = 0;
		_mesh.y = 0;
		_mesh.z = 0;
		_view.scene.addChild(_mesh);

		addEventListener(Event.ENTER_FRAME, enterFrame);

		
		
	}
	private function enterFrame(e:Event):void 
	{
		_mesh.rotationY ++;

		_view.render();
		_view2.render();
		//trace(_view.renderedFacesCount);
	}
}

}

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?