babylonjs-accessibility 5.17.1 → 5.18.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/babylon.accessibility.d.ts +166 -6
- package/babylon.accessibility.max.js +536 -536
- package/babylon.accessibility.module.d.ts +346 -186
- package/package.json +3 -3
@@ -31084,130 +31084,130 @@ __webpack_require__.r(__webpack_exports__);
|
|
31084
31084
|
/* harmony import */ var gui_2D_controls_button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! gui/2D/math2D */ "gui/2D/advancedDynamicTexture");
|
31085
31085
|
/* harmony import */ var gui_2D_controls_button__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(gui_2D_controls_button__WEBPACK_IMPORTED_MODULE_1__);
|
31086
31086
|
/* harmony import */ var _htmlTwinItem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./htmlTwinItem */ "../../../tools/accessibility/dist/HtmlTwin/htmlTwinItem.js");
|
31087
|
-
|
31088
|
-
|
31089
|
-
|
31090
|
-
|
31091
|
-
|
31092
|
-
|
31093
|
-
/**
|
31094
|
-
* A abstract layer to store the html twin tree structure. It is constructed from the BabylonJS scene entities that need to be accessible. It informs the parent-children relationship of html twin tree, and informs how to render: description, isActionable, onclick/onrightclick/onfocus/onblur.
|
31095
|
-
*/
|
31096
|
-
class HTMLTwinGUIItem extends _htmlTwinItem__WEBPACK_IMPORTED_MODULE_2__.HTMLTwinItem {
|
31097
|
-
constructor(entity, scene, children) {
|
31098
|
-
super(entity, scene, children);
|
31099
|
-
}
|
31100
|
-
/**
|
31101
|
-
* The text content displayed in HTML element.
|
31102
|
-
*/
|
31103
|
-
get description() {
|
31104
|
-
let description = "";
|
31105
|
-
if (this.entity.accessibilityTag?.description) {
|
31106
|
-
description = this.entity.accessibilityTag.description;
|
31107
|
-
}
|
31108
|
-
else if (this.entity instanceof gui_2D_controls_button__WEBPACK_IMPORTED_MODULE_1__.TextBlock) {
|
31109
|
-
description = this.entity.text;
|
31110
|
-
}
|
31111
|
-
else if (this.entity instanceof gui_2D_controls_button__WEBPACK_IMPORTED_MODULE_1__.Button) {
|
31112
|
-
description = this.entity.textBlock?.text ?? "";
|
31113
|
-
}
|
31114
|
-
else if (this.entity instanceof gui_2D_controls_button__WEBPACK_IMPORTED_MODULE_1__.Image) {
|
31115
|
-
description = this.entity.alt ?? "";
|
31116
|
-
}
|
31117
|
-
return description;
|
31118
|
-
}
|
31119
|
-
/**
|
31120
|
-
* If this entity is actionable (can be clicked).
|
31121
|
-
*/
|
31122
|
-
get isActionable() {
|
31123
|
-
if (this._isActionable) {
|
31124
|
-
return this._isActionable;
|
31125
|
-
}
|
31126
|
-
// If defined onclick, override default.
|
31127
|
-
const eventHandler = this.entity.accessibilityTag?.eventHandler;
|
31128
|
-
if (eventHandler?.click || eventHandler?.contextmenu) {
|
31129
|
-
this._isActionable = true;
|
31130
|
-
}
|
31131
|
-
else {
|
31132
|
-
if (this.entity instanceof gui_2D_controls_button__WEBPACK_IMPORTED_MODULE_1__.Button) {
|
31133
|
-
this._isActionable = true;
|
31134
|
-
}
|
31135
|
-
else {
|
31136
|
-
this._isActionable = false;
|
31137
|
-
}
|
31138
|
-
}
|
31139
|
-
return this._isActionable;
|
31140
|
-
}
|
31141
|
-
/**
|
31142
|
-
* If this entity is focusable (can be focused by tab key pressing).
|
31143
|
-
*/
|
31144
|
-
get isFocusable() {
|
31145
|
-
if (this._isFocusable) {
|
31146
|
-
return this._isFocusable;
|
31147
|
-
}
|
31148
|
-
if (this.entity instanceof gui_2D_controls_button__WEBPACK_IMPORTED_MODULE_1__.Button) {
|
31149
|
-
this._isFocusable = true;
|
31150
|
-
}
|
31151
|
-
else {
|
31152
|
-
this._isFocusable = false;
|
31153
|
-
}
|
31154
|
-
return this._isFocusable;
|
31155
|
-
}
|
31156
|
-
/**
|
31157
|
-
* Callback when the HTML element is focused. Show visual indication on BabylonJS entity.
|
31158
|
-
*/
|
31159
|
-
focus() {
|
31160
|
-
// If defined eventHandler, override default.
|
31161
|
-
const eventHandler = this.entity.accessibilityTag?.eventHandler;
|
31162
|
-
if (eventHandler?.focus) {
|
31163
|
-
eventHandler.focus();
|
31164
|
-
return;
|
31165
|
-
}
|
31166
|
-
const control = this.entity;
|
31167
|
-
control.highlightLineWidth = 10;
|
31168
|
-
control.isHighlighted = true;
|
31169
|
-
}
|
31170
|
-
/**
|
31171
|
-
* Callback when the HTML element is blured. Dismiss visual indication on BabylonJS entity.
|
31172
|
-
*/
|
31173
|
-
blur() {
|
31174
|
-
// If defined eventHandler, override default.
|
31175
|
-
const eventHandler = this.entity.accessibilityTag?.eventHandler;
|
31176
|
-
if (eventHandler?.blur) {
|
31177
|
-
eventHandler.blur();
|
31178
|
-
return;
|
31179
|
-
}
|
31180
|
-
const control = this.entity;
|
31181
|
-
control.isHighlighted = false;
|
31182
|
-
}
|
31183
|
-
/**
|
31184
|
-
* Callback when an event (e.g. click/right click) happens on the HTML element.
|
31185
|
-
* Implemented by child classes
|
31186
|
-
* @param eventType - Which event is triggered. E.g. "click", "contextmenu"
|
31187
|
-
*/
|
31188
|
-
triggerEvent(eventType) {
|
31189
|
-
const eventHandler = this.entity.accessibilityTag?.eventHandler;
|
31190
|
-
switch (eventType) {
|
31191
|
-
case "click":
|
31192
|
-
if (eventHandler?.click) {
|
31193
|
-
eventHandler.click();
|
31194
|
-
return;
|
31195
|
-
}
|
31196
|
-
if (!this.isActionable)
|
31197
|
-
return;
|
31198
|
-
this.entity.onPointerClickObservable.notifyObservers(new gui_2D_controls_button__WEBPACK_IMPORTED_MODULE_1__.Vector2WithInfo(new core_Maths_math__WEBPACK_IMPORTED_MODULE_0__.Vector2(this.scene.pointerX, this.scene.pointerY)));
|
31199
|
-
break;
|
31200
|
-
case "contextmenu":
|
31201
|
-
if (eventHandler?.contextmenu) {
|
31202
|
-
eventHandler.contextmenu();
|
31203
|
-
return;
|
31204
|
-
}
|
31205
|
-
break;
|
31206
|
-
default:
|
31207
|
-
break;
|
31208
|
-
}
|
31209
|
-
}
|
31210
|
-
}
|
31087
|
+
|
31088
|
+
|
31089
|
+
|
31090
|
+
|
31091
|
+
|
31092
|
+
|
31093
|
+
/**
|
31094
|
+
* A abstract layer to store the html twin tree structure. It is constructed from the BabylonJS scene entities that need to be accessible. It informs the parent-children relationship of html twin tree, and informs how to render: description, isActionable, onclick/onrightclick/onfocus/onblur.
|
31095
|
+
*/
|
31096
|
+
class HTMLTwinGUIItem extends _htmlTwinItem__WEBPACK_IMPORTED_MODULE_2__.HTMLTwinItem {
|
31097
|
+
constructor(entity, scene, children) {
|
31098
|
+
super(entity, scene, children);
|
31099
|
+
}
|
31100
|
+
/**
|
31101
|
+
* The text content displayed in HTML element.
|
31102
|
+
*/
|
31103
|
+
get description() {
|
31104
|
+
let description = "";
|
31105
|
+
if (this.entity.accessibilityTag?.description) {
|
31106
|
+
description = this.entity.accessibilityTag.description;
|
31107
|
+
}
|
31108
|
+
else if (this.entity instanceof gui_2D_controls_button__WEBPACK_IMPORTED_MODULE_1__.TextBlock) {
|
31109
|
+
description = this.entity.text;
|
31110
|
+
}
|
31111
|
+
else if (this.entity instanceof gui_2D_controls_button__WEBPACK_IMPORTED_MODULE_1__.Button) {
|
31112
|
+
description = this.entity.textBlock?.text ?? "";
|
31113
|
+
}
|
31114
|
+
else if (this.entity instanceof gui_2D_controls_button__WEBPACK_IMPORTED_MODULE_1__.Image) {
|
31115
|
+
description = this.entity.alt ?? "";
|
31116
|
+
}
|
31117
|
+
return description;
|
31118
|
+
}
|
31119
|
+
/**
|
31120
|
+
* If this entity is actionable (can be clicked).
|
31121
|
+
*/
|
31122
|
+
get isActionable() {
|
31123
|
+
if (this._isActionable) {
|
31124
|
+
return this._isActionable;
|
31125
|
+
}
|
31126
|
+
// If defined onclick, override default.
|
31127
|
+
const eventHandler = this.entity.accessibilityTag?.eventHandler;
|
31128
|
+
if (eventHandler?.click || eventHandler?.contextmenu) {
|
31129
|
+
this._isActionable = true;
|
31130
|
+
}
|
31131
|
+
else {
|
31132
|
+
if (this.entity instanceof gui_2D_controls_button__WEBPACK_IMPORTED_MODULE_1__.Button) {
|
31133
|
+
this._isActionable = true;
|
31134
|
+
}
|
31135
|
+
else {
|
31136
|
+
this._isActionable = false;
|
31137
|
+
}
|
31138
|
+
}
|
31139
|
+
return this._isActionable;
|
31140
|
+
}
|
31141
|
+
/**
|
31142
|
+
* If this entity is focusable (can be focused by tab key pressing).
|
31143
|
+
*/
|
31144
|
+
get isFocusable() {
|
31145
|
+
if (this._isFocusable) {
|
31146
|
+
return this._isFocusable;
|
31147
|
+
}
|
31148
|
+
if (this.entity instanceof gui_2D_controls_button__WEBPACK_IMPORTED_MODULE_1__.Button) {
|
31149
|
+
this._isFocusable = true;
|
31150
|
+
}
|
31151
|
+
else {
|
31152
|
+
this._isFocusable = false;
|
31153
|
+
}
|
31154
|
+
return this._isFocusable;
|
31155
|
+
}
|
31156
|
+
/**
|
31157
|
+
* Callback when the HTML element is focused. Show visual indication on BabylonJS entity.
|
31158
|
+
*/
|
31159
|
+
focus() {
|
31160
|
+
// If defined eventHandler, override default.
|
31161
|
+
const eventHandler = this.entity.accessibilityTag?.eventHandler;
|
31162
|
+
if (eventHandler?.focus) {
|
31163
|
+
eventHandler.focus();
|
31164
|
+
return;
|
31165
|
+
}
|
31166
|
+
const control = this.entity;
|
31167
|
+
control.highlightLineWidth = 10;
|
31168
|
+
control.isHighlighted = true;
|
31169
|
+
}
|
31170
|
+
/**
|
31171
|
+
* Callback when the HTML element is blured. Dismiss visual indication on BabylonJS entity.
|
31172
|
+
*/
|
31173
|
+
blur() {
|
31174
|
+
// If defined eventHandler, override default.
|
31175
|
+
const eventHandler = this.entity.accessibilityTag?.eventHandler;
|
31176
|
+
if (eventHandler?.blur) {
|
31177
|
+
eventHandler.blur();
|
31178
|
+
return;
|
31179
|
+
}
|
31180
|
+
const control = this.entity;
|
31181
|
+
control.isHighlighted = false;
|
31182
|
+
}
|
31183
|
+
/**
|
31184
|
+
* Callback when an event (e.g. click/right click) happens on the HTML element.
|
31185
|
+
* Implemented by child classes
|
31186
|
+
* @param eventType - Which event is triggered. E.g. "click", "contextmenu"
|
31187
|
+
*/
|
31188
|
+
triggerEvent(eventType) {
|
31189
|
+
const eventHandler = this.entity.accessibilityTag?.eventHandler;
|
31190
|
+
switch (eventType) {
|
31191
|
+
case "click":
|
31192
|
+
if (eventHandler?.click) {
|
31193
|
+
eventHandler.click();
|
31194
|
+
return;
|
31195
|
+
}
|
31196
|
+
if (!this.isActionable)
|
31197
|
+
return;
|
31198
|
+
this.entity.onPointerClickObservable.notifyObservers(new gui_2D_controls_button__WEBPACK_IMPORTED_MODULE_1__.Vector2WithInfo(new core_Maths_math__WEBPACK_IMPORTED_MODULE_0__.Vector2(this.scene.pointerX, this.scene.pointerY)));
|
31199
|
+
break;
|
31200
|
+
case "contextmenu":
|
31201
|
+
if (eventHandler?.contextmenu) {
|
31202
|
+
eventHandler.contextmenu();
|
31203
|
+
return;
|
31204
|
+
}
|
31205
|
+
break;
|
31206
|
+
default:
|
31207
|
+
break;
|
31208
|
+
}
|
31209
|
+
}
|
31210
|
+
}
|
31211
31211
|
|
31212
31212
|
|
31213
31213
|
/***/ }),
|
@@ -31231,186 +31231,186 @@ __webpack_require__.r(__webpack_exports__);
|
|
31231
31231
|
/* harmony import */ var core_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(core_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__);
|
31232
31232
|
/* harmony import */ var gui_2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! gui/2D/controls/container */ "gui/2D/advancedDynamicTexture");
|
31233
31233
|
/* harmony import */ var gui_2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(gui_2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_6__);
|
31234
|
-
|
31235
|
-
|
31236
|
-
|
31237
|
-
|
31238
|
-
|
31239
|
-
|
31240
|
-
|
31241
|
-
|
31242
|
-
|
31243
|
-
class HTMLTwinHostComponent extends react__WEBPACK_IMPORTED_MODULE_1__.Component {
|
31244
|
-
constructor(props) {
|
31245
|
-
super(props);
|
31246
|
-
this._observersMap = new Map();
|
31247
|
-
const a11yTreeItems = this._updateHTMLTwinItems();
|
31248
|
-
this.state = {
|
31249
|
-
a11yTreeItems: a11yTreeItems,
|
31250
|
-
};
|
31251
|
-
}
|
31252
|
-
componentDidMount() {
|
31253
|
-
const scene = this.props.scene;
|
31254
|
-
// Find all a11y entities in the scene, assemble the a11y forest (a11yTreeItems), and update React state to let React update DOM.
|
31255
|
-
const updateA11yTree = () => {
|
31256
|
-
const a11yTreeItems = this._updateHTMLTwinItems();
|
31257
|
-
this.setState({
|
31258
|
-
a11yTreeItems: a11yTreeItems,
|
31259
|
-
});
|
31260
|
-
};
|
31261
|
-
const addGUIObservers = (control) => {
|
31262
|
-
// observe isVisible changed
|
31263
|
-
if (!this._observersMap.has(control.onIsVisibleChangedObservable)) {
|
31264
|
-
this._observersMap.set(control.onIsVisibleChangedObservable, control.onIsVisibleChangedObservable.add(updateA11yTree));
|
31265
|
-
}
|
31266
|
-
if (!this._observersMap.has(control.onAccessibilityTagChangedObservable)) {
|
31267
|
-
this._observersMap.set(control.onAccessibilityTagChangedObservable, control.onAccessibilityTagChangedObservable.add(updateA11yTree));
|
31268
|
-
}
|
31269
|
-
if (control instanceof gui_2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_6__.Container) {
|
31270
|
-
const container = control;
|
31271
|
-
// observe add control and deal with new controls
|
31272
|
-
if (!this._observersMap.has(container.onControlAddedObservable)) {
|
31273
|
-
this._observersMap.set(container.onControlAddedObservable, container.onControlAddedObservable.add((newControl) => {
|
31274
|
-
if (newControl) {
|
31275
|
-
// deal with the new added control
|
31276
|
-
addGUIObservers(newControl);
|
31277
|
-
}
|
31278
|
-
updateA11yTree();
|
31279
|
-
}));
|
31280
|
-
}
|
31281
|
-
// observe remove control
|
31282
|
-
if (!this._observersMap.has(container.onControlRemovedObservable)) {
|
31283
|
-
this._observersMap.set(container.onControlRemovedObservable, container.onControlRemovedObservable.add((removedControl) => {
|
31284
|
-
updateA11yTree();
|
31285
|
-
}));
|
31286
|
-
}
|
31287
|
-
// deal with children
|
31288
|
-
control._children.forEach((child) => {
|
31289
|
-
addGUIObservers(child);
|
31290
|
-
});
|
31291
|
-
}
|
31292
|
-
};
|
31293
|
-
const addNodeObservers = (node) => {
|
31294
|
-
if (!this._observersMap.has(node.onEnabledStateChangedObservable)) {
|
31295
|
-
this._observersMap.set(node.onEnabledStateChangedObservable, node.onEnabledStateChangedObservable.add(updateA11yTree));
|
31296
|
-
}
|
31297
|
-
if (!this._observersMap.has(node.onAccessibilityTagChangedObservable)) {
|
31298
|
-
this._observersMap.set(node.onAccessibilityTagChangedObservable, node.onAccessibilityTagChangedObservable.add(updateA11yTree));
|
31299
|
-
}
|
31300
|
-
// If the node has GUI, add observer to the controls
|
31301
|
-
if (this._isGUI(node)) {
|
31302
|
-
const curMesh = node;
|
31303
|
-
const adt = curMesh.material?.getActiveTextures()[0];
|
31304
|
-
const guiRoot = adt.getChildren();
|
31305
|
-
guiRoot.forEach((control) => addGUIObservers(control));
|
31306
|
-
}
|
31307
|
-
};
|
31308
|
-
// observe add node and deal with new nodes
|
31309
|
-
if (!this._observersMap.has(scene.onNewMeshAddedObservable)) {
|
31310
|
-
this._observersMap.set(scene.onNewMeshAddedObservable, scene.onNewMeshAddedObservable.add((newNode) => {
|
31311
|
-
updateA11yTree();
|
31312
|
-
addNodeObservers(newNode);
|
31313
|
-
}));
|
31314
|
-
}
|
31315
|
-
if (!this._observersMap.has(scene.onNewTransformNodeAddedObservable)) {
|
31316
|
-
this._observersMap.set(scene.onNewTransformNodeAddedObservable, scene.onNewTransformNodeAddedObservable.add((newNode) => {
|
31317
|
-
updateA11yTree();
|
31318
|
-
addNodeObservers(newNode);
|
31319
|
-
}));
|
31320
|
-
}
|
31321
|
-
// observe remove node
|
31322
|
-
if (!this._observersMap.has(scene.onMeshRemovedObservable)) {
|
31323
|
-
this._observersMap.set(scene.onMeshRemovedObservable, scene.onMeshRemovedObservable.add(updateA11yTree));
|
31324
|
-
}
|
31325
|
-
if (!this._observersMap.has(scene.onTransformNodeRemovedObservable)) {
|
31326
|
-
this._observersMap.set(scene.onTransformNodeRemovedObservable, scene.onTransformNodeRemovedObservable.add(updateA11yTree));
|
31327
|
-
}
|
31328
|
-
// observe node enabled changed
|
31329
|
-
scene.getNodes().forEach((node) => {
|
31330
|
-
addNodeObservers(node);
|
31331
|
-
});
|
31332
|
-
}
|
31333
|
-
componentWillUnmount() {
|
31334
|
-
this._observersMap.forEach((observer, observable) => {
|
31335
|
-
observable.remove(observer);
|
31336
|
-
});
|
31337
|
-
this._observersMap.clear();
|
31338
|
-
}
|
31339
|
-
render() {
|
31340
|
-
return ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div", { id: "accessibility-host", children: this.state.a11yTreeItems.map((item) => {
|
31341
|
-
return ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_htmlTwinTreeComponent__WEBPACK_IMPORTED_MODULE_2__.HTMLTwinItemComponent, { a11yItem: item, level: 1 }, item.entity.uniqueId !== undefined && item.entity.uniqueId !== null ? item.entity.uniqueId : item.entity.name));
|
31342
|
-
}) }));
|
31343
|
-
}
|
31344
|
-
_updateHTMLTwinItems() {
|
31345
|
-
// Get html twin tree's root nodes
|
31346
|
-
const rootNodes = this.props.scene.rootNodes.slice(0);
|
31347
|
-
for (const mesh of this.props.scene.meshes) {
|
31348
|
-
// Adding nodes that are parented to a bone
|
31349
|
-
if (mesh.parent && mesh.parent.getClassName() === "Bone") {
|
31350
|
-
rootNodes.push(mesh);
|
31351
|
-
}
|
31352
|
-
}
|
31353
|
-
const a11yTreeItems = this._getHTMLTwinItemsFromNodes(rootNodes);
|
31354
|
-
return a11yTreeItems;
|
31355
|
-
}
|
31356
|
-
_getHTMLTwinItemsFromNodes(rootItems) {
|
31357
|
-
if (!rootItems || rootItems.length === 0) {
|
31358
|
-
return [];
|
31359
|
-
}
|
31360
|
-
const result = [];
|
31361
|
-
const queue = [...rootItems];
|
31362
|
-
for (let i = 0; i < queue.length; i++) {
|
31363
|
-
const curNode = queue[i];
|
31364
|
-
if (!curNode.isEnabled()) {
|
31365
|
-
continue;
|
31366
|
-
}
|
31367
|
-
if (this._isGUI(curNode)) {
|
31368
|
-
// if node texture is GUI, add that as a a11y GUI item (renders differently)
|
31369
|
-
const curMesh = curNode;
|
31370
|
-
const adt = curMesh.material?.getActiveTextures()[0];
|
31371
|
-
const guiRoot = adt.getChildren();
|
31372
|
-
result.push(new _htmlTwinNodeItem__WEBPACK_IMPORTED_MODULE_4__.HTMLTwinNodeItem(curNode, this.props.scene, this._getHTMLTwinItemsFromGUI(guiRoot)));
|
31373
|
-
}
|
31374
|
-
else if (curNode.accessibilityTag) {
|
31375
|
-
result.push(new _htmlTwinNodeItem__WEBPACK_IMPORTED_MODULE_4__.HTMLTwinNodeItem(curNode, this.props.scene, this._getHTMLTwinItemsFromNodes(curNode.getChildren())));
|
31376
|
-
}
|
31377
|
-
else {
|
31378
|
-
queue.push(...curNode.getChildren());
|
31379
|
-
}
|
31380
|
-
}
|
31381
|
-
return result;
|
31382
|
-
}
|
31383
|
-
_getHTMLTwinItemsFromGUI(rootItems) {
|
31384
|
-
if (!rootItems || rootItems.length === 0) {
|
31385
|
-
return [];
|
31386
|
-
}
|
31387
|
-
const result = [];
|
31388
|
-
const queue = [...rootItems];
|
31389
|
-
for (let i = 0; i < queue.length; i++) {
|
31390
|
-
const curNode = queue[i];
|
31391
|
-
if (!curNode.isVisible) {
|
31392
|
-
continue;
|
31393
|
-
}
|
31394
|
-
if (curNode instanceof gui_2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_6__.Container && curNode.children.length !== 0 && !(curNode instanceof gui_2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_6__.Button)) {
|
31395
|
-
const curContainer = curNode;
|
31396
|
-
result.push(new _htmlTwinGUIItem__WEBPACK_IMPORTED_MODULE_3__.HTMLTwinGUIItem(curContainer, this.props.scene, this._getHTMLTwinItemsFromGUI(curContainer.children)));
|
31397
|
-
}
|
31398
|
-
else {
|
31399
|
-
result.push(new _htmlTwinGUIItem__WEBPACK_IMPORTED_MODULE_3__.HTMLTwinGUIItem(curNode, this.props.scene, []));
|
31400
|
-
}
|
31401
|
-
}
|
31402
|
-
return result;
|
31403
|
-
}
|
31404
|
-
_isGUI(node) {
|
31405
|
-
let isGUI = false;
|
31406
|
-
if (node instanceof core_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__.AbstractMesh) {
|
31407
|
-
const curMesh = node;
|
31408
|
-
const textures = curMesh.material?.getActiveTextures();
|
31409
|
-
isGUI = !!textures && textures[0] instanceof gui_2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_6__.AdvancedDynamicTexture;
|
31410
|
-
}
|
31411
|
-
return isGUI;
|
31412
|
-
}
|
31413
|
-
}
|
31234
|
+
|
31235
|
+
|
31236
|
+
|
31237
|
+
|
31238
|
+
|
31239
|
+
|
31240
|
+
|
31241
|
+
|
31242
|
+
|
31243
|
+
class HTMLTwinHostComponent extends react__WEBPACK_IMPORTED_MODULE_1__.Component {
|
31244
|
+
constructor(props) {
|
31245
|
+
super(props);
|
31246
|
+
this._observersMap = new Map();
|
31247
|
+
const a11yTreeItems = this._updateHTMLTwinItems();
|
31248
|
+
this.state = {
|
31249
|
+
a11yTreeItems: a11yTreeItems,
|
31250
|
+
};
|
31251
|
+
}
|
31252
|
+
componentDidMount() {
|
31253
|
+
const scene = this.props.scene;
|
31254
|
+
// Find all a11y entities in the scene, assemble the a11y forest (a11yTreeItems), and update React state to let React update DOM.
|
31255
|
+
const updateA11yTree = () => {
|
31256
|
+
const a11yTreeItems = this._updateHTMLTwinItems();
|
31257
|
+
this.setState({
|
31258
|
+
a11yTreeItems: a11yTreeItems,
|
31259
|
+
});
|
31260
|
+
};
|
31261
|
+
const addGUIObservers = (control) => {
|
31262
|
+
// observe isVisible changed
|
31263
|
+
if (!this._observersMap.has(control.onIsVisibleChangedObservable)) {
|
31264
|
+
this._observersMap.set(control.onIsVisibleChangedObservable, control.onIsVisibleChangedObservable.add(updateA11yTree));
|
31265
|
+
}
|
31266
|
+
if (!this._observersMap.has(control.onAccessibilityTagChangedObservable)) {
|
31267
|
+
this._observersMap.set(control.onAccessibilityTagChangedObservable, control.onAccessibilityTagChangedObservable.add(updateA11yTree));
|
31268
|
+
}
|
31269
|
+
if (control instanceof gui_2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_6__.Container) {
|
31270
|
+
const container = control;
|
31271
|
+
// observe add control and deal with new controls
|
31272
|
+
if (!this._observersMap.has(container.onControlAddedObservable)) {
|
31273
|
+
this._observersMap.set(container.onControlAddedObservable, container.onControlAddedObservable.add((newControl) => {
|
31274
|
+
if (newControl) {
|
31275
|
+
// deal with the new added control
|
31276
|
+
addGUIObservers(newControl);
|
31277
|
+
}
|
31278
|
+
updateA11yTree();
|
31279
|
+
}));
|
31280
|
+
}
|
31281
|
+
// observe remove control
|
31282
|
+
if (!this._observersMap.has(container.onControlRemovedObservable)) {
|
31283
|
+
this._observersMap.set(container.onControlRemovedObservable, container.onControlRemovedObservable.add((removedControl) => {
|
31284
|
+
updateA11yTree();
|
31285
|
+
}));
|
31286
|
+
}
|
31287
|
+
// deal with children
|
31288
|
+
control._children.forEach((child) => {
|
31289
|
+
addGUIObservers(child);
|
31290
|
+
});
|
31291
|
+
}
|
31292
|
+
};
|
31293
|
+
const addNodeObservers = (node) => {
|
31294
|
+
if (!this._observersMap.has(node.onEnabledStateChangedObservable)) {
|
31295
|
+
this._observersMap.set(node.onEnabledStateChangedObservable, node.onEnabledStateChangedObservable.add(updateA11yTree));
|
31296
|
+
}
|
31297
|
+
if (!this._observersMap.has(node.onAccessibilityTagChangedObservable)) {
|
31298
|
+
this._observersMap.set(node.onAccessibilityTagChangedObservable, node.onAccessibilityTagChangedObservable.add(updateA11yTree));
|
31299
|
+
}
|
31300
|
+
// If the node has GUI, add observer to the controls
|
31301
|
+
if (this._isGUI(node)) {
|
31302
|
+
const curMesh = node;
|
31303
|
+
const adt = curMesh.material?.getActiveTextures()[0];
|
31304
|
+
const guiRoot = adt.getChildren();
|
31305
|
+
guiRoot.forEach((control) => addGUIObservers(control));
|
31306
|
+
}
|
31307
|
+
};
|
31308
|
+
// observe add node and deal with new nodes
|
31309
|
+
if (!this._observersMap.has(scene.onNewMeshAddedObservable)) {
|
31310
|
+
this._observersMap.set(scene.onNewMeshAddedObservable, scene.onNewMeshAddedObservable.add((newNode) => {
|
31311
|
+
updateA11yTree();
|
31312
|
+
addNodeObservers(newNode);
|
31313
|
+
}));
|
31314
|
+
}
|
31315
|
+
if (!this._observersMap.has(scene.onNewTransformNodeAddedObservable)) {
|
31316
|
+
this._observersMap.set(scene.onNewTransformNodeAddedObservable, scene.onNewTransformNodeAddedObservable.add((newNode) => {
|
31317
|
+
updateA11yTree();
|
31318
|
+
addNodeObservers(newNode);
|
31319
|
+
}));
|
31320
|
+
}
|
31321
|
+
// observe remove node
|
31322
|
+
if (!this._observersMap.has(scene.onMeshRemovedObservable)) {
|
31323
|
+
this._observersMap.set(scene.onMeshRemovedObservable, scene.onMeshRemovedObservable.add(updateA11yTree));
|
31324
|
+
}
|
31325
|
+
if (!this._observersMap.has(scene.onTransformNodeRemovedObservable)) {
|
31326
|
+
this._observersMap.set(scene.onTransformNodeRemovedObservable, scene.onTransformNodeRemovedObservable.add(updateA11yTree));
|
31327
|
+
}
|
31328
|
+
// observe node enabled changed
|
31329
|
+
scene.getNodes().forEach((node) => {
|
31330
|
+
addNodeObservers(node);
|
31331
|
+
});
|
31332
|
+
}
|
31333
|
+
componentWillUnmount() {
|
31334
|
+
this._observersMap.forEach((observer, observable) => {
|
31335
|
+
observable.remove(observer);
|
31336
|
+
});
|
31337
|
+
this._observersMap.clear();
|
31338
|
+
}
|
31339
|
+
render() {
|
31340
|
+
return ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div", { id: "accessibility-host", children: this.state.a11yTreeItems.map((item) => {
|
31341
|
+
return ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_htmlTwinTreeComponent__WEBPACK_IMPORTED_MODULE_2__.HTMLTwinItemComponent, { a11yItem: item, level: 1 }, item.entity.uniqueId !== undefined && item.entity.uniqueId !== null ? item.entity.uniqueId : item.entity.name));
|
31342
|
+
}) }));
|
31343
|
+
}
|
31344
|
+
_updateHTMLTwinItems() {
|
31345
|
+
// Get html twin tree's root nodes
|
31346
|
+
const rootNodes = this.props.scene.rootNodes.slice(0);
|
31347
|
+
for (const mesh of this.props.scene.meshes) {
|
31348
|
+
// Adding nodes that are parented to a bone
|
31349
|
+
if (mesh.parent && mesh.parent.getClassName() === "Bone") {
|
31350
|
+
rootNodes.push(mesh);
|
31351
|
+
}
|
31352
|
+
}
|
31353
|
+
const a11yTreeItems = this._getHTMLTwinItemsFromNodes(rootNodes);
|
31354
|
+
return a11yTreeItems;
|
31355
|
+
}
|
31356
|
+
_getHTMLTwinItemsFromNodes(rootItems) {
|
31357
|
+
if (!rootItems || rootItems.length === 0) {
|
31358
|
+
return [];
|
31359
|
+
}
|
31360
|
+
const result = [];
|
31361
|
+
const queue = [...rootItems];
|
31362
|
+
for (let i = 0; i < queue.length; i++) {
|
31363
|
+
const curNode = queue[i];
|
31364
|
+
if (!curNode.isEnabled()) {
|
31365
|
+
continue;
|
31366
|
+
}
|
31367
|
+
if (this._isGUI(curNode)) {
|
31368
|
+
// if node texture is GUI, add that as a a11y GUI item (renders differently)
|
31369
|
+
const curMesh = curNode;
|
31370
|
+
const adt = curMesh.material?.getActiveTextures()[0];
|
31371
|
+
const guiRoot = adt.getChildren();
|
31372
|
+
result.push(new _htmlTwinNodeItem__WEBPACK_IMPORTED_MODULE_4__.HTMLTwinNodeItem(curNode, this.props.scene, this._getHTMLTwinItemsFromGUI(guiRoot)));
|
31373
|
+
}
|
31374
|
+
else if (curNode.accessibilityTag) {
|
31375
|
+
result.push(new _htmlTwinNodeItem__WEBPACK_IMPORTED_MODULE_4__.HTMLTwinNodeItem(curNode, this.props.scene, this._getHTMLTwinItemsFromNodes(curNode.getChildren())));
|
31376
|
+
}
|
31377
|
+
else {
|
31378
|
+
queue.push(...curNode.getChildren());
|
31379
|
+
}
|
31380
|
+
}
|
31381
|
+
return result;
|
31382
|
+
}
|
31383
|
+
_getHTMLTwinItemsFromGUI(rootItems) {
|
31384
|
+
if (!rootItems || rootItems.length === 0) {
|
31385
|
+
return [];
|
31386
|
+
}
|
31387
|
+
const result = [];
|
31388
|
+
const queue = [...rootItems];
|
31389
|
+
for (let i = 0; i < queue.length; i++) {
|
31390
|
+
const curNode = queue[i];
|
31391
|
+
if (!curNode.isVisible) {
|
31392
|
+
continue;
|
31393
|
+
}
|
31394
|
+
if (curNode instanceof gui_2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_6__.Container && curNode.children.length !== 0 && !(curNode instanceof gui_2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_6__.Button)) {
|
31395
|
+
const curContainer = curNode;
|
31396
|
+
result.push(new _htmlTwinGUIItem__WEBPACK_IMPORTED_MODULE_3__.HTMLTwinGUIItem(curContainer, this.props.scene, this._getHTMLTwinItemsFromGUI(curContainer.children)));
|
31397
|
+
}
|
31398
|
+
else {
|
31399
|
+
result.push(new _htmlTwinGUIItem__WEBPACK_IMPORTED_MODULE_3__.HTMLTwinGUIItem(curNode, this.props.scene, []));
|
31400
|
+
}
|
31401
|
+
}
|
31402
|
+
return result;
|
31403
|
+
}
|
31404
|
+
_isGUI(node) {
|
31405
|
+
let isGUI = false;
|
31406
|
+
if (node instanceof core_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__.AbstractMesh) {
|
31407
|
+
const curMesh = node;
|
31408
|
+
const textures = curMesh.material?.getActiveTextures();
|
31409
|
+
isGUI = !!textures && textures[0] instanceof gui_2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_6__.AdvancedDynamicTexture;
|
31410
|
+
}
|
31411
|
+
return isGUI;
|
31412
|
+
}
|
31413
|
+
}
|
31414
31414
|
|
31415
31415
|
|
31416
31416
|
/***/ }),
|
@@ -31425,53 +31425,53 @@ __webpack_require__.r(__webpack_exports__);
|
|
31425
31425
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
31426
31426
|
/* harmony export */ "HTMLTwinItem": () => (/* binding */ HTMLTwinItem)
|
31427
31427
|
/* harmony export */ });
|
31428
|
-
/**
|
31429
|
-
* A abstract layer to store the html twin tree structure. It is constructed from the BabylonJS scene entities that need to be accessible. It informs the parent-children relationship of html twin tree, and informs how to render: description, isActionable, onclick/onrightclick/onfocus/onblur.
|
31430
|
-
*/
|
31431
|
-
class HTMLTwinItem {
|
31432
|
-
constructor(entity, scene, children) {
|
31433
|
-
this.entity = entity;
|
31434
|
-
this.scene = scene;
|
31435
|
-
this.children = children;
|
31436
|
-
}
|
31437
|
-
/**
|
31438
|
-
* The text content displayed in HTML element.
|
31439
|
-
* Returns the description in accessibilityTag, if defined (returns "" by default).
|
31440
|
-
*/
|
31441
|
-
get description() {
|
31442
|
-
return this.entity.accessibilityTag?.description ?? "";
|
31443
|
-
}
|
31444
|
-
/**
|
31445
|
-
* If this entity is actionable (can be clicked).
|
31446
|
-
* Implemented by child classes
|
31447
|
-
*/
|
31448
|
-
get isActionable() {
|
31449
|
-
return this._isActionable;
|
31450
|
-
}
|
31451
|
-
/**
|
31452
|
-
* If this entity is focusable (can be focused by tab key pressing).
|
31453
|
-
* Implemented by child classes
|
31454
|
-
*/
|
31455
|
-
get isFocusable() {
|
31456
|
-
return this._isFocusable;
|
31457
|
-
}
|
31458
|
-
/**
|
31459
|
-
* Callback when the HTML element is focused. Show visual indication on BabylonJS entity.
|
31460
|
-
* Implemented by child classes
|
31461
|
-
*/
|
31462
|
-
focus() { }
|
31463
|
-
/**
|
31464
|
-
* Callback when the HTML element is blured. Dismiss visual indication on BabylonJS entity.
|
31465
|
-
* Implemented by child classes
|
31466
|
-
*/
|
31467
|
-
blur() { }
|
31468
|
-
/**
|
31469
|
-
* Callback when an event (e.g. click/right click) happens on the HTML element.
|
31470
|
-
* Implemented by child classes
|
31471
|
-
* @param _eventType - Which event is triggered. E.g. "click", "contextmenu"
|
31472
|
-
*/
|
31473
|
-
triggerEvent(_eventType) { }
|
31474
|
-
}
|
31428
|
+
/**
|
31429
|
+
* A abstract layer to store the html twin tree structure. It is constructed from the BabylonJS scene entities that need to be accessible. It informs the parent-children relationship of html twin tree, and informs how to render: description, isActionable, onclick/onrightclick/onfocus/onblur.
|
31430
|
+
*/
|
31431
|
+
class HTMLTwinItem {
|
31432
|
+
constructor(entity, scene, children) {
|
31433
|
+
this.entity = entity;
|
31434
|
+
this.scene = scene;
|
31435
|
+
this.children = children;
|
31436
|
+
}
|
31437
|
+
/**
|
31438
|
+
* The text content displayed in HTML element.
|
31439
|
+
* Returns the description in accessibilityTag, if defined (returns "" by default).
|
31440
|
+
*/
|
31441
|
+
get description() {
|
31442
|
+
return this.entity.accessibilityTag?.description ?? "";
|
31443
|
+
}
|
31444
|
+
/**
|
31445
|
+
* If this entity is actionable (can be clicked).
|
31446
|
+
* Implemented by child classes
|
31447
|
+
*/
|
31448
|
+
get isActionable() {
|
31449
|
+
return this._isActionable;
|
31450
|
+
}
|
31451
|
+
/**
|
31452
|
+
* If this entity is focusable (can be focused by tab key pressing).
|
31453
|
+
* Implemented by child classes
|
31454
|
+
*/
|
31455
|
+
get isFocusable() {
|
31456
|
+
return this._isFocusable;
|
31457
|
+
}
|
31458
|
+
/**
|
31459
|
+
* Callback when the HTML element is focused. Show visual indication on BabylonJS entity.
|
31460
|
+
* Implemented by child classes
|
31461
|
+
*/
|
31462
|
+
focus() { }
|
31463
|
+
/**
|
31464
|
+
* Callback when the HTML element is blured. Dismiss visual indication on BabylonJS entity.
|
31465
|
+
* Implemented by child classes
|
31466
|
+
*/
|
31467
|
+
blur() { }
|
31468
|
+
/**
|
31469
|
+
* Callback when an event (e.g. click/right click) happens on the HTML element.
|
31470
|
+
* Implemented by child classes
|
31471
|
+
* @param _eventType - Which event is triggered. E.g. "click", "contextmenu"
|
31472
|
+
*/
|
31473
|
+
triggerEvent(_eventType) { }
|
31474
|
+
}
|
31475
31475
|
|
31476
31476
|
|
31477
31477
|
/***/ }),
|
@@ -31489,115 +31489,115 @@ __webpack_require__.r(__webpack_exports__);
|
|
31489
31489
|
/* harmony import */ var core_Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Meshes/mesh */ "core/Meshes/abstractMesh");
|
31490
31490
|
/* harmony import */ var core_Engines_constants__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Engines_constants__WEBPACK_IMPORTED_MODULE_0__);
|
31491
31491
|
/* harmony import */ var _htmlTwinItem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./htmlTwinItem */ "../../../tools/accessibility/dist/HtmlTwin/htmlTwinItem.js");
|
31492
|
-
|
31493
|
-
|
31494
|
-
|
31495
|
-
|
31496
|
-
/**
|
31497
|
-
* A abstract layer to store the html twin tree structure. It is constructed from the BabylonJS scene entities that need to be accessible. It informs the parent-children relationship of html twin tree, and informs how to render: description, isActionable, onclick/onrightclick/onfocus/onblur.
|
31498
|
-
*/
|
31499
|
-
class HTMLTwinNodeItem extends _htmlTwinItem__WEBPACK_IMPORTED_MODULE_1__.HTMLTwinItem {
|
31500
|
-
constructor(entity, scene, children) {
|
31501
|
-
super(entity, scene, children);
|
31502
|
-
}
|
31503
|
-
/**
|
31504
|
-
* If this entity is actionable (can be clicked).
|
31505
|
-
*/
|
31506
|
-
get isActionable() {
|
31507
|
-
if (this._isActionable) {
|
31508
|
-
return this._isActionable;
|
31509
|
-
}
|
31510
|
-
// If defined onclick, override default.
|
31511
|
-
const eventHandler = this.entity.accessibilityTag?.eventHandler;
|
31512
|
-
if (eventHandler?.click || eventHandler?.contextmenu) {
|
31513
|
-
this._isActionable = true;
|
31514
|
-
}
|
31515
|
-
else {
|
31516
|
-
this._isActionable = this.entity._getActionManagerForTrigger()?.hasPickTriggers;
|
31517
|
-
}
|
31518
|
-
return this._isActionable;
|
31519
|
-
}
|
31520
|
-
/**
|
31521
|
-
* If this entity is focusable (can be focused by tab key pressing).
|
31522
|
-
*/
|
31523
|
-
get isFocusable() {
|
31524
|
-
if (this._isFocusable) {
|
31525
|
-
return this._isFocusable;
|
31526
|
-
}
|
31527
|
-
else {
|
31528
|
-
this._isFocusable = this.isActionable;
|
31529
|
-
}
|
31530
|
-
return this._isFocusable;
|
31531
|
-
}
|
31532
|
-
/**
|
31533
|
-
* Callback when the HTML element is focused. Show visual indication on BabylonJS entity.
|
31534
|
-
*/
|
31535
|
-
focus() {
|
31536
|
-
// If defined eventHandler, override default.
|
31537
|
-
const eventHandler = this.entity.accessibilityTag?.eventHandler;
|
31538
|
-
if (eventHandler?.focus) {
|
31539
|
-
eventHandler.focus();
|
31540
|
-
return;
|
31541
|
-
}
|
31542
|
-
if (this.entity instanceof core_Engines_constants__WEBPACK_IMPORTED_MODULE_0__.Mesh) {
|
31543
|
-
const mesh = this.entity;
|
31544
|
-
mesh.enableEdgesRendering(0.999);
|
31545
|
-
mesh.edgesWidth = 5;
|
31546
|
-
mesh.edgesColor = new core_Engines_constants__WEBPACK_IMPORTED_MODULE_0__.Color4(0.25, 0.5, 1, 1);
|
31547
|
-
}
|
31548
|
-
}
|
31549
|
-
/**
|
31550
|
-
* Callback when the HTML element is blured. Dismiss visual indication on BabylonJS entity.
|
31551
|
-
*/
|
31552
|
-
blur() {
|
31553
|
-
// If defined eventHandler, override default.
|
31554
|
-
const eventHandler = this.entity.accessibilityTag?.eventHandler;
|
31555
|
-
if (eventHandler?.blur) {
|
31556
|
-
eventHandler.blur();
|
31557
|
-
return;
|
31558
|
-
}
|
31559
|
-
if (this.entity instanceof core_Engines_constants__WEBPACK_IMPORTED_MODULE_0__.Mesh) {
|
31560
|
-
const mesh = this.entity;
|
31561
|
-
mesh.disableEdgesRendering();
|
31562
|
-
}
|
31563
|
-
}
|
31564
|
-
/**
|
31565
|
-
* Callback when an event (e.g. click/right click) happens on the HTML element.
|
31566
|
-
* Implemented by child classes
|
31567
|
-
* @param eventType - Which event is triggered. E.g. "click", "contextmenu"
|
31568
|
-
*/
|
31569
|
-
triggerEvent(eventType) {
|
31570
|
-
const eventHandler = this.entity.accessibilityTag?.eventHandler;
|
31571
|
-
const actions = [];
|
31572
|
-
switch (eventType) {
|
31573
|
-
case "click":
|
31574
|
-
if (eventHandler?.click) {
|
31575
|
-
eventHandler.click();
|
31576
|
-
return;
|
31577
|
-
}
|
31578
|
-
actions.push(...this._getTriggerActions(this.entity, core_Engines_constants__WEBPACK_IMPORTED_MODULE_0__.Constants.ACTION_OnLeftPickTrigger));
|
31579
|
-
actions.push(...this._getTriggerActions(this.entity, core_Engines_constants__WEBPACK_IMPORTED_MODULE_0__.Constants.ACTION_OnPickTrigger));
|
31580
|
-
break;
|
31581
|
-
case "contextmenu":
|
31582
|
-
if (eventHandler?.contextmenu) {
|
31583
|
-
eventHandler.contextmenu();
|
31584
|
-
return;
|
31585
|
-
}
|
31586
|
-
actions.push(...this._getTriggerActions(this.entity, core_Engines_constants__WEBPACK_IMPORTED_MODULE_0__.Constants.ACTION_OnRightPickTrigger));
|
31587
|
-
actions.push(...this._getTriggerActions(this.entity, core_Engines_constants__WEBPACK_IMPORTED_MODULE_0__.Constants.ACTION_OnPickTrigger));
|
31588
|
-
break;
|
31589
|
-
default:
|
31590
|
-
break;
|
31591
|
-
}
|
31592
|
-
actions.forEach((action) => {
|
31593
|
-
action._executeCurrent();
|
31594
|
-
});
|
31595
|
-
}
|
31596
|
-
_getTriggerActions(node, trigger) {
|
31597
|
-
const triggerActions = node._getActionManagerForTrigger(trigger)?.actions.filter((action) => action.trigger == trigger);
|
31598
|
-
return triggerActions ?? [];
|
31599
|
-
}
|
31600
|
-
}
|
31492
|
+
|
31493
|
+
|
31494
|
+
|
31495
|
+
|
31496
|
+
/**
|
31497
|
+
* A abstract layer to store the html twin tree structure. It is constructed from the BabylonJS scene entities that need to be accessible. It informs the parent-children relationship of html twin tree, and informs how to render: description, isActionable, onclick/onrightclick/onfocus/onblur.
|
31498
|
+
*/
|
31499
|
+
class HTMLTwinNodeItem extends _htmlTwinItem__WEBPACK_IMPORTED_MODULE_1__.HTMLTwinItem {
|
31500
|
+
constructor(entity, scene, children) {
|
31501
|
+
super(entity, scene, children);
|
31502
|
+
}
|
31503
|
+
/**
|
31504
|
+
* If this entity is actionable (can be clicked).
|
31505
|
+
*/
|
31506
|
+
get isActionable() {
|
31507
|
+
if (this._isActionable) {
|
31508
|
+
return this._isActionable;
|
31509
|
+
}
|
31510
|
+
// If defined onclick, override default.
|
31511
|
+
const eventHandler = this.entity.accessibilityTag?.eventHandler;
|
31512
|
+
if (eventHandler?.click || eventHandler?.contextmenu) {
|
31513
|
+
this._isActionable = true;
|
31514
|
+
}
|
31515
|
+
else {
|
31516
|
+
this._isActionable = this.entity._getActionManagerForTrigger()?.hasPickTriggers;
|
31517
|
+
}
|
31518
|
+
return this._isActionable;
|
31519
|
+
}
|
31520
|
+
/**
|
31521
|
+
* If this entity is focusable (can be focused by tab key pressing).
|
31522
|
+
*/
|
31523
|
+
get isFocusable() {
|
31524
|
+
if (this._isFocusable) {
|
31525
|
+
return this._isFocusable;
|
31526
|
+
}
|
31527
|
+
else {
|
31528
|
+
this._isFocusable = this.isActionable;
|
31529
|
+
}
|
31530
|
+
return this._isFocusable;
|
31531
|
+
}
|
31532
|
+
/**
|
31533
|
+
* Callback when the HTML element is focused. Show visual indication on BabylonJS entity.
|
31534
|
+
*/
|
31535
|
+
focus() {
|
31536
|
+
// If defined eventHandler, override default.
|
31537
|
+
const eventHandler = this.entity.accessibilityTag?.eventHandler;
|
31538
|
+
if (eventHandler?.focus) {
|
31539
|
+
eventHandler.focus();
|
31540
|
+
return;
|
31541
|
+
}
|
31542
|
+
if (this.entity instanceof core_Engines_constants__WEBPACK_IMPORTED_MODULE_0__.Mesh) {
|
31543
|
+
const mesh = this.entity;
|
31544
|
+
mesh.enableEdgesRendering(0.999);
|
31545
|
+
mesh.edgesWidth = 5;
|
31546
|
+
mesh.edgesColor = new core_Engines_constants__WEBPACK_IMPORTED_MODULE_0__.Color4(0.25, 0.5, 1, 1);
|
31547
|
+
}
|
31548
|
+
}
|
31549
|
+
/**
|
31550
|
+
* Callback when the HTML element is blured. Dismiss visual indication on BabylonJS entity.
|
31551
|
+
*/
|
31552
|
+
blur() {
|
31553
|
+
// If defined eventHandler, override default.
|
31554
|
+
const eventHandler = this.entity.accessibilityTag?.eventHandler;
|
31555
|
+
if (eventHandler?.blur) {
|
31556
|
+
eventHandler.blur();
|
31557
|
+
return;
|
31558
|
+
}
|
31559
|
+
if (this.entity instanceof core_Engines_constants__WEBPACK_IMPORTED_MODULE_0__.Mesh) {
|
31560
|
+
const mesh = this.entity;
|
31561
|
+
mesh.disableEdgesRendering();
|
31562
|
+
}
|
31563
|
+
}
|
31564
|
+
/**
|
31565
|
+
* Callback when an event (e.g. click/right click) happens on the HTML element.
|
31566
|
+
* Implemented by child classes
|
31567
|
+
* @param eventType - Which event is triggered. E.g. "click", "contextmenu"
|
31568
|
+
*/
|
31569
|
+
triggerEvent(eventType) {
|
31570
|
+
const eventHandler = this.entity.accessibilityTag?.eventHandler;
|
31571
|
+
const actions = [];
|
31572
|
+
switch (eventType) {
|
31573
|
+
case "click":
|
31574
|
+
if (eventHandler?.click) {
|
31575
|
+
eventHandler.click();
|
31576
|
+
return;
|
31577
|
+
}
|
31578
|
+
actions.push(...this._getTriggerActions(this.entity, core_Engines_constants__WEBPACK_IMPORTED_MODULE_0__.Constants.ACTION_OnLeftPickTrigger));
|
31579
|
+
actions.push(...this._getTriggerActions(this.entity, core_Engines_constants__WEBPACK_IMPORTED_MODULE_0__.Constants.ACTION_OnPickTrigger));
|
31580
|
+
break;
|
31581
|
+
case "contextmenu":
|
31582
|
+
if (eventHandler?.contextmenu) {
|
31583
|
+
eventHandler.contextmenu();
|
31584
|
+
return;
|
31585
|
+
}
|
31586
|
+
actions.push(...this._getTriggerActions(this.entity, core_Engines_constants__WEBPACK_IMPORTED_MODULE_0__.Constants.ACTION_OnRightPickTrigger));
|
31587
|
+
actions.push(...this._getTriggerActions(this.entity, core_Engines_constants__WEBPACK_IMPORTED_MODULE_0__.Constants.ACTION_OnPickTrigger));
|
31588
|
+
break;
|
31589
|
+
default:
|
31590
|
+
break;
|
31591
|
+
}
|
31592
|
+
actions.forEach((action) => {
|
31593
|
+
action._executeCurrent();
|
31594
|
+
});
|
31595
|
+
}
|
31596
|
+
_getTriggerActions(node, trigger) {
|
31597
|
+
const triggerActions = node._getActionManagerForTrigger(trigger)?.actions.filter((action) => action.trigger == trigger);
|
31598
|
+
return triggerActions ?? [];
|
31599
|
+
}
|
31600
|
+
}
|
31601
31601
|
|
31602
31602
|
|
31603
31603
|
/***/ }),
|
@@ -31615,17 +31615,17 @@ __webpack_require__.r(__webpack_exports__);
|
|
31615
31615
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../../node_modules/react/index.js");
|
31616
31616
|
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ "../../../../node_modules/react-dom/index.js");
|
31617
31617
|
/* harmony import */ var _htmlTwinHostComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./htmlTwinHostComponent */ "../../../tools/accessibility/dist/HtmlTwin/htmlTwinHostComponent.js");
|
31618
|
-
|
31619
|
-
|
31620
|
-
|
31621
|
-
class HTMLTwinRenderer {
|
31622
|
-
static Render(scene) {
|
31623
|
-
const htmlTwinHost = react__WEBPACK_IMPORTED_MODULE_0__.createElement(_htmlTwinHostComponent__WEBPACK_IMPORTED_MODULE_2__.HTMLTwinHostComponent, {
|
31624
|
-
scene,
|
31625
|
-
});
|
31626
|
-
react_dom__WEBPACK_IMPORTED_MODULE_1__.render(htmlTwinHost, scene.getEngine().getRenderingCanvas());
|
31627
|
-
}
|
31628
|
-
}
|
31618
|
+
|
31619
|
+
|
31620
|
+
|
31621
|
+
class HTMLTwinRenderer {
|
31622
|
+
static Render(scene) {
|
31623
|
+
const htmlTwinHost = react__WEBPACK_IMPORTED_MODULE_0__.createElement(_htmlTwinHostComponent__WEBPACK_IMPORTED_MODULE_2__.HTMLTwinHostComponent, {
|
31624
|
+
scene,
|
31625
|
+
});
|
31626
|
+
react_dom__WEBPACK_IMPORTED_MODULE_1__.render(htmlTwinHost, scene.getEngine().getRenderingCanvas());
|
31627
|
+
}
|
31628
|
+
}
|
31629
31629
|
|
31630
31630
|
|
31631
31631
|
/***/ }),
|
@@ -31642,54 +31642,54 @@ __webpack_require__.r(__webpack_exports__);
|
|
31642
31642
|
/* harmony export */ });
|
31643
31643
|
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-runtime */ "../../../../node_modules/react/jsx-runtime.js");
|
31644
31644
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "../../../../node_modules/react/index.js");
|
31645
|
-
|
31646
|
-
|
31647
|
-
class HTMLTwinItemComponent extends react__WEBPACK_IMPORTED_MODULE_1__.Component {
|
31648
|
-
constructor(props) {
|
31649
|
-
super(props);
|
31650
|
-
}
|
31651
|
-
render() {
|
31652
|
-
const item = this.props.a11yItem;
|
31653
|
-
if (item.children.length === 0) {
|
31654
|
-
return this._renderLeafNode(item);
|
31655
|
-
}
|
31656
|
-
else {
|
31657
|
-
return this._renderParentNode(item, this.props.level);
|
31658
|
-
}
|
31659
|
-
}
|
31660
|
-
_renderLeafNode(a11yItem) {
|
31661
|
-
if (a11yItem.isActionable) {
|
31662
|
-
return ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("button", { onClick: () => {
|
31663
|
-
a11yItem.triggerEvent("click");
|
31664
|
-
}, onContextMenu: () => {
|
31665
|
-
a11yItem.triggerEvent("contextmenu");
|
31666
|
-
}, tabIndex: a11yItem.isFocusable ? 0 : -1, onFocus: () => {
|
31667
|
-
a11yItem.focus();
|
31668
|
-
}, onBlur: () => {
|
31669
|
-
a11yItem.blur();
|
31670
|
-
}, role: a11yItem.entity.accessibilityTag?.role, ...a11yItem.entity.accessibilityTag?.aria, children: a11yItem.description }));
|
31671
|
-
}
|
31672
|
-
else {
|
31673
|
-
return ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div", { tabIndex: a11yItem.isFocusable ? 0 : -1, onFocus: () => {
|
31674
|
-
a11yItem.focus();
|
31675
|
-
}, onBlur: () => {
|
31676
|
-
a11yItem.blur();
|
31677
|
-
}, role: a11yItem.entity.accessibilityTag?.role, ...a11yItem.entity.accessibilityTag?.aria, children: a11yItem.description }));
|
31678
|
-
}
|
31679
|
-
}
|
31680
|
-
_renderParentNode(a11yItem, level) {
|
31681
|
-
return ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", { children: [!!a11yItem.description && ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div", { role: a11yItem.entity.accessibilityTag?.role ?? "heading", "aria-level": level, tabIndex: a11yItem.isFocusable ? 0 : -1, onFocus: () => {
|
31682
|
-
a11yItem.focus();
|
31683
|
-
}, onBlur: () => {
|
31684
|
-
a11yItem.blur();
|
31685
|
-
}, ...a11yItem.entity.accessibilityTag?.aria, children: a11yItem.description })), this._renderChildren(a11yItem.children, Math.min(level + 1, 6))] }));
|
31686
|
-
}
|
31687
|
-
_renderChildren(children, level) {
|
31688
|
-
return children.map((child) => {
|
31689
|
-
return ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(HTMLTwinItemComponent, { a11yItem: child, level: level }, child.entity.uniqueId !== undefined && child.entity.uniqueId !== null ? child.entity.uniqueId : child.entity.name));
|
31690
|
-
});
|
31691
|
-
}
|
31692
|
-
}
|
31645
|
+
|
31646
|
+
|
31647
|
+
class HTMLTwinItemComponent extends react__WEBPACK_IMPORTED_MODULE_1__.Component {
|
31648
|
+
constructor(props) {
|
31649
|
+
super(props);
|
31650
|
+
}
|
31651
|
+
render() {
|
31652
|
+
const item = this.props.a11yItem;
|
31653
|
+
if (item.children.length === 0) {
|
31654
|
+
return this._renderLeafNode(item);
|
31655
|
+
}
|
31656
|
+
else {
|
31657
|
+
return this._renderParentNode(item, this.props.level);
|
31658
|
+
}
|
31659
|
+
}
|
31660
|
+
_renderLeafNode(a11yItem) {
|
31661
|
+
if (a11yItem.isActionable) {
|
31662
|
+
return ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("button", { onClick: () => {
|
31663
|
+
a11yItem.triggerEvent("click");
|
31664
|
+
}, onContextMenu: () => {
|
31665
|
+
a11yItem.triggerEvent("contextmenu");
|
31666
|
+
}, tabIndex: a11yItem.isFocusable ? 0 : -1, onFocus: () => {
|
31667
|
+
a11yItem.focus();
|
31668
|
+
}, onBlur: () => {
|
31669
|
+
a11yItem.blur();
|
31670
|
+
}, role: a11yItem.entity.accessibilityTag?.role, ...a11yItem.entity.accessibilityTag?.aria, children: a11yItem.description }));
|
31671
|
+
}
|
31672
|
+
else {
|
31673
|
+
return ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div", { tabIndex: a11yItem.isFocusable ? 0 : -1, onFocus: () => {
|
31674
|
+
a11yItem.focus();
|
31675
|
+
}, onBlur: () => {
|
31676
|
+
a11yItem.blur();
|
31677
|
+
}, role: a11yItem.entity.accessibilityTag?.role, ...a11yItem.entity.accessibilityTag?.aria, children: a11yItem.description }));
|
31678
|
+
}
|
31679
|
+
}
|
31680
|
+
_renderParentNode(a11yItem, level) {
|
31681
|
+
return ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", { children: [!!a11yItem.description && ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div", { role: a11yItem.entity.accessibilityTag?.role ?? "heading", "aria-level": level, tabIndex: a11yItem.isFocusable ? 0 : -1, onFocus: () => {
|
31682
|
+
a11yItem.focus();
|
31683
|
+
}, onBlur: () => {
|
31684
|
+
a11yItem.blur();
|
31685
|
+
}, ...a11yItem.entity.accessibilityTag?.aria, children: a11yItem.description })), this._renderChildren(a11yItem.children, Math.min(level + 1, 6))] }));
|
31686
|
+
}
|
31687
|
+
_renderChildren(children, level) {
|
31688
|
+
return children.map((child) => {
|
31689
|
+
return ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(HTMLTwinItemComponent, { a11yItem: child, level: level }, child.entity.uniqueId !== undefined && child.entity.uniqueId !== null ? child.entity.uniqueId : child.entity.name));
|
31690
|
+
});
|
31691
|
+
}
|
31692
|
+
}
|
31693
31693
|
|
31694
31694
|
|
31695
31695
|
/***/ }),
|
@@ -31705,7 +31705,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
31705
31705
|
/* harmony export */ "HTMLTwinRenderer": () => (/* reexport safe */ _htmlTwinRenderer__WEBPACK_IMPORTED_MODULE_0__.HTMLTwinRenderer)
|
31706
31706
|
/* harmony export */ });
|
31707
31707
|
/* harmony import */ var _htmlTwinRenderer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./htmlTwinRenderer */ "../../../tools/accessibility/dist/HtmlTwin/htmlTwinRenderer.js");
|
31708
|
-
|
31708
|
+
|
31709
31709
|
|
31710
31710
|
|
31711
31711
|
/***/ }),
|
@@ -31721,8 +31721,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
31721
31721
|
/* harmony export */ "HTMLTwinRenderer": () => (/* reexport safe */ _HtmlTwin_index__WEBPACK_IMPORTED_MODULE_0__.HTMLTwinRenderer)
|
31722
31722
|
/* harmony export */ });
|
31723
31723
|
/* harmony import */ var _HtmlTwin_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./HtmlTwin/index */ "../../../tools/accessibility/dist/HtmlTwin/index.js");
|
31724
|
-
// eslint-disable-next-line import/no-internal-modules
|
31725
|
-
|
31724
|
+
// eslint-disable-next-line import/no-internal-modules
|
31725
|
+
|
31726
31726
|
|
31727
31727
|
|
31728
31728
|
/***/ }),
|
@@ -31738,17 +31738,17 @@ __webpack_require__.r(__webpack_exports__);
|
|
31738
31738
|
/* harmony export */ "HTMLTwinRenderer": () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_0__.HTMLTwinRenderer)
|
31739
31739
|
/* harmony export */ });
|
31740
31740
|
/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "../../../tools/accessibility/dist/index.js");
|
31741
|
-
/* eslint-disable import/no-internal-modules */
|
31742
|
-
|
31743
|
-
const globalObject = typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof window !== "undefined" ? window : undefined;
|
31744
|
-
if (typeof globalObject !== "undefined") {
|
31745
|
-
globalObject.BABYLON = globalObject.BABYLON || {};
|
31746
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
31747
|
-
globalObject.BABYLON.Accessibility = { HTMLTwinRenderer: _index__WEBPACK_IMPORTED_MODULE_0__.HTMLTwinRenderer };
|
31748
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
31749
|
-
globalObject.ACCESSIBILITY = { HTMLTwinRenderer: _index__WEBPACK_IMPORTED_MODULE_0__.HTMLTwinRenderer };
|
31750
|
-
}
|
31751
|
-
|
31741
|
+
/* eslint-disable import/no-internal-modules */
|
31742
|
+
|
31743
|
+
const globalObject = typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof window !== "undefined" ? window : undefined;
|
31744
|
+
if (typeof globalObject !== "undefined") {
|
31745
|
+
globalObject.BABYLON = globalObject.BABYLON || {};
|
31746
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
31747
|
+
globalObject.BABYLON.Accessibility = { HTMLTwinRenderer: _index__WEBPACK_IMPORTED_MODULE_0__.HTMLTwinRenderer };
|
31748
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
31749
|
+
globalObject.ACCESSIBILITY = { HTMLTwinRenderer: _index__WEBPACK_IMPORTED_MODULE_0__.HTMLTwinRenderer };
|
31750
|
+
}
|
31751
|
+
|
31752
31752
|
|
31753
31753
|
|
31754
31754
|
/***/ }),
|
@@ -31865,9 +31865,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
31865
31865
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
31866
31866
|
/* harmony export */ });
|
31867
31867
|
/* harmony import */ var accessibility_legacy_legacy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! accessibility/legacy/legacy */ "../../../tools/accessibility/dist/legacy/legacy.js");
|
31868
|
-
|
31869
|
-
|
31870
|
-
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (accessibility_legacy_legacy__WEBPACK_IMPORTED_MODULE_0__);
|
31868
|
+
|
31869
|
+
|
31870
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (accessibility_legacy_legacy__WEBPACK_IMPORTED_MODULE_0__);
|
31871
31871
|
|
31872
31872
|
})();
|
31873
31873
|
|