Some callbacks used a variable called `instance` to stash `this` for use
inside the callback. Now that those callbacks have been converted from
`function` to `=>`, they can just use `this` instead.
- Move build outputs into `dist/`
- Make build output file names more consistent
- Update `playground/index.html` for new output file name
- Explicitly specify target => Node output is much smaller
- Minor fixes / cleanup in `.gitignore` and `src/index*.js`
* Start of an SVG rendering quirks mode
* Provide font defaults in SVG quirks mode
* Remove svg-to-image dependency
* Remove fonts and use package fonts instead.
* try/finally for getBBox
The whirl effect's direction was reversed in Scratch 2.0 with the
introduction of Stage3D. This "bug" has existed for long enough to
become the expected whirl direction. This change adjusts the Scratch 3.0
whirl direction to match the Scratch 2.0 3D whirl direction instead of
the Scratch 2.0 2D whirl direction.
* Add Rectangle utility and use it in Drawable.getBounds
* Add `getAABB`, `getFastBounds`.
* Add width and height getters to Rectangle
* Add rectangle clamp
* Optimized isTouchingColor
* Optimized isTouchingDrawables
* Rectangle.ceil -> Rectangle.snapToInt
* Refactor to common _touchingQueryCandidates
* Split helper into two
RenderWebGL{Local,Worker} class methods return Promise instances from
all methods returning a value. This makes the API consistent from a
Web Worker vs. the local page, and also allows the possibility of
asynchronous render queries in the future.
The build generates a new output set called `render-webgl-worker`, meant
to be imported from a web worker. This exposes the `RenderWebGLRemote`
class to facilitate communication with the renderer using `postMessage`
and `onmessage`.
Only a few messages are implemented so far, but it's enough to run the
demo page.
Drawable now creates its own temporary texture upon construction. This
1x1 transparent texture is ready immediately and is replaced once a real
skin is loaded. This slightly simplifies some of the skin loading code
but more importantly prevents GL errors caused when trying to draw a
Drawable if it hasn't yet created its "real" texture, as in the SVG load
path.
The ability to bitwise-combine draw modes turns out to not be a benefit:
it's not safe to short-circuit drawing in the way that I had intended
because it could change the results of blending. Blending could create a
color that matches a "touching color?" check without that color existing
anywhere else.
- Always take color in unsigned-byte terms.
- Moved tolerance value into a class constant.
- Use the same tolerance in JS color comparison as in the shader.
Draw modes are now enabled/disabled by bitmask and can be combined.
Combining silhouette mode and color mask mode will be useful for
color-touching-color, for example.
Effect converters are now one field in a larger EFFECT_INFO map, which
also contains bitmask values for each effect. Drawable no longer makes
any assumptions regarding how ShaderManager will unpack the effect bits.
The shader cache is now an array of arrays, where the outer index is the
mask of active draw modes and the inner index is the mask of active
effects (as it was before). Effects which cannot impact the shape of a
Drawable are masked out in silhouette mode in order to avoid compiling
redundant shaders.
The renderer now calculates the native render target size based on the
edge coordinates provided to the constructor. This native size will be
used directly for queries such as "touching color?" and will be scaled
when rendering for display.
The `isTouchingColor` function now takes an optional mask parameter. If
provided, only the parts of the Drawable which match the mask color will
be used for the test. For example:
```
isTouchingColor(4, red, blue);
```
This means "are there any parts of Drawable #4 which are blue and are
touching a red pixel on some other Drawable?"
Also eliminate the ability to specify background alpha, since that can
affect page-level compositing in undesirable ways.
Also avoid some redundant GL state calls.
Fixed timing errors related to calling `setSkin()` a second time before
the first callback chain completes.
Fixed a typo causing problems when more than one Drawable is registered.
HSL's lightness is, in this case, basically the same as half of HSV's
value, so this change halves the threshold value used by the color
effect to make it similar in appearance to the HSV implementation.
- Increased canvas border in demo.html to make it more obvious if future
code forgets to compensate for the border.
- Fixed picking code to compensate for a border around the canvas.
- Completed support for picking with a touch larger than a single point.
This will allow rendering the primary view, picking view, and "touching
color" view with different projection matrices without needing to
recalculate the model matrix for every Drawable every time.