super-three 0.165.0 → 0.168.0
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/build/three.cjs +854 -410
- package/build/three.module.js +849 -411
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +77755 -0
- package/build/three.webgpu.min.js +6 -0
- package/examples/jsm/Addons.js +5 -2
- package/examples/jsm/animation/AnimationClipCreator.js +1 -1
- package/examples/jsm/capabilities/WebGL.js +27 -21
- package/examples/jsm/controls/ArcballControls.js +174 -158
- package/examples/jsm/controls/DragControls.js +260 -132
- package/examples/jsm/controls/FirstPersonControls.js +175 -163
- package/examples/jsm/controls/FlyControls.js +194 -188
- package/examples/jsm/controls/OrbitControls.js +777 -786
- package/examples/jsm/controls/PointerLockControls.js +24 -15
- package/examples/jsm/controls/TrackballControls.js +453 -452
- package/examples/jsm/csm/CSMShader.js +4 -4
- package/examples/jsm/effects/AnaglyphEffect.js +6 -13
- package/examples/jsm/effects/ParallaxBarrierEffect.js +17 -11
- package/examples/jsm/effects/StereoEffect.js +6 -1
- package/examples/jsm/environments/RoomEnvironment.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +13 -4
- package/examples/jsm/exporters/USDZExporter.js +29 -8
- package/examples/jsm/geometries/TeapotGeometry.js +1 -1
- package/examples/jsm/helpers/LightProbeHelper.js +42 -43
- package/examples/jsm/helpers/ViewHelper.js +51 -2
- package/examples/jsm/libs/tween.module.js +64 -75
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +91 -0
- package/examples/jsm/lights/RectAreaLightUniformsLib.js +8 -63
- package/examples/jsm/lines/webgpu/Line2.js +20 -0
- package/examples/jsm/lines/webgpu/LineSegments2.js +376 -0
- package/examples/jsm/loaders/FBXLoader.js +23 -45
- package/examples/jsm/loaders/GLTFLoader.js +10 -4
- package/examples/jsm/loaders/KTX2Loader.js +19 -7
- package/examples/jsm/loaders/MaterialXLoader.js +10 -10
- package/examples/jsm/loaders/PCDLoader.js +9 -9
- package/examples/jsm/loaders/USDZLoader.js +124 -76
- package/examples/jsm/loaders/UltraHDRLoader.js +583 -0
- package/examples/jsm/loaders/VTKLoader.js +76 -3
- package/examples/jsm/misc/GPUComputationRenderer.js +9 -19
- package/examples/jsm/modifiers/SimplifyModifier.js +2 -1
- package/examples/jsm/objects/InstancedPoints.js +2 -2
- package/examples/jsm/objects/SkyMesh.js +188 -0
- package/examples/jsm/objects/Water2Mesh.js +159 -0
- package/examples/jsm/objects/WaterMesh.js +102 -0
- package/examples/jsm/physics/RapierPhysics.js +20 -0
- package/examples/jsm/postprocessing/OutlinePass.js +31 -46
- package/examples/jsm/postprocessing/RenderTransitionPass.js +13 -38
- package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
- package/examples/jsm/postprocessing/SSAOPass.js +6 -9
- package/examples/jsm/postprocessing/UnrealBloomPass.js +4 -4
- package/examples/jsm/shaders/BleachBypassShader.js +1 -2
- package/examples/jsm/shaders/ColorifyShader.js +1 -2
- package/examples/jsm/shaders/FXAAShader.js +0 -2
- package/examples/jsm/shaders/GTAOShader.js +1 -1
- package/examples/jsm/shaders/LuminosityHighPassShader.js +1 -3
- package/examples/jsm/shaders/OutputShader.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +46 -4
- package/examples/jsm/transpiler/TSLEncoder.js +24 -22
- package/examples/jsm/utils/TextureUtils.js +1 -1
- package/package.json +8 -6
- package/src/Three.WebGPU.js +200 -0
- package/src/Three.js +3 -0
- package/src/constants.js +4 -1
- package/src/core/Object3D.js +22 -22
- package/src/extras/Controls.js +32 -0
- package/src/extras/TextureUtils.js +210 -0
- package/src/lights/Light.js +1 -0
- package/src/lights/LightShadow.js +5 -0
- package/{examples/jsm/lights → src/lights/webgpu}/IESSpotLight.js +1 -1
- package/src/loaders/ObjectLoader.js +33 -2
- package/{examples/jsm/nodes/loaders → src/loaders/nodes}/NodeLoader.js +6 -4
- package/{examples/jsm/nodes/loaders → src/loaders/nodes}/NodeMaterialLoader.js +2 -2
- package/{examples/jsm/nodes/loaders → src/loaders/nodes}/NodeObjectLoader.js +2 -1
- package/src/materials/Material.js +7 -1
- package/{examples/jsm/nodes/materials → src/materials/nodes}/InstancedPointsNodeMaterial.js +36 -27
- package/{examples/jsm/nodes/materials → src/materials/nodes}/Line2NodeMaterial.js +37 -40
- package/src/materials/nodes/LineBasicNodeMaterial.js +27 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/LineDashedNodeMaterial.js +10 -11
- package/src/materials/nodes/MeshBasicNodeMaterial.js +73 -0
- package/src/materials/nodes/MeshLambertNodeMaterial.js +43 -0
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +53 -0
- package/src/materials/nodes/MeshNormalNodeMaterial.js +40 -0
- package/src/materials/nodes/MeshPhongNodeMaterial.js +74 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/MeshPhysicalNodeMaterial.js +22 -20
- package/{examples/jsm/nodes/materials → src/materials/nodes}/MeshSSSNodeMaterial.js +6 -6
- package/{examples/jsm/nodes/materials → src/materials/nodes}/MeshStandardNodeMaterial.js +28 -11
- package/src/materials/nodes/MeshToonNodeMaterial.js +34 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/NodeMaterial.js +142 -96
- package/{examples/jsm/nodes/materials/Materials.js → src/materials/nodes/NodeMaterials.js} +1 -1
- package/{examples/jsm/nodes/materials → src/materials/nodes}/PointsNodeMaterial.js +5 -6
- package/src/materials/nodes/ShadowNodeMaterial.js +34 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/SpriteNodeMaterial.js +13 -13
- package/{examples/jsm/nodes/materials → src/materials/nodes}/VolumeNodeMaterial.js +14 -16
- package/src/math/Box2.js +4 -4
- package/src/math/Box3.js +6 -6
- package/src/math/ColorManagement.js +10 -0
- package/src/math/Matrix2.js +54 -0
- package/src/math/Vector4.js +13 -0
- package/src/nodes/Nodes.js +164 -0
- package/src/nodes/TSL.js +176 -0
- package/{examples/jsm → src}/nodes/accessors/AccessorsUtils.js +8 -8
- package/src/nodes/accessors/BatchNode.js +124 -0
- package/{examples/jsm/nodes/accessors/BitangentNode.js → src/nodes/accessors/Bitangent.js} +9 -9
- package/{examples/jsm → src}/nodes/accessors/BufferAttributeNode.js +41 -6
- package/{examples/jsm → src}/nodes/accessors/BufferNode.js +4 -4
- package/src/nodes/accessors/Camera.js +19 -0
- package/{examples/jsm → src}/nodes/accessors/ClippingNode.js +16 -14
- package/src/nodes/accessors/CubeTextureNode.js +76 -0
- package/src/nodes/accessors/InstanceNode.js +144 -0
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +21 -0
- package/{examples/jsm → src}/nodes/accessors/MaterialNode.js +66 -49
- package/src/nodes/accessors/MaterialProperties.js +3 -0
- package/{examples/jsm → src}/nodes/accessors/MaterialReferenceNode.js +6 -4
- package/src/nodes/accessors/ModelNode.js +37 -0
- package/{examples/jsm → src}/nodes/accessors/ModelViewProjectionNode.js +6 -7
- package/{examples/jsm → src}/nodes/accessors/MorphNode.js +35 -31
- package/src/nodes/accessors/Normal.js +62 -0
- package/{examples/jsm → src}/nodes/accessors/Object3DNode.js +11 -11
- package/src/nodes/accessors/PointUVNode.js +26 -0
- package/src/nodes/accessors/Position.js +10 -0
- package/src/nodes/accessors/ReferenceBaseNode.js +143 -0
- package/{examples/jsm → src}/nodes/accessors/ReferenceNode.js +14 -8
- package/src/nodes/accessors/ReflectVector.js +10 -0
- package/{examples/jsm → src}/nodes/accessors/RendererReferenceNode.js +6 -6
- package/{examples/jsm → src}/nodes/accessors/SceneNode.js +5 -6
- package/src/nodes/accessors/SkinningNode.js +187 -0
- package/{examples/jsm → src}/nodes/accessors/StorageBufferNode.js +54 -6
- package/{examples/jsm → src}/nodes/accessors/StorageTextureNode.js +16 -7
- package/src/nodes/accessors/Tangent.js +22 -0
- package/{examples/jsm → src}/nodes/accessors/Texture3DNode.js +11 -11
- package/{examples/jsm/nodes/accessors/TextureBicubicNode.js → src/nodes/accessors/TextureBicubic.js} +3 -32
- package/{examples/jsm → src}/nodes/accessors/TextureNode.js +69 -37
- package/{examples/jsm → src}/nodes/accessors/TextureSizeNode.js +4 -6
- package/{examples/jsm/nodes/accessors/UniformsNode.js → src/nodes/accessors/UniformArrayNode.js} +24 -9
- package/{examples/jsm → src}/nodes/accessors/UserDataNode.js +4 -4
- package/src/nodes/accessors/VelocityNode.js +83 -0
- package/{examples/jsm → src}/nodes/accessors/VertexColorNode.js +6 -5
- package/{examples/jsm → src}/nodes/code/CodeNode.js +5 -5
- package/{examples/jsm → src}/nodes/code/ExpressionNode.js +4 -4
- package/{examples/jsm → src}/nodes/code/FunctionCallNode.js +5 -5
- package/{examples/jsm → src}/nodes/code/FunctionNode.js +5 -23
- package/{examples/jsm → src}/nodes/code/ScriptableNode.js +18 -6
- package/{examples/jsm → src}/nodes/code/ScriptableValueNode.js +6 -7
- package/{examples/jsm → src}/nodes/core/AssignNode.js +5 -5
- package/{examples/jsm → src}/nodes/core/AttributeNode.js +22 -21
- package/{examples/jsm → src}/nodes/core/BypassNode.js +5 -5
- package/src/nodes/core/CacheNode.js +46 -0
- package/{examples/jsm → src}/nodes/core/ConstNode.js +2 -2
- package/{examples/jsm → src}/nodes/core/ContextNode.js +17 -11
- package/{examples/jsm → src}/nodes/core/IndexNode.js +17 -6
- package/{examples/jsm → src}/nodes/core/InputNode.js +2 -2
- package/{examples/jsm → src}/nodes/core/LightingModel.js +2 -2
- package/src/nodes/core/MRTNode.js +82 -0
- package/{examples/jsm → src}/nodes/core/Node.js +57 -31
- package/{examples/jsm → src}/nodes/core/NodeBuilder.js +216 -65
- package/src/nodes/core/NodeCache.js +36 -0
- package/{examples/jsm → src}/nodes/core/NodeFrame.js +42 -0
- package/{examples/jsm → src}/nodes/core/NodeFunction.js +2 -2
- package/{examples/jsm → src}/nodes/core/NodeUniform.js +1 -2
- package/{examples/jsm → src}/nodes/core/NodeUtils.js +7 -1
- package/{examples/jsm → src}/nodes/core/OutputStructNode.js +4 -4
- package/{examples/jsm → src}/nodes/core/ParameterNode.js +4 -4
- package/src/nodes/core/PropertyNode.js +84 -0
- package/{examples/jsm → src}/nodes/core/StackNode.js +26 -10
- package/{examples/jsm → src}/nodes/core/StructTypeNode.js +2 -2
- package/{examples/jsm → src}/nodes/core/TempNode.js +4 -4
- package/src/nodes/core/UniformGroupNode.js +55 -0
- package/{examples/jsm → src}/nodes/core/UniformNode.js +14 -5
- package/{examples/jsm → src}/nodes/core/VarNode.js +8 -12
- package/{examples/jsm → src}/nodes/core/VaryingNode.js +13 -5
- package/{examples/jsm → src}/nodes/display/AfterImageNode.js +27 -35
- package/src/nodes/display/AnaglyphPassNode.js +61 -0
- package/{examples/jsm → src}/nodes/display/AnamorphicNode.js +27 -30
- package/src/nodes/display/BleachBypass.js +26 -0
- package/src/nodes/display/BlendMode.js +54 -0
- package/src/nodes/display/BloomNode.js +335 -0
- package/{examples/jsm → src}/nodes/display/BumpMapNode.js +7 -12
- package/src/nodes/display/ColorAdjustment.js +46 -0
- package/src/nodes/display/ColorSpaceFunctions.js +38 -0
- package/src/nodes/display/ColorSpaceNode.js +85 -0
- package/src/nodes/display/DenoiseNode.js +201 -0
- package/src/nodes/display/DepthOfFieldNode.js +121 -0
- package/src/nodes/display/DotScreenNode.js +63 -0
- package/src/nodes/display/FXAANode.js +329 -0
- package/src/nodes/display/FilmNode.js +53 -0
- package/src/nodes/display/FrontFacingNode.js +41 -0
- package/src/nodes/display/GTAONode.js +328 -0
- package/{examples/jsm → src}/nodes/display/GaussianBlurNode.js +44 -24
- package/src/nodes/display/Lut3DNode.js +54 -0
- package/src/nodes/display/MotionBlur.js +25 -0
- package/{examples/jsm → src}/nodes/display/NormalMapNode.js +9 -11
- package/src/nodes/display/ParallaxBarrierPassNode.js +55 -0
- package/src/nodes/display/PassNode.js +367 -0
- package/src/nodes/display/PixelationPassNode.js +206 -0
- package/{examples/jsm → src}/nodes/display/PosterizeNode.js +4 -6
- package/src/nodes/display/RGBShiftNode.js +50 -0
- package/src/nodes/display/RenderOutputNode.js +56 -0
- package/src/nodes/display/SSAAPassNode.js +284 -0
- package/src/nodes/display/Sepia.js +17 -0
- package/src/nodes/display/SobelOperatorNode.js +123 -0
- package/src/nodes/display/StereoCompositePassNode.js +107 -0
- package/src/nodes/display/StereoPassNode.js +80 -0
- package/src/nodes/display/ToneMappingFunctions.js +190 -0
- package/src/nodes/display/ToneMappingNode.js +66 -0
- package/src/nodes/display/TransitionNode.js +77 -0
- package/src/nodes/display/ViewportDepthNode.js +121 -0
- package/src/nodes/display/ViewportDepthTextureNode.js +30 -0
- package/{examples/jsm → src}/nodes/display/ViewportNode.js +28 -26
- package/src/nodes/display/ViewportSharedTextureNode.js +36 -0
- package/{examples/jsm → src}/nodes/display/ViewportTextureNode.js +12 -12
- package/{examples/jsm → src}/nodes/fog/FogExp2Node.js +4 -6
- package/{examples/jsm → src}/nodes/fog/FogNode.js +5 -7
- package/{examples/jsm → src}/nodes/fog/FogRangeNode.js +4 -6
- package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_GGX.js +4 -4
- package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_Sheen.js +6 -6
- package/{examples/jsm → src}/nodes/functions/BSDF/DFGApprox.js +2 -2
- package/{examples/jsm → src}/nodes/functions/BSDF/D_GGX.js +2 -2
- package/{examples/jsm → src}/nodes/functions/BSDF/D_GGX_Anisotropic.js +3 -3
- package/{examples/jsm → src}/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/{examples/jsm → src}/nodes/functions/BSDF/F_Schlick.js +2 -2
- package/src/nodes/functions/BSDF/LTC.js +131 -0
- package/{examples/jsm → src}/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
- package/{examples/jsm → src}/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
- package/{examples/jsm → src}/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
- package/src/nodes/functions/BasicLightingModel.js +78 -0
- package/{examples/jsm → src}/nodes/functions/PhongLightingModel.js +10 -8
- package/{examples/jsm → src}/nodes/functions/PhysicalLightingModel.js +73 -31
- package/{examples/jsm → src}/nodes/functions/ShadowMaskModel.js +1 -1
- package/{examples/jsm → src}/nodes/functions/ToonLightingModel.js +6 -4
- package/src/nodes/functions/material/getGeometryRoughness.js +13 -0
- package/{examples/jsm → src}/nodes/functions/material/getRoughness.js +2 -2
- package/{examples/jsm → src}/nodes/geometry/RangeNode.js +23 -10
- package/{examples/jsm → src}/nodes/gpgpu/ComputeNode.js +5 -5
- package/src/nodes/lighting/AONode.js +24 -0
- package/{examples/jsm → src}/nodes/lighting/AmbientLightNode.js +2 -7
- package/src/nodes/lighting/AnalyticLightNode.js +354 -0
- package/src/nodes/lighting/BasicEnvironmentNode.js +27 -0
- package/src/nodes/lighting/BasicLightMapNode.js +29 -0
- package/{examples/jsm → src}/nodes/lighting/DirectionalLightNode.js +3 -9
- package/{examples/jsm → src}/nodes/lighting/EnvironmentNode.js +23 -21
- package/{examples/jsm → src}/nodes/lighting/HemisphereLightNode.js +4 -7
- package/{examples/jsm → src}/nodes/lighting/IESSpotLightNode.js +3 -8
- package/{examples/jsm → src}/nodes/lighting/IrradianceNode.js +2 -2
- package/{examples/jsm → src}/nodes/lighting/LightNode.js +5 -5
- package/src/nodes/lighting/LightProbeNode.js +76 -0
- package/{examples/jsm → src}/nodes/lighting/LightUtils.js +3 -3
- package/src/nodes/lighting/LightingContextNode.js +64 -0
- package/{examples/jsm → src}/nodes/lighting/LightingNode.js +4 -2
- package/src/nodes/lighting/LightsNode.js +231 -0
- package/{examples/jsm → src}/nodes/lighting/PointLightNode.js +4 -10
- package/src/nodes/lighting/RectAreaLightNode.js +93 -0
- package/{examples/jsm → src}/nodes/lighting/SpotLightNode.js +4 -10
- package/{examples/jsm → src}/nodes/materialx/MaterialXNodes.js +2 -2
- package/{examples/jsm → src}/nodes/materialx/lib/mx_hsv.js +43 -46
- package/{examples/jsm → src}/nodes/materialx/lib/mx_noise.js +500 -603
- package/{examples/jsm → src}/nodes/materialx/lib/mx_transform_color.js +3 -9
- package/{examples/jsm/nodes/math/CondNode.js → src/nodes/math/ConditionalNode.js} +31 -13
- package/src/nodes/math/Hash.js +13 -0
- package/src/nodes/math/MathNode.js +404 -0
- package/{examples/jsm → src}/nodes/math/MathUtils.js +0 -7
- package/{examples/jsm → src}/nodes/math/OperatorNode.js +100 -58
- package/{examples/jsm → src}/nodes/math/TriNoise3D.js +19 -29
- package/{examples/jsm → src}/nodes/parsers/GLSLNodeFunction.js +7 -7
- package/{examples/jsm → src}/nodes/pmrem/PMREMNode.js +60 -16
- package/{examples/jsm → src}/nodes/pmrem/PMREMUtils.js +46 -46
- package/src/nodes/procedural/Checker.js +14 -0
- package/src/nodes/tsl/TSLBase.js +30 -0
- package/{examples/jsm/nodes/shadernode/ShaderNode.js → src/nodes/tsl/TSLCore.js} +106 -96
- package/{examples/jsm → src}/nodes/utils/ArrayElementNode.js +2 -2
- package/{examples/jsm → src}/nodes/utils/ConvertNode.js +2 -2
- package/src/nodes/utils/CubeMapNode.js +157 -0
- package/src/nodes/utils/Discard.js +8 -0
- package/{examples/jsm → src}/nodes/utils/EquirectUVNode.js +5 -5
- package/src/nodes/utils/FlipNode.js +65 -0
- package/{examples/jsm → src}/nodes/utils/FunctionOverloadingNode.js +7 -5
- package/{examples/jsm → src}/nodes/utils/JoinNode.js +2 -2
- package/{examples/jsm → src}/nodes/utils/LoopNode.js +19 -12
- package/{examples/jsm → src}/nodes/utils/MatcapUVNode.js +6 -6
- package/{examples/jsm → src}/nodes/utils/MaxMipLevelNode.js +12 -6
- package/{examples/jsm → src}/nodes/utils/OscNode.js +7 -7
- package/src/nodes/utils/Packing.js +4 -0
- package/src/nodes/utils/RTTNode.js +130 -0
- package/{examples/jsm → src}/nodes/utils/ReflectorNode.js +17 -4
- package/{examples/jsm → src}/nodes/utils/RemapNode.js +7 -7
- package/{examples/jsm → src}/nodes/utils/RotateNode.js +4 -12
- package/{examples/jsm → src}/nodes/utils/SetNode.js +2 -2
- package/{examples/jsm → src}/nodes/utils/SplitNode.js +2 -2
- package/{examples/jsm → src}/nodes/utils/SpriteSheetUVNode.js +5 -5
- package/src/nodes/utils/SpriteUtils.js +47 -0
- package/{examples/jsm → src}/nodes/utils/StorageArrayElementNode.js +4 -6
- package/{examples/jsm → src}/nodes/utils/TimerNode.js +5 -5
- package/{examples/jsm → src}/nodes/utils/TriplanarTexturesNode.js +7 -9
- package/src/nodes/utils/UVUtils.js +19 -0
- package/src/nodes/utils/ViewportUtils.js +14 -0
- package/src/objects/BatchedMesh.js +169 -190
- package/src/objects/InstancedMesh.js +1 -1
- package/src/renderers/WebGLRenderer.js +60 -23
- package/{examples/jsm → src}/renderers/common/Attributes.js +2 -1
- package/{examples/jsm → src}/renderers/common/Backend.js +30 -27
- package/{examples/jsm → src}/renderers/common/Background.js +12 -4
- package/src/renderers/common/BindGroup.js +18 -0
- package/{examples/jsm → src}/renderers/common/Bindings.js +45 -32
- package/{examples/jsm → src}/renderers/common/ClippingContext.js +18 -7
- package/{examples/jsm → src}/renderers/common/Color4.js +1 -1
- package/{examples/jsm → src}/renderers/common/CubeRenderTarget.js +16 -4
- package/{examples/jsm → src}/renderers/common/Geometries.js +37 -5
- package/{examples/jsm → src}/renderers/common/Info.js +34 -6
- package/src/renderers/common/PostProcessing.js +90 -0
- package/{examples/jsm/objects → src/renderers/common}/QuadMesh.js +8 -3
- package/{examples/jsm → src}/renderers/common/RenderContext.js +25 -1
- package/{examples/jsm → src}/renderers/common/RenderContexts.js +1 -1
- package/{examples/jsm → src}/renderers/common/RenderList.js +1 -1
- package/{examples/jsm → src}/renderers/common/RenderObject.js +45 -12
- package/{examples/jsm → src}/renderers/common/Renderer.js +151 -73
- package/{examples/jsm → src}/renderers/common/SampledTexture.js +14 -5
- package/src/renderers/common/StandardRenderer.js +18 -0
- package/{examples/jsm → src}/renderers/common/StorageBufferAttribute.js +1 -1
- package/{examples/jsm → src}/renderers/common/StorageInstancedBufferAttribute.js +1 -1
- package/{examples/jsm → src}/renderers/common/StorageTexture.js +2 -1
- package/{examples/jsm → src}/renderers/common/Textures.js +14 -14
- package/{examples/jsm → src}/renderers/common/Uniform.js +9 -4
- package/{examples/jsm → src}/renderers/common/UniformsGroup.js +69 -31
- package/{examples/jsm → src}/renderers/common/extras/PMREMGenerator.js +25 -25
- package/src/renderers/common/nodes/NodeBuilderState.js +58 -0
- package/src/renderers/common/nodes/NodeLibrary.js +118 -0
- package/{examples/jsm → src}/renderers/common/nodes/NodeSampledTexture.js +8 -7
- package/{examples/jsm → src}/renderers/common/nodes/NodeSampler.js +2 -1
- package/{examples/jsm → src}/renderers/common/nodes/NodeStorageBuffer.js +5 -1
- package/{examples/jsm → src}/renderers/common/nodes/NodeUniform.js +3 -3
- package/{examples/jsm → src}/renderers/common/nodes/NodeUniformBuffer.js +2 -1
- package/{examples/jsm → src}/renderers/common/nodes/NodeUniformsGroup.js +2 -8
- package/{examples/jsm → src}/renderers/common/nodes/Nodes.js +69 -21
- package/src/renderers/common/nodes/StandardNodeLibrary.js +105 -0
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +16 -1
- package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +0 -9
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -10
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +45 -13
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +7 -4
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +3 -0
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +8 -0
- package/src/renderers/shaders/UniformsLib.js +3 -0
- package/src/renderers/webgl/WebGLAttributes.js +2 -2
- package/src/renderers/webgl/WebGLBufferRenderer.js +6 -19
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +6 -18
- package/src/renderers/webgl/WebGLLights.js +6 -0
- package/src/renderers/webgl/WebGLProgram.js +27 -1
- package/src/renderers/webgl/WebGLPrograms.js +1 -1
- package/src/renderers/webgl/WebGLProperties.js +7 -0
- package/src/renderers/webgl/WebGLTextures.js +75 -57
- package/src/renderers/webgl/WebGLUniforms.js +12 -2
- package/src/renderers/webgl/WebGLUniformsGroups.js +7 -7
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/WebGLBackend.js +242 -120
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/nodes/GLSLNodeBuilder.js +227 -44
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLAttributeUtils.js +2 -2
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLConstants.js +1 -0
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLExtensions.js +2 -0
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLState.js +22 -1
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLTextureUtils.js +62 -23
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLUtils.js +1 -1
- package/{examples/jsm → src}/renderers/webgpu/WebGPUBackend.js +242 -136
- package/{examples/jsm → src}/renderers/webgpu/WebGPURenderer.js +9 -9
- package/{examples/jsm → src}/renderers/webgpu/nodes/WGSLNodeBuilder.js +281 -107
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +159 -0
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUAttributeUtils.js +2 -1
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUBindingUtils.js +64 -33
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUConstants.js +4 -1
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUPipelineUtils.js +34 -36
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTextureUtils.js +76 -44
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUUtils.js +42 -4
- package/src/renderers/webxr/WebXRDepthSensing.js +6 -0
- package/src/renderers/webxr/WebXRManager.js +37 -24
- package/src/textures/CompressedArrayTexture.js +1 -1
- package/examples/jsm/loaders/LogLuvLoader.js +0 -606
- package/examples/jsm/nodes/Nodes.js +0 -202
- package/examples/jsm/nodes/accessors/BatchNode.js +0 -78
- package/examples/jsm/nodes/accessors/CameraNode.js +0 -12
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +0 -61
- package/examples/jsm/nodes/accessors/InstanceNode.js +0 -94
- package/examples/jsm/nodes/accessors/InstancedPointsMaterialNode.js +0 -21
- package/examples/jsm/nodes/accessors/ModelNode.js +0 -36
- package/examples/jsm/nodes/accessors/NormalNode.js +0 -14
- package/examples/jsm/nodes/accessors/PointUVNode.js +0 -26
- package/examples/jsm/nodes/accessors/PositionNode.js +0 -10
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +0 -6
- package/examples/jsm/nodes/accessors/SkinningNode.js +0 -124
- package/examples/jsm/nodes/accessors/TangentNode.js +0 -23
- package/examples/jsm/nodes/core/CacheNode.js +0 -49
- package/examples/jsm/nodes/core/NodeCache.js +0 -26
- package/examples/jsm/nodes/core/NodeKeywords.js +0 -80
- package/examples/jsm/nodes/core/PropertyNode.js +0 -83
- package/examples/jsm/nodes/core/UniformGroupNode.js +0 -36
- package/examples/jsm/nodes/display/BlendModeNode.js +0 -128
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +0 -99
- package/examples/jsm/nodes/display/ColorSpaceNode.js +0 -108
- package/examples/jsm/nodes/display/FrontFacingNode.js +0 -40
- package/examples/jsm/nodes/display/PassNode.js +0 -201
- package/examples/jsm/nodes/display/ToneMappingNode.js +0 -188
- package/examples/jsm/nodes/display/ViewportDepthNode.js +0 -97
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +0 -31
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +0 -37
- package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +0 -13
- package/examples/jsm/nodes/lighting/AONode.js +0 -27
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +0 -256
- package/examples/jsm/nodes/lighting/LightingContextNode.js +0 -66
- package/examples/jsm/nodes/lighting/LightsNode.js +0 -215
- package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +0 -28
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +0 -28
- package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +0 -34
- package/examples/jsm/nodes/materials/MeshMatcapNodeMaterial.js +0 -52
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +0 -38
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +0 -65
- package/examples/jsm/nodes/materials/MeshToonNodeMaterial.js +0 -34
- package/examples/jsm/nodes/materials/ShadowNodeMaterial.js +0 -34
- package/examples/jsm/nodes/math/HashNode.js +0 -34
- package/examples/jsm/nodes/math/MathNode.js +0 -391
- package/examples/jsm/nodes/procedural/CheckerNode.js +0 -42
- package/examples/jsm/nodes/utils/DiscardNode.js +0 -27
- package/examples/jsm/nodes/utils/PackingNode.js +0 -55
- package/examples/jsm/nodes/utils/RotateUVNode.js +0 -35
- package/examples/jsm/renderers/common/PostProcessing.js +0 -33
- package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +0 -44
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +0 -104
- /package/{examples/jsm/nodes/accessors/UVNode.js → src/nodes/accessors/UV.js} +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeAttribute.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeCode.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeFunctionInput.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeParser.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeVar.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeVarying.js +0 -0
- /package/{examples/jsm → src}/nodes/core/UniformGroup.js +0 -0
- /package/{examples/jsm → src}/nodes/core/constants.js +0 -0
- /package/{examples/jsm → src}/nodes/materialx/DISCLAIMER.md +0 -0
- /package/{examples/jsm → src}/nodes/parsers/GLSLNodeParser.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Animation.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Binding.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Buffer.js +0 -0
- /package/{examples/jsm → src}/renderers/common/BufferUtils.js +0 -0
- /package/{examples/jsm → src}/renderers/common/ChainMap.js +0 -0
- /package/{examples/jsm → src}/renderers/common/ComputePipeline.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Constants.js +0 -0
- /package/{examples/jsm → src}/renderers/common/DataMap.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Pipeline.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Pipelines.js +0 -0
- /package/{examples/jsm → src}/renderers/common/ProgrammableStage.js +0 -0
- /package/{examples/jsm → src}/renderers/common/RenderBundle.js +0 -0
- /package/{examples/jsm → src}/renderers/common/RenderBundles.js +0 -0
- /package/{examples/jsm → src}/renderers/common/RenderLists.js +0 -0
- /package/{examples/jsm → src}/renderers/common/RenderObjects.js +0 -0
- /package/{examples/jsm → src}/renderers/common/RenderPipeline.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Sampler.js +0 -0
- /package/{examples/jsm → src}/renderers/common/StorageBuffer.js +0 -0
- /package/{examples/jsm → src}/renderers/common/UniformBuffer.js +0 -0
- /package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/WebGLBufferRenderer.js +0 -0
- /package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLCapabilities.js +0 -0
- /package/{examples/jsm → src}/renderers/webgpu/nodes/WGSLNodeParser.js +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { LineSegments2 } from './LineSegments2.js';
|
|
2
|
+
import { LineGeometry } from '../LineGeometry.js';
|
|
3
|
+
|
|
4
|
+
import { Line2NodeMaterial } from 'three';
|
|
5
|
+
|
|
6
|
+
class Line2 extends LineSegments2 {
|
|
7
|
+
|
|
8
|
+
constructor( geometry = new LineGeometry(), material = new Line2NodeMaterial( { color: Math.random() * 0xffffff } ) ) {
|
|
9
|
+
|
|
10
|
+
super( geometry, material );
|
|
11
|
+
|
|
12
|
+
this.isLine2 = true;
|
|
13
|
+
|
|
14
|
+
this.type = 'Line2';
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { Line2 };
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Box3,
|
|
3
|
+
InstancedInterleavedBuffer,
|
|
4
|
+
InterleavedBufferAttribute,
|
|
5
|
+
Line3,
|
|
6
|
+
MathUtils,
|
|
7
|
+
Matrix4,
|
|
8
|
+
Mesh,
|
|
9
|
+
Sphere,
|
|
10
|
+
Vector3,
|
|
11
|
+
Vector4,
|
|
12
|
+
Line2NodeMaterial
|
|
13
|
+
} from 'three';
|
|
14
|
+
import { LineSegmentsGeometry } from '../../lines/LineSegmentsGeometry.js';
|
|
15
|
+
|
|
16
|
+
const _viewport = new Vector4();
|
|
17
|
+
|
|
18
|
+
const _start = new Vector3();
|
|
19
|
+
const _end = new Vector3();
|
|
20
|
+
|
|
21
|
+
const _start4 = new Vector4();
|
|
22
|
+
const _end4 = new Vector4();
|
|
23
|
+
|
|
24
|
+
const _ssOrigin = new Vector4();
|
|
25
|
+
const _ssOrigin3 = new Vector3();
|
|
26
|
+
const _mvMatrix = new Matrix4();
|
|
27
|
+
const _line = new Line3();
|
|
28
|
+
const _closestPoint = new Vector3();
|
|
29
|
+
|
|
30
|
+
const _box = new Box3();
|
|
31
|
+
const _sphere = new Sphere();
|
|
32
|
+
const _clipToWorldVector = new Vector4();
|
|
33
|
+
|
|
34
|
+
let _ray, _lineWidth;
|
|
35
|
+
|
|
36
|
+
// Returns the margin required to expand by in world space given the distance from the camera,
|
|
37
|
+
// line width, resolution, and camera projection
|
|
38
|
+
function getWorldSpaceHalfWidth( camera, distance, resolution ) {
|
|
39
|
+
|
|
40
|
+
// transform into clip space, adjust the x and y values by the pixel width offset, then
|
|
41
|
+
// transform back into world space to get world offset. Note clip space is [-1, 1] so full
|
|
42
|
+
// width does not need to be halved.
|
|
43
|
+
_clipToWorldVector.set( 0, 0, - distance, 1.0 ).applyMatrix4( camera.projectionMatrix );
|
|
44
|
+
_clipToWorldVector.multiplyScalar( 1.0 / _clipToWorldVector.w );
|
|
45
|
+
_clipToWorldVector.x = _lineWidth / resolution.width;
|
|
46
|
+
_clipToWorldVector.y = _lineWidth / resolution.height;
|
|
47
|
+
_clipToWorldVector.applyMatrix4( camera.projectionMatrixInverse );
|
|
48
|
+
_clipToWorldVector.multiplyScalar( 1.0 / _clipToWorldVector.w );
|
|
49
|
+
|
|
50
|
+
return Math.abs( Math.max( _clipToWorldVector.x, _clipToWorldVector.y ) );
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function raycastWorldUnits( lineSegments, intersects ) {
|
|
55
|
+
|
|
56
|
+
const matrixWorld = lineSegments.matrixWorld;
|
|
57
|
+
const geometry = lineSegments.geometry;
|
|
58
|
+
const instanceStart = geometry.attributes.instanceStart;
|
|
59
|
+
const instanceEnd = geometry.attributes.instanceEnd;
|
|
60
|
+
const segmentCount = Math.min( geometry.instanceCount, instanceStart.count );
|
|
61
|
+
|
|
62
|
+
for ( let i = 0, l = segmentCount; i < l; i ++ ) {
|
|
63
|
+
|
|
64
|
+
_line.start.fromBufferAttribute( instanceStart, i );
|
|
65
|
+
_line.end.fromBufferAttribute( instanceEnd, i );
|
|
66
|
+
|
|
67
|
+
_line.applyMatrix4( matrixWorld );
|
|
68
|
+
|
|
69
|
+
const pointOnLine = new Vector3();
|
|
70
|
+
const point = new Vector3();
|
|
71
|
+
|
|
72
|
+
_ray.distanceSqToSegment( _line.start, _line.end, point, pointOnLine );
|
|
73
|
+
const isInside = point.distanceTo( pointOnLine ) < _lineWidth * 0.5;
|
|
74
|
+
|
|
75
|
+
if ( isInside ) {
|
|
76
|
+
|
|
77
|
+
intersects.push( {
|
|
78
|
+
point,
|
|
79
|
+
pointOnLine,
|
|
80
|
+
distance: _ray.origin.distanceTo( point ),
|
|
81
|
+
object: lineSegments,
|
|
82
|
+
face: null,
|
|
83
|
+
faceIndex: i,
|
|
84
|
+
uv: null,
|
|
85
|
+
uv1: null,
|
|
86
|
+
} );
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function raycastScreenSpace( lineSegments, camera, intersects ) {
|
|
95
|
+
|
|
96
|
+
const projectionMatrix = camera.projectionMatrix;
|
|
97
|
+
const material = lineSegments.material;
|
|
98
|
+
const resolution = material.resolution;
|
|
99
|
+
const matrixWorld = lineSegments.matrixWorld;
|
|
100
|
+
|
|
101
|
+
const geometry = lineSegments.geometry;
|
|
102
|
+
const instanceStart = geometry.attributes.instanceStart;
|
|
103
|
+
const instanceEnd = geometry.attributes.instanceEnd;
|
|
104
|
+
const segmentCount = Math.min( geometry.instanceCount, instanceStart.count );
|
|
105
|
+
|
|
106
|
+
const near = - camera.near;
|
|
107
|
+
|
|
108
|
+
//
|
|
109
|
+
|
|
110
|
+
// pick a point 1 unit out along the ray to avoid the ray origin
|
|
111
|
+
// sitting at the camera origin which will cause "w" to be 0 when
|
|
112
|
+
// applying the projection matrix.
|
|
113
|
+
_ray.at( 1, _ssOrigin );
|
|
114
|
+
|
|
115
|
+
// ndc space [ - 1.0, 1.0 ]
|
|
116
|
+
_ssOrigin.w = 1;
|
|
117
|
+
_ssOrigin.applyMatrix4( camera.matrixWorldInverse );
|
|
118
|
+
_ssOrigin.applyMatrix4( projectionMatrix );
|
|
119
|
+
_ssOrigin.multiplyScalar( 1 / _ssOrigin.w );
|
|
120
|
+
|
|
121
|
+
// screen space
|
|
122
|
+
_ssOrigin.x *= resolution.x / 2;
|
|
123
|
+
_ssOrigin.y *= resolution.y / 2;
|
|
124
|
+
_ssOrigin.z = 0;
|
|
125
|
+
|
|
126
|
+
_ssOrigin3.copy( _ssOrigin );
|
|
127
|
+
|
|
128
|
+
_mvMatrix.multiplyMatrices( camera.matrixWorldInverse, matrixWorld );
|
|
129
|
+
|
|
130
|
+
for ( let i = 0, l = segmentCount; i < l; i ++ ) {
|
|
131
|
+
|
|
132
|
+
_start4.fromBufferAttribute( instanceStart, i );
|
|
133
|
+
_end4.fromBufferAttribute( instanceEnd, i );
|
|
134
|
+
|
|
135
|
+
_start4.w = 1;
|
|
136
|
+
_end4.w = 1;
|
|
137
|
+
|
|
138
|
+
// camera space
|
|
139
|
+
_start4.applyMatrix4( _mvMatrix );
|
|
140
|
+
_end4.applyMatrix4( _mvMatrix );
|
|
141
|
+
|
|
142
|
+
// skip the segment if it's entirely behind the camera
|
|
143
|
+
const isBehindCameraNear = _start4.z > near && _end4.z > near;
|
|
144
|
+
if ( isBehindCameraNear ) {
|
|
145
|
+
|
|
146
|
+
continue;
|
|
147
|
+
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// trim the segment if it extends behind camera near
|
|
151
|
+
if ( _start4.z > near ) {
|
|
152
|
+
|
|
153
|
+
const deltaDist = _start4.z - _end4.z;
|
|
154
|
+
const t = ( _start4.z - near ) / deltaDist;
|
|
155
|
+
_start4.lerp( _end4, t );
|
|
156
|
+
|
|
157
|
+
} else if ( _end4.z > near ) {
|
|
158
|
+
|
|
159
|
+
const deltaDist = _end4.z - _start4.z;
|
|
160
|
+
const t = ( _end4.z - near ) / deltaDist;
|
|
161
|
+
_end4.lerp( _start4, t );
|
|
162
|
+
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// clip space
|
|
166
|
+
_start4.applyMatrix4( projectionMatrix );
|
|
167
|
+
_end4.applyMatrix4( projectionMatrix );
|
|
168
|
+
|
|
169
|
+
// ndc space [ - 1.0, 1.0 ]
|
|
170
|
+
_start4.multiplyScalar( 1 / _start4.w );
|
|
171
|
+
_end4.multiplyScalar( 1 / _end4.w );
|
|
172
|
+
|
|
173
|
+
// screen space
|
|
174
|
+
_start4.x *= resolution.x / 2;
|
|
175
|
+
_start4.y *= resolution.y / 2;
|
|
176
|
+
|
|
177
|
+
_end4.x *= resolution.x / 2;
|
|
178
|
+
_end4.y *= resolution.y / 2;
|
|
179
|
+
|
|
180
|
+
// create 2d segment
|
|
181
|
+
_line.start.copy( _start4 );
|
|
182
|
+
_line.start.z = 0;
|
|
183
|
+
|
|
184
|
+
_line.end.copy( _end4 );
|
|
185
|
+
_line.end.z = 0;
|
|
186
|
+
|
|
187
|
+
// get closest point on ray to segment
|
|
188
|
+
const param = _line.closestPointToPointParameter( _ssOrigin3, true );
|
|
189
|
+
_line.at( param, _closestPoint );
|
|
190
|
+
|
|
191
|
+
// check if the intersection point is within clip space
|
|
192
|
+
const zPos = MathUtils.lerp( _start4.z, _end4.z, param );
|
|
193
|
+
const isInClipSpace = zPos >= - 1 && zPos <= 1;
|
|
194
|
+
|
|
195
|
+
const isInside = _ssOrigin3.distanceTo( _closestPoint ) < _lineWidth * 0.5;
|
|
196
|
+
|
|
197
|
+
if ( isInClipSpace && isInside ) {
|
|
198
|
+
|
|
199
|
+
_line.start.fromBufferAttribute( instanceStart, i );
|
|
200
|
+
_line.end.fromBufferAttribute( instanceEnd, i );
|
|
201
|
+
|
|
202
|
+
_line.start.applyMatrix4( matrixWorld );
|
|
203
|
+
_line.end.applyMatrix4( matrixWorld );
|
|
204
|
+
|
|
205
|
+
const pointOnLine = new Vector3();
|
|
206
|
+
const point = new Vector3();
|
|
207
|
+
|
|
208
|
+
_ray.distanceSqToSegment( _line.start, _line.end, point, pointOnLine );
|
|
209
|
+
|
|
210
|
+
intersects.push( {
|
|
211
|
+
point: point,
|
|
212
|
+
pointOnLine: pointOnLine,
|
|
213
|
+
distance: _ray.origin.distanceTo( point ),
|
|
214
|
+
object: lineSegments,
|
|
215
|
+
face: null,
|
|
216
|
+
faceIndex: i,
|
|
217
|
+
uv: null,
|
|
218
|
+
uv1: null,
|
|
219
|
+
} );
|
|
220
|
+
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
class LineSegments2 extends Mesh {
|
|
228
|
+
|
|
229
|
+
constructor( geometry = new LineSegmentsGeometry(), material = new Line2NodeMaterial( { color: Math.random() * 0xffffff } ) ) {
|
|
230
|
+
|
|
231
|
+
super( geometry, material );
|
|
232
|
+
|
|
233
|
+
this.isLineSegments2 = true;
|
|
234
|
+
|
|
235
|
+
this.type = 'LineSegments2';
|
|
236
|
+
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// for backwards-compatibility, but could be a method of LineSegmentsGeometry...
|
|
240
|
+
|
|
241
|
+
computeLineDistances() {
|
|
242
|
+
|
|
243
|
+
const geometry = this.geometry;
|
|
244
|
+
|
|
245
|
+
const instanceStart = geometry.attributes.instanceStart;
|
|
246
|
+
const instanceEnd = geometry.attributes.instanceEnd;
|
|
247
|
+
const lineDistances = new Float32Array( 2 * instanceStart.count );
|
|
248
|
+
|
|
249
|
+
for ( let i = 0, j = 0, l = instanceStart.count; i < l; i ++, j += 2 ) {
|
|
250
|
+
|
|
251
|
+
_start.fromBufferAttribute( instanceStart, i );
|
|
252
|
+
_end.fromBufferAttribute( instanceEnd, i );
|
|
253
|
+
|
|
254
|
+
lineDistances[ j ] = ( j === 0 ) ? 0 : lineDistances[ j - 1 ];
|
|
255
|
+
lineDistances[ j + 1 ] = lineDistances[ j ] + _start.distanceTo( _end );
|
|
256
|
+
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const instanceDistanceBuffer = new InstancedInterleavedBuffer( lineDistances, 2, 1 ); // d0, d1
|
|
260
|
+
|
|
261
|
+
geometry.setAttribute( 'instanceDistanceStart', new InterleavedBufferAttribute( instanceDistanceBuffer, 1, 0 ) ); // d0
|
|
262
|
+
geometry.setAttribute( 'instanceDistanceEnd', new InterleavedBufferAttribute( instanceDistanceBuffer, 1, 1 ) ); // d1
|
|
263
|
+
|
|
264
|
+
return this;
|
|
265
|
+
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
raycast( raycaster, intersects ) {
|
|
269
|
+
|
|
270
|
+
const worldUnits = this.material.worldUnits;
|
|
271
|
+
const camera = raycaster.camera;
|
|
272
|
+
|
|
273
|
+
if ( camera === null && ! worldUnits ) {
|
|
274
|
+
|
|
275
|
+
console.error( 'LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.' );
|
|
276
|
+
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const threshold = ( raycaster.params.Line2 !== undefined ) ? raycaster.params.Line2.threshold || 0 : 0;
|
|
280
|
+
|
|
281
|
+
_ray = raycaster.ray;
|
|
282
|
+
|
|
283
|
+
const matrixWorld = this.matrixWorld;
|
|
284
|
+
const geometry = this.geometry;
|
|
285
|
+
const material = this.material;
|
|
286
|
+
|
|
287
|
+
_lineWidth = material.linewidth + threshold;
|
|
288
|
+
|
|
289
|
+
// check if we intersect the sphere bounds
|
|
290
|
+
if ( geometry.boundingSphere === null ) {
|
|
291
|
+
|
|
292
|
+
geometry.computeBoundingSphere();
|
|
293
|
+
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
_sphere.copy( geometry.boundingSphere ).applyMatrix4( matrixWorld );
|
|
297
|
+
|
|
298
|
+
// increase the sphere bounds by the worst case line screen space width
|
|
299
|
+
let sphereMargin;
|
|
300
|
+
if ( worldUnits ) {
|
|
301
|
+
|
|
302
|
+
sphereMargin = _lineWidth * 0.5;
|
|
303
|
+
|
|
304
|
+
} else {
|
|
305
|
+
|
|
306
|
+
const distanceToSphere = Math.max( camera.near, _sphere.distanceToPoint( _ray.origin ) );
|
|
307
|
+
sphereMargin = getWorldSpaceHalfWidth( camera, distanceToSphere, material.resolution );
|
|
308
|
+
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
_sphere.radius += sphereMargin;
|
|
312
|
+
|
|
313
|
+
if ( _ray.intersectsSphere( _sphere ) === false ) {
|
|
314
|
+
|
|
315
|
+
return;
|
|
316
|
+
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// check if we intersect the box bounds
|
|
320
|
+
if ( geometry.boundingBox === null ) {
|
|
321
|
+
|
|
322
|
+
geometry.computeBoundingBox();
|
|
323
|
+
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
_box.copy( geometry.boundingBox ).applyMatrix4( matrixWorld );
|
|
327
|
+
|
|
328
|
+
// increase the box bounds by the worst case line width
|
|
329
|
+
let boxMargin;
|
|
330
|
+
if ( worldUnits ) {
|
|
331
|
+
|
|
332
|
+
boxMargin = _lineWidth * 0.5;
|
|
333
|
+
|
|
334
|
+
} else {
|
|
335
|
+
|
|
336
|
+
const distanceToBox = Math.max( camera.near, _box.distanceToPoint( _ray.origin ) );
|
|
337
|
+
boxMargin = getWorldSpaceHalfWidth( camera, distanceToBox, material.resolution );
|
|
338
|
+
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
_box.expandByScalar( boxMargin );
|
|
342
|
+
|
|
343
|
+
if ( _ray.intersectsBox( _box ) === false ) {
|
|
344
|
+
|
|
345
|
+
return;
|
|
346
|
+
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
if ( worldUnits ) {
|
|
350
|
+
|
|
351
|
+
raycastWorldUnits( this, intersects );
|
|
352
|
+
|
|
353
|
+
} else {
|
|
354
|
+
|
|
355
|
+
raycastScreenSpace( this, camera, intersects );
|
|
356
|
+
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
onBeforeRender( renderer ) {
|
|
362
|
+
|
|
363
|
+
const uniforms = this.material.uniforms;
|
|
364
|
+
|
|
365
|
+
if ( uniforms && uniforms.resolution ) {
|
|
366
|
+
|
|
367
|
+
renderer.getViewport( _viewport );
|
|
368
|
+
this.material.uniforms.resolution.value.set( _viewport.z, _viewport.w );
|
|
369
|
+
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export { LineSegments2 };
|
|
@@ -407,72 +407,50 @@ class FBXTreeParser {
|
|
|
407
407
|
// load a texture specified as a blob or data URI, or via an external URL using TextureLoader
|
|
408
408
|
loadTexture( textureNode, images ) {
|
|
409
409
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
const currentPath = this.textureLoader.path;
|
|
413
|
-
|
|
414
|
-
const children = connections.get( textureNode.id ).children;
|
|
410
|
+
const nonNativeExtensions = new Set( [ 'tga', 'tif', 'tiff', 'exr', 'dds', 'hdr', 'ktx2' ] );
|
|
415
411
|
|
|
416
|
-
|
|
412
|
+
const extension = textureNode.FileName.split( '.' ).pop().toLowerCase();
|
|
417
413
|
|
|
418
|
-
|
|
414
|
+
const loader = nonNativeExtensions.has( extension ) ? this.manager.getHandler( `.${extension}` ) : this.textureLoader;
|
|
419
415
|
|
|
420
|
-
|
|
416
|
+
if ( ! loader ) {
|
|
421
417
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
418
|
+
console.warn(
|
|
419
|
+
`FBXLoader: ${extension.toUpperCase()} loader not found, creating placeholder texture for`,
|
|
420
|
+
textureNode.RelativeFilename
|
|
421
|
+
);
|
|
422
|
+
return new Texture();
|
|
425
423
|
|
|
426
424
|
}
|
|
427
425
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
const extension = textureNode.FileName.slice( - 3 ).toLowerCase();
|
|
431
|
-
|
|
432
|
-
if ( extension === 'tga' ) {
|
|
433
|
-
|
|
434
|
-
const loader = this.manager.getHandler( '.tga' );
|
|
426
|
+
const loaderPath = loader.path;
|
|
435
427
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
console.warn( 'FBXLoader: TGA loader not found, creating placeholder texture for', textureNode.RelativeFilename );
|
|
439
|
-
texture = new Texture();
|
|
440
|
-
|
|
441
|
-
} else {
|
|
428
|
+
if ( ! loaderPath ) {
|
|
442
429
|
|
|
443
|
-
|
|
444
|
-
texture = loader.load( fileName );
|
|
430
|
+
loader.setPath( this.textureLoader.path );
|
|
445
431
|
|
|
446
|
-
|
|
432
|
+
}
|
|
447
433
|
|
|
448
|
-
|
|
434
|
+
const children = connections.get( textureNode.id ).children;
|
|
449
435
|
|
|
450
|
-
|
|
436
|
+
let fileName;
|
|
451
437
|
|
|
452
|
-
|
|
438
|
+
if ( children !== undefined && children.length > 0 && images[ children[ 0 ].ID ] !== undefined ) {
|
|
453
439
|
|
|
454
|
-
|
|
455
|
-
texture = new Texture();
|
|
440
|
+
fileName = images[ children[ 0 ].ID ];
|
|
456
441
|
|
|
457
|
-
|
|
442
|
+
if ( fileName.indexOf( 'blob:' ) === 0 || fileName.indexOf( 'data:' ) === 0 ) {
|
|
458
443
|
|
|
459
|
-
loader.setPath(
|
|
460
|
-
texture = loader.load( fileName );
|
|
444
|
+
loader.setPath( undefined );
|
|
461
445
|
|
|
462
446
|
}
|
|
463
447
|
|
|
464
|
-
} else if ( extension === 'psd' ) {
|
|
465
|
-
|
|
466
|
-
console.warn( 'FBXLoader: PSD textures are not supported, creating placeholder texture for', textureNode.RelativeFilename );
|
|
467
|
-
texture = new Texture();
|
|
468
|
-
|
|
469
|
-
} else {
|
|
470
|
-
|
|
471
|
-
texture = this.textureLoader.load( fileName );
|
|
472
|
-
|
|
473
448
|
}
|
|
474
449
|
|
|
475
|
-
|
|
450
|
+
const texture = loader.load( fileName );
|
|
451
|
+
|
|
452
|
+
// revert to initial path
|
|
453
|
+
loader.setPath( loaderPath );
|
|
476
454
|
|
|
477
455
|
return texture;
|
|
478
456
|
|
|
@@ -2580,18 +2580,24 @@ class GLTFParser {
|
|
|
2580
2580
|
// expensive work of uploading a texture to the GPU off the main thread.
|
|
2581
2581
|
|
|
2582
2582
|
let isSafari = false;
|
|
2583
|
+
let safariVersion = - 1;
|
|
2583
2584
|
let isFirefox = false;
|
|
2584
2585
|
let firefoxVersion = - 1;
|
|
2585
2586
|
|
|
2586
2587
|
if ( typeof navigator !== 'undefined' ) {
|
|
2587
2588
|
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2589
|
+
const userAgent = navigator.userAgent;
|
|
2590
|
+
|
|
2591
|
+
isSafari = /^((?!chrome|android).)*safari/i.test( userAgent ) === true;
|
|
2592
|
+
const safariMatch = userAgent.match( /Version\/(\d+)/ );
|
|
2593
|
+
safariVersion = isSafari && safariMatch ? parseInt( safariMatch[ 1 ], 10 ) : - 1;
|
|
2594
|
+
|
|
2595
|
+
isFirefox = userAgent.indexOf( 'Firefox' ) > - 1;
|
|
2596
|
+
firefoxVersion = isFirefox ? userAgent.match( /Firefox\/([0-9]+)\./ )[ 1 ] : - 1;
|
|
2591
2597
|
|
|
2592
2598
|
}
|
|
2593
2599
|
|
|
2594
|
-
if ( typeof createImageBitmap === 'undefined' || isSafari || ( isFirefox && firefoxVersion < 98 ) ) {
|
|
2600
|
+
if ( typeof createImageBitmap === 'undefined' || ( isSafari && safariVersion < 17 ) || ( isFirefox && firefoxVersion < 98 ) ) {
|
|
2595
2601
|
|
|
2596
2602
|
this.textureLoader = new TextureLoader( this.options.manager );
|
|
2597
2603
|
|
|
@@ -251,22 +251,34 @@ class KTX2Loader extends Loader {
|
|
|
251
251
|
|
|
252
252
|
loader.load( url, ( buffer ) => {
|
|
253
253
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
254
|
+
this.parse( buffer, onLoad, onError);
|
|
255
|
+
|
|
256
|
+
}, onProgress, onError );
|
|
257
|
+
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
parse( buffer, onLoad, onError ) {
|
|
261
|
+
|
|
262
|
+
if ( this.workerConfig === null ) {
|
|
263
|
+
|
|
264
|
+
throw new Error( 'THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.' );
|
|
265
|
+
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Check for an existing task using this buffer. A transferred buffer cannot be transferred
|
|
269
|
+
// again from this thread.
|
|
270
|
+
if ( _taskCache.has( buffer ) ) {
|
|
257
271
|
|
|
258
272
|
const cachedTask = _taskCache.get( buffer );
|
|
259
273
|
|
|
260
274
|
return cachedTask.promise.then( onLoad ).catch( onError );
|
|
261
275
|
|
|
262
|
-
|
|
276
|
+
}
|
|
263
277
|
|
|
264
|
-
|
|
278
|
+
this._createTexture( buffer )
|
|
265
279
|
.then( ( texture ) => onLoad ? onLoad( texture ) : null )
|
|
266
280
|
.catch( onError );
|
|
267
281
|
|
|
268
|
-
}, onProgress, onError );
|
|
269
|
-
|
|
270
282
|
}
|
|
271
283
|
|
|
272
284
|
_createTextureFrom( transcodeResult, container ) {
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
FileLoader,
|
|
3
|
-
Loader,
|
|
4
|
-
TextureLoader,
|
|
5
|
-
RepeatWrapping
|
|
6
|
-
} from 'three';
|
|
1
|
+
import { FileLoader, Loader, TextureLoader, MeshBasicNodeMaterial, MeshPhysicalNodeMaterial, RepeatWrapping } from 'three';
|
|
7
2
|
|
|
8
3
|
import {
|
|
9
|
-
MeshBasicNodeMaterial, MeshPhysicalNodeMaterial,
|
|
10
4
|
float, bool, int, vec2, vec3, vec4, color, texture,
|
|
11
5
|
positionLocal, positionWorld, uv, vertexColor,
|
|
12
6
|
normalLocal, normalWorld, tangentLocal, tangentWorld,
|
|
@@ -19,8 +13,9 @@ import {
|
|
|
19
13
|
mx_transform_uv,
|
|
20
14
|
mx_safepower, mx_contrast,
|
|
21
15
|
mx_srgb_texture_to_lin_rec709,
|
|
22
|
-
saturation
|
|
23
|
-
|
|
16
|
+
saturation,
|
|
17
|
+
timerLocal, frameId
|
|
18
|
+
} from 'three/tsl';
|
|
24
19
|
|
|
25
20
|
const colorSpaceLib = {
|
|
26
21
|
mx_srgb_texture_to_lin_rec709
|
|
@@ -28,7 +23,7 @@ const colorSpaceLib = {
|
|
|
28
23
|
|
|
29
24
|
class MXElement {
|
|
30
25
|
|
|
31
|
-
constructor( name, nodeFunc, params =
|
|
26
|
+
constructor( name, nodeFunc, params = [] ) {
|
|
32
27
|
|
|
33
28
|
this.name = name;
|
|
34
29
|
this.nodeFunc = nodeFunc;
|
|
@@ -47,6 +42,8 @@ const mx_divide = ( in1, in2 = float( 1 ) ) => div( in1, in2 );
|
|
|
47
42
|
const mx_modulo = ( in1, in2 = float( 1 ) ) => mod( in1, in2 );
|
|
48
43
|
const mx_power = ( in1, in2 = float( 1 ) ) => pow( in1, in2 );
|
|
49
44
|
const mx_atan2 = ( in1 = float( 0 ), in2 = float( 1 ) ) => atan2( in1, in2 );
|
|
45
|
+
const mx_timer = () => timerLocal();
|
|
46
|
+
const mx_frame = () => frameId;
|
|
50
47
|
|
|
51
48
|
const MXElements = [
|
|
52
49
|
|
|
@@ -135,6 +132,9 @@ const MXElements = [
|
|
|
135
132
|
//new MtlXElement( 'separate3', ... ),
|
|
136
133
|
//new MtlXElement( 'separate4', ... )
|
|
137
134
|
|
|
135
|
+
new MXElement( 'time', mx_timer ),
|
|
136
|
+
new MXElement( 'frame', mx_frame )
|
|
137
|
+
|
|
138
138
|
];
|
|
139
139
|
|
|
140
140
|
const MtlXLibrary = {};
|
|
@@ -127,15 +127,15 @@ class PCDLoader extends Loader {
|
|
|
127
127
|
|
|
128
128
|
// parse
|
|
129
129
|
|
|
130
|
-
PCDheader.version =
|
|
131
|
-
PCDheader.fields =
|
|
132
|
-
PCDheader.size =
|
|
133
|
-
PCDheader.type =
|
|
134
|
-
PCDheader.count =
|
|
135
|
-
PCDheader.width =
|
|
136
|
-
PCDheader.height =
|
|
137
|
-
PCDheader.viewpoint =
|
|
138
|
-
PCDheader.points =
|
|
130
|
+
PCDheader.version = /^VERSION (.*)/im.exec( PCDheader.str );
|
|
131
|
+
PCDheader.fields = /^FIELDS (.*)/im.exec( PCDheader.str );
|
|
132
|
+
PCDheader.size = /^SIZE (.*)/im.exec( PCDheader.str );
|
|
133
|
+
PCDheader.type = /^TYPE (.*)/im.exec( PCDheader.str );
|
|
134
|
+
PCDheader.count = /^COUNT (.*)/im.exec( PCDheader.str );
|
|
135
|
+
PCDheader.width = /^WIDTH (.*)/im.exec( PCDheader.str );
|
|
136
|
+
PCDheader.height = /^HEIGHT (.*)/im.exec( PCDheader.str );
|
|
137
|
+
PCDheader.viewpoint = /^VIEWPOINT (.*)/im.exec( PCDheader.str );
|
|
138
|
+
PCDheader.points = /^POINTS (.*)/im.exec( PCDheader.str );
|
|
139
139
|
|
|
140
140
|
// evaluate
|
|
141
141
|
|