@needle-tools/three 0.162.12 → 0.169.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 +3 -3
- package/build/three.cjs +29789 -1941
- package/build/three.module.js +29095 -1933
- package/build/three.module.min.js +2 -2
- package/build/three.webgpu.js +80003 -0
- package/build/three.webgpu.min.js +6 -0
- package/build/three.webgpu.nodes.js +79951 -0
- package/build/three.webgpu.nodes.min.js +6 -0
- package/examples/jsm/Addons.js +2 -5
- package/examples/jsm/animation/AnimationClipCreator.js +1 -1
- package/examples/jsm/animation/CCDIKSolver.js +4 -2
- 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 +790 -797
- package/examples/jsm/controls/PointerLockControls.js +24 -15
- package/examples/jsm/controls/TrackballControls.js +469 -448
- package/examples/jsm/controls/TransformControls.js +98 -63
- 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 +2 -6
- package/examples/jsm/exporters/DRACOExporter.js +4 -2
- package/examples/jsm/exporters/EXRExporter.js +19 -11
- package/examples/jsm/exporters/GLTFExporter.js +77 -8
- package/examples/jsm/exporters/KTX2Exporter.js +21 -13
- package/examples/jsm/exporters/OBJExporter.js +5 -1
- package/examples/jsm/exporters/PLYExporter.js +9 -7
- package/examples/jsm/exporters/USDZExporter.js +55 -11
- package/examples/jsm/geometries/DecalGeometry.js +4 -1
- package/examples/jsm/geometries/InstancedPointsGeometry.js +1 -1
- package/examples/jsm/geometries/TeapotGeometry.js +1 -1
- package/examples/jsm/geometries/TextGeometry.js +10 -2
- package/examples/jsm/helpers/LightProbeHelper.js +43 -44
- package/examples/jsm/helpers/LightProbeHelperGPU.js +65 -0
- package/examples/jsm/helpers/ViewHelper.js +75 -61
- package/examples/jsm/interactive/HTMLMesh.js +7 -9
- package/examples/jsm/libs/basis/basis_transcoder.js +8 -10
- package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
- package/examples/jsm/libs/draco/README.md +2 -2
- package/examples/jsm/libs/fflate.module.js +694 -496
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/lights/LightProbeGenerator.js +24 -10
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +91 -0
- package/examples/jsm/lights/RectAreaLightUniformsLib.js +8 -63
- package/examples/jsm/lines/LineMaterial.js +1 -17
- package/examples/jsm/lines/LineSegments2.js +15 -0
- package/examples/jsm/lines/Wireframe.js +16 -1
- package/examples/jsm/lines/webgpu/Line2.js +20 -0
- package/examples/jsm/lines/webgpu/LineSegments2.js +376 -0
- package/examples/jsm/loaders/3MFLoader.js +2 -0
- package/examples/jsm/loaders/ColladaLoader.js +9 -6
- package/examples/jsm/loaders/DRACOLoader.js +4 -2
- package/examples/jsm/loaders/EXRLoader.js +351 -97
- package/examples/jsm/loaders/FBXLoader.js +77 -78
- package/examples/jsm/loaders/GLTFLoader.js +76 -14
- package/examples/jsm/loaders/KTX2Loader.js +30 -22
- package/examples/jsm/loaders/LDrawLoader.js +3 -2
- package/examples/jsm/loaders/LUT3dlLoader.js +0 -15
- package/examples/jsm/loaders/LUTCubeLoader.js +0 -14
- package/examples/jsm/loaders/LUTImageLoader.js +0 -14
- package/examples/jsm/loaders/MMDLoader.js +31 -12
- package/examples/jsm/loaders/MTLLoader.js +4 -3
- package/examples/jsm/loaders/MaterialXLoader.js +45 -21
- package/examples/jsm/loaders/OBJLoader.js +5 -3
- package/examples/jsm/loaders/PCDLoader.js +14 -13
- package/examples/jsm/loaders/PDBLoader.js +3 -2
- package/examples/jsm/loaders/PLYLoader.js +8 -5
- package/examples/jsm/loaders/RGBMLoader.js +16 -0
- package/examples/jsm/loaders/STLLoader.js +3 -2
- package/examples/jsm/loaders/USDZLoader.js +124 -76
- package/examples/jsm/loaders/UltraHDRLoader.js +583 -0
- package/examples/jsm/loaders/VRMLLoader.js +11 -11
- package/examples/jsm/loaders/VTKLoader.js +80 -6
- package/examples/jsm/loaders/XYZLoader.js +3 -2
- package/examples/jsm/loaders/lwo/IFFParser.js +8 -5
- package/examples/jsm/materials/MeshGouraudMaterial.js +7 -1
- package/examples/jsm/math/Octree.js +26 -20
- package/examples/jsm/misc/GPUComputationRenderer.js +9 -25
- package/examples/jsm/misc/Timer.js +1 -1
- package/examples/jsm/modifiers/CurveModifier.js +11 -9
- package/examples/jsm/modifiers/CurveModifierGPU.js +233 -0
- package/examples/jsm/modifiers/SimplifyModifier.js +2 -1
- package/examples/jsm/objects/InstancedPoints.js +2 -2
- package/examples/jsm/objects/Lensflare.js +2 -2
- package/examples/jsm/objects/LensflareMesh.js +322 -0
- package/examples/jsm/objects/SkyMesh.js +187 -0
- package/examples/jsm/objects/Water2Mesh.js +158 -0
- package/examples/jsm/objects/WaterMesh.js +101 -0
- package/examples/jsm/physics/JoltPhysics.js +281 -0
- package/examples/jsm/physics/RapierPhysics.js +25 -5
- package/examples/jsm/postprocessing/GlitchPass.js +0 -3
- package/examples/jsm/postprocessing/LUTPass.js +5 -71
- package/examples/jsm/postprocessing/OutlinePass.js +31 -46
- package/examples/jsm/postprocessing/RenderPass.js +1 -1
- package/examples/jsm/postprocessing/RenderTransitionPass.js +168 -0
- package/examples/jsm/postprocessing/SAOPass.js +0 -1
- package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
- package/examples/jsm/postprocessing/SSAOPass.js +6 -12
- package/examples/jsm/postprocessing/UnrealBloomPass.js +4 -4
- package/examples/jsm/renderers/CSS2DRenderer.js +25 -5
- package/examples/jsm/renderers/CSS3DRenderer.js +24 -3
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +1 -3
- package/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +1 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +7 -4
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodes.js +19 -5
- 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 +47 -5
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -2
- package/examples/jsm/transpiler/TSLEncoder.js +24 -22
- package/examples/jsm/utils/BufferGeometryUtils.js +18 -16
- package/examples/jsm/utils/GeometryCompressionUtils.js +37 -122
- package/examples/jsm/utils/SceneUtils.js +60 -1
- package/examples/jsm/utils/ShadowMapViewer.js +3 -8
- package/examples/jsm/utils/ShadowMapViewerGPU.js +201 -0
- package/examples/jsm/utils/SkeletonUtils.js +84 -66
- package/examples/jsm/utils/SortUtils.js +8 -5
- package/examples/jsm/utils/TextureUtils.js +3 -2
- package/examples/jsm/utils/TextureUtilsGPU.js +63 -0
- package/examples/jsm/webxr/OculusHandModel.js +3 -2
- package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
- package/examples/jsm/webxr/XRHandModelFactory.js +4 -2
- package/package.json +11 -8
- package/src/Three.WebGPU.Nodes.js +200 -0
- package/src/Three.WebGPU.js +201 -0
- package/src/Three.js +23 -1
- package/src/animation/AnimationClip.js +1 -1
- package/src/animation/tracks/BooleanKeyframeTrack.js +10 -1
- package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -2
- package/src/animation/tracks/StringKeyframeTrack.js +10 -1
- package/src/audio/Audio.js +2 -2
- package/src/constants.js +6 -7
- package/src/core/BufferAttribute.js +0 -9
- package/src/core/Clock.js +1 -1
- package/src/core/InterleavedBuffer.js +0 -9
- package/src/core/Object3D.js +34 -29
- package/src/core/Raycaster.js +6 -2
- package/src/core/RenderTarget.js +8 -0
- package/src/extras/Controls.js +32 -0
- package/src/extras/PMREMGenerator.js +12 -11
- package/src/extras/TextureUtils.js +210 -0
- package/src/geometries/CylinderGeometry.js +11 -4
- 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/FileLoader.js +5 -1
- package/src/loaders/LoaderUtils.js +3 -1
- package/src/loaders/MaterialLoader.js +8 -1
- package/src/loaders/ObjectLoader.js +36 -2
- package/{examples/jsm/nodes/loaders → src/loaders/nodes}/NodeLoader.js +27 -5
- package/{examples/jsm/nodes/loaders → src/loaders/nodes}/NodeMaterialLoader.js +22 -18
- package/{examples/jsm/nodes/loaders → src/loaders/nodes}/NodeObjectLoader.js +21 -1
- package/src/materials/Material.js +4 -0
- package/src/materials/MeshPhysicalMaterial.js +20 -0
- package/src/materials/ShaderMaterial.js +0 -4
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +156 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/Line2NodeMaterial.js +69 -68
- package/src/materials/nodes/LineBasicNodeMaterial.js +31 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/LineDashedNodeMaterial.js +15 -12
- package/src/materials/nodes/MeshBasicNodeMaterial.js +77 -0
- package/src/materials/nodes/MeshLambertNodeMaterial.js +47 -0
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +57 -0
- package/src/materials/nodes/MeshNormalNodeMaterial.js +44 -0
- package/src/materials/nodes/MeshPhongNodeMaterial.js +78 -0
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +248 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/MeshSSSNodeMaterial.js +10 -7
- package/src/materials/nodes/MeshStandardNodeMaterial.js +108 -0
- package/src/materials/nodes/MeshToonNodeMaterial.js +38 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/NodeMaterial.js +198 -157
- package/{examples/jsm/nodes/materials/Materials.js → src/materials/nodes/NodeMaterials.js} +7 -1
- package/{examples/jsm/nodes/materials → src/materials/nodes}/PointsNodeMaterial.js +10 -7
- package/src/materials/nodes/ShadowNodeMaterial.js +38 -0
- package/src/materials/nodes/SpriteNodeMaterial.js +123 -0
- package/src/materials/nodes/VolumeNodeMaterial.js +108 -0
- package/src/materials/nodes/manager/NodeMaterialObserver.js +302 -0
- 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/Spherical.js +4 -5
- package/src/math/Triangle.js +24 -0
- package/src/math/Vector4.js +13 -0
- package/src/nodes/Nodes.js +164 -0
- package/src/nodes/TSL.js +179 -0
- package/src/nodes/accessors/AccessorsUtils.js +25 -0
- package/src/nodes/accessors/BatchNode.js +128 -0
- package/src/nodes/accessors/Bitangent.js +13 -0
- package/{examples/jsm → src}/nodes/accessors/BufferAttributeNode.js +44 -6
- package/{examples/jsm → src}/nodes/accessors/BufferNode.js +13 -4
- package/src/nodes/accessors/Camera.js +13 -0
- package/{examples/jsm → src}/nodes/accessors/ClippingNode.js +22 -15
- package/src/nodes/accessors/CubeTextureNode.js +79 -0
- package/src/nodes/accessors/InstanceNode.js +144 -0
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +24 -0
- package/src/nodes/accessors/Lights.js +51 -0
- package/src/nodes/accessors/MaterialNode.js +441 -0
- package/src/nodes/accessors/MaterialProperties.js +3 -0
- package/{examples/jsm → src}/nodes/accessors/MaterialReferenceNode.js +10 -5
- package/src/nodes/accessors/ModelNode.js +72 -0
- package/src/nodes/accessors/ModelViewProjectionNode.js +42 -0
- package/{examples/jsm → src}/nodes/accessors/MorphNode.js +51 -33
- package/src/nodes/accessors/Normal.js +88 -0
- package/{examples/jsm → src}/nodes/accessors/Object3DNode.js +18 -34
- package/src/nodes/accessors/PointUVNode.js +30 -0
- package/src/nodes/accessors/Position.js +10 -0
- package/src/nodes/accessors/ReferenceBaseNode.js +171 -0
- package/{examples/jsm → src}/nodes/accessors/ReferenceNode.js +58 -9
- package/src/nodes/accessors/ReflectVector.js +10 -0
- package/src/nodes/accessors/RendererReferenceNode.js +35 -0
- package/{examples/jsm → src}/nodes/accessors/SceneNode.js +9 -6
- package/src/nodes/accessors/SkinningNode.js +191 -0
- package/src/nodes/accessors/StorageBufferNode.js +147 -0
- package/{examples/jsm/nodes/accessors/TextureStoreNode.js → src/nodes/accessors/StorageTextureNode.js} +35 -10
- package/src/nodes/accessors/Tangent.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +103 -0
- package/{examples/jsm/nodes/accessors/TextureBicubicNode.js → src/nodes/accessors/TextureBicubic.js} +3 -32
- package/{examples/jsm → src}/nodes/accessors/TextureNode.js +123 -39
- package/src/nodes/accessors/TextureSizeNode.js +36 -0
- package/src/nodes/accessors/UV.js +3 -0
- package/{examples/jsm/nodes/accessors/UniformsNode.js → src/nodes/accessors/UniformArrayNode.js} +33 -15
- package/{examples/jsm → src}/nodes/accessors/UserDataNode.js +10 -7
- package/src/nodes/accessors/VelocityNode.js +134 -0
- package/{examples/jsm → src}/nodes/accessors/VertexColorNode.js +9 -5
- package/{examples/jsm → src}/nodes/code/CodeNode.js +9 -5
- package/{examples/jsm → src}/nodes/code/ExpressionNode.js +10 -6
- package/{examples/jsm → src}/nodes/code/FunctionCallNode.js +8 -5
- package/{examples/jsm → src}/nodes/code/FunctionNode.js +8 -31
- package/{examples/jsm → src}/nodes/code/ScriptableNode.js +24 -7
- package/{examples/jsm → src}/nodes/code/ScriptableValueNode.js +11 -8
- package/{examples/jsm → src}/nodes/core/AssignNode.js +12 -9
- package/{examples/jsm → src}/nodes/core/AttributeNode.js +29 -12
- package/{examples/jsm → src}/nodes/core/BypassNode.js +11 -7
- package/src/nodes/core/CacheNode.js +50 -0
- package/{examples/jsm → src}/nodes/core/ConstNode.js +6 -3
- package/{examples/jsm → src}/nodes/core/ContextNode.js +27 -11
- package/src/nodes/core/IndexNode.js +99 -0
- package/{examples/jsm → src}/nodes/core/InputNode.js +7 -3
- package/{examples/jsm → src}/nodes/core/LightingModel.js +2 -2
- package/src/nodes/core/MRTNode.js +85 -0
- package/{examples/jsm → src}/nodes/core/Node.js +114 -57
- package/{examples/jsm → src}/nodes/core/NodeBuilder.js +327 -90
- package/src/nodes/core/NodeCache.js +36 -0
- package/{examples/jsm → src}/nodes/core/NodeFrame.js +52 -10
- 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 +56 -8
- package/{examples/jsm → src}/nodes/core/OutputStructNode.js +13 -12
- package/{examples/jsm → src}/nodes/core/ParameterNode.js +7 -4
- package/src/nodes/core/PropertyNode.js +88 -0
- package/{examples/jsm → src}/nodes/core/StackNode.js +31 -11
- package/{examples/jsm → src}/nodes/core/StructTypeNode.js +7 -3
- package/{examples/jsm → src}/nodes/core/TempNode.js +10 -6
- package/src/nodes/core/UniformGroupNode.js +59 -0
- package/{examples/jsm → src}/nodes/core/UniformNode.js +37 -5
- package/{examples/jsm → src}/nodes/core/VarNode.js +14 -14
- package/src/nodes/core/VaryingNode.js +108 -0
- package/{examples/jsm → src}/nodes/display/AfterImageNode.js +38 -28
- package/src/nodes/display/AnaglyphPassNode.js +67 -0
- package/{examples/jsm → src}/nodes/display/AnamorphicNode.js +33 -30
- package/src/nodes/display/BleachBypass.js +26 -0
- package/src/nodes/display/BlendMode.js +54 -0
- package/src/nodes/display/BloomNode.js +341 -0
- package/{examples/jsm → src}/nodes/display/BumpMapNode.js +20 -38
- package/src/nodes/display/ColorAdjustment.js +46 -0
- package/src/nodes/display/ColorSpaceFunctions.js +38 -0
- package/src/nodes/display/ColorSpaceNode.js +114 -0
- package/src/nodes/display/DenoiseNode.js +204 -0
- package/src/nodes/display/DepthOfFieldNode.js +124 -0
- package/src/nodes/display/DotScreenNode.js +66 -0
- package/src/nodes/display/FXAANode.js +332 -0
- package/src/nodes/display/FilmNode.js +56 -0
- package/src/nodes/display/FrontFacingNode.js +45 -0
- package/src/nodes/display/GTAONode.js +331 -0
- package/{examples/jsm → src}/nodes/display/GaussianBlurNode.js +47 -24
- package/src/nodes/display/Lut3DNode.js +57 -0
- package/src/nodes/display/MotionBlur.js +25 -0
- package/{examples/jsm → src}/nodes/display/NormalMapNode.js +14 -14
- package/src/nodes/display/ParallaxBarrierPassNode.js +58 -0
- package/src/nodes/display/PassNode.js +378 -0
- package/src/nodes/display/PixelationPassNode.js +213 -0
- package/{examples/jsm → src}/nodes/display/PosterizeNode.js +8 -7
- package/src/nodes/display/RGBShiftNode.js +53 -0
- package/src/nodes/display/RenderOutputNode.js +60 -0
- package/src/nodes/display/SSAAPassNode.js +287 -0
- package/src/nodes/display/ScreenNode.js +181 -0
- package/src/nodes/display/Sepia.js +17 -0
- package/src/nodes/display/SobelOperatorNode.js +126 -0
- package/src/nodes/display/StereoCompositePassNode.js +110 -0
- package/src/nodes/display/StereoPassNode.js +83 -0
- package/src/nodes/display/ToneMappingFunctions.js +190 -0
- package/src/nodes/display/ToneMappingNode.js +67 -0
- package/src/nodes/display/ToonOutlinePassNode.js +111 -0
- package/src/nodes/display/TransitionNode.js +80 -0
- package/src/nodes/display/ViewportDepthNode.js +125 -0
- package/src/nodes/display/ViewportDepthTextureNode.js +33 -0
- package/src/nodes/display/ViewportSharedTextureNode.js +39 -0
- package/{examples/jsm → src}/nodes/display/ViewportTextureNode.js +20 -14
- package/src/nodes/fog/FogExp2Node.js +35 -0
- package/src/nodes/fog/FogNode.js +50 -0
- package/src/nodes/fog/FogRangeNode.js +36 -0
- package/src/nodes/functions/BSDF/BRDF_GGX.js +59 -0
- 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/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +28 -0
- 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 -4
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +29 -0
- package/src/nodes/functions/BasicLightingModel.js +78 -0
- package/{examples/jsm → src}/nodes/functions/PhongLightingModel.js +11 -9
- package/src/nodes/functions/PhysicalLightingModel.js +633 -0
- package/src/nodes/functions/ShadowMaskModel.js +31 -0
- package/src/nodes/functions/ToonLightingModel.js +51 -0
- package/src/nodes/functions/material/getGeometryRoughness.js +13 -0
- package/{examples/jsm → src}/nodes/functions/material/getRoughness.js +2 -2
- package/src/nodes/functions/material/getShIrradianceAt.js +28 -0
- package/{examples/jsm → src}/nodes/geometry/RangeNode.js +28 -11
- package/src/nodes/gpgpu/AtomicFunctionNode.js +99 -0
- package/src/nodes/gpgpu/BarrierNode.js +40 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +98 -0
- package/{examples/jsm → src}/nodes/gpgpu/ComputeNode.js +10 -6
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +100 -0
- package/src/nodes/lighting/AONode.js +27 -0
- package/{examples/jsm → src}/nodes/lighting/AmbientLightNode.js +6 -8
- package/src/nodes/lighting/AnalyticLightNode.js +522 -0
- package/src/nodes/lighting/BasicEnvironmentNode.js +30 -0
- package/src/nodes/lighting/BasicLightMapNode.js +32 -0
- package/{examples/jsm → src}/nodes/lighting/DirectionalLightNode.js +7 -9
- package/src/nodes/lighting/EnvironmentNode.js +138 -0
- package/{examples/jsm → src}/nodes/lighting/HemisphereLightNode.js +12 -11
- package/{examples/jsm → src}/nodes/lighting/IESSpotLightNode.js +7 -9
- package/src/nodes/lighting/IrradianceNode.js +27 -0
- package/src/nodes/lighting/LightProbeNode.js +53 -0
- package/{examples/jsm → src}/nodes/lighting/LightUtils.js +3 -3
- package/src/nodes/lighting/LightingContextNode.js +67 -0
- package/{examples/jsm → src}/nodes/lighting/LightingNode.js +9 -3
- package/src/nodes/lighting/LightsNode.js +250 -0
- package/{examples/jsm → src}/nodes/lighting/PointLightNode.js +12 -13
- package/src/nodes/lighting/RectAreaLightNode.js +97 -0
- package/{examples/jsm → src}/nodes/lighting/SpotLightNode.js +14 -16
- package/{examples/jsm → src}/nodes/materialx/MaterialXNodes.js +2 -2
- package/src/nodes/materialx/lib/mx_hsv.js +127 -0
- 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} +48 -13
- package/src/nodes/math/Hash.js +13 -0
- package/src/nodes/math/MathNode.js +407 -0
- package/{examples/jsm → src}/nodes/math/MathUtils.js +0 -7
- package/src/nodes/math/OperatorNode.js +319 -0
- package/{examples/jsm → src}/nodes/math/TriNoise3D.js +19 -29
- package/{examples/jsm → src}/nodes/parsers/GLSLNodeFunction.js +7 -7
- package/src/nodes/pmrem/PMREMNode.js +240 -0
- package/src/nodes/pmrem/PMREMUtils.js +288 -0
- 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} +122 -96
- package/{examples/jsm → src}/nodes/utils/ArrayElementNode.js +9 -5
- package/{examples/jsm → src}/nodes/utils/ConvertNode.js +7 -3
- package/src/nodes/utils/CubeMapNode.js +160 -0
- package/src/nodes/utils/Discard.js +8 -0
- package/src/nodes/utils/EquirectUVNode.js +36 -0
- package/src/nodes/utils/FlipNode.js +68 -0
- package/{examples/jsm → src}/nodes/utils/FunctionOverloadingNode.js +11 -5
- package/{examples/jsm → src}/nodes/utils/JoinNode.js +6 -3
- package/{examples/jsm → src}/nodes/utils/LoopNode.js +23 -12
- package/src/nodes/utils/MatcapUVNode.js +33 -0
- package/{examples/jsm → src}/nodes/utils/MaxMipLevelNode.js +16 -7
- package/{examples/jsm → src}/nodes/utils/OscNode.js +12 -8
- package/src/nodes/utils/Packing.js +4 -0
- package/src/nodes/utils/RTTNode.js +133 -0
- package/{examples/jsm → src}/nodes/utils/ReflectorNode.js +21 -5
- package/{examples/jsm → src}/nodes/utils/RemapNode.js +12 -8
- package/{examples/jsm → src}/nodes/utils/RotateNode.js +8 -13
- package/{examples/jsm → src}/nodes/utils/SetNode.js +7 -4
- package/{examples/jsm → src}/nodes/utils/SplitNode.js +7 -3
- package/{examples/jsm → src}/nodes/utils/SpriteSheetUVNode.js +10 -6
- package/src/nodes/utils/SpriteUtils.js +47 -0
- package/{examples/jsm → src}/nodes/utils/StorageArrayElementNode.js +11 -12
- package/{examples/jsm → src}/nodes/utils/TimerNode.js +8 -5
- package/{examples/jsm → src}/nodes/utils/TriplanarTexturesNode.js +11 -9
- package/src/nodes/utils/UVUtils.js +19 -0
- package/src/nodes/utils/ViewportUtils.js +14 -0
- package/src/objects/BatchedMesh.js +302 -144
- package/src/objects/InstancedMesh.js +11 -1
- package/src/objects/LOD.js +21 -0
- package/src/objects/Line.js +67 -43
- package/src/objects/Mesh.js +7 -23
- package/src/objects/Points.js +2 -0
- package/src/renderers/WebGLRenderer.js +473 -224
- package/{examples/jsm → src}/renderers/common/Animation.js +3 -0
- package/{examples/jsm → src}/renderers/common/Attributes.js +4 -1
- package/{examples/jsm → src}/renderers/common/Backend.js +30 -27
- package/{examples/jsm → src}/renderers/common/Background.js +18 -10
- package/src/renderers/common/BindGroup.js +18 -0
- package/src/renderers/common/Bindings.js +203 -0
- package/src/renderers/common/BundleGroup.js +26 -0
- package/src/renderers/common/ChainMap.js +59 -0
- package/{examples/jsm → src}/renderers/common/ClippingContext.js +24 -12
- 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 +35 -15
- package/{examples/jsm → src}/renderers/common/Pipelines.js +2 -2
- package/src/renderers/common/PostProcessing.js +90 -0
- package/src/renderers/common/QuadMesh.js +55 -0
- package/src/renderers/common/RenderBundle.js +18 -0
- package/src/renderers/common/RenderBundles.js +38 -0
- package/{examples/jsm → src}/renderers/common/RenderContext.js +25 -2
- package/{examples/jsm → src}/renderers/common/RenderContexts.js +1 -1
- package/{examples/jsm → src}/renderers/common/RenderList.js +11 -2
- package/src/renderers/common/RenderObject.js +413 -0
- package/{examples/jsm → src}/renderers/common/RenderObjects.js +9 -2
- package/{examples/jsm → src}/renderers/common/Renderer.js +431 -83
- package/{examples/jsm → src}/renderers/common/SampledTexture.js +14 -5
- 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 +15 -15
- package/{examples/jsm → src}/renderers/common/Uniform.js +10 -5
- package/{examples/jsm → src}/renderers/common/UniformsGroup.js +69 -31
- package/src/renderers/common/extras/PMREMGenerator.js +771 -0
- package/src/renderers/common/nodes/NodeBuilderState.js +58 -0
- package/src/renderers/common/nodes/NodeLibrary.js +118 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +64 -0
- package/{examples/jsm → src}/renderers/common/nodes/NodeSampler.js +8 -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 +106 -68
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +31 -1
- package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +9 -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/lights_pars_begin.glsl.js +8 -22
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +1 -0
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +2 -10
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +2 -16
- package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +3 -14
- package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +10 -31
- package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +3 -23
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +45 -13
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +38 -25
- 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 +19 -11
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +47 -13
- package/src/renderers/shaders/ShaderChunk.js +0 -2
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +8 -0
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -0
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +2 -4
- package/src/renderers/shaders/ShaderLib.js +2 -1
- package/src/renderers/shaders/UniformsLib.js +3 -0
- package/src/renderers/shaders/UniformsUtils.js +10 -1
- package/src/renderers/webgl/WebGLAttributes.js +42 -38
- package/src/renderers/webgl/WebGLBackground.js +24 -3
- package/src/renderers/webgl/WebGLBindingStates.js +14 -51
- package/src/renderers/webgl/WebGLBufferRenderer.js +23 -22
- package/src/renderers/webgl/WebGLCapabilities.js +44 -13
- package/src/renderers/webgl/WebGLCubeUVMaps.js +10 -6
- package/src/renderers/webgl/WebGLExtensions.js +7 -20
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +23 -21
- package/src/renderers/webgl/WebGLLights.js +21 -44
- package/src/renderers/webgl/WebGLMaterials.js +9 -8
- package/src/renderers/webgl/WebGLMorphtargets.js +78 -217
- package/src/renderers/webgl/WebGLProgram.js +46 -78
- package/src/renderers/webgl/WebGLPrograms.js +37 -40
- package/src/renderers/webgl/WebGLProperties.js +7 -0
- package/src/renderers/webgl/WebGLRenderStates.js +15 -9
- package/src/renderers/webgl/WebGLShadowMap.js +25 -25
- package/src/renderers/webgl/WebGLState.js +35 -58
- package/src/renderers/webgl/WebGLTextures.js +313 -358
- package/src/renderers/webgl/WebGLUniforms.js +12 -2
- package/src/renderers/webgl/WebGLUniformsGroups.js +8 -8
- package/src/renderers/webgl/WebGLUtils.js +9 -78
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/WebGLBackend.js +389 -152
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +145 -0
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/nodes/GLSLNodeBuilder.js +245 -44
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLAttributeUtils.js +7 -1
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLConstants.js +2 -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 +21 -3
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLTextureUtils.js +271 -43
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLUtils.js +6 -23
- package/{examples/jsm → src}/renderers/webgpu/WebGPUBackend.js +318 -141
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +42 -0
- package/{examples/jsm → src}/renderers/webgpu/WebGPURenderer.js +10 -7
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +59 -0
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +105 -0
- package/{examples/jsm → src}/renderers/webgpu/nodes/WGSLNodeBuilder.js +424 -95
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +159 -0
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUAttributeUtils.js +37 -18
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUBindingUtils.js +86 -32
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUConstants.js +10 -1
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUPipelineUtils.js +68 -27
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTextureUtils.js +235 -68
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUUtils.js +43 -5
- package/src/renderers/webxr/WebXRDepthSensing.js +11 -6
- package/src/renderers/webxr/WebXRManager.js +53 -38
- package/src/scenes/Scene.js +7 -1
- package/src/textures/CompressedArrayTexture.js +14 -0
- package/src/textures/DataArrayTexture.js +14 -0
- package/src/textures/DepthTexture.js +1 -3
- package/src/textures/Texture.js +12 -2
- package/src/utils.js +62 -1
- package/examples/jsm/geometries/SDFGeometryGenerator.js +0 -144
- package/examples/jsm/loaders/LogLuvLoader.js +0 -606
- package/examples/jsm/loaders/TiltLoader.js +0 -520
- package/examples/jsm/nodes/Nodes.js +0 -195
- package/examples/jsm/nodes/accessors/AccessorsUtils.js +0 -10
- package/examples/jsm/nodes/accessors/BitangentNode.js +0 -89
- package/examples/jsm/nodes/accessors/CameraNode.js +0 -119
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +0 -61
- package/examples/jsm/nodes/accessors/InstanceNode.js +0 -71
- package/examples/jsm/nodes/accessors/InstancedPointsMaterialNode.js +0 -21
- package/examples/jsm/nodes/accessors/MaterialNode.js +0 -314
- package/examples/jsm/nodes/accessors/ModelNode.js +0 -33
- package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +0 -39
- package/examples/jsm/nodes/accessors/NormalNode.js +0 -96
- package/examples/jsm/nodes/accessors/PointUVNode.js +0 -26
- package/examples/jsm/nodes/accessors/PositionNode.js +0 -104
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +0 -35
- package/examples/jsm/nodes/accessors/SkinningNode.js +0 -124
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +0 -72
- package/examples/jsm/nodes/accessors/TangentNode.js +0 -109
- package/examples/jsm/nodes/accessors/TextureSizeNode.js +0 -35
- package/examples/jsm/nodes/accessors/UVNode.js +0 -47
- package/examples/jsm/nodes/core/CacheNode.js +0 -49
- package/examples/jsm/nodes/core/IndexNode.js +0 -66
- 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 -72
- package/examples/jsm/nodes/core/UniformGroupNode.js +0 -36
- package/examples/jsm/nodes/core/VaryingNode.js +0 -65
- 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 -27
- package/examples/jsm/nodes/display/PassNode.js +0 -183
- package/examples/jsm/nodes/display/ToneMappingNode.js +0 -184
- package/examples/jsm/nodes/display/ViewportDepthNode.js +0 -97
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +0 -31
- package/examples/jsm/nodes/display/ViewportNode.js +0 -134
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +0 -31
- package/examples/jsm/nodes/fog/FogExp2Node.js +0 -35
- package/examples/jsm/nodes/fog/FogNode.js +0 -38
- package/examples/jsm/nodes/fog/FogRangeNode.js +0 -34
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +0 -40
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +0 -393
- 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 -241
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +0 -181
- package/examples/jsm/nodes/lighting/LightNode.js +0 -57
- package/examples/jsm/nodes/lighting/LightingContextNode.js +0 -66
- package/examples/jsm/nodes/lighting/LightsNode.js +0 -188
- package/examples/jsm/nodes/materials/InstancedPointsNodeMaterial.js +0 -162
- 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/MeshNormalNodeMaterial.js +0 -40
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +0 -65
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +0 -155
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +0 -80
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +0 -90
- package/examples/jsm/nodes/materialx/lib/mx_hsv.js +0 -130
- package/examples/jsm/nodes/math/HashNode.js +0 -34
- package/examples/jsm/nodes/math/MathNode.js +0 -391
- package/examples/jsm/nodes/math/OperatorNode.js +0 -274
- package/examples/jsm/nodes/procedural/CheckerNode.js +0 -42
- package/examples/jsm/nodes/utils/DiscardNode.js +0 -27
- package/examples/jsm/nodes/utils/EquirectUVNode.js +0 -33
- package/examples/jsm/nodes/utils/MatcapUVNode.js +0 -30
- package/examples/jsm/nodes/utils/PackingNode.js +0 -55
- package/examples/jsm/nodes/utils/RotateUVNode.js +0 -35
- package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +0 -37
- package/examples/jsm/objects/QuadMesh.js +0 -66
- package/examples/jsm/renderers/common/Bindings.js +0 -173
- package/examples/jsm/renderers/common/ChainMap.js +0 -89
- package/examples/jsm/renderers/common/PostProcessing.js +0 -25
- package/examples/jsm/renderers/common/RenderObject.js +0 -221
- package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +0 -44
- package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +0 -49
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +0 -104
- package/examples/jsm/utils/GPUStatsPanel.js +0 -128
- package/examples/jsm/utils/PackedPhongMaterial.js +0 -178
- package/src/renderers/WebGL1Renderer.js +0 -7
- package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +0 -10
- /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/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/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/ProgrammableStage.js +0 -0
- /package/{examples/jsm → src}/renderers/common/RenderLists.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}/utils/WebGLCapabilities.js +0 -0
- /package/{examples/jsm → src}/renderers/webgpu/nodes/WGSLNodeParser.js +0 -0
|
@@ -4,7 +4,8 @@ import {
|
|
|
4
4
|
Color,
|
|
5
5
|
FileLoader,
|
|
6
6
|
Float32BufferAttribute,
|
|
7
|
-
Loader
|
|
7
|
+
Loader,
|
|
8
|
+
SRGBColorSpace
|
|
8
9
|
} from 'three';
|
|
9
10
|
import * as fflate from '../libs/fflate.module.js';
|
|
10
11
|
|
|
@@ -211,7 +212,7 @@ class VTKLoader extends Loader {
|
|
|
211
212
|
const g = parseFloat( result[ 2 ] );
|
|
212
213
|
const b = parseFloat( result[ 3 ] );
|
|
213
214
|
|
|
214
|
-
color.
|
|
215
|
+
color.setRGB( r, g, b, SRGBColorSpace );
|
|
215
216
|
|
|
216
217
|
colors.push( color.r, color.g, color.b );
|
|
217
218
|
|
|
@@ -325,7 +326,7 @@ class VTKLoader extends Loader {
|
|
|
325
326
|
const g = colors[ 3 * i + 1 ];
|
|
326
327
|
const b = colors[ 3 * i + 2 ];
|
|
327
328
|
|
|
328
|
-
color.
|
|
329
|
+
color.setRGB( r, g, b, SRGBColorSpace );
|
|
329
330
|
|
|
330
331
|
newColors.push( color.r, color.g, color.b );
|
|
331
332
|
newColors.push( color.r, color.g, color.b );
|
|
@@ -447,7 +448,6 @@ class VTKLoader extends Loader {
|
|
|
447
448
|
|
|
448
449
|
} else {
|
|
449
450
|
|
|
450
|
-
|
|
451
451
|
indices[ indicesIndex ++ ] = strip[ j ];
|
|
452
452
|
indices[ indicesIndex ++ ] = strip[ j + 1 ];
|
|
453
453
|
indices[ indicesIndex ++ ] = strip[ j + 2 ];
|
|
@@ -620,7 +620,17 @@ class VTKLoader extends Loader {
|
|
|
620
620
|
|
|
621
621
|
const tmp = xmlToJson( item );
|
|
622
622
|
|
|
623
|
-
if ( tmp !== '' )
|
|
623
|
+
if ( tmp !== '' ) {
|
|
624
|
+
|
|
625
|
+
if ( Array.isArray( tmp[ '#text' ] ) ) {
|
|
626
|
+
|
|
627
|
+
tmp[ '#text' ] = tmp[ '#text' ][ 0 ];
|
|
628
|
+
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
obj[ nodeName ] = tmp;
|
|
632
|
+
|
|
633
|
+
}
|
|
624
634
|
|
|
625
635
|
} else {
|
|
626
636
|
|
|
@@ -633,7 +643,17 @@ class VTKLoader extends Loader {
|
|
|
633
643
|
|
|
634
644
|
const tmp = xmlToJson( item );
|
|
635
645
|
|
|
636
|
-
if ( tmp !== '' )
|
|
646
|
+
if ( tmp !== '' ) {
|
|
647
|
+
|
|
648
|
+
if ( Array.isArray( tmp[ '#text' ] ) ) {
|
|
649
|
+
|
|
650
|
+
tmp[ '#text' ] = tmp[ '#text' ][ 0 ];
|
|
651
|
+
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
obj[ nodeName ].push( tmp );
|
|
655
|
+
|
|
656
|
+
}
|
|
637
657
|
|
|
638
658
|
}
|
|
639
659
|
|
|
@@ -894,6 +914,60 @@ class VTKLoader extends Loader {
|
|
|
894
914
|
let normals = [];
|
|
895
915
|
let indices = [];
|
|
896
916
|
|
|
917
|
+
if ( json.AppendedData ) {
|
|
918
|
+
|
|
919
|
+
const appendedData = json.AppendedData[ '#text' ].slice( 1 );
|
|
920
|
+
const piece = json.PolyData.Piece;
|
|
921
|
+
|
|
922
|
+
const sections = [ 'PointData', 'CellData', 'Points', 'Verts', 'Lines', 'Strips', 'Polys' ];
|
|
923
|
+
let sectionIndex = 0;
|
|
924
|
+
|
|
925
|
+
const offsets = sections.map( s => {
|
|
926
|
+
|
|
927
|
+
const sect = piece[ s ];
|
|
928
|
+
|
|
929
|
+
if ( sect && sect.DataArray ) {
|
|
930
|
+
|
|
931
|
+
const arr = Array.isArray( sect.DataArray ) ? sect.DataArray : [ sect.DataArray ];
|
|
932
|
+
|
|
933
|
+
return arr.map( a => a.attributes.offset );
|
|
934
|
+
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
return [];
|
|
938
|
+
|
|
939
|
+
} ).flat();
|
|
940
|
+
|
|
941
|
+
for ( const sect of sections ) {
|
|
942
|
+
|
|
943
|
+
const section = piece[ sect ];
|
|
944
|
+
|
|
945
|
+
if ( section && section.DataArray ) {
|
|
946
|
+
|
|
947
|
+
if ( Array.isArray( section.DataArray ) ) {
|
|
948
|
+
|
|
949
|
+
for ( const sectionEle of section.DataArray ) {
|
|
950
|
+
|
|
951
|
+
sectionEle[ '#text' ] = appendedData.slice( offsets[ sectionIndex ], offsets[ sectionIndex + 1 ] );
|
|
952
|
+
sectionEle.attributes.format = 'binary';
|
|
953
|
+
sectionIndex ++;
|
|
954
|
+
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
} else {
|
|
958
|
+
|
|
959
|
+
section.DataArray[ '#text' ] = appendedData.slice( offsets[ sectionIndex ], offsets[ sectionIndex + 1 ] );
|
|
960
|
+
section.DataArray.attributes.format = 'binary';
|
|
961
|
+
sectionIndex ++;
|
|
962
|
+
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
}
|
|
970
|
+
|
|
897
971
|
if ( json.PolyData ) {
|
|
898
972
|
|
|
899
973
|
const piece = json.PolyData.Piece;
|
|
@@ -3,7 +3,8 @@ import {
|
|
|
3
3
|
Color,
|
|
4
4
|
FileLoader,
|
|
5
5
|
Float32BufferAttribute,
|
|
6
|
-
Loader
|
|
6
|
+
Loader,
|
|
7
|
+
SRGBColorSpace
|
|
7
8
|
} from 'three';
|
|
8
9
|
|
|
9
10
|
class XYZLoader extends Loader {
|
|
@@ -80,7 +81,7 @@ class XYZLoader extends Loader {
|
|
|
80
81
|
const g = parseFloat( lineValues[ 4 ] ) / 255;
|
|
81
82
|
const b = parseFloat( lineValues[ 5 ] ) / 255;
|
|
82
83
|
|
|
83
|
-
color.
|
|
84
|
+
color.setRGB( r, g, b, SRGBColorSpace );
|
|
84
85
|
|
|
85
86
|
colors.push( color.r, color.g, color.b );
|
|
86
87
|
|
|
@@ -651,10 +651,13 @@ class IFFParser {
|
|
|
651
651
|
// LAYR: number[U2], flags[U2], pivot[VEC12], name[S0], parent[U2]
|
|
652
652
|
parseLayer( length ) {
|
|
653
653
|
|
|
654
|
+
var number = this.reader.getUint16();
|
|
655
|
+
var flags = this.reader.getUint16(); // If the least significant bit of flags is set, the layer is hidden.
|
|
656
|
+
var pivot = this.reader.getFloat32Array( 3 ); // Note: this seems to be superflous, as the geometry is translated when pivot is present
|
|
654
657
|
var layer = {
|
|
655
|
-
number:
|
|
656
|
-
flags:
|
|
657
|
-
pivot:
|
|
658
|
+
number: number,
|
|
659
|
+
flags: flags, // If the least significant bit of flags is set, the layer is hidden.
|
|
660
|
+
pivot: [ - pivot[ 0 ], pivot[ 1 ], pivot[ 2 ] ], // Note: this seems to be superflous, as the geometry is translated when pivot is present
|
|
658
661
|
name: this.reader.getString(),
|
|
659
662
|
};
|
|
660
663
|
|
|
@@ -676,8 +679,8 @@ class IFFParser {
|
|
|
676
679
|
this.currentPoints = [];
|
|
677
680
|
for ( var i = 0; i < length / 4; i += 3 ) {
|
|
678
681
|
|
|
679
|
-
//
|
|
680
|
-
this.currentPoints.push( this.reader.getFloat32(), this.reader.getFloat32(),
|
|
682
|
+
// x -> -x to match three.js right handed coords
|
|
683
|
+
this.currentPoints.push( - this.reader.getFloat32(), this.reader.getFloat32(), this.reader.getFloat32() );
|
|
681
684
|
|
|
682
685
|
}
|
|
683
686
|
|
|
@@ -270,7 +270,13 @@ const GouraudShader = {
|
|
|
270
270
|
|
|
271
271
|
#endif
|
|
272
272
|
|
|
273
|
-
#
|
|
273
|
+
#ifdef USE_LIGHTMAP
|
|
274
|
+
|
|
275
|
+
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
276
|
+
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
|
277
|
+
reflectedLight.indirectDiffuse += lightMapIrradiance;
|
|
278
|
+
|
|
279
|
+
#endif
|
|
274
280
|
|
|
275
281
|
reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );
|
|
276
282
|
|
|
@@ -4,7 +4,8 @@ import {
|
|
|
4
4
|
Plane,
|
|
5
5
|
Sphere,
|
|
6
6
|
Triangle,
|
|
7
|
-
Vector3
|
|
7
|
+
Vector3,
|
|
8
|
+
Layers
|
|
8
9
|
} from 'three';
|
|
9
10
|
import { Capsule } from '../math/Capsule.js';
|
|
10
11
|
|
|
@@ -89,6 +90,7 @@ class Octree {
|
|
|
89
90
|
|
|
90
91
|
this.subTrees = [];
|
|
91
92
|
this.triangles = [];
|
|
93
|
+
this.layers = new Layers();
|
|
92
94
|
|
|
93
95
|
}
|
|
94
96
|
|
|
@@ -478,38 +480,42 @@ class Octree {
|
|
|
478
480
|
|
|
479
481
|
if ( obj.isMesh === true ) {
|
|
480
482
|
|
|
481
|
-
|
|
483
|
+
if ( this.layers.test( obj.layers ) ) {
|
|
482
484
|
|
|
483
|
-
|
|
485
|
+
let geometry, isTemp = false;
|
|
484
486
|
|
|
485
|
-
|
|
486
|
-
geometry = obj.geometry.toNonIndexed();
|
|
487
|
+
if ( obj.geometry.index !== null ) {
|
|
487
488
|
|
|
488
|
-
|
|
489
|
+
isTemp = true;
|
|
490
|
+
geometry = obj.geometry.toNonIndexed();
|
|
489
491
|
|
|
490
|
-
|
|
492
|
+
} else {
|
|
491
493
|
|
|
492
|
-
|
|
494
|
+
geometry = obj.geometry;
|
|
493
495
|
|
|
494
|
-
|
|
496
|
+
}
|
|
495
497
|
|
|
496
|
-
|
|
498
|
+
const positionAttribute = geometry.getAttribute( 'position' );
|
|
497
499
|
|
|
498
|
-
|
|
499
|
-
const v2 = new Vector3().fromBufferAttribute( positionAttribute, i + 1 );
|
|
500
|
-
const v3 = new Vector3().fromBufferAttribute( positionAttribute, i + 2 );
|
|
500
|
+
for ( let i = 0; i < positionAttribute.count; i += 3 ) {
|
|
501
501
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
502
|
+
const v1 = new Vector3().fromBufferAttribute( positionAttribute, i );
|
|
503
|
+
const v2 = new Vector3().fromBufferAttribute( positionAttribute, i + 1 );
|
|
504
|
+
const v3 = new Vector3().fromBufferAttribute( positionAttribute, i + 2 );
|
|
505
505
|
|
|
506
|
-
|
|
506
|
+
v1.applyMatrix4( obj.matrixWorld );
|
|
507
|
+
v2.applyMatrix4( obj.matrixWorld );
|
|
508
|
+
v3.applyMatrix4( obj.matrixWorld );
|
|
507
509
|
|
|
508
|
-
|
|
510
|
+
this.addTriangle( new Triangle( v1, v2, v3 ) );
|
|
511
|
+
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
if ( isTemp ) {
|
|
509
515
|
|
|
510
|
-
|
|
516
|
+
geometry.dispose();
|
|
511
517
|
|
|
512
|
-
|
|
518
|
+
}
|
|
513
519
|
|
|
514
520
|
}
|
|
515
521
|
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Camera,
|
|
3
2
|
ClampToEdgeWrapping,
|
|
4
3
|
DataTexture,
|
|
5
4
|
FloatType,
|
|
6
|
-
Mesh,
|
|
7
5
|
NearestFilter,
|
|
8
|
-
PlaneGeometry,
|
|
9
6
|
RGBAFormat,
|
|
10
|
-
Scene,
|
|
11
7
|
ShaderMaterial,
|
|
12
8
|
WebGLRenderTarget
|
|
13
9
|
} from 'three';
|
|
14
10
|
|
|
11
|
+
import { FullScreenQuad } from '../postprocessing/Pass.js';
|
|
12
|
+
|
|
15
13
|
/**
|
|
16
14
|
* GPUComputationRenderer, based on SimulationRenderer by zz85
|
|
17
15
|
*
|
|
@@ -48,8 +46,8 @@ import {
|
|
|
48
46
|
* // and fill in here the texture data...
|
|
49
47
|
*
|
|
50
48
|
* // Add texture variables
|
|
51
|
-
* const velVar = gpuCompute.addVariable( "textureVelocity", fragmentShaderVel,
|
|
52
|
-
* const posVar = gpuCompute.addVariable( "texturePosition", fragmentShaderPos,
|
|
49
|
+
* const velVar = gpuCompute.addVariable( "textureVelocity", fragmentShaderVel, vel0 );
|
|
50
|
+
* const posVar = gpuCompute.addVariable( "texturePosition", fragmentShaderPos, pos0 );
|
|
53
51
|
*
|
|
54
52
|
* // Add variable dependencies
|
|
55
53
|
* gpuCompute.setVariableDependencies( velVar, [ velVar, posVar ] );
|
|
@@ -119,20 +117,13 @@ class GPUComputationRenderer {
|
|
|
119
117
|
|
|
120
118
|
let dataType = FloatType;
|
|
121
119
|
|
|
122
|
-
const scene = new Scene();
|
|
123
|
-
|
|
124
|
-
const camera = new Camera();
|
|
125
|
-
camera.position.z = 1;
|
|
126
|
-
|
|
127
120
|
const passThruUniforms = {
|
|
128
121
|
passThruTexture: { value: null }
|
|
129
122
|
};
|
|
130
123
|
|
|
131
124
|
const passThruShader = createShaderMaterial( getPassThroughFragmentShader(), passThruUniforms );
|
|
132
125
|
|
|
133
|
-
const
|
|
134
|
-
scene.add( mesh );
|
|
135
|
-
|
|
126
|
+
const quad = new FullScreenQuad( passThruShader );
|
|
136
127
|
|
|
137
128
|
this.setDataType = function ( type ) {
|
|
138
129
|
|
|
@@ -171,12 +162,6 @@ class GPUComputationRenderer {
|
|
|
171
162
|
|
|
172
163
|
this.init = function () {
|
|
173
164
|
|
|
174
|
-
if ( renderer.capabilities.isWebGL2 === false && renderer.extensions.has( 'OES_texture_float' ) === false ) {
|
|
175
|
-
|
|
176
|
-
return 'No OES_texture_float support for float textures.';
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
|
|
180
165
|
if ( renderer.capabilities.maxVertexTextures === 0 ) {
|
|
181
166
|
|
|
182
167
|
return 'No support for vertex shader textures.';
|
|
@@ -290,8 +275,7 @@ class GPUComputationRenderer {
|
|
|
290
275
|
|
|
291
276
|
this.dispose = function () {
|
|
292
277
|
|
|
293
|
-
|
|
294
|
-
mesh.material.dispose();
|
|
278
|
+
quad.dispose();
|
|
295
279
|
|
|
296
280
|
const variables = this.variables;
|
|
297
281
|
|
|
@@ -401,10 +385,10 @@ class GPUComputationRenderer {
|
|
|
401
385
|
|
|
402
386
|
renderer.xr.enabled = false; // Avoid camera modification
|
|
403
387
|
renderer.shadowMap.autoUpdate = false; // Avoid re-computing shadows
|
|
404
|
-
|
|
388
|
+
quad.material = material;
|
|
405
389
|
renderer.setRenderTarget( output );
|
|
406
|
-
|
|
407
|
-
|
|
390
|
+
quad.render( renderer );
|
|
391
|
+
quad.material = passThruShader;
|
|
408
392
|
|
|
409
393
|
renderer.xr.enabled = currentXrEnabled;
|
|
410
394
|
renderer.shadowMap.autoUpdate = currentShadowAutoUpdate;
|
|
@@ -5,12 +5,13 @@ const TEXTURE_HEIGHT = 4;
|
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
DataTexture,
|
|
8
|
+
DataUtils,
|
|
8
9
|
RGBAFormat,
|
|
9
|
-
|
|
10
|
+
HalfFloatType,
|
|
10
11
|
RepeatWrapping,
|
|
11
12
|
Mesh,
|
|
12
13
|
InstancedMesh,
|
|
13
|
-
|
|
14
|
+
LinearFilter,
|
|
14
15
|
DynamicDrawUsage,
|
|
15
16
|
Matrix4
|
|
16
17
|
} from 'three';
|
|
@@ -22,18 +23,19 @@ import {
|
|
|
22
23
|
*/
|
|
23
24
|
export function initSplineTexture( numberOfCurves = 1 ) {
|
|
24
25
|
|
|
25
|
-
const dataArray = new
|
|
26
|
+
const dataArray = new Uint16Array( TEXTURE_WIDTH * TEXTURE_HEIGHT * numberOfCurves * CHANNELS );
|
|
26
27
|
const dataTexture = new DataTexture(
|
|
27
28
|
dataArray,
|
|
28
29
|
TEXTURE_WIDTH,
|
|
29
30
|
TEXTURE_HEIGHT * numberOfCurves,
|
|
30
31
|
RGBAFormat,
|
|
31
|
-
|
|
32
|
+
HalfFloatType
|
|
32
33
|
);
|
|
33
34
|
|
|
34
35
|
dataTexture.wrapS = RepeatWrapping;
|
|
35
36
|
dataTexture.wrapY = RepeatWrapping;
|
|
36
|
-
dataTexture.magFilter =
|
|
37
|
+
dataTexture.magFilter = LinearFilter;
|
|
38
|
+
dataTexture.minFilter = LinearFilter;
|
|
37
39
|
dataTexture.needsUpdate = true;
|
|
38
40
|
|
|
39
41
|
return dataTexture;
|
|
@@ -81,10 +83,10 @@ function setTextureValue( texture, index, x, y, z, o ) {
|
|
|
81
83
|
const image = texture.image;
|
|
82
84
|
const { data } = image;
|
|
83
85
|
const i = CHANNELS * TEXTURE_WIDTH * o; // Row Offset
|
|
84
|
-
data[ index * CHANNELS + i + 0 ] = x;
|
|
85
|
-
data[ index * CHANNELS + i + 1 ] = y;
|
|
86
|
-
data[ index * CHANNELS + i + 2 ] = z;
|
|
87
|
-
data[ index * CHANNELS + i + 3 ] = 1;
|
|
86
|
+
data[ index * CHANNELS + i + 0 ] = DataUtils.toHalfFloat( x );
|
|
87
|
+
data[ index * CHANNELS + i + 1 ] = DataUtils.toHalfFloat( y );
|
|
88
|
+
data[ index * CHANNELS + i + 2 ] = DataUtils.toHalfFloat( z );
|
|
89
|
+
data[ index * CHANNELS + i + 3 ] = DataUtils.toHalfFloat( 1 );
|
|
88
90
|
|
|
89
91
|
}
|
|
90
92
|
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
// Original src: https://github.com/zz85/threejs-path-flow
|
|
2
|
+
const CHANNELS = 4;
|
|
3
|
+
const TEXTURE_WIDTH = 1024;
|
|
4
|
+
const TEXTURE_HEIGHT = 4;
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
DataTexture,
|
|
8
|
+
DataUtils,
|
|
9
|
+
RGBAFormat,
|
|
10
|
+
HalfFloatType,
|
|
11
|
+
RepeatWrapping,
|
|
12
|
+
Mesh,
|
|
13
|
+
InstancedMesh,
|
|
14
|
+
LinearFilter
|
|
15
|
+
} from 'three';
|
|
16
|
+
|
|
17
|
+
import { modelWorldMatrix, normalLocal, vec2, vec3, vec4, mat3, varyingProperty, texture, reference, Fn, select, positionLocal } from 'three/tsl';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Make a new DataTexture to store the descriptions of the curves.
|
|
21
|
+
*
|
|
22
|
+
* @param { number } numberOfCurves the number of curves needed to be described by this texture.
|
|
23
|
+
*/
|
|
24
|
+
export function initSplineTexture( numberOfCurves = 1 ) {
|
|
25
|
+
|
|
26
|
+
const dataArray = new Uint16Array( TEXTURE_WIDTH * TEXTURE_HEIGHT * numberOfCurves * CHANNELS );
|
|
27
|
+
const dataTexture = new DataTexture(
|
|
28
|
+
dataArray,
|
|
29
|
+
TEXTURE_WIDTH,
|
|
30
|
+
TEXTURE_HEIGHT * numberOfCurves,
|
|
31
|
+
RGBAFormat,
|
|
32
|
+
HalfFloatType
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
dataTexture.wrapS = RepeatWrapping;
|
|
36
|
+
dataTexture.wrapY = RepeatWrapping;
|
|
37
|
+
dataTexture.magFilter = LinearFilter;
|
|
38
|
+
dataTexture.minFilter = LinearFilter;
|
|
39
|
+
dataTexture.needsUpdate = true;
|
|
40
|
+
|
|
41
|
+
return dataTexture;
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Write the curve description to the data texture
|
|
47
|
+
*
|
|
48
|
+
* @param { DataTexture } texture The DataTexture to write to
|
|
49
|
+
* @param { Curve } splineCurve The curve to describe
|
|
50
|
+
* @param { number } offset Which curve slot to write to
|
|
51
|
+
*/
|
|
52
|
+
export function updateSplineTexture( texture, splineCurve, offset = 0 ) {
|
|
53
|
+
|
|
54
|
+
const numberOfPoints = Math.floor( TEXTURE_WIDTH * ( TEXTURE_HEIGHT / 4 ) );
|
|
55
|
+
splineCurve.arcLengthDivisions = numberOfPoints / 2;
|
|
56
|
+
splineCurve.updateArcLengths();
|
|
57
|
+
const points = splineCurve.getSpacedPoints( numberOfPoints );
|
|
58
|
+
const frenetFrames = splineCurve.computeFrenetFrames( numberOfPoints, true );
|
|
59
|
+
|
|
60
|
+
for ( let i = 0; i < numberOfPoints; i ++ ) {
|
|
61
|
+
|
|
62
|
+
const rowOffset = Math.floor( i / TEXTURE_WIDTH );
|
|
63
|
+
const rowIndex = i % TEXTURE_WIDTH;
|
|
64
|
+
|
|
65
|
+
let pt = points[ i ];
|
|
66
|
+
setTextureValue( texture, rowIndex, pt.x, pt.y, pt.z, 0 + rowOffset + ( TEXTURE_HEIGHT * offset ) );
|
|
67
|
+
pt = frenetFrames.tangents[ i ];
|
|
68
|
+
setTextureValue( texture, rowIndex, pt.x, pt.y, pt.z, 1 + rowOffset + ( TEXTURE_HEIGHT * offset ) );
|
|
69
|
+
pt = frenetFrames.normals[ i ];
|
|
70
|
+
setTextureValue( texture, rowIndex, pt.x, pt.y, pt.z, 2 + rowOffset + ( TEXTURE_HEIGHT * offset ) );
|
|
71
|
+
pt = frenetFrames.binormals[ i ];
|
|
72
|
+
setTextureValue( texture, rowIndex, pt.x, pt.y, pt.z, 3 + rowOffset + ( TEXTURE_HEIGHT * offset ) );
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
texture.needsUpdate = true;
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
function setTextureValue( texture, index, x, y, z, o ) {
|
|
82
|
+
|
|
83
|
+
const image = texture.image;
|
|
84
|
+
const { data } = image;
|
|
85
|
+
const i = CHANNELS * TEXTURE_WIDTH * o; // Row Offset
|
|
86
|
+
|
|
87
|
+
data[ index * CHANNELS + i + 0 ] = DataUtils.toHalfFloat( x );
|
|
88
|
+
data[ index * CHANNELS + i + 1 ] = DataUtils.toHalfFloat( y );
|
|
89
|
+
data[ index * CHANNELS + i + 2 ] = DataUtils.toHalfFloat( z );
|
|
90
|
+
data[ index * CHANNELS + i + 3 ] = DataUtils.toHalfFloat( 1 );
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Create a new set of uniforms for describing the curve modifier
|
|
96
|
+
*
|
|
97
|
+
* @param { DataTexture } Texture which holds the curve description
|
|
98
|
+
*/
|
|
99
|
+
export function getUniforms( splineTexture ) {
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
spineTexture: splineTexture,
|
|
103
|
+
pathOffset: 0, // time of path curve
|
|
104
|
+
pathSegment: 1, // fractional length of path
|
|
105
|
+
spineOffset: 161,
|
|
106
|
+
spineLength: 400,
|
|
107
|
+
flow: 1, // int
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function modifyShader( material, uniforms, numberOfCurves ) {
|
|
113
|
+
|
|
114
|
+
const spineTexture = uniforms.spineTexture;
|
|
115
|
+
|
|
116
|
+
const pathOffset = reference( 'pathOffset', 'float', uniforms );
|
|
117
|
+
const pathSegment = reference( 'pathSegment', 'float', uniforms );
|
|
118
|
+
const spineOffset = reference( 'spineOffset', 'float', uniforms );
|
|
119
|
+
const spineLength = reference( 'spineLength', 'float', uniforms );
|
|
120
|
+
const flow = reference( 'flow', 'float', uniforms );
|
|
121
|
+
|
|
122
|
+
material.positionNode = Fn( () => {
|
|
123
|
+
|
|
124
|
+
const textureStacks = TEXTURE_HEIGHT / 4;
|
|
125
|
+
const textureScale = TEXTURE_HEIGHT * numberOfCurves;
|
|
126
|
+
|
|
127
|
+
const worldPos = modelWorldMatrix.mul( vec4( positionLocal, 1 ) ).toVar();
|
|
128
|
+
|
|
129
|
+
const bend = flow.greaterThan( 0 ).toVar();
|
|
130
|
+
const xWeight = select( bend, 0, 1 ).toVar();
|
|
131
|
+
|
|
132
|
+
const spinePortion = select( bend, worldPos.x.add( spineOffset ).div( spineLength ), 0 );
|
|
133
|
+
const mt = spinePortion.mul( pathSegment ).add( pathOffset ).mul( textureStacks ).toVar();
|
|
134
|
+
|
|
135
|
+
mt.assign( mt.mod( textureStacks ) );
|
|
136
|
+
|
|
137
|
+
const rowOffset = mt.floor().toVar();
|
|
138
|
+
|
|
139
|
+
const spinePos = texture( spineTexture, vec2( mt, rowOffset.add( 0.5 ).div( textureScale ) ) ).xyz;
|
|
140
|
+
|
|
141
|
+
const a = texture( spineTexture, vec2( mt, rowOffset.add( 1.5 ).div( textureScale ) ) ).xyz;
|
|
142
|
+
const b = texture( spineTexture, vec2( mt, rowOffset.add( 2.5 ).div( textureScale ) ) ).xyz;
|
|
143
|
+
const c = texture( spineTexture, vec2( mt, rowOffset.add( 3.5 ).div( textureScale ) ) ).xyz;
|
|
144
|
+
|
|
145
|
+
const basis = mat3( a, b, c ).toVar();
|
|
146
|
+
|
|
147
|
+
varyingProperty( 'vec3', 'curveNormal' ).assign( basis.mul( normalLocal ) );
|
|
148
|
+
|
|
149
|
+
return basis.mul( vec3( worldPos.x.mul( xWeight ), worldPos.y, worldPos.z ) ).add( spinePos );
|
|
150
|
+
|
|
151
|
+
} )();
|
|
152
|
+
|
|
153
|
+
material.normalNode = varyingProperty( 'vec3', 'curveNormal' );
|
|
154
|
+
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* A helper class for making meshes bend aroudn curves
|
|
159
|
+
*/
|
|
160
|
+
export class Flow {
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* @param {Mesh} mesh The mesh to clone and modify to bend around the curve
|
|
164
|
+
* @param {number} numberOfCurves The amount of space that should preallocated for additional curves
|
|
165
|
+
*/
|
|
166
|
+
constructor( mesh, numberOfCurves = 1 ) {
|
|
167
|
+
|
|
168
|
+
const obj3D = mesh.clone();
|
|
169
|
+
const splineTexure = initSplineTexture( numberOfCurves );
|
|
170
|
+
const uniforms = getUniforms( splineTexure );
|
|
171
|
+
|
|
172
|
+
obj3D.traverse( function ( child ) {
|
|
173
|
+
|
|
174
|
+
if (
|
|
175
|
+
child instanceof Mesh ||
|
|
176
|
+
child instanceof InstancedMesh
|
|
177
|
+
) {
|
|
178
|
+
|
|
179
|
+
if ( Array.isArray( child.material ) ) {
|
|
180
|
+
|
|
181
|
+
const materials = [];
|
|
182
|
+
|
|
183
|
+
for ( const material of child.material ) {
|
|
184
|
+
|
|
185
|
+
const newMaterial = material.clone();
|
|
186
|
+
modifyShader( newMaterial, uniforms, numberOfCurves );
|
|
187
|
+
materials.push( newMaterial );
|
|
188
|
+
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
child.material = materials;
|
|
192
|
+
|
|
193
|
+
} else {
|
|
194
|
+
|
|
195
|
+
child.material = child.material.clone();
|
|
196
|
+
modifyShader( child.material, uniforms, numberOfCurves );
|
|
197
|
+
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
} );
|
|
203
|
+
|
|
204
|
+
this.curveArray = new Array( numberOfCurves );
|
|
205
|
+
this.curveLengthArray = new Array( numberOfCurves );
|
|
206
|
+
|
|
207
|
+
this.object3D = obj3D;
|
|
208
|
+
this.splineTexure = splineTexure;
|
|
209
|
+
this.uniforms = uniforms;
|
|
210
|
+
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
updateCurve( index, curve ) {
|
|
214
|
+
|
|
215
|
+
if ( index >= this.curveArray.length ) throw Error( 'Index out of range for Flow' );
|
|
216
|
+
|
|
217
|
+
const curveLength = curve.getLength();
|
|
218
|
+
|
|
219
|
+
this.uniforms.spineLength = curveLength;
|
|
220
|
+
this.curveLengthArray[ index ] = curveLength;
|
|
221
|
+
this.curveArray[ index ] = curve;
|
|
222
|
+
|
|
223
|
+
updateSplineTexture( this.splineTexure, curve, index );
|
|
224
|
+
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
moveAlongCurve( amount ) {
|
|
228
|
+
|
|
229
|
+
this.uniforms.pathOffset += amount;
|
|
230
|
+
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BufferGeometry,
|
|
3
|
+
Color,
|
|
3
4
|
Float32BufferAttribute,
|
|
4
5
|
Vector2,
|
|
5
6
|
Vector3,
|
|
@@ -81,7 +82,7 @@ class SimplifyModifier {
|
|
|
81
82
|
|
|
82
83
|
if ( colorAttribute ) {
|
|
83
84
|
|
|
84
|
-
col = new
|
|
85
|
+
col = new Color().fromBufferAttribute( colorAttribute, i );
|
|
85
86
|
|
|
86
87
|
}
|
|
87
88
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Mesh
|
|
2
|
+
Mesh,
|
|
3
|
+
InstancedPointsNodeMaterial
|
|
3
4
|
} from 'three';
|
|
4
5
|
import InstancedPointsGeometry from '../geometries/InstancedPointsGeometry.js';
|
|
5
|
-
import InstancedPointsNodeMaterial from '../nodes/materials/InstancedPointsNodeMaterial.js';
|
|
6
6
|
|
|
7
7
|
class InstancedPoints extends Mesh {
|
|
8
8
|
|