Comparing version 0.0.4 to 0.0.5
@@ -6,2 +6,3 @@ import React from "react"; | ||
scene: Cesium.Scene; | ||
camera: Cesium.Camera | null; | ||
entities: Cesium.EntityCollection; | ||
@@ -8,0 +9,0 @@ screenSpaceEventHandler: Cesium.ScreenSpaceEventHandler; |
@@ -1,2 +0,2 @@ | ||
import { Viewer, Entity, Camera, CameraSetView, CameraFlyTo, CameraFlyHome, ScreenSpaceEvent } from "./views"; | ||
export { Viewer, Entity, Camera, CameraSetView, CameraFlyTo, CameraFlyHome, ScreenSpaceEvent }; | ||
import { Viewer, Scene, Camera, CameraSetView, CameraFlyTo, CameraFlyHome, ScreenSpaceEvent, Entity } from "./views"; | ||
export { Viewer, Scene, Camera, CameraSetView, CameraFlyTo, CameraFlyHome, ScreenSpaceEvent, Entity }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ScreenSpaceEvent = exports.CameraFlyHome = exports.CameraFlyTo = exports.CameraSetView = exports.Camera = exports.Entity = exports.Viewer = void 0; | ||
exports.Entity = exports.ScreenSpaceEvent = exports.CameraFlyHome = exports.CameraFlyTo = exports.CameraSetView = exports.Camera = exports.Scene = exports.Viewer = void 0; | ||
const views_1 = require("./views"); | ||
Object.defineProperty(exports, "Viewer", { enumerable: true, get: function () { return views_1.Viewer; } }); | ||
Object.defineProperty(exports, "Entity", { enumerable: true, get: function () { return views_1.Entity; } }); | ||
Object.defineProperty(exports, "Scene", { enumerable: true, get: function () { return views_1.Scene; } }); | ||
Object.defineProperty(exports, "Camera", { enumerable: true, get: function () { return views_1.Camera; } }); | ||
@@ -12,2 +12,3 @@ Object.defineProperty(exports, "CameraSetView", { enumerable: true, get: function () { return views_1.CameraSetView; } }); | ||
Object.defineProperty(exports, "ScreenSpaceEvent", { enumerable: true, get: function () { return views_1.ScreenSpaceEvent; } }); | ||
Object.defineProperty(exports, "Entity", { enumerable: true, get: function () { return views_1.Entity; } }); | ||
//# sourceMappingURL=index.js.map |
import * as Cesium from "cesium"; | ||
export declare const wrapListener: (event: Cesium.Event, listener: (...params: any[]) => any, scope?: any) => () => void; | ||
export declare const getRestProps: (props: any, keys: string[]) => any; | ||
@@ -3,0 +4,0 @@ export declare const getViewer: (id: string) => Cesium.Viewer | null; |
@@ -22,5 +22,12 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.destroyViewer = exports.createViewer = exports.getViewer = exports.getRestProps = void 0; | ||
exports.destroyViewer = exports.createViewer = exports.getViewer = exports.getRestProps = exports.wrapListener = void 0; | ||
const Cesium = __importStar(require("cesium")); | ||
const viewers = {}; | ||
const wrapListener = (event, listener, scope) => { | ||
event.addEventListener(listener, scope); | ||
return () => { | ||
event.removeEventListener(listener, scope); | ||
}; | ||
}; | ||
exports.wrapListener = wrapListener; | ||
const getRestProps = (props, keys) => { | ||
@@ -27,0 +34,0 @@ return Object.keys(props).reduce((rest, key) => { |
@@ -24,8 +24,8 @@ "use strict"; | ||
const { created } = this.state; | ||
if (context && !created) { | ||
if (!created && context && context.camera) { | ||
if (onChange) { | ||
context.scene.camera.changed.addEventListener(onChange, "camera"); | ||
context.camera.changed.addEventListener(onChange, "camera"); | ||
} | ||
if (onMoveEnd) { | ||
context.scene.camera.moveEnd.addEventListener(onMoveEnd, "camera"); | ||
context.camera.moveEnd.addEventListener(onMoveEnd, "camera"); | ||
} | ||
@@ -39,9 +39,8 @@ this.setState({ | ||
const { context, onChange, onMoveEnd } = this.props; | ||
// @ts-ignore | ||
if (context && context.scene && context.scene._view) { | ||
if (context && context.camera) { | ||
if (onChange) { | ||
context.scene.camera.changed.removeEventListener(onChange, "camera"); | ||
context.camera.changed.removeEventListener(onChange, "camera"); | ||
} | ||
if (onMoveEnd) { | ||
context.scene.camera.moveEnd.removeEventListener(onMoveEnd, "camera"); | ||
context.camera.moveEnd.removeEventListener(onMoveEnd, "camera"); | ||
} | ||
@@ -48,0 +47,0 @@ } |
import Viewer from "./Viewer"; | ||
import Entity from "./Entity"; | ||
import Scene from "./Scene"; | ||
import Camera from "./Camera"; | ||
@@ -8,2 +8,3 @@ import CameraSetView from "./CameraSetView"; | ||
import ScreenSpaceEvent from "./ScreenSpaceEvent"; | ||
export { Viewer, Entity, Camera, CameraSetView, CameraFlyTo, CameraFlyHome, ScreenSpaceEvent }; | ||
import Entity from "./Entity"; | ||
export { Viewer, Scene, Camera, CameraSetView, CameraFlyTo, CameraFlyHome, ScreenSpaceEvent, Entity }; |
@@ -6,7 +6,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ScreenSpaceEvent = exports.CameraFlyHome = exports.CameraFlyTo = exports.CameraSetView = exports.Camera = exports.Entity = exports.Viewer = void 0; | ||
exports.Entity = exports.ScreenSpaceEvent = exports.CameraFlyHome = exports.CameraFlyTo = exports.CameraSetView = exports.Camera = exports.Scene = exports.Viewer = void 0; | ||
const Viewer_1 = __importDefault(require("./Viewer")); | ||
exports.Viewer = Viewer_1.default; | ||
const Entity_1 = __importDefault(require("./Entity")); | ||
exports.Entity = Entity_1.default; | ||
const Scene_1 = __importDefault(require("./Scene")); | ||
exports.Scene = Scene_1.default; | ||
const Camera_1 = __importDefault(require("./Camera")); | ||
@@ -22,2 +22,4 @@ exports.Camera = Camera_1.default; | ||
exports.ScreenSpaceEvent = ScreenSpaceEvent_1.default; | ||
const Entity_1 = __importDefault(require("./Entity")); | ||
exports.Entity = Entity_1.default; | ||
//# sourceMappingURL=index.js.map |
@@ -11,2 +11,5 @@ import React from "react"; | ||
viewer: Cesium.Viewer | null; | ||
_postUpdateHandler: () => void; | ||
get scene(): Cesium.Scene | null; | ||
get camera(): Cesium.Camera | null; | ||
constructor(props: Props); | ||
@@ -19,4 +22,5 @@ componentDidMount(): void; | ||
destroy(): void; | ||
onPostUpdate(): void; | ||
render(): JSX.Element; | ||
} | ||
export default Viewer; |
@@ -13,7 +13,22 @@ "use strict"; | ||
this.viewer = null; | ||
this._postUpdateHandler = () => this.onPostUpdate(); | ||
this.state = { | ||
id: "viewer-id-" + (Viewer.COUNT++), | ||
created: false | ||
created: false, | ||
rendered: false | ||
}; | ||
} | ||
get scene() { | ||
if (this.viewer) { | ||
return this.viewer.scene; | ||
} | ||
return null; | ||
} | ||
get camera() { | ||
// @ts-ignore | ||
if (this.scene && this.scene._view && this.scene.camera) { | ||
return this.scene.camera; | ||
} | ||
return null; | ||
} | ||
componentDidMount() { | ||
@@ -32,2 +47,5 @@ this.create(); | ||
this.viewer = tools_1.createViewer(id, options); | ||
if (this.scene) { | ||
this.scene.postRender.addEventListener(this._postUpdateHandler, "viewer"); | ||
} | ||
} | ||
@@ -39,4 +57,15 @@ update() { | ||
const { id } = this.state; | ||
if (this.scene) { | ||
this.scene.postUpdate.removeEventListener(this._postUpdateHandler, "viewer"); | ||
} | ||
tools_1.destroyViewer(id); | ||
} | ||
onPostUpdate() { | ||
this.setState({ | ||
rendered: true | ||
}); | ||
if (this.scene) { | ||
this.scene.postRender.removeEventListener(this._postUpdateHandler, "viewer"); | ||
} | ||
} | ||
render() { | ||
@@ -49,2 +78,3 @@ const { className, children } = this.props; | ||
scene: viewer.scene, | ||
camera: this.camera, | ||
entities: viewer.dataSourceDisplay.defaultDataSource.entities, | ||
@@ -51,0 +81,0 @@ screenSpaceEventHandler: viewer.screenSpaceEventHandler |
{ | ||
"name": "rcesium", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "author": "Kris Papercut <kearis666@gmail.com>", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
41573
38
758