I am developing a game on A-frame. In my game I need to make a shooting effect for which I am using a gun model and placing it behind the cursor, coded the click event so that an object will relocate in front of the gun and goes the direction of the cursor.
I am using setAttribute and requestAnimationFrame :-
renderObj: function(obj){
window.requestAnimationFrame(function() {
renderObj(obj);
});
}
to create the animation effect of bullet moving in a particular direction.
when the function calls itself again I am not able to retrieve the location of the object set by setAttribute using
var objWorldPos = new THREE.Vector3();
objWorldPos.setFromMatrixPosition(obj.object3D.matrixWorld);
whenever I change the position using setAttribute I am also updating the attribute in the bullet tag by obj.attributes.position="x y z"; i know this is not the best practice as I should be able to recover the position so is there a way I can set the position of the element using three.js and the retrieve it using THREE.Vector3()'s object3D.matrixWorld method...
Any help will be appreciated thanks a ton!