|
@@ -33,6 +33,7 @@ var BABYLON;
|
|
|
var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, BABYLON.Engine.TEXTUREFORMAT_RGBA) || this;
|
|
|
_this._isDirty = false;
|
|
|
_this._rootContainer = new GUI.Container("root");
|
|
|
+ _this._capturingControl = {};
|
|
|
_this._linkedControls = new Array();
|
|
|
_this._isFullscreen = false;
|
|
|
_this._fullscreenViewport = new BABYLON.Viewport(0, 0, 1, 1);
|
|
@@ -340,7 +341,7 @@ var BABYLON;
|
|
|
var measure = new GUI.Measure(0, 0, renderWidth, renderHeight);
|
|
|
this._rootContainer._draw(measure, context);
|
|
|
};
|
|
|
- AdvancedDynamicTexture.prototype._doPicking = function (x, y, type, buttonIndex) {
|
|
|
+ AdvancedDynamicTexture.prototype._doPicking = function (x, y, type, pointerId, buttonIndex) {
|
|
|
var scene = this.getScene();
|
|
|
if (!scene) {
|
|
|
return;
|
|
@@ -351,11 +352,11 @@ var BABYLON;
|
|
|
x = x * ((textureSize.width / this._renderScale) / engine.getRenderWidth());
|
|
|
y = y * ((textureSize.height / this._renderScale) / engine.getRenderHeight());
|
|
|
}
|
|
|
- if (this._capturingControl) {
|
|
|
- this._capturingControl._processObservables(type, x, y, buttonIndex);
|
|
|
+ if (this._capturingControl[pointerId]) {
|
|
|
+ this._capturingControl[pointerId]._processObservables(type, x, y, pointerId, buttonIndex);
|
|
|
return;
|
|
|
}
|
|
|
- if (!this._rootContainer._processPicking(x, y, type, buttonIndex)) {
|
|
|
+ if (!this._rootContainer._processPicking(x, y, type, pointerId, buttonIndex)) {
|
|
|
if (type === BABYLON.PointerEventTypes.POINTERMOVE) {
|
|
|
if (this._lastControlOver) {
|
|
|
this._lastControlOver._onPointerOut(this._lastControlOver);
|
|
@@ -389,7 +390,7 @@ var BABYLON;
|
|
|
var x = (scene.pointerX / engine.getHardwareScalingLevel() - viewport.x * engine.getRenderWidth()) / viewport.width;
|
|
|
var y = (scene.pointerY / engine.getHardwareScalingLevel() - viewport.y * engine.getRenderHeight()) / viewport.height;
|
|
|
_this._shouldBlockPointer = false;
|
|
|
- _this._doPicking(x, y, pi.type, pi.event.button);
|
|
|
+ _this._doPicking(x, y, pi.type, pi.event.pointerId || 0, pi.event.button);
|
|
|
pi.skipOnPointerObservable = _this._shouldBlockPointer;
|
|
|
});
|
|
|
this._attachToOnPointerOut(scene);
|
|
@@ -407,16 +408,17 @@ var BABYLON;
|
|
|
&& pi.type !== BABYLON.PointerEventTypes.POINTERDOWN) {
|
|
|
return;
|
|
|
}
|
|
|
+ var pointerId = pi.event.pointerId || 0;
|
|
|
if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
|
|
|
var uv = pi.pickInfo.getTextureCoordinates();
|
|
|
if (uv) {
|
|
|
var size = _this.getSize();
|
|
|
- _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pi.event.button);
|
|
|
+ _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pointerId, pi.event.button);
|
|
|
}
|
|
|
}
|
|
|
else if (pi.type === BABYLON.PointerEventTypes.POINTERUP) {
|
|
|
if (_this._lastControlDown) {
|
|
|
- _this._lastControlDown.forcePointerUp();
|
|
|
+ _this._lastControlDown.forcePointerUp(pointerId);
|
|
|
}
|
|
|
_this._lastControlDown = null;
|
|
|
_this.focusedControl = null;
|
|
@@ -854,6 +856,7 @@ var BABYLON;
|
|
|
this._downCount = 0;
|
|
|
this._enterCount = 0;
|
|
|
this._doNotRender = false;
|
|
|
+ this._downPointerIds = {};
|
|
|
this.isHitTestVisible = true;
|
|
|
this.isPointerBlocker = false;
|
|
|
this.isFocusInvisible = false;
|
|
@@ -1659,14 +1662,14 @@ var BABYLON;
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
- Control.prototype._processPicking = function (x, y, type, buttonIndex) {
|
|
|
+ Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
|
|
|
if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
|
|
|
return false;
|
|
|
}
|
|
|
if (!this.contains(x, y)) {
|
|
|
return false;
|
|
|
}
|
|
|
- this._processObservables(type, x, y, buttonIndex);
|
|
|
+ this._processObservables(type, x, y, pointerId, buttonIndex);
|
|
|
return true;
|
|
|
};
|
|
|
Control.prototype._onPointerMove = function (target, coordinates) {
|
|
@@ -1690,26 +1693,36 @@ var BABYLON;
|
|
|
if (canNotify && this.parent != null)
|
|
|
this.parent._onPointerOut(target);
|
|
|
};
|
|
|
- Control.prototype._onPointerDown = function (target, coordinates, buttonIndex) {
|
|
|
+ Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
|
|
|
if (this._downCount !== 0) {
|
|
|
return false;
|
|
|
}
|
|
|
this._downCount++;
|
|
|
+ this._downPointerIds[pointerId] = true;
|
|
|
var canNotify = this.onPointerDownObservable.notifyObservers(new GUI.Vector2WithInfo(coordinates, buttonIndex), -1, target, this);
|
|
|
if (canNotify && this.parent != null)
|
|
|
- this.parent._onPointerDown(target, coordinates, buttonIndex);
|
|
|
+ this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
|
|
|
return true;
|
|
|
};
|
|
|
- Control.prototype._onPointerUp = function (target, coordinates, buttonIndex) {
|
|
|
+ Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex) {
|
|
|
this._downCount = 0;
|
|
|
+ delete this._downPointerIds[pointerId];
|
|
|
var canNotify = this.onPointerUpObservable.notifyObservers(new GUI.Vector2WithInfo(coordinates, buttonIndex), -1, target, this);
|
|
|
if (canNotify && this.parent != null)
|
|
|
- this.parent._onPointerUp(target, coordinates, buttonIndex);
|
|
|
+ this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex);
|
|
|
};
|
|
|
- Control.prototype.forcePointerUp = function () {
|
|
|
- this._onPointerUp(this, BABYLON.Vector2.Zero(), 0);
|
|
|
+ Control.prototype.forcePointerUp = function (pointerId) {
|
|
|
+ if (pointerId === void 0) { pointerId = null; }
|
|
|
+ if (pointerId !== null) {
|
|
|
+ this._onPointerUp(this, BABYLON.Vector2.Zero(), pointerId, 0);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ for (var key in this._downPointerIds) {
|
|
|
+ this._onPointerUp(this, BABYLON.Vector2.Zero(), +key, 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
};
|
|
|
- Control.prototype._processObservables = function (type, x, y, buttonIndex) {
|
|
|
+ Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex) {
|
|
|
this._dummyVector2.copyFromFloats(x, y);
|
|
|
if (type === BABYLON.PointerEventTypes.POINTERMOVE) {
|
|
|
this._onPointerMove(this, this._dummyVector2);
|
|
@@ -1724,14 +1737,14 @@ var BABYLON;
|
|
|
return true;
|
|
|
}
|
|
|
if (type === BABYLON.PointerEventTypes.POINTERDOWN) {
|
|
|
- this._onPointerDown(this, this._dummyVector2, buttonIndex);
|
|
|
+ this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
|
|
|
this._host._lastControlDown = this;
|
|
|
this._host._lastPickedControl = this;
|
|
|
return true;
|
|
|
}
|
|
|
if (type === BABYLON.PointerEventTypes.POINTERUP) {
|
|
|
if (this._host._lastControlDown) {
|
|
|
- this._host._lastControlDown._onPointerUp(this, this._dummyVector2, buttonIndex);
|
|
|
+ this._host._lastControlDown._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex);
|
|
|
}
|
|
|
this._host._lastControlDown = null;
|
|
|
return true;
|
|
@@ -2043,7 +2056,7 @@ var BABYLON;
|
|
|
this.onAfterDrawObservable.notifyObservers(this);
|
|
|
}
|
|
|
};
|
|
|
- Container.prototype._processPicking = function (x, y, type, buttonIndex) {
|
|
|
+ Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
|
|
|
if (!this.isVisible || this.notRenderable) {
|
|
|
return false;
|
|
|
}
|
|
@@ -2053,14 +2066,14 @@ var BABYLON;
|
|
|
// Checking backwards to pick closest first
|
|
|
for (var index = this._children.length - 1; index >= 0; index--) {
|
|
|
var child = this._children[index];
|
|
|
- if (child._processPicking(x, y, type, buttonIndex)) {
|
|
|
+ if (child._processPicking(x, y, type, pointerId, buttonIndex)) {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
if (!this.isHitTestVisible) {
|
|
|
return false;
|
|
|
}
|
|
|
- return this._processObservables(type, x, y, buttonIndex);
|
|
|
+ return this._processObservables(type, x, y, pointerId, buttonIndex);
|
|
|
};
|
|
|
Container.prototype._clipForChildren = function (context) {
|
|
|
// DO nothing
|
|
@@ -2933,13 +2946,13 @@ var BABYLON;
|
|
|
}
|
|
|
this.value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
|
|
|
};
|
|
|
- Slider.prototype._onPointerDown = function (target, coordinates, buttonIndex) {
|
|
|
- if (!_super.prototype._onPointerDown.call(this, target, coordinates, buttonIndex)) {
|
|
|
+ Slider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
|
|
|
+ if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
|
|
|
return false;
|
|
|
}
|
|
|
this._pointerIsDown = true;
|
|
|
this._updateValueFromPointer(coordinates.x, coordinates.y);
|
|
|
- this._host._capturingControl = this;
|
|
|
+ this._host._capturingControl[pointerId] = this;
|
|
|
return true;
|
|
|
};
|
|
|
Slider.prototype._onPointerMove = function (target, coordinates) {
|
|
@@ -2948,10 +2961,10 @@ var BABYLON;
|
|
|
}
|
|
|
_super.prototype._onPointerMove.call(this, target, coordinates);
|
|
|
};
|
|
|
- Slider.prototype._onPointerUp = function (target, coordinates, buttonIndex) {
|
|
|
+ Slider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex) {
|
|
|
this._pointerIsDown = false;
|
|
|
- this._host._capturingControl = null;
|
|
|
- _super.prototype._onPointerUp.call(this, target, coordinates, buttonIndex);
|
|
|
+ delete this._host._capturingControl[pointerId];
|
|
|
+ _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex);
|
|
|
};
|
|
|
return Slider;
|
|
|
}(GUI.Control));
|
|
@@ -3073,8 +3086,8 @@ var BABYLON;
|
|
|
context.restore();
|
|
|
};
|
|
|
// Events
|
|
|
- Checkbox.prototype._onPointerDown = function (target, coordinates, buttonIndex) {
|
|
|
- if (!_super.prototype._onPointerDown.call(this, target, coordinates, buttonIndex)) {
|
|
|
+ Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
|
|
|
+ if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
|
|
|
return false;
|
|
|
}
|
|
|
this.isChecked = !this.isChecked;
|
|
@@ -3221,8 +3234,8 @@ var BABYLON;
|
|
|
context.restore();
|
|
|
};
|
|
|
// Events
|
|
|
- RadioButton.prototype._onPointerDown = function (target, coordinates, buttonIndex) {
|
|
|
- if (!_super.prototype._onPointerDown.call(this, target, coordinates, buttonIndex)) {
|
|
|
+ RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
|
|
|
+ if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
|
|
|
return false;
|
|
|
}
|
|
|
this.isChecked = !this.isChecked;
|
|
@@ -3929,14 +3942,14 @@ var BABYLON;
|
|
|
return "Button";
|
|
|
};
|
|
|
// While being a container, the button behaves like a control.
|
|
|
- Button.prototype._processPicking = function (x, y, type, buttonIndex) {
|
|
|
+ Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
|
|
|
if (!this.isHitTestVisible || !this.isVisible || this.notRenderable) {
|
|
|
return false;
|
|
|
}
|
|
|
if (!_super.prototype.contains.call(this, x, y)) {
|
|
|
return false;
|
|
|
}
|
|
|
- this._processObservables(type, x, y, buttonIndex);
|
|
|
+ this._processObservables(type, x, y, pointerId, buttonIndex);
|
|
|
return true;
|
|
|
};
|
|
|
Button.prototype._onPointerEnter = function (target) {
|
|
@@ -3954,8 +3967,8 @@ var BABYLON;
|
|
|
}
|
|
|
_super.prototype._onPointerOut.call(this, target);
|
|
|
};
|
|
|
- Button.prototype._onPointerDown = function (target, coordinates, buttonIndex) {
|
|
|
- if (!_super.prototype._onPointerDown.call(this, target, coordinates, buttonIndex)) {
|
|
|
+ Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
|
|
|
+ if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
|
|
|
return false;
|
|
|
}
|
|
|
if (this.pointerDownAnimation) {
|
|
@@ -3963,11 +3976,11 @@ var BABYLON;
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
- Button.prototype._onPointerUp = function (target, coordinates, buttonIndex) {
|
|
|
+ Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex) {
|
|
|
if (this.pointerUpAnimation) {
|
|
|
this.pointerUpAnimation();
|
|
|
}
|
|
|
- _super.prototype._onPointerUp.call(this, target, coordinates, buttonIndex);
|
|
|
+ _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex);
|
|
|
};
|
|
|
// Statics
|
|
|
Button.CreateImageButton = function (name, text, imageUrl) {
|
|
@@ -4349,8 +4362,8 @@ var BABYLON;
|
|
|
}
|
|
|
return false;
|
|
|
};
|
|
|
- ColorPicker.prototype._onPointerDown = function (target, coordinates, buttonIndex) {
|
|
|
- if (!_super.prototype._onPointerDown.call(this, target, coordinates, buttonIndex)) {
|
|
|
+ ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
|
|
|
+ if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
|
|
|
return false;
|
|
|
}
|
|
|
this._pointerIsDown = true;
|
|
@@ -4363,7 +4376,7 @@ var BABYLON;
|
|
|
this._pointerStartedOnWheel = true;
|
|
|
}
|
|
|
this._updateValueFromPointer(coordinates.x, coordinates.y);
|
|
|
- this._host._capturingControl = this;
|
|
|
+ this._host._capturingControl[pointerId] = this;
|
|
|
return true;
|
|
|
};
|
|
|
ColorPicker.prototype._onPointerMove = function (target, coordinates) {
|
|
@@ -4372,10 +4385,10 @@ var BABYLON;
|
|
|
}
|
|
|
_super.prototype._onPointerMove.call(this, target, coordinates);
|
|
|
};
|
|
|
- ColorPicker.prototype._onPointerUp = function (target, coordinates, buttonIndex) {
|
|
|
+ ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex) {
|
|
|
this._pointerIsDown = false;
|
|
|
- this._host._capturingControl = null;
|
|
|
- _super.prototype._onPointerUp.call(this, target, coordinates, buttonIndex);
|
|
|
+ delete this._host._capturingControl[pointerId];
|
|
|
+ _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex);
|
|
|
};
|
|
|
return ColorPicker;
|
|
|
}(GUI.Control));
|
|
@@ -4797,8 +4810,8 @@ var BABYLON;
|
|
|
}
|
|
|
context.restore();
|
|
|
};
|
|
|
- InputText.prototype._onPointerDown = function (target, coordinates, buttonIndex) {
|
|
|
- if (!_super.prototype._onPointerDown.call(this, target, coordinates, buttonIndex)) {
|
|
|
+ InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
|
|
|
+ if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
|
|
|
return false;
|
|
|
}
|
|
|
this._clickedCoordinate = coordinates.x;
|
|
@@ -4811,8 +4824,8 @@ var BABYLON;
|
|
|
this._host.focusedControl = this;
|
|
|
return true;
|
|
|
};
|
|
|
- InputText.prototype._onPointerUp = function (target, coordinates, buttonIndex) {
|
|
|
- _super.prototype._onPointerUp.call(this, target, coordinates, buttonIndex);
|
|
|
+ InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex) {
|
|
|
+ _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex);
|
|
|
};
|
|
|
InputText.prototype.dispose = function () {
|
|
|
_super.prototype.dispose.call(this);
|