brilliantsole 0.0.26 → 0.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -10
- package/assets/3d/anchor.glb +0 -0
- package/assets/3d/coin.glb +0 -0
- package/assets/3d/glasses.glb +0 -0
- package/assets/3d/rightHand.glb +0 -0
- package/assets/audio/bounceMedium.wav +0 -0
- package/assets/audio/bounceStrong.wav +0 -0
- package/assets/audio/bounceWeak.wav +0 -0
- package/assets/audio/coin.wav +0 -0
- package/assets/audio/getUp.wav +0 -0
- package/assets/audio/grab.wav +0 -0
- package/assets/audio/kick.wav +0 -0
- package/assets/audio/platterFadeIn old.wav +0 -0
- package/assets/audio/platterFadeIn.wav +0 -0
- package/assets/audio/platterFadeOut.wav +0 -0
- package/assets/audio/punch.wav +0 -0
- package/assets/audio/punchSqueak.wav +0 -0
- package/assets/audio/purr.wav +0 -0
- package/assets/audio/purrFadeOut.wav +0 -0
- package/assets/audio/release.wav +0 -0
- package/assets/audio/splat.wav +0 -0
- package/assets/audio/stomp.wav +0 -0
- package/assets/images/ukaton-pressure-0.svg +9 -0
- package/assets/images/ukaton-pressure-1.svg +9 -0
- package/assets/images/ukaton-pressure-10.svg +9 -0
- package/assets/images/ukaton-pressure-11.svg +9 -0
- package/assets/images/ukaton-pressure-12.svg +9 -0
- package/assets/images/ukaton-pressure-13.svg +9 -0
- package/assets/images/ukaton-pressure-14.svg +9 -0
- package/assets/images/ukaton-pressure-15.svg +9 -0
- package/assets/images/ukaton-pressure-2.svg +9 -0
- package/assets/images/ukaton-pressure-3.svg +9 -0
- package/assets/images/ukaton-pressure-4.svg +9 -0
- package/assets/images/ukaton-pressure-5.svg +9 -0
- package/assets/images/ukaton-pressure-6.svg +9 -0
- package/assets/images/ukaton-pressure-7.svg +9 -0
- package/assets/images/ukaton-pressure-8.svg +9 -0
- package/assets/images/ukaton-pressure-9.svg +9 -0
- package/assets/images/ukaton-right-insole.svg +798 -0
- package/build/brilliantsole.cjs +2870 -882
- package/build/brilliantsole.cjs.map +1 -1
- package/build/brilliantsole.js +2477 -782
- package/build/brilliantsole.js.map +1 -1
- package/build/brilliantsole.ls.js +2260 -592
- package/build/brilliantsole.ls.js.map +1 -1
- package/build/brilliantsole.min.js +1 -1
- package/build/brilliantsole.min.js.map +1 -1
- package/build/brilliantsole.module.d.ts +302 -116
- package/build/brilliantsole.module.js +2468 -782
- package/build/brilliantsole.module.js.map +1 -1
- package/build/brilliantsole.module.min.d.ts +302 -116
- package/build/brilliantsole.module.min.js +1 -1
- package/build/brilliantsole.module.min.js.map +1 -1
- package/build/brilliantsole.node.module.d.ts +295 -113
- package/build/brilliantsole.node.module.js +2860 -882
- package/build/brilliantsole.node.module.js.map +1 -1
- package/build/dts/BS-output.d.ts +10 -0
- package/build/dts/BS.d.ts +21 -9
- package/build/dts/CameraManager.d.ts +72 -0
- package/build/dts/Device.d.ts +53 -16
- package/build/dts/DeviceInformationManager.d.ts +4 -4
- package/build/dts/DeviceManager.d.ts +3 -0
- package/build/dts/FileTransferManager.d.ts +18 -8
- package/build/dts/InformationManager.d.ts +8 -5
- package/build/dts/TfliteManager.d.ts +22 -2
- package/build/dts/WifiManager.d.ts +61 -0
- package/build/dts/connection/BaseConnectionManager.d.ts +37 -3
- package/build/dts/connection/ClientConnectionManager.d.ts +11 -2
- package/build/dts/connection/bluetooth/BluetoothConnectionManager.d.ts +1 -0
- package/build/dts/connection/bluetooth/NobleConnectionManager.d.ts +3 -1
- package/build/dts/connection/bluetooth/WebBluetoothConnectionManager.d.ts +2 -0
- package/build/dts/connection/bluetooth/bluetoothUUIDs.d.ts +2 -2
- package/build/dts/connection/udp/UDPConnectionManager.d.ts +28 -0
- package/build/dts/connection/webSocket/WebSocketConnectionManager.d.ts +25 -0
- package/build/dts/devicePair/DevicePair.d.ts +14 -10
- package/build/dts/devicePair/DevicePairPressureSensorDataManager.d.ts +8 -4
- package/build/dts/devicePair/DevicePairSensorDataManager.d.ts +2 -2
- package/build/dts/scanner/BaseScanner.d.ts +4 -1
- package/build/dts/scanner/NobleScanner.d.ts +2 -1
- package/build/dts/sensor/MotionSensorDataManager.d.ts +5 -2
- package/build/dts/sensor/SensorDataManager.d.ts +5 -4
- package/build/dts/server/BaseClient.d.ts +6 -3
- package/build/dts/server/ServerUtils.d.ts +1 -1
- package/build/dts/server/websocket/WebSocketUtils.d.ts +1 -1
- package/build/dts/utils/CenterOfPressureHelper.d.ts +2 -2
- package/build/dts/utils/Console.d.ts +2 -0
- package/build/dts/utils/MathUtils.d.ts +2 -0
- package/build/dts/utils/ThrottleUtils.d.ts +2 -0
- package/build/dts/vibration/VibrationManager.d.ts +19 -2
- package/build/index.d.ts +299 -113
- package/build/index.node.d.ts +292 -110
- package/examples/3d/scene.html +19 -5
- package/examples/3d/script.js +90 -17
- package/examples/3d-generic/index.html +144 -0
- package/examples/3d-generic/script.js +266 -0
- package/examples/balance/script.js +2 -1
- package/examples/basic/index.html +232 -18
- package/examples/basic/script.js +746 -106
- package/examples/bottango/index.html +11 -1
- package/examples/bottango/script.js +2 -2
- package/examples/center-of-pressure/index.html +114 -114
- package/examples/center-of-pressure/script.js +1 -1
- package/examples/device-pair/index.html +58 -58
- package/examples/device-pair/script.js +12 -8
- package/examples/edge-impulse/script.js +135 -44
- package/examples/edge-impulse-test/README.md +11 -0
- package/examples/edge-impulse-test/edge-impulse-standalone.js +7228 -0
- package/examples/edge-impulse-test/edge-impulse-standalone.wasm +0 -0
- package/examples/edge-impulse-test/index.html +75 -0
- package/examples/edge-impulse-test/run-impulse.js +135 -0
- package/examples/edge-impulse-test/script.js +200 -0
- package/examples/gloves/edge-impulse-standalone.js +7228 -0
- package/examples/gloves/edge-impulse-standalone.wasm +0 -0
- package/examples/gloves/index.html +119 -0
- package/examples/gloves/run-impulse.js +135 -0
- package/examples/gloves/scene.html +124 -0
- package/examples/gloves/script.js +931 -0
- package/examples/graph/index.html +11 -1
- package/examples/graph/script.js +94 -37
- package/examples/pressure/index.html +180 -12
- package/examples/pressure/script.js +144 -7
- package/examples/punch/index.html +135 -0
- package/examples/punch/punch.tflite +0 -0
- package/examples/punch/script.js +169 -0
- package/examples/recording/index.html +191 -183
- package/examples/server/index.html +109 -23
- package/examples/server/script.js +322 -111
- package/examples/ukaton-firmware-update/index.html +20 -0
- package/examples/ukaton-firmware-update/manifest.json +11 -0
- package/examples/ukaton-firmware-update/merged-firmware.bin +0 -0
- package/examples/utils/aframe/aframe-master.min.js +2 -0
- package/examples/utils/aframe/bs-vibration.js +150 -0
- package/examples/utils/aframe/force-pushable.js +80 -0
- package/examples/utils/aframe/grabbable-anchor.js +46 -0
- package/examples/utils/aframe/grabbable-listener.js +31 -0
- package/examples/utils/aframe/grabbable-physics-body.js +190 -0
- package/examples/utils/aframe/grow-shrink.js +25 -0
- package/examples/utils/aframe/hand-punch.js +119 -0
- package/examples/utils/aframe/my-obb-collider.js +293 -0
- package/examples/utils/aframe/occlude-hand-tracking-controls.js +47 -0
- package/examples/utils/aframe/occlude-mesh.js +42 -0
- package/examples/utils/aframe/palm-up-detector.js +47 -0
- package/examples/utils/aframe/shadow-material.js +20 -0
- package/examples/utils/aframe/soft-shadow-light.js +9 -0
- package/examples/webxr/script.js +3 -3
- package/examples/webxr-2/assets/3d/soccerBall.glb +0 -0
- package/examples/webxr-2/assets/audio/shellBounce.wav +0 -0
- package/examples/webxr-2/assets/audio/shellHit.wav +0 -0
- package/examples/webxr-2/assets/audio/shellKick.wav +0 -0
- package/examples/webxr-2/assets/audio/soccerBounce.wav +0 -0
- package/examples/webxr-2/assets/audio/soccerKick.mp3 +0 -0
- package/examples/webxr-2/assets/images/shellTexture.png +0 -0
- package/examples/webxr-2/components/bs-ankle.js +337 -0
- package/examples/webxr-2/components/coin.js +84 -0
- package/examples/webxr-2/components/custom-wrap.js +17 -0
- package/examples/webxr-2/components/goomba.js +3250 -0
- package/examples/webxr-2/components/init-shell-material.js +215 -0
- package/examples/webxr-2/components/platter.js +172 -0
- package/examples/webxr-2/components/shell.js +374 -0
- package/examples/webxr-2/components/soccer-ball.js +250 -0
- package/examples/webxr-2/components/squashed-goomba.js +249 -0
- package/examples/webxr-2/edge-impulse-standalone.js +7228 -0
- package/examples/webxr-2/edge-impulse-standalone.wasm +0 -0
- package/examples/webxr-2/index.html +996 -0
- package/examples/webxr-2/kick.tflite +0 -0
- package/examples/webxr-2/kick2.tflite +0 -0
- package/examples/webxr-2/run-impulse.js +135 -0
- package/examples/webxr-2/script.js +384 -0
- package/package.json +2 -1
- package/src/.prettierrc +4 -0
- package/src/BS.ts +66 -9
- package/src/CameraManager.ts +499 -0
- package/src/Device.ts +620 -92
- package/src/DeviceInformationManager.ts +22 -11
- package/src/DeviceManager.ts +94 -25
- package/src/FileTransferManager.ts +146 -21
- package/src/FirmwareManager.ts +1 -1
- package/src/InformationManager.ts +62 -20
- package/src/TfliteManager.ts +172 -26
- package/src/WifiManager.ts +323 -0
- package/src/connection/BaseConnectionManager.ts +145 -30
- package/src/connection/ClientConnectionManager.ts +47 -11
- package/src/connection/bluetooth/BluetoothConnectionManager.ts +14 -3
- package/src/connection/bluetooth/NobleConnectionManager.ts +155 -42
- package/src/connection/bluetooth/WebBluetoothConnectionManager.ts +104 -35
- package/src/connection/bluetooth/bluetoothUUIDs.ts +40 -13
- package/src/connection/udp/UDPConnectionManager.ts +356 -0
- package/src/connection/websocket/WebSocketConnectionManager.ts +282 -0
- package/src/devicePair/DevicePair.ts +145 -49
- package/src/devicePair/DevicePairPressureSensorDataManager.ts +72 -24
- package/src/devicePair/DevicePairSensorDataManager.ts +5 -5
- package/src/scanner/BaseScanner.ts +49 -11
- package/src/scanner/NobleScanner.ts +81 -17
- package/src/sensor/BarometerSensorDataManager.ts +1 -1
- package/src/sensor/MotionSensorDataManager.ts +22 -7
- package/src/sensor/PressureSensorDataManager.ts +47 -13
- package/src/sensor/SensorConfigurationManager.ts +75 -24
- package/src/sensor/SensorDataManager.ts +107 -26
- package/src/server/BaseClient.ts +192 -37
- package/src/server/BaseServer.ts +201 -43
- package/src/server/ServerUtils.ts +39 -9
- package/src/server/udp/UDPServer.ts +74 -23
- package/src/server/udp/UDPUtils.ts +9 -2
- package/src/server/websocket/WebSocketClient.ts +30 -9
- package/src/server/websocket/WebSocketServer.ts +1 -1
- package/src/server/websocket/WebSocketUtils.ts +4 -2
- package/src/utils/CenterOfPressureHelper.ts +5 -5
- package/src/utils/Console.ts +62 -9
- package/src/utils/MathUtils.ts +31 -1
- package/src/utils/ParseUtils.ts +25 -6
- package/src/utils/ThrottleUtils.ts +62 -0
- package/src/utils/Timer.ts +1 -1
- package/src/utils/checksum.ts +1 -1
- package/src/utils/mcumgr.js +1 -1
- package/src/vibration/VibrationManager.ts +166 -40
|
@@ -0,0 +1,996 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<head>
|
|
3
|
+
<title>WebXR 2 | BrilliantSole JavaScript SDK</title>
|
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
5
|
+
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
|
|
6
|
+
<script src="../utils/aframe/aframe-master.min.js"></script>
|
|
7
|
+
<script src="https://cdn.jsdelivr.net/gh/c-frame/aframe-physics-system@v4.2.3/dist/aframe-physics-system.min.js"></script>
|
|
8
|
+
<script src="../utils/aframe/grabbable-physics-body.js"></script>
|
|
9
|
+
<script src="../utils/aframe/grabbable-listener.js"></script>
|
|
10
|
+
<script src="../utils/aframe/grabbable-anchor.js"></script>
|
|
11
|
+
<script src="../utils/aframe/hand-punch.js" type="module"></script>
|
|
12
|
+
<script src="../utils/aframe/occlude-hand-tracking-controls.js"></script>
|
|
13
|
+
<script src="../utils/aframe/palm-up-detector.js"></script>
|
|
14
|
+
<script src="../utils/aframe/grow-shrink.js"></script>
|
|
15
|
+
<script src="./components/platter.js"></script>
|
|
16
|
+
<script src="./components/goomba.js"></script>
|
|
17
|
+
<script src="./components/squashed-goomba.js"></script>
|
|
18
|
+
<script src="./components/coin.js"></script>
|
|
19
|
+
<script src="../utils/aframe/occlude-mesh.js"></script>
|
|
20
|
+
<script src="./components/custom-wrap.js"></script>
|
|
21
|
+
<script src="../utils/aframe/shadow-material.js"></script>
|
|
22
|
+
<script src="../utils/aframe/bs-vibration.js" type="module"></script>
|
|
23
|
+
<script src="../utils/aframe/soft-shadow-light.js"></script>
|
|
24
|
+
<script src="./components/init-shell-material.js"></script>
|
|
25
|
+
<script src="./components/bs-ankle.js" type="module"></script>
|
|
26
|
+
<script src="../utils/aframe/my-obb-collider.js"></script>
|
|
27
|
+
<script src="./components/shell.js"></script>
|
|
28
|
+
<script src="./components/soccer-ball.js"></script>
|
|
29
|
+
|
|
30
|
+
<script src="./edge-impulse-standalone.js"></script>
|
|
31
|
+
<script src="./run-impulse.js"></script>
|
|
32
|
+
<script type="module" src="./script.js"></script>
|
|
33
|
+
</head>
|
|
34
|
+
<style>
|
|
35
|
+
#scene {
|
|
36
|
+
width: 500px;
|
|
37
|
+
height: 400px;
|
|
38
|
+
margin: auto;
|
|
39
|
+
border-radius: 2rem;
|
|
40
|
+
overflow: hidden;
|
|
41
|
+
border: solid black;
|
|
42
|
+
box-sizing: border-box;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
#title {
|
|
46
|
+
margin: auto;
|
|
47
|
+
height: 70px;
|
|
48
|
+
display: flex;
|
|
49
|
+
flex-direction: row;
|
|
50
|
+
align-items: center;
|
|
51
|
+
justify-content: center;
|
|
52
|
+
|
|
53
|
+
font-size: xx-large;
|
|
54
|
+
}
|
|
55
|
+
</style>
|
|
56
|
+
<body>
|
|
57
|
+
<nav>
|
|
58
|
+
<a href="../../">home</a>
|
|
59
|
+
</nav>
|
|
60
|
+
|
|
61
|
+
<h1>WebXR 2 | BrilliantSole JavaScript SDK</h1>
|
|
62
|
+
|
|
63
|
+
<template id="connectToDeviceTemplate">
|
|
64
|
+
<div class="connectToDevice">
|
|
65
|
+
<label>
|
|
66
|
+
ip address:
|
|
67
|
+
<input
|
|
68
|
+
class="ipAddress"
|
|
69
|
+
placeholder="127.0.0.1"
|
|
70
|
+
type="text"
|
|
71
|
+
minlength="7"
|
|
72
|
+
maxlength="15"
|
|
73
|
+
size="15"
|
|
74
|
+
/>
|
|
75
|
+
</label>
|
|
76
|
+
<button class="toggleConnection">connect</button>
|
|
77
|
+
<progress hidden value="0" class="fileTransferProgress"></progress>
|
|
78
|
+
<label hidden>
|
|
79
|
+
is model ready <input type="checkbox" disabled class="isModelReady" />
|
|
80
|
+
</label>
|
|
81
|
+
<label hidden> gesture: <b class="maxClass"></b> </label>
|
|
82
|
+
</div>
|
|
83
|
+
</template>
|
|
84
|
+
|
|
85
|
+
<label hidden>
|
|
86
|
+
run model in browser
|
|
87
|
+
<input type="checkbox" id="runModelInBrowser" />
|
|
88
|
+
</label>
|
|
89
|
+
<!-- <br /> -->
|
|
90
|
+
|
|
91
|
+
<label>
|
|
92
|
+
persist entities <input type="checkbox" id="persistEntities" />
|
|
93
|
+
</label>
|
|
94
|
+
<button id="clearEntities">clear entities</button>
|
|
95
|
+
|
|
96
|
+
<div id="connectToDeviceContainers"></div>
|
|
97
|
+
|
|
98
|
+
<a-scene
|
|
99
|
+
pool__punchsound="mixin: punchSoundMixin; size: 10; dynamic: true;"
|
|
100
|
+
pool__shellhitsound="mixin: shellHitAudioMixin; size: 10; dynamic: true;"
|
|
101
|
+
pool__splatsound="mixin: splatSoundMixin; size: 5; dynamic: true;"
|
|
102
|
+
pool__coinsound="mixin: coinSoundMixin; size: 5; dynamic: true;"
|
|
103
|
+
pool__purrsound="mixin: purrSoundMixin; size: 2; dynamic: true;"
|
|
104
|
+
pool__purrsoundfadeout="mixin: purrFadeOutSoundMixin; size: 2; dynamic: true;"
|
|
105
|
+
pool__getupsound="mixin: getUpSoundMixin; size: 5; dynamic: true;"
|
|
106
|
+
pool__grabsound="mixin: grabSoundMixin; size: 2; dynamic: true;"
|
|
107
|
+
pool__releasesound="mixin: releaseSoundMixin; size: 2; dynamic: true;"
|
|
108
|
+
pool__punchsqueaksound="mixin: punchSqueakSoundMixin; size: 5; dynamic: true;"
|
|
109
|
+
pool__bounceweaksound="mixin: bounceWeakSoundMixin; size: 5; dynamic: true;"
|
|
110
|
+
pool__bouncemediumsound="mixin: bounceMediumSoundMixin; size: 5; dynamic: true;"
|
|
111
|
+
pool__bouncestrongsound="mixin: bounceStrongSoundMixin; size: 5; dynamic: true;"
|
|
112
|
+
pool__coin="mixin: coinMixin; size: 5; dynamic: true;"
|
|
113
|
+
pool__squashedgoomba="mixin: squashedGoombaMixin; size: 5; dynamic: true;"
|
|
114
|
+
id="scene"
|
|
115
|
+
light="defaultLightsEnabled: false"
|
|
116
|
+
physics="debug: false; restitution: 0.4;"
|
|
117
|
+
embedded
|
|
118
|
+
grabbable-listener
|
|
119
|
+
obb-collider="showColliders: false;"
|
|
120
|
+
xr-mode-ui="enabled: true; XRMode: ar;"
|
|
121
|
+
real-world-meshing="meshMixin: realWorldMeshMixin; meshesEnabled: true; planeMixin: realWorldPlaneMixin; planesEnabled: true; filterLabels: table, wall, desk, floor, ceiling, storage, other, plant, screen, lamp, couch, bed, screen;"
|
|
122
|
+
device-orientation-permission-ui="enabled: false"
|
|
123
|
+
>
|
|
124
|
+
<a-entity light="color: #BBB; type: ambient;"></a-entity>
|
|
125
|
+
<a-entity
|
|
126
|
+
light="type: directional; color: #FFF; intensity: 1.884; castShadow: false;"
|
|
127
|
+
position="-0.5 1 1"
|
|
128
|
+
>
|
|
129
|
+
</a-entity>
|
|
130
|
+
|
|
131
|
+
<a-assets>
|
|
132
|
+
<a-asset-item
|
|
133
|
+
id="anchorModel"
|
|
134
|
+
src="../../assets/3d/anchor.glb"
|
|
135
|
+
></a-asset-item>
|
|
136
|
+
<a-asset-item
|
|
137
|
+
id="coinModel"
|
|
138
|
+
src="../../assets/3d/coin.glb"
|
|
139
|
+
></a-asset-item>
|
|
140
|
+
<a-asset-item
|
|
141
|
+
id="soccerBallModel"
|
|
142
|
+
src="./assets/3d/soccerBall.glb"
|
|
143
|
+
></a-asset-item>
|
|
144
|
+
<a-mixin
|
|
145
|
+
id="realWorldPlaneMixin"
|
|
146
|
+
my-obb-collider
|
|
147
|
+
static-body
|
|
148
|
+
occlude-mesh
|
|
149
|
+
>
|
|
150
|
+
</a-mixin>
|
|
151
|
+
<a-mixin
|
|
152
|
+
id="realWorldMeshMixin"
|
|
153
|
+
my-obb-collider
|
|
154
|
+
static-body
|
|
155
|
+
occlude-mesh
|
|
156
|
+
visible="true"
|
|
157
|
+
></a-mixin>
|
|
158
|
+
<audio
|
|
159
|
+
id="coinAudio"
|
|
160
|
+
src="../../assets/audio/coin.wav"
|
|
161
|
+
preload="auto"
|
|
162
|
+
></audio>
|
|
163
|
+
<a-mixin
|
|
164
|
+
id="coinSoundMixin"
|
|
165
|
+
sound="src: #coinAudio; volume: 0.8;"
|
|
166
|
+
></a-mixin>
|
|
167
|
+
|
|
168
|
+
<audio
|
|
169
|
+
id="splatAudio"
|
|
170
|
+
src="../../assets/audio/splat.wav"
|
|
171
|
+
preload="auto"
|
|
172
|
+
></audio>
|
|
173
|
+
<a-mixin id="splatSoundMixin" sound="src: #splatAudio"></a-mixin>
|
|
174
|
+
|
|
175
|
+
<audio
|
|
176
|
+
id="punchAudio"
|
|
177
|
+
src="../../assets/audio/punch.wav"
|
|
178
|
+
preload="auto"
|
|
179
|
+
></audio>
|
|
180
|
+
<a-mixin id="punchSoundMixin" sound="src: #punchAudio;"></a-mixin>
|
|
181
|
+
|
|
182
|
+
<audio
|
|
183
|
+
id="purrAudio"
|
|
184
|
+
src="../../assets/audio/purr.wav"
|
|
185
|
+
preload="auto"
|
|
186
|
+
></audio>
|
|
187
|
+
<a-mixin
|
|
188
|
+
id="purrSoundMixin"
|
|
189
|
+
sound="src: #purrAudio; loop: true;"
|
|
190
|
+
></a-mixin>
|
|
191
|
+
|
|
192
|
+
<audio
|
|
193
|
+
id="purrFadeOutAudio"
|
|
194
|
+
src="../../assets/audio/purrFadeOut.wav"
|
|
195
|
+
preload="auto"
|
|
196
|
+
></audio>
|
|
197
|
+
<a-mixin
|
|
198
|
+
id="purrFadeOutSoundMixin"
|
|
199
|
+
sound="src: #purrFadeOutAudio;"
|
|
200
|
+
></a-mixin>
|
|
201
|
+
|
|
202
|
+
<audio
|
|
203
|
+
id="getUpAudio"
|
|
204
|
+
src="../../assets/audio/getUp.wav"
|
|
205
|
+
preload="auto"
|
|
206
|
+
></audio>
|
|
207
|
+
<a-mixin
|
|
208
|
+
id="getUpSoundMixin"
|
|
209
|
+
sound="src: #getUpAudio; volume: 0.5;"
|
|
210
|
+
></a-mixin>
|
|
211
|
+
|
|
212
|
+
<audio
|
|
213
|
+
id="platterFadeInAudio"
|
|
214
|
+
src="../../assets/audio/platterFadeIn.wav"
|
|
215
|
+
preload="auto"
|
|
216
|
+
></audio>
|
|
217
|
+
<audio
|
|
218
|
+
id="platterFadeOutAudio"
|
|
219
|
+
src="../../assets/audio/platterFadeOut.wav"
|
|
220
|
+
preload="auto"
|
|
221
|
+
></audio>
|
|
222
|
+
|
|
223
|
+
<audio
|
|
224
|
+
id="grabAudio"
|
|
225
|
+
src="../../assets/audio/grab.wav"
|
|
226
|
+
preload="auto"
|
|
227
|
+
></audio>
|
|
228
|
+
<a-mixin
|
|
229
|
+
id="grabSoundMixin"
|
|
230
|
+
sound="src: #grabAudio; volume: 0.2;"
|
|
231
|
+
></a-mixin>
|
|
232
|
+
|
|
233
|
+
<audio
|
|
234
|
+
id="releaseAudio"
|
|
235
|
+
src="../../assets/audio/release.wav"
|
|
236
|
+
preload="auto"
|
|
237
|
+
></audio>
|
|
238
|
+
<a-mixin
|
|
239
|
+
id="releaseSoundMixin"
|
|
240
|
+
sound="src: #releaseAudio; volume: 0.4;"
|
|
241
|
+
></a-mixin>
|
|
242
|
+
|
|
243
|
+
<audio
|
|
244
|
+
id="punchSqueakAudio"
|
|
245
|
+
src="../../assets/audio/punchSqueak.wav"
|
|
246
|
+
preload="auto"
|
|
247
|
+
></audio>
|
|
248
|
+
<a-mixin
|
|
249
|
+
id="punchSqueakSoundMixin"
|
|
250
|
+
sound="src: #punchSqueakAudio; volume: 1;"
|
|
251
|
+
></a-mixin>
|
|
252
|
+
|
|
253
|
+
<audio
|
|
254
|
+
id="bounceWeakAudio"
|
|
255
|
+
src="../../assets/audio/bounceWeak.wav"
|
|
256
|
+
preload="auto"
|
|
257
|
+
></audio>
|
|
258
|
+
<a-mixin
|
|
259
|
+
id="bounceWeakSoundMixin"
|
|
260
|
+
sound="src: #bounceWeakAudio; volume: 0.5;"
|
|
261
|
+
></a-mixin>
|
|
262
|
+
|
|
263
|
+
<audio
|
|
264
|
+
id="bounceMediumAudio"
|
|
265
|
+
src="../../assets/audio/bounceMedium.wav"
|
|
266
|
+
preload="auto"
|
|
267
|
+
></audio>
|
|
268
|
+
<a-mixin
|
|
269
|
+
id="bounceMediumSoundMixin"
|
|
270
|
+
sound="src: #bounceMediumAudio; volume: 0.5;"
|
|
271
|
+
></a-mixin>
|
|
272
|
+
|
|
273
|
+
<audio
|
|
274
|
+
id="bounceStrongAudio"
|
|
275
|
+
src="../../assets/audio/bounceStrong.wav"
|
|
276
|
+
preload="auto"
|
|
277
|
+
></audio>
|
|
278
|
+
<a-mixin
|
|
279
|
+
id="bounceStrongSoundMixin"
|
|
280
|
+
sound="src: #bounceStrongAudio; volume: 0.5;"
|
|
281
|
+
></a-mixin>
|
|
282
|
+
|
|
283
|
+
<a-mixin id="coinMixin" coin></a-mixin>
|
|
284
|
+
<a-mixin id="squashedGoombaMixin" squashed-goomba></a-mixin>
|
|
285
|
+
|
|
286
|
+
<audio
|
|
287
|
+
id="stompAudio"
|
|
288
|
+
src="../../assets/audio/stomp.wav"
|
|
289
|
+
preload="auto"
|
|
290
|
+
></audio>
|
|
291
|
+
<audio
|
|
292
|
+
id="kickAudio"
|
|
293
|
+
src="../../assets/audio/kick.wav"
|
|
294
|
+
preload="auto"
|
|
295
|
+
></audio>
|
|
296
|
+
|
|
297
|
+
<audio
|
|
298
|
+
id="shellKickAudio"
|
|
299
|
+
src="./assets/audio/shellKick.wav"
|
|
300
|
+
preload="auto"
|
|
301
|
+
></audio>
|
|
302
|
+
<audio
|
|
303
|
+
id="shellBounceAudio"
|
|
304
|
+
src="./assets/audio/shellBounce.wav"
|
|
305
|
+
preload="auto"
|
|
306
|
+
></audio>
|
|
307
|
+
|
|
308
|
+
<audio
|
|
309
|
+
id="soccerKickAudio"
|
|
310
|
+
src="./assets/audio/soccerKick.mp3"
|
|
311
|
+
preload="auto"
|
|
312
|
+
></audio>
|
|
313
|
+
<audio
|
|
314
|
+
id="soccerBounceAudio"
|
|
315
|
+
src="./assets/audio/soccerBounce.wav"
|
|
316
|
+
preload="auto"
|
|
317
|
+
></audio>
|
|
318
|
+
|
|
319
|
+
<audio
|
|
320
|
+
id="shellHitAudio"
|
|
321
|
+
src="./assets/audio/shellHit.wav"
|
|
322
|
+
preload="auto"
|
|
323
|
+
></audio>
|
|
324
|
+
<a-mixin id="shellHitAudioMixin" sound="src: #shellHitAudio;"></a-mixin>
|
|
325
|
+
|
|
326
|
+
<img id="shellTexture" src="./assets/images/shellTexture.png" />
|
|
327
|
+
</a-assets>
|
|
328
|
+
<!-- <a-entity rotation="-90 0 0" position="0 5 1">
|
|
329
|
+
<a-camera
|
|
330
|
+
class="lookAt"
|
|
331
|
+
id="camera"
|
|
332
|
+
_raycaster="objects: .raycastable; interval: 100;"
|
|
333
|
+
>
|
|
334
|
+
<a-sphere
|
|
335
|
+
color="black"
|
|
336
|
+
visible="false"
|
|
337
|
+
radius="0.001"
|
|
338
|
+
position="0 0 -0.1"
|
|
339
|
+
></a-sphere>
|
|
340
|
+
</a-camera>
|
|
341
|
+
</a-entity> -->
|
|
342
|
+
|
|
343
|
+
<a-camera
|
|
344
|
+
class="lookAt"
|
|
345
|
+
id="camera"
|
|
346
|
+
position="0 1 0"
|
|
347
|
+
_raycaster="objects: .raycastable; interval: 100;"
|
|
348
|
+
>
|
|
349
|
+
<a-text
|
|
350
|
+
visible="false"
|
|
351
|
+
id="debugText"
|
|
352
|
+
value="hello\nworld"
|
|
353
|
+
position="0 0 -0.5"
|
|
354
|
+
scale="0.5 0.5 0.5"
|
|
355
|
+
color="green"
|
|
356
|
+
align="center"
|
|
357
|
+
></a-text>
|
|
358
|
+
</a-camera>
|
|
359
|
+
|
|
360
|
+
<a-entity
|
|
361
|
+
id="anchor"
|
|
362
|
+
anchored="persistent: true"
|
|
363
|
+
position="0.2 1 -0.3"
|
|
364
|
+
grabbable
|
|
365
|
+
grabbable-anchor
|
|
366
|
+
>
|
|
367
|
+
<a-entity
|
|
368
|
+
gltf-model="#anchorModel"
|
|
369
|
+
scale="0.020 0.020 0.020"
|
|
370
|
+
rotation="90 0 0"
|
|
371
|
+
></a-entity>
|
|
372
|
+
</a-entity>
|
|
373
|
+
|
|
374
|
+
<template id="coinTemplate">
|
|
375
|
+
<a-entity>
|
|
376
|
+
<a-entity class="position">
|
|
377
|
+
<a-entity class="rotation">
|
|
378
|
+
<a-entity class="scale">
|
|
379
|
+
<a-entity
|
|
380
|
+
gltf-model="#coinModel"
|
|
381
|
+
scale="0.22 0.22 0.22"
|
|
382
|
+
></a-entity>
|
|
383
|
+
</a-entity>
|
|
384
|
+
</a-entity>
|
|
385
|
+
</a-entity>
|
|
386
|
+
</a-entity>
|
|
387
|
+
</template>
|
|
388
|
+
|
|
389
|
+
<template id="soccerTemplate">
|
|
390
|
+
<a-entity>
|
|
391
|
+
<a-entity
|
|
392
|
+
scale="0.11 0.11 0.11"
|
|
393
|
+
gltf-model="#soccerBallModel"
|
|
394
|
+
></a-entity>
|
|
395
|
+
</a-entity>
|
|
396
|
+
</template>
|
|
397
|
+
|
|
398
|
+
<!-- <a-entity soccer-ball id="soccerBall" position="0 1 -0.5"> </a-entity> -->
|
|
399
|
+
|
|
400
|
+
<template id="squashedGoombaTemplate">
|
|
401
|
+
<a-entity>
|
|
402
|
+
<a-sphere
|
|
403
|
+
class="body"
|
|
404
|
+
color="#a14e00"
|
|
405
|
+
radius="0.1"
|
|
406
|
+
scale="1 1 0.3"
|
|
407
|
+
></a-sphere>
|
|
408
|
+
|
|
409
|
+
<a-entity
|
|
410
|
+
class="eye left"
|
|
411
|
+
position="-0.02535 0.01077 0.02"
|
|
412
|
+
rotation="-11.205 -20.900 0"
|
|
413
|
+
>
|
|
414
|
+
<a-entity class="scalar" scale="1.460 1.690 0.940">
|
|
415
|
+
<a-sphere class="white" color="#fafafa" radius="0.017"></a-sphere>
|
|
416
|
+
<a-entity class="controller">
|
|
417
|
+
<a-sphere
|
|
418
|
+
class="black"
|
|
419
|
+
color="#000000"
|
|
420
|
+
position="0 0 0.015"
|
|
421
|
+
radius="0.008"
|
|
422
|
+
scale="1 1 -0.600"
|
|
423
|
+
>
|
|
424
|
+
</a-sphere>
|
|
425
|
+
</a-entity>
|
|
426
|
+
</a-entity>
|
|
427
|
+
</a-entity>
|
|
428
|
+
|
|
429
|
+
<a-sphere
|
|
430
|
+
class="left foot"
|
|
431
|
+
color="#301700"
|
|
432
|
+
radius="0.05"
|
|
433
|
+
position="-0.040 -0.070 0.020"
|
|
434
|
+
scale="0.790 1 0.400"
|
|
435
|
+
rotation="0 0 -13.900"
|
|
436
|
+
></a-sphere>
|
|
437
|
+
</a-entity>
|
|
438
|
+
</template>
|
|
439
|
+
<!--
|
|
440
|
+
<a-entity id="debugCone" visible="false" position="0 1 -1">
|
|
441
|
+
<a-cone
|
|
442
|
+
height="0.1"
|
|
443
|
+
rotation="-90 0 0"
|
|
444
|
+
radius-bottom="0.1"
|
|
445
|
+
color="green"
|
|
446
|
+
></a-cone>
|
|
447
|
+
</a-entity> -->
|
|
448
|
+
|
|
449
|
+
<!-- <a-entity
|
|
450
|
+
id="squashedGoomba1"
|
|
451
|
+
squashed-goomba
|
|
452
|
+
position="0 1.0 -0.3"
|
|
453
|
+
></a-entity> -->
|
|
454
|
+
<!--
|
|
455
|
+
<a-entity
|
|
456
|
+
goomba="grabbable: true;"
|
|
457
|
+
id="goomba1"
|
|
458
|
+
position="0 1.0 -0.3"
|
|
459
|
+
class="punchable"
|
|
460
|
+
rotation="0 0 0"
|
|
461
|
+
></a-entity> -->
|
|
462
|
+
|
|
463
|
+
<!-- <a-entity
|
|
464
|
+
goomba="grabbable: true;"
|
|
465
|
+
id="goomba2"
|
|
466
|
+
position="0 1.0 -0.6"
|
|
467
|
+
rotation="0 0 0"
|
|
468
|
+
></a-entity> -->
|
|
469
|
+
<!-- <a-box
|
|
470
|
+
scale="4 0.05 4"
|
|
471
|
+
static-body
|
|
472
|
+
rotation="0 0 0"
|
|
473
|
+
position="0 0.8 -0.5"
|
|
474
|
+
data-world-mesh="floor"
|
|
475
|
+
color="blue"
|
|
476
|
+
my-obb-collider
|
|
477
|
+
id="testFloor"
|
|
478
|
+
opacity="1"
|
|
479
|
+
></a-box> -->
|
|
480
|
+
<!-- <a-box
|
|
481
|
+
scale="1 0.05 1"
|
|
482
|
+
static-body
|
|
483
|
+
position="0 2 -0.5"
|
|
484
|
+
data-world-mesh="ceiling"
|
|
485
|
+
color="blue"
|
|
486
|
+
obb-collider
|
|
487
|
+
id="testCeiling"
|
|
488
|
+
></a-box> -->
|
|
489
|
+
<!-- <a-box
|
|
490
|
+
scale="2 2 0.05"
|
|
491
|
+
static-body
|
|
492
|
+
position="0 1 -1"
|
|
493
|
+
data-world-mesh="wall"
|
|
494
|
+
color="yellow"
|
|
495
|
+
obb-collider
|
|
496
|
+
rotation="0 0 0"
|
|
497
|
+
id="testWall"
|
|
498
|
+
visible="true"
|
|
499
|
+
></a-box> -->
|
|
500
|
+
<!-- <a-box
|
|
501
|
+
scale="2 2 0.05"
|
|
502
|
+
static-body
|
|
503
|
+
position="-1 1 0"
|
|
504
|
+
rotation="0 90 0"
|
|
505
|
+
data-world-mesh="wall"
|
|
506
|
+
color="yellow"
|
|
507
|
+
obb-collider
|
|
508
|
+
id="testLeftWall"
|
|
509
|
+
></a-box> -->
|
|
510
|
+
|
|
511
|
+
<template id="shellTemplate">
|
|
512
|
+
<a-entity scale="1.1 1.1 1.1">
|
|
513
|
+
<a-entity scale="0.86 0.85 1" class="body">
|
|
514
|
+
<a-sphere
|
|
515
|
+
rotation="-90 0 0"
|
|
516
|
+
scale="1 1 0.850"
|
|
517
|
+
radius="0.1"
|
|
518
|
+
phi-length="180"
|
|
519
|
+
segments-height="12"
|
|
520
|
+
segments-width="8"
|
|
521
|
+
repeat="0.420 0.550"
|
|
522
|
+
offset="0.040 0.160"
|
|
523
|
+
material="color: #29eb1c; src: #shellTexture; transparent: true"
|
|
524
|
+
>
|
|
525
|
+
</a-sphere>
|
|
526
|
+
<a-torus
|
|
527
|
+
radius="0.096"
|
|
528
|
+
radius-tubular="0.006"
|
|
529
|
+
rotation="90 0 0"
|
|
530
|
+
color="white"
|
|
531
|
+
position="0 -0.005 0"
|
|
532
|
+
></a-torus>
|
|
533
|
+
<a-sphere
|
|
534
|
+
rotation="90 0 0"
|
|
535
|
+
radius="0.1"
|
|
536
|
+
phi-length="180"
|
|
537
|
+
color="#e3c76b"
|
|
538
|
+
scale="1 1 0.55"
|
|
539
|
+
>
|
|
540
|
+
</a-sphere>
|
|
541
|
+
</a-entity>
|
|
542
|
+
</a-entity>
|
|
543
|
+
</template>
|
|
544
|
+
|
|
545
|
+
<a-entity
|
|
546
|
+
visible="true"
|
|
547
|
+
rotation="0 0 0"
|
|
548
|
+
position="-1 1 0"
|
|
549
|
+
id="shell"
|
|
550
|
+
shell
|
|
551
|
+
></a-entity>
|
|
552
|
+
|
|
553
|
+
<template id="goombaTemplate">
|
|
554
|
+
<a-entity>
|
|
555
|
+
<!-- <a-sphere color="green" opacity="0.1" radius="0.15"></a-sphere> -->
|
|
556
|
+
<a-sphere
|
|
557
|
+
class="pet"
|
|
558
|
+
color="black"
|
|
559
|
+
radius="0.02"
|
|
560
|
+
position="0 0.065 0"
|
|
561
|
+
visible="false"
|
|
562
|
+
></a-sphere>
|
|
563
|
+
<a-entity class="squash" position="0 -0.07 0">
|
|
564
|
+
<a-entity class="squashOffset" position="0 0.07 0">
|
|
565
|
+
<a-box
|
|
566
|
+
visible="false"
|
|
567
|
+
class="collider"
|
|
568
|
+
scale="0.2 0.18 0.18"
|
|
569
|
+
></a-box>
|
|
570
|
+
<a-sphere
|
|
571
|
+
class="body"
|
|
572
|
+
color="#a14e00"
|
|
573
|
+
radius="0.1"
|
|
574
|
+
scale="0.9 0.75 0.8"
|
|
575
|
+
>
|
|
576
|
+
</a-sphere>
|
|
577
|
+
<a-sphere
|
|
578
|
+
radius="0.30"
|
|
579
|
+
class="raycastable"
|
|
580
|
+
color="yellow"
|
|
581
|
+
visible="false"
|
|
582
|
+
opacity="0.1"
|
|
583
|
+
></a-sphere>
|
|
584
|
+
<a-entity
|
|
585
|
+
class="eye left"
|
|
586
|
+
position="-0.02535 0.01077 0.065"
|
|
587
|
+
rotation="-11.205 -20.900 0"
|
|
588
|
+
>
|
|
589
|
+
<a-entity class="scalar" scale="1.460 1.690 0.940">
|
|
590
|
+
<a-sphere
|
|
591
|
+
phi-length="180"
|
|
592
|
+
class="white"
|
|
593
|
+
color="#fafafa"
|
|
594
|
+
radius="0.017"
|
|
595
|
+
></a-sphere>
|
|
596
|
+
<a-entity class="controller">
|
|
597
|
+
<a-sphere
|
|
598
|
+
phi-start="180"
|
|
599
|
+
class="black"
|
|
600
|
+
color="#000000"
|
|
601
|
+
position="0 0 0.015"
|
|
602
|
+
radius="0.008"
|
|
603
|
+
scale="1 1 -0.600"
|
|
604
|
+
>
|
|
605
|
+
</a-sphere>
|
|
606
|
+
</a-entity>
|
|
607
|
+
</a-entity>
|
|
608
|
+
</a-entity>
|
|
609
|
+
</a-entity>
|
|
610
|
+
</a-entity>
|
|
611
|
+
<a-entity
|
|
612
|
+
class="left leg"
|
|
613
|
+
position="-0.036 -0.026 0.005"
|
|
614
|
+
rotation="0 -16.292 -8.000"
|
|
615
|
+
>
|
|
616
|
+
<a-sphere
|
|
617
|
+
class="foot"
|
|
618
|
+
color="#301700"
|
|
619
|
+
radius="0.05"
|
|
620
|
+
position="0 -0.048 0"
|
|
621
|
+
scale="0.8 0.418 1"
|
|
622
|
+
></a-sphere>
|
|
623
|
+
</a-entity>
|
|
624
|
+
</a-entity>
|
|
625
|
+
</template>
|
|
626
|
+
|
|
627
|
+
<a-entity bs-ankle id="ankle"></a-entity>
|
|
628
|
+
|
|
629
|
+
<a-entity
|
|
630
|
+
id="leftHand"
|
|
631
|
+
class="lookAt"
|
|
632
|
+
hand-tracking-controls="hand: left; model-opacity: 0;"
|
|
633
|
+
hand-tracking-grab-controls="hand: left;"
|
|
634
|
+
occlude-hand-tracking-controls
|
|
635
|
+
hand-punch
|
|
636
|
+
>
|
|
637
|
+
<a-entity
|
|
638
|
+
id="platter"
|
|
639
|
+
scale="0 0 0"
|
|
640
|
+
platter
|
|
641
|
+
rotation="200 0 -34.3"
|
|
642
|
+
position="0 -0.03 -0.07"
|
|
643
|
+
>
|
|
644
|
+
<a-cylinder color="grey" height="0.01" radius="0.15"></a-cylinder>
|
|
645
|
+
</a-entity>
|
|
646
|
+
</a-entity>
|
|
647
|
+
<a-entity
|
|
648
|
+
id="rightHand"
|
|
649
|
+
hand-punch
|
|
650
|
+
bs-vibration
|
|
651
|
+
class="lookAt"
|
|
652
|
+
hand-tracking-controls="hand: right;"
|
|
653
|
+
occlude-hand-tracking-controls
|
|
654
|
+
hand-tracking-grab-controls="hand: right;"
|
|
655
|
+
></a-entity>
|
|
656
|
+
</a-scene>
|
|
657
|
+
</body>
|
|
658
|
+
<script>
|
|
659
|
+
const scene = document.querySelector("a-scene");
|
|
660
|
+
let useShadows = false;
|
|
661
|
+
if (useShadows) {
|
|
662
|
+
scene.addEventListener("loaded", () => {
|
|
663
|
+
return;
|
|
664
|
+
setTimeout(() => {
|
|
665
|
+
const lights = Array.from(document.querySelectorAll("[light]"));
|
|
666
|
+
console.log(lights);
|
|
667
|
+
lights.forEach((light) => {
|
|
668
|
+
if (light.getAttribute("light").type != "ambient") {
|
|
669
|
+
console.log(light.getAttribute("light").type);
|
|
670
|
+
light.setAttribute("light", { castShadow: true });
|
|
671
|
+
}
|
|
672
|
+
});
|
|
673
|
+
}, 1);
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
let goombasTest = false;
|
|
678
|
+
let goombasTestSize = 3;
|
|
679
|
+
|
|
680
|
+
for (let i = 0; i < (goombasTest ? 10 : 0); i++) {
|
|
681
|
+
const goomba = document.createElement("a-entity");
|
|
682
|
+
goomba.setAttribute("goomba", "");
|
|
683
|
+
goomba.setAttribute(
|
|
684
|
+
"position",
|
|
685
|
+
`${Math.random() * goombasTestSize - goombasTestSize / 2} 1.1 ${
|
|
686
|
+
Math.random() * goombasTestSize - goombasTestSize / 2 - 0.5
|
|
687
|
+
}`
|
|
688
|
+
);
|
|
689
|
+
goomba.setAttribute("rotation", `0 ${Math.random() * 360} 0`);
|
|
690
|
+
scene.appendChild(goomba);
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
if (goombasTest) {
|
|
694
|
+
scene.addEventListener("loaded", () => {
|
|
695
|
+
goombas.forEach((goomba) => {
|
|
696
|
+
goomba.updatePhysicsEnabled(true);
|
|
697
|
+
goomba.setStatus("falling");
|
|
698
|
+
});
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
const persistEntitiesKey = "webxr-2-persist";
|
|
703
|
+
const persistedEntitiesKey = "webxr-2-entities";
|
|
704
|
+
const persistEntitiesCheckbox = document.getElementById("persistEntities");
|
|
705
|
+
persistEntitiesCheckbox.addEventListener("input", () => {
|
|
706
|
+
if (persistEntitiesCheckbox.checked) {
|
|
707
|
+
localStorage.setItem(persistEntitiesKey, "");
|
|
708
|
+
} else {
|
|
709
|
+
localStorage.removeItem(persistEntitiesKey);
|
|
710
|
+
localStorage.removeItem(persistedEntitiesKey);
|
|
711
|
+
}
|
|
712
|
+
});
|
|
713
|
+
const anchor = document.getElementById("anchor");
|
|
714
|
+
const waitForAnchor = async () => {
|
|
715
|
+
return new Promise((resolve) => {
|
|
716
|
+
let intervalId, timeoutId;
|
|
717
|
+
intervalId = setInterval(() => {
|
|
718
|
+
if (anchor.components["anchored"]?.anchor) {
|
|
719
|
+
clearTimeout(timeoutId);
|
|
720
|
+
clearInterval(intervalId);
|
|
721
|
+
resolve(true);
|
|
722
|
+
}
|
|
723
|
+
}, 200);
|
|
724
|
+
|
|
725
|
+
timeoutId = setTimeout(() => {
|
|
726
|
+
clearInterval(intervalId);
|
|
727
|
+
console.log("no anchor found");
|
|
728
|
+
resolve(false);
|
|
729
|
+
}, 3000);
|
|
730
|
+
});
|
|
731
|
+
};
|
|
732
|
+
const saveEntities = () => {
|
|
733
|
+
let transforms = [];
|
|
734
|
+
const relativeMatrix = new THREE.Matrix4();
|
|
735
|
+
const inverseRelativeMatrix = new THREE.Matrix4()
|
|
736
|
+
.copy(anchor.object3D.matrixWorld)
|
|
737
|
+
.invert();
|
|
738
|
+
const relativePosition = new THREE.Vector3();
|
|
739
|
+
const relativeQuaternion = new THREE.Quaternion();
|
|
740
|
+
const relativeScale = new THREE.Vector3();
|
|
741
|
+
window.goombas.forEach((goomba) => {
|
|
742
|
+
// don't save entites that weren't created from the platter
|
|
743
|
+
if (goomba.el.id || goomba.el.platter) {
|
|
744
|
+
return;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
relativeMatrix.multiplyMatrices(
|
|
748
|
+
inverseRelativeMatrix,
|
|
749
|
+
goomba.el.object3D.matrixWorld
|
|
750
|
+
);
|
|
751
|
+
|
|
752
|
+
relativeMatrix.decompose(
|
|
753
|
+
relativePosition,
|
|
754
|
+
relativeQuaternion,
|
|
755
|
+
relativeScale
|
|
756
|
+
);
|
|
757
|
+
|
|
758
|
+
const transform = {
|
|
759
|
+
position: relativePosition.toArray(),
|
|
760
|
+
quaternion: relativeQuaternion.toArray(),
|
|
761
|
+
scale: relativeScale.toArray(),
|
|
762
|
+
};
|
|
763
|
+
console.log("saving transform", transform);
|
|
764
|
+
transforms.push(transform);
|
|
765
|
+
});
|
|
766
|
+
console.log("saving transforms", transforms);
|
|
767
|
+
localStorage.setItem(persistedEntitiesKey, JSON.stringify(transforms));
|
|
768
|
+
};
|
|
769
|
+
window.addEventListener("beforeunload", () => {
|
|
770
|
+
if (persistEntitiesCheckbox.checked) {
|
|
771
|
+
saveEntities();
|
|
772
|
+
}
|
|
773
|
+
});
|
|
774
|
+
const loadEntities = async () => {
|
|
775
|
+
const hasAnchor = await waitForAnchor();
|
|
776
|
+
if (!hasAnchor) {
|
|
777
|
+
console.log("no anchor found");
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
780
|
+
const entityTransformsString = localStorage.getItem(persistedEntitiesKey);
|
|
781
|
+
if (!entityTransformsString) {
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
784
|
+
try {
|
|
785
|
+
const entityTransforms = JSON.parse(entityTransformsString);
|
|
786
|
+
|
|
787
|
+
const relativePosition = new THREE.Vector3();
|
|
788
|
+
const relativeQuaternion = new THREE.Quaternion();
|
|
789
|
+
const relativeScale = new THREE.Vector3();
|
|
790
|
+
|
|
791
|
+
const worldPosition = new THREE.Vector3();
|
|
792
|
+
const worldQuaternion = new THREE.Quaternion();
|
|
793
|
+
const worldScale = new THREE.Vector3();
|
|
794
|
+
|
|
795
|
+
const localMatrix = new THREE.Matrix4();
|
|
796
|
+
const referenceMatrix = new THREE.Matrix4().copy(
|
|
797
|
+
anchor.object3D.matrixWorld
|
|
798
|
+
);
|
|
799
|
+
const worldMatrix = new THREE.Matrix4();
|
|
800
|
+
|
|
801
|
+
entityTransforms.forEach((entityTransform) => {
|
|
802
|
+
console.log("entityTransform", entityTransform);
|
|
803
|
+
|
|
804
|
+
const {
|
|
805
|
+
position: positionArray,
|
|
806
|
+
quaternion: quaternionArray,
|
|
807
|
+
scale: scaleArray,
|
|
808
|
+
} = entityTransform;
|
|
809
|
+
relativePosition.set(...positionArray);
|
|
810
|
+
relativeQuaternion.set(...quaternionArray);
|
|
811
|
+
relativeScale.set(...scaleArray);
|
|
812
|
+
|
|
813
|
+
localMatrix.compose(
|
|
814
|
+
relativePosition,
|
|
815
|
+
relativeQuaternion,
|
|
816
|
+
relativeScale
|
|
817
|
+
);
|
|
818
|
+
worldMatrix.multiplyMatrices(referenceMatrix, localMatrix);
|
|
819
|
+
worldMatrix.decompose(worldPosition, worldQuaternion, worldScale);
|
|
820
|
+
|
|
821
|
+
const goomba = document.createElement("a-entity");
|
|
822
|
+
// goomba.setAttribute("position", worldPosition.toArray().join(" "));
|
|
823
|
+
// goomba.setAttribute("scale", worldScale.join(" "));
|
|
824
|
+
goomba.classList.add("punchable");
|
|
825
|
+
goomba.setAttribute("visible", "false");
|
|
826
|
+
goomba.setAttribute("goomba", "physics: true; grabbable: true;");
|
|
827
|
+
|
|
828
|
+
const position = worldPosition.clone();
|
|
829
|
+
const quaternion = worldQuaternion.clone();
|
|
830
|
+
const scalar = worldScale.clone();
|
|
831
|
+
goomba.addEventListener(
|
|
832
|
+
"goomba-loaded",
|
|
833
|
+
() => {
|
|
834
|
+
goomba.object3D.position.copy(position);
|
|
835
|
+
//goomba.object3D.scale.copy(scale);
|
|
836
|
+
goomba.object3D.quaternion.copy(quaternion);
|
|
837
|
+
goomba.object3D.visible = true;
|
|
838
|
+
goomba.object3D.position.y += 0.05;
|
|
839
|
+
goomba.components["goomba"].setPhysicsEnabled(true);
|
|
840
|
+
goomba.components["goomba"].setStatus("falling");
|
|
841
|
+
},
|
|
842
|
+
{ once: true }
|
|
843
|
+
);
|
|
844
|
+
scene.appendChild(goomba);
|
|
845
|
+
});
|
|
846
|
+
} catch (error) {
|
|
847
|
+
console.error("error parsing persisted entities", error);
|
|
848
|
+
}
|
|
849
|
+
};
|
|
850
|
+
|
|
851
|
+
scene.addEventListener(
|
|
852
|
+
"enter-vr",
|
|
853
|
+
() => {
|
|
854
|
+
loadEntities();
|
|
855
|
+
anchor.setAttribute("visible", "true");
|
|
856
|
+
},
|
|
857
|
+
{ once: true }
|
|
858
|
+
);
|
|
859
|
+
if (localStorage.getItem(persistEntitiesKey) != undefined) {
|
|
860
|
+
persistEntitiesCheckbox.checked = true;
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
const clearEntitiesButton = document.getElementById("clearEntities");
|
|
864
|
+
clearEntitiesButton.addEventListener("click", () => {
|
|
865
|
+
window.goombas.forEach((goomba) => {
|
|
866
|
+
if (goomba.el.id || goomba.el.platter) {
|
|
867
|
+
return;
|
|
868
|
+
}
|
|
869
|
+
goomba.el.remove();
|
|
870
|
+
});
|
|
871
|
+
saveEntities();
|
|
872
|
+
});
|
|
873
|
+
|
|
874
|
+
let worldMeshes = [];
|
|
875
|
+
const waitForWorldMeshes = async () => {
|
|
876
|
+
return new Promise((resolve) => {
|
|
877
|
+
let intervalId, timeoutId;
|
|
878
|
+
intervalId = setInterval(() => {
|
|
879
|
+
worldMeshes = Array.from(
|
|
880
|
+
scene.querySelectorAll(
|
|
881
|
+
"[data-world-mesh][mixin='realWorldMeshMixin']"
|
|
882
|
+
)
|
|
883
|
+
);
|
|
884
|
+
if (worldMeshes.length > 0) {
|
|
885
|
+
console.log("worldMeshes", worldMeshes);
|
|
886
|
+
clearTimeout(timeoutId);
|
|
887
|
+
clearInterval(intervalId);
|
|
888
|
+
resolve(true);
|
|
889
|
+
}
|
|
890
|
+
}, 200);
|
|
891
|
+
|
|
892
|
+
timeoutId = setTimeout(() => {
|
|
893
|
+
clearInterval(intervalId);
|
|
894
|
+
console.log("no world meshes found");
|
|
895
|
+
resolve(false);
|
|
896
|
+
}, 3000);
|
|
897
|
+
});
|
|
898
|
+
};
|
|
899
|
+
let planeMeshes = [];
|
|
900
|
+
const waitForPlaneMeshes = async () => {
|
|
901
|
+
return new Promise((resolve) => {
|
|
902
|
+
let intervalId, timeoutId;
|
|
903
|
+
intervalId = setInterval(() => {
|
|
904
|
+
planeMeshes = Array.from(
|
|
905
|
+
scene.querySelectorAll(
|
|
906
|
+
"[data-world-mesh][mixin='realWorldPlaneMixin']"
|
|
907
|
+
)
|
|
908
|
+
);
|
|
909
|
+
if (planeMeshes.length > 0) {
|
|
910
|
+
console.log("planeMeshes", planeMeshes);
|
|
911
|
+
clearTimeout(timeoutId);
|
|
912
|
+
clearInterval(intervalId);
|
|
913
|
+
resolve(true);
|
|
914
|
+
}
|
|
915
|
+
}, 200);
|
|
916
|
+
|
|
917
|
+
timeoutId = setTimeout(() => {
|
|
918
|
+
clearInterval(intervalId);
|
|
919
|
+
console.log("no plane meshes found");
|
|
920
|
+
resolve(false);
|
|
921
|
+
}, 3000);
|
|
922
|
+
});
|
|
923
|
+
};
|
|
924
|
+
const fixWorldMeshes = async () => {
|
|
925
|
+
await Promise.all([waitForPlaneMeshes(), waitForWorldMeshes()]);
|
|
926
|
+
const surfaces = ["table"];
|
|
927
|
+
setTimeout(() => {
|
|
928
|
+
planeMeshes
|
|
929
|
+
.filter((entity) => surfaces.includes(entity.dataset.worldMesh))
|
|
930
|
+
.forEach((planeMesh) => {
|
|
931
|
+
const similarMesh = worldMeshes
|
|
932
|
+
.filter(
|
|
933
|
+
(worldMesh) =>
|
|
934
|
+
worldMesh.dataset.worldMesh == planeMesh.dataset.worldMesh
|
|
935
|
+
)
|
|
936
|
+
.find((worldMesh) => {
|
|
937
|
+
const obbA = worldMesh.components["my-obb-collider"].obb;
|
|
938
|
+
const obbB = planeMesh.components["my-obb-collider"].obb;
|
|
939
|
+
// console.log("comparing", obbA, "with", obbB);
|
|
940
|
+
if (obbA.center.distanceTo(obbB.center) < 0.1) {
|
|
941
|
+
return true;
|
|
942
|
+
}
|
|
943
|
+
if (obbA.intersectsOBB(obbB)) {
|
|
944
|
+
return true;
|
|
945
|
+
}
|
|
946
|
+
return false;
|
|
947
|
+
});
|
|
948
|
+
if (!similarMesh) {
|
|
949
|
+
return;
|
|
950
|
+
}
|
|
951
|
+
if (true) {
|
|
952
|
+
// console.log("removing plane", planeMesh);
|
|
953
|
+
if (true) {
|
|
954
|
+
planeMesh.remove();
|
|
955
|
+
} else {
|
|
956
|
+
planeMesh.removeAttribute("static-body");
|
|
957
|
+
planeMesh.removeAttribute("my-obb-collider");
|
|
958
|
+
}
|
|
959
|
+
planeMesh.shouldRemove = true;
|
|
960
|
+
}
|
|
961
|
+
});
|
|
962
|
+
|
|
963
|
+
planeMeshes = planeMeshes.filter(
|
|
964
|
+
(planeMesh) => !planeMesh.shouldRemove
|
|
965
|
+
);
|
|
966
|
+
|
|
967
|
+
if (useShadows) {
|
|
968
|
+
[...planeMeshes, ...worldMeshes].forEach((entity) => {
|
|
969
|
+
entity.setAttribute("shadow", "cast: false; receive: true;");
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
scene.emit("world-meshes", { planeMeshes, worldMeshes });
|
|
973
|
+
}, 10);
|
|
974
|
+
};
|
|
975
|
+
scene.addEventListener(
|
|
976
|
+
"enter-vr",
|
|
977
|
+
() => {
|
|
978
|
+
fixWorldMeshes();
|
|
979
|
+
},
|
|
980
|
+
{ once: true }
|
|
981
|
+
);
|
|
982
|
+
</script>
|
|
983
|
+
|
|
984
|
+
<script>
|
|
985
|
+
if (false)
|
|
986
|
+
setTimeout(() => {
|
|
987
|
+
goombas[0].setPhysicsEnabled(true);
|
|
988
|
+
goombas[0].setStatus("falling");
|
|
989
|
+
}, 100);
|
|
990
|
+
|
|
991
|
+
if (false)
|
|
992
|
+
setTimeout(() => {
|
|
993
|
+
shell.setAttribute("dynamic-body", "");
|
|
994
|
+
}, 200);
|
|
995
|
+
</script>
|
|
996
|
+
</html>
|