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
package/examples/3d/scene.html
CHANGED
|
@@ -22,8 +22,14 @@
|
|
|
22
22
|
renderer="colorManagement: true;"
|
|
23
23
|
>
|
|
24
24
|
<a-assets>
|
|
25
|
-
<a-asset-item
|
|
26
|
-
|
|
25
|
+
<a-asset-item
|
|
26
|
+
id="leftInsole"
|
|
27
|
+
src="../../assets/3d/leftInsole.glb"
|
|
28
|
+
></a-asset-item>
|
|
29
|
+
<a-asset-item
|
|
30
|
+
id="rightInsole"
|
|
31
|
+
src="../../assets/3d/rightInsole.glb"
|
|
32
|
+
></a-asset-item>
|
|
27
33
|
</a-assets>
|
|
28
34
|
<a-light type="directional" position="2 2 -2" target=".target"></a-light>
|
|
29
35
|
<a-light type="directional" position="-2 2 2" target=".target"></a-light>
|
|
@@ -51,7 +57,11 @@
|
|
|
51
57
|
<a-entity class="target">
|
|
52
58
|
<a-entity class="rotation">
|
|
53
59
|
<a-entity class="position" position="0 0 0.005">
|
|
54
|
-
<a-entity
|
|
60
|
+
<a-entity
|
|
61
|
+
class="insole"
|
|
62
|
+
gltf-model="#rightInsole"
|
|
63
|
+
visible="true"
|
|
64
|
+
></a-entity>
|
|
55
65
|
</a-entity>
|
|
56
66
|
</a-entity>
|
|
57
67
|
</a-entity>
|
|
@@ -65,8 +75,12 @@
|
|
|
65
75
|
const isDark = params.has("dark");
|
|
66
76
|
if (isDark) {
|
|
67
77
|
document.querySelector("a-sky").setAttribute("color", "black");
|
|
68
|
-
document
|
|
69
|
-
|
|
78
|
+
document
|
|
79
|
+
.querySelector("a-camera")
|
|
80
|
+
.setAttribute("orbit-controls", "enableRotate", "false");
|
|
81
|
+
document
|
|
82
|
+
.querySelector("a-camera")
|
|
83
|
+
.setAttribute("orbit-controls", "enableRotate", "false");
|
|
70
84
|
document.querySelector("a-camera").setAttribute("position", "0 0 1");
|
|
71
85
|
}
|
|
72
86
|
};
|
package/examples/3d/script.js
CHANGED
|
@@ -70,7 +70,7 @@ addDeviceButton.addEventListener("click", () => {
|
|
|
70
70
|
BS.Device.Connect();
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
-
const devicePair = BS.DevicePair.
|
|
73
|
+
const devicePair = BS.DevicePair.insoles;
|
|
74
74
|
devicePair.addEventListener("isConnected", () => {
|
|
75
75
|
addDeviceButton.disabled = devicePair.isConnected;
|
|
76
76
|
});
|
|
@@ -83,7 +83,7 @@ const insoleTemplate = document.getElementById("insoleTemplate");
|
|
|
83
83
|
|
|
84
84
|
window.sensorRate = 20;
|
|
85
85
|
window.interpolationSmoothing = 0.4;
|
|
86
|
-
window.positionScalar = 0.
|
|
86
|
+
window.positionScalar = 0.1;
|
|
87
87
|
|
|
88
88
|
devicePair.sides.forEach((side) => {
|
|
89
89
|
/** @type {HTMLElement} */
|
|
@@ -122,7 +122,7 @@ function onIFrameLoaded(insoleContainer) {
|
|
|
122
122
|
});
|
|
123
123
|
devicePair.addEventListener("deviceIsConnected", (event) => {
|
|
124
124
|
const device = event.message.device;
|
|
125
|
-
if (device.
|
|
125
|
+
if (device.side != side) {
|
|
126
126
|
return;
|
|
127
127
|
}
|
|
128
128
|
|
|
@@ -134,7 +134,7 @@ function onIFrameLoaded(insoleContainer) {
|
|
|
134
134
|
|
|
135
135
|
devicePair.addEventListener("deviceConnectionStatus", (event) => {
|
|
136
136
|
const device = event.message.device;
|
|
137
|
-
if (device.
|
|
137
|
+
if (device.side != side) {
|
|
138
138
|
return;
|
|
139
139
|
}
|
|
140
140
|
|
|
@@ -188,7 +188,7 @@ function onIFrameLoaded(insoleContainer) {
|
|
|
188
188
|
});
|
|
189
189
|
devicePair.addEventListener("deviceIsConnected", (event) => {
|
|
190
190
|
const device = event.message.device;
|
|
191
|
-
if (device.
|
|
191
|
+
if (device.side != side) {
|
|
192
192
|
return;
|
|
193
193
|
}
|
|
194
194
|
|
|
@@ -224,7 +224,7 @@ function onIFrameLoaded(insoleContainer) {
|
|
|
224
224
|
});
|
|
225
225
|
devicePair.addEventListener("deviceIsConnected", (event) => {
|
|
226
226
|
const device = event.message.device;
|
|
227
|
-
if (device.
|
|
227
|
+
if (device.side != side) {
|
|
228
228
|
return;
|
|
229
229
|
}
|
|
230
230
|
|
|
@@ -234,7 +234,7 @@ function onIFrameLoaded(insoleContainer) {
|
|
|
234
234
|
|
|
235
235
|
devicePair.addEventListener("deviceGetSensorConfiguration", (event) => {
|
|
236
236
|
const device = event.message.device;
|
|
237
|
-
if (device.
|
|
237
|
+
if (device.side != side) {
|
|
238
238
|
return;
|
|
239
239
|
}
|
|
240
240
|
|
|
@@ -276,7 +276,7 @@ function onIFrameLoaded(insoleContainer) {
|
|
|
276
276
|
|
|
277
277
|
devicePair.addEventListener("deviceAcceleration", (event) => {
|
|
278
278
|
const device = event.message.device;
|
|
279
|
-
if (device.
|
|
279
|
+
if (device.side != side) {
|
|
280
280
|
return;
|
|
281
281
|
}
|
|
282
282
|
const acceleration = event.message.acceleration;
|
|
@@ -284,7 +284,7 @@ function onIFrameLoaded(insoleContainer) {
|
|
|
284
284
|
});
|
|
285
285
|
devicePair.addEventListener("deviceGravity", (event) => {
|
|
286
286
|
const device = event.message.device;
|
|
287
|
-
if (device.
|
|
287
|
+
if (device.side != side) {
|
|
288
288
|
return;
|
|
289
289
|
}
|
|
290
290
|
|
|
@@ -293,7 +293,7 @@ function onIFrameLoaded(insoleContainer) {
|
|
|
293
293
|
});
|
|
294
294
|
devicePair.addEventListener("deviceLinearAcceleration", (event) => {
|
|
295
295
|
const device = event.message.device;
|
|
296
|
-
if (device.
|
|
296
|
+
if (device.side != side) {
|
|
297
297
|
return;
|
|
298
298
|
}
|
|
299
299
|
|
|
@@ -325,22 +325,20 @@ function onIFrameLoaded(insoleContainer) {
|
|
|
325
325
|
};
|
|
326
326
|
devicePair.addEventListener("deviceGameRotation", (event) => {
|
|
327
327
|
const device = event.message.device;
|
|
328
|
-
if (device.
|
|
328
|
+
if (device.side != side) {
|
|
329
329
|
return;
|
|
330
330
|
}
|
|
331
331
|
|
|
332
|
-
|
|
333
|
-
//permuteQuaternion(gameRotation);
|
|
332
|
+
let gameRotation = event.message.gameRotation;
|
|
334
333
|
updateQuaternion(gameRotation, true);
|
|
335
334
|
});
|
|
336
335
|
devicePair.addEventListener("deviceRotation", (event) => {
|
|
337
336
|
const device = event.message.device;
|
|
338
|
-
if (device.
|
|
337
|
+
if (device.side != side) {
|
|
339
338
|
return;
|
|
340
339
|
}
|
|
341
340
|
|
|
342
341
|
const rotation = event.message.rotation;
|
|
343
|
-
//permuteQuaternion(rotation);
|
|
344
342
|
updateQuaternion(rotation, true);
|
|
345
343
|
});
|
|
346
344
|
|
|
@@ -352,7 +350,7 @@ function onIFrameLoaded(insoleContainer) {
|
|
|
352
350
|
const orientationQuaternion = new THREE.Quaternion();
|
|
353
351
|
devicePair.addEventListener("deviceOrientation", (event) => {
|
|
354
352
|
const device = event.message.device;
|
|
355
|
-
if (device.
|
|
353
|
+
if (device.side != side) {
|
|
356
354
|
return;
|
|
357
355
|
}
|
|
358
356
|
|
|
@@ -371,7 +369,7 @@ function onIFrameLoaded(insoleContainer) {
|
|
|
371
369
|
const gyroscopeQuaternion = new THREE.Quaternion();
|
|
372
370
|
devicePair.addEventListener("deviceGyroscope", (event) => {
|
|
373
371
|
const device = event.message.device;
|
|
374
|
-
if (device.
|
|
372
|
+
if (device.side != side) {
|
|
375
373
|
return;
|
|
376
374
|
}
|
|
377
375
|
|
|
@@ -408,3 +406,78 @@ websocketClient.addEventListener("connectionStatus", () => {
|
|
|
408
406
|
}
|
|
409
407
|
toggleServerConnectionButton.disabled = disabled;
|
|
410
408
|
});
|
|
409
|
+
|
|
410
|
+
// /**
|
|
411
|
+
// *
|
|
412
|
+
// * @param {BS.Quaternion} quaternion
|
|
413
|
+
// * @returns {BS.Quaternion}
|
|
414
|
+
// */
|
|
415
|
+
// function permuteQuaternion(quaternion) {
|
|
416
|
+
// const newQuaternion = {};
|
|
417
|
+
// const permutation = permutations[permutationIndex];
|
|
418
|
+
// const components = ["x", "y", "z", "w"];
|
|
419
|
+
// permutation.forEach((_index, toIndex) => {
|
|
420
|
+
// const fromIndex = Math.abs(_index) - 1;
|
|
421
|
+
// const sign = Math.sign(_index);
|
|
422
|
+
// newQuaternion[components[toIndex]] = sign * quaternion[components[fromIndex]];
|
|
423
|
+
// });
|
|
424
|
+
// return newQuaternion;
|
|
425
|
+
// }
|
|
426
|
+
|
|
427
|
+
// function generateSignedPermutations(arr) {
|
|
428
|
+
// function permute(nums, start = 0, result = []) {
|
|
429
|
+
// if (start === nums.length) {
|
|
430
|
+
// result.push([...nums]);
|
|
431
|
+
// return;
|
|
432
|
+
// }
|
|
433
|
+
// for (let i = start; i < nums.length; i++) {
|
|
434
|
+
// [nums[start], nums[i]] = [nums[i], nums[start]];
|
|
435
|
+
// permute(nums, start + 1, result);
|
|
436
|
+
// [nums[start], nums[i]] = [nums[i], nums[start]]; // backtrack
|
|
437
|
+
// }
|
|
438
|
+
// return result;
|
|
439
|
+
// }
|
|
440
|
+
|
|
441
|
+
// function generateSigns(permutation, index = 0, result = []) {
|
|
442
|
+
// if (index === permutation.length) {
|
|
443
|
+
// result.push([...permutation]);
|
|
444
|
+
// return;
|
|
445
|
+
// }
|
|
446
|
+
// permutation[index] = Math.abs(permutation[index]);
|
|
447
|
+
// generateSigns(permutation, index + 1, result);
|
|
448
|
+
// permutation[index] = -permutation[index];
|
|
449
|
+
// generateSigns(permutation, index + 1, result);
|
|
450
|
+
// return result;
|
|
451
|
+
// }
|
|
452
|
+
|
|
453
|
+
// let permutations = permute(arr);
|
|
454
|
+
// let signedPermutations = [];
|
|
455
|
+
// for (let perm of permutations) {
|
|
456
|
+
// signedPermutations.push(...generateSigns(perm));
|
|
457
|
+
// }
|
|
458
|
+
// return signedPermutations;
|
|
459
|
+
// }
|
|
460
|
+
|
|
461
|
+
// const permutations = generateSignedPermutations([1, 2, 3, 4]);
|
|
462
|
+
// console.log("permutations", permutations);
|
|
463
|
+
|
|
464
|
+
// let permutationIndex = 0;
|
|
465
|
+
// window.setPermutationIndex = (newPermutationIndex) => {
|
|
466
|
+
// permutationIndex = newPermutationIndex % permutations.length;
|
|
467
|
+
// console.log({ permutationIndex }, permutations[permutationIndex]);
|
|
468
|
+
// };
|
|
469
|
+
|
|
470
|
+
// document.addEventListener("keydown", (event) => {
|
|
471
|
+
// switch (event.key) {
|
|
472
|
+
// case "ArrowDown":
|
|
473
|
+
// if (permutationIndex > 0) {
|
|
474
|
+
// window.setPermutationIndex(permutationIndex - 1);
|
|
475
|
+
// }
|
|
476
|
+
// event.preventDefault();
|
|
477
|
+
// break;
|
|
478
|
+
// case "ArrowUp":
|
|
479
|
+
// window.setPermutationIndex(permutationIndex + 1);
|
|
480
|
+
// event.preventDefault();
|
|
481
|
+
// break;
|
|
482
|
+
// }
|
|
483
|
+
// });
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<head>
|
|
3
|
+
<title>3D | 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="https://aframe.io/releases/1.5.0/aframe.min.js"></script> -->
|
|
7
|
+
<script src="https://aframe.io/releases/1.6.0/aframe.min.js"></script>
|
|
8
|
+
<!-- required to get aframe-orbit-controls-component to work -->
|
|
9
|
+
<script>
|
|
10
|
+
THREE.Quaternion.prototype.inverse = THREE.Quaternion.prototype.invert;
|
|
11
|
+
THREE.Math = THREE.MathUtils;
|
|
12
|
+
</script>
|
|
13
|
+
<!-- https://github.com/tizzle/aframe-orbit-controls-component -->
|
|
14
|
+
<script src="https://cdn.rawgit.com/tizzle/aframe-orbit-controls-component/v0.1.14/dist/aframe-orbit-controls-component.min.js"></script>
|
|
15
|
+
<script type="module" src="./script.js"></script>
|
|
16
|
+
</head>
|
|
17
|
+
|
|
18
|
+
<style>
|
|
19
|
+
a-scene {
|
|
20
|
+
width: 500px;
|
|
21
|
+
height: 500px;
|
|
22
|
+
margin: auto;
|
|
23
|
+
border-radius: 2rem;
|
|
24
|
+
overflow: hidden;
|
|
25
|
+
border: solid black;
|
|
26
|
+
box-sizing: border-box;
|
|
27
|
+
}
|
|
28
|
+
</style>
|
|
29
|
+
|
|
30
|
+
<body>
|
|
31
|
+
<nav>
|
|
32
|
+
<a href="../../">home</a>
|
|
33
|
+
</nav>
|
|
34
|
+
|
|
35
|
+
<h1>3D (generic) | BrilliantSole JavaScript SDK</h1>
|
|
36
|
+
|
|
37
|
+
<button id="toggleConnection">connect</button>
|
|
38
|
+
|
|
39
|
+
<p>
|
|
40
|
+
<select class="orientation" disabled>
|
|
41
|
+
<optgroup label="orientation">
|
|
42
|
+
<option value="none">no orientation</option>
|
|
43
|
+
<option>gameRotation</option>
|
|
44
|
+
<option>rotation</option>
|
|
45
|
+
<option>orientation</option>
|
|
46
|
+
<option>gyroscope</option>
|
|
47
|
+
</optgroup>
|
|
48
|
+
</select>
|
|
49
|
+
<button disabled class="resetOrientation">reset orientation</button>
|
|
50
|
+
<br />
|
|
51
|
+
<select class="position" disabled>
|
|
52
|
+
<optgroup label="position">
|
|
53
|
+
<option value="none">no position</option>
|
|
54
|
+
<option>acceleration</option>
|
|
55
|
+
<option>gravity</option>
|
|
56
|
+
<option>linearAcceleration</option>
|
|
57
|
+
</optgroup>
|
|
58
|
+
</select>
|
|
59
|
+
</p>
|
|
60
|
+
|
|
61
|
+
<a-scene
|
|
62
|
+
embedded
|
|
63
|
+
xr-mode-ui="enabled: false;"
|
|
64
|
+
device-orientation-permission-ui="enabled: false"
|
|
65
|
+
renderer="colorManagement: true;"
|
|
66
|
+
>
|
|
67
|
+
<a-assets>
|
|
68
|
+
<a-asset-item
|
|
69
|
+
id="leftInsoleModel"
|
|
70
|
+
src="../../assets/3d/leftInsole.glb"
|
|
71
|
+
></a-asset-item>
|
|
72
|
+
<a-asset-item
|
|
73
|
+
id="rightInsoleModel"
|
|
74
|
+
src="../../assets/3d/rightInsole.glb"
|
|
75
|
+
></a-asset-item>
|
|
76
|
+
<a-asset-item
|
|
77
|
+
id="rightHandModel"
|
|
78
|
+
src="../../assets/3d/rightHand.glb"
|
|
79
|
+
></a-asset-item>
|
|
80
|
+
<a-asset-item
|
|
81
|
+
id="glassesModel"
|
|
82
|
+
src="../../assets/3d/glasses.glb"
|
|
83
|
+
></a-asset-item>
|
|
84
|
+
</a-assets>
|
|
85
|
+
<a-light type="directional" position="2 2 -2" target=".target"></a-light>
|
|
86
|
+
<a-light type="directional" position="-2 2 2" target=".target"></a-light>
|
|
87
|
+
<a-light type="directional" position="2 -2 2" target=".target"></a-light>
|
|
88
|
+
|
|
89
|
+
<a-entity light="color: #BBB; type: ambient;"></a-entity>
|
|
90
|
+
|
|
91
|
+
<a-camera
|
|
92
|
+
class="camera"
|
|
93
|
+
camera="fov: 50; zoom: 3.2;"
|
|
94
|
+
position="0 0 1"
|
|
95
|
+
orbit-controls="
|
|
96
|
+
enableZoom: true;
|
|
97
|
+
autoRotate: false;
|
|
98
|
+
|
|
99
|
+
target: .target;
|
|
100
|
+
enableDamping: true;
|
|
101
|
+
dampingFactor: 0.125;
|
|
102
|
+
rotateSpeed:0.25;
|
|
103
|
+
minDistance:0.75;
|
|
104
|
+
maxDistance:2;
|
|
105
|
+
"
|
|
106
|
+
></a-camera>
|
|
107
|
+
|
|
108
|
+
<a-sky></a-sky>
|
|
109
|
+
|
|
110
|
+
<a-entity class="target">
|
|
111
|
+
<a-entity class="rotation">
|
|
112
|
+
<a-entity class="position" position="0 0 0.005">
|
|
113
|
+
<a-entity
|
|
114
|
+
gltf-model="#rightInsoleModel"
|
|
115
|
+
visible="false"
|
|
116
|
+
data-type="rightInsole"
|
|
117
|
+
></a-entity>
|
|
118
|
+
<a-entity
|
|
119
|
+
gltf-model="#leftInsoleModel"
|
|
120
|
+
visible="false"
|
|
121
|
+
data-type="leftInsole"
|
|
122
|
+
></a-entity>
|
|
123
|
+
<a-entity
|
|
124
|
+
gltf-model="#glassesModel"
|
|
125
|
+
visible="false"
|
|
126
|
+
data-type="glasses"
|
|
127
|
+
></a-entity>
|
|
128
|
+
<a-entity
|
|
129
|
+
gltf-model="#rightHandModel"
|
|
130
|
+
visible="false"
|
|
131
|
+
data-type="rightGlove"
|
|
132
|
+
></a-entity>
|
|
133
|
+
<a-entity
|
|
134
|
+
gltf-model="#rightHandModel"
|
|
135
|
+
visible="false"
|
|
136
|
+
scale="-1 1 1"
|
|
137
|
+
data-type="leftGlove"
|
|
138
|
+
></a-entity>
|
|
139
|
+
</a-entity>
|
|
140
|
+
</a-entity>
|
|
141
|
+
</a-entity>
|
|
142
|
+
</a-scene>
|
|
143
|
+
</body>
|
|
144
|
+
</html>
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import * as BS from "../../build/brilliantsole.module.js";
|
|
2
|
+
window.BS = BS;
|
|
3
|
+
console.log({ BS });
|
|
4
|
+
//BS.setAllConsoleLevelFlags({ log: false });
|
|
5
|
+
|
|
6
|
+
// DEVICE
|
|
7
|
+
|
|
8
|
+
const device = new BS.Device();
|
|
9
|
+
console.log({ device });
|
|
10
|
+
window.device = device;
|
|
11
|
+
|
|
12
|
+
// CONNECT
|
|
13
|
+
|
|
14
|
+
const toggleConnectionButton = document.getElementById("toggleConnection");
|
|
15
|
+
toggleConnectionButton.addEventListener("click", () =>
|
|
16
|
+
device.toggleConnection()
|
|
17
|
+
);
|
|
18
|
+
device.addEventListener("connectionStatus", () => {
|
|
19
|
+
let disabled = false;
|
|
20
|
+
let innerText = device.connectionStatus;
|
|
21
|
+
switch (device.connectionStatus) {
|
|
22
|
+
case "notConnected":
|
|
23
|
+
innerText = "connect";
|
|
24
|
+
break;
|
|
25
|
+
case "connected":
|
|
26
|
+
innerText = "disconnect";
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
toggleConnectionButton.disabled = disabled;
|
|
30
|
+
toggleConnectionButton.innerText = innerText;
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// 3D VISUALIZATION
|
|
34
|
+
|
|
35
|
+
/** @typedef {import("../utils/three/three.module.min.js").Vector3} TVector3 */
|
|
36
|
+
/** @typedef {import("../utils/three/three.module.min.js").Quaternion} TQuaternion */
|
|
37
|
+
/** @typedef {import("../utils/three/three.module.min.js").Euler} TEuler */
|
|
38
|
+
|
|
39
|
+
window.sensorRate = 20;
|
|
40
|
+
window.interpolationSmoothing = 0.4;
|
|
41
|
+
window.positionScalar = 0.1;
|
|
42
|
+
|
|
43
|
+
const scene = document.querySelector("a-scene");
|
|
44
|
+
const targetEntity = scene.querySelector(".target");
|
|
45
|
+
const targetPositionEntity = targetEntity.querySelector(".position");
|
|
46
|
+
const targetRotationEntity = targetEntity.querySelector(".rotation");
|
|
47
|
+
const modelEntities = Array.from(targetEntity.querySelectorAll("[gltf-model]"));
|
|
48
|
+
|
|
49
|
+
device.addEventListener("connected", () => {
|
|
50
|
+
modelEntities.forEach((entity) => {
|
|
51
|
+
entity.setAttribute("visible", entity.dataset.type == device.type);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
/** @type {HTMLSelectElement} */
|
|
56
|
+
const orientationSelect = document.querySelector(".orientation");
|
|
57
|
+
orientationSelect.addEventListener("input", () => {
|
|
58
|
+
/** @type {BS.SensorConfiguration} */
|
|
59
|
+
const configuration = {
|
|
60
|
+
gameRotation: 0,
|
|
61
|
+
rotation: 0,
|
|
62
|
+
gyroscope: 0,
|
|
63
|
+
orientation: 0,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
switch (orientationSelect.value) {
|
|
67
|
+
case "none":
|
|
68
|
+
break;
|
|
69
|
+
case "gameRotation":
|
|
70
|
+
configuration.gameRotation = sensorRate;
|
|
71
|
+
break;
|
|
72
|
+
case "rotation":
|
|
73
|
+
configuration.rotation = sensorRate;
|
|
74
|
+
break;
|
|
75
|
+
case "orientation":
|
|
76
|
+
configuration.orientation = sensorRate;
|
|
77
|
+
break;
|
|
78
|
+
case "gyroscope":
|
|
79
|
+
configuration.gyroscope = sensorRate;
|
|
80
|
+
break;
|
|
81
|
+
default:
|
|
82
|
+
console.error(
|
|
83
|
+
`uncaught orientationSelect value "${orientationSelect.value}"`
|
|
84
|
+
);
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
device.setSensorConfiguration(configuration);
|
|
89
|
+
});
|
|
90
|
+
device.addEventListener("connected", () => {
|
|
91
|
+
orientationSelect.querySelectorAll("option").forEach((option) => {
|
|
92
|
+
option.hidden =
|
|
93
|
+
BS.SensorTypes.includes(option.value) &&
|
|
94
|
+
!device.sensorTypes.includes(option.value);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
/** @type {HTMLButtonElement} */
|
|
99
|
+
const resetOrientationButton = document.querySelector(".resetOrientation");
|
|
100
|
+
resetOrientationButton.addEventListener("click", () => {
|
|
101
|
+
resetOrientation();
|
|
102
|
+
});
|
|
103
|
+
device.addEventListener("isConnected", () => {
|
|
104
|
+
resetOrientationButton.disabled = !device.isConnected;
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
/** @type {HTMLSelectElement} */
|
|
108
|
+
const positionSelect = document.querySelector(".position");
|
|
109
|
+
positionSelect.addEventListener("input", () => {
|
|
110
|
+
/** @type {BS.SensorConfiguration} */
|
|
111
|
+
const configuration = {
|
|
112
|
+
acceleration: 0,
|
|
113
|
+
gravity: 0,
|
|
114
|
+
linearAcceleration: 0,
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
switch (positionSelect.value) {
|
|
118
|
+
case "none":
|
|
119
|
+
break;
|
|
120
|
+
case "acceleration":
|
|
121
|
+
configuration.acceleration = sensorRate;
|
|
122
|
+
break;
|
|
123
|
+
case "gravity":
|
|
124
|
+
configuration.gravity = sensorRate;
|
|
125
|
+
break;
|
|
126
|
+
case "linearAcceleration":
|
|
127
|
+
configuration.linearAcceleration = sensorRate;
|
|
128
|
+
break;
|
|
129
|
+
default:
|
|
130
|
+
console.error(`uncaught positionSelect value "${positionSelect.value}"`);
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
console.log({ configuration });
|
|
135
|
+
|
|
136
|
+
device.setSensorConfiguration(configuration);
|
|
137
|
+
});
|
|
138
|
+
device.addEventListener("connected", () => {
|
|
139
|
+
positionSelect.querySelectorAll("option").forEach((option) => {
|
|
140
|
+
option.hidden =
|
|
141
|
+
BS.SensorTypes.includes(option.value) &&
|
|
142
|
+
!device.sensorTypes.includes(option.value);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
device.addEventListener("isConnected", () => {
|
|
147
|
+
orientationSelect.disabled = !device.isConnected;
|
|
148
|
+
positionSelect.disabled = !device.isConnected;
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
device.addEventListener("getSensorConfiguration", () => {
|
|
152
|
+
let newOrientationSelectValue = "none";
|
|
153
|
+
let newPositionSelectValue = "none";
|
|
154
|
+
|
|
155
|
+
for (const key in device.sensorConfiguration) {
|
|
156
|
+
/** @type {BS.SensorType} */
|
|
157
|
+
const sensorType = key;
|
|
158
|
+
if (device.sensorConfiguration[sensorType] > 0) {
|
|
159
|
+
switch (sensorType) {
|
|
160
|
+
case "gameRotation":
|
|
161
|
+
case "rotation":
|
|
162
|
+
case "orientation":
|
|
163
|
+
case "gyroscope":
|
|
164
|
+
newOrientationSelectValue = sensorType;
|
|
165
|
+
break;
|
|
166
|
+
case "acceleration":
|
|
167
|
+
case "gravity":
|
|
168
|
+
case "linearAcceleration":
|
|
169
|
+
newPositionSelectValue = sensorType;
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
orientationSelect.value = newOrientationSelectValue;
|
|
176
|
+
positionSelect.value = newPositionSelectValue;
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
/** @type {TVector3} */
|
|
180
|
+
const _position = new THREE.Vector3();
|
|
181
|
+
|
|
182
|
+
/** @param {BS.Vector3} position */
|
|
183
|
+
const updatePosition = (position) => {
|
|
184
|
+
_position.copy(position).multiplyScalar(window.positionScalar);
|
|
185
|
+
targetPositionEntity.object3D.position.lerp(
|
|
186
|
+
_position,
|
|
187
|
+
window.interpolationSmoothing
|
|
188
|
+
);
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
device.addEventListener("acceleration", (event) => {
|
|
192
|
+
const acceleration = event.message.acceleration;
|
|
193
|
+
updatePosition(acceleration);
|
|
194
|
+
});
|
|
195
|
+
device.addEventListener("gravity", () => {
|
|
196
|
+
const gravity = event.message.gravity;
|
|
197
|
+
updatePosition(gravity);
|
|
198
|
+
});
|
|
199
|
+
device.addEventListener("linearAcceleration", (event) => {
|
|
200
|
+
const linearAcceleration = event.message.linearAcceleration;
|
|
201
|
+
updatePosition(linearAcceleration);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
/** @type {TQuaternion} */
|
|
205
|
+
const offsetQuaternion = new THREE.Quaternion();
|
|
206
|
+
const resetOrientation = () => {
|
|
207
|
+
offsetQuaternion.copy(_quaternion).invert();
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
/** @type {TQuaternion} */
|
|
211
|
+
const _quaternion = new THREE.Quaternion();
|
|
212
|
+
/** @type {TQuaternion} */
|
|
213
|
+
const targetQuaternion = new THREE.Quaternion();
|
|
214
|
+
/**
|
|
215
|
+
* @param {BS.Quaternion} quaternion
|
|
216
|
+
* @param {boolean} applyOffset
|
|
217
|
+
*/
|
|
218
|
+
const updateQuaternion = (quaternion, applyOffset = false) => {
|
|
219
|
+
_quaternion.copy(quaternion);
|
|
220
|
+
targetQuaternion.copy(_quaternion);
|
|
221
|
+
if (applyOffset) {
|
|
222
|
+
targetQuaternion.premultiply(offsetQuaternion);
|
|
223
|
+
}
|
|
224
|
+
targetRotationEntity.object3D.quaternion.slerp(
|
|
225
|
+
targetQuaternion,
|
|
226
|
+
window.interpolationSmoothing
|
|
227
|
+
);
|
|
228
|
+
};
|
|
229
|
+
device.addEventListener("gameRotation", (event) => {
|
|
230
|
+
let gameRotation = event.message.gameRotation;
|
|
231
|
+
updateQuaternion(gameRotation, true);
|
|
232
|
+
});
|
|
233
|
+
device.addEventListener("rotation", (event) => {
|
|
234
|
+
const rotation = event.message.rotation;
|
|
235
|
+
updateQuaternion(rotation, true);
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
/** @type {TVector3} */
|
|
239
|
+
const orientationVector3 = new THREE.Vector3();
|
|
240
|
+
/** @type {TEuler} */
|
|
241
|
+
const orientationEuler = new THREE.Euler(0, 0, 0, "YXZ");
|
|
242
|
+
/** @type {TQuaternion} */
|
|
243
|
+
const orientationQuaternion = new THREE.Quaternion();
|
|
244
|
+
device.addEventListener("orientation", (event) => {
|
|
245
|
+
const orientation = event.message.orientation;
|
|
246
|
+
orientationVector3
|
|
247
|
+
.set(orientation.pitch, orientation.heading, orientation.roll)
|
|
248
|
+
.multiplyScalar(THREE.MathUtils.DEG2RAD);
|
|
249
|
+
orientationEuler.setFromVector3(orientationVector3);
|
|
250
|
+
orientationQuaternion.setFromEuler(orientationEuler);
|
|
251
|
+
updateQuaternion(orientationQuaternion);
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
/** @type {TVector3} */
|
|
255
|
+
const gyroscopeVector3 = new THREE.Vector3();
|
|
256
|
+
/** @type {TEuler} */
|
|
257
|
+
const gyroscopeEuler = new THREE.Euler();
|
|
258
|
+
/** @type {TQuaternion} */
|
|
259
|
+
const gyroscopeQuaternion = new THREE.Quaternion();
|
|
260
|
+
device.addEventListener("gyroscope", (event) => {
|
|
261
|
+
const gyroscope = event.message.gyroscope;
|
|
262
|
+
gyroscopeVector3.copy(gyroscope).multiplyScalar(Math.PI / 180);
|
|
263
|
+
gyroscopeEuler.setFromVector3(gyroscopeVector3);
|
|
264
|
+
gyroscopeQuaternion.setFromEuler(gyroscopeEuler);
|
|
265
|
+
updateQuaternion(gyroscopeQuaternion);
|
|
266
|
+
});
|
|
@@ -59,7 +59,7 @@ BS.DeviceManager.AddEventListener("availableDevices", (event) => {
|
|
|
59
59
|
getDevices();
|
|
60
60
|
|
|
61
61
|
// CONNECTION
|
|
62
|
-
const devicePair = BS.DevicePair.
|
|
62
|
+
const devicePair = BS.DevicePair.insoles;
|
|
63
63
|
|
|
64
64
|
/** @type {HTMLButtonElement} */
|
|
65
65
|
const addDeviceButton = document.getElementById("addDevice");
|
|
@@ -164,6 +164,7 @@ const target = {
|
|
|
164
164
|
|
|
165
165
|
reset() {
|
|
166
166
|
balanceContainer.classList.remove("hover");
|
|
167
|
+
insideTargetTimeoutId = undefined;
|
|
167
168
|
|
|
168
169
|
this.height = randomValueBetween(0.2, 0.3);
|
|
169
170
|
this.start = randomValueBetween(0, 1 - this.height);
|