http://atassyu.tripod.com/Main.swfのソース
|
http://atassyu.tripod.com/NewProject3.swfのソース
|
http://atassyu.tripod.com/NewProject4.swfのソース
|
http://atassyu.tripod.com/NewProject5.swfのソース
|
http://atassyu.tripod.com/NewProject6.swfのソース
package {
//
// 参考
// 書籍 池田泰延, Flash 3D コンテンツ制作のための Papervision3D 入門
// Web http://wonderfl.net/
// http://www.libspark.org/wiki/nutsu/Frocessing
//
import flash.events.*;
import flash.events.MouseEvent;
import flash.geom.Point;
import flash.net.URLRequest;
import flash.net.navigateToURL;
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.materials.shadematerials.*;
import org.papervision3d.materials.utils.*;
import org.papervision3d.lights.*;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.view.*;
import org.papervision3d.render.*;
import org.papervision3d.objects.parsers.*;
import org.papervision3d.materials.BitmapFileMaterial;
import org.papervision3d.objects.primitives.*;
import org.papervision3d.events.*;
//import frocessing.color.ColorHSV;
public class Main extends BasicView {
// Bitmap
private var wrap:DisplayObject3D;
private var obj:Plane;
// Heart
private const ORBITAL_RADIUS:int = 300;
private const CUBE_SIZE:int = 30;
private const CUBE_MAX:int = 30;
private var wrapHeart:DisplayObject3D;
private var cube:Cube;
private var cubes:Vector.<Cube> = new Vector.<Cube>;
private var angle:Number;
public function Main():void {
super( 0, 0, true, true );
// Bitmap
wrap = new DisplayObject3D();
scene.addChild( wrap );
var mat:BitmapFileMaterial = new BitmapFileMaterial( "mentroom.jpg", true );
mat.interactive = true;
mat.doubleSided = true;
obj = new Plane( mat, 640, 480 );
obj.x = 600;
obj.z = 0;
obj.addEventListener( InteractiveScene3DEvent.OBJECT_CLICK, clickHandler );
wrap.addChild( obj );
// Heart
var light:PointLight3D = new PointLight3D( false, false );
scene.addChild( light );
wrapHeart = new DisplayObject3D();
scene.addChild( wrapHeart );
//var color:ColorHSV = new ColorHSV( 0, 0.5, 0.5 );
//var material:FlatShadeMaterial = new FlatShadeMaterial( light, 0xFFFFFF, 0x111111, 50 );
var material:GouraudMaterial = new GouraudMaterial( light, 0xFF0000, 0x110000, 50 );
//var material:GouraudMaterial = new GouraudMaterial( light, color.value32, 0x111111, 50 );
//var material:PhongMaterial = new PhongMaterial( light, 0xFFFFFF, 0x111111, 50 );
//var material:CellMaterial = new CellMaterial( light, 0xFFFFFF, 0x111111, 10 );
cube = new Cube( new MaterialsList( { all:material } ), CUBE_SIZE, CUBE_SIZE, CUBE_SIZE, 1, 1, 1 );
wrapHeart.addChild( cube );
cubes.push( cube );
for ( var i:int=1; i<CUBE_MAX; i++ ) {
cube = new Cube( new MaterialsList( { all:material } ), CUBE_SIZE, CUBE_SIZE, CUBE_SIZE, 1, 1, 1 );
wrapHeart.addChild( cube );
angle = ( i/CUBE_MAX/2 )*360*Math.PI/180;
cube.x = Math.sin( angle )*ORBITAL_RADIUS*i/10;
cube.y = Math.cos( angle )*ORBITAL_RADIUS*i/10;
cubes.push( cube );
cube = new Cube( new MaterialsList( { all:material } ), CUBE_SIZE, CUBE_SIZE, CUBE_SIZE, 1, 1, 1 );
wrapHeart.addChild( cube );
angle = ( i/CUBE_MAX/2 )*360*Math.PI/180;
cube.x = -Math.sin( angle )*ORBITAL_RADIUS*i/10;
cube.y = Math.cos( angle )*ORBITAL_RADIUS*i/10;
cubes.push( cube );
}
cube = new Cube( new MaterialsList( { all:material } ), CUBE_SIZE, CUBE_SIZE, CUBE_SIZE, 1, 1, 1 );
wrapHeart.addChild( cube );
angle = ( 1/2 )*360*Math.PI/180;
cube.x = Math.sin( angle )*ORBITAL_RADIUS*i/10;
cube.y = Math.cos( angle )*ORBITAL_RADIUS*i/10;
cubes.push( cube );
startRendering();
addEventListener( Event.ENTER_FRAME, loop );
//addEventListener( MouseEvent.CLICK, clickHandler );
}
private function loop(e:Event):void {
var rot:Number = (mouseX / stage.stageWidth ) * 720;
camera.x = 1000 * Math.sin( rot * Math.PI / 180 );
camera.z = 1000 * Math.cos( rot * Math.PI / 180 );
camera.y = 2000 * ( mouseY / stage.stageHeight );
wrap.rotationY += 0.5;
obj.rotationY += 1;
obj.rotationX += 0.3;
obj.rotationZ += 0.07;
wrapHeart.rotationX += 0.03;
wrapHeart.rotationY += 0.2;
for ( var i:int = 0; i < cubes.length; i++ ) {
cubes[ i ].rotationX += 0.3;
cubes[ i ].rotationZ += 1;
}
}
//private function clickHandler( e:MouseEvent ):void {
private function clickHandler( e:InteractiveScene3DEvent ):void {
navigateToURL( new URLRequest( "in9902.htm" ) );
}
}
}