Papervision3D: understanding Plane object – part 4
2009-10-21 00:00:00 来源:WEB开发网Let’s see what’s new:
Line 10: Importing InteractiveScene3DEvent class. It’s the class that will allow us to make objects interactive
Line 12: we also have to declare the viewport in a new way… we need the fourth parameter set to true in order to make the viewport interactive. Interactive objects inside a non-interactive viewport become non-interactive themselves.
Let’s see the four parameters:
viewportWidth:Number (default = 640) — Width of the viewport
viewportHeight:Number (default = 480) — Height of the viewport
autoScaleToStage:Boolean (default = false) — Determines whether the viewport should resize when the stage resizes
interactive:Boolean (default = false) — Determines whether the viewport should listen for Mouse events by creating an InteractiveSceneManager
Lines 16-17: This is the creation of a color material as seen in part 2, but this time I am rendering random colors
Lines 26-27: Making the planes interactive
Lines 30-31: Assigning names to both planes.
Lines 32-33: Adding the listener to planes. InteractiveScene3DEvent.OBJECT_PRESS works in the same way as MouseEvent.CLICK
Now let’s see what happens when I click on a plane:
Line 42: Changing the rotation speed of both planes
Lines 43-50: Retrieving the name of the plane I clicked, and according to its name changing the color of the front or back plane. Please notice I am not changing the plane material, but I am changing the material fill color.
And that’s it:
Click on the rotating plane to see what happens.
Tags:PapervisionD understanding Plane
编辑录入:爽爽 [复制链接] [打 印]更多精彩
赞助商链接