265 Commits

Author SHA1 Message Date
Paul Kaplan
0b731b92a6 Add "get bounds for bubble" method.
Note there was an inconsequential coordinate flip in the original
transformation code, which was fixed in order for the sliced bounds to
work. The change is at line 388
2018-03-23 10:58:21 -04:00
Chris Willis-Ford
57d834c42e
Merge pull request #235 from mzgoddard/calc-transform-cache
Drawable _calculateTransform cache and inline work
2018-01-24 15:41:31 -08:00
Chris Willis-Ford
f8c781c163
Merge pull request #227 from cwillisf/use-browser-field
Update packaging to use UMD and the browser field
2018-01-24 15:21:16 -08:00
Michael "Z" Goddard
b59b5a3075
Put Drawable skin scale updating behind dirty flag
- Clean out "showing your work" in calculate transform
- Add comments on inline math blocks from twgl
2018-01-23 14:15:59 -05:00
Michael "Z" Goddard
46bc30e4ee
Inline most calculateTransform math 2018-01-23 14:14:38 -05:00
Michael "Z" Goddard
40ab1bd59d
Cache drawable's rotation matrix and rotation center vector
Building a rotation matrix needs to call trigonometry functions. Cache the
resulting matrix to save future time on non-rotation motion.
2018-01-23 14:14:01 -05:00
DD
d46cc4fec7 Merge branch 'develop' into pull231 2018-01-19 17:33:17 -05:00
DD
008abed073 correct case 2018-01-19 17:19:58 -05:00
Paul Kaplan
8a04fcd541 Cache image element in the SVG renderer. 2018-01-17 09:46:07 -05:00
Christopher Willis-Ford
89b5ed32d0 First pass at re-rasterizing SVGs when scaled 2018-01-17 01:05:44 -05:00
Christopher Willis-Ford
bc423cef46 Use require, not import, for SVG renderer 2018-01-12 13:12:55 -08:00
Christopher Willis-Ford
f45442f879 Merge branch 'develop' into extract-svg-renderer 2018-01-12 10:59:46 -08:00
Christopher Willis-Ford
413c1d8027 Extract svg-renderer out into a separate module 2018-01-12 10:56:28 -08:00
Chris Willis-Ford
89d09e9b98
Merge pull request #226 from cwillisf/check-for-webgl-support
Check & report if browser supports this renderer
2018-01-11 11:38:57 -08:00
Christopher Willis-Ford
7dd707db17 Revert getWebGLContext => getContext change
This change allowed TWGL to create a WebGL 2 context when available and
fall back to WebGL 1 when that's the only option. This should in theory
be harmless, but deserves more extensive testing before rolling it out.
2018-01-11 10:07:42 -08:00
Chris Willis-Ford
28983666fd
Merge pull request #228 from LLK/greenkeeper/twgl.js-4.4.0
chore(package): update twgl.js to version 4.4.0
2018-01-10 20:06:08 -08:00
Christopher Willis-Ford
a38c74c2c1 Fix Drawable's use of m4 for TWGL 4.x
The `create` method of `m4` has disappeared; call `identity` instead.
2018-01-10 18:22:57 -08:00
Christopher Willis-Ford
e958e4bfff Fix playground, plus misc. cleanup
The playground was trying to build with a now-missing entry point.
Also, I fixed some JSDoc comments, added HTML labels, etc. until IDEA
had no meaningful complaints about `playground/index.html`.
2018-01-10 17:42:38 -08:00
Christopher Willis-Ford
63fc1c6f64 Update packaging to use UMD and the browser field
The web build is now packaged as UMD, and the `browser` field in
`package.json` now points to the web build output.
2018-01-10 12:58:10 -08:00
Christopher Willis-Ford
07a6ae57be Check & report if browser supports this renderer
`RenderWebGL`'s constructor will now throw if TWGL init fails. There's
also a new static method to check whether or not we expect TWGL init to
succeed.
2018-01-10 12:28:54 -08:00
Paul Kaplan
ab05c9aa32
Merge pull request #225 from paulkaplan/fix-edge
Fix working on Edge
2018-01-10 14:52:35 -05:00
Paul Kaplan
4ce8b8f655 Do not change properties on bbox directly it throws errors in edge. 2018-01-10 13:56:49 -05:00
Paul Kaplan
140bab5965 Escape xml before putting user text into svg 2018-01-09 11:23:04 -05:00
Chris Willis-Ford
1afae3acbd
Merge pull request #204 from cwillisf/use-linear-filtering
Use bilinear filtering except when we shouldn't
2017-12-11 11:54:57 -08:00
Paul Kaplan
43aa62e747 Update comment 2017-12-11 09:15:24 -05:00
Christopher Willis-Ford
96f416467d Remove 3 unnecessary blank lines 2017-12-08 16:36:04 -08:00
Paul Kaplan
1c4e166aa8 Return false instead of undefined 2017-12-08 12:38:04 -05:00
Paul Kaplan
7bb15c7444 Ignore sprite visibility for touching color 2017-12-08 12:27:45 -05:00
Paul Kaplan
8f3254470a Filter out drawables that are not visible. 2017-12-07 15:05:43 -05:00
Christopher Willis-Ford
61c75172d0 Remember: no Hungarian 2017-12-06 15:28:41 -08:00
Christopher Willis-Ford
408b259055 Simplify & document RGB->HSL conversion 2017-12-05 11:01:12 -08:00
Christopher Willis-Ford
e83673ffb8 Increase epsilon for RGB2HCV to fix mobile NaN
Some mobile GPUs end up dividing by "zero" with the previous epsilon
value. The larger epsilon doesn't cause any problems on systems which
didn't exhibit the bug (like my main dev machine).
2017-12-04 15:31:18 -08:00
Paul Kaplan
cde61630ab
Merge pull request #207 from paulkaplan/double-render
Fix double render issue by clearing canvas just before drawing
2017-12-01 11:46:34 -05:00
Paul Kaplan
101b74455c Clear the canvas just before the image is ready to draw. 2017-12-01 10:22:35 -05:00
Paul Kaplan
8a1f3306b7 Check if x has been incremented to OR above the width.
Fixes a bug with the convex hull calculation where the bounds could not
be calculated for certain costumes with non-integer sizes.
2017-12-01 08:56:12 -05:00
Christopher Willis-Ford
9307e09031 Use bilinear filtering except when we shouldn't
Use bilinear filtering unless the Drawable is angled by a multiple of 90
degrees and is either a raster image (like a BitmapSkin) or is around
its native resoluion. This makes both bitmaps and vectors look better in
most cases. This is roughly the same logic that Scratch 2.0 used; we may
want to tweak it over time to see if we can make it even better.
2017-11-29 20:55:50 -08:00
Chris Willis-Ford
72af98d2cf
Merge pull request #193 from griffpatch/touching-color-white
Touching color white always returns "true"
2017-11-20 17:25:42 -08:00
Chris Willis-Ford
8495c6c4e2
Merge pull request #196 from mzgoddard/alpha-shape
Emulate silhouette rendering for pick and _getConvexHullPointsForDrawable
2017-11-20 13:29:39 -08:00
Michael "Z" Goddard
59f6492742
Use isTouching methods in RenderWebGL.pick and getConvexHull
Use Drawable.isTouching and Skin.isTouching to implement pick and
_getConvexHullPointsForDrawable to emulate rendering the drawable's
silhouette and determining what is picked or the points for a convex
hull.
2017-11-20 14:00:37 -05:00
Michael "Z" Goddard
8bdf56705e
Add Drawable.isTouching
Use EffectTransform and Skin.isTouching to implement
Drawable.isTouching.

Drawable.isTouching takes a world coordinate.
2017-11-20 13:46:34 -05:00
Chris Willis-Ford
77e3d63da9
Merge pull request #195 from mzgoddard/whirl-fisheye-without-condition
Whirl and Fisheye shaders without conditions
2017-11-16 16:47:17 -08:00
griffpatch
10762c7f7c Fix misunderstanding of mask3b now that I can bypass the build failure and test 2017-11-16 08:33:10 +00:00
Michael "Z" Goddard
a0df7153bc
Add Skin.isTouching
Use Silhouette to implement Skin.isTouching in subclasses.
2017-11-15 17:41:46 -05:00
Michael "Z" Goddard
448c88e637
Add EffectTransform
EffectTransform transforms a point based on a Drawable's effect uniform
values mimicking the texcoord0 transformation in the shader. This way a
point in the Drawable space can know if its touching its silhouette
when the Drawable has effects active.
2017-11-15 17:41:46 -05:00
Michael "Z" Goddard
1926b49ebc
Add Silhouette class
Silhouette emulates silhouette rendering. Performing tests like
RenderWebGL.pick can use Silhouette in place of reading a silhouette
rendering from the GPU.

Silhouette.isTouching(vec) takes a texture coordinate vector and checks
if the corresponding location is opaque or not for the underlying
information.
2017-11-15 17:39:59 -05:00
Michael "Z" Goddard
08e4523324
Change the fisheye shader so it does not need a conditional 2017-11-15 14:05:26 -05:00
Michael "Z" Goddard
1c9f148923
Change whirl shader so it does not need a conditional 2017-11-15 14:05:25 -05:00
griffpatch
539eb4ce05 Lint issues 2017-11-14 08:32:53 +00:00
griffpatch
3380aa938f Fix for Touching color white always returns "true" #710
So the issue is simple... We start by filling the detector canvas with
the color white, then layer over this the costumes we are want to detect
white colors in (but clip to the shape of the costumre we are detecting
against) then the areas that were clipped will still be white (the
background fill color). So we detect white no matter what.
2017-11-14 08:29:01 +00:00
Michael "Z" Goddard
b060c07db1
Compare new setRotationCenter values after truncating to 32bit
`Skin._rotationCenter` is a twgl vector or said another way a
Float32Array. JavaScript casts values stored in this array as 32 bit
floats instead of JavaScript's standard 64 bit floats. Comparing the
equality, like `setRotationCenter` does, of a 64 bit float against a
value stored in a 32 bit container will virtually always be false.
Truncating the new value into a 32 bit (losing precision) will give a
more useful comparison and remove a lot of current false positives.
2017-11-07 17:33:21 -05:00