Skip to content

Commit

Permalink
feat: add disable render prop for postprocessing
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarosabu committed Apr 17, 2023
1 parent b354e87 commit b2fd557
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/api/renderer.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ renderer.shadowMap.type: PCFSoftShadowMap
| **preserveDrawingBuffer** | Whether to preserve the buffers until manually cleared or overwritten.. | `false` |
| **clearColor** | The color the renderer will use to clear the canvas. | `#000000` |
| **windowSize** | Whether to use the window size as the canvas size or the parent element. | `false` |
| **disableRender** | Disable render on requestAnimationFrame, usefull for PostProcessing | `false` |

## Defaults

Expand Down
2 changes: 2 additions & 0 deletions src/components/TresCanvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface TresCanvasProps {
clearColor?: string
windowSize?: boolean
preset?: RendererPresetsType
disableRender?: boolean
}
/**
* Vue component for rendering a Tres component.
Expand All @@ -39,6 +40,7 @@ export const TresCanvas = defineComponent<TresCanvasProps>({
'clearColor',
'windowSize',
'preset',
'disableRender',
] as unknown as undefined,
setup(props, { slots, expose }) {
const tres = useTresProvider()
Expand Down
4 changes: 3 additions & 1 deletion src/components/TresScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface TresSceneProps {
clearColor?: string
windowSize?: boolean
preset?: RendererPresetsType
disableRender?: boolean
}
/**
* Vue component for rendering a Tres component.
Expand All @@ -46,6 +47,7 @@ export const TresScene = defineComponent<TresSceneProps>({
'clearColor',
'windowSize',
'preset',
'disableRender',
] as unknown as undefined,
setup(props, { slots, expose }) {
if (props.physicallyCorrectLights === true) {
Expand Down Expand Up @@ -89,7 +91,7 @@ export const TresScene = defineComponent<TresSceneProps>({
})

onLoop(() => {
if (activeCamera.value) renderer.value?.render(scene, activeCamera.value)
if (activeCamera.value && props.disableRender === true) renderer.value?.render(scene, activeCamera.value)

if (raycaster.value) {
const intersects = raycaster.value.intersectObjects(scene.children)
Expand Down

0 comments on commit b2fd557

Please sign in to comment.