Commit 6426856 1 parent f196a38 commit 6426856 Copy full SHA for 6426856
File tree 4 files changed +8
-4
lines changed
playground/src/pages/rendering-modes
composables/useTresContextProvider
4 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ setTimeout(() => {
13
13
<template >
14
14
<TresCanvas
15
15
:clear-color =" clearColor"
16
- render-mode =" manual "
16
+ render-mode =" on-demand "
17
17
@render =" () => console.log('onRender')"
18
18
>
19
19
<Scene />
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import { OrbitControls } from '@tresjs/cientos'
5
5
const { invalidate, advance } = useTres ()
6
6
7
7
function onControlChange() {
8
- advance ()
8
+ invalidate ()
9
9
}
10
10
11
11
const positionX = ref (0 )
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ export interface TresContext {
45
45
* If set to 'always', the scene will be rendered every frame
46
46
*/
47
47
renderMode : Ref < 'always' | 'on-demand' | 'manual' >
48
+ canBeInvalidated : ComputedRef < boolean >
48
49
internal : InternalState
49
50
/**
50
51
* Invalidates the current frame when renderMode === 'on-demand'
@@ -147,6 +148,8 @@ export function useTresContextProvider({
147
148
disableRender,
148
149
} )
149
150
151
+ const renderMode = ref < 'always' | 'on-demand' | 'manual' > ( rendererOptions . renderMode || 'always' )
152
+
150
153
const toProvide : TresContext = {
151
154
sizes,
152
155
scene : localScene ,
@@ -167,7 +170,8 @@ export function useTresContextProvider({
167
170
accumulator : [ ] ,
168
171
} ,
169
172
} ,
170
- renderMode : ref ( rendererOptions . renderMode || 'always' ) ,
173
+ renderMode,
174
+ canBeInvalidated : computed ( ( ) => renderMode . value === 'on-demand' && internal . frames . value === 0 ) ,
171
175
internal,
172
176
advance,
173
177
extend,
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ export function invalidateInstance(instance: TresObject) {
28
28
29
29
if ( ! ctx ) return
30
30
31
- if ( ctx . renderMode . value === 'on-demand' && ctx . internal . frames . value === 0 ) {
31
+ if ( ctx . canBeInvalidated . value ) {
32
32
ctx . invalidate ( )
33
33
}
34
34
You can’t perform that action at this time.
0 commit comments