super-three 0.177.0 → 0.179.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 (211) hide show
  1. package/README.md +1 -1
  2. package/build/three.cjs +959 -231
  3. package/build/three.core.js +751 -170
  4. package/build/three.core.min.js +1 -1
  5. package/build/three.module.js +210 -64
  6. package/build/three.module.min.js +1 -1
  7. package/build/three.tsl.js +78 -29
  8. package/build/three.tsl.min.js +1 -1
  9. package/build/three.webgpu.js +3269 -1545
  10. package/build/three.webgpu.min.js +1 -1
  11. package/build/three.webgpu.nodes.js +3093 -1545
  12. package/build/three.webgpu.nodes.min.js +1 -1
  13. package/examples/jsm/Addons.js +1 -2
  14. package/examples/jsm/capabilities/WebGL.js +0 -27
  15. package/examples/jsm/capabilities/WebGPU.js +1 -1
  16. package/examples/jsm/controls/ArcballControls.js +1 -1
  17. package/examples/jsm/controls/TransformControls.js +61 -14
  18. package/examples/jsm/csm/CSMShadowNode.js +4 -4
  19. package/examples/jsm/environments/RoomEnvironment.js +8 -3
  20. package/examples/jsm/exporters/USDZExporter.js +676 -299
  21. package/examples/jsm/geometries/RoundedBoxGeometry.js +47 -8
  22. package/examples/jsm/interactive/HTMLMesh.js +5 -3
  23. package/examples/jsm/libs/meshopt_decoder.module.js +75 -58
  24. package/examples/jsm/lights/LightProbeGenerator.js +14 -3
  25. package/examples/jsm/loaders/ColladaLoader.js +1 -1
  26. package/examples/jsm/loaders/EXRLoader.js +210 -22
  27. package/examples/jsm/loaders/FBXLoader.js +2 -2
  28. package/examples/jsm/loaders/MaterialXLoader.js +212 -30
  29. package/examples/jsm/loaders/TTFLoader.js +13 -1
  30. package/examples/jsm/loaders/USDLoader.js +219 -0
  31. package/examples/jsm/loaders/USDZLoader.js +4 -892
  32. package/examples/jsm/loaders/usd/USDAParser.js +741 -0
  33. package/examples/jsm/loaders/usd/USDCParser.js +17 -0
  34. package/examples/jsm/objects/LensflareMesh.js +3 -3
  35. package/examples/jsm/objects/SkyMesh.js +2 -2
  36. package/examples/jsm/physics/RapierPhysics.js +95 -16
  37. package/examples/jsm/postprocessing/GTAOPass.js +10 -9
  38. package/examples/jsm/postprocessing/OutlinePass.js +17 -17
  39. package/examples/jsm/postprocessing/SSAOPass.js +10 -9
  40. package/examples/jsm/shaders/UnpackDepthRGBAShader.js +11 -2
  41. package/examples/jsm/transpiler/AST.js +381 -30
  42. package/examples/jsm/transpiler/GLSLDecoder.js +226 -86
  43. package/examples/jsm/transpiler/Linker.js +327 -0
  44. package/examples/jsm/transpiler/TSLEncoder.js +197 -92
  45. package/examples/jsm/transpiler/Transpiler.js +17 -1
  46. package/examples/jsm/transpiler/TranspilerUtils.js +29 -0
  47. package/examples/jsm/transpiler/WGSLEncoder.js +788 -0
  48. package/examples/jsm/tsl/display/BloomNode.js +8 -7
  49. package/examples/jsm/tsl/display/ChromaticAberrationNode.js +206 -0
  50. package/examples/jsm/tsl/display/GaussianBlurNode.js +8 -10
  51. package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
  52. package/examples/jsm/tsl/display/{TRAAPassNode.js → TRAANode.js} +181 -172
  53. package/examples/jsm/tsl/display/hashBlur.js +3 -3
  54. package/examples/jsm/tsl/lighting/TiledLightsNode.js +1 -1
  55. package/package.json +1 -1
  56. package/src/Three.Core.js +1 -0
  57. package/src/Three.TSL.js +77 -28
  58. package/src/Three.WebGPU.js +2 -0
  59. package/src/animation/KeyframeTrack.js +1 -1
  60. package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
  61. package/src/animation/tracks/StringKeyframeTrack.js +1 -1
  62. package/src/cameras/Camera.js +14 -0
  63. package/src/cameras/OrthographicCamera.js +1 -1
  64. package/src/cameras/PerspectiveCamera.js +1 -1
  65. package/src/constants.js +3 -3
  66. package/src/core/BufferAttribute.js +3 -3
  67. package/src/core/Clock.js +2 -8
  68. package/src/core/GLBufferAttribute.js +13 -1
  69. package/src/core/Object3D.js +1 -1
  70. package/{examples/jsm/misc → src/core}/Timer.js +4 -42
  71. package/src/extras/PMREMGenerator.js +11 -0
  72. package/src/extras/core/Path.js +22 -22
  73. package/src/helpers/CameraHelper.js +41 -11
  74. package/src/helpers/SkeletonHelper.js +35 -6
  75. package/src/lights/LightShadow.js +21 -8
  76. package/src/lights/PointLightShadow.js +1 -1
  77. package/src/loaders/FileLoader.js +27 -4
  78. package/src/loaders/ImageBitmapLoader.js +27 -4
  79. package/src/loaders/ImageLoader.js +55 -8
  80. package/src/loaders/Loader.js +14 -0
  81. package/src/loaders/LoadingManager.js +23 -0
  82. package/src/materials/MeshBasicMaterial.js +1 -1
  83. package/src/materials/nodes/Line2NodeMaterial.js +0 -8
  84. package/src/materials/nodes/MeshBasicNodeMaterial.js +4 -3
  85. package/src/materials/nodes/MeshMatcapNodeMaterial.js +1 -1
  86. package/src/materials/nodes/MeshNormalNodeMaterial.js +2 -2
  87. package/src/materials/nodes/MeshPhysicalNodeMaterial.js +2 -1
  88. package/src/materials/nodes/MeshSSSNodeMaterial.js +2 -2
  89. package/src/materials/nodes/NodeMaterial.js +28 -5
  90. package/src/materials/nodes/PointsNodeMaterial.js +5 -0
  91. package/src/materials/nodes/manager/NodeMaterialObserver.js +87 -2
  92. package/src/math/Frustum.js +25 -9
  93. package/src/math/FrustumArray.js +10 -5
  94. package/src/math/Line3.js +129 -2
  95. package/src/math/Matrix4.js +48 -27
  96. package/src/math/Quaternion.js +1 -1
  97. package/src/math/Spherical.js +2 -2
  98. package/src/nodes/Nodes.js +2 -3
  99. package/src/nodes/TSL.js +5 -3
  100. package/src/nodes/accessors/AccessorsUtils.js +7 -8
  101. package/src/nodes/accessors/Bitangent.js +31 -25
  102. package/src/nodes/accessors/Camera.js +12 -12
  103. package/src/nodes/accessors/Normal.js +95 -29
  104. package/src/nodes/accessors/Object3DNode.js +1 -1
  105. package/src/nodes/accessors/Position.js +7 -7
  106. package/src/nodes/accessors/ReferenceNode.js +18 -3
  107. package/src/nodes/accessors/ReflectVector.js +3 -3
  108. package/src/nodes/accessors/SceneNode.js +1 -1
  109. package/src/nodes/accessors/StorageTextureNode.js +1 -1
  110. package/src/nodes/accessors/Tangent.js +25 -17
  111. package/src/nodes/accessors/TangentUtils.js +46 -0
  112. package/src/nodes/accessors/TextureBicubic.js +21 -3
  113. package/src/nodes/accessors/TextureNode.js +12 -0
  114. package/src/nodes/accessors/UniformArrayNode.js +0 -16
  115. package/src/nodes/core/ArrayNode.js +12 -0
  116. package/src/nodes/core/AssignNode.js +3 -0
  117. package/src/nodes/core/CacheNode.js +0 -14
  118. package/src/nodes/core/ContextNode.js +20 -1
  119. package/src/nodes/core/Node.js +15 -3
  120. package/src/nodes/core/NodeBuilder.js +228 -92
  121. package/src/nodes/core/NodeUtils.js +4 -1
  122. package/src/nodes/core/StackNode.js +49 -29
  123. package/src/nodes/core/SubBuildNode.js +89 -0
  124. package/src/nodes/core/UniformNode.js +63 -5
  125. package/src/nodes/core/VarNode.js +91 -2
  126. package/src/nodes/core/VaryingNode.js +6 -4
  127. package/src/nodes/display/BlendModes.js +2 -2
  128. package/src/nodes/display/FrontFacingNode.js +34 -2
  129. package/src/nodes/display/NormalMapNode.js +19 -50
  130. package/src/nodes/display/PassNode.js +157 -9
  131. package/src/nodes/display/ScreenNode.js +0 -26
  132. package/src/nodes/display/ViewportTextureNode.js +67 -7
  133. package/src/nodes/functions/BSDF/BRDF_GGX.js +2 -6
  134. package/src/nodes/functions/BSDF/BRDF_Sheen.js +4 -4
  135. package/src/nodes/functions/PhongLightingModel.js +3 -3
  136. package/src/nodes/functions/PhysicalLightingModel.js +16 -16
  137. package/src/nodes/functions/material/getGeometryRoughness.js +2 -2
  138. package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
  139. package/src/nodes/gpgpu/ComputeNode.js +67 -23
  140. package/src/nodes/gpgpu/WorkgroupInfoNode.js +28 -3
  141. package/src/nodes/lighting/EnvironmentNode.js +5 -5
  142. package/src/nodes/lighting/LightsNode.js +4 -4
  143. package/src/nodes/lighting/ProjectorLightNode.js +19 -6
  144. package/src/nodes/lighting/ShadowFilterNode.js +1 -1
  145. package/src/nodes/lighting/ShadowNode.js +2 -2
  146. package/src/nodes/materialx/MaterialXNodes.js +131 -2
  147. package/src/nodes/materialx/lib/mx_noise.js +165 -1
  148. package/src/nodes/math/ConditionalNode.js +1 -20
  149. package/src/nodes/math/MathNode.js +90 -55
  150. package/src/nodes/math/OperatorNode.js +22 -39
  151. package/src/nodes/tsl/TSLBase.js +1 -0
  152. package/src/nodes/tsl/TSLCore.js +114 -55
  153. package/src/nodes/utils/DebugNode.js +1 -1
  154. package/src/nodes/utils/EquirectUV.js +27 -0
  155. package/src/nodes/utils/EventNode.js +83 -0
  156. package/src/nodes/utils/LoopNode.js +0 -17
  157. package/src/nodes/utils/MatcapUV.js +22 -0
  158. package/src/nodes/utils/RTTNode.js +22 -5
  159. package/src/nodes/utils/ReflectorNode.js +11 -4
  160. package/src/nodes/utils/SampleNode.js +81 -0
  161. package/src/nodes/utils/TriplanarTextures.js +65 -0
  162. package/src/objects/BatchedMesh.js +4 -2
  163. package/src/renderers/WebGLRenderer.js +26 -24
  164. package/src/renderers/common/Background.js +2 -2
  165. package/src/renderers/common/Bindings.js +19 -18
  166. package/src/renderers/common/Color4.js +2 -2
  167. package/src/renderers/common/CubeRenderTarget.js +1 -1
  168. package/src/renderers/common/PostProcessing.js +60 -5
  169. package/src/renderers/common/RenderObject.js +68 -3
  170. package/src/renderers/common/Renderer.js +19 -16
  171. package/src/renderers/common/SampledTexture.js +3 -71
  172. package/src/renderers/common/Sampler.js +79 -0
  173. package/src/renderers/common/Storage3DTexture.js +100 -0
  174. package/src/renderers/common/StorageArrayTexture.js +84 -0
  175. package/src/renderers/common/StorageTexture.js +19 -0
  176. package/src/renderers/common/Textures.js +19 -3
  177. package/src/renderers/common/XRManager.js +31 -12
  178. package/src/renderers/common/XRRenderTarget.js +21 -4
  179. package/src/renderers/common/extras/PMREMGenerator.js +1 -1
  180. package/src/renderers/common/nodes/NodeSampledTexture.js +0 -12
  181. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +20 -2
  182. package/src/renderers/shaders/ShaderLib/depth.glsl.js +11 -2
  183. package/src/renderers/webgl/WebGLAttributes.js +4 -0
  184. package/src/renderers/webgl/WebGLCapabilities.js +2 -2
  185. package/src/renderers/webgl/WebGLProgram.js +12 -6
  186. package/src/renderers/webgl/WebGLPrograms.js +6 -4
  187. package/src/renderers/webgl/WebGLShadowMap.js +11 -1
  188. package/src/renderers/webgl/WebGLState.js +4 -4
  189. package/src/renderers/webgl/WebGLTextures.js +19 -7
  190. package/src/renderers/webgl-fallback/WebGLBackend.js +103 -72
  191. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +3 -5
  192. package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +4 -0
  193. package/src/renderers/webgl-fallback/utils/WebGLState.js +4 -4
  194. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +2 -0
  195. package/src/renderers/webgpu/WebGPUBackend.js +63 -16
  196. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +64 -79
  197. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -0
  198. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -31
  199. package/src/renderers/webgpu/utils/WebGPUConstants.js +7 -1
  200. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +5 -5
  201. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +12 -65
  202. package/src/renderers/webgpu/utils/WebGPUUtils.js +2 -17
  203. package/src/renderers/webxr/WebXRDepthSensing.js +6 -10
  204. package/src/renderers/webxr/WebXRManager.js +68 -6
  205. package/src/textures/ExternalTexture.js +45 -0
  206. package/src/textures/FramebufferTexture.js +2 -2
  207. package/src/textures/Source.js +11 -1
  208. package/src/textures/VideoTexture.js +30 -2
  209. package/src/nodes/utils/EquirectUVNode.js +0 -65
  210. package/src/nodes/utils/MatcapUVNode.js +0 -49
  211. package/src/nodes/utils/TriplanarTexturesNode.js +0 -148
@@ -0,0 +1,17 @@
1
+ import {
2
+ Group
3
+ } from 'three';
4
+
5
+ class USDCParser {
6
+
7
+ parse( buffer ) {
8
+
9
+ // TODO
10
+
11
+ return new Group();
12
+
13
+ }
14
+
15
+ }
16
+
17
+ export { USDCParser };
@@ -110,7 +110,7 @@ class LensflareMesh extends Mesh {
110
110
  material1a.type = 'Lensflare-1a';
111
111
 
112
112
  material1a.vertexNode = vertexNode;
113
- material1a.fragmentNode = vec4( 1.0, 0.0, 1.0, 1.0 );
113
+ material1a.colorNode = vec4( 1.0, 0.0, 1.0, 1.0 );
114
114
 
115
115
  const material1b = new NodeMaterial();
116
116
 
@@ -121,7 +121,7 @@ class LensflareMesh extends Mesh {
121
121
  material1b.type = 'Lensflare-1b';
122
122
 
123
123
  material1b.vertexNode = vertexNode;
124
- material1b.fragmentNode = texture( tempMap, vec2( uv().flipY() ) );
124
+ material1b.colorNode = texture( tempMap, vec2( uv().flipY() ) );
125
125
 
126
126
  // the following object is used for occlusionMap generation
127
127
 
@@ -174,7 +174,7 @@ class LensflareMesh extends Mesh {
174
174
 
175
175
  } )();
176
176
 
177
- material2.fragmentNode = Fn( () => {
177
+ material2.colorNode = Fn( () => {
178
178
 
179
179
  const color = reference( 'color', 'color' );
180
180
  const map = reference( 'map', 'texture' );
@@ -165,7 +165,7 @@ class SkyMesh extends Mesh {
165
165
 
166
166
  } )();
167
167
 
168
- const fragmentNode = /*@__PURE__*/ Fn( () => {
168
+ const colorNode = /*@__PURE__*/ Fn( () => {
169
169
 
170
170
  // constants for atmospheric scattering
171
171
  const pi = float( 3.141592653589793238462643383279502884197169 );
@@ -234,7 +234,7 @@ class SkyMesh extends Mesh {
234
234
  material.depthWrite = false;
235
235
 
236
236
  material.vertexNode = vertexNode;
237
- material.fragmentNode = fragmentNode;
237
+ material.colorNode = colorNode;
238
238
 
239
239
  }
240
240
 
@@ -1,6 +1,6 @@
1
1
  import { Clock, Vector3, Quaternion, Matrix4 } from 'three';
2
2
 
3
- const RAPIER_PATH = 'https://cdn.skypack.dev/@dimforge/rapier3d-compat@0.12.0';
3
+ const RAPIER_PATH = 'https://cdn.skypack.dev/@dimforge/rapier3d-compat@0.17.3';
4
4
 
5
5
  const frameRate = 60;
6
6
 
@@ -15,7 +15,16 @@ function getShape( geometry ) {
15
15
 
16
16
  // TODO change type to is*
17
17
 
18
- if ( geometry.type === 'BoxGeometry' ) {
18
+ if ( geometry.type === 'RoundedBoxGeometry' ) {
19
+
20
+ const sx = parameters.width !== undefined ? parameters.width / 2 : 0.5;
21
+ const sy = parameters.height !== undefined ? parameters.height / 2 : 0.5;
22
+ const sz = parameters.depth !== undefined ? parameters.depth / 2 : 0.5;
23
+ const radius = parameters.radius !== undefined ? parameters.radius : 0.1;
24
+
25
+ return RAPIER.ColliderDesc.roundCuboid( sx - radius, sy - radius, sz - radius, radius );
26
+
27
+ } else if ( geometry.type === 'BoxGeometry' ) {
19
28
 
20
29
  const sx = parameters.width !== undefined ? parameters.width / 2 : 0.5;
21
30
  const sy = parameters.height !== undefined ? parameters.height / 2 : 0.5;
@@ -132,18 +141,40 @@ async function RapierPhysics() {
132
141
  shape.setMass( mass );
133
142
  shape.setRestitution( restitution );
134
143
 
135
- const body = mesh.isInstancedMesh
144
+ const { body, collider } = mesh.isInstancedMesh
136
145
  ? createInstancedBody( mesh, mass, shape )
137
146
  : createBody( mesh.position, mesh.quaternion, mass, shape );
138
147
 
139
148
  if ( ! mesh.userData.physics ) mesh.userData.physics = {};
140
149
 
141
150
  mesh.userData.physics.body = body;
151
+ mesh.userData.physics.collider = collider;
142
152
 
143
153
  if ( mass > 0 ) {
144
154
 
145
155
  meshes.push( mesh );
146
- meshMap.set( mesh, body );
156
+ meshMap.set( mesh, { body, collider } );
157
+
158
+ }
159
+
160
+ }
161
+
162
+ function removeMesh( mesh ) {
163
+
164
+ const index = meshes.indexOf( mesh );
165
+
166
+ if ( index !== - 1 ) {
167
+
168
+ meshes.splice( index, 1 );
169
+ meshMap.delete( mesh );
170
+
171
+ if ( ! mesh.userData.physics ) return;
172
+
173
+ const body = mesh.userData.physics.body;
174
+ const collider = mesh.userData.physics.collider;
175
+
176
+ if ( body ) removeBody( body );
177
+ if ( collider ) removeCollider( collider );
147
178
 
148
179
  }
149
180
 
@@ -154,15 +185,18 @@ async function RapierPhysics() {
154
185
  const array = mesh.instanceMatrix.array;
155
186
 
156
187
  const bodies = [];
188
+ const colliders = [];
157
189
 
158
190
  for ( let i = 0; i < mesh.count; i ++ ) {
159
191
 
160
192
  const position = _vector.fromArray( array, i * 16 + 12 );
161
- bodies.push( createBody( position, null, mass, shape ) );
193
+ const { body, collider } = createBody( position, null, mass, shape );
194
+ bodies.push( body );
195
+ colliders.push( collider );
162
196
 
163
197
  }
164
198
 
165
- return bodies;
199
+ return { body: bodies, collider: colliders };
166
200
 
167
201
  }
168
202
 
@@ -173,15 +207,51 @@ async function RapierPhysics() {
173
207
  if ( quaternion !== null ) desc.setRotation( quaternion );
174
208
 
175
209
  const body = world.createRigidBody( desc );
176
- world.createCollider( shape, body );
210
+ const collider = world.createCollider( shape, body );
177
211
 
178
- return body;
212
+ return { body, collider };
213
+
214
+ }
215
+
216
+ function removeBody( body ) {
217
+
218
+ if ( Array.isArray( body ) ) {
219
+
220
+ for ( let i = 0; i < body.length; i ++ ) {
221
+
222
+ world.removeRigidBody( body[ i ] );
223
+
224
+ }
225
+
226
+ } else {
227
+
228
+ world.removeRigidBody( body );
229
+
230
+ }
231
+
232
+ }
233
+
234
+ function removeCollider( collider ) {
235
+
236
+ if ( Array.isArray( collider ) ) {
237
+
238
+ for ( let i = 0; i < collider.length; i ++ ) {
239
+
240
+ world.removeCollider( collider[ i ] );
241
+
242
+ }
243
+
244
+ } else {
245
+
246
+ world.removeCollider( collider );
247
+
248
+ }
179
249
 
180
250
  }
181
251
 
182
252
  function setMeshPosition( mesh, position, index = 0 ) {
183
253
 
184
- let body = meshMap.get( mesh );
254
+ let { body } = meshMap.get( mesh );
185
255
 
186
256
  if ( mesh.isInstancedMesh ) {
187
257
 
@@ -197,7 +267,7 @@ async function RapierPhysics() {
197
267
 
198
268
  function setMeshVelocity( mesh, velocity, index = 0 ) {
199
269
 
200
- let body = meshMap.get( mesh );
270
+ let { body } = meshMap.get( mesh );
201
271
 
202
272
  if ( mesh.isInstancedMesh ) {
203
273
 
@@ -212,17 +282,17 @@ async function RapierPhysics() {
212
282
  function addHeightfield( mesh, width, depth, heights, scale ) {
213
283
 
214
284
  const shape = RAPIER.ColliderDesc.heightfield( width, depth, heights, scale );
215
-
285
+
216
286
  const bodyDesc = RAPIER.RigidBodyDesc.fixed();
217
287
  bodyDesc.setTranslation( mesh.position.x, mesh.position.y, mesh.position.z );
218
288
  bodyDesc.setRotation( mesh.quaternion );
219
-
289
+
220
290
  const body = world.createRigidBody( bodyDesc );
221
291
  world.createCollider( shape, body );
222
-
292
+
223
293
  if ( ! mesh.userData.physics ) mesh.userData.physics = {};
224
294
  mesh.userData.physics.body = body;
225
-
295
+
226
296
  return body;
227
297
 
228
298
  }
@@ -245,7 +315,7 @@ async function RapierPhysics() {
245
315
  if ( mesh.isInstancedMesh ) {
246
316
 
247
317
  const array = mesh.instanceMatrix.array;
248
- const bodies = meshMap.get( mesh );
318
+ const { body: bodies } = meshMap.get( mesh );
249
319
 
250
320
  for ( let j = 0; j < bodies.length; j ++ ) {
251
321
 
@@ -263,7 +333,7 @@ async function RapierPhysics() {
263
333
 
264
334
  } else {
265
335
 
266
- const body = meshMap.get( mesh );
336
+ const { body } = meshMap.get( mesh );
267
337
 
268
338
  mesh.position.copy( body.translation() );
269
339
  mesh.quaternion.copy( body.rotation() );
@@ -306,6 +376,15 @@ async function RapierPhysics() {
306
376
  */
307
377
  addMesh: addMesh,
308
378
 
379
+ /**
380
+ * Removes the given mesh from this physics simulation.
381
+ *
382
+ * @method
383
+ * @name RapierPhysics#removeMesh
384
+ * @param {Mesh} mesh The mesh to remove.
385
+ */
386
+ removeMesh: removeMesh,
387
+
309
388
  /**
310
389
  * Set the position of the given mesh which is part of the physics simulation. Calling this
311
390
  * method will reset the current simulated velocity of the mesh.
@@ -103,7 +103,7 @@ class GTAOPass extends Pass {
103
103
  */
104
104
  this.output = 0;
105
105
  this._renderGBuffer = true;
106
- this._visibilityCache = new Map();
106
+ this._visibilityCache = [];
107
107
 
108
108
  /**
109
109
  * The AO blend intensity.
@@ -655,9 +655,12 @@ class GTAOPass extends Pass {
655
655
 
656
656
  scene.traverse( function ( object ) {
657
657
 
658
- cache.set( object, object.visible );
658
+ if ( ( object.isPoints || object.isLine || object.isLine2 ) && object.visible ) {
659
659
 
660
- if ( object.isPoints || object.isLine ) object.visible = false;
660
+ object.visible = false;
661
+ cache.push( object );
662
+
663
+ }
661
664
 
662
665
  } );
663
666
 
@@ -665,17 +668,15 @@ class GTAOPass extends Pass {
665
668
 
666
669
  _restoreVisibility() {
667
670
 
668
- const scene = this.scene;
669
671
  const cache = this._visibilityCache;
670
672
 
671
- scene.traverse( function ( object ) {
673
+ for ( let i = 0; i < cache.length; i ++ ) {
672
674
 
673
- const visible = cache.get( object );
674
- object.visible = visible;
675
+ cache[ i ].visible = true;
675
676
 
676
- } );
677
+ }
677
678
 
678
- cache.clear();
679
+ cache.length = 0;
679
680
 
680
681
  }
681
682
 
@@ -494,37 +494,37 @@ class OutlinePass extends Pass {
494
494
 
495
495
  function VisibilityChangeCallBack( object ) {
496
496
 
497
- if ( object.isMesh || object.isSprite ) {
497
+ if ( object.isPoints || object.isLine || object.isLine2 ) {
498
498
 
499
- // only meshes and sprites are supported by OutlinePass
499
+ // the visibility of points and lines is always set to false in order to
500
+ // not affect the outline computation
500
501
 
501
- if ( ! selectionCache.has( object ) ) {
502
+ if ( bVisible === true ) {
502
503
 
503
- const visibility = object.visible;
504
+ object.visible = visibilityCache.get( object ); // restore
504
505
 
505
- if ( bVisible === false || visibilityCache.get( object ) === true ) {
506
+ } else {
506
507
 
507
- object.visible = bVisible;
508
+ visibilityCache.set( object, object.visible );
509
+ object.visible = bVisible;
508
510
 
509
- }
511
+ }
510
512
 
511
- visibilityCache.set( object, visibility );
513
+ } else if ( object.isMesh || object.isSprite) {
512
514
 
513
- }
515
+ // only meshes and sprites are supported by OutlinePass
514
516
 
515
- } else if ( object.isPoints || object.isLine ) {
517
+ if ( ! selectionCache.has( object ) ) {
516
518
 
517
- // the visibility of points and lines is always set to false in order to
518
- // not affect the outline computation
519
+ const visibility = object.visible;
519
520
 
520
- if ( bVisible === true ) {
521
+ if ( bVisible === false || visibilityCache.get( object ) === true ) {
521
522
 
522
- object.visible = visibilityCache.get( object ); // restore
523
+ object.visible = bVisible;
523
524
 
524
- } else {
525
+ }
525
526
 
526
- visibilityCache.set( object, object.visible );
527
- object.visible = bVisible;
527
+ visibilityCache.set( object, visibility );
528
528
 
529
529
  }
530
530
 
@@ -139,7 +139,7 @@ class SSAOPass extends Pass {
139
139
  */
140
140
  this.maxDistance = 0.1;
141
141
 
142
- this._visibilityCache = new Map();
142
+ this._visibilityCache = [];
143
143
 
144
144
  //
145
145
 
@@ -489,9 +489,12 @@ class SSAOPass extends Pass {
489
489
 
490
490
  scene.traverse( function ( object ) {
491
491
 
492
- cache.set( object, object.visible );
492
+ if ( ( object.isPoints || object.isLine || object.isLine2 ) && object.visible ) {
493
493
 
494
- if ( object.isPoints || object.isLine ) object.visible = false;
494
+ object.visible = false;
495
+ cache.push( object );
496
+
497
+ }
495
498
 
496
499
  } );
497
500
 
@@ -499,17 +502,15 @@ class SSAOPass extends Pass {
499
502
 
500
503
  _restoreVisibility() {
501
504
 
502
- const scene = this.scene;
503
505
  const cache = this._visibilityCache;
504
506
 
505
- scene.traverse( function ( object ) {
507
+ for ( let i = 0; i < cache.length; i ++ ) {
506
508
 
507
- const visible = cache.get( object );
508
- object.visible = visible;
509
+ cache[ i ].visible = true;
509
510
 
510
- } );
511
+ }
511
512
 
512
- cache.clear();
513
+ cache.length = 0;
513
514
 
514
515
  }
515
516
 
@@ -43,8 +43,17 @@ const UnpackDepthRGBAShader = {
43
43
 
44
44
  void main() {
45
45
 
46
- float depth = 1.0 - unpackRGBAToDepth( texture2D( tDiffuse, vUv ) );
47
- gl_FragColor = vec4( vec3( depth ), opacity );
46
+ float depth = unpackRGBAToDepth( texture2D( tDiffuse, vUv ) );
47
+
48
+ #ifdef USE_REVERSEDEPTHBUF
49
+
50
+ gl_FragColor = vec4( vec3( depth ), opacity );
51
+
52
+ #else
53
+
54
+ gl_FragColor = vec4( vec3( 1.0 - depth ), opacity );
55
+
56
+ #endif
48
57
 
49
58
  }`
50
59