Skip to content

Commit

Permalink
0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
OCSYT committed Feb 13, 2024
1 parent 0ecc259 commit d20a556
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 4 deletions.
4 changes: 3 additions & 1 deletion store.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"magnetometerHaritoraXW-A3V564": false
"magnetometerHaritoraXW-A3V564": false,
"smoothingEnabled": false,
"smoothinput": 0.5
}
6 changes: 5 additions & 1 deletion tracker/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ <h1>SlimeTora</h1>
<br>
<br>
<button onclick="disconnectAllDevices()">Disconnect All Devices</button>
<br>
<br>
<div id="status">Status: Not searching.</div>
<br>
<h1 id="trackercount">Connected Trackers: 0</h1>
<br>
</div>
Expand Down Expand Up @@ -69,7 +73,7 @@ <h3>Settings</h3>
</div>
<div class="content">
<br>
<h3>SlimeTora 0.1.0</h3>
<h3>SlimeTora 0.1.1</h3>
<p>Developed by BracketProto</p>
<p>https://bracketproto.com/</p>
<p>https://github.com/OCSYT/SlimeTora</p>
Expand Down
9 changes: 8 additions & 1 deletion tracker/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ function saveSmoothValue() {
var allowconnection = true;
var connecting = null;
async function connectToTrackers() {
const status = document.getElementById("status");
status.innerHTML = "Status: Searching for trackers.";
if (connecting == null) {
connecting = setInterval(async () => {
if (allowconnection) {
Expand All @@ -134,6 +136,8 @@ async function connectToTrackers() {

async function disconnectAllDevices() {
if (connecting) {
const status = document.getElementById("status");
status.innerHTML = "Status: Not searching.";
const devicelist = document.getElementById("devicelist");
trackercount.innerHTML = "Connected Trackers: " + 0;
devicelist.innerHTML = "<br><h1>Trackers: </h1><br></br>";
Expand Down Expand Up @@ -468,7 +472,10 @@ async function connectToDevice() {
rotationX: postDataCurrent["rotation"].x,
rotationY: postDataCurrent["rotation"].y,
rotationZ: postDataCurrent["rotation"].z,
rotationW: postDataCurrent["rotation"].w
rotationW: postDataCurrent["rotation"].w,
gravityX: IMUData[2].x,
gravityY: IMUData[2].y,
gravityZ: IMUData[2].z,
}, '*');
}

Expand Down
40 changes: 39 additions & 1 deletion tracker/visualization.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@
};


let gravityLine = null; // Variable to store the line representing the gravity vector

window.addEventListener('message', (event) => {
if (event.data.type === 'rotate') {
// Create a quaternion from the components
Expand All @@ -146,14 +148,50 @@
event.data.rotationW
);

// Normalize the quaternion (optional, depending on your use case)
const gravity = new THREE.Vector3(event.data.gravityX, event.data.gravityY, event.data.gravityZ);

quaternion.normalize();

// Apply the quaternion rotation to the cube
cube.quaternion.copy(quaternion);

// Update the length of the gravity line
if (gravityLine) {
updateGravityLineLength(gravity, cube.quaternion);
} else {
createGravityLine(gravity);
}
}
});

// Function to create or update the gravity line
function createGravityLine(gravity) {
// Create a line geometry to represent the gravity vector
const lineGeometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(0, 0, 0),
gravity.clone()
]);

// Create a basic material for the line
const lineMaterial = new THREE.LineBasicMaterial({ color: 0xffff00 });

// Create the line mesh
gravityLine = new THREE.Line(lineGeometry, lineMaterial);

// Add the line to the scene
scene.add(gravityLine);
}

// Function to update the length of the gravity line
function updateGravityLineLength(gravity, rot) {
const endPoint = gravity.clone().applyQuaternion(rot); // End point at the gravity vector's tip (multiplied by 10 for visualization)
const positions = gravityLine.geometry.attributes.position.array;
positions[3] = endPoint.x;
positions[4] = endPoint.y;
positions[5] = endPoint.z;
gravityLine.geometry.attributes.position.needsUpdate = true;
}


window.addEventListener('resize', () => {
const newWidth = window.innerWidth;
Expand Down

0 comments on commit d20a556

Please sign in to comment.