-
Notifications
You must be signed in to change notification settings - Fork 1
/
index - vox.html
119 lines (92 loc) · 2.74 KB
/
index - vox.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
<!DOCTYPE html>
<html>
<head>
<title>house orbit control</title>
</head>
<body>
<!--three.js-->
<script src="js/threejs/three.js"></script>
<!--three.js offical library-->
<script src="js/threejs/threejsplugin/Projector.js"></script>
<script src="js/threejs/threejsplugin/CanvasRenderer.js"></script>
<script src="js/threejs/threejsplugin/stats.min.js"></script>
<script src="js/threejs/threejsplugin/OBJLoader.js"></script>
<script src="js/threejs/threejsplugin/MTLLoader.js"></script>
<script src="js/threejs/threejsplugin/OrbitControls.js"></script>
<script src="js/threejs/threejsplugin/dat.gui.min.js"></script>
<script src="js/threejs/threejsplugin/inflate.min.js"></script>
<!--outline-->
<script src="js/threejs/threejsplugin/Detector.js"></script>
<script src="js/threejs/threejsplugin/CopyShader.js"></script>
<script src="js/threejs/threejsplugin/FXAAShader.js"></script>
<script src="js/threejs/threejsplugin/EffectComposer.js"></script>
<script src="js/threejs/threejsplugin/RenderPass.js"></script>
<script src="js/threejs/threejsplugin/ShaderPass.js"></script>
<script src="js/threejs/threejsplugin/OutlinePass.js"></script>
<!--the library we write-->
<script src="js/block42/JimThree.js"></script>
<script src="js/block42/customOutline.js"></script>
<!--vox.js-->
<script src="js/voxjs/vox.min.js"></script>
<script type="text/javascript">
init();
var poslist = [];
var id = 0;
var parser = new vox.Parser();
var bigdata = new vox.VoxelData();
var xSize = 3;
var ySize = 3;
for (var xi = 0; xi < xSize; xi++) {
for (var yi = 0; yi < ySize; yi++) {
var pos = [xi * 126, yi * 126];
poslist.push(pos);
parser.parse("assets/Shibuya.vox")
.then(function(data) {
bigdata.palette = data.palette;
for (var index = 0; index < data.voxels.length; index++) {
data.voxels[index].x += poslist[id][0];
data.voxels[index].y += poslist[id][1];
}
bigdata.voxels = bigdata.voxels.concat(data.voxels);
console.log(data);
//bigdata = data;
console.log(bigdata);
id++;
console.log(id + '% downloaded');
if(id >= xSize * ySize)
{
//id = 0;
buildMesh(bigdata);
}
});
}
}
var myprogress = 0;
function buildMesh(data)
{
bigdata.size = {
x: 6,
y: 6,
z: 6
};
console.log("start loading");
var builder = new vox.MeshBuilder(data, {
voxelSize: 1.0,
vertexColor: false,
optimizeFaces: true,
});
var mesh = builder.createMesh();
scene.add(mesh);
console.log(mesh);
console.log("finished loading");
}
var onProgress = function ( xhr ) {
if ( xhr.lengthComputable ) {
var percentComplete = xhr.loaded / xhr.total * 100;
console.log( Math.round( percentComplete, 2 ) + '% downloaded' );
}
};
var onError = function ( xhr ) { };
</script>
</body>
</html>