@plastic-software/three 0.178.0 → 0.180.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/README.md +1 -1
- package/build/three.cjs +950 -230
- package/build/three.core.js +754 -138
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +197 -96
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +99 -25
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +4586 -1499
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +4544 -1499
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +2 -3
- package/examples/jsm/capabilities/WebGPU.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +7 -7
- package/examples/jsm/controls/DragControls.js +6 -56
- package/examples/jsm/controls/FirstPersonControls.js +2 -2
- package/examples/jsm/controls/PointerLockControls.js +0 -8
- package/examples/jsm/csm/CSMShadowNode.js +4 -4
- package/examples/jsm/environments/RoomEnvironment.js +8 -3
- package/examples/jsm/exporters/GLTFExporter.js +30 -22
- package/examples/jsm/exporters/KTX2Exporter.js +4 -2
- package/examples/jsm/exporters/PLYExporter.js +1 -1
- package/examples/jsm/exporters/USDZExporter.js +676 -299
- package/examples/jsm/geometries/RoundedBoxGeometry.js +47 -8
- package/examples/jsm/interactive/HTMLMesh.js +5 -3
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/libs/meshopt_decoder.module.js +75 -58
- package/examples/jsm/lights/LightProbeGenerator.js +14 -3
- package/examples/jsm/lines/Line2.js +3 -3
- package/examples/jsm/lines/LineGeometry.js +1 -1
- package/examples/jsm/lines/LineSegments2.js +2 -2
- package/examples/jsm/lines/Wireframe.js +2 -2
- package/examples/jsm/lines/WireframeGeometry2.js +1 -1
- package/examples/jsm/lines/webgpu/LineSegments2.js +1 -1
- package/examples/jsm/lines/webgpu/Wireframe.js +1 -1
- package/examples/jsm/loaders/ColladaLoader.js +1 -1
- package/examples/jsm/loaders/EXRLoader.js +210 -22
- package/examples/jsm/loaders/FBXLoader.js +1 -1
- package/examples/jsm/loaders/GLTFLoader.js +9 -5
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +5 -5
- package/examples/jsm/loaders/HDRLoader.js +486 -0
- package/examples/jsm/loaders/KTX2Loader.js +112 -32
- package/examples/jsm/loaders/MaterialXLoader.js +212 -30
- package/examples/jsm/loaders/RGBELoader.js +7 -473
- package/examples/jsm/loaders/TTFLoader.js +13 -1
- package/examples/jsm/loaders/USDLoader.js +219 -0
- package/examples/jsm/loaders/USDZLoader.js +4 -892
- package/examples/jsm/loaders/UltraHDRLoader.js +1 -1
- package/examples/jsm/loaders/lwo/IFFParser.js +1 -1
- package/examples/jsm/loaders/usd/USDAParser.js +741 -0
- package/examples/jsm/loaders/usd/USDCParser.js +17 -0
- package/examples/jsm/materials/WoodNodeMaterial.js +533 -0
- package/examples/jsm/math/ColorSpaces.js +19 -1
- package/examples/jsm/math/ConvexHull.js +2 -2
- package/examples/jsm/math/Lut.js +2 -2
- package/examples/jsm/misc/MD2CharacterComplex.js +1 -1
- package/examples/jsm/misc/ProgressiveLightMap.js +1 -1
- package/examples/jsm/misc/Volume.js +1 -1
- package/examples/jsm/objects/LensflareMesh.js +3 -3
- package/examples/jsm/objects/SkyMesh.js +2 -2
- package/examples/jsm/physics/RapierPhysics.js +14 -5
- package/examples/jsm/postprocessing/GTAOPass.js +10 -9
- package/examples/jsm/postprocessing/OutlinePass.js +17 -17
- package/examples/jsm/postprocessing/SSAOPass.js +10 -9
- package/examples/jsm/postprocessing/SSRPass.js +37 -8
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +11 -2
- package/examples/jsm/transpiler/GLSLDecoder.js +23 -20
- package/examples/jsm/transpiler/TSLEncoder.js +2 -10
- package/examples/jsm/transpiler/WGSLEncoder.js +24 -0
- package/examples/jsm/tsl/display/AnamorphicNode.js +27 -4
- package/examples/jsm/tsl/display/BloomNode.js +7 -6
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +2 -1
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +439 -90
- package/examples/jsm/tsl/display/GTAONode.js +8 -0
- package/examples/jsm/tsl/display/GaussianBlurNode.js +51 -41
- package/examples/jsm/tsl/display/OutlineNode.js +2 -2
- package/examples/jsm/tsl/display/SSRNode.js +180 -65
- package/examples/jsm/tsl/display/{TRAAPassNode.js → TRAANode.js} +181 -172
- package/examples/jsm/tsl/display/boxBlur.js +64 -0
- package/examples/jsm/tsl/display/hashBlur.js +15 -18
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +1 -1
- package/examples/jsm/utils/BufferGeometryUtils.js +1 -1
- package/examples/jsm/utils/ShadowMapViewerGPU.js +12 -5
- package/examples/jsm/webxr/OculusHandModel.js +1 -1
- package/package.json +1 -1
- package/src/Three.Core.js +2 -0
- package/src/Three.TSL.js +98 -24
- package/src/animation/AnimationClip.js +17 -2
- package/src/animation/KeyframeTrack.js +1 -1
- package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
- package/src/animation/tracks/StringKeyframeTrack.js +1 -1
- package/src/cameras/Camera.js +14 -0
- package/src/cameras/OrthographicCamera.js +1 -1
- package/src/cameras/PerspectiveCamera.js +1 -1
- package/src/constants.js +11 -3
- package/src/core/BufferGeometry.js +2 -2
- package/{examples/jsm/misc → src/core}/Timer.js +4 -42
- package/src/extras/PMREMGenerator.js +11 -0
- package/src/extras/TextureUtils.js +2 -1
- package/src/extras/lib/earcut.js +1 -1
- package/src/helpers/CameraHelper.js +41 -11
- package/src/helpers/SkeletonHelper.js +35 -6
- package/src/lights/LightShadow.js +21 -8
- package/src/lights/PointLightShadow.js +1 -1
- package/src/lights/webgpu/ProjectorLight.js +1 -1
- package/src/loaders/FileLoader.js +25 -2
- package/src/loaders/ImageBitmapLoader.js +23 -0
- package/src/loaders/Loader.js +14 -0
- package/src/loaders/LoadingManager.js +23 -0
- package/src/materials/Material.js +12 -0
- package/src/materials/MeshBasicMaterial.js +1 -1
- package/src/materials/MeshDistanceMaterial.js +1 -1
- package/src/materials/nodes/Line2NodeMaterial.js +0 -8
- package/src/materials/nodes/NodeMaterial.js +1 -1
- package/src/materials/nodes/PointsNodeMaterial.js +86 -28
- package/src/materials/nodes/SpriteNodeMaterial.js +3 -15
- package/src/materials/nodes/manager/NodeMaterialObserver.js +87 -2
- package/src/math/ColorManagement.js +7 -1
- package/src/math/Frustum.js +19 -8
- package/src/math/FrustumArray.js +10 -5
- package/src/math/Line3.js +129 -2
- package/src/math/Matrix4.js +48 -27
- package/src/math/Spherical.js +2 -2
- package/src/nodes/Nodes.js +4 -0
- package/src/nodes/TSL.js +4 -0
- package/src/nodes/accessors/BufferNode.js +1 -1
- package/src/nodes/accessors/Camera.js +142 -16
- package/src/nodes/accessors/ClippingNode.js +6 -5
- package/src/nodes/accessors/CubeTextureNode.js +2 -2
- package/src/nodes/accessors/InstanceNode.js +3 -1
- package/src/nodes/accessors/Normal.js +11 -11
- package/src/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/ReferenceBaseNode.js +1 -1
- package/src/nodes/accessors/ReferenceNode.js +19 -4
- package/src/nodes/accessors/SceneNode.js +1 -1
- package/src/nodes/accessors/StorageTextureNode.js +1 -1
- package/src/nodes/accessors/Texture3DNode.js +13 -0
- package/src/nodes/accessors/TextureNode.js +83 -19
- package/src/nodes/code/FunctionCallNode.js +19 -0
- package/src/nodes/code/FunctionNode.js +23 -0
- package/src/nodes/core/ArrayNode.js +12 -0
- package/src/nodes/core/AssignNode.js +6 -2
- package/src/nodes/core/ContextNode.js +44 -1
- package/src/nodes/core/Node.js +30 -22
- package/src/nodes/core/NodeBuilder.js +71 -32
- package/src/nodes/core/NodeFrame.js +1 -1
- package/src/nodes/core/NodeUniform.js +1 -1
- package/src/nodes/core/NodeUtils.js +5 -3
- package/src/nodes/core/StackNode.js +71 -4
- package/src/nodes/core/StructNode.js +5 -5
- package/src/nodes/core/StructTypeNode.js +1 -0
- package/src/nodes/core/SubBuildNode.js +2 -2
- package/src/nodes/core/UniformNode.js +79 -14
- package/src/nodes/core/VarNode.js +83 -15
- package/src/nodes/display/FrontFacingNode.js +4 -8
- package/src/nodes/display/PassNode.js +148 -2
- package/src/nodes/display/ScreenNode.js +42 -13
- package/src/nodes/display/ViewportDepthTextureNode.js +16 -4
- package/src/nodes/display/ViewportSharedTextureNode.js +12 -0
- package/src/nodes/display/ViewportTextureNode.js +94 -4
- package/src/nodes/functions/PhysicalLightingModel.js +2 -2
- package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
- package/src/nodes/gpgpu/ComputeNode.js +67 -23
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +430 -0
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +28 -3
- package/src/nodes/lighting/LightsNode.js +1 -1
- package/src/nodes/lighting/ProjectorLightNode.js +19 -6
- package/src/nodes/lighting/ShadowFilterNode.js +1 -1
- package/src/nodes/materialx/MaterialXNodes.js +131 -2
- package/src/nodes/materialx/lib/mx_noise.js +165 -1
- package/src/nodes/math/BitcastNode.js +156 -0
- package/src/nodes/math/ConditionalNode.js +19 -3
- package/src/nodes/math/MathNode.js +72 -60
- package/src/nodes/math/OperatorNode.js +26 -25
- package/src/nodes/tsl/TSLCore.js +477 -142
- package/src/nodes/utils/DebugNode.js +1 -1
- package/src/nodes/utils/EventNode.js +83 -0
- package/src/nodes/utils/JoinNode.js +3 -1
- package/src/nodes/utils/MemberNode.js +58 -7
- package/src/nodes/utils/RTTNode.js +10 -1
- package/src/nodes/utils/ReflectorNode.js +51 -7
- package/src/nodes/utils/SampleNode.js +12 -2
- package/src/nodes/utils/SplitNode.js +11 -0
- package/src/nodes/utils/Timer.js +0 -47
- package/src/objects/BatchedMesh.js +6 -4
- package/src/objects/LOD.js +1 -1
- package/src/objects/Sprite.js +2 -2
- package/src/renderers/WebGLRenderer.js +21 -31
- package/src/renderers/common/Attributes.js +1 -1
- package/src/renderers/common/Backend.js +19 -1
- package/src/renderers/common/Bindings.js +21 -18
- package/src/renderers/common/ChainMap.js +1 -1
- package/src/renderers/common/Color4.js +2 -2
- package/src/renderers/common/DataMap.js +1 -1
- package/src/renderers/common/Pipelines.js +1 -1
- package/src/renderers/common/PostProcessing.js +60 -5
- package/src/renderers/common/RenderContext.js +2 -2
- package/src/renderers/common/RenderObject.js +14 -2
- package/src/renderers/common/Renderer.js +55 -32
- package/src/renderers/common/SampledTexture.js +4 -72
- package/src/renderers/common/Sampler.js +91 -0
- package/src/renderers/common/Storage3DTexture.js +21 -0
- package/src/renderers/common/StorageArrayTexture.js +21 -0
- package/src/renderers/common/StorageTexture.js +19 -0
- package/src/renderers/common/Textures.js +52 -14
- package/src/renderers/common/TimestampQueryPool.js +3 -3
- package/src/renderers/common/XRManager.js +51 -17
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/NodeLibrary.js +5 -5
- package/src/renderers/common/nodes/NodeSampledTexture.js +0 -12
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +21 -11
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +11 -2
- package/src/renderers/webgl/WebGLCapabilities.js +2 -2
- package/src/renderers/webgl/WebGLMaterials.js +6 -6
- package/src/renderers/webgl/WebGLProgram.js +24 -18
- package/src/renderers/webgl/WebGLPrograms.js +4 -4
- package/src/renderers/webgl/WebGLShadowMap.js +11 -1
- package/src/renderers/webgl/WebGLTextures.js +20 -7
- package/src/renderers/webgl/WebGLUtils.js +3 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +207 -146
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +112 -19
- package/src/renderers/webgl-fallback/utils/WebGLState.js +1 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +52 -3
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +9 -10
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +3 -2
- package/src/renderers/webgpu/WebGPUBackend.js +87 -44
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +169 -99
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +35 -31
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -2
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +10 -19
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +120 -84
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +3 -3
- package/src/renderers/webgpu/utils/WebGPUUtils.js +2 -17
- package/src/renderers/webxr/WebXRDepthSensing.js +6 -10
- package/src/renderers/webxr/WebXRManager.js +86 -11
- package/src/textures/ExternalTexture.js +56 -0
- package/src/textures/FramebufferTexture.js +2 -2
- package/src/textures/Source.js +12 -2
- package/src/textures/VideoTexture.js +27 -2
- package/examples/jsm/loaders/RGBMLoader.js +0 -1148
|
@@ -1,18 +1,36 @@
|
|
|
1
1
|
import SpriteNodeMaterial from './SpriteNodeMaterial.js';
|
|
2
|
-
import {
|
|
2
|
+
import { viewportSize, screenDPR } from '../../nodes/display/ScreenNode.js';
|
|
3
3
|
import { positionGeometry, positionLocal, positionView } from '../../nodes/accessors/Position.js';
|
|
4
4
|
import { modelViewMatrix } from '../../nodes/accessors/ModelNode.js';
|
|
5
5
|
import { materialPointSize } from '../../nodes/accessors/MaterialNode.js';
|
|
6
6
|
import { rotate } from '../../nodes/utils/RotateNode.js';
|
|
7
|
-
import { float, vec2, vec3, vec4 } from '../../nodes/tsl/TSLBase.js';
|
|
7
|
+
import { float, uniform, vec2, vec3, vec4 } from '../../nodes/tsl/TSLBase.js';
|
|
8
8
|
|
|
9
9
|
import { PointsMaterial } from '../PointsMaterial.js';
|
|
10
|
+
import { Vector2 } from '../../math/Vector2.js';
|
|
10
11
|
|
|
11
12
|
const _defaultValues = /*@__PURE__*/ new PointsMaterial();
|
|
13
|
+
const _size = /*@__PURE__*/ new Vector2();
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Node material version of {@link PointsMaterial}.
|
|
15
17
|
*
|
|
18
|
+
* This material can be used in two ways:
|
|
19
|
+
*
|
|
20
|
+
* - By rendering point primitives with {@link Points}. Since WebGPU only supports point primitives
|
|
21
|
+
* with a pixel size of `1`, it's not possible to define a size.
|
|
22
|
+
*
|
|
23
|
+
* ```js
|
|
24
|
+
* const pointCloud = new THREE.Points( geometry, new THREE.PointsNodeMaterial() );
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* - By rendering point primitives with {@link Sprites}. In this case, size is honored,
|
|
28
|
+
* see {@link PointsNodeMaterial#sizeNode}.
|
|
29
|
+
*
|
|
30
|
+
* ```js
|
|
31
|
+
* const instancedPoints = new THREE.Sprite( new THREE.PointsNodeMaterial( { positionNode: instancedBufferAttribute( positionAttribute ) } ) );
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
16
34
|
* @augments SpriteNodeMaterial
|
|
17
35
|
*/
|
|
18
36
|
class PointsNodeMaterial extends SpriteNodeMaterial {
|
|
@@ -35,6 +53,11 @@ class PointsNodeMaterial extends SpriteNodeMaterial {
|
|
|
35
53
|
/**
|
|
36
54
|
* This node property provides an additional way to set the point size.
|
|
37
55
|
*
|
|
56
|
+
* Note that WebGPU only supports point primitives with 1 pixel size. Consequently,
|
|
57
|
+
* this node has no effect when the material is used with {@link Points} and a WebGPU
|
|
58
|
+
* backend. If an application wants to render points with a size larger than 1 pixel,
|
|
59
|
+
* the material should be used with {@link Sprite} and instancing.
|
|
60
|
+
*
|
|
38
61
|
* @type {?Node<vec2>}
|
|
39
62
|
* @default null
|
|
40
63
|
*/
|
|
@@ -63,68 +86,95 @@ class PointsNodeMaterial extends SpriteNodeMaterial {
|
|
|
63
86
|
|
|
64
87
|
}
|
|
65
88
|
|
|
66
|
-
|
|
89
|
+
setupVertexSprite( builder ) {
|
|
90
|
+
|
|
91
|
+
const { material, camera } = builder;
|
|
92
|
+
|
|
93
|
+
const { rotationNode, scaleNode, sizeNode, sizeAttenuation } = this;
|
|
67
94
|
|
|
68
|
-
|
|
95
|
+
let mvp = super.setupVertex( builder );
|
|
69
96
|
|
|
70
97
|
// skip further processing if the material is not a node material
|
|
71
98
|
|
|
72
|
-
if (
|
|
99
|
+
if ( material.isNodeMaterial !== true ) {
|
|
73
100
|
|
|
74
101
|
return mvp;
|
|
75
102
|
|
|
76
103
|
}
|
|
77
104
|
|
|
78
|
-
//
|
|
105
|
+
// point size
|
|
79
106
|
|
|
80
|
-
|
|
107
|
+
let pointSize = sizeNode !== null ? vec2( sizeNode ) : materialPointSize;
|
|
81
108
|
|
|
82
|
-
|
|
83
|
-
const aspect = viewport.z.div( viewport.w );
|
|
109
|
+
pointSize = pointSize.mul( screenDPR );
|
|
84
110
|
|
|
85
|
-
//
|
|
111
|
+
// size attenuation
|
|
86
112
|
|
|
87
|
-
if (
|
|
113
|
+
if ( camera.isPerspectiveCamera && sizeAttenuation === true ) {
|
|
88
114
|
|
|
89
|
-
|
|
115
|
+
// follow WebGLRenderer's implementation, and scale by half the canvas height in logical units
|
|
90
116
|
|
|
91
|
-
|
|
117
|
+
pointSize = pointSize.mul( scale.div( positionView.z.negate() ) );
|
|
92
118
|
|
|
93
119
|
}
|
|
94
120
|
|
|
95
|
-
//
|
|
96
|
-
|
|
97
|
-
let pointSize = sizeNode !== null ? vec2( sizeNode ) : materialPointSize;
|
|
121
|
+
// scale
|
|
98
122
|
|
|
99
|
-
if (
|
|
123
|
+
if ( scaleNode && scaleNode.isNode ) {
|
|
100
124
|
|
|
101
|
-
pointSize = pointSize.mul(
|
|
125
|
+
pointSize = pointSize.mul( vec2( scaleNode ) );
|
|
102
126
|
|
|
103
127
|
}
|
|
104
128
|
|
|
105
|
-
//
|
|
129
|
+
// compute offset
|
|
106
130
|
|
|
107
|
-
|
|
131
|
+
let offset = positionGeometry.xy;
|
|
108
132
|
|
|
109
|
-
|
|
133
|
+
// apply rotation
|
|
134
|
+
|
|
135
|
+
if ( rotationNode && rotationNode.isNode ) {
|
|
136
|
+
|
|
137
|
+
const rotation = float( rotationNode );
|
|
138
|
+
|
|
139
|
+
offset = rotate( offset, rotation );
|
|
110
140
|
|
|
111
141
|
}
|
|
112
142
|
|
|
113
|
-
|
|
143
|
+
// account for point size
|
|
144
|
+
|
|
145
|
+
offset = offset.mul( pointSize );
|
|
146
|
+
|
|
147
|
+
// scale by viewport size
|
|
114
148
|
|
|
115
|
-
|
|
116
|
-
alignedPosition.y.assign( alignedPosition.y.mul( aspect ) );
|
|
149
|
+
offset = offset.div( viewportSize.div( 2 ) );
|
|
117
150
|
|
|
118
|
-
//
|
|
119
|
-
alignedPosition.assign( alignedPosition.mul( mvp.w ) );
|
|
151
|
+
// compensate for the perspective divide
|
|
120
152
|
|
|
121
|
-
|
|
122
|
-
|
|
153
|
+
offset = offset.mul( mvp.w );
|
|
154
|
+
|
|
155
|
+
// add offset
|
|
156
|
+
|
|
157
|
+
mvp = mvp.add( vec4( offset, 0, 0 ) );
|
|
123
158
|
|
|
124
159
|
return mvp;
|
|
125
160
|
|
|
126
161
|
}
|
|
127
162
|
|
|
163
|
+
setupVertex( builder ) {
|
|
164
|
+
|
|
165
|
+
if ( builder.object.isPoints ) {
|
|
166
|
+
|
|
167
|
+
return super.setupVertex( builder );
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
} else {
|
|
171
|
+
|
|
172
|
+
return this.setupVertexSprite( builder );
|
|
173
|
+
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
}
|
|
177
|
+
|
|
128
178
|
/**
|
|
129
179
|
* Whether alpha to coverage should be used or not.
|
|
130
180
|
*
|
|
@@ -150,4 +200,12 @@ class PointsNodeMaterial extends SpriteNodeMaterial {
|
|
|
150
200
|
|
|
151
201
|
}
|
|
152
202
|
|
|
203
|
+
const scale = /*@__PURE__*/ uniform( 1 ).onFrameUpdate( function ( { renderer } ) {
|
|
204
|
+
|
|
205
|
+
const size = renderer.getSize( _size ); // logical units
|
|
206
|
+
|
|
207
|
+
this.value = 0.5 * size.y;
|
|
208
|
+
|
|
209
|
+
} );
|
|
210
|
+
|
|
153
211
|
export default PointsNodeMaterial;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import NodeMaterial from './NodeMaterial.js';
|
|
2
|
-
import { cameraProjectionMatrix } from '../../nodes/accessors/Camera.js';
|
|
3
2
|
import { materialRotation } from '../../nodes/accessors/MaterialNode.js';
|
|
4
3
|
import { modelViewMatrix, modelWorldMatrix } from '../../nodes/accessors/ModelNode.js';
|
|
5
4
|
import { positionGeometry } from '../../nodes/accessors/Position.js';
|
|
@@ -111,9 +110,7 @@ class SpriteNodeMaterial extends NodeMaterial {
|
|
|
111
110
|
|
|
112
111
|
const { object, camera } = builder;
|
|
113
112
|
|
|
114
|
-
const sizeAttenuation = this
|
|
115
|
-
|
|
116
|
-
const { positionNode, rotationNode, scaleNode } = this;
|
|
113
|
+
const { positionNode, rotationNode, scaleNode, sizeAttenuation } = this;
|
|
117
114
|
|
|
118
115
|
const mvPosition = modelViewMatrix.mul( vec3( positionNode || 0 ) );
|
|
119
116
|
|
|
@@ -125,18 +122,9 @@ class SpriteNodeMaterial extends NodeMaterial {
|
|
|
125
122
|
|
|
126
123
|
}
|
|
127
124
|
|
|
128
|
-
if ( sizeAttenuation === false ) {
|
|
129
|
-
|
|
130
|
-
if ( camera.isPerspectiveCamera ) {
|
|
131
|
-
|
|
132
|
-
scale = scale.mul( mvPosition.z.negate() );
|
|
133
|
-
|
|
134
|
-
} else {
|
|
135
|
-
|
|
136
|
-
const orthoScale = float( 2.0 ).div( cameraProjectionMatrix.element( 1 ).element( 1 ) );
|
|
137
|
-
scale = scale.mul( orthoScale.mul( 2 ) );
|
|
125
|
+
if ( camera.isPerspectiveCamera && sizeAttenuation === false ) {
|
|
138
126
|
|
|
139
|
-
|
|
127
|
+
scale = scale.mul( mvPosition.z.negate() );
|
|
140
128
|
|
|
141
129
|
}
|
|
142
130
|
|
|
@@ -55,6 +55,16 @@ const refreshUniforms = [
|
|
|
55
55
|
'transmissionMap'
|
|
56
56
|
];
|
|
57
57
|
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* A WeakMap to cache lights data for node materials.
|
|
61
|
+
* Cache lights data by render ID to avoid unnecessary recalculations.
|
|
62
|
+
*
|
|
63
|
+
* @private
|
|
64
|
+
* @type {WeakMap<LightsNode,Object>}
|
|
65
|
+
*/
|
|
66
|
+
const _lightsCache = new WeakMap();
|
|
67
|
+
|
|
58
68
|
/**
|
|
59
69
|
* This class is used by {@link WebGPURenderer} as management component.
|
|
60
70
|
* It's primary purpose is to determine whether render objects require a
|
|
@@ -196,6 +206,8 @@ class NodeMaterialObserver {
|
|
|
196
206
|
|
|
197
207
|
}
|
|
198
208
|
|
|
209
|
+
data.lights = this.getLightsData( renderObject.lightsNode.getLights() );
|
|
210
|
+
|
|
199
211
|
this.renderObjects.set( renderObject, data );
|
|
200
212
|
|
|
201
213
|
}
|
|
@@ -299,9 +311,10 @@ class NodeMaterialObserver {
|
|
|
299
311
|
* Returns `true` if the given render object has not changed its state.
|
|
300
312
|
*
|
|
301
313
|
* @param {RenderObject} renderObject - The render object.
|
|
314
|
+
* @param {Array<Light>} lightsData - The current material lights.
|
|
302
315
|
* @return {boolean} Whether the given render object has changed its state or not.
|
|
303
316
|
*/
|
|
304
|
-
equals( renderObject ) {
|
|
317
|
+
equals( renderObject, lightsData ) {
|
|
305
318
|
|
|
306
319
|
const { object, material, geometry } = renderObject;
|
|
307
320
|
|
|
@@ -462,6 +475,22 @@ class NodeMaterialObserver {
|
|
|
462
475
|
|
|
463
476
|
}
|
|
464
477
|
|
|
478
|
+
// lights
|
|
479
|
+
|
|
480
|
+
if ( renderObjectData.lights ) {
|
|
481
|
+
|
|
482
|
+
for ( let i = 0; i < lightsData.length; i ++ ) {
|
|
483
|
+
|
|
484
|
+
if ( renderObjectData.lights[ i ].map !== lightsData[ i ].map ) {
|
|
485
|
+
|
|
486
|
+
return false;
|
|
487
|
+
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
}
|
|
493
|
+
|
|
465
494
|
// center
|
|
466
495
|
|
|
467
496
|
if ( renderObjectData.center ) {
|
|
@@ -488,6 +517,61 @@ class NodeMaterialObserver {
|
|
|
488
517
|
|
|
489
518
|
}
|
|
490
519
|
|
|
520
|
+
/**
|
|
521
|
+
* Returns the lights data for the given material lights.
|
|
522
|
+
*
|
|
523
|
+
* @param {Array<Light>} materialLights - The material lights.
|
|
524
|
+
* @return {Array<Object>} The lights data for the given material lights.
|
|
525
|
+
*/
|
|
526
|
+
getLightsData( materialLights ) {
|
|
527
|
+
|
|
528
|
+
const lights = [];
|
|
529
|
+
|
|
530
|
+
for ( const light of materialLights ) {
|
|
531
|
+
|
|
532
|
+
if ( light.isSpotLight === true && light.map !== null ) {
|
|
533
|
+
|
|
534
|
+
// only add lights that have a map
|
|
535
|
+
|
|
536
|
+
lights.push( { map: light.map.version } );
|
|
537
|
+
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
return lights;
|
|
543
|
+
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Returns the lights for the given lights node and render ID.
|
|
548
|
+
*
|
|
549
|
+
* @param {LightsNode} lightsNode - The lights node.
|
|
550
|
+
* @param {number} renderId - The render ID.
|
|
551
|
+
* @return {Array<Object>} The lights for the given lights node and render ID.
|
|
552
|
+
*/
|
|
553
|
+
getLights( lightsNode, renderId ) {
|
|
554
|
+
|
|
555
|
+
if ( _lightsCache.has( lightsNode ) ) {
|
|
556
|
+
|
|
557
|
+
const cached = _lightsCache.get( lightsNode );
|
|
558
|
+
|
|
559
|
+
if ( cached.renderId === renderId ) {
|
|
560
|
+
|
|
561
|
+
return cached.lightsData;
|
|
562
|
+
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
const lightsData = this.getLightsData( lightsNode.getLights() );
|
|
568
|
+
|
|
569
|
+
_lightsCache.set( lightsNode, { renderId, lightsData } );
|
|
570
|
+
|
|
571
|
+
return lightsData;
|
|
572
|
+
|
|
573
|
+
}
|
|
574
|
+
|
|
491
575
|
/**
|
|
492
576
|
* Checks if the given render object requires a refresh.
|
|
493
577
|
*
|
|
@@ -516,7 +600,8 @@ class NodeMaterialObserver {
|
|
|
516
600
|
if ( isStatic || isBundle )
|
|
517
601
|
return false;
|
|
518
602
|
|
|
519
|
-
const
|
|
603
|
+
const lightsData = this.getLights( renderObject.lightsNode, renderId );
|
|
604
|
+
const notEqual = this.equals( renderObject, lightsData ) !== true;
|
|
520
605
|
|
|
521
606
|
return notEqual;
|
|
522
607
|
|
|
@@ -34,7 +34,7 @@ function createColorManagement() {
|
|
|
34
34
|
* - luminanceCoefficients: RGB luminance coefficients
|
|
35
35
|
*
|
|
36
36
|
* Optional:
|
|
37
|
-
* - outputColorSpaceConfig: { drawingBufferColorSpace: ColorSpace }
|
|
37
|
+
* - outputColorSpaceConfig: { drawingBufferColorSpace: ColorSpace, toneMappingMode: 'extended' | 'standard' }
|
|
38
38
|
* - workingColorSpaceConfig: { unpackColorSpace: ColorSpace }
|
|
39
39
|
*
|
|
40
40
|
* Reference:
|
|
@@ -103,6 +103,12 @@ function createColorManagement() {
|
|
|
103
103
|
|
|
104
104
|
},
|
|
105
105
|
|
|
106
|
+
getToneMappingMode: function ( colorSpace ) {
|
|
107
|
+
|
|
108
|
+
return this.spaces[ colorSpace ].outputColorSpaceConfig.toneMappingMode || 'standard';
|
|
109
|
+
|
|
110
|
+
},
|
|
111
|
+
|
|
106
112
|
getLuminanceCoefficients: function ( target, colorSpace = this.workingColorSpace ) {
|
|
107
113
|
|
|
108
114
|
return target.fromArray( this.spaces[ colorSpace ].luminanceCoefficients );
|
package/src/math/Frustum.js
CHANGED
|
@@ -89,9 +89,10 @@ class Frustum {
|
|
|
89
89
|
*
|
|
90
90
|
* @param {Matrix4} m - The projection matrix.
|
|
91
91
|
* @param {(WebGLCoordinateSystem|WebGPUCoordinateSystem)} coordinateSystem - The coordinate system.
|
|
92
|
+
* @param {boolean} [reversedDepth=false] - Whether to use a reversed depth.
|
|
92
93
|
* @return {Frustum} A reference to this frustum.
|
|
93
94
|
*/
|
|
94
|
-
setFromProjectionMatrix( m, coordinateSystem = WebGLCoordinateSystem ) {
|
|
95
|
+
setFromProjectionMatrix( m, coordinateSystem = WebGLCoordinateSystem, reversedDepth = false ) {
|
|
95
96
|
|
|
96
97
|
const planes = this.planes;
|
|
97
98
|
const me = m.elements;
|
|
@@ -104,19 +105,29 @@ class Frustum {
|
|
|
104
105
|
planes[ 1 ].setComponents( me3 + me0, me7 + me4, me11 + me8, me15 + me12 ).normalize();
|
|
105
106
|
planes[ 2 ].setComponents( me3 + me1, me7 + me5, me11 + me9, me15 + me13 ).normalize();
|
|
106
107
|
planes[ 3 ].setComponents( me3 - me1, me7 - me5, me11 - me9, me15 - me13 ).normalize();
|
|
107
|
-
planes[ 4 ].setComponents( me3 - me2, me7 - me6, me11 - me10, me15 - me14 ).normalize();
|
|
108
108
|
|
|
109
|
-
if (
|
|
109
|
+
if ( reversedDepth ) {
|
|
110
110
|
|
|
111
|
-
planes[
|
|
111
|
+
planes[ 4 ].setComponents( me2, me6, me10, me14 ).normalize(); // far
|
|
112
|
+
planes[ 5 ].setComponents( me3 - me2, me7 - me6, me11 - me10, me15 - me14 ).normalize(); // near
|
|
112
113
|
|
|
113
|
-
} else
|
|
114
|
+
} else {
|
|
114
115
|
|
|
115
|
-
planes[
|
|
116
|
+
planes[ 4 ].setComponents( me3 - me2, me7 - me6, me11 - me10, me15 - me14 ).normalize(); // far
|
|
116
117
|
|
|
117
|
-
|
|
118
|
+
if ( coordinateSystem === WebGLCoordinateSystem ) {
|
|
119
|
+
|
|
120
|
+
planes[ 5 ].setComponents( me3 + me2, me7 + me6, me11 + me10, me15 + me14 ).normalize(); // near
|
|
121
|
+
|
|
122
|
+
} else if ( coordinateSystem === WebGPUCoordinateSystem ) {
|
|
118
123
|
|
|
119
|
-
|
|
124
|
+
planes[ 5 ].setComponents( me2, me6, me10, me14 ).normalize(); // near
|
|
125
|
+
|
|
126
|
+
} else {
|
|
127
|
+
|
|
128
|
+
throw new Error( 'THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: ' + coordinateSystem );
|
|
129
|
+
|
|
130
|
+
}
|
|
120
131
|
|
|
121
132
|
}
|
|
122
133
|
|
package/src/math/FrustumArray.js
CHANGED
|
@@ -54,7 +54,8 @@ class FrustumArray {
|
|
|
54
54
|
|
|
55
55
|
_frustum.setFromProjectionMatrix(
|
|
56
56
|
_projScreenMatrix,
|
|
57
|
-
|
|
57
|
+
camera.coordinateSystem,
|
|
58
|
+
camera.reversedDepth
|
|
58
59
|
);
|
|
59
60
|
|
|
60
61
|
if ( _frustum.intersectsObject( object ) ) {
|
|
@@ -96,7 +97,8 @@ class FrustumArray {
|
|
|
96
97
|
|
|
97
98
|
_frustum.setFromProjectionMatrix(
|
|
98
99
|
_projScreenMatrix,
|
|
99
|
-
|
|
100
|
+
camera.coordinateSystem,
|
|
101
|
+
camera.reversedDepth
|
|
100
102
|
);
|
|
101
103
|
|
|
102
104
|
if ( _frustum.intersectsSprite( sprite ) ) {
|
|
@@ -138,7 +140,8 @@ class FrustumArray {
|
|
|
138
140
|
|
|
139
141
|
_frustum.setFromProjectionMatrix(
|
|
140
142
|
_projScreenMatrix,
|
|
141
|
-
|
|
143
|
+
camera.coordinateSystem,
|
|
144
|
+
camera.reversedDepth
|
|
142
145
|
);
|
|
143
146
|
|
|
144
147
|
if ( _frustum.intersectsSphere( sphere ) ) {
|
|
@@ -180,7 +183,8 @@ class FrustumArray {
|
|
|
180
183
|
|
|
181
184
|
_frustum.setFromProjectionMatrix(
|
|
182
185
|
_projScreenMatrix,
|
|
183
|
-
|
|
186
|
+
camera.coordinateSystem,
|
|
187
|
+
camera.reversedDepth
|
|
184
188
|
);
|
|
185
189
|
|
|
186
190
|
if ( _frustum.intersectsBox( box ) ) {
|
|
@@ -222,7 +226,8 @@ class FrustumArray {
|
|
|
222
226
|
|
|
223
227
|
_frustum.setFromProjectionMatrix(
|
|
224
228
|
_projScreenMatrix,
|
|
225
|
-
|
|
229
|
+
camera.coordinateSystem,
|
|
230
|
+
camera.reversedDepth
|
|
226
231
|
);
|
|
227
232
|
|
|
228
233
|
if ( _frustum.containsPoint( point ) ) {
|
package/src/math/Line3.js
CHANGED
|
@@ -4,6 +4,12 @@ import { clamp } from './MathUtils.js';
|
|
|
4
4
|
const _startP = /*@__PURE__*/ new Vector3();
|
|
5
5
|
const _startEnd = /*@__PURE__*/ new Vector3();
|
|
6
6
|
|
|
7
|
+
const _d1 = /*@__PURE__*/ new Vector3();
|
|
8
|
+
const _d2 = /*@__PURE__*/ new Vector3();
|
|
9
|
+
const _r = /*@__PURE__*/ new Vector3();
|
|
10
|
+
const _c1 = /*@__PURE__*/ new Vector3();
|
|
11
|
+
const _c2 = /*@__PURE__*/ new Vector3();
|
|
12
|
+
|
|
7
13
|
/**
|
|
8
14
|
* An analytical line segment in 3D space represented by a start and end point.
|
|
9
15
|
*/
|
|
@@ -151,11 +157,11 @@ class Line3 {
|
|
|
151
157
|
}
|
|
152
158
|
|
|
153
159
|
/**
|
|
154
|
-
* Returns the
|
|
160
|
+
* Returns the closest point on the line for a given point.
|
|
155
161
|
*
|
|
156
162
|
* @param {Vector3} point - The point to compute the closest point on the line for.
|
|
157
163
|
* @param {boolean} clampToLine - Whether to clamp the result to the range `[0,1]` or not.
|
|
158
|
-
* @param {Vector3} target -
|
|
164
|
+
* @param {Vector3} target - The target vector that is used to store the method's result.
|
|
159
165
|
* @return {Vector3} The closest point on the line.
|
|
160
166
|
*/
|
|
161
167
|
closestPointToPoint( point, clampToLine, target ) {
|
|
@@ -166,6 +172,127 @@ class Line3 {
|
|
|
166
172
|
|
|
167
173
|
}
|
|
168
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Returns the closest squared distance between this line segment and the given one.
|
|
177
|
+
*
|
|
178
|
+
* @param {Line3} line - The line segment to compute the closest squared distance to.
|
|
179
|
+
* @param {Vector3} [c1] - The closest point on this line segment.
|
|
180
|
+
* @param {Vector3} [c2] - The closest point on the given line segment.
|
|
181
|
+
* @return {number} The squared distance between this line segment and the given one.
|
|
182
|
+
*/
|
|
183
|
+
distanceSqToLine3( line, c1 = _c1, c2 = _c2 ) {
|
|
184
|
+
|
|
185
|
+
// from Real-Time Collision Detection by Christer Ericson, chapter 5.1.9
|
|
186
|
+
|
|
187
|
+
// Computes closest points C1 and C2 of S1(s)=P1+s*(Q1-P1) and
|
|
188
|
+
// S2(t)=P2+t*(Q2-P2), returning s and t. Function result is squared
|
|
189
|
+
// distance between between S1(s) and S2(t)
|
|
190
|
+
|
|
191
|
+
const EPSILON = 1e-8 * 1e-8; // must be squared since we compare squared length
|
|
192
|
+
let s, t;
|
|
193
|
+
|
|
194
|
+
const p1 = this.start;
|
|
195
|
+
const p2 = line.start;
|
|
196
|
+
const q1 = this.end;
|
|
197
|
+
const q2 = line.end;
|
|
198
|
+
|
|
199
|
+
_d1.subVectors( q1, p1 ); // Direction vector of segment S1
|
|
200
|
+
_d2.subVectors( q2, p2 ); // Direction vector of segment S2
|
|
201
|
+
_r.subVectors( p1, p2 );
|
|
202
|
+
|
|
203
|
+
const a = _d1.dot( _d1 ); // Squared length of segment S1, always nonnegative
|
|
204
|
+
const e = _d2.dot( _d2 ); // Squared length of segment S2, always nonnegative
|
|
205
|
+
const f = _d2.dot( _r );
|
|
206
|
+
|
|
207
|
+
// Check if either or both segments degenerate into points
|
|
208
|
+
|
|
209
|
+
if ( a <= EPSILON && e <= EPSILON ) {
|
|
210
|
+
|
|
211
|
+
// Both segments degenerate into points
|
|
212
|
+
|
|
213
|
+
c1.copy( p1 );
|
|
214
|
+
c2.copy( p2 );
|
|
215
|
+
|
|
216
|
+
c1.sub( c2 );
|
|
217
|
+
|
|
218
|
+
return c1.dot( c1 );
|
|
219
|
+
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if ( a <= EPSILON ) {
|
|
223
|
+
|
|
224
|
+
// First segment degenerates into a point
|
|
225
|
+
|
|
226
|
+
s = 0;
|
|
227
|
+
t = f / e; // s = 0 => t = (b*s + f) / e = f / e
|
|
228
|
+
t = clamp( t, 0, 1 );
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
} else {
|
|
232
|
+
|
|
233
|
+
const c = _d1.dot( _r );
|
|
234
|
+
|
|
235
|
+
if ( e <= EPSILON ) {
|
|
236
|
+
|
|
237
|
+
// Second segment degenerates into a point
|
|
238
|
+
|
|
239
|
+
t = 0;
|
|
240
|
+
s = clamp( - c / a, 0, 1 ); // t = 0 => s = (b*t - c) / a = -c / a
|
|
241
|
+
|
|
242
|
+
} else {
|
|
243
|
+
|
|
244
|
+
// The general nondegenerate case starts here
|
|
245
|
+
|
|
246
|
+
const b = _d1.dot( _d2 );
|
|
247
|
+
const denom = a * e - b * b; // Always nonnegative
|
|
248
|
+
|
|
249
|
+
// If segments not parallel, compute closest point on L1 to L2 and
|
|
250
|
+
// clamp to segment S1. Else pick arbitrary s (here 0)
|
|
251
|
+
|
|
252
|
+
if ( denom !== 0 ) {
|
|
253
|
+
|
|
254
|
+
s = clamp( ( b * f - c * e ) / denom, 0, 1 );
|
|
255
|
+
|
|
256
|
+
} else {
|
|
257
|
+
|
|
258
|
+
s = 0;
|
|
259
|
+
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// Compute point on L2 closest to S1(s) using
|
|
263
|
+
// t = Dot((P1 + D1*s) - P2,D2) / Dot(D2,D2) = (b*s + f) / e
|
|
264
|
+
|
|
265
|
+
t = ( b * s + f ) / e;
|
|
266
|
+
|
|
267
|
+
// If t in [0,1] done. Else clamp t, recompute s for the new value
|
|
268
|
+
// of t using s = Dot((P2 + D2*t) - P1,D1) / Dot(D1,D1)= (t*b - c) / a
|
|
269
|
+
// and clamp s to [0, 1]
|
|
270
|
+
|
|
271
|
+
if ( t < 0 ) {
|
|
272
|
+
|
|
273
|
+
t = 0.;
|
|
274
|
+
s = clamp( - c / a, 0, 1 );
|
|
275
|
+
|
|
276
|
+
} else if ( t > 1 ) {
|
|
277
|
+
|
|
278
|
+
t = 1;
|
|
279
|
+
s = clamp( ( b - c ) / a, 0, 1 );
|
|
280
|
+
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
c1.copy( p1 ).add( _d1.multiplyScalar( s ) );
|
|
288
|
+
c2.copy( p2 ).add( _d2.multiplyScalar( t ) );
|
|
289
|
+
|
|
290
|
+
c1.sub( c2 );
|
|
291
|
+
|
|
292
|
+
return c1.dot( c1 );
|
|
293
|
+
|
|
294
|
+
}
|
|
295
|
+
|
|
169
296
|
/**
|
|
170
297
|
* Applies a 4x4 transformation matrix to this line segment.
|
|
171
298
|
*
|