diff --git a/src/alternativa/engine3d/core/Camera3D.as b/src/alternativa/engine3d/core/Camera3D.as
index 9b75688..49d6d07 100644
--- a/src/alternativa/engine3d/core/Camera3D.as
+++ b/src/alternativa/engine3d/core/Camera3D.as
@@ -326,7 +326,8 @@ public class Camera3D extends Object3D {
view.calculateRays(this, (globalMouseHandlingType & Object3D.MOUSE_HANDLING_MOVING) != 0,
(globalMouseHandlingType & Object3D.MOUSE_HANDLING_PRESSING) != 0,
(globalMouseHandlingType & Object3D.MOUSE_HANDLING_WHEEL) != 0,
- (globalMouseHandlingType & Object3D.MOUSE_HANDLING_MIDDLE_BUTTON) != 0);
+ (globalMouseHandlingType & Object3D.MOUSE_HANDLING_MIDDLE_BUTTON) != 0,
+ (globalMouseHandlingType & Object3D.MOUSE_HANDLING_RIGHT_BUTTON) != 0);
for (i = origins.length; i < view.raysLength; i++) {
origins[i] = new Vector3D();
directions[i] = new Vector3D();
diff --git a/src/alternativa/engine3d/core/Object3D.as b/src/alternativa/engine3d/core/Object3D.as
index 084937e..ec3d9ef 100644
--- a/src/alternativa/engine3d/core/Object3D.as
+++ b/src/alternativa/engine3d/core/Object3D.as
@@ -188,6 +188,10 @@ package alternativa.engine3d.core {
* @private
*/
alternativa3d static const MOUSE_HANDLING_MIDDLE_BUTTON:uint = 8;
+ /**
+ * @private
+ */
+ alternativa3d static const MOUSE_HANDLING_RIGHT_BUTTON:uint = 16;
/**
* Custom data available to store within Object3D by user.
@@ -747,6 +751,9 @@ package alternativa.engine3d.core {
if (type == MouseEvent3D.MIDDLE_CLICK || type == MouseEvent3D.MIDDLE_MOUSE_DOWN || type == MouseEvent3D.MIDDLE_MOUSE_UP) {
mouseHandlingType |= MOUSE_HANDLING_MIDDLE_BUTTON;
}
+ if (type == MouseEvent3D.RIGHT_CLICK || type == MouseEvent3D.RIGHT_MOUSE_DOWN || type == MouseEvent3D.RIGHT_MOUSE_UP) {
+ mouseHandlingType |= MOUSE_HANDLING_RIGHT_BUTTON;
+ }
}
if (vector.indexOf(listener) < 0) {
vector.push(listener);
@@ -796,6 +803,9 @@ package alternativa.engine3d.core {
if (type == MouseEvent3D.MIDDLE_CLICK || type == MouseEvent3D.MIDDLE_MOUSE_DOWN || type == MouseEvent3D.MIDDLE_MOUSE_UP) {
mouseHandlingType &= ~MOUSE_HANDLING_MIDDLE_BUTTON;
}
+ if (type == MouseEvent3D.RIGHT_CLICK || type == MouseEvent3D.RIGHT_MOUSE_DOWN || type == MouseEvent3D.RIGHT_MOUSE_UP) {
+ mouseHandlingType &= ~MOUSE_HANDLING_RIGHT_BUTTON;
+ }
}
}
}
diff --git a/src/alternativa/engine3d/core/View.as b/src/alternativa/engine3d/core/View.as
index f8b335d..ec25310 100644
--- a/src/alternativa/engine3d/core/View.as
+++ b/src/alternativa/engine3d/core/View.as
@@ -157,6 +157,7 @@ package alternativa.engine3d.core {
private var targetDepth:Number;
private var pressedTarget:Object3D;
private var pressedMiddleTarget:Object3D;
+ private var pressedRightTarget:Object3D;
private var clickedTarget:Object3D;
private var overedTarget:Object3D;
private var overedTargetSurface:Surface;
@@ -173,6 +174,7 @@ package alternativa.engine3d.core {
private var _logoHorizontalMargin:Number = 0;
private var _logoVerticalMargin:Number = 0;
private var _renderToBitmap:Boolean;
+ private var _rightClick3DEnabled:Boolean = false;
/**
* Creates a View object.
@@ -296,8 +298,6 @@ package alternativa.engine3d.core {
// Listeners
addEventListener(MouseEvent.MOUSE_DOWN, onMouse);
addEventListener(MouseEvent.CLICK, onMouse);
-// addEventListener("rightMouseDown", onMouse);
-// addEventListener("rightClick", onMouse);
addEventListener("middleMouseDown", onMouse);
addEventListener("middleClick", onMouse);
addEventListener(MouseEvent.DOUBLE_CLICK, onMouse);
@@ -309,6 +309,26 @@ package alternativa.engine3d.core {
addEventListener(Event.REMOVED_FROM_STAGE, onRemoveFromStage);
}
+ public function get rightClick3DEnabled():Boolean {
+ return _rightClick3DEnabled;
+ }
+
+ /**
+ * @private
+ */
+ public function set rightClick3DEnabled(value:Boolean):void {
+ if (value != _rightClick3DEnabled) {
+ if (value) {
+ addEventListener("rightMouseDown", onMouse);
+ addEventListener("rightClick", onMouse);
+ } else {
+ removeEventListener("rightMouseDown", onMouse);
+ removeEventListener("rightClick", onMouse);
+ }
+ _rightClick3DEnabled = value;
+ }
+ }
+
private function onMouse(mouseEvent:MouseEvent):void {
var prev:int = eventsLength - 1;
// case of mouseMove repeats
@@ -375,7 +395,7 @@ package alternativa.engine3d.core {
/**
* @private
*/
- alternativa3d function calculateRays(camera:Camera3D, processMoving:Boolean, processPressing:Boolean, processMouseWheel:Boolean, processMiddleButton:Boolean):void {
+ alternativa3d function calculateRays(camera:Camera3D, processMoving:Boolean, processPressing:Boolean, processMouseWheel:Boolean, processMiddleButton:Boolean, processRightButton:Boolean):void {
var i:int;
var mouseEvent:MouseEvent;
// Case of last coordinates fits in the view.
@@ -414,6 +434,11 @@ package alternativa.engine3d.core {
if (!processMiddleButton) {
pressedMiddleTarget = null;
}
+ // Mask with rightClick3DEnabled for case when in the list there are old events witch dispatched before rightClick3DEnabled was made false
+ processRightButton &&= _rightClick3DEnabled;
+ if (!processRightButton) {
+ pressedRightTarget = null;
+ }
// Creation of exclusive rays
var mouseX:Number = 1e+22;
@@ -434,6 +459,9 @@ package alternativa.engine3d.core {
if (!processMiddleButton && (mouseEvent.type == "middleMouseDown" || mouseEvent.type == "middleClick")) {
continue;
}
+ if (!processRightButton && (mouseEvent.type == "rightMouseDown" || mouseEvent.type == "rightClick")) {
+ continue;
+ }
if (mouseEvent.type != "mouseOut") {
// Calculation of ray within the camera
@@ -652,24 +680,23 @@ package alternativa.engine3d.core {
}
pressedMiddleTarget = null;
break;
-// case "rightMouseDown":
-// defineTarget(index);
-// if (target != null) {
-// propagateEvent(MouseEvent3D.RIGHT_MOUSE_DOWN, mouseEvent, camera, target, targetSurface, branchToVector(target, branch));
-// }
-// pressedTarget = target;
-// break;
-// case "rightClick":
-// defineTarget(index);
-// if (target != null) {
-// propagateEvent(MouseEvent3D.RIGHT_MOUSE_UP, mouseEvent, camera, target, targetSurface, branchToVector(target, branch));
-// if (pressedTarget == target) {
-// clickedTarget = target;
-// propagateEvent(MouseEvent3D.RIGHT_CLICK, mouseEvent, camera, target, targetSurface, branchToVector(target, branch));
-// }
-// }
-// pressedTarget = null;
-// break;
+ case "rightMouseDown":
+ defineTarget(index);
+ if (target != null) {
+ propagateEvent(MouseEvent3D.RIGHT_MOUSE_DOWN, mouseEvent, camera, target, targetSurface, branchToVector(target, branch));
+ }
+ pressedRightTarget = target;
+ break;
+ case "rightClick":
+ defineTarget(index);
+ if (target != null) {
+ propagateEvent(MouseEvent3D.RIGHT_MOUSE_UP, mouseEvent, camera, target, targetSurface, branchToVector(target, branch));
+ if (pressedRightTarget == target) {
+ propagateEvent(MouseEvent3D.RIGHT_CLICK, mouseEvent, camera, target, targetSurface, branchToVector(target, branch));
+ }
+ }
+ pressedRightTarget = null;
+ break;
case "mouseMove":
defineTarget(index);
if (target != null) {
diff --git a/src/alternativa/engine3d/core/events/MouseEvent3D.as b/src/alternativa/engine3d/core/events/MouseEvent3D.as
index fd995dd..3375052 100644
--- a/src/alternativa/engine3d/core/events/MouseEvent3D.as
+++ b/src/alternativa/engine3d/core/events/MouseEvent3D.as
@@ -46,23 +46,23 @@ package alternativa.engine3d.core.events {
*/
public static const MOUSE_UP:String = "mouseUp3D";
-// /**
-// * Defines the value of the type property of a rightClick3D event object.
-// * @eventType rightClick3D
-// */
-// public static const RIGHT_CLICK:String = "rightClick3D";
-//
-// /**
-// * Defines the value of the type property of a rightMouseDown3D event object.
-// * @eventType rightMouseDown3D
-// */
-// public static const RIGHT_MOUSE_DOWN:String = "rightMouseDown3D";
-//
-// /**
-// * Defines the value of the type property of a rightMouseUp3D event object.
-// * @eventType rightMouseUp3D
-// */
-// public static const RIGHT_MOUSE_UP:String = "rightMouseUp3D";
+ /**
+ * Defines the value of the type property of a rightClick3D event object.
+ * @eventType rightClick3D
+ */
+ public static const RIGHT_CLICK:String = "rightClick3D";
+
+ /**
+ * Defines the value of the type property of a rightMouseDown3D event object.
+ * @eventType rightMouseDown3D
+ */
+ public static const RIGHT_MOUSE_DOWN:String = "rightMouseDown3D";
+
+ /**
+ * Defines the value of the type property of a rightMouseUp3D event object.
+ * @eventType rightMouseUp3D
+ */
+ public static const RIGHT_MOUSE_UP:String = "rightMouseUp3D";
/**
* Defines the value of the type property of a middleClick3D event object.