tentone / potree-core

Potree point cloud viewer library core components for easier integration in a three.js project.
https://tentone.github.io/potree-core/
Other
171 stars 53 forks source link

original position lost? #23

Open ua4192 opened 1 year ago

ua4192 commented 1 year ago

Hi

I am using CloudCompare and Potree.exe in order to load multiple ply files into one LAS file and then convert it to potree format.

I have made a small modification on the fragment shader in order to be able to gpu pick the positions using vPosition that in the github files is only on the fragment shader and not in the vertex

basicallyI set in the vertexShader vPosition = position and gl_FragColor = vPosition on the fragmentShader.

I get the coordinates but they are displaced. I guess it is related to point organization?

The script I am using to convert files is this:

rem set OPENSSL_CONF=
set PATH=E:\AIRMOV3D\Sotfware\devel\CloudCompare_v2.12.alpha_bin_x64;E:\AIRMOV3D\Sotfware\Devel\PotreeConverter_2.0_windows_x64;%PATH%
rem echo *********************************************************************************
rem echo * start of ply2nxz.bat
rem echo * start of %0 %1 %2 %3 %4
rem echo *********************************************************************************
set cmdFolder=E:\AIRMOV3D\Code\Devel\cmd\
set inFolder=%1
set outFolder=%2
set format=%3
set format2=LAS
set base=%~n2
echo infile: %inFile%
echo outFolder: %outFolder%
echo base: %base%
echo format: %format%

echo "Step 1 --> convert to LAS"
rem call CloudCompare.exe -SILENT -O %inFolder%\%inFile% -AUTO_SAVE OFF -C_EXPORT_FMT %format2% -SAVE_CLOUDS FILE %outFolder%\%base%.%format%

rem SETLOCAL EnableDelayedExpansion
cd /D %inFolder%
set _filelist=
for /f "delims=|" %%f in ('dir /b "*.ply"') do (
    set "_filelist=!_filelist! -O %%f"
)
set _filelist=%_filelist:,,=%
echo %_filelist% > filelist.txt
call CloudCompare.exe -silent %_filelist% -LOG_FILE .\log.txt -AUTO_SAVE off -MERGE_CLOUDS -C_EXPORT_FMT %format2% -SAVE_CLOUDS FILE %outFolder%\A400M.%format%

cd /D %cmdFolder%

rem PotreeConverter.exe %outFolder%\%base%.%format% -o %outFolder% --overwrite --output-format %format%

echo "Step 2 --> convert to POTREE"
:wait
if not exist "%outFolder%\A400M.%format%" (
    echo "waiting..."
    timeout /t 1 /nobreak > nul
    goto wait
)

rem DIR "%outFolder%\%base%.%format%"
echo PotreeConverter.exe %outFolder%\A400M.%format% -o %outFolder% --overwrite -p myHomePage
call E:\AIRMOV3D\Sotfware\Devel\PotreeConverter_2.0_windows_x64\PotreeConverter.exe %outFolder%\A400M.%format% -o %outFolder% 

echo "End"

Is there any way to get the original coordinates when gpu picking?

Here the function I use to gpupick

function readMousePixels() {
                    renderer.render( scene, camera)
                    var fb = gl.createFramebuffer();
                    renderer.setRenderTarget(null);
                    if (mouseRenderTarget === undefined) {
                        mouseRenderTarget = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, { autoClear: true, minFilter: THREE.LinearFilter, magFilter: THREE.NearestFilter, format: THREE.RGBAFormat, type: THREE.FloatType } );
                    }
                    if (read === undefined) {
                        read = new Float32Array(4);
                    }

                    renderer.setRenderTarget(mouseRenderTarget);
                    renderer.render( scene, camera);
                    renderer.setRenderTarget(null);
                    renderer.readRenderTargetPixels( mouseRenderTarget, mouse.x, mouseRenderTarget.height - mouse.y, 1, 1, read );
                    console.log("pick: ", read);
                    renderer.setRenderTarget(null);

                    if (read[0] + read[1] + read[2] + read[3] !== 0 && read[0] * read[1] * read[2] * read[3] !== 0) {
                        console.log(read);
                        controls.target.set(read[0]  , read[1], read[2] )
                        controls.update();
                    }

                    renderer.render( scene, camera)
                    return read;
                }

Best regards

ua4192 commented 1 year ago

Hi.

Is there anybody who has faced this problem with potree?

I need to get the original coordinates when reading from pixels.

Best regards

tentone commented 1 year ago

Hello

You want the original coordinates before any transformation correct?

What you can do is to raycast the scene and you will get both the position in world coordinates as well as the geometry data containing the raw point data.

Mind that after conversion point data might suffer some changes (rounding & quantization).