@needle-tools/three 0.145.4 → 0.146.2
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/README.md +1 -1
- package/build/three.cjs +32586 -35951
- package/build/three.js +32600 -35965
- package/build/three.min.js +6 -7
- package/build/three.module.js +1547 -1154
- package/examples/js/animation/AnimationClipCreator.js +0 -8
- package/examples/js/animation/CCDIKSolver.js +49 -66
- package/examples/js/animation/MMDAnimationHelper.js +66 -137
- package/examples/js/animation/MMDPhysics.js +70 -134
- package/examples/js/cameras/CinematicCamera.js +33 -22
- package/examples/js/controls/ArcballControls.js +138 -405
- package/examples/js/controls/DragControls.js +8 -33
- package/examples/js/controls/FirstPersonControls.js +32 -54
- package/examples/js/controls/FlyControls.js +29 -55
- package/examples/js/controls/OrbitControls.js +85 -95
- package/examples/js/controls/PointerLockControls.js +5 -14
- package/examples/js/controls/TrackballControls.js +33 -86
- package/examples/js/controls/TransformControls.js +84 -169
- package/examples/js/csm/CSM.js +4 -39
- package/examples/js/csm/CSMFrustum.js +3 -9
- package/examples/js/csm/CSMHelper.js +24 -4
- package/examples/js/csm/CSMShader.js +2 -6
- package/examples/js/curves/CurveExtras.js +27 -27
- package/examples/js/curves/NURBSCurve.js +4 -16
- package/examples/js/curves/NURBSSurface.js +3 -9
- package/examples/js/curves/NURBSUtils.js +8 -45
- package/examples/js/effects/AnaglyphEffect.js +4 -18
- package/examples/js/effects/AsciiEffect.js +32 -31
- package/examples/js/effects/OutlineEffect.js +26 -30
- package/examples/js/effects/ParallaxBarrierEffect.js +0 -13
- package/examples/js/effects/PeppersGhostEffect.js +12 -39
- package/examples/js/effects/StereoEffect.js +0 -4
- package/examples/js/environments/RoomEnvironment.js +12 -10
- package/examples/js/exporters/ColladaExporter.js +48 -65
- package/examples/js/exporters/DRACOExporter.js +22 -22
- package/examples/js/exporters/EXRExporter.js +15 -18
- package/examples/js/exporters/GLTFExporter.js +143 -261
- package/examples/js/exporters/MMDExporter.js +5 -12
- package/examples/js/exporters/OBJExporter.js +42 -33
- package/examples/js/exporters/PLYExporter.js +38 -33
- package/examples/js/exporters/STLExporter.js +5 -7
- package/examples/js/exporters/USDZExporter.js +110 -25
- package/examples/js/geometries/BoxLineGeometry.js +0 -1
- package/examples/js/geometries/ConvexGeometry.js +11 -6
- package/examples/js/geometries/DecalGeometry.js +53 -20
- package/examples/js/geometries/LightningStrike.js +54 -67
- package/examples/js/geometries/ParametricGeometries.js +8 -7
- package/examples/js/geometries/ParametricGeometry.js +25 -12
- package/examples/js/geometries/RoundedBoxGeometry.js +21 -19
- package/examples/js/geometries/TeapotGeometry.js +54 -50
- package/examples/js/geometries/TextGeometry.js +6 -4
- package/examples/js/helpers/LightProbeHelper.js +1 -2
- package/examples/js/helpers/OctreeHelper.js +22 -20
- package/examples/js/helpers/PositionalAudioHelper.js +8 -6
- package/examples/js/helpers/RectAreaLightHelper.js +6 -7
- package/examples/js/helpers/VertexNormalsHelper.js +15 -13
- package/examples/js/helpers/VertexTangentsHelper.js +15 -9
- package/examples/js/helpers/ViewHelper.js +31 -16
- package/examples/js/interactive/HTMLMesh.js +22 -33
- package/examples/js/interactive/InteractiveGroup.js +6 -12
- package/examples/js/interactive/SelectionBox.js +3 -70
- package/examples/js/interactive/SelectionHelper.js +0 -8
- package/examples/js/lights/LightProbeGenerator.js +32 -39
- package/examples/js/lights/RectAreaLightUniformsLib.js +5 -1
- package/examples/js/lines/LineGeometry.js +3 -5
- package/examples/js/lines/LineMaterial.js +4 -11
- package/examples/js/lines/LineSegments2.js +38 -89
- package/examples/js/lines/LineSegmentsGeometry.js +7 -28
- package/examples/js/lines/Wireframe.js +2 -7
- package/examples/js/lines/WireframeGeometry2.js +3 -1
- package/examples/js/loaders/3DMLoader.js +58 -155
- package/examples/js/loaders/3MFLoader.js +72 -106
- package/examples/js/loaders/AMFLoader.js +0 -25
- package/examples/js/loaders/BVHLoader.js +44 -43
- package/examples/js/loaders/BasisTextureLoader.js +16 -46
- package/examples/js/loaders/ColladaLoader.js +201 -359
- package/examples/js/loaders/DDSLoader.js +24 -25
- package/examples/js/loaders/DRACOLoader.js +29 -66
- package/examples/js/loaders/EXRLoader.js +67 -164
- package/examples/js/loaders/FBXLoader.js +286 -441
- package/examples/js/loaders/FontLoader.js +6 -15
- package/examples/js/loaders/GCodeLoader.js +15 -16
- package/examples/js/loaders/GLTFLoader.js +354 -405
- package/examples/js/loaders/HDRCubeTextureLoader.js +0 -6
- package/examples/js/loaders/KMZLoader.js +3 -7
- package/examples/js/loaders/KTXLoader.js +12 -30
- package/examples/js/loaders/LDrawLoader.js +178 -289
- package/examples/js/loaders/LUT3dlLoader.js +7 -11
- package/examples/js/loaders/LUTCubeLoader.js +0 -8
- package/examples/js/loaders/LWOLoader.js +59 -124
- package/examples/js/loaders/LogLuvLoader.js +27 -77
- package/examples/js/loaders/LottieLoader.js +4 -4
- package/examples/js/loaders/MD2Loader.js +26 -27
- package/examples/js/loaders/MDDLoader.js +6 -10
- package/examples/js/loaders/MMDLoader.js +180 -189
- package/examples/js/loaders/MTLLoader.js +18 -47
- package/examples/js/loaders/MaterialXLoader.js +392 -0
- package/examples/js/loaders/NRRDLoader.js +44 -84
- package/examples/js/loaders/OBJLoader.js +50 -65
- package/examples/js/loaders/PCDLoader.js +34 -29
- package/examples/js/loaders/PDBLoader.js +17 -13
- package/examples/js/loaders/PLYLoader.js +9 -39
- package/examples/js/loaders/PRWMLoader.js +11 -22
- package/examples/js/loaders/PVRLoader.js +7 -16
- package/examples/js/loaders/RGBELoader.js +36 -61
- package/examples/js/loaders/RGBMLoader.js +26 -87
- package/examples/js/loaders/STLLoader.js +20 -27
- package/examples/js/loaders/SVGLoader.js +361 -233
- package/examples/js/loaders/TDSLoader.js +81 -118
- package/examples/js/loaders/TGALoader.js +39 -41
- package/examples/js/loaders/TIFFLoader.js +0 -1
- package/examples/js/loaders/TTFLoader.js +0 -8
- package/examples/js/loaders/TiltLoader.js +14 -15
- package/examples/js/loaders/VOXLoader.js +8 -16
- package/examples/js/loaders/VRMLLoader.js +243 -340
- package/examples/js/loaders/VTKLoader.js +101 -118
- package/examples/js/loaders/XYZLoader.js +2 -4
- package/examples/js/loaders/lwo/IFFParser.js +55 -136
- package/examples/js/loaders/lwo/LWO2Parser.js +32 -83
- package/examples/js/loaders/lwo/LWO3Parser.js +31 -73
- package/examples/js/materials/MeshGouraudMaterial.js +15 -13
- package/examples/js/math/Capsule.js +0 -17
- package/examples/js/math/ColorConverter.js +3 -3
- package/examples/js/math/ConvexHull.js +183 -139
- package/examples/js/math/ImprovedNoise.js +1 -1
- package/examples/js/math/Lut.js +8 -15
- package/examples/js/math/MeshSurfaceSampler.js +6 -28
- package/examples/js/math/OBB.js +90 -49
- package/examples/js/math/Octree.js +2 -57
- package/examples/js/math/SimplexNoise.js +74 -88
- package/examples/js/misc/ConvexObjectBreaker.js +37 -48
- package/examples/js/misc/GPUComputationRenderer.js +14 -18
- package/examples/js/misc/Gyroscope.js +5 -9
- package/examples/js/misc/MD2Character.js +14 -23
- package/examples/js/misc/MD2CharacterComplex.js +73 -54
- package/examples/js/misc/MorphAnimMesh.js +0 -6
- package/examples/js/misc/MorphBlendMesh.js +3 -30
- package/examples/js/misc/ProgressiveLightMap.js +47 -43
- package/examples/js/misc/RollerCoaster.js +17 -24
- package/examples/js/misc/TubePainter.js +18 -12
- package/examples/js/misc/Volume.js +16 -45
- package/examples/js/misc/VolumeSlice.js +14 -24
- package/examples/js/modifiers/CurveModifier.js +19 -21
- package/examples/js/modifiers/EdgeSplitModifier.js +0 -30
- package/examples/js/modifiers/SimplifyModifier.js +56 -59
- package/examples/js/modifiers/TessellateModifier.js +2 -9
- package/examples/js/objects/GroundProjectedEnv.js +2 -14
- package/examples/js/objects/Lensflare.js +47 -38
- package/examples/js/objects/LightningStorm.js +10 -13
- package/examples/js/objects/MarchingCubes.js +80 -59
- package/examples/js/objects/Reflector.js +22 -20
- package/examples/js/objects/ReflectorForSSRPass.js +19 -23
- package/examples/js/objects/Refractor.js +52 -30
- package/examples/js/objects/ShadowMesh.js +1 -2
- package/examples/js/objects/Sky.js +2 -7
- package/examples/js/objects/Water.js +23 -18
- package/examples/js/objects/Water2.js +20 -19
- package/examples/js/physics/AmmoPhysics.js +23 -20
- package/examples/js/physics/OimoPhysics.js +19 -17
- package/examples/js/postprocessing/AdaptiveToneMappingPass.js +13 -20
- package/examples/js/postprocessing/AfterimagePass.js +19 -12
- package/examples/js/postprocessing/BloomPass.js +38 -17
- package/examples/js/postprocessing/BokehPass.js +29 -12
- package/examples/js/postprocessing/ClearPass.js +1 -6
- package/examples/js/postprocessing/CubeTexturePass.js +12 -9
- package/examples/js/postprocessing/DotScreenPass.js +7 -5
- package/examples/js/postprocessing/EffectComposer.js +25 -32
- package/examples/js/postprocessing/FilmPass.js +7 -5
- package/examples/js/postprocessing/GlitchPass.js +10 -11
- package/examples/js/postprocessing/HalftonePass.js +9 -9
- package/examples/js/postprocessing/LUTPass.js +2 -15
- package/examples/js/postprocessing/MaskPass.js +20 -17
- package/examples/js/postprocessing/OutlinePass.js +45 -36
- package/examples/js/postprocessing/Pass.js +11 -14
- package/examples/js/postprocessing/RenderPass.js +3 -7
- package/examples/js/postprocessing/SAOPass.js +40 -32
- package/examples/js/postprocessing/SMAAPass.js +34 -17
- package/examples/js/postprocessing/SSAARenderPass.js +14 -14
- package/examples/js/postprocessing/SSAOPass.js +56 -42
- package/examples/js/postprocessing/SSRPass.js +78 -61
- package/examples/js/postprocessing/SavePass.js +14 -6
- package/examples/js/postprocessing/ShaderPass.js +9 -8
- package/examples/js/postprocessing/TAARenderPass.js +11 -9
- package/examples/js/postprocessing/TexturePass.js +7 -4
- package/examples/js/postprocessing/UnrealBloomPass.js +43 -25
- package/examples/js/renderers/CSS2DRenderer.js +2 -21
- package/examples/js/renderers/CSS3DRenderer.js +3 -24
- package/examples/js/renderers/Projector.js +29 -85
- package/examples/js/renderers/SVGRenderer.js +4 -50
- package/examples/js/shaders/ACESFilmicToneMappingShader.js +3 -6
- package/examples/js/shaders/AfterimageShader.js +3 -6
- package/examples/js/shaders/BasicShader.js +3 -6
- package/examples/js/shaders/BleachBypassShader.js +3 -6
- package/examples/js/shaders/BlendShader.js +3 -6
- package/examples/js/shaders/BokehShader.js +3 -6
- package/examples/js/shaders/BokehShader2.js +4 -13
- package/examples/js/shaders/BrightnessContrastShader.js +3 -6
- package/examples/js/shaders/ColorCorrectionShader.js +2 -6
- package/examples/js/shaders/ColorifyShader.js +2 -6
- package/examples/js/shaders/ConvolutionShader.js +5 -10
- package/examples/js/shaders/CopyShader.js +3 -6
- package/examples/js/shaders/DOFMipMapShader.js +3 -6
- package/examples/js/shaders/DepthLimitedBlurShader.js +2 -9
- package/examples/js/shaders/DigitalGlitch.js +3 -6
- package/examples/js/shaders/DotScreenShader.js +2 -6
- package/examples/js/shaders/FXAAShader.js +1 -3
- package/examples/js/shaders/FilmShader.js +3 -6
- package/examples/js/shaders/FocusShader.js +3 -6
- package/examples/js/shaders/FreiChenShader.js +2 -6
- package/examples/js/shaders/GammaCorrectionShader.js +3 -6
- package/examples/js/shaders/GodRaysShader.js +11 -24
- package/examples/js/shaders/HalftoneShader.js +3 -6
- package/examples/js/shaders/HorizontalBlurShader.js +3 -6
- package/examples/js/shaders/HorizontalTiltShiftShader.js +3 -6
- package/examples/js/shaders/HueSaturationShader.js +3 -6
- package/examples/js/shaders/KaleidoShader.js +3 -6
- package/examples/js/shaders/LuminosityHighPassShader.js +2 -6
- package/examples/js/shaders/LuminosityShader.js +3 -6
- package/examples/js/shaders/MMDToonShader.js +2 -6
- package/examples/js/shaders/MirrorShader.js +3 -6
- package/examples/js/shaders/NormalMapShader.js +2 -6
- package/examples/js/shaders/RGBShiftShader.js +3 -6
- package/examples/js/shaders/SAOShader.js +2 -6
- package/examples/js/shaders/SMAAShader.js +6 -18
- package/examples/js/shaders/SSAOShader.js +2 -6
- package/examples/js/shaders/SSRShader.js +6 -18
- package/examples/js/shaders/SepiaShader.js +3 -6
- package/examples/js/shaders/SobelOperatorShader.js +2 -6
- package/examples/js/shaders/TechnicolorShader.js +3 -6
- package/examples/js/shaders/ToneMapShader.js +3 -6
- package/examples/js/shaders/ToonShader.js +8 -24
- package/examples/js/shaders/TriangleBlurShader.js +2 -6
- package/examples/js/shaders/UnpackDepthRGBAShader.js +3 -6
- package/examples/js/shaders/VelocityShader.js +126 -0
- package/examples/js/shaders/VerticalBlurShader.js +3 -6
- package/examples/js/shaders/VerticalTiltShiftShader.js +3 -6
- package/examples/js/shaders/VignetteShader.js +3 -6
- package/examples/js/shaders/VolumeShader.js +2 -6
- package/examples/js/shaders/WaterRefractionShader.js +2 -6
- package/examples/js/textures/FlakesTexture.js +0 -1
- package/examples/js/utils/BufferGeometryUtils.js +234 -168
- package/examples/js/utils/CameraUtils.js +5 -20
- package/examples/js/utils/GPUStatsPanel.js +3 -12
- package/examples/js/utils/GeometryCompressionUtils.js +19 -44
- package/examples/js/utils/GeometryUtils.js +13 -18
- package/examples/js/utils/LDrawUtils.js +8 -11
- package/examples/js/utils/PackedPhongMaterial.js +6 -4
- package/examples/js/utils/SceneUtils.js +117 -6
- package/examples/js/utils/ShadowMapViewer.js +17 -14
- package/examples/js/utils/SkeletonUtils.js +13 -27
- package/examples/js/utils/UVsDebug.js +20 -12
- package/examples/js/utils/WorkerPool.js +1 -11
- package/examples/jsm/animation/CCDIKSolver.js +1 -1
- package/examples/jsm/capabilities/WebGPU.js +3 -1
- package/examples/jsm/controls/OrbitControls.js +44 -4
- package/examples/jsm/exporters/GLTFExporter.js +17 -131
- package/examples/jsm/exporters/USDZExporter.js +75 -19
- package/examples/jsm/interactive/HTMLMesh.js +2 -0
- package/examples/jsm/libs/lottie_canvas.module.js +14844 -0
- package/examples/jsm/loaders/3DMLoader.js +1 -2
- package/examples/jsm/loaders/ColladaLoader.js +28 -0
- package/examples/jsm/loaders/FBXLoader.js +16 -2
- package/examples/jsm/loaders/GLTFLoader.js +204 -377
- package/examples/jsm/loaders/KTX2Loader.js +68 -29
- package/examples/jsm/loaders/LDrawLoader.js +14 -13
- package/examples/jsm/loaders/LottieLoader.js +4 -2
- package/examples/jsm/loaders/MaterialXLoader.js +728 -0
- package/examples/jsm/loaders/PCDLoader.js +1 -1
- package/examples/jsm/loaders/PLYLoader.js +68 -16
- package/examples/jsm/loaders/SVGLoader.js +227 -14
- package/examples/jsm/loaders/USDZLoader.js +31 -16
- package/examples/jsm/nodes/Nodes.js +14 -2
- package/examples/jsm/nodes/accessors/Object3DNode.js +1 -1
- package/examples/jsm/nodes/accessors/PositionNode.js +6 -0
- package/examples/jsm/nodes/accessors/ReferenceNode.js +1 -1
- package/examples/jsm/nodes/accessors/SkinningNode.js +1 -1
- package/examples/jsm/nodes/core/Node.js +1 -1
- package/examples/jsm/nodes/core/NodeBuilder.js +36 -4
- package/examples/jsm/nodes/core/NodeFrame.js +2 -2
- package/examples/jsm/nodes/core/NodeVarying.js +7 -4
- package/examples/jsm/nodes/core/VaryingNode.js +6 -4
- package/examples/jsm/nodes/core/constants.js +13 -13
- package/examples/jsm/nodes/display/PosterizeNode.js +25 -0
- package/examples/jsm/nodes/display/ViewportNode.js +106 -0
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +1 -1
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +1 -1
- package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +3 -1
- package/examples/jsm/nodes/materials/Materials.js +9 -7
- package/examples/jsm/nodes/materials/NodeMaterial.js +9 -1
- package/examples/jsm/nodes/materialx/MaterialXNodes.js +6 -2
- package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +18 -0
- package/examples/jsm/nodes/math/MathNode.js +5 -0
- package/examples/jsm/nodes/math/OperatorNode.js +6 -1
- package/examples/jsm/nodes/shadernode/ShaderNode.js +26 -13
- package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +2 -0
- package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +18 -0
- package/examples/jsm/nodes/utils/EquirectUVNode.js +27 -0
- package/examples/jsm/nodes/utils/JoinNode.js +8 -2
- package/examples/jsm/nodes/utils/MatcapUVNode.js +2 -4
- package/examples/jsm/nodes/utils/MaxMipLevelNode.js +1 -1
- package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +8 -10
- package/examples/jsm/nodes/utils/TimerNode.js +1 -1
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +51 -0
- package/examples/jsm/postprocessing/AfterimagePass.js +17 -4
- package/examples/jsm/postprocessing/BloomPass.js +22 -3
- package/examples/jsm/postprocessing/BokehPass.js +18 -4
- package/examples/jsm/postprocessing/CubeTexturePass.js +12 -5
- package/examples/jsm/postprocessing/DotScreenPass.js +8 -0
- package/examples/jsm/postprocessing/EffectComposer.js +9 -0
- package/examples/jsm/postprocessing/FilmPass.js +8 -0
- package/examples/jsm/postprocessing/GlitchPass.js +13 -1
- package/examples/jsm/postprocessing/HalftonePass.js +8 -0
- package/examples/jsm/postprocessing/OutlinePass.js +10 -0
- package/examples/jsm/postprocessing/Pass.js +2 -0
- package/examples/jsm/postprocessing/RenderPixelatedPass.js +234 -0
- package/examples/jsm/postprocessing/SAOPass.js +20 -0
- package/examples/jsm/postprocessing/SMAAPass.js +16 -0
- package/examples/jsm/postprocessing/SSAARenderPass.js +4 -0
- package/examples/jsm/postprocessing/SavePass.js +17 -1
- package/examples/jsm/postprocessing/ShaderPass.js +8 -0
- package/examples/jsm/postprocessing/TAARenderPass.js +9 -0
- package/examples/jsm/postprocessing/TexturePass.js +8 -0
- package/examples/jsm/postprocessing/UnrealBloomPass.js +16 -0
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +39 -16
- package/examples/jsm/renderers/webgpu/WebGPUAnimation.js +58 -0
- package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +63 -5
- package/examples/jsm/renderers/webgpu/WebGPUBackground.js +36 -7
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +47 -12
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +35 -5
- package/examples/jsm/shaders/MMDToonShader.js +0 -2
- package/examples/jsm/shaders/VelocityShader.js +128 -0
- package/examples/jsm/utils/BufferGeometryUtils.js +130 -6
- package/examples/jsm/utils/SceneUtils.js +129 -4
- package/examples/jsm/utils/TextureUtils.js +85 -0
- package/examples/jsm/webxr/OculusHandModel.js +1 -1
- package/examples/jsm/webxr/XRHandMeshModel.js +6 -3
- package/package.json +11 -12
- package/src/Three.js +1 -0
- package/src/audio/AudioContext.js +5 -5
- package/src/cameras/CubeCamera.js +14 -14
- package/src/constants.js +1 -1
- package/src/core/InstancedBufferGeometry.js +1 -7
- package/src/extras/Earcut.js +67 -67
- package/src/helpers/DirectionalLightHelper.js +5 -1
- package/src/helpers/HemisphereLightHelper.js +4 -1
- package/src/helpers/PointLightHelper.js +2 -1
- package/src/helpers/SpotLightHelper.js +4 -2
- package/src/lights/PointLight.js +2 -2
- package/src/lights/SpotLight.js +2 -2
- package/src/loaders/FileLoader.js +4 -1
- package/src/loaders/ObjectLoader.js +5 -1
- package/src/materials/Material.js +1 -1
- package/src/math/Color.js +5 -5
- package/src/math/Matrix3.js +53 -18
- package/src/math/Ray.js +2 -5
- package/src/math/Sphere.js +19 -26
- package/src/objects/InstancedMesh.js +7 -0
- package/src/objects/LOD.js +25 -6
- package/src/renderers/WebGL3DRenderTarget.js +1 -1
- package/src/renderers/WebGLArrayRenderTarget.js +1 -1
- package/src/renderers/WebGLCubeRenderTarget.js +1 -1
- package/src/renderers/WebGLMultipleRenderTargets.js +1 -1
- package/src/renderers/WebGLRenderTarget.js +1 -1
- package/src/renderers/WebGLRenderer.js +36 -62
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +0 -4
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +0 -2
- package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +0 -2
- package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +0 -2
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk.js +3 -0
- package/src/renderers/shaders/ShaderLib/background.glsl.js +7 -2
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +62 -0
- package/src/renderers/shaders/ShaderLib/cube.glsl.js +4 -6
- package/src/renderers/shaders/ShaderLib.js +20 -6
- package/src/renderers/shaders/UniformsLib.js +1 -1
- package/src/renderers/shaders/UniformsUtils.js +15 -0
- package/src/renderers/webgl/WebGLAttributes.js +2 -0
- package/src/renderers/webgl/WebGLBackground.js +15 -7
- package/src/renderers/webgl/WebGLLights.js +0 -4
- package/src/renderers/webgl/WebGLMaterials.js +2 -1
- package/src/renderers/webgl/WebGLShadowMap.js +3 -1
- package/src/renderers/webgl/WebGLState.js +31 -1
- package/src/renderers/webgl/WebGLTextures.js +71 -18
- package/src/renderers/webgl/WebGLUniforms.js +116 -20
- package/src/renderers/webgl/WebGLUtils.js +1 -1
- package/src/renderers/webxr/WebXRController.js +46 -13
- package/src/renderers/webxr/WebXRManager.js +85 -3
- package/src/scenes/Scene.js +8 -0
- package/src/textures/CompressedArrayTexture.js +18 -0
- package/examples/js/libs/lottie_canvas.js +0 -12751
- package/examples/js/shaders/PixelShader.js +0 -51
- package/examples/jsm/shaders/PixelShader.js +0 -44
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
this.availableExtensions = [];
|
|
27
27
|
|
|
28
28
|
}
|
|
29
|
-
|
|
30
29
|
load( url, onLoad, onProgress, onError ) {
|
|
31
30
|
|
|
32
31
|
const scope = this;
|
|
@@ -60,12 +59,10 @@
|
|
|
60
59
|
}, onProgress, onError );
|
|
61
60
|
|
|
62
61
|
}
|
|
63
|
-
|
|
64
62
|
parse( data ) {
|
|
65
63
|
|
|
66
64
|
const scope = this;
|
|
67
65
|
const textureLoader = new THREE.TextureLoader( this.manager );
|
|
68
|
-
|
|
69
66
|
function loadDocument( data ) {
|
|
70
67
|
|
|
71
68
|
let zip = null;
|
|
@@ -78,7 +75,6 @@
|
|
|
78
75
|
const modelParts = {};
|
|
79
76
|
const printTicketParts = {};
|
|
80
77
|
const texturesParts = {};
|
|
81
|
-
|
|
82
78
|
try {
|
|
83
79
|
|
|
84
80
|
zip = fflate.unzipSync( new Uint8Array( data ) ); // eslint-disable-line no-undef
|
|
@@ -114,12 +110,15 @@
|
|
|
114
110
|
|
|
115
111
|
}
|
|
116
112
|
|
|
117
|
-
}
|
|
113
|
+
}
|
|
118
114
|
|
|
115
|
+
//
|
|
119
116
|
|
|
120
117
|
const relsView = zip[ relsName ];
|
|
121
118
|
const relsFileText = THREE.LoaderUtils.decodeText( relsView );
|
|
122
|
-
const rels = parseRelsXml( relsFileText );
|
|
119
|
+
const rels = parseRelsXml( relsFileText );
|
|
120
|
+
|
|
121
|
+
//
|
|
123
122
|
|
|
124
123
|
if ( modelRelsName ) {
|
|
125
124
|
|
|
@@ -127,8 +126,9 @@
|
|
|
127
126
|
const relsFileText = THREE.LoaderUtils.decodeText( relsView );
|
|
128
127
|
modelRels = parseRelsXml( relsFileText );
|
|
129
128
|
|
|
130
|
-
}
|
|
129
|
+
}
|
|
131
130
|
|
|
131
|
+
//
|
|
132
132
|
|
|
133
133
|
for ( let i = 0; i < modelPartNames.length; i ++ ) {
|
|
134
134
|
|
|
@@ -136,7 +136,6 @@
|
|
|
136
136
|
const view = zip[ modelPart ];
|
|
137
137
|
const fileText = THREE.LoaderUtils.decodeText( view );
|
|
138
138
|
const xmlData = new DOMParser().parseFromString( fileText, 'application/xml' );
|
|
139
|
-
|
|
140
139
|
if ( xmlData.documentElement.nodeName.toLowerCase() !== 'model' ) {
|
|
141
140
|
|
|
142
141
|
console.error( 'THREE.3MFLoader: Error loading 3MF - no 3MF document found: ', modelPart );
|
|
@@ -145,11 +144,9 @@
|
|
|
145
144
|
|
|
146
145
|
const modelNode = xmlData.querySelector( 'model' );
|
|
147
146
|
const extensions = {};
|
|
148
|
-
|
|
149
147
|
for ( let i = 0; i < modelNode.attributes.length; i ++ ) {
|
|
150
148
|
|
|
151
149
|
const attr = modelNode.attributes[ i ];
|
|
152
|
-
|
|
153
150
|
if ( attr.name.match( /^xmlns:(.+)$/ ) ) {
|
|
154
151
|
|
|
155
152
|
extensions[ attr.value ] = RegExp.$1;
|
|
@@ -160,7 +157,6 @@
|
|
|
160
157
|
|
|
161
158
|
const modelData = parseModelNode( modelNode );
|
|
162
159
|
modelData[ 'xml' ] = modelNode;
|
|
163
|
-
|
|
164
160
|
if ( 0 < Object.keys( extensions ).length ) {
|
|
165
161
|
|
|
166
162
|
modelData[ 'extensions' ] = extensions;
|
|
@@ -169,8 +165,9 @@
|
|
|
169
165
|
|
|
170
166
|
modelParts[ modelPart ] = modelData;
|
|
171
167
|
|
|
172
|
-
}
|
|
168
|
+
}
|
|
173
169
|
|
|
170
|
+
//
|
|
174
171
|
|
|
175
172
|
for ( let i = 0; i < texturesPartNames.length; i ++ ) {
|
|
176
173
|
|
|
@@ -194,7 +191,6 @@
|
|
|
194
191
|
const relationships = [];
|
|
195
192
|
const relsXmlData = new DOMParser().parseFromString( relsFileText, 'application/xml' );
|
|
196
193
|
const relsNodes = relsXmlData.querySelectorAll( 'Relationship' );
|
|
197
|
-
|
|
198
194
|
for ( let i = 0; i < relsNodes.length; i ++ ) {
|
|
199
195
|
|
|
200
196
|
const relsNode = relsNodes[ i ];
|
|
@@ -204,8 +200,8 @@
|
|
|
204
200
|
id: relsNode.getAttribute( 'Id' ),
|
|
205
201
|
//required
|
|
206
202
|
type: relsNode.getAttribute( 'Type' ) //required
|
|
207
|
-
|
|
208
203
|
};
|
|
204
|
+
|
|
209
205
|
relationships.push( relationship );
|
|
210
206
|
|
|
211
207
|
}
|
|
@@ -217,13 +213,11 @@
|
|
|
217
213
|
function parseMetadataNodes( metadataNodes ) {
|
|
218
214
|
|
|
219
215
|
const metadataData = {};
|
|
220
|
-
|
|
221
216
|
for ( let i = 0; i < metadataNodes.length; i ++ ) {
|
|
222
217
|
|
|
223
218
|
const metadataNode = metadataNodes[ i ];
|
|
224
219
|
const name = metadataNode.getAttribute( 'name' );
|
|
225
220
|
const validNames = [ 'Title', 'Designer', 'Description', 'Copyright', 'LicenseTerms', 'Rating', 'CreationDate', 'ModificationDate' ];
|
|
226
|
-
|
|
227
221
|
if ( 0 <= validNames.indexOf( name ) ) {
|
|
228
222
|
|
|
229
223
|
metadataData[ name ] = metadataNode.textContent;
|
|
@@ -244,13 +238,11 @@
|
|
|
244
238
|
basematerials: []
|
|
245
239
|
};
|
|
246
240
|
const basematerialNodes = basematerialsNode.querySelectorAll( 'base' );
|
|
247
|
-
|
|
248
241
|
for ( let i = 0; i < basematerialNodes.length; i ++ ) {
|
|
249
242
|
|
|
250
243
|
const basematerialNode = basematerialNodes[ i ];
|
|
251
244
|
const basematerialData = parseBasematerialNode( basematerialNode );
|
|
252
245
|
basematerialData.index = i; // the order and count of the material nodes form an implicit 0-based index
|
|
253
|
-
|
|
254
246
|
basematerialsData.basematerials.push( basematerialData );
|
|
255
247
|
|
|
256
248
|
}
|
|
@@ -287,7 +279,6 @@
|
|
|
287
279
|
};
|
|
288
280
|
const tex2coordNodes = texture2DGroupNode.querySelectorAll( 'tex2coord' );
|
|
289
281
|
const uvs = [];
|
|
290
|
-
|
|
291
282
|
for ( let i = 0; i < tex2coordNodes.length; i ++ ) {
|
|
292
283
|
|
|
293
284
|
const tex2coordNode = tex2coordNodes[ i ];
|
|
@@ -312,7 +303,6 @@
|
|
|
312
303
|
const colorNodes = colorGroupNode.querySelectorAll( 'color' );
|
|
313
304
|
const colors = [];
|
|
314
305
|
const colorObject = new THREE.Color();
|
|
315
|
-
|
|
316
306
|
for ( let i = 0; i < colorNodes.length; i ++ ) {
|
|
317
307
|
|
|
318
308
|
const colorNode = colorNodes[ i ];
|
|
@@ -333,11 +323,10 @@
|
|
|
333
323
|
|
|
334
324
|
const metallicDisplaypropertiesData = {
|
|
335
325
|
id: metallicDisplaypropetiesNode.getAttribute( 'id' ) // required
|
|
336
|
-
|
|
337
326
|
};
|
|
327
|
+
|
|
338
328
|
const metallicNodes = metallicDisplaypropetiesNode.querySelectorAll( 'pbmetallic' );
|
|
339
329
|
const metallicData = [];
|
|
340
|
-
|
|
341
330
|
for ( let i = 0; i < metallicNodes.length; i ++ ) {
|
|
342
331
|
|
|
343
332
|
const metallicNode = metallicNodes[ i ];
|
|
@@ -347,7 +336,6 @@
|
|
|
347
336
|
metallicness: parseFloat( metallicNode.getAttribute( 'metallicness' ) ),
|
|
348
337
|
// required
|
|
349
338
|
roughness: parseFloat( metallicNode.getAttribute( 'roughness' ) ) // required
|
|
350
|
-
|
|
351
339
|
} );
|
|
352
340
|
|
|
353
341
|
}
|
|
@@ -361,9 +349,7 @@
|
|
|
361
349
|
|
|
362
350
|
const basematerialData = {};
|
|
363
351
|
basematerialData[ 'name' ] = basematerialNode.getAttribute( 'name' ); // required
|
|
364
|
-
|
|
365
352
|
basematerialData[ 'displaycolor' ] = basematerialNode.getAttribute( 'displaycolor' ); // required
|
|
366
|
-
|
|
367
353
|
basematerialData[ 'displaypropertiesid' ] = basematerialNode.getAttribute( 'displaypropertiesid' );
|
|
368
354
|
return basematerialData;
|
|
369
355
|
|
|
@@ -374,7 +360,6 @@
|
|
|
374
360
|
const meshData = {};
|
|
375
361
|
const vertices = [];
|
|
376
362
|
const vertexNodes = meshNode.querySelectorAll( 'vertices vertex' );
|
|
377
|
-
|
|
378
363
|
for ( let i = 0; i < vertexNodes.length; i ++ ) {
|
|
379
364
|
|
|
380
365
|
const vertexNode = vertexNodes[ i ];
|
|
@@ -389,7 +374,6 @@
|
|
|
389
374
|
const triangleProperties = [];
|
|
390
375
|
const triangles = [];
|
|
391
376
|
const triangleNodes = meshNode.querySelectorAll( 'triangles triangle' );
|
|
392
|
-
|
|
393
377
|
for ( let i = 0; i < triangleNodes.length; i ++ ) {
|
|
394
378
|
|
|
395
379
|
const triangleNode = triangleNodes[ i ];
|
|
@@ -404,7 +388,9 @@
|
|
|
404
388
|
triangleProperty[ 'v1' ] = parseInt( v1, 10 );
|
|
405
389
|
triangleProperty[ 'v2' ] = parseInt( v2, 10 );
|
|
406
390
|
triangleProperty[ 'v3' ] = parseInt( v3, 10 );
|
|
407
|
-
triangles.push( triangleProperty[ 'v1' ], triangleProperty[ 'v2' ], triangleProperty[ 'v3' ] );
|
|
391
|
+
triangles.push( triangleProperty[ 'v1' ], triangleProperty[ 'v2' ], triangleProperty[ 'v3' ] );
|
|
392
|
+
|
|
393
|
+
// optional
|
|
408
394
|
|
|
409
395
|
if ( p1 ) {
|
|
410
396
|
|
|
@@ -448,7 +434,6 @@
|
|
|
448
434
|
|
|
449
435
|
const components = [];
|
|
450
436
|
const componentNodes = componentsNode.querySelectorAll( 'component' );
|
|
451
|
-
|
|
452
437
|
for ( let i = 0; i < componentNodes.length; i ++ ) {
|
|
453
438
|
|
|
454
439
|
const componentNode = componentNodes[ i ];
|
|
@@ -467,7 +452,6 @@
|
|
|
467
452
|
componentData[ 'objectId' ] = componentNode.getAttribute( 'objectid' ); // required
|
|
468
453
|
|
|
469
454
|
const transform = componentNode.getAttribute( 'transform' );
|
|
470
|
-
|
|
471
455
|
if ( transform ) {
|
|
472
456
|
|
|
473
457
|
componentData[ 'transform' ] = parseTransform( transform );
|
|
@@ -498,7 +482,6 @@
|
|
|
498
482
|
type: objectNode.getAttribute( 'type' )
|
|
499
483
|
};
|
|
500
484
|
const id = objectNode.getAttribute( 'id' );
|
|
501
|
-
|
|
502
485
|
if ( id ) {
|
|
503
486
|
|
|
504
487
|
objectData[ 'id' ] = id;
|
|
@@ -506,7 +489,6 @@
|
|
|
506
489
|
}
|
|
507
490
|
|
|
508
491
|
const pid = objectNode.getAttribute( 'pid' );
|
|
509
|
-
|
|
510
492
|
if ( pid ) {
|
|
511
493
|
|
|
512
494
|
objectData[ 'pid' ] = pid;
|
|
@@ -514,7 +496,6 @@
|
|
|
514
496
|
}
|
|
515
497
|
|
|
516
498
|
const pindex = objectNode.getAttribute( 'pindex' );
|
|
517
|
-
|
|
518
499
|
if ( pindex ) {
|
|
519
500
|
|
|
520
501
|
objectData[ 'pindex' ] = pindex;
|
|
@@ -522,7 +503,6 @@
|
|
|
522
503
|
}
|
|
523
504
|
|
|
524
505
|
const thumbnail = objectNode.getAttribute( 'thumbnail' );
|
|
525
|
-
|
|
526
506
|
if ( thumbnail ) {
|
|
527
507
|
|
|
528
508
|
objectData[ 'thumbnail' ] = thumbnail;
|
|
@@ -530,7 +510,6 @@
|
|
|
530
510
|
}
|
|
531
511
|
|
|
532
512
|
const partnumber = objectNode.getAttribute( 'partnumber' );
|
|
533
|
-
|
|
534
513
|
if ( partnumber ) {
|
|
535
514
|
|
|
536
515
|
objectData[ 'partnumber' ] = partnumber;
|
|
@@ -538,7 +517,6 @@
|
|
|
538
517
|
}
|
|
539
518
|
|
|
540
519
|
const name = objectNode.getAttribute( 'name' );
|
|
541
|
-
|
|
542
520
|
if ( name ) {
|
|
543
521
|
|
|
544
522
|
objectData[ 'name' ] = name;
|
|
@@ -546,7 +524,6 @@
|
|
|
546
524
|
}
|
|
547
525
|
|
|
548
526
|
const meshNode = objectNode.querySelector( 'mesh' );
|
|
549
|
-
|
|
550
527
|
if ( meshNode ) {
|
|
551
528
|
|
|
552
529
|
objectData[ 'mesh' ] = parseMeshNode( meshNode );
|
|
@@ -554,7 +531,6 @@
|
|
|
554
531
|
}
|
|
555
532
|
|
|
556
533
|
const componentsNode = objectNode.querySelector( 'components' );
|
|
557
|
-
|
|
558
534
|
if ( componentsNode ) {
|
|
559
535
|
|
|
560
536
|
objectData[ 'components' ] = parseComponentsNode( componentsNode );
|
|
@@ -570,67 +546,66 @@
|
|
|
570
546
|
const resourcesData = {};
|
|
571
547
|
resourcesData[ 'basematerials' ] = {};
|
|
572
548
|
const basematerialsNodes = resourcesNode.querySelectorAll( 'basematerials' );
|
|
573
|
-
|
|
574
549
|
for ( let i = 0; i < basematerialsNodes.length; i ++ ) {
|
|
575
550
|
|
|
576
551
|
const basematerialsNode = basematerialsNodes[ i ];
|
|
577
552
|
const basematerialsData = parseBasematerialsNode( basematerialsNode );
|
|
578
553
|
resourcesData[ 'basematerials' ][ basematerialsData[ 'id' ] ] = basematerialsData;
|
|
579
554
|
|
|
580
|
-
}
|
|
555
|
+
}
|
|
581
556
|
|
|
557
|
+
//
|
|
582
558
|
|
|
583
559
|
resourcesData[ 'texture2d' ] = {};
|
|
584
560
|
const textures2DNodes = resourcesNode.querySelectorAll( 'texture2d' );
|
|
585
|
-
|
|
586
561
|
for ( let i = 0; i < textures2DNodes.length; i ++ ) {
|
|
587
562
|
|
|
588
563
|
const textures2DNode = textures2DNodes[ i ];
|
|
589
564
|
const texture2DData = parseTexture2DNode( textures2DNode );
|
|
590
565
|
resourcesData[ 'texture2d' ][ texture2DData[ 'id' ] ] = texture2DData;
|
|
591
566
|
|
|
592
|
-
}
|
|
567
|
+
}
|
|
593
568
|
|
|
569
|
+
//
|
|
594
570
|
|
|
595
571
|
resourcesData[ 'colorgroup' ] = {};
|
|
596
572
|
const colorGroupNodes = resourcesNode.querySelectorAll( 'colorgroup' );
|
|
597
|
-
|
|
598
573
|
for ( let i = 0; i < colorGroupNodes.length; i ++ ) {
|
|
599
574
|
|
|
600
575
|
const colorGroupNode = colorGroupNodes[ i ];
|
|
601
576
|
const colorGroupData = parseColorGroupNode( colorGroupNode );
|
|
602
577
|
resourcesData[ 'colorgroup' ][ colorGroupData[ 'id' ] ] = colorGroupData;
|
|
603
578
|
|
|
604
|
-
}
|
|
579
|
+
}
|
|
605
580
|
|
|
581
|
+
//
|
|
606
582
|
|
|
607
583
|
resourcesData[ 'pbmetallicdisplayproperties' ] = {};
|
|
608
584
|
const pbmetallicdisplaypropertiesNodes = resourcesNode.querySelectorAll( 'pbmetallicdisplayproperties' );
|
|
609
|
-
|
|
610
585
|
for ( let i = 0; i < pbmetallicdisplaypropertiesNodes.length; i ++ ) {
|
|
611
586
|
|
|
612
587
|
const pbmetallicdisplaypropertiesNode = pbmetallicdisplaypropertiesNodes[ i ];
|
|
613
588
|
const pbmetallicdisplaypropertiesData = parseMetallicDisplaypropertiesNode( pbmetallicdisplaypropertiesNode );
|
|
614
589
|
resourcesData[ 'pbmetallicdisplayproperties' ][ pbmetallicdisplaypropertiesData[ 'id' ] ] = pbmetallicdisplaypropertiesData;
|
|
615
590
|
|
|
616
|
-
}
|
|
591
|
+
}
|
|
617
592
|
|
|
593
|
+
//
|
|
618
594
|
|
|
619
595
|
resourcesData[ 'texture2dgroup' ] = {};
|
|
620
596
|
const textures2DGroupNodes = resourcesNode.querySelectorAll( 'texture2dgroup' );
|
|
621
|
-
|
|
622
597
|
for ( let i = 0; i < textures2DGroupNodes.length; i ++ ) {
|
|
623
598
|
|
|
624
599
|
const textures2DGroupNode = textures2DGroupNodes[ i ];
|
|
625
600
|
const textures2DGroupData = parseTextures2DGroupNode( textures2DGroupNode );
|
|
626
601
|
resourcesData[ 'texture2dgroup' ][ textures2DGroupData[ 'id' ] ] = textures2DGroupData;
|
|
627
602
|
|
|
628
|
-
}
|
|
603
|
+
}
|
|
629
604
|
|
|
605
|
+
//
|
|
630
606
|
|
|
631
607
|
resourcesData[ 'object' ] = {};
|
|
632
608
|
const objectNodes = resourcesNode.querySelectorAll( 'object' );
|
|
633
|
-
|
|
634
609
|
for ( let i = 0; i < objectNodes.length; i ++ ) {
|
|
635
610
|
|
|
636
611
|
const objectNode = objectNodes[ i ];
|
|
@@ -647,7 +622,6 @@
|
|
|
647
622
|
|
|
648
623
|
const buildData = [];
|
|
649
624
|
const itemNodes = buildNode.querySelectorAll( 'item' );
|
|
650
|
-
|
|
651
625
|
for ( let i = 0; i < itemNodes.length; i ++ ) {
|
|
652
626
|
|
|
653
627
|
const itemNode = itemNodes[ i ];
|
|
@@ -655,7 +629,6 @@
|
|
|
655
629
|
objectId: itemNode.getAttribute( 'objectid' )
|
|
656
630
|
};
|
|
657
631
|
const transform = itemNode.getAttribute( 'transform' );
|
|
658
|
-
|
|
659
632
|
if ( transform ) {
|
|
660
633
|
|
|
661
634
|
buildItem[ 'transform' ] = parseTransform( transform );
|
|
@@ -676,7 +649,6 @@
|
|
|
676
649
|
unit: modelNode.getAttribute( 'unit' ) || 'millimeter'
|
|
677
650
|
};
|
|
678
651
|
const metadataNodes = modelNode.querySelectorAll( 'metadata' );
|
|
679
|
-
|
|
680
652
|
if ( metadataNodes ) {
|
|
681
653
|
|
|
682
654
|
modelData[ 'metadata' ] = parseMetadataNodes( metadataNodes );
|
|
@@ -684,7 +656,6 @@
|
|
|
684
656
|
}
|
|
685
657
|
|
|
686
658
|
const resourcesNode = modelNode.querySelector( 'resources' );
|
|
687
|
-
|
|
688
659
|
if ( resourcesNode ) {
|
|
689
660
|
|
|
690
661
|
modelData[ 'resources' ] = parseResourcesNode( resourcesNode );
|
|
@@ -692,7 +663,6 @@
|
|
|
692
663
|
}
|
|
693
664
|
|
|
694
665
|
const buildNode = modelNode.querySelector( 'build' );
|
|
695
|
-
|
|
696
666
|
if ( buildNode ) {
|
|
697
667
|
|
|
698
668
|
modelData[ 'build' ] = parseBuildNode( buildNode );
|
|
@@ -708,7 +678,6 @@
|
|
|
708
678
|
const texid = texture2dgroup.texid;
|
|
709
679
|
const texture2ds = modelData.resources.texture2d;
|
|
710
680
|
const texture2d = texture2ds[ texid ];
|
|
711
|
-
|
|
712
681
|
if ( texture2d ) {
|
|
713
682
|
|
|
714
683
|
const data = textureData[ texture2d.path ];
|
|
@@ -722,23 +691,22 @@
|
|
|
722
691
|
URL.revokeObjectURL( sourceURI );
|
|
723
692
|
|
|
724
693
|
} );
|
|
725
|
-
texture.encoding = THREE.sRGBEncoding;
|
|
694
|
+
texture.encoding = THREE.sRGBEncoding;
|
|
695
|
+
|
|
696
|
+
// texture parameters
|
|
726
697
|
|
|
727
698
|
switch ( texture2d.tilestyleu ) {
|
|
728
699
|
|
|
729
700
|
case 'wrap':
|
|
730
701
|
texture.wrapS = THREE.RepeatWrapping;
|
|
731
702
|
break;
|
|
732
|
-
|
|
733
703
|
case 'mirror':
|
|
734
704
|
texture.wrapS = THREE.MirroredRepeatWrapping;
|
|
735
705
|
break;
|
|
736
|
-
|
|
737
706
|
case 'none':
|
|
738
707
|
case 'clamp':
|
|
739
708
|
texture.wrapS = THREE.ClampToEdgeWrapping;
|
|
740
709
|
break;
|
|
741
|
-
|
|
742
710
|
default:
|
|
743
711
|
texture.wrapS = THREE.RepeatWrapping;
|
|
744
712
|
|
|
@@ -749,16 +717,13 @@
|
|
|
749
717
|
case 'wrap':
|
|
750
718
|
texture.wrapT = THREE.RepeatWrapping;
|
|
751
719
|
break;
|
|
752
|
-
|
|
753
720
|
case 'mirror':
|
|
754
721
|
texture.wrapT = THREE.MirroredRepeatWrapping;
|
|
755
722
|
break;
|
|
756
|
-
|
|
757
723
|
case 'none':
|
|
758
724
|
case 'clamp':
|
|
759
725
|
texture.wrapT = THREE.ClampToEdgeWrapping;
|
|
760
726
|
break;
|
|
761
|
-
|
|
762
727
|
default:
|
|
763
728
|
texture.wrapT = THREE.RepeatWrapping;
|
|
764
729
|
|
|
@@ -770,17 +735,14 @@
|
|
|
770
735
|
texture.magFilter = THREE.LinearFilter;
|
|
771
736
|
texture.minFilter = THREE.LinearMipmapLinearFilter;
|
|
772
737
|
break;
|
|
773
|
-
|
|
774
738
|
case 'linear':
|
|
775
739
|
texture.magFilter = THREE.LinearFilter;
|
|
776
740
|
texture.minFilter = THREE.LinearFilter;
|
|
777
741
|
break;
|
|
778
|
-
|
|
779
742
|
case 'nearest':
|
|
780
743
|
texture.magFilter = THREE.NearestFilter;
|
|
781
744
|
texture.minFilter = THREE.NearestFilter;
|
|
782
745
|
break;
|
|
783
|
-
|
|
784
746
|
default:
|
|
785
747
|
texture.magFilter = THREE.LinearFilter;
|
|
786
748
|
texture.minFilter = THREE.LinearMipmapLinearFilter;
|
|
@@ -801,7 +763,6 @@
|
|
|
801
763
|
|
|
802
764
|
const objectPindex = objectData.pindex;
|
|
803
765
|
const materialMap = {};
|
|
804
|
-
|
|
805
766
|
for ( let i = 0, l = triangleProperties.length; i < l; i ++ ) {
|
|
806
767
|
|
|
807
768
|
const triangleProperty = triangleProperties[ i ];
|
|
@@ -809,23 +770,24 @@
|
|
|
809
770
|
if ( materialMap[ pindex ] === undefined ) materialMap[ pindex ] = [];
|
|
810
771
|
materialMap[ pindex ].push( triangleProperty );
|
|
811
772
|
|
|
812
|
-
}
|
|
773
|
+
}
|
|
813
774
|
|
|
775
|
+
//
|
|
814
776
|
|
|
815
777
|
const keys = Object.keys( materialMap );
|
|
816
778
|
const meshes = [];
|
|
817
|
-
|
|
818
779
|
for ( let i = 0, l = keys.length; i < l; i ++ ) {
|
|
819
780
|
|
|
820
781
|
const materialIndex = keys[ i ];
|
|
821
782
|
const trianglePropertiesProps = materialMap[ materialIndex ];
|
|
822
783
|
const basematerialData = basematerials.basematerials[ materialIndex ];
|
|
823
|
-
const material = getBuild( basematerialData, objects, modelData, textureData, objectData, buildBasematerial );
|
|
784
|
+
const material = getBuild( basematerialData, objects, modelData, textureData, objectData, buildBasematerial );
|
|
785
|
+
|
|
786
|
+
//
|
|
824
787
|
|
|
825
788
|
const geometry = new THREE.BufferGeometry();
|
|
826
789
|
const positionData = [];
|
|
827
790
|
const vertices = meshData.vertices;
|
|
828
|
-
|
|
829
791
|
for ( let j = 0, jl = trianglePropertiesProps.length; j < jl; j ++ ) {
|
|
830
792
|
|
|
831
793
|
const triangleProperty = trianglePropertiesProps[ j ];
|
|
@@ -841,7 +803,9 @@
|
|
|
841
803
|
|
|
842
804
|
}
|
|
843
805
|
|
|
844
|
-
geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( positionData, 3 ) );
|
|
806
|
+
geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( positionData, 3 ) );
|
|
807
|
+
|
|
808
|
+
//
|
|
845
809
|
|
|
846
810
|
const mesh = new THREE.Mesh( geometry, material );
|
|
847
811
|
meshes.push( mesh );
|
|
@@ -855,12 +819,12 @@
|
|
|
855
819
|
function buildTexturedMesh( texture2dgroup, triangleProperties, meshData, objects, modelData, textureData, objectData ) {
|
|
856
820
|
|
|
857
821
|
// geometry
|
|
822
|
+
|
|
858
823
|
const geometry = new THREE.BufferGeometry();
|
|
859
824
|
const positionData = [];
|
|
860
825
|
const uvData = [];
|
|
861
826
|
const vertices = meshData.vertices;
|
|
862
827
|
const uvs = texture2dgroup.uvs;
|
|
863
|
-
|
|
864
828
|
for ( let i = 0, l = triangleProperties.length; i < l; i ++ ) {
|
|
865
829
|
|
|
866
830
|
const triangleProperty = triangleProperties[ i ];
|
|
@@ -872,7 +836,9 @@
|
|
|
872
836
|
positionData.push( vertices[ triangleProperty.v2 * 3 + 2 ] );
|
|
873
837
|
positionData.push( vertices[ triangleProperty.v3 * 3 + 0 ] );
|
|
874
838
|
positionData.push( vertices[ triangleProperty.v3 * 3 + 1 ] );
|
|
875
|
-
positionData.push( vertices[ triangleProperty.v3 * 3 + 2 ] );
|
|
839
|
+
positionData.push( vertices[ triangleProperty.v3 * 3 + 2 ] );
|
|
840
|
+
|
|
841
|
+
//
|
|
876
842
|
|
|
877
843
|
uvData.push( uvs[ triangleProperty.p1 * 2 + 0 ] );
|
|
878
844
|
uvData.push( uvs[ triangleProperty.p1 * 2 + 1 ] );
|
|
@@ -884,13 +850,17 @@
|
|
|
884
850
|
}
|
|
885
851
|
|
|
886
852
|
geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( positionData, 3 ) );
|
|
887
|
-
geometry.setAttribute( 'uv', new THREE.Float32BufferAttribute( uvData, 2 ) );
|
|
853
|
+
geometry.setAttribute( 'uv', new THREE.Float32BufferAttribute( uvData, 2 ) );
|
|
854
|
+
|
|
855
|
+
// material
|
|
888
856
|
|
|
889
857
|
const texture = getBuild( texture2dgroup, objects, modelData, textureData, objectData, buildTexture );
|
|
890
858
|
const material = new THREE.MeshPhongMaterial( {
|
|
891
859
|
map: texture,
|
|
892
860
|
flatShading: true
|
|
893
|
-
} );
|
|
861
|
+
} );
|
|
862
|
+
|
|
863
|
+
// mesh
|
|
894
864
|
|
|
895
865
|
const mesh = new THREE.Mesh( geometry, material );
|
|
896
866
|
return mesh;
|
|
@@ -900,12 +870,12 @@
|
|
|
900
870
|
function buildVertexColorMesh( colorgroup, triangleProperties, meshData, objectData ) {
|
|
901
871
|
|
|
902
872
|
// geometry
|
|
873
|
+
|
|
903
874
|
const geometry = new THREE.BufferGeometry();
|
|
904
875
|
const positionData = [];
|
|
905
876
|
const colorData = [];
|
|
906
877
|
const vertices = meshData.vertices;
|
|
907
878
|
const colors = colorgroup.colors;
|
|
908
|
-
|
|
909
879
|
for ( let i = 0, l = triangleProperties.length; i < l; i ++ ) {
|
|
910
880
|
|
|
911
881
|
const triangleProperty = triangleProperties[ i ];
|
|
@@ -920,7 +890,9 @@
|
|
|
920
890
|
positionData.push( vertices[ v2 * 3 + 2 ] );
|
|
921
891
|
positionData.push( vertices[ v3 * 3 + 0 ] );
|
|
922
892
|
positionData.push( vertices[ v3 * 3 + 1 ] );
|
|
923
|
-
positionData.push( vertices[ v3 * 3 + 2 ] );
|
|
893
|
+
positionData.push( vertices[ v3 * 3 + 2 ] );
|
|
894
|
+
|
|
895
|
+
//
|
|
924
896
|
|
|
925
897
|
const p1 = triangleProperty.p1 !== undefined ? triangleProperty.p1 : objectData.pindex;
|
|
926
898
|
const p2 = triangleProperty.p2 !== undefined ? triangleProperty.p2 : p1;
|
|
@@ -938,12 +910,16 @@
|
|
|
938
910
|
}
|
|
939
911
|
|
|
940
912
|
geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( positionData, 3 ) );
|
|
941
|
-
geometry.setAttribute( 'color', new THREE.Float32BufferAttribute( colorData, 3 ) );
|
|
913
|
+
geometry.setAttribute( 'color', new THREE.Float32BufferAttribute( colorData, 3 ) );
|
|
914
|
+
|
|
915
|
+
// material
|
|
942
916
|
|
|
943
917
|
const material = new THREE.MeshPhongMaterial( {
|
|
944
918
|
vertexColors: true,
|
|
945
919
|
flatShading: true
|
|
946
|
-
} );
|
|
920
|
+
} );
|
|
921
|
+
|
|
922
|
+
// mesh
|
|
947
923
|
|
|
948
924
|
const mesh = new THREE.Mesh( geometry, material );
|
|
949
925
|
return mesh;
|
|
@@ -968,19 +944,16 @@
|
|
|
968
944
|
|
|
969
945
|
const keys = Object.keys( resourceMap );
|
|
970
946
|
const meshes = [];
|
|
971
|
-
|
|
972
947
|
for ( let i = 0, il = keys.length; i < il; i ++ ) {
|
|
973
948
|
|
|
974
949
|
const resourceId = keys[ i ];
|
|
975
950
|
const triangleProperties = resourceMap[ resourceId ];
|
|
976
951
|
const resourceType = getResourceType( resourceId, modelData );
|
|
977
|
-
|
|
978
952
|
switch ( resourceType ) {
|
|
979
953
|
|
|
980
954
|
case 'material':
|
|
981
955
|
const basematerials = modelData.resources.basematerials[ resourceId ];
|
|
982
956
|
const newMeshes = buildBasematerialsMeshes( basematerials, triangleProperties, meshData, objects, modelData, textureData, objectData );
|
|
983
|
-
|
|
984
957
|
for ( let j = 0, jl = newMeshes.length; j < jl; j ++ ) {
|
|
985
958
|
|
|
986
959
|
meshes.push( newMeshes[ j ] );
|
|
@@ -988,21 +961,17 @@
|
|
|
988
961
|
}
|
|
989
962
|
|
|
990
963
|
break;
|
|
991
|
-
|
|
992
964
|
case 'texture':
|
|
993
965
|
const texture2dgroup = modelData.resources.texture2dgroup[ resourceId ];
|
|
994
966
|
meshes.push( buildTexturedMesh( texture2dgroup, triangleProperties, meshData, objects, modelData, textureData, objectData ) );
|
|
995
967
|
break;
|
|
996
|
-
|
|
997
968
|
case 'vertexColors':
|
|
998
969
|
const colorgroup = modelData.resources.colorgroup[ resourceId ];
|
|
999
970
|
meshes.push( buildVertexColorMesh( colorgroup, triangleProperties, meshData, objectData ) );
|
|
1000
971
|
break;
|
|
1001
|
-
|
|
1002
972
|
case 'default':
|
|
1003
973
|
meshes.push( buildDefaultMesh( meshData ) );
|
|
1004
974
|
break;
|
|
1005
|
-
|
|
1006
975
|
default:
|
|
1007
976
|
console.error( 'THREE.3MFLoader: Unsupported resource type.' );
|
|
1008
977
|
|
|
@@ -1055,7 +1024,6 @@
|
|
|
1055
1024
|
const resourceMap = {};
|
|
1056
1025
|
const triangleProperties = meshData[ 'triangleProperties' ];
|
|
1057
1026
|
const objectPid = objectData.pid;
|
|
1058
|
-
|
|
1059
1027
|
for ( let i = 0, l = triangleProperties.length; i < l; i ++ ) {
|
|
1060
1028
|
|
|
1061
1029
|
const triangleProperty = triangleProperties[ i ];
|
|
@@ -1075,7 +1043,6 @@
|
|
|
1075
1043
|
const group = new THREE.Group();
|
|
1076
1044
|
const resourceMap = analyzeObject( meshData, objectData );
|
|
1077
1045
|
const meshes = buildMeshes( resourceMap, meshData, objects, modelData, textureData, objectData );
|
|
1078
|
-
|
|
1079
1046
|
for ( let i = 0, l = meshes.length; i < l; i ++ ) {
|
|
1080
1047
|
|
|
1081
1048
|
group.add( meshes[ i ] );
|
|
@@ -1096,15 +1063,12 @@
|
|
|
1096
1063
|
|
|
1097
1064
|
const availableExtensions = [];
|
|
1098
1065
|
const keys = Object.keys( extensions );
|
|
1099
|
-
|
|
1100
1066
|
for ( let i = 0; i < keys.length; i ++ ) {
|
|
1101
1067
|
|
|
1102
1068
|
const ns = keys[ i ];
|
|
1103
|
-
|
|
1104
1069
|
for ( let j = 0; j < scope.availableExtensions.length; j ++ ) {
|
|
1105
1070
|
|
|
1106
1071
|
const extension = scope.availableExtensions[ j ];
|
|
1107
|
-
|
|
1108
1072
|
if ( extension.ns === ns ) {
|
|
1109
1073
|
|
|
1110
1074
|
availableExtensions.push( extension );
|
|
@@ -1137,10 +1101,10 @@
|
|
|
1137
1101
|
let material;
|
|
1138
1102
|
const displaypropertiesid = materialData.displaypropertiesid;
|
|
1139
1103
|
const pbmetallicdisplayproperties = modelData.resources.pbmetallicdisplayproperties;
|
|
1140
|
-
|
|
1141
1104
|
if ( displaypropertiesid !== null && pbmetallicdisplayproperties[ displaypropertiesid ] !== undefined ) {
|
|
1142
1105
|
|
|
1143
1106
|
// metallic display property, use StandardMaterial
|
|
1107
|
+
|
|
1144
1108
|
const pbmetallicdisplayproperty = pbmetallicdisplayproperties[ displaypropertiesid ];
|
|
1145
1109
|
const metallicData = pbmetallicdisplayproperty.data[ materialData.index ];
|
|
1146
1110
|
material = new THREE.MeshStandardMaterial( {
|
|
@@ -1152,18 +1116,22 @@
|
|
|
1152
1116
|
} else {
|
|
1153
1117
|
|
|
1154
1118
|
// otherwise use PhongMaterial
|
|
1119
|
+
|
|
1155
1120
|
material = new THREE.MeshPhongMaterial( {
|
|
1156
1121
|
flatShading: true
|
|
1157
1122
|
} );
|
|
1158
1123
|
|
|
1159
1124
|
}
|
|
1160
1125
|
|
|
1161
|
-
material.name = materialData.name;
|
|
1126
|
+
material.name = materialData.name;
|
|
1127
|
+
|
|
1128
|
+
// displaycolor MUST be specified with a value of a 6 or 8 digit hexadecimal number, e.g. "#RRGGBB" or "#RRGGBBAA"
|
|
1162
1129
|
|
|
1163
1130
|
const displaycolor = materialData.displaycolor;
|
|
1164
1131
|
const color = displaycolor.substring( 0, 7 );
|
|
1165
1132
|
material.color.setStyle( color );
|
|
1166
1133
|
material.color.convertSRGBToLinear(); // displaycolor is in sRGB
|
|
1134
|
+
|
|
1167
1135
|
// process alpha if set
|
|
1168
1136
|
|
|
1169
1137
|
if ( displaycolor.length === 9 ) {
|
|
@@ -1179,12 +1147,10 @@
|
|
|
1179
1147
|
function buildComposite( compositeData, objects, modelData, textureData ) {
|
|
1180
1148
|
|
|
1181
1149
|
const composite = new THREE.Group();
|
|
1182
|
-
|
|
1183
1150
|
for ( let j = 0; j < compositeData.length; j ++ ) {
|
|
1184
1151
|
|
|
1185
1152
|
const component = compositeData[ j ];
|
|
1186
1153
|
let build = objects[ component.objectId ];
|
|
1187
|
-
|
|
1188
1154
|
if ( build === undefined ) {
|
|
1189
1155
|
|
|
1190
1156
|
buildObject( component.objectId, objects, modelData, textureData );
|
|
@@ -1192,10 +1158,11 @@
|
|
|
1192
1158
|
|
|
1193
1159
|
}
|
|
1194
1160
|
|
|
1195
|
-
const object3D = build.clone();
|
|
1161
|
+
const object3D = build.clone();
|
|
1196
1162
|
|
|
1197
|
-
|
|
1163
|
+
// apply component transform
|
|
1198
1164
|
|
|
1165
|
+
const transform = component.transform;
|
|
1199
1166
|
if ( transform ) {
|
|
1200
1167
|
|
|
1201
1168
|
object3D.applyMatrix4( transform );
|
|
@@ -1213,7 +1180,6 @@
|
|
|
1213
1180
|
function buildObject( objectId, objects, modelData, textureData ) {
|
|
1214
1181
|
|
|
1215
1182
|
const objectData = modelData[ 'resources' ][ 'object' ][ objectId ];
|
|
1216
|
-
|
|
1217
1183
|
if ( objectData[ 'mesh' ] ) {
|
|
1218
1184
|
|
|
1219
1185
|
const meshData = objectData[ 'mesh' ];
|
|
@@ -1243,7 +1209,9 @@
|
|
|
1243
1209
|
const modelRels = data3mf.modelRels;
|
|
1244
1210
|
const objects = {};
|
|
1245
1211
|
const modelsKeys = Object.keys( modelsData );
|
|
1246
|
-
const textureData = {};
|
|
1212
|
+
const textureData = {};
|
|
1213
|
+
|
|
1214
|
+
// evaluate model relationships to textures
|
|
1247
1215
|
|
|
1248
1216
|
if ( modelRels ) {
|
|
1249
1217
|
|
|
@@ -1251,7 +1219,6 @@
|
|
|
1251
1219
|
|
|
1252
1220
|
const modelRel = modelRels[ i ];
|
|
1253
1221
|
const textureKey = modelRel.target.substring( 1 );
|
|
1254
|
-
|
|
1255
1222
|
if ( data3mf.texture[ textureKey ] ) {
|
|
1256
1223
|
|
|
1257
1224
|
textureData[ modelRel.target ] = data3mf.texture[ textureKey ];
|
|
@@ -1260,15 +1227,15 @@
|
|
|
1260
1227
|
|
|
1261
1228
|
}
|
|
1262
1229
|
|
|
1263
|
-
}
|
|
1230
|
+
}
|
|
1264
1231
|
|
|
1232
|
+
// start build
|
|
1265
1233
|
|
|
1266
1234
|
for ( let i = 0; i < modelsKeys.length; i ++ ) {
|
|
1267
1235
|
|
|
1268
1236
|
const modelsKey = modelsKeys[ i ];
|
|
1269
1237
|
const modelData = modelsData[ modelsKey ];
|
|
1270
1238
|
const objectIds = Object.keys( modelData[ 'resources' ][ 'object' ] );
|
|
1271
|
-
|
|
1272
1239
|
for ( let j = 0; j < objectIds.length; j ++ ) {
|
|
1273
1240
|
|
|
1274
1241
|
const objectId = objectIds[ j ];
|
|
@@ -1299,14 +1266,14 @@
|
|
|
1299
1266
|
const group = new THREE.Group();
|
|
1300
1267
|
const relationship = fetch3DModelPart( data3mf[ 'rels' ] );
|
|
1301
1268
|
const buildData = data3mf.model[ relationship[ 'target' ].substring( 1 ) ][ 'build' ];
|
|
1302
|
-
|
|
1303
1269
|
for ( let i = 0; i < buildData.length; i ++ ) {
|
|
1304
1270
|
|
|
1305
1271
|
const buildItem = buildData[ i ];
|
|
1306
|
-
const object3D = objects[ buildItem[ 'objectId' ] ].clone();
|
|
1272
|
+
const object3D = objects[ buildItem[ 'objectId' ] ].clone();
|
|
1307
1273
|
|
|
1308
|
-
|
|
1274
|
+
// apply transform
|
|
1309
1275
|
|
|
1276
|
+
const transform = buildItem[ 'transform' ];
|
|
1310
1277
|
if ( transform ) {
|
|
1311
1278
|
|
|
1312
1279
|
object3D.applyMatrix4( transform );
|
|
@@ -1326,7 +1293,6 @@
|
|
|
1326
1293
|
return build( objects, data3mf );
|
|
1327
1294
|
|
|
1328
1295
|
}
|
|
1329
|
-
|
|
1330
1296
|
addExtension( extension ) {
|
|
1331
1297
|
|
|
1332
1298
|
this.availableExtensions.push( extension );
|