@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
|
@@ -19,11 +19,9 @@ U : knot vector
|
|
|
19
19
|
|
|
20
20
|
returns the span
|
|
21
21
|
*/
|
|
22
|
-
|
|
23
22
|
function findSpan( p, u, U ) {
|
|
24
23
|
|
|
25
24
|
const n = U.length - p - 1;
|
|
26
|
-
|
|
27
25
|
if ( u >= U[ n ] ) {
|
|
28
26
|
|
|
29
27
|
return n - 1;
|
|
@@ -39,7 +37,6 @@ returns the span
|
|
|
39
37
|
let low = p;
|
|
40
38
|
let high = n;
|
|
41
39
|
let mid = Math.floor( ( low + high ) / 2 );
|
|
42
|
-
|
|
43
40
|
while ( u < U[ mid ] || u >= U[ mid + 1 ] ) {
|
|
44
41
|
|
|
45
42
|
if ( u < U[ mid ] ) {
|
|
@@ -59,6 +56,7 @@ returns the span
|
|
|
59
56
|
return mid;
|
|
60
57
|
|
|
61
58
|
}
|
|
59
|
+
|
|
62
60
|
/*
|
|
63
61
|
Calculate basis functions. See The NURBS Book, page 70, algorithm A2.2
|
|
64
62
|
|
|
@@ -69,21 +67,17 @@ U : knot vector
|
|
|
69
67
|
|
|
70
68
|
returns array[p+1] with basis functions values.
|
|
71
69
|
*/
|
|
72
|
-
|
|
73
|
-
|
|
74
70
|
function calcBasisFunctions( span, u, p, U ) {
|
|
75
71
|
|
|
76
72
|
const N = [];
|
|
77
73
|
const left = [];
|
|
78
74
|
const right = [];
|
|
79
75
|
N[ 0 ] = 1.0;
|
|
80
|
-
|
|
81
76
|
for ( let j = 1; j <= p; ++ j ) {
|
|
82
77
|
|
|
83
78
|
left[ j ] = u - U[ span + 1 - j ];
|
|
84
79
|
right[ j ] = U[ span + j ] - u;
|
|
85
80
|
let saved = 0.0;
|
|
86
|
-
|
|
87
81
|
for ( let r = 0; r < j; ++ r ) {
|
|
88
82
|
|
|
89
83
|
const rv = right[ r + 1 ];
|
|
@@ -101,6 +95,7 @@ returns array[p+1] with basis functions values.
|
|
|
101
95
|
return N;
|
|
102
96
|
|
|
103
97
|
}
|
|
98
|
+
|
|
104
99
|
/*
|
|
105
100
|
Calculate B-Spline curve points. See The NURBS Book, page 82, algorithm A3.1.
|
|
106
101
|
|
|
@@ -111,14 +106,11 @@ u : parametric point
|
|
|
111
106
|
|
|
112
107
|
returns point for given u
|
|
113
108
|
*/
|
|
114
|
-
|
|
115
|
-
|
|
116
109
|
function calcBSplinePoint( p, U, P, u ) {
|
|
117
110
|
|
|
118
111
|
const span = findSpan( p, u, U );
|
|
119
112
|
const N = calcBasisFunctions( span, u, p, U );
|
|
120
113
|
const C = new THREE.Vector4( 0, 0, 0, 0 );
|
|
121
|
-
|
|
122
114
|
for ( let j = 0; j <= p; ++ j ) {
|
|
123
115
|
|
|
124
116
|
const point = P[ span - p + j ];
|
|
@@ -134,6 +126,7 @@ returns point for given u
|
|
|
134
126
|
return C;
|
|
135
127
|
|
|
136
128
|
}
|
|
129
|
+
|
|
137
130
|
/*
|
|
138
131
|
Calculate basis functions derivatives. See The NURBS Book, page 72, algorithm A2.3.
|
|
139
132
|
|
|
@@ -145,32 +138,22 @@ U : knot vector
|
|
|
145
138
|
|
|
146
139
|
returns array[n+1][p+1] with basis functions derivatives
|
|
147
140
|
*/
|
|
148
|
-
|
|
149
|
-
|
|
150
141
|
function calcBasisFunctionDerivatives( span, u, p, n, U ) {
|
|
151
142
|
|
|
152
143
|
const zeroArr = [];
|
|
153
|
-
|
|
154
144
|
for ( let i = 0; i <= p; ++ i ) zeroArr[ i ] = 0.0;
|
|
155
|
-
|
|
156
145
|
const ders = [];
|
|
157
|
-
|
|
158
146
|
for ( let i = 0; i <= n; ++ i ) ders[ i ] = zeroArr.slice( 0 );
|
|
159
|
-
|
|
160
147
|
const ndu = [];
|
|
161
|
-
|
|
162
148
|
for ( let i = 0; i <= p; ++ i ) ndu[ i ] = zeroArr.slice( 0 );
|
|
163
|
-
|
|
164
149
|
ndu[ 0 ][ 0 ] = 1.0;
|
|
165
150
|
const left = zeroArr.slice( 0 );
|
|
166
151
|
const right = zeroArr.slice( 0 );
|
|
167
|
-
|
|
168
152
|
for ( let j = 1; j <= p; ++ j ) {
|
|
169
153
|
|
|
170
154
|
left[ j ] = u - U[ span + 1 - j ];
|
|
171
155
|
right[ j ] = U[ span + j ] - u;
|
|
172
156
|
let saved = 0.0;
|
|
173
|
-
|
|
174
157
|
for ( let r = 0; r < j; ++ r ) {
|
|
175
158
|
|
|
176
159
|
const rv = right[ r + 1 ];
|
|
@@ -197,7 +180,6 @@ returns array[n+1][p+1] with basis functions derivatives
|
|
|
197
180
|
let s1 = 0;
|
|
198
181
|
let s2 = 1;
|
|
199
182
|
const a = [];
|
|
200
|
-
|
|
201
183
|
for ( let i = 0; i <= p; ++ i ) {
|
|
202
184
|
|
|
203
185
|
a[ i ] = zeroArr.slice( 0 );
|
|
@@ -205,13 +187,11 @@ returns array[n+1][p+1] with basis functions derivatives
|
|
|
205
187
|
}
|
|
206
188
|
|
|
207
189
|
a[ 0 ][ 0 ] = 1.0;
|
|
208
|
-
|
|
209
190
|
for ( let k = 1; k <= n; ++ k ) {
|
|
210
191
|
|
|
211
192
|
let d = 0.0;
|
|
212
193
|
const rk = r - k;
|
|
213
194
|
const pk = p - k;
|
|
214
|
-
|
|
215
195
|
if ( r >= k ) {
|
|
216
196
|
|
|
217
197
|
a[ s2 ][ 0 ] = a[ s1 ][ 0 ] / ndu[ pk + 1 ][ rk ];
|
|
@@ -221,7 +201,6 @@ returns array[n+1][p+1] with basis functions derivatives
|
|
|
221
201
|
|
|
222
202
|
const j1 = rk >= - 1 ? 1 : - rk;
|
|
223
203
|
const j2 = r - 1 <= pk ? k - 1 : p - r;
|
|
224
|
-
|
|
225
204
|
for ( let j = j1; j <= j2; ++ j ) {
|
|
226
205
|
|
|
227
206
|
a[ s2 ][ j ] = ( a[ s1 ][ j ] - a[ s1 ][ j - 1 ] ) / ndu[ pk + 1 ][ rk + j ];
|
|
@@ -246,7 +225,6 @@ returns array[n+1][p+1] with basis functions derivatives
|
|
|
246
225
|
}
|
|
247
226
|
|
|
248
227
|
let r = p;
|
|
249
|
-
|
|
250
228
|
for ( let k = 1; k <= n; ++ k ) {
|
|
251
229
|
|
|
252
230
|
for ( let j = 0; j <= p; ++ j ) {
|
|
@@ -262,6 +240,7 @@ returns array[n+1][p+1] with basis functions derivatives
|
|
|
262
240
|
return ders;
|
|
263
241
|
|
|
264
242
|
}
|
|
243
|
+
|
|
265
244
|
/*
|
|
266
245
|
Calculate derivatives of a B-Spline. See The NURBS Book, page 93, algorithm A3.2.
|
|
267
246
|
|
|
@@ -273,8 +252,6 @@ returns array[n+1][p+1] with basis functions derivatives
|
|
|
273
252
|
|
|
274
253
|
returns array[d+1] with derivatives
|
|
275
254
|
*/
|
|
276
|
-
|
|
277
|
-
|
|
278
255
|
function calcBSplineDerivatives( p, U, P, u, nd ) {
|
|
279
256
|
|
|
280
257
|
const du = nd < p ? nd : p;
|
|
@@ -282,7 +259,6 @@ returns array[n+1][p+1] with basis functions derivatives
|
|
|
282
259
|
const span = findSpan( p, u, U );
|
|
283
260
|
const nders = calcBasisFunctionDerivatives( span, u, p, du, U );
|
|
284
261
|
const Pw = [];
|
|
285
|
-
|
|
286
262
|
for ( let i = 0; i < P.length; ++ i ) {
|
|
287
263
|
|
|
288
264
|
const point = P[ i ].clone();
|
|
@@ -297,7 +273,6 @@ returns array[n+1][p+1] with basis functions derivatives
|
|
|
297
273
|
for ( let k = 0; k <= du; ++ k ) {
|
|
298
274
|
|
|
299
275
|
const point = Pw[ span - p ].clone().multiplyScalar( nders[ k ][ 0 ] );
|
|
300
|
-
|
|
301
276
|
for ( let j = 1; j <= p; ++ j ) {
|
|
302
277
|
|
|
303
278
|
point.add( Pw[ span - p + j ].clone().multiplyScalar( nders[ k ][ j ] ) );
|
|
@@ -317,17 +292,15 @@ returns array[n+1][p+1] with basis functions derivatives
|
|
|
317
292
|
return CK;
|
|
318
293
|
|
|
319
294
|
}
|
|
295
|
+
|
|
320
296
|
/*
|
|
321
297
|
Calculate "K over I"
|
|
322
298
|
|
|
323
299
|
returns k!/(i!(k-i)!)
|
|
324
300
|
*/
|
|
325
|
-
|
|
326
|
-
|
|
327
301
|
function calcKoverI( k, i ) {
|
|
328
302
|
|
|
329
303
|
let nom = 1;
|
|
330
|
-
|
|
331
304
|
for ( let j = 2; j <= k; ++ j ) {
|
|
332
305
|
|
|
333
306
|
nom *= j;
|
|
@@ -335,7 +308,6 @@ returns k!/(i!(k-i)!)
|
|
|
335
308
|
}
|
|
336
309
|
|
|
337
310
|
let denom = 1;
|
|
338
|
-
|
|
339
311
|
for ( let j = 2; j <= i; ++ j ) {
|
|
340
312
|
|
|
341
313
|
denom *= j;
|
|
@@ -351,6 +323,7 @@ returns k!/(i!(k-i)!)
|
|
|
351
323
|
return nom / denom;
|
|
352
324
|
|
|
353
325
|
}
|
|
326
|
+
|
|
354
327
|
/*
|
|
355
328
|
Calculate derivatives (0-nd) of rational curve. See The NURBS Book, page 127, algorithm A4.2.
|
|
356
329
|
|
|
@@ -358,14 +331,11 @@ Pders : result of function calcBSplineDerivatives
|
|
|
358
331
|
|
|
359
332
|
returns array with derivatives for rational curve.
|
|
360
333
|
*/
|
|
361
|
-
|
|
362
|
-
|
|
363
334
|
function calcRationalCurveDerivatives( Pders ) {
|
|
364
335
|
|
|
365
336
|
const nd = Pders.length;
|
|
366
337
|
const Aders = [];
|
|
367
338
|
const wders = [];
|
|
368
|
-
|
|
369
339
|
for ( let i = 0; i < nd; ++ i ) {
|
|
370
340
|
|
|
371
341
|
const point = Pders[ i ];
|
|
@@ -375,11 +345,9 @@ returns array with derivatives for rational curve.
|
|
|
375
345
|
}
|
|
376
346
|
|
|
377
347
|
const CK = [];
|
|
378
|
-
|
|
379
348
|
for ( let k = 0; k < nd; ++ k ) {
|
|
380
349
|
|
|
381
350
|
const v = Aders[ k ].clone();
|
|
382
|
-
|
|
383
351
|
for ( let i = 1; i <= k; ++ i ) {
|
|
384
352
|
|
|
385
353
|
v.sub( CK[ k - i ].clone().multiplyScalar( calcKoverI( k, i ) * wders[ i ] ) );
|
|
@@ -393,6 +361,7 @@ returns array with derivatives for rational curve.
|
|
|
393
361
|
return CK;
|
|
394
362
|
|
|
395
363
|
}
|
|
364
|
+
|
|
396
365
|
/*
|
|
397
366
|
Calculate NURBS curve derivatives. See The NURBS Book, page 127, algorithm A4.2.
|
|
398
367
|
|
|
@@ -404,14 +373,13 @@ nd : number of derivatives
|
|
|
404
373
|
|
|
405
374
|
returns array with derivatives.
|
|
406
375
|
*/
|
|
407
|
-
|
|
408
|
-
|
|
409
376
|
function calcNURBSDerivatives( p, U, P, u, nd ) {
|
|
410
377
|
|
|
411
378
|
const Pders = calcBSplineDerivatives( p, U, P, u, nd );
|
|
412
379
|
return calcRationalCurveDerivatives( Pders );
|
|
413
380
|
|
|
414
381
|
}
|
|
382
|
+
|
|
415
383
|
/*
|
|
416
384
|
Calculate rational B-Spline surface point. See The NURBS Book, page 134, algorithm A4.3.
|
|
417
385
|
|
|
@@ -422,8 +390,6 @@ u, v : parametric values
|
|
|
422
390
|
|
|
423
391
|
returns point for given (u, v)
|
|
424
392
|
*/
|
|
425
|
-
|
|
426
|
-
|
|
427
393
|
function calcSurfacePoint( p, q, U, V, P, u, v, target ) {
|
|
428
394
|
|
|
429
395
|
const uspan = findSpan( p, u, U );
|
|
@@ -431,11 +397,9 @@ returns point for given (u, v)
|
|
|
431
397
|
const Nu = calcBasisFunctions( uspan, u, p, U );
|
|
432
398
|
const Nv = calcBasisFunctions( vspan, v, q, V );
|
|
433
399
|
const temp = [];
|
|
434
|
-
|
|
435
400
|
for ( let l = 0; l <= q; ++ l ) {
|
|
436
401
|
|
|
437
402
|
temp[ l ] = new THREE.Vector4( 0, 0, 0, 0 );
|
|
438
|
-
|
|
439
403
|
for ( let k = 0; k <= p; ++ k ) {
|
|
440
404
|
|
|
441
405
|
const point = P[ uspan - p + k ][ vspan - q + l ].clone();
|
|
@@ -450,7 +414,6 @@ returns point for given (u, v)
|
|
|
450
414
|
}
|
|
451
415
|
|
|
452
416
|
const Sw = new THREE.Vector4( 0, 0, 0, 0 );
|
|
453
|
-
|
|
454
417
|
for ( let l = 0; l <= q; ++ l ) {
|
|
455
418
|
|
|
456
419
|
Sw.add( temp[ l ].multiplyScalar( Nv[ l ] ) );
|
|
@@ -5,25 +5,19 @@
|
|
|
5
5
|
constructor( renderer, width = 512, height = 512 ) {
|
|
6
6
|
|
|
7
7
|
// Dubois matrices from https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.7.6968&rep=rep1&type=pdf#page=4
|
|
8
|
+
|
|
8
9
|
this.colorMatrixLeft = new THREE.Matrix3().fromArray( [ 0.456100, - 0.0400822, - 0.0152161, 0.500484, - 0.0378246, - 0.0205971, 0.176381, - 0.0157589, - 0.00546856 ] );
|
|
9
10
|
this.colorMatrixRight = new THREE.Matrix3().fromArray( [ - 0.0434706, 0.378476, - 0.0721527, - 0.0879388, 0.73364, - 0.112961, - 0.00155529, - 0.0184503, 1.2264 ] );
|
|
10
|
-
|
|
11
11
|
const _camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
|
|
12
|
-
|
|
13
12
|
const _scene = new THREE.Scene();
|
|
14
|
-
|
|
15
13
|
const _stereo = new THREE.StereoCamera();
|
|
16
|
-
|
|
17
14
|
const _params = {
|
|
18
15
|
minFilter: THREE.LinearFilter,
|
|
19
16
|
magFilter: THREE.NearestFilter,
|
|
20
17
|
format: THREE.RGBAFormat
|
|
21
18
|
};
|
|
22
|
-
|
|
23
19
|
const _renderTargetL = new THREE.WebGLRenderTarget( width, height, _params );
|
|
24
|
-
|
|
25
20
|
const _renderTargetR = new THREE.WebGLRenderTarget( width, height, _params );
|
|
26
|
-
|
|
27
21
|
const _material = new THREE.ShaderMaterial( {
|
|
28
22
|
uniforms: {
|
|
29
23
|
'mapLeft': {
|
|
@@ -40,21 +34,18 @@
|
|
|
40
34
|
}
|
|
41
35
|
},
|
|
42
36
|
vertexShader: [ 'varying vec2 vUv;', 'void main() {', ' vUv = vec2( uv.x, uv.y );', ' gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );', '}' ].join( '\n' ),
|
|
43
|
-
fragmentShader: [ 'uniform sampler2D mapLeft;', 'uniform sampler2D mapRight;', 'varying vec2 vUv;', 'uniform mat3 colorMatrixLeft;', 'uniform mat3 colorMatrixRight;',
|
|
37
|
+
fragmentShader: [ 'uniform sampler2D mapLeft;', 'uniform sampler2D mapRight;', 'varying vec2 vUv;', 'uniform mat3 colorMatrixLeft;', 'uniform mat3 colorMatrixRight;',
|
|
38
|
+
// These functions implement sRGB linearization and gamma correction
|
|
39
|
+
|
|
44
40
|
'float lin( float c ) {', ' return c <= 0.04045 ? c * 0.0773993808 :', ' pow( c * 0.9478672986 + 0.0521327014, 2.4 );', '}', 'vec4 lin( vec4 c ) {', ' return vec4( lin( c.r ), lin( c.g ), lin( c.b ), c.a );', '}', 'float dev( float c ) {', ' return c <= 0.0031308 ? c * 12.92', ' : pow( c, 0.41666 ) * 1.055 - 0.055;', '}', 'void main() {', ' vec2 uv = vUv;', ' vec4 colorL = lin( texture2D( mapLeft, uv ) );', ' vec4 colorR = lin( texture2D( mapRight, uv ) );', ' vec3 color = clamp(', ' colorMatrixLeft * colorL.rgb +', ' colorMatrixRight * colorR.rgb, 0., 1. );', ' gl_FragColor = vec4(', ' dev( color.r ), dev( color.g ), dev( color.b ),', ' max( colorL.a, colorR.a ) );', '}' ].join( '\n' )
|
|
45
41
|
} );
|
|
46
|
-
|
|
47
42
|
const _mesh = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), _material );
|
|
48
|
-
|
|
49
43
|
_scene.add( _mesh );
|
|
50
|
-
|
|
51
44
|
this.setSize = function ( width, height ) {
|
|
52
45
|
|
|
53
46
|
renderer.setSize( width, height );
|
|
54
47
|
const pixelRatio = renderer.getPixelRatio();
|
|
55
|
-
|
|
56
48
|
_renderTargetL.setSize( width * pixelRatio, height * pixelRatio );
|
|
57
|
-
|
|
58
49
|
_renderTargetR.setSize( width * pixelRatio, height * pixelRatio );
|
|
59
50
|
|
|
60
51
|
};
|
|
@@ -64,9 +55,7 @@
|
|
|
64
55
|
const currentRenderTarget = renderer.getRenderTarget();
|
|
65
56
|
if ( scene.matrixWorldAutoUpdate === true ) scene.updateMatrixWorld();
|
|
66
57
|
if ( camera.parent === null && camera.matrixWorldAutoUpdate === true ) camera.updateMatrixWorld();
|
|
67
|
-
|
|
68
58
|
_stereo.update( camera );
|
|
69
|
-
|
|
70
59
|
renderer.setRenderTarget( _renderTargetL );
|
|
71
60
|
renderer.clear();
|
|
72
61
|
renderer.render( scene, _stereo.cameraL );
|
|
@@ -82,11 +71,8 @@
|
|
|
82
71
|
this.dispose = function () {
|
|
83
72
|
|
|
84
73
|
_renderTargetL.dispose();
|
|
85
|
-
|
|
86
74
|
_renderTargetR.dispose();
|
|
87
|
-
|
|
88
75
|
_mesh.geometry.dispose();
|
|
89
|
-
|
|
90
76
|
_mesh.material.dispose();
|
|
91
77
|
|
|
92
78
|
};
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* 16 April 2012 - @blurspline
|
|
7
7
|
*/
|
|
8
|
+
|
|
8
9
|
class AsciiEffect {
|
|
9
10
|
|
|
10
11
|
constructor( renderer, charSet = ' .:-=+*#%@', options = {} ) {
|
|
@@ -12,18 +13,15 @@
|
|
|
12
13
|
// ' .,:;=|iI+hHOE#`$';
|
|
13
14
|
// darker bolder character set from https://github.com/saw/Canvas-ASCII-Art/
|
|
14
15
|
// ' .\'`^",:;Il!i~+_-?][}{1)(|/tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$'.split('');
|
|
16
|
+
|
|
15
17
|
// Some ASCII settings
|
|
16
|
-
const fResolution = options[ 'resolution' ] || 0.15; // Higher for more details
|
|
17
18
|
|
|
19
|
+
const fResolution = options[ 'resolution' ] || 0.15; // Higher for more details
|
|
18
20
|
const iScale = options[ 'scale' ] || 1;
|
|
19
21
|
const bColor = options[ 'color' ] || false; // nice but slows down rendering!
|
|
20
|
-
|
|
21
22
|
const bAlpha = options[ 'alpha' ] || false; // Transparency
|
|
22
|
-
|
|
23
23
|
const bBlock = options[ 'block' ] || false; // blocked characters. like good O dos
|
|
24
|
-
|
|
25
24
|
const bInvert = options[ 'invert' ] || false; // black is white, white is black
|
|
26
|
-
|
|
27
25
|
const strResolution = options[ 'strResolution' ] || 'low';
|
|
28
26
|
let width, height;
|
|
29
27
|
const domElement = document.createElement( 'div' );
|
|
@@ -32,7 +30,6 @@
|
|
|
32
30
|
domElement.appendChild( oAscii );
|
|
33
31
|
let iWidth, iHeight;
|
|
34
32
|
let oImg;
|
|
35
|
-
|
|
36
33
|
this.setSize = function ( w, h ) {
|
|
37
34
|
|
|
38
35
|
width = w;
|
|
@@ -49,19 +46,21 @@
|
|
|
49
46
|
|
|
50
47
|
};
|
|
51
48
|
|
|
52
|
-
this.domElement = domElement;
|
|
49
|
+
this.domElement = domElement;
|
|
50
|
+
|
|
51
|
+
// Throw in ascii library from https://github.com/hassadee/jsascii/blob/master/jsascii.js (MIT License)
|
|
53
52
|
|
|
54
53
|
function initAsciiSize() {
|
|
55
54
|
|
|
56
55
|
iWidth = Math.round( width * fResolution );
|
|
57
56
|
iHeight = Math.round( height * fResolution );
|
|
58
57
|
oCanvas.width = iWidth;
|
|
59
|
-
oCanvas.height = iHeight;
|
|
58
|
+
oCanvas.height = iHeight;
|
|
59
|
+
// oCanvas.style.display = "none";
|
|
60
60
|
// oCanvas.style.width = iWidth;
|
|
61
61
|
// oCanvas.style.height = iHeight;
|
|
62
62
|
|
|
63
63
|
oImg = renderer.domElement;
|
|
64
|
-
|
|
65
64
|
if ( oImg.style.backgroundColor ) {
|
|
66
65
|
|
|
67
66
|
oAscii.rows[ 0 ].cells[ 0 ].style.backgroundColor = oImg.style.backgroundColor;
|
|
@@ -92,7 +91,6 @@
|
|
|
92
91
|
const strFont = 'courier new, monospace';
|
|
93
92
|
const oCanvasImg = renderer.domElement;
|
|
94
93
|
const oCanvas = document.createElement( 'canvas' );
|
|
95
|
-
|
|
96
94
|
if ( ! oCanvas.getContext ) {
|
|
97
95
|
|
|
98
96
|
return;
|
|
@@ -100,7 +98,6 @@
|
|
|
100
98
|
}
|
|
101
99
|
|
|
102
100
|
const oCtx = oCanvas.getContext( '2d' );
|
|
103
|
-
|
|
104
101
|
if ( ! oCtx.getImageData ) {
|
|
105
102
|
|
|
106
103
|
return;
|
|
@@ -108,13 +105,16 @@
|
|
|
108
105
|
}
|
|
109
106
|
|
|
110
107
|
let aCharList = bColor ? aDefaultColorCharList : aDefaultCharList;
|
|
111
|
-
if ( charSet ) aCharList = charSet;
|
|
108
|
+
if ( charSet ) aCharList = charSet;
|
|
109
|
+
|
|
110
|
+
// Setup dom
|
|
112
111
|
|
|
113
112
|
const fFontSize = 2 / fResolution * iScale;
|
|
114
|
-
const fLineHeight = 2 / fResolution * iScale;
|
|
113
|
+
const fLineHeight = 2 / fResolution * iScale;
|
|
115
114
|
|
|
116
|
-
|
|
115
|
+
// adjust letter-spacing for all combinations of scale and resolution to get it to fit the image width.
|
|
117
116
|
|
|
117
|
+
let fLetterSpacing = 0;
|
|
118
118
|
if ( strResolution == 'low' ) {
|
|
119
119
|
|
|
120
120
|
switch ( iScale ) {
|
|
@@ -122,16 +122,13 @@
|
|
|
122
122
|
case 1:
|
|
123
123
|
fLetterSpacing = - 1;
|
|
124
124
|
break;
|
|
125
|
-
|
|
126
125
|
case 2:
|
|
127
126
|
case 3:
|
|
128
127
|
fLetterSpacing = - 2.1;
|
|
129
128
|
break;
|
|
130
|
-
|
|
131
129
|
case 4:
|
|
132
130
|
fLetterSpacing = - 3.1;
|
|
133
131
|
break;
|
|
134
|
-
|
|
135
132
|
case 5:
|
|
136
133
|
fLetterSpacing = - 4.15;
|
|
137
134
|
break;
|
|
@@ -147,15 +144,12 @@
|
|
|
147
144
|
case 1:
|
|
148
145
|
fLetterSpacing = 0;
|
|
149
146
|
break;
|
|
150
|
-
|
|
151
147
|
case 2:
|
|
152
148
|
fLetterSpacing = - 1;
|
|
153
149
|
break;
|
|
154
|
-
|
|
155
150
|
case 3:
|
|
156
151
|
fLetterSpacing = - 1.04;
|
|
157
152
|
break;
|
|
158
|
-
|
|
159
153
|
case 4:
|
|
160
154
|
case 5:
|
|
161
155
|
fLetterSpacing = - 2.1;
|
|
@@ -173,7 +167,6 @@
|
|
|
173
167
|
case 2:
|
|
174
168
|
fLetterSpacing = 0;
|
|
175
169
|
break;
|
|
176
|
-
|
|
177
170
|
case 3:
|
|
178
171
|
case 4:
|
|
179
172
|
case 5:
|
|
@@ -182,17 +175,22 @@
|
|
|
182
175
|
|
|
183
176
|
}
|
|
184
177
|
|
|
185
|
-
}
|
|
186
|
-
// convert img element to ascii
|
|
178
|
+
}
|
|
187
179
|
|
|
180
|
+
// can't get a span or div to flow like an img element, but a table works?
|
|
181
|
+
|
|
182
|
+
// convert img element to ascii
|
|
188
183
|
|
|
189
184
|
function asciifyImage( oAscii ) {
|
|
190
185
|
|
|
191
186
|
oCtx.clearRect( 0, 0, iWidth, iHeight );
|
|
192
187
|
oCtx.drawImage( oCanvasImg, 0, 0, iWidth, iHeight );
|
|
193
|
-
const oImgData = oCtx.getImageData( 0, 0, iWidth, iHeight ).data;
|
|
188
|
+
const oImgData = oCtx.getImageData( 0, 0, iWidth, iHeight ).data;
|
|
194
189
|
|
|
195
|
-
|
|
190
|
+
// Coloring loop starts now
|
|
191
|
+
let strChars = '';
|
|
192
|
+
|
|
193
|
+
// console.time('rendering');
|
|
196
194
|
|
|
197
195
|
for ( let y = 0; y < iHeight; y += 2 ) {
|
|
198
196
|
|
|
@@ -205,7 +203,8 @@
|
|
|
205
203
|
const iAlpha = oImgData[ iOffset + 3 ];
|
|
206
204
|
let iCharIdx;
|
|
207
205
|
let fBrightness;
|
|
208
|
-
fBrightness = ( 0.3 * iRed + 0.59 * iGreen + 0.11 * iBlue ) / 255;
|
|
206
|
+
fBrightness = ( 0.3 * iRed + 0.59 * iGreen + 0.11 * iBlue ) / 255;
|
|
207
|
+
// fBrightness = (0.3*iRed + 0.5*iGreen + 0.3*iBlue) / 255;
|
|
209
208
|
|
|
210
209
|
if ( iAlpha == 0 ) {
|
|
211
210
|
|
|
@@ -216,19 +215,18 @@
|
|
|
216
215
|
}
|
|
217
216
|
|
|
218
217
|
iCharIdx = Math.floor( ( 1 - fBrightness ) * ( aCharList.length - 1 ) );
|
|
219
|
-
|
|
220
218
|
if ( bInvert ) {
|
|
221
219
|
|
|
222
220
|
iCharIdx = aCharList.length - iCharIdx - 1;
|
|
223
221
|
|
|
224
|
-
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// good for debugging
|
|
225
225
|
//fBrightness = Math.floor(fBrightness * 10);
|
|
226
226
|
//strThisChar = fBrightness;
|
|
227
227
|
|
|
228
|
-
|
|
229
228
|
let strThisChar = aCharList[ iCharIdx ];
|
|
230
229
|
if ( strThisChar === undefined || strThisChar == ' ' ) strThisChar = ' ';
|
|
231
|
-
|
|
232
230
|
if ( bColor ) {
|
|
233
231
|
|
|
234
232
|
strChars += '<span style=\'' + 'color:rgb(' + iRed + ',' + iGreen + ',' + iBlue + ');' + ( bBlock ? 'background-color:rgb(' + iRed + ',' + iGreen + ',' + iBlue + ');' : '' ) + ( bAlpha ? 'opacity:' + iAlpha / 255 + ';' : '' ) + '\'>' + strThisChar + '</span>';
|
|
@@ -245,7 +243,10 @@
|
|
|
245
243
|
|
|
246
244
|
}
|
|
247
245
|
|
|
248
|
-
oAscii.innerHTML = '<tr><td>' + strChars + '</td></tr>';
|
|
246
|
+
oAscii.innerHTML = '<tr><td>' + strChars + '</td></tr>';
|
|
247
|
+
|
|
248
|
+
// console.timeEnd('rendering');
|
|
249
|
+
|
|
249
250
|
// return oAscii;
|
|
250
251
|
|
|
251
252
|
}
|