[iTowns-user] Accessing features of a GeometryLayer

Johnston, Chad Chad.Johnston at parsons.com
Tue Apr 21 07:21:28 PDT 2020


I looked at the onMeshCreated callback but I don't think I understand it very well.

In my small sample app, I have 3 features on the GeometryLayer from a FileSource. As I zoom in and out, I see onMeshCreated get called multiple times - does this mean new ThreeJS objects are being created for all zoom levels?

Also, the values that get passed in to onMeshCreated don't seem to represent individual features. Is there a one-to-one mapping between a feature defined in the FileSource and a ThreeJS object that gets created? The object passed in to onMeshCreated seems to represent something that holds all of the features.

I have a use case where I will need to change visibility for individual features in the layer. Am I going about this the wrong way by trying to access the ThreeJS objects? Is there another way to accomplish this?

Chad

From: Adrien Berthet <Adrien.Berthet at ign.fr>
Sent: Tuesday, April 21, 2020 12:46 AM
To: Johnston, Chad <Chad.Johnston at parsons.com>; itowns-user at lists.osgeo.org
Subject: [EXTERNAL] RE:Accessing features of a GeometryLayer

Hi Chad,

I assume you are using a FileSource ? In this case, you can use layer.source.parsedData to access the FeatureCollection (which is an internal itowns format).

If you meant the ThreeJS objects, you can get them by setting a onMeshCreated to your layer, like in this case for example: https://github.com/iTowns/itowns/blob/master/examples/source_stream_wfs_3d.html#L189-L192 [github.com]<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_iTowns_itowns_blob_master_examples_source-5Fstream-5Fwfs-5F3d.html-23L189-2DL192&d=DwMF-g&c=Nwf-pp4xtYRe0sCRVM8_LWH54joYF7EKmrYIdfxIq10&r=mQjF0_nPzjZcqOc5JWZp-Sz0OqXtNQ5NEp_IsAW3X-I&m=lbRrkYQRGdYF3aF_Q9iTbEjabC6FpWGbSR2gFv9NP2k&s=jrJw2LpCSd80WmcQQlDuec8u91wxQwfpL-UYrnMBDYA&e=>
It allows you to access the mesh once it has been created, and you can even use this method with a stream.

Hope it helps a bit

Adrien

________________________________
De : ITowns-user [itowns-user-bounces at lists.osgeo.org] de la part de Johnston, Chad [Chad.Johnston at parsons.com]
Envoyé : lundi 20 avril 2020 19:57
À : itowns-user at lists.osgeo.org<mailto:itowns-user at lists.osgeo.org>
Objet : [iTowns-user] Accessing features of a GeometryLayer
How can I access features that were added to a GeometryLayer from a GeoJSON source? I have to pass in a ThreeJS Group to the GeometryLayer constructor, but that object ends up having no children so I'm not sure where the actual features end up in the scene.

To be clear, I'd like to be able to access individual ThreeJS objects that represent each feature in the layer. I don't know if that's how they're created and added to the scene, but it seems logical since they can be different colors.

Thanks,
Chad

NOTICE: This email message and all attachments transmitted with it may contain privileged and confidential information, and information that is protected by, and proprietary to, Parsons Corporation, and is intended solely for the use of the addressee for the specific purpose set forth in this communication. If the reader of this message is not the intended recipient, you are hereby notified that any reading, dissemination, distribution, copying, or other use of this message or its attachments is strictly prohibited, and you should delete this message and all copies and backups thereof. The recipient may not further distribute or use any of the information contained herein without the express written authorization of the sender. If you have received this message in error, or if you have any questions regarding the use of the proprietary information contained therein, please contact the sender of this message immediately, and the sender will provide you with further instructions.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/itowns-user/attachments/20200421/ae0452b9/attachment.html>


More information about the ITowns-user mailing list