15832144755
2022-01-06 7b4c8991dca9cf2a809a95e239d144697d3afb56
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import Check from "../Core/Check.js";
 
/**
 * An enum describing the built-in instance attribute semantics.
 *
 * @enum {String}
 *
 * @private
 */
var InstanceAttributeSemantic = {
  /**
   * Per-instance translation.
   *
   * @type {String}
   * @constant
   */
  TRANSLATION: "TRANSLATION",
 
  /**
   * Per-instance rotation.
   *
   * @type {String}
   * @constant
   */
  ROTATION: "ROTATION",
 
  /**
   * Per-instance scale.
   *
   * @type {String}
   * @constant
   */
  SCALE: "SCALE",
 
  /**
   * Per-instance feature ID.
   *
   * @type {String}
   * @constant
   */
  FEATURE_ID: "FEATURE_ID",
};
 
/**
 * Gets the instance attribute semantic matching the glTF attribute semantic.
 *
 * @returns {InstanceAttributeSemantic} The instance attribute semantic, or undefined if there is no match.
 *
 * @private
 */
InstanceAttributeSemantic.fromGltfSemantic = function (gltfSemantic) {
  //>>includeStart('debug', pragmas.debug);
  Check.typeOf.string("gltfSemantic", gltfSemantic);
  //>>includeEnd('debug')
 
  var semantic = gltfSemantic;
 
  // Strip the set index from the semantic
  var setIndexRegex = /^(\w+)_\d+$/;
  var setIndexMatch = setIndexRegex.exec(gltfSemantic);
  if (setIndexMatch !== null) {
    semantic = setIndexMatch[1];
  }
 
  switch (semantic) {
    case "TRANSLATION":
      return InstanceAttributeSemantic.TRANSLATION;
    case "ROTATION":
      return InstanceAttributeSemantic.ROTATION;
    case "SCALE":
      return InstanceAttributeSemantic.SCALE;
    case "_FEATURE_ID":
    case "FEATURE_ID":
      // EXT_feature_metadata uses _FEATURE_ID, EXT_mesh_features drops the underscore
      return InstanceAttributeSemantic.FEATURE_ID;
  }
 
  return undefined;
};
 
export default Object.freeze(InstanceAttributeSemantic);