{"id":16147410,"url":"https://github.com/edap/palmgenerator","last_synced_at":"2025-03-16T09:33:33.400Z","repository":{"id":145594137,"uuid":"81544512","full_name":"edap/PalmGenerator","owner":"edap","description":"Three.js module to generate palms procedurally.","archived":false,"fork":false,"pushed_at":"2023-12-07T09:39:08.000Z","size":2096,"stargazers_count":75,"open_issues_count":0,"forks_count":11,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-27T07:12:03.682Z","etag":null,"topics":["3d","algorithmic-botany","palm","palm-generator"],"latest_commit_sha":null,"homepage":"http://www.davideprati.com/projects/palm-generator","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/edap.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-02-10T08:34:36.000Z","updated_at":"2024-08-12T15:49:49.000Z","dependencies_parsed_at":"2023-12-04T16:59:25.700Z","dependency_job_id":null,"html_url":"https://github.com/edap/PalmGenerator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edap%2FPalmGenerator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edap%2FPalmGenerator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edap%2FPalmGenerator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edap%2FPalmGenerator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/edap","download_url":"https://codeload.github.com/edap/PalmGenerator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243809875,"owners_count":20351407,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["3d","algorithmic-botany","palm","palm-generator"],"created_at":"2024-10-10T00:25:12.949Z","updated_at":"2025-03-16T09:33:32.955Z","avatar_url":"https://github.com/edap.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Palm Generator\n\n\u003ca href=\"https://vimeo.com/204789237\"\u003eVideo\u003c/a\u003e\n\nThe Palm Generator is a Three.js module to create palms. For the moment it is in beta version, and it is available just as es6 class, but an npm package will arrive soon.\n[Here](http://davideprati.com/projects/palm-generator) you can see what kind of palms it is able to create.\n\n## Usage\nThis repository contains a usage example, run `npm start`. To use the PalmGenerator in your THREEjs application, copy the classes `PalmGenerator.js` and `phyllotaxis.js` in your source folder and follow this instructions. \n\nFirst, you need to create a palm. The palm generator constructor has the following signature:\n\n```javascript\nlet palm = new PalmGenerator(leafGeometry, trunkGeometry, options, curve=false);\n```\n\n`leafGeometry`. Required. Has to be an instance of `THREE.Geometry`, and it is the geometry used for the leaves of the palm.\n\n`trunkGeometry`. Required. Has to be an instance of `THREE.Geometry`, and it is the geometry used for the trunk of the palm. \n\n`options`. Optional. Is an object containing the options. The available options are:\n\n- `spread`. Float. It is the value that defines how much the objects that compose the palm should distantiate from each other. Keep it between 0 and 2.\n\n- `angle` Float, degrees. It is the rotation angle that affects the phyllotaxis pattern. The default is the golden angle, 137.5,\n\n- `num` Integer. It defines how many objects compose the palm. Keep it between 200 and 1000. The smaller, the faster.\n\n- `growth`.Float. This value define how much the palm should grow along the y axis.\n\n- `foliage_start_at`. Integer.It defines how many object will be leafs. It has to be a value smaller than `num`.\n\n- `trunk_regular`. Boolean. It defines if the phyllotaxis will deform the trunk or not.\n\n- `vertex_colors`: Boolean. Enable per vertex color \n\n- `angle_open`: Float, degree. It defines the disclose angle of the leaves.\n\n- `starting_angle_open` Float, degree. It defines from which angle the leaves will start to disclose.\n\n`curve`. Optional. A CatmullRomCurve3 can be passed as last argument. The first vertex in the curve will define the position of the treetop, the last one will define the position of the part of the trunk that is attached to the ground. Look at the curve in `src/App.js` to see an example about how to make palms alongside curves. \n\nThe PalmGenerator returns an object containing an instance of THREE.Geometry.\n\nExample:\n\n```javascript\nlet leafGeometry = new THREE.SphereGeometry(5, 20, 20);\nlet trunkGeometry = new THREE.BoxGeometry(5,5,5);\nlet palm = new PalmGenerator(leafGeometry,\n                            trunkGeometry,\n                            curve);\nlet geometry = palm.geometry;\nlet bufGeometry = new THREE.BufferGeometry().fromGeometry(geometry);\nlet mesh = new THREE.Mesh(bufGeometry, material);\nscene.add( mesh );\n```\n\n## Enter LeafGeometry\n\nThe previous snippet generates a tree that looks weird. The trunk is fine but the foliage is really abstract.\nThis is because the PalmGenerator accepts any kind of geometry, but probably a sphere isn't the best geometry to draw a leaf. In order to have leaves the looks like palm leaves but do not require too much polygons, I've created a custom geometry, called `LeafGeometry`. You can dowload the class `LeafGeometry.js` from the [repository](https://github.com/edap/LeafGeometry) and put it into your source folder. We change the previous snippet as follows:\n\n```javascript\nlet leaf_opt = {\n    length: 60,\n    length_stem: 20,\n    width_stem: 0.2,\n    leaf_width: 0.8,\n    leaf_up: 1.5,\n    density: 11,\n    curvature: 0.04,\n    curvature_border: 0.005,\n    leaf_inclination: 0.9\n};\n\nlet trunkGeometry = new THREE.BoxGeometry(5,5,5);\nlet leafGeometry = new LeafGeometry(leaf_opt);\n\nlet palm_opt = {\n    spread: 0.1,\n    angle: 137.5,\n    num: 406,\n    growth: 0.12,\n    foliage_start_at: 56,\n    trunk_regular: false,\n    angle_open: 36.17,\n    starting_angle_open: 50\n};\n\nlet palmGeometry = new PalmGenerator(leafGeometry,\n                            trunkGeometry,\n                            palm_opt);\nlet mesh = new THREE.Mesh(palmGeometry, material);\nscene.add(mesh);\n```\n\nThe previous snippet should generate a palm like this one:\n\n![example](example.png)\n\n## Curves\n\nIf we add a curve to the previous palm, passing an instance of a `CatmullRomCurve3` as fourth argument to the constructor, for example:\n\n```javascript\nvar curve = new THREE.CatmullRomCurve3( [\n      new THREE.Vector3( -40, 150, 0 ),\n      new THREE.Vector3( -40, 100, 0 ),\n      new THREE.Vector3( 0, 60, 0 ),\n      new THREE.Vector3( 0, 0, 0 ),\n] );\n\nlet palm = new PalmGenerator(leafGeometry,\n                            trunkGeometry,\n                            palm_opt,\n                            curve);\n```\n\nA palm like the following one is created:\n\n![example](example-curve.png)\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedap%2Fpalmgenerator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedap%2Fpalmgenerator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedap%2Fpalmgenerator/lists"}