/* Disable all sensors in "IR-only" Worlds to save performance. If the property is set to true, any geo-related components (such as GeoObjects and ActionRanges) are active. If the property is set to false, any geo-related components will not be visible on the screen, and triggers will not fire.*/
AR.context.services.sensors = false;
this.createOverlays();
},
createOverlays: function createOverlaysFn() {
// Initialize Tracker
this.tracker = new AR.Tracker("assets/tracker.wtc", {
onLoaded: this.loadingStep
});
this.modelCar = new AR.Model("assets/car.wt3", {
onLoaded: this.loadingStep,
onClick: this.toggleAnimateModel,
scale: {
x: 0.0,
y: 0.0,
z: 0.0
},
translate: {
x: 0.0,
y: 0.05,
z: 0.0
},
rotate: {
roll: -25
}
});
// instantiate the model object
//var model = new AR.Model("assets/boss.wt3");
// instantiate the model animation with the animation id
//var animation = new AR.ModelAnimation(model, "pPlane4_animation");
createAppearingAnimation: function createAppearingAnimationFn(model, scale) {
var sx = new AR.PropertyAnimation(model, "scale.x", 0, scale, 1500, {
type: AR.CONST.EASING_CURVE_TYPE.EASE_OUT_ELASTIC
});
var sy = new AR.PropertyAnimation(model, "scale.y", 0, scale, 1500, {
type: AR.CONST.EASING_CURVE_TYPE.EASE_OUT_ELASTIC
});
var sz = new AR.PropertyAnimation(model, "scale.z", 0, scale, 1500, {
type: AR.CONST.EASING_CURVE_TYPE.EASE_OUT_ELASTIC
});
return new AR.AnimationGroup(AR.CONST.ANIMATION_GROUP_TYPE.PARALLEL, );
},
appear: function appearFn() {
World.resetModel();
World.appearingAnimation.start();
},
resetModel: function resetModelFn() {
World.rotationAnimation.stop();
World.rotating = false;
World.modelCar.rotate.roll = -25;
},
toggleAnimateModel: function toggleAnimateModelFn() {
var sound = new AR.Sound("assets/car-ignition-3.mp3");
if (!World.rotationAnimation.isRunning()) {
if (!World.rotating) {
World.rotationAnimation.start(-1);
World.rotating = true;
sound.play();
//alert("SOund played");
//sound.resume();
//alert("Sound Resume");
} else {
World.rotationAnimation.resume();
sound.stop();
}
} else {
World.rotationAnimation.pause();
sound.stop();
}
return false;
}
};
World.init();
Thanks in advance.
P
Pallavi Pawar
said
over 9 years ago
i m using Phonegap plugin.it starts playing the sound but dont stop
P
Pallavi Pawar
said
over 9 years ago
If any one have the Solution please provide it.
Thanks
W
Wolfgang Damm
said
over 9 years ago
From a quick look at it it seems you are creating a AR.Sound each time the toggle function is called. This means that by the time you call .stop() a new sound object has been created. Since you don't keep a reference to the original there is no way to call .stop on it.
I suggest to move the creation of the Sound object to createOverlays function.
P
Pallavi Pawar
said
over 9 years ago
I created AR.Sound object in createOverlays function and called sound.play() in toggle function
its giving error like
03-28 09:57:15.902: E/Web Console(31492): Uncaught ReferenceError: sound is not defined at file:///android_asset/www/world/2_3dAndImageRecognition_3_Interactivity/js/imagerecognitionand3d.js:127
Kindly help
Thanks
W
Wolfgang Damm
said
over 9 years ago
Please use the ADE included with the SDK Package (ade.js) to run your world inside a desktop browser. This allwos you to debug such javascript errors more easily. My guess here is that 'sound' is declared with in the createOverlays function and therefore is not known in the toggleAnimateModel function.
P
Pallavi Pawar
said
over 9 years ago
ADE is already included den also the toggle function is not geting the ar.sound object.Kinsly help me
Thank you
W
Wolfgang Damm
said
over 9 years ago
Did you run it inside a desktop browser and used the debugging tools available there to fix any javascript errors?
P
Pallavi Pawar
said
over 9 years ago
i tried running it inside a desktop browser but its just showing me main index.html page and on click of any sample its not opening the camera to scan the marker.Kindly help me
Thank you
W
Wolfgang Damm
said
over 9 years ago
The ADE is just a debugging environment for your javascript code. It allows to use all AR.xyz functions but does not render an AR scene. However there is a text based representation of all the objects you created and you have the possiblity to call triggers by clicking on an object's trigger function. To get to this text based representation click the triangle in the bottom right corner.
Pallavi Pawar