super-three 0.170.0 → 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 +24410 -24422
- package/build/three.core.js +37002 -0
- package/build/three.core.min.js +6 -0
- package/build/three.module.js +10573 -47578
- 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 +2907 -37975
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +2914 -37959
- package/build/three.webgpu.nodes.min.js +1 -1
- 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/csm/CSMShadowNode.js +7 -5
- package/examples/jsm/geometries/DecalGeometry.js +5 -1
- package/examples/jsm/lighting/TiledLighting.js +1 -1
- package/examples/jsm/lines/LineGeometry.js +25 -0
- package/examples/jsm/lines/LineMaterial.js +1 -7
- package/examples/jsm/lines/webgpu/Line2.js +2 -1
- package/examples/jsm/lines/webgpu/LineSegments2.js +2 -1
- package/examples/jsm/lines/webgpu/Wireframe.js +2 -1
- package/examples/jsm/loaders/KTX2Loader.js +3 -0
- package/examples/jsm/loaders/MMDLoader.js +2 -6
- package/examples/jsm/loaders/MaterialXLoader.js +2 -2
- package/examples/jsm/materials/MeshGouraudMaterial.js +2 -6
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +2 -2
- 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 +5 -3
- package/examples/jsm/transpiler/AST.js +2 -2
- package/examples/jsm/transpiler/GLSLDecoder.js +57 -25
- package/examples/jsm/transpiler/TSLEncoder.js +11 -6
- package/examples/jsm/tsl/display/AfterImageNode.js +3 -3
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +2 -2
- package/examples/jsm/tsl/display/AnamorphicNode.js +2 -2
- package/examples/jsm/tsl/display/BloomNode.js +3 -3
- package/examples/jsm/tsl/display/DenoiseNode.js +48 -12
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +3 -2
- package/examples/jsm/tsl/display/DotScreenNode.js +2 -2
- package/examples/jsm/tsl/display/FXAANode.js +3 -3
- package/examples/jsm/tsl/display/FilmNode.js +3 -2
- package/examples/jsm/tsl/display/GTAONode.js +62 -27
- package/examples/jsm/tsl/display/GaussianBlurNode.js +6 -8
- package/examples/jsm/tsl/display/LensflareNode.js +3 -3
- package/examples/jsm/tsl/display/Lut3DNode.js +3 -2
- package/examples/jsm/tsl/display/OutlineNode.js +2 -2
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +2 -1
- package/examples/jsm/tsl/display/PixelationPassNode.js +4 -4
- package/examples/jsm/tsl/display/RGBShiftNode.js +2 -1
- package/examples/jsm/tsl/display/SMAANode.js +3 -3
- package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
- package/examples/jsm/tsl/display/SSRNode.js +31 -8
- package/examples/jsm/tsl/display/SobelOperatorNode.js +3 -3
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +4 -4
- package/examples/jsm/tsl/display/StereoPassNode.js +2 -2
- package/examples/jsm/tsl/display/TRAAPassNode.js +2 -2
- package/examples/jsm/tsl/display/TransitionNode.js +3 -2
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +6 -9
- package/examples/jsm/utils/SceneOptimizer.js +410 -0
- package/examples/jsm/utils/UVsDebug.js +1 -1
- package/package.json +3 -3
- package/src/Three.Core.js +178 -0
- package/src/Three.TSL.js +526 -0
- package/src/Three.WebGPU.Nodes.js +5 -186
- package/src/Three.WebGPU.js +4 -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 -1
- package/src/core/BufferGeometry.js +5 -3
- 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/EdgesGeometry.js +2 -2
- package/src/geometries/LatheGeometry.js +2 -2
- package/src/lights/SpotLightShadow.js +2 -2
- package/src/materials/LineBasicMaterial.js +2 -6
- package/src/materials/LineDashedMaterial.js +1 -6
- package/src/materials/Material.js +3 -16
- package/src/materials/MeshBasicMaterial.js +2 -6
- package/src/materials/MeshDepthMaterial.js +2 -6
- package/src/materials/MeshDistanceMaterial.js +2 -6
- package/src/materials/MeshLambertMaterial.js +2 -6
- package/src/materials/MeshMatcapMaterial.js +2 -6
- package/src/materials/MeshNormalMaterial.js +2 -6
- package/src/materials/MeshPhongMaterial.js +3 -7
- package/src/materials/MeshPhysicalMaterial.js +4 -8
- package/src/materials/MeshStandardMaterial.js +2 -6
- package/src/materials/MeshToonMaterial.js +2 -6
- package/src/materials/PointsMaterial.js +2 -6
- package/src/materials/RawShaderMaterial.js +2 -6
- package/src/materials/ShaderMaterial.js +2 -6
- package/src/materials/ShadowMaterial.js +2 -6
- package/src/materials/SpriteMaterial.js +2 -6
- package/src/materials/nodes/Line2NodeMaterial.js +32 -13
- package/src/materials/nodes/LineDashedNodeMaterial.js +4 -2
- package/src/materials/nodes/NodeMaterial.js +64 -16
- package/src/materials/nodes/manager/NodeMaterialObserver.js +13 -10
- package/src/math/ColorManagement.js +130 -122
- 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 +11 -9
- package/src/nodes/Nodes.js +1 -0
- package/src/nodes/TSL.js +3 -1
- package/src/nodes/accessors/Arrays.js +27 -0
- package/src/nodes/accessors/BuiltinNode.js +26 -0
- 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/StorageBufferNode.js +29 -9
- package/src/nodes/accessors/StorageTextureNode.js +10 -4
- package/src/nodes/accessors/TextureNode.js +1 -1
- package/src/nodes/core/NodeBuilder.js +2 -9
- package/src/nodes/core/NodeUtils.js +28 -0
- package/src/nodes/core/constants.js +6 -0
- package/src/nodes/display/BlendModes.js +99 -0
- package/src/nodes/display/ToonOutlinePassNode.js +3 -3
- package/src/nodes/display/ViewportDepthNode.js +21 -6
- package/src/nodes/functions/material/getAlphaHashThreshold.js +13 -7
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +1 -1
- package/src/nodes/lighting/AnalyticLightNode.js +12 -4
- package/src/nodes/lighting/PointLightNode.js +10 -1
- package/src/nodes/lighting/PointShadowNode.js +254 -0
- package/src/nodes/lighting/ShadowNode.js +176 -67
- package/src/nodes/lighting/SpotLightNode.js +14 -2
- package/src/nodes/utils/RTTNode.js +9 -1
- package/src/nodes/utils/StorageArrayElementNode.js +2 -2
- package/src/objects/BatchedMesh.js +54 -95
- package/src/objects/ClippingGroup.js +19 -0
- package/src/objects/Skeleton.js +2 -2
- package/src/renderers/WebGLRenderer.js +94 -23
- package/src/renderers/common/Animation.js +23 -11
- package/src/renderers/common/Background.js +1 -1
- package/src/renderers/common/Bindings.js +20 -4
- package/src/renderers/common/ClippingContext.js +77 -85
- package/src/renderers/common/RenderList.js +9 -6
- package/src/renderers/common/RenderObject.js +27 -27
- package/src/renderers/common/RenderObjects.js +12 -6
- package/src/renderers/common/Renderer.js +63 -57
- package/src/renderers/common/Textures.js +11 -3
- 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 -2
- package/src/renderers/common/nodes/NodeStorageBuffer.js +2 -3
- package/src/renderers/common/nodes/NodeUniform.js +42 -0
- package/src/renderers/webgl/WebGLBackground.js +20 -1
- package/src/renderers/webgl/WebGLGeometries.js +0 -28
- package/src/renderers/webgl-fallback/WebGLBackend.js +13 -6
- 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 +4 -1
- package/src/renderers/webgpu/WebGPUBackend.js +47 -31
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +13 -26
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +184 -74
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +15 -2
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +72 -7
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +5 -1
- package/src/textures/Source.js +2 -2
- package/src/textures/Texture.js +2 -2
- 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.
|
|
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
|
|
|
@@ -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.
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
let clippingContext = this.clippingContext;
|
|
99
|
-
|
|
100
|
-
if ( Array.isArray( material.clippingPlanes ) ) {
|
|
94
|
+
this.clippingContext = parent;
|
|
101
95
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
clippingContext = new ClippingContext();
|
|
105
|
-
this.clippingContext = clippingContext;
|
|
106
|
-
|
|
107
|
-
}
|
|
96
|
+
}
|
|
108
97
|
|
|
109
|
-
|
|
98
|
+
get clippingNeedsUpdate() {
|
|
110
99
|
|
|
111
|
-
|
|
100
|
+
if ( this.clippingContext === null || this.clippingContext.cacheKey === this.clippingContextCacheKey ) return false;
|
|
112
101
|
|
|
113
|
-
|
|
102
|
+
this.clippingContextCacheKey = this.clippingContext.cacheKey;
|
|
114
103
|
|
|
115
|
-
|
|
104
|
+
return true;
|
|
116
105
|
|
|
117
106
|
}
|
|
118
107
|
|
|
119
|
-
get
|
|
120
|
-
|
|
121
|
-
if ( this.clippingContext.version === this.clippingContextVersion ) return false;
|
|
108
|
+
get hardwareClippingPlanes() {
|
|
122
109
|
|
|
123
|
-
this.
|
|
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.
|
|
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(
|
|
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
|
|