不幸的是,该文档缺少一小部分信息。使用 Autodesk.Viewing.MemoryLimited 扩展时,您必须配置您想要施加的实际内存限制,例如,如下所示:
const config = {
loaderExtensions: { svf: 'Autodesk.MemoryLimited' },
memory: {
limit: 1024
}
};
const viewer = new Autodesk.Viewing.GuiViewer3D(document.getElementById('preview'), config);
另外,请注意,内存限制加载将仅在您的模型大于配置的阈值时启用。如果您想强制限制内存加载,即使是较小的模型,试试这个:
const config = {
loaderExtensions: { svf: 'Autodesk.MemoryLimited' },
memory: {
limit: 1024,
debug: {
force: true
}
}
};
const viewer = new Autodesk.Viewing.GuiViewer3D(document.getElementById('preview'), config);
编辑
memory.debug 对象可以包含自定义内存限制加载行为的附加属性。这些是供内部使用的,但您也可以尝试使用它们:
options.debug = {
// Increase the max page out size. On slow (mobile) devices the scene
// traversal is a bottle neck and making this larger helps load more
// pack files earlier in the load.
maxPageOutSize: 195, // Max we will page out in one go
pixelCullingEnable: this.options.onDemandLoading, // Useful with on demand loading
pixelCullingThreshold: avp.PIXEL_CULLING_THRESHOLD,
occlusionThreshold: 1,
occlusionTestThreshold: 1,
startOcclusionTestingPackCount: 8,
testPackfileCount: 4,
useOcclusionInstancing: true,
automaticRefresh: true,
boxProxyMaxCount: 0, // show this many boxes during a render
boxProxyMinScreen: 0.4 // if entire render batch is >= 1/10 of the screen in area
};