Page 1 of 1

Überprüfung nach Maus -Schwebe in P5.Js mit unterschiedlicher Perspektive [geschlossen]

Posted: 12 Apr 2025, 16:18
by Anonymous
Ich erstelle ein 3-Achsen-Graph, mit dem der Benutzer die Perspektive interagieren und anpassen kann. Ich möchte eine Funktion implementieren, die überprüft, ob der Cursor über eines der Elemente des Diagramms schwebt, sodass der Benutzer, wenn der Benutzer auf ein Element zeigt, zusätzliches Informationen angezeigt werden kann. Ich würde gerne wissen, ob so etwas für einen 3D-Freigut und wenn ja, der Methode möglich ist. Vielen Dank!

Code: Select all

function preload() {
font = loadFont("Courier New.ttf");
}

function setup() {
createCanvas(700, 700, WEBGL);
textFont(font);
textSize(30);
textAlign(CENTER, CENTER);
frameRate(60);

//debugMode()
}

function graph() {
// graph axis
noFill();
stroke(2);
box(500, 500);

fill("black");
text("", 0, 250);
push();
rotateY(-HALF_PI);
text("", 0, 250);
pop();
push();
rotateZ(HALF_PI);
translate(0, -500);
text("", 0, 250);
pop();
}

function elements() {
let x = 100;
let y = 20;
let z = -100;

push();
translate(x, y, z);
noStroke();
fill("red");
sphere(5)

pop();
}

function draw() {
background("white");
orbitControl();
graph();
elements();
}