From 5ed57c477647598c778b5634d7fa1b5b4d381b2c Mon Sep 17 00:00:00 2001 From: alvarosabu Date: Fri, 12 Jul 2024 09:11:41 +0200 Subject: [PATCH 1/4] feat: add deprecation warnings to disableRender --- src/components/TresCanvas.vue | 9 ++++++--- src/composables/useRenderer/index.ts | 1 - src/composables/useTresContextProvider/index.ts | 3 --- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/components/TresCanvas.vue b/src/components/TresCanvas.vue index 207601720..b7f98bf49 100644 --- a/src/components/TresCanvas.vue +++ b/src/components/TresCanvas.vue @@ -55,6 +55,9 @@ export interface TresCanvasProps camera?: TresCamera preset?: RendererPresetsType windowSize?: boolean + /** + * @deprecated since version 4.2. Use `take-over render loop` approach instead. To be fully removed on v5. See https://docs.tresjs.org/api/composables.html#take-over-the-render-loop + */ disableRender?: boolean } @@ -65,6 +68,9 @@ const props = withDefaults(defineProps(), { stencil: undefined, antialias: undefined, windowSize: undefined, + /** + * @deprecated since version 4.2. Use `take-over render loop` approach instead. To be fully removed on v5. See https://docs.tresjs.org/api/composables.html#take-over-the-render-loop + */ disableRender: undefined, useLegacyLights: undefined, preserveDrawingBuffer: undefined, @@ -144,8 +150,6 @@ const dispose = (context: TresContext, force = false) => { mountCustomRenderer(context) } -const disableRender = computed(() => props.disableRender) - const context = shallowRef(null) defineExpose({ context, dispose: () => dispose(context.value as TresContext, true) }) @@ -157,7 +161,6 @@ onMounted(() => { scene: scene.value as TresScene, canvas: existingCanvas, windowSize: props.windowSize ?? false, - disableRender: disableRender.value ?? false, rendererOptions: props, emit, }) diff --git a/src/composables/useRenderer/index.ts b/src/composables/useRenderer/index.ts index f80c468c0..7fcdedfc6 100644 --- a/src/composables/useRenderer/index.ts +++ b/src/composables/useRenderer/index.ts @@ -111,7 +111,6 @@ export function useRenderer( options: UseRendererOptions emit: EmitEventFn contextParts: Pick & { invalidate: () => void, advance: () => void } - disableRender: MaybeRefOrGetter }, ) { const webGLRendererConstructorParameters = computed(() => ({ diff --git a/src/composables/useTresContextProvider/index.ts b/src/composables/useTresContextProvider/index.ts index c3e1d6943..1912e3506 100644 --- a/src/composables/useTresContextProvider/index.ts +++ b/src/composables/useTresContextProvider/index.ts @@ -88,14 +88,12 @@ export function useTresContextProvider({ scene, canvas, windowSize, - disableRender, rendererOptions, emit, }: { scene: TresScene canvas: MaybeRef windowSize: MaybeRefOrGetter - disableRender: MaybeRefOrGetter rendererOptions: UseRendererOptions emit: EmitEventFn @@ -150,7 +148,6 @@ export function useTresContextProvider({ emit, // TODO: replace contextParts with full ctx at https://github.com/Tresjs/tres/issues/516 contextParts: { sizes, camera, render, invalidate, advance }, - disableRender, }, ) From 98884bf8a82cf895f7dd3cce027762daffad28f9 Mon Sep 17 00:00:00 2001 From: alvarosabu Date: Fri, 12 Jul 2024 09:11:50 +0200 Subject: [PATCH 2/4] docs: updated docs with deprecation --- docs/api/tres-canvas.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/tres-canvas.md b/docs/api/tres-canvas.md index 71677b7e4..df02eff8f 100644 --- a/docs/api/tres-canvas.md +++ b/docs/api/tres-canvas.md @@ -78,7 +78,7 @@ renderer.shadowMap.type = PCFSoftShadowMap | **context** | This can be used to attach the renderer to an existing [RenderingContext](https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext) | | | **depth** | Whether the drawing buffer has a [depth buffer](https://en.wikipedia.org/wiki/Z-buffering) of at least 16 bits. | `true` | | **renderMode** | Render mode, can be `always`, `on-demand` or `manual`. See [Performance](../advanced/performance) | `always` | -| **disableRender** | Disable render on requestAnimationFrame, useful for PostProcessing | `false` | +| **~~disableRender~~** | **⚠️ Deprecated**: since version 4.2. Use [`take-over render` approach](https://docs.tresjs.org/api/composables.html#take-over-the-render-loop) instead. | `false` | | **failIfMajorPerformanceCaveat** | Whether the renderer creation will fail upon low performance is detected. See [WebGL spec](https://registry.khronos.org/webgl/specs/latest/1.0/#5.2) for details. | `false` | | **logarithmicDepthBuffer** | Whether to use a logarithmic depth buffer. It may be necessary to use this if dealing with huge differences in scale in a single scene. Note that this setting uses gl_FragDepth if available which disables the [Early Fragment Test](https://www.khronos.org/opengl/wiki/Early_Fragment_Test) optimization and can cause a decrease in performance. | `false` | | **outputColorSpace** | Defines the output encoding | `LinearEncoding` | From 4fa8066f1d0f151e1a9e65688b84e28cab215d52 Mon Sep 17 00:00:00 2001 From: alvarosabu Date: Fri, 12 Jul 2024 09:27:47 +0200 Subject: [PATCH 3/4] chore(playground): remove unusued method --- playground/src/pages/basic/index.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/playground/src/pages/basic/index.vue b/playground/src/pages/basic/index.vue index ded16d043..4402d45db 100644 --- a/playground/src/pages/basic/index.vue +++ b/playground/src/pages/basic/index.vue @@ -52,7 +52,6 @@ const toonTealMaterial = new MeshToonMaterial({ Date: Fri, 12 Jul 2024 09:45:17 +0200 Subject: [PATCH 4/4] chore: fix lint --- src/components/TresCanvas.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/TresCanvas.vue b/src/components/TresCanvas.vue index b7f98bf49..9a96bb018 100644 --- a/src/components/TresCanvas.vue +++ b/src/components/TresCanvas.vue @@ -10,7 +10,6 @@ import * as THREE from 'three' import type { App, Ref } from 'vue' import { Fragment, - computed, createRenderer, defineComponent, getCurrentInstance,