@babylonjs/gui-editor 5.39.0 → 5.40.0

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.
@@ -41118,7 +41118,7 @@ __webpack_require__.r(__webpack_exports__);
41118
41118
  /* harmony export */ "GizmoGeneric": () => (/* binding */ GizmoGeneric)
41119
41119
  /* harmony export */ });
41120
41120
  /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-runtime */ "../../../../node_modules/react/jsx-runtime.js");
41121
- /* harmony import */ var gui_2D_controls_control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! gui/2D/valueAndUnit */ "gui/2D/controls/container");
41121
+ /* harmony import */ var gui_2D_controls_control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! gui/2D/math2D */ "gui/2D/controls/container");
41122
41122
  /* harmony import */ var gui_2D_controls_control__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(gui_2D_controls_control__WEBPACK_IMPORTED_MODULE_1__);
41123
41123
  /* harmony import */ var core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! core/Maths/math.vector */ "core/Misc/observable");
41124
41124
  /* harmony import */ var core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__);
@@ -41132,6 +41132,7 @@ __webpack_require__.r(__webpack_exports__);
41132
41132
 
41133
41133
 
41134
41134
 
41135
+
41135
41136
  const roundFactor = 100;
41136
41137
  const round = (value) => Math.round(value * roundFactor) / roundFactor;
41137
41138
  const modulo = (dividend, divisor) => ((dividend % divisor) + divisor) % divisor;
@@ -41161,7 +41162,7 @@ class GizmoGeneric extends react__WEBPACK_IMPORTED_MODULE_3__.Component {
41161
41162
  const node = this.props.control;
41162
41163
  const inRTT = _coordinateHelper__WEBPACK_IMPORTED_MODULE_4__.CoordinateHelper.MousePointerToRTTSpace(node, scene.pointerX, scene.pointerY);
41163
41164
  const inNodeSpace = _coordinateHelper__WEBPACK_IMPORTED_MODULE_4__.CoordinateHelper.RttToLocalNodeSpace(node, inRTT.x, inRTT.y, undefined, this._storedValues);
41164
- this._dragLocalBounds(inNodeSpace);
41165
+ this._dragLocalBounds(inNodeSpace, this.props.globalState.shiftKeyPressed);
41165
41166
  this._updateNodeFromLocalBounds();
41166
41167
  this.props.globalState.onPropertyGridUpdateRequiredObservable.notifyObservers();
41167
41168
  }
@@ -41323,13 +41324,14 @@ class GizmoGeneric extends react__WEBPACK_IMPORTED_MODULE_3__.Component {
41323
41324
  y: (x - centerX) * Math.sin(angle) + (y - centerY) * Math.cos(angle) + centerY,
41324
41325
  };
41325
41326
  }
41326
- _dragLocalBounds(toPosition) {
41327
+ _dragLocalBounds(toPosition, preserveAspectRatio = false) {
41327
41328
  const scalePoint = this.state.scalePoints[this.state.scalePointDragging];
41328
41329
  const newBounds = this._localBounds.clone();
41330
+ const currentAspectRatio = gui_2D_controls_control__WEBPACK_IMPORTED_MODULE_1__.MathTools.Round(this._localBounds.width / this._localBounds.height);
41329
41331
  if (scalePoint.horizontalPosition === _gizmoScalePoint__WEBPACK_IMPORTED_MODULE_5__.ScalePointPosition.Left) {
41330
41332
  newBounds.left = Math.min(this._localBounds.right - 1, toPosition.x);
41331
41333
  }
41332
- if (scalePoint.verticalPosition === _gizmoScalePoint__WEBPACK_IMPORTED_MODULE_5__.ScalePointPosition.Left) {
41334
+ if (scalePoint.verticalPosition === _gizmoScalePoint__WEBPACK_IMPORTED_MODULE_5__.ScalePointPosition.Top) {
41333
41335
  newBounds.top = Math.min(this._localBounds.bottom - 1, toPosition.y);
41334
41336
  }
41335
41337
  if (scalePoint.horizontalPosition === _gizmoScalePoint__WEBPACK_IMPORTED_MODULE_5__.ScalePointPosition.Right) {
@@ -41338,6 +41340,38 @@ class GizmoGeneric extends react__WEBPACK_IMPORTED_MODULE_3__.Component {
41338
41340
  if (scalePoint.verticalPosition === _gizmoScalePoint__WEBPACK_IMPORTED_MODULE_5__.ScalePointPosition.Bottom) {
41339
41341
  newBounds.bottom = Math.max(this._localBounds.top + 1, toPosition.y);
41340
41342
  }
41343
+ if (preserveAspectRatio) {
41344
+ const deltaWidth = newBounds.width - this._localBounds.width;
41345
+ const deltaHeight = newBounds.height - this._localBounds.height;
41346
+ const signInverted = scalePoint.horizontalPosition === _gizmoScalePoint__WEBPACK_IMPORTED_MODULE_5__.ScalePointPosition.Center || scalePoint.verticalPosition === _gizmoScalePoint__WEBPACK_IMPORTED_MODULE_5__.ScalePointPosition.Center;
41347
+ const comparison = Math.abs(deltaWidth) > Math.abs(deltaHeight);
41348
+ if (signInverted ? comparison : !comparison) {
41349
+ const aspectRatioDeltaHeight = deltaWidth / currentAspectRatio;
41350
+ if (scalePoint.verticalPosition === _gizmoScalePoint__WEBPACK_IMPORTED_MODULE_5__.ScalePointPosition.Top) {
41351
+ newBounds.top = this._localBounds.top - aspectRatioDeltaHeight;
41352
+ }
41353
+ else if (scalePoint.verticalPosition === _gizmoScalePoint__WEBPACK_IMPORTED_MODULE_5__.ScalePointPosition.Bottom) {
41354
+ newBounds.bottom = this._localBounds.bottom + aspectRatioDeltaHeight;
41355
+ }
41356
+ else {
41357
+ newBounds.top = this._localBounds.top - aspectRatioDeltaHeight / 2;
41358
+ newBounds.bottom = this._localBounds.bottom + aspectRatioDeltaHeight / 2;
41359
+ }
41360
+ }
41361
+ else {
41362
+ const aspectRatioDeltaWidth = deltaHeight * currentAspectRatio;
41363
+ if (scalePoint.horizontalPosition === _gizmoScalePoint__WEBPACK_IMPORTED_MODULE_5__.ScalePointPosition.Left) {
41364
+ newBounds.left = this._localBounds.left - aspectRatioDeltaWidth;
41365
+ }
41366
+ else if (scalePoint.horizontalPosition === _gizmoScalePoint__WEBPACK_IMPORTED_MODULE_5__.ScalePointPosition.Right) {
41367
+ newBounds.right = this._localBounds.right + aspectRatioDeltaWidth;
41368
+ }
41369
+ else {
41370
+ newBounds.left = this._localBounds.left - aspectRatioDeltaWidth / 2;
41371
+ newBounds.right = this._localBounds.right + aspectRatioDeltaWidth / 2;
41372
+ }
41373
+ }
41374
+ }
41341
41375
  // apply bounds changes to all controls
41342
41376
  const edges = ["left", "top", "right", "bottom"];
41343
41377
  for (const node of this.props.globalState.selectedControls) {
@@ -41776,6 +41810,7 @@ class WorkbenchComponent extends react__WEBPACK_IMPORTED_MODULE_1__.Component {
41776
41810
  this._setConstraintDirection = false;
41777
41811
  this._constraintDirection = ConstraintDirection.NONE;
41778
41812
  }
41813
+ this.props.globalState.shiftKeyPressed = evt.shiftKey && evt.type === "keydown";
41779
41814
  if (evt.key === "Delete" || evt.key === "Backspace") {
41780
41815
  if (!this.props.globalState.lockObject.lock) {
41781
41816
  this.props.globalState.deleteSelectedNodes();
@@ -42750,6 +42785,7 @@ class GlobalState {
42750
42785
  this.onPasteObservable = new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable();
42751
42786
  this.isSaving = false;
42752
42787
  this.lockObject = new shared_ui_components_tabs_propertyGrids_lockObject__WEBPACK_IMPORTED_MODULE_1__.LockObject();
42788
+ this.shiftKeyPressed = false;
42753
42789
  this.controlCamera = core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.DataStorage.ReadBoolean("ControlCamera", true);
42754
42790
  const defaultBrightness = 204 / 255.0;
42755
42791
  const r = core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.DataStorage.ReadNumber("BackgroundColorR", defaultBrightness);
@@ -43198,7 +43234,7 @@ class GUINodeTools {
43198
43234
  }
43199
43235
  }
43200
43236
  }
43201
- GUINodeTools.ImageControlDefaultUrl = "./imageControlDefault.jpg";
43237
+ GUINodeTools.ImageControlDefaultUrl = "https://assets.babylonjs.com/textures/Checker_albedo.png";
43202
43238
 
43203
43239
 
43204
43240
  /***/ }),