Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 24 additions & 10 deletions src/GPUTileHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Wkx;

namespace i3dm.export;

public static class GPUTileHandler
{
public static void SaveGPUTile(string filePath, List<Instance> instances, bool UseScaleNonUniform, bool keepProjection = false)
Expand Down Expand Up @@ -119,12 +120,25 @@
foreach (var model in distinctModels)
{
var modelPath = (string)model;
var modelRoot = ModelRoot.Load(modelPath);

ExternalTextureHelper.CollectExternalTextures(externalTextures, modelPath, modelRoot);
try
{
var modelRoot = ModelRoot.Load(modelPath);

ExternalTextureHelper.CollectExternalTextures(externalTextures, modelPath, modelRoot);

var meshNodeCount = AddModelInstancesToScene(sceneBuilder, instances, UseScaleNonUniform, translation, modelPath, modelRoot, keepProjection);
if (meshNodeCountsByModel != null) meshNodeCountsByModel[modelPath] = meshNodeCount;
}
catch (SharpGLTF.Validation.LinkException ex)
{
if (ex.Message.Contains("draco"))
{
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);
}

var meshNodeCount = AddModelInstancesToScene(sceneBuilder, instances, UseScaleNonUniform, translation, modelPath, modelRoot, keepProjection);
if (meshNodeCountsByModel != null) meshNodeCountsByModel[modelPath] = meshNodeCount;
throw ex;

Check warning on line 140 in src/GPUTileHandler.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Re-throwing caught exception changes stack information (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2200)

Check warning on line 140 in src/GPUTileHandler.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Re-throwing caught exception changes stack information (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2200)

Check warning on line 140 in src/GPUTileHandler.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Re-throwing caught exception changes stack information (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2200)

Check warning on line 140 in src/GPUTileHandler.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Re-throwing caught exception changes stack information (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2200)
}
}

return sceneBuilder;
Expand Down Expand Up @@ -195,19 +209,19 @@
{
// Cartesian mode: positions are in local XYZ coordinates (X=East, Y=North, Z=Up)
// Transform to glTF Y-up space

// Position: transform from Cartesian XYZ to Y-up, then compute offset from RTC
var cartesianPos = new Vector3(
(float)point.X,
(float)point.Y,
(float)point.X,
(float)point.Y,
(float)point.Z.GetValueOrDefault());

var cartesianPosYUp = ToYUp(cartesianPos);

// translation is already in Y-up format (ToYUp applied in BuildGpuModel)
position2 = new Vector3(
cartesianPosYUp.X - (float)translation.X,
cartesianPosYUp.Y - (float)translation.Y,
cartesianPosYUp.Y - (float)translation.Y,
cartesianPosYUp.Z - (float)translation.Z);

// Rotation: apply yaw/pitch/roll in local Cartesian frame
Expand Down
Loading