{"_id":"@bimangle/cesium-info-accessor","_rev":"3-866d882b65814e7dfe71fa514e3cec32","name":"@bimangle/cesium-info-accessor","dist-tags":{"latest":"2.0.1"},"versions":{"1.0.1":{"name":"@bimangle/cesium-info-accessor","version":"1.0.1","keywords":["cesium","3dtiles","gis"],"author":{"name":"BimAngle"},"license":"MIT","_id":"@bimangle/cesium-info-accessor@1.0.1","maintainers":[{"name":"bimangle.liu","email":"liuyongsheng@msn.com"}],"dist":{"shasum":"61b31ae726d7c96fbe8082ab3cf8d8a066298b25","tarball":"https://registry.npmjs.org/@bimangle/cesium-info-accessor/-/cesium-info-accessor-1.0.1.tgz","fileCount":4,"integrity":"sha512-nbYeo1lnOmLc0dFc+Z4H3o+sqnh5NL5UOjqMf1xP6byT8AZLQ5AtghXW+RYcgL2rpNkZNqLGl9La7IQQQRHWCg==","signatures":[{"sig":"MEUCIQDVV39RO/AcLEAT2joXM7GX/do5Yq9hXm2KfKVS+roj0wIgOkGC5KbvvsFBJ765xgIfTl6eSdmUsEI9SiYyzqksRpw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":49721},"main":"dist/cesium-info-accessor.js","scripts":{"build":"rollup -c","prepare":"npm run build"},"_npmUser":{"name":"bimangle.liu","email":"liuyongsheng@msn.com"},"_npmVersion":"10.1.0","description":"A Cesium plugin for automatically loading and displaying component property data from BimAngle-exported 3D Tiles datasets.","directories":{},"_nodeVersion":"20.9.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"rollup":"^2.79.2","@rollup/plugin-commonjs":"^22.0.2","@rollup/plugin-node-resolve":"^13.3.0"},"peerDependencies":{"cesium":"^1.110.0"},"_npmOperationalInternal":{"tmp":"tmp/cesium-info-accessor_1.0.1_1733884089597_0.37646525265268194","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"@bimangle/cesium-info-accessor","version":"2.0.0","keywords":["cesium","3dtiles","gis"],"author":{"name":"BimAngle"},"license":"MIT","_id":"@bimangle/cesium-info-accessor@2.0.0","maintainers":[{"name":"bimangle.liu","email":"liuyongsheng@msn.com"}],"dist":{"shasum":"fbe614d532f835a89c3f8b2623bf0b2abd65ee24","tarball":"https://registry.npmjs.org/@bimangle/cesium-info-accessor/-/cesium-info-accessor-2.0.0.tgz","fileCount":5,"integrity":"sha512-amszFDa3qf/2hSbmUtRKYae2cv3+3T2FXNJs1oPtf1kKVmRPbEYAgS88lkJtxnMnZelout2E6uLVmv+FKsaAJg==","signatures":[{"sig":"MEQCIB6t1QkhDLQJPRzNwjn1PwkQXKShiO7/KO8jVBo8Nf0GAiBpUv865JHfggSatV7OUXvdB896O/7dYbhx5puqsOgBvg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":77658},"main":"dist/cesium-info-accessor.js","gitHead":"28eb6fcd2370b8a1aa8203d82fe345432f07901b","scripts":{"build":"rollup -c","prepare":"npm run build"},"_npmUser":{"name":"bimangle.liu","email":"liuyongsheng@msn.com"},"_npmVersion":"11.6.1","description":"A Cesium plugin for automatically loading and displaying component property data from BimAngle-exported 3D Tiles datasets.","directories":{},"_nodeVersion":"24.11.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"rollup":"^2.79.2","@rollup/plugin-commonjs":"^22.0.2","@rollup/plugin-node-resolve":"^13.3.0"},"peerDependencies":{"cesium":"^1.110.0"},"_npmOperationalInternal":{"tmp":"tmp/cesium-info-accessor_2.0.0_1783507744202_0.8623603268400402","host":"s3://npm-registry-packages-npm-production"}},"2.0.1":{"name":"@bimangle/cesium-info-accessor","version":"2.0.1","description":"A Cesium plugin for automatically loading and displaying component property data from BimAngle-exported 3D Tiles datasets.","main":"dist/cesium-info-accessor.js","scripts":{"build":"rollup -c","prepare":"npm run build"},"keywords":["cesium","3dtiles","gis"],"author":{"name":"BimAngle"},"license":"MIT","publishConfig":{"access":"public"},"peerDependencies":{"cesium":"^1.110.0"},"devDependencies":{"@rollup/plugin-commonjs":"^22.0.2","@rollup/plugin-node-resolve":"^13.3.0","rollup":"^2.79.2"},"gitHead":"3e16dc24c714b653c86c934092770ce88fa65eb8","_id":"@bimangle/cesium-info-accessor@2.0.1","_nodeVersion":"24.11.0","_npmVersion":"11.6.1","dist":{"integrity":"sha512-HqX9h6bUiddEwHbnqbPjArdI3VKonZlfH+VuEdjHmHMfFHB5bf6Sv78NqBI91xIYxqE+FCtkQaWd/e4oihOU4A==","shasum":"e95a72822e43fb5fd8dbed1c46e022819677b5e8","tarball":"https://registry.npmjs.org/@bimangle/cesium-info-accessor/-/cesium-info-accessor-2.0.1.tgz","fileCount":5,"unpackedSize":78153,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIGfwPuFQlcc6hPdvc4w4ULTSY9q3+UmC8ZlWQckIAhouAiEA5PVMdi+Zbn6/VcKpZlpA3fyuLILKDCYzPIEl+dUcTc0="}]},"_npmUser":{"name":"bimangle.liu","email":"liuyongsheng@msn.com"},"directories":{},"maintainers":[{"name":"bimangle.liu","email":"liuyongsheng@msn.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/cesium-info-accessor_2.0.1_1783586591213_0.2245555171058926"},"_hasShrinkwrap":false}},"time":{"created":"2024-12-11T02:28:09.475Z","modified":"2026-07-09T08:43:11.490Z","1.0.1":"2024-12-11T02:28:09.842Z","2.0.0":"2026-07-08T10:49:04.343Z","2.0.1":"2026-07-09T08:43:11.372Z"},"author":{"name":"BimAngle"},"license":"MIT","keywords":["cesium","3dtiles","gis"],"description":"A Cesium plugin for automatically loading and displaying component property data from BimAngle-exported 3D Tiles datasets.","maintainers":[{"name":"bimangle.liu","email":"liuyongsheng@msn.com"}],"readme":"# cesium-info-accessor\r\n\r\nA Cesium plugin for automatically loading and displaying component property data from BimAngle-exported 3D Tiles datasets.\r\n\r\n## Installation\r\n\r\n### NPM\r\n\r\n```bash\r\nnpm install @bimangle/cesium-info-accessor\r\n```\r\n\r\n### CDN\r\n\r\n```html\r\n<!-- Cesium must be loaded first -->\r\n<script src=\"https://cesium.com/downloads/cesiumjs/releases/1.120/Build/Cesium/Cesium.js\"></script>\r\n\r\n<!-- Then include cesium-info-accessor -->\r\n<script src=\"https://unpkg.com/@bimangle/cesium-info-accessor/dist/cesium-info-accessor.js\"></script>\r\n```\r\n\r\n---\r\n\r\n## Quick Start\r\n\r\n```html\r\n<!DOCTYPE html>\r\n<html>\r\n<head>\r\n  <script src=\"https://cesium.com/downloads/cesiumjs/releases/1.120/Build/Cesium/Cesium.js\"></script>\r\n  <link href=\"https://cesium.com/downloads/cesiumjs/releases/1.120/Build/Cesium/Widgets/widgets.css\" rel=\"stylesheet\">\r\n  <script src=\"https://unpkg.com/@bimangle/cesium-info-accessor/dist/cesium-info-accessor.js\"></script>\r\n</head>\r\n<body>\r\n  <div id=\"cesiumContainer\" style=\"width:100%;height:100vh;\"></div>\r\n  <script type=\"module\">\r\n    const viewer = new Cesium.Viewer('cesiumContainer');\r\n\r\n    // Attach the plugin to the viewer (autoAttach: true by default)\r\n    viewer.extend(InfoAccessorMixin);\r\n\r\n    // Load a BimAngle 3D Tiles dataset\r\n    const tileset = await Cesium.Cesium3DTileset.fromUrl('./tileset.json');\r\n    viewer.scene.primitives.add(tileset);\r\n\r\n    // The plugin auto-detects BimAngle tilesets and enables pick-to-select.\r\n    // You can also attach manually:\r\n    viewer.infoAccessor.attach(tileset);\r\n  </script>\r\n</body>\r\n</html>\r\n```\r\n\r\n---\r\n\r\n## Features\r\n\r\n- **Auto-detect** BimAngle 3D Tiles datasets added to the scene\r\n- **Hover highlight** — move the mouse over a feature to highlight it\r\n- **Click to select** — left-click selects a feature and displays its properties in Cesium's info box\r\n- **Right-click to zoom** — right-click a feature to fly to its bounding sphere\r\n- **Parent-node selection** — selecting a group node colors all descendant features\r\n- **Public event** `selectionChanged` — subscribe to react when the selected feature changes (e.g. to drive a scene tree)\r\n- **Bilingual UI** — automatically uses Simplified Chinese or English based on `navigator.language`\r\n- Compatible with **Cesium ≥ 1.110.0**\r\n\r\n---\r\n\r\n## API Reference\r\n\r\n### `InfoAccessorMixin(viewer, options?)`\r\n\r\nMixin function to be called via `viewer.extend(InfoAccessorMixin, options)`.  \r\nAttaches `viewer.infoAccessor` (`InfoAccessor`) and `viewer.infoAccessorX` (`InfoAccessorX`) to the viewer.\r\n\r\n| Option | Type | Default | Description |\r\n|--------|------|---------|-------------|\r\n| `autoAttach` | `boolean` | `true` | Automatically attach any BimAngle tileset added to the scene |\r\n| `highlightColor` | `Cesium.Color` | `Cesium.Color.YELLOW` | Feature color on mouse hover |\r\n| `selectedColor` | `Cesium.Color` | `Cesium.Color.LIME` | Feature color when selected |\r\n\r\n---\r\n\r\n### `viewer.infoAccessor` — `InfoAccessor`\r\n\r\n#### Methods\r\n\r\n##### `attach(tileset) → boolean`\r\n\r\nManually register a tileset with the plugin.  \r\nReturns `true` if successfully attached, `false` if the argument is not a valid `Cesium3DTileset`.\r\n\r\n```javascript\r\nconst ok = viewer.infoAccessor.attach(tileset);\r\n```\r\n\r\n---\r\n\r\n##### `select(tileset, dbId, options?) → void`\r\n\r\nProgrammatically select a component by its `dbId`.  \r\nOpens the info box and applies the selection color to matching features.\r\n\r\n```javascript\r\nviewer.infoAccessor.select(tileset, dbId);\r\n\r\n// With options (e.g. from a scene tree)\r\nviewer.infoAccessor.select(tileset, dbId, {\r\n  feature:     cesiumFeature,   // direct Cesium3DTileFeature (leaf node)\r\n  repFeature:  anyDescFeature,  // representative feature for base-path derivation (group node)\r\n  descendants: [dbId1, dbId2],  // descendant dbIds for batch coloring (group node)\r\n  name:        'Column A-1',    // override info box title\r\n});\r\n```\r\n\r\n| Option | Type | Description |\r\n|--------|------|-------------|\r\n| `feature` | `Cesium3DTileFeature` | Anchor feature used for base-path and embedded-property derivation; coloring always applies to all registered features for `dbId` |\r\n| `repFeature` | `Cesium3DTileFeature` | A representative descendant feature used only for property path derivation (group node) |\r\n| `descendants` | `number[]` | List of descendant `dbId`s for batch color application when there are no direct features registered for `dbId` |\r\n| `name` | `string` | Override the info box title |\r\n\r\n---\r\n\r\n##### `clearSelection() → void`\r\n\r\nDeselect the current component and close the info box.  \r\nAlso fires `selectionChanged` with `{ tileset: null, dbId: -1 }`.\r\n\r\n```javascript\r\nviewer.infoAccessor.clearSelection();\r\n```\r\n\r\n---\r\n\r\n##### `highlight(tileset, dbId, options?) → void`\r\n\r\nProgrammatically apply the hover highlight color to a component.\r\n\r\n```javascript\r\nviewer.infoAccessor.highlight(tileset, dbId);\r\n\r\n// With descendant batch highlight\r\nviewer.infoAccessor.highlight(tileset, dbId, { descendants: [dbId1, dbId2] });\r\n```\r\n\r\n---\r\n\r\n##### `clearHighlight() → void`\r\n\r\nRemove the current hover highlight.\r\n\r\n```javascript\r\nviewer.infoAccessor.clearHighlight();\r\n```\r\n\r\n---\r\n\r\n##### `showProps(node) → void`\r\n\r\nRender a property table in the Cesium info box from a property data node object.\r\n\r\n```javascript\r\nviewer.infoAccessor.showProps(propsNode);\r\n```\r\n\r\n---\r\n\r\n##### `getTilesetBasePath(tileset) → string`\r\n\r\nDerive the base directory path from a tileset's URL (strips the trailing `/tileset.json` segment).\r\n\r\n```javascript\r\nconst basePath = viewer.infoAccessor.getTilesetBasePath(tileset);\r\n// e.g. \"https://example.com/data/model\"\r\n```\r\n\r\n---\r\n\r\n#### Properties (read-only)\r\n\r\n| Property | Type | Description |\r\n|----------|------|-------------|\r\n| `selectedDbId` | `number` | Currently selected component `dbId`, or `-1` if none |\r\n| `selectedTileset` | `Cesium.Cesium3DTileset \\| null` | The tileset owning the currently selected component |\r\n| `highlightedDbId` | `number` | Currently hovered `dbId`, or `-1` if none |\r\n| `highlightColor` | `Cesium.Color` | Hover highlight color (writable) |\r\n| `selectedColor` | `Cesium.Color` | Selection color (writable) |\r\n\r\n---\r\n\r\n#### Events\r\n\r\n##### `selectionChanged` — `Cesium.Event`\r\n\r\nFired whenever the selected component changes (including when selection is cleared).  \r\nListener receives `{ tileset, dbId }` where `dbId` is `-1` when cleared.\r\n\r\n```javascript\r\nviewer.infoAccessor.selectionChanged.addEventListener(({ tileset, dbId }) => {\r\n  if (dbId < 0) {\r\n    console.log('Selection cleared');\r\n  } else {\r\n    console.log('Selected dbId:', dbId, 'in tileset:', tileset);\r\n  }\r\n});\r\n```\r\n\r\nThis event is the recommended integration point for external plugins (such as `cesium-scene-tree`) that need to react to user picks without relying on internal state.\r\n\r\n---\r\n\r\n### `viewer.infoAccessorX` — `InfoAccessorX`\r\n\r\nProvides **model-level** (tileset-level) information display, as opposed to the component-level display of `InfoAccessor`.\r\n\r\n```javascript\r\n// Display model-level info when the tileset is clicked\r\nviewer.infoAccessorX.attachTilesetX(tileset, 'Project Title', 'Description text');\r\n```\r\n\r\n---\r\n\r\n## Integration with `cesium-scene-tree`\r\n\r\n`cesium-info-accessor` v2.0 is designed to work alongside [`cesium-scene-tree`](https://www.npmjs.com/package/@bimangle/cesium-scene-tree).  \r\nThe scene tree listens to `infoAccessor.selectionChanged` to highlight the corresponding tree node when a component is picked in the Cesium viewport.\r\n\r\n```javascript\r\n// Both plugins share the same viewer instance\r\nviewer.extend(InfoAccessorMixin, { autoAttach: true });\r\nviewer.extend(SceneTreeMixin,    { showInfoNodes: false });\r\n\r\n// No extra wiring needed — the scene tree subscribes to selectionChanged automatically.\r\n```\r\n\r\n---\r\n\r\n## Changelog\r\n\r\n### v2.0.1\r\n- Fixed a bug where clicking any geometry of a multi-geometry component only selected that single geometry instead of all geometries belonging to the same component. Selection coloring now applies to all registered features for the clicked `dbId`, consistent with hover-highlight behavior.\r\n\r\n### v2.0.0\r\n- **New public API**: `select()`, `clearSelection()`, `highlight()`, `clearHighlight()`, `showProps()`, `getTilesetBasePath()`\r\n- **New public event**: `selectionChanged` (`Cesium.Event`) — replaces the need to observe internal state\r\n- **New read-only getters**: `selectedDbId`, `selectedTileset`, `highlightedDbId`\r\n- `select()` no longer requires a direct `Cesium3DTileFeature`; supports group/parent nodes via `descendants` batch coloring\r\n- **Bilingual UI**: property table boolean values and loading text now follow `navigator.language` (Simplified Chinese / English)\r\n- Fixed `_unloadFeature` array index lookup\r\n\r\n### v1.0.1\r\n- Initial public release\r\n\r\n---\r\n\r\n## License\r\n\r\nMIT\r\n","readmeFilename":"README.md"}