-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweb_mix_reality.html
90 lines (74 loc) · 2.51 KB
/
web_mix_reality.html
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
86
87
88
89
90
<!DOCTYPE html>
<html lang="en">
<head>
<title>增强现实</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
background-color: #000000;
margin: 0px;
padding: 0px;
overflow: hidden;
}
a {
color: #ffffff;
}
</style>
</head>
<body>
<button id="takePhoto" style="position: absolute;bottom:10px;left: 50%">takePhoto</button>
<div id="container"></div>
<script src="../build/three.js"></script>
<script src="../build/mxreality.js?id=cc"></script>
<script>
window.onload=function () {
init();//初始化
}
function init() {
var scene, renderer;
var container, mesh;
container = document.getElementById( 'container' );
renderer = new THREE.WebGLRenderer();
scene = new THREE.Scene();
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement );
var ar=new AR(scene,renderer,container);
ar.openAudio=false;
ar.cameraIndex=1;
ar.init();//初始化AR
//ar.showVedio();
ar.play();
/*document.getElementById("showpic").addEventListener("click",function () {
alert(ar.video);
ar.video.play();
},false);*/
var envLight=new THREE.AmbientLight(0xffffff,1);
scene.add(envLight);
light = new THREE.DirectionalLight(0xffffff, 1.0, 0);//设置平行光源
light.position.set( 400, 700, 800 );//设置光源向量
scene.add( light );
var geometry = new THREE.SphereGeometry( 50, 60, 40 );
var material = new THREE.MeshLambertMaterial( {
map: new THREE.TextureLoader().load( 'textures/land_ocean_ice_cloud_2048.jpg' ),
depthTest: false
} );
mesh = new THREE.Mesh( geometry, material );
mesh.position.set(0,0,600);
scene.add( mesh );
function animate() {
requestAnimationFrame(animate);
mesh.rotation.y +=0.01;
}
animate();
document.getElementById('takePhoto').addEventListener("click",function () {
var wi = window.open('about:blank', '_blank');
ar.takeScreenShot(function (screenshot) {
wi.location.href=screenshot;
});
},false)
}
</script>
</body>
</html>