Commit Graph

54 Commits

Author SHA1 Message Date
jjspace 09a719b8fb
run prettier v3 2024-09-20 11:24:24 -04:00
Gabby Getz 3f6608f66e Use top level await in Sandcastle 2023-02-03 11:38:55 -05:00
Sanjeet Suhag a4a3b783d8 Sets the Sandcastle startup function as a property to the window 2022-05-23 15:14:50 -04:00
Gabby Getz 8143df4436 var -> const/let 2022-01-21 11:26:25 -05:00
Matthew Amato 2fd0e8f7e4 Format all code with prettier 2020-04-16 20:31:36 -04:00
Matthew Amato aabd27a760 Migrate Cesium to ES6 Modules
See https://github.com/AnalyticalGraphicsInc/cesium/pull/8224 for details.

eslint
There are a handful of new .eslintrc.json files, mostly to identify the files that are still AMD modules (Sandcastle/Workers). These are needed because you can't change the parser type with a comment directive (since the parser is the thing reading the file). We can finally detect unusued modules! So those have all been cleaned up as well.

requirejs -> rollup & clean-css
requirejs, almond, and karma-requirejs have all been removed. We now use rollup for building and minifying (via uglify) JS code and clean-css for css. These changes are fairly straight-forward and just involve calling rollup instead of requirejs in the build process.

Overall build time is significantly faster. CI is ~11 minutes compared to ~17 in master. Running makeZipFile on my machine takes 69 seconds compared to 112 seconds in master. There's probably plenty of room for additional optimization here too.

We wrote an published a small npm module, rollup-plugin-strip-pragma, for stripping the requirejs pragmas we use out of the release builds. This is maintained in the Tools/rollup-plugin-strip-pragma directory.

As for what we produce. The built version of Cesium is now a UMD module. So it should work anywhere that hasn't made the jump to ES6 yet. For users that were already using the "legacy" combined/minified approach, nothing changes.

One awesome thing about roll-up is that it compiles all of the workers at once and automatically detects shared codes and generates separate bundles under the hood. This means the size of our worker modules shrink dramatically and Cesium itself will load them much faster. The total minified/gzipped size of all workers in master is 2.6 MB compared to 225 KB in this branch! This should be most noticeable on demos like Geometry & Appearances which load lots of workers for the various geometry typs.

roll-up is also used to build Cesium Viewer, which is now an ES6 app.

We use clean-css via gulp and it is also a straightforward change from requirejs that requires no special mention.

Workers
While the spec allows for ES6 Web Workers, no browser actually supports them yet. That means we needed a way to get our workers into non-ES6 form. Thankfully, roll-up can generate AMD modules, which means we now have a build step to compile our Worker source code back into AMD and use the existing TaskProcessor to load and execute them. This build step is part of the standard build task and is called createWorkers. During development, these "built" workers are un-optimized so you can still debug them and read the code.

Since there is a build step, that means if you are changing code that affects a worker, you need to re-run build, or you can use the build-watch task to do it automatically.

The ES6 versions of Worker code has moved into Source/WorkersES6 and we build the workers into their "old home" of Source/Workers. cesiumWorkerBootstrapper and transferTypedArrayTest which were already non-AMD ES5 scripts remain living in the Workers directory.

Surprisingly little was changed about TaskProcessor or the worker system in general, especially considering that I thought this would be one of the major hurdles.

ThirdParty
A lot of our ThirdParty either already had a hand-written wrapper for AMD (which I updated to ES6) or had UMD which created problems when importing the same code in both Node and the browser. I basically had to update the wrapper of every third-party library to fix these problems. In some cases I updated the library version itself (Autolinker, topojson). Nothing to be too concerned about, but future clean-up would be using npm versions of these libraries and auto-generating the wrappers as needed so we don't hand-edit things.

Sandcastle
Sandcastle is eternal and manages to live another day in it's ancient requirejs/dojo 1.x form. Sandcastle now automatically uses the ES6 version of Cesium if it is available and fallsback to the ES5 unminified version if it is now. The built version of Sandcastle always uses CesiumUnminified, just like master. This means Sandcastle still works in IE11 if you run the combine step first (or use the relase zip)

Removed Cesium usage from Sandcastle proper, since it wasn't really needed
Generate a VERSION propertyin the gallery index since Cesium is no longer being included.
Remove requirejs from Sandcastle bucket
Update bucket to use the built version of Cesium if it is available by fallbackto the ES6 version during development.
Standalone.html was also updated
There's a bit of room for further clean-up here, but I think this gets us into master. I did not rename bucket-requirejs.html because I'm pretty sure it would break previously shared demos. We can put in some backwards compatible code later on if we want. (But I'd rather just see a full Sandcastle rewrite).

Specs
Specs are now all ES6, except for TestWorkers, which remain standard JS worker modules. This means you can no longer run the unbuilt unit tests in IE11. No changes for Chrome and Firefox.

Since the specs use ES6 modules and built Cesium is an ES5 UMD, I added a build-specs build step which generates a combined ES5 version of the specs which rely on Cesium as a global variable. We then inject these files into jasmine instead of the standard specs and everything works exactly as it did before. SpecRunner.html has been updated to inject the correct version of the script depending on the build/release query parameters.

The Specs must always use Cesium by importing Source/Cesium.js, this is so we can replace it with the built Cesium as describe above.

There's a bunch of room for clean-up here, such as unifying our two copies of jasmine into a single helper file, but I didn't want to start doing that clean-up as part of this already overly big PR. The important thing is that we can still test the built version and still test on IE/Edge as needed.

I also found and fixed two bugs that were causing failing unit tests, one in BingMapsImageryProviderSpec.js (which was overwriting createImage andnot setting it back) and ShadowVolumeAppearance.js (which had a module level caching bug). I think these may have been the cause of random CI failures in master as well, but only time will tell.

For coverage, we had to switch to karma-coverage-istanbul-instrumenter for native ES6 support, but that's it.

Finally, I updated appveryor to build Cesium and run the built tests under IE. We still don't fail the build for IE, but we should probably fix that if we want to keep it going.

NodeJS
When NODE_ENV is production, we now require in the minified CesiumJS directly, which works great because it's now a UMD module. Otherwise, we use the excellant esmpackage to load individual modules, it was a fairly straightforward swap from our old requirejs usage. We could probably drop esm too if we don't care about debugging or if we provie source maps at some point.
2019-10-03 11:51:23 -04:00
Matthew Amato 6e0911e110 Remove all double quote usage from JS code
99% of this PR was automatically fixed with eslint, I simply removed the
`"quotes": "off"` from Sandcastle and Specs which was ignoring the
standard rule of using single quotes.

Also added some Sandcastle generated files to .eslintignore.
2018-07-24 13:28:31 -04:00
ggetz e8ef9c7e6c Added viewer option for shouldAnimate 2018-01-25 12:11:21 -05:00
ggetz 7d197e61df clockViewModel.shouldAnimate -> clock.shouldAnimate 2018-01-24 16:56:45 -05:00
ggetz b540746a6f Clock does not animate by default 2018-01-24 16:06:45 -05:00
Ottavio Hartman ac3129586c Enable no-trailing-spaces rule and fix errors 2017-06-16 11:04:53 -04:00
hpinkos b43e648fe2 picth 2017-01-09 08:40:40 -05:00
Sanuj 04216d0204 Replace "use strict" by 'use strict' 2016-02-09 11:07:51 +05:30
hpinkos cec4127890 Merge branch 'master' into sandcastleCleanup
# Conflicts:
#	Apps/Sandcastle/gallery/CZML.html
2016-02-04 11:48:48 -05:00
hpinkos 3b3b26cc52 add camera.flyHome 2016-02-01 17:54:07 -05:00
hpinkos 5e45012cb1 fix czml camera 2016-02-01 16:07:14 -05:00
hpinkos 66a6790afc cleanup 2016-02-01 16:03:39 -05:00
hpinkos 889af8ac5d cleanup examples 2016-02-01 12:02:17 -05:00
Matthew Amato 77d22e0c62 Update AMD loaders
Update `requirejs` from 2.1.9 to 2.1.20.
Update `almond` from 0.2.6 to 0.3.1.
2015-10-22 17:07:26 -04:00
Matthew Amato 72dcba6670 Remove remnants of Chrome Frame
Fixes #3065
2015-10-13 19:58:09 -04:00
Matthew Amato 18bbfc6a23 Refactor CZML loading methods to be consistent with other data sources
1. Deprecate `loadUrl` and `processUrl`.
2. `load` and `process` can now take urls as their first parameter.
3. Add `CzmlDataSource.load`.
4. All loading and processing functions now return a promise.
5. All RuntimeErrors now lead to rejected promises instead of exceptions.
2015-02-24 10:46:18 -05:00
Matthew Amato 5c6f803723 More Sandcastle cleanup. 2015-01-13 20:49:42 -05:00
Matthew Amato 998667f519 Remove deprecated calls to viewerEntityMixin. 2014-12-15 14:13:33 -05:00
Matthew Amato 388102db64 Remove height=device-height from remaining examples. 2014-09-17 21:00:56 -04:00
Matthew Amato 1d77d3f1b9 Fix CZML Sandcastle example to work standalone.
The script tag was in the wrong place so I just had to resave it.
2014-07-29 09:12:18 -04:00
Dan Bagnell 3bf2c5d345 Remove sensors. 2014-07-28 15:12:32 -04:00
Matthew Amato a2f70f04a2 Merge remote-tracking branch 'origin/master' into sandcastle-defaultToolbar 2014-07-25 09:27:40 -04:00
Matthew Amato c7445f0c3b Add Sandcastle.reset
When defined by a demo, Sandcastle.reset is called whenever a button or menu selection is main.  This allows for the bookeeping/cleanup code to be cleanly abstracted away from the example-specific code that the user is interested in.
2014-07-24 14:33:12 -04:00
Matthew Amato 762f9a7320 Add Sandcastle.addDefaultToolbarButton
Sandcastle.addDefaultToolbarButton excutes and highlights the toolbar immediately, eliminating the need for breaking out an extra function to call (muddying the code in the process).
2014-07-24 12:05:31 -04:00
Matthew Amato 7f466408bf Ongoing GeoJSON cleanup
1. Streamline Sandcastle example
2. Expose basic graphics objects instead of entire entities for default options
3. Add CZML Sandcastle example to the `DataSources` label.
2014-07-23 22:44:04 -04:00
Scott Hunter 891f9d3794 Fix CZML. 2014-07-22 17:30:13 -04:00
hpinkos 1aaa63fdec Merge branch 'master' into refactorSandcastle
Conflicts:
	Apps/Sandcastle/gallery/3D Models.html
	Apps/Sandcastle/gallery/Billboards.html
	Apps/Sandcastle/gallery/CZML.html
	Apps/Sandcastle/gallery/Camera.html
	Apps/Sandcastle/gallery/Labels.html
	Apps/Sandcastle/gallery/Materials.html
	Apps/Sandcastle/gallery/Polyline Color.html
	Apps/Sandcastle/gallery/Polyline Material.html
	Apps/Sandcastle/gallery/Polyline.html
	Apps/Sandcastle/gallery/Simple Polyline.html
	CHANGES.md
2014-07-14 18:03:09 -04:00
hpinkos 23a2a92ef8 Merge branch 'master' into scrubSandcastle 2014-07-11 17:13:33 -04:00
Scott Hunter cf7de52660 Merge remote-tracking branch 'origin/master' into refactorSandcastle
Conflicts:
	Apps/Sandcastle/gallery/CZML.html
2014-07-11 16:31:28 -04:00
Scott Hunter f74d16142a Remove bucketTitle. Fix QuadtreePrimitive example. 2014-07-11 15:42:25 -04:00
hpinkos 3cae7fe67e Create SampleData folder 2014-07-11 11:07:32 -04:00
Matthew Amato 369adf4956 Allow CZML polylines and paths to use materials.
We already allowed this via DataSources, but CZML itself had not yet been udpated.
2014-07-10 11:37:39 -04:00
Scott Hunter 3c9ac014c8 Refactor Sandcastle to avoid require boilerplate in the code editor.
The code in the editor is automatically surrounded with code to require in the Cesium module.  This removes the need for other buckets except Dojo (for now).
The gallery HTML files can be hand-edited to use a combined Cesium.js file simply by removing the RequireJS scripts from the head and inserting
a script tag for Cesium.js.
Various other cleanup in the Sandcastle code itself.  Gallery files are reloaded from the server when clicking them now, previously the contents would be cached in memory.
2014-07-09 17:58:10 -04:00
Matthew Amato 0fdbfd9880 Fix code after DynamicScene rename. 2014-07-02 15:34:44 -04:00
Ed Mackey f82bd45ebb Make Sandcastle.addToolbarButton hide the highlight logic. 2014-06-10 11:43:02 -04:00
Scott Hunter 5a7c643b78 Minor Sandcastle improvements.
Add a toolbar element to most examples to make it easier to copy/paste from one example to another.
Make CTRL-Home and End work properly again.  A Dojo upgrade changed the method we have to hack out to disable the TabContainer key binding.
2014-05-27 16:57:11 -04:00
hpinkos 168096da56 extent -> rectangle 2014-04-10 14:40:51 -04:00
Dan Bagnell 1983a825d8 More updates after removing CameraController. 2014-03-05 14:51:42 -05:00
hpinkos 1236a26ac0 CompositePrimitive, apps 2014-02-07 17:08:02 -05:00
Scott Hunter a9d66aa98f Refactor Sandcastle examples to use two new helper functions: addToolbarButton and addToolbarMenu. 2013-12-06 19:02:05 -05:00
Scott Hunter 2990551e08 Update RequireJS to 2.1.9. 2013-10-21 16:51:48 -04:00
Scott Hunter 4b32e4a3b9 Upgrade RequireJS to version 2.1.8, and Almond to 0.2.6. 2013-10-10 16:05:37 -04:00
hpinkos d3c3ee2312 add translucent shapes, rename everything 2013-09-18 15:25:51 -04:00
hpinkos aeb1b6eef8 scroll on all tabs, initial geometry examples, add showcase tab, move all tab to last position 2013-09-10 14:33:39 -04:00
Ed Mackey f4d4f9d353 Merge pull request #1056 from hpinkos/issue1051
firefox sandcastle css issues
2013-08-22 14:18:07 -07:00