Variable MiscUtilConst

MiscUtil: Readonly<{
    addLineNumberToCode: ((shaderString: string) => string);
    concatArrayBuffers: ((segments: ArrayBuffer[], sizes: number[], offsets: number[], finalSize?: number) => ArrayBufferLike);
    concatArrayBuffers2: ((params: {
        finalSize: number;
        srcs: ArrayBuffer[];
        srcsCopySize: number[];
        srcsOffset: number[];
    }) => ArrayBuffer);
    downloadArrayBuffer: ((fileNameToDownload: string, arrayBuffer: ArrayBuffer) => void);
    downloadTypedArray: ((fileNameToDownload: string, typedArray: TypedArray) => void);
    fillTemplate: ((templateString: string, templateVars: string) => string);
    isIOS: (() => boolean);
    isMobile: (() => boolean);
    isMobileVr: (() => boolean);
    isNode: (() => boolean);
    isObject: ((o: any) => boolean);
    isSafari: (() => boolean);
    preventDefaultForDesktopOnly: ((e: Event) => void);
}> = ...

Collection of miscellaneous utility functions for various common operations including device detection, array buffer manipulation, conditional execution, and file operations

Type declaration

  • addLineNumberToCode: ((shaderString: string) => string)
      • (shaderString): string
      • Adds line numbers to a code string for debugging purposes

        Parameters

        • shaderString: string

          The code string to add line numbers to

        Returns string

        The code string with line numbers prepended to each line

  • concatArrayBuffers: ((segments: ArrayBuffer[], sizes: number[], offsets: number[], finalSize?: number) => ArrayBufferLike)
      • (segments, sizes, offsets, finalSize?): ArrayBufferLike
      • Concatenates multiple ArrayBuffers into a single ArrayBuffer with specified sizes and offsets

        Parameters

        • segments: ArrayBuffer[]

          Array of ArrayBuffers to concatenate

        • sizes: number[]

          Array of sizes for each segment

        • offsets: number[]

          Array of offsets for each segment

        • OptionalfinalSize: number

          Optional final size of the resulting buffer

        Returns ArrayBufferLike

        The concatenated ArrayBuffer

  • concatArrayBuffers2: ((params: {
        finalSize: number;
        srcs: ArrayBuffer[];
        srcsCopySize: number[];
        srcsOffset: number[];
    }) => ArrayBuffer)
      • (params): ArrayBuffer
      • Concatenates multiple ArrayBuffers into a single ArrayBuffer with a more structured approach

        Parameters

        • params: {
              finalSize: number;
              srcs: ArrayBuffer[];
              srcsCopySize: number[];
              srcsOffset: number[];
          }

          Configuration object for concatenation

          • finalSize: number

            The final size of the resulting buffer

          • srcs: ArrayBuffer[]

            Array of source ArrayBuffers

          • srcsCopySize: number[]

            Array of copy sizes for each source buffer

          • srcsOffset: number[]

            Array of offsets for each source buffer

        Returns ArrayBuffer

        The concatenated ArrayBuffer

  • downloadArrayBuffer: ((fileNameToDownload: string, arrayBuffer: ArrayBuffer) => void)
      • (fileNameToDownload, arrayBuffer): void
      • Downloads an ArrayBuffer as a file in the browser

        Parameters

        • fileNameToDownload: string

          The name of the file to download

        • arrayBuffer: ArrayBuffer

          The ArrayBuffer data to download

        Returns void

  • downloadTypedArray: ((fileNameToDownload: string, typedArray: TypedArray) => void)
      • (fileNameToDownload, typedArray): void
      • Downloads a TypedArray as a file in the browser

        Parameters

        • fileNameToDownload: string

          The name of the file to download

        • typedArray: TypedArray

          The TypedArray data to download

        Returns void

  • fillTemplate: ((templateString: string, templateVars: string) => string)
  • isIOS: (() => boolean)
      • (): boolean
      • Detects if the current environment is an iOS device (iPod, iPad, iPhone)

        Returns boolean

        True if running on an iOS device, false otherwise

  • isMobile: (() => boolean)
      • (): boolean
      • Detects if the current environment is a mobile device (iPod, iPad, iPhone, Android)

        Returns boolean

        True if running on a mobile device, false otherwise

  • isMobileVr: (() => boolean)
      • (): boolean
      • Detects if the current environment is a mobile VR device (Oculus Browser, Samsung Browser VR, etc.)

        Returns boolean

        True if running on a mobile VR device, false otherwise

  • isNode: (() => boolean)
      • (): boolean
      • Detects if the current environment is Node.js

        Returns boolean

        True if running in Node.js environment, false otherwise

  • isObject: ((o: any) => boolean)
      • (o): boolean
      • Checks if a value is a plain object (not an array or other object types)

        Parameters

        • o: any

          The value to check

        Returns boolean

        True if the value is a plain object, false otherwise

  • isSafari: (() => boolean)
      • (): boolean
      • Detects if the current browser is Safari (excluding Chrome-based browsers)

        Returns boolean

        True if running on Safari browser, false otherwise

  • preventDefaultForDesktopOnly: ((e: Event) => void)
      • (e): void
      • Prevents the default behavior of an event only on desktop devices

        Parameters

        • e: Event

          The event to potentially prevent default behavior for

        Returns void