-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
From single sided to double sided materials #2
Comments
Support for implicit tileset traversal (and metadata handling)
The If the goal was to integrate this functionality in the 3d-tiles-tools, we'd have to think about how exactly it should be offered. It could be one operation, similar to the current I'm slightly leaning towards closing this issue, but maybe one ("important") question before doing so: Was the intention to apply this to B3DM/I3DM files? (For the latter, it may be easier and more reasonable to just batch-process them with one of the existing glTF libraries that may be used for this sort of operation...) |
As mentioned in the previous comment, operations on the glTF are not the main focus of the Some of the functionality that could be useful here is that of the For example, for a given input tileset with GLB tile content, this would convert all materials in all tiles to be double sided: import { NodeIO } from "@gltf-transform/core";
import { TileContentProcessing } from "./src/tilesetProcessing/TileContentProcessing";
import { TileContentProcessor } from "./src/tilesetProcessing/TileContentProcessor";
import { ContentDataTypes } from "./src/contentTypes/ContentDataTypes";
async function runExample() {
const tilesetSourceName = "./input/tileset.json";
const tilesetTargetName = "./output/tileset.json";
const overwrite = true;
// Create the TileContentProcessor that will be
// applied to each tile content
const io = new NodeIO();
const tileContentProcessor: TileContentProcessor = async (
content: Buffer,
type: string | undefined
): Promise<Buffer> => {
// Ignore everything except for GLB
if (type !== ContentDataTypes.CONTENT_TYPE_GLB) {
return content;
}
// Read the glTF-Transform document of the content
const document = await io.readBinary(content);
const root = document.getRoot();
// Go through all materials and set them to be double sided
const materials = root.listMaterials();
for (const material of materials) {
console.log("Material " + material.getDoubleSided());
material.setDoubleSided(true);
}
// Return a buffer that was created from the modified document
const modifiedContent = await io.writeBinary(document);
return Buffer.from(modifiedContent);
};
// Process the tileset source, and write it to the tileset target,
// applying the `TileContentProcessor` to all tile contents
await TileContentProcessing.process(
tilesetSourceName,
tilesetTargetName,
overwrite,
tileContentProcessor
);
}
runExample(); Given that this issue was opened 4 years ago, I assume that it is ... actually "obsolete", but hope that it is OK to close it with the hint: Yes, things like this are now possible with relatively little effort. |
Is it possible to add/adjust code for single sided materials to become double sided?
The text was updated successfully, but these errors were encountered: