纳金网
标题:
away3d鼠标感应效果教程
[打印本页]
作者:
xiongz
时间:
2013-5-8 16:30
标题:
away3d鼠标感应效果教程
away3d鼠标感应效果教程
package
{
import away3d.entities.Mesh;
import away3d.events.MouseEvent3D;
import away3d.materials.ColorMaterial;
import away3d.primitives.CubeGeometry;
import away3d.primitives.SphereGeometry;
public class PickingTutorialListing01 extends PickingTutorialListingBase
{
public function PickingTutorialListing01() {
super();
}
private var _inactiveMaterial:ColorMaterial;
private var _activeMaterial:ColorMaterial;
override protected function onSetup():void {
_cameraController.panAngle = 20;
_cameraController.tiltAngle = 20;
// Init materials.
_activeMaterial = new ColorMaterial( 0xFF0000 );
_activeMaterial.lightPicker = _lightPicker;
_inactiveMaterial = new ColorMaterial( 0xCCCCCC );
_inactiveMaterial.lightPicker = _lightPicker;
// Create 2 objects.
var cube:Mesh = new Mesh( new CubeGeometry(), _inactiveMaterial );
cube.x = -75;
_view.scene.addChild( cube );
var sphere:Mesh = new Mesh( new SphereGeometry(), _inactiveMaterial );
sphere.x = 75;
_view.scene.addChild( sphere );
// Enable mouse interactivity.
cube.mouseEnabled = true;
sphere.mouseEnabled = true;
// Attach mouse event listeners.
cube.addEventListener( MouseEvent3D.MOUSE_OVER, onObjectMouseOver );
cube.addEventListener( MouseEvent3D.MOUSE_OUT, onObjectMouseOut );
sphere.addEventListener( MouseEvent3D.MOUSE_OVER, onObjectMouseOver );
sphere.addEventListener( MouseEvent3D.MOUSE_OUT, onObjectMouseOut );
}
private function onObjectMouseOver( event:MouseEvent3D ):void {
event.target.material = _activeMaterial;
}
private function onObjectMouseOut( event:MouseEvent3D ):void {
event.target.material = _inactiveMaterial;
}
}
}
复制代码
作者:
shenyg77
时间:
2014-1-17 09:00
不错的资源,感谢楼主分享,支持下
欢迎光临 纳金网 (http://rs.narkii.com/club/)
Powered by Discuz! X2.5