Commit Graph

161 Commits

Author SHA1 Message Date
jjspace 09a719b8fb
run prettier v3 2024-09-20 11:24:24 -04:00
Gabby Getz e9dfea584a pickPosition uses globeDepth 2024-05-14 10:11:26 -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
Peter Gagliardi 2fa7015313 string concatenation -> template literals 2022-02-02 15:40:21 -05: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
Sanjeet Suhag 98f72e8649 Removes CesiumMilkTruck-kmc.glb, replaces all references to CesiumMilkTruck.glb instead 2020-01-15 10:43:41 -05:00
Matthew Amato dceac54c0e Fix missed file rename. 2019-11-01 14:51:06 -04:00
Sean Lilley 6a4a33344c
Merge pull request #8246 from AnalyticalGraphicsInc/sandcastleLogFixes
Replaced console.log and RuntimeError with window.alert for sandcastles with unsupported features
2019-10-04 17:14:55 -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
Ian Lilley f5405fc38f replaced console.log and RuntimeError unsupported feature errors to window.alert 2019-10-03 09:42:51 -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
loshjawrence f6b654838e adding the same pickPositionSupported check to the remaining Apps (Picking.html was the only other one with refernece to pickPositionSupported) 2018-06-04 16:05:58 -04:00
Dan Bagnell 9ba9db3ac4 Add support for picking depth in 2D. 2017-02-10 14:35:31 -05:00
Dan Bagnell e81d8c5b84 Add support for picking depth in CV. 2017-02-10 13:03:57 -05:00
Patrick Cozzi 70bcd38390 Tweak wording 2017-01-21 09:23:20 -05:00
Rachel Hwang 216056e659 Add scene mode checking in sandcastle picking example 2017-01-20 10:58:18 -05:00
Ed Mackey 6539033966 Update Sandcastle picking demo. 2016-12-12 10:14:31 -05:00
Tom Fili 4e05e71ba4 Fixed Picking example. 2016-06-30 16:06:49 -04:00
Sanuj 04216d0204 Replace "use strict" by 'use strict' 2016-02-09 11:07:51 +05:30
Patrick Cozzi 7eb031a1d9 Tweak picking example 2015-11-12 08:45:01 -05:00
Sean Lilley f94118d27c Updated Picking.html 2015-11-12 08:43:41 -05:00
Patrick Cozzi 7da25eb47c Fix picking Sandcastle example 2015-10-29 17:39:43 -04: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
Dan Bagnell ddeed08c12 Check for undefined when using Scene.pickPosition. 2015-06-01 14:28:24 -04:00
Dan Bagnell 3e7fe6b276 Use bgltf model and remove commented code in development example. 2015-05-27 17:28:54 -04:00
Dan Bagnell 6604aff8d8 Remove unecessary undefined check. 2015-05-22 15:06:26 -04:00
Dan Bagnell 24153338ae Remove commented code. 2015-05-22 14:12:51 -04:00
Dan Bagnell a65515f5c5 Adjust eye offset in picking Sandcastle example. 2015-05-22 14:12:02 -04:00
Patrick Cozzi 23937ee8cc Sandcastle example rename 2015-05-21 17:32:44 -04:00
Dan Bagnell 027ccab0c1 Add Scene.pickPositionSupported. 2015-05-21 17:10:44 -04:00
Dan Bagnell fe5c0cfacd Fix missed rename and change pickDepth -> pickPosition. 2015-05-21 17:04:51 -04:00
Dan Bagnell d261529c1e Clean up picking Sandcastle example. 2015-05-21 16:41:03 -04:00
Dan Bagnell 5a7208f247 Update Sandcastle example based on review. 2015-05-21 15:21:13 -04:00
Dan Bagnell 5c772f325d Fix packing/unpacking depth values from RGBA buffer. 2015-05-20 17:17:16 -04:00
Dan Bagnell dfb64a490d Pick the position closest to the camera position when picking depth. Added debug show pick depth to scene and Cesium Inspector. 2015-05-19 16:23:23 -04:00
Dan Bagnell a2b07b4d6c Tweak picking depth. Update Sandcastle example to not use labels. 2015-05-18 16:10:42 -04:00
Dan Bagnell 69907e03cf Add Sandcastle example for picking the depth buffer. 2015-05-14 17:55:24 -04:00
Matthew Amato 1dddd69358 Clean up drill pick example, even though it does not work properly due to #2442 2015-01-29 16:36:26 -05:00
Matthew Amato 86077a0357 Make Sandcastle examples use Color.withAlpha where appropriate. 2015-01-27 14:20:05 -05:00
Matthew Amato 5c6f803723 More Sandcastle cleanup. 2015-01-13 20:49:42 -05:00
Matthew Amato 75669959c9 Simplify drill-pick example
Still needs more work.  Also update labels on 2 dev-only demos.
2015-01-07 22:27:02 -05:00
Matthew Amato 599aaeb2b2 Port more Sandcastle exampels to use entities
There are some issues with Picking and 3D Models that require lower
level changes.
2015-01-06 20:50:18 -05:00
Patrick Cozzi f094841afc Added camera to Viewer and CesiumWidget 2014-12-23 09:19:35 -05:00
Patrick Cozzi 609a8f3a50 Clean up use of primitives.add in Sandcastle examples 2014-10-12 13:16:08 -04:00
Matthew Amato 388102db64 Remove height=device-height from remaining examples. 2014-09-17 21:00:56 -04:00
Matthew Amato 1a2686daf5 Merge remote-tracking branch 'origin/master' into sandcastle-defaultToolbar
Conflicts:
	Apps/Sandcastle/gallery/Billboards.html
	Apps/Sandcastle/gallery/Terrain.html
2014-07-25 13:37:30 -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