Cesium for Unity 1.15.2
Loading...
Searching...
No Matches
CesiumFeatureIdSet.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4
5namespace CesiumForUnity
6{
11 {
12 None,
14 Texture,
16 }
17
24 public class CesiumFeatureIdSet : IDisposable
25 {
26 #region Getters
27
32 {
33 get; protected set;
34 }
35
41 {
42 get; internal set;
43 }
44
49 {
50 get; internal set;
51 }
52
62 {
63 get; internal set;
64 }
65
75 {
76 get; internal set;
77 }
78
79 #endregion
80
81 #region Constructors
82
83 internal CesiumFeatureIdSet() : this(0)
84 { }
85
86 internal CesiumFeatureIdSet(Int64 featureCount)
87 {
88 this.type = featureCount > 0 ? CesiumFeatureIdSetType.Implicit : CesiumFeatureIdSetType.None;
89 this.featureCount = featureCount;
90 this.label = "";
91 this.nullFeatureId = -1;
92 this.propertyTableIndex = -1;
93 }
94
95 #endregion
96
97 #region Public methods
110 public virtual Int64 GetFeatureIdForVertex(Int64 vertexIndex)
111 {
112 if (this.type != CesiumFeatureIdSetType.Implicit)
113 {
114 // Other methods should be handled by CesiumFeatureIdAttribute and
115 // CesiumFeatureIdTexture respectively.
116 return -1;
117 }
118
119 if (vertexIndex < 0 || vertexIndex >= this.featureCount)
120 {
121 return -1;
122 }
123
124 return vertexIndex;
125 }
126
144 public virtual Int64 GetFeatureIdFromRaycastHit(RaycastHit hitInfo)
145 {
146 if (this.type != CesiumFeatureIdSetType.Implicit)
147 {
148 // Other methods should be handled by CesiumFeatureIdAttribute and
149 // CesiumFeatureIdTexture respectively.
150 return -1;
151 }
152
153
155 }
156
157 #endregion
158
159 // Cache the list of indices to prevent the allocation of a new array every time
160 // GetFirstVertexFromHitTriangle is called.
161 List<int> _indices;
162
163 public virtual void Dispose() { }
164 }
165}
Represents a feature ID set from a glTF primitive.
virtual Int64 GetFeatureIdForVertex(Int64 vertexIndex)
Gets the feature ID associated with a given vertex.
Int64 featureCount
The number of features this primitive has.
virtual Int64 GetFeatureIdFromRaycastHit(RaycastHit hitInfo)
Gets the feature ID from the feature ID set using the given raycast hit.
CesiumFeatureIdSetType type
The type of this feature ID set.
Int64 propertyTableIndex
The index of the property table corresponding to this feature ID set.
Int64 nullFeatureId
The null feature ID, i.e., the value that indicates no feature is associated with the owner....
String label
The label assigned to this feature ID set.
Represents the EXT_mesh_features of a glTF primitive in a Cesium3DTileset.
static int GetFirstVertexFromHitTriangle(RaycastHit hitInfo)
Given a successful raycast hit, finds the index of the first vertex from the hit triangle.
CesiumFeatureIdSetType
The type of a feature ID set.