@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
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
unitName: null,
|
|
25
25
|
unitMeter: null
|
|
26
26
|
}, options );
|
|
27
|
-
|
|
28
27
|
if ( options.upAxis.match( /^[XYZ]_UP$/ ) === null ) {
|
|
29
28
|
|
|
30
29
|
console.error( 'ColladaExporter: Invalid upAxis: valid values are X_UP, Y_UP or Z_UP.' );
|
|
@@ -53,23 +52,20 @@
|
|
|
53
52
|
}
|
|
54
53
|
|
|
55
54
|
const version = options.version;
|
|
56
|
-
|
|
57
55
|
if ( version !== '1.4.1' && version !== '1.5.0' ) {
|
|
58
56
|
|
|
59
57
|
console.warn( `ColladaExporter : Version ${version} not supported for export. Only 1.4.1 and 1.5.0.` );
|
|
60
58
|
return null;
|
|
61
59
|
|
|
62
|
-
}
|
|
63
|
-
|
|
60
|
+
}
|
|
64
61
|
|
|
62
|
+
// Convert the urdf xml into a well-formatted, indented format
|
|
65
63
|
function format( urdf ) {
|
|
66
64
|
|
|
67
65
|
const IS_END_TAG = /^<\//;
|
|
68
66
|
const IS_SELF_CLOSING = /(\?>$)|(\/>$)/;
|
|
69
67
|
const HAS_TEXT = /<[^>]+>[^<]*<\/[^<]+>/;
|
|
70
|
-
|
|
71
68
|
const pad = ( ch, num ) => num > 0 ? ch + pad( ch, num - 1 ) : '';
|
|
72
|
-
|
|
73
69
|
let tagnum = 0;
|
|
74
70
|
return urdf.match( /(<[^>]+>[^<]+<\/[^<]+>)|(<[^>]+>)/g ).map( tag => {
|
|
75
71
|
|
|
@@ -80,7 +76,6 @@
|
|
|
80
76
|
}
|
|
81
77
|
|
|
82
78
|
const res = `${pad( ' ', tagnum )}${tag}`;
|
|
83
|
-
|
|
84
79
|
if ( ! HAS_TEXT.test( tag ) && ! IS_SELF_CLOSING.test( tag ) && ! IS_END_TAG.test( tag ) ) {
|
|
85
80
|
|
|
86
81
|
tagnum ++;
|
|
@@ -91,14 +86,13 @@
|
|
|
91
86
|
|
|
92
87
|
} ).join( '\n' );
|
|
93
88
|
|
|
94
|
-
}
|
|
95
|
-
|
|
89
|
+
}
|
|
96
90
|
|
|
91
|
+
// Convert an image into a png format for saving
|
|
97
92
|
function base64ToBuffer( str ) {
|
|
98
93
|
|
|
99
94
|
const b = atob( str );
|
|
100
95
|
const buf = new Uint8Array( b.length );
|
|
101
|
-
|
|
102
96
|
for ( let i = 0, l = buf.length; i < l; i ++ ) {
|
|
103
97
|
|
|
104
98
|
buf[ i ] = b.charCodeAt( i );
|
|
@@ -110,25 +104,25 @@
|
|
|
110
104
|
}
|
|
111
105
|
|
|
112
106
|
let canvas, ctx;
|
|
113
|
-
|
|
114
107
|
function imageToData( image, ext ) {
|
|
115
108
|
|
|
116
109
|
canvas = canvas || document.createElement( 'canvas' );
|
|
117
110
|
ctx = ctx || canvas.getContext( '2d' );
|
|
118
111
|
canvas.width = image.width;
|
|
119
112
|
canvas.height = image.height;
|
|
120
|
-
ctx.drawImage( image, 0, 0 );
|
|
113
|
+
ctx.drawImage( image, 0, 0 );
|
|
121
114
|
|
|
122
|
-
|
|
115
|
+
// Get the base64 encoded data
|
|
116
|
+
const base64data = canvas.toDataURL( `image/${ext}`, 1 ).replace( /^data:image\/(png|jpg);base64,/, '' );
|
|
123
117
|
|
|
118
|
+
// Convert to a uint8 array
|
|
124
119
|
return base64ToBuffer( base64data );
|
|
125
120
|
|
|
126
|
-
}
|
|
127
|
-
|
|
121
|
+
}
|
|
128
122
|
|
|
123
|
+
// gets the attribute array. Generate a new array if the attribute is interleaved
|
|
129
124
|
const getFuncs = [ 'getX', 'getY', 'getZ', 'getW' ];
|
|
130
125
|
const tempColor = new THREE.Color();
|
|
131
|
-
|
|
132
126
|
function attrBufferToArray( attr, isColor = false ) {
|
|
133
127
|
|
|
134
128
|
if ( isColor ) {
|
|
@@ -136,7 +130,6 @@
|
|
|
136
130
|
// convert the colors to srgb before export
|
|
137
131
|
// colors are always written as floats
|
|
138
132
|
const arr = new Float32Array( attr.count * 3 );
|
|
139
|
-
|
|
140
133
|
for ( let i = 0, l = attr.count; i < l; i ++ ) {
|
|
141
134
|
|
|
142
135
|
tempColor.fromBufferAttribute( attr, i ).convertLinearToSRGB();
|
|
@@ -153,7 +146,6 @@
|
|
|
153
146
|
// use the typed array constructor to save on memory
|
|
154
147
|
const arr = new attr.array.constructor( attr.count * attr.itemSize );
|
|
155
148
|
const size = attr.itemSize;
|
|
156
|
-
|
|
157
149
|
for ( let i = 0, l = attr.count; i < l; i ++ ) {
|
|
158
150
|
|
|
159
151
|
for ( let j = 0; j < size; j ++ ) {
|
|
@@ -172,28 +164,27 @@
|
|
|
172
164
|
|
|
173
165
|
}
|
|
174
166
|
|
|
175
|
-
}
|
|
176
|
-
// and `ct` length
|
|
177
|
-
|
|
167
|
+
}
|
|
178
168
|
|
|
169
|
+
// Returns an array of the same type starting at the `st` index,
|
|
170
|
+
// and `ct` length
|
|
179
171
|
function subArray( arr, st, ct ) {
|
|
180
172
|
|
|
181
173
|
if ( Array.isArray( arr ) ) return arr.slice( st, st + ct ); else return new arr.constructor( arr.buffer, st * arr.BYTES_PER_ELEMENT, ct );
|
|
182
174
|
|
|
183
|
-
}
|
|
184
|
-
|
|
175
|
+
}
|
|
185
176
|
|
|
177
|
+
// Returns the string for a geometry's attribute
|
|
186
178
|
function getAttribute( attr, name, params, type, isColor = false ) {
|
|
187
179
|
|
|
188
180
|
const array = attrBufferToArray( attr, isColor );
|
|
189
181
|
const res = `<source id="${name}">` + `<float_array id="${name}-array" count="${array.length}">` + array.join( ' ' ) + '</float_array>' + '<technique_common>' + `<accessor source="#${name}-array" count="${Math.floor( array.length / attr.itemSize )}" stride="${attr.itemSize}">` + params.map( n => `<param name="${n}" type="${type}" />` ).join( '' ) + '</accessor>' + '</technique_common>' + '</source>';
|
|
190
182
|
return res;
|
|
191
183
|
|
|
192
|
-
}
|
|
193
|
-
|
|
184
|
+
}
|
|
194
185
|
|
|
186
|
+
// Returns the string for a node's transform information
|
|
195
187
|
let transMat;
|
|
196
|
-
|
|
197
188
|
function getTransform( o ) {
|
|
198
189
|
|
|
199
190
|
// ensure the object's matrix is up to date
|
|
@@ -204,14 +195,13 @@
|
|
|
204
195
|
transMat.transpose();
|
|
205
196
|
return `<matrix>${transMat.toArray().join( ' ' )}</matrix>`;
|
|
206
197
|
|
|
207
|
-
}
|
|
208
|
-
// Returns the mesh id
|
|
209
|
-
|
|
198
|
+
}
|
|
210
199
|
|
|
200
|
+
// Process the given piece of geometry into the geometry library
|
|
201
|
+
// Returns the mesh id
|
|
211
202
|
function processGeometry( bufferGeometry ) {
|
|
212
203
|
|
|
213
204
|
let info = geometryInfo.get( bufferGeometry );
|
|
214
|
-
|
|
215
205
|
if ( ! info ) {
|
|
216
206
|
|
|
217
207
|
const meshid = `Mesh${libraryGeometries.length + 1}`;
|
|
@@ -222,46 +212,48 @@
|
|
|
222
212
|
materialIndex: 0
|
|
223
213
|
} ];
|
|
224
214
|
const gname = bufferGeometry.name ? ` name="${bufferGeometry.name}"` : '';
|
|
225
|
-
let gnode = `<geometry id="${meshid}"${gname}><mesh>`;
|
|
215
|
+
let gnode = `<geometry id="${meshid}"${gname}><mesh>`;
|
|
226
216
|
|
|
217
|
+
// define the geometry node and the vertices for the geometry
|
|
227
218
|
const posName = `${meshid}-position`;
|
|
228
219
|
const vertName = `${meshid}-vertices`;
|
|
229
220
|
gnode += getAttribute( bufferGeometry.attributes.position, posName, [ 'X', 'Y', 'Z' ], 'float' );
|
|
230
|
-
gnode += `<vertices id="${vertName}"><input semantic="POSITION" source="#${posName}" /></vertices>`;
|
|
221
|
+
gnode += `<vertices id="${vertName}"><input semantic="POSITION" source="#${posName}" /></vertices>`;
|
|
222
|
+
|
|
223
|
+
// NOTE: We're not optimizing the attribute arrays here, so they're all the same length and
|
|
231
224
|
// can therefore share the same triangle indices. However, MeshLab seems to have trouble opening
|
|
232
225
|
// models with attributes that share an offset.
|
|
233
226
|
// MeshLab Bug#424: https://sourceforge.net/p/meshlab/bugs/424/
|
|
234
|
-
// serialize normals
|
|
235
227
|
|
|
228
|
+
// serialize normals
|
|
236
229
|
let triangleInputs = `<input semantic="VERTEX" source="#${vertName}" offset="0" />`;
|
|
237
|
-
|
|
238
230
|
if ( 'normal' in bufferGeometry.attributes ) {
|
|
239
231
|
|
|
240
232
|
const normName = `${meshid}-normal`;
|
|
241
233
|
gnode += getAttribute( bufferGeometry.attributes.normal, normName, [ 'X', 'Y', 'Z' ], 'float' );
|
|
242
234
|
triangleInputs += `<input semantic="NORMAL" source="#${normName}" offset="0" />`;
|
|
243
235
|
|
|
244
|
-
}
|
|
245
|
-
|
|
236
|
+
}
|
|
246
237
|
|
|
238
|
+
// serialize uvs
|
|
247
239
|
if ( 'uv' in bufferGeometry.attributes ) {
|
|
248
240
|
|
|
249
241
|
const uvName = `${meshid}-texcoord`;
|
|
250
242
|
gnode += getAttribute( bufferGeometry.attributes.uv, uvName, [ 'S', 'T' ], 'float' );
|
|
251
243
|
triangleInputs += `<input semantic="TEXCOORD" source="#${uvName}" offset="0" set="0" />`;
|
|
252
244
|
|
|
253
|
-
}
|
|
254
|
-
|
|
245
|
+
}
|
|
255
246
|
|
|
247
|
+
// serialize lightmap uvs
|
|
256
248
|
if ( 'uv2' in bufferGeometry.attributes ) {
|
|
257
249
|
|
|
258
250
|
const uvName = `${meshid}-texcoord2`;
|
|
259
251
|
gnode += getAttribute( bufferGeometry.attributes.uv2, uvName, [ 'S', 'T' ], 'float' );
|
|
260
252
|
triangleInputs += `<input semantic="TEXCOORD" source="#${uvName}" offset="0" set="1" />`;
|
|
261
253
|
|
|
262
|
-
}
|
|
263
|
-
|
|
254
|
+
}
|
|
264
255
|
|
|
256
|
+
// serialize colors
|
|
265
257
|
if ( 'color' in bufferGeometry.attributes ) {
|
|
266
258
|
|
|
267
259
|
// colors are always written as floats
|
|
@@ -272,7 +264,6 @@
|
|
|
272
264
|
}
|
|
273
265
|
|
|
274
266
|
let indexArray = null;
|
|
275
|
-
|
|
276
267
|
if ( bufferGeometry.index ) {
|
|
277
268
|
|
|
278
269
|
indexArray = attrBufferToArray( bufferGeometry.index );
|
|
@@ -280,7 +271,6 @@
|
|
|
280
271
|
} else {
|
|
281
272
|
|
|
282
273
|
indexArray = new Array( indexCount );
|
|
283
|
-
|
|
284
274
|
for ( let i = 0, l = indexArray.length; i < l; i ++ ) indexArray[ i ] = i;
|
|
285
275
|
|
|
286
276
|
}
|
|
@@ -309,21 +299,19 @@
|
|
|
309
299
|
|
|
310
300
|
return info;
|
|
311
301
|
|
|
312
|
-
}
|
|
313
|
-
// Returns the image library
|
|
314
|
-
|
|
302
|
+
}
|
|
315
303
|
|
|
304
|
+
// Process the given texture into the image library
|
|
305
|
+
// Returns the image library
|
|
316
306
|
function processTexture( tex ) {
|
|
317
307
|
|
|
318
308
|
let texid = imageMap.get( tex );
|
|
319
|
-
|
|
320
309
|
if ( texid == null ) {
|
|
321
310
|
|
|
322
311
|
texid = `image-${libraryImages.length + 1}`;
|
|
323
312
|
const ext = 'png';
|
|
324
313
|
const name = tex.name || texid;
|
|
325
314
|
let imageNode = `<image id="${texid}" name="${name}">`;
|
|
326
|
-
|
|
327
315
|
if ( version === '1.5.0' ) {
|
|
328
316
|
|
|
329
317
|
imageNode += `<init_from><ref>${options.textureDirectory}${name}.${ext}</ref></init_from>`;
|
|
@@ -350,19 +338,17 @@
|
|
|
350
338
|
|
|
351
339
|
return texid;
|
|
352
340
|
|
|
353
|
-
}
|
|
354
|
-
// Returns the material id
|
|
355
|
-
|
|
341
|
+
}
|
|
356
342
|
|
|
343
|
+
// Process the given material into the material and effect libraries
|
|
344
|
+
// Returns the material id
|
|
357
345
|
function processMaterial( m ) {
|
|
358
346
|
|
|
359
347
|
let matid = materialMap.get( m );
|
|
360
|
-
|
|
361
348
|
if ( matid == null ) {
|
|
362
349
|
|
|
363
350
|
matid = `Mat${libraryEffects.length + 1}`;
|
|
364
351
|
let type = 'phong';
|
|
365
|
-
|
|
366
352
|
if ( m.isMeshLambertMaterial === true ) {
|
|
367
353
|
|
|
368
354
|
type = 'lambert';
|
|
@@ -370,7 +356,6 @@
|
|
|
370
356
|
} else if ( m.isMeshBasicMaterial === true ) {
|
|
371
357
|
|
|
372
358
|
type = 'constant';
|
|
373
|
-
|
|
374
359
|
if ( m.map !== null ) {
|
|
375
360
|
|
|
376
361
|
// The Collada spec does not support diffuse texture maps with the
|
|
@@ -389,16 +374,15 @@
|
|
|
389
374
|
const reflectivity = m.reflectivity || 0;
|
|
390
375
|
emissive.convertLinearToSRGB();
|
|
391
376
|
specular.convertLinearToSRGB();
|
|
392
|
-
diffuse.convertLinearToSRGB();
|
|
377
|
+
diffuse.convertLinearToSRGB();
|
|
378
|
+
|
|
379
|
+
// Do not export and alpha map for the reasons mentioned in issue (#13792)
|
|
393
380
|
// in three.js alpha maps are black and white, but collada expects the alpha
|
|
394
381
|
// channel to specify the transparency
|
|
395
|
-
|
|
396
382
|
let transparencyNode = '';
|
|
397
|
-
|
|
398
383
|
if ( m.transparent === true ) {
|
|
399
384
|
|
|
400
385
|
transparencyNode += '<transparent>' + ( m.map ? '<texture texture="diffuse-sampler"></texture>' : '<float>1</float>' ) + '</transparent>';
|
|
401
|
-
|
|
402
386
|
if ( m.opacity < 1 ) {
|
|
403
387
|
|
|
404
388
|
transparencyNode += `<transparency><float>${m.opacity}</float></transparency>`;
|
|
@@ -419,30 +403,30 @@
|
|
|
419
403
|
|
|
420
404
|
return matid;
|
|
421
405
|
|
|
422
|
-
}
|
|
423
|
-
|
|
406
|
+
}
|
|
424
407
|
|
|
408
|
+
// Recursively process the object into a scene
|
|
425
409
|
function processObject( o ) {
|
|
426
410
|
|
|
427
411
|
let node = `<node name="${o.name}">`;
|
|
428
412
|
node += getTransform( o );
|
|
429
|
-
|
|
430
413
|
if ( o.isMesh === true && o.geometry !== null ) {
|
|
431
414
|
|
|
432
415
|
// function returns the id associated with the mesh and a "BufferGeometry" version
|
|
433
416
|
// of the geometry in case it's not a geometry.
|
|
434
417
|
const geomInfo = processGeometry( o.geometry );
|
|
435
418
|
const meshid = geomInfo.meshid;
|
|
436
|
-
const geometry = geomInfo.bufferGeometry;
|
|
419
|
+
const geometry = geomInfo.bufferGeometry;
|
|
437
420
|
|
|
421
|
+
// ids of the materials to bind to the geometry
|
|
438
422
|
let matids = null;
|
|
439
|
-
let matidsArray;
|
|
423
|
+
let matidsArray;
|
|
424
|
+
|
|
425
|
+
// get a list of materials to bind to the sub groups of the geometry.
|
|
440
426
|
// If the amount of subgroups is greater than the materials, than reuse
|
|
441
427
|
// the materials.
|
|
442
|
-
|
|
443
428
|
const mat = o.material || new THREE.MeshBasicMaterial();
|
|
444
429
|
const materials = Array.isArray( mat ) ? mat : [ mat ];
|
|
445
|
-
|
|
446
430
|
if ( geometry.groups.length > materials.length ) {
|
|
447
431
|
|
|
448
432
|
matidsArray = new Array( geometry.groups.length );
|
|
@@ -486,7 +470,6 @@
|
|
|
486
470
|
data: format( dae ),
|
|
487
471
|
textures
|
|
488
472
|
};
|
|
489
|
-
|
|
490
473
|
if ( typeof onDone === 'function' ) {
|
|
491
474
|
|
|
492
475
|
requestAnimationFrame( () => onDone( res ) );
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
/* global DracoEncoderModule */
|
|
18
|
+
|
|
18
19
|
class DRACOExporter {
|
|
19
20
|
|
|
20
21
|
parse( object, options = {
|
|
@@ -38,7 +39,6 @@
|
|
|
38
39
|
const encoder = new dracoEncoder.Encoder();
|
|
39
40
|
let builder;
|
|
40
41
|
let dracoObject;
|
|
41
|
-
|
|
42
42
|
if ( object.isMesh === true ) {
|
|
43
43
|
|
|
44
44
|
builder = new dracoEncoder.MeshBuilder();
|
|
@@ -46,7 +46,6 @@
|
|
|
46
46
|
const vertices = geometry.getAttribute( 'position' );
|
|
47
47
|
builder.AddFloatAttributeToMesh( dracoObject, dracoEncoder.POSITION, vertices.count, vertices.itemSize, vertices.array );
|
|
48
48
|
const faces = geometry.getIndex();
|
|
49
|
-
|
|
50
49
|
if ( faces !== null ) {
|
|
51
50
|
|
|
52
51
|
builder.AddFacesToMesh( dracoObject, faces.count / 3, faces.array );
|
|
@@ -54,7 +53,6 @@
|
|
|
54
53
|
} else {
|
|
55
54
|
|
|
56
55
|
const faces = new ( vertices.count > 65535 ? Uint32Array : Uint16Array )( vertices.count );
|
|
57
|
-
|
|
58
56
|
for ( let i = 0; i < faces.length; i ++ ) {
|
|
59
57
|
|
|
60
58
|
faces[ i ] = i;
|
|
@@ -68,7 +66,6 @@
|
|
|
68
66
|
if ( options.exportNormals === true ) {
|
|
69
67
|
|
|
70
68
|
const normals = geometry.getAttribute( 'normal' );
|
|
71
|
-
|
|
72
69
|
if ( normals !== undefined ) {
|
|
73
70
|
|
|
74
71
|
builder.AddFloatAttributeToMesh( dracoObject, dracoEncoder.NORMAL, normals.count, normals.itemSize, normals.array );
|
|
@@ -80,7 +77,6 @@
|
|
|
80
77
|
if ( options.exportUvs === true ) {
|
|
81
78
|
|
|
82
79
|
const uvs = geometry.getAttribute( 'uv' );
|
|
83
|
-
|
|
84
80
|
if ( uvs !== undefined ) {
|
|
85
81
|
|
|
86
82
|
builder.AddFloatAttributeToMesh( dracoObject, dracoEncoder.TEX_COORD, uvs.count, uvs.itemSize, uvs.array );
|
|
@@ -92,7 +88,6 @@
|
|
|
92
88
|
if ( options.exportColor === true ) {
|
|
93
89
|
|
|
94
90
|
const colors = geometry.getAttribute( 'color' );
|
|
95
|
-
|
|
96
91
|
if ( colors !== undefined ) {
|
|
97
92
|
|
|
98
93
|
builder.AddFloatAttributeToMesh( dracoObject, dracoEncoder.COLOR, colors.count, colors.itemSize, colors.array );
|
|
@@ -107,11 +102,9 @@
|
|
|
107
102
|
dracoObject = new dracoEncoder.PointCloud();
|
|
108
103
|
const vertices = geometry.getAttribute( 'position' );
|
|
109
104
|
builder.AddFloatAttribute( dracoObject, dracoEncoder.POSITION, vertices.count, vertices.itemSize, vertices.array );
|
|
110
|
-
|
|
111
105
|
if ( options.exportColor === true ) {
|
|
112
106
|
|
|
113
107
|
const colors = geometry.getAttribute( 'color' );
|
|
114
|
-
|
|
115
108
|
if ( colors !== undefined ) {
|
|
116
109
|
|
|
117
110
|
builder.AddFloatAttribute( dracoObject, dracoEncoder.COLOR, colors.count, colors.itemSize, colors.array );
|
|
@@ -124,23 +117,28 @@
|
|
|
124
117
|
|
|
125
118
|
throw new Error( 'DRACOExporter: Unsupported object type.' );
|
|
126
119
|
|
|
127
|
-
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
//Compress using draco encoder
|
|
128
123
|
|
|
124
|
+
const encodedData = new dracoEncoder.DracoInt8Array();
|
|
129
125
|
|
|
130
|
-
|
|
126
|
+
//Sets the desired encoding and decoding speed for the given options from 0 (slowest speed, but the best compression) to 10 (fastest, but the worst compression).
|
|
131
127
|
|
|
132
128
|
const encodeSpeed = options.encodeSpeed !== undefined ? options.encodeSpeed : 5;
|
|
133
129
|
const decodeSpeed = options.decodeSpeed !== undefined ? options.decodeSpeed : 5;
|
|
134
|
-
encoder.SetSpeedOptions( encodeSpeed, decodeSpeed );
|
|
130
|
+
encoder.SetSpeedOptions( encodeSpeed, decodeSpeed );
|
|
131
|
+
|
|
132
|
+
// Sets the desired encoding method for a given geometry.
|
|
135
133
|
|
|
136
134
|
if ( options.encoderMethod !== undefined ) {
|
|
137
135
|
|
|
138
136
|
encoder.SetEncodingMethod( options.encoderMethod );
|
|
139
137
|
|
|
140
|
-
}
|
|
141
|
-
// The attribute values will be quantized in a box defined by the maximum extent of the attribute values.
|
|
142
|
-
|
|
138
|
+
}
|
|
143
139
|
|
|
140
|
+
// Sets the quantization (number of bits used to represent) compression options for a named attribute.
|
|
141
|
+
// The attribute values will be quantized in a box defined by the maximum extent of the attribute values.
|
|
144
142
|
if ( options.quantization !== undefined ) {
|
|
145
143
|
|
|
146
144
|
for ( let i = 0; i < 5; i ++ ) {
|
|
@@ -156,7 +154,6 @@
|
|
|
156
154
|
}
|
|
157
155
|
|
|
158
156
|
let length;
|
|
159
|
-
|
|
160
157
|
if ( object.isMesh === true ) {
|
|
161
158
|
|
|
162
159
|
length = encoder.EncodeMeshToDracoBuffer( dracoObject, encodedData );
|
|
@@ -168,16 +165,14 @@
|
|
|
168
165
|
}
|
|
169
166
|
|
|
170
167
|
dracoEncoder.destroy( dracoObject );
|
|
171
|
-
|
|
172
168
|
if ( length === 0 ) {
|
|
173
169
|
|
|
174
170
|
throw new Error( 'THREE.DRACOExporter: Draco encoding failed.' );
|
|
175
171
|
|
|
176
|
-
}
|
|
177
|
-
|
|
172
|
+
}
|
|
178
173
|
|
|
174
|
+
//Copy encoded data to buffer.
|
|
179
175
|
const outputData = new Int8Array( new ArrayBuffer( length ) );
|
|
180
|
-
|
|
181
176
|
for ( let i = 0; i < length; i ++ ) {
|
|
182
177
|
|
|
183
178
|
outputData[ i ] = encodedData.GetValue( i );
|
|
@@ -191,14 +186,19 @@
|
|
|
191
186
|
|
|
192
187
|
}
|
|
193
188
|
|
|
194
|
-
}
|
|
189
|
+
}
|
|
195
190
|
|
|
191
|
+
// Encoder methods
|
|
196
192
|
|
|
197
193
|
DRACOExporter.MESH_EDGEBREAKER_ENCODING = 1;
|
|
198
|
-
DRACOExporter.MESH_SEQUENTIAL_ENCODING = 0;
|
|
194
|
+
DRACOExporter.MESH_SEQUENTIAL_ENCODING = 0;
|
|
195
|
+
|
|
196
|
+
// Geometry type
|
|
199
197
|
|
|
200
198
|
DRACOExporter.POINT_CLOUD = 0;
|
|
201
|
-
DRACOExporter.TRIANGULAR_MESH = 1;
|
|
199
|
+
DRACOExporter.TRIANGULAR_MESH = 1;
|
|
200
|
+
|
|
201
|
+
// Attribute type
|
|
202
202
|
|
|
203
203
|
DRACOExporter.INVALID = - 1;
|
|
204
204
|
DRACOExporter.POSITION = 0;
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
const NO_COMPRESSION = 0;
|
|
11
11
|
const ZIPS_COMPRESSION = 2;
|
|
12
12
|
const ZIP_COMPRESSION = 3;
|
|
13
|
-
|
|
14
13
|
class EXRExporter {
|
|
15
14
|
|
|
16
15
|
parse( renderer, renderTarget, options ) {
|
|
@@ -25,7 +24,6 @@
|
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
}
|
|
28
|
-
|
|
29
27
|
function supported( renderer, renderTarget ) {
|
|
30
28
|
|
|
31
29
|
if ( ! renderer || ! renderer.isWebGLRenderer ) {
|
|
@@ -97,7 +95,6 @@
|
|
|
97
95
|
function getPixelData( renderer, rtt, info ) {
|
|
98
96
|
|
|
99
97
|
let dataBuffer;
|
|
100
|
-
|
|
101
98
|
if ( info.type === THREE.FloatType ) {
|
|
102
99
|
|
|
103
100
|
dataBuffer = new Float32Array( info.width * info.height * info.numInputChannels );
|
|
@@ -131,7 +128,6 @@
|
|
|
131
128
|
setValue = info.dataType == 1 ? setFloat16 : setFloat32,
|
|
132
129
|
outBuffer = new Uint8Array( info.width * info.height * info.numOutputChannels * info.dataSize ),
|
|
133
130
|
dv = new DataView( outBuffer.buffer );
|
|
134
|
-
|
|
135
131
|
for ( let y = 0; y < h; ++ y ) {
|
|
136
132
|
|
|
137
133
|
for ( let x = 0; x < w; ++ x ) {
|
|
@@ -170,13 +166,11 @@
|
|
|
170
166
|
totalSize: 0
|
|
171
167
|
},
|
|
172
168
|
size = info.width * info.numOutputChannels * info.blockLines * info.dataSize;
|
|
173
|
-
|
|
174
169
|
switch ( info.compression ) {
|
|
175
170
|
|
|
176
171
|
case 0:
|
|
177
172
|
compress = compressNONE;
|
|
178
173
|
break;
|
|
179
|
-
|
|
180
174
|
case 2:
|
|
181
175
|
case 3:
|
|
182
176
|
compress = compressZIP;
|
|
@@ -218,11 +212,11 @@
|
|
|
218
212
|
//
|
|
219
213
|
// Reorder the pixel data.
|
|
220
214
|
//
|
|
215
|
+
|
|
221
216
|
let t1 = 0,
|
|
222
217
|
t2 = Math.floor( ( data.length + 1 ) / 2 ),
|
|
223
218
|
s = 0;
|
|
224
219
|
const stop = data.length - 1;
|
|
225
|
-
|
|
226
220
|
while ( true ) {
|
|
227
221
|
|
|
228
222
|
if ( s > stop ) break;
|
|
@@ -230,13 +224,13 @@
|
|
|
230
224
|
if ( s > stop ) break;
|
|
231
225
|
tmpBuffer[ t2 ++ ] = data[ s ++ ];
|
|
232
226
|
|
|
233
|
-
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
//
|
|
234
230
|
// Predictor.
|
|
235
231
|
//
|
|
236
232
|
|
|
237
|
-
|
|
238
233
|
let p = tmpBuffer[ 0 ];
|
|
239
|
-
|
|
240
234
|
for ( let t = 1; t < tmpBuffer.length; t ++ ) {
|
|
241
235
|
|
|
242
236
|
const d = tmpBuffer[ t ] - p + ( 128 + 256 );
|
|
@@ -264,8 +258,8 @@
|
|
|
264
258
|
};
|
|
265
259
|
const dv = new DataView( outBuffer.buffer );
|
|
266
260
|
setUint32( dv, 20000630, offset ); // magic
|
|
267
|
-
|
|
268
261
|
setUint32( dv, 2, offset ); // mask
|
|
262
|
+
|
|
269
263
|
// = HEADER =
|
|
270
264
|
|
|
271
265
|
setString( dv, 'compression', offset );
|
|
@@ -326,12 +320,14 @@
|
|
|
326
320
|
offset.value += 4;
|
|
327
321
|
setUint32( dv, 1, offset );
|
|
328
322
|
setUint32( dv, 1, offset );
|
|
329
|
-
setUint8( dv, 0, offset );
|
|
323
|
+
setUint8( dv, 0, offset );
|
|
330
324
|
|
|
331
|
-
|
|
325
|
+
// null-byte
|
|
326
|
+
setUint8( dv, 0, offset );
|
|
332
327
|
|
|
333
|
-
|
|
328
|
+
// = OFFSET TABLE =
|
|
334
329
|
|
|
330
|
+
let sum = offset.value + info.numBlocks * 8;
|
|
335
331
|
for ( let i = 0; i < chunks.data.length; ++ i ) {
|
|
336
332
|
|
|
337
333
|
setUint64( dv, sum, offset );
|
|
@@ -352,7 +348,6 @@
|
|
|
352
348
|
outBuffer = new Uint8Array( HeaderSize + TableSize + chunks.totalSize + info.numBlocks * 8 ),
|
|
353
349
|
dv = new DataView( outBuffer.buffer );
|
|
354
350
|
fillHeader( outBuffer, chunks, info );
|
|
355
|
-
|
|
356
351
|
for ( let i = 0; i < chunks.data.length; ++ i ) {
|
|
357
352
|
|
|
358
353
|
const data = chunks.data[ i ].dataChunk;
|
|
@@ -375,13 +370,16 @@
|
|
|
375
370
|
dec.b = b;
|
|
376
371
|
dec.a = a;
|
|
377
372
|
|
|
378
|
-
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// function decodeSRGB( dec, r, g, b, a ) {
|
|
376
|
+
|
|
379
377
|
// dec.r = r > 0.04045 ? Math.pow( r * 0.9478672986 + 0.0521327014, 2.4 ) : r * 0.0773993808;
|
|
380
378
|
// dec.g = g > 0.04045 ? Math.pow( g * 0.9478672986 + 0.0521327014, 2.4 ) : g * 0.0773993808;
|
|
381
379
|
// dec.b = b > 0.04045 ? Math.pow( b * 0.9478672986 + 0.0521327014, 2.4 ) : b * 0.0773993808;
|
|
382
380
|
// dec.a = a;
|
|
383
|
-
// }
|
|
384
381
|
|
|
382
|
+
// }
|
|
385
383
|
|
|
386
384
|
function setUint8( dv, value, offset ) {
|
|
387
385
|
|
|
@@ -421,7 +419,6 @@
|
|
|
421
419
|
function setString( dv, string, offset ) {
|
|
422
420
|
|
|
423
421
|
const tmp = textEncoder.encode( string + '\0' );
|
|
424
|
-
|
|
425
422
|
for ( let i = 0; i < tmp.length; ++ i ) {
|
|
426
423
|
|
|
427
424
|
setUint8( dv, tmp[ i ], offset );
|