Skip to content

Commit

Permalink
update to latest electron, potree, and potreeConverter
Browse files Browse the repository at this point in the history
  • Loading branch information
m-schuetz committed Nov 29, 2022
1 parent 41a0c5d commit 9849498
Show file tree
Hide file tree
Showing 14 changed files with 470 additions and 3,967 deletions.
Binary file modified libs/PotreeConverter2/PotreeConverter.exe
Binary file not shown.
Binary file modified libs/PotreeConverter2/laszip.dll
Binary file not shown.
239 changes: 224 additions & 15 deletions libs/potree/potree.js
Original file line number Diff line number Diff line change
Expand Up @@ -56826,7 +56826,7 @@
this.projection = info.srs.authority + ':' + info.srs.horizontal;
}

if (info.srs.wkt) {
if (info.srs && info.srs.wkt) {
if (!this.projection) this.projection = info.srs.wkt;
else this.fallbackProjection = info.srs.wkt;
}
Expand Down Expand Up @@ -57766,11 +57766,9 @@ float getLOD(){
// no more visible child nodes at this position
//return value.a * 255.0;

// float lodOffset = (255.0 * value.a) / 10.0 - 10.0;
float lodOffset = (255.0 * value.a) / 10.0 - 10.0;

// return depth + lodOffset;

return depth;
return depth + lodOffset;
}

offset = offset + (vec3(1.0, 1.0, 1.0) * nodeSizeAtLevel * 0.5) * index3d;
Expand Down Expand Up @@ -72447,6 +72445,184 @@ void main() {

}

/**
*
* @author roy.mdr / http://...
*
*/

class DXFProfileExporter {

static toXYZ(points, flatten = false) {

/*
points: {
...
data: {
mileage: [0, 1, 2...], -> one per point
position: [0, 0, 0, 1, 1, 1, 2, 2, 2...], -> X, Y, Z
rgba: [0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2...] -> R, G, B, A
},
numPoints: Int
}
*/

const pointsXYZ = {
x: [],
y: [],
z: [],
minX: Number.MAX_VALUE,
minY: Number.MAX_VALUE,
minZ: Number.MAX_VALUE,
maxX: -Number.MAX_VALUE,
maxY: -Number.MAX_VALUE,
maxZ: -Number.MAX_VALUE,
numPoints: 0
};

const pData = points.data;
const pMileage = pData.mileage;
const pCoords = pData.position;
const pColor = pData.rgba;

for (let pIx = 0; pIx < points.numPoints; pIx++) {

const poMileage = pMileage[pIx];
const poCoordX = pCoords[ ((pIx * 3) + 0) ];
const poCoordY = pCoords[ ((pIx * 3) + 1) ];
const poCoordZ = pCoords[ ((pIx * 3) + 2) ];
// const poColorR = pColor[ ((pIx * 4) + 0) ];
// const poColorG = pColor[ ((pIx * 4) + 1) ];
// const poColorB = pColor[ ((pIx * 4) + 2) ];
// const poColorA = pColor[ ((pIx * 4) + 3) ];

if (flatten === true) {

pointsXYZ.x.push(poMileage);
pointsXYZ.y.push(0);
pointsXYZ.z.push(poCoordZ);

// Get boundaries X
if (pointsXYZ.maxX < poMileage) pointsXYZ.maxX = poMileage;
if (pointsXYZ.minX > poMileage) pointsXYZ.minX = poMileage;

// Get boundaries Z
if (pointsXYZ.maxZ < poCoordZ) pointsXYZ.maxZ = poCoordZ;
if (pointsXYZ.minZ > poCoordZ) pointsXYZ.minZ = poCoordZ;

} else {

pointsXYZ.x.push(poCoordX);
pointsXYZ.y.push(poCoordY);
pointsXYZ.z.push(poCoordZ);

// Get boundaries X
if (pointsXYZ.maxX < poCoordX) pointsXYZ.maxX = poCoordX;
if (pointsXYZ.minX > poCoordX) pointsXYZ.minX = poCoordX;

// Get boundaries Y
if (pointsXYZ.maxY < poCoordY) pointsXYZ.maxY = poCoordY;
if (pointsXYZ.minY > poCoordY) pointsXYZ.minY = poCoordY;

// Get boundaries Z
if (pointsXYZ.maxZ < poCoordZ) pointsXYZ.maxZ = poCoordZ;
if (pointsXYZ.minZ > poCoordZ) pointsXYZ.minZ = poCoordZ;

}

}

if (flatten === true) {
// Set boundaries Y
pointsXYZ.maxY = 0;
pointsXYZ.minY = 0;
}

pointsXYZ.numPoints = points.numPoints;

return pointsXYZ;
}

static plotPCloudPoint(x, y, z) {

const dxfSection = `0
POINT
8
layer_pointCloud
10
${x}
20
${y}
30
${z}
`;

return dxfSection;
}

static toString(points, flatten = false) {

const pCloud = DXFProfileExporter.toXYZ(points, flatten);

const dxfHeader = `999
DXF created from potree
0
SECTION
2
HEADER
9
$ACADVER
1
AC1006
9
$INSBASE
10
0.0
20
0.0
30
0.0
9
$EXTMIN
10
${pCloud.minX}
20
${pCloud.minY}
30
${pCloud.minZ}
9
$EXTMAX
10
${pCloud.maxX}
20
${pCloud.maxY}
30
${pCloud.maxZ}
0
ENDSEC
`;

let dxfBody = `0
SECTION
2
ENTITIES
`;

for (let i = 0; i < pCloud.numPoints; i++) {
dxfBody += DXFProfileExporter.plotPCloudPoint(pCloud.x[i], pCloud.y[i], pCloud.z[i]);
}

dxfBody += `0
ENDSEC
`;

const dxf = dxfHeader + dxfBody + '0\nEOF';

return dxf;
}

}

class CSVExporter {
static toString (points) {
let string = '';
Expand Down Expand Up @@ -72629,8 +72805,8 @@ void main() {
view.setUint16(boffset + 18, points.data.pointSourceID[i]);
}

if (points.data.rgba) {
let rgba = points.data.rgba;
if (points.data.rgba || points.data.color) {
let rgba = points.data.rgba ?? points.data.color;
view.setUint16(boffset + 20, (rgba[4 * i + 0] * 255), true);
view.setUint16(boffset + 22, (rgba[4 * i + 1] * 255), true);
view.setUint16(boffset + 24, (rgba[4 * i + 2] * 255), true);
Expand Down Expand Up @@ -72895,6 +73071,12 @@ void main() {
let backwardIcon = `${exports.resourcePath}/icons/arrow_down.svg`;
$('#potree_profile_move_backward').attr('src', backwardIcon);

let dxf2DIcon = `${exports.resourcePath}/icons/file_dxf_2d.svg`;
$('#potree_download_dxf2D_icon').attr('src', dxf2DIcon);

let dxf3DIcon = `${exports.resourcePath}/icons/file_dxf_3d.svg`;
$('#potree_download_dxf3D_icon').attr('src', dxf3DIcon);

let csvIcon = `${exports.resourcePath}/icons/file_csv_2d.svg`;
$('#potree_download_csv_icon').attr('src', csvIcon);

Expand Down Expand Up @@ -73111,19 +73293,25 @@ void main() {
this.hide();
});

let getProfilePoints = () => {
let getProfilePoints = (truePosition) => {
let points = new Points$1();

for(let [pointcloud, entry] of this.pointclouds){
for(let pointSet of entry.points){

let originPos = pointSet.data.position;
let trueElevationPosition = new Float32Array(originPos);
let truePointPosition = new Float64Array(originPos);
for(let i = 0; i < pointSet.numPoints; i++){
trueElevationPosition[3 * i + 2] += pointcloud.position.z;

if (truePosition === true) {
truePointPosition[3 * i + 0] += pointcloud.position.x;
truePointPosition[3 * i + 1] += pointcloud.position.y;
}

truePointPosition[3 * i + 2] += pointcloud.position.z;
}

pointSet.data.position = trueElevationPosition;
pointSet.data.position = truePointPosition;
points.add(pointSet);
pointSet.data.position = originPos;
}
Expand All @@ -73132,9 +73320,29 @@ void main() {
return points;
};

$('#potree_download_dxf2D_icon').click(() => {

const points = getProfilePoints();

const string = DXFProfileExporter.toString(points, true);

const blob = new Blob([string], {type: "text/string"});
$('#potree_download_profile_dxf2D_link').attr('href', URL.createObjectURL(blob));
});

$('#potree_download_dxf3D_icon').click(() => {

const points = getProfilePoints(true);

const string = DXFProfileExporter.toString(points);

const blob = new Blob([string], {type: "text/string"});
$('#potree_download_profile_dxf3D_link').attr('href', URL.createObjectURL(blob));
});

$('#potree_download_csv_icon').click(() => {

let points = getProfilePoints();
let points = getProfilePoints(true);

let string = CSVExporter.toString(points);

Expand All @@ -73144,7 +73352,7 @@ void main() {

$('#potree_download_las_icon').click(() => {

let points = getProfilePoints();
let points = getProfilePoints(true);

let buffer = LASExporter.toLAS(points);

Expand Down Expand Up @@ -80233,7 +80441,8 @@ ENDSEC
["JP", "jp"],
["ES", "es"],
["SE", "se"],
["ZH", "zh"]
["ZH", "zh"],
["IT", "it"]
];

let elLanguages = $('#potree_languages');
Expand Down Expand Up @@ -89025,7 +89234,7 @@ ENDSEC
i18n.init({
lng: 'en',
resGetPath: Potree.resourcePath + '/lang/__lng__/__ns__.json',
preload: ['en', 'fr', 'de', 'jp', 'se', 'es', 'zh'],
preload: ['en', 'fr', 'de', 'jp', 'se', 'es', 'zh', 'it'],
getAsync: true,
debug: false
}, function (t) {
Expand Down
2 changes: 1 addition & 1 deletion libs/potree/potree.js.map

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions libs/potree/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@
<img id="potree_profile_move_forward" class="text-icon"/>
<img id="potree_profile_move_backward" class="text-icon"/>

<a id="potree_download_profile_dxf2D_link" href="#" download="profile_2D.dxf">
<img id="potree_download_dxf2D_icon" class="text-icon"/>
</a>

<a id="potree_download_profile_dxf3D_link" href="#" download="profile_3D.dxf">
<img id="potree_download_dxf3D_icon" class="text-icon"/>
</a>

<a id="potree_download_profile_ortho_link" href="#" download="profile.csv">
<img id="potree_download_csv_icon" class="text-icon"/>
</a>
Expand Down
Loading

0 comments on commit 9849498

Please sign in to comment.