Browse Source

interact prompt

master
cailean 1 hour ago
parent
commit
972a165087
  1. 116
      js/Player.js

116
js/Player.js

@ -979,64 +979,64 @@ export class Player {
this._checkAreaTriggers();
// --- Interact Prompt Logic ---
// if (!this.interactPrompt) {
// this.interactPrompt = this._createInteractPrompt();
// this.camera.add(this.interactPrompt);
// this.interactPrompt.position.set(0, -0.5, -2);
// this.interactPrompt.visible = false;
// }
// // Show prompt if hovering over item and not holding one
// if (this.currentIntItem && !this.attachedItem) {
// // Regenerate prompt if hovered item changed
// if (this.lastPromptItem !== this.currentIntItem) {
// // Remove old prompt mesh
// this.camera.remove(this.interactPrompt);
// // Dispose all character meshes in the group
// if (this.interactPrompt.userData.charMeshes) {
// this.interactPrompt.userData.charMeshes.forEach(mesh => {
// if (mesh.geometry) mesh.geometry.dispose();
// if (mesh.material) {
// if (mesh.material.map) mesh.material.map.dispose();
// mesh.material.dispose();
// }
// });
// }
// // Create new prompt with new random colors
// this.interactPrompt = this._createInteractPrompt();
// this.camera.add(this.interactPrompt);
// this.interactPrompt.position.set(0, -0.5, -2);
// }
// this.interactPrompt.visible = true;
// this.interactPromptTime += delta;
// const bob = Math.sin(this.interactPromptTime * 2) * 0.01;
// this.interactPrompt.position.y = -0.5 + bob;
// this.lastPromptItem = this.currentIntItem;
// } else {
// this.interactPrompt.visible = false;
// this.interactPromptTime = 0;
// this.lastPromptItem = null;
// }
// if (this.interactPrompt && this.interactPrompt.userData.charMeshes) {
// const now = performance.now();
// this.interactPrompt.userData.charMeshes.forEach((mesh, i) => {
// // Don't animate spaces
// if (mesh.material.map.image) {
// const ctx = mesh.material.map.image.getContext && mesh.material.map.image.getContext('2d');
// if (ctx && ctx.measureText && ctx.measureText(' ').width === 0) return;
// }
// // Snap rotation at random intervals
// if (now > mesh.userData.nextSnap) {
// mesh.userData.snapRotation = (Math.random() * 40 - 20) * Math.PI / 180; // -20 to +20 deg in radians
// mesh.userData.nextSnap = now + Math.random() * 600 + 300; // 100-700ms
// }
// mesh.rotation.z = mesh.userData.snapRotation;
// });
// }
if (!this.interactPrompt) {
this.interactPrompt = this._createInteractPrompt();
this.camera.add(this.interactPrompt);
this.interactPrompt.position.set(0, -0.5, -2);
this.interactPrompt.visible = false;
}
// Show prompt if hovering over item and not holding one
if (this.currentIntItem && !this.attachedItem) {
// Regenerate prompt if hovered item changed
if (this.lastPromptItem !== this.currentIntItem) {
// Remove old prompt mesh
this.camera.remove(this.interactPrompt);
// Dispose all character meshes in the group
if (this.interactPrompt.userData.charMeshes) {
this.interactPrompt.userData.charMeshes.forEach(mesh => {
if (mesh.geometry) mesh.geometry.dispose();
if (mesh.material) {
if (mesh.material.map) mesh.material.map.dispose();
mesh.material.dispose();
}
});
}
// Create new prompt with new random colors
this.interactPrompt = this._createInteractPrompt();
this.camera.add(this.interactPrompt);
this.interactPrompt.position.set(0, -0.5, -2);
}
this.interactPrompt.visible = true;
this.interactPromptTime += delta;
const bob = Math.sin(this.interactPromptTime * 2) * 0.01;
this.interactPrompt.position.y = -0.5 + bob;
this.lastPromptItem = this.currentIntItem;
} else {
this.interactPrompt.visible = false;
this.interactPromptTime = 0;
this.lastPromptItem = null;
}
if (this.interactPrompt && this.interactPrompt.userData.charMeshes) {
const now = performance.now();
this.interactPrompt.userData.charMeshes.forEach((mesh, i) => {
// Don't animate spaces
if (mesh.material.map.image) {
const ctx = mesh.material.map.image.getContext && mesh.material.map.image.getContext('2d');
if (ctx && ctx.measureText && ctx.measureText(' ').width === 0) return;
}
// Snap rotation at random intervals
if (now > mesh.userData.nextSnap) {
mesh.userData.snapRotation = (Math.random() * 40 - 20) * Math.PI / 180; // -20 to +20 deg in radians
mesh.userData.nextSnap = now + Math.random() * 600 + 300; // 100-700ms
}
mesh.rotation.z = mesh.userData.snapRotation;
});
}
// --- Item Counter Animation ---
if (this.itemCountDisplay && this.itemCountAnim.active) {

Loading…
Cancel
Save