@babylonjs/gui 7.12.0 → 7.13.1
Sign up to get free protection for your applications and to get access to all the features.
- package/2D/advancedDynamicTexture.d.ts +9 -4
- package/2D/advancedDynamicTexture.js +44 -0
- package/2D/advancedDynamicTexture.js.map +1 -1
- package/2D/controls/control.d.ts +53 -1
- package/2D/controls/control.js +88 -0
- package/2D/controls/control.js.map +1 -1
- package/2D/controls/focusableButton.d.ts +0 -37
- package/2D/controls/focusableButton.js +0 -65
- package/2D/controls/focusableButton.js.map +1 -1
- package/2D/controls/focusableControl.d.ts +9 -0
- package/2D/controls/focusableControl.js.map +1 -1
- package/2D/controls/inputText.d.ts +1 -19
- package/2D/controls/inputText.js +2 -27
- package/2D/controls/inputText.js.map +1 -1
- package/2D/controls/textBlock.d.ts +1 -1
- package/2D/controls/textBlock.js +5 -5
- package/2D/controls/textBlock.js.map +1 -1
- package/2D/controls/virtualKeyboard.js.map +1 -1
- package/3D/controls/cylinderPanel.js +2 -2
- package/3D/controls/cylinderPanel.js.map +1 -1
- package/3D/controls/holographicSlate.js +2 -2
- package/3D/controls/holographicSlate.js.map +1 -1
- package/3D/controls/spherePanel.js +2 -2
- package/3D/controls/spherePanel.js.map +1 -1
- package/3D/gizmos/gizmoHandle.d.ts +1 -1
- package/3D/gizmos/gizmoHandle.js +7 -7
- package/3D/gizmos/gizmoHandle.js.map +1 -1
- package/package.json +2 -2
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"spherePanel.js","sourceRoot":"","sources":["../../../../../dev/gui/src/3D/controls/spherePanel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,sCAAwB;AACxC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,6CAA+B;AAGrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,IAAI,
|
1
|
+
{"version":3,"file":"spherePanel.js","sourceRoot":"","sources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,KAAK,WAAW,CAAC,8BAA8B;gBAC3C,IAAI,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC1D,MAAM;YACV,KAAK,WAAW,CAAC,uBAAuB;gBACpC,MAAM;YACV,KAAK,WAAW,CAAC,+BAA+B;gBAC5C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,sBAAc,CAAC;gBAC1C,MAAM;SACb;IACL,CAAC;IAEO,iBAAiB,CAAC,MAAe;QACrC,MAAM,MAAM,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAE/C,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC;QACvC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;QAE1C,MAAM,CAAC,yBAAyB,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAE1E,OAAO,OAAO,CAAC,eAAe,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACjE,CAAC;CACJ","sourcesContent":["import { Tools } from \"core/Misc/tools\";\r\nimport { Matrix, TmpVectors, Vector3 } from \"core/Maths/math.vector\";\r\nimport type { float } from \"core/types\";\r\n\r\nimport { VolumeBasedPanel } from \"./volumeBasedPanel\";\r\nimport type { Control3D } from \"./control3D\";\r\nimport { Container3D } from \"./container3D\";\r\nimport { Axis, Space } from \"core/Maths/math.axis\";\r\n\r\n/**\r\n * Class used to create a container panel deployed on the surface of a sphere\r\n */\r\nexport class SpherePanel extends VolumeBasedPanel {\r\n private _radius = 5.0;\r\n\r\n /**\r\n * Gets or sets the radius of the sphere where to project controls (5 by default)\r\n */\r\n public get radius(): float {\r\n return this._radius;\r\n }\r\n\r\n public set radius(value: float) {\r\n if (this._radius === value) {\r\n return;\r\n }\r\n\r\n this._radius = value;\r\n\r\n Tools.SetImmediate(() => {\r\n this._arrangeChildren();\r\n });\r\n }\r\n\r\n protected _mapGridNode(control: Control3D, nodePosition: Vector3) {\r\n const mesh = control.mesh;\r\n\r\n if (!mesh) {\r\n return;\r\n }\r\n\r\n const newPos = this._sphericalMapping(nodePosition);\r\n control.position = newPos;\r\n\r\n switch (this.orientation) {\r\n case Container3D.FACEORIGIN_ORIENTATION:\r\n mesh.lookAt(new Vector3(2 * newPos.x, 2 * newPos.y, 2 * newPos.z));\r\n break;\r\n case Container3D.FACEORIGINREVERSED_ORIENTATION:\r\n mesh.lookAt(new Vector3(-newPos.x, -newPos.y, -newPos.z));\r\n break;\r\n case Container3D.FACEFORWARD_ORIENTATION:\r\n break;\r\n case Container3D.FACEFORWARDREVERSED_ORIENTATION:\r\n mesh.rotate(Axis.Y, Math.PI, Space.LOCAL);\r\n break;\r\n }\r\n }\r\n\r\n private _sphericalMapping(source: Vector3) {\r\n const newPos = new Vector3(0, 0, this._radius);\r\n\r\n const xAngle = source.y / this._radius;\r\n const yAngle = -(source.x / this._radius);\r\n\r\n Matrix.RotationYawPitchRollToRef(yAngle, xAngle, 0, TmpVectors.Matrix[0]);\r\n\r\n return Vector3.TransformNormal(newPos, TmpVectors.Matrix[0]);\r\n }\r\n}\r\n"]}
|
package/3D/gizmos/gizmoHandle.js
CHANGED
@@ -42,10 +42,10 @@ export class GizmoHandle {
|
|
42
42
|
*/
|
43
43
|
set hover(value) {
|
44
44
|
if (value) {
|
45
|
-
this._state |= HandleState.HOVER
|
45
|
+
this._state |= 1 /* HandleState.HOVER */;
|
46
46
|
}
|
47
47
|
else {
|
48
|
-
this._state &= ~HandleState.HOVER
|
48
|
+
this._state &= ~1 /* HandleState.HOVER */;
|
49
49
|
}
|
50
50
|
this._updateMaterial();
|
51
51
|
}
|
@@ -54,10 +54,10 @@ export class GizmoHandle {
|
|
54
54
|
*/
|
55
55
|
set drag(value) {
|
56
56
|
if (value) {
|
57
|
-
this._state |= HandleState.DRAG
|
57
|
+
this._state |= 2 /* HandleState.DRAG */;
|
58
58
|
}
|
59
59
|
else {
|
60
|
-
this._state &= ~HandleState.DRAG
|
60
|
+
this._state &= ~2 /* HandleState.DRAG */;
|
61
61
|
}
|
62
62
|
this._updateMaterial();
|
63
63
|
}
|
@@ -67,7 +67,7 @@ export class GizmoHandle {
|
|
67
67
|
* @param scene scene
|
68
68
|
*/
|
69
69
|
constructor(gizmo, scene) {
|
70
|
-
this._state = HandleState.IDLE
|
70
|
+
this._state = 0 /* HandleState.IDLE */;
|
71
71
|
this._materials = [];
|
72
72
|
this._scene = scene;
|
73
73
|
this._gizmo = gizmo;
|
@@ -89,12 +89,12 @@ export class GizmoHandle {
|
|
89
89
|
mat.hover = false;
|
90
90
|
mat.drag = false;
|
91
91
|
}
|
92
|
-
if (state & HandleState.DRAG) {
|
92
|
+
if (state & 2 /* HandleState.DRAG */) {
|
93
93
|
for (const mat of this._materials) {
|
94
94
|
mat.drag = true;
|
95
95
|
}
|
96
96
|
}
|
97
|
-
else if (state & HandleState.HOVER) {
|
97
|
+
else if (state & 1 /* HandleState.HOVER */) {
|
98
98
|
for (const mat of this._materials) {
|
99
99
|
mat.hover = true;
|
100
100
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"gizmoHandle.js","sourceRoot":"","sources":["../../../../../dev/gui/src/3D/gizmos/gizmoHandle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,sDAAwC;AAC5D,OAAO,EAAE,aAAa,EAAE,gDAAkC;AAC1D,OAAO,EAAE,OAAO,EAAE,6CAA+B;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEpE,OAAO,EAAE,sBAAsB,EA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C;;;OAGG;IACI,UAAU;QACb,6CAA6C;QAC7C,MAAM,aAAa,GAAG,SAAS,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC9F,MAAM,WAAW,GAAG,SAAS,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAE7F,MAAM,SAAS,GAAG,IAAI,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1D,aAAa,CAAC,MAAM,GAAG,SAAS,CAAC;QACjC,WAAW,CAAC,MAAM,GAAG,SAAS,CAAC;QAE/B,aAAa,CAAC,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACpE,WAAW,CAAC,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAClE,WAAW,CAAC,eAAe,GAAG,IAAI,CAAC;QACnC,aAAa,CAAC,eAAe,GAAG,IAAI,CAAC;QAErC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,QAA0B,CAAC,CAAC;QAC/D,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,QAA0B,CAAC,CAAC;QAC7D,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ","sourcesContent":["import type { Scene } from \"core/scene\";\r\nimport { CreateBox } from \"core/Meshes/Builders/boxBuilder\";\r\nimport { TransformNode } from \"core/Meshes/transformNode\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport { HandleMaterial } from \"../materials/handle/handleMaterial\";\r\nimport type { SlateGizmo } from \"./slateGizmo\";\r\nimport { BaseSixDofDragBehavior } from \"core/Behaviors/Meshes/baseSixDofDragBehavior\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { Observer } from \"core/Misc/observable\";\r\n\r\n/**\r\n * State of the handle regarding user interaction\r\n */\r\nexport enum HandleState {\r\n /**\r\n * Handle is idle\r\n */\r\n IDLE = 0,\r\n /**\r\n * Handle is hovered\r\n */\r\n HOVER = 1,\r\n /**\r\n * Handle is dragged\r\n */\r\n DRAG = 2,\r\n}\r\n\r\n/**\r\n * Base class for SlateGizmo handles\r\n */\r\nexport abstract class GizmoHandle {\r\n protected _scene: Scene;\r\n protected _state: HandleState = HandleState.IDLE;\r\n protected _materials: HandleMaterial[] = [];\r\n\r\n private _dragStartObserver: Nullable<Observer<any>>;\r\n private _draggingObserver: Nullable<Observer<any>>;\r\n private _dragEndObserver: Nullable<Observer<any>>;\r\n /**\r\n * @internal\r\n */\r\n public _dragBehavior: BaseSixDofDragBehavior;\r\n\r\n /**\r\n * The current state of the handle\r\n */\r\n public get state(): HandleState {\r\n return this._state;\r\n }\r\n\r\n private _gizmo: SlateGizmo;\r\n\r\n /**\r\n * Returns the gizmo carrying this handle\r\n */\r\n public get gizmo() {\r\n return this._gizmo;\r\n }\r\n\r\n /**\r\n * Sets hover state\r\n */\r\n public set hover(value: boolean) {\r\n if (value) {\r\n this._state |= HandleState.HOVER;\r\n } else {\r\n this._state &= ~HandleState.HOVER;\r\n }\r\n\r\n this._updateMaterial();\r\n }\r\n /**\r\n * Sets drag state\r\n */\r\n public set drag(value: boolean) {\r\n if (value) {\r\n this._state |= HandleState.DRAG;\r\n } else {\r\n this._state &= ~HandleState.DRAG;\r\n }\r\n\r\n this._updateMaterial();\r\n }\r\n\r\n /**\r\n * Node of this handle\r\n */\r\n public node: TransformNode;\r\n\r\n /**\r\n * Creates a handle for a SlateGizmo\r\n * @param gizmo associated SlateGizmo\r\n * @param scene scene\r\n */\r\n constructor(gizmo: SlateGizmo, scene: Scene) {\r\n this._scene = scene;\r\n this._gizmo = gizmo;\r\n\r\n this.node = this.createNode();\r\n this.node.reservedDataStore = {\r\n handle: this,\r\n };\r\n }\r\n\r\n protected _createMaterial(positionOffset?: Vector3) {\r\n const mat = new HandleMaterial(\"handle\", this._scene);\r\n if (positionOffset) {\r\n mat._positionOffset = positionOffset;\r\n }\r\n return mat;\r\n }\r\n\r\n private _updateMaterial() {\r\n const state = this._state;\r\n for (const mat of this._materials) {\r\n mat.hover = false;\r\n mat.drag = false;\r\n }\r\n\r\n if (state & HandleState.DRAG) {\r\n for (const mat of this._materials) {\r\n mat.drag = true;\r\n }\r\n } else if (state & HandleState.HOVER) {\r\n for (const mat of this._materials) {\r\n mat.hover = true;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Binds callbacks from dragging interaction\r\n * @param dragStartFn Function to call on drag start\r\n * @param dragFn Function to call on drag\r\n * @param dragEndFn Function to call on drag end\r\n */\r\n public setDragBehavior(dragStartFn: (event: { position: Vector3 }) => void, dragFn: (event: { position: Vector3 }) => void, dragEndFn: () => void) {\r\n const dragBehavior = new BaseSixDofDragBehavior();\r\n\r\n this._dragBehavior = dragBehavior;\r\n\r\n this._dragStartObserver = dragBehavior.onDragStartObservable.add(dragStartFn);\r\n this._draggingObserver = dragBehavior.onDragObservable.add(dragFn);\r\n this._dragEndObserver = dragBehavior.onDragEndObservable.add(dragEndFn);\r\n\r\n this._dragBehavior.attach(this.node);\r\n }\r\n\r\n /**\r\n * Creates the meshes and parent node of the handle\r\n * Should be overridden by child classes\r\n * @returns created node\r\n */\r\n public abstract createNode(): TransformNode;\r\n\r\n /**\r\n * Disposes the handle\r\n */\r\n public dispose() {\r\n this._dragBehavior.onDragStartObservable.remove(this._dragStartObserver);\r\n this._dragBehavior.onDragObservable.remove(this._draggingObserver);\r\n this._dragBehavior.onDragEndObservable.remove(this._dragEndObserver);\r\n\r\n this._dragBehavior.detach();\r\n\r\n for (const material of this._materials) {\r\n material.dispose();\r\n }\r\n this.node.dispose();\r\n }\r\n}\r\n\r\n/**\r\n * Side handle class that rotates the slate\r\n */\r\nexport class SideHandle extends GizmoHandle {\r\n /**\r\n * Creates the meshes and parent node of the handle\r\n * @returns created node\r\n */\r\n public createNode() {\r\n // Create a simple vertical rectangle\r\n const verticalBox = CreateBox(\"sideVert\", { width: 1, height: 10, depth: 0.1 }, this._scene);\r\n const sideNode = new TransformNode(\"side\", this._scene);\r\n verticalBox.parent = sideNode;\r\n\r\n const mat = this._createMaterial();\r\n verticalBox.material = mat;\r\n verticalBox.isNearGrabbable = true;\r\n this._materials.push(mat);\r\n\r\n return sideNode;\r\n }\r\n}\r\n\r\n/**\r\n * Corner handle that resizes the slate\r\n */\r\nexport class CornerHandle extends GizmoHandle {\r\n /**\r\n * Creates the meshes and parent node of the handle\r\n * @returns created node\r\n */\r\n public createNode() {\r\n // Create 2 boxes making a bottom left corner\r\n const horizontalBox = CreateBox(\"angleHor\", { width: 3, height: 1, depth: 0.1 }, this._scene);\r\n const verticalBox = CreateBox(\"angleVert\", { width: 1, height: 3, depth: 0.1 }, this._scene);\r\n\r\n const angleNode = new TransformNode(\"angle\", this._scene);\r\n horizontalBox.parent = angleNode;\r\n verticalBox.parent = angleNode;\r\n\r\n horizontalBox.material = this._createMaterial(new Vector3(1, 0, 0));\r\n verticalBox.material = this._createMaterial(new Vector3(0, 1, 0));\r\n verticalBox.isNearGrabbable = true;\r\n horizontalBox.isNearGrabbable = true;\r\n\r\n this._materials.push(horizontalBox.material as HandleMaterial);\r\n this._materials.push(verticalBox.material as HandleMaterial);\r\n return angleNode;\r\n }\r\n}\r\n"]}
|
1
|
+
{"version":3,"file":"gizmoHandle.js","sourceRoot":"","sources":["../../../../../dev/gui/src/3D/gizmos/gizmoHandle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,sDAAwC;AAC5D,OAAO,EAAE,aAAa,EAAE,gDAAkC;AAC1D,OAAO,EAAE,OAAO,EAAE,6CAA+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AA6C;QAC7C,MAAM,aAAa,GAAG,SAAS,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC9F,MAAM,WAAW,GAAG,SAAS,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAE7F,MAAM,SAAS,GAAG,IAAI,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1D,aAAa,CAAC,MAAM,GAAG,SAAS,CAAC;QACjC,WAAW,CAAC,MAAM,GAAG,SAAS,CAAC;QAE/B,aAAa,CAAC,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACpE,WAAW,CAAC,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAClE,WAAW,CAAC,eAAe,GAAG,IAAI,CAAC;QACnC,aAAa,CAAC,eAAe,GAAG,IAAI,CAAC;QAErC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,QAA0B,CAAC,CAAC;QAC/D,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,QAA0B,CAAC,CAAC;QAC7D,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ","sourcesContent":["import type { Scene } from \"core/scene\";\r\nimport { CreateBox } from \"core/Meshes/Builders/boxBuilder\";\r\nimport { TransformNode } from \"core/Meshes/transformNode\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport { HandleMaterial } from \"../materials/handle/handleMaterial\";\r\nimport type { SlateGizmo } from \"./slateGizmo\";\r\nimport { BaseSixDofDragBehavior } from \"core/Behaviors/Meshes/baseSixDofDragBehavior\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { Observer } from \"core/Misc/observable\";\r\n\r\n/**\r\n * State of the handle regarding user interaction\r\n */\r\nexport const enum HandleState {\r\n /**\r\n * Handle is idle\r\n */\r\n IDLE = 0,\r\n /**\r\n * Handle is hovered\r\n */\r\n HOVER = 1,\r\n /**\r\n * Handle is dragged\r\n */\r\n DRAG = 2,\r\n}\r\n\r\n/**\r\n * Base class for SlateGizmo handles\r\n */\r\nexport abstract class GizmoHandle {\r\n protected _scene: Scene;\r\n protected _state: HandleState = HandleState.IDLE;\r\n protected _materials: HandleMaterial[] = [];\r\n\r\n private _dragStartObserver: Nullable<Observer<any>>;\r\n private _draggingObserver: Nullable<Observer<any>>;\r\n private _dragEndObserver: Nullable<Observer<any>>;\r\n /**\r\n * @internal\r\n */\r\n public _dragBehavior: BaseSixDofDragBehavior;\r\n\r\n /**\r\n * The current state of the handle\r\n */\r\n public get state(): HandleState {\r\n return this._state;\r\n }\r\n\r\n private _gizmo: SlateGizmo;\r\n\r\n /**\r\n * Returns the gizmo carrying this handle\r\n */\r\n public get gizmo() {\r\n return this._gizmo;\r\n }\r\n\r\n /**\r\n * Sets hover state\r\n */\r\n public set hover(value: boolean) {\r\n if (value) {\r\n this._state |= HandleState.HOVER;\r\n } else {\r\n this._state &= ~HandleState.HOVER;\r\n }\r\n\r\n this._updateMaterial();\r\n }\r\n /**\r\n * Sets drag state\r\n */\r\n public set drag(value: boolean) {\r\n if (value) {\r\n this._state |= HandleState.DRAG;\r\n } else {\r\n this._state &= ~HandleState.DRAG;\r\n }\r\n\r\n this._updateMaterial();\r\n }\r\n\r\n /**\r\n * Node of this handle\r\n */\r\n public node: TransformNode;\r\n\r\n /**\r\n * Creates a handle for a SlateGizmo\r\n * @param gizmo associated SlateGizmo\r\n * @param scene scene\r\n */\r\n constructor(gizmo: SlateGizmo, scene: Scene) {\r\n this._scene = scene;\r\n this._gizmo = gizmo;\r\n\r\n this.node = this.createNode();\r\n this.node.reservedDataStore = {\r\n handle: this,\r\n };\r\n }\r\n\r\n protected _createMaterial(positionOffset?: Vector3) {\r\n const mat = new HandleMaterial(\"handle\", this._scene);\r\n if (positionOffset) {\r\n mat._positionOffset = positionOffset;\r\n }\r\n return mat;\r\n }\r\n\r\n private _updateMaterial() {\r\n const state = this._state;\r\n for (const mat of this._materials) {\r\n mat.hover = false;\r\n mat.drag = false;\r\n }\r\n\r\n if (state & HandleState.DRAG) {\r\n for (const mat of this._materials) {\r\n mat.drag = true;\r\n }\r\n } else if (state & HandleState.HOVER) {\r\n for (const mat of this._materials) {\r\n mat.hover = true;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Binds callbacks from dragging interaction\r\n * @param dragStartFn Function to call on drag start\r\n * @param dragFn Function to call on drag\r\n * @param dragEndFn Function to call on drag end\r\n */\r\n public setDragBehavior(dragStartFn: (event: { position: Vector3 }) => void, dragFn: (event: { position: Vector3 }) => void, dragEndFn: () => void) {\r\n const dragBehavior = new BaseSixDofDragBehavior();\r\n\r\n this._dragBehavior = dragBehavior;\r\n\r\n this._dragStartObserver = dragBehavior.onDragStartObservable.add(dragStartFn);\r\n this._draggingObserver = dragBehavior.onDragObservable.add(dragFn);\r\n this._dragEndObserver = dragBehavior.onDragEndObservable.add(dragEndFn);\r\n\r\n this._dragBehavior.attach(this.node);\r\n }\r\n\r\n /**\r\n * Creates the meshes and parent node of the handle\r\n * Should be overridden by child classes\r\n * @returns created node\r\n */\r\n public abstract createNode(): TransformNode;\r\n\r\n /**\r\n * Disposes the handle\r\n */\r\n public dispose() {\r\n this._dragBehavior.onDragStartObservable.remove(this._dragStartObserver);\r\n this._dragBehavior.onDragObservable.remove(this._draggingObserver);\r\n this._dragBehavior.onDragEndObservable.remove(this._dragEndObserver);\r\n\r\n this._dragBehavior.detach();\r\n\r\n for (const material of this._materials) {\r\n material.dispose();\r\n }\r\n this.node.dispose();\r\n }\r\n}\r\n\r\n/**\r\n * Side handle class that rotates the slate\r\n */\r\nexport class SideHandle extends GizmoHandle {\r\n /**\r\n * Creates the meshes and parent node of the handle\r\n * @returns created node\r\n */\r\n public createNode() {\r\n // Create a simple vertical rectangle\r\n const verticalBox = CreateBox(\"sideVert\", { width: 1, height: 10, depth: 0.1 }, this._scene);\r\n const sideNode = new TransformNode(\"side\", this._scene);\r\n verticalBox.parent = sideNode;\r\n\r\n const mat = this._createMaterial();\r\n verticalBox.material = mat;\r\n verticalBox.isNearGrabbable = true;\r\n this._materials.push(mat);\r\n\r\n return sideNode;\r\n }\r\n}\r\n\r\n/**\r\n * Corner handle that resizes the slate\r\n */\r\nexport class CornerHandle extends GizmoHandle {\r\n /**\r\n * Creates the meshes and parent node of the handle\r\n * @returns created node\r\n */\r\n public createNode() {\r\n // Create 2 boxes making a bottom left corner\r\n const horizontalBox = CreateBox(\"angleHor\", { width: 3, height: 1, depth: 0.1 }, this._scene);\r\n const verticalBox = CreateBox(\"angleVert\", { width: 1, height: 3, depth: 0.1 }, this._scene);\r\n\r\n const angleNode = new TransformNode(\"angle\", this._scene);\r\n horizontalBox.parent = angleNode;\r\n verticalBox.parent = angleNode;\r\n\r\n horizontalBox.material = this._createMaterial(new Vector3(1, 0, 0));\r\n verticalBox.material = this._createMaterial(new Vector3(0, 1, 0));\r\n verticalBox.isNearGrabbable = true;\r\n horizontalBox.isNearGrabbable = true;\r\n\r\n this._materials.push(horizontalBox.material as HandleMaterial);\r\n this._materials.push(verticalBox.material as HandleMaterial);\r\n return angleNode;\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@babylonjs/gui",
|
3
|
-
"version": "7.
|
3
|
+
"version": "7.13.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.
|
21
|
+
"@babylonjs/core": "^7.13.1",
|
22
22
|
"@dev/build-tools": "^1.0.0",
|
23
23
|
"@lts/gui": "1.0.0"
|
24
24
|
},
|