Objective-C/iOS port

Hi everyone,

I’ve started working on an Objective-C port of Cesium.

I was initially going to use it as part of a private iOS project, however figure its probably more widely useful than just to myself so have posted up the current source.

At the moment it mainly consists of a partial implementation of Core and Renderer. Nothing end-user friendly yet, but hopefully basic untextured globe rendering will be working soon.

At the moment its largely a straight port of the JS and WebGL logic, but hopefully once it’s working there will be some efficiencies to be gained via native code on the device.

Hopefully I’m not crazy and this will actually be a manageable amount of work and helpful to others. Comments and commits welcome! The code is up at github. Licensed under the Apache 2.0 licence as is Cesium.

Comments and commits welcome!

Regards,

Ryan

Hi Ryan,

Exciting news. Good luck with this project.

Are you doing the port by hand? Or are you using an automated tool?

What version of Cesium are you porting? We are planning for 1.0 in July. How to you plan to keep the port in sync?

Just curious…what personal project is driving this?

Patrick

Thanks Patrick, and thanks for making Cesium open source and so well-documented.

I’m porting by hand, which is a bit laborious but it’s good learning as I go. If you know of any automated tools to speed things up I’m all ears though! I’d initially started with the OpenGlobe C# code from your book, however porting from JS is probably just as easy if not easier, and Cesium is obviously much more feature complete. The book is a handy reference though particularly with theory.

Currently I’m using the main development branch and keeping an eye on commits, as I’d like to keep as close as possible to the javascript code, at least at the API level. CZML-parsing is also a very useful thing I’d like to retain once I get primitives working. If I was going to pick a fixed target a 1.0 release would be a good one though.

Some WebGL vs GLES idiosyncracies will likely mean some renderer change, hopefully this is minimal though as I appreciate the clarity and simplicity of the level of abstraction.

There’s also no lightweight array type in Objective C so I’ll likely have to roll my own C-based one for the vertex arrays.

I don’t have any good ideas on how to keep things in sync other than manually at this stage, hopefully once I’m up to feature parity tracking changes won’t be too hard, and if there’s community interest in specific features once the core renderer is stable.

I’m a private pilot and have a wee situational awareness app that I’m wanting to extend with more navigational and synthetic vision tools. A virtual globe seemed like a good way to get that, and yours is the best in town as far as I can tell.

Regards,

Ryan

Ryan,

Ah, I noticed some OpenGlobe references in your code. That makes sense now. Working off of Cesium is definitionally the right direction as Kevin and I are both working on Cesium, not OpenGlobe. OpenGlobe remains a much smaller engine good for learning.

As for automated tools, this is not really my area, but I think it is worth looking into as conversion tools exist between lots of languages.

Again, good luck with this and please keep us in the loop about your progress. We’re happy to help promote your work.

Patrick

Yeah I didn’t find Cesium until after I’d started a few experiments from the book. The architecture is very clear which is helpful, although I was slightly confused at first until I realised the globe was being ray-traced rather than tessellated.

Do you have any idea on how raytracing performance would compare with tessellation on portable-class hardware? I’m targeting an iPad Air currently on iOS 7/GLES 2.0, largely just because that’s what I have available. I’ll run some experiments and see how fast the rendering is. Certainly Cesium is very quick on my desktop, but that’s with a GTX 760.

I’ve had a brief look at some of the porting work going on with LLVM/emscripten etc, but most of it is targeting LLVM bytecode as a common intermediate, which is not that helpful when trying to get code to port to the device. By hand I don’t think will go too badly once the renderer is complete.

Thanks again for your support, will definitely keep you posted.

Regards,

Ryan

Ryan,

I don’t know about the iPad Air GPU specifically, but ray casting the ellipsoid uses less bandwidth, which is good for power and performance, but it is probably insignificant in this case. In OpenGlobe, only the ellipsoid can be ray traced; in both Cesium and OpenGlobe, the terrain engine uses rasterization.

Patrick

Good to know, thanks Patrick. Hopefully I’ll find out soon!

A newbie question, have you looked into using CocoonJS? They claim to have an accelerated port of canvas and support for WebGL on iOS. I need to play a bit with it, but it looks like with the Cocoon launcher you can test it pretty much straight away http://support.ludei.com/hc/en-us/articles/201048463-How-to-use

Interested in knowing if anyone has tried this before.

Hi Thomas, I have just done a rapid test with Cocoonjs app launcher but unfortunately it doesn't work with Cesium :frowning:

Arturo

Ah, nevermind, thanks for checking. Any idea why it wouldn’t work?

No. When I try to launch http://cesiumjs.org/Cesium/Build/HelloWorld.html I got this error:
Javascript Exception (Line: 416 Tag:'script'): TypeError: 'null' is not an object (evaluating 'h.setAttribute')

Arturo

OS X 10.10 and iOS 8.0 Safari enable WebGL so I’m sure that Cesium will work on these platforms with a little debugging. I need a native Obj-C port for my project so that’s what I’m working on currently.

Regards,

Ryan

Sure. I understand. My requirements were more for mobile app support with older/current versions of iOS. That’s where I was coming from. Good luck with the port, sounds like a big job to me :wink:

Oh yup I see. I did have a brief look at some of the javascript wrapper frameworks. The most promising looked like Ejecta.js, which passed through WebGL to the underlying GLES 2.0 implementation, but would have required some modifications to the main Cesium object.

Anything which tries to run using the system WebView pre-iOS 8 will run afoul of the private WebGL implementation unfortunately. I’ve had a brief go with it on iOS 8 and basic globe rendering works with some bugs which I’m sure won’t be too hard to fix.

Tried with uploading and then testing, but I got teh same. Using Canvas/WebGL I have the message you mentioned. Using System WebView I get a Cesium message “The browser supports WebGL, but initialization failed”.

Hey Ryan and all,

Have you checked out http://mousebird.github.io/WhirlyGlobe/? I’ve been interested in an open source 3d map on iOS/Android as well and from using it last night it’s very performant on my iPad Air2 (it’s native). It isn’t as fully featured as Cesium but it’s got some a lot of core features like touch, locations, basic entities (markers, images, shapes), etc.

Minh

Hi Minh,

I have and in fact started my experimentation there, however Whirlyglobe has several limitations, most significant of which are that it uses a spheroid representation of the globe rather than a WGS84 ellipsoid, and has more limited terrain support, relying on an arbitrary format and limited picking support. I also had some issues with real time position updating, consequently it was of limited use for my project.

My iOS port currently has about 95% support for Bing Maps, I'm just working on a few remaining texture issues, and the recent 1.2 release of Swift threw a spanner in the works. Next priorities will be camera control, terrain (which should be pretty rapid as most of the architecture is already ported), then basic Entity support.

As always, thoughts and commits welcome!

Regards,

Ryan