Skip to content

Commit c4547f9

Browse files
authored
feat: 492 set tone mapping default to acesfilmictonemapping (#498)
* feat: set ACESFilmicToneMapping as default toneMapping * chore: usage of nullish coealescing operator instead of ternaries
1 parent 8bbafde commit c4547f9

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

playground/src/components/TheExperience.vue

-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<script setup lang="ts">
22
import { ref, watchEffect } from 'vue'
3-
import { BasicShadowMap, SRGBColorSpace, NoToneMapping } from 'three'
43
import { TresCanvas } from '@tresjs/core'
54
import { OrbitControls } from '@tresjs/cientos'
65
import { TresLeches, useControls } from '@tresjs/leches'
@@ -10,10 +9,6 @@ import TheSphere from './TheSphere.vue'
109
const gl = {
1110
clearColor: '#82DBC5',
1211
shadows: true,
13-
alpha: false,
14-
shadowMapType: BasicShadowMap,
15-
outputColorSpace: SRGBColorSpace,
16-
toneMapping: NoToneMapping,
1712
}
1813
1914
const wireframe = ref(true)
@@ -39,7 +34,6 @@ watchEffect(() => {
3934
ref="canvas"
4035
window-size
4136
class="awiwi"
42-
:style="{ background: '#008080' }"
4337
>
4438
<TresPerspectiveCamera
4539
:position="[7, 7, 7]"

src/composables/useRenderer/const.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ACESFilmicToneMapping, PCFSoftShadowMap, SRGBColorSpace } from 'three'
1+
import { ACESFilmicToneMapping, NoToneMapping, PCFSoftShadowMap, SRGBColorSpace } from 'three'
22

33
export const rendererPresets = {
44
realistic: {
@@ -12,6 +12,10 @@ export const rendererPresets = {
1212
type: PCFSoftShadowMap,
1313
},
1414
},
15+
flat: {
16+
toneMapping: NoToneMapping,
17+
toneMappingExposure: 1,
18+
},
1519
}
1620

1721
export type RendererPresetsType = keyof typeof rendererPresets

src/composables/useRenderer/index.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { Color, WebGLRenderer } from 'three'
2-
import { shallowRef, watchEffect, onUnmounted, type MaybeRef, computed, watch, nextTick } from 'vue'
1+
import { ACESFilmicToneMapping, Color, WebGLRenderer } from 'three'
2+
import { shallowRef, watchEffect, onUnmounted, type MaybeRef, computed, watch } from 'vue'
3+
34
import {
45
toValue,
56
unrefElement,
@@ -77,7 +78,7 @@ export interface UseRendererOptions extends TransformToMaybeRefOrGetter<WebGLRen
7778
* CineonToneMapping, ACESFilmicToneMapping,
7879
* CustomToneMapping
7980
*
80-
* @default NoToneMapping
81+
* @default ACESFilmicToneMapping
8182
*/
8283
toneMapping?: MaybeRefOrGetter<ToneMapping>
8384

@@ -124,14 +125,12 @@ export function useRenderer(
124125
) {
125126

126127
const webGLRendererConstructorParameters = computed<WebGLRendererParameters>(() => ({
127-
alpha: toValue(options.alpha),
128+
alpha: toValue(options.alpha) ?? true,
128129
depth: toValue(options.depth),
129130
canvas: unrefElement(canvas),
130131
context: toValue(options.context),
131132
stencil: toValue(options.stencil),
132-
antialias: toValue(options.antialias) === undefined // an opinionated default of tres
133-
? true
134-
: toValue(options.antialias),
133+
antialias: toValue(options.antialias) ?? true,
135134
precision: toValue(options.precision),
136135
powerPreference: toValue(options.powerPreference),
137136
premultipliedAlpha: toValue(options.premultipliedAlpha),
@@ -273,7 +272,7 @@ export function useRenderer(
273272
set(renderer.value, pathInThree, getValue(option, pathInThree))
274273

275274
setValueOrDefault(options.shadows, 'shadowMap.enabled')
276-
setValueOrDefault(options.toneMapping, 'toneMapping')
275+
setValueOrDefault(options.toneMapping ?? ACESFilmicToneMapping, 'toneMapping')
277276
setValueOrDefault(options.shadowMapType, 'shadowMap.type')
278277

279278
if (revision < 150)

0 commit comments

Comments
 (0)