Skip to content

Commit 37eda28

Browse files
committed
fix: improve type guard
1 parent 38e6fff commit 37eda28

File tree

1 file changed

+4
-4
lines changed
  • packages/cientos/src/core/materials/meshReflectionMaterial

1 file changed

+4
-4
lines changed

packages/cientos/src/core/materials/meshReflectionMaterial/index.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
WebGLRenderTarget,
2222
} from 'three'
2323
import { computed, onBeforeUnmount, shallowRef, toValue, watch } from 'vue'
24-
import type { TresColor } from '@tresjs/core'
24+
import type { TresColor, TresObject } from '@tresjs/core'
2525
import { BlurPass } from './BlurPass'
2626
import { MeshReflectionMaterial } from './material'
2727
@@ -158,7 +158,7 @@ const hasDepth = computed(() => props.sharpDepthScale > 0 || props.blurDepthScal
158158
const hasDistortion = computed(() => !!props.distortionMap)
159159
const hasRoughness = computed(() => !!props.roughnessMap)
160160
161-
const materialRef = shallowRef()
161+
const materialRef = shallowRef<TresObject>()
162162
let blurpass: BlurPass
163163
164164
const state = {
@@ -279,11 +279,11 @@ onBeforeUnmount(() => {
279279
const { onBeforeRender } = useLoop()
280280
281281
onBeforeRender(({ renderer, scene, camera }) => {
282-
const parent = (materialRef.value as any)?.__tres?.parent
282+
const parent = materialRef.value?.__tres?.parent
283283
if (!parent) { return }
284284
// WebGPU compatibility: avoid importing three/webgpu (not exported in older versions).
285285
// Detect WebGPU renderer by its flag property defined in its class (`isWebGPURenderer: true`).
286-
if ((renderer as any)?.isWebGPURenderer === true) {
286+
if ('isWebGPURenderer' in renderer && renderer.isWebGPURenderer === true) {
287287
console.warn('MeshReflectionMaterial: WebGPURenderer is not supported yet')
288288
return
289289
}

0 commit comments

Comments
 (0)