@cesium/engine 9.1.0 → 10.0.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/Build/ThirdParty/Workers/pako_deflate.min.js +108 -210
- package/Build/ThirdParty/Workers/pako_inflate.min.js +466 -568
- package/Build/ThirdParty/Workers/z-worker-pako.js +54 -104
- package/Build/Workers/{chunk-TMMOULW3.js → chunk-2J3JKXCP.js} +5 -5
- package/Build/Workers/{chunk-ZDP32RQI.js → chunk-3WUV74WM.js} +95 -155
- package/Build/Workers/{chunk-FOZQIHZK.js → chunk-4BAE4PWO.js} +6 -6
- package/Build/Workers/{chunk-CYAJYEKW.js → chunk-4MSUJ4I7.js} +8 -8
- package/Build/Workers/{chunk-KPY4F4BW.js → chunk-4YSNMHZ4.js} +6 -6
- package/Build/Workers/{chunk-66E3H2KU.js → chunk-5S7OLEPK.js} +12 -12
- package/Build/Workers/{chunk-4AJGCQFX.js → chunk-7XGC6YB2.js} +14 -14
- package/Build/Workers/{chunk-BDUJXBVF.js → chunk-AA4GZKOT.js} +3 -5
- package/Build/Workers/{chunk-7LPEGKOF.js → chunk-AD5HBJ2F.js} +11 -8
- package/Build/Workers/{chunk-XHLDDE65.js → chunk-AVI4IUWC.js} +11 -11
- package/Build/Workers/{chunk-MWYZ64MH.js → chunk-BCL4PHHT.js} +10 -10
- package/Build/Workers/{chunk-PWF3YJJ5.js → chunk-BDFNKFOE.js} +13 -13
- package/Build/Workers/{chunk-7VZNXIKG.js → chunk-BJF5LOWE.js} +7 -7
- package/Build/Workers/{chunk-3S2MFY4B.js → chunk-C2CGMAIU.js} +13 -13
- package/Build/Workers/{chunk-UAJEGIWA.js → chunk-COYFZ5VA.js} +6 -6
- package/Build/Workers/{chunk-ZWPIM77Q.js → chunk-DGS5QNIO.js} +13 -13
- package/Build/Workers/{chunk-V7JB576Q.js → chunk-DKVHRNFY.js} +5 -5
- package/Build/Workers/{chunk-NI2R52QD.js → chunk-DOXCPOG4.js} +11 -9
- package/Build/Workers/{chunk-XWML5Y7N.js → chunk-FXIHSF7O.js} +9 -9
- package/Build/Workers/{chunk-LW7WGHEU.js → chunk-G3YR53LY.js} +13 -13
- package/Build/Workers/{chunk-34DGOKCO.js → chunk-GR3CDLCP.js} +7 -7
- package/Build/Workers/{chunk-AOIKO5Y7.js → chunk-GRAT5GE7.js} +5 -5
- package/Build/Workers/{chunk-AOFMPKUB.js → chunk-I2RC4XVN.js} +4 -4
- package/Build/Workers/{chunk-PK7TEP3J.js → chunk-JYAHOGGL.js} +15 -15
- package/Build/Workers/{chunk-4KIUON73.js → chunk-KUN2ZA5X.js} +4 -4
- package/Build/Workers/{chunk-POLFRINT.js → chunk-L6RTJ3RE.js} +14 -14
- package/Build/Workers/{chunk-LVJCR7DH.js → chunk-LCLJJ2MZ.js} +18 -18
- package/Build/Workers/{chunk-3RZK5NNV.js → chunk-LEABCTLP.js} +4 -4
- package/Build/Workers/{chunk-QKF7XXEQ.js → chunk-MDHQR3ZS.js} +10 -8
- package/Build/Workers/{chunk-4PHPQRSH.js → chunk-MSKXMXJI.js} +5 -6
- package/Build/Workers/{chunk-GIFJ77E4.js → chunk-NTXTUNEF.js} +4 -4
- package/Build/Workers/{chunk-I5TDPPC4.js → chunk-O3JCMSS3.js} +17 -17
- package/Build/Workers/{chunk-PEABJLCK.js → chunk-OOK53QUQ.js} +1 -1
- package/Build/Workers/{chunk-PS6AEMBR.js → chunk-OORVMGDU.js} +7 -7
- package/Build/Workers/{chunk-JI2445T5.js → chunk-PCP4YQST.js} +11 -11
- package/Build/Workers/{chunk-C5CE4OG6.js → chunk-PYHLO636.js} +42 -13
- package/Build/Workers/{chunk-S4XDCPKD.js → chunk-Q55ECN3Y.js} +1 -1
- package/Build/Workers/{chunk-WWP3I7R5.js → chunk-QD4KM3GO.js} +5 -5
- package/Build/Workers/{chunk-YLZTCEBJ.js → chunk-QMLTCCYG.js} +1 -1
- package/Build/Workers/{chunk-IBXGK4WV.js → chunk-QX5XS4LC.js} +2 -2
- package/Build/Workers/{chunk-RL73GOEF.js → chunk-R6B7UCQB.js} +2 -2
- package/Build/Workers/{chunk-RR7EOKGZ.js → chunk-RJYML24O.js} +48 -85
- package/Build/Workers/{chunk-U4IMCOF5.js → chunk-S3PI2KFM.js} +2 -2
- package/Build/Workers/{chunk-6HCAQOVK.js → chunk-STBBMQGG.js} +6 -6
- package/Build/Workers/{chunk-CE6GTZ4I.js → chunk-SYCPRK3D.js} +10 -10
- package/Build/Workers/{chunk-WFICTTOE.js → chunk-T77JILCU.js} +2 -2
- package/Build/Workers/{chunk-ZC4AGBZK.js → chunk-TO2PVHKI.js} +2 -2
- package/Build/Workers/{chunk-UCPPWV64.js → chunk-VE7BFUIX.js} +1 -1
- package/Build/Workers/{chunk-2CSEEWHN.js → chunk-VFBNELXB.js} +7 -7
- package/Build/Workers/{chunk-A6NCZSL3.js → chunk-VO3ACQB2.js} +19 -19
- package/Build/Workers/{chunk-WEGCQ5DY.js → chunk-X23FRWHJ.js} +6 -6
- package/Build/Workers/{chunk-G7CJQKKD.js → chunk-XD445VDH.js} +7 -7
- package/Build/Workers/combineGeometry.js +22 -22
- package/Build/Workers/createBoxGeometry.js +16 -16
- package/Build/Workers/createBoxOutlineGeometry.js +14 -14
- package/Build/Workers/createCircleGeometry.js +29 -25
- package/Build/Workers/createCircleOutlineGeometry.js +17 -17
- package/Build/Workers/createCoplanarPolygonGeometry.js +32 -32
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +29 -29
- package/Build/Workers/createCorridorGeometry.js +29 -29
- package/Build/Workers/createCorridorOutlineGeometry.js +27 -27
- package/Build/Workers/createCylinderGeometry.js +18 -18
- package/Build/Workers/createCylinderOutlineGeometry.js +16 -16
- package/Build/Workers/createEllipseGeometry.js +24 -24
- package/Build/Workers/createEllipseOutlineGeometry.js +17 -17
- package/Build/Workers/createEllipsoidGeometry.js +17 -17
- package/Build/Workers/createEllipsoidOutlineGeometry.js +16 -16
- package/Build/Workers/createFrustumGeometry.js +16 -16
- package/Build/Workers/createFrustumOutlineGeometry.js +16 -16
- package/Build/Workers/createGeometry.js +22 -22
- package/Build/Workers/createGroundPolylineGeometry.js +24 -24
- package/Build/Workers/createPlaneGeometry.js +14 -14
- package/Build/Workers/createPlaneOutlineGeometry.js +13 -13
- package/Build/Workers/createPolygonGeometry.js +32 -32
- package/Build/Workers/createPolygonOutlineGeometry.js +29 -29
- package/Build/Workers/createPolylineGeometry.js +24 -24
- package/Build/Workers/createPolylineVolumeGeometry.js +30 -30
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +26 -26
- package/Build/Workers/createRectangleGeometry.js +27 -27
- package/Build/Workers/createRectangleOutlineGeometry.js +19 -19
- package/Build/Workers/createSimplePolylineGeometry.js +22 -22
- package/Build/Workers/createSphereGeometry.js +17 -17
- package/Build/Workers/createSphereOutlineGeometry.js +16 -16
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +13 -13
- package/Build/Workers/createVectorTileGeometries.js +22 -22
- package/Build/Workers/createVectorTilePoints.js +12 -12
- package/Build/Workers/createVectorTilePolygons.js +20 -20
- package/Build/Workers/createVectorTilePolylines.js +13 -13
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +20 -20
- package/Build/Workers/createVerticesFromHeightmap.js +21 -21
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +17 -17
- package/Build/Workers/createWallGeometry.js +23 -23
- package/Build/Workers/createWallOutlineGeometry.js +22 -22
- package/Build/Workers/decodeDraco.js +11 -11
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +12 -19
- package/Build/Workers/decodeI3S.js +10 -10
- package/Build/Workers/transcodeKTX2.js +43 -79
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +20 -20
- package/Source/Core/ApproximateTerrainHeights.js +4 -4
- package/Source/Core/ArcGISTiledElevationTerrainProvider.js +12 -8
- package/Source/Core/BoundingRectangle.js +2 -0
- package/Source/Core/BoundingSphere.js +4 -2
- package/Source/Core/Cartesian3.js +13 -10
- package/Source/Core/Cartographic.js +11 -8
- package/Source/Core/CesiumTerrainProvider.js +3 -2
- package/Source/Core/CircleGeometry.js +6 -2
- package/Source/Core/CircleOutlineGeometry.js +1 -1
- package/Source/Core/CoplanarPolygonGeometry.js +3 -3
- package/Source/Core/CorridorGeometry.js +4 -4
- package/Source/Core/CorridorOutlineGeometry.js +2 -2
- package/Source/Core/Credit.js +3 -2
- package/Source/Core/CustomHeightmapTerrainProvider.js +17 -3
- package/Source/Core/EllipseGeometry.js +4 -4
- package/Source/Core/EllipseOutlineGeometry.js +2 -2
- package/Source/Core/Ellipsoid.js +34 -0
- package/Source/Core/EllipsoidGeodesic.js +2 -2
- package/Source/Core/EllipsoidRhumbLine.js +4 -4
- package/Source/Core/EllipsoidTangentPlane.js +3 -3
- package/Source/Core/EllipsoidTerrainProvider.js +3 -3
- package/Source/Core/GeographicProjection.js +4 -3
- package/Source/Core/GeographicTilingScheme.js +3 -3
- package/Source/Core/GeometryPipeline.js +2 -2
- package/Source/Core/GoogleEarthEnterpriseTerrainProvider.js +1 -1
- package/Source/Core/GoogleMaps.js +1 -1
- package/Source/Core/GroundPolylineGeometry.js +1 -1
- package/Source/Core/HeightmapTessellator.js +2 -2
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/Math.js +0 -5
- package/Source/Core/Occluder.js +3 -3
- package/Source/Core/OrientedBoundingBox.js +2 -2
- package/Source/Core/PolygonGeometry.js +4 -4
- package/Source/Core/PolygonGeometryLibrary.js +1 -1
- package/Source/Core/PolygonOutlineGeometry.js +3 -3
- package/Source/Core/PolygonPipeline.js +2 -2
- package/Source/Core/PolylineGeometry.js +2 -2
- package/Source/Core/PolylinePipeline.js +6 -6
- package/Source/Core/PolylineVolumeGeometry.js +2 -2
- package/Source/Core/PolylineVolumeOutlineGeometry.js +2 -2
- package/Source/Core/Rectangle.js +6 -6
- package/Source/Core/RectangleGeometry.js +6 -6
- package/Source/Core/RectangleGeometryLibrary.js +3 -0
- package/Source/Core/RectangleOutlineGeometry.js +2 -2
- package/Source/Core/Simon1994PlanetaryPositions.js +3 -2
- package/Source/Core/SimplePolylineGeometry.js +2 -2
- package/Source/Core/Stereographic.js +2 -2
- package/Source/Core/TaskProcessor.js +19 -3
- package/Source/Core/Transforms.js +17 -17
- package/Source/Core/VRTheWorldTerrainProvider.js +2 -2
- package/Source/Core/WallGeometry.js +3 -3
- package/Source/Core/WallOutlineGeometry.js +3 -3
- package/Source/Core/WebMercatorTilingScheme.js +3 -3
- package/Source/Core/createWorldTerrainAsync.js +2 -0
- package/Source/Core/sampleTerrain.js +3 -3
- package/Source/DataSources/BoxGeometryUpdater.js +2 -2
- package/Source/DataSources/CylinderGeometryUpdater.js +2 -2
- package/Source/DataSources/CzmlDataSource.js +8 -8
- package/Source/DataSources/EllipsoidGeometryUpdater.js +3 -3
- package/Source/DataSources/EntityCluster.js +1 -1
- package/Source/DataSources/EntityView.js +2 -2
- package/Source/DataSources/KmlDataSource.js +4 -4
- package/Source/DataSources/ModelVisualizer.js +1 -2
- package/Source/DataSources/PolygonGeometryUpdater.js +1 -1
- package/Source/DataSources/PolylineGeometryUpdater.js +3 -2
- package/Source/DataSources/RectangleGeometryUpdater.js +1 -1
- package/Source/DataSources/ScaledPositionProperty.js +2 -2
- package/Source/DataSources/TerrainOffsetProperty.js +3 -7
- package/Source/DataSources/VelocityOrientationProperty.js +2 -2
- package/Source/DataSources/exportKml.js +2 -2
- package/Source/Renderer/UniformState.js +1 -1
- package/Source/Scene/ArcGisMapServerImageryProvider.js +2 -2
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Billboard.js +8 -6
- package/Source/Scene/BingMapsImageryProvider.js +1 -1
- package/Source/Scene/Camera.js +16 -10
- package/Source/Scene/Cesium3DTileset.js +1 -1
- package/Source/Scene/ClippingPolygon.js +2 -2
- package/Source/Scene/ClippingPolygonCollection.js +1 -1
- package/Source/Scene/CreditDisplay.js +94 -104
- package/Source/Scene/Globe.js +16 -13
- package/Source/Scene/GltfLoader.js +458 -435
- package/Source/Scene/GltfLoaderUtil.js +5 -16
- package/Source/Scene/GltfPipeline/forEachTextureInMaterial.js +23 -7
- package/Source/Scene/GltfStructuralMetadataLoader.js +11 -9
- package/Source/Scene/GoogleEarthEnterpriseImageryProvider.js +1 -1
- package/Source/Scene/GoogleEarthEnterpriseMapsProvider.js +1 -1
- package/Source/Scene/GridImageryProvider.js +2 -2
- package/Source/Scene/ImageryLayerCollection.js +2 -2
- package/Source/Scene/Label.js +1 -1
- package/Source/Scene/MapboxImageryProvider.js +1 -1
- package/Source/Scene/MapboxStyleImageryProvider.js +1 -1
- package/Source/Scene/MetadataSemantic.js +4 -4
- package/Source/Scene/Model/AlphaPipelineStage.js +1 -1
- package/Source/Scene/Model/GeometryPipelineStage.js +15 -43
- package/Source/Scene/Model/ImageBasedLightingPipelineStage.js +7 -0
- package/Source/Scene/Model/InstancingPipelineStage.js +3 -3
- package/Source/Scene/Model/LightingPipelineStage.js +2 -4
- package/Source/Scene/Model/MaterialPipelineStage.js +395 -29
- package/Source/Scene/Model/Model.js +15 -7
- package/Source/Scene/Model/ModelSceneGraph.js +1 -1
- package/Source/Scene/Model/ModelUtility.js +3 -0
- package/Source/Scene/Model/SceneMode2DPipelineStage.js +3 -3
- package/Source/Scene/Model/VerticalExaggerationPipelineStage.js +4 -6
- package/Source/Scene/Model/pickModel.js +2 -2
- package/Source/Scene/ModelComponents.js +178 -1
- package/Source/Scene/PickDepth.js +23 -15
- package/Source/Scene/Picking.js +4 -13
- package/Source/Scene/PointPrimitive.js +5 -2
- package/Source/Scene/ResourceCache.js +41 -50
- package/Source/Scene/ResourceCacheKey.js +41 -53
- package/Source/Scene/Scene.js +39 -31
- package/Source/Scene/SceneTransforms.js +78 -20
- package/Source/Scene/SceneTransitioner.js +2 -2
- package/Source/Scene/ScreenSpaceCameraController.js +29 -19
- package/Source/Scene/SkyBox.js +26 -0
- package/Source/Scene/Sun.js +1 -1
- package/Source/Shaders/Builtin/CzmBuiltins.js +4 -10
- package/Source/Shaders/Builtin/Functions/ellipsoidTextureCoordinates.glsl +10 -0
- package/Source/Shaders/Builtin/Functions/{ellipsoidWgs84TextureCoordinates.js → ellipsoidTextureCoordinates.js} +3 -3
- package/Source/Shaders/Builtin/Functions/maximumComponent.glsl +21 -0
- package/Source/Shaders/Builtin/Functions/maximumComponent.js +23 -0
- package/Source/Shaders/Builtin/Functions/pbrLighting.glsl +108 -44
- package/Source/Shaders/Builtin/Functions/pbrLighting.js +108 -44
- package/Source/Shaders/Builtin/Structs/materialInput.glsl +1 -1
- package/Source/Shaders/Builtin/Structs/materialInput.js +1 -1
- package/Source/Shaders/Builtin/Structs/modelMaterial.glsl +16 -0
- package/Source/Shaders/Builtin/Structs/modelMaterial.js +16 -0
- package/Source/Shaders/EllipsoidFS.glsl +1 -1
- package/Source/Shaders/EllipsoidFS.js +1 -1
- package/Source/Shaders/GlobeFS.glsl +3 -3
- package/Source/Shaders/GlobeFS.js +3 -3
- package/Source/Shaders/Model/ImageBasedLightingStageFS.glsl +211 -133
- package/Source/Shaders/Model/ImageBasedLightingStageFS.js +212 -133
- package/Source/Shaders/Model/LightingStageFS.glsl +113 -48
- package/Source/Shaders/Model/LightingStageFS.js +113 -48
- package/Source/Shaders/Model/MaterialStageFS.glsl +407 -136
- package/Source/Shaders/Model/MaterialStageFS.js +407 -136
- package/Source/Widget/CesiumWidget.css +0 -5
- package/Source/Widget/CesiumWidget.js +29 -28
- package/index.d.ts +184 -116
- package/index.js +92 -95
- package/package.json +2 -2
- package/Source/Shaders/Builtin/Functions/defaultPbrMaterial.glsl +0 -16
- package/Source/Shaders/Builtin/Functions/defaultPbrMaterial.js +0 -18
- package/Source/Shaders/Builtin/Functions/ellipsoidWgs84TextureCoordinates.glsl +0 -10
- package/Source/Shaders/Builtin/Functions/pbrMetallicRoughnessMaterial.glsl +0 -37
- package/Source/Shaders/Builtin/Functions/pbrMetallicRoughnessMaterial.js +0 -39
- package/Source/Shaders/Builtin/Functions/pbrSpecularGlossinessMaterial.glsl +0 -30
- package/Source/Shaders/Builtin/Functions/pbrSpecularGlossinessMaterial.js +0 -32
- package/Source/Shaders/Builtin/Structs/pbrParameters.glsl +0 -16
- package/Source/Shaders/Builtin/Structs/pbrParameters.js +0 -18
|
@@ -30,29 +30,34 @@ import ResourceLoader from "./ResourceLoader.js";
|
|
|
30
30
|
import SupportedImageFormats from "./SupportedImageFormats.js";
|
|
31
31
|
import VertexAttributeSemantic from "./VertexAttributeSemantic.js";
|
|
32
32
|
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
33
|
+
const {
|
|
34
|
+
Attribute,
|
|
35
|
+
Indices,
|
|
36
|
+
FeatureIdAttribute,
|
|
37
|
+
FeatureIdTexture,
|
|
38
|
+
FeatureIdImplicitRange,
|
|
39
|
+
MorphTarget,
|
|
40
|
+
Primitive,
|
|
41
|
+
Instances,
|
|
42
|
+
Skin,
|
|
43
|
+
Node,
|
|
44
|
+
AnimatedPropertyType,
|
|
45
|
+
AnimationSampler,
|
|
46
|
+
AnimationTarget,
|
|
47
|
+
AnimationChannel,
|
|
48
|
+
Animation,
|
|
49
|
+
ArticulationStage,
|
|
50
|
+
Articulation,
|
|
51
|
+
Asset,
|
|
52
|
+
Scene,
|
|
53
|
+
Components,
|
|
54
|
+
MetallicRoughness,
|
|
55
|
+
SpecularGlossiness,
|
|
56
|
+
Specular,
|
|
57
|
+
Anisotropy,
|
|
58
|
+
Clearcoat,
|
|
59
|
+
Material,
|
|
60
|
+
} = ModelComponents;
|
|
56
61
|
|
|
57
62
|
/**
|
|
58
63
|
* States of the glTF loading process. These states also apply to
|
|
@@ -188,42 +193,28 @@ const GltfLoaderState = {
|
|
|
188
193
|
*/
|
|
189
194
|
function GltfLoader(options) {
|
|
190
195
|
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
false
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
const enablePick = defaultValue(options.enablePick);
|
|
208
|
-
const loadIndicesForWireframe = defaultValue(
|
|
209
|
-
options.loadIndicesForWireframe,
|
|
210
|
-
false
|
|
211
|
-
);
|
|
212
|
-
const loadPrimitiveOutline = defaultValue(options.loadPrimitiveOutline, true);
|
|
213
|
-
const loadForClassification = defaultValue(
|
|
214
|
-
options.loadForClassification,
|
|
215
|
-
false
|
|
216
|
-
);
|
|
217
|
-
const renameBatchIdSemantic = defaultValue(
|
|
218
|
-
options.renameBatchIdSemantic,
|
|
219
|
-
false
|
|
220
|
-
);
|
|
196
|
+
const {
|
|
197
|
+
gltfResource,
|
|
198
|
+
typedArray,
|
|
199
|
+
releaseGltfJson = false,
|
|
200
|
+
asynchronous = true,
|
|
201
|
+
incrementallyLoadTextures = true,
|
|
202
|
+
upAxis = Axis.Y,
|
|
203
|
+
forwardAxis = Axis.Z,
|
|
204
|
+
loadAttributesAsTypedArray = false,
|
|
205
|
+
loadAttributesFor2D = false,
|
|
206
|
+
enablePick = false,
|
|
207
|
+
loadIndicesForWireframe = false,
|
|
208
|
+
loadPrimitiveOutline = true,
|
|
209
|
+
loadForClassification = false,
|
|
210
|
+
renameBatchIdSemantic = false,
|
|
211
|
+
} = options;
|
|
221
212
|
|
|
222
213
|
//>>includeStart('debug', pragmas.debug);
|
|
223
214
|
Check.typeOf.object("options.gltfResource", gltfResource);
|
|
224
215
|
//>>includeEnd('debug');
|
|
225
216
|
|
|
226
|
-
|
|
217
|
+
const { baseResource = gltfResource.clone() } = options;
|
|
227
218
|
|
|
228
219
|
this._gltfJson = options.gltfJson;
|
|
229
220
|
this._gltfResource = gltfResource;
|
|
@@ -273,6 +264,8 @@ function GltfLoader(options) {
|
|
|
273
264
|
this._resourcesLoaded = false;
|
|
274
265
|
this._texturesLoaded = false;
|
|
275
266
|
|
|
267
|
+
this._supportedImageFormats = undefined;
|
|
268
|
+
|
|
276
269
|
// In some cases where geometry post-processing is needed (like generating
|
|
277
270
|
// outlines) new attributes are added that may have GPU resources attached.
|
|
278
271
|
// The GltfLoader will own the resources and store them here.
|
|
@@ -408,20 +401,17 @@ async function loadResources(loader, frameState) {
|
|
|
408
401
|
await FeatureDetection.supportsWebP.initialize();
|
|
409
402
|
}
|
|
410
403
|
|
|
411
|
-
|
|
404
|
+
loader._supportedImageFormats = new SupportedImageFormats({
|
|
412
405
|
webp: FeatureDetection.supportsWebP(),
|
|
413
406
|
basis: frameState.context.supportsBasis,
|
|
414
407
|
});
|
|
415
408
|
|
|
416
|
-
//
|
|
417
|
-
// resolve once the loaders are ready (i.e. all external resources
|
|
418
|
-
// have been fetched and all GPU resources have been created). Loaders that
|
|
419
|
-
// create GPU resources need to be processed every frame until they become
|
|
409
|
+
// Loaders that create GPU resources need to be processed every frame until they become
|
|
420
410
|
// ready since the JobScheduler is not able to execute all jobs in a single
|
|
421
|
-
// frame. Any promise failures are collected, and will be handled synchronously in process().
|
|
422
|
-
// to process
|
|
423
|
-
|
|
424
|
-
const promise = parse(loader,
|
|
411
|
+
// frame. Any promise failures are collected, and will be handled synchronously in process().
|
|
412
|
+
// Also note that it's fine to call process before a loader is ready to process or
|
|
413
|
+
// after it has failed; nothing will happen.
|
|
414
|
+
const promise = parse(loader, frameState);
|
|
425
415
|
|
|
426
416
|
// All resource loaders have been created, so we can begin processing
|
|
427
417
|
loader._state = GltfLoaderState.PROCESSING;
|
|
@@ -460,11 +450,9 @@ function handleError(gltfLoader, error) {
|
|
|
460
450
|
}
|
|
461
451
|
|
|
462
452
|
function processLoaders(loader, frameState) {
|
|
463
|
-
let i;
|
|
464
453
|
let ready = true;
|
|
465
454
|
const geometryLoaders = loader._geometryLoaders;
|
|
466
|
-
|
|
467
|
-
for (i = 0; i < geometryLoadersLength; ++i) {
|
|
455
|
+
for (let i = 0; i < geometryLoaders.length; ++i) {
|
|
468
456
|
const geometryReady = geometryLoaders[i].process(frameState);
|
|
469
457
|
if (geometryReady && defined(loader._geometryCallbacks[i])) {
|
|
470
458
|
loader._geometryCallbacks[i]();
|
|
@@ -493,8 +481,7 @@ function postProcessGeometry(loader, context) {
|
|
|
493
481
|
// Apply post-processing steps on geometry such as
|
|
494
482
|
// updating attributes for rendering outlines.
|
|
495
483
|
const loadPlans = loader._primitiveLoadPlans;
|
|
496
|
-
|
|
497
|
-
for (let i = 0; i < length; i++) {
|
|
484
|
+
for (let i = 0; i < loadPlans.length; i++) {
|
|
498
485
|
const loadPlan = loadPlans[i];
|
|
499
486
|
loadPlan.postProcess(context);
|
|
500
487
|
|
|
@@ -520,8 +507,7 @@ function gatherPostProcessBuffers(loader, primitiveLoadPlan) {
|
|
|
520
507
|
// to do post-processing, all the attributes are loaded as typed arrays
|
|
521
508
|
// so if a buffer exists, it was newly generated
|
|
522
509
|
const attributes = primitive.attributes;
|
|
523
|
-
|
|
524
|
-
for (let i = 0; i < length; i++) {
|
|
510
|
+
for (let i = 0; i < attributes.length; i++) {
|
|
525
511
|
const attribute = attributes[i];
|
|
526
512
|
if (defined(attribute.buffer)) {
|
|
527
513
|
buffers.push(attribute.buffer);
|
|
@@ -583,11 +569,9 @@ GltfLoader.prototype._processTextures = function (frameState) {
|
|
|
583
569
|
return false;
|
|
584
570
|
}
|
|
585
571
|
|
|
586
|
-
let i;
|
|
587
572
|
let ready = true;
|
|
588
573
|
const textureLoaders = this._textureLoaders;
|
|
589
|
-
|
|
590
|
-
for (i = 0; i < textureLoadersLength; ++i) {
|
|
574
|
+
for (let i = 0; i < textureLoaders.length; ++i) {
|
|
591
575
|
const textureReady = textureLoaders[i].process(frameState);
|
|
592
576
|
if (textureReady && defined(this._textureCallbacks[i])) {
|
|
593
577
|
this._textureCallbacks[i]();
|
|
@@ -676,7 +660,6 @@ GltfLoader.prototype.process = function (frameState) {
|
|
|
676
660
|
|
|
677
661
|
function getVertexBufferLoader(
|
|
678
662
|
loader,
|
|
679
|
-
gltf,
|
|
680
663
|
accessorId,
|
|
681
664
|
semantic,
|
|
682
665
|
draco,
|
|
@@ -684,6 +667,7 @@ function getVertexBufferLoader(
|
|
|
684
667
|
loadTypedArray,
|
|
685
668
|
frameState
|
|
686
669
|
) {
|
|
670
|
+
const gltf = loader.gltfJson;
|
|
687
671
|
const accessor = gltf.accessors[accessorId];
|
|
688
672
|
const bufferViewId = accessor.bufferView;
|
|
689
673
|
|
|
@@ -706,7 +690,6 @@ function getVertexBufferLoader(
|
|
|
706
690
|
|
|
707
691
|
function getIndexBufferLoader(
|
|
708
692
|
loader,
|
|
709
|
-
gltf,
|
|
710
693
|
accessorId,
|
|
711
694
|
draco,
|
|
712
695
|
loadBuffer,
|
|
@@ -714,7 +697,7 @@ function getIndexBufferLoader(
|
|
|
714
697
|
frameState
|
|
715
698
|
) {
|
|
716
699
|
const indexBufferLoader = ResourceCache.getIndexBufferLoader({
|
|
717
|
-
gltf:
|
|
700
|
+
gltf: loader.gltfJson,
|
|
718
701
|
accessorId: accessorId,
|
|
719
702
|
gltfResource: loader._gltfResource,
|
|
720
703
|
baseResource: loader._baseResource,
|
|
@@ -728,9 +711,9 @@ function getIndexBufferLoader(
|
|
|
728
711
|
return indexBufferLoader;
|
|
729
712
|
}
|
|
730
713
|
|
|
731
|
-
function getBufferViewLoader(loader,
|
|
714
|
+
function getBufferViewLoader(loader, bufferViewId) {
|
|
732
715
|
const bufferViewLoader = ResourceCache.getBufferViewLoader({
|
|
733
|
-
gltf:
|
|
716
|
+
gltf: loader.gltfJson,
|
|
734
717
|
bufferViewId: bufferViewId,
|
|
735
718
|
gltfResource: loader._gltfResource,
|
|
736
719
|
baseResource: loader._baseResource,
|
|
@@ -828,35 +811,37 @@ function loadAccessorValues(accessor, typedArray, values, useQuaternion) {
|
|
|
828
811
|
async function loadAccessorBufferView(
|
|
829
812
|
loader,
|
|
830
813
|
bufferViewLoader,
|
|
831
|
-
gltf,
|
|
832
814
|
accessor,
|
|
833
815
|
useQuaternion,
|
|
834
816
|
values
|
|
835
817
|
) {
|
|
818
|
+
// Save a link to the gltfJson, which is removed after bufferViewLoader.load()
|
|
819
|
+
const { gltfJson } = loader;
|
|
820
|
+
|
|
836
821
|
await bufferViewLoader.load();
|
|
837
822
|
if (loader.isDestroyed()) {
|
|
838
823
|
return;
|
|
839
824
|
}
|
|
840
825
|
|
|
841
|
-
const
|
|
842
|
-
|
|
826
|
+
const typedArray = getPackedTypedArray(
|
|
827
|
+
gltfJson,
|
|
828
|
+
accessor,
|
|
829
|
+
bufferViewLoader.typedArray
|
|
830
|
+
);
|
|
843
831
|
|
|
844
832
|
useQuaternion = defaultValue(useQuaternion, false);
|
|
845
833
|
loadAccessorValues(accessor, typedArray, values, useQuaternion);
|
|
846
834
|
}
|
|
847
835
|
|
|
848
|
-
function loadAccessor(loader,
|
|
849
|
-
const
|
|
850
|
-
const accessorCount = accessor.count;
|
|
851
|
-
const values = new Array(accessorCount);
|
|
836
|
+
function loadAccessor(loader, accessor, useQuaternion) {
|
|
837
|
+
const values = new Array(accessor.count);
|
|
852
838
|
|
|
853
839
|
const bufferViewId = accessor.bufferView;
|
|
854
840
|
if (defined(bufferViewId)) {
|
|
855
|
-
const bufferViewLoader = getBufferViewLoader(loader,
|
|
841
|
+
const bufferViewLoader = getBufferViewLoader(loader, bufferViewId);
|
|
856
842
|
const promise = loadAccessorBufferView(
|
|
857
843
|
loader,
|
|
858
844
|
bufferViewLoader,
|
|
859
|
-
gltf,
|
|
860
845
|
accessor,
|
|
861
846
|
useQuaternion,
|
|
862
847
|
values
|
|
@@ -1145,7 +1130,6 @@ function finalizeAttribute(
|
|
|
1145
1130
|
|
|
1146
1131
|
function loadAttribute(
|
|
1147
1132
|
loader,
|
|
1148
|
-
gltf,
|
|
1149
1133
|
accessorId,
|
|
1150
1134
|
semanticInfo,
|
|
1151
1135
|
draco,
|
|
@@ -1153,6 +1137,7 @@ function loadAttribute(
|
|
|
1153
1137
|
loadTypedArray,
|
|
1154
1138
|
frameState
|
|
1155
1139
|
) {
|
|
1140
|
+
const gltf = loader.gltfJson;
|
|
1156
1141
|
const accessor = gltf.accessors[accessorId];
|
|
1157
1142
|
const bufferViewId = accessor.bufferView;
|
|
1158
1143
|
|
|
@@ -1179,7 +1164,6 @@ function loadAttribute(
|
|
|
1179
1164
|
|
|
1180
1165
|
const vertexBufferLoader = getVertexBufferLoader(
|
|
1181
1166
|
loader,
|
|
1182
|
-
gltf,
|
|
1183
1167
|
accessorId,
|
|
1184
1168
|
gltfSemantic,
|
|
1185
1169
|
draco,
|
|
@@ -1224,7 +1208,6 @@ function loadAttribute(
|
|
|
1224
1208
|
|
|
1225
1209
|
function loadVertexAttribute(
|
|
1226
1210
|
loader,
|
|
1227
|
-
gltf,
|
|
1228
1211
|
accessorId,
|
|
1229
1212
|
semanticInfo,
|
|
1230
1213
|
draco,
|
|
@@ -1271,7 +1254,6 @@ function loadVertexAttribute(
|
|
|
1271
1254
|
|
|
1272
1255
|
const attribute = loadAttribute(
|
|
1273
1256
|
loader,
|
|
1274
|
-
gltf,
|
|
1275
1257
|
accessorId,
|
|
1276
1258
|
semanticInfo,
|
|
1277
1259
|
draco,
|
|
@@ -1289,17 +1271,17 @@ function loadVertexAttribute(
|
|
|
1289
1271
|
|
|
1290
1272
|
function loadInstancedAttribute(
|
|
1291
1273
|
loader,
|
|
1292
|
-
gltf,
|
|
1293
1274
|
accessorId,
|
|
1294
1275
|
attributes,
|
|
1295
1276
|
gltfSemantic,
|
|
1296
1277
|
frameState
|
|
1297
1278
|
) {
|
|
1279
|
+
const accessors = loader.gltfJson.accessors;
|
|
1298
1280
|
const hasRotation = defined(attributes.ROTATION);
|
|
1299
1281
|
const hasTranslationMinMax =
|
|
1300
1282
|
defined(attributes.TRANSLATION) &&
|
|
1301
|
-
defined(
|
|
1302
|
-
defined(
|
|
1283
|
+
defined(accessors[attributes.TRANSLATION].min) &&
|
|
1284
|
+
defined(accessors[attributes.TRANSLATION].max);
|
|
1303
1285
|
|
|
1304
1286
|
const semanticInfo = getSemanticInfo(
|
|
1305
1287
|
loader,
|
|
@@ -1344,7 +1326,6 @@ function loadInstancedAttribute(
|
|
|
1344
1326
|
// Don't pass in draco object since instanced attributes can't be draco compressed
|
|
1345
1327
|
return loadAttribute(
|
|
1346
1328
|
loader,
|
|
1347
|
-
gltf,
|
|
1348
1329
|
accessorId,
|
|
1349
1330
|
semanticInfo,
|
|
1350
1331
|
undefined,
|
|
@@ -1356,14 +1337,13 @@ function loadInstancedAttribute(
|
|
|
1356
1337
|
|
|
1357
1338
|
function loadIndices(
|
|
1358
1339
|
loader,
|
|
1359
|
-
gltf,
|
|
1360
1340
|
accessorId,
|
|
1361
1341
|
draco,
|
|
1362
1342
|
hasFeatureIds,
|
|
1363
1343
|
needsPostProcessing,
|
|
1364
1344
|
frameState
|
|
1365
1345
|
) {
|
|
1366
|
-
const accessor =
|
|
1346
|
+
const accessor = loader.gltfJson.accessors[accessorId];
|
|
1367
1347
|
const bufferViewId = accessor.bufferView;
|
|
1368
1348
|
|
|
1369
1349
|
if (!defined(draco) && !defined(bufferViewId)) {
|
|
@@ -1400,7 +1380,6 @@ function loadIndices(
|
|
|
1400
1380
|
|
|
1401
1381
|
const indexBufferLoader = getIndexBufferLoader(
|
|
1402
1382
|
loader,
|
|
1403
|
-
gltf,
|
|
1404
1383
|
accessorId,
|
|
1405
1384
|
draco,
|
|
1406
1385
|
loadBuffer,
|
|
@@ -1428,18 +1407,12 @@ function loadIndices(
|
|
|
1428
1407
|
return indicesPlan;
|
|
1429
1408
|
}
|
|
1430
1409
|
|
|
1431
|
-
function loadTexture(
|
|
1432
|
-
loader
|
|
1433
|
-
gltf,
|
|
1434
|
-
textureInfo,
|
|
1435
|
-
supportedImageFormats,
|
|
1436
|
-
frameState,
|
|
1437
|
-
samplerOverride
|
|
1438
|
-
) {
|
|
1410
|
+
function loadTexture(loader, textureInfo, frameState, samplerOverride) {
|
|
1411
|
+
const gltf = loader.gltfJson;
|
|
1439
1412
|
const imageId = GltfLoaderUtil.getImageIdFromTexture({
|
|
1440
1413
|
gltf: gltf,
|
|
1441
1414
|
textureId: textureInfo.index,
|
|
1442
|
-
supportedImageFormats:
|
|
1415
|
+
supportedImageFormats: loader._supportedImageFormats,
|
|
1443
1416
|
});
|
|
1444
1417
|
|
|
1445
1418
|
if (!defined(imageId)) {
|
|
@@ -1451,7 +1424,7 @@ function loadTexture(
|
|
|
1451
1424
|
textureInfo: textureInfo,
|
|
1452
1425
|
gltfResource: loader._gltfResource,
|
|
1453
1426
|
baseResource: loader._baseResource,
|
|
1454
|
-
supportedImageFormats:
|
|
1427
|
+
supportedImageFormats: loader._supportedImageFormats,
|
|
1455
1428
|
frameState: frameState,
|
|
1456
1429
|
asynchronous: loader._asynchronous,
|
|
1457
1430
|
});
|
|
@@ -1491,13 +1464,177 @@ function loadTexture(
|
|
|
1491
1464
|
return textureReader;
|
|
1492
1465
|
}
|
|
1493
1466
|
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1467
|
+
/**
|
|
1468
|
+
* Load textures and parse factors for the KHR_materials_pbrSpecularGlossiness extension
|
|
1469
|
+
* @param {GltfLoader} loader
|
|
1470
|
+
* @param {object} specularGlossinessInfo The contents of the KHR_materials_pbrSpecularGlossiness extension in the parsed glTF JSON
|
|
1471
|
+
* @param {FrameState} frameState
|
|
1472
|
+
* @returns {ModelComponents.SpecularGlossiness}
|
|
1473
|
+
* @private
|
|
1474
|
+
*/
|
|
1475
|
+
function loadSpecularGlossiness(loader, specularGlossinessInfo, frameState) {
|
|
1476
|
+
const {
|
|
1477
|
+
diffuseTexture,
|
|
1478
|
+
specularGlossinessTexture,
|
|
1479
|
+
diffuseFactor,
|
|
1480
|
+
specularFactor,
|
|
1481
|
+
glossinessFactor,
|
|
1482
|
+
} = specularGlossinessInfo;
|
|
1483
|
+
|
|
1484
|
+
const specularGlossiness = new SpecularGlossiness();
|
|
1485
|
+
if (defined(diffuseTexture)) {
|
|
1486
|
+
specularGlossiness.diffuseTexture = loadTexture(
|
|
1487
|
+
loader,
|
|
1488
|
+
diffuseTexture,
|
|
1489
|
+
frameState
|
|
1490
|
+
);
|
|
1491
|
+
}
|
|
1492
|
+
if (defined(specularGlossinessTexture)) {
|
|
1493
|
+
specularGlossiness.specularGlossinessTexture = loadTexture(
|
|
1494
|
+
loader,
|
|
1495
|
+
specularGlossinessTexture,
|
|
1496
|
+
frameState
|
|
1497
|
+
);
|
|
1498
|
+
}
|
|
1499
|
+
specularGlossiness.diffuseFactor = fromArray(Cartesian4, diffuseFactor);
|
|
1500
|
+
specularGlossiness.specularFactor = fromArray(Cartesian3, specularFactor);
|
|
1501
|
+
specularGlossiness.glossinessFactor = glossinessFactor;
|
|
1502
|
+
|
|
1503
|
+
return specularGlossiness;
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
/**
|
|
1507
|
+
* Load textures and parse factors for a metallic-roughness PBR model in a glTF material
|
|
1508
|
+
* @param {GltfLoader} loader
|
|
1509
|
+
* @param {object} metallicRoughnessInfo The contents of a pbrMetallicRoughness property in the parsed glTF JSON
|
|
1510
|
+
* @param {FrameState} frameState
|
|
1511
|
+
* @returns {ModelComponents.MetallicRoughness}
|
|
1512
|
+
* @private
|
|
1513
|
+
*/
|
|
1514
|
+
function loadMetallicRoughness(loader, metallicRoughnessInfo, frameState) {
|
|
1515
|
+
const {
|
|
1516
|
+
baseColorTexture,
|
|
1517
|
+
metallicRoughnessTexture,
|
|
1518
|
+
baseColorFactor,
|
|
1519
|
+
metallicFactor,
|
|
1520
|
+
roughnessFactor,
|
|
1521
|
+
} = metallicRoughnessInfo;
|
|
1522
|
+
|
|
1523
|
+
const metallicRoughness = new MetallicRoughness();
|
|
1524
|
+
if (defined(baseColorTexture)) {
|
|
1525
|
+
metallicRoughness.baseColorTexture = loadTexture(
|
|
1526
|
+
loader,
|
|
1527
|
+
baseColorTexture,
|
|
1528
|
+
frameState
|
|
1529
|
+
);
|
|
1530
|
+
}
|
|
1531
|
+
if (defined(metallicRoughnessTexture)) {
|
|
1532
|
+
metallicRoughness.metallicRoughnessTexture = loadTexture(
|
|
1533
|
+
loader,
|
|
1534
|
+
metallicRoughnessTexture,
|
|
1535
|
+
frameState
|
|
1536
|
+
);
|
|
1537
|
+
}
|
|
1538
|
+
metallicRoughness.baseColorFactor = fromArray(Cartesian4, baseColorFactor);
|
|
1539
|
+
metallicRoughness.metallicFactor = metallicFactor;
|
|
1540
|
+
metallicRoughness.roughnessFactor = roughnessFactor;
|
|
1541
|
+
|
|
1542
|
+
return metallicRoughness;
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
function loadSpecular(loader, specularInfo, frameState) {
|
|
1546
|
+
const {
|
|
1547
|
+
specularFactor,
|
|
1548
|
+
specularTexture,
|
|
1549
|
+
specularColorFactor,
|
|
1550
|
+
specularColorTexture,
|
|
1551
|
+
} = specularInfo;
|
|
1552
|
+
|
|
1553
|
+
const specular = new Specular();
|
|
1554
|
+
if (defined(specularTexture)) {
|
|
1555
|
+
specular.specularTexture = loadTexture(loader, specularTexture, frameState);
|
|
1556
|
+
}
|
|
1557
|
+
if (defined(specularColorTexture)) {
|
|
1558
|
+
specular.specularColorTexture = loadTexture(
|
|
1559
|
+
loader,
|
|
1560
|
+
specularColorTexture,
|
|
1561
|
+
frameState
|
|
1562
|
+
);
|
|
1563
|
+
}
|
|
1564
|
+
specular.specularFactor = specularFactor;
|
|
1565
|
+
specular.specularColorFactor = fromArray(Cartesian3, specularColorFactor);
|
|
1566
|
+
|
|
1567
|
+
return specular;
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
function loadAnisotropy(loader, anisotropyInfo, frameState) {
|
|
1571
|
+
const {
|
|
1572
|
+
anisotropyStrength = Anisotropy.DEFAULT_ANISOTROPY_STRENGTH,
|
|
1573
|
+
anisotropyRotation = Anisotropy.DEFAULT_ANISOTROPY_ROTATION,
|
|
1574
|
+
anisotropyTexture,
|
|
1575
|
+
} = anisotropyInfo;
|
|
1576
|
+
|
|
1577
|
+
const anisotropy = new Anisotropy();
|
|
1578
|
+
if (defined(anisotropyTexture)) {
|
|
1579
|
+
anisotropy.anisotropyTexture = loadTexture(
|
|
1580
|
+
loader,
|
|
1581
|
+
anisotropyTexture,
|
|
1582
|
+
frameState
|
|
1583
|
+
);
|
|
1584
|
+
}
|
|
1585
|
+
anisotropy.anisotropyStrength = anisotropyStrength;
|
|
1586
|
+
anisotropy.anisotropyRotation = anisotropyRotation;
|
|
1587
|
+
|
|
1588
|
+
return anisotropy;
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
function loadClearcoat(loader, clearcoatInfo, frameState) {
|
|
1592
|
+
const {
|
|
1593
|
+
clearcoatFactor = Clearcoat.DEFAULT_CLEARCOAT_FACTOR,
|
|
1594
|
+
clearcoatTexture,
|
|
1595
|
+
clearcoatRoughnessFactor = Clearcoat.DEFAULT_CLEARCOAT_ROUGHNESS_FACTOR,
|
|
1596
|
+
clearcoatRoughnessTexture,
|
|
1597
|
+
clearcoatNormalTexture,
|
|
1598
|
+
} = clearcoatInfo;
|
|
1599
|
+
|
|
1600
|
+
const clearcoat = new Clearcoat();
|
|
1601
|
+
if (defined(clearcoatTexture)) {
|
|
1602
|
+
clearcoat.clearcoatTexture = loadTexture(
|
|
1603
|
+
loader,
|
|
1604
|
+
clearcoatTexture,
|
|
1605
|
+
frameState
|
|
1606
|
+
);
|
|
1607
|
+
}
|
|
1608
|
+
if (defined(clearcoatRoughnessTexture)) {
|
|
1609
|
+
clearcoat.clearcoatRoughnessTexture = loadTexture(
|
|
1610
|
+
loader,
|
|
1611
|
+
clearcoatRoughnessTexture,
|
|
1612
|
+
frameState
|
|
1613
|
+
);
|
|
1614
|
+
}
|
|
1615
|
+
if (defined(clearcoatNormalTexture)) {
|
|
1616
|
+
clearcoat.clearcoatNormalTexture = loadTexture(
|
|
1617
|
+
loader,
|
|
1618
|
+
clearcoatNormalTexture,
|
|
1619
|
+
frameState
|
|
1620
|
+
);
|
|
1621
|
+
}
|
|
1622
|
+
clearcoat.clearcoatFactor = clearcoatFactor;
|
|
1623
|
+
clearcoat.clearcoatRoughnessFactor = clearcoatRoughnessFactor;
|
|
1624
|
+
|
|
1625
|
+
return clearcoat;
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
/**
|
|
1629
|
+
* Load textures and parse factors and flags for a glTF material
|
|
1630
|
+
*
|
|
1631
|
+
* @param {GltfLoader} loader
|
|
1632
|
+
* @param {object} gltfMaterial An entry from the <code>.materials</code> array in the glTF JSON
|
|
1633
|
+
* @param {FrameState} frameState
|
|
1634
|
+
* @returns {ModelComponents.Material}
|
|
1635
|
+
* @private
|
|
1636
|
+
*/
|
|
1637
|
+
function loadMaterial(loader, gltfMaterial, frameState) {
|
|
1501
1638
|
const material = new Material();
|
|
1502
1639
|
|
|
1503
1640
|
const extensions = defaultValue(
|
|
@@ -1505,82 +1642,43 @@ function loadMaterial(
|
|
|
1505
1642
|
defaultValue.EMPTY_OBJECT
|
|
1506
1643
|
);
|
|
1507
1644
|
const pbrSpecularGlossiness = extensions.KHR_materials_pbrSpecularGlossiness;
|
|
1645
|
+
const pbrSpecular = extensions.KHR_materials_specular;
|
|
1646
|
+
const pbrAnisotropy = extensions.KHR_materials_anisotropy;
|
|
1647
|
+
const pbrClearcoat = extensions.KHR_materials_clearcoat;
|
|
1508
1648
|
const pbrMetallicRoughness = gltfMaterial.pbrMetallicRoughness;
|
|
1509
1649
|
|
|
1510
1650
|
material.unlit = defined(extensions.KHR_materials_unlit);
|
|
1511
1651
|
|
|
1512
1652
|
if (defined(pbrSpecularGlossiness)) {
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1653
|
+
material.specularGlossiness = loadSpecularGlossiness(
|
|
1654
|
+
loader,
|
|
1655
|
+
pbrSpecularGlossiness,
|
|
1656
|
+
frameState
|
|
1657
|
+
);
|
|
1658
|
+
} else {
|
|
1659
|
+
if (defined(pbrMetallicRoughness)) {
|
|
1660
|
+
material.metallicRoughness = loadMetallicRoughness(
|
|
1518
1661
|
loader,
|
|
1519
|
-
|
|
1520
|
-
pbrSpecularGlossiness.diffuseTexture,
|
|
1521
|
-
supportedImageFormats,
|
|
1662
|
+
pbrMetallicRoughness,
|
|
1522
1663
|
frameState
|
|
1523
1664
|
);
|
|
1524
1665
|
}
|
|
1525
|
-
if (defined(
|
|
1526
|
-
|
|
1527
|
-
specularGlossiness.specularGlossinessTexture = loadTexture(
|
|
1528
|
-
loader,
|
|
1529
|
-
gltf,
|
|
1530
|
-
pbrSpecularGlossiness.specularGlossinessTexture,
|
|
1531
|
-
supportedImageFormats,
|
|
1532
|
-
frameState
|
|
1533
|
-
);
|
|
1534
|
-
}
|
|
1666
|
+
if (defined(pbrSpecular) && !material.unlit) {
|
|
1667
|
+
material.specular = loadSpecular(loader, pbrSpecular, frameState);
|
|
1535
1668
|
}
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
pbrSpecularGlossiness.diffuseFactor
|
|
1539
|
-
);
|
|
1540
|
-
specularGlossiness.specularFactor = fromArray(
|
|
1541
|
-
Cartesian3,
|
|
1542
|
-
pbrSpecularGlossiness.specularFactor
|
|
1543
|
-
);
|
|
1544
|
-
specularGlossiness.glossinessFactor =
|
|
1545
|
-
pbrSpecularGlossiness.glossinessFactor;
|
|
1546
|
-
material.pbrSpecularGlossiness = pbrSpecularGlossiness;
|
|
1547
|
-
} else if (defined(pbrMetallicRoughness)) {
|
|
1548
|
-
const metallicRoughness = new MetallicRoughness();
|
|
1549
|
-
|
|
1550
|
-
if (defined(pbrMetallicRoughness.baseColorTexture)) {
|
|
1551
|
-
metallicRoughness.baseColorTexture = loadTexture(
|
|
1552
|
-
loader,
|
|
1553
|
-
gltf,
|
|
1554
|
-
pbrMetallicRoughness.baseColorTexture,
|
|
1555
|
-
supportedImageFormats,
|
|
1556
|
-
frameState
|
|
1557
|
-
);
|
|
1669
|
+
if (defined(pbrAnisotropy) && !material.unlit) {
|
|
1670
|
+
material.anisotropy = loadAnisotropy(loader, pbrAnisotropy, frameState);
|
|
1558
1671
|
}
|
|
1559
|
-
if (defined(
|
|
1560
|
-
|
|
1561
|
-
loader,
|
|
1562
|
-
gltf,
|
|
1563
|
-
pbrMetallicRoughness.metallicRoughnessTexture,
|
|
1564
|
-
supportedImageFormats,
|
|
1565
|
-
frameState
|
|
1566
|
-
);
|
|
1672
|
+
if (defined(pbrClearcoat) && !material.unlit) {
|
|
1673
|
+
material.clearcoat = loadClearcoat(loader, pbrClearcoat, frameState);
|
|
1567
1674
|
}
|
|
1568
|
-
metallicRoughness.baseColorFactor = fromArray(
|
|
1569
|
-
Cartesian4,
|
|
1570
|
-
pbrMetallicRoughness.baseColorFactor
|
|
1571
|
-
);
|
|
1572
|
-
metallicRoughness.metallicFactor = pbrMetallicRoughness.metallicFactor;
|
|
1573
|
-
metallicRoughness.roughnessFactor = pbrMetallicRoughness.roughnessFactor;
|
|
1574
|
-
material.metallicRoughness = metallicRoughness;
|
|
1575
1675
|
}
|
|
1576
1676
|
|
|
1577
1677
|
// Top level textures
|
|
1578
1678
|
if (defined(gltfMaterial.emissiveTexture)) {
|
|
1579
1679
|
material.emissiveTexture = loadTexture(
|
|
1580
1680
|
loader,
|
|
1581
|
-
gltf,
|
|
1582
1681
|
gltfMaterial.emissiveTexture,
|
|
1583
|
-
supportedImageFormats,
|
|
1584
1682
|
frameState
|
|
1585
1683
|
);
|
|
1586
1684
|
}
|
|
@@ -1588,18 +1686,14 @@ function loadMaterial(
|
|
|
1588
1686
|
if (defined(gltfMaterial.normalTexture) && !loader._loadForClassification) {
|
|
1589
1687
|
material.normalTexture = loadTexture(
|
|
1590
1688
|
loader,
|
|
1591
|
-
gltf,
|
|
1592
1689
|
gltfMaterial.normalTexture,
|
|
1593
|
-
supportedImageFormats,
|
|
1594
1690
|
frameState
|
|
1595
1691
|
);
|
|
1596
1692
|
}
|
|
1597
1693
|
if (defined(gltfMaterial.occlusionTexture)) {
|
|
1598
1694
|
material.occlusionTexture = loadTexture(
|
|
1599
1695
|
loader,
|
|
1600
|
-
gltf,
|
|
1601
1696
|
gltfMaterial.occlusionTexture,
|
|
1602
|
-
supportedImageFormats,
|
|
1603
1697
|
frameState
|
|
1604
1698
|
);
|
|
1605
1699
|
}
|
|
@@ -1679,9 +1773,7 @@ function loadFeatureIdImplicitRangeLegacy(
|
|
|
1679
1773
|
// for EXT_mesh_features
|
|
1680
1774
|
function loadFeatureIdTexture(
|
|
1681
1775
|
loader,
|
|
1682
|
-
gltf,
|
|
1683
1776
|
gltfFeatureIdTexture,
|
|
1684
|
-
supportedImageFormats,
|
|
1685
1777
|
frameState,
|
|
1686
1778
|
positionalLabel
|
|
1687
1779
|
) {
|
|
@@ -1696,9 +1788,7 @@ function loadFeatureIdTexture(
|
|
|
1696
1788
|
const textureInfo = gltfFeatureIdTexture.texture;
|
|
1697
1789
|
featureIdTexture.textureReader = loadTexture(
|
|
1698
1790
|
loader,
|
|
1699
|
-
gltf,
|
|
1700
1791
|
textureInfo,
|
|
1701
|
-
supportedImageFormats,
|
|
1702
1792
|
frameState,
|
|
1703
1793
|
Sampler.NEAREST // Feature ID textures require nearest sampling
|
|
1704
1794
|
);
|
|
@@ -1720,10 +1810,8 @@ function loadFeatureIdTexture(
|
|
|
1720
1810
|
// for backwards compatibility with EXT_feature_metadata
|
|
1721
1811
|
function loadFeatureIdTextureLegacy(
|
|
1722
1812
|
loader,
|
|
1723
|
-
gltf,
|
|
1724
1813
|
gltfFeatureIdTexture,
|
|
1725
1814
|
featureTableId,
|
|
1726
|
-
supportedImageFormats,
|
|
1727
1815
|
frameState,
|
|
1728
1816
|
featureCount,
|
|
1729
1817
|
positionalLabel
|
|
@@ -1735,9 +1823,7 @@ function loadFeatureIdTextureLegacy(
|
|
|
1735
1823
|
featureIdTexture.propertyTableId = featureTableId;
|
|
1736
1824
|
featureIdTexture.textureReader = loadTexture(
|
|
1737
1825
|
loader,
|
|
1738
|
-
gltf,
|
|
1739
1826
|
textureInfo,
|
|
1740
|
-
supportedImageFormats,
|
|
1741
1827
|
frameState,
|
|
1742
1828
|
Sampler.NEAREST // Feature ID textures require nearest sampling
|
|
1743
1829
|
);
|
|
@@ -1750,7 +1836,6 @@ function loadFeatureIdTextureLegacy(
|
|
|
1750
1836
|
|
|
1751
1837
|
function loadMorphTarget(
|
|
1752
1838
|
loader,
|
|
1753
|
-
gltf,
|
|
1754
1839
|
target,
|
|
1755
1840
|
needsPostProcessing,
|
|
1756
1841
|
primitiveLoadPlan,
|
|
@@ -1763,44 +1848,46 @@ function loadMorphTarget(
|
|
|
1763
1848
|
const hasInstances = false;
|
|
1764
1849
|
|
|
1765
1850
|
for (const semantic in target) {
|
|
1766
|
-
if (target.hasOwnProperty(semantic)) {
|
|
1767
|
-
|
|
1851
|
+
if (!target.hasOwnProperty(semantic)) {
|
|
1852
|
+
continue;
|
|
1853
|
+
}
|
|
1854
|
+
const accessorId = target[semantic];
|
|
1768
1855
|
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1856
|
+
const semanticInfo = getSemanticInfo(
|
|
1857
|
+
loader,
|
|
1858
|
+
VertexAttributeSemantic,
|
|
1859
|
+
semantic
|
|
1860
|
+
);
|
|
1774
1861
|
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
morphTarget.attributes.push(attributePlan.attribute);
|
|
1862
|
+
const attributePlan = loadVertexAttribute(
|
|
1863
|
+
loader,
|
|
1864
|
+
accessorId,
|
|
1865
|
+
semanticInfo,
|
|
1866
|
+
draco,
|
|
1867
|
+
hasInstances,
|
|
1868
|
+
needsPostProcessing,
|
|
1869
|
+
frameState
|
|
1870
|
+
);
|
|
1871
|
+
morphTarget.attributes.push(attributePlan.attribute);
|
|
1786
1872
|
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
}
|
|
1873
|
+
// The load plan doesn't need to distinguish morph target attributes from
|
|
1874
|
+
// regular attributes
|
|
1875
|
+
primitiveLoadPlan.attributePlans.push(attributePlan);
|
|
1791
1876
|
}
|
|
1792
1877
|
|
|
1793
1878
|
return morphTarget;
|
|
1794
1879
|
}
|
|
1795
1880
|
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1881
|
+
/**
|
|
1882
|
+
* Load resources associated with a mesh primitive for a glTF node
|
|
1883
|
+
* @param {GltfLoader} loader
|
|
1884
|
+
* @param {object} gltfPrimitive One of the primitives in a mesh
|
|
1885
|
+
* @param {boolean} hasInstances True if the node using this mesh has instances
|
|
1886
|
+
* @param {FrameState} frameState
|
|
1887
|
+
* @returns {ModelComponents.Primitive}
|
|
1888
|
+
* @private
|
|
1889
|
+
*/
|
|
1890
|
+
function loadPrimitive(loader, gltfPrimitive, hasInstances, frameState) {
|
|
1804
1891
|
const primitive = new Primitive();
|
|
1805
1892
|
const primitivePlan = new PrimitiveLoadPlan(primitive);
|
|
1806
1893
|
loader._primitiveLoadPlans.push(primitivePlan);
|
|
@@ -1809,9 +1896,7 @@ function loadPrimitive(
|
|
|
1809
1896
|
if (defined(materialId)) {
|
|
1810
1897
|
primitive.material = loadMaterial(
|
|
1811
1898
|
loader,
|
|
1812
|
-
|
|
1813
|
-
gltf.materials[materialId],
|
|
1814
|
-
supportedImageFormats,
|
|
1899
|
+
loader.gltfJson.materials[materialId],
|
|
1815
1900
|
frameState
|
|
1816
1901
|
);
|
|
1817
1902
|
}
|
|
@@ -1828,7 +1913,6 @@ function loadPrimitive(
|
|
|
1828
1913
|
primitivePlan.needsOutlines = true;
|
|
1829
1914
|
primitivePlan.outlineIndices = loadPrimitiveOutline(
|
|
1830
1915
|
loader,
|
|
1831
|
-
gltf,
|
|
1832
1916
|
outlineExtension,
|
|
1833
1917
|
primitivePlan
|
|
1834
1918
|
);
|
|
@@ -1841,52 +1925,47 @@ function loadPrimitive(
|
|
|
1841
1925
|
const attributes = gltfPrimitive.attributes;
|
|
1842
1926
|
if (defined(attributes)) {
|
|
1843
1927
|
for (const semantic in attributes) {
|
|
1844
|
-
if (attributes.hasOwnProperty(semantic)) {
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1928
|
+
if (!attributes.hasOwnProperty(semantic)) {
|
|
1929
|
+
continue;
|
|
1930
|
+
}
|
|
1931
|
+
const accessorId = attributes[semantic];
|
|
1932
|
+
const semanticInfo = getSemanticInfo(
|
|
1933
|
+
loader,
|
|
1934
|
+
VertexAttributeSemantic,
|
|
1935
|
+
semantic
|
|
1936
|
+
);
|
|
1851
1937
|
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
) {
|
|
1857
|
-
continue;
|
|
1858
|
-
}
|
|
1938
|
+
const modelSemantic = semanticInfo.modelSemantic;
|
|
1939
|
+
if (loadForClassification && !isClassificationAttribute(modelSemantic)) {
|
|
1940
|
+
continue;
|
|
1941
|
+
}
|
|
1859
1942
|
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1943
|
+
if (modelSemantic === VertexAttributeSemantic.FEATURE_ID) {
|
|
1944
|
+
hasFeatureIds = true;
|
|
1945
|
+
}
|
|
1863
1946
|
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
);
|
|
1947
|
+
const attributePlan = loadVertexAttribute(
|
|
1948
|
+
loader,
|
|
1949
|
+
accessorId,
|
|
1950
|
+
semanticInfo,
|
|
1951
|
+
draco,
|
|
1952
|
+
hasInstances,
|
|
1953
|
+
needsPostProcessing,
|
|
1954
|
+
frameState
|
|
1955
|
+
);
|
|
1874
1956
|
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
}
|
|
1957
|
+
primitivePlan.attributePlans.push(attributePlan);
|
|
1958
|
+
primitive.attributes.push(attributePlan.attribute);
|
|
1878
1959
|
}
|
|
1879
1960
|
}
|
|
1880
1961
|
|
|
1881
1962
|
const targets = gltfPrimitive.targets;
|
|
1882
1963
|
// Morph targets are disabled for classification models.
|
|
1883
1964
|
if (defined(targets) && !loadForClassification) {
|
|
1884
|
-
|
|
1885
|
-
for (let i = 0; i < targetsLength; ++i) {
|
|
1965
|
+
for (let i = 0; i < targets.length; ++i) {
|
|
1886
1966
|
primitive.morphTargets.push(
|
|
1887
1967
|
loadMorphTarget(
|
|
1888
1968
|
loader,
|
|
1889
|
-
gltf,
|
|
1890
1969
|
targets[i],
|
|
1891
1970
|
needsPostProcessing,
|
|
1892
1971
|
primitivePlan,
|
|
@@ -1900,7 +1979,6 @@ function loadPrimitive(
|
|
|
1900
1979
|
if (defined(indices)) {
|
|
1901
1980
|
const indicesPlan = loadIndices(
|
|
1902
1981
|
loader,
|
|
1903
|
-
gltf,
|
|
1904
1982
|
indices,
|
|
1905
1983
|
draco,
|
|
1906
1984
|
hasFeatureIds,
|
|
@@ -1925,21 +2003,12 @@ function loadPrimitive(
|
|
|
1925
2003
|
|
|
1926
2004
|
// Load feature Ids
|
|
1927
2005
|
if (defined(meshFeatures)) {
|
|
1928
|
-
loadPrimitiveFeatures(
|
|
1929
|
-
loader,
|
|
1930
|
-
gltf,
|
|
1931
|
-
primitive,
|
|
1932
|
-
meshFeatures,
|
|
1933
|
-
supportedImageFormats,
|
|
1934
|
-
frameState
|
|
1935
|
-
);
|
|
2006
|
+
loadPrimitiveFeatures(loader, primitive, meshFeatures, frameState);
|
|
1936
2007
|
} else if (hasFeatureMetadataLegacy) {
|
|
1937
2008
|
loadPrimitiveFeaturesLegacy(
|
|
1938
2009
|
loader,
|
|
1939
|
-
gltf,
|
|
1940
2010
|
primitive,
|
|
1941
2011
|
featureMetadataLegacy,
|
|
1942
|
-
supportedImageFormats,
|
|
1943
2012
|
frameState
|
|
1944
2013
|
);
|
|
1945
2014
|
}
|
|
@@ -1962,19 +2031,18 @@ function loadPrimitive(
|
|
|
1962
2031
|
return primitive;
|
|
1963
2032
|
}
|
|
1964
2033
|
|
|
1965
|
-
function loadPrimitiveOutline(loader,
|
|
2034
|
+
function loadPrimitiveOutline(loader, outlineExtension) {
|
|
1966
2035
|
const accessorId = outlineExtension.indices;
|
|
2036
|
+
const accessor = loader.gltfJson.accessors[accessorId];
|
|
1967
2037
|
const useQuaternion = false;
|
|
1968
|
-
return loadAccessor(loader,
|
|
2038
|
+
return loadAccessor(loader, accessor, useQuaternion);
|
|
1969
2039
|
}
|
|
1970
2040
|
|
|
1971
2041
|
// For EXT_mesh_features
|
|
1972
2042
|
function loadPrimitiveFeatures(
|
|
1973
2043
|
loader,
|
|
1974
|
-
gltf,
|
|
1975
2044
|
primitive,
|
|
1976
2045
|
meshFeaturesExtension,
|
|
1977
|
-
supportedImageFormats,
|
|
1978
2046
|
frameState
|
|
1979
2047
|
) {
|
|
1980
2048
|
let featureIdsArray;
|
|
@@ -1995,9 +2063,7 @@ function loadPrimitiveFeatures(
|
|
|
1995
2063
|
if (defined(featureIds.texture)) {
|
|
1996
2064
|
featureIdComponent = loadFeatureIdTexture(
|
|
1997
2065
|
loader,
|
|
1998
|
-
gltf,
|
|
1999
2066
|
featureIds,
|
|
2000
|
-
supportedImageFormats,
|
|
2001
2067
|
frameState,
|
|
2002
2068
|
label
|
|
2003
2069
|
);
|
|
@@ -2016,22 +2082,19 @@ function loadPrimitiveFeatures(
|
|
|
2016
2082
|
// For EXT_feature_metadata
|
|
2017
2083
|
function loadPrimitiveFeaturesLegacy(
|
|
2018
2084
|
loader,
|
|
2019
|
-
gltf,
|
|
2020
2085
|
primitive,
|
|
2021
2086
|
metadataExtension,
|
|
2022
|
-
supportedImageFormats,
|
|
2023
2087
|
frameState
|
|
2024
2088
|
) {
|
|
2025
2089
|
// For looking up the featureCount for each set of feature IDs
|
|
2026
|
-
const featureTables =
|
|
2090
|
+
const { featureTables } = loader.gltfJson.extensions.EXT_feature_metadata;
|
|
2027
2091
|
|
|
2028
2092
|
let nextFeatureIdIndex = 0;
|
|
2029
2093
|
|
|
2030
2094
|
// Feature ID Attributes
|
|
2031
2095
|
const featureIdAttributes = metadataExtension.featureIdAttributes;
|
|
2032
2096
|
if (defined(featureIdAttributes)) {
|
|
2033
|
-
|
|
2034
|
-
for (let i = 0; i < featureIdAttributesLength; ++i) {
|
|
2097
|
+
for (let i = 0; i < featureIdAttributes.length; ++i) {
|
|
2035
2098
|
const featureIdAttribute = featureIdAttributes[i];
|
|
2036
2099
|
const featureTableId = featureIdAttribute.featureTable;
|
|
2037
2100
|
const propertyTableId = loader._sortedPropertyTableIds.indexOf(
|
|
@@ -2064,8 +2127,7 @@ function loadPrimitiveFeaturesLegacy(
|
|
|
2064
2127
|
// Feature ID Textures
|
|
2065
2128
|
const featureIdTextures = metadataExtension.featureIdTextures;
|
|
2066
2129
|
if (defined(featureIdTextures)) {
|
|
2067
|
-
|
|
2068
|
-
for (let i = 0; i < featureIdTexturesLength; ++i) {
|
|
2130
|
+
for (let i = 0; i < featureIdTextures.length; ++i) {
|
|
2069
2131
|
const featureIdTexture = featureIdTextures[i];
|
|
2070
2132
|
const featureTableId = featureIdTexture.featureTable;
|
|
2071
2133
|
const propertyTableId = loader._sortedPropertyTableIds.indexOf(
|
|
@@ -2077,10 +2139,8 @@ function loadPrimitiveFeaturesLegacy(
|
|
|
2077
2139
|
|
|
2078
2140
|
const featureIdComponent = loadFeatureIdTextureLegacy(
|
|
2079
2141
|
loader,
|
|
2080
|
-
gltf,
|
|
2081
2142
|
featureIdTexture,
|
|
2082
2143
|
propertyTableId,
|
|
2083
|
-
supportedImageFormats,
|
|
2084
2144
|
frameState,
|
|
2085
2145
|
featureCount,
|
|
2086
2146
|
featureIdLabel
|
|
@@ -2124,26 +2184,26 @@ function loadPrimitiveMetadataLegacy(loader, primitive, metadataExtension) {
|
|
|
2124
2184
|
}
|
|
2125
2185
|
}
|
|
2126
2186
|
|
|
2127
|
-
function loadInstances(loader,
|
|
2187
|
+
function loadInstances(loader, nodeExtensions, frameState) {
|
|
2128
2188
|
const instancingExtension = nodeExtensions.EXT_mesh_gpu_instancing;
|
|
2129
2189
|
|
|
2130
2190
|
const instances = new Instances();
|
|
2131
2191
|
const attributes = instancingExtension.attributes;
|
|
2132
2192
|
if (defined(attributes)) {
|
|
2133
2193
|
for (const semantic in attributes) {
|
|
2134
|
-
if (attributes.hasOwnProperty(semantic)) {
|
|
2135
|
-
|
|
2136
|
-
instances.attributes.push(
|
|
2137
|
-
loadInstancedAttribute(
|
|
2138
|
-
loader,
|
|
2139
|
-
gltf,
|
|
2140
|
-
accessorId,
|
|
2141
|
-
attributes,
|
|
2142
|
-
semantic,
|
|
2143
|
-
frameState
|
|
2144
|
-
)
|
|
2145
|
-
);
|
|
2194
|
+
if (!attributes.hasOwnProperty(semantic)) {
|
|
2195
|
+
continue;
|
|
2146
2196
|
}
|
|
2197
|
+
const accessorId = attributes[semantic];
|
|
2198
|
+
instances.attributes.push(
|
|
2199
|
+
loadInstancedAttribute(
|
|
2200
|
+
loader,
|
|
2201
|
+
accessorId,
|
|
2202
|
+
attributes,
|
|
2203
|
+
semantic,
|
|
2204
|
+
frameState
|
|
2205
|
+
)
|
|
2206
|
+
);
|
|
2147
2207
|
}
|
|
2148
2208
|
}
|
|
2149
2209
|
|
|
@@ -2158,7 +2218,7 @@ function loadInstances(loader, gltf, nodeExtensions, frameState) {
|
|
|
2158
2218
|
loadInstanceFeatures(instances, instanceFeatures);
|
|
2159
2219
|
} else if (defined(featureMetadataLegacy)) {
|
|
2160
2220
|
loadInstanceFeaturesLegacy(
|
|
2161
|
-
|
|
2221
|
+
loader.gltfJson,
|
|
2162
2222
|
instances,
|
|
2163
2223
|
featureMetadataLegacy,
|
|
2164
2224
|
loader._sortedPropertyTableIds
|
|
@@ -2202,8 +2262,7 @@ function loadInstanceFeaturesLegacy(
|
|
|
2202
2262
|
|
|
2203
2263
|
const featureIdAttributes = metadataExtension.featureIdAttributes;
|
|
2204
2264
|
if (defined(featureIdAttributes)) {
|
|
2205
|
-
|
|
2206
|
-
for (let i = 0; i < featureIdAttributesLength; ++i) {
|
|
2265
|
+
for (let i = 0; i < featureIdAttributes.length; ++i) {
|
|
2207
2266
|
const featureIdAttribute = featureIdAttributes[i];
|
|
2208
2267
|
const featureTableId = featureIdAttribute.featureTable;
|
|
2209
2268
|
const propertyTableId = sortedPropertyTableIds.indexOf(featureTableId);
|
|
@@ -2231,7 +2290,15 @@ function loadInstanceFeaturesLegacy(
|
|
|
2231
2290
|
}
|
|
2232
2291
|
}
|
|
2233
2292
|
|
|
2234
|
-
|
|
2293
|
+
/**
|
|
2294
|
+
* Load resources associated with one node from a glTF JSON
|
|
2295
|
+
* @param {GltfLoader} loader
|
|
2296
|
+
* @param {object} gltfNode An entry from the <code>.nodes</code> array in the glTF JSON
|
|
2297
|
+
* @param {FrameState} frameState
|
|
2298
|
+
* @returns {ModelComponents.Node}
|
|
2299
|
+
* @private
|
|
2300
|
+
*/
|
|
2301
|
+
function loadNode(loader, gltfNode, frameState) {
|
|
2235
2302
|
const node = new Node();
|
|
2236
2303
|
|
|
2237
2304
|
node.name = gltfNode.name;
|
|
@@ -2254,7 +2321,7 @@ function loadNode(loader, gltf, gltfNode, supportedImageFormats, frameState) {
|
|
|
2254
2321
|
"Models with the EXT_mesh_gpu_instancing extension cannot be used for classification."
|
|
2255
2322
|
);
|
|
2256
2323
|
}
|
|
2257
|
-
node.instances = loadInstances(loader,
|
|
2324
|
+
node.instances = loadInstances(loader, nodeExtensions, frameState);
|
|
2258
2325
|
}
|
|
2259
2326
|
|
|
2260
2327
|
if (defined(articulationsExtension)) {
|
|
@@ -2263,17 +2330,14 @@ function loadNode(loader, gltf, gltfNode, supportedImageFormats, frameState) {
|
|
|
2263
2330
|
|
|
2264
2331
|
const meshId = gltfNode.mesh;
|
|
2265
2332
|
if (defined(meshId)) {
|
|
2266
|
-
const mesh =
|
|
2333
|
+
const mesh = loader.gltfJson.meshes[meshId];
|
|
2267
2334
|
const primitives = mesh.primitives;
|
|
2268
|
-
|
|
2269
|
-
for (let i = 0; i < primitivesLength; ++i) {
|
|
2335
|
+
for (let i = 0; i < primitives.length; ++i) {
|
|
2270
2336
|
node.primitives.push(
|
|
2271
2337
|
loadPrimitive(
|
|
2272
2338
|
loader,
|
|
2273
|
-
gltf,
|
|
2274
2339
|
primitives[i],
|
|
2275
2340
|
defined(node.instances),
|
|
2276
|
-
supportedImageFormats,
|
|
2277
2341
|
frameState
|
|
2278
2342
|
)
|
|
2279
2343
|
);
|
|
@@ -2283,120 +2347,105 @@ function loadNode(loader, gltf, gltfNode, supportedImageFormats, frameState) {
|
|
|
2283
2347
|
// by the mesh. If both are undefined, it will default to an array of zero weights.
|
|
2284
2348
|
const morphWeights = defaultValue(gltfNode.weights, mesh.weights);
|
|
2285
2349
|
const targets = node.primitives[0].morphTargets;
|
|
2286
|
-
const targetsLength = targets.length;
|
|
2287
2350
|
|
|
2288
2351
|
// Since meshes are not stored as separate components, the mesh weights will still
|
|
2289
2352
|
// be stored at the node level.
|
|
2290
2353
|
node.morphWeights = defined(morphWeights)
|
|
2291
2354
|
? morphWeights.slice()
|
|
2292
|
-
: new Array(
|
|
2355
|
+
: new Array(targets.length).fill(0.0);
|
|
2293
2356
|
}
|
|
2294
2357
|
|
|
2295
2358
|
return node;
|
|
2296
2359
|
}
|
|
2297
2360
|
|
|
2298
|
-
|
|
2299
|
-
|
|
2361
|
+
/**
|
|
2362
|
+
* Load resources associated with the nodes in a glTF JSON
|
|
2363
|
+
* @param {GltfLoader} loader
|
|
2364
|
+
* @param {FrameState} frameState
|
|
2365
|
+
* @returns {ModelComponents.Node[]}
|
|
2366
|
+
* @private
|
|
2367
|
+
*/
|
|
2368
|
+
function loadNodes(loader, frameState) {
|
|
2369
|
+
const nodeJsons = loader.gltfJson.nodes;
|
|
2370
|
+
if (!defined(nodeJsons)) {
|
|
2300
2371
|
return [];
|
|
2301
2372
|
}
|
|
2302
2373
|
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
const nodesLength = gltf.nodes.length;
|
|
2307
|
-
const nodes = new Array(nodesLength);
|
|
2308
|
-
for (i = 0; i < nodesLength; ++i) {
|
|
2309
|
-
const node = loadNode(
|
|
2310
|
-
loader,
|
|
2311
|
-
gltf,
|
|
2312
|
-
gltf.nodes[i],
|
|
2313
|
-
supportedImageFormats,
|
|
2314
|
-
frameState
|
|
2315
|
-
);
|
|
2374
|
+
const loadedNodes = nodeJsons.map(function (nodeJson, i) {
|
|
2375
|
+
const node = loadNode(loader, nodeJson, frameState);
|
|
2316
2376
|
node.index = i;
|
|
2317
|
-
|
|
2318
|
-
}
|
|
2377
|
+
return node;
|
|
2378
|
+
});
|
|
2319
2379
|
|
|
2320
|
-
for (i = 0; i <
|
|
2321
|
-
const childrenNodeIds =
|
|
2380
|
+
for (let i = 0; i < loadedNodes.length; ++i) {
|
|
2381
|
+
const childrenNodeIds = nodeJsons[i].children;
|
|
2322
2382
|
if (defined(childrenNodeIds)) {
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
nodes[i].children.push(nodes[childrenNodeIds[j]]);
|
|
2383
|
+
for (let j = 0; j < childrenNodeIds.length; ++j) {
|
|
2384
|
+
loadedNodes[i].children.push(loadedNodes[childrenNodeIds[j]]);
|
|
2326
2385
|
}
|
|
2327
2386
|
}
|
|
2328
2387
|
}
|
|
2329
2388
|
|
|
2330
|
-
return
|
|
2389
|
+
return loadedNodes;
|
|
2331
2390
|
}
|
|
2332
2391
|
|
|
2333
|
-
function loadSkin(loader,
|
|
2392
|
+
function loadSkin(loader, gltfSkin, nodes) {
|
|
2334
2393
|
const skin = new Skin();
|
|
2335
2394
|
|
|
2336
2395
|
const jointIds = gltfSkin.joints;
|
|
2337
|
-
|
|
2338
|
-
const joints = new Array(jointsLength);
|
|
2339
|
-
for (let i = 0; i < jointsLength; ++i) {
|
|
2340
|
-
joints[i] = nodes[jointIds[i]];
|
|
2341
|
-
}
|
|
2342
|
-
skin.joints = joints;
|
|
2396
|
+
skin.joints = jointIds.map((jointId) => nodes[jointId]);
|
|
2343
2397
|
|
|
2344
2398
|
const inverseBindMatricesAccessorId = gltfSkin.inverseBindMatrices;
|
|
2345
2399
|
if (defined(inverseBindMatricesAccessorId)) {
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
gltf,
|
|
2349
|
-
inverseBindMatricesAccessorId
|
|
2350
|
-
);
|
|
2400
|
+
const accessor = loader.gltfJson.accessors[inverseBindMatricesAccessorId];
|
|
2401
|
+
skin.inverseBindMatrices = loadAccessor(loader, accessor);
|
|
2351
2402
|
} else {
|
|
2352
|
-
skin.inverseBindMatrices = new Array(
|
|
2403
|
+
skin.inverseBindMatrices = new Array(jointIds.length).fill(
|
|
2404
|
+
Matrix4.IDENTITY
|
|
2405
|
+
);
|
|
2353
2406
|
}
|
|
2354
2407
|
|
|
2355
2408
|
return skin;
|
|
2356
2409
|
}
|
|
2357
2410
|
|
|
2358
|
-
function loadSkins(loader,
|
|
2359
|
-
const
|
|
2411
|
+
function loadSkins(loader, nodes) {
|
|
2412
|
+
const skinJsons = loader.gltfJson.skins;
|
|
2360
2413
|
|
|
2361
2414
|
// Skins are disabled for classification models.
|
|
2362
|
-
if (loader._loadForClassification || !defined(
|
|
2415
|
+
if (loader._loadForClassification || !defined(skinJsons)) {
|
|
2363
2416
|
return [];
|
|
2364
2417
|
}
|
|
2365
2418
|
|
|
2366
|
-
const
|
|
2367
|
-
|
|
2368
|
-
for (let i = 0; i < skinsLength; ++i) {
|
|
2369
|
-
const skin = loadSkin(loader, gltf, gltf.skins[i], nodes);
|
|
2419
|
+
const loadedSkins = skinJsons.map(function (skinJson, i) {
|
|
2420
|
+
const skin = loadSkin(loader, skinJson, nodes);
|
|
2370
2421
|
skin.index = i;
|
|
2371
|
-
|
|
2372
|
-
}
|
|
2422
|
+
return skin;
|
|
2423
|
+
});
|
|
2373
2424
|
|
|
2374
|
-
const
|
|
2375
|
-
for (let i = 0; i <
|
|
2376
|
-
const skinId =
|
|
2425
|
+
const nodeJsons = loader.gltfJson.nodes;
|
|
2426
|
+
for (let i = 0; i < nodes.length; ++i) {
|
|
2427
|
+
const skinId = nodeJsons[i].skin;
|
|
2377
2428
|
if (defined(skinId)) {
|
|
2378
|
-
nodes[i].skin =
|
|
2429
|
+
nodes[i].skin = loadedSkins[skinId];
|
|
2379
2430
|
}
|
|
2380
2431
|
}
|
|
2381
2432
|
|
|
2382
|
-
return
|
|
2433
|
+
return loadedSkins;
|
|
2383
2434
|
}
|
|
2384
2435
|
|
|
2385
2436
|
async function loadStructuralMetadata(
|
|
2386
2437
|
loader,
|
|
2387
|
-
gltf,
|
|
2388
2438
|
extension,
|
|
2389
2439
|
extensionLegacy,
|
|
2390
|
-
supportedImageFormats,
|
|
2391
2440
|
frameState
|
|
2392
2441
|
) {
|
|
2393
2442
|
const structuralMetadataLoader = new GltfStructuralMetadataLoader({
|
|
2394
|
-
gltf:
|
|
2443
|
+
gltf: loader.gltfJson,
|
|
2395
2444
|
extension: extension,
|
|
2396
2445
|
extensionLegacy: extensionLegacy,
|
|
2397
2446
|
gltfResource: loader._gltfResource,
|
|
2398
2447
|
baseResource: loader._baseResource,
|
|
2399
|
-
supportedImageFormats:
|
|
2448
|
+
supportedImageFormats: loader._supportedImageFormats,
|
|
2400
2449
|
frameState: frameState,
|
|
2401
2450
|
asynchronous: loader._asynchronous,
|
|
2402
2451
|
});
|
|
@@ -2404,11 +2453,12 @@ async function loadStructuralMetadata(
|
|
|
2404
2453
|
return structuralMetadataLoader.load();
|
|
2405
2454
|
}
|
|
2406
2455
|
|
|
2407
|
-
function loadAnimationSampler(loader,
|
|
2456
|
+
function loadAnimationSampler(loader, gltfSampler) {
|
|
2408
2457
|
const animationSampler = new AnimationSampler();
|
|
2458
|
+
const accessors = loader.gltfJson.accessors;
|
|
2409
2459
|
|
|
2410
|
-
const
|
|
2411
|
-
animationSampler.input = loadAccessor(loader,
|
|
2460
|
+
const inputAccessor = accessors[gltfSampler.input];
|
|
2461
|
+
animationSampler.input = loadAccessor(loader, inputAccessor);
|
|
2412
2462
|
|
|
2413
2463
|
const gltfInterpolation = gltfSampler.interpolation;
|
|
2414
2464
|
animationSampler.interpolation = defaultValue(
|
|
@@ -2416,8 +2466,8 @@ function loadAnimationSampler(loader, gltf, gltfSampler) {
|
|
|
2416
2466
|
InterpolationType.LINEAR
|
|
2417
2467
|
);
|
|
2418
2468
|
|
|
2419
|
-
const
|
|
2420
|
-
animationSampler.output = loadAccessor(loader,
|
|
2469
|
+
const outputAccessor = accessors[gltfSampler.output];
|
|
2470
|
+
animationSampler.output = loadAccessor(loader, outputAccessor, true);
|
|
2421
2471
|
|
|
2422
2472
|
return animationSampler;
|
|
2423
2473
|
}
|
|
@@ -2450,29 +2500,19 @@ function loadAnimationChannel(gltfChannel, samplers, nodes) {
|
|
|
2450
2500
|
return animationChannel;
|
|
2451
2501
|
}
|
|
2452
2502
|
|
|
2453
|
-
function loadAnimation(loader,
|
|
2454
|
-
let i;
|
|
2455
|
-
|
|
2503
|
+
function loadAnimation(loader, animationJson, nodes) {
|
|
2456
2504
|
const animation = new Animation();
|
|
2457
|
-
animation.name =
|
|
2505
|
+
animation.name = animationJson.name;
|
|
2458
2506
|
|
|
2459
|
-
const
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
const samplers = new Array(samplersLength);
|
|
2463
|
-
for (i = 0; i < samplersLength; i++) {
|
|
2464
|
-
const sampler = loadAnimationSampler(loader, gltf, gltfSamplers[i]);
|
|
2507
|
+
const samplers = animationJson.samplers.map(function (samplerJson, i) {
|
|
2508
|
+
const sampler = loadAnimationSampler(loader, samplerJson);
|
|
2465
2509
|
sampler.index = i;
|
|
2466
|
-
|
|
2467
|
-
}
|
|
2468
|
-
|
|
2469
|
-
const gltfChannels = gltfAnimation.channels;
|
|
2470
|
-
const channelsLength = gltfChannels.length;
|
|
2510
|
+
return sampler;
|
|
2511
|
+
});
|
|
2471
2512
|
|
|
2472
|
-
const channels =
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
}
|
|
2513
|
+
const channels = animationJson.channels.map(function (channelJson) {
|
|
2514
|
+
return loadAnimationChannel(channelJson, samplers, nodes);
|
|
2515
|
+
});
|
|
2476
2516
|
|
|
2477
2517
|
animation.samplers = samplers;
|
|
2478
2518
|
animation.channels = channels;
|
|
@@ -2480,21 +2520,19 @@ function loadAnimation(loader, gltf, gltfAnimation, nodes) {
|
|
|
2480
2520
|
return animation;
|
|
2481
2521
|
}
|
|
2482
2522
|
|
|
2483
|
-
function loadAnimations(loader,
|
|
2484
|
-
const
|
|
2523
|
+
function loadAnimations(loader, nodes) {
|
|
2524
|
+
const animationJsons = loader.gltfJson.animations;
|
|
2485
2525
|
|
|
2486
2526
|
// Animations are disabled for classification models.
|
|
2487
|
-
if (loader._loadForClassification || !defined(
|
|
2527
|
+
if (loader._loadForClassification || !defined(animationJsons)) {
|
|
2488
2528
|
return [];
|
|
2489
2529
|
}
|
|
2490
2530
|
|
|
2491
|
-
const
|
|
2492
|
-
|
|
2493
|
-
for (let i = 0; i < animationsLength; ++i) {
|
|
2494
|
-
const animation = loadAnimation(loader, gltf, gltf.animations[i], nodes);
|
|
2531
|
+
const animations = animationJsons.map(function (animationJson, i) {
|
|
2532
|
+
const animation = loadAnimation(loader, animationJson, nodes);
|
|
2495
2533
|
animation.index = i;
|
|
2496
|
-
|
|
2497
|
-
}
|
|
2534
|
+
return animation;
|
|
2535
|
+
});
|
|
2498
2536
|
|
|
2499
2537
|
return animations;
|
|
2500
2538
|
}
|
|
@@ -2513,45 +2551,20 @@ function loadArticulationStage(gltfStage) {
|
|
|
2513
2551
|
return stage;
|
|
2514
2552
|
}
|
|
2515
2553
|
|
|
2516
|
-
function loadArticulation(
|
|
2554
|
+
function loadArticulation(articulationJson) {
|
|
2517
2555
|
const articulation = new Articulation();
|
|
2518
|
-
articulation.name =
|
|
2519
|
-
|
|
2520
|
-
const gltfStages = gltfArticulation.stages;
|
|
2521
|
-
const gltfStagesLength = gltfStages.length;
|
|
2522
|
-
|
|
2523
|
-
const stages = new Array(gltfStagesLength);
|
|
2524
|
-
for (let i = 0; i < gltfStagesLength; i++) {
|
|
2525
|
-
const stage = loadArticulationStage(gltfStages[i]);
|
|
2526
|
-
stages[i] = stage;
|
|
2527
|
-
}
|
|
2528
|
-
|
|
2529
|
-
articulation.stages = stages;
|
|
2530
|
-
|
|
2556
|
+
articulation.name = articulationJson.name;
|
|
2557
|
+
articulation.stages = articulationJson.stages.map(loadArticulationStage);
|
|
2531
2558
|
return articulation;
|
|
2532
2559
|
}
|
|
2533
2560
|
|
|
2534
2561
|
function loadArticulations(gltf) {
|
|
2535
2562
|
const extensions = defaultValue(gltf.extensions, defaultValue.EMPTY_OBJECT);
|
|
2536
|
-
const
|
|
2537
|
-
|
|
2538
|
-
if (!defined(articulationsExtension)) {
|
|
2563
|
+
const articulationJsons = extensions.AGI_articulations?.articulations;
|
|
2564
|
+
if (!defined(articulationJsons)) {
|
|
2539
2565
|
return [];
|
|
2540
2566
|
}
|
|
2541
|
-
|
|
2542
|
-
const gltfArticulations = articulationsExtension.articulations;
|
|
2543
|
-
if (!defined(gltfArticulations)) {
|
|
2544
|
-
return [];
|
|
2545
|
-
}
|
|
2546
|
-
|
|
2547
|
-
const gltfArticulationsLength = gltfArticulations.length;
|
|
2548
|
-
const articulations = new Array(gltfArticulationsLength);
|
|
2549
|
-
for (let i = 0; i < gltfArticulationsLength; i++) {
|
|
2550
|
-
const articulation = loadArticulation(gltfArticulations[i]);
|
|
2551
|
-
articulations[i] = articulation;
|
|
2552
|
-
}
|
|
2553
|
-
|
|
2554
|
-
return articulations;
|
|
2567
|
+
return articulationJsons.map(loadArticulation);
|
|
2555
2568
|
}
|
|
2556
2569
|
|
|
2557
2570
|
function getSceneNodeIds(gltf) {
|
|
@@ -2575,7 +2588,23 @@ function loadScene(gltf, nodes) {
|
|
|
2575
2588
|
|
|
2576
2589
|
const scratchCenter = new Cartesian3();
|
|
2577
2590
|
|
|
2578
|
-
|
|
2591
|
+
/**
|
|
2592
|
+
* Parse the glTF which populates the loaders arrays. Loading promises will be created, and will
|
|
2593
|
+
* resolve once the loaders are ready (i.e. all external resources
|
|
2594
|
+
* have been fetched and all GPU resources have been created). Loaders that
|
|
2595
|
+
* create GPU resources need to be processed every frame until they become
|
|
2596
|
+
* ready since the JobScheduler is not able to execute all jobs in a single
|
|
2597
|
+
* frame. Any promise failures are collected, and will be handled synchronously in process().
|
|
2598
|
+
* Also note that it's fine to call process before a loader is ready to process or
|
|
2599
|
+
* after it has failed; nothing will happen.
|
|
2600
|
+
*
|
|
2601
|
+
* @param {GltfLoader} loader
|
|
2602
|
+
* @param {FrameState} frameState
|
|
2603
|
+
* @returns {Promise} A Promise that resolves when all loaders are ready
|
|
2604
|
+
* @private
|
|
2605
|
+
*/
|
|
2606
|
+
function parse(loader, frameState) {
|
|
2607
|
+
const gltf = loader.gltfJson;
|
|
2579
2608
|
const extensions = defaultValue(gltf.extensions, defaultValue.EMPTY_OBJECT);
|
|
2580
2609
|
const structuralMetadataExtension = extensions.EXT_structural_metadata;
|
|
2581
2610
|
const featureMetadataExtensionLegacy = extensions.EXT_feature_metadata;
|
|
@@ -2598,9 +2627,9 @@ function parse(loader, gltf, supportedImageFormats, frameState) {
|
|
|
2598
2627
|
loader._sortedFeatureTextureIds = Object.keys(allFeatureTextureIds).sort();
|
|
2599
2628
|
}
|
|
2600
2629
|
|
|
2601
|
-
const nodes = loadNodes(loader,
|
|
2602
|
-
const skins = loadSkins(loader,
|
|
2603
|
-
const animations = loadAnimations(loader,
|
|
2630
|
+
const nodes = loadNodes(loader, frameState);
|
|
2631
|
+
const skins = loadSkins(loader, nodes);
|
|
2632
|
+
const animations = loadAnimations(loader, nodes);
|
|
2604
2633
|
const articulations = loadArticulations(gltf);
|
|
2605
2634
|
const scene = loadScene(gltf, nodes);
|
|
2606
2635
|
|
|
@@ -2645,10 +2674,8 @@ function parse(loader, gltf, supportedImageFormats, frameState) {
|
|
|
2645
2674
|
) {
|
|
2646
2675
|
const promise = loadStructuralMetadata(
|
|
2647
2676
|
loader,
|
|
2648
|
-
gltf,
|
|
2649
2677
|
structuralMetadataExtension,
|
|
2650
2678
|
featureMetadataExtensionLegacy,
|
|
2651
|
-
supportedImageFormats,
|
|
2652
2679
|
frameState
|
|
2653
2680
|
);
|
|
2654
2681
|
loader._loaderPromises.push(promise);
|
|
@@ -2669,8 +2696,7 @@ function parse(loader, gltf, supportedImageFormats, frameState) {
|
|
|
2669
2696
|
|
|
2670
2697
|
function unloadTextures(loader) {
|
|
2671
2698
|
const textureLoaders = loader._textureLoaders;
|
|
2672
|
-
|
|
2673
|
-
for (let i = 0; i < textureLoadersLength; ++i) {
|
|
2699
|
+
for (let i = 0; i < textureLoaders.length; ++i) {
|
|
2674
2700
|
textureLoaders[i] =
|
|
2675
2701
|
!textureLoaders[i].isDestroyed() &&
|
|
2676
2702
|
ResourceCache.unload(textureLoaders[i]);
|
|
@@ -2680,8 +2706,7 @@ function unloadTextures(loader) {
|
|
|
2680
2706
|
|
|
2681
2707
|
function unloadBufferViewLoaders(loader) {
|
|
2682
2708
|
const bufferViewLoaders = loader._bufferViewLoaders;
|
|
2683
|
-
|
|
2684
|
-
for (let i = 0; i < bufferViewLoadersLength; ++i) {
|
|
2709
|
+
for (let i = 0; i < bufferViewLoaders.length; ++i) {
|
|
2685
2710
|
bufferViewLoaders[i] =
|
|
2686
2711
|
!bufferViewLoaders[i].isDestroyed() &&
|
|
2687
2712
|
ResourceCache.unload(bufferViewLoaders[i]);
|
|
@@ -2691,8 +2716,7 @@ function unloadBufferViewLoaders(loader) {
|
|
|
2691
2716
|
|
|
2692
2717
|
function unloadGeometry(loader) {
|
|
2693
2718
|
const geometryLoaders = loader._geometryLoaders;
|
|
2694
|
-
|
|
2695
|
-
for (let i = 0; i < geometryLoadersLength; ++i) {
|
|
2719
|
+
for (let i = 0; i < geometryLoaders.length; ++i) {
|
|
2696
2720
|
geometryLoaders[i] =
|
|
2697
2721
|
!geometryLoaders[i].isDestroyed() &&
|
|
2698
2722
|
ResourceCache.unload(geometryLoaders[i]);
|
|
@@ -2702,8 +2726,7 @@ function unloadGeometry(loader) {
|
|
|
2702
2726
|
|
|
2703
2727
|
function unloadGeneratedAttributes(loader) {
|
|
2704
2728
|
const buffers = loader._postProcessBuffers;
|
|
2705
|
-
|
|
2706
|
-
for (let i = 0; i < length; i++) {
|
|
2729
|
+
for (let i = 0; i < buffers.length; i++) {
|
|
2707
2730
|
const buffer = buffers[i];
|
|
2708
2731
|
if (!buffer.isDestroyed()) {
|
|
2709
2732
|
buffer.destroy();
|