Skip to content

Commit 2c35892

Browse files
committed
add Draco eror handling
1 parent a6b6bb4 commit 2c35892

1 file changed

Lines changed: 24 additions & 10 deletions

File tree

src/GPUTileHandler.cs

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using Wkx;
1515

1616
namespace i3dm.export;
17+
1718
public static class GPUTileHandler
1819
{
1920
public static void SaveGPUTile(string filePath, List<Instance> instances, bool UseScaleNonUniform, bool keepProjection = false)
@@ -119,12 +120,25 @@ private static SceneBuilder AddModels(IEnumerable<Instance> instances, Point tra
119120
foreach (var model in distinctModels)
120121
{
121122
var modelPath = (string)model;
122-
var modelRoot = ModelRoot.Load(modelPath);
123123

124-
ExternalTextureHelper.CollectExternalTextures(externalTextures, modelPath, modelRoot);
124+
try
125+
{
126+
var modelRoot = ModelRoot.Load(modelPath);
127+
128+
ExternalTextureHelper.CollectExternalTextures(externalTextures, modelPath, modelRoot);
129+
130+
var meshNodeCount = AddModelInstancesToScene(sceneBuilder, instances, UseScaleNonUniform, translation, modelPath, modelRoot, keepProjection);
131+
if (meshNodeCountsByModel != null) meshNodeCountsByModel[modelPath] = meshNodeCount;
132+
}
133+
catch (SharpGLTF.Validation.LinkException ex)
134+
{
135+
if (ex.Message.Contains("draco"))
136+
{
137+
throw new InvalidOperationException($"The model '{modelPath}' uses Draco compression, which is not supported for GPU instancing. Please re-export the model without Draco compression and try again.", ex);
138+
}
125139

126-
var meshNodeCount = AddModelInstancesToScene(sceneBuilder, instances, UseScaleNonUniform, translation, modelPath, modelRoot, keepProjection);
127-
if (meshNodeCountsByModel != null) meshNodeCountsByModel[modelPath] = meshNodeCount;
140+
throw ex;
141+
}
128142
}
129143

130144
return sceneBuilder;
@@ -195,19 +209,19 @@ private static AffineTransform GetInstanceTransform(Instance instance, bool UseS
195209
{
196210
// Cartesian mode: positions are in local XYZ coordinates (X=East, Y=North, Z=Up)
197211
// Transform to glTF Y-up space
198-
212+
199213
// Position: transform from Cartesian XYZ to Y-up, then compute offset from RTC
200214
var cartesianPos = new Vector3(
201-
(float)point.X,
202-
(float)point.Y,
215+
(float)point.X,
216+
(float)point.Y,
203217
(float)point.Z.GetValueOrDefault());
204-
218+
205219
var cartesianPosYUp = ToYUp(cartesianPos);
206-
220+
207221
// translation is already in Y-up format (ToYUp applied in BuildGpuModel)
208222
position2 = new Vector3(
209223
cartesianPosYUp.X - (float)translation.X,
210-
cartesianPosYUp.Y - (float)translation.Y,
224+
cartesianPosYUp.Y - (float)translation.Y,
211225
cartesianPosYUp.Z - (float)translation.Z);
212226

213227
// Rotation: apply yaw/pitch/roll in local Cartesian frame

0 commit comments

Comments
 (0)