Commit graph

162 commits

Author SHA1 Message Date
Tim Mickel
2b81b791b3 Use the right skin format in playground demo () 2016-09-12 12:08:56 -04:00
Tim Mickel
042f0f0353 Fix asset URL handling from ()
* Fix URL handling of assets

* Recompile 2 Sept 12
2016-09-12 11:55:08 -04:00
Tim Mickel
69821db56f Recompile Sept 12 () 2016-09-12 11:06:53 -04:00
TheBrokenRail
3277584da9 Offline Sprites ()
* Added Scratch Cat SVG

* Offline Scratch Cat

* Moved To SRC

* Update README.md

* Delete Travis

* Add Travis YML

* Recompile

* Add files via upload

* Recompile Part 1

* Recompile Part 1

* Recompile Part 1

* Recompile Part 1

* Recompile!

* Not Needed

* Recompile For Real

* Update README.md

* Added Stage Offline

* Less Hacky Offline

* Recompile

* Fixed Line Length
2016-09-12 11:03:57 -04:00
Andrew Sliwinski
19bb8b99c3 Build 2016-08-08 15:00:04 -04:00
Andrew Sliwinski
bf26fe41e8 Update demo worker based on feedback from @cwillisf 2016-08-08 14:59:51 -04:00
Andrew Sliwinski
92fc916b86 Synchronize with master branch 2016-08-08 14:58:35 -04:00
Andrew Sliwinski
f5cd625be8 Fix issue in worker where 'window' is undefined 2016-08-08 14:28:06 -04:00
Andrew Sliwinski
b8cc5f5245 Update documentation in README 2016-08-08 14:23:25 -04:00
Andrew Sliwinski
47b5d07497 Update gitignore 2016-08-08 14:23:01 -04:00
Andrew Sliwinski
672947ca56 Normalize build result naming to match VM conventions 2016-08-08 14:22:54 -04:00
Andrew Sliwinski
fc7db05978 Add Travis configuration 2016-08-08 14:22:21 -04:00
Andrew Sliwinski
3dca142bb9 Move “demo” into “playground” directory as to match VM and Blocks 2016-08-08 14:22:06 -04:00
Andrew Sliwinski
894ada4960 Move development dependencies into “devDependencies” in package.json 2016-08-08 14:21:21 -04:00
Andrew Sliwinski
86ae0d63e3 Remove unused test commands and clean-up Makefile 2016-08-08 14:21:01 -04:00
Andrew Sliwinski
5c75fc0112 Remove IDEA IDE specific configuration files. 2016-08-08 14:20:32 -04:00
Christopher Willis-Ford
543f05d6d4 Use babel-polyfill, plus compatibility fixes 2016-06-16 14:30:32 -07: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
b00ec4c501 Rename WorkerRemote to RenderWebGLWorker 2016-06-15 15:36:46 -07:00
Christopher Willis-Ford
ad94df4afe Use ES6 class definitions 2016-06-15 15:21:58 -07:00
Christopher Willis-Ford
2c9e17d486 Use babel for ES6 / ES2015 support 2016-06-15 14:39:44 -07:00
Christopher Willis-Ford
f3a80c3429 Split 'index' files into 3: node, web, worker 2016-06-15 13:48:02 -07:00
Chris Willis-Ford
73ae8c205d Add missing raw-loader package 2016-06-14 18:55:38 -04: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
b74f9448f5 Simplify draw modes again
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.
2016-06-09 16:30:26 -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
91cc797c3b Refactor ShaderManager's DRAW_MODE and effect info
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.
2016-06-09 12:17:12 -07:00
Christopher Willis-Ford
bb357ba8bc Exclude build directory in IDEA
This helps with searches, "Go To Declaration", etc.
2016-06-09 12:03:10 -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
74deedba1b Add .editorconfig 2016-06-08 09:27:01 -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  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
Christopher Willis-Ford
4d04ef5de7 Use Buffer instead of Uint8Array (lint fix)
Also suppress lint warning about unused alpha in color4ubToID since
that's intentional (for now).
2016-06-02 15:42:55 -07:00
Christopher Willis-Ford
bdf65d4284 Add isTouchingColor(drawableID, color3ub)
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.
2016-06-02 15:09:02 -07:00
Christopher Willis-Ford
25d8148ec4 Add more flexibility to draw-time object filtering
The `_drawThese` call now takes both a list of Drawable IDs for positive
filtering and a filter function for negative filtering.
2016-06-01 16:17:56 -07:00
Christopher Willis-Ford
137e4a642e Skin loading improvements
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.
2016-06-01 15:28:08 -07:00
Christopher Willis-Ford
e03e9a0929 Drop lightness threshold for color effect
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.
2016-06-01 14:23:13 -07:00
Christopher Willis-Ford
f6b78b2216 Picking improvements
- 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.
2016-05-31 14:00:39 -07:00
Christopher Willis-Ford
c02d2a1f5b Add picking test to demo.html
It appears that picking is 1 pixel off in each dimension
2016-05-27 16:18:13 -07:00
Christopher Willis-Ford
94cbe8999d Implement pick(x,y) -> Drawable ID 2016-05-27 16:10:22 -07:00
Christopher Willis-Ford
36439bf665 Multiply projection and model matrices in shader
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.
2016-05-27 11:55:15 -07:00
Christopher Willis-Ford
c24cfaaf4c Fix pixelate "pixel" size
Pixelate still needs a bit more work: at certain scales the edges of the
"pixels" are ragged. This happens in Scratch 2.0 as well, but for me it
seems slightly worse in this implementation.
2016-05-26 09:53:22 -07:00
Christopher Willis-Ford
03107781ab Use HSL instead of HSV for brightness effect 2016-05-25 14:21:40 -07:00
Christopher Willis-Ford
dcedd0c3cf Fix brightness and ghost effects
The renderer now uses premultiplied alpha in the frame buffer, though
textures are still stored without premultiplied alpha. This makes it
easier to get the desired results from the browser's canvas compositing
step, and might be nicer for mobile hardware depending on which parts of
the Internet you believe.
2016-05-20 15:36:02 -07:00
Christopher Willis-Ford
920271d076 Fix pixelate effect
This implementation of the pixel effect is now very similar to the
PixelBender implementation in Scratch 2.0

I also added a slider to demo.html as a debugging aid: it manipulates a
value that is passed into the shader and used in whatever way helps.
2016-05-20 14:17:44 -07:00