-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodelMindARonDemand.html
More file actions
executable file
·85 lines (68 loc) · 2.07 KB
/
modelMindARonDemand.html
File metadata and controls
executable file
·85 lines (68 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script async src="https://unpkg.com/es-module-shims@1.7.3/dist/es-module-shims.js"></script>
<script type="importmap">
{
"imports": {
"three": "https://unpkg.com/three@0.153.0/build/three.module.js",
"three/addons/": "https://unpkg.com/three@0.153.0/examples/jsm/",
"mindar-image-three":"https://cdn.jsdelivr.net/npm/mind-ar@1.2.2/dist/mindar-image-three.prod.js"
}
}
</script>
<script type="module">
import * as THREE from 'three';
import { MindARThree } from 'mindar-image-three';
const mindarThree = new MindARThree({
container: document.querySelector("#container"),
imageTargetSrc: "https://cdn.jsdelivr.net/gh/hiukim/mind-ar-js@1.2.2/examples/image-tracking/assets/card-example/card.mind"
});
const { renderer, scene, camera } = mindarThree;
const anchor = mindarThree.addAnchor(0);
const geometry = new THREE.PlaneGeometry(1, 0.55);
const material = new THREE.MeshBasicMaterial({ color: 0x00ffff, transparent: true, opacity: 0.5 });
const plane = new THREE.Mesh(geometry, material);
anchor.group.add(plane);
const start = async () => {
await mindarThree.start();
renderer.setAnimationLoop(() => {
renderer.render(scene, camera);
});
}
const startButton = document.querySelector("#startButton");
startButton.addEventListener("click", () => {
start();
});
stopButton.addEventListener("click", () => {
mindarThree.stop();
mindarThree.renderer.setAnimationLoop(null);
});
</script>
<style>
body {
margin: 0;
}
#container {
width: 100vw;
height: 100vh;
position: relative;
overflow: hidden;
}
#control {
position: fixed;
top: 0;
left: 0;
z-index: 2;
}
</style>
</head>
<body>
<div id="control">
<button id="startButton">Start</button>
<button id="stopButton">Stop</button>
</div>
<div id="container">
</div>
</body>
</html>