Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TresDirectionalLightHelper Uncaught (in promise): Cannot read properties of undefined (reading 'matrixWorld') #860

Open
5 tasks done
idank opened this issue Oct 19, 2024 · 2 comments
Labels
bug Something isn't working p4-important-bug Violate documented behavior or significantly improve performance (priority)

Comments

@idank
Copy link

idank commented Oct 19, 2024

Describe the bug

Can't seem to use TresDirectionalLightHelper in the simplest way.

Reproduction

https://play.tresjs.org/#eNqdVW1P2zAQ/itW0MSmtUlaYNoyNrF2Y2MaAwHfCB9McjQGx7Zs922I/76z07QJMChro6q+l+eeO99dboMzDeaLUuFkDEES7JpMM2WJATtWhFMx+pQG1qTB51SwUkltyS0xBeVcTk/gityRKy1Lsonemw0LBzqkYkLN0mLPouzaRJnUsPmxYXukL5kdSmG15I+YMxBWGueRikwKYwlno8K64J8aTF6/ScVuVLFHrniwUCpOLeCJkN0GoykTuZx2DfsDJONAdTeTXGpMdON9/+tguOOzJfjxXsegjYLMsgkMaQmakkRJwyyTAl3OP3SIey7SgES1WzulpdihHYIp2gDdfofgEzuEREtLa0XcIYfUFuHxQaVdwNTJSAHfQZZg9ZwkVI+M8+l1SC/c6ZCtJp9G6DMpBYKCZpSTB2mvqEa1w9PckaJ7XLCMGtvF+8DStsMO5OwRno5k/fMirtv77vsfXLHGrtQPK3mqCtCrWq7NZH8wiLcGzzL5yrTrHiko/+U6l2i4Qve6i92t3yspstz23cCEBYGqOSp6Yb9d5XZf3Y/yA7gCvSp4Ha5DluX2c+EpV4OBot2oMTV4NHbO3d/ClryTikuZz8mt8ysRl4mExDiXhCia50yM6mMBLlhCenH8ygumLLfF8nyXig2qVAX0jC0hlzS7GWk5Fnk1pgnZiGMXB2Fw4D3BoBNU66RbUhVeGylwlXn4dKHADZZUAZ2suYucIg0Ka5VJoijLBfrnwNlEhwJsJFQZNc33tsN+2I9yZmzkxGidBliae8DV1noJduWB8HEYdwXMbNhbRVlo28HsFOiNomKdFJa2PkCNXAvDkjmfJnahYS1cZ7eHiO+QdvQWTNmsBr4VxgbWLnPDfK8XhzuIiKsaZmHZLvLCDsdAQ/4C4MrhKWg07OZQsjVAa1OX/Hb4LuLssgnpELFD77A1rcH31hUb3WvMTJaKcdBHyo1tu0H9W+2nl1k9hiW/rIDs5hH5tZlVlI+xWUBPsNyrq8RRBVupv53+xs5qKEuZj/nicv6hPAEj+dhxrMwGOIpIu2Hn2R74OcMtcGa+zfzaWiTVImrnCrz0vF6yy16rBBe+cN7eX8fwiSqtMtsKt5YFv/sLFQ3fhw==

Steps to reproduce

Using the Tres playground, I've added <TresDirectionalLightHelper :args="[lightRef, 5]" /> just below the TresDirectionalLight, and sets it ref property to a shallow ref. This seems to cause an error in the library:

three.module.js:52035 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'matrixWorld')
    at new Lm (three.module.js:52035:23)
    at n (tres.js:1202:14)
    at mountElement (runtime-dom.esm-browser.js:5971:21)
    at processElement (runtime-dom.esm-browser.js:5945:7)
    at patch (runtime-dom.esm-browser.js:5813:11)
    at mountChildren (runtime-dom.esm-browser.js:6057:7)
    at processFragment (runtime-dom.esm-browser.js:6239:7)
    at patch (runtime-dom.esm-browser.js:5799:9)
    at ReactiveEffect.componentUpdateFn [as fn] (runtime-dom.esm-browser.js:6440:11)
    at ReactiveEffect.run (runtime-dom.esm-browser.js:471:19)

System Info

No response

Used Package Manager

npm

Code of Conduct

@andretchen0
Copy link
Contributor

Here's a StackBlitz.

https://stackblitz.com/edit/tresjs-minimal-reproduction?file=src%2FApp.vue

<script setup lang="ts">
import { shallowRef } from 'vue';
import { DirectionalLight } from 'three';
import { TresCanvas } from '@tresjs/core';
import { OrbitControls } from '@tresjs/cientos';

const lightRef = shallowRef(new DirectionalLight());

setInterval(
  () => (lightRef.value.position.x = Math.sin(Date.now() * 0.01)),
  1000 / 60
);
</script>

<template>
  <TresCanvas window-size clear-color="#82DBC5">
    <TresPerspectiveCamera :position="[9, 9, 9]" />
    <OrbitControls />
    <TresMesh :position="[0, 0, 0]" cast-shadow>
      <TresBoxGeometry :args="[1.5, 1.5, 1.5]" />
      <TresMeshStandardMaterial />
    </TresMesh>
    <TresDirectionalLight
      ref="lightRef"
      :position="[-10, 10, 4]"
      :intensity="1.2"
      cast-shadow
    />
    <TresDirectionalLightHelper :args="[lightRef, 5]" />
  </TresCanvas>
</template>

See console. Error:

Uncaught (in promise) TypeError: "position" is read-only

@andretchen0 andretchen0 added bug Something isn't working p3-minor-bug An edge case that only affects very specific usage (priority) p4-important-bug Violate documented behavior or significantly improve performance (priority) and removed p3-minor-bug An edge case that only affects very specific usage (priority) labels Oct 19, 2024
@andretchen0
Copy link
Contributor

See also: PlaneHelper

https://stackblitz.com/edit/tresjs-minimal-reproduction-6rkjr6?file=src%2FApp.vue

<script setup lang="ts">
import { shallowRef } from 'vue';
import { TresCanvas } from '@tresjs/core';
import { OrbitControls } from '@tresjs/cientos';

const planeRef = shallowRef();
</script>

<template>
  <TresCanvas window-size clear-color="#82DBC5">
    <TresPerspectiveCamera :position="[9, 9, 9]" />
    <OrbitControls />
    <TresPlane ref="planeRef" />
    <TresPlaneHelper :args="[planeRef, 1, '#ffff00']" />
  </TresCanvas>
</template>

See console. Error:

Uncaught (in promise) TypeError: "position" is read-only

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p4-important-bug Violate documented behavior or significantly improve performance (priority)
Projects
None yet
Development

No branches or pull requests

2 participants