Skip to content

Commit e11c702

Browse files
committed
few fixes
1 parent 33e8c4e commit e11c702

File tree

11 files changed

+39
-30
lines changed

11 files changed

+39
-30
lines changed

Directory.Build.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22

33
<PropertyGroup>
4-
<LangVersion>8.0</LangVersion>
4+
<LangVersion>10.0</LangVersion>
55
<NetStandardVersion>netstandard2.1</NetStandardVersion>
66
<NetCoreAppVersion>netcoreapp3.1</NetCoreAppVersion>
77
</PropertyGroup>

Directory.Build.targets

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<None Remove="**\*.Cache" />
4343

4444
<!-- FxCop Analyzer-related configuration -->
45-
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0-beta*">
45+
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.*">
4646
<PrivateAssets>all</PrivateAssets>
4747
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
4848
</PackageReference>
@@ -54,7 +54,7 @@
5454
</PackageReference>
5555

5656
<!-- Sonar Analyzer-related configuration -->
57-
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.6.*">
57+
<PackageReference Include="SonarAnalyzer.CSharp" Version="[8.*, 9.0)">
5858
<PrivateAssets>all</PrivateAssets>
5959
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
6060
</PackageReference>

src/CodeCave.Threejs.Entities.csproj

+3-11
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,15 @@
1010

1111
<PropertyGroup>
1212
<IsPackable>true</IsPackable>
13-
<Version>0.7.0</Version>
14-
<FileVersion>0.7.0</FileVersion>
15-
<AssemblyVersion>0.7.0</AssemblyVersion>
13+
<Version>0.7.2</Version>
14+
<FileVersion>0.7.2</FileVersion>
15+
<AssemblyVersion>0.7.2</AssemblyVersion>
1616
<RepositoryType>git</RepositoryType>
1717
<PackageProjectUrl>https://github.com/CodeCavePro/threejs-entities.git</PackageProjectUrl>
1818
<RepositoryUrl>https://github.com/CodeCavePro/threejs-entities.git</RepositoryUrl>
1919
<PackageTags>nuget, package, library, three.js, revit, export</PackageTags>
2020
</PropertyGroup>
2121

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-
3022
<ItemGroup>
3123
<PackageReference Include="JsonSubTypes" Version="1.8.*" />
3224
<PackageReference Include="Newtonsoft.Json" Version="[10.0.1, 12.1)" />

src/Extensions/Object3DExtensions.cs

+9-3
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public static ObjectScene AddCube(this ObjectScene objectScene, double width, do
6969
};
7070
objectScene.AddMaterial(material);
7171

72-
var cubeObject = new Object3D("Mesh", Guid.NewGuid().ToString())
72+
var cubeObject = new Object3D("Mesh", Guid.NewGuid().ToString(), id: null)
7373
{
7474
CastShadow = true,
7575
ReceiveShadow = true,
@@ -86,10 +86,16 @@ internal static System.Collections.Generic.IEnumerable<Object3D> Flatten(this Sy
8686
{
8787
foreach (var obj in collection)
8888
{
89-
if (obj.Children.Count == 0)
89+
if ((obj?.Children?.Count ?? 0) == 0)
9090
yield return obj;
9191

92-
foreach (var c in obj.Children.Flatten())
92+
var children = obj?.Children?.Flatten() ??
93+
#if !NETFRAMEWORK
94+
Array.Empty<Object3D>();
95+
#else
96+
new Object3D[0];
97+
#endif
98+
foreach (var c in children)
9399
yield return c;
94100
}
95101
}

src/Geometries/BufferGeometry.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace CodeCave.Threejs.Entities
44
{
55
/// <summary>
66
/// An efficient representation of mesh, line, or point geometry.
7-
/// Includes vertex positions, face indices, normals, colors, UVs,
7+
/// Includes vertex positions, face indexes, normals, colors, UVs,
88
/// and custom attributes within buffers, reducing the cost of passing all this data to the GPU.
99
/// To read and edit data in BufferGeometry attributes, see BufferAttribute documentation.
1010
///

src/Geometries/Geometry.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public Geometry(string uuid)
5656
[JsonPropertyName("data")]
5757
public virtual GeometryData Data { get; internal set; }
5858

59-
/// <summary>Adds the point to the vertices.</summary>
59+
/// <summary>Adds the point to the vertexes.</summary>
6060
/// <param name="vertex">The vertex.</param>
6161
[SuppressMessage(
6262
"StyleCop.CSharp.OrderingRules",
@@ -72,7 +72,7 @@ public void AddPoint(Vector3 vertex)
7272
Data.Vertices.Add(vertex.Z);
7373
}
7474

75-
/// <summary>Adds the point to the vertices.</summary>
75+
/// <summary>Adds the point to the vertexes.</summary>
7676
/// <param name="x">The x coordinate.</param>
7777
/// <param name="y">The y coordinate.</param>
7878
/// <param name="z">The z coordinate.</param>
@@ -83,8 +83,8 @@ public void AddPoint(double x, double y, double z)
8383
Data.Vertices.Add(z);
8484
}
8585

86-
/// <summary>Adds a faces from its vertices.</summary>
87-
/// <param name="vertices">The vertices of a face.</param>
86+
/// <summary>Adds a faces from its vertexes.</summary>
87+
/// <param name="vertices">The vertexes of a face.</param>
8888
public void AddFace(params int[] vertices)
8989
{
9090
Data.Faces.AddRange(vertices);

src/Math/Color.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ public Color(int red, int green, int blue)
4848

4949
/// <summary>Initializes a new instance of the <see cref="Color"/> class.</summary>
5050
/// <param name="integerValue">The integer value.</param>
51-
[JsonConstructor]
51+
[Newtonsoft.Json.JsonConstructor]
52+
[System.Text.Json.Serialization.JsonConstructor]
5253
internal Color(int integerValue = 0)
5354
{
5455
this.integerValue = integerValue;

src/Objects/Group.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace CodeCave.Threejs.Entities
55
public class Group : Object3D
66
{
77
public Group(string uuid = null)
8-
: base(nameof(Group), uuid)
8+
: base(nameof(Group), uuid, id: null)
99
{
1010
}
1111
}

src/Objects/Object3D.cs

+9-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ namespace CodeCave.Threejs.Entities
2222
public class Object3D : IEquatable<Object3D>, IEqualityComparer<Object3D>
2323
{
2424
private List<Object3D> children;
25+
private double[] matrix;
2526

2627
/// <summary>Initializes a new instance of the <see cref="Object3D"/> class.</summary>
2728
/// <param name="type">The type of the object.</param>
@@ -89,9 +90,15 @@ public Object3D(string type = nameof(Object3D), string uuid = null, long? id = n
8990
/// The local transform matrix.
9091
/// </value>
9192
[DataMember(Name = "matrix")]
92-
[JsonProperty("matrix")]
93+
[JsonProperty("matrix", ObjectCreationHandling = ObjectCreationHandling.Replace)]
9394
[JsonPropertyName("matrix")]
94-
public ICollection<double> Matrix => new[]
95+
public double[] Matrix
96+
{
97+
get => matrix ?? (matrix = DefaultMatrix);
98+
private set => matrix = value ?? DefaultMatrix;
99+
}
100+
101+
public double[] DefaultMatrix => new[]
95102
{
96103
Scale?.X ?? 1D, 0D, 0D, 0D, // TODO implement rotation, quaternion
97104
0D, Scale?.Y ?? 1D, 0D, 0D,

src/Objects/Scene.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Runtime.Serialization;
23
using System.Text.Json.Serialization;
34
using Newtonsoft.Json;
@@ -16,15 +17,15 @@ public class Scene : Object3D
1617
/// <summary>Initializes a new instance of the <see cref="Scene"/> class.</summary>
1718
/// <param name="uuid">The unique identified of the object.</param>
1819
public Scene(string uuid)
19-
: base(nameof(Scene), uuid)
20+
: base(nameof(Scene), uuid, id: null)
2021
{
2122
}
2223

2324
/// <summary>Initializes a new instance of the <see cref="Scene"/> class.</summary>
2425
[Newtonsoft.Json.JsonConstructor]
2526
[System.Text.Json.Serialization.JsonConstructor]
2627
private Scene()
27-
: this(null)
28+
: this(uuid: Guid.NewGuid().ToString())
2829
{
2930
}
3031

src/Serialization/NewtonsoftJson/ColorIntConverter.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
2222

2323
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
2424
{
25-
var integerValue = (int)value;
26-
writer.WriteValue(integerValue);
25+
if (value is not Color)
26+
throw new NotImplementedException();
27+
28+
writer.WriteValue(((Color)value).ToInt32());
2729
}
2830
}
2931
}

0 commit comments

Comments
 (0)