Commit graph

162 commits

Author SHA1 Message Date
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
Christopher Willis-Ford
4730a057ff Move Drawable.NONE into new RenderConstants
This constant will soon be shared with another class.
2016-12-22 12:58:58 -08:00
Christopher Willis-Ford
e3a05743b0 Handle changing the stage's native size, tell pen
The `setStageSize` wasn't working correctly. This change fixes that and
also notifies active `PenDrawable` instances about the resize. This was
implemented by making the renderer an `EventEmitter`.
2016-12-21 16:13:57 -08:00
Christopher Willis-Ford
2a64c1dd18 Convert pen to subclass of Drawable: PenDrawable
To test, load the playground and type `renderer.createPenDrawable()`
into the JS console. Note that the pen layer is now just another
drawable object, so it can move and use effects.
2016-12-21 11:36:29 -08:00
Christopher Willis-Ford
c6356f71ff Move uniforms, skins, transform back to Drawable
It turns out that it might make sense for the pen to share these
features. Splitting them out would likely work too, but would introduce
unnecessary complexity.
2016-12-20 15:29:22 -08:00
Christopher Willis-Ford
2dafa70ff7 Use sprite shader for pen 2016-12-20 15:22:54 -08:00
Chris Willis-Ford
71ad4a8a80 Merge pull request from cwillisf/more-es6
Convert class methods to ES6 style
2016-12-19 14:53:38 -08:00
Christopher Willis-Ford
8164fef77e Split Drawable into interface & implementation
The skin-based implementation of `Drawable` has been moved into a new
class called `SkinnedDrawable`. This makes room for `PenLayer` to become
a new type of `Drawable`.
2016-12-15 15:51:56 -08:00
Christopher Willis-Ford
14b34f4b3c WIP pen layer
This is the absolute basics of a working pen layer. Still to do:
- Make it so that the pen layer can be in the drawables list so that it
  can be in front of the backdrop but behind other Drawables.
- Remove current debug canvas operations
- Add pen layer API
2016-12-15 13:35:37 -08:00
Christopher Willis-Ford
b18ddadbe6 Rename color4bToID to color3bToID
A recent change made this function take only RGB instead of RGBA, so the
name might as well change to match.
2016-12-15 10:26:24 -08:00
Christopher Willis-Ford
4afbba3657 Respond to review feedback
- Remove unused alpha parameter from `color4bToID`
- Don't wrap URLs for default skins in `Drawable`
2016-12-14 13:38:43 -08:00
Christopher Willis-Ford
d1ea82b2bf Use this inside => callbacks
Some callbacks used a variable called `instance` to stash `this` for use
inside the callback. Now that those callbacks have been converted from
`function` to `=>`, they can just use `this` instead.
2016-12-13 15:51:46 -08:00
Christopher Willis-Ford
b700560198 Convert class methods to ES6 style
Also un-wrap lines which were originally written for an 80-column limit
but don't need to wrap now that the limit is 120 columns.
2016-12-13 15:32:07 -08:00
Chris Willis-Ford
b950b9f9ad Merge pull request from cwillisf/structural-updates
Update configuration to match other Scratch 3.0 projects
2016-12-13 10:04:06 -08:00
Christopher Willis-Ford
3c80ed73a7 Fix lint warnings 2016-12-12 12:06:19 -08:00
Christopher Willis-Ford
5db860efed Use eslint-config-scratch, fix linting errors 2016-12-12 12:06:19 -08:00
Christopher Willis-Ford
47b46fb1aa Update Webpack config like scratch-storage
- Move build outputs into `dist/`
- Make build output file names more consistent
- Update `playground/index.html` for new output file name
- Explicitly specify target => Node output is much smaller
- Minor fixes / cleanup in `.gitignore` and `src/index*.js`
2016-12-12 12:06:05 -08:00
Tim Mickel
b35f684478 A start on SVG "quirks mode" ()
* Start of an SVG rendering quirks mode

* Provide font defaults in SVG quirks mode

* Remove svg-to-image dependency

* Remove fonts and use package fonts instead.

* try/finally for getBBox
2016-11-07 17:40:59 -05:00
Chris Willis-Ford
8be289b7ee Merge pull request from cwillisf/watch-poll
Windows compat: Tell webpack-dev-server to poll
2016-11-02 14:02:31 -04:00
Chris Willis-Ford
722d7224f9 Merge pull request from cwillisf/whirl-direction
Change whirl direction to match Scratch 2.0 3D
2016-11-02 14:02:22 -04:00
Christopher Willis-Ford
85bdbdb721 Windows compat: Tell webpack-dev-server to poll
When running on Windows, Webpack seems to more reliably notice altered
files when running in polling mode. We already use the `--watch-poll`
argument in the `watch` script, but this change adds equivalent settings
to the config used in the `start` script by `webpack-dev-server`.
2016-11-02 10:39:10 -04:00
Christopher Willis-Ford
6c4715f793 Change whirl direction to match Scratch 2.0 3D
The whirl effect's direction was reversed in Scratch 2.0 with the
introduction of Stage3D. This "bug" has existed for long enough to
become the expected whirl direction. This change adjusts the Scratch 3.0
whirl direction to match the Scratch 2.0 3D whirl direction instead of
the Scratch 2.0 2D whirl direction.
2016-11-02 10:32:40 -04:00
Tim Mickel
be6d2dc4e4 Bounding-box optimizations for touching color, touching drawables ()
* 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
2cffa7b643 Add rotation center and bitmap/costume resolution () 2016-10-19 17:02:04 -04:00
Ray Schamp
a484fda1a6 Merge pull request from rschamp/Makefile--
Replace Makefile with npm scripts
2016-10-18 09:44:44 -04:00
Ray Schamp
662ba3c645 Replace Makefile with npm scripts
Allows Windows users to run what's currently in the Makefile
2016-10-17 09:56:32 -04:00
Tim Mickel
85c8b599a0 Update dirty transform before calculating bounds () 2016-10-12 15:20:40 -04:00
Tim Mickel
8e7a85d1a6 Fix y coordinates of bounding box () 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 ()
* 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 () 2016-10-11 18:14:14 -04:00
Tim Mickel
f1ac1a8211 Add RenderWebGL.prototype.isTouchingDrawables () 2016-10-11 18:13:46 -04:00
Tim Mickel
14018f5ff6 Apply ghost effect after discard () 2016-10-11 17:37:28 -04:00
Tim Mickel
7629b2ab6d Add setDrawableOrder for layering ()
* Add `setDrawableOrder` for layering

* Add 0-limit for newIndex
2016-10-07 17:57:47 -04:00
Ray Schamp
d261b57cd1 Merge pull request from LLK/npm
Publish to NPM and Github Pages
2016-09-27 10:28:17 -04:00
Ray Schamp
d813dd9191 Lint 2016-09-27 09:42:04 -04:00
Ray Schamp
053092c85b Alphabetize 2016-09-27 09:29:42 -04:00
Ray Schamp
9fa35524de Be accurate in version comment 2016-09-27 09:22:01 -04:00
Ray Schamp
d7d1f92a13 Remove empty dependencies field 2016-09-27 00:53:25 -04:00
Ray Schamp
59337ef8b5 Update version format for usage with semver
Tracking the version under one `-prerelease` channel allows other packages to depend on `^0.1.0-prerelease` for the most up to date version.

Track the git sha for the release in package.json

Reuse the json package needed for writing the sha to retrieve the package.json version field
2016-09-27 00:52:27 -04:00
Ray Schamp
09dc67fa83 Set playground as dev server content base
For consistency with scratch-vm.
The redirect from index to playground was already unnecessary.
2016-09-26 11:58:26 -04:00
Ray Schamp
856f919970 Add explanatory comments, update gh-pages message 2016-09-25 13:52:40 -04:00
Ray Schamp
9f26ab17eb Publish playground to gh-pages 2016-09-24 15:26:37 -04:00
Ray Schamp
d91ddf4158 Publish to NPM 2016-09-24 15:26:37 -04:00
Ray Schamp
201ceaba77 Merge pull request from rschamp/build-dist
Use path to webpack for postinstall
2016-09-20 16:48:10 -04:00
Ray Schamp
a6c8be8226 Use path to webpack for postinstall 2016-09-20 16:25:24 -04:00
Ray Schamp
89402a88c7 Merge pull request from LLK/build-dist
Build module to be imported
2016-09-20 15:39:05 -04:00
Ray Schamp
278cddf04e Build module to be imported
If another package wants to import `src/index.js`, it needs to replicate the loader config in `webpack.config.js`. To avoid this, package the module in `dist.js` and set that as the module to require.

I changed `main` to point to this so that other packages can just `require('scratch-blocks')`, but it would also work for our purposes to add `"webpack": "./dist.js"` if we want to keep `src/index.js` as `main`.
2016-09-20 09:13:35 -04:00
Tim Mickel
fb3f677e2c Remove worker support ()
* Remove WebWorker support

* Recompile Sept. 14
2016-09-15 19:01:44 -04:00
Tim Mickel
a5fb65ebeb Recompile 3 Sept. 12 () 2016-09-12 12:24:51 -04:00