This repository has been archived by the owner on Jun 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 61
/
attachment.ts
87 lines (80 loc) · 1.87 KB
/
attachment.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*!
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
import { ZeroGuid } from "../../constants";
/**
* The complete set of attach points.
*/
export type AttachPoint
= 'none'
| 'camera'
| 'head'
| 'neck'
| 'hips'
| 'center-eye'
| 'spine-top'
| 'spine-middle'
| 'spine-bottom'
| 'left-eye'
| 'left-upper-leg'
| 'left-lower-leg'
| 'left-foot'
| 'left-toes'
| 'left-shoulder'
| 'left-upper-arm'
| 'left-lower-arm'
| 'left-hand'
| 'left-thumb'
| 'left-index'
| 'left-middle'
| 'left-ring'
| 'left-pinky'
| 'right-eye'
| 'right-upper-leg'
| 'right-lower-leg'
| 'right-foot'
| 'right-toes'
| 'right-shoulder'
| 'right-upper-arm'
| 'right-lower-arm'
| 'right-hand'
| 'right-thumb'
| 'right-index'
| 'right-middle'
| 'right-ring'
| 'right-pinky'
;
/**
* The characteristics of an active attachment.
*/
export interface AttachmentLike {
userId: string;
attachPoint: AttachPoint;
}
/**
* Implementation of AttachmentLike. This class is observable.
*/
export class Attachment implements AttachmentLike {
// tslint:disable:variable-name
private _userId = ZeroGuid;
private _attachPoint: AttachPoint = 'none';
// tslint:enable:variable-name
public get userId() { return this._userId; }
public set userId(value) { this._userId = value || ZeroGuid; }
public get attachPoint() { return this._attachPoint; }
public set attachPoint(value) { this._attachPoint = value || 'none'; }
/** @hidden */
public toJSON(): AttachmentLike {
return {
userId: this.userId,
attachPoint: this.attachPoint
} as AttachmentLike;
}
public copy(from: Partial<AttachmentLike>): this {
if (!from) return this;
if (from.userId) this._userId = from.userId;
if (from.attachPoint) this._attachPoint = from.attachPoint;
return this;
}
}