diff --git a/src/components/DoodlePreview.js b/src/components/DoodlePreview.js index 78d70a6..ce2d650 100644 --- a/src/components/DoodlePreview.js +++ b/src/components/DoodlePreview.js @@ -9,6 +9,9 @@ import injectSheet from 'react-jss'; import ReactResizeDetector from 'react-resize-detector'; import requestAnimationFrame from 'raf'; import { load as loadMatcapMaterial } from '../d3/MatcapMaterial.js'; +import createRAFOnce from '../utils/rafOnce.js'; + +const rafOnce = createRAFOnce(); const styles = { container: { @@ -56,7 +59,7 @@ class DoodlePreview extends React.Component { this.setState(scene); this.editorControls = new THREE.EditorControls(scene.camera, canvas); - this.editorControls.addEventListener('change', scene.render); + this.editorControls.addEventListener('change', rafOnce(scene.render)); loadMatcapMaterial.then(scene.render); }