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

refactor: move geometric layers off views #794

Closed
wants to merge 4 commits into from

Conversation

zarov
Copy link
Contributor

@zarov zarov commented Jun 27, 2018

Move all contents of createXXXLayer in XXXView to XXXLayer in Prefab/XXX/. This declutters the XXXView files. This change applies for Globe, Planar and Panorama.

In the same time, GeometryLayer has been extract from Layer and given some new methods which were repeated through each View.

The idea here is to simplifies some files, and later move the related processing of each layer (GlobeTileProcessing, etc) inside either the Layer itself, or in the same folder, to group each "type" of view and its workings (this, but also Controls too) in the same spot. Note that this is a proposition.

Move all contents of `createXXXLayer` in XXXView to XXXLayer in
Prefab/XXX/. This declutters the XXXView files. This change applies for
Globe, Planar and Panorama.

In the same time, GeometryLayer has been extract from Layer and given
some new methods which were repeated through each View.
Copy link
Collaborator

@mbredif mbredif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I support the approach and left some comments to go further.


this._attachedLayers = [];
this.type = 'geometry';
this.protocol = 'tile';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is GeometryLayer restricted to be used with the TileProtocol?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it shouldn't have a tile protocol in geometryLayer. you would need another tiledGeometryLayer or tiledMeshLayer inherited of geometryLayer.

Ideally it would be necessary to remove the layer protocol, and to replace it a source (where source is object which makes it possible to obtain the data)

return this._attachedLayers.length < count;
};

GeometryLayer.prototype.onTileCreated = function onTileCreated(layer, parent, node) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not use this. which layer is it ? I suggest you either use this instead or make it a static function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I also removed parent as it is not used.

}
};

GeometryLayer.prototype.preUpdate = function preUpdate(context, layer, changeSources) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • same thing here (no use of this)

  • it relies on layer.level0Nodes which is only relevant for tiled GeometryLayer. Maybe there is room to create a TiledGeometryLayer subclass.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • removed
  • yeah @gchoqueux said that as well, what do you suggest ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, i agree

you would need a meshLayerProcessing class consisting of static functions that would then be attached to the layer.

actually, this preUpdate should be specific to the quadtree / tiledMesh and should be in tiledMeshLayerProcessing

@zarov
Copy link
Contributor Author

zarov commented Jun 28, 2018

So I pushed some changes, but I'm not satisfied with moving from layer to this in PointCloudProcessing and 3dtilesProcessing. Maybe we could move to PointCloudLayer and 3dtilesLayer in the same time ?


this._attachedLayers = [];
this.type = 'geometry';
this.protocol = 'tile';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it shouldn't have a tile protocol in geometryLayer. you would need another tiledGeometryLayer or tiledMeshLayer inherited of geometryLayer.

Ideally it would be necessary to remove the layer protocol, and to replace it a source (where source is object which makes it possible to obtain the data)

import { EventDispatcher } from 'three';
import Picking from '../Picking';

function GeometryLayer(id, object3d) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could use class?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logically, it should be called meshLayer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could use class?

Wouldn't that be losing coherence with the actual code or do you wish to push the use of class elsewhere ?

logically, it should be called meshLayer

But then the type would be mesh, and I find it too specific.

this._attachedLayers = [];
this.type = 'geometry';
this.protocol = 'tile';
this.visible = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would visibility and opacity not be rendering/style options?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes for opacity, no for visibility imho.

return this._attachedLayers.length < count;
};

GeometryLayer.prototype.onTileCreated = function onTileCreated(layer, parent, node) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename on onMeshCreated

}
};

GeometryLayer.prototype.preUpdate = function preUpdate(context, layer, changeSources) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, i agree

you would need a meshLayerProcessing class consisting of static functions that would then be attached to the layer.

actually, this preUpdate should be specific to the quadtree / tiledMesh and should be in tiledMeshLayerProcessing

}
};

export default GeometryLayer;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

finally it might look like this

class meshLayer {
   source: {
       // how get data
   },
   processing: { 
       // processing attached to layer
   },
   style: {
        // how render this layer
   },
}

@zarov
Copy link
Contributor Author

zarov commented Jun 29, 2018

@mbredif @gchoqueux I understand the concern on introducing a TiledGeometryLayer here, but I feel this is out of scope of this PR which is only a reorganization of code. I'm open to work on it right after this one, and maybe take the opportunity to clear some definition on layers. WDYT ?

@peppsac
Copy link
Contributor

peppsac commented Jul 2, 2018

I understand the concern on introducing a TiledGeometryLayer here, but I feel this is out of scope of this PR which is only a reorganization of code.

As GeometryLayer is currently used by 3dtiles and pointcloud, you can't ignore them.
If you want a simple "reorganize" code PR, then I'd suggest to not modify GeometryLayer at all, and instead create a TiledGeometryLayer (that would be more or less the GeometryLayer from your PR).

WDYT?

@zarov
Copy link
Contributor Author

zarov commented Jul 19, 2018

Closing this PR, I will do another one soon from another branch (see this more complete commit zarov@3af73b0)

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

Successfully merging this pull request may close these issues.

4 participants