three-stdlib 2.8.2 → 2.8.3

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.
Files changed (70) hide show
  1. package/{BufferGeometryUtils-582025b8.js → BufferGeometryUtils-1a7a235c.js} +2 -1
  2. package/{BufferGeometryUtils-9eb5c2e7.js → BufferGeometryUtils-971dfde3.js} +0 -0
  3. package/animation/MMDAnimationHelper.d.ts +17 -17
  4. package/animation/MMDPhysics.d.ts +3 -3
  5. package/csm/CSM.d.ts +47 -22
  6. package/csm/CSMHelper.d.ts +20 -7
  7. package/effects/OutlineEffect.d.ts +4 -4
  8. package/effects/OutlineEffect.js +8 -2
  9. package/exporters/GLTFExporter.js +5 -10
  10. package/geometries/ConvexGeometry.d.ts +1 -1
  11. package/geometries/ParametricGeometries.d.ts +4 -2
  12. package/helpers/RectAreaLightHelper.d.ts +3 -3
  13. package/loaders/AssimpLoader.js +39 -10
  14. package/loaders/ColladaLoader.js +22 -5
  15. package/loaders/EXRLoader.js +5 -1
  16. package/loaders/FBXLoader.js +10 -2
  17. package/loaders/GLTFLoader.d.ts +44 -20
  18. package/loaders/LDrawLoader.d.ts +6 -0
  19. package/loaders/MTLLoader.d.ts +18 -18
  20. package/loaders/RGBMLoader.d.ts +10 -10
  21. package/loaders/RGBMLoader.js +253 -178
  22. package/loaders/SVGLoader.d.ts +5 -3
  23. package/loaders/SVGLoader.js +10 -5
  24. package/loaders/lwo/IFFParser.js +4 -1
  25. package/math/OBB.d.ts +1 -1
  26. package/misc/GPUComputationRenderer.d.ts +8 -6
  27. package/misc/MD2CharacterComplex.js +9 -2
  28. package/misc/Volume.d.ts +2 -0
  29. package/modifiers/EdgeSplitModifier.cjs.js +1 -1
  30. package/modifiers/SimplifyModifier.cjs.js +1 -1
  31. package/nodes/inputs/ColorNode.d.ts +2 -2
  32. package/nodes/inputs/TextureNode.d.ts +3 -2
  33. package/nodes/materials/StandardNodeMaterial.d.ts +1 -1
  34. package/nodes/materials/nodes/StandardNode.d.ts +1 -0
  35. package/nodes/utils/ColorSpaceNode.d.ts +1 -1
  36. package/nodes/utils/JoinNode.d.ts +1 -0
  37. package/objects/MarchingCubes.d.ts +12 -4
  38. package/objects/Reflector.d.ts +4 -2
  39. package/objects/ReflectorForSSRPass.d.ts +6 -6
  40. package/objects/Refractor.d.ts +4 -2
  41. package/objects/Water.d.ts +4 -3
  42. package/objects/Water2.d.ts +12 -3
  43. package/package.json +1 -1
  44. package/postprocessing/ClearPass.d.ts +3 -3
  45. package/postprocessing/SAOPass.d.ts +3 -2
  46. package/postprocessing/SSAARenderPass.d.ts +3 -3
  47. package/postprocessing/SSAOPass.d.ts +3 -2
  48. package/postprocessing/SSRPass.d.ts +14 -17
  49. package/postprocessing/TAARenderPass.d.ts +2 -2
  50. package/renderers/CSS2DRenderer.d.ts +5 -1
  51. package/renderers/CSS3DRenderer.d.ts +5 -1
  52. package/renderers/webgpu/WebGPUTextures.js +62 -41
  53. package/shaders/SSRShader.d.ts +1 -2
  54. package/utils/BufferGeometryUtils.cjs.js +1 -1
  55. package/utils/BufferGeometryUtils.js +2 -1
  56. package/utils/LDrawUtils.cjs.js +1 -1
  57. package/utils/LDrawUtils.d.ts +5 -0
  58. package/utils/LDrawUtils.js +1 -1
  59. package/utils/RoughnessMipmapper.js +5 -1
  60. package/utils/SceneUtils.d.ts +10 -12
  61. package/utils/ShadowMapViewer.js +4 -1
  62. package/webxr/XRHandModelFactory.d.ts +3 -3
  63. package/webxr/XRHandPrimitiveModel.d.ts +1 -1
  64. package/csm/Frustum.d.ts +0 -16
  65. package/csm/Shader.d.ts +0 -6
  66. package/loaders/XLoader.d.ts +0 -19
  67. package/shaders/FresnelShader.d.ts +0 -13
  68. package/shaders/ParallaxShader.d.ts +0 -20
  69. package/utils/RoughnessMipmapper.d.ts +0 -7
  70. package/webxr/XRHandOculusMeshModel.d.ts +0 -23
@@ -485,7 +485,8 @@ function computeMorphedAttributes(object) {
485
485
 
486
486
  const morphInfluences = object.morphTargetInfluences;
487
487
 
488
- if (material.morphTargets && morphAttribute && morphInfluences) {
488
+ if ( // @ts-expect-error
489
+ material.morphTargets && morphAttribute && morphInfluences) {
489
490
  _morphA.set(0, 0, 0);
490
491
 
491
492
  _morphB.set(0, 0, 0);
@@ -14,34 +14,34 @@ import { CCDIKSolver } from './CCDIKSolver';
14
14
  import { MMDPhysics } from './MMDPhysics';
15
15
 
16
16
  export interface MMDAnimationHelperParameter {
17
- sync?: boolean;
18
- afterglow?: number;
19
- resetPhysicsOnLoop?: boolean;
17
+ sync?: boolean | undefined;
18
+ afterglow?: number | undefined;
19
+ resetPhysicsOnLoop?: boolean | undefined;
20
20
  }
21
21
 
22
22
  export interface MMDAnimationHelperAddParameter {
23
- animation?: AnimationClip | AnimationClip[];
24
- physics?: boolean;
25
- warmup?: number;
26
- unitStep?: number;
27
- maxStepNum?: number;
28
- gravity?: number;
29
- delayTime?: number;
23
+ animation?: AnimationClip | AnimationClip[] | undefined;
24
+ physics?: boolean | undefined;
25
+ warmup?: number | undefined;
26
+ unitStep?: number | undefined;
27
+ maxStepNum?: number | undefined;
28
+ gravity?: number | undefined;
29
+ delayTime?: number | undefined;
30
30
  }
31
31
 
32
32
  export interface MMDAnimationHelperPoseParameter {
33
- resetPose?: boolean;
34
- ik?: boolean;
35
- grant?: boolean;
33
+ resetPose?: boolean | undefined;
34
+ ik?: boolean | undefined;
35
+ grant?: boolean | undefined;
36
36
  }
37
37
 
38
38
  export interface MMDAnimationHelperMixer {
39
39
  looped: boolean;
40
- mixer?: AnimationMixer;
40
+ mixer?: AnimationMixer | undefined;
41
41
  ikSolver: CCDIKSolver;
42
42
  grantSolver: GrantSolver;
43
- physics?: MMDPhysics;
44
- duration?: number;
43
+ physics?: MMDPhysics | undefined;
44
+ duration?: number | undefined;
45
45
  }
46
46
 
47
47
  export class MMDAnimationHelper {
@@ -77,7 +77,7 @@ export class MMDAnimationHelper {
77
77
  }
78
78
 
79
79
  export interface AudioManagerParameter {
80
- delayTime?: number;
80
+ delayTime?: number | undefined;
81
81
  }
82
82
 
83
83
  export class AudioManager {
@@ -1,9 +1,9 @@
1
1
  import { Bone, Euler, Matrix4, Object3D, Quaternion, SkinnedMesh, Vector3 } from 'three';
2
2
 
3
3
  export interface MMDPhysicsParameter {
4
- unitStep?: number;
5
- maxStepNum?: number;
6
- gravity?: Vector3;
4
+ unitStep?: number | undefined;
5
+ maxStepNum?: number | undefined;
6
+ gravity?: Vector3 | undefined;
7
7
  }
8
8
 
9
9
  export class MMDPhysics {
package/csm/CSM.d.ts CHANGED
@@ -1,36 +1,61 @@
1
+ import { Camera, Vector3, DirectionalLight, Material, Vector2, Object3D } from 'three';
2
+
3
+ export enum CMSMode {
4
+ practical = 'practical',
5
+ uniform = 'uniform',
6
+ logarithmic = 'logarithmic',
7
+ custom = 'custom',
8
+ }
9
+
10
+ export interface CMSParameters {
11
+ camera?: Camera;
12
+ parent?: Object3D;
13
+ cascades?: number;
14
+ maxFar?: number;
15
+ mode?: CMSMode;
16
+ shadowMapSize?: number;
17
+ shadowBias?: number;
18
+ lightDirection?: Vector3;
19
+ lightIntensity?: number;
20
+ lightNear?: number;
21
+ lightFar?: number;
22
+ lightMargin?: number;
23
+ customSplitsCallback?: (cascades: number, cameraNear: number, cameraFar: number, breaks: number[]) => void;
24
+ }
25
+
1
26
  export class CSM {
2
- constructor(data: any);
3
- camera: any;
4
- parent: any;
5
- cascades: any;
6
- maxFar: any;
7
- mode: any;
8
- shadowMapSize: any;
9
- shadowBias: any;
10
- lightDirection: any;
11
- lightIntensity: any;
12
- lightNear: any;
13
- lightFar: any;
14
- lightMargin: any;
15
- customSplitsCallback: any;
27
+ constructor(data?: CMSParameters);
28
+ camera: Camera;
29
+ parent: Object3D;
30
+ cascades: number;
31
+ maxFar: number;
32
+ mode: CMSMode;
33
+ shadowMapSize: number;
34
+ shadowBias: number;
35
+ lightDirection: Vector3;
36
+ lightIntensity: number;
37
+ lightNear: number;
38
+ lightFar: number;
39
+ lightMargin: number;
40
+ customSplitsCallback: (cascades: number, cameraNear: number, cameraFar: number, breaks: number[]) => void;
16
41
  fade: boolean;
17
- mainFrustum: Frustum;
18
- frustums: any[];
19
- breaks: any[];
20
- lights: any[];
21
- shaders: Map<any, any>;
42
+ mainFrustum: CSMFrustrum;
43
+ frustums: CSMFrustrum[];
44
+ breaks: number[];
45
+ lights: DirectionalLight[];
46
+ shaders: Map<unknown, string>;
22
47
  createLights(): void;
23
48
  initCascades(): void;
24
49
  updateShadowBounds(): void;
25
50
  getBreaks(): void;
26
51
  update(): void;
27
52
  injectInclude(): void;
28
- setupMaterial(material: any): void;
53
+ setupMaterial(material: Material): void;
29
54
  updateUniforms(): void;
30
- getExtendedBreaks(target: any): void;
55
+ getExtendedBreaks(target: Vector2[]): void;
31
56
  updateFrustums(): void;
32
57
  remove(): void;
33
58
  dispose(): void;
34
59
  }
35
60
 
36
- import Frustum from './Frustum.js';
61
+ import CSMFrustrum from './CSMFrustum.js';
@@ -1,13 +1,26 @@
1
- export class CSMHelper {
2
- constructor(csm: any);
3
- csm: any;
1
+ import {
2
+ Box3Helper,
3
+ BufferGeometry,
4
+ Group,
5
+ LineBasicMaterial,
6
+ LineSegments,
7
+ Mesh,
8
+ MeshBasicMaterial,
9
+ PlaneGeometry,
10
+ } from 'three';
11
+
12
+ import { CSM } from './CSM';
13
+
14
+ export class CSMHelper<TCSM extends CSM = CSM> extends Group {
15
+ constructor(csm: TCSM);
16
+ csm: TCSM;
4
17
  displayFrustum: boolean;
5
18
  displayPlanes: boolean;
6
19
  displayShadowBounds: boolean;
7
- frustumLines: any;
8
- cascadeLines: any[];
9
- cascadePlanes: any[];
10
- shadowLines: any[];
20
+ frustumLines: LineSegments<BufferGeometry, LineBasicMaterial>;
21
+ cascadeLines: Box3Helper[];
22
+ cascadePlanes: Array<Mesh<PlaneGeometry, MeshBasicMaterial>>;
23
+ shadowLines: Box3Helper[];
11
24
  updateVisibility(): void;
12
25
  update(): void;
13
26
  }
@@ -1,10 +1,10 @@
1
1
  import { Camera, Scene, Vector2, Vector4, WebGLRenderer, WebGLRenderTarget, WebGLShadowMap } from 'three';
2
2
 
3
3
  export interface OutlineEffectParameters {
4
- defaultThickness?: number;
5
- defaultColor?: number[];
6
- defaultAlpha?: number;
7
- defaultKeepAlive?: boolean;
4
+ defaultThickness?: number | undefined;
5
+ defaultColor?: number[] | undefined;
6
+ defaultAlpha?: number | undefined;
7
+ defaultKeepAlive?: boolean | undefined;
8
8
  }
9
9
 
10
10
  export class OutlineEffect {
@@ -185,7 +185,10 @@ const OutlineEffect = function (renderer, parameters) {
185
185
  material.uniforms.outlineAlpha.value = originalMaterial.opacity;
186
186
 
187
187
  if (outlineParameters !== undefined) {
188
- if (outlineParameters.thickness !== undefined) material.uniforms.outlineThickness.value = outlineParameters.thickness;
188
+ if (outlineParameters.thickness !== undefined) {
189
+ material.uniforms.outlineThickness.value = outlineParameters.thickness;
190
+ }
191
+
189
192
  if (outlineParameters.color !== undefined) material.uniforms.outlineColor.value.fromArray(outlineParameters.color);
190
193
  if (outlineParameters.alpha !== undefined) material.uniforms.outlineAlpha.value = outlineParameters.alpha;
191
194
  }
@@ -216,7 +219,10 @@ const OutlineEffect = function (renderer, parameters) {
216
219
  }
217
220
 
218
221
  material.transparent = outlineParameters.alpha !== undefined && outlineParameters.alpha < 1.0 ? true : originalMaterial.transparent;
219
- if (outlineParameters.keepAlive !== undefined) cache[originalMaterial.uuid].keepAlive = outlineParameters.keepAlive;
222
+
223
+ if (outlineParameters.keepAlive !== undefined) {
224
+ cache[originalMaterial.uuid].keepAlive = outlineParameters.keepAlive;
225
+ }
220
226
  } else {
221
227
  material.transparent = originalMaterial.transparent;
222
228
  material.visible = originalMaterial.visible;
@@ -1902,29 +1902,24 @@ class GLTFMaterialsVolumeExtension {
1902
1902
 
1903
1903
  writeMaterial(material, materialDef) {
1904
1904
  if (!(material instanceof MeshPhysicalMaterial && // @ts-expect-error
1905
- material.isMeshPhysicalMaterial) || // @ts-expect-error
1906
- material.thickness === 0) {
1905
+ material.isMeshPhysicalMaterial) || material.thickness === 0) {
1907
1906
  return;
1908
1907
  }
1909
1908
 
1910
1909
  const writer = this.writer;
1911
1910
  const extensionsUsed = writer.extensionsUsed;
1912
1911
  const extensionDef = {};
1913
- extensionDef.thickness = // @ts-expect-error
1914
- material.thickness; // @ts-expect-error
1912
+ extensionDef.thickness = material.thickness;
1915
1913
 
1916
1914
  if (material.thicknessMap) {
1917
1915
  const thicknessMapDef = {
1918
- index: writer.processTexture( // @ts-expect-error
1919
- material.thicknessMap)
1916
+ index: writer.processTexture(material.thicknessMap)
1920
1917
  };
1921
- writer.applyTextureTransform(thicknessMapDef, // @ts-expect-error
1922
- material.thicknessMap);
1918
+ writer.applyTextureTransform(thicknessMapDef, material.thicknessMap);
1923
1919
  extensionDef.thicknessTexture = thicknessMapDef;
1924
1920
  }
1925
1921
 
1926
- extensionDef.attenuationDistance = //@ts-expect-error
1927
- material.attenuationDistance;
1922
+ extensionDef.attenuationDistance = material.attenuationDistance;
1928
1923
  extensionDef.attenuationColor = //@ts-expect-error
1929
1924
  material.attenuationTint.toArray();
1930
1925
  materialDef.extensions = materialDef.extensions || {};
@@ -1,5 +1,5 @@
1
1
  import { BufferGeometry, Vector3 } from 'three';
2
2
 
3
3
  export class ConvexGeometry extends BufferGeometry {
4
- constructor(points: Vector3[]);
4
+ constructor(points?: Vector3[]);
5
5
  }
@@ -1,8 +1,10 @@
1
- import { Curve, ParametricGeometry, Vector3 } from 'three';
1
+ import { Curve, Vector3 } from 'three';
2
+
3
+ import { ParametricGeometry } from './ParametricGeometry';
2
4
 
3
5
  export namespace ParametricGeometries {
4
6
  function klein(v: number, u: number, target: Vector3): Vector3;
5
- function plane(width: number, height: number, target: Vector3): Vector3;
7
+ function plane(width: number, height: number): (u: number, v: number, target: Vector3) => Vector3;
6
8
  function mobius(u: number, t: number, target: Vector3): Vector3;
7
9
  function mobius3d(u: number, t: number, target: Vector3): Vector3;
8
10
 
@@ -1,10 +1,10 @@
1
- import { Color, Line, RectAreaLight } from 'three';
1
+ import { Line, RectAreaLight, ColorRepresentation } from 'three';
2
2
 
3
3
  export class RectAreaLightHelper extends Line {
4
- constructor(light: RectAreaLight, color?: Color | string | number);
4
+ constructor(light: RectAreaLight, color?: ColorRepresentation);
5
5
 
6
6
  light: RectAreaLight;
7
- color: Color | string | number | undefined;
7
+ color: ColorRepresentation | undefined;
8
8
 
9
9
  dispose(): void;
10
10
  }
@@ -568,12 +568,30 @@ AssimpLoader.prototype = Object.assign(Object.create(Loader.prototype), {
568
568
  if (scene.mMaterials[this.mMaterialIndex]) mat = scene.mMaterials[this.mMaterialIndex].toTHREE(scene);else mat = new MeshLambertMaterial();
569
569
  geometry.setIndex(new BufferAttribute(new Uint32Array(this.mIndexArray), 1));
570
570
  geometry.setAttribute('position', new BufferAttribute(this.mVertexBuffer, 3));
571
- if (this.mNormalBuffer && this.mNormalBuffer.length > 0) geometry.setAttribute('normal', new BufferAttribute(this.mNormalBuffer, 3));
572
- if (this.mColorBuffer && this.mColorBuffer.length > 0) geometry.setAttribute('color', new BufferAttribute(this.mColorBuffer, 4));
573
- if (this.mTexCoordsBuffers[0] && this.mTexCoordsBuffers[0].length > 0) geometry.setAttribute('uv', new BufferAttribute(new Float32Array(this.mTexCoordsBuffers[0]), 2));
574
- if (this.mTexCoordsBuffers[1] && this.mTexCoordsBuffers[1].length > 0) geometry.setAttribute('uv1', new BufferAttribute(new Float32Array(this.mTexCoordsBuffers[1]), 2));
575
- if (this.mTangentBuffer && this.mTangentBuffer.length > 0) geometry.setAttribute('tangents', new BufferAttribute(this.mTangentBuffer, 3));
576
- if (this.mBitangentBuffer && this.mBitangentBuffer.length > 0) geometry.setAttribute('bitangents', new BufferAttribute(this.mBitangentBuffer, 3));
571
+
572
+ if (this.mNormalBuffer && this.mNormalBuffer.length > 0) {
573
+ geometry.setAttribute('normal', new BufferAttribute(this.mNormalBuffer, 3));
574
+ }
575
+
576
+ if (this.mColorBuffer && this.mColorBuffer.length > 0) {
577
+ geometry.setAttribute('color', new BufferAttribute(this.mColorBuffer, 4));
578
+ }
579
+
580
+ if (this.mTexCoordsBuffers[0] && this.mTexCoordsBuffers[0].length > 0) {
581
+ geometry.setAttribute('uv', new BufferAttribute(new Float32Array(this.mTexCoordsBuffers[0]), 2));
582
+ }
583
+
584
+ if (this.mTexCoordsBuffers[1] && this.mTexCoordsBuffers[1].length > 0) {
585
+ geometry.setAttribute('uv1', new BufferAttribute(new Float32Array(this.mTexCoordsBuffers[1]), 2));
586
+ }
587
+
588
+ if (this.mTangentBuffer && this.mTangentBuffer.length > 0) {
589
+ geometry.setAttribute('tangents', new BufferAttribute(this.mTangentBuffer, 3));
590
+ }
591
+
592
+ if (this.mBitangentBuffer && this.mBitangentBuffer.length > 0) {
593
+ geometry.setAttribute('bitangents', new BufferAttribute(this.mBitangentBuffer, 3));
594
+ }
577
595
 
578
596
  if (this.mBones.length > 0) {
579
597
  var weights = [];
@@ -824,10 +842,21 @@ AssimpLoader.prototype = Object.assign(Object.create(Loader.prototype), {
824
842
  var mat = new MeshPhongMaterial();
825
843
 
826
844
  for (let i = 0; i < this.mProperties.length; i++) {
827
- if (nameTypeMapping[this.mProperties[i].mKey] == 'float') mat[namePropMapping[this.mProperties[i].mKey]] = this.mProperties[i].dataAsFloat();
828
- if (nameTypeMapping[this.mProperties[i].mKey] == 'color') mat[namePropMapping[this.mProperties[i].mKey]] = this.mProperties[i].dataAsColor();
829
- if (nameTypeMapping[this.mProperties[i].mKey] == 'bool') mat[namePropMapping[this.mProperties[i].mKey]] = this.mProperties[i].dataAsBool();
830
- if (nameTypeMapping[this.mProperties[i].mKey] == 'string') mat[namePropMapping[this.mProperties[i].mKey]] = this.mProperties[i].dataAsString();
845
+ if (nameTypeMapping[this.mProperties[i].mKey] == 'float') {
846
+ mat[namePropMapping[this.mProperties[i].mKey]] = this.mProperties[i].dataAsFloat();
847
+ }
848
+
849
+ if (nameTypeMapping[this.mProperties[i].mKey] == 'color') {
850
+ mat[namePropMapping[this.mProperties[i].mKey]] = this.mProperties[i].dataAsColor();
851
+ }
852
+
853
+ if (nameTypeMapping[this.mProperties[i].mKey] == 'bool') {
854
+ mat[namePropMapping[this.mProperties[i].mKey]] = this.mProperties[i].dataAsBool();
855
+ }
856
+
857
+ if (nameTypeMapping[this.mProperties[i].mKey] == 'string') {
858
+ mat[namePropMapping[this.mProperties[i].mKey]] = this.mProperties[i].dataAsString();
859
+ }
831
860
 
832
861
  if (nameTypeMapping[this.mProperties[i].mKey] == 'map') {
833
862
  var prop = this.mProperties[i];
@@ -370,7 +370,11 @@ class ColladaLoader extends Loader {
370
370
  }
371
371
 
372
372
  if (positionData.length > 0) tracks.push(new VectorKeyframeTrack(name + '.position', times, positionData));
373
- if (quaternionData.length > 0) tracks.push(new QuaternionKeyframeTrack(name + '.quaternion', times, quaternionData));
373
+
374
+ if (quaternionData.length > 0) {
375
+ tracks.push(new QuaternionKeyframeTrack(name + '.quaternion', times, quaternionData));
376
+ }
377
+
374
378
  if (scaleData.length > 0) tracks.push(new VectorKeyframeTrack(name + '.scale', times, scaleData));
375
379
  return tracks;
376
380
  }
@@ -1835,13 +1839,26 @@ class ColladaLoader extends Loader {
1835
1839
  } // build geometry
1836
1840
 
1837
1841
 
1838
- if (position.array.length > 0) geometry.setAttribute('position', new Float32BufferAttribute(position.array, position.stride));
1839
- if (normal.array.length > 0) geometry.setAttribute('normal', new Float32BufferAttribute(normal.array, normal.stride));
1842
+ if (position.array.length > 0) {
1843
+ geometry.setAttribute('position', new Float32BufferAttribute(position.array, position.stride));
1844
+ }
1845
+
1846
+ if (normal.array.length > 0) {
1847
+ geometry.setAttribute('normal', new Float32BufferAttribute(normal.array, normal.stride));
1848
+ }
1849
+
1840
1850
  if (color.array.length > 0) geometry.setAttribute('color', new Float32BufferAttribute(color.array, color.stride));
1841
1851
  if (uv.array.length > 0) geometry.setAttribute('uv', new Float32BufferAttribute(uv.array, uv.stride));
1842
1852
  if (uv2.array.length > 0) geometry.setAttribute('uv2', new Float32BufferAttribute(uv2.array, uv2.stride));
1843
- if (skinIndex.array.length > 0) geometry.setAttribute('skinIndex', new Float32BufferAttribute(skinIndex.array, skinIndex.stride));
1844
- if (skinWeight.array.length > 0) geometry.setAttribute('skinWeight', new Float32BufferAttribute(skinWeight.array, skinWeight.stride));
1853
+
1854
+ if (skinIndex.array.length > 0) {
1855
+ geometry.setAttribute('skinIndex', new Float32BufferAttribute(skinIndex.array, skinIndex.stride));
1856
+ }
1857
+
1858
+ if (skinWeight.array.length > 0) {
1859
+ geometry.setAttribute('skinWeight', new Float32BufferAttribute(skinWeight.array, skinWeight.stride));
1860
+ }
1861
+
1845
1862
  build.data = geometry;
1846
1863
  build.type = primitives[0].type;
1847
1864
  build.materialKeys = materialKeys;
@@ -1067,7 +1067,11 @@ class EXRLoader extends DataTextureLoader {
1067
1067
  totalDcUncompressedCount: parseInt64(inDataView, inOffset),
1068
1068
  acCompression: parseInt64(inDataView, inOffset)
1069
1069
  };
1070
- if (dwaHeader.version < 2) throw 'EXRLoader.parse: ' + EXRHeader.compression + ' version ' + dwaHeader.version + ' is unsupported'; // Read channel ruleset information
1070
+
1071
+ if (dwaHeader.version < 2) {
1072
+ throw 'EXRLoader.parse: ' + EXRHeader.compression + ' version ' + dwaHeader.version + ' is unsupported';
1073
+ } // Read channel ruleset information
1074
+
1071
1075
 
1072
1076
  var channelRules = new Array();
1073
1077
  var ruleSize = parseUint16(inDataView, inOffset) - INT16_SIZE;
@@ -514,7 +514,11 @@ class FBXTreeParser {
514
514
  if (deformerNode.attrType === 'Skin') {
515
515
  const skeleton = this.parseSkeleton(relationships, DeformerNodes);
516
516
  skeleton.ID = nodeID;
517
- if (relationships.parents.length > 1) console.warn('THREE.FBXLoader: skeleton attached to more than one geometry is not supported.');
517
+
518
+ if (relationships.parents.length > 1) {
519
+ console.warn('THREE.FBXLoader: skeleton attached to more than one geometry is not supported.');
520
+ }
521
+
518
522
  skeleton.geometryID = relationships.parents[0].ID;
519
523
  skeletons[nodeID] = skeleton;
520
524
  } else if (deformerNode.attrType === 'BlendShape') {
@@ -523,7 +527,11 @@ class FBXTreeParser {
523
527
  };
524
528
  morphTarget.rawTargets = this.parseMorphTargets(relationships, DeformerNodes);
525
529
  morphTarget.id = nodeID;
526
- if (relationships.parents.length > 1) console.warn('THREE.FBXLoader: morph target attached to more than one geometry is not supported.');
530
+
531
+ if (relationships.parents.length > 1) {
532
+ console.warn('THREE.FBXLoader: morph target attached to more than one geometry is not supported.');
533
+ }
534
+
527
535
  morphTargets[nodeID] = morphTarget;
528
536
  }
529
537
  }
@@ -13,6 +13,9 @@ import {
13
13
  Material,
14
14
  SkinnedMesh,
15
15
  Texture,
16
+ TextureLoader,
17
+ FileLoader,
18
+ ImageBitmapLoader,
16
19
  } from 'three';
17
20
 
18
21
  import { DRACOLoader } from './DRACOLoader';
@@ -24,10 +27,10 @@ export interface GLTF {
24
27
  scenes: Group[];
25
28
  cameras: Camera[];
26
29
  asset: {
27
- copyright?: string;
28
- generator?: string;
29
- version?: string;
30
- minVersion?: string;
30
+ copyright?: string | undefined;
31
+ generator?: string | undefined;
32
+ version?: string | undefined;
33
+ minVersion?: string | undefined;
31
34
  extensions?: any;
32
35
  extras?: any;
33
36
  };
@@ -61,16 +64,35 @@ export class GLTFLoader extends Loader {
61
64
  onLoad: (gltf: GLTF) => void,
62
65
  onError?: (event: ErrorEvent) => void,
63
66
  ): void;
67
+
68
+ parseAsync(data: ArrayBuffer | string, path: string): Promise<void>;
64
69
  }
65
70
 
71
+ export type GLTFReferenceType = 'materials' | 'nodes' | 'textures' | 'meshes';
72
+
66
73
  export interface GLTFReference {
67
- type: 'materials' | 'nodes' | 'textures';
68
- index: number;
74
+ materials?: number;
75
+ nodes?: number;
76
+ textures?: number;
77
+ meshes?: number;
69
78
  }
70
79
 
71
80
  export class GLTFParser {
72
81
  json: any;
73
82
 
83
+ options: {
84
+ path: string;
85
+ manager: LoadingManager;
86
+ ktx2Loader: KTX2Loader;
87
+ meshoptDecoder: /* MeshoptDecoder */ any;
88
+ crossOrigin: string;
89
+ requestHeader: { [header: string]: string };
90
+ };
91
+
92
+ fileLoader: FileLoader;
93
+ textureLoader: TextureLoader | ImageBitmapLoader;
94
+ plugins: GLTFLoaderPlugin;
95
+ extensions: { [name: string]: any };
74
96
  associations: Map<Object3D | Material | Texture, GLTFReference>;
75
97
 
76
98
  getDependency: (type: string, index: number) => Promise<any>;
@@ -93,7 +115,7 @@ export class GLTFParser {
93
115
  mapName: string,
94
116
  mapDef: {
95
117
  index: number;
96
- texCoord?: number;
118
+ texCoord?: number | undefined;
97
119
  extensions?: any;
98
120
  },
99
121
  ) => Promise<void>;
@@ -101,6 +123,7 @@ export class GLTFParser {
101
123
  getMaterialType: () => typeof MeshStandardMaterial;
102
124
  loadMaterial: (materialIndex: number) => Promise<Material>;
103
125
  createUniqueName: (originalName: string) => string;
126
+ createNodeMesh: (nodeIndex: number) => Promise<Group | Mesh | SkinnedMesh>;
104
127
  loadGeometries: (
105
128
  /**
106
129
  * GLTF.Primitive[]
@@ -110,11 +133,9 @@ export class GLTFParser {
110
133
  ) => Promise<BufferGeometry[]>;
111
134
  loadMesh: (meshIndex: number) => Promise<Group | Mesh | SkinnedMesh>;
112
135
  loadCamera: (cameraIndex: number) => Promise<Camera>;
113
- loadSkin: (
114
- skinIndex: number,
115
- ) => Promise<{
136
+ loadSkin: (skinIndex: number) => Promise<{
116
137
  joints: number[];
117
- inverseBindMatrices?: BufferAttribute | InterleavedBufferAttribute;
138
+ inverseBindMatrices?: BufferAttribute | InterleavedBufferAttribute | undefined;
118
139
  }>;
119
140
  loadAnimation: (animationIndex: number) => Promise<AnimationClip>;
120
141
  loadNode: (nodeIndex: number) => Promise<Object3D>;
@@ -122,13 +143,16 @@ export class GLTFParser {
122
143
  }
123
144
 
124
145
  export interface GLTFLoaderPlugin {
125
- beforeRoot?: () => Promise<void> | null;
126
- afterRoot?: (result: GLTF) => Promise<void> | null;
127
- loadMesh?: (meshIndex: number) => Promise<Group | Mesh | SkinnedMesh> | null;
128
- loadBufferView?: (bufferViewIndex: number) => Promise<ArrayBuffer> | null;
129
- loadMaterial?: (materialIndex: number) => Promise<Material> | null;
130
- loadTexture?: (textureIndex: number) => Promise<Texture> | null;
131
- getMaterialType?: (materialIndex: number) => typeof Material | null;
132
- extendMaterialParams?: (materialIndex: number, materialParams: { [key: string]: any }) => Promise<any> | null;
133
- createNodeAttachment?: (nodeIndex: number) => Promise<Object3D> | null;
146
+ beforeRoot?: (() => Promise<void> | null) | undefined;
147
+ afterRoot?: ((result: GLTF) => Promise<void> | null) | undefined;
148
+ loadMesh?: ((meshIndex: number) => Promise<Group | Mesh | SkinnedMesh> | null) | undefined;
149
+ loadBufferView?: ((bufferViewIndex: number) => Promise<ArrayBuffer> | null) | undefined;
150
+ loadMaterial?: ((materialIndex: number) => Promise<Material> | null) | undefined;
151
+ loadTexture?: ((textureIndex: number) => Promise<Texture> | null) | undefined;
152
+ getMaterialType?: ((materialIndex: number) => typeof Material | null) | undefined;
153
+ extendMaterialParams?:
154
+ | ((materialIndex: number, materialParams: { [key: string]: any }) => Promise<any> | null)
155
+ | undefined;
156
+ createNodeMesh?: ((nodeIndex: number) => Promise<Group | Mesh | SkinnedMesh> | null) | undefined;
157
+ createNodeAttachment?: ((nodeIndex: number) => Promise<Object3D> | null) | undefined;
134
158
  }
@@ -1,6 +1,11 @@
1
1
  import { Loader, LoadingManager, Group, Material } from 'three';
2
2
 
3
3
  export class LDrawLoader extends Loader {
4
+ materials: Material[];
5
+ materialsLibrary: Record<string, Material>;
6
+ fileMap: Record<string, string>;
7
+ smoothNormals: boolean;
8
+
4
9
  constructor(manager?: LoadingManager);
5
10
 
6
11
  load(
@@ -10,6 +15,7 @@ export class LDrawLoader extends Loader {
10
15
  onError?: (event: ErrorEvent) => void,
11
16
  ): void;
12
17
  loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<Group>;
18
+ preloadMaterials(url: string): Promise<void>;
13
19
  setFileMap(fileMap: Record<string, string>): void;
14
20
  setMaterials(materials: Material[]): void;
15
21