Skip to content

Commit

Permalink
Added physically-based rendering mode for PerformanceModel #569
Browse files Browse the repository at this point in the history
  • Loading branch information
xeolabs committed Mar 12, 2021
1 parent 5d9a34f commit 37e17d4
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/plugins/XKTLoaderPlugin/parsers/ParserV7.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function extract(elements) {

eachMeshGeometriesPortion: elements[13],
eachMeshMatricesPortion: elements[14],
eachMeshColorAndOpacity: elements[15],
eachMeshMaterial: elements[15],

// Entity elements in the following arrays are grouped in runs that are shared by the same tiles

Expand Down Expand Up @@ -83,7 +83,7 @@ function inflate(deflatedData) {

eachMeshGeometriesPortion: new Uint32Array(pako.inflate(deflatedData.eachMeshGeometriesPortion).buffer),
eachMeshMatricesPortion: new Uint32Array(pako.inflate(deflatedData.eachMeshMatricesPortion).buffer),
eachMeshColorAndOpacity: new Uint8Array(pako.inflate(deflatedData.eachMeshColorAndOpacity).buffer),
eachMeshMaterial: new Uint8Array(pako.inflate(deflatedData.eachMeshMaterial).buffer),

eachEntityId: pako.inflate(deflatedData.eachEntityId, {to: 'string'}),
eachEntityMeshesPortion: new Uint32Array(pako.inflate(deflatedData.eachEntityMeshesPortion).buffer),
Expand Down Expand Up @@ -125,7 +125,7 @@ function load(viewer, options, inflatedData, performanceModel) {

const eachMeshGeometriesPortion = inflatedData.eachMeshGeometriesPortion;
const eachMeshMatricesPortion = inflatedData.eachMeshMatricesPortion;
const eachMeshColorAndOpacity = inflatedData.eachMeshColorAndOpacity;
const eachMeshMaterial = inflatedData.eachMeshMaterial;

const eachEntityId = JSON.parse(inflatedData.eachEntityId);
const eachEntityMeshesPortion = inflatedData.eachEntityMeshesPortion;
Expand Down Expand Up @@ -248,8 +248,10 @@ function load(viewer, options, inflatedData, performanceModel) {

const atLastGeometry = (geometryIndex === (numGeometries - 1));

const meshColor = decompressColor(eachMeshColorAndOpacity.subarray((meshIndex * 4), (meshIndex * 4) + 3));
const meshOpacity = eachMeshColorAndOpacity[(meshIndex * 4) + 3] / 255.0;
const meshColor = decompressColor(eachMeshMaterial.subarray((meshIndex * 6), (meshIndex * 6) + 3));
const meshOpacity = eachMeshMaterial[(meshIndex * 6) + 3] / 255.0;
const meshMetallic = eachMeshMaterial[(meshIndex * 6) + 4] / 255.0;
const meshRoughness = eachMeshMaterial[(meshIndex * 6) + 5] / 255.0;

const meshId = nextMeshId++;

Expand Down Expand Up @@ -322,6 +324,8 @@ function load(viewer, options, inflatedData, performanceModel) {
geometryId: geometryId,
matrix: meshMatrix,
color: meshColor,
metallic: meshMetallic,
roughness: meshRoughness,
opacity: meshOpacity
}));

Expand Down Expand Up @@ -378,6 +382,8 @@ function load(viewer, options, inflatedData, performanceModel) {
edgeIndices: geometryEdgeIndices,
positionsDecodeMatrix: tileDecodeMatrix,
color: meshColor,
metallic: meshMetallic,
roughness: meshRoughness,
opacity: meshOpacity
}));

Expand Down

0 comments on commit 37e17d4

Please sign in to comment.