itowns 2.42.1-next.8 → 2.43.0
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/changelog.md +90 -0
- package/dist/debug.js +1 -1
- package/dist/debug.js.map +1 -1
- package/dist/itowns.js +1 -1
- package/dist/itowns.js.map +1 -1
- package/dist/itowns_widgets.js +1 -1
- package/dist/itowns_widgets.js.map +1 -1
- package/examples/{.eslintrc.js → .eslintrc.cjs} +1 -1
- package/examples/effects_stereo.html +2 -2
- package/examples/misc_collada.html +2 -2
- package/examples/source_stream_wfs_25d.html +11 -11
- package/examples/source_stream_wfs_3d.html +1 -1
- package/examples/view_25d_map.html +2 -2
- package/examples/view_3d_map.html +2 -2
- package/examples/view_3d_map_webxr.html +1 -1
- package/examples/view_3d_mns_map.html +2 -2
- package/examples/view_immersive.html +1 -1
- package/examples/view_multi_25d.html +2 -2
- package/examples/widgets_searchbar.html +2 -2
- package/lib/Controls/FirstPersonControls.js +5 -12
- package/lib/Controls/FlyControls.js +4 -13
- package/lib/Controls/GlobeControls.js +33 -43
- package/lib/Controls/PlanarControls.js +9 -20
- package/lib/Controls/StateControl.js +2 -11
- package/lib/Controls/StreetControls.js +14 -24
- package/lib/Converter/Feature2Mesh.js +28 -38
- package/lib/Converter/Feature2Texture.js +15 -25
- package/lib/Converter/convertToTile.js +16 -26
- package/lib/Converter/textureConverter.js +9 -19
- package/lib/Core/3DTiles/C3DTBatchTable.js +5 -13
- package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +1 -8
- package/lib/Core/3DTiles/C3DTBoundingVolume.js +17 -27
- package/lib/Core/3DTiles/C3DTExtensions.js +1 -8
- package/lib/Core/3DTiles/C3DTFeature.js +3 -10
- package/lib/Core/3DTiles/C3DTilesEnums.js +3 -11
- package/lib/Core/3DTiles/C3DTileset.js +7 -16
- package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +5 -11
- package/lib/Core/AnimationPlayer.js +2 -11
- package/lib/Core/Deprecated/Undeprecator.js +9 -20
- package/lib/Core/EntwinePointTileNode.js +6 -16
- package/lib/Core/Feature.js +16 -30
- package/lib/Core/Geographic/CoordStars.js +3 -12
- package/lib/Core/Geographic/Coordinates.js +12 -22
- package/lib/Core/Geographic/Crs.js +7 -15
- package/lib/Core/Geographic/Extent.js +36 -47
- package/lib/Core/Geographic/GeoidGrid.js +6 -16
- package/lib/Core/Label.js +7 -17
- package/lib/Core/MainLoop.js +7 -16
- package/lib/Core/Math/Ellipsoid.js +6 -17
- package/lib/Core/Picking.js +10 -20
- package/lib/Core/PointCloudNode.js +2 -11
- package/lib/Core/PotreeNode.js +4 -13
- package/lib/Core/Prefab/Globe/Atmosphere.js +17 -26
- package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +6 -16
- package/lib/Core/Prefab/Globe/GlobeLayer.js +19 -28
- package/lib/Core/Prefab/Globe/SkyShader.js +2 -11
- package/lib/Core/Prefab/GlobeView.js +27 -45
- package/lib/Core/Prefab/Planar/PlanarLayer.js +11 -20
- package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +6 -16
- package/lib/Core/Prefab/PlanarView.js +10 -25
- package/lib/Core/Prefab/TileBuilder.js +13 -22
- package/lib/Core/Prefab/computeBufferTileGeometry.js +12 -16
- package/lib/Core/Scheduler/Cache.js +2 -10
- package/lib/Core/Scheduler/CancelledCommandException.js +1 -8
- package/lib/Core/Scheduler/Scheduler.js +15 -23
- package/lib/Core/Style.js +24 -38
- package/lib/Core/System/Capabilities.js +2 -13
- package/lib/Core/TileGeometry.js +13 -15
- package/lib/Core/TileMesh.js +6 -15
- package/lib/Core/View.js +43 -58
- package/lib/Layer/C3DTilesLayer.js +29 -41
- package/lib/Layer/ColorLayer.js +10 -16
- package/lib/Layer/ElevationLayer.js +7 -14
- package/lib/Layer/EntwinePointTileLayer.js +9 -18
- package/lib/Layer/FeatureGeometryLayer.js +9 -16
- package/lib/Layer/GeoidLayer.js +6 -15
- package/lib/Layer/GeometryLayer.js +11 -17
- package/lib/Layer/InfoLayer.js +5 -14
- package/lib/Layer/LabelLayer.js +22 -32
- package/lib/Layer/Layer.js +16 -26
- package/lib/Layer/LayerUpdateState.js +1 -8
- package/lib/Layer/LayerUpdateStrategy.js +7 -18
- package/lib/Layer/OrientedImageLayer.js +15 -25
- package/lib/Layer/PointCloudLayer.js +9 -19
- package/lib/Layer/PotreeLayer.js +8 -18
- package/lib/Layer/RasterLayer.js +9 -17
- package/lib/Layer/ReferencingLayerProperties.js +1 -8
- package/lib/Layer/TiledGeometryLayer.js +37 -33
- package/lib/Main.js +87 -708
- package/lib/MainBundle.js +4 -34
- package/lib/Parser/B3dmParser.js +80 -131
- package/lib/Parser/CameraCalibrationParser.js +5 -14
- package/lib/Parser/GDFParser.js +11 -22
- package/lib/Parser/GLTFParser.js +88 -0
- package/lib/Parser/GTXParser.js +9 -21
- package/lib/Parser/GeoJsonParser.js +14 -22
- package/lib/Parser/GpxParser.js +7 -14
- package/lib/Parser/ISGParser.js +19 -28
- package/lib/Parser/KMLParser.js +7 -14
- package/lib/Parser/LASLoader.js +20 -21
- package/lib/Parser/LASParser.js +6 -15
- package/lib/Parser/MapBoxUrlParser.js +2 -9
- package/lib/Parser/PntsParser.js +4 -14
- package/lib/Parser/PotreeBinParser.js +8 -16
- package/lib/Parser/PotreeCinParser.js +3 -12
- package/lib/Parser/ShapefileParser.js +11 -18
- package/lib/Parser/VectorTileParser.js +23 -31
- package/lib/Parser/XbilParser.js +5 -13
- package/lib/Parser/deprecated/LegacyGLTFLoader.js +2 -12
- package/lib/Process/3dTilesProcessing.js +14 -27
- package/lib/Process/FeatureProcessing.js +14 -22
- package/lib/Process/LayeredMaterialNodeProcessing.js +14 -26
- package/lib/Process/ObjectRemovalHelper.js +2 -9
- package/lib/Process/handlerNodeError.js +1 -7
- package/lib/Provider/3dTilesProvider.js +32 -29
- package/lib/Provider/DataSourceProvider.js +2 -9
- package/lib/Provider/Fetcher.js +40 -22
- package/lib/Provider/PointCloudProvider.js +7 -19
- package/lib/Provider/TileProvider.js +4 -12
- package/lib/Provider/URLBuilder.js +4 -12
- package/lib/Renderer/Camera.js +7 -17
- package/lib/Renderer/Color.js +3 -11
- package/lib/Renderer/ColorLayersOrdering.js +14 -22
- package/lib/Renderer/CommonMaterial.js +3 -12
- package/lib/Renderer/Label2DRenderer.js +5 -16
- package/lib/Renderer/LayeredMaterial.js +33 -53
- package/lib/Renderer/OBB.js +12 -21
- package/lib/Renderer/OrientedImageCamera.js +2 -11
- package/lib/Renderer/OrientedImageMaterial.js +17 -35
- package/lib/Renderer/PointsMaterial.js +37 -60
- package/lib/Renderer/RasterTile.js +16 -29
- package/lib/Renderer/RenderMode.js +2 -9
- package/lib/Renderer/Shader/ShaderChunk.js +5 -23
- package/lib/Renderer/Shader/ShaderUtils.js +2 -9
- package/lib/Renderer/SphereHelper.js +2 -11
- package/lib/Renderer/WebXR.js +2 -11
- package/lib/Renderer/c3DEngine.js +20 -53
- package/lib/Source/C3DTilesGoogleSource.js +76 -0
- package/lib/Source/C3DTilesIonSource.js +6 -13
- package/lib/Source/C3DTilesSource.js +5 -12
- package/lib/Source/EntwinePointTileSource.js +12 -19
- package/lib/Source/FileSource.js +7 -14
- package/lib/Source/OrientedImageSource.js +6 -14
- package/lib/Source/PotreeSource.js +9 -16
- package/lib/Source/Source.js +26 -39
- package/lib/Source/TMSSource.js +11 -22
- package/lib/Source/VectorTilesSource.js +75 -34
- package/lib/Source/WFSSource.js +7 -14
- package/lib/Source/WMSSource.js +5 -12
- package/lib/Source/WMTSSource.js +3 -10
- package/lib/ThreeExtended/capabilities/WebGL.js +1 -8
- package/lib/ThreeExtended/libs/ktx-parse.module.js +2 -256
- package/lib/ThreeExtended/libs/zstddec.module.js +2 -8
- package/lib/ThreeExtended/loaders/DDSLoader.js +10 -16
- package/lib/ThreeExtended/loaders/DRACOLoader.js +14 -19
- package/lib/ThreeExtended/loaders/GLTFLoader.js +124 -129
- package/lib/ThreeExtended/loaders/KTX2Loader.js +73 -78
- package/lib/ThreeExtended/utils/BufferGeometryUtils.js +40 -59
- package/lib/ThreeExtended/utils/WorkerPool.js +2 -9
- package/lib/Utils/CameraUtils.js +32 -44
- package/lib/Utils/DEMUtils.js +8 -19
- package/lib/Utils/FeaturesUtils.js +8 -16
- package/lib/Utils/Gradients.js +3 -12
- package/lib/Utils/OrientationUtils.js +8 -18
- package/lib/Utils/ThreeUtils.js +2 -9
- package/lib/Utils/gui/C3DTilesStyle.js +7 -15
- package/lib/Utils/gui/Main.js +7 -48
- package/lib/Utils/gui/Minimap.js +12 -20
- package/lib/Utils/gui/Navigation.js +6 -14
- package/lib/Utils/gui/Scale.js +11 -19
- package/lib/Utils/gui/Searchbar.js +5 -13
- package/lib/Utils/gui/Widget.js +1 -8
- package/lib/Utils/placeObjectOnGround.js +13 -23
- package/package.json +13 -8
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.GLTFLoader = void 0;
|
|
7
|
-
var _three = require("three");
|
|
8
|
-
var _BufferGeometryUtils = require("../utils/BufferGeometryUtils.js");
|
|
9
|
-
class GLTFLoader extends _three.Loader {
|
|
1
|
+
import { AnimationClip, Bone, Box3, BufferAttribute, BufferGeometry, ClampToEdgeWrapping, Color, ColorManagement, DirectionalLight, DoubleSide, FileLoader, FrontSide, Group, ImageBitmapLoader, InstancedMesh, InterleavedBuffer, InterleavedBufferAttribute, Interpolant, InterpolateDiscrete, InterpolateLinear, Line, LineBasicMaterial, LineLoop, LineSegments, LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, LinearSRGBColorSpace, Loader, LoaderUtils, Material, MathUtils, Matrix4, Mesh, MeshBasicMaterial, MeshPhysicalMaterial, MeshStandardMaterial, MirroredRepeatWrapping, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, NumberKeyframeTrack, Object3D, OrthographicCamera, PerspectiveCamera, PointLight, Points, PointsMaterial, PropertyBinding, Quaternion, QuaternionKeyframeTrack, RepeatWrapping, Skeleton, SkinnedMesh, Sphere, SpotLight, Texture, TextureLoader, TriangleFanDrawMode, TriangleStripDrawMode, Vector2, Vector3, VectorKeyframeTrack, SRGBColorSpace, InstancedBufferAttribute } from 'three';
|
|
2
|
+
import { toTrianglesDrawMode } from "../utils/BufferGeometryUtils.js";
|
|
3
|
+
class GLTFLoader extends Loader {
|
|
10
4
|
constructor(manager) {
|
|
11
5
|
super(manager);
|
|
12
6
|
this.dracoLoader = null;
|
|
@@ -73,10 +67,10 @@ class GLTFLoader extends _three.Loader {
|
|
|
73
67
|
// resourcePath = 'https://my-cnd-server.com/assets/models/'
|
|
74
68
|
// referenced resource 'model.bin' will be loaded from 'https://my-cnd-server.com/assets/models/model.bin'
|
|
75
69
|
// referenced resource '../textures/texture.png' will be loaded from 'https://my-cnd-server.com/assets/textures/texture.png'
|
|
76
|
-
const relativeUrl =
|
|
77
|
-
resourcePath =
|
|
70
|
+
const relativeUrl = LoaderUtils.extractUrlBase(url);
|
|
71
|
+
resourcePath = LoaderUtils.resolveURL(relativeUrl, this.path);
|
|
78
72
|
} else {
|
|
79
|
-
resourcePath =
|
|
73
|
+
resourcePath = LoaderUtils.extractUrlBase(url);
|
|
80
74
|
}
|
|
81
75
|
|
|
82
76
|
// Tells the LoadingManager to track an extra item, which resolves after
|
|
@@ -92,7 +86,7 @@ class GLTFLoader extends _three.Loader {
|
|
|
92
86
|
scope.manager.itemError(url);
|
|
93
87
|
scope.manager.itemEnd(url);
|
|
94
88
|
};
|
|
95
|
-
const loader = new
|
|
89
|
+
const loader = new FileLoader(this.manager);
|
|
96
90
|
loader.setPath(this.path);
|
|
97
91
|
loader.setResponseType('arraybuffer');
|
|
98
92
|
loader.setRequestHeader(this.requestHeader);
|
|
@@ -219,7 +213,7 @@ class GLTFLoader extends _three.Loader {
|
|
|
219
213
|
}
|
|
220
214
|
|
|
221
215
|
/* GLTFREGISTRY */
|
|
222
|
-
|
|
216
|
+
|
|
223
217
|
function GLTFRegistry() {
|
|
224
218
|
let objects = {};
|
|
225
219
|
return {
|
|
@@ -302,21 +296,21 @@ class GLTFLightsExtension {
|
|
|
302
296
|
const lightDefs = extensions.lights || [];
|
|
303
297
|
const lightDef = lightDefs[lightIndex];
|
|
304
298
|
let lightNode;
|
|
305
|
-
const color = new
|
|
306
|
-
if (lightDef.color !== undefined) color.setRGB(lightDef.color[0], lightDef.color[1], lightDef.color[2],
|
|
299
|
+
const color = new Color(0xffffff);
|
|
300
|
+
if (lightDef.color !== undefined) color.setRGB(lightDef.color[0], lightDef.color[1], lightDef.color[2], LinearSRGBColorSpace);
|
|
307
301
|
const range = lightDef.range !== undefined ? lightDef.range : 0;
|
|
308
302
|
switch (lightDef.type) {
|
|
309
303
|
case 'directional':
|
|
310
|
-
lightNode = new
|
|
304
|
+
lightNode = new DirectionalLight(color);
|
|
311
305
|
lightNode.target.position.set(0, 0, -1);
|
|
312
306
|
lightNode.add(lightNode.target);
|
|
313
307
|
break;
|
|
314
308
|
case 'point':
|
|
315
|
-
lightNode = new
|
|
309
|
+
lightNode = new PointLight(color);
|
|
316
310
|
lightNode.distance = range;
|
|
317
311
|
break;
|
|
318
312
|
case 'spot':
|
|
319
|
-
lightNode = new
|
|
313
|
+
lightNode = new SpotLight(color);
|
|
320
314
|
lightNode.distance = range;
|
|
321
315
|
// Handle spotlight properties.
|
|
322
316
|
lightDef.spot = lightDef.spot || {};
|
|
@@ -370,21 +364,21 @@ class GLTFMaterialsUnlitExtension {
|
|
|
370
364
|
this.name = EXTENSIONS.KHR_MATERIALS_UNLIT;
|
|
371
365
|
}
|
|
372
366
|
getMaterialType() {
|
|
373
|
-
return
|
|
367
|
+
return MeshBasicMaterial;
|
|
374
368
|
}
|
|
375
369
|
extendParams(materialParams, materialDef, parser) {
|
|
376
370
|
const pending = [];
|
|
377
|
-
materialParams.color = new
|
|
371
|
+
materialParams.color = new Color(1.0, 1.0, 1.0);
|
|
378
372
|
materialParams.opacity = 1.0;
|
|
379
373
|
const metallicRoughness = materialDef.pbrMetallicRoughness;
|
|
380
374
|
if (metallicRoughness) {
|
|
381
375
|
if (Array.isArray(metallicRoughness.baseColorFactor)) {
|
|
382
376
|
const array = metallicRoughness.baseColorFactor;
|
|
383
|
-
materialParams.color.setRGB(array[0], array[1], array[2],
|
|
377
|
+
materialParams.color.setRGB(array[0], array[1], array[2], LinearSRGBColorSpace);
|
|
384
378
|
materialParams.opacity = array[3];
|
|
385
379
|
}
|
|
386
380
|
if (metallicRoughness.baseColorTexture !== undefined) {
|
|
387
|
-
pending.push(parser.assignTexture(materialParams, 'map', metallicRoughness.baseColorTexture,
|
|
381
|
+
pending.push(parser.assignTexture(materialParams, 'map', metallicRoughness.baseColorTexture, SRGBColorSpace));
|
|
388
382
|
}
|
|
389
383
|
}
|
|
390
384
|
return Promise.all(pending);
|
|
@@ -429,7 +423,7 @@ class GLTFMaterialsClearcoatExtension {
|
|
|
429
423
|
const parser = this.parser;
|
|
430
424
|
const materialDef = parser.json.materials[materialIndex];
|
|
431
425
|
if (!materialDef.extensions || !materialDef.extensions[this.name]) return null;
|
|
432
|
-
return
|
|
426
|
+
return MeshPhysicalMaterial;
|
|
433
427
|
}
|
|
434
428
|
extendMaterialParams(materialIndex, materialParams) {
|
|
435
429
|
const parser = this.parser;
|
|
@@ -455,7 +449,7 @@ class GLTFMaterialsClearcoatExtension {
|
|
|
455
449
|
pending.push(parser.assignTexture(materialParams, 'clearcoatNormalMap', extension.clearcoatNormalTexture));
|
|
456
450
|
if (extension.clearcoatNormalTexture.scale !== undefined) {
|
|
457
451
|
const scale = extension.clearcoatNormalTexture.scale;
|
|
458
|
-
materialParams.clearcoatNormalScale = new
|
|
452
|
+
materialParams.clearcoatNormalScale = new Vector2(scale, scale);
|
|
459
453
|
}
|
|
460
454
|
}
|
|
461
455
|
return Promise.all(pending);
|
|
@@ -476,7 +470,7 @@ class GLTFMaterialsIridescenceExtension {
|
|
|
476
470
|
const parser = this.parser;
|
|
477
471
|
const materialDef = parser.json.materials[materialIndex];
|
|
478
472
|
if (!materialDef.extensions || !materialDef.extensions[this.name]) return null;
|
|
479
|
-
return
|
|
473
|
+
return MeshPhysicalMaterial;
|
|
480
474
|
}
|
|
481
475
|
extendMaterialParams(materialIndex, materialParams) {
|
|
482
476
|
const parser = this.parser;
|
|
@@ -525,7 +519,7 @@ class GLTFMaterialsSheenExtension {
|
|
|
525
519
|
const parser = this.parser;
|
|
526
520
|
const materialDef = parser.json.materials[materialIndex];
|
|
527
521
|
if (!materialDef.extensions || !materialDef.extensions[this.name]) return null;
|
|
528
|
-
return
|
|
522
|
+
return MeshPhysicalMaterial;
|
|
529
523
|
}
|
|
530
524
|
extendMaterialParams(materialIndex, materialParams) {
|
|
531
525
|
const parser = this.parser;
|
|
@@ -534,19 +528,19 @@ class GLTFMaterialsSheenExtension {
|
|
|
534
528
|
return Promise.resolve();
|
|
535
529
|
}
|
|
536
530
|
const pending = [];
|
|
537
|
-
materialParams.sheenColor = new
|
|
531
|
+
materialParams.sheenColor = new Color(0, 0, 0);
|
|
538
532
|
materialParams.sheenRoughness = 0;
|
|
539
533
|
materialParams.sheen = 1;
|
|
540
534
|
const extension = materialDef.extensions[this.name];
|
|
541
535
|
if (extension.sheenColorFactor !== undefined) {
|
|
542
536
|
const colorFactor = extension.sheenColorFactor;
|
|
543
|
-
materialParams.sheenColor.setRGB(colorFactor[0], colorFactor[1], colorFactor[2],
|
|
537
|
+
materialParams.sheenColor.setRGB(colorFactor[0], colorFactor[1], colorFactor[2], LinearSRGBColorSpace);
|
|
544
538
|
}
|
|
545
539
|
if (extension.sheenRoughnessFactor !== undefined) {
|
|
546
540
|
materialParams.sheenRoughness = extension.sheenRoughnessFactor;
|
|
547
541
|
}
|
|
548
542
|
if (extension.sheenColorTexture !== undefined) {
|
|
549
|
-
pending.push(parser.assignTexture(materialParams, 'sheenColorMap', extension.sheenColorTexture,
|
|
543
|
+
pending.push(parser.assignTexture(materialParams, 'sheenColorMap', extension.sheenColorTexture, SRGBColorSpace));
|
|
550
544
|
}
|
|
551
545
|
if (extension.sheenRoughnessTexture !== undefined) {
|
|
552
546
|
pending.push(parser.assignTexture(materialParams, 'sheenRoughnessMap', extension.sheenRoughnessTexture));
|
|
@@ -570,7 +564,7 @@ class GLTFMaterialsTransmissionExtension {
|
|
|
570
564
|
const parser = this.parser;
|
|
571
565
|
const materialDef = parser.json.materials[materialIndex];
|
|
572
566
|
if (!materialDef.extensions || !materialDef.extensions[this.name]) return null;
|
|
573
|
-
return
|
|
567
|
+
return MeshPhysicalMaterial;
|
|
574
568
|
}
|
|
575
569
|
extendMaterialParams(materialIndex, materialParams) {
|
|
576
570
|
const parser = this.parser;
|
|
@@ -604,7 +598,7 @@ class GLTFMaterialsVolumeExtension {
|
|
|
604
598
|
const parser = this.parser;
|
|
605
599
|
const materialDef = parser.json.materials[materialIndex];
|
|
606
600
|
if (!materialDef.extensions || !materialDef.extensions[this.name]) return null;
|
|
607
|
-
return
|
|
601
|
+
return MeshPhysicalMaterial;
|
|
608
602
|
}
|
|
609
603
|
extendMaterialParams(materialIndex, materialParams) {
|
|
610
604
|
const parser = this.parser;
|
|
@@ -620,7 +614,7 @@ class GLTFMaterialsVolumeExtension {
|
|
|
620
614
|
}
|
|
621
615
|
materialParams.attenuationDistance = extension.attenuationDistance || Infinity;
|
|
622
616
|
const colorArray = extension.attenuationColor || [1, 1, 1];
|
|
623
|
-
materialParams.attenuationColor = new
|
|
617
|
+
materialParams.attenuationColor = new Color().setRGB(colorArray[0], colorArray[1], colorArray[2], LinearSRGBColorSpace);
|
|
624
618
|
return Promise.all(pending);
|
|
625
619
|
}
|
|
626
620
|
}
|
|
@@ -639,7 +633,7 @@ class GLTFMaterialsIorExtension {
|
|
|
639
633
|
const parser = this.parser;
|
|
640
634
|
const materialDef = parser.json.materials[materialIndex];
|
|
641
635
|
if (!materialDef.extensions || !materialDef.extensions[this.name]) return null;
|
|
642
|
-
return
|
|
636
|
+
return MeshPhysicalMaterial;
|
|
643
637
|
}
|
|
644
638
|
extendMaterialParams(materialIndex, materialParams) {
|
|
645
639
|
const parser = this.parser;
|
|
@@ -667,7 +661,7 @@ class GLTFMaterialsSpecularExtension {
|
|
|
667
661
|
const parser = this.parser;
|
|
668
662
|
const materialDef = parser.json.materials[materialIndex];
|
|
669
663
|
if (!materialDef.extensions || !materialDef.extensions[this.name]) return null;
|
|
670
|
-
return
|
|
664
|
+
return MeshPhysicalMaterial;
|
|
671
665
|
}
|
|
672
666
|
extendMaterialParams(materialIndex, materialParams) {
|
|
673
667
|
const parser = this.parser;
|
|
@@ -682,9 +676,9 @@ class GLTFMaterialsSpecularExtension {
|
|
|
682
676
|
pending.push(parser.assignTexture(materialParams, 'specularIntensityMap', extension.specularTexture));
|
|
683
677
|
}
|
|
684
678
|
const colorArray = extension.specularColorFactor || [1, 1, 1];
|
|
685
|
-
materialParams.specularColor = new
|
|
679
|
+
materialParams.specularColor = new Color().setRGB(colorArray[0], colorArray[1], colorArray[2], LinearSRGBColorSpace);
|
|
686
680
|
if (extension.specularColorTexture !== undefined) {
|
|
687
|
-
pending.push(parser.assignTexture(materialParams, 'specularColorMap', extension.specularColorTexture,
|
|
681
|
+
pending.push(parser.assignTexture(materialParams, 'specularColorMap', extension.specularColorTexture, SRGBColorSpace));
|
|
688
682
|
}
|
|
689
683
|
return Promise.all(pending);
|
|
690
684
|
}
|
|
@@ -704,7 +698,7 @@ class GLTFMaterialsBumpExtension {
|
|
|
704
698
|
const parser = this.parser;
|
|
705
699
|
const materialDef = parser.json.materials[materialIndex];
|
|
706
700
|
if (!materialDef.extensions || !materialDef.extensions[this.name]) return null;
|
|
707
|
-
return
|
|
701
|
+
return MeshPhysicalMaterial;
|
|
708
702
|
}
|
|
709
703
|
extendMaterialParams(materialIndex, materialParams) {
|
|
710
704
|
const parser = this.parser;
|
|
@@ -736,7 +730,7 @@ class GLTFMaterialsAnisotropyExtension {
|
|
|
736
730
|
const parser = this.parser;
|
|
737
731
|
const materialDef = parser.json.materials[materialIndex];
|
|
738
732
|
if (!materialDef.extensions || !materialDef.extensions[this.name]) return null;
|
|
739
|
-
return
|
|
733
|
+
return MeshPhysicalMaterial;
|
|
740
734
|
}
|
|
741
735
|
extendMaterialParams(materialIndex, materialParams) {
|
|
742
736
|
const parser = this.parser;
|
|
@@ -995,11 +989,11 @@ class GLTFMeshGpuInstancing {
|
|
|
995
989
|
const instancedMeshes = [];
|
|
996
990
|
for (const mesh of meshes) {
|
|
997
991
|
// Temporal variables
|
|
998
|
-
const m = new
|
|
999
|
-
const p = new
|
|
1000
|
-
const q = new
|
|
1001
|
-
const s = new
|
|
1002
|
-
const instancedMesh = new
|
|
992
|
+
const m = new Matrix4();
|
|
993
|
+
const p = new Vector3();
|
|
994
|
+
const q = new Quaternion();
|
|
995
|
+
const s = new Vector3(1, 1, 1);
|
|
996
|
+
const instancedMesh = new InstancedMesh(mesh.geometry, mesh.material, count);
|
|
1003
997
|
for (let i = 0; i < count; i++) {
|
|
1004
998
|
if (attributes.TRANSLATION) {
|
|
1005
999
|
p.fromBufferAttribute(attributes.TRANSLATION, i);
|
|
@@ -1017,14 +1011,14 @@ class GLTFMeshGpuInstancing {
|
|
|
1017
1011
|
for (const attributeName in attributes) {
|
|
1018
1012
|
if (attributeName === '_COLOR_0') {
|
|
1019
1013
|
const attr = attributes[attributeName];
|
|
1020
|
-
instancedMesh.instanceColor = new
|
|
1014
|
+
instancedMesh.instanceColor = new InstancedBufferAttribute(attr.array, attr.itemSize, attr.normalized);
|
|
1021
1015
|
} else if (attributeName !== 'TRANSLATION' && attributeName !== 'ROTATION' && attributeName !== 'SCALE') {
|
|
1022
1016
|
mesh.geometry.setAttribute(attributeName, attributes[attributeName]);
|
|
1023
1017
|
}
|
|
1024
1018
|
}
|
|
1025
1019
|
|
|
1026
1020
|
// Just in case
|
|
1027
|
-
|
|
1021
|
+
Object3D.prototype.copy.call(instancedMesh, mesh);
|
|
1028
1022
|
this.parser.assignFinalMaterial(instancedMesh);
|
|
1029
1023
|
instancedMeshes.push(instancedMesh);
|
|
1030
1024
|
}
|
|
@@ -1188,7 +1182,7 @@ class GLTFMeshQuantizationExtension {
|
|
|
1188
1182
|
|
|
1189
1183
|
// Spline Interpolation
|
|
1190
1184
|
// Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#appendix-c-spline-interpolation
|
|
1191
|
-
class GLTFCubicSplineInterpolant extends
|
|
1185
|
+
class GLTFCubicSplineInterpolant extends Interpolant {
|
|
1192
1186
|
constructor(parameterPositions, sampleValues, sampleSize, resultBuffer) {
|
|
1193
1187
|
super(parameterPositions, sampleValues, sampleSize, resultBuffer);
|
|
1194
1188
|
}
|
|
@@ -1230,7 +1224,7 @@ class GLTFCubicSplineInterpolant extends _three.Interpolant {
|
|
|
1230
1224
|
return result;
|
|
1231
1225
|
}
|
|
1232
1226
|
}
|
|
1233
|
-
const _q = new
|
|
1227
|
+
const _q = new Quaternion();
|
|
1234
1228
|
class GLTFCubicSplineQuaternionInterpolant extends GLTFCubicSplineInterpolant {
|
|
1235
1229
|
interpolate_(i1, t0, t, t1) {
|
|
1236
1230
|
const result = super.interpolate_(i1, t0, t, t1);
|
|
@@ -1275,17 +1269,17 @@ const WEBGL_COMPONENT_TYPES = {
|
|
|
1275
1269
|
5126: Float32Array
|
|
1276
1270
|
};
|
|
1277
1271
|
const WEBGL_FILTERS = {
|
|
1278
|
-
9728:
|
|
1279
|
-
9729:
|
|
1280
|
-
9984:
|
|
1281
|
-
9985:
|
|
1282
|
-
9986:
|
|
1283
|
-
9987:
|
|
1272
|
+
9728: NearestFilter,
|
|
1273
|
+
9729: LinearFilter,
|
|
1274
|
+
9984: NearestMipmapNearestFilter,
|
|
1275
|
+
9985: LinearMipmapNearestFilter,
|
|
1276
|
+
9986: NearestMipmapLinearFilter,
|
|
1277
|
+
9987: LinearMipmapLinearFilter
|
|
1284
1278
|
};
|
|
1285
1279
|
const WEBGL_WRAPPINGS = {
|
|
1286
|
-
33071:
|
|
1287
|
-
33648:
|
|
1288
|
-
10497:
|
|
1280
|
+
33071: ClampToEdgeWrapping,
|
|
1281
|
+
33648: MirroredRepeatWrapping,
|
|
1282
|
+
10497: RepeatWrapping
|
|
1289
1283
|
};
|
|
1290
1284
|
const WEBGL_TYPE_SIZES = {
|
|
1291
1285
|
'SCALAR': 1,
|
|
@@ -1319,8 +1313,8 @@ const INTERPOLATION = {
|
|
|
1319
1313
|
CUBICSPLINE: undefined,
|
|
1320
1314
|
// We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each
|
|
1321
1315
|
// keyframe track will be initialized with a default interpolation type, then modified.
|
|
1322
|
-
LINEAR:
|
|
1323
|
-
STEP:
|
|
1316
|
+
LINEAR: InterpolateLinear,
|
|
1317
|
+
STEP: InterpolateDiscrete
|
|
1324
1318
|
};
|
|
1325
1319
|
const ALPHA_MODES = {
|
|
1326
1320
|
OPAQUE: 'OPAQUE',
|
|
@@ -1333,14 +1327,14 @@ const ALPHA_MODES = {
|
|
|
1333
1327
|
*/
|
|
1334
1328
|
function createDefaultMaterial(cache) {
|
|
1335
1329
|
if (cache['DefaultMaterial'] === undefined) {
|
|
1336
|
-
cache['DefaultMaterial'] = new
|
|
1330
|
+
cache['DefaultMaterial'] = new MeshStandardMaterial({
|
|
1337
1331
|
color: 0xFFFFFF,
|
|
1338
1332
|
emissive: 0x000000,
|
|
1339
1333
|
metalness: 1,
|
|
1340
1334
|
roughness: 1,
|
|
1341
1335
|
transparent: false,
|
|
1342
1336
|
depthTest: true,
|
|
1343
|
-
side:
|
|
1337
|
+
side: FrontSide
|
|
1344
1338
|
});
|
|
1345
1339
|
}
|
|
1346
1340
|
return cache['DefaultMaterial'];
|
|
@@ -1490,7 +1484,7 @@ function getImageURIMimeType(uri) {
|
|
|
1490
1484
|
if (uri.search(/\.webp($|\?)/i) > 0 || uri.search(/^data\:image\/webp/) === 0) return 'image/webp';
|
|
1491
1485
|
return 'image/png';
|
|
1492
1486
|
}
|
|
1493
|
-
const _identityMatrix = new
|
|
1487
|
+
const _identityMatrix = new Matrix4();
|
|
1494
1488
|
|
|
1495
1489
|
/* GLTF PARSER */
|
|
1496
1490
|
|
|
@@ -1546,13 +1540,13 @@ class GLTFParser {
|
|
|
1546
1540
|
firefoxVersion = isFirefox ? navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1] : -1;
|
|
1547
1541
|
}
|
|
1548
1542
|
if (typeof createImageBitmap === 'undefined' || isSafari || isFirefox && firefoxVersion < 98) {
|
|
1549
|
-
this.textureLoader = new
|
|
1543
|
+
this.textureLoader = new TextureLoader(this.options.manager);
|
|
1550
1544
|
} else {
|
|
1551
|
-
this.textureLoader = new
|
|
1545
|
+
this.textureLoader = new ImageBitmapLoader(this.options.manager);
|
|
1552
1546
|
}
|
|
1553
1547
|
this.textureLoader.setCrossOrigin(this.options.crossOrigin);
|
|
1554
1548
|
this.textureLoader.setRequestHeader(this.options.requestHeader);
|
|
1555
|
-
this.fileLoader = new
|
|
1549
|
+
this.fileLoader = new FileLoader(this.options.manager);
|
|
1556
1550
|
this.fileLoader.setResponseType('arraybuffer');
|
|
1557
1551
|
if (this.options.crossOrigin === 'use-credentials') {
|
|
1558
1552
|
this.fileLoader.setWithCredentials(true);
|
|
@@ -1801,7 +1795,7 @@ class GLTFParser {
|
|
|
1801
1795
|
}
|
|
1802
1796
|
const options = this.options;
|
|
1803
1797
|
return new Promise(function (resolve, reject) {
|
|
1804
|
-
loader.load(
|
|
1798
|
+
loader.load(LoaderUtils.resolveURL(bufferDef.uri, options.path), resolve, undefined, function () {
|
|
1805
1799
|
reject(new Error('THREE.GLTFLoader: Failed to load buffer "' + bufferDef.uri + '".'));
|
|
1806
1800
|
});
|
|
1807
1801
|
});
|
|
@@ -1835,7 +1829,7 @@ class GLTFParser {
|
|
|
1835
1829
|
const TypedArray = WEBGL_COMPONENT_TYPES[accessorDef.componentType];
|
|
1836
1830
|
const normalized = accessorDef.normalized === true;
|
|
1837
1831
|
const array = new TypedArray(accessorDef.count * itemSize);
|
|
1838
|
-
return Promise.resolve(new
|
|
1832
|
+
return Promise.resolve(new BufferAttribute(array, itemSize, normalized));
|
|
1839
1833
|
}
|
|
1840
1834
|
const pendingBufferViews = [];
|
|
1841
1835
|
if (accessorDef.bufferView !== undefined) {
|
|
@@ -1870,17 +1864,17 @@ class GLTFParser {
|
|
|
1870
1864
|
array = new TypedArray(bufferView, ibSlice * byteStride, accessorDef.count * byteStride / elementBytes);
|
|
1871
1865
|
|
|
1872
1866
|
// Integer parameters to IB/IBA are in array elements, not bytes.
|
|
1873
|
-
ib = new
|
|
1867
|
+
ib = new InterleavedBuffer(array, byteStride / elementBytes);
|
|
1874
1868
|
parser.cache.add(ibCacheKey, ib);
|
|
1875
1869
|
}
|
|
1876
|
-
bufferAttribute = new
|
|
1870
|
+
bufferAttribute = new InterleavedBufferAttribute(ib, itemSize, byteOffset % byteStride / elementBytes, normalized);
|
|
1877
1871
|
} else {
|
|
1878
1872
|
if (bufferView === null) {
|
|
1879
1873
|
array = new TypedArray(accessorDef.count * itemSize);
|
|
1880
1874
|
} else {
|
|
1881
1875
|
array = new TypedArray(bufferView, byteOffset, accessorDef.count * itemSize);
|
|
1882
1876
|
}
|
|
1883
|
-
bufferAttribute = new
|
|
1877
|
+
bufferAttribute = new BufferAttribute(array, itemSize, normalized);
|
|
1884
1878
|
}
|
|
1885
1879
|
|
|
1886
1880
|
// https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#sparse-accessors
|
|
@@ -1893,7 +1887,7 @@ class GLTFParser {
|
|
|
1893
1887
|
const sparseValues = new TypedArray(bufferViews[2], byteOffsetValues, accessorDef.sparse.count * itemSize);
|
|
1894
1888
|
if (bufferView !== null) {
|
|
1895
1889
|
// Avoid modifying the original ArrayBuffer, if the bufferView wasn't initialized with zeroes.
|
|
1896
|
-
bufferAttribute = new
|
|
1890
|
+
bufferAttribute = new BufferAttribute(bufferAttribute.array.slice(), bufferAttribute.itemSize, bufferAttribute.normalized);
|
|
1897
1891
|
}
|
|
1898
1892
|
for (let i = 0, il = sparseIndices.length; i < il; i++) {
|
|
1899
1893
|
const index = sparseIndices[i];
|
|
@@ -1944,10 +1938,10 @@ class GLTFParser {
|
|
|
1944
1938
|
}
|
|
1945
1939
|
const samplers = json.samplers || {};
|
|
1946
1940
|
const sampler = samplers[textureDef.sampler] || {};
|
|
1947
|
-
texture.magFilter = WEBGL_FILTERS[sampler.magFilter] ||
|
|
1948
|
-
texture.minFilter = WEBGL_FILTERS[sampler.minFilter] ||
|
|
1949
|
-
texture.wrapS = WEBGL_WRAPPINGS[sampler.wrapS] ||
|
|
1950
|
-
texture.wrapT = WEBGL_WRAPPINGS[sampler.wrapT] ||
|
|
1941
|
+
texture.magFilter = WEBGL_FILTERS[sampler.magFilter] || LinearFilter;
|
|
1942
|
+
texture.minFilter = WEBGL_FILTERS[sampler.minFilter] || LinearMipmapLinearFilter;
|
|
1943
|
+
texture.wrapS = WEBGL_WRAPPINGS[sampler.wrapS] || RepeatWrapping;
|
|
1944
|
+
texture.wrapT = WEBGL_WRAPPINGS[sampler.wrapT] || RepeatWrapping;
|
|
1951
1945
|
parser.associations.set(texture, {
|
|
1952
1946
|
textures: textureIndex
|
|
1953
1947
|
});
|
|
@@ -1988,12 +1982,12 @@ class GLTFParser {
|
|
|
1988
1982
|
let onLoad = resolve;
|
|
1989
1983
|
if (loader.isImageBitmapLoader === true) {
|
|
1990
1984
|
onLoad = function (imageBitmap) {
|
|
1991
|
-
const texture = new
|
|
1985
|
+
const texture = new Texture(imageBitmap);
|
|
1992
1986
|
texture.needsUpdate = true;
|
|
1993
1987
|
resolve(texture);
|
|
1994
1988
|
};
|
|
1995
1989
|
}
|
|
1996
|
-
loader.load(
|
|
1990
|
+
loader.load(LoaderUtils.resolveURL(sourceURI, options.path), onLoad, undefined, reject);
|
|
1997
1991
|
});
|
|
1998
1992
|
}).then(function (texture) {
|
|
1999
1993
|
// Clean up resources and configure Texture.
|
|
@@ -2060,8 +2054,8 @@ class GLTFParser {
|
|
|
2060
2054
|
const cacheKey = 'PointsMaterial:' + material.uuid;
|
|
2061
2055
|
let pointsMaterial = this.cache.get(cacheKey);
|
|
2062
2056
|
if (!pointsMaterial) {
|
|
2063
|
-
pointsMaterial = new
|
|
2064
|
-
|
|
2057
|
+
pointsMaterial = new PointsMaterial();
|
|
2058
|
+
Material.prototype.copy.call(pointsMaterial, material);
|
|
2065
2059
|
pointsMaterial.color.copy(material.color);
|
|
2066
2060
|
pointsMaterial.map = material.map;
|
|
2067
2061
|
pointsMaterial.sizeAttenuation = false; // glTF spec says points should be 1px
|
|
@@ -2073,8 +2067,8 @@ class GLTFParser {
|
|
|
2073
2067
|
const cacheKey = 'LineBasicMaterial:' + material.uuid;
|
|
2074
2068
|
let lineMaterial = this.cache.get(cacheKey);
|
|
2075
2069
|
if (!lineMaterial) {
|
|
2076
|
-
lineMaterial = new
|
|
2077
|
-
|
|
2070
|
+
lineMaterial = new LineBasicMaterial();
|
|
2071
|
+
Material.prototype.copy.call(lineMaterial, material);
|
|
2078
2072
|
lineMaterial.color.copy(material.color);
|
|
2079
2073
|
lineMaterial.map = material.map;
|
|
2080
2074
|
this.cache.add(cacheKey, lineMaterial);
|
|
@@ -2107,7 +2101,7 @@ class GLTFParser {
|
|
|
2107
2101
|
}
|
|
2108
2102
|
getMaterialType( /* materialIndex */
|
|
2109
2103
|
) {
|
|
2110
|
-
return
|
|
2104
|
+
return MeshStandardMaterial;
|
|
2111
2105
|
}
|
|
2112
2106
|
|
|
2113
2107
|
/**
|
|
@@ -2133,15 +2127,15 @@ class GLTFParser {
|
|
|
2133
2127
|
// https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#metallic-roughness-material
|
|
2134
2128
|
|
|
2135
2129
|
const metallicRoughness = materialDef.pbrMetallicRoughness || {};
|
|
2136
|
-
materialParams.color = new
|
|
2130
|
+
materialParams.color = new Color(1.0, 1.0, 1.0);
|
|
2137
2131
|
materialParams.opacity = 1.0;
|
|
2138
2132
|
if (Array.isArray(metallicRoughness.baseColorFactor)) {
|
|
2139
2133
|
const array = metallicRoughness.baseColorFactor;
|
|
2140
|
-
materialParams.color.setRGB(array[0], array[1], array[2],
|
|
2134
|
+
materialParams.color.setRGB(array[0], array[1], array[2], LinearSRGBColorSpace);
|
|
2141
2135
|
materialParams.opacity = array[3];
|
|
2142
2136
|
}
|
|
2143
2137
|
if (metallicRoughness.baseColorTexture !== undefined) {
|
|
2144
|
-
pending.push(parser.assignTexture(materialParams, 'map', metallicRoughness.baseColorTexture,
|
|
2138
|
+
pending.push(parser.assignTexture(materialParams, 'map', metallicRoughness.baseColorTexture, SRGBColorSpace));
|
|
2145
2139
|
}
|
|
2146
2140
|
materialParams.metalness = metallicRoughness.metallicFactor !== undefined ? metallicRoughness.metallicFactor : 1.0;
|
|
2147
2141
|
materialParams.roughness = metallicRoughness.roughnessFactor !== undefined ? metallicRoughness.roughnessFactor : 1.0;
|
|
@@ -2157,7 +2151,7 @@ class GLTFParser {
|
|
|
2157
2151
|
})));
|
|
2158
2152
|
}
|
|
2159
2153
|
if (materialDef.doubleSided === true) {
|
|
2160
|
-
materialParams.side =
|
|
2154
|
+
materialParams.side = DoubleSide;
|
|
2161
2155
|
}
|
|
2162
2156
|
const alphaMode = materialDef.alphaMode || ALPHA_MODES.OPAQUE;
|
|
2163
2157
|
if (alphaMode === ALPHA_MODES.BLEND) {
|
|
@@ -2171,26 +2165,26 @@ class GLTFParser {
|
|
|
2171
2165
|
materialParams.alphaTest = materialDef.alphaCutoff !== undefined ? materialDef.alphaCutoff : 0.5;
|
|
2172
2166
|
}
|
|
2173
2167
|
}
|
|
2174
|
-
if (materialDef.normalTexture !== undefined && materialType !==
|
|
2168
|
+
if (materialDef.normalTexture !== undefined && materialType !== MeshBasicMaterial) {
|
|
2175
2169
|
pending.push(parser.assignTexture(materialParams, 'normalMap', materialDef.normalTexture));
|
|
2176
|
-
materialParams.normalScale = new
|
|
2170
|
+
materialParams.normalScale = new Vector2(1, 1);
|
|
2177
2171
|
if (materialDef.normalTexture.scale !== undefined) {
|
|
2178
2172
|
const scale = materialDef.normalTexture.scale;
|
|
2179
2173
|
materialParams.normalScale.set(scale, scale);
|
|
2180
2174
|
}
|
|
2181
2175
|
}
|
|
2182
|
-
if (materialDef.occlusionTexture !== undefined && materialType !==
|
|
2176
|
+
if (materialDef.occlusionTexture !== undefined && materialType !== MeshBasicMaterial) {
|
|
2183
2177
|
pending.push(parser.assignTexture(materialParams, 'aoMap', materialDef.occlusionTexture));
|
|
2184
2178
|
if (materialDef.occlusionTexture.strength !== undefined) {
|
|
2185
2179
|
materialParams.aoMapIntensity = materialDef.occlusionTexture.strength;
|
|
2186
2180
|
}
|
|
2187
2181
|
}
|
|
2188
|
-
if (materialDef.emissiveFactor !== undefined && materialType !==
|
|
2182
|
+
if (materialDef.emissiveFactor !== undefined && materialType !== MeshBasicMaterial) {
|
|
2189
2183
|
const emissiveFactor = materialDef.emissiveFactor;
|
|
2190
|
-
materialParams.emissive = new
|
|
2184
|
+
materialParams.emissive = new Color().setRGB(emissiveFactor[0], emissiveFactor[1], emissiveFactor[2], LinearSRGBColorSpace);
|
|
2191
2185
|
}
|
|
2192
|
-
if (materialDef.emissiveTexture !== undefined && materialType !==
|
|
2193
|
-
pending.push(parser.assignTexture(materialParams, 'emissiveMap', materialDef.emissiveTexture,
|
|
2186
|
+
if (materialDef.emissiveTexture !== undefined && materialType !== MeshBasicMaterial) {
|
|
2187
|
+
pending.push(parser.assignTexture(materialParams, 'emissiveMap', materialDef.emissiveTexture, SRGBColorSpace));
|
|
2194
2188
|
}
|
|
2195
2189
|
return Promise.all(pending).then(function () {
|
|
2196
2190
|
const material = new materialType(materialParams);
|
|
@@ -2206,7 +2200,7 @@ class GLTFParser {
|
|
|
2206
2200
|
|
|
2207
2201
|
/** When Object3D instances are targeted by animation, they need unique names. */
|
|
2208
2202
|
createUniqueName(originalName) {
|
|
2209
|
-
const sanitizedName =
|
|
2203
|
+
const sanitizedName = PropertyBinding.sanitizeNodeName(originalName || '');
|
|
2210
2204
|
if (sanitizedName in this.nodeNamesUsed) {
|
|
2211
2205
|
return sanitizedName + '_' + ++this.nodeNamesUsed[sanitizedName];
|
|
2212
2206
|
} else {
|
|
@@ -2249,7 +2243,7 @@ class GLTFParser {
|
|
|
2249
2243
|
geometryPromise = createDracoPrimitive(primitive);
|
|
2250
2244
|
} else {
|
|
2251
2245
|
// Otherwise create a new geometry
|
|
2252
|
-
geometryPromise = addPrimitiveAttributes(new
|
|
2246
|
+
geometryPromise = addPrimitiveAttributes(new BufferGeometry(), primitive, parser);
|
|
2253
2247
|
}
|
|
2254
2248
|
|
|
2255
2249
|
// Cache this geometry
|
|
@@ -2294,24 +2288,24 @@ class GLTFParser {
|
|
|
2294
2288
|
const material = materials[i];
|
|
2295
2289
|
if (primitive.mode === WEBGL_CONSTANTS.TRIANGLES || primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP || primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN || primitive.mode === undefined) {
|
|
2296
2290
|
// .isSkinnedMesh isn't in glTF spec. See ._markDefs()
|
|
2297
|
-
mesh = meshDef.isSkinnedMesh === true ? new
|
|
2291
|
+
mesh = meshDef.isSkinnedMesh === true ? new SkinnedMesh(geometry, material) : new Mesh(geometry, material);
|
|
2298
2292
|
if (mesh.isSkinnedMesh === true) {
|
|
2299
2293
|
// normalize skin weights to fix malformed assets (see #15319)
|
|
2300
2294
|
mesh.normalizeSkinWeights();
|
|
2301
2295
|
}
|
|
2302
2296
|
if (primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP) {
|
|
2303
|
-
mesh.geometry =
|
|
2297
|
+
mesh.geometry = toTrianglesDrawMode(mesh.geometry, TriangleStripDrawMode);
|
|
2304
2298
|
} else if (primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN) {
|
|
2305
|
-
mesh.geometry =
|
|
2299
|
+
mesh.geometry = toTrianglesDrawMode(mesh.geometry, TriangleFanDrawMode);
|
|
2306
2300
|
}
|
|
2307
2301
|
} else if (primitive.mode === WEBGL_CONSTANTS.LINES) {
|
|
2308
|
-
mesh = new
|
|
2302
|
+
mesh = new LineSegments(geometry, material);
|
|
2309
2303
|
} else if (primitive.mode === WEBGL_CONSTANTS.LINE_STRIP) {
|
|
2310
|
-
mesh = new
|
|
2304
|
+
mesh = new Line(geometry, material);
|
|
2311
2305
|
} else if (primitive.mode === WEBGL_CONSTANTS.LINE_LOOP) {
|
|
2312
|
-
mesh = new
|
|
2306
|
+
mesh = new LineLoop(geometry, material);
|
|
2313
2307
|
} else if (primitive.mode === WEBGL_CONSTANTS.POINTS) {
|
|
2314
|
-
mesh = new
|
|
2308
|
+
mesh = new Points(geometry, material);
|
|
2315
2309
|
} else {
|
|
2316
2310
|
throw new Error('THREE.GLTFLoader: Primitive mode unsupported: ' + primitive.mode);
|
|
2317
2311
|
}
|
|
@@ -2334,7 +2328,7 @@ class GLTFParser {
|
|
|
2334
2328
|
if (meshDef.extensions) addUnknownExtensionsToUserData(extensions, meshes[0], meshDef);
|
|
2335
2329
|
return meshes[0];
|
|
2336
2330
|
}
|
|
2337
|
-
const group = new
|
|
2331
|
+
const group = new Group();
|
|
2338
2332
|
if (meshDef.extensions) addUnknownExtensionsToUserData(extensions, group, meshDef);
|
|
2339
2333
|
parser.associations.set(group, {
|
|
2340
2334
|
meshes: meshIndex
|
|
@@ -2360,9 +2354,9 @@ class GLTFParser {
|
|
|
2360
2354
|
return;
|
|
2361
2355
|
}
|
|
2362
2356
|
if (cameraDef.type === 'perspective') {
|
|
2363
|
-
camera = new
|
|
2357
|
+
camera = new PerspectiveCamera(MathUtils.radToDeg(params.yfov), params.aspectRatio || 1, params.znear || 1, params.zfar || 2e6);
|
|
2364
2358
|
} else if (cameraDef.type === 'orthographic') {
|
|
2365
|
-
camera = new
|
|
2359
|
+
camera = new OrthographicCamera(-params.xmag, params.xmag, params.ymag, -params.ymag, params.znear, params.zfar);
|
|
2366
2360
|
}
|
|
2367
2361
|
if (cameraDef.name) camera.name = this.createUniqueName(cameraDef.name);
|
|
2368
2362
|
assignExtrasToUserData(camera, cameraDef);
|
|
@@ -2398,7 +2392,7 @@ class GLTFParser {
|
|
|
2398
2392
|
const jointNode = jointNodes[i];
|
|
2399
2393
|
if (jointNode) {
|
|
2400
2394
|
bones.push(jointNode);
|
|
2401
|
-
const mat = new
|
|
2395
|
+
const mat = new Matrix4();
|
|
2402
2396
|
if (inverseBindMatrices !== null) {
|
|
2403
2397
|
mat.fromArray(inverseBindMatrices.array, i * 16);
|
|
2404
2398
|
}
|
|
@@ -2407,7 +2401,7 @@ class GLTFParser {
|
|
|
2407
2401
|
console.warn('THREE.GLTFLoader: Joint "%s" could not be found.', skinDef.joints[i]);
|
|
2408
2402
|
}
|
|
2409
2403
|
}
|
|
2410
|
-
return new
|
|
2404
|
+
return new Skeleton(bones, boneInverses);
|
|
2411
2405
|
});
|
|
2412
2406
|
}
|
|
2413
2407
|
|
|
@@ -2464,7 +2458,7 @@ class GLTFParser {
|
|
|
2464
2458
|
}
|
|
2465
2459
|
}
|
|
2466
2460
|
}
|
|
2467
|
-
return new
|
|
2461
|
+
return new AnimationClip(animationName, undefined, tracks);
|
|
2468
2462
|
});
|
|
2469
2463
|
}
|
|
2470
2464
|
createNodeMesh(nodeIndex) {
|
|
@@ -2562,13 +2556,13 @@ class GLTFParser {
|
|
|
2562
2556
|
|
|
2563
2557
|
// .isBone isn't in glTF spec. See ._markDefs
|
|
2564
2558
|
if (nodeDef.isBone === true) {
|
|
2565
|
-
node = new
|
|
2559
|
+
node = new Bone();
|
|
2566
2560
|
} else if (objects.length > 1) {
|
|
2567
|
-
node = new
|
|
2561
|
+
node = new Group();
|
|
2568
2562
|
} else if (objects.length === 1) {
|
|
2569
2563
|
node = objects[0];
|
|
2570
2564
|
} else {
|
|
2571
|
-
node = new
|
|
2565
|
+
node = new Object3D();
|
|
2572
2566
|
}
|
|
2573
2567
|
if (node !== objects[0]) {
|
|
2574
2568
|
for (let i = 0, il = objects.length; i < il; i++) {
|
|
@@ -2582,7 +2576,7 @@ class GLTFParser {
|
|
|
2582
2576
|
assignExtrasToUserData(node, nodeDef);
|
|
2583
2577
|
if (nodeDef.extensions) addUnknownExtensionsToUserData(extensions, node, nodeDef);
|
|
2584
2578
|
if (nodeDef.matrix !== undefined) {
|
|
2585
|
-
const matrix = new
|
|
2579
|
+
const matrix = new Matrix4();
|
|
2586
2580
|
matrix.fromArray(nodeDef.matrix);
|
|
2587
2581
|
node.applyMatrix4(matrix);
|
|
2588
2582
|
} else {
|
|
@@ -2617,7 +2611,7 @@ class GLTFParser {
|
|
|
2617
2611
|
|
|
2618
2612
|
// Loader returns Group, not Scene.
|
|
2619
2613
|
// See: https://github.com/mrdoob/three.js/issues/18342#issuecomment-578981172
|
|
2620
|
-
const scene = new
|
|
2614
|
+
const scene = new Group();
|
|
2621
2615
|
if (sceneDef.name) scene.name = parser.createUniqueName(sceneDef.name);
|
|
2622
2616
|
assignExtrasToUserData(scene, sceneDef);
|
|
2623
2617
|
if (sceneDef.extensions) addUnknownExtensionsToUserData(extensions, scene, sceneDef);
|
|
@@ -2636,7 +2630,7 @@ class GLTFParser {
|
|
|
2636
2630
|
parser.associations = (node => {
|
|
2637
2631
|
const reducedAssociations = new Map();
|
|
2638
2632
|
for (const [key, value] of parser.associations) {
|
|
2639
|
-
if (key instanceof
|
|
2633
|
+
if (key instanceof Material || key instanceof Texture) {
|
|
2640
2634
|
reducedAssociations.set(key, value);
|
|
2641
2635
|
}
|
|
2642
2636
|
}
|
|
@@ -2667,29 +2661,29 @@ class GLTFParser {
|
|
|
2667
2661
|
let TypedKeyframeTrack;
|
|
2668
2662
|
switch (PATH_PROPERTIES[target.path]) {
|
|
2669
2663
|
case PATH_PROPERTIES.weights:
|
|
2670
|
-
TypedKeyframeTrack =
|
|
2664
|
+
TypedKeyframeTrack = NumberKeyframeTrack;
|
|
2671
2665
|
break;
|
|
2672
2666
|
case PATH_PROPERTIES.rotation:
|
|
2673
|
-
TypedKeyframeTrack =
|
|
2667
|
+
TypedKeyframeTrack = QuaternionKeyframeTrack;
|
|
2674
2668
|
break;
|
|
2675
2669
|
case PATH_PROPERTIES.position:
|
|
2676
2670
|
case PATH_PROPERTIES.scale:
|
|
2677
|
-
TypedKeyframeTrack =
|
|
2671
|
+
TypedKeyframeTrack = VectorKeyframeTrack;
|
|
2678
2672
|
break;
|
|
2679
2673
|
default:
|
|
2680
2674
|
switch (outputAccessor.itemSize) {
|
|
2681
2675
|
case 1:
|
|
2682
|
-
TypedKeyframeTrack =
|
|
2676
|
+
TypedKeyframeTrack = NumberKeyframeTrack;
|
|
2683
2677
|
break;
|
|
2684
2678
|
case 2:
|
|
2685
2679
|
case 3:
|
|
2686
2680
|
default:
|
|
2687
|
-
TypedKeyframeTrack =
|
|
2681
|
+
TypedKeyframeTrack = VectorKeyframeTrack;
|
|
2688
2682
|
break;
|
|
2689
2683
|
}
|
|
2690
2684
|
break;
|
|
2691
2685
|
}
|
|
2692
|
-
const interpolation = sampler.interpolation !== undefined ? INTERPOLATION[sampler.interpolation] :
|
|
2686
|
+
const interpolation = sampler.interpolation !== undefined ? INTERPOLATION[sampler.interpolation] : InterpolateLinear;
|
|
2693
2687
|
const outputArray = this._getArrayFromAccessor(outputAccessor);
|
|
2694
2688
|
for (let j = 0, jl = targetNames.length; j < jl; j++) {
|
|
2695
2689
|
const track = new TypedKeyframeTrack(targetNames[j] + '.' + PATH_PROPERTIES[target.path], inputAccessor.array, outputArray, interpolation);
|
|
@@ -2720,7 +2714,7 @@ class GLTFParser {
|
|
|
2720
2714
|
// representing inTangent, splineVertex, and outTangent. As a result, track.getValueSize()
|
|
2721
2715
|
// must be divided by three to get the interpolant's sampleSize argument.
|
|
2722
2716
|
|
|
2723
|
-
const interpolantType = this instanceof
|
|
2717
|
+
const interpolantType = this instanceof QuaternionKeyframeTrack ? GLTFCubicSplineQuaternionInterpolant : GLTFCubicSplineInterpolant;
|
|
2724
2718
|
return new interpolantType(this.times, this.values, this.getValueSize() / 3, result);
|
|
2725
2719
|
};
|
|
2726
2720
|
|
|
@@ -2736,7 +2730,7 @@ class GLTFParser {
|
|
|
2736
2730
|
*/
|
|
2737
2731
|
function computeBounds(geometry, primitiveDef, parser) {
|
|
2738
2732
|
const attributes = primitiveDef.attributes;
|
|
2739
|
-
const box = new
|
|
2733
|
+
const box = new Box3();
|
|
2740
2734
|
if (attributes.POSITION !== undefined) {
|
|
2741
2735
|
const accessor = parser.json.accessors[attributes.POSITION];
|
|
2742
2736
|
const min = accessor.min;
|
|
@@ -2745,7 +2739,7 @@ function computeBounds(geometry, primitiveDef, parser) {
|
|
|
2745
2739
|
// glTF requires 'min' and 'max', but VRM (which extends glTF) currently ignores that requirement.
|
|
2746
2740
|
|
|
2747
2741
|
if (min !== undefined && max !== undefined) {
|
|
2748
|
-
box.set(new
|
|
2742
|
+
box.set(new Vector3(min[0], min[1], min[2]), new Vector3(max[0], max[1], max[2]));
|
|
2749
2743
|
if (accessor.normalized) {
|
|
2750
2744
|
const boxScale = getNormalizedComponentScale(WEBGL_COMPONENT_TYPES[accessor.componentType]);
|
|
2751
2745
|
box.min.multiplyScalar(boxScale);
|
|
@@ -2760,8 +2754,8 @@ function computeBounds(geometry, primitiveDef, parser) {
|
|
|
2760
2754
|
}
|
|
2761
2755
|
const targets = primitiveDef.targets;
|
|
2762
2756
|
if (targets !== undefined) {
|
|
2763
|
-
const maxDisplacement = new
|
|
2764
|
-
const vector = new
|
|
2757
|
+
const maxDisplacement = new Vector3();
|
|
2758
|
+
const vector = new Vector3();
|
|
2765
2759
|
for (let i = 0, il = targets.length; i < il; i++) {
|
|
2766
2760
|
const target = targets[i];
|
|
2767
2761
|
if (target.POSITION !== undefined) {
|
|
@@ -2796,7 +2790,7 @@ function computeBounds(geometry, primitiveDef, parser) {
|
|
|
2796
2790
|
box.expandByVector(maxDisplacement);
|
|
2797
2791
|
}
|
|
2798
2792
|
geometry.boundingBox = box;
|
|
2799
|
-
const sphere = new
|
|
2793
|
+
const sphere = new Sphere();
|
|
2800
2794
|
box.getCenter(sphere.center);
|
|
2801
2795
|
sphere.radius = box.min.distanceTo(box.max) / 2;
|
|
2802
2796
|
geometry.boundingSphere = sphere;
|
|
@@ -2829,12 +2823,13 @@ function addPrimitiveAttributes(geometry, primitiveDef, parser) {
|
|
|
2829
2823
|
});
|
|
2830
2824
|
pending.push(accessor);
|
|
2831
2825
|
}
|
|
2832
|
-
if (
|
|
2833
|
-
console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${
|
|
2826
|
+
if (ColorManagement.workingColorSpace !== LinearSRGBColorSpace && 'COLOR_0' in attributes) {
|
|
2827
|
+
console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${ColorManagement.workingColorSpace}" not supported.`);
|
|
2834
2828
|
}
|
|
2835
2829
|
assignExtrasToUserData(geometry, primitiveDef);
|
|
2836
2830
|
computeBounds(geometry, primitiveDef, parser);
|
|
2837
2831
|
return Promise.all(pending).then(function () {
|
|
2838
2832
|
return primitiveDef.targets !== undefined ? addMorphTargets(geometry, primitiveDef.targets, parser) : geometry;
|
|
2839
2833
|
});
|
|
2840
|
-
}
|
|
2834
|
+
}
|
|
2835
|
+
export { GLTFLoader };
|