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

Force all backfaces visible in XKT models created with xeokit-convert #804

Open
elyrank opened this issue Feb 1, 2022 · 6 comments
Open
Labels
feature-suggestion Suggestion for how to extend xeokit good first issue Good for newcomers help wanted Community contribution welcome

Comments

@elyrank
Copy link
Contributor

elyrank commented Feb 1, 2022

when I create a mesh with a geometry - as long as it is not sliced it looks ok,
but when it is sliced - you can see that it is hollow, and if you look at it exactly from the top - you can't even see it.

I used buildCylinderGeometry. I tried playing with the properties - but nothing helped.
also tried with phongMaterial , and emphasis material using xray , but all are hollow.

when not sliced:
Screen Shot 2022-02-01 at 19 04 55

when sliced:
Screen Shot 2022-02-01 at 19 04 47
Screen Shot 2022-02-01 at 19 04 03

when exactly top:
Screen Shot 2022-02-01 at 19 03 07

@Amoki
Copy link
Contributor

Amoki commented Feb 2, 2022

"It's not a bug, it's a feature"
By default, surfaces are only visible from 1 side (for performance reasons). In your case, from the outside of the object.
Slicing it allows you to see it from the inside, but the surface is not shown.

@elyrank
Copy link
Contributor Author

elyrank commented Feb 3, 2022

is there any way to change it so it will be shown?

@Amoki
Copy link
Contributor

Amoki commented Feb 3, 2022

There is some low-level stuff but I never used it.
@xeolabs?

@xeolabs
Copy link
Member

xeolabs commented Aug 23, 2022

Only when building scenes using the Geometry, Node, Mesh components will you lose control over the visibility of backfaces.

That's by design, because we rarely want to slice open things built with those components, to see their backfaces (eg. NavCubePlugin).

However, you can control backface visibility within models loaded into the SceneModel scene representation (so far implemented by VBOSceneModel).

That's used to represent models loaded by the various loader plugins, from XKT, glTF, CityJSON, IFC etc.

The VBOSceneModel's createGeometry and createMesh methods support the "solid" and "surface" primitive types; these are just aliases for "triangles", where "solid" indicates a triangle mesh that we know is closed, and "surface" indicates a triangle mesh that we know is open.

The Viewer will render "surface" geometries with backfaces visible, and "solid" and "triangles" geometries with backfaces hidden.

Maybe you could switch to using VBOSceneModel? As long as you don't need animated transform hierarchies (ie. as supported Node and Mesh components), it should have all the methods you need otherwise..

@elyrank
Copy link
Contributor Author

elyrank commented Aug 23, 2022

I'm loading all using XKT files instead of generating the geometry.
is there a way to set the backfaces to be visible?

@xeolabs
Copy link
Member

xeolabs commented Aug 23, 2022

Currently, xeokit-convert (XKTModel, convert2xkt etc) automatically checks if geometries are closed or open and generates "solid" vs "surface" primitives in the XKT accordingly. That allows the xeokit Viewer to decide whether to draw their backfaces or not when rendering them.

We can't override that currently - it does not currently expose an option to force all triangle mesh primitives to be "surface".

We'd be open to adding that as an option within xeokit-convert, however, so a PR on this would be welcome if anybody want's to contribute.

For this feature, we'd want a PR on xeokit-convert, with the new override option, and a PR on xeokit-sdk, containing a live example that loads an XKT that was generated by convert2xkt using the new option.

@xeolabs xeolabs changed the title geometry is hollow when sliced Force all backfaces visible in XKT models created with xeokit-convert Aug 23, 2022
@xeolabs xeolabs added help wanted Community contribution welcome good first issue Good for newcomers feature-suggestion Suggestion for how to extend xeokit labels Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-suggestion Suggestion for how to extend xeokit good first issue Good for newcomers help wanted Community contribution welcome
Projects
None yet
Development

No branches or pull requests

3 participants