Skip to content

Commit f27322c

Browse files
committed
gradually getting rid of .NET Framework 4.5 and other legacy code
1 parent 70da56e commit f27322c

24 files changed

+1438
-1528
lines changed
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net8.0;netstandard2.0;net45</TargetFrameworks>
4+
<TargetFrameworks>net8.0;netstandard2.0</TargetFrameworks>
55
<OutputType>library</OutputType>
66
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
77
<!-- Multiple targets can cause obj folder locking by concurrent builds -->
@@ -12,11 +12,11 @@
1212
<PropertyGroup>
1313
<IsPackable>true</IsPackable>
1414
<IncludeSymbols>true</IncludeSymbols>
15-
<DebugType>full</DebugType>
15+
<DebugType>portable</DebugType>
1616
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
17-
<Version>0.9.1</Version>
18-
<FileVersion>0.9.1</FileVersion>
19-
<AssemblyVersion>0.9.1</AssemblyVersion>
17+
<Version>0.10.0</Version>
18+
<FileVersion>0.10.0</FileVersion>
19+
<AssemblyVersion>0.10.0</AssemblyVersion>
2020
<RepositoryType>git</RepositoryType>
2121
<PackageProjectUrl>https://github.com/CodeCavePro/threejs-entities.git</PackageProjectUrl>
2222
<RepositoryUrl>https://github.com/CodeCavePro/threejs-entities.git</RepositoryUrl>
@@ -26,7 +26,7 @@
2626
<ItemGroup>
2727
<PackageReference Include="JsonSubTypes" Version="2.0.*" />
2828
<PackageReference Include="Newtonsoft.Json" Version="[13.*, 13.1)" />
29-
<PackageReference Include="System.Text.Json" Version="8.0.*" Condition="'$(TargetFramework)' != 'net45'" />
29+
<PackageReference Include="System.Text.Json" Version="8.0.*" />
3030
</ItemGroup>
3131

3232
</Project>
Lines changed: 75 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,102 @@
11
using System;
22
using System.Linq;
33

4-
namespace CodeCave.Threejs.Entities
4+
namespace CodeCave.Threejs.Entities;
5+
6+
public static class Object3DExtensions
57
{
6-
public static class Object3DExtensions
8+
/// <summary>Merges the specified other scene.</summary>
9+
/// <param name="objectScene">The object scene.</param>
10+
/// <param name="otherScene">The other scene.</param>
11+
/// <param name="newPosition">The new position of merged objects after merge.</param>
12+
/// <returns>Returns the modified <see cref="ObjectScene"/> with other scene merged into it. </returns>
13+
/// <exception cref="ArgumentNullException">objectScene
14+
/// or
15+
/// otherScene.</exception>
16+
public static ObjectScene Merge(this ObjectScene objectScene, ObjectScene otherScene, Vector3 newPosition = null)
717
{
8-
/// <summary>Merges the specified other scene.</summary>
9-
/// <param name="objectScene">The object scene.</param>
10-
/// <param name="otherScene">The other scene.</param>
11-
/// <param name="newPosition">The new position of merged objects after merge.</param>
12-
/// <returns>Returns the modified <see cref="ObjectScene"/> with other scene merged into it. </returns>
13-
/// <exception cref="ArgumentNullException">objectScene
14-
/// or
15-
/// otherScene.</exception>
16-
public static ObjectScene Merge(this ObjectScene objectScene, ObjectScene otherScene, Vector3 newPosition = null)
17-
{
18-
if (objectScene is null)
19-
throw new ArgumentNullException(nameof(objectScene));
18+
if (objectScene is null)
19+
throw new ArgumentNullException(nameof(objectScene));
2020

21-
if (otherScene is null)
22-
throw new ArgumentNullException(nameof(otherScene));
21+
if (otherScene is null)
22+
throw new ArgumentNullException(nameof(otherScene));
2323

24-
foreach (var geometry in otherScene.Geometries)
25-
objectScene.AddGeometry(geometry);
24+
foreach (var geometry in otherScene.Geometries)
25+
objectScene.AddGeometry(geometry);
2626

27-
foreach (var material in otherScene.Materials)
28-
objectScene.AddMaterial(material);
27+
foreach (var material in otherScene.Materials)
28+
objectScene.AddMaterial(material);
2929

30-
if (otherScene.Object.Children.Any())
31-
{
32-
foreach (var child in otherScene.Object.Children)
33-
{
34-
if (newPosition != null)
35-
child.Position = newPosition;
36-
objectScene.Object.AddChild(child);
37-
}
38-
}
39-
else
30+
if (otherScene.Object.Children.Any())
31+
{
32+
foreach (var child in otherScene.Object.Children)
4033
{
4134
if (newPosition != null)
42-
otherScene.Object.Position = newPosition;
43-
objectScene.Object.AddChild(otherScene.Object);
35+
child.Position = newPosition;
36+
objectScene.Object.AddChild(child);
4437
}
45-
46-
return objectScene;
4738
}
48-
49-
/// <summary>Adds a simple cube (of the given dimensions and color) to the scene.</summary>
50-
/// <param name="objectScene">The object scene.</param>
51-
/// <param name="width">The width.</param>
52-
/// <param name="height">The height.</param>
53-
/// <param name="depth">The depth.</param>
54-
/// <param name="position">The position.</param>
55-
/// <param name="color">The color.</param>
56-
/// <returns>Returns the original <see cref="ObjectScene"/> with cube added into it.</returns>
57-
/// <exception cref="ArgumentNullException">objectScene.</exception>
58-
public static ObjectScene AddCube(this ObjectScene objectScene, double width, double height, double depth, Vector3 position = default, int color = 11674146)
39+
else
5940
{
60-
if (objectScene is null)
61-
throw new ArgumentNullException(nameof(objectScene));
41+
if (newPosition != null)
42+
otherScene.Object.Position = newPosition;
43+
objectScene.Object.AddChild(otherScene.Object);
44+
}
6245

63-
var geometry = new BoxGeometry(Guid.NewGuid().ToString(), width, height, depth);
64-
objectScene.AddGeometry(geometry);
46+
return objectScene;
47+
}
6548

66-
var material = new MeshStandardMaterial(Guid.NewGuid().ToString())
67-
{
68-
Color = color,
69-
};
70-
objectScene.AddMaterial(material);
49+
/// <summary>Adds a simple cube (of the given dimensions and color) to the scene.</summary>
50+
/// <param name="objectScene">The object scene.</param>
51+
/// <param name="width">The width.</param>
52+
/// <param name="height">The height.</param>
53+
/// <param name="depth">The depth.</param>
54+
/// <param name="position">The position.</param>
55+
/// <param name="color">The color.</param>
56+
/// <returns>Returns the original <see cref="ObjectScene"/> with cube added into it.</returns>
57+
/// <exception cref="ArgumentNullException">objectScene.</exception>
58+
public static ObjectScene AddCube(this ObjectScene objectScene, double width, double height, double depth, Vector3 position = default, int color = 11674146)
59+
{
60+
if (objectScene is null)
61+
throw new ArgumentNullException(nameof(objectScene));
7162

72-
var cubeObject = new Object3D("Mesh", Guid.NewGuid().ToString(), id: null)
73-
{
74-
CastShadow = true,
75-
ReceiveShadow = true,
76-
GeometryUuid = geometry.Uuid,
77-
MaterialUuid = material.Uuid,
78-
Position = position,
79-
};
80-
objectScene.Object.AddChild(cubeObject);
63+
var geometry = new BoxGeometry(Guid.NewGuid().ToString(), width, height, depth);
64+
objectScene.AddGeometry(geometry);
8165

82-
return objectScene;
83-
}
66+
var material = new MeshStandardMaterial(Guid.NewGuid().ToString())
67+
{
68+
Color = color,
69+
};
70+
objectScene.AddMaterial(material);
8471

85-
internal static System.Collections.Generic.IEnumerable<Object3D> Flatten(this System.Collections.Generic.IEnumerable<Object3D> collection)
72+
var cubeObject = new Object3D("Mesh", Guid.NewGuid().ToString(), id: null)
8673
{
87-
foreach (var obj in collection)
88-
{
89-
if ((obj?.Children?.Count ?? 0) == 0)
90-
yield return obj;
74+
CastShadow = true,
75+
ReceiveShadow = true,
76+
GeometryUuid = geometry.Uuid,
77+
MaterialUuid = material.Uuid,
78+
Position = position,
79+
};
80+
objectScene.Object.AddChild(cubeObject);
9181

92-
var children = obj?.Children?.Flatten() ??
82+
return objectScene;
83+
}
84+
85+
internal static System.Collections.Generic.IEnumerable<Object3D> Flatten(this System.Collections.Generic.IEnumerable<Object3D> collection)
86+
{
87+
foreach (var obj in collection)
88+
{
89+
if ((obj?.Children?.Count ?? 0) == 0)
90+
yield return obj;
91+
92+
var children = obj?.Children?.Flatten() ??
9393
#if !NETFRAMEWORK
94-
Array.Empty<Object3D>();
94+
Array.Empty<Object3D>();
9595
#else
96-
new Object3D[0];
96+
new Object3D[0];
9797
#endif
98-
foreach (var c in children)
99-
yield return c;
100-
}
98+
foreach (var c in children)
99+
yield return c;
101100
}
102101
}
103102
}

src/Geometries/BoxGeometry.cs

Lines changed: 56 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -4,74 +4,73 @@
44
using System.Text.Json.Serialization;
55
using Newtonsoft.Json;
66

7-
namespace CodeCave.Threejs.Entities
7+
namespace CodeCave.Threejs.Entities;
8+
9+
[Serializable]
10+
public sealed class BoxGeometry : Geometry, IEquatable<BoxGeometry>
811
{
9-
[Serializable]
10-
public sealed class BoxGeometry : Geometry, IEquatable<BoxGeometry>
12+
/// <summary>Initializes a new instance of the <see cref="BoxGeometry"/> class.</summary>
13+
/// <param name="uuid">The UUID of this object instance.</param>
14+
public BoxGeometry(string uuid, double width = 1D, double height = 1D, double depth = 1D)
15+
: base(uuid)
1116
{
12-
/// <summary>Initializes a new instance of the <see cref="BoxGeometry"/> class.</summary>
13-
/// <param name="uuid">The UUID of this object instance.</param>
14-
public BoxGeometry(string uuid, double width = 1D, double height = 1D, double depth = 1D)
15-
: base(uuid)
16-
{
17-
Width = width;
18-
Height = height;
19-
Depth = depth;
20-
}
17+
Width = width;
18+
Height = height;
19+
Depth = depth;
20+
}
2121

22-
[Newtonsoft.Json.JsonConstructor]
23-
[System.Text.Json.Serialization.JsonConstructor]
24-
private BoxGeometry()
25-
: base(Guid.NewGuid().ToString())
26-
{
27-
}
22+
[Newtonsoft.Json.JsonConstructor]
23+
[System.Text.Json.Serialization.JsonConstructor]
24+
private BoxGeometry()
25+
: base(Guid.NewGuid().ToString())
26+
{
27+
}
2828

29-
/// <summary>Gets the type of this object, it always equals 'BoxGeometry'.</summary>
30-
/// <value>The 'BoxGeometry' type.</value>
31-
[DataMember(Name = "type")]
32-
[JsonProperty("type")]
33-
[JsonPropertyName("type")]
29+
/// <summary>Gets the type of this object, it always equals 'BoxGeometry'.</summary>
30+
/// <value>The 'BoxGeometry' type.</value>
31+
[DataMember(Name = "type")]
32+
[JsonProperty("type")]
33+
[JsonPropertyName("type")]
3434

35-
public override string Type => nameof(BoxGeometry);
35+
public override string Type => nameof(BoxGeometry);
3636

37-
/// <summary>
38-
/// Gets or sets width — Width; that is, the length of the edges parallel to the X axis. Optional; defaults to 1.
39-
/// </summary>
40-
/// <value>The width.</value>
41-
[DataMember(Name = "width")]
42-
[JsonProperty("width")]
43-
[JsonPropertyName("width")]
44-
public double Width { get; set; }
37+
/// <summary>
38+
/// Gets or sets width — Width; that is, the length of the edges parallel to the X axis. Optional; defaults to 1.
39+
/// </summary>
40+
/// <value>The width.</value>
41+
[DataMember(Name = "width")]
42+
[JsonProperty("width")]
43+
[JsonPropertyName("width")]
44+
public double Width { get; set; }
4545

46-
/// <summary>
47-
/// Gets or sets height — Height; that is, the length of the edges parallel to the Y axis.Optional; defaults to 1.
48-
/// </summary>
49-
/// <value>The height.</value>
50-
[DataMember(Name = "height")]
51-
[JsonProperty("height")]
52-
[JsonPropertyName("height")]
53-
public double Height { get; set; }
46+
/// <summary>
47+
/// Gets or sets height — Height; that is, the length of the edges parallel to the Y axis.Optional; defaults to 1.
48+
/// </summary>
49+
/// <value>The height.</value>
50+
[DataMember(Name = "height")]
51+
[JsonProperty("height")]
52+
[JsonPropertyName("height")]
53+
public double Height { get; set; }
5454

55-
/// <summary>
56-
/// Gets or sets depth — Depth; that is, the length of the edges parallel to the Z axis.Optional; defaults to 1.
57-
/// </summary>
58-
/// <value>The depth.</value>
59-
[DataMember(Name = "depth")]
60-
[JsonProperty("depth")]
61-
[JsonPropertyName("depth")]
62-
public double Depth { get; set; }
55+
/// <summary>
56+
/// Gets or sets depth — Depth; that is, the length of the edges parallel to the Z axis.Optional; defaults to 1.
57+
/// </summary>
58+
/// <value>The depth.</value>
59+
[DataMember(Name = "depth")]
60+
[JsonProperty("depth")]
61+
[JsonPropertyName("depth")]
62+
public double Depth { get; set; }
6363

64-
[System.Text.Json.Serialization.JsonIgnore]
65-
[Newtonsoft.Json.JsonIgnore]
66-
public override GeometryData Data => null;
64+
[System.Text.Json.Serialization.JsonIgnore]
65+
[Newtonsoft.Json.JsonIgnore]
66+
public override GeometryData Data => null;
6767

68-
public override bool Equals(object obj) => obj is BoxGeometry geometry && Equals(geometry);
68+
public override bool Equals(object obj) => obj is BoxGeometry geometry && Equals(geometry);
6969

70-
public bool Equals(BoxGeometry other) => Uuid.Equals(other?.Uuid, StringComparison.OrdinalIgnoreCase);
70+
public bool Equals(BoxGeometry other) => Uuid.Equals(other?.Uuid, StringComparison.OrdinalIgnoreCase);
7171

72-
public override int GetHashCode()
73-
{
74-
return 2083305506 + EqualityComparer<string>.Default.GetHashCode(Uuid);
75-
}
72+
public override int GetHashCode()
73+
{
74+
return 2083305506 + EqualityComparer<string>.Default.GetHashCode(Uuid);
7675
}
7776
}

src/Geometries/BufferGeometry.cs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
using System;
22

3-
namespace CodeCave.Threejs.Entities
3+
namespace CodeCave.Threejs.Entities;
4+
5+
/// <summary>
6+
/// An efficient representation of mesh, line, or point geometry.
7+
/// Includes vertex positions, face indexes, normals, colors, UVs,
8+
/// and custom attributes within buffers, reducing the cost of passing all this data to the GPU.
9+
/// To read and edit data in BufferGeometry attributes, see BufferAttribute documentation.
10+
///
11+
/// For a less efficient but easier-to-use representation of geometry, see <see cref="Geometry"/>.
12+
/// </summary>
13+
[Serializable]
14+
public class BufferGeometry
415
{
5-
/// <summary>
6-
/// An efficient representation of mesh, line, or point geometry.
7-
/// Includes vertex positions, face indexes, normals, colors, UVs,
8-
/// and custom attributes within buffers, reducing the cost of passing all this data to the GPU.
9-
/// To read and edit data in BufferGeometry attributes, see BufferAttribute documentation.
10-
///
11-
/// For a less efficient but easier-to-use representation of geometry, see <see cref="Geometry"/>.
12-
/// </summary>
13-
[Serializable]
14-
public class BufferGeometry
16+
public BufferGeometry()
1517
{
16-
public BufferGeometry()
17-
{
18-
// TODO implement buffer geometry class and use it instead of Geometry
19-
throw new NotImplementedException("implement buffer geometry class and use it instead of Geometry");
20-
}
18+
// TODO implement buffer geometry class and use it instead of Geometry
19+
throw new NotImplementedException("implement buffer geometry class and use it instead of Geometry");
2120
}
2221
}

0 commit comments

Comments
 (0)