在谷歌地球中移动 3D 模型?
我正在使用 Google 地球 Web 插件 API,并且已经获得了直升机的 3D 模型,我可以使用以下代码创建 3D 模型:
var 地标 = ge.createPlacemark('');
placemark.setName('模型');
// 地标/模型(几何)
变量 model = ge.createModel('heli'); placemark.setGeometry(模型);
// 地标/模型/链接
变量链接 = ge.createLink('');
link.setHref('http://my.url/heli.dae');
model.setLink(链接);
// 地标/模型/位置
var loc = ge.createLocation('');
loc.setLatLngAlt(temp1,temp2,alt)
model.setLocation(loc);
model.setAltitudeMode(ge.ALTITUDE_RELATIVE_TO_GROUND);
// 将模型地标添加到地球
ge.getFeatures().appendChild(placemark);
所以每次新的经纬度坐标出现时我都会创建一个新模型,有没有一种方法可以简单地将 3d 模型移动到这些坐标而不是创建一个新模型,在大约 50 次渲染后,它变得没有响应!任何帮助将不胜感激
我假设我需要 getPlacemark 而不是 createPlacemark,但参考文献中没有提到这样的函数。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
无需每次都重新创建地标 - 只需更新其坐标即可。您可以轻松地使用函数来执行此操作。然后,每次您希望更新模型位置时,您都可以使用所需的坐标调用 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.
您会在侧栏中看到您的模型(在您重命名之前,它称为“无标题”) - 右键单击它 - 复制!然后在侧边栏中的同一位置粘贴。现在您会看到另一个“无标题”模型 - 重命名。
现在,前往地球上的任何地方,将视图置于您希望模型所在的位置(目前,请在非常靠近模型的位置执行此操作)。在 GE 菜单“编辑”中 - 按“复制视图位置”
现在,右键单击侧栏中复制的模型 - 属性。现在,将剪贴板中最后复制的视图位置粘贴到经度/纬度栏中。
现在您在不同位置有两个相同的模型。如果您取消选中任何模型,则可以隐藏它,反之亦然。
现在,正如我所看到的,GE 无法正常运行(至少我的不能正常运行),因为每次您双击模型时,它都应该带您到那里,但事实并非如此,解决方案 - 只需记录一个电影的第二个位置(您的模型所在的位置)并保存它 - 这样游览(您的位置)就会被保存,每次您双击保存的游览时,它都会带您到那里。
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.