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

A couple questions #39

Closed
ShaneTex opened this issue Aug 18, 2020 · 6 comments
Closed

A couple questions #39

ShaneTex opened this issue Aug 18, 2020 · 6 comments
Labels
❓ question Further information is requested

Comments

@ShaneTex
Copy link

ShaneTex commented Aug 18, 2020

@jscastro76 I have a couple Questions:

  1. How do I delete specific models that I have loaded, do I have to loop through all tb.world.children and look for a name, for one to remove, or is there a way to remove via name, or Id.

  2. Can I group by id, and have some objects that are meant to be animated, and not, and then remove or clean via different id's. For example, here in addlayer, do all threebox objects need to be added to this id, or is there a smarter way.
    map.addLayer({
    id: 'custom_layer',
    type: 'custom',
    renderingMode: '3d'

@jscastro76
Copy link
Owner

Hi @ShaneTex,

  1. You can delete any object through tb.remove with the 3D object as param.

  2. Of course you can create multiple layers and group in each one of them different 3D objects, that´s the standard approach for multi-floor scenarios.

@jscastro76 jscastro76 added the ❓ question Further information is requested label Aug 31, 2020
@ShaneTex
Copy link
Author

Got it so the id: can be anything, it doesn't have to be 'custom_layer'?

@jscastro76
Copy link
Owner

jscastro76 commented Aug 31, 2020

Got it so the id: can be anything, it doesn't have to be 'custom_layer'?

Of course, the id is a string value check out mapbox documentation for map.addLayer
For instance, I have an example with a building of N layers and each one of them are called 'floor_0', 'floor_1', 'floor_3'... dynamically base on what I read from a GeoJson file.

@ShaneTex
Copy link
Author

Gotcha, perfect. So you remove them the same way, so it would be tb.remove('floor_0'), etc.

@jscastro76
Copy link
Owner

Gotcha, perfect. So you remove them the same way, so it would be tb.remove('floor_0'), etc.

You are mixing things...
If you want to remove a 3D object, then you must use tb.remove
If you want to remove a layer, then you have to use map.removeLayer('floor_0'), but the layer won´t remove it´s 3D objects.

What I would recommend to you is to add an attribute with the layerId to each 3D object as part of their init options, then you´ll be able to loop through all them.

I will consider to create methods to override map.addLayer and map.removeLayer to wrap up this functionality.

@ShaneTex
Copy link
Author

ShaneTex commented Sep 2, 2020

@jscastro76 Gotcha, that makes better sense now. Thanks for the help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❓ question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants