@gnsx/three 0.185.16 → 0.186.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 +10 -82600
- package/build/three.core.js +1309 -807
- package/build/three.module.js +439 -338
- package/build/three.tsl.js +74 -44
- package/build/three.webgpu.js +6036 -2184
- package/build/three.webgpu.nodes.js +6020 -2184
- package/examples/jsm/Addons.js +6 -6
- package/examples/jsm/controls/ArcballControls.js +1 -1
- package/examples/jsm/controls/FirstPersonControls.js +44 -20
- package/examples/jsm/controls/OrbitControls.js +9 -0
- package/examples/jsm/controls/TrackballControls.js +109 -4
- package/examples/jsm/csm/CSMShadowNode.js +13 -0
- package/examples/jsm/exporters/GLTFExporter.js +23 -7
- package/examples/jsm/exporters/USDZExporter.js +2 -2
- package/examples/jsm/generators/CityGenerator.js +377 -45
- package/examples/jsm/generators/ForestGenerator.js +12 -12
- package/examples/jsm/generators/TerrainGenerator.js +49 -37
- package/examples/jsm/generators/TreeGenerator.js +70 -76
- package/examples/jsm/generators/city/BenchGenerator.js +127 -0
- package/examples/jsm/generators/city/CarGenerator.js +479 -0
- package/examples/jsm/generators/city/CityGeneratorUtils.js +31 -0
- package/examples/jsm/generators/city/HydrantGenerator.js +106 -0
- package/examples/jsm/generators/city/InstancedMeshGenerator.js +86 -0
- package/examples/jsm/generators/city/PersonGenerator.js +447 -0
- package/examples/jsm/generators/city/SidewalkGenerator.js +33 -38
- package/examples/jsm/generators/city/SkyscraperGenerator.js +448 -48
- package/examples/jsm/generators/city/StreetTreeGenerator.js +231 -0
- package/examples/jsm/generators/city/StreetlightGenerator.js +100 -0
- package/examples/jsm/generators/city/TrafficlightGenerator.js +106 -0
- package/examples/jsm/generators/city/TrashcanGenerator.js +100 -0
- package/examples/jsm/geometries/BoxLineGeometry.js +1 -1
- package/examples/jsm/geometries/ParametricGeometry.js +1 -1
- package/examples/jsm/geometries/RoundedBoxGeometry.js +1 -1
- package/examples/jsm/gpgpu/CountingSort.js +271 -0
- package/examples/jsm/helpers/LightProbeGridHelper.js +60 -239
- package/examples/jsm/helpers/LightProbeGridHelperWebGL.js +221 -0
- package/examples/jsm/inspector/Extension.js +94 -0
- package/examples/jsm/inspector/Inspector.js +145 -41
- package/examples/jsm/inspector/RendererInspector.js +100 -52
- package/examples/jsm/inspector/extensions/color-grading/ColorGrading.js +2609 -0
- package/examples/jsm/inspector/extensions/color-grading/ColorWheel.js +352 -0
- package/examples/jsm/inspector/extensions/color-grading/CurveEditor.js +599 -0
- package/examples/jsm/inspector/extensions/color-grading/LUT3DStyle.js +1201 -0
- package/examples/jsm/inspector/extensions/color-grading/LUTMath.js +788 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/BrightnessModule.js +72 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ColorWheelModule.js +112 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ContrastModule.js +82 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/CurvesModule.js +109 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ExposureHueModule.js +110 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ExposureModule.js +73 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/HueModule.js +78 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ImportedCubeModule.js +89 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/Module.js +285 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/OutputModule.js +101 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/RendererModule.js +225 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/SatVibranceModule.js +102 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/SaturationModule.js +76 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/VibranceModule.js +76 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/WhiteBalanceModule.js +86 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +26 -31
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +1 -0
- package/examples/jsm/inspector/tabs/Memory.js +0 -2
- package/examples/jsm/inspector/tabs/Settings.js +4 -0
- package/examples/jsm/inspector/tabs/Timeline.js +223 -171
- package/examples/jsm/inspector/tabs/Viewer.js +515 -21
- package/examples/jsm/inspector/ui/List.js +15 -9
- package/examples/jsm/inspector/ui/Profiler.js +170 -14
- package/examples/jsm/inspector/ui/Style.js +269 -23
- package/examples/jsm/inspector/ui/Tab.js +2 -0
- package/examples/jsm/inspector/ui/Values.js +14 -2
- package/examples/jsm/interactive/HTMLMesh.js +19 -3
- package/examples/jsm/lighting/LightProbeGrid.js +484 -889
- package/examples/jsm/lighting/LightProbeGridUtils.js +107 -0
- package/examples/jsm/lighting/LightProbeGridWebGL.js +841 -0
- package/examples/jsm/lighting/vxgi/VXGIConeTracer.js +194 -0
- package/examples/jsm/lighting/vxgi/VXGINode.js +660 -0
- package/examples/jsm/lighting/vxgi/VXGISceneCollector.js +478 -0
- package/examples/jsm/lighting/vxgi/VXGIVolume.js +1430 -0
- package/examples/jsm/lights/SunLight.js +95 -0
- package/examples/jsm/lights/SunLightNode.js +56 -0
- package/examples/jsm/lights/SunLightShadow.js +319 -0
- package/examples/jsm/lights/SunShadowNode.js +312 -0
- package/examples/jsm/loaders/3DMLoader.js +150 -49
- package/examples/jsm/loaders/3MFLoader.js +202 -1
- package/examples/jsm/loaders/FBXLoader.js +81 -5
- package/examples/jsm/loaders/GLTFGaussianSplatLoaderExtension.js +330 -0
- package/examples/jsm/loaders/GLTFLoader.js +79 -14
- package/examples/jsm/loaders/GaussianSplatPLYLoader.js +386 -0
- package/examples/jsm/loaders/KSPLATLoader.js +463 -0
- package/examples/jsm/loaders/MaterialXLoader.js +111 -1010
- package/examples/jsm/loaders/PCDLoader.js +1 -1
- package/examples/jsm/loaders/SPLATLoader.js +139 -0
- package/examples/jsm/loaders/SPZLoader.js +561 -0
- package/examples/jsm/loaders/materialx/MaterialXArchive.js +108 -0
- package/examples/jsm/loaders/materialx/MaterialXDocument.js +878 -0
- package/examples/jsm/loaders/materialx/MaterialXHextile.js +183 -0
- package/examples/jsm/loaders/materialx/MaterialXInterfaceValidation.js +376 -0
- package/examples/jsm/loaders/materialx/MaterialXLog.js +75 -0
- package/examples/jsm/loaders/materialx/MaterialXNodeInterfaceRegistry.js +4 -0
- package/examples/jsm/loaders/materialx/MaterialXNodeLibrary.js +1021 -0
- package/examples/jsm/loaders/materialx/MaterialXSurfaceMappings.js +661 -0
- package/examples/jsm/loaders/materialx/MaterialXUtils.js +57 -0
- package/examples/jsm/loaders/materialx/compile/MaterialXCompileRegistry.js +997 -0
- package/examples/jsm/loaders/materialx/parse/MaterialXParser.js +28 -0
- package/examples/jsm/loaders/usd/USDAParser.js +15 -2
- package/examples/jsm/loaders/usd/USDCParser.js +1 -4
- package/examples/jsm/loaders/usd/USDComposer.js +80 -42
- package/examples/jsm/materials/WoodNodeMaterial.js +6 -108
- package/examples/jsm/misc/RollerCoaster.js +2 -2
- package/examples/jsm/misc/SculptGL.LICENSE.txt +21 -0
- package/examples/jsm/misc/Sculptor.js +1679 -0
- package/examples/jsm/misc/SculptorMesh.js +1504 -0
- package/examples/jsm/misc/SculptorTools.js +1180 -0
- package/examples/jsm/misc/SculptorUtils.js +345 -0
- package/examples/jsm/misc/TubePainter.js +28 -16
- package/examples/jsm/misc/VolumeSlice.js +24 -24
- package/examples/jsm/modifiers/SimplifyModifier.js +63 -556
- package/examples/jsm/objects/GaussianSplat.js +1039 -0
- package/examples/jsm/objects/Sky.js +66 -45
- package/examples/jsm/objects/SkyMesh.js +70 -51
- package/examples/jsm/physics/JoltPhysics.js +1 -1
- package/examples/jsm/postprocessing/AfterimagePass.js +4 -2
- package/examples/jsm/postprocessing/BloomPass.js +2 -2
- package/examples/jsm/postprocessing/GTAOPass.js +1 -1
- package/examples/jsm/postprocessing/OutlinePass.js +5 -5
- package/examples/jsm/postprocessing/SAOPass.js +1 -1
- package/examples/jsm/postprocessing/SSAOPass.js +1 -1
- package/examples/jsm/postprocessing/SSRPass.js +4 -2
- package/examples/jsm/postprocessing/SavePass.js +1 -1
- package/examples/jsm/postprocessing/TAARenderPass.js +1 -1
- package/examples/jsm/postprocessing/UnrealBloomPass.js +30 -13
- package/examples/jsm/renderers/CSS2DRenderer.js +29 -5
- package/examples/jsm/shaders/DepthLimitedBlurShader.js +4 -1
- package/examples/jsm/shaders/ExposureShader.js +1 -1
- package/examples/jsm/shaders/FilmShader.js +2 -1
- package/examples/jsm/transpiler/AST.js +21 -2
- package/examples/jsm/transpiler/GLSLDecoder.js +498 -8
- package/examples/jsm/transpiler/TSLEncoder.js +82 -10
- package/examples/jsm/transpiler/WGSLEncoder.js +33 -4
- package/examples/jsm/tsl/WebGLNodesHandler.js +29 -39
- package/examples/jsm/tsl/display/AfterImageNode.js +2 -0
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +3 -2
- package/examples/jsm/tsl/display/BilateralBlurNode.js +5 -2
- package/examples/jsm/tsl/display/BloomNode.js +55 -30
- package/examples/jsm/tsl/display/DenoiseNode.js +21 -1
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +24 -6
- package/examples/jsm/tsl/display/DotScreenNode.js +11 -11
- package/examples/jsm/tsl/display/FSR1Node.js +8 -4
- package/examples/jsm/tsl/display/GTAONode.js +199 -86
- package/examples/jsm/tsl/display/GaussianBlurNode.js +65 -52
- package/examples/jsm/tsl/display/GodraysNode.js +5 -2
- package/examples/jsm/tsl/display/ImportanceSampledEnvironment.js +2 -2
- package/examples/jsm/tsl/display/LensflareNode.js +5 -2
- package/examples/jsm/tsl/display/OITPassNode.js +352 -0
- package/examples/jsm/tsl/display/OutlineNode.js +2 -0
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +3 -2
- package/examples/jsm/tsl/display/RGBShiftNode.js +9 -9
- package/examples/jsm/tsl/display/RecurrentDenoiseNode.js +7 -4
- package/examples/jsm/tsl/display/RetroPassNode.js +1 -1
- package/examples/jsm/tsl/display/SMAANode.js +22 -61
- package/examples/jsm/tsl/display/SSAAPassNode.js +2 -4
- package/examples/jsm/tsl/display/SSAONode.js +436 -0
- package/examples/jsm/tsl/display/SSGINode.js +5 -2
- package/examples/jsm/tsl/display/SSRNode.js +7 -2
- package/examples/jsm/tsl/display/SSSNode.js +5 -2
- package/examples/jsm/tsl/display/SharpenNode.js +5 -4
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +1 -3
- package/examples/jsm/tsl/display/StereoPassNode.js +1 -3
- package/examples/jsm/tsl/display/TAAUNode.js +22 -125
- package/examples/jsm/tsl/display/TRAANode.js +16 -142
- package/examples/jsm/tsl/display/TemporalReprojectNode.js +21 -15
- package/examples/jsm/tsl/display/depthAwareBlur.js +63 -0
- package/examples/jsm/tsl/display/hashBlur.js +3 -2
- package/examples/jsm/tsl/lighting/ClusteredLightsNode.js +38 -27
- package/examples/jsm/tsl/lighting/LightProbeGridNode.js +136 -0
- package/examples/jsm/tsl/math/voronoiNoise.js +112 -0
- package/examples/jsm/tsl/shadows/TileShadowNode.js +4 -6
- package/examples/jsm/tsl/utils/Raymarching.js +5 -5
- package/examples/jsm/tsl/utils/SoftParticles.js +60 -0
- package/examples/jsm/tsl/utils/TAAUtils.js +195 -0
- package/examples/jsm/utils/BufferGeometryUtils.js +14 -14
- package/examples/jsm/utils/GaussianSplatUtils.js +229 -0
- package/examples/jsm/utils/WebGLTextureUtils.js +1 -1
- package/examples/jsm/utils/WebGPUTextureUtils.js +1 -1
- package/examples/jsm/webxr/WebGLXRFallback.js +2 -16
- package/examples/jsm/webxr/XRControllerModelFactory.js +16 -4
- package/package.json +9 -16
- package/src/Three.Core.js +2 -1
- package/src/Three.TSL.js +73 -43
- package/src/Three.WebGPU.Nodes.js +1 -0
- package/src/Three.WebGPU.js +1 -0
- package/src/animation/AnimationClip.js +15 -2
- package/src/animation/AnimationObjectGroup.js +18 -6
- package/src/animation/AnimationUtils.js +26 -0
- package/src/animation/KeyframeTrack.js +37 -0
- package/src/constants.js +23 -1
- package/src/core/BufferAttribute.js +3 -2
- package/src/core/BufferGeometry.js +1 -1
- package/src/core/InterleavedBuffer.js +5 -1
- package/src/core/Object3D.js +40 -12
- package/src/core/Raycaster.js +4 -0
- package/src/core/RenderTarget.js +99 -9
- package/src/core/RenderTarget3D.js +12 -8
- package/src/extras/Controls.js +0 -8
- package/src/extras/PMREMGenerator.js +99 -205
- package/src/geometries/TorusGeometry.js +1 -1
- package/src/helpers/ArrowHelper.js +2 -0
- package/src/helpers/AxesHelper.js +2 -0
- package/src/helpers/Box3Helper.js +2 -0
- package/src/helpers/BoxHelper.js +2 -0
- package/src/helpers/CameraHelper.js +2 -0
- package/src/helpers/DirectionalLightHelper.js +2 -0
- package/src/helpers/GridHelper.js +2 -0
- package/src/helpers/HemisphereLightHelper.js +2 -0
- package/src/helpers/PlaneHelper.js +2 -0
- package/src/helpers/PointLightHelper.js +2 -0
- package/src/helpers/PolarGridHelper.js +2 -0
- package/src/helpers/SkeletonHelper.js +2 -0
- package/src/helpers/SpotLightHelper.js +2 -0
- package/src/lights/Light.js +0 -10
- package/src/lights/LightShadow.js +43 -12
- package/src/lights/SpotLightShadow.js +18 -0
- package/src/loaders/BufferGeometryLoader.js +5 -0
- package/src/loaders/ImageBitmapLoader.js +3 -1
- package/src/loaders/ObjectLoader.js +8 -5
- package/src/materials/Material.js +80 -57
- package/src/materials/MeshPhysicalMaterial.js +32 -0
- package/src/materials/nodes/Line2NodeMaterial.js +17 -8
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +42 -5
- package/src/materials/nodes/NodeMaterial.js +19 -13
- package/src/materials/nodes/PointsNodeMaterial.js +2 -1
- package/src/materials/nodes/manager/NodeMaterialObserver.js +282 -55
- package/src/math/Frustum.js +9 -0
- package/src/math/FrustumArray.js +1 -1
- package/src/math/MathUtils.js +5 -3
- package/src/math/Matrix4.js +2 -9
- package/src/math/Plane.js +30 -1
- package/src/math/Quaternion.js +0 -10
- package/src/math/Ray.js +95 -45
- package/src/math/Triangle.js +0 -2
- package/src/math/Vector3.js +2 -2
- package/src/math/Vector4.js +0 -4
- package/src/math/interpolants/BezierInterpolant.js +36 -23
- package/src/nodes/Nodes.js +2 -0
- package/src/nodes/TSL.js +11 -3
- package/src/nodes/accessors/Batch.js +85 -13
- package/src/nodes/accessors/BufferAttributeNode.js +1 -1
- package/src/nodes/accessors/BuiltinNode.js +1 -1
- package/src/nodes/accessors/Instance.js +19 -18
- package/src/nodes/accessors/MaterialNode.js +9 -0
- package/src/nodes/accessors/ModelNode.js +85 -9
- package/src/nodes/accessors/ReferenceBaseNode.js +1 -70
- package/src/nodes/accessors/ReferenceElementNode.js +72 -0
- package/src/nodes/accessors/ReferenceNode.js +1 -70
- package/src/nodes/accessors/Skinning.js +124 -12
- package/src/nodes/accessors/StorageTextureNode.js +7 -3
- package/src/nodes/accessors/Texture3DNode.js +1 -1
- package/src/nodes/accessors/TextureNode.js +51 -21
- package/src/nodes/accessors/TextureSizeNode.js +4 -2
- package/src/nodes/accessors/UniformArrayNode.js +30 -5
- package/src/nodes/code/CodeNode.js +1 -1
- package/src/nodes/code/FunctionNode.js +12 -2
- package/src/nodes/core/ArrayNode.js +2 -2
- package/src/nodes/core/ContextNode.js +57 -4
- package/src/nodes/core/IndexNode.js +69 -4
- package/src/nodes/core/InspectorNode.js +2 -2
- package/src/nodes/core/MRTNode.js +44 -2
- package/src/nodes/core/Node.js +6 -3
- package/src/nodes/core/NodeBuilder.js +65 -50
- package/src/nodes/core/NodeFrame.js +11 -3
- package/src/nodes/core/NodeUtils.js +88 -0
- package/src/nodes/core/PropertyNode.js +8 -0
- package/src/nodes/core/StackNode.js +0 -1
- package/src/nodes/core/StructNode.js +4 -3
- package/src/nodes/core/UniformGroupNode.js +3 -2
- package/src/nodes/core/UniformNode.js +26 -12
- package/src/nodes/core/VarNode.js +0 -1
- package/src/nodes/display/BumpMapNode.js +2 -2
- package/src/nodes/display/ColorAdjustment.js +1 -1
- package/src/nodes/display/PassNode.js +76 -15
- package/src/nodes/display/ScreenNode.js +22 -65
- package/src/nodes/fog/Fog.js +4 -4
- package/src/nodes/functions/BSDF/BRDF_GGX.js +6 -6
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +1 -1
- package/src/nodes/functions/BSDF/DFGLUT.js +2 -1
- package/src/nodes/functions/BSDF/LTC.js +1 -1
- package/src/nodes/functions/PhongLightingModel.js +1 -1
- package/src/nodes/functions/PhysicalLightingModel.js +83 -25
- package/src/nodes/functions/ToonLightingModel.js +2 -2
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +3 -3
- package/src/nodes/gpgpu/AtomicFunctionNode.js +64 -13
- package/src/nodes/gpgpu/BarrierNode.js +13 -4
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -1
- package/src/nodes/gpgpu/ComputeNode.js +20 -17
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +165 -37
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +44 -6
- package/src/nodes/lighting/EnvironmentNode.js +40 -4
- package/src/nodes/lighting/LightsNode.js +20 -4
- package/src/nodes/lighting/ShadowBaseNode.js +158 -1
- package/src/nodes/lighting/ShadowFilterNode.js +2 -106
- package/src/nodes/lighting/ShadowNode.js +22 -91
- package/src/nodes/materialx/{lib/mx_hsv.js → MaterialXColor.js} +3 -6
- package/src/nodes/materialx/{lib/mx_transform_color.js → MaterialXColorTransform.js} +3 -6
- package/src/nodes/materialx/MaterialXCore.js +37 -0
- package/src/nodes/materialx/MaterialXNodes.js +64 -72
- package/src/nodes/materialx/{lib/mx_noise.js → MaterialXNoise.js} +426 -197
- package/src/nodes/math/BitcountNode.js +24 -4
- package/src/nodes/math/MathNode.js +4 -4
- package/src/nodes/math/MathUtils.js +15 -4
- package/src/nodes/math/OperatorNode.js +2 -2
- package/src/nodes/math/PackFloatNode.js +29 -1
- package/src/nodes/math/Packed4x8IntegerNode.js +433 -0
- package/src/nodes/math/UnpackFloatNode.js +30 -2
- package/src/nodes/parsers/GLSLNodeFunction.js +1 -1
- package/src/nodes/pmrem/PMREMNode.js +1 -1
- package/src/nodes/pmrem/PMREMUtils.js +31 -74
- package/src/nodes/shapes/Shapes.js +1 -1
- package/src/nodes/tsl/TSLCore.js +1 -31
- package/src/nodes/utils/EventNode.js +75 -0
- package/src/nodes/utils/LoopNode.js +54 -13
- package/src/nodes/utils/PostProcessingUtils.js +23 -2
- package/src/nodes/utils/RTTNode.js +97 -32
- package/src/nodes/utils/ReflectorNode.js +8 -4
- package/src/nodes/utils/RotateNode.js +85 -8
- package/src/nodes/utils/SpriteUtils.js +58 -23
- package/src/objects/BatchedMesh.js +6 -0
- package/src/objects/InstancedMesh.js +1 -1
- package/src/objects/LOD.js +1 -1
- package/src/objects/Line.js +12 -0
- package/src/objects/Mesh.js +12 -0
- package/src/objects/Points.js +12 -0
- package/src/objects/Sprite.js +12 -0
- package/src/renderers/WebGLRenderer.js +93 -27
- package/src/renderers/common/Animation.js +12 -2
- package/src/renderers/common/Backend.js +38 -10
- package/src/renderers/common/BindGroup.js +0 -1
- package/src/renderers/common/Bindings.js +50 -4
- package/src/renderers/common/BundleGroup.js +4 -0
- package/src/renderers/common/ClippingContext.js +11 -1
- package/src/renderers/common/Color4.js +9 -0
- package/src/renderers/common/Constants.js +0 -5
- package/src/renderers/common/DirectRenderPipeline.js +233 -0
- package/src/renderers/common/Geometries.js +24 -3
- package/src/renderers/common/Info.js +3 -3
- package/src/renderers/common/InspectorBase.js +37 -8
- package/src/renderers/common/Lighting.js +11 -4
- package/src/renderers/common/Pipelines.js +6 -4
- package/src/renderers/common/QuadMesh.js +16 -2
- package/src/renderers/common/RenderContext.js +8 -0
- package/src/renderers/common/RenderList.js +53 -19
- package/src/renderers/common/RenderLists.js +58 -11
- package/src/renderers/common/RenderObject.js +14 -0
- package/src/renderers/common/RenderObjects.js +14 -9
- package/src/renderers/common/RenderPipeline.js +52 -44
- package/src/renderers/common/Renderer.js +226 -55
- package/src/renderers/common/Storage3DTexture.js +16 -0
- package/src/renderers/common/Textures.js +3 -3
- package/src/renderers/common/XRManager.js +79 -72
- package/src/renderers/common/extras/PMREMGenerator.js +76 -144
- package/src/renderers/common/nodes/NodeManager.js +144 -6
- package/src/renderers/common/nodes/NodeStorageBuffer.js +3 -1
- package/src/renderers/common/nodes/NodeUniformBuffer.js +3 -1
- package/src/renderers/shaders/DFGLUTData.js +2 -1
- package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +4 -2
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +48 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +53 -4
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +20 -2
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +20 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +61 -57
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +82 -0
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +9 -0
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +8 -1
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +15 -0
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -0
- package/src/renderers/shaders/ShaderLib.js +1 -0
- package/src/renderers/shaders/UniformsLib.js +16 -0
- package/src/renderers/webgl/WebGLAnimation.js +2 -2
- package/src/renderers/webgl/WebGLCapabilities.js +2 -2
- package/src/renderers/webgl/WebGLLights.js +74 -4
- package/src/renderers/webgl/WebGLMaterials.js +6 -0
- package/src/renderers/webgl/WebGLOutput.js +36 -24
- package/src/renderers/webgl/WebGLProgram.js +3 -0
- package/src/renderers/webgl/WebGLPrograms.js +8 -0
- package/src/renderers/webgl/WebGLRenderLists.js +6 -10
- package/src/renderers/webgl/WebGLShadowMap.js +47 -44
- package/src/renderers/webgl/WebGLTextures.js +7 -7
- package/src/renderers/webgl-fallback/WebGLBackend.js +153 -45
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +83 -29
- package/src/renderers/webgl-fallback/utils/WebGLState.js +163 -17
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +32 -5
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +11 -4
- package/src/renderers/webgpu/WebGPUBackend.js +513 -145
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +99 -20
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +2 -1
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +3 -12
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +24 -14
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +80 -14
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +62 -7
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +9 -3
- package/src/renderers/webgpu/utils/WebGPUUtils.js +16 -4
- package/src/renderers/webxr/WebXRManager.js +25 -2
- package/src/scenes/Scene.js +3 -3
- package/src/textures/CompressedArrayTexture.js +16 -0
- package/src/textures/Data3DTexture.js +16 -0
- package/src/textures/DataArrayTexture.js +16 -0
- package/src/textures/DepthTexture.js +3 -3
- package/src/textures/Texture.js +3 -3
- package/src/textures/{Source.js → TextureSource.js} +39 -8
- package/src/utils.js +6 -79
- package/build/three.core.min.js +0 -6
- package/build/three.module.min.js +0 -6
- package/build/three.tsl.min.js +0 -6
- package/build/three.webgpu.min.js +0 -6
- package/build/three.webgpu.nodes.min.js +0 -6
- package/examples/jsm/libs/ecsy.module.js +0 -1792
- package/examples/jsm/loaders/LottieLoader.js +0 -130
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +0 -52
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Portions adapted from SculptGL by Stéphane Ginier.
|
|
3
|
+
* Copyright (c) 2019 Stéphane GINIER
|
|
4
|
+
* Licensed under the MIT License; see ./SculptGL.LICENSE.txt.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const TRI_INDEX = 4294967295;
|
|
8
|
+
|
|
9
|
+
const MAX_FLAG = 0x7fffffff;
|
|
10
|
+
|
|
11
|
+
let _memoryBuffer = new ArrayBuffer( 100000 );
|
|
12
|
+
const _sortByIndex = ( a, b ) => a - b;
|
|
13
|
+
|
|
14
|
+
function getMemory( byteLength ) {
|
|
15
|
+
|
|
16
|
+
if ( _memoryBuffer.byteLength < byteLength ) {
|
|
17
|
+
|
|
18
|
+
_memoryBuffer = new ArrayBuffer( Math.max( byteLength, _memoryBuffer.byteLength * 2 ) );
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return _memoryBuffer;
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function replaceElement( array, oldValue, newValue ) {
|
|
27
|
+
|
|
28
|
+
for ( let i = 0, l = array.length; i < l; ++ i ) {
|
|
29
|
+
|
|
30
|
+
if ( array[ i ] === oldValue ) {
|
|
31
|
+
|
|
32
|
+
array[ i ] = newValue;
|
|
33
|
+
return;
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function removeElement( array, value ) {
|
|
42
|
+
|
|
43
|
+
for ( let i = 0, l = array.length; i < l; ++ i ) {
|
|
44
|
+
|
|
45
|
+
if ( array[ i ] === value ) {
|
|
46
|
+
|
|
47
|
+
array[ i ] = array[ l - 1 ];
|
|
48
|
+
array.pop();
|
|
49
|
+
return;
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function tidy( array ) {
|
|
58
|
+
|
|
59
|
+
if ( array.length < 2 ) return;
|
|
60
|
+
|
|
61
|
+
array.sort( _sortByIndex );
|
|
62
|
+
let writeIndex = 1;
|
|
63
|
+
|
|
64
|
+
for ( let i = 1; i < array.length; i ++ ) {
|
|
65
|
+
|
|
66
|
+
if ( array[ writeIndex - 1 ] !== array[ i ] ) array[ writeIndex ++ ] = array[ i ];
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
array.length = writeIndex;
|
|
71
|
+
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Geometry helpers
|
|
75
|
+
|
|
76
|
+
const _edge1 = [ 0, 0, 0 ];
|
|
77
|
+
const _edge2 = [ 0, 0, 0 ];
|
|
78
|
+
const _pvec = [ 0, 0, 0 ];
|
|
79
|
+
const _tvec = [ 0, 0, 0 ];
|
|
80
|
+
const _qvec = [ 0, 0, 0 ];
|
|
81
|
+
const _scaledDir = [ 0, 0, 0 ];
|
|
82
|
+
const RAY_EPSILON = 1e-15;
|
|
83
|
+
|
|
84
|
+
function cross( out, a, b ) {
|
|
85
|
+
|
|
86
|
+
out[ 0 ] = a[ 1 ] * b[ 2 ] - a[ 2 ] * b[ 1 ];
|
|
87
|
+
out[ 1 ] = a[ 2 ] * b[ 0 ] - a[ 0 ] * b[ 2 ];
|
|
88
|
+
out[ 2 ] = a[ 0 ] * b[ 1 ] - a[ 1 ] * b[ 0 ];
|
|
89
|
+
return out;
|
|
90
|
+
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function dot( a, b ) {
|
|
94
|
+
|
|
95
|
+
return a[ 0 ] * b[ 0 ] + a[ 1 ] * b[ 1 ] + a[ 2 ] * b[ 2 ];
|
|
96
|
+
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function sub( out, a, b ) {
|
|
100
|
+
|
|
101
|
+
out[ 0 ] = a[ 0 ] - b[ 0 ];
|
|
102
|
+
out[ 1 ] = a[ 1 ] - b[ 1 ];
|
|
103
|
+
out[ 2 ] = a[ 2 ] - b[ 2 ];
|
|
104
|
+
return out;
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function sqrDist( a, b ) {
|
|
109
|
+
|
|
110
|
+
const dx = a[ 0 ] - b[ 0 ], dy = a[ 1 ] - b[ 1 ], dz = a[ 2 ] - b[ 2 ];
|
|
111
|
+
return dx * dx + dy * dy + dz * dz;
|
|
112
|
+
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function setRayIntersection( target, origin, direction, distance ) {
|
|
116
|
+
|
|
117
|
+
if ( ! target ) return;
|
|
118
|
+
|
|
119
|
+
target[ 0 ] = origin[ 0 ] + direction[ 0 ] * distance;
|
|
120
|
+
target[ 1 ] = origin[ 1 ] + direction[ 1 ] * distance;
|
|
121
|
+
target[ 2 ] = origin[ 2 ] + direction[ 2 ] * distance;
|
|
122
|
+
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function intersectionRayTriangleScaled( orig, dir, v1, v2, v3, vertInter ) {
|
|
126
|
+
|
|
127
|
+
sub( _edge1, v2, v1 );
|
|
128
|
+
sub( _edge2, v3, v1 );
|
|
129
|
+
|
|
130
|
+
const edge1Scale = Math.max( Math.abs( _edge1[ 0 ] ), Math.abs( _edge1[ 1 ] ), Math.abs( _edge1[ 2 ] ) );
|
|
131
|
+
const edge2Scale = Math.max( Math.abs( _edge2[ 0 ] ), Math.abs( _edge2[ 1 ] ), Math.abs( _edge2[ 2 ] ) );
|
|
132
|
+
const dirScale = Math.max( Math.abs( dir[ 0 ] ), Math.abs( dir[ 1 ] ), Math.abs( dir[ 2 ] ) );
|
|
133
|
+
|
|
134
|
+
if ( edge1Scale === 0 || edge2Scale === 0 || dirScale === 0 ||
|
|
135
|
+
Number.isFinite( edge1Scale ) === false || Number.isFinite( edge2Scale ) === false || Number.isFinite( dirScale ) === false ) return - 1.0;
|
|
136
|
+
|
|
137
|
+
_edge1[ 0 ] /= edge1Scale; _edge1[ 1 ] /= edge1Scale; _edge1[ 2 ] /= edge1Scale;
|
|
138
|
+
_edge2[ 0 ] /= edge2Scale; _edge2[ 1 ] /= edge2Scale; _edge2[ 2 ] /= edge2Scale;
|
|
139
|
+
_scaledDir[ 0 ] = dir[ 0 ] / dirScale;
|
|
140
|
+
_scaledDir[ 1 ] = dir[ 1 ] / dirScale;
|
|
141
|
+
_scaledDir[ 2 ] = dir[ 2 ] / dirScale;
|
|
142
|
+
|
|
143
|
+
cross( _pvec, _scaledDir, _edge2 );
|
|
144
|
+
const det = dot( _edge1, _pvec );
|
|
145
|
+
const determinantScale = Math.hypot( _edge1[ 0 ], _edge1[ 1 ], _edge1[ 2 ] ) *
|
|
146
|
+
Math.hypot( _edge2[ 0 ], _edge2[ 1 ], _edge2[ 2 ] ) *
|
|
147
|
+
Math.hypot( _scaledDir[ 0 ], _scaledDir[ 1 ], _scaledDir[ 2 ] );
|
|
148
|
+
|
|
149
|
+
if ( Math.abs( det ) <= RAY_EPSILON * determinantScale ) return - 1.0;
|
|
150
|
+
|
|
151
|
+
const invDet = 1.0 / det;
|
|
152
|
+
sub( _tvec, orig, v1 );
|
|
153
|
+
const translationScale = Math.max( Math.abs( _tvec[ 0 ] ), Math.abs( _tvec[ 1 ] ), Math.abs( _tvec[ 2 ] ) );
|
|
154
|
+
|
|
155
|
+
if ( Number.isFinite( translationScale ) === false ) return - 1.0;
|
|
156
|
+
|
|
157
|
+
if ( translationScale !== 0 ) {
|
|
158
|
+
|
|
159
|
+
_tvec[ 0 ] /= translationScale; _tvec[ 1 ] /= translationScale; _tvec[ 2 ] /= translationScale;
|
|
160
|
+
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const u = dot( _tvec, _pvec ) * invDet * translationScale / edge1Scale;
|
|
164
|
+
if ( u < - RAY_EPSILON || u > 1.0 + RAY_EPSILON ) return - 1.0;
|
|
165
|
+
cross( _qvec, _tvec, _edge1 );
|
|
166
|
+
const v = dot( _scaledDir, _qvec ) * invDet * translationScale / edge2Scale;
|
|
167
|
+
if ( v < - RAY_EPSILON || u + v > 1.0 + RAY_EPSILON ) return - 1.0;
|
|
168
|
+
const t = dot( _edge2, _qvec ) * invDet * translationScale / dirScale;
|
|
169
|
+
if ( t < - RAY_EPSILON ) return - 1.0;
|
|
170
|
+
|
|
171
|
+
setRayIntersection( vertInter, orig, dir, t );
|
|
172
|
+
|
|
173
|
+
return t;
|
|
174
|
+
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function intersectionRayTriangle( orig, dir, v1, v2, v3, vertInter ) {
|
|
178
|
+
|
|
179
|
+
sub( _edge1, v2, v1 );
|
|
180
|
+
sub( _edge2, v3, v1 );
|
|
181
|
+
cross( _pvec, dir, _edge2 );
|
|
182
|
+
const det = dot( _edge1, _pvec );
|
|
183
|
+
const determinantScale = Math.hypot( _edge1[ 0 ], _edge1[ 1 ], _edge1[ 2 ] ) *
|
|
184
|
+
Math.hypot( _edge2[ 0 ], _edge2[ 1 ], _edge2[ 2 ] ) *
|
|
185
|
+
Math.hypot( dir[ 0 ], dir[ 1 ], dir[ 2 ] );
|
|
186
|
+
const determinantTolerance = RAY_EPSILON * determinantScale;
|
|
187
|
+
if ( Number.isFinite( det ) === false || Number.isFinite( determinantScale ) === false || determinantTolerance === 0 ) {
|
|
188
|
+
|
|
189
|
+
return intersectionRayTriangleScaled( orig, dir, v1, v2, v3, vertInter );
|
|
190
|
+
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if ( Math.abs( det ) <= determinantTolerance ) return - 1.0;
|
|
194
|
+
const invDet = 1.0 / det;
|
|
195
|
+
sub( _tvec, orig, v1 );
|
|
196
|
+
const u = dot( _tvec, _pvec ) * invDet;
|
|
197
|
+
if ( Number.isFinite( u ) === false ) return intersectionRayTriangleScaled( orig, dir, v1, v2, v3, vertInter );
|
|
198
|
+
if ( u < - RAY_EPSILON || u > 1.0 + RAY_EPSILON ) return - 1.0;
|
|
199
|
+
cross( _qvec, _tvec, _edge1 );
|
|
200
|
+
const v = dot( dir, _qvec ) * invDet;
|
|
201
|
+
if ( Number.isFinite( v ) === false ) return intersectionRayTriangleScaled( orig, dir, v1, v2, v3, vertInter );
|
|
202
|
+
if ( v < - RAY_EPSILON || u + v > 1.0 + RAY_EPSILON ) return - 1.0;
|
|
203
|
+
const t = dot( _edge2, _qvec ) * invDet;
|
|
204
|
+
if ( Number.isFinite( t ) === false ) return intersectionRayTriangleScaled( orig, dir, v1, v2, v3, vertInter );
|
|
205
|
+
if ( t < - RAY_EPSILON ) return - 1.0;
|
|
206
|
+
|
|
207
|
+
setRayIntersection( vertInter, orig, dir, t );
|
|
208
|
+
|
|
209
|
+
return t;
|
|
210
|
+
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function distanceSqToSegment( point, v1, v2 ) {
|
|
214
|
+
|
|
215
|
+
const ptx = point[ 0 ] - v1[ 0 ], pty = point[ 1 ] - v1[ 1 ], ptz = point[ 2 ] - v1[ 2 ];
|
|
216
|
+
const vx = v2[ 0 ] - v1[ 0 ], vy = v2[ 1 ] - v1[ 1 ], vz = v2[ 2 ] - v1[ 2 ];
|
|
217
|
+
const lengthSquared = vx * vx + vy * vy + vz * vz;
|
|
218
|
+
if ( lengthSquared === 0 ) return ptx * ptx + pty * pty + ptz * ptz;
|
|
219
|
+
|
|
220
|
+
const t = ( ptx * vx + pty * vy + ptz * vz ) / lengthSquared;
|
|
221
|
+
if ( t < 0 ) return ptx * ptx + pty * pty + ptz * ptz;
|
|
222
|
+
if ( t > 1 ) {
|
|
223
|
+
|
|
224
|
+
const dx = point[ 0 ] - v2[ 0 ], dy = point[ 1 ] - v2[ 1 ], dz = point[ 2 ] - v2[ 2 ];
|
|
225
|
+
return dx * dx + dy * dy + dz * dz;
|
|
226
|
+
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const rx = point[ 0 ] - v1[ 0 ] - t * vx;
|
|
230
|
+
const ry = point[ 1 ] - v1[ 1 ] - t * vy;
|
|
231
|
+
const rz = point[ 2 ] - v1[ 2 ] - t * vz;
|
|
232
|
+
return rx * rx + ry * ry + rz * rz;
|
|
233
|
+
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function distanceSqToTriangle( point, v1, v2, v3 ) {
|
|
237
|
+
|
|
238
|
+
const abx = v2[ 0 ] - v1[ 0 ], aby = v2[ 1 ] - v1[ 1 ], abz = v2[ 2 ] - v1[ 2 ];
|
|
239
|
+
const acx = v3[ 0 ] - v1[ 0 ], acy = v3[ 1 ] - v1[ 1 ], acz = v3[ 2 ] - v1[ 2 ];
|
|
240
|
+
const bcx = v3[ 0 ] - v2[ 0 ], bcy = v3[ 1 ] - v2[ 1 ], bcz = v3[ 2 ] - v2[ 2 ];
|
|
241
|
+
const crossX = aby * acz - abz * acy;
|
|
242
|
+
const crossY = abz * acx - abx * acz;
|
|
243
|
+
const crossZ = abx * acy - aby * acx;
|
|
244
|
+
const areaSquared = crossX * crossX + crossY * crossY + crossZ * crossZ;
|
|
245
|
+
const maxEdgeSquared = Math.max(
|
|
246
|
+
abx * abx + aby * aby + abz * abz,
|
|
247
|
+
acx * acx + acy * acy + acz * acz,
|
|
248
|
+
bcx * bcx + bcy * bcy + bcz * bcz
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
if ( areaSquared <= Number.EPSILON * maxEdgeSquared * maxEdgeSquared ) {
|
|
252
|
+
|
|
253
|
+
return Math.min(
|
|
254
|
+
distanceSqToSegment( point, v1, v2 ),
|
|
255
|
+
distanceSqToSegment( point, v2, v3 ),
|
|
256
|
+
distanceSqToSegment( point, v3, v1 )
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
const apx = point[ 0 ] - v1[ 0 ], apy = point[ 1 ] - v1[ 1 ], apz = point[ 2 ] - v1[ 2 ];
|
|
262
|
+
const d1 = abx * apx + aby * apy + abz * apz;
|
|
263
|
+
const d2 = acx * apx + acy * apy + acz * apz;
|
|
264
|
+
|
|
265
|
+
if ( d1 <= 0 && d2 <= 0 ) return apx * apx + apy * apy + apz * apz;
|
|
266
|
+
|
|
267
|
+
const bpx = point[ 0 ] - v2[ 0 ], bpy = point[ 1 ] - v2[ 1 ], bpz = point[ 2 ] - v2[ 2 ];
|
|
268
|
+
const d3 = abx * bpx + aby * bpy + abz * bpz;
|
|
269
|
+
const d4 = acx * bpx + acy * bpy + acz * bpz;
|
|
270
|
+
|
|
271
|
+
if ( d3 >= 0 && d4 <= d3 ) return bpx * bpx + bpy * bpy + bpz * bpz;
|
|
272
|
+
|
|
273
|
+
const vc = d1 * d4 - d3 * d2;
|
|
274
|
+
|
|
275
|
+
if ( vc <= 0 && d1 >= 0 && d3 <= 0 ) {
|
|
276
|
+
|
|
277
|
+
const v = d1 / ( d1 - d3 );
|
|
278
|
+
const dx = apx - abx * v, dy = apy - aby * v, dz = apz - abz * v;
|
|
279
|
+
return dx * dx + dy * dy + dz * dz;
|
|
280
|
+
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
const cpx = point[ 0 ] - v3[ 0 ], cpy = point[ 1 ] - v3[ 1 ], cpz = point[ 2 ] - v3[ 2 ];
|
|
284
|
+
const d5 = abx * cpx + aby * cpy + abz * cpz;
|
|
285
|
+
const d6 = acx * cpx + acy * cpy + acz * cpz;
|
|
286
|
+
|
|
287
|
+
if ( d6 >= 0 && d5 <= d6 ) return cpx * cpx + cpy * cpy + cpz * cpz;
|
|
288
|
+
|
|
289
|
+
const vb = d5 * d2 - d1 * d6;
|
|
290
|
+
|
|
291
|
+
if ( vb <= 0 && d2 >= 0 && d6 <= 0 ) {
|
|
292
|
+
|
|
293
|
+
const w = d2 / ( d2 - d6 );
|
|
294
|
+
const dx = apx - acx * w, dy = apy - acy * w, dz = apz - acz * w;
|
|
295
|
+
return dx * dx + dy * dy + dz * dz;
|
|
296
|
+
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
const va = d3 * d6 - d5 * d4;
|
|
300
|
+
|
|
301
|
+
if ( va <= 0 && d4 - d3 >= 0 && d5 - d6 >= 0 ) {
|
|
302
|
+
|
|
303
|
+
const edgeX = v3[ 0 ] - v2[ 0 ], edgeY = v3[ 1 ] - v2[ 1 ], edgeZ = v3[ 2 ] - v2[ 2 ];
|
|
304
|
+
const w = ( d4 - d3 ) / ( d4 - d3 + d5 - d6 );
|
|
305
|
+
const dx = bpx - edgeX * w, dy = bpy - edgeY * w, dz = bpz - edgeZ * w;
|
|
306
|
+
return dx * dx + dy * dy + dz * dz;
|
|
307
|
+
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
const denominator = va + vb + vc;
|
|
311
|
+
const inverse = 1.0 / denominator;
|
|
312
|
+
const v = vb * inverse;
|
|
313
|
+
const w = vc * inverse;
|
|
314
|
+
const dx = apx - abx * v - acx * w;
|
|
315
|
+
const dy = apy - aby * v - acy * w;
|
|
316
|
+
const dz = apz - abz * v - acz * w;
|
|
317
|
+
return dx * dx + dy * dy + dz * dz;
|
|
318
|
+
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
function triangleInsideSphere( point, radiusSquared, v1, v2, v3 ) {
|
|
322
|
+
|
|
323
|
+
return distanceSqToTriangle( point, v1, v2, v3 ) < radiusSquared;
|
|
324
|
+
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function falloff( dist ) {
|
|
328
|
+
|
|
329
|
+
const d2 = dist * dist;
|
|
330
|
+
return 3.0 * d2 * d2 - 4.0 * d2 * dist + 1.0;
|
|
331
|
+
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export {
|
|
335
|
+
TRI_INDEX,
|
|
336
|
+
MAX_FLAG,
|
|
337
|
+
getMemory,
|
|
338
|
+
replaceElement,
|
|
339
|
+
removeElement,
|
|
340
|
+
tidy,
|
|
341
|
+
sqrDist,
|
|
342
|
+
intersectionRayTriangle,
|
|
343
|
+
triangleInsideSphere,
|
|
344
|
+
falloff
|
|
345
|
+
};
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
Color,
|
|
5
5
|
DynamicDrawUsage,
|
|
6
6
|
Matrix4,
|
|
7
|
+
Matrix3,
|
|
7
8
|
Mesh,
|
|
8
9
|
MeshStandardMaterial,
|
|
9
10
|
Vector3
|
|
@@ -47,6 +48,10 @@ function TubePainter() {
|
|
|
47
48
|
const mesh = new Mesh( geometry, material );
|
|
48
49
|
mesh.frustumCulled = false;
|
|
49
50
|
|
|
51
|
+
const normalMatrix = new Matrix3();
|
|
52
|
+
const normalMatrix1 = new Matrix3();
|
|
53
|
+
const normalMatrix2 = new Matrix3();
|
|
54
|
+
|
|
50
55
|
//
|
|
51
56
|
|
|
52
57
|
function getPoints( size ) {
|
|
@@ -93,6 +98,8 @@ function TubePainter() {
|
|
|
93
98
|
const latSegments = 4;
|
|
94
99
|
const directionSign = isEndCap ? - 1 : 1;
|
|
95
100
|
|
|
101
|
+
normalMatrix.getNormalMatrix( matrix );
|
|
102
|
+
|
|
96
103
|
for ( let lat = 0; lat < latSegments; lat ++ ) {
|
|
97
104
|
|
|
98
105
|
const phi1 = ( lat / latSegments ) * Math.PI * 0.5;
|
|
@@ -130,9 +137,9 @@ function TubePainter() {
|
|
|
130
137
|
vector4.set( x4, y4, z2 ).applyMatrix4( matrix ).add( position );
|
|
131
138
|
|
|
132
139
|
// First triangle
|
|
133
|
-
normal.set( x1, y1, z1 ).
|
|
134
|
-
vector.set( x2, y2, z1 ).
|
|
135
|
-
side.set( x3, y3, z2 ).
|
|
140
|
+
normal.set( x1, y1, z1 ).applyNormalMatrix( normalMatrix );
|
|
141
|
+
vector.set( x2, y2, z1 ).applyNormalMatrix( normalMatrix );
|
|
142
|
+
side.set( x3, y3, z2 ).applyNormalMatrix( normalMatrix );
|
|
136
143
|
|
|
137
144
|
if ( isEndCap ) {
|
|
138
145
|
|
|
@@ -165,9 +172,9 @@ function TubePainter() {
|
|
|
165
172
|
// Second triangle
|
|
166
173
|
if ( r2 > 0.001 ) {
|
|
167
174
|
|
|
168
|
-
normal.set( x2, y2, z1 ).
|
|
169
|
-
vector.set( x4, y4, z2 ).
|
|
170
|
-
side.set( x3, y3, z2 ).
|
|
175
|
+
normal.set( x2, y2, z1 ).applyNormalMatrix( normalMatrix );
|
|
176
|
+
vector.set( x4, y4, z2 ).applyNormalMatrix( normalMatrix );
|
|
177
|
+
side.set( x3, y3, z2 ).applyNormalMatrix( normalMatrix );
|
|
171
178
|
|
|
172
179
|
if ( isEndCap ) {
|
|
173
180
|
|
|
@@ -216,6 +223,8 @@ function TubePainter() {
|
|
|
216
223
|
const radius = 0.01 * capSize;
|
|
217
224
|
const latSegments = 4;
|
|
218
225
|
|
|
226
|
+
normalMatrix.getNormalMatrix( matrix );
|
|
227
|
+
|
|
219
228
|
let count = endCapStartIndex;
|
|
220
229
|
|
|
221
230
|
for ( let lat = 0; lat < latSegments; lat ++ ) {
|
|
@@ -255,9 +264,9 @@ function TubePainter() {
|
|
|
255
264
|
vector4.set( x4, y4, z2 ).applyMatrix4( matrix ).add( position );
|
|
256
265
|
|
|
257
266
|
// Transform normals to world space
|
|
258
|
-
normal.set( x1, y1, z1 ).
|
|
259
|
-
vector.set( x2, y2, z1 ).
|
|
260
|
-
side.set( x3, y3, z2 ).
|
|
267
|
+
normal.set( x1, y1, z1 ).applyNormalMatrix( normalMatrix );
|
|
268
|
+
vector.set( x2, y2, z1 ).applyNormalMatrix( normalMatrix );
|
|
269
|
+
side.set( x3, y3, z2 ).applyNormalMatrix( normalMatrix );
|
|
261
270
|
|
|
262
271
|
// First triangle
|
|
263
272
|
vector1.toArray( positions.array, count * 3 );
|
|
@@ -277,9 +286,9 @@ function TubePainter() {
|
|
|
277
286
|
// Second triangle
|
|
278
287
|
if ( r2 > 0.001 ) {
|
|
279
288
|
|
|
280
|
-
normal.set( x2, y2, z1 ).
|
|
281
|
-
vector.set( x4, y4, z2 ).
|
|
282
|
-
side.set( x3, y3, z2 ).
|
|
289
|
+
normal.set( x2, y2, z1 ).applyNormalMatrix( normalMatrix );
|
|
290
|
+
vector.set( x4, y4, z2 ).applyNormalMatrix( normalMatrix );
|
|
291
|
+
side.set( x3, y3, z2 ).applyNormalMatrix( normalMatrix );
|
|
283
292
|
|
|
284
293
|
vector2.toArray( positions.array, count * 3 );
|
|
285
294
|
vector4.toArray( positions.array, ( count + 1 ) * 3 );
|
|
@@ -316,6 +325,9 @@ function TubePainter() {
|
|
|
316
325
|
const points1 = getPoints( size1 );
|
|
317
326
|
const points2 = getPoints( size2 );
|
|
318
327
|
|
|
328
|
+
normalMatrix1.getNormalMatrix( matrix1 );
|
|
329
|
+
normalMatrix2.getNormalMatrix( matrix2 );
|
|
330
|
+
|
|
319
331
|
for ( let i = 0, il = points2.length; i < il; i ++ ) {
|
|
320
332
|
|
|
321
333
|
const vertex1_2 = points2[ i ];
|
|
@@ -336,10 +348,10 @@ function TubePainter() {
|
|
|
336
348
|
vector3.toArray( positions.array, ( count + 4 ) * 3 );
|
|
337
349
|
vector4.toArray( positions.array, ( count + 5 ) * 3 );
|
|
338
350
|
|
|
339
|
-
vector1.copy( vertex1_2 ).
|
|
340
|
-
vector2.copy( vertex2_2 ).
|
|
341
|
-
vector3.copy( vertex2_1 ).
|
|
342
|
-
vector4.copy( vertex1_1 ).
|
|
351
|
+
vector1.copy( vertex1_2 ).applyNormalMatrix( normalMatrix2 );
|
|
352
|
+
vector2.copy( vertex2_2 ).applyNormalMatrix( normalMatrix2 );
|
|
353
|
+
vector3.copy( vertex2_1 ).applyNormalMatrix( normalMatrix1 );
|
|
354
|
+
vector4.copy( vertex1_1 ).applyNormalMatrix( normalMatrix1 );
|
|
343
355
|
|
|
344
356
|
vector1.toArray( normals.array, ( count + 0 ) * 3 );
|
|
345
357
|
vector2.toArray( normals.array, ( count + 1 ) * 3 );
|
|
@@ -93,6 +93,30 @@ class VolumeSlice {
|
|
|
93
93
|
*/
|
|
94
94
|
this.ctxBuffer;
|
|
95
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Width of slice in the original coordinate system, corresponds to the width of the buffer canvas.
|
|
98
|
+
*
|
|
99
|
+
* @type {number}
|
|
100
|
+
* @default 0
|
|
101
|
+
*/
|
|
102
|
+
this.iLength = 0;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Height of slice in the original coordinate system, corresponds to the height of the buffer canvas.
|
|
106
|
+
*
|
|
107
|
+
* @type {number}
|
|
108
|
+
* @default 0
|
|
109
|
+
*/
|
|
110
|
+
this.jLength = 0;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Function that allow the slice to access right data.
|
|
114
|
+
*
|
|
115
|
+
* @type {?Function}
|
|
116
|
+
* @see {@link Volume#extractPerpendicularPlane}
|
|
117
|
+
*/
|
|
118
|
+
this.sliceAccess = null;
|
|
119
|
+
|
|
96
120
|
this.updateGeometry();
|
|
97
121
|
|
|
98
122
|
|
|
@@ -120,30 +144,6 @@ class VolumeSlice {
|
|
|
120
144
|
this.geometryNeedsUpdate = true;
|
|
121
145
|
this.repaint();
|
|
122
146
|
|
|
123
|
-
/**
|
|
124
|
-
* Width of slice in the original coordinate system, corresponds to the width of the buffer canvas.
|
|
125
|
-
*
|
|
126
|
-
* @type {number}
|
|
127
|
-
* @default 0
|
|
128
|
-
*/
|
|
129
|
-
this.iLength = 0;
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Height of slice in the original coordinate system, corresponds to the height of the buffer canvas.
|
|
133
|
-
*
|
|
134
|
-
* @type {number}
|
|
135
|
-
* @default 0
|
|
136
|
-
*/
|
|
137
|
-
this.jLength = 0;
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Function that allow the slice to access right data.
|
|
141
|
-
*
|
|
142
|
-
* @type {?Function}
|
|
143
|
-
* @see {@link Volume#extractPerpendicularPlane}
|
|
144
|
-
*/
|
|
145
|
-
this.sliceAccess = null;
|
|
146
|
-
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
/**
|