@needle-tools/engine 5.1.0-alpha.2 → 5.1.0-alpha.3
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 +35 -1
- package/components.needle.json +1 -1
- package/dist/{needle-engine.bundle-qZfVf_v-.umd.cjs → needle-engine.bundle-C-ixARur.umd.cjs} +128 -127
- package/dist/{needle-engine.bundle-B-5Q2CpC.min.js → needle-engine.bundle-CHmXdnE1.min.js} +138 -137
- package/dist/{needle-engine.bundle-dit3f1l5.js → needle-engine.bundle-DF01sSGQ.js} +7815 -7602
- package/dist/needle-engine.d.ts +125 -27
- package/dist/needle-engine.js +524 -521
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/lib/engine/api.d.ts +2 -0
- package/lib/engine/api.js +2 -0
- package/lib/engine/api.js.map +1 -1
- package/lib/engine/debug/debug_spatial_console.d.ts +2 -0
- package/lib/engine/debug/debug_spatial_console.js +10 -7
- package/lib/engine/debug/debug_spatial_console.js.map +1 -1
- package/lib/engine/engine_addressables.d.ts +2 -0
- package/lib/engine/engine_addressables.js +6 -3
- package/lib/engine/engine_addressables.js.map +1 -1
- package/lib/engine/engine_audio.d.ts +68 -0
- package/lib/engine/engine_audio.js +172 -0
- package/lib/engine/engine_audio.js.map +1 -1
- package/lib/engine/engine_components.js +1 -1
- package/lib/engine/engine_components.js.map +1 -1
- package/lib/engine/engine_context.d.ts +1 -1
- package/lib/engine/engine_context.js +1 -1
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_gameobject.js +2 -2
- package/lib/engine/engine_gameobject.js.map +1 -1
- package/lib/engine/engine_init.js +13 -3
- package/lib/engine/engine_init.js.map +1 -1
- package/lib/engine/engine_input.d.ts +1 -1
- package/lib/engine/engine_input.js +1 -1
- package/lib/engine/engine_input.js.map +1 -1
- package/lib/engine/engine_license.js +1 -1
- package/lib/engine/engine_license.js.map +1 -1
- package/lib/engine/engine_mainloop_utils.js +5 -2
- package/lib/engine/engine_mainloop_utils.js.map +1 -1
- package/lib/engine/engine_networking_blob.js +1 -1
- package/lib/engine/engine_networking_blob.js.map +1 -1
- package/lib/engine/engine_scenedata.d.ts +2 -0
- package/lib/engine/engine_scenedata.js +4 -2
- package/lib/engine/engine_scenedata.js.map +1 -1
- package/lib/engine/engine_serialization_builtin_serializer.d.ts +10 -16
- package/lib/engine/engine_serialization_builtin_serializer.js +55 -41
- package/lib/engine/engine_serialization_builtin_serializer.js.map +1 -1
- package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +1 -1
- package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js.map +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu.d.ts +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu.js +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.d.ts +10 -4
- package/lib/engine/webcomponents/needle-engine.js +1 -1
- package/lib/engine/webcomponents/needle-engine.js.map +1 -1
- package/lib/engine/xr/NeedleXRSession.d.ts +3 -2
- package/lib/engine/xr/NeedleXRSession.js +50 -14
- package/lib/engine/xr/NeedleXRSession.js.map +1 -1
- package/lib/engine/xr/events.d.ts +1 -1
- package/lib/engine/xr/events.js.map +1 -1
- package/lib/engine-components/Animation.js +17 -16
- package/lib/engine-components/Animation.js.map +1 -1
- package/lib/engine-components/AnimatorController.d.ts +2 -0
- package/lib/engine-components/AnimatorController.js +4 -1
- package/lib/engine-components/AnimatorController.js.map +1 -1
- package/lib/engine-components/AudioSource.d.ts +19 -3
- package/lib/engine-components/AudioSource.js +121 -68
- package/lib/engine-components/AudioSource.js.map +1 -1
- package/lib/engine-components/DragControls.d.ts +7 -0
- package/lib/engine-components/DragControls.js +19 -0
- package/lib/engine-components/DragControls.js.map +1 -1
- package/lib/engine-components/Networking.d.ts +1 -1
- package/lib/engine-components/Networking.js +1 -1
- package/lib/engine-components/OrbitControls.js +16 -11
- package/lib/engine-components/OrbitControls.js.map +1 -1
- package/lib/engine-components/ReflectionProbe.js +2 -0
- package/lib/engine-components/ReflectionProbe.js.map +1 -1
- package/lib/engine-components/SeeThrough.js +2 -2
- package/lib/engine-components/SeeThrough.js.map +1 -1
- package/lib/engine-components/api.d.ts +1 -1
- package/lib/engine-components/api.js +1 -1
- package/lib/engine-components/api.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/Tonemapping.utils.d.ts +1 -1
- package/lib/engine-components/postprocessing/VolumeParameter.d.ts +2 -0
- package/lib/engine-components/postprocessing/VolumeParameter.js +4 -1
- package/lib/engine-components/postprocessing/VolumeParameter.js.map +1 -1
- package/lib/engine-components/ui/Canvas.d.ts +1 -1
- package/lib/engine-components/ui/Canvas.js +2 -8
- package/lib/engine-components/ui/Canvas.js.map +1 -1
- package/lib/engine-components/ui/Text.d.ts +1 -0
- package/lib/engine-components/ui/Text.js +10 -7
- package/lib/engine-components/ui/Text.js.map +1 -1
- package/lib/engine-components/web/CursorFollow.js +21 -12
- package/lib/engine-components/web/CursorFollow.js.map +1 -1
- package/lib/engine-components/webxr/WebXRImageTracking.js +4 -0
- package/lib/engine-components/webxr/WebXRImageTracking.js.map +1 -1
- package/package.json +1 -1
- package/plugins/vite/asap.js +17 -8
- package/plugins/vite/dependencies.js +29 -0
- package/plugins/vite/local-files-core.js +3 -3
- package/plugins/vite/local-files-utils.d.ts +3 -1
- package/plugins/vite/local-files-utils.js +29 -5
- package/src/engine/api.ts +3 -0
- package/src/engine/debug/debug_spatial_console.ts +10 -7
- package/src/engine/engine_addressables.ts +6 -3
- package/src/engine/engine_audio.ts +184 -0
- package/src/engine/engine_components.ts +1 -1
- package/src/engine/engine_context.ts +2 -2
- package/src/engine/engine_gameobject.ts +2 -2
- package/src/engine/engine_init.ts +13 -3
- package/src/engine/engine_input.ts +1 -1
- package/src/engine/engine_license.ts +1 -1
- package/src/engine/engine_mainloop_utils.ts +5 -2
- package/src/engine/engine_networking_blob.ts +1 -1
- package/src/engine/engine_scenedata.ts +5 -3
- package/src/engine/engine_serialization_builtin_serializer.ts +63 -46
- package/src/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +1 -1
- package/src/engine/webcomponents/needle menu/needle-menu.ts +1 -1
- package/src/engine/webcomponents/needle-engine.ts +10 -4
- package/src/engine/xr/NeedleXRSession.ts +48 -13
- package/src/engine/xr/events.ts +1 -1
- package/src/engine-components/Animation.ts +19 -16
- package/src/engine-components/AnimatorController.ts +4 -1
- package/src/engine-components/AudioSource.ts +130 -79
- package/src/engine-components/DragControls.ts +18 -2
- package/src/engine-components/Networking.ts +1 -1
- package/src/engine-components/OrbitControls.ts +18 -9
- package/src/engine-components/ReflectionProbe.ts +2 -0
- package/src/engine-components/SeeThrough.ts +2 -2
- package/src/engine-components/api.ts +1 -1
- package/src/engine-components/postprocessing/VolumeParameter.ts +4 -1
- package/src/engine-components/ui/Canvas.ts +2 -8
- package/src/engine-components/ui/Text.ts +12 -8
- package/src/engine-components/web/CursorFollow.ts +21 -13
- package/src/engine-components/webxr/WebXRImageTracking.ts +2 -0
|
@@ -170,12 +170,15 @@ export class Text extends Graphic implements IHasAlphaFactor, ICanvasEventReceiv
|
|
|
170
170
|
this._font = val;
|
|
171
171
|
this.uiObject?.set(this.getTextOpts());
|
|
172
172
|
this.markDirty();
|
|
173
|
+
// If the font is assigned during deserialization it means the font URL MUST be resolved with the style suffix. If it's assigned at runtime by a user invocation and is absolute then we assume the user is prividing a full path to the font asset json or png
|
|
174
|
+
this._assignedAtRuntime = this.__didAwake;
|
|
173
175
|
}
|
|
174
176
|
}
|
|
175
177
|
get font(): string | null {
|
|
176
178
|
return this._font;
|
|
177
179
|
}
|
|
178
180
|
private _font: string | null = "https://cdn.needle.tools/static/fonts/msdf/arial/arial";
|
|
181
|
+
private _assignedAtRuntime: boolean = true;
|
|
179
182
|
|
|
180
183
|
|
|
181
184
|
/**
|
|
@@ -274,7 +277,7 @@ export class Text extends Graphic implements IHasAlphaFactor, ICanvasEventReceiv
|
|
|
274
277
|
}
|
|
275
278
|
|
|
276
279
|
protected onCreate(_opts: any): void {
|
|
277
|
-
if (debug) console.log(this);
|
|
280
|
+
if (debug) console.log("[Text] onCreate", this);
|
|
278
281
|
|
|
279
282
|
// @marwie : Should be fixed. Currently _opts are always fed with :
|
|
280
283
|
// backgroundOpacity : color.opacity
|
|
@@ -442,7 +445,7 @@ export class Text extends Graphic implements IHasAlphaFactor, ICanvasEventReceiv
|
|
|
442
445
|
private feedText(text: string, richText: boolean): void {
|
|
443
446
|
// if (!text || text.length <= 0) return;
|
|
444
447
|
// if (!text ) return;
|
|
445
|
-
if (debug) console.log("feedText", this.uiObject, text, richText);
|
|
448
|
+
if (debug) console.log("[Text] feedText", this.uiObject, text, richText);
|
|
446
449
|
|
|
447
450
|
if (!this.uiObject) return;
|
|
448
451
|
if (!this._textMeshUi)
|
|
@@ -603,16 +606,17 @@ export class Text extends Graphic implements IHasAlphaFactor, ICanvasEventReceiv
|
|
|
603
606
|
* @private
|
|
604
607
|
*/
|
|
605
608
|
private setFont(opts: ThreeMeshUIEveryOptions, fontStyle: FontStyle) {
|
|
606
|
-
|
|
609
|
+
|
|
607
610
|
if (!this.font) {
|
|
608
|
-
if(debug) console.warn("No font set for Text component, skipping font setup");
|
|
611
|
+
if (debug) console.warn("[Text] No font set for Text component, skipping font setup");
|
|
609
612
|
return;
|
|
610
613
|
}
|
|
611
614
|
|
|
612
615
|
const fontName = this.font;
|
|
616
|
+
|
|
613
617
|
const familyName = this.getFamilyNameWithCorrectSuffix(fontName, fontStyle);
|
|
614
618
|
|
|
615
|
-
if (debug) console.log(
|
|
619
|
+
if (debug) console.log(`[Text] Selected font family '${familyName}' from ${fontName} with style ${FontStyle[fontStyle]}`);
|
|
616
620
|
|
|
617
621
|
// ensure a font family is register under this name
|
|
618
622
|
let fontFamily = ThreeMeshUI.FontLibrary.getFontFamily(familyName as string);
|
|
@@ -676,7 +680,7 @@ export class Text extends Graphic implements IHasAlphaFactor, ICanvasEventReceiv
|
|
|
676
680
|
// e.g. -Medium, -Black, -Thin...
|
|
677
681
|
const styleName = familyName.substring(styleSeparator + 1)?.toLowerCase();
|
|
678
682
|
if (unsupportedStyleNames.includes(styleName)) {
|
|
679
|
-
if (debug) console.warn("Unsupported font style: " + styleName);
|
|
683
|
+
if (debug) console.warn("[Text] Unsupported font style: " + styleName);
|
|
680
684
|
return familyName;
|
|
681
685
|
}
|
|
682
686
|
|
|
@@ -691,12 +695,12 @@ export class Text extends Graphic implements IHasAlphaFactor, ICanvasEventReceiv
|
|
|
691
695
|
const isUpperCase = fontBaseName[0] === fontBaseName[0].toUpperCase();
|
|
692
696
|
const fontNameWithoutSuffix = familyName.substring(0, styleSeparator > pathSeparatorIndex ? styleSeparator : familyName.length);
|
|
693
697
|
|
|
694
|
-
if (debug) console.log("Select font: ", familyName, FontStyle[style], fontBaseName, isUpperCase, fontNameWithoutSuffix);
|
|
698
|
+
if (debug) console.log("[Text] Select font: ", familyName, FontStyle[style], fontBaseName, isUpperCase, fontNameWithoutSuffix);
|
|
695
699
|
|
|
696
700
|
/**
|
|
697
701
|
* If a user provides a font with an absolute URL AND the font name does not end with "-msdf.json" or ".png" (e.g. "https://example.com/fonts/Arial-Bold"), we will assume that the user is providing the full path to the font files and we will not try to modify the font name based on the style. This allows users to have more control over the font files they are using, especially if they are hosting their own fonts or using a custom font provider that does not follow the same naming conventions as our default fonts.
|
|
698
702
|
*/
|
|
699
|
-
if (isAbsolute && !(familyName.endsWith("-msdf.json") || familyName.endsWith(".png"))) {
|
|
703
|
+
if (isAbsolute && this._assignedAtRuntime && !(familyName.endsWith("-msdf.json") || familyName.endsWith(".png"))) {
|
|
700
704
|
return fontNameWithoutSuffix;
|
|
701
705
|
}
|
|
702
706
|
|
|
@@ -289,20 +289,28 @@ export class CursorFollow extends Behaviour {
|
|
|
289
289
|
|
|
290
290
|
|
|
291
291
|
if (this.snapToSurface) {
|
|
292
|
-
ray.origin =
|
|
293
|
-
ray.direction = rayDirection
|
|
294
|
-
const hits = this.context.physics.raycastFromRay(ray
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
if (this.damping > 0) {
|
|
298
|
-
this.gameObject.worldPosition = _position.lerp(hit.point, this.context.time.deltaTime / this.damping);
|
|
299
|
-
}
|
|
300
|
-
else {
|
|
301
|
-
this.gameObject.worldPosition = hit.point;
|
|
292
|
+
ray.origin = cameraPosition;
|
|
293
|
+
ray.direction = rayDirection;
|
|
294
|
+
const hits = this.context.physics.raycastFromRay(ray, {
|
|
295
|
+
testObject: obj => {
|
|
296
|
+
return obj !== this.gameObject && !this.gameObject.contains(obj) ? true : false
|
|
302
297
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
298
|
+
});
|
|
299
|
+
if (hits?.length) {
|
|
300
|
+
// Get the first hit that is not a child of *this* object. Because we do not want to lerp to a surface that is part of the object itself, since that would result in *this* object moving closer and closer to the camera as it tries to snap to itself
|
|
301
|
+
const hit = hits[0];//.find(h => !this.gameObject.contains(h.object));
|
|
302
|
+
if (hit) {
|
|
303
|
+
if (this.damping > 0) {
|
|
304
|
+
this.gameObject.worldPosition = _position.lerp(hit.point, this.context.time.deltaTime / this.damping);
|
|
305
|
+
// this._distance = this.gameObject.worldPosition.distanceTo(cameraPosition);
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
this.gameObject.worldPosition = hit.point;
|
|
309
|
+
// this._distance = hit.point.distanceTo(cameraPosition);
|
|
310
|
+
}
|
|
311
|
+
if (debug) {
|
|
312
|
+
Gizmos.DrawLine(hit.point, hit.normal!.add(hit.point), 0x00FF00);
|
|
313
|
+
}
|
|
306
314
|
}
|
|
307
315
|
}
|
|
308
316
|
}
|
|
@@ -886,9 +886,11 @@ async function loadImage(url: string) {
|
|
|
886
886
|
}
|
|
887
887
|
const promise = new Promise<boolean>(res => {
|
|
888
888
|
_imageElements.set(url, null);
|
|
889
|
+
if(isDevEnvironment() || debug) console.debug(`[WebXRImageTracking] Start loading image for tracking: ${url}`);
|
|
889
890
|
const imageElement = document.createElement("img") as HTMLImageElement;
|
|
890
891
|
imageElement.src = url;
|
|
891
892
|
imageElement.addEventListener("load", async () => {
|
|
893
|
+
if(isDevEnvironment() || debug) console.debug(`[WebXRImageTracking] Loaded image for tracking: ${url}`);
|
|
892
894
|
const img = await createImageBitmap(imageElement);
|
|
893
895
|
_imageElements.set(url, img);
|
|
894
896
|
res(true);
|