Commit Graph

718 Commits

Author SHA1 Message Date
Simon Seyock 8facb252f1 Replace google closure syntax = with brackets around name 2021-02-03 14:06:02 +01:00
Tim Schaub 19bb3f8c88 Consistent use of Array and Object types 2021-02-02 13:53:10 -07:00
Tim Schaub afd0b8f757 Throw an error if shaders fail to compile or program fails to link 2021-01-05 17:24:58 -07:00
Maximilian Krög 23dc768c2e Order callback calls by distance to click position
All callback calls for hits with a tolerance > 0 are queued and
called ordered by distance after all hits are detected.
2020-12-01 23:21:59 +01:00
Andreas Hocevar 28aaa2e0d3 Pass geometry to forEachFeatureAtPixel callback 2020-11-27 13:43:28 +01:00
Andreas Hocevar 7a5e0db59f Remove decluttering for a fresh start 2020-09-18 23:31:20 +02:00
Frederic Junod 142fbc0811 Use the className param in ol.layer.Heatmap 2020-09-11 08:23:15 +02:00
Langbein, Michael a70ce2ca06 Implement preRender and postRender methods for WebGLLayerRenderer
This is required so that Renderers like WebGLPointsLayerRenderer can fire prerender and postrender events.
Problem described in [issue 11463](https://github.com/openlayers/openlayers/issues/11463).
2020-08-30 13:20:18 +02:00
Andreas Hocevar fda93cee23 Updates for TypeScript v4 2020-08-25 13:03:58 +02:00
Tim Schaub 054af09032 Make code prettier
This updates ESLint and our shared eslint-config-openlayers to use Prettier.  Most formatting changes were automatically applied with this:

    npm run lint -- --fix

A few manual changes were required:

 * In `examples/offscreen-canvas.js`, the `//eslint-disable-line` comment needed to be moved to the appropriate line to disable the error about the `'worker-loader!./offscreen-canvas.worker.js'` import.
 * In `examples/webpack/exapmle-builder.js`, spaces could not be added after a couple `function`s for some reason.  While editing this, I reworked `ExampleBuilder` to be a class.
 * In `src/ol/format/WMSGetFeatureInfo.js`, the `// @ts-ignore` comment needed to be moved down one line so it applied to the `parsersNS` argument.
2020-04-06 12:54:09 -06:00
Frederic Junod dda7342ea7 Remove all inheritDoc tags from src/ol/renderer 2020-04-03 09:08:09 +02:00
Frederic Junod d15ec1c12c Remove all inheritDoc tags from disposeInternal functions 2020-04-03 08:10:41 +02:00
John Leonard e6a2d4b235 fix: handle layer clear event in case clear(true) called
and individual delete feature events aren't generated
2020-03-09 18:36:12 +00:00
Olivier Guyot ae66471e78 Webgl renderer / hide shader compile errors
Turns out there are sometimes errors that will not prevent the
shader from functioning normally. As such, it is not possible
to simply throw when there are errors/warnings.

Since we are not logging to the console, these errors will have to stay hidden
unless the user requests them explicitly.
2019-11-06 21:40:39 +01:00
Olivier Guyot 7da86ae71f Webgl points renderer / slight improvements following review
Also fixes a lint error.
2019-11-04 09:55:54 +01:00
Olivier Guyot 600e1a4647 Webgl points renderer / use a smaller canvas for hit detection render
The hit detection render is now done against a canvas with half the
width/height of the main render. This still provides sufficient precision
while requiring a much smaller memory allocation (especially for
retina devices).
2019-11-04 09:31:38 +01:00
jahow f7b0f6750b Resolve memory leak when deleting a webgl layer
Various references were kept, preventing the layer and underlying
renderer and webgl context to be garbage collected.

Also, the Helper was simplified because it turns out deleting manually
all Webgl objects is useless: these objects will be released when
the context is garbage collected anyway.

Note: this touches the Layer and BaseLayer classes, as the following were
preventing the layer from being garbage collected:
* layer reference in the `state_` object in BaseLayer
* dangling listener for source change in Layer
2019-11-04 09:31:38 +01:00
Olivier Guyot e78c14c061 Webgl points renderer / add a cache for features in the source
This allows quicker access to features as well as their geometries
and properties, reducing the time taken by a rebuildBuffers call.
2019-11-04 09:31:38 +01:00
Andreas Hocevar ac50cc3460 New eslint config with no-multi-assign 2019-11-02 15:20:21 +01:00
Olivier Guyot f84fae8f70 Merge pull request #10198 from jahow/fix-webgl-renderer-loading-extent
WebGL renderer / use the specified loading strategy for the vector data
2019-10-28 16:19:52 +01:00
Olivier Guyot cd3b222467 Specify an actual extent when loading features in the Webgl points renderer
This means any specified loading strategy will be taken into account.

Also added some tests to make sure the interaction with the source is
correct.
2019-10-28 10:26:31 +01:00
Olivier Guyot d643951a74 Shader Builder / add option to generate hit detection shaders 2019-10-25 14:55:44 +02:00
Olivier Guyot a1c00744d1 Webgl points renderer / throw if shader compilation fails
This should only happen if providing handcrafted shaders to the renderer.
2019-10-22 23:17:00 +02:00
Simon Seyock 5b1106ac23 some type corrections 2019-10-10 09:07:35 +02:00
Frederic Junod ea88e6cbd4 Remove invalid undefined type in params 2019-09-27 11:01:50 +02:00
Olivier Guyot 7e4383f554 Webgl renderer / now accepts any kind of layer (not just vector) 2019-09-26 15:33:54 +02:00
Olivier Guyot 607f2f0746 Merge pull request #9994 from jahow/add-webgl-layer-type
Add a new layer type: WebGLPointsLayer
2019-09-26 14:55:09 +02:00
Olivier Guyot 9e9aa66f5f Webgl points renderer / restore check for hit detection readiness 2019-09-25 17:22:36 +02:00
Olivier Guyot b8564d503a Webgl icon example / restore texture for icons 2019-09-25 17:22:36 +02:00
Olivier Guyot 9e55a8b2f0 Webgl / linting & test fixes 2019-09-25 17:22:36 +02:00
Olivier Guyot 610a846149 Webgl points renderer / make the hit detection optional 2019-09-25 17:22:36 +02:00
Simon Seyock 6b5c2f47bb reduced typecasts in layerrenderer 2019-09-25 15:24:37 +02:00
Olivier Guyot 23c2999cab Webgl points renderer / fix hit detection
Due to the fact that the points renderer does not know for sure
which attributes will be used for rendering, it is now mandatory
to provide both vertex/fragment shaders for rendering AND hit
detection.

The hit detection shaders should expect having an `a_hitColor`
that they should return to allow matching the feature uid.

This will be all one eventually by shader builders under the hood.
2019-09-25 12:11:09 +02:00
Olivier Guyot 2b36445ecc Webgl / Adapt the points renderer to use custom attributes
Now most attributes will be custom ones defined by the user of the renderer.
The hit detection is broken for now and still has to be fixed.
Also it is not possible anymore to give a texture to the renderer,
this will have to be fixed as well.
2019-09-25 10:11:27 +02:00
Olivier Guyot 30f19f8317 Webgl points renderer / terminates worker & dispose helper 2019-09-24 17:59:21 +02:00
Olivier Guyot 4d7562fca2 Add a new WebGLPointsLayer type using the shader builder utilities
This required adding a `a_index` attribute in the points layer renderer
to be able to make the precomputed shaders to work.
2019-09-24 17:24:56 +02:00
Olivier Guyot 732b383b53 Webgl points / re-render when buffers have been built offthread 2019-08-31 08:41:04 +02:00
Olivier Guyot 5c1191dd5c Webgl points / skip hit detection render when out of sync
This happens when the indices buffer has been generated by the
worker but not the hit detection vertices buffer.
2019-08-30 10:38:41 +02:00
Olivier Guyot c48350b666 Webgl buffer / add utility getSize function
Saves checking whether the buffer was initialized with
an array already
2019-08-30 10:38:02 +02:00
Olivier Guyot e57e660819 Webgl points / use default vertex shader for hit detection
Otherwise we were getting errors if the custom
vertex shader was missing varyings expected by
HIT_FRAGMENT_SHADER.
2019-08-30 10:16:55 +02:00
Frédéric Junod 5cff84522a Merge pull request #9745 from fredj/misc_webgl
Simplify heatmap's shaders
2019-07-05 08:27:08 +02:00
Frederic Junod 89295b0359 Remove hit detection transforms from ol/renderer/webgl/PointsLayer 2019-07-03 10:38:13 +02:00
Frederic Junod bb35a03704 Don't rotate the points of the heatmap layer 2019-07-01 11:29:27 +02:00
Frederic Junod 24e4f41452 Use size property from the frameState instead of creating new array 2019-07-01 09:44:37 +02:00
Frederic Junod 933a6297bb Remove unused hasFeatureAtCoordinate from ol/renderer/Layer 2019-06-28 11:10:33 +02:00
jahow 3bca9b5297 Webgl / use feature index for hit detection in points layer
For each feature its opacity value index is encoded on 4 bytes
in the color values, and the uid is stored in the opacity
value, allowing for a much higher range of uids to be read.
2019-06-28 09:12:20 +02:00
Olivier Guyot 28b99767f8 Webgl points / read only one pixel for feature hit detection
Also implements `hasFeatureAtCoordinate`.

`hitTolerance` is not supported for now.
2019-06-28 09:12:20 +02:00
Olivier Guyot 5ffca0633c Webgl Points / Add support for feature hit detection
For now only `forEachFeatureAtCoordinate` is implemented.

Each time the viewport is rendered, another similar render pass is
done using the specific hit detection instructions. Feature uid's are
encoded in the r,g,b,a channels and can then be decoded on the fly.

Note: the `readPixels` operation is taking a lot of time,
around 10-20ms each frame.
2019-06-28 09:12:20 +02:00
Olivier Guyot 1257ade199 Webgl renderer / rename function to avoid confusion
`getBlankTexture` was too close to `WebGLHelper#createTexture`
2019-06-28 09:12:20 +02:00
Olivier Guyot 2b5e5459ab Webgl points / add hit detection buffers generation
Hit detection is done by rendering features with their id encoded in the
color attribute. A parallel set of render instructions and a second
vertex buffer is used specifically for that.
2019-06-28 09:06:16 +02:00