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

SelectionBox: Add support for InstancedMesh. #22399

Merged
merged 3 commits into from
Aug 24, 2021

Conversation

webzep
Copy link
Contributor

@webzep webzep commented Aug 24, 2021

Related issue: https://discourse.threejs.org/t/how-to-select-objects-with-a-selection-rectangle/4772/14

Description

SelectionBox.js does not give information about which instances in an InstanceMesh are in the frustum. This change adds a property called instanceDetection to the SelectionBox class.

When the searchChildInFrustum method is called, the instanceDetection property will update with information about which instances of an InstanceMesh are in the frustum.

An example of this.instanceDetection when the selection includes the instance at index 12 is below. The InstanceMesh uuid gets added to the object with a value of an array which includes all instanceIds that are in the frustum.

{
    "460A8174-2AD7-4F0B-96B1-3DD4CA57AE3A": [12]
}

ezgif com-gif-maker

@Mugen87 Mugen87 changed the title Instance mesh support for selection box SelectionBox: Add support for InstancedMesh. Aug 24, 2021
@mrdoob mrdoob added this to the r132 milestone Aug 24, 2021
@mrdoob mrdoob merged commit 6b9eab9 into mrdoob:dev Aug 24, 2021
@mrdoob
Copy link
Owner

mrdoob commented Aug 24, 2021

Thanks!

@mrdoob
Copy link
Owner

mrdoob commented Aug 24, 2021

Did some clean up... b88cb7f

@Steviebaa Isn't it possible to add the results to the collection array somehow?

@webzep
Copy link
Contributor Author

webzep commented Aug 24, 2021

@mrdoob Ideally, I think the results would look like the raycaster results where the array items have an object key with the mesh and an instanceId if it is InstanceMesh. Changing to that will no doubt break existing code though.

Sorry about the indentation... first PR 😆. Maybe a prettier config file could be good for the project?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants