Permalink
Browse files

Add a CesiumContents component to render many billboards

  • Loading branch information...
markerikson committed Feb 25, 2017
1 parent 6776f54 commit 02077028997db9f3248bc9d1256762ccd729da5b
Showing with 55 additions and 0 deletions.
  1. +55 −0 src/cesium/CesiumProjectContents.jsx
@@ -0,0 +1,55 @@
+import React, {Component} from "react";
+
+import BillboardCollection from "cesium/Source/Scene/BillboardCollection";
+
+import CesiumBillboard from "./primitives/CesiumBillboard";
+
+export class CesiumProjectContents extends Component {
+ constructor(props) {
+ super(props);
+
+ this.billboards = new BillboardCollection();
+
+ const {scene} = props;
+
+ if(scene) {
+ scene.primitives.add(this.billboards);
+ }
+ }
+
+ componentWillUnmount() {
+ const {billboards} = this;
+
+ if(!billboards.isDestroyed()) {
+ billboards.destroy();
+ }
+
+ const {scene} = this.props;
+
+ if(scene && !scene.isDestroyed() && scene.primitives) {
+ scene.primitives.remove(billboards);
+ }
+ }
+
+ render() {
+ const {icons = []} = this.props;
+
+ const renderedBillboards = icons.map( (icon, index) =>
+ <CesiumBillboard
+ {...icon}
+ billboards={this.billboards}
+ key={index}
+ />
+ );
+
+
+ return (
+ <span>
+ {renderedBillboards}
+ </span>
+ );
+ }
+}
+
+
+export default CesiumProjectContents;

0 comments on commit 0207702

Please sign in to comment.