FIXED And because I dont like just saying that and rubbing it in other people with the same problems face, all I had to do to fix it was add
view.camera.rotationZ=figher.rotationZ; to the lines. On Jul 15, 12:32 pm, maltech <[email protected]> wrote: > Here is my whole code so you may be able to better see what is wrong. > Maybe you can tell me by this why the camera will not go into a > container. > > private var texture:Class; > private var cam:Camera3D; > private var lastKey:uint; > private var keyIsDown:Boolean = false; > private var view:View3D; > private var player:ObjectContainer3D; > private var plane:Plane; > private var hero:Sphere; > private var sphere:Sphere; > private var fighter:Object3DLoader; > > public function World() > { > // create a basic camera > cam = new Camera3D(); > view = new View3D({x:250,y:200}); > addChild(view); > view.camera = cam; > fighter = new > Object3DLoader(Max3DS.load("spaceship.3DS", > { material:"red#black", name:"fighter", scaling:1, > y:0, x:0, z:0, > rotationX:-90, loadersize:300})); > view.scene.addChild(fighter); > view.render(); > > // create a temporary container-sprite to add stars > into > var mc:Sprite = new Sprite(); > mc.graphics.beginFill(0); > mc.graphics.drawRect(0,0,2048,2048); > mc.graphics.endFill(); > // add 2000 star-sprites to the container > var s:Sprite, r:Number; > for( var i:uint=0; i<2000; i++ ) > { > r = Math.random()*Math.random(); > s = new Sprite(); > s.graphics.beginFill(0xFFFFFF,0.9); > s.graphics.drawCircle(0,0,r); > s.graphics.endFill(); > s.x = r + (mc.width - 2*r)*Math.random(); > s.y = r + (mc.height - 2*r)*Math.random(); > mc.addChild(s); > } > > // render the container-sprite to a bitmap > var bmd:BitmapData = new BitmapData(mc.width, mc.height, > false, 0); > bmd.draw(mc); > // create a 2x2 tiled material from the bitmap > var mat:TransformBitmapMaterial = new > TransformBitmapMaterial(bmd, { > smooth: true, precision:0, > repeat: true, scaleX: 0.5, scaleY: 0.5 }); > // create a skybox using that material on all 6 sides > var box:Skybox = new Skybox( mat,mat,mat,mat,mat,mat ); > // and finally add it to the scene > view.scene.addChild(box); > > > this.stage.addEventListener(KeyboardEvent.KEY_DOWN,keyDown); > > this.stage.addEventListener(KeyboardEvent.KEY_UP,keyUp); > this.addEventListener(Event.ENTER_FRAME,onEnterFrame); > > } > private function onEnterFrame(e:Event):void > { > if(keyIsDown){ > // if the key is still pressed, just > keep on moving > switch(lastKey){ > case 87 > : fighter.moveForward(10); break; > case 83 > : fighter.moveBackward(-5); break; > case 65 > : fighter.roll(10); break; > case 68 > : fighter.roll(-10); break; > case Keyboard.UP : > fighter.pitch(10); break; > case Keyboard.DOWN : > fighter.pitch(-10); break; > case Keyboard.RIGHT : > fighter.yaw(10); break; > case Keyboard.LEFT : > fighter.yaw(-10); break; > } > } > view.camera.moveTo(fighter.x,fighter.y,fighter.z); > view.camera.rotationY=fighter.rotationY; > view.camera.rotationX=fighter.rotationX; > view.camera.moveBackward(25);// or some other number; > view.render(); > } > private function keyDown(e:KeyboardEvent):void > { > lastKey = e.keyCode; > keyIsDown = true; > } > private function keyUp(e:KeyboardEvent):void > { > keyIsDown = false; > } > } > > On Jul 15, 12:13 pm, desgraci <[email protected]> wrote: > > > i remind u that this is based in the naivgation systema made by rob in > > the frustrum demo
