Skip to content

Commit

Permalink
Merge pull request #18 from kalwalt/fixing-nft-w-binaryen
Browse files Browse the repository at this point in the history
Adding NFT examples with WASM and a Worker.
  • Loading branch information
kalwalt authored Jan 5, 2020
2 parents a4d21cd + f36f635 commit f566a50
Show file tree
Hide file tree
Showing 16 changed files with 90,198 additions and 81,837 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ jsartoolkit5 aim is to create a Javascript version of artoolkit5. First, you nee
3. Run `npm install`
4. Run `npm run build-local`

Troubleshootings:
- If you get errors about `BINARYEN_TRAP_MODE`, comment/de-comment following line on `makem.js` file: `FLAGS += ' -s BINARYEN_TRAP_MODE=clamp'`

During development, you can run ```npm run watch```, it will rebuild the library everytime you change ```./js/``` directory.

4. The built ASM.js files are in `/build`. There's a build with debug symbols in `artoolkit.debug.js` and the optimized build with bundled JS API in `artoolkit.min.js`.
Expand Down
171,497 changes: 89,712 additions & 81,785 deletions build/artoolkit.debug.js

Large diffs are not rendered by default.

30 changes: 14 additions & 16 deletions build/artoolkit.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/artoolkit_wasm.js

Large diffs are not rendered by default.

Binary file modified build/artoolkit_wasm.wasm
Binary file not shown.
1 change: 1 addition & 0 deletions examples/nft_improved_worker/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ <h3>jsartoolkit5 demos with ar2Tracking</h3>
<li><a href="main.html">camera input, single-threaded</a></li>
<li><a href="main_worker.html">camera input, worker</a></li>
<li><a href="main_threejs_worker.html">camera input, worker, threejs rendering</a></li>
<li><a href="main_threejs_wasm_worker.html">camera input, worker with wasm, threejs rendering</a></li>
<li><a href="threejs_worker_gltf.html">camera input, worker, threejs rendering and gltf model</a></li>
<li><a href="video.html">video input, single-threaded</a></li>
<li><a href="video_worker.html">video input, worker</a></li>
Expand Down
140 changes: 140 additions & 0 deletions examples/nft_improved_worker/main_threejs_wasm_worker.html
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>
18 changes: 0 additions & 18 deletions examples/nft_improved_worker/nft_armchair_image.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,31 +52,13 @@
<canvas id="canvas"></canvas>
</div>


<!--
==================
VIDEO
==================
-->

<video
loop
autoplay
muted
playsinline
id="arvideo">
<source src="../Data/video.mp4" type="video/mp4">
</video>


<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_worker_armchair_image.js"></script>
Expand Down
Loading

0 comments on commit f566a50

Please sign in to comment.