From e8d474fada5d8f5d125d1f57ba0a95fb7bbc840b Mon Sep 17 00:00:00 2001 From: casperlamboo Date: Tue, 5 Dec 2017 14:12:56 +0100 Subject: [PATCH] render on request anim frame in doodle preview --- src/components/DoodlePreview.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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); }