**I am using potree in a project but now I want to put pointcloud on globe. **
I use cesium and render cesium and potree on same canvas but the problem I am facing is that when I use tileset from cesium It is laying behind potree’s objects like pointcloud.
See video of my issue https://youtu.be/Zvja1MRX9wQ
I want that objects of potree and cesium would be in same scene**
Here is how I use potree and cesium.**
I initialize both cesium in potree and remove all controls on Cesium
cviewer = new Cesium.Viewer('cesiumContainer', {
useDefaultRenderLoop: false,
animation: false,
baseLayerPicker : false,
fullscreenButton: false,
geocoder: false,
homeButton: false,
infoBox: false,
sceneModePicker: false,
selectionIndicator: false,
timeline: false,
navigationHelpButton: false,
imageryProvider : Cesium.createOpenStreetMapImageryProvider({url : 'http://a.tile.openstreetmap.org/'}),
terrainShadows: Cesium.ShadowMode.DISABLED,
});
viewer = new Potree.Viewer(document.getElementById("potree_render_area"),"");
``
Call Cesium render function inside Potree render function
render(){
cviewer.render();
……
}
``
I modified initThree() function remove line that add potree’s canvas in potree render area
// this.renderArea.appendChild(this.renderer.domElement);
``
and add cesium canvas in Three.WebGl Render
this.renderer = new THREE.WebGLRenderer({alpha : true,preserveDrawingBuffer: true , canvas : cviewer.canvas});
``
And also added the following lines as I see this on https://github.com/AnalyticalGraphicsInc/cesium/issues/648
var resetFunc = this.renderer.state.reset;
this.renderer.state.reset = function(){};
this.renderer.resetGLState();
this.renderer.state.reset = resetFunc;
``
I remove all events of Cesium except rotate because I want potree’s events only. And to stop collusion of some of the same events from both sides.
cviewer.scene.screenSpaceCameraController.enableTranslate = false;
cviewer.scene.screenSpaceCameraController.enableZoom = false;
cviewer.scene.screenSpaceCameraController.enableTilt = false;
cviewer.scene.screenSpaceCameraController.enableLook = false;
``
Identified pointdown event handler of Cesium from debugger and remove it. Because it stops orbit controls in potree.
function p(e, t, i, r) {
// function n(t) {
// r(e, t)
// }
i.addEventListener(t, n, !1), e._removalFunctions.push(function() {
i.removeEventListener(t, n, !1)
})
``