Skip to content

Commit

Permalink
formatting examples and fix for badges
Browse files Browse the repository at this point in the history
  • Loading branch information
kalwalt committed Nov 3, 2024
1 parent 106d2b9 commit 3423661
Show file tree
Hide file tree
Showing 16 changed files with 1,248 additions and 1,258 deletions.
2 changes: 0 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
dist
docs
node_modules
examples
types
*.html
*.json
*.js
*.lock
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
![Dependabot Badge](https://flat.badgen.net/dependabot/thepracticaldev/dev.to?icon=dependabot)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![CI](https://github.com/webarkit/ARnft/actions/workflows/CI.yml/badge.svg)](https://github.com/webarkit/ARnft/actions/workflows/CI.yml)
[![Build ARnft CI](https://github.com/webarkit/ARnft/actions/workflows/main.yml/badge.svg)](https://github.com/webarkit/ARnft/actions/workflows/main.yml)
![twitter](https://flat.badgen.net/twitter/follow/WebarkitO)
[![Build ARnft CI](https://github.com/webarkit/ARnft/actions/workflows/build.yml/badge.svg)](https://github.com/webarkit/ARnft/actions/workflows/main.yml)
![twitter](https://flat.badgen.net/badge/twitter/WebarkitO/follow)

# ARnft - WebAR with NFT

Expand Down
184 changes: 95 additions & 89 deletions examples/arNFT_autoupdate_example.html
Original file line number Diff line number Diff line change
@@ -1,101 +1,107 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>ARnft example showing a simple red cube</title>
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=0.5, maximum-scale=1" />
<link rel="stylesheet" href="css/nft-style.css" />
</head>
<head>
<meta charset="utf-8" />
<title>ARnft example showing a simple red cube</title>
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=0.5, maximum-scale=1" />
<link rel="stylesheet" href="css/nft-style.css" />
</head>

<body>
<a href="https://raw.githubusercontent.com/artoolkitx/artoolkit5/master/doc/Marker%20images/pinball.jpg" class="ui marker" target="_blank">
🖼 Marker Image
</a>
<body>
<a
href="https://raw.githubusercontent.com/artoolkitx/artoolkit5/master/doc/Marker%20images/pinball.jpg"
class="ui marker"
target="_blank"
>
🖼 Marker Image
</a>

<script type="importmap">
{
"imports": {
"three": "./js/third_party/three.js/three.module.min.js",
"arnft-threejs": "./js/ARnftThreejs.module.js",
"arnft": "./../dist/ARnft.module.js"
}
<script type="importmap">
{
"imports": {
"three": "./js/third_party/three.js/three.module.min.js",
"arnft-threejs": "./js/ARnftThreejs.module.js",
"arnft": "./../dist/ARnft.module.js"
}
}
</script>
</script>

<script type="module">
import * as THREE from 'three'
import arnft from 'arnft'
const { ARnft } = arnft
import ARnftThreejs from 'arnft-threejs'
const { SceneRendererTJS, NFTaddTJS } = ARnftThreejs;
<script type="module">
import * as THREE from "three";
import arnft from "arnft";
const { ARnft } = arnft;
import ARnftThreejs from "arnft-threejs";
const { SceneRendererTJS, NFTaddTJS } = ARnftThreejs;

let width = 640;
let width = 640;
let height = 480;
ARnft.initWithConfig({
width: width,
height: height,
markerUrls: [["examples/DataNFT/pinball"]],
names: [["pinball"]],
configUrl: "config.json",
stats: true,
autoUpdate: false,
})
.then((nft) => {
let mat = new THREE.MeshLambertMaterial({
color: 0xff0000,
});
let boxGeom = new THREE.BoxGeometry(1, 1, 1);
let cube = new THREE.Mesh(boxGeom, mat);
cube.position.z = 90;
cube.scale.set(180, 180, 180);
ARnft.initWithConfig({
width: width,
height: height,
markerUrls: [["examples/DataNFT/pinball"]],
names: [["pinball"]],
configUrl: "config.json",
stats: true,
autoUpdate: false,
})
.then((nft) => {
let mat = new THREE.MeshLambertMaterial({
color: 0xff0000,
});
let boxGeom = new THREE.BoxGeometry(1, 1, 1);
let cube = new THREE.Mesh(boxGeom, mat);
cube.position.z = 90;
cube.scale.set(180, 180, 180);

document.addEventListener("containerEvent", function (ev) {
let canvas = document.getElementById("canvas");
let fov = (0.8 * 180) / Math.PI;
let ratio = width / height;
let config = {
renderer: {
alpha: true,
antialias: true,
context: null,
precision: "mediump",
premultipliedAlpha: true,
stencil: true,
depth: true,
logarithmicDepthBuffer: true,
},
camera: {
fov: fov,
ratio: ratio,
near: 0.01,
far: 1000,
},
};
document.addEventListener("containerEvent", function (ev) {
let canvas = document.getElementById("canvas");
let fov = (0.8 * 180) / Math.PI;
let ratio = width / height;
let config = {
renderer: {
alpha: true,
antialias: true,
context: null,
precision: "mediump",
premultipliedAlpha: true,
stencil: true,
depth: true,
logarithmicDepthBuffer: true,
},
camera: {
fov: fov,
ratio: ratio,
near: 0.01,
far: 1000,
},
};

let sceneThreejs = new SceneRendererTJS(config, canvas, nft.uuid, true);
sceneThreejs.initRenderer();
let sceneThreejs = new SceneRendererTJS(config, canvas, nft.uuid, true);
sceneThreejs.initRenderer();

let nftAddTJS = new NFTaddTJS(nft.uuid);
nftAddTJS.add(cube, "pinball", false);
let nftAddTJS = new NFTaddTJS(nft.uuid);
nftAddTJS.add(cube, "pinball", false);

const fpsInterval = 1000 / 30;
let now = Date.now(), elapsed = 0, then = now;
const tick = () => {
now = Date.now();
elapsed = now - then;
sceneThreejs.draw();
if (elapsed > fpsInterval) {
then = now - (elapsed % fpsInterval);
nft.update();
}
window.requestAnimationFrame(tick);
};
tick();
});
})
.catch((error) => {
console.log(error);
});
</script>
</body>
const fpsInterval = 1000 / 30;
let now = Date.now(),
elapsed = 0,
then = now;
const tick = () => {
now = Date.now();
elapsed = now - then;
sceneThreejs.draw();
if (elapsed > fpsInterval) {
then = now - (elapsed % fpsInterval);
nft.update();
}
window.requestAnimationFrame(tick);
};
tick();
});
})
.catch((error) => {
console.log(error);
});
</script>
</body>
</html>
Loading

0 comments on commit 3423661

Please sign in to comment.