three-stdlib 2.25.0 → 2.26.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/controls/OrbitControls.d.ts +1 -0
- package/index.cjs +116465 -611
- package/index.js +116101 -263
- package/package.json +17 -4
- package/_polyfill/CapsuleGeometry.cjs +0 -22
- package/_polyfill/CapsuleGeometry.js +0 -22
- package/_polyfill/CompressedArrayTexture.cjs +0 -12
- package/_polyfill/CompressedArrayTexture.js +0 -12
- package/_polyfill/Data3DTexture.cjs +0 -17
- package/_polyfill/Data3DTexture.js +0 -17
- package/animation/AnimationClipCreator.cjs +0 -56
- package/animation/AnimationClipCreator.js +0 -56
- package/animation/CCDIKSolver.cjs +0 -269
- package/animation/CCDIKSolver.js +0 -269
- package/animation/MMDAnimationHelper.cjs +0 -688
- package/animation/MMDAnimationHelper.js +0 -688
- package/animation/MMDPhysics.cjs +0 -830
- package/animation/MMDPhysics.js +0 -830
- package/cameras/CinematicCamera.cjs +0 -131
- package/cameras/CinematicCamera.js +0 -131
- package/controls/ArcballControls.cjs +0 -2033
- package/controls/ArcballControls.js +0 -2033
- package/controls/DeviceOrientationControls.cjs +0 -85
- package/controls/DeviceOrientationControls.js +0 -85
- package/controls/DragControls.cjs +0 -182
- package/controls/DragControls.js +0 -182
- package/controls/FirstPersonControls.cjs +0 -229
- package/controls/FirstPersonControls.js +0 -229
- package/controls/FlyControls.cjs +0 -248
- package/controls/FlyControls.js +0 -248
- package/controls/OrbitControls.cjs +0 -791
- package/controls/OrbitControls.js +0 -791
- package/controls/PointerLockControls.cjs +0 -103
- package/controls/PointerLockControls.js +0 -103
- package/controls/TrackballControls.cjs +0 -502
- package/controls/TrackballControls.js +0 -502
- package/controls/TransformControls.cjs +0 -1089
- package/controls/TransformControls.js +0 -1089
- package/controls/experimental/CameraControls.cjs +0 -736
- package/controls/experimental/CameraControls.js +0 -736
- package/csm/CSM.cjs +0 -244
- package/csm/CSM.js +0 -244
- package/csm/CSMFrustum.cjs +0 -75
- package/csm/CSMFrustum.js +0 -75
- package/csm/CSMHelper.cjs +0 -114
- package/csm/CSMHelper.js +0 -114
- package/csm/CSMShader.cjs +0 -261
- package/csm/CSMShader.js +0 -261
- package/curves/CurveExtras.cjs +0 -214
- package/curves/CurveExtras.js +0 -214
- package/curves/NURBSCurve.cjs +0 -35
- package/curves/NURBSCurve.js +0 -35
- package/curves/NURBSSurface.cjs +0 -28
- package/curves/NURBSSurface.js +0 -28
- package/curves/NURBSUtils.cjs +0 -226
- package/curves/NURBSUtils.js +0 -226
- package/deprecated/Geometry.cjs +0 -971
- package/deprecated/Geometry.js +0 -971
- package/effects/AnaglyphEffect.cjs +0 -102
- package/effects/AnaglyphEffect.js +0 -102
- package/effects/AsciiEffect.cjs +0 -155
- package/effects/AsciiEffect.js +0 -155
- package/effects/OutlineEffect.cjs +0 -275
- package/effects/OutlineEffect.js +0 -275
- package/effects/ParallaxBarrierEffect.cjs +0 -65
- package/effects/ParallaxBarrierEffect.js +0 -65
- package/effects/PeppersGhostEffect.cjs +0 -88
- package/effects/PeppersGhostEffect.js +0 -88
- package/effects/StereoEffect.cjs +0 -35
- package/effects/StereoEffect.js +0 -35
- package/environments/RoomEnvironment.cjs +0 -95
- package/environments/RoomEnvironment.js +0 -78
- package/exporters/ColladaExporter.cjs +0 -331
- package/exporters/ColladaExporter.js +0 -331
- package/exporters/DRACOExporter.cjs +0 -141
- package/exporters/DRACOExporter.js +0 -141
- package/exporters/GLTFExporter.cjs +0 -1909
- package/exporters/GLTFExporter.js +0 -1909
- package/exporters/MMDExporter.cjs +0 -131
- package/exporters/MMDExporter.js +0 -131
- package/exporters/OBJExporter.cjs +0 -181
- package/exporters/OBJExporter.js +0 -181
- package/exporters/PLYExporter.cjs +0 -280
- package/exporters/PLYExporter.js +0 -280
- package/exporters/STLExporter.cjs +0 -146
- package/exporters/STLExporter.js +0 -146
- package/exporters/USDZExporter.cjs +0 -340
- package/exporters/USDZExporter.js +0 -340
- package/geometries/BoxLineGeometry.cjs +0 -45
- package/geometries/BoxLineGeometry.js +0 -45
- package/geometries/ConvexGeometry.cjs +0 -26
- package/geometries/ConvexGeometry.js +0 -26
- package/geometries/DecalGeometry.cjs +0 -184
- package/geometries/DecalGeometry.js +0 -184
- package/geometries/LightningStrike.cjs +0 -553
- package/geometries/LightningStrike.js +0 -553
- package/geometries/ParametricGeometries.cjs +0 -130
- package/geometries/ParametricGeometries.js +0 -130
- package/geometries/ParametricGeometry.cjs +0 -63
- package/geometries/ParametricGeometry.js +0 -63
- package/geometries/RoundedBoxGeometry.cjs +0 -91
- package/geometries/RoundedBoxGeometry.js +0 -91
- package/geometries/TeapotGeometry.cjs +0 -1563
- package/geometries/TeapotGeometry.js +0 -1563
- package/geometries/TextGeometry.cjs +0 -27
- package/geometries/TextGeometry.js +0 -27
- package/helpers/LightProbeHelper.cjs +0 -73
- package/helpers/LightProbeHelper.js +0 -73
- package/helpers/PositionalAudioHelper.cjs +0 -68
- package/helpers/PositionalAudioHelper.js +0 -68
- package/helpers/RectAreaLightHelper.cjs +0 -44
- package/helpers/RectAreaLightHelper.js +0 -44
- package/helpers/VertexNormalsHelper.cjs +0 -47
- package/helpers/VertexNormalsHelper.js +0 -47
- package/helpers/VertexTangentsHelper.cjs +0 -43
- package/helpers/VertexTangentsHelper.js +0 -43
- package/interactive/HTMLMesh.cjs +0 -325
- package/interactive/HTMLMesh.js +0 -325
- package/interactive/InteractiveGroup.cjs +0 -68
- package/interactive/InteractiveGroup.js +0 -68
- package/interactive/SelectionBox.cjs +0 -134
- package/interactive/SelectionBox.js +0 -134
- package/interactive/SelectionHelper.cjs +0 -51
- package/interactive/SelectionHelper.js +0 -51
- package/libs/MeshoptDecoder.cjs +0 -221
- package/libs/MeshoptDecoder.js +0 -221
- package/libs/MotionControllers.cjs +0 -325
- package/libs/MotionControllers.js +0 -325
- package/lights/LightProbeGenerator.cjs +0 -145
- package/lights/LightProbeGenerator.js +0 -145
- package/lights/RectAreaLightUniformsLib.cjs +0 -32846
- package/lights/RectAreaLightUniformsLib.js +0 -32846
- package/lines/Line2.cjs +0 -13
- package/lines/Line2.js +0 -13
- package/lines/LineGeometry.cjs +0 -44
- package/lines/LineGeometry.js +0 -44
- package/lines/LineMaterial.cjs +0 -547
- package/lines/LineMaterial.js +0 -547
- package/lines/LineSegments2.cjs +0 -203
- package/lines/LineSegments2.js +0 -203
- package/lines/LineSegmentsGeometry.cjs +0 -124
- package/lines/LineSegmentsGeometry.js +0 -124
- package/lines/Wireframe.cjs +0 -32
- package/lines/Wireframe.js +0 -32
- package/lines/WireframeGeometry2.cjs +0 -13
- package/lines/WireframeGeometry2.js +0 -13
- package/loaders/3DMLoader.cjs +0 -803
- package/loaders/3DMLoader.js +0 -803
- package/loaders/3MFLoader.cjs +0 -854
- package/loaders/3MFLoader.js +0 -854
- package/loaders/AMFLoader.cjs +0 -284
- package/loaders/AMFLoader.js +0 -284
- package/loaders/AssimpLoader.cjs +0 -1434
- package/loaders/AssimpLoader.js +0 -1434
- package/loaders/BVHLoader.cjs +0 -207
- package/loaders/BVHLoader.js +0 -207
- package/loaders/BasisTextureLoader.cjs +0 -489
- package/loaders/BasisTextureLoader.js +0 -489
- package/loaders/ColladaLoader.cjs +0 -2405
- package/loaders/ColladaLoader.js +0 -2405
- package/loaders/DDSLoader.cjs +0 -148
- package/loaders/DDSLoader.js +0 -148
- package/loaders/DRACOLoader.cjs +0 -341
- package/loaders/DRACOLoader.js +0 -341
- package/loaders/EXRLoader.cjs +0 -1356
- package/loaders/EXRLoader.js +0 -1356
- package/loaders/FBXLoader.cjs +0 -2457
- package/loaders/FBXLoader.js +0 -2457
- package/loaders/FontLoader.cjs +0 -123
- package/loaders/FontLoader.js +0 -123
- package/loaders/GCodeLoader.cjs +0 -141
- package/loaders/GCodeLoader.js +0 -141
- package/loaders/GLTFLoader.cjs +0 -2504
- package/loaders/GLTFLoader.js +0 -2504
- package/loaders/HDRCubeTextureLoader.cjs +0 -75
- package/loaders/HDRCubeTextureLoader.js +0 -75
- package/loaders/KMZLoader.cjs +0 -75
- package/loaders/KMZLoader.js +0 -75
- package/loaders/KTX2Loader.cjs +0 -480
- package/loaders/KTX2Loader.js +0 -480
- package/loaders/KTXLoader.cjs +0 -93
- package/loaders/KTXLoader.js +0 -93
- package/loaders/LDrawLoader.cjs +0 -1424
- package/loaders/LDrawLoader.js +0 -1424
- package/loaders/LUT3dlLoader.cjs +0 -103
- package/loaders/LUT3dlLoader.js +0 -103
- package/loaders/LUTCubeLoader.cjs +0 -107
- package/loaders/LUTCubeLoader.js +0 -107
- package/loaders/LWOLoader.cjs +0 -645
- package/loaders/LWOLoader.js +0 -645
- package/loaders/LottieLoader.cjs +0 -47
- package/loaders/LottieLoader.js +0 -47
- package/loaders/MD2Loader.cjs +0 -359
- package/loaders/MD2Loader.js +0 -359
- package/loaders/MDDLoader.cjs +0 -58
- package/loaders/MDDLoader.js +0 -58
- package/loaders/MMDLoader.cjs +0 -1121
- package/loaders/MMDLoader.js +0 -1121
- package/loaders/MTLLoader.cjs +0 -304
- package/loaders/MTLLoader.js +0 -304
- package/loaders/NRRDLoader.cjs +0 -401
- package/loaders/NRRDLoader.js +0 -401
- package/loaders/OBJLoader.cjs +0 -487
- package/loaders/OBJLoader.js +0 -487
- package/loaders/PCDLoader.cjs +0 -248
- package/loaders/PCDLoader.js +0 -248
- package/loaders/PDBLoader.cjs +0 -247
- package/loaders/PDBLoader.js +0 -247
- package/loaders/PLYLoader.cjs +0 -317
- package/loaders/PLYLoader.js +0 -317
- package/loaders/PRWMLoader.cjs +0 -160
- package/loaders/PRWMLoader.js +0 -160
- package/loaders/PVRLoader.cjs +0 -131
- package/loaders/PVRLoader.js +0 -131
- package/loaders/RGBELoader.cjs +0 -252
- package/loaders/RGBELoader.js +0 -252
- package/loaders/RGBMLoader.cjs +0 -1004
- package/loaders/RGBMLoader.js +0 -1004
- package/loaders/STLLoader.cjs +0 -190
- package/loaders/STLLoader.js +0 -190
- package/loaders/SVGLoader.cjs +0 -1712
- package/loaders/SVGLoader.js +0 -1712
- package/loaders/TDSLoader.cjs +0 -650
- package/loaders/TDSLoader.js +0 -650
- package/loaders/TGALoader.cjs +0 -285
- package/loaders/TGALoader.js +0 -285
- package/loaders/TTFLoader.cjs +0 -131
- package/loaders/TTFLoader.js +0 -131
- package/loaders/TiltLoader.cjs +0 -375
- package/loaders/TiltLoader.js +0 -375
- package/loaders/VOXLoader.cjs +0 -432
- package/loaders/VOXLoader.js +0 -432
- package/loaders/VRMLLoader.cjs +0 -2105
- package/loaders/VRMLLoader.js +0 -2105
- package/loaders/VRMLoader.cjs +0 -38
- package/loaders/VRMLoader.js +0 -38
- package/loaders/VTKLoader.cjs +0 -648
- package/loaders/VTKLoader.js +0 -648
- package/loaders/XLoader.cjs +0 -1258
- package/loaders/XLoader.js +0 -1258
- package/loaders/XYZLoader.cjs +0 -60
- package/loaders/XYZLoader.js +0 -60
- package/loaders/lwo/IFFParser.cjs +0 -743
- package/loaders/lwo/IFFParser.js +0 -743
- package/loaders/lwo/LWO2Parser.cjs +0 -312
- package/loaders/lwo/LWO2Parser.js +0 -312
- package/loaders/lwo/LWO3Parser.cjs +0 -282
- package/loaders/lwo/LWO3Parser.js +0 -282
- package/math/Capsule.cjs +0 -98
- package/math/Capsule.js +0 -98
- package/math/ColorConverter.cjs +0 -42
- package/math/ColorConverter.js +0 -42
- package/math/ConvexHull.cjs +0 -596
- package/math/ConvexHull.js +0 -596
- package/math/ImprovedNoise.cjs +0 -304
- package/math/ImprovedNoise.js +0 -304
- package/math/Lut.cjs +0 -137
- package/math/Lut.js +0 -137
- package/math/MeshSurfaceSampler.cjs +0 -103
- package/math/MeshSurfaceSampler.js +0 -103
- package/math/OBB.cjs +0 -242
- package/math/OBB.js +0 -242
- package/math/Octree.cjs +0 -273
- package/math/Octree.js +0 -273
- package/math/SimplexNoise.cjs +0 -440
- package/math/SimplexNoise.js +0 -440
- package/misc/ConvexObjectBreaker.cjs +0 -292
- package/misc/ConvexObjectBreaker.js +0 -292
- package/misc/GPUComputationRenderer.cjs +0 -205
- package/misc/GPUComputationRenderer.js +0 -205
- package/misc/Gyroscope.cjs +0 -33
- package/misc/Gyroscope.js +0 -33
- package/misc/MD2Character.cjs +0 -167
- package/misc/MD2Character.js +0 -167
- package/misc/MD2CharacterComplex.cjs +0 -332
- package/misc/MD2CharacterComplex.js +0 -332
- package/misc/MorphAnimMesh.cjs +0 -40
- package/misc/MorphAnimMesh.js +0 -40
- package/misc/MorphBlendMesh.cjs +0 -179
- package/misc/MorphBlendMesh.js +0 -179
- package/misc/ProgressiveLightmap.cjs +0 -186
- package/misc/ProgressiveLightmap.js +0 -186
- package/misc/RollerCoaster.cjs +0 -353
- package/misc/RollerCoaster.js +0 -353
- package/misc/Timer.cjs +0 -101
- package/misc/Timer.js +0 -101
- package/misc/TubePainter.cjs +0 -123
- package/misc/TubePainter.js +0 -123
- package/misc/Volume.cjs +0 -305
- package/misc/Volume.js +0 -305
- package/misc/VolumeSlice.cjs +0 -114
- package/misc/VolumeSlice.js +0 -114
- package/misc/WebGL.cjs +0 -74
- package/misc/WebGL.js +0 -74
- package/modifiers/CurveModifier.cjs +0 -232
- package/modifiers/CurveModifier.js +0 -232
- package/modifiers/EdgeSplitModifier.cjs +0 -167
- package/modifiers/EdgeSplitModifier.js +0 -168
- package/modifiers/SimplifyModifier.cjs +0 -301
- package/modifiers/SimplifyModifier.js +0 -301
- package/modifiers/TessellateModifier.cjs +0 -214
- package/modifiers/TessellateModifier.js +0 -214
- package/objects/GroundProjectedEnv.cjs +0 -134
- package/objects/GroundProjectedEnv.js +0 -134
- package/objects/Lensflare.cjs +0 -291
- package/objects/Lensflare.js +0 -291
- package/objects/LightningStorm.cjs +0 -110
- package/objects/LightningStorm.js +0 -110
- package/objects/MarchingCubes.cjs +0 -4809
- package/objects/MarchingCubes.js +0 -4809
- package/objects/Reflector.cjs +0 -202
- package/objects/Reflector.js +0 -202
- package/objects/ReflectorForSSRPass.cjs +0 -260
- package/objects/ReflectorForSSRPass.js +0 -260
- package/objects/ReflectorRTT.cjs +0 -10
- package/objects/ReflectorRTT.js +0 -10
- package/objects/Refractor.cjs +0 -215
- package/objects/Refractor.js +0 -215
- package/objects/ShadowMesh.cjs +0 -45
- package/objects/ShadowMesh.js +0 -45
- package/objects/Sky.cjs +0 -200
- package/objects/Sky.js +0 -200
- package/objects/Water.cjs +0 -242
- package/objects/Water.js +0 -242
- package/objects/Water2.cjs +0 -256
- package/objects/Water2.js +0 -256
- package/physics/AmmoPhysics.cjs +0 -166
- package/physics/AmmoPhysics.js +0 -166
- package/postprocessing/AdaptiveToneMappingPass.cjs +0 -218
- package/postprocessing/AdaptiveToneMappingPass.js +0 -218
- package/postprocessing/AfterimagePass.cjs +0 -68
- package/postprocessing/AfterimagePass.js +0 -68
- package/postprocessing/BloomPass.cjs +0 -109
- package/postprocessing/BloomPass.js +0 -109
- package/postprocessing/BokehPass.cjs +0 -90
- package/postprocessing/BokehPass.js +0 -90
- package/postprocessing/ClearPass.cjs +0 -36
- package/postprocessing/ClearPass.js +0 -36
- package/postprocessing/CubeTexturePass.cjs +0 -53
- package/postprocessing/CubeTexturePass.js +0 -53
- package/postprocessing/DotScreenPass.cjs +0 -49
- package/postprocessing/DotScreenPass.js +0 -49
- package/postprocessing/EffectComposer.cjs +0 -157
- package/postprocessing/EffectComposer.js +0 -157
- package/postprocessing/FilmPass.cjs +0 -51
- package/postprocessing/FilmPass.js +0 -51
- package/postprocessing/GlitchPass.cjs +0 -84
- package/postprocessing/GlitchPass.js +0 -84
- package/postprocessing/HalftonePass.cjs +0 -53
- package/postprocessing/HalftonePass.js +0 -53
- package/postprocessing/LUTPass.cjs +0 -142
- package/postprocessing/LUTPass.js +0 -142
- package/postprocessing/MaskPass.cjs +0 -69
- package/postprocessing/MaskPass.js +0 -69
- package/postprocessing/OutlinePass.cjs +0 -479
- package/postprocessing/OutlinePass.js +0 -479
- package/postprocessing/Pass.cjs +0 -48
- package/postprocessing/Pass.js +0 -48
- package/postprocessing/RenderPass.cjs +0 -59
- package/postprocessing/RenderPass.js +0 -59
- package/postprocessing/RenderPixelatedPass.cjs +0 -199
- package/postprocessing/RenderPixelatedPass.js +0 -199
- package/postprocessing/SAOPass.cjs +0 -288
- package/postprocessing/SAOPass.js +0 -288
- package/postprocessing/SMAAPass.cjs +0 -112
- package/postprocessing/SMAAPass.js +0 -112
- package/postprocessing/SSAARenderPass.cjs +0 -189
- package/postprocessing/SSAARenderPass.js +0 -189
- package/postprocessing/SSAOPass.cjs +0 -272
- package/postprocessing/SSAOPass.js +0 -272
- package/postprocessing/SSRPass.cjs +0 -411
- package/postprocessing/SSRPass.js +0 -411
- package/postprocessing/SavePass.cjs +0 -38
- package/postprocessing/SavePass.js +0 -38
- package/postprocessing/ShaderPass.cjs +0 -49
- package/postprocessing/ShaderPass.js +0 -49
- package/postprocessing/TAARenderPass.cjs +0 -174
- package/postprocessing/TAARenderPass.js +0 -174
- package/postprocessing/TexturePass.cjs +0 -42
- package/postprocessing/TexturePass.js +0 -42
- package/postprocessing/UnrealBloomPass.cjs +0 -277
- package/postprocessing/UnrealBloomPass.js +0 -277
- package/postprocessing/WaterPass.cjs +0 -72
- package/postprocessing/WaterPass.js +0 -72
- package/renderers/CSS2DRenderer.cjs +0 -122
- package/renderers/CSS2DRenderer.js +0 -122
- package/renderers/CSS3DRenderer.cjs +0 -167
- package/renderers/CSS3DRenderer.js +0 -167
- package/renderers/Projector.cjs +0 -499
- package/renderers/Projector.js +0 -499
- package/renderers/SVGRenderer.cjs +0 -311
- package/renderers/SVGRenderer.js +0 -311
- package/shaders/ACESFilmicToneMappingShader.cjs +0 -55
- package/shaders/ACESFilmicToneMappingShader.js +0 -55
- package/shaders/AfterimageShader.cjs +0 -32
- package/shaders/AfterimageShader.js +0 -32
- package/shaders/BasicShader.cjs +0 -12
- package/shaders/BasicShader.js +0 -12
- package/shaders/BleachBypassShader.cjs +0 -35
- package/shaders/BleachBypassShader.js +0 -35
- package/shaders/BlendShader.cjs +0 -30
- package/shaders/BlendShader.js +0 -30
- package/shaders/BokehShader.cjs +0 -109
- package/shaders/BokehShader.js +0 -109
- package/shaders/BokehShader2.cjs +0 -269
- package/shaders/BokehShader2.js +0 -269
- package/shaders/BrightnessContrastShader.cjs +0 -32
- package/shaders/BrightnessContrastShader.js +0 -32
- package/shaders/ColorCorrectionShader.cjs +0 -30
- package/shaders/ColorCorrectionShader.js +0 -30
- package/shaders/ColorifyShader.cjs +0 -28
- package/shaders/ColorifyShader.js +0 -28
- package/shaders/ConvolutionShader.cjs +0 -55
- package/shaders/ConvolutionShader.js +0 -55
- package/shaders/CopyShader.cjs +0 -25
- package/shaders/CopyShader.js +0 -25
- package/shaders/DOFMipMapShader.cjs +0 -32
- package/shaders/DOFMipMapShader.js +0 -32
- package/shaders/DepthLimitedBlurShader.cjs +0 -114
- package/shaders/DepthLimitedBlurShader.js +0 -114
- package/shaders/DigitalGlitch.cjs +0 -85
- package/shaders/DigitalGlitch.js +0 -85
- package/shaders/DotScreenShader.cjs +0 -39
- package/shaders/DotScreenShader.js +0 -39
- package/shaders/FXAAShader.cjs +0 -1098
- package/shaders/FXAAShader.js +0 -1098
- package/shaders/FilmShader.cjs +0 -53
- package/shaders/FilmShader.js +0 -53
- package/shaders/FocusShader.cjs +0 -55
- package/shaders/FocusShader.js +0 -55
- package/shaders/FreiChenShader.cjs +0 -64
- package/shaders/FreiChenShader.js +0 -64
- package/shaders/FresnelShader.cjs +0 -47
- package/shaders/FresnelShader.js +0 -47
- package/shaders/GammaCorrectionShader.cjs +0 -23
- package/shaders/GammaCorrectionShader.js +0 -23
- package/shaders/GodRaysShader.cjs +0 -183
- package/shaders/GodRaysShader.js +0 -183
- package/shaders/HalftoneShader.cjs +0 -228
- package/shaders/HalftoneShader.js +0 -228
- package/shaders/HorizontalBlurShader.cjs +0 -49
- package/shaders/HorizontalBlurShader.js +0 -49
- package/shaders/HorizontalTiltShiftShader.cjs +0 -37
- package/shaders/HorizontalTiltShiftShader.js +0 -37
- package/shaders/HueSaturationShader.cjs +0 -43
- package/shaders/HueSaturationShader.js +0 -43
- package/shaders/KaleidoShader.cjs +0 -34
- package/shaders/KaleidoShader.js +0 -34
- package/shaders/LuminosityHighPassShader.cjs +0 -37
- package/shaders/LuminosityHighPassShader.js +0 -37
- package/shaders/LuminosityShader.cjs +0 -25
- package/shaders/LuminosityShader.js +0 -25
- package/shaders/MirrorShader.cjs +0 -35
- package/shaders/MirrorShader.js +0 -35
- package/shaders/NormalMapShader.cjs +0 -31
- package/shaders/NormalMapShader.js +0 -31
- package/shaders/ParallaxShader.cjs +0 -133
- package/shaders/ParallaxShader.js +0 -133
- package/shaders/PixelShader.cjs +0 -28
- package/shaders/PixelShader.js +0 -28
- package/shaders/RGBShiftShader.cjs +0 -30
- package/shaders/RGBShiftShader.js +0 -30
- package/shaders/SAOShader.cjs +0 -144
- package/shaders/SAOShader.js +0 -144
- package/shaders/SMAAShader.cjs +0 -358
- package/shaders/SMAAShader.js +0 -358
- package/shaders/SSAOShader.cjs +0 -182
- package/shaders/SSAOShader.js +0 -182
- package/shaders/SSRShader.cjs +0 -342
- package/shaders/SSRShader.js +0 -342
- package/shaders/SepiaShader.cjs +0 -29
- package/shaders/SepiaShader.js +0 -29
- package/shaders/SobelOperatorShader.cjs +0 -54
- package/shaders/SobelOperatorShader.js +0 -54
- package/shaders/SubsurfaceScatteringShader.cjs +0 -98
- package/shaders/SubsurfaceScatteringShader.js +0 -98
- package/shaders/TechnicolorShader.cjs +0 -24
- package/shaders/TechnicolorShader.js +0 -24
- package/shaders/ToneMapShader.cjs +0 -51
- package/shaders/ToneMapShader.js +0 -51
- package/shaders/ToonShader.cjs +0 -188
- package/shaders/ToonShader.js +0 -188
- package/shaders/TriangleBlurShader.cjs +0 -37
- package/shaders/TriangleBlurShader.js +0 -37
- package/shaders/UnpackDepthRGBAShader.cjs +0 -26
- package/shaders/UnpackDepthRGBAShader.js +0 -26
- package/shaders/VerticalBlurShader.cjs +0 -50
- package/shaders/VerticalBlurShader.js +0 -50
- package/shaders/VerticalTiltShiftShader.cjs +0 -37
- package/shaders/VerticalTiltShiftShader.js +0 -37
- package/shaders/VignetteShader.cjs +0 -38
- package/shaders/VignetteShader.js +0 -38
- package/shaders/VolumeShader.cjs +0 -225
- package/shaders/VolumeShader.js +0 -225
- package/shaders/WaterRefractionShader.cjs +0 -59
- package/shaders/WaterRefractionShader.js +0 -59
- package/shaders/types.cjs +0 -1
- package/shaders/types.js +0 -1
- package/textures/FlakesTexture.cjs +0 -30
- package/textures/FlakesTexture.js +0 -30
- package/types/helpers.cjs +0 -4
- package/types/helpers.js +0 -4
- package/utils/BufferGeometryUtils.cjs +0 -636
- package/utils/BufferGeometryUtils.js +0 -636
- package/utils/GeometryCompressionUtils.cjs +0 -573
- package/utils/GeometryCompressionUtils.js +0 -573
- package/utils/GeometryUtils.cjs +0 -109
- package/utils/GeometryUtils.js +0 -109
- package/utils/RoughnessMipmapper.cjs +0 -223
- package/utils/RoughnessMipmapper.js +0 -223
- package/utils/SceneUtils.cjs +0 -36
- package/utils/SceneUtils.js +0 -36
- package/utils/ShadowMapViewer.cjs +0 -111
- package/utils/ShadowMapViewer.js +0 -111
- package/utils/SkeletonUtils.cjs +0 -211
- package/utils/SkeletonUtils.js +0 -211
- package/utils/UVsDebug.cjs +0 -80
- package/utils/UVsDebug.js +0 -80
- package/utils/WorkerPool.cjs +0 -62
- package/utils/WorkerPool.js +0 -62
- package/webxr/ARButton.cjs +0 -119
- package/webxr/ARButton.js +0 -119
- package/webxr/OculusHandModel.cjs +0 -82
- package/webxr/OculusHandModel.js +0 -82
- package/webxr/OculusHandPointerModel.cjs +0 -241
- package/webxr/OculusHandPointerModel.js +0 -224
- package/webxr/Text2D.cjs +0 -48
- package/webxr/Text2D.js +0 -31
- package/webxr/VRButton.cjs +0 -111
- package/webxr/VRButton.js +0 -111
- package/webxr/XRControllerModelFactory.cjs +0 -174
- package/webxr/XRControllerModelFactory.js +0 -174
- package/webxr/XREstimatedLight.cjs +0 -126
- package/webxr/XREstimatedLight.js +0 -126
- package/webxr/XRHandMeshModel.cjs +0 -82
- package/webxr/XRHandMeshModel.js +0 -82
- package/webxr/XRHandModelFactory.cjs +0 -61
- package/webxr/XRHandModelFactory.js +0 -61
- package/webxr/XRHandPrimitiveModel.cjs +0 -68
- package/webxr/XRHandPrimitiveModel.js +0 -68
package/loaders/3MFLoader.js
DELETED
|
@@ -1,854 +0,0 @@
|
|
|
1
|
-
import { Loader, FileLoader, TextureLoader, LoaderUtils, Color, Matrix4, RepeatWrapping, ClampToEdgeWrapping, MirroredRepeatWrapping, LinearFilter, LinearMipmapLinearFilter, NearestFilter, BufferGeometry, Float32BufferAttribute, Mesh, MeshPhongMaterial, BufferAttribute, Group, MeshStandardMaterial } from "three";
|
|
2
|
-
import { unzipSync } from "fflate";
|
|
3
|
-
class ThreeMFLoader extends Loader {
|
|
4
|
-
constructor(manager) {
|
|
5
|
-
super(manager);
|
|
6
|
-
this.availableExtensions = [];
|
|
7
|
-
}
|
|
8
|
-
load(url, onLoad, onProgress, onError) {
|
|
9
|
-
const scope = this;
|
|
10
|
-
const loader = new FileLoader(scope.manager);
|
|
11
|
-
loader.setPath(scope.path);
|
|
12
|
-
loader.setResponseType("arraybuffer");
|
|
13
|
-
loader.setRequestHeader(scope.requestHeader);
|
|
14
|
-
loader.setWithCredentials(scope.withCredentials);
|
|
15
|
-
loader.load(
|
|
16
|
-
url,
|
|
17
|
-
function(buffer) {
|
|
18
|
-
try {
|
|
19
|
-
onLoad(scope.parse(buffer));
|
|
20
|
-
} catch (e) {
|
|
21
|
-
if (onError) {
|
|
22
|
-
onError(e);
|
|
23
|
-
} else {
|
|
24
|
-
console.error(e);
|
|
25
|
-
}
|
|
26
|
-
scope.manager.itemError(url);
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
onProgress,
|
|
30
|
-
onError
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
parse(data) {
|
|
34
|
-
const scope = this;
|
|
35
|
-
const textureLoader = new TextureLoader(this.manager);
|
|
36
|
-
function loadDocument(data2) {
|
|
37
|
-
let zip = null;
|
|
38
|
-
let file = null;
|
|
39
|
-
let relsName;
|
|
40
|
-
let modelRelsName;
|
|
41
|
-
const modelPartNames = [];
|
|
42
|
-
const printTicketPartNames = [];
|
|
43
|
-
const texturesPartNames = [];
|
|
44
|
-
const otherPartNames = [];
|
|
45
|
-
let modelRels;
|
|
46
|
-
const modelParts = {};
|
|
47
|
-
const printTicketParts = {};
|
|
48
|
-
const texturesParts = {};
|
|
49
|
-
const otherParts = {};
|
|
50
|
-
try {
|
|
51
|
-
zip = unzipSync(new Uint8Array(data2));
|
|
52
|
-
} catch (e) {
|
|
53
|
-
if (e instanceof ReferenceError) {
|
|
54
|
-
console.error("THREE.3MFLoader: fflate missing and file is compressed.");
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
for (file in zip) {
|
|
59
|
-
if (file.match(/\_rels\/.rels$/)) {
|
|
60
|
-
relsName = file;
|
|
61
|
-
} else if (file.match(/3D\/_rels\/.*\.model\.rels$/)) {
|
|
62
|
-
modelRelsName = file;
|
|
63
|
-
} else if (file.match(/^3D\/.*\.model$/)) {
|
|
64
|
-
modelPartNames.push(file);
|
|
65
|
-
} else if (file.match(/^3D\/Metadata\/.*\.xml$/)) {
|
|
66
|
-
printTicketPartNames.push(file);
|
|
67
|
-
} else if (file.match(/^3D\/Textures?\/.*/)) {
|
|
68
|
-
texturesPartNames.push(file);
|
|
69
|
-
} else if (file.match(/^3D\/Other\/.*/)) {
|
|
70
|
-
otherPartNames.push(file);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
const relsView = zip[relsName];
|
|
74
|
-
const relsFileText = LoaderUtils.decodeText(relsView);
|
|
75
|
-
const rels = parseRelsXml(relsFileText);
|
|
76
|
-
if (modelRelsName) {
|
|
77
|
-
const relsView2 = zip[modelRelsName];
|
|
78
|
-
const relsFileText2 = LoaderUtils.decodeText(relsView2);
|
|
79
|
-
modelRels = parseRelsXml(relsFileText2);
|
|
80
|
-
}
|
|
81
|
-
for (let i = 0; i < modelPartNames.length; i++) {
|
|
82
|
-
const modelPart = modelPartNames[i];
|
|
83
|
-
const view = zip[modelPart];
|
|
84
|
-
const fileText = LoaderUtils.decodeText(view);
|
|
85
|
-
const xmlData = new DOMParser().parseFromString(fileText, "application/xml");
|
|
86
|
-
if (xmlData.documentElement.nodeName.toLowerCase() !== "model") {
|
|
87
|
-
console.error("THREE.3MFLoader: Error loading 3MF - no 3MF document found: ", modelPart);
|
|
88
|
-
}
|
|
89
|
-
const modelNode = xmlData.querySelector("model");
|
|
90
|
-
const extensions = {};
|
|
91
|
-
for (let i2 = 0; i2 < modelNode.attributes.length; i2++) {
|
|
92
|
-
const attr = modelNode.attributes[i2];
|
|
93
|
-
if (attr.name.match(/^xmlns:(.+)$/)) {
|
|
94
|
-
extensions[attr.value] = RegExp.$1;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
const modelData = parseModelNode(modelNode);
|
|
98
|
-
modelData["xml"] = modelNode;
|
|
99
|
-
if (0 < Object.keys(extensions).length) {
|
|
100
|
-
modelData["extensions"] = extensions;
|
|
101
|
-
}
|
|
102
|
-
modelParts[modelPart] = modelData;
|
|
103
|
-
}
|
|
104
|
-
for (let i = 0; i < texturesPartNames.length; i++) {
|
|
105
|
-
const texturesPartName = texturesPartNames[i];
|
|
106
|
-
texturesParts[texturesPartName] = zip[texturesPartName].buffer;
|
|
107
|
-
}
|
|
108
|
-
return {
|
|
109
|
-
rels,
|
|
110
|
-
modelRels,
|
|
111
|
-
model: modelParts,
|
|
112
|
-
printTicket: printTicketParts,
|
|
113
|
-
texture: texturesParts,
|
|
114
|
-
other: otherParts
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
function parseRelsXml(relsFileText) {
|
|
118
|
-
const relationships = [];
|
|
119
|
-
const relsXmlData = new DOMParser().parseFromString(relsFileText, "application/xml");
|
|
120
|
-
const relsNodes = relsXmlData.querySelectorAll("Relationship");
|
|
121
|
-
for (let i = 0; i < relsNodes.length; i++) {
|
|
122
|
-
const relsNode = relsNodes[i];
|
|
123
|
-
const relationship = {
|
|
124
|
-
target: relsNode.getAttribute("Target"),
|
|
125
|
-
//required
|
|
126
|
-
id: relsNode.getAttribute("Id"),
|
|
127
|
-
//required
|
|
128
|
-
type: relsNode.getAttribute("Type")
|
|
129
|
-
//required
|
|
130
|
-
};
|
|
131
|
-
relationships.push(relationship);
|
|
132
|
-
}
|
|
133
|
-
return relationships;
|
|
134
|
-
}
|
|
135
|
-
function parseMetadataNodes(metadataNodes) {
|
|
136
|
-
const metadataData = {};
|
|
137
|
-
for (let i = 0; i < metadataNodes.length; i++) {
|
|
138
|
-
const metadataNode = metadataNodes[i];
|
|
139
|
-
const name = metadataNode.getAttribute("name");
|
|
140
|
-
const validNames = [
|
|
141
|
-
"Title",
|
|
142
|
-
"Designer",
|
|
143
|
-
"Description",
|
|
144
|
-
"Copyright",
|
|
145
|
-
"LicenseTerms",
|
|
146
|
-
"Rating",
|
|
147
|
-
"CreationDate",
|
|
148
|
-
"ModificationDate"
|
|
149
|
-
];
|
|
150
|
-
if (0 <= validNames.indexOf(name)) {
|
|
151
|
-
metadataData[name] = metadataNode.textContent;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
return metadataData;
|
|
155
|
-
}
|
|
156
|
-
function parseBasematerialsNode(basematerialsNode) {
|
|
157
|
-
const basematerialsData = {
|
|
158
|
-
id: basematerialsNode.getAttribute("id"),
|
|
159
|
-
// required
|
|
160
|
-
basematerials: []
|
|
161
|
-
};
|
|
162
|
-
const basematerialNodes = basematerialsNode.querySelectorAll("base");
|
|
163
|
-
for (let i = 0; i < basematerialNodes.length; i++) {
|
|
164
|
-
const basematerialNode = basematerialNodes[i];
|
|
165
|
-
const basematerialData = parseBasematerialNode(basematerialNode);
|
|
166
|
-
basematerialData.index = i;
|
|
167
|
-
basematerialsData.basematerials.push(basematerialData);
|
|
168
|
-
}
|
|
169
|
-
return basematerialsData;
|
|
170
|
-
}
|
|
171
|
-
function parseTexture2DNode(texture2DNode) {
|
|
172
|
-
const texture2dData = {
|
|
173
|
-
id: texture2DNode.getAttribute("id"),
|
|
174
|
-
// required
|
|
175
|
-
path: texture2DNode.getAttribute("path"),
|
|
176
|
-
// required
|
|
177
|
-
contenttype: texture2DNode.getAttribute("contenttype"),
|
|
178
|
-
// required
|
|
179
|
-
tilestyleu: texture2DNode.getAttribute("tilestyleu"),
|
|
180
|
-
tilestylev: texture2DNode.getAttribute("tilestylev"),
|
|
181
|
-
filter: texture2DNode.getAttribute("filter")
|
|
182
|
-
};
|
|
183
|
-
return texture2dData;
|
|
184
|
-
}
|
|
185
|
-
function parseTextures2DGroupNode(texture2DGroupNode) {
|
|
186
|
-
const texture2DGroupData = {
|
|
187
|
-
id: texture2DGroupNode.getAttribute("id"),
|
|
188
|
-
// required
|
|
189
|
-
texid: texture2DGroupNode.getAttribute("texid"),
|
|
190
|
-
// required
|
|
191
|
-
displaypropertiesid: texture2DGroupNode.getAttribute("displaypropertiesid")
|
|
192
|
-
};
|
|
193
|
-
const tex2coordNodes = texture2DGroupNode.querySelectorAll("tex2coord");
|
|
194
|
-
const uvs = [];
|
|
195
|
-
for (let i = 0; i < tex2coordNodes.length; i++) {
|
|
196
|
-
const tex2coordNode = tex2coordNodes[i];
|
|
197
|
-
const u = tex2coordNode.getAttribute("u");
|
|
198
|
-
const v = tex2coordNode.getAttribute("v");
|
|
199
|
-
uvs.push(parseFloat(u), parseFloat(v));
|
|
200
|
-
}
|
|
201
|
-
texture2DGroupData["uvs"] = new Float32Array(uvs);
|
|
202
|
-
return texture2DGroupData;
|
|
203
|
-
}
|
|
204
|
-
function parseColorGroupNode(colorGroupNode) {
|
|
205
|
-
const colorGroupData = {
|
|
206
|
-
id: colorGroupNode.getAttribute("id"),
|
|
207
|
-
// required
|
|
208
|
-
displaypropertiesid: colorGroupNode.getAttribute("displaypropertiesid")
|
|
209
|
-
};
|
|
210
|
-
const colorNodes = colorGroupNode.querySelectorAll("color");
|
|
211
|
-
const colors = [];
|
|
212
|
-
const colorObject = new Color();
|
|
213
|
-
for (let i = 0; i < colorNodes.length; i++) {
|
|
214
|
-
const colorNode = colorNodes[i];
|
|
215
|
-
const color = colorNode.getAttribute("color");
|
|
216
|
-
colorObject.setStyle(color.substring(0, 7));
|
|
217
|
-
colorObject.convertSRGBToLinear();
|
|
218
|
-
colors.push(colorObject.r, colorObject.g, colorObject.b);
|
|
219
|
-
}
|
|
220
|
-
colorGroupData["colors"] = new Float32Array(colors);
|
|
221
|
-
return colorGroupData;
|
|
222
|
-
}
|
|
223
|
-
function parseMetallicDisplaypropertiesNode(metallicDisplaypropetiesNode) {
|
|
224
|
-
const metallicDisplaypropertiesData = {
|
|
225
|
-
id: metallicDisplaypropetiesNode.getAttribute("id")
|
|
226
|
-
// required
|
|
227
|
-
};
|
|
228
|
-
const metallicNodes = metallicDisplaypropetiesNode.querySelectorAll("pbmetallic");
|
|
229
|
-
const metallicData = [];
|
|
230
|
-
for (let i = 0; i < metallicNodes.length; i++) {
|
|
231
|
-
const metallicNode = metallicNodes[i];
|
|
232
|
-
metallicData.push({
|
|
233
|
-
name: metallicNode.getAttribute("name"),
|
|
234
|
-
// required
|
|
235
|
-
metallicness: parseFloat(metallicNode.getAttribute("metallicness")),
|
|
236
|
-
// required
|
|
237
|
-
roughness: parseFloat(metallicNode.getAttribute("roughness"))
|
|
238
|
-
// required
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
metallicDisplaypropertiesData.data = metallicData;
|
|
242
|
-
return metallicDisplaypropertiesData;
|
|
243
|
-
}
|
|
244
|
-
function parseBasematerialNode(basematerialNode) {
|
|
245
|
-
const basematerialData = {};
|
|
246
|
-
basematerialData["name"] = basematerialNode.getAttribute("name");
|
|
247
|
-
basematerialData["displaycolor"] = basematerialNode.getAttribute("displaycolor");
|
|
248
|
-
basematerialData["displaypropertiesid"] = basematerialNode.getAttribute("displaypropertiesid");
|
|
249
|
-
return basematerialData;
|
|
250
|
-
}
|
|
251
|
-
function parseMeshNode(meshNode) {
|
|
252
|
-
const meshData = {};
|
|
253
|
-
const vertices = [];
|
|
254
|
-
const vertexNodes = meshNode.querySelectorAll("vertices vertex");
|
|
255
|
-
for (let i = 0; i < vertexNodes.length; i++) {
|
|
256
|
-
const vertexNode = vertexNodes[i];
|
|
257
|
-
const x = vertexNode.getAttribute("x");
|
|
258
|
-
const y = vertexNode.getAttribute("y");
|
|
259
|
-
const z = vertexNode.getAttribute("z");
|
|
260
|
-
vertices.push(parseFloat(x), parseFloat(y), parseFloat(z));
|
|
261
|
-
}
|
|
262
|
-
meshData["vertices"] = new Float32Array(vertices);
|
|
263
|
-
const triangleProperties = [];
|
|
264
|
-
const triangles = [];
|
|
265
|
-
const triangleNodes = meshNode.querySelectorAll("triangles triangle");
|
|
266
|
-
for (let i = 0; i < triangleNodes.length; i++) {
|
|
267
|
-
const triangleNode = triangleNodes[i];
|
|
268
|
-
const v1 = triangleNode.getAttribute("v1");
|
|
269
|
-
const v2 = triangleNode.getAttribute("v2");
|
|
270
|
-
const v3 = triangleNode.getAttribute("v3");
|
|
271
|
-
const p1 = triangleNode.getAttribute("p1");
|
|
272
|
-
const p2 = triangleNode.getAttribute("p2");
|
|
273
|
-
const p3 = triangleNode.getAttribute("p3");
|
|
274
|
-
const pid = triangleNode.getAttribute("pid");
|
|
275
|
-
const triangleProperty = {};
|
|
276
|
-
triangleProperty["v1"] = parseInt(v1, 10);
|
|
277
|
-
triangleProperty["v2"] = parseInt(v2, 10);
|
|
278
|
-
triangleProperty["v3"] = parseInt(v3, 10);
|
|
279
|
-
triangles.push(triangleProperty["v1"], triangleProperty["v2"], triangleProperty["v3"]);
|
|
280
|
-
if (p1) {
|
|
281
|
-
triangleProperty["p1"] = parseInt(p1, 10);
|
|
282
|
-
}
|
|
283
|
-
if (p2) {
|
|
284
|
-
triangleProperty["p2"] = parseInt(p2, 10);
|
|
285
|
-
}
|
|
286
|
-
if (p3) {
|
|
287
|
-
triangleProperty["p3"] = parseInt(p3, 10);
|
|
288
|
-
}
|
|
289
|
-
if (pid) {
|
|
290
|
-
triangleProperty["pid"] = pid;
|
|
291
|
-
}
|
|
292
|
-
if (0 < Object.keys(triangleProperty).length) {
|
|
293
|
-
triangleProperties.push(triangleProperty);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
meshData["triangleProperties"] = triangleProperties;
|
|
297
|
-
meshData["triangles"] = new Uint32Array(triangles);
|
|
298
|
-
return meshData;
|
|
299
|
-
}
|
|
300
|
-
function parseComponentsNode(componentsNode) {
|
|
301
|
-
const components = [];
|
|
302
|
-
const componentNodes = componentsNode.querySelectorAll("component");
|
|
303
|
-
for (let i = 0; i < componentNodes.length; i++) {
|
|
304
|
-
const componentNode = componentNodes[i];
|
|
305
|
-
const componentData = parseComponentNode(componentNode);
|
|
306
|
-
components.push(componentData);
|
|
307
|
-
}
|
|
308
|
-
return components;
|
|
309
|
-
}
|
|
310
|
-
function parseComponentNode(componentNode) {
|
|
311
|
-
const componentData = {};
|
|
312
|
-
componentData["objectId"] = componentNode.getAttribute("objectid");
|
|
313
|
-
const transform = componentNode.getAttribute("transform");
|
|
314
|
-
if (transform) {
|
|
315
|
-
componentData["transform"] = parseTransform(transform);
|
|
316
|
-
}
|
|
317
|
-
return componentData;
|
|
318
|
-
}
|
|
319
|
-
function parseTransform(transform) {
|
|
320
|
-
const t = [];
|
|
321
|
-
transform.split(" ").forEach(function(s) {
|
|
322
|
-
t.push(parseFloat(s));
|
|
323
|
-
});
|
|
324
|
-
const matrix = new Matrix4();
|
|
325
|
-
matrix.set(t[0], t[3], t[6], t[9], t[1], t[4], t[7], t[10], t[2], t[5], t[8], t[11], 0, 0, 0, 1);
|
|
326
|
-
return matrix;
|
|
327
|
-
}
|
|
328
|
-
function parseObjectNode(objectNode) {
|
|
329
|
-
const objectData = {
|
|
330
|
-
type: objectNode.getAttribute("type")
|
|
331
|
-
};
|
|
332
|
-
const id = objectNode.getAttribute("id");
|
|
333
|
-
if (id) {
|
|
334
|
-
objectData["id"] = id;
|
|
335
|
-
}
|
|
336
|
-
const pid = objectNode.getAttribute("pid");
|
|
337
|
-
if (pid) {
|
|
338
|
-
objectData["pid"] = pid;
|
|
339
|
-
}
|
|
340
|
-
const pindex = objectNode.getAttribute("pindex");
|
|
341
|
-
if (pindex) {
|
|
342
|
-
objectData["pindex"] = pindex;
|
|
343
|
-
}
|
|
344
|
-
const thumbnail = objectNode.getAttribute("thumbnail");
|
|
345
|
-
if (thumbnail) {
|
|
346
|
-
objectData["thumbnail"] = thumbnail;
|
|
347
|
-
}
|
|
348
|
-
const partnumber = objectNode.getAttribute("partnumber");
|
|
349
|
-
if (partnumber) {
|
|
350
|
-
objectData["partnumber"] = partnumber;
|
|
351
|
-
}
|
|
352
|
-
const name = objectNode.getAttribute("name");
|
|
353
|
-
if (name) {
|
|
354
|
-
objectData["name"] = name;
|
|
355
|
-
}
|
|
356
|
-
const meshNode = objectNode.querySelector("mesh");
|
|
357
|
-
if (meshNode) {
|
|
358
|
-
objectData["mesh"] = parseMeshNode(meshNode);
|
|
359
|
-
}
|
|
360
|
-
const componentsNode = objectNode.querySelector("components");
|
|
361
|
-
if (componentsNode) {
|
|
362
|
-
objectData["components"] = parseComponentsNode(componentsNode);
|
|
363
|
-
}
|
|
364
|
-
return objectData;
|
|
365
|
-
}
|
|
366
|
-
function parseResourcesNode(resourcesNode) {
|
|
367
|
-
const resourcesData = {};
|
|
368
|
-
resourcesData["basematerials"] = {};
|
|
369
|
-
const basematerialsNodes = resourcesNode.querySelectorAll("basematerials");
|
|
370
|
-
for (let i = 0; i < basematerialsNodes.length; i++) {
|
|
371
|
-
const basematerialsNode = basematerialsNodes[i];
|
|
372
|
-
const basematerialsData = parseBasematerialsNode(basematerialsNode);
|
|
373
|
-
resourcesData["basematerials"][basematerialsData["id"]] = basematerialsData;
|
|
374
|
-
}
|
|
375
|
-
resourcesData["texture2d"] = {};
|
|
376
|
-
const textures2DNodes = resourcesNode.querySelectorAll("texture2d");
|
|
377
|
-
for (let i = 0; i < textures2DNodes.length; i++) {
|
|
378
|
-
const textures2DNode = textures2DNodes[i];
|
|
379
|
-
const texture2DData = parseTexture2DNode(textures2DNode);
|
|
380
|
-
resourcesData["texture2d"][texture2DData["id"]] = texture2DData;
|
|
381
|
-
}
|
|
382
|
-
resourcesData["colorgroup"] = {};
|
|
383
|
-
const colorGroupNodes = resourcesNode.querySelectorAll("colorgroup");
|
|
384
|
-
for (let i = 0; i < colorGroupNodes.length; i++) {
|
|
385
|
-
const colorGroupNode = colorGroupNodes[i];
|
|
386
|
-
const colorGroupData = parseColorGroupNode(colorGroupNode);
|
|
387
|
-
resourcesData["colorgroup"][colorGroupData["id"]] = colorGroupData;
|
|
388
|
-
}
|
|
389
|
-
resourcesData["pbmetallicdisplayproperties"] = {};
|
|
390
|
-
const pbmetallicdisplaypropertiesNodes = resourcesNode.querySelectorAll("pbmetallicdisplayproperties");
|
|
391
|
-
for (let i = 0; i < pbmetallicdisplaypropertiesNodes.length; i++) {
|
|
392
|
-
const pbmetallicdisplaypropertiesNode = pbmetallicdisplaypropertiesNodes[i];
|
|
393
|
-
const pbmetallicdisplaypropertiesData = parseMetallicDisplaypropertiesNode(pbmetallicdisplaypropertiesNode);
|
|
394
|
-
resourcesData["pbmetallicdisplayproperties"][pbmetallicdisplaypropertiesData["id"]] = pbmetallicdisplaypropertiesData;
|
|
395
|
-
}
|
|
396
|
-
resourcesData["texture2dgroup"] = {};
|
|
397
|
-
const textures2DGroupNodes = resourcesNode.querySelectorAll("texture2dgroup");
|
|
398
|
-
for (let i = 0; i < textures2DGroupNodes.length; i++) {
|
|
399
|
-
const textures2DGroupNode = textures2DGroupNodes[i];
|
|
400
|
-
const textures2DGroupData = parseTextures2DGroupNode(textures2DGroupNode);
|
|
401
|
-
resourcesData["texture2dgroup"][textures2DGroupData["id"]] = textures2DGroupData;
|
|
402
|
-
}
|
|
403
|
-
resourcesData["object"] = {};
|
|
404
|
-
const objectNodes = resourcesNode.querySelectorAll("object");
|
|
405
|
-
for (let i = 0; i < objectNodes.length; i++) {
|
|
406
|
-
const objectNode = objectNodes[i];
|
|
407
|
-
const objectData = parseObjectNode(objectNode);
|
|
408
|
-
resourcesData["object"][objectData["id"]] = objectData;
|
|
409
|
-
}
|
|
410
|
-
return resourcesData;
|
|
411
|
-
}
|
|
412
|
-
function parseBuildNode(buildNode) {
|
|
413
|
-
const buildData = [];
|
|
414
|
-
const itemNodes = buildNode.querySelectorAll("item");
|
|
415
|
-
for (let i = 0; i < itemNodes.length; i++) {
|
|
416
|
-
const itemNode = itemNodes[i];
|
|
417
|
-
const buildItem = {
|
|
418
|
-
objectId: itemNode.getAttribute("objectid")
|
|
419
|
-
};
|
|
420
|
-
const transform = itemNode.getAttribute("transform");
|
|
421
|
-
if (transform) {
|
|
422
|
-
buildItem["transform"] = parseTransform(transform);
|
|
423
|
-
}
|
|
424
|
-
buildData.push(buildItem);
|
|
425
|
-
}
|
|
426
|
-
return buildData;
|
|
427
|
-
}
|
|
428
|
-
function parseModelNode(modelNode) {
|
|
429
|
-
const modelData = { unit: modelNode.getAttribute("unit") || "millimeter" };
|
|
430
|
-
const metadataNodes = modelNode.querySelectorAll("metadata");
|
|
431
|
-
if (metadataNodes) {
|
|
432
|
-
modelData["metadata"] = parseMetadataNodes(metadataNodes);
|
|
433
|
-
}
|
|
434
|
-
const resourcesNode = modelNode.querySelector("resources");
|
|
435
|
-
if (resourcesNode) {
|
|
436
|
-
modelData["resources"] = parseResourcesNode(resourcesNode);
|
|
437
|
-
}
|
|
438
|
-
const buildNode = modelNode.querySelector("build");
|
|
439
|
-
if (buildNode) {
|
|
440
|
-
modelData["build"] = parseBuildNode(buildNode);
|
|
441
|
-
}
|
|
442
|
-
return modelData;
|
|
443
|
-
}
|
|
444
|
-
function buildTexture(texture2dgroup, objects2, modelData, textureData) {
|
|
445
|
-
const texid = texture2dgroup.texid;
|
|
446
|
-
const texture2ds = modelData.resources.texture2d;
|
|
447
|
-
const texture2d = texture2ds[texid];
|
|
448
|
-
if (texture2d) {
|
|
449
|
-
const data2 = textureData[texture2d.path];
|
|
450
|
-
const type = texture2d.contenttype;
|
|
451
|
-
const blob = new Blob([data2], { type });
|
|
452
|
-
const sourceURI = URL.createObjectURL(blob);
|
|
453
|
-
const texture = textureLoader.load(sourceURI, function() {
|
|
454
|
-
URL.revokeObjectURL(sourceURI);
|
|
455
|
-
});
|
|
456
|
-
if ("colorSpace" in texture)
|
|
457
|
-
texture.colorSpace = "srgb";
|
|
458
|
-
else
|
|
459
|
-
texture.encoding = 3001;
|
|
460
|
-
switch (texture2d.tilestyleu) {
|
|
461
|
-
case "wrap":
|
|
462
|
-
texture.wrapS = RepeatWrapping;
|
|
463
|
-
break;
|
|
464
|
-
case "mirror":
|
|
465
|
-
texture.wrapS = MirroredRepeatWrapping;
|
|
466
|
-
break;
|
|
467
|
-
case "none":
|
|
468
|
-
case "clamp":
|
|
469
|
-
texture.wrapS = ClampToEdgeWrapping;
|
|
470
|
-
break;
|
|
471
|
-
default:
|
|
472
|
-
texture.wrapS = RepeatWrapping;
|
|
473
|
-
}
|
|
474
|
-
switch (texture2d.tilestylev) {
|
|
475
|
-
case "wrap":
|
|
476
|
-
texture.wrapT = RepeatWrapping;
|
|
477
|
-
break;
|
|
478
|
-
case "mirror":
|
|
479
|
-
texture.wrapT = MirroredRepeatWrapping;
|
|
480
|
-
break;
|
|
481
|
-
case "none":
|
|
482
|
-
case "clamp":
|
|
483
|
-
texture.wrapT = ClampToEdgeWrapping;
|
|
484
|
-
break;
|
|
485
|
-
default:
|
|
486
|
-
texture.wrapT = RepeatWrapping;
|
|
487
|
-
}
|
|
488
|
-
switch (texture2d.filter) {
|
|
489
|
-
case "auto":
|
|
490
|
-
texture.magFilter = LinearFilter;
|
|
491
|
-
texture.minFilter = LinearMipmapLinearFilter;
|
|
492
|
-
break;
|
|
493
|
-
case "linear":
|
|
494
|
-
texture.magFilter = LinearFilter;
|
|
495
|
-
texture.minFilter = LinearFilter;
|
|
496
|
-
break;
|
|
497
|
-
case "nearest":
|
|
498
|
-
texture.magFilter = NearestFilter;
|
|
499
|
-
texture.minFilter = NearestFilter;
|
|
500
|
-
break;
|
|
501
|
-
default:
|
|
502
|
-
texture.magFilter = LinearFilter;
|
|
503
|
-
texture.minFilter = LinearMipmapLinearFilter;
|
|
504
|
-
}
|
|
505
|
-
return texture;
|
|
506
|
-
} else {
|
|
507
|
-
return null;
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
function buildBasematerialsMeshes(basematerials, triangleProperties, meshData, objects2, modelData, textureData, objectData) {
|
|
511
|
-
const objectPindex = objectData.pindex;
|
|
512
|
-
const materialMap = {};
|
|
513
|
-
for (let i = 0, l = triangleProperties.length; i < l; i++) {
|
|
514
|
-
const triangleProperty = triangleProperties[i];
|
|
515
|
-
const pindex = triangleProperty.p1 !== void 0 ? triangleProperty.p1 : objectPindex;
|
|
516
|
-
if (materialMap[pindex] === void 0)
|
|
517
|
-
materialMap[pindex] = [];
|
|
518
|
-
materialMap[pindex].push(triangleProperty);
|
|
519
|
-
}
|
|
520
|
-
const keys = Object.keys(materialMap);
|
|
521
|
-
const meshes = [];
|
|
522
|
-
for (let i = 0, l = keys.length; i < l; i++) {
|
|
523
|
-
const materialIndex = keys[i];
|
|
524
|
-
const trianglePropertiesProps = materialMap[materialIndex];
|
|
525
|
-
const basematerialData = basematerials.basematerials[materialIndex];
|
|
526
|
-
const material = getBuild(basematerialData, objects2, modelData, textureData, objectData, buildBasematerial);
|
|
527
|
-
const geometry = new BufferGeometry();
|
|
528
|
-
const positionData = [];
|
|
529
|
-
const vertices = meshData.vertices;
|
|
530
|
-
for (let j = 0, jl = trianglePropertiesProps.length; j < jl; j++) {
|
|
531
|
-
const triangleProperty = trianglePropertiesProps[j];
|
|
532
|
-
positionData.push(vertices[triangleProperty.v1 * 3 + 0]);
|
|
533
|
-
positionData.push(vertices[triangleProperty.v1 * 3 + 1]);
|
|
534
|
-
positionData.push(vertices[triangleProperty.v1 * 3 + 2]);
|
|
535
|
-
positionData.push(vertices[triangleProperty.v2 * 3 + 0]);
|
|
536
|
-
positionData.push(vertices[triangleProperty.v2 * 3 + 1]);
|
|
537
|
-
positionData.push(vertices[triangleProperty.v2 * 3 + 2]);
|
|
538
|
-
positionData.push(vertices[triangleProperty.v3 * 3 + 0]);
|
|
539
|
-
positionData.push(vertices[triangleProperty.v3 * 3 + 1]);
|
|
540
|
-
positionData.push(vertices[triangleProperty.v3 * 3 + 2]);
|
|
541
|
-
}
|
|
542
|
-
geometry.setAttribute("position", new Float32BufferAttribute(positionData, 3));
|
|
543
|
-
const mesh = new Mesh(geometry, material);
|
|
544
|
-
meshes.push(mesh);
|
|
545
|
-
}
|
|
546
|
-
return meshes;
|
|
547
|
-
}
|
|
548
|
-
function buildTexturedMesh(texture2dgroup, triangleProperties, meshData, objects2, modelData, textureData, objectData) {
|
|
549
|
-
const geometry = new BufferGeometry();
|
|
550
|
-
const positionData = [];
|
|
551
|
-
const uvData = [];
|
|
552
|
-
const vertices = meshData.vertices;
|
|
553
|
-
const uvs = texture2dgroup.uvs;
|
|
554
|
-
for (let i = 0, l = triangleProperties.length; i < l; i++) {
|
|
555
|
-
const triangleProperty = triangleProperties[i];
|
|
556
|
-
positionData.push(vertices[triangleProperty.v1 * 3 + 0]);
|
|
557
|
-
positionData.push(vertices[triangleProperty.v1 * 3 + 1]);
|
|
558
|
-
positionData.push(vertices[triangleProperty.v1 * 3 + 2]);
|
|
559
|
-
positionData.push(vertices[triangleProperty.v2 * 3 + 0]);
|
|
560
|
-
positionData.push(vertices[triangleProperty.v2 * 3 + 1]);
|
|
561
|
-
positionData.push(vertices[triangleProperty.v2 * 3 + 2]);
|
|
562
|
-
positionData.push(vertices[triangleProperty.v3 * 3 + 0]);
|
|
563
|
-
positionData.push(vertices[triangleProperty.v3 * 3 + 1]);
|
|
564
|
-
positionData.push(vertices[triangleProperty.v3 * 3 + 2]);
|
|
565
|
-
uvData.push(uvs[triangleProperty.p1 * 2 + 0]);
|
|
566
|
-
uvData.push(uvs[triangleProperty.p1 * 2 + 1]);
|
|
567
|
-
uvData.push(uvs[triangleProperty.p2 * 2 + 0]);
|
|
568
|
-
uvData.push(uvs[triangleProperty.p2 * 2 + 1]);
|
|
569
|
-
uvData.push(uvs[triangleProperty.p3 * 2 + 0]);
|
|
570
|
-
uvData.push(uvs[triangleProperty.p3 * 2 + 1]);
|
|
571
|
-
}
|
|
572
|
-
geometry.setAttribute("position", new Float32BufferAttribute(positionData, 3));
|
|
573
|
-
geometry.setAttribute("uv", new Float32BufferAttribute(uvData, 2));
|
|
574
|
-
const texture = getBuild(texture2dgroup, objects2, modelData, textureData, objectData, buildTexture);
|
|
575
|
-
const material = new MeshPhongMaterial({ map: texture, flatShading: true });
|
|
576
|
-
const mesh = new Mesh(geometry, material);
|
|
577
|
-
return mesh;
|
|
578
|
-
}
|
|
579
|
-
function buildVertexColorMesh(colorgroup, triangleProperties, meshData, objects2, modelData, objectData) {
|
|
580
|
-
const geometry = new BufferGeometry();
|
|
581
|
-
const positionData = [];
|
|
582
|
-
const colorData = [];
|
|
583
|
-
const vertices = meshData.vertices;
|
|
584
|
-
const colors = colorgroup.colors;
|
|
585
|
-
for (let i = 0, l = triangleProperties.length; i < l; i++) {
|
|
586
|
-
const triangleProperty = triangleProperties[i];
|
|
587
|
-
const v1 = triangleProperty.v1;
|
|
588
|
-
const v2 = triangleProperty.v2;
|
|
589
|
-
const v3 = triangleProperty.v3;
|
|
590
|
-
positionData.push(vertices[v1 * 3 + 0]);
|
|
591
|
-
positionData.push(vertices[v1 * 3 + 1]);
|
|
592
|
-
positionData.push(vertices[v1 * 3 + 2]);
|
|
593
|
-
positionData.push(vertices[v2 * 3 + 0]);
|
|
594
|
-
positionData.push(vertices[v2 * 3 + 1]);
|
|
595
|
-
positionData.push(vertices[v2 * 3 + 2]);
|
|
596
|
-
positionData.push(vertices[v3 * 3 + 0]);
|
|
597
|
-
positionData.push(vertices[v3 * 3 + 1]);
|
|
598
|
-
positionData.push(vertices[v3 * 3 + 2]);
|
|
599
|
-
const p1 = triangleProperty.p1 !== void 0 ? triangleProperty.p1 : objectData.pindex;
|
|
600
|
-
const p2 = triangleProperty.p2 !== void 0 ? triangleProperty.p2 : p1;
|
|
601
|
-
const p3 = triangleProperty.p3 !== void 0 ? triangleProperty.p3 : p1;
|
|
602
|
-
colorData.push(colors[p1 * 3 + 0]);
|
|
603
|
-
colorData.push(colors[p1 * 3 + 1]);
|
|
604
|
-
colorData.push(colors[p1 * 3 + 2]);
|
|
605
|
-
colorData.push(colors[p2 * 3 + 0]);
|
|
606
|
-
colorData.push(colors[p2 * 3 + 1]);
|
|
607
|
-
colorData.push(colors[p2 * 3 + 2]);
|
|
608
|
-
colorData.push(colors[p3 * 3 + 0]);
|
|
609
|
-
colorData.push(colors[p3 * 3 + 1]);
|
|
610
|
-
colorData.push(colors[p3 * 3 + 2]);
|
|
611
|
-
}
|
|
612
|
-
geometry.setAttribute("position", new Float32BufferAttribute(positionData, 3));
|
|
613
|
-
geometry.setAttribute("color", new Float32BufferAttribute(colorData, 3));
|
|
614
|
-
const material = new MeshPhongMaterial({ vertexColors: true, flatShading: true });
|
|
615
|
-
const mesh = new Mesh(geometry, material);
|
|
616
|
-
return mesh;
|
|
617
|
-
}
|
|
618
|
-
function buildDefaultMesh(meshData) {
|
|
619
|
-
const geometry = new BufferGeometry();
|
|
620
|
-
geometry.setIndex(new BufferAttribute(meshData["triangles"], 1));
|
|
621
|
-
geometry.setAttribute("position", new BufferAttribute(meshData["vertices"], 3));
|
|
622
|
-
const material = new MeshPhongMaterial({ color: 11184895, flatShading: true });
|
|
623
|
-
const mesh = new Mesh(geometry, material);
|
|
624
|
-
return mesh;
|
|
625
|
-
}
|
|
626
|
-
function buildMeshes(resourceMap, meshData, objects2, modelData, textureData, objectData) {
|
|
627
|
-
const keys = Object.keys(resourceMap);
|
|
628
|
-
const meshes = [];
|
|
629
|
-
for (let i = 0, il = keys.length; i < il; i++) {
|
|
630
|
-
const resourceId = keys[i];
|
|
631
|
-
const triangleProperties = resourceMap[resourceId];
|
|
632
|
-
const resourceType = getResourceType(resourceId, modelData);
|
|
633
|
-
switch (resourceType) {
|
|
634
|
-
case "material":
|
|
635
|
-
const basematerials = modelData.resources.basematerials[resourceId];
|
|
636
|
-
const newMeshes = buildBasematerialsMeshes(
|
|
637
|
-
basematerials,
|
|
638
|
-
triangleProperties,
|
|
639
|
-
meshData,
|
|
640
|
-
objects2,
|
|
641
|
-
modelData,
|
|
642
|
-
textureData,
|
|
643
|
-
objectData
|
|
644
|
-
);
|
|
645
|
-
for (let j = 0, jl = newMeshes.length; j < jl; j++) {
|
|
646
|
-
meshes.push(newMeshes[j]);
|
|
647
|
-
}
|
|
648
|
-
break;
|
|
649
|
-
case "texture":
|
|
650
|
-
const texture2dgroup = modelData.resources.texture2dgroup[resourceId];
|
|
651
|
-
meshes.push(
|
|
652
|
-
buildTexturedMesh(
|
|
653
|
-
texture2dgroup,
|
|
654
|
-
triangleProperties,
|
|
655
|
-
meshData,
|
|
656
|
-
objects2,
|
|
657
|
-
modelData,
|
|
658
|
-
textureData,
|
|
659
|
-
objectData
|
|
660
|
-
)
|
|
661
|
-
);
|
|
662
|
-
break;
|
|
663
|
-
case "vertexColors":
|
|
664
|
-
const colorgroup = modelData.resources.colorgroup[resourceId];
|
|
665
|
-
meshes.push(buildVertexColorMesh(colorgroup, triangleProperties, meshData, objects2, modelData, objectData));
|
|
666
|
-
break;
|
|
667
|
-
case "default":
|
|
668
|
-
meshes.push(buildDefaultMesh(meshData));
|
|
669
|
-
break;
|
|
670
|
-
default:
|
|
671
|
-
console.error("THREE.3MFLoader: Unsupported resource type.");
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
return meshes;
|
|
675
|
-
}
|
|
676
|
-
function getResourceType(pid, modelData) {
|
|
677
|
-
if (modelData.resources.texture2dgroup[pid] !== void 0) {
|
|
678
|
-
return "texture";
|
|
679
|
-
} else if (modelData.resources.basematerials[pid] !== void 0) {
|
|
680
|
-
return "material";
|
|
681
|
-
} else if (modelData.resources.colorgroup[pid] !== void 0) {
|
|
682
|
-
return "vertexColors";
|
|
683
|
-
} else if (pid === "default") {
|
|
684
|
-
return "default";
|
|
685
|
-
} else {
|
|
686
|
-
return void 0;
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
function analyzeObject(modelData, meshData, objectData) {
|
|
690
|
-
const resourceMap = {};
|
|
691
|
-
const triangleProperties = meshData["triangleProperties"];
|
|
692
|
-
const objectPid = objectData.pid;
|
|
693
|
-
for (let i = 0, l = triangleProperties.length; i < l; i++) {
|
|
694
|
-
const triangleProperty = triangleProperties[i];
|
|
695
|
-
let pid = triangleProperty.pid !== void 0 ? triangleProperty.pid : objectPid;
|
|
696
|
-
if (pid === void 0)
|
|
697
|
-
pid = "default";
|
|
698
|
-
if (resourceMap[pid] === void 0)
|
|
699
|
-
resourceMap[pid] = [];
|
|
700
|
-
resourceMap[pid].push(triangleProperty);
|
|
701
|
-
}
|
|
702
|
-
return resourceMap;
|
|
703
|
-
}
|
|
704
|
-
function buildGroup(meshData, objects2, modelData, textureData, objectData) {
|
|
705
|
-
const group = new Group();
|
|
706
|
-
const resourceMap = analyzeObject(modelData, meshData, objectData);
|
|
707
|
-
const meshes = buildMeshes(resourceMap, meshData, objects2, modelData, textureData, objectData);
|
|
708
|
-
for (let i = 0, l = meshes.length; i < l; i++) {
|
|
709
|
-
group.add(meshes[i]);
|
|
710
|
-
}
|
|
711
|
-
return group;
|
|
712
|
-
}
|
|
713
|
-
function applyExtensions(extensions, meshData, modelXml) {
|
|
714
|
-
if (!extensions) {
|
|
715
|
-
return;
|
|
716
|
-
}
|
|
717
|
-
const availableExtensions = [];
|
|
718
|
-
const keys = Object.keys(extensions);
|
|
719
|
-
for (let i = 0; i < keys.length; i++) {
|
|
720
|
-
const ns = keys[i];
|
|
721
|
-
for (let j = 0; j < scope.availableExtensions.length; j++) {
|
|
722
|
-
const extension = scope.availableExtensions[j];
|
|
723
|
-
if (extension.ns === ns) {
|
|
724
|
-
availableExtensions.push(extension);
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
for (let i = 0; i < availableExtensions.length; i++) {
|
|
729
|
-
const extension = availableExtensions[i];
|
|
730
|
-
extension.apply(modelXml, extensions[extension["ns"]], meshData);
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
function getBuild(data2, objects2, modelData, textureData, objectData, builder) {
|
|
734
|
-
if (data2.build !== void 0)
|
|
735
|
-
return data2.build;
|
|
736
|
-
data2.build = builder(data2, objects2, modelData, textureData, objectData);
|
|
737
|
-
return data2.build;
|
|
738
|
-
}
|
|
739
|
-
function buildBasematerial(materialData, objects2, modelData) {
|
|
740
|
-
let material;
|
|
741
|
-
const displaypropertiesid = materialData.displaypropertiesid;
|
|
742
|
-
const pbmetallicdisplayproperties = modelData.resources.pbmetallicdisplayproperties;
|
|
743
|
-
if (displaypropertiesid !== null && pbmetallicdisplayproperties[displaypropertiesid] !== void 0) {
|
|
744
|
-
const pbmetallicdisplayproperty = pbmetallicdisplayproperties[displaypropertiesid];
|
|
745
|
-
const metallicData = pbmetallicdisplayproperty.data[materialData.index];
|
|
746
|
-
material = new MeshStandardMaterial({
|
|
747
|
-
flatShading: true,
|
|
748
|
-
roughness: metallicData.roughness,
|
|
749
|
-
metalness: metallicData.metallicness
|
|
750
|
-
});
|
|
751
|
-
} else {
|
|
752
|
-
material = new MeshPhongMaterial({ flatShading: true });
|
|
753
|
-
}
|
|
754
|
-
material.name = materialData.name;
|
|
755
|
-
const displaycolor = materialData.displaycolor;
|
|
756
|
-
const color = displaycolor.substring(0, 7);
|
|
757
|
-
material.color.setStyle(color);
|
|
758
|
-
material.color.convertSRGBToLinear();
|
|
759
|
-
if (displaycolor.length === 9) {
|
|
760
|
-
material.opacity = parseInt(displaycolor.charAt(7) + displaycolor.charAt(8), 16) / 255;
|
|
761
|
-
}
|
|
762
|
-
return material;
|
|
763
|
-
}
|
|
764
|
-
function buildComposite(compositeData, objects2, modelData, textureData) {
|
|
765
|
-
const composite = new Group();
|
|
766
|
-
for (let j = 0; j < compositeData.length; j++) {
|
|
767
|
-
const component = compositeData[j];
|
|
768
|
-
let build2 = objects2[component.objectId];
|
|
769
|
-
if (build2 === void 0) {
|
|
770
|
-
buildObject(component.objectId, objects2, modelData, textureData);
|
|
771
|
-
build2 = objects2[component.objectId];
|
|
772
|
-
}
|
|
773
|
-
const object3D = build2.clone();
|
|
774
|
-
const transform = component.transform;
|
|
775
|
-
if (transform) {
|
|
776
|
-
object3D.applyMatrix4(transform);
|
|
777
|
-
}
|
|
778
|
-
composite.add(object3D);
|
|
779
|
-
}
|
|
780
|
-
return composite;
|
|
781
|
-
}
|
|
782
|
-
function buildObject(objectId, objects2, modelData, textureData) {
|
|
783
|
-
const objectData = modelData["resources"]["object"][objectId];
|
|
784
|
-
if (objectData["mesh"]) {
|
|
785
|
-
const meshData = objectData["mesh"];
|
|
786
|
-
const extensions = modelData["extensions"];
|
|
787
|
-
const modelXml = modelData["xml"];
|
|
788
|
-
applyExtensions(extensions, meshData, modelXml);
|
|
789
|
-
objects2[objectData.id] = getBuild(meshData, objects2, modelData, textureData, objectData, buildGroup);
|
|
790
|
-
} else {
|
|
791
|
-
const compositeData = objectData["components"];
|
|
792
|
-
objects2[objectData.id] = getBuild(compositeData, objects2, modelData, textureData, objectData, buildComposite);
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
function buildObjects(data3mf2) {
|
|
796
|
-
const modelsData = data3mf2.model;
|
|
797
|
-
const modelRels = data3mf2.modelRels;
|
|
798
|
-
const objects2 = {};
|
|
799
|
-
const modelsKeys = Object.keys(modelsData);
|
|
800
|
-
const textureData = {};
|
|
801
|
-
if (modelRels) {
|
|
802
|
-
for (let i = 0, l = modelRels.length; i < l; i++) {
|
|
803
|
-
const modelRel = modelRels[i];
|
|
804
|
-
const textureKey = modelRel.target.substring(1);
|
|
805
|
-
if (data3mf2.texture[textureKey]) {
|
|
806
|
-
textureData[modelRel.target] = data3mf2.texture[textureKey];
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
for (let i = 0; i < modelsKeys.length; i++) {
|
|
811
|
-
const modelsKey = modelsKeys[i];
|
|
812
|
-
const modelData = modelsData[modelsKey];
|
|
813
|
-
const objectIds = Object.keys(modelData["resources"]["object"]);
|
|
814
|
-
for (let j = 0; j < objectIds.length; j++) {
|
|
815
|
-
const objectId = objectIds[j];
|
|
816
|
-
buildObject(objectId, objects2, modelData, textureData);
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
return objects2;
|
|
820
|
-
}
|
|
821
|
-
function fetch3DModelPart(rels) {
|
|
822
|
-
for (let i = 0; i < rels.length; i++) {
|
|
823
|
-
const rel = rels[i];
|
|
824
|
-
const extension = rel.target.split(".").pop();
|
|
825
|
-
if (extension.toLowerCase() === "model")
|
|
826
|
-
return rel;
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
function build(objects2, data3mf2) {
|
|
830
|
-
const group = new Group();
|
|
831
|
-
const relationship = fetch3DModelPart(data3mf2["rels"]);
|
|
832
|
-
const buildData = data3mf2.model[relationship["target"].substring(1)]["build"];
|
|
833
|
-
for (let i = 0; i < buildData.length; i++) {
|
|
834
|
-
const buildItem = buildData[i];
|
|
835
|
-
const object3D = objects2[buildItem["objectId"]];
|
|
836
|
-
const transform = buildItem["transform"];
|
|
837
|
-
if (transform) {
|
|
838
|
-
object3D.applyMatrix4(transform);
|
|
839
|
-
}
|
|
840
|
-
group.add(object3D);
|
|
841
|
-
}
|
|
842
|
-
return group;
|
|
843
|
-
}
|
|
844
|
-
const data3mf = loadDocument(data);
|
|
845
|
-
const objects = buildObjects(data3mf);
|
|
846
|
-
return build(objects, data3mf);
|
|
847
|
-
}
|
|
848
|
-
addExtension(extension) {
|
|
849
|
-
this.availableExtensions.push(extension);
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
export {
|
|
853
|
-
ThreeMFLoader
|
|
854
|
-
};
|