@babylonjs/gui 6.34.0 → 6.34.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -3,6 +3,7 @@ import { Observable } from "@babylonjs/core/Misc/observable.js";
|
|
3
3
|
import { Control } from "../control.js";
|
4
4
|
import { ValueAndUnit } from "../../valueAndUnit.js";
|
5
5
|
import { serialize } from "@babylonjs/core/Misc/decorators.js";
|
6
|
+
import { Logger } from "@babylonjs/core/Misc/logger.js";
|
6
7
|
/**
|
7
8
|
* Class used to create slider controls
|
8
9
|
*/
|
@@ -190,7 +191,7 @@ export class BaseSlider extends Control {
|
|
190
191
|
}
|
191
192
|
//throw error when height is less than width for vertical slider
|
192
193
|
if (this.isVertical && this._currentMeasure.height < this._currentMeasure.width) {
|
193
|
-
|
194
|
+
Logger.Error("Height should be greater than width");
|
194
195
|
return;
|
195
196
|
}
|
196
197
|
if (this._barOffset.isPixel) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"baseSlider.js","sourceRoot":"","sources":["../../../../../../dev/gui/src/2D/controls/sliders/baseSlider.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAGlD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,SAAS,EAAE,2CAA6B;AAEjD;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,OAAO;IA0BnC,sEAAsE;IAEtE,IAAW,YAAY;QACnB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED,IAAW,YAAY,CAAC,KAAc;QAClC,IAAI,IAAI,CAAC,aAAa,KAAK,KAAK,EAAE;YAC9B,OAAO;SACV;QAED,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;QAC3B,IAAI,CAAC,YAAY,EAAE,CAAC;IACxB,CAAC;IAED,4DAA4D;IAE5D,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CA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AAE;yCAGX;AAeD;IADC,SAAS,EAAE;uCAGX;AAgBD;IADC,SAAS,EAAE;4CAGX;AAaD;IADC,SAAS,EAAE;gDAGX","sourcesContent":["import { Observable } from \"core/Misc/observable\";\r\nimport type { Vector2 } from \"core/Maths/math.vector\";\r\n\r\nimport { Control } from \"../control\";\r\nimport { ValueAndUnit } from \"../../valueAndUnit\";\r\nimport type { PointerInfoBase } from \"core/Events/pointerEvents\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\n\r\n/**\r\n * Class used to create slider controls\r\n */\r\nexport class BaseSlider extends Control {\r\n protected _thumbWidth = new ValueAndUnit(20, ValueAndUnit.UNITMODE_PIXEL, false);\r\n private _minimum = 0;\r\n private _maximum = 100;\r\n private _value = 50;\r\n private _isVertical = false;\r\n protected _barOffset = new ValueAndUnit(5, ValueAndUnit.UNITMODE_PIXEL, false);\r\n private _isThumbClamped = false;\r\n protected _displayThumb = true;\r\n private _step = 0;\r\n\r\n private _lastPointerDownId = -1;\r\n\r\n // Shared rendering info\r\n protected _effectiveBarOffset = 0;\r\n protected _renderLeft: number;\r\n protected _renderTop: number;\r\n protected _renderWidth: number;\r\n protected _renderHeight: number;\r\n protected _backgroundBoxLength: number;\r\n protected _backgroundBoxThickness: number;\r\n protected _effectiveThumbThickness: number;\r\n\r\n /** Observable raised when the slider value changes */\r\n public onValueChangedObservable = new Observable<number>();\r\n\r\n /** Gets or sets a boolean indicating if the thumb must be rendered */\r\n @serialize()\r\n public get displayThumb(): boolean {\r\n return this._displayThumb;\r\n }\r\n\r\n public set displayThumb(value: boolean) {\r\n if (this._displayThumb === value) {\r\n return;\r\n }\r\n\r\n this._displayThumb = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /** Gets or sets a step to apply to values (0 by default) */\r\n @serialize()\r\n public get step(): number {\r\n return this._step;\r\n }\r\n\r\n public set step(value: number) {\r\n if (this._step === value) {\r\n return;\r\n }\r\n\r\n this._step = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /** Gets or sets main bar offset (ie. the margin applied to the value bar) */\r\n @serialize()\r\n public get barOffset(): string | number {\r\n return this._barOffset.toString(this._host);\r\n }\r\n\r\n /** Gets main bar offset in pixels*/\r\n public get barOffsetInPixels(): number {\r\n return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);\r\n }\r\n\r\n public set barOffset(value: string | number) {\r\n if (this._barOffset.toString(this._host) === value) {\r\n return;\r\n }\r\n\r\n if (this._barOffset.fromString(value)) {\r\n this._markAsDirty();\r\n }\r\n }\r\n\r\n /** Gets or sets thumb width */\r\n @serialize()\r\n public get thumbWidth(): string | number {\r\n return this._thumbWidth.toString(this._host);\r\n }\r\n\r\n /** Gets thumb width in pixels */\r\n public get thumbWidthInPixels(): number {\r\n return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);\r\n }\r\n\r\n public set thumbWidth(value: string | number) {\r\n if (this._thumbWidth.toString(this._host) === value) {\r\n return;\r\n }\r\n\r\n if (this._thumbWidth.fromString(value)) {\r\n this._markAsDirty();\r\n }\r\n }\r\n\r\n /** Gets or sets minimum value */\r\n @serialize()\r\n public get minimum(): number {\r\n return this._minimum;\r\n }\r\n\r\n public set minimum(value: number) {\r\n if (this._minimum === value) {\r\n return;\r\n }\r\n\r\n this._minimum = value;\r\n this._markAsDirty();\r\n\r\n this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);\r\n }\r\n\r\n /** Gets or sets maximum value */\r\n @serialize()\r\n public get maximum(): number {\r\n return this._maximum;\r\n }\r\n\r\n public set maximum(value: number) {\r\n if (this._maximum === value) {\r\n return;\r\n }\r\n\r\n this._maximum = value;\r\n this._markAsDirty();\r\n\r\n this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);\r\n }\r\n\r\n /** Gets or sets current value */\r\n @serialize()\r\n public get value(): number {\r\n return this._value;\r\n }\r\n\r\n public set value(value: number) {\r\n value = Math.max(Math.min(value, this._maximum), this._minimum);\r\n\r\n if (this._value === value) {\r\n return;\r\n }\r\n\r\n this._value = value;\r\n this._markAsDirty();\r\n this.onValueChangedObservable.notifyObservers(this._value);\r\n }\r\n\r\n /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */\r\n @serialize()\r\n public get isVertical(): boolean {\r\n return this._isVertical;\r\n }\r\n\r\n public set isVertical(value: boolean) {\r\n if (this._isVertical === value) {\r\n return;\r\n }\r\n\r\n this._isVertical = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /** Gets or sets a value indicating if the thumb can go over main bar extends */\r\n @serialize()\r\n public get isThumbClamped(): boolean {\r\n return this._isThumbClamped;\r\n }\r\n\r\n public set isThumbClamped(value: boolean) {\r\n if (this._isThumbClamped === value) {\r\n return;\r\n }\r\n\r\n this._isThumbClamped = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Creates a new BaseSlider\r\n * @param name defines the control name\r\n */\r\n constructor(public name?: string) {\r\n super(name);\r\n\r\n this.isPointerBlocker = true;\r\n }\r\n\r\n protected _getTypeName(): string {\r\n return \"BaseSlider\";\r\n }\r\n\r\n protected _getThumbPosition() {\r\n if (this.isVertical) {\r\n return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;\r\n }\r\n\r\n return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;\r\n }\r\n\r\n protected _getThumbThickness(type: string): number {\r\n let thumbThickness = 0;\r\n switch (type) {\r\n case \"circle\":\r\n if (this._thumbWidth.isPixel) {\r\n thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);\r\n } else {\r\n thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);\r\n }\r\n break;\r\n case \"rectangle\":\r\n if (this._thumbWidth.isPixel) {\r\n thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);\r\n } else {\r\n thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);\r\n }\r\n }\r\n return thumbThickness;\r\n }\r\n\r\n protected _prepareRenderingData(type: string) {\r\n // Main bar\r\n this._effectiveBarOffset = 0;\r\n this._renderLeft = this._currentMeasure.left;\r\n this._renderTop = this._currentMeasure.top;\r\n this._renderWidth = this._currentMeasure.width;\r\n this._renderHeight = this._currentMeasure.height;\r\n\r\n this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);\r\n this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);\r\n this._effectiveThumbThickness = this._getThumbThickness(type);\r\n\r\n if (this.displayThumb) {\r\n this._backgroundBoxLength -= this._effectiveThumbThickness;\r\n }\r\n //throw error when height is less than width for vertical slider\r\n if (this.isVertical && this._currentMeasure.height < this._currentMeasure.width) {\r\n console.error(\"Height should be greater than width\");\r\n return;\r\n }\r\n if (this._barOffset.isPixel) {\r\n this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);\r\n } else {\r\n this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);\r\n }\r\n\r\n this._backgroundBoxThickness -= this._effectiveBarOffset * 2;\r\n\r\n if (this.isVertical) {\r\n this._renderLeft += this._effectiveBarOffset;\r\n if (!this.isThumbClamped && this.displayThumb) {\r\n this._renderTop += this._effectiveThumbThickness / 2;\r\n }\r\n\r\n this._renderHeight = this._backgroundBoxLength;\r\n this._renderWidth = this._backgroundBoxThickness;\r\n } else {\r\n this._renderTop += this._effectiveBarOffset;\r\n if (!this.isThumbClamped && this.displayThumb) {\r\n this._renderLeft += this._effectiveThumbThickness / 2;\r\n }\r\n this._renderHeight = this._backgroundBoxThickness;\r\n this._renderWidth = this._backgroundBoxLength;\r\n }\r\n }\r\n\r\n // Events\r\n private _pointerIsDown = false;\r\n\r\n /**\r\n * @internal\r\n */\r\n protected _updateValueFromPointer(x: number, y: number): void {\r\n if (this.rotation != 0) {\r\n this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);\r\n x = this._transformedPosition.x;\r\n y = this._transformedPosition.y;\r\n }\r\n\r\n let value: number;\r\n if (this._isVertical) {\r\n value = this._minimum + (1 - (y - this._currentMeasure.top) / this._currentMeasure.height) * (this._maximum - this._minimum);\r\n } else {\r\n value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);\r\n }\r\n this.value = this._step ? Math.round(value / this._step) * this._step : value;\r\n }\r\n\r\n public _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, pi: PointerInfoBase): boolean {\r\n if (!super._onPointerDown(target, coordinates, pointerId, buttonIndex, pi)) {\r\n return false;\r\n }\r\n\r\n if (this.isReadOnly) {\r\n return true;\r\n }\r\n\r\n this._pointerIsDown = true;\r\n\r\n this._updateValueFromPointer(coordinates.x, coordinates.y);\r\n this._host._capturingControl[pointerId] = this;\r\n this._lastPointerDownId = pointerId;\r\n return true;\r\n }\r\n\r\n public _onPointerMove(target: Control, coordinates: Vector2, pointerId: number, pi: PointerInfoBase): void {\r\n // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)\r\n if (pointerId != this._lastPointerDownId) {\r\n return;\r\n }\r\n\r\n if (this._pointerIsDown && !this.isReadOnly) {\r\n this._updateValueFromPointer(coordinates.x, coordinates.y);\r\n }\r\n\r\n super._onPointerMove(target, coordinates, pointerId, pi);\r\n }\r\n\r\n public _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void {\r\n this._pointerIsDown = false;\r\n\r\n delete this._host._capturingControl[pointerId];\r\n super._onPointerUp(target, coordinates, pointerId, buttonIndex, notifyClick);\r\n }\r\n\r\n public _onCanvasBlur(): void {\r\n this._forcePointerUp();\r\n super._onCanvasBlur();\r\n }\r\n}\r\n"]}
|
1
|
+
{"version":3,"file":"baseSlider.js","sourceRoot":"","sources":["../../../../../../dev/gui/src/2D/controls/sliders/baseSlider.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAGlD,OAAO,EAAE,OAAO,EAAE,MAAM,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EAAE,SAAiB,EAAE,WAAmB,EAAE,WAAoB;QACnH,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;QAE5B,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;QAC/C,KAAK,CAAC,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;IACjF,CAAC;IAEM,aAAa;QAChB,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,KAAK,CAAC,aAAa,EAAE,CAAC;IAC1B,CAAC;CACJ;AA/SG;IADC,SAAS,EAAE;8CAGX;AAaD;IADC,SAAS,EAAE;sCAGX;AAaD;IADC,SAAS,EAAE;2CAGX;AAmBD;IADC,SAAS,EAAE;4CAGX;AAmBD;IADC,SAAS,EAAE;yCAGX;AAeD;IADC,SAAS,EAAE;yCAGX;AAeD;IADC,SAAS,EAAE;uCAGX;AAgBD;IADC,SAAS,EAAE;4CAGX;AAaD;IADC,SAAS,EAAE;gDAGX","sourcesContent":["import { Observable } from \"core/Misc/observable\";\r\nimport type { Vector2 } from \"core/Maths/math.vector\";\r\n\r\nimport { Control } from \"../control\";\r\nimport { ValueAndUnit } from \"../../valueAndUnit\";\r\nimport type { PointerInfoBase } from \"core/Events/pointerEvents\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\nimport { Logger } from \"core/Misc/logger\";\r\n\r\n/**\r\n * Class used to create slider controls\r\n */\r\nexport class BaseSlider extends Control {\r\n protected _thumbWidth = new ValueAndUnit(20, ValueAndUnit.UNITMODE_PIXEL, false);\r\n private _minimum = 0;\r\n private _maximum = 100;\r\n private _value = 50;\r\n private _isVertical = false;\r\n protected _barOffset = new ValueAndUnit(5, ValueAndUnit.UNITMODE_PIXEL, false);\r\n private _isThumbClamped = false;\r\n protected _displayThumb = true;\r\n private _step = 0;\r\n\r\n private _lastPointerDownId = -1;\r\n\r\n // Shared rendering info\r\n protected _effectiveBarOffset = 0;\r\n protected _renderLeft: number;\r\n protected _renderTop: number;\r\n protected _renderWidth: number;\r\n protected _renderHeight: number;\r\n protected _backgroundBoxLength: number;\r\n protected _backgroundBoxThickness: number;\r\n protected _effectiveThumbThickness: number;\r\n\r\n /** Observable raised when the slider value changes */\r\n public onValueChangedObservable = new Observable<number>();\r\n\r\n /** Gets or sets a boolean indicating if the thumb must be rendered */\r\n @serialize()\r\n public get displayThumb(): boolean {\r\n return this._displayThumb;\r\n }\r\n\r\n public set displayThumb(value: boolean) {\r\n if (this._displayThumb === value) {\r\n return;\r\n }\r\n\r\n this._displayThumb = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /** Gets or sets a step to apply to values (0 by default) */\r\n @serialize()\r\n public get step(): number {\r\n return this._step;\r\n }\r\n\r\n public set step(value: number) {\r\n if (this._step === value) {\r\n return;\r\n }\r\n\r\n this._step = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /** Gets or sets main bar offset (ie. the margin applied to the value bar) */\r\n @serialize()\r\n public get barOffset(): string | number {\r\n return this._barOffset.toString(this._host);\r\n }\r\n\r\n /** Gets main bar offset in pixels*/\r\n public get barOffsetInPixels(): number {\r\n return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);\r\n }\r\n\r\n public set barOffset(value: string | number) {\r\n if (this._barOffset.toString(this._host) === value) {\r\n return;\r\n }\r\n\r\n if (this._barOffset.fromString(value)) {\r\n this._markAsDirty();\r\n }\r\n }\r\n\r\n /** Gets or sets thumb width */\r\n @serialize()\r\n public get thumbWidth(): string | number {\r\n return this._thumbWidth.toString(this._host);\r\n }\r\n\r\n /** Gets thumb width in pixels */\r\n public get thumbWidthInPixels(): number {\r\n return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);\r\n }\r\n\r\n public set thumbWidth(value: string | number) {\r\n if (this._thumbWidth.toString(this._host) === value) {\r\n return;\r\n }\r\n\r\n if (this._thumbWidth.fromString(value)) {\r\n this._markAsDirty();\r\n }\r\n }\r\n\r\n /** Gets or sets minimum value */\r\n @serialize()\r\n public get minimum(): number {\r\n return this._minimum;\r\n }\r\n\r\n public set minimum(value: number) {\r\n if (this._minimum === value) {\r\n return;\r\n }\r\n\r\n this._minimum = value;\r\n this._markAsDirty();\r\n\r\n this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);\r\n }\r\n\r\n /** Gets or sets maximum value */\r\n @serialize()\r\n public get maximum(): number {\r\n return this._maximum;\r\n }\r\n\r\n public set maximum(value: number) {\r\n if (this._maximum === value) {\r\n return;\r\n }\r\n\r\n this._maximum = value;\r\n this._markAsDirty();\r\n\r\n this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);\r\n }\r\n\r\n /** Gets or sets current value */\r\n @serialize()\r\n public get value(): number {\r\n return this._value;\r\n }\r\n\r\n public set value(value: number) {\r\n value = Math.max(Math.min(value, this._maximum), this._minimum);\r\n\r\n if (this._value === value) {\r\n return;\r\n }\r\n\r\n this._value = value;\r\n this._markAsDirty();\r\n this.onValueChangedObservable.notifyObservers(this._value);\r\n }\r\n\r\n /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */\r\n @serialize()\r\n public get isVertical(): boolean {\r\n return this._isVertical;\r\n }\r\n\r\n public set isVertical(value: boolean) {\r\n if (this._isVertical === value) {\r\n return;\r\n }\r\n\r\n this._isVertical = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /** Gets or sets a value indicating if the thumb can go over main bar extends */\r\n @serialize()\r\n public get isThumbClamped(): boolean {\r\n return this._isThumbClamped;\r\n }\r\n\r\n public set isThumbClamped(value: boolean) {\r\n if (this._isThumbClamped === value) {\r\n return;\r\n }\r\n\r\n this._isThumbClamped = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Creates a new BaseSlider\r\n * @param name defines the control name\r\n */\r\n constructor(public name?: string) {\r\n super(name);\r\n\r\n this.isPointerBlocker = true;\r\n }\r\n\r\n protected _getTypeName(): string {\r\n return \"BaseSlider\";\r\n }\r\n\r\n protected _getThumbPosition() {\r\n if (this.isVertical) {\r\n return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;\r\n }\r\n\r\n return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;\r\n }\r\n\r\n protected _getThumbThickness(type: string): number {\r\n let thumbThickness = 0;\r\n switch (type) {\r\n case \"circle\":\r\n if (this._thumbWidth.isPixel) {\r\n thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);\r\n } else {\r\n thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);\r\n }\r\n break;\r\n case \"rectangle\":\r\n if (this._thumbWidth.isPixel) {\r\n thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);\r\n } else {\r\n thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);\r\n }\r\n }\r\n return thumbThickness;\r\n }\r\n\r\n protected _prepareRenderingData(type: string) {\r\n // Main bar\r\n this._effectiveBarOffset = 0;\r\n this._renderLeft = this._currentMeasure.left;\r\n this._renderTop = this._currentMeasure.top;\r\n this._renderWidth = this._currentMeasure.width;\r\n this._renderHeight = this._currentMeasure.height;\r\n\r\n this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);\r\n this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);\r\n this._effectiveThumbThickness = this._getThumbThickness(type);\r\n\r\n if (this.displayThumb) {\r\n this._backgroundBoxLength -= this._effectiveThumbThickness;\r\n }\r\n //throw error when height is less than width for vertical slider\r\n if (this.isVertical && this._currentMeasure.height < this._currentMeasure.width) {\r\n Logger.Error(\"Height should be greater than width\");\r\n return;\r\n }\r\n if (this._barOffset.isPixel) {\r\n this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);\r\n } else {\r\n this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);\r\n }\r\n\r\n this._backgroundBoxThickness -= this._effectiveBarOffset * 2;\r\n\r\n if (this.isVertical) {\r\n this._renderLeft += this._effectiveBarOffset;\r\n if (!this.isThumbClamped && this.displayThumb) {\r\n this._renderTop += this._effectiveThumbThickness / 2;\r\n }\r\n\r\n this._renderHeight = this._backgroundBoxLength;\r\n this._renderWidth = this._backgroundBoxThickness;\r\n } else {\r\n this._renderTop += this._effectiveBarOffset;\r\n if (!this.isThumbClamped && this.displayThumb) {\r\n this._renderLeft += this._effectiveThumbThickness / 2;\r\n }\r\n this._renderHeight = this._backgroundBoxThickness;\r\n this._renderWidth = this._backgroundBoxLength;\r\n }\r\n }\r\n\r\n // Events\r\n private _pointerIsDown = false;\r\n\r\n /**\r\n * @internal\r\n */\r\n protected _updateValueFromPointer(x: number, y: number): void {\r\n if (this.rotation != 0) {\r\n this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);\r\n x = this._transformedPosition.x;\r\n y = this._transformedPosition.y;\r\n }\r\n\r\n let value: number;\r\n if (this._isVertical) {\r\n value = this._minimum + (1 - (y - this._currentMeasure.top) / this._currentMeasure.height) * (this._maximum - this._minimum);\r\n } else {\r\n value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);\r\n }\r\n this.value = this._step ? Math.round(value / this._step) * this._step : value;\r\n }\r\n\r\n public _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, pi: PointerInfoBase): boolean {\r\n if (!super._onPointerDown(target, coordinates, pointerId, buttonIndex, pi)) {\r\n return false;\r\n }\r\n\r\n if (this.isReadOnly) {\r\n return true;\r\n }\r\n\r\n this._pointerIsDown = true;\r\n\r\n this._updateValueFromPointer(coordinates.x, coordinates.y);\r\n this._host._capturingControl[pointerId] = this;\r\n this._lastPointerDownId = pointerId;\r\n return true;\r\n }\r\n\r\n public _onPointerMove(target: Control, coordinates: Vector2, pointerId: number, pi: PointerInfoBase): void {\r\n // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)\r\n if (pointerId != this._lastPointerDownId) {\r\n return;\r\n }\r\n\r\n if (this._pointerIsDown && !this.isReadOnly) {\r\n this._updateValueFromPointer(coordinates.x, coordinates.y);\r\n }\r\n\r\n super._onPointerMove(target, coordinates, pointerId, pi);\r\n }\r\n\r\n public _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void {\r\n this._pointerIsDown = false;\r\n\r\n delete this._host._capturingControl[pointerId];\r\n super._onPointerUp(target, coordinates, pointerId, buttonIndex, notifyClick);\r\n }\r\n\r\n public _onCanvasBlur(): void {\r\n this._forcePointerUp();\r\n super._onCanvasBlur();\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@babylonjs/gui",
|
3
|
-
"version": "6.34.
|
3
|
+
"version": "6.34.2",
|
4
4
|
"main": "index.js",
|
5
5
|
"module": "index.js",
|
6
6
|
"types": "index.d.ts",
|
@@ -18,7 +18,7 @@
|
|
18
18
|
"postcompile": "build-tools -c add-js-to-es6"
|
19
19
|
},
|
20
20
|
"devDependencies": {
|
21
|
-
"@babylonjs/core": "^6.34.
|
21
|
+
"@babylonjs/core": "^6.34.2",
|
22
22
|
"@dev/build-tools": "^1.0.0",
|
23
23
|
"@lts/gui": "1.0.0"
|
24
24
|
},
|