Moving 3D Models

778 views
Skip to first unread message

do...@isidorey.com

unread,
Jul 28, 2010, 4:20:45 PM7/28/10
to KML Developer Support - Google Earth Plug-in
Hi Everyone!

I'm using the Google Earth Web-plugin API and I've got a 3d model of a
helicopter, I can create a 3d model using the following code:

var placemark = ge.createPlacemark('');

placemark.setName('model');

// Placemark/Model (geometry)

var model = ge.createModel('heli'); placemark.setGeometry(model);

// Placemark/Model/Link

var link = ge.createLink('');

link.setHref('http://my.url/heli.dae');

model.setLink(link);

// Placemark/Model/Location

var loc = ge.createLocation('');

loc.setLatLngAlt(temp1,temp2,alt)

model.setLocation(loc);

model.setAltitudeMode(ge.ALTITUDE_RELATIVE_TO_GROUND);

// add the model placemark to Earth

ge.getFeatures().appendChild(placemark);

So I've been creating a new model everytime new lat long coordinates
come in, is there a way to simply move the 3d models to these
coordinates instead of creating a new one, after about 50 renders, it
becomes unresponsive! Any help would be appreciated

I assume that instead of createPlacemark I need to getPlacemark, but
there's no mention of such a function in the reference.

Please dont say look at this milk truck example! I've looked over it
the past couple days and I can't seem to make it translate to the way
im working with this model.

Thank you

Nymor

unread,
Jul 28, 2010, 5:19:41 PM7/28/10
to KML Developer Support - Google Earth Plug-in
Hi,

I've got an example (quite old but still works) at
http://www.thekmz.co.uk/GEPlugin/pathtour/v3/path_tour_v3.htm

That moves a model around and the bit in the code that does that is my
TourSimulator.prototype.moveModel_ function of which
this.model.getLocation().setLatLngAlt(loc.lat(), loc.lng(), 0);
is the part that moves the model without the need to re-render -
obviously you'll have to change slightly the way that works so it
suits your objects but the model.getLocation().setLatLngAlt() is key.

Hope that helps.

Regards
Nymor

shsavage

unread,
Jul 29, 2010, 10:07:07 AM7/29/10
to KML Developer Support - Google Earth Plug-in
Hi Doug,

See my Drive the Solar System webpage at http://gaialab.asu.edu/SolarSystem
for an example of moving models. On the page, the user can drop a
Mars rover at any point on the surface, then drive it using a set of
button controls.

-Steve

Greg-WBSR

unread,
Aug 6, 2010, 8:54:05 PM8/6/10
to KML Developer Support - Google Earth Plug-in
Hi Doug,

The above answers are good examples and I thank both of those guys a
lot for helping me out over the last year or so.

However, they developed that stuff on older versions of the GE plugin
- the new version supports a 'feature' called 'Tracks' which allows
you to move a model along a pre-set linestring.

here is the reference for it
http://code.google.com/apis/kml/documentation/kmlreference.html#gxtrack

All you need to do is reference a <model> in the kml and it will
replace the 'placemark icon' as the item moving along the 'track'

It is a little bit overwhelming at first dealing with editing the kml,
but once I got it sorted out I like it - plus it saves having to deal
with the extra code used by Nymor and shsavage.
And it should be easier to manage as future versions of the plugin get
released.

If you are having troubles, reply back to me somehow and I can make up
a demo for you - right now I don't have one set up.

Cheers
Greg

On Jul 29, 7:07 am, shsavage wrote:
> Hi Doug,
>
>    See my Drive the Solar System webpage athttp://gaialab.asu.edu/SolarSystem
Reply all
Reply to author
Forward
0 new messages