@needle-tools/engine 4.9.2 → 4.9.3-next.0facab6
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 +4 -0
- package/components.needle.json +1 -1
- package/dist/{gltf-progressive-DhE1A6hX.min.js → gltf-progressive-CoZbSfPR.min.js} +1 -1
- package/dist/{gltf-progressive-egsMzRdv.js → gltf-progressive-DUR9TuAH.js} +3 -3
- package/dist/{gltf-progressive-DWiyqrwB.umd.cjs → gltf-progressive-Iy7aSAPk.umd.cjs} +1 -1
- package/dist/{needle-engine.bundle-WLYWw5OF.umd.cjs → needle-engine.bundle-DAo7BPxQ.umd.cjs} +149 -127
- package/dist/needle-engine.bundle-DP2gYtOQ.min.js +1638 -0
- package/dist/{needle-engine.bundle-XBRfMDwo.js → needle-engine.bundle-TvT7wv7z.js} +7567 -7380
- package/dist/needle-engine.js +446 -444
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/{postprocessing-B_FzkwDz.min.js → postprocessing-BHMVuZQ1.min.js} +53 -53
- package/dist/{postprocessing-DTX5VXrj.umd.cjs → postprocessing-BsnRNRRS.umd.cjs} +76 -76
- package/dist/{postprocessing-DP1U_BpT.js → postprocessing-DQ2pynXW.js} +213 -191
- package/dist/{three-BK56xWDs.umd.cjs → three-B-jwTHao.umd.cjs} +11 -11
- package/dist/{three-CsHK73Zc.js → three-CJSAehtG.js} +1 -0
- package/dist/{three-examples-Bph291U2.min.js → three-examples-BivkhnvN.min.js} +1 -1
- package/dist/{three-examples-C9WfZu-X.umd.cjs → three-examples-Deqc1bNw.umd.cjs} +1 -1
- package/dist/{three-examples-BvMpKSun.js → three-examples-Doq0rvFU.js} +1 -1
- package/dist/{three-mesh-ui-CN6aRT7i.js → three-mesh-ui-CktOi6oI.js} +1 -1
- package/dist/{three-mesh-ui-DnxkZWNA.umd.cjs → three-mesh-ui-CsHwj9cJ.umd.cjs} +1 -1
- package/dist/{three-mesh-ui-n_qS2BM-.min.js → three-mesh-ui-DhYXcXZe.min.js} +1 -1
- package/dist/{three-TNFQHSFa.min.js → three-qw28ZtTy.min.js} +10 -10
- package/dist/{vendor-BtJpSuCj.umd.cjs → vendor-D0Yvltn9.umd.cjs} +1 -1
- package/dist/{vendor-k9i6CeGi.js → vendor-DU8tJyl_.js} +1 -1
- package/dist/{vendor-XJ9xiwrv.min.js → vendor-JyrX4DVM.min.js} +1 -1
- package/lib/engine/api.d.ts +1 -0
- package/lib/engine/api.js +1 -0
- package/lib/engine/api.js.map +1 -1
- package/lib/engine/codegen/register_types.js +2 -0
- package/lib/engine/codegen/register_types.js.map +1 -1
- package/lib/engine/engine_animation.d.ts +21 -1
- package/lib/engine/engine_animation.js +32 -1
- package/lib/engine/engine_animation.js.map +1 -1
- package/lib/engine/engine_camera.fit.d.ts +68 -0
- package/lib/engine/engine_camera.fit.js +193 -0
- package/lib/engine/engine_camera.fit.js.map +1 -0
- package/lib/engine/engine_gizmos.d.ts +2 -2
- package/lib/engine/engine_gizmos.js +2 -2
- package/lib/engine/engine_physics.js +6 -3
- package/lib/engine/engine_physics.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.d.ts +1 -0
- package/lib/engine/webcomponents/needle-engine.js +6 -0
- package/lib/engine/webcomponents/needle-engine.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.loading.js +59 -23
- package/lib/engine/webcomponents/needle-engine.loading.js.map +1 -1
- package/lib/engine/xr/NeedleXRSession.d.ts +1 -0
- package/lib/engine/xr/NeedleXRSession.js +25 -11
- package/lib/engine/xr/NeedleXRSession.js.map +1 -1
- package/lib/engine-components/AnimatorController.js +16 -0
- package/lib/engine-components/AnimatorController.js.map +1 -1
- package/lib/engine-components/CameraUtils.js +8 -9
- package/lib/engine-components/CameraUtils.js.map +1 -1
- package/lib/engine-components/OrbitControls.d.ts +4 -47
- package/lib/engine-components/OrbitControls.js +30 -178
- package/lib/engine-components/OrbitControls.js.map +1 -1
- package/lib/engine-components/Renderer.js +9 -5
- package/lib/engine-components/Renderer.js.map +1 -1
- package/lib/engine-components/SpriteRenderer.js +4 -1
- package/lib/engine-components/SpriteRenderer.js.map +1 -1
- package/lib/engine-components/api.d.ts +0 -1
- package/lib/engine-components/api.js.map +1 -1
- package/lib/engine-components/codegen/components.d.ts +1 -0
- package/lib/engine-components/codegen/components.js +1 -0
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/lib/engine-components/web/Clickthrough.d.ts +3 -0
- package/lib/engine-components/web/Clickthrough.js +3 -0
- package/lib/engine-components/web/Clickthrough.js.map +1 -1
- package/lib/engine-components/web/CursorFollow.d.ts +3 -0
- package/lib/engine-components/web/CursorFollow.js +3 -0
- package/lib/engine-components/web/CursorFollow.js.map +1 -1
- package/lib/engine-components/web/HoverAnimation.d.ts +44 -0
- package/lib/engine-components/web/HoverAnimation.js +105 -0
- package/lib/engine-components/web/HoverAnimation.js.map +1 -0
- package/lib/engine-components/web/ScrollFollow.d.ts +4 -0
- package/lib/engine-components/web/ScrollFollow.js +4 -0
- package/lib/engine-components/web/ScrollFollow.js.map +1 -1
- package/lib/engine-components/web/index.d.ts +1 -0
- package/lib/engine-components/web/index.js +1 -0
- package/lib/engine-components/web/index.js.map +1 -1
- package/package.json +2 -2
- package/plugins/vite/alias.js +5 -3
- package/plugins/vite/poster-client.js +22 -21
- package/src/engine/api.ts +2 -1
- package/src/engine/codegen/register_types.ts +2 -0
- package/src/engine/engine_animation.ts +69 -1
- package/src/engine/engine_camera.fit.ts +288 -0
- package/src/engine/engine_gizmos.ts +2 -2
- package/src/engine/engine_physics.ts +6 -3
- package/src/engine/webcomponents/needle-engine.loading.ts +63 -24
- package/src/engine/webcomponents/needle-engine.ts +6 -1
- package/src/engine/xr/NeedleXRSession.ts +25 -10
- package/src/engine-components/AnimatorController.ts +21 -2
- package/src/engine-components/CameraUtils.ts +8 -9
- package/src/engine-components/OrbitControls.ts +30 -239
- package/src/engine-components/Renderer.ts +9 -6
- package/src/engine-components/SpriteRenderer.ts +3 -1
- package/src/engine-components/api.ts +0 -1
- package/src/engine-components/codegen/components.ts +1 -0
- package/src/engine-components/web/Clickthrough.ts +3 -0
- package/src/engine-components/web/CursorFollow.ts +3 -0
- package/src/engine-components/web/HoverAnimation.ts +99 -0
- package/src/engine-components/web/ScrollFollow.ts +4 -0
- package/src/engine-components/web/index.ts +1 -0
- package/dist/needle-engine.bundle-DwspSk2O.min.js +0 -1616
|
@@ -357,7 +357,7 @@ export class Renderer extends Behaviour implements IRenderer {
|
|
|
357
357
|
get sharedMaterials(): SharedMaterialArray {
|
|
358
358
|
|
|
359
359
|
// @ts-ignore during deserialization code might access this property *before* the setter and then create an empty array
|
|
360
|
-
if(!this.__didAwake) return null;
|
|
360
|
+
if (!this.__didAwake) return null;
|
|
361
361
|
|
|
362
362
|
if (!this._sharedMaterials || !this._sharedMaterials.is(this)) {
|
|
363
363
|
if (!this._originalMaterials) this._originalMaterials = [];
|
|
@@ -674,7 +674,7 @@ export class Renderer extends Behaviour implements IRenderer {
|
|
|
674
674
|
this.applySettings(this.gameObject);
|
|
675
675
|
}
|
|
676
676
|
|
|
677
|
-
if (this.sharedMaterials
|
|
677
|
+
if (this.sharedMaterials?.changed) {
|
|
678
678
|
this.sharedMaterials.changed = false;
|
|
679
679
|
this.applyLightmapping();
|
|
680
680
|
}
|
|
@@ -718,12 +718,15 @@ export class Renderer extends Behaviour implements IRenderer {
|
|
|
718
718
|
// since three 163 we need to set the envMap to the scene envMap if it is not set
|
|
719
719
|
// otherwise the envmapIntensity has no effect: https://github.com/mrdoob/three.js/pull/27903
|
|
720
720
|
// internal issue: https://linear.app/needle/issue/NE-6363
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
mat
|
|
721
|
+
if (this._sharedMaterials) {
|
|
722
|
+
for (const mat of this._sharedMaterials) {
|
|
723
|
+
// If the material has a envMap and is NOT using a reflection probe we set the envMap to the scene environment
|
|
724
|
+
if (mat && "envMap" in mat && "envMapIntensity" in mat && !ReflectionProbe.isUsingReflectionProbe(mat)) {
|
|
725
|
+
mat.envMap = this.context.scene.environment;
|
|
726
|
+
}
|
|
725
727
|
}
|
|
726
728
|
}
|
|
729
|
+
else if (debugRenderer) console.warn("[Renderer] sharedMaterials not initialized yet: " + this.name);
|
|
727
730
|
}
|
|
728
731
|
|
|
729
732
|
private onBeforeRenderThree = (_renderer, _scene, _camera, _geometry, material, _group) => {
|
|
@@ -329,7 +329,9 @@ export class SpriteRenderer extends Behaviour {
|
|
|
329
329
|
set sprite(value: Sprite | SpriteData | undefined | number) {
|
|
330
330
|
if (value === this._spriteSheet) return;
|
|
331
331
|
if (typeof value === "number") {
|
|
332
|
-
|
|
332
|
+
// the value if interpolated is sometimes *slightly* off (e.g. 0.999999 or 1.000001) so we round it
|
|
333
|
+
const index = Math.round(value);
|
|
334
|
+
if (debug) console.log("[SpriteSheet] Set index to " + index + " (was " + this.spriteIndex + ")", value);
|
|
333
335
|
this.spriteIndex = index;
|
|
334
336
|
}
|
|
335
337
|
else if (value instanceof Sprite) {
|
|
@@ -53,7 +53,6 @@ import "./AnimationUtilsAutoplay.js"
|
|
|
53
53
|
|
|
54
54
|
export { DragMode } from "./DragControls.js";
|
|
55
55
|
export type { DropListenerNetworkEventArguments, DropListenerOnDropArguments } from "./DropListener.js";
|
|
56
|
-
export { type FitCameraOptions } from "./OrbitControls.js";
|
|
57
56
|
export * from "./particlesystem/api.js"
|
|
58
57
|
export * from "./splines/index.js";
|
|
59
58
|
export * from "./web/index.js";
|
|
@@ -205,6 +205,7 @@ export { VideoPlayer } from "../VideoPlayer.js";
|
|
|
205
205
|
export { Voip } from "../Voip.js";
|
|
206
206
|
export { ClickThrough } from "../web/Clickthrough.js";
|
|
207
207
|
export { CursorFollow } from "../web/CursorFollow.js";
|
|
208
|
+
export { HoverAnimation } from "../web/HoverAnimation.js";
|
|
208
209
|
export { ScrollFollow } from "../web/ScrollFollow.js";
|
|
209
210
|
export { Avatar } from "../webxr/Avatar.js";
|
|
210
211
|
export { XRControllerFollow } from "../webxr/controllers/XRControllerFollow.js";
|
|
@@ -21,6 +21,9 @@ onStart(ctx => {
|
|
|
21
21
|
* - Alternatively, add the `clickthrough` attribute to the `<needle-engine>` HTML element (e.g. `<needle-engine clickthrough></needle-engine>`).
|
|
22
22
|
*
|
|
23
23
|
* @link Example https://stackblitz.com/~/github.com/needle-engine/sample-3d-over-html
|
|
24
|
+
* @category Web
|
|
25
|
+
* @group Components
|
|
26
|
+
* @component
|
|
24
27
|
*/
|
|
25
28
|
export class ClickThrough extends Behaviour {
|
|
26
29
|
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { AnimationClip } from "three";
|
|
2
|
+
|
|
3
|
+
import { ScaleClipType } from "../../engine/engine_animation.js";
|
|
4
|
+
import { AnimationUtils } from "../../engine/engine_animation.js";
|
|
5
|
+
import { serializable } from "../../engine/engine_serialization_decorator.js";
|
|
6
|
+
import { registerType } from "../../engine/engine_typestore.js";
|
|
7
|
+
import { Animation } from "../Animation.js";
|
|
8
|
+
import { Behaviour } from "../Component.js";
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @category Web
|
|
13
|
+
* @group Components
|
|
14
|
+
* @component
|
|
15
|
+
*/
|
|
16
|
+
@registerType
|
|
17
|
+
export class HoverAnimation extends Behaviour {
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Default hover animation type if no custom clip is provided.
|
|
21
|
+
* **Node**: This is only used if no custom hover animation clip is provided.
|
|
22
|
+
* @default "linear"
|
|
23
|
+
*/
|
|
24
|
+
@serializable()
|
|
25
|
+
type: ScaleClipType = "linear";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Duration of the hover animation in seconds.
|
|
29
|
+
* **Node**: This is only used if no custom hover animation clip is provided.
|
|
30
|
+
* @default 0.1
|
|
31
|
+
*/
|
|
32
|
+
@serializable()
|
|
33
|
+
duration: number = 0.1;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Scale factor to apply when hovering.
|
|
37
|
+
* **Node**: This is only used if no custom hover animation clip is provided.
|
|
38
|
+
* @default 1.1
|
|
39
|
+
*/
|
|
40
|
+
@serializable()
|
|
41
|
+
scaleFactor: number = 1.1;
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Animation clip to play when hovering. If null, a default scale-up animation is used.
|
|
46
|
+
*/
|
|
47
|
+
@serializable(AnimationClip)
|
|
48
|
+
hovered: AnimationClip | null = null;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Animation clip to play when not hovering. If null, an empty clip is used.
|
|
52
|
+
*/
|
|
53
|
+
@serializable(AnimationClip)
|
|
54
|
+
idle: AnimationClip | null = null;
|
|
55
|
+
|
|
56
|
+
private animation: Animation | null = null;
|
|
57
|
+
|
|
58
|
+
start() {
|
|
59
|
+
if (!this.idle) this.idle = AnimationUtils.emptyClip();
|
|
60
|
+
|
|
61
|
+
if (!this.hovered) {
|
|
62
|
+
this.hovered = AnimationUtils.createScaleClip({
|
|
63
|
+
type: "linear",
|
|
64
|
+
duration: this.duration || 0.1,
|
|
65
|
+
scale: this.gameObject.scale,
|
|
66
|
+
scaleFactor: this.scaleFactor || 1.1,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
this.animation ??= this.gameObject.addComponent(Animation);
|
|
71
|
+
this.animation.playAutomatically = false;
|
|
72
|
+
this.playIdle();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
onEnable() {
|
|
76
|
+
if (this.animation) this.animation.enabled = true;
|
|
77
|
+
this.playIdle();
|
|
78
|
+
}
|
|
79
|
+
onDisable() {
|
|
80
|
+
if (this.animation) this.animation.enabled = false;
|
|
81
|
+
this.playIdle();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
onPointerEnter() {
|
|
85
|
+
this.playHover();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
onPointerExit() {
|
|
89
|
+
this.playIdle();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private playIdle() {
|
|
93
|
+
if (this.idle) this.animation?.play(this.idle, { exclusive: true, fadeDuration: .1, loop: true });
|
|
94
|
+
}
|
|
95
|
+
private playHover() {
|
|
96
|
+
if (this.hovered) this.animation?.play(this.hovered, { exclusive: true, fadeDuration: .1, loop: false, clampWhenFinished: true });
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
}
|
|
@@ -44,6 +44,10 @@ type ScrollFollowEvent = {
|
|
|
44
44
|
* 2. Add a ScrollFollow component to the same GameObject or another GameObject in the scene.
|
|
45
45
|
* 3. Assign the PlayableDirector component to the ScrollFollow's target property.
|
|
46
46
|
* 4. The timeline will now scrub based on the scroll position of the page.
|
|
47
|
+
*
|
|
48
|
+
* @category Web
|
|
49
|
+
* @group Components
|
|
50
|
+
* @component
|
|
47
51
|
*/
|
|
48
52
|
export class ScrollFollow extends Behaviour {
|
|
49
53
|
|