onClick trigger not working for animated 3D model.
A
Ashif Shereef
started a topic
over 6 years ago
I have an animated 3D model at a geoLocation. Where do I declare the onClick?
(Wikitude documentation is confusing a bit because both of them seems to have their own "Onclick")
1. In the Model
2. In the GeoObject?
Since I am confused about which would the better optimized and efficient way. But either way, my click event is not working. It is printing the alert when I debug in browser, but NOT on phone.
The following is my model animation and click event.
var location = new AR.RelativeLocation(null, 90, 90, 40);
var indicatorImage = new AR.ImageResource("assets/indi.png");
var indicatorDrawable = new AR.ImageDrawable(indicatorImage, 0.1, {
verticalAnchor: AR.CONST.VERTICAL_ANCHOR.TOP
});
var modelCoin = new AR.Model("assets/coinqwerty.wt3", {
onLoaded:function() {
alert("loaded");
var obj = new AR.GeoObject(location, {
drawables: {
cam: [modelCoin],
indicator: [indicatorDrawable]
},
onEnterFieldOfVision: function() {
//dragonVisible = true;
//ajax here
//this.coinAnimation.start(-1);
},
onExitFieldOfVision: function() {
//dragonVisible = false;
//this.coinAnimation.stop();
}
});
},
onError: function(err) {
alert("error");
},
scale: {
x: 5,
y: 5,
z: 5
},
translate: {
x: 0,
y: 0,
z: 0
},
rotate: {
//heading: 180,
//tilt: -40
},
onClick: function() {
//console.log('clicked the dragon');
alert("coin clicked");
}
});
modelCoin.onInitialized =function()
{
alert("rendered");
var coinAnimation= new AR.ModelAnimation(modelCoin,ANIMATION_TO_LOOP);
//coinAnimation.start(-1);
setTimeout(function() {coinAnimation.start(-1); }, 500);
};
}
1 Comment
Wikitude Support
said
over 6 years ago
Hello Ashif,
Please read carefully the following examples as they explain in details what you want to accomplish with your use case:
Ashif Shereef
I have an animated 3D model at a geoLocation. Where do I declare the onClick? (Wikitude documentation is confusing a bit because both of them seems to have their own "Onclick")
1. In the Model
2. In the GeoObject?
Since I am confused about which would the better optimized and efficient way. But either way, my click event is not working. It is printing the alert when I debug in browser, but NOT on phone.
The following is my model animation and click event.