开发者

Moving 3d Model in google earth?

开发者 https://www.devze.com 2023-01-09 01:46 出处:网络
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:

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 c开发者_StackOverflow中文版reatePlacemark I need to getPlacemark, but there's no mention of such a function in the reference.


Rather than recreating the placemark each time - simply update its coordinates. You could easily use a function to do this. You could then simply call the moveModel function with the desired coordinates every time you wish to update the models position.

var placemark = ge.createPlacemark('');
var model = ge.createModel('heli'); 
var link = ge.createLink('');

placemark.setName('model');
placemark.setGeometry(model);
link.setHref('http://my.url/heli.dae');
model.setLink(link);

moveModel(temp1, temp2, alt); // your location...

ge.getFeatures().appendChild(placemark);

function moveModel(temp1, temp2, alt) {
  var loc = ge.createLocation('');
  loc.setLatLngAlt(temp1,temp2,alt)
  model.setLocation(loc);
  model.setAltitudeMode(ge.ALTITUDE_RELATIVE_TO_GROUND);
}


You see your model in a side bar (its called "Untitled" until you rename it) - right click on it - copy! Then at the same place in side bar just paste. Now you see another "Untitled" model - rename it.

Now go to any place on earth and center your view where you want your model to be (for now, do this very close to your model). Up in GE menu "Edit"- press "copy view location"

Now, go and right click your copied model in a side bar - properties. Now, paste last copied view location from the clipboard in longitude/latitude bar. Now you have two same models on a different location. You can hide any model if you uncheck it, and vise versa.

Now, as I can see, GE is not functioning right (at least mine doesnt), because each time you double-click the model it should take you there,but it doesnt, Solution - just record a second of movie from that location(Where your model is) and save it- this way tour (your location) is saved and each time you double-click the saved tour it will take you there.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号