近期有在关注 Forge 的朋友应该有注意到 Forge Viewer 终于推出原生的楼层剖切扩展 (Autodesk.AEC.LevelsExtension) 和小地图扩展 (Autodesk.AEC.Minimap3DExtension) 以下图:git
在使用这两个扩展时有个大前提,都须要加载一个叫 AecModelData.json 的文檔,但这个文檔只有在Viewer在线模式下经过 Viewer3D#loadDocumentNode
加载模型,才可以经过 Document#downloadAecModelData
加载,并经过 BubbleNode#getAecModelData
获取,因此有许多 Forge 的小伙伴在咨询有没有什么办法能够在本地模式下也能获取 AECModelData 数据?github
所幸,咱们Forge开发技术支持团队的黄老师提出了一个不错的解方;在开始说明前,咱们先看完整代码样例长什么样子:数据库
const manifestJsonObject={ "type": "manifest", "hasThumbnail": "true", "status": "success", "progress": "complete", "region": "US", "urn": "dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0", "version": "1.0", "derivatives": [ { "name": "revithouse.rvt", "hasThumbnail": "true", "status": "success", "progress": "complete", "outputType": "svf", "children": [ { "guid": "6fac95cb-af5d-3e4f-b943-8a7f55847ff1", "type": "resource", "role": "Autodesk.CloudPlatform.PropertyDatabase", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/model.sdb", "mime": "application/autodesk-db", "status": "success" }, { "guid": "a4aac952-a3f4-031c-4113-b2d9ac2d0de6", "type": "resource", "role": "Autodesk.AEC.ModelData", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/AECModelData.json", "mime": "application/json", "status": "success" }, { "guid": "250a6ce5-ee70-fdca-bfc9-4111f54e9baa", "type": "geometry", "role": "3d", "name": "{3D}", "viewableID": "44745acb-ebea-4fb9-a091-88d28bd746c7-000ea86d", "phaseNames": "Working Drawings", "status": "success", "hasThumbnail": "true", "progress": "complete", "children": [ { "guid": "44745acb-ebea-4fb9-a091-88d28bd746c7-000ea86d", "type": "view", "role": "3d", "name": "{3D}", "status": "success", "progress": "complete", "camera": [ -179.730789, -280.752563, 195.499207, -1.51878, -48.585297, 10.432776, 0.32542, 0.423943, 0.845207, 1.261474, 0, 1, 1 ], "sectionBox": [ -91.740555, -128.710696, -43.86306, 73.721828, 102.143481, 43.86306 ], "sectionBoxTransform": [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 7.490585, -35.301688, 16.574985, 1 ] }, { "guid": "6bfb4886-f2ee-9ccb-8db0-c5c170220c40", "type": "resource", "role": "graphics", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/3D View/{3D} 960621/{3D}.svf", "mime": "application/autodesk-svf" }, { "guid": "59793754-3f96-a1aa-a227-b183c61a3e2b", "type": "resource", "role": "thumbnail", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/3D View/{3D} 960621/{3D}1.png", "resolution": [ 100, 100 ], "mime": "image/png", "status": "success" }, { "guid": "72ed64e1-86c1-27c6-6aea-53a8471d8058", "type": "resource", "role": "thumbnail", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/3D View/{3D} 960621/{3D}2.png", "resolution": [ 200, 200 ], "mime": "image/png", "status": "success" }, { "guid": "7617fb7e-2274-2fa7-2fde-a0e7ae4faa72", "type": "resource", "role": "thumbnail", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/3D/0/{3D}4.png", "resolution": [ 400, 400 ], "mime": "image/png", "status": "success" } ] }, { "guid": "0fcae25c-c092-0192-49bc-63a7f3f9f73c", "type": "geometry", "role": "3d", "name": "Working Drawings", "viewableID": "c884ae1b-61e7-4f9d-0001-719e20b22d0b-0010948b", "phaseNames": "Working Drawings", "status": "success", "hasThumbnail": "true", "progress": "complete", "children": [ { "guid": "c884ae1b-61e7-4f9d-0001-719e20b22d0b-0010948b", "type": "view", "role": "3d", "name": "Working Drawings", "status": "success", "progress": "complete", "camera": [ 124.788673, -152.599777, 133.873077, 7.490562, -35.301666, 16.574966, -0.408248, 0.408248, 0.816497, 1.285019, 0, 1, 1 ] }, { "guid": "9fd4cfc3-9d57-8220-95af-ca79a841aeed", "type": "resource", "role": "graphics", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/3D View/08f99ae5-b8be-4f8d-881b-128675723c10/Working Drawings/Working Drawings.svf", "mime": "application/autodesk-svf" }, { "guid": "58a4a113-6c40-4868-3ca6-ba9d4404bdb0", "type": "resource", "role": "thumbnail", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/3D View/08f99ae5-b8be-4f8d-881b-128675723c10/Working Drawings/Working Drawings1.png", "resolution": [ 100, 100 ], "mime": "image/png", "status": "success" }, { "guid": "e6e1cb4a-9d5f-3d5a-ada3-80811be28418", "type": "resource", "role": "thumbnail", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/3D View/08f99ae5-b8be-4f8d-881b-128675723c10/Working Drawings/Working Drawings2.png", "resolution": [ 200, 200 ], "mime": "image/png", "status": "success" }, { "guid": "7842fef9-edfb-ca38-1f19-0b7489065f35", "type": "resource", "role": "thumbnail", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/3D View/08f99ae5-b8be-4f8d-881b-128675723c10/Working Drawings/Working Drawings4.png", "resolution": [ 400, 400 ], "mime": "image/png", "status": "success" } ] }, { "guid": "3241c8f8-aec7-5511-c85d-b2e4dc6dee9a", "type": "geometry", "role": "3d", "name": "Learning Content", "viewableID": "c884ae1b-61e7-4f9d-0002-719e20b22d0b-00109496", "phaseNames": "Learning Content", "status": "success", "hasThumbnail": "true", "progress": "complete", "children": [ { "guid": "c884ae1b-61e7-4f9d-0002-719e20b22d0b-00109496", "type": "view", "role": "3d", "name": "Learning Content", "status": "success", "progress": "complete", "camera": [ 124.788673, -152.599777, 133.873077, 7.490562, -35.301666, 16.574966, -0.408248, 0.408248, 0.816497, 1.285019, 0, 1, 1 ] }, { "guid": "cd4cd7f1-01ec-7f05-7541-e2beb2c72316", "type": "resource", "role": "graphics", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/3D View/08f99ae5-b8be-4f8d-881b-128675723c10/Learning Content/Learning Content.svf", "mime": "application/autodesk-svf" }, { "guid": "ae8c0aad-c025-b7f0-6129-f29bfbd0fbba", "type": "resource", "role": "thumbnail", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/3D View/08f99ae5-b8be-4f8d-881b-128675723c10/Learning Content/Learning Content1.png", "resolution": [ 100, 100 ], "mime": "image/png", "status": "success" }, { "guid": "4f6ad79d-56fe-7f3b-68c4-7316030cdf8c", "type": "resource", "role": "thumbnail", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/3D View/08f99ae5-b8be-4f8d-881b-128675723c10/Learning Content/Learning Content2.png", "resolution": [ 200, 200 ], "mime": "image/png", "status": "success" }, { "guid": "dc49a9dc-3468-a8fe-36e5-2d145f68535b", "type": "resource", "role": "thumbnail", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/3D View/08f99ae5-b8be-4f8d-881b-128675723c10/Learning Content/Learning Content4.png", "resolution": [ 400, 400 ], "mime": "image/png", "status": "success" } ] }, { "guid": "6d3acd40-53b7-41b4-9d96-72e9eaf4bc89-0005d699", "type": "geometry", "role": "2d", "name": "A102 - Plans", "viewableID": "6d3acd40-53b7-41b4-9d96-72e9eaf4bc89-0005d699", "phaseNames": "Working Drawings", "status": "success", "progress": "complete", "properties": { "Print Setting": { "Layout": "Landscape", "Paper size": "ISO A4, 210 x 297 mm" } }, "hasThumbnail": "true", "children": [ { "guid": "94a13396-cab7-17d9-43df-511de85acd16", "type": "resource", "role": "thumbnail", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/Sheet/A102 - Plans 382617/dwfx/A102 - Plans1.png", "resolution": [ 100, 100 ], "mime": "image/png", "status": "success" }, { "guid": "417a5a56-1d60-cf20-5303-217e1bf2ca7f", "type": "resource", "role": "thumbnail", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/Sheet/A102 - Plans 382617/dwfx/A102 - Plans2.png", "resolution": [ 200, 200 ], "mime": "image/png", "status": "success" }, { "guid": "b2aabe02-2cc6-5454-60fb-fe2c401d2f10", "type": "resource", "role": "thumbnail", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/Sheet/A102 - Plans 382617/dwfx/A102 - Plans4.png", "resolution": [ 400, 400 ], "mime": "image/png", "status": "success" }, { "guid": "abdacd31-f94c-e84f-9a58-4663e281d894", "type": "resource", "role": "graphics", "mime": "application/autodesk-f2d", "status": "success", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/2a4f999f-9163-0bcc-dd15-7513ea2ac029_f2d/primaryGraphics.f2d" }, { "guid": "416bcbbf-68bc-4d98-9f32-2e771d7bb89b", "type": "view", "role": "2d", "name": "Sheet: A102 - Plans", "viewbox": [ 0, 0.023889, 839.999999, 593.976111 ] } ] }, { "guid": "96cdd175-e436-4cac-a08f-bf0fabb86ac5-0007af95", "type": "geometry", "role": "2d", "name": "A104 - Elev./Sec./Det.", "viewableID": "96cdd175-e436-4cac-a08f-bf0fabb86ac5-0007af95", "phaseNames": "Working Drawings", "status": "success", "progress": "complete", "properties": { "Print Setting": { "Layout": "Landscape", "Paper size": "ISO A4, 210 x 297 mm" } }, "hasThumbnail": "true", "children": [ { "guid": "3eacd73d-4ae4-30d0-f315-bc7d9e5d9ded", "type": "resource", "role": "thumbnail", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/Sheet/A104 - Elev__Sec__Det_ 503701/dwfx/A104 - Elev__Sec__Det_1.png", "resolution": [ 100, 100 ], "mime": "image/png", "status": "success" }, { "guid": "f5544678-39a3-0567-f15f-1c1866b8f7c6", "type": "resource", "role": "thumbnail", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/Sheet/A104 - Elev__Sec__Det_ 503701/dwfx/A104 - Elev__Sec__Det_2.png", "resolution": [ 200, 200 ], "mime": "image/png", "status": "success" }, { "guid": "7ed24829-0478-4905-2846-d50dff6b6ef0", "type": "resource", "role": "thumbnail", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/Sheet/A104 - Elev__Sec__Det_ 503701/dwfx/A104 - Elev__Sec__Det_4.png", "resolution": [ 400, 400 ], "mime": "image/png", "status": "success" }, { "guid": "8be5a450-c03d-fcb2-6125-08d5baf4b9d9", "type": "resource", "role": "graphics", "mime": "application/autodesk-f2d", "status": "success", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/8a103c87-5bc5-3f78-8480-b3803677b5df_f2d/primaryGraphics.f2d" }, { "guid": "b27045d1-8f56-4d93-b442-57dfdd533726", "type": "view", "role": "2d", "name": "Sheet: A104 - Elev./Sec./Det.", "viewbox": [ 0, 0.023889, 839.999999, 593.976111 ] } ] }, { "guid": "f11061a0-4a15-4ce6-9ed0-20da98b45046-000e9ee8", "type": "geometry", "role": "2d", "name": "A103 - Elevations/Sections", "viewableID": "f11061a0-4a15-4ce6-9ed0-20da98b45046-000e9ee8", "phaseNames": "Working Drawings", "status": "success", "progress": "complete", "properties": { "Print Setting": { "Layout": "Landscape", "Paper size": "ISO A4, 210 x 297 mm" } }, "hasThumbnail": "true", "children": [ { "guid": "28920669-568c-0d6d-b391-c67e931ab81d", "type": "resource", "role": "thumbnail", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/Sheet/A103 - Elevations_Sections 958184/dwfx/A103 - Elevations_Sections1.png", "resolution": [ 100, 100 ], "mime": "image/png", "status": "success" }, { "guid": "a133ebae-5b89-e688-7025-a09f2a761042", "type": "resource", "role": "thumbnail", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/Sheet/A103 - Elevations_Sections 958184/dwfx/A103 - Elevations_Sections2.png", "resolution": [ 200, 200 ], "mime": "image/png", "status": "success" }, { "guid": "95f74c13-412a-f986-ee01-28fac48ff7a8", "type": "resource", "role": "thumbnail", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/Sheet/A103 - Elevations_Sections 958184/dwfx/A103 - Elevations_Sections4.png", "resolution": [ 400, 400 ], "mime": "image/png", "status": "success" }, { "guid": "10f26e65-bbca-7a68-125e-749e559c1e3b", "type": "resource", "role": "graphics", "mime": "application/autodesk-f2d", "status": "success", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/6760532e-631e-a17e-63eb-4a45dce1aa74_f2d/primaryGraphics.f2d" }, { "guid": "4d8f3e93-83bd-429a-888d-96ddf6c089e3", "type": "view", "role": "2d", "name": "Sheet: A103 - Elevations/Sections", "viewbox": [ 0, 0.023889, 839.999999, 593.976111 ] } ] }, { "guid": "f11061a0-4a15-4ce6-9ed0-20da98b45046-000e9f2b", "type": "geometry", "role": "2d", "name": "A105 - Elev./ Stair Sections", "viewableID": "f11061a0-4a15-4ce6-9ed0-20da98b45046-000e9f2b", "phaseNames": "Working Drawings", "status": "success", "progress": "complete", "properties": { "Print Setting": { "Layout": "Landscape", "Paper size": "ISO A4, 210 x 297 mm" } }, "hasThumbnail": "true", "children": [ { "guid": "197124fd-7222-b77e-2a7a-5defe29a509b", "type": "resource", "role": "thumbnail", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/Sheet/A105 - Elev__ Stair Sections 958251/dwfx/A105 - Elev__ Stair Sections1.png", "resolution": [ 100, 100 ], "mime": "image/png", "status": "success" }, { "guid": "47ed6748-b99f-8b41-e540-b5cc5db50ce1", "type": "resource", "role": "thumbnail", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/Sheet/A105 - Elev__ Stair Sections 958251/dwfx/A105 - Elev__ Stair Sections2.png", "resolution": [ 200, 200 ], "mime": "image/png", "status": "success" }, { "guid": "060ddb1a-9398-45a3-d2bf-1560f8650e6f", "type": "resource", "role": "thumbnail", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/Sheet/A105 - Elev__ Stair Sections 958251/dwfx/A105 - Elev__ Stair Sections4.png", "resolution": [ 400, 400 ], "mime": "image/png", "status": "success" }, { "guid": "db90b95d-0265-5fe4-376a-4dd3386c3d7d", "type": "resource", "role": "graphics", "mime": "application/autodesk-f2d", "status": "success", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/8c15d5f2-9aa1-61e6-77a7-61e08633eb4f_f2d/primaryGraphics.f2d" }, { "guid": "eb6a5fb3-d049-4cfb-bf32-1a8a22dc31c8", "type": "view", "role": "2d", "name": "Sheet: A105 - Elev./ Stair Sections", "viewbox": [ 0, 0.023889, 839.999999, 593.976111 ] } ] }, { "guid": "e9248f2e-7bb7-4baf-8541-afac7b6872de-000ea29f", "type": "geometry", "role": "2d", "name": "A101 - Site Plan", "viewableID": "e9248f2e-7bb7-4baf-8541-afac7b6872de-000ea29f", "phaseNames": "Working Drawings", "status": "success", "progress": "complete", "properties": { "Print Setting": { "Layout": "Landscape", "Paper size": "ISO A4, 210 x 297 mm" } }, "hasThumbnail": "true", "children": [ { "guid": "ccaa45fd-a10e-aa0a-1bc4-4ce456f6356f", "type": "resource", "role": "thumbnail", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/Sheet/A101 - Site Plan 959135/dwfx/A101 - Site Plan1.png", "resolution": [ 100, 100 ], "mime": "image/png", "status": "success" }, { "guid": "6e8928d6-0ea0-80d3-e66d-2815cee64d1c", "type": "resource", "role": "thumbnail", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/Sheet/A101 - Site Plan 959135/dwfx/A101 - Site Plan2.png", "resolution": [ 200, 200 ], "mime": "image/png", "status": "success" }, { "guid": "dfe3c27a-0757-fe54-ed61-984456235f87", "type": "resource", "role": "thumbnail", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/Sheet/A101 - Site Plan 959135/dwfx/A101 - Site Plan4.png", "resolution": [ 400, 400 ], "mime": "image/png", "status": "success" }, { "guid": "1fd6b2ec-267d-8ba3-6b00-abe1adf80994", "type": "resource", "role": "graphics", "mime": "application/autodesk-f2d", "status": "success", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/72d0413b-08ca-d1b5-2af2-60a9e588793b_f2d/primaryGraphics.f2d" }, { "guid": "8ea7bfa8-847d-455f-87cc-389b43124326", "type": "view", "role": "2d", "name": "Sheet: A101 - Site Plan", "viewbox": [ 0, 0.023889, 839.999999, 593.976111 ] } ] }, { "guid": "666da4f5-76ba-443a-9fe6-0bcd8a1bcfe9-000ea416", "type": "geometry", "role": "2d", "name": "A001 - Title Sheet", "viewableID": "666da4f5-76ba-443a-9fe6-0bcd8a1bcfe9-000ea416", "status": "success", "progress": "complete", "properties": { "Print Setting": { "Layout": "Landscape", "Paper size": "ISO A4, 210 x 297 mm" } }, "hasThumbnail": "true", "children": [ { "guid": "a9589c82-05f3-6298-dbee-c6157a8d8bb8", "type": "resource", "role": "thumbnail", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/Sheet/A001 - Title Sheet 959510/dwfx/A001 - Title Sheet1.png", "resolution": [ 100, 100 ], "mime": "image/png", "status": "success" }, { "guid": "e8cdf870-7bc1-5d7c-bf7b-a1cdf1c15381", "type": "resource", "role": "thumbnail", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/Sheet/A001 - Title Sheet 959510/dwfx/A001 - Title Sheet2.png", "resolution": [ 200, 200 ], "mime": "image/png", "status": "success" }, { "guid": "53bfab17-2fa9-e9f2-c21e-cd466b3eecd9", "type": "resource", "role": "thumbnail", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/Sheet/A001 - Title Sheet 959510/dwfx/A001 - Title Sheet4.png", "resolution": [ 400, 400 ], "mime": "image/png", "status": "success" }, { "guid": "97e8b569-a295-8750-f788-2d5067608b9c", "type": "resource", "role": "graphics", "mime": "application/autodesk-f2d", "status": "success", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/9c6e0f4b-edee-0c07-9f8d-fe90a92668fa_f2d/primaryGraphics.f2d" }, { "guid": "86896da4-be5c-465e-940b-465a2aeb326d", "type": "view", "role": "2d", "name": "Sheet: A001 - Title Sheet", "viewbox": [ 0, 0.023889, 839.999999, 593.976111 ] } ] } ] }, { "status": "success", "progress": "complete", "outputType": "thumbnail", "children": [ { "guid": "db899ab5-939f-e250-d79d-2d1637ce4565", "type": "resource", "role": "thumbnail", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/preview1.png", "resolution": [ 100, 100 ], "mime": "image/png", "status": "success" }, { "guid": "3f6c118d-f551-7bf0-03c9-8548d26c9772", "type": "resource", "role": "thumbnail", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/preview2.png", "resolution": [ 200, 200 ], "mime": "image/png", "status": "success" }, { "guid": "4e751806-0920-ce32-e9fd-47c3cec21536", "type": "resource", "role": "thumbnail", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/preview4.png", "resolution": [ 400, 400 ], "mime": "image/png", "status": "success" } ] } ] } Autodesk.Viewing.endpoint.getItemApi= (endpoint, derivativeUrn, api) => { return 'https://sbhehe.github.io/sb233/house'+decodeURIComponent( derivativeUrn.split('Resource')[1]) }; Autodesk.Viewing.Initializer( { env:'Local' }, () => { const viewerDocument = new Autodesk.Viewing.Document( manifestJsonObject ); viewerDocument.downloadAecModelData(); const config3d = { extensions:[ 'Autodesk.AEC.LevelsExtension', 'Autodesk.AEC.Minimap3DExtension' ] }; const viewer = new Autodesk.Viewing.GuiViewer3D( document.body.children[0], config3d); viewer.start(); viewer.loadDocumentNode(viewerDocument, viewerDocument.getRoot().getDefaultGeometry()) })
首先, 第一步,咱们需先将模型上载到 Forge 服务上进行转换,等待转换完成后,获取转换的Manifest,并把他存放在某处,像上面代码样例的 manifestJsonObject 写在JavaScript文檔里面,也能够把它存放在本身的数据存储、数据库什么的,在须要时经过 AJAX 请求获取。json
第二步,咱们须要将在线模式的 Viewer代码作个转换,从下面这个代码:api
const options = { env: 'AutodeskProduction' //... }; Autodesk.Viewing.Initializer(options, () => { Autodesk.Viewing.Document.load( urn, viewerDocument => { Viewer.loadDocumentNode( viewerDocument, geometry ) } })
转换成这个样子:服务器
const options = { env: 'Local' //... }; Autodesk.Viewing.Initializer(options, () => { const viewerDocument = new Autodesk.Viewing.Document(manifestJsonObject) //从 Forge Model Derivative GET :urn/manifest 端点获取 manifest 物件 Viewer.loadDocumentNode( viewerDocument, geometry ) //... })
第三步,复写 viewer 的 getItem 方法:网络
Autodesk.Viewing.endpoint.getItemApi = ( endpoint, derivativeUrn, api ) => { return '/path/to/model/'+decodeURIComponent( derivativeUrn.split('Resource')[1] ); //decode the URN and extract its path }
下面给小伙伴们举个例,app
假设下载的 SVF 包放在网页服务器的 House文件夹里,且经过网络能够访问的地址是 https://sbhehe.github.io/sb233/house
;那么,你的 /path/to/model/
就会是 https://sbhehe.github.io/sb233/house
ui
在来,AecModelData.json 文檔在 manifest的描述是:spa
{ "guid": "a4aac952-a3f4-031c-4113-b2d9ac2d0de6", "type": "resource", "role": "Autodesk.AEC.ModelData", "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMzMzMzL3Jldml0aG91c2UucnZ0/output/Resource/AECModelData.json", "mime": "application/json", "status": "success" },
则 derivativeUrn.split('Resource')[1]
的结果会是 /AECModelData.json
因此最后,
你须要确保你的 SVF 包的文件夹结构是相似下面这个样子:
/ House |------> AecModelData.json |------> Model.sdb |------> /3D View |------> /{3D} 960621 |------> {3D}.svf |------> {3D}.png |------> // 其余文檔或文件夹…………… |------> // 其余文檔或文件夹…………… |------> // 其余文檔或文件夹……………
上面这些注意事项都作完以后,你就能够在本地模式下获取 AecModelData 数据,并正常使用 Forge Viewer原生的楼层剖切扩展和小地图扩展啦~
顺祝开发顺利!