Commit Graph

46 Commits

Author SHA1 Message Date
jerome.fayot 402fe6b579 fix: replaced defaultValue with ?? 2025-03-11 22:58:00 +01:00
Sanjeet Suhag aaf6bd8a5c Adds engine and widgets workspaces 2022-11-01 15:39:57 -04:00
Sanjeet Suhag cf266ae4af Fixes duplicate imports in specs 2022-07-21 17:32:08 -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
Ottavio Hartman 337ad9d7eb Remove global define and global defineSuite 2017-06-28 17:10:51 -04:00
Patrick Cozzi 5205fce667 Move WebGL stub to the Specs directory so it is not part of the Cesium build 2017-01-05 08:53:19 -05:00
Patrick Cozzi a211783459 Remove destroyCanvas 2017-01-05 08:28:53 -05:00
Patrick Cozzi 937fc23bb9 Fix timing issue when using WebGL stub from the command line 2017-01-05 07:48:41 -05:00
Patrick Cozzi 0317330f27 Change createContext and related tests to not request alpha for the WebGL context just like the default when constructing a Scene 2016-12-21 09:55:04 -05:00
Patrick Cozzi fc9459fab5 Fix JSHint warnings 2016-12-20 08:07:49 -05:00
Patrick Cozzi 4bc0ec1373 Replace verifyDrawForSpecs with custom matcher 2016-12-16 07:45:57 -05:00
Patrick Cozzi 547d126a5f Pass through webglStub query parameter 2016-12-02 09:18:54 -05:00
Sanuj 04216d0204 Replace "use strict" by 'use strict' 2016-02-09 11:07:51 +05:30
Matthew Amato 86b7a49568 Fix Travis, update .jshintrc, remove a ton of junk.
So it turns out that jsHint no longer works on Node 0.10.x, which is
ancient anyway.  So I updated Travis to use 0.12.x.  I then decided to
update our .jshintrc to take advantage of the latest JSHint features and
that produced a TON of new (perfectly valid) errors about unused variables,
empty code blocks, and unused defined globals, which I have now cleaned up.
This also uncovered a bunch of other stuff that I also fixed.

In summary:

1. Update travis to use Node 0.12.x
2. Update .jshintrc to take advantage of new features
3. Fix bad code pointed out by said features
4. Remove all uneeded `jasmine` globals in spec files
5. Generate a `Specs` specific .jshintrc as part of the build which enables jasmine mode in jshint
6. Move `QuadtreePrimitive` to Development Sandcastle gallery.
7. Update NPM modules to latest versions.
8. Lock NPM modules to specific versions to avoid untested updates in the future.
9. Ran `sortRequires`
2015-11-13 01:11:20 -05:00
Dan Bagnell 9ce636224a Frame state refactor WIP. 2015-10-23 19:20:40 -04:00
Matthew Amato 2b34d0aac3 Default failIfMajorPerformanceCaveat to false
In order to avoid users first impression of Cesium being a failed to
load screen, this changes failIfMajorPerformanceCaveat back to the
official WebGL default of `false`. While I agree that many Cesium apps
will perform poorly under these conditions, there are several use cases
where it makes sense, such as RDP sessions.

I also removed an old Firefox workaround for Firefox 35.  Since 35 was not
an ESR release, there's no reason for the workaround to still be there.
2015-10-19 12:14:39 -04:00
Sean Lilley da9cfd6cfe Updates to buffer to separate sizeInBytes from typedArray 2015-08-27 11:05:43 -04:00
Sean Lilley 7738eb6917 Refactor buffer creation 2015-08-26 16:40:27 -04:00
Sean Lilley c72c1b8bcf Moved ShaderProgram creation out of Context 2015-08-25 17:18:53 -04:00
Sean Lilley b027ab1dc8 Removed vertex array creation from Context 2015-08-24 09:33:15 -04:00
unknown e2fe7c4598 set failIfMajorPerformanceCaveat to false in tests 2015-08-20 15:52:28 -04:00
Kevin Ring 321ffcfdb5 Remove waitsFor, waits, and runs from spec global list. 2015-02-17 16:17:54 +11:00
Patrick Cozzi db2df1fef3 Remove destroyContext 2015-02-06 11:10:07 -05:00
Patrick Cozzi a12b87cefc Reuse verifyDraw for several tests 2015-02-06 10:44:15 -05:00
Scott Hunter 5399aee0be remove Specs/getQueryParameters which is no longer needed 2014-10-01 16:31:46 -04:00
Patrick Cozzi 974937a1a3 Fix JSHint warnings 2014-06-20 20:48:45 -04:00
Patrick Cozzi fac9c689b0 Use WebGL validation with tests using createScene. Use WebGL validation only when requested. 2014-06-20 16:58:03 -04:00
hpinkos 8403d3d9eb replace functions in code 2014-03-27 15:46:38 -04:00
Patrick Cozzi dfc7593c48 Added allowTextureFilterAnisotropic 2013-11-28 08:35:53 -05:00
Frank Stoner 2a19aef805 Turn off antialiasing for test robustness. 2013-11-12 12:06:23 -05:00
Daniel Yankowsky 17bfbf1208 addressing minor issues with pull request 2013-09-20 15:56:39 -04:00
Daniel Yankowsky b5789e1b8f Decoupled canvas client dimensions from drawing buffer dimensions. 2013-09-20 11:54:39 -04:00
Patrick Cozzi eee3088588 Fixed JSHint warning 2013-09-13 15:00:17 -04:00
Patrick Cozzi bf3327fa9f Option to run tests with WebGL validation 2013-09-12 17:13:03 -04:00
Patrick Cozzi 2fb48033c2 Changed way GLSL source is generated to workaround uniforms not being optimized out 2013-08-21 14:48:46 -04:00
Scott Hunter ed7898e05b Clean up usage of defaultValue.
* Add a reusable defaultValue.EMPTY_OBJECT instance for convenience without allocations.
* Prefer `typeof a !== 'undefined' ? a : b` when not using defaultValue, to have a consistent order of values.
* Make `clone` not deep copy by default.  Use `clone` to avoid modifying passed-in option hashes.  Add tests.
2013-04-26 20:30:12 -04:00
Dan Bagnell a538e343a4 Fix tests. 2013-03-18 15:30:10 -04:00
Scott Hunter 9e13d8a1f3 Replace ../Specs with Specs everywhere.
The two are subtly different, though largely equivalent, but cause a problem in a use case in our imagery_layers branch.
2012-09-20 17:51:15 -04:00
Scott Hunter 08d7cfe072 Fix file modes. 2012-06-29 14:57:53 -04:00
Dan Bagnell 34c7980fb4 Add tests for Scene and chekc for undefined values in the Camera pick functions. 2012-06-28 19:42:00 -04:00
Matthew Amato d8032f326f Change all double quotes, ", to single quotes, ', except for "use strict" 2012-06-08 11:13:00 -04:00
Scott Hunter 3d2c456cd1 Specify all JSHint options, then fix warnings.
There were still some options that defaulted to the unexpected choice,
so I finally gave in and specified values for all the options on the webpage.
Also turn on browser globals across the board.
2012-05-10 11:17:06 -04:00
Scott Hunter 4457439a11 set default Eclipse settings to use LF and UTF-8 for new files.
Fix existing files that had CRLFs.
2012-05-01 17:02:13 -04:00
Scott Hunter c2105b7e72 Reorganize project. Move Cesium up one level, so now the root of the git repository is the root of the source tree, and the root of the Eclipse project. 2012-04-25 10:55:13 -04:00