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.

93 lines 3.53 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; import { serializable } from '../engine/engine_serialization.js'; import { DeviceUtilities } from '../engine/engine_utils.js'; import { Behaviour } from './Component.js'; /** * Provides configuration options for the built-in Needle Menu. * Needle Menu uses HTML in 2D mode, and automatically switches to a 3D menu in VR/AR mode. * * Controls display options, button visibility, and menu positioning. * From code, you can access the menu via {@link Context.menu}. * @category User Interface * @group Components **/ export class NeedleMenu extends Behaviour { /** * Determines the vertical positioning of the menu on the screen */ position = "bottom"; /** * Controls the visibility of the Needle logo in the menu (requires PRO license) */ showNeedleLogo = false; /** * When enabled, displays the menu in VR/AR mode when the user looks up * @default undefined */ showSpatialMenu; /** * When enabled, adds a fullscreen toggle button to the menu * @default undefined */ createFullscreenButton; /** * When enabled, adds an audio mute/unmute button to the menu * @default undefined */ createMuteButton; /** * When enabled, adds a button to display a QR code for sharing the application. * The QR code is only displayed on desktop devices. * @default undefined */ createQRCodeButton; /** * Applies the configured menu options when the component is enabled * @hidden */ onEnable() { this.applyOptions(); } /** * Applies all configured options to the active {@link 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); } } } } __decorate([ serializable() ], NeedleMenu.prototype, "position", void 0); __decorate([ serializable() ], NeedleMenu.prototype, "showNeedleLogo", void 0); __decorate([ serializable() ], NeedleMenu.prototype, "showSpatialMenu", void 0); __decorate([ serializable() ], NeedleMenu.prototype, "createFullscreenButton", void 0); __decorate([ serializable() ], NeedleMenu.prototype, "createMuteButton", void 0); __decorate([ serializable() ], NeedleMenu.prototype, "createQRCodeButton", void 0); //# sourceMappingURL=NeedleMenu.js.map