Git Product home page Git Product logo

Comments (1)

JaimeTorrealba avatar JaimeTorrealba commented on August 12, 2024

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>

from tres.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.