mirror of
https://github.com/MapMakersAndProgrammers/Alternativa3D.git
synced 2025-10-26 01:49:07 -07:00
Middle button mouse down, up and clicks support
This commit is contained in:
@@ -323,7 +323,10 @@ public class Camera3D extends Object3D {
|
||||
if (lightsLength > 0) sortLights(0, lightsLength - 1);
|
||||
|
||||
// Calculating the rays of mouse events
|
||||
view.calculateRays(this, (globalMouseHandlingType & Object3D.MOUSE_HANDLING_MOVING) != 0, (globalMouseHandlingType & Object3D.MOUSE_HANDLING_PRESSING) != 0, (globalMouseHandlingType & Object3D.MOUSE_HANDLING_WHEEL) != 0);
|
||||
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);
|
||||
for (i = origins.length; i < view.raysLength; i++) {
|
||||
origins[i] = new Vector3D();
|
||||
directions[i] = new Vector3D();
|
||||
|
||||
@@ -64,18 +64,53 @@ package alternativa.engine3d.core {
|
||||
*/
|
||||
[Event (name="doubleClick", type="alternativa.engine3d.core.events.MouseEvent3D")]
|
||||
|
||||
/**
|
||||
* Dispatched when a user presses and releases the middle button
|
||||
* of the user's pointing device over the same <code>Object3D</code>.
|
||||
* Any other evens can occur between pressing and releasing the button.
|
||||
*
|
||||
* @eventType alternativa.engine3d.events.MouseEvent3D.CLICK
|
||||
*/
|
||||
[Event (name="middleClick", type="alternativa.engine3d.core.events.MouseEvent3D")]
|
||||
|
||||
/**
|
||||
* Dispatched when a user presses the middle pointing device button over an <code>Object3D</code> instance.
|
||||
* Any other evens can occur between pressing and releasing the button.
|
||||
*
|
||||
* @eventType alternativa.engine3d.events.MouseEvent3D.CLICK
|
||||
*/
|
||||
[Event (name="middleMouseDown", type="alternativa.engine3d.core.events.MouseEvent3D")]
|
||||
|
||||
/**
|
||||
* Dispatched when a user releases the pointing device button over an <code>Object3D</code> instance.
|
||||
* @eventType alternativa.engine3d.events.MouseEvent3D.MOUSE_UP
|
||||
*/
|
||||
[Event (name="middleMouseUp", type="alternativa.engine3d.core.events.MouseEvent3D")]
|
||||
|
||||
/**
|
||||
* Dispatched when a user presses the pointing device button over an <code>Object3D</code> instance.
|
||||
* @eventType alternativa.engine3d.events.MouseEvent3D.MOUSE_DOWN
|
||||
*/
|
||||
[Event (name="mouseDown", type="alternativa.engine3d.core.events.MouseEvent3D")]
|
||||
|
||||
/**
|
||||
* Dispatched when a user moves the pointing device while it is over an <code>Object3D</code>.
|
||||
* @eventType alternativa.engine3d.events.MouseEvent3D.MOUSE_MOVE
|
||||
*/
|
||||
[Event (name="mouseMove", type="alternativa.engine3d.core.events.MouseEvent3D")]
|
||||
|
||||
/**
|
||||
* Dispatched when a user releases the pointing device button over an <code>Object3D</code> instance.
|
||||
* @eventType alternativa.engine3d.events.MouseEvent3D.MOUSE_UP
|
||||
*/
|
||||
[Event (name="mouseUp", type="alternativa.engine3d.core.events.MouseEvent3D")]
|
||||
|
||||
/**
|
||||
* Dispatched when the user moves a pointing device away from an <code>Object3D</code> instance.
|
||||
* @eventType alternativa.engine3d.events.MouseEvent3D.MOUSE_OUT
|
||||
*/
|
||||
[Event (name="mouseOut", type="alternativa.engine3d.core.events.MouseEvent3D")]
|
||||
|
||||
/**
|
||||
* Dispatched when the user moves a pointing device over an <code>Object3D</code> instance.
|
||||
* @eventType alternativa.engine3d.events.MouseEvent3D.MOUSE_OVER
|
||||
@@ -83,10 +118,33 @@ package alternativa.engine3d.core {
|
||||
[Event (name="mouseOver", type="alternativa.engine3d.core.events.MouseEvent3D")]
|
||||
|
||||
/**
|
||||
* Dispatched when the user moves a pointing device away from an <code>Object3D</code> instance.
|
||||
* @eventType alternativa.engine3d.events.MouseEvent3D.MOUSE_OUT
|
||||
* Dispatched when a mouse wheel is spun over an <code>Object3D</code> instance.
|
||||
* @eventType alternativa.engine3d.events.MouseEvent3D.MOUSE_WHEEL
|
||||
*/
|
||||
[Event (name="mouseOut", type="alternativa.engine3d.core.events.MouseEvent3D")]
|
||||
[Event (name="mouseWheel", type="alternativa.engine3d.core.events.MouseEvent3D")]
|
||||
|
||||
/**
|
||||
* Dispatched when a user presses and releases the right button
|
||||
* of the user's pointing device over the same <code>Object3D</code>.
|
||||
* Any other evens can occur between pressing and releasing the button.
|
||||
*
|
||||
* @eventType alternativa.engine3d.events.MouseEvent3D.CLICK
|
||||
*/
|
||||
[Event (name="rightClick", type="alternativa.engine3d.core.events.MouseEvent3D")]
|
||||
|
||||
/**
|
||||
* Dispatched when a user presses the right pointing device button over an <code>Object3D</code> instance.
|
||||
* Any other evens can occur between pressing and releasing the button.
|
||||
*
|
||||
* @eventType alternativa.engine3d.events.MouseEvent3D.CLICK
|
||||
*/
|
||||
[Event (name="rightMouseDown", type="alternativa.engine3d.core.events.MouseEvent3D")]
|
||||
|
||||
/**
|
||||
* Dispatched when a user releases the pointing device button over an <code>Object3D</code> instance.
|
||||
* @eventType alternativa.engine3d.events.MouseEvent3D.MOUSE_UP
|
||||
*/
|
||||
[Event (name="rightMouseUp", type="alternativa.engine3d.core.events.MouseEvent3D")]
|
||||
|
||||
/**
|
||||
* Dispatched when the user moves a pointing device over an <code>Object3D</code> instance.
|
||||
@@ -100,18 +158,6 @@ package alternativa.engine3d.core {
|
||||
*/
|
||||
[Event (name="rollOut", type="alternativa.engine3d.core.events.MouseEvent3D")]
|
||||
|
||||
/**
|
||||
* Dispatched when a user moves the pointing device while it is over an <code>Object3D</code>.
|
||||
* @eventType alternativa.engine3d.events.MouseEvent3D.MOUSE_MOVE
|
||||
*/
|
||||
[Event (name="mouseMove", type="alternativa.engine3d.core.events.MouseEvent3D")]
|
||||
|
||||
/**
|
||||
* Dispatched when a mouse wheel is spun over an <code>Object3D</code> instance.
|
||||
* @eventType alternativa.engine3d.events.MouseEvent3D.MOUSE_WHEEL
|
||||
*/
|
||||
[Event (name="mouseWheel", type="alternativa.engine3d.core.events.MouseEvent3D")]
|
||||
|
||||
/**
|
||||
* <code>Object3D</code> class ia a base class for all 3D objects. Any <code>Object3D</code> has a property
|
||||
* of transformation that defines its position in space, the property <code>boundBox</code>,
|
||||
@@ -138,6 +184,10 @@ package alternativa.engine3d.core {
|
||||
* @private
|
||||
*/
|
||||
alternativa3d static const MOUSE_HANDLING_WHEEL:uint = 4;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
alternativa3d static const MOUSE_HANDLING_MIDDLE_BUTTON:uint = 8;
|
||||
|
||||
/**
|
||||
* Custom data available to store within <code>Object3D</code> by user.
|
||||
@@ -694,6 +744,9 @@ package alternativa.engine3d.core {
|
||||
if (type == MouseEvent3D.MOUSE_WHEEL) {
|
||||
mouseHandlingType |= MOUSE_HANDLING_WHEEL;
|
||||
}
|
||||
if (type == MouseEvent3D.MIDDLE_CLICK || type == MouseEvent3D.MIDDLE_MOUSE_DOWN || type == MouseEvent3D.MIDDLE_MOUSE_UP) {
|
||||
mouseHandlingType |= MOUSE_HANDLING_MIDDLE_BUTTON;
|
||||
}
|
||||
}
|
||||
if (vector.indexOf(listener) < 0) {
|
||||
vector.push(listener);
|
||||
@@ -740,6 +793,9 @@ package alternativa.engine3d.core {
|
||||
if (type == MouseEvent3D.MOUSE_WHEEL) {
|
||||
mouseHandlingType &= ~MOUSE_HANDLING_WHEEL;
|
||||
}
|
||||
if (type == MouseEvent3D.MIDDLE_CLICK || type == MouseEvent3D.MIDDLE_MOUSE_DOWN || type == MouseEvent3D.MIDDLE_MOUSE_UP) {
|
||||
mouseHandlingType &= ~MOUSE_HANDLING_MIDDLE_BUTTON;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,6 +156,7 @@ package alternativa.engine3d.core {
|
||||
private var targetSurface:Surface;
|
||||
private var targetDepth:Number;
|
||||
private var pressedTarget:Object3D;
|
||||
private var pressedMiddleTarget:Object3D;
|
||||
private var clickedTarget:Object3D;
|
||||
private var overedTarget:Object3D;
|
||||
private var overedTargetSurface:Surface;
|
||||
@@ -295,10 +296,10 @@ package alternativa.engine3d.core {
|
||||
// Listeners
|
||||
addEventListener(MouseEvent.MOUSE_DOWN, onMouse);
|
||||
addEventListener(MouseEvent.CLICK, onMouse);
|
||||
addEventListener(MouseEvent.RIGHT_MOUSE_DOWN, onMouse);
|
||||
addEventListener(MouseEvent.RIGHT_CLICK, onMouse);
|
||||
addEventListener(MouseEvent.MIDDLE_MOUSE_DOWN, onMouse);
|
||||
addEventListener(MouseEvent.MIDDLE_CLICK, onMouse);
|
||||
// addEventListener("rightMouseDown", onMouse);
|
||||
// addEventListener("rightClick", onMouse);
|
||||
addEventListener("middleMouseDown", onMouse);
|
||||
addEventListener("middleClick", onMouse);
|
||||
addEventListener(MouseEvent.DOUBLE_CLICK, onMouse);
|
||||
addEventListener(MouseEvent.MOUSE_MOVE, onMouse);
|
||||
addEventListener(MouseEvent.MOUSE_OVER, onMouse);
|
||||
@@ -374,7 +375,7 @@ package alternativa.engine3d.core {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
alternativa3d function calculateRays(camera:Camera3D, processMoving:Boolean, processPressing:Boolean, processMouseWheel:Boolean):void {
|
||||
alternativa3d function calculateRays(camera:Camera3D, processMoving:Boolean, processPressing:Boolean, processMouseWheel:Boolean, processMiddleButton:Boolean):void {
|
||||
var i:int;
|
||||
var mouseEvent:MouseEvent;
|
||||
// Case of last coordinates fits in the view.
|
||||
@@ -410,6 +411,9 @@ package alternativa.engine3d.core {
|
||||
pressedTarget = null;
|
||||
clickedTarget = null;
|
||||
}
|
||||
if (!processMiddleButton) {
|
||||
pressedMiddleTarget = null;
|
||||
}
|
||||
|
||||
// Creation of exclusive rays
|
||||
var mouseX:Number = 1e+22;
|
||||
@@ -427,6 +431,9 @@ package alternativa.engine3d.core {
|
||||
if (!processMouseWheel && mouseEvent.type == MouseEvent.MOUSE_WHEEL) {
|
||||
continue;
|
||||
}
|
||||
if (!processMiddleButton && (mouseEvent.type == "middleMouseDown" || mouseEvent.type == "middleClick")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mouseEvent.type != "mouseOut") {
|
||||
// Calculation of ray within the camera
|
||||
@@ -606,12 +613,6 @@ package alternativa.engine3d.core {
|
||||
}
|
||||
pressedTarget = target;
|
||||
break;
|
||||
case "mouseWheel":
|
||||
defineTarget(index);
|
||||
if (target != null) {
|
||||
propagateEvent(MouseEvent3D.MOUSE_WHEEL, mouseEvent, camera, target, targetSurface, branchToVector(target, branch));
|
||||
}
|
||||
break;
|
||||
case "click":
|
||||
defineTarget(index);
|
||||
if (target != null) {
|
||||
@@ -623,42 +624,6 @@ package alternativa.engine3d.core {
|
||||
}
|
||||
pressedTarget = null;
|
||||
break;
|
||||
case "middleMouseDown":
|
||||
defineTarget(index);
|
||||
if (target != null) {
|
||||
propagateEvent(MouseEvent3D.MIDDLE_MOUSE_DOWN, mouseEvent, camera, target, targetSurface, branchToVector(target, branch));
|
||||
}
|
||||
pressedTarget = target;
|
||||
break;
|
||||
case "middleClick":
|
||||
defineTarget(index);
|
||||
if (target != null) {
|
||||
propagateEvent(MouseEvent3D.MIDDLE_MOUSE_UP, mouseEvent, camera, target, targetSurface, branchToVector(target, branch));
|
||||
if (pressedTarget == target) {
|
||||
clickedTarget = target;
|
||||
propagateEvent(MouseEvent3D.MIDDLE_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));
|
||||
}
|
||||
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 "doubleClick":
|
||||
defineTarget(index);
|
||||
if (target != null) {
|
||||
@@ -670,6 +635,41 @@ package alternativa.engine3d.core {
|
||||
clickedTarget = null;
|
||||
pressedTarget = null;
|
||||
break;
|
||||
case "middleMouseDown":
|
||||
defineTarget(index);
|
||||
if (target != null) {
|
||||
propagateEvent(MouseEvent3D.MIDDLE_MOUSE_DOWN, mouseEvent, camera, target, targetSurface, branchToVector(target, branch));
|
||||
}
|
||||
pressedMiddleTarget = target;
|
||||
break;
|
||||
case "middleClick":
|
||||
defineTarget(index);
|
||||
if (target != null) {
|
||||
propagateEvent(MouseEvent3D.MIDDLE_MOUSE_UP, mouseEvent, camera, target, targetSurface, branchToVector(target, branch));
|
||||
if (pressedMiddleTarget == target) {
|
||||
propagateEvent(MouseEvent3D.MIDDLE_CLICK, mouseEvent, camera, target, targetSurface, branchToVector(target, branch));
|
||||
}
|
||||
}
|
||||
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 "mouseMove":
|
||||
defineTarget(index);
|
||||
if (target != null) {
|
||||
@@ -679,6 +679,12 @@ package alternativa.engine3d.core {
|
||||
processOverOut(mouseEvent, camera);
|
||||
}
|
||||
break;
|
||||
case "mouseWheel":
|
||||
defineTarget(index);
|
||||
if (target != null) {
|
||||
propagateEvent(MouseEvent3D.MOUSE_WHEEL, mouseEvent, camera, target, targetSurface, branchToVector(target, branch));
|
||||
}
|
||||
break;
|
||||
case "mouseOut":
|
||||
// TODO: lastEvent not need change here. For example when MOUSE_OUT and MOUSE_MOVE exists in the one frame.
|
||||
lastEvent = null;
|
||||
|
||||
@@ -46,23 +46,23 @@ package alternativa.engine3d.core.events {
|
||||
*/
|
||||
public static const MOUSE_UP:String = "mouseUp3D";
|
||||
|
||||
/**
|
||||
* Defines the value of the <code>type</code> property of a <code>rightClick3D</code> event object.
|
||||
* @eventType rightClick3D
|
||||
*/
|
||||
public static const RIGHT_CLICK:String = "rightClick3D";
|
||||
|
||||
/**
|
||||
* Defines the value of the <code>type</code> property of a <code>rightMouseDown3D</code> event object.
|
||||
* @eventType 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.
|
||||
* @eventType rightMouseUp3D
|
||||
*/
|
||||
public static const RIGHT_MOUSE_UP:String = "rightMouseUp3D";
|
||||
// /**
|
||||
// * Defines the value of the <code>type</code> property of a <code>rightClick3D</code> event object.
|
||||
// * @eventType rightClick3D
|
||||
// */
|
||||
// public static const RIGHT_CLICK:String = "rightClick3D";
|
||||
//
|
||||
// /**
|
||||
// * Defines the value of the <code>type</code> property of a <code>rightMouseDown3D</code> event object.
|
||||
// * @eventType 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.
|
||||
// * @eventType 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.
|
||||
|
||||
Reference in New Issue
Block a user