私は PaperVision3d と FLARToolkit (および一般的に AS3) を初めて使用します。拡張現実アプリの作成方法について、YouTube でチュートを行っています。エラーが発生する
Function does not have a body.
と
return value for function 'loop' has no type declaration.
プライベート関数ループ。私は自分が間違っていることを本当に理解できません。PLZヘルプ!!
コード
package
{
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.events.Event;
import flash.media.Camera;
import flash.media.Video;
import flash.utils.ByteArray;
import org.libspark.flartoolkit.core.FLARCode;
import org.libspark.flartoolkit.core.param.FLARParam;
import org.libspark.flartoolkit.core.raster.rgb.FLARRgbRaster_BitmapData;
import org.libspark.flartoolkit.core.transmat.FLARTransMatResult;
import org.libspark.flartoolkit.detector.FLARSingleMarkerDetector;
import org.libspark.flartoolkit.support.alternativa3d.FLARCamera3D;
import org.libspark.flartoolkit.support.pv3d.FLARBaseNode;
import org.libspark.flartoolkit.support.pv3d.FLARCamera3D;
import org.papervision3d.lights.PointLight3D;
import org.papervision3d.materials.BitmapFileMaterial;
import org.papervision3d.materials.BitmapMaterial;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.objects.primitives.Cube;
import org.papervision3d.render.BasicRenderEngine;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.view.Viewport3D;
[SWF(width="640", height="480", frameRate="30", backgroundColor="#ffffff")]
public class testweb extends Sprite
{
[Embed(source="earth.pat", mimeType="application/octet-stream")]
private var marker:Class;
[Embed(source="camera_para.dat", mimeType="application/octet-stream")]
private var cam_params:Class;
//createFLAR variables
private var ar_params:FLARParam;
private var ar_marker:FLARCode;
//createCam variables
private var ar_vid:Video
private var ar_cam:Camera
//createBMP vairiables
private var ar_bmp:BitmapData;
private var ar_raster:FLARRgbRaster_BitmapData;
private var ar_detection:FLARSingleMarkerDetector;
//createPapervision variables
private var ar_scene:Scene3D;
private var ar_3dcam:org.libspark.flartoolkit.support.pv3d.FLARCamera3D;
private var ar_basenode:FLARBaseNode;
private var ar_viewport:Viewport3D;
private var ar_renderengine:BasicRenderEngine;
private var ar_transmat:FLARTransMatResult;
private var ar_cube:Cube;
public function testweb()
{
createFLAR();
createCam();
createBMP();
createPapervision();
addEventListener(Event.ENTER_FRAME, loop);
}
public function createFLAR()
{
ar_params= new FLARParam();
ar_marker= new FLARCode(16,16);
ar_params.loadARParam(new cam_params() as ByteArray);
ar_marker.loadARPatt(new marker());
}
public function createCam()
{
ar_vid= new Video(640, 480);
ar_cam= Camera.getCamera();
ar_cam.setMode(640,480,30);
ar_vid.attachCamera(ar_cam);
addChild(ar_vid);
}
public function createBMP()
{
ar_bmp= new BitmapData(640,480);
ar_bmp.draw(ar_vid);
ar_raster= new FLARRgbRaster_BitmapData(ar_bmp);
ar_detection= new FLARSingleMarkerDetector(ar_params, ar_marker,80);
}
public function createPapervision()
{
ar_scene= new Scene3D();
ar_3dcam= new org.libspark.flartoolkit.support.pv3d.FLARCamera3D(ar_params);
ar_basenode= new FLARBaseNode();
ar_renderengine= new BasicRenderEngine();
ar_transmat= new FLARTransMatResult();
var ar_light:PointLight3D= new PointLight3D();
ar_light.x= 1000;
ar_light.y= 1000;
ar_light.z= -1000;
var ar_bitmap:BitmapFileMaterial;
ar_bitmap=new BitmapFileMaterial ("LBP2.jpg");
ar_bitmap.doubleSided=true;
ar_cube=new Cube(new MaterialsList({all:ar_bitmap}), 80, 80, 80);
ar_scene.addChild(ar_basenode);
ar_basenode.addChild(ar_cube);
addChild(ar_viewport);
}
private function loop(e:Event);void
{
ar_bmp.draw(ar_vid);
ar_cube.rotationX +=4;
ar_cube.rotationY +=6;
try
{
if(ar_detection.detectMarkerLite(ar_raster, 80) && ar_detection.getConfidence()>0.5)
{
ar_detection.getTransformMatrix(ar_transmat);
ar_basenode.setTransformMatrix(ar_transmat);
ar_renderengine.renderLayers(ar_scene, ar_3dcam, ar_viewport);
}
}
catch (e:Error){}
}
}
}