Git Product home page Git Product logo

Comments (4)

saitonakamura avatar saitonakamura commented on May 12, 2024

@oveddan can you elaborate on what is actually invisible? Are you placing invisible on a Box itself or on the items inside it?

from react-three-flex.

oveddan avatar oveddan commented on May 12, 2024

@saitonakamura A mesh inside the box.

Here is a sample piece of code where this happens:

      <Flex flexDirection="row" alignItems="baseline">
        <Box>
          <mesh>
            <meshBasicMaterial color="blue" />
            <boxBufferGeometry />
          </mesh>
          <mesh scale-y={1.5} visible={false}>
            <meshBasicMaterial color="green" />
            <boxBufferGeometry />
          </mesh>
        </Box>

        <Box>
          <mesh>
            <meshBasicMaterial color="red" />
            <boxBufferGeometry />
          </mesh>
        </Box>
      </Flex>

This results in this:
Screen Shot 2021-10-22 at 9 11 56 AM

You can see the full example in this codesandbox

Why would I want an invisible element inside the box? Because I have some reusable components that render those invisible elements, mostly for raycasting. I would like them to not affect the alignment of items.

from react-three-flex.

saitonakamura avatar saitonakamura commented on May 12, 2024

@oveddan , thanks for the clarification

I may be wrong but it seems it's pretty hard thing to do, ignore the invisibles I mean, because the invisibility of an item doesn't affect bounding box calculation in threejs (which is used under the hood of r3flex). visibility is more like opacity: 0.

BUT I do however have a workaround. See, if a Box have a Box children, it's them who's gonna affect the size and not top level meshes and groups. So you can do

<Flex flexDirection="row" alignItems="baseline">
  <Box>
    <Box>
      <mesh>
        <meshBasicMaterial color="blue" />
        <boxBufferGeometry />
      </mesh>
    </Box>
    <mesh scale-y={1.5} visible={false}>
      <meshBasicMaterial color="green" />
      <boxBufferGeometry />
    </mesh>
  </Box>

  <Box>
    <mesh>
      <meshBasicMaterial color="red" />
      <boxBufferGeometry />
    </mesh>
  </Box>
</Flex>

from react-three-flex.

oveddan avatar oveddan commented on May 12, 2024

Totally get why that is hard after looking at the code.

Your technique is a great suggestion, and it works for my solution. Thank you for that!

from react-three-flex.

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.