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.
`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.
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).
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
- `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.
- 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
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.