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?