|
14 | 14 | using Wkx; |
15 | 15 |
|
16 | 16 | namespace i3dm.export; |
| 17 | + |
17 | 18 | public static class GPUTileHandler |
18 | 19 | { |
19 | 20 | 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 |
119 | 120 | foreach (var model in distinctModels) |
120 | 121 | { |
121 | 122 | var modelPath = (string)model; |
122 | | - var modelRoot = ModelRoot.Load(modelPath); |
123 | 123 |
|
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 | + } |
125 | 139 |
|
126 | | - var meshNodeCount = AddModelInstancesToScene(sceneBuilder, instances, UseScaleNonUniform, translation, modelPath, modelRoot, keepProjection); |
127 | | - if (meshNodeCountsByModel != null) meshNodeCountsByModel[modelPath] = meshNodeCount; |
| 140 | + throw ex; |
| 141 | + } |
128 | 142 | } |
129 | 143 |
|
130 | 144 | return sceneBuilder; |
@@ -195,19 +209,19 @@ private static AffineTransform GetInstanceTransform(Instance instance, bool UseS |
195 | 209 | { |
196 | 210 | // Cartesian mode: positions are in local XYZ coordinates (X=East, Y=North, Z=Up) |
197 | 211 | // Transform to glTF Y-up space |
198 | | - |
| 212 | + |
199 | 213 | // Position: transform from Cartesian XYZ to Y-up, then compute offset from RTC |
200 | 214 | var cartesianPos = new Vector3( |
201 | | - (float)point.X, |
202 | | - (float)point.Y, |
| 215 | + (float)point.X, |
| 216 | + (float)point.Y, |
203 | 217 | (float)point.Z.GetValueOrDefault()); |
204 | | - |
| 218 | + |
205 | 219 | var cartesianPosYUp = ToYUp(cartesianPos); |
206 | | - |
| 220 | + |
207 | 221 | // translation is already in Y-up format (ToYUp applied in BuildGpuModel) |
208 | 222 | position2 = new Vector3( |
209 | 223 | cartesianPosYUp.X - (float)translation.X, |
210 | | - cartesianPosYUp.Y - (float)translation.Y, |
| 224 | + cartesianPosYUp.Y - (float)translation.Y, |
211 | 225 | cartesianPosYUp.Z - (float)translation.Z); |
212 | 226 |
|
213 | 227 | // Rotation: apply yaw/pitch/roll in local Cartesian frame |
|
0 commit comments