three-stdlib 2.29.12 → 2.30.1

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.
@@ -1,6 +1,10 @@
1
- import { Loader, LoaderUtils, FileLoader, Color, SpotLight, PointLight, DirectionalLight, MeshBasicMaterial, MeshPhysicalMaterial, Vector2, Matrix4, Vector3, Quaternion, InstancedMesh, Object3D, TextureLoader, ImageBitmapLoader, BufferAttribute, InterleavedBuffer, InterleavedBufferAttribute, LinearFilter, LinearMipmapLinearFilter, RepeatWrapping, PointsMaterial, Material, LineBasicMaterial, MeshStandardMaterial, DoubleSide, PropertyBinding, BufferGeometry, SkinnedMesh, Mesh, TriangleStripDrawMode, TriangleFanDrawMode, LineSegments, Line, LineLoop, Points, Group, PerspectiveCamera, MathUtils, OrthographicCamera, Skeleton, InterpolateLinear, AnimationClip, Bone, NearestFilter, NearestMipmapNearestFilter, LinearMipmapNearestFilter, NearestMipmapLinearFilter, ClampToEdgeWrapping, MirroredRepeatWrapping, InterpolateDiscrete, FrontSide, Texture, VectorKeyframeTrack, QuaternionKeyframeTrack, NumberKeyframeTrack, Box3, Sphere, Interpolant } from "three";
1
+ import { Loader, LoaderUtils, FileLoader, Color, SpotLight, PointLight, DirectionalLight, MeshBasicMaterial, MeshPhysicalMaterial, Vector2, Matrix4, Vector3, Quaternion, InstancedMesh, InstancedBufferAttribute, Object3D, TextureLoader, ImageBitmapLoader, BufferAttribute, InterleavedBuffer, InterleavedBufferAttribute, LinearFilter, LinearMipmapLinearFilter, RepeatWrapping, PointsMaterial, Material, LineBasicMaterial, MeshStandardMaterial, DoubleSide, PropertyBinding, BufferGeometry, SkinnedMesh, Mesh, TriangleStripDrawMode, TriangleFanDrawMode, LineSegments, Line, LineLoop, Points, Group, PerspectiveCamera, MathUtils, OrthographicCamera, Skeleton, AnimationClip, Bone, InterpolateLinear, NearestFilter, NearestMipmapNearestFilter, LinearMipmapNearestFilter, NearestMipmapLinearFilter, ClampToEdgeWrapping, MirroredRepeatWrapping, InterpolateDiscrete, FrontSide, Texture, VectorKeyframeTrack, NumberKeyframeTrack, QuaternionKeyframeTrack, Box3, Sphere, Interpolant } from "three";
2
2
  import { toTrianglesDrawMode } from "../utils/BufferGeometryUtils.js";
3
3
  import { version } from "../_polyfill/constants.js";
4
+ const SRGBColorSpace = "srgb";
5
+ const LinearSRGBColorSpace = "srgb-linear";
6
+ const sRGBEncoding = 3001;
7
+ const LinearEncoding = 3e3;
4
8
  class GLTFLoader extends Loader {
5
9
  constructor(manager) {
6
10
  super(manager);
@@ -11,6 +15,9 @@ class GLTFLoader extends Loader {
11
15
  this.register(function(parser) {
12
16
  return new GLTFMaterialsClearcoatExtension(parser);
13
17
  });
18
+ this.register(function(parser) {
19
+ return new GLTFMaterialsDispersionExtension(parser);
20
+ });
14
21
  this.register(function(parser) {
15
22
  return new GLTFTextureBasisUExtension(parser);
16
23
  });
@@ -44,6 +51,9 @@ class GLTFLoader extends Loader {
44
51
  this.register(function(parser) {
45
52
  return new GLTFMaterialsAnisotropyExtension(parser);
46
53
  });
54
+ this.register(function(parser) {
55
+ return new GLTFMaterialsBumpExtension(parser);
56
+ });
47
57
  this.register(function(parser) {
48
58
  return new GLTFLightsExtension(parser);
49
59
  });
@@ -60,7 +70,8 @@ class GLTFLoader extends Loader {
60
70
  if (this.resourcePath !== "") {
61
71
  resourcePath = this.resourcePath;
62
72
  } else if (this.path !== "") {
63
- resourcePath = this.path;
73
+ const relativeUrl = LoaderUtils.extractUrlBase(url);
74
+ resourcePath = LoaderUtils.resolveURL(relativeUrl, this.path);
64
75
  } else {
65
76
  resourcePath = LoaderUtils.extractUrlBase(url);
66
77
  }
@@ -166,6 +177,8 @@ class GLTFLoader extends Loader {
166
177
  parser.fileLoader.setRequestHeader(this.requestHeader);
167
178
  for (let i = 0; i < this.pluginCallbacks.length; i++) {
168
179
  const plugin = this.pluginCallbacks[i](parser);
180
+ if (!plugin.name)
181
+ console.error("THREE.GLTFLoader: Invalid plugin found: missing name");
169
182
  plugins[plugin.name] = plugin;
170
183
  extensions[plugin.name] = true;
171
184
  }
@@ -226,6 +239,7 @@ const EXTENSIONS = {
226
239
  KHR_DRACO_MESH_COMPRESSION: "KHR_draco_mesh_compression",
227
240
  KHR_LIGHTS_PUNCTUAL: "KHR_lights_punctual",
228
241
  KHR_MATERIALS_CLEARCOAT: "KHR_materials_clearcoat",
242
+ KHR_MATERIALS_DISPERSION: "KHR_materials_dispersion",
229
243
  KHR_MATERIALS_IOR: "KHR_materials_ior",
230
244
  KHR_MATERIALS_SHEEN: "KHR_materials_sheen",
231
245
  KHR_MATERIALS_SPECULAR: "KHR_materials_specular",
@@ -238,6 +252,7 @@ const EXTENSIONS = {
238
252
  KHR_TEXTURE_TRANSFORM: "KHR_texture_transform",
239
253
  KHR_MESH_QUANTIZATION: "KHR_mesh_quantization",
240
254
  KHR_MATERIALS_EMISSIVE_STRENGTH: "KHR_materials_emissive_strength",
255
+ EXT_MATERIALS_BUMP: "EXT_materials_bump",
241
256
  EXT_TEXTURE_WEBP: "EXT_texture_webp",
242
257
  EXT_TEXTURE_AVIF: "EXT_texture_avif",
243
258
  EXT_MESHOPT_COMPRESSION: "EXT_meshopt_compression",
@@ -272,7 +287,7 @@ class GLTFLightsExtension {
272
287
  let lightNode;
273
288
  const color = new Color(16777215);
274
289
  if (lightDef.color !== void 0)
275
- color.fromArray(lightDef.color);
290
+ color.setRGB(lightDef.color[0], lightDef.color[1], lightDef.color[2], LinearSRGBColorSpace);
276
291
  const range = lightDef.range !== void 0 ? lightDef.range : 0;
277
292
  switch (lightDef.type) {
278
293
  case "directional":
@@ -342,11 +357,11 @@ class GLTFMaterialsUnlitExtension {
342
357
  if (metallicRoughness) {
343
358
  if (Array.isArray(metallicRoughness.baseColorFactor)) {
344
359
  const array = metallicRoughness.baseColorFactor;
345
- materialParams.color.fromArray(array);
360
+ materialParams.color.setRGB(array[0], array[1], array[2], LinearSRGBColorSpace);
346
361
  materialParams.opacity = array[3];
347
362
  }
348
363
  if (metallicRoughness.baseColorTexture !== void 0) {
349
- pending.push(parser.assignTexture(materialParams, "map", metallicRoughness.baseColorTexture, 3001));
364
+ pending.push(parser.assignTexture(materialParams, "map", metallicRoughness.baseColorTexture, SRGBColorSpace));
350
365
  }
351
366
  }
352
367
  return Promise.all(pending);
@@ -412,6 +427,29 @@ class GLTFMaterialsClearcoatExtension {
412
427
  return Promise.all(pending);
413
428
  }
414
429
  }
430
+ class GLTFMaterialsDispersionExtension {
431
+ constructor(parser) {
432
+ this.parser = parser;
433
+ this.name = EXTENSIONS.KHR_MATERIALS_DISPERSION;
434
+ }
435
+ getMaterialType(materialIndex) {
436
+ const parser = this.parser;
437
+ const materialDef = parser.json.materials[materialIndex];
438
+ if (!materialDef.extensions || !materialDef.extensions[this.name])
439
+ return null;
440
+ return MeshPhysicalMaterial;
441
+ }
442
+ extendMaterialParams(materialIndex, materialParams) {
443
+ const parser = this.parser;
444
+ const materialDef = parser.json.materials[materialIndex];
445
+ if (!materialDef.extensions || !materialDef.extensions[this.name]) {
446
+ return Promise.resolve();
447
+ }
448
+ const extension = materialDef.extensions[this.name];
449
+ materialParams.dispersion = extension.dispersion !== void 0 ? extension.dispersion : 0;
450
+ return Promise.resolve();
451
+ }
452
+ }
415
453
  class GLTFMaterialsIridescenceExtension {
416
454
  constructor(parser) {
417
455
  this.parser = parser;
@@ -482,13 +520,14 @@ class GLTFMaterialsSheenExtension {
482
520
  materialParams.sheen = 1;
483
521
  const extension = materialDef.extensions[this.name];
484
522
  if (extension.sheenColorFactor !== void 0) {
485
- materialParams.sheenColor.fromArray(extension.sheenColorFactor);
523
+ const colorFactor = extension.sheenColorFactor;
524
+ materialParams.sheenColor.setRGB(colorFactor[0], colorFactor[1], colorFactor[2], LinearSRGBColorSpace);
486
525
  }
487
526
  if (extension.sheenRoughnessFactor !== void 0) {
488
527
  materialParams.sheenRoughness = extension.sheenRoughnessFactor;
489
528
  }
490
529
  if (extension.sheenColorTexture !== void 0) {
491
- pending.push(parser.assignTexture(materialParams, "sheenColorMap", extension.sheenColorTexture, 3001));
530
+ pending.push(parser.assignTexture(materialParams, "sheenColorMap", extension.sheenColorTexture, SRGBColorSpace));
492
531
  }
493
532
  if (extension.sheenRoughnessTexture !== void 0) {
494
533
  pending.push(parser.assignTexture(materialParams, "sheenRoughnessMap", extension.sheenRoughnessTexture));
@@ -551,7 +590,12 @@ class GLTFMaterialsVolumeExtension {
551
590
  }
552
591
  materialParams.attenuationDistance = extension.attenuationDistance || Infinity;
553
592
  const colorArray = extension.attenuationColor || [1, 1, 1];
554
- materialParams.attenuationColor = new Color(colorArray[0], colorArray[1], colorArray[2]);
593
+ materialParams.attenuationColor = new Color().setRGB(
594
+ colorArray[0],
595
+ colorArray[1],
596
+ colorArray[2],
597
+ LinearSRGBColorSpace
598
+ );
555
599
  return Promise.all(pending);
556
600
  }
557
601
  }
@@ -603,16 +647,42 @@ class GLTFMaterialsSpecularExtension {
603
647
  pending.push(parser.assignTexture(materialParams, "specularIntensityMap", extension.specularTexture));
604
648
  }
605
649
  const colorArray = extension.specularColorFactor || [1, 1, 1];
606
- materialParams.specularColor = new Color(colorArray[0], colorArray[1], colorArray[2]);
650
+ materialParams.specularColor = new Color().setRGB(colorArray[0], colorArray[1], colorArray[2], LinearSRGBColorSpace);
607
651
  if (extension.specularColorTexture !== void 0) {
608
652
  pending.push(
609
- parser.assignTexture(materialParams, "specularColorMap", extension.specularColorTexture, 3001)
610
- // sRGBEncoding
653
+ parser.assignTexture(materialParams, "specularColorMap", extension.specularColorTexture, SRGBColorSpace)
611
654
  );
612
655
  }
613
656
  return Promise.all(pending);
614
657
  }
615
658
  }
659
+ class GLTFMaterialsBumpExtension {
660
+ constructor(parser) {
661
+ this.parser = parser;
662
+ this.name = EXTENSIONS.EXT_MATERIALS_BUMP;
663
+ }
664
+ getMaterialType(materialIndex) {
665
+ const parser = this.parser;
666
+ const materialDef = parser.json.materials[materialIndex];
667
+ if (!materialDef.extensions || !materialDef.extensions[this.name])
668
+ return null;
669
+ return MeshPhysicalMaterial;
670
+ }
671
+ extendMaterialParams(materialIndex, materialParams) {
672
+ const parser = this.parser;
673
+ const materialDef = parser.json.materials[materialIndex];
674
+ if (!materialDef.extensions || !materialDef.extensions[this.name]) {
675
+ return Promise.resolve();
676
+ }
677
+ const pending = [];
678
+ const extension = materialDef.extensions[this.name];
679
+ materialParams.bumpScale = extension.bumpFactor !== void 0 ? extension.bumpFactor : 1;
680
+ if (extension.bumpTexture !== void 0) {
681
+ pending.push(parser.assignTexture(materialParams, "bumpMap", extension.bumpTexture));
682
+ }
683
+ return Promise.all(pending);
684
+ }
685
+ }
616
686
  class GLTFMaterialsAnisotropyExtension {
617
687
  constructor(parser) {
618
688
  this.parser = parser;
@@ -863,7 +933,10 @@ class GLTFMeshGpuInstancing {
863
933
  instancedMesh.setMatrixAt(i, m.compose(p, q, s));
864
934
  }
865
935
  for (const attributeName in attributes) {
866
- if (attributeName !== "TRANSLATION" && attributeName !== "ROTATION" && attributeName !== "SCALE") {
936
+ if (attributeName === "_COLOR_0") {
937
+ const attr = attributes[attributeName];
938
+ instancedMesh.instanceColor = new InstancedBufferAttribute(attr.array, attr.itemSize, attr.normalized);
939
+ } else if (attributeName !== "TRANSLATION" && attributeName !== "ROTATION" && attributeName !== "SCALE") {
867
940
  mesh.geometry.setAttribute(attributeName, attributes[attributeName]);
868
941
  }
869
942
  }
@@ -953,7 +1026,7 @@ class GLTFDracoMeshCompressionExtension {
953
1026
  }
954
1027
  }
955
1028
  return parser.getDependency("bufferView", bufferViewIndex).then(function(bufferView) {
956
- return new Promise(function(resolve) {
1029
+ return new Promise(function(resolve, reject) {
957
1030
  dracoLoader.decodeDracoFile(
958
1031
  bufferView,
959
1032
  function(geometry) {
@@ -966,7 +1039,9 @@ class GLTFDracoMeshCompressionExtension {
966
1039
  resolve(geometry);
967
1040
  },
968
1041
  threeAttributeMap,
969
- attributeTypeMap
1042
+ attributeTypeMap,
1043
+ LinearSRGBColorSpace,
1044
+ reject
970
1045
  );
971
1046
  });
972
1047
  });
@@ -1358,11 +1433,14 @@ class GLTFParser {
1358
1433
  };
1359
1434
  addUnknownExtensionsToUserData(extensions, result, json);
1360
1435
  assignExtrasToUserData(result, json);
1361
- Promise.all(
1436
+ return Promise.all(
1362
1437
  parser._invokeAll(function(ext) {
1363
1438
  return ext.afterRoot && ext.afterRoot(result);
1364
1439
  })
1365
1440
  ).then(function() {
1441
+ for (const scene of result.scenes) {
1442
+ scene.updateMatrixWorld();
1443
+ }
1366
1444
  onLoad(result);
1367
1445
  });
1368
1446
  }).catch(onError);
@@ -1749,6 +1827,7 @@ class GLTFParser {
1749
1827
  if (isObjectURL === true) {
1750
1828
  URL.revokeObjectURL(sourceURI);
1751
1829
  }
1830
+ assignExtrasToUserData(texture, sourceDef);
1752
1831
  texture.userData.mimeType = sourceDef.mimeType || getImageURIMimeType(sourceDef.uri);
1753
1832
  return texture;
1754
1833
  }).catch(function(error) {
@@ -1765,7 +1844,7 @@ class GLTFParser {
1765
1844
  * @param {Object} mapDef
1766
1845
  * @return {Promise<Texture>}
1767
1846
  */
1768
- assignTexture(materialParams, mapName, mapDef, encoding) {
1847
+ assignTexture(materialParams, mapName, mapDef, colorSpace) {
1769
1848
  const parser = this;
1770
1849
  return this.getDependency("texture", mapDef.index).then(function(texture) {
1771
1850
  if (!texture)
@@ -1782,11 +1861,13 @@ class GLTFParser {
1782
1861
  parser.associations.set(texture, gltfReference);
1783
1862
  }
1784
1863
  }
1785
- if (encoding !== void 0) {
1864
+ if (colorSpace !== void 0) {
1865
+ if (typeof colorSpace === "number")
1866
+ colorSpace = colorSpace === sRGBEncoding ? SRGBColorSpace : LinearSRGBColorSpace;
1786
1867
  if ("colorSpace" in texture)
1787
- texture.colorSpace = encoding === 3001 ? "srgb" : "srgb-linear";
1868
+ texture.colorSpace = colorSpace;
1788
1869
  else
1789
- texture.encoding = encoding;
1870
+ texture.encoding = colorSpace === SRGBColorSpace ? sRGBEncoding : LinearEncoding;
1790
1871
  }
1791
1872
  materialParams[mapName] = texture;
1792
1873
  return texture;
@@ -1885,11 +1966,11 @@ class GLTFParser {
1885
1966
  materialParams.opacity = 1;
1886
1967
  if (Array.isArray(metallicRoughness.baseColorFactor)) {
1887
1968
  const array = metallicRoughness.baseColorFactor;
1888
- materialParams.color.fromArray(array);
1969
+ materialParams.color.setRGB(array[0], array[1], array[2], LinearSRGBColorSpace);
1889
1970
  materialParams.opacity = array[3];
1890
1971
  }
1891
1972
  if (metallicRoughness.baseColorTexture !== void 0) {
1892
- pending.push(parser.assignTexture(materialParams, "map", metallicRoughness.baseColorTexture, 3001));
1973
+ pending.push(parser.assignTexture(materialParams, "map", metallicRoughness.baseColorTexture, SRGBColorSpace));
1893
1974
  }
1894
1975
  materialParams.metalness = metallicRoughness.metallicFactor !== void 0 ? metallicRoughness.metallicFactor : 1;
1895
1976
  materialParams.roughness = metallicRoughness.roughnessFactor !== void 0 ? metallicRoughness.roughnessFactor : 1;
@@ -1936,10 +2017,16 @@ class GLTFParser {
1936
2017
  }
1937
2018
  }
1938
2019
  if (materialDef.emissiveFactor !== void 0 && materialType !== MeshBasicMaterial) {
1939
- materialParams.emissive = new Color().fromArray(materialDef.emissiveFactor);
2020
+ const emissiveFactor = materialDef.emissiveFactor;
2021
+ materialParams.emissive = new Color().setRGB(
2022
+ emissiveFactor[0],
2023
+ emissiveFactor[1],
2024
+ emissiveFactor[2],
2025
+ LinearSRGBColorSpace
2026
+ );
1940
2027
  }
1941
2028
  if (materialDef.emissiveTexture !== void 0 && materialType !== MeshBasicMaterial) {
1942
- pending.push(parser.assignTexture(materialParams, "emissiveMap", materialDef.emissiveTexture, 3001));
2029
+ pending.push(parser.assignTexture(materialParams, "emissiveMap", materialDef.emissiveTexture, SRGBColorSpace));
1943
2030
  }
1944
2031
  return Promise.all(pending).then(function() {
1945
2032
  const material = new materialType(materialParams);
@@ -2149,6 +2236,7 @@ class GLTFParser {
2149
2236
  */
2150
2237
  loadAnimation(animationIndex) {
2151
2238
  const json = this.json;
2239
+ const parser = this;
2152
2240
  const animationDef = json.animations[animationIndex];
2153
2241
  const animationName = animationDef.name ? animationDef.name : "animation_" + animationIndex;
2154
2242
  const pendingNodes = [];
@@ -2192,57 +2280,14 @@ class GLTFParser {
2192
2280
  const target = targets[i];
2193
2281
  if (node === void 0)
2194
2282
  continue;
2195
- node.updateMatrix();
2196
- let TypedKeyframeTrack;
2197
- switch (PATH_PROPERTIES[target.path]) {
2198
- case PATH_PROPERTIES.weights:
2199
- TypedKeyframeTrack = NumberKeyframeTrack;
2200
- break;
2201
- case PATH_PROPERTIES.rotation:
2202
- TypedKeyframeTrack = QuaternionKeyframeTrack;
2203
- break;
2204
- case PATH_PROPERTIES.position:
2205
- case PATH_PROPERTIES.scale:
2206
- default:
2207
- TypedKeyframeTrack = VectorKeyframeTrack;
2208
- break;
2209
- }
2210
- const targetName = node.name ? node.name : node.uuid;
2211
- const interpolation = sampler.interpolation !== void 0 ? INTERPOLATION[sampler.interpolation] : InterpolateLinear;
2212
- const targetNames = [];
2213
- if (PATH_PROPERTIES[target.path] === PATH_PROPERTIES.weights) {
2214
- node.traverse(function(object) {
2215
- if (object.morphTargetInfluences) {
2216
- targetNames.push(object.name ? object.name : object.uuid);
2217
- }
2218
- });
2219
- } else {
2220
- targetNames.push(targetName);
2283
+ if (node.updateMatrix) {
2284
+ node.updateMatrix();
2221
2285
  }
2222
- let outputArray = outputAccessor.array;
2223
- if (outputAccessor.normalized) {
2224
- const scale = getNormalizedComponentScale(outputArray.constructor);
2225
- const scaled = new Float32Array(outputArray.length);
2226
- for (let j = 0, jl = outputArray.length; j < jl; j++) {
2227
- scaled[j] = outputArray[j] * scale;
2286
+ const createdTracks = parser._createAnimationTracks(node, inputAccessor, outputAccessor, sampler, target);
2287
+ if (createdTracks) {
2288
+ for (let k = 0; k < createdTracks.length; k++) {
2289
+ tracks.push(createdTracks[k]);
2228
2290
  }
2229
- outputArray = scaled;
2230
- }
2231
- for (let j = 0, jl = targetNames.length; j < jl; j++) {
2232
- const track = new TypedKeyframeTrack(
2233
- targetNames[j] + "." + PATH_PROPERTIES[target.path],
2234
- inputAccessor.array,
2235
- outputArray,
2236
- interpolation
2237
- );
2238
- if (sampler.interpolation === "CUBICSPLINE") {
2239
- track.createInterpolant = function InterpolantFactoryMethodGLTFCubicSpline(result) {
2240
- const interpolantType = this instanceof QuaternionKeyframeTrack ? GLTFCubicSplineQuaternionInterpolant : GLTFCubicSplineInterpolant;
2241
- return new interpolantType(this.times, this.values, this.getValueSize() / 3, result);
2242
- };
2243
- track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = true;
2244
- }
2245
- tracks.push(track);
2246
2291
  }
2247
2292
  }
2248
2293
  return new AnimationClip(animationName, void 0, tracks);
@@ -2420,6 +2465,79 @@ class GLTFParser {
2420
2465
  return scene;
2421
2466
  });
2422
2467
  }
2468
+ _createAnimationTracks(node, inputAccessor, outputAccessor, sampler, target) {
2469
+ const tracks = [];
2470
+ const targetName = node.name ? node.name : node.uuid;
2471
+ const targetNames = [];
2472
+ if (PATH_PROPERTIES[target.path] === PATH_PROPERTIES.weights) {
2473
+ node.traverse(function(object) {
2474
+ if (object.morphTargetInfluences) {
2475
+ targetNames.push(object.name ? object.name : object.uuid);
2476
+ }
2477
+ });
2478
+ } else {
2479
+ targetNames.push(targetName);
2480
+ }
2481
+ let TypedKeyframeTrack;
2482
+ switch (PATH_PROPERTIES[target.path]) {
2483
+ case PATH_PROPERTIES.weights:
2484
+ TypedKeyframeTrack = NumberKeyframeTrack;
2485
+ break;
2486
+ case PATH_PROPERTIES.rotation:
2487
+ TypedKeyframeTrack = QuaternionKeyframeTrack;
2488
+ break;
2489
+ case PATH_PROPERTIES.position:
2490
+ case PATH_PROPERTIES.scale:
2491
+ TypedKeyframeTrack = VectorKeyframeTrack;
2492
+ break;
2493
+ default:
2494
+ switch (outputAccessor.itemSize) {
2495
+ case 1:
2496
+ TypedKeyframeTrack = NumberKeyframeTrack;
2497
+ break;
2498
+ case 2:
2499
+ case 3:
2500
+ default:
2501
+ TypedKeyframeTrack = VectorKeyframeTrack;
2502
+ break;
2503
+ }
2504
+ break;
2505
+ }
2506
+ const interpolation = sampler.interpolation !== void 0 ? INTERPOLATION[sampler.interpolation] : InterpolateLinear;
2507
+ const outputArray = this._getArrayFromAccessor(outputAccessor);
2508
+ for (let j = 0, jl = targetNames.length; j < jl; j++) {
2509
+ const track = new TypedKeyframeTrack(
2510
+ targetNames[j] + "." + PATH_PROPERTIES[target.path],
2511
+ inputAccessor.array,
2512
+ outputArray,
2513
+ interpolation
2514
+ );
2515
+ if (sampler.interpolation === "CUBICSPLINE") {
2516
+ this._createCubicSplineTrackInterpolant(track);
2517
+ }
2518
+ tracks.push(track);
2519
+ }
2520
+ return tracks;
2521
+ }
2522
+ _getArrayFromAccessor(accessor) {
2523
+ let outputArray = accessor.array;
2524
+ if (accessor.normalized) {
2525
+ const scale = getNormalizedComponentScale(outputArray.constructor);
2526
+ const scaled = new Float32Array(outputArray.length);
2527
+ for (let j = 0, jl = outputArray.length; j < jl; j++) {
2528
+ scaled[j] = outputArray[j] * scale;
2529
+ }
2530
+ outputArray = scaled;
2531
+ }
2532
+ return outputArray;
2533
+ }
2534
+ _createCubicSplineTrackInterpolant(track) {
2535
+ track.createInterpolant = function InterpolantFactoryMethodGLTFCubicSpline(result) {
2536
+ const interpolantType = this instanceof QuaternionKeyframeTrack ? GLTFCubicSplineQuaternionInterpolant : GLTFCubicSplineInterpolant;
2537
+ return new interpolantType(this.times, this.values, this.getValueSize() / 3, result);
2538
+ };
2539
+ track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = true;
2540
+ }
2423
2541
  }
2424
2542
  function computeBounds(geometry, primitiveDef, parser) {
2425
2543
  const attributes = primitiveDef.attributes;