locar
    Preparing search index...

    Class App

    Application class to orchestrate the interaction between the individual LocAR classes and the Three.js camera, renderer and scene.

    Hierarchy (View Summary)

    Index
    • Create an App object.

      Parameters

      • -: AppOptions

        Startup options. Note that you can only specify ONE of cameraOptions and threeObjects, as cameraOptions is intended to configure a new three.js camera, while threeObjects allows you to specify an existing camera, renderer and scene.

      Returns App

    camera: PerspectiveCamera
    cameraFeedDimensions: { landHeight: number; landWidth: number } | null
    deviceOrientationControls: DeviceOrientationControls | null
    eventHandlers: Record<string, ((...args: any[]) => void)[]>
    locar: LocAR
    origHfov: number
    renderer: WebGLRenderer
    scene: Scene
    webcam: Webcam
    • Set the correct three.js camera field of view based on the proportion of the webcam feed currently visible.

      Parameters

      • videoWidth: number

        the current video feed width

      • videoHeight: number

        the current video feed height

      • aspectScreen: number

        the current screen aspect ratio

      Returns void

    • Remove an event handler.

      Parameters

      • eventName: string

        the event to remove a handler from.

      • eventHandler: (...args: any[]) => void

        the event handler function to remove.

      Returns void

    • Add an event handler. Overridden from EventEmitter to create a ClickHandler for objectsIntersected event.

      Parameters

      • eventName: string

        the event to handle.

      • eventHandler: (...args: any[]) => void

        the event handler function.

      Returns void

    • Start the app. Must be called after construction.

      Returns Promise<LocAR>

      Promise resolving with LocAR object. Rejects with object containing code and message.

    • Sync the Three.js fov with the webcam. It may be necessary to adjust the Three fov to match the proportion of the world currently visible through the webcam, which will vary depending on orientation (portrait or landscape) For example, if the device is in portrait, less of the world horizontally will be visible. Mostly intended to be called internally: if you are developing a pure LocAR app you will not need to call this. However it will be necessary to call this on each frame if another library/framework (typically R3F) has provided the three.js objects (i.e the threeObjects option has been provided to the constructor).

      Parameters

      • OptionalaspectScreen: number

      Returns void