[SWF(width=800,height=600,frameRate=20)]
public class soundWave extends Sprite {
var scene:Scene3D;
var lineArr1:Array;
var lineArr2:Array;
var tempPtArr:Array;
var moArr:Array;
var ptArr:Array;
var soundByte:ByteArray;
var sound:Sound;
var soundCh:SoundChannel;
public function soundWave() {
scene=new Viewer3D(this);
scene.camera=new Camera3D();
scene.camera.setPosition(-100,130,-200);
scene.camera.lookAt(0,0,0);
init();
var txt:TextField=new TextField();
var txtFormat:TextFormat=new TextFormat(null,20,0xff0000);
txt.text="按下鼠标左键 拖动,可以旋转视角";
txt.setTextFormat(txtFormat);
txt.autoSize=TextFieldAutoSize.LEFT;
addChild(txt);
}
private function init(){
buildMesh();
}
private function buildMesh(){
ptArr=new Array();
for(var i=0;i<128;i++){
var temptArr:Array=new Array();
for(var a=0;a<32;a++){
var pt:Vector3D=new Vector3D(i*5-160,0,a*5-80);
temptArr.push(pt);
}
ptArr.push(temptArr);
}
buildLines();
moArr=new Array();
for(var v=0;v<32;v++){
var moPt:Vector3D=ptArr[0][v].clone();
moArr.push(moPt);
}
}
private function buildLines(){
lineArr1=new Array();
lineArr2=new Array ();
for(var i=0;i<128;i++){
var line1ines3D=new Lines3D();
line1.lineStyle(1,0x33ffff);
line1.moveTo(ptArr[0].x,ptArr[0].y,ptArr[0].z);
for(var a=0;a<32;a++){
line1.lineTo(ptArr[a].x,ptArr[a].y,ptArr[a].z)
}
scene.addChild(line1);
lineArr1.push(line1);
}
for(var p=0;p<32;p++){
var line2ines3D=new Lines3D();
line2.lineStyle(1,0x33ffff);
line2.moveTo(ptArr[0][p].x,ptArr[0][p].y,ptArr[0][p].z);
for(var u=0;u<128;u++){
line2.lineTo(ptArr[p].x,ptArr[p].y,ptArr[p].z);
}
scene.addChild(line2);
lineArr2.push(line2);
}
playSound();
//buildLines2();
}
private function buildLines2(){
for(var i=0;i<128;i++){
var line1ines3D=new Lines3D();
line1.lineStyle(1,0x33ffff);
line1.moveTo(ptArr[0].x,ptArr[0].y,ptArr[0].z);
for(var a=0;a<32;a++){
line1.lineTo(ptArr[a].x,ptArr[a].y,ptArr[a].z)
}
scene.addChild(line1);
}
for(var p=0;p<32;p++){
var line2ines3D=new Lines3D();
line2.lineStyle(1,0x33ffff);
line2.moveTo(ptArr[0][p].x,ptArr[0][p].y,ptArr[0][p].z);
for(var u=0;u<128;u++){
line2.lineTo(ptArr[p].x,ptArr[p].y,ptArr[p].z);
}
scene.addChild(line2);
}