@needle-tools/three 0.145.2 → 0.146.1
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 +3559 -6924
- package/build/three.js +3559 -6924
- package/build/three.min.js +1 -2
- package/build/three.module.js +732 -339
- 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 +94 -28
- 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/WebGLCubeUVMaps.js +1 -1
- 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
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
this.type = THREE.HalfFloatType;
|
|
9
9
|
|
|
10
10
|
}
|
|
11
|
-
|
|
12
11
|
parse( buffer ) {
|
|
13
12
|
|
|
14
13
|
const ifds = UTIF.decode( buffer );
|
|
@@ -24,7 +23,6 @@
|
|
|
24
23
|
};
|
|
25
24
|
|
|
26
25
|
}
|
|
27
|
-
|
|
28
26
|
setDataType( value ) {
|
|
29
27
|
|
|
30
28
|
this.type = value;
|
|
@@ -32,30 +30,26 @@
|
|
|
32
30
|
|
|
33
31
|
}
|
|
34
32
|
|
|
35
|
-
}
|
|
33
|
+
}
|
|
36
34
|
|
|
35
|
+
// from https://github.com/photopea/UTIF.js (MIT License)
|
|
37
36
|
|
|
38
37
|
const UTIF = {};
|
|
39
|
-
|
|
40
38
|
UTIF.decode = function ( buff, prm ) {
|
|
41
39
|
|
|
42
40
|
if ( prm == null ) prm = {
|
|
43
41
|
parseMN: true,
|
|
44
42
|
debug: false
|
|
45
43
|
}; // read MakerNote, debug
|
|
46
|
-
|
|
47
44
|
var data = new Uint8Array( buff ),
|
|
48
45
|
offset = 0;
|
|
49
|
-
|
|
50
46
|
var id = UTIF._binBE.readASCII( data, offset, 2 );
|
|
51
|
-
|
|
52
47
|
offset += 2;
|
|
53
48
|
var bin = id == 'II' ? UTIF._binLE : UTIF._binBE;
|
|
54
49
|
bin.readUshort( data, offset );
|
|
55
50
|
offset += 2;
|
|
56
51
|
var ifdo = bin.readUint( data, offset );
|
|
57
52
|
var ifds = [];
|
|
58
|
-
|
|
59
53
|
while ( true ) {
|
|
60
54
|
|
|
61
55
|
var cnt = bin.readUshort( data, ifdo ),
|
|
@@ -68,7 +62,6 @@
|
|
|
68
62
|
}
|
|
69
63
|
|
|
70
64
|
UTIF._readIFD( bin, data, ifdo, ifds, 0, prm );
|
|
71
|
-
|
|
72
65
|
ifdo = bin.readUint( data, ifdo + 2 + cnt * 12 );
|
|
73
66
|
if ( ifdo == 0 ) break;
|
|
74
67
|
|
|
@@ -82,26 +75,19 @@
|
|
|
82
75
|
|
|
83
76
|
if ( img.data ) return;
|
|
84
77
|
var data = new Uint8Array( buff );
|
|
85
|
-
|
|
86
78
|
var id = UTIF._binBE.readASCII( data, 0, 2 );
|
|
87
|
-
|
|
88
79
|
if ( img[ 't256' ] == null ) return; // No width => probably not an image
|
|
89
|
-
|
|
90
80
|
img.isLE = id == 'II';
|
|
91
81
|
img.width = img[ 't256' ][ 0 ]; //delete img["t256"];
|
|
92
|
-
|
|
93
82
|
img.height = img[ 't257' ][ 0 ]; //delete img["t257"];
|
|
94
83
|
|
|
95
84
|
var cmpr = img[ 't259' ] ? img[ 't259' ][ 0 ] : 1; //delete img["t259"];
|
|
96
|
-
|
|
97
85
|
var fo = img[ 't266' ] ? img[ 't266' ][ 0 ] : 1; //delete img["t266"];
|
|
98
|
-
|
|
99
86
|
if ( img[ 't284' ] && img[ 't284' ][ 0 ] == 2 ) console.log( 'PlanarConfiguration 2 should not be used!' );
|
|
100
87
|
if ( cmpr == 7 && img[ 't258' ] && img[ 't258' ].length > 3 ) img[ 't258' ] = img[ 't258' ].slice( 0, 3 );
|
|
101
88
|
var bipp; // bits per pixel
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
89
|
+
if ( img[ 't258' ] ) bipp = Math.min( 32, img[ 't258' ][ 0 ] ) * img[ 't258' ].length; else bipp = img[ 't277' ] ? img[ 't277' ][ 0 ] : 1;
|
|
90
|
+
// Some .NEF files have t258==14, even though they use 16 bits per pixel
|
|
105
91
|
if ( cmpr == 1 && img[ 't279' ] != null && img[ 't278' ] && img[ 't262' ][ 0 ] == 32803 ) {
|
|
106
92
|
|
|
107
93
|
bipp = Math.round( img[ 't279' ][ 0 ] * 8 / ( img.width * img[ 't278' ][ 0 ] ) );
|
|
@@ -113,11 +99,10 @@
|
|
|
113
99
|
if ( soff == null ) soff = img[ 't324' ];
|
|
114
100
|
var bcnt = img[ 't279' ];
|
|
115
101
|
if ( cmpr == 1 && soff.length == 1 ) bcnt = [ img.height * ( bipl >>> 3 ) ];
|
|
116
|
-
if ( bcnt == null ) bcnt = img[ 't325' ];
|
|
117
|
-
|
|
102
|
+
if ( bcnt == null ) bcnt = img[ 't325' ];
|
|
103
|
+
//bcnt[0] = Math.min(bcnt[0], data.length); // Hasselblad, "RAW_HASSELBLAD_H3D39II.3FR"
|
|
118
104
|
var bytes = new Uint8Array( img.height * ( bipl >>> 3 ) ),
|
|
119
105
|
bilen = 0;
|
|
120
|
-
|
|
121
106
|
if ( img[ 't322' ] != null ) {
|
|
122
107
|
|
|
123
108
|
var tw = img[ 't322' ][ 0 ],
|
|
@@ -125,16 +110,12 @@
|
|
|
125
110
|
var tx = Math.floor( ( img.width + tw - 1 ) / tw );
|
|
126
111
|
var ty = Math.floor( ( img.height + th - 1 ) / th );
|
|
127
112
|
var tbuff = new Uint8Array( Math.ceil( tw * th * bipp / 8 ) | 0 );
|
|
128
|
-
|
|
129
113
|
for ( var y = 0; y < ty; y ++ ) for ( var x = 0; x < tx; x ++ ) {
|
|
130
114
|
|
|
131
115
|
var i = y * tx + x;
|
|
132
|
-
|
|
133
116
|
for ( var j = 0; j < tbuff.length; j ++ ) tbuff[ j ] = 0;
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
117
|
+
UTIF.decode._decompress( img, ifds, data, soff[ i ], bcnt[ i ], cmpr, tbuff, 0, fo );
|
|
118
|
+
// Might be required for 7 too. Need to check
|
|
138
119
|
if ( cmpr == 6 ) bytes = tbuff; else UTIF._copyTile( tbuff, Math.ceil( tw * bipp / 8 ) | 0, th, bytes, Math.ceil( img.width * bipp / 8 ) | 0, img.height, Math.ceil( x * tw * bipp / 8 ) | 0, y * th );
|
|
139
120
|
|
|
140
121
|
}
|
|
@@ -145,11 +126,9 @@
|
|
|
145
126
|
|
|
146
127
|
var rps = img[ 't278' ] ? img[ 't278' ][ 0 ] : img.height;
|
|
147
128
|
rps = Math.min( rps, img.height );
|
|
148
|
-
|
|
149
129
|
for ( var i = 0; i < soff.length; i ++ ) {
|
|
150
130
|
|
|
151
131
|
UTIF.decode._decompress( img, ifds, data, soff[ i ], bcnt[ i ], cmpr, bytes, Math.ceil( bilen / 8 ) | 0, fo );
|
|
152
|
-
|
|
153
132
|
bilen += bipl * rps;
|
|
154
133
|
|
|
155
134
|
}
|
|
@@ -166,20 +145,23 @@
|
|
|
166
145
|
|
|
167
146
|
//console.log("compression", cmpr);
|
|
168
147
|
//var time = Date.now();
|
|
169
|
-
if ( cmpr == 34676 ) UTIF.decode._decodeLogLuv32( img, data, off, len, tgt, toff ); else console.log( 'Unsupported compression', cmpr );
|
|
148
|
+
if ( cmpr == 34676 ) UTIF.decode._decodeLogLuv32( img, data, off, len, tgt, toff ); else console.log( 'Unsupported compression', cmpr );
|
|
149
|
+
|
|
150
|
+
//console.log(Date.now()-time);
|
|
170
151
|
|
|
171
152
|
var bps = img[ 't258' ] ? Math.min( 32, img[ 't258' ][ 0 ] ) : 1;
|
|
172
153
|
var noc = img[ 't277' ] ? img[ 't277' ][ 0 ] : 1,
|
|
173
154
|
bpp = bps * noc >>> 3,
|
|
174
155
|
h = img[ 't278' ] ? img[ 't278' ][ 0 ] : img.height,
|
|
175
|
-
bpl = Math.ceil( bps * noc * img.width / 8 );
|
|
156
|
+
bpl = Math.ceil( bps * noc * img.width / 8 );
|
|
176
157
|
|
|
177
|
-
|
|
158
|
+
// convert to Little Endian /*
|
|
159
|
+
if ( bps == 16 && ! img.isLE && img[ 't33422' ] == null )
|
|
160
|
+
// not DNG
|
|
178
161
|
for ( var y = 0; y < h; y ++ ) {
|
|
179
162
|
|
|
180
163
|
//console.log("fixing endianity");
|
|
181
164
|
var roff = toff + y * bpl;
|
|
182
|
-
|
|
183
165
|
for ( var x = 1; x < bpl; x += 2 ) {
|
|
184
166
|
|
|
185
167
|
var t = tgt[ roff + x ];
|
|
@@ -221,29 +203,23 @@
|
|
|
221
203
|
qw = w * 4;
|
|
222
204
|
var io = 0,
|
|
223
205
|
out = new Uint8Array( qw );
|
|
224
|
-
|
|
225
206
|
while ( io < len ) {
|
|
226
207
|
|
|
227
208
|
var oo = 0;
|
|
228
|
-
|
|
229
209
|
while ( oo < qw ) {
|
|
230
210
|
|
|
231
211
|
var c = data[ off + io ];
|
|
232
212
|
io ++;
|
|
233
|
-
|
|
234
213
|
if ( c < 128 ) {
|
|
235
214
|
|
|
236
215
|
for ( var j = 0; j < c; j ++ ) out[ oo + j ] = data[ off + io + j ];
|
|
237
|
-
|
|
238
216
|
oo += c;
|
|
239
217
|
io += c;
|
|
240
218
|
|
|
241
219
|
} else {
|
|
242
220
|
|
|
243
221
|
c = c - 126;
|
|
244
|
-
|
|
245
222
|
for ( var j = 0; j < c; j ++ ) out[ oo + j ] = data[ off + io ];
|
|
246
|
-
|
|
247
223
|
oo += c;
|
|
248
224
|
io ++;
|
|
249
225
|
|
|
@@ -265,9 +241,9 @@
|
|
|
265
241
|
|
|
266
242
|
};
|
|
267
243
|
|
|
268
|
-
UTIF.tags = {};
|
|
244
|
+
UTIF.tags = {};
|
|
245
|
+
//UTIF.ttypes = { 256:3,257:3,258:3, 259:3, 262:3, 273:4, 274:3, 277:3,278:4,279:4, 282:5, 283:5, 284:3, 286:5,287:5, 296:3, 305:2, 306:2, 338:3, 513:4, 514:4, 34665:4 };
|
|
269
246
|
// start at tag 250
|
|
270
|
-
|
|
271
247
|
UTIF._types = function () {
|
|
272
248
|
|
|
273
249
|
var main = new Array( 250 );
|
|
@@ -339,14 +315,12 @@
|
|
|
339
315
|
};
|
|
340
316
|
|
|
341
317
|
}();
|
|
342
|
-
|
|
343
318
|
UTIF._readIFD = function ( bin, data, offset, ifds, depth, prm ) {
|
|
344
319
|
|
|
345
320
|
var cnt = bin.readUshort( data, offset );
|
|
346
321
|
offset += 2;
|
|
347
322
|
var ifd = {};
|
|
348
323
|
if ( prm.debug ) console.log( ' '.repeat( depth ), ifds.length - 1, '>>>----------------' );
|
|
349
|
-
|
|
350
324
|
for ( var i = 0; i < cnt; i ++ ) {
|
|
351
325
|
|
|
352
326
|
var tag = bin.readUshort( data, offset );
|
|
@@ -357,8 +331,8 @@
|
|
|
357
331
|
offset += 4;
|
|
358
332
|
var voff = bin.readUint( data, offset );
|
|
359
333
|
offset += 4;
|
|
360
|
-
var arr = [];
|
|
361
|
-
|
|
334
|
+
var arr = [];
|
|
335
|
+
//ifd["t"+tag+"-"+UTIF.tags[tag]] = arr;
|
|
362
336
|
if ( type == 1 || type == 7 ) {
|
|
363
337
|
|
|
364
338
|
arr = new Uint8Array( data.buffer, num < 5 ? offset - 4 : voff, num );
|
|
@@ -389,7 +363,6 @@
|
|
|
389
363
|
if ( type == 5 || type == 10 ) {
|
|
390
364
|
|
|
391
365
|
var ri = type == 5 ? bin.readUint : bin.readInt;
|
|
392
|
-
|
|
393
366
|
for ( var j = 0; j < num; j ++ ) arr.push( [ ri( data, voff + j * 8 ), ri( data, voff + j * 8 + 4 ) ] );
|
|
394
367
|
|
|
395
368
|
}
|
|
@@ -428,18 +401,14 @@
|
|
|
428
401
|
|
|
429
402
|
if ( prm.debug ) console.log( ' '.repeat( depth ), tag, type, UTIF.tags[ tag ], arr );
|
|
430
403
|
ifd[ 't' + tag ] = arr;
|
|
431
|
-
|
|
432
404
|
if ( tag == 330 || tag == 34665 || tag == 34853 || tag == 50740 && bin.readUshort( data, bin.readUint( arr, 0 ) ) < 300 || tag == 61440 ) {
|
|
433
405
|
|
|
434
406
|
var oarr = tag == 50740 ? [ bin.readUint( arr, 0 ) ] : arr;
|
|
435
407
|
var subfd = [];
|
|
436
|
-
|
|
437
408
|
for ( var j = 0; j < oarr.length; j ++ ) UTIF._readIFD( bin, data, oarr[ j ], subfd, depth + 1, prm );
|
|
438
|
-
|
|
439
409
|
if ( tag == 330 ) ifd.subIFD = subfd;
|
|
440
410
|
if ( tag == 34665 ) ifd.exifIFD = subfd[ 0 ];
|
|
441
411
|
if ( tag == 34853 ) ifd.gpsiIFD = subfd[ 0 ]; //console.log("gps", subfd[0]); }
|
|
442
|
-
|
|
443
412
|
if ( tag == 50740 ) ifd.dngPrvt = subfd[ 0 ];
|
|
444
413
|
if ( tag == 61440 ) ifd.fujiIFD = subfd[ 0 ];
|
|
445
414
|
|
|
@@ -447,14 +416,12 @@
|
|
|
447
416
|
|
|
448
417
|
if ( tag == 37500 && prm.parseMN ) {
|
|
449
418
|
|
|
450
|
-
var mn = arr;
|
|
451
|
-
|
|
419
|
+
var mn = arr;
|
|
420
|
+
//console.log(bin.readASCII(mn,0,mn.length), mn);
|
|
452
421
|
if ( bin.readASCII( mn, 0, 5 ) == 'Nikon' ) ifd.makerNote = UTIF[ 'decode' ]( mn.slice( 10 ).buffer )[ 0 ]; else if ( bin.readUshort( data, voff ) < 300 && bin.readUshort( data, voff + 4 ) <= 12 ) {
|
|
453
422
|
|
|
454
423
|
var subsub = [];
|
|
455
|
-
|
|
456
424
|
UTIF._readIFD( bin, data, voff, subsub, depth + 1, prm );
|
|
457
|
-
|
|
458
425
|
ifd.makerNote = subsub[ 0 ];
|
|
459
426
|
|
|
460
427
|
}
|
|
@@ -476,17 +443,14 @@
|
|
|
476
443
|
area = w * h,
|
|
477
444
|
data = out.data;
|
|
478
445
|
let img;
|
|
479
|
-
|
|
480
446
|
switch ( type ) {
|
|
481
447
|
|
|
482
448
|
case THREE.HalfFloatType:
|
|
483
449
|
img = new Uint16Array( area * 4 );
|
|
484
450
|
break;
|
|
485
|
-
|
|
486
451
|
case THREE.FloatType:
|
|
487
452
|
img = new Float32Array( area * 4 );
|
|
488
453
|
break;
|
|
489
|
-
|
|
490
454
|
default:
|
|
491
455
|
console.error( 'THREE.LogLuvLoader: Unsupported texture data type:', type );
|
|
492
456
|
|
|
@@ -495,7 +459,6 @@
|
|
|
495
459
|
let intp = out[ 't262' ] ? out[ 't262' ][ 0 ] : 2;
|
|
496
460
|
const bps = out[ 't258' ] ? Math.min( 32, out[ 't258' ][ 0 ] ) : 1;
|
|
497
461
|
if ( out[ 't262' ] == null && bps == 1 ) intp = 0;
|
|
498
|
-
|
|
499
462
|
if ( intp == 32845 ) {
|
|
500
463
|
|
|
501
464
|
for ( let y = 0; y < h; y ++ ) {
|
|
@@ -507,20 +470,22 @@
|
|
|
507
470
|
let L = data[ si + 1 ] << 8 | data[ si ];
|
|
508
471
|
L = Math.pow( 2, ( L + 0.5 ) / 256 - 64 );
|
|
509
472
|
const u = ( data[ si + 3 ] + 0.5 ) / 410;
|
|
510
|
-
const v = ( data[ si + 5 ] + 0.5 ) / 410;
|
|
473
|
+
const v = ( data[ si + 5 ] + 0.5 ) / 410;
|
|
511
474
|
|
|
475
|
+
// Luv to xyY
|
|
512
476
|
const sX = 9 * u / ( 6 * u - 16 * v + 12 );
|
|
513
477
|
const sY = 4 * v / ( 6 * u - 16 * v + 12 );
|
|
514
|
-
const bY = L;
|
|
478
|
+
const bY = L;
|
|
515
479
|
|
|
480
|
+
// xyY to XYZ
|
|
516
481
|
const X = sX * bY / sY,
|
|
517
482
|
Y = bY,
|
|
518
|
-
Z = ( 1 - sX - sY ) * bY / sY;
|
|
483
|
+
Z = ( 1 - sX - sY ) * bY / sY;
|
|
519
484
|
|
|
485
|
+
// XYZ to linear RGB
|
|
520
486
|
const r = 2.690 * X - 1.276 * Y - 0.414 * Z;
|
|
521
487
|
const g = - 1.022 * X + 1.978 * Y + 0.044 * Z;
|
|
522
488
|
const b = 0.061 * X - 0.224 * Y + 1.163 * Z;
|
|
523
|
-
|
|
524
489
|
if ( type === THREE.HalfFloatType ) {
|
|
525
490
|
|
|
526
491
|
img[ qi ] = THREE.DataUtils.toHalfFloat( Math.min( r, 65504 ) );
|
|
@@ -555,7 +520,6 @@
|
|
|
555
520
|
nextZero: function ( data, o ) {
|
|
556
521
|
|
|
557
522
|
while ( data[ o ] != 0 ) o ++;
|
|
558
|
-
|
|
559
523
|
return o;
|
|
560
524
|
|
|
561
525
|
},
|
|
@@ -595,27 +559,21 @@
|
|
|
595
559
|
readASCII: function ( buff, p, l ) {
|
|
596
560
|
|
|
597
561
|
var s = '';
|
|
598
|
-
|
|
599
562
|
for ( var i = 0; i < l; i ++ ) s += String.fromCharCode( buff[ p + i ] );
|
|
600
|
-
|
|
601
563
|
return s;
|
|
602
564
|
|
|
603
565
|
},
|
|
604
566
|
readFloat: function ( buff, p ) {
|
|
605
567
|
|
|
606
568
|
var a = UTIF._binBE.ui8;
|
|
607
|
-
|
|
608
569
|
for ( var i = 0; i < 4; i ++ ) a[ i ] = buff[ p + 3 - i ];
|
|
609
|
-
|
|
610
570
|
return UTIF._binBE.fl32[ 0 ];
|
|
611
571
|
|
|
612
572
|
},
|
|
613
573
|
readDouble: function ( buff, p ) {
|
|
614
574
|
|
|
615
575
|
var a = UTIF._binBE.ui8;
|
|
616
|
-
|
|
617
576
|
for ( var i = 0; i < 8; i ++ ) a[ i ] = buff[ p + 7 - i ];
|
|
618
|
-
|
|
619
577
|
return UTIF._binBE.fl64[ 0 ];
|
|
620
578
|
|
|
621
579
|
},
|
|
@@ -651,7 +609,6 @@
|
|
|
651
609
|
writeDouble: function ( buff, p, n ) {
|
|
652
610
|
|
|
653
611
|
UTIF._binBE.fl64[ 0 ] = n;
|
|
654
|
-
|
|
655
612
|
for ( var i = 0; i < 8; i ++ ) buff[ p + i ] = UTIF._binBE.ui8[ 7 - i ];
|
|
656
613
|
|
|
657
614
|
}
|
|
@@ -701,18 +658,14 @@
|
|
|
701
658
|
readFloat: function ( buff, p ) {
|
|
702
659
|
|
|
703
660
|
var a = UTIF._binBE.ui8;
|
|
704
|
-
|
|
705
661
|
for ( var i = 0; i < 4; i ++ ) a[ i ] = buff[ p + i ];
|
|
706
|
-
|
|
707
662
|
return UTIF._binBE.fl32[ 0 ];
|
|
708
663
|
|
|
709
664
|
},
|
|
710
665
|
readDouble: function ( buff, p ) {
|
|
711
666
|
|
|
712
667
|
var a = UTIF._binBE.ui8;
|
|
713
|
-
|
|
714
668
|
for ( var i = 0; i < 8; i ++ ) a[ i ] = buff[ p + i ];
|
|
715
|
-
|
|
716
669
|
return UTIF._binBE.fl64[ 0 ];
|
|
717
670
|
|
|
718
671
|
},
|
|
@@ -742,18 +695,15 @@
|
|
|
742
695
|
},
|
|
743
696
|
writeASCII: UTIF._binBE.writeASCII
|
|
744
697
|
};
|
|
745
|
-
|
|
746
698
|
UTIF._copyTile = function ( tb, tw, th, b, w, h, xoff, yoff ) {
|
|
747
699
|
|
|
748
700
|
//log("copyTile", tw, th, w, h, xoff, yoff);
|
|
749
701
|
var xlim = Math.min( tw, w - xoff );
|
|
750
702
|
var ylim = Math.min( th, h - yoff );
|
|
751
|
-
|
|
752
703
|
for ( var y = 0; y < ylim; y ++ ) {
|
|
753
704
|
|
|
754
705
|
var tof = ( yoff + y ) * w + xoff;
|
|
755
706
|
var sof = y * tw;
|
|
756
|
-
|
|
757
707
|
for ( var x = 0; x < xlim; x ++ ) b[ tof + x ] = tb[ sof + x ];
|
|
758
708
|
|
|
759
709
|
}
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
this._quality = value;
|
|
8
8
|
|
|
9
9
|
}
|
|
10
|
-
|
|
11
10
|
load( url, onLoad, onProgress, onError ) {
|
|
12
11
|
|
|
13
12
|
const quality = this._quality || 1;
|
|
@@ -18,14 +17,16 @@
|
|
|
18
17
|
loader.setWithCredentials( this.withCredentials );
|
|
19
18
|
loader.load( url, function ( text ) {
|
|
20
19
|
|
|
21
|
-
const data = JSON.parse( text );
|
|
20
|
+
const data = JSON.parse( text );
|
|
21
|
+
|
|
22
|
+
// lottie uses container.offetWidth and offsetHeight
|
|
22
23
|
// to define width/height
|
|
23
24
|
|
|
24
25
|
const container = document.createElement( 'div' );
|
|
25
26
|
container.style.width = data.w + 'px';
|
|
26
27
|
container.style.height = data.h + 'px';
|
|
27
28
|
document.body.appendChild( container );
|
|
28
|
-
const animation =
|
|
29
|
+
const animation = lottie.loadAnimation( {
|
|
29
30
|
container: container,
|
|
30
31
|
animType: 'canvas',
|
|
31
32
|
loop: true,
|
|
@@ -43,7 +44,6 @@
|
|
|
43
44
|
|
|
44
45
|
} );
|
|
45
46
|
container.style.display = 'none';
|
|
46
|
-
|
|
47
47
|
if ( onLoad !== undefined ) {
|
|
48
48
|
|
|
49
49
|
onLoad( texture );
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
( function () {
|
|
2
2
|
|
|
3
3
|
const _normalData = [[ - 0.525731, 0.000000, 0.850651 ], [ - 0.442863, 0.238856, 0.864188 ], [ - 0.295242, 0.000000, 0.955423 ], [ - 0.309017, 0.500000, 0.809017 ], [ - 0.162460, 0.262866, 0.951056 ], [ 0.000000, 0.000000, 1.000000 ], [ 0.000000, 0.850651, 0.525731 ], [ - 0.147621, 0.716567, 0.681718 ], [ 0.147621, 0.716567, 0.681718 ], [ 0.000000, 0.525731, 0.850651 ], [ 0.309017, 0.500000, 0.809017 ], [ 0.525731, 0.000000, 0.850651 ], [ 0.295242, 0.000000, 0.955423 ], [ 0.442863, 0.238856, 0.864188 ], [ 0.162460, 0.262866, 0.951056 ], [ - 0.681718, 0.147621, 0.716567 ], [ - 0.809017, 0.309017, 0.500000 ], [ - 0.587785, 0.425325, 0.688191 ], [ - 0.850651, 0.525731, 0.000000 ], [ - 0.864188, 0.442863, 0.238856 ], [ - 0.716567, 0.681718, 0.147621 ], [ - 0.688191, 0.587785, 0.425325 ], [ - 0.500000, 0.809017, 0.309017 ], [ - 0.238856, 0.864188, 0.442863 ], [ - 0.425325, 0.688191, 0.587785 ], [ - 0.716567, 0.681718, - 0.147621 ], [ - 0.500000, 0.809017, - 0.309017 ], [ - 0.525731, 0.850651, 0.000000 ], [ 0.000000, 0.850651, - 0.525731 ], [ - 0.238856, 0.864188, - 0.442863 ], [ 0.000000, 0.955423, - 0.295242 ], [ - 0.262866, 0.951056, - 0.162460 ], [ 0.000000, 1.000000, 0.000000 ], [ 0.000000, 0.955423, 0.295242 ], [ - 0.262866, 0.951056, 0.162460 ], [ 0.238856, 0.864188, 0.442863 ], [ 0.262866, 0.951056, 0.162460 ], [ 0.500000, 0.809017, 0.309017 ], [ 0.238856, 0.864188, - 0.442863 ], [ 0.262866, 0.951056, - 0.162460 ], [ 0.500000, 0.809017, - 0.309017 ], [ 0.850651, 0.525731, 0.000000 ], [ 0.716567, 0.681718, 0.147621 ], [ 0.716567, 0.681718, - 0.147621 ], [ 0.525731, 0.850651, 0.000000 ], [ 0.425325, 0.688191, 0.587785 ], [ 0.864188, 0.442863, 0.238856 ], [ 0.688191, 0.587785, 0.425325 ], [ 0.809017, 0.309017, 0.500000 ], [ 0.681718, 0.147621, 0.716567 ], [ 0.587785, 0.425325, 0.688191 ], [ 0.955423, 0.295242, 0.000000 ], [ 1.000000, 0.000000, 0.000000 ], [ 0.951056, 0.162460, 0.262866 ], [ 0.850651, - 0.525731, 0.000000 ], [ 0.955423, - 0.295242, 0.000000 ], [ 0.864188, - 0.442863, 0.238856 ], [ 0.951056, - 0.162460, 0.262866 ], [ 0.809017, - 0.309017, 0.500000 ], [ 0.681718, - 0.147621, 0.716567 ], [ 0.850651, 0.000000, 0.525731 ], [ 0.864188, 0.442863, - 0.238856 ], [ 0.809017, 0.309017, - 0.500000 ], [ 0.951056, 0.162460, - 0.262866 ], [ 0.525731, 0.000000, - 0.850651 ], [ 0.681718, 0.147621, - 0.716567 ], [ 0.681718, - 0.147621, - 0.716567 ], [ 0.850651, 0.000000, - 0.525731 ], [ 0.809017, - 0.309017, - 0.500000 ], [ 0.864188, - 0.442863, - 0.238856 ], [ 0.951056, - 0.162460, - 0.262866 ], [ 0.147621, 0.716567, - 0.681718 ], [ 0.309017, 0.500000, - 0.809017 ], [ 0.425325, 0.688191, - 0.587785 ], [ 0.442863, 0.238856, - 0.864188 ], [ 0.587785, 0.425325, - 0.688191 ], [ 0.688191, 0.587785, - 0.425325 ], [ - 0.147621, 0.716567, - 0.681718 ], [ - 0.309017, 0.500000, - 0.809017 ], [ 0.000000, 0.525731, - 0.850651 ], [ - 0.525731, 0.000000, - 0.850651 ], [ - 0.442863, 0.238856, - 0.864188 ], [ - 0.295242, 0.000000, - 0.955423 ], [ - 0.162460, 0.262866, - 0.951056 ], [ 0.000000, 0.000000, - 1.000000 ], [ 0.295242, 0.000000, - 0.955423 ], [ 0.162460, 0.262866, - 0.951056 ], [ - 0.442863, - 0.238856, - 0.864188 ], [ - 0.309017, - 0.500000, - 0.809017 ], [ - 0.162460, - 0.262866, - 0.951056 ], [ 0.000000, - 0.850651, - 0.525731 ], [ - 0.147621, - 0.716567, - 0.681718 ], [ 0.147621, - 0.716567, - 0.681718 ], [ 0.000000, - 0.525731, - 0.850651 ], [ 0.309017, - 0.500000, - 0.809017 ], [ 0.442863, - 0.238856, - 0.864188 ], [ 0.162460, - 0.262866, - 0.951056 ], [ 0.238856, - 0.864188, - 0.442863 ], [ 0.500000, - 0.809017, - 0.309017 ], [ 0.425325, - 0.688191, - 0.587785 ], [ 0.716567, - 0.681718, - 0.147621 ], [ 0.688191, - 0.587785, - 0.425325 ], [ 0.587785, - 0.425325, - 0.688191 ], [ 0.000000, - 0.955423, - 0.295242 ], [ 0.000000, - 1.000000, 0.000000 ], [ 0.262866, - 0.951056, - 0.162460 ], [ 0.000000, - 0.850651, 0.525731 ], [ 0.000000, - 0.955423, 0.295242 ], [ 0.238856, - 0.864188, 0.442863 ], [ 0.262866, - 0.951056, 0.162460 ], [ 0.500000, - 0.809017, 0.309017 ], [ 0.716567, - 0.681718, 0.147621 ], [ 0.525731, - 0.850651, 0.000000 ], [ - 0.238856, - 0.864188, - 0.442863 ], [ - 0.500000, - 0.809017, - 0.309017 ], [ - 0.262866, - 0.951056, - 0.162460 ], [ - 0.850651, - 0.525731, 0.000000 ], [ - 0.716567, - 0.681718, - 0.147621 ], [ - 0.716567, - 0.681718, 0.147621 ], [ - 0.525731, - 0.850651, 0.000000 ], [ - 0.500000, - 0.809017, 0.309017 ], [ - 0.238856, - 0.864188, 0.442863 ], [ - 0.262866, - 0.951056, 0.162460 ], [ - 0.864188, - 0.442863, 0.238856 ], [ - 0.809017, - 0.309017, 0.500000 ], [ - 0.688191, - 0.587785, 0.425325 ], [ - 0.681718, - 0.147621, 0.716567 ], [ - 0.442863, - 0.238856, 0.864188 ], [ - 0.587785, - 0.425325, 0.688191 ], [ - 0.309017, - 0.500000, 0.809017 ], [ - 0.147621, - 0.716567, 0.681718 ], [ - 0.425325, - 0.688191, 0.587785 ], [ - 0.162460, - 0.262866, 0.951056 ], [ 0.442863, - 0.238856, 0.864188 ], [ 0.162460, - 0.262866, 0.951056 ], [ 0.309017, - 0.500000, 0.809017 ], [ 0.147621, - 0.716567, 0.681718 ], [ 0.000000, - 0.525731, 0.850651 ], [ 0.425325, - 0.688191, 0.587785 ], [ 0.587785, - 0.425325, 0.688191 ], [ 0.688191, - 0.587785, 0.425325 ], [ - 0.955423, 0.295242, 0.000000 ], [ - 0.951056, 0.162460, 0.262866 ], [ - 1.000000, 0.000000, 0.000000 ], [ - 0.850651, 0.000000, 0.525731 ], [ - 0.955423, - 0.295242, 0.000000 ], [ - 0.951056, - 0.162460, 0.262866 ], [ - 0.864188, 0.442863, - 0.238856 ], [ - 0.951056, 0.162460, - 0.262866 ], [ - 0.809017, 0.309017, - 0.500000 ], [ - 0.864188, - 0.442863, - 0.238856 ], [ - 0.951056, - 0.162460, - 0.262866 ], [ - 0.809017, - 0.309017, - 0.500000 ], [ - 0.681718, 0.147621, - 0.716567 ], [ - 0.681718, - 0.147621, - 0.716567 ], [ - 0.850651, 0.000000, - 0.525731 ], [ - 0.688191, 0.587785, - 0.425325 ], [ - 0.587785, 0.425325, - 0.688191 ], [ - 0.425325, 0.688191, - 0.587785 ], [ - 0.425325, - 0.688191, - 0.587785 ], [ - 0.587785, - 0.425325, - 0.688191 ], [ - 0.688191, - 0.587785, - 0.425325 ]];
|
|
4
|
-
|
|
5
4
|
class MD2Loader extends THREE.Loader {
|
|
6
5
|
|
|
7
6
|
constructor( manager ) {
|
|
@@ -9,7 +8,6 @@
|
|
|
9
8
|
super( manager );
|
|
10
9
|
|
|
11
10
|
}
|
|
12
|
-
|
|
13
11
|
load( url, onLoad, onProgress, onError ) {
|
|
14
12
|
|
|
15
13
|
const scope = this;
|
|
@@ -43,14 +41,14 @@
|
|
|
43
41
|
}, onProgress, onError );
|
|
44
42
|
|
|
45
43
|
}
|
|
46
|
-
|
|
47
44
|
parse( buffer ) {
|
|
48
45
|
|
|
49
|
-
const data = new DataView( buffer );
|
|
46
|
+
const data = new DataView( buffer );
|
|
47
|
+
|
|
48
|
+
// http://tfc.duke.free.fr/coding/md2-specs-en.html
|
|
50
49
|
|
|
51
50
|
const header = {};
|
|
52
51
|
const headerNames = [ 'ident', 'version', 'skinwidth', 'skinheight', 'framesize', 'num_skins', 'num_vertices', 'num_st', 'num_tris', 'num_glcmds', 'num_frames', 'offset_skins', 'offset_st', 'offset_tris', 'offset_frames', 'offset_glcmds', 'offset_end' ];
|
|
53
|
-
|
|
54
52
|
for ( let i = 0; i < headerNames.length; i ++ ) {
|
|
55
53
|
|
|
56
54
|
header[ headerNames[ i ] ] = data.getInt32( i * 4, true );
|
|
@@ -69,14 +67,16 @@
|
|
|
69
67
|
console.error( 'Corrupted MD2 file' );
|
|
70
68
|
return;
|
|
71
69
|
|
|
72
|
-
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
//
|
|
73
73
|
|
|
74
|
+
const geometry = new THREE.BufferGeometry();
|
|
74
75
|
|
|
75
|
-
|
|
76
|
+
// uvs
|
|
76
77
|
|
|
77
78
|
const uvsTemp = [];
|
|
78
79
|
let offset = header.offset_st;
|
|
79
|
-
|
|
80
80
|
for ( let i = 0, l = header.num_st; i < l; i ++ ) {
|
|
81
81
|
|
|
82
82
|
const u = data.getInt16( offset + 0, true );
|
|
@@ -84,34 +84,33 @@
|
|
|
84
84
|
uvsTemp.push( u / header.skinwidth, 1 - v / header.skinheight );
|
|
85
85
|
offset += 4;
|
|
86
86
|
|
|
87
|
-
}
|
|
87
|
+
}
|
|
88
88
|
|
|
89
|
+
// triangles
|
|
89
90
|
|
|
90
91
|
offset = header.offset_tris;
|
|
91
92
|
const vertexIndices = [];
|
|
92
93
|
const uvIndices = [];
|
|
93
|
-
|
|
94
94
|
for ( let i = 0, l = header.num_tris; i < l; i ++ ) {
|
|
95
95
|
|
|
96
96
|
vertexIndices.push( data.getUint16( offset + 0, true ), data.getUint16( offset + 2, true ), data.getUint16( offset + 4, true ) );
|
|
97
97
|
uvIndices.push( data.getUint16( offset + 6, true ), data.getUint16( offset + 8, true ), data.getUint16( offset + 10, true ) );
|
|
98
98
|
offset += 12;
|
|
99
99
|
|
|
100
|
-
}
|
|
100
|
+
}
|
|
101
101
|
|
|
102
|
+
// frames
|
|
102
103
|
|
|
103
104
|
const translation = new THREE.Vector3();
|
|
104
105
|
const scale = new THREE.Vector3();
|
|
105
106
|
const frames = [];
|
|
106
107
|
offset = header.offset_frames;
|
|
107
|
-
|
|
108
108
|
for ( let i = 0, l = header.num_frames; i < l; i ++ ) {
|
|
109
109
|
|
|
110
110
|
scale.set( data.getFloat32( offset + 0, true ), data.getFloat32( offset + 4, true ), data.getFloat32( offset + 8, true ) );
|
|
111
111
|
translation.set( data.getFloat32( offset + 12, true ), data.getFloat32( offset + 16, true ), data.getFloat32( offset + 20, true ) );
|
|
112
112
|
offset += 24;
|
|
113
113
|
const string = [];
|
|
114
|
-
|
|
115
114
|
for ( let j = 0; j < 16; j ++ ) {
|
|
116
115
|
|
|
117
116
|
const character = data.getUint8( offset + j );
|
|
@@ -126,49 +125,51 @@
|
|
|
126
125
|
normals: []
|
|
127
126
|
};
|
|
128
127
|
offset += 16;
|
|
129
|
-
|
|
130
128
|
for ( let j = 0; j < header.num_vertices; j ++ ) {
|
|
131
129
|
|
|
132
130
|
let x = data.getUint8( offset ++ );
|
|
133
131
|
let y = data.getUint8( offset ++ );
|
|
134
132
|
let z = data.getUint8( offset ++ );
|
|
135
|
-
|
|
136
133
|
const n = _normalData[ data.getUint8( offset ++ ) ];
|
|
137
|
-
|
|
138
134
|
x = x * scale.x + translation.x;
|
|
139
135
|
y = y * scale.y + translation.y;
|
|
140
136
|
z = z * scale.z + translation.z;
|
|
141
137
|
frame.vertices.push( x, z, y ); // convert to Y-up
|
|
142
|
-
|
|
143
138
|
frame.normals.push( n[ 0 ], n[ 2 ], n[ 1 ] ); // convert to Y-up
|
|
144
139
|
|
|
145
140
|
}
|
|
146
141
|
|
|
147
142
|
frames.push( frame );
|
|
148
143
|
|
|
149
|
-
}
|
|
144
|
+
}
|
|
150
145
|
|
|
146
|
+
// static
|
|
151
147
|
|
|
152
148
|
const positions = [];
|
|
153
149
|
const normals = [];
|
|
154
150
|
const uvs = [];
|
|
155
151
|
const verticesTemp = frames[ 0 ].vertices;
|
|
156
152
|
const normalsTemp = frames[ 0 ].normals;
|
|
157
|
-
|
|
158
153
|
for ( let i = 0, l = vertexIndices.length; i < l; i ++ ) {
|
|
159
154
|
|
|
160
155
|
const vertexIndex = vertexIndices[ i ];
|
|
161
|
-
let stride = vertexIndex * 3;
|
|
156
|
+
let stride = vertexIndex * 3;
|
|
157
|
+
|
|
158
|
+
//
|
|
162
159
|
|
|
163
160
|
const x = verticesTemp[ stride ];
|
|
164
161
|
const y = verticesTemp[ stride + 1 ];
|
|
165
162
|
const z = verticesTemp[ stride + 2 ];
|
|
166
|
-
positions.push( x, y, z );
|
|
163
|
+
positions.push( x, y, z );
|
|
164
|
+
|
|
165
|
+
//
|
|
167
166
|
|
|
168
167
|
const nx = normalsTemp[ stride ];
|
|
169
168
|
const ny = normalsTemp[ stride + 1 ];
|
|
170
169
|
const nz = normalsTemp[ stride + 2 ];
|
|
171
|
-
normals.push( nx, ny, nz );
|
|
170
|
+
normals.push( nx, ny, nz );
|
|
171
|
+
|
|
172
|
+
//
|
|
172
173
|
|
|
173
174
|
const uvIndex = uvIndices[ i ];
|
|
174
175
|
stride = uvIndex * 2;
|
|
@@ -180,20 +181,19 @@
|
|
|
180
181
|
|
|
181
182
|
geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( positions, 3 ) );
|
|
182
183
|
geometry.setAttribute( 'normal', new THREE.Float32BufferAttribute( normals, 3 ) );
|
|
183
|
-
geometry.setAttribute( 'uv', new THREE.Float32BufferAttribute( uvs, 2 ) );
|
|
184
|
+
geometry.setAttribute( 'uv', new THREE.Float32BufferAttribute( uvs, 2 ) );
|
|
185
|
+
|
|
186
|
+
// animation
|
|
184
187
|
|
|
185
188
|
const morphPositions = [];
|
|
186
189
|
const morphNormals = [];
|
|
187
|
-
|
|
188
190
|
for ( let i = 0, l = frames.length; i < l; i ++ ) {
|
|
189
191
|
|
|
190
192
|
const frame = frames[ i ];
|
|
191
193
|
const attributeName = frame.name;
|
|
192
|
-
|
|
193
194
|
if ( frame.vertices.length > 0 ) {
|
|
194
195
|
|
|
195
196
|
const positions = [];
|
|
196
|
-
|
|
197
197
|
for ( let j = 0, jl = vertexIndices.length; j < jl; j ++ ) {
|
|
198
198
|
|
|
199
199
|
const vertexIndex = vertexIndices[ j ];
|
|
@@ -214,7 +214,6 @@
|
|
|
214
214
|
if ( frame.normals.length > 0 ) {
|
|
215
215
|
|
|
216
216
|
const normals = [];
|
|
217
|
-
|
|
218
217
|
for ( let j = 0, jl = vertexIndices.length; j < jl; j ++ ) {
|
|
219
218
|
|
|
220
219
|
const vertexIndex = vertexIndices[ j ];
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
* time values for each frame (sequence of float32)
|
|
12
12
|
* vertex data for each frame (sequence of float32)
|
|
13
13
|
*/
|
|
14
|
-
|
|
15
14
|
class MDDLoader extends THREE.Loader {
|
|
16
15
|
|
|
17
16
|
constructor( manager ) {
|
|
@@ -19,7 +18,6 @@
|
|
|
19
18
|
super( manager );
|
|
20
19
|
|
|
21
20
|
}
|
|
22
|
-
|
|
23
21
|
load( url, onLoad, onProgress, onError ) {
|
|
24
22
|
|
|
25
23
|
const scope = this;
|
|
@@ -33,17 +31,17 @@
|
|
|
33
31
|
}, onProgress, onError );
|
|
34
32
|
|
|
35
33
|
}
|
|
36
|
-
|
|
37
34
|
parse( data ) {
|
|
38
35
|
|
|
39
36
|
const view = new DataView( data );
|
|
40
37
|
const totalFrames = view.getUint32( 0 );
|
|
41
38
|
const totalPoints = view.getUint32( 4 );
|
|
42
|
-
let offset = 8;
|
|
39
|
+
let offset = 8;
|
|
40
|
+
|
|
41
|
+
// animation clip
|
|
43
42
|
|
|
44
43
|
const times = new Float32Array( totalFrames );
|
|
45
44
|
const values = new Float32Array( totalFrames * totalFrames ).fill( 0 );
|
|
46
|
-
|
|
47
45
|
for ( let i = 0; i < totalFrames; i ++ ) {
|
|
48
46
|
|
|
49
47
|
times[ i ] = view.getFloat32( offset );
|
|
@@ -53,23 +51,21 @@
|
|
|
53
51
|
}
|
|
54
52
|
|
|
55
53
|
const track = new THREE.NumberKeyframeTrack( '.morphTargetInfluences', times, values );
|
|
56
|
-
const clip = new THREE.AnimationClip( 'default', times[ times.length - 1 ], [ track ] );
|
|
54
|
+
const clip = new THREE.AnimationClip( 'default', times[ times.length - 1 ], [ track ] );
|
|
57
55
|
|
|
58
|
-
|
|
56
|
+
// morph targets
|
|
59
57
|
|
|
58
|
+
const morphTargets = [];
|
|
60
59
|
for ( let i = 0; i < totalFrames; i ++ ) {
|
|
61
60
|
|
|
62
61
|
const morphTarget = new Float32Array( totalPoints * 3 );
|
|
63
|
-
|
|
64
62
|
for ( let j = 0; j < totalPoints; j ++ ) {
|
|
65
63
|
|
|
66
64
|
const stride = j * 3;
|
|
67
65
|
morphTarget[ stride + 0 ] = view.getFloat32( offset );
|
|
68
66
|
offset += 4; // x
|
|
69
|
-
|
|
70
67
|
morphTarget[ stride + 1 ] = view.getFloat32( offset );
|
|
71
68
|
offset += 4; // y
|
|
72
|
-
|
|
73
69
|
morphTarget[ stride + 2 ] = view.getFloat32( offset );
|
|
74
70
|
offset += 4; // z
|
|
75
71
|
|