Small update, I've found that when I set the view size to 1390 by 880, the mouse position is correct again. this of course does not help me fix it :(
I've tried setting the view scaleX and scaleY while the size is set to the above values, but that simply repeats the problem of the inaccurate mouse position. On Mar 23, 10:34 pm, Snownova <[email protected]> wrote: > I've been playing around with Broomstick over the past few days, and > I've run into a problem when trying to set a size for my View3D > element. here is a basic version of the example InteractionTest to > demonstrate my problem: > > package { > > import away3d.containers.View3D; > import away3d.events.MouseEvent3D; > import away3d.materials.BitmapMaterial; > import away3d.primitives.Plane; > > import flash.display.Bitmap; > import flash.display.BitmapData; > import flash.display.BitmapDataChannel; > import flash.display.Sprite; > import flash.events.Event; > import flash.geom.Rectangle; > > [SWF(width="800", height="450", frameRate="60")] > public class InteractionTest extends Sprite { > private var _view:View3D; > > private var _mesh1:Plane; > private var _material1:BitmapMaterial; > > public function InteractionTest() { > > _view = new View3D; > _view.width = 800; > _view.height = 450; > _view.antiAlias = 4; > this.addChild(_view); > > var bitmapData1:BitmapData = new BitmapData(512, 512, > false, > 0x000000); > bitmapData1.perlinNoise(64, 64, 5, 0, false, true, > BitmapDataChannel.BLUE); > _material1 = new BitmapMaterial(bitmapData1); > _material1.bothSides = true; > > _mesh1 = new Plane(_material1, 500, 500, 1, 1); > _view.scene.addChild(_mesh1); > _mesh1.rotationY = .01; > _mesh1.mouseEnabled = true; > _mesh1.mouseDetails = true; > _mesh1.addEventListener(MouseEvent3D.MOUSE_MOVE, > onMouseMove); > > this.addEventListener(Event.ENTER_FRAME, > handleEnterFrame); > } > > private function onMouseMove(event:MouseEvent3D):void { > var material:BitmapMaterial = event.target.material; > var rect:Rectangle = new > Rectangle(event.uv.x*material.bitmapData.width-4, > event.uv.y*material.bitmapData.height-4, 9, 9); > material.bitmapData.fillRect(rect, 0x00ff00); > material.updateTexture(); > } > > private function handleEnterFrame(ev:Event):void { > _view.render(); > } > } > > } > > When I set _view.width and _view.height, the mouse interaction appears > to be quite a bit to the left and up from where the cursor actually > is. When I don't set the widht and height properties for the View3D, > it works just fine, but my view extends beyond my swf and is scaled > and centered improperly. > > Does anyone have any suggestions as to how to fix this?
