webgl_marching_cubes.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771
  1. <!DOCTYPE HTML>
  2. <html lang="en">
  3. <head>
  4. <title>three.js webgl - marching cubes</title>
  5. <meta charset="utf-8">
  6. <style>
  7. body {
  8. color: #fff;
  9. font-family: Monospace;
  10. font-size: 13px;
  11. text-align: center;
  12. background-color: #000;
  13. margin: 0px;
  14. overflow: hidden;
  15. }
  16. #info {
  17. color: #ffffff;
  18. position: absolute;
  19. top: 0px;
  20. width: 100%;
  21. padding: 5px;
  22. }
  23. a {
  24. color: gold;
  25. }
  26. #oldie {
  27. font-family: monospace;
  28. font-size: 13px;
  29. text-align: center;
  30. background: rgb(0, 0, 50);
  31. color: #fff;
  32. padding: 1em;
  33. width: 475px;
  34. margin: 5em auto 0;
  35. display: none;
  36. }
  37. </style>
  38. </head>
  39. <body>
  40. <div id="container"></div>
  41. <div id="info">
  42. <a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> -
  43. marching cubes -
  44. [based on greggman's <a href="http://webglsamples.googlecode.com/hg/blob/blob.html">blob</a>, original code by Henrik Rydgård]
  45. </div>
  46. <script src="../build/three.min.js"></script>
  47. <script src="js/MarchingCubes.js"></script>
  48. <script src="js/ShaderExtras.js"></script>
  49. <script src="js/ShaderToon.js"></script>
  50. <script src="js/ShaderExtras.js"></script>
  51. <script src="js/postprocessing/EffectComposer.js"></script>
  52. <script src="js/postprocessing/RenderPass.js"></script>
  53. <script src="js/postprocessing/BloomPass.js"></script>
  54. <script src="js/postprocessing/ShaderPass.js"></script>
  55. <script src="js/postprocessing/MaskPass.js"></script>
  56. <script src="js/postprocessing/SavePass.js"></script>
  57. <script src="js/Detector.js"></script>
  58. <script src="js/Stats.js"></script>
  59. <script src="js/DAT.GUI.min.js"></script>
  60. <script>
  61. if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
  62. var MARGIN = 0;
  63. var SCREEN_WIDTH = window.innerWidth;
  64. var SCREEN_HEIGHT = window.innerHeight - 2 * MARGIN;
  65. var container, stats;
  66. var camera, scene, renderer;
  67. var mesh, texture, geometry, materials, material, current_material;
  68. var light, pointLight, ambientLight;
  69. var effect, resolution, numBlobs;
  70. var composer, effectFXAA, hblur, vblur;
  71. var effectController;
  72. var time = 0;
  73. var clock = new THREE.Clock();
  74. init();
  75. animate();
  76. function init() {
  77. container = document.getElementById( 'container' );
  78. // CAMERA
  79. camera = new THREE.PerspectiveCamera( 45, SCREEN_WIDTH / SCREEN_HEIGHT, 1, 10000 );
  80. camera.position.set( -500, 500, 1500 );
  81. // CONTROLS
  82. controls = new THREE.TrackballControls( camera );
  83. // SCENE
  84. scene = new THREE.Scene();
  85. // LIGHTS
  86. light = new THREE.DirectionalLight( 0xffffff );
  87. light.position.set( 0.5, 0.5, 1 );
  88. scene.add( light );
  89. pointLight = new THREE.PointLight( 0xff3300 );
  90. pointLight.position.set( 0, 0, 100 );
  91. scene.add( pointLight );
  92. ambientLight = new THREE.AmbientLight( 0x080808 );
  93. scene.add( ambientLight );
  94. // MATERIALS
  95. materials = generateMaterials();
  96. current_material = "shiny";
  97. // MARCHING CUBES
  98. resolution = 28;
  99. numBlobs = 10;
  100. effect = new THREE.MarchingCubes( resolution, materials[ current_material ].m, true, true );
  101. effect.position.set( 0, 0, 0 );
  102. effect.scale.set( 700, 700, 700 );
  103. effect.enableUvs = false;
  104. effect.enableColors = false;
  105. scene.add( effect );
  106. // RENDERER
  107. renderer = new THREE.WebGLRenderer( { clearColor: 0x050505, clearAlpha: 1, alpha: false } );
  108. renderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
  109. renderer.domElement.style.position = "absolute";
  110. renderer.domElement.style.top = MARGIN + "px";
  111. renderer.domElement.style.left = "0px";
  112. container.appendChild( renderer.domElement );
  113. //
  114. renderer.gammaInput = true;
  115. renderer.gammaOutput = true;
  116. renderer.physicallyBasedShading = true;
  117. // STATS
  118. stats = new Stats();
  119. stats.domElement.style.position = 'absolute';
  120. stats.domElement.style.top = '0px';
  121. container.appendChild( stats.domElement );
  122. stats.domElement.children[ 0 ].children[ 0 ].style.color = "#888";
  123. stats.domElement.children[ 0 ].style.background = "transparent";
  124. stats.domElement.children[ 0 ].children[ 1 ].style.display = "none";
  125. // COMPOSER
  126. renderer.autoClear = false;
  127. renderTargetParameters = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat, stencilBuffer: false };
  128. renderTarget = new THREE.WebGLRenderTarget( SCREEN_WIDTH, SCREEN_HEIGHT, renderTargetParameters );
  129. effectFXAA = new THREE.ShaderPass( THREE.ShaderExtras[ "fxaa" ] );
  130. hblur = new THREE.ShaderPass( THREE.ShaderExtras[ "horizontalTiltShift" ] );
  131. vblur = new THREE.ShaderPass( THREE.ShaderExtras[ "verticalTiltShift" ] );
  132. var bluriness = 8;
  133. hblur.uniforms[ 'h' ].value = bluriness / SCREEN_WIDTH;
  134. vblur.uniforms[ 'v' ].value = bluriness / SCREEN_HEIGHT;
  135. hblur.uniforms[ 'r' ].value = vblur.uniforms[ 'r' ].value = 0.5;
  136. effectFXAA.uniforms[ 'resolution' ].value.set( 1 / SCREEN_WIDTH, 1 / SCREEN_HEIGHT );
  137. composer = new THREE.EffectComposer( renderer, renderTarget );
  138. var renderModel = new THREE.RenderPass( scene, camera );
  139. vblur.renderToScreen = true;
  140. //effectFXAA.renderToScreen = true;
  141. composer = new THREE.EffectComposer( renderer, renderTarget );
  142. composer.addPass( renderModel );
  143. composer.addPass( effectFXAA );
  144. composer.addPass( hblur );
  145. composer.addPass( vblur );
  146. // GUI
  147. setupGui();
  148. // EVENTS
  149. window.addEventListener( 'resize', onWindowResize, false );
  150. }
  151. //
  152. function onWindowResize( event ) {
  153. SCREEN_WIDTH = window.innerWidth;
  154. SCREEN_HEIGHT = window.innerHeight - 2 * MARGIN;
  155. renderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
  156. camera.aspect = SCREEN_WIDTH / SCREEN_HEIGHT;
  157. camera.updateProjectionMatrix();
  158. renderTarget = new THREE.WebGLRenderTarget( SCREEN_WIDTH, SCREEN_HEIGHT, renderTargetParameters );
  159. composer.reset( renderTarget );
  160. hblur.uniforms[ 'h' ].value = 4 / SCREEN_WIDTH;
  161. vblur.uniforms[ 'v' ].value = 4 / SCREEN_HEIGHT;
  162. effectFXAA.uniforms[ 'resolution' ].value.set( 1 / SCREEN_WIDTH, 1 / SCREEN_HEIGHT );
  163. }
  164. function generateMaterials() {
  165. // environment map
  166. var path = "textures/cube/SwedishRoyalCastle/";
  167. var format = '.jpg';
  168. var urls = [
  169. path + 'px' + format, path + 'nx' + format,
  170. path + 'py' + format, path + 'ny' + format,
  171. path + 'pz' + format, path + 'nz' + format
  172. ];
  173. var reflectionCube = THREE.ImageUtils.loadTextureCube( urls );
  174. reflectionCube.format = THREE.RGBFormat;
  175. var refractionCube = new THREE.Texture( reflectionCube.image, new THREE.CubeRefractionMapping() );
  176. reflectionCube.format = THREE.RGBFormat;
  177. // toons
  178. var toonMaterial1 = createShaderMaterial( "toon1", light, ambientLight ),
  179. toonMaterial2 = createShaderMaterial( "toon2", light, ambientLight ),
  180. hatchingMaterial = createShaderMaterial( "hatching", light, ambientLight ),
  181. hatchingMaterial2 = createShaderMaterial( "hatching", light, ambientLight ),
  182. dottedMaterial = createShaderMaterial( "dotted", light, ambientLight ),
  183. dottedMaterial2 = createShaderMaterial( "dotted", light, ambientLight );
  184. hatchingMaterial2.uniforms.uBaseColor.value.setRGB( 0, 0, 0 );
  185. hatchingMaterial2.uniforms.uLineColor1.value.setHSV( 0, 0.9, 0.9 );
  186. hatchingMaterial2.uniforms.uLineColor2.value.setHSV( 0, 0.9, 0.9 );
  187. hatchingMaterial2.uniforms.uLineColor3.value.setHSV( 0, 0.9, 0.9 );
  188. hatchingMaterial2.uniforms.uLineColor4.value.setHSV( 0.1, 0.9, 0.9 );
  189. dottedMaterial2.uniforms.uBaseColor.value.setRGB( 0, 0, 0 );
  190. dottedMaterial2.uniforms.uLineColor1.value.setHSV( 0.05, 1.0, 1.0 );
  191. var texture = THREE.ImageUtils.loadTexture( "textures/ash_uvgrid01.jpg" );
  192. texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
  193. var materials = {
  194. "chrome" :
  195. {
  196. m: new THREE.MeshLambertMaterial( { color: 0xffffff, envMap: reflectionCube } ),
  197. h: 0, s: 0, v: 1
  198. },
  199. "liquid" :
  200. {
  201. m: new THREE.MeshLambertMaterial( { color: 0xffffff, envMap: refractionCube, refractionRatio: 0.85 } ),
  202. h: 0, s: 0, v: 1
  203. },
  204. "shiny" :
  205. {
  206. m: new THREE.MeshPhongMaterial( { color: 0x550000, specular: 0x440000, envMap: reflectionCube, combine: THREE.MixOperation, reflectivity: 0.3, perPixel: true, metal: true } ),
  207. h: 0, s: 0.9, v: 0.3
  208. },
  209. "matte" :
  210. {
  211. m: new THREE.MeshPhongMaterial( { color: 0x000000, specular: 0x111111, shininess: 1, perPixel: true } ),
  212. h: 0, s: 0, v: 1
  213. },
  214. "flat" :
  215. {
  216. m: new THREE.MeshPhongMaterial( { color: 0x000000, specular: 0x111111, shininess: 1, shading: THREE.FlatShading, perPixel: true } ),
  217. h: 0, s: 0, v: 1
  218. },
  219. "textured" :
  220. {
  221. m: new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0x111111, shininess: 1, map: texture, perPixel: true } ),
  222. h: 0, s: 0, v: 1
  223. },
  224. "colors" :
  225. {
  226. m: new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0xffffff, shininess: 2, vertexColors: THREE.VertexColors, perPixel: true } ),
  227. h: 0, s: 0, v: 1
  228. },
  229. "plastic" :
  230. {
  231. m: new THREE.MeshPhongMaterial( { color: 0x000000, specular: 0x888888, ambient: 0x000000, shininess: 250, perPixel: true } ),
  232. h: 0.6, s: 0.9, v: 0.2
  233. },
  234. "toon1" :
  235. {
  236. m: toonMaterial1,
  237. h: 0.2, s: 0.5, v: 1
  238. },
  239. "toon2" :
  240. {
  241. m: toonMaterial2,
  242. h: 0.4, s: 0.5, v: 1
  243. },
  244. "hatching" :
  245. {
  246. m: hatchingMaterial,
  247. h: 0.2, s: 0.2, v: 1
  248. },
  249. "hatching2" :
  250. {
  251. m: hatchingMaterial2,
  252. h: 0.0, s: 0.9, v: 0.9
  253. },
  254. "dotted" :
  255. {
  256. m: dottedMaterial,
  257. h: 0.2, s: 0.2, v: 1
  258. },
  259. "dotted2" :
  260. {
  261. m: dottedMaterial2,
  262. h: 0.1, s: 1.0, v: 1
  263. }
  264. };
  265. return materials;
  266. }
  267. function createShaderMaterial( id, light, ambientLight ) {
  268. var shader = THREE.ShaderToon[ id ];
  269. var u = THREE.UniformsUtils.clone( shader.uniforms );
  270. var vs = shader.vertexShader;
  271. var fs = shader.fragmentShader;
  272. var material = new THREE.ShaderMaterial( { uniforms: u, vertexShader: vs, fragmentShader: fs } );
  273. material.uniforms.uDirLightPos.value = light.position;
  274. material.uniforms.uDirLightColor.value = light.color;
  275. material.uniforms.uAmbientLightColor.value = ambientLight.color;
  276. return material;
  277. }
  278. //
  279. function setupGui() {
  280. var createHandler = function( id ) {
  281. return function() {
  282. var mat_old = materials[ current_material ];
  283. mat_old.h = m_h.getValue();
  284. mat_old.s = m_s.getValue();
  285. mat_old.v = m_v.getValue();
  286. current_material = id;
  287. var mat = materials[ id ];
  288. effect.material = mat.m;
  289. m_h.setValue( mat.h );
  290. m_s.setValue( mat.s );
  291. m_v.setValue( mat.v );
  292. mm.setValue( current_material );
  293. if ( current_material === "textured" ) {
  294. effect.enableUvs = true;
  295. } else {
  296. effect.enableUvs = false;
  297. }
  298. if ( current_material === "colors" ) {
  299. effect.enableColors = true;
  300. } else {
  301. effect.enableColors = false;
  302. }
  303. };
  304. };
  305. function toggle( e ) {
  306. if ( e.style.display === "block" ) {
  307. e.style.display = "none";
  308. } else {
  309. e.style.display = "block";
  310. }
  311. }
  312. effectController = {
  313. material: "shiny",
  314. speed : 1.0,
  315. numBlobs: 10,
  316. resolution: 28,
  317. isolation: 80,
  318. floor: true,
  319. wallx: false,
  320. wallz: false,
  321. hue: 0.0,
  322. saturation: 0.9,
  323. value: 0.3,
  324. lhue: 0.04,
  325. lsaturation: 1.0,
  326. lvalue: 1.0,
  327. lx: 0.5,
  328. ly: 0.5,
  329. lz: 1.0,
  330. postprocessing: false,
  331. h_m: function() {
  332. for (var i = 0; i < g_m.length; i++) toggle(g_m[ i ].domElement);
  333. },
  334. h_c: function() {
  335. for (var i = 0; i < g_c.length; i++) toggle(g_c[ i ].domElement);
  336. },
  337. h_pc: function() {
  338. for (var i = 0; i < g_pc.length; i++) toggle(g_pc[ i ].domElement);
  339. },
  340. h_do: function() {
  341. for (var i = 0; i < g_do.length; i++) toggle(g_do[ i ].domElement);
  342. },
  343. h_s: function() {
  344. for (var i = 0; i < g_s.length; i++) toggle(g_s[ i ].domElement);
  345. },
  346. h_r: function() {
  347. for (var i = 0; i < g_r.length; i++) toggle(g_r[ i ].domElement);
  348. },
  349. dummy: function() {
  350. }
  351. };
  352. var e1, e2, e3, e4, e5, e6, h, m_h, m_s, m_v,
  353. g_m = [], g_c, g_pc, g_do, g_s, g_r, mm,
  354. gui = new DAT.GUI();
  355. // material (type)
  356. mm = gui.add( effectController, "material" );
  357. mm.domElement.style.display = "none";
  358. h = gui.add( effectController, "h_m" ).name( "Materials" );
  359. setGuiHeaderStyle(h, 0, 65, 50);
  360. for ( var m in materials ) {
  361. effectController[ m ] = createHandler( m );
  362. e1 = gui.add( effectController, m ).name( m );
  363. setGuiElementStyle( [ e1 ], 0, 65, 50, "block" );
  364. g_m.push( e1 );
  365. }
  366. // material (color)
  367. h = gui.add( effectController, "h_c" ).name( "Material color" );
  368. m_h = gui.add( effectController, "hue", 0.0, 1.0, 0.025 );
  369. m_s = gui.add( effectController, "saturation", 0.0, 1.0, 0.025 );
  370. m_v = gui.add( effectController, "value", 0.0, 1.0, 0.025 );
  371. g_c = [ m_h, m_s, m_v ];
  372. setGuiHeaderStyle( h, 20, 65, 50 );
  373. setGuiElementStyle( g_c, 20, 65, 50, "block" );
  374. // light (point)
  375. h = gui.add(effectController, "h_pc").name("Point light color");
  376. e1 = gui.add(effectController, "lhue", 0.0, 1.0, 0.025).name("hue");
  377. e2 = gui.add(effectController, "lsaturation", 0.0, 1.0, 0.025).name("saturation");
  378. e3 = gui.add(effectController, "lvalue", 0.0, 1.0, 0.025).name("value");
  379. g_pc = [ e1, e2, e3 ];
  380. setGuiHeaderStyle(h, 50, 65, 50);
  381. setGuiElementStyle(g_pc, 50, 65, 50);
  382. // light (directional)
  383. h = gui.add(effectController, "h_do").name("Directional light orientation");
  384. e1 = gui.add(effectController, "lx", -1.0, 1.0, 0.025).name("x");
  385. e2 = gui.add(effectController, "ly", -1.0, 1.0, 0.025).name("y");
  386. e3 = gui.add(effectController, "lz", -1.0, 1.0, 0.025).name("z");
  387. g_do = [ e1, e2, e3 ];
  388. setGuiHeaderStyle(h, 80, 65, 50);
  389. setGuiElementStyle(g_do, 80, 65, 50);
  390. // simulation
  391. h = gui.add(effectController, "h_s").name("Simulation");
  392. e1 = gui.add(effectController, "speed", 0.1, 8.0, 0.05);
  393. e2 = gui.add(effectController, "numBlobs", 1, 50, 1);
  394. e3 = gui.add(effectController, "resolution", 14, 40, 1);
  395. e4 = gui.add(effectController, "isolation", 10, 300, 1);
  396. e5 = gui.add(effectController, "floor");
  397. e6 = gui.add(effectController, "wallx");
  398. e7 = gui.add(effectController, "wallz");
  399. e5.updateDisplay();
  400. e6.updateDisplay();
  401. e7.updateDisplay();
  402. g_s = [ e1, e2, e3, e4, e5, e6, e7 ];
  403. setGuiHeaderStyle(h, 200, 65, 50);
  404. setGuiElementStyle(g_s, 200, 65, 50, "block");
  405. // rendering
  406. h = gui.add(effectController, "h_r").name("Rendering");
  407. e1 = gui.add(effectController, "postprocessing");
  408. g_r = [ e1 ];
  409. setGuiHeaderStyle(h, 225, 65, 50);
  410. setGuiElementStyle(g_r, 225, 65, 50, "block");
  411. // save
  412. //e1 = gui.add(GUI, "saveURL").name("Save to URL");
  413. //setGuiHeaderStyle(e1, 250, 65, 50, "block");
  414. gui.domElement.style.backgroundColor = "#222";
  415. // restore material from URL
  416. id = mm.getValue()
  417. current_material = id;
  418. var mat = materials[ id ];
  419. effect.material = mat.m;
  420. }
  421. function setGuiHeaderStyle( g, h, s, v ) {
  422. var color = "hsl(" + h + "," + s + "%, " + v + "%)";
  423. g.domElement.style.borderLeft = "solid 5px " + color;
  424. g.domElement.style.background = color;
  425. g.domElement.style.fontWeight = "bold";
  426. }
  427. function setGuiElementStyle( a, h, s, v, display ) {
  428. var s, color = "hsl(" + h + "," + s + "%, " + v + "%)";
  429. for ( i = 0; i < a.length; i ++ ) {
  430. s = a[ i ].domElement.style;
  431. s.borderLeft = "solid 5px " + color;
  432. s.display = display ? display : "none";
  433. }
  434. }
  435. // this controls content of marching cubes voxel field
  436. function updateCubes( object, time, numblobs, floor, wallx, wallz ) {
  437. object.reset();
  438. // fill the field with some metaballs
  439. var i, ballx, bally, ballz, subtract, strength;
  440. subtract = 12;
  441. strength = 1.2 / ( ( Math.sqrt( numblobs ) - 1 ) / 4 + 1 );
  442. for ( i = 0; i < numblobs; i ++ ) {
  443. ballx = Math.sin( i + 1.26 * time * ( 1.03 + 0.5 * Math.cos( 0.21 * i ) ) ) * 0.27 + 0.5;
  444. bally = Math.abs( Math.cos( i + 1.12 * time * Math.cos( 1.22 + 0.1424 * i ) ) ) * 0.77; // dip into the floor
  445. ballz = Math.cos( i + 1.32 * time * 0.1 * Math.sin( ( 0.92 + 0.53 * i ) ) ) * 0.27 + 0.5;
  446. object.addBall(ballx, bally, ballz, strength, subtract);
  447. }
  448. if ( floor ) object.addPlaneY( 2, 12 );
  449. if ( wallz ) object.addPlaneZ( 2, 12 );
  450. if ( wallx ) object.addPlaneX( 2, 12 );
  451. }
  452. //
  453. function animate() {
  454. requestAnimationFrame( animate );
  455. render();
  456. stats.update();
  457. }
  458. function render() {
  459. var delta = clock.getDelta();
  460. time += delta * effectController.speed * 0.5;
  461. controls.update( delta );
  462. // marching cubes
  463. if ( effectController.resolution !== resolution ) {
  464. resolution = effectController.resolution;
  465. effect.init( resolution );
  466. }
  467. if ( effectController.isolation !== effect.isolation ) {
  468. effect.isolation = effectController.isolation;
  469. }
  470. updateCubes( effect, time, effectController.numBlobs, effectController.floor, effectController.wallx, effectController.wallz );
  471. // materials
  472. if ( effect.material instanceof THREE.ShaderMaterial ) {
  473. if ( current_material === "dotted2" ) {
  474. effect.material.uniforms.uLineColor1.value.setHSV( effectController.hue, effectController.saturation, effectController.value );
  475. } else if ( current_material === "hatching2" ) {
  476. u = effect.material.uniforms;
  477. u.uLineColor1.value.setHSV( effectController.hue, effectController.saturation, effectController.value );
  478. u.uLineColor2.value.setHSV( effectController.hue, effectController.saturation, effectController.value );
  479. u.uLineColor3.value.setHSV( effectController.hue, effectController.saturation, effectController.value );
  480. u.uLineColor4.value.setHSV( ( effectController.hue + 0.2 % 1.0 ), effectController.saturation, effectController.value );
  481. } else {
  482. effect.material.uniforms.uBaseColor.value.setHSV( effectController.hue, effectController.saturation, effectController.value );
  483. }
  484. } else {
  485. effect.material.color.setHSV( effectController.hue, effectController.saturation, effectController.value );
  486. }
  487. // lights
  488. light.position.set( effectController.lx, effectController.ly, effectController.lz );
  489. light.position.normalize();
  490. pointLight.color.setHSV( effectController.lhue, effectController.lsaturation, effectController.lvalue );
  491. // render
  492. if ( effectController.postprocessing ) {
  493. composer.render( delta );
  494. } else {
  495. renderer.clear();
  496. renderer.render( scene, camera );
  497. }
  498. }
  499. </script>
  500. </body>
  501. </html>