Tag Archives: 3D

3d SVG Text Generator

This app generates 3d SVG text in various colors and with various fonts. Here is an example of how it appears:

This is the code:

<!DOCTYPE HTML >
<html>
<head><style>
body{}
input {position: relative}
</style></head>
<body>
<input type=”text” id=”t1″ style=”” placeholder=”text” /> <select id=”s2″><option>font</option><option>Georgia</option><option>Arial</option><option>Arial Black</option><option>Times New Roman</option><option>Courier New</option><option>Georgia</option><option>Verdana</option><option>Comic Sans MS</option></select> <select id=”s1″ onchange=’drw();’><option>color</option><option>red</option><option>green</option><option>blue</option><option>gold</option><option>orange</option><option>magenta</option><option>cyan</option><option>silver</option><option>brown</option><option>purple</option></select> <input type=”button” value = “Save” onclick=’sve();’ /> <input type=”checkbox” id=”ch1″ value=”” />small change
<svg id=”svg1″ style=”position:absolute;left:10px;top:50px;width:1500px;height:200px;background: #ffffaa”></svg>
<script>
var lft = 20; var tp = 70; var r = 55; var col = []; var oldURL = “3Dtext.svg”; var wd = 1500; var ht = 200; var s1 = document.getElementById(“s1”); var s2 = document.getElementById(“s2”);

document.onkeydown = rsize;

function rsize(e) {


if (e.key == “ArrowLeft”) {
if(document.getElementById(“ch1”).checked) {
wd -= 1;
} else {
wd -= 70;
}
document.getElementById(“svg1”).style.width= wd + “px”;
}

if (e.key == “ArrowRight”) {
if(document.getElementById(“ch1”).checked) {
wd += 1;
} else {
wd += 70;
}
document.getElementById(“svg1”).style.width= wd + “px”;
}

if (e.key == “ArrowUp”) {
ht –;
document.getElementById(“svg1”).style.height= ht + “px”;
}

if (e.key == “ArrowDown”) {
ht ++;
document.getElementById(“svg1”).style.height= ht + “px”;
}
}

function drw() {
document.getElementById(“svg1″).innerHTML = ”;
lft = 0;
tp = 70;
if(s2.value == “Comic Sans MS” || s2.value == “Verdana”) tp += 5;
if (s1.value == “red”) col = [“#553333″,”#773333″,”#993333″,”#bb4444″,”#dd4444″,”#ff4444”];
if (s1.value == “green”) col = [“#335533″,”#337733″,”#339933″,”#33aa33″,”#33bb33″,”#33cc33”];
if (s1.value == “blue”) col = [“#333355″,”#333377″,”#333399″,”#4444bb”,”#5555dd”,”#5555ff”];
if (s1.value == “gold”) col = [“#555500″,”#777700″,”#999900″,”#aaaa00″,”#bbbb00″,”#cccc00”];
if (s1.value == “orange”) col = [“#553300″,”#774400″,”#995500″,”#aa6600″,”#bb7700″,”#cc8800”];
if (s1.value == “magenta”) col = [“#550055″,”#770077″,”#990099″,”#aa00aa”,”#bb00bb”,”#cc00cc”];
if (s1.value == “cyan”) col = [“#005555″,”#007777″,”#009999″,”#00aaaa”,”#00bbbb”,”#00cccc”];
if (s1.value == “silver”) col = [“#555555″,”#777777″,”#999999″,”#bbbbbb”,”#dddddd”,”#eeeeee”];
if (s1.value == “brown”) col = [“#553311″,”#774422″,”#885533″,”#996644″,”#aa7755″,”#bb8866”];
if (s1.value == “purple”) col = [“#550044″,”#770066″,”#990088″,”#aa0099″,”#bb00aa”,”#cc00bb”];
s1.value = “color”;
for (var i = 0; i <= 5; i ++) {
lft += 2;
tp += 2;
document.getElementById(“svg1″).innerHTML += ‘<text x=”‘ + lft + ‘” y=”‘+ tp + ‘” fill=”‘ + col[i] + ‘” font-size=”100″ font-family=”‘ + document.getElementById(“s2″).value + ‘” font-style=”italic” >’ + document.getElementById(“t1”).value + ‘</text>’;
}
}

function sve() {
document.getElementById(“svg1”).style.backgroundColor = “white”;
var textToSave = ‘<?xml version=”1.0″ encoding=”UTF-8″ standalone=”no”?> <svg xmlns:svg=”http://www.w3.org/2000/svg&#8221; xmlns=”http://www.w3.org/2000/svg&#8221; width=”‘ + wd + ‘” height=”‘ + ht + ‘” id=”svg1″ >’ + document.getElementById(“svg1”).innerHTML + ‘</svg>’;
//alert(textToSave);
var textToSaveAsBlob = new Blob([textToSave], {type:”text/plain”});
var textToSaveAsURL = window.URL.createObjectURL(textToSaveAsBlob);
fileNameToSaveAs = prompt(“FileName to save as”,oldURL);
oldURL = fileNameToSaveAs;
var downloadLink = document.createElement(“a”);
downloadLink.download = fileNameToSaveAs;
downloadLink.innerHTML = “Download File”;
downloadLink.href = textToSaveAsURL;
downloadLink.onclick = destroyClickedElement;
downloadLink.style.display = “none”;
document.body.appendChild(downloadLink);
downloadLink.click();
}

function destroyClickedElement(event) {
document.body.removeChild(event.target);
}
</script>
</body></html>


The main function is named drw(). it sets up a series of svg text elements at incremented locations to give a gradient effect:
for (var i = 0; i <= 5; i ++) {
lft += 2;
tp += 2;
document.getElementById(“svg1″).innerHTML += ” + document.getElementById(“t1″).value + ”;
}

The chosen color is derived from a series of arrays:
if (s1.value == “purple”) col = [“#550044″,”#770066″,”#990088″,”#aa0099″,”#bb00aa”,”#cc00bb”];

The svg element was created larger than the string that would be embedded and then resized to fir te text. The reason for the slight color is to see it as igt resizes. The saved file has no color.

This is the resizing code:
function rsize(e) {

if (e.key == “ArrowLeft”) {
if(document.getElementById(“ch1”).checked) {
wd -= 1;
} else {
wd -= 70;
}
document.getElementById(“svg1”).style.width= wd + “px”;
}

if (e.key == “ArrowRight”) {
if(document.getElementById(“ch1”).checked) {
wd += 1;
} else {
wd += 70;
}
document.getElementById(“svg1”).style.width= wd + “px”;
}

if (e.key == “ArrowUp”) {
ht –;
document.getElementById(“svg1”).style.height= ht + “px”;
}

if (e.key == “ArrowDown”) {
ht ++;
document.getElementById(“svg1”).style.height= ht + “px”;
}
}

The code for the saved svg file has the following appearence:

The code for the saved svg file has the following appearence:

 

<?xml version=”1.0″ encoding=”UTF-8″ standalone=”no”?> <svg xmlns:svg=”http://www.w3.org/2000/svg&#8221; xmlns=”http://www.w3.org/2000/svg&#8221; width=”147″ height=”200″ id=”svg1″ ><text x=”2″ y=”72″ fill=”#553333″ font-size=”100″ font-family=”Georgia” font-style=”italic”>res</text><text x=”4″ y=”74″ fill=”#773333″ font-size=”100″ font-family=”Georgia” font-style=”italic”>res</text><text x=”6″ y=”76″ fill=”#993333″ font-size=”100″ font-family=”Georgia” font-style=”italic”>res</text><text x=”8″ y=”78″ fill=”#bb3333″ font-size=”100″ font-family=”Georgia” font-style=”italic”>res</text><text x=”10″ y=”80″ fill=”#dd3333″ font-size=”100″ font-family=”Georgia” font-style=”italic”>res</text></svg>










The main function is named drw(). it sets up a series of svg text elements at incremented locations to give a gradient effect:
for (var i = 0; i <= 5; i ++) {
lft += 2;
tp += 2;
document.getElementById(“svg1″).innerHTML += ” + document.getElementById(“t1″).value + ”;
}

The chosen color is derived from a series of arrays:
if (s1.value == “purple”) col = [“#550044″,”#770066″,”#990088″,”#aa0099″,”#bb00aa”,”#cc00bb”];

The svg element was created larger than the string that would be embedded and then resized to fir te text. The reason for the slight color is to see it as igt resizes. The saved file has no color.

This is the resizing code:
function rsize(e) {

if (e.key == “ArrowLeft”) {
if(document.getElementById(“ch1”).checked) {
wd -= 1;
} else {
wd -= 70;
}
document.getElementById(“svg1”).style.width= wd + “px”;
}

if (e.key == “ArrowRight”) {
if(document.getElementById(“ch1”).checked) {
wd += 1;
} else {
wd += 70;
}
document.getElementById(“svg1”).style.width= wd + “px”;
}

if (e.key == “ArrowUp”) {
ht –;
document.getElementById(“svg1”).style.height= ht + “px”;
}

if (e.key == “ArrowDown”) {
ht ++;
document.getElementById(“svg1”).style.height= ht + “px”;
}
}

The code for the saved svg file has the following appearence:

resresresresres

View Youtube Videos in 3d

This app allows the viewing of Youtube videos in 3d.
It involves getting the embed code of the video and using the url to view the video in an iframe.
A caveat: for most videos this file must be run from a server of simulated server, or a Video Unavailable message is obtained.

This is the code:

<html>
<body>
<div id=”frame” style = “position: absolute; width: 100%; height: 100%; top: 40px; background:black” ></div>
<select id= “s1″ onchange=’strt();’><option>Choose File</option><option>Roller Coaster</option><option>White Water</option><option>Toboggan</option><option>Scuba Diving</option><option>Honeymooners</option><option>Dick Van Dyke</option><option>Skiing</option></select> <input type=”text” id=”t1″ value = “” placeholder=”rotate (default: 22)” />
<script>
var param = ‘<iframe id=”if1″ frameborder=”0″ allow=”accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share”‘; var ht; var wd; var rotat; var cnt = 0; var si; var a; var b;
function strt() {
var choice = document.getElementById(“s1”).value;
if (choice == “Roller Coaster”) param += ‘src=”https://www.youtube.com/embed/oAJLKDMihnU&#8221; width = “887 “; height = “499 ” ></iframe>’;
if (choice == “White Water”) param += ‘src=”https://www.youtube.com/embed/DXFehwLKO6I&#8221; width = “887 “; height = “499 ” ></iframe>’;
if (choice == “Toboggan”) param += ‘src=”https://www.youtube.com/embed/oRzs-HaRP_c&#8221; width = “887 “; height = “499 ” ></iframe>’;
if (choice == “Scuba Diving”) param += ‘src=”https://www.youtube.com/embed/bNucJgetMjE&#8221; width = “887 “; height = “499 ” ></iframe>’;
if (choice == “Honeymooners”) param += ‘src=”https://www.youtube.com/embed/em1DEwOtm3I&#8221; width = “665 “; height = “499 ” ></iframe>’;
if (choice == “Dick Van Dyke”) param += ‘src=”https://www.youtube.com/embed/jNXxWXBShFk&#8221; width = “887 “; height = “499 ” ></iframe>’;
if (choice == “Skiing”) param += ‘src=”https://www.youtube.com/embed/fbqHK8i-HdA&#8221; width = “887 “; height = “499 ” ></iframe>’;
a = param.indexOf(‘width = “‘);
wd = parseInt(param.substr(a + 9, 4));
a = param.indexOf(‘height = “‘);
ht = parseInt(param.substr(a + 9, 4));
document.getElementById(“frame”).innerHTML = param;
document.getElementById(“if1”).style.width = wd + “px”;
document.getElementById(“if1”).style.height = ht + “px”;
document.getElementById(“if1”).style.transform = “webkitRotateY(30deg)”;
document.getElementById(“if1”).style.transform = “rotateY(30deg)”;
rotat = (22 * (400 / wd)) + “deg”;
setTimeout(“go()”,10000);
}

function go(){
si = setInterval(“rot()”, 200);
}

function rot() {
if (document.getElementById(“t1”).value != “”) rotat = (parseInt(document.getElementById(“t1”).value) * (400 / wd)) + “deg”;
cnt ++;
if (cnt % 2 == 1) {
document.getElementById(“if1”).style.transform = “webkitRotateY(” + rotat + “)”;
document.getElementById(“if1”).style.transform = “rotateY(” + rotat + “)”;
} else {
document.getElementById(“if1”).style.transform = “webkitRotateY(0deg)”;
document.getElementById(“if1”).style.transform = “rotateY(0deg)”;
}
if (cnt == 10) cnt = 0;
}
</script>
</body></html>

A select element is set up:
<select id= “s1” onchange=’strt();’><option>Choose File</option><option>Roller Coaster</option><option>White Water</option><option>Toboggan</option><option>Scuba Diving</option><option>Honeymooners</option><option>Dick Van Dyke</option><option>Skiing</option></select>

var choice = document.getElementById(“s1”).value;
if (choice == “Roller Coaster”) param += ‘src=”https://www.youtube.com/embed/oAJLKDMihnU&#8221; width = “887 “; height = “499 ” ></iframe>’;
if (choice == “White Water”) param += ‘src=”https://www.youtube.com/embed/DXFehwLKO6I&#8221; width = “887 “; height = “499 ” ></iframe>’;
if (choice == “Toboggan”) param += ‘src=”https://www.youtube.com/embed/oRzs-HaRP_c&#8221; width = “887 “; height = “499 ” ></iframe>’;
if (choice == “Scuba Diving”) param += ‘src=”https://www.youtube.com/embed/bNucJgetMjE&#8221; width = “887 “; height = “499 ” ></iframe>’;
if (choice == “Honeymooners”) param += ‘src=”https://www.youtube.com/embed/em1DEwOtm3I&#8221; width = “665 “; height = “499 ” ></iframe>’;
if (choice == “Dick Van Dyke”) param += ‘src=”https://www.youtube.com/embed/jNXxWXBShFk&#8221; width = “887 “; height = “499 ” ></iframe>’;
if (choice == “Skiing”) param += ‘src=”https://www.youtube.com/embed/fbqHK8i-HdA&#8221; width = “887 “; height = “499 ” ></iframe>’;

The URL is loaded and the iframe set to the video size:
a = param.indexOf(‘width = “‘);
wd = parseInt(param.substr(a + 9, 4));
a = param.indexOf(‘height = “‘);
ht = parseInt(param.substr(a + 9, 4));
document.getElementById(“frame”).innerHTML = param;
document.getElementById(“if1”).style.width = wd + “px”;
document.getElementById(“if1”).style.height = ht + “px”;

A time delay allows the clicking of the Youtube play:
setTimeout(“go()”,10000);

The amount of rotation is set:
rotat = (22 * (400 / wd)) + “deg”;

function go() sets up the Yrotation:
function go(){
si = setInterval(“rot()”, 200);
}

function rot() {
if (document.getElementById(“t1”).value != “”) rotat = (parseInt(document.getElementById(“t1”).value) * (400 / wd)) + “deg”;
cnt ++;
if (cnt % 2 == 1) {
document.getElementById(“if1”).style.transform = “webkitRotateY(” + rotat + “)”;
document.getElementById(“if1”).style.transform = “rotateY(” + rotat + “)”;
} else {
document.getElementById(“if1”).style.transform = “webkitRotateY(0deg)”;
document.getElementById(“if1”).style.transform = “rotateY(0deg)”;
}
if (cnt == 10) cnt = 0;
}

The rotation is adjustable; More rotation gives a greater effect but too much can be distracting.
Since the rotationm is interactively controlled, it can be customized for each video to give the best compromise.

View YouTube Videos in 3d

This extends the 3d viewer to YouTube videos.

Click to Try

<!DOCTYPE html>
<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head profile=”http://gmpg.org/xfn/11″&gt;
<title>Wobble Video</title>
<style>
body {margin-left:0;margin-right:0;font:normal normal normal 15px Arial;background: black}
a{ text-decoration: }:link { color: rgb(0, 0, 255) }:visited {color :rgb(100, 0,100) }:hover { }:active { }
#frame{position: absolute; left: 50%; top: 50%; border: 12px ridge tan}
input{position: relative}
</style>
</head>
<body>
<select id=”s1″ onchange=’ld();’><option>Choose Video</option><option>width=”1028″ height=”578″ src=”https://www.youtube.com/embed/kYsWz79MN5Q”</option><option>House_of_Wax__Segment_0_VP8.webm</option></select&gt;
<input type = “text” id = “t1” placeholder = “choose wobble rate; eg 500″ /> <select id=”vol” style=”position: relative” onchange=’vlm();’></select> <input type = “text” id = “t2” placeholder = “wobble amount; eg .01″ /> <input type=”button” id=”b1″ value=”New” onclick=’location.reload();’ />
<div id=”frame”></div>
<script>
var wd; var ht; var cnt = 0; var si; var rt = 200; var wobb = .01;
for (var i = 0; i <= 20; i ++) {
if (i == 0) document.getElementById(“vol”).innerHTML = “<option>Choose Volume</option>”;
if (i > 0) document.getElementById(“vol”).innerHTML += “<option>” + (.05 * i).toFixed(2) + “</option>”;
}

function ld() {
s = “” + document.getElementById(“s1”);
wd = 0; ht = 0;
rt = 200;
clearInterval(si);

if (document.getElementById(“s1”).value.indexOf(“mp4”) != -1 || document.getElementById(“s1”).value.indexOf(“webm”) != -1) {
document.getElementById(“frame”).innerHTML = ‘<video id=”im1″ autoplay=”true” loop=”true” controls=”true” ><source src=”TestImages/’ + document.getElementById(“s1″).value + ‘” style = “position: absolute” ></video>’;
} else {
document.getElementById(“frame”).innerHTML = ‘<iframe id = “im1” ‘ + document.getElementById(“s1″).value + ‘ title=”YouTube video player” frameborder=”0″ allow=”accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope”;</iframe>’;
}
setTimeout(“ld2()”, 500);
}

function ld2() {
//var s = “” + document.getElementById(“s1”);
wd = im1.clientWidth;
ht = im1.clientHeight;

if(document.getElementById(“frame”).innerHTML.indexOf(“img”) == -1) {
document.getElementById(“im1”).volume = .5;
if (wd/ht <= 1.65) {
document.getElementById(“im1”).style.height = “680px”;
} else if (wd/ht <= 1.85) {
document.getElementById(“im1”).style.height = “640px”;
} else if (wd/ht <= 2.0) {
document.getElementById(“im1”).style.height = “610px”;
} else if (wd/ht <= 2.5) {
document.getElementById(“im1”).style.height = “560px”;
} else {
document.getElementById(“im1”).style.height = “450px”;
}
}

wd = im1.clientWidth;
ht = im1.clientHeight;
if (document.getElementById(“t2”).value != “”) wobb = parseFloat(document.getElementById(“t2”).value);
document.getElementById(“frame”).style.width = (1 – wobb) * wd + “px”;
document.getElementById(“frame”).style.height = ht + “px”;
if (document.getElementById(“frame”).innerHTML.indexOf(“img” > -1)) document.getElementById(“frame”).style.overflow = “hidden”;
document.getElementById(“frame”).style.marginLeft= -wd/2 + “px”;
document.getElementById(“frame”).style.marginTop= -ht/2 + “px”;
if (document.getElementById(“t1”).value != “”) rt = parseInt(document.getElementById(“t1”).value);
si = setInterval(“rot()”,rt);
}

function rot() {
cnt ++;
if (cnt % 2 == 0) {
document.getElementById(“im1”).style.left = -wobb * wd + “px”;
} else {
document.getElementById(“im1”).style.left = 0;
}
}

function vlm() {
document.getElementById(“im1”).volume = parseFloat(document.getElementById(“vol”).value);
}
</script>
</body></html>

It takes the YouTube embed code and inserts parts of it in two places.
Part is placed in the ld() function:
else {
document.getElementById(“frame”).innerHTML = ‘<iframe id = “im1” ‘ + document.getElementById(“s1″).value + ‘ title=”YouTube video player” frameborder=”0″ allow=”accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope”;</iframe>’;
}

The other part in a select optiion:
<option>width=”1028″ height=”578″ src=”https://www.youtube.com/embed/kYsWz79MN5Q”</option&gt;

One Window 3d Videos

This app extends the concept of the previous one to videos. Images can be used as well, but I am restricting the discussion to videos.

Click to Try

Sometimes it is necessary to reload to page to get the correct resizing.

This is the code:

<!DOCTYPE html>
<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head profile=”http://gmpg.org/xfn/11″&gt;
<title>Wobble Video</title>
<style>
body {margin-left:0;margin-right:0;font:normal normal normal 15px Arial;background: black}
a{ text-decoration: }:link { color: rgb(0, 0, 255) }:visited {color :rgb(100, 0,100) }:hover { }:active { }
#frame{position: absolute; left: 50%; top: 50%; border: 12px ridge tan}
input{position: relative}
</style>
</head>
<body>
<select id=”s1″ onchange=’ld();’><option>Choose Video</option><option>House_of_Wax__Segment_0_VP8.webm</option></select>
<input type = “text” id = “t1” placeholder = “choose wobble rate; eg 500″ /> <select id=”vol” style=”position: relative” onchange=’vlm();’></select> <input type = “text” id = “t2” placeholder = “wobble amount; eg .01″ /> <input type=”button” id=”b1″ value=”New” onclick=’location.reload();’ />
<div id=”frame”></div>
<script>
var wd; var ht; var cnt = 0; var si; var rt = 200; var wobb = .01;
for (var i = 0; i <= 20; i ++) {
if (i == 0) document.getElementById(“vol”).innerHTML = “<option>Choose Volume</option>”;
if (i > 0) document.getElementById(“vol”).innerHTML += “<option>” + (.05 * i).toFixed(2) + “</option>”;
}

function ld() {
s = “” + document.getElementById(“s1”);
wd = 0; ht = 0;
rt = 200;
clearInterval(si);

if (document.getElementById(“s1”).value.indexOf(“mp4”) != -1 || document.getElementById(“s1”).value.indexOf(“webm”) != -1) {
document.getElementById(“frame”).innerHTML = ‘<video id=”im1″ autoplay=”true” loop=”true” controls=”true” ><source src=”TestImages/’ + document.getElementById(“s1″).value + ‘” style = “position: absolute” ></video>’;
} else {
document.getElementById(“frame”).innerHTML = ‘<img id=”im1″ src=”‘ + document.getElementById(“s1″).value + ‘” style = “position: absolute” />’;
}
setTimeout(“ld2()”, 500);
}

function ld2() {
wd = im1.clientWidth;
ht = im1.clientHeight;

if(document.getElementById(“frame”).innerHTML.indexOf(“img”) == -1) {
document.getElementById(“im1”).volume = .5;
if (wd/ht <= 1.65) {
document.getElementById(“im1”).style.height = “680px”;
} else if (wd/ht <= 1.85) {
document.getElementById(“im1”).style.height = “640px”;
} else if (wd/ht <= 2.0) {
document.getElementById(“im1”).style.height = “610px”;
} else if (wd/ht <= 2.5) {
document.getElementById(“im1”).style.height = “560px”;
} else {
document.getElementById(“im1”).style.height = “450px”;
}
}

wd = im1.clientWidth;
ht = im1.clientHeight;
if (document.getElementById(“t2”).value != “”) wobb = parseFloat(document.getElementById(“t2”).value);
document.getElementById(“frame”).style.width = (1 – wobb) * wd + “px”;
document.getElementById(“frame”).style.height = ht + “px”;
if (document.getElementById(“frame”).innerHTML.indexOf(“img” > -1)) document.getElementById(“frame”).style.overflow = “hidden”;
document.getElementById(“frame”).style.marginLeft= -wd/2 + “px”;
document.getElementById(“frame”).style.marginTop= -ht/2 + “px”;
if (document.getElementById(“t1”).value != “”) rt = parseInt(document.getElementById(“t1”).value);
si = setInterval(“rot()”,rt);
}

function rot() {
cnt ++;
if (cnt % 2 == 0) {
document.getElementById(“im1”).style.left = -wobb * wd + “px”;
} else {
document.getElementById(“im1”).style.left = 0;
}
}

function vlm() {
document.getElementById(“im1”).volume = parseFloat(document.getElementById(“vol”).value);
}
</script>
</body></html>

A mp4 or webm file will be loaded:
if (document.getElementById(“s1”).value.indexOf(“mp4”) != -1 || document.getElementById(“s1”).value.indexOf(“webm”) != -1) {
document.getElementById(“frame”).innerHTML = ‘<video id=”im1″ autoplay=”true” loop=”true” controls=”true” ><source src=”Videos/’ + document.getElementById(“s1″).value + ‘” style = “position: absolute” ></video>’;

As before, a delay is needed to get the dimensions:
setTimeout(“ld2()”, 500);

The window size is set with the following code:
if (wd/ht <= 1.65) {
document.getElementById(“im1”).style.height = “680px”;
} else if (wd/ht <= 1.85) {
document.getElementById(“im1”).style.height = “640px”;
} else if (wd/ht <= 2.0) {
document.getElementById(“im1”).style.height = “610px”;
} else if (wd/ht <= 2.5) {
document.getElementById(“im1”).style.height = “560px”;
} else {
document.getElementById(“im1”).style.height = “450px”;
}

Additionally the function vlm() adjusts th playback volume:
function vlm() {
document.getElementById(“im1”).volume = parseFloat(document.getElementById(“vol”).value);
}

Although a listing indicates the left position of the video is periodically being cycled, there is no appearance of this on the video, just a 3d effect.

One Window 3d Images

This exploits the automatic resizing and centering of a division around an image to create a wobble-3d viewer for images. There is a slight wobble noticeable, but in my opinion, it is not obtrusive.

Click to Try

<!DOCTYPE html>
<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head profile=”http://gmpg.org/xfn/11″&gt;
<title>HTML Editor</title>
<style>
body {margin-left:0;margin-right:0;font:normal normal normal 15px Arial;background: black}
a{ text-decoration: }:link { color: rgb(0, 0, 255) }:visited {color :rgb(100, 0,100) }:hover { }:active { }
#frame{position: absolute; left: 50%; top: 50%; border: 12px ridge tan; overflow: hidden}
</style>
</head>
<body>
<div id=”frame”></div>
<select id=”s1″ onchange=’ld();’><option>Choose Image</option><option>images/SAG.png</option><option>../DBackup/My Pictures/A-E/aloe.png</option><option>../DBackup/My Pictures/F-J/garden.png</option></select>
<script>
var wd; var ht; var rt = 200; var cnt = 0; var wobb = .002; var si; var si2; var cnt2 = 0;

function ld() {
document.getElementById(“frame”).innerHTML = ‘<img id=”im1″ src=”‘ + document.getElementById(“s1″).value + ‘” style = “position: absolute” />’;
setTimeout(“ld2()”, 500);
}

function ld2() {
wd = im1.clientWidth;
ht = im1.clientHeight;
document.getElementById(“frame”).style.marginLeft= -wd/2 + “px”;
document.getElementById(“frame”).style.marginTop= -ht/2 + “px”;
document.getElementById(“frame”).style.width = (1 – wobb) * wd + “px”;
document.getElementById(“frame”).style.height = ht + “px”;
si = setInterval(“rot()”,rt);
//si2 = setInterval(“bl()”,100);
}

function rot() {
cnt ++;
if (cnt % 2 == 0) {
document.getElementById(“im1”).style.left = -wobb * wd + “px”;
} else {
document.getElementById(“im1”).style.left = 0;
}
}

</script>
</body></html>

The wobble is applied by the function rot():
function rot() {
cnt ++;
if (cnt % 2 == 0) {
document.getElementById(“im1”).style.left = -wobb * wd + “px”;
} else {
document.getElementById(“im1”).style.left = 0;
}
}

The image is alternately displaced to the left by a fraction of its width by given by the variable wobb. The overlap is set to “hidden” so the overlap cannot be seen.
The background is also set to black, because I think that is better for viewing images.

3d rotation of svg objects

This app demonstrates using rotateY to animate 3-dimensional objects placed in svg elements. One object is a pyramid and the other is a cube. The pyramid is made from polygons and the cube from rectangles and lines. The svg elements are placed on a image background.

Click to Try

This is the code:

<!DOCTYPE html>
<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head profile=”http://gmpg.org/xfn/11″&gt;
<title>HTML Editor</title>
<style>
body {margin-left:0;margin-right:0;font:normal normal normal 15px Arial;}
a{ text-decoration: }:link { color: rgb(0, 0, 255) }:visited {color :rgb(100, 0,100) }:hover { }:active { }
#svg1{position: absolute; width: 100px; height: 200px; left: 350px; top: 390px;}
#svg2{position: absolute; width: 310px; height: 310px; left: 825px; top: 335px;}
</style>
</head>
<body onload = ‘go();’>
<img id = “im1” src= “../../My Pictures/F-J/garden.jpg” style = “width: 100%” />
<svg id=”svg2″ >
<rect x=”5″ y=”55″ width=”200″ height=”200″ style=”fill:black; fill-opacity: .4 ; stroke:orange ; stroke-width: 2px” />
<rect x=”105″ y=”5″ width=”200″ height=”200″ style=”fill:none ; stroke:orange ; stroke-width: 2px” />
<line x1 = “5” y1 = “55” x2 = “105” y2 = “5” style=”stroke:orange ; stroke-width: 2px” />
<line x1 = “205” y1 = “55” x2 = “305” y2 = “5” style=”stroke:orange ; stroke-width: 2px” />
<line x1 = “5” y1 = “255” x2 = “105” y2 = “205” style=”stroke:orange ; stroke-width: 2px” />
<line x1 = “205” y1 = “255” x2 = “305” y2 = “205” style=”stroke:orange; stroke-width: 2px” />
</svg>
<svg id=”svg1″ >
<polygon points=”45,80 55,185 0,200 45,80 90,200 55,185″ style=”fill:lime;stroke:purple;stroke-width:1″/>
<polygon points=”0,200 55,185 90,200″ style=”fill:lime;stroke:purple;stroke-width:1″/>
</svg>

<script type=”text/javascript”>
var rot = 0; var si; var rotlim = 4;
function go() {
clearInterval(si);
document.getElementById(“svg1”).style.top = (im1.clientHeight – 200) + “px”;
document.getElementById(“svg2”).style.top = (im1.clientHeight – 265) + “px”;
si = setInterval(“cont()”,25);
}

function cont() {
rot += .25;

if (rot == 360) rot = 0;
if (rot == rotlim ) rot = 180 – rotlim;
if (rot == 180 + rotlim) rot = 360 – rotlim;
document.getElementById(“svg1”).style.transform = ‘rotateY(‘ + rot + ‘deg)’;
document.getElementById(“svg2”).style.transform = ‘rotateY(‘ + rot + ‘deg)’;
}
</script>
</body></html>

In both cases the object is made to nearly completely fill the svg container. The svg container is the element that is actually rotated and to get the object rotation centered, it must be the same size as its container.

This is the pyramid:
<polygon points=”45,80 55,185 0,200 45,80 90,200 55,185″ style=”fill:lime;stroke:purple;stroke-width:1″/>
<polygon points=”0,200 55,185 90,200″ style=”fill:lime;stroke:purple;stroke-width:1″/>

This is the cube:
<rect x=”5″ y=”55″ width=”200″ height=”200″ style=”fill:black; fill-opacity: .4 ; stroke:orange ; stroke-width: 2px” />
<rect x=”105″ y=”5″ width=”200″ height=”200″ style=”fill:none ; stroke:orange ; stroke-width: 2px” />
<line x1 = “5” y1 = “55” x2 = “105” y2 = “5” style=”stroke:orange ; stroke-width: 2px” />
<line x1 = “205” y1 = “55” x2 = “305” y2 = “5” style=”stroke:orange ; stroke-width: 2px” />
<line x1 = “5” y1 = “255” x2 = “105” y2 = “205” style=”stroke:orange ; stroke-width: 2px” />
<line x1 = “205” y1 = “255” x2 = “305” y2 = “205” style=”stroke:orange; stroke-width: 2px” />

Other parts of this have been discussed before.

A HTML One Window No Glasses 3d Video Viewer


I have made several attempts in the past at a 3d video viewer and I finally have what I think is the best viewer. It allows single image, no glasses 3d viewing of 2d videos and is quite simple.

The app opens with a short clip, so rather than show a captured video, I have elected to have you view the app:

View App

The app uses the principle of the wobble 3d. Run windowed the wobble is virtually unnoticeable. Run fullscreen it is unnoticeable.

The video can be taken out of fullscreen mode either with the control panel or by hitting the escape key.

While the video is not fullscreen hitting any key other than escape or clicking the video will open a dialog in which a new video can be chosen. The code must be modified to include a list of folders containing videos to be played. The file can then be chosen with the file input.

All computers seem to support WebM while some may support MP4 as well.

Here is the code:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;
<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head profile=”http://gmpg.org/xfn/11″&gt;
<title>Wobble Video</title>
<style>
body {margin-left:0;margin-right:0;font:normal normal normal 15px Arial;background: black}
a{ text-decoration: }:link { color: rgb(0, 0, 255) }:visited {color :rgb(100, 0,100) }:hover { }:active { }
#im1{position: absolute; left: 20%; top:2% ; width:60% ; -webkit-perspective: 10; -webkit-transform-style: preserve-3d; -webkit-transition: all 1.0s linear; -moz-perspective: 10; -moz-transform-style: preserve-3d; -webkit-transition: all 1.0s linear;}
#d1{position: absolute; left:2% ; top:2% ; width:50% ; height:25% ; background: white; visibility: hidden }
</style>
</head>
<body onload=’go1();’>
<video id=”im1″ autoplay = “true” controls=”controls” ><source src=”” type=’video/webm; codecs=”vp8.0, vorbis”‘> <source src=”” type=’video/ogg; codecs=”theora, vorbis”‘> <source src=”” type=’video/mp4; codecs=”avc1.4D401E, mp4a.40.2″‘></video>’;
<di id=”d1″>
<input type=”file” id=”files” name=”files” /><br />
<select id = “s1″>
<option>Select Folder</option>
<option></option>
<option>file:///media/removable/TOSHIBA%20EXT/mediaplayer-viral/FLV/WebM/</option>
<option>file:///media/removable/TOSHIBA%20EXT/Debut/Wondershare/MP4/</option>
<option>file:///media/removable/USB%20Drive/videos/</option>
<option>file://D:/mediaplayer-viral/FLV/WebM/</option>
<option>file://D:/Debut/Wondershare/MP4/</option>
<option>file:///media/dynabar/TOSHIBA EXT/mediaplayer-viral/FLV/WebM/</option>
<option>file:///media/dynabar/TOSHIBA EXT/Debut/Wondershare/MP4/</option>
</select><br />
<input type=”button” id=”b1″ name=”b1″ value=”Play” onclick=’go1();’;/>
</di>

var cnt = 0; var si; var fl = “Kiss_Me_Kate_xvid_Segment_0_VP8.webm”; var fldr = “”;
document.onkeyup = rset;

function rset(e) {
if (e.keyCode != 27) {
clearInterval(si);
document.getElementById(“files”).value = “”;
document.getElementById(“im1”).src = “”;
fl = “”;
cnt = 0;
fldr = “”;
document.getElementById(“d1″).style.visibility=”visible”;
}
}

function go1() {
if (fl == “”) {
fl = document.getElementById(“files”).value;
fldr = document.getElementById(“s1”).value;
}
if (fl.indexOf(“fake”) > -1) fl = fl.substr(12);
document.getElementById(“im1”).src = fldr + fl;
si = setInterval(“wobble()”,100);
document.getElementById(“d1″).style.visibility=”hidden”;
}

function wobble() {
cnt ++;
if (cnt % 2 == 1) {

document.getElementById(“im1”).style.WebkitTransform= “rotateY(11deg)”;
} else {
document.getElementById(“im1”).style.WebkitTransform= “rotateY(1deg)”;
}
if ( cnt == 2) cnt = 0;
}

</body></html>


The app uses the video tag:
<video id=”im1″ autoplay = “true” controls=”controls” ><source src=”” type=’video/webm; codecs=”vp8.0, vorbis”‘> <source src=”” type=’video/ogg; codecs=”theora, vorbis”‘> <source src=”” type=’video/mp4; codecs=”avc1.4D401E, mp4a.40.2″‘></video>’;

As I had previously said, wobble 3d, in which two views of an image are rapidly alternated, is used. Since I did not have two images for each frame, I simulated it with alternating 3d y rotations.

A timer is started:
function go1() {
if (fl == “”) {
fl = document.getElementById(“files”).value;
fldr = document.getElementById(“s1”).value;
}
if (fl.indexOf(“fake”) > -1) fl = fl.substr(12);
document.getElementById(“im1”).src = fldr + fl;
si = setInterval(“wobble()”,100);
document.getElementById(“d1″).style.visibility=”hidden”;
}

This function also gets the path and hides the dialog.

The timer calls the function wobble at 100ms intervals which does the y rotation on videos set up for 3d rotation:
si = setInterval(“wobble()”,100);

function wobble() {
cnt ++;
if (cnt % 2 == 1) {

document.getElementById(“im1”).style.WebkitTransform= “rotateY(11deg)”;
} else {
document.getElementById(“im1”).style.WebkitTransform= “rotateY(1deg)”;
}
if ( cnt == 2) cnt = 0;
}

#im1{position: absolute; left: 20%; top:2% ; width:60% ; -webkit-perspective: 10; -webkit-transform-style: preserve-3d; -webkit-transition: all 1.0s linear; -moz-perspective: 10; -moz-transform-style: preserve-3d; -webkit-transition: all 1.0s linear;}

Image Objects Update

I had previously discussed the use of Image Objects in 3d Web Pages

This posts has several updates:

An app to generate the pages is included.
I have included animated gif images in as both background and objects.
The objects can be rotated.

Here is an example of a page created with the app

Click Image for larger view

XCountry

Notice that the object is used twice, each time at a different rotation.

Here is the code for the app:

<!DOCTYPE html PUBLIC ‘-//W3C//DTD XHTML 1.0 Transitional//EN’ ‘http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd’&gt;
<html xmlns=’http://www.w3.org/1999/xhtml’&gt;
<head profile=’http://gmpg.org/xfn/11′&gt;
<title>Enter Title Here</title>
<style type=’text/css’>
body {margin-left:0;margin-right:0;font:normal normal normal 12px Arial; }
a{ text-decoration: }
:link { color: rgb(0, 0, 255) }
:visited {color :rgb(100, 0,100) }
:hover { }
:active { }
#i2,#i3,#i4{position: absolute}
#i1{position: relative}
input{width: 60px}
#files{width: 200px}
#sav{position: absolute; width: 100%; height: 100%; top: 0; visibility: hidden; background: #EEEEEE; padding: 5px}
</style>
</head>
<body>
<center>Choose Image <input type=”file” id=”files” name=”files” /> <button name=”b1″ value=”” onclick=’rot();’>Load</button> <input type=”text” id=”t1″ name=”t1″ value=”Left” ondblclick=’clearInterval(si);’/> <input type=”text” id=”t2″ name=”t2″ value=”Height” /> <input type=”text” id=”t3″ name=”t3″ value=”Top” /> <input type=”text” id=”t4″ name=”t4″ value=”Rotate” /> Folder<select id = “s1″ name=”s1″><option></option><option>file://D:/My Pictures/</option><option>file://D:/My Pictures/threed/</option><option>file://D:/My Pictures/Animated GIF/</option></select> <input type=”button” id=”b2″ name=”b2″ value=”Redo” onclick=’clearInterval(si); redo();’ /> <input type=”button” id=”b3″ name=”b3″ value=”Save” onclick=’save();’ /><br />
<di id=”frame” style=”width: 1100px; height: 570px; background: black”></di></center><textarea id=”sav”name=”sav” rows=”rows” cols=”columns”></textarea>

var j = -1; var cnt = 0; var img; var img2; var si; var ratio; var img3; var img4; var done = false; var fl = “”; var im1; var im2; var im3; var im4; var si; var r2 = 0; var r3 = 0; var r4 = 0; var rt2 = false; var rt3 = false; var rt4 = false; var si;function save() {
var r2b = r2 – 5; var r3b = r3 – 7; var r4b = r4 – 9; var r2c = r2 – 10; var r3c = r3 – 12; var r4c = r4 – 14;
var ta = document.getElementById(“sav”);
ta.value = ‘3dImage\n\nbody {margin-left:0;margin-right:0;font:normal normal normal 12px Arial; }\n#i2,#i3,#i4{position: absolute}\n#i1{position:relative}\n\n\n\n
\n\n\n ‘;
ta.value += ‘var imga; var j = -1; var imgb; var imgc; var imgd; var cnt2 =’ + cnt + ‘;\n’;
ta.value += ‘document.getElementById(“frame2″).innerHTML = \” + im1 + ‘\’;\n’;
ta.value += ‘imga = document.getElementById(“i1”);\n’;
if (img.style.width > img.style.height) {
ta.value += ‘imga.style.width = “‘ + img.style.width + ‘”;\n’;
} else {
ta.value += ‘imga.style.height = “‘ + img.style.height + ‘”;\n’;
}
ta.value += ‘document.getElementById(“frame2″).innerHTML += \” + im2 + ‘\’;\n’;
ta.value += ‘imgb = document.getElementById(“i2”);\n’;
ta.value += ‘imgb.style.left = “‘ + img2.style.left + ‘”;\nimgb.style.height = “‘ + img2.style.height + ‘”;\nimgb.style.top = “‘ + img2.style.top + ‘”;\n ‘;
if (cnt > 2) {
ta.value += ‘document.getElementById(“frame2″).innerHTML += \” + im3 + ‘\’;\n’;
ta.value += ‘imgc = document.getElementById(“i3”);\n’;
ta.value += ‘imgc.style.left = “‘ + img3.style.left + ‘”;\nimgc.style.height = “‘ + img3.style.height + ‘”;\nimgc.style.top = “‘ + img3.style.top + ‘”;\n ‘;
}
if (cnt == 4) {
ta.value += ‘document.getElementById(“frame2″).innerHTML += \” + im4 + ‘\’;\n’;
ta.value += ‘imgd = document.getElementById(“i4”);\n’;
ta.value += ‘imgd.style.left = “‘ + img4.style.left + ‘”;\nimgd.style.height = “‘ + img4.style.height + ‘”;\nimgd.style.top = “‘ + img4.style.top + ‘”;\n ‘;
}
ta.value += ‘si = setInterval(“rot2()”, 40);\n’;ta.value += ‘function rot2() {\nj++;\nimga = document.getElementById(“i1”);\nimgb = document.getElementById(“i2”);\n’;
if (cnt == 3 || cnt == 4) ta.value += ‘imgc = document.getElementById(“i3”);\n’;
if (cnt == 4) ta.value += ‘imgd = document.getElementById(“i4″);\n’;
ta.value += ‘if (j==0) {\nimga.style.transform=”rotateY(4deg)”;\nimgb.style.transform=”rotateY(‘ + r2 + ‘deg)”;\nif (cnt2 == 3 || cnt2 == 4) imgc.style.transform=”rotateY(‘ + r3 + ‘deg)”;\nif (cnt2 == 4) imgd.style.transform=”rotateY(‘ + r4 + ‘deg)”;\n}\nif (j==1) {\nimga.style.transform=”rotateY(7deg)”;\nimgb.style.transform=”rotateY(‘ + r2b + ‘deg)”;\nif (cnt2 == 3 || cnt2 == 4) imgc.style.transform=”rotateY(‘ + r3b + ‘deg)”;\nif (cnt2 == 4)\nimgd.style.transform=”rotateY(‘ + r4b + ‘deg)”;\n}\nif (j==2) {\nimga.style.transform=”rotateY(10deg)”;\nimgb.style.transform=”rotateY(‘ + r2c + ‘deg)”;\nif (cnt2 == 3 || cnt2 == 4) imgc.style.transform=”rotateY(‘ + r3c + ‘deg)”;\nif (cnt2 == 4)\nimgd.style.transform=”rotateY(‘ + r4c + ‘deg)”;\n}\nif (j==3) {\nimga.style.transform=”rotateY(7deg)”;\nimgb.style.transform=”rotateY(‘ + r2b + ‘deg)”;\nif (cnt2 == 3 || cnt2 == 4) imgc.style.transform=”rotateY(‘ + r3b + ‘deg)”;\nif (cnt2 == 4)\nimgd.style.transform=”rotateY(‘ + r4b + ‘deg)”;\nj = -1;\n}\n\n}\n’;ta.value += ”;
ta.style.visibility=”visible”;
}

function redo() {
clearInterval(si);
cnt –;
alert(“Make Change”);
done = true;
if (cnt == 1) rt2 = false;
if (cnt == 2 || cnt == 3) rt3 = false;
if (cnt == 4) rt4 = false;
j = -1;
}

function rot() {
if (document.getElementById(“s1”).value != “”) {
document.getElementById(“s1″).style.backgroundColor=”yellow”;
} else {
document.getElementById(“s1″).style.backgroundColor=”white”;
}
cnt++;
var fil = document.getElementById(“files”).value;
if (fil == fl && cnt == 2 && ! done) {
alert(“choose an Object”);
cnt –;
}
fl = fil;
if (fil.indexOf(“fake”) > -1) fil = fil.substr(12, fl.length – 12);
if (cnt == 1) {
document.getElementById(“frame”).innerHTML = ‘‘;
im1= ‘‘;
img = document.getElementById(“i1”);
alert(“loading”);
if (i1.clientWidth/i1.clientHeight ‘;
im2 = ‘‘;
}
img = document.getElementById(“i1”);
img2 = document.getElementById(“i2”);
alert(“loading”);
img2.style.left = document.getElementById(“t1”).value + “%”;
img2.style.height = ((document.getElementById(“t2”).value/85) * img.clientHeight) + “px”;
if (document.getElementById(“t3”).value != “Top”) {
img2.style.top = document.getElementById(“t3”).value + “%”;
document.getElementById(“t3”).style.backgroundColor = “yellow”;
} else {
img2.style.top = ((img.clientHeight – img2.clientHeight) / 2 + 50 ) + “px”;
}
} else if (cnt == 3) {
if (! done) {
document.getElementById(“frame”).innerHTML += ‘‘;
im3 = ‘‘;
}
img = document.getElementById(“i1”);
img2 = document.getElementById(“i2”);
img3 = document.getElementById(“i3”);
alert(“loading”);
img3.style.left = document.getElementById(“t1”).value + “%”;
img3.style.height = ((document.getElementById(“t2”).value/85) * img.clientHeight) + “px”;
if (document.getElementById(“t3”).value != “Top”) {
img3.style.top = document.getElementById(“t3”).value + “%”;
document.getElementById(“t3”).style.backgroundColor = “yellow”;
} else {
img3.style.top = ((img.clientHeight – img3.clientHeight) / 2 + 50 ) + “px”;
}
} else if (cnt == 4) {
if (! done) {
document.getElementById(“frame”).innerHTML += ‘‘;
im4 = ‘‘;
}
img = document.getElementById(“i1”);
img2 = document.getElementById(“i2”);
img3 = document.getElementById(“i3”);
img4 = document.getElementById(“i4”);
alert(“loading”);
img4.style.left = document.getElementById(“t1”).value + “%”;
img4.style.height = ((document.getElementById(“t2”).value/85) * img.clientHeight) + “px”;
if (document.getElementById(“t3”).value != “Top”) {
img4.style.top = document.getElementById(“t3”).value + “%”;
document.getElementById(“t3”).style.backgroundColor = “yellow”;
} else {
img4.style.top = ((img.clientHeight – img4.clientHeight) / 2 + 50 ) + “px”;
}
}
if (cnt > 1) si = setInterval(“rot2()”, 40);
done = false;
if (document.getElementById(“t4”).value != “Rotate”) document.getElementById(“t4”).style.backgroundColor = “yellow”;
}

function rot2() {
j++;

if (j==-0) {
img.style.transform=”rotateY(4deg)”;
if (document.getElementById(“t4”).value != “Rotate” && ! rt2) {
r2 = parseInt(document.getElementById(“t4″).value);
img2.style.transform=”rotateY(” + r2 + “deg)”;
rt2 = true;
}
if (cnt == 3 || cnt == 4) {
if (document.getElementById(“t4”).value != “Rotate” && ! rt3) {
r3 = parseInt(document.getElementById(“t4″).value);
img3.style.transform=”rotateY(” + r3 + “deg)”;
rt3 = true;
}
}
if (cnt == 4) {
if (document.getElementById(“t4”).value != “Rotate” && ! rt4) {
r4 = parseInt(document.getElementById(“t4″).value);
img4.style.transform=”rotateY(” + r4 + “deg)”;
rt4 = true;
}
}
}

if (j==-1) {
img.style.transform=”rotateY(4deg)”;
if (document.getElementById(“t4”).value != “Rotate” && ! rt2) {
r2 = parseInt(document.getElementById(“t4″).value) – 5;
img2.style.transform=”rotateY(” + r2 + “deg)”;
}
if (cnt == 3|| cnt == 4) {
alert(rt2);
if (document.getElementById(“t4”).value != “Rotate” && ! rt3) {
r3 = parseInt(document.getElementById(“t4″).value – 7);
img3.style.transform=”rotateY(” + r3 + “deg)”;
}
}
if (cnt == 4) {
if (document.getElementById(“t4”).value != “Rotate” && ! rt4) {
r4 = parseInt(document.getElementById(“t4″).value – 9);
img4.style.transform=”rotateY(” + r4 + “deg)”;
}
}
}

if (j==2) {
img.style.transform=”rotateY(9deg)”;
if (document.getElementById(“t4”).value != “Rotate” && ! rt2) {
r2 = parseInt(document.getElementById(“t4″).value) – 10;
img2.style.transform=”rotateY(” + r2 + “deg)”;
}

if (cnt == 3 || cnt == 3) {
if (document.getElementById(“t4”).value != “Rotate” && ! rt3) {
r3 = parseInt(document.getElementById(“t4″).value) – 12;
img3.style.transform=”rotateY(” + r3 + “deg)”;
}
}

if (cnt == 4) {
if (document.getElementById(“t4”).value != “Rotate” && ! rt4) {
r4= parseInt(document.getElementById(“t4″).value) – 14;
img4.style.transform=”rotateY(” + r4 + “deg)”;
}
}
}

if (j==3) {
img.style.transform=”rotateY(7deg)”;
if (document.getElementById(“t4”).value != “Rotate” && ! rt2) {
r2 = parseInt(document.getElementById(“t4″).value) – 5;
img2.style.transform=”rotateY(” + r2 + “deg)”;
}
if (cnt == 3|| cnt == 4) {
if (document.getElementById(“t4”).value != “Rotate” && ! rt3) {
r3 = parseInt(document.getElementById(“t4″).value) – 7;
img3.style.transform=”rotateY(” + r3 + “deg)”;
}
}
if (cnt == 4) {
if (document.getElementById(“t4”).value != “Rotate” && ! rt4) {
r4 = parseInt(document.getElementById(“t4″).value) – 9;
img4.style.transform=”rotateY(” + r4 + “deg)”;
}
}
j = -1;
}

}

</body></html>

To use, first load the background image by choosing it with the File box  and  clicking Load.

It is best to have all images in the same folder as the app, as no path is required in that case. I you want to use a file from another folder, the path must be added to the select box and chosen before using the File box.

Next, the first object must be chosen. Before loading, the left and height must be entered in the text boxes; top and rotation are optional. There is a default top which approximately centers the object vertically, and the default rotation is 0.

If not satisfied click Redo.

With each of the Load button, a variable named cnt is incremented. The background and each object correspond to a value of cnt.

When Redo is clicked, the value  of cnt is deceased, so on clicking Load after making changes,  it is increased to its previous value so the changes are made to the current object.

After clicking Load, the effect is immediately apparent.

After being satisfied with the first object, up to two more objects can be added, using either the same or different images.

Here is how the interface appears:

Click Image for larger view

wob3-interface

When satisfied with the scene, click save and a hidden textarea is made visible, with generated code.

A couple of changes must be made before the code can be saved. The two script tags required a space after the opening bracket. These spaces must be removed. Once that is done, the text can be copied, pasted into a text editor and saved as a html file.

Here is the code generated for the viewed example:

<html><head><title>3dImage</title>
<style>
body {margin-left:0;margin-right:0;font:normal normal normal 12px Arial; }
#i2,#i3,#i4{position: absolute}
#i1{position:relative}
</style>
</head>
<body>
<br />
<center>

</center>var imga; var j = -1; var imgb; var imgc; var imgd; var cnt2 =3;
document.getElementById(“frame2”).innerHTML = ‘‘;
imga = document.getElementById(“i1”);
imga.style.width = “1060px”;
document.getElementById(“frame2”).innerHTML += ‘‘;
imgb = document.getElementById(“i2”);
imgb.style.left = “55%”;
imgb.style.height = “217.059px”;
imgb.style.top = “15%”;
document.getElementById(“frame2”).innerHTML += ‘‘;
imgc = document.getElementById(“i3”);
imgc.style.left = “38%”;
imgc.style.height = “337.647px”;
imgc.style.top = “15%”;
si = setInterval(“rot2()”, 40);
function rot2() {
j++;
imga = document.getElementById(“i1”);
imgb = document.getElementById(“i2”);
imgc = document.getElementById(“i3″);
if (j==0) {
imga.style.transform=”rotateY(4deg)”;
imgb.style.transform=”rotateY(35deg)”;
if (cnt2 == 3 || cnt2 == 4) imgc.style.transform=”rotateY(160deg)”;
if (cnt2 == 4) imgd.style.transform=”rotateY(0deg)”;
}
if (j==1) {
imga.style.transform=”rotateY(7deg)”;
imgb.style.transform=”rotateY(30deg)”;
if (cnt2 == 3 || cnt2 == 4) imgc.style.transform=”rotateY(153deg)”;
if (cnt2 == 4)
imgd.style.transform=”rotateY(-9deg)”;
}
if (j==2) {
imga.style.transform=”rotateY(10deg)”;
imgb.style.transform=”rotateY(25deg)”;
if (cnt2 == 3 || cnt2 == 4) imgc.style.transform=”rotateY(148deg)”;
if (cnt2 == 4)
imgd.style.transform=”rotateY(-14deg)”;
}
if (j==3) {
imga.style.transform=”rotateY(7deg)”;
imgb.style.transform=”rotateY(30deg)”;
if (cnt2 == 3 || cnt2 == 4) imgc.style.transform=”rotateY(153deg)”;
if (cnt2 == 4)
imgd.style.transform=”rotateY(-9deg)”;
j = -1;
}}
</body></html>
 

To get this page to appear properly, I had to change div to di, so add the v if you want to use the code.

“imageObjects” and Some Uses for Them

What I call an “Image Object” is a png file with a transparent background and containing only one subject, such as an isolated person.

Here is an example:

Click image for larger view

gimp4

This was made in GIMP by the following method, but I imagine other editors would work as well:

Extract a single figure from an image and paste into GIMP as new image.

create a new transparent layer.

Select the background, select the figure and copy.

Select the transparent layer, paste and anchor the floating selection.

Hide the background and save the layer as a png file.

Here is something I did with the “object”:

Click image for larger view

gimp5

The figure on the right was given perspective, which had the effect of being a 3d rotation. This can be seen by comparing the superimposed images at the bottom.

Another thing that can be done is to use “image objects” to create 3d web pages.

Here is an example:

Click image for larger view

runrs

I had to screen record and convert this to an animated gif, so the quality is reduced, but the idea is there.

here is the code:

<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'&gt;
<html xmlns='http://www.w3.org/1999/xhtml'&gt;
<head profile='http://gmpg.org/xfn/11'&gt;
<title>Enter Title Here</title>
<style>
body {margin-left:0;margin-right:0;font:normal normal normal 15pt Arial;background: #777777}
#i1,#i4{position: absolute; left: 20%; top: 20.5%; height: 380px}
#i4{left: 58%}
#i3{position: absolute; left: 27%; top: 31.5%; height: 380px}
#i2{position: absolute; top: 20%;  left: 15%; width: 70%}
#b1{position: absolute; left: 10%; font:normal normal normal 15pt Arial}
</style>
</head>
<body><br />
<input type=”button” id=”b1″ name=”b1″ value=”rotate” onclick=’rot();’/>
<img id=”i2″ src=”file://D:/Misc/Garden.jpg” width = “” height = “” alt = “” align=”” />
<img id=”i1″ src=”file://D:/Misc/runner1.png” width = “” height = “” alt = “” align=”” />
<img id=”i3″ src=”file://D:/Misc/runner2.png” width = “” height = “” alt = “” align=”” />
<img id=”i4″ src=”file://D:/Misc/runner1.png” width = “” height = “” alt = “” align=”” />
var j = -2; var si; var on = false;
function rot() {
if (! on) {
document.getElementById(“b1”).value = “stop”;
on = true;
} else {
on = false;
document.getElementById(“b1”).value = “rotate”;
}
if (on) {
si = setInterval(“rot1()”, 40);
} else {
clearInterval(si);
}
}function rot1() {
j++;
if (j==-1) {
document.getElementById(“i1″).style.transform=”rotateY(0deg)”;
document.getElementById(“i2″).style.transform=”rotateY(0deg)”;
document.getElementById(“i4″).style.transform=”rotateY(0deg)”;
}
if (j==0) {
document.getElementById(“i1″).style.transform=”rotateY(-4deg)”;
document.getElementById(“i2″).style.transform=”rotateY(3deg)”;
document.getElementById(“i4″).style.transform=”rotateY(-4deg)”;
}
if (j==1) {
document.getElementById(“i1″).style.transform=”rotateY(-8deg)”;
document.getElementById(“i2″).style.transform=”rotateY(6deg)”;
document.getElementById(“i3″).style.transform=”rotateY(-8deg)”;
}
if (j==2) {
document.getElementById(“i1″).style.transform=”rotateY(-12deg)”;
document.getElementById(“i2″).style.transform=”rotateY(9deg)”;
document.getElementById(“i4″).style.transform=”rotateY(-12deg)”;
}
if (j==3) {
document.getElementById(“i1″).style.transform=”rotateY(-8deg)”;
document.getElementById(“i2″).style.transform=”rotateY(6deg)”;
document.getElementById(“i4″).style.transform=”rotateY(-8deg)”;
}
if (j==4) {
document.getElementById(“i1″).style.transform=”rotateY(-4deg)”;
document.getElementById(“i2″).style.transform=”rotateY(3deg)”;
document.getElementById(“i4″).style.transform=”rotateY(-4deg)”;
}
if (j==5) {
document.getElementById(“i1″).style.transform=”rotateY(0deg)”;
document.getElementById(“i2″).style.transform=”rotateY(0deg)”;
document.getElementById(“i4″).style.transform=”rotateY(0deg)”;
};
if (j==6) {
document.getElementById(“i1″).style.transform=”rotateY(4deg)”;
document.getElementById(“i2″).style.transform=”rotateY(-3deg)”;
document.getElementById(“i4″).style.transform=”rotateY(4deg)”;
}
if (j==7) {
document.getElementById(“i1″).style.transform=”rotateY(8deg)”;
document.getElementById(“i2″).style.transform=”rotateY(-6deg)”;
document.getElementById(“i4″).style.transform=”rotateY(8deg)”;
}
if (j==8) {
document.getElementById(“i1″).style.transform=”rotateY(12deg)”;
document.getElementById(“i2″).style.transform=”rotateY(-9deg)”;
document.getElementById(“i4″).style.transform=”rotateY(12deg)”;
}
if (j==9) {
document.getElementById(“i1″).style.transform=”rotateY(8deg)”;
document.getElementById(“i2″).style.transform=”rotateY(-6deg)”;
document.getElementById(“i4″).style.transform=”rotateY(8deg)”;
}
if (j==10) {
document.getElementById(“i1″).style.transform=”rotateY(4deg)”;
document.getElementById(“i2″).style.transform=”rotateY(-3deg)”;
document.getElementById(“i4″).style.transform=”rotateY(4deg)”;
j = -2;
}
}

</body></html>

I used two objects and a background image.

The foreground object was given an oscillating Y rotation, while the background was rotated in the opposite direction. The mid figure was not given a rotation.

Also, I made the button a toggle. If it is not rotating, clicking it will start rotation and clicking a image with rotation will stop it

 

Anaglyph Creator Updated

I had previously described a 3d viewer app with thumbnails and an anaglyph viewer app for images. This post combines the two into an anaglyph viewer with thumbnails and also includes viewing videos.

Here is the code:

<!DOCTYPE html PUBLIC ‘-//W3C//DTD XHTML 1.0 Transitional//EN’ ‘http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd’&gt;
<html xmlns=’http://www.w3.org/1999/xhtml’&gt;
<head profile=’http://gmpg.org/xfn/11′&gt;
<title>3D</title>
<style type=’text/css’>body{background: black}
#r1,#h5,#h6,#h7,#h8{position: relative; top: 120px}
#i1{height: 50px}
td{height: 50px; text-align: center; border: 1px solid black; padding: 1px}
#s2{position: absolute; left: 600px; top: 0}
#ta1{position: absolute; left: 1150px; top: 0}
#t1a{position: absolute; left: 150px; top: 200px; }
#control{position: absolute; background: #DDDDDD; height: 200%; width: 100%}
.container{position:absolute; left: 0;  width: 100%; top: 100px;}
#files{position: absolute; left: 10px; top: 3.2%; width: 400px}
#b1{position: absolute; left: 10px; top: 5%; width: 160px}
#b3{position: absolute; left: 215px; top: 5%; width: 160px}
#b2{position: absolute; left: 420px; top: 5%; width: 160px}
#list{position: absolute; left: 420px; top: 2.5%; width: 160px}
#h1{position: absolute; left: 10px; top: 12.5%; background: white; font-size: 15pt }
#t1{position: absolute; left: 10px; top: 15.5%; width: 50px}
#h2{position: absolute; left: 10px; top: 22.5%; background: white; font-size: 15pt }
#t2{position: absolute; left: 10px; top: 25.5%;  width: 50px}
#h3{position: absolute; left: 10px; top: 32.5%; background: white; font-size: 15pt }
#t3{position: absolute; left: 10px; top: 35.5%; width: 50px }
#h4{position: absolute; left: 10px; top: 42.5%; background: white; font-size: 15pt }
#t4{position: absolute; left: 10px; top: 45.5%; width: 50px }
#arrows{position: absolute; width: 200px; height: 50px; left: 50%; top: 850px; margin-left: -100px; text-align: center; visibility: hidden; background: black}
#f1_container {    position: absolute; top: 0;
-webkit-perspective: 1000;
-moz-perspective: 1000px; background: white}
#f2_container {    position: absolute; top: 0;
-webkit-perspective: 1000;
-moz-perspective: 1000px; opacity: 0.5; background: white}

#f1card {width: 100%; height: 100%;
-webkit-transform-style: preserve-3d;
-webkit-transition: all 1.0s linear;
-moz-transform-style: preserve-3d;
-moz-transition: all 1.0s linear;
-o-transform-style: preserve-3d;
-o-transition: all 1.0s linear;
-ms-transform-style: preserve-3d;
-ms-transition: all 1.0s linear;
transform-style: preserve-3d;
transition: all 1.0s linear;
-webkit-transform: rotateY(-6deg);
-moz-transform: rotateY(-6deg);
-o-transform: rotateY(-6deg);
-ms-transform: rotateY(-6deg);
transform: rotateY(-6deg);
}

#f2card {width: 100%; height: 100%;
-webkit-transform-style: preserve-3d;
-webkit-transition: all 1.0s linear;
-moz-transform-style: preserve-3d;
-moz-transition: all 1.0s linear;
-o-transform-style: preserve-3d;
-o-transition: all 1.0s linear;
-ms-transform-style: preserve-3d;
-ms-transition: all 1.0s linear;
transform-style: preserve-3d;
transition: all 1.0s linear;
-webkit-transform: rotateY(6deg);
-moz-transform: rotateY(6deg);
-o-transform: rotateY(6deg);
-ms-transform: rotateY(6deg);
transform: rotateY(6deg);
}

#img1,#img2{ }
#lr{position: absolute; width: 100%; height: 100%;  top: 0; left: 0}
#lc{position: absolute; width: 100%; height: 100%;  top: 0; left: 0}

</style>
</head>
<body>

</div>
</div>

</div>
</div>
</div>

Yellow BlueBlue YellowRed CyanCyan Red
Left Rotation Right Rotation Separation   Slide Interval

Choose Folder
file:///media/removable/TOSHIBA%20EXT/My%20Pictures/
file:///media/removable/TOSHIBA%20EXT/My%20Pictures/Animated GIF/
file:///media/removable/TOSHIBA%20EXT/My%20Pictures/A-E/file:///media/removable/TOSHIBA%20EXT/My%20Pictures/F-J/
file:///media/removable/TOSHIBA%20EXT/My%20Pictures/K-O/
file:///media/removable/TOSHIBA%20EXT/My%20Pictures/P-R/
file:///media/removable/TOSHIBA%20EXT/My%20Pictures/S-T/
file:///media/removable/TOSHIBA%20EXT/My%20Pictures/Nails/
file:///media/removable/TOSHIBA%20EXT/My%20Pictures/threed/
file:///media/removable/TOSHIBA%20EXT/mediaplayer-viral/FLV/
file:///media/removable/TOSHIBA%20EXT/Debut/Wondershare/MP4/
file:///home/chronos/u-1eb10e124afb2b2cad22d7f9b971259b7789c079/Downloads/
file:///home/chronos/u-1eb10e124afb2b2cad22d7f9b971259b7789c079/Downloads/Blog/
file://I:/My Pictures/
file://I:/My Pictures/Animated GIF/
file://I:/My Pictures/A-E/
file://I:/My Pictures/F-J/
file://I:/My Pictures/K-O/
file://I:/My Pictures/P-R/
file://I:/My Pictures/S-T/
file://I:/My Pictures/threed/

<select id=”s2″ onchange=’create();’>
<option>Choose Set</option>
<option>thumb1</option>
</select>
<textarea id=”ta1″ name=”ta1″ rows=”40″ cols=”20″></textarea>
</div>
<table id=”t1a” ></table>

     

http://images2.js

var v1; var v2; var rot; var rot2; var fl; var fl2;  var width; var height; var lt; var rt;  var cnt = 0; var fl1 = “”; var a = 0; var b; var fl3; var sld = false; var fld = “”; var j = 0; var fil = “”;
var content = “”; var files; var inter = “5000”; var clrval = “by”; var fltr = .2;
var table2 = [];

function reset() {
document.getElementById(“f1_container”).innerHTML = “”;
document.getElementById(“f2_container”).innerHTML = “”;
}

function endSlide() {
clearInterval(s);
sld = false;
changeImage(“n”);
}

function showSlides() {
sld = true;
inter = parseInt(document.getElementById(“t4”).value)*1000;
s = setInterval(“changeImage(‘y’)”, inter);
}

function changeImage(val) {
if (sld || val == “n”) {
if (val == “n” && sld) clearInterval(s);
a = document.getElementById(“ta1”).value.indexOf(“display”, a + 1) + 9;
b = document.getElementById(“ta1”).value.indexOf(“‘”, a + 1);
fl = document.getElementById(“ta1″).value.substr(a, b – a);
if (a == 37) fl3 = fl
if (fl == ” id=”) {
fl = fl3;
fl1 = fl;
a = 37;
}
fl1 = fl;
display(fl1);
}
}

function multiFileSelect(evt) {
files = evt.target.files;
fld = document.getElementById(“s1”).value;
for (var i = 0, f; f = files[i]; i++) {
cnt ++;
if (cnt == 1) content = “

“;
if (f.name.indexOf(“jpg”) > -1 || f.name.indexOf(“gif”) > -1 || f.name.indexOf(“png”) > -1 || f.name.indexOf(“webm”) > -1 || f.name.indexOf(“mp4”) > -1)  {
j++;
table2.push(“

” );
if (j % 5 == 0) table2.push(“ “);
fil = fld + f.name;
}
}
}
document.getElementById(‘files’).addEventListener(‘change’, multiFileSelect, false);

function create() {
if (document.getElementById(“s2”).value != “Choose Set”) {
if (document.getElementById(“s2”).value == “thumb1″) content = thumb1;
} else {
content += table2.join(”) + “

“;
}
document.getElementById(“t1a”).innerHTML = content;
content = content.replace(/”/g,’\\”‘);
document.getElementById(“ta1”).value = ‘”‘ + content + ‘”‘;
}

function getFile() {
fl = fil;
fl2 = fl;
fl1 = fl;
fl = “ “;
fl2 = “ “;
if (fl.indexOf(“webm”) > -1 ) {
fl = ”;
fl2 = ”;
}
if (fl.indexOf(“mp4″) > -1 ) {
fl = ”;
fl2 = ”;
}

v1 = document.getElementById(“f1card”);
v2 = document.getElementById(“f2card”);
v1.innerHTML = fl;
v2.innerHTML = fl2;
}

function display(fla) {
document.getElementById(“arrows”).style.visibility=”visible”;
if (fl1 != “”) fla = fl1;
var vid = fla;
fl = “ “;
fl2 = fla;
fl2 = “ “;

if (fla.indexOf(“webm”) > -1 ) {
fl = ”;
fl2 = ”;
}

if (fla.indexOf(“mp4″) > -1 ) {
fl = ”;
fl2 = ”;
}

v1 = document.getElementById(“f1card”);
v2 = document.getElementById(“f2card”);
v1.innerHTML = fl;
v2.innerHTML = fl2;
fl1 = “”;
rot = parseInt(document.getElementById(‘t1’).value);
rot2 = parseInt(document.getElementById(‘t2’).value);
v1.style.WebkitTransform= “rotateY(” + rot + “deg)”;
v1.style.MozTransform= “rotateY(” + rot + “deg)”;
v1.style.msTransform= “rotateY(” + rot + “deg)”;
v1.style.transform= “rotateY(” + rot + “deg)”;
v2.style.WebkitTransform= “rotateY(” + rot2 + “deg)”;
v2.style.MozTransform= “rotateY(” + rot2 + “deg)”;
v2.style.msTransform= “rotateY(” + rot2 + “deg)”;
v2.style.transform= “rotateY(” + rot2 + “deg)”;
document.getElementById(“control”).style.visibility = “hidden”;
document.getElementById(“t1a”).style.visibility = “hidden”;
width = img1.clientWidth;
height = img1.clientHeight;
var width2 = width;

if (width / height > 1.1 ) {
width2 = 500;
document.getElementById(“f1_container”).style.width=”700px”;
document.getElementById(“f2_container”).style.width=”700px”;
document.getElementById(“f1_container”).style.height= 700*height/width + “px”;
document.getElementById(“f2_container”).style.height= 700*height/width + “px”;
} else {
document.getElementById(“f1_container”).style.height=”500px”;
document.getElementById(“f2_container”).style.height=”500px”;
document.getElementById(“f1_container”).style.width= 500*width/height + “px”;
document.getElementById(“f2_container”).style.width= 500*width/height + “px”;
}

if (fl.indexOf(“video”) > -1) {
document.getElementById(“f1_container”).style.width=”800px”;
document.getElementById(“f2_container”).style.width=”800px”;
document.getElementById(“f1_container”).style.height= 800*height/width + “px”;
document.getElementById(“f2_container”).style.height= 800*height/width + “px”;
}

if (width / height > 1.5) {
document.getElementById(“f1_container”).style.width=”1000px”;
document.getElementById(“f2_container”).style.width=”1000px”;
document.getElementById(“f1_container”).style.height= 1000*height/width + “px”;
document.getElementById(“f2_container”).style.height= 1000*height/width + “px”;
}

if (document.getElementById(“t3”).value != “0”) {
lt = screen.width/2 – parseInt(document.getElementById(“f1_container”).style.width)/2 – parseInt(document.getElementById(“t3”).value);
rt = lt + parseInt(document.getElementById(“t3”).value) + “px”;
lt += “px”;
document.getElementById(“f1_container”).style.left = lt;
document.getElementById(“f2_container”).style.left = rt;
document.getElementById(“img1”).style.width = document.getElementById(“f1_container”).style.width;
document.getElementById(“img2”).style.width = document.getElementById(“f2_container”).style.width;
}

var r = document.getElementsByName(“r1”);
for (var i=0; i

</body></html>

The various parts have been described before.

Perspective:
#f1_container {    position: absolute; top: 0;
-webkit-perspective: 1000;
-moz-perspective: 1000px; background: white}
#f2_container {    position: absolute; top: 0;
-webkit-perspective: 1000;
-moz-perspective: 1000px; opacity: 0.5; background: white}

#f1card {width: 100%; height: 100%;
-webkit-transform-style: preserve-3d;
-webkit-transition: all 1.0s linear;
-moz-transform-style: preserve-3d;
-moz-transition: all 1.0s linear;
-o-transform-style: preserve-3d;
-o-transition: all 1.0s linear;
-ms-transform-style: preserve-3d;
-ms-transition: all 1.0s linear;
transform-style: preserve-3d;
transition: all 1.0s linear;
-webkit-transform: rotateY(-6deg);
-moz-transform: rotateY(-6deg);
-o-transform: rotateY(-6deg);
-ms-transform: rotateY(-6deg);
transform: rotateY(-6deg);
}

#f2card {width: 100%; height: 100%;
-webkit-transform-style: preserve-3d;
-webkit-transition: all 1.0s linear;
-moz-transform-style: preserve-3d;
-moz-transition: all 1.0s linear;
-o-transform-style: preserve-3d;
-o-transition: all 1.0s linear;
-ms-transform-style: preserve-3d;
-ms-transition: all 1.0s linear;
transform-style: preserve-3d;
transition: all 1.0s linear;
-webkit-transform: rotateY(6deg);
-moz-transform: rotateY(6deg);
-o-transform: rotateY(6deg);
-ms-transform: rotateY(6deg);
transform: rotateY(6deg);
}

v1 = document.getElementById(“f1card”);
v2 = document.getElementById(“f2card”);
v1.innerHTML = fl;
v2.innerHTML = fl2;
fl1 = “”;
rot = parseInt(document.getElementById(‘t1’).value);
rot2 = parseInt(document.getElementById(‘t2’).value);
v1.style.WebkitTransform= “rotateY(” + rot + “deg)”;
v1.style.MozTransform= “rotateY(” + rot + “deg)”;
v1.style.msTransform= “rotateY(” + rot + “deg)”;
v1.style.transform= “rotateY(” + rot + “deg)”;
v2.style.WebkitTransform= “rotateY(” + rot2 + “deg)”;
v2.style.MozTransform= “rotateY(” + rot2 + “deg)”;
v2.style.msTransform= “rotateY(” + rot2 + “deg)”;
v2.style.transform= “rotateY(” + rot2 + “deg)”;
document.getElementById(“control”).style.visibility = “hidden”;
document.getElementById(“t1a”).style.visibility = “hidden”;
width = img1.clientWidth;
height = img1.clientHeight;

Filters:
var r = document.getElementsByName(“r1”);
for (var i=0; i < r.length ;i++) {
if (r[i].checked){
clrval = r[i].value;
if (clrval == “by”){
document.getElementById(“lr”).style.backgroundColor=”rgba(100,100,255,” + fltr + “)”;
document.getElementById(“lc”).style.backgroundColor=”rgba(255,255,100,” + fltr + “)”;
} else if (clrval == “yb”) {
document.getElementById(“lr”).style.backgroundColor=”rgba(255,255,100,” + fltr + “)”;
document.getElementById(“lc”).style.backgroundColor=”rgba(100,100,255,” + fltr + “)”;
} else if (clrval == “rc”) {
document.getElementById(“lr”).style.backgroundColor=”rgba(255,100,100,” + fltr + “)”;
document.getElementById(“lc”).style.backgroundColor=”rgba(100,255,255,” + fltr + “)”;
alert(document.getElementById(“lr”).style.backgroundColor);
} else if (clrval == “cr”) {
document.getElementById(“lr”).style.backgroundColor=”rgba(100,255,255,” + fltr + “)”;
document.getElementById(“lc”).style.backgroundColor=”rgba(255,100,100,” + fltr + “)”;
}

}
}

Video:
if (fl.indexOf(“webm”) > -1 ) {
fl = ‘<video id=”img1″ autoplay = “true”><source src=”‘ + vid + ‘”></video>’;
fl2 = ‘<video id=”img2″ autoplay = “true”><source src=”‘ + vid + ‘” ></video>’;
}
if (fl.indexOf(“mp4″) > -1 ) {
fl = ‘<video id=”img1” width = “800” autoplay = “true”><source src=”‘ + vid + ‘” type=”video/mp4″></video>’;
fl2 = ‘<video id=”img2″ width = “800”  autoplay = “true”><source src=”‘ + vid + ‘” type=”video/mp4″></video>’;
}

Slides:
function showSlides() {
sld = true;
inter = parseInt(document.getElementById(“t4”).value)*1000;
s = setInterval(“changeImage(‘y’)”, inter);
}

function changeImage(val) {
if (sld || val == “n”) {
if (val == “n” && sld) clearInterval(s);
a = document.getElementById(“ta1”).value.indexOf(“display”, a + 1) + 9;
b = document.getElementById(“ta1”).value.indexOf(“‘”, a + 1);
fl = document.getElementById(“ta1″).value.substr(a, b – a);
if (a == 37) fl3 = fl
if (fl == ” id=”) {
fl = fl3;
fl1 = fl;
a = 37;
}
fl1 = fl;
display(fl1);
}
}

File Selection:
function multiFileSelect(evt) {
files = evt.target.files;
fld = document.getElementById(“s1”).value;
for (var i = 0, f; f = files[i]; i++) {
cnt ++;
if (cnt == 1) content = “<tr>”;
if (f.name.indexOf(“jpg”) > -1 || f.name.indexOf(“gif”) > -1 || f.name.indexOf(“png”) > -1 || f.name.indexOf(“webm”) > -1 || f.name.indexOf(“mp4”) > -1)  {
j++;
table2.push(“<td id=’td” + cnt.toString() + “‘ onclick=\”display(‘” + fld + f.name + “‘);\”><img src='”,fld, f.name, “‘ id=’i1’ /></td>” );
if (j % 5 == 0) table2.push(“</tr><tr>”);
fil = fld + f.name;
}
}
}
document.getElementById(‘files’).addEventListener(‘change’, multiFileSelect, false);

function create() {
if (document.getElementById(“s2”).value != “Choose Set”) {
if (document.getElementById(“s2”).value == “thumb1″) content = thumb1;
} else {
content += table2.join(”) + “</tr>”;
}
document.getElementById(“t1a”).innerHTML = content;
content = content.replace(/”/g,’\\”‘);
document.getElementById(“ta1”).value = ‘”‘ + content + ‘”‘;
}

There are four color combinations; yellow-blue, blue-yellow, red-cyan and cyan-red, chosen by a radio button.

Although all parameters can be varied, I would suggest sticking with the defaults. In particular, use the default color filter, which I think gives the best effect. It means using glasses with blue on the left and yellow on the right.

The text area at the right can be copied and pasted into a js file to make a playlist.

Here is how the interface appears:

Click image for larger view

3d11

Here is how it appears with some thumbnails:

Click image for larger view

3d11-thumbnails