Skip to content
This repository was archived by the owner on Feb 1, 2026. It is now read-only.

Commit eb337d4

Browse files
committed
fix: update camera reference handling in Billboard and ScreenSpace components
- Modified the `update` function in `Billboard.vue` to correctly use `camera.value` for improved reactivity. - Updated the camera reference handling in `ScreenSpace.vue` to ensure both `outerRef` and `camera.value` are checked before accessing their properties, enhancing stability. - Adjusted the `imageBounds` computed property in `Image/component.vue` to safely access image dimensions, preventing potential runtime errors. - Removed unused `shallowRef` import in `Sparkles/component.vue` to streamline the component structure.
1 parent 4b13579 commit eb337d4

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/core/abstractions/Billboard.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function update(camera?: Camera) {
6060
}
6161
6262
useLoop().onBeforeRender(({ camera }) => {
63-
if (props.autoUpdate) { update(camera) }
63+
if (props.autoUpdate) { update(camera.value) }
6464
})
6565
6666
defineExpose({ instance: outerRef, update })

src/core/abstractions/Image/component.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const imageRef = shallowRef()
7979
const texture = shallowRef<Texture | null>(props.texture ?? null)
8080
const size = useTres().sizes
8181
const planeBounds = computed(() => Array.isArray(props.scale) ? [props.scale[0], props.scale[1]] : [props.scale, props.scale])
82-
const imageBounds = computed(() => [texture.value?.image.width ?? 0, texture.value?.image.height ?? 0])
82+
const imageBounds = computed(() => [texture.value?.image?.width ?? 0, texture.value?.image?.height ?? 0])
8383
const resolution = computed(() => Math.max(size.width.value, size.height.value))
8484
8585
watchEffect(() => {
@@ -88,7 +88,7 @@ watchEffect(() => {
8888
}
8989
else {
9090
const { state: t } = useTexture(props.url!)
91-
texture.value = t
91+
texture.value = t.value
9292
}
9393
})
9494

src/core/abstractions/ScreenSpace.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ withDefaults(defineProps<ScreenSpaceProps>(), {
1313
const outerRef = shallowRef()
1414
1515
useLoop().onBeforeRender(({ camera }) => {
16-
if (outerRef.value) {
17-
outerRef.value.quaternion.copy(camera.quaternion)
18-
outerRef.value.position.copy(camera.position)
16+
if (outerRef.value && camera.value) {
17+
outerRef.value.quaternion.copy(camera.value.quaternion)
18+
outerRef.value.position.copy(camera.value.position)
1919
}
2020
})
2121

src/core/staging/Sparkles/component.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
Uniform,
1212
Vector3,
1313
} from 'three'
14-
import { onMounted, onUnmounted, shallowRef, toRefs, watch } from 'vue'
14+
import { onMounted, onUnmounted, toRefs, watch } from 'vue'
1515
import type { TresColor, VectorFlexibleParams } from '@tresjs/core'
1616
import type { Blending, BufferGeometry, IUniform, ShaderMaterialParameters, Texture } from 'three'
1717
import type { Ref } from 'vue'

0 commit comments

Comments
 (0)