Skip to content

Commit 5570161

Browse files
committed
adding car'
1 parent 936ded3 commit 5570161

File tree

2 files changed

+142
-4
lines changed

2 files changed

+142
-4
lines changed

examples/webgl_custom_attributes_particles.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,4 +221,4 @@
221221

222222
</body>
223223

224-
</html>
224+
</html>

examples/webgl_shadowmap.html

Lines changed: 141 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@
3030

3131
<script type="text/javascript" src="js/ShaderExtras.js"></script>
3232

33+
34+
35+
<script type="text/javascript" src="js/postprocessing/EffectComposer.js"></script>
36+
<script type="text/javascript" src="js/postprocessing/MaskPass.js"></script>
37+
<script type="text/javascript" src="js/postprocessing/RenderPass.js"></script>
38+
<script type="text/javascript" src="js/postprocessing/BloomPass.js"></script>
39+
<script type="text/javascript" src="js/postprocessing/ShaderPass.js"></script>
40+
<script type="text/javascript" src="js/postprocessing/FilmPass.js"></script>
41+
42+
43+
3344
<script type="text/javascript" src="js/Detector.js"></script>
3445
<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
3546
<script type="text/javascript" src="js/Stats.js"></script>
@@ -40,6 +51,14 @@
4051

4152
if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
4253

54+
var aloader, bloader;
55+
var parent,
56+
meshes2 = [], clonemeshes = [];
57+
58+
var total = 0, totaln = 0;
59+
60+
var composer, effectFocus;
61+
4362
var SHADOW_MAP_WIDTH = 1024, SHADOW_MAP_HEIGHT = 1024;
4463

4564
var mouse = { x: 0, y: 0 };
@@ -148,8 +167,118 @@
148167
stats.domElement.style.zIndex = 100;
149168
//container.appendChild( stats.domElement );
150169

170+
171+
//post processing
172+
173+
// postprocessing
174+
175+
var renderModel = new THREE.RenderPass( scene, camera );
176+
var effectBloom = new THREE.BloomPass( 0.75 );
177+
var effectFilm = new THREE.FilmPass( 0.5, 0.5, 1448, false );
178+
179+
effectFocus = new THREE.ShaderPass( THREE.ShaderExtras[ "focus" ] );
180+
181+
effectFocus.uniforms[ "screenWidth" ].value = window.innerWidth;
182+
effectFocus.uniforms[ "screenHeight" ].value = window.innerHeight;
183+
184+
effectFocus.renderToScreen = true;
185+
186+
composer = new THREE.EffectComposer( renderer );
187+
188+
composer.addPass( renderModel );
189+
composer.addPass( effectBloom );
190+
composer.addPass( effectFilm );
191+
composer.addPass( effectFocus );
192+
193+
//
194+
195+
196+
}
197+
198+
199+
function createMesh( originalGeometry, scene, scale, x, y, z, color, dynamic ) {
200+
201+
var i, c;
202+
203+
var vertices = originalGeometry.vertices;
204+
var vl = vertices.length;
205+
206+
var geometry = new THREE.Geometry();
207+
var vertices_tmp = [];
208+
209+
for( i = 0; i < vl; i++ ) {
210+
211+
p = vertices[ i ].position;
212+
213+
geometry.vertices[ i ] = new THREE.Vertex( p.clone() );
214+
vertices_tmp[ i ] = [ p.x, p.y, p.z, 0, 0 ];
215+
216+
}
217+
218+
var clones = [
219+
[ 6000, 0, -4000 ],
220+
[ 5000, 0, 0 ],
221+
[ 1000, 0, 5000 ],
222+
[ 1000, 0, -5000 ],
223+
[ 4000, 0, 2000 ],
224+
[ -4000, 0, 1000 ],
225+
[ -5000, 0, -5000 ],
226+
227+
[ 0, 0, 0 ]
228+
229+
];
230+
231+
if ( dynamic ) {
232+
233+
for( i = 0; i < clones.length; i++ ) {
234+
235+
c = ( i < clones.length -1 ) ? 0x252525 : color;
236+
237+
mesh = new THREE.ParticleSystem( geometry, new THREE.ParticleBasicMaterial( { size: 3, color: c } ) );
238+
mesh.scale.x = mesh.scale.y = mesh.scale.z = scale;
239+
240+
mesh.position.x = x + clones[ i ][ 0 ];
241+
mesh.position.y = y + clones[ i ][ 1 ];
242+
mesh.position.z = z + clones[ i ][ 2 ];
243+
244+
parent.addChild( mesh );
245+
246+
clonemeshes.push( { mesh: mesh, speed: 0.5 + Math.random() } );
247+
248+
}
249+
250+
totaln += clones.length;
251+
total += clones.length * vl;
252+
253+
} else {
254+
255+
mesh = new THREE.ParticleSystem( geometry, new THREE.ParticleBasicMaterial( { size: 3, color: color } ) );
256+
mesh.scale.x = mesh.scale.y = mesh.scale.z = scale;
257+
258+
mesh.position.x = x;
259+
mesh.position.y = y;
260+
mesh.position.z = z;
261+
262+
parent.addChild( mesh );
263+
264+
totaln += 1;
265+
total += vl;
266+
267+
}
268+
269+
bloader.statusDomElement.style.display = "none";
270+
271+
meshes2.push( { mesh: mesh, vertices: geometry.vertices, vertices_tmp: vertices_tmp, vl: vl,
272+
down: 0, up: 0, direction: 0, speed: 35, delay: Math.floor( 200 + 200 * Math.random() ),
273+
started: false, start: Math.floor( 100 + 200 * Math.random() ),
274+
dynamic: dynamic,
275+
bb: geometry.boundingBox } );
276+
277+
//console.log( total, totaln );
278+
151279
}
152280

281+
153282
function createHUD() {
154283

155284
cameraOrtho = new THREE.OrthoCamera( SCREEN_WIDTH / - 2, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, SCREEN_HEIGHT / - 2, -10, 1000 );
@@ -229,7 +358,7 @@
229358

230359
// TEXT
231360

232-
var textGeo = new THREE.TextGeometry( "> 3", {
361+
var textGeo = new THREE.TextGeometry( "> 5", {
233362

234363
size: 200,
235364
height: 50,
@@ -281,6 +410,15 @@
281410

282411
scene.addObject( mesh );
283412

413+
// car
414+
parent = new THREE.Object3D();
415+
scene.addObject( parent );
416+
417+
418+
bloader = new THREE.BinaryLoader( true );
419+
bloader.load( { model: "obj/veyron/VeyronNoUv_bin.js", callback: function( geometry ) { createMesh( geometry, scene, 6.8, 2200, -200, -100, 0x0055ff, false ) } } );
420+
421+
284422
// MORPHS
285423

286424
function addMorph( geometry, speed, duration, x, y, z, fudgeColor ) {
@@ -305,7 +443,7 @@
305443

306444
morphs.push( { mesh: meshAnim, lastKeyframe: 0, currentKeyframe: 0,
307445
offset: Math.random() * 6, speed: speed, duration: duration,
308-
oldTime: new Date().getTime(), txt: add_text(Math.floor(Math.random()*11)) } );
446+
oldTime: new Date().getTime(), txt: add_text(Math.floor(Math.random()*10)) } );
309447
}
310448

311449

@@ -404,7 +542,7 @@
404542
//reset
405543
for ( i = 0; i < l; i++ ) {
406544

407-
meshes[ i ].materials[ 0 ].color.setHex( 0x003300 );
545+
meshes[ i ].materials[ 0 ].color.setHex( 0x003300 );
408546

409547
}
410548

0 commit comments

Comments
 (0)