![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
A debugging utility that makes it easy to view console logs in WebXR experiences. LogXR provides developers with a simple and straightforward way to debug and troubleshoot their WebXR applications, giving them clarity and insight into the console output. The library is designed to be lightweight and versatile, offering a wide range of customization options for the appearance and behavior of the XR console. Currently, LogXR only supports Three.js, with support for Babylon.js coming soon.
console
API for logging, and their logs will be displayed both in the browser dev console and in the XR console.console.log
, console.warn
, console.error
, console.info
, and console.debug
.A demo app has been built using Three.js to showcase LogXR in action. You can check out the demo app at https://felixtrz.github.io/logxr/ to see how LogXR works and to get a feel for its capabilities.
This demo app is a great resource for developers who are considering using LogXR in their projects. It provides a hands-on experience with the library, and will give you a better understanding of how it works and what it can do.
To install LogXR, simply run the following command in your terminal:
npm install logxr
Or if you prefer using Yarn:
$ yarn add logxr
Using LogXR is simple. First, import the package in your WebXR project:
import { XRConsoleFactory } from 'logxr';
NOTE: LogXR requires Three.js as a peer dependency, make sure to have a recent version installed. Babylon.js support is coming soon! 🚀
Then, create an instance of the XR console:
const xrConsole = XRConsoleFactory.getInstance().createConsole({
pixelWidth: 1024,
pixelHeight: 512,
actualWidth: 2,
actualHeight: 1,
});
The xrConsole object created extends THREE.Object3D, and can be used as such. After a console is set up, simply use console.log() as usual, and the logs will be intercepted and reflected on the xrConsole.
The following classes are exported by LogXR, and are available for use in your WebXR projects:
The XRConsoleFactory class provides a factory method to create instances of XRConsole, and manage the message queue that all instances of XRConsole read from.
maxNumMessages
maxNumMessages: number;
Gets or sets the maximum number of messages that can be stored by the XRConsoleFactory
. The default value is 100.
static getInstance(): XRConsoleFactory
static getInstance(): XRConsoleFactory
Gets a singleton instance of the XRConsoleFactory.
createConsole(options: XRConsoleOptions): XRConsole
createConsole(options: XRConsoleOptions): XRConsole
Creates a new instance of XRConsole with the specified options.
getMessages(messageTypes: MessageType[], count: number): Message[]
getMessages(messageTypes: MessageType[], count: number): Message[]
Gets the messages in the message queue that match the specified message types. The number of messages returned is limited by the count
parameter.
The XRConsole
class represents the XR console and provides the necessary functionality for rendering console logs in a WebXR environment.
panelMesh: Mesh
The panelMesh
property represents the mesh object that serves as the panel for the console.
needsUpdate: boolean
The needsUpdate
property is a flag that indicates whether the console canvas needs to be updated.
constructor(options?: XRConsoleOptions)
constructor(options?: XRConsoleOptions)
Creates a new instance of the XR console with the specified options.
render()
render(): void
Renders the console to the canvas.
XRConsoleOptions
The XRConsoleOptions
interface represents a set of options that can be passed to the XRConsole
constructor to customize its appearance and behavior.
pixelWidth?: number
: The width of the canvas in pixels. Default is 1024.pixelHeight?: number
: The height of the canvas in pixels. Default is 512.actualWidth?: number
: The width of the plane in meters. Default is 1.actualHeight?: number
: The height of the plane in meters. Default is 1.fontSize?: number
: The font size of the text in pixels. Default is 16.horizontalPadding?: number
: The horizontal padding of the text in pixels. Default is 5.verticalPadding?: number
: The vertical padding of the text in pixels. Default is 5.showTimestamp?: boolean
: Whether or not to show the timestamp. Default is true.messageType?: MessageType
: The type of messages to show. Default is MessageType.All
.backgroundColor?: string
: The background color of the canvas. Default is '#222222'
.logColor?: string
: The color of the log messages. Default is '#FFFFFF'
.errorColor?: string
: The color of the error messages. Default is '#D0342C'
.warningColor?: string
: The color of the warning messages. Default is '#FF7900'
.infoColor?: string
: The color of the info messages. Default is '#76B947'
.debugColor?: string
: The color of the debug messages. Default is '#0E86D4'
.MessageType
The MessageType
enumeration is used to specify the type of messages that should be displayed in the XR console.
All
: Displays all messages.Log
: Displays only log messages.Error
: Displays only error messages.Warning
: Displays only warning messages.Info
: Displays only info messages.Debug
: Displays only debug messages.MIT License © 2023 Felix Zhang
FAQs
WebXR in-session console
The npm package logxr receives a total of 1 weekly downloads. As such, logxr popularity was classified as not popular.
We found that logxr demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.