-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.html
More file actions
269 lines (250 loc) · 8.51 KB
/
example.html
File metadata and controls
269 lines (250 loc) · 8.51 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Basic PdXR Example</title>
<script src="https://aframe.io/releases/1.3.0/aframe.min.js"></script>
<script src="./aframe-super-keyboard/dist/aframe-super-keyboard.js"></script>
<!-- NAF basic requirements -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.5.0/socket.io.slim.js"></script>
<script src="/easyrtc/easyrtc.js"></script>
<script src="/dist/networked-aframe.js"></script>
<!-- used for flying in this demo -->
<script src="https://cdn.jsdelivr.net/gh/n5ro/aframe-extras@14411ea/dist/aframe-extras.controls.min.js"></script>
<!-- used for the pretty environment -->
<script src="https://unpkg.com/aframe-environment-component@1.3.1/dist/aframe-environment-component.min.js"></script>
<!-- used to prevent players from spawning on top of each other so much -->
<script src="./aframe-resonance-audio-component/aframe-resonance-audio-component.js"></script>
<script src="./public/js/webmidi.min.js"></script>
<script>
// Note the way we're establishing the NAF schema here; this is a bit awkward
// because of a recent bug found in the original handling. This mitigates that bug for now,
// until a refactor in the future that should fix the issue more cleanly.
// see issue https://github.com/networked-aframe/networked-aframe/issues/267
// This one is necessary, because tracking the .head child component's material's color
// won't happen unless we tell NAF to keep it in sync, like here.
NAF.schemas.getComponentsOriginal = NAF.schemas.getComponents;
NAF.schemas.getComponents = (template) => {
if (!NAF.schemas.hasTemplate("#avatar-template")) {
NAF.schemas.add({
template: "#avatar-template",
components: [
// position and rotation are added by default if we don't include a template, but since
// we also want to sync the color, we need to specify a custom template; if we didn't
// include position and rotation in this custom template, they'd not be synced.
"position",
"rotation",
// this is how we sync a particular property of a particular component for a particular
// child element of template instances.
{
selector: ".head",
component: "material",
property: "color", // property is optional; if excluded, syncs everything in the component schema
},
],
});
}
if (!NAF.schemas.hasTemplate("#bang-template")) {
NAF.schemas.add({
template: "#bang-template",
components: [
"position",
{
component: "bang",
property: "bang",
},
],
});
}
if (!NAF.schemas.hasTemplate("#toggle-template")) {
NAF.schemas.add({
template: "#toggle-template",
components: [
"position",
{
component: "material",
property: "wireframe",
},
{
component: "toggle",
property: "toggle",
},
],
});
}
if (!NAF.schemas.hasTemplate("#sld-template")) {
NAF.schemas.add({
template: "#sld-template",
components: [
"position",
{
component: "pdsld",
property: "value",
},
],
});
}
if (!NAF.schemas.hasTemplate("#num-template")) {
NAF.schemas.add({
template: "#num-template",
components: [
"position",
{
component: "num",
property: "value",
},
],
});
}
if (!NAF.schemas.hasTemplate("#sym-template")) {
NAF.schemas.add({
template: "#sym-template",
components: [
"position",
{
component: "sym",
property: "value",
},
],
});
}
const components = NAF.schemas.getComponentsOriginal(template);
return components;
};
</script>
</head>
<body>
<script src="a-pdxr.js"></script>
<a-scene
networked-scene="
room: basic;
debug: true;
adapter: wseasyrtc;
"
>
<a-assets>
<!-- Templates -->
<!-- Camera Rig / Player -->
<template id="rig-template">
<a-entity></a-entity>
</template>
<!-- Head / Avatar -->
<!-- a few spheres make a head + eyes + pupils -->
<template id="avatar-template">
<a-entity class="avatar">
<a-sphere class="head" scale="0.2 0.22 0.2"></a-sphere>
</a-entity>
</template>
<!--
Templates of PD GUI Objects
change visual appearance here.
-->
<template id="bang-template">
<a-entity
geometry="primitive: box"
material="wireframe: false; color: white"
bang
animation="property: material.color; from: #FFFFFF; to: #000000; dur: 50; dir: reverse; startEvents: pdbng_glow"
animation__2="property: bang.bang;from: 1; to: 0; delay: 50; dur: 1; startEvents: pdbng_false"
>
</a-entity>
</template>
<template id="num-template">
<a-entity
geometry="primitive: box"
material="wireframe: true; color: white"
num
>
</a-entity>
</template>
<template id="sym-template">
<a-entity
geometry="primitive: box"
material="wireframe: true; color: white"
sym
>
</a-entity>
</template>
<template id="toggle-template">
<a-entity
geometry="primitive: box"
material="wireframe: true; color: white"
toggle
>
</a-entity>
</template>
<template id="sld-template">
<a-entity
geometry="primitive: box; height:4"
material="wireframe:true"
scale="0.5 0.5 0.5"
>
<a-entity
geometry="primitive: box; height:0.5"
material="wireframe:false"
position="0 2.25 0"
slideup
animation="property:material.color; from: #FFFFFF; to: #000000; dur:50; dir:reverse; startEvents: pdsldup_glow"
></a-entity>
<a-entity
geometry="primitive: box; height:0.1"
material="wireframe:false"
position="0 0 0"
slider
></a-entity>
<a-entity
geometry="primitive: box; height:0.5"
material="wireframe:false"
position="0 -2.25 0"
slidedwn
animation="property:material.color; from: #FFFFFF; to: #000000; dur:50; dir:reverse; startEvents: pdslddwn_glow"
></a-entity>
</a-entity>
</template>
</a-assets>
<a-resonance-audio-room
position="0 0 0"
width="1"
height="1"
depth="1"
ambisonic-order="3"
speed-of-sound="343"
left="brick-bare"
right="brick-bare"
front="brick-bare"
back="brick-bare"
down="brick-bare"
up="brick-bare"
visualize="true"
>
</a-resonance-audio-room>
<a-entity environment="preset:default;" hide-on-enter-ar></a-entity>
<a-entity light="type:ambient;intensity:0.5"></a-entity>
<a-entity
id="rig"
movement-controls="fly:true;"
networked="template:#rig-template;"
>
<a-entity
id="player"
camera
cursor="rayOrigin: mouse"
position="0 1.6 0"
look-controls
networked="template:#avatar-template;"
visible="true"
>
</a-entity>
</a-entity>
<a-pdxr visualize="true" src="default.pd" position="0 1 0" ></a-pdxr>
</a-scene>
<svg id="canvas" hidden></svg>
<script>
// Called by Networked-Aframe when connected to server
// Optional to use; this API will change in the future
function onConnect() {
console.log("onConnect", new Date());
}
</script>
</body>
</html>