Issue with Plane Click Interaction in A-Frame Component

Hello,

I’m trying to implement a clickable plane in my 8th Wall project that opens a URL when clicked. While the component initializes correctly, the click interaction isn’t working as expected.

Here’s my setup:

  • Component implementation (components.js):

[code]const planeLinkComponent = {

schema: {

url: {type: ā€˜string’, default: ā€˜https://facebook.com’}

},

init: function() {

console.log(ā€˜Plane link component initialized’);

const {object3D} = this.el;

object3D.visible = true;

this.el.setAttribute(ā€˜material’, {

color: ā€˜#FFFFFF’,

shader: ā€˜standard’,

transparent: true,

opacity: 0.9

});

const textEntity = document.createElement(ā€˜a-entity’);

textEntity.setAttribute(ā€˜text’, {

value: ā€˜Click to visit website’,

align: ā€˜center’,

width: 2,

color: ā€˜#000000’

});

textEntity.setAttribute(ā€˜position’, ā€˜0 0 0.01’);

textEntity.setAttribute(ā€˜rotation’, ā€˜90 0 0’);

this.el.appendChild(textEntity);

this.el.setAttribute(ā€˜class’, ā€˜cantap clickable’);

const handleClick = () => {

console.log(ā€˜Click detected’);

try {

window.open(this.data.url, ā€˜blank’);

} catch (error) {

console.error(ā€˜Failed to open URL:’, error);

}

};

this.el.addEventListener(ā€˜click’, handleClick);

}

};[/code]

  • Scene setup in body.html:

[code]<a-scene

xrextras-gesture-detector

xrextras-loading

xrextras-runtime-error

cursor-raycast

renderer=ā€œcolorManagement: trueā€

xrweb=ā€œallowedDevices: anyā€>

<a-camera

id=ā€œcameraā€

position=ā€œ0 1.75 4ā€

raycaster=ā€œobjects: .clickable; far: 100; interval: 100ā€

cursor=ā€œfuse: false; rayOrigin: mouseā€>

<a-plane

id=ā€œplane1ā€

class=ā€œclickableā€

position=ā€œ0 0 0ā€

rotation=ā€œ-90 0 0ā€

width=ā€œ1ā€

height=ā€œ1ā€

material=ā€œshader: standard; color: #FFFFFF; transparent: true; opacity: 0.9ā€

plane-link=ā€œurl: https://facebook.comā€>

[/code]

  1. Component registration in app.js:

[code]window.addEventListener(ā€˜load’, () => {

if (window.AFRAME) {

console.log(ā€˜AFRAME found, registering component’)

AFRAME.registerComponent(ā€˜plane-link’, planeLinkComponent)

}

})

window.addEventListener(ā€˜xrloaded’, () => {

console.log(ā€˜XR8 is ready’)

})[/code]

Current Behavior:

[list]

The plane and text render correctly

The component initializes (confirmed via console logs)

Click/tap events are not being detected

Getting AudioContext warning in console

[/list]

What I’ve Tried:

[list]

Added cantap and clickable classes

Implemented both click and touch event listeners

Verified raycaster configuration

Simplified material settings

[/list]

Questions:

[list=1]

Is there a specific way to handle click events in 8th Wall that I’m missing?

Should I be using a different approach for URL opening in WebXR?

Is the AudioContext warning related to the interaction issues?

[/list]

Any guidance would be greatly appreciated!

this.el.setAttribute(ā€˜class’, ā€˜cantap clickable’);

i think you must
this.el.setAttribute(ā€˜class’,ā€˜.clickable’)
or
this.el.setAttribute(ā€˜class’,ā€˜clickable’)

[quote]Thanks for the suggestion! However, the current syntax ā€˜cantap clickable’ is correct for adding multiple classes. The dot prefix (.) is only used in CSS selectors and raycaster queries, not when setting class names.

We need both classes:

  • cantap for 8th Wall’s touch handling

  • clickable for the raycaster

Using setAttribute(ā€˜class’,ā€˜.clickable’) would actually create an invalid class name with a dot in it.[/quote]

Here’s a sample project that creates a clickable plane: Call to Action Link | 8th Wall Playground | 8th Wall

I already cloned it and it didn’t work. My initial code was based on it, then I tried to do some modifications. But couldn’t get the planes to become clickable.

Strange, I just tested the sample project on my device and it worked. When you cloned it what did you change?