super-three 0.160.1 → 0.162.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 (225) hide show
  1. package/LICENSE +1 -1
  2. package/build/three.cjs +867 -499
  3. package/build/three.module.js +867 -496
  4. package/build/three.module.min.js +1 -1
  5. package/examples/jsm/Addons.js +5 -1
  6. package/examples/jsm/capabilities/WebGPU.js +13 -9
  7. package/examples/jsm/controls/DragControls.js +91 -30
  8. package/examples/jsm/controls/OrbitControls.js +130 -15
  9. package/examples/jsm/controls/TransformControls.js +6 -6
  10. package/examples/jsm/curves/NURBSUtils.js +59 -4
  11. package/examples/jsm/curves/NURBSVolume.js +62 -0
  12. package/examples/jsm/exporters/GLTFExporter.js +11 -1
  13. package/examples/jsm/exporters/USDZExporter.js +8 -7
  14. package/examples/jsm/helpers/TextureHelper.js +3 -3
  15. package/examples/jsm/interactive/InteractiveGroup.js +15 -25
  16. package/examples/jsm/libs/rhino3dm/rhino3dm.js +1 -8723
  17. package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +1 -8734
  18. package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
  19. package/examples/jsm/libs/tween.module.js +32 -14
  20. package/examples/jsm/loaders/3DMLoader.js +57 -64
  21. package/examples/jsm/loaders/DDSLoader.js +1 -0
  22. package/examples/jsm/loaders/KTX2Loader.js +20 -5
  23. package/examples/jsm/loaders/LUT3dlLoader.js +78 -46
  24. package/examples/jsm/loaders/LUTCubeLoader.js +81 -67
  25. package/examples/jsm/loaders/LUTImageLoader.js +3 -2
  26. package/examples/jsm/loaders/MaterialXLoader.js +115 -16
  27. package/examples/jsm/loaders/SVGLoader.js +4 -3
  28. package/examples/jsm/loaders/VOXLoader.js +9 -2
  29. package/examples/jsm/loaders/VRMLLoader.js +7 -3
  30. package/examples/jsm/materials/MeshPostProcessingMaterial.js +144 -0
  31. package/examples/jsm/misc/ProgressiveLightMap.js +1 -0
  32. package/examples/jsm/misc/Timer.js +13 -4
  33. package/examples/jsm/nodes/Nodes.js +24 -11
  34. package/examples/jsm/nodes/accessors/AccessorsUtils.js +10 -0
  35. package/examples/jsm/nodes/accessors/BufferAttributeNode.js +5 -3
  36. package/examples/jsm/nodes/accessors/CameraNode.js +9 -4
  37. package/examples/jsm/nodes/accessors/ClippingNode.js +144 -0
  38. package/examples/jsm/nodes/accessors/CubeTextureNode.js +12 -1
  39. package/examples/jsm/nodes/accessors/MaterialNode.js +2 -2
  40. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +2 -12
  41. package/examples/jsm/nodes/accessors/MorphNode.js +8 -8
  42. package/examples/jsm/nodes/accessors/ReferenceNode.js +87 -29
  43. package/examples/jsm/nodes/accessors/SkinningNode.js +31 -10
  44. package/examples/jsm/nodes/accessors/StorageBufferNode.js +45 -0
  45. package/examples/jsm/nodes/accessors/TangentNode.js +8 -2
  46. package/examples/jsm/nodes/accessors/TextureNode.js +1 -1
  47. package/examples/jsm/nodes/accessors/TextureStoreNode.js +56 -3
  48. package/examples/jsm/nodes/accessors/UniformsNode.js +140 -0
  49. package/examples/jsm/nodes/accessors/VertexColorNode.js +70 -0
  50. package/examples/jsm/nodes/code/CodeNode.js +6 -0
  51. package/examples/jsm/nodes/core/AssignNode.js +68 -12
  52. package/examples/jsm/nodes/core/AttributeNode.js +1 -1
  53. package/examples/jsm/nodes/core/Node.js +14 -4
  54. package/examples/jsm/nodes/core/NodeBuilder.js +26 -27
  55. package/examples/jsm/nodes/core/NodeFrame.js +18 -10
  56. package/examples/jsm/nodes/core/TempNode.js +1 -1
  57. package/examples/jsm/nodes/core/constants.js +1 -0
  58. package/examples/jsm/nodes/display/AfterImageNode.js +148 -0
  59. package/examples/jsm/nodes/display/AnamorphicNode.js +148 -0
  60. package/examples/jsm/nodes/display/BlendModeNode.js +30 -1
  61. package/examples/jsm/nodes/display/ColorAdjustmentNode.js +3 -0
  62. package/examples/jsm/nodes/display/GaussianBlurNode.js +33 -13
  63. package/examples/jsm/nodes/display/NormalMapNode.js +3 -5
  64. package/examples/jsm/nodes/display/PassNode.js +3 -2
  65. package/examples/jsm/nodes/display/ToneMappingNode.js +46 -3
  66. package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +1 -4
  67. package/examples/jsm/nodes/display/ViewportNode.js +0 -2
  68. package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +4 -4
  69. package/examples/jsm/nodes/fog/FogNode.js +2 -1
  70. package/examples/jsm/nodes/lighting/AmbientLightNode.js +1 -1
  71. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +13 -5
  72. package/examples/jsm/nodes/lighting/LightingContextNode.js +1 -1
  73. package/examples/jsm/nodes/lighting/LightsNode.js +1 -1
  74. package/examples/jsm/nodes/materials/Line2NodeMaterial.js +18 -30
  75. package/examples/jsm/nodes/materials/Materials.js +1 -0
  76. package/examples/jsm/nodes/materials/MeshSSSNodeMaterial.js +84 -0
  77. package/examples/jsm/nodes/materials/NodeMaterial.js +43 -10
  78. package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +1 -7
  79. package/examples/jsm/nodes/math/CondNode.js +42 -7
  80. package/examples/jsm/nodes/math/MathNode.js +32 -2
  81. package/examples/jsm/nodes/math/MathUtils.js +15 -0
  82. package/examples/jsm/nodes/math/OperatorNode.js +13 -5
  83. package/examples/jsm/nodes/math/TriNoise3D.js +71 -0
  84. package/examples/jsm/nodes/shadernode/ShaderNode.js +10 -1
  85. package/examples/jsm/nodes/utils/JoinNode.js +2 -2
  86. package/examples/jsm/nodes/utils/LoopNode.js +5 -3
  87. package/examples/jsm/nodes/utils/ReflectorNode.js +227 -0
  88. package/examples/jsm/nodes/utils/RotateNode.js +68 -0
  89. package/examples/jsm/nodes/utils/RotateUVNode.js +1 -9
  90. package/examples/jsm/nodes/utils/SplitNode.js +4 -4
  91. package/examples/jsm/nodes/utils/StorageArrayElementNode.js +91 -0
  92. package/examples/jsm/objects/GroundedSkybox.js +50 -0
  93. package/examples/jsm/objects/QuadMesh.js +8 -2
  94. package/examples/jsm/objects/Water2.js +8 -8
  95. package/examples/jsm/postprocessing/GTAOPass.js +11 -1
  96. package/examples/jsm/postprocessing/OutputPass.js +2 -0
  97. package/examples/jsm/renderers/common/Backend.js +14 -0
  98. package/examples/jsm/renderers/common/Background.js +2 -2
  99. package/examples/jsm/renderers/common/Bindings.js +1 -1
  100. package/examples/jsm/renderers/common/ClippingContext.js +165 -0
  101. package/examples/jsm/renderers/common/DataMap.js +1 -1
  102. package/examples/jsm/renderers/common/Info.js +25 -1
  103. package/examples/jsm/renderers/common/Pipelines.js +8 -8
  104. package/examples/jsm/renderers/common/PostProcessing.js +2 -2
  105. package/examples/jsm/renderers/common/ProgrammableStage.js +3 -1
  106. package/examples/jsm/renderers/common/RenderContext.js +2 -0
  107. package/examples/jsm/renderers/common/RenderContexts.js +2 -13
  108. package/examples/jsm/renderers/common/RenderObject.js +46 -1
  109. package/examples/jsm/renderers/common/RenderObjects.js +3 -1
  110. package/examples/jsm/renderers/common/Renderer.js +290 -17
  111. package/examples/jsm/renderers/common/StorageBufferAttribute.js +17 -0
  112. package/examples/jsm/renderers/common/StorageInstancedBufferAttribute.js +17 -0
  113. package/examples/jsm/renderers/common/Textures.js +28 -18
  114. package/examples/jsm/renderers/common/UniformsGroup.js +6 -4
  115. package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +2 -1
  116. package/examples/jsm/renderers/common/nodes/NodeStorageBuffer.js +23 -0
  117. package/examples/jsm/renderers/common/nodes/NodeUniformBuffer.js +23 -0
  118. package/examples/jsm/renderers/common/nodes/Nodes.js +5 -2
  119. package/examples/jsm/renderers/webgl/WebGLBackend.js +653 -272
  120. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +171 -39
  121. package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +95 -8
  122. package/examples/jsm/renderers/webgl/utils/WebGLConstants.js +11 -0
  123. package/examples/jsm/renderers/webgl/utils/WebGLState.js +197 -0
  124. package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +424 -11
  125. package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +3 -2
  126. package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +1 -21
  127. package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +2 -2
  128. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +300 -112
  129. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +7 -2
  130. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +71 -79
  131. package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +15 -1
  132. package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +38 -4
  133. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +87 -14
  134. package/examples/jsm/shaders/OutputShader.js +4 -0
  135. package/examples/jsm/transpiler/AST.js +1 -1
  136. package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
  137. package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
  138. package/examples/jsm/transpiler/TSLEncoder.js +1 -1
  139. package/examples/jsm/utils/BufferGeometryUtils.js +23 -27
  140. package/examples/jsm/utils/SkeletonUtils.js +14 -3
  141. package/examples/jsm/utils/SortUtils.js +2 -0
  142. package/examples/jsm/webxr/ARButton.js +12 -2
  143. package/examples/jsm/webxr/VRButton.js +25 -7
  144. package/examples/jsm/webxr/XRButton.js +12 -3
  145. package/examples/jsm/webxr/XRControllerModelFactory.js +14 -1
  146. package/examples/jsm/webxr/XRHandMeshModel.js +3 -1
  147. package/package.json +5 -4
  148. package/src/Three.Legacy.js +20 -0
  149. package/src/Three.js +0 -1
  150. package/src/audio/Audio.js +1 -3
  151. package/src/cameras/PerspectiveCamera.js +35 -0
  152. package/src/constants.js +2 -6
  153. package/src/core/BufferAttribute.js +2 -12
  154. package/src/core/BufferGeometry.js +23 -29
  155. package/src/core/InterleavedBuffer.js +2 -1
  156. package/src/core/InterleavedBufferAttribute.js +20 -0
  157. package/src/core/Object3D.js +11 -0
  158. package/src/core/Raycaster.js +18 -4
  159. package/src/core/RenderTarget.js +44 -21
  160. package/src/extras/PMREMGenerator.js +2 -0
  161. package/src/extras/curves/EllipseCurve.js +2 -2
  162. package/src/helpers/SpotLightHelper.js +18 -1
  163. package/src/loaders/DataTextureLoader.js +0 -4
  164. package/src/loaders/MaterialLoader.js +1 -0
  165. package/src/loaders/ObjectLoader.js +2 -1
  166. package/src/materials/Material.js +2 -1
  167. package/src/materials/MeshBasicMaterial.js +3 -0
  168. package/src/materials/MeshLambertMaterial.js +3 -0
  169. package/src/materials/MeshPhongMaterial.js +3 -0
  170. package/src/materials/MeshStandardMaterial.js +3 -0
  171. package/src/materials/ShaderMaterial.js +2 -1
  172. package/src/math/Quaternion.js +13 -12
  173. package/src/math/Triangle.js +0 -30
  174. package/src/math/Vector3.js +7 -7
  175. package/src/objects/BatchedMesh.js +6 -7
  176. package/src/objects/InstancedMesh.js +53 -0
  177. package/src/objects/Mesh.js +0 -1
  178. package/src/objects/SkinnedMesh.js +0 -8
  179. package/src/renderers/WebGLCubeRenderTarget.js +1 -10
  180. package/src/renderers/WebGLRenderer.js +20 -23
  181. package/src/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js +9 -0
  182. package/src/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js +56 -11
  183. package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -0
  184. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
  185. package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +2 -2
  186. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +1 -1
  187. package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +14 -0
  188. package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +11 -2
  189. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +38 -7
  190. package/src/renderers/shaders/ShaderChunk.js +2 -0
  191. package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +3 -2
  192. package/src/renderers/shaders/ShaderLib/depth.glsl.js +3 -2
  193. package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +3 -2
  194. package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +2 -1
  195. package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +2 -2
  196. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -1
  197. package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +2 -2
  198. package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +4 -1
  199. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -1
  200. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +2 -1
  201. package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +2 -1
  202. package/src/renderers/shaders/ShaderLib/points.glsl.js +2 -1
  203. package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -0
  204. package/src/renderers/shaders/ShaderLib/sprite.glsl.js +1 -1
  205. package/src/renderers/shaders/ShaderLib.js +2 -1
  206. package/src/renderers/shaders/UniformsLib.js +1 -0
  207. package/src/renderers/webgl/WebGLAttributes.js +2 -2
  208. package/src/renderers/webgl/WebGLBackground.js +18 -0
  209. package/src/renderers/webgl/WebGLCubeMaps.js +1 -1
  210. package/src/renderers/webgl/WebGLMaterials.js +24 -1
  211. package/src/renderers/webgl/WebGLMorphtargets.js +15 -8
  212. package/src/renderers/webgl/WebGLProgram.js +42 -4
  213. package/src/renderers/webgl/WebGLPrograms.js +38 -27
  214. package/src/renderers/webgl/WebGLState.js +11 -21
  215. package/src/renderers/webgl/WebGLTextures.js +170 -66
  216. package/src/renderers/webxr/WebXRDepthSensing.js +105 -0
  217. package/src/renderers/webxr/WebXRManager.js +46 -0
  218. package/src/scenes/Scene.js +8 -0
  219. package/src/textures/Source.js +1 -0
  220. package/src/textures/Texture.js +1 -29
  221. package/build/three.js +0 -54519
  222. package/build/three.min.js +0 -7
  223. package/examples/jsm/nodes/core/ArrayUniformNode.js +0 -26
  224. package/examples/jsm/objects/GroundProjectedSkybox.js +0 -172
  225. package/src/renderers/WebGLMultipleRenderTargets.js +0 -82
@@ -107,7 +107,12 @@ class ARButton {
107
107
  if ( navigator.xr.offerSession !== undefined ) {
108
108
 
109
109
  navigator.xr.offerSession( 'immersive-ar', sessionInit )
110
- .then( onSessionStarted );
110
+ .then( onSessionStarted )
111
+ .catch( ( err ) => {
112
+
113
+ console.warn( err );
114
+
115
+ } );
111
116
 
112
117
  }
113
118
 
@@ -118,7 +123,12 @@ class ARButton {
118
123
  if ( navigator.xr.offerSession !== undefined ) {
119
124
 
120
125
  navigator.xr.offerSession( 'immersive-ar', sessionInit )
121
- .then( onSessionStarted );
126
+ .then( onSessionStarted )
127
+ .catch( ( err ) => {
128
+
129
+ console.warn( err );
130
+
131
+ } );
122
132
 
123
133
  }
124
134
 
@@ -1,6 +1,6 @@
1
1
  class VRButton {
2
2
 
3
- static createButton( renderer ) {
3
+ static createButton( renderer, sessionInit = {} ) {
4
4
 
5
5
  const button = document.createElement( 'button' );
6
6
 
@@ -46,7 +46,15 @@ class VRButton {
46
46
  // ('local' is always available for immersive sessions and doesn't need to
47
47
  // be requested separately.)
48
48
 
49
- const sessionInit = { optionalFeatures: [ 'local-floor', 'bounded-floor', 'hand-tracking', 'layers' ] };
49
+ const sessionOptions = {
50
+ ...sessionInit,
51
+ optionalFeatures: [
52
+ 'local-floor',
53
+ 'bounded-floor',
54
+ 'layers',
55
+ ...( sessionInit.optionalFeatures || [] )
56
+ ],
57
+ };
50
58
 
51
59
  button.onmouseenter = function () {
52
60
 
@@ -64,7 +72,7 @@ class VRButton {
64
72
 
65
73
  if ( currentSession === null ) {
66
74
 
67
- navigator.xr.requestSession( 'immersive-vr', sessionInit ).then( onSessionStarted );
75
+ navigator.xr.requestSession( 'immersive-vr', sessionOptions ).then( onSessionStarted );
68
76
 
69
77
  } else {
70
78
 
@@ -72,8 +80,13 @@ class VRButton {
72
80
 
73
81
  if ( navigator.xr.offerSession !== undefined ) {
74
82
 
75
- navigator.xr.offerSession( 'immersive-vr', sessionInit )
76
- .then( onSessionStarted );
83
+ navigator.xr.offerSession( 'immersive-vr', sessionOptions )
84
+ .then( onSessionStarted )
85
+ .catch( ( err ) => {
86
+
87
+ console.warn( err );
88
+
89
+ } );
77
90
 
78
91
  }
79
92
 
@@ -83,8 +96,13 @@ class VRButton {
83
96
 
84
97
  if ( navigator.xr.offerSession !== undefined ) {
85
98
 
86
- navigator.xr.offerSession( 'immersive-vr', sessionInit )
87
- .then( onSessionStarted );
99
+ navigator.xr.offerSession( 'immersive-vr', sessionOptions )
100
+ .then( onSessionStarted )
101
+ .catch( ( err ) => {
102
+
103
+ console.warn( err );
104
+
105
+ } );
88
106
 
89
107
  }
90
108
 
@@ -45,7 +45,6 @@ class XRButton {
45
45
  optionalFeatures: [
46
46
  'local-floor',
47
47
  'bounded-floor',
48
- 'hand-tracking',
49
48
  'layers',
50
49
  ...( sessionInit.optionalFeatures || [] )
51
50
  ],
@@ -77,7 +76,12 @@ class XRButton {
77
76
  if ( navigator.xr.offerSession !== undefined ) {
78
77
 
79
78
  navigator.xr.offerSession( mode, sessionOptions )
80
- .then( onSessionStarted );
79
+ .then( onSessionStarted )
80
+ .catch( ( err ) => {
81
+
82
+ console.warn( err );
83
+
84
+ } );
81
85
 
82
86
  }
83
87
 
@@ -88,7 +92,12 @@ class XRButton {
88
92
  if ( navigator.xr.offerSession !== undefined ) {
89
93
 
90
94
  navigator.xr.offerSession( mode, sessionOptions )
91
- .then( onSessionStarted );
95
+ .then( onSessionStarted )
96
+ .catch( ( err ) => {
97
+
98
+ console.warn( err );
99
+
100
+ } );
92
101
 
93
102
  }
94
103
 
@@ -206,11 +206,12 @@ function addAssetSceneToControllerModel( controllerModel, scene ) {
206
206
 
207
207
  class XRControllerModelFactory {
208
208
 
209
- constructor( gltfLoader = null ) {
209
+ constructor( gltfLoader = null, onLoad = null ) {
210
210
 
211
211
  this.gltfLoader = gltfLoader;
212
212
  this.path = DEFAULT_PROFILES_PATH;
213
213
  this._assetCache = {};
214
+ this.onLoad = onLoad;
214
215
 
215
216
  // If a GLTFLoader wasn't supplied to the constructor create a new one.
216
217
  if ( ! this.gltfLoader ) {
@@ -221,6 +222,14 @@ class XRControllerModelFactory {
221
222
 
222
223
  }
223
224
 
225
+ setPath( path ) {
226
+
227
+ this.path = path;
228
+
229
+ return this;
230
+
231
+ }
232
+
224
233
  createControllerModel( controller ) {
225
234
 
226
235
  const controllerModel = new XRControllerModel();
@@ -247,6 +256,8 @@ class XRControllerModelFactory {
247
256
 
248
257
  addAssetSceneToControllerModel( controllerModel, scene );
249
258
 
259
+ if ( this.onLoad ) this.onLoad( scene );
260
+
250
261
  } else {
251
262
 
252
263
  if ( ! this.gltfLoader ) {
@@ -264,6 +275,8 @@ class XRControllerModelFactory {
264
275
 
265
276
  addAssetSceneToControllerModel( controllerModel, scene );
266
277
 
278
+ if ( this.onLoad ) this.onLoad( scene );
279
+
267
280
  },
268
281
  null,
269
282
  () => {
@@ -4,7 +4,7 @@ const DEFAULT_HAND_PROFILE_PATH = 'https://cdn.jsdelivr.net/npm/@webxr-input-pro
4
4
 
5
5
  class XRHandMeshModel {
6
6
 
7
- constructor( handModel, controller, path, handedness, loader = null ) {
7
+ constructor( handModel, controller, path, handedness, loader = null, onLoad = null ) {
8
8
 
9
9
  this.controller = controller;
10
10
  this.handModel = handModel;
@@ -74,6 +74,8 @@ class XRHandMeshModel {
74
74
 
75
75
  } );
76
76
 
77
+ if ( onLoad ) onLoad( object );
78
+
77
79
  } );
78
80
 
79
81
  }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "super-three",
3
- "version": "0.160.1",
3
+ "version": "0.162.0",
4
4
  "description": "JavaScript 3D library",
5
5
  "type": "module",
6
- "main": "./build/three.js",
6
+ "main": "./build/three.cjs",
7
7
  "module": "./build/three.module.js",
8
8
  "exports": {
9
9
  ".": {
@@ -45,6 +45,7 @@
45
45
  "build": "rollup -c utils/build/rollup.config.js",
46
46
  "build-module": "rollup -c utils/build/rollup.config.js --configOnlyModule",
47
47
  "dev": "concurrently --names \"ROLLUP,HTTP\" -c \"bgBlue.bold,bgGreen.bold\" \"rollup -c utils/build/rollup.config.js -w -m inline\" \"servez -p 8080\"",
48
+ "dev-ssl": "concurrently --names \"ROLLUP,HTTPS\" -c \"bgBlue.bold,bgGreen.bold\" \"rollup -c utils/build/rollup.config.js -w -m inline\" \"servez -p 8080 --ssl\"",
48
49
  "lint-core": "eslint src",
49
50
  "lint-addons": "eslint examples/jsm --ext .js --ignore-pattern libs --ignore-pattern ifc",
50
51
  "lint-examples": "eslint examples --ext .html",
@@ -94,13 +95,13 @@
94
95
  "eslint": "^8.37.0",
95
96
  "eslint-config-mdcs": "^5.0.0",
96
97
  "eslint-plugin-compat": "^4.1.2",
97
- "eslint-plugin-html": "^7.1.0",
98
+ "eslint-plugin-html": "^8.0.0",
98
99
  "eslint-plugin-import": "^2.27.5",
99
100
  "failonlyreporter": "^1.0.0",
100
101
  "jimp": "^0.22.7",
101
102
  "magic-string": "^0.30.0",
102
103
  "pixelmatch": "^5.3.0",
103
- "puppeteer": "^21.5.1",
104
+ "puppeteer": "^22.0.0",
104
105
  "qunit": "^2.19.4",
105
106
  "rollup": "^4.6.0",
106
107
  "rollup-plugin-filesize": "^10.0.0",
@@ -1 +1,21 @@
1
+ import { WebGLRenderTarget } from './renderers/WebGLRenderTarget.js';
1
2
 
3
+ export class WebGLMultipleRenderTargets extends WebGLRenderTarget { // @deprecated, r162
4
+
5
+ constructor( width = 1, height = 1, count = 1, options = {} ) {
6
+
7
+ console.warn( 'THREE.WebGLMultipleRenderTargets has been deprecated and will be removed in r172. Use THREE.WebGLRenderTarget and set the "count" parameter to enable MRT.' );
8
+
9
+ super( width, height, { ...options, count } );
10
+
11
+ this.isWebGLMultipleRenderTargets = true;
12
+
13
+ }
14
+
15
+ get texture() {
16
+
17
+ return this.textures;
18
+
19
+ }
20
+
21
+ }
package/src/Three.js CHANGED
@@ -2,7 +2,6 @@ import { REVISION } from './constants.js';
2
2
 
3
3
  export { WebGLArrayRenderTarget } from './renderers/WebGLArrayRenderTarget.js';
4
4
  export { WebGL3DRenderTarget } from './renderers/WebGL3DRenderTarget.js';
5
- export { WebGLMultipleRenderTargets } from './renderers/WebGLMultipleRenderTargets.js';
6
5
  export { WebGLCubeRenderTarget } from './renderers/WebGLCubeRenderTarget.js';
7
6
  export { WebGLRenderTarget } from './renderers/WebGLRenderTarget.js';
8
7
  export { WebGLRenderer } from './renderers/WebGLRenderer.js';
@@ -270,9 +270,7 @@ class Audio extends Object3D {
270
270
 
271
271
  this.detune = value;
272
272
 
273
- if ( this.source.detune === undefined ) return; // only set detune when available
274
-
275
- if ( this.isPlaying === true ) {
273
+ if ( this.isPlaying === true && this.source.detune !== undefined ) {
276
274
 
277
275
  this.source.detune.setTargetAtTime( this.detune, this.context.currentTime, 0.01 );
278
276
 
@@ -1,5 +1,12 @@
1
1
  import { Camera } from './Camera.js';
2
2
  import * as MathUtils from '../math/MathUtils.js';
3
+ import { Vector2 } from '../math/Vector2.js';
4
+ import { Vector3 } from '../math/Vector3.js';
5
+
6
+ const _v3 = /*@__PURE__*/ new Vector3();
7
+ const _minTarget = /*@__PURE__*/ new Vector2();
8
+ const _maxTarget = /*@__PURE__*/ new Vector2();
9
+
3
10
 
4
11
  class PerspectiveCamera extends Camera {
5
12
 
@@ -99,6 +106,34 @@ class PerspectiveCamera extends Camera {
99
106
 
100
107
  }
101
108
 
109
+ /**
110
+ * Computes the 2D bounds of the camera's viewable rectangle at a given distance along the viewing direction.
111
+ * Sets minTarget and maxTarget to the coordinates of the lower-left and upper-right corners of the view rectangle.
112
+ */
113
+ getViewBounds( distance, minTarget, maxTarget ) {
114
+
115
+ _v3.set( - 1, - 1, 0.5 ).applyMatrix4( this.projectionMatrixInverse );
116
+
117
+ minTarget.set( _v3.x, _v3.y ).multiplyScalar( - distance / _v3.z );
118
+
119
+ _v3.set( 1, 1, 0.5 ).applyMatrix4( this.projectionMatrixInverse );
120
+
121
+ maxTarget.set( _v3.x, _v3.y ).multiplyScalar( - distance / _v3.z );
122
+
123
+ }
124
+
125
+ /**
126
+ * Computes the width and height of the camera's viewable rectangle at a given distance along the viewing direction.
127
+ * Copies the result into the target Vector2, where x is width and y is height.
128
+ */
129
+ getViewSize( distance, target ) {
130
+
131
+ this.getViewBounds( distance, _minTarget, _maxTarget );
132
+
133
+ return target.subVectors( _maxTarget, _minTarget );
134
+
135
+ }
136
+
102
137
  /**
103
138
  * Sets an offset in a larger frustum. This is useful for multi-window or
104
139
  * multi-monitor/multi-machine setups.
package/src/constants.js CHANGED
@@ -1,4 +1,4 @@
1
- export const REVISION = '160';
1
+ export const REVISION = '162';
2
2
 
3
3
  export const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
4
4
  export const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
@@ -13,7 +13,6 @@ export const VSMShadowMap = 3;
13
13
  export const FrontSide = 0;
14
14
  export const BackSide = 1;
15
15
  export const DoubleSide = 2;
16
- export const TwoPassDoubleSide = 2; // r149
17
16
  export const NoBlending = 0;
18
17
  export const NormalBlending = 1;
19
18
  export const AdditiveBlending = 2;
@@ -58,6 +57,7 @@ export const CineonToneMapping = 3;
58
57
  export const ACESFilmicToneMapping = 4;
59
58
  export const CustomToneMapping = 5;
60
59
  export const AgXToneMapping = 6;
60
+ export const NeutralToneMapping = 7;
61
61
  export const AttachedBindMode = 'attached';
62
62
  export const DetachedBindMode = 'detached';
63
63
 
@@ -149,10 +149,6 @@ export const AdditiveAnimationBlendMode = 2501;
149
149
  export const TrianglesDrawMode = 0;
150
150
  export const TriangleStripDrawMode = 1;
151
151
  export const TriangleFanDrawMode = 2;
152
- /** @deprecated Use LinearSRGBColorSpace or NoColorSpace in three.js r152+. */
153
- export const LinearEncoding = 3000;
154
- /** @deprecated Use SRGBColorSpace in three.js r152+. */
155
- export const sRGBEncoding = 3001;
156
152
  export const BasicDepthPacking = 3200;
157
153
  export const RGBADepthPacking = 3201;
158
154
  export const TangentSpaceNormalMap = 0;
@@ -3,6 +3,7 @@ import { Vector2 } from '../math/Vector2.js';
3
3
  import { denormalize, normalize } from '../math/MathUtils.js';
4
4
  import { StaticDrawUsage, FloatType } from '../constants.js';
5
5
  import { fromHalfFloat, toHalfFloat } from '../extras/DataUtils.js';
6
+ import { warnOnce } from '../utils.js';
6
7
 
7
8
  const _vector = /*@__PURE__*/ new Vector3();
8
9
  const _vector2 = /*@__PURE__*/ new Vector2();
@@ -45,7 +46,7 @@ class BufferAttribute {
45
46
 
46
47
  get updateRange() {
47
48
 
48
- console.warn( 'THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead.' ); // @deprecated, r159
49
+ warnOnce( 'THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead.' ); // @deprecated, r159
49
50
  return this._updateRange;
50
51
 
51
52
  }
@@ -622,20 +623,9 @@ class Float32BufferAttribute extends BufferAttribute {
622
623
 
623
624
  }
624
625
 
625
- class Float64BufferAttribute extends BufferAttribute {
626
-
627
- constructor( array, itemSize, normalized ) {
628
-
629
- super( new Float64Array( array ), itemSize, normalized );
630
-
631
- }
632
-
633
- }
634
-
635
626
  //
636
627
 
637
628
  export {
638
- Float64BufferAttribute,
639
629
  Float32BufferAttribute,
640
630
  Float16BufferAttribute,
641
631
  Uint32BufferAttribute,
@@ -300,7 +300,7 @@ class BufferGeometry extends EventDispatcher {
300
300
 
301
301
  if ( position && position.isGLBufferAttribute ) {
302
302
 
303
- console.error( 'THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".', this );
303
+ console.error( 'THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.', this );
304
304
 
305
305
  this.boundingBox.set(
306
306
  new Vector3( - Infinity, - Infinity, - Infinity ),
@@ -370,7 +370,7 @@ class BufferGeometry extends EventDispatcher {
370
370
 
371
371
  if ( position && position.isGLBufferAttribute ) {
372
372
 
373
- console.error( 'THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".', this );
373
+ console.error( 'THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.', this );
374
374
 
375
375
  this.boundingSphere.set( new Vector3(), Infinity );
376
376
 
@@ -487,24 +487,21 @@ class BufferGeometry extends EventDispatcher {
487
487
 
488
488
  }
489
489
 
490
- const indices = index.array;
491
- const positions = attributes.position.array;
492
- const normals = attributes.normal.array;
493
- const uvs = attributes.uv.array;
494
-
495
- const nVertices = positions.length / 3;
490
+ const positionAttribute = attributes.position;
491
+ const normalAttribute = attributes.normal;
492
+ const uvAttribute = attributes.uv;
496
493
 
497
494
  if ( this.hasAttribute( 'tangent' ) === false ) {
498
495
 
499
- this.setAttribute( 'tangent', new BufferAttribute( new Float32Array( 4 * nVertices ), 4 ) );
496
+ this.setAttribute( 'tangent', new BufferAttribute( new Float32Array( 4 * positionAttribute.count ), 4 ) );
500
497
 
501
498
  }
502
499
 
503
- const tangents = this.getAttribute( 'tangent' ).array;
500
+ const tangentAttribute = this.getAttribute( 'tangent' );
504
501
 
505
502
  const tan1 = [], tan2 = [];
506
503
 
507
- for ( let i = 0; i < nVertices; i ++ ) {
504
+ for ( let i = 0; i < positionAttribute.count; i ++ ) {
508
505
 
509
506
  tan1[ i ] = new Vector3();
510
507
  tan2[ i ] = new Vector3();
@@ -524,13 +521,13 @@ class BufferGeometry extends EventDispatcher {
524
521
 
525
522
  function handleTriangle( a, b, c ) {
526
523
 
527
- vA.fromArray( positions, a * 3 );
528
- vB.fromArray( positions, b * 3 );
529
- vC.fromArray( positions, c * 3 );
524
+ vA.fromBufferAttribute( positionAttribute, a );
525
+ vB.fromBufferAttribute( positionAttribute, b );
526
+ vC.fromBufferAttribute( positionAttribute, c );
530
527
 
531
- uvA.fromArray( uvs, a * 2 );
532
- uvB.fromArray( uvs, b * 2 );
533
- uvC.fromArray( uvs, c * 2 );
528
+ uvA.fromBufferAttribute( uvAttribute, a );
529
+ uvB.fromBufferAttribute( uvAttribute, b );
530
+ uvC.fromBufferAttribute( uvAttribute, c );
534
531
 
535
532
  vB.sub( vA );
536
533
  vC.sub( vA );
@@ -563,7 +560,7 @@ class BufferGeometry extends EventDispatcher {
563
560
 
564
561
  groups = [ {
565
562
  start: 0,
566
- count: indices.length
563
+ count: index.count
567
564
  } ];
568
565
 
569
566
  }
@@ -578,9 +575,9 @@ class BufferGeometry extends EventDispatcher {
578
575
  for ( let j = start, jl = start + count; j < jl; j += 3 ) {
579
576
 
580
577
  handleTriangle(
581
- indices[ j + 0 ],
582
- indices[ j + 1 ],
583
- indices[ j + 2 ]
578
+ index.getX( j + 0 ),
579
+ index.getX( j + 1 ),
580
+ index.getX( j + 2 )
584
581
  );
585
582
 
586
583
  }
@@ -592,7 +589,7 @@ class BufferGeometry extends EventDispatcher {
592
589
 
593
590
  function handleVertex( v ) {
594
591
 
595
- n.fromArray( normals, v * 3 );
592
+ n.fromBufferAttribute( normalAttribute, v );
596
593
  n2.copy( n );
597
594
 
598
595
  const t = tan1[ v ];
@@ -608,10 +605,7 @@ class BufferGeometry extends EventDispatcher {
608
605
  const test = tmp2.dot( tan2[ v ] );
609
606
  const w = ( test < 0.0 ) ? - 1.0 : 1.0;
610
607
 
611
- tangents[ v * 4 ] = tmp.x;
612
- tangents[ v * 4 + 1 ] = tmp.y;
613
- tangents[ v * 4 + 2 ] = tmp.z;
614
- tangents[ v * 4 + 3 ] = w;
608
+ tangentAttribute.setXYZW( v, tmp.x, tmp.y, tmp.z, w );
615
609
 
616
610
  }
617
611
 
@@ -624,9 +618,9 @@ class BufferGeometry extends EventDispatcher {
624
618
 
625
619
  for ( let j = start, jl = start + count; j < jl; j += 3 ) {
626
620
 
627
- handleVertex( indices[ j + 0 ] );
628
- handleVertex( indices[ j + 1 ] );
629
- handleVertex( indices[ j + 2 ] );
621
+ handleVertex( index.getX( j + 0 ) );
622
+ handleVertex( index.getX( j + 1 ) );
623
+ handleVertex( index.getX( j + 2 ) );
630
624
 
631
625
  }
632
626
 
@@ -1,5 +1,6 @@
1
1
  import * as MathUtils from '../math/MathUtils.js';
2
2
  import { StaticDrawUsage } from '../constants.js';
3
+ import { warnOnce } from '../utils.js';
3
4
 
4
5
  class InterleavedBuffer {
5
6
 
@@ -31,7 +32,7 @@ class InterleavedBuffer {
31
32
 
32
33
  get updateRange() {
33
34
 
34
- console.warn( 'THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead.' ); // @deprecated, r159
35
+ warnOnce( 'THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead.' ); // @deprecated, r159
35
36
  return this._updateRange;
36
37
 
37
38
  }
@@ -86,6 +86,26 @@ class InterleavedBufferAttribute {
86
86
 
87
87
  }
88
88
 
89
+ getComponent( index, component ) {
90
+
91
+ let value = this.array[ index * this.data.stride + this.offset + component ];
92
+
93
+ if ( this.normalized ) value = denormalize( value, this.array );
94
+
95
+ return value;
96
+
97
+ }
98
+
99
+ setComponent( index, component, value ) {
100
+
101
+ if ( this.normalized ) value = normalize( value, this.array );
102
+
103
+ this.data.array[ index * this.data.stride + this.offset + component ] = value;
104
+
105
+ return this;
106
+
107
+ }
108
+
89
109
  setX( index, x ) {
90
110
 
91
111
  if ( this.normalized ) x = normalize( x, this.array );
@@ -25,6 +25,9 @@ const _zAxis = /*@__PURE__*/ new Vector3( 0, 0, 1 );
25
25
  const _addedEvent = { type: 'added' };
26
26
  const _removedEvent = { type: 'removed' };
27
27
 
28
+ const _childaddedEvent = { type: 'childadded', child: null };
29
+ const _childremovedEvent = { type: 'childremoved', child: null };
30
+
28
31
  class Object3D extends EventDispatcher {
29
32
 
30
33
  constructor() {
@@ -341,6 +344,10 @@ class Object3D extends EventDispatcher {
341
344
 
342
345
  object.dispatchEvent( _addedEvent );
343
346
 
347
+ _childaddedEvent.child = object;
348
+ this.dispatchEvent( _childaddedEvent );
349
+ _childaddedEvent.child = null;
350
+
344
351
  } else {
345
352
 
346
353
  console.error( 'THREE.Object3D.add: object not an instance of THREE.Object3D.', object );
@@ -374,6 +381,10 @@ class Object3D extends EventDispatcher {
374
381
 
375
382
  object.dispatchEvent( _removedEvent );
376
383
 
384
+ _childremovedEvent.child = object;
385
+ this.dispatchEvent( _childremovedEvent );
386
+ _childremovedEvent.child = null;
387
+
377
388
  }
378
389
 
379
390
  return this;
@@ -1,6 +1,9 @@
1
+ import { Matrix4 } from '../math/Matrix4.js';
1
2
  import { Ray } from '../math/Ray.js';
2
3
  import { Layers } from './Layers.js';
3
4
 
5
+ const _matrix = /*@__PURE__*/ new Matrix4();
6
+
4
7
  class Raycaster {
5
8
 
6
9
  constructor( origin, direction, near = 0, far = Infinity ) {
@@ -53,9 +56,20 @@ class Raycaster {
53
56
 
54
57
  }
55
58
 
59
+ setFromXRController( controller ) {
60
+
61
+ _matrix.identity().extractRotation( controller.matrixWorld );
62
+
63
+ this.ray.origin.setFromMatrixPosition( controller.matrixWorld );
64
+ this.ray.direction.set( 0, 0, - 1 ).applyMatrix4( _matrix );
65
+
66
+ return this;
67
+
68
+ }
69
+
56
70
  intersectObject( object, recursive = true, intersects = [] ) {
57
71
 
58
- intersectObject( object, this, intersects, recursive );
72
+ intersect( object, this, intersects, recursive );
59
73
 
60
74
  intersects.sort( ascSort );
61
75
 
@@ -67,7 +81,7 @@ class Raycaster {
67
81
 
68
82
  for ( let i = 0, l = objects.length; i < l; i ++ ) {
69
83
 
70
- intersectObject( objects[ i ], this, intersects, recursive );
84
+ intersect( objects[ i ], this, intersects, recursive );
71
85
 
72
86
  }
73
87
 
@@ -85,7 +99,7 @@ function ascSort( a, b ) {
85
99
 
86
100
  }
87
101
 
88
- function intersectObject( object, raycaster, intersects, recursive ) {
102
+ function intersect( object, raycaster, intersects, recursive ) {
89
103
 
90
104
  if ( object.layers.test( raycaster.layers ) ) {
91
105
 
@@ -99,7 +113,7 @@ function intersectObject( object, raycaster, intersects, recursive ) {
99
113
 
100
114
  for ( let i = 0, l = children.length; i < l; i ++ ) {
101
115
 
102
- intersectObject( children[ i ], raycaster, intersects, true );
116
+ intersect( children[ i ], raycaster, intersects, true );
103
117
 
104
118
  }
105
119