forked from mikocml/jsartoolkit5
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from kalwalt/fixing-nft-w-binaryen
Adding NFT examples with WASM and a Worker.
- Loading branch information
Showing
16 changed files
with
90,198 additions
and
81,837 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
140 changes: 140 additions & 0 deletions
140
examples/nft_improved_worker/main_threejs_wasm_worker.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>NFT marker example with Three.js</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=0.5, maximum-scale=1"> | ||
<link rel="stylesheet" href="../css/video-style.css"> | ||
</head> | ||
<body class="loading"> | ||
<div id="loading" > | ||
<img src="../Data/logo.gif"/> | ||
<span class="loading-text">Loading, please wait</span> | ||
</div> | ||
<!-- | ||
================== | ||
STATS | ||
================== | ||
--> | ||
|
||
<div id="stats" class="ui stats"> | ||
|
||
<div id="stats1" class="stats-item"> | ||
<p class="stats-item-title"> | ||
Main | ||
</p> | ||
</div> | ||
|
||
<div id="stats2" class="stats-item"> | ||
<p class="stats-item-title"> | ||
Worker | ||
</p> | ||
</div> | ||
|
||
</div> | ||
|
||
<!-- | ||
================== | ||
CAMERA VIDEO & CANVAS | ||
================== | ||
--> | ||
|
||
<div id="app"> | ||
<video | ||
loop | ||
autoplay | ||
muted | ||
playsinline | ||
id="video"> | ||
</video> | ||
|
||
<canvas id="canvas"></canvas> | ||
</div> | ||
|
||
<a | ||
href="https://raw.githubusercontent.com/artoolkit/artoolkit5/master/doc/Marker%20images/pinball.jpg" | ||
class="ui marker" | ||
target="_blank"> | ||
🖼 Marker Image | ||
</a> | ||
|
||
<script src="../js/third_party/three.js/stats.min.js"></script> | ||
<script src="../js/third_party/three.js/three.min.js"></script> | ||
<script src="threejs_wasm_worker.js"></script> | ||
|
||
<script> | ||
|
||
/** | ||
* STATS | ||
*/ | ||
let statsMain = new Stats(); | ||
statsMain.showPanel( 0 ); // 0: fps, 1: ms, 2: mb, 3+: custom | ||
document.getElementById( 'stats1' ).appendChild( statsMain.dom ); | ||
|
||
let statsWorker = new Stats(); | ||
statsWorker.showPanel( 0 ); // 0: fps, 1: ms, 2: mb, 3+: custom | ||
document.getElementById( 'stats2' ).appendChild( statsWorker.dom ); | ||
|
||
/** | ||
* APP / ELEMENTS | ||
*/ | ||
let container = document.getElementById( 'app' ); | ||
let video = document.getElementById( 'video' ); | ||
let canvas = document.getElementById( 'canvas' ); | ||
|
||
/** | ||
* APP / VIDEO STREAM | ||
*/ | ||
|
||
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) { | ||
let hint = { | ||
audio: false, | ||
video: true | ||
}; | ||
if( window.innerWidth < 800 ) { | ||
let width = ( window.innerWidth < window.innerHeight ) ? 240 : 360; | ||
let height = ( window.innerWidth < window.innerHeight ) ? 360 : 240; | ||
|
||
let aspectRatio = window.innerWidth / window.innerHeight; | ||
|
||
console.log( width, height ); | ||
|
||
hint = { | ||
audio: false, | ||
video: { | ||
facingMode: 'environment', | ||
width: { min: width, max: width } | ||
}, | ||
}; | ||
|
||
console.log( hint ); | ||
} | ||
|
||
navigator.mediaDevices.getUserMedia( hint ).then( function( stream ) { | ||
video.srcObject = stream; | ||
video.addEventListener( 'loadedmetadata', () => { | ||
video.play(); | ||
|
||
console.log( 'video', video, video.videoWidth, video.videoHeight ); | ||
|
||
start( | ||
container, | ||
markers['pinball'], | ||
video, | ||
video.videoWidth, | ||
video.videoHeight, | ||
canvas, | ||
function() { | ||
statsMain.update() | ||
}, | ||
function() { | ||
statsWorker.update(); | ||
}, | ||
null | ||
); | ||
} ); | ||
} ); | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.