-
Notifications
You must be signed in to change notification settings - Fork 303
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 Layer folder, extract geometric layers from views #815
Conversation
If we move away from layers being data-container + attached (external) functions to layers being classes, then we should also reconsider the existence of the process code. For instance, all the code from Other questions:
|
Completely agree, all layers should have their own
It could, and it should, but those layers are for now more present in examples. But we could take the opportunity to create them here.
I don't have an opinion here, I'm okay to leave it or remove it. It could be at least deprecated in this PR. |
I don't have any opinion on the proposed changes, so I'll keep asking questions :) Is there a point to keep
I'm not sure that theses layers would make sense actually. |
There is some code that we could move from views to layers, but I don't really see the point of dropping views. To me, views are the basis of any project using itowns. Or do you meant we could only keep
OK, so maybe a 3dtiles layer would be added as a GeometryLayer/TiledGeometryLayer, and then the provider(/source ?) would change the specific update stuff ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the specific globe's part in GlobeTileProcessing
is the horizonCulling, this part could be moved in globeLayer
. We must strive to unify the other parts of the GlobeTileProcessing (if possible and justified)
Do you meant we could only keep
View
and only use that ?
Yes, it would be necessary to have only View
, the different things are the controls / Camera
and the fog / atmosphere
(atmosphere should be a layer)
@@ -1,199 +0,0 @@ | |||
import { EventDispatcher } from 'three'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move Layer.js in other PR to see history change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep !
src/Core/Prefab/Globe/GlobeLayer.js
Outdated
this.builder = new BuilderEllipsoidTile(); | ||
} | ||
|
||
pickObjectsAt(view, mouse, radius = 5) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why he doesn't inherit from geometryLayer or TiledGeometryLayer.js?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of the default radius
value which isn't the same, and I don't know a way of specifying this differently.
src/Core/Prefab/Globe/GlobeLayer.js
Outdated
this._latestUpdateStartingLevel = 0; | ||
} | ||
|
||
preGlobeUpdate(context, this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why globeLayer.preUpdate
should be identical to planarLayer.preUpdate
or panoramaLayer.preUpdate
, exepted for preGlobeUpdate
, prePlanarUpdate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
Object.assign(this, config); | ||
|
||
Object.defineProperty(this, 'id', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could you use class's getter and setter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only using a getter
would do the same job indeed, but does not emit an error: what is your take here ?
// * the minimum sequence will always be 0 | ||
// * the maximum sequence will always be layers.lenght - 1 | ||
// the ordering of all layers (Except that specified) doesn't change | ||
moveLayerToIndex: function moveLayerToIndex(layer, newIndex, imageryLayers) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe this should be in geometryLayer
because the color and elevation layers are only attached to geometric layers : geometryLayer.moveColorLayerToIndex(layer, index)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This kind of makes sense, but this method is used in ColorLayersOrdering
too; how do you see the integration with this one, very specific to color layers ?
PR updated, I moved the Note that it is getting quite unbrowseable in the jsdoc page, so it may be interesting to regroup classes by theme (here we could have |
src/Core/Layer/Layer.js
Outdated
this.options = config.options || {}; | ||
|
||
// Does this layer is attached to another one | ||
this.isAttached = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's necessary, because if (this.attachedLayers.length === 0)
so this.isAttached === false
src/Core/Layer/Layer.js
Outdated
// Does this layer is attached to another one | ||
this.isAttached = false; | ||
|
||
if (!this.updateStrategy) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note
It's necessary to think where to place the strategy of loading.
The layer is a good place because it must independent of the source.
src/Core/Layer/Layer.js
Outdated
}); | ||
|
||
// Default properties | ||
this.options = config.options || {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be necessary, to write _
before private property name.
Could you tell me the properties that make sense to be accessible?
by example this.isAttached
is not supposed to be modifiable by the user
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this line comes from View
, so I kinda let it as it is. For private property name, I'm okay to write it with _
, but I don't know a way to keep a property modifiable by us but not by the user.
src/Core/Prefab/Globe/GlobeLayer.js
Outdated
|
||
function subdivision(context, layer, node) { | ||
if (TiledGeometryLayer.hasEnoughTexturesToSubdivide(context, node)) { | ||
return globeSubdivisionControl(2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
Could you standardize the signature of
globeSubdivisionControl
,panoramaSubdivisionControl
andplanarSubdivisionControl
, because these functions are pretty much the same -
Could you move
subdivision
andthis.update
declaration toTiledGeometryLayer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- pretty much yes, but the panorama one is kinda annoying... I'll see what I can do here
- I don't agree with this, I'd prefer to transfer the called methods (from
GlobeTiledProcessing
for example) in layers in the PR following this one.
|
||
this.update = processTiledGeometryNode(panoramaCulling, subdivision); | ||
this.builder = new PanoramaTileBuilder(type, config.ratio || 1); | ||
this.segments = 8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to this.options
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
defineLayerProperty(layer, 'visible', true, () => _syncGeometryLayerVisibility(layer, view)); | ||
defineLayerProperty(layer, 'frozen', false); | ||
if (layer.type == 'geometry' || layer.type == 'debug') { | ||
layer.defineLayerProperty('visible', true, () => _syncGeometryLayerVisibility(layer, view)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a shame that (layer.defineLayerProperty) this remains
It should use the notifyChange mechanism
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How could I use it ?
src/Layer/GeometryLayer.js
Outdated
* @return {Array} An array containing all targets picked under the | ||
* specified coordinates. | ||
*/ | ||
pickObjectsAt(view, coordinates, radius) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why radius parameter don't use default value?
pickObjectsAt(view, coordinates, radius = this.config.defaultRadius)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, didn't think of it this way !
src/Layer/TiledGeometryLayer.js
Outdated
* @return {Array} An array containing all targets picked under the | ||
* specified coordinates. | ||
*/ | ||
pickObjectsAt(view, coordinates, radius) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can declare in class geometryLayer
pickObjectsAt(view, coordinates, radius = this.defaultPickingRadius) {
return Picking.pickTilesAt(view, coordinates, radius, this);
}
and remove pickObjectsAt
in TiledGeometryLayer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But TiledGeometryLayer
uses pickTilesAt
and GeometryLayer
uses pickObjectsAt
.
@@ -42,15 +42,6 @@ export function preGlobeUpdate(context, layer) { | |||
|
|||
// pre-sse | |||
context.camera.preSSE = _preSSE(context.view); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this deleted or moved part for?
@@ -24,17 +24,6 @@ function _isTileBigOnScreen(camera, node) { | |||
return (dim.x >= 256 && dim.y >= 256); | |||
} | |||
|
|||
export function prePlanarUpdate(context, layer) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same part that here
There's the same preUpdate
in globePreUpdate
?
It's used for elevation with color data , can use color data for elevation in the globeLayer
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the same indeed, so I moved it to TiledGeometryLayer.
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. TiledGeometryLayer, ColorLayer and ElevationLayer has been created as well, in the same spirit. All code present in src/Core/Layer has been moved to src/Layer.
good job |
This is a PR similar to #794 but more advanced. It is still missing documentation and test at the moment, but we can discuss the main goal of the PR while I add it.
Description
Several things have been done here:
src/Core/Layer
tosrc/Layer
GeometryLayer
,TiledGeometryLayer
,ColorLayer
andElevationLayer
src/Core/Prefab
, remove thecreateXXXLayer
in profit of aXXXLayer
fileMotivation and Context
I feel that layers are one of the main aspect in itowns, and refactoring them like this can help us see clearer through it and help refactoring things around them (like #798 and #807).