Skip to content

Commit

Permalink
Remove object detected rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
idkiller committed Apr 29, 2021
1 parent 3dea785 commit dfe1436
Showing 1 changed file with 1 addition and 54 deletions.
55 changes: 1 addition & 54 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ interface UserInfo {
user: MRE.User,
location: string,
token: string,
remainedPositions: Array<{ position: {x: number, y: number, z: number}, type: string, locationId: string }>
}

export default class Ideas {
Expand All @@ -36,7 +35,6 @@ export default class Ideas {
this.ctx.onStarted(() => this.started());
this.ctx.onUserJoined(this.onUserJoined.bind(this));
this.ctx.rpc.on(RPC.LocationChanged, this.onLocationChanged.bind(this));
this.ctx.rpc.on(RPC.ObjectDetected, this.onObjectDetected.bind(this));
}

private async started() {
Expand All @@ -57,46 +55,13 @@ export default class Ideas {
this.userMap[userId] = {
user,
location: "",
token: user.properties['token'],
remainedPositions: []
token: user.properties['token']
}
this.removeNotesFromUser(userId);
this.userObjects[userId] = [];
console.log(`user: ${user.name}[${userId}] is registed`);
}

private onObjectDetected(options: { userId: Guid; }, ...args: any[]): void {
console.log(`onObjectDetected... user [${options.userId}], ${args[0]}`);
const objectType = args[0];
const x = args[1];
const y = args[2];
const z = args[3];
const locationId = args[4];
const position = x instanceof Number && y instanceof Number && z instanceof Number ?
{ x: 0, y: 0, z: 0 } : { x, y, z };

const userId = options.userId?.toString();
if (!userId) return;

const objs = this.userObjects[userId];

if (objs.length > 0) {
for (let i = 0 ; i < objs.length; i++) {
if (objs[i].type === objectType)
{
objs[i].obj.show();
objs[i].obj.move(position);
objs[i].positioned = true;
console.log(`${objectType} => ${position.x}, ${position.y}, ${position.z} - ${userId}`);
break;
}
}
}
this.userMap[userId].remainedPositions.push({position, type: objectType, locationId});
console.log(`remained position is pushed : ${objectType} / ${locationId} / (${position.x}, ${position.y}, ${position.z})`);
}


private onLocationChanged(options: { userId: Guid; }, ...args: any[]) : void
{
console.log(`onLocationChanged... user [${options.userId}]`);
Expand Down Expand Up @@ -154,19 +119,6 @@ export default class Ideas {
console.log(`object is created : ${memo.linkedObjectType} - ${memo.permission} - [${memo.contents}] - ${user.user.name} - ${options.userId}`);

obj.show();

/*
for (let i = this.userMap[userId].remainedPositions.length - 1; i >= 0; i--) {
const p = this.userMap[userId].remainedPositions[i];
if (p.locationId === locationId && p.type === memo.linkedObjectType) {
obj.show();
obj.move(p.position);
//this.userMap[userId].remainedPositions.splice(i, 1);
console.log(`object moved : ${memo.linkedObjectType}, (${p.position.x}, ${p.position.y}, ${p.position.z})`);
break;
}
}
*/
}
}
});
Expand All @@ -183,11 +135,6 @@ export default class Ideas {
}
}

interface ObjectInfo {
type: string;
position: {x: number, y: number, z: number};
}

interface Memo {
textureType: string,
type: string;
Expand Down

0 comments on commit dfe1436

Please sign in to comment.