Skip to content

Add 360deg View of Headphones #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .cache/plugin/git-committers/page-authors.json

This file was deleted.

Binary file added docs/assets/img_360/Image-1.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/img_360/Image-10.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/img_360/Image-11.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/img_360/Image-12.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/img_360/Image-13.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/img_360/Image-14.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/img_360/Image-15.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/img_360/Image-16.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/img_360/Image-17.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/img_360/Image-18.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/img_360/Image-19.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/img_360/Image-2.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/img_360/Image-20.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/img_360/Image-21.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/img_360/Image-22.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/img_360/Image-23.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/img_360/Image-24.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/img_360/Image-25.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/img_360/Image-26.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/img_360/Image-27.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/img_360/Image-28.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/img_360/Image-29.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/img_360/Image-3.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/img_360/Image-30.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/img_360/Image-31.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/img_360/Image-32.jpeg
Binary file added docs/assets/img_360/Image-33.jpeg
Binary file added docs/assets/img_360/Image-34.jpeg
Binary file added docs/assets/img_360/Image-35.jpeg
Binary file added docs/assets/img_360/Image-36.jpeg
Binary file added docs/assets/img_360/Image-37.jpeg
Binary file added docs/assets/img_360/Image-38.jpeg
Binary file added docs/assets/img_360/Image-39.jpeg
Binary file added docs/assets/img_360/Image-4.jpeg
Binary file added docs/assets/img_360/Image-40.jpeg
Binary file added docs/assets/img_360/Image-41.jpeg
Binary file added docs/assets/img_360/Image-42.jpeg
Binary file added docs/assets/img_360/Image-43.jpeg
Binary file added docs/assets/img_360/Image-44.jpeg
Binary file added docs/assets/img_360/Image-45.jpeg
Binary file added docs/assets/img_360/Image-46.jpeg
Binary file added docs/assets/img_360/Image-47.jpeg
Binary file added docs/assets/img_360/Image-48.jpeg
Binary file added docs/assets/img_360/Image-49.jpeg
Binary file added docs/assets/img_360/Image-5.jpeg
Binary file added docs/assets/img_360/Image-50.jpeg
Binary file added docs/assets/img_360/Image-51.jpeg
Binary file added docs/assets/img_360/Image-52.jpeg
Binary file added docs/assets/img_360/Image-53.jpeg
Binary file added docs/assets/img_360/Image-54.jpeg
Binary file added docs/assets/img_360/Image-55.jpeg
Binary file added docs/assets/img_360/Image-56.jpeg
Binary file added docs/assets/img_360/Image-57.jpeg
Binary file added docs/assets/img_360/Image-58.jpeg
Binary file added docs/assets/img_360/Image-59.jpeg
Binary file added docs/assets/img_360/Image-6.jpeg
Binary file added docs/assets/img_360/Image-60.jpeg
Binary file added docs/assets/img_360/Image-7.jpeg
Binary file added docs/assets/img_360/Image-8.jpeg
Binary file added docs/assets/img_360/Image-9.jpeg
9 changes: 5 additions & 4 deletions docs/introduction.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
This tutorial will guide you through how to build your own wireless and/or wired headphones with ambient microphones. We start with some off-the-shelf headphones intended for use while lawn mowing, and then hack in some new electronics to allow wireless (BT), auxiliary 3.5mm TRS input, and stereo ambient microphones. The original purpose of this project was to make it easy and safe to play loud music with a rock band in the basement, however, the inclusion of the natural sounds around you into your listening experience can be useful in many other situations.

<div id="dummy"></div>

<div class="grid cards" markdown align="center">

- <a href="../assets/img/hp_rotate2.gif">
<figure markdown>
![Headphones](../assets/img/hp_rotate2.gif)
</figure>
- <article id="pdtViewer">
<article id="product360"></article>
</article>

---

Expand Down
132 changes: 132 additions & 0 deletions docs/javascript/pdt360DegViewer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
var
file_path = '../assets/img_360/Image-',
file_type = 'jpeg',
n = 60,
interval,
pause = false,
speed = 85,
touch = false;

// Load Page and Enable Autoplay
loaderNone();

var i = 1, j = 0, move = [],
mainDiv = document.querySelector(`#product360`);
mainDiv.className = 'viewer';
mainDiv.innerHTML += `<img class="frame" draggable="false" src='${file_path}${i}.${file_type}' title="Scroll Mouse or Drag Image">`;
mainDiv.innerHTML += '<div class="loader"></div>'

// Load Images
for (var k = 1; k <= n; k++) {
document.getElementById('dummy').innerHTML += `<img src='${file_path}${k}.${file_type}'>`;
}

var img = document.querySelector(`#product360 .frame`);

(window.matchMedia("screen and (max-width: 992px)").matches) ? touchFun() : nonTouch();


//For Touch Devices
window.addEventListener('touchstart', function () {
touchFun();
});

function touchFun() {
touch = true;
img.removeAttribute('draggable');
img.addEventListener('touchmove', function (e) {
logic(this, e);
});
img.addEventListener('touchend', function (e) {
move = [];
});
}


//For Non-Touch Devices
function nonTouch() {
touch = false;
mouseEvent();

img.addEventListener('mousedown', function (e) {
drag = true;
logic(this, e);
});
img.addEventListener('mouseup', function (e) {
drag = false;
move = [];
});

img.addEventListener('wheel', function (e) {
// Pause on Scroll
pause = true;

// Index Scrolling
e.preventDefault();
(e.wheelDelta / 120 > 0) ? nxt(this) : prev(this);
});

function mouseEvent() {
img.addEventListener('mousemove', function (e) {
(drag) ? logic(this, e) : null;
});
}
}


// Iterate through frames
function logic(el, e) {
pause = true;
j++;
var x = touch ? e.touches[0].clientX : e.clientX;
var coord = (x - img.offsetLeft);
move.push(coord);

var l = move.length,
oldMove = move[l - 2],
newMove = move[l - 1];
var thresh = touch ? true : !(j % 3);
if (thresh) {
if (newMove > oldMove)
prev(el);
else if (newMove < oldMove)
nxt(el);
}
}

function prev(e) {
if (i <= 1) {
i = n;
e.src = `${file_path}${--i}.${file_type}`;
nxt(e);
} else
e.src = `${file_path}${--i}.${file_type}`;
}

function nxt(e) {
if (i >= n) {
i = 1;
e.src = `${file_path}${++i}.${file_type}`;
prev(e);
} else
e.src = `${file_path}${++i}.${file_type}`;
}


// Page Loading
function autoplay() {
clearInterval(interval);
interval = setInterval(function () {
if (!pause) {
nxt(img);
}
}, speed);
}

function loaderNone() {
window.addEventListener('load',function(){
document.querySelector(`.loader`).style.display = 'none';
pause = false;
autoplay();
});
}
46 changes: 45 additions & 1 deletion docs/stylesheet/extra.css
Original file line number Diff line number Diff line change
Expand Up @@ -562,4 +562,48 @@
max-height: 120mm;
overflow: hidden;
}
}
}



/* ================================================================================== */
/* Icons */
/* ================================================================================== */

.viewer{
position:relative
}

#pdtViewer{
width:85%;
max-width: 250px;
margin:0
}

#pdtViewer img{
user-select:none;
-moz-user-select:none
}

#dummy{
display:none
}

.loader{
width:100%;
height:100%;
position:absolute;
background:rgba(0,0,0,.5);
z-index:1;
top:0
}

img.draggable{
cursor:e-resize
}

@media screen {
#pdtViewer img{
width:100%
}
}
3 changes: 3 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ extra_javascript:
- https://polyfill.io/v3/polyfill.min.js?features=es6
- https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js

# Enable 360 Product Viewer
- javascript/pdt360DegViewer.js



# Configures webpage navigation
Expand Down