Comments (4)
@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.
@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>
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.
@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.
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)
- Codesandbox examples not working on iOS HOT 8
- Axis orientation HOT 2
- Boundingbox for Flex HOT 2
- Use scrollarea and mesh events HOT 6
- Width: auto on flex containers not taking the full space available HOT 4
- Box size control HOT 3
- Debug view HOT 3
- Rotation on flex root causes overlapping elements HOT 2
- Initial bounding box calculation are wrong when using nested boxes
- Vite compatibility HOT 3
- Sticky HOT 2
- Center of flex element is not aligned with parent object center. HOT 1
- Scaled box results in child elements collapsing on each other. HOT 1
- (Beginner) Faulty behaviour with changing Content and on Load
- Flex with text
- typescript errors with r3f v8 HOT 5
- Hook to get the position, similar to useFlexSize() HOT 1
- Update to a newer version of react-pdf/yoga
- Unexpected positioning of Box object
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-three-flex.