babylonjs-addons 7.32.4 → 7.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/babylonjs.addons.d.ts +281 -1
- package/babylonjs.addons.js +1839 -8
- package/babylonjs.addons.min.js +1 -1
- package/babylonjs.addons.min.js.map +1 -1
- package/babylonjs.addons.module.d.ts +585 -2
- package/package.json +2 -2
package/babylonjs.addons.d.ts
CHANGED
@@ -1,6 +1,286 @@
|
|
1
1
|
|
2
2
|
declare module ADDONS {
|
3
|
-
|
3
|
+
|
4
|
+
|
5
|
+
/**
|
6
|
+
* BABYLON.Behavior for any content that can capture pointer events, i.e. bypass the Babylon pointer event handling
|
7
|
+
* and receive pointer events directly. It will register the capture triggers and negotiate the capture and
|
8
|
+
* release of pointer events. Curerntly this applies only to HtmlMesh
|
9
|
+
*/
|
10
|
+
export class PointerEventsCaptureBehavior implements BABYLON.Behavior<BABYLON.AbstractMesh> {
|
11
|
+
private _captureCallback;
|
12
|
+
private _releaseCallback;
|
13
|
+
/** gets or sets behavior's name */
|
14
|
+
name: string;
|
15
|
+
private _attachedMesh;
|
16
|
+
/** @internal */
|
17
|
+
_captureOnPointerEnter: boolean;
|
18
|
+
/**
|
19
|
+
* Gets or sets the mesh that the behavior is attached to
|
20
|
+
*/
|
21
|
+
get attachedMesh(): BABYLON.AbstractMesh | null;
|
22
|
+
set attachedMesh(value: BABYLON.AbstractMesh | null);
|
23
|
+
constructor(_captureCallback: () => void, _releaseCallback: () => void, { captureOnPointerEnter }?: {
|
24
|
+
captureOnPointerEnter?: boolean | undefined;
|
25
|
+
});
|
26
|
+
/**
|
27
|
+
* Set if the behavior should capture pointer events when the pointer enters the mesh
|
28
|
+
*/
|
29
|
+
set captureOnPointerEnter(captureOnPointerEnter: boolean);
|
30
|
+
/**
|
31
|
+
* Function called when the behavior needs to be initialized (before attaching it to a target)
|
32
|
+
*/
|
33
|
+
init(): void;
|
34
|
+
/**
|
35
|
+
* Called when the behavior is attached to a target
|
36
|
+
* @param mesh defines the target where the behavior is attached to
|
37
|
+
*/
|
38
|
+
attach(mesh: BABYLON.AbstractMesh): void;
|
39
|
+
/**
|
40
|
+
* Called when the behavior is detached from its target
|
41
|
+
*/
|
42
|
+
detach(): void;
|
43
|
+
/**
|
44
|
+
* Dispose the behavior
|
45
|
+
*/
|
46
|
+
dispose(): void;
|
47
|
+
releasePointerEvents(): void;
|
48
|
+
capturePointerEvents(): void;
|
49
|
+
}
|
50
|
+
|
51
|
+
|
52
|
+
type CaptureReleaseCallback = () => void;
|
53
|
+
/**
|
54
|
+
* Get the id of the object currently capturing pointer events
|
55
|
+
* @returns The id of the object currently capturing pointer events
|
56
|
+
* or null if no object is capturing pointer events
|
57
|
+
*/
|
58
|
+
export const getCapturingId: () => string | null;
|
59
|
+
/**
|
60
|
+
* Request that the object with the given id capture pointer events. If there is no current
|
61
|
+
* owner, then the request is granted immediately. If there is a current owner, then the request
|
62
|
+
* is queued until the current owner releases pointer events.
|
63
|
+
* @param requestId An id to identify the request. This id will be used to match the capture
|
64
|
+
* request with the release request.
|
65
|
+
* @param captureCallback The callback to call when the request is granted and the object is capturing
|
66
|
+
* @param releaseCallback The callback to call when the object is no longer capturing pointer events
|
67
|
+
*/
|
68
|
+
export const requestCapture: (requestId: string, captureCallback: CaptureReleaseCallback, releaseCallback: CaptureReleaseCallback) => void;
|
69
|
+
/**
|
70
|
+
* Release pointer events from the object with the given id. If the object is the current owner
|
71
|
+
* then pointer events are released immediately. If the object is not the current owner, then the
|
72
|
+
* associated capture request is removed from the queue. If there is no matching capture request
|
73
|
+
* in the queue, then the release request is added to a list of unmatched release requests and will
|
74
|
+
* negate the next capture request with the same id. This is to guard against the possibility that
|
75
|
+
* the release request arrived before the capture request.
|
76
|
+
* @param requestId The id which should match the id of the capture request
|
77
|
+
*/
|
78
|
+
export const requestRelease: (requestId: string | null) => void;
|
79
|
+
/**
|
80
|
+
* Relase pointer events from the current owner
|
81
|
+
*/
|
82
|
+
export const releaseCurrent: () => void;
|
83
|
+
}
|
84
|
+
|
85
|
+
interface Window {
|
86
|
+
"pointer-events-capture-debug": boolean | null;
|
87
|
+
}
|
88
|
+
declare module ADDONS {
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
/**
|
94
|
+
* A function that compares two submeshes and returns a number indicating which
|
95
|
+
* should be rendered first.
|
96
|
+
*/
|
97
|
+
type RenderOrderFunction = (subMeshA: BABYLON.SubMesh, subMeshB: BABYLON.SubMesh) => number;
|
98
|
+
/**
|
99
|
+
* An instance of this is required to render HtmlMeshes in the scene.
|
100
|
+
* if using HtmlMeshes, you must not set render order for group 0 using
|
101
|
+
* scene.setRenderingOrder. You must instead pass the compare functions
|
102
|
+
* to the HtmlMeshRenderer constructor. If you do not, then your render
|
103
|
+
* order will be overwritten if the HtmlMeshRenderer is created after and
|
104
|
+
* the HtmlMeshes will not render correctly (they will appear in front of
|
105
|
+
* meshes that are actually in front of them) if the HtmlMeshRenderer is
|
106
|
+
* created before.
|
107
|
+
*/
|
108
|
+
export class HtmlMeshRenderer {
|
109
|
+
private _containerId?;
|
110
|
+
private _inSceneElements?;
|
111
|
+
private _overlayElements?;
|
112
|
+
private _engine;
|
113
|
+
private _cache;
|
114
|
+
private _width;
|
115
|
+
private _height;
|
116
|
+
private _heightHalf;
|
117
|
+
private _cameraWorldMatrix?;
|
118
|
+
private _temp;
|
119
|
+
private _lastDevicePixelRatio;
|
120
|
+
private _cameraMatrixUpdated;
|
121
|
+
private _previousCanvasDocumentPosition;
|
122
|
+
private _renderObserver;
|
123
|
+
/**
|
124
|
+
* Contruct an instance of HtmlMeshRenderer
|
125
|
+
* @param scene
|
126
|
+
* @param options object containing the following optional properties:
|
127
|
+
* @returns
|
128
|
+
*/
|
129
|
+
constructor(scene: BABYLON.Scene, { parentContainerId, _containerId, enableOverlayRender, defaultOpaqueRenderOrder, defaultAlphaTestRenderOrder, defaultTransparentRenderOrder, }?: {
|
130
|
+
parentContainerId?: string | null;
|
131
|
+
_containerId?: string;
|
132
|
+
defaultOpaqueRenderOrder?: RenderOrderFunction;
|
133
|
+
defaultAlphaTestRenderOrder?: RenderOrderFunction;
|
134
|
+
defaultTransparentRenderOrder?: RenderOrderFunction;
|
135
|
+
enableOverlayRender?: boolean;
|
136
|
+
});
|
137
|
+
/**
|
138
|
+
* Dispose of the HtmlMeshRenderer
|
139
|
+
*/
|
140
|
+
dispose(): void;
|
141
|
+
protected _init(scene: BABYLON.Scene, parentContainerId: string | null, enableOverlayRender: boolean, defaultOpaqueRenderOrder: RenderOrderFunction, defaultAlphaTestRenderOrder: RenderOrderFunction, defaultTransparentRenderOrder: RenderOrderFunction): void;
|
142
|
+
private _createRenderLayerElements;
|
143
|
+
protected _getSize(): {
|
144
|
+
width: number;
|
145
|
+
height: number;
|
146
|
+
};
|
147
|
+
protected _setSize(width: number, height: number): void;
|
148
|
+
protected _getCameraCSSMatrix(matrix: BABYLON.Matrix): string;
|
149
|
+
protected _getHtmlContentCSSMatrix(matrix: BABYLON.Matrix, useRightHandedSystem: boolean): string;
|
150
|
+
protected _getTransformationMatrix(htmlMesh: HtmlMesh, useRightHandedSystem: boolean): BABYLON.Matrix;
|
151
|
+
protected _renderHtmlMesh(htmlMesh: HtmlMesh, useRightHandedSystem: boolean): void;
|
152
|
+
protected _render(scene: BABYLON.Scene, camera: BABYLON.Camera): void;
|
153
|
+
protected _updateBaseScaleFactor(htmlMesh: HtmlMesh): void;
|
154
|
+
protected _updateContainerPositionIfNeeded(): void;
|
155
|
+
protected _onCameraMatrixChanged: (camera: BABYLON.Camera) => void;
|
156
|
+
private _epsilon;
|
157
|
+
private _getAncestorMarginsAndPadding;
|
158
|
+
}
|
159
|
+
|
160
|
+
|
161
|
+
/**
|
162
|
+
* This class represents HTML content that we want to render as though it is part of the scene. The HTML content is actually
|
163
|
+
* rendered below the canvas, but a depth mask is created by this class that writes to the depth buffer but does not
|
164
|
+
* write to the color buffer, effectively punching a hole in the canvas. CSS transforms are used to scale, translate, and rotate
|
165
|
+
* the HTML content so that it matches the camera and mesh orientation. The class supports interactions in editable and non-editable mode.
|
166
|
+
* In non-editable mode (the default), events are passed to the HTML content when the pointer is over the mask (and not occluded by other meshes
|
167
|
+
* in the scene).
|
168
|
+
* #HVHYJC#5
|
169
|
+
* #B17TC7#112
|
170
|
+
*/
|
171
|
+
export class HtmlMesh extends BABYLON.Mesh {
|
172
|
+
/**
|
173
|
+
* Helps identifying a html mesh from a regular mesh
|
174
|
+
*/
|
175
|
+
get isHtmlMesh(): boolean;
|
176
|
+
private _enabled;
|
177
|
+
private _ready;
|
178
|
+
/**
|
179
|
+
* @internal
|
180
|
+
*/
|
181
|
+
_isCanvasOverlay: boolean;
|
182
|
+
private _requiresUpdate;
|
183
|
+
private _element?;
|
184
|
+
private _width?;
|
185
|
+
private _height?;
|
186
|
+
private _inverseScaleMatrix;
|
187
|
+
private _captureOnPointerEnter;
|
188
|
+
private _pointerEventCaptureBehavior;
|
189
|
+
private _sourceWidth;
|
190
|
+
private _sourceHeight;
|
191
|
+
/**
|
192
|
+
* Return the source width of the content in pixels
|
193
|
+
*/
|
194
|
+
get sourceWidth(): number | null;
|
195
|
+
/**
|
196
|
+
* Return the source height of the content in pixels
|
197
|
+
*/
|
198
|
+
get sourceHeight(): number | null;
|
199
|
+
private _worldMatrixUpdateObserver;
|
200
|
+
private _fitStrategy;
|
201
|
+
/**
|
202
|
+
* Contruct an instance of HtmlMesh
|
203
|
+
* @param scene
|
204
|
+
* @param id The id of the mesh. Will be used as the id of the HTML element as well.
|
205
|
+
* @param options object with optional parameters
|
206
|
+
*/
|
207
|
+
constructor(scene: BABYLON.Scene, id: string, { captureOnPointerEnter, isCanvasOverlay, fitStrategy }?: {
|
208
|
+
captureOnPointerEnter?: boolean | undefined;
|
209
|
+
isCanvasOverlay?: boolean | undefined;
|
210
|
+
fitStrategy?: FitStrategyType | undefined;
|
211
|
+
});
|
212
|
+
/**
|
213
|
+
* The width of the content in pixels
|
214
|
+
*/
|
215
|
+
get width(): number | undefined;
|
216
|
+
/**
|
217
|
+
* The height of the content in pixels
|
218
|
+
*/
|
219
|
+
get height(): number | undefined;
|
220
|
+
/**
|
221
|
+
* The HTML element that is being rendered as a mesh
|
222
|
+
*/
|
223
|
+
get element(): HTMLElement | undefined;
|
224
|
+
/**
|
225
|
+
* True if the mesh has been moved, rotated, or scaled since the last time this
|
226
|
+
* property was read. This property is reset to false after reading.
|
227
|
+
*/
|
228
|
+
get requiresUpdate(): boolean;
|
229
|
+
/**
|
230
|
+
* Enable capture for the pointer when entering the mesh area
|
231
|
+
*/
|
232
|
+
set captureOnPointerEnter(captureOnPointerEnter: boolean);
|
233
|
+
/**
|
234
|
+
* Disposes of the mesh and the HTML element
|
235
|
+
*/
|
236
|
+
dispose(): void;
|
237
|
+
/**
|
238
|
+
* @internal
|
239
|
+
*/
|
240
|
+
_markAsUpdated(): void;
|
241
|
+
/**
|
242
|
+
* Sets the content of the element to the specified content adjusting the mesh scale to match and making it visible.
|
243
|
+
* If the the specified content is undefined, then it will make the mesh invisible. In either case it will clear the
|
244
|
+
* element content first.
|
245
|
+
* @param element The element to render as a mesh
|
246
|
+
* @param width The width of the mesh in Babylon units
|
247
|
+
* @param height The height of the mesh in Babylon units
|
248
|
+
*/
|
249
|
+
setContent(element: HTMLElement, width: number, height: number): void;
|
250
|
+
setEnabled(enabled: boolean): void;
|
251
|
+
/**
|
252
|
+
* Sets the content size in pixels
|
253
|
+
* @param width width of the source
|
254
|
+
* @param height height of the source
|
255
|
+
*/
|
256
|
+
setContentSizePx(width: number, height: number): void;
|
257
|
+
protected _setAsReady(ready: boolean): void;
|
258
|
+
protected _doSetEnabled(enabled: boolean): void;
|
259
|
+
protected _updateScaleIfNecessary(): void;
|
260
|
+
protected _createMask(): void;
|
261
|
+
protected _setElementZIndex(zIndex: number): void;
|
262
|
+
/**
|
263
|
+
* Callback used by the PointerEventsCaptureBehavior to capture pointer events
|
264
|
+
*/
|
265
|
+
capturePointerEvents(): void;
|
266
|
+
/**
|
267
|
+
* Callback used by the PointerEventsCaptureBehavior to release pointer events
|
268
|
+
*/
|
269
|
+
releasePointerEvents(): void;
|
270
|
+
protected _createElement(): HTMLDivElement | undefined;
|
271
|
+
}
|
272
|
+
|
273
|
+
|
274
|
+
export type FitStrategyType = {
|
275
|
+
wrapElement(element: HTMLElement): HTMLElement;
|
276
|
+
updateSize(sizingElement: HTMLElement, width: number, height: number): void;
|
277
|
+
};
|
278
|
+
export var FitStrategy: {
|
279
|
+
CONTAIN: FitStrategyType;
|
280
|
+
COVER: FitStrategyType;
|
281
|
+
STRETCH: FitStrategyType;
|
282
|
+
NONE: FitStrategyType;
|
283
|
+
};
|
4
284
|
|
5
285
|
|
6
286
|
|