{"id":15044716,"url":"https://github.com/cityjson/cityjson-threejs-loader","last_synced_at":"2025-03-17T16:13:39.844Z","repository":{"id":41410761,"uuid":"331300015","full_name":"cityjson/cityjson-threejs-loader","owner":"cityjson","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-06T16:50:36.000Z","size":27638,"stargazers_count":24,"open_issues_count":5,"forks_count":12,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-10T11:37:28.988Z","etag":null,"topics":["cityjson","threejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cityjson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-20T12:27:22.000Z","updated_at":"2025-02-20T00:06:05.000Z","dependencies_parsed_at":"2022-09-19T08:40:44.293Z","dependency_job_id":"c2be1055-063f-4fe3-b00a-a645829175c4","html_url":"https://github.com/cityjson/cityjson-threejs-loader","commit_stats":{"total_commits":169,"total_committers":3,"mean_commits":"56.333333333333336","dds":"0.047337278106508895","last_synced_commit":"7376b620d5fa333303d7a28e7e2d27b8b2570646"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cityjson%2Fcityjson-threejs-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cityjson%2Fcityjson-threejs-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cityjson%2Fcityjson-threejs-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cityjson%2Fcityjson-threejs-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cityjson","download_url":"https://codeload.github.com/cityjson/cityjson-threejs-loader/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244066189,"owners_count":20392406,"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":["cityjson","threejs"],"created_at":"2024-09-24T20:50:56.779Z","updated_at":"2025-03-17T16:13:39.804Z","avatar_url":"https://github.com/cityjson.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CityJSON three.js loader\n\nA loader for [CityJSON](https://www.cityjson.org) files in `three.js`.\n\n# Installation\n\n## Use in your project\n\n```\nyarn install git+https://github.com/cityjson/cityjson-threejs-loader.git\n```\n\n## Development\n\n- Clone this repository\n- Run `yarn install`\n- Go nuts!\n\n### Run examples\n\n- Run `yarn run dev`.\n- Visit [http://localhost:9080/example/dev-bundle/index.html](http://localhost:9080/example/dev-bundle/index.html)\n- Drag 'n' drop any file to visualise it.\n\n# Use\n\nYou need to select one of the availables parsers (recommended is `CityJSONWorkerParser`) and use it with `CityJSONLoader`.\n\n```JS\nimport { CityJSONLoader, CityJSONWorkerParser } from 'cityjson-threejs-loader'\n\n// Initialise your scene here\n\nconst parser = CityJSONWorkerParser();\n\nconst loader = CityJSONLoader( parser );\n\nloader.load( cityjsonData );\n\nscene.add( loader.scene );\n```\n\n## Raycasting the scene\n\nThe added scene objects contain functions to retrieve information related to the original city model when raycasting:\n\n```JS\n// Initialise raycaster\n\nconst intersections = raycaster.intersectObject( loader.scene );\n\nif ( intersection ) {\n\n    // Gain the 3D object that was hit by the closest ray\n    const object = intersection[ 0 ].object;\n\n    // Check if this is a city object\n    if ( object.isCityObject ) {\n\n        const data = object.resolveIntersectionInfo( intersection[ 0 ] )\n\n        const objectId = data.objectId; // This is the objectId of the city object hit by the ray\n\n    }\n\n}\n```\n\n## Visualization options\n\nThe scene objects have specialised materials to handle aspects of how the respective geometries are handled. For example:\n\n```JS\n// Traverse the scene for objects\nscene.traverse( obj = \u003e {\n\n    // Check if this has a material and if this is a city object material\n    if ( obj.material \u0026\u0026 obj.material.isCityObjectsMaterial ) {\n\n        obj.material.showSemantics = false; // This will disable coloring per semantic surface\n\n    }\n\n} );\n```\n\n## Highlighting objects\n\nCity object materials can be used to highlight a specific object:\n\n```JS\n// Assuming cityjsonData contains the citymodel and we want to highlight the selectObjectId\nconst objectIndex = Object.keys( cityjsonData.CityObjects ).indexOf( selectedObjectId )\n\n// Traverse the scene for objects\nscene.traverse( obj = \u003e {\n\n    // Check if this has a material and if this is a city object material\n    if ( obj.material \u0026\u0026 obj.material.isCityObjectsMaterial ) {\n\n        // Set the highlighted object index to what was found before\n        obj.highlightedObject = {\n\n            objectIndex: objectIndex\n\n        };\n\n    }\n\n} );\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcityjson%2Fcityjson-threejs-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcityjson%2Fcityjson-threejs-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcityjson%2Fcityjson-threejs-loader/lists"}