Compare commits
1 Commits
mimo/build
...
mimo/code/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4706861619 |
@@ -815,6 +815,42 @@ const SpatialMemory = (() => {
|
|||||||
return results.slice(0, maxResults);
|
return results.slice(0, maxResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ─── CONTENT SEARCH ─────────────────────────────────
|
||||||
|
/**
|
||||||
|
* Search memories by text content — case-insensitive substring match.
|
||||||
|
* @param {string} query - Search text
|
||||||
|
* @param {object} [options] - Optional filters
|
||||||
|
* @param {string} [options.category] - Restrict to a specific region
|
||||||
|
* @param {number} [options.maxResults=20] - Cap results
|
||||||
|
* @returns {Array<{memory: object, score: number, position: THREE.Vector3}>}
|
||||||
|
*/
|
||||||
|
function searchByContent(query, options = {}) {
|
||||||
|
if (!query || !query.trim()) return [];
|
||||||
|
const { category, maxResults = 20 } = options;
|
||||||
|
const needle = query.trim().toLowerCase();
|
||||||
|
const results = [];
|
||||||
|
|
||||||
|
Object.values(_memoryObjects).forEach(obj => {
|
||||||
|
if (category && obj.region !== category) return;
|
||||||
|
const content = (obj.data.content || '').toLowerCase();
|
||||||
|
if (!content.includes(needle)) return;
|
||||||
|
|
||||||
|
// Score: number of occurrences + strength bonus
|
||||||
|
let matches = 0, idx = 0;
|
||||||
|
while ((idx = content.indexOf(needle, idx)) !== -1) { matches++; idx += needle.length; }
|
||||||
|
const score = matches + (obj.mesh.userData.strength || 0.7);
|
||||||
|
|
||||||
|
results.push({
|
||||||
|
memory: obj.data,
|
||||||
|
score,
|
||||||
|
position: obj.mesh.position.clone()
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
results.sort((a, b) => b.score - a.score);
|
||||||
|
return results.slice(0, maxResults);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ─── CRYSTAL MESH COLLECTION (for raycasting) ────────
|
// ─── CRYSTAL MESH COLLECTION (for raycasting) ────────
|
||||||
function getCrystalMeshes() {
|
function getCrystalMeshes() {
|
||||||
@@ -864,7 +900,7 @@ const SpatialMemory = (() => {
|
|||||||
init, placeMemory, removeMemory, update, importMemories, updateMemory,
|
init, placeMemory, removeMemory, update, importMemories, updateMemory,
|
||||||
getMemoryAtPosition, getRegionAtPosition, getMemoriesInRegion, getAllMemories,
|
getMemoryAtPosition, getRegionAtPosition, getMemoriesInRegion, getAllMemories,
|
||||||
getCrystalMeshes, getMemoryFromMesh, highlightMemory, clearHighlight, getSelectedId,
|
getCrystalMeshes, getMemoryFromMesh, highlightMemory, clearHighlight, getSelectedId,
|
||||||
exportIndex, importIndex, searchNearby, REGIONS,
|
exportIndex, importIndex, searchNearby, searchByContent, REGIONS,
|
||||||
saveToStorage, loadFromStorage, clearStorage,
|
saveToStorage, loadFromStorage, clearStorage,
|
||||||
runGravityLayout, setCamera
|
runGravityLayout, setCamera
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user