# @standard/view

> 3D Graphics Library for React Apps

Latest version **1.0.5** (published 2020-07-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install @standard/view
pnpm add @standard/view
yarn add @standard/view
bun add @standard/view
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2020-07-31 |
| First published | 2020-06-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 3.3 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Maintainers | alex-scott-sc, chongr, franciscop-sc, loganweir, maytee, mike-sc, standardcognition, wasifislam |
| Keywords | standard-view, standard-view-core, standard, view, core, react-three-fiber, three, three.js, visualization, tool, package, 3D, graphics |

## Links

- npm: https://www.npmjs.com/package/@standard/view
- Repository: https://github.com/standard-ai/standard-view
- npm.io page: https://npm.io/package/@standard/view

## Dependencies (2)

- [stats.js](https://npm.io/package/stats.js.md) ^0.17.0
- [multivariate-normal](https://npm.io/package/multivariate-normal.md) ^0.1.2

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 1.0.5 (latest) — 2020-07-31
- 1.0.4 — 2020-07-10
- 1.0.3 — 2020-06-25
- 1.0.0 — 2020-06-25

## README

# Standard View

# Usage

Install

```
$ npm install @standard/view
```

Place Views into your React App. For example:

```
import { View3D, Box } from '@standard/view';
.
.
.
<View3D>
  <Box position={[1, 0, 0]} color="green" />
  <Box position={[-1, 0, 0]} color="red" />
</View3D>
```

<img src="https://github.com/standard-ai/standard-view/blob/master/example-gifs/example.png?raw=true" width="250" height="200" />

For details about valid properties, look at the interfaces named `*Props`, where `*` is the component name, in `src/primitves/` and `src/groups/`.

## Stories

`yarn storybook` to see stories of each component in `standard-view`.
You may also visit [Standard View Storybook](https://standard-view.netlify.app/?path=/story) served with netlify.

### Examples

<p align="center">
<img src="https://github.com/standard-ai/standard-view/blob/master/example-gifs/sample-platter.gif?raw=true" width="800" height="400" />
<img src="https://github.com/standard-ai/standard-view/blob/master/example-gifs/standard-cube.gif?raw=true" width="400" height="400" />
</p>

## create-react-app to Standard View Project

<p align="center">
<img src="https://github.com/standard-ai/standard-view/blob/master/example-gifs/create-app-to-standard-view.gif?raw=true" />
</p>

## Fit to Window

<p align="center">
<img src="https://github.com/standard-ai/standard-view/blob/master/example-gifs/canvas-css.gif?raw=true" />
</p>

Set `.App canvas` in css file to adjust Standard View `View3D` canvas.

## Intellisense

<p align="center">
<img src="https://github.com/standard-ai/standard-view/blob/master/example-gifs/intellisense.gif?raw=true" />
</p>

For VSCode, press `ctrl + space` to force load intellisense at cursor location.

## Standard View Components

Primitives

- `Mesh`
- `Box`
- `Camera`
- `Circle`
- `Cylinder`
- `Plane`
- `Polygon`
- `Quad`
- `Sphere`
- `Triangle`

Groups

- `Group`
- `Arrow`
- `Axis`
- `Capsule`
- `GLTF`
- `OBJ`
- `PCD`

Lines

- `Line`
- `BoundingBox` (Group)

Texts

- `Text` (Mesh)
- `Label` (Mesh)

Lights

- `AmbientLight`
- `DirectionalLight`
- `HemisphereLight`
- `PointLight`
- `SpotLight`

Views

- `View3D`

## Mesh

All Standard View primitives are composed within `Mesh`,
with the exception of `Line`, `BoundingBox`, `Text`, and `Group`.
Therefore, properties of `Mesh` are common to nearly alll components.
Here is a list of explicitly managed `Mesh` properties in Standard View:

Mesh Properties

- position: Array\<number\>
- scale: Array\<number\>
- rotation: Array\<number\>
- quaternion: Array\<number\>

Material Properties

- color: string
- hoverColor: string
- opacity: number
- texturePath: string
- textureURL: string
- material: THREE.Material

Geometry Properties

- wireframe: boolean
- side: number
- geometry: THREE.Geometry

Animation Properties

- animation: Function
- state: Object

Event Properties

- onClick: Function
- onDoubleClick: Function
- onWheel: Function
- onPointerUp: Function
- onPointerDown: Function
- onPointerOver: Function
- onPointerOut: Function
- onPointerMove: Function

`Mesh` can also support animations via the animation property. A function with one argument that may be destructured to include `state`, `setState`, `mesh`, and any Canvas properties desired for the animation.
All primitives and shapes may have animation. These animations are reactive, so they incur many render calls, but also maintain `react-three-renderer`'s native raycasting for the event property functions.

`Mesh` also exposes `react-three-fiber`'s the event property functions but with a constrained argument set, similar to animation. All event property functions take one arguement that may be destructured to include `mesh`, `state`, `setState`, and any Canvas prop. The benefit of this design, just like animations, is that a reference to `mesh` is automatically provided. Moreover, `react-three-fiber`'s `Canvas` state properties are exposed. This allows event functions to reach right into the `react-three-fiber`/`three.js`'s `scene`, `camera`, `gl`, etc. Hence all shapes that are `Mesh`s may have these event property functions.

Of course, `Mesh` can accept properties handled by `react-three-fiber`/`three.js` as well.
After explicitly managing these properties, remaining properties are passed to `react-three-fiber`'s `mesh`.
(`Mesh` is a wrapper of `react-three-fiber`'s `mesh`, which is a wrapper of `THREE.Mesh`.)

## View3D

Here is a list of explicitly managed `View3D` properties in Standard View:

WebGLRenderer Properties

- background: string

Camera Control Properties

- trackballControls: boolean
- orbitControls: boolean
- mapControls: boolean

Of course, `View3D` can accept `Canvas` properties handled by `react-three-fiber` as well. The Standard View properties are handled and stripped away before passing the properties to `Canvas`.
(`View3D` is a wrapper of `react-three-fiber`'s `Canvas`.)

## Text

`Text` in Standard View is composed within a `Mesh`. So `Text` may accept all the same properties as a `Mesh`. `Text` also should have a `text` property with the desired string to be displayed and also a `font` or `fontName`. `font`s are typeface.json fonts and must be a `THREE.Font`. The default `three.js` fonts are also included in Standard View, so simply passing `fontName` with one of those fonts will work.

Fonts

- helvetiker
- helvetikerBold
- optimer
- optimerBold
- gentilis
- gentilisBold

In general `Text` will be much more computation expensive to render compared to `Label` which is just a `Plane` with a texture of the desired text.

## react-three-fiber

Checkout [`react-three-fiber`'s page](https://github.com/drcmda/react-three-fiber) for more details.

---
_Source: https://npm.io/package/@standard/view · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
