-
Notifications
You must be signed in to change notification settings - Fork 115
/
viewer-00.html
215 lines (169 loc) · 6.37 KB
/
viewer-00.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<!doctype html>
<html lang=en >
<head>
<title>va3c viewer</title>
<meta charset=utf-8 >
<meta name=viewport content=width=device-width,user-scalable=no,minimum-scale=1.0,maximum-scale=1.0 >
</head>
<body>
<script src=https://mrdoob.github.io/three.js/build/three.min.js ></script>
<script src=https://mrdoob.github.io/three.js/examples/js/controls/TrackballControls.js ></script>
<script src=https://mrdoob.github.io/three.js/examples/js/libs/stats.min.js ></script>
<script>
var info, stats, renderer, scene, camera, controls;
var obj;
init();
animate();
function init() {
var geometry, material, mesh;
document.body.style.cssText = 'font: 600 12pt monospace; margin: 0; overflow: hidden' ;
info = document.body.appendChild( document.createElement( 'div' ) );
info.style.cssText = 'left: 20px; position: absolute; top: 0px; width: 100% ';
info.innerHTML = '<h1>' + document.title + '<h1>' +
'<select id=selJS onchange="loadJS( this.value );" ></select>';
'<div id=msg></div>';
var arr = [ ['../json/Wall.rvt.js','../json/test_3dsmax.js','../json/aeron/hey-ron.js','../json/aeron/hey-ron.js'],['../json/noguchi/no-gucci.js','../json/noguchi/no-gucci.js'],['../json/lounge/scrounge.js','../json/lounge/scrounge.js'],['../json/HMI_Stool_One_3ds_3D/tool-won.js','../json/HMI_Stool_One_3ds_3D/tool-won.js'],['../json/lounge/scrounge.js','../json/lounge/scrounge.js'],['./test.js','test.js'] ] ;
for (var i = 0; i < arr.length; i++) {
selJS.appendChild( document.createElement( 'option' ) );
selJS.children[ i ].text = arr[i][0];
selJS.children[ i ].title = arr[i][1];
}
selJS.selectedIndex = 2;
stats = new Stats();
stats.domElement.style.cssText = 'position: absolute; right: 0; top: 0; zIndex: 100; ';
document.body.appendChild( stats.domElement );
renderer = new THREE.WebGLRenderer( { alpha: 1, antialias: true, clearColor: 0xffffff } );
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera( 40, window.innerWidth / window.innerHeight, 1, 1000 );
camera.position.set( 10, 10, 10 );
controls = new THREE.TrackballControls( camera, renderer.domElement );
scene.add(new THREE.AmbientLight(0x444444));
// light
var light = new THREE.PointLight( 0xffffff, 1 );
light.position = camera.position;
scene.add( light );
// axes
function v( x, y, z ){ return new THREE.Vector3( x, y, z ); }
scene.add( new THREE.ArrowHelper( v(1, 0, 0), v(0, 0, 0), 30, 0xcc0000) );
scene.add( new THREE.ArrowHelper( v(0, 1, 0), v(0, 0, 0), 30, 0x00cc00) );
scene.add( new THREE.ArrowHelper( v(0, 0, 1), v(0, 0, 0), 30, 0x0000cc) );
// ground box
geometry = new THREE.BoxGeometry( 200, 1, 100 );
material = new THREE.MeshNormalMaterial();
mesh = new THREE.Mesh( geometry, material );
mesh.position.set( 0, -10, 0 );
scene.add( mesh );
//loadJS( './test.js' );
loadJS( '../json/Wall.rvt.js' );
}
/*
function addCSS() {
var css = document.body.appendChild( document.createElement('style') );
css.innerHTML = 'body { font: 600 12pt monospace; margin: 0; overflow: hidden; }' +
'h1 { margin: 0; }' +
'h1 a {text-decoration: none; }' +
'#closer { position: absolute; right: 5px; top: 5px; }' +
'#movable { left: 20px; overflow: auto; padding: 10px; position: absolute; top: 20px; }' +
'';
}
function addMenu() {
menu = document.body.appendChild( document.createElement( 'div' ) );
menu.id = 'movable';
menu.style.cssText = ' background-color: #ccc; opacity: 0.8; ';
menu.addEventListener( 'mousedown', mouseMove, false );
menu.innerHTML = '<span onclick=movable.style.height=(movable.style.height==="12px")?"":"12px"; >[x]</span>' +
'<h1>' +
'<a href="" >' + title + '</a> ' +
'<a href=# id=infoIcon onclick=info.style.display="block"; >ⓘ</a>' +
'</h1>' +
'<p>' +
'Zoom: <input id=setZoom title="0 to 18: OK" type=number min=0 max=18 step=1 ><br>' +
'Pretty colors: <input id=inpPretty type=checkbox ><br>' +
'Overlay: <select id=selList title="Select the 2D overlay" >select option<select><br>' +
'<input type=button onclick=saveIt(); value="Save as PNG" >' +
'</p>' +
'<hr>' +
'<p>' +
'More...' +
'</p>' +
'<div id=messages></div>' +
'';
*/
var loader;
function loadJS ( fname ) {
if ( obj ) scene.remove( obj );
obj = new THREE.Object3D();
loader = new THREE.ObjectLoader();
loader.load(fname, function(obj){
scene.add(obj);
});
//loader.load( fname, function ( geometry, materials) {
// mesh = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial( materials ) );
// for (var i = 0, len = materials.length; i < len; i++) {
// materials[i].side = 2;
// }
//mesh.position.set( -3, 0, 0 );
// mesh.scale.set( 20, 20, 20 );
// obj.add( mesh );
//} );
scene.add( obj );
}
/*
function loadJS ( fname ) {
var loader = new THREE.ObjectLoader();
loader.load("dragon.json",
function ( obj ) {
scene.add( obj );
}
);
if ( obj ) scene.remove( obj );
obj = new THREE.Object3D();
loader = new THREE.ObjectLoader();
loader.load( fname, function ( result ) {
config = [
[ "Objects", "obj", result.objects ],
[ "Geometries", "geo", result.geometries ],
[ "Materials", "mat", result.materials ],
[ "Textures", "tex", result.textures ],
[ "Lights", "lit", result.lights ],
[ "Cameras", "cam", result.cameras ]
];
mesh = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial( materials ) );
for (var i = 0, len = materials.length; i < len; i++) {
materials[i].side = 2;
}
mesh.position.set( -3, 0, 0 );
mesh.scale.set( 20, 20, 20 );
obj.add( mesh );
} );
scene.add( obj );
})
}
*/
/*
function generateSceneView( result ) {
var config = [
[ "Objects", "obj", result.objects ],
[ "Geometries", "geo", result.geometries ],
[ "Materials", "mat", result.materials ],
[ "Textures", "tex", result.textures ],
[ "Lights", "lit", result.lights ],
[ "Cameras", "cam", result.cameras ]
];
var html = "";
for ( var i = 0; i < config.length; i++ )
html += generateSection( config[i][0], config[i][1], config[i][2] );
return html;
}
*/
function animate() {
requestAnimationFrame( animate );
renderer.render( scene, camera );
controls.update();
stats.update();
}
</script>
</body>
</html>