@needle-tools/engine
Version:
Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in
67 lines (58 loc) • 2.16 kB
text/typescript
import type { Context } from '../engine/engine_context.js';
import { serializable } from '../engine/engine_serialization.js';
import { DeviceUtilities } from '../engine/engine_utils.js';
import { Behaviour } from './Component.js';
/**
* Exposes options to customize the built-in Needle Menu.
* From code, you can access the menu via {@link Context.menu}.
* @category User Interface
* @group Components
**/
export class NeedleMenu extends Behaviour {
position: "top" | "bottom" = "bottom";
/** Show the Needle logo in the menu (requires PRO license) */
showNeedleLogo: boolean = true;
/** When enabled the menu will also be visible in VR/AR when you look up
* @default undefined
*/
showSpatialMenu?: boolean;
/** When enabled a button to enter fullscreen will be added to the menu
* @default undefined
*/
createFullscreenButton?: boolean;
/** When enabled a button to mute the application will be added to the menu
* @default undefined
*/
createMuteButton?: boolean;
/**
* When enabled a button to show a QR code will be added to the menu.
* @default undefined
*/
createQRCodeButton?: boolean;
/** @hidden */
onEnable() {
this.applyOptions();
}
/** applies the options to `this.context.menu` */
applyOptions() {
this.context.menu.setPosition(this.position);
this.context.menu.showNeedleLogo(this.showNeedleLogo);
if (this.createFullscreenButton === true)
this.context.menu.showFullscreenOption(true);
if (this.createMuteButton === true)
this.context.menu.showAudioPlaybackOption(true);
if (this.showSpatialMenu === true)
this.context.menu.showSpatialMenu(this.showSpatialMenu);
if (this.createQRCodeButton === true) {
if (!DeviceUtilities.isMobileDevice()) {
this.context.menu.showQRCodeButton(true);
}
}
}
}