main
reng 1 month ago
parent 4aa167bb20
commit 3539a8e14f
  1. 2
      Assets/Qdrant/storage/collections/data-v1/0/newest_clocks.json
  2. 2
      Assets/Qdrant/storage/collections/data-v2/0/newest_clocks.json
  3. 2
      Assets/Qdrant/storage/collections/data-v3/0/newest_clocks.json
  4. 2
      Assets/Qdrant/storage/collections/keywords_v1/0/newest_clocks.json
  5. 2
      Assets/Qdrant/storage/collections/theme-v1/0/newest_clocks.json
  6. 52
      v2/app/src/App.jsx
  7. 57
      v2/app/src/components/graph.jsx
  8. 14
      v2/app/src/components/point.jsx
  9. 14
      v2/app/src/utils/firebase.js

@ -1 +1 @@
{"clocks":[{"peer_id":2200039024721645,"clock_id":3,"current_tick":5,"token":12159487072447257415},{"peer_id":2200039024721645,"clock_id":5,"current_tick":3,"token":16737324663161229622},{"peer_id":2200039024721645,"clock_id":0,"current_tick":31,"token":14274923382223712766},{"peer_id":2200039024721645,"clock_id":6,"current_tick":1,"token":9225203475475803001},{"peer_id":2200039024721645,"clock_id":1,"current_tick":19,"token":13530503213804333634},{"peer_id":2200039024721645,"clock_id":4,"current_tick":3,"token":3225682797052271524},{"peer_id":2200039024721645,"clock_id":2,"current_tick":13,"token":18171945371147883509}]}
{"clocks":[{"peer_id":2200039024721645,"clock_id":6,"current_tick":1,"token":9225203475475803001},{"peer_id":2200039024721645,"clock_id":4,"current_tick":3,"token":3225682797052271524},{"peer_id":2200039024721645,"clock_id":5,"current_tick":3,"token":16737324663161229622},{"peer_id":2200039024721645,"clock_id":1,"current_tick":19,"token":13530503213804333634},{"peer_id":2200039024721645,"clock_id":0,"current_tick":31,"token":14274923382223712766},{"peer_id":2200039024721645,"clock_id":3,"current_tick":5,"token":12159487072447257415},{"peer_id":2200039024721645,"clock_id":2,"current_tick":13,"token":18171945371147883509}]}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1 +1 @@
{"clocks":[{"peer_id":2200039024721645,"clock_id":2,"current_tick":1,"token":9487764786059616743},{"peer_id":2200039024721645,"clock_id":0,"current_tick":14,"token":3773126989639130100},{"peer_id":2200039024721645,"clock_id":1,"current_tick":3,"token":1867745747127142053}]}
{"clocks":[{"peer_id":2200039024721645,"clock_id":0,"current_tick":14,"token":3773126989639130100},{"peer_id":2200039024721645,"clock_id":2,"current_tick":1,"token":9487764786059616743},{"peer_id":2200039024721645,"clock_id":1,"current_tick":3,"token":1867745747127142053}]}

@ -1 +1 @@
{"clocks":[{"peer_id":2200039024721645,"clock_id":1,"current_tick":1,"token":18111163424196140885},{"peer_id":2200039024721645,"clock_id":0,"current_tick":9,"token":9315707229535449938}]}
{"clocks":[{"peer_id":2200039024721645,"clock_id":0,"current_tick":9,"token":9315707229535449938},{"peer_id":2200039024721645,"clock_id":1,"current_tick":1,"token":18111163424196140885}]}

@ -84,23 +84,57 @@ function App() {
setKeywords(json);
});
const keyword_unsub=addFirebaseListener('keywords', (data)=>{
// const keyword_unsub=addFirebaseListener('keywords', (data)=>{
// console.log("Firebase keywords updated:", data);
// // setKeywords(data);
// const currentTime = Date.now();
// let inTime = data.filter(el=>el.updatedTime && (currentTime - el.updatedTime.seconds * 1000) < KeywordLastTime);
// if(inTime.length===0){
// console.log("No keywords updated in the last", KeywordLastTime/1000, "seconds.");
// // select latest 4 keywords
// inTime = data.sort((a,b)=>b.updatedTime.seconds - a.updatedTime.seconds).slice(0,4);
// }
// selectKeywords(inTime.map(el=>el.id));
// });
const keyword_unsub=addFirebaseListener('state', (data)=>{
console.log("Firebase keywords updated:", data);
// setKeywords(data);
const currentTime = Date.now();
let inTime = data.filter(el=>el.updatedTime && (currentTime - el.updatedTime.seconds * 1000) < KeywordLastTime);
if(inTime.length===0){
console.log("No keywords updated in the last", KeywordLastTime/1000, "seconds.");
// select latest 4 keywords
inTime = data.sort((a,b)=>b.updatedTime.seconds - a.updatedTime.seconds).slice(0,4);
// const currentTime = Date.now();
// let inTime = data.filter(el=>el.updatedTime && (currentTime - el.updatedTime.seconds * 1000) < KeywordLastTime);
// if(inTime.length===0){
// console.log("No keywords updated in the last", KeywordLastTime/1000, "seconds.");
// // select latest 4 keywords
// inTime = data.sort((a,b)=>b.updatedTime.seconds - a.updatedTime.seconds).slice(0,4);
// }
// console.log(data);
const latest_page=data.find(el=>el.id === 'latest_page');
if(latest_page){
console.log(latest_page);
const keywords_on_page=latest_page.keywords || [];
selectKeywords(keywords_on_page.map(el=>el.id));
}
selectKeywords(inTime.map(el=>el.id));
// selectKeywords(inTime.map(el=>el.id));
});
const lookat_unsub=addFirebaseListener('lookat', (data)=>{
console.log("Firebase lookat updated:", data);
if(data.length===0){
console.log("No lookat data.");
lookatKeywords([{
id: 'default',
}]);
return;
}
const currentTime = Date.now();
let inTime = data.filter(el=>el.updatedTime && (currentTime - el.updatedTime.seconds * 1000) < LookatLastTime);

@ -10,6 +10,14 @@ import { rgbToCss, getRgbFromIndex } from '../utils/color.js';
import { getRevolution } from '../utils/group.js';
const getDistance = (v1, v2) => {
if (!v1 || !v2) return Infinity;
return Math.sqrt(
v1.reduce((acc, val, i) => acc + Math.pow(val - (v2[i] || 0), 2), 0)
);
};
export default function Graph({results}){
const [points, setPoints]=useState();
@ -20,7 +28,7 @@ export default function Graph({results}){
// const [showContent, setShowContent]=useState(true);
// const [showKeyword, setShowKeyword]=useState(false);
const { showContent, contentType, showKeywords, showLines, textToShow, drawDistance, distToKeywords, keywordColor } = useControls({
const { showContent, contentType, showKeywords, showLines, textToShow, drawDistance, distToKeywords, keywordColor, useAnimation } = useControls({
showContent: { value: true },
contentType: { options: Object.values(PointContentType), value: PointContentType.Teaser },
showKeywords: { value: false },
@ -29,6 +37,7 @@ export default function Graph({results}){
drawDistance: { value: 0.2, min: 0.1, max: 5, step: 0.01 },
keywordColor: { value: true },
distToKeywords: { value: 3, min: 0.1, max: 10, step: 0.01 },
useAnimation: {value:false},
});
@ -81,7 +90,48 @@ export default function Graph({results}){
sendOsc('/clear', JSON.stringify({}));
// return;
const keywords=results.filter((point)=>point?.type==='keyword');
const keywords = results.filter(p => p?.type === 'keyword');
const dataPoints = results.filter(p => p?.type !== 'keyword');
console.log(dataPoints)
// --- STEP 1: Identify Empty Groups ---
// Create a map of keyword IDs and how many points are currently assigned to them
const groupCounts = {};
keywords.forEach(kw => groupCounts[kw.id] = 0);
results.forEach(res => {
if (res.type !== 'keyword' && res.payload?.group?.[0]) {
const id = res.payload.group[0].id;
if (groupCounts[id] !== undefined) groupCounts[id]++;
}
});
// --- STEP 2: Force Assignment for Empty Groups ---
keywords.forEach(kw => {
if (groupCounts[kw.id] === 0) {
// Find the nearest data point that isn't a keyword itself
let nearestPoint = null;
let minDocDist = Infinity;
results.forEach((res, idx) => {
if (res.type === 'keyword') return;
// Calculate distance in vector space (using the embedding/vector)
const d = getDistance(res.vector, kw.vector);
if (d < minDocDist) {
minDocDist = d;
nearestPoint = res;
}
});
// Re-assign the nearest point to this keyword
if (nearestPoint) {
console.log(`Force assigning point ${nearestPoint.id} to empty group ${kw.id}`);
nearestPoint.payload.group = [{ id: kw.id, distance: minDocDist }];
groupCounts[kw.id]++;
}
}
});
let i=0;
@ -177,6 +227,7 @@ export default function Graph({results}){
z: keyword_point[2],
content: `${content.title||''} ${content.title_en||''}` || 'Keyword',
average_distance: average_distances[group_index]/points.length,
question: content.content || '',
color: getColorByGroup(results?.[index]),
group: index,
@ -186,6 +237,7 @@ export default function Graph({results}){
}, [points]);
useEffect(()=>{
if(!results || results.length===0){
setLines([]);
@ -241,6 +293,7 @@ export default function Graph({results}){
showContent={showContent} showKeyword={showKeywords} contentType={contentType}
textToShow={textToShow}
color={rgbToCss(getColorByGroup(results?.[index]))}
useAnimation={useAnimation}
/>
))}
</group>

@ -31,7 +31,7 @@ export const PointContentType={
}
export default function Point({point, index, totalPoints, result, showContent, showKeyword, contentType, textToShow, color}) {
export default function Point({point, index, totalPoints, result, showContent, showKeyword, contentType, textToShow, color, useAnimation}) {
const [payload, setPayload]=useState();
const [showPayload, setShowPayload]=useState(false);
@ -88,14 +88,16 @@ export default function Point({point, index, totalPoints, result, showContent, s
if (!meshRef.current || !refText.current || !payload) return;
const time = state.clock.elapsedTime;
const lifeTimeOffset = (payload.number / payload.total) || 0;
// const time = state.clock.elapsedTime;
// const lifeTimeOffset = (payload.number / payload.total) || 0;
// 1. ( GSAP)
// 使 PointDuration
const pulseSpeed = Math.PI / PointDuration;
const pulse = 1;//Math.abs(Math.sin(time * pulseSpeed + lifeTimeOffset * Math.PI));
const currentMeshScale = THREE.MathUtils.lerp(0.5, PointSize, pulse);
const currentMeshScale = useAnimation? THREE.MathUtils.lerp(0.5, PointSize, pulse): PointSize;
meshRef.current.scale.set(currentMeshScale, currentMeshScale, currentMeshScale);
// 2.
@ -148,6 +150,10 @@ export default function Point({point, index, totalPoints, result, showContent, s
const lifeTime=payload.normalized_time;
if(lifeTime===-1) return; // keyword
// if(!useAnimation) {
// setTextStyle(1);
// return;
// }
// console.log("Point lifeTime:", lifeTime);

@ -7,13 +7,13 @@ import { getFirestore, collection, doc, writeBatch, onSnapshot } from "firebase/
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
apiKey: "AIzaSyB3Yfrh18w5VNSb36LFHJHvegTSv_W1VOU",
authDomain: "uc-23070-grayscale.firebaseapp.com",
projectId: "uc-23070-grayscale",
storageBucket: "uc-23070-grayscale.firebasestorage.app",
messagingSenderId: "866564340708",
appId: "1:866564340708:web:31eea78e6c56eeab6825f1",
measurementId: "G-NNY50B5T9F"
apiKey: "AIzaSyBPI9CDh0rnGnFAc4xSCfTC43oDDblEAsY",
authDomain: "uc-23070-grayscale-backup.firebaseapp.com",
projectId: "uc-23070-grayscale-backup",
storageBucket: "uc-23070-grayscale-backup.firebasestorage.app",
messagingSenderId: "611635514938",
appId: "1:611635514938:web:897fdb87381a0e54166f03",
measurementId: "G-F2TFEBMWCN"
};
// Initialize Firebase

Loading…
Cancel
Save