@shapediver/sdk.sdtf-v1
Version:
Official sdTF SDK for TypeScript
50 lines • 1.96 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.writeableComponentListFromAsset = writeableComponentListFromAsset;
function writeableComponentListFromAsset(asset) {
const addToList = (component, array) => {
if (!component)
return;
if (array.findIndex((c) => c.componentId === component.componentId) === -1)
array.push(component);
};
const list = {
accessors: [],
asset: asset,
attributes: [],
buffers: [],
bufferViews: [],
chunks: asset.chunks,
items: [],
nodes: [],
typeHints: [],
fileInfo: asset.fileInfo,
};
list.chunks.forEach((chunk) => {
addToList(chunk.attributes, list.attributes);
chunk.items.forEach((item) => addToList(item, list.items));
chunk.nodes.forEach((node) => addToList(node, list.nodes));
addToList(chunk.typeHint, list.typeHints);
});
list.nodes.forEach((nodes) => {
addToList(nodes.attributes, list.attributes);
nodes.items.forEach((item) => addToList(item, list.items));
nodes.nodes.forEach((node) => addToList(node, list.nodes));
addToList(nodes.typeHint, list.typeHints);
});
list.items.forEach((item) => {
addToList(item.accessor, list.accessors);
addToList(item.attributes, list.attributes);
addToList(item.typeHint, list.typeHints);
});
list.attributes.forEach((attributes) => {
Object.values(attributes.entries).forEach((attribute) => {
addToList(attribute.accessor, list.accessors);
addToList(attribute.typeHint, list.typeHints);
});
});
list.accessors.forEach((accessor) => addToList(accessor.bufferView, list.bufferViews));
list.bufferViews.forEach((bufferView) => addToList(bufferView.buffer, list.buffers));
return list;
}
//# sourceMappingURL=ISdtfWriteableComponentList.js.map