Registered Component click event in Aframe Version 0.8.2 and master isn't working












0














I was using this exact code in the previous version of Aframe 0.8.0 And the clicking was working normally.
However, when I tried using the 0.8.2 or the master version it showed no signs of clicking and without showing any errors



This is my registered component which I would like to detect clicks on the entities it is attached to



 AFRAME.registerComponent('change-color-on-hover', { 
init: function () {
var data = this.data;
var el = this.el; // <a-box>
var defaultColor = el.getAttribute('material').color;
/**
* Attach 'click' event
*/
el.addEventListener('click', function () {
alert('clicked');
});
}});


The Element where I want to detect the click (I am setting its position later and they it's appearing where they should be)



  <a-image position="" src="#blue_target_rendered" height="30" width="40" depth="1" shadow event-set__click="_event: click; color:black" change-color-on-hover look-at="[camera]"  id="hotspot-{{$hotspot->id}}" data-link-to="{{$hotspot->link_to}}" data-link-from="{{$hotspot->link_from}}">









share|improve this question
























  • on 0.8.2 both 'click' and 'event-set' events are working properly, fiddle here. How is your cursor set ?
    – Piotr Adam Milewski
    Nov 23 '18 at 14:43










  • Weird becauses i didnt change any code from the working one on previous version : This is my camera + cursor <a-entity id="cameraParent" position="0 0 0" > <a-entity id="cam" camera="zoom:1;" look-controls collider-check position="0 0 0" > <a-entity cursor=" rayOrigin: mouse" geometry="primitive: ring; radiusInner: 0; radiusOuter: 0" material="color: black; shader: flat"></a-entity> <a-entity raycaster="showLine:false; far: 1000" line="color:orange; opacity:1" ></a-entity> </a-entity> </a-entity>
    – Sandy Al Akhras
    Nov 23 '18 at 14:52












  • I think i've overreacted a bit with the issue, check out my updated anwser :D also commented on the issue.
    – Piotr Adam Milewski
    Nov 23 '18 at 16:55
















0














I was using this exact code in the previous version of Aframe 0.8.0 And the clicking was working normally.
However, when I tried using the 0.8.2 or the master version it showed no signs of clicking and without showing any errors



This is my registered component which I would like to detect clicks on the entities it is attached to



 AFRAME.registerComponent('change-color-on-hover', { 
init: function () {
var data = this.data;
var el = this.el; // <a-box>
var defaultColor = el.getAttribute('material').color;
/**
* Attach 'click' event
*/
el.addEventListener('click', function () {
alert('clicked');
});
}});


The Element where I want to detect the click (I am setting its position later and they it's appearing where they should be)



  <a-image position="" src="#blue_target_rendered" height="30" width="40" depth="1" shadow event-set__click="_event: click; color:black" change-color-on-hover look-at="[camera]"  id="hotspot-{{$hotspot->id}}" data-link-to="{{$hotspot->link_to}}" data-link-from="{{$hotspot->link_from}}">









share|improve this question
























  • on 0.8.2 both 'click' and 'event-set' events are working properly, fiddle here. How is your cursor set ?
    – Piotr Adam Milewski
    Nov 23 '18 at 14:43










  • Weird becauses i didnt change any code from the working one on previous version : This is my camera + cursor <a-entity id="cameraParent" position="0 0 0" > <a-entity id="cam" camera="zoom:1;" look-controls collider-check position="0 0 0" > <a-entity cursor=" rayOrigin: mouse" geometry="primitive: ring; radiusInner: 0; radiusOuter: 0" material="color: black; shader: flat"></a-entity> <a-entity raycaster="showLine:false; far: 1000" line="color:orange; opacity:1" ></a-entity> </a-entity> </a-entity>
    – Sandy Al Akhras
    Nov 23 '18 at 14:52












  • I think i've overreacted a bit with the issue, check out my updated anwser :D also commented on the issue.
    – Piotr Adam Milewski
    Nov 23 '18 at 16:55














0












0








0







I was using this exact code in the previous version of Aframe 0.8.0 And the clicking was working normally.
However, when I tried using the 0.8.2 or the master version it showed no signs of clicking and without showing any errors



This is my registered component which I would like to detect clicks on the entities it is attached to



 AFRAME.registerComponent('change-color-on-hover', { 
init: function () {
var data = this.data;
var el = this.el; // <a-box>
var defaultColor = el.getAttribute('material').color;
/**
* Attach 'click' event
*/
el.addEventListener('click', function () {
alert('clicked');
});
}});


The Element where I want to detect the click (I am setting its position later and they it's appearing where they should be)



  <a-image position="" src="#blue_target_rendered" height="30" width="40" depth="1" shadow event-set__click="_event: click; color:black" change-color-on-hover look-at="[camera]"  id="hotspot-{{$hotspot->id}}" data-link-to="{{$hotspot->link_to}}" data-link-from="{{$hotspot->link_from}}">









share|improve this question















I was using this exact code in the previous version of Aframe 0.8.0 And the clicking was working normally.
However, when I tried using the 0.8.2 or the master version it showed no signs of clicking and without showing any errors



This is my registered component which I would like to detect clicks on the entities it is attached to



 AFRAME.registerComponent('change-color-on-hover', { 
init: function () {
var data = this.data;
var el = this.el; // <a-box>
var defaultColor = el.getAttribute('material').color;
/**
* Attach 'click' event
*/
el.addEventListener('click', function () {
alert('clicked');
});
}});


The Element where I want to detect the click (I am setting its position later and they it's appearing where they should be)



  <a-image position="" src="#blue_target_rendered" height="30" width="40" depth="1" shadow event-set__click="_event: click; color:black" change-color-on-hover look-at="[camera]"  id="hotspot-{{$hotspot->id}}" data-link-to="{{$hotspot->link_to}}" data-link-from="{{$hotspot->link_from}}">






javascript aframe






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 14:05

























asked Nov 23 '18 at 13:32









Sandy Al Akhras

356




356












  • on 0.8.2 both 'click' and 'event-set' events are working properly, fiddle here. How is your cursor set ?
    – Piotr Adam Milewski
    Nov 23 '18 at 14:43










  • Weird becauses i didnt change any code from the working one on previous version : This is my camera + cursor <a-entity id="cameraParent" position="0 0 0" > <a-entity id="cam" camera="zoom:1;" look-controls collider-check position="0 0 0" > <a-entity cursor=" rayOrigin: mouse" geometry="primitive: ring; radiusInner: 0; radiusOuter: 0" material="color: black; shader: flat"></a-entity> <a-entity raycaster="showLine:false; far: 1000" line="color:orange; opacity:1" ></a-entity> </a-entity> </a-entity>
    – Sandy Al Akhras
    Nov 23 '18 at 14:52












  • I think i've overreacted a bit with the issue, check out my updated anwser :D also commented on the issue.
    – Piotr Adam Milewski
    Nov 23 '18 at 16:55


















  • on 0.8.2 both 'click' and 'event-set' events are working properly, fiddle here. How is your cursor set ?
    – Piotr Adam Milewski
    Nov 23 '18 at 14:43










  • Weird becauses i didnt change any code from the working one on previous version : This is my camera + cursor <a-entity id="cameraParent" position="0 0 0" > <a-entity id="cam" camera="zoom:1;" look-controls collider-check position="0 0 0" > <a-entity cursor=" rayOrigin: mouse" geometry="primitive: ring; radiusInner: 0; radiusOuter: 0" material="color: black; shader: flat"></a-entity> <a-entity raycaster="showLine:false; far: 1000" line="color:orange; opacity:1" ></a-entity> </a-entity> </a-entity>
    – Sandy Al Akhras
    Nov 23 '18 at 14:52












  • I think i've overreacted a bit with the issue, check out my updated anwser :D also commented on the issue.
    – Piotr Adam Milewski
    Nov 23 '18 at 16:55
















on 0.8.2 both 'click' and 'event-set' events are working properly, fiddle here. How is your cursor set ?
– Piotr Adam Milewski
Nov 23 '18 at 14:43




on 0.8.2 both 'click' and 'event-set' events are working properly, fiddle here. How is your cursor set ?
– Piotr Adam Milewski
Nov 23 '18 at 14:43












Weird becauses i didnt change any code from the working one on previous version : This is my camera + cursor <a-entity id="cameraParent" position="0 0 0" > <a-entity id="cam" camera="zoom:1;" look-controls collider-check position="0 0 0" > <a-entity cursor=" rayOrigin: mouse" geometry="primitive: ring; radiusInner: 0; radiusOuter: 0" material="color: black; shader: flat"></a-entity> <a-entity raycaster="showLine:false; far: 1000" line="color:orange; opacity:1" ></a-entity> </a-entity> </a-entity>
– Sandy Al Akhras
Nov 23 '18 at 14:52






Weird becauses i didnt change any code from the working one on previous version : This is my camera + cursor <a-entity id="cameraParent" position="0 0 0" > <a-entity id="cam" camera="zoom:1;" look-controls collider-check position="0 0 0" > <a-entity cursor=" rayOrigin: mouse" geometry="primitive: ring; radiusInner: 0; radiusOuter: 0" material="color: black; shader: flat"></a-entity> <a-entity raycaster="showLine:false; far: 1000" line="color:orange; opacity:1" ></a-entity> </a-entity> </a-entity>
– Sandy Al Akhras
Nov 23 '18 at 14:52














I think i've overreacted a bit with the issue, check out my updated anwser :D also commented on the issue.
– Piotr Adam Milewski
Nov 23 '18 at 16:55




I think i've overreacted a bit with the issue, check out my updated anwser :D also commented on the issue.
– Piotr Adam Milewski
Nov 23 '18 at 16:55












1 Answer
1






active

oldest

votes


















1














With a setup like this:



<a-entity id="cameraParent" position="0 0 0" > 
<a-entity id="cam" camera="zoom:1;" look-controls collider-check position="0 0 0" >
<a-entity cursor=" rayOrigin: mouse" geometry="primitive: ring; radiusInner: 0; radiusOuter: 0" material="color: black; shader: flat"></a-entity>
<a-entity raycaster="showLine: true; far: 1000"></a-entity>
</a-entity>
</a-entity>


The line component created by the raycaster is interfering with the rays emitted by the cursor = rayOrigin: mouse. In other words, you're clicking on the element with the line on each click.



If you reposition the raycaster a bit:



<a-entity position="0 -0.1 0" raycaster="showLine:true; far: 1000"></a-entity>


The mouse cursor should be working fine.






share|improve this answer























  • Although i understand and agree with the suggested logic something very weird is happening after i implement the position change of the ray caster: if i put show line =true it catches intersections and disables clicking. if i put show line=false or it does vise versa but i cant see to make the two work
    – Sandy Al Akhras
    Nov 26 '18 at 15:01










  • @SandyAlAkhras seems to be working jsfiddle.net/8bt6cs9d
    – Piotr Adam Milewski
    Nov 26 '18 at 16:33











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53447669%2fregistered-component-click-event-in-aframe-version-0-8-2-and-master-isnt-workin%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














With a setup like this:



<a-entity id="cameraParent" position="0 0 0" > 
<a-entity id="cam" camera="zoom:1;" look-controls collider-check position="0 0 0" >
<a-entity cursor=" rayOrigin: mouse" geometry="primitive: ring; radiusInner: 0; radiusOuter: 0" material="color: black; shader: flat"></a-entity>
<a-entity raycaster="showLine: true; far: 1000"></a-entity>
</a-entity>
</a-entity>


The line component created by the raycaster is interfering with the rays emitted by the cursor = rayOrigin: mouse. In other words, you're clicking on the element with the line on each click.



If you reposition the raycaster a bit:



<a-entity position="0 -0.1 0" raycaster="showLine:true; far: 1000"></a-entity>


The mouse cursor should be working fine.






share|improve this answer























  • Although i understand and agree with the suggested logic something very weird is happening after i implement the position change of the ray caster: if i put show line =true it catches intersections and disables clicking. if i put show line=false or it does vise versa but i cant see to make the two work
    – Sandy Al Akhras
    Nov 26 '18 at 15:01










  • @SandyAlAkhras seems to be working jsfiddle.net/8bt6cs9d
    – Piotr Adam Milewski
    Nov 26 '18 at 16:33
















1














With a setup like this:



<a-entity id="cameraParent" position="0 0 0" > 
<a-entity id="cam" camera="zoom:1;" look-controls collider-check position="0 0 0" >
<a-entity cursor=" rayOrigin: mouse" geometry="primitive: ring; radiusInner: 0; radiusOuter: 0" material="color: black; shader: flat"></a-entity>
<a-entity raycaster="showLine: true; far: 1000"></a-entity>
</a-entity>
</a-entity>


The line component created by the raycaster is interfering with the rays emitted by the cursor = rayOrigin: mouse. In other words, you're clicking on the element with the line on each click.



If you reposition the raycaster a bit:



<a-entity position="0 -0.1 0" raycaster="showLine:true; far: 1000"></a-entity>


The mouse cursor should be working fine.






share|improve this answer























  • Although i understand and agree with the suggested logic something very weird is happening after i implement the position change of the ray caster: if i put show line =true it catches intersections and disables clicking. if i put show line=false or it does vise versa but i cant see to make the two work
    – Sandy Al Akhras
    Nov 26 '18 at 15:01










  • @SandyAlAkhras seems to be working jsfiddle.net/8bt6cs9d
    – Piotr Adam Milewski
    Nov 26 '18 at 16:33














1












1








1






With a setup like this:



<a-entity id="cameraParent" position="0 0 0" > 
<a-entity id="cam" camera="zoom:1;" look-controls collider-check position="0 0 0" >
<a-entity cursor=" rayOrigin: mouse" geometry="primitive: ring; radiusInner: 0; radiusOuter: 0" material="color: black; shader: flat"></a-entity>
<a-entity raycaster="showLine: true; far: 1000"></a-entity>
</a-entity>
</a-entity>


The line component created by the raycaster is interfering with the rays emitted by the cursor = rayOrigin: mouse. In other words, you're clicking on the element with the line on each click.



If you reposition the raycaster a bit:



<a-entity position="0 -0.1 0" raycaster="showLine:true; far: 1000"></a-entity>


The mouse cursor should be working fine.






share|improve this answer














With a setup like this:



<a-entity id="cameraParent" position="0 0 0" > 
<a-entity id="cam" camera="zoom:1;" look-controls collider-check position="0 0 0" >
<a-entity cursor=" rayOrigin: mouse" geometry="primitive: ring; radiusInner: 0; radiusOuter: 0" material="color: black; shader: flat"></a-entity>
<a-entity raycaster="showLine: true; far: 1000"></a-entity>
</a-entity>
</a-entity>


The line component created by the raycaster is interfering with the rays emitted by the cursor = rayOrigin: mouse. In other words, you're clicking on the element with the line on each click.



If you reposition the raycaster a bit:



<a-entity position="0 -0.1 0" raycaster="showLine:true; far: 1000"></a-entity>


The mouse cursor should be working fine.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 23 '18 at 17:34

























answered Nov 23 '18 at 15:23









Piotr Adam Milewski

5,31221025




5,31221025












  • Although i understand and agree with the suggested logic something very weird is happening after i implement the position change of the ray caster: if i put show line =true it catches intersections and disables clicking. if i put show line=false or it does vise versa but i cant see to make the two work
    – Sandy Al Akhras
    Nov 26 '18 at 15:01










  • @SandyAlAkhras seems to be working jsfiddle.net/8bt6cs9d
    – Piotr Adam Milewski
    Nov 26 '18 at 16:33


















  • Although i understand and agree with the suggested logic something very weird is happening after i implement the position change of the ray caster: if i put show line =true it catches intersections and disables clicking. if i put show line=false or it does vise versa but i cant see to make the two work
    – Sandy Al Akhras
    Nov 26 '18 at 15:01










  • @SandyAlAkhras seems to be working jsfiddle.net/8bt6cs9d
    – Piotr Adam Milewski
    Nov 26 '18 at 16:33
















Although i understand and agree with the suggested logic something very weird is happening after i implement the position change of the ray caster: if i put show line =true it catches intersections and disables clicking. if i put show line=false or it does vise versa but i cant see to make the two work
– Sandy Al Akhras
Nov 26 '18 at 15:01




Although i understand and agree with the suggested logic something very weird is happening after i implement the position change of the ray caster: if i put show line =true it catches intersections and disables clicking. if i put show line=false or it does vise versa but i cant see to make the two work
– Sandy Al Akhras
Nov 26 '18 at 15:01












@SandyAlAkhras seems to be working jsfiddle.net/8bt6cs9d
– Piotr Adam Milewski
Nov 26 '18 at 16:33




@SandyAlAkhras seems to be working jsfiddle.net/8bt6cs9d
– Piotr Adam Milewski
Nov 26 '18 at 16:33


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53447669%2fregistered-component-click-event-in-aframe-version-0-8-2-and-master-isnt-workin%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Contact image not getting when fetch all contact list from iPhone by CNContact

count number of partitions of a set with n elements into k subsets

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks