Skip to content

Commit 33e8c4e

Browse files
committed
updating dependencies, using much older Newtonsoft.Json
1 parent 2bf9a51 commit 33e8c4e

12 files changed

+198
-154
lines changed

src/CodeCave.Threejs.Entities.csproj

+36-36
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
2-
3-
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
5-
<OutputType>library</OutputType>
6-
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
7-
<!-- Multiple targets can cause obj folder locking by concurrent builds -->
8-
<BuildInParallel>false</BuildInParallel>
9-
</PropertyGroup>
10-
11-
<PropertyGroup>
12-
<IsPackable>true</IsPackable>
13-
<Version>0.1.0</Version>
14-
<FileVersion>0.1.0</FileVersion>
15-
<AssemblyVersion>0.1.0</AssemblyVersion>
16-
<RepositoryType>git</RepositoryType>
17-
<PackageProjectUrl>https://github.com/CodeCavePro/threejs-entities.git</PackageProjectUrl>
18-
<RepositoryUrl>https://github.com/CodeCavePro/threejs-entities.git</RepositoryUrl>
19-
<PackageTags>nuget, package, library, three.js, revit, export</PackageTags>
20-
</PropertyGroup>
21-
22-
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netstandard2.0|AnyCPU'">
23-
<CodeAnalysisRuleSet>..\stylecop.ruleset</CodeAnalysisRuleSet>
24-
</PropertyGroup>
25-
26-
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard2.0|AnyCPU'">
27-
<CodeAnalysisRuleSet>..\stylecop.ruleset</CodeAnalysisRuleSet>
28-
</PropertyGroup>
29-
30-
<ItemGroup>
31-
<PackageReference Include="JsonSubTypes" Version="1.7.0" />
32-
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
33-
<PackageReference Include="System.Text.Json" Version="4.7.1" Condition="'$(TargetFramework)' != 'net45'" />
34-
</ItemGroup>
35-
36-
</Project>
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
5+
<OutputType>library</OutputType>
6+
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
7+
<!-- Multiple targets can cause obj folder locking by concurrent builds -->
8+
<BuildInParallel>false</BuildInParallel>
9+
</PropertyGroup>
10+
11+
<PropertyGroup>
12+
<IsPackable>true</IsPackable>
13+
<Version>0.7.0</Version>
14+
<FileVersion>0.7.0</FileVersion>
15+
<AssemblyVersion>0.7.0</AssemblyVersion>
16+
<RepositoryType>git</RepositoryType>
17+
<PackageProjectUrl>https://github.com/CodeCavePro/threejs-entities.git</PackageProjectUrl>
18+
<RepositoryUrl>https://github.com/CodeCavePro/threejs-entities.git</RepositoryUrl>
19+
<PackageTags>nuget, package, library, three.js, revit, export</PackageTags>
20+
</PropertyGroup>
21+
22+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netstandard2.0|AnyCPU'">
23+
<CodeAnalysisRuleSet>..\stylecop.ruleset</CodeAnalysisRuleSet>
24+
</PropertyGroup>
25+
26+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard2.0|AnyCPU'">
27+
<CodeAnalysisRuleSet>..\stylecop.ruleset</CodeAnalysisRuleSet>
28+
</PropertyGroup>
29+
30+
<ItemGroup>
31+
<PackageReference Include="JsonSubTypes" Version="1.8.*" />
32+
<PackageReference Include="Newtonsoft.Json" Version="[10.0.1, 12.1)" />
33+
<PackageReference Include="System.Text.Json" Version="5.0.*" Condition="'$(TargetFramework)' != 'net45'" />
34+
</ItemGroup>
35+
36+
</Project>

src/Geometries/BoxGeometry.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ public BoxGeometry(string uuid, double width = 1D, double height = 1D, double de
1919
Depth = depth;
2020
}
2121

22-
[JsonConstructor]
22+
[Newtonsoft.Json.JsonConstructor]
23+
[System.Text.Json.Serialization.JsonConstructor]
2324
private BoxGeometry()
2425
: base(Guid.NewGuid().ToString())
2526
{

src/Geometries/Geometry.cs

+107-101
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,107 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Diagnostics.CodeAnalysis;
4-
using System.Runtime.Serialization;
5-
using System.Text.Json.Serialization;
6-
using JsonSubTypes;
7-
using Newtonsoft.Json;
8-
9-
namespace CodeCave.Threejs.Entities
10-
{
11-
/// <summary>
12-
/// Geometry is a user-friendly alternative to BufferGeometry.
13-
/// Geometries store attributes (vertex positions, faces, colors, etc.)
14-
/// using objects like Vector3 or Color that are easier to read and edit,
15-
/// but less efficient than typed arrays.
16-
///
17-
/// Prefer <see cref="BufferGeometry"/> for large or serious projects.
18-
/// </summary>
19-
[Serializable]
20-
[DataContract]
21-
[Newtonsoft.Json.JsonConverter(typeof(JsonSubtypes), nameof(Type))]
22-
[JsonSubtypes.KnownSubType(typeof(BoxGeometry), nameof(BoxGeometry))]
23-
[System.Text.Json.Serialization.JsonConverter(typeof(Utf8Json.PolymorphicJsonConverter<Geometry>))]
24-
public partial class Geometry : IEquatable<Geometry>
25-
{
26-
/// <summary>Initializes a new instance of the <see cref="Geometry"/> class.</summary>
27-
/// <param name="uuid">The UUID of this object instance.</param>
28-
[JsonConstructor]
29-
public Geometry(string uuid)
30-
{
31-
Uuid = uuid ?? Guid.NewGuid().ToString();
32-
Data = new GeometryData();
33-
}
34-
35-
/// <summary>Gets the type of this object, it always equals 'Geometry'.</summary>
36-
/// <value>The 'Geometry' type.</value>
37-
[DataMember(Name = "type")]
38-
[JsonProperty("type")]
39-
[JsonPropertyName("type")]
40-
public virtual string Type => nameof(Geometry);
41-
42-
/// <summary>
43-
/// Gets the UUID of this object instance.
44-
/// </summary>
45-
/// <value>
46-
/// The UUID. This gets automatically assigned and shouldn't be edited.
47-
/// </value>
48-
[DataMember(Name = "uuid")]
49-
[JsonProperty("uuid")]
50-
[JsonPropertyName("uuid")]
51-
public string Uuid { get; internal set; }
52-
53-
[DataMember(Name = "data")]
54-
[JsonProperty("data")]
55-
[JsonPropertyName("data")]
56-
public virtual GeometryData Data { get; internal set; }
57-
58-
/// <summary>Adds the point to the vertices.</summary>
59-
/// <param name="vertex">The vertex.</param>
60-
[SuppressMessage(
61-
"StyleCop.CSharp.OrderingRules",
62-
"SA1201:Elements should appear in the correct order",
63-
Justification = "The class below is private, so it will never be OK.")]
64-
public void AddPoint(Vector3 vertex)
65-
{
66-
if (vertex is null)
67-
throw new ArgumentNullException(nameof(vertex));
68-
69-
Data.Vertices.Add(vertex.X);
70-
Data.Vertices.Add(vertex.Y);
71-
Data.Vertices.Add(vertex.Z);
72-
}
73-
74-
/// <summary>Adds the point to the vertices.</summary>
75-
/// <param name="x">The x coordinate.</param>
76-
/// <param name="y">The y coordinate.</param>
77-
/// <param name="z">The z coordinate.</param>
78-
public void AddPoint(double x, double y, double z)
79-
{
80-
Data.Vertices.Add(x);
81-
Data.Vertices.Add(y);
82-
Data.Vertices.Add(z);
83-
}
84-
85-
/// <summary>Adds a faces from its vertices.</summary>
86-
/// <param name="vertices">The vertices of a face.</param>
87-
public void AddFace(params int[] vertices)
88-
{
89-
Data.Faces.AddRange(vertices);
90-
}
91-
92-
public override bool Equals(object obj) => obj is Geometry geometry && Equals(geometry);
93-
94-
public bool Equals(Geometry other) => Uuid.Equals(other?.Uuid, StringComparison.OrdinalIgnoreCase);
95-
96-
public override int GetHashCode()
97-
{
98-
return 2083305506 + EqualityComparer<string>.Default.GetHashCode(Uuid);
99-
}
100-
}
101-
}
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Diagnostics.CodeAnalysis;
4+
using System.Runtime.Serialization;
5+
using System.Text.Json.Serialization;
6+
using JsonSubTypes;
7+
using Newtonsoft.Json;
8+
9+
namespace CodeCave.Threejs.Entities
10+
{
11+
/// <summary>
12+
/// Geometry is a user-friendly alternative to BufferGeometry.
13+
/// Geometries store attributes (vertex positions, faces, colors, etc.)
14+
/// using objects like Vector3 or Color that are easier to read and edit,
15+
/// but less efficient than typed arrays.
16+
///
17+
/// Prefer <see cref="BufferGeometry"/> for large or serious projects.
18+
/// </summary>
19+
[Serializable]
20+
[DataContract]
21+
[Newtonsoft.Json.JsonConverter(typeof(JsonSubtypes), nameof(Type))]
22+
[JsonSubtypes.KnownSubType(typeof(BoxGeometry), nameof(BoxGeometry))]
23+
[System.Text.Json.Serialization.JsonConverter(typeof(Utf8Json.PolymorphicJsonConverter<Geometry>))]
24+
public partial class Geometry : IEquatable<Geometry>
25+
{
26+
/// <summary>Initializes a new instance of the <see cref="Geometry"/> class.</summary>
27+
/// <param name="uuid">The UUID of this object instance.</param>
28+
[Newtonsoft.Json.JsonConstructor]
29+
[System.Text.Json.Serialization.JsonConstructor]
30+
public Geometry(string uuid)
31+
{
32+
Uuid = uuid ?? Guid.NewGuid().ToString();
33+
Data = new GeometryData();
34+
}
35+
36+
/// <summary>Gets the type of this object, it always equals 'Geometry'.</summary>
37+
/// <value>The 'Geometry' type.</value>
38+
[DataMember(Name = "type")]
39+
[JsonProperty("type")]
40+
[JsonPropertyName("type")]
41+
public virtual string Type => nameof(Geometry);
42+
43+
/// <summary>
44+
/// Gets the UUID of this object instance.
45+
/// </summary>
46+
/// <value>
47+
/// The UUID. This gets automatically assigned and shouldn't be edited.
48+
/// </value>
49+
[DataMember(Name = "uuid")]
50+
[JsonProperty("uuid")]
51+
[JsonPropertyName("uuid")]
52+
public string Uuid { get; internal set; }
53+
54+
[DataMember(Name = "data")]
55+
[JsonProperty("data")]
56+
[JsonPropertyName("data")]
57+
public virtual GeometryData Data { get; internal set; }
58+
59+
/// <summary>Adds the point to the vertices.</summary>
60+
/// <param name="vertex">The vertex.</param>
61+
[SuppressMessage(
62+
"StyleCop.CSharp.OrderingRules",
63+
"SA1201:Elements should appear in the correct order",
64+
Justification = "The class below is private, so it will never be OK.")]
65+
public void AddPoint(Vector3 vertex)
66+
{
67+
if (vertex is null)
68+
throw new ArgumentNullException(nameof(vertex));
69+
70+
Data.Vertices.Add(vertex.X);
71+
Data.Vertices.Add(vertex.Y);
72+
Data.Vertices.Add(vertex.Z);
73+
}
74+
75+
/// <summary>Adds the point to the vertices.</summary>
76+
/// <param name="x">The x coordinate.</param>
77+
/// <param name="y">The y coordinate.</param>
78+
/// <param name="z">The z coordinate.</param>
79+
public void AddPoint(double x, double y, double z)
80+
{
81+
Data.Vertices.Add(x);
82+
Data.Vertices.Add(y);
83+
Data.Vertices.Add(z);
84+
}
85+
86+
/// <summary>Adds a faces from its vertices.</summary>
87+
/// <param name="vertices">The vertices of a face.</param>
88+
public void AddFace(params int[] vertices)
89+
{
90+
Data.Faces.AddRange(vertices);
91+
}
92+
93+
public void AddUVs(params double[] uvs)
94+
{
95+
Data.UVs.AddRange(uvs);
96+
}
97+
98+
public override bool Equals(object obj) => obj is Geometry geometry && Equals(geometry);
99+
100+
public bool Equals(Geometry other) => Uuid.Equals(other?.Uuid, StringComparison.OrdinalIgnoreCase);
101+
102+
public override int GetHashCode()
103+
{
104+
return 2083305506 + EqualityComparer<string>.Default.GetHashCode(Uuid);
105+
}
106+
}
107+
}

src/Geometries/GeometryData.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ namespace CodeCave.Threejs.Entities
1212
[DataContract]
1313
public class GeometryData
1414
{
15-
[JsonConstructor]
15+
[Newtonsoft.Json.JsonConstructor]
16+
[System.Text.Json.Serialization.JsonConstructor]
1617
internal GeometryData()
1718
{
1819
}
@@ -108,7 +109,7 @@ internal GeometryData()
108109
[DataMember(Name = "uvs")]
109110
[JsonProperty("uvs")]
110111
[JsonPropertyName("uvs")]
111-
public ICollection<double> UVs { get; set; } = new List<double>();
112+
public List<double> UVs { get; set; } = new List<double>();
112113

113114
/// <summary>
114115
/// Gets or sets the array of vertices (in millimeters).

src/Materials/MeshPhongMaterial.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ public MeshPhongMaterial(string uuid)
2525
{
2626
}
2727

28-
[JsonConstructor]
28+
[Newtonsoft.Json.JsonConstructor]
29+
[System.Text.Json.Serialization.JsonConstructor]
2930
private MeshPhongMaterial()
3031
: base(Guid.NewGuid().ToString())
3132
{

src/Materials/MeshStandardMaterial.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ public MeshStandardMaterial(string uuid)
1313
{
1414
}
1515

16-
[JsonConstructor]
16+
[Newtonsoft.Json.JsonConstructor]
17+
[System.Text.Json.Serialization.JsonConstructor]
1718
private MeshStandardMaterial()
1819
: base(Guid.NewGuid().ToString())
1920
{

src/ObjectMetadata.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ public ObjectMetadata(string generator)
2828
/// <summary>
2929
/// Initializes a new instance of the <see cref="ObjectMetadata"/> class.
3030
/// </summary>
31-
[JsonConstructor]
31+
[Newtonsoft.Json.JsonConstructor]
32+
[System.Text.Json.Serialization.JsonConstructor]
3233
internal ObjectMetadata()
3334
{
3435
}

src/ObjectScene.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public ObjectScene(string generator, string uuid)
4242
/// <summary>
4343
/// Initializes a new instance of the <see cref="ObjectScene"/> class.
4444
/// </summary>
45-
[JsonConstructor]
45+
[Newtonsoft.Json.JsonConstructor]
46+
[System.Text.Json.Serialization.JsonConstructor]
4647
public ObjectScene()
4748
{
4849
Metadata = new ObjectMetadata();
@@ -151,5 +152,11 @@ public ObjectScene Optimize(bool aggressive = false)
151152

152153
return this;
153154
}
155+
156+
public ObjectScene CleanUp()
157+
{
158+
Object.CleanUp();
159+
return this;
160+
}
154161
}
155162
}

0 commit comments

Comments
 (0)