Skip to content

getVisibilityMap struggling with bigger modelsΒ #667

@Sephiroth5050

Description

@Sephiroth5050

Describe the bug πŸ“

`const syncHiddenObjectsStore = async () =>
{
if (!componentsRef)
{
return;
}

const hider = componentsRef.get(OBC.Hider) as OBC.Hider | undefined;
if (!hider)
{
return;
}

const hiddenMap = await hider.getVisibilityMap(false);

const hiddenInternalIds: string[] = [];

for (const [modelId, list] of Object.entries(hiddenMap))
{
if (!list)
{
continue;
}

for (const localId of list as number[])
{
  hiddenInternalIds.push(`${modelId}:${localId}`);
}

}

const { setHiddenObjIds } = useSceneObjectsStore.getState();
setHiddenObjIds(hiddenInternalIds);
};`

I implemented a visibility-tracking function that synchronizes show/hide/isolate actions in the viewer with other UI components (e.g., greying out hidden nodes in the project tree). While the visibility operations themselves are fast, getVisibilityMap becomes a bottleneck when handling tens of thousands of objects, even though that scale should be manageable.

Reproduction ▢️

No response

Steps to reproduce πŸ”’

Call this function When lots of elements are hidden
const hiddenMap = await hider.getVisibilityMap(false);

System Info πŸ’»

-

Used Package Manager πŸ“¦

yarn

Error Trace/Logs πŸ“ƒ

No response

Validations βœ…

  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Make sure this is a repository issue and not a framework-specific issue. For example, if it's a THREE.js related bug, it should likely be reported to mrdoob/threejs instead.
  • Check that this is a concrete bug. For Q&A join our Community.
  • The provided reproduction is a minimal reproducible example of the bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions