28 Commits

Author SHA1 Message Date
Karishma Chadha
11665299bc
Revert "Put Skin Alter Push Back In" 2019-09-26 09:39:05 -05:00
Karishma Chadha
2a1d215e50
Revert "Revert "Revert "Revert "Skin alter push"""" 2019-09-12 13:43:32 -04:00
Karishma Chadha
1cd9e54834
Revert "Revert "Revert "Skin alter push""" 2019-09-12 13:24:03 -04:00
Chris Willis-Ford
928cd60dd5
Merge pull request #496 from LLK/revert-493-revert-470-skin-alter-push
Revert "Revert "Skin alter push""
2019-09-04 18:14:41 -07:00
Karishma Chadha
7c4393787b
Revert "Revert "Skin alter push"" 2019-08-13 11:42:51 -04:00
Karishma Chadha
a340b8a04b
Revert "Revert "Initialialize AABB Rectangle "" 2019-08-13 11:41:11 -04:00
Karishma Chadha
c2e32d2baf
Merge pull request #494 from LLK/revert-467-rect-init-matrix
Revert "Initialialize AABB Rectangle "
2019-08-13 11:38:41 -04:00
Karishma Chadha
c8f7496fba
Revert "Initialialize AABB Rectangle " 2019-08-13 11:26:07 -04:00
Karishma Chadha
4a28cffcd4
Revert "Skin alter push" 2019-08-13 11:22:27 -04:00
Chris Willis-Ford
cc5fea803e
Merge pull request #470 from mzgoddard/skin-alter-push
Skin alter push
2019-07-01 10:43:11 -07:00
Michael "Z" Goddard
f9b1a04d1a
cache Skin.size 2019-06-18 17:18:48 -04:00
Michael "Z" Goddard
a840089bc9
fence bounds 2019-06-11 13:05:22 -04:00
Michael "Z" Goddard
bf47f69b04
use a destination parameter for bounds; add initFromMatrixRadius
- pass bounds as a destination parameter
- add initFromMatrixRadius
- use initFromMatrixRadius in getAABB
2019-06-06 14:39:56 -04:00
peabrainiac
152cf028cc
Update Skin.js 2019-03-03 18:39:40 +01:00
Katie Broida
1f0f89920a Always use getAABB for bitmap skins when determining fenced position 2019-02-11 11:56:59 -05:00
Mx Corey Frang
c54a928f0a
Touching color implementation (#312)
* Touching color draft implementation

* New constant for CPU/GPU render split determined, removing query param

* Small fix for pick tests
2018-08-08 14:20:35 -04:00
Mx Corey Frang
2b8371e5af
Rewrite isTouchingDrawables on CPU (#263)
* avoid gl.readPixels at all costs
2018-04-27 16:19:25 -04: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
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
a0df7153bc
Add Skin.isTouching
Use Silhouette to implement Skin.isTouching in subclasses.
2017-11-15 17:41:46 -05: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
Josh Lory
0d1d7dab3a Scratch 2.0 compat: don't modify rotation center of empty sprites 2017-08-09 23:01:09 -07:00
Ray Schamp
3c6511d94e Generate docs from src, publish to gh-pages
Fix any broken JSDoc syntax. Unfortunately there is no way to document tuples like `{[int, int]}` for a `[width, height]` array. We could possibly fix this and make the code more readable with `{width: number, height: number}` instead of tuples.

Remove single `@fileoverview` from Rectangle.js, since it was the only file with one and was weird to have that one module show up on the docs home page.

Add a `docs` script to `package.json`, run it from `npm test`, so invalid docs will cause tests to fail (eventually we may want to start using eslint-plugin-jsdoc to catch these errors with the linter alone).
2017-02-21 14:46:24 -05:00
Ray Schamp
875a5a3ec1 Calculate rotation center if it's not supplied
When a new skin is added, previously the rotation center was set to `[0, 0]`.  In the case of costumes and backdrops added from libraries, the center should be calculated from the bounding box of the imported skin.

Toward LLK/scratch-gui#18
2017-01-13 13:10:20 -05:00
Christopher Willis-Ford
1f0cd4b61f Fix resource leaks discovered while testing
- `Drawable` now removes its `Skin` on `dispose`, disconnecting events.
- Creating a new `Drawable` doesn't always create a new `Skin` any more:
  now it can share an existing skin.
- Don't throw when asked to update the properties of a `Drawable` that
  has already been destroyed. This seems like a VM bug but was causing
  overwhelming output in the browser for some projects.
2016-12-29 13:42:58 -08:00
Christopher Willis-Ford
6a0798062b Make a Skin emit an event when it is altered
This allows any `Drawable` using the `Skin` to update its transform as
necessary.
2016-12-29 10:46:12 -08:00
Christopher Willis-Ford
ba5deb9936 Minor cleanup after Drawable/Skin refactor
- Add & correct a few comments
- Make `Drawable` IDs work like `Skin` IDs
- Remove some dead code
- Fix costume resolution in `BitmapSkin` before first `setBitmap` call
- Rename `Drawable` & `Skin` management variables in `RenderWebGL` to
  clarify their purpose and better distinguish them from each other
- Remove problematic premature optimization in `_drawThese`
- Fix missing return statement in `Skin`'s `setRotationCenter`
- Fix mismatch between getTexture & getUniforms in the `Skin` class
2016-12-28 14:38:48 -08:00
Christopher Willis-Ford
64c5991486 Split Skin functionality out of Drawable
There is now a `Skin` base class along with `SVGSkin` and `BitmapSkin`
classes for vector and bitmap skin support. Loading a skin by URL is in
the process of being deprecated. In the future skin data should be
downloaded outside the renderer and supplied through new `create*Skin`
API calls.
2016-12-28 12:17:45 -08:00