super-three 0.163.0 → 0.164.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 (114) hide show
  1. package/build/three.cjs +473 -245
  2. package/build/three.module.js +473 -245
  3. package/build/three.module.min.js +2 -2
  4. package/examples/jsm/animation/CCDIKSolver.js +4 -2
  5. package/examples/jsm/exporters/GLTFExporter.js +45 -1
  6. package/examples/jsm/exporters/USDZExporter.js +7 -1
  7. package/examples/jsm/libs/draco/README.md +2 -2
  8. package/examples/jsm/loaders/EXRLoader.js +283 -99
  9. package/examples/jsm/loaders/GLTFLoader.js +53 -0
  10. package/examples/jsm/loaders/KTX2Loader.js +3 -6
  11. package/examples/jsm/loaders/VRMLLoader.js +1 -1
  12. package/examples/jsm/loaders/lwo/IFFParser.js +8 -5
  13. package/examples/jsm/materials/MeshGouraudMaterial.js +7 -1
  14. package/examples/jsm/math/Octree.js +26 -20
  15. package/examples/jsm/nodes/Nodes.js +4 -3
  16. package/examples/jsm/nodes/accessors/AccessorsUtils.js +16 -1
  17. package/examples/jsm/nodes/accessors/ClippingNode.js +3 -2
  18. package/examples/jsm/nodes/accessors/MaterialNode.js +107 -3
  19. package/examples/jsm/nodes/accessors/StorageBufferNode.js +9 -0
  20. package/examples/jsm/nodes/accessors/TextureNode.js +21 -3
  21. package/examples/jsm/nodes/accessors/TextureSizeNode.js +1 -1
  22. package/examples/jsm/nodes/code/FunctionNode.js +0 -8
  23. package/examples/jsm/nodes/core/Node.js +8 -0
  24. package/examples/jsm/nodes/core/NodeBuilder.js +5 -9
  25. package/examples/jsm/nodes/core/OutputStructNode.js +2 -1
  26. package/examples/jsm/nodes/core/PropertyNode.js +10 -0
  27. package/examples/jsm/nodes/display/BumpMapNode.js +7 -26
  28. package/examples/jsm/nodes/display/FrontFacingNode.js +13 -0
  29. package/examples/jsm/nodes/display/ViewportDepthNode.js +1 -1
  30. package/examples/jsm/nodes/display/ViewportNode.js +4 -2
  31. package/examples/jsm/nodes/display/ViewportTextureNode.js +4 -1
  32. package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +26 -7
  33. package/examples/jsm/nodes/functions/BSDF/D_GGX_Anisotropic.js +28 -0
  34. package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +1 -3
  35. package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +29 -0
  36. package/examples/jsm/nodes/functions/PhongLightingModel.js +1 -1
  37. package/examples/jsm/nodes/functions/PhysicalLightingModel.js +164 -10
  38. package/examples/jsm/nodes/functions/ShadowMaskModel.js +31 -0
  39. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +18 -4
  40. package/examples/jsm/nodes/lighting/DirectionalLightNode.js +2 -1
  41. package/examples/jsm/nodes/lighting/EnvironmentNode.js +11 -2
  42. package/examples/jsm/nodes/lighting/IrradianceNode.js +24 -0
  43. package/examples/jsm/nodes/lighting/LightsNode.js +11 -1
  44. package/examples/jsm/nodes/lighting/PointLightNode.js +2 -1
  45. package/examples/jsm/nodes/lighting/SpotLightNode.js +2 -1
  46. package/examples/jsm/nodes/materials/Line2NodeMaterial.js +10 -6
  47. package/examples/jsm/nodes/materials/Materials.js +1 -0
  48. package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +0 -2
  49. package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +2 -2
  50. package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +76 -5
  51. package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +11 -4
  52. package/examples/jsm/nodes/materials/NodeMaterial.js +31 -41
  53. package/examples/jsm/nodes/materials/ShadowNodeMaterial.js +34 -0
  54. package/examples/jsm/nodes/pmrem/PMREMUtils.js +1 -1
  55. package/examples/jsm/nodes/shadernode/ShaderNode.js +2 -8
  56. package/examples/jsm/physics/JoltPhysics.js +281 -0
  57. package/examples/jsm/postprocessing/RenderTransitionPass.js +193 -0
  58. package/examples/jsm/renderers/common/Background.js +3 -3
  59. package/examples/jsm/renderers/common/ClippingContext.js +1 -1
  60. package/examples/jsm/renderers/common/RenderList.js +1 -1
  61. package/examples/jsm/renderers/common/RenderObject.js +43 -1
  62. package/examples/jsm/renderers/common/Renderer.js +129 -14
  63. package/examples/jsm/renderers/common/Textures.js +1 -1
  64. package/examples/jsm/renderers/common/extras/PMREMGenerator.js +13 -17
  65. package/examples/jsm/renderers/common/nodes/Nodes.js +31 -47
  66. package/examples/jsm/renderers/webgl/WebGLBackend.js +7 -21
  67. package/examples/jsm/renderers/webgl/WebGLBufferRenderer.js +5 -1
  68. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +6 -0
  69. package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +21 -7
  70. package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +3 -21
  71. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +33 -45
  72. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +16 -1
  73. package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +4 -1
  74. package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
  75. package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
  76. package/examples/jsm/utils/SceneUtils.js +60 -1
  77. package/examples/jsm/webxr/OculusHandModel.js +3 -2
  78. package/examples/jsm/webxr/XRHandModelFactory.js +4 -2
  79. package/package.json +1 -1
  80. package/src/constants.js +1 -1
  81. package/src/core/RenderTarget.js +8 -0
  82. package/src/extras/PMREMGenerator.js +12 -11
  83. package/src/loaders/FileLoader.js +1 -1
  84. package/src/loaders/MaterialLoader.js +1 -0
  85. package/src/materials/Material.js +2 -0
  86. package/src/materials/MeshPhysicalMaterial.js +20 -0
  87. package/src/objects/BatchedMesh.js +23 -0
  88. package/src/objects/Line.js +66 -43
  89. package/src/renderers/WebGLRenderer.js +92 -61
  90. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +6 -0
  91. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +1 -0
  92. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +17 -9
  93. package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
  94. package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +47 -13
  95. package/src/renderers/shaders/ShaderChunk.js +0 -2
  96. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -0
  97. package/src/renderers/shaders/ShaderLib.js +1 -0
  98. package/src/renderers/webgl/WebGLBackground.js +18 -3
  99. package/src/renderers/webgl/WebGLBufferRenderer.js +36 -0
  100. package/src/renderers/webgl/WebGLCapabilities.js +33 -1
  101. package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +36 -0
  102. package/src/renderers/webgl/WebGLMaterials.js +6 -0
  103. package/src/renderers/webgl/WebGLProgram.js +3 -5
  104. package/src/renderers/webgl/WebGLPrograms.js +5 -0
  105. package/src/renderers/webgl/WebGLRenderStates.js +6 -2
  106. package/src/renderers/webgl/WebGLShadowMap.js +25 -25
  107. package/src/renderers/webgl/WebGLTextures.js +68 -60
  108. package/src/renderers/webgl/WebGLUtils.js +3 -21
  109. package/src/renderers/webxr/WebXRManager.js +2 -4
  110. package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +0 -318
  111. package/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +0 -26
  112. package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +0 -792
  113. package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodes.js +0 -51
  114. package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +0 -10
@@ -0,0 +1,281 @@
1
+ import { Clock, Vector3, Quaternion, Matrix4 } from 'three';
2
+
3
+ const JOLT_PATH = 'https://cdn.jsdelivr.net/npm/jolt-physics@0.23.0/dist/jolt-physics.wasm-compat.js';
4
+
5
+ const frameRate = 60;
6
+
7
+ let Jolt = null;
8
+
9
+ function getShape( geometry ) {
10
+
11
+ const parameters = geometry.parameters;
12
+
13
+ // TODO change type to is*
14
+
15
+ if ( geometry.type === 'BoxGeometry' ) {
16
+
17
+ const sx = parameters.width !== undefined ? parameters.width / 2 : 0.5;
18
+ const sy = parameters.height !== undefined ? parameters.height / 2 : 0.5;
19
+ const sz = parameters.depth !== undefined ? parameters.depth / 2 : 0.5;
20
+
21
+ return new Jolt.BoxShape( new Jolt.Vec3( sx, sy, sz ), 0.05 * Math.min( sx, sy, sz ), null );
22
+
23
+ } else if ( geometry.type === 'SphereGeometry' || geometry.type === 'IcosahedronGeometry' ) {
24
+
25
+ const radius = parameters.radius !== undefined ? parameters.radius : 1;
26
+
27
+ return new Jolt.SphereShape( radius, null );
28
+
29
+ }
30
+
31
+ return null;
32
+
33
+ }
34
+
35
+ // Object layers
36
+ const LAYER_NON_MOVING = 0;
37
+ const LAYER_MOVING = 1;
38
+ const NUM_OBJECT_LAYERS = 2;
39
+
40
+ function setupCollisionFiltering( settings ) {
41
+
42
+ let objectFilter = new Jolt.ObjectLayerPairFilterTable( NUM_OBJECT_LAYERS );
43
+ objectFilter.EnableCollision( LAYER_NON_MOVING, LAYER_MOVING );
44
+ objectFilter.EnableCollision( LAYER_MOVING, LAYER_MOVING );
45
+
46
+ const BP_LAYER_NON_MOVING = new Jolt.BroadPhaseLayer( 0 );
47
+ const BP_LAYER_MOVING = new Jolt.BroadPhaseLayer( 1 );
48
+ const NUM_BROAD_PHASE_LAYERS = 2;
49
+
50
+ let bpInterface = new Jolt.BroadPhaseLayerInterfaceTable( NUM_OBJECT_LAYERS, NUM_BROAD_PHASE_LAYERS );
51
+ bpInterface.MapObjectToBroadPhaseLayer( LAYER_NON_MOVING, BP_LAYER_NON_MOVING );
52
+ bpInterface.MapObjectToBroadPhaseLayer( LAYER_MOVING, BP_LAYER_MOVING );
53
+
54
+ settings.mObjectLayerPairFilter = objectFilter;
55
+ settings.mBroadPhaseLayerInterface = bpInterface;
56
+ settings.mObjectVsBroadPhaseLayerFilter = new Jolt.ObjectVsBroadPhaseLayerFilterTable( settings.mBroadPhaseLayerInterface, NUM_BROAD_PHASE_LAYERS, settings.mObjectLayerPairFilter, NUM_OBJECT_LAYERS );
57
+
58
+ };
59
+
60
+ async function JoltPhysics() {
61
+
62
+ if ( Jolt === null ) {
63
+
64
+ const { default: initJolt } = await import( JOLT_PATH );
65
+ Jolt = await initJolt();
66
+
67
+ }
68
+
69
+ const settings = new Jolt.JoltSettings();
70
+ setupCollisionFiltering( settings );
71
+
72
+ const jolt = new Jolt.JoltInterface( settings );
73
+ Jolt.destroy( settings );
74
+
75
+ const physicsSystem = jolt.GetPhysicsSystem();
76
+ const bodyInterface = physicsSystem.GetBodyInterface();
77
+
78
+ const meshes = [];
79
+ const meshMap = new WeakMap();
80
+
81
+ const _position = new Vector3();
82
+ const _quaternion = new Quaternion();
83
+ const _scale = new Vector3( 1, 1, 1 );
84
+
85
+ const _matrix = new Matrix4();
86
+
87
+ function addScene( scene ) {
88
+
89
+ scene.traverse( function ( child ) {
90
+
91
+ if ( child.isMesh ) {
92
+
93
+ const physics = child.userData.physics;
94
+
95
+ if ( physics ) {
96
+
97
+ addMesh( child, physics.mass, physics.restitution );
98
+
99
+ }
100
+
101
+ }
102
+
103
+ } );
104
+
105
+ }
106
+
107
+ function addMesh( mesh, mass = 0, restitution = 0 ) {
108
+
109
+ const shape = getShape( mesh.geometry );
110
+
111
+ if ( shape === null ) return;
112
+
113
+ const body = mesh.isInstancedMesh
114
+ ? createInstancedBody( mesh, mass, restitution, shape )
115
+ : createBody( mesh.position, mesh.quaternion, mass, restitution, shape );
116
+
117
+ if ( mass > 0 ) {
118
+
119
+ meshes.push( mesh );
120
+ meshMap.set( mesh, body );
121
+
122
+ }
123
+
124
+ }
125
+
126
+ function createInstancedBody( mesh, mass, restitution, shape ) {
127
+
128
+ const array = mesh.instanceMatrix.array;
129
+
130
+ const bodies = [];
131
+
132
+ for ( let i = 0; i < mesh.count; i ++ ) {
133
+
134
+ const position = _position.fromArray( array, i * 16 + 12 );
135
+ const quaternion = _quaternion.setFromRotationMatrix( _matrix.fromArray( array, i * 16 ) ); // TODO Copilot did this
136
+ bodies.push( createBody( position, quaternion, mass, restitution, shape ) );
137
+
138
+ }
139
+
140
+ return bodies;
141
+
142
+ }
143
+
144
+ function createBody( position, rotation, mass, restitution, shape ) {
145
+
146
+ const pos = new Jolt.Vec3( position.x, position.y, position.z );
147
+ const rot = new Jolt.Quat( rotation.x, rotation.y, rotation.z, rotation.w );
148
+
149
+ const motion = mass > 0 ? Jolt.EMotionType_Dynamic : Jolt.EMotionType_Static;
150
+ const layer = mass > 0 ? LAYER_MOVING : LAYER_NON_MOVING;
151
+
152
+ const creationSettings = new Jolt.BodyCreationSettings( shape, pos, rot, motion, layer );
153
+ creationSettings.mRestitution = restitution;
154
+
155
+ const body = bodyInterface.CreateBody( creationSettings );
156
+
157
+ bodyInterface.AddBody( body.GetID(), Jolt.EActivation_Activate );
158
+
159
+ Jolt.destroy( creationSettings );
160
+
161
+ return body;
162
+
163
+ }
164
+
165
+ function setMeshPosition( mesh, position, index = 0 ) {
166
+
167
+ if ( mesh.isInstancedMesh ) {
168
+
169
+ const bodies = meshMap.get( mesh );
170
+
171
+ const body = bodies[ index ];
172
+
173
+ bodyInterface.RemoveBody( body.GetID() );
174
+ bodyInterface.DestroyBody( body.GetID() );
175
+
176
+ const physics = mesh.userData.physics;
177
+
178
+ let shape = body.GetShape();
179
+ let body2 = createBody( position, { x: 0, y: 0, z: 0, w: 1 }, physics.mass, physics.restitution, shape );
180
+
181
+ bodies[ index ] = body2;
182
+
183
+ } else {
184
+
185
+ // TODO: Implement this
186
+
187
+ }
188
+
189
+ }
190
+
191
+ function setMeshVelocity( mesh, velocity, index = 0 ) {
192
+
193
+ /*
194
+ let body = meshMap.get( mesh );
195
+
196
+ if ( mesh.isInstancedMesh ) {
197
+
198
+ body = body[ index ];
199
+
200
+ }
201
+
202
+ body.setLinvel( velocity );
203
+ */
204
+
205
+ }
206
+
207
+ //
208
+
209
+ const clock = new Clock();
210
+
211
+ function step() {
212
+
213
+ let deltaTime = clock.getDelta();
214
+
215
+ // Don't go below 30 Hz to prevent spiral of death
216
+ deltaTime = Math.min( deltaTime, 1.0 / 30.0 );
217
+
218
+ // When running below 55 Hz, do 2 steps instead of 1
219
+ const numSteps = deltaTime > 1.0 / 55.0 ? 2 : 1;
220
+
221
+ // Step the physics world
222
+ jolt.Step( deltaTime, numSteps );
223
+
224
+ //
225
+
226
+ for ( let i = 0, l = meshes.length; i < l; i ++ ) {
227
+
228
+ const mesh = meshes[ i ];
229
+
230
+ if ( mesh.isInstancedMesh ) {
231
+
232
+ const array = mesh.instanceMatrix.array;
233
+ const bodies = meshMap.get( mesh );
234
+
235
+ for ( let j = 0; j < bodies.length; j ++ ) {
236
+
237
+ const body = bodies[ j ];
238
+
239
+ const position = body.GetPosition();
240
+ const quaternion = body.GetRotation();
241
+
242
+ _position.set( position.GetX(), position.GetY(), position.GetZ() );
243
+ _quaternion.set( quaternion.GetX(), quaternion.GetY(), quaternion.GetZ(), quaternion.GetW() );
244
+
245
+ _matrix.compose( _position, _quaternion, _scale ).toArray( array, j * 16 );
246
+
247
+ }
248
+
249
+ mesh.instanceMatrix.needsUpdate = true;
250
+ mesh.computeBoundingSphere();
251
+
252
+ } else {
253
+
254
+ const body = meshMap.get( mesh );
255
+
256
+ const position = body.GetPosition();
257
+ const rotation = body.GetRotation();
258
+
259
+ mesh.position.set( position.GetX(), position.GetY(), position.GetZ() );
260
+ mesh.quaternion.set( rotation.GetX(), rotation.GetY(), rotation.GetZ(), rotation.GetW() );
261
+
262
+ }
263
+
264
+ }
265
+
266
+ }
267
+
268
+ // animate
269
+
270
+ setInterval( step, 1000 / frameRate );
271
+
272
+ return {
273
+ addScene: addScene,
274
+ addMesh: addMesh,
275
+ setMeshPosition: setMeshPosition,
276
+ setMeshVelocity: setMeshVelocity
277
+ };
278
+
279
+ }
280
+
281
+ export { JoltPhysics };
@@ -0,0 +1,193 @@
1
+ import {
2
+ HalfFloatType,
3
+ ShaderMaterial,
4
+ WebGLRenderTarget
5
+ } from 'three';
6
+ import { FullScreenQuad, Pass } from './Pass.js';
7
+
8
+ class RenderTransitionPass extends Pass {
9
+
10
+ constructor( sceneA, cameraA, sceneB, cameraB ) {
11
+
12
+ super();
13
+
14
+ this.material = this.createMaterial();
15
+ this.fsQuad = new FullScreenQuad( this.material );
16
+
17
+ this.sceneA = sceneA;
18
+ this.cameraA = cameraA;
19
+ this.sceneB = sceneB;
20
+ this.cameraB = cameraB;
21
+
22
+ this.renderTargetA = new WebGLRenderTarget();
23
+ this.renderTargetA.texture.type = HalfFloatType;
24
+ this.renderTargetB = new WebGLRenderTarget();
25
+ this.renderTargetB.texture.type = HalfFloatType;
26
+
27
+ }
28
+
29
+ setTransition( value ) {
30
+
31
+ this.material.uniforms.mixRatio.value = value;
32
+
33
+ }
34
+
35
+ useTexture( value ) {
36
+
37
+ this.material.uniforms.useTexture.value = value ? 1 : 0;
38
+
39
+ }
40
+
41
+ setTexture( value ) {
42
+
43
+ this.material.uniforms.tMixTexture.value = value;
44
+
45
+ }
46
+
47
+ setTextureThreshold( value ) {
48
+
49
+ this.material.uniforms.threshold.value = value;
50
+
51
+ }
52
+
53
+ setSize( width, height ) {
54
+
55
+ this.renderTargetA.setSize( width, height );
56
+ this.renderTargetB.setSize( width, height );
57
+
58
+ }
59
+
60
+ render( renderer, writeBuffer ) {
61
+
62
+ const uniforms = this.fsQuad.material.uniforms;
63
+ const transition = uniforms.mixRatio.value;
64
+
65
+ // Prevent render both scenes when it's not necessary
66
+
67
+ if ( transition === 0 ) {
68
+
69
+ renderer.setRenderTarget( writeBuffer );
70
+ if ( this.clear ) renderer.clear();
71
+ renderer.render( this.sceneB, this.cameraB );
72
+
73
+ } else if ( transition === 1 ) {
74
+
75
+ renderer.setRenderTarget( writeBuffer );
76
+ if ( this.clear ) renderer.clear();
77
+ renderer.render( this.sceneA, this.cameraA );
78
+
79
+ } else {
80
+
81
+ // When 0 < transition < 1 render transition between two scenes
82
+
83
+ renderer.setRenderTarget( this.renderTargetA );
84
+ renderer.render( this.sceneA, this.cameraA );
85
+ renderer.setRenderTarget( this.renderTargetB );
86
+ renderer.render( this.sceneB, this.cameraB );
87
+
88
+ uniforms.tDiffuse1.value = this.renderTargetA.texture;
89
+ uniforms.tDiffuse2.value = this.renderTargetB.texture;
90
+
91
+ if ( this.renderToScreen ) {
92
+
93
+ renderer.setRenderTarget( null );
94
+ renderer.clear();
95
+
96
+ } else {
97
+
98
+ renderer.setRenderTarget( writeBuffer );
99
+ if ( this.clear ) renderer.clear();
100
+
101
+ }
102
+
103
+ this.fsQuad.render( renderer );
104
+
105
+ }
106
+
107
+ }
108
+
109
+ dispose() {
110
+
111
+ this.renderTargetA.dispose();
112
+ this.renderTargetB.dispose();
113
+ this.material.dispose();
114
+ this.fsQuad.dispose();
115
+
116
+ }
117
+
118
+ createMaterial() {
119
+
120
+ return new ShaderMaterial( {
121
+ uniforms: {
122
+ tDiffuse1: {
123
+ value: null
124
+ },
125
+ tDiffuse2: {
126
+ value: null
127
+ },
128
+ mixRatio: {
129
+ value: 0.0
130
+ },
131
+ threshold: {
132
+ value: 0.1
133
+ },
134
+ useTexture: {
135
+ value: 1
136
+ },
137
+ tMixTexture: {
138
+ value: null
139
+ }
140
+ },
141
+ vertexShader: /* glsl */`
142
+ varying vec2 vUv;
143
+
144
+ void main() {
145
+
146
+ vUv = vec2( uv.x, uv.y );
147
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
148
+
149
+ }
150
+ `,
151
+ fragmentShader: /* glsl */`
152
+ uniform float mixRatio;
153
+
154
+ uniform sampler2D tDiffuse1;
155
+ uniform sampler2D tDiffuse2;
156
+ uniform sampler2D tMixTexture;
157
+
158
+ uniform int useTexture;
159
+ uniform float threshold;
160
+
161
+ varying vec2 vUv;
162
+
163
+ void main() {
164
+
165
+ vec4 texel1 = texture2D( tDiffuse1, vUv );
166
+ vec4 texel2 = texture2D( tDiffuse2, vUv );
167
+
168
+ if (useTexture == 1) {
169
+
170
+ vec4 transitionTexel = texture2D( tMixTexture, vUv );
171
+ float r = mixRatio * ( 1.0 + threshold * 2.0 ) - threshold;
172
+ float mixf = clamp( ( transitionTexel.r - r ) * ( 1.0 / threshold ), 0.0, 1.0 );
173
+
174
+ gl_FragColor = mix( texel1, texel2, mixf );
175
+
176
+ } else {
177
+
178
+ gl_FragColor = mix( texel2, texel1, mixRatio );
179
+
180
+ }
181
+
182
+ #include <tonemapping_fragment>
183
+ #include <colorspace_fragment>
184
+
185
+ }
186
+ `
187
+ } );
188
+
189
+ }
190
+
191
+ }
192
+
193
+ export { RenderTransitionPass };
@@ -1,6 +1,6 @@
1
1
  import DataMap from './DataMap.js';
2
2
  import Color4 from './Color4.js';
3
- import { Mesh, SphereGeometry, BackSide } from 'three';
3
+ import { Mesh, SphereGeometry, BackSide, LinearSRGBColorSpace } from 'three';
4
4
  import { vec4, context, normalWorld, backgroundBlurriness, backgroundIntensity, NodeMaterial, modelViewProjection } from '../../nodes/Nodes.js';
5
5
 
6
6
  const _clearColor = new Color4();
@@ -27,14 +27,14 @@ class Background extends DataMap {
27
27
 
28
28
  // no background settings, use clear color configuration from the renderer
29
29
 
30
- renderer._clearColor.getRGB( _clearColor, this.renderer.currentColorSpace );
30
+ renderer._clearColor.getRGB( _clearColor, LinearSRGBColorSpace );
31
31
  _clearColor.a = renderer._clearColor.a;
32
32
 
33
33
  } else if ( background.isColor === true ) {
34
34
 
35
35
  // background is an opaque color
36
36
 
37
- background.getRGB( _clearColor, this.renderer.currentColorSpace );
37
+ background.getRGB( _clearColor, LinearSRGBColorSpace );
38
38
  _clearColor.a = 1;
39
39
 
40
40
  forceClear = true;
@@ -101,7 +101,7 @@ class ClippingContext {
101
101
 
102
102
  if ( this !== parent && parent.version !== this.parentVersion ) {
103
103
 
104
- this.globalClippingCount = material.isShadowNodeMaterial ? 0 : parent.globalClippingCount;
104
+ this.globalClippingCount = material.isShadowNodeMaterial ? 0 : parent.globalClippingCount;
105
105
  this.localClippingEnabled = parent.localClippingEnabled;
106
106
  this.planes = Array.from( parent.planes );
107
107
  this.parentVersion = parent.version;
@@ -123,7 +123,7 @@ class RenderList {
123
123
 
124
124
  if ( object.occlusionTest === true ) this.occlusionQueryCount ++;
125
125
 
126
- ( material.transparent === true ? this.transparent : this.opaque ).push( renderItem );
126
+ ( material.transparent === true || material.transmission > 0 ? this.transparent : this.opaque ).push( renderItem );
127
127
 
128
128
  }
129
129
 
@@ -2,6 +2,40 @@ import ClippingContext from './ClippingContext.js';
2
2
 
3
3
  let id = 0;
4
4
 
5
+ function getKeys( obj ) {
6
+
7
+ const keys = Object.keys( obj );
8
+
9
+ let proto = Object.getPrototypeOf( obj );
10
+
11
+ while ( proto ) {
12
+
13
+ const descriptors = Object.getOwnPropertyDescriptors( proto );
14
+
15
+ for ( const key in descriptors ) {
16
+
17
+ if ( descriptors[ key ] !== undefined ) {
18
+
19
+ const descriptor = descriptors[ key ];
20
+
21
+ if ( descriptor && typeof descriptor.get === 'function' ) {
22
+
23
+ keys.push( key );
24
+
25
+ }
26
+
27
+ }
28
+
29
+ }
30
+
31
+ proto = Object.getPrototypeOf( proto );
32
+
33
+ }
34
+
35
+ return keys;
36
+
37
+ }
38
+
5
39
  export default class RenderObject {
6
40
 
7
41
  constructor( nodes, geometries, renderer, object, material, scene, camera, lightsNode, renderContext ) {
@@ -22,6 +56,8 @@ export default class RenderObject {
22
56
  this.geometry = object.geometry;
23
57
  this.version = material.version;
24
58
 
59
+ this.drawRange = null;
60
+
25
61
  this.attributes = null;
26
62
  this.pipeline = null;
27
63
  this.vertexBuffers = null;
@@ -153,7 +189,7 @@ export default class RenderObject {
153
189
 
154
190
  let cacheKey = material.customProgramCacheKey();
155
191
 
156
- for ( const property in material ) {
192
+ for ( const property of getKeys( material ) ) {
157
193
 
158
194
  if ( /^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test( property ) ) continue;
159
195
 
@@ -186,6 +222,12 @@ export default class RenderObject {
186
222
 
187
223
  }
188
224
 
225
+ if ( object.isBatchedMesh ) {
226
+
227
+ cacheKey += object._matricesTexture.uuid + ',';
228
+
229
+ }
230
+
189
231
  return cacheKey;
190
232
 
191
233
  }