-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMarker.proto
executable file
·99 lines (98 loc) · 2.57 KB
/
Marker.proto
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
88
89
90
91
92
93
94
95
96
97
98
99
#VRML_SIM R2022b utf8
# template language: javascript
# tags: nonDeterministic
PROTO Marker [
field SFVec3f translation 0 0 0
field SFRotation rotation 0 1 0 0
field SFVec2f {0.08 0.08, 0.1 0.1, 0.15 0.15, 0.2 0.2} size 0.08 0.08
field SFString name ""
field SFString model ""
field MFString texture_url []
field SFBool add_recognition FALSE
field SFBool upright FALSE
]
{
%< if (fields.upright.value) { >%
Pose {
translation IS translation
rotation IS rotation
children [
%< } >%
Solid {
%<
import * as wbrandom from 'wbrandom.js';
wbrandom.seed(context.id);
const uid = wbrandom.integer();
>%
%< if (fields.upright.value) { >%
rotation 1 0 0 1.5708
%< } else { >%
translation IS translation
rotation IS rotation
%< } >%
children [
%<
if (fields.add_recognition.value) {
for (let corner of [['TL', 1, 1], ['TR', -1, 1], ['BR', -1, -1], ['BL', 1, -1]]) {
let corner_name = corner[0];
let horiz_sign = corner[1];
let vert_sign = corner[2];
>%
Solid {
translation %<= horiz_sign * fields.size.value.x / 2 >% %<= vert_sign * fields.size.value.y / 2 >% 0.001
children [
Shape {
appearance PBRAppearance {
transparency 1
metalness 0
}
geometry Plane {
# Make the detection corners one marker pixel in size
size %<= fields.size.value.x / 8 >% %<= fields.size.value.y / 8 >%
}
castShadows FALSE
}
]
model %<= "\"" + uid + "_" + fields.model.value + "_" + corner_name + "\"" >%
name %<= "\"" + corner_name + "\"" >%
locked TRUE
recognitionColors [
0 0 1
]
}
%< }} >%
Shape {
appearance PBRAppearance {
baseColorMap ImageTexture {
url IS texture_url
repeatS FALSE
repeatT FALSE
}
roughness 1
metalness 0
}
geometry Plane {
# The size of the marker including the white border
size %<= 1.25 * fields.size.value.x >% %<= 1.25 * fields.size.value.y >%
}
castShadows FALSE
}
]
%< if (fields.name.value !== "") { >%
name IS name
%< } else { >%
name IS model
%< } >%
model %<= "\"" + uid + "_" + fields.model.value + "_base\"" >%
locked TRUE
%< if (fields.add_recognition.value) { >%
recognitionColors [
1 1 1
]
%< } >%
}
%< if (fields.upright.value) { >%
]
}
%< } >%
}