项目作者: hofk

项目描述 :
three.js addon, to produce almost infinite many time-varying geometries / buffer geometries with functions (cylindrical coordinates)
高级语言: JavaScript
项目地址: git://github.com/hofk/THREEf.js.git
创建时间: 2017-04-26T07:20:45Z
项目社区:https://github.com/hofk/THREEf.js

开源协议:

下载


THREEf.js

three.js addon, to produce almost infinite many time-varying Geometries and BufferGeometries with functions

License identical to three.js

//
@author hofk / http://sandbox.threejs.hofk.de/
//

Produce almost infinite many time-varying Geometries( up to three.js r124 ) or BufferGeometries with only 15 properties, 19 functions and 2 arrays:

  1. ( geometry = new THREE.Geometry(); // old base class geometry object, only up to revision 124! )
  2. // use better:
  3. geometry = new THREE.BufferGeometry(); // base class buffer-geometry object from THREE.js
  4. geometry.createMorphGeometry = THREEf.createMorphGeometry; // insert the methode from THREEf.js
  5. // for non-indexed BufferGeometry set parameter indexed: false,
  6. geometry.createMorphGeometry(); // apply the methode ( here without parameters: all default )
  7. mesh = new THREE.Mesh( geometry, materials ); // create a material array: materials
  8. scene.add( mesh );
  9. mesh.add( geometry.quadLine ); // only if used propertie quadLine: add the quad line

Include:


  1. _87 now contains
  2. function vertexFaceNumbersHelper (mesh, mode, size, color)
  3. // mode: 0 nothing, 1 vertex, 2 face, 3 vertex & face
  4. and uses .flatShading: true or false; // three.js r87
  5. -----------------------------------------------------
  6. _88 now contains
  7. explode, // function ( t ) // factor for exploded view (only non indexed BufferGeometry)
  8. -----------------------------------------------------
  9. _89 now contains
  10. fixedMatTop, // fixed given material index (string of digits for faces), overrides materialTop values
  11. fixedMatBottom, // fixed given material index (string of digits for faces), overrides materialBottom values
  12. -----------------------------------------------------
  13. _90 now contains
  14. explodemode, // 'center','normal'

Note:
From revision 95 modifyGeo.html no longer needs a workaround of three.js
Multimaterial raycast is now supported in the core of three.js. (r94 still has a bug)

As of three.js revision 125, the old geometry is no longer available.


Example:

  1. geometry = new THREE.BufferGeometry();
  2. geometry.createMorphGeometry = THREEf.createMorphGeometry;
  3. geometry.createMorphGeometry({
  4. indexed: false, // default is true
  5. height: 80,
  6. heightSegments: 80,
  7. rCircHeight: function ( u, v, t ) { return 1.01 + Math.cos( 25.2 * v ) * Math.sin( 0.2 * t ) },
  8. centerX: function ( v, t ) { return 0.75*Math.sin( 9 * v + 0.2 * t)},
  9. centerZ: function ( v, t ) { return 0.45*Math.cos( 9 * v + 0.2 * t)},
  10. materialCover: function ( u, v, t) { return Math.floor( t ) % 20 < 5 ? 0 : 0.8 }
  11. }); // Material: min. 9 materials in multi material array! index: 0.8 * 10 = 8

View the live version of formLibrary.html: https://rawgit.com/hofk/THREEf.js/dev/formLibrary.html

Parameters briefly explained in THREEf.js:

  1. /* parameter overview --- all parameters are optional ---
  2. p = {
  3. // simple properties
  4. indexed, // indexed or non indexed BufferGeometry
  5. radius, // reference radius, multiplier for functions
  6. height, // reference height, multiplier for functions
  7. radiusSegments, // radius segments (number)
  8. heightSegments, // height segments (number)
  9. circOpen, // circular connected or disconnected
  10. withTop, // with a top
  11. fixedMatTop, // fixed given material index (string of digits for faces), overrides materialTop values
  12. withBottom, // with a bottom
  13. fixedMatBottom, // fixed given material index (string of digits for faces), overrides materialBottom values
  14. waffled, // four faces / segment, with center vertex
  15. quadLine, // separate quad line, only aviable when circular open
  16. quadColor, // color of quad line
  17. style, // 'complete', 'cover', 'map'
  18. explodemode, // 'center','normal'
  19. // functions: u,v and result normally 0 .. 1, otherwise specific / interesting results!
  20. // ( trigonometric functions often with factor n * PI )
  21. // u radial, v heigt, t time
  22. rCircHeight, // function ( u, v, t ) // radius depending on segment location
  23. centerX, // function ( v, t ) // centerpoint x by height
  24. centerY, // function ( v, t ) // centerpoint y by height
  25. centerZ, // function ( v, t ) // centerpoint z by height
  26. unrollCover, // function ( v, t ) // 0 closed, 1 linear open (to -1*radius)
  27. waffleDeep, // function ( u, v, t ) // radius difference center vertex
  28. moveX, // function ( u, v, t ) // factor for radius, move in x direction
  29. moveY, // function ( u, v, t ) // factor for height, move in y direction
  30. moveZ, // function ( v, u, t ) // factor for radius, move in z direction
  31. explode, // function ( t ) // factor for exploded view (only non indexed BufferGeometry)
  32. endCircAngle, // function ( v, t ) // circular end angle (per height)
  33. startCircAngle, // function ( v, t ) // circular starting angle (per height)
  34. scaleCircAngle, // function ( u, t ) // scaling between start and end of circular angle
  35. topHeight, // function ( u, t ) // top height (per circular angle)
  36. bottomHeight, // function ( u, t ) // bottom height (per circular angle)
  37. scaleHeight, // function ( v, t ) // scaling between bottom and top height
  38. materialTop, // function ( u, t ) // material top ( per circular sector)
  39. materialBottom, // function ( u, t ) // material bottom ( per circular sector)
  40. materialCover, // function ( u, v, t ) // material cover ( per circular sector and height )
  41. // material: round( result*10 ) is material index 0 .. 10
  42. // string array (strings of digits) seperated with a ,
  43. fixedMaterial, // fixed given material index, overrides materialCover
  44. // array of center points replaces heightSegments, scaleHeight and the center functions centerX, centerY, centerZ
  45. centerPoints // array of arrays of coordinates [ [ x0, y0, z0 ], .. [ xi , yi, zi ] ], values normally 0 .. 1
  46. }
  47. */
  48. // When using multi material:
  49. // Take index 0 for invisible faces like THREE.MeshBasicMaterial( { visible: false } ),
  50. // or use transparent faces like THREE.MeshBasicMaterial( {transparent: true, opacity: 0.05 } )
  51. // Please note! The functions normally should have results from 0 to 1. If the multimaterial array
  52. // contains fewer materials than the functional result * 10, the script will crash.
  53. // Even if the result is negative.
  54. // String array fixedMaterial contains strings of digits 0 to 9, for instance [ .. '0011997741', '222200' .. ].
  55. // Every string represents a corresponding row of faces from left-top from cover.
  56. // It's not necessary, that the length of array / strings equals the number of faces, e.g. only ['1'] is sufficient.