Commit Graph
100 Commits
Author SHA1 Message Date
Olivier Guyot 6f000e3155 Add missing documentation in ol/style/expressions 2019-12-20 17:13:15 +01:00
Olivier Guyot 4a8a7619d5 Merge pull request #10409 from jahow/fix-heatmap-pixelratio
Improve viewport computation in WebGL Postprocessing
2019-12-13 12:13:17 +01:00
Olivier Guyot cae32edb02 WebGL Postprocess / fix viewport computation with pixelratio != 1 2019-12-13 10:34:31 +01:00
Olivier Guyot ca0ce4986d Merge pull request #10119 from mike-000/patch-8
Add crossOrigin option to ol/format/KML for icons
2019-12-13 09:26:56 +01:00
Olivier Guyot 6537fecc69 Merge pull request #10181 from roemhildtg/master
add tags to example docs
2019-12-13 09:25:50 +01: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 af15cfb815 Icon webgl example / avoid doing hit detection when view is moving 2019-11-04 09:31:38 +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
Olivier Guyot 43010c8934 Webgl / return 0 if doing renderTarget.read outside of data width/height
This would happen when WebGLPointsLayerRenderer.forEachFeatureAtCoordinate
is called on "warped" worlds at -360/+360 degrees, and may produce false
positives.
2019-11-04 09:31:38 +01:00
Olivier Guyot e5e03d46a0 Webgl points renderer / more optimizations
Simplify calls in the attributes callback, also less stress
on garbage collection.
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
Olivier Guyot 6c0dd6152d Modified the icon-sprite-webgl example to allow filtering on a string attribute 2019-10-28 15:55:15 +01:00
Olivier Guyot b96e70e952 Expressions / renamed mod to % to be more in line with MB style spec 2019-10-28 15:55:15 +01:00
Olivier Guyot 501c90b0a2 Expressions / introduced the case operator
This operator is used for if/else control flow
2019-10-28 15:52:31 +01:00
Olivier Guyot 2a2783c086 ShaderBuilder / better handling of strings variables/attributes
Now values which are not mentioned in the style are still added to
the string literals mapping.

Also an error will be thrown if a style references a missing variable.
2019-10-28 15:21:44 +01:00
Olivier Guyot 2f49876180 Expressions / add != operator & slightly better doc 2019-10-28 15:13:43 +01:00
Olivier Guyot 80b4473180 Simplify the heatmap example
Use a weight function instead of manually edditing the features.
2019-10-28 10:27:29 +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 e63bb45e6f Webgl points layer / allow disabling hit detection
Having hit detection enabled has an overhead as it means
continously generating additional render instructions and rendering
to an offscreen canvas
2019-10-25 15:11:37 +02:00
Olivier Guyot 4462608991 Expressions / adds color and array conversion operators
Also fixes existing error throwingtests which were essentially doing nothing.
2019-10-25 14:55:44 +02:00
Olivier Guyot ff3cc9b4d0 Expressions / renamed operator pow to ^
To be more in line with Mapbox style spec
2019-10-25 14:55:44 +02:00
Olivier Guyot a844691d7b Added new example styles in the webgl points layer example 2019-10-25 14:55:44 +02:00
Olivier Guyot acf973751b Webgl / added time and resolution as default uniforms
Also added the `zoom` and `resolution` style operators
2019-10-25 14:55:44 +02:00
Olivier Guyot e843b2cfc0 Expressions / adaptation and cleanup after stretch operator removal
The examples have been fixed as well.
2019-10-25 14:55:44 +02:00
Olivier Guyot 719495587c Expressions / rework the interpolate operator
This operator is now able to map numbers to output ranges as well as colors,
making the stretch operator unnecessary. Also allows giving multiple stops,
like in Mapbox style spec.
2019-10-25 14:55:44 +02:00
Olivier Guyot 9e010631c1 Expressions / refactor operators to avoid linting errors
Previously the utilities used the Operators dict before its definition.
2019-10-25 14:55:44 +02:00
Olivier Guyot a64f2eb720 Update the icon-sprite-webgl example to use a WebGLPoints layer 2019-10-25 14:55:44 +02:00
Olivier Guyot d643951a74 Shader Builder / add option to generate hit detection shaders 2019-10-25 14:55:44 +02:00
Olivier Guyot a39f751981 Shader Builder / adapt logic & test to the new expression types
Also fixes a sneaky bug where the two last texture coordinates were inverted.
2019-10-25 14:55:44 +02:00
Olivier Guyot fc98704bcb Expressions / adds a test for a complex combination of operators 2019-10-25 14:55:44 +02:00
Olivier Guyot 27c530ec64 Expressions / introduce the match operator
This operator allows mapping from input values to output values of different
kinds and handles variable arguments count.
2019-10-25 14:55:44 +02:00
Olivier Guyot e3f7d29bb2 Expressions / add utilities for using strings in GLSL & more type checking
It is now possible to specify a type hint when parsing an expression, which
helps determine the output value type.

When no single output type can be inferred, an error is thrown.

For strings, every literal value will be replaced by a number and a map of
these associations will be kept in the parsing context, which is passed
recursively.
2019-10-25 14:55:44 +02:00
Olivier Guyot 44347a9ed3 Adapt the icon-sprite-webgl example to the new expressions module 2019-10-25 14:55:44 +02:00
Olivier Guyot 31dae929f5 ShaderBuilder / adapt logic & tests to new expressions module 2019-10-25 14:55:44 +02:00
Olivier Guyot 5712792772 Expressions / add more tests for conversion to GLSL 2019-10-25 14:55:44 +02:00
Olivier Guyot bcf7649b9a Expressions / store the variables & attributes in the context 2019-10-25 14:55:44 +02:00
Olivier Guyot 7e4119d580 Expressions / restored the parsing logic with better type checking
Converting expressions to GLSL is now done in ol/style/expressions, with the
same logic as before in ol/webgl/ShaderBuilder.
2019-10-25 14:55:44 +02:00
Olivier Guyot 72903d6454 Expressions / added operator declarations & type checking logic 2019-10-25 14:55:44 +02:00
Olivier Guyot 35af80b433 Style / add an ol/style/expressions module
This module will contain the utilities and operator declarations
for literal style expressions, boh for type checking and parsing
2019-10-25 14:55:44 +02:00
Olivier Guyot fc555241ea ShaderBuilder / simplify check/parse code a bit 2019-10-23 09:22:12 +02:00
Olivier Guyot 1fe5a68e16 Fix the triangles style in the wbegl-points-layer example 2019-10-22 23:27:26 +02:00
Olivier Guyot 948003ff27 Rewrite to filter-points-webgl example to use a Webgl points layer
The demonstrated features have been recreated using a literal
style (filtering, pulse animation).
2019-10-22 23:17:00 +02:00
Olivier Guyot d837166a1b Literal Style / add new math operators 2019-10-22 23:17:00 +02:00
Olivier Guyot c659c05de8 ShaderBuilder / fix stretch operator GLSL expression 2019-10-22 23:17:00 +02:00
Olivier Guyot 485ade42b5 Literal Style / add support for color interpolation 2019-10-22 23:17:00 +02:00
Olivier Guyot 85c3aae454 ShaderBuilder / add support for color interpolation in parse 2019-10-22 23:17:00 +02:00
Olivier Guyot a29fc016f5 ShaderBuilder / formatColor/Array utilities now output vecX(...) 2019-10-22 23:17:00 +02:00
Olivier Guyot 19eadaea24 Shader Builder / add type checking in expressions parsing
All expressions will now be type checked before actually being parsed.
2019-10-22 23:17:00 +02:00
Olivier Guyot b8e8d30df0 Shader Builder / add utilities for checking an expression type
Type checking is done either against a literal value (number, string...)
or against the operator in case of an expression.

Sometimes it is not possible to infer only one type, for example
the value 'transparent' could either be a color or a string. This
is covered by the fact that all operators expect exactly one type
for their arguments.
2019-10-22 23:17:00 +02:00
Olivier Guyot f43637cc33 Shader Builder / support strings in formatColor 2019-10-22 23:17:00 +02:00
Olivier Guyot 56faf4c3ad Color / add an isStringColor utility function 2019-10-22 23:17:30 +02:00
Olivier Guyot a0b271a812 Literal Style / add support for variables in the style
These variables are accessed using the `var` operator, and are meant
to be mutated directly in the style object. When doing so,
the new value will always be used for the render.

This is intended to be used for modifying the style through external
parameters such as an input field, a slider, mouse position etc.
2019-10-22 23:17:00 +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
Olivier Guyot 94b8cf6af3 Webgl / add support for a time operator in literal styles
This required adding `u_time` as one of the default uniforms provided by the
webgl helper.
2019-10-22 23:17:23 +02:00
Olivier Guyot 0c0c8c5d56 Literal Style / add support for a filter property 2019-10-22 23:17:00 +02:00
Olivier Guyot e38250ee14 ShaderBuilder / add fragment discard expression in shader params 2019-10-22 11:39:30 +02:00
Olivier Guyot 7b66b294a8 ShaderBuilder / attempt to clarify the way attributes are handled in parseSymbolStyle 2019-10-22 11:18:39 +02:00
Olivier Guyot 9ee93cd2cf ShaderBuilder / refactoring to use an actual builder pattern
There is now a ShaderBuilder class with chainable methods
to specify more easily the contents of the final shaders.
This is to avoid passing around large objects to different functions,
and allow for a richer API.

The documentation has also been corrected and clarified.
2019-10-22 11:12:06 +02:00
Olivier Guyot 87414256e2 Heatmap / use worker events instead of timeout for test 2019-10-11 14:06:27 +02:00
Olivier Guyot b44a6ab26a Heatmap / add hit detection shaders 2019-10-08 13:27:31 +02:00
Olivier Guyot 13147e0b82 Add experimental tags to a few examples & added doc in the README
Plus some typos.
2019-09-26 20:19:23 +02:00
Olivier Guyot 09134a6091 Shader builder / typecheck fix for parse fn 2019-09-26 16:30:19 +02:00
Olivier Guyot 858f0fc0cc Update the webgl-points-layer example to reflect new possibilities 2019-09-26 16:30:19 +02:00
Olivier Guyot 28d157af56 Shader builder / add circle and triangle shapes for symbols 2019-09-26 16:30:19 +02:00
Olivier Guyot 9b3a9b5eca Shader builder / add logic for transforming a style into shader params
This was previously handled by the WebGLPointsLayer class, but is now
externalized and tested.
2019-09-26 16:20:35 +02:00
Olivier Guyot d5caabbbfc Shader builder / add basic expression parsing
Only a handful of expressions for now, very loosely based on the
mapbox style spec. Also only work on numerical values.
2019-09-26 16:20:35 +02:00
Olivier Guyot 02e5e1776c Hit detection / fix test for wrapped geometries hit detection
Also restores the whole unit test suite.
2019-09-26 15:59:14 +02:00
Olivier Guyot b89c1255f7 Canvas vector / Avoid modifying the coordinates array in place 2019-09-26 15:34:31 +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 7da3b60061 Webgl Layer / rename literalStyle property to style 2019-09-26 14:44:32 +02:00
Olivier Guyot 0732f17fd3 Webgl layer / remove @api tag & better doc
Also the webgl layer now only inherits from the Layer class,
not the VectorLayer one.
2019-09-26 14:42:04 +02:00
Olivier Guyot 9e9aa66f5f Webgl points renderer / restore check for hit detection readiness 2019-09-25 17:22:36 +02:00
Olivier Guyot 34572da17b Webgl shader builder / expanded functionality
Now takes in a custom object with attributes, uniforms etc.
The WebGLPointsLayer uses this to handle image icons.
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
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 109f9718f9 Webgl renderer / fix existing examples
The shaders were rewritten manually for those, althoughj eventually they
should use the shader builder utilities as well.
2019-09-25 11:09:07 +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 076b674d6f Webgl helper / easier utility for binding attributes
also a bit of improvement on the doc
2019-09-24 19:10:07 +02:00
Olivier Guyot 30f19f8317 Webgl points renderer / terminates worker & dispose helper 2019-09-24 17:59:21 +02:00
Olivier Guyot cb2c596a6d Add an example for the WebGLPointsLayer with editable style 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 a6b8d920b7 Webgl / add a fixed fragment shader builder for symbols 2019-09-24 15:49:07 +02:00
Olivier Guyot 4de0c0b082 Webgl / add a very simple vertex shader builder utility
This only allows including hardcoded values in the shader,
and only for symbols.
2019-09-24 15:43:26 +02:00
Olivier Guyot 167fa6b8a0 Add property to all layers api doc 2019-09-24 10:58:55 +02:00
Olivier Guyot 449686527b Document how to avoid canvas reuse for layers
This restores the `map.forEachLayerAtPixel` functionality.

This is intended to help with openlayers#9720
2019-09-24 09:46:32 +02:00
Olivier Guyot cae8c333f2 Enable https on tile layer in webgl sprite example 2019-09-23 17:51:32 +02:00
Olivier Guyot 5b5a3657f0 Fix typings in workers
The worker self object is simply cast to any to make sure typescript
does not complain.
Actual typecheck may be restored once the following issue is fixed:
https://github.com/microsoft/TypeScript/issues/20595
2019-09-23 15:37:48 +02:00
Olivier Guyot 05a0600fe5 Webgl icon example / render map when texture ready 2019-08-31 08:59:34 +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 29d07ada54 Webgl helper / skip binding texture if underlying image is not ready 2019-08-30 11:02:31 +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
Olivier Guyot 2f3e8d04f1 Webgl points / fix hit detection for retina devices 2019-07-11 00:05:55 +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 e852294938 Webgl / improve reading of render targets data
Now two methods are available: `readAll` and `readPixel`,
and the data from the render target is not re-read every time unless
`clearCachedData` is called.
2019-06-28 09:12:20 +02:00
Olivier Guyot 917950a32b Improve icon-sprite-webgl example to include hit detection 2019-06-28 09:12:20 +02:00