21 Commits

Author SHA1 Message Date
Tim Mickel
be6d2dc4e4 Bounding-box optimizations for touching color, touching drawables (#55)
* 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
2016-10-24 13:19:20 -04:00
Tim Mickel
8e7a85d1a6 Fix y coordinates of bounding box (#46) 2016-10-12 14:32:14 -04:00
Tim Mickel
c00f0f55fc Math.max mix-up
Bounding to a minimum, we should use `Math.max`...
2016-10-12 13:46:32 -04:00
Tim Mickel
1fa97d248b Expose skin/costume size (#45)
* Expose skin/costume size

* Return skin size as a copy
2016-10-11 18:43:57 -04:00
Tim Mickel
a62d52a2d0 Calculating tight bounding boxes for Drawables (#42) 2016-10-11 18:14:14 -04:00
Tim Mickel
f1ac1a8211 Add RenderWebGL.prototype.isTouchingDrawables (#43) 2016-10-11 18:13:46 -04:00
Tim Mickel
7629b2ab6d Add setDrawableOrder for layering (#41)
* Add `setDrawableOrder` for layering

* Add 0-limit for newIndex
2016-10-07 17:57:47 -04:00
Tim Mickel
fb3f677e2c Remove worker support (#36)
* Remove WebWorker support

* Recompile Sept. 14
2016-09-15 19:01:44 -04:00
Andrew Sliwinski
92fc916b86 Synchronize with master branch 2016-08-08 14:58:35 -04:00
Christopher Willis-Ford
ef100bf91e Make API consistent from page and worker
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.
2016-06-16 12:59:48 -07:00
Christopher Willis-Ford
ad94df4afe Use ES6 class definitions 2016-06-15 15:21:58 -07:00
Christopher Willis-Ford
fc10df7e41 Allow driving the renderer from a web worker
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.
2016-06-14 11:45:35 -07:00
Christopher Willis-Ford
f0dae7aa48 Fix GL errors when using SVG Drawable early
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.
2016-06-13 10:23:54 -07:00
Christopher Willis-Ford
04cebb9eed Improve color handling in isTouchingColor
- 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.
2016-06-09 15:32:23 -07:00
Christopher Willis-Ford
aeefe8e5a3 Add setDebugCanvas method
Some debug code has been moved inside conditionals instead of comments
2016-06-09 15:17:21 -07:00
Christopher Willis-Ford
1edb753ac8 Add silhouette color to Drawable's uniforms 2016-06-09 13:44:04 -07:00
Christopher Willis-Ford
a21bd1aff1 Simplify coordinate system specification
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.
2016-06-09 10:59:19 -07:00
Christopher Willis-Ford
1040189e27 Move shader management to new ShaderManager class 2016-06-08 13:38:49 -07:00
Christopher Willis-Ford
9f59b42901 Implement color-touching-color
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?"
2016-06-06 16:21:24 -07:00
Christopher Willis-Ford
6b0f3379bf Allow overriding the candidates for picking
This can be used to implement the "touching {mouse-pointer}?" block.
2016-06-03 09:21:36 -07:00
Christopher Willis-Ford
eb7e87730c Move RenderWebGL class into its own file
The `index.js` file now handles module-level exports only.
2016-06-03 08:47:50 -07:00