@needle-tools/engine 4.14.0 → 4.15.0-next.f391a30
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/CHANGELOG.md +8 -0
- package/components.needle.json +1 -1
- package/dist/{gltf-progressive-BttGBXw6.umd.cjs → gltf-progressive-CMwJPwEt.umd.cjs} +1 -1
- package/dist/{gltf-progressive-Bm_6aEi4.js → gltf-progressive-CTlvpS3A.js} +1 -1
- package/dist/{gltf-progressive-T5WKTux5.min.js → gltf-progressive-DYL3SLVb.min.js} +1 -1
- package/dist/materialx-4jJLLe9Q.js +4174 -0
- package/dist/materialx-Bt9FHwco.min.js +158 -0
- package/dist/materialx-NDD0y4JY.umd.cjs +158 -0
- package/dist/{needle-engine.bundle-COL2Bar3.umd.cjs → needle-engine.bundle-C1BFRZDF.umd.cjs} +150 -140
- package/dist/{needle-engine.bundle-Z_gAD7Kg.js → needle-engine.bundle-DB4kLWO_.js} +6651 -6400
- package/dist/{needle-engine.bundle-NolzHLqO.min.js → needle-engine.bundle-DsTdfmeb.min.js} +151 -141
- package/dist/needle-engine.d.ts +345 -88
- package/dist/needle-engine.js +322 -322
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/{postprocessing-06AXuvdv.min.js → postprocessing-BN-f4viE.min.js} +1 -1
- package/dist/{postprocessing-CPDcA21P.umd.cjs → postprocessing-DYmYOVm4.umd.cjs} +1 -1
- package/dist/{postprocessing-CI2x8Cln.js → postprocessing-De9ZpJrk.js} +1 -1
- package/dist/{three-examples-BMmNgNCN.umd.cjs → three-examples-BHqRVpO_.umd.cjs} +12 -12
- package/dist/{three-examples-CMYCd5nH.js → three-examples-C0ZCCA_K.js} +182 -192
- package/dist/{three-examples-CQl1fFZp.min.js → three-examples-DmTY8tGr.min.js} +14 -14
- package/lib/engine/api.d.ts +0 -2
- package/lib/engine/api.js +0 -2
- package/lib/engine/api.js.map +1 -1
- package/lib/engine/debug/debug.js +1 -1
- package/lib/engine/debug/debug.js.map +1 -1
- package/lib/engine/debug/debug_spatial_console.js +1 -1
- package/lib/engine/debug/debug_spatial_console.js.map +1 -1
- package/lib/engine/engine_accessibility.d.ts +77 -0
- package/lib/engine/engine_accessibility.js +162 -0
- package/lib/engine/engine_accessibility.js.map +1 -0
- package/lib/engine/engine_context.d.ts +2 -0
- package/lib/engine/engine_context.js +8 -1
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_create_objects.js +1 -1
- package/lib/engine/engine_create_objects.js.map +1 -1
- package/lib/engine/engine_gizmos.js +1 -1
- package/lib/engine/engine_gizmos.js.map +1 -1
- package/lib/engine/engine_license.js +7 -2
- package/lib/engine/engine_license.js.map +1 -1
- package/lib/engine/engine_materialpropertyblock.d.ts +90 -4
- package/lib/engine/engine_materialpropertyblock.js +97 -7
- package/lib/engine/engine_materialpropertyblock.js.map +1 -1
- package/lib/engine/engine_math.d.ts +34 -1
- package/lib/engine/engine_math.js +34 -1
- package/lib/engine/engine_math.js.map +1 -1
- package/lib/engine/engine_networking.js +1 -1
- package/lib/engine/engine_networking.js.map +1 -1
- package/lib/engine/engine_types.d.ts +2 -0
- package/lib/engine/engine_types.js +2 -0
- package/lib/engine/engine_types.js.map +1 -1
- package/lib/engine/engine_utils.js +2 -2
- package/lib/engine/engine_utils.js.map +1 -1
- package/lib/engine/export/gltf/EXT_mesh_gpu_instancing_exporter.js.map +1 -0
- package/lib/engine/export/gltf/index.js +1 -1
- package/lib/engine/export/gltf/index.js.map +1 -1
- package/lib/engine/webcomponents/icons.js +3 -0
- package/lib/engine/webcomponents/icons.js.map +1 -1
- package/lib/engine/webcomponents/logo-element.d.ts +7 -3
- package/lib/engine/webcomponents/logo-element.js +21 -1
- package/lib/engine/webcomponents/logo-element.js.map +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js +2 -2
- package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js.map +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu.d.ts +10 -7
- package/lib/engine/webcomponents/needle menu/needle-menu.js +14 -4
- package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
- package/lib/engine/webcomponents/needle-button.d.ts +37 -11
- package/lib/engine/webcomponents/needle-button.js +42 -11
- package/lib/engine/webcomponents/needle-button.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.ar-overlay.js +10 -1
- package/lib/engine/webcomponents/needle-engine.ar-overlay.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.d.ts +13 -2
- package/lib/engine/webcomponents/needle-engine.js +23 -3
- package/lib/engine/webcomponents/needle-engine.js.map +1 -1
- package/lib/engine-components/Component.d.ts +1 -2
- package/lib/engine-components/Component.js +1 -3
- package/lib/engine-components/Component.js.map +1 -1
- package/lib/engine-components/DragControls.d.ts +1 -0
- package/lib/engine-components/DragControls.js +21 -0
- package/lib/engine-components/DragControls.js.map +1 -1
- package/lib/engine-components/NeedleMenu.d.ts +2 -0
- package/lib/engine-components/NeedleMenu.js +2 -0
- package/lib/engine-components/NeedleMenu.js.map +1 -1
- package/lib/engine-components/Networking.d.ts +28 -3
- package/lib/engine-components/Networking.js +28 -3
- package/lib/engine-components/Networking.js.map +1 -1
- package/lib/engine-components/ReflectionProbe.d.ts +25 -2
- package/lib/engine-components/ReflectionProbe.js +46 -2
- package/lib/engine-components/ReflectionProbe.js.map +1 -1
- package/lib/engine-components/Skybox.js +4 -2
- package/lib/engine-components/Skybox.js.map +1 -1
- package/lib/engine-components/export/gltf/GltfExport.js +1 -1
- package/lib/engine-components/export/gltf/GltfExport.js.map +1 -1
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.js +2 -2
- package/lib/engine-components/export/usdz/USDZExporter.js +1 -1
- package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.d.ts +15 -0
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js +77 -0
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js.map +1 -1
- package/lib/engine-components/export/usdz/extensions/behavior/PhysicsExtension.js +2 -2
- package/lib/engine-components/export/usdz/extensions/behavior/PhysicsExtension.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/Tonemapping.utils.d.ts +1 -1
- package/lib/engine-components/ui/Button.d.ts +1 -0
- package/lib/engine-components/ui/Button.js +11 -0
- package/lib/engine-components/ui/Button.js.map +1 -1
- package/lib/engine-components/ui/Text.d.ts +1 -0
- package/lib/engine-components/ui/Text.js +11 -0
- package/lib/engine-components/ui/Text.js.map +1 -1
- package/package.json +18 -14
- package/plugins/common/buildinfo.js +46 -10
- package/plugins/common/files.js +2 -1
- package/plugins/common/license.js +144 -69
- package/plugins/common/logger.js +172 -11
- package/plugins/common/needle-engine-skill.md +175 -0
- package/plugins/common/worker.js +5 -4
- package/plugins/types/userconfig.d.ts +40 -2
- package/plugins/vite/ai.js +71 -0
- package/plugins/vite/alias.js +6 -5
- package/plugins/vite/asap.js +6 -5
- package/plugins/vite/build-pipeline.js +224 -41
- package/plugins/vite/buildinfo.js +66 -6
- package/plugins/vite/copyfiles.js +41 -12
- package/plugins/vite/custom-element-data.js +26 -16
- package/plugins/vite/defines.js +8 -5
- package/plugins/vite/dependencies.js +16 -10
- package/plugins/vite/dependency-watcher.js +35 -7
- package/plugins/vite/drop-client.js +7 -5
- package/plugins/vite/drop.js +16 -14
- package/plugins/vite/editor-connection.js +18 -16
- package/plugins/vite/imports-logger.js +12 -2
- package/plugins/vite/index.js +8 -3
- package/plugins/vite/local-files-analysis.js +789 -0
- package/plugins/vite/local-files-core.js +992 -0
- package/plugins/vite/local-files-internals.js +28 -0
- package/plugins/vite/local-files-types.d.ts +111 -0
- package/plugins/vite/local-files-utils.js +359 -0
- package/plugins/vite/local-files.js +2 -441
- package/plugins/vite/logger.client.js +45 -35
- package/plugins/vite/logger.js +6 -3
- package/plugins/vite/logging.js +129 -0
- package/plugins/vite/meta.js +18 -4
- package/plugins/vite/needle-app.js +4 -3
- package/plugins/vite/peer.js +2 -1
- package/plugins/vite/pwa.js +33 -17
- package/plugins/vite/reload.js +24 -2
- package/src/engine/api.ts +0 -3
- package/src/engine/debug/debug.ts +1 -1
- package/src/engine/debug/debug_spatial_console.ts +5 -1
- package/src/engine/engine_accessibility.ts +198 -0
- package/src/engine/engine_context.ts +10 -1
- package/src/engine/engine_create_objects.ts +1 -1
- package/src/engine/engine_gizmos.ts +9 -5
- package/src/engine/engine_license.ts +7 -2
- package/src/engine/engine_materialpropertyblock.ts +102 -11
- package/src/engine/engine_math.ts +34 -1
- package/src/engine/engine_networking.ts +1 -1
- package/src/engine/engine_types.ts +5 -0
- package/src/engine/engine_utils.ts +2 -2
- package/src/engine/export/gltf/index.ts +1 -1
- package/src/engine/webcomponents/icons.ts +3 -0
- package/src/engine/webcomponents/logo-element.ts +24 -4
- package/src/engine/webcomponents/needle menu/needle-menu-spatial.ts +6 -2
- package/src/engine/webcomponents/needle menu/needle-menu.ts +23 -11
- package/src/engine/webcomponents/needle-button.ts +44 -13
- package/src/engine/webcomponents/needle-engine.ar-overlay.ts +13 -2
- package/src/engine/webcomponents/needle-engine.ts +31 -8
- package/src/engine-components/Component.ts +2 -5
- package/src/engine-components/DragControls.ts +29 -4
- package/src/engine-components/NeedleMenu.ts +5 -3
- package/src/engine-components/Networking.ts +29 -4
- package/src/engine-components/ReflectionProbe.ts +52 -9
- package/src/engine-components/Skybox.ts +4 -2
- package/src/engine-components/export/gltf/GltfExport.ts +1 -1
- package/src/engine-components/export/usdz/ThreeUSDZExporter.ts +2 -2
- package/src/engine-components/export/usdz/USDZExporter.ts +1 -1
- package/src/engine-components/export/usdz/extensions/behavior/BehaviourComponents.ts +108 -32
- package/src/engine-components/export/usdz/extensions/behavior/PhysicsExtension.ts +2 -2
- package/src/engine-components/ui/Button.ts +12 -0
- package/src/engine-components/ui/Text.ts +13 -0
- package/dist/materialx-CJyQZtjt.min.js +0 -90
- package/dist/materialx-DMs1E08Z.js +0 -4636
- package/dist/materialx-DaKKOoVk.umd.cjs +0 -90
- package/lib/engine/engine_test_utils.d.ts +0 -39
- package/lib/engine/engine_test_utils.js +0 -84
- package/lib/engine/engine_test_utils.js.map +0 -1
- package/lib/include/three/EXT_mesh_gpu_instancing_exporter.js.map +0 -1
- package/src/engine/engine_test_utils.ts +0 -109
- package/src/include/draco/draco_decoder.js +0 -34
- package/src/include/draco/draco_decoder.wasm +0 -0
- package/src/include/draco/draco_wasm_wrapper.js +0 -117
- package/src/include/ktx2/basis_transcoder.js +0 -19
- package/src/include/ktx2/basis_transcoder.wasm +0 -0
- package/src/include/needle/arial-msdf.json +0 -1472
- package/src/include/needle/arial.png +0 -0
- package/src/include/needle/poweredbyneedle.webp +0 -0
- /package/lib/{include/three → engine/export/gltf}/EXT_mesh_gpu_instancing_exporter.d.ts +0 -0
- /package/lib/{include/three → engine/export/gltf}/EXT_mesh_gpu_instancing_exporter.js +0 -0
- /package/src/{include/three → engine/export/gltf}/EXT_mesh_gpu_instancing_exporter.js +0 -0
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CubeTexture, EquirectangularReflectionMapping, LinearSRGBColorSpace, Material, Object3D, Texture, Vector3 } from "three";
|
|
2
2
|
|
|
3
|
-
import { isDevEnvironment, showBalloonWarning } from "../engine/debug/index.js";
|
|
4
3
|
import { MaterialPropertyBlock } from "../engine/engine_materialpropertyblock.js";
|
|
4
|
+
import { loadPMREM } from "../engine/engine_pmrem.js";
|
|
5
5
|
import { serializable } from "../engine/engine_serialization.js";
|
|
6
6
|
import { Context } from "../engine/engine_setup.js";
|
|
7
|
-
import
|
|
8
|
-
import { getParam } from "../engine/engine_utils.js";
|
|
7
|
+
import { getParam, resolveUrl } from "../engine/engine_utils.js";
|
|
9
8
|
import { BoxHelperComponent } from "./BoxHelperComponent.js";
|
|
10
9
|
import { Behaviour } from "./Component.js";
|
|
11
10
|
import { EventList } from "./EventList.js";
|
|
@@ -41,7 +40,11 @@ const $reflectionProbeKey = Symbol("reflectionProbeKey");
|
|
|
41
40
|
export class ReflectionProbe extends Behaviour {
|
|
42
41
|
|
|
43
42
|
private static _probes: Map<Context, ReflectionProbe[]> = new Map();
|
|
44
|
-
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Checks if the given material is currently using a reflection probe. This is determined by checking for an override on the material's "envMap" property, which is set by the Renderer component when applying a reflection probe.
|
|
47
|
+
*/
|
|
45
48
|
static isUsingReflectionProbe(material: Material) {
|
|
46
49
|
return !!(material as any)[$reflectionProbeKey];
|
|
47
50
|
}
|
|
@@ -49,8 +52,13 @@ export class ReflectionProbe extends Behaviour {
|
|
|
49
52
|
|
|
50
53
|
/**
|
|
51
54
|
* Event invoked when a reflection probe is enabled. Used internally by Renderer components to update probes when they become active. Not recommended to call this directly in most cases.
|
|
55
|
+
* @see {@link onDisabled} for the corresponding disable event.
|
|
52
56
|
*/
|
|
53
57
|
static readonly onEnabled: EventList<ReflectionProbe> = new EventList();
|
|
58
|
+
/**
|
|
59
|
+
* Event invoked when a reflection probe is disabled. Used internally by Renderer components to update probes when they become inactive. Not recommended to call this directly in most cases.
|
|
60
|
+
* @see {@link onEnabled} for the corresponding enable event.
|
|
61
|
+
*/
|
|
54
62
|
static readonly onDisabled: EventList<ReflectionProbe> = new EventList();
|
|
55
63
|
|
|
56
64
|
/**
|
|
@@ -89,11 +97,35 @@ export class ReflectionProbe extends Behaviour {
|
|
|
89
97
|
return null;
|
|
90
98
|
}
|
|
91
99
|
|
|
92
|
-
private _texture!: Texture;
|
|
100
|
+
private _texture!: Texture | null;
|
|
101
|
+
private _textureUrlInFlight?: string;
|
|
93
102
|
|
|
94
|
-
|
|
95
|
-
|
|
103
|
+
/**
|
|
104
|
+
* The cubemap or HDR texture used for reflections. Can be assigned directly or via a URL string. When assigning via URL, the texture will be loaded asynchronously and applied once ready.
|
|
105
|
+
*/
|
|
106
|
+
@serializable([Texture, String])
|
|
107
|
+
set texture(tex: Texture | null) {
|
|
96
108
|
if (this._texture === tex) return;
|
|
109
|
+
|
|
110
|
+
if (typeof tex === "string") {
|
|
111
|
+
if(debug) console.debug(`[ReflectionProbe] Loading reflection probe texture from URL: ${tex}`);
|
|
112
|
+
this._textureUrlInFlight = tex;
|
|
113
|
+
const textureUrl = resolveUrl(this.sourceId, tex);
|
|
114
|
+
loadPMREM(textureUrl, this.context.renderer).then(loaded => {
|
|
115
|
+
if (this._textureUrlInFlight === tex && loaded) {
|
|
116
|
+
this._textureUrlInFlight = undefined;
|
|
117
|
+
if (debug) console.debug(`[ReflectionProbe] Successfully loaded reflection probe texture: ${tex}`);
|
|
118
|
+
this.texture = loaded;
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// During deserialization / loading of the GLB the deserializer sets an empty DataTexture
|
|
125
|
+
// But if the texture is serialized as a string (via Blender Reflection Probes) then the async loading above
|
|
126
|
+
// Will abort IF textureInFlight is reset (here). That's why we do NOT reset textureInFlight during initialization (when __didAwake is false). Only after awake, when we are sure that the async loading is done, we reset the in-flight URL to allow new assignments.
|
|
127
|
+
if(this.__didAwake) this._textureUrlInFlight = undefined;
|
|
128
|
+
|
|
97
129
|
this._texture = tex;
|
|
98
130
|
|
|
99
131
|
if (debug) console.debug("[ReflectionProbe] Set reflection probe texture " + (tex?.name || "(removed)"));
|
|
@@ -108,7 +140,7 @@ export class ReflectionProbe extends Behaviour {
|
|
|
108
140
|
tex.needsUpdate = true;
|
|
109
141
|
}
|
|
110
142
|
}
|
|
111
|
-
get texture(): Texture {
|
|
143
|
+
get texture(): Texture | null {
|
|
112
144
|
return this._texture;
|
|
113
145
|
}
|
|
114
146
|
|
|
@@ -146,6 +178,7 @@ export class ReflectionProbe extends Behaviour {
|
|
|
146
178
|
ReflectionProbe._probes.get(this.context)?.push(this);
|
|
147
179
|
}
|
|
148
180
|
|
|
181
|
+
/** @internal */
|
|
149
182
|
awake() {
|
|
150
183
|
this._boxHelper = this.gameObject.addComponent(BoxHelperComponent) as BoxHelperComponent;
|
|
151
184
|
this._boxHelper.updateBox(true);
|
|
@@ -159,20 +192,24 @@ export class ReflectionProbe extends Behaviour {
|
|
|
159
192
|
}
|
|
160
193
|
}
|
|
161
194
|
|
|
195
|
+
/** @internal */
|
|
162
196
|
onEnable(): void {
|
|
163
197
|
ReflectionProbe.onEnabled?.invoke(this);
|
|
164
198
|
}
|
|
165
199
|
|
|
200
|
+
/** @internal */
|
|
166
201
|
onDisable(): void {
|
|
167
202
|
ReflectionProbe.onDisabled?.invoke(this);
|
|
168
203
|
}
|
|
169
204
|
|
|
205
|
+
/** @internal */
|
|
170
206
|
start(): void {
|
|
171
207
|
if (!this._texture) {
|
|
172
208
|
console.warn(`[ReflectionProbe] Missing texture. Please assign a custom cubemap texture. To use reflection probes assign them to your renderer's "anchor" property.`);
|
|
173
209
|
}
|
|
174
210
|
}
|
|
175
211
|
|
|
212
|
+
/** @internal */
|
|
176
213
|
onDestroy() {
|
|
177
214
|
const probes = ReflectionProbe._probes.get(this.context);
|
|
178
215
|
if (probes) {
|
|
@@ -183,6 +220,9 @@ export class ReflectionProbe extends Behaviour {
|
|
|
183
220
|
}
|
|
184
221
|
}
|
|
185
222
|
|
|
223
|
+
/**
|
|
224
|
+
* Applies this reflection probe to the given object by setting material property overrides for "envMap", "envMapRotation", and "envMapIntensity". This is typically called by the Renderer component when determining which reflection probe to use for a given object.
|
|
225
|
+
*/
|
|
186
226
|
apply(object: Object3D) {
|
|
187
227
|
if (disable) return;
|
|
188
228
|
if (!this.enabled) return;
|
|
@@ -199,6 +239,9 @@ export class ReflectionProbe extends Behaviour {
|
|
|
199
239
|
propertyBlock.setOverride("envMapIntensity", intensity);
|
|
200
240
|
}
|
|
201
241
|
|
|
242
|
+
/**
|
|
243
|
+
* Removes the reflection probe overrides from the given object. This is typically called by the Renderer component when an object is no longer influenced by this probe or when the probe is disabled.
|
|
244
|
+
*/
|
|
202
245
|
unapply(obj: Object3D) {
|
|
203
246
|
const block = MaterialPropertyBlock.get(obj);
|
|
204
247
|
if (block) {
|
|
@@ -479,8 +479,10 @@ function tryParseMagicSkyboxName(str: string | null | undefined, environment: bo
|
|
|
479
479
|
return useLowRes ? value.url_low : value.url;
|
|
480
480
|
}
|
|
481
481
|
else if (typeof str === "string" && str?.length && (isDevEnvironment() || debug)) {
|
|
482
|
-
|
|
483
|
-
|
|
482
|
+
// Only warn if the string looks like it was meant to be a magic skybox name.
|
|
483
|
+
// Strings that contain "/" or "." are paths or URLs, not magic names.
|
|
484
|
+
const looksLikePath = str.includes("/") || str.includes(".");
|
|
485
|
+
if(!looksLikePath) {
|
|
484
486
|
console.warn(`RemoteSkybox: Unknown magic skybox name "${str}". Valid names are: ${Object.keys(MagicSkyboxNames).map(n => `"${n}"`).join(", ")}`);
|
|
485
487
|
}
|
|
486
488
|
}
|
|
@@ -6,11 +6,11 @@ import { SerializationContext } from "../../../engine/engine_serialization_core.
|
|
|
6
6
|
import { serializable } from "../../../engine/engine_serialization_decorator.js";
|
|
7
7
|
import { getWorldPosition } from "../../../engine/engine_three_utils.js";
|
|
8
8
|
import { getParam } from "../../../engine/engine_utils.js";
|
|
9
|
+
import GLTFMeshGPUInstancingExtension from '../../../engine/export/gltf/EXT_mesh_gpu_instancing_exporter.js';
|
|
9
10
|
import { RenderTextureWriter } from "../../../engine/export/gltf/Writers.js";
|
|
10
11
|
import { shouldExport_HideFlags } from "../../../engine/export/utils.js";
|
|
11
12
|
import { registerExportExtensions } from "../../../engine/extensions/index.js";
|
|
12
13
|
import { NEEDLE_components } from "../../../engine/extensions/NEEDLE_components.js";
|
|
13
|
-
import GLTFMeshGPUInstancingExtension from '../../../include/three/EXT_mesh_gpu_instancing_exporter.js';
|
|
14
14
|
import { BoxHelperComponent } from "../../BoxHelperComponent.js";
|
|
15
15
|
import { Behaviour, GameObject } from "../../Component.js";
|
|
16
16
|
import { Renderer } from "../../Renderer.js";
|
|
@@ -2457,7 +2457,7 @@ ${usedUVChannels.has(0) ? `
|
|
|
2457
2457
|
def Shader "uvReader_st"
|
|
2458
2458
|
{
|
|
2459
2459
|
uniform token info:id = "UsdPrimvarReader_float2"
|
|
2460
|
-
|
|
2460
|
+
string inputs:varname = "st"
|
|
2461
2461
|
float2 inputs:fallback = (0.0, 0.0)
|
|
2462
2462
|
float2 outputs:result
|
|
2463
2463
|
}
|
|
@@ -2466,7 +2466,7 @@ ${usedUVChannels.has(1) ? `
|
|
|
2466
2466
|
def Shader "uvReader_st1"
|
|
2467
2467
|
{
|
|
2468
2468
|
uniform token info:id = "UsdPrimvarReader_float2"
|
|
2469
|
-
|
|
2469
|
+
string inputs:varname = "st1"
|
|
2470
2470
|
float2 inputs:fallback = (0.0, 0.0)
|
|
2471
2471
|
float2 outputs:result
|
|
2472
2472
|
}
|
|
@@ -740,7 +740,7 @@ export class USDZExporter extends Behaviour {
|
|
|
740
740
|
}
|
|
741
741
|
else if (sessionRoot) {
|
|
742
742
|
arScale = sessionRoot.arScale;
|
|
743
|
-
// eslint-disable-next-line
|
|
743
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
744
744
|
_invertForward = sessionRoot.invertForward;
|
|
745
745
|
}
|
|
746
746
|
|
|
@@ -13,12 +13,11 @@ import { AudioSource } from "../../../../AudioSource.js";
|
|
|
13
13
|
import { Behaviour, GameObject } from "../../../../Component.js";
|
|
14
14
|
import { Rigidbody } from "../../../../RigidBody.js";
|
|
15
15
|
import type { IPointerClickHandler, PointerEventData } from "../../../../ui/PointerEvents.js";
|
|
16
|
-
|
|
17
|
-
import { makeNameSafeForUSD,USDDocument, USDObject, USDZExporterContext } from "../../ThreeUSDZExporter.js";
|
|
16
|
+
import { makeNameSafeForUSD, USDDocument, USDObject, USDZExporterContext } from "../../ThreeUSDZExporter.js";
|
|
18
17
|
import { AnimationExtension, RegisteredAnimationInfo, type UsdzAnimation } from "../Animation.js";
|
|
19
18
|
import { AudioExtension } from "./AudioExtension.js";
|
|
20
19
|
import type { BehaviorExtension, UsdzBehaviour } from "./Behaviour.js";
|
|
21
|
-
import { ActionBuilder, ActionModel, BehaviorModel, EmphasizeActionMotionType,GroupActionModel,type IBehaviorElement, Target, TriggerBuilder } from "./BehavioursBuilder.js";
|
|
20
|
+
import { ActionBuilder, ActionModel, BehaviorModel, EmphasizeActionMotionType, GroupActionModel, type IBehaviorElement, Target, TriggerBuilder } from "./BehavioursBuilder.js";
|
|
22
21
|
|
|
23
22
|
const debug = getParam("debugusdzbehaviours");
|
|
24
23
|
|
|
@@ -57,6 +56,22 @@ export class ChangeTransformOnClick extends Behaviour implements IPointerClickHa
|
|
|
57
56
|
private targetRot = new Quaternion();
|
|
58
57
|
private targetScale = new Vector3();
|
|
59
58
|
|
|
59
|
+
onEnable(): void {
|
|
60
|
+
this.context.accessibility.updateElement(this, {
|
|
61
|
+
role: "button",
|
|
62
|
+
label: "Move " + (this.object?.name || "object") + " to " + (this.target?.name || "target") + " on click",
|
|
63
|
+
hidden: false,
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
onDisable(): void {
|
|
67
|
+
this.context.accessibility.updateElement(this, {
|
|
68
|
+
hidden: true,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
onDestroy(): void {
|
|
72
|
+
this.context.accessibility.removeElement(this);
|
|
73
|
+
}
|
|
74
|
+
|
|
60
75
|
onPointerEnter() {
|
|
61
76
|
this.context.input.setCursor("pointer");
|
|
62
77
|
}
|
|
@@ -68,8 +83,8 @@ export class ChangeTransformOnClick extends Behaviour implements IPointerClickHa
|
|
|
68
83
|
|
|
69
84
|
const rbs = this.object?.getComponentsInChildren(Rigidbody);
|
|
70
85
|
|
|
71
|
-
if (rbs){
|
|
72
|
-
for (const rb of rbs) {
|
|
86
|
+
if (rbs) {
|
|
87
|
+
for (const rb of rbs) {
|
|
73
88
|
rb.resetVelocities();
|
|
74
89
|
rb.resetForcesAndTorques();
|
|
75
90
|
}
|
|
@@ -227,6 +242,22 @@ export class ChangeMaterialOnClick extends Behaviour implements IPointerClickHan
|
|
|
227
242
|
}
|
|
228
243
|
}
|
|
229
244
|
|
|
245
|
+
onEnable(): void {
|
|
246
|
+
this.context.accessibility.updateElement(this, {
|
|
247
|
+
role: "button",
|
|
248
|
+
label: "Change material to " + (this.variantMaterial?.name || "unknown material"),
|
|
249
|
+
hidden: false,
|
|
250
|
+
})
|
|
251
|
+
}
|
|
252
|
+
onDisable(): void {
|
|
253
|
+
this.context.accessibility.updateElement(this, {
|
|
254
|
+
hidden: true,
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
onDestroy(): void {
|
|
258
|
+
this.context.accessibility.removeElement(this);
|
|
259
|
+
}
|
|
260
|
+
|
|
230
261
|
onPointerEnter(_args: PointerEventData) {
|
|
231
262
|
this.context.input.setCursor("pointer");
|
|
232
263
|
}
|
|
@@ -427,7 +458,7 @@ export class SetActiveOnClick extends Behaviour implements IPointerClickHandler,
|
|
|
427
458
|
|
|
428
459
|
if (!this.toggleOnClick && this.hideSelf)
|
|
429
460
|
this.gameObject.visible = false;
|
|
430
|
-
|
|
461
|
+
|
|
431
462
|
if (this.target)
|
|
432
463
|
this.target.visible = this.toggleOnClick ? !this.target.visible : this.targetState;
|
|
433
464
|
}
|
|
@@ -453,7 +484,7 @@ export class SetActiveOnClick extends Behaviour implements IPointerClickHandler,
|
|
|
453
484
|
|
|
454
485
|
beforeCreateDocument() {
|
|
455
486
|
if (!this.target) return;
|
|
456
|
-
|
|
487
|
+
|
|
457
488
|
// need to cache on the object itself, because otherwise different actions would override each other's visibility state
|
|
458
489
|
// TODO would probably be better to have this somewhere on the exporter, not on this component
|
|
459
490
|
if (this.gameObject[SetActiveOnClick.wasVisible] === undefined)
|
|
@@ -514,7 +545,7 @@ export class SetActiveOnClick extends Behaviour implements IPointerClickHandler,
|
|
|
514
545
|
// It's much easier to reason about nested actions when we're not duplicating tons of hierarchy...
|
|
515
546
|
// We can probably only do a shallow clone when the tapped object has geometry of its own, otherwise
|
|
516
547
|
// we end up with nothing to tap on.
|
|
517
|
-
|
|
548
|
+
|
|
518
549
|
// Option A: we deep clone ourselves. This makes hierarchical cases and nested behaviours really complex.
|
|
519
550
|
// We do this currently when the object doesn't have any geometry.
|
|
520
551
|
if (!this.selfModelClone.geometry) {
|
|
@@ -533,11 +564,11 @@ export class SetActiveOnClick extends Behaviour implements IPointerClickHandler,
|
|
|
533
564
|
clone.name += "_toggle" + (SetActiveOnClick.clonedToggleIndex++);
|
|
534
565
|
originalModel.add(clone);
|
|
535
566
|
this.gameObject[SetActiveOnClick.toggleClone] = clone;
|
|
536
|
-
|
|
567
|
+
|
|
537
568
|
console.warn("USDZExport: Toggle " + this.gameObject.name + " doesn't have geometry. It will be deep cloned and nested behaviours will likely not work.");
|
|
538
569
|
}
|
|
539
570
|
const clonedSelfModel = this.gameObject[SetActiveOnClick.toggleClone];
|
|
540
|
-
|
|
571
|
+
|
|
541
572
|
if (!this.gameObject[SetActiveOnClick.reverseToggleClone]) {
|
|
542
573
|
const clone = this.selfModelClone.clone();
|
|
543
574
|
clone.setMatrix(new Matrix4());
|
|
@@ -589,7 +620,7 @@ export class SetActiveOnClick extends Behaviour implements IPointerClickHandler,
|
|
|
589
620
|
TriggerBuilder.tapTrigger(selfModel),
|
|
590
621
|
ActionBuilder.parallel(...toggleSequence)
|
|
591
622
|
));
|
|
592
|
-
|
|
623
|
+
|
|
593
624
|
const reverseSequence: ActionModel[] = [];
|
|
594
625
|
reverseSequence.push(ActionBuilder.fadeAction(this.toggleModel, 0, false));
|
|
595
626
|
reverseSequence.push(ActionBuilder.fadeAction(selfModel, 0, true));
|
|
@@ -680,7 +711,7 @@ export class HideOnStart extends Behaviour implements UsdzBehaviour {
|
|
|
680
711
|
}
|
|
681
712
|
|
|
682
713
|
private wasVisible: boolean = false;
|
|
683
|
-
|
|
714
|
+
|
|
684
715
|
beforeCreateDocument() {
|
|
685
716
|
this.wasVisible = GameObject.isActiveSelf(this.gameObject);
|
|
686
717
|
}
|
|
@@ -713,6 +744,22 @@ export class EmphasizeOnClick extends Behaviour implements UsdzBehaviour {
|
|
|
713
744
|
@serializable()
|
|
714
745
|
motionType: EmphasizeActionMotionType = "bounce";
|
|
715
746
|
|
|
747
|
+
onEnable(): void {
|
|
748
|
+
this.context.accessibility.updateElement(this, {
|
|
749
|
+
role: "button",
|
|
750
|
+
label: "Emphasize " + this.target?.name + " on click",
|
|
751
|
+
hidden: false,
|
|
752
|
+
})
|
|
753
|
+
}
|
|
754
|
+
onDisable(): void {
|
|
755
|
+
this.context.accessibility.updateElement(this, {
|
|
756
|
+
hidden: true,
|
|
757
|
+
});
|
|
758
|
+
}
|
|
759
|
+
onDestroy(): void {
|
|
760
|
+
this.context.accessibility.removeElement(this);
|
|
761
|
+
}
|
|
762
|
+
|
|
716
763
|
beforeCreateDocument() { }
|
|
717
764
|
|
|
718
765
|
createBehaviours(ext, model, _context) {
|
|
@@ -775,6 +822,21 @@ export class PlayAudioOnClick extends Behaviour implements IPointerClickHandler,
|
|
|
775
822
|
}
|
|
776
823
|
}
|
|
777
824
|
|
|
825
|
+
onEnable(): void {
|
|
826
|
+
this.context.accessibility.updateElement(this, {
|
|
827
|
+
role: "button",
|
|
828
|
+
label: "Play audio: " + (this.clip || this.target?.clip || "unknown clip"),
|
|
829
|
+
hidden: false,
|
|
830
|
+
})
|
|
831
|
+
}
|
|
832
|
+
onDisable(): void {
|
|
833
|
+
this.context.accessibility.updateElement(this, {
|
|
834
|
+
hidden: true,
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
onDestroy(): void {
|
|
838
|
+
this.context.accessibility.removeElement(this);
|
|
839
|
+
}
|
|
778
840
|
|
|
779
841
|
onPointerEnter() {
|
|
780
842
|
this.context.input.setCursor("pointer");
|
|
@@ -816,7 +878,7 @@ export class PlayAudioOnClick extends Behaviour implements IPointerClickHandler,
|
|
|
816
878
|
const clipName = AudioExtension.getName(clipUrl);
|
|
817
879
|
const volume = this.target ? this.target.volume : 1;
|
|
818
880
|
const auralMode = this.target && this.target.spatialBlend == 0 ? "nonSpatial" : "spatial";
|
|
819
|
-
|
|
881
|
+
|
|
820
882
|
// This checks if any child is clickable – if yes, the tap trigger is added; if not, we omit it.
|
|
821
883
|
let anyChildHasGeometry = false;
|
|
822
884
|
this.gameObject.traverse(c => {
|
|
@@ -825,7 +887,7 @@ export class PlayAudioOnClick extends Behaviour implements IPointerClickHandler,
|
|
|
825
887
|
// Workaround: seems iOS often simply doesn't play audio on scene start when this is NOT present.
|
|
826
888
|
// unclear why, but having a useless tap action (nothing to tap on) "fixes" it.
|
|
827
889
|
anyChildHasGeometry = true;
|
|
828
|
-
|
|
890
|
+
|
|
829
891
|
const audioClip = ext.addAudioClip(clipUrl);
|
|
830
892
|
// const stopAction: IBehaviorElement = ActionBuilder.playAudioAction(playbackTarget, audioClip, "stop", volume, auralMode);
|
|
831
893
|
let playAction: IBehaviorElement = ActionBuilder.playAudioAction(playbackTarget, audioClip, "play", volume, auralMode);
|
|
@@ -834,8 +896,7 @@ export class PlayAudioOnClick extends Behaviour implements IPointerClickHandler,
|
|
|
834
896
|
|
|
835
897
|
const behaviorName = (this.name ? "_" + this.name : "");
|
|
836
898
|
|
|
837
|
-
if (anyChildHasGeometry && this.trigger === "tap")
|
|
838
|
-
{
|
|
899
|
+
if (anyChildHasGeometry && this.trigger === "tap") {
|
|
839
900
|
// does not seem to work in iOS / QuickLook...
|
|
840
901
|
// TODO use play "type" which can be start/stop/pause
|
|
841
902
|
if (this.toggleOnClick) (playAction as ActionModel).multiplePerformOperation = "stop";
|
|
@@ -901,9 +962,25 @@ export class PlayAnimationOnClick extends Behaviour implements IPointerClickHand
|
|
|
901
962
|
|
|
902
963
|
private get target() { return this.animator?.gameObject || this.animation?.gameObject }
|
|
903
964
|
|
|
965
|
+
onEnable(): void {
|
|
966
|
+
this.context.accessibility.updateElement(this, {
|
|
967
|
+
role: "button",
|
|
968
|
+
label: "Plays animation " + (this.stateName || "") + " on " + (this.target ? this.target.name : ""),
|
|
969
|
+
hidden: false
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
onDisable(): void {
|
|
973
|
+
this.context.accessibility.updateElement(this, {
|
|
974
|
+
hidden: true,
|
|
975
|
+
});
|
|
976
|
+
}
|
|
977
|
+
onDestroy(): void {
|
|
978
|
+
this.context.accessibility.removeElement(this);
|
|
979
|
+
}
|
|
904
980
|
|
|
905
981
|
onPointerEnter() {
|
|
906
982
|
this.context.input.setCursor("pointer");
|
|
983
|
+
this.context.accessibility.hover(this, "Click to play animation " + (this.stateName || "") + " on " + (this.target ? this.target.name : ""));
|
|
907
984
|
}
|
|
908
985
|
onPointerExit() {
|
|
909
986
|
this.context.input.unsetCursor("pointer");
|
|
@@ -912,6 +989,7 @@ export class PlayAnimationOnClick extends Behaviour implements IPointerClickHand
|
|
|
912
989
|
args.use();
|
|
913
990
|
if (!this.target) return;
|
|
914
991
|
if (this.stateName) {
|
|
992
|
+
this.context.accessibility.focus(this);
|
|
915
993
|
// TODO this is currently quite annoying to use,
|
|
916
994
|
// as for the web we use the Animator component and its states directly,
|
|
917
995
|
// while in QuickLook we use explicit animations / states.
|
|
@@ -923,8 +1001,8 @@ export class PlayAnimationOnClick extends Behaviour implements IPointerClickHand
|
|
|
923
1001
|
|
|
924
1002
|
private stateAnimationModel: any;
|
|
925
1003
|
|
|
926
|
-
private animationSequence
|
|
927
|
-
private animationLoopAfterSequence
|
|
1004
|
+
private animationSequence?= new Array<RegisteredAnimationInfo>();
|
|
1005
|
+
private animationLoopAfterSequence?= new Array<RegisteredAnimationInfo>();
|
|
928
1006
|
private randomOffsetNormalized: number = 0;
|
|
929
1007
|
|
|
930
1008
|
createBehaviours(_ext: BehaviorExtension, model: USDObject, _context: USDZExporterContext) {
|
|
@@ -950,9 +1028,9 @@ export class PlayAnimationOnClick extends Behaviour implements IPointerClickHand
|
|
|
950
1028
|
afterCreateDocument(ext: BehaviorExtension, context: USDZExporterContext) {
|
|
951
1029
|
if ((this.animationSequence === undefined && this.animationLoopAfterSequence === undefined) || !this.stateAnimationModel) return;
|
|
952
1030
|
if (!this.target) return;
|
|
953
|
-
|
|
1031
|
+
|
|
954
1032
|
const document = context.document;
|
|
955
|
-
|
|
1033
|
+
|
|
956
1034
|
// check if the AnimationExtension has been attached and what data it has for the current object
|
|
957
1035
|
const animationExt = context.extensions.find(ext => ext instanceof AnimationExtension) as AnimationExtension;
|
|
958
1036
|
if (!animationExt) return;
|
|
@@ -966,7 +1044,7 @@ export class PlayAnimationOnClick extends Behaviour implements IPointerClickHand
|
|
|
966
1044
|
if (requiresExclusivePlayback) {
|
|
967
1045
|
if (isDevEnvironment())
|
|
968
1046
|
console.warn("Setting exclusive playback for " + this.target.name + "@" + this.stateName + " because it has " + animationExt.getClipCount(this.target) + " animations. This works around QuickLook bug FB13410767.");
|
|
969
|
-
|
|
1047
|
+
|
|
970
1048
|
PlayAnimationOnClick.rootsWithExclusivePlayback.add(this.target);
|
|
971
1049
|
}
|
|
972
1050
|
|
|
@@ -986,7 +1064,7 @@ export class PlayAnimationOnClick extends Behaviour implements IPointerClickHand
|
|
|
986
1064
|
this.trigger == "tap" ? TriggerBuilder.tapTrigger(this.selfModel) : TriggerBuilder.sceneStartTrigger(),
|
|
987
1065
|
sequence
|
|
988
1066
|
);
|
|
989
|
-
|
|
1067
|
+
|
|
990
1068
|
// See comment above for why exclusive playback is currently required when playing multiple animations on the same root.
|
|
991
1069
|
if (requiresExclusivePlayback)
|
|
992
1070
|
playAnimationOnTap.makeExclusive(true);
|
|
@@ -1008,8 +1086,7 @@ export class PlayAnimationOnClick extends Behaviour implements IPointerClickHand
|
|
|
1008
1086
|
|
|
1009
1087
|
const sequence = ActionBuilder.sequence();
|
|
1010
1088
|
|
|
1011
|
-
if (animationSequence && animationSequence.length > 0)
|
|
1012
|
-
{
|
|
1089
|
+
if (animationSequence && animationSequence.length > 0) {
|
|
1013
1090
|
for (const anim of animationSequence) {
|
|
1014
1091
|
sequence.addAction(getOrCacheAction(model, anim));
|
|
1015
1092
|
}
|
|
@@ -1033,11 +1110,10 @@ export class PlayAnimationOnClick extends Behaviour implements IPointerClickHand
|
|
|
1033
1110
|
return sequence;
|
|
1034
1111
|
}
|
|
1035
1112
|
|
|
1036
|
-
static getAndRegisterAnimationSequences(ext: AnimationExtension, target: GameObject, stateName?: string):
|
|
1037
|
-
|
|
1038
|
-
animationSequence: Array<RegisteredAnimationInfo>,
|
|
1113
|
+
static getAndRegisterAnimationSequences(ext: AnimationExtension, target: GameObject, stateName?: string): {
|
|
1114
|
+
animationSequence: Array<RegisteredAnimationInfo>,
|
|
1039
1115
|
animationLoopAfterSequence: Array<RegisteredAnimationInfo>,
|
|
1040
|
-
randomTimeOffset: number,
|
|
1116
|
+
randomTimeOffset: number,
|
|
1041
1117
|
} | undefined {
|
|
1042
1118
|
|
|
1043
1119
|
if (!target) return undefined;
|
|
@@ -1055,14 +1131,14 @@ export class PlayAnimationOnClick extends Behaviour implements IPointerClickHand
|
|
|
1055
1131
|
let animationLoopAfterSequence: Array<RegisteredAnimationInfo> = [];
|
|
1056
1132
|
|
|
1057
1133
|
if (animation) {
|
|
1058
|
-
const anim = ext.registerAnimation(target, animation.clip);
|
|
1059
|
-
if (anim) {
|
|
1134
|
+
const anim = ext.registerAnimation(target, animation.clip);
|
|
1135
|
+
if (anim) {
|
|
1060
1136
|
if (animation.loop)
|
|
1061
1137
|
animationLoopAfterSequence.push(anim);
|
|
1062
1138
|
else
|
|
1063
1139
|
animationSequence.push(anim);
|
|
1064
1140
|
}
|
|
1065
|
-
|
|
1141
|
+
|
|
1066
1142
|
let randomTimeOffset = 0;
|
|
1067
1143
|
if (animation.minMaxOffsetNormalized) {
|
|
1068
1144
|
const from = animation.minMaxOffsetNormalized.x;
|
|
@@ -1156,7 +1232,7 @@ export class PlayAnimationOnClick extends Behaviour implements IPointerClickHand
|
|
|
1156
1232
|
if (lastClip) {
|
|
1157
1233
|
let clipCopy: AnimationClip | undefined;
|
|
1158
1234
|
if (ext.holdClipMap.has(lastClip)) {
|
|
1159
|
-
clipCopy = ext.holdClipMap.get(lastClip);
|
|
1235
|
+
clipCopy = ext.holdClipMap.get(lastClip);
|
|
1160
1236
|
}
|
|
1161
1237
|
else {
|
|
1162
1238
|
// We're creating a "hold" clip here; exactly 1 second long, and inteprolates exactly on the duration of the clip
|
|
@@ -62,9 +62,9 @@ export class PhysicsExtension implements IUSDExporterExtension {
|
|
|
62
62
|
writer.appendLine(`double dynamicFriction = ${colliderSource.sharedMaterial?.dynamicFriction}`);
|
|
63
63
|
if (mat && mat.bounciness !== undefined)
|
|
64
64
|
writer.appendLine(`double restitution = ${colliderSource.sharedMaterial?.bounciness}`);
|
|
65
|
-
// eslint-disable-next-line
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
66
66
|
if (mat && mat.staticFriction !== undefined)
|
|
67
|
-
// eslint-disable-next-line
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
68
68
|
writer.appendLine(`double staticFriction = ${colliderSource.sharedMaterial?.staticFriction}`);
|
|
69
69
|
writer.closeBlock( "}" );
|
|
70
70
|
}
|
|
@@ -180,6 +180,8 @@ export class Button extends Behaviour implements IPointerEventHandler {
|
|
|
180
180
|
this.onClick.invoke();
|
|
181
181
|
args.use();
|
|
182
182
|
|
|
183
|
+
this.context.accessibility.focus(this);
|
|
184
|
+
|
|
183
185
|
// debug clicks for WebXR
|
|
184
186
|
if (debug) {
|
|
185
187
|
const pos = this.gameObject.worldPosition;
|
|
@@ -238,9 +240,19 @@ export class Button extends Behaviour implements IPointerEventHandler {
|
|
|
238
240
|
|
|
239
241
|
onEnable() {
|
|
240
242
|
super.onEnable();
|
|
243
|
+
this.context.accessibility.updateElement(this, {
|
|
244
|
+
role: "button",
|
|
245
|
+
label: this.gameObject.name + " button",
|
|
246
|
+
hidden: false
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
onDisable() {
|
|
250
|
+
super.onDisable();
|
|
251
|
+
this.context.accessibility.updateElement(this, { hidden: true })
|
|
241
252
|
}
|
|
242
253
|
|
|
243
254
|
onDestroy(): void {
|
|
255
|
+
this.context.accessibility.removeElement(this);
|
|
244
256
|
if (this._isHovered) this.context.input.unsetCursor("pointer");
|
|
245
257
|
}
|
|
246
258
|
|
|
@@ -102,6 +102,7 @@ export class Text extends Graphic implements IHasAlphaFactor, ICanvasEventReceiv
|
|
|
102
102
|
this._text = val;
|
|
103
103
|
this.feedText(this.text, this.supportRichText);
|
|
104
104
|
this.markDirty();
|
|
105
|
+
this.context.accessibility.updateElement(this, { label: this.text });
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
108
|
|
|
@@ -238,6 +239,13 @@ export class Text extends Graphic implements IHasAlphaFactor, ICanvasEventReceiv
|
|
|
238
239
|
|
|
239
240
|
onEnable(): void {
|
|
240
241
|
super.onEnable();
|
|
242
|
+
|
|
243
|
+
this.context.accessibility.updateElement(this, {
|
|
244
|
+
role: "text",
|
|
245
|
+
label: this.text,
|
|
246
|
+
hidden: false
|
|
247
|
+
});
|
|
248
|
+
|
|
241
249
|
this._didHandleTextRenderOnTop = false;
|
|
242
250
|
if (this.uiObject) {
|
|
243
251
|
// @ts-ignore
|
|
@@ -261,6 +269,11 @@ export class Text extends Graphic implements IHasAlphaFactor, ICanvasEventReceiv
|
|
|
261
269
|
onDisable(): void {
|
|
262
270
|
super.onDisable();
|
|
263
271
|
this.canvas?.unregisterEventReceiver(this);
|
|
272
|
+
this.context.accessibility.updateElement(this, { hidden: true });
|
|
273
|
+
}
|
|
274
|
+
onDestroy(): void {
|
|
275
|
+
super.onDestroy();
|
|
276
|
+
this.context.accessibility.removeElement(this);
|
|
264
277
|
}
|
|
265
278
|
|
|
266
279
|
private getAlignment(opts: ThreeMeshUIEveryOptions): ThreeMeshUIEveryOptions {
|