geometry-browser.html 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Three.js Geometry Browser</title>
  6. <link rel="shortcut icon" href="../../files/favicon.ico" />
  7. <link rel="stylesheet" type="text/css" href="../../files/main.css">
  8. <style>
  9. canvas {
  10. display: block;
  11. width: 100%;
  12. height: 100%;
  13. }
  14. #newWindow {
  15. display: block;
  16. position: absolute;
  17. bottom: 0.3em;
  18. left: 0.5em;
  19. color: #fff;
  20. }
  21. </style>
  22. </head>
  23. <body>
  24. <a id='newWindow' href='./geometry-browser.html' target='_blank'>Open in New Window</a>
  25. <script type="module">
  26. import {
  27. BoxGeometry, BoxBufferGeometry,
  28. BufferGeometry,
  29. CircleGeometry, CircleBufferGeometry,
  30. Color,
  31. ConeGeometry, ConeBufferGeometry,
  32. Curve,
  33. CylinderGeometry, CylinderBufferGeometry,
  34. DodecahedronGeometry, DodecahedronBufferGeometry,
  35. DoubleSide,
  36. ExtrudeGeometry, ExtrudeBufferGeometry,
  37. Float32BufferAttribute,
  38. FontLoader,
  39. Group,
  40. IcosahedronGeometry, IcosahedronBufferGeometry,
  41. LatheGeometry, LatheBufferGeometry,
  42. LineSegments,
  43. LineBasicMaterial,
  44. Mesh,
  45. MeshPhongMaterial,
  46. OctahedronGeometry, OctahedronBufferGeometry,
  47. ParametricGeometry, ParametricBufferGeometry,
  48. PerspectiveCamera,
  49. PlaneGeometry, PlaneBufferGeometry,
  50. PointLight,
  51. RingGeometry, RingBufferGeometry,
  52. Scene,
  53. Shape,
  54. ShapeGeometry, ShapeBufferGeometry,
  55. SphereGeometry, SphereBufferGeometry,
  56. TetrahedronGeometry, TetrahedronBufferGeometry,
  57. TextGeometry, TextBufferGeometry,
  58. TorusGeometry, TorusBufferGeometry,
  59. TorusKnotGeometry, TorusKnotBufferGeometry,
  60. TubeGeometry, TubeBufferGeometry,
  61. Vector2,
  62. Vector3,
  63. WireframeGeometry,
  64. WebGLRenderer
  65. } from "../../build/three.module.js";
  66. import { GUI } from '../../examples/jsm/libs/dat.gui.module.js';
  67. import { OrbitControls } from '../../examples/jsm/controls/OrbitControls.js';
  68. import { ParametricGeometries } from '../../examples/jsm/geometries/ParametricGeometries.js';
  69. /**
  70. * @author TatumCreative (Greg Tatum) / http://gregtatum.com/
  71. */
  72. var twoPi = Math.PI * 2;
  73. function updateGroupGeometry( mesh, geometry ) {
  74. if ( geometry.isGeometry ) {
  75. geometry = new BufferGeometry().fromGeometry( geometry );
  76. console.warn( 'THREE.GeometryBrowser: Converted Geometry to BufferGeometry.' );
  77. }
  78. mesh.children[ 0 ].geometry.dispose();
  79. mesh.children[ 1 ].geometry.dispose();
  80. mesh.children[ 0 ].geometry = new WireframeGeometry( geometry );
  81. mesh.children[ 1 ].geometry = geometry;
  82. // these do not update nicely together if shared
  83. }
  84. function CustomSinCurve( scale ) {
  85. Curve.call( this );
  86. this.scale = ( scale === undefined ) ? 1 : scale;
  87. }
  88. CustomSinCurve.prototype = Object.create( Curve.prototype );
  89. CustomSinCurve.prototype.constructor = CustomSinCurve;
  90. CustomSinCurve.prototype.getPoint = function ( t ) {
  91. var tx = t * 3 - 1.5;
  92. var ty = Math.sin( 2 * Math.PI * t );
  93. var tz = 0;
  94. return new Vector3( tx, ty, tz ).multiplyScalar( this.scale );
  95. };
  96. // heart shape
  97. var x = 0, y = 0;
  98. var heartShape = new Shape();
  99. heartShape.moveTo( x + 5, y + 5 );
  100. heartShape.bezierCurveTo( x + 5, y + 5, x + 4, y, x, y );
  101. heartShape.bezierCurveTo( x - 6, y, x - 6, y + 7, x - 6, y + 7 );
  102. heartShape.bezierCurveTo( x - 6, y + 11, x - 3, y + 15.4, x + 5, y + 19 );
  103. heartShape.bezierCurveTo( x + 12, y + 15.4, x + 16, y + 11, x + 16, y + 7 );
  104. heartShape.bezierCurveTo( x + 16, y + 7, x + 16, y, x + 10, y );
  105. heartShape.bezierCurveTo( x + 7, y, x + 5, y + 5, x + 5, y + 5 );
  106. var guis = {
  107. BoxBufferGeometry: function ( mesh ) {
  108. var data = {
  109. width: 15,
  110. height: 15,
  111. depth: 15,
  112. widthSegments: 1,
  113. heightSegments: 1,
  114. depthSegments: 1
  115. };
  116. function generateGeometry() {
  117. updateGroupGeometry( mesh,
  118. new BoxBufferGeometry(
  119. data.width, data.height, data.depth, data.widthSegments, data.heightSegments, data.depthSegments
  120. )
  121. );
  122. }
  123. var folder = gui.addFolder( 'THREE.BoxBufferGeometry' );
  124. folder.add( data, 'width', 1, 30 ).onChange( generateGeometry );
  125. folder.add( data, 'height', 1, 30 ).onChange( generateGeometry );
  126. folder.add( data, 'depth', 1, 30 ).onChange( generateGeometry );
  127. folder.add( data, 'widthSegments', 1, 10 ).step( 1 ).onChange( generateGeometry );
  128. folder.add( data, 'heightSegments', 1, 10 ).step( 1 ).onChange( generateGeometry );
  129. folder.add( data, 'depthSegments', 1, 10 ).step( 1 ).onChange( generateGeometry );
  130. generateGeometry();
  131. },
  132. BoxGeometry: function ( mesh ) {
  133. var data = {
  134. width: 15,
  135. height: 15,
  136. depth: 15,
  137. widthSegments: 1,
  138. heightSegments: 1,
  139. depthSegments: 1
  140. };
  141. function generateGeometry() {
  142. updateGroupGeometry( mesh,
  143. new BoxGeometry(
  144. data.width, data.height, data.depth, data.widthSegments, data.heightSegments, data.depthSegments
  145. )
  146. );
  147. }
  148. var folder = gui.addFolder( 'THREE.BoxGeometry' );
  149. folder.add( data, 'width', 1, 30 ).onChange( generateGeometry );
  150. folder.add( data, 'height', 1, 30 ).onChange( generateGeometry );
  151. folder.add( data, 'depth', 1, 30 ).onChange( generateGeometry );
  152. folder.add( data, 'widthSegments', 1, 10 ).step( 1 ).onChange( generateGeometry );
  153. folder.add( data, 'heightSegments', 1, 10 ).step( 1 ).onChange( generateGeometry );
  154. folder.add( data, 'depthSegments', 1, 10 ).step( 1 ).onChange( generateGeometry );
  155. generateGeometry();
  156. },
  157. CylinderBufferGeometry: function ( mesh ) {
  158. var data = {
  159. radiusTop: 5,
  160. radiusBottom: 5,
  161. height: 10,
  162. radialSegments: 8,
  163. heightSegments: 1,
  164. openEnded: false,
  165. thetaStart: 0,
  166. thetaLength: twoPi
  167. };
  168. function generateGeometry() {
  169. updateGroupGeometry( mesh,
  170. new CylinderBufferGeometry(
  171. data.radiusTop,
  172. data.radiusBottom,
  173. data.height,
  174. data.radialSegments,
  175. data.heightSegments,
  176. data.openEnded,
  177. data.thetaStart,
  178. data.thetaLength
  179. )
  180. );
  181. }
  182. var folder = gui.addFolder( 'THREE.CylinderBufferGeometry' );
  183. folder.add( data, 'radiusTop', 0, 30 ).onChange( generateGeometry );
  184. folder.add( data, 'radiusBottom', 0, 30 ).onChange( generateGeometry );
  185. folder.add( data, 'height', 1, 50 ).onChange( generateGeometry );
  186. folder.add( data, 'radialSegments', 3, 64 ).step( 1 ).onChange( generateGeometry );
  187. folder.add( data, 'heightSegments', 1, 64 ).step( 1 ).onChange( generateGeometry );
  188. folder.add( data, 'openEnded' ).onChange( generateGeometry );
  189. folder.add( data, 'thetaStart', 0, twoPi ).onChange( generateGeometry );
  190. folder.add( data, 'thetaLength', 0, twoPi ).onChange( generateGeometry );
  191. generateGeometry();
  192. },
  193. CylinderGeometry: function ( mesh ) {
  194. var data = {
  195. radiusTop: 5,
  196. radiusBottom: 5,
  197. height: 10,
  198. radialSegments: 8,
  199. heightSegments: 1,
  200. openEnded: false,
  201. thetaStart: 0,
  202. thetaLength: twoPi
  203. };
  204. function generateGeometry() {
  205. updateGroupGeometry( mesh,
  206. new CylinderGeometry(
  207. data.radiusTop,
  208. data.radiusBottom,
  209. data.height,
  210. data.radialSegments,
  211. data.heightSegments,
  212. data.openEnded,
  213. data.thetaStart,
  214. data.thetaLength
  215. )
  216. );
  217. }
  218. var folder = gui.addFolder( 'THREE.CylinderGeometry' );
  219. folder.add( data, 'radiusTop', 1, 30 ).onChange( generateGeometry );
  220. folder.add( data, 'radiusBottom', 1, 30 ).onChange( generateGeometry );
  221. folder.add( data, 'height', 1, 50 ).onChange( generateGeometry );
  222. folder.add( data, 'radialSegments', 3, 64 ).step( 1 ).onChange( generateGeometry );
  223. folder.add( data, 'heightSegments', 1, 64 ).step( 1 ).onChange( generateGeometry );
  224. folder.add( data, 'openEnded' ).onChange( generateGeometry );
  225. folder.add( data, 'thetaStart', 0, twoPi ).onChange( generateGeometry );
  226. folder.add( data, 'thetaLength', 0, twoPi ).onChange( generateGeometry );
  227. generateGeometry();
  228. },
  229. ConeBufferGeometry: function ( mesh ) {
  230. var data = {
  231. radius: 5,
  232. height: 10,
  233. radialSegments: 8,
  234. heightSegments: 1,
  235. openEnded: false,
  236. thetaStart: 0,
  237. thetaLength: twoPi
  238. };
  239. function generateGeometry() {
  240. updateGroupGeometry( mesh,
  241. new ConeBufferGeometry(
  242. data.radius,
  243. data.height,
  244. data.radialSegments,
  245. data.heightSegments,
  246. data.openEnded,
  247. data.thetaStart,
  248. data.thetaLength
  249. )
  250. );
  251. }
  252. var folder = gui.addFolder( 'THREE.ConeBufferGeometry' );
  253. folder.add( data, 'radius', 0, 30 ).onChange( generateGeometry );
  254. folder.add( data, 'height', 1, 50 ).onChange( generateGeometry );
  255. folder.add( data, 'radialSegments', 3, 64 ).step( 1 ).onChange( generateGeometry );
  256. folder.add( data, 'heightSegments', 1, 64 ).step( 1 ).onChange( generateGeometry );
  257. folder.add( data, 'openEnded' ).onChange( generateGeometry );
  258. folder.add( data, 'thetaStart', 0, twoPi ).onChange( generateGeometry );
  259. folder.add( data, 'thetaLength', 0, twoPi ).onChange( generateGeometry );
  260. generateGeometry();
  261. },
  262. ConeGeometry: function ( mesh ) {
  263. var data = {
  264. radius: 5,
  265. height: 10,
  266. radialSegments: 8,
  267. heightSegments: 1,
  268. openEnded: false,
  269. thetaStart: 0,
  270. thetaLength: twoPi
  271. };
  272. function generateGeometry() {
  273. updateGroupGeometry( mesh,
  274. new ConeGeometry(
  275. data.radius,
  276. data.height,
  277. data.radialSegments,
  278. data.heightSegments,
  279. data.openEnded,
  280. data.thetaStart,
  281. data.thetaLength
  282. )
  283. );
  284. }
  285. var folder = gui.addFolder( 'THREE.ConeGeometry' );
  286. folder.add( data, 'radius', 0, 30 ).onChange( generateGeometry );
  287. folder.add( data, 'height', 1, 50 ).onChange( generateGeometry );
  288. folder.add( data, 'radialSegments', 3, 64 ).step( 1 ).onChange( generateGeometry );
  289. folder.add( data, 'heightSegments', 1, 64 ).step( 1 ).onChange( generateGeometry );
  290. folder.add( data, 'openEnded' ).onChange( generateGeometry );
  291. folder.add( data, 'thetaStart', 0, twoPi ).onChange( generateGeometry );
  292. folder.add( data, 'thetaLength', 0, twoPi ).onChange( generateGeometry );
  293. generateGeometry();
  294. },
  295. CircleBufferGeometry: function ( mesh ) {
  296. var data = {
  297. radius: 10,
  298. segments: 32,
  299. thetaStart: 0,
  300. thetaLength: twoPi
  301. };
  302. function generateGeometry() {
  303. updateGroupGeometry( mesh,
  304. new CircleBufferGeometry(
  305. data.radius, data.segments, data.thetaStart, data.thetaLength
  306. )
  307. );
  308. }
  309. var folder = gui.addFolder( 'THREE.CircleBufferGeometry' );
  310. folder.add( data, 'radius', 1, 20 ).onChange( generateGeometry );
  311. folder.add( data, 'segments', 0, 128 ).step( 1 ).onChange( generateGeometry );
  312. folder.add( data, 'thetaStart', 0, twoPi ).onChange( generateGeometry );
  313. folder.add( data, 'thetaLength', 0, twoPi ).onChange( generateGeometry );
  314. generateGeometry();
  315. },
  316. CircleGeometry: function ( mesh ) {
  317. var data = {
  318. radius: 10,
  319. segments: 32,
  320. thetaStart: 0,
  321. thetaLength: twoPi
  322. };
  323. function generateGeometry() {
  324. updateGroupGeometry( mesh,
  325. new CircleGeometry(
  326. data.radius, data.segments, data.thetaStart, data.thetaLength
  327. )
  328. );
  329. }
  330. var folder = gui.addFolder( 'THREE.CircleGeometry' );
  331. folder.add( data, 'radius', 1, 20 ).onChange( generateGeometry );
  332. folder.add( data, 'segments', 0, 128 ).step( 1 ).onChange( generateGeometry );
  333. folder.add( data, 'thetaStart', 0, twoPi ).onChange( generateGeometry );
  334. folder.add( data, 'thetaLength', 0, twoPi ).onChange( generateGeometry );
  335. generateGeometry();
  336. },
  337. DodecahedronGeometry: function ( mesh ) {
  338. var data = {
  339. radius: 10,
  340. detail: 0
  341. };
  342. function generateGeometry() {
  343. updateGroupGeometry( mesh,
  344. new DodecahedronGeometry(
  345. data.radius, data.detail
  346. )
  347. );
  348. }
  349. var folder = gui.addFolder( 'THREE.DodecahedronGeometry' );
  350. folder.add( data, 'radius', 1, 20 ).onChange( generateGeometry );
  351. folder.add( data, 'detail', 0, 5 ).step( 1 ).onChange( generateGeometry );
  352. generateGeometry();
  353. },
  354. DodecahedronBufferGeometry: function ( mesh ) {
  355. var data = {
  356. radius: 10,
  357. detail: 0
  358. };
  359. function generateGeometry() {
  360. updateGroupGeometry( mesh,
  361. new DodecahedronBufferGeometry(
  362. data.radius, data.detail
  363. )
  364. );
  365. }
  366. var folder = gui.addFolder( 'THREE.DodecahedronBufferGeometry' );
  367. folder.add( data, 'radius', 1, 20 ).onChange( generateGeometry );
  368. folder.add( data, 'detail', 0, 5 ).step( 1 ).onChange( generateGeometry );
  369. generateGeometry();
  370. },
  371. IcosahedronGeometry: function ( mesh ) {
  372. var data = {
  373. radius: 10,
  374. detail: 0
  375. };
  376. function generateGeometry() {
  377. updateGroupGeometry( mesh,
  378. new IcosahedronGeometry(
  379. data.radius, data.detail
  380. )
  381. );
  382. }
  383. var folder = gui.addFolder( 'THREE.IcosahedronGeometry' );
  384. folder.add( data, 'radius', 1, 20 ).onChange( generateGeometry );
  385. folder.add( data, 'detail', 0, 5 ).step( 1 ).onChange( generateGeometry );
  386. generateGeometry();
  387. },
  388. IcosahedronBufferGeometry: function ( mesh ) {
  389. var data = {
  390. radius: 10,
  391. detail: 0
  392. };
  393. function generateGeometry() {
  394. updateGroupGeometry( mesh,
  395. new IcosahedronBufferGeometry(
  396. data.radius, data.detail
  397. )
  398. );
  399. }
  400. var folder = gui.addFolder( 'THREE.IcosahedronBufferGeometry' );
  401. folder.add( data, 'radius', 1, 20 ).onChange( generateGeometry );
  402. folder.add( data, 'detail', 0, 5 ).step( 1 ).onChange( generateGeometry );
  403. generateGeometry();
  404. },
  405. LatheBufferGeometry: function ( mesh ) {
  406. var points = [];
  407. for ( var i = 0; i < 10; i ++ ) {
  408. points.push( new Vector2( Math.sin( i * 0.2 ) * 10 + 5, ( i - 5 ) * 2 ) );
  409. }
  410. var data = {
  411. segments: 12,
  412. phiStart: 0,
  413. phiLength: twoPi
  414. };
  415. function generateGeometry() {
  416. var geometry = new LatheBufferGeometry(
  417. points, data.segments, data.phiStart, data.phiLength
  418. );
  419. updateGroupGeometry( mesh, geometry );
  420. }
  421. var folder = gui.addFolder( 'THREE.LatheBufferGeometry' );
  422. folder.add( data, 'segments', 1, 30 ).step( 1 ).onChange( generateGeometry );
  423. folder.add( data, 'phiStart', 0, twoPi ).onChange( generateGeometry );
  424. folder.add( data, 'phiLength', 0, twoPi ).onChange( generateGeometry );
  425. generateGeometry();
  426. },
  427. LatheGeometry: function ( mesh ) {
  428. var points = [];
  429. for ( var i = 0; i < 10; i ++ ) {
  430. points.push( new Vector2( Math.sin( i * 0.2 ) * 10 + 5, ( i - 5 ) * 2 ) );
  431. }
  432. var data = {
  433. segments: 12,
  434. phiStart: 0,
  435. phiLength: twoPi
  436. };
  437. function generateGeometry() {
  438. var geometry = new LatheGeometry(
  439. points, data.segments, data.phiStart, data.phiLength
  440. );
  441. updateGroupGeometry( mesh, geometry );
  442. }
  443. var folder = gui.addFolder( 'THREE.LatheGeometry' );
  444. folder.add( data, 'segments', 1, 30 ).step( 1 ).onChange( generateGeometry );
  445. folder.add( data, 'phiStart', 0, twoPi ).onChange( generateGeometry );
  446. folder.add( data, 'phiLength', 0, twoPi ).onChange( generateGeometry );
  447. generateGeometry();
  448. },
  449. OctahedronGeometry: function ( mesh ) {
  450. var data = {
  451. radius: 10,
  452. detail: 0
  453. };
  454. function generateGeometry() {
  455. updateGroupGeometry( mesh,
  456. new OctahedronGeometry(
  457. data.radius, data.detail
  458. )
  459. );
  460. }
  461. var folder = gui.addFolder( 'THREE.OctahedronGeometry' );
  462. folder.add( data, 'radius', 1, 20 ).onChange( generateGeometry );
  463. folder.add( data, 'detail', 0, 5 ).step( 1 ).onChange( generateGeometry );
  464. generateGeometry();
  465. },
  466. OctahedronBufferGeometry: function ( mesh ) {
  467. var data = {
  468. radius: 10,
  469. detail: 0
  470. };
  471. function generateGeometry() {
  472. updateGroupGeometry( mesh,
  473. new OctahedronBufferGeometry(
  474. data.radius, data.detail
  475. )
  476. );
  477. }
  478. var folder = gui.addFolder( 'THREE.OctahedronBufferGeometry' );
  479. folder.add( data, 'radius', 1, 20 ).onChange( generateGeometry );
  480. folder.add( data, 'detail', 0, 5 ).step( 1 ).onChange( generateGeometry );
  481. generateGeometry();
  482. },
  483. PlaneBufferGeometry: function ( mesh ) {
  484. var data = {
  485. width: 10,
  486. height: 10,
  487. widthSegments: 1,
  488. heightSegments: 1
  489. };
  490. function generateGeometry() {
  491. updateGroupGeometry( mesh,
  492. new PlaneBufferGeometry(
  493. data.width, data.height, data.widthSegments, data.heightSegments
  494. )
  495. );
  496. }
  497. var folder = gui.addFolder( 'THREE.PlaneBufferGeometry' );
  498. folder.add( data, 'width', 1, 30 ).onChange( generateGeometry );
  499. folder.add( data, 'height', 1, 30 ).onChange( generateGeometry );
  500. folder.add( data, 'widthSegments', 1, 30 ).step( 1 ).onChange( generateGeometry );
  501. folder.add( data, 'heightSegments', 1, 30 ).step( 1 ).onChange( generateGeometry );
  502. generateGeometry();
  503. },
  504. PlaneGeometry: function ( mesh ) {
  505. var data = {
  506. width: 10,
  507. height: 10,
  508. widthSegments: 1,
  509. heightSegments: 1
  510. };
  511. function generateGeometry() {
  512. updateGroupGeometry( mesh,
  513. new PlaneGeometry(
  514. data.width, data.height, data.widthSegments, data.heightSegments
  515. )
  516. );
  517. }
  518. var folder = gui.addFolder( 'THREE.PlaneGeometry' );
  519. folder.add( data, 'width', 1, 30 ).onChange( generateGeometry );
  520. folder.add( data, 'height', 1, 30 ).onChange( generateGeometry );
  521. folder.add( data, 'widthSegments', 1, 30 ).step( 1 ).onChange( generateGeometry );
  522. folder.add( data, 'heightSegments', 1, 30 ).step( 1 ).onChange( generateGeometry );
  523. generateGeometry();
  524. },
  525. RingBufferGeometry: function ( mesh ) {
  526. var data = {
  527. innerRadius: 5,
  528. outerRadius: 10,
  529. thetaSegments: 8,
  530. phiSegments: 8,
  531. thetaStart: 0,
  532. thetaLength: twoPi
  533. };
  534. function generateGeometry() {
  535. updateGroupGeometry( mesh,
  536. new RingBufferGeometry(
  537. data.innerRadius, data.outerRadius, data.thetaSegments, data.phiSegments, data.thetaStart, data.thetaLength
  538. )
  539. );
  540. }
  541. var folder = gui.addFolder( 'THREE.RingBufferGeometry' );
  542. folder.add( data, 'innerRadius', 1, 30 ).onChange( generateGeometry );
  543. folder.add( data, 'outerRadius', 1, 30 ).onChange( generateGeometry );
  544. folder.add( data, 'thetaSegments', 1, 30 ).step( 1 ).onChange( generateGeometry );
  545. folder.add( data, 'phiSegments', 1, 30 ).step( 1 ).onChange( generateGeometry );
  546. folder.add( data, 'thetaStart', 0, twoPi ).onChange( generateGeometry );
  547. folder.add( data, 'thetaLength', 0, twoPi ).onChange( generateGeometry );
  548. generateGeometry();
  549. },
  550. RingGeometry: function ( mesh ) {
  551. var data = {
  552. innerRadius: 5,
  553. outerRadius: 10,
  554. thetaSegments: 8,
  555. phiSegments: 8,
  556. thetaStart: 0,
  557. thetaLength: twoPi
  558. };
  559. function generateGeometry() {
  560. updateGroupGeometry( mesh,
  561. new RingGeometry(
  562. data.innerRadius, data.outerRadius, data.thetaSegments, data.phiSegments, data.thetaStart, data.thetaLength
  563. )
  564. );
  565. }
  566. var folder = gui.addFolder( 'THREE.RingGeometry' );
  567. folder.add( data, 'innerRadius', 1, 30 ).onChange( generateGeometry );
  568. folder.add( data, 'outerRadius', 1, 30 ).onChange( generateGeometry );
  569. folder.add( data, 'thetaSegments', 1, 30 ).step( 1 ).onChange( generateGeometry );
  570. folder.add( data, 'phiSegments', 1, 30 ).step( 1 ).onChange( generateGeometry );
  571. folder.add( data, 'thetaStart', 0, twoPi ).onChange( generateGeometry );
  572. folder.add( data, 'thetaLength', 0, twoPi ).onChange( generateGeometry );
  573. generateGeometry();
  574. },
  575. SphereBufferGeometry: function ( mesh ) {
  576. var data = {
  577. radius: 15,
  578. widthSegments: 8,
  579. heightSegments: 6,
  580. phiStart: 0,
  581. phiLength: twoPi,
  582. thetaStart: 0,
  583. thetaLength: Math.PI
  584. };
  585. function generateGeometry() {
  586. updateGroupGeometry( mesh,
  587. new SphereBufferGeometry(
  588. data.radius, data.widthSegments, data.heightSegments, data.phiStart, data.phiLength, data.thetaStart, data.thetaLength
  589. )
  590. );
  591. }
  592. var folder = gui.addFolder( 'THREE.SphereBufferGeometry' );
  593. folder.add( data, 'radius', 1, 30 ).onChange( generateGeometry );
  594. folder.add( data, 'widthSegments', 3, 32 ).step( 1 ).onChange( generateGeometry );
  595. folder.add( data, 'heightSegments', 2, 32 ).step( 1 ).onChange( generateGeometry );
  596. folder.add( data, 'phiStart', 0, twoPi ).onChange( generateGeometry );
  597. folder.add( data, 'phiLength', 0, twoPi ).onChange( generateGeometry );
  598. folder.add( data, 'thetaStart', 0, twoPi ).onChange( generateGeometry );
  599. folder.add( data, 'thetaLength', 0, twoPi ).onChange( generateGeometry );
  600. generateGeometry();
  601. },
  602. SphereGeometry: function ( mesh ) {
  603. var data = {
  604. radius: 15,
  605. widthSegments: 8,
  606. heightSegments: 6,
  607. phiStart: 0,
  608. phiLength: twoPi,
  609. thetaStart: 0,
  610. thetaLength: Math.PI
  611. };
  612. function generateGeometry() {
  613. updateGroupGeometry( mesh,
  614. new SphereGeometry(
  615. data.radius, data.widthSegments, data.heightSegments, data.phiStart, data.phiLength, data.thetaStart, data.thetaLength
  616. )
  617. );
  618. }
  619. var folder = gui.addFolder( 'THREE.SphereGeometry' );
  620. folder.add( data, 'radius', 1, 30 ).onChange( generateGeometry );
  621. folder.add( data, 'widthSegments', 3, 32 ).step( 1 ).onChange( generateGeometry );
  622. folder.add( data, 'heightSegments', 2, 32 ).step( 1 ).onChange( generateGeometry );
  623. folder.add( data, 'phiStart', 0, twoPi ).onChange( generateGeometry );
  624. folder.add( data, 'phiLength', 0, twoPi ).onChange( generateGeometry );
  625. folder.add( data, 'thetaStart', 0, twoPi ).onChange( generateGeometry );
  626. folder.add( data, 'thetaLength', 0, twoPi ).onChange( generateGeometry );
  627. generateGeometry();
  628. },
  629. TetrahedronGeometry: function ( mesh ) {
  630. var data = {
  631. radius: 10,
  632. detail: 0
  633. };
  634. function generateGeometry() {
  635. updateGroupGeometry( mesh,
  636. new TetrahedronGeometry(
  637. data.radius, data.detail
  638. )
  639. );
  640. }
  641. var folder = gui.addFolder( 'THREE.TetrahedronGeometry' );
  642. folder.add( data, 'radius', 1, 20 ).onChange( generateGeometry );
  643. folder.add( data, 'detail', 0, 5 ).step( 1 ).onChange( generateGeometry );
  644. generateGeometry();
  645. },
  646. TetrahedronBufferGeometry: function ( mesh ) {
  647. var data = {
  648. radius: 10,
  649. detail: 0
  650. };
  651. function generateGeometry() {
  652. updateGroupGeometry( mesh,
  653. new TetrahedronBufferGeometry(
  654. data.radius, data.detail
  655. )
  656. );
  657. }
  658. var folder = gui.addFolder( 'THREE.TetrahedronBufferGeometry' );
  659. folder.add( data, 'radius', 1, 20 ).onChange( generateGeometry );
  660. folder.add( data, 'detail', 0, 5 ).step( 1 ).onChange( generateGeometry );
  661. generateGeometry();
  662. },
  663. TextGeometry: function ( mesh ) {
  664. var data = {
  665. text: "TextGeometry",
  666. size: 5,
  667. height: 2,
  668. curveSegments: 12,
  669. font: "helvetiker",
  670. weight: "regular",
  671. bevelEnabled: false,
  672. bevelThickness: 1,
  673. bevelSize: 0.5,
  674. bevelOffset: 0.0,
  675. bevelSegments: 3
  676. };
  677. var fonts = [
  678. "helvetiker",
  679. "optimer",
  680. "gentilis",
  681. "droid/droid_serif"
  682. ];
  683. var weights = [
  684. "regular", "bold"
  685. ];
  686. function generateGeometry() {
  687. var loader = new FontLoader();
  688. loader.load( '../../examples/fonts/' + data.font + '_' + data.weight + '.typeface.json', function ( font ) {
  689. var geometry = new TextGeometry( data.text, {
  690. font: font,
  691. size: data.size,
  692. height: data.height,
  693. curveSegments: data.curveSegments,
  694. bevelEnabled: data.bevelEnabled,
  695. bevelThickness: data.bevelThickness,
  696. bevelSize: data.bevelSize,
  697. bevelOffset: data.bevelOffset,
  698. bevelSegments: data.bevelSegments
  699. } );
  700. geometry.center();
  701. updateGroupGeometry( mesh, geometry );
  702. } );
  703. }
  704. //Hide the wireframe
  705. mesh.children[ 0 ].visible = false;
  706. var folder = gui.addFolder( 'THREE.TextGeometry' );
  707. folder.add( data, 'text' ).onChange( generateGeometry );
  708. folder.add( data, 'size', 1, 30 ).onChange( generateGeometry );
  709. folder.add( data, 'height', 1, 20 ).onChange( generateGeometry );
  710. folder.add( data, 'curveSegments', 1, 20 ).step( 1 ).onChange( generateGeometry );
  711. folder.add( data, 'font', fonts ).onChange( generateGeometry );
  712. folder.add( data, 'weight', weights ).onChange( generateGeometry );
  713. folder.add( data, 'bevelEnabled' ).onChange( generateGeometry );
  714. folder.add( data, 'bevelThickness', 0.1, 3 ).onChange( generateGeometry );
  715. folder.add( data, 'bevelSize', 0, 3 ).onChange( generateGeometry );
  716. folder.add( data, 'bevelOffset', - 0.5, 1.5 ).onChange( generateGeometry );
  717. folder.add( data, 'bevelSegments', 0, 8 ).step( 1 ).onChange( generateGeometry );
  718. generateGeometry();
  719. },
  720. TextBufferGeometry: function ( mesh ) {
  721. var data = {
  722. text: "TextBufferGeometry",
  723. size: 5,
  724. height: 2,
  725. curveSegments: 12,
  726. font: "helvetiker",
  727. weight: "regular",
  728. bevelEnabled: false,
  729. bevelThickness: 1,
  730. bevelSize: 0.5,
  731. bevelOffset: 0.0,
  732. bevelSegments: 3
  733. };
  734. var fonts = [
  735. "helvetiker",
  736. "optimer",
  737. "gentilis",
  738. "droid/droid_serif"
  739. ];
  740. var weights = [
  741. "regular", "bold"
  742. ];
  743. function generateGeometry() {
  744. var loader = new FontLoader();
  745. loader.load( '../../examples/fonts/' + data.font + '_' + data.weight + '.typeface.json', function ( font ) {
  746. var geometry = new TextBufferGeometry( data.text, {
  747. font: font,
  748. size: data.size,
  749. height: data.height,
  750. curveSegments: data.curveSegments,
  751. bevelEnabled: data.bevelEnabled,
  752. bevelThickness: data.bevelThickness,
  753. bevelSize: data.bevelSize,
  754. bevelOffset: data.bevelOffset,
  755. bevelSegments: data.bevelSegments
  756. } );
  757. geometry.center();
  758. updateGroupGeometry( mesh, geometry );
  759. } );
  760. }
  761. //Hide the wireframe
  762. mesh.children[ 0 ].visible = false;
  763. var folder = gui.addFolder( 'THREE.TextBufferGeometry' );
  764. folder.add( data, 'text' ).onChange( generateGeometry );
  765. folder.add( data, 'size', 1, 30 ).onChange( generateGeometry );
  766. folder.add( data, 'height', 1, 20 ).onChange( generateGeometry );
  767. folder.add( data, 'curveSegments', 1, 20 ).step( 1 ).onChange( generateGeometry );
  768. folder.add( data, 'font', fonts ).onChange( generateGeometry );
  769. folder.add( data, 'weight', weights ).onChange( generateGeometry );
  770. folder.add( data, 'bevelEnabled' ).onChange( generateGeometry );
  771. folder.add( data, 'bevelThickness', 0.1, 3 ).onChange( generateGeometry );
  772. folder.add( data, 'bevelSize', 0, 3 ).onChange( generateGeometry );
  773. folder.add( data, 'bevelOffset', - 0.5, 1.5 ).onChange( generateGeometry );
  774. folder.add( data, 'bevelSegments', 0, 8 ).step( 1 ).onChange( generateGeometry );
  775. generateGeometry();
  776. },
  777. TorusBufferGeometry: function ( mesh ) {
  778. var data = {
  779. radius: 10,
  780. tube: 3,
  781. radialSegments: 16,
  782. tubularSegments: 100,
  783. arc: twoPi
  784. };
  785. function generateGeometry() {
  786. updateGroupGeometry( mesh,
  787. new TorusBufferGeometry(
  788. data.radius, data.tube, data.radialSegments, data.tubularSegments, data.arc
  789. )
  790. );
  791. }
  792. var folder = gui.addFolder( 'THREE.TorusBufferGeometry' );
  793. folder.add( data, 'radius', 1, 20 ).onChange( generateGeometry );
  794. folder.add( data, 'tube', 0.1, 10 ).onChange( generateGeometry );
  795. folder.add( data, 'radialSegments', 2, 30 ).step( 1 ).onChange( generateGeometry );
  796. folder.add( data, 'tubularSegments', 3, 200 ).step( 1 ).onChange( generateGeometry );
  797. folder.add( data, 'arc', 0.1, twoPi ).onChange( generateGeometry );
  798. generateGeometry();
  799. },
  800. TorusGeometry: function ( mesh ) {
  801. var data = {
  802. radius: 10,
  803. tube: 3,
  804. radialSegments: 16,
  805. tubularSegments: 100,
  806. arc: twoPi
  807. };
  808. function generateGeometry() {
  809. updateGroupGeometry( mesh,
  810. new TorusGeometry(
  811. data.radius, data.tube, data.radialSegments, data.tubularSegments, data.arc
  812. )
  813. );
  814. }
  815. var folder = gui.addFolder( 'THREE.TorusGeometry' );
  816. folder.add( data, 'radius', 1, 20 ).onChange( generateGeometry );
  817. folder.add( data, 'tube', 0.1, 10 ).onChange( generateGeometry );
  818. folder.add( data, 'radialSegments', 2, 30 ).step( 1 ).onChange( generateGeometry );
  819. folder.add( data, 'tubularSegments', 3, 200 ).step( 1 ).onChange( generateGeometry );
  820. folder.add( data, 'arc', 0.1, twoPi ).onChange( generateGeometry );
  821. generateGeometry();
  822. },
  823. TorusKnotBufferGeometry: function ( mesh ) {
  824. var data = {
  825. radius: 10,
  826. tube: 3,
  827. tubularSegments: 64,
  828. radialSegments: 8,
  829. p: 2,
  830. q: 3
  831. };
  832. function generateGeometry() {
  833. updateGroupGeometry( mesh,
  834. new TorusKnotBufferGeometry(
  835. data.radius, data.tube, data.tubularSegments, data.radialSegments,
  836. data.p, data.q
  837. )
  838. );
  839. }
  840. var folder = gui.addFolder( 'THREE.TorusKnotBufferGeometry' );
  841. folder.add( data, 'radius', 1, 20 ).onChange( generateGeometry );
  842. folder.add( data, 'tube', 0.1, 10 ).onChange( generateGeometry );
  843. folder.add( data, 'tubularSegments', 3, 300 ).step( 1 ).onChange( generateGeometry );
  844. folder.add( data, 'radialSegments', 3, 20 ).step( 1 ).onChange( generateGeometry );
  845. folder.add( data, 'p', 1, 20 ).step( 1 ).onChange( generateGeometry );
  846. folder.add( data, 'q', 1, 20 ).step( 1 ).onChange( generateGeometry );
  847. generateGeometry();
  848. },
  849. TorusKnotGeometry: function ( mesh ) {
  850. var data = {
  851. radius: 10,
  852. tube: 3,
  853. tubularSegments: 64,
  854. radialSegments: 8,
  855. p: 2,
  856. q: 3
  857. };
  858. function generateGeometry() {
  859. updateGroupGeometry( mesh,
  860. new TorusKnotGeometry(
  861. data.radius, data.tube, data.tubularSegments, data.radialSegments,
  862. data.p, data.q
  863. )
  864. );
  865. }
  866. var folder = gui.addFolder( 'THREE.TorusKnotGeometry' );
  867. folder.add( data, 'radius', 1, 20 ).onChange( generateGeometry );
  868. folder.add( data, 'tube', 0.1, 10 ).onChange( generateGeometry );
  869. folder.add( data, 'tubularSegments', 3, 300 ).step( 1 ).onChange( generateGeometry );
  870. folder.add( data, 'radialSegments', 3, 20 ).step( 1 ).onChange( generateGeometry );
  871. folder.add( data, 'p', 1, 20 ).step( 1 ).onChange( generateGeometry );
  872. folder.add( data, 'q', 1, 20 ).step( 1 ).onChange( generateGeometry );
  873. generateGeometry();
  874. },
  875. ParametricBufferGeometry: function ( mesh ) {
  876. var data = {
  877. slices: 25,
  878. stacks: 25
  879. };
  880. function generateGeometry() {
  881. updateGroupGeometry( mesh,
  882. new ParametricBufferGeometry( ParametricGeometries.klein, data.slices, data.stacks )
  883. );
  884. }
  885. var folder = gui.addFolder( 'THREE.ParametricBufferGeometry' );
  886. folder.add( data, 'slices', 1, 100 ).step( 1 ).onChange( generateGeometry );
  887. folder.add( data, 'stacks', 1, 100 ).step( 1 ).onChange( generateGeometry );
  888. generateGeometry();
  889. },
  890. ParametricGeometry: function ( mesh ) {
  891. var data = {
  892. slices: 25,
  893. stacks: 25
  894. };
  895. function generateGeometry() {
  896. updateGroupGeometry( mesh,
  897. new ParametricGeometry( ParametricGeometries.klein, data.slices, data.stacks )
  898. );
  899. }
  900. var folder = gui.addFolder( 'THREE.ParametricGeometry' );
  901. folder.add( data, 'slices', 1, 100 ).step( 1 ).onChange( generateGeometry );
  902. folder.add( data, 'stacks', 1, 100 ).step( 1 ).onChange( generateGeometry );
  903. generateGeometry();
  904. },
  905. TubeGeometry: function ( mesh ) {
  906. var data = {
  907. segments: 20,
  908. radius: 2,
  909. radialSegments: 8
  910. };
  911. var path = new CustomSinCurve( 10 );
  912. function generateGeometry() {
  913. updateGroupGeometry( mesh,
  914. new TubeGeometry( path, data.segments, data.radius, data.radialSegments, false )
  915. );
  916. }
  917. var folder = gui.addFolder( 'THREE.TubeGeometry' );
  918. folder.add( data, 'segments', 1, 100 ).step( 1 ).onChange( generateGeometry );
  919. folder.add( data, 'radius', 1, 10 ).onChange( generateGeometry );
  920. folder.add( data, 'radialSegments', 1, 20 ).step( 1 ).onChange( generateGeometry );
  921. generateGeometry();
  922. },
  923. TubeBufferGeometry: function ( mesh ) {
  924. var data = {
  925. segments: 20,
  926. radius: 2,
  927. radialSegments: 8
  928. };
  929. var path = new CustomSinCurve( 10 );
  930. function generateGeometry() {
  931. updateGroupGeometry( mesh,
  932. new TubeBufferGeometry( path, data.segments, data.radius, data.radialSegments, false )
  933. );
  934. }
  935. var folder = gui.addFolder( 'THREE.TubeBufferGeometry' );
  936. folder.add( data, 'segments', 1, 100 ).step( 1 ).onChange( generateGeometry );
  937. folder.add( data, 'radius', 1, 10 ).onChange( generateGeometry );
  938. folder.add( data, 'radialSegments', 1, 20 ).step( 1 ).onChange( generateGeometry );
  939. generateGeometry();
  940. },
  941. ShapeGeometry: function ( mesh ) {
  942. var data = {
  943. segments: 12
  944. };
  945. function generateGeometry() {
  946. var geometry = new ShapeGeometry( heartShape, data.segments );
  947. geometry.center();
  948. updateGroupGeometry( mesh, geometry );
  949. }
  950. var folder = gui.addFolder( 'THREE.ShapeGeometry' );
  951. folder.add( data, 'segments', 1, 100 ).step( 1 ).onChange( generateGeometry );
  952. generateGeometry();
  953. },
  954. ShapeBufferGeometry: function ( mesh ) {
  955. var data = {
  956. segments: 12
  957. };
  958. function generateGeometry() {
  959. var geometry = new ShapeBufferGeometry( heartShape, data.segments );
  960. geometry.center();
  961. updateGroupGeometry( mesh, geometry );
  962. }
  963. var folder = gui.addFolder( 'THREE.ShapeBufferGeometry' );
  964. folder.add( data, 'segments', 1, 100 ).step( 1 ).onChange( generateGeometry );
  965. generateGeometry();
  966. },
  967. ExtrudeGeometry: function ( mesh ) {
  968. var data = {
  969. steps: 2,
  970. depth: 16,
  971. bevelEnabled: true,
  972. bevelThickness: 1,
  973. bevelSize: 1,
  974. bevelOffset: 0,
  975. bevelSegments: 1
  976. };
  977. var length = 12, width = 8;
  978. var shape = new Shape();
  979. shape.moveTo( 0, 0 );
  980. shape.lineTo( 0, width );
  981. shape.lineTo( length, width );
  982. shape.lineTo( length, 0 );
  983. shape.lineTo( 0, 0 );
  984. function generateGeometry() {
  985. var geometry = new ExtrudeGeometry( shape, data );
  986. geometry.center();
  987. updateGroupGeometry( mesh, geometry );
  988. }
  989. var folder = gui.addFolder( 'THREE.ExtrudeGeometry' );
  990. folder.add( data, 'steps', 1, 10 ).step( 1 ).onChange( generateGeometry );
  991. folder.add( data, 'depth', 1, 20 ).onChange( generateGeometry );
  992. folder.add( data, 'bevelThickness', 1, 5 ).step( 1 ).onChange( generateGeometry );
  993. folder.add( data, 'bevelSize', 0, 5 ).step( 1 ).onChange( generateGeometry );
  994. folder.add( data, 'bevelOffset', - 4, 5 ).step( 1 ).onChange( generateGeometry );
  995. folder.add( data, 'bevelSegments', 1, 5 ).step( 1 ).onChange( generateGeometry );
  996. generateGeometry();
  997. },
  998. ExtrudeBufferGeometry: function ( mesh ) {
  999. var data = {
  1000. steps: 2,
  1001. depth: 16,
  1002. bevelEnabled: true,
  1003. bevelThickness: 1,
  1004. bevelSize: 1,
  1005. bevelOffset: 0,
  1006. bevelSegments: 1
  1007. };
  1008. var length = 12, width = 8;
  1009. var shape = new Shape();
  1010. shape.moveTo( 0, 0 );
  1011. shape.lineTo( 0, width );
  1012. shape.lineTo( length, width );
  1013. shape.lineTo( length, 0 );
  1014. shape.lineTo( 0, 0 );
  1015. function generateGeometry() {
  1016. var geometry = new ExtrudeBufferGeometry( shape, data );
  1017. geometry.center();
  1018. updateGroupGeometry( mesh, geometry );
  1019. }
  1020. var folder = gui.addFolder( 'THREE.ExtrudeBufferGeometry' );
  1021. folder.add( data, 'steps', 1, 10 ).step( 1 ).onChange( generateGeometry );
  1022. folder.add( data, 'depth', 1, 20 ).onChange( generateGeometry );
  1023. folder.add( data, 'bevelThickness', 1, 5 ).step( 1 ).onChange( generateGeometry );
  1024. folder.add( data, 'bevelSize', 0, 5 ).step( 1 ).onChange( generateGeometry );
  1025. folder.add( data, 'bevelOffset', - 4, 5 ).step( 1 ).onChange( generateGeometry );
  1026. folder.add( data, 'bevelSegments', 1, 5 ).step( 1 ).onChange( generateGeometry );
  1027. generateGeometry();
  1028. }
  1029. };
  1030. function chooseFromHash( mesh ) {
  1031. var selectedGeometry = window.location.hash.substring( 1 ) || "TorusGeometry";
  1032. if ( guis[ selectedGeometry ] !== undefined ) {
  1033. guis[ selectedGeometry ]( mesh );
  1034. }
  1035. if ( selectedGeometry === 'TextGeometry' || selectedGeometry === 'TextBufferGeometry' ) {
  1036. return { fixed: true };
  1037. }
  1038. //No configuration options
  1039. return {};
  1040. }
  1041. //
  1042. document.getElementById( 'newWindow' ).href += window.location.hash;
  1043. var gui = new GUI();
  1044. var scene = new Scene();
  1045. scene.background = new Color( 0x444444 );
  1046. var camera = new PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 50 );
  1047. camera.position.z = 30;
  1048. var renderer = new WebGLRenderer( { antialias: true } );
  1049. renderer.setPixelRatio( window.devicePixelRatio );
  1050. renderer.setSize( window.innerWidth, window.innerHeight );
  1051. document.body.appendChild( renderer.domElement );
  1052. var orbit = new OrbitControls( camera, renderer.domElement );
  1053. orbit.enableZoom = false;
  1054. var lights = [];
  1055. lights[ 0 ] = new PointLight( 0xffffff, 1, 0 );
  1056. lights[ 1 ] = new PointLight( 0xffffff, 1, 0 );
  1057. lights[ 2 ] = new PointLight( 0xffffff, 1, 0 );
  1058. lights[ 0 ].position.set( 0, 200, 0 );
  1059. lights[ 1 ].position.set( 100, 200, 100 );
  1060. lights[ 2 ].position.set( - 100, - 200, - 100 );
  1061. scene.add( lights[ 0 ] );
  1062. scene.add( lights[ 1 ] );
  1063. scene.add( lights[ 2 ] );
  1064. var group = new Group();
  1065. var geometry = new BufferGeometry();
  1066. geometry.setAttribute( 'position', new Float32BufferAttribute( [], 3 ) );
  1067. var lineMaterial = new LineBasicMaterial( { color: 0xffffff, transparent: true, opacity: 0.5 } );
  1068. var meshMaterial = new MeshPhongMaterial( { color: 0x156289, emissive: 0x072534, side: DoubleSide, flatShading: true } );
  1069. group.add( new LineSegments( geometry, lineMaterial ) );
  1070. group.add( new Mesh( geometry, meshMaterial ) );
  1071. var options = chooseFromHash( group );
  1072. scene.add( group );
  1073. var render = function () {
  1074. requestAnimationFrame( render );
  1075. if ( ! options.fixed ) {
  1076. group.rotation.x += 0.005;
  1077. group.rotation.y += 0.005;
  1078. }
  1079. renderer.render( scene, camera );
  1080. };
  1081. window.addEventListener( 'resize', function () {
  1082. camera.aspect = window.innerWidth / window.innerHeight;
  1083. camera.updateProjectionMatrix();
  1084. renderer.setSize( window.innerWidth, window.innerHeight );
  1085. }, false );
  1086. render();
  1087. </script>
  1088. </body>
  1089. </html>