super-three 0.170.0 → 0.171.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.
Files changed (172) hide show
  1. package/build/three.cjs +24410 -24422
  2. package/build/three.core.js +37002 -0
  3. package/build/three.core.min.js +6 -0
  4. package/build/three.module.js +10573 -47578
  5. package/build/three.module.min.js +1 -1
  6. package/build/three.tsl.js +533 -0
  7. package/build/three.tsl.min.js +6 -0
  8. package/build/three.webgpu.js +2907 -37975
  9. package/build/three.webgpu.min.js +1 -1
  10. package/build/three.webgpu.nodes.js +2914 -37959
  11. package/build/three.webgpu.nodes.min.js +1 -1
  12. package/examples/jsm/capabilities/WebGPU.js +1 -10
  13. package/examples/jsm/controls/ArcballControls.js +25 -21
  14. package/examples/jsm/controls/OrbitControls.js +41 -9
  15. package/examples/jsm/controls/PointerLockControls.js +2 -5
  16. package/examples/jsm/csm/CSMShadowNode.js +7 -5
  17. package/examples/jsm/geometries/DecalGeometry.js +5 -1
  18. package/examples/jsm/lighting/TiledLighting.js +1 -1
  19. package/examples/jsm/lines/LineGeometry.js +25 -0
  20. package/examples/jsm/lines/LineMaterial.js +1 -7
  21. package/examples/jsm/lines/webgpu/Line2.js +2 -1
  22. package/examples/jsm/lines/webgpu/LineSegments2.js +2 -1
  23. package/examples/jsm/lines/webgpu/Wireframe.js +2 -1
  24. package/examples/jsm/loaders/KTX2Loader.js +3 -0
  25. package/examples/jsm/loaders/MMDLoader.js +2 -6
  26. package/examples/jsm/loaders/MaterialXLoader.js +2 -2
  27. package/examples/jsm/materials/MeshGouraudMaterial.js +2 -6
  28. package/examples/jsm/misc/ProgressiveLightMapGPU.js +2 -2
  29. package/examples/jsm/objects/InstancedPoints.js +2 -4
  30. package/examples/jsm/objects/LensflareMesh.js +4 -2
  31. package/examples/jsm/objects/SkyMesh.js +5 -3
  32. package/examples/jsm/objects/Water2Mesh.js +7 -3
  33. package/examples/jsm/objects/WaterMesh.js +5 -3
  34. package/examples/jsm/transpiler/AST.js +2 -2
  35. package/examples/jsm/transpiler/GLSLDecoder.js +57 -25
  36. package/examples/jsm/transpiler/TSLEncoder.js +11 -6
  37. package/examples/jsm/tsl/display/AfterImageNode.js +3 -3
  38. package/examples/jsm/tsl/display/AnaglyphPassNode.js +2 -2
  39. package/examples/jsm/tsl/display/AnamorphicNode.js +2 -2
  40. package/examples/jsm/tsl/display/BloomNode.js +3 -3
  41. package/examples/jsm/tsl/display/DenoiseNode.js +48 -12
  42. package/examples/jsm/tsl/display/DepthOfFieldNode.js +3 -2
  43. package/examples/jsm/tsl/display/DotScreenNode.js +2 -2
  44. package/examples/jsm/tsl/display/FXAANode.js +3 -3
  45. package/examples/jsm/tsl/display/FilmNode.js +3 -2
  46. package/examples/jsm/tsl/display/GTAONode.js +62 -27
  47. package/examples/jsm/tsl/display/GaussianBlurNode.js +6 -8
  48. package/examples/jsm/tsl/display/LensflareNode.js +3 -3
  49. package/examples/jsm/tsl/display/Lut3DNode.js +3 -2
  50. package/examples/jsm/tsl/display/OutlineNode.js +2 -2
  51. package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +2 -1
  52. package/examples/jsm/tsl/display/PixelationPassNode.js +4 -4
  53. package/examples/jsm/tsl/display/RGBShiftNode.js +2 -1
  54. package/examples/jsm/tsl/display/SMAANode.js +3 -3
  55. package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
  56. package/examples/jsm/tsl/display/SSRNode.js +31 -8
  57. package/examples/jsm/tsl/display/SobelOperatorNode.js +3 -3
  58. package/examples/jsm/tsl/display/StereoCompositePassNode.js +4 -4
  59. package/examples/jsm/tsl/display/StereoPassNode.js +2 -2
  60. package/examples/jsm/tsl/display/TRAAPassNode.js +2 -2
  61. package/examples/jsm/tsl/display/TransitionNode.js +3 -2
  62. package/examples/jsm/tsl/lighting/TiledLightsNode.js +6 -9
  63. package/examples/jsm/utils/SceneOptimizer.js +410 -0
  64. package/examples/jsm/utils/UVsDebug.js +1 -1
  65. package/package.json +3 -3
  66. package/src/Three.Core.js +178 -0
  67. package/src/Three.TSL.js +526 -0
  68. package/src/Three.WebGPU.Nodes.js +5 -186
  69. package/src/Three.WebGPU.js +4 -186
  70. package/src/Three.js +1 -177
  71. package/src/animation/AnimationClip.js +2 -2
  72. package/src/animation/AnimationObjectGroup.js +2 -2
  73. package/src/audio/Audio.js +38 -0
  74. package/src/cameras/PerspectiveCamera.js +6 -6
  75. package/src/cameras/StereoCamera.js +2 -2
  76. package/src/constants.js +1 -1
  77. package/src/core/BufferGeometry.js +5 -3
  78. package/src/core/InterleavedBuffer.js +4 -4
  79. package/src/core/Object3D.js +2 -2
  80. package/src/extras/core/Curve.js +3 -3
  81. package/src/extras/core/Shape.js +2 -2
  82. package/src/geometries/EdgesGeometry.js +2 -2
  83. package/src/geometries/LatheGeometry.js +2 -2
  84. package/src/lights/SpotLightShadow.js +2 -2
  85. package/src/materials/LineBasicMaterial.js +2 -6
  86. package/src/materials/LineDashedMaterial.js +1 -6
  87. package/src/materials/Material.js +3 -16
  88. package/src/materials/MeshBasicMaterial.js +2 -6
  89. package/src/materials/MeshDepthMaterial.js +2 -6
  90. package/src/materials/MeshDistanceMaterial.js +2 -6
  91. package/src/materials/MeshLambertMaterial.js +2 -6
  92. package/src/materials/MeshMatcapMaterial.js +2 -6
  93. package/src/materials/MeshNormalMaterial.js +2 -6
  94. package/src/materials/MeshPhongMaterial.js +3 -7
  95. package/src/materials/MeshPhysicalMaterial.js +4 -8
  96. package/src/materials/MeshStandardMaterial.js +2 -6
  97. package/src/materials/MeshToonMaterial.js +2 -6
  98. package/src/materials/PointsMaterial.js +2 -6
  99. package/src/materials/RawShaderMaterial.js +2 -6
  100. package/src/materials/ShaderMaterial.js +2 -6
  101. package/src/materials/ShadowMaterial.js +2 -6
  102. package/src/materials/SpriteMaterial.js +2 -6
  103. package/src/materials/nodes/Line2NodeMaterial.js +32 -13
  104. package/src/materials/nodes/LineDashedNodeMaterial.js +4 -2
  105. package/src/materials/nodes/NodeMaterial.js +64 -16
  106. package/src/materials/nodes/manager/NodeMaterialObserver.js +13 -10
  107. package/src/math/ColorManagement.js +130 -122
  108. package/src/math/Line3.js +2 -2
  109. package/src/math/Quaternion.js +2 -2
  110. package/src/math/Spherical.js +3 -3
  111. package/src/math/Vector2.js +7 -7
  112. package/src/math/Vector3.js +9 -9
  113. package/src/math/Vector4.js +11 -9
  114. package/src/nodes/Nodes.js +1 -0
  115. package/src/nodes/TSL.js +3 -1
  116. package/src/nodes/accessors/Arrays.js +27 -0
  117. package/src/nodes/accessors/BuiltinNode.js +26 -0
  118. package/src/nodes/accessors/ClippingNode.js +76 -42
  119. package/src/nodes/accessors/InstanceNode.js +17 -20
  120. package/src/nodes/accessors/InstancedMeshNode.js +26 -0
  121. package/src/nodes/accessors/Lights.js +32 -0
  122. package/src/nodes/accessors/StorageBufferNode.js +29 -9
  123. package/src/nodes/accessors/StorageTextureNode.js +10 -4
  124. package/src/nodes/accessors/TextureNode.js +1 -1
  125. package/src/nodes/core/NodeBuilder.js +2 -9
  126. package/src/nodes/core/NodeUtils.js +28 -0
  127. package/src/nodes/core/constants.js +6 -0
  128. package/src/nodes/display/BlendModes.js +99 -0
  129. package/src/nodes/display/ToonOutlinePassNode.js +3 -3
  130. package/src/nodes/display/ViewportDepthNode.js +21 -6
  131. package/src/nodes/functions/material/getAlphaHashThreshold.js +13 -7
  132. package/src/nodes/functions/material/getParallaxCorrectNormal.js +1 -1
  133. package/src/nodes/lighting/AnalyticLightNode.js +12 -4
  134. package/src/nodes/lighting/PointLightNode.js +10 -1
  135. package/src/nodes/lighting/PointShadowNode.js +254 -0
  136. package/src/nodes/lighting/ShadowNode.js +176 -67
  137. package/src/nodes/lighting/SpotLightNode.js +14 -2
  138. package/src/nodes/utils/RTTNode.js +9 -1
  139. package/src/nodes/utils/StorageArrayElementNode.js +2 -2
  140. package/src/objects/BatchedMesh.js +54 -95
  141. package/src/objects/ClippingGroup.js +19 -0
  142. package/src/objects/Skeleton.js +2 -2
  143. package/src/renderers/WebGLRenderer.js +94 -23
  144. package/src/renderers/common/Animation.js +23 -11
  145. package/src/renderers/common/Background.js +1 -1
  146. package/src/renderers/common/Bindings.js +20 -4
  147. package/src/renderers/common/ClippingContext.js +77 -85
  148. package/src/renderers/common/RenderList.js +9 -6
  149. package/src/renderers/common/RenderObject.js +27 -27
  150. package/src/renderers/common/RenderObjects.js +12 -6
  151. package/src/renderers/common/Renderer.js +63 -57
  152. package/src/renderers/common/Textures.js +11 -3
  153. package/src/renderers/common/UniformsGroup.js +16 -4
  154. package/src/renderers/common/extras/PMREMGenerator.js +89 -13
  155. package/src/renderers/common/nodes/NodeLibrary.js +2 -2
  156. package/src/renderers/common/nodes/NodeStorageBuffer.js +2 -3
  157. package/src/renderers/common/nodes/NodeUniform.js +42 -0
  158. package/src/renderers/webgl/WebGLBackground.js +20 -1
  159. package/src/renderers/webgl/WebGLGeometries.js +0 -28
  160. package/src/renderers/webgl-fallback/WebGLBackend.js +13 -6
  161. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +43 -12
  162. package/src/renderers/webgl-fallback/utils/WebGLState.js +26 -1
  163. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +4 -1
  164. package/src/renderers/webgpu/WebGPUBackend.js +47 -31
  165. package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +13 -26
  166. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +184 -74
  167. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +15 -2
  168. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +72 -7
  169. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +5 -1
  170. package/src/textures/Source.js +2 -2
  171. package/src/textures/Texture.js +2 -2
  172. package/src/nodes/display/BlendMode.js +0 -54
@@ -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.globalClippingCount = 0;
13
+ this.clipIntersection = null;
14
+ this.cacheKey = '';
15
15
 
16
- this.localClippingCount = 0;
17
- this.localClippingEnabled = false;
18
- this.localClipIntersection = false;
19
16
 
20
- this.planes = [];
17
+ if ( parentContext === null ) {
21
18
 
22
- this.parentVersion = 0;
23
- this.viewNormalMatrix = new Matrix3();
24
- this.cacheKey = 0;
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 = planes[ offset + i ];
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( renderer, camera ) {
62
+ updateGlobal( scene, camera ) {
50
63
 
51
- const rendererClippingPlanes = renderer.clippingPlanes;
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
- let update = false;
57
-
58
- if ( Array.isArray( rendererClippingPlanes ) && rendererClippingPlanes.length !== 0 ) {
69
+ }
59
70
 
60
- const l = rendererClippingPlanes.length;
71
+ update( parentContext, clippingGroup ) {
61
72
 
62
- if ( l !== this.globalClippingCount ) {
73
+ let update = false;
63
74
 
64
- const planes = [];
75
+ if ( parentContext.version !== this.parentVersion ) {
65
76
 
66
- for ( let i = 0; i < l; i ++ ) {
77
+ this.intersectionPlanes = Array.from( parentContext.intersectionPlanes );
78
+ this.unionPlanes = Array.from( parentContext.unionPlanes );
79
+ this.parentVersion = parentContext.version;
67
80
 
68
- planes.push( new Vector4() );
81
+ }
69
82
 
70
- }
83
+ if ( this.clipIntersection !== clippingGroup.clipIntersection ) {
71
84
 
72
- this.globalClippingCount = l;
73
- this.planes = planes;
85
+ this.clipIntersection = clippingGroup.clipIntersection;
74
86
 
75
- update = true;
87
+ if ( this.clipIntersection ) {
76
88
 
77
- }
89
+ this.unionPlanes.length = parentContext.unionPlanes.length;
78
90
 
79
- this.projectPlanes( rendererClippingPlanes, 0 );
91
+ } else {
80
92
 
81
- } else if ( this.globalClippingCount !== 0 ) {
93
+ this.intersectionPlanes.length = parentContext.intersectionPlanes.length;
82
94
 
83
- this.globalClippingCount = 0;
84
- this.planes = [];
85
- update = true;
95
+ }
86
96
 
87
97
  }
88
98
 
89
- if ( renderer.localClippingEnabled !== this.localClippingEnabled ) {
99
+ const srcClippingPlanes = clippingGroup.clippingPlanes;
100
+ const l = srcClippingPlanes.length;
90
101
 
91
- this.localClippingEnabled = renderer.localClippingEnabled;
92
- update = true;
102
+ let dstClippingPlanes;
103
+ let offset;
93
104
 
94
- }
105
+ if ( this.clipIntersection ) {
95
106
 
96
- if ( update ) {
107
+ dstClippingPlanes = this.intersectionPlanes;
108
+ offset = parentContext.intersectionPlanes.length;
97
109
 
98
- this.version ++;
99
- this.cacheKey = hash( this.globalClippingCount, this.localClippingEnabled === true ? 1 : 0 );
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
- update( parent, material ) {
119
+ dstClippingPlanes.length = offset + l;
106
120
 
107
- let update = false;
121
+ for ( let i = 0; i < l; i ++ ) {
108
122
 
109
- if ( this !== parent && parent.version !== this.parentVersion ) {
123
+ dstClippingPlanes[ offset + i ] = new Vector4();
110
124
 
111
- this.globalClippingCount = material.isShadowNodeMaterial ? 0 : parent.globalClippingCount;
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
- if ( this.localClippingEnabled ) {
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
- if ( update || l !== this.localClippingCount ) {
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
- this.localClippingCount = l;
143
- update = true;
135
+ this.version ++;
136
+ this.cacheKey = `${ this.intersectionPlanes.length }:${ this.unionPlanes.length }`;
144
137
 
145
- }
138
+ }
146
139
 
147
- this.projectPlanes( localClippingPlanes, offset );
140
+ }
148
141
 
142
+ getGroupContext( clippingGroup ) {
149
143
 
150
- } else if ( this.localClippingCount !== 0 ) {
144
+ if ( this.shadowPass && ! clippingGroup.clipShadows ) return this;
151
145
 
152
- this.localClippingCount = 0;
153
- update = true;
146
+ let context = this.clippingGroupContexts.get( clippingGroup );
154
147
 
155
- }
148
+ if ( context === undefined ) {
156
149
 
157
- if ( this.localClipIntersection !== material.clipIntersection ) {
150
+ context = new ClippingContext( this );
151
+ this.clippingGroupContexts.set( clippingGroup, context );
158
152
 
159
- this.localClipIntersection = material.clipIntersection;
160
- update = true;
153
+ }
161
154
 
162
- }
155
+ context.update( this, clippingGroup );
163
156
 
164
- }
157
+ return context;
165
158
 
166
- if ( update ) {
159
+ }
167
160
 
168
- this.version += parent.version;
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
 
@@ -95,7 +95,7 @@ class RenderList {
95
95
 
96
96
  }
97
97
 
98
- getNextRenderItem( object, geometry, material, groupOrder, z, group ) {
98
+ getNextRenderItem( object, geometry, material, groupOrder, z, group, clippingContext ) {
99
99
 
100
100
  let renderItem = this.renderItems[ this.renderItemsIndex ];
101
101
 
@@ -109,7 +109,8 @@ class RenderList {
109
109
  groupOrder: groupOrder,
110
110
  renderOrder: object.renderOrder,
111
111
  z: z,
112
- group: group
112
+ group: group,
113
+ clippingContext: clippingContext
113
114
  };
114
115
 
115
116
  this.renderItems[ this.renderItemsIndex ] = renderItem;
@@ -124,6 +125,7 @@ class RenderList {
124
125
  renderItem.renderOrder = object.renderOrder;
125
126
  renderItem.z = z;
126
127
  renderItem.group = group;
128
+ renderItem.clippingContext = clippingContext;
127
129
 
128
130
  }
129
131
 
@@ -133,9 +135,9 @@ class RenderList {
133
135
 
134
136
  }
135
137
 
136
- push( object, geometry, material, groupOrder, z, group ) {
138
+ push( object, geometry, material, groupOrder, z, group, clippingContext ) {
137
139
 
138
- const renderItem = this.getNextRenderItem( object, geometry, material, groupOrder, z, group );
140
+ const renderItem = this.getNextRenderItem( object, geometry, material, groupOrder, z, group, clippingContext );
139
141
 
140
142
  if ( object.occlusionTest === true ) this.occlusionQueryCount ++;
141
143
 
@@ -153,9 +155,9 @@ class RenderList {
153
155
 
154
156
  }
155
157
 
156
- unshift( object, geometry, material, groupOrder, z, group ) {
158
+ unshift( object, geometry, material, groupOrder, z, group, clippingContext ) {
157
159
 
158
- const renderItem = this.getNextRenderItem( object, geometry, material, groupOrder, z, group );
160
+ const renderItem = this.getNextRenderItem( object, geometry, material, groupOrder, z, group, clippingContext );
159
161
 
160
162
  if ( material.transparent === true || material.transmission > 0 ) {
161
163
 
@@ -213,6 +215,7 @@ class RenderList {
213
215
  renderItem.renderOrder = null;
214
216
  renderItem.z = null;
215
217
  renderItem.group = null;
218
+ renderItem.clippingContext = null;
216
219
 
217
220
  }
218
221
 
@@ -1,5 +1,4 @@
1
1
  import { hashString } from '../../nodes/core/NodeUtils.js';
2
- import ClippingContext from './ClippingContext.js';
3
2
 
4
3
  let _id = 0;
5
4
 
@@ -39,7 +38,7 @@ function getKeys( obj ) {
39
38
 
40
39
  export default class RenderObject {
41
40
 
42
- constructor( nodes, geometries, renderer, object, material, scene, camera, lightsNode, renderContext ) {
41
+ constructor( nodes, geometries, renderer, object, material, scene, camera, lightsNode, renderContext, clippingContext ) {
43
42
 
44
43
  this._nodes = nodes;
45
44
  this._geometries = geometries;
@@ -66,9 +65,8 @@ export default class RenderObject {
66
65
 
67
66
  this.bundle = null;
68
67
 
69
- this.updateClipping( renderContext.clippingContext );
70
-
71
- this.clippingContextVersion = this.clippingContext.version;
68
+ this.clippingContext = clippingContext;
69
+ this.clippingContextCacheKey = clippingContext !== null ? clippingContext.cacheKey : '';
72
70
 
73
71
  this.initialNodesCacheKey = this.getDynamicCacheKey();
74
72
  this.initialCacheKey = this.getCacheKey();
@@ -93,36 +91,23 @@ export default class RenderObject {
93
91
 
94
92
  updateClipping( parent ) {
95
93
 
96
- const material = this.material;
97
-
98
- let clippingContext = this.clippingContext;
99
-
100
- if ( Array.isArray( material.clippingPlanes ) ) {
94
+ this.clippingContext = parent;
101
95
 
102
- if ( clippingContext === parent || ! clippingContext ) {
103
-
104
- clippingContext = new ClippingContext();
105
- this.clippingContext = clippingContext;
106
-
107
- }
96
+ }
108
97
 
109
- clippingContext.update( parent, material );
98
+ get clippingNeedsUpdate() {
110
99
 
111
- } else if ( this.clippingContext !== parent ) {
100
+ if ( this.clippingContext === null || this.clippingContext.cacheKey === this.clippingContextCacheKey ) return false;
112
101
 
113
- this.clippingContext = parent;
102
+ this.clippingContextCacheKey = this.clippingContext.cacheKey;
114
103
 
115
- }
104
+ return true;
116
105
 
117
106
  }
118
107
 
119
- get clippingNeedsUpdate() {
120
-
121
- if ( this.clippingContext.version === this.clippingContextVersion ) return false;
108
+ get hardwareClippingPlanes() {
122
109
 
123
- this.clippingContextVersion = this.clippingContext.version;
124
-
125
- return true;
110
+ return this.material.hardwareClipping === true ? this.clippingContext.unionClippingCount : 0;
126
111
 
127
112
  }
128
113
 
@@ -162,6 +147,13 @@ export default class RenderObject {
162
147
 
163
148
  }
164
149
 
150
+ setGeometry( geometry ) {
151
+
152
+ this.geometry = geometry;
153
+ this.attributes = null;
154
+
155
+ }
156
+
165
157
  getAttributes() {
166
158
 
167
159
  if ( this.attributes !== null ) return this.attributes;
@@ -347,7 +339,7 @@ export default class RenderObject {
347
339
 
348
340
  }
349
341
 
350
- cacheKey += this.clippingContext.cacheKey + ',';
342
+ cacheKey += this.clippingContextCacheKey + ',';
351
343
 
352
344
  if ( object.geometry ) {
353
345
 
@@ -387,10 +379,18 @@ export default class RenderObject {
387
379
 
388
380
  }
389
381
 
382
+ cacheKey += object.receiveShadow + ',';
383
+
390
384
  return hashString( cacheKey );
391
385
 
392
386
  }
393
387
 
388
+ get needsGeometryUpdate() {
389
+
390
+ return this.geometry.id !== this.object.geometry.id;
391
+
392
+ }
393
+
394
394
  get needsUpdate() {
395
395
 
396
396
  return /*this.object.static !== true &&*/ ( this.initialNodesCacheKey !== this.getDynamicCacheKey() || this.clippingNeedsUpdate );
@@ -18,7 +18,7 @@ class RenderObjects {
18
18
 
19
19
  }
20
20
 
21
- get( object, material, scene, camera, lightsNode, renderContext, passId ) {
21
+ get( object, material, scene, camera, lightsNode, renderContext, clippingContext, passId ) {
22
22
 
23
23
  const chainMap = this.getChainMap( passId );
24
24
 
@@ -32,13 +32,19 @@ class RenderObjects {
32
32
 
33
33
  if ( renderObject === undefined ) {
34
34
 
35
- renderObject = this.createRenderObject( this.nodes, this.geometries, this.renderer, object, material, scene, camera, lightsNode, renderContext, passId );
35
+ renderObject = this.createRenderObject( this.nodes, this.geometries, this.renderer, object, material, scene, camera, lightsNode, renderContext, clippingContext, passId );
36
36
 
37
37
  chainMap.set( chainArray, renderObject );
38
38
 
39
39
  } else {
40
40
 
41
- renderObject.updateClipping( renderContext.clippingContext );
41
+ renderObject.updateClipping( clippingContext );
42
+
43
+ if ( renderObject.needsGeometryUpdate ) {
44
+
45
+ renderObject.setGeometry( object.geometry );
46
+
47
+ }
42
48
 
43
49
  if ( renderObject.version !== material.version || renderObject.needsUpdate ) {
44
50
 
@@ -46,7 +52,7 @@ class RenderObjects {
46
52
 
47
53
  renderObject.dispose();
48
54
 
49
- renderObject = this.get( object, material, scene, camera, lightsNode, renderContext, passId );
55
+ renderObject = this.get( object, material, scene, camera, lightsNode, renderContext, clippingContext, passId );
50
56
 
51
57
  } else {
52
58
 
@@ -74,11 +80,11 @@ class RenderObjects {
74
80
 
75
81
  }
76
82
 
77
- createRenderObject( nodes, geometries, renderer, object, material, scene, camera, lightsNode, renderContext, passId ) {
83
+ createRenderObject( nodes, geometries, renderer, object, material, scene, camera, lightsNode, renderContext, clippingContext, passId ) {
78
84
 
79
85
  const chainMap = this.getChainMap( passId );
80
86
 
81
- const renderObject = new RenderObject( nodes, geometries, renderer, object, material, scene, camera, lightsNode, renderContext );
87
+ const renderObject = new RenderObject( nodes, geometries, renderer, object, material, scene, camera, lightsNode, renderContext, clippingContext );
82
88
 
83
89
  renderObject.onDispose = () => {
84
90