UNPKG

@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
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 { @serializable() position: "top" | "bottom" = "bottom"; /** Show the Needle logo in the menu (requires PRO license) */ @serializable() showNeedleLogo: boolean = true; /** When enabled the menu will also be visible in VR/AR when you look up * @default undefined */ @serializable() showSpatialMenu?: boolean; /** When enabled a button to enter fullscreen will be added to the menu * @default undefined */ @serializable() createFullscreenButton?: boolean; /** When enabled a button to mute the application will be added to the menu * @default undefined */ @serializable() createMuteButton?: boolean; /** * When enabled a button to show a QR code will be added to the menu. * @default undefined */ @serializable() 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); } } } }