brilliantsole 0.0.27 → 0.0.29
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/assets/3d/anchor.glb +0 -0
- package/assets/3d/coin.glb +0 -0
- package/assets/3d/glasses.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/build/brilliantsole.cjs +3091 -741
- package/build/brilliantsole.cjs.map +1 -1
- package/build/brilliantsole.js +2759 -709
- package/build/brilliantsole.js.map +1 -1
- package/build/brilliantsole.ls.js +2602 -543
- 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 +295 -65
- package/build/brilliantsole.module.js +2749 -710
- package/build/brilliantsole.module.js.map +1 -1
- package/build/brilliantsole.module.min.d.ts +295 -65
- package/build/brilliantsole.module.min.js +1 -1
- package/build/brilliantsole.module.min.js.map +1 -1
- package/build/brilliantsole.node.module.d.ts +289 -62
- package/build/brilliantsole.node.module.js +3080 -742
- 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 -8
- package/build/dts/CameraManager.d.ts +72 -0
- package/build/dts/Device.d.ts +64 -13
- package/build/dts/DeviceInformationManager.d.ts +4 -4
- package/build/dts/DeviceManager.d.ts +2 -0
- package/build/dts/FileTransferManager.d.ts +18 -8
- package/build/dts/InformationManager.d.ts +2 -0
- package/build/dts/MicrophoneManager.d.ts +88 -0
- package/build/dts/TfliteManager.d.ts +22 -2
- package/build/dts/WifiManager.d.ts +61 -0
- package/build/dts/connection/BaseConnectionManager.d.ts +35 -3
- package/build/dts/connection/ClientConnectionManager.d.ts +7 -2
- package/build/dts/connection/bluetooth/NobleConnectionManager.d.ts +2 -1
- package/build/dts/connection/bluetooth/WebBluetoothConnectionManager.d.ts +1 -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 +5 -5
- 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 +5 -3
- package/build/dts/server/ServerUtils.d.ts +1 -1
- package/build/dts/server/websocket/WebSocketUtils.d.ts +1 -1
- package/build/dts/utils/AudioUtils.d.ts +2 -0
- package/build/dts/utils/Console.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 +292 -62
- package/build/index.node.d.ts +286 -59
- package/examples/3d/scene.html +19 -5
- package/examples/3d-generic/index.html +144 -0
- package/examples/3d-generic/script.js +266 -0
- package/examples/basic/index.html +267 -17
- package/examples/basic/script.js +958 -105
- package/examples/camera/barcode-detector.js +109 -0
- package/examples/camera/depth-estimation.js +71 -0
- package/examples/camera/face-detector.js +119 -0
- package/examples/camera/face-landmark.js +111 -0
- package/examples/camera/gesture-recognition.js +97 -0
- package/examples/camera/hand-landmark.js +74 -0
- package/examples/camera/image-segmentation.js +98 -0
- package/examples/camera/image-to-text.js +43 -0
- package/examples/camera/image-upscale.js +75 -0
- package/examples/camera/index.html +129 -0
- package/examples/camera/object-detection.js +98 -0
- package/examples/camera/pose-landmark.js +60 -0
- package/examples/camera/script.js +316 -0
- package/examples/camera/utils.js +165 -0
- package/examples/camera/yolo-tiny.js +54 -0
- package/examples/camera/yolo.js +119 -0
- package/examples/edge-impulse/script.js +157 -48
- 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/glasses-gestures/README.md +11 -0
- package/examples/glasses-gestures/edge-impulse-standalone.js +7228 -0
- package/examples/glasses-gestures/edge-impulse-standalone.wasm +0 -0
- package/examples/glasses-gestures/index.html +69 -0
- package/examples/glasses-gestures/run-impulse.js +135 -0
- package/examples/glasses-gestures/script.js +226 -0
- package/examples/gloves/edge-impulse-standalone.js +7228 -0
- package/examples/gloves/edge-impulse-standalone.wasm +0 -0
- package/examples/gloves/index.html +4 -1
- package/examples/gloves/run-impulse.js +135 -0
- package/examples/gloves/script.js +367 -51
- package/examples/graph/script.js +94 -37
- package/examples/microphone/gender.js +54 -0
- package/examples/microphone/index.html +102 -0
- package/examples/microphone/script.js +394 -0
- package/examples/microphone/utils.js +45 -0
- package/examples/microphone/whisper-realtime.js +166 -0
- package/examples/microphone/whisper.js +132 -0
- package/examples/punch/index.html +135 -0
- package/examples/punch/punch.tflite +0 -0
- package/examples/punch/script.js +169 -0
- package/examples/server/index.html +98 -22
- package/examples/server/script.js +317 -109
- 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-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/examples/webxr-3/components/bs-camera.js +65 -0
- package/examples/webxr-3/index.html +134 -0
- package/examples/webxr-3/script.js +432 -0
- package/package.json +2 -1
- package/src/.prettierrc +4 -0
- package/src/BS.ts +79 -8
- package/src/CameraManager.ts +497 -0
- package/src/Device.ts +691 -86
- package/src/DeviceInformationManager.ts +19 -10
- package/src/DeviceManager.ts +85 -25
- package/src/FileTransferManager.ts +145 -20
- package/src/InformationManager.ts +40 -15
- package/src/MicrophoneManager.ts +599 -0
- package/src/TfliteManager.ts +171 -25
- package/src/WifiManager.ts +323 -0
- package/src/connection/BaseConnectionManager.ts +130 -30
- package/src/connection/ClientConnectionManager.ts +34 -10
- package/src/connection/bluetooth/BluetoothConnectionManager.ts +8 -2
- package/src/connection/bluetooth/NobleConnectionManager.ts +147 -41
- package/src/connection/bluetooth/WebBluetoothConnectionManager.ts +99 -34
- 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 +95 -25
- package/src/devicePair/DevicePairPressureSensorDataManager.ts +27 -7
- package/src/scanner/BaseScanner.ts +49 -11
- package/src/scanner/NobleScanner.ts +76 -14
- package/src/sensor/MotionSensorDataManager.ts +21 -6
- package/src/sensor/PressureSensorDataManager.ts +37 -8
- package/src/sensor/SensorConfigurationManager.ts +73 -22
- package/src/sensor/SensorDataManager.ts +109 -23
- package/src/server/BaseClient.ts +150 -36
- package/src/server/BaseServer.ts +50 -2
- package/src/server/ServerUtils.ts +39 -9
- package/src/server/udp/UDPServer.ts +73 -22
- package/src/server/udp/UDPUtils.ts +9 -2
- package/src/server/websocket/WebSocketClient.ts +27 -7
- package/src/server/websocket/WebSocketUtils.ts +4 -2
- package/src/utils/AudioUtils.ts +65 -0
- package/src/utils/Console.ts +62 -9
- package/src/utils/ParseUtils.ts +24 -5
- package/src/utils/ThrottleUtils.ts +62 -0
- package/src/utils/Timer.ts +1 -1
- package/src/vibration/VibrationManager.ts +166 -40
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
AFRAME.registerSystem("init-shell-material", {
|
|
2
|
+
waitForPhysics: async function () {
|
|
3
|
+
return new Promise((resolve) => {
|
|
4
|
+
let interval = setInterval(() => {
|
|
5
|
+
const sceneEl = this.el.sceneEl;
|
|
6
|
+
const system = sceneEl.systems.physics;
|
|
7
|
+
if (system) {
|
|
8
|
+
clearInterval(interval);
|
|
9
|
+
resolve();
|
|
10
|
+
}
|
|
11
|
+
}, 100);
|
|
12
|
+
});
|
|
13
|
+
},
|
|
14
|
+
init: async function () {
|
|
15
|
+
await this.waitForPhysics();
|
|
16
|
+
const sceneEl = this.el.sceneEl;
|
|
17
|
+
const system = sceneEl.systems.physics;
|
|
18
|
+
|
|
19
|
+
if (system && system.driver && system.driver.addMaterial) {
|
|
20
|
+
// system.driver.world.defaultContactMaterial.contactEquationStiffness = 1e9;
|
|
21
|
+
// system.driver.world.defaultContactMaterial.contactEquationRelaxation = 4;
|
|
22
|
+
|
|
23
|
+
system.driver.world.addMaterial(system.driver.materials.defaultMaterial);
|
|
24
|
+
system.driver.world.addMaterial(system.driver.materials.staticMaterial);
|
|
25
|
+
|
|
26
|
+
// Add a frictionless material if not defined already
|
|
27
|
+
const shellMaterial = new CANNON.Material("shell");
|
|
28
|
+
shellMaterial.friction = 0.0;
|
|
29
|
+
shellMaterial.restitution = 1; // adjust bounce if needed
|
|
30
|
+
system.driver.materials["shell"] = shellMaterial;
|
|
31
|
+
system.driver.world.addMaterial(shellMaterial);
|
|
32
|
+
|
|
33
|
+
const goombaMaterial = new CANNON.Material("goomba");
|
|
34
|
+
goombaMaterial.friction = -1;
|
|
35
|
+
goombaMaterial.restitution = 0.5;
|
|
36
|
+
system.driver.materials["goomba"] = goombaMaterial;
|
|
37
|
+
system.driver.world.addMaterial(goombaMaterial);
|
|
38
|
+
|
|
39
|
+
const soccerBallMaterial = new CANNON.Material("soccerBall");
|
|
40
|
+
soccerBallMaterial.friction = 0.2;
|
|
41
|
+
soccerBallMaterial.restitution = 0.6;
|
|
42
|
+
system.driver.materials["soccerBall"] = soccerBallMaterial;
|
|
43
|
+
system.driver.world.addMaterial(soccerBallMaterial);
|
|
44
|
+
|
|
45
|
+
const bounceWallMaterial = new CANNON.Material("bounceWall");
|
|
46
|
+
bounceWallMaterial.friction = 0.0;
|
|
47
|
+
bounceWallMaterial.restitution = 1; // adjust bounce if needed
|
|
48
|
+
system.driver.materials["bounceWall"] = bounceWallMaterial;
|
|
49
|
+
system.driver.world.addMaterial(bounceWallMaterial);
|
|
50
|
+
|
|
51
|
+
this.addContactMaterial();
|
|
52
|
+
|
|
53
|
+
sceneEl.addEventListener("world-meshes", this.onWorldMeshes.bind(this));
|
|
54
|
+
|
|
55
|
+
const testFloor = document.getElementById("testFloor");
|
|
56
|
+
if (testFloor) {
|
|
57
|
+
return;
|
|
58
|
+
testFloor.components["static-body"].body.material = bounceWallMaterial;
|
|
59
|
+
testFloor.addEventListener("body-loaded", (event) => {
|
|
60
|
+
const { body } = event.detail;
|
|
61
|
+
console.log(body);
|
|
62
|
+
body.material = bounceWallMaterial;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
onWorldMeshes: function (event) {
|
|
68
|
+
const { planeMeshes, worldMeshes } = event.detail;
|
|
69
|
+
console.log("onWorldMeshes", event.detail);
|
|
70
|
+
|
|
71
|
+
const sceneEl = this.el.sceneEl;
|
|
72
|
+
const system = sceneEl.systems.physics;
|
|
73
|
+
const materials = system.driver.materials;
|
|
74
|
+
|
|
75
|
+
planeMeshes.forEach((planeMesh) => {
|
|
76
|
+
let material = planeMesh.components["static-body"].body.material;
|
|
77
|
+
switch (planeMesh.dataset.worldMesh) {
|
|
78
|
+
case "wall":
|
|
79
|
+
material = materials["bounceWall"];
|
|
80
|
+
break;
|
|
81
|
+
default:
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
planeMesh.components["static-body"].body.material = material;
|
|
85
|
+
});
|
|
86
|
+
worldMeshes.forEach((worldMesh) => {
|
|
87
|
+
let material = worldMesh.components["static-body"].body.material;
|
|
88
|
+
switch (worldMesh.dataset.worldMesh) {
|
|
89
|
+
case "table":
|
|
90
|
+
material = materials["bounceWall"];
|
|
91
|
+
break;
|
|
92
|
+
default:
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
worldMesh.components["static-body"].body.material = material;
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
addContactMaterial: function () {
|
|
99
|
+
const sceneEl = this.el.sceneEl;
|
|
100
|
+
const system = sceneEl.systems.physics;
|
|
101
|
+
|
|
102
|
+
if (system && system.driver && system.driver.addMaterial) {
|
|
103
|
+
const shellMaterial = system.driver.materials["shell"];
|
|
104
|
+
const defaultMaterial = system.driver.materials["defaultMaterial"];
|
|
105
|
+
const staticMaterial = system.driver.materials["staticMaterial"];
|
|
106
|
+
|
|
107
|
+
const defaultContactMaterial = {
|
|
108
|
+
friction: 0.01,
|
|
109
|
+
restitution: 0.3,
|
|
110
|
+
contactEquationStiffness: 1e8,
|
|
111
|
+
contactEquationRelaxation: 3,
|
|
112
|
+
frictionEquationStiffness: 1e8,
|
|
113
|
+
frictionEquationRegularization: 3,
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
// console.log("shellMaterial", shellMaterial);
|
|
117
|
+
|
|
118
|
+
const shellDefaultContact = new CANNON.ContactMaterial(
|
|
119
|
+
shellMaterial,
|
|
120
|
+
defaultMaterial,
|
|
121
|
+
{ friction: 0, restitution: 0 }
|
|
122
|
+
);
|
|
123
|
+
system.driver.world.addContactMaterial(shellDefaultContact);
|
|
124
|
+
// console.log("added shellDefaultContact", shellDefaultContact);
|
|
125
|
+
|
|
126
|
+
const shellStaticContact = new CANNON.ContactMaterial(
|
|
127
|
+
shellMaterial,
|
|
128
|
+
staticMaterial,
|
|
129
|
+
{ friction: 0, restitution: 0 }
|
|
130
|
+
);
|
|
131
|
+
system.driver.world.addContactMaterial(shellStaticContact);
|
|
132
|
+
// console.log("added shellStaticContact", shellStaticContact);
|
|
133
|
+
|
|
134
|
+
const bounceWallMaterial = system.driver.materials["bounceWall"];
|
|
135
|
+
const bounceWallContact = new CANNON.ContactMaterial(
|
|
136
|
+
shellMaterial,
|
|
137
|
+
bounceWallMaterial,
|
|
138
|
+
{
|
|
139
|
+
friction: 0,
|
|
140
|
+
restitution: 1,
|
|
141
|
+
contactEquationStiffness: 1e9,
|
|
142
|
+
contactEquationRelaxation: 4,
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
system.driver.world.addContactMaterial(bounceWallContact);
|
|
146
|
+
// console.log("added bounceWallContact", bounceWallContact);
|
|
147
|
+
|
|
148
|
+
const defaultBounceWallContact = new CANNON.ContactMaterial(
|
|
149
|
+
defaultMaterial,
|
|
150
|
+
bounceWallMaterial,
|
|
151
|
+
{ ...defaultContactMaterial }
|
|
152
|
+
);
|
|
153
|
+
system.driver.world.addContactMaterial(defaultBounceWallContact);
|
|
154
|
+
// console.log("added defaultBounceWallContact", defaultBounceWallContact);
|
|
155
|
+
|
|
156
|
+
const goombaMaterial = system.driver.materials["goomba"];
|
|
157
|
+
const goombaDefaultContactMaterial = {
|
|
158
|
+
...defaultContactMaterial,
|
|
159
|
+
restitution: goombaMaterial.restitution,
|
|
160
|
+
};
|
|
161
|
+
const goombaBounceWallContact = new CANNON.ContactMaterial(
|
|
162
|
+
goombaMaterial,
|
|
163
|
+
bounceWallMaterial,
|
|
164
|
+
{ ...goombaDefaultContactMaterial }
|
|
165
|
+
);
|
|
166
|
+
system.driver.world.addContactMaterial(goombaBounceWallContact);
|
|
167
|
+
// console.log("added goombaBounceWallContact", goombaBounceWallContact);
|
|
168
|
+
|
|
169
|
+
const goombaStaticContact = new CANNON.ContactMaterial(
|
|
170
|
+
goombaMaterial,
|
|
171
|
+
system.driver.materials.staticMaterial,
|
|
172
|
+
{ ...goombaDefaultContactMaterial }
|
|
173
|
+
);
|
|
174
|
+
system.driver.world.addContactMaterial(goombaStaticContact);
|
|
175
|
+
// console.log("added goombaStaticContact", goombaStaticContact);
|
|
176
|
+
|
|
177
|
+
const goombaDefaultContact = new CANNON.ContactMaterial(
|
|
178
|
+
goombaMaterial,
|
|
179
|
+
system.driver.materials.defaultMaterial,
|
|
180
|
+
{ ...goombaDefaultContactMaterial }
|
|
181
|
+
);
|
|
182
|
+
system.driver.world.addContactMaterial(goombaDefaultContact);
|
|
183
|
+
// console.log("added goombaDefaultContact", goombaDefaultContact);
|
|
184
|
+
|
|
185
|
+
const soccerBallMaterial = system.driver.materials["soccerBall"];
|
|
186
|
+
const soccerBallDefaultContactMaterial = {
|
|
187
|
+
...defaultContactMaterial,
|
|
188
|
+
restitution: soccerBallMaterial.restitution,
|
|
189
|
+
};
|
|
190
|
+
const soccerBallBounceWallContact = new CANNON.ContactMaterial(
|
|
191
|
+
soccerBallMaterial,
|
|
192
|
+
bounceWallMaterial,
|
|
193
|
+
{ ...soccerBallDefaultContactMaterial, friction: 0, restitution: 1 }
|
|
194
|
+
);
|
|
195
|
+
system.driver.world.addContactMaterial(soccerBallBounceWallContact);
|
|
196
|
+
// console.log("added soccerBallBounceWallContact", soccerBallBounceWallContact);
|
|
197
|
+
|
|
198
|
+
const soccerBallStaticContact = new CANNON.ContactMaterial(
|
|
199
|
+
soccerBallMaterial,
|
|
200
|
+
system.driver.materials.staticMaterial,
|
|
201
|
+
{ ...soccerBallDefaultContactMaterial }
|
|
202
|
+
);
|
|
203
|
+
system.driver.world.addContactMaterial(soccerBallStaticContact);
|
|
204
|
+
// console.log("added soccerBallStaticContact", soccerBallStaticContact);
|
|
205
|
+
|
|
206
|
+
const soccerBallDefaultContact = new CANNON.ContactMaterial(
|
|
207
|
+
soccerBallMaterial,
|
|
208
|
+
system.driver.materials.defaultMaterial,
|
|
209
|
+
{ ...soccerBallDefaultContactMaterial }
|
|
210
|
+
);
|
|
211
|
+
system.driver.world.addContactMaterial(soccerBallDefaultContact);
|
|
212
|
+
// console.log("added soccerBallDefaultContact", soccerBallDefaultContact);
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
});
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
AFRAME.registerComponent("platter", {
|
|
2
|
+
schema: {
|
|
3
|
+
fadeInSoundSelector: { default: "#platterFadeInAudio" },
|
|
4
|
+
fadeOutSoundSelector: { default: "#platterFadeOutAudio" },
|
|
5
|
+
fadeInSoundVolume: { default: 0.2 },
|
|
6
|
+
fadeOutSoundVolume: { default: 0.2 },
|
|
7
|
+
},
|
|
8
|
+
|
|
9
|
+
init: function () {
|
|
10
|
+
this.auxMatrix = new THREE.Matrix4();
|
|
11
|
+
this.goombaTransform = {
|
|
12
|
+
position: new THREE.Vector3(),
|
|
13
|
+
quaternion: new THREE.Quaternion(),
|
|
14
|
+
scale: new THREE.Vector3(1, 1, 1),
|
|
15
|
+
};
|
|
16
|
+
this.addGoomba();
|
|
17
|
+
|
|
18
|
+
this.isOpen = false;
|
|
19
|
+
|
|
20
|
+
this.el.setAttribute("grow-shrink", "");
|
|
21
|
+
this.hand = this.el.closest("[hand-tracking-controls]");
|
|
22
|
+
|
|
23
|
+
this.hand.setAttribute("palm-up-detector", "");
|
|
24
|
+
this.hand.addEventListener("palmupon", () => {
|
|
25
|
+
this.hand.components["hand-tracking-grab-controls"].setDisabled(true);
|
|
26
|
+
this.setGrabEnabled(false);
|
|
27
|
+
this.isGrabbed = false;
|
|
28
|
+
this.isOpen = true;
|
|
29
|
+
this.playFadeInSound();
|
|
30
|
+
if (this.goomba) {
|
|
31
|
+
this.goomba.setAttribute("visible", "true");
|
|
32
|
+
}
|
|
33
|
+
setTimeout(() => {
|
|
34
|
+
if (!this.isOpen) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
this.addGoomba();
|
|
38
|
+
if (this.goomba && !this.isGrabbed) {
|
|
39
|
+
this.goomba.setAttribute("grabbable", "");
|
|
40
|
+
this.goomba.play();
|
|
41
|
+
}
|
|
42
|
+
}, 200);
|
|
43
|
+
this.el.emit("grow");
|
|
44
|
+
this.hand.setAttribute("occlude-hand-tracking-controls", {
|
|
45
|
+
enabled: false,
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
this.hand.addEventListener("palmupoff", () => {
|
|
49
|
+
this.hand.components["hand-tracking-grab-controls"].setDisabled(false);
|
|
50
|
+
this.setGrabEnabled(true);
|
|
51
|
+
this.isOpen = false;
|
|
52
|
+
this.playFadeOutSound();
|
|
53
|
+
if (this.goomba && !this.isGrabbed) {
|
|
54
|
+
this.goomba.removeAttribute("grabbable");
|
|
55
|
+
this.goomba.pause();
|
|
56
|
+
}
|
|
57
|
+
this.el.emit("shrink");
|
|
58
|
+
this.hand.setAttribute("occlude-hand-tracking-controls", {
|
|
59
|
+
enabled: true,
|
|
60
|
+
});
|
|
61
|
+
this.isGrabbed = false;
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
this.fadeInSound = document.createElement("a-entity");
|
|
65
|
+
this.fadeInSound.setAttribute(
|
|
66
|
+
"sound",
|
|
67
|
+
`src: ${this.data.fadeInSoundSelector}; volume: ${this.data.fadeInSoundVolume}`
|
|
68
|
+
);
|
|
69
|
+
this.el.sceneEl.appendChild(this.fadeInSound);
|
|
70
|
+
|
|
71
|
+
this.fadeOutSound = document.createElement("a-entity");
|
|
72
|
+
this.fadeOutSound.setAttribute(
|
|
73
|
+
"sound",
|
|
74
|
+
`src: ${this.data.fadeOutSoundSelector}; volume: ${this.data.fadeOutSoundVolume}`
|
|
75
|
+
);
|
|
76
|
+
this.el.sceneEl.appendChild(this.fadeOutSound);
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
setGrabEnabled: function (enabled) {
|
|
80
|
+
if (!this.originalObbColliderAttribute) {
|
|
81
|
+
this.originalObbColliderAttribute = Object.assign(
|
|
82
|
+
{},
|
|
83
|
+
this.hand.getAttribute("obb-collider")
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
if (enabled) {
|
|
87
|
+
this.hand.setAttribute("obb-collider", this.originalObbColliderAttribute);
|
|
88
|
+
} else {
|
|
89
|
+
this.hand.removeAttribute("obb-collider");
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
playFadeInSound: function () {
|
|
94
|
+
this.stopFadeOutSound();
|
|
95
|
+
this.el.object3D.getWorldPosition(this.fadeInSound.object3D.position);
|
|
96
|
+
this.fadeInSound.components.sound.playSound();
|
|
97
|
+
},
|
|
98
|
+
stopFadeInSound: function () {
|
|
99
|
+
this.fadeInSound.components.sound.stopSound();
|
|
100
|
+
},
|
|
101
|
+
playFadeOutSound: function () {
|
|
102
|
+
this.stopFadeInSound();
|
|
103
|
+
this.el.object3D.getWorldPosition(this.fadeOutSound.object3D.position);
|
|
104
|
+
this.fadeOutSound.components.sound.playSound();
|
|
105
|
+
},
|
|
106
|
+
stopFadeOutSound: function () {
|
|
107
|
+
this.fadeOutSound.components.sound.stopSound();
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
addGoomba: function () {
|
|
111
|
+
if (!this.goomba) {
|
|
112
|
+
this.goomba = document.createElement("a-entity");
|
|
113
|
+
const goomba = this.goomba;
|
|
114
|
+
goomba.addEventListener(
|
|
115
|
+
"die",
|
|
116
|
+
() => {
|
|
117
|
+
if (this.goomba == goomba) {
|
|
118
|
+
this.goomba = undefined;
|
|
119
|
+
this.addGoomba();
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
{ once: true }
|
|
123
|
+
);
|
|
124
|
+
this.goomba.platter = this;
|
|
125
|
+
// console.log("adding goomba", this.goomba);
|
|
126
|
+
this.goomba.addEventListener("loaded", () => {
|
|
127
|
+
this.setOwner(this.el.object3D);
|
|
128
|
+
setTimeout(() => {
|
|
129
|
+
this.goomba.setAttribute("position", "0 0.1 0");
|
|
130
|
+
this.goomba.setAttribute("scale", "1 1 1");
|
|
131
|
+
this.goomba.setAttribute("rotation", "0 180 0");
|
|
132
|
+
this.goomba.pause();
|
|
133
|
+
}, 1);
|
|
134
|
+
});
|
|
135
|
+
this.goomba.setAttribute("goomba", "physics: true;");
|
|
136
|
+
this.goomba.addEventListener(
|
|
137
|
+
"grabstarted",
|
|
138
|
+
(event) => {
|
|
139
|
+
this.isGrabbed = true;
|
|
140
|
+
//console.log("grabstarted goomba");
|
|
141
|
+
event.detail.grab.originalParent = this.el.sceneEl.object3D;
|
|
142
|
+
},
|
|
143
|
+
{ once: true }
|
|
144
|
+
);
|
|
145
|
+
this.goomba.addEventListener(
|
|
146
|
+
"grabended",
|
|
147
|
+
() => {
|
|
148
|
+
this.isGrabbed = false;
|
|
149
|
+
//console.log("grabended goomba");
|
|
150
|
+
this.goomba.play();
|
|
151
|
+
this.goomba.setAttribute("grabbable", "");
|
|
152
|
+
this.goomba.components["goomba"].punchable = true;
|
|
153
|
+
this.goomba.platter = undefined;
|
|
154
|
+
this.goomba = undefined;
|
|
155
|
+
this.addGoomba();
|
|
156
|
+
this.goomba.setAttribute("visible", "false");
|
|
157
|
+
},
|
|
158
|
+
{ once: true }
|
|
159
|
+
);
|
|
160
|
+
this.el.sceneEl.appendChild(this.goomba);
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
setOwner: function (newParent) {
|
|
165
|
+
var child = this.goomba.object3D;
|
|
166
|
+
var parent = child.parent;
|
|
167
|
+
child.applyMatrix4(parent.matrixWorld);
|
|
168
|
+
child.applyMatrix4(this.auxMatrix.copy(newParent.matrixWorld).invert());
|
|
169
|
+
parent.remove(child);
|
|
170
|
+
newParent.add(child);
|
|
171
|
+
},
|
|
172
|
+
});
|