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

Commit 4b13579

Browse files
committed
refactor(Sky.vue, Sparkles/component.vue): streamline instance exposure and remove unused refs
- Updated `Sky.vue` to directly expose the `skyImpl` instance instead of using a shallow reference, improving clarity and performance. - Removed the unused `sparkleRef` in `Sparkles/component.vue`, simplifying the component structure while maintaining functionality. - These changes enhance code maintainability and align with best practices for instance management in Vue components.
1 parent d59ef26 commit 4b13579

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/core/staging/Sky.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useTres } from '@tresjs/core'
33
// eslint-disable-file vue/attribute-hyphenation
44
import { MathUtils, Vector3 } from 'three'
55
import { Sky as SkyImpl } from 'three-stdlib'
6-
import { computed, shallowRef, watch } from 'vue'
6+
import { computed, watch } from 'vue'
77
88
export interface SkyProps {
99
/**
@@ -53,7 +53,6 @@ watch(props, () => {
5353
invalidate()
5454
})
5555
56-
const skyRef = shallowRef<SkyImpl>()
5756
const skyImpl = new SkyImpl()
5857
const sunPosition = computed(() =>
5958
getSunPosition(props.azimuth, props.elevation),
@@ -66,14 +65,13 @@ function getSunPosition(azimuth: number, elevation: number) {
6665
}
6766
6867
defineExpose({
69-
instance: skyRef,
68+
instance: skyImpl,
7069
sunPosition: sunPosition.value,
7170
})
7271
</script>
7372

7473
<template>
7574
<primitive
76-
ref="skyRef"
7775
:object="skyImpl"
7876
:material-uniforms-turbidity-value="props.turbidity"
7977
:material-uniforms-rayleigh-value="props.rayleigh"

src/core/staging/Sparkles/component.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ const shaderMaterialParameters: ShaderMaterialParameters = {
323323
const mat = new ShaderMaterial(shaderMaterialParameters)
324324
const sparkles = new Points(undefined, mat)
325325
326+
defineExpose({ instance: sparkles })
327+
326328
const u = mat.uniforms
327329
const NOW = { immediate: true }
328330
@@ -414,11 +416,8 @@ onUnmounted(() => {
414416
infoTexture.value.dispose()
415417
mat.dispose()
416418
})
417-
418-
const sparkleRef = shallowRef()
419-
defineExpose({ instance: sparkles })
420419
</script>
421420

422421
<template>
423-
<primitive ref="sparkleRef" :object="sparkles" />
422+
<primitive :object="sparkles" />
424423
</template>

0 commit comments

Comments
 (0)