@babylonjs/gui 7.23.0 → 7.23.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,13 +1,17 @@
1
1
  import type { Control } from "../../2D/controls/control";
2
2
  import { AdvancedDynamicTexture } from "../../2D/advancedDynamicTexture";
3
+ import type { Nullable } from "@babylonjs/core/types.js";
3
4
  import { Control3D } from "./control3D";
4
5
  /**
5
6
  * The base class for controls that display content
6
7
  */
7
8
  export declare class ContentDisplay3D extends Control3D {
8
9
  private _content;
9
- private _facadeTexture;
10
- protected _contentResolution: number;
10
+ protected _facadeTexture: Nullable<AdvancedDynamicTexture>;
11
+ protected _contentResolution: number | {
12
+ width: number;
13
+ height: number;
14
+ };
11
15
  protected _contentScaleRatio: number;
12
16
  protected _contentScaleRatioY?: number;
13
17
  /**
@@ -19,8 +23,14 @@ export declare class ContentDisplay3D extends Control3D {
19
23
  /**
20
24
  * Gets or sets the texture resolution used to render content (512 by default)
21
25
  */
22
- get contentResolution(): number;
23
- set contentResolution(value: number);
26
+ get contentResolution(): number | {
27
+ width: number;
28
+ height: number;
29
+ };
30
+ set contentResolution(value: number | {
31
+ width: number;
32
+ height: number;
33
+ });
24
34
  protected _disposeFacadeTexture(): void;
25
35
  protected _resetContent(): void;
26
36
  /**
@@ -22,7 +22,9 @@ export class ContentDisplay3D extends Control3D {
22
22
  return;
23
23
  }
24
24
  if (!this._facadeTexture) {
25
- this._facadeTexture = new AdvancedDynamicTexture("Facade", this._contentResolution, this._contentResolution, this._host.utilityLayer.utilityLayerScene, true, Texture.TRILINEAR_SAMPLINGMODE);
25
+ const width = typeof this._contentResolution === "number" ? this._contentResolution : this._contentResolution.width;
26
+ const height = typeof this._contentResolution === "number" ? this._contentResolution : this._contentResolution.height;
27
+ this._facadeTexture = new AdvancedDynamicTexture("Facade", width, height, this._host.utilityLayer.utilityLayerScene, true, Texture.TRILINEAR_SAMPLINGMODE);
26
28
  this._setFacadeTextureScaling();
27
29
  this._facadeTexture.premulAlpha = true;
28
30
  }
@@ -34,6 +36,9 @@ export class ContentDisplay3D extends Control3D {
34
36
  }
35
37
  _setFacadeTextureScaling() {
36
38
  if (this._facadeTexture) {
39
+ if (typeof this._contentResolution !== "number") {
40
+ this._contentScaleRatioY = (this._contentResolution.height / this._contentResolution.width) * this._contentScaleRatio;
41
+ }
37
42
  this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
38
43
  this._facadeTexture.rootContainer.scaleY = this._contentScaleRatioY ?? this._contentScaleRatio;
39
44
  }
@@ -45,7 +50,11 @@ export class ContentDisplay3D extends Control3D {
45
50
  return this._contentResolution;
46
51
  }
47
52
  set contentResolution(value) {
48
- if (this._contentResolution === value) {
53
+ const incomingWidth = typeof value === "number" ? value : value.width;
54
+ const incomingHeight = typeof value === "number" ? value : value.height;
55
+ const currentWidth = typeof this._contentResolution === "number" ? this._contentResolution : this._contentResolution.width;
56
+ const currentHeight = typeof this._contentResolution === "number" ? this._contentResolution : this._contentResolution.height;
57
+ if (incomingWidth === currentWidth && incomingHeight === currentHeight) {
49
58
  return;
50
59
  }
51
60
  this._contentResolution = value;
@@ -1 +1 @@
1
- {"version":3,"file":"contentDisplay3D.js","sourceRoot":"","sources":["../../../../../dev/gui/src/3D/controls/contentDisplay3D.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAEzE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,sDAAwC;AAE1D;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IAA/C;;QAGc,uBAAkB,GAAG,GAAG,CAAC;QACzB,uBAAkB,GAAG,CAAC,CAAC;IA+ErC,CAAC;IA5EG;;OAEG;IACH,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED,IAAW,OAAO,CAAC,KAAc;QAC7B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QAEtB,IAAI,CAAC,KAAK,IAAI,C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,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;YAC9B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;SAC9B;IACL,CAAC;IAES,aAAa;QACnB,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACH,6DAA6D;IACnD,YAAY,CAAC,aAAqC,IAAG,CAAC;CACnE","sourcesContent":["import type { Control } from \"../../2D/controls/control\";\r\nimport { AdvancedDynamicTexture } from \"../../2D/advancedDynamicTexture\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { Control3D } from \"./control3D\";\r\nimport { Texture } from \"core/Materials/Textures/texture\";\r\n\r\n/**\r\n * The base class for controls that display content\r\n */\r\nexport class ContentDisplay3D extends Control3D {\r\n private _content: Control;\r\n private _facadeTexture: Nullable<AdvancedDynamicTexture>;\r\n protected _contentResolution = 512;\r\n protected _contentScaleRatio = 2;\r\n protected _contentScaleRatioY?: number;\r\n\r\n /**\r\n * Gets or sets the GUI 2D content used to display the button's facade\r\n */\r\n public get content(): Control {\r\n return this._content;\r\n }\r\n\r\n public set content(value: Control) {\r\n this._content = value;\r\n\r\n if (!value || !this._host || !this._host.utilityLayer) {\r\n return;\r\n }\r\n\r\n if (!this._facadeTexture) {\r\n this._facadeTexture = new AdvancedDynamicTexture(\r\n \"Facade\",\r\n this._contentResolution,\r\n this._contentResolution,\r\n this._host.utilityLayer.utilityLayerScene,\r\n true,\r\n Texture.TRILINEAR_SAMPLINGMODE\r\n );\r\n this._setFacadeTextureScaling();\r\n this._facadeTexture.premulAlpha = true;\r\n } else {\r\n this._facadeTexture.rootContainer.clearControls();\r\n }\r\n\r\n this._facadeTexture.addControl(value);\r\n\r\n this._applyFacade(this._facadeTexture);\r\n }\r\n\r\n protected _setFacadeTextureScaling() {\r\n if (this._facadeTexture) {\r\n this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;\r\n this._facadeTexture.rootContainer.scaleY = this._contentScaleRatioY ?? this._contentScaleRatio;\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the texture resolution used to render content (512 by default)\r\n */\r\n public get contentResolution(): number {\r\n return this._contentResolution;\r\n }\r\n\r\n public set contentResolution(value: number) {\r\n if (this._contentResolution === value) {\r\n return;\r\n }\r\n\r\n this._contentResolution = value;\r\n this._resetContent();\r\n }\r\n\r\n protected _disposeFacadeTexture() {\r\n if (this._facadeTexture) {\r\n this._facadeTexture.dispose();\r\n this._facadeTexture = null;\r\n }\r\n }\r\n\r\n protected _resetContent() {\r\n this._disposeFacadeTexture();\r\n this.content = this._content;\r\n }\r\n\r\n /**\r\n * Apply the facade texture (created from the content property).\r\n * This function can be overloaded by child classes\r\n * @param facadeTexture defines the AdvancedDynamicTexture to use\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n protected _applyFacade(facadeTexture: AdvancedDynamicTexture) {}\r\n}\r\n"]}
1
+ {"version":3,"file":"contentDisplay3D.js","sourceRoot":"","sources":["../../../../../dev/gui/src/3D/controls/contentDisplay3D.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAEzE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,sDAAwC;AAE1D;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IAA/C;;QAGc,uBAAkB,GAA+C,GAAG,CAAC;QACrE,uBAAkB,GAAG,CAAC,CAAC;IAiFrC,CAAC;IA9EG;;OAEG;IACH,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED,IAAW,OAAO,CAAC,KAAc;QAC7B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QAEtB,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,EA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ACH,6DAA6D;IACnD,YAAY,CAAC,aAAqC,IAAG,CAAC;CACnE","sourcesContent":["import type { Control } from \"../../2D/controls/control\";\r\nimport { AdvancedDynamicTexture } from \"../../2D/advancedDynamicTexture\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { Control3D } from \"./control3D\";\r\nimport { Texture } from \"core/Materials/Textures/texture\";\r\n\r\n/**\r\n * The base class for controls that display content\r\n */\r\nexport class ContentDisplay3D extends Control3D {\r\n private _content: Control;\r\n protected _facadeTexture: Nullable<AdvancedDynamicTexture>;\r\n protected _contentResolution: number | { width: number; height: number } = 512;\r\n protected _contentScaleRatio = 2;\r\n protected _contentScaleRatioY?: number;\r\n\r\n /**\r\n * Gets or sets the GUI 2D content used to display the button's facade\r\n */\r\n public get content(): Control {\r\n return this._content;\r\n }\r\n\r\n public set content(value: Control) {\r\n this._content = value;\r\n\r\n if (!value || !this._host || !this._host.utilityLayer) {\r\n return;\r\n }\r\n\r\n if (!this._facadeTexture) {\r\n const width = typeof this._contentResolution === \"number\" ? this._contentResolution : this._contentResolution.width;\r\n const height = typeof this._contentResolution === \"number\" ? this._contentResolution : this._contentResolution.height;\r\n this._facadeTexture = new AdvancedDynamicTexture(\"Facade\", width, height, this._host.utilityLayer.utilityLayerScene, true, Texture.TRILINEAR_SAMPLINGMODE);\r\n this._setFacadeTextureScaling();\r\n this._facadeTexture.premulAlpha = true;\r\n } else {\r\n this._facadeTexture.rootContainer.clearControls();\r\n }\r\n\r\n this._facadeTexture.addControl(value);\r\n\r\n this._applyFacade(this._facadeTexture);\r\n }\r\n\r\n protected _setFacadeTextureScaling() {\r\n if (this._facadeTexture) {\r\n if (typeof this._contentResolution !== \"number\") {\r\n this._contentScaleRatioY = (this._contentResolution.height / this._contentResolution.width) * this._contentScaleRatio;\r\n }\r\n this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;\r\n this._facadeTexture.rootContainer.scaleY = this._contentScaleRatioY ?? this._contentScaleRatio;\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the texture resolution used to render content (512 by default)\r\n */\r\n public get contentResolution(): number | { width: number; height: number } {\r\n return this._contentResolution;\r\n }\r\n\r\n public set contentResolution(value: number | { width: number; height: number }) {\r\n const incomingWidth = typeof value === \"number\" ? value : value.width;\r\n const incomingHeight = typeof value === \"number\" ? value : value.height;\r\n const currentWidth = typeof this._contentResolution === \"number\" ? this._contentResolution : this._contentResolution.width;\r\n const currentHeight = typeof this._contentResolution === \"number\" ? this._contentResolution : this._contentResolution.height;\r\n if (incomingWidth === currentWidth && incomingHeight === currentHeight) {\r\n return;\r\n }\r\n\r\n this._contentResolution = value;\r\n this._resetContent();\r\n }\r\n\r\n protected _disposeFacadeTexture() {\r\n if (this._facadeTexture) {\r\n this._facadeTexture.dispose();\r\n this._facadeTexture = null;\r\n }\r\n }\r\n\r\n protected _resetContent() {\r\n this._disposeFacadeTexture();\r\n this.content = this._content;\r\n }\r\n\r\n /**\r\n * Apply the facade texture (created from the content property).\r\n * This function can be overloaded by child classes\r\n * @param facadeTexture defines the AdvancedDynamicTexture to use\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n protected _applyFacade(facadeTexture: AdvancedDynamicTexture) {}\r\n}\r\n"]}
@@ -23,6 +23,8 @@ export declare class Control3D implements IDisposable, IBehaviorAware<Control3D>
23
23
  _host: GUI3DManager;
24
24
  /** @internal */
25
25
  _isScaledByManager: boolean;
26
+ private _position?;
27
+ private _scaling?;
26
28
  /** Gets or sets the control position in world space */
27
29
  get position(): Vector3;
28
30
  set position(value: Vector3);
@@ -10,29 +10,33 @@ export class Control3D {
10
10
  /** Gets or sets the control position in world space */
11
11
  get position() {
12
12
  if (!this._node) {
13
- return Vector3.Zero();
13
+ this._position = this._position || Vector3.Zero();
14
+ return this._position;
14
15
  }
15
16
  return this._node.position;
16
17
  }
17
18
  set position(value) {
19
+ this._position = value;
18
20
  if (!this._node) {
19
21
  return;
20
22
  }
21
- this._node.position = value;
23
+ this._node.position = this._position;
22
24
  }
23
25
  /** Gets or sets the control scaling in world space */
24
26
  get scaling() {
25
27
  if (!this._node) {
26
- return new Vector3(1, 1, 1);
28
+ this._scaling = this.scaling || new Vector3(1, 1, 1);
29
+ return this._scaling;
27
30
  }
28
31
  return this._node.scaling;
29
32
  }
30
33
  set scaling(value) {
34
+ this._scaling = value;
31
35
  if (!this._node) {
32
36
  return;
33
37
  }
34
38
  this._isScaledByManager = false;
35
- this._node.scaling = value;
39
+ this._node.scaling = this._scaling;
36
40
  }
37
41
  /**
38
42
  * Gets the list of attached behaviors
@@ -201,6 +205,12 @@ export class Control3D {
201
205
  if (!this.node) {
202
206
  return;
203
207
  }
208
+ if (this._position) {
209
+ this.node.position = this._position;
210
+ }
211
+ if (this._scaling) {
212
+ this.node.scaling = this._scaling;
213
+ }
204
214
  this._injectGUI3DReservedDataStore(this.node).control = this; // Store the control on the reservedDataStore field in order to get it when picking
205
215
  const mesh = this.mesh;
206
216
  if (mesh) {
@@ -1 +1 @@
1
- {"version":3,"file":"control3D.js","sourceRoot":"","sources":["../../../../../dev/gui/src/3D/controls/control3D.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAClD,OAAO,EAAE,OAAO,EAAE,6CAA+B;AACjD,OAAO,EAAE,iBAAiB,EAAE,gDAAkC;AAE9D,OAAO,EAAE,YAAY,EAAE,+CAAiC;AAKxD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAKrD;;GAEG;AACH,MAAM,OAAO,SAAS;IAalB,uDAAuD;IACvD,IAAW,QAAQ;QACf,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACb,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC;SACzB;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC/B,CAAC;IAED,IAAW,QAAQ,CAAC,KAAc;QAC9B,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACb,OAAO;SACV;QAED,IAAI,CAAC,KA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able } from \"core/types\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport { PointerEventTypes } from \"core/Events/pointerEvents\";\r\nimport type { TransformNode } from \"core/Meshes/transformNode\";\r\nimport { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport type { IBehaviorAware, Behavior } from \"core/Behaviors/behavior\";\r\nimport type { IDisposable, Scene } from \"core/scene\";\r\n\r\nimport type { GUI3DManager } from \"../gui3DManager\";\r\nimport { Vector3WithInfo } from \"../vector3WithInfo\";\r\nimport type { Container3D } from \"./container3D\";\r\n\r\nimport type { TouchButton3D } from \"./touchButton3D\";\r\n\r\n/**\r\n * Class used as base class for controls\r\n */\r\nexport class Control3D implements IDisposable, IBehaviorAware<Control3D> {\r\n private _node: Nullable<TransformNode>;\r\n private _downCount = 0;\r\n private _enterCount = -1;\r\n private _downPointerIds: { [id: number]: number } = {}; // Store number of pointer downs per ID, from near and far interactions\r\n\r\n protected _isVisible = true;\r\n\r\n /** @internal */\r\n public _host: GUI3DManager;\r\n /** @internal */\r\n public _isScaledByManager = false;\r\n\r\n /** Gets or sets the control position in world space */\r\n public get position(): Vector3 {\r\n if (!this._node) {\r\n return Vector3.Zero();\r\n }\r\n\r\n return this._node.position;\r\n }\r\n\r\n public set position(value: Vector3) {\r\n if (!this._node) {\r\n return;\r\n }\r\n\r\n this._node.position = value;\r\n }\r\n\r\n /** Gets or sets the control scaling in world space */\r\n public get scaling(): Vector3 {\r\n if (!this._node) {\r\n return new Vector3(1, 1, 1);\r\n }\r\n\r\n return this._node.scaling;\r\n }\r\n\r\n public set scaling(value: Vector3) {\r\n if (!this._node) {\r\n return;\r\n }\r\n\r\n this._isScaledByManager = false;\r\n this._node.scaling = value;\r\n }\r\n\r\n /** Callback used to start pointer enter animation */\r\n public pointerEnterAnimation: () => void;\r\n /** Callback used to start pointer out animation */\r\n public pointerOutAnimation: () => void;\r\n /** Callback used to start pointer down animation */\r\n public pointerDownAnimation: () => void;\r\n /** Callback used to start pointer up animation */\r\n public pointerUpAnimation: () => void;\r\n\r\n /**\r\n * An event triggered when the pointer moves over the control\r\n */\r\n public onPointerMoveObservable = new Observable<Vector3>();\r\n\r\n /**\r\n * An event triggered when the pointer moves out of the control\r\n */\r\n public onPointerOutObservable = new Observable<Control3D>();\r\n\r\n /**\r\n * An event triggered when the pointer taps the control\r\n */\r\n public onPointerDownObservable = new Observable<Vector3WithInfo>();\r\n\r\n /**\r\n * An event triggered when pointer is up\r\n */\r\n public onPointerUpObservable = new Observable<Vector3WithInfo>();\r\n\r\n /**\r\n * An event triggered when a control is clicked on (with a mouse)\r\n */\r\n public onPointerClickObservable = new Observable<Vector3WithInfo>();\r\n\r\n /**\r\n * An event triggered when pointer enters the control\r\n */\r\n public onPointerEnterObservable = new Observable<Control3D>();\r\n\r\n /**\r\n * Gets or sets the parent container\r\n */\r\n public parent: Nullable<Container3D>;\r\n\r\n // Behaviors\r\n private _behaviors = new Array<Behavior<Control3D>>();\r\n\r\n /**\r\n * Gets the list of attached behaviors\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/behaviors\r\n */\r\n public get behaviors(): Behavior<Control3D>[] {\r\n return this._behaviors;\r\n }\r\n\r\n /**\r\n * Attach a behavior to the control\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/behaviors\r\n * @param behavior defines the behavior to attach\r\n * @returns the current control\r\n */\r\n public addBehavior(behavior: Behavior<Control3D>): Control3D {\r\n const index = this._behaviors.indexOf(behavior);\r\n\r\n if (index !== -1) {\r\n return this;\r\n }\r\n\r\n behavior.init();\r\n const scene = this._host.scene;\r\n if (scene.isLoading) {\r\n // We defer the attach when the scene will be loaded\r\n scene.onDataLoadedObservable.addOnce(() => {\r\n behavior.attach(this);\r\n });\r\n } else {\r\n behavior.attach(this);\r\n }\r\n this._behaviors.push(behavior);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Remove an attached behavior\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/behaviors\r\n * @param behavior defines the behavior to attach\r\n * @returns the current control\r\n */\r\n public removeBehavior(behavior: Behavior<Control3D>): Control3D {\r\n const index = this._behaviors.indexOf(behavior);\r\n\r\n if (index === -1) {\r\n return this;\r\n }\r\n\r\n this._behaviors[index].detach();\r\n this._behaviors.splice(index, 1);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets an attached behavior by name\r\n * @param name defines the name of the behavior to look for\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/behaviors\r\n * @returns null if behavior was not found else the requested behavior\r\n */\r\n public getBehaviorByName(name: string): Nullable<Behavior<Control3D>> {\r\n for (const behavior of this._behaviors) {\r\n if (behavior.name === name) {\r\n return behavior;\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /** Gets or sets a boolean indicating if the control is visible */\r\n public get isVisible(): boolean {\r\n return this._isVisible;\r\n }\r\n\r\n public set isVisible(value: boolean) {\r\n if (this._isVisible === value) {\r\n return;\r\n }\r\n\r\n this._isVisible = value;\r\n\r\n const mesh = this.mesh;\r\n if (mesh) {\r\n mesh.setEnabled(value);\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new control\r\n * @param name defines the control name\r\n */\r\n constructor(\r\n /** Defines the control name */\r\n public name?: string\r\n ) {}\r\n\r\n /**\r\n * Gets a string representing the class name\r\n */\r\n public get typeName(): string {\r\n return this._getTypeName();\r\n }\r\n\r\n /**\r\n * Get the current class name of the control.\r\n * @returns current class name\r\n */\r\n public getClassName(): string {\r\n return this._getTypeName();\r\n }\r\n\r\n protected _getTypeName(): string {\r\n return \"Control3D\";\r\n }\r\n\r\n /**\r\n * Gets the transform node used by this control\r\n */\r\n public get node(): Nullable<TransformNode> {\r\n return this._node;\r\n }\r\n\r\n /**\r\n * Gets the mesh used to render this control\r\n */\r\n public get mesh(): Nullable<AbstractMesh> {\r\n if (this._node instanceof AbstractMesh) {\r\n return this._node as AbstractMesh;\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Link the control as child of the given node\r\n * @param node defines the node to link to. Use null to unlink the control\r\n * @returns the current control\r\n */\r\n public linkToTransformNode(node: Nullable<TransformNode>): Control3D {\r\n if (this._node) {\r\n this._node.parent = node;\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _prepareNode(scene: Scene): void {\r\n if (!this._node) {\r\n this._node = this._createNode(scene);\r\n\r\n if (!this.node) {\r\n return;\r\n }\r\n this._injectGUI3DReservedDataStore(this.node).control = this; // Store the control on the reservedDataStore field in order to get it when picking\r\n\r\n const mesh = this.mesh;\r\n if (mesh) {\r\n mesh.isPickable = true;\r\n\r\n this._affectMaterial(mesh);\r\n }\r\n }\r\n }\r\n\r\n protected _injectGUI3DReservedDataStore(node: TransformNode): any {\r\n node.reservedDataStore = node.reservedDataStore ?? {};\r\n node.reservedDataStore.GUI3D = node.reservedDataStore.GUI3D ?? {};\r\n return node.reservedDataStore.GUI3D;\r\n }\r\n\r\n /**\r\n * Node creation.\r\n * Can be overriden by children\r\n * @param scene defines the scene where the node must be attached\r\n * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an attached visible object\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n protected _createNode(scene: Scene): Nullable<TransformNode> {\r\n // Do nothing by default\r\n return null;\r\n }\r\n\r\n /**\r\n * Affect a material to the given mesh\r\n * @param mesh defines the mesh which will represent the control\r\n */\r\n protected _affectMaterial(mesh: AbstractMesh) {\r\n mesh.material = null;\r\n }\r\n\r\n private _isTouchButton3D(control: Control3D): control is TouchButton3D {\r\n return (control as TouchButton3D)._generatePointerEventType !== undefined;\r\n }\r\n\r\n // Pointers\r\n\r\n /**\r\n * @internal\r\n */\r\n public _onPointerMove(target: Control3D, coordinates: Vector3): void {\r\n this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _onPointerEnter(target: Control3D): boolean {\r\n if (this._enterCount === -1) {\r\n // -1 is for touch input, we are now sure we are with a mouse or pencil\r\n this._enterCount = 0;\r\n }\r\n\r\n this._enterCount++;\r\n\r\n if (this._enterCount > 1) {\r\n return false;\r\n }\r\n\r\n this.onPointerEnterObservable.notifyObservers(this, -1, target, this);\r\n\r\n if (this.pointerEnterAnimation) {\r\n this.pointerEnterAnimation();\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _onPointerOut(target: Control3D): void {\r\n this._enterCount--;\r\n\r\n if (this._enterCount > 0) {\r\n return;\r\n }\r\n\r\n this._enterCount = 0;\r\n\r\n this.onPointerOutObservable.notifyObservers(this, -1, target, this);\r\n\r\n if (this.pointerOutAnimation) {\r\n this.pointerOutAnimation();\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _onPointerDown(target: Control3D, coordinates: Vector3, pointerId: number, buttonIndex: number): boolean {\r\n this._downCount++;\r\n this._downPointerIds[pointerId] = this._downPointerIds[pointerId] + 1 || 1;\r\n\r\n if (this._downCount !== 1) {\r\n return false;\r\n }\r\n\r\n this.onPointerDownObservable.notifyObservers(new Vector3WithInfo(coordinates, buttonIndex), -1, target, this);\r\n\r\n if (this.pointerDownAnimation) {\r\n this.pointerDownAnimation();\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _onPointerUp(target: Control3D, coordinates: Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void {\r\n this._downCount--;\r\n this._downPointerIds[pointerId]--;\r\n\r\n if (this._downPointerIds[pointerId] <= 0) {\r\n delete this._downPointerIds[pointerId];\r\n }\r\n\r\n if (this._downCount < 0) {\r\n // Handle if forcePointerUp was called prior to this\r\n this._downCount = 0;\r\n return;\r\n }\r\n\r\n if (this._downCount == 0) {\r\n if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {\r\n this.onPointerClickObservable.notifyObservers(new Vector3WithInfo(coordinates, buttonIndex), -1, target, this);\r\n }\r\n this.onPointerUpObservable.notifyObservers(new Vector3WithInfo(coordinates, buttonIndex), -1, target, this);\r\n\r\n if (this.pointerUpAnimation) {\r\n this.pointerUpAnimation();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public forcePointerUp(pointerId: Nullable<number> = null) {\r\n if (pointerId !== null) {\r\n this._onPointerUp(this, Vector3.Zero(), pointerId, 0, true);\r\n } else {\r\n for (const key in this._downPointerIds) {\r\n this._onPointerUp(this, Vector3.Zero(), +key as number, 0, true);\r\n }\r\n if (this._downCount > 0) {\r\n this._downCount = 1;\r\n this._onPointerUp(this, Vector3.Zero(), 0, 0, true);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _processObservables(type: number, pickedPoint: Vector3, originMeshPosition: Nullable<Vector3>, pointerId: number, buttonIndex: number): boolean {\r\n if (this._isTouchButton3D(this) && originMeshPosition) {\r\n type = this._generatePointerEventType(type, originMeshPosition, this._downCount);\r\n }\r\n\r\n if (type === PointerEventTypes.POINTERMOVE) {\r\n this._onPointerMove(this, pickedPoint);\r\n\r\n const previousControlOver = this._host._lastControlOver[pointerId];\r\n if (previousControlOver && previousControlOver !== this) {\r\n previousControlOver._onPointerOut(this);\r\n }\r\n\r\n if (previousControlOver !== this) {\r\n this._onPointerEnter(this);\r\n }\r\n\r\n this._host._lastControlOver[pointerId] = this;\r\n return true;\r\n }\r\n\r\n if (type === PointerEventTypes.POINTERDOWN) {\r\n this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);\r\n this._host._lastControlDown[pointerId] = this;\r\n this._host._lastPickedControl = this;\r\n return true;\r\n }\r\n\r\n if (type === PointerEventTypes.POINTERUP || type === PointerEventTypes.POINTERDOUBLETAP) {\r\n if (this._host._lastControlDown[pointerId]) {\r\n this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);\r\n }\r\n delete this._host._lastControlDown[pointerId];\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /** @internal */\r\n public _disposeNode(): void {\r\n if (this._node) {\r\n this._node.dispose();\r\n this._node = null;\r\n }\r\n }\r\n\r\n /**\r\n * Releases all associated resources\r\n */\r\n public dispose() {\r\n this.onPointerDownObservable.clear();\r\n this.onPointerEnterObservable.clear();\r\n this.onPointerMoveObservable.clear();\r\n this.onPointerOutObservable.clear();\r\n this.onPointerUpObservable.clear();\r\n this.onPointerClickObservable.clear();\r\n\r\n this._disposeNode();\r\n\r\n // Behaviors\r\n for (const behavior of this._behaviors) {\r\n behavior.detach();\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"control3D.js","sourceRoot":"","sources":["../../../../../dev/gui/src/3D/controls/control3D.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAClD,OAAO,EAAE,OAAO,EAAE,6CAA+B;AACjD,OAAO,EAAE,iBAAiB,EAAE,gDAAkC;AAE9D,OAAO,EAAE,YAAY,EAAE,+CAAiC;AAKxD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAKrD;;GAEG;AACH,MAAM,OAAO,SAAS;IAgBlB,uDAAuD;IACvD,IAAW,QAAQ;QACf,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACb,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YAClD,OAAO,IAAI,CAAC,SAAS,CAAC;SACzB;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC/B,CAAC;IAED,IAAW,QAAQ,CAAC,KAAc;QAC9B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACb,OAAO;SACV;QAED,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC;IACzC,CAAC;IAED,sDAAsD;IACtD,IAAW,OAAO;QACd,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACb,IAAI,CAAC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AC,wBAAwB,CAAC,KAAK,EAAE,CAAC;QAEtC,IAAI,CAAC,YAAY,EAAE,CAAC;QAEpB,YAAY;QACZ,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,UAAU,EAAE;YACpC,QAAQ,CAAC,MAAM,EAAE,CAAC;SACrB;IACL,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport { PointerEventTypes } from \"core/Events/pointerEvents\";\r\nimport type { TransformNode } from \"core/Meshes/transformNode\";\r\nimport { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport type { IBehaviorAware, Behavior } from \"core/Behaviors/behavior\";\r\nimport type { IDisposable, Scene } from \"core/scene\";\r\n\r\nimport type { GUI3DManager } from \"../gui3DManager\";\r\nimport { Vector3WithInfo } from \"../vector3WithInfo\";\r\nimport type { Container3D } from \"./container3D\";\r\n\r\nimport type { TouchButton3D } from \"./touchButton3D\";\r\n\r\n/**\r\n * Class used as base class for controls\r\n */\r\nexport class Control3D implements IDisposable, IBehaviorAware<Control3D> {\r\n private _node: Nullable<TransformNode>;\r\n private _downCount = 0;\r\n private _enterCount = -1;\r\n private _downPointerIds: { [id: number]: number } = {}; // Store number of pointer downs per ID, from near and far interactions\r\n\r\n protected _isVisible = true;\r\n\r\n /** @internal */\r\n public _host: GUI3DManager;\r\n /** @internal */\r\n public _isScaledByManager = false;\r\n\r\n private _position?: Vector3;\r\n private _scaling?: Vector3;\r\n\r\n /** Gets or sets the control position in world space */\r\n public get position(): Vector3 {\r\n if (!this._node) {\r\n this._position = this._position || Vector3.Zero();\r\n return this._position;\r\n }\r\n\r\n return this._node.position;\r\n }\r\n\r\n public set position(value: Vector3) {\r\n this._position = value;\r\n if (!this._node) {\r\n return;\r\n }\r\n\r\n this._node.position = this._position;\r\n }\r\n\r\n /** Gets or sets the control scaling in world space */\r\n public get scaling(): Vector3 {\r\n if (!this._node) {\r\n this._scaling = this.scaling || new Vector3(1, 1, 1);\r\n return this._scaling;\r\n }\r\n\r\n return this._node.scaling;\r\n }\r\n\r\n public set scaling(value: Vector3) {\r\n this._scaling = value;\r\n if (!this._node) {\r\n return;\r\n }\r\n\r\n this._isScaledByManager = false;\r\n this._node.scaling = this._scaling;\r\n }\r\n\r\n /** Callback used to start pointer enter animation */\r\n public pointerEnterAnimation: () => void;\r\n /** Callback used to start pointer out animation */\r\n public pointerOutAnimation: () => void;\r\n /** Callback used to start pointer down animation */\r\n public pointerDownAnimation: () => void;\r\n /** Callback used to start pointer up animation */\r\n public pointerUpAnimation: () => void;\r\n\r\n /**\r\n * An event triggered when the pointer moves over the control\r\n */\r\n public onPointerMoveObservable = new Observable<Vector3>();\r\n\r\n /**\r\n * An event triggered when the pointer moves out of the control\r\n */\r\n public onPointerOutObservable = new Observable<Control3D>();\r\n\r\n /**\r\n * An event triggered when the pointer taps the control\r\n */\r\n public onPointerDownObservable = new Observable<Vector3WithInfo>();\r\n\r\n /**\r\n * An event triggered when pointer is up\r\n */\r\n public onPointerUpObservable = new Observable<Vector3WithInfo>();\r\n\r\n /**\r\n * An event triggered when a control is clicked on (with a mouse)\r\n */\r\n public onPointerClickObservable = new Observable<Vector3WithInfo>();\r\n\r\n /**\r\n * An event triggered when pointer enters the control\r\n */\r\n public onPointerEnterObservable = new Observable<Control3D>();\r\n\r\n /**\r\n * Gets or sets the parent container\r\n */\r\n public parent: Nullable<Container3D>;\r\n\r\n // Behaviors\r\n private _behaviors = new Array<Behavior<Control3D>>();\r\n\r\n /**\r\n * Gets the list of attached behaviors\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/behaviors\r\n */\r\n public get behaviors(): Behavior<Control3D>[] {\r\n return this._behaviors;\r\n }\r\n\r\n /**\r\n * Attach a behavior to the control\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/behaviors\r\n * @param behavior defines the behavior to attach\r\n * @returns the current control\r\n */\r\n public addBehavior(behavior: Behavior<Control3D>): Control3D {\r\n const index = this._behaviors.indexOf(behavior);\r\n\r\n if (index !== -1) {\r\n return this;\r\n }\r\n\r\n behavior.init();\r\n const scene = this._host.scene;\r\n if (scene.isLoading) {\r\n // We defer the attach when the scene will be loaded\r\n scene.onDataLoadedObservable.addOnce(() => {\r\n behavior.attach(this);\r\n });\r\n } else {\r\n behavior.attach(this);\r\n }\r\n this._behaviors.push(behavior);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Remove an attached behavior\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/behaviors\r\n * @param behavior defines the behavior to attach\r\n * @returns the current control\r\n */\r\n public removeBehavior(behavior: Behavior<Control3D>): Control3D {\r\n const index = this._behaviors.indexOf(behavior);\r\n\r\n if (index === -1) {\r\n return this;\r\n }\r\n\r\n this._behaviors[index].detach();\r\n this._behaviors.splice(index, 1);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets an attached behavior by name\r\n * @param name defines the name of the behavior to look for\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/behaviors\r\n * @returns null if behavior was not found else the requested behavior\r\n */\r\n public getBehaviorByName(name: string): Nullable<Behavior<Control3D>> {\r\n for (const behavior of this._behaviors) {\r\n if (behavior.name === name) {\r\n return behavior;\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /** Gets or sets a boolean indicating if the control is visible */\r\n public get isVisible(): boolean {\r\n return this._isVisible;\r\n }\r\n\r\n public set isVisible(value: boolean) {\r\n if (this._isVisible === value) {\r\n return;\r\n }\r\n\r\n this._isVisible = value;\r\n\r\n const mesh = this.mesh;\r\n if (mesh) {\r\n mesh.setEnabled(value);\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new control\r\n * @param name defines the control name\r\n */\r\n constructor(\r\n /** Defines the control name */\r\n public name?: string\r\n ) {}\r\n\r\n /**\r\n * Gets a string representing the class name\r\n */\r\n public get typeName(): string {\r\n return this._getTypeName();\r\n }\r\n\r\n /**\r\n * Get the current class name of the control.\r\n * @returns current class name\r\n */\r\n public getClassName(): string {\r\n return this._getTypeName();\r\n }\r\n\r\n protected _getTypeName(): string {\r\n return \"Control3D\";\r\n }\r\n\r\n /**\r\n * Gets the transform node used by this control\r\n */\r\n public get node(): Nullable<TransformNode> {\r\n return this._node;\r\n }\r\n\r\n /**\r\n * Gets the mesh used to render this control\r\n */\r\n public get mesh(): Nullable<AbstractMesh> {\r\n if (this._node instanceof AbstractMesh) {\r\n return this._node as AbstractMesh;\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Link the control as child of the given node\r\n * @param node defines the node to link to. Use null to unlink the control\r\n * @returns the current control\r\n */\r\n public linkToTransformNode(node: Nullable<TransformNode>): Control3D {\r\n if (this._node) {\r\n this._node.parent = node;\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _prepareNode(scene: Scene): void {\r\n if (!this._node) {\r\n this._node = this._createNode(scene);\r\n\r\n if (!this.node) {\r\n return;\r\n }\r\n if (this._position) {\r\n this.node.position = this._position;\r\n }\r\n if (this._scaling) {\r\n this.node.scaling = this._scaling;\r\n }\r\n this._injectGUI3DReservedDataStore(this.node).control = this; // Store the control on the reservedDataStore field in order to get it when picking\r\n\r\n const mesh = this.mesh;\r\n if (mesh) {\r\n mesh.isPickable = true;\r\n\r\n this._affectMaterial(mesh);\r\n }\r\n }\r\n }\r\n\r\n protected _injectGUI3DReservedDataStore(node: TransformNode): any {\r\n node.reservedDataStore = node.reservedDataStore ?? {};\r\n node.reservedDataStore.GUI3D = node.reservedDataStore.GUI3D ?? {};\r\n return node.reservedDataStore.GUI3D;\r\n }\r\n\r\n /**\r\n * Node creation.\r\n * Can be overriden by children\r\n * @param scene defines the scene where the node must be attached\r\n * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an attached visible object\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n protected _createNode(scene: Scene): Nullable<TransformNode> {\r\n // Do nothing by default\r\n return null;\r\n }\r\n\r\n /**\r\n * Affect a material to the given mesh\r\n * @param mesh defines the mesh which will represent the control\r\n */\r\n protected _affectMaterial(mesh: AbstractMesh) {\r\n mesh.material = null;\r\n }\r\n\r\n private _isTouchButton3D(control: Control3D): control is TouchButton3D {\r\n return (control as TouchButton3D)._generatePointerEventType !== undefined;\r\n }\r\n\r\n // Pointers\r\n\r\n /**\r\n * @internal\r\n */\r\n public _onPointerMove(target: Control3D, coordinates: Vector3): void {\r\n this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _onPointerEnter(target: Control3D): boolean {\r\n if (this._enterCount === -1) {\r\n // -1 is for touch input, we are now sure we are with a mouse or pencil\r\n this._enterCount = 0;\r\n }\r\n\r\n this._enterCount++;\r\n\r\n if (this._enterCount > 1) {\r\n return false;\r\n }\r\n\r\n this.onPointerEnterObservable.notifyObservers(this, -1, target, this);\r\n\r\n if (this.pointerEnterAnimation) {\r\n this.pointerEnterAnimation();\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _onPointerOut(target: Control3D): void {\r\n this._enterCount--;\r\n\r\n if (this._enterCount > 0) {\r\n return;\r\n }\r\n\r\n this._enterCount = 0;\r\n\r\n this.onPointerOutObservable.notifyObservers(this, -1, target, this);\r\n\r\n if (this.pointerOutAnimation) {\r\n this.pointerOutAnimation();\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _onPointerDown(target: Control3D, coordinates: Vector3, pointerId: number, buttonIndex: number): boolean {\r\n this._downCount++;\r\n this._downPointerIds[pointerId] = this._downPointerIds[pointerId] + 1 || 1;\r\n\r\n if (this._downCount !== 1) {\r\n return false;\r\n }\r\n\r\n this.onPointerDownObservable.notifyObservers(new Vector3WithInfo(coordinates, buttonIndex), -1, target, this);\r\n\r\n if (this.pointerDownAnimation) {\r\n this.pointerDownAnimation();\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _onPointerUp(target: Control3D, coordinates: Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void {\r\n this._downCount--;\r\n this._downPointerIds[pointerId]--;\r\n\r\n if (this._downPointerIds[pointerId] <= 0) {\r\n delete this._downPointerIds[pointerId];\r\n }\r\n\r\n if (this._downCount < 0) {\r\n // Handle if forcePointerUp was called prior to this\r\n this._downCount = 0;\r\n return;\r\n }\r\n\r\n if (this._downCount == 0) {\r\n if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {\r\n this.onPointerClickObservable.notifyObservers(new Vector3WithInfo(coordinates, buttonIndex), -1, target, this);\r\n }\r\n this.onPointerUpObservable.notifyObservers(new Vector3WithInfo(coordinates, buttonIndex), -1, target, this);\r\n\r\n if (this.pointerUpAnimation) {\r\n this.pointerUpAnimation();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public forcePointerUp(pointerId: Nullable<number> = null) {\r\n if (pointerId !== null) {\r\n this._onPointerUp(this, Vector3.Zero(), pointerId, 0, true);\r\n } else {\r\n for (const key in this._downPointerIds) {\r\n this._onPointerUp(this, Vector3.Zero(), +key as number, 0, true);\r\n }\r\n if (this._downCount > 0) {\r\n this._downCount = 1;\r\n this._onPointerUp(this, Vector3.Zero(), 0, 0, true);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _processObservables(type: number, pickedPoint: Vector3, originMeshPosition: Nullable<Vector3>, pointerId: number, buttonIndex: number): boolean {\r\n if (this._isTouchButton3D(this) && originMeshPosition) {\r\n type = this._generatePointerEventType(type, originMeshPosition, this._downCount);\r\n }\r\n\r\n if (type === PointerEventTypes.POINTERMOVE) {\r\n this._onPointerMove(this, pickedPoint);\r\n\r\n const previousControlOver = this._host._lastControlOver[pointerId];\r\n if (previousControlOver && previousControlOver !== this) {\r\n previousControlOver._onPointerOut(this);\r\n }\r\n\r\n if (previousControlOver !== this) {\r\n this._onPointerEnter(this);\r\n }\r\n\r\n this._host._lastControlOver[pointerId] = this;\r\n return true;\r\n }\r\n\r\n if (type === PointerEventTypes.POINTERDOWN) {\r\n this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);\r\n this._host._lastControlDown[pointerId] = this;\r\n this._host._lastPickedControl = this;\r\n return true;\r\n }\r\n\r\n if (type === PointerEventTypes.POINTERUP || type === PointerEventTypes.POINTERDOUBLETAP) {\r\n if (this._host._lastControlDown[pointerId]) {\r\n this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);\r\n }\r\n delete this._host._lastControlDown[pointerId];\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /** @internal */\r\n public _disposeNode(): void {\r\n if (this._node) {\r\n this._node.dispose();\r\n this._node = null;\r\n }\r\n }\r\n\r\n /**\r\n * Releases all associated resources\r\n */\r\n public dispose() {\r\n this.onPointerDownObservable.clear();\r\n this.onPointerEnterObservable.clear();\r\n this.onPointerMoveObservable.clear();\r\n this.onPointerOutObservable.clear();\r\n this.onPointerUpObservable.clear();\r\n this.onPointerClickObservable.clear();\r\n\r\n this._disposeNode();\r\n\r\n // Behaviors\r\n for (const behavior of this._behaviors) {\r\n behavior.detach();\r\n }\r\n }\r\n}\r\n"]}
@@ -46,6 +46,10 @@ export declare class HolographicSlate extends ContentDisplay3D {
46
46
  private _contentViewport;
47
47
  private _contentDragBehavior;
48
48
  private _defaultBehavior;
49
+ /**
50
+ * If true, the content will be scaled to fit the dimensions of the slate
51
+ */
52
+ fitContentToDimensions: boolean;
49
53
  /**
50
54
  * Regroups all mesh behaviors for the slate
51
55
  */
@@ -103,6 +103,10 @@ export class HolographicSlate extends ContentDisplay3D {
103
103
  this._dimensions = new Vector2(21.875, 12.5);
104
104
  this._titleBarHeight = 0.625;
105
105
  this._titleText = "";
106
+ /**
107
+ * If true, the content will be scaled to fit the dimensions of the slate
108
+ */
109
+ this.fitContentToDimensions = false;
106
110
  this._contentScaleRatio = 1;
107
111
  /**
108
112
  * Minimum dimensions of the slate
@@ -184,14 +188,14 @@ export class HolographicSlate extends ContentDisplay3D {
184
188
  if (this._contentPlate?.material && this._contentPlate.material.albedoTexture) {
185
189
  const tex = this._contentPlate.material.albedoTexture;
186
190
  tex.uScale = this._contentScaleRatio;
187
- tex.vScale = (this._contentScaleRatio / this._contentViewport.width) * this._contentViewport.height;
191
+ tex.vScale = this.fitContentToDimensions ? this._contentScaleRatio : (this._contentScaleRatio / this._contentViewport.width) * this._contentViewport.height;
188
192
  tex.uOffset = this._contentViewport.x;
189
193
  tex.vOffset = this._contentViewport.y;
190
194
  }
191
195
  }
192
196
  _resetContentPositionAndZoom() {
193
197
  this._contentViewport.x = 0;
194
- this._contentViewport.y = 1 - this._contentViewport.height / this._contentViewport.width;
198
+ this._contentViewport.y = 0; // 1 - this._contentViewport.height / this._contentViewport.width;
195
199
  this._contentScaleRatio = 1;
196
200
  }
197
201
  /**
@@ -300,6 +304,9 @@ export class HolographicSlate extends ContentDisplay3D {
300
304
  });
301
305
  const offset = new Vector3();
302
306
  this._contentDragBehavior.onDragObservable.add((event) => {
307
+ if (this.fitContentToDimensions) {
308
+ return;
309
+ }
303
310
  offset.copyFrom(event.dragPlanePoint);
304
311
  offset.subtractInPlace(origin);
305
312
  projectedOffset.copyFromFloats(Vector3.Dot(offset, rightWorld), Vector3.Dot(offset, upWorld));
@@ -358,7 +365,10 @@ export class HolographicSlate extends ContentDisplay3D {
358
365
  this.origin.setAll(0);
359
366
  this._gizmo.updateBoundingBox();
360
367
  const pivot = this.node.getAbsolutePivotPoint();
361
- this.node.position.copyFrom(camera.position).subtractInPlace(backward).subtractInPlace(pivot);
368
+ // only if position was not yet set!
369
+ if (this.node.position.equalsToFloats(0, 0, 0)) {
370
+ this.node.position.copyFrom(camera.position).subtractInPlace(backward).subtractInPlace(pivot);
371
+ }
362
372
  this.node.rotationQuaternion = Quaternion.FromLookDirectionLH(backward, new Vector3(0, 1, 0));
363
373
  if (resetAspect) {
364
374
  this.dimensions = this.defaultDimensions;
@@ -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port { TouchHolographicButton } from \"./touchHolographicButton\";\r\nimport { AdvancedDynamicTexture } from \"../../2D/advancedDynamicTexture\";\r\nimport { Control } from \"../../2D/controls/control\";\r\nimport { TextBlock, TextWrapping } from \"../../2D/controls/textBlock\";\r\nimport { DefaultBehavior } from \"../behaviors/defaultBehavior\";\r\nimport { SlateGizmo } from \"../gizmos/slateGizmo\";\r\nimport { FluentMaterial } from \"../materials/fluent/fluentMaterial\";\r\nimport { FluentBackplateMaterial } from \"../materials/fluentBackplate/fluentBackplateMaterial\";\r\nimport { PointerDragBehavior } from \"core/Behaviors/Meshes/pointerDragBehavior\";\r\nimport type { Texture } from \"core/Materials/Textures/texture\";\r\nimport { Vector4 } from \"core/Maths/math\";\r\nimport { Epsilon } from \"core/Maths/math.constants\";\r\nimport { Scalar } from \"core/Maths/math.scalar\";\r\nimport type { Matrix } from \"core/Maths/math.vector\";\r\nimport { Quaternion, Vector2, Vector3 } from \"core/Maths/math.vector\";\r\nimport { Viewport } from \"core/Maths/math.viewport\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport { CreateBox } from \"core/Meshes/Builders/boxBuilder\";\r\nimport { CreatePlane } from \"core/Meshes/Builders/planeBuilder\";\r\nimport type { TransformNode } from \"core/Meshes/transformNode\";\r\nimport { Mesh } from \"core/Meshes/mesh\";\r\nimport { VertexData } from \"core/Meshes/mesh.vertexData\";\r\nimport type { Observer } from \"core/Misc/observable\";\r\nimport type { Scene } from \"core/scene\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\n/**\r\n * Class used to create a holographic slate\r\n * @since 5.0.0\r\n */\r\nexport class HolographicSlate extends ContentDisplay3D {\r\n /**\r\n * Base Url for the assets.\r\n */\r\n public static ASSETS_BASE_URL: string = \"https://assets.babylonjs.com/meshes/MRTK/\";\r\n /**\r\n * File name for the close icon.\r\n */\r\n public static CLOSE_ICON_FILENAME: string = \"IconClose.png\";\r\n /**\r\n * File name for the close icon.\r\n */\r\n public static FOLLOW_ICON_FILENAME: string = \"IconFollowMe.png\";\r\n\r\n private static _DEFAULT_TEXT_RESOLUTION_Y = 102.4;\r\n\r\n /**\r\n * Margin between title bar and contentplate\r\n */\r\n public titleBarMargin = 0.005;\r\n\r\n /**\r\n * Origin in local coordinates (top left corner)\r\n */\r\n public origin = new Vector3(0, 0, 0);\r\n\r\n private _dimensions = new Vector2(21.875, 12.5);\r\n private _titleBarHeight = 0.625;\r\n\r\n private _titleBarMaterial: FluentBackplateMaterial;\r\n private _backMaterial: FluentBackplateMaterial;\r\n private _contentMaterial: FluentMaterial;\r\n private _pickedPointObserver: Nullable<Observer<Nullable<Vector3>>>;\r\n private _positionChangedObserver: Nullable<Observer<{ position: Vector3 }>>;\r\n\r\n private _titleText = \"\";\r\n private _titleTextComponent: TextBlock;\r\n\r\n private _contentViewport: Viewport;\r\n private _contentDragBehavior: PointerDragBehavior;\r\n\r\n private _defaultBehavior: DefaultBehavior;\r\n /**\r\n * Regroups all mesh behaviors for the slate\r\n */\r\n public get defaultBehavior(): DefaultBehavior {\r\n return this._defaultBehavior;\r\n }\r\n\r\n /** @internal */\r\n public _gizmo: SlateGizmo;\r\n\r\n protected _titleBar: Mesh;\r\n protected _titleBarTitle: Mesh;\r\n protected _contentPlate: Mesh;\r\n protected _backPlate: Mesh;\r\n /** @internal */\r\n public _followButton: TouchHolographicButton;\r\n protected _closeButton: TouchHolographicButton;\r\n protected override _contentScaleRatio = 1;\r\n\r\n /**\r\n * 2D dimensions of the slate\r\n */\r\n public get dimensions() {\r\n return this._dimensions;\r\n }\r\n public set dimensions(value) {\r\n //clamp, respecting ratios\r\n let scale = 1.0;\r\n if (value.x < this.minDimensions.x || value.y < this.minDimensions.y) {\r\n const newRatio = value.x / value.y;\r\n const minRatio = this.minDimensions.x / this.minDimensions.y;\r\n if (minRatio > newRatio) {\r\n // We just need to make sure the x-val is greater than the min\r\n scale = this.minDimensions.x / value.x;\r\n } else {\r\n // We just need to make sure the y-val is greater than the min\r\n scale = this.minDimensions.y / value.y;\r\n }\r\n }\r\n\r\n this._dimensions.copyFrom(value).scaleInPlace(scale);\r\n this._updatePivot();\r\n this._positionElements();\r\n }\r\n\r\n /**\r\n * Minimum dimensions of the slate\r\n */\r\n public minDimensions = new Vector2(15.625, 6.25);\r\n\r\n /**\r\n * Default dimensions of the slate\r\n */\r\n public readonly defaultDimensions = this._dimensions.clone();\r\n\r\n /**\r\n * Height of the title bar component\r\n */\r\n public get titleBarHeight() {\r\n return this._titleBarHeight;\r\n }\r\n public set titleBarHeight(value) {\r\n this._titleBarHeight = value;\r\n }\r\n\r\n /**\r\n * Rendering ground id of all the meshes\r\n */\r\n public set renderingGroupId(id: number) {\r\n this._titleBar.renderingGroupId = id;\r\n this._titleBarTitle.renderingGroupId = id;\r\n this._contentPlate.renderingGroupId = id;\r\n this._backPlate.renderingGroupId = id;\r\n }\r\n public get renderingGroupId(): number {\r\n return this._titleBar.renderingGroupId;\r\n }\r\n\r\n /**\r\n * The title text displayed at the top of the slate\r\n */\r\n public set title(title: string) {\r\n this._titleText = title;\r\n if (this._titleTextComponent) {\r\n this._titleTextComponent.text = title;\r\n }\r\n }\r\n public get title() {\r\n return this._titleText;\r\n }\r\n\r\n /**\r\n * Creates a new slate\r\n * @param name defines the control name\r\n */\r\n constructor(name?: string) {\r\n super(name);\r\n\r\n this._followButton = new TouchHolographicButton(\"followButton\" + this.name);\r\n this._followButton.isToggleButton = true;\r\n this._closeButton = new TouchHolographicButton(\"closeButton\" + this.name);\r\n\r\n this._contentViewport = new Viewport(0, 0, 1, 1);\r\n this._contentDragBehavior = new PointerDragBehavior({\r\n dragPlaneNormal: new Vector3(0, 0, -1),\r\n });\r\n }\r\n\r\n /**\r\n * Apply the facade texture (created from the content property).\r\n * This function can be overloaded by child classes\r\n * @param facadeTexture defines the AdvancedDynamicTexture to use\r\n */\r\n protected override _applyFacade(facadeTexture: AdvancedDynamicTexture) {\r\n this._contentMaterial.albedoTexture = facadeTexture;\r\n this._resetContentPositionAndZoom();\r\n this._applyContentViewport();\r\n\r\n facadeTexture.attachToMesh(this._contentPlate, true);\r\n }\r\n\r\n private _addControl(control: Control3D): void {\r\n control._host = this._host;\r\n if (this._host.utilityLayer) {\r\n control._prepareNode(this._host.utilityLayer.utilityLayerScene);\r\n }\r\n }\r\n\r\n protected override _getTypeName(): string {\r\n return \"HolographicSlate\";\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _positionElements() {\r\n const followButton = this._followButton;\r\n const closeButton = this._closeButton;\r\n const titleBar = this._titleBar;\r\n const titleBarTitle = this._titleBarTitle;\r\n const contentPlate = this._contentPlate;\r\n const backPlate = this._backPlate;\r\n\r\n if (followButton && closeButton && titleBar) {\r\n closeButton.scaling.setAll(this.titleBarHeight);\r\n followButton.scaling.setAll(this.titleBarHeight);\r\n closeButton.position.copyFromFloats(this.dimensions.x - this.titleBarHeight / 2, -this.titleBarHeight / 2, 0).addInPlace(this.origin);\r\n followButton.position.copyFromFloats(this.dimensions.x - (3 * this.titleBarHeight) / 2, -this.titleBarHeight / 2, 0).addInPlace(this.origin);\r\n\r\n const contentPlateHeight = this.dimensions.y - this.titleBarHeight - this.titleBarMargin;\r\n const rightHandScene = contentPlate.getScene().useRightHandedSystem;\r\n\r\n titleBar.scaling.set(this.dimensions.x, this.titleBarHeight, Epsilon);\r\n titleBarTitle.scaling.set(this.dimensions.x - 2 * this.titleBarHeight, this.titleBarHeight, Epsilon);\r\n contentPlate.scaling.copyFromFloats(this.dimensions.x, contentPlateHeight, Epsilon);\r\n backPlate.scaling.copyFromFloats(this.dimensions.x, contentPlateHeight, Epsilon);\r\n\r\n titleBar.position.copyFromFloats(this.dimensions.x / 2, -(this.titleBarHeight / 2), 0).addInPlace(this.origin);\r\n titleBarTitle.position\r\n .copyFromFloats(this.dimensions.x / 2 - this.titleBarHeight, -(this.titleBarHeight / 2), rightHandScene ? Epsilon : -Epsilon)\r\n .addInPlace(this.origin);\r\n contentPlate.position.copyFromFloats(this.dimensions.x / 2, -(this.titleBarHeight + this.titleBarMargin + contentPlateHeight / 2), 0).addInPlace(this.origin);\r\n backPlate.position\r\n .copyFromFloats(this.dimensions.x / 2, -(this.titleBarHeight + this.titleBarMargin + contentPlateHeight / 2), rightHandScene ? -Epsilon : Epsilon)\r\n .addInPlace(this.origin);\r\n\r\n // Update the title's AdvancedDynamicTexture scale to avoid visual stretching\r\n this._titleTextComponent.host.scaleTo(\r\n (HolographicSlate._DEFAULT_TEXT_RESOLUTION_Y * titleBarTitle.scaling.x) / titleBarTitle.scaling.y,\r\n HolographicSlate._DEFAULT_TEXT_RESOLUTION_Y\r\n );\r\n\r\n const aspectRatio = this.dimensions.x / contentPlateHeight;\r\n this._contentViewport.width = this._contentScaleRatio;\r\n this._contentViewport.height = this._contentScaleRatio / aspectRatio;\r\n\r\n this._applyContentViewport();\r\n if (this._gizmo) {\r\n this._gizmo.updateBoundingBox();\r\n }\r\n }\r\n }\r\n\r\n private _applyContentViewport() {\r\n if (this._contentPlate?.material && (this._contentPlate.material as FluentMaterial).albedoTexture) {\r\n const tex = (this._contentPlate.material as FluentMaterial).albedoTexture as Texture;\r\n tex.uScale = this._contentScaleRatio;\r\n tex.vScale = (this._contentScaleRatio / this._contentViewport.width) * this._contentViewport.height;\r\n tex.uOffset = this._contentViewport.x;\r\n tex.vOffset = this._contentViewport.y;\r\n }\r\n }\r\n\r\n private _resetContentPositionAndZoom() {\r\n this._contentViewport.x = 0;\r\n this._contentViewport.y = 1 - this._contentViewport.height / this._contentViewport.width;\r\n this._contentScaleRatio = 1;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _updatePivot() {\r\n if (!this.mesh) {\r\n return;\r\n }\r\n\r\n // Update pivot point so it is at the center of geometry\r\n // As origin is topleft corner in 2D, dimensions are calculated towards bottom right corner, thus y axis is downwards\r\n const center = new Vector3(this.dimensions.x * 0.5, -this.dimensions.y * 0.5, Epsilon);\r\n center.addInPlace(this.origin);\r\n center.z = 0;\r\n\r\n const origin = new Vector3(0, 0, 0);\r\n Vector3.TransformCoordinatesToRef(origin, this.mesh.computeWorldMatrix(true), origin);\r\n this.mesh.setPivotPoint(center);\r\n const origin2 = new Vector3(0, 0, 0);\r\n Vector3.TransformCoordinatesToRef(origin2, this.mesh.computeWorldMatrix(true), origin2);\r\n this.mesh.position.addInPlace(origin).subtractInPlace(origin2);\r\n }\r\n\r\n // Mesh association\r\n protected override _createNode(scene: Scene): TransformNode {\r\n const node = new Mesh(\"slate_\" + this.name, scene);\r\n\r\n this._titleBar = CreateBox(\"titleBar_\" + this.name, { size: 1 }, scene);\r\n this._titleBarTitle = CreatePlane(\"titleText_\" + this.name, { size: 1 }, scene);\r\n this._titleBarTitle.parent = node;\r\n this._titleBarTitle.isPickable = false;\r\n\r\n const adt = AdvancedDynamicTexture.CreateForMesh(this._titleBarTitle);\r\n this._titleTextComponent = new TextBlock(\"titleText_\" + this.name, this._titleText);\r\n this._titleTextComponent.textWrapping = TextWrapping.Ellipsis;\r\n this._titleTextComponent.textHorizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;\r\n this._titleTextComponent.color = \"white\";\r\n this._titleTextComponent.fontSize = HolographicSlate._DEFAULT_TEXT_RESOLUTION_Y / 2;\r\n this._titleTextComponent.paddingLeft = HolographicSlate._DEFAULT_TEXT_RESOLUTION_Y / 4;\r\n adt.addControl(this._titleTextComponent);\r\n\r\n if (scene.useRightHandedSystem) {\r\n const faceUV = new Vector4(0, 0, 1, 1);\r\n this._contentPlate = CreatePlane(\"contentPlate_\" + this.name, { size: 1, sideOrientation: VertexData.BACKSIDE, frontUVs: faceUV }, scene);\r\n this._backPlate = CreatePlane(\"backPlate_\" + this.name, { size: 1, sideOrientation: VertexData.FRONTSIDE }, scene);\r\n } else {\r\n const faceUV = new Vector4(0, 0, 1, 1);\r\n this._contentPlate = CreatePlane(\"contentPlate_\" + this.name, { size: 1, sideOrientation: VertexData.FRONTSIDE, frontUVs: faceUV }, scene);\r\n this._backPlate = CreatePlane(\"backPlate_\" + this.name, { size: 1, sideOrientation: VertexData.BACKSIDE }, scene);\r\n }\r\n\r\n this._titleBar.parent = node;\r\n this._titleBar.isNearGrabbable = true;\r\n this._contentPlate.parent = node;\r\n this._backPlate.parent = node;\r\n this._attachContentPlateBehavior();\r\n\r\n this._addControl(this._followButton);\r\n this._addControl(this._closeButton);\r\n\r\n const followButton = this._followButton;\r\n const closeButton = this._closeButton;\r\n\r\n followButton.node!.parent = node;\r\n closeButton.node!.parent = node;\r\n\r\n this._positionElements();\r\n\r\n this._followButton.imageUrl = HolographicSlate.ASSETS_BASE_URL + HolographicSlate.FOLLOW_ICON_FILENAME;\r\n this._closeButton.imageUrl = HolographicSlate.ASSETS_BASE_URL + HolographicSlate.CLOSE_ICON_FILENAME;\r\n\r\n this._followButton.isBackplateVisible = false;\r\n this._closeButton.isBackplateVisible = false;\r\n\r\n this._followButton.onToggleObservable.add((isToggled) => {\r\n this._defaultBehavior.followBehaviorEnabled = isToggled;\r\n if (this._defaultBehavior.followBehaviorEnabled) {\r\n this._defaultBehavior.followBehavior.recenter();\r\n }\r\n });\r\n\r\n this._closeButton.onPointerClickObservable.add(() => {\r\n this.dispose();\r\n });\r\n\r\n node.rotationQuaternion = Quaternion.Identity();\r\n node.isVisible = false;\r\n\r\n return node;\r\n }\r\n\r\n private _attachContentPlateBehavior() {\r\n this._contentDragBehavior.attach(this._contentPlate);\r\n this._contentDragBehavior.moveAttached = false;\r\n this._contentDragBehavior.useObjectOrientationForDragging = true;\r\n this._contentDragBehavior.updateDragPlane = false;\r\n\r\n const origin = new Vector3();\r\n const worldDimensions = new Vector3();\r\n const upWorld = new Vector3();\r\n const rightWorld = new Vector3();\r\n const projectedOffset = new Vector2();\r\n let startViewport: Viewport;\r\n let worldMatrix: Matrix;\r\n\r\n this._contentDragBehavior.onDragStartObservable.add((event) => {\r\n if (!this.node) {\r\n return;\r\n }\r\n startViewport = this._contentViewport.clone();\r\n worldMatrix = this.node.computeWorldMatrix(true);\r\n\r\n origin.copyFrom(event.dragPlanePoint);\r\n worldDimensions.set(this.dimensions.x, this.dimensions.y, Epsilon);\r\n worldDimensions.y -= this.titleBarHeight + this.titleBarMargin;\r\n Vector3.TransformNormalToRef(worldDimensions, worldMatrix, worldDimensions);\r\n upWorld.copyFromFloats(0, 1, 0);\r\n Vector3.TransformNormalToRef(upWorld, worldMatrix, upWorld);\r\n rightWorld.copyFromFloats(1, 0, 0);\r\n Vector3.TransformNormalToRef(rightWorld, worldMatrix, rightWorld);\r\n upWorld.normalize();\r\n upWorld.scaleInPlace(1 / Vector3.Dot(upWorld, worldDimensions));\r\n rightWorld.normalize();\r\n rightWorld.scaleInPlace(1 / Vector3.Dot(rightWorld, worldDimensions));\r\n });\r\n\r\n const offset = new Vector3();\r\n this._contentDragBehavior.onDragObservable.add((event) => {\r\n offset.copyFrom(event.dragPlanePoint);\r\n offset.subtractInPlace(origin);\r\n projectedOffset.copyFromFloats(Vector3.Dot(offset, rightWorld), Vector3.Dot(offset, upWorld));\r\n\r\n // By default, content takes full width available and height is cropped to keep aspect ratio\r\n this._contentViewport.x = Scalar.Clamp(startViewport.x - offset.x, 0, 1 - this._contentViewport.width * this._contentScaleRatio);\r\n this._contentViewport.y = Scalar.Clamp(startViewport.y - offset.y, 0, 1 - this._contentViewport.height * this._contentScaleRatio);\r\n this._applyContentViewport();\r\n });\r\n }\r\n\r\n protected override _affectMaterial(mesh: AbstractMesh) {\r\n // TODO share materials\r\n this._titleBarMaterial = new FluentBackplateMaterial(`${this.name} plateMaterial`, mesh.getScene());\r\n\r\n this._contentMaterial = new FluentMaterial(`${this.name} contentMaterial`, mesh.getScene());\r\n this._contentMaterial.renderBorders = true;\r\n\r\n this._backMaterial = new FluentBackplateMaterial(`${this.name} backPlate`, mesh.getScene());\r\n this._backMaterial.lineWidth = Epsilon;\r\n this._backMaterial.radius = 0.005;\r\n this._backMaterial.backFaceCulling = true;\r\n\r\n this._titleBar.material = this._titleBarMaterial;\r\n this._contentPlate.material = this._contentMaterial;\r\n this._backPlate.material = this._backMaterial;\r\n\r\n this._resetContent();\r\n this._applyContentViewport();\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override _prepareNode(scene: Scene): void {\r\n super._prepareNode(scene);\r\n this._gizmo = new SlateGizmo(this._host.utilityLayer!);\r\n this._gizmo.attachedSlate = this;\r\n this._defaultBehavior = new DefaultBehavior();\r\n this._defaultBehavior.attach(this.node as Mesh, [this._titleBar]);\r\n this._defaultBehavior.sixDofDragBehavior.onDragStartObservable.add(() => {\r\n this._followButton.isToggled = false;\r\n });\r\n\r\n this._positionChangedObserver = this._defaultBehavior.sixDofDragBehavior.onPositionChangedObservable.add(() => {\r\n this._gizmo.updateBoundingBox();\r\n });\r\n\r\n this._updatePivot();\r\n this.resetDefaultAspectAndPose(false);\r\n }\r\n\r\n /**\r\n * Resets the aspect and pose of the slate so it is right in front of the active camera, facing towards it.\r\n * @param resetAspect Should the slate's dimensions/aspect ratio be reset as well\r\n */\r\n public resetDefaultAspectAndPose(resetAspect: boolean = true) {\r\n if (!this._host || !this._host.utilityLayer || !this.node) {\r\n return;\r\n }\r\n const scene = this._host.utilityLayer.utilityLayerScene;\r\n const camera = scene.activeCamera;\r\n if (camera) {\r\n const worldMatrix = camera.getWorldMatrix();\r\n const backward = Vector3.TransformNormal(Vector3.Backward(scene.useRightHandedSystem), worldMatrix);\r\n this.origin.setAll(0);\r\n this._gizmo.updateBoundingBox();\r\n const pivot = this.node.getAbsolutePivotPoint();\r\n this.node.position.copyFrom(camera.position).subtractInPlace(backward).subtractInPlace(pivot);\r\n this.node.rotationQuaternion = Quaternion.FromLookDirectionLH(backward, new Vector3(0, 1, 0));\r\n\r\n if (resetAspect) {\r\n this.dimensions = this.defaultDimensions;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Releases all associated resources\r\n */\r\n public override dispose() {\r\n super.dispose();\r\n this._titleBarMaterial.dispose();\r\n this._contentMaterial.dispose();\r\n\r\n this._titleBar.dispose();\r\n this._titleBarTitle.dispose();\r\n this._contentPlate.dispose();\r\n this._backPlate.dispose();\r\n\r\n this._followButton.dispose();\r\n this._closeButton.dispose();\r\n\r\n this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);\r\n this._defaultBehavior.sixDofDragBehavior.onPositionChangedObservable.remove(this._positionChangedObserver);\r\n\r\n this._defaultBehavior.detach();\r\n this._gizmo.dispose();\r\n this._contentDragBehavior.detach();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"holographicSlate.js","sourceRoot":"","sources":["../../../../../dev/gui/src/3D/controls/holographicSlate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,SAAS,EAAgB,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,sDAAsD,CAAC;AAC/F,OAAO,EAAE,mBAAmB,EAAE,gEAAkD;AAEhF,OAAO,EAAE,OAAO,EAAE,sCAAwB;AAC1C,OAAO,EAAE,OAAO,EAAE,gDAAkC;AACpD,OAAO,EAAE,MAAM,EAAE,6CAA+B;AAEhD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,6CAA+B;AACtE,OAAO,EAAE,QAAQ,EAAE,+CAAiC;AAEpD,OAAO,EAAE,SAAS,EAAE,sDAAwC;AAC5D,OAAO,EAAE,WAAW,EAAE,wDAA0C;AAEhE,OAAO,EAAE,IAAI,EAAE,uCAAyB;AACxC,OAAO,EAAE,UAAU,E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BAA2B,CAAC,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;QAE3G,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC;QAC/B,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtB,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,CAAC;IACvC,CAAC;;AA7dD;;GAEG;AACW,gCAAe,GAAW,2CAA2C,AAAtD,CAAuD;AACpF;;GAEG;AACW,oCAAmB,GAAW,eAAe,AAA1B,CAA2B;AAC5D;;GAEG;AACW,qCAAoB,GAAW,kBAAkB,AAA7B,CAA8B;AAEjD,2CAA0B,GAAG,KAAK,AAAR,CAAS","sourcesContent":["import { ContentDisplay3D } from \"./contentDisplay3D\";\r\nimport type { Control3D } from \"./control3D\";\r\nimport { TouchHolographicButton } from \"./touchHolographicButton\";\r\nimport { AdvancedDynamicTexture } from \"../../2D/advancedDynamicTexture\";\r\nimport { Control } from \"../../2D/controls/control\";\r\nimport { TextBlock, TextWrapping } from \"../../2D/controls/textBlock\";\r\nimport { DefaultBehavior } from \"../behaviors/defaultBehavior\";\r\nimport { SlateGizmo } from \"../gizmos/slateGizmo\";\r\nimport { FluentMaterial } from \"../materials/fluent/fluentMaterial\";\r\nimport { FluentBackplateMaterial } from \"../materials/fluentBackplate/fluentBackplateMaterial\";\r\nimport { PointerDragBehavior } from \"core/Behaviors/Meshes/pointerDragBehavior\";\r\nimport type { Texture } from \"core/Materials/Textures/texture\";\r\nimport { Vector4 } from \"core/Maths/math\";\r\nimport { Epsilon } from \"core/Maths/math.constants\";\r\nimport { Scalar } from \"core/Maths/math.scalar\";\r\nimport type { Matrix } from \"core/Maths/math.vector\";\r\nimport { Quaternion, Vector2, Vector3 } from \"core/Maths/math.vector\";\r\nimport { Viewport } from \"core/Maths/math.viewport\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport { CreateBox } from \"core/Meshes/Builders/boxBuilder\";\r\nimport { CreatePlane } from \"core/Meshes/Builders/planeBuilder\";\r\nimport type { TransformNode } from \"core/Meshes/transformNode\";\r\nimport { Mesh } from \"core/Meshes/mesh\";\r\nimport { VertexData } from \"core/Meshes/mesh.vertexData\";\r\nimport type { Observer } from \"core/Misc/observable\";\r\nimport type { Scene } from \"core/scene\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\n/**\r\n * Class used to create a holographic slate\r\n * @since 5.0.0\r\n */\r\nexport class HolographicSlate extends ContentDisplay3D {\r\n /**\r\n * Base Url for the assets.\r\n */\r\n public static ASSETS_BASE_URL: string = \"https://assets.babylonjs.com/meshes/MRTK/\";\r\n /**\r\n * File name for the close icon.\r\n */\r\n public static CLOSE_ICON_FILENAME: string = \"IconClose.png\";\r\n /**\r\n * File name for the close icon.\r\n */\r\n public static FOLLOW_ICON_FILENAME: string = \"IconFollowMe.png\";\r\n\r\n private static _DEFAULT_TEXT_RESOLUTION_Y = 102.4;\r\n\r\n /**\r\n * Margin between title bar and contentplate\r\n */\r\n public titleBarMargin = 0.005;\r\n\r\n /**\r\n * Origin in local coordinates (top left corner)\r\n */\r\n public origin = new Vector3(0, 0, 0);\r\n\r\n private _dimensions = new Vector2(21.875, 12.5);\r\n private _titleBarHeight = 0.625;\r\n\r\n private _titleBarMaterial: FluentBackplateMaterial;\r\n private _backMaterial: FluentBackplateMaterial;\r\n private _contentMaterial: FluentMaterial;\r\n private _pickedPointObserver: Nullable<Observer<Nullable<Vector3>>>;\r\n private _positionChangedObserver: Nullable<Observer<{ position: Vector3 }>>;\r\n\r\n private _titleText = \"\";\r\n private _titleTextComponent: TextBlock;\r\n\r\n private _contentViewport: Viewport;\r\n private _contentDragBehavior: PointerDragBehavior;\r\n\r\n private _defaultBehavior: DefaultBehavior;\r\n\r\n /**\r\n * If true, the content will be scaled to fit the dimensions of the slate\r\n */\r\n public fitContentToDimensions = false;\r\n /**\r\n * Regroups all mesh behaviors for the slate\r\n */\r\n public get defaultBehavior(): DefaultBehavior {\r\n return this._defaultBehavior;\r\n }\r\n\r\n /** @internal */\r\n public _gizmo: SlateGizmo;\r\n\r\n protected _titleBar: Mesh;\r\n protected _titleBarTitle: Mesh;\r\n protected _contentPlate: Mesh;\r\n protected _backPlate: Mesh;\r\n /** @internal */\r\n public _followButton: TouchHolographicButton;\r\n protected _closeButton: TouchHolographicButton;\r\n protected override _contentScaleRatio = 1;\r\n\r\n /**\r\n * 2D dimensions of the slate\r\n */\r\n public get dimensions() {\r\n return this._dimensions;\r\n }\r\n public set dimensions(value) {\r\n //clamp, respecting ratios\r\n let scale = 1.0;\r\n if (value.x < this.minDimensions.x || value.y < this.minDimensions.y) {\r\n const newRatio = value.x / value.y;\r\n const minRatio = this.minDimensions.x / this.minDimensions.y;\r\n if (minRatio > newRatio) {\r\n // We just need to make sure the x-val is greater than the min\r\n scale = this.minDimensions.x / value.x;\r\n } else {\r\n // We just need to make sure the y-val is greater than the min\r\n scale = this.minDimensions.y / value.y;\r\n }\r\n }\r\n\r\n this._dimensions.copyFrom(value).scaleInPlace(scale);\r\n this._updatePivot();\r\n this._positionElements();\r\n }\r\n\r\n /**\r\n * Minimum dimensions of the slate\r\n */\r\n public minDimensions = new Vector2(15.625, 6.25);\r\n\r\n /**\r\n * Default dimensions of the slate\r\n */\r\n public readonly defaultDimensions = this._dimensions.clone();\r\n\r\n /**\r\n * Height of the title bar component\r\n */\r\n public get titleBarHeight() {\r\n return this._titleBarHeight;\r\n }\r\n public set titleBarHeight(value) {\r\n this._titleBarHeight = value;\r\n }\r\n\r\n /**\r\n * Rendering ground id of all the meshes\r\n */\r\n public set renderingGroupId(id: number) {\r\n this._titleBar.renderingGroupId = id;\r\n this._titleBarTitle.renderingGroupId = id;\r\n this._contentPlate.renderingGroupId = id;\r\n this._backPlate.renderingGroupId = id;\r\n }\r\n public get renderingGroupId(): number {\r\n return this._titleBar.renderingGroupId;\r\n }\r\n\r\n /**\r\n * The title text displayed at the top of the slate\r\n */\r\n public set title(title: string) {\r\n this._titleText = title;\r\n if (this._titleTextComponent) {\r\n this._titleTextComponent.text = title;\r\n }\r\n }\r\n public get title() {\r\n return this._titleText;\r\n }\r\n\r\n /**\r\n * Creates a new slate\r\n * @param name defines the control name\r\n */\r\n constructor(name?: string) {\r\n super(name);\r\n\r\n this._followButton = new TouchHolographicButton(\"followButton\" + this.name);\r\n this._followButton.isToggleButton = true;\r\n this._closeButton = new TouchHolographicButton(\"closeButton\" + this.name);\r\n\r\n this._contentViewport = new Viewport(0, 0, 1, 1);\r\n this._contentDragBehavior = new PointerDragBehavior({\r\n dragPlaneNormal: new Vector3(0, 0, -1),\r\n });\r\n }\r\n\r\n /**\r\n * Apply the facade texture (created from the content property).\r\n * This function can be overloaded by child classes\r\n * @param facadeTexture defines the AdvancedDynamicTexture to use\r\n */\r\n protected override _applyFacade(facadeTexture: AdvancedDynamicTexture) {\r\n this._contentMaterial.albedoTexture = facadeTexture;\r\n this._resetContentPositionAndZoom();\r\n this._applyContentViewport();\r\n\r\n facadeTexture.attachToMesh(this._contentPlate, true);\r\n }\r\n\r\n private _addControl(control: Control3D): void {\r\n control._host = this._host;\r\n if (this._host.utilityLayer) {\r\n control._prepareNode(this._host.utilityLayer.utilityLayerScene);\r\n }\r\n }\r\n\r\n protected override _getTypeName(): string {\r\n return \"HolographicSlate\";\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _positionElements() {\r\n const followButton = this._followButton;\r\n const closeButton = this._closeButton;\r\n const titleBar = this._titleBar;\r\n const titleBarTitle = this._titleBarTitle;\r\n const contentPlate = this._contentPlate;\r\n const backPlate = this._backPlate;\r\n\r\n if (followButton && closeButton && titleBar) {\r\n closeButton.scaling.setAll(this.titleBarHeight);\r\n followButton.scaling.setAll(this.titleBarHeight);\r\n closeButton.position.copyFromFloats(this.dimensions.x - this.titleBarHeight / 2, -this.titleBarHeight / 2, 0).addInPlace(this.origin);\r\n followButton.position.copyFromFloats(this.dimensions.x - (3 * this.titleBarHeight) / 2, -this.titleBarHeight / 2, 0).addInPlace(this.origin);\r\n\r\n const contentPlateHeight = this.dimensions.y - this.titleBarHeight - this.titleBarMargin;\r\n const rightHandScene = contentPlate.getScene().useRightHandedSystem;\r\n\r\n titleBar.scaling.set(this.dimensions.x, this.titleBarHeight, Epsilon);\r\n titleBarTitle.scaling.set(this.dimensions.x - 2 * this.titleBarHeight, this.titleBarHeight, Epsilon);\r\n contentPlate.scaling.copyFromFloats(this.dimensions.x, contentPlateHeight, Epsilon);\r\n backPlate.scaling.copyFromFloats(this.dimensions.x, contentPlateHeight, Epsilon);\r\n\r\n titleBar.position.copyFromFloats(this.dimensions.x / 2, -(this.titleBarHeight / 2), 0).addInPlace(this.origin);\r\n titleBarTitle.position\r\n .copyFromFloats(this.dimensions.x / 2 - this.titleBarHeight, -(this.titleBarHeight / 2), rightHandScene ? Epsilon : -Epsilon)\r\n .addInPlace(this.origin);\r\n contentPlate.position.copyFromFloats(this.dimensions.x / 2, -(this.titleBarHeight + this.titleBarMargin + contentPlateHeight / 2), 0).addInPlace(this.origin);\r\n backPlate.position\r\n .copyFromFloats(this.dimensions.x / 2, -(this.titleBarHeight + this.titleBarMargin + contentPlateHeight / 2), rightHandScene ? -Epsilon : Epsilon)\r\n .addInPlace(this.origin);\r\n\r\n // Update the title's AdvancedDynamicTexture scale to avoid visual stretching\r\n this._titleTextComponent.host.scaleTo(\r\n (HolographicSlate._DEFAULT_TEXT_RESOLUTION_Y * titleBarTitle.scaling.x) / titleBarTitle.scaling.y,\r\n HolographicSlate._DEFAULT_TEXT_RESOLUTION_Y\r\n );\r\n\r\n const aspectRatio = this.dimensions.x / contentPlateHeight;\r\n this._contentViewport.width = this._contentScaleRatio;\r\n this._contentViewport.height = this._contentScaleRatio / aspectRatio;\r\n\r\n this._applyContentViewport();\r\n if (this._gizmo) {\r\n this._gizmo.updateBoundingBox();\r\n }\r\n }\r\n }\r\n\r\n private _applyContentViewport() {\r\n if (this._contentPlate?.material && (this._contentPlate.material as FluentMaterial).albedoTexture) {\r\n const tex = (this._contentPlate.material as FluentMaterial).albedoTexture as Texture;\r\n tex.uScale = this._contentScaleRatio;\r\n tex.vScale = this.fitContentToDimensions ? this._contentScaleRatio : (this._contentScaleRatio / this._contentViewport.width) * this._contentViewport.height;\r\n tex.uOffset = this._contentViewport.x;\r\n tex.vOffset = this._contentViewport.y;\r\n }\r\n }\r\n\r\n private _resetContentPositionAndZoom() {\r\n this._contentViewport.x = 0;\r\n this._contentViewport.y = 0; // 1 - this._contentViewport.height / this._contentViewport.width;\r\n this._contentScaleRatio = 1;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _updatePivot() {\r\n if (!this.mesh) {\r\n return;\r\n }\r\n\r\n // Update pivot point so it is at the center of geometry\r\n // As origin is topleft corner in 2D, dimensions are calculated towards bottom right corner, thus y axis is downwards\r\n const center = new Vector3(this.dimensions.x * 0.5, -this.dimensions.y * 0.5, Epsilon);\r\n center.addInPlace(this.origin);\r\n center.z = 0;\r\n\r\n const origin = new Vector3(0, 0, 0);\r\n Vector3.TransformCoordinatesToRef(origin, this.mesh.computeWorldMatrix(true), origin);\r\n this.mesh.setPivotPoint(center);\r\n const origin2 = new Vector3(0, 0, 0);\r\n Vector3.TransformCoordinatesToRef(origin2, this.mesh.computeWorldMatrix(true), origin2);\r\n this.mesh.position.addInPlace(origin).subtractInPlace(origin2);\r\n }\r\n\r\n // Mesh association\r\n protected override _createNode(scene: Scene): TransformNode {\r\n const node = new Mesh(\"slate_\" + this.name, scene);\r\n\r\n this._titleBar = CreateBox(\"titleBar_\" + this.name, { size: 1 }, scene);\r\n this._titleBarTitle = CreatePlane(\"titleText_\" + this.name, { size: 1 }, scene);\r\n this._titleBarTitle.parent = node;\r\n this._titleBarTitle.isPickable = false;\r\n\r\n const adt = AdvancedDynamicTexture.CreateForMesh(this._titleBarTitle);\r\n this._titleTextComponent = new TextBlock(\"titleText_\" + this.name, this._titleText);\r\n this._titleTextComponent.textWrapping = TextWrapping.Ellipsis;\r\n this._titleTextComponent.textHorizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;\r\n this._titleTextComponent.color = \"white\";\r\n this._titleTextComponent.fontSize = HolographicSlate._DEFAULT_TEXT_RESOLUTION_Y / 2;\r\n this._titleTextComponent.paddingLeft = HolographicSlate._DEFAULT_TEXT_RESOLUTION_Y / 4;\r\n adt.addControl(this._titleTextComponent);\r\n\r\n if (scene.useRightHandedSystem) {\r\n const faceUV = new Vector4(0, 0, 1, 1);\r\n this._contentPlate = CreatePlane(\"contentPlate_\" + this.name, { size: 1, sideOrientation: VertexData.BACKSIDE, frontUVs: faceUV }, scene);\r\n this._backPlate = CreatePlane(\"backPlate_\" + this.name, { size: 1, sideOrientation: VertexData.FRONTSIDE }, scene);\r\n } else {\r\n const faceUV = new Vector4(0, 0, 1, 1);\r\n this._contentPlate = CreatePlane(\"contentPlate_\" + this.name, { size: 1, sideOrientation: VertexData.FRONTSIDE, frontUVs: faceUV }, scene);\r\n this._backPlate = CreatePlane(\"backPlate_\" + this.name, { size: 1, sideOrientation: VertexData.BACKSIDE }, scene);\r\n }\r\n\r\n this._titleBar.parent = node;\r\n this._titleBar.isNearGrabbable = true;\r\n this._contentPlate.parent = node;\r\n this._backPlate.parent = node;\r\n this._attachContentPlateBehavior();\r\n\r\n this._addControl(this._followButton);\r\n this._addControl(this._closeButton);\r\n\r\n const followButton = this._followButton;\r\n const closeButton = this._closeButton;\r\n\r\n followButton.node!.parent = node;\r\n closeButton.node!.parent = node;\r\n\r\n this._positionElements();\r\n\r\n this._followButton.imageUrl = HolographicSlate.ASSETS_BASE_URL + HolographicSlate.FOLLOW_ICON_FILENAME;\r\n this._closeButton.imageUrl = HolographicSlate.ASSETS_BASE_URL + HolographicSlate.CLOSE_ICON_FILENAME;\r\n\r\n this._followButton.isBackplateVisible = false;\r\n this._closeButton.isBackplateVisible = false;\r\n\r\n this._followButton.onToggleObservable.add((isToggled) => {\r\n this._defaultBehavior.followBehaviorEnabled = isToggled;\r\n if (this._defaultBehavior.followBehaviorEnabled) {\r\n this._defaultBehavior.followBehavior.recenter();\r\n }\r\n });\r\n\r\n this._closeButton.onPointerClickObservable.add(() => {\r\n this.dispose();\r\n });\r\n\r\n node.rotationQuaternion = Quaternion.Identity();\r\n node.isVisible = false;\r\n\r\n return node;\r\n }\r\n\r\n private _attachContentPlateBehavior() {\r\n this._contentDragBehavior.attach(this._contentPlate);\r\n this._contentDragBehavior.moveAttached = false;\r\n this._contentDragBehavior.useObjectOrientationForDragging = true;\r\n this._contentDragBehavior.updateDragPlane = false;\r\n\r\n const origin = new Vector3();\r\n const worldDimensions = new Vector3();\r\n const upWorld = new Vector3();\r\n const rightWorld = new Vector3();\r\n const projectedOffset = new Vector2();\r\n let startViewport: Viewport;\r\n let worldMatrix: Matrix;\r\n\r\n this._contentDragBehavior.onDragStartObservable.add((event) => {\r\n if (!this.node) {\r\n return;\r\n }\r\n startViewport = this._contentViewport.clone();\r\n worldMatrix = this.node.computeWorldMatrix(true);\r\n\r\n origin.copyFrom(event.dragPlanePoint);\r\n worldDimensions.set(this.dimensions.x, this.dimensions.y, Epsilon);\r\n worldDimensions.y -= this.titleBarHeight + this.titleBarMargin;\r\n Vector3.TransformNormalToRef(worldDimensions, worldMatrix, worldDimensions);\r\n upWorld.copyFromFloats(0, 1, 0);\r\n Vector3.TransformNormalToRef(upWorld, worldMatrix, upWorld);\r\n rightWorld.copyFromFloats(1, 0, 0);\r\n Vector3.TransformNormalToRef(rightWorld, worldMatrix, rightWorld);\r\n upWorld.normalize();\r\n upWorld.scaleInPlace(1 / Vector3.Dot(upWorld, worldDimensions));\r\n rightWorld.normalize();\r\n rightWorld.scaleInPlace(1 / Vector3.Dot(rightWorld, worldDimensions));\r\n });\r\n\r\n const offset = new Vector3();\r\n this._contentDragBehavior.onDragObservable.add((event) => {\r\n if (this.fitContentToDimensions) {\r\n return;\r\n }\r\n offset.copyFrom(event.dragPlanePoint);\r\n offset.subtractInPlace(origin);\r\n projectedOffset.copyFromFloats(Vector3.Dot(offset, rightWorld), Vector3.Dot(offset, upWorld));\r\n\r\n // By default, content takes full width available and height is cropped to keep aspect ratio\r\n this._contentViewport.x = Scalar.Clamp(startViewport.x - offset.x, 0, 1 - this._contentViewport.width * this._contentScaleRatio);\r\n this._contentViewport.y = Scalar.Clamp(startViewport.y - offset.y, 0, 1 - this._contentViewport.height * this._contentScaleRatio);\r\n this._applyContentViewport();\r\n });\r\n }\r\n\r\n protected override _affectMaterial(mesh: AbstractMesh) {\r\n // TODO share materials\r\n this._titleBarMaterial = new FluentBackplateMaterial(`${this.name} plateMaterial`, mesh.getScene());\r\n\r\n this._contentMaterial = new FluentMaterial(`${this.name} contentMaterial`, mesh.getScene());\r\n this._contentMaterial.renderBorders = true;\r\n\r\n this._backMaterial = new FluentBackplateMaterial(`${this.name} backPlate`, mesh.getScene());\r\n this._backMaterial.lineWidth = Epsilon;\r\n this._backMaterial.radius = 0.005;\r\n this._backMaterial.backFaceCulling = true;\r\n\r\n this._titleBar.material = this._titleBarMaterial;\r\n this._contentPlate.material = this._contentMaterial;\r\n this._backPlate.material = this._backMaterial;\r\n\r\n this._resetContent();\r\n this._applyContentViewport();\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override _prepareNode(scene: Scene): void {\r\n super._prepareNode(scene);\r\n this._gizmo = new SlateGizmo(this._host.utilityLayer!);\r\n this._gizmo.attachedSlate = this;\r\n this._defaultBehavior = new DefaultBehavior();\r\n this._defaultBehavior.attach(this.node as Mesh, [this._titleBar]);\r\n this._defaultBehavior.sixDofDragBehavior.onDragStartObservable.add(() => {\r\n this._followButton.isToggled = false;\r\n });\r\n\r\n this._positionChangedObserver = this._defaultBehavior.sixDofDragBehavior.onPositionChangedObservable.add(() => {\r\n this._gizmo.updateBoundingBox();\r\n });\r\n\r\n this._updatePivot();\r\n this.resetDefaultAspectAndPose(false);\r\n }\r\n\r\n /**\r\n * Resets the aspect and pose of the slate so it is right in front of the active camera, facing towards it.\r\n * @param resetAspect Should the slate's dimensions/aspect ratio be reset as well\r\n */\r\n public resetDefaultAspectAndPose(resetAspect: boolean = true) {\r\n if (!this._host || !this._host.utilityLayer || !this.node) {\r\n return;\r\n }\r\n const scene = this._host.utilityLayer.utilityLayerScene;\r\n const camera = scene.activeCamera;\r\n if (camera) {\r\n const worldMatrix = camera.getWorldMatrix();\r\n const backward = Vector3.TransformNormal(Vector3.Backward(scene.useRightHandedSystem), worldMatrix);\r\n this.origin.setAll(0);\r\n this._gizmo.updateBoundingBox();\r\n const pivot = this.node.getAbsolutePivotPoint();\r\n // only if position was not yet set!\r\n if (this.node.position.equalsToFloats(0, 0, 0)) {\r\n this.node.position.copyFrom(camera.position).subtractInPlace(backward).subtractInPlace(pivot);\r\n }\r\n this.node.rotationQuaternion = Quaternion.FromLookDirectionLH(backward, new Vector3(0, 1, 0));\r\n\r\n if (resetAspect) {\r\n this.dimensions = this.defaultDimensions;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Releases all associated resources\r\n */\r\n public override dispose() {\r\n super.dispose();\r\n this._titleBarMaterial.dispose();\r\n this._contentMaterial.dispose();\r\n\r\n this._titleBar.dispose();\r\n this._titleBarTitle.dispose();\r\n this._contentPlate.dispose();\r\n this._backPlate.dispose();\r\n\r\n this._followButton.dispose();\r\n this._closeButton.dispose();\r\n\r\n this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);\r\n this._defaultBehavior.sixDofDragBehavior.onPositionChangedObservable.remove(this._positionChangedObserver);\r\n\r\n this._defaultBehavior.detach();\r\n this._gizmo.dispose();\r\n this._contentDragBehavior.detach();\r\n }\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babylonjs/gui",
3
- "version": "7.23.0",
3
+ "version": "7.23.1",
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": "^7.23.0",
21
+ "@babylonjs/core": "^7.23.1",
22
22
  "@dev/build-tools": "^1.0.0",
23
23
  "@lts/gui": "1.0.0"
24
24
  },