Sorry, this will not work. There are several issues in this snippet, it is invalid JavaScript. You cannot use new World() when World is not a function (see my example in the previous post).
And you need to remember that
geoObject.drawables.addCamDrawable
is a function. You should not override it with
geoObject.drawables.addCamDrawable = this.model;
but instead must use
geoObject.drawables.addCamDrawable(this.model);
So, your best bet is to use the snippet I have provided, and then modify the onLoaded function of the Model as you did in your post.
Please also use the ADE and always check the developer console in your browser before asking for help with the code. The Browser will tell you if the JavaScript is valid or not. In your case with the previous snippet, the Browser immediately tells you that there is something wrong in the JavaScript. It tells you:
TypeError: object is not a function
because you used new World(), but World is a plain JavaScript object, not a function.
Best,
Martin
L
Luca
said
over 9 years ago
Ok, now I changed the code like below, but it doesn't show anything focusing the camera on defined geolocation (you have not to look at locationChanged that it is, in this case, useless):
var World =
{
location : new AR.GeoLocation(41.773046, 12.237229, 3.0),
initiallyLoaded : false,
model : new AR.Model("3d/car.wt3", {
onLoaded: function()
{
geoObject = new AR.GeoObject(this.location);
geoObject.drawables.addCamDrawable = this.model;
}
}),
locationChanged: function locationChangedFn(lat, lon, alt, acc)
Luca