我想用 API 和谷歌插件在谷歌地球环境中表示 3D 模型。
我有代码:
var ge;
google.load("earth", "1");
function init() {
google.earth.createInstance('map3d', initCB, failureCB);
}
function initCB(instance) {
ge = instance;
ge.getWindow().setVisibility(true);
ge.getNavigationControl().setVisibility(ge.VISIBILITY_HIDE);
// Placemark
var placemark = ge.createPlacemark('Modello1');
placemark.setName('model');
var place2 = ge.createPlacemark('Modello2');
place2.setName('modello2');
// Placemark/Model (geometry)
var model = ge.createModel('Mod1');
placemark.setGeometry(model);
var modello2 = ge.createModel('Mod2');
place2.setGeometry(modello2);
// Placemark/Model/Link
var link = ge.createLink('File1');
link.setHref("http://myhost.org/table2/models/table2.dae");
model.setLink(link);
var link2 = ge.createLink('File2');
link2.setHref("http://myhost.org/tavolo/models/table2.dae");
modello2.setLink(link2);
// get center look at location
var lookAt = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
// Placemark/Model/Location
var loc = ge.createLocation('');
loc.setLatitude(40.01000594412381);
loc.setLongitude(-105.2727379358738);
model.setLocation(loc);
//slightly varying coordinates...
var loc2 = ge.createLocation('');
loc2.setLatitude(40.01000594412389);
loc2.setLongitude(-105.2727379358731);
modello2.setLocation(loc2);
// add the model placemark to Earth
ge.getFeatures().appendChild(placemark);
ge.getFeatures().appendChild(place2);
// zoom into the model
lookAt.setLatitude(40.01000594412381);
lookAt.setLongitude(-105.2727379358738);
lookAt.setRange(300);
lookAt.setTilt(80);
ge.getView().setAbstractView(lookAt);
}
function failureCB(errorCode) {
}
google.setOnLoadCallback(init);
当我加载不同的 collada (.dae) 文件时,不会出现任何问题......但它不会加载相同的表 2 次!为什么?!?
我也尝试过分离实例和文件......但问题仍然存在。我的环境中只有一张桌子。
有没有办法将单个模型克隆成 N 个模型?