@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
|
@@ -12,9 +12,7 @@
|
|
|
12
12
|
* https://static.lightwave3d.com/sdk/2019/html/filefmts/lwo2.html
|
|
13
13
|
*
|
|
14
14
|
**/
|
|
15
|
-
|
|
16
15
|
let _lwoTree;
|
|
17
|
-
|
|
18
16
|
class LWOLoader extends THREE.Loader {
|
|
19
17
|
|
|
20
18
|
constructor( manager, parameters = {} ) {
|
|
@@ -23,12 +21,12 @@
|
|
|
23
21
|
this.resourcePath = parameters.resourcePath !== undefined ? parameters.resourcePath : '';
|
|
24
22
|
|
|
25
23
|
}
|
|
26
|
-
|
|
27
24
|
load( url, onLoad, onProgress, onError ) {
|
|
28
25
|
|
|
29
26
|
const scope = this;
|
|
30
|
-
const path = scope.path === '' ? extractParentUrl( url, 'Objects' ) : scope.path;
|
|
27
|
+
const path = scope.path === '' ? extractParentUrl( url, 'Objects' ) : scope.path;
|
|
31
28
|
|
|
29
|
+
// give the mesh a default name based on the filename
|
|
32
30
|
const modelName = url.split( path ).pop().split( '.' )[ 0 ];
|
|
33
31
|
const loader = new THREE.FileLoader( this.manager );
|
|
34
32
|
loader.setPath( scope.path );
|
|
@@ -36,6 +34,7 @@
|
|
|
36
34
|
loader.load( url, function ( buffer ) {
|
|
37
35
|
|
|
38
36
|
// console.time( 'Total parsing: ' );
|
|
37
|
+
|
|
39
38
|
try {
|
|
40
39
|
|
|
41
40
|
onLoad( scope.parse( buffer, path, modelName ) );
|
|
@@ -54,24 +53,27 @@
|
|
|
54
53
|
|
|
55
54
|
scope.manager.itemError( url );
|
|
56
55
|
|
|
57
|
-
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// console.timeEnd( 'Total parsing: ' );
|
|
58
59
|
|
|
59
60
|
}, onProgress, onError );
|
|
60
61
|
|
|
61
62
|
}
|
|
62
|
-
|
|
63
63
|
parse( iffBuffer, path, modelName ) {
|
|
64
64
|
|
|
65
|
-
_lwoTree = new THREE.IFFParser().parse( iffBuffer );
|
|
65
|
+
_lwoTree = new THREE.IFFParser().parse( iffBuffer );
|
|
66
|
+
|
|
67
|
+
// console.log( 'lwoTree', lwoTree );
|
|
66
68
|
|
|
67
69
|
const textureLoader = new THREE.TextureLoader( this.manager ).setPath( this.resourcePath || path ).setCrossOrigin( this.crossOrigin );
|
|
68
70
|
return new LWOTreeParser( textureLoader ).parse( modelName );
|
|
69
71
|
|
|
70
72
|
}
|
|
71
73
|
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
+
}
|
|
74
75
|
|
|
76
|
+
// Parse the lwoTree object
|
|
75
77
|
class LWOTreeParser {
|
|
76
78
|
|
|
77
79
|
constructor( textureLoader ) {
|
|
@@ -79,7 +81,6 @@
|
|
|
79
81
|
this.textureLoader = textureLoader;
|
|
80
82
|
|
|
81
83
|
}
|
|
82
|
-
|
|
83
84
|
parse( modelName ) {
|
|
84
85
|
|
|
85
86
|
this.materials = new MaterialParser( this.textureLoader ).parse();
|
|
@@ -91,16 +92,15 @@
|
|
|
91
92
|
};
|
|
92
93
|
|
|
93
94
|
}
|
|
94
|
-
|
|
95
95
|
parseLayers() {
|
|
96
96
|
|
|
97
97
|
// array of all meshes for building hierarchy
|
|
98
|
-
const meshes = [];
|
|
98
|
+
const meshes = [];
|
|
99
99
|
|
|
100
|
+
// final array containing meshes with scene graph hierarchy set up
|
|
100
101
|
const finalMeshes = [];
|
|
101
102
|
const geometryParser = new GeometryParser();
|
|
102
103
|
const scope = this;
|
|
103
|
-
|
|
104
104
|
_lwoTree.layers.forEach( function ( layer ) {
|
|
105
105
|
|
|
106
106
|
const geometry = geometryParser.parse( layer.geometry, layer );
|
|
@@ -109,12 +109,10 @@
|
|
|
109
109
|
if ( layer.parent === - 1 ) finalMeshes.push( mesh ); else meshes[ layer.parent ].add( mesh );
|
|
110
110
|
|
|
111
111
|
} );
|
|
112
|
-
|
|
113
112
|
this.applyPivots( finalMeshes );
|
|
114
113
|
return finalMeshes;
|
|
115
114
|
|
|
116
115
|
}
|
|
117
|
-
|
|
118
116
|
parseMesh( geometry, layer ) {
|
|
119
117
|
|
|
120
118
|
let mesh;
|
|
@@ -125,9 +123,9 @@
|
|
|
125
123
|
mesh.userData.pivot = layer.pivot;
|
|
126
124
|
return mesh;
|
|
127
125
|
|
|
128
|
-
}
|
|
129
|
-
|
|
126
|
+
}
|
|
130
127
|
|
|
128
|
+
// TODO: may need to be reversed in z to convert LWO to three.js coordinates
|
|
131
129
|
applyPivots( meshes ) {
|
|
132
130
|
|
|
133
131
|
meshes.forEach( function ( mesh ) {
|
|
@@ -138,7 +136,6 @@
|
|
|
138
136
|
child.position.x += pivot[ 0 ];
|
|
139
137
|
child.position.y += pivot[ 1 ];
|
|
140
138
|
child.position.z += pivot[ 2 ];
|
|
141
|
-
|
|
142
139
|
if ( child.parent ) {
|
|
143
140
|
|
|
144
141
|
const parentPivot = child.parent.userData.pivot;
|
|
@@ -153,7 +150,6 @@
|
|
|
153
150
|
} );
|
|
154
151
|
|
|
155
152
|
}
|
|
156
|
-
|
|
157
153
|
getMaterials( namesArray, type ) {
|
|
158
154
|
|
|
159
155
|
const materials = [];
|
|
@@ -162,8 +158,9 @@
|
|
|
162
158
|
|
|
163
159
|
materials[ i ] = scope.getMaterialByName( name );
|
|
164
160
|
|
|
165
|
-
} );
|
|
161
|
+
} );
|
|
166
162
|
|
|
163
|
+
// convert materials to line or point mats if required
|
|
167
164
|
if ( type === 'points' || type === 'lines' ) {
|
|
168
165
|
|
|
169
166
|
materials.forEach( function ( mat, i ) {
|
|
@@ -171,7 +168,6 @@
|
|
|
171
168
|
const spec = {
|
|
172
169
|
color: mat.color
|
|
173
170
|
};
|
|
174
|
-
|
|
175
171
|
if ( type === 'points' ) {
|
|
176
172
|
|
|
177
173
|
spec.size = 0.1;
|
|
@@ -186,15 +182,14 @@
|
|
|
186
182
|
|
|
187
183
|
} );
|
|
188
184
|
|
|
189
|
-
}
|
|
190
|
-
|
|
185
|
+
}
|
|
191
186
|
|
|
187
|
+
// if there is only one material, return that directly instead of array
|
|
192
188
|
const filtered = materials.filter( Boolean );
|
|
193
189
|
if ( filtered.length === 1 ) return filtered[ 0 ];
|
|
194
190
|
return materials;
|
|
195
191
|
|
|
196
192
|
}
|
|
197
|
-
|
|
198
193
|
getMaterialByName( name ) {
|
|
199
194
|
|
|
200
195
|
return this.materials.filter( function ( m ) {
|
|
@@ -203,13 +198,12 @@
|
|
|
203
198
|
|
|
204
199
|
} )[ 0 ];
|
|
205
200
|
|
|
206
|
-
}
|
|
207
|
-
|
|
201
|
+
}
|
|
208
202
|
|
|
203
|
+
// If the material has an aoMap, duplicate UVs
|
|
209
204
|
duplicateUVs( geometry, materials ) {
|
|
210
205
|
|
|
211
206
|
let duplicateUVs = false;
|
|
212
|
-
|
|
213
207
|
if ( ! Array.isArray( materials ) ) {
|
|
214
208
|
|
|
215
209
|
if ( materials.aoMap ) duplicateUVs = true;
|
|
@@ -230,7 +224,6 @@
|
|
|
230
224
|
}
|
|
231
225
|
|
|
232
226
|
}
|
|
233
|
-
|
|
234
227
|
class MaterialParser {
|
|
235
228
|
|
|
236
229
|
constructor( textureLoader ) {
|
|
@@ -238,12 +231,10 @@
|
|
|
238
231
|
this.textureLoader = textureLoader;
|
|
239
232
|
|
|
240
233
|
}
|
|
241
|
-
|
|
242
234
|
parse() {
|
|
243
235
|
|
|
244
236
|
const materials = [];
|
|
245
237
|
this.textures = {};
|
|
246
|
-
|
|
247
238
|
for ( const name in _lwoTree.materials ) {
|
|
248
239
|
|
|
249
240
|
if ( _lwoTree.format === 'LWO3' ) {
|
|
@@ -261,7 +252,6 @@
|
|
|
261
252
|
return materials;
|
|
262
253
|
|
|
263
254
|
}
|
|
264
|
-
|
|
265
255
|
parseMaterial( materialData, name, textures ) {
|
|
266
256
|
|
|
267
257
|
let params = {
|
|
@@ -282,10 +272,7 @@
|
|
|
282
272
|
return new materialType( params );
|
|
283
273
|
|
|
284
274
|
}
|
|
285
|
-
|
|
286
|
-
parseMaterialLwo2( materialData, name
|
|
287
|
-
/*, textures*/
|
|
288
|
-
) {
|
|
275
|
+
parseMaterialLwo2( materialData, name /*, textures*/ ) {
|
|
289
276
|
|
|
290
277
|
let params = {
|
|
291
278
|
name: name,
|
|
@@ -296,38 +283,33 @@
|
|
|
296
283
|
params = Object.assign( params, attributes );
|
|
297
284
|
return new THREE.MeshPhongMaterial( params );
|
|
298
285
|
|
|
299
|
-
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// Note: converting from left to right handed coords by switching x -> -x in vertices, and
|
|
300
289
|
// then switching mat THREE.FrontSide -> THREE.BackSide
|
|
301
290
|
// NB: this means that THREE.FrontSide and THREE.BackSide have been switched!
|
|
302
|
-
|
|
303
|
-
|
|
304
291
|
getSide( attributes ) {
|
|
305
292
|
|
|
306
293
|
if ( ! attributes.side ) return THREE.BackSide;
|
|
307
|
-
|
|
308
294
|
switch ( attributes.side ) {
|
|
309
295
|
|
|
310
296
|
case 0:
|
|
311
297
|
case 1:
|
|
312
298
|
return THREE.BackSide;
|
|
313
|
-
|
|
314
299
|
case 2:
|
|
315
300
|
return THREE.FrontSide;
|
|
316
|
-
|
|
317
301
|
case 3:
|
|
318
302
|
return THREE.DoubleSide;
|
|
319
303
|
|
|
320
304
|
}
|
|
321
305
|
|
|
322
306
|
}
|
|
323
|
-
|
|
324
307
|
getSmooth( attributes ) {
|
|
325
308
|
|
|
326
309
|
if ( ! attributes.smooth ) return true;
|
|
327
310
|
return ! attributes.smooth;
|
|
328
311
|
|
|
329
312
|
}
|
|
330
|
-
|
|
331
313
|
parseConnections( connections, nodes ) {
|
|
332
314
|
|
|
333
315
|
const materialConnections = {
|
|
@@ -361,7 +343,6 @@
|
|
|
361
343
|
return materialConnections;
|
|
362
344
|
|
|
363
345
|
}
|
|
364
|
-
|
|
365
346
|
getNodeByRefName( refName, nodes ) {
|
|
366
347
|
|
|
367
348
|
for ( const name in nodes ) {
|
|
@@ -371,11 +352,9 @@
|
|
|
371
352
|
}
|
|
372
353
|
|
|
373
354
|
}
|
|
374
|
-
|
|
375
355
|
parseTextureNodes( textureNodes ) {
|
|
376
356
|
|
|
377
357
|
const maps = {};
|
|
378
|
-
|
|
379
358
|
for ( const name in textureNodes ) {
|
|
380
359
|
|
|
381
360
|
const node = textureNodes[ name ];
|
|
@@ -384,70 +363,60 @@
|
|
|
384
363
|
const texture = this.loadTexture( path );
|
|
385
364
|
if ( node.widthWrappingMode !== undefined ) texture.wrapS = this.getWrappingType( node.widthWrappingMode );
|
|
386
365
|
if ( node.heightWrappingMode !== undefined ) texture.wrapT = this.getWrappingType( node.heightWrappingMode );
|
|
387
|
-
|
|
388
366
|
switch ( name ) {
|
|
389
367
|
|
|
390
368
|
case 'Color':
|
|
391
369
|
maps.map = texture;
|
|
392
370
|
break;
|
|
393
|
-
|
|
394
371
|
case 'Roughness':
|
|
395
372
|
maps.roughnessMap = texture;
|
|
396
373
|
maps.roughness = 1;
|
|
397
374
|
break;
|
|
398
|
-
|
|
399
375
|
case 'Specular':
|
|
400
376
|
maps.specularMap = texture;
|
|
401
377
|
maps.specular = 0xffffff;
|
|
402
378
|
break;
|
|
403
|
-
|
|
404
379
|
case 'Luminous':
|
|
405
380
|
maps.emissiveMap = texture;
|
|
406
381
|
maps.emissive = 0x808080;
|
|
407
382
|
break;
|
|
408
|
-
|
|
409
383
|
case 'Luminous THREE.Color':
|
|
410
384
|
maps.emissive = 0x808080;
|
|
411
385
|
break;
|
|
412
|
-
|
|
413
386
|
case 'Metallic':
|
|
414
387
|
maps.metalnessMap = texture;
|
|
415
388
|
maps.metalness = 1;
|
|
416
389
|
break;
|
|
417
|
-
|
|
418
390
|
case 'Transparency':
|
|
419
391
|
case 'Alpha':
|
|
420
392
|
maps.alphaMap = texture;
|
|
421
393
|
maps.transparent = true;
|
|
422
394
|
break;
|
|
423
|
-
|
|
424
395
|
case 'Normal':
|
|
425
396
|
maps.normalMap = texture;
|
|
426
397
|
if ( node.amplitude !== undefined ) maps.normalScale = new THREE.Vector2( node.amplitude, node.amplitude );
|
|
427
398
|
break;
|
|
428
|
-
|
|
429
399
|
case 'Bump':
|
|
430
400
|
maps.bumpMap = texture;
|
|
431
401
|
break;
|
|
432
402
|
|
|
433
403
|
}
|
|
434
404
|
|
|
435
|
-
}
|
|
436
|
-
|
|
405
|
+
}
|
|
437
406
|
|
|
407
|
+
// LWO BSDF materials can have both spec and rough, but this is not valid in three
|
|
438
408
|
if ( maps.roughnessMap && maps.specularMap ) delete maps.specularMap;
|
|
439
409
|
return maps;
|
|
440
410
|
|
|
441
|
-
}
|
|
442
|
-
// This occurs on Standard (Phong) surfaces
|
|
443
|
-
|
|
411
|
+
}
|
|
444
412
|
|
|
413
|
+
// maps can also be defined on individual material attributes, parse those here
|
|
414
|
+
// This occurs on Standard (Phong) surfaces
|
|
445
415
|
parseAttributeImageMaps( attributes, textures, maps ) {
|
|
446
416
|
|
|
447
417
|
for ( const name in attributes ) {
|
|
448
418
|
|
|
449
419
|
const attribute = attributes[ name ];
|
|
450
|
-
|
|
451
420
|
if ( attribute.maps ) {
|
|
452
421
|
|
|
453
422
|
const mapData = attribute.maps[ 0 ];
|
|
@@ -456,47 +425,38 @@
|
|
|
456
425
|
const texture = this.loadTexture( path );
|
|
457
426
|
if ( mapData.wrap !== undefined ) texture.wrapS = this.getWrappingType( mapData.wrap.w );
|
|
458
427
|
if ( mapData.wrap !== undefined ) texture.wrapT = this.getWrappingType( mapData.wrap.h );
|
|
459
|
-
|
|
460
428
|
switch ( name ) {
|
|
461
429
|
|
|
462
430
|
case 'Color':
|
|
463
431
|
maps.map = texture;
|
|
464
432
|
break;
|
|
465
|
-
|
|
466
433
|
case 'Diffuse':
|
|
467
434
|
maps.aoMap = texture;
|
|
468
435
|
break;
|
|
469
|
-
|
|
470
436
|
case 'Roughness':
|
|
471
437
|
maps.roughnessMap = texture;
|
|
472
438
|
maps.roughness = 1;
|
|
473
439
|
break;
|
|
474
|
-
|
|
475
440
|
case 'Specular':
|
|
476
441
|
maps.specularMap = texture;
|
|
477
442
|
maps.specular = 0xffffff;
|
|
478
443
|
break;
|
|
479
|
-
|
|
480
444
|
case 'Luminosity':
|
|
481
445
|
maps.emissiveMap = texture;
|
|
482
446
|
maps.emissive = 0x808080;
|
|
483
447
|
break;
|
|
484
|
-
|
|
485
448
|
case 'Metallic':
|
|
486
449
|
maps.metalnessMap = texture;
|
|
487
450
|
maps.metalness = 1;
|
|
488
451
|
break;
|
|
489
|
-
|
|
490
452
|
case 'Transparency':
|
|
491
453
|
case 'Alpha':
|
|
492
454
|
maps.alphaMap = texture;
|
|
493
455
|
maps.transparent = true;
|
|
494
456
|
break;
|
|
495
|
-
|
|
496
457
|
case 'Normal':
|
|
497
458
|
maps.normalMap = texture;
|
|
498
459
|
break;
|
|
499
|
-
|
|
500
460
|
case 'Bump':
|
|
501
461
|
maps.bumpMap = texture;
|
|
502
462
|
break;
|
|
@@ -508,17 +468,16 @@
|
|
|
508
468
|
}
|
|
509
469
|
|
|
510
470
|
}
|
|
511
|
-
|
|
512
471
|
parseAttributes( attributes, maps ) {
|
|
513
472
|
|
|
514
|
-
const params = {};
|
|
473
|
+
const params = {};
|
|
515
474
|
|
|
475
|
+
// don't use color data if color map is present
|
|
516
476
|
if ( attributes.Color && ! maps.map ) {
|
|
517
477
|
|
|
518
478
|
params.color = new THREE.Color().fromArray( attributes.Color.value );
|
|
519
479
|
|
|
520
480
|
} else params.color = new THREE.Color();
|
|
521
|
-
|
|
522
481
|
if ( attributes.Transparency && attributes.Transparency.value !== 0 ) {
|
|
523
482
|
|
|
524
483
|
params.opacity = 1 - attributes.Transparency.value;
|
|
@@ -533,15 +492,11 @@
|
|
|
533
492
|
return params;
|
|
534
493
|
|
|
535
494
|
}
|
|
536
|
-
|
|
537
|
-
parsePhysicalAttributes( params, attributes
|
|
538
|
-
/*, maps*/
|
|
539
|
-
) {
|
|
495
|
+
parsePhysicalAttributes( params, attributes /*, maps*/ ) {
|
|
540
496
|
|
|
541
497
|
if ( attributes.Clearcoat && attributes.Clearcoat.value > 0 ) {
|
|
542
498
|
|
|
543
499
|
params.clearcoat = attributes.Clearcoat.value;
|
|
544
|
-
|
|
545
500
|
if ( attributes[ 'Clearcoat Gloss' ] ) {
|
|
546
501
|
|
|
547
502
|
params.clearcoatRoughness = 0.5 * ( 1 - attributes[ 'Clearcoat Gloss' ].value );
|
|
@@ -551,13 +506,11 @@
|
|
|
551
506
|
}
|
|
552
507
|
|
|
553
508
|
}
|
|
554
|
-
|
|
555
509
|
parseStandardAttributes( params, attributes, maps ) {
|
|
556
510
|
|
|
557
511
|
if ( attributes.Luminous ) {
|
|
558
512
|
|
|
559
513
|
params.emissiveIntensity = attributes.Luminous.value;
|
|
560
|
-
|
|
561
514
|
if ( attributes[ 'Luminous THREE.Color' ] && ! maps.emissive ) {
|
|
562
515
|
|
|
563
516
|
params.emissive = new THREE.Color().fromArray( attributes[ 'Luminous THREE.Color' ].value );
|
|
@@ -574,12 +527,10 @@
|
|
|
574
527
|
if ( attributes.Metallic && ! maps.metalnessMap ) params.metalness = attributes.Metallic.value;
|
|
575
528
|
|
|
576
529
|
}
|
|
577
|
-
|
|
578
530
|
parsePhongAttributes( params, attributes, maps ) {
|
|
579
531
|
|
|
580
532
|
if ( attributes[ 'Refraction Index' ] ) params.refractionRatio = 0.98 / attributes[ 'Refraction Index' ].value;
|
|
581
533
|
if ( attributes.Diffuse ) params.color.multiplyScalar( attributes.Diffuse.value );
|
|
582
|
-
|
|
583
534
|
if ( attributes.Reflection ) {
|
|
584
535
|
|
|
585
536
|
params.reflectivity = attributes.Reflection.value;
|
|
@@ -590,7 +541,6 @@
|
|
|
590
541
|
if ( attributes.Luminosity ) {
|
|
591
542
|
|
|
592
543
|
params.emissiveIntensity = attributes.Luminosity.value;
|
|
593
|
-
|
|
594
544
|
if ( ! maps.emissiveMap && ! maps.map ) {
|
|
595
545
|
|
|
596
546
|
params.emissive = params.color;
|
|
@@ -601,9 +551,9 @@
|
|
|
601
551
|
|
|
602
552
|
}
|
|
603
553
|
|
|
604
|
-
}
|
|
605
|
-
|
|
554
|
+
}
|
|
606
555
|
|
|
556
|
+
// parse specular if there is no roughness - we will interpret the material as 'Phong' in this case
|
|
607
557
|
if ( ! attributes.Roughness && attributes.Specular && ! maps.specularMap ) {
|
|
608
558
|
|
|
609
559
|
if ( attributes[ 'Color Highlight' ] ) {
|
|
@@ -621,17 +571,16 @@
|
|
|
621
571
|
if ( params.specular && attributes.Glossiness ) params.shininess = 7 + Math.pow( 2, attributes.Glossiness.value * 12 + 2 );
|
|
622
572
|
|
|
623
573
|
}
|
|
624
|
-
|
|
625
574
|
parseEnvMap( connections, maps, attributes ) {
|
|
626
575
|
|
|
627
576
|
if ( connections.envMap ) {
|
|
628
577
|
|
|
629
578
|
const envMap = this.loadTexture( connections.envMap );
|
|
630
|
-
|
|
631
579
|
if ( attributes.transparent && attributes.opacity < 0.999 ) {
|
|
632
580
|
|
|
633
|
-
envMap.mapping = THREE.EquirectangularRefractionMapping;
|
|
581
|
+
envMap.mapping = THREE.EquirectangularRefractionMapping;
|
|
634
582
|
|
|
583
|
+
// Reflectivity and refraction mapping don't work well together in Phong materials
|
|
635
584
|
if ( attributes.reflectivity !== undefined ) {
|
|
636
585
|
|
|
637
586
|
delete attributes.reflectivity;
|
|
@@ -648,29 +597,25 @@
|
|
|
648
597
|
attributes.opacity = 1; // transparency fades out refraction, forcing opacity to 1 ensures a closer visual match to the material in Lightwave.
|
|
649
598
|
|
|
650
599
|
} else envMap.mapping = THREE.EquirectangularReflectionMapping;
|
|
651
|
-
|
|
652
600
|
maps.envMap = envMap;
|
|
653
601
|
|
|
654
602
|
}
|
|
655
603
|
|
|
656
|
-
}
|
|
657
|
-
|
|
604
|
+
}
|
|
658
605
|
|
|
606
|
+
// get texture defined at top level by its index
|
|
659
607
|
getTexturePathByIndex( index ) {
|
|
660
608
|
|
|
661
609
|
let fileName = '';
|
|
662
610
|
if ( ! _lwoTree.textures ) return fileName;
|
|
663
|
-
|
|
664
611
|
_lwoTree.textures.forEach( function ( texture ) {
|
|
665
612
|
|
|
666
613
|
if ( texture.index === index ) fileName = texture.fileName;
|
|
667
614
|
|
|
668
615
|
} );
|
|
669
|
-
|
|
670
616
|
return fileName;
|
|
671
617
|
|
|
672
618
|
}
|
|
673
|
-
|
|
674
619
|
loadTexture( path ) {
|
|
675
620
|
|
|
676
621
|
if ( ! path ) return null;
|
|
@@ -681,9 +626,9 @@
|
|
|
681
626
|
} );
|
|
682
627
|
return texture;
|
|
683
628
|
|
|
684
|
-
}
|
|
685
|
-
|
|
629
|
+
}
|
|
686
630
|
|
|
631
|
+
// 0 = Reset, 1 = Repeat, 2 = Mirror, 3 = Edge
|
|
687
632
|
getWrappingType( num ) {
|
|
688
633
|
|
|
689
634
|
switch ( num ) {
|
|
@@ -691,20 +636,16 @@
|
|
|
691
636
|
case 0:
|
|
692
637
|
console.warn( 'LWOLoader: "Reset" texture wrapping type is not supported in three.js' );
|
|
693
638
|
return THREE.ClampToEdgeWrapping;
|
|
694
|
-
|
|
695
639
|
case 1:
|
|
696
640
|
return THREE.RepeatWrapping;
|
|
697
|
-
|
|
698
641
|
case 2:
|
|
699
642
|
return THREE.MirroredRepeatWrapping;
|
|
700
|
-
|
|
701
643
|
case 3:
|
|
702
644
|
return THREE.ClampToEdgeWrapping;
|
|
703
645
|
|
|
704
646
|
}
|
|
705
647
|
|
|
706
648
|
}
|
|
707
|
-
|
|
708
649
|
getMaterialType( nodeData ) {
|
|
709
650
|
|
|
710
651
|
if ( nodeData.Clearcoat && nodeData.Clearcoat.value > 0 ) return THREE.MeshPhysicalMaterial;
|
|
@@ -714,7 +655,6 @@
|
|
|
714
655
|
}
|
|
715
656
|
|
|
716
657
|
}
|
|
717
|
-
|
|
718
658
|
class GeometryParser {
|
|
719
659
|
|
|
720
660
|
parse( geoData, layer ) {
|
|
@@ -726,17 +666,20 @@
|
|
|
726
666
|
this.parseGroups( geometry, geoData );
|
|
727
667
|
geometry.computeVertexNormals();
|
|
728
668
|
this.parseUVs( geometry, layer, indices );
|
|
729
|
-
this.parseMorphTargets( geometry, layer, indices );
|
|
669
|
+
this.parseMorphTargets( geometry, layer, indices );
|
|
730
670
|
|
|
731
|
-
|
|
671
|
+
// TODO: z may need to be reversed to account for coordinate system change
|
|
672
|
+
geometry.translate( - layer.pivot[ 0 ], - layer.pivot[ 1 ], - layer.pivot[ 2 ] );
|
|
673
|
+
|
|
674
|
+
// let userData = geometry.userData;
|
|
732
675
|
// geometry = geometry.toNonIndexed()
|
|
733
676
|
// geometry.userData = userData;
|
|
734
677
|
|
|
735
678
|
return geometry;
|
|
736
679
|
|
|
737
|
-
}
|
|
738
|
-
|
|
680
|
+
}
|
|
739
681
|
|
|
682
|
+
// split quads into tris
|
|
740
683
|
splitIndices( indices, polygonDimensions ) {
|
|
741
684
|
|
|
742
685
|
const remappedIndices = [];
|
|
@@ -768,9 +711,9 @@
|
|
|
768
711
|
} );
|
|
769
712
|
return remappedIndices;
|
|
770
713
|
|
|
771
|
-
}
|
|
772
|
-
|
|
714
|
+
}
|
|
773
715
|
|
|
716
|
+
// NOTE: currently ignoring poly indices and assuming that they are intelligently ordered
|
|
774
717
|
parseGroups( geometry, geoData ) {
|
|
775
718
|
|
|
776
719
|
const tags = _lwoTree.tags;
|
|
@@ -780,24 +723,20 @@
|
|
|
780
723
|
if ( geoData.type === 'points' ) elemSize = 1;
|
|
781
724
|
const remappedIndices = this.splitMaterialIndices( geoData.polygonDimensions, geoData.materialIndices );
|
|
782
725
|
let indexNum = 0; // create new indices in numerical order
|
|
783
|
-
|
|
784
726
|
const indexPairs = {}; // original indices mapped to numerical indices
|
|
785
727
|
|
|
786
728
|
let prevMaterialIndex;
|
|
787
729
|
let materialIndex;
|
|
788
730
|
let prevStart = 0;
|
|
789
731
|
let currentCount = 0;
|
|
790
|
-
|
|
791
732
|
for ( let i = 0; i < remappedIndices.length; i += 2 ) {
|
|
792
733
|
|
|
793
734
|
materialIndex = remappedIndices[ i + 1 ];
|
|
794
735
|
if ( i === 0 ) matNames[ indexNum ] = tags[ materialIndex ];
|
|
795
736
|
if ( prevMaterialIndex === undefined ) prevMaterialIndex = materialIndex;
|
|
796
|
-
|
|
797
737
|
if ( materialIndex !== prevMaterialIndex ) {
|
|
798
738
|
|
|
799
739
|
let currentIndex;
|
|
800
|
-
|
|
801
740
|
if ( indexPairs[ tags[ prevMaterialIndex ] ] ) {
|
|
802
741
|
|
|
803
742
|
currentIndex = indexPairs[ tags[ prevMaterialIndex ] ];
|
|
@@ -820,13 +759,12 @@
|
|
|
820
759
|
|
|
821
760
|
currentCount += elemSize;
|
|
822
761
|
|
|
823
|
-
}
|
|
824
|
-
|
|
762
|
+
}
|
|
825
763
|
|
|
764
|
+
// the loop above doesn't add the last group, do that here.
|
|
826
765
|
if ( geometry.groups.length > 0 ) {
|
|
827
766
|
|
|
828
767
|
let currentIndex;
|
|
829
|
-
|
|
830
768
|
if ( indexPairs[ tags[ materialIndex ] ] ) {
|
|
831
769
|
|
|
832
770
|
currentIndex = indexPairs[ tags[ materialIndex ] ];
|
|
@@ -841,13 +779,12 @@
|
|
|
841
779
|
|
|
842
780
|
geometry.addGroup( prevStart, currentCount, currentIndex );
|
|
843
781
|
|
|
844
|
-
}
|
|
845
|
-
|
|
782
|
+
}
|
|
846
783
|
|
|
784
|
+
// Mat names from TAGS chunk, used to build up an array of materials for this geometry
|
|
847
785
|
geometry.userData.matNames = matNames;
|
|
848
786
|
|
|
849
787
|
}
|
|
850
|
-
|
|
851
788
|
splitMaterialIndices( polygonDimensions, indices ) {
|
|
852
789
|
|
|
853
790
|
const remappedIndices = [];
|
|
@@ -875,7 +812,9 @@
|
|
|
875
812
|
} );
|
|
876
813
|
return remappedIndices;
|
|
877
814
|
|
|
878
|
-
}
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
// UV maps:
|
|
879
818
|
// 1: are defined via index into an array of points, not into a geometry
|
|
880
819
|
// - the geometry is also defined by an index into this array, but the indexes may not match
|
|
881
820
|
// 2: there can be any number of UV maps for a single geometry. Here these are combined,
|
|
@@ -884,8 +823,6 @@
|
|
|
884
823
|
// 4: UV maps can be VMAP or VMAD (discontinuous, to allow for seams). In practice, most
|
|
885
824
|
// UV maps are defined as partially VMAP and partially VMAD
|
|
886
825
|
// VMADs are currently not supported
|
|
887
|
-
|
|
888
|
-
|
|
889
826
|
parseUVs( geometry, layer ) {
|
|
890
827
|
|
|
891
828
|
// start by creating a UV map set to zero for the whole geometry
|
|
@@ -894,7 +831,6 @@
|
|
|
894
831
|
return 0;
|
|
895
832
|
|
|
896
833
|
} );
|
|
897
|
-
|
|
898
834
|
for ( const name in layer.uvs ) {
|
|
899
835
|
|
|
900
836
|
const uvs = layer.uvs[ name ].uvs;
|
|
@@ -911,11 +847,9 @@
|
|
|
911
847
|
geometry.setAttribute( 'uv', new THREE.Float32BufferAttribute( remappedUVs, 2 ) );
|
|
912
848
|
|
|
913
849
|
}
|
|
914
|
-
|
|
915
850
|
parseMorphTargets( geometry, layer ) {
|
|
916
851
|
|
|
917
852
|
let num = 0;
|
|
918
|
-
|
|
919
853
|
for ( const name in layer.morphTargets ) {
|
|
920
854
|
|
|
921
855
|
const remappedPoints = geometry.attributes.position.array.slice();
|
|
@@ -950,8 +884,9 @@
|
|
|
950
884
|
|
|
951
885
|
}
|
|
952
886
|
|
|
953
|
-
}
|
|
887
|
+
}
|
|
954
888
|
|
|
889
|
+
// ************** UTILITY FUNCTIONS **************
|
|
955
890
|
|
|
956
891
|
function extractParentUrl( url, dir ) {
|
|
957
892
|
|