mirror of
https://github.com/MapMakersAndProgrammers/Alternativa3D.git
synced 2025-10-26 09:59:10 -07:00
Added events for FP 11.2: RIGHT_CLICK, RIGHT_MOUSE_DOWN, RIGHT_MOUSE_UP. Need use FP 11.2 and -swf-version=15. #8
This commit is contained in:
@@ -326,7 +326,8 @@ public class Camera3D extends Object3D {
|
|||||||
view.calculateRays(this, (globalMouseHandlingType & Object3D.MOUSE_HANDLING_MOVING) != 0,
|
view.calculateRays(this, (globalMouseHandlingType & Object3D.MOUSE_HANDLING_MOVING) != 0,
|
||||||
(globalMouseHandlingType & Object3D.MOUSE_HANDLING_PRESSING) != 0,
|
(globalMouseHandlingType & Object3D.MOUSE_HANDLING_PRESSING) != 0,
|
||||||
(globalMouseHandlingType & Object3D.MOUSE_HANDLING_WHEEL) != 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++) {
|
for (i = origins.length; i < view.raysLength; i++) {
|
||||||
origins[i] = new Vector3D();
|
origins[i] = new Vector3D();
|
||||||
directions[i] = new Vector3D();
|
directions[i] = new Vector3D();
|
||||||
|
|||||||
@@ -188,6 +188,10 @@ package alternativa.engine3d.core {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
alternativa3d static const MOUSE_HANDLING_MIDDLE_BUTTON:uint = 8;
|
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 <code>Object3D</code> by user.
|
* Custom data available to store within <code>Object3D</code> 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) {
|
if (type == MouseEvent3D.MIDDLE_CLICK || type == MouseEvent3D.MIDDLE_MOUSE_DOWN || type == MouseEvent3D.MIDDLE_MOUSE_UP) {
|
||||||
mouseHandlingType |= MOUSE_HANDLING_MIDDLE_BUTTON;
|
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) {
|
if (vector.indexOf(listener) < 0) {
|
||||||
vector.push(listener);
|
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) {
|
if (type == MouseEvent3D.MIDDLE_CLICK || type == MouseEvent3D.MIDDLE_MOUSE_DOWN || type == MouseEvent3D.MIDDLE_MOUSE_UP) {
|
||||||
mouseHandlingType &= ~MOUSE_HANDLING_MIDDLE_BUTTON;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -157,6 +157,7 @@ package alternativa.engine3d.core {
|
|||||||
private var targetDepth:Number;
|
private var targetDepth:Number;
|
||||||
private var pressedTarget:Object3D;
|
private var pressedTarget:Object3D;
|
||||||
private var pressedMiddleTarget:Object3D;
|
private var pressedMiddleTarget:Object3D;
|
||||||
|
private var pressedRightTarget:Object3D;
|
||||||
private var clickedTarget:Object3D;
|
private var clickedTarget:Object3D;
|
||||||
private var overedTarget:Object3D;
|
private var overedTarget:Object3D;
|
||||||
private var overedTargetSurface:Surface;
|
private var overedTargetSurface:Surface;
|
||||||
@@ -173,6 +174,7 @@ package alternativa.engine3d.core {
|
|||||||
private var _logoHorizontalMargin:Number = 0;
|
private var _logoHorizontalMargin:Number = 0;
|
||||||
private var _logoVerticalMargin:Number = 0;
|
private var _logoVerticalMargin:Number = 0;
|
||||||
private var _renderToBitmap:Boolean;
|
private var _renderToBitmap:Boolean;
|
||||||
|
private var _rightClick3DEnabled:Boolean = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a <code>View</code> object.
|
* Creates a <code>View</code> object.
|
||||||
@@ -296,8 +298,6 @@ package alternativa.engine3d.core {
|
|||||||
// Listeners
|
// Listeners
|
||||||
addEventListener(MouseEvent.MOUSE_DOWN, onMouse);
|
addEventListener(MouseEvent.MOUSE_DOWN, onMouse);
|
||||||
addEventListener(MouseEvent.CLICK, onMouse);
|
addEventListener(MouseEvent.CLICK, onMouse);
|
||||||
// addEventListener("rightMouseDown", onMouse);
|
|
||||||
// addEventListener("rightClick", onMouse);
|
|
||||||
addEventListener("middleMouseDown", onMouse);
|
addEventListener("middleMouseDown", onMouse);
|
||||||
addEventListener("middleClick", onMouse);
|
addEventListener("middleClick", onMouse);
|
||||||
addEventListener(MouseEvent.DOUBLE_CLICK, onMouse);
|
addEventListener(MouseEvent.DOUBLE_CLICK, onMouse);
|
||||||
@@ -309,6 +309,26 @@ package alternativa.engine3d.core {
|
|||||||
addEventListener(Event.REMOVED_FROM_STAGE, onRemoveFromStage);
|
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 {
|
private function onMouse(mouseEvent:MouseEvent):void {
|
||||||
var prev:int = eventsLength - 1;
|
var prev:int = eventsLength - 1;
|
||||||
// case of mouseMove repeats
|
// case of mouseMove repeats
|
||||||
@@ -375,7 +395,7 @@ package alternativa.engine3d.core {
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @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 i:int;
|
||||||
var mouseEvent:MouseEvent;
|
var mouseEvent:MouseEvent;
|
||||||
// Case of last coordinates fits in the view.
|
// Case of last coordinates fits in the view.
|
||||||
@@ -414,6 +434,11 @@ package alternativa.engine3d.core {
|
|||||||
if (!processMiddleButton) {
|
if (!processMiddleButton) {
|
||||||
pressedMiddleTarget = null;
|
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
|
// Creation of exclusive rays
|
||||||
var mouseX:Number = 1e+22;
|
var mouseX:Number = 1e+22;
|
||||||
@@ -434,6 +459,9 @@ package alternativa.engine3d.core {
|
|||||||
if (!processMiddleButton && (mouseEvent.type == "middleMouseDown" || mouseEvent.type == "middleClick")) {
|
if (!processMiddleButton && (mouseEvent.type == "middleMouseDown" || mouseEvent.type == "middleClick")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (!processRightButton && (mouseEvent.type == "rightMouseDown" || mouseEvent.type == "rightClick")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (mouseEvent.type != "mouseOut") {
|
if (mouseEvent.type != "mouseOut") {
|
||||||
// Calculation of ray within the camera
|
// Calculation of ray within the camera
|
||||||
@@ -652,24 +680,23 @@ package alternativa.engine3d.core {
|
|||||||
}
|
}
|
||||||
pressedMiddleTarget = null;
|
pressedMiddleTarget = null;
|
||||||
break;
|
break;
|
||||||
// case "rightMouseDown":
|
case "rightMouseDown":
|
||||||
// defineTarget(index);
|
defineTarget(index);
|
||||||
// if (target != null) {
|
if (target != null) {
|
||||||
// propagateEvent(MouseEvent3D.RIGHT_MOUSE_DOWN, mouseEvent, camera, target, targetSurface, branchToVector(target, branch));
|
propagateEvent(MouseEvent3D.RIGHT_MOUSE_DOWN, mouseEvent, camera, target, targetSurface, branchToVector(target, branch));
|
||||||
// }
|
}
|
||||||
// pressedTarget = target;
|
pressedRightTarget = target;
|
||||||
// break;
|
break;
|
||||||
// case "rightClick":
|
case "rightClick":
|
||||||
// defineTarget(index);
|
defineTarget(index);
|
||||||
// if (target != null) {
|
if (target != null) {
|
||||||
// propagateEvent(MouseEvent3D.RIGHT_MOUSE_UP, mouseEvent, camera, target, targetSurface, branchToVector(target, branch));
|
propagateEvent(MouseEvent3D.RIGHT_MOUSE_UP, mouseEvent, camera, target, targetSurface, branchToVector(target, branch));
|
||||||
// if (pressedTarget == target) {
|
if (pressedRightTarget == target) {
|
||||||
// clickedTarget = target;
|
propagateEvent(MouseEvent3D.RIGHT_CLICK, mouseEvent, camera, target, targetSurface, branchToVector(target, branch));
|
||||||
// propagateEvent(MouseEvent3D.RIGHT_CLICK, mouseEvent, camera, target, targetSurface, branchToVector(target, branch));
|
}
|
||||||
// }
|
}
|
||||||
// }
|
pressedRightTarget = null;
|
||||||
// pressedTarget = null;
|
break;
|
||||||
// break;
|
|
||||||
case "mouseMove":
|
case "mouseMove":
|
||||||
defineTarget(index);
|
defineTarget(index);
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
|
|||||||
@@ -46,23 +46,23 @@ package alternativa.engine3d.core.events {
|
|||||||
*/
|
*/
|
||||||
public static const MOUSE_UP:String = "mouseUp3D";
|
public static const MOUSE_UP:String = "mouseUp3D";
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Defines the value of the <code>type</code> property of a <code>rightClick3D</code> event object.
|
* Defines the value of the <code>type</code> property of a <code>rightClick3D</code> event object.
|
||||||
// * @eventType rightClick3D
|
* @eventType rightClick3D
|
||||||
// */
|
*/
|
||||||
// public static const RIGHT_CLICK:String = "rightClick3D";
|
public static const RIGHT_CLICK:String = "rightClick3D";
|
||||||
//
|
|
||||||
// /**
|
/**
|
||||||
// * Defines the value of the <code>type</code> property of a <code>rightMouseDown3D</code> event object.
|
* Defines the value of the <code>type</code> property of a <code>rightMouseDown3D</code> event object.
|
||||||
// * @eventType rightMouseDown3D
|
* @eventType rightMouseDown3D
|
||||||
// */
|
*/
|
||||||
// public static const RIGHT_MOUSE_DOWN:String = "rightMouseDown3D";
|
public static const RIGHT_MOUSE_DOWN:String = "rightMouseDown3D";
|
||||||
//
|
|
||||||
// /**
|
/**
|
||||||
// * Defines the value of the <code>type</code> property of a <code>rightMouseUp3D</code> event object.
|
* Defines the value of the <code>type</code> property of a <code>rightMouseUp3D</code> event object.
|
||||||
// * @eventType rightMouseUp3D
|
* @eventType rightMouseUp3D
|
||||||
// */
|
*/
|
||||||
// public static const RIGHT_MOUSE_UP:String = "rightMouseUp3D";
|
public static const RIGHT_MOUSE_UP:String = "rightMouseUp3D";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the value of the <code>type</code> property of a <code>middleClick3D</code> event object.
|
* Defines the value of the <code>type</code> property of a <code>middleClick3D</code> event object.
|
||||||
|
|||||||
Reference in New Issue
Block a user