Try older version of Away3D (such as 2.3.3), maybe the problem is MatrixAway3D class which in older version is named as Matrix3D
On 1月22日, 上午6时02分, rocketmcm <[email protected]> wrote: > Hey there, > > I can not figure out where I am going wrong below. I have downloaded > the demo's on both the FLARManager(to see how Away3D is implemented) > and the Away3D site but can not see what I am missing. > > What I am trying to do here is place a sphere on top of the marker. > This is the code I have below. > > FLARManager Version: latest download from site > Away3D version: 3.4 > Targeting FP10 from Flex. > > Code: > ************************************ > package { > import away3d.*; > import away3d.containers.ObjectContainer3D; > import away3d.containers.Scene3D; > import away3d.containers.View3D; > import away3d.core.render.*; > import away3d.materials.WireColorMaterial; > import away3d.primitives.Plane; > import away3d.primitives.Sphere; > > import com.transmote.flar.FLARManager; > import com.transmote.flar.marker.FLARMarker; > import com.transmote.flar.marker.FLARMarkerEvent; > import com.transmote.flar.utils.geom.FLARAwayGeomUtils; > > import examples.*; > > import flash.display.Sprite; > import flash.events.Event; > import flash.events.MouseEvent; > > import org.libspark.flartoolkit.support.away3d.FLARCamera3D; > > [SWF(width="640", height="480", frameRate="30", > backgroundColor="#FFFFFF")] > > public class FLARManagerExampleLauncher extends Sprite { > > private var fm:FLARManager; > private var scene:Scene3D; > private var view:View3D; > private var camera:FLARCamera3D; > private var ball:Sphere; > private var p:Plane; > private var activeMarker:FLARMarker; > private var v:Vid; > private var con:ObjectContainer3D; > private var re:BasicRenderer; > > public function FLARManagerExampleLauncher () { > initFLAR(); > } > > private function initFLAR():void{ > fm = new > FLARManager("../resources/flar/flarConfig.xml"); > > fm.addEventListener(FLARMarkerEvent.MARKER_ADDED, > onAdded); > fm.addEventListener(FLARMarkerEvent.MARKER_REMOVED, > onRemoved); > fm.addEventListener(Event.INIT, init3D); > addChild(Sprite(fm.flarSource)); > } > > private function init3D(e:Event):void{ > // remove init event listener > fm.removeEventListener(Event.INIT, init3D); > > scene = new Scene3D(); > camera = new FLARCamera3D(fm.cameraParams); > camera.z = -30; > view = new View3D({scene:scene, camera:camera}); > addChild(view); > > con = new ObjectContainer3D(); > scene.addChild(con); > > var ballMat:WireColorMaterial = new > WireColorMaterial(0x666666, > {wirecolor:0xFFFFFF}); > ball = new Sphere({material:ballMat, radius:18, > segmentsW:10, > segmentsH:10}); > con.addChild(ball); > > //addChild(new FramerateDisplay()); > this.addEventListener(Event.ENTER_FRAME, loop); > } > > private function loop(e:Event):void{ > trace("loop") > if(activeMarker != null){ > con.transform = > FLARAwayGeomUtils.convertFLARMatrixToAwayMatrix > (activeMarker.transformMatrix); > } > view.render(); > } > > private function onAdded(e:FLARMarkerEvent):void{ > activeMarker = e.marker; > trace("Marker Added"); > } > > private function onRemoved(e:FLARMarkerEvent):void{ > activeMarker = null; > trace("Marker Removed"); > } > } > > } > > Error printed in the console: > ************************************ > TypeError: Error #1009: Cannot access a property or method of a null > object reference. > at away3d.core.math::MatrixAway3D/inverse()[U:\Global\away3d\core\math > \MatrixAway3D.as:649] > at org.libspark.flartoolkit.support.away3d::FLARCamera3D/get > viewMatrix()[U:\Flex Builder\FLARManager\src\org\libspark\flartoolkit > \support\away3d\FLARCamera3D.as:131] > at away3d.core.traverse::ProjectionTraverser/set view()[U:\Global > \away3d\core\traverse\ProjectionTraverser.as:46] > at away3d.containers::Scene3D/update()[U:\Global\away3d\containers > \Scene3D.as:211] > at away3d.containers::Scene3D/onUpdate()[U:\Global\away3d\containers > \Scene3D.as:63] > at flash.events::EventDispatcher/dispatchEventFunction() > at flash.events::EventDispatcher/dispatchEvent() > at away3d.containers::View3D/notifySceneUpdate()[U:\Global\away3d > \containers\View3D.as:228] > at away3d.containers::View3D/render()[U:\Global\away3d\containers > \View3D.as:907] > at FLARManagerExampleLauncher/loop()[U:\Flex Builder\FLARManager\src > \FLARManagerExampleLauncher.as:86] > > The launching "suspends" and opens up MatrixAway3D.as with the first > line of the inverse() function highlighted. > > I am new to Flex Builder, Away3D and the FLARManager and so it is > likely I will be tripping up a lot of the way when I am using this > stuff. > I would really appreciate some tips on to how I could have used what > information I have got here to see where I have gone wrong. This would > also stop me from having to annoy people on this forum in future :) > > I know from the debugger that "m" is null which I assume is the > problem (being a null object reference), I have tried to dig around in > the code and the docs but have not got anywhere. I think I am just not > using the render function correctly but I can not see any difference > in the way I have implemented this code and others that work. > > Thanks for your time.
