0.1.6 • Published 3 years ago

jscad-react v0.1.6

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

jscad-react

Overview

This package provides a rendering component for rendering jscad models (V2). It currently requires the alpha version of the rendering package.

Installation

By itself it doesn't actually render any solids, it just shows a default grid view. You will need to install the @jscad/modeling package as well.

# Install the react component.
npm i -S jscad-react

# Install the jscad modeling package.
npm i -S @jscad/modeling

Usage

Typescript

import * as React from 'react'
import { cube } from '@jscad/modeling/src/primitives'
import { render } from 'react-dom'
import { Renderer } from 'jscad-react'

const App: React.FC = () => {
  const [solids] = React.useState<any[]>([cube([0, 0, 0], 12)])
  return <Renderer solids={solids} height={500} width={500} />
}

render(<App />, document.body)

Javascript

import * as React from 'react'
import { cube } from '@jscad/modeling/src/primitives'
import { render } from 'react-dom'
import { Renderer } from 'jscad-react'

const App = () => {
  const [solids] = React.useState([cube([0, 0, 0], 12)])
  return <Renderer solids={solids} height={500} width={500} />
}

render(<App />, document.body)

The renderer only rerenders on state change. If your app is having rendering issues you can add the animate prop and it will run the render as a requestAnimationFrame loop.

License

The MIT License (MIT)

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago