render on request anim frame in doodle preview

This commit is contained in:
casperlamboo 2017-12-05 14:12:56 +01:00
parent 595327da17
commit e8d474fada
1 changed files with 4 additions and 1 deletions

View File

@ -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);
}