I’ve applied ctx to all the side of BoxGeometry .furthermore, I’m using raycaster to get the data present on ctx so that onclick it gives x,y co-ordinates of ctx and index of that partcular side to understand which side the ctx is present.
this is my code
document.addEventListener ("mousedown",( event ) => {
var vector = new THREE.Vector3();
pointer.x = ( event.clientX / window.innerWidth ) * 2 - 1;
pointer.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
vector.unproject( camera );
raycaster.setFromCamera( pointer, camera);
var intersects = raycaster.intersectObject( this.cube );
if (intersects.length > 0) {
index = Math.floor(intersects[0].faceIndex / 2);
if (index == 0) {
let templabelarray = []
for (let i = 0; i < this.labels.length; i++) {
if (this.labels[i].typename == 'Left' ) {
templabelarray.push(this.labels[i]);
}
this.state.totalLabels.push(templabelarray);
let rect = this.ctxArr[0].getBoundingClientRect()
this.x = e.clientX - rect.left
this.y = e.clientY - rect.top
let i = 0, r;
this.labels will give me the array for ctx present on the particular side and further i"m pssing it into state variable
Using this I’m able to get the index but, unable to fetch x,y co-ordinates for ctx. any help would be greatly appreciated