Open hthaigler opened 6 months ago
Hi I got this.
You can enable the localClippingEnabled by using the template ref (like in my example) or by using useTresContext
But I believe you got another problem related to the bound of clippingPlane
null to the material.
<script setup lang="ts">
import { reactive, ref, shallowRef, watch } from 'vue';
import { BasicShadowMap, SRGBColorSpace, NoToneMapping } from 'three';
import { TresCanvas, vLog } from '@tresjs/core';
import { OrbitControls, ContactShadows } from '@tresjs/cientos';
const gl = {
clearColor: '#82DBC5',
shadows: true,
alpha: false,
shadowMapType: BasicShadowMap,
outputColorSpace: SRGBColorSpace,
toneMapping: NoToneMapping,
};
const clippingPlane = ref(null);
const ctxRef = shallowRef();
watch(ctxRef, (ctx) => {
const { renderer } = ctx.context;
renderer.value.localClippingEnabled = true;
console.log(renderer.value.localClippingEnabled);
});
</script>
<template>
<TresCanvas v-bind="gl" ref="ctxRef">
<TresPerspectiveCamera :position="[9, 9, 9]" />
<OrbitControls />
<TresMesh>
<TresBoxGeometry :args="[1, 1, 1]" />
<TresMeshNormalMaterial /> // If I leave the null bound here throw error
</TresMesh>
<TresMesh :position="[0, 0.25, 0]" :rotation="[-Math.PI / 2, 0, 0]">
<TresPlaneGeometry ref="clippingPlane" :args="[2, 2]" />
<TresMeshBasicMaterial color="#555" :side="DoubleSide" />
</TresMesh>
<ContactShadows />
<TresDirectionalLight :position="[0, 2, 4]" :intensity="1.2" cast-shadow />
</TresCanvas>
</template>
Describe the bug
I am trying to clip materials using local clipping planes, but no matter what I do, I am not able to access the localClippingEnabled attribute on the instance of the WebGLRenderer.
I think the most simple solution would be:
... but this is not working.
I've tried using:
but I get this error:
Reproduction
https://stackblitz.com/edit/tresjs-basic-eaxcaf?file=src%2Fcomponents%2FTheExperience.vue
Steps to reproduce
No response
System Info
No response
Used Package Manager
npm
Code of Conduct