flash on 2009-7-18
♥0 |
Line 77 |
Modified 2009-07-18 02:02:56 |
MIT License
archived:2017-03-20 15:46:22
ActionScript3 source code
/**
* Copyright arfyasu ( http://wonderfl.net/user/arfyasu )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/dlI8
*/
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
addedToStage="init()">
<mx:Script>
<![CDATA[
import org.papervision3d.materials.special.CompositeMaterial;
import caurina.transitions.Tweener;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.events.InteractiveScene3DEvent;
import mx.containers.Panel;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.core.proto.MaterialObject3D;
import org.papervision3d.objects.primitives.Cube;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.core.effects.view.ReflectionView;
private var _container:ReflectionView;
private var _items:Array;
private static var ITEMS:uint = 20;
private function init():void {
_container = new ReflectionView();
//リフレクションを置く場所
_container.surfaceHeight = 0;
_container.viewport.interactive = true;
//ぼかし反映
var blur:Number = 4;
_container.viewportReflection.filters = [new BlurFilter(blur, blur, 1)];
_container.viewportReflection.alpha = 0.5;
_container.camera.x = 0;
_container.camera.z = -2000;
_container.camera.y = 25;
stage.addChild(_container);
_items= [];
for(var i:uint = 0; i < ITEMS; i++) {
var material:ColorMaterial = new ColorMaterial(0xffff * Math.random(), 1, true);
material.doubleSided = true;
var plane:Plane = new Plane(material, 60, 60);
plane.x = 400 * Math.random() - 250;
plane.y = 30;
plane.z = -2000 / ITEMS * i;
_items.push(_container.scene.addChild(plane));
plane.addEventListener(InteractiveScene3DEvent.OBJECT_PRESS, onClickAtPlane);
}
_container.addEventListener(Event.ENTER_FRAME, onEnterFrameAtContainer);
_container.addEventListener(MouseEvent.MOUSE_WHEEL, onMouserWheelAtContainer);
}
private function onEnterFrameAtContainer(e:Event):void {
_container.singleRender();
// _container.camera.z += 5;
for(var i:uint = 0; i < ITEMS; i++) {
var plane:Plane = _items[i];
var diff:Number = Math.abs(_container.camera.z) - Math.abs(plane.z);
if (diff < 100) {
plane.material.fillAlpha -= 0.04;
}
}
}
private function onMouserWheelAtContainer(e:MouseEvent):void {
}
private function onClickAtPlane(event:InteractiveScene3DEvent):void {
moveCamera(event.displayObject3D);
}
private function moveCamera(target:DisplayObject3D):void {
Tweener.addTween(
_container.camera,
{
x:target.x,
y:target.y,
z:target.z - 100,
rotationX:target.rotationX,
rotationY:target.rotationY,
rotationZ:target.rotationZ,
time:2,
transition:"easeOutExpo"
}
);
}
]]>
</mx:Script>
</mx:Application>