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]
- 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!