webgl_gpgpu_birds.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>three.js webgl - gpgpu - flocking</title>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  7. <style>
  8. body {
  9. background-color: #ffffff;
  10. margin: 0px;
  11. overflow: hidden;
  12. font-family:Monospace;
  13. font-size:13px;
  14. text-align:center;
  15. text-align:center;
  16. cursor: pointer;
  17. }
  18. a {
  19. color:#0078ff;
  20. }
  21. #info {
  22. color: #000;
  23. position: absolute;
  24. top: 10px;
  25. width: 100%;
  26. }
  27. </style>
  28. </head>
  29. <body>
  30. <div id="info">
  31. <a href="http://threejs.org" target="_blank">three.js</a> - <span id="birds"></span> webgl gpgpu birds<br/>
  32. Select <span id="options"></span> birds<br/>
  33. Move mouse to disturb birds.
  34. </div>
  35. <script src="../build/three.min.js"></script>
  36. <script src="js/Detector.js"></script>
  37. <script src="js/libs/stats.min.js"></script>
  38. <script src="js/libs/dat.gui.min.js"></script>
  39. <script src="js/SimulatorRenderer.js"></script>
  40. <!--
  41. TODO: If you're reading this, you may wish to improve this example by
  42. - Replacing the custom BirdGeometry with a BufferGeometry?
  43. - Create a better shading for the birds?
  44. - Refactoring the SimulationRenderer to a more generic TextureRenderer / making the GPGPU workflow easier?
  45. -->
  46. <!-- pass through vertex shader -->
  47. <script id="vertexShader" type="x-shader/x-vertex">
  48. void main() {
  49. gl_Position = vec4( position, 1.0 );
  50. }
  51. </script>
  52. <!-- pass through fragment shader -->
  53. <script id="fragmentShader" type="x-shader/x-fragment">
  54. uniform vec2 resolution;
  55. uniform float time;
  56. uniform sampler2D texture;
  57. void main() {
  58. vec2 uv = gl_FragCoord.xy / resolution.xy;
  59. vec3 color = texture2D( texture, uv ).xyz;
  60. gl_FragColor=vec4(color, 1.0);
  61. }
  62. </script>
  63. <!-- end pass through shaders -->
  64. <!-- shader for bird's position -->
  65. <script id="fragmentShaderPosition" type="x-shader/x-fragment">
  66. uniform vec2 resolution;
  67. uniform float time;
  68. uniform float delta;
  69. uniform sampler2D textureVelocity;
  70. uniform sampler2D texturePosition;
  71. void main() {
  72. vec2 uv = gl_FragCoord.xy / resolution.xy;
  73. vec4 tmpPos = texture2D( texturePosition, uv );
  74. vec3 position = tmpPos.xyz;
  75. vec3 velocity = texture2D( textureVelocity, uv ).xyz;
  76. float phase = tmpPos.w;
  77. phase = mod( ( phase + delta +
  78. length( velocity.xz ) * delta * 3. +
  79. max( velocity.y, 0.0 ) * delta * 6. ), 62.83 );
  80. gl_FragColor = vec4( position + velocity * delta * 15. , phase );
  81. }
  82. </script>
  83. <!-- shader for bird's velocity -->
  84. <script id="fragmentShaderVelocity" type="x-shader/x-fragment">
  85. uniform vec2 resolution;
  86. uniform float time;
  87. uniform float testing;
  88. uniform float delta; // about 0.016
  89. uniform float seperationDistance; // 20
  90. uniform float alignmentDistance; // 40
  91. uniform float cohesionDistance; //
  92. uniform float freedomFactor;
  93. uniform vec3 predator;
  94. uniform sampler2D textureVelocity;
  95. uniform sampler2D texturePosition;
  96. const float width = WIDTH;
  97. const float height = WIDTH;
  98. const float PI = 3.141592653589793;
  99. const float PI_2 = PI * 2.0;
  100. // const float VISION = PI * 0.55;
  101. float zoneRadius = 40.0;
  102. float zoneRadiusSquared = zoneRadius * zoneRadius;
  103. float separationThresh = 0.45;
  104. float alignmentThresh = 0.65;
  105. const float UPPER_BOUNDS = 400.0;
  106. const float LOWER_BOUNDS = -UPPER_BOUNDS;
  107. const float SPEED_LIMIT = 9.0;
  108. float rand(vec2 co){
  109. return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
  110. }
  111. void main() {
  112. zoneRadius = seperationDistance + alignmentDistance + cohesionDistance;
  113. separationThresh = seperationDistance / zoneRadius;
  114. alignmentThresh = ( seperationDistance + alignmentDistance ) / zoneRadius;
  115. zoneRadiusSquared = zoneRadius * zoneRadius;
  116. vec2 uv = gl_FragCoord.xy / resolution.xy;
  117. vec3 birdPosition, birdVelocity;
  118. vec3 selfPosition = texture2D( texturePosition, uv ).xyz;
  119. vec3 selfVelocity = texture2D( textureVelocity, uv ).xyz;
  120. float dist;
  121. vec3 dir; // direction
  122. float distSquared;
  123. float seperationSquared = seperationDistance * seperationDistance;
  124. float cohesionSquared = cohesionDistance * cohesionDistance;
  125. float f;
  126. float percent;
  127. vec3 velocity = selfVelocity;
  128. float limit = SPEED_LIMIT;
  129. dir = predator * UPPER_BOUNDS - selfPosition;
  130. dir.z = 0.;
  131. // dir.z *= 0.6;
  132. dist = length( dir );
  133. distSquared = dist * dist;
  134. float preyRadius = 150.0;
  135. float preyRadiusSq = preyRadius * preyRadius;
  136. // move birds away from predator
  137. if (dist < preyRadius) {
  138. f = ( distSquared / preyRadiusSq - 1.0 ) * delta * 100.;
  139. velocity += normalize( dir ) * f;
  140. limit += 5.0;
  141. }
  142. // if (testing == 0.0) {}
  143. // if ( rand( uv + time ) < freedomFactor ) {}
  144. // Attract flocks to the center
  145. vec3 central = vec3( 0., 0., 0. );
  146. dir = selfPosition - central;
  147. dist = length( dir );
  148. dir.y *= 2.5;
  149. velocity -= normalize( dir ) * delta * 5.;
  150. for (float y=0.0;y<height;y++) {
  151. for (float x=0.0;x<width;x++) {
  152. if (
  153. x == gl_FragCoord.x && y == gl_FragCoord.y) continue;
  154. birdPosition = texture2D( texturePosition,
  155. vec2( x / resolution.x, y / resolution.y ) ).xyz;
  156. dir = birdPosition - selfPosition;
  157. dist = length(dir);
  158. distSquared = dist * dist;
  159. if ( dist > 0.0 && distSquared < zoneRadiusSquared ) {
  160. percent = distSquared / zoneRadiusSquared;
  161. if ( percent < separationThresh ) { // low
  162. // Separation - Move apart for comfort
  163. f = (separationThresh / percent - 1.0) * delta;
  164. velocity -= normalize(dir) * f;
  165. } else if ( percent < alignmentThresh ) { // high
  166. // Alignment - fly the same direction
  167. float threshDelta = alignmentThresh - separationThresh;
  168. float adjustedPercent = ( percent - separationThresh ) / threshDelta;
  169. birdVelocity = texture2D( textureVelocity, vec2(x/resolution.x, y/resolution.y) ).xyz;
  170. f = ( 0.5 - cos( adjustedPercent * PI_2 ) * 0.5 + 0.5 ) * delta;
  171. velocity += normalize(birdVelocity) * f;
  172. } else {
  173. // Attraction / Cohesion - move closer
  174. float threshDelta = 1.0 - alignmentThresh;
  175. float adjustedPercent = ( percent - alignmentThresh ) / threshDelta;
  176. f = ( 0.5 - ( cos( adjustedPercent * PI_2 ) * -0.5 + 0.5 ) ) * delta;
  177. velocity += normalize(dir) * f;
  178. }
  179. }
  180. }
  181. }
  182. // this make tends to fly around than down or up
  183. // if (velocity.y > 0.) velocity.y *= (1. - 0.2 * delta);
  184. // Speed Limits
  185. if ( length( velocity ) > limit ) {
  186. velocity = normalize( velocity ) * limit;
  187. }
  188. gl_FragColor = vec4( velocity, 1.0 );
  189. }
  190. </script>
  191. <script type="x-shader/x-vertex" id="birdVS">
  192. attribute vec2 reference;
  193. attribute float birdVertex;
  194. attribute vec3 birdColor;
  195. uniform sampler2D texturePosition;
  196. uniform sampler2D textureVelocity;
  197. varying vec3 vNormal;
  198. varying vec2 vUv;
  199. varying vec4 vColor;
  200. varying float z;
  201. uniform float time;
  202. void main() {
  203. vNormal = normal;
  204. vec4 tmpPos = texture2D( texturePosition, reference );
  205. vec3 pos = tmpPos.xyz;
  206. vec3 velocity = normalize(texture2D( textureVelocity, reference ).xyz);
  207. vec3 newPosition = position;
  208. if ( birdVertex == 4.0 || birdVertex == 7.0 ) {
  209. // flap wings
  210. newPosition.y = sin( tmpPos.w ) * 5.;
  211. }
  212. newPosition = mat3( modelMatrix ) * newPosition;
  213. velocity.z *= -1.;
  214. float xz = length( velocity.xz );
  215. float xyz = 1.;
  216. float x = sqrt( 1. - velocity.y * velocity.y );
  217. float cosry = velocity.x / xz;
  218. float sinry = velocity.z / xz;
  219. float cosrz = x / xyz;
  220. float sinrz = velocity.y / xyz;
  221. mat3 maty = mat3(
  222. cosry, 0, -sinry,
  223. 0 , 1, 0 ,
  224. sinry, 0, cosry
  225. );
  226. mat3 matz = mat3(
  227. cosrz , sinrz, 0,
  228. -sinrz, cosrz, 0,
  229. 0 , 0 , 1
  230. );
  231. newPosition = maty * matz * newPosition;
  232. newPosition += pos;
  233. z = newPosition.z;
  234. vColor = vec4( birdColor, 1.0 );
  235. gl_Position = projectionMatrix * viewMatrix * vec4( newPosition, 1.0 );
  236. }
  237. </script>
  238. <!-- bird geometry shader -->
  239. <script type="x-shader/x-fragment" id="birdFS">
  240. varying vec3 vNormal;
  241. varying vec2 vUv;
  242. varying vec4 vColor;
  243. varying float z;
  244. uniform vec3 color;
  245. void main() {
  246. // Fake colors for now
  247. float z2 = 0.2 + ( 1000. - z ) / 1000. * vColor.x;
  248. gl_FragColor = vec4( z2, z2, z2, 1. );
  249. // vec3 light = vec3( 0.0, 1.0, 1.0 );
  250. // light = normalize( light );
  251. // float dProd = dot( vNormal, light ) ; //* 0.5 + 0.5;
  252. // vec4 tcolor = vColor;
  253. // vec4 gray = vec4( vec3( tcolor.r * 0.3 + tcolor.g * 0.59 + tcolor.b * 0.11 ), 1.0 );
  254. // gl_FragColor = gray * dProd;
  255. // gl_FragColor = vec4( dProd * tcolor );
  256. }
  257. </script>
  258. <script>
  259. if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
  260. var hash = document.location.hash.substr( 1 );
  261. if (hash) hash = parseInt(hash, 0);
  262. /* TEXTURE WIDTH FOR SIMULATION */
  263. var WIDTH = hash || 32;
  264. var BIRDS = 1024;
  265. // Custom Geometry
  266. THREE.BirdGeometry = function () {
  267. THREE.Geometry.call( this );
  268. BIRDS = WIDTH * WIDTH;
  269. var verts = this.vertices;
  270. var faces = this.faces;
  271. var uvs = this.faceVertexUvs[ 0 ];
  272. var fi = 0;
  273. for (var f = 0; f<BIRDS; f++ ) {
  274. verts.push(
  275. new THREE.Vector3(0, -0, -20),
  276. new THREE.Vector3(0, 4, -20),
  277. new THREE.Vector3(0, 0, 30)
  278. );
  279. faces.push(new THREE.Face3(
  280. fi++,
  281. fi++,
  282. fi++
  283. ));
  284. uvs.push([
  285. new THREE.Vector2(0, 0),
  286. new THREE.Vector2(0, 1),
  287. new THREE.Vector2(1, 1)
  288. ]);
  289. var wingsSpan = 20;
  290. verts.push(
  291. new THREE.Vector3(0, 0, -15),
  292. new THREE.Vector3(-wingsSpan, 0, 0),
  293. new THREE.Vector3(0, 0, 15)
  294. );
  295. verts.push(
  296. new THREE.Vector3(0, 0, 15),
  297. new THREE.Vector3(wingsSpan, 0, 0),
  298. new THREE.Vector3(0, 0, -15)
  299. );
  300. faces.push(new THREE.Face3(
  301. fi++,
  302. fi++,
  303. fi++
  304. ));
  305. faces.push(new THREE.Face3(
  306. fi++,
  307. fi++,
  308. fi++
  309. ));
  310. uvs.push([
  311. new THREE.Vector2(0, 0),
  312. new THREE.Vector2(0, 1),
  313. new THREE.Vector2(1, 1)
  314. ]);
  315. uvs.push([
  316. new THREE.Vector2(0, 0),
  317. new THREE.Vector2(0, 1),
  318. new THREE.Vector2(1, 1)
  319. ]);
  320. }
  321. this.applyMatrix( new THREE.Matrix4().makeScale( 0.2, 0.2, 0.2 ) );
  322. this.computeCentroids();
  323. this.computeFaceNormals();
  324. this.computeVertexNormals();
  325. }
  326. THREE.BirdGeometry.prototype = Object.create( THREE.Geometry.prototype );
  327. var container, stats;
  328. var camera, scene, renderer, geometry, i, h, color;
  329. var mouseX = 0, mouseY = 0;
  330. var windowHalfX = window.innerWidth / 2;
  331. var windowHalfY = window.innerHeight / 2;
  332. var HEIGHT = WIDTH;
  333. var PARTICLES = WIDTH * WIDTH;
  334. var BOUNDS = 800, BOUNDS_HALF = BOUNDS / 2;
  335. document.getElementById('birds').innerText = PARTICLES;
  336. function change(n) {
  337. location.hash = n;
  338. location.reload();
  339. return false;
  340. }
  341. var options = '';
  342. for (i=1; i<7; i++) {
  343. var j = Math.pow(2, i);
  344. options += '<a href="#" onclick="return change(' + j + ')">' + (j * j) + '</a> ';
  345. }
  346. document.getElementById('options').innerHTML = options;
  347. var debug;
  348. var data, texture;
  349. var spline = new THREE.SplineCurve3();
  350. var timer = 0;
  351. var paused = false;
  352. var last = performance.now();
  353. var delta, now, t = 0;
  354. var simulator;
  355. init();
  356. animate();
  357. onMouseDown();
  358. function init() {
  359. container = document.createElement( 'div' );
  360. document.body.appendChild( container );
  361. camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 3000 );
  362. camera.position.z = 350;
  363. scene = new THREE.Scene();
  364. scene.fog = new THREE.Fog( 0xffffff, 100, 1000 );
  365. renderer = new THREE.WebGLRenderer();
  366. renderer.setSize( window.innerWidth, window.innerHeight );
  367. container.appendChild( renderer.domElement );
  368. renderer.setClearColor( scene.fog.color, 1 );
  369. renderer.autoClear = true;
  370. ////////
  371. simulator = new SimulatorRenderer(WIDTH, renderer);
  372. simulator.init();
  373. /////////
  374. plane = new THREE.PlaneGeometry( BOUNDS, BOUNDS, 1, 1 );
  375. // new THREE.BoxGeometry( BOUNDS, BOUNDS, BOUNDS),
  376. cube = new THREE.Mesh(
  377. plane,
  378. new THREE.MeshBasicMaterial( {color: 0xdddddd, wireframe: true, depthWrite: false} )
  379. );
  380. cube.rotation.x = -Math.PI / 2;
  381. cube.position.y = -400;
  382. // scene.add(cube);
  383. stats = new Stats();
  384. stats.domElement.style.position = 'absolute';
  385. stats.domElement.style.top = '0px';
  386. container.appendChild( stats.domElement );
  387. document.addEventListener( 'mousemove', onDocumentMouseMove, false );
  388. // document.addEventListener( 'mousedown', onMouseDown, false );
  389. document.addEventListener( 'mouseup', onMouseUp, false );
  390. document.addEventListener( 'touchstart', onDocumentTouchStart, false );
  391. document.addEventListener( 'touchmove', onDocumentTouchMove, false );
  392. //
  393. window.addEventListener( 'resize', onWindowResize, false );
  394. var gui = new dat.GUI();
  395. var effectController = {
  396. seperation: 20.0,
  397. alignment: 20.0,
  398. cohesion: 20.0,
  399. freedom: 0.75
  400. };
  401. var valuesChanger = function() {
  402. simulator.velocityUniforms.seperationDistance.value = effectController.seperation;
  403. simulator.velocityUniforms.alignmentDistance.value = effectController.alignment;
  404. simulator.velocityUniforms.cohesionDistance.value = effectController.cohesion;
  405. simulator.velocityUniforms.freedomFactor.value = effectController.freedom;
  406. };
  407. valuesChanger();
  408. gui.add( effectController, "seperation", 0.0, 100.0, 1.0 ).onChange( valuesChanger );
  409. gui.add( effectController, "alignment", 0.0, 100, 0.001 ).onChange( valuesChanger );
  410. gui.add( effectController, "cohesion", 0.0, 100, 0.025 ).onChange( valuesChanger );
  411. // gui.add( effectController, "freedom", 0.0, 1.0, 0.025 ).onChange( valuesChanger );
  412. gui.close();
  413. initBirds();
  414. // var ambient = new THREE.AmbientLight( 0x444444 );
  415. // scene.add( ambient );
  416. // light = new THREE.DirectionalLight( 0xffffff );
  417. // light.position.set( 1, 1, 1 );
  418. // scene.add( light );
  419. // light = new THREE.DirectionalLight( 0xffffff );
  420. // light.position.set( -1, -1, -1 );
  421. // scene.add( light );
  422. }
  423. function initBirds() {
  424. var geometry = new THREE.BirdGeometry( );
  425. // For Vertex Shaders
  426. birdAttributes = {
  427. index: { type: 'i', value: [] },
  428. birdColor: { type: 'c', value: [] },
  429. reference: { type: 'v2', value: [] },
  430. birdVertex: { type: 'f', value: [] },
  431. };
  432. // For Vertex and Fragment
  433. birdUniforms = {
  434. color: { type: "c", value: new THREE.Color( 0xff2200 ) },
  435. texturePosition: { type: "t", value: null },
  436. textureVelocity: { type: "t", value: null },
  437. time: { type: "f", value: 1.0 },
  438. delta: { type: "f", value: 0.0 },
  439. };
  440. // ShaderMaterial
  441. var shaderMaterial = new THREE.ShaderMaterial( {
  442. uniforms: birdUniforms,
  443. attributes: birdAttributes,
  444. vertexShader: document.getElementById( 'birdVS' ).textContent,
  445. fragmentShader: document.getElementById( 'birdFS' ).textContent,
  446. side: THREE.DoubleSide,
  447. // wireframe: true
  448. });
  449. // geometry.dynamic = false;
  450. var vertices = geometry.vertices;
  451. var birdColors = birdAttributes.birdColor.value;
  452. var references = birdAttributes.reference.value;
  453. var birdVertex = birdAttributes.birdVertex.value;
  454. for( var v = 0; v < vertices.length; v++ ) {
  455. var i = ~~(v / 3);
  456. var x = (i % WIDTH) / WIDTH;
  457. var y = ~~(i / WIDTH) / WIDTH;
  458. birdColors[ v ] = new THREE.Color(
  459. 0x444444 +
  460. ~~(v / 9) / BIRDS * 0x666666
  461. );
  462. references[ v ] = new THREE.Vector2( x, y );
  463. birdVertex[ v ] = v % 9;
  464. }
  465. // var
  466. birdMesh = new THREE.Mesh( geometry, shaderMaterial );
  467. birdMesh.rotation.y = Math.PI / 2;
  468. birdMesh.sortObjects = false;
  469. birdMesh.matrixAutoUpdate = false;
  470. birdMesh.updateMatrix();
  471. scene.add(birdMesh);
  472. }
  473. function onWindowResize() {
  474. windowHalfX = window.innerWidth / 2;
  475. windowHalfY = window.innerHeight / 2;
  476. camera.aspect = window.innerWidth / window.innerHeight;
  477. camera.updateProjectionMatrix();
  478. renderer.setSize( window.innerWidth, window.innerHeight );
  479. }
  480. function onDocumentMouseMove( event ) {
  481. mouseX = event.clientX - windowHalfX;
  482. mouseY = event.clientY - windowHalfY;
  483. }
  484. function onDocumentTouchStart( event ) {
  485. if ( event.touches.length === 1 ) {
  486. event.preventDefault();
  487. mouseX = event.touches[ 0 ].pageX - windowHalfX;
  488. mouseY = event.touches[ 0 ].pageY - windowHalfY;
  489. }
  490. }
  491. function onDocumentTouchMove( event ) {
  492. if ( event.touches.length === 1 ) {
  493. event.preventDefault();
  494. mouseX = event.touches[ 0 ].pageX - windowHalfX;
  495. mouseY = event.touches[ 0 ].pageY - windowHalfY;
  496. }
  497. }
  498. //
  499. function animate() {
  500. requestAnimationFrame( animate );
  501. render();
  502. stats.update();
  503. }
  504. function render() {
  505. now = performance.now()
  506. delta = (now - last) / 1000;
  507. if (delta > 1) delta = 1; // safety cap on large deltas
  508. last = now;
  509. birdUniforms.time.value = now;
  510. birdUniforms.delta.value = delta;
  511. // if ( paused ) {
  512. // camera.position.x += ( mouseX * 2 - camera.position.x ) * 0.05;
  513. // camera.position.y += ( - mouseY * 2 - camera.position.y ) * 0.05;
  514. // camera.lookAt( scene.position );
  515. // delta = 0.0001;
  516. // }
  517. if (!paused) {
  518. simulator.simulate( delta );
  519. birdUniforms.texturePosition.value = simulator.currentPosition;
  520. birdUniforms.textureVelocity.value = simulator.currentVelocity;
  521. }
  522. simulator.velocityUniforms.predator.value.set( mouseX / windowHalfX, -mouseY / windowHalfY, 0 );
  523. mouseX = 10000;
  524. mouseY = 10000;
  525. renderer.render( scene, camera );
  526. }
  527. function onMouseDown() {
  528. // simulator.velocityUniforms.testing.value = 0;
  529. }
  530. function onMouseUp() {
  531. // simulator.velocityUniforms.testing.value = 1;
  532. }
  533. </script>
  534. </body>
  535. </html>