Apply scene ghost height to viewer ghosts, live on scene updates
This commit is contained in:
@@ -16,6 +16,7 @@ let info = { mode: 'dev' };
|
|||||||
let scene3, camera3, renderer, video, canvas2d, ctx2d;
|
let scene3, camera3, renderer, video, canvas2d, ctx2d;
|
||||||
let detector, poseEst, fuser;
|
let detector, poseEst, fuser;
|
||||||
let gradients = {}, modelManifest = null;
|
let gradients = {}, modelManifest = null;
|
||||||
|
let ghostHeight = 4; // cm, from scene.ghostHeightCm
|
||||||
const activeGhosts = new Map(); // uid -> { rec, group }
|
const activeGhosts = new Map(); // uid -> { rec, group }
|
||||||
let tracking = { markers: 0, lastSeen: 0 };
|
let tracking = { markers: 0, lastSeen: 0 };
|
||||||
const clockOffsetSamples = [];
|
const clockOffsetSamples = [];
|
||||||
@@ -62,7 +63,11 @@ async function start() {
|
|||||||
|
|
||||||
// network
|
// network
|
||||||
const net = new ExhibitNet();
|
const net = new ExhibitNet();
|
||||||
net.on('scene', (m) => { fuser.setScene(m.scene); buildOcclusion(m.scene); })
|
net.on('scene', (m) => {
|
||||||
|
fuser.setScene(m.scene); buildOcclusion(m.scene);
|
||||||
|
ghostHeight = m.scene.ghostHeightCm || 4;
|
||||||
|
for (const e of activeGhosts.values()) e.group.userData.setHeight(ghostHeight);
|
||||||
|
})
|
||||||
.on('active', async (m) => {
|
.on('active', async (m) => {
|
||||||
for (const uid of [...activeGhosts.keys()]) removeGhost(uid);
|
for (const uid of [...activeGhosts.keys()]) removeGhost(uid);
|
||||||
for (const rec of m.ghosts) await addGhost(rec);
|
for (const rec of m.ghosts) await addGhost(rec);
|
||||||
@@ -107,6 +112,7 @@ function buildOcclusion(scene) {
|
|||||||
async function addGhost(rec) {
|
async function addGhost(rec) {
|
||||||
if (activeGhosts.has(rec.uid)) return;
|
if (activeGhosts.has(rec.uid)) return;
|
||||||
const group = await buildGhost(rec, gradients, modelManifest);
|
const group = await buildGhost(rec, gradients, modelManifest);
|
||||||
|
group.userData.setHeight(ghostHeight);
|
||||||
scene3.add(group);
|
scene3.add(group);
|
||||||
activeGhosts.set(rec.uid, { rec, group });
|
activeGhosts.set(rec.uid, { rec, group });
|
||||||
toast(`${rec.name} appeared`);
|
toast(`${rec.name} appeared`);
|
||||||
|
|||||||
Reference in New Issue
Block a user