@loaders.gl/gltf 4.0.0-alpha.22 → 4.0.0-alpha.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.min.js +3577 -3025
- package/dist/es5/index.js +21 -0
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/api/gltf-extensions.js +3 -1
- package/dist/es5/lib/api/gltf-extensions.js.map +1 -1
- package/dist/es5/lib/extensions/EXT_mesh_features.js +111 -0
- package/dist/es5/lib/extensions/EXT_mesh_features.js.map +1 -0
- package/dist/es5/lib/extensions/EXT_structural_metadata.js +386 -0
- package/dist/es5/lib/extensions/EXT_structural_metadata.js.map +1 -0
- package/dist/es5/lib/extensions/data-processing.js +181 -0
- package/dist/es5/lib/extensions/data-processing.js.map +1 -0
- package/dist/es5/lib/extensions/deprecated/EXT_feature_metadata.js +6 -9
- package/dist/es5/lib/extensions/deprecated/EXT_feature_metadata.js.map +1 -1
- package/dist/es5/lib/types/gltf-ext-mesh-features-schema.js +2 -0
- package/dist/es5/lib/types/gltf-ext-mesh-features-schema.js.map +1 -0
- package/dist/es5/lib/types/gltf-ext-structural-metadata-schema.js +2 -0
- package/dist/es5/lib/types/gltf-ext-structural-metadata-schema.js.map +1 -0
- package/dist/es5/lib/types/gltf-json-schema.js.map +1 -1
- package/dist/es5/lib/utils/version.js +1 -1
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/api/gltf-extensions.js +3 -1
- package/dist/esm/lib/api/gltf-extensions.js.map +1 -1
- package/dist/esm/lib/extensions/EXT_mesh_features.js +55 -0
- package/dist/esm/lib/extensions/EXT_mesh_features.js.map +1 -0
- package/dist/esm/lib/extensions/EXT_structural_metadata.js +320 -0
- package/dist/esm/lib/extensions/EXT_structural_metadata.js.map +1 -0
- package/dist/esm/lib/extensions/data-processing.js +146 -0
- package/dist/esm/lib/extensions/data-processing.js.map +1 -0
- package/dist/esm/lib/extensions/deprecated/EXT_feature_metadata.js +4 -7
- package/dist/esm/lib/extensions/deprecated/EXT_feature_metadata.js.map +1 -1
- package/dist/esm/lib/types/gltf-ext-mesh-features-schema.js +2 -0
- package/dist/esm/lib/types/gltf-ext-mesh-features-schema.js.map +1 -0
- package/dist/esm/lib/types/gltf-ext-structural-metadata-schema.js +2 -0
- package/dist/esm/lib/types/gltf-ext-structural-metadata-schema.js.map +1 -0
- package/dist/esm/lib/types/gltf-json-schema.js.map +1 -1
- package/dist/esm/lib/utils/version.js +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/lib/api/gltf-extensions.d.ts.map +1 -1
- package/dist/lib/api/gltf-extensions.js +5 -0
- package/dist/lib/extensions/EXT_mesh_features.d.ts +7 -0
- package/dist/lib/extensions/EXT_mesh_features.d.ts.map +1 -0
- package/dist/lib/extensions/EXT_mesh_features.js +89 -0
- package/dist/lib/extensions/EXT_structural_metadata.d.ts +17 -0
- package/dist/lib/extensions/EXT_structural_metadata.d.ts.map +1 -0
- package/dist/lib/extensions/EXT_structural_metadata.js +504 -0
- package/dist/lib/extensions/data-processing.d.ts +34 -0
- package/dist/lib/extensions/data-processing.d.ts.map +1 -0
- package/dist/lib/extensions/data-processing.js +212 -0
- package/dist/lib/extensions/deprecated/EXT_feature_metadata.d.ts.map +1 -1
- package/dist/lib/extensions/deprecated/EXT_feature_metadata.js +8 -17
- package/dist/lib/types/gltf-ext-mesh-features-schema.d.ts +45 -0
- package/dist/lib/types/gltf-ext-mesh-features-schema.d.ts.map +1 -0
- package/dist/lib/types/gltf-ext-mesh-features-schema.js +2 -0
- package/dist/lib/types/gltf-ext-structural-metadata-schema.d.ts +310 -0
- package/dist/lib/types/gltf-ext-structural-metadata-schema.d.ts.map +1 -0
- package/dist/lib/types/gltf-ext-structural-metadata-schema.js +2 -0
- package/dist/lib/types/gltf-json-schema.d.ts +11 -57
- package/dist/lib/types/gltf-json-schema.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/index.ts +11 -3
- package/src/lib/api/gltf-extensions.ts +6 -2
- package/src/lib/extensions/EXT_mesh_features.ts +117 -0
- package/src/lib/extensions/EXT_structural_metadata.ts +730 -0
- package/src/lib/extensions/data-processing.ts +264 -0
- package/src/lib/extensions/deprecated/EXT_feature_metadata.ts +6 -17
- package/src/lib/types/gltf-ext-mesh-features-schema.ts +48 -0
- package/src/lib/types/gltf-ext-structural-metadata-schema.ts +357 -0
- package/src/lib/types/gltf-json-schema.ts +12 -60
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import type {GLTFTextureInfoMetadata, GLTFMeshPrimitive} from '../types/gltf-json-schema';
|
|
2
|
+
import type {TypedArray} from '@loaders.gl/schema';
|
|
3
|
+
import type {ImageType} from '@loaders.gl/images';
|
|
4
|
+
|
|
5
|
+
import {GLTFScenegraph} from '../api/gltf-scenegraph';
|
|
6
|
+
import {getComponentTypeFromArray} from '../gltf-utils/gltf-utils';
|
|
7
|
+
import {getImageData} from '@loaders.gl/images';
|
|
8
|
+
import {emod} from '@loaders.gl/math';
|
|
9
|
+
|
|
10
|
+
const ATTRIBUTE_TYPE_TO_COMPONENTS = {
|
|
11
|
+
SCALAR: 1,
|
|
12
|
+
VEC2: 2,
|
|
13
|
+
VEC3: 3,
|
|
14
|
+
VEC4: 4,
|
|
15
|
+
MAT2: 4,
|
|
16
|
+
MAT3: 9,
|
|
17
|
+
MAT4: 16,
|
|
18
|
+
BOOLEAN: 1,
|
|
19
|
+
STRING: 1,
|
|
20
|
+
ENUM: 1
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY = {
|
|
24
|
+
INT8: Int8Array,
|
|
25
|
+
UINT8: Uint8Array,
|
|
26
|
+
INT16: Int16Array,
|
|
27
|
+
UINT16: Uint16Array,
|
|
28
|
+
INT32: Int32Array,
|
|
29
|
+
UINT32: Uint32Array,
|
|
30
|
+
INT64: BigInt64Array,
|
|
31
|
+
UINT64: BigUint64Array,
|
|
32
|
+
FLOAT32: Float32Array,
|
|
33
|
+
FLOAT64: Float64Array
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE = {
|
|
37
|
+
INT8: 1,
|
|
38
|
+
UINT8: 1,
|
|
39
|
+
INT16: 2,
|
|
40
|
+
UINT16: 2,
|
|
41
|
+
INT32: 4,
|
|
42
|
+
UINT32: 4,
|
|
43
|
+
INT64: 8,
|
|
44
|
+
UINT64: 8,
|
|
45
|
+
FLOAT32: 4,
|
|
46
|
+
FLOAT64: 8
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export function getArrayElementByteSize(attributeType, componentType): number {
|
|
50
|
+
return (
|
|
51
|
+
ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE[componentType] *
|
|
52
|
+
ATTRIBUTE_TYPE_TO_COMPONENTS[attributeType]
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Converts raw bytes that are in the buffer to an array of the type defined by the schema.
|
|
58
|
+
* @param {Uint8Array} typedArray - raw bytes in the buffer
|
|
59
|
+
* @param {string} attributeType - SCALAR, VECN, MATN
|
|
60
|
+
* @param {string} componentType - type of the component in elements, e.g. 'UINT8' or 'FLOAT32'
|
|
61
|
+
* @param {number} elementCount - number of elements in the array. Default value is 1.
|
|
62
|
+
* @returns {TypedArray} Data array
|
|
63
|
+
*/
|
|
64
|
+
export function convertRawBufferToMetadataArray(
|
|
65
|
+
typedArray: Uint8Array,
|
|
66
|
+
attributeType: string,
|
|
67
|
+
componentType: string,
|
|
68
|
+
elementCount: number = 1
|
|
69
|
+
): TypedArray {
|
|
70
|
+
const numberOfComponents = ATTRIBUTE_TYPE_TO_COMPONENTS[attributeType];
|
|
71
|
+
const ArrayType = ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY[componentType];
|
|
72
|
+
const length = elementCount * numberOfComponents;
|
|
73
|
+
const size = ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE[componentType];
|
|
74
|
+
// the buffer view `byteOffset` must be aligned to a multiple of the `componentType` size.
|
|
75
|
+
const offset =
|
|
76
|
+
typedArray.byteOffset % size
|
|
77
|
+
? Math.ceil(typedArray.byteOffset / size) * size
|
|
78
|
+
: typedArray.byteOffset;
|
|
79
|
+
return new ArrayType(typedArray.buffer, offset, length);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Processes data encoded in the texture associated with the primitive.
|
|
84
|
+
* If Ext_mesh_featues is combined with the Ext_structural_metadata, propertyTable will also be processed.
|
|
85
|
+
* @param {GLTFScenegraph} scenegraph - Instance of the class for structured access to GLTF data.
|
|
86
|
+
* @param {GLTFTextureInfoMetadata} textureInfo - reference to the texture where extension data are stored.
|
|
87
|
+
* @param {GLTFMeshPrimitive} primitive - primitive object in the mesh
|
|
88
|
+
* @returns {number[] | null} Array of data taken. Null if data can't be taken from the texture.
|
|
89
|
+
*/
|
|
90
|
+
export function getPrimitiveTextureData(
|
|
91
|
+
scenegraph: GLTFScenegraph,
|
|
92
|
+
textureInfo: GLTFTextureInfoMetadata,
|
|
93
|
+
primitive: GLTFMeshPrimitive
|
|
94
|
+
): number[] | null {
|
|
95
|
+
/*
|
|
96
|
+
texture.index is an index for the "textures" array.
|
|
97
|
+
The texture object referenced by this index looks like this:
|
|
98
|
+
{
|
|
99
|
+
"sampler": 0,
|
|
100
|
+
"source": 0
|
|
101
|
+
}
|
|
102
|
+
"sampler" is an index for the "samplers" array
|
|
103
|
+
"source" is an index for the "images" array that contains data. These data are stored in rgba channels of the image.
|
|
104
|
+
|
|
105
|
+
texture.texCoord is a number-suffix (like 1) for an attribute like "TEXCOORD_1" in meshes.primitives
|
|
106
|
+
The value of "TEXCOORD_1" is an accessor that is used to get coordinates. These coordinates are being used to get data from the image.
|
|
107
|
+
*/
|
|
108
|
+
const json = scenegraph.gltf.json;
|
|
109
|
+
|
|
110
|
+
const texCoordAccessorKey = `TEXCOORD_${textureInfo.texCoord || 0}`;
|
|
111
|
+
const texCoordAccessorIndex = primitive.attributes[texCoordAccessorKey];
|
|
112
|
+
const texCoordBufferView = scenegraph.getBufferView(texCoordAccessorIndex);
|
|
113
|
+
const texCoordArray: Uint8Array = scenegraph.getTypedArrayForBufferView(texCoordBufferView);
|
|
114
|
+
|
|
115
|
+
// textureCoordinates array contains UV coordinates of the actual data stored in the texture
|
|
116
|
+
const textureCoordinates: Float32Array = new Float32Array(
|
|
117
|
+
texCoordArray.buffer,
|
|
118
|
+
texCoordArray.byteOffset,
|
|
119
|
+
texCoordArray.length / 4
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
const textureIndex: number = textureInfo.index;
|
|
123
|
+
const imageIndex = json.textures?.[textureIndex]?.source;
|
|
124
|
+
if (typeof imageIndex !== 'undefined') {
|
|
125
|
+
const mimeType = json.images?.[imageIndex]?.mimeType;
|
|
126
|
+
const parsedImage = scenegraph.gltf.images?.[imageIndex];
|
|
127
|
+
// Checking for width is to prevent handling Un-processed images (e.g. [analyze] stage, where loadImages option is set to false)
|
|
128
|
+
if (parsedImage && typeof parsedImage.width !== 'undefined') {
|
|
129
|
+
const textureData: number[] = [];
|
|
130
|
+
for (let index = 0; index < textureCoordinates.length; index += 2) {
|
|
131
|
+
const value = getImageValueByCoordinates(
|
|
132
|
+
parsedImage,
|
|
133
|
+
mimeType,
|
|
134
|
+
textureCoordinates,
|
|
135
|
+
index,
|
|
136
|
+
textureInfo.channels
|
|
137
|
+
);
|
|
138
|
+
textureData.push(value);
|
|
139
|
+
}
|
|
140
|
+
return textureData;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Puts property data to attributes.
|
|
148
|
+
* It creates corresponding buffer, bufferView and accessor
|
|
149
|
+
* so the data can be accessed like regular data stored in buffers.
|
|
150
|
+
* @param {GLTFScenegraph} scenegraph - scenegraph object
|
|
151
|
+
* @param {string} attributeName - name of the attribute
|
|
152
|
+
* @param {number[]} propertyData - property data to store
|
|
153
|
+
* @param {number[]} featureTable - an array where unique data from the property data are being stored
|
|
154
|
+
* @param {GLTFMeshPrimitive} primitive - primitive object
|
|
155
|
+
*/
|
|
156
|
+
export function primitivePropertyDataToAttributes(
|
|
157
|
+
scenegraph: GLTFScenegraph,
|
|
158
|
+
attributeName: string,
|
|
159
|
+
propertyData: number[],
|
|
160
|
+
featureTable: number[],
|
|
161
|
+
primitive: GLTFMeshPrimitive
|
|
162
|
+
): void {
|
|
163
|
+
if (propertyData === null) return;
|
|
164
|
+
/*
|
|
165
|
+
featureTable will contain unique values, e.g.
|
|
166
|
+
propertyData = [24, 35, 28, 24]
|
|
167
|
+
featureTable = [24, 35, 28]
|
|
168
|
+
featureIndices will contain indices that refer featureTextureTable, e.g.
|
|
169
|
+
featureIndices = [0, 1, 2, 0]
|
|
170
|
+
*/
|
|
171
|
+
const featureIndices: number[] = [];
|
|
172
|
+
for (const texelData of propertyData) {
|
|
173
|
+
let index = featureTable.findIndex((item) => item === texelData);
|
|
174
|
+
if (index === -1) {
|
|
175
|
+
index = featureTable.push(texelData) - 1;
|
|
176
|
+
}
|
|
177
|
+
featureIndices.push(index);
|
|
178
|
+
}
|
|
179
|
+
const typedArray = new Uint32Array(featureIndices);
|
|
180
|
+
const bufferIndex =
|
|
181
|
+
scenegraph.gltf.buffers.push({
|
|
182
|
+
arrayBuffer: typedArray.buffer,
|
|
183
|
+
byteOffset: typedArray.byteOffset,
|
|
184
|
+
byteLength: typedArray.byteLength
|
|
185
|
+
}) - 1;
|
|
186
|
+
const bufferViewIndex = scenegraph.addBufferView(typedArray, bufferIndex, 0);
|
|
187
|
+
const accessorIndex = scenegraph.addAccessor(bufferViewIndex, {
|
|
188
|
+
size: 1,
|
|
189
|
+
componentType: getComponentTypeFromArray(typedArray),
|
|
190
|
+
count: typedArray.length
|
|
191
|
+
});
|
|
192
|
+
primitive.attributes[attributeName] = accessorIndex;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Gets the value from the texture by coordinates provided.
|
|
197
|
+
* @param {ImageType} parsedImage - image where the data are stored.
|
|
198
|
+
* @param {string | undefined} mimeType - MIME type
|
|
199
|
+
* @param {Float32Array} textureCoordinates - uv coordinates to access data in the image.
|
|
200
|
+
* @param {number} index - index of uv coordinates in the array textureCoordinates
|
|
201
|
+
* @param {channels} channels - image channels where data are stored. Channels of an RGBA texture are numbered 0..3 respectively.
|
|
202
|
+
* @returns {number} Value taken from the image.
|
|
203
|
+
*/
|
|
204
|
+
function getImageValueByCoordinates(
|
|
205
|
+
parsedImage: ImageType,
|
|
206
|
+
mimeType: string | undefined,
|
|
207
|
+
textureCoordinates: Float32Array,
|
|
208
|
+
index: number,
|
|
209
|
+
channels: number[] = [0]
|
|
210
|
+
) {
|
|
211
|
+
const CHANNELS_MAP = [
|
|
212
|
+
{offset: 0, shift: 0},
|
|
213
|
+
{offset: 1, shift: 8},
|
|
214
|
+
{offset: 2, shift: 16},
|
|
215
|
+
{offset: 3, shift: 24}
|
|
216
|
+
];
|
|
217
|
+
|
|
218
|
+
const u = textureCoordinates[index];
|
|
219
|
+
const v = textureCoordinates[index + 1];
|
|
220
|
+
|
|
221
|
+
let components = 1;
|
|
222
|
+
if (mimeType && (mimeType.indexOf('image/jpeg') !== -1 || mimeType.indexOf('image/png') !== -1))
|
|
223
|
+
components = 4;
|
|
224
|
+
const offset = coordinatesToOffset(u, v, parsedImage, components);
|
|
225
|
+
let value: number = 0;
|
|
226
|
+
for (const c of channels) {
|
|
227
|
+
const map = CHANNELS_MAP[c];
|
|
228
|
+
const imageOffset = offset + map.offset;
|
|
229
|
+
const imageData = getImageData(parsedImage);
|
|
230
|
+
if (imageData.data.length <= imageOffset) {
|
|
231
|
+
throw new Error(`${imageData.data.length} <= ${imageOffset}`);
|
|
232
|
+
}
|
|
233
|
+
const imageValue = imageData.data[imageOffset];
|
|
234
|
+
value |= imageValue << map.shift;
|
|
235
|
+
}
|
|
236
|
+
return value;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Retrieves the offset in the image where the data are stored
|
|
241
|
+
* @param u - u-coordinate
|
|
242
|
+
* @param v - v-coordinate
|
|
243
|
+
* @param parsedImage - image where the data are stored
|
|
244
|
+
* @param componentsCount - number of components the data consists of.
|
|
245
|
+
* @returns offset in the image where the data are stored
|
|
246
|
+
*/
|
|
247
|
+
function coordinatesToOffset(
|
|
248
|
+
u: number,
|
|
249
|
+
v: number,
|
|
250
|
+
parsedImage: any,
|
|
251
|
+
componentsCount: number = 1
|
|
252
|
+
): number {
|
|
253
|
+
const w = parsedImage.width;
|
|
254
|
+
const iX = emod(u) * (w - 1);
|
|
255
|
+
const indX = Math.round(iX);
|
|
256
|
+
|
|
257
|
+
const h = parsedImage.height;
|
|
258
|
+
const iY = emod(v) * (h - 1);
|
|
259
|
+
const indY = Math.round(iY);
|
|
260
|
+
const components = parsedImage.components ? parsedImage.components : componentsCount;
|
|
261
|
+
// components is a number of channels in the image
|
|
262
|
+
const offset = (indY * w + indX) * components;
|
|
263
|
+
return offset;
|
|
264
|
+
}
|
|
@@ -14,11 +14,11 @@ import {getImageData} from '@loaders.gl/images';
|
|
|
14
14
|
import {GLTFMeshPrimitive} from '../../types/gltf-json-schema';
|
|
15
15
|
import {getComponentTypeFromArray} from '../../gltf-utils/gltf-utils';
|
|
16
16
|
import {GLTFLoaderOptions} from '../../../gltf-loader';
|
|
17
|
+
import {emod} from '@loaders.gl/math';
|
|
17
18
|
|
|
18
19
|
/** Extension name */
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
export const name = EXT_FEATURE_METADATA;
|
|
20
|
+
const EXT_FEATURE_METADATA_NAME = 'EXT_feature_metadata';
|
|
21
|
+
export const name = EXT_FEATURE_METADATA_NAME;
|
|
22
22
|
|
|
23
23
|
export async function decode(gltfData: {json: GLTF}, options: GLTFLoaderOptions): Promise<void> {
|
|
24
24
|
const scenegraph = new GLTFScenegraph(gltfData);
|
|
@@ -31,7 +31,7 @@ export async function decode(gltfData: {json: GLTF}, options: GLTFLoaderOptions)
|
|
|
31
31
|
*/
|
|
32
32
|
function decodeExtFeatureMetadata(scenegraph: GLTFScenegraph, options: GLTFLoaderOptions): void {
|
|
33
33
|
const extension: GLTF_EXT_feature_metadata_GLTF | null =
|
|
34
|
-
scenegraph.getExtension(
|
|
34
|
+
scenegraph.getExtension(EXT_FEATURE_METADATA_NAME);
|
|
35
35
|
if (!extension) return;
|
|
36
36
|
|
|
37
37
|
const schemaClasses = extension.schema?.classes;
|
|
@@ -62,7 +62,7 @@ function decodeExtFeatureMetadata(scenegraph: GLTFScenegraph, options: GLTFLoade
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
|
-
*
|
|
65
|
+
* Navigates through all properies in feature table and gets properties data.
|
|
66
66
|
* @param scenegraph
|
|
67
67
|
* @param featureTable
|
|
68
68
|
* @param schemaClass
|
|
@@ -90,7 +90,7 @@ function handleFeatureTableProperties(
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
|
-
*
|
|
93
|
+
* Navigates through all properies in feature texture and gets properties data.
|
|
94
94
|
* Data will be stored in featureTexture.properties[propertyName].data
|
|
95
95
|
* @param scenegraph
|
|
96
96
|
* @param featureTexture
|
|
@@ -327,17 +327,6 @@ function coordinatesToOffset(
|
|
|
327
327
|
return offset;
|
|
328
328
|
}
|
|
329
329
|
|
|
330
|
-
// The following is taken from tile-converter\src\i3s-converter\helpers\batch-ids-extensions.ts
|
|
331
|
-
/**
|
|
332
|
-
* Handle UVs if they are out of range [0,1].
|
|
333
|
-
* @param n
|
|
334
|
-
* @param m
|
|
335
|
-
*/
|
|
336
|
-
function emod(n: number): number {
|
|
337
|
-
const a = ((n % 1) + 1) % 1;
|
|
338
|
-
return a;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
330
|
/**
|
|
342
331
|
* Find the feature table by class name.
|
|
343
332
|
* @param featureTables
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {GLTFTextureInfoMetadata} from './gltf-json-schema';
|
|
2
|
+
/* eslint-disable camelcase */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* EXT_mesh_features extension types
|
|
6
|
+
* This is a primitive-level extension
|
|
7
|
+
* @see https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_mesh_features
|
|
8
|
+
* or https://github.com/CesiumGS/glTF/blob/c38f7f37e894004353c15cd0481bc5b7381ce841/extensions/2.0/Vendor/EXT_mesh_features/schema/mesh.primitive.EXT_mesh_features.schema.json
|
|
9
|
+
* An object describing feature IDs for a mesh primitive.
|
|
10
|
+
*/
|
|
11
|
+
export type GLTF_EXT_mesh_features = {
|
|
12
|
+
/** An array of feature ID sets. */
|
|
13
|
+
featureIds: GLTF_EXT_mesh_features_featureId[];
|
|
14
|
+
extensions?: Record<string, unknown>;
|
|
15
|
+
extras?: unknown;
|
|
16
|
+
/** For internal usage */
|
|
17
|
+
dataAttributeNames?: string[];
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @see https://github.com/CesiumGS/glTF/blob/c38f7f37e894004353c15cd0481bc5b7381ce841/extensions/2.0/Vendor/EXT_mesh_features/schema/featureId.schema.json
|
|
22
|
+
* Feature IDs stored in an attribute or texture.
|
|
23
|
+
*/
|
|
24
|
+
export type GLTF_EXT_mesh_features_featureId = {
|
|
25
|
+
/** The number of unique features in the attribute or texture. */
|
|
26
|
+
featureCount: number;
|
|
27
|
+
/** A value that indicates that no feature is associated with this vertex or texel. */
|
|
28
|
+
nullFeatureId?: number;
|
|
29
|
+
/** A label assigned to this feature ID set. Labels must be alphanumeric identifiers matching the regular expression `^[a-zA-Z_][a-zA-Z0-9_]*$`. */
|
|
30
|
+
label?: string;
|
|
31
|
+
/**
|
|
32
|
+
* An attribute containing feature IDs.
|
|
33
|
+
* When `attribute` and `texture` are omitted the feature IDs are assigned to vertices by their index.
|
|
34
|
+
* @see https://github.com/CesiumGS/glTF/blob/3d-tiles-next/extensions/2.0/Vendor/EXT_mesh_features/schema/featureIdAttribute.schema.json
|
|
35
|
+
* An integer value used to construct a string in the format `_FEATURE_ID_<set index>` which is a reference to a key in `mesh.primitives.attributes`
|
|
36
|
+
* (e.g. a value of `0` corresponds to `_FEATURE_ID_0`).
|
|
37
|
+
*/
|
|
38
|
+
attribute?: number;
|
|
39
|
+
/** A texture containing feature IDs. */
|
|
40
|
+
texture?: GLTFTextureInfoMetadata;
|
|
41
|
+
/** The index of the property table containing per-feature property values. Only applicable when using the `EXT_structural_metadata` extension. */
|
|
42
|
+
propertyTable?: number;
|
|
43
|
+
extensions?: Record<string, unknown>;
|
|
44
|
+
extras?: unknown;
|
|
45
|
+
|
|
46
|
+
/** For internal usage */
|
|
47
|
+
data?: unknown;
|
|
48
|
+
};
|