0.1.7 • Published 3 months ago

jscad-react v0.1.7

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months 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 (live demo)

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 (live demo)

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.7

3 months ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago