日期:2013-07-04  浏览次数:20778 次

这个例子展现的是一个球体,它上面由很多小三角面组成,这些小的三角面可以随着音乐的变化进而变换色彩。下面是这个例子的源代码。

import flash.display.*;
import flash.events.*;
import flash.media.Sound;
import flash.media.SoundMixer;
import flash.net.URLRequest;
import flash.utils.ByteArray;

import flash.display.Bitmap;
import flash.display.BitmapData;

import org.papervision3d.scenes.*;
import org.papervision3d.objects.*;
import org.papervision3d.cameras.*;
import org.papervision3d.materials.*;
import org.papervision3d.events.*;
import org.papervision3d.core.proto.DisplayObjectContainer3D;

import com.mrdoob.pv3d_phunky.objects.*;
import com.mrdoob.utils.*;

import caurina.transitions.Tweener;


// .. VARS .....................................................................................................               


var container                :Sprite;
var containerPos        :Sprite;
var bitmapPos                :BitmapData;

var mtr                                :Matrix;

var scene                     :MovieScene3D;
var camera                    :Camera3D;
var root3D                           :DisplayObject3D;
var sound                          :Sound;
var bytes                          :ByteArray;
var amount                          :Number = 15;
var values                          :Array;

var resetPos        :Number = 0;


// .............................................................................................................


stage.quality = "MEDIUM";
stage.scaleMode = "noScale";
stage.align = "TL";

stage.addEventListener(Event.RESIZE, resizeHandler);

function resizeHandler(e)
{
        mtr = new Matrix();
        mtr.translate(stage.stageWidth * .5,stage.stageHeight * .5);
        mtr.scale(.01,.01);
        container.x = stage.stageWidth * .5;
        container.y = stage.stageHeight * .5;
        containerPos.width = stage.stageWidth;
        containerPos.height = stage.stageHeight;               
}

init3D();
init();       
resizeHandler(null);
generateCameraPath();
this.addEventListener( Event.ENTER_FRAME, loop3D );


// .. INIT ...............................