@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,52 +24,37 @@
|
|
|
24
24
|
* @param {Vector3} bottomRightCorner
|
|
25
25
|
* @param {Vector3} topLeftCorner
|
|
26
26
|
* @param {boolean} estimateViewFrustum */
|
|
27
|
-
|
|
28
|
-
|
|
29
27
|
function frameCorners( camera, bottomLeftCorner, bottomRightCorner, topLeftCorner, estimateViewFrustum = false ) {
|
|
30
28
|
|
|
31
29
|
const pa = bottomLeftCorner,
|
|
32
30
|
pb = bottomRightCorner,
|
|
33
31
|
pc = topLeftCorner;
|
|
34
32
|
const pe = camera.position; // eye position
|
|
35
|
-
|
|
36
33
|
const n = camera.near; // distance of near clipping plane
|
|
37
|
-
|
|
38
34
|
const f = camera.far; //distance of far clipping plane
|
|
39
35
|
|
|
40
36
|
_vr.copy( pb ).sub( pa ).normalize();
|
|
41
|
-
|
|
42
37
|
_vu.copy( pc ).sub( pa ).normalize();
|
|
43
|
-
|
|
44
38
|
_vn.crossVectors( _vr, _vu ).normalize();
|
|
45
|
-
|
|
46
39
|
_va.copy( pa ).sub( pe ); // from pe to pa
|
|
47
|
-
|
|
48
|
-
|
|
49
40
|
_vb.copy( pb ).sub( pe ); // from pe to pb
|
|
50
|
-
|
|
51
|
-
|
|
52
41
|
_vc.copy( pc ).sub( pe ); // from pe to pc
|
|
53
42
|
|
|
54
|
-
|
|
55
43
|
const d = - _va.dot( _vn ); // distance from eye to screen
|
|
56
|
-
|
|
57
44
|
const l = _vr.dot( _va ) * n / d; // distance to left screen edge
|
|
58
|
-
|
|
59
45
|
const r = _vr.dot( _vb ) * n / d; // distance to right screen edge
|
|
60
|
-
|
|
61
46
|
const b = _vu.dot( _va ) * n / d; // distance to bottom screen edge
|
|
62
|
-
|
|
63
47
|
const t = _vu.dot( _vc ) * n / d; // distance to top screen edge
|
|
64
|
-
// Set the camera rotation to match the focal plane to the corners' plane
|
|
65
48
|
|
|
49
|
+
// Set the camera rotation to match the focal plane to the corners' plane
|
|
66
50
|
_quat.setFromUnitVectors( _vec.set( 0, 1, 0 ), _vu );
|
|
51
|
+
camera.quaternion.setFromUnitVectors( _vec.set( 0, 0, 1 ).applyQuaternion( _quat ), _vn ).multiply( _quat );
|
|
67
52
|
|
|
68
|
-
|
|
69
|
-
|
|
53
|
+
// Set the off-axis projection matrix to match the corners
|
|
70
54
|
camera.projectionMatrix.set( 2.0 * n / ( r - l ), 0.0, ( r + l ) / ( r - l ), 0.0, 0.0, 2.0 * n / ( t - b ), ( t + b ) / ( t - b ), 0.0, 0.0, 0.0, ( f + n ) / ( n - f ), 2.0 * f * n / ( n - f ), 0.0, 0.0, - 1.0, 0.0 );
|
|
71
|
-
camera.projectionMatrixInverse.copy( camera.projectionMatrix ).invert();
|
|
55
|
+
camera.projectionMatrixInverse.copy( camera.projectionMatrix ).invert();
|
|
72
56
|
|
|
57
|
+
// FoV estimation to fix frustum culling
|
|
73
58
|
if ( estimateViewFrustum ) {
|
|
74
59
|
|
|
75
60
|
// Set fieldOfView to a conservative estimate
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
( function () {
|
|
2
2
|
|
|
3
|
+
// https://www.khronos.org/registry/webgl/extensions/EXT_disjoint_timer_query/
|
|
3
4
|
// https://www.khronos.org/registry/webgl/extensions/EXT_disjoint_timer_query_webgl2/
|
|
4
|
-
|
|
5
5
|
class GPUStatsPanel extends Stats.Panel {
|
|
6
6
|
|
|
7
7
|
constructor( context, name = 'GPU MS' ) {
|
|
@@ -9,12 +9,10 @@
|
|
|
9
9
|
super( name, '#f90', '#210' );
|
|
10
10
|
let isWebGL2 = true;
|
|
11
11
|
let extension = context.getExtension( 'EXT_disjoint_timer_query_webgl2' );
|
|
12
|
-
|
|
13
12
|
if ( extension === null ) {
|
|
14
13
|
|
|
15
14
|
isWebGL2 = false;
|
|
16
15
|
extension = context.getExtension( 'EXT_disjoint_timer_query' );
|
|
17
|
-
|
|
18
16
|
if ( extension === null ) {
|
|
19
17
|
|
|
20
18
|
console.warn( 'GPUStatsPanel: disjoint_time_query extension not available.' );
|
|
@@ -27,21 +25,18 @@
|
|
|
27
25
|
this.extension = extension;
|
|
28
26
|
this.maxTime = 30;
|
|
29
27
|
this.activeQueries = 0;
|
|
30
|
-
|
|
31
28
|
this.startQuery = function () {
|
|
32
29
|
|
|
33
30
|
const gl = this.context;
|
|
34
31
|
const ext = this.extension;
|
|
35
|
-
|
|
36
32
|
if ( ext === null ) {
|
|
37
33
|
|
|
38
34
|
return;
|
|
39
35
|
|
|
40
|
-
}
|
|
41
|
-
|
|
36
|
+
}
|
|
42
37
|
|
|
38
|
+
// create the query object
|
|
43
39
|
let query;
|
|
44
|
-
|
|
45
40
|
if ( isWebGL2 ) {
|
|
46
41
|
|
|
47
42
|
query = gl.createQuery();
|
|
@@ -55,12 +50,10 @@
|
|
|
55
50
|
}
|
|
56
51
|
|
|
57
52
|
this.activeQueries ++;
|
|
58
|
-
|
|
59
53
|
const checkQuery = () => {
|
|
60
54
|
|
|
61
55
|
// check if the query is available and valid
|
|
62
56
|
let available, disjoint, ns;
|
|
63
|
-
|
|
64
57
|
if ( isWebGL2 ) {
|
|
65
58
|
|
|
66
59
|
available = gl.getQueryParameter( query, gl.QUERY_RESULT_AVAILABLE );
|
|
@@ -76,7 +69,6 @@
|
|
|
76
69
|
}
|
|
77
70
|
|
|
78
71
|
const ms = ns * 1e-6;
|
|
79
|
-
|
|
80
72
|
if ( available ) {
|
|
81
73
|
|
|
82
74
|
// update the display if it is valid
|
|
@@ -106,7 +98,6 @@
|
|
|
106
98
|
// finish the query measurement
|
|
107
99
|
const ext = this.extension;
|
|
108
100
|
const gl = this.context;
|
|
109
|
-
|
|
110
101
|
if ( ext === null ) {
|
|
111
102
|
|
|
112
103
|
return;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* @link https://github.com/tsherif/mesh-quantization-example
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
|
+
|
|
9
10
|
/**
|
|
10
11
|
* Make the input mesh.geometry's normal attribute encoded and compressed by 3 different methods.
|
|
11
12
|
* Also will change the mesh.material to `PackedPhongMaterial` which let the vertex shader program decode the normal data.
|
|
@@ -14,7 +15,6 @@
|
|
|
14
15
|
* @param {String} encodeMethod "DEFAULT" || "OCT1Byte" || "OCT2Byte" || "ANGLES"
|
|
15
16
|
*
|
|
16
17
|
*/
|
|
17
|
-
|
|
18
18
|
function compressNormals( mesh, encodeMethod ) {
|
|
19
19
|
|
|
20
20
|
if ( ! mesh.geometry ) {
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
const normal = mesh.geometry.attributes.normal;
|
|
27
|
-
|
|
28
27
|
if ( ! normal ) {
|
|
29
28
|
|
|
30
29
|
console.error( 'Geometry must contain normal attribute. ' );
|
|
@@ -32,7 +31,6 @@
|
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
if ( normal.isPacked ) return;
|
|
35
|
-
|
|
36
34
|
if ( normal.itemSize != 3 ) {
|
|
37
35
|
|
|
38
36
|
console.error( 'normal.itemSize is not 3, which cannot be encoded. ' );
|
|
@@ -42,12 +40,10 @@
|
|
|
42
40
|
const array = normal.array;
|
|
43
41
|
const count = normal.count;
|
|
44
42
|
let result;
|
|
45
|
-
|
|
46
43
|
if ( encodeMethod == 'DEFAULT' ) {
|
|
47
44
|
|
|
48
45
|
// TODO: Add 1 byte to the result, making the encoded length to be 4 bytes.
|
|
49
46
|
result = new Uint8Array( count * 3 );
|
|
50
|
-
|
|
51
47
|
for ( let idx = 0; idx < array.length; idx += 3 ) {
|
|
52
48
|
|
|
53
49
|
const encoded = defaultEncode( array[ idx ], array[ idx + 1 ], array[ idx + 2 ], 1 );
|
|
@@ -67,8 +63,8 @@
|
|
|
67
63
|
* As it makes vertex data not aligned to a 4 byte boundary which may harm some WebGL implementations and sometimes the normal distortion is visible
|
|
68
64
|
* Please refer to @zeux 's comments in https://github.com/mrdoob/three.js/pull/18208
|
|
69
65
|
*/
|
|
70
|
-
result = new Int8Array( count * 2 );
|
|
71
66
|
|
|
67
|
+
result = new Int8Array( count * 2 );
|
|
72
68
|
for ( let idx = 0; idx < array.length; idx += 3 ) {
|
|
73
69
|
|
|
74
70
|
const encoded = octEncodeBest( array[ idx ], array[ idx + 1 ], array[ idx + 2 ], 1 );
|
|
@@ -83,7 +79,6 @@
|
|
|
83
79
|
} else if ( encodeMethod == 'OCT2Byte' ) {
|
|
84
80
|
|
|
85
81
|
result = new Int16Array( count * 2 );
|
|
86
|
-
|
|
87
82
|
for ( let idx = 0; idx < array.length; idx += 3 ) {
|
|
88
83
|
|
|
89
84
|
const encoded = octEncodeBest( array[ idx ], array[ idx + 1 ], array[ idx + 2 ], 2 );
|
|
@@ -98,7 +93,6 @@
|
|
|
98
93
|
} else if ( encodeMethod == 'ANGLES' ) {
|
|
99
94
|
|
|
100
95
|
result = new Uint16Array( count * 2 );
|
|
101
|
-
|
|
102
96
|
for ( let idx = 0; idx < array.length; idx += 3 ) {
|
|
103
97
|
|
|
104
98
|
const encoded = anglesEncode( array[ idx ], array[ idx + 1 ], array[ idx + 2 ] );
|
|
@@ -118,8 +112,9 @@
|
|
|
118
112
|
|
|
119
113
|
mesh.geometry.attributes.normal.needsUpdate = true;
|
|
120
114
|
mesh.geometry.attributes.normal.isPacked = true;
|
|
121
|
-
mesh.geometry.attributes.normal.packingMethod = encodeMethod;
|
|
115
|
+
mesh.geometry.attributes.normal.packingMethod = encodeMethod;
|
|
122
116
|
|
|
117
|
+
// modify material
|
|
123
118
|
if ( ! ( mesh.material instanceof THREE.PackedPhongMaterial ) ) {
|
|
124
119
|
|
|
125
120
|
mesh.material = new THREE.PackedPhongMaterial().copy( mesh.material );
|
|
@@ -151,6 +146,7 @@
|
|
|
151
146
|
}
|
|
152
147
|
|
|
153
148
|
}
|
|
149
|
+
|
|
154
150
|
/**
|
|
155
151
|
* Make the input mesh.geometry's position attribute encoded and compressed.
|
|
156
152
|
* Also will change the mesh.material to `PackedPhongMaterial` which let the vertex shader program decode the position data.
|
|
@@ -158,8 +154,6 @@
|
|
|
158
154
|
* @param {THREE.Mesh} mesh
|
|
159
155
|
*
|
|
160
156
|
*/
|
|
161
|
-
|
|
162
|
-
|
|
163
157
|
function compressPositions( mesh ) {
|
|
164
158
|
|
|
165
159
|
if ( ! mesh.geometry ) {
|
|
@@ -169,7 +163,6 @@
|
|
|
169
163
|
}
|
|
170
164
|
|
|
171
165
|
const position = mesh.geometry.attributes.position;
|
|
172
|
-
|
|
173
166
|
if ( ! position ) {
|
|
174
167
|
|
|
175
168
|
console.error( 'Geometry must contain position attribute. ' );
|
|
@@ -177,7 +170,6 @@
|
|
|
177
170
|
}
|
|
178
171
|
|
|
179
172
|
if ( position.isPacked ) return;
|
|
180
|
-
|
|
181
173
|
if ( position.itemSize != 3 ) {
|
|
182
174
|
|
|
183
175
|
console.error( 'position.itemSize is not 3, which cannot be packed. ' );
|
|
@@ -188,15 +180,17 @@
|
|
|
188
180
|
const encodingBytes = 2;
|
|
189
181
|
const result = quantizedEncode( array, encodingBytes );
|
|
190
182
|
const quantized = result.quantized;
|
|
191
|
-
const decodeMat = result.decodeMat;
|
|
183
|
+
const decodeMat = result.decodeMat;
|
|
192
184
|
|
|
185
|
+
// IMPORTANT: calculate original geometry bounding info first, before updating packed positions
|
|
193
186
|
if ( mesh.geometry.boundingBox == null ) mesh.geometry.computeBoundingBox();
|
|
194
187
|
if ( mesh.geometry.boundingSphere == null ) mesh.geometry.computeBoundingSphere();
|
|
195
188
|
mesh.geometry.setAttribute( 'position', new THREE.BufferAttribute( quantized, 3 ) );
|
|
196
189
|
mesh.geometry.attributes.position.isPacked = true;
|
|
197
190
|
mesh.geometry.attributes.position.needsUpdate = true;
|
|
198
|
-
mesh.geometry.attributes.position.bytes = quantized.length * encodingBytes;
|
|
191
|
+
mesh.geometry.attributes.position.bytes = quantized.length * encodingBytes;
|
|
199
192
|
|
|
193
|
+
// modify material
|
|
200
194
|
if ( ! ( mesh.material instanceof THREE.PackedPhongMaterial ) ) {
|
|
201
195
|
|
|
202
196
|
mesh.material = new THREE.PackedPhongMaterial().copy( mesh.material );
|
|
@@ -208,6 +202,7 @@
|
|
|
208
202
|
mesh.material.uniforms.quantizeMatPos.needsUpdate = true;
|
|
209
203
|
|
|
210
204
|
}
|
|
205
|
+
|
|
211
206
|
/**
|
|
212
207
|
* Make the input mesh.geometry's uv attribute encoded and compressed.
|
|
213
208
|
* Also will change the mesh.material to `PackedPhongMaterial` which let the vertex shader program decode the uv data.
|
|
@@ -215,8 +210,6 @@
|
|
|
215
210
|
* @param {THREE.Mesh} mesh
|
|
216
211
|
*
|
|
217
212
|
*/
|
|
218
|
-
|
|
219
|
-
|
|
220
213
|
function compressUvs( mesh ) {
|
|
221
214
|
|
|
222
215
|
if ( ! mesh.geometry ) {
|
|
@@ -226,7 +219,6 @@
|
|
|
226
219
|
}
|
|
227
220
|
|
|
228
221
|
const uvs = mesh.geometry.attributes.uv;
|
|
229
|
-
|
|
230
222
|
if ( ! uvs ) {
|
|
231
223
|
|
|
232
224
|
console.error( 'Geometry must contain uv attribute. ' );
|
|
@@ -239,7 +231,6 @@
|
|
|
239
231
|
max: - Infinity
|
|
240
232
|
};
|
|
241
233
|
const array = uvs.array;
|
|
242
|
-
|
|
243
234
|
for ( let i = 0; i < array.length; i ++ ) {
|
|
244
235
|
|
|
245
236
|
range.min = Math.min( range.min, array[ i ] );
|
|
@@ -248,12 +239,10 @@
|
|
|
248
239
|
}
|
|
249
240
|
|
|
250
241
|
let result;
|
|
251
|
-
|
|
252
242
|
if ( range.min >= - 1.0 && range.max <= 1.0 ) {
|
|
253
243
|
|
|
254
244
|
// use default encoding method
|
|
255
245
|
result = new Uint16Array( array.length );
|
|
256
|
-
|
|
257
246
|
for ( let i = 0; i < array.length; i += 2 ) {
|
|
258
247
|
|
|
259
248
|
const encoded = defaultEncode( array[ i ], array[ i + 1 ], 0, 2 );
|
|
@@ -266,7 +255,6 @@
|
|
|
266
255
|
mesh.geometry.attributes.uv.isPacked = true;
|
|
267
256
|
mesh.geometry.attributes.uv.needsUpdate = true;
|
|
268
257
|
mesh.geometry.attributes.uv.bytes = result.length * 2;
|
|
269
|
-
|
|
270
258
|
if ( ! ( mesh.material instanceof THREE.PackedPhongMaterial ) ) {
|
|
271
259
|
|
|
272
260
|
mesh.material = new THREE.PackedPhongMaterial().copy( mesh.material );
|
|
@@ -283,7 +271,6 @@
|
|
|
283
271
|
mesh.geometry.attributes.uv.isPacked = true;
|
|
284
272
|
mesh.geometry.attributes.uv.needsUpdate = true;
|
|
285
273
|
mesh.geometry.attributes.uv.bytes = result.quantized.length * 2;
|
|
286
|
-
|
|
287
274
|
if ( ! ( mesh.material instanceof THREE.PackedPhongMaterial ) ) {
|
|
288
275
|
|
|
289
276
|
mesh.material = new THREE.PackedPhongMaterial().copy( mesh.material );
|
|
@@ -296,8 +283,9 @@
|
|
|
296
283
|
|
|
297
284
|
}
|
|
298
285
|
|
|
299
|
-
}
|
|
286
|
+
}
|
|
300
287
|
|
|
288
|
+
// Encoding functions
|
|
301
289
|
|
|
302
290
|
function defaultEncode( x, y, z, bytes ) {
|
|
303
291
|
|
|
@@ -321,30 +309,30 @@
|
|
|
321
309
|
|
|
322
310
|
}
|
|
323
311
|
|
|
324
|
-
}
|
|
325
|
-
|
|
312
|
+
}
|
|
326
313
|
|
|
314
|
+
// for `Angles` encoding
|
|
327
315
|
function anglesEncode( x, y, z ) {
|
|
328
316
|
|
|
329
317
|
const normal0 = parseInt( 0.5 * ( 1.0 + Math.atan2( y, x ) / Math.PI ) * 65535 );
|
|
330
318
|
const normal1 = parseInt( 0.5 * ( 1.0 + z ) * 65535 );
|
|
331
319
|
return new Uint16Array( [ normal0, normal1 ] );
|
|
332
320
|
|
|
333
|
-
}
|
|
334
|
-
|
|
321
|
+
}
|
|
335
322
|
|
|
323
|
+
// for `Octahedron` encoding
|
|
336
324
|
function octEncodeBest( x, y, z, bytes ) {
|
|
337
325
|
|
|
338
|
-
let oct, dec, best, currentCos, bestCos;
|
|
339
|
-
// to minimize rounding errors
|
|
326
|
+
let oct, dec, best, currentCos, bestCos;
|
|
340
327
|
|
|
328
|
+
// Test various combinations of ceil and floor
|
|
329
|
+
// to minimize rounding errors
|
|
341
330
|
best = oct = octEncodeVec3( x, y, z, 'floor', 'floor' );
|
|
342
331
|
dec = octDecodeVec2( oct );
|
|
343
332
|
bestCos = dot( x, y, z, dec );
|
|
344
333
|
oct = octEncodeVec3( x, y, z, 'ceil', 'floor' );
|
|
345
334
|
dec = octDecodeVec2( oct );
|
|
346
335
|
currentCos = dot( x, y, z, dec );
|
|
347
|
-
|
|
348
336
|
if ( currentCos > bestCos ) {
|
|
349
337
|
|
|
350
338
|
best = oct;
|
|
@@ -355,7 +343,6 @@
|
|
|
355
343
|
oct = octEncodeVec3( x, y, z, 'floor', 'ceil' );
|
|
356
344
|
dec = octDecodeVec2( oct );
|
|
357
345
|
currentCos = dot( x, y, z, dec );
|
|
358
|
-
|
|
359
346
|
if ( currentCos > bestCos ) {
|
|
360
347
|
|
|
361
348
|
best = oct;
|
|
@@ -366,7 +353,6 @@
|
|
|
366
353
|
oct = octEncodeVec3( x, y, z, 'ceil', 'ceil' );
|
|
367
354
|
dec = octDecodeVec2( oct );
|
|
368
355
|
currentCos = dot( x, y, z, dec );
|
|
369
|
-
|
|
370
356
|
if ( currentCos > bestCos ) {
|
|
371
357
|
|
|
372
358
|
best = oct;
|
|
@@ -374,12 +360,10 @@
|
|
|
374
360
|
}
|
|
375
361
|
|
|
376
362
|
return best;
|
|
377
|
-
|
|
378
363
|
function octEncodeVec3( x0, y0, z0, xfunc, yfunc ) {
|
|
379
364
|
|
|
380
365
|
let x = x0 / ( Math.abs( x0 ) + Math.abs( y0 ) + Math.abs( z0 ) );
|
|
381
366
|
let y = y0 / ( Math.abs( x0 ) + Math.abs( y0 ) + Math.abs( z0 ) );
|
|
382
|
-
|
|
383
367
|
if ( z < 0 ) {
|
|
384
368
|
|
|
385
369
|
const tempx = ( 1 - Math.abs( y ) ) * ( x >= 0 ? 1 : - 1 );
|
|
@@ -387,7 +371,6 @@
|
|
|
387
371
|
x = tempx;
|
|
388
372
|
y = tempy;
|
|
389
373
|
let diff = 1 - Math.abs( x ) - Math.abs( y );
|
|
390
|
-
|
|
391
374
|
if ( diff > 0 ) {
|
|
392
375
|
|
|
393
376
|
diff += 0.001;
|
|
@@ -416,7 +399,6 @@
|
|
|
416
399
|
|
|
417
400
|
let x = oct[ 0 ];
|
|
418
401
|
let y = oct[ 1 ];
|
|
419
|
-
|
|
420
402
|
if ( bytes == 1 ) {
|
|
421
403
|
|
|
422
404
|
x /= x < 0 ? 127 : 128;
|
|
@@ -430,7 +412,6 @@
|
|
|
430
412
|
}
|
|
431
413
|
|
|
432
414
|
const z = 1 - Math.abs( x ) - Math.abs( y );
|
|
433
|
-
|
|
434
415
|
if ( z < 0 ) {
|
|
435
416
|
|
|
436
417
|
const tmpx = x;
|
|
@@ -455,7 +436,6 @@
|
|
|
455
436
|
function quantizedEncode( array, bytes ) {
|
|
456
437
|
|
|
457
438
|
let quantized, segments;
|
|
458
|
-
|
|
459
439
|
if ( bytes == 1 ) {
|
|
460
440
|
|
|
461
441
|
quantized = new Uint8Array( array.length );
|
|
@@ -477,7 +457,6 @@
|
|
|
477
457
|
const max = new Float32Array( 3 );
|
|
478
458
|
min[ 0 ] = min[ 1 ] = min[ 2 ] = Number.MAX_VALUE;
|
|
479
459
|
max[ 0 ] = max[ 1 ] = max[ 2 ] = - Number.MAX_VALUE;
|
|
480
|
-
|
|
481
460
|
for ( let i = 0; i < array.length; i += 3 ) {
|
|
482
461
|
|
|
483
462
|
min[ 0 ] = Math.min( min[ 0 ], array[ i + 0 ] );
|
|
@@ -495,7 +474,6 @@
|
|
|
495
474
|
decodeMat.elements[ 14 ] = min[ 2 ];
|
|
496
475
|
decodeMat.transpose();
|
|
497
476
|
const multiplier = new Float32Array( [ max[ 0 ] !== min[ 0 ] ? segments / ( max[ 0 ] - min[ 0 ] ) : 0, max[ 1 ] !== min[ 1 ] ? segments / ( max[ 1 ] - min[ 1 ] ) : 0, max[ 2 ] !== min[ 2 ] ? segments / ( max[ 2 ] - min[ 2 ] ) : 0 ] );
|
|
498
|
-
|
|
499
477
|
for ( let i = 0; i < array.length; i += 3 ) {
|
|
500
478
|
|
|
501
479
|
quantized[ i + 0 ] = Math.floor( ( array[ i + 0 ] - min[ 0 ] ) * multiplier[ 0 ] );
|
|
@@ -514,7 +492,6 @@
|
|
|
514
492
|
function quantizedEncodeUV( array, bytes ) {
|
|
515
493
|
|
|
516
494
|
let quantized, segments;
|
|
517
|
-
|
|
518
495
|
if ( bytes == 1 ) {
|
|
519
496
|
|
|
520
497
|
quantized = new Uint8Array( array.length );
|
|
@@ -536,7 +513,6 @@
|
|
|
536
513
|
const max = new Float32Array( 2 );
|
|
537
514
|
min[ 0 ] = min[ 1 ] = Number.MAX_VALUE;
|
|
538
515
|
max[ 0 ] = max[ 1 ] = - Number.MAX_VALUE;
|
|
539
|
-
|
|
540
516
|
for ( let i = 0; i < array.length; i += 2 ) {
|
|
541
517
|
|
|
542
518
|
min[ 0 ] = Math.min( min[ 0 ], array[ i + 0 ] );
|
|
@@ -551,7 +527,6 @@
|
|
|
551
527
|
decodeMat.elements[ 7 ] = min[ 1 ];
|
|
552
528
|
decodeMat.transpose();
|
|
553
529
|
const multiplier = new Float32Array( [ max[ 0 ] !== min[ 0 ] ? segments / ( max[ 0 ] - min[ 0 ] ) : 0, max[ 1 ] !== min[ 1 ] ? segments / ( max[ 1 ] - min[ 1 ] ) : 0 ] );
|
|
554
|
-
|
|
555
530
|
for ( let i = 0; i < array.length; i += 2 ) {
|
|
556
531
|
|
|
557
532
|
quantized[ i + 0 ] = Math.floor( ( array[ i + 0 ] - min[ 0 ] ) * multiplier[ 0 ] );
|
|
@@ -14,23 +14,24 @@
|
|
|
14
14
|
* @param v2 Corner index +X, +Z.
|
|
15
15
|
* @param v3 Corner index +X, -Z.
|
|
16
16
|
*/
|
|
17
|
-
|
|
18
17
|
function hilbert2D( center = new THREE.Vector3( 0, 0, 0 ), size = 10, iterations = 1, v0 = 0, v1 = 1, v2 = 2, v3 = 3 ) {
|
|
19
18
|
|
|
20
19
|
const half = size / 2;
|
|
21
20
|
const vec_s = [ new THREE.Vector3( center.x - half, center.y, center.z - half ), new THREE.Vector3( center.x - half, center.y, center.z + half ), new THREE.Vector3( center.x + half, center.y, center.z + half ), new THREE.Vector3( center.x + half, center.y, center.z - half ) ];
|
|
22
|
-
const vec = [ vec_s[ v0 ], vec_s[ v1 ], vec_s[ v2 ], vec_s[ v3 ] ];
|
|
21
|
+
const vec = [ vec_s[ v0 ], vec_s[ v1 ], vec_s[ v2 ], vec_s[ v3 ] ];
|
|
23
22
|
|
|
23
|
+
// Recurse iterations
|
|
24
24
|
if ( 0 <= -- iterations ) {
|
|
25
25
|
|
|
26
26
|
return [ ...hilbert2D( vec[ 0 ], half, iterations, v0, v3, v2, v1 ), ...hilbert2D( vec[ 1 ], half, iterations, v0, v1, v2, v3 ), ...hilbert2D( vec[ 2 ], half, iterations, v0, v1, v2, v3 ), ...hilbert2D( vec[ 3 ], half, iterations, v2, v1, v0, v3 ) ];
|
|
27
27
|
|
|
28
|
-
}
|
|
29
|
-
|
|
28
|
+
}
|
|
30
29
|
|
|
30
|
+
// Return complete Hilbert Curve.
|
|
31
31
|
return vec;
|
|
32
32
|
|
|
33
33
|
}
|
|
34
|
+
|
|
34
35
|
/**
|
|
35
36
|
* Generates 3D-Coordinates in a very fast way.
|
|
36
37
|
*
|
|
@@ -49,25 +50,25 @@
|
|
|
49
50
|
* @param v6 Corner index +X, +Y, +Z.
|
|
50
51
|
* @param v7 Corner index +X, +Y, -Z.
|
|
51
52
|
*/
|
|
52
|
-
|
|
53
|
-
|
|
54
53
|
function hilbert3D( center = new THREE.Vector3( 0, 0, 0 ), size = 10, iterations = 1, v0 = 0, v1 = 1, v2 = 2, v3 = 3, v4 = 4, v5 = 5, v6 = 6, v7 = 7 ) {
|
|
55
54
|
|
|
56
55
|
// Default Vars
|
|
57
56
|
const half = size / 2;
|
|
58
57
|
const vec_s = [ new THREE.Vector3( center.x - half, center.y + half, center.z - half ), new THREE.Vector3( center.x - half, center.y + half, center.z + half ), new THREE.Vector3( center.x - half, center.y - half, center.z + half ), new THREE.Vector3( center.x - half, center.y - half, center.z - half ), new THREE.Vector3( center.x + half, center.y - half, center.z - half ), new THREE.Vector3( center.x + half, center.y - half, center.z + half ), new THREE.Vector3( center.x + half, center.y + half, center.z + half ), new THREE.Vector3( center.x + half, center.y + half, center.z - half ) ];
|
|
59
|
-
const vec = [ vec_s[ v0 ], vec_s[ v1 ], vec_s[ v2 ], vec_s[ v3 ], vec_s[ v4 ], vec_s[ v5 ], vec_s[ v6 ], vec_s[ v7 ] ];
|
|
58
|
+
const vec = [ vec_s[ v0 ], vec_s[ v1 ], vec_s[ v2 ], vec_s[ v3 ], vec_s[ v4 ], vec_s[ v5 ], vec_s[ v6 ], vec_s[ v7 ] ];
|
|
60
59
|
|
|
60
|
+
// Recurse iterations
|
|
61
61
|
if ( -- iterations >= 0 ) {
|
|
62
62
|
|
|
63
63
|
return [ ...hilbert3D( vec[ 0 ], half, iterations, v0, v3, v4, v7, v6, v5, v2, v1 ), ...hilbert3D( vec[ 1 ], half, iterations, v0, v7, v6, v1, v2, v5, v4, v3 ), ...hilbert3D( vec[ 2 ], half, iterations, v0, v7, v6, v1, v2, v5, v4, v3 ), ...hilbert3D( vec[ 3 ], half, iterations, v2, v3, v0, v1, v6, v7, v4, v5 ), ...hilbert3D( vec[ 4 ], half, iterations, v2, v3, v0, v1, v6, v7, v4, v5 ), ...hilbert3D( vec[ 5 ], half, iterations, v4, v3, v2, v5, v6, v1, v0, v7 ), ...hilbert3D( vec[ 6 ], half, iterations, v4, v3, v2, v5, v6, v1, v0, v7 ), ...hilbert3D( vec[ 7 ], half, iterations, v6, v5, v2, v1, v0, v3, v4, v7 ) ];
|
|
64
64
|
|
|
65
|
-
}
|
|
66
|
-
|
|
65
|
+
}
|
|
67
66
|
|
|
67
|
+
// Return complete Hilbert Curve.
|
|
68
68
|
return vec;
|
|
69
69
|
|
|
70
70
|
}
|
|
71
|
+
|
|
71
72
|
/**
|
|
72
73
|
* Generates a Gosper curve (lying in the XY plane)
|
|
73
74
|
*
|
|
@@ -75,23 +76,18 @@
|
|
|
75
76
|
*
|
|
76
77
|
* @param size The size of a single gosper island.
|
|
77
78
|
*/
|
|
78
|
-
|
|
79
|
-
|
|
80
79
|
function gosper( size = 1 ) {
|
|
81
80
|
|
|
82
81
|
function fractalize( config ) {
|
|
83
82
|
|
|
84
83
|
let output;
|
|
85
84
|
let input = config.axiom;
|
|
86
|
-
|
|
87
85
|
for ( let i = 0, il = config.steps; 0 <= il ? i < il : i > il; 0 <= il ? i ++ : i -- ) {
|
|
88
86
|
|
|
89
87
|
output = '';
|
|
90
|
-
|
|
91
88
|
for ( let j = 0, jl = input.length; j < jl; j ++ ) {
|
|
92
89
|
|
|
93
90
|
const char = input[ j ];
|
|
94
|
-
|
|
95
91
|
if ( char in config.rules ) {
|
|
96
92
|
|
|
97
93
|
output += config.rules[ char ];
|
|
@@ -119,11 +115,9 @@
|
|
|
119
115
|
let angle = 0;
|
|
120
116
|
const path = [ 0, 0, 0 ];
|
|
121
117
|
const fractal = config.fractal;
|
|
122
|
-
|
|
123
118
|
for ( let i = 0, l = fractal.length; i < l; i ++ ) {
|
|
124
119
|
|
|
125
120
|
const char = fractal[ i ];
|
|
126
|
-
|
|
127
121
|
if ( char === '+' ) {
|
|
128
122
|
|
|
129
123
|
angle += config.angle;
|
|
@@ -144,8 +138,9 @@
|
|
|
144
138
|
|
|
145
139
|
return path;
|
|
146
140
|
|
|
147
|
-
}
|
|
141
|
+
}
|
|
148
142
|
|
|
143
|
+
//
|
|
149
144
|
|
|
150
145
|
const gosper = fractalize( {
|
|
151
146
|
axiom: 'A',
|
|
@@ -159,8 +154,8 @@
|
|
|
159
154
|
fractal: gosper,
|
|
160
155
|
size: size,
|
|
161
156
|
angle: Math.PI / 3 // 60 degrees
|
|
162
|
-
|
|
163
157
|
} );
|
|
158
|
+
|
|
164
159
|
return points;
|
|
165
160
|
|
|
166
161
|
}
|
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
// Merges geometries in object by materials and returns new object. Use on not indexed geometries.
|
|
8
8
|
// The object buffers reference the old object ones.
|
|
9
9
|
// Special treatment is done to the conditional lines generated by LDrawLoader.
|
|
10
|
+
|
|
10
11
|
function extractGroup( geometry, group, elementSize, isConditionalLine ) {
|
|
11
12
|
|
|
12
13
|
// Extracts a group from a geometry as a new geometry (with attribute buffers referencing original buffers)
|
|
14
|
+
|
|
13
15
|
const newGeometry = new THREE.BufferGeometry();
|
|
14
16
|
const originalPositions = geometry.getAttribute( 'position' ).array;
|
|
15
17
|
const originalNormals = elementSize === 3 ? geometry.getAttribute( 'normal' ).array : null;
|
|
@@ -20,7 +22,6 @@
|
|
|
20
22
|
const normals = originalNormals !== null ? originalNormals.subarray( vertStart, vertEnd ) : null;
|
|
21
23
|
newGeometry.setAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) );
|
|
22
24
|
if ( normals !== null ) newGeometry.setAttribute( 'normal', new THREE.BufferAttribute( normals, 3 ) );
|
|
23
|
-
|
|
24
25
|
if ( isConditionalLine ) {
|
|
25
26
|
|
|
26
27
|
const controlArray0 = geometry.getAttribute( 'control0' ).array.subarray( vertStart, vertEnd );
|
|
@@ -39,7 +40,6 @@
|
|
|
39
40
|
function addGeometry( mat, geometry, geometries ) {
|
|
40
41
|
|
|
41
42
|
const geoms = geometries[ mat.uuid ];
|
|
42
|
-
|
|
43
43
|
if ( ! geoms ) {
|
|
44
44
|
|
|
45
45
|
geometries[ mat.uuid ] = {
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
function permuteAttribute( attribute, elemSize ) {
|
|
59
59
|
|
|
60
60
|
// Permutes first two vertices of each attribute element
|
|
61
|
+
|
|
61
62
|
if ( ! attribute ) return;
|
|
62
63
|
const verts = attribute.array;
|
|
63
64
|
const numVerts = Math.floor( verts.length / 3 );
|
|
64
65
|
let offset = 0;
|
|
65
|
-
|
|
66
66
|
for ( let i = 0; i < numVerts; i ++ ) {
|
|
67
67
|
|
|
68
68
|
const x = verts[ offset ];
|
|
@@ -78,8 +78,9 @@
|
|
|
78
78
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
}
|
|
81
|
+
}
|
|
82
82
|
|
|
83
|
+
// Traverse the object hierarchy collecting geometries and transforming them to world space
|
|
83
84
|
|
|
84
85
|
const meshGeometries = {};
|
|
85
86
|
const linesGeometries = {};
|
|
@@ -93,7 +94,6 @@
|
|
|
93
94
|
const elemSize = c.isMesh ? 3 : 2;
|
|
94
95
|
const geometry = c.geometry.clone();
|
|
95
96
|
const matrixIsInverted = c.matrixWorld.determinant() < 0;
|
|
96
|
-
|
|
97
97
|
if ( matrixIsInverted ) {
|
|
98
98
|
|
|
99
99
|
permuteAttribute( geometry.attributes.position, elemSize );
|
|
@@ -102,7 +102,6 @@
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
geometry.applyMatrix4( c.matrixWorld );
|
|
105
|
-
|
|
106
105
|
if ( c.isConditionalLine ) {
|
|
107
106
|
|
|
108
107
|
geometry.attributes.control0.applyMatrix4( c.matrixWorld );
|
|
@@ -113,7 +112,6 @@
|
|
|
113
112
|
}
|
|
114
113
|
|
|
115
114
|
const geometries = c.isMesh ? meshGeometries : c.isConditionalLine ? condLinesGeometries : linesGeometries;
|
|
116
|
-
|
|
117
115
|
if ( Array.isArray( c.material ) ) {
|
|
118
116
|
|
|
119
117
|
for ( const groupIndex in geometry.groups ) {
|
|
@@ -133,11 +131,12 @@
|
|
|
133
131
|
|
|
134
132
|
}
|
|
135
133
|
|
|
136
|
-
} );
|
|
134
|
+
} );
|
|
135
|
+
|
|
136
|
+
// Create object with merged geometries
|
|
137
137
|
|
|
138
138
|
const mergedObject = new THREE.Group();
|
|
139
139
|
const meshMaterialsIds = Object.keys( meshGeometries );
|
|
140
|
-
|
|
141
140
|
for ( const meshMaterialsId of meshMaterialsIds ) {
|
|
142
141
|
|
|
143
142
|
const meshGeometry = meshGeometries[ meshMaterialsId ];
|
|
@@ -147,7 +146,6 @@
|
|
|
147
146
|
}
|
|
148
147
|
|
|
149
148
|
const linesMaterialsIds = Object.keys( linesGeometries );
|
|
150
|
-
|
|
151
149
|
for ( const linesMaterialsId of linesMaterialsIds ) {
|
|
152
150
|
|
|
153
151
|
const lineGeometry = linesGeometries[ linesMaterialsId ];
|
|
@@ -157,7 +155,6 @@
|
|
|
157
155
|
}
|
|
158
156
|
|
|
159
157
|
const condLinesMaterialsIds = Object.keys( condLinesGeometries );
|
|
160
|
-
|
|
161
158
|
for ( const condLinesMaterialsId of condLinesMaterialsIds ) {
|
|
162
159
|
|
|
163
160
|
const condLineGeometry = condLinesGeometries[ condLinesMaterialsId ];
|