Skip to content

Commit

Permalink
clear canvas if data changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Hydrophobefireman committed Feb 1, 2021
1 parent 5edc3d2 commit 5d3ba03
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
import * as React from 'react'
import styles from './styles.module.css'
import './setup'

import * as React from 'react'

import { SpeRuntime } from './spline-runtime.js'
import styles from './styles.module.css'

interface Props {
scene: object
assets: object
}

export const Spline = ({ scene, assets }: Props) => {
const ref = React.useRef()
React.useEffect(() => {
const { current } = ref
if (current) {
current.width = current.width
}
const splineRuntime = new SpeRuntime(scene, assets)
splineRuntime.run()
}, [])
}, [scene, assets])
return (
<div>
<div className={styles.container}>
<canvas id='canvas3d' className={styles.canvas}></canvas>
<canvas id='canvas3d' className={styles.canvas} ref={ref}></canvas>
</div>
</div>
)
Expand Down

0 comments on commit 5d3ba03

Please sign in to comment.