I want to have an object displayed on a target, and when I touch the object I want to replace it with another object.
Seems simple enough. I create a Trackable2DObject with its drawable.cam set to be the first Model, and I add an onClick() handler that does a removeCamDrawable() and an addCamDrawable().
The result, however, is a bit strange. It displays the first object, but when I click on it, it simply disappears and the second object is nowhere to be seen. However, when I look away from the target and back again, the second object appears! It's almost as if the removeCamDrawable() worked, but the addCamDrawable() was somehow postponed.
My code is very short. Here it is:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta name="viewport" content="target-densitydpi=device-dpi, width=540, user-scalable=0" /> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
Both models will be added to the trackable2dobject during creation. One model is disabled (.enabled = false) so it won't be rendered. On a user click the first model is disabled and the second model enabled.
over 8 years ago
Thanks. I ended up doing something similar, and it works fine.