Using the combined Build/Cesium.js instead of the individual .js files

612 views
Skip to first unread message

Gerald Kaszuba

unread,
Oct 2, 2012, 6:01:18 PM10/2/12
to cesiu...@googlegroups.com
Hi,

I asked this question on Stack Overflow without much luck so I thought to try in here. I'll repost the question, so for reference, the URL is: http://stackoverflow.com/questions/12684914/using-the-combined-build-cesium-js-instead-of-the-individual-js-files

I've been going around in circles trying to get the Cesium dependencies not to import when they're imported from the "combined" Cesium.js.

I've got this code to a stage where it's correctly finding the path of Cesium files, but it is loading up 100's of them, instead of only the combined Build/Cesium.js and the CesiumViewerWidget (which doesn't seem to be included in combined). e.g. One of the many files it loads is Source/Core/Clock.js which is built into Build/Cesium.js.

How can I tell dojo or CesiumViewerWidget to assume the core dependencies are already there?

I'm running this with Rails, hence the /assets/ path.

The code I'm working with:

<script src="/assets/cesium/Build/Cesium.js" type="text/javascript"></script>
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.8.0/dojo/dojo.js" type="text/javascript"></script>

require({
    baseUrl: '/assets/cesium/Source/Widgets',
    packages: [
        // {name: 'Cesium', location: '../../Build/Cesium'},
        {name: 'Widgets/Dojo/CesiumViewerWidget'},
        // {name: 'dojo/on', location: 'dojo/on'},
        // {name: 'dojo/dom', location: 'dojo/dom'},
        // {name: 'dojo/io-query', location: 'dojo/io-query'}
    ]},
    [
        'Widgets/Dojo/CesiumViewerWidget',
        'dojo/on', 'dojo/dom', 'dojo/io-query'
    ], function(CesiumViewerWidget, on, dom, ioQuery) {
})

Thanks,

Gerald

Scott Hunter

unread,
Oct 2, 2012, 6:09:37 PM10/2/12
to cesiu...@googlegroups.com
Hi Gerald,

If you're using the combined JS file (Build/Cesium.js), you don't need to use require at all.  It exports a global Cesium variable.  

However, if you want to use Cesium with Dojo, then loading lots of individual source files is the expected result, in development mode.  The combined file is not built to work with Dojo, but instead is there to hide all of the modules, for users who aren't interested in using an AMD module system in their application.

For deployment, you can then use the Dojo build system (http://dojotoolkit.org/reference-guide/1.8/build/) to produce layers containing all your application's dependencies in one file.  The Dojo build system is fairly complicated, but if you look in our build.xml file, you can see how we use the build system on the CesiumViewer application, producing minified, combined output in Build/Apps.

Let me know if that helps.

Scott

--
You received this message because you are subscribed to the Google Groups "cesium-dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cesium-dev/-/IpjMyJzhO3QJ.
To post to this group, send email to cesiu...@googlegroups.com.
To unsubscribe from this group, send email to cesium-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cesium-dev?hl=en.

Gerald Kaszuba

unread,
Oct 2, 2012, 9:07:20 PM10/2/12
to cesiu...@googlegroups.com
Scott,

Looking into it after your advice, I've (basically) hacked CesiumViewerWidget so it refers to the Cesium object (e.g. Cesium.Scene instead of Scene) and removed the Cesium dependencies from the dojo require() call. This is a simple explanation of what I actually did, but that essentially solves the dependency problem.

Thanks for the help!

Gerald
Reply all
Reply to author
Forward
0 new messages