|
@@ -14677,7 +14677,7 @@ var BABYLON;
|
|
|
var url = String(urlArg); // assign a new string, so that the original is still available in case of fallback
|
|
|
var fromData = url.substr(0, 5) === "data:";
|
|
|
var fromBlob = url.substr(0, 5) === "blob:";
|
|
|
- var isBase64 = fromData && url.indexOf("base64") !== -1;
|
|
|
+ var isBase64 = fromData && url.indexOf(";base64,") !== -1;
|
|
|
var texture = fallback ? fallback : new BABYLON.InternalTexture(this, BABYLON.InternalTexture.DATASOURCE_URL);
|
|
|
// establish the file extension, if possible
|
|
|
var lastDot = url.lastIndexOf('.');
|
|
@@ -17901,16 +17901,18 @@ var BABYLON;
|
|
|
* Attach a behavior to the node
|
|
|
* @see http://doc.babylonjs.com/features/behaviour
|
|
|
* @param behavior defines the behavior to attach
|
|
|
+ * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
|
|
|
* @returns the current Node
|
|
|
*/
|
|
|
- Node.prototype.addBehavior = function (behavior) {
|
|
|
+ Node.prototype.addBehavior = function (behavior, attachImmediately) {
|
|
|
var _this = this;
|
|
|
+ if (attachImmediately === void 0) { attachImmediately = false; }
|
|
|
var index = this._behaviors.indexOf(behavior);
|
|
|
if (index !== -1) {
|
|
|
return this;
|
|
|
}
|
|
|
behavior.init();
|
|
|
- if (this._scene.isLoading) {
|
|
|
+ if (this._scene.isLoading && !attachImmediately) {
|
|
|
// We defer the attach when the scene will be loaded
|
|
|
this._scene.onDataLoadedObservable.addOnce(function () {
|
|
|
behavior.attach(_this);
|
|
@@ -95712,6 +95714,14 @@ var BABYLON;
|
|
|
}
|
|
|
else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERMOVE) {
|
|
|
var pointerId = pointerInfo.event.pointerId;
|
|
|
+ // If drag was started with anyMouseID specified, set pointerID to the next mouse that moved
|
|
|
+ if (_this.currentDraggingPointerID === PointerDragBehavior._AnyMouseID && pointerId !== PointerDragBehavior._AnyMouseID && pointerInfo.event.pointerType == "mouse") {
|
|
|
+ if (_this._lastPointerRay[_this.currentDraggingPointerID]) {
|
|
|
+ _this._lastPointerRay[pointerId] = _this._lastPointerRay[_this.currentDraggingPointerID];
|
|
|
+ delete _this._lastPointerRay[_this.currentDraggingPointerID];
|
|
|
+ }
|
|
|
+ _this.currentDraggingPointerID = pointerId;
|
|
|
+ }
|
|
|
// Keep track of last pointer ray, this is used simulating the start of a drag in startDrag()
|
|
|
if (!_this._lastPointerRay[pointerId]) {
|
|
|
_this._lastPointerRay[pointerId] = new BABYLON.Ray(new BABYLON.Vector3(), new BABYLON.Vector3());
|
|
@@ -95749,20 +95759,23 @@ var BABYLON;
|
|
|
};
|
|
|
/**
|
|
|
* Simulates the start of a pointer drag event on the behavior
|
|
|
- * @param pointerId pointerID of the pointer that should be simulated (Default: 1 for mouse pointer)
|
|
|
+ * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
|
|
|
* @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
|
|
|
* @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
|
|
|
*/
|
|
|
PointerDragBehavior.prototype.startDrag = function (pointerId, fromRay, startPickedPoint) {
|
|
|
- if (pointerId === void 0) { pointerId = 1; }
|
|
|
+ if (pointerId === void 0) { pointerId = PointerDragBehavior._AnyMouseID; }
|
|
|
this._startDrag(pointerId, fromRay, startPickedPoint);
|
|
|
- if (this._lastPointerRay[pointerId]) {
|
|
|
+ var lastRay = this._lastPointerRay[pointerId];
|
|
|
+ if (pointerId === PointerDragBehavior._AnyMouseID) {
|
|
|
+ lastRay = this._lastPointerRay[Object.keys(this._lastPointerRay)[0]];
|
|
|
+ }
|
|
|
+ if (lastRay) {
|
|
|
// if there was a last pointer ray drag the object there
|
|
|
- this._moveDrag(this._lastPointerRay[pointerId]);
|
|
|
+ this._moveDrag(lastRay);
|
|
|
}
|
|
|
};
|
|
|
PointerDragBehavior.prototype._startDrag = function (pointerId, fromRay, startPickedPoint) {
|
|
|
- if (pointerId === void 0) { pointerId = 1; }
|
|
|
if (!this._scene.activeCamera || this.dragging || !this._attachedNode) {
|
|
|
return;
|
|
|
}
|
|
@@ -95906,6 +95919,7 @@ var BABYLON;
|
|
|
this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
|
|
|
}
|
|
|
};
|
|
|
+ PointerDragBehavior._AnyMouseID = -2;
|
|
|
return PointerDragBehavior;
|
|
|
}());
|
|
|
BABYLON.PointerDragBehavior = PointerDragBehavior;
|