移动3D模型在谷歌地球? [英] Moving 3d Model in google earth?
问题描述
我使用谷歌地球网络插件API和我有一个直升机的3D模型,我可以使用下面的code创建3D模型:
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标=
ge.createPlacemark('');
var placemark = ge.createPlacemark('');
placemark.setName('模型');
placemark.setName('model');
//标/模型(几何)
// Placemark/Model (geometry)
无功
模型= ge.createModel('合力');
placemark.setGeometry(模型);
var model = ge.createModel('heli'); placemark.setGeometry(model);
//标/型号/链接
VAR链接=
ge.createLink('');
var link = ge.createLink('');
link.setHref('HTTP://my.url/heli.dae');
link.setHref('http://my.url/heli.dae');
model.setLink(链接);
model.setLink(link);
//标/型号/位置
变种LOC =
ge.createLocation('');
var loc = ge.createLocation('');
loc.setLatLngAlt(temp1中,TEMP2,ALT)
loc.setLatLngAlt(temp1,temp2,alt)
model.setLocation(LOC);
model.setLocation(loc);
model.setAltitudeMode(ge.ALTITUDE_RELATIVE_TO_GROUND);
model.setAltitudeMode(ge.ALTITUDE_RELATIVE_TO_GROUND);
//添加模型标地球
ge.getFeatures()的appendChild(标);
ge.getFeatures().appendChild(placemark);
所以,我一直在创造一种新的模式,每次新的经纬度座标来了,有没有办法简单地将3D模型移到这些坐标,而不是创建一个新的,约50渲染之后,就变得没有反应!任何帮助将是AP preciated
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
我认为不是createPlacemark我需要getPlacemark,但有没有这样的功能提到的参考。
I assume that instead of createPlacemark I need to getPlacemark, but there's no mention of such a function in the reference.
推荐答案
而不是每次都重新地标 - 简单地更新它的坐标。你可以很容易地使用一个函数来做到这一点。然后,您可以每次你要更新的车型定位时间只需调用函数moveModel与所需的坐标。
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);
}
这篇关于移动3D模型在谷歌地球?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!