bx-1140-postprocessing #12
|
@ -1,7 +1,7 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, watch } from 'vue';
|
import { onMounted, watch } from 'vue';
|
||||||
|
|
||||||
import { EquirectangularReflectionMapping, ReinhardToneMapping } from 'three';
|
import { ACESFilmicToneMapping, EquirectangularReflectionMapping, ReinhardToneMapping, SRGBColorSpace } from 'three';
|
||||||
import { GainMapLoader } from '@monogrid/gainmap-js'
|
import { GainMapLoader } from '@monogrid/gainmap-js'
|
||||||
import { useTresContext } from '@tresjs/core';
|
import { useTresContext } from '@tresjs/core';
|
||||||
|
|
||||||
|
@ -26,7 +26,12 @@ const loadEnv = async () => {
|
||||||
// scene.value.backgroundBlurriness = 0.15
|
// scene.value.backgroundBlurriness = 0.15
|
||||||
result.renderTarget.texture.dispose();
|
result.renderTarget.texture.dispose();
|
||||||
}
|
}
|
||||||
renderer.value.toneMapping = ReinhardToneMapping
|
// renderer.value.toneMapping = ReinhardToneMapping
|
||||||
|
renderer.value.outputColorSpace = SRGBColorSpace;
|
||||||
|
renderer.value.toneMapping = ACESFilmicToneMapping;
|
||||||
|
renderer.value.toneMappingExposure = 1;
|
||||||
|
|
||||||
|
renderer.value.setPixelRatio(1.5)
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
loadEnv()
|
loadEnv()
|
||||||
})
|
})
|
||||||
|
|
|
@ -72,6 +72,10 @@ const loadModels = async () => {
|
||||||
item.modelFile = loaded_scene
|
item.modelFile = loaded_scene
|
||||||
item.name = element.name
|
item.name = element.name
|
||||||
|
|
||||||
|
if(!element.is_enabled) {
|
||||||
|
item.modelFile.visible = false
|
||||||
|
}
|
||||||
|
|
||||||
models.value.push(item)
|
models.value.push(item)
|
||||||
|
|
||||||
const res = await fetch(`${SERVER_URL}/api/obj/clickable/?source=${element.id}`)
|
const res = await fetch(`${SERVER_URL}/api/obj/clickable/?source=${element.id}`)
|
||||||
|
|
|
@ -59,7 +59,7 @@ const clearColor = 'steelBlue'
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<div :class="[{ 'loading': models_loading }, 'canvas-wrapper']">
|
<div :class="[{ 'loading': models_loading }, 'canvas-wrapper']">
|
||||||
<TresCanvas window-size :alpha="false" power-preference="high-performance" :clear-color="clearColor">
|
<TresCanvas window-size :alpha="false" power-preference="high-performance" :clear-color="clearColor" :logarithmicDepthBuffer="true">
|
||||||
<TresPerspectiveCamera :position="cameraPosition" ref="camera" />
|
<TresPerspectiveCamera :position="cameraPosition" ref="camera" />
|
||||||
<OrbitControls v-bind="controlsState" @change="onChange" make-default />
|
<OrbitControls v-bind="controlsState" @change="onChange" make-default />
|
||||||
<Suspense>
|
<Suspense>
|
||||||
|
|
|
@ -9,6 +9,7 @@ import { OutputPass } from 'three/addons/postprocessing/OutputPass.js';
|
||||||
import { useTresContext, useLoop } from '@tresjs/core';
|
import { useTresContext, useLoop } from '@tresjs/core';
|
||||||
import { watch } from 'vue';
|
import { watch } from 'vue';
|
||||||
import { Color, Fog, FogExp2 } from 'three';
|
import { Color, Fog, FogExp2 } from 'three';
|
||||||
|
import { GammaCorrectionShader, TAARenderPass } from 'three/examples/jsm/Addons.js';
|
||||||
|
|
||||||
const { renderer, camera, scene } = useTresContext()
|
const { renderer, camera, scene } = useTresContext()
|
||||||
|
|
||||||
|
@ -20,37 +21,37 @@ const k = { start: 0.5, end: 3 }
|
||||||
if (camera.value) {
|
if (camera.value) {
|
||||||
const renderPass = new RenderPass(scene.value, camera.value);
|
const renderPass = new RenderPass(scene.value, camera.value);
|
||||||
|
|
||||||
const bokehPass = new BokehPass(scene.value, camera.value, {
|
// const bokehPass = new BokehPass(scene.value, camera.value, {
|
||||||
focus: props.tiltShift.focus,
|
// focus: props.tiltShift.focus,
|
||||||
aperture: (props.tiltShift.aperture) * 0.00001,
|
// aperture: (props.tiltShift.aperture) * 0.00001,
|
||||||
maxblur: (props.tiltShift.maxblur) * 0.01
|
// maxblur: (props.tiltShift.maxblur) * 0.01
|
||||||
});
|
// });
|
||||||
|
|
||||||
const outputPass = new OutputPass();
|
const outputPass = new OutputPass();
|
||||||
composer.addPass(renderPass);
|
composer.addPass(renderPass);
|
||||||
composer.addPass(bokehPass);
|
// composer.addPass(outputPass);
|
||||||
composer.addPass(outputPass);
|
|
||||||
scene.value.fog = new Fog(props.clearColor, props.tiltShift.focus * k.start, props.tiltShift.focus * k.end)
|
scene.value.fog = new Fog(props.clearColor, props.tiltShift.focus * k.start, props.tiltShift.focus * k.end)
|
||||||
}
|
}
|
||||||
const { onAfterRender } = useLoop()
|
const { onAfterRender } = useLoop()
|
||||||
onAfterRender(() => {
|
onAfterRender(() => {
|
||||||
composer.render()
|
// composer.render()
|
||||||
})
|
})
|
||||||
watch(props.tiltShift, () => {
|
watch(props.tiltShift, () => {
|
||||||
if (camera.value) {
|
if (camera.value) {
|
||||||
const args = {
|
// const args = {
|
||||||
focus: props.tiltShift.focus,
|
// focus: props.tiltShift.focus,
|
||||||
aperture: props.tiltShift.aperture * 0.00001,
|
// aperture: props.tiltShift.aperture * 0.00001,
|
||||||
maxblur: props.tiltShift.maxblur * 0.01
|
// maxblur: props.tiltShift.maxblur * 0.01
|
||||||
}
|
// }
|
||||||
const bokehPass = new BokehPass(scene.value, camera.value, args);
|
// const bokehPass = new BokehPass(scene.value, camera.value, args);
|
||||||
composer.passes = []
|
// composer.passes = []
|
||||||
const renderPass = new RenderPass(scene.value, camera.value);
|
// const renderPass = new RenderPass(scene.value, camera.value);
|
||||||
const outputPass = new OutputPass();
|
// const outputPass = new OutputPass();
|
||||||
composer.addPass(renderPass);
|
// composer.addPass(renderPass);
|
||||||
composer.addPass(bokehPass);
|
// composer.addPass(bokehPass);
|
||||||
composer.addPass(outputPass);
|
// composer.addPass(outputPass);
|
||||||
|
const gammaCorrectionPass = new ShaderPass(GammaCorrectionShader);
|
||||||
|
composer.addPass(gammaCorrectionPass);
|
||||||
scene.value.fog = new Fog(props.clearColor, props.tiltShift.focus * k.start, props.tiltShift.focus * k.end)
|
scene.value.fog = new Fog(props.clearColor, props.tiltShift.focus * k.start, props.tiltShift.focus * k.end)
|
||||||
}
|
}
|
||||||
}, { deep: true })
|
}, { deep: true })
|
||||||
|
|
Loading…
Reference in New Issue