在PV3D裡, 如果物件要有滑鼠指標, 只能對整個容器開啟buttonMode的
如果希望針對單一物件呢?
有二個方法可以使用。
方法1:偵聽物件的rollOver和rollOut, over時就開啟viewport.buttonMode = true;
out時就buttonMoe = false;
如果希望針對單一物件呢?
有二個方法可以使用。
方法1:偵聽物件的rollOver和rollOut, over時就開啟viewport.buttonMode = true;
out時就buttonMoe = false;
package { import flash.display.Sprite; import flash.events.Event; import org.papervision3d.cameras.CameraType; import org.papervision3d.events.InteractiveScene3DEvent; import org.papervision3d.materials.ColorMaterial; import org.papervision3d.objects.primitives.Plane; import org.papervision3d.view.BasicView; [SWF(width = "950", height = "500", frameRate = "41", backgroundColor = "#000000", pageTitle = "milkmidi.com")] public class PV3DButtonMode extends BasicView { private var _greenPlane:Plane; private var _redPlane:Plane; public function PV3DButtonMode(){ super(0, 0, true, true, CameraType.TARGET); init3DObjects(); startRendering(); } private function init3DObjects():void{ var _redMat:ColorMaterial = new ColorMaterial(0xff0000); _redMat.interactive = true; _redMat.doubleSided = true; _redPlane = new Plane(_redMat, 300, 300); _redPlane.addEventListener(InteractiveScene3DEvent.OBJECT_OVER , objOverHandler); _redPlane.addEventListener(InteractiveScene3DEvent.OBJECT_OUT , objOutHandler); scene.addChild(_redPlane); var _greenMat:ColorMaterial = new ColorMaterial(0x00ff00); _greenMat.doubleSided = true; _greenPlane = new Plane(_greenMat, 300, 300); _greenPlane.x = 400; scene.addChild(_greenPlane); } private function objOverHandler(e:InteractiveScene3DEvent):void { viewport.buttonMode = true; } private function objOutHandler(e:InteractiveScene3DEvent):void { viewport.buttonMode = false; } override protected function onRenderTick(event:Event = null):void { _greenPlane.rotationY += 1; _redPlane.rotationY += 1; super.onRenderTick(event); } } }方法2:使用ViewportLayer, 就可以針對單一物件開啟buttonMode。
package { import flash.display.Sprite; import flash.events.Event; import org.papervision3d.cameras.CameraType; import org.papervision3d.events.InteractiveScene3DEvent; import org.papervision3d.materials.ColorMaterial; import org.papervision3d.objects.primitives.Plane; import org.papervision3d.view.BasicView; import org.papervision3d.view.layer.ViewportLayer; [SWF(width = "950", height = "500", frameRate = "41", backgroundColor = "#000000", pageTitle = "milkmidi.com")] public class PV3DButtonMode2 extends BasicView { private var _greenPlane:Plane; private var _redPlane:Plane; public function PV3DButtonMode2(){ super(0, 0, true, true, CameraType.TARGET); init3DObjects(); startRendering(); } private function init3DObjects():void{ var _redMat:ColorMaterial = new ColorMaterial(0xff0000); _redMat.interactive = true; _redMat.doubleSided = true; _redPlane = new Plane(_redMat, 300, 300); var _layer:ViewportLayer = new ViewportLayer(viewport, _redPlane); _layer.buttonMode = true; viewport.containerSprite.addLayer(_layer); scene.addChild(_redPlane); var _greenMat:ColorMaterial = new ColorMaterial(0x00ff00); _greenMat.doubleSided = true; _greenPlane = new Plane(_greenMat, 300, 300); _greenPlane.x = 400; scene.addChild(_greenPlane); } override protected function onRenderTick(event:Event = null):void { _greenPlane.rotationY += 1; _redPlane.rotationY += 1; super.onRenderTick(event); } } }
留言
奶伯有方式解決物體太靠近鏡頭就破掉不見的方式嗎?除了用那個甚麼QuadrantRenderEngine外~
不知道為何~感覺上PV3D的東西有些做起來怎麼破破的~
算是Flash 3D Engine的限制。
原理是因為要把圖型切成許多個三角型
當面數過底且重疊時, 就一定會發生這樣的問題, QuadrantRenderEngine就是為了要決解這個問題才出現的
所以就是效能和破面只能有一好
這點就沒辬法