npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@homee-ai/3d-space-viewer

v0.0.30-alpha

Published

This package is a react package for rendering 3D space for viewing

Downloads

9

Readme

Homee 3D Space Viewer

This viewer enables the rendering of 3D spaces, enhancing visual detail through precise spatial information (e.g., dimensions, object coordinates). It offers features for navigating and adjusting the camera view within the space. Additionally, this library includes a chat UI component that interacts with an AI service, allowing users to communicate with a custom AI designed to understand the rendered space. Interaction between the chat and the viewer is facilitated through a context function provided by the library.

Installation

npm install @homee-ai/3d-space-viewer

Quick Start

To initiate the viewer:

import { HomeeViewer, HomeeViewerProvider } from '@homee-ai/3d-space-viewer'

const Viewer = () => {
  return <HomeeViewer source={{ scene: 'homee-scene.ply', model: 'homee-room.glb' }} />
}

const App = () => {
  return (
    <HomeeViewerProvider>
      <Viewer />
    </HomeeViewerProvider>
  )
}

export default App

API

HomeeViewerProvider

<HomeeViewerProvider>
  {children}
</HomeeViewerProvider>

useHomeeViewer

// pattern for getting global states under `HomeeViewerProvider`
const initViewer = useHomeeViewerContext(state =>  state.initViewer)
const disposeViewer = useHomeeViewerContext(state =>  state.disposeViewer)

Returns

  • isDimensionShown: boolean
    • when true indicate space dimensions are visible in the viewer.
    • when false indicates space dimensions are not visible in the viewer.
  • isPreviewMode: boolean
    • when true indicate space is in preview mode and mouse movement is disabled.
    • when false indicates that space is not in preview mode.
  • initViewer: ({ ref?: HTMLDivElement, sharedMemoryForWorkers?: boolean, preview?: boolean }) => Promise<void>
    • bind the viewer to div element.
    • if no ref is provided, by default the viewer will bind to document.body.
    • sharedMemoryForWorkers tells the viewer to use shared memory via a SharedArrayBuffer (for better performance) to transfer data to and from the sorting web worker. Refer to the CORS section below when setting this field to true.
      • default false
    • preview when set to true it will enable preview mode which will disable mouse movement and only allow user to rotate the view angle of the space on a fixed point.
      • default false
  • disposeViewer: () => Promise<void>
    • require viewer to be init before calling.
    • dispose the viewer
  • loadSpace: (arg: { sceneSrc: string, modelSrc: string }) => Promise<void>
    • require viewer to be init before calling.
    • sceneSrc should be either a .ply or .kspat source, used for loading the 3D scene.
    • modelSrc should be a .glb source, used to map to the 3D scene on load to provide accurate coordinates and dimensions for interactions.
  • setCameraHeight: (level: number) => void
    • min:0, max:1
    • require viewer to be init before calling.
    • adjust the viewer's camera height (y).
  • moveCamera: (arg: { position: { x: number, z: number }, target?: { x: number, z: number } | null }) => void
    • require viewer to be init before calling.
    • position will move the camera position to x and z.
    • target will move the camera view to x and z.
    • height (y) of the camera will remain the same when moving camera.
  • toggleDimensionView: (bool? boolean) => void
    • if bool is provided it will set isDimensionShown to value, else it will toggle isDimensionShown value.

HomeeViewer

<HomeeViewer source={{ scene: 'homee-scene.ply', model: 'homee-plan.glb' }} />

Props

  • source: { scene: string, model: string }
    • required
    • scene should be either a .ply or .kspat source, used for loading the 3D scene.
    • model should be a .glb source, used to map to the 3D scene on load to provide accurate coordinates and dimensions for interactions.
  • sharedMemoryForWorkers?: boolean
    • optional (default: false)
    • tells the viewer to use shared memory via a SharedArrayBuffer (for better performance) to transfer data to and from the sorting web worker. Refer to the CORS section below when setting this field to true.
  • preview?: boolean
    • optional (default: false)
    • when set to true it will enable preview mode which will disable mouse movement and only allow user to rotate the view angle of the space on a fixed point.

CORS issue and SharedArrayBuffer

By default, the Viewer class uses shared memory (via a typed array backed by a SharedArrayBufffer) to communicate with the web worker to enhance the performance. This mechanism presents a potential security issue that is outlined here: https://web.dev/articles/cross-origin-isolation-guide. Shared memory can be disabled by passing false for the sharedMemoryForWorkers parameter to the constructor for Viewer, but if you want to leave it enabled, a couple of extra CORS HTTP headers need to be present in the response from the server that is sent when loading the application.