@inweb/viewer-three 27.4.2 → 27.4.4
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/viewer-three.js +145 -53
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +3 -3
- package/dist/viewer-three.module.js +146 -54
- package/dist/viewer-three.module.js.map +1 -1
- package/package.json +5 -5
- package/src/Viewer/loaders/DynamicGltfLoader/DynamicGltfLoader.js +19 -42
- package/src/Viewer/loaders/DynamicGltfLoader/GltfStructure.js +164 -34
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
import { draggersRegistry, commandsRegistry, Options, componentsRegistry, Info, Loader, loadersRegistry, CANVAS_EVENTS } from '@inweb/viewer-core';
|
|
25
25
|
export * from '@inweb/viewer-core';
|
|
26
|
-
import { EventDispatcher, Vector3, MOUSE, TOUCH, Spherical, Quaternion, Vector2, Object3D, BufferGeometry, Float32BufferAttribute, Line, LineBasicMaterial, Mesh, MeshBasicMaterial, DoubleSide, Line3, Raycaster, MathUtils, EdgesGeometry, Plane, Matrix4, Vector4, Controls, Box3, Clock, Color, PerspectiveCamera, OrthographicCamera, AmbientLight, DirectionalLight, HemisphereLight, REVISION, MeshPhongMaterial, WebGLRenderTarget, UnsignedByteType, RGBAFormat, CylinderGeometry, Sprite, CanvasTexture, SRGBColorSpace, SpriteMaterial, TextureLoader, BufferAttribute, PointsMaterial, DataTexture, FloatType,
|
|
26
|
+
import { EventDispatcher, Vector3, MOUSE, TOUCH, Spherical, Quaternion, Vector2, Object3D, BufferGeometry, Float32BufferAttribute, Line, LineBasicMaterial, Mesh, MeshBasicMaterial, DoubleSide, Line3, Raycaster, MathUtils, EdgesGeometry, Plane, Matrix4, Vector4, Controls, Box3, Clock, Color, PerspectiveCamera, OrthographicCamera, AmbientLight, DirectionalLight, HemisphereLight, REVISION, MeshPhongMaterial, WebGLRenderTarget, UnsignedByteType, RGBAFormat, CylinderGeometry, Sprite, CanvasTexture, SRGBColorSpace, SpriteMaterial, TextureLoader, BufferAttribute, LinearMipmapLinearFilter, NearestMipmapLinearFilter, LinearMipmapNearestFilter, NearestMipmapNearestFilter, LinearFilter, NearestFilter, RepeatWrapping, MirroredRepeatWrapping, ClampToEdgeWrapping, PointsMaterial, MeshStandardMaterial, DataTexture, FloatType, Points, TriangleStripDrawMode, TriangleFanDrawMode, LineSegments, LineLoop, Group, NormalBlending, LoadingManager, LoaderUtils, FileLoader, UniformsUtils, ShaderMaterial, AdditiveBlending, HalfFloatType, Scene, WebGLRenderer, LinearSRGBColorSpace } from 'three';
|
|
27
27
|
import { TransformControls } from 'three/examples/jsm/controls/TransformControls.js';
|
|
28
28
|
import { LineSegmentsGeometry } from 'three/examples/jsm/lines/LineSegmentsGeometry.js';
|
|
29
29
|
import { Wireframe } from 'three/examples/jsm/lines/Wireframe.js';
|
|
@@ -4017,6 +4017,19 @@ class DynamicModelImpl extends ModelImpl {
|
|
|
4017
4017
|
}
|
|
4018
4018
|
}
|
|
4019
4019
|
|
|
4020
|
+
const GL_TO_THREE_WRAP = {
|
|
4021
|
+
33071: ClampToEdgeWrapping,
|
|
4022
|
+
33648: MirroredRepeatWrapping,
|
|
4023
|
+
10497: RepeatWrapping,
|
|
4024
|
+
};
|
|
4025
|
+
const GL_TO_THREE_FILTER = {
|
|
4026
|
+
9728: NearestFilter,
|
|
4027
|
+
9729: LinearFilter,
|
|
4028
|
+
9984: NearestMipmapNearestFilter,
|
|
4029
|
+
9985: LinearMipmapNearestFilter,
|
|
4030
|
+
9986: NearestMipmapLinearFilter,
|
|
4031
|
+
9987: LinearMipmapLinearFilter,
|
|
4032
|
+
};
|
|
4020
4033
|
const GL_COMPONENT_TYPES = {
|
|
4021
4034
|
5120: Int8Array,
|
|
4022
4035
|
5121: Uint8Array,
|
|
@@ -4059,6 +4072,7 @@ class GltfStructure {
|
|
|
4059
4072
|
this.pendingRequests = [];
|
|
4060
4073
|
this.batchTimeout = null;
|
|
4061
4074
|
this.textureLoader = new TextureLoader();
|
|
4075
|
+
this.textureLoader.crossOrigin = "anonymous";
|
|
4062
4076
|
this.materials = new Map();
|
|
4063
4077
|
this.textureCache = new Map();
|
|
4064
4078
|
this.materialCache = new Map();
|
|
@@ -4070,7 +4084,7 @@ class GltfStructure {
|
|
|
4070
4084
|
async initialize(loader) {
|
|
4071
4085
|
const json = await this.loadController.loadJson();
|
|
4072
4086
|
if (json.asset === undefined || json.asset.version[0] < 2) {
|
|
4073
|
-
throw new Error("
|
|
4087
|
+
throw new Error("DynamicLoader: Unsupported asset. glTF versions >=2.0 are supported.");
|
|
4074
4088
|
}
|
|
4075
4089
|
this.json = json;
|
|
4076
4090
|
this.loader = loader;
|
|
@@ -4098,7 +4112,9 @@ class GltfStructure {
|
|
|
4098
4112
|
scheduleRequest(request) {
|
|
4099
4113
|
return new Promise((resolve, reject) => {
|
|
4100
4114
|
if (this.loadingAborted) {
|
|
4101
|
-
reject(
|
|
4115
|
+
reject(
|
|
4116
|
+
this.criticalError || new Error("DynamicLoader: Structure loading has been aborted due to critical error")
|
|
4117
|
+
);
|
|
4102
4118
|
return;
|
|
4103
4119
|
}
|
|
4104
4120
|
this.pendingRequests.push({
|
|
@@ -4137,7 +4153,7 @@ class GltfStructure {
|
|
|
4137
4153
|
}
|
|
4138
4154
|
}
|
|
4139
4155
|
console.error(
|
|
4140
|
-
|
|
4156
|
+
`DynamicLoader: Critical error for structure "${this.id}". All further loading aborted.`,
|
|
4141
4157
|
`\n Error: ${error.message || error}`,
|
|
4142
4158
|
`\n Rejected ${requests.length} pending chunk requests.`
|
|
4143
4159
|
);
|
|
@@ -4207,7 +4223,7 @@ class GltfStructure {
|
|
|
4207
4223
|
const promises = finalRanges.map(async (range, index) => {
|
|
4208
4224
|
if (this.loadingAborted) {
|
|
4209
4225
|
for (const req of range.requests) {
|
|
4210
|
-
req._reject(this.criticalError || new Error("Structure loading aborted"));
|
|
4226
|
+
req._reject(this.criticalError || new Error("DynamicLoader: Structure loading aborted"));
|
|
4211
4227
|
}
|
|
4212
4228
|
return;
|
|
4213
4229
|
}
|
|
@@ -4230,7 +4246,10 @@ class GltfStructure {
|
|
|
4230
4246
|
if (this.isCriticalHttpError(error)) {
|
|
4231
4247
|
this.abortLoading(error);
|
|
4232
4248
|
} else {
|
|
4233
|
-
console.warn(
|
|
4249
|
+
console.warn(
|
|
4250
|
+
`DynamicLoader: Failed to load chunk ${index + 1}/${finalRanges.length} (${range.start}-${range.end}):`,
|
|
4251
|
+
error
|
|
4252
|
+
);
|
|
4234
4253
|
}
|
|
4235
4254
|
} finally {
|
|
4236
4255
|
this.loader.releaseChunkSlot();
|
|
@@ -4249,7 +4268,7 @@ class GltfStructure {
|
|
|
4249
4268
|
createTypedArray(buffer, offset, length, componentType) {
|
|
4250
4269
|
try {
|
|
4251
4270
|
if (!buffer || !(buffer instanceof ArrayBuffer)) {
|
|
4252
|
-
throw new Error("Invalid buffer");
|
|
4271
|
+
throw new Error("DynamicLoader: Invalid buffer");
|
|
4253
4272
|
}
|
|
4254
4273
|
let elementSize;
|
|
4255
4274
|
switch (componentType) {
|
|
@@ -4266,20 +4285,22 @@ class GltfStructure {
|
|
|
4266
4285
|
elementSize = 4;
|
|
4267
4286
|
break;
|
|
4268
4287
|
default:
|
|
4269
|
-
throw new Error(`Unsupported component type: ${componentType}`);
|
|
4288
|
+
throw new Error(`DynamicLoader: Unsupported component type: ${componentType}`);
|
|
4270
4289
|
}
|
|
4271
4290
|
const numElements = length / elementSize;
|
|
4272
4291
|
if (!Number.isInteger(numElements)) {
|
|
4273
|
-
throw new Error(`Invalid length ${length} for component type ${componentType}`);
|
|
4292
|
+
throw new Error(`DynamicLoader: Invalid length ${length} for component type ${componentType}`);
|
|
4274
4293
|
}
|
|
4275
4294
|
if (length > buffer.byteLength) {
|
|
4276
|
-
throw new Error(
|
|
4295
|
+
throw new Error(
|
|
4296
|
+
`DynamicLoader: Buffer too small: need ${length} bytes, but buffer is ${buffer.byteLength} bytes`
|
|
4297
|
+
);
|
|
4277
4298
|
}
|
|
4278
4299
|
const ArrayType = GL_COMPONENT_TYPES[componentType];
|
|
4279
4300
|
return new ArrayType(buffer, offset, numElements);
|
|
4280
4301
|
} catch (error) {
|
|
4281
4302
|
if (error.name !== "AbortError") {
|
|
4282
|
-
console.
|
|
4303
|
+
console.warn("DynamicLoader: Error creating typed array:", {
|
|
4283
4304
|
bufferSize: buffer?.byteLength,
|
|
4284
4305
|
offset,
|
|
4285
4306
|
length,
|
|
@@ -4292,7 +4313,7 @@ class GltfStructure {
|
|
|
4292
4313
|
}
|
|
4293
4314
|
async createBufferAttribute(accessorIndex) {
|
|
4294
4315
|
if (!this.json) {
|
|
4295
|
-
throw new Error("No GLTF structure loaded");
|
|
4316
|
+
throw new Error("DynamicLoader: No GLTF structure loaded");
|
|
4296
4317
|
}
|
|
4297
4318
|
const gltf = this.json;
|
|
4298
4319
|
const accessor = gltf.accessors[accessorIndex];
|
|
@@ -4309,7 +4330,7 @@ class GltfStructure {
|
|
|
4309
4330
|
return attribute;
|
|
4310
4331
|
} catch (error) {
|
|
4311
4332
|
if (error.name !== "AbortError") {
|
|
4312
|
-
console.
|
|
4333
|
+
console.warn("DynamicLoader: Error creating buffer attribute:", {
|
|
4313
4334
|
error,
|
|
4314
4335
|
accessor,
|
|
4315
4336
|
bufferView,
|
|
@@ -4330,7 +4351,7 @@ class GltfStructure {
|
|
|
4330
4351
|
case 5126:
|
|
4331
4352
|
return 4;
|
|
4332
4353
|
default:
|
|
4333
|
-
throw new Error(`Unknown component type: ${componentType}`);
|
|
4354
|
+
throw new Error(`DynamicLoader: Unknown component type: ${componentType}`);
|
|
4334
4355
|
}
|
|
4335
4356
|
}
|
|
4336
4357
|
getNumComponents(type) {
|
|
@@ -4350,31 +4371,50 @@ class GltfStructure {
|
|
|
4350
4371
|
case "MAT4":
|
|
4351
4372
|
return 16;
|
|
4352
4373
|
default:
|
|
4353
|
-
throw new Error(`Unknown type: ${type}`);
|
|
4374
|
+
throw new Error(`DynamicLoader: Unknown type: ${type}`);
|
|
4354
4375
|
}
|
|
4355
4376
|
}
|
|
4356
4377
|
async loadTextures() {
|
|
4357
4378
|
if (!this.json.textures) return;
|
|
4358
4379
|
const loadTexture = async (imageIndex) => {
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
const
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4380
|
+
let textureName = `index_${imageIndex}`;
|
|
4381
|
+
try {
|
|
4382
|
+
const image = this.json.images[imageIndex];
|
|
4383
|
+
textureName = image.uri || image.name || textureName;
|
|
4384
|
+
if (image.uri) {
|
|
4385
|
+
const fullUrl = await this.loadController.resolveURL(image.uri);
|
|
4386
|
+
return await this.textureLoader.loadAsync(fullUrl);
|
|
4387
|
+
} else if (image.bufferView !== undefined) {
|
|
4388
|
+
const bufferView = this.json.bufferViews[image.bufferView];
|
|
4389
|
+
const array = await this.getBufferView(bufferView.byteOffset || 0, bufferView.byteLength, 5121);
|
|
4390
|
+
const blob = new Blob([array], { type: image.mimeType });
|
|
4391
|
+
const url = URL.createObjectURL(blob);
|
|
4392
|
+
const texture = await this.textureLoader.loadAsync(url);
|
|
4393
|
+
URL.revokeObjectURL(url);
|
|
4394
|
+
return texture;
|
|
4395
|
+
}
|
|
4396
|
+
} catch {
|
|
4397
|
+
console.warn(`DynamicLoader: Error loading texture ${textureName}`);
|
|
4372
4398
|
}
|
|
4373
4399
|
};
|
|
4374
4400
|
const texturePromises = [];
|
|
4375
4401
|
for (let i = 0; i < this.json.textures.length; i++) {
|
|
4376
4402
|
texturePromises.push(
|
|
4377
|
-
loadTexture(this.json.textures[i].source).then((texture) =>
|
|
4403
|
+
loadTexture(this.json.textures[i].source).then((texture) => {
|
|
4404
|
+
if (texture) {
|
|
4405
|
+
const samplerDef =
|
|
4406
|
+
this.json.textures[i].sampler !== undefined && this.json.samplers
|
|
4407
|
+
? this.json.samplers[this.json.textures[i].sampler]
|
|
4408
|
+
: {};
|
|
4409
|
+
texture.magFilter = GL_TO_THREE_FILTER[samplerDef.magFilter] || LinearFilter;
|
|
4410
|
+
texture.minFilter = GL_TO_THREE_FILTER[samplerDef.minFilter] || LinearMipmapLinearFilter;
|
|
4411
|
+
texture.wrapS = GL_TO_THREE_WRAP[samplerDef.wrapS] || RepeatWrapping;
|
|
4412
|
+
texture.wrapT = GL_TO_THREE_WRAP[samplerDef.wrapT] || RepeatWrapping;
|
|
4413
|
+
texture.flipY = false;
|
|
4414
|
+
texture.needsUpdate = true;
|
|
4415
|
+
}
|
|
4416
|
+
this.textureCache.set(i, texture);
|
|
4417
|
+
})
|
|
4378
4418
|
);
|
|
4379
4419
|
}
|
|
4380
4420
|
await Promise.all(texturePromises);
|
|
@@ -4405,8 +4445,14 @@ class GltfStructure {
|
|
|
4405
4445
|
params.opacity = pbr.baseColorFactor[3];
|
|
4406
4446
|
if (params.opacity < 1.0) params.transparent = true;
|
|
4407
4447
|
}
|
|
4408
|
-
if (pbr.baseColorTexture) {
|
|
4409
|
-
|
|
4448
|
+
if (pbr.baseColorTexture !== undefined) {
|
|
4449
|
+
const texture = this.textureCache.get(pbr.baseColorTexture.index);
|
|
4450
|
+
if (texture) {
|
|
4451
|
+
params.map = texture;
|
|
4452
|
+
if (!pbr.baseColorFactor) {
|
|
4453
|
+
params.color = new Color(0xffffff);
|
|
4454
|
+
}
|
|
4455
|
+
}
|
|
4410
4456
|
}
|
|
4411
4457
|
}
|
|
4412
4458
|
if (materialDef.emissiveFactor) {
|
|
@@ -4436,10 +4482,58 @@ class GltfStructure {
|
|
|
4436
4482
|
params.polygonOffset = true;
|
|
4437
4483
|
params.polygonOffsetFactor = 1;
|
|
4438
4484
|
params.polygonOffsetUnits = 1;
|
|
4439
|
-
if (materialDef.
|
|
4440
|
-
params.
|
|
4485
|
+
if (params.map && !materialDef.pbrMetallicRoughness?.baseColorFactor) {
|
|
4486
|
+
params.color = new Color(0xffffff);
|
|
4487
|
+
}
|
|
4488
|
+
if (materialDef.normalTexture !== undefined) {
|
|
4489
|
+
const normalMap = this.textureCache.get(materialDef.normalTexture.index);
|
|
4490
|
+
if (normalMap) {
|
|
4491
|
+
params.normalMap = normalMap;
|
|
4492
|
+
}
|
|
4493
|
+
}
|
|
4494
|
+
if (materialDef.emissiveTexture !== undefined) {
|
|
4495
|
+
const emissiveMap = this.textureCache.get(materialDef.emissiveTexture.index);
|
|
4496
|
+
if (emissiveMap) {
|
|
4497
|
+
params.emissiveMap = emissiveMap;
|
|
4498
|
+
}
|
|
4499
|
+
}
|
|
4500
|
+
const usePBR = materialDef.pbrMetallicRoughness?.metallicRoughnessTexture !== undefined;
|
|
4501
|
+
if (usePBR) {
|
|
4502
|
+
params.metalness =
|
|
4503
|
+
materialDef.pbrMetallicRoughness?.metallicFactor !== undefined
|
|
4504
|
+
? materialDef.pbrMetallicRoughness.metallicFactor
|
|
4505
|
+
: 1.0;
|
|
4506
|
+
params.roughness =
|
|
4507
|
+
materialDef.pbrMetallicRoughness?.roughnessFactor !== undefined
|
|
4508
|
+
? materialDef.pbrMetallicRoughness.roughnessFactor
|
|
4509
|
+
: 1.0;
|
|
4510
|
+
if (materialDef.pbrMetallicRoughness?.metallicRoughnessTexture !== undefined) {
|
|
4511
|
+
const map = this.textureCache.get(materialDef.pbrMetallicRoughness.metallicRoughnessTexture.index);
|
|
4512
|
+
if (map) {
|
|
4513
|
+
params.metalnessMap = map;
|
|
4514
|
+
params.roughnessMap = map;
|
|
4515
|
+
}
|
|
4516
|
+
}
|
|
4517
|
+
material = new MeshStandardMaterial(params);
|
|
4518
|
+
} else {
|
|
4519
|
+
material = new MeshPhongMaterial(params);
|
|
4520
|
+
}
|
|
4521
|
+
if (material.map) material.map.colorSpace = SRGBColorSpace;
|
|
4522
|
+
if (material.emissiveMap) material.emissiveMap.colorSpace = SRGBColorSpace;
|
|
4523
|
+
if (material.normalMap) {
|
|
4524
|
+
if (materialDef.normalTexture?.scale !== undefined) {
|
|
4525
|
+
material.normalScale.set(materialDef.normalTexture.scale, materialDef.normalTexture.scale);
|
|
4526
|
+
}
|
|
4527
|
+
}
|
|
4528
|
+
if (materialDef.occlusionTexture !== undefined) {
|
|
4529
|
+
const aoMap = this.textureCache.get(materialDef.occlusionTexture.index);
|
|
4530
|
+
if (aoMap) {
|
|
4531
|
+
material.aoMap = aoMap;
|
|
4532
|
+
if (materialDef.occlusionTexture.strength !== undefined) {
|
|
4533
|
+
material.aoMapIntensity = materialDef.occlusionTexture.strength;
|
|
4534
|
+
}
|
|
4535
|
+
}
|
|
4441
4536
|
}
|
|
4442
|
-
material = new MeshPhongMaterial(params);
|
|
4443
4537
|
}
|
|
4444
4538
|
return material;
|
|
4445
4539
|
}
|
|
@@ -4694,7 +4788,7 @@ class DynamicGltfLoader {
|
|
|
4694
4788
|
memoryLimit = Math.max(memoryLimit, 2 * 1024 * 1024 * 1024);
|
|
4695
4789
|
console.log(`Available memory set to ${Math.round(memoryLimit / (1024 * 1024 * 1024))}GB`);
|
|
4696
4790
|
} catch (error) {
|
|
4697
|
-
console.warn("Error detecting available memory:", error);
|
|
4791
|
+
console.warn("DynamicLoader: Error detecting available memory:", error);
|
|
4698
4792
|
}
|
|
4699
4793
|
return memoryLimit;
|
|
4700
4794
|
}
|
|
@@ -4859,7 +4953,7 @@ class DynamicGltfLoader {
|
|
|
4859
4953
|
if (entry?.lines?.uuid) uniqueMaterialIds.add(entry.lines.uuid);
|
|
4860
4954
|
}
|
|
4861
4955
|
} catch (exp) {
|
|
4862
|
-
console.
|
|
4956
|
+
console.warn("DynamicLoader: Error collecting material stats", exp);
|
|
4863
4957
|
}
|
|
4864
4958
|
}
|
|
4865
4959
|
}
|
|
@@ -4880,7 +4974,7 @@ class DynamicGltfLoader {
|
|
|
4880
4974
|
this._webglInfoCache = { renderer: null, vendor: null };
|
|
4881
4975
|
}
|
|
4882
4976
|
} catch (e) {
|
|
4883
|
-
console.
|
|
4977
|
+
console.warn("DynamicLoader: Error getting webgl info", e);
|
|
4884
4978
|
this._webglInfoCache = { renderer: null, vendor: null };
|
|
4885
4979
|
}
|
|
4886
4980
|
}
|
|
@@ -5137,7 +5231,7 @@ class DynamicGltfLoader {
|
|
|
5137
5231
|
if (node.structure && node.structure.loadingAborted) {
|
|
5138
5232
|
return;
|
|
5139
5233
|
}
|
|
5140
|
-
console.
|
|
5234
|
+
console.warn(`DynamicLoader: Error loading node ${nodeId}:`, error);
|
|
5141
5235
|
}
|
|
5142
5236
|
}
|
|
5143
5237
|
unloadNode(nodeId) {
|
|
@@ -5190,7 +5284,7 @@ class DynamicGltfLoader {
|
|
|
5190
5284
|
await structure.loadTextures();
|
|
5191
5285
|
await structure.loadMaterials();
|
|
5192
5286
|
} catch (error) {
|
|
5193
|
-
console.error("Error loading materials:", error);
|
|
5287
|
+
console.error("DynamicLoader: Error loading materials:", error);
|
|
5194
5288
|
throw error;
|
|
5195
5289
|
}
|
|
5196
5290
|
}
|
|
@@ -5198,14 +5292,14 @@ class DynamicGltfLoader {
|
|
|
5198
5292
|
}
|
|
5199
5293
|
async processSceneHierarchy() {
|
|
5200
5294
|
if (this.structures.length === 0) {
|
|
5201
|
-
throw new Error("No GLTF structures loaded");
|
|
5295
|
+
throw new Error("DynamicLoader: No GLTF structures loaded");
|
|
5202
5296
|
}
|
|
5203
5297
|
this.nodesToLoad = [];
|
|
5204
5298
|
let estimatedSize = 0;
|
|
5205
5299
|
for (const structure of this.structures) {
|
|
5206
5300
|
const gltf = structure.getJson();
|
|
5207
5301
|
if (!gltf.scenes || !gltf.scenes.length) {
|
|
5208
|
-
console.warn("No scenes found in GLTF structure");
|
|
5302
|
+
console.warn("DynamicLoader: No scenes found in GLTF structure");
|
|
5209
5303
|
continue;
|
|
5210
5304
|
}
|
|
5211
5305
|
estimatedSize += gltf.buffers[0].byteLength;
|
|
@@ -5447,7 +5541,6 @@ class DynamicGltfLoader {
|
|
|
5447
5541
|
color: 0x808080,
|
|
5448
5542
|
specular: 0x222222,
|
|
5449
5543
|
shininess: 10,
|
|
5450
|
-
side: DoubleSide,
|
|
5451
5544
|
});
|
|
5452
5545
|
}
|
|
5453
5546
|
}
|
|
@@ -5918,7 +6011,6 @@ class DynamicGltfLoader {
|
|
|
5918
6011
|
}
|
|
5919
6012
|
});
|
|
5920
6013
|
if (totalObjectsToMerge > 0) {
|
|
5921
|
-
console.log(`Pre-allocating transform texture for ${totalObjectsToMerge} objects`);
|
|
5922
6014
|
this.maxObjectId = totalObjectsToMerge;
|
|
5923
6015
|
this.initTransformTexture();
|
|
5924
6016
|
this.initializeObjectVisibility();
|
|
@@ -5981,7 +6073,7 @@ class DynamicGltfLoader {
|
|
|
5981
6073
|
let processedGroups = 0;
|
|
5982
6074
|
for (const group of materialGroups) {
|
|
5983
6075
|
if (!group.material) {
|
|
5984
|
-
console.warn("Skipping mesh group with null material");
|
|
6076
|
+
console.warn("DynamicLoader: Skipping mesh group with null material");
|
|
5985
6077
|
continue;
|
|
5986
6078
|
}
|
|
5987
6079
|
try {
|
|
@@ -6066,7 +6158,7 @@ class DynamicGltfLoader {
|
|
|
6066
6158
|
await this.yieldToUI();
|
|
6067
6159
|
}
|
|
6068
6160
|
} catch (error) {
|
|
6069
|
-
console.
|
|
6161
|
+
console.warn("DynamicLoader: Failed to merge meshes for material:", error);
|
|
6070
6162
|
group.objects.forEach((mesh) => {
|
|
6071
6163
|
mesh.visible = true;
|
|
6072
6164
|
});
|
|
@@ -6078,7 +6170,7 @@ class DynamicGltfLoader {
|
|
|
6078
6170
|
for (const group of materialGroups) {
|
|
6079
6171
|
if (group.objects.length === 0) continue;
|
|
6080
6172
|
if (!group.material) {
|
|
6081
|
-
console.warn("Skipping line group with null material");
|
|
6173
|
+
console.warn("DynamicLoader: Skipping line group with null material");
|
|
6082
6174
|
continue;
|
|
6083
6175
|
}
|
|
6084
6176
|
const handles = new Set();
|
|
@@ -6188,7 +6280,7 @@ class DynamicGltfLoader {
|
|
|
6188
6280
|
let processedGroups = 0;
|
|
6189
6281
|
for (const group of materialGroups) {
|
|
6190
6282
|
if (!group.material) {
|
|
6191
|
-
console.warn("Skipping line segment group with null material");
|
|
6283
|
+
console.warn("DynamicLoader: Skipping line segment group with null material");
|
|
6192
6284
|
continue;
|
|
6193
6285
|
}
|
|
6194
6286
|
try {
|
|
@@ -6276,7 +6368,7 @@ class DynamicGltfLoader {
|
|
|
6276
6368
|
await this.yieldToUI();
|
|
6277
6369
|
}
|
|
6278
6370
|
} catch (error) {
|
|
6279
|
-
console.warn("Failed to merge line segments for material:", error);
|
|
6371
|
+
console.warn("DynamicLoader: Failed to merge line segments for material:", error);
|
|
6280
6372
|
group.objects.forEach((line) => {
|
|
6281
6373
|
line.visible = true;
|
|
6282
6374
|
});
|
|
@@ -6287,7 +6379,7 @@ class DynamicGltfLoader {
|
|
|
6287
6379
|
let processedGroups = 0;
|
|
6288
6380
|
for (const group of materialGroups) {
|
|
6289
6381
|
if (!group.material) {
|
|
6290
|
-
console.warn("Skipping points group with null material");
|
|
6382
|
+
console.warn("DynamicLoader: Skipping points group with null material");
|
|
6291
6383
|
continue;
|
|
6292
6384
|
}
|
|
6293
6385
|
try {
|
|
@@ -6359,7 +6451,7 @@ class DynamicGltfLoader {
|
|
|
6359
6451
|
await this.yieldToUI();
|
|
6360
6452
|
}
|
|
6361
6453
|
} catch (error) {
|
|
6362
|
-
console.warn("Failed to merge points for material:", error);
|
|
6454
|
+
console.warn("DynamicLoader: Failed to merge points for material:", error);
|
|
6363
6455
|
group.objects.forEach((points) => {
|
|
6364
6456
|
points.visible = true;
|
|
6365
6457
|
});
|
|
@@ -6439,7 +6531,7 @@ class DynamicGltfLoader {
|
|
|
6439
6531
|
obj.geometry.dispose();
|
|
6440
6532
|
});
|
|
6441
6533
|
} catch (error) {
|
|
6442
|
-
console.
|
|
6534
|
+
console.warn("DynamicLoader: Failed to merge geometries:", error);
|
|
6443
6535
|
lineSegmentsArray.forEach((obj) => {
|
|
6444
6536
|
obj.visible = true;
|
|
6445
6537
|
rootGroup.add(obj);
|
|
@@ -6543,11 +6635,11 @@ class DynamicGltfLoader {
|
|
|
6543
6635
|
}
|
|
6544
6636
|
applyObjectTransforms(objectTransformMap) {
|
|
6545
6637
|
if (this.mergedObjectMap.size === 0) {
|
|
6546
|
-
console.warn("No merged objects to transform");
|
|
6638
|
+
console.warn("DynamicLoader: No merged objects to transform");
|
|
6547
6639
|
return;
|
|
6548
6640
|
}
|
|
6549
6641
|
if (!this.transformData) {
|
|
6550
|
-
console.warn("Transform texture not initialized");
|
|
6642
|
+
console.warn("DynamicLoader: Transform texture not initialized");
|
|
6551
6643
|
return;
|
|
6552
6644
|
}
|
|
6553
6645
|
this.objectTransforms = objectTransformMap;
|
|
@@ -6730,7 +6822,7 @@ class DynamicGltfLoader {
|
|
|
6730
6822
|
}
|
|
6731
6823
|
syncHiddenObjects() {
|
|
6732
6824
|
if (this.mergedObjectMap.size === 0) {
|
|
6733
|
-
console.
|
|
6825
|
+
console.warn("DynamicLoader: No merged objects to sync");
|
|
6734
6826
|
return;
|
|
6735
6827
|
}
|
|
6736
6828
|
if (this.objectVisibility.length > 0) {
|