Hey fab4ce

materials in f10 are going through a bit of a spring clean atm... however,
this was an incorrect update in view3d - now corrected in the latest svn

hth!

Rob




On Sun, Jan 31, 2010 at 9:06 PM, fab4ce <[email protected]> wrote:

> hey, it´s me again.
> Seems like noone else has these problems like i have.
> ...or maybe just noone understands what i´m talking about :)
> I really need to find a solution, that´s why i set up an example to
> show what´s wrong:
>
> here is a link to the working MouseEvent3D on a ColorMaterial:
> http://www.mischen-impossible.de/away3d/clickTestMesh.swf
>
> and here the demonstration of exactly the same code but using a
> PhongColorMaterial instead of ColorMaterial:
> http://www.mischen-impossible.de/away3d/clickTestMeshPhong.swf
>
> Please, could you show me what´s wrong with my code? Or give me
> another quick example of using the MouseDown Event on
> PhongColorMaterial?
> I´m using the actual SVN Version of Away3D FP10.
> Here is my Code with the 3ds file:
> http://www.mischen-impossible.de/away3d/clickTestMesh.zip
>
> and that´s what the code looks like:
>
>    package {
>        import flash.display.Sprite;
>        import flash.display.Stage;
>        import away3d.containers.View3D;
>        import away3d.materials.PhongColorMaterial;
>        import away3d.materials.PhongBitmapMaterial;
>        import away3d.materials.ColorMaterial;
>        import away3d.events.MouseEvent3D;
>        import away3d.lights.DirectionalLight3D;
>        import flash.events.MouseEvent;
>        import flash.events.Event;
>        import com.greensock.TweenLite;
>        import away3d.loaders.*;
>        import away3d.events.Loader3DEvent;
>        import away3d.core.utils.Cast;
>        import away3d.containers.ObjectContainer3D;
>        import away3d.events.MouseEvent3D;
>
>        public class clickTestMesh extends Sprite {
>                private var view:View3D;
>                private var xPos:Number;
>                private var yPos:Number;
>                public var loader:Loader3D;
>                private var lastMouseX:Number;
>                private var lastMouseY:Number;
>                private var lastPanAngle:Number;
>                private var lastTiltAngle:Number;
>                private var mouseIsDown:Boolean = false;
>                private var speed:Number = 1.5;
>                public var phongC:PhongColorMaterial = new
> PhongColorMaterial
> (0x9EC482);
>                public var phongB:PhongBitmapMaterial;
>                public var colorMaterial:ColorMaterial = new ColorMaterial
> (0xFFA500);
>                public var mesh:ObjectContainer3D;
>                private var light:DirectionalLight3D = new
> DirectionalLight3D({color:
> 0xFFFFFF, ambient:0.15, diffuse:0.75, specular:0.8});
>
>        public function clickTestMesh() {
>                view = new View3D({x:200,y:200});
>                addChild(view);
>
>                view.scene.addChild(light);
>                light.y = 500;
>                light.x = -1300;
>                light.z = -1200;
>
>                phongB = new PhongBitmapMaterial(Cast.bitmap(Symbol1),
> {smooth:true,
> precision:2});
>
>                loader = Max3DS.load("2.3ds");
>                loader.addOnSuccess(meshLoaded);
>                view.scene.addChild(loader);
>
>                addEventListener(Event.ENTER_FRAME, onEnterFrame);
>        }
>        private function meshLoaded(e:Loader3DEvent) {
>                        mesh = e.loader.handle as ObjectContainer3D;
>
>                        // -------- MATERIALS ------ //
>                        mesh.materialLibrary.getMaterial("Mat").material =
> colorMaterial;
>                        //mesh.materialLibrary.getMaterial("Mat").material =
> phongB;
>                        //mesh.materialLibrary.getMaterial("Mat").material =
> phongC;
>
>                        mesh.useHandCursor = true;
>
>                        mesh.addEventListener(MouseEvent3D.MOUSE_DOWN,
> MouseDown);
>                        stage.addEventListener(MouseEvent.MOUSE_UP,
> MouseUp);
>                }
>                private function MouseDown(e:MouseEvent3D) {
>                        lastPanAngle = mesh.rotationY;
>                        lastTiltAngle = mesh.rotationX;
>                        lastMouseX = stage.mouseX;
>                        lastMouseY = stage.mouseY;
>                        mouseIsDown = true;
>                        stage.addEventListener(MouseEvent.MOUSE_MOVE,
> MouseMove);
>                }
>                private function MouseUp(e:MouseEvent):void
>                {
>                        mouseIsDown = false;
>                }
>                private function MouseMove(e:MouseEvent) {
>                        var newX:Number;
>                        var newY:Number;
>                        if(mouseIsDown){
>                                newY = speed*(stage.mouseX - lastMouseX) +
> lastPanAngle;
>                                newX = speed*(stage.mouseY - lastMouseY) +
> lastTiltAngle;
>                                TweenLite.to(mesh, 1,
> {rotationX:newX,rotationY:newY});
>                        }
>                }
>                private function onEnterFrame(e:Event) {
>                        view.render();
>                 }
>        }
>        }
>
>
> On 27 Jan., 20:21, fab4ce <[email protected]> wrote:
> > Thank you for trying to help.
> > But...of course i tried that
> > It´s not working :(
> >
> > On 27 Jan., 10:55, Valts Darznieks <[email protected]> wrote:
> >
> > > Have you tried to apply MouseEvent after applying new material, don`t
> > > know if this will fix the issue, but doesn't hurt to try.
> >
> > > On 26 Janv., 15:20, fab4ce <[email protected]> wrote:
> >
> > > > Hi all,
> >
> > > > after i load a mesh and i apply aMouseEvent3D(like MouseDown) on my
> > > > Mesh everything works fine.
> > > > Then i changed the Material to ColorMaterial and it still worked. But
> > > > if i want to use a PhongColorMat, PhongBitmapMat or i.e. Dot3Mat the
> > > > MouseEvent just doesn´t work.
> > > > Anyone know this conflict? What´s the difference between the ColorMat
> > > > and the PhongColorMat in this case?
>



-- 
Rob Bateman
Flash Development & Consultancy

[email protected]
www.infiniteturtles.co.uk
www.away3d.com

Reply via email to