Skip to content

Commit

Permalink
Merge pull request #10126 from CesiumGS/enable-draco-quantization
Browse files Browse the repository at this point in the history
Re-enable draco quantization
  • Loading branch information
lilleyse authored Feb 22, 2022
2 parents ff34e0c + c497cdb commit ef4293b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 41 deletions.
48 changes: 8 additions & 40 deletions Source/WorkersES6/decodeDraco.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,17 +288,7 @@ function decodePrimitive(parameters) {
const dracoDecoder = new draco.Decoder();

// Skip all parameter types except generic
// Note: As a temporary work-around until GetAttributeByUniqueId() works after
// calling SkipAttributeTransform(), we will not skip attributes with multiple
// sets of data in the glTF.
const attributesToSkip = ["POSITION", "NORMAL"];
const compressedAttributes = parameters.compressedAttributes;
if (!defined(compressedAttributes["COLOR_1"])) {
attributesToSkip.push("COLOR");
}
if (!defined(compressedAttributes["TEXCOORD_1"])) {
attributesToSkip.push("TEX_COORD");
}
const attributesToSkip = ["POSITION", "NORMAL", "COLOR", "TEX_COORD"];
if (parameters.dequantizeInShader) {
for (let i = 0; i < attributesToSkip.length; ++i) {
dracoDecoder.SkipAttributeTransform(draco[attributesToSkip[i]]);
Expand All @@ -325,37 +315,15 @@ function decodePrimitive(parameters) {
draco.destroy(buffer);

const attributeData = {};

const compressedAttributes = parameters.compressedAttributes;
for (const attributeName in compressedAttributes) {
if (compressedAttributes.hasOwnProperty(attributeName)) {
// Since GetAttributeByUniqueId() only works on attributes that we have not called
// SkipAttributeTransform() on, we must first store a `dracoAttributeName` in case
// we call GetAttributeId() instead.
let dracoAttributeName = attributeName;
if (attributeName === "TEXCOORD_0") {
dracoAttributeName = "TEX_COORD";
}
if (attributeName === "COLOR_0") {
dracoAttributeName = "COLOR";
}

let dracoAttribute;
if (attributesToSkip.includes(dracoAttributeName)) {
const dracoAttributeId = dracoDecoder.GetAttributeId(
dracoGeometry,
draco[dracoAttributeName]
);
dracoAttribute = dracoDecoder.GetAttribute(
dracoGeometry,
dracoAttributeId
);
} else {
const compressedAttribute = compressedAttributes[attributeName];
dracoAttribute = dracoDecoder.GetAttributeByUniqueId(
dracoGeometry,
compressedAttribute
);
}

const compressedAttribute = compressedAttributes[attributeName];
const dracoAttribute = dracoDecoder.GetAttributeByUniqueId(
dracoGeometry,
compressedAttribute
);
attributeData[attributeName] = decodeAttribute(
dracoGeometry,
dracoDecoder,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"cloc": "^2.8.0",
"compression": "^1.7.4",
"dompurify": "^2.2.2",
"draco3d": "^1.4.1",
"draco3d": "^1.5.1",
"earcut": "^2.2.2",
"eslint": "^7.29.0",
"eslint-config-prettier": "^8.3.0",
Expand Down

0 comments on commit ef4293b

Please sign in to comment.