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

@vctrl/viewer

v0.2.2

Published

vctrl/viewer is a React component library for rendering and interacting with 3D models. It's part of the vectreal ecosystem and is designed to work seamlessly with the vctrl/hooks package for model loading and management.

Downloads

369

Readme

vctrl/viewer

Version and release packages to NPM @vctrl/viewer | NPM Downloads

This library is still undergoing heavy development until the first major version is released. This may lead to breaking changes in upcoming updates.

Overview

vctrl/viewer is a React component library for rendering and interacting with 3D models. It's part of the vectreal ecosystem and is designed to work seamlessly with the vctrl/hooks package for model loading and management.

Table of Contents

Features

  • Easy-to-use React component for 3D model visualization
  • Integration with Three.js and React Three Fiber
  • Customizable camera, controls, and grid options
  • Support for various 3D model formats (via vctrl/hooks)
  • Responsive design with automatic resizing
  • Custom loading component support

Installation

To install the package, use npm or yarn:

npm install @vctrl/viewer
# or
yarn add @vctrl/viewer

Usage

Here's a basic example of how to use the VectrealViewer component:

import React from 'react';
import { VectrealViewer } from '@vctrl/viewer';
import { ModelProvider } from '@vctrl/hooks/use-load-model';

function App() {
  return (
    <ModelProvider>
      <VectrealViewer />
    </ModelProvider>
  );
}

export default App;

You can also load any model supported by the react-three-drei loading hooks and pass it into the VectrealViewer using the model prop.

API Reference

VectrealViewer Component

The main component exported by this package.

Props

| Prop | Type | Description | | --------------- | ----------------- | ---------------------------------------------------------- | | model | Object3D | (Optional) The 3D model to display | | className | string | (Optional) Additional CSS classes for the viewer container | | cameraOptions | CameraProps | (Optional) Configuration for the camera | | controlsOptions | ControlsProps | (Optional) Configuration for the OrbitControls | | gridOptions | GridProps | (Optional) Configuration for the grid | | loader | () => JSX.Element | (Optional) Custom loading component |

Customization

Camera Options

You can customize the camera by passing a cameraOptions prop:

<VectrealViewer
  cameraOptions={{
    initialCameraPosition: new Vector3(0, 5, 5),
    fov: 75,
    aspect: 1,
    near: 0.1,
    far: 1000,
  }}
/>

Controls Options

Customize the OrbitControls with the controlsOptions prop:

<VectrealViewer
  controlsOptions={{
    maxPolarAngle: Math.PI / 2,
    autoRotate: true,
    controlsTimeout: 2000,
  }}
/>

Grid Options

Configure the grid display with the gridOptions prop:

<VectrealViewer
  gridOptions={{
    showGrid: true,
    cellSize: 0.5,
    sectionSize: 5,
    sectionColor: 'rgb(134, 73, 33)',
    cellColor: 'rgb(100, 100, 100)',
  }}
/>

Integration with vctrl/hooks

The VectrealViewer component is designed to work with the vctrl/hooks package. It uses the useModelContext hook to access the loaded model and loading state:

import { ModelProvider } from '@vctrl/hooks/use-load-model';
import { VectrealViewer } from '@vctrl/viewer';

function App() {
  return (
    <ModelProvider>
      <VectrealViewer />
      {/* Other components that use the model context */}
    </ModelProvider>
  );
}

Development

This package is part of a monorepo workspace managed with Nx. To contribute or modify the package:

  1. Clone the monorepo
  2. Install dependencies: npm install or yarn install
  3. Make your changes
  4. Build the package: nx build vctrl/viewer
  5. Test your changes: nx test vctrl/viewer

License

Please refer to the LICENSE file in the package root for licensing information.

Contributing

Contributions are welcome! Please read the contributing guidelines in the vectreal-core monorepo before submitting pull requests.

Support

For issues, feature requests, or questions, please file an issue in the GitHub repository.