This repository has been archived by the owner on May 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jupiter.html
139 lines (109 loc) · 3.58 KB
/
jupiter.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<!DOCTYPE html>
<head>
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<title>Rellusion</title>
<!-- incluindo three.js -->
<script src='js/three.js'></script>
<!-- incluindo jsartookit -->
<script src="jsartoolkit5/artoolkit.min.js"></script>
<script src="jsartoolkit5/artoolkit.api.js"></script>
<!-- incluindo threex.artoolkit -->
<script src="threex/threex-artoolkitsource.js"></script>
<script src="threex/threex-artoolkitcontext.js"></script>
<script src="threex/threex-arbasecontrols.js"></script>
<script src="threex/threex-armarkercontrols.js"></script>
</head>
<body style='margin : 0px; overflow: hidden;'>
<script>
var cena, camera, renderizador, tempo, deltaTime, tempoTotal;
var arToolkitSource, arToolkitContext;
var cenario;
var planeta;
inicializar();
animacao();
function inicializar() {
cena = new THREE.Scene();
let luzAmbiente = new THREE.AmbientLight(0xcccccc, 0.5);
cena.add(luzAmbiente);
camera = new THREE.Camera();
cena.add(camera);
renderizador = new THREE.WebGLRenderer({
antialias: true,
alpha: true
});
renderizador.setClearColor(new THREE.Color('lightgrey'), 0)
renderizador.setSize(640, 480);
renderizador.domElement.style.position = 'absolute'
renderizador.domElement.style.top = '0px'
renderizador.domElement.style.left = '0px'
document.body.appendChild(renderizador.domElement);
//VARIAVEIS DE ANIMAÇÃO
tempo = new THREE.Clock();
deltaTime = 0;
tempoTotal = 0;
//TIPO DE ENTRADA
arToolkitSource = new THREEx.ArToolkitSource({
sourceType: 'webcam',
});
function onResize() {
arToolkitSource.onResize()
arToolkitSource.copySizeTo(renderizador.domElement)
if (arToolkitContext.arController !== null) {
arToolkitSource.copySizeTo(arToolkitContext.arController.canvas)
}
}
arToolkitSource.init(function onReady() {
onResize()
});
//Redefine tamanho
window.addEventListener('resize', function () {
onResize()
});
//CONFIGURANDO ARTOOLKITCONTEXT
//criando atToolkitContext
arToolkitContext = new THREEx.ArToolkitContext({
cameraParametersUrl: 'data/camera_para.dat',
detectionMode: 'mono'
});
// copy projection matrix to camera when initialization complete
arToolkitContext.init(function onCompleted() {
camera.projectionMatrix.copy(arToolkitContext.getProjectionMatrix());
});
cenario = new THREE.Group();
cena.add(cenario);
let marca = new THREEx.ArMarkerControls(arToolkitContext, cenario, {
type: 'pattern', patternUrl: "data/hiro.patt",
})
let geoPlaneta = new THREE.SphereGeometry(1, 32, 32);
let loader = new THREE.TextureLoader();
let texturaDiretorio = loader.load('imagens/jupiter.jpg', render);
let texturaPlaneta = new THREE.MeshLambertMaterial({ map: texturaDiretorio, opacity: 100 });
planeta = new THREE.Mesh(geoPlaneta, texturaPlaneta);
planeta.position.y = 1;
cenario.add(planeta);
//Fobos
let pontoLum = new THREE.PointLight(0xffffff, 1, 100);
pontoLum.position.set(3, 1, 0.5);
cenario.add(pontoLum);
//Deimos
}
function update() {
if (cenario.visible)
planeta.rotation.y += 0.01;
//Atualiza a cada frame e adiciona +1 em rotação
if (arToolkitSource.ready !== false)
arToolkitContext.update(arToolkitSource.domElement);
}
function render() {
renderizador.render(cena, camera);
}
function animacao() {
requestAnimationFrame(animacao);
deltaTime = tempo.getDelta();
tempoTotal += deltaTime;
update();
render();
}
</script>
</body>
</html>