@needle-tools/engine 4.11.4-next.a568de7 → 4.11.5-beta
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 +6 -0
- package/dist/{needle-engine.bundle-lEVjhicZ.min.js → needle-engine.bundle-78QepNU6.min.js} +1 -1
- package/dist/{needle-engine.bundle-nX51yB5a.umd.cjs → needle-engine.bundle-CtMdIm9E.umd.cjs} +2 -2
- package/dist/{needle-engine.bundle-DpWrB4yf.js → needle-engine.bundle-DLreKDiJ.js} +24 -3
- package/dist/needle-engine.js +2 -2
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/lib/engine/engine_addressables.js.map +1 -1
- package/lib/engine/engine_camera.fit.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_components.js.map +1 -1
- package/lib/engine/webcomponents/buttons.d.ts +3 -1
- package/lib/engine/webcomponents/buttons.js +3 -1
- package/lib/engine/webcomponents/buttons.js.map +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu.d.ts +39 -2
- package/lib/engine/webcomponents/needle menu/needle-menu.js +39 -2
- package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
- package/package.json +2 -2
- package/src/engine/engine_addressables.ts +1 -2
- package/src/engine/engine_camera.fit.ts +1 -2
- package/src/engine/extensions/NEEDLE_components.ts +1 -1
- package/src/engine/webcomponents/buttons.ts +3 -1
- package/src/engine/webcomponents/needle menu/needle-menu.ts +40 -3
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { Camera, Object3D, PerspectiveCamera, Vector3, Vector3Like } from "three";
|
|
2
2
|
|
|
3
3
|
import { GroundProjectedEnv } from "../engine-components/GroundProjection.js";
|
|
4
|
+
import type { OrbitControls } from "../engine-components/OrbitControls.js";
|
|
4
5
|
import { findObjectOfType } from "./engine_components.js";
|
|
5
6
|
import { Context } from "./engine_context.js";
|
|
6
7
|
import { Gizmos } from "./engine_gizmos.js";
|
|
7
8
|
import { getBoundingBox } from "./engine_three_utils.js";
|
|
8
9
|
import { NeedleXRSession } from "./xr/NeedleXRSession.js";
|
|
9
10
|
|
|
10
|
-
import type { OrbitControls } from "../engine-components/OrbitControls.js";
|
|
11
|
-
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* Options for fitting a camera to the scene or specific objects.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Object3D } from "three";
|
|
2
2
|
import { GLTFExporter } from 'three/examples/jsm/exporters/GLTFExporter.js';
|
|
3
3
|
import { type GLTF, type GLTFLoaderPlugin, GLTFParser } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
4
|
-
import { isDevEnvironment } from "../debug/debug.js";
|
|
5
4
|
|
|
5
|
+
import { isDevEnvironment } from "../debug/debug.js";
|
|
6
6
|
import { builtinComponentKeyName } from "../engine_constants.js";
|
|
7
7
|
import { debugExtension } from "../engine_default_parameters.js";
|
|
8
8
|
import { getLoader } from "../engine_gltf.js";
|
|
@@ -8,7 +8,9 @@ import { getIconElement } from "./icons.js";
|
|
|
8
8
|
* Use the ButtonsFactory to create buttons with icons and functionality
|
|
9
9
|
* Get access to the default buttons by using `ButtonsFactory.instance`
|
|
10
10
|
* The factory will create the buttons if they don't exist yet, and return the existing ones if they do (this allows you to reparent or modify created buttons)
|
|
11
|
-
|
|
11
|
+
*
|
|
12
|
+
* @category HTML
|
|
13
|
+
*/
|
|
12
14
|
export class ButtonsFactory {
|
|
13
15
|
|
|
14
16
|
private static _instance?: ButtonsFactory;
|
|
@@ -48,11 +48,13 @@ export declare type ButtonInfo = {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
|
-
* The NeedleMenu is a menu that can be displayed in the needle engine webcomponent or in VR/AR sessions.
|
|
51
|
+
* The NeedleMenu is a menu that can be displayed in the needle engine webcomponent or in VR/AR sessions.
|
|
52
|
+
*
|
|
52
53
|
* The menu can be used to add buttons to the needle engine that can be used to interact with the application.
|
|
53
|
-
* The menu can be positioned at the top or the bottom of the needle engine webcomponent
|
|
54
54
|
*
|
|
55
|
-
*
|
|
55
|
+
* The menu can be positioned at the top or the bottom of the <needle-engine> webcomponent.
|
|
56
|
+
*
|
|
57
|
+
* @example Add a new button using the NeedleMenu
|
|
56
58
|
* ```typescript
|
|
57
59
|
* onStart(ctx => {
|
|
58
60
|
* ctx.menu.appendChild({
|
|
@@ -76,6 +78,20 @@ export declare type ButtonInfo = {
|
|
|
76
78
|
* }
|
|
77
79
|
* }, "*");
|
|
78
80
|
* ```
|
|
81
|
+
*
|
|
82
|
+
* @example Access the menu from a component
|
|
83
|
+
* ```typescript
|
|
84
|
+
* import { Behaviour, OnStart } from '@needle-tools/engine';
|
|
85
|
+
*
|
|
86
|
+
* export class MyComponent extends Behaviour {
|
|
87
|
+
*
|
|
88
|
+
* start() {
|
|
89
|
+
* this.context.menu.appendChild({ ... });
|
|
90
|
+
* }
|
|
91
|
+
* }
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* @category HTML
|
|
79
95
|
*/
|
|
80
96
|
export class NeedleMenu {
|
|
81
97
|
private readonly _context: Context;
|
|
@@ -909,6 +925,27 @@ export class NeedleMenuElement extends HTMLElement {
|
|
|
909
925
|
}
|
|
910
926
|
}
|
|
911
927
|
}
|
|
928
|
+
/**
|
|
929
|
+
* Appends a button or HTML element to the needle-menu options.
|
|
930
|
+
* @param node a Node or ButtonInfo to create a button from
|
|
931
|
+
* @returns the appended Node
|
|
932
|
+
*
|
|
933
|
+
* @example Append a button
|
|
934
|
+
* ```javascript
|
|
935
|
+
* const button = document.createElement("button");
|
|
936
|
+
* button.textContent = "Click Me";
|
|
937
|
+
* needleMenu.appendChild(button);
|
|
938
|
+
* ```
|
|
939
|
+
* @example Append a button using ButtonInfo
|
|
940
|
+
* ```javascript
|
|
941
|
+
* needleMenu.appendChild({
|
|
942
|
+
* label: "Click Me",
|
|
943
|
+
* onClick: () => { alert("Button clicked!"); },
|
|
944
|
+
* icon: "info",
|
|
945
|
+
* title: "This is a button",
|
|
946
|
+
* });
|
|
947
|
+
* ```
|
|
948
|
+
*/
|
|
912
949
|
appendChild<T extends Node>(node: T | ButtonInfo): T {
|
|
913
950
|
|
|
914
951
|
if (!(node instanceof Node)) {
|