@threepipe/plugins-extra-importers 0.2.2 → 0.2.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.
@@ -1,5 +1,5 @@
1
1
  Name: three
2
- Version: 0.153.1006
2
+ Version: 0.157.1007
3
3
  License: MIT
4
4
  Private: false
5
5
  Description: JavaScript 3D library
package/dist/index.d.ts CHANGED
@@ -30,8 +30,6 @@ export declare class ColladaLoadPlugin extends BaseImporterPlugin {
30
30
  static readonly PluginType = "ColladaLoadPlugin";
31
31
  protected _importer: Importer<{
32
32
  transform(res: Collada, _: AnyOptions): Scene;
33
- load(url: string, onLoad: (collada: Collada) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
34
- loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<Collada>;
35
33
  parse(text: string, path: string): Collada;
36
34
  crossOrigin: string;
37
35
  withCredentials: boolean;
@@ -41,6 +39,8 @@ export declare class ColladaLoadPlugin extends BaseImporterPlugin {
41
39
  requestHeader: {
42
40
  [header: string]: string;
43
41
  };
42
+ load(url: string, onLoad: (data: Collada) => void, onProgress?: (event: ProgressEvent) => void, onError?: (err: unknown) => void): void;
43
+ loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<Collada>;
44
44
  setCrossOrigin(crossOrigin: string): /*elided*/ any;
45
45
  setWithCredentials(value: boolean): /*elided*/ any;
46
46
  setPath(path: string): /*elided*/ any;
@@ -73,8 +73,6 @@ export declare class BVHLoadPlugin extends BaseImporterPlugin {
73
73
  transform(res: BVH, _: AnyOptions): Object3D;
74
74
  animateBonePositions: boolean;
75
75
  animateBoneRotations: boolean;
76
- load(url: string, onLoad: (bvh: BVH) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
77
- loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<BVH>;
78
76
  parse(text: string): BVH;
79
77
  crossOrigin: string;
80
78
  withCredentials: boolean;
@@ -84,6 +82,8 @@ export declare class BVHLoadPlugin extends BaseImporterPlugin {
84
82
  requestHeader: {
85
83
  [header: string]: string;
86
84
  };
85
+ load(url: string, onLoad: (data: BVH) => void, onProgress?: (event: ProgressEvent) => void, onError?: (err: unknown) => void): void;
86
+ loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<BVH>;
87
87
  setCrossOrigin(crossOrigin: string): /*elided*/ any;
88
88
  setWithCredentials(value: boolean): /*elided*/ any;
89
89
  setPath(path: string): /*elided*/ any;
@@ -100,8 +100,6 @@ export declare class VOXLoadPlugin extends BaseImporterPlugin {
100
100
  static readonly PluginType = "VOXLoadPlugin";
101
101
  protected _importer: Importer<{
102
102
  transform(chunks: Chunk[], _: AnyOptions): Object3D;
103
- load(url: string, onLoad: (chunks: Chunk[]) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
104
- loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<Chunk[]>;
105
103
  parse(data: ArrayBuffer): object[];
106
104
  crossOrigin: string;
107
105
  withCredentials: boolean;
@@ -111,6 +109,8 @@ export declare class VOXLoadPlugin extends BaseImporterPlugin {
111
109
  requestHeader: {
112
110
  [header: string]: string;
113
111
  };
112
+ load(url: string, onLoad: (data: Chunk[]) => void, onProgress?: (event: ProgressEvent) => void, onError?: (err: unknown) => void): void;
113
+ loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<Chunk[]>;
114
114
  setCrossOrigin(crossOrigin: string): /*elided*/ any;
115
115
  setWithCredentials(value: boolean): /*elided*/ any;
116
116
  setPath(path: string): /*elided*/ any;
@@ -127,8 +127,6 @@ export declare class MDDLoadPlugin extends BaseImporterPlugin {
127
127
  static readonly PluginType = "MDDLoadPlugin";
128
128
  protected _importer: Importer<{
129
129
  transform(res: MDD, _: AnyOptions): Object3D;
130
- load(url: string, onLoad: (result: MDD) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
131
- loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<MDD>;
132
130
  parse(data: ArrayBuffer): MDD;
133
131
  crossOrigin: string;
134
132
  withCredentials: boolean;
@@ -138,6 +136,8 @@ export declare class MDDLoadPlugin extends BaseImporterPlugin {
138
136
  requestHeader: {
139
137
  [header: string]: string;
140
138
  };
139
+ load(url: string, onLoad: (data: MDD) => void, onProgress?: (event: ProgressEvent) => void, onError?: (err: unknown) => void): void;
140
+ loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<MDD>;
141
141
  setCrossOrigin(crossOrigin: string): /*elided*/ any;
142
142
  setWithCredentials(value: boolean): /*elided*/ any;
143
143
  setPath(path: string): /*elided*/ any;
@@ -155,8 +155,6 @@ export declare class PCDLoadPlugin extends BaseImporterPlugin {
155
155
  protected _importer: Importer<{
156
156
  transform(points: Points, options: AnyOptions): any;
157
157
  littleEndian: boolean;
158
- load(url: string, onLoad: (points: Points) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
159
- loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<Points>;
160
158
  parse(data: ArrayBuffer | string): Points;
161
159
  crossOrigin: string;
162
160
  withCredentials: boolean;
@@ -166,6 +164,8 @@ export declare class PCDLoadPlugin extends BaseImporterPlugin {
166
164
  requestHeader: {
167
165
  [header: string]: string;
168
166
  };
167
+ load(url: string, onLoad: (data: Points<BufferGeometry<import('./threepipe').NormalBufferAttributes, import('./threepipe').BufferGeometryEventMap>, import('threepipe').Material<import('./threepipe').MaterialEventMap> | import('threepipe').Material<import('./threepipe').MaterialEventMap>[]>) => void, onProgress?: (event: ProgressEvent) => void, onError?: (err: unknown) => void): void;
168
+ loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<Points<BufferGeometry<import('./threepipe').NormalBufferAttributes, import('./threepipe').BufferGeometryEventMap>, import('threepipe').Material<import('./threepipe').MaterialEventMap> | import('threepipe').Material<import('./threepipe').MaterialEventMap>[]>>;
169
169
  setCrossOrigin(crossOrigin: string): /*elided*/ any;
170
170
  setWithCredentials(value: boolean): /*elided*/ any;
171
171
  setPath(path: string): /*elided*/ any;
@@ -200,8 +200,6 @@ export declare class LDrawLoadPlugin extends BaseImporterPlugin {
200
200
  materialsLibrary: Record<string, import('threepipe').Material>;
201
201
  fileMap: Record<string, string>;
202
202
  smoothNormals: boolean;
203
- load(url: string, onLoad: (data: Group) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
204
- loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<Group>;
205
203
  preloadMaterials(url: string): Promise<void>;
206
204
  setFileMap(fileMap: Record<string, string>): void;
207
205
  setMaterials(materials: import('threepipe').Material[]): void;
@@ -216,6 +214,8 @@ export declare class LDrawLoadPlugin extends BaseImporterPlugin {
216
214
  requestHeader: {
217
215
  [header: string]: string;
218
216
  };
217
+ load(url: string, onLoad: (data: Group<import('./threepipe').Object3DEventMap>) => void, onProgress?: (event: ProgressEvent) => void, onError?: (err: unknown) => void): void;
218
+ loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<Group<import('./threepipe').Object3DEventMap>>;
219
219
  setCrossOrigin(crossOrigin: string): /*elided*/ any;
220
220
  setWithCredentials(value: boolean): /*elided*/ any;
221
221
  setPath(path: string): /*elided*/ any;
@@ -232,8 +232,6 @@ export declare class VTKLoadPlugin extends BaseImporterPlugin {
232
232
  static readonly PluginType = "VTKLoadPlugin";
233
233
  protected _importer: Importer<{
234
234
  transform(res: BufferGeometry, _: AnyOptions): Mesh | undefined;
235
- load(url: string, onLoad: (geometry: BufferGeometry) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
236
- loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<BufferGeometry>;
237
235
  parse(data: ArrayBuffer | string, path: string): BufferGeometry;
238
236
  crossOrigin: string;
239
237
  withCredentials: boolean;
@@ -243,6 +241,8 @@ export declare class VTKLoadPlugin extends BaseImporterPlugin {
243
241
  requestHeader: {
244
242
  [header: string]: string;
245
243
  };
244
+ load(url: string, onLoad: (data: BufferGeometry<import('./threepipe').NormalBufferAttributes, import('./threepipe').BufferGeometryEventMap>) => void, onProgress?: (event: ProgressEvent) => void, onError?: (err: unknown) => void): void;
245
+ loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<BufferGeometry<import('./threepipe').NormalBufferAttributes, import('./threepipe').BufferGeometryEventMap>>;
246
246
  setCrossOrigin(crossOrigin: string): /*elided*/ any;
247
247
  setWithCredentials(value: boolean): /*elided*/ any;
248
248
  setPath(path: string): /*elided*/ any;
@@ -259,8 +259,6 @@ export declare class XYZLoadPlugin extends BaseImporterPlugin {
259
259
  static readonly PluginType = "XYZLoadPlugin";
260
260
  protected _importer: Importer<{
261
261
  transform(res: BufferGeometry, options: AnyOptions): Points | undefined;
262
- load(url: string, onLoad: (geometry: BufferGeometry) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
263
- loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<BufferGeometry>;
264
262
  parse(data: string, onLoad: (geometry: BufferGeometry) => void): object;
265
263
  crossOrigin: string;
266
264
  withCredentials: boolean;
@@ -270,6 +268,8 @@ export declare class XYZLoadPlugin extends BaseImporterPlugin {
270
268
  requestHeader: {
271
269
  [header: string]: string;
272
270
  };
271
+ load(url: string, onLoad: (data: BufferGeometry<import('./threepipe').NormalBufferAttributes, import('./threepipe').BufferGeometryEventMap>) => void, onProgress?: (event: ProgressEvent) => void, onError?: (err: unknown) => void): void;
272
+ loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<BufferGeometry<import('./threepipe').NormalBufferAttributes, import('./threepipe').BufferGeometryEventMap>>;
273
273
  setCrossOrigin(crossOrigin: string): /*elided*/ any;
274
274
  setWithCredentials(value: boolean): /*elided*/ any;
275
275
  setPath(path: string): /*elided*/ any;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * @threepipe/plugins-extra-importers v0.2.2
3
+ * @threepipe/plugins-extra-importers v0.2.3
4
4
  * Copyright 2022-2025 repalash <palash@shaders.app>
5
5
  * Apache-2.0 License
6
6
  * See ./dependencies.txt for any bundled third-party dependencies and licenses.
@@ -1660,7 +1660,11 @@ class ThreeMFLoader extends Loader {
1660
1660
  const geometry = new BufferGeometry();
1661
1661
  geometry.setIndex(new BufferAttribute(meshData["triangles"], 1));
1662
1662
  geometry.setAttribute("position", new BufferAttribute(meshData["vertices"], 3));
1663
- const material = new MeshPhongMaterial({ color: 16777215, flatShading: true });
1663
+ const material = new MeshPhongMaterial({
1664
+ name: Loader.DEFAULT_MATERIAL_NAME,
1665
+ color: 16777215,
1666
+ flatShading: true
1667
+ });
1664
1668
  const mesh = new Mesh(geometry, material);
1665
1669
  return mesh;
1666
1670
  }
@@ -1882,7 +1886,7 @@ class TGALoader extends DataTextureLoader {
1882
1886
  case TGA_TYPE_INDEXED:
1883
1887
  case TGA_TYPE_RLE_INDEXED:
1884
1888
  if (header2.colormap_length > 256 || header2.colormap_size !== 24 || header2.colormap_type !== 1) {
1885
- console.error("THREE.TGALoader: Invalid type colormap data for indexed type.");
1889
+ throw new Error("THREE.TGALoader: Invalid type colormap data for indexed type.");
1886
1890
  }
1887
1891
  break;
1888
1892
  // check colormap type
@@ -1891,21 +1895,21 @@ class TGALoader extends DataTextureLoader {
1891
1895
  case TGA_TYPE_RLE_RGB:
1892
1896
  case TGA_TYPE_RLE_GREY:
1893
1897
  if (header2.colormap_type) {
1894
- console.error("THREE.TGALoader: Invalid type colormap data for colormap type.");
1898
+ throw new Error("THREE.TGALoader: Invalid type colormap data for colormap type.");
1895
1899
  }
1896
1900
  break;
1897
1901
  // What the need of a file without data ?
1898
1902
  case TGA_TYPE_NO_DATA:
1899
- console.error("THREE.TGALoader: No data.");
1903
+ throw new Error("THREE.TGALoader: No data.");
1900
1904
  // Invalid type ?
1901
1905
  default:
1902
- console.error('THREE.TGALoader: Invalid type "%s".', header2.image_type);
1906
+ throw new Error("THREE.TGALoader: Invalid type " + header2.image_type);
1903
1907
  }
1904
1908
  if (header2.width <= 0 || header2.height <= 0) {
1905
- console.error("THREE.TGALoader: Invalid image size.");
1909
+ throw new Error("THREE.TGALoader: Invalid image size.");
1906
1910
  }
1907
1911
  if (header2.pixel_size !== 8 && header2.pixel_size !== 16 && header2.pixel_size !== 24 && header2.pixel_size !== 32) {
1908
- console.error('THREE.TGALoader: Invalid pixel size "%s".', header2.pixel_size);
1912
+ throw new Error("THREE.TGALoader: Invalid pixel size " + header2.pixel_size);
1909
1913
  }
1910
1914
  }
1911
1915
  function tgaParse(use_rle2, use_pal2, header2, offset2, data) {
@@ -2078,8 +2082,7 @@ class TGALoader extends DataTextureLoader {
2078
2082
  tgaGetImageDataGrey16bits(data, y_start, y_step, y_end, x_start, x_step, x_end, image);
2079
2083
  break;
2080
2084
  default:
2081
- console.error("THREE.TGALoader: Format not supported.");
2082
- break;
2085
+ throw new Error("THREE.TGALoader: Format not supported.");
2083
2086
  }
2084
2087
  } else {
2085
2088
  switch (header.pixel_size) {
@@ -2096,14 +2099,13 @@ class TGALoader extends DataTextureLoader {
2096
2099
  tgaGetImageData32bits(data, y_start, y_step, y_end, x_start, x_step, x_end, image);
2097
2100
  break;
2098
2101
  default:
2099
- console.error("THREE.TGALoader: Format not supported.");
2100
- break;
2102
+ throw new Error("THREE.TGALoader: Format not supported.");
2101
2103
  }
2102
2104
  }
2103
2105
  return data;
2104
2106
  }
2105
2107
  const TGA_TYPE_NO_DATA = 0, TGA_TYPE_INDEXED = 1, TGA_TYPE_RGB = 2, TGA_TYPE_GREY = 3, TGA_TYPE_RLE_INDEXED = 9, TGA_TYPE_RLE_RGB = 10, TGA_TYPE_RLE_GREY = 11, TGA_ORIGIN_MASK = 48, TGA_ORIGIN_SHIFT = 4, TGA_ORIGIN_BL = 0, TGA_ORIGIN_BR = 1, TGA_ORIGIN_UL = 2, TGA_ORIGIN_UR = 3;
2106
- if (buffer.length < 19) console.error("THREE.TGALoader: Not enough data to contain header.");
2108
+ if (buffer.length < 19) throw new Error("THREE.TGALoader: Not enough data to contain header.");
2107
2109
  let offset = 0;
2108
2110
  const content = new Uint8Array(buffer), header = {
2109
2111
  id_length: content[offset++],
@@ -2123,7 +2125,7 @@ class TGALoader extends DataTextureLoader {
2123
2125
  };
2124
2126
  tgaCheckHeader(header);
2125
2127
  if (header.id_length + offset > buffer.length) {
2126
- console.error("THREE.TGALoader: No data.");
2128
+ throw new Error("THREE.TGALoader: No data.");
2127
2129
  }
2128
2130
  offset += header.id_length;
2129
2131
  let use_rle = false, use_pal = false, use_grey = false;
@@ -4268,7 +4270,10 @@ class ColladaLoader extends Loader {
4268
4270
  object.matrix.decompose(object.position, object.quaternion, object.scale);
4269
4271
  return object;
4270
4272
  }
4271
- const fallbackMaterial = new MeshBasicMaterial({ color: 16711935 });
4273
+ const fallbackMaterial = new MeshBasicMaterial({
4274
+ name: Loader.DEFAULT_MATERIAL_NAME,
4275
+ color: 16711935
4276
+ });
4272
4277
  function resolveMaterialBinding(keys, instanceMaterials) {
4273
4278
  const materials = [];
4274
4279
  for (let i = 0, l = keys.length; i < l; i++) {
@@ -4717,7 +4722,11 @@ class AMFLoader extends Loader {
4717
4722
  }
4718
4723
  }
4719
4724
  const sceneObject = new Group();
4720
- const defaultMaterial = new MeshPhongMaterial({ color: 11184895, flatShading: true });
4725
+ const defaultMaterial = new MeshPhongMaterial({
4726
+ name: Loader.DEFAULT_MATERIAL_NAME,
4727
+ color: 11184895,
4728
+ flatShading: true
4729
+ });
4721
4730
  sceneObject.name = amfName;
4722
4731
  sceneObject.userData.author = amfAuthor;
4723
4732
  sceneObject.userData.loader = "AMF";
@@ -11387,7 +11396,10 @@ class VRMLLoader extends Loader {
11387
11396
  }
11388
11397
  function buildShapeNode(node) {
11389
11398
  const fields = node.fields;
11390
- let material = new MeshBasicMaterial({ color: 0 });
11399
+ let material = new MeshBasicMaterial({
11400
+ name: Loader.DEFAULT_MATERIAL_NAME,
11401
+ color: 0
11402
+ });
11391
11403
  let geometry;
11392
11404
  for (let i = 0, l = fields.length; i < l; i++) {
11393
11405
  const field = fields[i];
@@ -11413,7 +11425,10 @@ class VRMLLoader extends Loader {
11413
11425
  if (geometry && geometry.attributes.position) {
11414
11426
  const type = geometry._type;
11415
11427
  if (type === "points") {
11416
- const pointsMaterial = new PointsMaterial({ color: 16777215 });
11428
+ const pointsMaterial = new PointsMaterial({
11429
+ name: Loader.DEFAULT_MATERIAL_NAME,
11430
+ color: 16777215
11431
+ });
11417
11432
  if (geometry.attributes.color !== void 0) {
11418
11433
  pointsMaterial.vertexColors = true;
11419
11434
  } else {
@@ -11423,7 +11438,10 @@ class VRMLLoader extends Loader {
11423
11438
  }
11424
11439
  object = new Points(geometry, pointsMaterial);
11425
11440
  } else if (type === "line") {
11426
- const lineMaterial = new LineBasicMaterial({ color: 16777215 });
11441
+ const lineMaterial = new LineBasicMaterial({
11442
+ name: Loader.DEFAULT_MATERIAL_NAME,
11443
+ color: 16777215
11444
+ });
11427
11445
  if (geometry.attributes.color !== void 0) {
11428
11446
  lineMaterial.vertexColors = true;
11429
11447
  } else {
@@ -11466,7 +11484,10 @@ class VRMLLoader extends Loader {
11466
11484
  if (materialData.transparency) material.opacity = 1 - materialData.transparency;
11467
11485
  if (materialData.transparency > 0) material.transparent = true;
11468
11486
  } else {
11469
- material = new MeshBasicMaterial({ color: 0 });
11487
+ material = new MeshBasicMaterial({
11488
+ name: Loader.DEFAULT_MATERIAL_NAME,
11489
+ color: 0
11490
+ });
11470
11491
  }
11471
11492
  break;
11472
11493
  case "texture":
@@ -12924,7 +12945,7 @@ class LDrawConditionalLineMaterial extends ShaderMaterial {
12924
12945
  outgoingLight = diffuseColor.rgb; // simple shader
12925
12946
  gl_FragColor = vec4( outgoingLight, diffuseColor.a );
12926
12947
  #include <tonemapping_fragment>
12927
- #include <encodings_fragment>
12948
+ #include <colorspace_fragment>
12928
12949
  #include <fog_fragment>
12929
12950
  #include <premultiplied_alpha_fragment>
12930
12951
  }
@@ -13285,7 +13306,7 @@ class LDrawParsedCache {
13285
13306
  try {
13286
13307
  const text = await fileLoader.loadAsync(subobjectURL);
13287
13308
  return text;
13288
- } catch {
13309
+ } catch (_) {
13289
13310
  continue;
13290
13311
  }
13291
13312
  }
@@ -13755,13 +13776,13 @@ class LDrawPartsGeometryCache {
13755
13776
  }
13756
13777
  const group = info.group;
13757
13778
  if (info.faces.length > 0) {
13758
- group.add(createObject(info.faces, 3, false, info.totalFaces));
13779
+ group.add(createObject(this.loader, info.faces, 3, false, info.totalFaces));
13759
13780
  }
13760
13781
  if (info.lineSegments.length > 0) {
13761
- group.add(createObject(info.lineSegments, 2));
13782
+ group.add(createObject(this.loader, info.lineSegments, 2));
13762
13783
  }
13763
13784
  if (info.conditionalSegments.length > 0) {
13764
- group.add(createObject(info.conditionalSegments, 2, true));
13785
+ group.add(createObject(this.loader, info.conditionalSegments, 2, true));
13765
13786
  }
13766
13787
  return group;
13767
13788
  }
@@ -13816,7 +13837,7 @@ function sortByMaterial(a, b) {
13816
13837
  }
13817
13838
  return 1;
13818
13839
  }
13819
- function createObject(elements, elementSize, isConditionalSegments = false, totalElements = null) {
13840
+ function createObject(loader, elements, elementSize, isConditionalSegments = false, totalElements = null) {
13820
13841
  elements.sort(sortByMaterial);
13821
13842
  if (totalElements === null) {
13822
13843
  totalElements = elements.length;
@@ -13889,9 +13910,10 @@ function createObject(elements, elementSize, isConditionalSegments = false, tota
13889
13910
  materials.push(material);
13890
13911
  } else if (elementSize === 2) {
13891
13912
  if (isConditionalSegments) {
13892
- materials.push(material.userData.edgeMaterial.userData.conditionalEdgeMaterial);
13913
+ const edgeMaterial = loader.edgeMaterialCache.get(material);
13914
+ materials.push(loader.conditionalEdgeMaterialCache.get(edgeMaterial));
13893
13915
  } else {
13894
- materials.push(material.userData.edgeMaterial);
13916
+ materials.push(loader.edgeMaterialCache.get(material));
13895
13917
  }
13896
13918
  }
13897
13919
  } else {
@@ -13966,19 +13988,18 @@ class LDrawLoader extends Loader {
13966
13988
  super(manager);
13967
13989
  this.materials = [];
13968
13990
  this.materialLibrary = {};
13991
+ this.edgeMaterialCache = /* @__PURE__ */ new WeakMap();
13992
+ this.conditionalEdgeMaterialCache = /* @__PURE__ */ new WeakMap();
13969
13993
  this.partsCache = new LDrawPartsGeometryCache(this);
13970
13994
  this.fileMap = {};
13971
13995
  this.setMaterials([]);
13972
13996
  this.smoothNormals = true;
13973
13997
  this.partsLibraryPath = "";
13974
- this.missingColorMaterial = new MeshStandardMaterial({ color: 16711935, roughness: 0.3, metalness: 0 });
13975
- this.missingColorMaterial.name = "Missing material";
13976
- this.missingEdgeColorMaterial = new LineBasicMaterial({ color: 16711935 });
13977
- this.missingEdgeColorMaterial.name = "Missing material - Edge";
13978
- this.missingConditionalEdgeColorMaterial = new LDrawConditionalLineMaterial({ fog: true, color: 16711935 });
13979
- this.missingConditionalEdgeColorMaterial.name = "Missing material - Conditional Edge";
13980
- this.missingColorMaterial.userData.edgeMaterial = this.missingEdgeColorMaterial;
13981
- this.missingEdgeColorMaterial.userData.conditionalEdgeMaterial = this.missingConditionalEdgeColorMaterial;
13998
+ this.missingColorMaterial = new MeshStandardMaterial({ name: Loader.DEFAULT_MATERIAL_NAME, color: 16711935, roughness: 0.3, metalness: 0 });
13999
+ this.missingEdgeColorMaterial = new LineBasicMaterial({ name: Loader.DEFAULT_MATERIAL_NAME, color: 16711935 });
14000
+ this.missingConditionalEdgeColorMaterial = new LDrawConditionalLineMaterial({ name: Loader.DEFAULT_MATERIAL_NAME, fog: true, color: 16711935 });
14001
+ this.edgeMaterialCache.set(this.missingColorMaterial, this.missingEdgeColorMaterial);
14002
+ this.conditionalEdgeMaterialCache.set(this.missingEdgeColorMaterial, this.missingConditionalEdgeColorMaterial);
13982
14003
  }
13983
14004
  setPartsLibraryPath(path) {
13984
14005
  this.partsLibraryPath = path;
@@ -14094,9 +14115,9 @@ class LDrawLoader extends Loader {
14094
14115
  return colorCode;
14095
14116
  }
14096
14117
  if (c.isLineSegments) {
14097
- material = material.userData.edgeMaterial;
14118
+ material = loader.edgeMaterialCache.get(material);
14098
14119
  if (c.isConditionalLine) {
14099
- material = material.userData.conditionalEdgeMaterial;
14120
+ material = loader.conditionalEdgeMaterialCache.get(material);
14100
14121
  }
14101
14122
  }
14102
14123
  return material;
@@ -14107,7 +14128,7 @@ class LDrawLoader extends Loader {
14107
14128
  }
14108
14129
  getMainEdgeMaterial() {
14109
14130
  const mat = this.getMaterial(MAIN_EDGE_COLOUR_CODE);
14110
- return mat ? mat.userData.edgeMaterial : null;
14131
+ return mat ? this.edgeMaterialCache.get(mat) : null;
14111
14132
  }
14112
14133
  parseColorMetaDirective(lineParser) {
14113
14134
  let code = null;
@@ -14150,7 +14171,7 @@ class LDrawLoader extends Loader {
14150
14171
  if (!edgeMaterial) {
14151
14172
  throw new Error("LDrawLoader: Invalid edge color while parsing material" + lineParser.getLineNumberString() + ".");
14152
14173
  }
14153
- edgeMaterial = edgeMaterial.userData.edgeMaterial;
14174
+ edgeMaterial = this.edgeMaterialCache.get(edgeMaterial);
14154
14175
  }
14155
14176
  break;
14156
14177
  case "ALPHA":
@@ -14232,19 +14253,20 @@ class LDrawLoader extends Loader {
14232
14253
  edgeMaterial.color;
14233
14254
  edgeMaterial.userData.code = code;
14234
14255
  edgeMaterial.name = name + " - Edge";
14235
- edgeMaterial.userData.conditionalEdgeMaterial = new LDrawConditionalLineMaterial({
14256
+ const conditionalEdgeMaterial = new LDrawConditionalLineMaterial({
14236
14257
  fog: true,
14237
14258
  transparent: isTransparent,
14238
14259
  depthWrite: !isTransparent,
14239
14260
  color: new Color().setStyle(edgeColor, COLOR_SPACE_LDRAW),
14240
14261
  opacity: alpha
14241
14262
  });
14242
- edgeMaterial.userData.conditionalEdgeMaterial.userData.code = code;
14243
- edgeMaterial.userData.conditionalEdgeMaterial.name = name + " - Conditional Edge";
14263
+ conditionalEdgeMaterial.userData.code = code;
14264
+ conditionalEdgeMaterial.name = name + " - Conditional Edge";
14265
+ this.conditionalEdgeMaterialCache.set(edgeMaterial, conditionalEdgeMaterial);
14244
14266
  }
14245
14267
  material.userData.code = code;
14246
14268
  material.name = name;
14247
- material.userData.edgeMaterial = edgeMaterial;
14269
+ this.edgeMaterialCache.set(material, edgeMaterial);
14248
14270
  this.addMaterial(material);
14249
14271
  return material;
14250
14272
  function parseLuminance(token2) {