super-three 0.169.1 → 0.170.1
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 +24628 -24228
- package/build/three.core.js +37002 -0
- package/build/three.core.min.js +6 -0
- package/build/three.module.js +10519 -47108
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +533 -0
- package/build/three.tsl.min.js +6 -0
- package/build/three.webgpu.js +17071 -53583
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +17134 -53623
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +3 -3
- package/examples/jsm/animation/MMDAnimationHelper.js +2 -0
- package/examples/jsm/animation/MMDPhysics.js +2 -0
- package/examples/jsm/capabilities/WebGPU.js +1 -10
- package/examples/jsm/controls/ArcballControls.js +25 -21
- package/examples/jsm/controls/OrbitControls.js +41 -9
- package/examples/jsm/controls/PointerLockControls.js +2 -5
- package/examples/jsm/controls/TransformControls.js +22 -6
- package/examples/jsm/csm/CSM.js +2 -2
- package/examples/jsm/csm/CSMFrustum.js +7 -4
- package/examples/jsm/csm/CSMHelper.js +2 -0
- package/examples/jsm/csm/CSMShadowNode.js +437 -0
- package/examples/jsm/curves/NURBSCurve.js +34 -3
- package/examples/jsm/exporters/GLTFExporter.js +138 -71
- package/examples/jsm/exporters/KTX2Exporter.js +35 -12
- package/examples/jsm/exporters/MMDExporter.js +6 -0
- package/examples/jsm/exporters/USDZExporter.js +21 -3
- package/examples/jsm/geometries/DecalGeometry.js +70 -21
- package/examples/jsm/geometries/InstancedPointsGeometry.js +2 -0
- package/examples/jsm/helpers/TextureHelperGPU.js +175 -0
- package/examples/jsm/interactive/HTMLMesh.js +1 -0
- package/examples/jsm/lighting/TiledLighting.js +18 -0
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +1 -1
- package/examples/jsm/lines/LineGeometry.js +25 -0
- package/examples/jsm/lines/LineMaterial.js +0 -1
- package/examples/jsm/lines/LineSegmentsGeometry.js +2 -0
- package/examples/jsm/lines/webgpu/Line2.js +2 -1
- package/examples/jsm/lines/webgpu/LineSegments2.js +2 -16
- package/examples/jsm/lines/webgpu/Wireframe.js +57 -0
- package/examples/jsm/loaders/3DMLoader.js +1 -0
- package/examples/jsm/loaders/3MFLoader.js +91 -0
- package/examples/jsm/loaders/FBXLoader.js +12 -2
- package/examples/jsm/loaders/GLTFLoader.js +2 -0
- package/examples/jsm/loaders/KTX2Loader.js +143 -49
- package/examples/jsm/loaders/LDrawLoader.js +22 -136
- package/examples/jsm/loaders/LottieLoader.js +1 -0
- package/examples/jsm/loaders/MMDLoader.js +3 -0
- package/examples/jsm/loaders/MaterialXLoader.js +2 -2
- package/examples/jsm/materials/LDrawConditionalLineMaterial.js +143 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +114 -0
- package/examples/jsm/math/ColorSpaces.js +76 -0
- package/examples/jsm/misc/ProgressiveLightMap.js +52 -40
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +293 -0
- package/examples/jsm/misc/VolumeSlice.js +1 -0
- package/examples/jsm/objects/InstancedPoints.js +2 -4
- package/examples/jsm/objects/LensflareMesh.js +4 -2
- package/examples/jsm/objects/SkyMesh.js +5 -3
- package/examples/jsm/objects/Water2Mesh.js +7 -3
- package/examples/jsm/objects/WaterMesh.js +12 -10
- package/examples/jsm/postprocessing/AfterimagePass.js +14 -3
- package/examples/jsm/postprocessing/SSRPass.js +6 -0
- package/examples/jsm/renderers/CSS2DRenderer.js +6 -3
- package/examples/jsm/renderers/CSS3DRenderer.js +7 -4
- package/examples/jsm/shaders/FXAAShader.js +225 -224
- package/examples/jsm/transpiler/AST.js +2 -2
- package/examples/jsm/transpiler/GLSLDecoder.js +57 -25
- package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
- package/examples/jsm/transpiler/TSLEncoder.js +11 -6
- package/{src/nodes → examples/jsm/tsl}/display/AfterImageNode.js +18 -21
- package/{src/nodes → examples/jsm/tsl}/display/AnaglyphPassNode.js +2 -6
- package/{src/nodes → examples/jsm/tsl}/display/AnamorphicNode.js +12 -18
- package/{src/nodes → examples/jsm/tsl}/display/BleachBypass.js +1 -3
- package/{src/nodes → examples/jsm/tsl}/display/BloomNode.js +12 -41
- package/{src/nodes → examples/jsm/tsl}/display/DenoiseNode.js +60 -47
- package/{src/nodes → examples/jsm/tsl}/display/DepthOfFieldNode.js +4 -9
- package/{src/nodes → examples/jsm/tsl}/display/DotScreenNode.js +2 -9
- package/examples/jsm/tsl/display/FXAANode.js +316 -0
- package/{src/nodes → examples/jsm/tsl}/display/FilmNode.js +4 -7
- package/{src/nodes → examples/jsm/tsl}/display/GTAONode.js +73 -78
- package/{src/nodes → examples/jsm/tsl}/display/GaussianBlurNode.js +78 -42
- package/examples/jsm/tsl/display/LensflareNode.js +161 -0
- package/{src/nodes → examples/jsm/tsl}/display/Lut3DNode.js +3 -5
- package/{src/nodes → examples/jsm/tsl}/display/MotionBlur.js +2 -3
- package/examples/jsm/tsl/display/OutlineNode.js +434 -0
- package/{src/nodes → examples/jsm/tsl}/display/ParallaxBarrierPassNode.js +2 -5
- package/{src/nodes → examples/jsm/tsl}/display/PixelationPassNode.js +5 -17
- package/{src/nodes → examples/jsm/tsl}/display/RGBShiftNode.js +2 -6
- package/examples/jsm/tsl/display/SMAANode.js +620 -0
- package/{src/nodes → examples/jsm/tsl}/display/SSAAPassNode.js +10 -25
- package/examples/jsm/tsl/display/SSRNode.js +366 -0
- package/{src/nodes → examples/jsm/tsl}/display/Sepia.js +1 -2
- package/{src/nodes → examples/jsm/tsl}/display/SobelOperatorNode.js +4 -12
- package/{src/nodes → examples/jsm/tsl}/display/StereoCompositePassNode.js +9 -11
- package/{src/nodes → examples/jsm/tsl}/display/StereoPassNode.js +10 -11
- package/examples/jsm/tsl/display/TRAAPassNode.js +355 -0
- package/{src/nodes → examples/jsm/tsl}/display/TransitionNode.js +3 -7
- package/examples/jsm/tsl/display/hashBlur.js +24 -0
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +389 -0
- package/examples/jsm/utils/SceneOptimizer.js +410 -0
- package/examples/jsm/utils/UVsDebug.js +1 -1
- package/examples/jsm/utils/{TextureUtilsGPU.js → WebGPUTextureUtils.js} +2 -1
- package/examples/jsm/webxr/OculusHandPointerModel.js +21 -21
- package/examples/jsm/webxr/Text2D.js +6 -6
- package/package.json +4 -4
- package/src/Three.Core.js +178 -0
- package/src/Three.TSL.js +526 -0
- package/src/Three.WebGPU.Nodes.js +9 -186
- package/src/Three.WebGPU.js +8 -186
- package/src/Three.js +1 -177
- package/src/animation/AnimationClip.js +2 -2
- package/src/animation/AnimationObjectGroup.js +2 -2
- package/src/audio/Audio.js +38 -0
- package/src/cameras/PerspectiveCamera.js +6 -6
- package/src/cameras/StereoCamera.js +2 -2
- package/src/constants.js +1 -6
- package/src/core/BufferGeometry.js +48 -8
- package/src/core/InterleavedBuffer.js +4 -4
- package/src/core/Object3D.js +2 -2
- package/src/extras/core/Curve.js +3 -3
- package/src/extras/core/Shape.js +2 -2
- package/src/geometries/CylinderGeometry.js +2 -2
- package/src/geometries/EdgesGeometry.js +2 -2
- package/src/geometries/LatheGeometry.js +2 -2
- package/src/lights/SpotLightShadow.js +2 -2
- package/src/materials/LineDashedMaterial.js +0 -1
- package/src/materials/Material.js +2 -2
- package/src/materials/MeshPhongMaterial.js +1 -1
- package/src/materials/MeshPhysicalMaterial.js +2 -2
- package/src/materials/MeshStandardMaterial.js +2 -2
- package/src/materials/nodes/Line2NodeMaterial.js +32 -13
- package/src/materials/nodes/LineDashedNodeMaterial.js +4 -2
- package/src/materials/nodes/NodeMaterial.js +93 -23
- package/src/materials/nodes/SpriteNodeMaterial.js +11 -2
- package/src/materials/nodes/manager/NodeMaterialObserver.js +119 -7
- package/src/math/ColorManagement.js +143 -102
- package/src/math/Line3.js +2 -2
- package/src/math/Quaternion.js +2 -2
- package/src/math/Spherical.js +3 -3
- package/src/math/Vector2.js +7 -7
- package/src/math/Vector3.js +9 -9
- package/src/math/Vector4.js +22 -9
- package/src/nodes/Nodes.js +2 -21
- package/src/nodes/TSL.js +9 -25
- package/src/nodes/accessors/Arrays.js +27 -0
- package/src/nodes/accessors/BuiltinNode.js +26 -0
- package/src/nodes/accessors/Camera.js +0 -1
- package/src/nodes/accessors/ClippingNode.js +76 -42
- package/src/nodes/accessors/InstanceNode.js +17 -20
- package/src/nodes/accessors/InstancedMeshNode.js +26 -0
- package/src/nodes/accessors/Lights.js +32 -0
- package/src/nodes/accessors/SceneNode.js +35 -1
- package/src/nodes/accessors/StorageBufferNode.js +61 -19
- package/src/nodes/accessors/StorageTextureNode.js +10 -4
- package/src/nodes/accessors/TextureNode.js +1 -1
- package/src/nodes/accessors/VelocityNode.js +13 -3
- package/src/nodes/code/FunctionCallNode.js +16 -5
- package/src/nodes/code/ScriptableNode.js +4 -4
- package/src/nodes/core/Node.js +1 -0
- package/src/nodes/core/NodeBuilder.js +31 -14
- package/src/nodes/core/NodeUtils.js +28 -0
- package/src/nodes/core/VarNode.js +15 -3
- package/src/nodes/core/constants.js +6 -0
- package/src/nodes/display/BlendModes.js +99 -0
- package/src/nodes/display/ColorAdjustment.js +53 -4
- package/src/nodes/display/ColorSpaceFunctions.js +5 -5
- package/src/nodes/display/ColorSpaceNode.js +27 -39
- package/src/nodes/display/PassNode.js +6 -4
- package/src/nodes/display/ToneMappingNode.js +1 -1
- package/src/nodes/display/ToonOutlinePassNode.js +3 -3
- package/src/nodes/display/ViewportDepthNode.js +48 -1
- package/src/nodes/functions/PhysicalLightingModel.js +21 -15
- package/src/nodes/functions/material/getAlphaHashThreshold.js +70 -0
- package/src/nodes/functions/material/getGeometryRoughness.js +8 -2
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +22 -0
- package/src/nodes/gpgpu/ComputeNode.js +9 -1
- package/src/nodes/lighting/AnalyticLightNode.js +23 -419
- package/src/nodes/lighting/LightsNode.js +24 -12
- package/src/nodes/lighting/PointLightNode.js +41 -22
- package/src/nodes/lighting/PointShadowNode.js +254 -0
- package/src/nodes/lighting/RectAreaLightNode.js +3 -0
- package/src/nodes/lighting/ShadowNode.js +593 -0
- package/src/nodes/lighting/SpotLightNode.js +14 -2
- package/src/nodes/utils/LoopNode.js +2 -2
- package/src/nodes/utils/Oscillators.js +6 -0
- package/src/nodes/utils/PostProcessingUtils.js +89 -0
- package/src/nodes/utils/RTTNode.js +9 -1
- package/src/nodes/utils/ReflectorNode.js +101 -15
- package/src/nodes/utils/StorageArrayElementNode.js +2 -2
- package/src/nodes/utils/Timer.js +29 -0
- package/src/objects/BatchedMesh.js +472 -296
- package/src/objects/ClippingGroup.js +19 -0
- package/src/objects/Skeleton.js +2 -2
- package/src/renderers/WebGLRenderer.js +183 -109
- package/src/renderers/common/Animation.js +23 -11
- package/src/renderers/common/Attributes.js +4 -0
- package/src/renderers/common/Backend.js +2 -0
- package/src/renderers/common/Background.js +15 -5
- package/src/renderers/common/Bindings.js +23 -6
- package/src/renderers/common/ClippingContext.js +77 -85
- package/src/renderers/common/Constants.js +2 -1
- package/src/renderers/common/Geometries.js +20 -0
- package/src/renderers/common/IndirectStorageBufferAttribute.js +15 -0
- package/src/renderers/common/Lighting.js +45 -0
- package/src/renderers/common/PostProcessingUtils.js +86 -0
- package/src/renderers/common/RenderList.js +48 -17
- package/src/renderers/common/RenderLists.js +4 -2
- package/src/renderers/common/RenderObject.js +45 -28
- package/src/renderers/common/RenderObjects.js +12 -6
- package/src/renderers/common/Renderer.js +222 -77
- package/src/renderers/common/Textures.js +41 -17
- package/src/renderers/common/UniformsGroup.js +16 -4
- package/src/renderers/common/extras/PMREMGenerator.js +89 -13
- package/src/renderers/common/nodes/NodeLibrary.js +2 -15
- package/src/renderers/common/nodes/NodeStorageBuffer.js +2 -3
- package/src/renderers/common/nodes/NodeUniform.js +42 -0
- package/src/renderers/common/nodes/Nodes.js +2 -2
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +4 -24
- package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +2 -2
- package/src/renderers/webgl/WebGLBackground.js +20 -1
- package/src/renderers/webgl/WebGLBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLCapabilities.js +0 -7
- package/src/renderers/webgl/WebGLGeometries.js +0 -28
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLProgram.js +24 -28
- package/src/renderers/webgl/WebGLPrograms.js +5 -2
- package/src/renderers/webgl/WebGLState.js +37 -1
- package/src/renderers/webgl/WebGLTextures.js +29 -12
- package/src/renderers/webgl-fallback/WebGLBackend.js +111 -37
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +2 -7
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +43 -12
- package/src/renderers/webgl-fallback/utils/WebGLState.js +26 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +37 -9
- package/src/renderers/webgpu/WebGPUBackend.js +152 -56
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +1 -1
- package/src/renderers/webgpu/WebGPURenderer.js +1 -1
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +0 -8
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +13 -34
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +192 -92
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +12 -4
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +15 -2
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +72 -7
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +29 -9
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +29 -7
- package/src/renderers/webgpu/utils/WebGPUUtils.js +0 -1
- package/src/renderers/webxr/WebXRManager.js +4 -4
- package/src/textures/Source.js +2 -2
- package/src/textures/Texture.js +2 -2
- package/examples/jsm/cameras/CinematicCamera.js +0 -208
- package/src/nodes/display/BlendMode.js +0 -54
- package/src/nodes/display/FXAANode.js +0 -332
- package/src/nodes/utils/OscNode.js +0 -85
- package/src/nodes/utils/TimerNode.js +0 -97
- /package/examples/jsm/utils/{TextureUtils.js → WebGLTextureUtils.js} +0 -0
|
@@ -32,7 +32,7 @@ class Bindings extends DataMap {
|
|
|
32
32
|
|
|
33
33
|
this._init( bindGroup );
|
|
34
34
|
|
|
35
|
-
this.backend.createBindings( bindGroup, bindings );
|
|
35
|
+
this.backend.createBindings( bindGroup, bindings, 0 );
|
|
36
36
|
|
|
37
37
|
groupData.bindGroup = bindGroup;
|
|
38
38
|
|
|
@@ -56,7 +56,7 @@ class Bindings extends DataMap {
|
|
|
56
56
|
|
|
57
57
|
this._init( bindGroup );
|
|
58
58
|
|
|
59
|
-
this.backend.createBindings( bindGroup, bindings );
|
|
59
|
+
this.backend.createBindings( bindGroup, bindings, 0 );
|
|
60
60
|
|
|
61
61
|
groupData.bindGroup = bindGroup;
|
|
62
62
|
|
|
@@ -101,8 +101,9 @@ class Bindings extends DataMap {
|
|
|
101
101
|
} else if ( binding.isStorageBuffer ) {
|
|
102
102
|
|
|
103
103
|
const attribute = binding.attribute;
|
|
104
|
+
const attributeType = attribute.isIndirectStorageBufferAttribute ? AttributeType.INDIRECT : AttributeType.STORAGE;
|
|
104
105
|
|
|
105
|
-
this.attributes.update( attribute,
|
|
106
|
+
this.attributes.update( attribute, attributeType );
|
|
106
107
|
|
|
107
108
|
}
|
|
108
109
|
|
|
@@ -115,6 +116,9 @@ class Bindings extends DataMap {
|
|
|
115
116
|
const { backend } = this;
|
|
116
117
|
|
|
117
118
|
let needsBindingsUpdate = false;
|
|
119
|
+
let cacheBindings = true;
|
|
120
|
+
let cacheIndex = 0;
|
|
121
|
+
let version = 0;
|
|
118
122
|
|
|
119
123
|
// iterate over all bindings and check if buffer updates or a new binding group is required
|
|
120
124
|
|
|
@@ -144,7 +148,9 @@ class Bindings extends DataMap {
|
|
|
144
148
|
|
|
145
149
|
} else if ( binding.isSampledTexture ) {
|
|
146
150
|
|
|
147
|
-
|
|
151
|
+
const texturesTextureData = this.textures.get( binding.texture );
|
|
152
|
+
|
|
153
|
+
if ( binding.needsBindingsUpdate( texturesTextureData.generation ) ) needsBindingsUpdate = true;
|
|
148
154
|
|
|
149
155
|
const updated = binding.update();
|
|
150
156
|
|
|
@@ -158,6 +164,17 @@ class Bindings extends DataMap {
|
|
|
158
164
|
|
|
159
165
|
const textureData = backend.get( texture );
|
|
160
166
|
|
|
167
|
+
if ( textureData.externalTexture !== undefined || texturesTextureData.isDefaultTexture ) {
|
|
168
|
+
|
|
169
|
+
cacheBindings = false;
|
|
170
|
+
|
|
171
|
+
} else {
|
|
172
|
+
|
|
173
|
+
cacheIndex = cacheIndex * 10 + texture.id;
|
|
174
|
+
version += texture.version;
|
|
175
|
+
|
|
176
|
+
}
|
|
177
|
+
|
|
161
178
|
if ( backend.isWebGPUBackend === true && textureData.texture === undefined && textureData.externalTexture === undefined ) {
|
|
162
179
|
|
|
163
180
|
// TODO: Remove this once we found why updated === false isn't bound to a texture in the WebGPU backend
|
|
@@ -176,7 +193,7 @@ class Bindings extends DataMap {
|
|
|
176
193
|
|
|
177
194
|
textureData.needsMipmap = true;
|
|
178
195
|
|
|
179
|
-
} else if (
|
|
196
|
+
} else if ( this.textures.needsMipmaps( texture ) && textureData.needsMipmap === true ) {
|
|
180
197
|
|
|
181
198
|
this.backend.generateMipmaps( texture );
|
|
182
199
|
|
|
@@ -192,7 +209,7 @@ class Bindings extends DataMap {
|
|
|
192
209
|
|
|
193
210
|
if ( needsBindingsUpdate === true ) {
|
|
194
211
|
|
|
195
|
-
this.backend.updateBindings( bindGroup, bindings );
|
|
212
|
+
this.backend.updateBindings( bindGroup, bindings, cacheBindings ? cacheIndex : 0, version );
|
|
196
213
|
|
|
197
214
|
}
|
|
198
215
|
|
|
@@ -1,40 +1,53 @@
|
|
|
1
1
|
import { Matrix3 } from '../../math/Matrix3.js';
|
|
2
2
|
import { Plane } from '../../math/Plane.js';
|
|
3
3
|
import { Vector4 } from '../../math/Vector4.js';
|
|
4
|
-
import { hash } from '../../nodes/core/NodeUtils.js';
|
|
5
4
|
|
|
6
5
|
const _plane = /*@__PURE__*/ new Plane();
|
|
7
6
|
|
|
8
7
|
class ClippingContext {
|
|
9
8
|
|
|
10
|
-
constructor() {
|
|
9
|
+
constructor( parentContext = null ) {
|
|
11
10
|
|
|
12
11
|
this.version = 0;
|
|
13
12
|
|
|
14
|
-
this.
|
|
13
|
+
this.clipIntersection = null;
|
|
14
|
+
this.cacheKey = '';
|
|
15
15
|
|
|
16
|
-
this.localClippingCount = 0;
|
|
17
|
-
this.localClippingEnabled = false;
|
|
18
|
-
this.localClipIntersection = false;
|
|
19
16
|
|
|
20
|
-
|
|
17
|
+
if ( parentContext === null ) {
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
this.intersectionPlanes = [];
|
|
20
|
+
this.unionPlanes = [];
|
|
21
|
+
|
|
22
|
+
this.viewNormalMatrix = new Matrix3();
|
|
23
|
+
this.clippingGroupContexts = new WeakMap();
|
|
24
|
+
|
|
25
|
+
this.shadowPass = false;
|
|
26
|
+
|
|
27
|
+
} else {
|
|
28
|
+
|
|
29
|
+
this.viewNormalMatrix = parentContext.viewNormalMatrix;
|
|
30
|
+
this.clippingGroupContexts = parentContext.clippingGroupContexts;
|
|
31
|
+
|
|
32
|
+
this.shadowPass = parentContext.shadowPass;
|
|
33
|
+
|
|
34
|
+
this.viewMatrix = parentContext.viewMatrix;
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
this.parentVersion = null;
|
|
25
39
|
|
|
26
40
|
}
|
|
27
41
|
|
|
28
|
-
projectPlanes( source, offset ) {
|
|
42
|
+
projectPlanes( source, destination, offset ) {
|
|
29
43
|
|
|
30
44
|
const l = source.length;
|
|
31
|
-
const planes = this.planes;
|
|
32
45
|
|
|
33
46
|
for ( let i = 0; i < l; i ++ ) {
|
|
34
47
|
|
|
35
48
|
_plane.copy( source[ i ] ).applyMatrix4( this.viewMatrix, this.viewNormalMatrix );
|
|
36
49
|
|
|
37
|
-
const v =
|
|
50
|
+
const v = destination[ offset + i ];
|
|
38
51
|
const normal = _plane.normal;
|
|
39
52
|
|
|
40
53
|
v.x = - normal.x;
|
|
@@ -46,129 +59,108 @@ class ClippingContext {
|
|
|
46
59
|
|
|
47
60
|
}
|
|
48
61
|
|
|
49
|
-
updateGlobal(
|
|
62
|
+
updateGlobal( scene, camera ) {
|
|
50
63
|
|
|
51
|
-
|
|
64
|
+
this.shadowPass = ( scene.overrideMaterial !== null && scene.overrideMaterial.isShadowNodeMaterial );
|
|
52
65
|
this.viewMatrix = camera.matrixWorldInverse;
|
|
53
66
|
|
|
54
67
|
this.viewNormalMatrix.getNormalMatrix( this.viewMatrix );
|
|
55
68
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if ( Array.isArray( rendererClippingPlanes ) && rendererClippingPlanes.length !== 0 ) {
|
|
69
|
+
}
|
|
59
70
|
|
|
60
|
-
|
|
71
|
+
update( parentContext, clippingGroup ) {
|
|
61
72
|
|
|
62
|
-
|
|
73
|
+
let update = false;
|
|
63
74
|
|
|
64
|
-
|
|
75
|
+
if ( parentContext.version !== this.parentVersion ) {
|
|
65
76
|
|
|
66
|
-
|
|
77
|
+
this.intersectionPlanes = Array.from( parentContext.intersectionPlanes );
|
|
78
|
+
this.unionPlanes = Array.from( parentContext.unionPlanes );
|
|
79
|
+
this.parentVersion = parentContext.version;
|
|
67
80
|
|
|
68
|
-
|
|
81
|
+
}
|
|
69
82
|
|
|
70
|
-
|
|
83
|
+
if ( this.clipIntersection !== clippingGroup.clipIntersection ) {
|
|
71
84
|
|
|
72
|
-
|
|
73
|
-
this.planes = planes;
|
|
85
|
+
this.clipIntersection = clippingGroup.clipIntersection;
|
|
74
86
|
|
|
75
|
-
|
|
87
|
+
if ( this.clipIntersection ) {
|
|
76
88
|
|
|
77
|
-
|
|
89
|
+
this.unionPlanes.length = parentContext.unionPlanes.length;
|
|
78
90
|
|
|
79
|
-
|
|
91
|
+
} else {
|
|
80
92
|
|
|
81
|
-
|
|
93
|
+
this.intersectionPlanes.length = parentContext.intersectionPlanes.length;
|
|
82
94
|
|
|
83
|
-
|
|
84
|
-
this.planes = [];
|
|
85
|
-
update = true;
|
|
95
|
+
}
|
|
86
96
|
|
|
87
97
|
}
|
|
88
98
|
|
|
89
|
-
|
|
99
|
+
const srcClippingPlanes = clippingGroup.clippingPlanes;
|
|
100
|
+
const l = srcClippingPlanes.length;
|
|
90
101
|
|
|
91
|
-
|
|
92
|
-
|
|
102
|
+
let dstClippingPlanes;
|
|
103
|
+
let offset;
|
|
93
104
|
|
|
94
|
-
|
|
105
|
+
if ( this.clipIntersection ) {
|
|
95
106
|
|
|
96
|
-
|
|
107
|
+
dstClippingPlanes = this.intersectionPlanes;
|
|
108
|
+
offset = parentContext.intersectionPlanes.length;
|
|
97
109
|
|
|
98
|
-
|
|
99
|
-
|
|
110
|
+
} else {
|
|
111
|
+
|
|
112
|
+
dstClippingPlanes = this.unionPlanes;
|
|
113
|
+
offset = parentContext.unionPlanes.length;
|
|
100
114
|
|
|
101
115
|
}
|
|
102
116
|
|
|
103
|
-
|
|
117
|
+
if ( dstClippingPlanes.length !== offset + l ) {
|
|
104
118
|
|
|
105
|
-
|
|
119
|
+
dstClippingPlanes.length = offset + l;
|
|
106
120
|
|
|
107
|
-
|
|
121
|
+
for ( let i = 0; i < l; i ++ ) {
|
|
108
122
|
|
|
109
|
-
|
|
123
|
+
dstClippingPlanes[ offset + i ] = new Vector4();
|
|
110
124
|
|
|
111
|
-
|
|
112
|
-
this.localClippingEnabled = parent.localClippingEnabled;
|
|
113
|
-
this.planes = Array.from( parent.planes );
|
|
114
|
-
this.parentVersion = parent.version;
|
|
115
|
-
this.viewMatrix = parent.viewMatrix;
|
|
116
|
-
this.viewNormalMatrix = parent.viewNormalMatrix;
|
|
125
|
+
}
|
|
117
126
|
|
|
118
127
|
update = true;
|
|
119
128
|
|
|
120
129
|
}
|
|
121
130
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const localClippingPlanes = material.clippingPlanes;
|
|
125
|
-
|
|
126
|
-
if ( ( Array.isArray( localClippingPlanes ) && localClippingPlanes.length !== 0 ) ) {
|
|
127
|
-
|
|
128
|
-
const l = localClippingPlanes.length;
|
|
129
|
-
const planes = this.planes;
|
|
130
|
-
const offset = this.globalClippingCount;
|
|
131
|
+
this.projectPlanes( srcClippingPlanes, dstClippingPlanes, offset );
|
|
131
132
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
planes.length = offset + l;
|
|
135
|
-
|
|
136
|
-
for ( let i = 0; i < l; i ++ ) {
|
|
137
|
-
|
|
138
|
-
planes[ offset + i ] = new Vector4();
|
|
139
|
-
|
|
140
|
-
}
|
|
133
|
+
if ( update ) {
|
|
141
134
|
|
|
142
|
-
|
|
143
|
-
|
|
135
|
+
this.version ++;
|
|
136
|
+
this.cacheKey = `${ this.intersectionPlanes.length }:${ this.unionPlanes.length }`;
|
|
144
137
|
|
|
145
|
-
|
|
138
|
+
}
|
|
146
139
|
|
|
147
|
-
|
|
140
|
+
}
|
|
148
141
|
|
|
142
|
+
getGroupContext( clippingGroup ) {
|
|
149
143
|
|
|
150
|
-
|
|
144
|
+
if ( this.shadowPass && ! clippingGroup.clipShadows ) return this;
|
|
151
145
|
|
|
152
|
-
|
|
153
|
-
update = true;
|
|
146
|
+
let context = this.clippingGroupContexts.get( clippingGroup );
|
|
154
147
|
|
|
155
|
-
|
|
148
|
+
if ( context === undefined ) {
|
|
156
149
|
|
|
157
|
-
|
|
150
|
+
context = new ClippingContext( this );
|
|
151
|
+
this.clippingGroupContexts.set( clippingGroup, context );
|
|
158
152
|
|
|
159
|
-
|
|
160
|
-
update = true;
|
|
153
|
+
}
|
|
161
154
|
|
|
162
|
-
|
|
155
|
+
context.update( this, clippingGroup );
|
|
163
156
|
|
|
164
|
-
|
|
157
|
+
return context;
|
|
165
158
|
|
|
166
|
-
|
|
159
|
+
}
|
|
167
160
|
|
|
168
|
-
|
|
169
|
-
this.cacheKey = hash( parent.cacheKey, this.localClippingCount, this.localClipIntersection === true ? 1 : 0 );
|
|
161
|
+
get unionClippingCount() {
|
|
170
162
|
|
|
171
|
-
|
|
163
|
+
return this.unionPlanes.length;
|
|
172
164
|
|
|
173
165
|
}
|
|
174
166
|
|
|
@@ -144,6 +144,8 @@ class Geometries extends DataMap {
|
|
|
144
144
|
|
|
145
145
|
updateAttributes( renderObject ) {
|
|
146
146
|
|
|
147
|
+
// attributes
|
|
148
|
+
|
|
147
149
|
const attributes = renderObject.getAttributes();
|
|
148
150
|
|
|
149
151
|
for ( const attribute of attributes ) {
|
|
@@ -160,6 +162,8 @@ class Geometries extends DataMap {
|
|
|
160
162
|
|
|
161
163
|
}
|
|
162
164
|
|
|
165
|
+
// indexes
|
|
166
|
+
|
|
163
167
|
const index = this.getIndex( renderObject );
|
|
164
168
|
|
|
165
169
|
if ( index !== null ) {
|
|
@@ -168,6 +172,16 @@ class Geometries extends DataMap {
|
|
|
168
172
|
|
|
169
173
|
}
|
|
170
174
|
|
|
175
|
+
// indirect
|
|
176
|
+
|
|
177
|
+
const indirect = renderObject.geometry.indirect;
|
|
178
|
+
|
|
179
|
+
if ( indirect !== null ) {
|
|
180
|
+
|
|
181
|
+
this.updateAttribute( indirect, AttributeType.INDIRECT );
|
|
182
|
+
|
|
183
|
+
}
|
|
184
|
+
|
|
171
185
|
}
|
|
172
186
|
|
|
173
187
|
updateAttribute( attribute, type ) {
|
|
@@ -206,6 +220,12 @@ class Geometries extends DataMap {
|
|
|
206
220
|
|
|
207
221
|
}
|
|
208
222
|
|
|
223
|
+
getIndirect( renderObject ) {
|
|
224
|
+
|
|
225
|
+
return renderObject.geometry.indirect;
|
|
226
|
+
|
|
227
|
+
}
|
|
228
|
+
|
|
209
229
|
getIndex( renderObject ) {
|
|
210
230
|
|
|
211
231
|
const { geometry, material } = renderObject;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import StorageBufferAttribute from './StorageBufferAttribute.js';
|
|
2
|
+
|
|
3
|
+
class IndirectStorageBufferAttribute extends StorageBufferAttribute {
|
|
4
|
+
|
|
5
|
+
constructor( array, itemSize ) {
|
|
6
|
+
|
|
7
|
+
super( array, itemSize, Uint32Array );
|
|
8
|
+
|
|
9
|
+
this.isIndirectStorageBufferAttribute = true;
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default IndirectStorageBufferAttribute;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { LightsNode } from '../../nodes/Nodes.js';
|
|
2
|
+
import ChainMap from './ChainMap.js';
|
|
3
|
+
|
|
4
|
+
const _defaultLights = /*@__PURE__*/ new LightsNode();
|
|
5
|
+
|
|
6
|
+
class Lighting extends ChainMap {
|
|
7
|
+
|
|
8
|
+
constructor() {
|
|
9
|
+
|
|
10
|
+
super();
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
createNode( lights = [] ) {
|
|
15
|
+
|
|
16
|
+
return new LightsNode().setLights( lights );
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getNode( scene, camera ) {
|
|
21
|
+
|
|
22
|
+
// ignore post-processing
|
|
23
|
+
|
|
24
|
+
if ( scene.isQuadMesh ) return _defaultLights;
|
|
25
|
+
|
|
26
|
+
// tiled lighting
|
|
27
|
+
|
|
28
|
+
const keys = [ scene, camera ];
|
|
29
|
+
|
|
30
|
+
let node = this.get( keys );
|
|
31
|
+
|
|
32
|
+
if ( node === undefined ) {
|
|
33
|
+
|
|
34
|
+
node = this.createNode();
|
|
35
|
+
this.set( keys, node );
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return node;
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default Lighting;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Color } from '../../math/Color.js';
|
|
2
|
+
|
|
3
|
+
// renderer state
|
|
4
|
+
|
|
5
|
+
export function saveRendererState( renderer, state = {} ) {
|
|
6
|
+
|
|
7
|
+
state.toneMapping = renderer.toneMapping;
|
|
8
|
+
state.toneMappingExposure = renderer.toneMappingExposure;
|
|
9
|
+
state.outputColorSpace = renderer.outputColorSpace;
|
|
10
|
+
state.renderTarget = renderer.getRenderTarget();
|
|
11
|
+
state.activeCubeFace = renderer.getActiveCubeFace();
|
|
12
|
+
state.activeMipmapLevel = renderer.getActiveMipmapLevel();
|
|
13
|
+
state.renderObjectFunction = renderer.getRenderObjectFunction();
|
|
14
|
+
state.pixelRatio = renderer.getPixelRatio();
|
|
15
|
+
state.mrt = renderer.getMRT();
|
|
16
|
+
state.clearColor = renderer.getClearColor( state.clearColor || new Color() );
|
|
17
|
+
state.clearAlpha = renderer.getClearAlpha();
|
|
18
|
+
state.autoClear = renderer.autoClear;
|
|
19
|
+
state.scissorTest = renderer.getScissorTest();
|
|
20
|
+
|
|
21
|
+
return state;
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function resetRendererState( renderer, state ) {
|
|
26
|
+
|
|
27
|
+
state = saveRendererState( renderer, state );
|
|
28
|
+
|
|
29
|
+
renderer.setMRT( null );
|
|
30
|
+
renderer.setRenderObjectFunction( null );
|
|
31
|
+
renderer.setClearColor( 0x000000, 1 );
|
|
32
|
+
renderer.autoClear = true;
|
|
33
|
+
|
|
34
|
+
return state;
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function restoreRendererState( renderer, state ) {
|
|
39
|
+
|
|
40
|
+
renderer.toneMapping = state.toneMapping;
|
|
41
|
+
renderer.toneMappingExposure = state.toneMappingExposure;
|
|
42
|
+
renderer.outputColorSpace = state.outputColorSpace;
|
|
43
|
+
renderer.setRenderTarget( state.renderTarget, state.activeCubeFace, state.activeMipmapLevel );
|
|
44
|
+
renderer.setRenderObjectFunction( state.renderObjectFunction );
|
|
45
|
+
renderer.setPixelRatio( state.pixelRatio );
|
|
46
|
+
renderer.setMRT( state.mrt );
|
|
47
|
+
renderer.setClearColor( state.clearColor, state.clearAlpha );
|
|
48
|
+
renderer.autoClear = state.autoClear;
|
|
49
|
+
renderer.setScissorTest( state.scissorTest );
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// renderer and scene state
|
|
54
|
+
|
|
55
|
+
export function saveRendererAndSceneState( renderer, scene, state = {} ) {
|
|
56
|
+
|
|
57
|
+
state = saveRendererState( renderer, state );
|
|
58
|
+
state.background = scene.background;
|
|
59
|
+
state.backgroundNode = scene.backgroundNode;
|
|
60
|
+
state.overrideMaterial = scene.overrideMaterial;
|
|
61
|
+
|
|
62
|
+
return state;
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function resetRendererAndSceneState( renderer, scene, state ) {
|
|
67
|
+
|
|
68
|
+
state = saveRendererAndSceneState( renderer, scene, state );
|
|
69
|
+
|
|
70
|
+
scene.background = null;
|
|
71
|
+
scene.backgroundNode = null;
|
|
72
|
+
scene.overrideMaterial = null;
|
|
73
|
+
|
|
74
|
+
return state;
|
|
75
|
+
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function restoreRendererAndSceneState( renderer, scene, state ) {
|
|
79
|
+
|
|
80
|
+
restoreRendererState( renderer, state );
|
|
81
|
+
|
|
82
|
+
scene.background = state.background;
|
|
83
|
+
scene.backgroundNode = state.backgroundNode;
|
|
84
|
+
scene.overrideMaterial = state.overrideMaterial;
|
|
85
|
+
|
|
86
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DoubleSide } from '../../constants.js';
|
|
2
2
|
|
|
3
3
|
function painterSortStable( a, b ) {
|
|
4
4
|
|
|
@@ -48,20 +48,32 @@ function reversePainterSortStable( a, b ) {
|
|
|
48
48
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
function needsDoublePass( material ) {
|
|
52
|
+
|
|
53
|
+
const hasTransmission = material.transmission > 0 || material.transmissionNode;
|
|
54
|
+
|
|
55
|
+
return hasTransmission && material.side === DoubleSide && material.forceSinglePass === false;
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
|
|
51
59
|
class RenderList {
|
|
52
60
|
|
|
53
|
-
constructor() {
|
|
61
|
+
constructor( lighting, scene, camera ) {
|
|
54
62
|
|
|
55
63
|
this.renderItems = [];
|
|
56
64
|
this.renderItemsIndex = 0;
|
|
57
65
|
|
|
58
66
|
this.opaque = [];
|
|
67
|
+
this.transparentDoublePass = [];
|
|
59
68
|
this.transparent = [];
|
|
60
69
|
this.bundles = [];
|
|
61
70
|
|
|
62
|
-
this.lightsNode =
|
|
71
|
+
this.lightsNode = lighting.getNode( scene, camera );
|
|
63
72
|
this.lightsArray = [];
|
|
64
73
|
|
|
74
|
+
this.scene = scene;
|
|
75
|
+
this.camera = camera;
|
|
76
|
+
|
|
65
77
|
this.occlusionQueryCount = 0;
|
|
66
78
|
|
|
67
79
|
}
|
|
@@ -71,6 +83,7 @@ class RenderList {
|
|
|
71
83
|
this.renderItemsIndex = 0;
|
|
72
84
|
|
|
73
85
|
this.opaque.length = 0;
|
|
86
|
+
this.transparentDoublePass.length = 0;
|
|
74
87
|
this.transparent.length = 0;
|
|
75
88
|
this.bundles.length = 0;
|
|
76
89
|
|
|
@@ -82,7 +95,7 @@ class RenderList {
|
|
|
82
95
|
|
|
83
96
|
}
|
|
84
97
|
|
|
85
|
-
getNextRenderItem( object, geometry, material, groupOrder, z, group ) {
|
|
98
|
+
getNextRenderItem( object, geometry, material, groupOrder, z, group, clippingContext ) {
|
|
86
99
|
|
|
87
100
|
let renderItem = this.renderItems[ this.renderItemsIndex ];
|
|
88
101
|
|
|
@@ -96,7 +109,8 @@ class RenderList {
|
|
|
96
109
|
groupOrder: groupOrder,
|
|
97
110
|
renderOrder: object.renderOrder,
|
|
98
111
|
z: z,
|
|
99
|
-
group: group
|
|
112
|
+
group: group,
|
|
113
|
+
clippingContext: clippingContext
|
|
100
114
|
};
|
|
101
115
|
|
|
102
116
|
this.renderItems[ this.renderItemsIndex ] = renderItem;
|
|
@@ -111,6 +125,7 @@ class RenderList {
|
|
|
111
125
|
renderItem.renderOrder = object.renderOrder;
|
|
112
126
|
renderItem.z = z;
|
|
113
127
|
renderItem.group = group;
|
|
128
|
+
renderItem.clippingContext = clippingContext;
|
|
114
129
|
|
|
115
130
|
}
|
|
116
131
|
|
|
@@ -120,21 +135,41 @@ class RenderList {
|
|
|
120
135
|
|
|
121
136
|
}
|
|
122
137
|
|
|
123
|
-
push( object, geometry, material, groupOrder, z, group ) {
|
|
138
|
+
push( object, geometry, material, groupOrder, z, group, clippingContext ) {
|
|
124
139
|
|
|
125
|
-
const renderItem = this.getNextRenderItem( object, geometry, material, groupOrder, z, group );
|
|
140
|
+
const renderItem = this.getNextRenderItem( object, geometry, material, groupOrder, z, group, clippingContext );
|
|
126
141
|
|
|
127
142
|
if ( object.occlusionTest === true ) this.occlusionQueryCount ++;
|
|
128
143
|
|
|
129
|
-
( material.transparent === true || material.transmission > 0
|
|
144
|
+
if ( material.transparent === true || material.transmission > 0 ) {
|
|
145
|
+
|
|
146
|
+
if ( needsDoublePass( material ) ) this.transparentDoublePass.push( renderItem );
|
|
147
|
+
|
|
148
|
+
this.transparent.push( renderItem );
|
|
149
|
+
|
|
150
|
+
} else {
|
|
151
|
+
|
|
152
|
+
this.opaque.push( renderItem );
|
|
153
|
+
|
|
154
|
+
}
|
|
130
155
|
|
|
131
156
|
}
|
|
132
157
|
|
|
133
|
-
unshift( object, geometry, material, groupOrder, z, group ) {
|
|
158
|
+
unshift( object, geometry, material, groupOrder, z, group, clippingContext ) {
|
|
159
|
+
|
|
160
|
+
const renderItem = this.getNextRenderItem( object, geometry, material, groupOrder, z, group, clippingContext );
|
|
161
|
+
|
|
162
|
+
if ( material.transparent === true || material.transmission > 0 ) {
|
|
163
|
+
|
|
164
|
+
if ( needsDoublePass( material ) ) this.transparentDoublePass.unshift( renderItem );
|
|
165
|
+
|
|
166
|
+
this.transparent.unshift( renderItem );
|
|
167
|
+
|
|
168
|
+
} else {
|
|
134
169
|
|
|
135
|
-
|
|
170
|
+
this.opaque.unshift( renderItem );
|
|
136
171
|
|
|
137
|
-
|
|
172
|
+
}
|
|
138
173
|
|
|
139
174
|
}
|
|
140
175
|
|
|
@@ -150,15 +185,10 @@ class RenderList {
|
|
|
150
185
|
|
|
151
186
|
}
|
|
152
187
|
|
|
153
|
-
getLightsNode() {
|
|
154
|
-
|
|
155
|
-
return this.lightsNode.fromLights( this.lightsArray );
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
|
|
159
188
|
sort( customOpaqueSort, customTransparentSort ) {
|
|
160
189
|
|
|
161
190
|
if ( this.opaque.length > 1 ) this.opaque.sort( customOpaqueSort || painterSortStable );
|
|
191
|
+
if ( this.transparentDoublePass.length > 1 ) this.transparentDoublePass.sort( customTransparentSort || reversePainterSortStable );
|
|
162
192
|
if ( this.transparent.length > 1 ) this.transparent.sort( customTransparentSort || reversePainterSortStable );
|
|
163
193
|
|
|
164
194
|
}
|
|
@@ -185,6 +215,7 @@ class RenderList {
|
|
|
185
215
|
renderItem.renderOrder = null;
|
|
186
216
|
renderItem.z = null;
|
|
187
217
|
renderItem.group = null;
|
|
218
|
+
renderItem.clippingContext = null;
|
|
188
219
|
|
|
189
220
|
}
|
|
190
221
|
|