@babylonjs/gui 5.15.1 → 5.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/2D/advancedDynamicTexture.d.ts +28 -4
- package/2D/advancedDynamicTexture.js +77 -35
- package/2D/advancedDynamicTexture.js.map +1 -1
- package/2D/controls/control.d.ts +7 -1
- package/2D/controls/control.js +12 -6
- package/2D/controls/control.js.map +1 -1
- package/2D/controls/grid.js +5 -5
- package/2D/controls/grid.js.map +1 -1
- package/2D/controls/virtualKeyboard.js +1 -1
- package/2D/controls/virtualKeyboard.js.map +1 -1
- package/3D/controls/container3D.js +1 -1
- package/3D/controls/container3D.js.map +1 -1
- package/3D/controls/control3D.d.ts +3 -3
- package/3D/controls/control3D.js.map +1 -1
- package/3D/controls/slider3D.d.ts +2 -0
- package/3D/controls/slider3D.js +17 -0
- package/3D/controls/slider3D.js.map +1 -1
- package/package.json +2 -2
|
@@ -27,7 +27,7 @@ export declare class AdvancedDynamicTexture extends DynamicTexture {
|
|
|
27
27
|
private _renderObserver;
|
|
28
28
|
private _resizeObserver;
|
|
29
29
|
private _preKeyboardObserver;
|
|
30
|
-
private
|
|
30
|
+
private _prePointerObserver;
|
|
31
31
|
private _sceneRenderObserver;
|
|
32
32
|
private _pointerObserver;
|
|
33
33
|
private _canvasPointerOutObserver;
|
|
@@ -375,21 +375,45 @@ export declare class AdvancedDynamicTexture extends DynamicTexture {
|
|
|
375
375
|
* @param serializedObject define the JSON serialized object to restore from
|
|
376
376
|
* @param scaleToSize defines whether to scale to texture to the saved size
|
|
377
377
|
*/
|
|
378
|
-
|
|
378
|
+
parseSerializedObject(serializedObject: any, scaleToSize?: boolean): void;
|
|
379
|
+
/**
|
|
380
|
+
* Recreate the content of the ADT from a JSON object
|
|
381
|
+
* @param serializedObject define the JSON serialized object to restore from
|
|
382
|
+
* @param scaleToSize defines whether to scale to texture to the saved size
|
|
383
|
+
* @deprecated Please use parseSerializedObject instead
|
|
384
|
+
*/
|
|
385
|
+
parseContent: (serializedObject: any, scaleToSize?: boolean | undefined) => void;
|
|
379
386
|
/**
|
|
380
387
|
* Recreate the content of the ADT from a snippet saved by the GUI editor
|
|
381
388
|
* @param snippetId defines the snippet to load
|
|
382
389
|
* @param scaleToSize defines whether to scale to texture to the saved size
|
|
390
|
+
* @param appendToAdt if provided the snippet will be appended to the adt. Otherwise a fullscreen ADT will be created.
|
|
391
|
+
* @returns a promise that will resolve on success
|
|
392
|
+
*/
|
|
393
|
+
static ParseFromSnippetAsync(snippetId: string, scaleToSize?: boolean, appendToAdt?: AdvancedDynamicTexture): Promise<AdvancedDynamicTexture>;
|
|
394
|
+
/**
|
|
395
|
+
* Recreate the content of the ADT from a snippet saved by the GUI editor
|
|
396
|
+
* @param snippetId defines the snippet to load
|
|
397
|
+
* @param scaleToSize defines whether to scale to texture to the saved size
|
|
398
|
+
* @returns a promise that will resolve on success
|
|
399
|
+
*/
|
|
400
|
+
parseFromSnippetAsync(snippetId: string, scaleToSize?: boolean): Promise<AdvancedDynamicTexture>;
|
|
401
|
+
/**
|
|
402
|
+
* Recreate the content of the ADT from a url json
|
|
403
|
+
* @param url defines the url to load
|
|
404
|
+
* @param scaleToSize defines whether to scale to texture to the saved size
|
|
405
|
+
* @param appendToAdt if provided the snippet will be appended to the adt. Otherwise a fullscreen ADT will be created.
|
|
383
406
|
* @returns a promise that will resolve on success
|
|
384
407
|
*/
|
|
385
|
-
|
|
408
|
+
static ParseFromFileAsync(url: string, scaleToSize?: boolean, appendToAdt?: AdvancedDynamicTexture): Promise<AdvancedDynamicTexture>;
|
|
386
409
|
/**
|
|
387
410
|
* Recreate the content of the ADT from a url json
|
|
388
411
|
* @param url defines the url to load
|
|
389
412
|
* @param scaleToSize defines whether to scale to texture to the saved size
|
|
390
413
|
* @returns a promise that will resolve on success
|
|
391
414
|
*/
|
|
392
|
-
parseFromURLAsync(url: string, scaleToSize?: boolean): Promise<
|
|
415
|
+
parseFromURLAsync(url: string, scaleToSize?: boolean): Promise<AdvancedDynamicTexture>;
|
|
416
|
+
private static _LoadURLContentAsync;
|
|
393
417
|
/**
|
|
394
418
|
* Compares two rectangle based controls for pixel overlap
|
|
395
419
|
* @param control1 The first control to compare
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __extends } from "tslib";
|
|
1
|
+
import { __awaiter, __extends, __generator } from "tslib";
|
|
2
2
|
import { Observable } from "@babylonjs/core/Misc/observable.js";
|
|
3
3
|
import { Vector2, Vector3 } from "@babylonjs/core/Maths/math.vector.js";
|
|
4
4
|
import { Tools } from "@babylonjs/core/Misc/tools.js";
|
|
@@ -144,6 +144,13 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
|
|
|
144
144
|
_this.onClipboardObservable.notifyObservers(ev);
|
|
145
145
|
evt.preventDefault();
|
|
146
146
|
};
|
|
147
|
+
/**
|
|
148
|
+
* Recreate the content of the ADT from a JSON object
|
|
149
|
+
* @param serializedObject define the JSON serialized object to restore from
|
|
150
|
+
* @param scaleToSize defines whether to scale to texture to the saved size
|
|
151
|
+
* @deprecated Please use parseSerializedObject instead
|
|
152
|
+
*/
|
|
153
|
+
_this.parseContent = _this.parseSerializedObject;
|
|
147
154
|
scene = _this.getScene();
|
|
148
155
|
if (!scene || !_this._texture) {
|
|
149
156
|
return _this;
|
|
@@ -589,8 +596,8 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
|
|
|
589
596
|
if (this._resizeObserver) {
|
|
590
597
|
scene.getEngine().onResizeObservable.remove(this._resizeObserver);
|
|
591
598
|
}
|
|
592
|
-
if (this.
|
|
593
|
-
scene.onPrePointerObservable.remove(this.
|
|
599
|
+
if (this._prePointerObserver) {
|
|
600
|
+
scene.onPrePointerObservable.remove(this._prePointerObserver);
|
|
594
601
|
}
|
|
595
602
|
if (this._sceneRenderObserver) {
|
|
596
603
|
scene.onBeforeRenderObservable.remove(this._sceneRenderObserver);
|
|
@@ -802,6 +809,9 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
|
|
|
802
809
|
y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
|
|
803
810
|
}
|
|
804
811
|
if (this._capturingControl[pointerId]) {
|
|
812
|
+
if (this._capturingControl[pointerId].isPointerBlocker) {
|
|
813
|
+
this._shouldBlockPointer = true;
|
|
814
|
+
}
|
|
805
815
|
this._capturingControl[pointerId]._processObservables(type, x, y, pi, pointerId, buttonIndex);
|
|
806
816
|
return;
|
|
807
817
|
}
|
|
@@ -909,18 +919,21 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
|
|
|
909
919
|
return;
|
|
910
920
|
}
|
|
911
921
|
var tempViewport = new Viewport(0, 0, 0, 0);
|
|
912
|
-
this.
|
|
913
|
-
if (scene.isPointerCaptured(pi.event.pointerId)) {
|
|
914
|
-
return;
|
|
915
|
-
}
|
|
922
|
+
this._prePointerObserver = scene.onPrePointerObservable.add(function (pi) {
|
|
916
923
|
if (pi.type !== PointerEventTypes.POINTERMOVE &&
|
|
917
924
|
pi.type !== PointerEventTypes.POINTERUP &&
|
|
918
925
|
pi.type !== PointerEventTypes.POINTERDOWN &&
|
|
919
926
|
pi.type !== PointerEventTypes.POINTERWHEEL) {
|
|
920
927
|
return;
|
|
921
928
|
}
|
|
922
|
-
if (pi.type === PointerEventTypes.POINTERMOVE
|
|
923
|
-
|
|
929
|
+
if (pi.type === PointerEventTypes.POINTERMOVE) {
|
|
930
|
+
// Avoid pointerMove events firing while the pointer is captured by the scene
|
|
931
|
+
if (scene.isPointerCaptured(pi.event.pointerId)) {
|
|
932
|
+
return;
|
|
933
|
+
}
|
|
934
|
+
if (pi.event.pointerId) {
|
|
935
|
+
_this._defaultMousePointerId = pi.event.pointerId; // This is required to make sure we have the correct pointer ID for wheel
|
|
936
|
+
}
|
|
924
937
|
}
|
|
925
938
|
_this._translateToPicking(scene, tempViewport, pi);
|
|
926
939
|
});
|
|
@@ -1109,7 +1122,7 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
|
|
|
1109
1122
|
* @param serializedObject define the JSON serialized object to restore from
|
|
1110
1123
|
* @param scaleToSize defines whether to scale to texture to the saved size
|
|
1111
1124
|
*/
|
|
1112
|
-
AdvancedDynamicTexture.prototype.
|
|
1125
|
+
AdvancedDynamicTexture.prototype.parseSerializedObject = function (serializedObject, scaleToSize) {
|
|
1113
1126
|
this._rootContainer = Control.Parse(serializedObject.root, this);
|
|
1114
1127
|
if (scaleToSize) {
|
|
1115
1128
|
var width = serializedObject.width;
|
|
@@ -1123,6 +1136,32 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
|
|
|
1123
1136
|
}
|
|
1124
1137
|
}
|
|
1125
1138
|
};
|
|
1139
|
+
/**
|
|
1140
|
+
* Recreate the content of the ADT from a snippet saved by the GUI editor
|
|
1141
|
+
* @param snippetId defines the snippet to load
|
|
1142
|
+
* @param scaleToSize defines whether to scale to texture to the saved size
|
|
1143
|
+
* @param appendToAdt if provided the snippet will be appended to the adt. Otherwise a fullscreen ADT will be created.
|
|
1144
|
+
* @returns a promise that will resolve on success
|
|
1145
|
+
*/
|
|
1146
|
+
AdvancedDynamicTexture.ParseFromSnippetAsync = function (snippetId, scaleToSize, appendToAdt) {
|
|
1147
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1148
|
+
var adt, serialized;
|
|
1149
|
+
return __generator(this, function (_a) {
|
|
1150
|
+
switch (_a.label) {
|
|
1151
|
+
case 0:
|
|
1152
|
+
adt = appendToAdt !== null && appendToAdt !== void 0 ? appendToAdt : AdvancedDynamicTexture.CreateFullscreenUI("ADT from snippet");
|
|
1153
|
+
if (snippetId === "_BLANK") {
|
|
1154
|
+
return [2 /*return*/, adt];
|
|
1155
|
+
}
|
|
1156
|
+
return [4 /*yield*/, AdvancedDynamicTexture._LoadURLContentAsync(AdvancedDynamicTexture.SnippetUrl + "/" + snippetId.replace(/#/g, "/"), true)];
|
|
1157
|
+
case 1:
|
|
1158
|
+
serialized = _a.sent();
|
|
1159
|
+
adt.parseSerializedObject(serialized, scaleToSize);
|
|
1160
|
+
return [2 /*return*/, adt];
|
|
1161
|
+
}
|
|
1162
|
+
});
|
|
1163
|
+
});
|
|
1164
|
+
};
|
|
1126
1165
|
/**
|
|
1127
1166
|
* Recreate the content of the ADT from a snippet saved by the GUI editor
|
|
1128
1167
|
* @param snippetId defines the snippet to load
|
|
@@ -1130,28 +1169,29 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
|
|
|
1130
1169
|
* @returns a promise that will resolve on success
|
|
1131
1170
|
*/
|
|
1132
1171
|
AdvancedDynamicTexture.prototype.parseFromSnippetAsync = function (snippetId, scaleToSize) {
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1172
|
+
return AdvancedDynamicTexture.ParseFromSnippetAsync(snippetId, scaleToSize, this);
|
|
1173
|
+
};
|
|
1174
|
+
/**
|
|
1175
|
+
* Recreate the content of the ADT from a url json
|
|
1176
|
+
* @param url defines the url to load
|
|
1177
|
+
* @param scaleToSize defines whether to scale to texture to the saved size
|
|
1178
|
+
* @param appendToAdt if provided the snippet will be appended to the adt. Otherwise a fullscreen ADT will be created.
|
|
1179
|
+
* @returns a promise that will resolve on success
|
|
1180
|
+
*/
|
|
1181
|
+
AdvancedDynamicTexture.ParseFromFileAsync = function (url, scaleToSize, appendToAdt) {
|
|
1182
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1183
|
+
var adt, serialized;
|
|
1184
|
+
return __generator(this, function (_a) {
|
|
1185
|
+
switch (_a.label) {
|
|
1186
|
+
case 0:
|
|
1187
|
+
adt = appendToAdt !== null && appendToAdt !== void 0 ? appendToAdt : AdvancedDynamicTexture.CreateFullscreenUI("ADT from URL");
|
|
1188
|
+
return [4 /*yield*/, AdvancedDynamicTexture._LoadURLContentAsync(url)];
|
|
1189
|
+
case 1:
|
|
1190
|
+
serialized = _a.sent();
|
|
1191
|
+
adt.parseSerializedObject(serialized, scaleToSize);
|
|
1192
|
+
return [2 /*return*/, adt];
|
|
1151
1193
|
}
|
|
1152
1194
|
});
|
|
1153
|
-
request.open("GET", AdvancedDynamicTexture.SnippetUrl + "/" + snippetId.replace(/#/g, "/"));
|
|
1154
|
-
request.send();
|
|
1155
1195
|
});
|
|
1156
1196
|
};
|
|
1157
1197
|
/**
|
|
@@ -1161,19 +1201,21 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
|
|
|
1161
1201
|
* @returns a promise that will resolve on success
|
|
1162
1202
|
*/
|
|
1163
1203
|
AdvancedDynamicTexture.prototype.parseFromURLAsync = function (url, scaleToSize) {
|
|
1164
|
-
|
|
1204
|
+
return AdvancedDynamicTexture.ParseFromFileAsync(url, scaleToSize, this);
|
|
1205
|
+
};
|
|
1206
|
+
AdvancedDynamicTexture._LoadURLContentAsync = function (url, snippet) {
|
|
1207
|
+
if (snippet === void 0) { snippet = false; }
|
|
1165
1208
|
if (url === "") {
|
|
1166
|
-
return Promise.
|
|
1209
|
+
return Promise.reject("No URL provided");
|
|
1167
1210
|
}
|
|
1168
1211
|
return new Promise(function (resolve, reject) {
|
|
1169
1212
|
var request = new WebRequest();
|
|
1170
1213
|
request.addEventListener("readystatechange", function () {
|
|
1171
1214
|
if (request.readyState == 4) {
|
|
1172
1215
|
if (request.status == 200) {
|
|
1173
|
-
var gui = request.responseText;
|
|
1216
|
+
var gui = snippet ? JSON.parse(JSON.parse(request.responseText).jsonPayload).gui : request.responseText;
|
|
1174
1217
|
var serializationObject = JSON.parse(gui);
|
|
1175
|
-
|
|
1176
|
-
resolve();
|
|
1218
|
+
resolve(serializationObject);
|
|
1177
1219
|
}
|
|
1178
1220
|
else {
|
|
1179
1221
|
reject("Unable to load");
|